File: /home/imagzxcb/public_html/db127a/include.tar
xcb/dri3.h 0000644 00000057261 15201526705 0006350 0 ustar 00 /*
* This file generated automatically from dri3.xml by c_client.py.
* Edit at your peril.
*/
/**
* @defgroup XCB_DRI3_API XCB DRI3 API
* @brief DRI3 XCB Protocol Implementation.
* @{
**/
#ifndef __DRI3_H
#define __DRI3_H
#include "xcb.h"
#include "xproto.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XCB_DRI3_MAJOR_VERSION 1
#define XCB_DRI3_MINOR_VERSION 2
extern xcb_extension_t xcb_dri3_id;
/**
* @brief xcb_dri3_query_version_cookie_t
**/
typedef struct xcb_dri3_query_version_cookie_t {
unsigned int sequence;
} xcb_dri3_query_version_cookie_t;
/** Opcode for xcb_dri3_query_version. */
#define XCB_DRI3_QUERY_VERSION 0
/**
* @brief xcb_dri3_query_version_request_t
**/
typedef struct xcb_dri3_query_version_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t major_version;
uint32_t minor_version;
} xcb_dri3_query_version_request_t;
/**
* @brief xcb_dri3_query_version_reply_t
**/
typedef struct xcb_dri3_query_version_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t major_version;
uint32_t minor_version;
} xcb_dri3_query_version_reply_t;
/**
* @brief xcb_dri3_open_cookie_t
**/
typedef struct xcb_dri3_open_cookie_t {
unsigned int sequence;
} xcb_dri3_open_cookie_t;
/** Opcode for xcb_dri3_open. */
#define XCB_DRI3_OPEN 1
/**
* @brief xcb_dri3_open_request_t
**/
typedef struct xcb_dri3_open_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_drawable_t drawable;
uint32_t provider;
} xcb_dri3_open_request_t;
/**
* @brief xcb_dri3_open_reply_t
**/
typedef struct xcb_dri3_open_reply_t {
uint8_t response_type;
uint8_t nfd;
uint16_t sequence;
uint32_t length;
uint8_t pad0[24];
} xcb_dri3_open_reply_t;
/** Opcode for xcb_dri3_pixmap_from_buffer. */
#define XCB_DRI3_PIXMAP_FROM_BUFFER 2
/**
* @brief xcb_dri3_pixmap_from_buffer_request_t
**/
typedef struct xcb_dri3_pixmap_from_buffer_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_pixmap_t pixmap;
xcb_drawable_t drawable;
uint32_t size;
uint16_t width;
uint16_t height;
uint16_t stride;
uint8_t depth;
uint8_t bpp;
} xcb_dri3_pixmap_from_buffer_request_t;
/**
* @brief xcb_dri3_buffer_from_pixmap_cookie_t
**/
typedef struct xcb_dri3_buffer_from_pixmap_cookie_t {
unsigned int sequence;
} xcb_dri3_buffer_from_pixmap_cookie_t;
/** Opcode for xcb_dri3_buffer_from_pixmap. */
#define XCB_DRI3_BUFFER_FROM_PIXMAP 3
/**
* @brief xcb_dri3_buffer_from_pixmap_request_t
**/
typedef struct xcb_dri3_buffer_from_pixmap_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_pixmap_t pixmap;
} xcb_dri3_buffer_from_pixmap_request_t;
/**
* @brief xcb_dri3_buffer_from_pixmap_reply_t
**/
typedef struct xcb_dri3_buffer_from_pixmap_reply_t {
uint8_t response_type;
uint8_t nfd;
uint16_t sequence;
uint32_t length;
uint32_t size;
uint16_t width;
uint16_t height;
uint16_t stride;
uint8_t depth;
uint8_t bpp;
uint8_t pad0[12];
} xcb_dri3_buffer_from_pixmap_reply_t;
/** Opcode for xcb_dri3_fence_from_fd. */
#define XCB_DRI3_FENCE_FROM_FD 4
/**
* @brief xcb_dri3_fence_from_fd_request_t
**/
typedef struct xcb_dri3_fence_from_fd_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_drawable_t drawable;
uint32_t fence;
uint8_t initially_triggered;
uint8_t pad0[3];
} xcb_dri3_fence_from_fd_request_t;
/**
* @brief xcb_dri3_fd_from_fence_cookie_t
**/
typedef struct xcb_dri3_fd_from_fence_cookie_t {
unsigned int sequence;
} xcb_dri3_fd_from_fence_cookie_t;
/** Opcode for xcb_dri3_fd_from_fence. */
#define XCB_DRI3_FD_FROM_FENCE 5
/**
* @brief xcb_dri3_fd_from_fence_request_t
**/
typedef struct xcb_dri3_fd_from_fence_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_drawable_t drawable;
uint32_t fence;
} xcb_dri3_fd_from_fence_request_t;
/**
* @brief xcb_dri3_fd_from_fence_reply_t
**/
typedef struct xcb_dri3_fd_from_fence_reply_t {
uint8_t response_type;
uint8_t nfd;
uint16_t sequence;
uint32_t length;
uint8_t pad0[24];
} xcb_dri3_fd_from_fence_reply_t;
/**
* @brief xcb_dri3_get_supported_modifiers_cookie_t
**/
typedef struct xcb_dri3_get_supported_modifiers_cookie_t {
unsigned int sequence;
} xcb_dri3_get_supported_modifiers_cookie_t;
/** Opcode for xcb_dri3_get_supported_modifiers. */
#define XCB_DRI3_GET_SUPPORTED_MODIFIERS 6
/**
* @brief xcb_dri3_get_supported_modifiers_request_t
**/
typedef struct xcb_dri3_get_supported_modifiers_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t window;
uint8_t depth;
uint8_t bpp;
uint8_t pad0[2];
} xcb_dri3_get_supported_modifiers_request_t;
/**
* @brief xcb_dri3_get_supported_modifiers_reply_t
**/
typedef struct xcb_dri3_get_supported_modifiers_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t num_window_modifiers;
uint32_t num_screen_modifiers;
uint8_t pad1[16];
} xcb_dri3_get_supported_modifiers_reply_t;
/** Opcode for xcb_dri3_pixmap_from_buffers. */
#define XCB_DRI3_PIXMAP_FROM_BUFFERS 7
/**
* @brief xcb_dri3_pixmap_from_buffers_request_t
**/
typedef struct xcb_dri3_pixmap_from_buffers_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_pixmap_t pixmap;
xcb_window_t window;
uint8_t num_buffers;
uint8_t pad0[3];
uint16_t width;
uint16_t height;
uint32_t stride0;
uint32_t offset0;
uint32_t stride1;
uint32_t offset1;
uint32_t stride2;
uint32_t offset2;
uint32_t stride3;
uint32_t offset3;
uint8_t depth;
uint8_t bpp;
uint8_t pad1[2];
uint64_t modifier;
} xcb_dri3_pixmap_from_buffers_request_t;
/**
* @brief xcb_dri3_buffers_from_pixmap_cookie_t
**/
typedef struct xcb_dri3_buffers_from_pixmap_cookie_t {
unsigned int sequence;
} xcb_dri3_buffers_from_pixmap_cookie_t;
/** Opcode for xcb_dri3_buffers_from_pixmap. */
#define XCB_DRI3_BUFFERS_FROM_PIXMAP 8
/**
* @brief xcb_dri3_buffers_from_pixmap_request_t
**/
typedef struct xcb_dri3_buffers_from_pixmap_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_pixmap_t pixmap;
} xcb_dri3_buffers_from_pixmap_request_t;
/**
* @brief xcb_dri3_buffers_from_pixmap_reply_t
**/
typedef struct xcb_dri3_buffers_from_pixmap_reply_t {
uint8_t response_type;
uint8_t nfd;
uint16_t sequence;
uint32_t length;
uint16_t width;
uint16_t height;
uint8_t pad0[4];
uint64_t modifier;
uint8_t depth;
uint8_t bpp;
uint8_t pad1[6];
} xcb_dri3_buffers_from_pixmap_reply_t;
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_dri3_query_version_cookie_t
xcb_dri3_query_version (xcb_connection_t *c,
uint32_t major_version,
uint32_t minor_version);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_dri3_query_version_cookie_t
xcb_dri3_query_version_unchecked (xcb_connection_t *c,
uint32_t major_version,
uint32_t minor_version);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_dri3_query_version_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_dri3_query_version_reply_t *
xcb_dri3_query_version_reply (xcb_connection_t *c,
xcb_dri3_query_version_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_dri3_open_cookie_t
xcb_dri3_open (xcb_connection_t *c,
xcb_drawable_t drawable,
uint32_t provider);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_dri3_open_cookie_t
xcb_dri3_open_unchecked (xcb_connection_t *c,
xcb_drawable_t drawable,
uint32_t provider);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_dri3_open_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_dri3_open_reply_t *
xcb_dri3_open_reply (xcb_connection_t *c,
xcb_dri3_open_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
* Return the reply fds
* @param c The connection
* @param reply The reply
*
* Returns the array of reply fds of the request asked by
*
* The returned value must be freed by the caller using free().
*/
int *
xcb_dri3_open_reply_fds (xcb_connection_t *c /**< */,
xcb_dri3_open_reply_t *reply);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_dri3_pixmap_from_buffer_checked (xcb_connection_t *c,
xcb_pixmap_t pixmap,
xcb_drawable_t drawable,
uint32_t size,
uint16_t width,
uint16_t height,
uint16_t stride,
uint8_t depth,
uint8_t bpp,
int32_t pixmap_fd);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_dri3_pixmap_from_buffer (xcb_connection_t *c,
xcb_pixmap_t pixmap,
xcb_drawable_t drawable,
uint32_t size,
uint16_t width,
uint16_t height,
uint16_t stride,
uint8_t depth,
uint8_t bpp,
int32_t pixmap_fd);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_dri3_buffer_from_pixmap_cookie_t
xcb_dri3_buffer_from_pixmap (xcb_connection_t *c,
xcb_pixmap_t pixmap);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_dri3_buffer_from_pixmap_cookie_t
xcb_dri3_buffer_from_pixmap_unchecked (xcb_connection_t *c,
xcb_pixmap_t pixmap);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_dri3_buffer_from_pixmap_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_dri3_buffer_from_pixmap_reply_t *
xcb_dri3_buffer_from_pixmap_reply (xcb_connection_t *c,
xcb_dri3_buffer_from_pixmap_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
* Return the reply fds
* @param c The connection
* @param reply The reply
*
* Returns the array of reply fds of the request asked by
*
* The returned value must be freed by the caller using free().
*/
int *
xcb_dri3_buffer_from_pixmap_reply_fds (xcb_connection_t *c /**< */,
xcb_dri3_buffer_from_pixmap_reply_t *reply);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_dri3_fence_from_fd_checked (xcb_connection_t *c,
xcb_drawable_t drawable,
uint32_t fence,
uint8_t initially_triggered,
int32_t fence_fd);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_dri3_fence_from_fd (xcb_connection_t *c,
xcb_drawable_t drawable,
uint32_t fence,
uint8_t initially_triggered,
int32_t fence_fd);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_dri3_fd_from_fence_cookie_t
xcb_dri3_fd_from_fence (xcb_connection_t *c,
xcb_drawable_t drawable,
uint32_t fence);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_dri3_fd_from_fence_cookie_t
xcb_dri3_fd_from_fence_unchecked (xcb_connection_t *c,
xcb_drawable_t drawable,
uint32_t fence);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_dri3_fd_from_fence_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_dri3_fd_from_fence_reply_t *
xcb_dri3_fd_from_fence_reply (xcb_connection_t *c,
xcb_dri3_fd_from_fence_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
* Return the reply fds
* @param c The connection
* @param reply The reply
*
* Returns the array of reply fds of the request asked by
*
* The returned value must be freed by the caller using free().
*/
int *
xcb_dri3_fd_from_fence_reply_fds (xcb_connection_t *c /**< */,
xcb_dri3_fd_from_fence_reply_t *reply);
int
xcb_dri3_get_supported_modifiers_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_dri3_get_supported_modifiers_cookie_t
xcb_dri3_get_supported_modifiers (xcb_connection_t *c,
uint32_t window,
uint8_t depth,
uint8_t bpp);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_dri3_get_supported_modifiers_cookie_t
xcb_dri3_get_supported_modifiers_unchecked (xcb_connection_t *c,
uint32_t window,
uint8_t depth,
uint8_t bpp);
uint64_t *
xcb_dri3_get_supported_modifiers_window_modifiers (const xcb_dri3_get_supported_modifiers_reply_t *R);
int
xcb_dri3_get_supported_modifiers_window_modifiers_length (const xcb_dri3_get_supported_modifiers_reply_t *R);
xcb_generic_iterator_t
xcb_dri3_get_supported_modifiers_window_modifiers_end (const xcb_dri3_get_supported_modifiers_reply_t *R);
uint64_t *
xcb_dri3_get_supported_modifiers_screen_modifiers (const xcb_dri3_get_supported_modifiers_reply_t *R);
int
xcb_dri3_get_supported_modifiers_screen_modifiers_length (const xcb_dri3_get_supported_modifiers_reply_t *R);
xcb_generic_iterator_t
xcb_dri3_get_supported_modifiers_screen_modifiers_end (const xcb_dri3_get_supported_modifiers_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_dri3_get_supported_modifiers_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_dri3_get_supported_modifiers_reply_t *
xcb_dri3_get_supported_modifiers_reply (xcb_connection_t *c,
xcb_dri3_get_supported_modifiers_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_dri3_pixmap_from_buffers_checked (xcb_connection_t *c,
xcb_pixmap_t pixmap,
xcb_window_t window,
uint8_t num_buffers,
uint16_t width,
uint16_t height,
uint32_t stride0,
uint32_t offset0,
uint32_t stride1,
uint32_t offset1,
uint32_t stride2,
uint32_t offset2,
uint32_t stride3,
uint32_t offset3,
uint8_t depth,
uint8_t bpp,
uint64_t modifier,
const int32_t *buffers);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_dri3_pixmap_from_buffers (xcb_connection_t *c,
xcb_pixmap_t pixmap,
xcb_window_t window,
uint8_t num_buffers,
uint16_t width,
uint16_t height,
uint32_t stride0,
uint32_t offset0,
uint32_t stride1,
uint32_t offset1,
uint32_t stride2,
uint32_t offset2,
uint32_t stride3,
uint32_t offset3,
uint8_t depth,
uint8_t bpp,
uint64_t modifier,
const int32_t *buffers);
int
xcb_dri3_buffers_from_pixmap_sizeof (const void *_buffer,
int32_t buffers);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_dri3_buffers_from_pixmap_cookie_t
xcb_dri3_buffers_from_pixmap (xcb_connection_t *c,
xcb_pixmap_t pixmap);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_dri3_buffers_from_pixmap_cookie_t
xcb_dri3_buffers_from_pixmap_unchecked (xcb_connection_t *c,
xcb_pixmap_t pixmap);
uint32_t *
xcb_dri3_buffers_from_pixmap_strides (const xcb_dri3_buffers_from_pixmap_reply_t *R);
int
xcb_dri3_buffers_from_pixmap_strides_length (const xcb_dri3_buffers_from_pixmap_reply_t *R);
xcb_generic_iterator_t
xcb_dri3_buffers_from_pixmap_strides_end (const xcb_dri3_buffers_from_pixmap_reply_t *R);
uint32_t *
xcb_dri3_buffers_from_pixmap_offsets (const xcb_dri3_buffers_from_pixmap_reply_t *R);
int
xcb_dri3_buffers_from_pixmap_offsets_length (const xcb_dri3_buffers_from_pixmap_reply_t *R);
xcb_generic_iterator_t
xcb_dri3_buffers_from_pixmap_offsets_end (const xcb_dri3_buffers_from_pixmap_reply_t *R);
int32_t *
xcb_dri3_buffers_from_pixmap_buffers (const xcb_dri3_buffers_from_pixmap_reply_t *R);
int
xcb_dri3_buffers_from_pixmap_buffers_length (const xcb_dri3_buffers_from_pixmap_reply_t *R);
xcb_generic_iterator_t
xcb_dri3_buffers_from_pixmap_buffers_end (const xcb_dri3_buffers_from_pixmap_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_dri3_buffers_from_pixmap_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_dri3_buffers_from_pixmap_reply_t *
xcb_dri3_buffers_from_pixmap_reply (xcb_connection_t *c,
xcb_dri3_buffers_from_pixmap_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
* Return the reply fds
* @param c The connection
* @param reply The reply
*
* Returns the array of reply fds of the request asked by
*
* The returned value must be freed by the caller using free().
*/
int *
xcb_dri3_buffers_from_pixmap_reply_fds (xcb_connection_t *c /**< */,
xcb_dri3_buffers_from_pixmap_reply_t *reply);
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/
xcb/render.h 0000644 00000312456 15201526705 0006766 0 ustar 00 /*
* This file generated automatically from render.xml by c_client.py.
* Edit at your peril.
*/
/**
* @defgroup XCB_Render_API XCB Render API
* @brief Render XCB Protocol Implementation.
* @{
**/
#ifndef __RENDER_H
#define __RENDER_H
#include "xcb.h"
#include "xproto.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XCB_RENDER_MAJOR_VERSION 0
#define XCB_RENDER_MINOR_VERSION 11
extern xcb_extension_t xcb_render_id;
typedef enum xcb_render_pict_type_t {
XCB_RENDER_PICT_TYPE_INDEXED = 0,
XCB_RENDER_PICT_TYPE_DIRECT = 1
} xcb_render_pict_type_t;
typedef enum xcb_render_picture_enum_t {
XCB_RENDER_PICTURE_NONE = 0
} xcb_render_picture_enum_t;
typedef enum xcb_render_pict_op_t {
XCB_RENDER_PICT_OP_CLEAR = 0,
XCB_RENDER_PICT_OP_SRC = 1,
XCB_RENDER_PICT_OP_DST = 2,
XCB_RENDER_PICT_OP_OVER = 3,
XCB_RENDER_PICT_OP_OVER_REVERSE = 4,
XCB_RENDER_PICT_OP_IN = 5,
XCB_RENDER_PICT_OP_IN_REVERSE = 6,
XCB_RENDER_PICT_OP_OUT = 7,
XCB_RENDER_PICT_OP_OUT_REVERSE = 8,
XCB_RENDER_PICT_OP_ATOP = 9,
XCB_RENDER_PICT_OP_ATOP_REVERSE = 10,
XCB_RENDER_PICT_OP_XOR = 11,
XCB_RENDER_PICT_OP_ADD = 12,
XCB_RENDER_PICT_OP_SATURATE = 13,
XCB_RENDER_PICT_OP_DISJOINT_CLEAR = 16,
XCB_RENDER_PICT_OP_DISJOINT_SRC = 17,
XCB_RENDER_PICT_OP_DISJOINT_DST = 18,
XCB_RENDER_PICT_OP_DISJOINT_OVER = 19,
XCB_RENDER_PICT_OP_DISJOINT_OVER_REVERSE = 20,
XCB_RENDER_PICT_OP_DISJOINT_IN = 21,
XCB_RENDER_PICT_OP_DISJOINT_IN_REVERSE = 22,
XCB_RENDER_PICT_OP_DISJOINT_OUT = 23,
XCB_RENDER_PICT_OP_DISJOINT_OUT_REVERSE = 24,
XCB_RENDER_PICT_OP_DISJOINT_ATOP = 25,
XCB_RENDER_PICT_OP_DISJOINT_ATOP_REVERSE = 26,
XCB_RENDER_PICT_OP_DISJOINT_XOR = 27,
XCB_RENDER_PICT_OP_CONJOINT_CLEAR = 32,
XCB_RENDER_PICT_OP_CONJOINT_SRC = 33,
XCB_RENDER_PICT_OP_CONJOINT_DST = 34,
XCB_RENDER_PICT_OP_CONJOINT_OVER = 35,
XCB_RENDER_PICT_OP_CONJOINT_OVER_REVERSE = 36,
XCB_RENDER_PICT_OP_CONJOINT_IN = 37,
XCB_RENDER_PICT_OP_CONJOINT_IN_REVERSE = 38,
XCB_RENDER_PICT_OP_CONJOINT_OUT = 39,
XCB_RENDER_PICT_OP_CONJOINT_OUT_REVERSE = 40,
XCB_RENDER_PICT_OP_CONJOINT_ATOP = 41,
XCB_RENDER_PICT_OP_CONJOINT_ATOP_REVERSE = 42,
XCB_RENDER_PICT_OP_CONJOINT_XOR = 43,
XCB_RENDER_PICT_OP_MULTIPLY = 48,
XCB_RENDER_PICT_OP_SCREEN = 49,
XCB_RENDER_PICT_OP_OVERLAY = 50,
XCB_RENDER_PICT_OP_DARKEN = 51,
XCB_RENDER_PICT_OP_LIGHTEN = 52,
XCB_RENDER_PICT_OP_COLOR_DODGE = 53,
XCB_RENDER_PICT_OP_COLOR_BURN = 54,
XCB_RENDER_PICT_OP_HARD_LIGHT = 55,
XCB_RENDER_PICT_OP_SOFT_LIGHT = 56,
XCB_RENDER_PICT_OP_DIFFERENCE = 57,
XCB_RENDER_PICT_OP_EXCLUSION = 58,
XCB_RENDER_PICT_OP_HSL_HUE = 59,
XCB_RENDER_PICT_OP_HSL_SATURATION = 60,
XCB_RENDER_PICT_OP_HSL_COLOR = 61,
XCB_RENDER_PICT_OP_HSL_LUMINOSITY = 62
} xcb_render_pict_op_t;
typedef enum xcb_render_poly_edge_t {
XCB_RENDER_POLY_EDGE_SHARP = 0,
XCB_RENDER_POLY_EDGE_SMOOTH = 1
} xcb_render_poly_edge_t;
typedef enum xcb_render_poly_mode_t {
XCB_RENDER_POLY_MODE_PRECISE = 0,
XCB_RENDER_POLY_MODE_IMPRECISE = 1
} xcb_render_poly_mode_t;
typedef enum xcb_render_cp_t {
XCB_RENDER_CP_REPEAT = 1,
XCB_RENDER_CP_ALPHA_MAP = 2,
XCB_RENDER_CP_ALPHA_X_ORIGIN = 4,
XCB_RENDER_CP_ALPHA_Y_ORIGIN = 8,
XCB_RENDER_CP_CLIP_X_ORIGIN = 16,
XCB_RENDER_CP_CLIP_Y_ORIGIN = 32,
XCB_RENDER_CP_CLIP_MASK = 64,
XCB_RENDER_CP_GRAPHICS_EXPOSURE = 128,
XCB_RENDER_CP_SUBWINDOW_MODE = 256,
XCB_RENDER_CP_POLY_EDGE = 512,
XCB_RENDER_CP_POLY_MODE = 1024,
XCB_RENDER_CP_DITHER = 2048,
XCB_RENDER_CP_COMPONENT_ALPHA = 4096
} xcb_render_cp_t;
typedef enum xcb_render_sub_pixel_t {
XCB_RENDER_SUB_PIXEL_UNKNOWN = 0,
XCB_RENDER_SUB_PIXEL_HORIZONTAL_RGB = 1,
XCB_RENDER_SUB_PIXEL_HORIZONTAL_BGR = 2,
XCB_RENDER_SUB_PIXEL_VERTICAL_RGB = 3,
XCB_RENDER_SUB_PIXEL_VERTICAL_BGR = 4,
XCB_RENDER_SUB_PIXEL_NONE = 5
} xcb_render_sub_pixel_t;
typedef enum xcb_render_repeat_t {
XCB_RENDER_REPEAT_NONE = 0,
XCB_RENDER_REPEAT_NORMAL = 1,
XCB_RENDER_REPEAT_PAD = 2,
XCB_RENDER_REPEAT_REFLECT = 3
} xcb_render_repeat_t;
typedef uint32_t xcb_render_glyph_t;
/**
* @brief xcb_render_glyph_iterator_t
**/
typedef struct xcb_render_glyph_iterator_t {
xcb_render_glyph_t *data;
int rem;
int index;
} xcb_render_glyph_iterator_t;
typedef uint32_t xcb_render_glyphset_t;
/**
* @brief xcb_render_glyphset_iterator_t
**/
typedef struct xcb_render_glyphset_iterator_t {
xcb_render_glyphset_t *data;
int rem;
int index;
} xcb_render_glyphset_iterator_t;
typedef uint32_t xcb_render_picture_t;
/**
* @brief xcb_render_picture_iterator_t
**/
typedef struct xcb_render_picture_iterator_t {
xcb_render_picture_t *data;
int rem;
int index;
} xcb_render_picture_iterator_t;
typedef uint32_t xcb_render_pictformat_t;
/**
* @brief xcb_render_pictformat_iterator_t
**/
typedef struct xcb_render_pictformat_iterator_t {
xcb_render_pictformat_t *data;
int rem;
int index;
} xcb_render_pictformat_iterator_t;
typedef int32_t xcb_render_fixed_t;
/**
* @brief xcb_render_fixed_iterator_t
**/
typedef struct xcb_render_fixed_iterator_t {
xcb_render_fixed_t *data;
int rem;
int index;
} xcb_render_fixed_iterator_t;
/** Opcode for xcb_render_pict_format. */
#define XCB_RENDER_PICT_FORMAT 0
/**
* @brief xcb_render_pict_format_error_t
**/
typedef struct xcb_render_pict_format_error_t {
uint8_t response_type;
uint8_t error_code;
uint16_t sequence;
} xcb_render_pict_format_error_t;
/** Opcode for xcb_render_picture. */
#define XCB_RENDER_PICTURE 1
/**
* @brief xcb_render_picture_error_t
**/
typedef struct xcb_render_picture_error_t {
uint8_t response_type;
uint8_t error_code;
uint16_t sequence;
} xcb_render_picture_error_t;
/** Opcode for xcb_render_pict_op. */
#define XCB_RENDER_PICT_OP 2
/**
* @brief xcb_render_pict_op_error_t
**/
typedef struct xcb_render_pict_op_error_t {
uint8_t response_type;
uint8_t error_code;
uint16_t sequence;
} xcb_render_pict_op_error_t;
/** Opcode for xcb_render_glyph_set. */
#define XCB_RENDER_GLYPH_SET 3
/**
* @brief xcb_render_glyph_set_error_t
**/
typedef struct xcb_render_glyph_set_error_t {
uint8_t response_type;
uint8_t error_code;
uint16_t sequence;
} xcb_render_glyph_set_error_t;
/** Opcode for xcb_render_glyph. */
#define XCB_RENDER_GLYPH 4
/**
* @brief xcb_render_glyph_error_t
**/
typedef struct xcb_render_glyph_error_t {
uint8_t response_type;
uint8_t error_code;
uint16_t sequence;
} xcb_render_glyph_error_t;
/**
* @brief xcb_render_directformat_t
**/
typedef struct xcb_render_directformat_t {
uint16_t red_shift;
uint16_t red_mask;
uint16_t green_shift;
uint16_t green_mask;
uint16_t blue_shift;
uint16_t blue_mask;
uint16_t alpha_shift;
uint16_t alpha_mask;
} xcb_render_directformat_t;
/**
* @brief xcb_render_directformat_iterator_t
**/
typedef struct xcb_render_directformat_iterator_t {
xcb_render_directformat_t *data;
int rem;
int index;
} xcb_render_directformat_iterator_t;
/**
* @brief xcb_render_pictforminfo_t
**/
typedef struct xcb_render_pictforminfo_t {
xcb_render_pictformat_t id;
uint8_t type;
uint8_t depth;
uint8_t pad0[2];
xcb_render_directformat_t direct;
xcb_colormap_t colormap;
} xcb_render_pictforminfo_t;
/**
* @brief xcb_render_pictforminfo_iterator_t
**/
typedef struct xcb_render_pictforminfo_iterator_t {
xcb_render_pictforminfo_t *data;
int rem;
int index;
} xcb_render_pictforminfo_iterator_t;
/**
* @brief xcb_render_pictvisual_t
**/
typedef struct xcb_render_pictvisual_t {
xcb_visualid_t visual;
xcb_render_pictformat_t format;
} xcb_render_pictvisual_t;
/**
* @brief xcb_render_pictvisual_iterator_t
**/
typedef struct xcb_render_pictvisual_iterator_t {
xcb_render_pictvisual_t *data;
int rem;
int index;
} xcb_render_pictvisual_iterator_t;
/**
* @brief xcb_render_pictdepth_t
**/
typedef struct xcb_render_pictdepth_t {
uint8_t depth;
uint8_t pad0;
uint16_t num_visuals;
uint8_t pad1[4];
} xcb_render_pictdepth_t;
/**
* @brief xcb_render_pictdepth_iterator_t
**/
typedef struct xcb_render_pictdepth_iterator_t {
xcb_render_pictdepth_t *data;
int rem;
int index;
} xcb_render_pictdepth_iterator_t;
/**
* @brief xcb_render_pictscreen_t
**/
typedef struct xcb_render_pictscreen_t {
uint32_t num_depths;
xcb_render_pictformat_t fallback;
} xcb_render_pictscreen_t;
/**
* @brief xcb_render_pictscreen_iterator_t
**/
typedef struct xcb_render_pictscreen_iterator_t {
xcb_render_pictscreen_t *data;
int rem;
int index;
} xcb_render_pictscreen_iterator_t;
/**
* @brief xcb_render_indexvalue_t
**/
typedef struct xcb_render_indexvalue_t {
uint32_t pixel;
uint16_t red;
uint16_t green;
uint16_t blue;
uint16_t alpha;
} xcb_render_indexvalue_t;
/**
* @brief xcb_render_indexvalue_iterator_t
**/
typedef struct xcb_render_indexvalue_iterator_t {
xcb_render_indexvalue_t *data;
int rem;
int index;
} xcb_render_indexvalue_iterator_t;
/**
* @brief xcb_render_color_t
**/
typedef struct xcb_render_color_t {
uint16_t red;
uint16_t green;
uint16_t blue;
uint16_t alpha;
} xcb_render_color_t;
/**
* @brief xcb_render_color_iterator_t
**/
typedef struct xcb_render_color_iterator_t {
xcb_render_color_t *data;
int rem;
int index;
} xcb_render_color_iterator_t;
/**
* @brief xcb_render_pointfix_t
**/
typedef struct xcb_render_pointfix_t {
xcb_render_fixed_t x;
xcb_render_fixed_t y;
} xcb_render_pointfix_t;
/**
* @brief xcb_render_pointfix_iterator_t
**/
typedef struct xcb_render_pointfix_iterator_t {
xcb_render_pointfix_t *data;
int rem;
int index;
} xcb_render_pointfix_iterator_t;
/**
* @brief xcb_render_linefix_t
**/
typedef struct xcb_render_linefix_t {
xcb_render_pointfix_t p1;
xcb_render_pointfix_t p2;
} xcb_render_linefix_t;
/**
* @brief xcb_render_linefix_iterator_t
**/
typedef struct xcb_render_linefix_iterator_t {
xcb_render_linefix_t *data;
int rem;
int index;
} xcb_render_linefix_iterator_t;
/**
* @brief xcb_render_triangle_t
**/
typedef struct xcb_render_triangle_t {
xcb_render_pointfix_t p1;
xcb_render_pointfix_t p2;
xcb_render_pointfix_t p3;
} xcb_render_triangle_t;
/**
* @brief xcb_render_triangle_iterator_t
**/
typedef struct xcb_render_triangle_iterator_t {
xcb_render_triangle_t *data;
int rem;
int index;
} xcb_render_triangle_iterator_t;
/**
* @brief xcb_render_trapezoid_t
**/
typedef struct xcb_render_trapezoid_t {
xcb_render_fixed_t top;
xcb_render_fixed_t bottom;
xcb_render_linefix_t left;
xcb_render_linefix_t right;
} xcb_render_trapezoid_t;
/**
* @brief xcb_render_trapezoid_iterator_t
**/
typedef struct xcb_render_trapezoid_iterator_t {
xcb_render_trapezoid_t *data;
int rem;
int index;
} xcb_render_trapezoid_iterator_t;
/**
* @brief xcb_render_glyphinfo_t
**/
typedef struct xcb_render_glyphinfo_t {
uint16_t width;
uint16_t height;
int16_t x;
int16_t y;
int16_t x_off;
int16_t y_off;
} xcb_render_glyphinfo_t;
/**
* @brief xcb_render_glyphinfo_iterator_t
**/
typedef struct xcb_render_glyphinfo_iterator_t {
xcb_render_glyphinfo_t *data;
int rem;
int index;
} xcb_render_glyphinfo_iterator_t;
/**
* @brief xcb_render_query_version_cookie_t
**/
typedef struct xcb_render_query_version_cookie_t {
unsigned int sequence;
} xcb_render_query_version_cookie_t;
/** Opcode for xcb_render_query_version. */
#define XCB_RENDER_QUERY_VERSION 0
/**
* @brief xcb_render_query_version_request_t
**/
typedef struct xcb_render_query_version_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t client_major_version;
uint32_t client_minor_version;
} xcb_render_query_version_request_t;
/**
* @brief xcb_render_query_version_reply_t
**/
typedef struct xcb_render_query_version_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t major_version;
uint32_t minor_version;
uint8_t pad1[16];
} xcb_render_query_version_reply_t;
/**
* @brief xcb_render_query_pict_formats_cookie_t
**/
typedef struct xcb_render_query_pict_formats_cookie_t {
unsigned int sequence;
} xcb_render_query_pict_formats_cookie_t;
/** Opcode for xcb_render_query_pict_formats. */
#define XCB_RENDER_QUERY_PICT_FORMATS 1
/**
* @brief xcb_render_query_pict_formats_request_t
**/
typedef struct xcb_render_query_pict_formats_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_render_query_pict_formats_request_t;
/**
* @brief xcb_render_query_pict_formats_reply_t
**/
typedef struct xcb_render_query_pict_formats_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t num_formats;
uint32_t num_screens;
uint32_t num_depths;
uint32_t num_visuals;
uint32_t num_subpixel;
uint8_t pad1[4];
} xcb_render_query_pict_formats_reply_t;
/**
* @brief xcb_render_query_pict_index_values_cookie_t
**/
typedef struct xcb_render_query_pict_index_values_cookie_t {
unsigned int sequence;
} xcb_render_query_pict_index_values_cookie_t;
/** Opcode for xcb_render_query_pict_index_values. */
#define XCB_RENDER_QUERY_PICT_INDEX_VALUES 2
/**
* @brief xcb_render_query_pict_index_values_request_t
**/
typedef struct xcb_render_query_pict_index_values_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_render_pictformat_t format;
} xcb_render_query_pict_index_values_request_t;
/**
* @brief xcb_render_query_pict_index_values_reply_t
**/
typedef struct xcb_render_query_pict_index_values_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t num_values;
uint8_t pad1[20];
} xcb_render_query_pict_index_values_reply_t;
/**
* @brief xcb_render_create_picture_value_list_t
**/
typedef struct xcb_render_create_picture_value_list_t {
uint32_t repeat;
xcb_render_picture_t alphamap;
int32_t alphaxorigin;
int32_t alphayorigin;
int32_t clipxorigin;
int32_t clipyorigin;
xcb_pixmap_t clipmask;
uint32_t graphicsexposure;
uint32_t subwindowmode;
uint32_t polyedge;
uint32_t polymode;
xcb_atom_t dither;
uint32_t componentalpha;
} xcb_render_create_picture_value_list_t;
/** Opcode for xcb_render_create_picture. */
#define XCB_RENDER_CREATE_PICTURE 4
/**
* @brief xcb_render_create_picture_request_t
**/
typedef struct xcb_render_create_picture_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_render_picture_t pid;
xcb_drawable_t drawable;
xcb_render_pictformat_t format;
uint32_t value_mask;
} xcb_render_create_picture_request_t;
/**
* @brief xcb_render_change_picture_value_list_t
**/
typedef struct xcb_render_change_picture_value_list_t {
uint32_t repeat;
xcb_render_picture_t alphamap;
int32_t alphaxorigin;
int32_t alphayorigin;
int32_t clipxorigin;
int32_t clipyorigin;
xcb_pixmap_t clipmask;
uint32_t graphicsexposure;
uint32_t subwindowmode;
uint32_t polyedge;
uint32_t polymode;
xcb_atom_t dither;
uint32_t componentalpha;
} xcb_render_change_picture_value_list_t;
/** Opcode for xcb_render_change_picture. */
#define XCB_RENDER_CHANGE_PICTURE 5
/**
* @brief xcb_render_change_picture_request_t
**/
typedef struct xcb_render_change_picture_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_render_picture_t picture;
uint32_t value_mask;
} xcb_render_change_picture_request_t;
/** Opcode for xcb_render_set_picture_clip_rectangles. */
#define XCB_RENDER_SET_PICTURE_CLIP_RECTANGLES 6
/**
* @brief xcb_render_set_picture_clip_rectangles_request_t
**/
typedef struct xcb_render_set_picture_clip_rectangles_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_render_picture_t picture;
int16_t clip_x_origin;
int16_t clip_y_origin;
} xcb_render_set_picture_clip_rectangles_request_t;
/** Opcode for xcb_render_free_picture. */
#define XCB_RENDER_FREE_PICTURE 7
/**
* @brief xcb_render_free_picture_request_t
**/
typedef struct xcb_render_free_picture_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_render_picture_t picture;
} xcb_render_free_picture_request_t;
/** Opcode for xcb_render_composite. */
#define XCB_RENDER_COMPOSITE 8
/**
* @brief xcb_render_composite_request_t
**/
typedef struct xcb_render_composite_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t op;
uint8_t pad0[3];
xcb_render_picture_t src;
xcb_render_picture_t mask;
xcb_render_picture_t dst;
int16_t src_x;
int16_t src_y;
int16_t mask_x;
int16_t mask_y;
int16_t dst_x;
int16_t dst_y;
uint16_t width;
uint16_t height;
} xcb_render_composite_request_t;
/** Opcode for xcb_render_trapezoids. */
#define XCB_RENDER_TRAPEZOIDS 10
/**
* @brief xcb_render_trapezoids_request_t
**/
typedef struct xcb_render_trapezoids_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t op;
uint8_t pad0[3];
xcb_render_picture_t src;
xcb_render_picture_t dst;
xcb_render_pictformat_t mask_format;
int16_t src_x;
int16_t src_y;
} xcb_render_trapezoids_request_t;
/** Opcode for xcb_render_triangles. */
#define XCB_RENDER_TRIANGLES 11
/**
* @brief xcb_render_triangles_request_t
**/
typedef struct xcb_render_triangles_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t op;
uint8_t pad0[3];
xcb_render_picture_t src;
xcb_render_picture_t dst;
xcb_render_pictformat_t mask_format;
int16_t src_x;
int16_t src_y;
} xcb_render_triangles_request_t;
/** Opcode for xcb_render_tri_strip. */
#define XCB_RENDER_TRI_STRIP 12
/**
* @brief xcb_render_tri_strip_request_t
**/
typedef struct xcb_render_tri_strip_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t op;
uint8_t pad0[3];
xcb_render_picture_t src;
xcb_render_picture_t dst;
xcb_render_pictformat_t mask_format;
int16_t src_x;
int16_t src_y;
} xcb_render_tri_strip_request_t;
/** Opcode for xcb_render_tri_fan. */
#define XCB_RENDER_TRI_FAN 13
/**
* @brief xcb_render_tri_fan_request_t
**/
typedef struct xcb_render_tri_fan_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t op;
uint8_t pad0[3];
xcb_render_picture_t src;
xcb_render_picture_t dst;
xcb_render_pictformat_t mask_format;
int16_t src_x;
int16_t src_y;
} xcb_render_tri_fan_request_t;
/** Opcode for xcb_render_create_glyph_set. */
#define XCB_RENDER_CREATE_GLYPH_SET 17
/**
* @brief xcb_render_create_glyph_set_request_t
**/
typedef struct xcb_render_create_glyph_set_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_render_glyphset_t gsid;
xcb_render_pictformat_t format;
} xcb_render_create_glyph_set_request_t;
/** Opcode for xcb_render_reference_glyph_set. */
#define XCB_RENDER_REFERENCE_GLYPH_SET 18
/**
* @brief xcb_render_reference_glyph_set_request_t
**/
typedef struct xcb_render_reference_glyph_set_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_render_glyphset_t gsid;
xcb_render_glyphset_t existing;
} xcb_render_reference_glyph_set_request_t;
/** Opcode for xcb_render_free_glyph_set. */
#define XCB_RENDER_FREE_GLYPH_SET 19
/**
* @brief xcb_render_free_glyph_set_request_t
**/
typedef struct xcb_render_free_glyph_set_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_render_glyphset_t glyphset;
} xcb_render_free_glyph_set_request_t;
/** Opcode for xcb_render_add_glyphs. */
#define XCB_RENDER_ADD_GLYPHS 20
/**
* @brief xcb_render_add_glyphs_request_t
**/
typedef struct xcb_render_add_glyphs_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_render_glyphset_t glyphset;
uint32_t glyphs_len;
} xcb_render_add_glyphs_request_t;
/** Opcode for xcb_render_free_glyphs. */
#define XCB_RENDER_FREE_GLYPHS 22
/**
* @brief xcb_render_free_glyphs_request_t
**/
typedef struct xcb_render_free_glyphs_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_render_glyphset_t glyphset;
} xcb_render_free_glyphs_request_t;
/** Opcode for xcb_render_composite_glyphs_8. */
#define XCB_RENDER_COMPOSITE_GLYPHS_8 23
/**
* @brief xcb_render_composite_glyphs_8_request_t
**/
typedef struct xcb_render_composite_glyphs_8_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t op;
uint8_t pad0[3];
xcb_render_picture_t src;
xcb_render_picture_t dst;
xcb_render_pictformat_t mask_format;
xcb_render_glyphset_t glyphset;
int16_t src_x;
int16_t src_y;
} xcb_render_composite_glyphs_8_request_t;
/** Opcode for xcb_render_composite_glyphs_16. */
#define XCB_RENDER_COMPOSITE_GLYPHS_16 24
/**
* @brief xcb_render_composite_glyphs_16_request_t
**/
typedef struct xcb_render_composite_glyphs_16_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t op;
uint8_t pad0[3];
xcb_render_picture_t src;
xcb_render_picture_t dst;
xcb_render_pictformat_t mask_format;
xcb_render_glyphset_t glyphset;
int16_t src_x;
int16_t src_y;
} xcb_render_composite_glyphs_16_request_t;
/** Opcode for xcb_render_composite_glyphs_32. */
#define XCB_RENDER_COMPOSITE_GLYPHS_32 25
/**
* @brief xcb_render_composite_glyphs_32_request_t
**/
typedef struct xcb_render_composite_glyphs_32_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t op;
uint8_t pad0[3];
xcb_render_picture_t src;
xcb_render_picture_t dst;
xcb_render_pictformat_t mask_format;
xcb_render_glyphset_t glyphset;
int16_t src_x;
int16_t src_y;
} xcb_render_composite_glyphs_32_request_t;
/** Opcode for xcb_render_fill_rectangles. */
#define XCB_RENDER_FILL_RECTANGLES 26
/**
* @brief xcb_render_fill_rectangles_request_t
**/
typedef struct xcb_render_fill_rectangles_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t op;
uint8_t pad0[3];
xcb_render_picture_t dst;
xcb_render_color_t color;
} xcb_render_fill_rectangles_request_t;
/** Opcode for xcb_render_create_cursor. */
#define XCB_RENDER_CREATE_CURSOR 27
/**
* @brief xcb_render_create_cursor_request_t
**/
typedef struct xcb_render_create_cursor_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_cursor_t cid;
xcb_render_picture_t source;
uint16_t x;
uint16_t y;
} xcb_render_create_cursor_request_t;
/**
* @brief xcb_render_transform_t
**/
typedef struct xcb_render_transform_t {
xcb_render_fixed_t matrix11;
xcb_render_fixed_t matrix12;
xcb_render_fixed_t matrix13;
xcb_render_fixed_t matrix21;
xcb_render_fixed_t matrix22;
xcb_render_fixed_t matrix23;
xcb_render_fixed_t matrix31;
xcb_render_fixed_t matrix32;
xcb_render_fixed_t matrix33;
} xcb_render_transform_t;
/**
* @brief xcb_render_transform_iterator_t
**/
typedef struct xcb_render_transform_iterator_t {
xcb_render_transform_t *data;
int rem;
int index;
} xcb_render_transform_iterator_t;
/** Opcode for xcb_render_set_picture_transform. */
#define XCB_RENDER_SET_PICTURE_TRANSFORM 28
/**
* @brief xcb_render_set_picture_transform_request_t
**/
typedef struct xcb_render_set_picture_transform_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_render_picture_t picture;
xcb_render_transform_t transform;
} xcb_render_set_picture_transform_request_t;
/**
* @brief xcb_render_query_filters_cookie_t
**/
typedef struct xcb_render_query_filters_cookie_t {
unsigned int sequence;
} xcb_render_query_filters_cookie_t;
/** Opcode for xcb_render_query_filters. */
#define XCB_RENDER_QUERY_FILTERS 29
/**
* @brief xcb_render_query_filters_request_t
**/
typedef struct xcb_render_query_filters_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_drawable_t drawable;
} xcb_render_query_filters_request_t;
/**
* @brief xcb_render_query_filters_reply_t
**/
typedef struct xcb_render_query_filters_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t num_aliases;
uint32_t num_filters;
uint8_t pad1[16];
} xcb_render_query_filters_reply_t;
/** Opcode for xcb_render_set_picture_filter. */
#define XCB_RENDER_SET_PICTURE_FILTER 30
/**
* @brief xcb_render_set_picture_filter_request_t
**/
typedef struct xcb_render_set_picture_filter_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_render_picture_t picture;
uint16_t filter_len;
uint8_t pad0[2];
} xcb_render_set_picture_filter_request_t;
/**
* @brief xcb_render_animcursorelt_t
**/
typedef struct xcb_render_animcursorelt_t {
xcb_cursor_t cursor;
uint32_t delay;
} xcb_render_animcursorelt_t;
/**
* @brief xcb_render_animcursorelt_iterator_t
**/
typedef struct xcb_render_animcursorelt_iterator_t {
xcb_render_animcursorelt_t *data;
int rem;
int index;
} xcb_render_animcursorelt_iterator_t;
/** Opcode for xcb_render_create_anim_cursor. */
#define XCB_RENDER_CREATE_ANIM_CURSOR 31
/**
* @brief xcb_render_create_anim_cursor_request_t
**/
typedef struct xcb_render_create_anim_cursor_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_cursor_t cid;
} xcb_render_create_anim_cursor_request_t;
/**
* @brief xcb_render_spanfix_t
**/
typedef struct xcb_render_spanfix_t {
xcb_render_fixed_t l;
xcb_render_fixed_t r;
xcb_render_fixed_t y;
} xcb_render_spanfix_t;
/**
* @brief xcb_render_spanfix_iterator_t
**/
typedef struct xcb_render_spanfix_iterator_t {
xcb_render_spanfix_t *data;
int rem;
int index;
} xcb_render_spanfix_iterator_t;
/**
* @brief xcb_render_trap_t
**/
typedef struct xcb_render_trap_t {
xcb_render_spanfix_t top;
xcb_render_spanfix_t bot;
} xcb_render_trap_t;
/**
* @brief xcb_render_trap_iterator_t
**/
typedef struct xcb_render_trap_iterator_t {
xcb_render_trap_t *data;
int rem;
int index;
} xcb_render_trap_iterator_t;
/** Opcode for xcb_render_add_traps. */
#define XCB_RENDER_ADD_TRAPS 32
/**
* @brief xcb_render_add_traps_request_t
**/
typedef struct xcb_render_add_traps_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_render_picture_t picture;
int16_t x_off;
int16_t y_off;
} xcb_render_add_traps_request_t;
/** Opcode for xcb_render_create_solid_fill. */
#define XCB_RENDER_CREATE_SOLID_FILL 33
/**
* @brief xcb_render_create_solid_fill_request_t
**/
typedef struct xcb_render_create_solid_fill_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_render_picture_t picture;
xcb_render_color_t color;
} xcb_render_create_solid_fill_request_t;
/** Opcode for xcb_render_create_linear_gradient. */
#define XCB_RENDER_CREATE_LINEAR_GRADIENT 34
/**
* @brief xcb_render_create_linear_gradient_request_t
**/
typedef struct xcb_render_create_linear_gradient_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_render_picture_t picture;
xcb_render_pointfix_t p1;
xcb_render_pointfix_t p2;
uint32_t num_stops;
} xcb_render_create_linear_gradient_request_t;
/** Opcode for xcb_render_create_radial_gradient. */
#define XCB_RENDER_CREATE_RADIAL_GRADIENT 35
/**
* @brief xcb_render_create_radial_gradient_request_t
**/
typedef struct xcb_render_create_radial_gradient_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_render_picture_t picture;
xcb_render_pointfix_t inner;
xcb_render_pointfix_t outer;
xcb_render_fixed_t inner_radius;
xcb_render_fixed_t outer_radius;
uint32_t num_stops;
} xcb_render_create_radial_gradient_request_t;
/** Opcode for xcb_render_create_conical_gradient. */
#define XCB_RENDER_CREATE_CONICAL_GRADIENT 36
/**
* @brief xcb_render_create_conical_gradient_request_t
**/
typedef struct xcb_render_create_conical_gradient_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_render_picture_t picture;
xcb_render_pointfix_t center;
xcb_render_fixed_t angle;
uint32_t num_stops;
} xcb_render_create_conical_gradient_request_t;
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_render_glyph_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_render_glyph_t)
*/
void
xcb_render_glyph_next (xcb_render_glyph_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_render_glyph_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_render_glyph_end (xcb_render_glyph_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_render_glyphset_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_render_glyphset_t)
*/
void
xcb_render_glyphset_next (xcb_render_glyphset_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_render_glyphset_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_render_glyphset_end (xcb_render_glyphset_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_render_picture_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_render_picture_t)
*/
void
xcb_render_picture_next (xcb_render_picture_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_render_picture_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_render_picture_end (xcb_render_picture_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_render_pictformat_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_render_pictformat_t)
*/
void
xcb_render_pictformat_next (xcb_render_pictformat_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_render_pictformat_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_render_pictformat_end (xcb_render_pictformat_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_render_fixed_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_render_fixed_t)
*/
void
xcb_render_fixed_next (xcb_render_fixed_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_render_fixed_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_render_fixed_end (xcb_render_fixed_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_render_directformat_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_render_directformat_t)
*/
void
xcb_render_directformat_next (xcb_render_directformat_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_render_directformat_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_render_directformat_end (xcb_render_directformat_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_render_pictforminfo_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_render_pictforminfo_t)
*/
void
xcb_render_pictforminfo_next (xcb_render_pictforminfo_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_render_pictforminfo_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_render_pictforminfo_end (xcb_render_pictforminfo_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_render_pictvisual_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_render_pictvisual_t)
*/
void
xcb_render_pictvisual_next (xcb_render_pictvisual_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_render_pictvisual_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_render_pictvisual_end (xcb_render_pictvisual_iterator_t i);
int
xcb_render_pictdepth_sizeof (const void *_buffer);
xcb_render_pictvisual_t *
xcb_render_pictdepth_visuals (const xcb_render_pictdepth_t *R);
int
xcb_render_pictdepth_visuals_length (const xcb_render_pictdepth_t *R);
xcb_render_pictvisual_iterator_t
xcb_render_pictdepth_visuals_iterator (const xcb_render_pictdepth_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_render_pictdepth_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_render_pictdepth_t)
*/
void
xcb_render_pictdepth_next (xcb_render_pictdepth_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_render_pictdepth_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_render_pictdepth_end (xcb_render_pictdepth_iterator_t i);
int
xcb_render_pictscreen_sizeof (const void *_buffer);
int
xcb_render_pictscreen_depths_length (const xcb_render_pictscreen_t *R);
xcb_render_pictdepth_iterator_t
xcb_render_pictscreen_depths_iterator (const xcb_render_pictscreen_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_render_pictscreen_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_render_pictscreen_t)
*/
void
xcb_render_pictscreen_next (xcb_render_pictscreen_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_render_pictscreen_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_render_pictscreen_end (xcb_render_pictscreen_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_render_indexvalue_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_render_indexvalue_t)
*/
void
xcb_render_indexvalue_next (xcb_render_indexvalue_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_render_indexvalue_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_render_indexvalue_end (xcb_render_indexvalue_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_render_color_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_render_color_t)
*/
void
xcb_render_color_next (xcb_render_color_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_render_color_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_render_color_end (xcb_render_color_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_render_pointfix_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_render_pointfix_t)
*/
void
xcb_render_pointfix_next (xcb_render_pointfix_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_render_pointfix_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_render_pointfix_end (xcb_render_pointfix_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_render_linefix_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_render_linefix_t)
*/
void
xcb_render_linefix_next (xcb_render_linefix_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_render_linefix_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_render_linefix_end (xcb_render_linefix_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_render_triangle_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_render_triangle_t)
*/
void
xcb_render_triangle_next (xcb_render_triangle_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_render_triangle_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_render_triangle_end (xcb_render_triangle_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_render_trapezoid_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_render_trapezoid_t)
*/
void
xcb_render_trapezoid_next (xcb_render_trapezoid_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_render_trapezoid_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_render_trapezoid_end (xcb_render_trapezoid_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_render_glyphinfo_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_render_glyphinfo_t)
*/
void
xcb_render_glyphinfo_next (xcb_render_glyphinfo_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_render_glyphinfo_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_render_glyphinfo_end (xcb_render_glyphinfo_iterator_t i);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_render_query_version_cookie_t
xcb_render_query_version (xcb_connection_t *c,
uint32_t client_major_version,
uint32_t client_minor_version);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_render_query_version_cookie_t
xcb_render_query_version_unchecked (xcb_connection_t *c,
uint32_t client_major_version,
uint32_t client_minor_version);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_render_query_version_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_render_query_version_reply_t *
xcb_render_query_version_reply (xcb_connection_t *c,
xcb_render_query_version_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_render_query_pict_formats_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_render_query_pict_formats_cookie_t
xcb_render_query_pict_formats (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_render_query_pict_formats_cookie_t
xcb_render_query_pict_formats_unchecked (xcb_connection_t *c);
xcb_render_pictforminfo_t *
xcb_render_query_pict_formats_formats (const xcb_render_query_pict_formats_reply_t *R);
int
xcb_render_query_pict_formats_formats_length (const xcb_render_query_pict_formats_reply_t *R);
xcb_render_pictforminfo_iterator_t
xcb_render_query_pict_formats_formats_iterator (const xcb_render_query_pict_formats_reply_t *R);
int
xcb_render_query_pict_formats_screens_length (const xcb_render_query_pict_formats_reply_t *R);
xcb_render_pictscreen_iterator_t
xcb_render_query_pict_formats_screens_iterator (const xcb_render_query_pict_formats_reply_t *R);
uint32_t *
xcb_render_query_pict_formats_subpixels (const xcb_render_query_pict_formats_reply_t *R);
int
xcb_render_query_pict_formats_subpixels_length (const xcb_render_query_pict_formats_reply_t *R);
xcb_generic_iterator_t
xcb_render_query_pict_formats_subpixels_end (const xcb_render_query_pict_formats_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_render_query_pict_formats_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_render_query_pict_formats_reply_t *
xcb_render_query_pict_formats_reply (xcb_connection_t *c,
xcb_render_query_pict_formats_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_render_query_pict_index_values_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_render_query_pict_index_values_cookie_t
xcb_render_query_pict_index_values (xcb_connection_t *c,
xcb_render_pictformat_t format);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_render_query_pict_index_values_cookie_t
xcb_render_query_pict_index_values_unchecked (xcb_connection_t *c,
xcb_render_pictformat_t format);
xcb_render_indexvalue_t *
xcb_render_query_pict_index_values_values (const xcb_render_query_pict_index_values_reply_t *R);
int
xcb_render_query_pict_index_values_values_length (const xcb_render_query_pict_index_values_reply_t *R);
xcb_render_indexvalue_iterator_t
xcb_render_query_pict_index_values_values_iterator (const xcb_render_query_pict_index_values_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_render_query_pict_index_values_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_render_query_pict_index_values_reply_t *
xcb_render_query_pict_index_values_reply (xcb_connection_t *c,
xcb_render_query_pict_index_values_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_render_create_picture_value_list_serialize (void **_buffer,
uint32_t value_mask,
const xcb_render_create_picture_value_list_t *_aux);
int
xcb_render_create_picture_value_list_unpack (const void *_buffer,
uint32_t value_mask,
xcb_render_create_picture_value_list_t *_aux);
int
xcb_render_create_picture_value_list_sizeof (const void *_buffer,
uint32_t value_mask);
int
xcb_render_create_picture_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_render_create_picture_checked (xcb_connection_t *c,
xcb_render_picture_t pid,
xcb_drawable_t drawable,
xcb_render_pictformat_t format,
uint32_t value_mask,
const void *value_list);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_render_create_picture (xcb_connection_t *c,
xcb_render_picture_t pid,
xcb_drawable_t drawable,
xcb_render_pictformat_t format,
uint32_t value_mask,
const void *value_list);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_render_create_picture_aux_checked (xcb_connection_t *c,
xcb_render_picture_t pid,
xcb_drawable_t drawable,
xcb_render_pictformat_t format,
uint32_t value_mask,
const xcb_render_create_picture_value_list_t *value_list);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_render_create_picture_aux (xcb_connection_t *c,
xcb_render_picture_t pid,
xcb_drawable_t drawable,
xcb_render_pictformat_t format,
uint32_t value_mask,
const xcb_render_create_picture_value_list_t *value_list);
void *
xcb_render_create_picture_value_list (const xcb_render_create_picture_request_t *R);
int
xcb_render_change_picture_value_list_serialize (void **_buffer,
uint32_t value_mask,
const xcb_render_change_picture_value_list_t *_aux);
int
xcb_render_change_picture_value_list_unpack (const void *_buffer,
uint32_t value_mask,
xcb_render_change_picture_value_list_t *_aux);
int
xcb_render_change_picture_value_list_sizeof (const void *_buffer,
uint32_t value_mask);
int
xcb_render_change_picture_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_render_change_picture_checked (xcb_connection_t *c,
xcb_render_picture_t picture,
uint32_t value_mask,
const void *value_list);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_render_change_picture (xcb_connection_t *c,
xcb_render_picture_t picture,
uint32_t value_mask,
const void *value_list);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_render_change_picture_aux_checked (xcb_connection_t *c,
xcb_render_picture_t picture,
uint32_t value_mask,
const xcb_render_change_picture_value_list_t *value_list);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_render_change_picture_aux (xcb_connection_t *c,
xcb_render_picture_t picture,
uint32_t value_mask,
const xcb_render_change_picture_value_list_t *value_list);
void *
xcb_render_change_picture_value_list (const xcb_render_change_picture_request_t *R);
int
xcb_render_set_picture_clip_rectangles_sizeof (const void *_buffer,
uint32_t rectangles_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_render_set_picture_clip_rectangles_checked (xcb_connection_t *c,
xcb_render_picture_t picture,
int16_t clip_x_origin,
int16_t clip_y_origin,
uint32_t rectangles_len,
const xcb_rectangle_t *rectangles);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_render_set_picture_clip_rectangles (xcb_connection_t *c,
xcb_render_picture_t picture,
int16_t clip_x_origin,
int16_t clip_y_origin,
uint32_t rectangles_len,
const xcb_rectangle_t *rectangles);
xcb_rectangle_t *
xcb_render_set_picture_clip_rectangles_rectangles (const xcb_render_set_picture_clip_rectangles_request_t *R);
int
xcb_render_set_picture_clip_rectangles_rectangles_length (const xcb_render_set_picture_clip_rectangles_request_t *R);
xcb_rectangle_iterator_t
xcb_render_set_picture_clip_rectangles_rectangles_iterator (const xcb_render_set_picture_clip_rectangles_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_render_free_picture_checked (xcb_connection_t *c,
xcb_render_picture_t picture);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_render_free_picture (xcb_connection_t *c,
xcb_render_picture_t picture);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_render_composite_checked (xcb_connection_t *c,
uint8_t op,
xcb_render_picture_t src,
xcb_render_picture_t mask,
xcb_render_picture_t dst,
int16_t src_x,
int16_t src_y,
int16_t mask_x,
int16_t mask_y,
int16_t dst_x,
int16_t dst_y,
uint16_t width,
uint16_t height);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_render_composite (xcb_connection_t *c,
uint8_t op,
xcb_render_picture_t src,
xcb_render_picture_t mask,
xcb_render_picture_t dst,
int16_t src_x,
int16_t src_y,
int16_t mask_x,
int16_t mask_y,
int16_t dst_x,
int16_t dst_y,
uint16_t width,
uint16_t height);
int
xcb_render_trapezoids_sizeof (const void *_buffer,
uint32_t traps_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_render_trapezoids_checked (xcb_connection_t *c,
uint8_t op,
xcb_render_picture_t src,
xcb_render_picture_t dst,
xcb_render_pictformat_t mask_format,
int16_t src_x,
int16_t src_y,
uint32_t traps_len,
const xcb_render_trapezoid_t *traps);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_render_trapezoids (xcb_connection_t *c,
uint8_t op,
xcb_render_picture_t src,
xcb_render_picture_t dst,
xcb_render_pictformat_t mask_format,
int16_t src_x,
int16_t src_y,
uint32_t traps_len,
const xcb_render_trapezoid_t *traps);
xcb_render_trapezoid_t *
xcb_render_trapezoids_traps (const xcb_render_trapezoids_request_t *R);
int
xcb_render_trapezoids_traps_length (const xcb_render_trapezoids_request_t *R);
xcb_render_trapezoid_iterator_t
xcb_render_trapezoids_traps_iterator (const xcb_render_trapezoids_request_t *R);
int
xcb_render_triangles_sizeof (const void *_buffer,
uint32_t triangles_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_render_triangles_checked (xcb_connection_t *c,
uint8_t op,
xcb_render_picture_t src,
xcb_render_picture_t dst,
xcb_render_pictformat_t mask_format,
int16_t src_x,
int16_t src_y,
uint32_t triangles_len,
const xcb_render_triangle_t *triangles);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_render_triangles (xcb_connection_t *c,
uint8_t op,
xcb_render_picture_t src,
xcb_render_picture_t dst,
xcb_render_pictformat_t mask_format,
int16_t src_x,
int16_t src_y,
uint32_t triangles_len,
const xcb_render_triangle_t *triangles);
xcb_render_triangle_t *
xcb_render_triangles_triangles (const xcb_render_triangles_request_t *R);
int
xcb_render_triangles_triangles_length (const xcb_render_triangles_request_t *R);
xcb_render_triangle_iterator_t
xcb_render_triangles_triangles_iterator (const xcb_render_triangles_request_t *R);
int
xcb_render_tri_strip_sizeof (const void *_buffer,
uint32_t points_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_render_tri_strip_checked (xcb_connection_t *c,
uint8_t op,
xcb_render_picture_t src,
xcb_render_picture_t dst,
xcb_render_pictformat_t mask_format,
int16_t src_x,
int16_t src_y,
uint32_t points_len,
const xcb_render_pointfix_t *points);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_render_tri_strip (xcb_connection_t *c,
uint8_t op,
xcb_render_picture_t src,
xcb_render_picture_t dst,
xcb_render_pictformat_t mask_format,
int16_t src_x,
int16_t src_y,
uint32_t points_len,
const xcb_render_pointfix_t *points);
xcb_render_pointfix_t *
xcb_render_tri_strip_points (const xcb_render_tri_strip_request_t *R);
int
xcb_render_tri_strip_points_length (const xcb_render_tri_strip_request_t *R);
xcb_render_pointfix_iterator_t
xcb_render_tri_strip_points_iterator (const xcb_render_tri_strip_request_t *R);
int
xcb_render_tri_fan_sizeof (const void *_buffer,
uint32_t points_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_render_tri_fan_checked (xcb_connection_t *c,
uint8_t op,
xcb_render_picture_t src,
xcb_render_picture_t dst,
xcb_render_pictformat_t mask_format,
int16_t src_x,
int16_t src_y,
uint32_t points_len,
const xcb_render_pointfix_t *points);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_render_tri_fan (xcb_connection_t *c,
uint8_t op,
xcb_render_picture_t src,
xcb_render_picture_t dst,
xcb_render_pictformat_t mask_format,
int16_t src_x,
int16_t src_y,
uint32_t points_len,
const xcb_render_pointfix_t *points);
xcb_render_pointfix_t *
xcb_render_tri_fan_points (const xcb_render_tri_fan_request_t *R);
int
xcb_render_tri_fan_points_length (const xcb_render_tri_fan_request_t *R);
xcb_render_pointfix_iterator_t
xcb_render_tri_fan_points_iterator (const xcb_render_tri_fan_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_render_create_glyph_set_checked (xcb_connection_t *c,
xcb_render_glyphset_t gsid,
xcb_render_pictformat_t format);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_render_create_glyph_set (xcb_connection_t *c,
xcb_render_glyphset_t gsid,
xcb_render_pictformat_t format);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_render_reference_glyph_set_checked (xcb_connection_t *c,
xcb_render_glyphset_t gsid,
xcb_render_glyphset_t existing);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_render_reference_glyph_set (xcb_connection_t *c,
xcb_render_glyphset_t gsid,
xcb_render_glyphset_t existing);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_render_free_glyph_set_checked (xcb_connection_t *c,
xcb_render_glyphset_t glyphset);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_render_free_glyph_set (xcb_connection_t *c,
xcb_render_glyphset_t glyphset);
int
xcb_render_add_glyphs_sizeof (const void *_buffer,
uint32_t data_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_render_add_glyphs_checked (xcb_connection_t *c,
xcb_render_glyphset_t glyphset,
uint32_t glyphs_len,
const uint32_t *glyphids,
const xcb_render_glyphinfo_t *glyphs,
uint32_t data_len,
const uint8_t *data);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_render_add_glyphs (xcb_connection_t *c,
xcb_render_glyphset_t glyphset,
uint32_t glyphs_len,
const uint32_t *glyphids,
const xcb_render_glyphinfo_t *glyphs,
uint32_t data_len,
const uint8_t *data);
uint32_t *
xcb_render_add_glyphs_glyphids (const xcb_render_add_glyphs_request_t *R);
int
xcb_render_add_glyphs_glyphids_length (const xcb_render_add_glyphs_request_t *R);
xcb_generic_iterator_t
xcb_render_add_glyphs_glyphids_end (const xcb_render_add_glyphs_request_t *R);
xcb_render_glyphinfo_t *
xcb_render_add_glyphs_glyphs (const xcb_render_add_glyphs_request_t *R);
int
xcb_render_add_glyphs_glyphs_length (const xcb_render_add_glyphs_request_t *R);
xcb_render_glyphinfo_iterator_t
xcb_render_add_glyphs_glyphs_iterator (const xcb_render_add_glyphs_request_t *R);
uint8_t *
xcb_render_add_glyphs_data (const xcb_render_add_glyphs_request_t *R);
int
xcb_render_add_glyphs_data_length (const xcb_render_add_glyphs_request_t *R);
xcb_generic_iterator_t
xcb_render_add_glyphs_data_end (const xcb_render_add_glyphs_request_t *R);
int
xcb_render_free_glyphs_sizeof (const void *_buffer,
uint32_t glyphs_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_render_free_glyphs_checked (xcb_connection_t *c,
xcb_render_glyphset_t glyphset,
uint32_t glyphs_len,
const xcb_render_glyph_t *glyphs);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_render_free_glyphs (xcb_connection_t *c,
xcb_render_glyphset_t glyphset,
uint32_t glyphs_len,
const xcb_render_glyph_t *glyphs);
xcb_render_glyph_t *
xcb_render_free_glyphs_glyphs (const xcb_render_free_glyphs_request_t *R);
int
xcb_render_free_glyphs_glyphs_length (const xcb_render_free_glyphs_request_t *R);
xcb_generic_iterator_t
xcb_render_free_glyphs_glyphs_end (const xcb_render_free_glyphs_request_t *R);
int
xcb_render_composite_glyphs_8_sizeof (const void *_buffer,
uint32_t glyphcmds_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_render_composite_glyphs_8_checked (xcb_connection_t *c,
uint8_t op,
xcb_render_picture_t src,
xcb_render_picture_t dst,
xcb_render_pictformat_t mask_format,
xcb_render_glyphset_t glyphset,
int16_t src_x,
int16_t src_y,
uint32_t glyphcmds_len,
const uint8_t *glyphcmds);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_render_composite_glyphs_8 (xcb_connection_t *c,
uint8_t op,
xcb_render_picture_t src,
xcb_render_picture_t dst,
xcb_render_pictformat_t mask_format,
xcb_render_glyphset_t glyphset,
int16_t src_x,
int16_t src_y,
uint32_t glyphcmds_len,
const uint8_t *glyphcmds);
uint8_t *
xcb_render_composite_glyphs_8_glyphcmds (const xcb_render_composite_glyphs_8_request_t *R);
int
xcb_render_composite_glyphs_8_glyphcmds_length (const xcb_render_composite_glyphs_8_request_t *R);
xcb_generic_iterator_t
xcb_render_composite_glyphs_8_glyphcmds_end (const xcb_render_composite_glyphs_8_request_t *R);
int
xcb_render_composite_glyphs_16_sizeof (const void *_buffer,
uint32_t glyphcmds_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_render_composite_glyphs_16_checked (xcb_connection_t *c,
uint8_t op,
xcb_render_picture_t src,
xcb_render_picture_t dst,
xcb_render_pictformat_t mask_format,
xcb_render_glyphset_t glyphset,
int16_t src_x,
int16_t src_y,
uint32_t glyphcmds_len,
const uint8_t *glyphcmds);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_render_composite_glyphs_16 (xcb_connection_t *c,
uint8_t op,
xcb_render_picture_t src,
xcb_render_picture_t dst,
xcb_render_pictformat_t mask_format,
xcb_render_glyphset_t glyphset,
int16_t src_x,
int16_t src_y,
uint32_t glyphcmds_len,
const uint8_t *glyphcmds);
uint8_t *
xcb_render_composite_glyphs_16_glyphcmds (const xcb_render_composite_glyphs_16_request_t *R);
int
xcb_render_composite_glyphs_16_glyphcmds_length (const xcb_render_composite_glyphs_16_request_t *R);
xcb_generic_iterator_t
xcb_render_composite_glyphs_16_glyphcmds_end (const xcb_render_composite_glyphs_16_request_t *R);
int
xcb_render_composite_glyphs_32_sizeof (const void *_buffer,
uint32_t glyphcmds_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_render_composite_glyphs_32_checked (xcb_connection_t *c,
uint8_t op,
xcb_render_picture_t src,
xcb_render_picture_t dst,
xcb_render_pictformat_t mask_format,
xcb_render_glyphset_t glyphset,
int16_t src_x,
int16_t src_y,
uint32_t glyphcmds_len,
const uint8_t *glyphcmds);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_render_composite_glyphs_32 (xcb_connection_t *c,
uint8_t op,
xcb_render_picture_t src,
xcb_render_picture_t dst,
xcb_render_pictformat_t mask_format,
xcb_render_glyphset_t glyphset,
int16_t src_x,
int16_t src_y,
uint32_t glyphcmds_len,
const uint8_t *glyphcmds);
uint8_t *
xcb_render_composite_glyphs_32_glyphcmds (const xcb_render_composite_glyphs_32_request_t *R);
int
xcb_render_composite_glyphs_32_glyphcmds_length (const xcb_render_composite_glyphs_32_request_t *R);
xcb_generic_iterator_t
xcb_render_composite_glyphs_32_glyphcmds_end (const xcb_render_composite_glyphs_32_request_t *R);
int
xcb_render_fill_rectangles_sizeof (const void *_buffer,
uint32_t rects_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_render_fill_rectangles_checked (xcb_connection_t *c,
uint8_t op,
xcb_render_picture_t dst,
xcb_render_color_t color,
uint32_t rects_len,
const xcb_rectangle_t *rects);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_render_fill_rectangles (xcb_connection_t *c,
uint8_t op,
xcb_render_picture_t dst,
xcb_render_color_t color,
uint32_t rects_len,
const xcb_rectangle_t *rects);
xcb_rectangle_t *
xcb_render_fill_rectangles_rects (const xcb_render_fill_rectangles_request_t *R);
int
xcb_render_fill_rectangles_rects_length (const xcb_render_fill_rectangles_request_t *R);
xcb_rectangle_iterator_t
xcb_render_fill_rectangles_rects_iterator (const xcb_render_fill_rectangles_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_render_create_cursor_checked (xcb_connection_t *c,
xcb_cursor_t cid,
xcb_render_picture_t source,
uint16_t x,
uint16_t y);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_render_create_cursor (xcb_connection_t *c,
xcb_cursor_t cid,
xcb_render_picture_t source,
uint16_t x,
uint16_t y);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_render_transform_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_render_transform_t)
*/
void
xcb_render_transform_next (xcb_render_transform_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_render_transform_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_render_transform_end (xcb_render_transform_iterator_t i);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_render_set_picture_transform_checked (xcb_connection_t *c,
xcb_render_picture_t picture,
xcb_render_transform_t transform);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_render_set_picture_transform (xcb_connection_t *c,
xcb_render_picture_t picture,
xcb_render_transform_t transform);
int
xcb_render_query_filters_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_render_query_filters_cookie_t
xcb_render_query_filters (xcb_connection_t *c,
xcb_drawable_t drawable);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_render_query_filters_cookie_t
xcb_render_query_filters_unchecked (xcb_connection_t *c,
xcb_drawable_t drawable);
uint16_t *
xcb_render_query_filters_aliases (const xcb_render_query_filters_reply_t *R);
int
xcb_render_query_filters_aliases_length (const xcb_render_query_filters_reply_t *R);
xcb_generic_iterator_t
xcb_render_query_filters_aliases_end (const xcb_render_query_filters_reply_t *R);
int
xcb_render_query_filters_filters_length (const xcb_render_query_filters_reply_t *R);
xcb_str_iterator_t
xcb_render_query_filters_filters_iterator (const xcb_render_query_filters_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_render_query_filters_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_render_query_filters_reply_t *
xcb_render_query_filters_reply (xcb_connection_t *c,
xcb_render_query_filters_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_render_set_picture_filter_sizeof (const void *_buffer,
uint32_t values_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_render_set_picture_filter_checked (xcb_connection_t *c,
xcb_render_picture_t picture,
uint16_t filter_len,
const char *filter,
uint32_t values_len,
const xcb_render_fixed_t *values);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_render_set_picture_filter (xcb_connection_t *c,
xcb_render_picture_t picture,
uint16_t filter_len,
const char *filter,
uint32_t values_len,
const xcb_render_fixed_t *values);
char *
xcb_render_set_picture_filter_filter (const xcb_render_set_picture_filter_request_t *R);
int
xcb_render_set_picture_filter_filter_length (const xcb_render_set_picture_filter_request_t *R);
xcb_generic_iterator_t
xcb_render_set_picture_filter_filter_end (const xcb_render_set_picture_filter_request_t *R);
xcb_render_fixed_t *
xcb_render_set_picture_filter_values (const xcb_render_set_picture_filter_request_t *R);
int
xcb_render_set_picture_filter_values_length (const xcb_render_set_picture_filter_request_t *R);
xcb_generic_iterator_t
xcb_render_set_picture_filter_values_end (const xcb_render_set_picture_filter_request_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_render_animcursorelt_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_render_animcursorelt_t)
*/
void
xcb_render_animcursorelt_next (xcb_render_animcursorelt_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_render_animcursorelt_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_render_animcursorelt_end (xcb_render_animcursorelt_iterator_t i);
int
xcb_render_create_anim_cursor_sizeof (const void *_buffer,
uint32_t cursors_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_render_create_anim_cursor_checked (xcb_connection_t *c,
xcb_cursor_t cid,
uint32_t cursors_len,
const xcb_render_animcursorelt_t *cursors);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_render_create_anim_cursor (xcb_connection_t *c,
xcb_cursor_t cid,
uint32_t cursors_len,
const xcb_render_animcursorelt_t *cursors);
xcb_render_animcursorelt_t *
xcb_render_create_anim_cursor_cursors (const xcb_render_create_anim_cursor_request_t *R);
int
xcb_render_create_anim_cursor_cursors_length (const xcb_render_create_anim_cursor_request_t *R);
xcb_render_animcursorelt_iterator_t
xcb_render_create_anim_cursor_cursors_iterator (const xcb_render_create_anim_cursor_request_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_render_spanfix_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_render_spanfix_t)
*/
void
xcb_render_spanfix_next (xcb_render_spanfix_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_render_spanfix_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_render_spanfix_end (xcb_render_spanfix_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_render_trap_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_render_trap_t)
*/
void
xcb_render_trap_next (xcb_render_trap_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_render_trap_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_render_trap_end (xcb_render_trap_iterator_t i);
int
xcb_render_add_traps_sizeof (const void *_buffer,
uint32_t traps_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_render_add_traps_checked (xcb_connection_t *c,
xcb_render_picture_t picture,
int16_t x_off,
int16_t y_off,
uint32_t traps_len,
const xcb_render_trap_t *traps);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_render_add_traps (xcb_connection_t *c,
xcb_render_picture_t picture,
int16_t x_off,
int16_t y_off,
uint32_t traps_len,
const xcb_render_trap_t *traps);
xcb_render_trap_t *
xcb_render_add_traps_traps (const xcb_render_add_traps_request_t *R);
int
xcb_render_add_traps_traps_length (const xcb_render_add_traps_request_t *R);
xcb_render_trap_iterator_t
xcb_render_add_traps_traps_iterator (const xcb_render_add_traps_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_render_create_solid_fill_checked (xcb_connection_t *c,
xcb_render_picture_t picture,
xcb_render_color_t color);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_render_create_solid_fill (xcb_connection_t *c,
xcb_render_picture_t picture,
xcb_render_color_t color);
int
xcb_render_create_linear_gradient_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_render_create_linear_gradient_checked (xcb_connection_t *c,
xcb_render_picture_t picture,
xcb_render_pointfix_t p1,
xcb_render_pointfix_t p2,
uint32_t num_stops,
const xcb_render_fixed_t *stops,
const xcb_render_color_t *colors);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_render_create_linear_gradient (xcb_connection_t *c,
xcb_render_picture_t picture,
xcb_render_pointfix_t p1,
xcb_render_pointfix_t p2,
uint32_t num_stops,
const xcb_render_fixed_t *stops,
const xcb_render_color_t *colors);
xcb_render_fixed_t *
xcb_render_create_linear_gradient_stops (const xcb_render_create_linear_gradient_request_t *R);
int
xcb_render_create_linear_gradient_stops_length (const xcb_render_create_linear_gradient_request_t *R);
xcb_generic_iterator_t
xcb_render_create_linear_gradient_stops_end (const xcb_render_create_linear_gradient_request_t *R);
xcb_render_color_t *
xcb_render_create_linear_gradient_colors (const xcb_render_create_linear_gradient_request_t *R);
int
xcb_render_create_linear_gradient_colors_length (const xcb_render_create_linear_gradient_request_t *R);
xcb_render_color_iterator_t
xcb_render_create_linear_gradient_colors_iterator (const xcb_render_create_linear_gradient_request_t *R);
int
xcb_render_create_radial_gradient_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_render_create_radial_gradient_checked (xcb_connection_t *c,
xcb_render_picture_t picture,
xcb_render_pointfix_t inner,
xcb_render_pointfix_t outer,
xcb_render_fixed_t inner_radius,
xcb_render_fixed_t outer_radius,
uint32_t num_stops,
const xcb_render_fixed_t *stops,
const xcb_render_color_t *colors);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_render_create_radial_gradient (xcb_connection_t *c,
xcb_render_picture_t picture,
xcb_render_pointfix_t inner,
xcb_render_pointfix_t outer,
xcb_render_fixed_t inner_radius,
xcb_render_fixed_t outer_radius,
uint32_t num_stops,
const xcb_render_fixed_t *stops,
const xcb_render_color_t *colors);
xcb_render_fixed_t *
xcb_render_create_radial_gradient_stops (const xcb_render_create_radial_gradient_request_t *R);
int
xcb_render_create_radial_gradient_stops_length (const xcb_render_create_radial_gradient_request_t *R);
xcb_generic_iterator_t
xcb_render_create_radial_gradient_stops_end (const xcb_render_create_radial_gradient_request_t *R);
xcb_render_color_t *
xcb_render_create_radial_gradient_colors (const xcb_render_create_radial_gradient_request_t *R);
int
xcb_render_create_radial_gradient_colors_length (const xcb_render_create_radial_gradient_request_t *R);
xcb_render_color_iterator_t
xcb_render_create_radial_gradient_colors_iterator (const xcb_render_create_radial_gradient_request_t *R);
int
xcb_render_create_conical_gradient_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_render_create_conical_gradient_checked (xcb_connection_t *c,
xcb_render_picture_t picture,
xcb_render_pointfix_t center,
xcb_render_fixed_t angle,
uint32_t num_stops,
const xcb_render_fixed_t *stops,
const xcb_render_color_t *colors);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_render_create_conical_gradient (xcb_connection_t *c,
xcb_render_picture_t picture,
xcb_render_pointfix_t center,
xcb_render_fixed_t angle,
uint32_t num_stops,
const xcb_render_fixed_t *stops,
const xcb_render_color_t *colors);
xcb_render_fixed_t *
xcb_render_create_conical_gradient_stops (const xcb_render_create_conical_gradient_request_t *R);
int
xcb_render_create_conical_gradient_stops_length (const xcb_render_create_conical_gradient_request_t *R);
xcb_generic_iterator_t
xcb_render_create_conical_gradient_stops_end (const xcb_render_create_conical_gradient_request_t *R);
xcb_render_color_t *
xcb_render_create_conical_gradient_colors (const xcb_render_create_conical_gradient_request_t *R);
int
xcb_render_create_conical_gradient_colors_length (const xcb_render_create_conical_gradient_request_t *R);
xcb_render_color_iterator_t
xcb_render_create_conical_gradient_colors_iterator (const xcb_render_create_conical_gradient_request_t *R);
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/
xcb/xtest.h 0000644 00000016645 15201526705 0006657 0 ustar 00 /*
* This file generated automatically from xtest.xml by c_client.py.
* Edit at your peril.
*/
/**
* @defgroup XCB_Test_API XCB Test API
* @brief Test XCB Protocol Implementation.
* @{
**/
#ifndef __XTEST_H
#define __XTEST_H
#include "xcb.h"
#include "xproto.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XCB_TEST_MAJOR_VERSION 2
#define XCB_TEST_MINOR_VERSION 2
extern xcb_extension_t xcb_test_id;
/**
* @brief xcb_test_get_version_cookie_t
**/
typedef struct xcb_test_get_version_cookie_t {
unsigned int sequence;
} xcb_test_get_version_cookie_t;
/** Opcode for xcb_test_get_version. */
#define XCB_TEST_GET_VERSION 0
/**
* @brief xcb_test_get_version_request_t
**/
typedef struct xcb_test_get_version_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t major_version;
uint8_t pad0;
uint16_t minor_version;
} xcb_test_get_version_request_t;
/**
* @brief xcb_test_get_version_reply_t
**/
typedef struct xcb_test_get_version_reply_t {
uint8_t response_type;
uint8_t major_version;
uint16_t sequence;
uint32_t length;
uint16_t minor_version;
} xcb_test_get_version_reply_t;
typedef enum xcb_test_cursor_t {
XCB_TEST_CURSOR_NONE = 0,
XCB_TEST_CURSOR_CURRENT = 1
} xcb_test_cursor_t;
/**
* @brief xcb_test_compare_cursor_cookie_t
**/
typedef struct xcb_test_compare_cursor_cookie_t {
unsigned int sequence;
} xcb_test_compare_cursor_cookie_t;
/** Opcode for xcb_test_compare_cursor. */
#define XCB_TEST_COMPARE_CURSOR 1
/**
* @brief xcb_test_compare_cursor_request_t
**/
typedef struct xcb_test_compare_cursor_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
xcb_cursor_t cursor;
} xcb_test_compare_cursor_request_t;
/**
* @brief xcb_test_compare_cursor_reply_t
**/
typedef struct xcb_test_compare_cursor_reply_t {
uint8_t response_type;
uint8_t same;
uint16_t sequence;
uint32_t length;
} xcb_test_compare_cursor_reply_t;
/** Opcode for xcb_test_fake_input. */
#define XCB_TEST_FAKE_INPUT 2
/**
* @brief xcb_test_fake_input_request_t
**/
typedef struct xcb_test_fake_input_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t type;
uint8_t detail;
uint8_t pad0[2];
uint32_t time;
xcb_window_t root;
uint8_t pad1[8];
int16_t rootX;
int16_t rootY;
uint8_t pad2[7];
uint8_t deviceid;
} xcb_test_fake_input_request_t;
/** Opcode for xcb_test_grab_control. */
#define XCB_TEST_GRAB_CONTROL 3
/**
* @brief xcb_test_grab_control_request_t
**/
typedef struct xcb_test_grab_control_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t impervious;
uint8_t pad0[3];
} xcb_test_grab_control_request_t;
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_test_get_version_cookie_t
xcb_test_get_version (xcb_connection_t *c,
uint8_t major_version,
uint16_t minor_version);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_test_get_version_cookie_t
xcb_test_get_version_unchecked (xcb_connection_t *c,
uint8_t major_version,
uint16_t minor_version);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_test_get_version_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_test_get_version_reply_t *
xcb_test_get_version_reply (xcb_connection_t *c,
xcb_test_get_version_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_test_compare_cursor_cookie_t
xcb_test_compare_cursor (xcb_connection_t *c,
xcb_window_t window,
xcb_cursor_t cursor);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_test_compare_cursor_cookie_t
xcb_test_compare_cursor_unchecked (xcb_connection_t *c,
xcb_window_t window,
xcb_cursor_t cursor);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_test_compare_cursor_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_test_compare_cursor_reply_t *
xcb_test_compare_cursor_reply (xcb_connection_t *c,
xcb_test_compare_cursor_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_test_fake_input_checked (xcb_connection_t *c,
uint8_t type,
uint8_t detail,
uint32_t time,
xcb_window_t root,
int16_t rootX,
int16_t rootY,
uint8_t deviceid);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_test_fake_input (xcb_connection_t *c,
uint8_t type,
uint8_t detail,
uint32_t time,
xcb_window_t root,
int16_t rootX,
int16_t rootY,
uint8_t deviceid);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_test_grab_control_checked (xcb_connection_t *c,
uint8_t impervious);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_test_grab_control (xcb_connection_t *c,
uint8_t impervious);
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/
xcb/res.h 0000644 00000057643 15201526705 0006304 0 ustar 00 /*
* This file generated automatically from res.xml by c_client.py.
* Edit at your peril.
*/
/**
* @defgroup XCB_Res_API XCB Res API
* @brief Res XCB Protocol Implementation.
* @{
**/
#ifndef __RES_H
#define __RES_H
#include "xcb.h"
#include "xproto.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XCB_RES_MAJOR_VERSION 1
#define XCB_RES_MINOR_VERSION 2
extern xcb_extension_t xcb_res_id;
/**
* @brief xcb_res_client_t
**/
typedef struct xcb_res_client_t {
uint32_t resource_base;
uint32_t resource_mask;
} xcb_res_client_t;
/**
* @brief xcb_res_client_iterator_t
**/
typedef struct xcb_res_client_iterator_t {
xcb_res_client_t *data;
int rem;
int index;
} xcb_res_client_iterator_t;
/**
* @brief xcb_res_type_t
**/
typedef struct xcb_res_type_t {
xcb_atom_t resource_type;
uint32_t count;
} xcb_res_type_t;
/**
* @brief xcb_res_type_iterator_t
**/
typedef struct xcb_res_type_iterator_t {
xcb_res_type_t *data;
int rem;
int index;
} xcb_res_type_iterator_t;
typedef enum xcb_res_client_id_mask_t {
XCB_RES_CLIENT_ID_MASK_CLIENT_XID = 1,
XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID = 2
} xcb_res_client_id_mask_t;
/**
* @brief xcb_res_client_id_spec_t
**/
typedef struct xcb_res_client_id_spec_t {
uint32_t client;
uint32_t mask;
} xcb_res_client_id_spec_t;
/**
* @brief xcb_res_client_id_spec_iterator_t
**/
typedef struct xcb_res_client_id_spec_iterator_t {
xcb_res_client_id_spec_t *data;
int rem;
int index;
} xcb_res_client_id_spec_iterator_t;
/**
* @brief xcb_res_client_id_value_t
**/
typedef struct xcb_res_client_id_value_t {
xcb_res_client_id_spec_t spec;
uint32_t length;
} xcb_res_client_id_value_t;
/**
* @brief xcb_res_client_id_value_iterator_t
**/
typedef struct xcb_res_client_id_value_iterator_t {
xcb_res_client_id_value_t *data;
int rem;
int index;
} xcb_res_client_id_value_iterator_t;
/**
* @brief xcb_res_resource_id_spec_t
**/
typedef struct xcb_res_resource_id_spec_t {
uint32_t resource;
uint32_t type;
} xcb_res_resource_id_spec_t;
/**
* @brief xcb_res_resource_id_spec_iterator_t
**/
typedef struct xcb_res_resource_id_spec_iterator_t {
xcb_res_resource_id_spec_t *data;
int rem;
int index;
} xcb_res_resource_id_spec_iterator_t;
/**
* @brief xcb_res_resource_size_spec_t
**/
typedef struct xcb_res_resource_size_spec_t {
xcb_res_resource_id_spec_t spec;
uint32_t bytes;
uint32_t ref_count;
uint32_t use_count;
} xcb_res_resource_size_spec_t;
/**
* @brief xcb_res_resource_size_spec_iterator_t
**/
typedef struct xcb_res_resource_size_spec_iterator_t {
xcb_res_resource_size_spec_t *data;
int rem;
int index;
} xcb_res_resource_size_spec_iterator_t;
/**
* @brief xcb_res_resource_size_value_t
**/
typedef struct xcb_res_resource_size_value_t {
xcb_res_resource_size_spec_t size;
uint32_t num_cross_references;
} xcb_res_resource_size_value_t;
/**
* @brief xcb_res_resource_size_value_iterator_t
**/
typedef struct xcb_res_resource_size_value_iterator_t {
xcb_res_resource_size_value_t *data;
int rem;
int index;
} xcb_res_resource_size_value_iterator_t;
/**
* @brief xcb_res_query_version_cookie_t
**/
typedef struct xcb_res_query_version_cookie_t {
unsigned int sequence;
} xcb_res_query_version_cookie_t;
/** Opcode for xcb_res_query_version. */
#define XCB_RES_QUERY_VERSION 0
/**
* @brief xcb_res_query_version_request_t
**/
typedef struct xcb_res_query_version_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t client_major;
uint8_t client_minor;
} xcb_res_query_version_request_t;
/**
* @brief xcb_res_query_version_reply_t
**/
typedef struct xcb_res_query_version_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t server_major;
uint16_t server_minor;
} xcb_res_query_version_reply_t;
/**
* @brief xcb_res_query_clients_cookie_t
**/
typedef struct xcb_res_query_clients_cookie_t {
unsigned int sequence;
} xcb_res_query_clients_cookie_t;
/** Opcode for xcb_res_query_clients. */
#define XCB_RES_QUERY_CLIENTS 1
/**
* @brief xcb_res_query_clients_request_t
**/
typedef struct xcb_res_query_clients_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_res_query_clients_request_t;
/**
* @brief xcb_res_query_clients_reply_t
**/
typedef struct xcb_res_query_clients_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t num_clients;
uint8_t pad1[20];
} xcb_res_query_clients_reply_t;
/**
* @brief xcb_res_query_client_resources_cookie_t
**/
typedef struct xcb_res_query_client_resources_cookie_t {
unsigned int sequence;
} xcb_res_query_client_resources_cookie_t;
/** Opcode for xcb_res_query_client_resources. */
#define XCB_RES_QUERY_CLIENT_RESOURCES 2
/**
* @brief xcb_res_query_client_resources_request_t
**/
typedef struct xcb_res_query_client_resources_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t xid;
} xcb_res_query_client_resources_request_t;
/**
* @brief xcb_res_query_client_resources_reply_t
**/
typedef struct xcb_res_query_client_resources_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t num_types;
uint8_t pad1[20];
} xcb_res_query_client_resources_reply_t;
/**
* @brief xcb_res_query_client_pixmap_bytes_cookie_t
**/
typedef struct xcb_res_query_client_pixmap_bytes_cookie_t {
unsigned int sequence;
} xcb_res_query_client_pixmap_bytes_cookie_t;
/** Opcode for xcb_res_query_client_pixmap_bytes. */
#define XCB_RES_QUERY_CLIENT_PIXMAP_BYTES 3
/**
* @brief xcb_res_query_client_pixmap_bytes_request_t
**/
typedef struct xcb_res_query_client_pixmap_bytes_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t xid;
} xcb_res_query_client_pixmap_bytes_request_t;
/**
* @brief xcb_res_query_client_pixmap_bytes_reply_t
**/
typedef struct xcb_res_query_client_pixmap_bytes_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t bytes;
uint32_t bytes_overflow;
} xcb_res_query_client_pixmap_bytes_reply_t;
/**
* @brief xcb_res_query_client_ids_cookie_t
**/
typedef struct xcb_res_query_client_ids_cookie_t {
unsigned int sequence;
} xcb_res_query_client_ids_cookie_t;
/** Opcode for xcb_res_query_client_ids. */
#define XCB_RES_QUERY_CLIENT_IDS 4
/**
* @brief xcb_res_query_client_ids_request_t
**/
typedef struct xcb_res_query_client_ids_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t num_specs;
} xcb_res_query_client_ids_request_t;
/**
* @brief xcb_res_query_client_ids_reply_t
**/
typedef struct xcb_res_query_client_ids_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t num_ids;
uint8_t pad1[20];
} xcb_res_query_client_ids_reply_t;
/**
* @brief xcb_res_query_resource_bytes_cookie_t
**/
typedef struct xcb_res_query_resource_bytes_cookie_t {
unsigned int sequence;
} xcb_res_query_resource_bytes_cookie_t;
/** Opcode for xcb_res_query_resource_bytes. */
#define XCB_RES_QUERY_RESOURCE_BYTES 5
/**
* @brief xcb_res_query_resource_bytes_request_t
**/
typedef struct xcb_res_query_resource_bytes_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t client;
uint32_t num_specs;
} xcb_res_query_resource_bytes_request_t;
/**
* @brief xcb_res_query_resource_bytes_reply_t
**/
typedef struct xcb_res_query_resource_bytes_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t num_sizes;
uint8_t pad1[20];
} xcb_res_query_resource_bytes_reply_t;
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_res_client_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_res_client_t)
*/
void
xcb_res_client_next (xcb_res_client_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_res_client_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_res_client_end (xcb_res_client_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_res_type_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_res_type_t)
*/
void
xcb_res_type_next (xcb_res_type_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_res_type_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_res_type_end (xcb_res_type_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_res_client_id_spec_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_res_client_id_spec_t)
*/
void
xcb_res_client_id_spec_next (xcb_res_client_id_spec_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_res_client_id_spec_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_res_client_id_spec_end (xcb_res_client_id_spec_iterator_t i);
int
xcb_res_client_id_value_sizeof (const void *_buffer);
uint32_t *
xcb_res_client_id_value_value (const xcb_res_client_id_value_t *R);
int
xcb_res_client_id_value_value_length (const xcb_res_client_id_value_t *R);
xcb_generic_iterator_t
xcb_res_client_id_value_value_end (const xcb_res_client_id_value_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_res_client_id_value_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_res_client_id_value_t)
*/
void
xcb_res_client_id_value_next (xcb_res_client_id_value_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_res_client_id_value_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_res_client_id_value_end (xcb_res_client_id_value_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_res_resource_id_spec_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_res_resource_id_spec_t)
*/
void
xcb_res_resource_id_spec_next (xcb_res_resource_id_spec_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_res_resource_id_spec_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_res_resource_id_spec_end (xcb_res_resource_id_spec_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_res_resource_size_spec_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_res_resource_size_spec_t)
*/
void
xcb_res_resource_size_spec_next (xcb_res_resource_size_spec_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_res_resource_size_spec_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_res_resource_size_spec_end (xcb_res_resource_size_spec_iterator_t i);
int
xcb_res_resource_size_value_sizeof (const void *_buffer);
xcb_res_resource_size_spec_t *
xcb_res_resource_size_value_cross_references (const xcb_res_resource_size_value_t *R);
int
xcb_res_resource_size_value_cross_references_length (const xcb_res_resource_size_value_t *R);
xcb_res_resource_size_spec_iterator_t
xcb_res_resource_size_value_cross_references_iterator (const xcb_res_resource_size_value_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_res_resource_size_value_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_res_resource_size_value_t)
*/
void
xcb_res_resource_size_value_next (xcb_res_resource_size_value_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_res_resource_size_value_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_res_resource_size_value_end (xcb_res_resource_size_value_iterator_t i);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_res_query_version_cookie_t
xcb_res_query_version (xcb_connection_t *c,
uint8_t client_major,
uint8_t client_minor);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_res_query_version_cookie_t
xcb_res_query_version_unchecked (xcb_connection_t *c,
uint8_t client_major,
uint8_t client_minor);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_res_query_version_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_res_query_version_reply_t *
xcb_res_query_version_reply (xcb_connection_t *c,
xcb_res_query_version_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_res_query_clients_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_res_query_clients_cookie_t
xcb_res_query_clients (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_res_query_clients_cookie_t
xcb_res_query_clients_unchecked (xcb_connection_t *c);
xcb_res_client_t *
xcb_res_query_clients_clients (const xcb_res_query_clients_reply_t *R);
int
xcb_res_query_clients_clients_length (const xcb_res_query_clients_reply_t *R);
xcb_res_client_iterator_t
xcb_res_query_clients_clients_iterator (const xcb_res_query_clients_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_res_query_clients_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_res_query_clients_reply_t *
xcb_res_query_clients_reply (xcb_connection_t *c,
xcb_res_query_clients_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_res_query_client_resources_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_res_query_client_resources_cookie_t
xcb_res_query_client_resources (xcb_connection_t *c,
uint32_t xid);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_res_query_client_resources_cookie_t
xcb_res_query_client_resources_unchecked (xcb_connection_t *c,
uint32_t xid);
xcb_res_type_t *
xcb_res_query_client_resources_types (const xcb_res_query_client_resources_reply_t *R);
int
xcb_res_query_client_resources_types_length (const xcb_res_query_client_resources_reply_t *R);
xcb_res_type_iterator_t
xcb_res_query_client_resources_types_iterator (const xcb_res_query_client_resources_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_res_query_client_resources_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_res_query_client_resources_reply_t *
xcb_res_query_client_resources_reply (xcb_connection_t *c,
xcb_res_query_client_resources_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_res_query_client_pixmap_bytes_cookie_t
xcb_res_query_client_pixmap_bytes (xcb_connection_t *c,
uint32_t xid);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_res_query_client_pixmap_bytes_cookie_t
xcb_res_query_client_pixmap_bytes_unchecked (xcb_connection_t *c,
uint32_t xid);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_res_query_client_pixmap_bytes_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_res_query_client_pixmap_bytes_reply_t *
xcb_res_query_client_pixmap_bytes_reply (xcb_connection_t *c,
xcb_res_query_client_pixmap_bytes_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_res_query_client_ids_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_res_query_client_ids_cookie_t
xcb_res_query_client_ids (xcb_connection_t *c,
uint32_t num_specs,
const xcb_res_client_id_spec_t *specs);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_res_query_client_ids_cookie_t
xcb_res_query_client_ids_unchecked (xcb_connection_t *c,
uint32_t num_specs,
const xcb_res_client_id_spec_t *specs);
int
xcb_res_query_client_ids_ids_length (const xcb_res_query_client_ids_reply_t *R);
xcb_res_client_id_value_iterator_t
xcb_res_query_client_ids_ids_iterator (const xcb_res_query_client_ids_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_res_query_client_ids_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_res_query_client_ids_reply_t *
xcb_res_query_client_ids_reply (xcb_connection_t *c,
xcb_res_query_client_ids_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_res_query_resource_bytes_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_res_query_resource_bytes_cookie_t
xcb_res_query_resource_bytes (xcb_connection_t *c,
uint32_t client,
uint32_t num_specs,
const xcb_res_resource_id_spec_t *specs);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_res_query_resource_bytes_cookie_t
xcb_res_query_resource_bytes_unchecked (xcb_connection_t *c,
uint32_t client,
uint32_t num_specs,
const xcb_res_resource_id_spec_t *specs);
int
xcb_res_query_resource_bytes_sizes_length (const xcb_res_query_resource_bytes_reply_t *R);
xcb_res_resource_size_value_iterator_t
xcb_res_query_resource_bytes_sizes_iterator (const xcb_res_query_resource_bytes_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_res_query_resource_bytes_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_res_query_resource_bytes_reply_t *
xcb_res_query_resource_bytes_reply (xcb_connection_t *c,
xcb_res_query_resource_bytes_cookie_t cookie /**< */,
xcb_generic_error_t **e);
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/
xcb/xv.h 0000644 00000160674 15201526705 0006147 0 ustar 00 /*
* This file generated automatically from xv.xml by c_client.py.
* Edit at your peril.
*/
/**
* @defgroup XCB_Xv_API XCB Xv API
* @brief Xv XCB Protocol Implementation.
* @{
**/
#ifndef __XV_H
#define __XV_H
#include "xcb.h"
#include "xproto.h"
#include "shm.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XCB_XV_MAJOR_VERSION 2
#define XCB_XV_MINOR_VERSION 2
extern xcb_extension_t xcb_xv_id;
typedef uint32_t xcb_xv_port_t;
/**
* @brief xcb_xv_port_iterator_t
**/
typedef struct xcb_xv_port_iterator_t {
xcb_xv_port_t *data;
int rem;
int index;
} xcb_xv_port_iterator_t;
typedef uint32_t xcb_xv_encoding_t;
/**
* @brief xcb_xv_encoding_iterator_t
**/
typedef struct xcb_xv_encoding_iterator_t {
xcb_xv_encoding_t *data;
int rem;
int index;
} xcb_xv_encoding_iterator_t;
typedef enum xcb_xv_type_t {
XCB_XV_TYPE_INPUT_MASK = 1,
XCB_XV_TYPE_OUTPUT_MASK = 2,
XCB_XV_TYPE_VIDEO_MASK = 4,
XCB_XV_TYPE_STILL_MASK = 8,
XCB_XV_TYPE_IMAGE_MASK = 16
} xcb_xv_type_t;
typedef enum xcb_xv_image_format_info_type_t {
XCB_XV_IMAGE_FORMAT_INFO_TYPE_RGB = 0,
XCB_XV_IMAGE_FORMAT_INFO_TYPE_YUV = 1
} xcb_xv_image_format_info_type_t;
typedef enum xcb_xv_image_format_info_format_t {
XCB_XV_IMAGE_FORMAT_INFO_FORMAT_PACKED = 0,
XCB_XV_IMAGE_FORMAT_INFO_FORMAT_PLANAR = 1
} xcb_xv_image_format_info_format_t;
typedef enum xcb_xv_attribute_flag_t {
XCB_XV_ATTRIBUTE_FLAG_GETTABLE = 1,
XCB_XV_ATTRIBUTE_FLAG_SETTABLE = 2
} xcb_xv_attribute_flag_t;
typedef enum xcb_xv_video_notify_reason_t {
XCB_XV_VIDEO_NOTIFY_REASON_STARTED = 0,
XCB_XV_VIDEO_NOTIFY_REASON_STOPPED = 1,
XCB_XV_VIDEO_NOTIFY_REASON_BUSY = 2,
XCB_XV_VIDEO_NOTIFY_REASON_PREEMPTED = 3,
XCB_XV_VIDEO_NOTIFY_REASON_HARD_ERROR = 4
} xcb_xv_video_notify_reason_t;
typedef enum xcb_xv_scanline_order_t {
XCB_XV_SCANLINE_ORDER_TOP_TO_BOTTOM = 0,
XCB_XV_SCANLINE_ORDER_BOTTOM_TO_TOP = 1
} xcb_xv_scanline_order_t;
typedef enum xcb_xv_grab_port_status_t {
XCB_XV_GRAB_PORT_STATUS_SUCCESS = 0,
XCB_XV_GRAB_PORT_STATUS_BAD_EXTENSION = 1,
XCB_XV_GRAB_PORT_STATUS_ALREADY_GRABBED = 2,
XCB_XV_GRAB_PORT_STATUS_INVALID_TIME = 3,
XCB_XV_GRAB_PORT_STATUS_BAD_REPLY = 4,
XCB_XV_GRAB_PORT_STATUS_BAD_ALLOC = 5
} xcb_xv_grab_port_status_t;
/**
* @brief xcb_xv_rational_t
**/
typedef struct xcb_xv_rational_t {
int32_t numerator;
int32_t denominator;
} xcb_xv_rational_t;
/**
* @brief xcb_xv_rational_iterator_t
**/
typedef struct xcb_xv_rational_iterator_t {
xcb_xv_rational_t *data;
int rem;
int index;
} xcb_xv_rational_iterator_t;
/**
* @brief xcb_xv_format_t
**/
typedef struct xcb_xv_format_t {
xcb_visualid_t visual;
uint8_t depth;
uint8_t pad0[3];
} xcb_xv_format_t;
/**
* @brief xcb_xv_format_iterator_t
**/
typedef struct xcb_xv_format_iterator_t {
xcb_xv_format_t *data;
int rem;
int index;
} xcb_xv_format_iterator_t;
/**
* @brief xcb_xv_adaptor_info_t
**/
typedef struct xcb_xv_adaptor_info_t {
xcb_xv_port_t base_id;
uint16_t name_size;
uint16_t num_ports;
uint16_t num_formats;
uint8_t type;
uint8_t pad0;
} xcb_xv_adaptor_info_t;
/**
* @brief xcb_xv_adaptor_info_iterator_t
**/
typedef struct xcb_xv_adaptor_info_iterator_t {
xcb_xv_adaptor_info_t *data;
int rem;
int index;
} xcb_xv_adaptor_info_iterator_t;
/**
* @brief xcb_xv_encoding_info_t
**/
typedef struct xcb_xv_encoding_info_t {
xcb_xv_encoding_t encoding;
uint16_t name_size;
uint16_t width;
uint16_t height;
uint8_t pad0[2];
xcb_xv_rational_t rate;
} xcb_xv_encoding_info_t;
/**
* @brief xcb_xv_encoding_info_iterator_t
**/
typedef struct xcb_xv_encoding_info_iterator_t {
xcb_xv_encoding_info_t *data;
int rem;
int index;
} xcb_xv_encoding_info_iterator_t;
/**
* @brief xcb_xv_image_t
**/
typedef struct xcb_xv_image_t {
uint32_t id;
uint16_t width;
uint16_t height;
uint32_t data_size;
uint32_t num_planes;
} xcb_xv_image_t;
/**
* @brief xcb_xv_image_iterator_t
**/
typedef struct xcb_xv_image_iterator_t {
xcb_xv_image_t *data;
int rem;
int index;
} xcb_xv_image_iterator_t;
/**
* @brief xcb_xv_attribute_info_t
**/
typedef struct xcb_xv_attribute_info_t {
uint32_t flags;
int32_t min;
int32_t max;
uint32_t size;
} xcb_xv_attribute_info_t;
/**
* @brief xcb_xv_attribute_info_iterator_t
**/
typedef struct xcb_xv_attribute_info_iterator_t {
xcb_xv_attribute_info_t *data;
int rem;
int index;
} xcb_xv_attribute_info_iterator_t;
/**
* @brief xcb_xv_image_format_info_t
**/
typedef struct xcb_xv_image_format_info_t {
uint32_t id;
uint8_t type;
uint8_t byte_order;
uint8_t pad0[2];
uint8_t guid[16];
uint8_t bpp;
uint8_t num_planes;
uint8_t pad1[2];
uint8_t depth;
uint8_t pad2[3];
uint32_t red_mask;
uint32_t green_mask;
uint32_t blue_mask;
uint8_t format;
uint8_t pad3[3];
uint32_t y_sample_bits;
uint32_t u_sample_bits;
uint32_t v_sample_bits;
uint32_t vhorz_y_period;
uint32_t vhorz_u_period;
uint32_t vhorz_v_period;
uint32_t vvert_y_period;
uint32_t vvert_u_period;
uint32_t vvert_v_period;
uint8_t vcomp_order[32];
uint8_t vscanline_order;
uint8_t pad4[11];
} xcb_xv_image_format_info_t;
/**
* @brief xcb_xv_image_format_info_iterator_t
**/
typedef struct xcb_xv_image_format_info_iterator_t {
xcb_xv_image_format_info_t *data;
int rem;
int index;
} xcb_xv_image_format_info_iterator_t;
/** Opcode for xcb_xv_bad_port. */
#define XCB_XV_BAD_PORT 0
/**
* @brief xcb_xv_bad_port_error_t
**/
typedef struct xcb_xv_bad_port_error_t {
uint8_t response_type;
uint8_t error_code;
uint16_t sequence;
} xcb_xv_bad_port_error_t;
/** Opcode for xcb_xv_bad_encoding. */
#define XCB_XV_BAD_ENCODING 1
/**
* @brief xcb_xv_bad_encoding_error_t
**/
typedef struct xcb_xv_bad_encoding_error_t {
uint8_t response_type;
uint8_t error_code;
uint16_t sequence;
} xcb_xv_bad_encoding_error_t;
/** Opcode for xcb_xv_bad_control. */
#define XCB_XV_BAD_CONTROL 2
/**
* @brief xcb_xv_bad_control_error_t
**/
typedef struct xcb_xv_bad_control_error_t {
uint8_t response_type;
uint8_t error_code;
uint16_t sequence;
} xcb_xv_bad_control_error_t;
/** Opcode for xcb_xv_video_notify. */
#define XCB_XV_VIDEO_NOTIFY 0
/**
* @brief xcb_xv_video_notify_event_t
**/
typedef struct xcb_xv_video_notify_event_t {
uint8_t response_type;
uint8_t reason;
uint16_t sequence;
xcb_timestamp_t time;
xcb_drawable_t drawable;
xcb_xv_port_t port;
} xcb_xv_video_notify_event_t;
/** Opcode for xcb_xv_port_notify. */
#define XCB_XV_PORT_NOTIFY 1
/**
* @brief xcb_xv_port_notify_event_t
**/
typedef struct xcb_xv_port_notify_event_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
xcb_timestamp_t time;
xcb_xv_port_t port;
xcb_atom_t attribute;
int32_t value;
} xcb_xv_port_notify_event_t;
/**
* @brief xcb_xv_query_extension_cookie_t
**/
typedef struct xcb_xv_query_extension_cookie_t {
unsigned int sequence;
} xcb_xv_query_extension_cookie_t;
/** Opcode for xcb_xv_query_extension. */
#define XCB_XV_QUERY_EXTENSION 0
/**
* @brief xcb_xv_query_extension_request_t
**/
typedef struct xcb_xv_query_extension_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_xv_query_extension_request_t;
/**
* @brief xcb_xv_query_extension_reply_t
**/
typedef struct xcb_xv_query_extension_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t major;
uint16_t minor;
} xcb_xv_query_extension_reply_t;
/**
* @brief xcb_xv_query_adaptors_cookie_t
**/
typedef struct xcb_xv_query_adaptors_cookie_t {
unsigned int sequence;
} xcb_xv_query_adaptors_cookie_t;
/** Opcode for xcb_xv_query_adaptors. */
#define XCB_XV_QUERY_ADAPTORS 1
/**
* @brief xcb_xv_query_adaptors_request_t
**/
typedef struct xcb_xv_query_adaptors_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
} xcb_xv_query_adaptors_request_t;
/**
* @brief xcb_xv_query_adaptors_reply_t
**/
typedef struct xcb_xv_query_adaptors_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t num_adaptors;
uint8_t pad1[22];
} xcb_xv_query_adaptors_reply_t;
/**
* @brief xcb_xv_query_encodings_cookie_t
**/
typedef struct xcb_xv_query_encodings_cookie_t {
unsigned int sequence;
} xcb_xv_query_encodings_cookie_t;
/** Opcode for xcb_xv_query_encodings. */
#define XCB_XV_QUERY_ENCODINGS 2
/**
* @brief xcb_xv_query_encodings_request_t
**/
typedef struct xcb_xv_query_encodings_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xv_port_t port;
} xcb_xv_query_encodings_request_t;
/**
* @brief xcb_xv_query_encodings_reply_t
**/
typedef struct xcb_xv_query_encodings_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t num_encodings;
uint8_t pad1[22];
} xcb_xv_query_encodings_reply_t;
/**
* @brief xcb_xv_grab_port_cookie_t
**/
typedef struct xcb_xv_grab_port_cookie_t {
unsigned int sequence;
} xcb_xv_grab_port_cookie_t;
/** Opcode for xcb_xv_grab_port. */
#define XCB_XV_GRAB_PORT 3
/**
* @brief xcb_xv_grab_port_request_t
**/
typedef struct xcb_xv_grab_port_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xv_port_t port;
xcb_timestamp_t time;
} xcb_xv_grab_port_request_t;
/**
* @brief xcb_xv_grab_port_reply_t
**/
typedef struct xcb_xv_grab_port_reply_t {
uint8_t response_type;
uint8_t result;
uint16_t sequence;
uint32_t length;
} xcb_xv_grab_port_reply_t;
/** Opcode for xcb_xv_ungrab_port. */
#define XCB_XV_UNGRAB_PORT 4
/**
* @brief xcb_xv_ungrab_port_request_t
**/
typedef struct xcb_xv_ungrab_port_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xv_port_t port;
xcb_timestamp_t time;
} xcb_xv_ungrab_port_request_t;
/** Opcode for xcb_xv_put_video. */
#define XCB_XV_PUT_VIDEO 5
/**
* @brief xcb_xv_put_video_request_t
**/
typedef struct xcb_xv_put_video_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xv_port_t port;
xcb_drawable_t drawable;
xcb_gcontext_t gc;
int16_t vid_x;
int16_t vid_y;
uint16_t vid_w;
uint16_t vid_h;
int16_t drw_x;
int16_t drw_y;
uint16_t drw_w;
uint16_t drw_h;
} xcb_xv_put_video_request_t;
/** Opcode for xcb_xv_put_still. */
#define XCB_XV_PUT_STILL 6
/**
* @brief xcb_xv_put_still_request_t
**/
typedef struct xcb_xv_put_still_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xv_port_t port;
xcb_drawable_t drawable;
xcb_gcontext_t gc;
int16_t vid_x;
int16_t vid_y;
uint16_t vid_w;
uint16_t vid_h;
int16_t drw_x;
int16_t drw_y;
uint16_t drw_w;
uint16_t drw_h;
} xcb_xv_put_still_request_t;
/** Opcode for xcb_xv_get_video. */
#define XCB_XV_GET_VIDEO 7
/**
* @brief xcb_xv_get_video_request_t
**/
typedef struct xcb_xv_get_video_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xv_port_t port;
xcb_drawable_t drawable;
xcb_gcontext_t gc;
int16_t vid_x;
int16_t vid_y;
uint16_t vid_w;
uint16_t vid_h;
int16_t drw_x;
int16_t drw_y;
uint16_t drw_w;
uint16_t drw_h;
} xcb_xv_get_video_request_t;
/** Opcode for xcb_xv_get_still. */
#define XCB_XV_GET_STILL 8
/**
* @brief xcb_xv_get_still_request_t
**/
typedef struct xcb_xv_get_still_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xv_port_t port;
xcb_drawable_t drawable;
xcb_gcontext_t gc;
int16_t vid_x;
int16_t vid_y;
uint16_t vid_w;
uint16_t vid_h;
int16_t drw_x;
int16_t drw_y;
uint16_t drw_w;
uint16_t drw_h;
} xcb_xv_get_still_request_t;
/** Opcode for xcb_xv_stop_video. */
#define XCB_XV_STOP_VIDEO 9
/**
* @brief xcb_xv_stop_video_request_t
**/
typedef struct xcb_xv_stop_video_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xv_port_t port;
xcb_drawable_t drawable;
} xcb_xv_stop_video_request_t;
/** Opcode for xcb_xv_select_video_notify. */
#define XCB_XV_SELECT_VIDEO_NOTIFY 10
/**
* @brief xcb_xv_select_video_notify_request_t
**/
typedef struct xcb_xv_select_video_notify_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_drawable_t drawable;
uint8_t onoff;
uint8_t pad0[3];
} xcb_xv_select_video_notify_request_t;
/** Opcode for xcb_xv_select_port_notify. */
#define XCB_XV_SELECT_PORT_NOTIFY 11
/**
* @brief xcb_xv_select_port_notify_request_t
**/
typedef struct xcb_xv_select_port_notify_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xv_port_t port;
uint8_t onoff;
uint8_t pad0[3];
} xcb_xv_select_port_notify_request_t;
/**
* @brief xcb_xv_query_best_size_cookie_t
**/
typedef struct xcb_xv_query_best_size_cookie_t {
unsigned int sequence;
} xcb_xv_query_best_size_cookie_t;
/** Opcode for xcb_xv_query_best_size. */
#define XCB_XV_QUERY_BEST_SIZE 12
/**
* @brief xcb_xv_query_best_size_request_t
**/
typedef struct xcb_xv_query_best_size_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xv_port_t port;
uint16_t vid_w;
uint16_t vid_h;
uint16_t drw_w;
uint16_t drw_h;
uint8_t motion;
uint8_t pad0[3];
} xcb_xv_query_best_size_request_t;
/**
* @brief xcb_xv_query_best_size_reply_t
**/
typedef struct xcb_xv_query_best_size_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t actual_width;
uint16_t actual_height;
} xcb_xv_query_best_size_reply_t;
/** Opcode for xcb_xv_set_port_attribute. */
#define XCB_XV_SET_PORT_ATTRIBUTE 13
/**
* @brief xcb_xv_set_port_attribute_request_t
**/
typedef struct xcb_xv_set_port_attribute_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xv_port_t port;
xcb_atom_t attribute;
int32_t value;
} xcb_xv_set_port_attribute_request_t;
/**
* @brief xcb_xv_get_port_attribute_cookie_t
**/
typedef struct xcb_xv_get_port_attribute_cookie_t {
unsigned int sequence;
} xcb_xv_get_port_attribute_cookie_t;
/** Opcode for xcb_xv_get_port_attribute. */
#define XCB_XV_GET_PORT_ATTRIBUTE 14
/**
* @brief xcb_xv_get_port_attribute_request_t
**/
typedef struct xcb_xv_get_port_attribute_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xv_port_t port;
xcb_atom_t attribute;
} xcb_xv_get_port_attribute_request_t;
/**
* @brief xcb_xv_get_port_attribute_reply_t
**/
typedef struct xcb_xv_get_port_attribute_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
int32_t value;
} xcb_xv_get_port_attribute_reply_t;
/**
* @brief xcb_xv_query_port_attributes_cookie_t
**/
typedef struct xcb_xv_query_port_attributes_cookie_t {
unsigned int sequence;
} xcb_xv_query_port_attributes_cookie_t;
/** Opcode for xcb_xv_query_port_attributes. */
#define XCB_XV_QUERY_PORT_ATTRIBUTES 15
/**
* @brief xcb_xv_query_port_attributes_request_t
**/
typedef struct xcb_xv_query_port_attributes_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xv_port_t port;
} xcb_xv_query_port_attributes_request_t;
/**
* @brief xcb_xv_query_port_attributes_reply_t
**/
typedef struct xcb_xv_query_port_attributes_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t num_attributes;
uint32_t text_size;
uint8_t pad1[16];
} xcb_xv_query_port_attributes_reply_t;
/**
* @brief xcb_xv_list_image_formats_cookie_t
**/
typedef struct xcb_xv_list_image_formats_cookie_t {
unsigned int sequence;
} xcb_xv_list_image_formats_cookie_t;
/** Opcode for xcb_xv_list_image_formats. */
#define XCB_XV_LIST_IMAGE_FORMATS 16
/**
* @brief xcb_xv_list_image_formats_request_t
**/
typedef struct xcb_xv_list_image_formats_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xv_port_t port;
} xcb_xv_list_image_formats_request_t;
/**
* @brief xcb_xv_list_image_formats_reply_t
**/
typedef struct xcb_xv_list_image_formats_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t num_formats;
uint8_t pad1[20];
} xcb_xv_list_image_formats_reply_t;
/**
* @brief xcb_xv_query_image_attributes_cookie_t
**/
typedef struct xcb_xv_query_image_attributes_cookie_t {
unsigned int sequence;
} xcb_xv_query_image_attributes_cookie_t;
/** Opcode for xcb_xv_query_image_attributes. */
#define XCB_XV_QUERY_IMAGE_ATTRIBUTES 17
/**
* @brief xcb_xv_query_image_attributes_request_t
**/
typedef struct xcb_xv_query_image_attributes_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xv_port_t port;
uint32_t id;
uint16_t width;
uint16_t height;
} xcb_xv_query_image_attributes_request_t;
/**
* @brief xcb_xv_query_image_attributes_reply_t
**/
typedef struct xcb_xv_query_image_attributes_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t num_planes;
uint32_t data_size;
uint16_t width;
uint16_t height;
uint8_t pad1[12];
} xcb_xv_query_image_attributes_reply_t;
/** Opcode for xcb_xv_put_image. */
#define XCB_XV_PUT_IMAGE 18
/**
* @brief xcb_xv_put_image_request_t
**/
typedef struct xcb_xv_put_image_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xv_port_t port;
xcb_drawable_t drawable;
xcb_gcontext_t gc;
uint32_t id;
int16_t src_x;
int16_t src_y;
uint16_t src_w;
uint16_t src_h;
int16_t drw_x;
int16_t drw_y;
uint16_t drw_w;
uint16_t drw_h;
uint16_t width;
uint16_t height;
} xcb_xv_put_image_request_t;
/** Opcode for xcb_xv_shm_put_image. */
#define XCB_XV_SHM_PUT_IMAGE 19
/**
* @brief xcb_xv_shm_put_image_request_t
**/
typedef struct xcb_xv_shm_put_image_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xv_port_t port;
xcb_drawable_t drawable;
xcb_gcontext_t gc;
xcb_shm_seg_t shmseg;
uint32_t id;
uint32_t offset;
int16_t src_x;
int16_t src_y;
uint16_t src_w;
uint16_t src_h;
int16_t drw_x;
int16_t drw_y;
uint16_t drw_w;
uint16_t drw_h;
uint16_t width;
uint16_t height;
uint8_t send_event;
uint8_t pad0[3];
} xcb_xv_shm_put_image_request_t;
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xv_port_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xv_port_t)
*/
void
xcb_xv_port_next (xcb_xv_port_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xv_port_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xv_port_end (xcb_xv_port_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xv_encoding_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xv_encoding_t)
*/
void
xcb_xv_encoding_next (xcb_xv_encoding_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xv_encoding_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xv_encoding_end (xcb_xv_encoding_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xv_rational_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xv_rational_t)
*/
void
xcb_xv_rational_next (xcb_xv_rational_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xv_rational_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xv_rational_end (xcb_xv_rational_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xv_format_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xv_format_t)
*/
void
xcb_xv_format_next (xcb_xv_format_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xv_format_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xv_format_end (xcb_xv_format_iterator_t i);
int
xcb_xv_adaptor_info_sizeof (const void *_buffer);
char *
xcb_xv_adaptor_info_name (const xcb_xv_adaptor_info_t *R);
int
xcb_xv_adaptor_info_name_length (const xcb_xv_adaptor_info_t *R);
xcb_generic_iterator_t
xcb_xv_adaptor_info_name_end (const xcb_xv_adaptor_info_t *R);
xcb_xv_format_t *
xcb_xv_adaptor_info_formats (const xcb_xv_adaptor_info_t *R);
int
xcb_xv_adaptor_info_formats_length (const xcb_xv_adaptor_info_t *R);
xcb_xv_format_iterator_t
xcb_xv_adaptor_info_formats_iterator (const xcb_xv_adaptor_info_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xv_adaptor_info_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xv_adaptor_info_t)
*/
void
xcb_xv_adaptor_info_next (xcb_xv_adaptor_info_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xv_adaptor_info_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xv_adaptor_info_end (xcb_xv_adaptor_info_iterator_t i);
int
xcb_xv_encoding_info_sizeof (const void *_buffer);
char *
xcb_xv_encoding_info_name (const xcb_xv_encoding_info_t *R);
int
xcb_xv_encoding_info_name_length (const xcb_xv_encoding_info_t *R);
xcb_generic_iterator_t
xcb_xv_encoding_info_name_end (const xcb_xv_encoding_info_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xv_encoding_info_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xv_encoding_info_t)
*/
void
xcb_xv_encoding_info_next (xcb_xv_encoding_info_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xv_encoding_info_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xv_encoding_info_end (xcb_xv_encoding_info_iterator_t i);
int
xcb_xv_image_sizeof (const void *_buffer);
uint32_t *
xcb_xv_image_pitches (const xcb_xv_image_t *R);
int
xcb_xv_image_pitches_length (const xcb_xv_image_t *R);
xcb_generic_iterator_t
xcb_xv_image_pitches_end (const xcb_xv_image_t *R);
uint32_t *
xcb_xv_image_offsets (const xcb_xv_image_t *R);
int
xcb_xv_image_offsets_length (const xcb_xv_image_t *R);
xcb_generic_iterator_t
xcb_xv_image_offsets_end (const xcb_xv_image_t *R);
uint8_t *
xcb_xv_image_data (const xcb_xv_image_t *R);
int
xcb_xv_image_data_length (const xcb_xv_image_t *R);
xcb_generic_iterator_t
xcb_xv_image_data_end (const xcb_xv_image_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xv_image_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xv_image_t)
*/
void
xcb_xv_image_next (xcb_xv_image_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xv_image_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xv_image_end (xcb_xv_image_iterator_t i);
int
xcb_xv_attribute_info_sizeof (const void *_buffer);
char *
xcb_xv_attribute_info_name (const xcb_xv_attribute_info_t *R);
int
xcb_xv_attribute_info_name_length (const xcb_xv_attribute_info_t *R);
xcb_generic_iterator_t
xcb_xv_attribute_info_name_end (const xcb_xv_attribute_info_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xv_attribute_info_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xv_attribute_info_t)
*/
void
xcb_xv_attribute_info_next (xcb_xv_attribute_info_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xv_attribute_info_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xv_attribute_info_end (xcb_xv_attribute_info_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xv_image_format_info_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xv_image_format_info_t)
*/
void
xcb_xv_image_format_info_next (xcb_xv_image_format_info_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xv_image_format_info_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xv_image_format_info_end (xcb_xv_image_format_info_iterator_t i);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xv_query_extension_cookie_t
xcb_xv_query_extension (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xv_query_extension_cookie_t
xcb_xv_query_extension_unchecked (xcb_connection_t *c);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xv_query_extension_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xv_query_extension_reply_t *
xcb_xv_query_extension_reply (xcb_connection_t *c,
xcb_xv_query_extension_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_xv_query_adaptors_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xv_query_adaptors_cookie_t
xcb_xv_query_adaptors (xcb_connection_t *c,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xv_query_adaptors_cookie_t
xcb_xv_query_adaptors_unchecked (xcb_connection_t *c,
xcb_window_t window);
int
xcb_xv_query_adaptors_info_length (const xcb_xv_query_adaptors_reply_t *R);
xcb_xv_adaptor_info_iterator_t
xcb_xv_query_adaptors_info_iterator (const xcb_xv_query_adaptors_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xv_query_adaptors_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xv_query_adaptors_reply_t *
xcb_xv_query_adaptors_reply (xcb_connection_t *c,
xcb_xv_query_adaptors_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_xv_query_encodings_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xv_query_encodings_cookie_t
xcb_xv_query_encodings (xcb_connection_t *c,
xcb_xv_port_t port);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xv_query_encodings_cookie_t
xcb_xv_query_encodings_unchecked (xcb_connection_t *c,
xcb_xv_port_t port);
int
xcb_xv_query_encodings_info_length (const xcb_xv_query_encodings_reply_t *R);
xcb_xv_encoding_info_iterator_t
xcb_xv_query_encodings_info_iterator (const xcb_xv_query_encodings_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xv_query_encodings_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xv_query_encodings_reply_t *
xcb_xv_query_encodings_reply (xcb_connection_t *c,
xcb_xv_query_encodings_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xv_grab_port_cookie_t
xcb_xv_grab_port (xcb_connection_t *c,
xcb_xv_port_t port,
xcb_timestamp_t time);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xv_grab_port_cookie_t
xcb_xv_grab_port_unchecked (xcb_connection_t *c,
xcb_xv_port_t port,
xcb_timestamp_t time);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xv_grab_port_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xv_grab_port_reply_t *
xcb_xv_grab_port_reply (xcb_connection_t *c,
xcb_xv_grab_port_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xv_ungrab_port_checked (xcb_connection_t *c,
xcb_xv_port_t port,
xcb_timestamp_t time);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xv_ungrab_port (xcb_connection_t *c,
xcb_xv_port_t port,
xcb_timestamp_t time);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xv_put_video_checked (xcb_connection_t *c,
xcb_xv_port_t port,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
int16_t vid_x,
int16_t vid_y,
uint16_t vid_w,
uint16_t vid_h,
int16_t drw_x,
int16_t drw_y,
uint16_t drw_w,
uint16_t drw_h);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xv_put_video (xcb_connection_t *c,
xcb_xv_port_t port,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
int16_t vid_x,
int16_t vid_y,
uint16_t vid_w,
uint16_t vid_h,
int16_t drw_x,
int16_t drw_y,
uint16_t drw_w,
uint16_t drw_h);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xv_put_still_checked (xcb_connection_t *c,
xcb_xv_port_t port,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
int16_t vid_x,
int16_t vid_y,
uint16_t vid_w,
uint16_t vid_h,
int16_t drw_x,
int16_t drw_y,
uint16_t drw_w,
uint16_t drw_h);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xv_put_still (xcb_connection_t *c,
xcb_xv_port_t port,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
int16_t vid_x,
int16_t vid_y,
uint16_t vid_w,
uint16_t vid_h,
int16_t drw_x,
int16_t drw_y,
uint16_t drw_w,
uint16_t drw_h);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xv_get_video_checked (xcb_connection_t *c,
xcb_xv_port_t port,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
int16_t vid_x,
int16_t vid_y,
uint16_t vid_w,
uint16_t vid_h,
int16_t drw_x,
int16_t drw_y,
uint16_t drw_w,
uint16_t drw_h);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xv_get_video (xcb_connection_t *c,
xcb_xv_port_t port,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
int16_t vid_x,
int16_t vid_y,
uint16_t vid_w,
uint16_t vid_h,
int16_t drw_x,
int16_t drw_y,
uint16_t drw_w,
uint16_t drw_h);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xv_get_still_checked (xcb_connection_t *c,
xcb_xv_port_t port,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
int16_t vid_x,
int16_t vid_y,
uint16_t vid_w,
uint16_t vid_h,
int16_t drw_x,
int16_t drw_y,
uint16_t drw_w,
uint16_t drw_h);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xv_get_still (xcb_connection_t *c,
xcb_xv_port_t port,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
int16_t vid_x,
int16_t vid_y,
uint16_t vid_w,
uint16_t vid_h,
int16_t drw_x,
int16_t drw_y,
uint16_t drw_w,
uint16_t drw_h);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xv_stop_video_checked (xcb_connection_t *c,
xcb_xv_port_t port,
xcb_drawable_t drawable);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xv_stop_video (xcb_connection_t *c,
xcb_xv_port_t port,
xcb_drawable_t drawable);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xv_select_video_notify_checked (xcb_connection_t *c,
xcb_drawable_t drawable,
uint8_t onoff);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xv_select_video_notify (xcb_connection_t *c,
xcb_drawable_t drawable,
uint8_t onoff);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xv_select_port_notify_checked (xcb_connection_t *c,
xcb_xv_port_t port,
uint8_t onoff);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xv_select_port_notify (xcb_connection_t *c,
xcb_xv_port_t port,
uint8_t onoff);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xv_query_best_size_cookie_t
xcb_xv_query_best_size (xcb_connection_t *c,
xcb_xv_port_t port,
uint16_t vid_w,
uint16_t vid_h,
uint16_t drw_w,
uint16_t drw_h,
uint8_t motion);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xv_query_best_size_cookie_t
xcb_xv_query_best_size_unchecked (xcb_connection_t *c,
xcb_xv_port_t port,
uint16_t vid_w,
uint16_t vid_h,
uint16_t drw_w,
uint16_t drw_h,
uint8_t motion);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xv_query_best_size_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xv_query_best_size_reply_t *
xcb_xv_query_best_size_reply (xcb_connection_t *c,
xcb_xv_query_best_size_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xv_set_port_attribute_checked (xcb_connection_t *c,
xcb_xv_port_t port,
xcb_atom_t attribute,
int32_t value);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xv_set_port_attribute (xcb_connection_t *c,
xcb_xv_port_t port,
xcb_atom_t attribute,
int32_t value);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xv_get_port_attribute_cookie_t
xcb_xv_get_port_attribute (xcb_connection_t *c,
xcb_xv_port_t port,
xcb_atom_t attribute);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xv_get_port_attribute_cookie_t
xcb_xv_get_port_attribute_unchecked (xcb_connection_t *c,
xcb_xv_port_t port,
xcb_atom_t attribute);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xv_get_port_attribute_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xv_get_port_attribute_reply_t *
xcb_xv_get_port_attribute_reply (xcb_connection_t *c,
xcb_xv_get_port_attribute_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_xv_query_port_attributes_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xv_query_port_attributes_cookie_t
xcb_xv_query_port_attributes (xcb_connection_t *c,
xcb_xv_port_t port);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xv_query_port_attributes_cookie_t
xcb_xv_query_port_attributes_unchecked (xcb_connection_t *c,
xcb_xv_port_t port);
int
xcb_xv_query_port_attributes_attributes_length (const xcb_xv_query_port_attributes_reply_t *R);
xcb_xv_attribute_info_iterator_t
xcb_xv_query_port_attributes_attributes_iterator (const xcb_xv_query_port_attributes_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xv_query_port_attributes_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xv_query_port_attributes_reply_t *
xcb_xv_query_port_attributes_reply (xcb_connection_t *c,
xcb_xv_query_port_attributes_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_xv_list_image_formats_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xv_list_image_formats_cookie_t
xcb_xv_list_image_formats (xcb_connection_t *c,
xcb_xv_port_t port);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xv_list_image_formats_cookie_t
xcb_xv_list_image_formats_unchecked (xcb_connection_t *c,
xcb_xv_port_t port);
xcb_xv_image_format_info_t *
xcb_xv_list_image_formats_format (const xcb_xv_list_image_formats_reply_t *R);
int
xcb_xv_list_image_formats_format_length (const xcb_xv_list_image_formats_reply_t *R);
xcb_xv_image_format_info_iterator_t
xcb_xv_list_image_formats_format_iterator (const xcb_xv_list_image_formats_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xv_list_image_formats_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xv_list_image_formats_reply_t *
xcb_xv_list_image_formats_reply (xcb_connection_t *c,
xcb_xv_list_image_formats_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_xv_query_image_attributes_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xv_query_image_attributes_cookie_t
xcb_xv_query_image_attributes (xcb_connection_t *c,
xcb_xv_port_t port,
uint32_t id,
uint16_t width,
uint16_t height);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xv_query_image_attributes_cookie_t
xcb_xv_query_image_attributes_unchecked (xcb_connection_t *c,
xcb_xv_port_t port,
uint32_t id,
uint16_t width,
uint16_t height);
uint32_t *
xcb_xv_query_image_attributes_pitches (const xcb_xv_query_image_attributes_reply_t *R);
int
xcb_xv_query_image_attributes_pitches_length (const xcb_xv_query_image_attributes_reply_t *R);
xcb_generic_iterator_t
xcb_xv_query_image_attributes_pitches_end (const xcb_xv_query_image_attributes_reply_t *R);
uint32_t *
xcb_xv_query_image_attributes_offsets (const xcb_xv_query_image_attributes_reply_t *R);
int
xcb_xv_query_image_attributes_offsets_length (const xcb_xv_query_image_attributes_reply_t *R);
xcb_generic_iterator_t
xcb_xv_query_image_attributes_offsets_end (const xcb_xv_query_image_attributes_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xv_query_image_attributes_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xv_query_image_attributes_reply_t *
xcb_xv_query_image_attributes_reply (xcb_connection_t *c,
xcb_xv_query_image_attributes_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_xv_put_image_sizeof (const void *_buffer,
uint32_t data_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xv_put_image_checked (xcb_connection_t *c,
xcb_xv_port_t port,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
uint32_t id,
int16_t src_x,
int16_t src_y,
uint16_t src_w,
uint16_t src_h,
int16_t drw_x,
int16_t drw_y,
uint16_t drw_w,
uint16_t drw_h,
uint16_t width,
uint16_t height,
uint32_t data_len,
const uint8_t *data);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xv_put_image (xcb_connection_t *c,
xcb_xv_port_t port,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
uint32_t id,
int16_t src_x,
int16_t src_y,
uint16_t src_w,
uint16_t src_h,
int16_t drw_x,
int16_t drw_y,
uint16_t drw_w,
uint16_t drw_h,
uint16_t width,
uint16_t height,
uint32_t data_len,
const uint8_t *data);
uint8_t *
xcb_xv_put_image_data (const xcb_xv_put_image_request_t *R);
int
xcb_xv_put_image_data_length (const xcb_xv_put_image_request_t *R);
xcb_generic_iterator_t
xcb_xv_put_image_data_end (const xcb_xv_put_image_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xv_shm_put_image_checked (xcb_connection_t *c,
xcb_xv_port_t port,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
xcb_shm_seg_t shmseg,
uint32_t id,
uint32_t offset,
int16_t src_x,
int16_t src_y,
uint16_t src_w,
uint16_t src_h,
int16_t drw_x,
int16_t drw_y,
uint16_t drw_w,
uint16_t drw_h,
uint16_t width,
uint16_t height,
uint8_t send_event);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xv_shm_put_image (xcb_connection_t *c,
xcb_xv_port_t port,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
xcb_shm_seg_t shmseg,
uint32_t id,
uint32_t offset,
int16_t src_x,
int16_t src_y,
uint16_t src_w,
uint16_t src_h,
int16_t drw_x,
int16_t drw_y,
uint16_t drw_w,
uint16_t drw_h,
uint16_t width,
uint16_t height,
uint8_t send_event);
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/
xcb/dpms.h 0000644 00000027224 15201526705 0006446 0 ustar 00 /*
* This file generated automatically from dpms.xml by c_client.py.
* Edit at your peril.
*/
/**
* @defgroup XCB_DPMS_API XCB DPMS API
* @brief DPMS XCB Protocol Implementation.
* @{
**/
#ifndef __DPMS_H
#define __DPMS_H
#include "xcb.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XCB_DPMS_MAJOR_VERSION 0
#define XCB_DPMS_MINOR_VERSION 0
extern xcb_extension_t xcb_dpms_id;
/**
* @brief xcb_dpms_get_version_cookie_t
**/
typedef struct xcb_dpms_get_version_cookie_t {
unsigned int sequence;
} xcb_dpms_get_version_cookie_t;
/** Opcode for xcb_dpms_get_version. */
#define XCB_DPMS_GET_VERSION 0
/**
* @brief xcb_dpms_get_version_request_t
**/
typedef struct xcb_dpms_get_version_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint16_t client_major_version;
uint16_t client_minor_version;
} xcb_dpms_get_version_request_t;
/**
* @brief xcb_dpms_get_version_reply_t
**/
typedef struct xcb_dpms_get_version_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t server_major_version;
uint16_t server_minor_version;
} xcb_dpms_get_version_reply_t;
/**
* @brief xcb_dpms_capable_cookie_t
**/
typedef struct xcb_dpms_capable_cookie_t {
unsigned int sequence;
} xcb_dpms_capable_cookie_t;
/** Opcode for xcb_dpms_capable. */
#define XCB_DPMS_CAPABLE 1
/**
* @brief xcb_dpms_capable_request_t
**/
typedef struct xcb_dpms_capable_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_dpms_capable_request_t;
/**
* @brief xcb_dpms_capable_reply_t
**/
typedef struct xcb_dpms_capable_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t capable;
uint8_t pad1[23];
} xcb_dpms_capable_reply_t;
/**
* @brief xcb_dpms_get_timeouts_cookie_t
**/
typedef struct xcb_dpms_get_timeouts_cookie_t {
unsigned int sequence;
} xcb_dpms_get_timeouts_cookie_t;
/** Opcode for xcb_dpms_get_timeouts. */
#define XCB_DPMS_GET_TIMEOUTS 2
/**
* @brief xcb_dpms_get_timeouts_request_t
**/
typedef struct xcb_dpms_get_timeouts_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_dpms_get_timeouts_request_t;
/**
* @brief xcb_dpms_get_timeouts_reply_t
**/
typedef struct xcb_dpms_get_timeouts_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t standby_timeout;
uint16_t suspend_timeout;
uint16_t off_timeout;
uint8_t pad1[18];
} xcb_dpms_get_timeouts_reply_t;
/** Opcode for xcb_dpms_set_timeouts. */
#define XCB_DPMS_SET_TIMEOUTS 3
/**
* @brief xcb_dpms_set_timeouts_request_t
**/
typedef struct xcb_dpms_set_timeouts_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint16_t standby_timeout;
uint16_t suspend_timeout;
uint16_t off_timeout;
} xcb_dpms_set_timeouts_request_t;
/** Opcode for xcb_dpms_enable. */
#define XCB_DPMS_ENABLE 4
/**
* @brief xcb_dpms_enable_request_t
**/
typedef struct xcb_dpms_enable_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_dpms_enable_request_t;
/** Opcode for xcb_dpms_disable. */
#define XCB_DPMS_DISABLE 5
/**
* @brief xcb_dpms_disable_request_t
**/
typedef struct xcb_dpms_disable_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_dpms_disable_request_t;
typedef enum xcb_dpms_dpms_mode_t {
XCB_DPMS_DPMS_MODE_ON = 0,
XCB_DPMS_DPMS_MODE_STANDBY = 1,
XCB_DPMS_DPMS_MODE_SUSPEND = 2,
XCB_DPMS_DPMS_MODE_OFF = 3
} xcb_dpms_dpms_mode_t;
/** Opcode for xcb_dpms_force_level. */
#define XCB_DPMS_FORCE_LEVEL 6
/**
* @brief xcb_dpms_force_level_request_t
**/
typedef struct xcb_dpms_force_level_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint16_t power_level;
} xcb_dpms_force_level_request_t;
/**
* @brief xcb_dpms_info_cookie_t
**/
typedef struct xcb_dpms_info_cookie_t {
unsigned int sequence;
} xcb_dpms_info_cookie_t;
/** Opcode for xcb_dpms_info. */
#define XCB_DPMS_INFO 7
/**
* @brief xcb_dpms_info_request_t
**/
typedef struct xcb_dpms_info_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_dpms_info_request_t;
/**
* @brief xcb_dpms_info_reply_t
**/
typedef struct xcb_dpms_info_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t power_level;
uint8_t state;
uint8_t pad1[21];
} xcb_dpms_info_reply_t;
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_dpms_get_version_cookie_t
xcb_dpms_get_version (xcb_connection_t *c,
uint16_t client_major_version,
uint16_t client_minor_version);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_dpms_get_version_cookie_t
xcb_dpms_get_version_unchecked (xcb_connection_t *c,
uint16_t client_major_version,
uint16_t client_minor_version);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_dpms_get_version_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_dpms_get_version_reply_t *
xcb_dpms_get_version_reply (xcb_connection_t *c,
xcb_dpms_get_version_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_dpms_capable_cookie_t
xcb_dpms_capable (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_dpms_capable_cookie_t
xcb_dpms_capable_unchecked (xcb_connection_t *c);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_dpms_capable_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_dpms_capable_reply_t *
xcb_dpms_capable_reply (xcb_connection_t *c,
xcb_dpms_capable_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_dpms_get_timeouts_cookie_t
xcb_dpms_get_timeouts (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_dpms_get_timeouts_cookie_t
xcb_dpms_get_timeouts_unchecked (xcb_connection_t *c);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_dpms_get_timeouts_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_dpms_get_timeouts_reply_t *
xcb_dpms_get_timeouts_reply (xcb_connection_t *c,
xcb_dpms_get_timeouts_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_dpms_set_timeouts_checked (xcb_connection_t *c,
uint16_t standby_timeout,
uint16_t suspend_timeout,
uint16_t off_timeout);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_dpms_set_timeouts (xcb_connection_t *c,
uint16_t standby_timeout,
uint16_t suspend_timeout,
uint16_t off_timeout);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_dpms_enable_checked (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_dpms_enable (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_dpms_disable_checked (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_dpms_disable (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_dpms_force_level_checked (xcb_connection_t *c,
uint16_t power_level);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_dpms_force_level (xcb_connection_t *c,
uint16_t power_level);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_dpms_info_cookie_t
xcb_dpms_info (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_dpms_info_cookie_t
xcb_dpms_info_unchecked (xcb_connection_t *c);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_dpms_info_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_dpms_info_reply_t *
xcb_dpms_info_reply (xcb_connection_t *c,
xcb_dpms_info_cookie_t cookie /**< */,
xcb_generic_error_t **e);
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/
xcb/shm.h 0000644 00000041555 15201526705 0006275 0 ustar 00 /*
* This file generated automatically from shm.xml by c_client.py.
* Edit at your peril.
*/
/**
* @defgroup XCB_Shm_API XCB Shm API
* @brief Shm XCB Protocol Implementation.
* @{
**/
#ifndef __SHM_H
#define __SHM_H
#include "xcb.h"
#include "xproto.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XCB_SHM_MAJOR_VERSION 1
#define XCB_SHM_MINOR_VERSION 2
extern xcb_extension_t xcb_shm_id;
typedef uint32_t xcb_shm_seg_t;
/**
* @brief xcb_shm_seg_iterator_t
**/
typedef struct xcb_shm_seg_iterator_t {
xcb_shm_seg_t *data;
int rem;
int index;
} xcb_shm_seg_iterator_t;
/** Opcode for xcb_shm_completion. */
#define XCB_SHM_COMPLETION 0
/**
* @brief xcb_shm_completion_event_t
**/
typedef struct xcb_shm_completion_event_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
xcb_drawable_t drawable;
uint16_t minor_event;
uint8_t major_event;
uint8_t pad1;
xcb_shm_seg_t shmseg;
uint32_t offset;
} xcb_shm_completion_event_t;
/** Opcode for xcb_shm_bad_seg. */
#define XCB_SHM_BAD_SEG 0
typedef xcb_value_error_t xcb_shm_bad_seg_error_t;
/**
* @brief xcb_shm_query_version_cookie_t
**/
typedef struct xcb_shm_query_version_cookie_t {
unsigned int sequence;
} xcb_shm_query_version_cookie_t;
/** Opcode for xcb_shm_query_version. */
#define XCB_SHM_QUERY_VERSION 0
/**
* @brief xcb_shm_query_version_request_t
**/
typedef struct xcb_shm_query_version_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_shm_query_version_request_t;
/**
* @brief xcb_shm_query_version_reply_t
**/
typedef struct xcb_shm_query_version_reply_t {
uint8_t response_type;
uint8_t shared_pixmaps;
uint16_t sequence;
uint32_t length;
uint16_t major_version;
uint16_t minor_version;
uint16_t uid;
uint16_t gid;
uint8_t pixmap_format;
uint8_t pad0[15];
} xcb_shm_query_version_reply_t;
/** Opcode for xcb_shm_attach. */
#define XCB_SHM_ATTACH 1
/**
* @brief xcb_shm_attach_request_t
**/
typedef struct xcb_shm_attach_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_shm_seg_t shmseg;
uint32_t shmid;
uint8_t read_only;
uint8_t pad0[3];
} xcb_shm_attach_request_t;
/** Opcode for xcb_shm_detach. */
#define XCB_SHM_DETACH 2
/**
* @brief xcb_shm_detach_request_t
**/
typedef struct xcb_shm_detach_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_shm_seg_t shmseg;
} xcb_shm_detach_request_t;
/** Opcode for xcb_shm_put_image. */
#define XCB_SHM_PUT_IMAGE 3
/**
* @brief xcb_shm_put_image_request_t
**/
typedef struct xcb_shm_put_image_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_drawable_t drawable;
xcb_gcontext_t gc;
uint16_t total_width;
uint16_t total_height;
uint16_t src_x;
uint16_t src_y;
uint16_t src_width;
uint16_t src_height;
int16_t dst_x;
int16_t dst_y;
uint8_t depth;
uint8_t format;
uint8_t send_event;
uint8_t pad0;
xcb_shm_seg_t shmseg;
uint32_t offset;
} xcb_shm_put_image_request_t;
/**
* @brief xcb_shm_get_image_cookie_t
**/
typedef struct xcb_shm_get_image_cookie_t {
unsigned int sequence;
} xcb_shm_get_image_cookie_t;
/** Opcode for xcb_shm_get_image. */
#define XCB_SHM_GET_IMAGE 4
/**
* @brief xcb_shm_get_image_request_t
**/
typedef struct xcb_shm_get_image_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_drawable_t drawable;
int16_t x;
int16_t y;
uint16_t width;
uint16_t height;
uint32_t plane_mask;
uint8_t format;
uint8_t pad0[3];
xcb_shm_seg_t shmseg;
uint32_t offset;
} xcb_shm_get_image_request_t;
/**
* @brief xcb_shm_get_image_reply_t
**/
typedef struct xcb_shm_get_image_reply_t {
uint8_t response_type;
uint8_t depth;
uint16_t sequence;
uint32_t length;
xcb_visualid_t visual;
uint32_t size;
} xcb_shm_get_image_reply_t;
/** Opcode for xcb_shm_create_pixmap. */
#define XCB_SHM_CREATE_PIXMAP 5
/**
* @brief xcb_shm_create_pixmap_request_t
**/
typedef struct xcb_shm_create_pixmap_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_pixmap_t pid;
xcb_drawable_t drawable;
uint16_t width;
uint16_t height;
uint8_t depth;
uint8_t pad0[3];
xcb_shm_seg_t shmseg;
uint32_t offset;
} xcb_shm_create_pixmap_request_t;
/** Opcode for xcb_shm_attach_fd. */
#define XCB_SHM_ATTACH_FD 6
/**
* @brief xcb_shm_attach_fd_request_t
**/
typedef struct xcb_shm_attach_fd_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_shm_seg_t shmseg;
uint8_t read_only;
uint8_t pad0[3];
} xcb_shm_attach_fd_request_t;
/**
* @brief xcb_shm_create_segment_cookie_t
**/
typedef struct xcb_shm_create_segment_cookie_t {
unsigned int sequence;
} xcb_shm_create_segment_cookie_t;
/** Opcode for xcb_shm_create_segment. */
#define XCB_SHM_CREATE_SEGMENT 7
/**
* @brief xcb_shm_create_segment_request_t
**/
typedef struct xcb_shm_create_segment_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_shm_seg_t shmseg;
uint32_t size;
uint8_t read_only;
uint8_t pad0[3];
} xcb_shm_create_segment_request_t;
/**
* @brief xcb_shm_create_segment_reply_t
**/
typedef struct xcb_shm_create_segment_reply_t {
uint8_t response_type;
uint8_t nfd;
uint16_t sequence;
uint32_t length;
uint8_t pad0[24];
} xcb_shm_create_segment_reply_t;
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_shm_seg_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_shm_seg_t)
*/
void
xcb_shm_seg_next (xcb_shm_seg_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_shm_seg_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_shm_seg_end (xcb_shm_seg_iterator_t i);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_shm_query_version_cookie_t
xcb_shm_query_version (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_shm_query_version_cookie_t
xcb_shm_query_version_unchecked (xcb_connection_t *c);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_shm_query_version_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_shm_query_version_reply_t *
xcb_shm_query_version_reply (xcb_connection_t *c,
xcb_shm_query_version_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_shm_attach_checked (xcb_connection_t *c,
xcb_shm_seg_t shmseg,
uint32_t shmid,
uint8_t read_only);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_shm_attach (xcb_connection_t *c,
xcb_shm_seg_t shmseg,
uint32_t shmid,
uint8_t read_only);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_shm_detach_checked (xcb_connection_t *c,
xcb_shm_seg_t shmseg);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_shm_detach (xcb_connection_t *c,
xcb_shm_seg_t shmseg);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_shm_put_image_checked (xcb_connection_t *c,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
uint16_t total_width,
uint16_t total_height,
uint16_t src_x,
uint16_t src_y,
uint16_t src_width,
uint16_t src_height,
int16_t dst_x,
int16_t dst_y,
uint8_t depth,
uint8_t format,
uint8_t send_event,
xcb_shm_seg_t shmseg,
uint32_t offset);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_shm_put_image (xcb_connection_t *c,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
uint16_t total_width,
uint16_t total_height,
uint16_t src_x,
uint16_t src_y,
uint16_t src_width,
uint16_t src_height,
int16_t dst_x,
int16_t dst_y,
uint8_t depth,
uint8_t format,
uint8_t send_event,
xcb_shm_seg_t shmseg,
uint32_t offset);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_shm_get_image_cookie_t
xcb_shm_get_image (xcb_connection_t *c,
xcb_drawable_t drawable,
int16_t x,
int16_t y,
uint16_t width,
uint16_t height,
uint32_t plane_mask,
uint8_t format,
xcb_shm_seg_t shmseg,
uint32_t offset);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_shm_get_image_cookie_t
xcb_shm_get_image_unchecked (xcb_connection_t *c,
xcb_drawable_t drawable,
int16_t x,
int16_t y,
uint16_t width,
uint16_t height,
uint32_t plane_mask,
uint8_t format,
xcb_shm_seg_t shmseg,
uint32_t offset);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_shm_get_image_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_shm_get_image_reply_t *
xcb_shm_get_image_reply (xcb_connection_t *c,
xcb_shm_get_image_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_shm_create_pixmap_checked (xcb_connection_t *c,
xcb_pixmap_t pid,
xcb_drawable_t drawable,
uint16_t width,
uint16_t height,
uint8_t depth,
xcb_shm_seg_t shmseg,
uint32_t offset);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_shm_create_pixmap (xcb_connection_t *c,
xcb_pixmap_t pid,
xcb_drawable_t drawable,
uint16_t width,
uint16_t height,
uint8_t depth,
xcb_shm_seg_t shmseg,
uint32_t offset);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_shm_attach_fd_checked (xcb_connection_t *c,
xcb_shm_seg_t shmseg,
int32_t shm_fd,
uint8_t read_only);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_shm_attach_fd (xcb_connection_t *c,
xcb_shm_seg_t shmseg,
int32_t shm_fd,
uint8_t read_only);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_shm_create_segment_cookie_t
xcb_shm_create_segment (xcb_connection_t *c,
xcb_shm_seg_t shmseg,
uint32_t size,
uint8_t read_only);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_shm_create_segment_cookie_t
xcb_shm_create_segment_unchecked (xcb_connection_t *c,
xcb_shm_seg_t shmseg,
uint32_t size,
uint8_t read_only);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_shm_create_segment_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_shm_create_segment_reply_t *
xcb_shm_create_segment_reply (xcb_connection_t *c,
xcb_shm_create_segment_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
* Return the reply fds
* @param c The connection
* @param reply The reply
*
* Returns the array of reply fds of the request asked by
*
* The returned value must be freed by the caller using free().
*/
int *
xcb_shm_create_segment_reply_fds (xcb_connection_t *c /**< */,
xcb_shm_create_segment_reply_t *reply);
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/
xcb/randr.h 0000644 00000420416 15201526705 0006611 0 ustar 00 /*
* This file generated automatically from randr.xml by c_client.py.
* Edit at your peril.
*/
/**
* @defgroup XCB_RandR_API XCB RandR API
* @brief RandR XCB Protocol Implementation.
* @{
**/
#ifndef __RANDR_H
#define __RANDR_H
#include "xcb.h"
#include "xproto.h"
#include "render.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XCB_RANDR_MAJOR_VERSION 1
#define XCB_RANDR_MINOR_VERSION 6
extern xcb_extension_t xcb_randr_id;
typedef uint32_t xcb_randr_mode_t;
/**
* @brief xcb_randr_mode_iterator_t
**/
typedef struct xcb_randr_mode_iterator_t {
xcb_randr_mode_t *data;
int rem;
int index;
} xcb_randr_mode_iterator_t;
typedef uint32_t xcb_randr_crtc_t;
/**
* @brief xcb_randr_crtc_iterator_t
**/
typedef struct xcb_randr_crtc_iterator_t {
xcb_randr_crtc_t *data;
int rem;
int index;
} xcb_randr_crtc_iterator_t;
typedef uint32_t xcb_randr_output_t;
/**
* @brief xcb_randr_output_iterator_t
**/
typedef struct xcb_randr_output_iterator_t {
xcb_randr_output_t *data;
int rem;
int index;
} xcb_randr_output_iterator_t;
typedef uint32_t xcb_randr_provider_t;
/**
* @brief xcb_randr_provider_iterator_t
**/
typedef struct xcb_randr_provider_iterator_t {
xcb_randr_provider_t *data;
int rem;
int index;
} xcb_randr_provider_iterator_t;
typedef uint32_t xcb_randr_lease_t;
/**
* @brief xcb_randr_lease_iterator_t
**/
typedef struct xcb_randr_lease_iterator_t {
xcb_randr_lease_t *data;
int rem;
int index;
} xcb_randr_lease_iterator_t;
/** Opcode for xcb_randr_bad_output. */
#define XCB_RANDR_BAD_OUTPUT 0
/**
* @brief xcb_randr_bad_output_error_t
**/
typedef struct xcb_randr_bad_output_error_t {
uint8_t response_type;
uint8_t error_code;
uint16_t sequence;
} xcb_randr_bad_output_error_t;
/** Opcode for xcb_randr_bad_crtc. */
#define XCB_RANDR_BAD_CRTC 1
/**
* @brief xcb_randr_bad_crtc_error_t
**/
typedef struct xcb_randr_bad_crtc_error_t {
uint8_t response_type;
uint8_t error_code;
uint16_t sequence;
} xcb_randr_bad_crtc_error_t;
/** Opcode for xcb_randr_bad_mode. */
#define XCB_RANDR_BAD_MODE 2
/**
* @brief xcb_randr_bad_mode_error_t
**/
typedef struct xcb_randr_bad_mode_error_t {
uint8_t response_type;
uint8_t error_code;
uint16_t sequence;
} xcb_randr_bad_mode_error_t;
/** Opcode for xcb_randr_bad_provider. */
#define XCB_RANDR_BAD_PROVIDER 3
/**
* @brief xcb_randr_bad_provider_error_t
**/
typedef struct xcb_randr_bad_provider_error_t {
uint8_t response_type;
uint8_t error_code;
uint16_t sequence;
} xcb_randr_bad_provider_error_t;
typedef enum xcb_randr_rotation_t {
XCB_RANDR_ROTATION_ROTATE_0 = 1,
XCB_RANDR_ROTATION_ROTATE_90 = 2,
XCB_RANDR_ROTATION_ROTATE_180 = 4,
XCB_RANDR_ROTATION_ROTATE_270 = 8,
XCB_RANDR_ROTATION_REFLECT_X = 16,
XCB_RANDR_ROTATION_REFLECT_Y = 32
} xcb_randr_rotation_t;
/**
* @brief xcb_randr_screen_size_t
**/
typedef struct xcb_randr_screen_size_t {
uint16_t width;
uint16_t height;
uint16_t mwidth;
uint16_t mheight;
} xcb_randr_screen_size_t;
/**
* @brief xcb_randr_screen_size_iterator_t
**/
typedef struct xcb_randr_screen_size_iterator_t {
xcb_randr_screen_size_t *data;
int rem;
int index;
} xcb_randr_screen_size_iterator_t;
/**
* @brief xcb_randr_refresh_rates_t
**/
typedef struct xcb_randr_refresh_rates_t {
uint16_t nRates;
} xcb_randr_refresh_rates_t;
/**
* @brief xcb_randr_refresh_rates_iterator_t
**/
typedef struct xcb_randr_refresh_rates_iterator_t {
xcb_randr_refresh_rates_t *data;
int rem;
int index;
} xcb_randr_refresh_rates_iterator_t;
/**
* @brief xcb_randr_query_version_cookie_t
**/
typedef struct xcb_randr_query_version_cookie_t {
unsigned int sequence;
} xcb_randr_query_version_cookie_t;
/** Opcode for xcb_randr_query_version. */
#define XCB_RANDR_QUERY_VERSION 0
/**
* @brief xcb_randr_query_version_request_t
**/
typedef struct xcb_randr_query_version_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t major_version;
uint32_t minor_version;
} xcb_randr_query_version_request_t;
/**
* @brief xcb_randr_query_version_reply_t
**/
typedef struct xcb_randr_query_version_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t major_version;
uint32_t minor_version;
uint8_t pad1[16];
} xcb_randr_query_version_reply_t;
typedef enum xcb_randr_set_config_t {
XCB_RANDR_SET_CONFIG_SUCCESS = 0,
XCB_RANDR_SET_CONFIG_INVALID_CONFIG_TIME = 1,
XCB_RANDR_SET_CONFIG_INVALID_TIME = 2,
XCB_RANDR_SET_CONFIG_FAILED = 3
} xcb_randr_set_config_t;
/**
* @brief xcb_randr_set_screen_config_cookie_t
**/
typedef struct xcb_randr_set_screen_config_cookie_t {
unsigned int sequence;
} xcb_randr_set_screen_config_cookie_t;
/** Opcode for xcb_randr_set_screen_config. */
#define XCB_RANDR_SET_SCREEN_CONFIG 2
/**
* @brief xcb_randr_set_screen_config_request_t
**/
typedef struct xcb_randr_set_screen_config_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
xcb_timestamp_t timestamp;
xcb_timestamp_t config_timestamp;
uint16_t sizeID;
uint16_t rotation;
uint16_t rate;
uint8_t pad0[2];
} xcb_randr_set_screen_config_request_t;
/**
* @brief xcb_randr_set_screen_config_reply_t
**/
typedef struct xcb_randr_set_screen_config_reply_t {
uint8_t response_type;
uint8_t status;
uint16_t sequence;
uint32_t length;
xcb_timestamp_t new_timestamp;
xcb_timestamp_t config_timestamp;
xcb_window_t root;
uint16_t subpixel_order;
uint8_t pad0[10];
} xcb_randr_set_screen_config_reply_t;
typedef enum xcb_randr_notify_mask_t {
XCB_RANDR_NOTIFY_MASK_SCREEN_CHANGE = 1,
XCB_RANDR_NOTIFY_MASK_CRTC_CHANGE = 2,
XCB_RANDR_NOTIFY_MASK_OUTPUT_CHANGE = 4,
XCB_RANDR_NOTIFY_MASK_OUTPUT_PROPERTY = 8,
XCB_RANDR_NOTIFY_MASK_PROVIDER_CHANGE = 16,
XCB_RANDR_NOTIFY_MASK_PROVIDER_PROPERTY = 32,
XCB_RANDR_NOTIFY_MASK_RESOURCE_CHANGE = 64,
XCB_RANDR_NOTIFY_MASK_LEASE = 128
} xcb_randr_notify_mask_t;
/** Opcode for xcb_randr_select_input. */
#define XCB_RANDR_SELECT_INPUT 4
/**
* @brief xcb_randr_select_input_request_t
**/
typedef struct xcb_randr_select_input_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
uint16_t enable;
uint8_t pad0[2];
} xcb_randr_select_input_request_t;
/**
* @brief xcb_randr_get_screen_info_cookie_t
**/
typedef struct xcb_randr_get_screen_info_cookie_t {
unsigned int sequence;
} xcb_randr_get_screen_info_cookie_t;
/** Opcode for xcb_randr_get_screen_info. */
#define XCB_RANDR_GET_SCREEN_INFO 5
/**
* @brief xcb_randr_get_screen_info_request_t
**/
typedef struct xcb_randr_get_screen_info_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
} xcb_randr_get_screen_info_request_t;
/**
* @brief xcb_randr_get_screen_info_reply_t
**/
typedef struct xcb_randr_get_screen_info_reply_t {
uint8_t response_type;
uint8_t rotations;
uint16_t sequence;
uint32_t length;
xcb_window_t root;
xcb_timestamp_t timestamp;
xcb_timestamp_t config_timestamp;
uint16_t nSizes;
uint16_t sizeID;
uint16_t rotation;
uint16_t rate;
uint16_t nInfo;
uint8_t pad0[2];
} xcb_randr_get_screen_info_reply_t;
/**
* @brief xcb_randr_get_screen_size_range_cookie_t
**/
typedef struct xcb_randr_get_screen_size_range_cookie_t {
unsigned int sequence;
} xcb_randr_get_screen_size_range_cookie_t;
/** Opcode for xcb_randr_get_screen_size_range. */
#define XCB_RANDR_GET_SCREEN_SIZE_RANGE 6
/**
* @brief xcb_randr_get_screen_size_range_request_t
**/
typedef struct xcb_randr_get_screen_size_range_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
} xcb_randr_get_screen_size_range_request_t;
/**
* @brief xcb_randr_get_screen_size_range_reply_t
**/
typedef struct xcb_randr_get_screen_size_range_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t min_width;
uint16_t min_height;
uint16_t max_width;
uint16_t max_height;
uint8_t pad1[16];
} xcb_randr_get_screen_size_range_reply_t;
/** Opcode for xcb_randr_set_screen_size. */
#define XCB_RANDR_SET_SCREEN_SIZE 7
/**
* @brief xcb_randr_set_screen_size_request_t
**/
typedef struct xcb_randr_set_screen_size_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
uint16_t width;
uint16_t height;
uint32_t mm_width;
uint32_t mm_height;
} xcb_randr_set_screen_size_request_t;
typedef enum xcb_randr_mode_flag_t {
XCB_RANDR_MODE_FLAG_HSYNC_POSITIVE = 1,
XCB_RANDR_MODE_FLAG_HSYNC_NEGATIVE = 2,
XCB_RANDR_MODE_FLAG_VSYNC_POSITIVE = 4,
XCB_RANDR_MODE_FLAG_VSYNC_NEGATIVE = 8,
XCB_RANDR_MODE_FLAG_INTERLACE = 16,
XCB_RANDR_MODE_FLAG_DOUBLE_SCAN = 32,
XCB_RANDR_MODE_FLAG_CSYNC = 64,
XCB_RANDR_MODE_FLAG_CSYNC_POSITIVE = 128,
XCB_RANDR_MODE_FLAG_CSYNC_NEGATIVE = 256,
XCB_RANDR_MODE_FLAG_HSKEW_PRESENT = 512,
XCB_RANDR_MODE_FLAG_BCAST = 1024,
XCB_RANDR_MODE_FLAG_PIXEL_MULTIPLEX = 2048,
XCB_RANDR_MODE_FLAG_DOUBLE_CLOCK = 4096,
XCB_RANDR_MODE_FLAG_HALVE_CLOCK = 8192
} xcb_randr_mode_flag_t;
/**
* @brief xcb_randr_mode_info_t
**/
typedef struct xcb_randr_mode_info_t {
uint32_t id;
uint16_t width;
uint16_t height;
uint32_t dot_clock;
uint16_t hsync_start;
uint16_t hsync_end;
uint16_t htotal;
uint16_t hskew;
uint16_t vsync_start;
uint16_t vsync_end;
uint16_t vtotal;
uint16_t name_len;
uint32_t mode_flags;
} xcb_randr_mode_info_t;
/**
* @brief xcb_randr_mode_info_iterator_t
**/
typedef struct xcb_randr_mode_info_iterator_t {
xcb_randr_mode_info_t *data;
int rem;
int index;
} xcb_randr_mode_info_iterator_t;
/**
* @brief xcb_randr_get_screen_resources_cookie_t
**/
typedef struct xcb_randr_get_screen_resources_cookie_t {
unsigned int sequence;
} xcb_randr_get_screen_resources_cookie_t;
/** Opcode for xcb_randr_get_screen_resources. */
#define XCB_RANDR_GET_SCREEN_RESOURCES 8
/**
* @brief xcb_randr_get_screen_resources_request_t
**/
typedef struct xcb_randr_get_screen_resources_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
} xcb_randr_get_screen_resources_request_t;
/**
* @brief xcb_randr_get_screen_resources_reply_t
**/
typedef struct xcb_randr_get_screen_resources_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
xcb_timestamp_t timestamp;
xcb_timestamp_t config_timestamp;
uint16_t num_crtcs;
uint16_t num_outputs;
uint16_t num_modes;
uint16_t names_len;
uint8_t pad1[8];
} xcb_randr_get_screen_resources_reply_t;
typedef enum xcb_randr_connection_t {
XCB_RANDR_CONNECTION_CONNECTED = 0,
XCB_RANDR_CONNECTION_DISCONNECTED = 1,
XCB_RANDR_CONNECTION_UNKNOWN = 2
} xcb_randr_connection_t;
/**
* @brief xcb_randr_get_output_info_cookie_t
**/
typedef struct xcb_randr_get_output_info_cookie_t {
unsigned int sequence;
} xcb_randr_get_output_info_cookie_t;
/** Opcode for xcb_randr_get_output_info. */
#define XCB_RANDR_GET_OUTPUT_INFO 9
/**
* @brief xcb_randr_get_output_info_request_t
**/
typedef struct xcb_randr_get_output_info_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_randr_output_t output;
xcb_timestamp_t config_timestamp;
} xcb_randr_get_output_info_request_t;
/**
* @brief xcb_randr_get_output_info_reply_t
**/
typedef struct xcb_randr_get_output_info_reply_t {
uint8_t response_type;
uint8_t status;
uint16_t sequence;
uint32_t length;
xcb_timestamp_t timestamp;
xcb_randr_crtc_t crtc;
uint32_t mm_width;
uint32_t mm_height;
uint8_t connection;
uint8_t subpixel_order;
uint16_t num_crtcs;
uint16_t num_modes;
uint16_t num_preferred;
uint16_t num_clones;
uint16_t name_len;
} xcb_randr_get_output_info_reply_t;
/**
* @brief xcb_randr_list_output_properties_cookie_t
**/
typedef struct xcb_randr_list_output_properties_cookie_t {
unsigned int sequence;
} xcb_randr_list_output_properties_cookie_t;
/** Opcode for xcb_randr_list_output_properties. */
#define XCB_RANDR_LIST_OUTPUT_PROPERTIES 10
/**
* @brief xcb_randr_list_output_properties_request_t
**/
typedef struct xcb_randr_list_output_properties_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_randr_output_t output;
} xcb_randr_list_output_properties_request_t;
/**
* @brief xcb_randr_list_output_properties_reply_t
**/
typedef struct xcb_randr_list_output_properties_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t num_atoms;
uint8_t pad1[22];
} xcb_randr_list_output_properties_reply_t;
/**
* @brief xcb_randr_query_output_property_cookie_t
**/
typedef struct xcb_randr_query_output_property_cookie_t {
unsigned int sequence;
} xcb_randr_query_output_property_cookie_t;
/** Opcode for xcb_randr_query_output_property. */
#define XCB_RANDR_QUERY_OUTPUT_PROPERTY 11
/**
* @brief xcb_randr_query_output_property_request_t
**/
typedef struct xcb_randr_query_output_property_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_randr_output_t output;
xcb_atom_t property;
} xcb_randr_query_output_property_request_t;
/**
* @brief xcb_randr_query_output_property_reply_t
**/
typedef struct xcb_randr_query_output_property_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pending;
uint8_t range;
uint8_t immutable;
uint8_t pad1[21];
} xcb_randr_query_output_property_reply_t;
/** Opcode for xcb_randr_configure_output_property. */
#define XCB_RANDR_CONFIGURE_OUTPUT_PROPERTY 12
/**
* @brief xcb_randr_configure_output_property_request_t
**/
typedef struct xcb_randr_configure_output_property_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_randr_output_t output;
xcb_atom_t property;
uint8_t pending;
uint8_t range;
uint8_t pad0[2];
} xcb_randr_configure_output_property_request_t;
/** Opcode for xcb_randr_change_output_property. */
#define XCB_RANDR_CHANGE_OUTPUT_PROPERTY 13
/**
* @brief xcb_randr_change_output_property_request_t
**/
typedef struct xcb_randr_change_output_property_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_randr_output_t output;
xcb_atom_t property;
xcb_atom_t type;
uint8_t format;
uint8_t mode;
uint8_t pad0[2];
uint32_t num_units;
} xcb_randr_change_output_property_request_t;
/** Opcode for xcb_randr_delete_output_property. */
#define XCB_RANDR_DELETE_OUTPUT_PROPERTY 14
/**
* @brief xcb_randr_delete_output_property_request_t
**/
typedef struct xcb_randr_delete_output_property_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_randr_output_t output;
xcb_atom_t property;
} xcb_randr_delete_output_property_request_t;
/**
* @brief xcb_randr_get_output_property_cookie_t
**/
typedef struct xcb_randr_get_output_property_cookie_t {
unsigned int sequence;
} xcb_randr_get_output_property_cookie_t;
/** Opcode for xcb_randr_get_output_property. */
#define XCB_RANDR_GET_OUTPUT_PROPERTY 15
/**
* @brief xcb_randr_get_output_property_request_t
**/
typedef struct xcb_randr_get_output_property_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_randr_output_t output;
xcb_atom_t property;
xcb_atom_t type;
uint32_t long_offset;
uint32_t long_length;
uint8_t _delete;
uint8_t pending;
uint8_t pad0[2];
} xcb_randr_get_output_property_request_t;
/**
* @brief xcb_randr_get_output_property_reply_t
**/
typedef struct xcb_randr_get_output_property_reply_t {
uint8_t response_type;
uint8_t format;
uint16_t sequence;
uint32_t length;
xcb_atom_t type;
uint32_t bytes_after;
uint32_t num_items;
uint8_t pad0[12];
} xcb_randr_get_output_property_reply_t;
/**
* @brief xcb_randr_create_mode_cookie_t
**/
typedef struct xcb_randr_create_mode_cookie_t {
unsigned int sequence;
} xcb_randr_create_mode_cookie_t;
/** Opcode for xcb_randr_create_mode. */
#define XCB_RANDR_CREATE_MODE 16
/**
* @brief xcb_randr_create_mode_request_t
**/
typedef struct xcb_randr_create_mode_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
xcb_randr_mode_info_t mode_info;
} xcb_randr_create_mode_request_t;
/**
* @brief xcb_randr_create_mode_reply_t
**/
typedef struct xcb_randr_create_mode_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
xcb_randr_mode_t mode;
uint8_t pad1[20];
} xcb_randr_create_mode_reply_t;
/** Opcode for xcb_randr_destroy_mode. */
#define XCB_RANDR_DESTROY_MODE 17
/**
* @brief xcb_randr_destroy_mode_request_t
**/
typedef struct xcb_randr_destroy_mode_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_randr_mode_t mode;
} xcb_randr_destroy_mode_request_t;
/** Opcode for xcb_randr_add_output_mode. */
#define XCB_RANDR_ADD_OUTPUT_MODE 18
/**
* @brief xcb_randr_add_output_mode_request_t
**/
typedef struct xcb_randr_add_output_mode_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_randr_output_t output;
xcb_randr_mode_t mode;
} xcb_randr_add_output_mode_request_t;
/** Opcode for xcb_randr_delete_output_mode. */
#define XCB_RANDR_DELETE_OUTPUT_MODE 19
/**
* @brief xcb_randr_delete_output_mode_request_t
**/
typedef struct xcb_randr_delete_output_mode_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_randr_output_t output;
xcb_randr_mode_t mode;
} xcb_randr_delete_output_mode_request_t;
/**
* @brief xcb_randr_get_crtc_info_cookie_t
**/
typedef struct xcb_randr_get_crtc_info_cookie_t {
unsigned int sequence;
} xcb_randr_get_crtc_info_cookie_t;
/** Opcode for xcb_randr_get_crtc_info. */
#define XCB_RANDR_GET_CRTC_INFO 20
/**
* @brief xcb_randr_get_crtc_info_request_t
**/
typedef struct xcb_randr_get_crtc_info_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_randr_crtc_t crtc;
xcb_timestamp_t config_timestamp;
} xcb_randr_get_crtc_info_request_t;
/**
* @brief xcb_randr_get_crtc_info_reply_t
**/
typedef struct xcb_randr_get_crtc_info_reply_t {
uint8_t response_type;
uint8_t status;
uint16_t sequence;
uint32_t length;
xcb_timestamp_t timestamp;
int16_t x;
int16_t y;
uint16_t width;
uint16_t height;
xcb_randr_mode_t mode;
uint16_t rotation;
uint16_t rotations;
uint16_t num_outputs;
uint16_t num_possible_outputs;
} xcb_randr_get_crtc_info_reply_t;
/**
* @brief xcb_randr_set_crtc_config_cookie_t
**/
typedef struct xcb_randr_set_crtc_config_cookie_t {
unsigned int sequence;
} xcb_randr_set_crtc_config_cookie_t;
/** Opcode for xcb_randr_set_crtc_config. */
#define XCB_RANDR_SET_CRTC_CONFIG 21
/**
* @brief xcb_randr_set_crtc_config_request_t
**/
typedef struct xcb_randr_set_crtc_config_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_randr_crtc_t crtc;
xcb_timestamp_t timestamp;
xcb_timestamp_t config_timestamp;
int16_t x;
int16_t y;
xcb_randr_mode_t mode;
uint16_t rotation;
uint8_t pad0[2];
} xcb_randr_set_crtc_config_request_t;
/**
* @brief xcb_randr_set_crtc_config_reply_t
**/
typedef struct xcb_randr_set_crtc_config_reply_t {
uint8_t response_type;
uint8_t status;
uint16_t sequence;
uint32_t length;
xcb_timestamp_t timestamp;
uint8_t pad0[20];
} xcb_randr_set_crtc_config_reply_t;
/**
* @brief xcb_randr_get_crtc_gamma_size_cookie_t
**/
typedef struct xcb_randr_get_crtc_gamma_size_cookie_t {
unsigned int sequence;
} xcb_randr_get_crtc_gamma_size_cookie_t;
/** Opcode for xcb_randr_get_crtc_gamma_size. */
#define XCB_RANDR_GET_CRTC_GAMMA_SIZE 22
/**
* @brief xcb_randr_get_crtc_gamma_size_request_t
**/
typedef struct xcb_randr_get_crtc_gamma_size_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_randr_crtc_t crtc;
} xcb_randr_get_crtc_gamma_size_request_t;
/**
* @brief xcb_randr_get_crtc_gamma_size_reply_t
**/
typedef struct xcb_randr_get_crtc_gamma_size_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t size;
uint8_t pad1[22];
} xcb_randr_get_crtc_gamma_size_reply_t;
/**
* @brief xcb_randr_get_crtc_gamma_cookie_t
**/
typedef struct xcb_randr_get_crtc_gamma_cookie_t {
unsigned int sequence;
} xcb_randr_get_crtc_gamma_cookie_t;
/** Opcode for xcb_randr_get_crtc_gamma. */
#define XCB_RANDR_GET_CRTC_GAMMA 23
/**
* @brief xcb_randr_get_crtc_gamma_request_t
**/
typedef struct xcb_randr_get_crtc_gamma_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_randr_crtc_t crtc;
} xcb_randr_get_crtc_gamma_request_t;
/**
* @brief xcb_randr_get_crtc_gamma_reply_t
**/
typedef struct xcb_randr_get_crtc_gamma_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t size;
uint8_t pad1[22];
} xcb_randr_get_crtc_gamma_reply_t;
/** Opcode for xcb_randr_set_crtc_gamma. */
#define XCB_RANDR_SET_CRTC_GAMMA 24
/**
* @brief xcb_randr_set_crtc_gamma_request_t
**/
typedef struct xcb_randr_set_crtc_gamma_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_randr_crtc_t crtc;
uint16_t size;
uint8_t pad0[2];
} xcb_randr_set_crtc_gamma_request_t;
/**
* @brief xcb_randr_get_screen_resources_current_cookie_t
**/
typedef struct xcb_randr_get_screen_resources_current_cookie_t {
unsigned int sequence;
} xcb_randr_get_screen_resources_current_cookie_t;
/** Opcode for xcb_randr_get_screen_resources_current. */
#define XCB_RANDR_GET_SCREEN_RESOURCES_CURRENT 25
/**
* @brief xcb_randr_get_screen_resources_current_request_t
**/
typedef struct xcb_randr_get_screen_resources_current_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
} xcb_randr_get_screen_resources_current_request_t;
/**
* @brief xcb_randr_get_screen_resources_current_reply_t
**/
typedef struct xcb_randr_get_screen_resources_current_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
xcb_timestamp_t timestamp;
xcb_timestamp_t config_timestamp;
uint16_t num_crtcs;
uint16_t num_outputs;
uint16_t num_modes;
uint16_t names_len;
uint8_t pad1[8];
} xcb_randr_get_screen_resources_current_reply_t;
typedef enum xcb_randr_transform_t {
XCB_RANDR_TRANSFORM_UNIT = 1,
XCB_RANDR_TRANSFORM_SCALE_UP = 2,
XCB_RANDR_TRANSFORM_SCALE_DOWN = 4,
XCB_RANDR_TRANSFORM_PROJECTIVE = 8
} xcb_randr_transform_t;
/** Opcode for xcb_randr_set_crtc_transform. */
#define XCB_RANDR_SET_CRTC_TRANSFORM 26
/**
* @brief xcb_randr_set_crtc_transform_request_t
**/
typedef struct xcb_randr_set_crtc_transform_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_randr_crtc_t crtc;
xcb_render_transform_t transform;
uint16_t filter_len;
uint8_t pad0[2];
} xcb_randr_set_crtc_transform_request_t;
/**
* @brief xcb_randr_get_crtc_transform_cookie_t
**/
typedef struct xcb_randr_get_crtc_transform_cookie_t {
unsigned int sequence;
} xcb_randr_get_crtc_transform_cookie_t;
/** Opcode for xcb_randr_get_crtc_transform. */
#define XCB_RANDR_GET_CRTC_TRANSFORM 27
/**
* @brief xcb_randr_get_crtc_transform_request_t
**/
typedef struct xcb_randr_get_crtc_transform_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_randr_crtc_t crtc;
} xcb_randr_get_crtc_transform_request_t;
/**
* @brief xcb_randr_get_crtc_transform_reply_t
**/
typedef struct xcb_randr_get_crtc_transform_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
xcb_render_transform_t pending_transform;
uint8_t has_transforms;
uint8_t pad1[3];
xcb_render_transform_t current_transform;
uint8_t pad2[4];
uint16_t pending_len;
uint16_t pending_nparams;
uint16_t current_len;
uint16_t current_nparams;
} xcb_randr_get_crtc_transform_reply_t;
/**
* @brief xcb_randr_get_panning_cookie_t
**/
typedef struct xcb_randr_get_panning_cookie_t {
unsigned int sequence;
} xcb_randr_get_panning_cookie_t;
/** Opcode for xcb_randr_get_panning. */
#define XCB_RANDR_GET_PANNING 28
/**
* @brief xcb_randr_get_panning_request_t
**/
typedef struct xcb_randr_get_panning_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_randr_crtc_t crtc;
} xcb_randr_get_panning_request_t;
/**
* @brief xcb_randr_get_panning_reply_t
**/
typedef struct xcb_randr_get_panning_reply_t {
uint8_t response_type;
uint8_t status;
uint16_t sequence;
uint32_t length;
xcb_timestamp_t timestamp;
uint16_t left;
uint16_t top;
uint16_t width;
uint16_t height;
uint16_t track_left;
uint16_t track_top;
uint16_t track_width;
uint16_t track_height;
int16_t border_left;
int16_t border_top;
int16_t border_right;
int16_t border_bottom;
} xcb_randr_get_panning_reply_t;
/**
* @brief xcb_randr_set_panning_cookie_t
**/
typedef struct xcb_randr_set_panning_cookie_t {
unsigned int sequence;
} xcb_randr_set_panning_cookie_t;
/** Opcode for xcb_randr_set_panning. */
#define XCB_RANDR_SET_PANNING 29
/**
* @brief xcb_randr_set_panning_request_t
**/
typedef struct xcb_randr_set_panning_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_randr_crtc_t crtc;
xcb_timestamp_t timestamp;
uint16_t left;
uint16_t top;
uint16_t width;
uint16_t height;
uint16_t track_left;
uint16_t track_top;
uint16_t track_width;
uint16_t track_height;
int16_t border_left;
int16_t border_top;
int16_t border_right;
int16_t border_bottom;
} xcb_randr_set_panning_request_t;
/**
* @brief xcb_randr_set_panning_reply_t
**/
typedef struct xcb_randr_set_panning_reply_t {
uint8_t response_type;
uint8_t status;
uint16_t sequence;
uint32_t length;
xcb_timestamp_t timestamp;
} xcb_randr_set_panning_reply_t;
/** Opcode for xcb_randr_set_output_primary. */
#define XCB_RANDR_SET_OUTPUT_PRIMARY 30
/**
* @brief xcb_randr_set_output_primary_request_t
**/
typedef struct xcb_randr_set_output_primary_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
xcb_randr_output_t output;
} xcb_randr_set_output_primary_request_t;
/**
* @brief xcb_randr_get_output_primary_cookie_t
**/
typedef struct xcb_randr_get_output_primary_cookie_t {
unsigned int sequence;
} xcb_randr_get_output_primary_cookie_t;
/** Opcode for xcb_randr_get_output_primary. */
#define XCB_RANDR_GET_OUTPUT_PRIMARY 31
/**
* @brief xcb_randr_get_output_primary_request_t
**/
typedef struct xcb_randr_get_output_primary_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
} xcb_randr_get_output_primary_request_t;
/**
* @brief xcb_randr_get_output_primary_reply_t
**/
typedef struct xcb_randr_get_output_primary_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
xcb_randr_output_t output;
} xcb_randr_get_output_primary_reply_t;
/**
* @brief xcb_randr_get_providers_cookie_t
**/
typedef struct xcb_randr_get_providers_cookie_t {
unsigned int sequence;
} xcb_randr_get_providers_cookie_t;
/** Opcode for xcb_randr_get_providers. */
#define XCB_RANDR_GET_PROVIDERS 32
/**
* @brief xcb_randr_get_providers_request_t
**/
typedef struct xcb_randr_get_providers_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
} xcb_randr_get_providers_request_t;
/**
* @brief xcb_randr_get_providers_reply_t
**/
typedef struct xcb_randr_get_providers_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
xcb_timestamp_t timestamp;
uint16_t num_providers;
uint8_t pad1[18];
} xcb_randr_get_providers_reply_t;
typedef enum xcb_randr_provider_capability_t {
XCB_RANDR_PROVIDER_CAPABILITY_SOURCE_OUTPUT = 1,
XCB_RANDR_PROVIDER_CAPABILITY_SINK_OUTPUT = 2,
XCB_RANDR_PROVIDER_CAPABILITY_SOURCE_OFFLOAD = 4,
XCB_RANDR_PROVIDER_CAPABILITY_SINK_OFFLOAD = 8
} xcb_randr_provider_capability_t;
/**
* @brief xcb_randr_get_provider_info_cookie_t
**/
typedef struct xcb_randr_get_provider_info_cookie_t {
unsigned int sequence;
} xcb_randr_get_provider_info_cookie_t;
/** Opcode for xcb_randr_get_provider_info. */
#define XCB_RANDR_GET_PROVIDER_INFO 33
/**
* @brief xcb_randr_get_provider_info_request_t
**/
typedef struct xcb_randr_get_provider_info_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_randr_provider_t provider;
xcb_timestamp_t config_timestamp;
} xcb_randr_get_provider_info_request_t;
/**
* @brief xcb_randr_get_provider_info_reply_t
**/
typedef struct xcb_randr_get_provider_info_reply_t {
uint8_t response_type;
uint8_t status;
uint16_t sequence;
uint32_t length;
xcb_timestamp_t timestamp;
uint32_t capabilities;
uint16_t num_crtcs;
uint16_t num_outputs;
uint16_t num_associated_providers;
uint16_t name_len;
uint8_t pad0[8];
} xcb_randr_get_provider_info_reply_t;
/** Opcode for xcb_randr_set_provider_offload_sink. */
#define XCB_RANDR_SET_PROVIDER_OFFLOAD_SINK 34
/**
* @brief xcb_randr_set_provider_offload_sink_request_t
**/
typedef struct xcb_randr_set_provider_offload_sink_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_randr_provider_t provider;
xcb_randr_provider_t sink_provider;
xcb_timestamp_t config_timestamp;
} xcb_randr_set_provider_offload_sink_request_t;
/** Opcode for xcb_randr_set_provider_output_source. */
#define XCB_RANDR_SET_PROVIDER_OUTPUT_SOURCE 35
/**
* @brief xcb_randr_set_provider_output_source_request_t
**/
typedef struct xcb_randr_set_provider_output_source_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_randr_provider_t provider;
xcb_randr_provider_t source_provider;
xcb_timestamp_t config_timestamp;
} xcb_randr_set_provider_output_source_request_t;
/**
* @brief xcb_randr_list_provider_properties_cookie_t
**/
typedef struct xcb_randr_list_provider_properties_cookie_t {
unsigned int sequence;
} xcb_randr_list_provider_properties_cookie_t;
/** Opcode for xcb_randr_list_provider_properties. */
#define XCB_RANDR_LIST_PROVIDER_PROPERTIES 36
/**
* @brief xcb_randr_list_provider_properties_request_t
**/
typedef struct xcb_randr_list_provider_properties_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_randr_provider_t provider;
} xcb_randr_list_provider_properties_request_t;
/**
* @brief xcb_randr_list_provider_properties_reply_t
**/
typedef struct xcb_randr_list_provider_properties_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t num_atoms;
uint8_t pad1[22];
} xcb_randr_list_provider_properties_reply_t;
/**
* @brief xcb_randr_query_provider_property_cookie_t
**/
typedef struct xcb_randr_query_provider_property_cookie_t {
unsigned int sequence;
} xcb_randr_query_provider_property_cookie_t;
/** Opcode for xcb_randr_query_provider_property. */
#define XCB_RANDR_QUERY_PROVIDER_PROPERTY 37
/**
* @brief xcb_randr_query_provider_property_request_t
**/
typedef struct xcb_randr_query_provider_property_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_randr_provider_t provider;
xcb_atom_t property;
} xcb_randr_query_provider_property_request_t;
/**
* @brief xcb_randr_query_provider_property_reply_t
**/
typedef struct xcb_randr_query_provider_property_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pending;
uint8_t range;
uint8_t immutable;
uint8_t pad1[21];
} xcb_randr_query_provider_property_reply_t;
/** Opcode for xcb_randr_configure_provider_property. */
#define XCB_RANDR_CONFIGURE_PROVIDER_PROPERTY 38
/**
* @brief xcb_randr_configure_provider_property_request_t
**/
typedef struct xcb_randr_configure_provider_property_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_randr_provider_t provider;
xcb_atom_t property;
uint8_t pending;
uint8_t range;
uint8_t pad0[2];
} xcb_randr_configure_provider_property_request_t;
/** Opcode for xcb_randr_change_provider_property. */
#define XCB_RANDR_CHANGE_PROVIDER_PROPERTY 39
/**
* @brief xcb_randr_change_provider_property_request_t
**/
typedef struct xcb_randr_change_provider_property_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_randr_provider_t provider;
xcb_atom_t property;
xcb_atom_t type;
uint8_t format;
uint8_t mode;
uint8_t pad0[2];
uint32_t num_items;
} xcb_randr_change_provider_property_request_t;
/** Opcode for xcb_randr_delete_provider_property. */
#define XCB_RANDR_DELETE_PROVIDER_PROPERTY 40
/**
* @brief xcb_randr_delete_provider_property_request_t
**/
typedef struct xcb_randr_delete_provider_property_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_randr_provider_t provider;
xcb_atom_t property;
} xcb_randr_delete_provider_property_request_t;
/**
* @brief xcb_randr_get_provider_property_cookie_t
**/
typedef struct xcb_randr_get_provider_property_cookie_t {
unsigned int sequence;
} xcb_randr_get_provider_property_cookie_t;
/** Opcode for xcb_randr_get_provider_property. */
#define XCB_RANDR_GET_PROVIDER_PROPERTY 41
/**
* @brief xcb_randr_get_provider_property_request_t
**/
typedef struct xcb_randr_get_provider_property_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_randr_provider_t provider;
xcb_atom_t property;
xcb_atom_t type;
uint32_t long_offset;
uint32_t long_length;
uint8_t _delete;
uint8_t pending;
uint8_t pad0[2];
} xcb_randr_get_provider_property_request_t;
/**
* @brief xcb_randr_get_provider_property_reply_t
**/
typedef struct xcb_randr_get_provider_property_reply_t {
uint8_t response_type;
uint8_t format;
uint16_t sequence;
uint32_t length;
xcb_atom_t type;
uint32_t bytes_after;
uint32_t num_items;
uint8_t pad0[12];
} xcb_randr_get_provider_property_reply_t;
/** Opcode for xcb_randr_screen_change_notify. */
#define XCB_RANDR_SCREEN_CHANGE_NOTIFY 0
/**
* @brief xcb_randr_screen_change_notify_event_t
**/
typedef struct xcb_randr_screen_change_notify_event_t {
uint8_t response_type;
uint8_t rotation;
uint16_t sequence;
xcb_timestamp_t timestamp;
xcb_timestamp_t config_timestamp;
xcb_window_t root;
xcb_window_t request_window;
uint16_t sizeID;
uint16_t subpixel_order;
uint16_t width;
uint16_t height;
uint16_t mwidth;
uint16_t mheight;
} xcb_randr_screen_change_notify_event_t;
typedef enum xcb_randr_notify_t {
XCB_RANDR_NOTIFY_CRTC_CHANGE = 0,
XCB_RANDR_NOTIFY_OUTPUT_CHANGE = 1,
XCB_RANDR_NOTIFY_OUTPUT_PROPERTY = 2,
XCB_RANDR_NOTIFY_PROVIDER_CHANGE = 3,
XCB_RANDR_NOTIFY_PROVIDER_PROPERTY = 4,
XCB_RANDR_NOTIFY_RESOURCE_CHANGE = 5,
XCB_RANDR_NOTIFY_LEASE = 6
} xcb_randr_notify_t;
/**
* @brief xcb_randr_crtc_change_t
**/
typedef struct xcb_randr_crtc_change_t {
xcb_timestamp_t timestamp;
xcb_window_t window;
xcb_randr_crtc_t crtc;
xcb_randr_mode_t mode;
uint16_t rotation;
uint8_t pad0[2];
int16_t x;
int16_t y;
uint16_t width;
uint16_t height;
} xcb_randr_crtc_change_t;
/**
* @brief xcb_randr_crtc_change_iterator_t
**/
typedef struct xcb_randr_crtc_change_iterator_t {
xcb_randr_crtc_change_t *data;
int rem;
int index;
} xcb_randr_crtc_change_iterator_t;
/**
* @brief xcb_randr_output_change_t
**/
typedef struct xcb_randr_output_change_t {
xcb_timestamp_t timestamp;
xcb_timestamp_t config_timestamp;
xcb_window_t window;
xcb_randr_output_t output;
xcb_randr_crtc_t crtc;
xcb_randr_mode_t mode;
uint16_t rotation;
uint8_t connection;
uint8_t subpixel_order;
} xcb_randr_output_change_t;
/**
* @brief xcb_randr_output_change_iterator_t
**/
typedef struct xcb_randr_output_change_iterator_t {
xcb_randr_output_change_t *data;
int rem;
int index;
} xcb_randr_output_change_iterator_t;
/**
* @brief xcb_randr_output_property_t
**/
typedef struct xcb_randr_output_property_t {
xcb_window_t window;
xcb_randr_output_t output;
xcb_atom_t atom;
xcb_timestamp_t timestamp;
uint8_t status;
uint8_t pad0[11];
} xcb_randr_output_property_t;
/**
* @brief xcb_randr_output_property_iterator_t
**/
typedef struct xcb_randr_output_property_iterator_t {
xcb_randr_output_property_t *data;
int rem;
int index;
} xcb_randr_output_property_iterator_t;
/**
* @brief xcb_randr_provider_change_t
**/
typedef struct xcb_randr_provider_change_t {
xcb_timestamp_t timestamp;
xcb_window_t window;
xcb_randr_provider_t provider;
uint8_t pad0[16];
} xcb_randr_provider_change_t;
/**
* @brief xcb_randr_provider_change_iterator_t
**/
typedef struct xcb_randr_provider_change_iterator_t {
xcb_randr_provider_change_t *data;
int rem;
int index;
} xcb_randr_provider_change_iterator_t;
/**
* @brief xcb_randr_provider_property_t
**/
typedef struct xcb_randr_provider_property_t {
xcb_window_t window;
xcb_randr_provider_t provider;
xcb_atom_t atom;
xcb_timestamp_t timestamp;
uint8_t state;
uint8_t pad0[11];
} xcb_randr_provider_property_t;
/**
* @brief xcb_randr_provider_property_iterator_t
**/
typedef struct xcb_randr_provider_property_iterator_t {
xcb_randr_provider_property_t *data;
int rem;
int index;
} xcb_randr_provider_property_iterator_t;
/**
* @brief xcb_randr_resource_change_t
**/
typedef struct xcb_randr_resource_change_t {
xcb_timestamp_t timestamp;
xcb_window_t window;
uint8_t pad0[20];
} xcb_randr_resource_change_t;
/**
* @brief xcb_randr_resource_change_iterator_t
**/
typedef struct xcb_randr_resource_change_iterator_t {
xcb_randr_resource_change_t *data;
int rem;
int index;
} xcb_randr_resource_change_iterator_t;
/**
* @brief xcb_randr_monitor_info_t
**/
typedef struct xcb_randr_monitor_info_t {
xcb_atom_t name;
uint8_t primary;
uint8_t automatic;
uint16_t nOutput;
int16_t x;
int16_t y;
uint16_t width;
uint16_t height;
uint32_t width_in_millimeters;
uint32_t height_in_millimeters;
} xcb_randr_monitor_info_t;
/**
* @brief xcb_randr_monitor_info_iterator_t
**/
typedef struct xcb_randr_monitor_info_iterator_t {
xcb_randr_monitor_info_t *data;
int rem;
int index;
} xcb_randr_monitor_info_iterator_t;
/**
* @brief xcb_randr_get_monitors_cookie_t
**/
typedef struct xcb_randr_get_monitors_cookie_t {
unsigned int sequence;
} xcb_randr_get_monitors_cookie_t;
/** Opcode for xcb_randr_get_monitors. */
#define XCB_RANDR_GET_MONITORS 42
/**
* @brief xcb_randr_get_monitors_request_t
**/
typedef struct xcb_randr_get_monitors_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
uint8_t get_active;
} xcb_randr_get_monitors_request_t;
/**
* @brief xcb_randr_get_monitors_reply_t
**/
typedef struct xcb_randr_get_monitors_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
xcb_timestamp_t timestamp;
uint32_t nMonitors;
uint32_t nOutputs;
uint8_t pad1[12];
} xcb_randr_get_monitors_reply_t;
/** Opcode for xcb_randr_set_monitor. */
#define XCB_RANDR_SET_MONITOR 43
/**
* @brief xcb_randr_set_monitor_request_t
**/
typedef struct xcb_randr_set_monitor_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
} xcb_randr_set_monitor_request_t;
/** Opcode for xcb_randr_delete_monitor. */
#define XCB_RANDR_DELETE_MONITOR 44
/**
* @brief xcb_randr_delete_monitor_request_t
**/
typedef struct xcb_randr_delete_monitor_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
xcb_atom_t name;
} xcb_randr_delete_monitor_request_t;
/**
* @brief xcb_randr_create_lease_cookie_t
**/
typedef struct xcb_randr_create_lease_cookie_t {
unsigned int sequence;
} xcb_randr_create_lease_cookie_t;
/** Opcode for xcb_randr_create_lease. */
#define XCB_RANDR_CREATE_LEASE 45
/**
* @brief xcb_randr_create_lease_request_t
**/
typedef struct xcb_randr_create_lease_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
xcb_randr_lease_t lid;
uint16_t num_crtcs;
uint16_t num_outputs;
} xcb_randr_create_lease_request_t;
/**
* @brief xcb_randr_create_lease_reply_t
**/
typedef struct xcb_randr_create_lease_reply_t {
uint8_t response_type;
uint8_t nfd;
uint16_t sequence;
uint32_t length;
uint8_t pad0[24];
} xcb_randr_create_lease_reply_t;
/** Opcode for xcb_randr_free_lease. */
#define XCB_RANDR_FREE_LEASE 46
/**
* @brief xcb_randr_free_lease_request_t
**/
typedef struct xcb_randr_free_lease_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_randr_lease_t lid;
uint8_t terminate;
} xcb_randr_free_lease_request_t;
/**
* @brief xcb_randr_lease_notify_t
**/
typedef struct xcb_randr_lease_notify_t {
xcb_timestamp_t timestamp;
xcb_window_t window;
xcb_randr_lease_t lease;
uint8_t created;
uint8_t pad0[15];
} xcb_randr_lease_notify_t;
/**
* @brief xcb_randr_lease_notify_iterator_t
**/
typedef struct xcb_randr_lease_notify_iterator_t {
xcb_randr_lease_notify_t *data;
int rem;
int index;
} xcb_randr_lease_notify_iterator_t;
/**
* @brief xcb_randr_notify_data_t
**/
typedef union xcb_randr_notify_data_t {
xcb_randr_crtc_change_t cc;
xcb_randr_output_change_t oc;
xcb_randr_output_property_t op;
xcb_randr_provider_change_t pc;
xcb_randr_provider_property_t pp;
xcb_randr_resource_change_t rc;
xcb_randr_lease_notify_t lc;
} xcb_randr_notify_data_t;
/**
* @brief xcb_randr_notify_data_iterator_t
**/
typedef struct xcb_randr_notify_data_iterator_t {
xcb_randr_notify_data_t *data;
int rem;
int index;
} xcb_randr_notify_data_iterator_t;
/** Opcode for xcb_randr_notify. */
#define XCB_RANDR_NOTIFY 1
/**
* @brief xcb_randr_notify_event_t
**/
typedef struct xcb_randr_notify_event_t {
uint8_t response_type;
uint8_t subCode;
uint16_t sequence;
xcb_randr_notify_data_t u;
} xcb_randr_notify_event_t;
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_randr_mode_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_randr_mode_t)
*/
void
xcb_randr_mode_next (xcb_randr_mode_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_randr_mode_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_randr_mode_end (xcb_randr_mode_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_randr_crtc_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_randr_crtc_t)
*/
void
xcb_randr_crtc_next (xcb_randr_crtc_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_randr_crtc_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_randr_crtc_end (xcb_randr_crtc_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_randr_output_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_randr_output_t)
*/
void
xcb_randr_output_next (xcb_randr_output_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_randr_output_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_randr_output_end (xcb_randr_output_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_randr_provider_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_randr_provider_t)
*/
void
xcb_randr_provider_next (xcb_randr_provider_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_randr_provider_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_randr_provider_end (xcb_randr_provider_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_randr_lease_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_randr_lease_t)
*/
void
xcb_randr_lease_next (xcb_randr_lease_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_randr_lease_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_randr_lease_end (xcb_randr_lease_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_randr_screen_size_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_randr_screen_size_t)
*/
void
xcb_randr_screen_size_next (xcb_randr_screen_size_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_randr_screen_size_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_randr_screen_size_end (xcb_randr_screen_size_iterator_t i);
int
xcb_randr_refresh_rates_sizeof (const void *_buffer);
uint16_t *
xcb_randr_refresh_rates_rates (const xcb_randr_refresh_rates_t *R);
int
xcb_randr_refresh_rates_rates_length (const xcb_randr_refresh_rates_t *R);
xcb_generic_iterator_t
xcb_randr_refresh_rates_rates_end (const xcb_randr_refresh_rates_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_randr_refresh_rates_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_randr_refresh_rates_t)
*/
void
xcb_randr_refresh_rates_next (xcb_randr_refresh_rates_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_randr_refresh_rates_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_randr_refresh_rates_end (xcb_randr_refresh_rates_iterator_t i);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_randr_query_version_cookie_t
xcb_randr_query_version (xcb_connection_t *c,
uint32_t major_version,
uint32_t minor_version);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_randr_query_version_cookie_t
xcb_randr_query_version_unchecked (xcb_connection_t *c,
uint32_t major_version,
uint32_t minor_version);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_randr_query_version_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_randr_query_version_reply_t *
xcb_randr_query_version_reply (xcb_connection_t *c,
xcb_randr_query_version_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_randr_set_screen_config_cookie_t
xcb_randr_set_screen_config (xcb_connection_t *c,
xcb_window_t window,
xcb_timestamp_t timestamp,
xcb_timestamp_t config_timestamp,
uint16_t sizeID,
uint16_t rotation,
uint16_t rate);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_randr_set_screen_config_cookie_t
xcb_randr_set_screen_config_unchecked (xcb_connection_t *c,
xcb_window_t window,
xcb_timestamp_t timestamp,
xcb_timestamp_t config_timestamp,
uint16_t sizeID,
uint16_t rotation,
uint16_t rate);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_randr_set_screen_config_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_randr_set_screen_config_reply_t *
xcb_randr_set_screen_config_reply (xcb_connection_t *c,
xcb_randr_set_screen_config_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_randr_select_input_checked (xcb_connection_t *c,
xcb_window_t window,
uint16_t enable);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_randr_select_input (xcb_connection_t *c,
xcb_window_t window,
uint16_t enable);
int
xcb_randr_get_screen_info_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_randr_get_screen_info_cookie_t
xcb_randr_get_screen_info (xcb_connection_t *c,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_randr_get_screen_info_cookie_t
xcb_randr_get_screen_info_unchecked (xcb_connection_t *c,
xcb_window_t window);
xcb_randr_screen_size_t *
xcb_randr_get_screen_info_sizes (const xcb_randr_get_screen_info_reply_t *R);
int
xcb_randr_get_screen_info_sizes_length (const xcb_randr_get_screen_info_reply_t *R);
xcb_randr_screen_size_iterator_t
xcb_randr_get_screen_info_sizes_iterator (const xcb_randr_get_screen_info_reply_t *R);
int
xcb_randr_get_screen_info_rates_length (const xcb_randr_get_screen_info_reply_t *R);
xcb_randr_refresh_rates_iterator_t
xcb_randr_get_screen_info_rates_iterator (const xcb_randr_get_screen_info_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_randr_get_screen_info_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_randr_get_screen_info_reply_t *
xcb_randr_get_screen_info_reply (xcb_connection_t *c,
xcb_randr_get_screen_info_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_randr_get_screen_size_range_cookie_t
xcb_randr_get_screen_size_range (xcb_connection_t *c,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_randr_get_screen_size_range_cookie_t
xcb_randr_get_screen_size_range_unchecked (xcb_connection_t *c,
xcb_window_t window);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_randr_get_screen_size_range_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_randr_get_screen_size_range_reply_t *
xcb_randr_get_screen_size_range_reply (xcb_connection_t *c,
xcb_randr_get_screen_size_range_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_randr_set_screen_size_checked (xcb_connection_t *c,
xcb_window_t window,
uint16_t width,
uint16_t height,
uint32_t mm_width,
uint32_t mm_height);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_randr_set_screen_size (xcb_connection_t *c,
xcb_window_t window,
uint16_t width,
uint16_t height,
uint32_t mm_width,
uint32_t mm_height);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_randr_mode_info_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_randr_mode_info_t)
*/
void
xcb_randr_mode_info_next (xcb_randr_mode_info_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_randr_mode_info_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_randr_mode_info_end (xcb_randr_mode_info_iterator_t i);
int
xcb_randr_get_screen_resources_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_randr_get_screen_resources_cookie_t
xcb_randr_get_screen_resources (xcb_connection_t *c,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_randr_get_screen_resources_cookie_t
xcb_randr_get_screen_resources_unchecked (xcb_connection_t *c,
xcb_window_t window);
xcb_randr_crtc_t *
xcb_randr_get_screen_resources_crtcs (const xcb_randr_get_screen_resources_reply_t *R);
int
xcb_randr_get_screen_resources_crtcs_length (const xcb_randr_get_screen_resources_reply_t *R);
xcb_generic_iterator_t
xcb_randr_get_screen_resources_crtcs_end (const xcb_randr_get_screen_resources_reply_t *R);
xcb_randr_output_t *
xcb_randr_get_screen_resources_outputs (const xcb_randr_get_screen_resources_reply_t *R);
int
xcb_randr_get_screen_resources_outputs_length (const xcb_randr_get_screen_resources_reply_t *R);
xcb_generic_iterator_t
xcb_randr_get_screen_resources_outputs_end (const xcb_randr_get_screen_resources_reply_t *R);
xcb_randr_mode_info_t *
xcb_randr_get_screen_resources_modes (const xcb_randr_get_screen_resources_reply_t *R);
int
xcb_randr_get_screen_resources_modes_length (const xcb_randr_get_screen_resources_reply_t *R);
xcb_randr_mode_info_iterator_t
xcb_randr_get_screen_resources_modes_iterator (const xcb_randr_get_screen_resources_reply_t *R);
uint8_t *
xcb_randr_get_screen_resources_names (const xcb_randr_get_screen_resources_reply_t *R);
int
xcb_randr_get_screen_resources_names_length (const xcb_randr_get_screen_resources_reply_t *R);
xcb_generic_iterator_t
xcb_randr_get_screen_resources_names_end (const xcb_randr_get_screen_resources_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_randr_get_screen_resources_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_randr_get_screen_resources_reply_t *
xcb_randr_get_screen_resources_reply (xcb_connection_t *c,
xcb_randr_get_screen_resources_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_randr_get_output_info_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_randr_get_output_info_cookie_t
xcb_randr_get_output_info (xcb_connection_t *c,
xcb_randr_output_t output,
xcb_timestamp_t config_timestamp);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_randr_get_output_info_cookie_t
xcb_randr_get_output_info_unchecked (xcb_connection_t *c,
xcb_randr_output_t output,
xcb_timestamp_t config_timestamp);
xcb_randr_crtc_t *
xcb_randr_get_output_info_crtcs (const xcb_randr_get_output_info_reply_t *R);
int
xcb_randr_get_output_info_crtcs_length (const xcb_randr_get_output_info_reply_t *R);
xcb_generic_iterator_t
xcb_randr_get_output_info_crtcs_end (const xcb_randr_get_output_info_reply_t *R);
xcb_randr_mode_t *
xcb_randr_get_output_info_modes (const xcb_randr_get_output_info_reply_t *R);
int
xcb_randr_get_output_info_modes_length (const xcb_randr_get_output_info_reply_t *R);
xcb_generic_iterator_t
xcb_randr_get_output_info_modes_end (const xcb_randr_get_output_info_reply_t *R);
xcb_randr_output_t *
xcb_randr_get_output_info_clones (const xcb_randr_get_output_info_reply_t *R);
int
xcb_randr_get_output_info_clones_length (const xcb_randr_get_output_info_reply_t *R);
xcb_generic_iterator_t
xcb_randr_get_output_info_clones_end (const xcb_randr_get_output_info_reply_t *R);
uint8_t *
xcb_randr_get_output_info_name (const xcb_randr_get_output_info_reply_t *R);
int
xcb_randr_get_output_info_name_length (const xcb_randr_get_output_info_reply_t *R);
xcb_generic_iterator_t
xcb_randr_get_output_info_name_end (const xcb_randr_get_output_info_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_randr_get_output_info_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_randr_get_output_info_reply_t *
xcb_randr_get_output_info_reply (xcb_connection_t *c,
xcb_randr_get_output_info_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_randr_list_output_properties_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_randr_list_output_properties_cookie_t
xcb_randr_list_output_properties (xcb_connection_t *c,
xcb_randr_output_t output);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_randr_list_output_properties_cookie_t
xcb_randr_list_output_properties_unchecked (xcb_connection_t *c,
xcb_randr_output_t output);
xcb_atom_t *
xcb_randr_list_output_properties_atoms (const xcb_randr_list_output_properties_reply_t *R);
int
xcb_randr_list_output_properties_atoms_length (const xcb_randr_list_output_properties_reply_t *R);
xcb_generic_iterator_t
xcb_randr_list_output_properties_atoms_end (const xcb_randr_list_output_properties_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_randr_list_output_properties_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_randr_list_output_properties_reply_t *
xcb_randr_list_output_properties_reply (xcb_connection_t *c,
xcb_randr_list_output_properties_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_randr_query_output_property_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_randr_query_output_property_cookie_t
xcb_randr_query_output_property (xcb_connection_t *c,
xcb_randr_output_t output,
xcb_atom_t property);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_randr_query_output_property_cookie_t
xcb_randr_query_output_property_unchecked (xcb_connection_t *c,
xcb_randr_output_t output,
xcb_atom_t property);
int32_t *
xcb_randr_query_output_property_valid_values (const xcb_randr_query_output_property_reply_t *R);
int
xcb_randr_query_output_property_valid_values_length (const xcb_randr_query_output_property_reply_t *R);
xcb_generic_iterator_t
xcb_randr_query_output_property_valid_values_end (const xcb_randr_query_output_property_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_randr_query_output_property_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_randr_query_output_property_reply_t *
xcb_randr_query_output_property_reply (xcb_connection_t *c,
xcb_randr_query_output_property_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_randr_configure_output_property_sizeof (const void *_buffer,
uint32_t values_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_randr_configure_output_property_checked (xcb_connection_t *c,
xcb_randr_output_t output,
xcb_atom_t property,
uint8_t pending,
uint8_t range,
uint32_t values_len,
const int32_t *values);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_randr_configure_output_property (xcb_connection_t *c,
xcb_randr_output_t output,
xcb_atom_t property,
uint8_t pending,
uint8_t range,
uint32_t values_len,
const int32_t *values);
int32_t *
xcb_randr_configure_output_property_values (const xcb_randr_configure_output_property_request_t *R);
int
xcb_randr_configure_output_property_values_length (const xcb_randr_configure_output_property_request_t *R);
xcb_generic_iterator_t
xcb_randr_configure_output_property_values_end (const xcb_randr_configure_output_property_request_t *R);
int
xcb_randr_change_output_property_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_randr_change_output_property_checked (xcb_connection_t *c,
xcb_randr_output_t output,
xcb_atom_t property,
xcb_atom_t type,
uint8_t format,
uint8_t mode,
uint32_t num_units,
const void *data);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_randr_change_output_property (xcb_connection_t *c,
xcb_randr_output_t output,
xcb_atom_t property,
xcb_atom_t type,
uint8_t format,
uint8_t mode,
uint32_t num_units,
const void *data);
void *
xcb_randr_change_output_property_data (const xcb_randr_change_output_property_request_t *R);
int
xcb_randr_change_output_property_data_length (const xcb_randr_change_output_property_request_t *R);
xcb_generic_iterator_t
xcb_randr_change_output_property_data_end (const xcb_randr_change_output_property_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_randr_delete_output_property_checked (xcb_connection_t *c,
xcb_randr_output_t output,
xcb_atom_t property);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_randr_delete_output_property (xcb_connection_t *c,
xcb_randr_output_t output,
xcb_atom_t property);
int
xcb_randr_get_output_property_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_randr_get_output_property_cookie_t
xcb_randr_get_output_property (xcb_connection_t *c,
xcb_randr_output_t output,
xcb_atom_t property,
xcb_atom_t type,
uint32_t long_offset,
uint32_t long_length,
uint8_t _delete,
uint8_t pending);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_randr_get_output_property_cookie_t
xcb_randr_get_output_property_unchecked (xcb_connection_t *c,
xcb_randr_output_t output,
xcb_atom_t property,
xcb_atom_t type,
uint32_t long_offset,
uint32_t long_length,
uint8_t _delete,
uint8_t pending);
uint8_t *
xcb_randr_get_output_property_data (const xcb_randr_get_output_property_reply_t *R);
int
xcb_randr_get_output_property_data_length (const xcb_randr_get_output_property_reply_t *R);
xcb_generic_iterator_t
xcb_randr_get_output_property_data_end (const xcb_randr_get_output_property_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_randr_get_output_property_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_randr_get_output_property_reply_t *
xcb_randr_get_output_property_reply (xcb_connection_t *c,
xcb_randr_get_output_property_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_randr_create_mode_sizeof (const void *_buffer,
uint32_t name_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_randr_create_mode_cookie_t
xcb_randr_create_mode (xcb_connection_t *c,
xcb_window_t window,
xcb_randr_mode_info_t mode_info,
uint32_t name_len,
const char *name);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_randr_create_mode_cookie_t
xcb_randr_create_mode_unchecked (xcb_connection_t *c,
xcb_window_t window,
xcb_randr_mode_info_t mode_info,
uint32_t name_len,
const char *name);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_randr_create_mode_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_randr_create_mode_reply_t *
xcb_randr_create_mode_reply (xcb_connection_t *c,
xcb_randr_create_mode_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_randr_destroy_mode_checked (xcb_connection_t *c,
xcb_randr_mode_t mode);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_randr_destroy_mode (xcb_connection_t *c,
xcb_randr_mode_t mode);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_randr_add_output_mode_checked (xcb_connection_t *c,
xcb_randr_output_t output,
xcb_randr_mode_t mode);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_randr_add_output_mode (xcb_connection_t *c,
xcb_randr_output_t output,
xcb_randr_mode_t mode);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_randr_delete_output_mode_checked (xcb_connection_t *c,
xcb_randr_output_t output,
xcb_randr_mode_t mode);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_randr_delete_output_mode (xcb_connection_t *c,
xcb_randr_output_t output,
xcb_randr_mode_t mode);
int
xcb_randr_get_crtc_info_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_randr_get_crtc_info_cookie_t
xcb_randr_get_crtc_info (xcb_connection_t *c,
xcb_randr_crtc_t crtc,
xcb_timestamp_t config_timestamp);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_randr_get_crtc_info_cookie_t
xcb_randr_get_crtc_info_unchecked (xcb_connection_t *c,
xcb_randr_crtc_t crtc,
xcb_timestamp_t config_timestamp);
xcb_randr_output_t *
xcb_randr_get_crtc_info_outputs (const xcb_randr_get_crtc_info_reply_t *R);
int
xcb_randr_get_crtc_info_outputs_length (const xcb_randr_get_crtc_info_reply_t *R);
xcb_generic_iterator_t
xcb_randr_get_crtc_info_outputs_end (const xcb_randr_get_crtc_info_reply_t *R);
xcb_randr_output_t *
xcb_randr_get_crtc_info_possible (const xcb_randr_get_crtc_info_reply_t *R);
int
xcb_randr_get_crtc_info_possible_length (const xcb_randr_get_crtc_info_reply_t *R);
xcb_generic_iterator_t
xcb_randr_get_crtc_info_possible_end (const xcb_randr_get_crtc_info_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_randr_get_crtc_info_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_randr_get_crtc_info_reply_t *
xcb_randr_get_crtc_info_reply (xcb_connection_t *c,
xcb_randr_get_crtc_info_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_randr_set_crtc_config_sizeof (const void *_buffer,
uint32_t outputs_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_randr_set_crtc_config_cookie_t
xcb_randr_set_crtc_config (xcb_connection_t *c,
xcb_randr_crtc_t crtc,
xcb_timestamp_t timestamp,
xcb_timestamp_t config_timestamp,
int16_t x,
int16_t y,
xcb_randr_mode_t mode,
uint16_t rotation,
uint32_t outputs_len,
const xcb_randr_output_t *outputs);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_randr_set_crtc_config_cookie_t
xcb_randr_set_crtc_config_unchecked (xcb_connection_t *c,
xcb_randr_crtc_t crtc,
xcb_timestamp_t timestamp,
xcb_timestamp_t config_timestamp,
int16_t x,
int16_t y,
xcb_randr_mode_t mode,
uint16_t rotation,
uint32_t outputs_len,
const xcb_randr_output_t *outputs);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_randr_set_crtc_config_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_randr_set_crtc_config_reply_t *
xcb_randr_set_crtc_config_reply (xcb_connection_t *c,
xcb_randr_set_crtc_config_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_randr_get_crtc_gamma_size_cookie_t
xcb_randr_get_crtc_gamma_size (xcb_connection_t *c,
xcb_randr_crtc_t crtc);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_randr_get_crtc_gamma_size_cookie_t
xcb_randr_get_crtc_gamma_size_unchecked (xcb_connection_t *c,
xcb_randr_crtc_t crtc);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_randr_get_crtc_gamma_size_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_randr_get_crtc_gamma_size_reply_t *
xcb_randr_get_crtc_gamma_size_reply (xcb_connection_t *c,
xcb_randr_get_crtc_gamma_size_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_randr_get_crtc_gamma_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_randr_get_crtc_gamma_cookie_t
xcb_randr_get_crtc_gamma (xcb_connection_t *c,
xcb_randr_crtc_t crtc);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_randr_get_crtc_gamma_cookie_t
xcb_randr_get_crtc_gamma_unchecked (xcb_connection_t *c,
xcb_randr_crtc_t crtc);
uint16_t *
xcb_randr_get_crtc_gamma_red (const xcb_randr_get_crtc_gamma_reply_t *R);
int
xcb_randr_get_crtc_gamma_red_length (const xcb_randr_get_crtc_gamma_reply_t *R);
xcb_generic_iterator_t
xcb_randr_get_crtc_gamma_red_end (const xcb_randr_get_crtc_gamma_reply_t *R);
uint16_t *
xcb_randr_get_crtc_gamma_green (const xcb_randr_get_crtc_gamma_reply_t *R);
int
xcb_randr_get_crtc_gamma_green_length (const xcb_randr_get_crtc_gamma_reply_t *R);
xcb_generic_iterator_t
xcb_randr_get_crtc_gamma_green_end (const xcb_randr_get_crtc_gamma_reply_t *R);
uint16_t *
xcb_randr_get_crtc_gamma_blue (const xcb_randr_get_crtc_gamma_reply_t *R);
int
xcb_randr_get_crtc_gamma_blue_length (const xcb_randr_get_crtc_gamma_reply_t *R);
xcb_generic_iterator_t
xcb_randr_get_crtc_gamma_blue_end (const xcb_randr_get_crtc_gamma_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_randr_get_crtc_gamma_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_randr_get_crtc_gamma_reply_t *
xcb_randr_get_crtc_gamma_reply (xcb_connection_t *c,
xcb_randr_get_crtc_gamma_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_randr_set_crtc_gamma_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_randr_set_crtc_gamma_checked (xcb_connection_t *c,
xcb_randr_crtc_t crtc,
uint16_t size,
const uint16_t *red,
const uint16_t *green,
const uint16_t *blue);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_randr_set_crtc_gamma (xcb_connection_t *c,
xcb_randr_crtc_t crtc,
uint16_t size,
const uint16_t *red,
const uint16_t *green,
const uint16_t *blue);
uint16_t *
xcb_randr_set_crtc_gamma_red (const xcb_randr_set_crtc_gamma_request_t *R);
int
xcb_randr_set_crtc_gamma_red_length (const xcb_randr_set_crtc_gamma_request_t *R);
xcb_generic_iterator_t
xcb_randr_set_crtc_gamma_red_end (const xcb_randr_set_crtc_gamma_request_t *R);
uint16_t *
xcb_randr_set_crtc_gamma_green (const xcb_randr_set_crtc_gamma_request_t *R);
int
xcb_randr_set_crtc_gamma_green_length (const xcb_randr_set_crtc_gamma_request_t *R);
xcb_generic_iterator_t
xcb_randr_set_crtc_gamma_green_end (const xcb_randr_set_crtc_gamma_request_t *R);
uint16_t *
xcb_randr_set_crtc_gamma_blue (const xcb_randr_set_crtc_gamma_request_t *R);
int
xcb_randr_set_crtc_gamma_blue_length (const xcb_randr_set_crtc_gamma_request_t *R);
xcb_generic_iterator_t
xcb_randr_set_crtc_gamma_blue_end (const xcb_randr_set_crtc_gamma_request_t *R);
int
xcb_randr_get_screen_resources_current_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_randr_get_screen_resources_current_cookie_t
xcb_randr_get_screen_resources_current (xcb_connection_t *c,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_randr_get_screen_resources_current_cookie_t
xcb_randr_get_screen_resources_current_unchecked (xcb_connection_t *c,
xcb_window_t window);
xcb_randr_crtc_t *
xcb_randr_get_screen_resources_current_crtcs (const xcb_randr_get_screen_resources_current_reply_t *R);
int
xcb_randr_get_screen_resources_current_crtcs_length (const xcb_randr_get_screen_resources_current_reply_t *R);
xcb_generic_iterator_t
xcb_randr_get_screen_resources_current_crtcs_end (const xcb_randr_get_screen_resources_current_reply_t *R);
xcb_randr_output_t *
xcb_randr_get_screen_resources_current_outputs (const xcb_randr_get_screen_resources_current_reply_t *R);
int
xcb_randr_get_screen_resources_current_outputs_length (const xcb_randr_get_screen_resources_current_reply_t *R);
xcb_generic_iterator_t
xcb_randr_get_screen_resources_current_outputs_end (const xcb_randr_get_screen_resources_current_reply_t *R);
xcb_randr_mode_info_t *
xcb_randr_get_screen_resources_current_modes (const xcb_randr_get_screen_resources_current_reply_t *R);
int
xcb_randr_get_screen_resources_current_modes_length (const xcb_randr_get_screen_resources_current_reply_t *R);
xcb_randr_mode_info_iterator_t
xcb_randr_get_screen_resources_current_modes_iterator (const xcb_randr_get_screen_resources_current_reply_t *R);
uint8_t *
xcb_randr_get_screen_resources_current_names (const xcb_randr_get_screen_resources_current_reply_t *R);
int
xcb_randr_get_screen_resources_current_names_length (const xcb_randr_get_screen_resources_current_reply_t *R);
xcb_generic_iterator_t
xcb_randr_get_screen_resources_current_names_end (const xcb_randr_get_screen_resources_current_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_randr_get_screen_resources_current_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_randr_get_screen_resources_current_reply_t *
xcb_randr_get_screen_resources_current_reply (xcb_connection_t *c,
xcb_randr_get_screen_resources_current_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_randr_set_crtc_transform_sizeof (const void *_buffer,
uint32_t filter_params_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_randr_set_crtc_transform_checked (xcb_connection_t *c,
xcb_randr_crtc_t crtc,
xcb_render_transform_t transform,
uint16_t filter_len,
const char *filter_name,
uint32_t filter_params_len,
const xcb_render_fixed_t *filter_params);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_randr_set_crtc_transform (xcb_connection_t *c,
xcb_randr_crtc_t crtc,
xcb_render_transform_t transform,
uint16_t filter_len,
const char *filter_name,
uint32_t filter_params_len,
const xcb_render_fixed_t *filter_params);
char *
xcb_randr_set_crtc_transform_filter_name (const xcb_randr_set_crtc_transform_request_t *R);
int
xcb_randr_set_crtc_transform_filter_name_length (const xcb_randr_set_crtc_transform_request_t *R);
xcb_generic_iterator_t
xcb_randr_set_crtc_transform_filter_name_end (const xcb_randr_set_crtc_transform_request_t *R);
xcb_render_fixed_t *
xcb_randr_set_crtc_transform_filter_params (const xcb_randr_set_crtc_transform_request_t *R);
int
xcb_randr_set_crtc_transform_filter_params_length (const xcb_randr_set_crtc_transform_request_t *R);
xcb_generic_iterator_t
xcb_randr_set_crtc_transform_filter_params_end (const xcb_randr_set_crtc_transform_request_t *R);
int
xcb_randr_get_crtc_transform_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_randr_get_crtc_transform_cookie_t
xcb_randr_get_crtc_transform (xcb_connection_t *c,
xcb_randr_crtc_t crtc);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_randr_get_crtc_transform_cookie_t
xcb_randr_get_crtc_transform_unchecked (xcb_connection_t *c,
xcb_randr_crtc_t crtc);
char *
xcb_randr_get_crtc_transform_pending_filter_name (const xcb_randr_get_crtc_transform_reply_t *R);
int
xcb_randr_get_crtc_transform_pending_filter_name_length (const xcb_randr_get_crtc_transform_reply_t *R);
xcb_generic_iterator_t
xcb_randr_get_crtc_transform_pending_filter_name_end (const xcb_randr_get_crtc_transform_reply_t *R);
xcb_render_fixed_t *
xcb_randr_get_crtc_transform_pending_params (const xcb_randr_get_crtc_transform_reply_t *R);
int
xcb_randr_get_crtc_transform_pending_params_length (const xcb_randr_get_crtc_transform_reply_t *R);
xcb_generic_iterator_t
xcb_randr_get_crtc_transform_pending_params_end (const xcb_randr_get_crtc_transform_reply_t *R);
char *
xcb_randr_get_crtc_transform_current_filter_name (const xcb_randr_get_crtc_transform_reply_t *R);
int
xcb_randr_get_crtc_transform_current_filter_name_length (const xcb_randr_get_crtc_transform_reply_t *R);
xcb_generic_iterator_t
xcb_randr_get_crtc_transform_current_filter_name_end (const xcb_randr_get_crtc_transform_reply_t *R);
xcb_render_fixed_t *
xcb_randr_get_crtc_transform_current_params (const xcb_randr_get_crtc_transform_reply_t *R);
int
xcb_randr_get_crtc_transform_current_params_length (const xcb_randr_get_crtc_transform_reply_t *R);
xcb_generic_iterator_t
xcb_randr_get_crtc_transform_current_params_end (const xcb_randr_get_crtc_transform_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_randr_get_crtc_transform_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_randr_get_crtc_transform_reply_t *
xcb_randr_get_crtc_transform_reply (xcb_connection_t *c,
xcb_randr_get_crtc_transform_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_randr_get_panning_cookie_t
xcb_randr_get_panning (xcb_connection_t *c,
xcb_randr_crtc_t crtc);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_randr_get_panning_cookie_t
xcb_randr_get_panning_unchecked (xcb_connection_t *c,
xcb_randr_crtc_t crtc);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_randr_get_panning_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_randr_get_panning_reply_t *
xcb_randr_get_panning_reply (xcb_connection_t *c,
xcb_randr_get_panning_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_randr_set_panning_cookie_t
xcb_randr_set_panning (xcb_connection_t *c,
xcb_randr_crtc_t crtc,
xcb_timestamp_t timestamp,
uint16_t left,
uint16_t top,
uint16_t width,
uint16_t height,
uint16_t track_left,
uint16_t track_top,
uint16_t track_width,
uint16_t track_height,
int16_t border_left,
int16_t border_top,
int16_t border_right,
int16_t border_bottom);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_randr_set_panning_cookie_t
xcb_randr_set_panning_unchecked (xcb_connection_t *c,
xcb_randr_crtc_t crtc,
xcb_timestamp_t timestamp,
uint16_t left,
uint16_t top,
uint16_t width,
uint16_t height,
uint16_t track_left,
uint16_t track_top,
uint16_t track_width,
uint16_t track_height,
int16_t border_left,
int16_t border_top,
int16_t border_right,
int16_t border_bottom);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_randr_set_panning_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_randr_set_panning_reply_t *
xcb_randr_set_panning_reply (xcb_connection_t *c,
xcb_randr_set_panning_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_randr_set_output_primary_checked (xcb_connection_t *c,
xcb_window_t window,
xcb_randr_output_t output);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_randr_set_output_primary (xcb_connection_t *c,
xcb_window_t window,
xcb_randr_output_t output);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_randr_get_output_primary_cookie_t
xcb_randr_get_output_primary (xcb_connection_t *c,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_randr_get_output_primary_cookie_t
xcb_randr_get_output_primary_unchecked (xcb_connection_t *c,
xcb_window_t window);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_randr_get_output_primary_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_randr_get_output_primary_reply_t *
xcb_randr_get_output_primary_reply (xcb_connection_t *c,
xcb_randr_get_output_primary_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_randr_get_providers_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_randr_get_providers_cookie_t
xcb_randr_get_providers (xcb_connection_t *c,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_randr_get_providers_cookie_t
xcb_randr_get_providers_unchecked (xcb_connection_t *c,
xcb_window_t window);
xcb_randr_provider_t *
xcb_randr_get_providers_providers (const xcb_randr_get_providers_reply_t *R);
int
xcb_randr_get_providers_providers_length (const xcb_randr_get_providers_reply_t *R);
xcb_generic_iterator_t
xcb_randr_get_providers_providers_end (const xcb_randr_get_providers_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_randr_get_providers_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_randr_get_providers_reply_t *
xcb_randr_get_providers_reply (xcb_connection_t *c,
xcb_randr_get_providers_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_randr_get_provider_info_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_randr_get_provider_info_cookie_t
xcb_randr_get_provider_info (xcb_connection_t *c,
xcb_randr_provider_t provider,
xcb_timestamp_t config_timestamp);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_randr_get_provider_info_cookie_t
xcb_randr_get_provider_info_unchecked (xcb_connection_t *c,
xcb_randr_provider_t provider,
xcb_timestamp_t config_timestamp);
xcb_randr_crtc_t *
xcb_randr_get_provider_info_crtcs (const xcb_randr_get_provider_info_reply_t *R);
int
xcb_randr_get_provider_info_crtcs_length (const xcb_randr_get_provider_info_reply_t *R);
xcb_generic_iterator_t
xcb_randr_get_provider_info_crtcs_end (const xcb_randr_get_provider_info_reply_t *R);
xcb_randr_output_t *
xcb_randr_get_provider_info_outputs (const xcb_randr_get_provider_info_reply_t *R);
int
xcb_randr_get_provider_info_outputs_length (const xcb_randr_get_provider_info_reply_t *R);
xcb_generic_iterator_t
xcb_randr_get_provider_info_outputs_end (const xcb_randr_get_provider_info_reply_t *R);
xcb_randr_provider_t *
xcb_randr_get_provider_info_associated_providers (const xcb_randr_get_provider_info_reply_t *R);
int
xcb_randr_get_provider_info_associated_providers_length (const xcb_randr_get_provider_info_reply_t *R);
xcb_generic_iterator_t
xcb_randr_get_provider_info_associated_providers_end (const xcb_randr_get_provider_info_reply_t *R);
uint32_t *
xcb_randr_get_provider_info_associated_capability (const xcb_randr_get_provider_info_reply_t *R);
int
xcb_randr_get_provider_info_associated_capability_length (const xcb_randr_get_provider_info_reply_t *R);
xcb_generic_iterator_t
xcb_randr_get_provider_info_associated_capability_end (const xcb_randr_get_provider_info_reply_t *R);
char *
xcb_randr_get_provider_info_name (const xcb_randr_get_provider_info_reply_t *R);
int
xcb_randr_get_provider_info_name_length (const xcb_randr_get_provider_info_reply_t *R);
xcb_generic_iterator_t
xcb_randr_get_provider_info_name_end (const xcb_randr_get_provider_info_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_randr_get_provider_info_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_randr_get_provider_info_reply_t *
xcb_randr_get_provider_info_reply (xcb_connection_t *c,
xcb_randr_get_provider_info_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_randr_set_provider_offload_sink_checked (xcb_connection_t *c,
xcb_randr_provider_t provider,
xcb_randr_provider_t sink_provider,
xcb_timestamp_t config_timestamp);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_randr_set_provider_offload_sink (xcb_connection_t *c,
xcb_randr_provider_t provider,
xcb_randr_provider_t sink_provider,
xcb_timestamp_t config_timestamp);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_randr_set_provider_output_source_checked (xcb_connection_t *c,
xcb_randr_provider_t provider,
xcb_randr_provider_t source_provider,
xcb_timestamp_t config_timestamp);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_randr_set_provider_output_source (xcb_connection_t *c,
xcb_randr_provider_t provider,
xcb_randr_provider_t source_provider,
xcb_timestamp_t config_timestamp);
int
xcb_randr_list_provider_properties_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_randr_list_provider_properties_cookie_t
xcb_randr_list_provider_properties (xcb_connection_t *c,
xcb_randr_provider_t provider);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_randr_list_provider_properties_cookie_t
xcb_randr_list_provider_properties_unchecked (xcb_connection_t *c,
xcb_randr_provider_t provider);
xcb_atom_t *
xcb_randr_list_provider_properties_atoms (const xcb_randr_list_provider_properties_reply_t *R);
int
xcb_randr_list_provider_properties_atoms_length (const xcb_randr_list_provider_properties_reply_t *R);
xcb_generic_iterator_t
xcb_randr_list_provider_properties_atoms_end (const xcb_randr_list_provider_properties_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_randr_list_provider_properties_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_randr_list_provider_properties_reply_t *
xcb_randr_list_provider_properties_reply (xcb_connection_t *c,
xcb_randr_list_provider_properties_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_randr_query_provider_property_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_randr_query_provider_property_cookie_t
xcb_randr_query_provider_property (xcb_connection_t *c,
xcb_randr_provider_t provider,
xcb_atom_t property);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_randr_query_provider_property_cookie_t
xcb_randr_query_provider_property_unchecked (xcb_connection_t *c,
xcb_randr_provider_t provider,
xcb_atom_t property);
int32_t *
xcb_randr_query_provider_property_valid_values (const xcb_randr_query_provider_property_reply_t *R);
int
xcb_randr_query_provider_property_valid_values_length (const xcb_randr_query_provider_property_reply_t *R);
xcb_generic_iterator_t
xcb_randr_query_provider_property_valid_values_end (const xcb_randr_query_provider_property_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_randr_query_provider_property_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_randr_query_provider_property_reply_t *
xcb_randr_query_provider_property_reply (xcb_connection_t *c,
xcb_randr_query_provider_property_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_randr_configure_provider_property_sizeof (const void *_buffer,
uint32_t values_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_randr_configure_provider_property_checked (xcb_connection_t *c,
xcb_randr_provider_t provider,
xcb_atom_t property,
uint8_t pending,
uint8_t range,
uint32_t values_len,
const int32_t *values);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_randr_configure_provider_property (xcb_connection_t *c,
xcb_randr_provider_t provider,
xcb_atom_t property,
uint8_t pending,
uint8_t range,
uint32_t values_len,
const int32_t *values);
int32_t *
xcb_randr_configure_provider_property_values (const xcb_randr_configure_provider_property_request_t *R);
int
xcb_randr_configure_provider_property_values_length (const xcb_randr_configure_provider_property_request_t *R);
xcb_generic_iterator_t
xcb_randr_configure_provider_property_values_end (const xcb_randr_configure_provider_property_request_t *R);
int
xcb_randr_change_provider_property_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_randr_change_provider_property_checked (xcb_connection_t *c,
xcb_randr_provider_t provider,
xcb_atom_t property,
xcb_atom_t type,
uint8_t format,
uint8_t mode,
uint32_t num_items,
const void *data);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_randr_change_provider_property (xcb_connection_t *c,
xcb_randr_provider_t provider,
xcb_atom_t property,
xcb_atom_t type,
uint8_t format,
uint8_t mode,
uint32_t num_items,
const void *data);
void *
xcb_randr_change_provider_property_data (const xcb_randr_change_provider_property_request_t *R);
int
xcb_randr_change_provider_property_data_length (const xcb_randr_change_provider_property_request_t *R);
xcb_generic_iterator_t
xcb_randr_change_provider_property_data_end (const xcb_randr_change_provider_property_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_randr_delete_provider_property_checked (xcb_connection_t *c,
xcb_randr_provider_t provider,
xcb_atom_t property);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_randr_delete_provider_property (xcb_connection_t *c,
xcb_randr_provider_t provider,
xcb_atom_t property);
int
xcb_randr_get_provider_property_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_randr_get_provider_property_cookie_t
xcb_randr_get_provider_property (xcb_connection_t *c,
xcb_randr_provider_t provider,
xcb_atom_t property,
xcb_atom_t type,
uint32_t long_offset,
uint32_t long_length,
uint8_t _delete,
uint8_t pending);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_randr_get_provider_property_cookie_t
xcb_randr_get_provider_property_unchecked (xcb_connection_t *c,
xcb_randr_provider_t provider,
xcb_atom_t property,
xcb_atom_t type,
uint32_t long_offset,
uint32_t long_length,
uint8_t _delete,
uint8_t pending);
void *
xcb_randr_get_provider_property_data (const xcb_randr_get_provider_property_reply_t *R);
int
xcb_randr_get_provider_property_data_length (const xcb_randr_get_provider_property_reply_t *R);
xcb_generic_iterator_t
xcb_randr_get_provider_property_data_end (const xcb_randr_get_provider_property_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_randr_get_provider_property_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_randr_get_provider_property_reply_t *
xcb_randr_get_provider_property_reply (xcb_connection_t *c,
xcb_randr_get_provider_property_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_randr_crtc_change_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_randr_crtc_change_t)
*/
void
xcb_randr_crtc_change_next (xcb_randr_crtc_change_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_randr_crtc_change_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_randr_crtc_change_end (xcb_randr_crtc_change_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_randr_output_change_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_randr_output_change_t)
*/
void
xcb_randr_output_change_next (xcb_randr_output_change_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_randr_output_change_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_randr_output_change_end (xcb_randr_output_change_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_randr_output_property_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_randr_output_property_t)
*/
void
xcb_randr_output_property_next (xcb_randr_output_property_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_randr_output_property_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_randr_output_property_end (xcb_randr_output_property_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_randr_provider_change_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_randr_provider_change_t)
*/
void
xcb_randr_provider_change_next (xcb_randr_provider_change_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_randr_provider_change_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_randr_provider_change_end (xcb_randr_provider_change_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_randr_provider_property_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_randr_provider_property_t)
*/
void
xcb_randr_provider_property_next (xcb_randr_provider_property_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_randr_provider_property_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_randr_provider_property_end (xcb_randr_provider_property_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_randr_resource_change_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_randr_resource_change_t)
*/
void
xcb_randr_resource_change_next (xcb_randr_resource_change_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_randr_resource_change_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_randr_resource_change_end (xcb_randr_resource_change_iterator_t i);
int
xcb_randr_monitor_info_sizeof (const void *_buffer);
xcb_randr_output_t *
xcb_randr_monitor_info_outputs (const xcb_randr_monitor_info_t *R);
int
xcb_randr_monitor_info_outputs_length (const xcb_randr_monitor_info_t *R);
xcb_generic_iterator_t
xcb_randr_monitor_info_outputs_end (const xcb_randr_monitor_info_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_randr_monitor_info_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_randr_monitor_info_t)
*/
void
xcb_randr_monitor_info_next (xcb_randr_monitor_info_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_randr_monitor_info_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_randr_monitor_info_end (xcb_randr_monitor_info_iterator_t i);
int
xcb_randr_get_monitors_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_randr_get_monitors_cookie_t
xcb_randr_get_monitors (xcb_connection_t *c,
xcb_window_t window,
uint8_t get_active);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_randr_get_monitors_cookie_t
xcb_randr_get_monitors_unchecked (xcb_connection_t *c,
xcb_window_t window,
uint8_t get_active);
int
xcb_randr_get_monitors_monitors_length (const xcb_randr_get_monitors_reply_t *R);
xcb_randr_monitor_info_iterator_t
xcb_randr_get_monitors_monitors_iterator (const xcb_randr_get_monitors_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_randr_get_monitors_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_randr_get_monitors_reply_t *
xcb_randr_get_monitors_reply (xcb_connection_t *c,
xcb_randr_get_monitors_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_randr_set_monitor_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_randr_set_monitor_checked (xcb_connection_t *c,
xcb_window_t window,
xcb_randr_monitor_info_t *monitorinfo);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_randr_set_monitor (xcb_connection_t *c,
xcb_window_t window,
xcb_randr_monitor_info_t *monitorinfo);
xcb_randr_monitor_info_t *
xcb_randr_set_monitor_monitorinfo (const xcb_randr_set_monitor_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_randr_delete_monitor_checked (xcb_connection_t *c,
xcb_window_t window,
xcb_atom_t name);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_randr_delete_monitor (xcb_connection_t *c,
xcb_window_t window,
xcb_atom_t name);
int
xcb_randr_create_lease_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_randr_create_lease_cookie_t
xcb_randr_create_lease (xcb_connection_t *c,
xcb_window_t window,
xcb_randr_lease_t lid,
uint16_t num_crtcs,
uint16_t num_outputs,
const xcb_randr_crtc_t *crtcs,
const xcb_randr_output_t *outputs);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_randr_create_lease_cookie_t
xcb_randr_create_lease_unchecked (xcb_connection_t *c,
xcb_window_t window,
xcb_randr_lease_t lid,
uint16_t num_crtcs,
uint16_t num_outputs,
const xcb_randr_crtc_t *crtcs,
const xcb_randr_output_t *outputs);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_randr_create_lease_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_randr_create_lease_reply_t *
xcb_randr_create_lease_reply (xcb_connection_t *c,
xcb_randr_create_lease_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
* Return the reply fds
* @param c The connection
* @param reply The reply
*
* Returns the array of reply fds of the request asked by
*
* The returned value must be freed by the caller using free().
*/
int *
xcb_randr_create_lease_reply_fds (xcb_connection_t *c /**< */,
xcb_randr_create_lease_reply_t *reply);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_randr_free_lease_checked (xcb_connection_t *c,
xcb_randr_lease_t lid,
uint8_t terminate);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_randr_free_lease (xcb_connection_t *c,
xcb_randr_lease_t lid,
uint8_t terminate);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_randr_lease_notify_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_randr_lease_notify_t)
*/
void
xcb_randr_lease_notify_next (xcb_randr_lease_notify_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_randr_lease_notify_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_randr_lease_notify_end (xcb_randr_lease_notify_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_randr_notify_data_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_randr_notify_data_t)
*/
void
xcb_randr_notify_data_next (xcb_randr_notify_data_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_randr_notify_data_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_randr_notify_data_end (xcb_randr_notify_data_iterator_t i);
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/
xcb/xinput.h 0000644 00001124625 15201526705 0007036 0 ustar 00 /*
* This file generated automatically from xinput.xml by c_client.py.
* Edit at your peril.
*/
/**
* @defgroup XCB_Input_API XCB Input API
* @brief Input XCB Protocol Implementation.
* @{
**/
#ifndef __XINPUT_H
#define __XINPUT_H
#include "xcb.h"
#include "xfixes.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XCB_INPUT_MAJOR_VERSION 2
#define XCB_INPUT_MINOR_VERSION 3
extern xcb_extension_t xcb_input_id;
typedef uint32_t xcb_input_event_class_t;
/**
* @brief xcb_input_event_class_iterator_t
**/
typedef struct xcb_input_event_class_iterator_t {
xcb_input_event_class_t *data;
int rem;
int index;
} xcb_input_event_class_iterator_t;
typedef uint8_t xcb_input_key_code_t;
/**
* @brief xcb_input_key_code_iterator_t
**/
typedef struct xcb_input_key_code_iterator_t {
xcb_input_key_code_t *data;
int rem;
int index;
} xcb_input_key_code_iterator_t;
typedef uint16_t xcb_input_device_id_t;
/**
* @brief xcb_input_device_id_iterator_t
**/
typedef struct xcb_input_device_id_iterator_t {
xcb_input_device_id_t *data;
int rem;
int index;
} xcb_input_device_id_iterator_t;
typedef int32_t xcb_input_fp1616_t;
/**
* @brief xcb_input_fp1616_iterator_t
**/
typedef struct xcb_input_fp1616_iterator_t {
xcb_input_fp1616_t *data;
int rem;
int index;
} xcb_input_fp1616_iterator_t;
/**
* @brief xcb_input_fp3232_t
**/
typedef struct xcb_input_fp3232_t {
int32_t integral;
uint32_t frac;
} xcb_input_fp3232_t;
/**
* @brief xcb_input_fp3232_iterator_t
**/
typedef struct xcb_input_fp3232_iterator_t {
xcb_input_fp3232_t *data;
int rem;
int index;
} xcb_input_fp3232_iterator_t;
/**
* @brief xcb_input_get_extension_version_cookie_t
**/
typedef struct xcb_input_get_extension_version_cookie_t {
unsigned int sequence;
} xcb_input_get_extension_version_cookie_t;
/** Opcode for xcb_input_get_extension_version. */
#define XCB_INPUT_GET_EXTENSION_VERSION 1
/**
* @brief xcb_input_get_extension_version_request_t
**/
typedef struct xcb_input_get_extension_version_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint16_t name_len;
uint8_t pad0[2];
} xcb_input_get_extension_version_request_t;
/**
* @brief xcb_input_get_extension_version_reply_t
**/
typedef struct xcb_input_get_extension_version_reply_t {
uint8_t response_type;
uint8_t xi_reply_type;
uint16_t sequence;
uint32_t length;
uint16_t server_major;
uint16_t server_minor;
uint8_t present;
uint8_t pad0[19];
} xcb_input_get_extension_version_reply_t;
typedef enum xcb_input_device_use_t {
XCB_INPUT_DEVICE_USE_IS_X_POINTER = 0,
XCB_INPUT_DEVICE_USE_IS_X_KEYBOARD = 1,
XCB_INPUT_DEVICE_USE_IS_X_EXTENSION_DEVICE = 2,
XCB_INPUT_DEVICE_USE_IS_X_EXTENSION_KEYBOARD = 3,
XCB_INPUT_DEVICE_USE_IS_X_EXTENSION_POINTER = 4
} xcb_input_device_use_t;
typedef enum xcb_input_input_class_t {
XCB_INPUT_INPUT_CLASS_KEY = 0,
XCB_INPUT_INPUT_CLASS_BUTTON = 1,
XCB_INPUT_INPUT_CLASS_VALUATOR = 2,
XCB_INPUT_INPUT_CLASS_FEEDBACK = 3,
XCB_INPUT_INPUT_CLASS_PROXIMITY = 4,
XCB_INPUT_INPUT_CLASS_FOCUS = 5,
XCB_INPUT_INPUT_CLASS_OTHER = 6
} xcb_input_input_class_t;
typedef enum xcb_input_valuator_mode_t {
XCB_INPUT_VALUATOR_MODE_RELATIVE = 0,
XCB_INPUT_VALUATOR_MODE_ABSOLUTE = 1
} xcb_input_valuator_mode_t;
/**
* @brief xcb_input_device_info_t
**/
typedef struct xcb_input_device_info_t {
xcb_atom_t device_type;
uint8_t device_id;
uint8_t num_class_info;
uint8_t device_use;
uint8_t pad0;
} xcb_input_device_info_t;
/**
* @brief xcb_input_device_info_iterator_t
**/
typedef struct xcb_input_device_info_iterator_t {
xcb_input_device_info_t *data;
int rem;
int index;
} xcb_input_device_info_iterator_t;
/**
* @brief xcb_input_key_info_t
**/
typedef struct xcb_input_key_info_t {
uint8_t class_id;
uint8_t len;
xcb_input_key_code_t min_keycode;
xcb_input_key_code_t max_keycode;
uint16_t num_keys;
uint8_t pad0[2];
} xcb_input_key_info_t;
/**
* @brief xcb_input_key_info_iterator_t
**/
typedef struct xcb_input_key_info_iterator_t {
xcb_input_key_info_t *data;
int rem;
int index;
} xcb_input_key_info_iterator_t;
/**
* @brief xcb_input_button_info_t
**/
typedef struct xcb_input_button_info_t {
uint8_t class_id;
uint8_t len;
uint16_t num_buttons;
} xcb_input_button_info_t;
/**
* @brief xcb_input_button_info_iterator_t
**/
typedef struct xcb_input_button_info_iterator_t {
xcb_input_button_info_t *data;
int rem;
int index;
} xcb_input_button_info_iterator_t;
/**
* @brief xcb_input_axis_info_t
**/
typedef struct xcb_input_axis_info_t {
uint32_t resolution;
int32_t minimum;
int32_t maximum;
} xcb_input_axis_info_t;
/**
* @brief xcb_input_axis_info_iterator_t
**/
typedef struct xcb_input_axis_info_iterator_t {
xcb_input_axis_info_t *data;
int rem;
int index;
} xcb_input_axis_info_iterator_t;
/**
* @brief xcb_input_valuator_info_t
**/
typedef struct xcb_input_valuator_info_t {
uint8_t class_id;
uint8_t len;
uint8_t axes_len;
uint8_t mode;
uint32_t motion_size;
} xcb_input_valuator_info_t;
/**
* @brief xcb_input_valuator_info_iterator_t
**/
typedef struct xcb_input_valuator_info_iterator_t {
xcb_input_valuator_info_t *data;
int rem;
int index;
} xcb_input_valuator_info_iterator_t;
/**
* @brief xcb_input_input_info_info_t
**/
typedef struct xcb_input_input_info_info_t {
struct {
xcb_input_key_code_t min_keycode;
xcb_input_key_code_t max_keycode;
uint16_t num_keys;
uint8_t pad0[2];
} key;
struct {
uint16_t num_buttons;
} button;
struct {
uint8_t axes_len;
uint8_t mode;
uint32_t motion_size;
xcb_input_axis_info_t *axes;
} valuator;
} xcb_input_input_info_info_t;
/**
* @brief xcb_input_input_info_t
**/
typedef struct xcb_input_input_info_t {
uint8_t class_id;
uint8_t len;
} xcb_input_input_info_t;
void *
xcb_input_input_info_info (const xcb_input_input_info_t *R);
/**
* @brief xcb_input_input_info_iterator_t
**/
typedef struct xcb_input_input_info_iterator_t {
xcb_input_input_info_t *data;
int rem;
int index;
} xcb_input_input_info_iterator_t;
/**
* @brief xcb_input_device_name_t
**/
typedef struct xcb_input_device_name_t {
uint8_t len;
} xcb_input_device_name_t;
/**
* @brief xcb_input_device_name_iterator_t
**/
typedef struct xcb_input_device_name_iterator_t {
xcb_input_device_name_t *data;
int rem;
int index;
} xcb_input_device_name_iterator_t;
/**
* @brief xcb_input_list_input_devices_cookie_t
**/
typedef struct xcb_input_list_input_devices_cookie_t {
unsigned int sequence;
} xcb_input_list_input_devices_cookie_t;
/** Opcode for xcb_input_list_input_devices. */
#define XCB_INPUT_LIST_INPUT_DEVICES 2
/**
* @brief xcb_input_list_input_devices_request_t
**/
typedef struct xcb_input_list_input_devices_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_input_list_input_devices_request_t;
/**
* @brief xcb_input_list_input_devices_reply_t
**/
typedef struct xcb_input_list_input_devices_reply_t {
uint8_t response_type;
uint8_t xi_reply_type;
uint16_t sequence;
uint32_t length;
uint8_t devices_len;
uint8_t pad0[23];
} xcb_input_list_input_devices_reply_t;
typedef uint8_t xcb_input_event_type_base_t;
/**
* @brief xcb_input_event_type_base_iterator_t
**/
typedef struct xcb_input_event_type_base_iterator_t {
xcb_input_event_type_base_t *data;
int rem;
int index;
} xcb_input_event_type_base_iterator_t;
/**
* @brief xcb_input_input_class_info_t
**/
typedef struct xcb_input_input_class_info_t {
uint8_t class_id;
xcb_input_event_type_base_t event_type_base;
} xcb_input_input_class_info_t;
/**
* @brief xcb_input_input_class_info_iterator_t
**/
typedef struct xcb_input_input_class_info_iterator_t {
xcb_input_input_class_info_t *data;
int rem;
int index;
} xcb_input_input_class_info_iterator_t;
/**
* @brief xcb_input_open_device_cookie_t
**/
typedef struct xcb_input_open_device_cookie_t {
unsigned int sequence;
} xcb_input_open_device_cookie_t;
/** Opcode for xcb_input_open_device. */
#define XCB_INPUT_OPEN_DEVICE 3
/**
* @brief xcb_input_open_device_request_t
**/
typedef struct xcb_input_open_device_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t device_id;
uint8_t pad0[3];
} xcb_input_open_device_request_t;
/**
* @brief xcb_input_open_device_reply_t
**/
typedef struct xcb_input_open_device_reply_t {
uint8_t response_type;
uint8_t xi_reply_type;
uint16_t sequence;
uint32_t length;
uint8_t num_classes;
uint8_t pad0[23];
} xcb_input_open_device_reply_t;
/** Opcode for xcb_input_close_device. */
#define XCB_INPUT_CLOSE_DEVICE 4
/**
* @brief xcb_input_close_device_request_t
**/
typedef struct xcb_input_close_device_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t device_id;
uint8_t pad0[3];
} xcb_input_close_device_request_t;
/**
* @brief xcb_input_set_device_mode_cookie_t
**/
typedef struct xcb_input_set_device_mode_cookie_t {
unsigned int sequence;
} xcb_input_set_device_mode_cookie_t;
/** Opcode for xcb_input_set_device_mode. */
#define XCB_INPUT_SET_DEVICE_MODE 5
/**
* @brief xcb_input_set_device_mode_request_t
**/
typedef struct xcb_input_set_device_mode_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t device_id;
uint8_t mode;
uint8_t pad0[2];
} xcb_input_set_device_mode_request_t;
/**
* @brief xcb_input_set_device_mode_reply_t
**/
typedef struct xcb_input_set_device_mode_reply_t {
uint8_t response_type;
uint8_t xi_reply_type;
uint16_t sequence;
uint32_t length;
uint8_t status;
uint8_t pad0[23];
} xcb_input_set_device_mode_reply_t;
/** Opcode for xcb_input_select_extension_event. */
#define XCB_INPUT_SELECT_EXTENSION_EVENT 6
/**
* @brief xcb_input_select_extension_event_request_t
**/
typedef struct xcb_input_select_extension_event_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
uint16_t num_classes;
uint8_t pad0[2];
} xcb_input_select_extension_event_request_t;
/**
* @brief xcb_input_get_selected_extension_events_cookie_t
**/
typedef struct xcb_input_get_selected_extension_events_cookie_t {
unsigned int sequence;
} xcb_input_get_selected_extension_events_cookie_t;
/** Opcode for xcb_input_get_selected_extension_events. */
#define XCB_INPUT_GET_SELECTED_EXTENSION_EVENTS 7
/**
* @brief xcb_input_get_selected_extension_events_request_t
**/
typedef struct xcb_input_get_selected_extension_events_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
} xcb_input_get_selected_extension_events_request_t;
/**
* @brief xcb_input_get_selected_extension_events_reply_t
**/
typedef struct xcb_input_get_selected_extension_events_reply_t {
uint8_t response_type;
uint8_t xi_reply_type;
uint16_t sequence;
uint32_t length;
uint16_t num_this_classes;
uint16_t num_all_classes;
uint8_t pad0[20];
} xcb_input_get_selected_extension_events_reply_t;
typedef enum xcb_input_propagate_mode_t {
XCB_INPUT_PROPAGATE_MODE_ADD_TO_LIST = 0,
XCB_INPUT_PROPAGATE_MODE_DELETE_FROM_LIST = 1
} xcb_input_propagate_mode_t;
/** Opcode for xcb_input_change_device_dont_propagate_list. */
#define XCB_INPUT_CHANGE_DEVICE_DONT_PROPAGATE_LIST 8
/**
* @brief xcb_input_change_device_dont_propagate_list_request_t
**/
typedef struct xcb_input_change_device_dont_propagate_list_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
uint16_t num_classes;
uint8_t mode;
uint8_t pad0;
} xcb_input_change_device_dont_propagate_list_request_t;
/**
* @brief xcb_input_get_device_dont_propagate_list_cookie_t
**/
typedef struct xcb_input_get_device_dont_propagate_list_cookie_t {
unsigned int sequence;
} xcb_input_get_device_dont_propagate_list_cookie_t;
/** Opcode for xcb_input_get_device_dont_propagate_list. */
#define XCB_INPUT_GET_DEVICE_DONT_PROPAGATE_LIST 9
/**
* @brief xcb_input_get_device_dont_propagate_list_request_t
**/
typedef struct xcb_input_get_device_dont_propagate_list_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
} xcb_input_get_device_dont_propagate_list_request_t;
/**
* @brief xcb_input_get_device_dont_propagate_list_reply_t
**/
typedef struct xcb_input_get_device_dont_propagate_list_reply_t {
uint8_t response_type;
uint8_t xi_reply_type;
uint16_t sequence;
uint32_t length;
uint16_t num_classes;
uint8_t pad0[22];
} xcb_input_get_device_dont_propagate_list_reply_t;
/**
* @brief xcb_input_device_time_coord_t
**/
typedef struct xcb_input_device_time_coord_t {
xcb_timestamp_t time;
} xcb_input_device_time_coord_t;
/**
* @brief xcb_input_device_time_coord_iterator_t
**/
typedef struct xcb_input_device_time_coord_iterator_t {
xcb_input_device_time_coord_t *data;
int rem;
int index;
uint8_t num_axes; /**< */
} xcb_input_device_time_coord_iterator_t;
/**
* @brief xcb_input_get_device_motion_events_cookie_t
**/
typedef struct xcb_input_get_device_motion_events_cookie_t {
unsigned int sequence;
} xcb_input_get_device_motion_events_cookie_t;
/** Opcode for xcb_input_get_device_motion_events. */
#define XCB_INPUT_GET_DEVICE_MOTION_EVENTS 10
/**
* @brief xcb_input_get_device_motion_events_request_t
**/
typedef struct xcb_input_get_device_motion_events_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_timestamp_t start;
xcb_timestamp_t stop;
uint8_t device_id;
uint8_t pad0[3];
} xcb_input_get_device_motion_events_request_t;
/**
* @brief xcb_input_get_device_motion_events_reply_t
**/
typedef struct xcb_input_get_device_motion_events_reply_t {
uint8_t response_type;
uint8_t xi_reply_type;
uint16_t sequence;
uint32_t length;
uint32_t num_events;
uint8_t num_axes;
uint8_t device_mode;
uint8_t pad0[18];
} xcb_input_get_device_motion_events_reply_t;
/**
* @brief xcb_input_change_keyboard_device_cookie_t
**/
typedef struct xcb_input_change_keyboard_device_cookie_t {
unsigned int sequence;
} xcb_input_change_keyboard_device_cookie_t;
/** Opcode for xcb_input_change_keyboard_device. */
#define XCB_INPUT_CHANGE_KEYBOARD_DEVICE 11
/**
* @brief xcb_input_change_keyboard_device_request_t
**/
typedef struct xcb_input_change_keyboard_device_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t device_id;
uint8_t pad0[3];
} xcb_input_change_keyboard_device_request_t;
/**
* @brief xcb_input_change_keyboard_device_reply_t
**/
typedef struct xcb_input_change_keyboard_device_reply_t {
uint8_t response_type;
uint8_t xi_reply_type;
uint16_t sequence;
uint32_t length;
uint8_t status;
uint8_t pad0[23];
} xcb_input_change_keyboard_device_reply_t;
/**
* @brief xcb_input_change_pointer_device_cookie_t
**/
typedef struct xcb_input_change_pointer_device_cookie_t {
unsigned int sequence;
} xcb_input_change_pointer_device_cookie_t;
/** Opcode for xcb_input_change_pointer_device. */
#define XCB_INPUT_CHANGE_POINTER_DEVICE 12
/**
* @brief xcb_input_change_pointer_device_request_t
**/
typedef struct xcb_input_change_pointer_device_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t x_axis;
uint8_t y_axis;
uint8_t device_id;
uint8_t pad0;
} xcb_input_change_pointer_device_request_t;
/**
* @brief xcb_input_change_pointer_device_reply_t
**/
typedef struct xcb_input_change_pointer_device_reply_t {
uint8_t response_type;
uint8_t xi_reply_type;
uint16_t sequence;
uint32_t length;
uint8_t status;
uint8_t pad0[23];
} xcb_input_change_pointer_device_reply_t;
/**
* @brief xcb_input_grab_device_cookie_t
**/
typedef struct xcb_input_grab_device_cookie_t {
unsigned int sequence;
} xcb_input_grab_device_cookie_t;
/** Opcode for xcb_input_grab_device. */
#define XCB_INPUT_GRAB_DEVICE 13
/**
* @brief xcb_input_grab_device_request_t
**/
typedef struct xcb_input_grab_device_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t grab_window;
xcb_timestamp_t time;
uint16_t num_classes;
uint8_t this_device_mode;
uint8_t other_device_mode;
uint8_t owner_events;
uint8_t device_id;
uint8_t pad0[2];
} xcb_input_grab_device_request_t;
/**
* @brief xcb_input_grab_device_reply_t
**/
typedef struct xcb_input_grab_device_reply_t {
uint8_t response_type;
uint8_t xi_reply_type;
uint16_t sequence;
uint32_t length;
uint8_t status;
uint8_t pad0[23];
} xcb_input_grab_device_reply_t;
/** Opcode for xcb_input_ungrab_device. */
#define XCB_INPUT_UNGRAB_DEVICE 14
/**
* @brief xcb_input_ungrab_device_request_t
**/
typedef struct xcb_input_ungrab_device_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_timestamp_t time;
uint8_t device_id;
uint8_t pad0[3];
} xcb_input_ungrab_device_request_t;
typedef enum xcb_input_modifier_device_t {
XCB_INPUT_MODIFIER_DEVICE_USE_X_KEYBOARD = 255
} xcb_input_modifier_device_t;
/** Opcode for xcb_input_grab_device_key. */
#define XCB_INPUT_GRAB_DEVICE_KEY 15
/**
* @brief xcb_input_grab_device_key_request_t
**/
typedef struct xcb_input_grab_device_key_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t grab_window;
uint16_t num_classes;
uint16_t modifiers;
uint8_t modifier_device;
uint8_t grabbed_device;
uint8_t key;
uint8_t this_device_mode;
uint8_t other_device_mode;
uint8_t owner_events;
uint8_t pad0[2];
} xcb_input_grab_device_key_request_t;
/** Opcode for xcb_input_ungrab_device_key. */
#define XCB_INPUT_UNGRAB_DEVICE_KEY 16
/**
* @brief xcb_input_ungrab_device_key_request_t
**/
typedef struct xcb_input_ungrab_device_key_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t grabWindow;
uint16_t modifiers;
uint8_t modifier_device;
uint8_t key;
uint8_t grabbed_device;
} xcb_input_ungrab_device_key_request_t;
/** Opcode for xcb_input_grab_device_button. */
#define XCB_INPUT_GRAB_DEVICE_BUTTON 17
/**
* @brief xcb_input_grab_device_button_request_t
**/
typedef struct xcb_input_grab_device_button_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t grab_window;
uint8_t grabbed_device;
uint8_t modifier_device;
uint16_t num_classes;
uint16_t modifiers;
uint8_t this_device_mode;
uint8_t other_device_mode;
uint8_t button;
uint8_t owner_events;
uint8_t pad0[2];
} xcb_input_grab_device_button_request_t;
/** Opcode for xcb_input_ungrab_device_button. */
#define XCB_INPUT_UNGRAB_DEVICE_BUTTON 18
/**
* @brief xcb_input_ungrab_device_button_request_t
**/
typedef struct xcb_input_ungrab_device_button_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t grab_window;
uint16_t modifiers;
uint8_t modifier_device;
uint8_t button;
uint8_t grabbed_device;
uint8_t pad0[3];
} xcb_input_ungrab_device_button_request_t;
typedef enum xcb_input_device_input_mode_t {
XCB_INPUT_DEVICE_INPUT_MODE_ASYNC_THIS_DEVICE = 0,
XCB_INPUT_DEVICE_INPUT_MODE_SYNC_THIS_DEVICE = 1,
XCB_INPUT_DEVICE_INPUT_MODE_REPLAY_THIS_DEVICE = 2,
XCB_INPUT_DEVICE_INPUT_MODE_ASYNC_OTHER_DEVICES = 3,
XCB_INPUT_DEVICE_INPUT_MODE_ASYNC_ALL = 4,
XCB_INPUT_DEVICE_INPUT_MODE_SYNC_ALL = 5
} xcb_input_device_input_mode_t;
/** Opcode for xcb_input_allow_device_events. */
#define XCB_INPUT_ALLOW_DEVICE_EVENTS 19
/**
* @brief xcb_input_allow_device_events_request_t
**/
typedef struct xcb_input_allow_device_events_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_timestamp_t time;
uint8_t mode;
uint8_t device_id;
uint8_t pad0[2];
} xcb_input_allow_device_events_request_t;
/**
* @brief xcb_input_get_device_focus_cookie_t
**/
typedef struct xcb_input_get_device_focus_cookie_t {
unsigned int sequence;
} xcb_input_get_device_focus_cookie_t;
/** Opcode for xcb_input_get_device_focus. */
#define XCB_INPUT_GET_DEVICE_FOCUS 20
/**
* @brief xcb_input_get_device_focus_request_t
**/
typedef struct xcb_input_get_device_focus_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t device_id;
uint8_t pad0[3];
} xcb_input_get_device_focus_request_t;
/**
* @brief xcb_input_get_device_focus_reply_t
**/
typedef struct xcb_input_get_device_focus_reply_t {
uint8_t response_type;
uint8_t xi_reply_type;
uint16_t sequence;
uint32_t length;
xcb_window_t focus;
xcb_timestamp_t time;
uint8_t revert_to;
uint8_t pad0[15];
} xcb_input_get_device_focus_reply_t;
/** Opcode for xcb_input_set_device_focus. */
#define XCB_INPUT_SET_DEVICE_FOCUS 21
/**
* @brief xcb_input_set_device_focus_request_t
**/
typedef struct xcb_input_set_device_focus_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t focus;
xcb_timestamp_t time;
uint8_t revert_to;
uint8_t device_id;
uint8_t pad0[2];
} xcb_input_set_device_focus_request_t;
typedef enum xcb_input_feedback_class_t {
XCB_INPUT_FEEDBACK_CLASS_KEYBOARD = 0,
XCB_INPUT_FEEDBACK_CLASS_POINTER = 1,
XCB_INPUT_FEEDBACK_CLASS_STRING = 2,
XCB_INPUT_FEEDBACK_CLASS_INTEGER = 3,
XCB_INPUT_FEEDBACK_CLASS_LED = 4,
XCB_INPUT_FEEDBACK_CLASS_BELL = 5
} xcb_input_feedback_class_t;
/**
* @brief xcb_input_kbd_feedback_state_t
**/
typedef struct xcb_input_kbd_feedback_state_t {
uint8_t class_id;
uint8_t feedback_id;
uint16_t len;
uint16_t pitch;
uint16_t duration;
uint32_t led_mask;
uint32_t led_values;
uint8_t global_auto_repeat;
uint8_t click;
uint8_t percent;
uint8_t pad0;
uint8_t auto_repeats[32];
} xcb_input_kbd_feedback_state_t;
/**
* @brief xcb_input_kbd_feedback_state_iterator_t
**/
typedef struct xcb_input_kbd_feedback_state_iterator_t {
xcb_input_kbd_feedback_state_t *data;
int rem;
int index;
} xcb_input_kbd_feedback_state_iterator_t;
/**
* @brief xcb_input_ptr_feedback_state_t
**/
typedef struct xcb_input_ptr_feedback_state_t {
uint8_t class_id;
uint8_t feedback_id;
uint16_t len;
uint8_t pad0[2];
uint16_t accel_num;
uint16_t accel_denom;
uint16_t threshold;
} xcb_input_ptr_feedback_state_t;
/**
* @brief xcb_input_ptr_feedback_state_iterator_t
**/
typedef struct xcb_input_ptr_feedback_state_iterator_t {
xcb_input_ptr_feedback_state_t *data;
int rem;
int index;
} xcb_input_ptr_feedback_state_iterator_t;
/**
* @brief xcb_input_integer_feedback_state_t
**/
typedef struct xcb_input_integer_feedback_state_t {
uint8_t class_id;
uint8_t feedback_id;
uint16_t len;
uint32_t resolution;
int32_t min_value;
int32_t max_value;
} xcb_input_integer_feedback_state_t;
/**
* @brief xcb_input_integer_feedback_state_iterator_t
**/
typedef struct xcb_input_integer_feedback_state_iterator_t {
xcb_input_integer_feedback_state_t *data;
int rem;
int index;
} xcb_input_integer_feedback_state_iterator_t;
/**
* @brief xcb_input_string_feedback_state_t
**/
typedef struct xcb_input_string_feedback_state_t {
uint8_t class_id;
uint8_t feedback_id;
uint16_t len;
uint16_t max_symbols;
uint16_t num_keysyms;
} xcb_input_string_feedback_state_t;
/**
* @brief xcb_input_string_feedback_state_iterator_t
**/
typedef struct xcb_input_string_feedback_state_iterator_t {
xcb_input_string_feedback_state_t *data;
int rem;
int index;
} xcb_input_string_feedback_state_iterator_t;
/**
* @brief xcb_input_bell_feedback_state_t
**/
typedef struct xcb_input_bell_feedback_state_t {
uint8_t class_id;
uint8_t feedback_id;
uint16_t len;
uint8_t percent;
uint8_t pad0[3];
uint16_t pitch;
uint16_t duration;
} xcb_input_bell_feedback_state_t;
/**
* @brief xcb_input_bell_feedback_state_iterator_t
**/
typedef struct xcb_input_bell_feedback_state_iterator_t {
xcb_input_bell_feedback_state_t *data;
int rem;
int index;
} xcb_input_bell_feedback_state_iterator_t;
/**
* @brief xcb_input_led_feedback_state_t
**/
typedef struct xcb_input_led_feedback_state_t {
uint8_t class_id;
uint8_t feedback_id;
uint16_t len;
uint32_t led_mask;
uint32_t led_values;
} xcb_input_led_feedback_state_t;
/**
* @brief xcb_input_led_feedback_state_iterator_t
**/
typedef struct xcb_input_led_feedback_state_iterator_t {
xcb_input_led_feedback_state_t *data;
int rem;
int index;
} xcb_input_led_feedback_state_iterator_t;
/**
* @brief xcb_input_feedback_state_data_t
**/
typedef struct xcb_input_feedback_state_data_t {
struct {
uint16_t pitch;
uint16_t duration;
uint32_t led_mask;
uint32_t led_values;
uint8_t global_auto_repeat;
uint8_t click;
uint8_t percent;
uint8_t pad0;
uint8_t auto_repeats[32];
} keyboard;
struct {
uint8_t pad1[2];
uint16_t accel_num;
uint16_t accel_denom;
uint16_t threshold;
} pointer;
struct {
uint16_t max_symbols;
uint16_t num_keysyms;
xcb_keysym_t *keysyms;
} string;
struct {
uint32_t resolution;
int32_t min_value;
int32_t max_value;
} integer;
struct {
uint32_t led_mask;
uint32_t led_values;
} led;
struct {
uint8_t percent;
uint8_t pad2[3];
uint16_t pitch;
uint16_t duration;
} bell;
} xcb_input_feedback_state_data_t;
/**
* @brief xcb_input_feedback_state_t
**/
typedef struct xcb_input_feedback_state_t {
uint8_t class_id;
uint8_t feedback_id;
uint16_t len;
} xcb_input_feedback_state_t;
void *
xcb_input_feedback_state_data (const xcb_input_feedback_state_t *R);
/**
* @brief xcb_input_feedback_state_iterator_t
**/
typedef struct xcb_input_feedback_state_iterator_t {
xcb_input_feedback_state_t *data;
int rem;
int index;
} xcb_input_feedback_state_iterator_t;
/**
* @brief xcb_input_get_feedback_control_cookie_t
**/
typedef struct xcb_input_get_feedback_control_cookie_t {
unsigned int sequence;
} xcb_input_get_feedback_control_cookie_t;
/** Opcode for xcb_input_get_feedback_control. */
#define XCB_INPUT_GET_FEEDBACK_CONTROL 22
/**
* @brief xcb_input_get_feedback_control_request_t
**/
typedef struct xcb_input_get_feedback_control_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t device_id;
uint8_t pad0[3];
} xcb_input_get_feedback_control_request_t;
/**
* @brief xcb_input_get_feedback_control_reply_t
**/
typedef struct xcb_input_get_feedback_control_reply_t {
uint8_t response_type;
uint8_t xi_reply_type;
uint16_t sequence;
uint32_t length;
uint16_t num_feedbacks;
uint8_t pad0[22];
} xcb_input_get_feedback_control_reply_t;
/**
* @brief xcb_input_kbd_feedback_ctl_t
**/
typedef struct xcb_input_kbd_feedback_ctl_t {
uint8_t class_id;
uint8_t feedback_id;
uint16_t len;
xcb_input_key_code_t key;
uint8_t auto_repeat_mode;
int8_t key_click_percent;
int8_t bell_percent;
int16_t bell_pitch;
int16_t bell_duration;
uint32_t led_mask;
uint32_t led_values;
} xcb_input_kbd_feedback_ctl_t;
/**
* @brief xcb_input_kbd_feedback_ctl_iterator_t
**/
typedef struct xcb_input_kbd_feedback_ctl_iterator_t {
xcb_input_kbd_feedback_ctl_t *data;
int rem;
int index;
} xcb_input_kbd_feedback_ctl_iterator_t;
/**
* @brief xcb_input_ptr_feedback_ctl_t
**/
typedef struct xcb_input_ptr_feedback_ctl_t {
uint8_t class_id;
uint8_t feedback_id;
uint16_t len;
uint8_t pad0[2];
int16_t num;
int16_t denom;
int16_t threshold;
} xcb_input_ptr_feedback_ctl_t;
/**
* @brief xcb_input_ptr_feedback_ctl_iterator_t
**/
typedef struct xcb_input_ptr_feedback_ctl_iterator_t {
xcb_input_ptr_feedback_ctl_t *data;
int rem;
int index;
} xcb_input_ptr_feedback_ctl_iterator_t;
/**
* @brief xcb_input_integer_feedback_ctl_t
**/
typedef struct xcb_input_integer_feedback_ctl_t {
uint8_t class_id;
uint8_t feedback_id;
uint16_t len;
int32_t int_to_display;
} xcb_input_integer_feedback_ctl_t;
/**
* @brief xcb_input_integer_feedback_ctl_iterator_t
**/
typedef struct xcb_input_integer_feedback_ctl_iterator_t {
xcb_input_integer_feedback_ctl_t *data;
int rem;
int index;
} xcb_input_integer_feedback_ctl_iterator_t;
/**
* @brief xcb_input_string_feedback_ctl_t
**/
typedef struct xcb_input_string_feedback_ctl_t {
uint8_t class_id;
uint8_t feedback_id;
uint16_t len;
uint8_t pad0[2];
uint16_t num_keysyms;
} xcb_input_string_feedback_ctl_t;
/**
* @brief xcb_input_string_feedback_ctl_iterator_t
**/
typedef struct xcb_input_string_feedback_ctl_iterator_t {
xcb_input_string_feedback_ctl_t *data;
int rem;
int index;
} xcb_input_string_feedback_ctl_iterator_t;
/**
* @brief xcb_input_bell_feedback_ctl_t
**/
typedef struct xcb_input_bell_feedback_ctl_t {
uint8_t class_id;
uint8_t feedback_id;
uint16_t len;
int8_t percent;
uint8_t pad0[3];
int16_t pitch;
int16_t duration;
} xcb_input_bell_feedback_ctl_t;
/**
* @brief xcb_input_bell_feedback_ctl_iterator_t
**/
typedef struct xcb_input_bell_feedback_ctl_iterator_t {
xcb_input_bell_feedback_ctl_t *data;
int rem;
int index;
} xcb_input_bell_feedback_ctl_iterator_t;
/**
* @brief xcb_input_led_feedback_ctl_t
**/
typedef struct xcb_input_led_feedback_ctl_t {
uint8_t class_id;
uint8_t feedback_id;
uint16_t len;
uint32_t led_mask;
uint32_t led_values;
} xcb_input_led_feedback_ctl_t;
/**
* @brief xcb_input_led_feedback_ctl_iterator_t
**/
typedef struct xcb_input_led_feedback_ctl_iterator_t {
xcb_input_led_feedback_ctl_t *data;
int rem;
int index;
} xcb_input_led_feedback_ctl_iterator_t;
/**
* @brief xcb_input_feedback_ctl_data_t
**/
typedef struct xcb_input_feedback_ctl_data_t {
struct {
xcb_input_key_code_t key;
uint8_t auto_repeat_mode;
int8_t key_click_percent;
int8_t bell_percent;
int16_t bell_pitch;
int16_t bell_duration;
uint32_t led_mask;
uint32_t led_values;
} keyboard;
struct {
uint8_t pad0[2];
int16_t num;
int16_t denom;
int16_t threshold;
} pointer;
struct {
uint8_t pad1[2];
uint16_t num_keysyms;
xcb_keysym_t *keysyms;
} string;
struct {
int32_t int_to_display;
} integer;
struct {
uint32_t led_mask;
uint32_t led_values;
} led;
struct {
int8_t percent;
uint8_t pad2[3];
int16_t pitch;
int16_t duration;
} bell;
} xcb_input_feedback_ctl_data_t;
/**
* @brief xcb_input_feedback_ctl_t
**/
typedef struct xcb_input_feedback_ctl_t {
uint8_t class_id;
uint8_t feedback_id;
uint16_t len;
} xcb_input_feedback_ctl_t;
void *
xcb_input_feedback_ctl_data (const xcb_input_feedback_ctl_t *R);
/**
* @brief xcb_input_feedback_ctl_iterator_t
**/
typedef struct xcb_input_feedback_ctl_iterator_t {
xcb_input_feedback_ctl_t *data;
int rem;
int index;
} xcb_input_feedback_ctl_iterator_t;
typedef enum xcb_input_change_feedback_control_mask_t {
XCB_INPUT_CHANGE_FEEDBACK_CONTROL_MASK_KEY_CLICK_PERCENT = 1,
XCB_INPUT_CHANGE_FEEDBACK_CONTROL_MASK_PERCENT = 2,
XCB_INPUT_CHANGE_FEEDBACK_CONTROL_MASK_PITCH = 4,
XCB_INPUT_CHANGE_FEEDBACK_CONTROL_MASK_DURATION = 8,
XCB_INPUT_CHANGE_FEEDBACK_CONTROL_MASK_LED = 16,
XCB_INPUT_CHANGE_FEEDBACK_CONTROL_MASK_LED_MODE = 32,
XCB_INPUT_CHANGE_FEEDBACK_CONTROL_MASK_KEY = 64,
XCB_INPUT_CHANGE_FEEDBACK_CONTROL_MASK_AUTO_REPEAT_MODE = 128,
XCB_INPUT_CHANGE_FEEDBACK_CONTROL_MASK_STRING = 1,
XCB_INPUT_CHANGE_FEEDBACK_CONTROL_MASK_INTEGER = 1,
XCB_INPUT_CHANGE_FEEDBACK_CONTROL_MASK_ACCEL_NUM = 1,
XCB_INPUT_CHANGE_FEEDBACK_CONTROL_MASK_ACCEL_DENOM = 2,
XCB_INPUT_CHANGE_FEEDBACK_CONTROL_MASK_THRESHOLD = 4
} xcb_input_change_feedback_control_mask_t;
/** Opcode for xcb_input_change_feedback_control. */
#define XCB_INPUT_CHANGE_FEEDBACK_CONTROL 23
/**
* @brief xcb_input_change_feedback_control_request_t
**/
typedef struct xcb_input_change_feedback_control_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t mask;
uint8_t device_id;
uint8_t feedback_id;
uint8_t pad0[2];
} xcb_input_change_feedback_control_request_t;
/**
* @brief xcb_input_get_device_key_mapping_cookie_t
**/
typedef struct xcb_input_get_device_key_mapping_cookie_t {
unsigned int sequence;
} xcb_input_get_device_key_mapping_cookie_t;
/** Opcode for xcb_input_get_device_key_mapping. */
#define XCB_INPUT_GET_DEVICE_KEY_MAPPING 24
/**
* @brief xcb_input_get_device_key_mapping_request_t
**/
typedef struct xcb_input_get_device_key_mapping_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t device_id;
xcb_input_key_code_t first_keycode;
uint8_t count;
uint8_t pad0;
} xcb_input_get_device_key_mapping_request_t;
/**
* @brief xcb_input_get_device_key_mapping_reply_t
**/
typedef struct xcb_input_get_device_key_mapping_reply_t {
uint8_t response_type;
uint8_t xi_reply_type;
uint16_t sequence;
uint32_t length;
uint8_t keysyms_per_keycode;
uint8_t pad0[23];
} xcb_input_get_device_key_mapping_reply_t;
/** Opcode for xcb_input_change_device_key_mapping. */
#define XCB_INPUT_CHANGE_DEVICE_KEY_MAPPING 25
/**
* @brief xcb_input_change_device_key_mapping_request_t
**/
typedef struct xcb_input_change_device_key_mapping_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t device_id;
xcb_input_key_code_t first_keycode;
uint8_t keysyms_per_keycode;
uint8_t keycode_count;
} xcb_input_change_device_key_mapping_request_t;
/**
* @brief xcb_input_get_device_modifier_mapping_cookie_t
**/
typedef struct xcb_input_get_device_modifier_mapping_cookie_t {
unsigned int sequence;
} xcb_input_get_device_modifier_mapping_cookie_t;
/** Opcode for xcb_input_get_device_modifier_mapping. */
#define XCB_INPUT_GET_DEVICE_MODIFIER_MAPPING 26
/**
* @brief xcb_input_get_device_modifier_mapping_request_t
**/
typedef struct xcb_input_get_device_modifier_mapping_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t device_id;
uint8_t pad0[3];
} xcb_input_get_device_modifier_mapping_request_t;
/**
* @brief xcb_input_get_device_modifier_mapping_reply_t
**/
typedef struct xcb_input_get_device_modifier_mapping_reply_t {
uint8_t response_type;
uint8_t xi_reply_type;
uint16_t sequence;
uint32_t length;
uint8_t keycodes_per_modifier;
uint8_t pad0[23];
} xcb_input_get_device_modifier_mapping_reply_t;
/**
* @brief xcb_input_set_device_modifier_mapping_cookie_t
**/
typedef struct xcb_input_set_device_modifier_mapping_cookie_t {
unsigned int sequence;
} xcb_input_set_device_modifier_mapping_cookie_t;
/** Opcode for xcb_input_set_device_modifier_mapping. */
#define XCB_INPUT_SET_DEVICE_MODIFIER_MAPPING 27
/**
* @brief xcb_input_set_device_modifier_mapping_request_t
**/
typedef struct xcb_input_set_device_modifier_mapping_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t device_id;
uint8_t keycodes_per_modifier;
uint8_t pad0[2];
} xcb_input_set_device_modifier_mapping_request_t;
/**
* @brief xcb_input_set_device_modifier_mapping_reply_t
**/
typedef struct xcb_input_set_device_modifier_mapping_reply_t {
uint8_t response_type;
uint8_t xi_reply_type;
uint16_t sequence;
uint32_t length;
uint8_t status;
uint8_t pad0[23];
} xcb_input_set_device_modifier_mapping_reply_t;
/**
* @brief xcb_input_get_device_button_mapping_cookie_t
**/
typedef struct xcb_input_get_device_button_mapping_cookie_t {
unsigned int sequence;
} xcb_input_get_device_button_mapping_cookie_t;
/** Opcode for xcb_input_get_device_button_mapping. */
#define XCB_INPUT_GET_DEVICE_BUTTON_MAPPING 28
/**
* @brief xcb_input_get_device_button_mapping_request_t
**/
typedef struct xcb_input_get_device_button_mapping_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t device_id;
uint8_t pad0[3];
} xcb_input_get_device_button_mapping_request_t;
/**
* @brief xcb_input_get_device_button_mapping_reply_t
**/
typedef struct xcb_input_get_device_button_mapping_reply_t {
uint8_t response_type;
uint8_t xi_reply_type;
uint16_t sequence;
uint32_t length;
uint8_t map_size;
uint8_t pad0[23];
} xcb_input_get_device_button_mapping_reply_t;
/**
* @brief xcb_input_set_device_button_mapping_cookie_t
**/
typedef struct xcb_input_set_device_button_mapping_cookie_t {
unsigned int sequence;
} xcb_input_set_device_button_mapping_cookie_t;
/** Opcode for xcb_input_set_device_button_mapping. */
#define XCB_INPUT_SET_DEVICE_BUTTON_MAPPING 29
/**
* @brief xcb_input_set_device_button_mapping_request_t
**/
typedef struct xcb_input_set_device_button_mapping_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t device_id;
uint8_t map_size;
uint8_t pad0[2];
} xcb_input_set_device_button_mapping_request_t;
/**
* @brief xcb_input_set_device_button_mapping_reply_t
**/
typedef struct xcb_input_set_device_button_mapping_reply_t {
uint8_t response_type;
uint8_t xi_reply_type;
uint16_t sequence;
uint32_t length;
uint8_t status;
uint8_t pad0[23];
} xcb_input_set_device_button_mapping_reply_t;
/**
* @brief xcb_input_key_state_t
**/
typedef struct xcb_input_key_state_t {
uint8_t class_id;
uint8_t len;
uint8_t num_keys;
uint8_t pad0;
uint8_t keys[32];
} xcb_input_key_state_t;
/**
* @brief xcb_input_key_state_iterator_t
**/
typedef struct xcb_input_key_state_iterator_t {
xcb_input_key_state_t *data;
int rem;
int index;
} xcb_input_key_state_iterator_t;
/**
* @brief xcb_input_button_state_t
**/
typedef struct xcb_input_button_state_t {
uint8_t class_id;
uint8_t len;
uint8_t num_buttons;
uint8_t pad0;
uint8_t buttons[32];
} xcb_input_button_state_t;
/**
* @brief xcb_input_button_state_iterator_t
**/
typedef struct xcb_input_button_state_iterator_t {
xcb_input_button_state_t *data;
int rem;
int index;
} xcb_input_button_state_iterator_t;
typedef enum xcb_input_valuator_state_mode_mask_t {
XCB_INPUT_VALUATOR_STATE_MODE_MASK_DEVICE_MODE_ABSOLUTE = 1,
XCB_INPUT_VALUATOR_STATE_MODE_MASK_OUT_OF_PROXIMITY = 2
} xcb_input_valuator_state_mode_mask_t;
/**
* @brief xcb_input_valuator_state_t
**/
typedef struct xcb_input_valuator_state_t {
uint8_t class_id;
uint8_t len;
uint8_t num_valuators;
uint8_t mode;
} xcb_input_valuator_state_t;
/**
* @brief xcb_input_valuator_state_iterator_t
**/
typedef struct xcb_input_valuator_state_iterator_t {
xcb_input_valuator_state_t *data;
int rem;
int index;
} xcb_input_valuator_state_iterator_t;
/**
* @brief xcb_input_input_state_data_t
**/
typedef struct xcb_input_input_state_data_t {
struct {
uint8_t num_keys;
uint8_t pad0;
uint8_t keys[32];
} key;
struct {
uint8_t num_buttons;
uint8_t pad1;
uint8_t buttons[32];
} button;
struct {
uint8_t num_valuators;
uint8_t mode;
int32_t *valuators;
} valuator;
} xcb_input_input_state_data_t;
/**
* @brief xcb_input_input_state_t
**/
typedef struct xcb_input_input_state_t {
uint8_t class_id;
uint8_t len;
} xcb_input_input_state_t;
void *
xcb_input_input_state_data (const xcb_input_input_state_t *R);
/**
* @brief xcb_input_input_state_iterator_t
**/
typedef struct xcb_input_input_state_iterator_t {
xcb_input_input_state_t *data;
int rem;
int index;
} xcb_input_input_state_iterator_t;
/**
* @brief xcb_input_query_device_state_cookie_t
**/
typedef struct xcb_input_query_device_state_cookie_t {
unsigned int sequence;
} xcb_input_query_device_state_cookie_t;
/** Opcode for xcb_input_query_device_state. */
#define XCB_INPUT_QUERY_DEVICE_STATE 30
/**
* @brief xcb_input_query_device_state_request_t
**/
typedef struct xcb_input_query_device_state_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t device_id;
uint8_t pad0[3];
} xcb_input_query_device_state_request_t;
/**
* @brief xcb_input_query_device_state_reply_t
**/
typedef struct xcb_input_query_device_state_reply_t {
uint8_t response_type;
uint8_t xi_reply_type;
uint16_t sequence;
uint32_t length;
uint8_t num_classes;
uint8_t pad0[23];
} xcb_input_query_device_state_reply_t;
/** Opcode for xcb_input_device_bell. */
#define XCB_INPUT_DEVICE_BELL 32
/**
* @brief xcb_input_device_bell_request_t
**/
typedef struct xcb_input_device_bell_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t device_id;
uint8_t feedback_id;
uint8_t feedback_class;
int8_t percent;
} xcb_input_device_bell_request_t;
/**
* @brief xcb_input_set_device_valuators_cookie_t
**/
typedef struct xcb_input_set_device_valuators_cookie_t {
unsigned int sequence;
} xcb_input_set_device_valuators_cookie_t;
/** Opcode for xcb_input_set_device_valuators. */
#define XCB_INPUT_SET_DEVICE_VALUATORS 33
/**
* @brief xcb_input_set_device_valuators_request_t
**/
typedef struct xcb_input_set_device_valuators_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t device_id;
uint8_t first_valuator;
uint8_t num_valuators;
uint8_t pad0;
} xcb_input_set_device_valuators_request_t;
/**
* @brief xcb_input_set_device_valuators_reply_t
**/
typedef struct xcb_input_set_device_valuators_reply_t {
uint8_t response_type;
uint8_t xi_reply_type;
uint16_t sequence;
uint32_t length;
uint8_t status;
uint8_t pad0[23];
} xcb_input_set_device_valuators_reply_t;
typedef enum xcb_input_device_control_t {
XCB_INPUT_DEVICE_CONTROL_RESOLUTION = 1,
XCB_INPUT_DEVICE_CONTROL_ABS_CALIB = 2,
XCB_INPUT_DEVICE_CONTROL_CORE = 3,
XCB_INPUT_DEVICE_CONTROL_ENABLE = 4,
XCB_INPUT_DEVICE_CONTROL_ABS_AREA = 5
} xcb_input_device_control_t;
/**
* @brief xcb_input_device_resolution_state_t
**/
typedef struct xcb_input_device_resolution_state_t {
uint16_t control_id;
uint16_t len;
uint32_t num_valuators;
} xcb_input_device_resolution_state_t;
/**
* @brief xcb_input_device_resolution_state_iterator_t
**/
typedef struct xcb_input_device_resolution_state_iterator_t {
xcb_input_device_resolution_state_t *data;
int rem;
int index;
} xcb_input_device_resolution_state_iterator_t;
/**
* @brief xcb_input_device_abs_calib_state_t
**/
typedef struct xcb_input_device_abs_calib_state_t {
uint16_t control_id;
uint16_t len;
int32_t min_x;
int32_t max_x;
int32_t min_y;
int32_t max_y;
uint32_t flip_x;
uint32_t flip_y;
uint32_t rotation;
uint32_t button_threshold;
} xcb_input_device_abs_calib_state_t;
/**
* @brief xcb_input_device_abs_calib_state_iterator_t
**/
typedef struct xcb_input_device_abs_calib_state_iterator_t {
xcb_input_device_abs_calib_state_t *data;
int rem;
int index;
} xcb_input_device_abs_calib_state_iterator_t;
/**
* @brief xcb_input_device_abs_area_state_t
**/
typedef struct xcb_input_device_abs_area_state_t {
uint16_t control_id;
uint16_t len;
uint32_t offset_x;
uint32_t offset_y;
uint32_t width;
uint32_t height;
uint32_t screen;
uint32_t following;
} xcb_input_device_abs_area_state_t;
/**
* @brief xcb_input_device_abs_area_state_iterator_t
**/
typedef struct xcb_input_device_abs_area_state_iterator_t {
xcb_input_device_abs_area_state_t *data;
int rem;
int index;
} xcb_input_device_abs_area_state_iterator_t;
/**
* @brief xcb_input_device_core_state_t
**/
typedef struct xcb_input_device_core_state_t {
uint16_t control_id;
uint16_t len;
uint8_t status;
uint8_t iscore;
uint8_t pad0[2];
} xcb_input_device_core_state_t;
/**
* @brief xcb_input_device_core_state_iterator_t
**/
typedef struct xcb_input_device_core_state_iterator_t {
xcb_input_device_core_state_t *data;
int rem;
int index;
} xcb_input_device_core_state_iterator_t;
/**
* @brief xcb_input_device_enable_state_t
**/
typedef struct xcb_input_device_enable_state_t {
uint16_t control_id;
uint16_t len;
uint8_t enable;
uint8_t pad0[3];
} xcb_input_device_enable_state_t;
/**
* @brief xcb_input_device_enable_state_iterator_t
**/
typedef struct xcb_input_device_enable_state_iterator_t {
xcb_input_device_enable_state_t *data;
int rem;
int index;
} xcb_input_device_enable_state_iterator_t;
/**
* @brief xcb_input_device_state_data_t
**/
typedef struct xcb_input_device_state_data_t {
struct {
uint32_t num_valuators;
uint32_t *resolution_values;
uint32_t *resolution_min;
uint32_t *resolution_max;
} resolution;
struct {
int32_t min_x;
int32_t max_x;
int32_t min_y;
int32_t max_y;
uint32_t flip_x;
uint32_t flip_y;
uint32_t rotation;
uint32_t button_threshold;
} abs_calib;
struct {
uint8_t status;
uint8_t iscore;
uint8_t pad0[2];
} core;
struct {
uint8_t enable;
uint8_t pad1[3];
} enable;
struct {
uint32_t offset_x;
uint32_t offset_y;
uint32_t width;
uint32_t height;
uint32_t screen;
uint32_t following;
} abs_area;
} xcb_input_device_state_data_t;
/**
* @brief xcb_input_device_state_t
**/
typedef struct xcb_input_device_state_t {
uint16_t control_id;
uint16_t len;
} xcb_input_device_state_t;
void *
xcb_input_device_state_data (const xcb_input_device_state_t *R);
/**
* @brief xcb_input_device_state_iterator_t
**/
typedef struct xcb_input_device_state_iterator_t {
xcb_input_device_state_t *data;
int rem;
int index;
} xcb_input_device_state_iterator_t;
/**
* @brief xcb_input_get_device_control_cookie_t
**/
typedef struct xcb_input_get_device_control_cookie_t {
unsigned int sequence;
} xcb_input_get_device_control_cookie_t;
/** Opcode for xcb_input_get_device_control. */
#define XCB_INPUT_GET_DEVICE_CONTROL 34
/**
* @brief xcb_input_get_device_control_request_t
**/
typedef struct xcb_input_get_device_control_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint16_t control_id;
uint8_t device_id;
uint8_t pad0;
} xcb_input_get_device_control_request_t;
/**
* @brief xcb_input_get_device_control_reply_t
**/
typedef struct xcb_input_get_device_control_reply_t {
uint8_t response_type;
uint8_t xi_reply_type;
uint16_t sequence;
uint32_t length;
uint8_t status;
uint8_t pad0[23];
} xcb_input_get_device_control_reply_t;
/**
* @brief xcb_input_device_resolution_ctl_t
**/
typedef struct xcb_input_device_resolution_ctl_t {
uint16_t control_id;
uint16_t len;
uint8_t first_valuator;
uint8_t num_valuators;
uint8_t pad0[2];
} xcb_input_device_resolution_ctl_t;
/**
* @brief xcb_input_device_resolution_ctl_iterator_t
**/
typedef struct xcb_input_device_resolution_ctl_iterator_t {
xcb_input_device_resolution_ctl_t *data;
int rem;
int index;
} xcb_input_device_resolution_ctl_iterator_t;
/**
* @brief xcb_input_device_abs_calib_ctl_t
**/
typedef struct xcb_input_device_abs_calib_ctl_t {
uint16_t control_id;
uint16_t len;
int32_t min_x;
int32_t max_x;
int32_t min_y;
int32_t max_y;
uint32_t flip_x;
uint32_t flip_y;
uint32_t rotation;
uint32_t button_threshold;
} xcb_input_device_abs_calib_ctl_t;
/**
* @brief xcb_input_device_abs_calib_ctl_iterator_t
**/
typedef struct xcb_input_device_abs_calib_ctl_iterator_t {
xcb_input_device_abs_calib_ctl_t *data;
int rem;
int index;
} xcb_input_device_abs_calib_ctl_iterator_t;
/**
* @brief xcb_input_device_abs_area_ctrl_t
**/
typedef struct xcb_input_device_abs_area_ctrl_t {
uint16_t control_id;
uint16_t len;
uint32_t offset_x;
uint32_t offset_y;
int32_t width;
int32_t height;
int32_t screen;
uint32_t following;
} xcb_input_device_abs_area_ctrl_t;
/**
* @brief xcb_input_device_abs_area_ctrl_iterator_t
**/
typedef struct xcb_input_device_abs_area_ctrl_iterator_t {
xcb_input_device_abs_area_ctrl_t *data;
int rem;
int index;
} xcb_input_device_abs_area_ctrl_iterator_t;
/**
* @brief xcb_input_device_core_ctrl_t
**/
typedef struct xcb_input_device_core_ctrl_t {
uint16_t control_id;
uint16_t len;
uint8_t status;
uint8_t pad0[3];
} xcb_input_device_core_ctrl_t;
/**
* @brief xcb_input_device_core_ctrl_iterator_t
**/
typedef struct xcb_input_device_core_ctrl_iterator_t {
xcb_input_device_core_ctrl_t *data;
int rem;
int index;
} xcb_input_device_core_ctrl_iterator_t;
/**
* @brief xcb_input_device_enable_ctrl_t
**/
typedef struct xcb_input_device_enable_ctrl_t {
uint16_t control_id;
uint16_t len;
uint8_t enable;
uint8_t pad0[3];
} xcb_input_device_enable_ctrl_t;
/**
* @brief xcb_input_device_enable_ctrl_iterator_t
**/
typedef struct xcb_input_device_enable_ctrl_iterator_t {
xcb_input_device_enable_ctrl_t *data;
int rem;
int index;
} xcb_input_device_enable_ctrl_iterator_t;
/**
* @brief xcb_input_device_ctl_data_t
**/
typedef struct xcb_input_device_ctl_data_t {
struct {
uint8_t first_valuator;
uint8_t num_valuators;
uint8_t pad0[2];
uint32_t *resolution_values;
} resolution;
struct {
int32_t min_x;
int32_t max_x;
int32_t min_y;
int32_t max_y;
uint32_t flip_x;
uint32_t flip_y;
uint32_t rotation;
uint32_t button_threshold;
} abs_calib;
struct {
uint8_t status;
uint8_t pad1[3];
} core;
struct {
uint8_t enable;
uint8_t pad2[3];
} enable;
struct {
uint32_t offset_x;
uint32_t offset_y;
int32_t width;
int32_t height;
int32_t screen;
uint32_t following;
} abs_area;
} xcb_input_device_ctl_data_t;
/**
* @brief xcb_input_device_ctl_t
**/
typedef struct xcb_input_device_ctl_t {
uint16_t control_id;
uint16_t len;
} xcb_input_device_ctl_t;
void *
xcb_input_device_ctl_data (const xcb_input_device_ctl_t *R);
/**
* @brief xcb_input_device_ctl_iterator_t
**/
typedef struct xcb_input_device_ctl_iterator_t {
xcb_input_device_ctl_t *data;
int rem;
int index;
} xcb_input_device_ctl_iterator_t;
/**
* @brief xcb_input_change_device_control_cookie_t
**/
typedef struct xcb_input_change_device_control_cookie_t {
unsigned int sequence;
} xcb_input_change_device_control_cookie_t;
/** Opcode for xcb_input_change_device_control. */
#define XCB_INPUT_CHANGE_DEVICE_CONTROL 35
/**
* @brief xcb_input_change_device_control_request_t
**/
typedef struct xcb_input_change_device_control_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint16_t control_id;
uint8_t device_id;
uint8_t pad0;
} xcb_input_change_device_control_request_t;
/**
* @brief xcb_input_change_device_control_reply_t
**/
typedef struct xcb_input_change_device_control_reply_t {
uint8_t response_type;
uint8_t xi_reply_type;
uint16_t sequence;
uint32_t length;
uint8_t status;
uint8_t pad0[23];
} xcb_input_change_device_control_reply_t;
/**
* @brief xcb_input_list_device_properties_cookie_t
**/
typedef struct xcb_input_list_device_properties_cookie_t {
unsigned int sequence;
} xcb_input_list_device_properties_cookie_t;
/** Opcode for xcb_input_list_device_properties. */
#define XCB_INPUT_LIST_DEVICE_PROPERTIES 36
/**
* @brief xcb_input_list_device_properties_request_t
**/
typedef struct xcb_input_list_device_properties_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t device_id;
uint8_t pad0[3];
} xcb_input_list_device_properties_request_t;
/**
* @brief xcb_input_list_device_properties_reply_t
**/
typedef struct xcb_input_list_device_properties_reply_t {
uint8_t response_type;
uint8_t xi_reply_type;
uint16_t sequence;
uint32_t length;
uint16_t num_atoms;
uint8_t pad0[22];
} xcb_input_list_device_properties_reply_t;
typedef enum xcb_input_property_format_t {
XCB_INPUT_PROPERTY_FORMAT_8_BITS = 8,
XCB_INPUT_PROPERTY_FORMAT_16_BITS = 16,
XCB_INPUT_PROPERTY_FORMAT_32_BITS = 32
} xcb_input_property_format_t;
/**
* @brief xcb_input_change_device_property_items_t
**/
typedef struct xcb_input_change_device_property_items_t {
uint8_t *data8;
uint16_t *data16;
uint32_t *data32;
} xcb_input_change_device_property_items_t;
/** Opcode for xcb_input_change_device_property. */
#define XCB_INPUT_CHANGE_DEVICE_PROPERTY 37
/**
* @brief xcb_input_change_device_property_request_t
**/
typedef struct xcb_input_change_device_property_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_atom_t property;
xcb_atom_t type;
uint8_t device_id;
uint8_t format;
uint8_t mode;
uint8_t pad0;
uint32_t num_items;
} xcb_input_change_device_property_request_t;
/** Opcode for xcb_input_delete_device_property. */
#define XCB_INPUT_DELETE_DEVICE_PROPERTY 38
/**
* @brief xcb_input_delete_device_property_request_t
**/
typedef struct xcb_input_delete_device_property_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_atom_t property;
uint8_t device_id;
uint8_t pad0[3];
} xcb_input_delete_device_property_request_t;
/**
* @brief xcb_input_get_device_property_cookie_t
**/
typedef struct xcb_input_get_device_property_cookie_t {
unsigned int sequence;
} xcb_input_get_device_property_cookie_t;
/** Opcode for xcb_input_get_device_property. */
#define XCB_INPUT_GET_DEVICE_PROPERTY 39
/**
* @brief xcb_input_get_device_property_request_t
**/
typedef struct xcb_input_get_device_property_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_atom_t property;
xcb_atom_t type;
uint32_t offset;
uint32_t len;
uint8_t device_id;
uint8_t _delete;
uint8_t pad0[2];
} xcb_input_get_device_property_request_t;
/**
* @brief xcb_input_get_device_property_items_t
**/
typedef struct xcb_input_get_device_property_items_t {
uint8_t *data8;
uint16_t *data16;
uint32_t *data32;
} xcb_input_get_device_property_items_t;
/**
* @brief xcb_input_get_device_property_reply_t
**/
typedef struct xcb_input_get_device_property_reply_t {
uint8_t response_type;
uint8_t xi_reply_type;
uint16_t sequence;
uint32_t length;
xcb_atom_t type;
uint32_t bytes_after;
uint32_t num_items;
uint8_t format;
uint8_t device_id;
uint8_t pad0[10];
} xcb_input_get_device_property_reply_t;
typedef enum xcb_input_device_t {
XCB_INPUT_DEVICE_ALL = 0,
XCB_INPUT_DEVICE_ALL_MASTER = 1
} xcb_input_device_t;
/**
* @brief xcb_input_group_info_t
**/
typedef struct xcb_input_group_info_t {
uint8_t base;
uint8_t latched;
uint8_t locked;
uint8_t effective;
} xcb_input_group_info_t;
/**
* @brief xcb_input_group_info_iterator_t
**/
typedef struct xcb_input_group_info_iterator_t {
xcb_input_group_info_t *data;
int rem;
int index;
} xcb_input_group_info_iterator_t;
/**
* @brief xcb_input_modifier_info_t
**/
typedef struct xcb_input_modifier_info_t {
uint32_t base;
uint32_t latched;
uint32_t locked;
uint32_t effective;
} xcb_input_modifier_info_t;
/**
* @brief xcb_input_modifier_info_iterator_t
**/
typedef struct xcb_input_modifier_info_iterator_t {
xcb_input_modifier_info_t *data;
int rem;
int index;
} xcb_input_modifier_info_iterator_t;
/**
* @brief xcb_input_xi_query_pointer_cookie_t
**/
typedef struct xcb_input_xi_query_pointer_cookie_t {
unsigned int sequence;
} xcb_input_xi_query_pointer_cookie_t;
/** Opcode for xcb_input_xi_query_pointer. */
#define XCB_INPUT_XI_QUERY_POINTER 40
/**
* @brief xcb_input_xi_query_pointer_request_t
**/
typedef struct xcb_input_xi_query_pointer_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
xcb_input_device_id_t deviceid;
uint8_t pad0[2];
} xcb_input_xi_query_pointer_request_t;
/**
* @brief xcb_input_xi_query_pointer_reply_t
**/
typedef struct xcb_input_xi_query_pointer_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
xcb_window_t root;
xcb_window_t child;
xcb_input_fp1616_t root_x;
xcb_input_fp1616_t root_y;
xcb_input_fp1616_t win_x;
xcb_input_fp1616_t win_y;
uint8_t same_screen;
uint8_t pad1;
uint16_t buttons_len;
xcb_input_modifier_info_t mods;
xcb_input_group_info_t group;
} xcb_input_xi_query_pointer_reply_t;
/** Opcode for xcb_input_xi_warp_pointer. */
#define XCB_INPUT_XI_WARP_POINTER 41
/**
* @brief xcb_input_xi_warp_pointer_request_t
**/
typedef struct xcb_input_xi_warp_pointer_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t src_win;
xcb_window_t dst_win;
xcb_input_fp1616_t src_x;
xcb_input_fp1616_t src_y;
uint16_t src_width;
uint16_t src_height;
xcb_input_fp1616_t dst_x;
xcb_input_fp1616_t dst_y;
xcb_input_device_id_t deviceid;
uint8_t pad0[2];
} xcb_input_xi_warp_pointer_request_t;
/** Opcode for xcb_input_xi_change_cursor. */
#define XCB_INPUT_XI_CHANGE_CURSOR 42
/**
* @brief xcb_input_xi_change_cursor_request_t
**/
typedef struct xcb_input_xi_change_cursor_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
xcb_cursor_t cursor;
xcb_input_device_id_t deviceid;
uint8_t pad0[2];
} xcb_input_xi_change_cursor_request_t;
typedef enum xcb_input_hierarchy_change_type_t {
XCB_INPUT_HIERARCHY_CHANGE_TYPE_ADD_MASTER = 1,
XCB_INPUT_HIERARCHY_CHANGE_TYPE_REMOVE_MASTER = 2,
XCB_INPUT_HIERARCHY_CHANGE_TYPE_ATTACH_SLAVE = 3,
XCB_INPUT_HIERARCHY_CHANGE_TYPE_DETACH_SLAVE = 4
} xcb_input_hierarchy_change_type_t;
typedef enum xcb_input_change_mode_t {
XCB_INPUT_CHANGE_MODE_ATTACH = 1,
XCB_INPUT_CHANGE_MODE_FLOAT = 2
} xcb_input_change_mode_t;
/**
* @brief xcb_input_add_master_t
**/
typedef struct xcb_input_add_master_t {
uint16_t type;
uint16_t len;
uint16_t name_len;
uint8_t send_core;
uint8_t enable;
} xcb_input_add_master_t;
/**
* @brief xcb_input_add_master_iterator_t
**/
typedef struct xcb_input_add_master_iterator_t {
xcb_input_add_master_t *data;
int rem;
int index;
} xcb_input_add_master_iterator_t;
/**
* @brief xcb_input_remove_master_t
**/
typedef struct xcb_input_remove_master_t {
uint16_t type;
uint16_t len;
xcb_input_device_id_t deviceid;
uint8_t return_mode;
uint8_t pad0;
xcb_input_device_id_t return_pointer;
xcb_input_device_id_t return_keyboard;
} xcb_input_remove_master_t;
/**
* @brief xcb_input_remove_master_iterator_t
**/
typedef struct xcb_input_remove_master_iterator_t {
xcb_input_remove_master_t *data;
int rem;
int index;
} xcb_input_remove_master_iterator_t;
/**
* @brief xcb_input_attach_slave_t
**/
typedef struct xcb_input_attach_slave_t {
uint16_t type;
uint16_t len;
xcb_input_device_id_t deviceid;
xcb_input_device_id_t master;
} xcb_input_attach_slave_t;
/**
* @brief xcb_input_attach_slave_iterator_t
**/
typedef struct xcb_input_attach_slave_iterator_t {
xcb_input_attach_slave_t *data;
int rem;
int index;
} xcb_input_attach_slave_iterator_t;
/**
* @brief xcb_input_detach_slave_t
**/
typedef struct xcb_input_detach_slave_t {
uint16_t type;
uint16_t len;
xcb_input_device_id_t deviceid;
uint8_t pad0[2];
} xcb_input_detach_slave_t;
/**
* @brief xcb_input_detach_slave_iterator_t
**/
typedef struct xcb_input_detach_slave_iterator_t {
xcb_input_detach_slave_t *data;
int rem;
int index;
} xcb_input_detach_slave_iterator_t;
/**
* @brief xcb_input_hierarchy_change_data_t
**/
typedef struct xcb_input_hierarchy_change_data_t {
struct {
uint16_t name_len;
uint8_t send_core;
uint8_t enable;
char *name;
} add_master;
struct {
xcb_input_device_id_t deviceid;
uint8_t return_mode;
uint8_t pad1;
xcb_input_device_id_t return_pointer;
xcb_input_device_id_t return_keyboard;
} remove_master;
struct {
xcb_input_device_id_t deviceid;
xcb_input_device_id_t master;
} attach_slave;
struct {
xcb_input_device_id_t deviceid;
uint8_t pad2[2];
} detach_slave;
} xcb_input_hierarchy_change_data_t;
/**
* @brief xcb_input_hierarchy_change_t
**/
typedef struct xcb_input_hierarchy_change_t {
uint16_t type;
uint16_t len;
} xcb_input_hierarchy_change_t;
void *
xcb_input_hierarchy_change_data (const xcb_input_hierarchy_change_t *R);
/**
* @brief xcb_input_hierarchy_change_iterator_t
**/
typedef struct xcb_input_hierarchy_change_iterator_t {
xcb_input_hierarchy_change_t *data;
int rem;
int index;
} xcb_input_hierarchy_change_iterator_t;
/** Opcode for xcb_input_xi_change_hierarchy. */
#define XCB_INPUT_XI_CHANGE_HIERARCHY 43
/**
* @brief xcb_input_xi_change_hierarchy_request_t
**/
typedef struct xcb_input_xi_change_hierarchy_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t num_changes;
uint8_t pad0[3];
} xcb_input_xi_change_hierarchy_request_t;
/** Opcode for xcb_input_xi_set_client_pointer. */
#define XCB_INPUT_XI_SET_CLIENT_POINTER 44
/**
* @brief xcb_input_xi_set_client_pointer_request_t
**/
typedef struct xcb_input_xi_set_client_pointer_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
xcb_input_device_id_t deviceid;
uint8_t pad0[2];
} xcb_input_xi_set_client_pointer_request_t;
/**
* @brief xcb_input_xi_get_client_pointer_cookie_t
**/
typedef struct xcb_input_xi_get_client_pointer_cookie_t {
unsigned int sequence;
} xcb_input_xi_get_client_pointer_cookie_t;
/** Opcode for xcb_input_xi_get_client_pointer. */
#define XCB_INPUT_XI_GET_CLIENT_POINTER 45
/**
* @brief xcb_input_xi_get_client_pointer_request_t
**/
typedef struct xcb_input_xi_get_client_pointer_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
} xcb_input_xi_get_client_pointer_request_t;
/**
* @brief xcb_input_xi_get_client_pointer_reply_t
**/
typedef struct xcb_input_xi_get_client_pointer_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t set;
uint8_t pad1;
xcb_input_device_id_t deviceid;
uint8_t pad2[20];
} xcb_input_xi_get_client_pointer_reply_t;
typedef enum xcb_input_xi_event_mask_t {
XCB_INPUT_XI_EVENT_MASK_DEVICE_CHANGED = 2,
XCB_INPUT_XI_EVENT_MASK_KEY_PRESS = 4,
XCB_INPUT_XI_EVENT_MASK_KEY_RELEASE = 8,
XCB_INPUT_XI_EVENT_MASK_BUTTON_PRESS = 16,
XCB_INPUT_XI_EVENT_MASK_BUTTON_RELEASE = 32,
XCB_INPUT_XI_EVENT_MASK_MOTION = 64,
XCB_INPUT_XI_EVENT_MASK_ENTER = 128,
XCB_INPUT_XI_EVENT_MASK_LEAVE = 256,
XCB_INPUT_XI_EVENT_MASK_FOCUS_IN = 512,
XCB_INPUT_XI_EVENT_MASK_FOCUS_OUT = 1024,
XCB_INPUT_XI_EVENT_MASK_HIERARCHY = 2048,
XCB_INPUT_XI_EVENT_MASK_PROPERTY = 4096,
XCB_INPUT_XI_EVENT_MASK_RAW_KEY_PRESS = 8192,
XCB_INPUT_XI_EVENT_MASK_RAW_KEY_RELEASE = 16384,
XCB_INPUT_XI_EVENT_MASK_RAW_BUTTON_PRESS = 32768,
XCB_INPUT_XI_EVENT_MASK_RAW_BUTTON_RELEASE = 65536,
XCB_INPUT_XI_EVENT_MASK_RAW_MOTION = 131072,
XCB_INPUT_XI_EVENT_MASK_TOUCH_BEGIN = 262144,
XCB_INPUT_XI_EVENT_MASK_TOUCH_UPDATE = 524288,
XCB_INPUT_XI_EVENT_MASK_TOUCH_END = 1048576,
XCB_INPUT_XI_EVENT_MASK_TOUCH_OWNERSHIP = 2097152,
XCB_INPUT_XI_EVENT_MASK_RAW_TOUCH_BEGIN = 4194304,
XCB_INPUT_XI_EVENT_MASK_RAW_TOUCH_UPDATE = 8388608,
XCB_INPUT_XI_EVENT_MASK_RAW_TOUCH_END = 16777216,
XCB_INPUT_XI_EVENT_MASK_BARRIER_HIT = 33554432,
XCB_INPUT_XI_EVENT_MASK_BARRIER_LEAVE = 67108864
} xcb_input_xi_event_mask_t;
/**
* @brief xcb_input_event_mask_t
**/
typedef struct xcb_input_event_mask_t {
xcb_input_device_id_t deviceid;
uint16_t mask_len;
} xcb_input_event_mask_t;
/**
* @brief xcb_input_event_mask_iterator_t
**/
typedef struct xcb_input_event_mask_iterator_t {
xcb_input_event_mask_t *data;
int rem;
int index;
} xcb_input_event_mask_iterator_t;
/** Opcode for xcb_input_xi_select_events. */
#define XCB_INPUT_XI_SELECT_EVENTS 46
/**
* @brief xcb_input_xi_select_events_request_t
**/
typedef struct xcb_input_xi_select_events_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
uint16_t num_mask;
uint8_t pad0[2];
} xcb_input_xi_select_events_request_t;
/**
* @brief xcb_input_xi_query_version_cookie_t
**/
typedef struct xcb_input_xi_query_version_cookie_t {
unsigned int sequence;
} xcb_input_xi_query_version_cookie_t;
/** Opcode for xcb_input_xi_query_version. */
#define XCB_INPUT_XI_QUERY_VERSION 47
/**
* @brief xcb_input_xi_query_version_request_t
**/
typedef struct xcb_input_xi_query_version_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint16_t major_version;
uint16_t minor_version;
} xcb_input_xi_query_version_request_t;
/**
* @brief xcb_input_xi_query_version_reply_t
**/
typedef struct xcb_input_xi_query_version_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t major_version;
uint16_t minor_version;
uint8_t pad1[20];
} xcb_input_xi_query_version_reply_t;
typedef enum xcb_input_device_class_type_t {
XCB_INPUT_DEVICE_CLASS_TYPE_KEY = 0,
XCB_INPUT_DEVICE_CLASS_TYPE_BUTTON = 1,
XCB_INPUT_DEVICE_CLASS_TYPE_VALUATOR = 2,
XCB_INPUT_DEVICE_CLASS_TYPE_SCROLL = 3,
XCB_INPUT_DEVICE_CLASS_TYPE_TOUCH = 8
} xcb_input_device_class_type_t;
typedef enum xcb_input_device_type_t {
XCB_INPUT_DEVICE_TYPE_MASTER_POINTER = 1,
XCB_INPUT_DEVICE_TYPE_MASTER_KEYBOARD = 2,
XCB_INPUT_DEVICE_TYPE_SLAVE_POINTER = 3,
XCB_INPUT_DEVICE_TYPE_SLAVE_KEYBOARD = 4,
XCB_INPUT_DEVICE_TYPE_FLOATING_SLAVE = 5
} xcb_input_device_type_t;
typedef enum xcb_input_scroll_flags_t {
XCB_INPUT_SCROLL_FLAGS_NO_EMULATION = 1,
XCB_INPUT_SCROLL_FLAGS_PREFERRED = 2
} xcb_input_scroll_flags_t;
typedef enum xcb_input_scroll_type_t {
XCB_INPUT_SCROLL_TYPE_VERTICAL = 1,
XCB_INPUT_SCROLL_TYPE_HORIZONTAL = 2
} xcb_input_scroll_type_t;
typedef enum xcb_input_touch_mode_t {
XCB_INPUT_TOUCH_MODE_DIRECT = 1,
XCB_INPUT_TOUCH_MODE_DEPENDENT = 2
} xcb_input_touch_mode_t;
/**
* @brief xcb_input_button_class_t
**/
typedef struct xcb_input_button_class_t {
uint16_t type;
uint16_t len;
xcb_input_device_id_t sourceid;
uint16_t num_buttons;
} xcb_input_button_class_t;
/**
* @brief xcb_input_button_class_iterator_t
**/
typedef struct xcb_input_button_class_iterator_t {
xcb_input_button_class_t *data;
int rem;
int index;
} xcb_input_button_class_iterator_t;
/**
* @brief xcb_input_key_class_t
**/
typedef struct xcb_input_key_class_t {
uint16_t type;
uint16_t len;
xcb_input_device_id_t sourceid;
uint16_t num_keys;
} xcb_input_key_class_t;
/**
* @brief xcb_input_key_class_iterator_t
**/
typedef struct xcb_input_key_class_iterator_t {
xcb_input_key_class_t *data;
int rem;
int index;
} xcb_input_key_class_iterator_t;
/**
* @brief xcb_input_scroll_class_t
**/
typedef struct xcb_input_scroll_class_t {
uint16_t type;
uint16_t len;
xcb_input_device_id_t sourceid;
uint16_t number;
uint16_t scroll_type;
uint8_t pad0[2];
uint32_t flags;
xcb_input_fp3232_t increment;
} xcb_input_scroll_class_t;
/**
* @brief xcb_input_scroll_class_iterator_t
**/
typedef struct xcb_input_scroll_class_iterator_t {
xcb_input_scroll_class_t *data;
int rem;
int index;
} xcb_input_scroll_class_iterator_t;
/**
* @brief xcb_input_touch_class_t
**/
typedef struct xcb_input_touch_class_t {
uint16_t type;
uint16_t len;
xcb_input_device_id_t sourceid;
uint8_t mode;
uint8_t num_touches;
} xcb_input_touch_class_t;
/**
* @brief xcb_input_touch_class_iterator_t
**/
typedef struct xcb_input_touch_class_iterator_t {
xcb_input_touch_class_t *data;
int rem;
int index;
} xcb_input_touch_class_iterator_t;
/**
* @brief xcb_input_valuator_class_t
**/
typedef struct xcb_input_valuator_class_t {
uint16_t type;
uint16_t len;
xcb_input_device_id_t sourceid;
uint16_t number;
xcb_atom_t label;
xcb_input_fp3232_t min;
xcb_input_fp3232_t max;
xcb_input_fp3232_t value;
uint32_t resolution;
uint8_t mode;
uint8_t pad0[3];
} xcb_input_valuator_class_t;
/**
* @brief xcb_input_valuator_class_iterator_t
**/
typedef struct xcb_input_valuator_class_iterator_t {
xcb_input_valuator_class_t *data;
int rem;
int index;
} xcb_input_valuator_class_iterator_t;
/**
* @brief xcb_input_device_class_data_t
**/
typedef struct xcb_input_device_class_data_t {
struct {
uint16_t num_keys;
uint32_t *keys;
} key;
struct {
uint16_t num_buttons;
uint32_t *state;
xcb_atom_t *labels;
} button;
struct {
uint16_t number;
xcb_atom_t label;
xcb_input_fp3232_t min;
xcb_input_fp3232_t max;
xcb_input_fp3232_t value;
uint32_t resolution;
uint8_t mode;
uint8_t pad0[3];
} valuator;
struct {
uint16_t number;
uint16_t scroll_type;
uint8_t pad1[2];
uint32_t flags;
xcb_input_fp3232_t increment;
} scroll;
struct {
uint8_t mode;
uint8_t num_touches;
} touch;
} xcb_input_device_class_data_t;
/**
* @brief xcb_input_device_class_t
**/
typedef struct xcb_input_device_class_t {
uint16_t type;
uint16_t len;
xcb_input_device_id_t sourceid;
} xcb_input_device_class_t;
void *
xcb_input_device_class_data (const xcb_input_device_class_t *R);
/**
* @brief xcb_input_device_class_iterator_t
**/
typedef struct xcb_input_device_class_iterator_t {
xcb_input_device_class_t *data;
int rem;
int index;
} xcb_input_device_class_iterator_t;
/**
* @brief xcb_input_xi_device_info_t
**/
typedef struct xcb_input_xi_device_info_t {
xcb_input_device_id_t deviceid;
uint16_t type;
xcb_input_device_id_t attachment;
uint16_t num_classes;
uint16_t name_len;
uint8_t enabled;
uint8_t pad0;
} xcb_input_xi_device_info_t;
/**
* @brief xcb_input_xi_device_info_iterator_t
**/
typedef struct xcb_input_xi_device_info_iterator_t {
xcb_input_xi_device_info_t *data;
int rem;
int index;
} xcb_input_xi_device_info_iterator_t;
/**
* @brief xcb_input_xi_query_device_cookie_t
**/
typedef struct xcb_input_xi_query_device_cookie_t {
unsigned int sequence;
} xcb_input_xi_query_device_cookie_t;
/** Opcode for xcb_input_xi_query_device. */
#define XCB_INPUT_XI_QUERY_DEVICE 48
/**
* @brief xcb_input_xi_query_device_request_t
**/
typedef struct xcb_input_xi_query_device_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_input_device_id_t deviceid;
uint8_t pad0[2];
} xcb_input_xi_query_device_request_t;
/**
* @brief xcb_input_xi_query_device_reply_t
**/
typedef struct xcb_input_xi_query_device_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t num_infos;
uint8_t pad1[22];
} xcb_input_xi_query_device_reply_t;
/** Opcode for xcb_input_xi_set_focus. */
#define XCB_INPUT_XI_SET_FOCUS 49
/**
* @brief xcb_input_xi_set_focus_request_t
**/
typedef struct xcb_input_xi_set_focus_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
xcb_timestamp_t time;
xcb_input_device_id_t deviceid;
uint8_t pad0[2];
} xcb_input_xi_set_focus_request_t;
/**
* @brief xcb_input_xi_get_focus_cookie_t
**/
typedef struct xcb_input_xi_get_focus_cookie_t {
unsigned int sequence;
} xcb_input_xi_get_focus_cookie_t;
/** Opcode for xcb_input_xi_get_focus. */
#define XCB_INPUT_XI_GET_FOCUS 50
/**
* @brief xcb_input_xi_get_focus_request_t
**/
typedef struct xcb_input_xi_get_focus_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_input_device_id_t deviceid;
uint8_t pad0[2];
} xcb_input_xi_get_focus_request_t;
/**
* @brief xcb_input_xi_get_focus_reply_t
**/
typedef struct xcb_input_xi_get_focus_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
xcb_window_t focus;
uint8_t pad1[20];
} xcb_input_xi_get_focus_reply_t;
typedef enum xcb_input_grab_owner_t {
XCB_INPUT_GRAB_OWNER_NO_OWNER = 0,
XCB_INPUT_GRAB_OWNER_OWNER = 1
} xcb_input_grab_owner_t;
/**
* @brief xcb_input_xi_grab_device_cookie_t
**/
typedef struct xcb_input_xi_grab_device_cookie_t {
unsigned int sequence;
} xcb_input_xi_grab_device_cookie_t;
/** Opcode for xcb_input_xi_grab_device. */
#define XCB_INPUT_XI_GRAB_DEVICE 51
/**
* @brief xcb_input_xi_grab_device_request_t
**/
typedef struct xcb_input_xi_grab_device_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
xcb_timestamp_t time;
xcb_cursor_t cursor;
xcb_input_device_id_t deviceid;
uint8_t mode;
uint8_t paired_device_mode;
uint8_t owner_events;
uint8_t pad0;
uint16_t mask_len;
} xcb_input_xi_grab_device_request_t;
/**
* @brief xcb_input_xi_grab_device_reply_t
**/
typedef struct xcb_input_xi_grab_device_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t status;
uint8_t pad1[23];
} xcb_input_xi_grab_device_reply_t;
/** Opcode for xcb_input_xi_ungrab_device. */
#define XCB_INPUT_XI_UNGRAB_DEVICE 52
/**
* @brief xcb_input_xi_ungrab_device_request_t
**/
typedef struct xcb_input_xi_ungrab_device_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_timestamp_t time;
xcb_input_device_id_t deviceid;
uint8_t pad0[2];
} xcb_input_xi_ungrab_device_request_t;
typedef enum xcb_input_event_mode_t {
XCB_INPUT_EVENT_MODE_ASYNC_DEVICE = 0,
XCB_INPUT_EVENT_MODE_SYNC_DEVICE = 1,
XCB_INPUT_EVENT_MODE_REPLAY_DEVICE = 2,
XCB_INPUT_EVENT_MODE_ASYNC_PAIRED_DEVICE = 3,
XCB_INPUT_EVENT_MODE_ASYNC_PAIR = 4,
XCB_INPUT_EVENT_MODE_SYNC_PAIR = 5,
XCB_INPUT_EVENT_MODE_ACCEPT_TOUCH = 6,
XCB_INPUT_EVENT_MODE_REJECT_TOUCH = 7
} xcb_input_event_mode_t;
/** Opcode for xcb_input_xi_allow_events. */
#define XCB_INPUT_XI_ALLOW_EVENTS 53
/**
* @brief xcb_input_xi_allow_events_request_t
**/
typedef struct xcb_input_xi_allow_events_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_timestamp_t time;
xcb_input_device_id_t deviceid;
uint8_t event_mode;
uint8_t pad0;
uint32_t touchid;
xcb_window_t grab_window;
} xcb_input_xi_allow_events_request_t;
typedef enum xcb_input_grab_mode_22_t {
XCB_INPUT_GRAB_MODE_22_SYNC = 0,
XCB_INPUT_GRAB_MODE_22_ASYNC = 1,
XCB_INPUT_GRAB_MODE_22_TOUCH = 2
} xcb_input_grab_mode_22_t;
typedef enum xcb_input_grab_type_t {
XCB_INPUT_GRAB_TYPE_BUTTON = 0,
XCB_INPUT_GRAB_TYPE_KEYCODE = 1,
XCB_INPUT_GRAB_TYPE_ENTER = 2,
XCB_INPUT_GRAB_TYPE_FOCUS_IN = 3,
XCB_INPUT_GRAB_TYPE_TOUCH_BEGIN = 4
} xcb_input_grab_type_t;
typedef enum xcb_input_modifier_mask_t {
XCB_INPUT_MODIFIER_MASK_ANY = 2147483648
} xcb_input_modifier_mask_t;
/**
* @brief xcb_input_grab_modifier_info_t
**/
typedef struct xcb_input_grab_modifier_info_t {
uint32_t modifiers;
uint8_t status;
uint8_t pad0[3];
} xcb_input_grab_modifier_info_t;
/**
* @brief xcb_input_grab_modifier_info_iterator_t
**/
typedef struct xcb_input_grab_modifier_info_iterator_t {
xcb_input_grab_modifier_info_t *data;
int rem;
int index;
} xcb_input_grab_modifier_info_iterator_t;
/**
* @brief xcb_input_xi_passive_grab_device_cookie_t
**/
typedef struct xcb_input_xi_passive_grab_device_cookie_t {
unsigned int sequence;
} xcb_input_xi_passive_grab_device_cookie_t;
/** Opcode for xcb_input_xi_passive_grab_device. */
#define XCB_INPUT_XI_PASSIVE_GRAB_DEVICE 54
/**
* @brief xcb_input_xi_passive_grab_device_request_t
**/
typedef struct xcb_input_xi_passive_grab_device_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_timestamp_t time;
xcb_window_t grab_window;
xcb_cursor_t cursor;
uint32_t detail;
xcb_input_device_id_t deviceid;
uint16_t num_modifiers;
uint16_t mask_len;
uint8_t grab_type;
uint8_t grab_mode;
uint8_t paired_device_mode;
uint8_t owner_events;
uint8_t pad0[2];
} xcb_input_xi_passive_grab_device_request_t;
/**
* @brief xcb_input_xi_passive_grab_device_reply_t
**/
typedef struct xcb_input_xi_passive_grab_device_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t num_modifiers;
uint8_t pad1[22];
} xcb_input_xi_passive_grab_device_reply_t;
/** Opcode for xcb_input_xi_passive_ungrab_device. */
#define XCB_INPUT_XI_PASSIVE_UNGRAB_DEVICE 55
/**
* @brief xcb_input_xi_passive_ungrab_device_request_t
**/
typedef struct xcb_input_xi_passive_ungrab_device_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t grab_window;
uint32_t detail;
xcb_input_device_id_t deviceid;
uint16_t num_modifiers;
uint8_t grab_type;
uint8_t pad0[3];
} xcb_input_xi_passive_ungrab_device_request_t;
/**
* @brief xcb_input_xi_list_properties_cookie_t
**/
typedef struct xcb_input_xi_list_properties_cookie_t {
unsigned int sequence;
} xcb_input_xi_list_properties_cookie_t;
/** Opcode for xcb_input_xi_list_properties. */
#define XCB_INPUT_XI_LIST_PROPERTIES 56
/**
* @brief xcb_input_xi_list_properties_request_t
**/
typedef struct xcb_input_xi_list_properties_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_input_device_id_t deviceid;
uint8_t pad0[2];
} xcb_input_xi_list_properties_request_t;
/**
* @brief xcb_input_xi_list_properties_reply_t
**/
typedef struct xcb_input_xi_list_properties_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t num_properties;
uint8_t pad1[22];
} xcb_input_xi_list_properties_reply_t;
/**
* @brief xcb_input_xi_change_property_items_t
**/
typedef struct xcb_input_xi_change_property_items_t {
uint8_t *data8;
uint16_t *data16;
uint32_t *data32;
} xcb_input_xi_change_property_items_t;
/** Opcode for xcb_input_xi_change_property. */
#define XCB_INPUT_XI_CHANGE_PROPERTY 57
/**
* @brief xcb_input_xi_change_property_request_t
**/
typedef struct xcb_input_xi_change_property_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_input_device_id_t deviceid;
uint8_t mode;
uint8_t format;
xcb_atom_t property;
xcb_atom_t type;
uint32_t num_items;
} xcb_input_xi_change_property_request_t;
/** Opcode for xcb_input_xi_delete_property. */
#define XCB_INPUT_XI_DELETE_PROPERTY 58
/**
* @brief xcb_input_xi_delete_property_request_t
**/
typedef struct xcb_input_xi_delete_property_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_input_device_id_t deviceid;
uint8_t pad0[2];
xcb_atom_t property;
} xcb_input_xi_delete_property_request_t;
/**
* @brief xcb_input_xi_get_property_cookie_t
**/
typedef struct xcb_input_xi_get_property_cookie_t {
unsigned int sequence;
} xcb_input_xi_get_property_cookie_t;
/** Opcode for xcb_input_xi_get_property. */
#define XCB_INPUT_XI_GET_PROPERTY 59
/**
* @brief xcb_input_xi_get_property_request_t
**/
typedef struct xcb_input_xi_get_property_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_input_device_id_t deviceid;
uint8_t _delete;
uint8_t pad0;
xcb_atom_t property;
xcb_atom_t type;
uint32_t offset;
uint32_t len;
} xcb_input_xi_get_property_request_t;
/**
* @brief xcb_input_xi_get_property_items_t
**/
typedef struct xcb_input_xi_get_property_items_t {
uint8_t *data8;
uint16_t *data16;
uint32_t *data32;
} xcb_input_xi_get_property_items_t;
/**
* @brief xcb_input_xi_get_property_reply_t
**/
typedef struct xcb_input_xi_get_property_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
xcb_atom_t type;
uint32_t bytes_after;
uint32_t num_items;
uint8_t format;
uint8_t pad1[11];
} xcb_input_xi_get_property_reply_t;
/**
* @brief xcb_input_xi_get_selected_events_cookie_t
**/
typedef struct xcb_input_xi_get_selected_events_cookie_t {
unsigned int sequence;
} xcb_input_xi_get_selected_events_cookie_t;
/** Opcode for xcb_input_xi_get_selected_events. */
#define XCB_INPUT_XI_GET_SELECTED_EVENTS 60
/**
* @brief xcb_input_xi_get_selected_events_request_t
**/
typedef struct xcb_input_xi_get_selected_events_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
} xcb_input_xi_get_selected_events_request_t;
/**
* @brief xcb_input_xi_get_selected_events_reply_t
**/
typedef struct xcb_input_xi_get_selected_events_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t num_masks;
uint8_t pad1[22];
} xcb_input_xi_get_selected_events_reply_t;
/**
* @brief xcb_input_barrier_release_pointer_info_t
**/
typedef struct xcb_input_barrier_release_pointer_info_t {
xcb_input_device_id_t deviceid;
uint8_t pad0[2];
xcb_xfixes_barrier_t barrier;
uint32_t eventid;
} xcb_input_barrier_release_pointer_info_t;
/**
* @brief xcb_input_barrier_release_pointer_info_iterator_t
**/
typedef struct xcb_input_barrier_release_pointer_info_iterator_t {
xcb_input_barrier_release_pointer_info_t *data;
int rem;
int index;
} xcb_input_barrier_release_pointer_info_iterator_t;
/** Opcode for xcb_input_xi_barrier_release_pointer. */
#define XCB_INPUT_XI_BARRIER_RELEASE_POINTER 61
/**
* @brief xcb_input_xi_barrier_release_pointer_request_t
**/
typedef struct xcb_input_xi_barrier_release_pointer_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t num_barriers;
} xcb_input_xi_barrier_release_pointer_request_t;
/** Opcode for xcb_input_device_valuator. */
#define XCB_INPUT_DEVICE_VALUATOR 0
/**
* @brief xcb_input_device_valuator_event_t
**/
typedef struct xcb_input_device_valuator_event_t {
uint8_t response_type;
uint8_t device_id;
uint16_t sequence;
uint16_t device_state;
uint8_t num_valuators;
uint8_t first_valuator;
int32_t valuators[6];
} xcb_input_device_valuator_event_t;
typedef enum xcb_input_more_events_mask_t {
XCB_INPUT_MORE_EVENTS_MASK_MORE_EVENTS = 128
} xcb_input_more_events_mask_t;
/** Opcode for xcb_input_device_key_press. */
#define XCB_INPUT_DEVICE_KEY_PRESS 1
/**
* @brief xcb_input_device_key_press_event_t
**/
typedef struct xcb_input_device_key_press_event_t {
uint8_t response_type;
uint8_t detail;
uint16_t sequence;
xcb_timestamp_t time;
xcb_window_t root;
xcb_window_t event;
xcb_window_t child;
int16_t root_x;
int16_t root_y;
int16_t event_x;
int16_t event_y;
uint16_t state;
uint8_t same_screen;
uint8_t device_id;
} xcb_input_device_key_press_event_t;
/** Opcode for xcb_input_device_key_release. */
#define XCB_INPUT_DEVICE_KEY_RELEASE 2
typedef xcb_input_device_key_press_event_t xcb_input_device_key_release_event_t;
/** Opcode for xcb_input_device_button_press. */
#define XCB_INPUT_DEVICE_BUTTON_PRESS 3
typedef xcb_input_device_key_press_event_t xcb_input_device_button_press_event_t;
/** Opcode for xcb_input_device_button_release. */
#define XCB_INPUT_DEVICE_BUTTON_RELEASE 4
typedef xcb_input_device_key_press_event_t xcb_input_device_button_release_event_t;
/** Opcode for xcb_input_device_motion_notify. */
#define XCB_INPUT_DEVICE_MOTION_NOTIFY 5
typedef xcb_input_device_key_press_event_t xcb_input_device_motion_notify_event_t;
/** Opcode for xcb_input_device_focus_in. */
#define XCB_INPUT_DEVICE_FOCUS_IN 6
/**
* @brief xcb_input_device_focus_in_event_t
**/
typedef struct xcb_input_device_focus_in_event_t {
uint8_t response_type;
uint8_t detail;
uint16_t sequence;
xcb_timestamp_t time;
xcb_window_t window;
uint8_t mode;
uint8_t device_id;
uint8_t pad0[18];
} xcb_input_device_focus_in_event_t;
/** Opcode for xcb_input_device_focus_out. */
#define XCB_INPUT_DEVICE_FOCUS_OUT 7
typedef xcb_input_device_focus_in_event_t xcb_input_device_focus_out_event_t;
/** Opcode for xcb_input_proximity_in. */
#define XCB_INPUT_PROXIMITY_IN 8
typedef xcb_input_device_key_press_event_t xcb_input_proximity_in_event_t;
/** Opcode for xcb_input_proximity_out. */
#define XCB_INPUT_PROXIMITY_OUT 9
typedef xcb_input_device_key_press_event_t xcb_input_proximity_out_event_t;
typedef enum xcb_input_classes_reported_mask_t {
XCB_INPUT_CLASSES_REPORTED_MASK_OUT_OF_PROXIMITY = 128,
XCB_INPUT_CLASSES_REPORTED_MASK_DEVICE_MODE_ABSOLUTE = 64,
XCB_INPUT_CLASSES_REPORTED_MASK_REPORTING_VALUATORS = 4,
XCB_INPUT_CLASSES_REPORTED_MASK_REPORTING_BUTTONS = 2,
XCB_INPUT_CLASSES_REPORTED_MASK_REPORTING_KEYS = 1
} xcb_input_classes_reported_mask_t;
/** Opcode for xcb_input_device_state_notify. */
#define XCB_INPUT_DEVICE_STATE_NOTIFY 10
/**
* @brief xcb_input_device_state_notify_event_t
**/
typedef struct xcb_input_device_state_notify_event_t {
uint8_t response_type;
uint8_t device_id;
uint16_t sequence;
xcb_timestamp_t time;
uint8_t num_keys;
uint8_t num_buttons;
uint8_t num_valuators;
uint8_t classes_reported;
uint8_t buttons[4];
uint8_t keys[4];
uint32_t valuators[3];
} xcb_input_device_state_notify_event_t;
/** Opcode for xcb_input_device_mapping_notify. */
#define XCB_INPUT_DEVICE_MAPPING_NOTIFY 11
/**
* @brief xcb_input_device_mapping_notify_event_t
**/
typedef struct xcb_input_device_mapping_notify_event_t {
uint8_t response_type;
uint8_t device_id;
uint16_t sequence;
uint8_t request;
xcb_input_key_code_t first_keycode;
uint8_t count;
uint8_t pad0;
xcb_timestamp_t time;
uint8_t pad1[20];
} xcb_input_device_mapping_notify_event_t;
typedef enum xcb_input_change_device_t {
XCB_INPUT_CHANGE_DEVICE_NEW_POINTER = 0,
XCB_INPUT_CHANGE_DEVICE_NEW_KEYBOARD = 1
} xcb_input_change_device_t;
/** Opcode for xcb_input_change_device_notify. */
#define XCB_INPUT_CHANGE_DEVICE_NOTIFY 12
/**
* @brief xcb_input_change_device_notify_event_t
**/
typedef struct xcb_input_change_device_notify_event_t {
uint8_t response_type;
uint8_t device_id;
uint16_t sequence;
xcb_timestamp_t time;
uint8_t request;
uint8_t pad0[23];
} xcb_input_change_device_notify_event_t;
/** Opcode for xcb_input_device_key_state_notify. */
#define XCB_INPUT_DEVICE_KEY_STATE_NOTIFY 13
/**
* @brief xcb_input_device_key_state_notify_event_t
**/
typedef struct xcb_input_device_key_state_notify_event_t {
uint8_t response_type;
uint8_t device_id;
uint16_t sequence;
uint8_t keys[28];
} xcb_input_device_key_state_notify_event_t;
/** Opcode for xcb_input_device_button_state_notify. */
#define XCB_INPUT_DEVICE_BUTTON_STATE_NOTIFY 14
/**
* @brief xcb_input_device_button_state_notify_event_t
**/
typedef struct xcb_input_device_button_state_notify_event_t {
uint8_t response_type;
uint8_t device_id;
uint16_t sequence;
uint8_t buttons[28];
} xcb_input_device_button_state_notify_event_t;
typedef enum xcb_input_device_change_t {
XCB_INPUT_DEVICE_CHANGE_ADDED = 0,
XCB_INPUT_DEVICE_CHANGE_REMOVED = 1,
XCB_INPUT_DEVICE_CHANGE_ENABLED = 2,
XCB_INPUT_DEVICE_CHANGE_DISABLED = 3,
XCB_INPUT_DEVICE_CHANGE_UNRECOVERABLE = 4,
XCB_INPUT_DEVICE_CHANGE_CONTROL_CHANGED = 5
} xcb_input_device_change_t;
/** Opcode for xcb_input_device_presence_notify. */
#define XCB_INPUT_DEVICE_PRESENCE_NOTIFY 15
/**
* @brief xcb_input_device_presence_notify_event_t
**/
typedef struct xcb_input_device_presence_notify_event_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
xcb_timestamp_t time;
uint8_t devchange;
uint8_t device_id;
uint16_t control;
uint8_t pad1[20];
} xcb_input_device_presence_notify_event_t;
/** Opcode for xcb_input_device_property_notify. */
#define XCB_INPUT_DEVICE_PROPERTY_NOTIFY 16
/**
* @brief xcb_input_device_property_notify_event_t
**/
typedef struct xcb_input_device_property_notify_event_t {
uint8_t response_type;
uint8_t state;
uint16_t sequence;
xcb_timestamp_t time;
xcb_atom_t property;
uint8_t pad0[19];
uint8_t device_id;
} xcb_input_device_property_notify_event_t;
typedef enum xcb_input_change_reason_t {
XCB_INPUT_CHANGE_REASON_SLAVE_SWITCH = 1,
XCB_INPUT_CHANGE_REASON_DEVICE_CHANGE = 2
} xcb_input_change_reason_t;
/** Opcode for xcb_input_device_changed. */
#define XCB_INPUT_DEVICE_CHANGED 1
/**
* @brief xcb_input_device_changed_event_t
**/
typedef struct xcb_input_device_changed_event_t {
uint8_t response_type;
uint8_t extension;
uint16_t sequence;
uint32_t length;
uint16_t event_type;
xcb_input_device_id_t deviceid;
xcb_timestamp_t time;
uint16_t num_classes;
xcb_input_device_id_t sourceid;
uint8_t reason;
uint8_t pad0[11];
uint32_t full_sequence;
} xcb_input_device_changed_event_t;
typedef enum xcb_input_key_event_flags_t {
XCB_INPUT_KEY_EVENT_FLAGS_KEY_REPEAT = 65536
} xcb_input_key_event_flags_t;
/** Opcode for xcb_input_key_press. */
#define XCB_INPUT_KEY_PRESS 2
/**
* @brief xcb_input_key_press_event_t
**/
typedef struct xcb_input_key_press_event_t {
uint8_t response_type;
uint8_t extension;
uint16_t sequence;
uint32_t length;
uint16_t event_type;
xcb_input_device_id_t deviceid;
xcb_timestamp_t time;
uint32_t detail;
xcb_window_t root;
xcb_window_t event;
xcb_window_t child;
uint32_t full_sequence;
xcb_input_fp1616_t root_x;
xcb_input_fp1616_t root_y;
xcb_input_fp1616_t event_x;
xcb_input_fp1616_t event_y;
uint16_t buttons_len;
uint16_t valuators_len;
xcb_input_device_id_t sourceid;
uint8_t pad0[2];
uint32_t flags;
xcb_input_modifier_info_t mods;
xcb_input_group_info_t group;
} xcb_input_key_press_event_t;
/** Opcode for xcb_input_key_release. */
#define XCB_INPUT_KEY_RELEASE 3
typedef xcb_input_key_press_event_t xcb_input_key_release_event_t;
typedef enum xcb_input_pointer_event_flags_t {
XCB_INPUT_POINTER_EVENT_FLAGS_POINTER_EMULATED = 65536
} xcb_input_pointer_event_flags_t;
/** Opcode for xcb_input_button_press. */
#define XCB_INPUT_BUTTON_PRESS 4
/**
* @brief xcb_input_button_press_event_t
**/
typedef struct xcb_input_button_press_event_t {
uint8_t response_type;
uint8_t extension;
uint16_t sequence;
uint32_t length;
uint16_t event_type;
xcb_input_device_id_t deviceid;
xcb_timestamp_t time;
uint32_t detail;
xcb_window_t root;
xcb_window_t event;
xcb_window_t child;
uint32_t full_sequence;
xcb_input_fp1616_t root_x;
xcb_input_fp1616_t root_y;
xcb_input_fp1616_t event_x;
xcb_input_fp1616_t event_y;
uint16_t buttons_len;
uint16_t valuators_len;
xcb_input_device_id_t sourceid;
uint8_t pad0[2];
uint32_t flags;
xcb_input_modifier_info_t mods;
xcb_input_group_info_t group;
} xcb_input_button_press_event_t;
/** Opcode for xcb_input_button_release. */
#define XCB_INPUT_BUTTON_RELEASE 5
typedef xcb_input_button_press_event_t xcb_input_button_release_event_t;
/** Opcode for xcb_input_motion. */
#define XCB_INPUT_MOTION 6
typedef xcb_input_button_press_event_t xcb_input_motion_event_t;
typedef enum xcb_input_notify_mode_t {
XCB_INPUT_NOTIFY_MODE_NORMAL = 0,
XCB_INPUT_NOTIFY_MODE_GRAB = 1,
XCB_INPUT_NOTIFY_MODE_UNGRAB = 2,
XCB_INPUT_NOTIFY_MODE_WHILE_GRABBED = 3,
XCB_INPUT_NOTIFY_MODE_PASSIVE_GRAB = 4,
XCB_INPUT_NOTIFY_MODE_PASSIVE_UNGRAB = 5
} xcb_input_notify_mode_t;
typedef enum xcb_input_notify_detail_t {
XCB_INPUT_NOTIFY_DETAIL_ANCESTOR = 0,
XCB_INPUT_NOTIFY_DETAIL_VIRTUAL = 1,
XCB_INPUT_NOTIFY_DETAIL_INFERIOR = 2,
XCB_INPUT_NOTIFY_DETAIL_NONLINEAR = 3,
XCB_INPUT_NOTIFY_DETAIL_NONLINEAR_VIRTUAL = 4,
XCB_INPUT_NOTIFY_DETAIL_POINTER = 5,
XCB_INPUT_NOTIFY_DETAIL_POINTER_ROOT = 6,
XCB_INPUT_NOTIFY_DETAIL_NONE = 7
} xcb_input_notify_detail_t;
/** Opcode for xcb_input_enter. */
#define XCB_INPUT_ENTER 7
/**
* @brief xcb_input_enter_event_t
**/
typedef struct xcb_input_enter_event_t {
uint8_t response_type;
uint8_t extension;
uint16_t sequence;
uint32_t length;
uint16_t event_type;
xcb_input_device_id_t deviceid;
xcb_timestamp_t time;
xcb_input_device_id_t sourceid;
uint8_t mode;
uint8_t detail;
xcb_window_t root;
xcb_window_t event;
xcb_window_t child;
uint32_t full_sequence;
xcb_input_fp1616_t root_x;
xcb_input_fp1616_t root_y;
xcb_input_fp1616_t event_x;
xcb_input_fp1616_t event_y;
uint8_t same_screen;
uint8_t focus;
uint16_t buttons_len;
xcb_input_modifier_info_t mods;
xcb_input_group_info_t group;
} xcb_input_enter_event_t;
/** Opcode for xcb_input_leave. */
#define XCB_INPUT_LEAVE 8
typedef xcb_input_enter_event_t xcb_input_leave_event_t;
/** Opcode for xcb_input_focus_in. */
#define XCB_INPUT_FOCUS_IN 9
typedef xcb_input_enter_event_t xcb_input_focus_in_event_t;
/** Opcode for xcb_input_focus_out. */
#define XCB_INPUT_FOCUS_OUT 10
typedef xcb_input_enter_event_t xcb_input_focus_out_event_t;
typedef enum xcb_input_hierarchy_mask_t {
XCB_INPUT_HIERARCHY_MASK_MASTER_ADDED = 1,
XCB_INPUT_HIERARCHY_MASK_MASTER_REMOVED = 2,
XCB_INPUT_HIERARCHY_MASK_SLAVE_ADDED = 4,
XCB_INPUT_HIERARCHY_MASK_SLAVE_REMOVED = 8,
XCB_INPUT_HIERARCHY_MASK_SLAVE_ATTACHED = 16,
XCB_INPUT_HIERARCHY_MASK_SLAVE_DETACHED = 32,
XCB_INPUT_HIERARCHY_MASK_DEVICE_ENABLED = 64,
XCB_INPUT_HIERARCHY_MASK_DEVICE_DISABLED = 128
} xcb_input_hierarchy_mask_t;
/**
* @brief xcb_input_hierarchy_info_t
**/
typedef struct xcb_input_hierarchy_info_t {
xcb_input_device_id_t deviceid;
xcb_input_device_id_t attachment;
uint8_t type;
uint8_t enabled;
uint8_t pad0[2];
uint32_t flags;
} xcb_input_hierarchy_info_t;
/**
* @brief xcb_input_hierarchy_info_iterator_t
**/
typedef struct xcb_input_hierarchy_info_iterator_t {
xcb_input_hierarchy_info_t *data;
int rem;
int index;
} xcb_input_hierarchy_info_iterator_t;
/** Opcode for xcb_input_hierarchy. */
#define XCB_INPUT_HIERARCHY 11
/**
* @brief xcb_input_hierarchy_event_t
**/
typedef struct xcb_input_hierarchy_event_t {
uint8_t response_type;
uint8_t extension;
uint16_t sequence;
uint32_t length;
uint16_t event_type;
xcb_input_device_id_t deviceid;
xcb_timestamp_t time;
uint32_t flags;
uint16_t num_infos;
uint8_t pad0[10];
uint32_t full_sequence;
} xcb_input_hierarchy_event_t;
typedef enum xcb_input_property_flag_t {
XCB_INPUT_PROPERTY_FLAG_DELETED = 0,
XCB_INPUT_PROPERTY_FLAG_CREATED = 1,
XCB_INPUT_PROPERTY_FLAG_MODIFIED = 2
} xcb_input_property_flag_t;
/** Opcode for xcb_input_property. */
#define XCB_INPUT_PROPERTY 12
/**
* @brief xcb_input_property_event_t
**/
typedef struct xcb_input_property_event_t {
uint8_t response_type;
uint8_t extension;
uint16_t sequence;
uint32_t length;
uint16_t event_type;
xcb_input_device_id_t deviceid;
xcb_timestamp_t time;
xcb_atom_t property;
uint8_t what;
uint8_t pad0[11];
uint32_t full_sequence;
} xcb_input_property_event_t;
/** Opcode for xcb_input_raw_key_press. */
#define XCB_INPUT_RAW_KEY_PRESS 13
/**
* @brief xcb_input_raw_key_press_event_t
**/
typedef struct xcb_input_raw_key_press_event_t {
uint8_t response_type;
uint8_t extension;
uint16_t sequence;
uint32_t length;
uint16_t event_type;
xcb_input_device_id_t deviceid;
xcb_timestamp_t time;
uint32_t detail;
xcb_input_device_id_t sourceid;
uint16_t valuators_len;
uint32_t flags;
uint8_t pad0[4];
uint32_t full_sequence;
} xcb_input_raw_key_press_event_t;
/** Opcode for xcb_input_raw_key_release. */
#define XCB_INPUT_RAW_KEY_RELEASE 14
typedef xcb_input_raw_key_press_event_t xcb_input_raw_key_release_event_t;
/** Opcode for xcb_input_raw_button_press. */
#define XCB_INPUT_RAW_BUTTON_PRESS 15
/**
* @brief xcb_input_raw_button_press_event_t
**/
typedef struct xcb_input_raw_button_press_event_t {
uint8_t response_type;
uint8_t extension;
uint16_t sequence;
uint32_t length;
uint16_t event_type;
xcb_input_device_id_t deviceid;
xcb_timestamp_t time;
uint32_t detail;
xcb_input_device_id_t sourceid;
uint16_t valuators_len;
uint32_t flags;
uint8_t pad0[4];
uint32_t full_sequence;
} xcb_input_raw_button_press_event_t;
/** Opcode for xcb_input_raw_button_release. */
#define XCB_INPUT_RAW_BUTTON_RELEASE 16
typedef xcb_input_raw_button_press_event_t xcb_input_raw_button_release_event_t;
/** Opcode for xcb_input_raw_motion. */
#define XCB_INPUT_RAW_MOTION 17
typedef xcb_input_raw_button_press_event_t xcb_input_raw_motion_event_t;
typedef enum xcb_input_touch_event_flags_t {
XCB_INPUT_TOUCH_EVENT_FLAGS_TOUCH_PENDING_END = 65536,
XCB_INPUT_TOUCH_EVENT_FLAGS_TOUCH_EMULATING_POINTER = 131072
} xcb_input_touch_event_flags_t;
/** Opcode for xcb_input_touch_begin. */
#define XCB_INPUT_TOUCH_BEGIN 18
/**
* @brief xcb_input_touch_begin_event_t
**/
typedef struct xcb_input_touch_begin_event_t {
uint8_t response_type;
uint8_t extension;
uint16_t sequence;
uint32_t length;
uint16_t event_type;
xcb_input_device_id_t deviceid;
xcb_timestamp_t time;
uint32_t detail;
xcb_window_t root;
xcb_window_t event;
xcb_window_t child;
uint32_t full_sequence;
xcb_input_fp1616_t root_x;
xcb_input_fp1616_t root_y;
xcb_input_fp1616_t event_x;
xcb_input_fp1616_t event_y;
uint16_t buttons_len;
uint16_t valuators_len;
xcb_input_device_id_t sourceid;
uint8_t pad0[2];
uint32_t flags;
xcb_input_modifier_info_t mods;
xcb_input_group_info_t group;
} xcb_input_touch_begin_event_t;
/** Opcode for xcb_input_touch_update. */
#define XCB_INPUT_TOUCH_UPDATE 19
typedef xcb_input_touch_begin_event_t xcb_input_touch_update_event_t;
/** Opcode for xcb_input_touch_end. */
#define XCB_INPUT_TOUCH_END 20
typedef xcb_input_touch_begin_event_t xcb_input_touch_end_event_t;
typedef enum xcb_input_touch_ownership_flags_t {
XCB_INPUT_TOUCH_OWNERSHIP_FLAGS_NONE = 0
} xcb_input_touch_ownership_flags_t;
/** Opcode for xcb_input_touch_ownership. */
#define XCB_INPUT_TOUCH_OWNERSHIP 21
/**
* @brief xcb_input_touch_ownership_event_t
**/
typedef struct xcb_input_touch_ownership_event_t {
uint8_t response_type;
uint8_t extension;
uint16_t sequence;
uint32_t length;
uint16_t event_type;
xcb_input_device_id_t deviceid;
xcb_timestamp_t time;
uint32_t touchid;
xcb_window_t root;
xcb_window_t event;
xcb_window_t child;
uint32_t full_sequence;
xcb_input_device_id_t sourceid;
uint8_t pad0[2];
uint32_t flags;
uint8_t pad1[8];
} xcb_input_touch_ownership_event_t;
/** Opcode for xcb_input_raw_touch_begin. */
#define XCB_INPUT_RAW_TOUCH_BEGIN 22
/**
* @brief xcb_input_raw_touch_begin_event_t
**/
typedef struct xcb_input_raw_touch_begin_event_t {
uint8_t response_type;
uint8_t extension;
uint16_t sequence;
uint32_t length;
uint16_t event_type;
xcb_input_device_id_t deviceid;
xcb_timestamp_t time;
uint32_t detail;
xcb_input_device_id_t sourceid;
uint16_t valuators_len;
uint32_t flags;
uint8_t pad0[4];
uint32_t full_sequence;
} xcb_input_raw_touch_begin_event_t;
/** Opcode for xcb_input_raw_touch_update. */
#define XCB_INPUT_RAW_TOUCH_UPDATE 23
typedef xcb_input_raw_touch_begin_event_t xcb_input_raw_touch_update_event_t;
/** Opcode for xcb_input_raw_touch_end. */
#define XCB_INPUT_RAW_TOUCH_END 24
typedef xcb_input_raw_touch_begin_event_t xcb_input_raw_touch_end_event_t;
typedef enum xcb_input_barrier_flags_t {
XCB_INPUT_BARRIER_FLAGS_POINTER_RELEASED = 1,
XCB_INPUT_BARRIER_FLAGS_DEVICE_IS_GRABBED = 2
} xcb_input_barrier_flags_t;
/** Opcode for xcb_input_barrier_hit. */
#define XCB_INPUT_BARRIER_HIT 25
/**
* @brief xcb_input_barrier_hit_event_t
**/
typedef struct xcb_input_barrier_hit_event_t {
uint8_t response_type;
uint8_t extension;
uint16_t sequence;
uint32_t length;
uint16_t event_type;
xcb_input_device_id_t deviceid;
xcb_timestamp_t time;
uint32_t eventid;
xcb_window_t root;
xcb_window_t event;
xcb_xfixes_barrier_t barrier;
uint32_t full_sequence;
uint32_t dtime;
uint32_t flags;
xcb_input_device_id_t sourceid;
uint8_t pad0[2];
xcb_input_fp1616_t root_x;
xcb_input_fp1616_t root_y;
xcb_input_fp3232_t dx;
xcb_input_fp3232_t dy;
} xcb_input_barrier_hit_event_t;
/** Opcode for xcb_input_barrier_leave. */
#define XCB_INPUT_BARRIER_LEAVE 26
typedef xcb_input_barrier_hit_event_t xcb_input_barrier_leave_event_t;
/**
* @brief xcb_input_event_for_send_t
**/
typedef union xcb_input_event_for_send_t {
xcb_input_device_valuator_event_t device_valuator;
xcb_input_device_key_press_event_t device_key_press;
xcb_input_device_key_release_event_t device_key_release;
xcb_input_device_button_press_event_t device_button_press;
xcb_input_device_button_release_event_t device_button_release;
xcb_input_device_motion_notify_event_t device_motion_notify;
xcb_input_device_focus_in_event_t device_focus_in;
xcb_input_device_focus_out_event_t device_focus_out;
xcb_input_proximity_in_event_t proximity_in;
xcb_input_proximity_out_event_t proximity_out;
xcb_input_device_state_notify_event_t device_state_notify;
xcb_input_device_mapping_notify_event_t device_mapping_notify;
xcb_input_change_device_notify_event_t change_device_notify;
xcb_input_device_key_state_notify_event_t device_key_state_notify;
xcb_input_device_button_state_notify_event_t device_button_state_notify;
xcb_input_device_presence_notify_event_t device_presence_notify;
xcb_raw_generic_event_t event_header;
} xcb_input_event_for_send_t;
/**
* @brief xcb_input_event_for_send_iterator_t
**/
typedef struct xcb_input_event_for_send_iterator_t {
xcb_input_event_for_send_t *data;
int rem;
int index;
} xcb_input_event_for_send_iterator_t;
/** Opcode for xcb_input_send_extension_event. */
#define XCB_INPUT_SEND_EXTENSION_EVENT 31
/**
* @brief xcb_input_send_extension_event_request_t
**/
typedef struct xcb_input_send_extension_event_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t destination;
uint8_t device_id;
uint8_t propagate;
uint16_t num_classes;
uint8_t num_events;
uint8_t pad0[3];
} xcb_input_send_extension_event_request_t;
/** Opcode for xcb_input_device. */
#define XCB_INPUT_DEVICE 0
/**
* @brief xcb_input_device_error_t
**/
typedef struct xcb_input_device_error_t {
uint8_t response_type;
uint8_t error_code;
uint16_t sequence;
} xcb_input_device_error_t;
/** Opcode for xcb_input_event. */
#define XCB_INPUT_EVENT 1
/**
* @brief xcb_input_event_error_t
**/
typedef struct xcb_input_event_error_t {
uint8_t response_type;
uint8_t error_code;
uint16_t sequence;
} xcb_input_event_error_t;
/** Opcode for xcb_input_mode. */
#define XCB_INPUT_MODE 2
/**
* @brief xcb_input_mode_error_t
**/
typedef struct xcb_input_mode_error_t {
uint8_t response_type;
uint8_t error_code;
uint16_t sequence;
} xcb_input_mode_error_t;
/** Opcode for xcb_input_device_busy. */
#define XCB_INPUT_DEVICE_BUSY 3
/**
* @brief xcb_input_device_busy_error_t
**/
typedef struct xcb_input_device_busy_error_t {
uint8_t response_type;
uint8_t error_code;
uint16_t sequence;
} xcb_input_device_busy_error_t;
/** Opcode for xcb_input_class. */
#define XCB_INPUT_CLASS 4
/**
* @brief xcb_input_class_error_t
**/
typedef struct xcb_input_class_error_t {
uint8_t response_type;
uint8_t error_code;
uint16_t sequence;
} xcb_input_class_error_t;
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_event_class_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_event_class_t)
*/
void
xcb_input_event_class_next (xcb_input_event_class_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_event_class_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_event_class_end (xcb_input_event_class_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_key_code_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_key_code_t)
*/
void
xcb_input_key_code_next (xcb_input_key_code_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_key_code_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_key_code_end (xcb_input_key_code_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_device_id_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_device_id_t)
*/
void
xcb_input_device_id_next (xcb_input_device_id_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_device_id_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_device_id_end (xcb_input_device_id_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_fp1616_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_fp1616_t)
*/
void
xcb_input_fp1616_next (xcb_input_fp1616_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_fp1616_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_fp1616_end (xcb_input_fp1616_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_fp3232_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_fp3232_t)
*/
void
xcb_input_fp3232_next (xcb_input_fp3232_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_fp3232_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_fp3232_end (xcb_input_fp3232_iterator_t i);
int
xcb_input_get_extension_version_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_get_extension_version_cookie_t
xcb_input_get_extension_version (xcb_connection_t *c,
uint16_t name_len,
const char *name);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_get_extension_version_cookie_t
xcb_input_get_extension_version_unchecked (xcb_connection_t *c,
uint16_t name_len,
const char *name);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_get_extension_version_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_get_extension_version_reply_t *
xcb_input_get_extension_version_reply (xcb_connection_t *c,
xcb_input_get_extension_version_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_device_info_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_device_info_t)
*/
void
xcb_input_device_info_next (xcb_input_device_info_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_device_info_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_device_info_end (xcb_input_device_info_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_key_info_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_key_info_t)
*/
void
xcb_input_key_info_next (xcb_input_key_info_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_key_info_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_key_info_end (xcb_input_key_info_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_button_info_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_button_info_t)
*/
void
xcb_input_button_info_next (xcb_input_button_info_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_button_info_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_button_info_end (xcb_input_button_info_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_axis_info_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_axis_info_t)
*/
void
xcb_input_axis_info_next (xcb_input_axis_info_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_axis_info_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_axis_info_end (xcb_input_axis_info_iterator_t i);
int
xcb_input_valuator_info_sizeof (const void *_buffer);
xcb_input_axis_info_t *
xcb_input_valuator_info_axes (const xcb_input_valuator_info_t *R);
int
xcb_input_valuator_info_axes_length (const xcb_input_valuator_info_t *R);
xcb_input_axis_info_iterator_t
xcb_input_valuator_info_axes_iterator (const xcb_input_valuator_info_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_valuator_info_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_valuator_info_t)
*/
void
xcb_input_valuator_info_next (xcb_input_valuator_info_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_valuator_info_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_valuator_info_end (xcb_input_valuator_info_iterator_t i);
xcb_input_axis_info_t *
xcb_input_input_info_info_valuator_axes (const xcb_input_input_info_info_t *S);
int
xcb_input_input_info_info_valuator_axes_length (const xcb_input_input_info_t *R,
const xcb_input_input_info_info_t *S);
xcb_input_axis_info_iterator_t
xcb_input_input_info_info_valuator_axes_iterator (const xcb_input_input_info_t *R,
const xcb_input_input_info_info_t *S);
int
xcb_input_input_info_info_serialize (void **_buffer,
uint8_t class_id,
const xcb_input_input_info_info_t *_aux);
int
xcb_input_input_info_info_unpack (const void *_buffer,
uint8_t class_id,
xcb_input_input_info_info_t *_aux);
int
xcb_input_input_info_info_sizeof (const void *_buffer,
uint8_t class_id);
int
xcb_input_input_info_sizeof (const void *_buffer);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_input_info_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_input_info_t)
*/
void
xcb_input_input_info_next (xcb_input_input_info_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_input_info_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_input_info_end (xcb_input_input_info_iterator_t i);
int
xcb_input_device_name_sizeof (const void *_buffer);
char *
xcb_input_device_name_string (const xcb_input_device_name_t *R);
int
xcb_input_device_name_string_length (const xcb_input_device_name_t *R);
xcb_generic_iterator_t
xcb_input_device_name_string_end (const xcb_input_device_name_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_device_name_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_device_name_t)
*/
void
xcb_input_device_name_next (xcb_input_device_name_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_device_name_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_device_name_end (xcb_input_device_name_iterator_t i);
int
xcb_input_list_input_devices_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_list_input_devices_cookie_t
xcb_input_list_input_devices (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_list_input_devices_cookie_t
xcb_input_list_input_devices_unchecked (xcb_connection_t *c);
xcb_input_device_info_t *
xcb_input_list_input_devices_devices (const xcb_input_list_input_devices_reply_t *R);
int
xcb_input_list_input_devices_devices_length (const xcb_input_list_input_devices_reply_t *R);
xcb_input_device_info_iterator_t
xcb_input_list_input_devices_devices_iterator (const xcb_input_list_input_devices_reply_t *R);
int
xcb_input_list_input_devices_infos_length (const xcb_input_list_input_devices_reply_t *R);
xcb_input_input_info_iterator_t
xcb_input_list_input_devices_infos_iterator (const xcb_input_list_input_devices_reply_t *R);
int
xcb_input_list_input_devices_names_length (const xcb_input_list_input_devices_reply_t *R);
xcb_str_iterator_t
xcb_input_list_input_devices_names_iterator (const xcb_input_list_input_devices_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_list_input_devices_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_list_input_devices_reply_t *
xcb_input_list_input_devices_reply (xcb_connection_t *c,
xcb_input_list_input_devices_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_event_type_base_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_event_type_base_t)
*/
void
xcb_input_event_type_base_next (xcb_input_event_type_base_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_event_type_base_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_event_type_base_end (xcb_input_event_type_base_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_input_class_info_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_input_class_info_t)
*/
void
xcb_input_input_class_info_next (xcb_input_input_class_info_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_input_class_info_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_input_class_info_end (xcb_input_input_class_info_iterator_t i);
int
xcb_input_open_device_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_open_device_cookie_t
xcb_input_open_device (xcb_connection_t *c,
uint8_t device_id);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_open_device_cookie_t
xcb_input_open_device_unchecked (xcb_connection_t *c,
uint8_t device_id);
xcb_input_input_class_info_t *
xcb_input_open_device_class_info (const xcb_input_open_device_reply_t *R);
int
xcb_input_open_device_class_info_length (const xcb_input_open_device_reply_t *R);
xcb_input_input_class_info_iterator_t
xcb_input_open_device_class_info_iterator (const xcb_input_open_device_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_open_device_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_open_device_reply_t *
xcb_input_open_device_reply (xcb_connection_t *c,
xcb_input_open_device_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_input_close_device_checked (xcb_connection_t *c,
uint8_t device_id);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_input_close_device (xcb_connection_t *c,
uint8_t device_id);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_set_device_mode_cookie_t
xcb_input_set_device_mode (xcb_connection_t *c,
uint8_t device_id,
uint8_t mode);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_set_device_mode_cookie_t
xcb_input_set_device_mode_unchecked (xcb_connection_t *c,
uint8_t device_id,
uint8_t mode);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_set_device_mode_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_set_device_mode_reply_t *
xcb_input_set_device_mode_reply (xcb_connection_t *c,
xcb_input_set_device_mode_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_input_select_extension_event_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_input_select_extension_event_checked (xcb_connection_t *c,
xcb_window_t window,
uint16_t num_classes,
const xcb_input_event_class_t *classes);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_input_select_extension_event (xcb_connection_t *c,
xcb_window_t window,
uint16_t num_classes,
const xcb_input_event_class_t *classes);
xcb_input_event_class_t *
xcb_input_select_extension_event_classes (const xcb_input_select_extension_event_request_t *R);
int
xcb_input_select_extension_event_classes_length (const xcb_input_select_extension_event_request_t *R);
xcb_generic_iterator_t
xcb_input_select_extension_event_classes_end (const xcb_input_select_extension_event_request_t *R);
int
xcb_input_get_selected_extension_events_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_get_selected_extension_events_cookie_t
xcb_input_get_selected_extension_events (xcb_connection_t *c,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_get_selected_extension_events_cookie_t
xcb_input_get_selected_extension_events_unchecked (xcb_connection_t *c,
xcb_window_t window);
xcb_input_event_class_t *
xcb_input_get_selected_extension_events_this_classes (const xcb_input_get_selected_extension_events_reply_t *R);
int
xcb_input_get_selected_extension_events_this_classes_length (const xcb_input_get_selected_extension_events_reply_t *R);
xcb_generic_iterator_t
xcb_input_get_selected_extension_events_this_classes_end (const xcb_input_get_selected_extension_events_reply_t *R);
xcb_input_event_class_t *
xcb_input_get_selected_extension_events_all_classes (const xcb_input_get_selected_extension_events_reply_t *R);
int
xcb_input_get_selected_extension_events_all_classes_length (const xcb_input_get_selected_extension_events_reply_t *R);
xcb_generic_iterator_t
xcb_input_get_selected_extension_events_all_classes_end (const xcb_input_get_selected_extension_events_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_get_selected_extension_events_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_get_selected_extension_events_reply_t *
xcb_input_get_selected_extension_events_reply (xcb_connection_t *c,
xcb_input_get_selected_extension_events_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_input_change_device_dont_propagate_list_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_input_change_device_dont_propagate_list_checked (xcb_connection_t *c,
xcb_window_t window,
uint16_t num_classes,
uint8_t mode,
const xcb_input_event_class_t *classes);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_input_change_device_dont_propagate_list (xcb_connection_t *c,
xcb_window_t window,
uint16_t num_classes,
uint8_t mode,
const xcb_input_event_class_t *classes);
xcb_input_event_class_t *
xcb_input_change_device_dont_propagate_list_classes (const xcb_input_change_device_dont_propagate_list_request_t *R);
int
xcb_input_change_device_dont_propagate_list_classes_length (const xcb_input_change_device_dont_propagate_list_request_t *R);
xcb_generic_iterator_t
xcb_input_change_device_dont_propagate_list_classes_end (const xcb_input_change_device_dont_propagate_list_request_t *R);
int
xcb_input_get_device_dont_propagate_list_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_get_device_dont_propagate_list_cookie_t
xcb_input_get_device_dont_propagate_list (xcb_connection_t *c,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_get_device_dont_propagate_list_cookie_t
xcb_input_get_device_dont_propagate_list_unchecked (xcb_connection_t *c,
xcb_window_t window);
xcb_input_event_class_t *
xcb_input_get_device_dont_propagate_list_classes (const xcb_input_get_device_dont_propagate_list_reply_t *R);
int
xcb_input_get_device_dont_propagate_list_classes_length (const xcb_input_get_device_dont_propagate_list_reply_t *R);
xcb_generic_iterator_t
xcb_input_get_device_dont_propagate_list_classes_end (const xcb_input_get_device_dont_propagate_list_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_get_device_dont_propagate_list_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_get_device_dont_propagate_list_reply_t *
xcb_input_get_device_dont_propagate_list_reply (xcb_connection_t *c,
xcb_input_get_device_dont_propagate_list_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_input_device_time_coord_sizeof (const void *_buffer,
uint8_t num_axes);
int32_t *
xcb_input_device_time_coord_axisvalues (const xcb_input_device_time_coord_t *R);
int
xcb_input_device_time_coord_axisvalues_length (const xcb_input_device_time_coord_t *R,
uint8_t num_axes);
xcb_generic_iterator_t
xcb_input_device_time_coord_axisvalues_end (const xcb_input_device_time_coord_t *R,
uint8_t num_axes);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_device_time_coord_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_device_time_coord_t)
*/
void
xcb_input_device_time_coord_next (xcb_input_device_time_coord_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_device_time_coord_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_device_time_coord_end (xcb_input_device_time_coord_iterator_t i);
int
xcb_input_get_device_motion_events_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_get_device_motion_events_cookie_t
xcb_input_get_device_motion_events (xcb_connection_t *c,
xcb_timestamp_t start,
xcb_timestamp_t stop,
uint8_t device_id);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_get_device_motion_events_cookie_t
xcb_input_get_device_motion_events_unchecked (xcb_connection_t *c,
xcb_timestamp_t start,
xcb_timestamp_t stop,
uint8_t device_id);
int
xcb_input_get_device_motion_events_events_length (const xcb_input_get_device_motion_events_reply_t *R);
xcb_input_device_time_coord_iterator_t
xcb_input_get_device_motion_events_events_iterator (const xcb_input_get_device_motion_events_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_get_device_motion_events_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_get_device_motion_events_reply_t *
xcb_input_get_device_motion_events_reply (xcb_connection_t *c,
xcb_input_get_device_motion_events_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_change_keyboard_device_cookie_t
xcb_input_change_keyboard_device (xcb_connection_t *c,
uint8_t device_id);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_change_keyboard_device_cookie_t
xcb_input_change_keyboard_device_unchecked (xcb_connection_t *c,
uint8_t device_id);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_change_keyboard_device_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_change_keyboard_device_reply_t *
xcb_input_change_keyboard_device_reply (xcb_connection_t *c,
xcb_input_change_keyboard_device_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_change_pointer_device_cookie_t
xcb_input_change_pointer_device (xcb_connection_t *c,
uint8_t x_axis,
uint8_t y_axis,
uint8_t device_id);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_change_pointer_device_cookie_t
xcb_input_change_pointer_device_unchecked (xcb_connection_t *c,
uint8_t x_axis,
uint8_t y_axis,
uint8_t device_id);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_change_pointer_device_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_change_pointer_device_reply_t *
xcb_input_change_pointer_device_reply (xcb_connection_t *c,
xcb_input_change_pointer_device_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_input_grab_device_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_grab_device_cookie_t
xcb_input_grab_device (xcb_connection_t *c,
xcb_window_t grab_window,
xcb_timestamp_t time,
uint16_t num_classes,
uint8_t this_device_mode,
uint8_t other_device_mode,
uint8_t owner_events,
uint8_t device_id,
const xcb_input_event_class_t *classes);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_grab_device_cookie_t
xcb_input_grab_device_unchecked (xcb_connection_t *c,
xcb_window_t grab_window,
xcb_timestamp_t time,
uint16_t num_classes,
uint8_t this_device_mode,
uint8_t other_device_mode,
uint8_t owner_events,
uint8_t device_id,
const xcb_input_event_class_t *classes);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_grab_device_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_grab_device_reply_t *
xcb_input_grab_device_reply (xcb_connection_t *c,
xcb_input_grab_device_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_input_ungrab_device_checked (xcb_connection_t *c,
xcb_timestamp_t time,
uint8_t device_id);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_input_ungrab_device (xcb_connection_t *c,
xcb_timestamp_t time,
uint8_t device_id);
int
xcb_input_grab_device_key_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_input_grab_device_key_checked (xcb_connection_t *c,
xcb_window_t grab_window,
uint16_t num_classes,
uint16_t modifiers,
uint8_t modifier_device,
uint8_t grabbed_device,
uint8_t key,
uint8_t this_device_mode,
uint8_t other_device_mode,
uint8_t owner_events,
const xcb_input_event_class_t *classes);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_input_grab_device_key (xcb_connection_t *c,
xcb_window_t grab_window,
uint16_t num_classes,
uint16_t modifiers,
uint8_t modifier_device,
uint8_t grabbed_device,
uint8_t key,
uint8_t this_device_mode,
uint8_t other_device_mode,
uint8_t owner_events,
const xcb_input_event_class_t *classes);
xcb_input_event_class_t *
xcb_input_grab_device_key_classes (const xcb_input_grab_device_key_request_t *R);
int
xcb_input_grab_device_key_classes_length (const xcb_input_grab_device_key_request_t *R);
xcb_generic_iterator_t
xcb_input_grab_device_key_classes_end (const xcb_input_grab_device_key_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_input_ungrab_device_key_checked (xcb_connection_t *c,
xcb_window_t grabWindow,
uint16_t modifiers,
uint8_t modifier_device,
uint8_t key,
uint8_t grabbed_device);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_input_ungrab_device_key (xcb_connection_t *c,
xcb_window_t grabWindow,
uint16_t modifiers,
uint8_t modifier_device,
uint8_t key,
uint8_t grabbed_device);
int
xcb_input_grab_device_button_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_input_grab_device_button_checked (xcb_connection_t *c,
xcb_window_t grab_window,
uint8_t grabbed_device,
uint8_t modifier_device,
uint16_t num_classes,
uint16_t modifiers,
uint8_t this_device_mode,
uint8_t other_device_mode,
uint8_t button,
uint8_t owner_events,
const xcb_input_event_class_t *classes);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_input_grab_device_button (xcb_connection_t *c,
xcb_window_t grab_window,
uint8_t grabbed_device,
uint8_t modifier_device,
uint16_t num_classes,
uint16_t modifiers,
uint8_t this_device_mode,
uint8_t other_device_mode,
uint8_t button,
uint8_t owner_events,
const xcb_input_event_class_t *classes);
xcb_input_event_class_t *
xcb_input_grab_device_button_classes (const xcb_input_grab_device_button_request_t *R);
int
xcb_input_grab_device_button_classes_length (const xcb_input_grab_device_button_request_t *R);
xcb_generic_iterator_t
xcb_input_grab_device_button_classes_end (const xcb_input_grab_device_button_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_input_ungrab_device_button_checked (xcb_connection_t *c,
xcb_window_t grab_window,
uint16_t modifiers,
uint8_t modifier_device,
uint8_t button,
uint8_t grabbed_device);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_input_ungrab_device_button (xcb_connection_t *c,
xcb_window_t grab_window,
uint16_t modifiers,
uint8_t modifier_device,
uint8_t button,
uint8_t grabbed_device);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_input_allow_device_events_checked (xcb_connection_t *c,
xcb_timestamp_t time,
uint8_t mode,
uint8_t device_id);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_input_allow_device_events (xcb_connection_t *c,
xcb_timestamp_t time,
uint8_t mode,
uint8_t device_id);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_get_device_focus_cookie_t
xcb_input_get_device_focus (xcb_connection_t *c,
uint8_t device_id);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_get_device_focus_cookie_t
xcb_input_get_device_focus_unchecked (xcb_connection_t *c,
uint8_t device_id);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_get_device_focus_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_get_device_focus_reply_t *
xcb_input_get_device_focus_reply (xcb_connection_t *c,
xcb_input_get_device_focus_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_input_set_device_focus_checked (xcb_connection_t *c,
xcb_window_t focus,
xcb_timestamp_t time,
uint8_t revert_to,
uint8_t device_id);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_input_set_device_focus (xcb_connection_t *c,
xcb_window_t focus,
xcb_timestamp_t time,
uint8_t revert_to,
uint8_t device_id);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_kbd_feedback_state_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_kbd_feedback_state_t)
*/
void
xcb_input_kbd_feedback_state_next (xcb_input_kbd_feedback_state_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_kbd_feedback_state_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_kbd_feedback_state_end (xcb_input_kbd_feedback_state_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_ptr_feedback_state_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_ptr_feedback_state_t)
*/
void
xcb_input_ptr_feedback_state_next (xcb_input_ptr_feedback_state_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_ptr_feedback_state_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_ptr_feedback_state_end (xcb_input_ptr_feedback_state_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_integer_feedback_state_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_integer_feedback_state_t)
*/
void
xcb_input_integer_feedback_state_next (xcb_input_integer_feedback_state_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_integer_feedback_state_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_integer_feedback_state_end (xcb_input_integer_feedback_state_iterator_t i);
int
xcb_input_string_feedback_state_sizeof (const void *_buffer);
xcb_keysym_t *
xcb_input_string_feedback_state_keysyms (const xcb_input_string_feedback_state_t *R);
int
xcb_input_string_feedback_state_keysyms_length (const xcb_input_string_feedback_state_t *R);
xcb_generic_iterator_t
xcb_input_string_feedback_state_keysyms_end (const xcb_input_string_feedback_state_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_string_feedback_state_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_string_feedback_state_t)
*/
void
xcb_input_string_feedback_state_next (xcb_input_string_feedback_state_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_string_feedback_state_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_string_feedback_state_end (xcb_input_string_feedback_state_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_bell_feedback_state_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_bell_feedback_state_t)
*/
void
xcb_input_bell_feedback_state_next (xcb_input_bell_feedback_state_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_bell_feedback_state_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_bell_feedback_state_end (xcb_input_bell_feedback_state_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_led_feedback_state_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_led_feedback_state_t)
*/
void
xcb_input_led_feedback_state_next (xcb_input_led_feedback_state_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_led_feedback_state_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_led_feedback_state_end (xcb_input_led_feedback_state_iterator_t i);
xcb_keysym_t *
xcb_input_feedback_state_data_string_keysyms (const xcb_input_feedback_state_data_t *S);
int
xcb_input_feedback_state_data_string_keysyms_length (const xcb_input_feedback_state_t *R,
const xcb_input_feedback_state_data_t *S);
xcb_generic_iterator_t
xcb_input_feedback_state_data_string_keysyms_end (const xcb_input_feedback_state_t *R,
const xcb_input_feedback_state_data_t *S);
int
xcb_input_feedback_state_data_serialize (void **_buffer,
uint8_t class_id,
const xcb_input_feedback_state_data_t *_aux);
int
xcb_input_feedback_state_data_unpack (const void *_buffer,
uint8_t class_id,
xcb_input_feedback_state_data_t *_aux);
int
xcb_input_feedback_state_data_sizeof (const void *_buffer,
uint8_t class_id);
int
xcb_input_feedback_state_sizeof (const void *_buffer);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_feedback_state_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_feedback_state_t)
*/
void
xcb_input_feedback_state_next (xcb_input_feedback_state_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_feedback_state_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_feedback_state_end (xcb_input_feedback_state_iterator_t i);
int
xcb_input_get_feedback_control_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_get_feedback_control_cookie_t
xcb_input_get_feedback_control (xcb_connection_t *c,
uint8_t device_id);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_get_feedback_control_cookie_t
xcb_input_get_feedback_control_unchecked (xcb_connection_t *c,
uint8_t device_id);
int
xcb_input_get_feedback_control_feedbacks_length (const xcb_input_get_feedback_control_reply_t *R);
xcb_input_feedback_state_iterator_t
xcb_input_get_feedback_control_feedbacks_iterator (const xcb_input_get_feedback_control_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_get_feedback_control_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_get_feedback_control_reply_t *
xcb_input_get_feedback_control_reply (xcb_connection_t *c,
xcb_input_get_feedback_control_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_kbd_feedback_ctl_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_kbd_feedback_ctl_t)
*/
void
xcb_input_kbd_feedback_ctl_next (xcb_input_kbd_feedback_ctl_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_kbd_feedback_ctl_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_kbd_feedback_ctl_end (xcb_input_kbd_feedback_ctl_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_ptr_feedback_ctl_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_ptr_feedback_ctl_t)
*/
void
xcb_input_ptr_feedback_ctl_next (xcb_input_ptr_feedback_ctl_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_ptr_feedback_ctl_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_ptr_feedback_ctl_end (xcb_input_ptr_feedback_ctl_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_integer_feedback_ctl_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_integer_feedback_ctl_t)
*/
void
xcb_input_integer_feedback_ctl_next (xcb_input_integer_feedback_ctl_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_integer_feedback_ctl_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_integer_feedback_ctl_end (xcb_input_integer_feedback_ctl_iterator_t i);
int
xcb_input_string_feedback_ctl_sizeof (const void *_buffer);
xcb_keysym_t *
xcb_input_string_feedback_ctl_keysyms (const xcb_input_string_feedback_ctl_t *R);
int
xcb_input_string_feedback_ctl_keysyms_length (const xcb_input_string_feedback_ctl_t *R);
xcb_generic_iterator_t
xcb_input_string_feedback_ctl_keysyms_end (const xcb_input_string_feedback_ctl_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_string_feedback_ctl_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_string_feedback_ctl_t)
*/
void
xcb_input_string_feedback_ctl_next (xcb_input_string_feedback_ctl_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_string_feedback_ctl_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_string_feedback_ctl_end (xcb_input_string_feedback_ctl_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_bell_feedback_ctl_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_bell_feedback_ctl_t)
*/
void
xcb_input_bell_feedback_ctl_next (xcb_input_bell_feedback_ctl_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_bell_feedback_ctl_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_bell_feedback_ctl_end (xcb_input_bell_feedback_ctl_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_led_feedback_ctl_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_led_feedback_ctl_t)
*/
void
xcb_input_led_feedback_ctl_next (xcb_input_led_feedback_ctl_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_led_feedback_ctl_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_led_feedback_ctl_end (xcb_input_led_feedback_ctl_iterator_t i);
xcb_keysym_t *
xcb_input_feedback_ctl_data_string_keysyms (const xcb_input_feedback_ctl_data_t *S);
int
xcb_input_feedback_ctl_data_string_keysyms_length (const xcb_input_feedback_ctl_t *R,
const xcb_input_feedback_ctl_data_t *S);
xcb_generic_iterator_t
xcb_input_feedback_ctl_data_string_keysyms_end (const xcb_input_feedback_ctl_t *R,
const xcb_input_feedback_ctl_data_t *S);
int
xcb_input_feedback_ctl_data_serialize (void **_buffer,
uint8_t class_id,
const xcb_input_feedback_ctl_data_t *_aux);
int
xcb_input_feedback_ctl_data_unpack (const void *_buffer,
uint8_t class_id,
xcb_input_feedback_ctl_data_t *_aux);
int
xcb_input_feedback_ctl_data_sizeof (const void *_buffer,
uint8_t class_id);
int
xcb_input_feedback_ctl_sizeof (const void *_buffer);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_feedback_ctl_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_feedback_ctl_t)
*/
void
xcb_input_feedback_ctl_next (xcb_input_feedback_ctl_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_feedback_ctl_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_feedback_ctl_end (xcb_input_feedback_ctl_iterator_t i);
int
xcb_input_change_feedback_control_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_input_change_feedback_control_checked (xcb_connection_t *c,
uint32_t mask,
uint8_t device_id,
uint8_t feedback_id,
xcb_input_feedback_ctl_t *feedback);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_input_change_feedback_control (xcb_connection_t *c,
uint32_t mask,
uint8_t device_id,
uint8_t feedback_id,
xcb_input_feedback_ctl_t *feedback);
xcb_input_feedback_ctl_t *
xcb_input_change_feedback_control_feedback (const xcb_input_change_feedback_control_request_t *R);
int
xcb_input_get_device_key_mapping_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_get_device_key_mapping_cookie_t
xcb_input_get_device_key_mapping (xcb_connection_t *c,
uint8_t device_id,
xcb_input_key_code_t first_keycode,
uint8_t count);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_get_device_key_mapping_cookie_t
xcb_input_get_device_key_mapping_unchecked (xcb_connection_t *c,
uint8_t device_id,
xcb_input_key_code_t first_keycode,
uint8_t count);
xcb_keysym_t *
xcb_input_get_device_key_mapping_keysyms (const xcb_input_get_device_key_mapping_reply_t *R);
int
xcb_input_get_device_key_mapping_keysyms_length (const xcb_input_get_device_key_mapping_reply_t *R);
xcb_generic_iterator_t
xcb_input_get_device_key_mapping_keysyms_end (const xcb_input_get_device_key_mapping_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_get_device_key_mapping_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_get_device_key_mapping_reply_t *
xcb_input_get_device_key_mapping_reply (xcb_connection_t *c,
xcb_input_get_device_key_mapping_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_input_change_device_key_mapping_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_input_change_device_key_mapping_checked (xcb_connection_t *c,
uint8_t device_id,
xcb_input_key_code_t first_keycode,
uint8_t keysyms_per_keycode,
uint8_t keycode_count,
const xcb_keysym_t *keysyms);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_input_change_device_key_mapping (xcb_connection_t *c,
uint8_t device_id,
xcb_input_key_code_t first_keycode,
uint8_t keysyms_per_keycode,
uint8_t keycode_count,
const xcb_keysym_t *keysyms);
xcb_keysym_t *
xcb_input_change_device_key_mapping_keysyms (const xcb_input_change_device_key_mapping_request_t *R);
int
xcb_input_change_device_key_mapping_keysyms_length (const xcb_input_change_device_key_mapping_request_t *R);
xcb_generic_iterator_t
xcb_input_change_device_key_mapping_keysyms_end (const xcb_input_change_device_key_mapping_request_t *R);
int
xcb_input_get_device_modifier_mapping_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_get_device_modifier_mapping_cookie_t
xcb_input_get_device_modifier_mapping (xcb_connection_t *c,
uint8_t device_id);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_get_device_modifier_mapping_cookie_t
xcb_input_get_device_modifier_mapping_unchecked (xcb_connection_t *c,
uint8_t device_id);
uint8_t *
xcb_input_get_device_modifier_mapping_keymaps (const xcb_input_get_device_modifier_mapping_reply_t *R);
int
xcb_input_get_device_modifier_mapping_keymaps_length (const xcb_input_get_device_modifier_mapping_reply_t *R);
xcb_generic_iterator_t
xcb_input_get_device_modifier_mapping_keymaps_end (const xcb_input_get_device_modifier_mapping_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_get_device_modifier_mapping_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_get_device_modifier_mapping_reply_t *
xcb_input_get_device_modifier_mapping_reply (xcb_connection_t *c,
xcb_input_get_device_modifier_mapping_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_input_set_device_modifier_mapping_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_set_device_modifier_mapping_cookie_t
xcb_input_set_device_modifier_mapping (xcb_connection_t *c,
uint8_t device_id,
uint8_t keycodes_per_modifier,
const uint8_t *keymaps);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_set_device_modifier_mapping_cookie_t
xcb_input_set_device_modifier_mapping_unchecked (xcb_connection_t *c,
uint8_t device_id,
uint8_t keycodes_per_modifier,
const uint8_t *keymaps);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_set_device_modifier_mapping_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_set_device_modifier_mapping_reply_t *
xcb_input_set_device_modifier_mapping_reply (xcb_connection_t *c,
xcb_input_set_device_modifier_mapping_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_input_get_device_button_mapping_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_get_device_button_mapping_cookie_t
xcb_input_get_device_button_mapping (xcb_connection_t *c,
uint8_t device_id);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_get_device_button_mapping_cookie_t
xcb_input_get_device_button_mapping_unchecked (xcb_connection_t *c,
uint8_t device_id);
uint8_t *
xcb_input_get_device_button_mapping_map (const xcb_input_get_device_button_mapping_reply_t *R);
int
xcb_input_get_device_button_mapping_map_length (const xcb_input_get_device_button_mapping_reply_t *R);
xcb_generic_iterator_t
xcb_input_get_device_button_mapping_map_end (const xcb_input_get_device_button_mapping_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_get_device_button_mapping_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_get_device_button_mapping_reply_t *
xcb_input_get_device_button_mapping_reply (xcb_connection_t *c,
xcb_input_get_device_button_mapping_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_input_set_device_button_mapping_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_set_device_button_mapping_cookie_t
xcb_input_set_device_button_mapping (xcb_connection_t *c,
uint8_t device_id,
uint8_t map_size,
const uint8_t *map);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_set_device_button_mapping_cookie_t
xcb_input_set_device_button_mapping_unchecked (xcb_connection_t *c,
uint8_t device_id,
uint8_t map_size,
const uint8_t *map);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_set_device_button_mapping_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_set_device_button_mapping_reply_t *
xcb_input_set_device_button_mapping_reply (xcb_connection_t *c,
xcb_input_set_device_button_mapping_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_key_state_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_key_state_t)
*/
void
xcb_input_key_state_next (xcb_input_key_state_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_key_state_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_key_state_end (xcb_input_key_state_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_button_state_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_button_state_t)
*/
void
xcb_input_button_state_next (xcb_input_button_state_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_button_state_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_button_state_end (xcb_input_button_state_iterator_t i);
int
xcb_input_valuator_state_sizeof (const void *_buffer);
int32_t *
xcb_input_valuator_state_valuators (const xcb_input_valuator_state_t *R);
int
xcb_input_valuator_state_valuators_length (const xcb_input_valuator_state_t *R);
xcb_generic_iterator_t
xcb_input_valuator_state_valuators_end (const xcb_input_valuator_state_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_valuator_state_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_valuator_state_t)
*/
void
xcb_input_valuator_state_next (xcb_input_valuator_state_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_valuator_state_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_valuator_state_end (xcb_input_valuator_state_iterator_t i);
int32_t *
xcb_input_input_state_data_valuator_valuators (const xcb_input_input_state_data_t *S);
int
xcb_input_input_state_data_valuator_valuators_length (const xcb_input_input_state_t *R,
const xcb_input_input_state_data_t *S);
xcb_generic_iterator_t
xcb_input_input_state_data_valuator_valuators_end (const xcb_input_input_state_t *R,
const xcb_input_input_state_data_t *S);
int
xcb_input_input_state_data_serialize (void **_buffer,
uint8_t class_id,
const xcb_input_input_state_data_t *_aux);
int
xcb_input_input_state_data_unpack (const void *_buffer,
uint8_t class_id,
xcb_input_input_state_data_t *_aux);
int
xcb_input_input_state_data_sizeof (const void *_buffer,
uint8_t class_id);
int
xcb_input_input_state_sizeof (const void *_buffer);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_input_state_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_input_state_t)
*/
void
xcb_input_input_state_next (xcb_input_input_state_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_input_state_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_input_state_end (xcb_input_input_state_iterator_t i);
int
xcb_input_query_device_state_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_query_device_state_cookie_t
xcb_input_query_device_state (xcb_connection_t *c,
uint8_t device_id);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_query_device_state_cookie_t
xcb_input_query_device_state_unchecked (xcb_connection_t *c,
uint8_t device_id);
int
xcb_input_query_device_state_classes_length (const xcb_input_query_device_state_reply_t *R);
xcb_input_input_state_iterator_t
xcb_input_query_device_state_classes_iterator (const xcb_input_query_device_state_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_query_device_state_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_query_device_state_reply_t *
xcb_input_query_device_state_reply (xcb_connection_t *c,
xcb_input_query_device_state_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_input_device_bell_checked (xcb_connection_t *c,
uint8_t device_id,
uint8_t feedback_id,
uint8_t feedback_class,
int8_t percent);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_input_device_bell (xcb_connection_t *c,
uint8_t device_id,
uint8_t feedback_id,
uint8_t feedback_class,
int8_t percent);
int
xcb_input_set_device_valuators_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_set_device_valuators_cookie_t
xcb_input_set_device_valuators (xcb_connection_t *c,
uint8_t device_id,
uint8_t first_valuator,
uint8_t num_valuators,
const int32_t *valuators);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_set_device_valuators_cookie_t
xcb_input_set_device_valuators_unchecked (xcb_connection_t *c,
uint8_t device_id,
uint8_t first_valuator,
uint8_t num_valuators,
const int32_t *valuators);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_set_device_valuators_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_set_device_valuators_reply_t *
xcb_input_set_device_valuators_reply (xcb_connection_t *c,
xcb_input_set_device_valuators_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_input_device_resolution_state_sizeof (const void *_buffer);
uint32_t *
xcb_input_device_resolution_state_resolution_values (const xcb_input_device_resolution_state_t *R);
int
xcb_input_device_resolution_state_resolution_values_length (const xcb_input_device_resolution_state_t *R);
xcb_generic_iterator_t
xcb_input_device_resolution_state_resolution_values_end (const xcb_input_device_resolution_state_t *R);
uint32_t *
xcb_input_device_resolution_state_resolution_min (const xcb_input_device_resolution_state_t *R);
int
xcb_input_device_resolution_state_resolution_min_length (const xcb_input_device_resolution_state_t *R);
xcb_generic_iterator_t
xcb_input_device_resolution_state_resolution_min_end (const xcb_input_device_resolution_state_t *R);
uint32_t *
xcb_input_device_resolution_state_resolution_max (const xcb_input_device_resolution_state_t *R);
int
xcb_input_device_resolution_state_resolution_max_length (const xcb_input_device_resolution_state_t *R);
xcb_generic_iterator_t
xcb_input_device_resolution_state_resolution_max_end (const xcb_input_device_resolution_state_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_device_resolution_state_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_device_resolution_state_t)
*/
void
xcb_input_device_resolution_state_next (xcb_input_device_resolution_state_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_device_resolution_state_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_device_resolution_state_end (xcb_input_device_resolution_state_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_device_abs_calib_state_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_device_abs_calib_state_t)
*/
void
xcb_input_device_abs_calib_state_next (xcb_input_device_abs_calib_state_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_device_abs_calib_state_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_device_abs_calib_state_end (xcb_input_device_abs_calib_state_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_device_abs_area_state_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_device_abs_area_state_t)
*/
void
xcb_input_device_abs_area_state_next (xcb_input_device_abs_area_state_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_device_abs_area_state_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_device_abs_area_state_end (xcb_input_device_abs_area_state_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_device_core_state_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_device_core_state_t)
*/
void
xcb_input_device_core_state_next (xcb_input_device_core_state_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_device_core_state_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_device_core_state_end (xcb_input_device_core_state_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_device_enable_state_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_device_enable_state_t)
*/
void
xcb_input_device_enable_state_next (xcb_input_device_enable_state_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_device_enable_state_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_device_enable_state_end (xcb_input_device_enable_state_iterator_t i);
uint32_t *
xcb_input_device_state_data_resolution_resolution_values (const xcb_input_device_state_data_t *S);
int
xcb_input_device_state_data_resolution_resolution_values_length (const xcb_input_device_state_t *R,
const xcb_input_device_state_data_t *S);
xcb_generic_iterator_t
xcb_input_device_state_data_resolution_resolution_values_end (const xcb_input_device_state_t *R,
const xcb_input_device_state_data_t *S);
uint32_t *
xcb_input_device_state_data_resolution_resolution_min (const xcb_input_device_state_data_t *S);
int
xcb_input_device_state_data_resolution_resolution_min_length (const xcb_input_device_state_t *R,
const xcb_input_device_state_data_t *S);
xcb_generic_iterator_t
xcb_input_device_state_data_resolution_resolution_min_end (const xcb_input_device_state_t *R,
const xcb_input_device_state_data_t *S);
uint32_t *
xcb_input_device_state_data_resolution_resolution_max (const xcb_input_device_state_data_t *S);
int
xcb_input_device_state_data_resolution_resolution_max_length (const xcb_input_device_state_t *R,
const xcb_input_device_state_data_t *S);
xcb_generic_iterator_t
xcb_input_device_state_data_resolution_resolution_max_end (const xcb_input_device_state_t *R,
const xcb_input_device_state_data_t *S);
int
xcb_input_device_state_data_serialize (void **_buffer,
uint16_t control_id,
const xcb_input_device_state_data_t *_aux);
int
xcb_input_device_state_data_unpack (const void *_buffer,
uint16_t control_id,
xcb_input_device_state_data_t *_aux);
int
xcb_input_device_state_data_sizeof (const void *_buffer,
uint16_t control_id);
int
xcb_input_device_state_sizeof (const void *_buffer);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_device_state_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_device_state_t)
*/
void
xcb_input_device_state_next (xcb_input_device_state_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_device_state_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_device_state_end (xcb_input_device_state_iterator_t i);
int
xcb_input_get_device_control_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_get_device_control_cookie_t
xcb_input_get_device_control (xcb_connection_t *c,
uint16_t control_id,
uint8_t device_id);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_get_device_control_cookie_t
xcb_input_get_device_control_unchecked (xcb_connection_t *c,
uint16_t control_id,
uint8_t device_id);
xcb_input_device_state_t *
xcb_input_get_device_control_control (const xcb_input_get_device_control_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_get_device_control_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_get_device_control_reply_t *
xcb_input_get_device_control_reply (xcb_connection_t *c,
xcb_input_get_device_control_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_input_device_resolution_ctl_sizeof (const void *_buffer);
uint32_t *
xcb_input_device_resolution_ctl_resolution_values (const xcb_input_device_resolution_ctl_t *R);
int
xcb_input_device_resolution_ctl_resolution_values_length (const xcb_input_device_resolution_ctl_t *R);
xcb_generic_iterator_t
xcb_input_device_resolution_ctl_resolution_values_end (const xcb_input_device_resolution_ctl_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_device_resolution_ctl_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_device_resolution_ctl_t)
*/
void
xcb_input_device_resolution_ctl_next (xcb_input_device_resolution_ctl_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_device_resolution_ctl_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_device_resolution_ctl_end (xcb_input_device_resolution_ctl_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_device_abs_calib_ctl_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_device_abs_calib_ctl_t)
*/
void
xcb_input_device_abs_calib_ctl_next (xcb_input_device_abs_calib_ctl_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_device_abs_calib_ctl_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_device_abs_calib_ctl_end (xcb_input_device_abs_calib_ctl_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_device_abs_area_ctrl_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_device_abs_area_ctrl_t)
*/
void
xcb_input_device_abs_area_ctrl_next (xcb_input_device_abs_area_ctrl_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_device_abs_area_ctrl_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_device_abs_area_ctrl_end (xcb_input_device_abs_area_ctrl_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_device_core_ctrl_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_device_core_ctrl_t)
*/
void
xcb_input_device_core_ctrl_next (xcb_input_device_core_ctrl_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_device_core_ctrl_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_device_core_ctrl_end (xcb_input_device_core_ctrl_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_device_enable_ctrl_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_device_enable_ctrl_t)
*/
void
xcb_input_device_enable_ctrl_next (xcb_input_device_enable_ctrl_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_device_enable_ctrl_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_device_enable_ctrl_end (xcb_input_device_enable_ctrl_iterator_t i);
uint32_t *
xcb_input_device_ctl_data_resolution_resolution_values (const xcb_input_device_ctl_data_t *S);
int
xcb_input_device_ctl_data_resolution_resolution_values_length (const xcb_input_device_ctl_t *R,
const xcb_input_device_ctl_data_t *S);
xcb_generic_iterator_t
xcb_input_device_ctl_data_resolution_resolution_values_end (const xcb_input_device_ctl_t *R,
const xcb_input_device_ctl_data_t *S);
int
xcb_input_device_ctl_data_serialize (void **_buffer,
uint16_t control_id,
const xcb_input_device_ctl_data_t *_aux);
int
xcb_input_device_ctl_data_unpack (const void *_buffer,
uint16_t control_id,
xcb_input_device_ctl_data_t *_aux);
int
xcb_input_device_ctl_data_sizeof (const void *_buffer,
uint16_t control_id);
int
xcb_input_device_ctl_sizeof (const void *_buffer);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_device_ctl_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_device_ctl_t)
*/
void
xcb_input_device_ctl_next (xcb_input_device_ctl_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_device_ctl_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_device_ctl_end (xcb_input_device_ctl_iterator_t i);
int
xcb_input_change_device_control_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_change_device_control_cookie_t
xcb_input_change_device_control (xcb_connection_t *c,
uint16_t control_id,
uint8_t device_id,
xcb_input_device_ctl_t *control);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_change_device_control_cookie_t
xcb_input_change_device_control_unchecked (xcb_connection_t *c,
uint16_t control_id,
uint8_t device_id,
xcb_input_device_ctl_t *control);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_change_device_control_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_change_device_control_reply_t *
xcb_input_change_device_control_reply (xcb_connection_t *c,
xcb_input_change_device_control_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_input_list_device_properties_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_list_device_properties_cookie_t
xcb_input_list_device_properties (xcb_connection_t *c,
uint8_t device_id);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_list_device_properties_cookie_t
xcb_input_list_device_properties_unchecked (xcb_connection_t *c,
uint8_t device_id);
xcb_atom_t *
xcb_input_list_device_properties_atoms (const xcb_input_list_device_properties_reply_t *R);
int
xcb_input_list_device_properties_atoms_length (const xcb_input_list_device_properties_reply_t *R);
xcb_generic_iterator_t
xcb_input_list_device_properties_atoms_end (const xcb_input_list_device_properties_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_list_device_properties_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_list_device_properties_reply_t *
xcb_input_list_device_properties_reply (xcb_connection_t *c,
xcb_input_list_device_properties_cookie_t cookie /**< */,
xcb_generic_error_t **e);
uint8_t *
xcb_input_change_device_property_items_data_8 (const xcb_input_change_device_property_items_t *S);
int
xcb_input_change_device_property_items_data_8_length (const xcb_input_change_device_property_request_t *R,
const xcb_input_change_device_property_items_t *S);
xcb_generic_iterator_t
xcb_input_change_device_property_items_data_8_end (const xcb_input_change_device_property_request_t *R,
const xcb_input_change_device_property_items_t *S);
uint16_t *
xcb_input_change_device_property_items_data_16 (const xcb_input_change_device_property_items_t *S);
int
xcb_input_change_device_property_items_data_16_length (const xcb_input_change_device_property_request_t *R,
const xcb_input_change_device_property_items_t *S);
xcb_generic_iterator_t
xcb_input_change_device_property_items_data_16_end (const xcb_input_change_device_property_request_t *R,
const xcb_input_change_device_property_items_t *S);
uint32_t *
xcb_input_change_device_property_items_data_32 (const xcb_input_change_device_property_items_t *S);
int
xcb_input_change_device_property_items_data_32_length (const xcb_input_change_device_property_request_t *R,
const xcb_input_change_device_property_items_t *S);
xcb_generic_iterator_t
xcb_input_change_device_property_items_data_32_end (const xcb_input_change_device_property_request_t *R,
const xcb_input_change_device_property_items_t *S);
int
xcb_input_change_device_property_items_serialize (void **_buffer,
uint32_t num_items,
uint8_t format,
const xcb_input_change_device_property_items_t *_aux);
int
xcb_input_change_device_property_items_unpack (const void *_buffer,
uint32_t num_items,
uint8_t format,
xcb_input_change_device_property_items_t *_aux);
int
xcb_input_change_device_property_items_sizeof (const void *_buffer,
uint32_t num_items,
uint8_t format);
int
xcb_input_change_device_property_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_input_change_device_property_checked (xcb_connection_t *c,
xcb_atom_t property,
xcb_atom_t type,
uint8_t device_id,
uint8_t format,
uint8_t mode,
uint32_t num_items,
const void *items);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_input_change_device_property (xcb_connection_t *c,
xcb_atom_t property,
xcb_atom_t type,
uint8_t device_id,
uint8_t format,
uint8_t mode,
uint32_t num_items,
const void *items);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_input_change_device_property_aux_checked (xcb_connection_t *c,
xcb_atom_t property,
xcb_atom_t type,
uint8_t device_id,
uint8_t format,
uint8_t mode,
uint32_t num_items,
const xcb_input_change_device_property_items_t *items);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_input_change_device_property_aux (xcb_connection_t *c,
xcb_atom_t property,
xcb_atom_t type,
uint8_t device_id,
uint8_t format,
uint8_t mode,
uint32_t num_items,
const xcb_input_change_device_property_items_t *items);
void *
xcb_input_change_device_property_items (const xcb_input_change_device_property_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_input_delete_device_property_checked (xcb_connection_t *c,
xcb_atom_t property,
uint8_t device_id);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_input_delete_device_property (xcb_connection_t *c,
xcb_atom_t property,
uint8_t device_id);
uint8_t *
xcb_input_get_device_property_items_data_8 (const xcb_input_get_device_property_items_t *S);
int
xcb_input_get_device_property_items_data_8_length (const xcb_input_get_device_property_reply_t *R,
const xcb_input_get_device_property_items_t *S);
xcb_generic_iterator_t
xcb_input_get_device_property_items_data_8_end (const xcb_input_get_device_property_reply_t *R,
const xcb_input_get_device_property_items_t *S);
uint16_t *
xcb_input_get_device_property_items_data_16 (const xcb_input_get_device_property_items_t *S);
int
xcb_input_get_device_property_items_data_16_length (const xcb_input_get_device_property_reply_t *R,
const xcb_input_get_device_property_items_t *S);
xcb_generic_iterator_t
xcb_input_get_device_property_items_data_16_end (const xcb_input_get_device_property_reply_t *R,
const xcb_input_get_device_property_items_t *S);
uint32_t *
xcb_input_get_device_property_items_data_32 (const xcb_input_get_device_property_items_t *S);
int
xcb_input_get_device_property_items_data_32_length (const xcb_input_get_device_property_reply_t *R,
const xcb_input_get_device_property_items_t *S);
xcb_generic_iterator_t
xcb_input_get_device_property_items_data_32_end (const xcb_input_get_device_property_reply_t *R,
const xcb_input_get_device_property_items_t *S);
int
xcb_input_get_device_property_items_serialize (void **_buffer,
uint32_t num_items,
uint8_t format,
const xcb_input_get_device_property_items_t *_aux);
int
xcb_input_get_device_property_items_unpack (const void *_buffer,
uint32_t num_items,
uint8_t format,
xcb_input_get_device_property_items_t *_aux);
int
xcb_input_get_device_property_items_sizeof (const void *_buffer,
uint32_t num_items,
uint8_t format);
int
xcb_input_get_device_property_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_get_device_property_cookie_t
xcb_input_get_device_property (xcb_connection_t *c,
xcb_atom_t property,
xcb_atom_t type,
uint32_t offset,
uint32_t len,
uint8_t device_id,
uint8_t _delete);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_get_device_property_cookie_t
xcb_input_get_device_property_unchecked (xcb_connection_t *c,
xcb_atom_t property,
xcb_atom_t type,
uint32_t offset,
uint32_t len,
uint8_t device_id,
uint8_t _delete);
void *
xcb_input_get_device_property_items (const xcb_input_get_device_property_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_get_device_property_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_get_device_property_reply_t *
xcb_input_get_device_property_reply (xcb_connection_t *c,
xcb_input_get_device_property_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_group_info_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_group_info_t)
*/
void
xcb_input_group_info_next (xcb_input_group_info_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_group_info_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_group_info_end (xcb_input_group_info_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_modifier_info_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_modifier_info_t)
*/
void
xcb_input_modifier_info_next (xcb_input_modifier_info_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_modifier_info_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_modifier_info_end (xcb_input_modifier_info_iterator_t i);
int
xcb_input_xi_query_pointer_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_xi_query_pointer_cookie_t
xcb_input_xi_query_pointer (xcb_connection_t *c,
xcb_window_t window,
xcb_input_device_id_t deviceid);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_xi_query_pointer_cookie_t
xcb_input_xi_query_pointer_unchecked (xcb_connection_t *c,
xcb_window_t window,
xcb_input_device_id_t deviceid);
uint32_t *
xcb_input_xi_query_pointer_buttons (const xcb_input_xi_query_pointer_reply_t *R);
int
xcb_input_xi_query_pointer_buttons_length (const xcb_input_xi_query_pointer_reply_t *R);
xcb_generic_iterator_t
xcb_input_xi_query_pointer_buttons_end (const xcb_input_xi_query_pointer_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_xi_query_pointer_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_xi_query_pointer_reply_t *
xcb_input_xi_query_pointer_reply (xcb_connection_t *c,
xcb_input_xi_query_pointer_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_input_xi_warp_pointer_checked (xcb_connection_t *c,
xcb_window_t src_win,
xcb_window_t dst_win,
xcb_input_fp1616_t src_x,
xcb_input_fp1616_t src_y,
uint16_t src_width,
uint16_t src_height,
xcb_input_fp1616_t dst_x,
xcb_input_fp1616_t dst_y,
xcb_input_device_id_t deviceid);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_input_xi_warp_pointer (xcb_connection_t *c,
xcb_window_t src_win,
xcb_window_t dst_win,
xcb_input_fp1616_t src_x,
xcb_input_fp1616_t src_y,
uint16_t src_width,
uint16_t src_height,
xcb_input_fp1616_t dst_x,
xcb_input_fp1616_t dst_y,
xcb_input_device_id_t deviceid);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_input_xi_change_cursor_checked (xcb_connection_t *c,
xcb_window_t window,
xcb_cursor_t cursor,
xcb_input_device_id_t deviceid);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_input_xi_change_cursor (xcb_connection_t *c,
xcb_window_t window,
xcb_cursor_t cursor,
xcb_input_device_id_t deviceid);
int
xcb_input_add_master_sizeof (const void *_buffer);
char *
xcb_input_add_master_name (const xcb_input_add_master_t *R);
int
xcb_input_add_master_name_length (const xcb_input_add_master_t *R);
xcb_generic_iterator_t
xcb_input_add_master_name_end (const xcb_input_add_master_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_add_master_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_add_master_t)
*/
void
xcb_input_add_master_next (xcb_input_add_master_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_add_master_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_add_master_end (xcb_input_add_master_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_remove_master_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_remove_master_t)
*/
void
xcb_input_remove_master_next (xcb_input_remove_master_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_remove_master_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_remove_master_end (xcb_input_remove_master_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_attach_slave_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_attach_slave_t)
*/
void
xcb_input_attach_slave_next (xcb_input_attach_slave_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_attach_slave_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_attach_slave_end (xcb_input_attach_slave_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_detach_slave_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_detach_slave_t)
*/
void
xcb_input_detach_slave_next (xcb_input_detach_slave_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_detach_slave_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_detach_slave_end (xcb_input_detach_slave_iterator_t i);
char *
xcb_input_hierarchy_change_data_add_master_name (const xcb_input_hierarchy_change_data_t *S);
int
xcb_input_hierarchy_change_data_add_master_name_length (const xcb_input_hierarchy_change_t *R,
const xcb_input_hierarchy_change_data_t *S);
xcb_generic_iterator_t
xcb_input_hierarchy_change_data_add_master_name_end (const xcb_input_hierarchy_change_t *R,
const xcb_input_hierarchy_change_data_t *S);
int
xcb_input_hierarchy_change_data_serialize (void **_buffer,
uint16_t type,
const xcb_input_hierarchy_change_data_t *_aux);
int
xcb_input_hierarchy_change_data_unpack (const void *_buffer,
uint16_t type,
xcb_input_hierarchy_change_data_t *_aux);
int
xcb_input_hierarchy_change_data_sizeof (const void *_buffer,
uint16_t type);
int
xcb_input_hierarchy_change_sizeof (const void *_buffer);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_hierarchy_change_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_hierarchy_change_t)
*/
void
xcb_input_hierarchy_change_next (xcb_input_hierarchy_change_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_hierarchy_change_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_hierarchy_change_end (xcb_input_hierarchy_change_iterator_t i);
int
xcb_input_xi_change_hierarchy_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_input_xi_change_hierarchy_checked (xcb_connection_t *c,
uint8_t num_changes,
const xcb_input_hierarchy_change_t *changes);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_input_xi_change_hierarchy (xcb_connection_t *c,
uint8_t num_changes,
const xcb_input_hierarchy_change_t *changes);
int
xcb_input_xi_change_hierarchy_changes_length (const xcb_input_xi_change_hierarchy_request_t *R);
xcb_input_hierarchy_change_iterator_t
xcb_input_xi_change_hierarchy_changes_iterator (const xcb_input_xi_change_hierarchy_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_input_xi_set_client_pointer_checked (xcb_connection_t *c,
xcb_window_t window,
xcb_input_device_id_t deviceid);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_input_xi_set_client_pointer (xcb_connection_t *c,
xcb_window_t window,
xcb_input_device_id_t deviceid);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_xi_get_client_pointer_cookie_t
xcb_input_xi_get_client_pointer (xcb_connection_t *c,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_xi_get_client_pointer_cookie_t
xcb_input_xi_get_client_pointer_unchecked (xcb_connection_t *c,
xcb_window_t window);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_xi_get_client_pointer_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_xi_get_client_pointer_reply_t *
xcb_input_xi_get_client_pointer_reply (xcb_connection_t *c,
xcb_input_xi_get_client_pointer_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_input_event_mask_sizeof (const void *_buffer);
uint32_t *
xcb_input_event_mask_mask (const xcb_input_event_mask_t *R);
int
xcb_input_event_mask_mask_length (const xcb_input_event_mask_t *R);
xcb_generic_iterator_t
xcb_input_event_mask_mask_end (const xcb_input_event_mask_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_event_mask_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_event_mask_t)
*/
void
xcb_input_event_mask_next (xcb_input_event_mask_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_event_mask_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_event_mask_end (xcb_input_event_mask_iterator_t i);
int
xcb_input_xi_select_events_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_input_xi_select_events_checked (xcb_connection_t *c,
xcb_window_t window,
uint16_t num_mask,
const xcb_input_event_mask_t *masks);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_input_xi_select_events (xcb_connection_t *c,
xcb_window_t window,
uint16_t num_mask,
const xcb_input_event_mask_t *masks);
int
xcb_input_xi_select_events_masks_length (const xcb_input_xi_select_events_request_t *R);
xcb_input_event_mask_iterator_t
xcb_input_xi_select_events_masks_iterator (const xcb_input_xi_select_events_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_xi_query_version_cookie_t
xcb_input_xi_query_version (xcb_connection_t *c,
uint16_t major_version,
uint16_t minor_version);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_xi_query_version_cookie_t
xcb_input_xi_query_version_unchecked (xcb_connection_t *c,
uint16_t major_version,
uint16_t minor_version);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_xi_query_version_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_xi_query_version_reply_t *
xcb_input_xi_query_version_reply (xcb_connection_t *c,
xcb_input_xi_query_version_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_input_button_class_sizeof (const void *_buffer);
uint32_t *
xcb_input_button_class_state (const xcb_input_button_class_t *R);
int
xcb_input_button_class_state_length (const xcb_input_button_class_t *R);
xcb_generic_iterator_t
xcb_input_button_class_state_end (const xcb_input_button_class_t *R);
xcb_atom_t *
xcb_input_button_class_labels (const xcb_input_button_class_t *R);
int
xcb_input_button_class_labels_length (const xcb_input_button_class_t *R);
xcb_generic_iterator_t
xcb_input_button_class_labels_end (const xcb_input_button_class_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_button_class_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_button_class_t)
*/
void
xcb_input_button_class_next (xcb_input_button_class_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_button_class_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_button_class_end (xcb_input_button_class_iterator_t i);
int
xcb_input_key_class_sizeof (const void *_buffer);
uint32_t *
xcb_input_key_class_keys (const xcb_input_key_class_t *R);
int
xcb_input_key_class_keys_length (const xcb_input_key_class_t *R);
xcb_generic_iterator_t
xcb_input_key_class_keys_end (const xcb_input_key_class_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_key_class_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_key_class_t)
*/
void
xcb_input_key_class_next (xcb_input_key_class_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_key_class_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_key_class_end (xcb_input_key_class_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_scroll_class_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_scroll_class_t)
*/
void
xcb_input_scroll_class_next (xcb_input_scroll_class_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_scroll_class_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_scroll_class_end (xcb_input_scroll_class_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_touch_class_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_touch_class_t)
*/
void
xcb_input_touch_class_next (xcb_input_touch_class_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_touch_class_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_touch_class_end (xcb_input_touch_class_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_valuator_class_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_valuator_class_t)
*/
void
xcb_input_valuator_class_next (xcb_input_valuator_class_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_valuator_class_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_valuator_class_end (xcb_input_valuator_class_iterator_t i);
uint32_t *
xcb_input_device_class_data_key_keys (const xcb_input_device_class_data_t *S);
int
xcb_input_device_class_data_key_keys_length (const xcb_input_device_class_t *R,
const xcb_input_device_class_data_t *S);
xcb_generic_iterator_t
xcb_input_device_class_data_key_keys_end (const xcb_input_device_class_t *R,
const xcb_input_device_class_data_t *S);
uint32_t *
xcb_input_device_class_data_button_state (const xcb_input_device_class_data_t *S);
int
xcb_input_device_class_data_button_state_length (const xcb_input_device_class_t *R,
const xcb_input_device_class_data_t *S);
xcb_generic_iterator_t
xcb_input_device_class_data_button_state_end (const xcb_input_device_class_t *R,
const xcb_input_device_class_data_t *S);
xcb_atom_t *
xcb_input_device_class_data_button_labels (const xcb_input_device_class_data_t *S);
int
xcb_input_device_class_data_button_labels_length (const xcb_input_device_class_t *R,
const xcb_input_device_class_data_t *S);
xcb_generic_iterator_t
xcb_input_device_class_data_button_labels_end (const xcb_input_device_class_t *R,
const xcb_input_device_class_data_t *S);
int
xcb_input_device_class_data_serialize (void **_buffer,
uint16_t type,
const xcb_input_device_class_data_t *_aux);
int
xcb_input_device_class_data_unpack (const void *_buffer,
uint16_t type,
xcb_input_device_class_data_t *_aux);
int
xcb_input_device_class_data_sizeof (const void *_buffer,
uint16_t type);
int
xcb_input_device_class_sizeof (const void *_buffer);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_device_class_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_device_class_t)
*/
void
xcb_input_device_class_next (xcb_input_device_class_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_device_class_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_device_class_end (xcb_input_device_class_iterator_t i);
int
xcb_input_xi_device_info_sizeof (const void *_buffer);
char *
xcb_input_xi_device_info_name (const xcb_input_xi_device_info_t *R);
int
xcb_input_xi_device_info_name_length (const xcb_input_xi_device_info_t *R);
xcb_generic_iterator_t
xcb_input_xi_device_info_name_end (const xcb_input_xi_device_info_t *R);
int
xcb_input_xi_device_info_classes_length (const xcb_input_xi_device_info_t *R);
xcb_input_device_class_iterator_t
xcb_input_xi_device_info_classes_iterator (const xcb_input_xi_device_info_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_xi_device_info_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_xi_device_info_t)
*/
void
xcb_input_xi_device_info_next (xcb_input_xi_device_info_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_xi_device_info_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_xi_device_info_end (xcb_input_xi_device_info_iterator_t i);
int
xcb_input_xi_query_device_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_xi_query_device_cookie_t
xcb_input_xi_query_device (xcb_connection_t *c,
xcb_input_device_id_t deviceid);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_xi_query_device_cookie_t
xcb_input_xi_query_device_unchecked (xcb_connection_t *c,
xcb_input_device_id_t deviceid);
int
xcb_input_xi_query_device_infos_length (const xcb_input_xi_query_device_reply_t *R);
xcb_input_xi_device_info_iterator_t
xcb_input_xi_query_device_infos_iterator (const xcb_input_xi_query_device_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_xi_query_device_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_xi_query_device_reply_t *
xcb_input_xi_query_device_reply (xcb_connection_t *c,
xcb_input_xi_query_device_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_input_xi_set_focus_checked (xcb_connection_t *c,
xcb_window_t window,
xcb_timestamp_t time,
xcb_input_device_id_t deviceid);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_input_xi_set_focus (xcb_connection_t *c,
xcb_window_t window,
xcb_timestamp_t time,
xcb_input_device_id_t deviceid);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_xi_get_focus_cookie_t
xcb_input_xi_get_focus (xcb_connection_t *c,
xcb_input_device_id_t deviceid);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_xi_get_focus_cookie_t
xcb_input_xi_get_focus_unchecked (xcb_connection_t *c,
xcb_input_device_id_t deviceid);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_xi_get_focus_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_xi_get_focus_reply_t *
xcb_input_xi_get_focus_reply (xcb_connection_t *c,
xcb_input_xi_get_focus_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_input_xi_grab_device_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_xi_grab_device_cookie_t
xcb_input_xi_grab_device (xcb_connection_t *c,
xcb_window_t window,
xcb_timestamp_t time,
xcb_cursor_t cursor,
xcb_input_device_id_t deviceid,
uint8_t mode,
uint8_t paired_device_mode,
uint8_t owner_events,
uint16_t mask_len,
const uint32_t *mask);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_xi_grab_device_cookie_t
xcb_input_xi_grab_device_unchecked (xcb_connection_t *c,
xcb_window_t window,
xcb_timestamp_t time,
xcb_cursor_t cursor,
xcb_input_device_id_t deviceid,
uint8_t mode,
uint8_t paired_device_mode,
uint8_t owner_events,
uint16_t mask_len,
const uint32_t *mask);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_xi_grab_device_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_xi_grab_device_reply_t *
xcb_input_xi_grab_device_reply (xcb_connection_t *c,
xcb_input_xi_grab_device_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_input_xi_ungrab_device_checked (xcb_connection_t *c,
xcb_timestamp_t time,
xcb_input_device_id_t deviceid);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_input_xi_ungrab_device (xcb_connection_t *c,
xcb_timestamp_t time,
xcb_input_device_id_t deviceid);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_input_xi_allow_events_checked (xcb_connection_t *c,
xcb_timestamp_t time,
xcb_input_device_id_t deviceid,
uint8_t event_mode,
uint32_t touchid,
xcb_window_t grab_window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_input_xi_allow_events (xcb_connection_t *c,
xcb_timestamp_t time,
xcb_input_device_id_t deviceid,
uint8_t event_mode,
uint32_t touchid,
xcb_window_t grab_window);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_grab_modifier_info_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_grab_modifier_info_t)
*/
void
xcb_input_grab_modifier_info_next (xcb_input_grab_modifier_info_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_grab_modifier_info_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_grab_modifier_info_end (xcb_input_grab_modifier_info_iterator_t i);
int
xcb_input_xi_passive_grab_device_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_xi_passive_grab_device_cookie_t
xcb_input_xi_passive_grab_device (xcb_connection_t *c,
xcb_timestamp_t time,
xcb_window_t grab_window,
xcb_cursor_t cursor,
uint32_t detail,
xcb_input_device_id_t deviceid,
uint16_t num_modifiers,
uint16_t mask_len,
uint8_t grab_type,
uint8_t grab_mode,
uint8_t paired_device_mode,
uint8_t owner_events,
const uint32_t *mask,
const uint32_t *modifiers);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_xi_passive_grab_device_cookie_t
xcb_input_xi_passive_grab_device_unchecked (xcb_connection_t *c,
xcb_timestamp_t time,
xcb_window_t grab_window,
xcb_cursor_t cursor,
uint32_t detail,
xcb_input_device_id_t deviceid,
uint16_t num_modifiers,
uint16_t mask_len,
uint8_t grab_type,
uint8_t grab_mode,
uint8_t paired_device_mode,
uint8_t owner_events,
const uint32_t *mask,
const uint32_t *modifiers);
xcb_input_grab_modifier_info_t *
xcb_input_xi_passive_grab_device_modifiers (const xcb_input_xi_passive_grab_device_reply_t *R);
int
xcb_input_xi_passive_grab_device_modifiers_length (const xcb_input_xi_passive_grab_device_reply_t *R);
xcb_input_grab_modifier_info_iterator_t
xcb_input_xi_passive_grab_device_modifiers_iterator (const xcb_input_xi_passive_grab_device_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_xi_passive_grab_device_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_xi_passive_grab_device_reply_t *
xcb_input_xi_passive_grab_device_reply (xcb_connection_t *c,
xcb_input_xi_passive_grab_device_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_input_xi_passive_ungrab_device_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_input_xi_passive_ungrab_device_checked (xcb_connection_t *c,
xcb_window_t grab_window,
uint32_t detail,
xcb_input_device_id_t deviceid,
uint16_t num_modifiers,
uint8_t grab_type,
const uint32_t *modifiers);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_input_xi_passive_ungrab_device (xcb_connection_t *c,
xcb_window_t grab_window,
uint32_t detail,
xcb_input_device_id_t deviceid,
uint16_t num_modifiers,
uint8_t grab_type,
const uint32_t *modifiers);
uint32_t *
xcb_input_xi_passive_ungrab_device_modifiers (const xcb_input_xi_passive_ungrab_device_request_t *R);
int
xcb_input_xi_passive_ungrab_device_modifiers_length (const xcb_input_xi_passive_ungrab_device_request_t *R);
xcb_generic_iterator_t
xcb_input_xi_passive_ungrab_device_modifiers_end (const xcb_input_xi_passive_ungrab_device_request_t *R);
int
xcb_input_xi_list_properties_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_xi_list_properties_cookie_t
xcb_input_xi_list_properties (xcb_connection_t *c,
xcb_input_device_id_t deviceid);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_xi_list_properties_cookie_t
xcb_input_xi_list_properties_unchecked (xcb_connection_t *c,
xcb_input_device_id_t deviceid);
xcb_atom_t *
xcb_input_xi_list_properties_properties (const xcb_input_xi_list_properties_reply_t *R);
int
xcb_input_xi_list_properties_properties_length (const xcb_input_xi_list_properties_reply_t *R);
xcb_generic_iterator_t
xcb_input_xi_list_properties_properties_end (const xcb_input_xi_list_properties_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_xi_list_properties_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_xi_list_properties_reply_t *
xcb_input_xi_list_properties_reply (xcb_connection_t *c,
xcb_input_xi_list_properties_cookie_t cookie /**< */,
xcb_generic_error_t **e);
uint8_t *
xcb_input_xi_change_property_items_data_8 (const xcb_input_xi_change_property_items_t *S);
int
xcb_input_xi_change_property_items_data_8_length (const xcb_input_xi_change_property_request_t *R,
const xcb_input_xi_change_property_items_t *S);
xcb_generic_iterator_t
xcb_input_xi_change_property_items_data_8_end (const xcb_input_xi_change_property_request_t *R,
const xcb_input_xi_change_property_items_t *S);
uint16_t *
xcb_input_xi_change_property_items_data_16 (const xcb_input_xi_change_property_items_t *S);
int
xcb_input_xi_change_property_items_data_16_length (const xcb_input_xi_change_property_request_t *R,
const xcb_input_xi_change_property_items_t *S);
xcb_generic_iterator_t
xcb_input_xi_change_property_items_data_16_end (const xcb_input_xi_change_property_request_t *R,
const xcb_input_xi_change_property_items_t *S);
uint32_t *
xcb_input_xi_change_property_items_data_32 (const xcb_input_xi_change_property_items_t *S);
int
xcb_input_xi_change_property_items_data_32_length (const xcb_input_xi_change_property_request_t *R,
const xcb_input_xi_change_property_items_t *S);
xcb_generic_iterator_t
xcb_input_xi_change_property_items_data_32_end (const xcb_input_xi_change_property_request_t *R,
const xcb_input_xi_change_property_items_t *S);
int
xcb_input_xi_change_property_items_serialize (void **_buffer,
uint32_t num_items,
uint8_t format,
const xcb_input_xi_change_property_items_t *_aux);
int
xcb_input_xi_change_property_items_unpack (const void *_buffer,
uint32_t num_items,
uint8_t format,
xcb_input_xi_change_property_items_t *_aux);
int
xcb_input_xi_change_property_items_sizeof (const void *_buffer,
uint32_t num_items,
uint8_t format);
int
xcb_input_xi_change_property_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_input_xi_change_property_checked (xcb_connection_t *c,
xcb_input_device_id_t deviceid,
uint8_t mode,
uint8_t format,
xcb_atom_t property,
xcb_atom_t type,
uint32_t num_items,
const void *items);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_input_xi_change_property (xcb_connection_t *c,
xcb_input_device_id_t deviceid,
uint8_t mode,
uint8_t format,
xcb_atom_t property,
xcb_atom_t type,
uint32_t num_items,
const void *items);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_input_xi_change_property_aux_checked (xcb_connection_t *c,
xcb_input_device_id_t deviceid,
uint8_t mode,
uint8_t format,
xcb_atom_t property,
xcb_atom_t type,
uint32_t num_items,
const xcb_input_xi_change_property_items_t *items);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_input_xi_change_property_aux (xcb_connection_t *c,
xcb_input_device_id_t deviceid,
uint8_t mode,
uint8_t format,
xcb_atom_t property,
xcb_atom_t type,
uint32_t num_items,
const xcb_input_xi_change_property_items_t *items);
void *
xcb_input_xi_change_property_items (const xcb_input_xi_change_property_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_input_xi_delete_property_checked (xcb_connection_t *c,
xcb_input_device_id_t deviceid,
xcb_atom_t property);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_input_xi_delete_property (xcb_connection_t *c,
xcb_input_device_id_t deviceid,
xcb_atom_t property);
uint8_t *
xcb_input_xi_get_property_items_data_8 (const xcb_input_xi_get_property_items_t *S);
int
xcb_input_xi_get_property_items_data_8_length (const xcb_input_xi_get_property_reply_t *R,
const xcb_input_xi_get_property_items_t *S);
xcb_generic_iterator_t
xcb_input_xi_get_property_items_data_8_end (const xcb_input_xi_get_property_reply_t *R,
const xcb_input_xi_get_property_items_t *S);
uint16_t *
xcb_input_xi_get_property_items_data_16 (const xcb_input_xi_get_property_items_t *S);
int
xcb_input_xi_get_property_items_data_16_length (const xcb_input_xi_get_property_reply_t *R,
const xcb_input_xi_get_property_items_t *S);
xcb_generic_iterator_t
xcb_input_xi_get_property_items_data_16_end (const xcb_input_xi_get_property_reply_t *R,
const xcb_input_xi_get_property_items_t *S);
uint32_t *
xcb_input_xi_get_property_items_data_32 (const xcb_input_xi_get_property_items_t *S);
int
xcb_input_xi_get_property_items_data_32_length (const xcb_input_xi_get_property_reply_t *R,
const xcb_input_xi_get_property_items_t *S);
xcb_generic_iterator_t
xcb_input_xi_get_property_items_data_32_end (const xcb_input_xi_get_property_reply_t *R,
const xcb_input_xi_get_property_items_t *S);
int
xcb_input_xi_get_property_items_serialize (void **_buffer,
uint32_t num_items,
uint8_t format,
const xcb_input_xi_get_property_items_t *_aux);
int
xcb_input_xi_get_property_items_unpack (const void *_buffer,
uint32_t num_items,
uint8_t format,
xcb_input_xi_get_property_items_t *_aux);
int
xcb_input_xi_get_property_items_sizeof (const void *_buffer,
uint32_t num_items,
uint8_t format);
int
xcb_input_xi_get_property_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_xi_get_property_cookie_t
xcb_input_xi_get_property (xcb_connection_t *c,
xcb_input_device_id_t deviceid,
uint8_t _delete,
xcb_atom_t property,
xcb_atom_t type,
uint32_t offset,
uint32_t len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_xi_get_property_cookie_t
xcb_input_xi_get_property_unchecked (xcb_connection_t *c,
xcb_input_device_id_t deviceid,
uint8_t _delete,
xcb_atom_t property,
xcb_atom_t type,
uint32_t offset,
uint32_t len);
void *
xcb_input_xi_get_property_items (const xcb_input_xi_get_property_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_xi_get_property_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_xi_get_property_reply_t *
xcb_input_xi_get_property_reply (xcb_connection_t *c,
xcb_input_xi_get_property_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_input_xi_get_selected_events_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_input_xi_get_selected_events_cookie_t
xcb_input_xi_get_selected_events (xcb_connection_t *c,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_input_xi_get_selected_events_cookie_t
xcb_input_xi_get_selected_events_unchecked (xcb_connection_t *c,
xcb_window_t window);
int
xcb_input_xi_get_selected_events_masks_length (const xcb_input_xi_get_selected_events_reply_t *R);
xcb_input_event_mask_iterator_t
xcb_input_xi_get_selected_events_masks_iterator (const xcb_input_xi_get_selected_events_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_input_xi_get_selected_events_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_input_xi_get_selected_events_reply_t *
xcb_input_xi_get_selected_events_reply (xcb_connection_t *c,
xcb_input_xi_get_selected_events_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_barrier_release_pointer_info_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_barrier_release_pointer_info_t)
*/
void
xcb_input_barrier_release_pointer_info_next (xcb_input_barrier_release_pointer_info_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_barrier_release_pointer_info_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_barrier_release_pointer_info_end (xcb_input_barrier_release_pointer_info_iterator_t i);
int
xcb_input_xi_barrier_release_pointer_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_input_xi_barrier_release_pointer_checked (xcb_connection_t *c,
uint32_t num_barriers,
const xcb_input_barrier_release_pointer_info_t *barriers);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_input_xi_barrier_release_pointer (xcb_connection_t *c,
uint32_t num_barriers,
const xcb_input_barrier_release_pointer_info_t *barriers);
xcb_input_barrier_release_pointer_info_t *
xcb_input_xi_barrier_release_pointer_barriers (const xcb_input_xi_barrier_release_pointer_request_t *R);
int
xcb_input_xi_barrier_release_pointer_barriers_length (const xcb_input_xi_barrier_release_pointer_request_t *R);
xcb_input_barrier_release_pointer_info_iterator_t
xcb_input_xi_barrier_release_pointer_barriers_iterator (const xcb_input_xi_barrier_release_pointer_request_t *R);
int
xcb_input_device_changed_sizeof (const void *_buffer);
int
xcb_input_device_changed_classes_length (const xcb_input_device_changed_event_t *R);
xcb_input_device_class_iterator_t
xcb_input_device_changed_classes_iterator (const xcb_input_device_changed_event_t *R);
int
xcb_input_key_press_sizeof (const void *_buffer);
uint32_t *
xcb_input_key_press_button_mask (const xcb_input_key_press_event_t *R);
int
xcb_input_key_press_button_mask_length (const xcb_input_key_press_event_t *R);
xcb_generic_iterator_t
xcb_input_key_press_button_mask_end (const xcb_input_key_press_event_t *R);
uint32_t *
xcb_input_key_press_valuator_mask (const xcb_input_key_press_event_t *R);
int
xcb_input_key_press_valuator_mask_length (const xcb_input_key_press_event_t *R);
xcb_generic_iterator_t
xcb_input_key_press_valuator_mask_end (const xcb_input_key_press_event_t *R);
xcb_input_fp3232_t *
xcb_input_key_press_axisvalues (const xcb_input_key_press_event_t *R);
int
xcb_input_key_press_axisvalues_length (const xcb_input_key_press_event_t *R);
xcb_input_fp3232_iterator_t
xcb_input_key_press_axisvalues_iterator (const xcb_input_key_press_event_t *R);
int
xcb_input_key_release_sizeof (const void *_buffer /**< */);
int
xcb_input_button_press_sizeof (const void *_buffer);
uint32_t *
xcb_input_button_press_button_mask (const xcb_input_button_press_event_t *R);
int
xcb_input_button_press_button_mask_length (const xcb_input_button_press_event_t *R);
xcb_generic_iterator_t
xcb_input_button_press_button_mask_end (const xcb_input_button_press_event_t *R);
uint32_t *
xcb_input_button_press_valuator_mask (const xcb_input_button_press_event_t *R);
int
xcb_input_button_press_valuator_mask_length (const xcb_input_button_press_event_t *R);
xcb_generic_iterator_t
xcb_input_button_press_valuator_mask_end (const xcb_input_button_press_event_t *R);
xcb_input_fp3232_t *
xcb_input_button_press_axisvalues (const xcb_input_button_press_event_t *R);
int
xcb_input_button_press_axisvalues_length (const xcb_input_button_press_event_t *R);
xcb_input_fp3232_iterator_t
xcb_input_button_press_axisvalues_iterator (const xcb_input_button_press_event_t *R);
int
xcb_input_button_release_sizeof (const void *_buffer /**< */);
int
xcb_input_motion_sizeof (const void *_buffer /**< */);
int
xcb_input_enter_sizeof (const void *_buffer);
uint32_t *
xcb_input_enter_buttons (const xcb_input_enter_event_t *R);
int
xcb_input_enter_buttons_length (const xcb_input_enter_event_t *R);
xcb_generic_iterator_t
xcb_input_enter_buttons_end (const xcb_input_enter_event_t *R);
int
xcb_input_leave_sizeof (const void *_buffer /**< */);
int
xcb_input_focus_in_sizeof (const void *_buffer /**< */);
int
xcb_input_focus_out_sizeof (const void *_buffer /**< */);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_hierarchy_info_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_hierarchy_info_t)
*/
void
xcb_input_hierarchy_info_next (xcb_input_hierarchy_info_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_hierarchy_info_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_hierarchy_info_end (xcb_input_hierarchy_info_iterator_t i);
int
xcb_input_hierarchy_sizeof (const void *_buffer);
xcb_input_hierarchy_info_t *
xcb_input_hierarchy_infos (const xcb_input_hierarchy_event_t *R);
int
xcb_input_hierarchy_infos_length (const xcb_input_hierarchy_event_t *R);
xcb_input_hierarchy_info_iterator_t
xcb_input_hierarchy_infos_iterator (const xcb_input_hierarchy_event_t *R);
int
xcb_input_raw_key_press_sizeof (const void *_buffer);
uint32_t *
xcb_input_raw_key_press_valuator_mask (const xcb_input_raw_key_press_event_t *R);
int
xcb_input_raw_key_press_valuator_mask_length (const xcb_input_raw_key_press_event_t *R);
xcb_generic_iterator_t
xcb_input_raw_key_press_valuator_mask_end (const xcb_input_raw_key_press_event_t *R);
xcb_input_fp3232_t *
xcb_input_raw_key_press_axisvalues (const xcb_input_raw_key_press_event_t *R);
int
xcb_input_raw_key_press_axisvalues_length (const xcb_input_raw_key_press_event_t *R);
xcb_input_fp3232_iterator_t
xcb_input_raw_key_press_axisvalues_iterator (const xcb_input_raw_key_press_event_t *R);
xcb_input_fp3232_t *
xcb_input_raw_key_press_axisvalues_raw (const xcb_input_raw_key_press_event_t *R);
int
xcb_input_raw_key_press_axisvalues_raw_length (const xcb_input_raw_key_press_event_t *R);
xcb_input_fp3232_iterator_t
xcb_input_raw_key_press_axisvalues_raw_iterator (const xcb_input_raw_key_press_event_t *R);
int
xcb_input_raw_key_release_sizeof (const void *_buffer /**< */);
int
xcb_input_raw_button_press_sizeof (const void *_buffer);
uint32_t *
xcb_input_raw_button_press_valuator_mask (const xcb_input_raw_button_press_event_t *R);
int
xcb_input_raw_button_press_valuator_mask_length (const xcb_input_raw_button_press_event_t *R);
xcb_generic_iterator_t
xcb_input_raw_button_press_valuator_mask_end (const xcb_input_raw_button_press_event_t *R);
xcb_input_fp3232_t *
xcb_input_raw_button_press_axisvalues (const xcb_input_raw_button_press_event_t *R);
int
xcb_input_raw_button_press_axisvalues_length (const xcb_input_raw_button_press_event_t *R);
xcb_input_fp3232_iterator_t
xcb_input_raw_button_press_axisvalues_iterator (const xcb_input_raw_button_press_event_t *R);
xcb_input_fp3232_t *
xcb_input_raw_button_press_axisvalues_raw (const xcb_input_raw_button_press_event_t *R);
int
xcb_input_raw_button_press_axisvalues_raw_length (const xcb_input_raw_button_press_event_t *R);
xcb_input_fp3232_iterator_t
xcb_input_raw_button_press_axisvalues_raw_iterator (const xcb_input_raw_button_press_event_t *R);
int
xcb_input_raw_button_release_sizeof (const void *_buffer /**< */);
int
xcb_input_raw_motion_sizeof (const void *_buffer /**< */);
int
xcb_input_touch_begin_sizeof (const void *_buffer);
uint32_t *
xcb_input_touch_begin_button_mask (const xcb_input_touch_begin_event_t *R);
int
xcb_input_touch_begin_button_mask_length (const xcb_input_touch_begin_event_t *R);
xcb_generic_iterator_t
xcb_input_touch_begin_button_mask_end (const xcb_input_touch_begin_event_t *R);
uint32_t *
xcb_input_touch_begin_valuator_mask (const xcb_input_touch_begin_event_t *R);
int
xcb_input_touch_begin_valuator_mask_length (const xcb_input_touch_begin_event_t *R);
xcb_generic_iterator_t
xcb_input_touch_begin_valuator_mask_end (const xcb_input_touch_begin_event_t *R);
xcb_input_fp3232_t *
xcb_input_touch_begin_axisvalues (const xcb_input_touch_begin_event_t *R);
int
xcb_input_touch_begin_axisvalues_length (const xcb_input_touch_begin_event_t *R);
xcb_input_fp3232_iterator_t
xcb_input_touch_begin_axisvalues_iterator (const xcb_input_touch_begin_event_t *R);
int
xcb_input_touch_update_sizeof (const void *_buffer /**< */);
int
xcb_input_touch_end_sizeof (const void *_buffer /**< */);
int
xcb_input_raw_touch_begin_sizeof (const void *_buffer);
uint32_t *
xcb_input_raw_touch_begin_valuator_mask (const xcb_input_raw_touch_begin_event_t *R);
int
xcb_input_raw_touch_begin_valuator_mask_length (const xcb_input_raw_touch_begin_event_t *R);
xcb_generic_iterator_t
xcb_input_raw_touch_begin_valuator_mask_end (const xcb_input_raw_touch_begin_event_t *R);
xcb_input_fp3232_t *
xcb_input_raw_touch_begin_axisvalues (const xcb_input_raw_touch_begin_event_t *R);
int
xcb_input_raw_touch_begin_axisvalues_length (const xcb_input_raw_touch_begin_event_t *R);
xcb_input_fp3232_iterator_t
xcb_input_raw_touch_begin_axisvalues_iterator (const xcb_input_raw_touch_begin_event_t *R);
xcb_input_fp3232_t *
xcb_input_raw_touch_begin_axisvalues_raw (const xcb_input_raw_touch_begin_event_t *R);
int
xcb_input_raw_touch_begin_axisvalues_raw_length (const xcb_input_raw_touch_begin_event_t *R);
xcb_input_fp3232_iterator_t
xcb_input_raw_touch_begin_axisvalues_raw_iterator (const xcb_input_raw_touch_begin_event_t *R);
int
xcb_input_raw_touch_update_sizeof (const void *_buffer /**< */);
int
xcb_input_raw_touch_end_sizeof (const void *_buffer /**< */);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_input_event_for_send_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_input_event_for_send_t)
*/
void
xcb_input_event_for_send_next (xcb_input_event_for_send_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_input_event_for_send_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_input_event_for_send_end (xcb_input_event_for_send_iterator_t i);
int
xcb_input_send_extension_event_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_input_send_extension_event_checked (xcb_connection_t *c,
xcb_window_t destination,
uint8_t device_id,
uint8_t propagate,
uint16_t num_classes,
uint8_t num_events,
const xcb_input_event_for_send_t *events,
const xcb_input_event_class_t *classes);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_input_send_extension_event (xcb_connection_t *c,
xcb_window_t destination,
uint8_t device_id,
uint8_t propagate,
uint16_t num_classes,
uint8_t num_events,
const xcb_input_event_for_send_t *events,
const xcb_input_event_class_t *classes);
xcb_input_event_for_send_t *
xcb_input_send_extension_event_events (const xcb_input_send_extension_event_request_t *R);
int
xcb_input_send_extension_event_events_length (const xcb_input_send_extension_event_request_t *R);
xcb_input_event_for_send_iterator_t
xcb_input_send_extension_event_events_iterator (const xcb_input_send_extension_event_request_t *R);
xcb_input_event_class_t *
xcb_input_send_extension_event_classes (const xcb_input_send_extension_event_request_t *R);
int
xcb_input_send_extension_event_classes_length (const xcb_input_send_extension_event_request_t *R);
xcb_generic_iterator_t
xcb_input_send_extension_event_classes_end (const xcb_input_send_extension_event_request_t *R);
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/
xcb/xselinux.h 0000644 00000156456 15201526705 0007374 0 ustar 00 /*
* This file generated automatically from xselinux.xml by c_client.py.
* Edit at your peril.
*/
/**
* @defgroup XCB_SELinux_API XCB SELinux API
* @brief SELinux XCB Protocol Implementation.
* @{
**/
#ifndef __XSELINUX_H
#define __XSELINUX_H
#include "xcb.h"
#include "xproto.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XCB_SELINUX_MAJOR_VERSION 1
#define XCB_SELINUX_MINOR_VERSION 0
extern xcb_extension_t xcb_selinux_id;
/**
* @brief xcb_selinux_query_version_cookie_t
**/
typedef struct xcb_selinux_query_version_cookie_t {
unsigned int sequence;
} xcb_selinux_query_version_cookie_t;
/** Opcode for xcb_selinux_query_version. */
#define XCB_SELINUX_QUERY_VERSION 0
/**
* @brief xcb_selinux_query_version_request_t
**/
typedef struct xcb_selinux_query_version_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t client_major;
uint8_t client_minor;
} xcb_selinux_query_version_request_t;
/**
* @brief xcb_selinux_query_version_reply_t
**/
typedef struct xcb_selinux_query_version_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t server_major;
uint16_t server_minor;
} xcb_selinux_query_version_reply_t;
/** Opcode for xcb_selinux_set_device_create_context. */
#define XCB_SELINUX_SET_DEVICE_CREATE_CONTEXT 1
/**
* @brief xcb_selinux_set_device_create_context_request_t
**/
typedef struct xcb_selinux_set_device_create_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t context_len;
} xcb_selinux_set_device_create_context_request_t;
/**
* @brief xcb_selinux_get_device_create_context_cookie_t
**/
typedef struct xcb_selinux_get_device_create_context_cookie_t {
unsigned int sequence;
} xcb_selinux_get_device_create_context_cookie_t;
/** Opcode for xcb_selinux_get_device_create_context. */
#define XCB_SELINUX_GET_DEVICE_CREATE_CONTEXT 2
/**
* @brief xcb_selinux_get_device_create_context_request_t
**/
typedef struct xcb_selinux_get_device_create_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_selinux_get_device_create_context_request_t;
/**
* @brief xcb_selinux_get_device_create_context_reply_t
**/
typedef struct xcb_selinux_get_device_create_context_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t context_len;
uint8_t pad1[20];
} xcb_selinux_get_device_create_context_reply_t;
/** Opcode for xcb_selinux_set_device_context. */
#define XCB_SELINUX_SET_DEVICE_CONTEXT 3
/**
* @brief xcb_selinux_set_device_context_request_t
**/
typedef struct xcb_selinux_set_device_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t device;
uint32_t context_len;
} xcb_selinux_set_device_context_request_t;
/**
* @brief xcb_selinux_get_device_context_cookie_t
**/
typedef struct xcb_selinux_get_device_context_cookie_t {
unsigned int sequence;
} xcb_selinux_get_device_context_cookie_t;
/** Opcode for xcb_selinux_get_device_context. */
#define XCB_SELINUX_GET_DEVICE_CONTEXT 4
/**
* @brief xcb_selinux_get_device_context_request_t
**/
typedef struct xcb_selinux_get_device_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t device;
} xcb_selinux_get_device_context_request_t;
/**
* @brief xcb_selinux_get_device_context_reply_t
**/
typedef struct xcb_selinux_get_device_context_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t context_len;
uint8_t pad1[20];
} xcb_selinux_get_device_context_reply_t;
/** Opcode for xcb_selinux_set_window_create_context. */
#define XCB_SELINUX_SET_WINDOW_CREATE_CONTEXT 5
/**
* @brief xcb_selinux_set_window_create_context_request_t
**/
typedef struct xcb_selinux_set_window_create_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t context_len;
} xcb_selinux_set_window_create_context_request_t;
/**
* @brief xcb_selinux_get_window_create_context_cookie_t
**/
typedef struct xcb_selinux_get_window_create_context_cookie_t {
unsigned int sequence;
} xcb_selinux_get_window_create_context_cookie_t;
/** Opcode for xcb_selinux_get_window_create_context. */
#define XCB_SELINUX_GET_WINDOW_CREATE_CONTEXT 6
/**
* @brief xcb_selinux_get_window_create_context_request_t
**/
typedef struct xcb_selinux_get_window_create_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_selinux_get_window_create_context_request_t;
/**
* @brief xcb_selinux_get_window_create_context_reply_t
**/
typedef struct xcb_selinux_get_window_create_context_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t context_len;
uint8_t pad1[20];
} xcb_selinux_get_window_create_context_reply_t;
/**
* @brief xcb_selinux_get_window_context_cookie_t
**/
typedef struct xcb_selinux_get_window_context_cookie_t {
unsigned int sequence;
} xcb_selinux_get_window_context_cookie_t;
/** Opcode for xcb_selinux_get_window_context. */
#define XCB_SELINUX_GET_WINDOW_CONTEXT 7
/**
* @brief xcb_selinux_get_window_context_request_t
**/
typedef struct xcb_selinux_get_window_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
} xcb_selinux_get_window_context_request_t;
/**
* @brief xcb_selinux_get_window_context_reply_t
**/
typedef struct xcb_selinux_get_window_context_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t context_len;
uint8_t pad1[20];
} xcb_selinux_get_window_context_reply_t;
/**
* @brief xcb_selinux_list_item_t
**/
typedef struct xcb_selinux_list_item_t {
xcb_atom_t name;
uint32_t object_context_len;
uint32_t data_context_len;
} xcb_selinux_list_item_t;
/**
* @brief xcb_selinux_list_item_iterator_t
**/
typedef struct xcb_selinux_list_item_iterator_t {
xcb_selinux_list_item_t *data;
int rem;
int index;
} xcb_selinux_list_item_iterator_t;
/** Opcode for xcb_selinux_set_property_create_context. */
#define XCB_SELINUX_SET_PROPERTY_CREATE_CONTEXT 8
/**
* @brief xcb_selinux_set_property_create_context_request_t
**/
typedef struct xcb_selinux_set_property_create_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t context_len;
} xcb_selinux_set_property_create_context_request_t;
/**
* @brief xcb_selinux_get_property_create_context_cookie_t
**/
typedef struct xcb_selinux_get_property_create_context_cookie_t {
unsigned int sequence;
} xcb_selinux_get_property_create_context_cookie_t;
/** Opcode for xcb_selinux_get_property_create_context. */
#define XCB_SELINUX_GET_PROPERTY_CREATE_CONTEXT 9
/**
* @brief xcb_selinux_get_property_create_context_request_t
**/
typedef struct xcb_selinux_get_property_create_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_selinux_get_property_create_context_request_t;
/**
* @brief xcb_selinux_get_property_create_context_reply_t
**/
typedef struct xcb_selinux_get_property_create_context_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t context_len;
uint8_t pad1[20];
} xcb_selinux_get_property_create_context_reply_t;
/** Opcode for xcb_selinux_set_property_use_context. */
#define XCB_SELINUX_SET_PROPERTY_USE_CONTEXT 10
/**
* @brief xcb_selinux_set_property_use_context_request_t
**/
typedef struct xcb_selinux_set_property_use_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t context_len;
} xcb_selinux_set_property_use_context_request_t;
/**
* @brief xcb_selinux_get_property_use_context_cookie_t
**/
typedef struct xcb_selinux_get_property_use_context_cookie_t {
unsigned int sequence;
} xcb_selinux_get_property_use_context_cookie_t;
/** Opcode for xcb_selinux_get_property_use_context. */
#define XCB_SELINUX_GET_PROPERTY_USE_CONTEXT 11
/**
* @brief xcb_selinux_get_property_use_context_request_t
**/
typedef struct xcb_selinux_get_property_use_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_selinux_get_property_use_context_request_t;
/**
* @brief xcb_selinux_get_property_use_context_reply_t
**/
typedef struct xcb_selinux_get_property_use_context_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t context_len;
uint8_t pad1[20];
} xcb_selinux_get_property_use_context_reply_t;
/**
* @brief xcb_selinux_get_property_context_cookie_t
**/
typedef struct xcb_selinux_get_property_context_cookie_t {
unsigned int sequence;
} xcb_selinux_get_property_context_cookie_t;
/** Opcode for xcb_selinux_get_property_context. */
#define XCB_SELINUX_GET_PROPERTY_CONTEXT 12
/**
* @brief xcb_selinux_get_property_context_request_t
**/
typedef struct xcb_selinux_get_property_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
xcb_atom_t property;
} xcb_selinux_get_property_context_request_t;
/**
* @brief xcb_selinux_get_property_context_reply_t
**/
typedef struct xcb_selinux_get_property_context_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t context_len;
uint8_t pad1[20];
} xcb_selinux_get_property_context_reply_t;
/**
* @brief xcb_selinux_get_property_data_context_cookie_t
**/
typedef struct xcb_selinux_get_property_data_context_cookie_t {
unsigned int sequence;
} xcb_selinux_get_property_data_context_cookie_t;
/** Opcode for xcb_selinux_get_property_data_context. */
#define XCB_SELINUX_GET_PROPERTY_DATA_CONTEXT 13
/**
* @brief xcb_selinux_get_property_data_context_request_t
**/
typedef struct xcb_selinux_get_property_data_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
xcb_atom_t property;
} xcb_selinux_get_property_data_context_request_t;
/**
* @brief xcb_selinux_get_property_data_context_reply_t
**/
typedef struct xcb_selinux_get_property_data_context_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t context_len;
uint8_t pad1[20];
} xcb_selinux_get_property_data_context_reply_t;
/**
* @brief xcb_selinux_list_properties_cookie_t
**/
typedef struct xcb_selinux_list_properties_cookie_t {
unsigned int sequence;
} xcb_selinux_list_properties_cookie_t;
/** Opcode for xcb_selinux_list_properties. */
#define XCB_SELINUX_LIST_PROPERTIES 14
/**
* @brief xcb_selinux_list_properties_request_t
**/
typedef struct xcb_selinux_list_properties_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
} xcb_selinux_list_properties_request_t;
/**
* @brief xcb_selinux_list_properties_reply_t
**/
typedef struct xcb_selinux_list_properties_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t properties_len;
uint8_t pad1[20];
} xcb_selinux_list_properties_reply_t;
/** Opcode for xcb_selinux_set_selection_create_context. */
#define XCB_SELINUX_SET_SELECTION_CREATE_CONTEXT 15
/**
* @brief xcb_selinux_set_selection_create_context_request_t
**/
typedef struct xcb_selinux_set_selection_create_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t context_len;
} xcb_selinux_set_selection_create_context_request_t;
/**
* @brief xcb_selinux_get_selection_create_context_cookie_t
**/
typedef struct xcb_selinux_get_selection_create_context_cookie_t {
unsigned int sequence;
} xcb_selinux_get_selection_create_context_cookie_t;
/** Opcode for xcb_selinux_get_selection_create_context. */
#define XCB_SELINUX_GET_SELECTION_CREATE_CONTEXT 16
/**
* @brief xcb_selinux_get_selection_create_context_request_t
**/
typedef struct xcb_selinux_get_selection_create_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_selinux_get_selection_create_context_request_t;
/**
* @brief xcb_selinux_get_selection_create_context_reply_t
**/
typedef struct xcb_selinux_get_selection_create_context_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t context_len;
uint8_t pad1[20];
} xcb_selinux_get_selection_create_context_reply_t;
/** Opcode for xcb_selinux_set_selection_use_context. */
#define XCB_SELINUX_SET_SELECTION_USE_CONTEXT 17
/**
* @brief xcb_selinux_set_selection_use_context_request_t
**/
typedef struct xcb_selinux_set_selection_use_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t context_len;
} xcb_selinux_set_selection_use_context_request_t;
/**
* @brief xcb_selinux_get_selection_use_context_cookie_t
**/
typedef struct xcb_selinux_get_selection_use_context_cookie_t {
unsigned int sequence;
} xcb_selinux_get_selection_use_context_cookie_t;
/** Opcode for xcb_selinux_get_selection_use_context. */
#define XCB_SELINUX_GET_SELECTION_USE_CONTEXT 18
/**
* @brief xcb_selinux_get_selection_use_context_request_t
**/
typedef struct xcb_selinux_get_selection_use_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_selinux_get_selection_use_context_request_t;
/**
* @brief xcb_selinux_get_selection_use_context_reply_t
**/
typedef struct xcb_selinux_get_selection_use_context_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t context_len;
uint8_t pad1[20];
} xcb_selinux_get_selection_use_context_reply_t;
/**
* @brief xcb_selinux_get_selection_context_cookie_t
**/
typedef struct xcb_selinux_get_selection_context_cookie_t {
unsigned int sequence;
} xcb_selinux_get_selection_context_cookie_t;
/** Opcode for xcb_selinux_get_selection_context. */
#define XCB_SELINUX_GET_SELECTION_CONTEXT 19
/**
* @brief xcb_selinux_get_selection_context_request_t
**/
typedef struct xcb_selinux_get_selection_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_atom_t selection;
} xcb_selinux_get_selection_context_request_t;
/**
* @brief xcb_selinux_get_selection_context_reply_t
**/
typedef struct xcb_selinux_get_selection_context_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t context_len;
uint8_t pad1[20];
} xcb_selinux_get_selection_context_reply_t;
/**
* @brief xcb_selinux_get_selection_data_context_cookie_t
**/
typedef struct xcb_selinux_get_selection_data_context_cookie_t {
unsigned int sequence;
} xcb_selinux_get_selection_data_context_cookie_t;
/** Opcode for xcb_selinux_get_selection_data_context. */
#define XCB_SELINUX_GET_SELECTION_DATA_CONTEXT 20
/**
* @brief xcb_selinux_get_selection_data_context_request_t
**/
typedef struct xcb_selinux_get_selection_data_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_atom_t selection;
} xcb_selinux_get_selection_data_context_request_t;
/**
* @brief xcb_selinux_get_selection_data_context_reply_t
**/
typedef struct xcb_selinux_get_selection_data_context_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t context_len;
uint8_t pad1[20];
} xcb_selinux_get_selection_data_context_reply_t;
/**
* @brief xcb_selinux_list_selections_cookie_t
**/
typedef struct xcb_selinux_list_selections_cookie_t {
unsigned int sequence;
} xcb_selinux_list_selections_cookie_t;
/** Opcode for xcb_selinux_list_selections. */
#define XCB_SELINUX_LIST_SELECTIONS 21
/**
* @brief xcb_selinux_list_selections_request_t
**/
typedef struct xcb_selinux_list_selections_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_selinux_list_selections_request_t;
/**
* @brief xcb_selinux_list_selections_reply_t
**/
typedef struct xcb_selinux_list_selections_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t selections_len;
uint8_t pad1[20];
} xcb_selinux_list_selections_reply_t;
/**
* @brief xcb_selinux_get_client_context_cookie_t
**/
typedef struct xcb_selinux_get_client_context_cookie_t {
unsigned int sequence;
} xcb_selinux_get_client_context_cookie_t;
/** Opcode for xcb_selinux_get_client_context. */
#define XCB_SELINUX_GET_CLIENT_CONTEXT 22
/**
* @brief xcb_selinux_get_client_context_request_t
**/
typedef struct xcb_selinux_get_client_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t resource;
} xcb_selinux_get_client_context_request_t;
/**
* @brief xcb_selinux_get_client_context_reply_t
**/
typedef struct xcb_selinux_get_client_context_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t context_len;
uint8_t pad1[20];
} xcb_selinux_get_client_context_reply_t;
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_selinux_query_version_cookie_t
xcb_selinux_query_version (xcb_connection_t *c,
uint8_t client_major,
uint8_t client_minor);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_selinux_query_version_cookie_t
xcb_selinux_query_version_unchecked (xcb_connection_t *c,
uint8_t client_major,
uint8_t client_minor);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_selinux_query_version_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_selinux_query_version_reply_t *
xcb_selinux_query_version_reply (xcb_connection_t *c,
xcb_selinux_query_version_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_selinux_set_device_create_context_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_selinux_set_device_create_context_checked (xcb_connection_t *c,
uint32_t context_len,
const char *context);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_selinux_set_device_create_context (xcb_connection_t *c,
uint32_t context_len,
const char *context);
char *
xcb_selinux_set_device_create_context_context (const xcb_selinux_set_device_create_context_request_t *R);
int
xcb_selinux_set_device_create_context_context_length (const xcb_selinux_set_device_create_context_request_t *R);
xcb_generic_iterator_t
xcb_selinux_set_device_create_context_context_end (const xcb_selinux_set_device_create_context_request_t *R);
int
xcb_selinux_get_device_create_context_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_selinux_get_device_create_context_cookie_t
xcb_selinux_get_device_create_context (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_selinux_get_device_create_context_cookie_t
xcb_selinux_get_device_create_context_unchecked (xcb_connection_t *c);
char *
xcb_selinux_get_device_create_context_context (const xcb_selinux_get_device_create_context_reply_t *R);
int
xcb_selinux_get_device_create_context_context_length (const xcb_selinux_get_device_create_context_reply_t *R);
xcb_generic_iterator_t
xcb_selinux_get_device_create_context_context_end (const xcb_selinux_get_device_create_context_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_selinux_get_device_create_context_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_selinux_get_device_create_context_reply_t *
xcb_selinux_get_device_create_context_reply (xcb_connection_t *c,
xcb_selinux_get_device_create_context_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_selinux_set_device_context_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_selinux_set_device_context_checked (xcb_connection_t *c,
uint32_t device,
uint32_t context_len,
const char *context);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_selinux_set_device_context (xcb_connection_t *c,
uint32_t device,
uint32_t context_len,
const char *context);
char *
xcb_selinux_set_device_context_context (const xcb_selinux_set_device_context_request_t *R);
int
xcb_selinux_set_device_context_context_length (const xcb_selinux_set_device_context_request_t *R);
xcb_generic_iterator_t
xcb_selinux_set_device_context_context_end (const xcb_selinux_set_device_context_request_t *R);
int
xcb_selinux_get_device_context_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_selinux_get_device_context_cookie_t
xcb_selinux_get_device_context (xcb_connection_t *c,
uint32_t device);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_selinux_get_device_context_cookie_t
xcb_selinux_get_device_context_unchecked (xcb_connection_t *c,
uint32_t device);
char *
xcb_selinux_get_device_context_context (const xcb_selinux_get_device_context_reply_t *R);
int
xcb_selinux_get_device_context_context_length (const xcb_selinux_get_device_context_reply_t *R);
xcb_generic_iterator_t
xcb_selinux_get_device_context_context_end (const xcb_selinux_get_device_context_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_selinux_get_device_context_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_selinux_get_device_context_reply_t *
xcb_selinux_get_device_context_reply (xcb_connection_t *c,
xcb_selinux_get_device_context_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_selinux_set_window_create_context_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_selinux_set_window_create_context_checked (xcb_connection_t *c,
uint32_t context_len,
const char *context);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_selinux_set_window_create_context (xcb_connection_t *c,
uint32_t context_len,
const char *context);
char *
xcb_selinux_set_window_create_context_context (const xcb_selinux_set_window_create_context_request_t *R);
int
xcb_selinux_set_window_create_context_context_length (const xcb_selinux_set_window_create_context_request_t *R);
xcb_generic_iterator_t
xcb_selinux_set_window_create_context_context_end (const xcb_selinux_set_window_create_context_request_t *R);
int
xcb_selinux_get_window_create_context_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_selinux_get_window_create_context_cookie_t
xcb_selinux_get_window_create_context (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_selinux_get_window_create_context_cookie_t
xcb_selinux_get_window_create_context_unchecked (xcb_connection_t *c);
char *
xcb_selinux_get_window_create_context_context (const xcb_selinux_get_window_create_context_reply_t *R);
int
xcb_selinux_get_window_create_context_context_length (const xcb_selinux_get_window_create_context_reply_t *R);
xcb_generic_iterator_t
xcb_selinux_get_window_create_context_context_end (const xcb_selinux_get_window_create_context_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_selinux_get_window_create_context_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_selinux_get_window_create_context_reply_t *
xcb_selinux_get_window_create_context_reply (xcb_connection_t *c,
xcb_selinux_get_window_create_context_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_selinux_get_window_context_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_selinux_get_window_context_cookie_t
xcb_selinux_get_window_context (xcb_connection_t *c,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_selinux_get_window_context_cookie_t
xcb_selinux_get_window_context_unchecked (xcb_connection_t *c,
xcb_window_t window);
char *
xcb_selinux_get_window_context_context (const xcb_selinux_get_window_context_reply_t *R);
int
xcb_selinux_get_window_context_context_length (const xcb_selinux_get_window_context_reply_t *R);
xcb_generic_iterator_t
xcb_selinux_get_window_context_context_end (const xcb_selinux_get_window_context_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_selinux_get_window_context_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_selinux_get_window_context_reply_t *
xcb_selinux_get_window_context_reply (xcb_connection_t *c,
xcb_selinux_get_window_context_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_selinux_list_item_sizeof (const void *_buffer);
char *
xcb_selinux_list_item_object_context (const xcb_selinux_list_item_t *R);
int
xcb_selinux_list_item_object_context_length (const xcb_selinux_list_item_t *R);
xcb_generic_iterator_t
xcb_selinux_list_item_object_context_end (const xcb_selinux_list_item_t *R);
char *
xcb_selinux_list_item_data_context (const xcb_selinux_list_item_t *R);
int
xcb_selinux_list_item_data_context_length (const xcb_selinux_list_item_t *R);
xcb_generic_iterator_t
xcb_selinux_list_item_data_context_end (const xcb_selinux_list_item_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_selinux_list_item_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_selinux_list_item_t)
*/
void
xcb_selinux_list_item_next (xcb_selinux_list_item_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_selinux_list_item_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_selinux_list_item_end (xcb_selinux_list_item_iterator_t i);
int
xcb_selinux_set_property_create_context_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_selinux_set_property_create_context_checked (xcb_connection_t *c,
uint32_t context_len,
const char *context);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_selinux_set_property_create_context (xcb_connection_t *c,
uint32_t context_len,
const char *context);
char *
xcb_selinux_set_property_create_context_context (const xcb_selinux_set_property_create_context_request_t *R);
int
xcb_selinux_set_property_create_context_context_length (const xcb_selinux_set_property_create_context_request_t *R);
xcb_generic_iterator_t
xcb_selinux_set_property_create_context_context_end (const xcb_selinux_set_property_create_context_request_t *R);
int
xcb_selinux_get_property_create_context_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_selinux_get_property_create_context_cookie_t
xcb_selinux_get_property_create_context (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_selinux_get_property_create_context_cookie_t
xcb_selinux_get_property_create_context_unchecked (xcb_connection_t *c);
char *
xcb_selinux_get_property_create_context_context (const xcb_selinux_get_property_create_context_reply_t *R);
int
xcb_selinux_get_property_create_context_context_length (const xcb_selinux_get_property_create_context_reply_t *R);
xcb_generic_iterator_t
xcb_selinux_get_property_create_context_context_end (const xcb_selinux_get_property_create_context_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_selinux_get_property_create_context_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_selinux_get_property_create_context_reply_t *
xcb_selinux_get_property_create_context_reply (xcb_connection_t *c,
xcb_selinux_get_property_create_context_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_selinux_set_property_use_context_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_selinux_set_property_use_context_checked (xcb_connection_t *c,
uint32_t context_len,
const char *context);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_selinux_set_property_use_context (xcb_connection_t *c,
uint32_t context_len,
const char *context);
char *
xcb_selinux_set_property_use_context_context (const xcb_selinux_set_property_use_context_request_t *R);
int
xcb_selinux_set_property_use_context_context_length (const xcb_selinux_set_property_use_context_request_t *R);
xcb_generic_iterator_t
xcb_selinux_set_property_use_context_context_end (const xcb_selinux_set_property_use_context_request_t *R);
int
xcb_selinux_get_property_use_context_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_selinux_get_property_use_context_cookie_t
xcb_selinux_get_property_use_context (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_selinux_get_property_use_context_cookie_t
xcb_selinux_get_property_use_context_unchecked (xcb_connection_t *c);
char *
xcb_selinux_get_property_use_context_context (const xcb_selinux_get_property_use_context_reply_t *R);
int
xcb_selinux_get_property_use_context_context_length (const xcb_selinux_get_property_use_context_reply_t *R);
xcb_generic_iterator_t
xcb_selinux_get_property_use_context_context_end (const xcb_selinux_get_property_use_context_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_selinux_get_property_use_context_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_selinux_get_property_use_context_reply_t *
xcb_selinux_get_property_use_context_reply (xcb_connection_t *c,
xcb_selinux_get_property_use_context_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_selinux_get_property_context_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_selinux_get_property_context_cookie_t
xcb_selinux_get_property_context (xcb_connection_t *c,
xcb_window_t window,
xcb_atom_t property);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_selinux_get_property_context_cookie_t
xcb_selinux_get_property_context_unchecked (xcb_connection_t *c,
xcb_window_t window,
xcb_atom_t property);
char *
xcb_selinux_get_property_context_context (const xcb_selinux_get_property_context_reply_t *R);
int
xcb_selinux_get_property_context_context_length (const xcb_selinux_get_property_context_reply_t *R);
xcb_generic_iterator_t
xcb_selinux_get_property_context_context_end (const xcb_selinux_get_property_context_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_selinux_get_property_context_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_selinux_get_property_context_reply_t *
xcb_selinux_get_property_context_reply (xcb_connection_t *c,
xcb_selinux_get_property_context_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_selinux_get_property_data_context_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_selinux_get_property_data_context_cookie_t
xcb_selinux_get_property_data_context (xcb_connection_t *c,
xcb_window_t window,
xcb_atom_t property);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_selinux_get_property_data_context_cookie_t
xcb_selinux_get_property_data_context_unchecked (xcb_connection_t *c,
xcb_window_t window,
xcb_atom_t property);
char *
xcb_selinux_get_property_data_context_context (const xcb_selinux_get_property_data_context_reply_t *R);
int
xcb_selinux_get_property_data_context_context_length (const xcb_selinux_get_property_data_context_reply_t *R);
xcb_generic_iterator_t
xcb_selinux_get_property_data_context_context_end (const xcb_selinux_get_property_data_context_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_selinux_get_property_data_context_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_selinux_get_property_data_context_reply_t *
xcb_selinux_get_property_data_context_reply (xcb_connection_t *c,
xcb_selinux_get_property_data_context_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_selinux_list_properties_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_selinux_list_properties_cookie_t
xcb_selinux_list_properties (xcb_connection_t *c,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_selinux_list_properties_cookie_t
xcb_selinux_list_properties_unchecked (xcb_connection_t *c,
xcb_window_t window);
int
xcb_selinux_list_properties_properties_length (const xcb_selinux_list_properties_reply_t *R);
xcb_selinux_list_item_iterator_t
xcb_selinux_list_properties_properties_iterator (const xcb_selinux_list_properties_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_selinux_list_properties_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_selinux_list_properties_reply_t *
xcb_selinux_list_properties_reply (xcb_connection_t *c,
xcb_selinux_list_properties_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_selinux_set_selection_create_context_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_selinux_set_selection_create_context_checked (xcb_connection_t *c,
uint32_t context_len,
const char *context);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_selinux_set_selection_create_context (xcb_connection_t *c,
uint32_t context_len,
const char *context);
char *
xcb_selinux_set_selection_create_context_context (const xcb_selinux_set_selection_create_context_request_t *R);
int
xcb_selinux_set_selection_create_context_context_length (const xcb_selinux_set_selection_create_context_request_t *R);
xcb_generic_iterator_t
xcb_selinux_set_selection_create_context_context_end (const xcb_selinux_set_selection_create_context_request_t *R);
int
xcb_selinux_get_selection_create_context_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_selinux_get_selection_create_context_cookie_t
xcb_selinux_get_selection_create_context (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_selinux_get_selection_create_context_cookie_t
xcb_selinux_get_selection_create_context_unchecked (xcb_connection_t *c);
char *
xcb_selinux_get_selection_create_context_context (const xcb_selinux_get_selection_create_context_reply_t *R);
int
xcb_selinux_get_selection_create_context_context_length (const xcb_selinux_get_selection_create_context_reply_t *R);
xcb_generic_iterator_t
xcb_selinux_get_selection_create_context_context_end (const xcb_selinux_get_selection_create_context_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_selinux_get_selection_create_context_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_selinux_get_selection_create_context_reply_t *
xcb_selinux_get_selection_create_context_reply (xcb_connection_t *c,
xcb_selinux_get_selection_create_context_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_selinux_set_selection_use_context_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_selinux_set_selection_use_context_checked (xcb_connection_t *c,
uint32_t context_len,
const char *context);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_selinux_set_selection_use_context (xcb_connection_t *c,
uint32_t context_len,
const char *context);
char *
xcb_selinux_set_selection_use_context_context (const xcb_selinux_set_selection_use_context_request_t *R);
int
xcb_selinux_set_selection_use_context_context_length (const xcb_selinux_set_selection_use_context_request_t *R);
xcb_generic_iterator_t
xcb_selinux_set_selection_use_context_context_end (const xcb_selinux_set_selection_use_context_request_t *R);
int
xcb_selinux_get_selection_use_context_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_selinux_get_selection_use_context_cookie_t
xcb_selinux_get_selection_use_context (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_selinux_get_selection_use_context_cookie_t
xcb_selinux_get_selection_use_context_unchecked (xcb_connection_t *c);
char *
xcb_selinux_get_selection_use_context_context (const xcb_selinux_get_selection_use_context_reply_t *R);
int
xcb_selinux_get_selection_use_context_context_length (const xcb_selinux_get_selection_use_context_reply_t *R);
xcb_generic_iterator_t
xcb_selinux_get_selection_use_context_context_end (const xcb_selinux_get_selection_use_context_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_selinux_get_selection_use_context_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_selinux_get_selection_use_context_reply_t *
xcb_selinux_get_selection_use_context_reply (xcb_connection_t *c,
xcb_selinux_get_selection_use_context_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_selinux_get_selection_context_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_selinux_get_selection_context_cookie_t
xcb_selinux_get_selection_context (xcb_connection_t *c,
xcb_atom_t selection);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_selinux_get_selection_context_cookie_t
xcb_selinux_get_selection_context_unchecked (xcb_connection_t *c,
xcb_atom_t selection);
char *
xcb_selinux_get_selection_context_context (const xcb_selinux_get_selection_context_reply_t *R);
int
xcb_selinux_get_selection_context_context_length (const xcb_selinux_get_selection_context_reply_t *R);
xcb_generic_iterator_t
xcb_selinux_get_selection_context_context_end (const xcb_selinux_get_selection_context_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_selinux_get_selection_context_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_selinux_get_selection_context_reply_t *
xcb_selinux_get_selection_context_reply (xcb_connection_t *c,
xcb_selinux_get_selection_context_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_selinux_get_selection_data_context_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_selinux_get_selection_data_context_cookie_t
xcb_selinux_get_selection_data_context (xcb_connection_t *c,
xcb_atom_t selection);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_selinux_get_selection_data_context_cookie_t
xcb_selinux_get_selection_data_context_unchecked (xcb_connection_t *c,
xcb_atom_t selection);
char *
xcb_selinux_get_selection_data_context_context (const xcb_selinux_get_selection_data_context_reply_t *R);
int
xcb_selinux_get_selection_data_context_context_length (const xcb_selinux_get_selection_data_context_reply_t *R);
xcb_generic_iterator_t
xcb_selinux_get_selection_data_context_context_end (const xcb_selinux_get_selection_data_context_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_selinux_get_selection_data_context_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_selinux_get_selection_data_context_reply_t *
xcb_selinux_get_selection_data_context_reply (xcb_connection_t *c,
xcb_selinux_get_selection_data_context_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_selinux_list_selections_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_selinux_list_selections_cookie_t
xcb_selinux_list_selections (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_selinux_list_selections_cookie_t
xcb_selinux_list_selections_unchecked (xcb_connection_t *c);
int
xcb_selinux_list_selections_selections_length (const xcb_selinux_list_selections_reply_t *R);
xcb_selinux_list_item_iterator_t
xcb_selinux_list_selections_selections_iterator (const xcb_selinux_list_selections_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_selinux_list_selections_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_selinux_list_selections_reply_t *
xcb_selinux_list_selections_reply (xcb_connection_t *c,
xcb_selinux_list_selections_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_selinux_get_client_context_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_selinux_get_client_context_cookie_t
xcb_selinux_get_client_context (xcb_connection_t *c,
uint32_t resource);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_selinux_get_client_context_cookie_t
xcb_selinux_get_client_context_unchecked (xcb_connection_t *c,
uint32_t resource);
char *
xcb_selinux_get_client_context_context (const xcb_selinux_get_client_context_reply_t *R);
int
xcb_selinux_get_client_context_context_length (const xcb_selinux_get_client_context_reply_t *R);
xcb_generic_iterator_t
xcb_selinux_get_client_context_context_end (const xcb_selinux_get_client_context_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_selinux_get_client_context_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_selinux_get_client_context_reply_t *
xcb_selinux_get_client_context_reply (xcb_connection_t *c,
xcb_selinux_get_client_context_cookie_t cookie /**< */,
xcb_generic_error_t **e);
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/
xcb/xf86dri.h 0000644 00000066602 15201526705 0007000 0 ustar 00 /*
* This file generated automatically from xf86dri.xml by c_client.py.
* Edit at your peril.
*/
/**
* @defgroup XCB_XF86Dri_API XCB XF86Dri API
* @brief XF86Dri XCB Protocol Implementation.
* @{
**/
#ifndef __XF86DRI_H
#define __XF86DRI_H
#include "xcb.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XCB_XF86DRI_MAJOR_VERSION 4
#define XCB_XF86DRI_MINOR_VERSION 1
extern xcb_extension_t xcb_xf86dri_id;
/**
* @brief xcb_xf86dri_drm_clip_rect_t
**/
typedef struct xcb_xf86dri_drm_clip_rect_t {
int16_t x1;
int16_t y1;
int16_t x2;
int16_t x3;
} xcb_xf86dri_drm_clip_rect_t;
/**
* @brief xcb_xf86dri_drm_clip_rect_iterator_t
**/
typedef struct xcb_xf86dri_drm_clip_rect_iterator_t {
xcb_xf86dri_drm_clip_rect_t *data;
int rem;
int index;
} xcb_xf86dri_drm_clip_rect_iterator_t;
/**
* @brief xcb_xf86dri_query_version_cookie_t
**/
typedef struct xcb_xf86dri_query_version_cookie_t {
unsigned int sequence;
} xcb_xf86dri_query_version_cookie_t;
/** Opcode for xcb_xf86dri_query_version. */
#define XCB_XF86DRI_QUERY_VERSION 0
/**
* @brief xcb_xf86dri_query_version_request_t
**/
typedef struct xcb_xf86dri_query_version_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_xf86dri_query_version_request_t;
/**
* @brief xcb_xf86dri_query_version_reply_t
**/
typedef struct xcb_xf86dri_query_version_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t dri_major_version;
uint16_t dri_minor_version;
uint32_t dri_minor_patch;
} xcb_xf86dri_query_version_reply_t;
/**
* @brief xcb_xf86dri_query_direct_rendering_capable_cookie_t
**/
typedef struct xcb_xf86dri_query_direct_rendering_capable_cookie_t {
unsigned int sequence;
} xcb_xf86dri_query_direct_rendering_capable_cookie_t;
/** Opcode for xcb_xf86dri_query_direct_rendering_capable. */
#define XCB_XF86DRI_QUERY_DIRECT_RENDERING_CAPABLE 1
/**
* @brief xcb_xf86dri_query_direct_rendering_capable_request_t
**/
typedef struct xcb_xf86dri_query_direct_rendering_capable_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t screen;
} xcb_xf86dri_query_direct_rendering_capable_request_t;
/**
* @brief xcb_xf86dri_query_direct_rendering_capable_reply_t
**/
typedef struct xcb_xf86dri_query_direct_rendering_capable_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t is_capable;
} xcb_xf86dri_query_direct_rendering_capable_reply_t;
/**
* @brief xcb_xf86dri_open_connection_cookie_t
**/
typedef struct xcb_xf86dri_open_connection_cookie_t {
unsigned int sequence;
} xcb_xf86dri_open_connection_cookie_t;
/** Opcode for xcb_xf86dri_open_connection. */
#define XCB_XF86DRI_OPEN_CONNECTION 2
/**
* @brief xcb_xf86dri_open_connection_request_t
**/
typedef struct xcb_xf86dri_open_connection_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t screen;
} xcb_xf86dri_open_connection_request_t;
/**
* @brief xcb_xf86dri_open_connection_reply_t
**/
typedef struct xcb_xf86dri_open_connection_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t sarea_handle_low;
uint32_t sarea_handle_high;
uint32_t bus_id_len;
uint8_t pad1[12];
} xcb_xf86dri_open_connection_reply_t;
/** Opcode for xcb_xf86dri_close_connection. */
#define XCB_XF86DRI_CLOSE_CONNECTION 3
/**
* @brief xcb_xf86dri_close_connection_request_t
**/
typedef struct xcb_xf86dri_close_connection_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t screen;
} xcb_xf86dri_close_connection_request_t;
/**
* @brief xcb_xf86dri_get_client_driver_name_cookie_t
**/
typedef struct xcb_xf86dri_get_client_driver_name_cookie_t {
unsigned int sequence;
} xcb_xf86dri_get_client_driver_name_cookie_t;
/** Opcode for xcb_xf86dri_get_client_driver_name. */
#define XCB_XF86DRI_GET_CLIENT_DRIVER_NAME 4
/**
* @brief xcb_xf86dri_get_client_driver_name_request_t
**/
typedef struct xcb_xf86dri_get_client_driver_name_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t screen;
} xcb_xf86dri_get_client_driver_name_request_t;
/**
* @brief xcb_xf86dri_get_client_driver_name_reply_t
**/
typedef struct xcb_xf86dri_get_client_driver_name_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t client_driver_major_version;
uint32_t client_driver_minor_version;
uint32_t client_driver_patch_version;
uint32_t client_driver_name_len;
uint8_t pad1[8];
} xcb_xf86dri_get_client_driver_name_reply_t;
/**
* @brief xcb_xf86dri_create_context_cookie_t
**/
typedef struct xcb_xf86dri_create_context_cookie_t {
unsigned int sequence;
} xcb_xf86dri_create_context_cookie_t;
/** Opcode for xcb_xf86dri_create_context. */
#define XCB_XF86DRI_CREATE_CONTEXT 5
/**
* @brief xcb_xf86dri_create_context_request_t
**/
typedef struct xcb_xf86dri_create_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t screen;
uint32_t visual;
uint32_t context;
} xcb_xf86dri_create_context_request_t;
/**
* @brief xcb_xf86dri_create_context_reply_t
**/
typedef struct xcb_xf86dri_create_context_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t hw_context;
} xcb_xf86dri_create_context_reply_t;
/** Opcode for xcb_xf86dri_destroy_context. */
#define XCB_XF86DRI_DESTROY_CONTEXT 6
/**
* @brief xcb_xf86dri_destroy_context_request_t
**/
typedef struct xcb_xf86dri_destroy_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t screen;
uint32_t context;
} xcb_xf86dri_destroy_context_request_t;
/**
* @brief xcb_xf86dri_create_drawable_cookie_t
**/
typedef struct xcb_xf86dri_create_drawable_cookie_t {
unsigned int sequence;
} xcb_xf86dri_create_drawable_cookie_t;
/** Opcode for xcb_xf86dri_create_drawable. */
#define XCB_XF86DRI_CREATE_DRAWABLE 7
/**
* @brief xcb_xf86dri_create_drawable_request_t
**/
typedef struct xcb_xf86dri_create_drawable_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t screen;
uint32_t drawable;
} xcb_xf86dri_create_drawable_request_t;
/**
* @brief xcb_xf86dri_create_drawable_reply_t
**/
typedef struct xcb_xf86dri_create_drawable_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t hw_drawable_handle;
} xcb_xf86dri_create_drawable_reply_t;
/** Opcode for xcb_xf86dri_destroy_drawable. */
#define XCB_XF86DRI_DESTROY_DRAWABLE 8
/**
* @brief xcb_xf86dri_destroy_drawable_request_t
**/
typedef struct xcb_xf86dri_destroy_drawable_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t screen;
uint32_t drawable;
} xcb_xf86dri_destroy_drawable_request_t;
/**
* @brief xcb_xf86dri_get_drawable_info_cookie_t
**/
typedef struct xcb_xf86dri_get_drawable_info_cookie_t {
unsigned int sequence;
} xcb_xf86dri_get_drawable_info_cookie_t;
/** Opcode for xcb_xf86dri_get_drawable_info. */
#define XCB_XF86DRI_GET_DRAWABLE_INFO 9
/**
* @brief xcb_xf86dri_get_drawable_info_request_t
**/
typedef struct xcb_xf86dri_get_drawable_info_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t screen;
uint32_t drawable;
} xcb_xf86dri_get_drawable_info_request_t;
/**
* @brief xcb_xf86dri_get_drawable_info_reply_t
**/
typedef struct xcb_xf86dri_get_drawable_info_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t drawable_table_index;
uint32_t drawable_table_stamp;
int16_t drawable_origin_X;
int16_t drawable_origin_Y;
int16_t drawable_size_W;
int16_t drawable_size_H;
uint32_t num_clip_rects;
int16_t back_x;
int16_t back_y;
uint32_t num_back_clip_rects;
} xcb_xf86dri_get_drawable_info_reply_t;
/**
* @brief xcb_xf86dri_get_device_info_cookie_t
**/
typedef struct xcb_xf86dri_get_device_info_cookie_t {
unsigned int sequence;
} xcb_xf86dri_get_device_info_cookie_t;
/** Opcode for xcb_xf86dri_get_device_info. */
#define XCB_XF86DRI_GET_DEVICE_INFO 10
/**
* @brief xcb_xf86dri_get_device_info_request_t
**/
typedef struct xcb_xf86dri_get_device_info_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t screen;
} xcb_xf86dri_get_device_info_request_t;
/**
* @brief xcb_xf86dri_get_device_info_reply_t
**/
typedef struct xcb_xf86dri_get_device_info_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t framebuffer_handle_low;
uint32_t framebuffer_handle_high;
uint32_t framebuffer_origin_offset;
uint32_t framebuffer_size;
uint32_t framebuffer_stride;
uint32_t device_private_size;
} xcb_xf86dri_get_device_info_reply_t;
/**
* @brief xcb_xf86dri_auth_connection_cookie_t
**/
typedef struct xcb_xf86dri_auth_connection_cookie_t {
unsigned int sequence;
} xcb_xf86dri_auth_connection_cookie_t;
/** Opcode for xcb_xf86dri_auth_connection. */
#define XCB_XF86DRI_AUTH_CONNECTION 11
/**
* @brief xcb_xf86dri_auth_connection_request_t
**/
typedef struct xcb_xf86dri_auth_connection_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t screen;
uint32_t magic;
} xcb_xf86dri_auth_connection_request_t;
/**
* @brief xcb_xf86dri_auth_connection_reply_t
**/
typedef struct xcb_xf86dri_auth_connection_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t authenticated;
} xcb_xf86dri_auth_connection_reply_t;
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xf86dri_drm_clip_rect_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xf86dri_drm_clip_rect_t)
*/
void
xcb_xf86dri_drm_clip_rect_next (xcb_xf86dri_drm_clip_rect_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xf86dri_drm_clip_rect_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xf86dri_drm_clip_rect_end (xcb_xf86dri_drm_clip_rect_iterator_t i);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xf86dri_query_version_cookie_t
xcb_xf86dri_query_version (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xf86dri_query_version_cookie_t
xcb_xf86dri_query_version_unchecked (xcb_connection_t *c);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xf86dri_query_version_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xf86dri_query_version_reply_t *
xcb_xf86dri_query_version_reply (xcb_connection_t *c,
xcb_xf86dri_query_version_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xf86dri_query_direct_rendering_capable_cookie_t
xcb_xf86dri_query_direct_rendering_capable (xcb_connection_t *c,
uint32_t screen);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xf86dri_query_direct_rendering_capable_cookie_t
xcb_xf86dri_query_direct_rendering_capable_unchecked (xcb_connection_t *c,
uint32_t screen);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xf86dri_query_direct_rendering_capable_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xf86dri_query_direct_rendering_capable_reply_t *
xcb_xf86dri_query_direct_rendering_capable_reply (xcb_connection_t *c,
xcb_xf86dri_query_direct_rendering_capable_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_xf86dri_open_connection_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xf86dri_open_connection_cookie_t
xcb_xf86dri_open_connection (xcb_connection_t *c,
uint32_t screen);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xf86dri_open_connection_cookie_t
xcb_xf86dri_open_connection_unchecked (xcb_connection_t *c,
uint32_t screen);
char *
xcb_xf86dri_open_connection_bus_id (const xcb_xf86dri_open_connection_reply_t *R);
int
xcb_xf86dri_open_connection_bus_id_length (const xcb_xf86dri_open_connection_reply_t *R);
xcb_generic_iterator_t
xcb_xf86dri_open_connection_bus_id_end (const xcb_xf86dri_open_connection_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xf86dri_open_connection_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xf86dri_open_connection_reply_t *
xcb_xf86dri_open_connection_reply (xcb_connection_t *c,
xcb_xf86dri_open_connection_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xf86dri_close_connection_checked (xcb_connection_t *c,
uint32_t screen);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xf86dri_close_connection (xcb_connection_t *c,
uint32_t screen);
int
xcb_xf86dri_get_client_driver_name_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xf86dri_get_client_driver_name_cookie_t
xcb_xf86dri_get_client_driver_name (xcb_connection_t *c,
uint32_t screen);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xf86dri_get_client_driver_name_cookie_t
xcb_xf86dri_get_client_driver_name_unchecked (xcb_connection_t *c,
uint32_t screen);
char *
xcb_xf86dri_get_client_driver_name_client_driver_name (const xcb_xf86dri_get_client_driver_name_reply_t *R);
int
xcb_xf86dri_get_client_driver_name_client_driver_name_length (const xcb_xf86dri_get_client_driver_name_reply_t *R);
xcb_generic_iterator_t
xcb_xf86dri_get_client_driver_name_client_driver_name_end (const xcb_xf86dri_get_client_driver_name_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xf86dri_get_client_driver_name_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xf86dri_get_client_driver_name_reply_t *
xcb_xf86dri_get_client_driver_name_reply (xcb_connection_t *c,
xcb_xf86dri_get_client_driver_name_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xf86dri_create_context_cookie_t
xcb_xf86dri_create_context (xcb_connection_t *c,
uint32_t screen,
uint32_t visual,
uint32_t context);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xf86dri_create_context_cookie_t
xcb_xf86dri_create_context_unchecked (xcb_connection_t *c,
uint32_t screen,
uint32_t visual,
uint32_t context);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xf86dri_create_context_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xf86dri_create_context_reply_t *
xcb_xf86dri_create_context_reply (xcb_connection_t *c,
xcb_xf86dri_create_context_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xf86dri_destroy_context_checked (xcb_connection_t *c,
uint32_t screen,
uint32_t context);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xf86dri_destroy_context (xcb_connection_t *c,
uint32_t screen,
uint32_t context);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xf86dri_create_drawable_cookie_t
xcb_xf86dri_create_drawable (xcb_connection_t *c,
uint32_t screen,
uint32_t drawable);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xf86dri_create_drawable_cookie_t
xcb_xf86dri_create_drawable_unchecked (xcb_connection_t *c,
uint32_t screen,
uint32_t drawable);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xf86dri_create_drawable_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xf86dri_create_drawable_reply_t *
xcb_xf86dri_create_drawable_reply (xcb_connection_t *c,
xcb_xf86dri_create_drawable_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xf86dri_destroy_drawable_checked (xcb_connection_t *c,
uint32_t screen,
uint32_t drawable);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xf86dri_destroy_drawable (xcb_connection_t *c,
uint32_t screen,
uint32_t drawable);
int
xcb_xf86dri_get_drawable_info_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xf86dri_get_drawable_info_cookie_t
xcb_xf86dri_get_drawable_info (xcb_connection_t *c,
uint32_t screen,
uint32_t drawable);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xf86dri_get_drawable_info_cookie_t
xcb_xf86dri_get_drawable_info_unchecked (xcb_connection_t *c,
uint32_t screen,
uint32_t drawable);
xcb_xf86dri_drm_clip_rect_t *
xcb_xf86dri_get_drawable_info_clip_rects (const xcb_xf86dri_get_drawable_info_reply_t *R);
int
xcb_xf86dri_get_drawable_info_clip_rects_length (const xcb_xf86dri_get_drawable_info_reply_t *R);
xcb_xf86dri_drm_clip_rect_iterator_t
xcb_xf86dri_get_drawable_info_clip_rects_iterator (const xcb_xf86dri_get_drawable_info_reply_t *R);
xcb_xf86dri_drm_clip_rect_t *
xcb_xf86dri_get_drawable_info_back_clip_rects (const xcb_xf86dri_get_drawable_info_reply_t *R);
int
xcb_xf86dri_get_drawable_info_back_clip_rects_length (const xcb_xf86dri_get_drawable_info_reply_t *R);
xcb_xf86dri_drm_clip_rect_iterator_t
xcb_xf86dri_get_drawable_info_back_clip_rects_iterator (const xcb_xf86dri_get_drawable_info_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xf86dri_get_drawable_info_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xf86dri_get_drawable_info_reply_t *
xcb_xf86dri_get_drawable_info_reply (xcb_connection_t *c,
xcb_xf86dri_get_drawable_info_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_xf86dri_get_device_info_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xf86dri_get_device_info_cookie_t
xcb_xf86dri_get_device_info (xcb_connection_t *c,
uint32_t screen);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xf86dri_get_device_info_cookie_t
xcb_xf86dri_get_device_info_unchecked (xcb_connection_t *c,
uint32_t screen);
uint32_t *
xcb_xf86dri_get_device_info_device_private (const xcb_xf86dri_get_device_info_reply_t *R);
int
xcb_xf86dri_get_device_info_device_private_length (const xcb_xf86dri_get_device_info_reply_t *R);
xcb_generic_iterator_t
xcb_xf86dri_get_device_info_device_private_end (const xcb_xf86dri_get_device_info_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xf86dri_get_device_info_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xf86dri_get_device_info_reply_t *
xcb_xf86dri_get_device_info_reply (xcb_connection_t *c,
xcb_xf86dri_get_device_info_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xf86dri_auth_connection_cookie_t
xcb_xf86dri_auth_connection (xcb_connection_t *c,
uint32_t screen,
uint32_t magic);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xf86dri_auth_connection_cookie_t
xcb_xf86dri_auth_connection_unchecked (xcb_connection_t *c,
uint32_t screen,
uint32_t magic);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xf86dri_auth_connection_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xf86dri_auth_connection_reply_t *
xcb_xf86dri_auth_connection_reply (xcb_connection_t *c,
xcb_xf86dri_auth_connection_cookie_t cookie /**< */,
xcb_generic_error_t **e);
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/
xcb/xvmc.h 0000644 00000057722 15201526705 0006466 0 ustar 00 /*
* This file generated automatically from xvmc.xml by c_client.py.
* Edit at your peril.
*/
/**
* @defgroup XCB_XvMC_API XCB XvMC API
* @brief XvMC XCB Protocol Implementation.
* @{
**/
#ifndef __XVMC_H
#define __XVMC_H
#include "xcb.h"
#include "xv.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XCB_XVMC_MAJOR_VERSION 1
#define XCB_XVMC_MINOR_VERSION 1
extern xcb_extension_t xcb_xvmc_id;
typedef uint32_t xcb_xvmc_context_t;
/**
* @brief xcb_xvmc_context_iterator_t
**/
typedef struct xcb_xvmc_context_iterator_t {
xcb_xvmc_context_t *data;
int rem;
int index;
} xcb_xvmc_context_iterator_t;
typedef uint32_t xcb_xvmc_surface_t;
/**
* @brief xcb_xvmc_surface_iterator_t
**/
typedef struct xcb_xvmc_surface_iterator_t {
xcb_xvmc_surface_t *data;
int rem;
int index;
} xcb_xvmc_surface_iterator_t;
typedef uint32_t xcb_xvmc_subpicture_t;
/**
* @brief xcb_xvmc_subpicture_iterator_t
**/
typedef struct xcb_xvmc_subpicture_iterator_t {
xcb_xvmc_subpicture_t *data;
int rem;
int index;
} xcb_xvmc_subpicture_iterator_t;
/**
* @brief xcb_xvmc_surface_info_t
**/
typedef struct xcb_xvmc_surface_info_t {
xcb_xvmc_surface_t id;
uint16_t chroma_format;
uint16_t pad0;
uint16_t max_width;
uint16_t max_height;
uint16_t subpicture_max_width;
uint16_t subpicture_max_height;
uint32_t mc_type;
uint32_t flags;
} xcb_xvmc_surface_info_t;
/**
* @brief xcb_xvmc_surface_info_iterator_t
**/
typedef struct xcb_xvmc_surface_info_iterator_t {
xcb_xvmc_surface_info_t *data;
int rem;
int index;
} xcb_xvmc_surface_info_iterator_t;
/**
* @brief xcb_xvmc_query_version_cookie_t
**/
typedef struct xcb_xvmc_query_version_cookie_t {
unsigned int sequence;
} xcb_xvmc_query_version_cookie_t;
/** Opcode for xcb_xvmc_query_version. */
#define XCB_XVMC_QUERY_VERSION 0
/**
* @brief xcb_xvmc_query_version_request_t
**/
typedef struct xcb_xvmc_query_version_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_xvmc_query_version_request_t;
/**
* @brief xcb_xvmc_query_version_reply_t
**/
typedef struct xcb_xvmc_query_version_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t major;
uint32_t minor;
} xcb_xvmc_query_version_reply_t;
/**
* @brief xcb_xvmc_list_surface_types_cookie_t
**/
typedef struct xcb_xvmc_list_surface_types_cookie_t {
unsigned int sequence;
} xcb_xvmc_list_surface_types_cookie_t;
/** Opcode for xcb_xvmc_list_surface_types. */
#define XCB_XVMC_LIST_SURFACE_TYPES 1
/**
* @brief xcb_xvmc_list_surface_types_request_t
**/
typedef struct xcb_xvmc_list_surface_types_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xv_port_t port_id;
} xcb_xvmc_list_surface_types_request_t;
/**
* @brief xcb_xvmc_list_surface_types_reply_t
**/
typedef struct xcb_xvmc_list_surface_types_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t num;
uint8_t pad1[20];
} xcb_xvmc_list_surface_types_reply_t;
/**
* @brief xcb_xvmc_create_context_cookie_t
**/
typedef struct xcb_xvmc_create_context_cookie_t {
unsigned int sequence;
} xcb_xvmc_create_context_cookie_t;
/** Opcode for xcb_xvmc_create_context. */
#define XCB_XVMC_CREATE_CONTEXT 2
/**
* @brief xcb_xvmc_create_context_request_t
**/
typedef struct xcb_xvmc_create_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xvmc_context_t context_id;
xcb_xv_port_t port_id;
xcb_xvmc_surface_t surface_id;
uint16_t width;
uint16_t height;
uint32_t flags;
} xcb_xvmc_create_context_request_t;
/**
* @brief xcb_xvmc_create_context_reply_t
**/
typedef struct xcb_xvmc_create_context_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t width_actual;
uint16_t height_actual;
uint32_t flags_return;
uint8_t pad1[20];
} xcb_xvmc_create_context_reply_t;
/** Opcode for xcb_xvmc_destroy_context. */
#define XCB_XVMC_DESTROY_CONTEXT 3
/**
* @brief xcb_xvmc_destroy_context_request_t
**/
typedef struct xcb_xvmc_destroy_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xvmc_context_t context_id;
} xcb_xvmc_destroy_context_request_t;
/**
* @brief xcb_xvmc_create_surface_cookie_t
**/
typedef struct xcb_xvmc_create_surface_cookie_t {
unsigned int sequence;
} xcb_xvmc_create_surface_cookie_t;
/** Opcode for xcb_xvmc_create_surface. */
#define XCB_XVMC_CREATE_SURFACE 4
/**
* @brief xcb_xvmc_create_surface_request_t
**/
typedef struct xcb_xvmc_create_surface_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xvmc_surface_t surface_id;
xcb_xvmc_context_t context_id;
} xcb_xvmc_create_surface_request_t;
/**
* @brief xcb_xvmc_create_surface_reply_t
**/
typedef struct xcb_xvmc_create_surface_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[24];
} xcb_xvmc_create_surface_reply_t;
/** Opcode for xcb_xvmc_destroy_surface. */
#define XCB_XVMC_DESTROY_SURFACE 5
/**
* @brief xcb_xvmc_destroy_surface_request_t
**/
typedef struct xcb_xvmc_destroy_surface_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xvmc_surface_t surface_id;
} xcb_xvmc_destroy_surface_request_t;
/**
* @brief xcb_xvmc_create_subpicture_cookie_t
**/
typedef struct xcb_xvmc_create_subpicture_cookie_t {
unsigned int sequence;
} xcb_xvmc_create_subpicture_cookie_t;
/** Opcode for xcb_xvmc_create_subpicture. */
#define XCB_XVMC_CREATE_SUBPICTURE 6
/**
* @brief xcb_xvmc_create_subpicture_request_t
**/
typedef struct xcb_xvmc_create_subpicture_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xvmc_subpicture_t subpicture_id;
xcb_xvmc_context_t context;
uint32_t xvimage_id;
uint16_t width;
uint16_t height;
} xcb_xvmc_create_subpicture_request_t;
/**
* @brief xcb_xvmc_create_subpicture_reply_t
**/
typedef struct xcb_xvmc_create_subpicture_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t width_actual;
uint16_t height_actual;
uint16_t num_palette_entries;
uint16_t entry_bytes;
uint8_t component_order[4];
uint8_t pad1[12];
} xcb_xvmc_create_subpicture_reply_t;
/** Opcode for xcb_xvmc_destroy_subpicture. */
#define XCB_XVMC_DESTROY_SUBPICTURE 7
/**
* @brief xcb_xvmc_destroy_subpicture_request_t
**/
typedef struct xcb_xvmc_destroy_subpicture_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xvmc_subpicture_t subpicture_id;
} xcb_xvmc_destroy_subpicture_request_t;
/**
* @brief xcb_xvmc_list_subpicture_types_cookie_t
**/
typedef struct xcb_xvmc_list_subpicture_types_cookie_t {
unsigned int sequence;
} xcb_xvmc_list_subpicture_types_cookie_t;
/** Opcode for xcb_xvmc_list_subpicture_types. */
#define XCB_XVMC_LIST_SUBPICTURE_TYPES 8
/**
* @brief xcb_xvmc_list_subpicture_types_request_t
**/
typedef struct xcb_xvmc_list_subpicture_types_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xv_port_t port_id;
xcb_xvmc_surface_t surface_id;
} xcb_xvmc_list_subpicture_types_request_t;
/**
* @brief xcb_xvmc_list_subpicture_types_reply_t
**/
typedef struct xcb_xvmc_list_subpicture_types_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t num;
uint8_t pad1[20];
} xcb_xvmc_list_subpicture_types_reply_t;
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xvmc_context_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xvmc_context_t)
*/
void
xcb_xvmc_context_next (xcb_xvmc_context_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xvmc_context_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xvmc_context_end (xcb_xvmc_context_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xvmc_surface_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xvmc_surface_t)
*/
void
xcb_xvmc_surface_next (xcb_xvmc_surface_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xvmc_surface_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xvmc_surface_end (xcb_xvmc_surface_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xvmc_subpicture_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xvmc_subpicture_t)
*/
void
xcb_xvmc_subpicture_next (xcb_xvmc_subpicture_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xvmc_subpicture_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xvmc_subpicture_end (xcb_xvmc_subpicture_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xvmc_surface_info_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xvmc_surface_info_t)
*/
void
xcb_xvmc_surface_info_next (xcb_xvmc_surface_info_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xvmc_surface_info_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xvmc_surface_info_end (xcb_xvmc_surface_info_iterator_t i);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xvmc_query_version_cookie_t
xcb_xvmc_query_version (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xvmc_query_version_cookie_t
xcb_xvmc_query_version_unchecked (xcb_connection_t *c);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xvmc_query_version_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xvmc_query_version_reply_t *
xcb_xvmc_query_version_reply (xcb_connection_t *c,
xcb_xvmc_query_version_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_xvmc_list_surface_types_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xvmc_list_surface_types_cookie_t
xcb_xvmc_list_surface_types (xcb_connection_t *c,
xcb_xv_port_t port_id);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xvmc_list_surface_types_cookie_t
xcb_xvmc_list_surface_types_unchecked (xcb_connection_t *c,
xcb_xv_port_t port_id);
xcb_xvmc_surface_info_t *
xcb_xvmc_list_surface_types_surfaces (const xcb_xvmc_list_surface_types_reply_t *R);
int
xcb_xvmc_list_surface_types_surfaces_length (const xcb_xvmc_list_surface_types_reply_t *R);
xcb_xvmc_surface_info_iterator_t
xcb_xvmc_list_surface_types_surfaces_iterator (const xcb_xvmc_list_surface_types_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xvmc_list_surface_types_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xvmc_list_surface_types_reply_t *
xcb_xvmc_list_surface_types_reply (xcb_connection_t *c,
xcb_xvmc_list_surface_types_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_xvmc_create_context_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xvmc_create_context_cookie_t
xcb_xvmc_create_context (xcb_connection_t *c,
xcb_xvmc_context_t context_id,
xcb_xv_port_t port_id,
xcb_xvmc_surface_t surface_id,
uint16_t width,
uint16_t height,
uint32_t flags);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xvmc_create_context_cookie_t
xcb_xvmc_create_context_unchecked (xcb_connection_t *c,
xcb_xvmc_context_t context_id,
xcb_xv_port_t port_id,
xcb_xvmc_surface_t surface_id,
uint16_t width,
uint16_t height,
uint32_t flags);
uint32_t *
xcb_xvmc_create_context_priv_data (const xcb_xvmc_create_context_reply_t *R);
int
xcb_xvmc_create_context_priv_data_length (const xcb_xvmc_create_context_reply_t *R);
xcb_generic_iterator_t
xcb_xvmc_create_context_priv_data_end (const xcb_xvmc_create_context_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xvmc_create_context_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xvmc_create_context_reply_t *
xcb_xvmc_create_context_reply (xcb_connection_t *c,
xcb_xvmc_create_context_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xvmc_destroy_context_checked (xcb_connection_t *c,
xcb_xvmc_context_t context_id);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xvmc_destroy_context (xcb_connection_t *c,
xcb_xvmc_context_t context_id);
int
xcb_xvmc_create_surface_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xvmc_create_surface_cookie_t
xcb_xvmc_create_surface (xcb_connection_t *c,
xcb_xvmc_surface_t surface_id,
xcb_xvmc_context_t context_id);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xvmc_create_surface_cookie_t
xcb_xvmc_create_surface_unchecked (xcb_connection_t *c,
xcb_xvmc_surface_t surface_id,
xcb_xvmc_context_t context_id);
uint32_t *
xcb_xvmc_create_surface_priv_data (const xcb_xvmc_create_surface_reply_t *R);
int
xcb_xvmc_create_surface_priv_data_length (const xcb_xvmc_create_surface_reply_t *R);
xcb_generic_iterator_t
xcb_xvmc_create_surface_priv_data_end (const xcb_xvmc_create_surface_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xvmc_create_surface_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xvmc_create_surface_reply_t *
xcb_xvmc_create_surface_reply (xcb_connection_t *c,
xcb_xvmc_create_surface_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xvmc_destroy_surface_checked (xcb_connection_t *c,
xcb_xvmc_surface_t surface_id);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xvmc_destroy_surface (xcb_connection_t *c,
xcb_xvmc_surface_t surface_id);
int
xcb_xvmc_create_subpicture_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xvmc_create_subpicture_cookie_t
xcb_xvmc_create_subpicture (xcb_connection_t *c,
xcb_xvmc_subpicture_t subpicture_id,
xcb_xvmc_context_t context,
uint32_t xvimage_id,
uint16_t width,
uint16_t height);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xvmc_create_subpicture_cookie_t
xcb_xvmc_create_subpicture_unchecked (xcb_connection_t *c,
xcb_xvmc_subpicture_t subpicture_id,
xcb_xvmc_context_t context,
uint32_t xvimage_id,
uint16_t width,
uint16_t height);
uint32_t *
xcb_xvmc_create_subpicture_priv_data (const xcb_xvmc_create_subpicture_reply_t *R);
int
xcb_xvmc_create_subpicture_priv_data_length (const xcb_xvmc_create_subpicture_reply_t *R);
xcb_generic_iterator_t
xcb_xvmc_create_subpicture_priv_data_end (const xcb_xvmc_create_subpicture_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xvmc_create_subpicture_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xvmc_create_subpicture_reply_t *
xcb_xvmc_create_subpicture_reply (xcb_connection_t *c,
xcb_xvmc_create_subpicture_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xvmc_destroy_subpicture_checked (xcb_connection_t *c,
xcb_xvmc_subpicture_t subpicture_id);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xvmc_destroy_subpicture (xcb_connection_t *c,
xcb_xvmc_subpicture_t subpicture_id);
int
xcb_xvmc_list_subpicture_types_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xvmc_list_subpicture_types_cookie_t
xcb_xvmc_list_subpicture_types (xcb_connection_t *c,
xcb_xv_port_t port_id,
xcb_xvmc_surface_t surface_id);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xvmc_list_subpicture_types_cookie_t
xcb_xvmc_list_subpicture_types_unchecked (xcb_connection_t *c,
xcb_xv_port_t port_id,
xcb_xvmc_surface_t surface_id);
xcb_xv_image_format_info_t *
xcb_xvmc_list_subpicture_types_types (const xcb_xvmc_list_subpicture_types_reply_t *R);
int
xcb_xvmc_list_subpicture_types_types_length (const xcb_xvmc_list_subpicture_types_reply_t *R);
xcb_xv_image_format_info_iterator_t
xcb_xvmc_list_subpicture_types_types_iterator (const xcb_xvmc_list_subpicture_types_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xvmc_list_subpicture_types_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xvmc_list_subpicture_types_reply_t *
xcb_xvmc_list_subpicture_types_reply (xcb_connection_t *c,
xcb_xvmc_list_subpicture_types_cookie_t cookie /**< */,
xcb_generic_error_t **e);
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/
xcb/dri2.h 0000644 00000105657 15201526705 0006352 0 ustar 00 /*
* This file generated automatically from dri2.xml by c_client.py.
* Edit at your peril.
*/
/**
* @defgroup XCB_DRI2_API XCB DRI2 API
* @brief DRI2 XCB Protocol Implementation.
* @{
**/
#ifndef __DRI2_H
#define __DRI2_H
#include "xcb.h"
#include "xproto.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XCB_DRI2_MAJOR_VERSION 1
#define XCB_DRI2_MINOR_VERSION 4
extern xcb_extension_t xcb_dri2_id;
typedef enum xcb_dri2_attachment_t {
XCB_DRI2_ATTACHMENT_BUFFER_FRONT_LEFT = 0,
XCB_DRI2_ATTACHMENT_BUFFER_BACK_LEFT = 1,
XCB_DRI2_ATTACHMENT_BUFFER_FRONT_RIGHT = 2,
XCB_DRI2_ATTACHMENT_BUFFER_BACK_RIGHT = 3,
XCB_DRI2_ATTACHMENT_BUFFER_DEPTH = 4,
XCB_DRI2_ATTACHMENT_BUFFER_STENCIL = 5,
XCB_DRI2_ATTACHMENT_BUFFER_ACCUM = 6,
XCB_DRI2_ATTACHMENT_BUFFER_FAKE_FRONT_LEFT = 7,
XCB_DRI2_ATTACHMENT_BUFFER_FAKE_FRONT_RIGHT = 8,
XCB_DRI2_ATTACHMENT_BUFFER_DEPTH_STENCIL = 9,
XCB_DRI2_ATTACHMENT_BUFFER_HIZ = 10
} xcb_dri2_attachment_t;
typedef enum xcb_dri2_driver_type_t {
XCB_DRI2_DRIVER_TYPE_DRI = 0,
XCB_DRI2_DRIVER_TYPE_VDPAU = 1
} xcb_dri2_driver_type_t;
typedef enum xcb_dri2_event_type_t {
XCB_DRI2_EVENT_TYPE_EXCHANGE_COMPLETE = 1,
XCB_DRI2_EVENT_TYPE_BLIT_COMPLETE = 2,
XCB_DRI2_EVENT_TYPE_FLIP_COMPLETE = 3
} xcb_dri2_event_type_t;
/**
* @brief xcb_dri2_dri2_buffer_t
**/
typedef struct xcb_dri2_dri2_buffer_t {
uint32_t attachment;
uint32_t name;
uint32_t pitch;
uint32_t cpp;
uint32_t flags;
} xcb_dri2_dri2_buffer_t;
/**
* @brief xcb_dri2_dri2_buffer_iterator_t
**/
typedef struct xcb_dri2_dri2_buffer_iterator_t {
xcb_dri2_dri2_buffer_t *data;
int rem;
int index;
} xcb_dri2_dri2_buffer_iterator_t;
/**
* @brief xcb_dri2_attach_format_t
**/
typedef struct xcb_dri2_attach_format_t {
uint32_t attachment;
uint32_t format;
} xcb_dri2_attach_format_t;
/**
* @brief xcb_dri2_attach_format_iterator_t
**/
typedef struct xcb_dri2_attach_format_iterator_t {
xcb_dri2_attach_format_t *data;
int rem;
int index;
} xcb_dri2_attach_format_iterator_t;
/**
* @brief xcb_dri2_query_version_cookie_t
**/
typedef struct xcb_dri2_query_version_cookie_t {
unsigned int sequence;
} xcb_dri2_query_version_cookie_t;
/** Opcode for xcb_dri2_query_version. */
#define XCB_DRI2_QUERY_VERSION 0
/**
* @brief xcb_dri2_query_version_request_t
**/
typedef struct xcb_dri2_query_version_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t major_version;
uint32_t minor_version;
} xcb_dri2_query_version_request_t;
/**
* @brief xcb_dri2_query_version_reply_t
**/
typedef struct xcb_dri2_query_version_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t major_version;
uint32_t minor_version;
} xcb_dri2_query_version_reply_t;
/**
* @brief xcb_dri2_connect_cookie_t
**/
typedef struct xcb_dri2_connect_cookie_t {
unsigned int sequence;
} xcb_dri2_connect_cookie_t;
/** Opcode for xcb_dri2_connect. */
#define XCB_DRI2_CONNECT 1
/**
* @brief xcb_dri2_connect_request_t
**/
typedef struct xcb_dri2_connect_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
uint32_t driver_type;
} xcb_dri2_connect_request_t;
/**
* @brief xcb_dri2_connect_reply_t
**/
typedef struct xcb_dri2_connect_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t driver_name_length;
uint32_t device_name_length;
uint8_t pad1[16];
} xcb_dri2_connect_reply_t;
/**
* @brief xcb_dri2_authenticate_cookie_t
**/
typedef struct xcb_dri2_authenticate_cookie_t {
unsigned int sequence;
} xcb_dri2_authenticate_cookie_t;
/** Opcode for xcb_dri2_authenticate. */
#define XCB_DRI2_AUTHENTICATE 2
/**
* @brief xcb_dri2_authenticate_request_t
**/
typedef struct xcb_dri2_authenticate_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
uint32_t magic;
} xcb_dri2_authenticate_request_t;
/**
* @brief xcb_dri2_authenticate_reply_t
**/
typedef struct xcb_dri2_authenticate_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t authenticated;
} xcb_dri2_authenticate_reply_t;
/** Opcode for xcb_dri2_create_drawable. */
#define XCB_DRI2_CREATE_DRAWABLE 3
/**
* @brief xcb_dri2_create_drawable_request_t
**/
typedef struct xcb_dri2_create_drawable_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_drawable_t drawable;
} xcb_dri2_create_drawable_request_t;
/** Opcode for xcb_dri2_destroy_drawable. */
#define XCB_DRI2_DESTROY_DRAWABLE 4
/**
* @brief xcb_dri2_destroy_drawable_request_t
**/
typedef struct xcb_dri2_destroy_drawable_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_drawable_t drawable;
} xcb_dri2_destroy_drawable_request_t;
/**
* @brief xcb_dri2_get_buffers_cookie_t
**/
typedef struct xcb_dri2_get_buffers_cookie_t {
unsigned int sequence;
} xcb_dri2_get_buffers_cookie_t;
/** Opcode for xcb_dri2_get_buffers. */
#define XCB_DRI2_GET_BUFFERS 5
/**
* @brief xcb_dri2_get_buffers_request_t
**/
typedef struct xcb_dri2_get_buffers_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_drawable_t drawable;
uint32_t count;
} xcb_dri2_get_buffers_request_t;
/**
* @brief xcb_dri2_get_buffers_reply_t
**/
typedef struct xcb_dri2_get_buffers_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t width;
uint32_t height;
uint32_t count;
uint8_t pad1[12];
} xcb_dri2_get_buffers_reply_t;
/**
* @brief xcb_dri2_copy_region_cookie_t
**/
typedef struct xcb_dri2_copy_region_cookie_t {
unsigned int sequence;
} xcb_dri2_copy_region_cookie_t;
/** Opcode for xcb_dri2_copy_region. */
#define XCB_DRI2_COPY_REGION 6
/**
* @brief xcb_dri2_copy_region_request_t
**/
typedef struct xcb_dri2_copy_region_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_drawable_t drawable;
uint32_t region;
uint32_t dest;
uint32_t src;
} xcb_dri2_copy_region_request_t;
/**
* @brief xcb_dri2_copy_region_reply_t
**/
typedef struct xcb_dri2_copy_region_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
} xcb_dri2_copy_region_reply_t;
/**
* @brief xcb_dri2_get_buffers_with_format_cookie_t
**/
typedef struct xcb_dri2_get_buffers_with_format_cookie_t {
unsigned int sequence;
} xcb_dri2_get_buffers_with_format_cookie_t;
/** Opcode for xcb_dri2_get_buffers_with_format. */
#define XCB_DRI2_GET_BUFFERS_WITH_FORMAT 7
/**
* @brief xcb_dri2_get_buffers_with_format_request_t
**/
typedef struct xcb_dri2_get_buffers_with_format_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_drawable_t drawable;
uint32_t count;
} xcb_dri2_get_buffers_with_format_request_t;
/**
* @brief xcb_dri2_get_buffers_with_format_reply_t
**/
typedef struct xcb_dri2_get_buffers_with_format_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t width;
uint32_t height;
uint32_t count;
uint8_t pad1[12];
} xcb_dri2_get_buffers_with_format_reply_t;
/**
* @brief xcb_dri2_swap_buffers_cookie_t
**/
typedef struct xcb_dri2_swap_buffers_cookie_t {
unsigned int sequence;
} xcb_dri2_swap_buffers_cookie_t;
/** Opcode for xcb_dri2_swap_buffers. */
#define XCB_DRI2_SWAP_BUFFERS 8
/**
* @brief xcb_dri2_swap_buffers_request_t
**/
typedef struct xcb_dri2_swap_buffers_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_drawable_t drawable;
uint32_t target_msc_hi;
uint32_t target_msc_lo;
uint32_t divisor_hi;
uint32_t divisor_lo;
uint32_t remainder_hi;
uint32_t remainder_lo;
} xcb_dri2_swap_buffers_request_t;
/**
* @brief xcb_dri2_swap_buffers_reply_t
**/
typedef struct xcb_dri2_swap_buffers_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t swap_hi;
uint32_t swap_lo;
} xcb_dri2_swap_buffers_reply_t;
/**
* @brief xcb_dri2_get_msc_cookie_t
**/
typedef struct xcb_dri2_get_msc_cookie_t {
unsigned int sequence;
} xcb_dri2_get_msc_cookie_t;
/** Opcode for xcb_dri2_get_msc. */
#define XCB_DRI2_GET_MSC 9
/**
* @brief xcb_dri2_get_msc_request_t
**/
typedef struct xcb_dri2_get_msc_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_drawable_t drawable;
} xcb_dri2_get_msc_request_t;
/**
* @brief xcb_dri2_get_msc_reply_t
**/
typedef struct xcb_dri2_get_msc_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t ust_hi;
uint32_t ust_lo;
uint32_t msc_hi;
uint32_t msc_lo;
uint32_t sbc_hi;
uint32_t sbc_lo;
} xcb_dri2_get_msc_reply_t;
/**
* @brief xcb_dri2_wait_msc_cookie_t
**/
typedef struct xcb_dri2_wait_msc_cookie_t {
unsigned int sequence;
} xcb_dri2_wait_msc_cookie_t;
/** Opcode for xcb_dri2_wait_msc. */
#define XCB_DRI2_WAIT_MSC 10
/**
* @brief xcb_dri2_wait_msc_request_t
**/
typedef struct xcb_dri2_wait_msc_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_drawable_t drawable;
uint32_t target_msc_hi;
uint32_t target_msc_lo;
uint32_t divisor_hi;
uint32_t divisor_lo;
uint32_t remainder_hi;
uint32_t remainder_lo;
} xcb_dri2_wait_msc_request_t;
/**
* @brief xcb_dri2_wait_msc_reply_t
**/
typedef struct xcb_dri2_wait_msc_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t ust_hi;
uint32_t ust_lo;
uint32_t msc_hi;
uint32_t msc_lo;
uint32_t sbc_hi;
uint32_t sbc_lo;
} xcb_dri2_wait_msc_reply_t;
/**
* @brief xcb_dri2_wait_sbc_cookie_t
**/
typedef struct xcb_dri2_wait_sbc_cookie_t {
unsigned int sequence;
} xcb_dri2_wait_sbc_cookie_t;
/** Opcode for xcb_dri2_wait_sbc. */
#define XCB_DRI2_WAIT_SBC 11
/**
* @brief xcb_dri2_wait_sbc_request_t
**/
typedef struct xcb_dri2_wait_sbc_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_drawable_t drawable;
uint32_t target_sbc_hi;
uint32_t target_sbc_lo;
} xcb_dri2_wait_sbc_request_t;
/**
* @brief xcb_dri2_wait_sbc_reply_t
**/
typedef struct xcb_dri2_wait_sbc_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t ust_hi;
uint32_t ust_lo;
uint32_t msc_hi;
uint32_t msc_lo;
uint32_t sbc_hi;
uint32_t sbc_lo;
} xcb_dri2_wait_sbc_reply_t;
/** Opcode for xcb_dri2_swap_interval. */
#define XCB_DRI2_SWAP_INTERVAL 12
/**
* @brief xcb_dri2_swap_interval_request_t
**/
typedef struct xcb_dri2_swap_interval_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_drawable_t drawable;
uint32_t interval;
} xcb_dri2_swap_interval_request_t;
/**
* @brief xcb_dri2_get_param_cookie_t
**/
typedef struct xcb_dri2_get_param_cookie_t {
unsigned int sequence;
} xcb_dri2_get_param_cookie_t;
/** Opcode for xcb_dri2_get_param. */
#define XCB_DRI2_GET_PARAM 13
/**
* @brief xcb_dri2_get_param_request_t
**/
typedef struct xcb_dri2_get_param_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_drawable_t drawable;
uint32_t param;
} xcb_dri2_get_param_request_t;
/**
* @brief xcb_dri2_get_param_reply_t
**/
typedef struct xcb_dri2_get_param_reply_t {
uint8_t response_type;
uint8_t is_param_recognized;
uint16_t sequence;
uint32_t length;
uint32_t value_hi;
uint32_t value_lo;
} xcb_dri2_get_param_reply_t;
/** Opcode for xcb_dri2_buffer_swap_complete. */
#define XCB_DRI2_BUFFER_SWAP_COMPLETE 0
/**
* @brief xcb_dri2_buffer_swap_complete_event_t
**/
typedef struct xcb_dri2_buffer_swap_complete_event_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint16_t event_type;
uint8_t pad1[2];
xcb_drawable_t drawable;
uint32_t ust_hi;
uint32_t ust_lo;
uint32_t msc_hi;
uint32_t msc_lo;
uint32_t sbc;
} xcb_dri2_buffer_swap_complete_event_t;
/** Opcode for xcb_dri2_invalidate_buffers. */
#define XCB_DRI2_INVALIDATE_BUFFERS 1
/**
* @brief xcb_dri2_invalidate_buffers_event_t
**/
typedef struct xcb_dri2_invalidate_buffers_event_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
xcb_drawable_t drawable;
} xcb_dri2_invalidate_buffers_event_t;
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_dri2_dri2_buffer_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_dri2_dri2_buffer_t)
*/
void
xcb_dri2_dri2_buffer_next (xcb_dri2_dri2_buffer_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_dri2_dri2_buffer_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_dri2_dri2_buffer_end (xcb_dri2_dri2_buffer_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_dri2_attach_format_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_dri2_attach_format_t)
*/
void
xcb_dri2_attach_format_next (xcb_dri2_attach_format_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_dri2_attach_format_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_dri2_attach_format_end (xcb_dri2_attach_format_iterator_t i);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_dri2_query_version_cookie_t
xcb_dri2_query_version (xcb_connection_t *c,
uint32_t major_version,
uint32_t minor_version);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_dri2_query_version_cookie_t
xcb_dri2_query_version_unchecked (xcb_connection_t *c,
uint32_t major_version,
uint32_t minor_version);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_dri2_query_version_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_dri2_query_version_reply_t *
xcb_dri2_query_version_reply (xcb_connection_t *c,
xcb_dri2_query_version_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_dri2_connect_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_dri2_connect_cookie_t
xcb_dri2_connect (xcb_connection_t *c,
xcb_window_t window,
uint32_t driver_type);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_dri2_connect_cookie_t
xcb_dri2_connect_unchecked (xcb_connection_t *c,
xcb_window_t window,
uint32_t driver_type);
char *
xcb_dri2_connect_driver_name (const xcb_dri2_connect_reply_t *R);
int
xcb_dri2_connect_driver_name_length (const xcb_dri2_connect_reply_t *R);
xcb_generic_iterator_t
xcb_dri2_connect_driver_name_end (const xcb_dri2_connect_reply_t *R);
void *
xcb_dri2_connect_alignment_pad (const xcb_dri2_connect_reply_t *R);
int
xcb_dri2_connect_alignment_pad_length (const xcb_dri2_connect_reply_t *R);
xcb_generic_iterator_t
xcb_dri2_connect_alignment_pad_end (const xcb_dri2_connect_reply_t *R);
char *
xcb_dri2_connect_device_name (const xcb_dri2_connect_reply_t *R);
int
xcb_dri2_connect_device_name_length (const xcb_dri2_connect_reply_t *R);
xcb_generic_iterator_t
xcb_dri2_connect_device_name_end (const xcb_dri2_connect_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_dri2_connect_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_dri2_connect_reply_t *
xcb_dri2_connect_reply (xcb_connection_t *c,
xcb_dri2_connect_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_dri2_authenticate_cookie_t
xcb_dri2_authenticate (xcb_connection_t *c,
xcb_window_t window,
uint32_t magic);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_dri2_authenticate_cookie_t
xcb_dri2_authenticate_unchecked (xcb_connection_t *c,
xcb_window_t window,
uint32_t magic);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_dri2_authenticate_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_dri2_authenticate_reply_t *
xcb_dri2_authenticate_reply (xcb_connection_t *c,
xcb_dri2_authenticate_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_dri2_create_drawable_checked (xcb_connection_t *c,
xcb_drawable_t drawable);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_dri2_create_drawable (xcb_connection_t *c,
xcb_drawable_t drawable);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_dri2_destroy_drawable_checked (xcb_connection_t *c,
xcb_drawable_t drawable);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_dri2_destroy_drawable (xcb_connection_t *c,
xcb_drawable_t drawable);
int
xcb_dri2_get_buffers_sizeof (const void *_buffer,
uint32_t attachments_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_dri2_get_buffers_cookie_t
xcb_dri2_get_buffers (xcb_connection_t *c,
xcb_drawable_t drawable,
uint32_t count,
uint32_t attachments_len,
const uint32_t *attachments);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_dri2_get_buffers_cookie_t
xcb_dri2_get_buffers_unchecked (xcb_connection_t *c,
xcb_drawable_t drawable,
uint32_t count,
uint32_t attachments_len,
const uint32_t *attachments);
xcb_dri2_dri2_buffer_t *
xcb_dri2_get_buffers_buffers (const xcb_dri2_get_buffers_reply_t *R);
int
xcb_dri2_get_buffers_buffers_length (const xcb_dri2_get_buffers_reply_t *R);
xcb_dri2_dri2_buffer_iterator_t
xcb_dri2_get_buffers_buffers_iterator (const xcb_dri2_get_buffers_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_dri2_get_buffers_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_dri2_get_buffers_reply_t *
xcb_dri2_get_buffers_reply (xcb_connection_t *c,
xcb_dri2_get_buffers_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_dri2_copy_region_cookie_t
xcb_dri2_copy_region (xcb_connection_t *c,
xcb_drawable_t drawable,
uint32_t region,
uint32_t dest,
uint32_t src);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_dri2_copy_region_cookie_t
xcb_dri2_copy_region_unchecked (xcb_connection_t *c,
xcb_drawable_t drawable,
uint32_t region,
uint32_t dest,
uint32_t src);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_dri2_copy_region_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_dri2_copy_region_reply_t *
xcb_dri2_copy_region_reply (xcb_connection_t *c,
xcb_dri2_copy_region_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_dri2_get_buffers_with_format_sizeof (const void *_buffer,
uint32_t attachments_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_dri2_get_buffers_with_format_cookie_t
xcb_dri2_get_buffers_with_format (xcb_connection_t *c,
xcb_drawable_t drawable,
uint32_t count,
uint32_t attachments_len,
const xcb_dri2_attach_format_t *attachments);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_dri2_get_buffers_with_format_cookie_t
xcb_dri2_get_buffers_with_format_unchecked (xcb_connection_t *c,
xcb_drawable_t drawable,
uint32_t count,
uint32_t attachments_len,
const xcb_dri2_attach_format_t *attachments);
xcb_dri2_dri2_buffer_t *
xcb_dri2_get_buffers_with_format_buffers (const xcb_dri2_get_buffers_with_format_reply_t *R);
int
xcb_dri2_get_buffers_with_format_buffers_length (const xcb_dri2_get_buffers_with_format_reply_t *R);
xcb_dri2_dri2_buffer_iterator_t
xcb_dri2_get_buffers_with_format_buffers_iterator (const xcb_dri2_get_buffers_with_format_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_dri2_get_buffers_with_format_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_dri2_get_buffers_with_format_reply_t *
xcb_dri2_get_buffers_with_format_reply (xcb_connection_t *c,
xcb_dri2_get_buffers_with_format_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_dri2_swap_buffers_cookie_t
xcb_dri2_swap_buffers (xcb_connection_t *c,
xcb_drawable_t drawable,
uint32_t target_msc_hi,
uint32_t target_msc_lo,
uint32_t divisor_hi,
uint32_t divisor_lo,
uint32_t remainder_hi,
uint32_t remainder_lo);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_dri2_swap_buffers_cookie_t
xcb_dri2_swap_buffers_unchecked (xcb_connection_t *c,
xcb_drawable_t drawable,
uint32_t target_msc_hi,
uint32_t target_msc_lo,
uint32_t divisor_hi,
uint32_t divisor_lo,
uint32_t remainder_hi,
uint32_t remainder_lo);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_dri2_swap_buffers_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_dri2_swap_buffers_reply_t *
xcb_dri2_swap_buffers_reply (xcb_connection_t *c,
xcb_dri2_swap_buffers_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_dri2_get_msc_cookie_t
xcb_dri2_get_msc (xcb_connection_t *c,
xcb_drawable_t drawable);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_dri2_get_msc_cookie_t
xcb_dri2_get_msc_unchecked (xcb_connection_t *c,
xcb_drawable_t drawable);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_dri2_get_msc_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_dri2_get_msc_reply_t *
xcb_dri2_get_msc_reply (xcb_connection_t *c,
xcb_dri2_get_msc_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_dri2_wait_msc_cookie_t
xcb_dri2_wait_msc (xcb_connection_t *c,
xcb_drawable_t drawable,
uint32_t target_msc_hi,
uint32_t target_msc_lo,
uint32_t divisor_hi,
uint32_t divisor_lo,
uint32_t remainder_hi,
uint32_t remainder_lo);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_dri2_wait_msc_cookie_t
xcb_dri2_wait_msc_unchecked (xcb_connection_t *c,
xcb_drawable_t drawable,
uint32_t target_msc_hi,
uint32_t target_msc_lo,
uint32_t divisor_hi,
uint32_t divisor_lo,
uint32_t remainder_hi,
uint32_t remainder_lo);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_dri2_wait_msc_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_dri2_wait_msc_reply_t *
xcb_dri2_wait_msc_reply (xcb_connection_t *c,
xcb_dri2_wait_msc_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_dri2_wait_sbc_cookie_t
xcb_dri2_wait_sbc (xcb_connection_t *c,
xcb_drawable_t drawable,
uint32_t target_sbc_hi,
uint32_t target_sbc_lo);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_dri2_wait_sbc_cookie_t
xcb_dri2_wait_sbc_unchecked (xcb_connection_t *c,
xcb_drawable_t drawable,
uint32_t target_sbc_hi,
uint32_t target_sbc_lo);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_dri2_wait_sbc_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_dri2_wait_sbc_reply_t *
xcb_dri2_wait_sbc_reply (xcb_connection_t *c,
xcb_dri2_wait_sbc_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_dri2_swap_interval_checked (xcb_connection_t *c,
xcb_drawable_t drawable,
uint32_t interval);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_dri2_swap_interval (xcb_connection_t *c,
xcb_drawable_t drawable,
uint32_t interval);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_dri2_get_param_cookie_t
xcb_dri2_get_param (xcb_connection_t *c,
xcb_drawable_t drawable,
uint32_t param);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_dri2_get_param_cookie_t
xcb_dri2_get_param_unchecked (xcb_connection_t *c,
xcb_drawable_t drawable,
uint32_t param);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_dri2_get_param_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_dri2_get_param_reply_t *
xcb_dri2_get_param_reply (xcb_connection_t *c,
xcb_dri2_get_param_cookie_t cookie /**< */,
xcb_generic_error_t **e);
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/
xcb/glx.h 0000644 00000755622 15201526705 0006307 0 ustar 00 /*
* This file generated automatically from glx.xml by c_client.py.
* Edit at your peril.
*/
/**
* @defgroup XCB_Glx_API XCB Glx API
* @brief Glx XCB Protocol Implementation.
* @{
**/
#ifndef __GLX_H
#define __GLX_H
#include "xcb.h"
#include "xproto.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XCB_GLX_MAJOR_VERSION 1
#define XCB_GLX_MINOR_VERSION 4
extern xcb_extension_t xcb_glx_id;
typedef uint32_t xcb_glx_pixmap_t;
/**
* @brief xcb_glx_pixmap_iterator_t
**/
typedef struct xcb_glx_pixmap_iterator_t {
xcb_glx_pixmap_t *data;
int rem;
int index;
} xcb_glx_pixmap_iterator_t;
typedef uint32_t xcb_glx_context_t;
/**
* @brief xcb_glx_context_iterator_t
**/
typedef struct xcb_glx_context_iterator_t {
xcb_glx_context_t *data;
int rem;
int index;
} xcb_glx_context_iterator_t;
typedef uint32_t xcb_glx_pbuffer_t;
/**
* @brief xcb_glx_pbuffer_iterator_t
**/
typedef struct xcb_glx_pbuffer_iterator_t {
xcb_glx_pbuffer_t *data;
int rem;
int index;
} xcb_glx_pbuffer_iterator_t;
typedef uint32_t xcb_glx_window_t;
/**
* @brief xcb_glx_window_iterator_t
**/
typedef struct xcb_glx_window_iterator_t {
xcb_glx_window_t *data;
int rem;
int index;
} xcb_glx_window_iterator_t;
typedef uint32_t xcb_glx_fbconfig_t;
/**
* @brief xcb_glx_fbconfig_iterator_t
**/
typedef struct xcb_glx_fbconfig_iterator_t {
xcb_glx_fbconfig_t *data;
int rem;
int index;
} xcb_glx_fbconfig_iterator_t;
typedef uint32_t xcb_glx_drawable_t;
/**
* @brief xcb_glx_drawable_iterator_t
**/
typedef struct xcb_glx_drawable_iterator_t {
xcb_glx_drawable_t *data;
int rem;
int index;
} xcb_glx_drawable_iterator_t;
typedef float xcb_glx_float32_t;
/**
* @brief xcb_glx_float32_iterator_t
**/
typedef struct xcb_glx_float32_iterator_t {
xcb_glx_float32_t *data;
int rem;
int index;
} xcb_glx_float32_iterator_t;
typedef double xcb_glx_float64_t;
/**
* @brief xcb_glx_float64_iterator_t
**/
typedef struct xcb_glx_float64_iterator_t {
xcb_glx_float64_t *data;
int rem;
int index;
} xcb_glx_float64_iterator_t;
typedef uint32_t xcb_glx_bool32_t;
/**
* @brief xcb_glx_bool32_iterator_t
**/
typedef struct xcb_glx_bool32_iterator_t {
xcb_glx_bool32_t *data;
int rem;
int index;
} xcb_glx_bool32_iterator_t;
typedef uint32_t xcb_glx_context_tag_t;
/**
* @brief xcb_glx_context_tag_iterator_t
**/
typedef struct xcb_glx_context_tag_iterator_t {
xcb_glx_context_tag_t *data;
int rem;
int index;
} xcb_glx_context_tag_iterator_t;
/** Opcode for xcb_glx_generic. */
#define XCB_GLX_GENERIC -1
/**
* @brief xcb_glx_generic_error_t
**/
typedef struct xcb_glx_generic_error_t {
uint8_t response_type;
uint8_t error_code;
uint16_t sequence;
uint32_t bad_value;
uint16_t minor_opcode;
uint8_t major_opcode;
uint8_t pad0[21];
} xcb_glx_generic_error_t;
/** Opcode for xcb_glx_bad_context. */
#define XCB_GLX_BAD_CONTEXT 0
typedef xcb_glx_generic_error_t xcb_glx_bad_context_error_t;
/** Opcode for xcb_glx_bad_context_state. */
#define XCB_GLX_BAD_CONTEXT_STATE 1
typedef xcb_glx_generic_error_t xcb_glx_bad_context_state_error_t;
/** Opcode for xcb_glx_bad_drawable. */
#define XCB_GLX_BAD_DRAWABLE 2
typedef xcb_glx_generic_error_t xcb_glx_bad_drawable_error_t;
/** Opcode for xcb_glx_bad_pixmap. */
#define XCB_GLX_BAD_PIXMAP 3
typedef xcb_glx_generic_error_t xcb_glx_bad_pixmap_error_t;
/** Opcode for xcb_glx_bad_context_tag. */
#define XCB_GLX_BAD_CONTEXT_TAG 4
typedef xcb_glx_generic_error_t xcb_glx_bad_context_tag_error_t;
/** Opcode for xcb_glx_bad_current_window. */
#define XCB_GLX_BAD_CURRENT_WINDOW 5
typedef xcb_glx_generic_error_t xcb_glx_bad_current_window_error_t;
/** Opcode for xcb_glx_bad_render_request. */
#define XCB_GLX_BAD_RENDER_REQUEST 6
typedef xcb_glx_generic_error_t xcb_glx_bad_render_request_error_t;
/** Opcode for xcb_glx_bad_large_request. */
#define XCB_GLX_BAD_LARGE_REQUEST 7
typedef xcb_glx_generic_error_t xcb_glx_bad_large_request_error_t;
/** Opcode for xcb_glx_unsupported_private_request. */
#define XCB_GLX_UNSUPPORTED_PRIVATE_REQUEST 8
typedef xcb_glx_generic_error_t xcb_glx_unsupported_private_request_error_t;
/** Opcode for xcb_glx_bad_fb_config. */
#define XCB_GLX_BAD_FB_CONFIG 9
typedef xcb_glx_generic_error_t xcb_glx_bad_fb_config_error_t;
/** Opcode for xcb_glx_bad_pbuffer. */
#define XCB_GLX_BAD_PBUFFER 10
typedef xcb_glx_generic_error_t xcb_glx_bad_pbuffer_error_t;
/** Opcode for xcb_glx_bad_current_drawable. */
#define XCB_GLX_BAD_CURRENT_DRAWABLE 11
typedef xcb_glx_generic_error_t xcb_glx_bad_current_drawable_error_t;
/** Opcode for xcb_glx_bad_window. */
#define XCB_GLX_BAD_WINDOW 12
typedef xcb_glx_generic_error_t xcb_glx_bad_window_error_t;
/** Opcode for xcb_glx_glx_bad_profile_arb. */
#define XCB_GLX_GLX_BAD_PROFILE_ARB 13
typedef xcb_glx_generic_error_t xcb_glx_glx_bad_profile_arb_error_t;
/** Opcode for xcb_glx_pbuffer_clobber. */
#define XCB_GLX_PBUFFER_CLOBBER 0
/**
* @brief xcb_glx_pbuffer_clobber_event_t
**/
typedef struct xcb_glx_pbuffer_clobber_event_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint16_t event_type;
uint16_t draw_type;
xcb_glx_drawable_t drawable;
uint32_t b_mask;
uint16_t aux_buffer;
uint16_t x;
uint16_t y;
uint16_t width;
uint16_t height;
uint16_t count;
uint8_t pad1[4];
} xcb_glx_pbuffer_clobber_event_t;
/** Opcode for xcb_glx_buffer_swap_complete. */
#define XCB_GLX_BUFFER_SWAP_COMPLETE 1
/**
* @brief xcb_glx_buffer_swap_complete_event_t
**/
typedef struct xcb_glx_buffer_swap_complete_event_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint16_t event_type;
uint8_t pad1[2];
xcb_glx_drawable_t drawable;
uint32_t ust_hi;
uint32_t ust_lo;
uint32_t msc_hi;
uint32_t msc_lo;
uint32_t sbc;
} xcb_glx_buffer_swap_complete_event_t;
typedef enum xcb_glx_pbcet_t {
XCB_GLX_PBCET_DAMAGED = 32791,
XCB_GLX_PBCET_SAVED = 32792
} xcb_glx_pbcet_t;
typedef enum xcb_glx_pbcdt_t {
XCB_GLX_PBCDT_WINDOW = 32793,
XCB_GLX_PBCDT_PBUFFER = 32794
} xcb_glx_pbcdt_t;
/** Opcode for xcb_glx_render. */
#define XCB_GLX_RENDER 1
/**
* @brief xcb_glx_render_request_t
**/
typedef struct xcb_glx_render_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
} xcb_glx_render_request_t;
/** Opcode for xcb_glx_render_large. */
#define XCB_GLX_RENDER_LARGE 2
/**
* @brief xcb_glx_render_large_request_t
**/
typedef struct xcb_glx_render_large_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint16_t request_num;
uint16_t request_total;
uint32_t data_len;
} xcb_glx_render_large_request_t;
/** Opcode for xcb_glx_create_context. */
#define XCB_GLX_CREATE_CONTEXT 3
/**
* @brief xcb_glx_create_context_request_t
**/
typedef struct xcb_glx_create_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_t context;
xcb_visualid_t visual;
uint32_t screen;
xcb_glx_context_t share_list;
uint8_t is_direct;
uint8_t pad0[3];
} xcb_glx_create_context_request_t;
/** Opcode for xcb_glx_destroy_context. */
#define XCB_GLX_DESTROY_CONTEXT 4
/**
* @brief xcb_glx_destroy_context_request_t
**/
typedef struct xcb_glx_destroy_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_t context;
} xcb_glx_destroy_context_request_t;
/**
* @brief xcb_glx_make_current_cookie_t
**/
typedef struct xcb_glx_make_current_cookie_t {
unsigned int sequence;
} xcb_glx_make_current_cookie_t;
/** Opcode for xcb_glx_make_current. */
#define XCB_GLX_MAKE_CURRENT 5
/**
* @brief xcb_glx_make_current_request_t
**/
typedef struct xcb_glx_make_current_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_drawable_t drawable;
xcb_glx_context_t context;
xcb_glx_context_tag_t old_context_tag;
} xcb_glx_make_current_request_t;
/**
* @brief xcb_glx_make_current_reply_t
**/
typedef struct xcb_glx_make_current_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
xcb_glx_context_tag_t context_tag;
uint8_t pad1[20];
} xcb_glx_make_current_reply_t;
/**
* @brief xcb_glx_is_direct_cookie_t
**/
typedef struct xcb_glx_is_direct_cookie_t {
unsigned int sequence;
} xcb_glx_is_direct_cookie_t;
/** Opcode for xcb_glx_is_direct. */
#define XCB_GLX_IS_DIRECT 6
/**
* @brief xcb_glx_is_direct_request_t
**/
typedef struct xcb_glx_is_direct_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_t context;
} xcb_glx_is_direct_request_t;
/**
* @brief xcb_glx_is_direct_reply_t
**/
typedef struct xcb_glx_is_direct_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t is_direct;
uint8_t pad1[23];
} xcb_glx_is_direct_reply_t;
/**
* @brief xcb_glx_query_version_cookie_t
**/
typedef struct xcb_glx_query_version_cookie_t {
unsigned int sequence;
} xcb_glx_query_version_cookie_t;
/** Opcode for xcb_glx_query_version. */
#define XCB_GLX_QUERY_VERSION 7
/**
* @brief xcb_glx_query_version_request_t
**/
typedef struct xcb_glx_query_version_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t major_version;
uint32_t minor_version;
} xcb_glx_query_version_request_t;
/**
* @brief xcb_glx_query_version_reply_t
**/
typedef struct xcb_glx_query_version_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t major_version;
uint32_t minor_version;
uint8_t pad1[16];
} xcb_glx_query_version_reply_t;
/** Opcode for xcb_glx_wait_gl. */
#define XCB_GLX_WAIT_GL 8
/**
* @brief xcb_glx_wait_gl_request_t
**/
typedef struct xcb_glx_wait_gl_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
} xcb_glx_wait_gl_request_t;
/** Opcode for xcb_glx_wait_x. */
#define XCB_GLX_WAIT_X 9
/**
* @brief xcb_glx_wait_x_request_t
**/
typedef struct xcb_glx_wait_x_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
} xcb_glx_wait_x_request_t;
/** Opcode for xcb_glx_copy_context. */
#define XCB_GLX_COPY_CONTEXT 10
/**
* @brief xcb_glx_copy_context_request_t
**/
typedef struct xcb_glx_copy_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_t src;
xcb_glx_context_t dest;
uint32_t mask;
xcb_glx_context_tag_t src_context_tag;
} xcb_glx_copy_context_request_t;
typedef enum xcb_glx_gc_t {
XCB_GLX_GC_GL_CURRENT_BIT = 1,
XCB_GLX_GC_GL_POINT_BIT = 2,
XCB_GLX_GC_GL_LINE_BIT = 4,
XCB_GLX_GC_GL_POLYGON_BIT = 8,
XCB_GLX_GC_GL_POLYGON_STIPPLE_BIT = 16,
XCB_GLX_GC_GL_PIXEL_MODE_BIT = 32,
XCB_GLX_GC_GL_LIGHTING_BIT = 64,
XCB_GLX_GC_GL_FOG_BIT = 128,
XCB_GLX_GC_GL_DEPTH_BUFFER_BIT = 256,
XCB_GLX_GC_GL_ACCUM_BUFFER_BIT = 512,
XCB_GLX_GC_GL_STENCIL_BUFFER_BIT = 1024,
XCB_GLX_GC_GL_VIEWPORT_BIT = 2048,
XCB_GLX_GC_GL_TRANSFORM_BIT = 4096,
XCB_GLX_GC_GL_ENABLE_BIT = 8192,
XCB_GLX_GC_GL_COLOR_BUFFER_BIT = 16384,
XCB_GLX_GC_GL_HINT_BIT = 32768,
XCB_GLX_GC_GL_EVAL_BIT = 65536,
XCB_GLX_GC_GL_LIST_BIT = 131072,
XCB_GLX_GC_GL_TEXTURE_BIT = 262144,
XCB_GLX_GC_GL_SCISSOR_BIT = 524288,
XCB_GLX_GC_GL_ALL_ATTRIB_BITS = 16777215
} xcb_glx_gc_t;
/** Opcode for xcb_glx_swap_buffers. */
#define XCB_GLX_SWAP_BUFFERS 11
/**
* @brief xcb_glx_swap_buffers_request_t
**/
typedef struct xcb_glx_swap_buffers_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
xcb_glx_drawable_t drawable;
} xcb_glx_swap_buffers_request_t;
/** Opcode for xcb_glx_use_x_font. */
#define XCB_GLX_USE_X_FONT 12
/**
* @brief xcb_glx_use_x_font_request_t
**/
typedef struct xcb_glx_use_x_font_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
xcb_font_t font;
uint32_t first;
uint32_t count;
uint32_t list_base;
} xcb_glx_use_x_font_request_t;
/** Opcode for xcb_glx_create_glx_pixmap. */
#define XCB_GLX_CREATE_GLX_PIXMAP 13
/**
* @brief xcb_glx_create_glx_pixmap_request_t
**/
typedef struct xcb_glx_create_glx_pixmap_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t screen;
xcb_visualid_t visual;
xcb_pixmap_t pixmap;
xcb_glx_pixmap_t glx_pixmap;
} xcb_glx_create_glx_pixmap_request_t;
/**
* @brief xcb_glx_get_visual_configs_cookie_t
**/
typedef struct xcb_glx_get_visual_configs_cookie_t {
unsigned int sequence;
} xcb_glx_get_visual_configs_cookie_t;
/** Opcode for xcb_glx_get_visual_configs. */
#define XCB_GLX_GET_VISUAL_CONFIGS 14
/**
* @brief xcb_glx_get_visual_configs_request_t
**/
typedef struct xcb_glx_get_visual_configs_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t screen;
} xcb_glx_get_visual_configs_request_t;
/**
* @brief xcb_glx_get_visual_configs_reply_t
**/
typedef struct xcb_glx_get_visual_configs_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t num_visuals;
uint32_t num_properties;
uint8_t pad1[16];
} xcb_glx_get_visual_configs_reply_t;
/** Opcode for xcb_glx_destroy_glx_pixmap. */
#define XCB_GLX_DESTROY_GLX_PIXMAP 15
/**
* @brief xcb_glx_destroy_glx_pixmap_request_t
**/
typedef struct xcb_glx_destroy_glx_pixmap_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_pixmap_t glx_pixmap;
} xcb_glx_destroy_glx_pixmap_request_t;
/** Opcode for xcb_glx_vendor_private. */
#define XCB_GLX_VENDOR_PRIVATE 16
/**
* @brief xcb_glx_vendor_private_request_t
**/
typedef struct xcb_glx_vendor_private_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t vendor_code;
xcb_glx_context_tag_t context_tag;
} xcb_glx_vendor_private_request_t;
/**
* @brief xcb_glx_vendor_private_with_reply_cookie_t
**/
typedef struct xcb_glx_vendor_private_with_reply_cookie_t {
unsigned int sequence;
} xcb_glx_vendor_private_with_reply_cookie_t;
/** Opcode for xcb_glx_vendor_private_with_reply. */
#define XCB_GLX_VENDOR_PRIVATE_WITH_REPLY 17
/**
* @brief xcb_glx_vendor_private_with_reply_request_t
**/
typedef struct xcb_glx_vendor_private_with_reply_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t vendor_code;
xcb_glx_context_tag_t context_tag;
} xcb_glx_vendor_private_with_reply_request_t;
/**
* @brief xcb_glx_vendor_private_with_reply_reply_t
**/
typedef struct xcb_glx_vendor_private_with_reply_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t retval;
uint8_t data1[24];
} xcb_glx_vendor_private_with_reply_reply_t;
/**
* @brief xcb_glx_query_extensions_string_cookie_t
**/
typedef struct xcb_glx_query_extensions_string_cookie_t {
unsigned int sequence;
} xcb_glx_query_extensions_string_cookie_t;
/** Opcode for xcb_glx_query_extensions_string. */
#define XCB_GLX_QUERY_EXTENSIONS_STRING 18
/**
* @brief xcb_glx_query_extensions_string_request_t
**/
typedef struct xcb_glx_query_extensions_string_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t screen;
} xcb_glx_query_extensions_string_request_t;
/**
* @brief xcb_glx_query_extensions_string_reply_t
**/
typedef struct xcb_glx_query_extensions_string_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
uint8_t pad2[16];
} xcb_glx_query_extensions_string_reply_t;
/**
* @brief xcb_glx_query_server_string_cookie_t
**/
typedef struct xcb_glx_query_server_string_cookie_t {
unsigned int sequence;
} xcb_glx_query_server_string_cookie_t;
/** Opcode for xcb_glx_query_server_string. */
#define XCB_GLX_QUERY_SERVER_STRING 19
/**
* @brief xcb_glx_query_server_string_request_t
**/
typedef struct xcb_glx_query_server_string_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t screen;
uint32_t name;
} xcb_glx_query_server_string_request_t;
/**
* @brief xcb_glx_query_server_string_reply_t
**/
typedef struct xcb_glx_query_server_string_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t str_len;
uint8_t pad2[16];
} xcb_glx_query_server_string_reply_t;
/** Opcode for xcb_glx_client_info. */
#define XCB_GLX_CLIENT_INFO 20
/**
* @brief xcb_glx_client_info_request_t
**/
typedef struct xcb_glx_client_info_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t major_version;
uint32_t minor_version;
uint32_t str_len;
} xcb_glx_client_info_request_t;
/**
* @brief xcb_glx_get_fb_configs_cookie_t
**/
typedef struct xcb_glx_get_fb_configs_cookie_t {
unsigned int sequence;
} xcb_glx_get_fb_configs_cookie_t;
/** Opcode for xcb_glx_get_fb_configs. */
#define XCB_GLX_GET_FB_CONFIGS 21
/**
* @brief xcb_glx_get_fb_configs_request_t
**/
typedef struct xcb_glx_get_fb_configs_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t screen;
} xcb_glx_get_fb_configs_request_t;
/**
* @brief xcb_glx_get_fb_configs_reply_t
**/
typedef struct xcb_glx_get_fb_configs_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t num_FB_configs;
uint32_t num_properties;
uint8_t pad1[16];
} xcb_glx_get_fb_configs_reply_t;
/** Opcode for xcb_glx_create_pixmap. */
#define XCB_GLX_CREATE_PIXMAP 22
/**
* @brief xcb_glx_create_pixmap_request_t
**/
typedef struct xcb_glx_create_pixmap_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t screen;
xcb_glx_fbconfig_t fbconfig;
xcb_pixmap_t pixmap;
xcb_glx_pixmap_t glx_pixmap;
uint32_t num_attribs;
} xcb_glx_create_pixmap_request_t;
/** Opcode for xcb_glx_destroy_pixmap. */
#define XCB_GLX_DESTROY_PIXMAP 23
/**
* @brief xcb_glx_destroy_pixmap_request_t
**/
typedef struct xcb_glx_destroy_pixmap_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_pixmap_t glx_pixmap;
} xcb_glx_destroy_pixmap_request_t;
/** Opcode for xcb_glx_create_new_context. */
#define XCB_GLX_CREATE_NEW_CONTEXT 24
/**
* @brief xcb_glx_create_new_context_request_t
**/
typedef struct xcb_glx_create_new_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_t context;
xcb_glx_fbconfig_t fbconfig;
uint32_t screen;
uint32_t render_type;
xcb_glx_context_t share_list;
uint8_t is_direct;
uint8_t pad0[3];
} xcb_glx_create_new_context_request_t;
/**
* @brief xcb_glx_query_context_cookie_t
**/
typedef struct xcb_glx_query_context_cookie_t {
unsigned int sequence;
} xcb_glx_query_context_cookie_t;
/** Opcode for xcb_glx_query_context. */
#define XCB_GLX_QUERY_CONTEXT 25
/**
* @brief xcb_glx_query_context_request_t
**/
typedef struct xcb_glx_query_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_t context;
} xcb_glx_query_context_request_t;
/**
* @brief xcb_glx_query_context_reply_t
**/
typedef struct xcb_glx_query_context_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t num_attribs;
uint8_t pad1[20];
} xcb_glx_query_context_reply_t;
/**
* @brief xcb_glx_make_context_current_cookie_t
**/
typedef struct xcb_glx_make_context_current_cookie_t {
unsigned int sequence;
} xcb_glx_make_context_current_cookie_t;
/** Opcode for xcb_glx_make_context_current. */
#define XCB_GLX_MAKE_CONTEXT_CURRENT 26
/**
* @brief xcb_glx_make_context_current_request_t
**/
typedef struct xcb_glx_make_context_current_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t old_context_tag;
xcb_glx_drawable_t drawable;
xcb_glx_drawable_t read_drawable;
xcb_glx_context_t context;
} xcb_glx_make_context_current_request_t;
/**
* @brief xcb_glx_make_context_current_reply_t
**/
typedef struct xcb_glx_make_context_current_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
xcb_glx_context_tag_t context_tag;
uint8_t pad1[20];
} xcb_glx_make_context_current_reply_t;
/** Opcode for xcb_glx_create_pbuffer. */
#define XCB_GLX_CREATE_PBUFFER 27
/**
* @brief xcb_glx_create_pbuffer_request_t
**/
typedef struct xcb_glx_create_pbuffer_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t screen;
xcb_glx_fbconfig_t fbconfig;
xcb_glx_pbuffer_t pbuffer;
uint32_t num_attribs;
} xcb_glx_create_pbuffer_request_t;
/** Opcode for xcb_glx_destroy_pbuffer. */
#define XCB_GLX_DESTROY_PBUFFER 28
/**
* @brief xcb_glx_destroy_pbuffer_request_t
**/
typedef struct xcb_glx_destroy_pbuffer_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_pbuffer_t pbuffer;
} xcb_glx_destroy_pbuffer_request_t;
/**
* @brief xcb_glx_get_drawable_attributes_cookie_t
**/
typedef struct xcb_glx_get_drawable_attributes_cookie_t {
unsigned int sequence;
} xcb_glx_get_drawable_attributes_cookie_t;
/** Opcode for xcb_glx_get_drawable_attributes. */
#define XCB_GLX_GET_DRAWABLE_ATTRIBUTES 29
/**
* @brief xcb_glx_get_drawable_attributes_request_t
**/
typedef struct xcb_glx_get_drawable_attributes_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_drawable_t drawable;
} xcb_glx_get_drawable_attributes_request_t;
/**
* @brief xcb_glx_get_drawable_attributes_reply_t
**/
typedef struct xcb_glx_get_drawable_attributes_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t num_attribs;
uint8_t pad1[20];
} xcb_glx_get_drawable_attributes_reply_t;
/** Opcode for xcb_glx_change_drawable_attributes. */
#define XCB_GLX_CHANGE_DRAWABLE_ATTRIBUTES 30
/**
* @brief xcb_glx_change_drawable_attributes_request_t
**/
typedef struct xcb_glx_change_drawable_attributes_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_drawable_t drawable;
uint32_t num_attribs;
} xcb_glx_change_drawable_attributes_request_t;
/** Opcode for xcb_glx_create_window. */
#define XCB_GLX_CREATE_WINDOW 31
/**
* @brief xcb_glx_create_window_request_t
**/
typedef struct xcb_glx_create_window_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t screen;
xcb_glx_fbconfig_t fbconfig;
xcb_window_t window;
xcb_glx_window_t glx_window;
uint32_t num_attribs;
} xcb_glx_create_window_request_t;
/** Opcode for xcb_glx_delete_window. */
#define XCB_GLX_DELETE_WINDOW 32
/**
* @brief xcb_glx_delete_window_request_t
**/
typedef struct xcb_glx_delete_window_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_window_t glxwindow;
} xcb_glx_delete_window_request_t;
/** Opcode for xcb_glx_set_client_info_arb. */
#define XCB_GLX_SET_CLIENT_INFO_ARB 33
/**
* @brief xcb_glx_set_client_info_arb_request_t
**/
typedef struct xcb_glx_set_client_info_arb_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t major_version;
uint32_t minor_version;
uint32_t num_versions;
uint32_t gl_str_len;
uint32_t glx_str_len;
} xcb_glx_set_client_info_arb_request_t;
/** Opcode for xcb_glx_create_context_attribs_arb. */
#define XCB_GLX_CREATE_CONTEXT_ATTRIBS_ARB 34
/**
* @brief xcb_glx_create_context_attribs_arb_request_t
**/
typedef struct xcb_glx_create_context_attribs_arb_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_t context;
xcb_glx_fbconfig_t fbconfig;
uint32_t screen;
xcb_glx_context_t share_list;
uint8_t is_direct;
uint8_t pad0[3];
uint32_t num_attribs;
} xcb_glx_create_context_attribs_arb_request_t;
/** Opcode for xcb_glx_set_client_info_2arb. */
#define XCB_GLX_SET_CLIENT_INFO_2ARB 35
/**
* @brief xcb_glx_set_client_info_2arb_request_t
**/
typedef struct xcb_glx_set_client_info_2arb_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t major_version;
uint32_t minor_version;
uint32_t num_versions;
uint32_t gl_str_len;
uint32_t glx_str_len;
} xcb_glx_set_client_info_2arb_request_t;
/** Opcode for xcb_glx_new_list. */
#define XCB_GLX_NEW_LIST 101
/**
* @brief xcb_glx_new_list_request_t
**/
typedef struct xcb_glx_new_list_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t list;
uint32_t mode;
} xcb_glx_new_list_request_t;
/** Opcode for xcb_glx_end_list. */
#define XCB_GLX_END_LIST 102
/**
* @brief xcb_glx_end_list_request_t
**/
typedef struct xcb_glx_end_list_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
} xcb_glx_end_list_request_t;
/** Opcode for xcb_glx_delete_lists. */
#define XCB_GLX_DELETE_LISTS 103
/**
* @brief xcb_glx_delete_lists_request_t
**/
typedef struct xcb_glx_delete_lists_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t list;
int32_t range;
} xcb_glx_delete_lists_request_t;
/**
* @brief xcb_glx_gen_lists_cookie_t
**/
typedef struct xcb_glx_gen_lists_cookie_t {
unsigned int sequence;
} xcb_glx_gen_lists_cookie_t;
/** Opcode for xcb_glx_gen_lists. */
#define XCB_GLX_GEN_LISTS 104
/**
* @brief xcb_glx_gen_lists_request_t
**/
typedef struct xcb_glx_gen_lists_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
int32_t range;
} xcb_glx_gen_lists_request_t;
/**
* @brief xcb_glx_gen_lists_reply_t
**/
typedef struct xcb_glx_gen_lists_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t ret_val;
} xcb_glx_gen_lists_reply_t;
/** Opcode for xcb_glx_feedback_buffer. */
#define XCB_GLX_FEEDBACK_BUFFER 105
/**
* @brief xcb_glx_feedback_buffer_request_t
**/
typedef struct xcb_glx_feedback_buffer_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
int32_t size;
int32_t type;
} xcb_glx_feedback_buffer_request_t;
/** Opcode for xcb_glx_select_buffer. */
#define XCB_GLX_SELECT_BUFFER 106
/**
* @brief xcb_glx_select_buffer_request_t
**/
typedef struct xcb_glx_select_buffer_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
int32_t size;
} xcb_glx_select_buffer_request_t;
/**
* @brief xcb_glx_render_mode_cookie_t
**/
typedef struct xcb_glx_render_mode_cookie_t {
unsigned int sequence;
} xcb_glx_render_mode_cookie_t;
/** Opcode for xcb_glx_render_mode. */
#define XCB_GLX_RENDER_MODE 107
/**
* @brief xcb_glx_render_mode_request_t
**/
typedef struct xcb_glx_render_mode_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t mode;
} xcb_glx_render_mode_request_t;
/**
* @brief xcb_glx_render_mode_reply_t
**/
typedef struct xcb_glx_render_mode_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t ret_val;
uint32_t n;
uint32_t new_mode;
uint8_t pad1[12];
} xcb_glx_render_mode_reply_t;
typedef enum xcb_glx_rm_t {
XCB_GLX_RM_GL_RENDER = 7168,
XCB_GLX_RM_GL_FEEDBACK = 7169,
XCB_GLX_RM_GL_SELECT = 7170
} xcb_glx_rm_t;
/**
* @brief xcb_glx_finish_cookie_t
**/
typedef struct xcb_glx_finish_cookie_t {
unsigned int sequence;
} xcb_glx_finish_cookie_t;
/** Opcode for xcb_glx_finish. */
#define XCB_GLX_FINISH 108
/**
* @brief xcb_glx_finish_request_t
**/
typedef struct xcb_glx_finish_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
} xcb_glx_finish_request_t;
/**
* @brief xcb_glx_finish_reply_t
**/
typedef struct xcb_glx_finish_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
} xcb_glx_finish_reply_t;
/** Opcode for xcb_glx_pixel_storef. */
#define XCB_GLX_PIXEL_STOREF 109
/**
* @brief xcb_glx_pixel_storef_request_t
**/
typedef struct xcb_glx_pixel_storef_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t pname;
xcb_glx_float32_t datum;
} xcb_glx_pixel_storef_request_t;
/** Opcode for xcb_glx_pixel_storei. */
#define XCB_GLX_PIXEL_STOREI 110
/**
* @brief xcb_glx_pixel_storei_request_t
**/
typedef struct xcb_glx_pixel_storei_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t pname;
int32_t datum;
} xcb_glx_pixel_storei_request_t;
/**
* @brief xcb_glx_read_pixels_cookie_t
**/
typedef struct xcb_glx_read_pixels_cookie_t {
unsigned int sequence;
} xcb_glx_read_pixels_cookie_t;
/** Opcode for xcb_glx_read_pixels. */
#define XCB_GLX_READ_PIXELS 111
/**
* @brief xcb_glx_read_pixels_request_t
**/
typedef struct xcb_glx_read_pixels_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
int32_t x;
int32_t y;
int32_t width;
int32_t height;
uint32_t format;
uint32_t type;
uint8_t swap_bytes;
uint8_t lsb_first;
} xcb_glx_read_pixels_request_t;
/**
* @brief xcb_glx_read_pixels_reply_t
**/
typedef struct xcb_glx_read_pixels_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[24];
} xcb_glx_read_pixels_reply_t;
/**
* @brief xcb_glx_get_booleanv_cookie_t
**/
typedef struct xcb_glx_get_booleanv_cookie_t {
unsigned int sequence;
} xcb_glx_get_booleanv_cookie_t;
/** Opcode for xcb_glx_get_booleanv. */
#define XCB_GLX_GET_BOOLEANV 112
/**
* @brief xcb_glx_get_booleanv_request_t
**/
typedef struct xcb_glx_get_booleanv_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
int32_t pname;
} xcb_glx_get_booleanv_request_t;
/**
* @brief xcb_glx_get_booleanv_reply_t
**/
typedef struct xcb_glx_get_booleanv_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
uint8_t datum;
uint8_t pad2[15];
} xcb_glx_get_booleanv_reply_t;
/**
* @brief xcb_glx_get_clip_plane_cookie_t
**/
typedef struct xcb_glx_get_clip_plane_cookie_t {
unsigned int sequence;
} xcb_glx_get_clip_plane_cookie_t;
/** Opcode for xcb_glx_get_clip_plane. */
#define XCB_GLX_GET_CLIP_PLANE 113
/**
* @brief xcb_glx_get_clip_plane_request_t
**/
typedef struct xcb_glx_get_clip_plane_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
int32_t plane;
} xcb_glx_get_clip_plane_request_t;
/**
* @brief xcb_glx_get_clip_plane_reply_t
**/
typedef struct xcb_glx_get_clip_plane_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[24];
} xcb_glx_get_clip_plane_reply_t;
/**
* @brief xcb_glx_get_doublev_cookie_t
**/
typedef struct xcb_glx_get_doublev_cookie_t {
unsigned int sequence;
} xcb_glx_get_doublev_cookie_t;
/** Opcode for xcb_glx_get_doublev. */
#define XCB_GLX_GET_DOUBLEV 114
/**
* @brief xcb_glx_get_doublev_request_t
**/
typedef struct xcb_glx_get_doublev_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t pname;
} xcb_glx_get_doublev_request_t;
/**
* @brief xcb_glx_get_doublev_reply_t
**/
typedef struct xcb_glx_get_doublev_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
xcb_glx_float64_t datum;
uint8_t pad2[8];
} xcb_glx_get_doublev_reply_t;
/**
* @brief xcb_glx_get_error_cookie_t
**/
typedef struct xcb_glx_get_error_cookie_t {
unsigned int sequence;
} xcb_glx_get_error_cookie_t;
/** Opcode for xcb_glx_get_error. */
#define XCB_GLX_GET_ERROR 115
/**
* @brief xcb_glx_get_error_request_t
**/
typedef struct xcb_glx_get_error_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
} xcb_glx_get_error_request_t;
/**
* @brief xcb_glx_get_error_reply_t
**/
typedef struct xcb_glx_get_error_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
int32_t error;
} xcb_glx_get_error_reply_t;
/**
* @brief xcb_glx_get_floatv_cookie_t
**/
typedef struct xcb_glx_get_floatv_cookie_t {
unsigned int sequence;
} xcb_glx_get_floatv_cookie_t;
/** Opcode for xcb_glx_get_floatv. */
#define XCB_GLX_GET_FLOATV 116
/**
* @brief xcb_glx_get_floatv_request_t
**/
typedef struct xcb_glx_get_floatv_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t pname;
} xcb_glx_get_floatv_request_t;
/**
* @brief xcb_glx_get_floatv_reply_t
**/
typedef struct xcb_glx_get_floatv_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
xcb_glx_float32_t datum;
uint8_t pad2[12];
} xcb_glx_get_floatv_reply_t;
/**
* @brief xcb_glx_get_integerv_cookie_t
**/
typedef struct xcb_glx_get_integerv_cookie_t {
unsigned int sequence;
} xcb_glx_get_integerv_cookie_t;
/** Opcode for xcb_glx_get_integerv. */
#define XCB_GLX_GET_INTEGERV 117
/**
* @brief xcb_glx_get_integerv_request_t
**/
typedef struct xcb_glx_get_integerv_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t pname;
} xcb_glx_get_integerv_request_t;
/**
* @brief xcb_glx_get_integerv_reply_t
**/
typedef struct xcb_glx_get_integerv_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
int32_t datum;
uint8_t pad2[12];
} xcb_glx_get_integerv_reply_t;
/**
* @brief xcb_glx_get_lightfv_cookie_t
**/
typedef struct xcb_glx_get_lightfv_cookie_t {
unsigned int sequence;
} xcb_glx_get_lightfv_cookie_t;
/** Opcode for xcb_glx_get_lightfv. */
#define XCB_GLX_GET_LIGHTFV 118
/**
* @brief xcb_glx_get_lightfv_request_t
**/
typedef struct xcb_glx_get_lightfv_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t light;
uint32_t pname;
} xcb_glx_get_lightfv_request_t;
/**
* @brief xcb_glx_get_lightfv_reply_t
**/
typedef struct xcb_glx_get_lightfv_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
xcb_glx_float32_t datum;
uint8_t pad2[12];
} xcb_glx_get_lightfv_reply_t;
/**
* @brief xcb_glx_get_lightiv_cookie_t
**/
typedef struct xcb_glx_get_lightiv_cookie_t {
unsigned int sequence;
} xcb_glx_get_lightiv_cookie_t;
/** Opcode for xcb_glx_get_lightiv. */
#define XCB_GLX_GET_LIGHTIV 119
/**
* @brief xcb_glx_get_lightiv_request_t
**/
typedef struct xcb_glx_get_lightiv_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t light;
uint32_t pname;
} xcb_glx_get_lightiv_request_t;
/**
* @brief xcb_glx_get_lightiv_reply_t
**/
typedef struct xcb_glx_get_lightiv_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
int32_t datum;
uint8_t pad2[12];
} xcb_glx_get_lightiv_reply_t;
/**
* @brief xcb_glx_get_mapdv_cookie_t
**/
typedef struct xcb_glx_get_mapdv_cookie_t {
unsigned int sequence;
} xcb_glx_get_mapdv_cookie_t;
/** Opcode for xcb_glx_get_mapdv. */
#define XCB_GLX_GET_MAPDV 120
/**
* @brief xcb_glx_get_mapdv_request_t
**/
typedef struct xcb_glx_get_mapdv_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t target;
uint32_t query;
} xcb_glx_get_mapdv_request_t;
/**
* @brief xcb_glx_get_mapdv_reply_t
**/
typedef struct xcb_glx_get_mapdv_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
xcb_glx_float64_t datum;
uint8_t pad2[8];
} xcb_glx_get_mapdv_reply_t;
/**
* @brief xcb_glx_get_mapfv_cookie_t
**/
typedef struct xcb_glx_get_mapfv_cookie_t {
unsigned int sequence;
} xcb_glx_get_mapfv_cookie_t;
/** Opcode for xcb_glx_get_mapfv. */
#define XCB_GLX_GET_MAPFV 121
/**
* @brief xcb_glx_get_mapfv_request_t
**/
typedef struct xcb_glx_get_mapfv_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t target;
uint32_t query;
} xcb_glx_get_mapfv_request_t;
/**
* @brief xcb_glx_get_mapfv_reply_t
**/
typedef struct xcb_glx_get_mapfv_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
xcb_glx_float32_t datum;
uint8_t pad2[12];
} xcb_glx_get_mapfv_reply_t;
/**
* @brief xcb_glx_get_mapiv_cookie_t
**/
typedef struct xcb_glx_get_mapiv_cookie_t {
unsigned int sequence;
} xcb_glx_get_mapiv_cookie_t;
/** Opcode for xcb_glx_get_mapiv. */
#define XCB_GLX_GET_MAPIV 122
/**
* @brief xcb_glx_get_mapiv_request_t
**/
typedef struct xcb_glx_get_mapiv_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t target;
uint32_t query;
} xcb_glx_get_mapiv_request_t;
/**
* @brief xcb_glx_get_mapiv_reply_t
**/
typedef struct xcb_glx_get_mapiv_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
int32_t datum;
uint8_t pad2[12];
} xcb_glx_get_mapiv_reply_t;
/**
* @brief xcb_glx_get_materialfv_cookie_t
**/
typedef struct xcb_glx_get_materialfv_cookie_t {
unsigned int sequence;
} xcb_glx_get_materialfv_cookie_t;
/** Opcode for xcb_glx_get_materialfv. */
#define XCB_GLX_GET_MATERIALFV 123
/**
* @brief xcb_glx_get_materialfv_request_t
**/
typedef struct xcb_glx_get_materialfv_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t face;
uint32_t pname;
} xcb_glx_get_materialfv_request_t;
/**
* @brief xcb_glx_get_materialfv_reply_t
**/
typedef struct xcb_glx_get_materialfv_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
xcb_glx_float32_t datum;
uint8_t pad2[12];
} xcb_glx_get_materialfv_reply_t;
/**
* @brief xcb_glx_get_materialiv_cookie_t
**/
typedef struct xcb_glx_get_materialiv_cookie_t {
unsigned int sequence;
} xcb_glx_get_materialiv_cookie_t;
/** Opcode for xcb_glx_get_materialiv. */
#define XCB_GLX_GET_MATERIALIV 124
/**
* @brief xcb_glx_get_materialiv_request_t
**/
typedef struct xcb_glx_get_materialiv_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t face;
uint32_t pname;
} xcb_glx_get_materialiv_request_t;
/**
* @brief xcb_glx_get_materialiv_reply_t
**/
typedef struct xcb_glx_get_materialiv_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
int32_t datum;
uint8_t pad2[12];
} xcb_glx_get_materialiv_reply_t;
/**
* @brief xcb_glx_get_pixel_mapfv_cookie_t
**/
typedef struct xcb_glx_get_pixel_mapfv_cookie_t {
unsigned int sequence;
} xcb_glx_get_pixel_mapfv_cookie_t;
/** Opcode for xcb_glx_get_pixel_mapfv. */
#define XCB_GLX_GET_PIXEL_MAPFV 125
/**
* @brief xcb_glx_get_pixel_mapfv_request_t
**/
typedef struct xcb_glx_get_pixel_mapfv_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t map;
} xcb_glx_get_pixel_mapfv_request_t;
/**
* @brief xcb_glx_get_pixel_mapfv_reply_t
**/
typedef struct xcb_glx_get_pixel_mapfv_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
xcb_glx_float32_t datum;
uint8_t pad2[12];
} xcb_glx_get_pixel_mapfv_reply_t;
/**
* @brief xcb_glx_get_pixel_mapuiv_cookie_t
**/
typedef struct xcb_glx_get_pixel_mapuiv_cookie_t {
unsigned int sequence;
} xcb_glx_get_pixel_mapuiv_cookie_t;
/** Opcode for xcb_glx_get_pixel_mapuiv. */
#define XCB_GLX_GET_PIXEL_MAPUIV 126
/**
* @brief xcb_glx_get_pixel_mapuiv_request_t
**/
typedef struct xcb_glx_get_pixel_mapuiv_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t map;
} xcb_glx_get_pixel_mapuiv_request_t;
/**
* @brief xcb_glx_get_pixel_mapuiv_reply_t
**/
typedef struct xcb_glx_get_pixel_mapuiv_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
uint32_t datum;
uint8_t pad2[12];
} xcb_glx_get_pixel_mapuiv_reply_t;
/**
* @brief xcb_glx_get_pixel_mapusv_cookie_t
**/
typedef struct xcb_glx_get_pixel_mapusv_cookie_t {
unsigned int sequence;
} xcb_glx_get_pixel_mapusv_cookie_t;
/** Opcode for xcb_glx_get_pixel_mapusv. */
#define XCB_GLX_GET_PIXEL_MAPUSV 127
/**
* @brief xcb_glx_get_pixel_mapusv_request_t
**/
typedef struct xcb_glx_get_pixel_mapusv_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t map;
} xcb_glx_get_pixel_mapusv_request_t;
/**
* @brief xcb_glx_get_pixel_mapusv_reply_t
**/
typedef struct xcb_glx_get_pixel_mapusv_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
uint16_t datum;
uint8_t pad2[16];
} xcb_glx_get_pixel_mapusv_reply_t;
/**
* @brief xcb_glx_get_polygon_stipple_cookie_t
**/
typedef struct xcb_glx_get_polygon_stipple_cookie_t {
unsigned int sequence;
} xcb_glx_get_polygon_stipple_cookie_t;
/** Opcode for xcb_glx_get_polygon_stipple. */
#define XCB_GLX_GET_POLYGON_STIPPLE 128
/**
* @brief xcb_glx_get_polygon_stipple_request_t
**/
typedef struct xcb_glx_get_polygon_stipple_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint8_t lsb_first;
} xcb_glx_get_polygon_stipple_request_t;
/**
* @brief xcb_glx_get_polygon_stipple_reply_t
**/
typedef struct xcb_glx_get_polygon_stipple_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[24];
} xcb_glx_get_polygon_stipple_reply_t;
/**
* @brief xcb_glx_get_string_cookie_t
**/
typedef struct xcb_glx_get_string_cookie_t {
unsigned int sequence;
} xcb_glx_get_string_cookie_t;
/** Opcode for xcb_glx_get_string. */
#define XCB_GLX_GET_STRING 129
/**
* @brief xcb_glx_get_string_request_t
**/
typedef struct xcb_glx_get_string_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t name;
} xcb_glx_get_string_request_t;
/**
* @brief xcb_glx_get_string_reply_t
**/
typedef struct xcb_glx_get_string_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
uint8_t pad2[16];
} xcb_glx_get_string_reply_t;
/**
* @brief xcb_glx_get_tex_envfv_cookie_t
**/
typedef struct xcb_glx_get_tex_envfv_cookie_t {
unsigned int sequence;
} xcb_glx_get_tex_envfv_cookie_t;
/** Opcode for xcb_glx_get_tex_envfv. */
#define XCB_GLX_GET_TEX_ENVFV 130
/**
* @brief xcb_glx_get_tex_envfv_request_t
**/
typedef struct xcb_glx_get_tex_envfv_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t target;
uint32_t pname;
} xcb_glx_get_tex_envfv_request_t;
/**
* @brief xcb_glx_get_tex_envfv_reply_t
**/
typedef struct xcb_glx_get_tex_envfv_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
xcb_glx_float32_t datum;
uint8_t pad2[12];
} xcb_glx_get_tex_envfv_reply_t;
/**
* @brief xcb_glx_get_tex_enviv_cookie_t
**/
typedef struct xcb_glx_get_tex_enviv_cookie_t {
unsigned int sequence;
} xcb_glx_get_tex_enviv_cookie_t;
/** Opcode for xcb_glx_get_tex_enviv. */
#define XCB_GLX_GET_TEX_ENVIV 131
/**
* @brief xcb_glx_get_tex_enviv_request_t
**/
typedef struct xcb_glx_get_tex_enviv_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t target;
uint32_t pname;
} xcb_glx_get_tex_enviv_request_t;
/**
* @brief xcb_glx_get_tex_enviv_reply_t
**/
typedef struct xcb_glx_get_tex_enviv_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
int32_t datum;
uint8_t pad2[12];
} xcb_glx_get_tex_enviv_reply_t;
/**
* @brief xcb_glx_get_tex_gendv_cookie_t
**/
typedef struct xcb_glx_get_tex_gendv_cookie_t {
unsigned int sequence;
} xcb_glx_get_tex_gendv_cookie_t;
/** Opcode for xcb_glx_get_tex_gendv. */
#define XCB_GLX_GET_TEX_GENDV 132
/**
* @brief xcb_glx_get_tex_gendv_request_t
**/
typedef struct xcb_glx_get_tex_gendv_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t coord;
uint32_t pname;
} xcb_glx_get_tex_gendv_request_t;
/**
* @brief xcb_glx_get_tex_gendv_reply_t
**/
typedef struct xcb_glx_get_tex_gendv_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
xcb_glx_float64_t datum;
uint8_t pad2[8];
} xcb_glx_get_tex_gendv_reply_t;
/**
* @brief xcb_glx_get_tex_genfv_cookie_t
**/
typedef struct xcb_glx_get_tex_genfv_cookie_t {
unsigned int sequence;
} xcb_glx_get_tex_genfv_cookie_t;
/** Opcode for xcb_glx_get_tex_genfv. */
#define XCB_GLX_GET_TEX_GENFV 133
/**
* @brief xcb_glx_get_tex_genfv_request_t
**/
typedef struct xcb_glx_get_tex_genfv_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t coord;
uint32_t pname;
} xcb_glx_get_tex_genfv_request_t;
/**
* @brief xcb_glx_get_tex_genfv_reply_t
**/
typedef struct xcb_glx_get_tex_genfv_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
xcb_glx_float32_t datum;
uint8_t pad2[12];
} xcb_glx_get_tex_genfv_reply_t;
/**
* @brief xcb_glx_get_tex_geniv_cookie_t
**/
typedef struct xcb_glx_get_tex_geniv_cookie_t {
unsigned int sequence;
} xcb_glx_get_tex_geniv_cookie_t;
/** Opcode for xcb_glx_get_tex_geniv. */
#define XCB_GLX_GET_TEX_GENIV 134
/**
* @brief xcb_glx_get_tex_geniv_request_t
**/
typedef struct xcb_glx_get_tex_geniv_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t coord;
uint32_t pname;
} xcb_glx_get_tex_geniv_request_t;
/**
* @brief xcb_glx_get_tex_geniv_reply_t
**/
typedef struct xcb_glx_get_tex_geniv_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
int32_t datum;
uint8_t pad2[12];
} xcb_glx_get_tex_geniv_reply_t;
/**
* @brief xcb_glx_get_tex_image_cookie_t
**/
typedef struct xcb_glx_get_tex_image_cookie_t {
unsigned int sequence;
} xcb_glx_get_tex_image_cookie_t;
/** Opcode for xcb_glx_get_tex_image. */
#define XCB_GLX_GET_TEX_IMAGE 135
/**
* @brief xcb_glx_get_tex_image_request_t
**/
typedef struct xcb_glx_get_tex_image_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t target;
int32_t level;
uint32_t format;
uint32_t type;
uint8_t swap_bytes;
} xcb_glx_get_tex_image_request_t;
/**
* @brief xcb_glx_get_tex_image_reply_t
**/
typedef struct xcb_glx_get_tex_image_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[8];
int32_t width;
int32_t height;
int32_t depth;
uint8_t pad2[4];
} xcb_glx_get_tex_image_reply_t;
/**
* @brief xcb_glx_get_tex_parameterfv_cookie_t
**/
typedef struct xcb_glx_get_tex_parameterfv_cookie_t {
unsigned int sequence;
} xcb_glx_get_tex_parameterfv_cookie_t;
/** Opcode for xcb_glx_get_tex_parameterfv. */
#define XCB_GLX_GET_TEX_PARAMETERFV 136
/**
* @brief xcb_glx_get_tex_parameterfv_request_t
**/
typedef struct xcb_glx_get_tex_parameterfv_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t target;
uint32_t pname;
} xcb_glx_get_tex_parameterfv_request_t;
/**
* @brief xcb_glx_get_tex_parameterfv_reply_t
**/
typedef struct xcb_glx_get_tex_parameterfv_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
xcb_glx_float32_t datum;
uint8_t pad2[12];
} xcb_glx_get_tex_parameterfv_reply_t;
/**
* @brief xcb_glx_get_tex_parameteriv_cookie_t
**/
typedef struct xcb_glx_get_tex_parameteriv_cookie_t {
unsigned int sequence;
} xcb_glx_get_tex_parameteriv_cookie_t;
/** Opcode for xcb_glx_get_tex_parameteriv. */
#define XCB_GLX_GET_TEX_PARAMETERIV 137
/**
* @brief xcb_glx_get_tex_parameteriv_request_t
**/
typedef struct xcb_glx_get_tex_parameteriv_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t target;
uint32_t pname;
} xcb_glx_get_tex_parameteriv_request_t;
/**
* @brief xcb_glx_get_tex_parameteriv_reply_t
**/
typedef struct xcb_glx_get_tex_parameteriv_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
int32_t datum;
uint8_t pad2[12];
} xcb_glx_get_tex_parameteriv_reply_t;
/**
* @brief xcb_glx_get_tex_level_parameterfv_cookie_t
**/
typedef struct xcb_glx_get_tex_level_parameterfv_cookie_t {
unsigned int sequence;
} xcb_glx_get_tex_level_parameterfv_cookie_t;
/** Opcode for xcb_glx_get_tex_level_parameterfv. */
#define XCB_GLX_GET_TEX_LEVEL_PARAMETERFV 138
/**
* @brief xcb_glx_get_tex_level_parameterfv_request_t
**/
typedef struct xcb_glx_get_tex_level_parameterfv_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t target;
int32_t level;
uint32_t pname;
} xcb_glx_get_tex_level_parameterfv_request_t;
/**
* @brief xcb_glx_get_tex_level_parameterfv_reply_t
**/
typedef struct xcb_glx_get_tex_level_parameterfv_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
xcb_glx_float32_t datum;
uint8_t pad2[12];
} xcb_glx_get_tex_level_parameterfv_reply_t;
/**
* @brief xcb_glx_get_tex_level_parameteriv_cookie_t
**/
typedef struct xcb_glx_get_tex_level_parameteriv_cookie_t {
unsigned int sequence;
} xcb_glx_get_tex_level_parameteriv_cookie_t;
/** Opcode for xcb_glx_get_tex_level_parameteriv. */
#define XCB_GLX_GET_TEX_LEVEL_PARAMETERIV 139
/**
* @brief xcb_glx_get_tex_level_parameteriv_request_t
**/
typedef struct xcb_glx_get_tex_level_parameteriv_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t target;
int32_t level;
uint32_t pname;
} xcb_glx_get_tex_level_parameteriv_request_t;
/**
* @brief xcb_glx_get_tex_level_parameteriv_reply_t
**/
typedef struct xcb_glx_get_tex_level_parameteriv_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
int32_t datum;
uint8_t pad2[12];
} xcb_glx_get_tex_level_parameteriv_reply_t;
/**
* @brief xcb_glx_is_enabled_cookie_t
**/
typedef struct xcb_glx_is_enabled_cookie_t {
unsigned int sequence;
} xcb_glx_is_enabled_cookie_t;
/** Opcode for xcb_glx_is_enabled. */
#define XCB_GLX_IS_ENABLED 140
/**
* @brief xcb_glx_is_enabled_request_t
**/
typedef struct xcb_glx_is_enabled_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t capability;
} xcb_glx_is_enabled_request_t;
/**
* @brief xcb_glx_is_enabled_reply_t
**/
typedef struct xcb_glx_is_enabled_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
xcb_glx_bool32_t ret_val;
} xcb_glx_is_enabled_reply_t;
/**
* @brief xcb_glx_is_list_cookie_t
**/
typedef struct xcb_glx_is_list_cookie_t {
unsigned int sequence;
} xcb_glx_is_list_cookie_t;
/** Opcode for xcb_glx_is_list. */
#define XCB_GLX_IS_LIST 141
/**
* @brief xcb_glx_is_list_request_t
**/
typedef struct xcb_glx_is_list_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t list;
} xcb_glx_is_list_request_t;
/**
* @brief xcb_glx_is_list_reply_t
**/
typedef struct xcb_glx_is_list_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
xcb_glx_bool32_t ret_val;
} xcb_glx_is_list_reply_t;
/** Opcode for xcb_glx_flush. */
#define XCB_GLX_FLUSH 142
/**
* @brief xcb_glx_flush_request_t
**/
typedef struct xcb_glx_flush_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
} xcb_glx_flush_request_t;
/**
* @brief xcb_glx_are_textures_resident_cookie_t
**/
typedef struct xcb_glx_are_textures_resident_cookie_t {
unsigned int sequence;
} xcb_glx_are_textures_resident_cookie_t;
/** Opcode for xcb_glx_are_textures_resident. */
#define XCB_GLX_ARE_TEXTURES_RESIDENT 143
/**
* @brief xcb_glx_are_textures_resident_request_t
**/
typedef struct xcb_glx_are_textures_resident_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
int32_t n;
} xcb_glx_are_textures_resident_request_t;
/**
* @brief xcb_glx_are_textures_resident_reply_t
**/
typedef struct xcb_glx_are_textures_resident_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
xcb_glx_bool32_t ret_val;
uint8_t pad1[20];
} xcb_glx_are_textures_resident_reply_t;
/** Opcode for xcb_glx_delete_textures. */
#define XCB_GLX_DELETE_TEXTURES 144
/**
* @brief xcb_glx_delete_textures_request_t
**/
typedef struct xcb_glx_delete_textures_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
int32_t n;
} xcb_glx_delete_textures_request_t;
/**
* @brief xcb_glx_gen_textures_cookie_t
**/
typedef struct xcb_glx_gen_textures_cookie_t {
unsigned int sequence;
} xcb_glx_gen_textures_cookie_t;
/** Opcode for xcb_glx_gen_textures. */
#define XCB_GLX_GEN_TEXTURES 145
/**
* @brief xcb_glx_gen_textures_request_t
**/
typedef struct xcb_glx_gen_textures_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
int32_t n;
} xcb_glx_gen_textures_request_t;
/**
* @brief xcb_glx_gen_textures_reply_t
**/
typedef struct xcb_glx_gen_textures_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[24];
} xcb_glx_gen_textures_reply_t;
/**
* @brief xcb_glx_is_texture_cookie_t
**/
typedef struct xcb_glx_is_texture_cookie_t {
unsigned int sequence;
} xcb_glx_is_texture_cookie_t;
/** Opcode for xcb_glx_is_texture. */
#define XCB_GLX_IS_TEXTURE 146
/**
* @brief xcb_glx_is_texture_request_t
**/
typedef struct xcb_glx_is_texture_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t texture;
} xcb_glx_is_texture_request_t;
/**
* @brief xcb_glx_is_texture_reply_t
**/
typedef struct xcb_glx_is_texture_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
xcb_glx_bool32_t ret_val;
} xcb_glx_is_texture_reply_t;
/**
* @brief xcb_glx_get_color_table_cookie_t
**/
typedef struct xcb_glx_get_color_table_cookie_t {
unsigned int sequence;
} xcb_glx_get_color_table_cookie_t;
/** Opcode for xcb_glx_get_color_table. */
#define XCB_GLX_GET_COLOR_TABLE 147
/**
* @brief xcb_glx_get_color_table_request_t
**/
typedef struct xcb_glx_get_color_table_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t target;
uint32_t format;
uint32_t type;
uint8_t swap_bytes;
} xcb_glx_get_color_table_request_t;
/**
* @brief xcb_glx_get_color_table_reply_t
**/
typedef struct xcb_glx_get_color_table_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[8];
int32_t width;
uint8_t pad2[12];
} xcb_glx_get_color_table_reply_t;
/**
* @brief xcb_glx_get_color_table_parameterfv_cookie_t
**/
typedef struct xcb_glx_get_color_table_parameterfv_cookie_t {
unsigned int sequence;
} xcb_glx_get_color_table_parameterfv_cookie_t;
/** Opcode for xcb_glx_get_color_table_parameterfv. */
#define XCB_GLX_GET_COLOR_TABLE_PARAMETERFV 148
/**
* @brief xcb_glx_get_color_table_parameterfv_request_t
**/
typedef struct xcb_glx_get_color_table_parameterfv_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t target;
uint32_t pname;
} xcb_glx_get_color_table_parameterfv_request_t;
/**
* @brief xcb_glx_get_color_table_parameterfv_reply_t
**/
typedef struct xcb_glx_get_color_table_parameterfv_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
xcb_glx_float32_t datum;
uint8_t pad2[12];
} xcb_glx_get_color_table_parameterfv_reply_t;
/**
* @brief xcb_glx_get_color_table_parameteriv_cookie_t
**/
typedef struct xcb_glx_get_color_table_parameteriv_cookie_t {
unsigned int sequence;
} xcb_glx_get_color_table_parameteriv_cookie_t;
/** Opcode for xcb_glx_get_color_table_parameteriv. */
#define XCB_GLX_GET_COLOR_TABLE_PARAMETERIV 149
/**
* @brief xcb_glx_get_color_table_parameteriv_request_t
**/
typedef struct xcb_glx_get_color_table_parameteriv_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t target;
uint32_t pname;
} xcb_glx_get_color_table_parameteriv_request_t;
/**
* @brief xcb_glx_get_color_table_parameteriv_reply_t
**/
typedef struct xcb_glx_get_color_table_parameteriv_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
int32_t datum;
uint8_t pad2[12];
} xcb_glx_get_color_table_parameteriv_reply_t;
/**
* @brief xcb_glx_get_convolution_filter_cookie_t
**/
typedef struct xcb_glx_get_convolution_filter_cookie_t {
unsigned int sequence;
} xcb_glx_get_convolution_filter_cookie_t;
/** Opcode for xcb_glx_get_convolution_filter. */
#define XCB_GLX_GET_CONVOLUTION_FILTER 150
/**
* @brief xcb_glx_get_convolution_filter_request_t
**/
typedef struct xcb_glx_get_convolution_filter_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t target;
uint32_t format;
uint32_t type;
uint8_t swap_bytes;
} xcb_glx_get_convolution_filter_request_t;
/**
* @brief xcb_glx_get_convolution_filter_reply_t
**/
typedef struct xcb_glx_get_convolution_filter_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[8];
int32_t width;
int32_t height;
uint8_t pad2[8];
} xcb_glx_get_convolution_filter_reply_t;
/**
* @brief xcb_glx_get_convolution_parameterfv_cookie_t
**/
typedef struct xcb_glx_get_convolution_parameterfv_cookie_t {
unsigned int sequence;
} xcb_glx_get_convolution_parameterfv_cookie_t;
/** Opcode for xcb_glx_get_convolution_parameterfv. */
#define XCB_GLX_GET_CONVOLUTION_PARAMETERFV 151
/**
* @brief xcb_glx_get_convolution_parameterfv_request_t
**/
typedef struct xcb_glx_get_convolution_parameterfv_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t target;
uint32_t pname;
} xcb_glx_get_convolution_parameterfv_request_t;
/**
* @brief xcb_glx_get_convolution_parameterfv_reply_t
**/
typedef struct xcb_glx_get_convolution_parameterfv_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
xcb_glx_float32_t datum;
uint8_t pad2[12];
} xcb_glx_get_convolution_parameterfv_reply_t;
/**
* @brief xcb_glx_get_convolution_parameteriv_cookie_t
**/
typedef struct xcb_glx_get_convolution_parameteriv_cookie_t {
unsigned int sequence;
} xcb_glx_get_convolution_parameteriv_cookie_t;
/** Opcode for xcb_glx_get_convolution_parameteriv. */
#define XCB_GLX_GET_CONVOLUTION_PARAMETERIV 152
/**
* @brief xcb_glx_get_convolution_parameteriv_request_t
**/
typedef struct xcb_glx_get_convolution_parameteriv_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t target;
uint32_t pname;
} xcb_glx_get_convolution_parameteriv_request_t;
/**
* @brief xcb_glx_get_convolution_parameteriv_reply_t
**/
typedef struct xcb_glx_get_convolution_parameteriv_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
int32_t datum;
uint8_t pad2[12];
} xcb_glx_get_convolution_parameteriv_reply_t;
/**
* @brief xcb_glx_get_separable_filter_cookie_t
**/
typedef struct xcb_glx_get_separable_filter_cookie_t {
unsigned int sequence;
} xcb_glx_get_separable_filter_cookie_t;
/** Opcode for xcb_glx_get_separable_filter. */
#define XCB_GLX_GET_SEPARABLE_FILTER 153
/**
* @brief xcb_glx_get_separable_filter_request_t
**/
typedef struct xcb_glx_get_separable_filter_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t target;
uint32_t format;
uint32_t type;
uint8_t swap_bytes;
} xcb_glx_get_separable_filter_request_t;
/**
* @brief xcb_glx_get_separable_filter_reply_t
**/
typedef struct xcb_glx_get_separable_filter_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[8];
int32_t row_w;
int32_t col_h;
uint8_t pad2[8];
} xcb_glx_get_separable_filter_reply_t;
/**
* @brief xcb_glx_get_histogram_cookie_t
**/
typedef struct xcb_glx_get_histogram_cookie_t {
unsigned int sequence;
} xcb_glx_get_histogram_cookie_t;
/** Opcode for xcb_glx_get_histogram. */
#define XCB_GLX_GET_HISTOGRAM 154
/**
* @brief xcb_glx_get_histogram_request_t
**/
typedef struct xcb_glx_get_histogram_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t target;
uint32_t format;
uint32_t type;
uint8_t swap_bytes;
uint8_t reset;
} xcb_glx_get_histogram_request_t;
/**
* @brief xcb_glx_get_histogram_reply_t
**/
typedef struct xcb_glx_get_histogram_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[8];
int32_t width;
uint8_t pad2[12];
} xcb_glx_get_histogram_reply_t;
/**
* @brief xcb_glx_get_histogram_parameterfv_cookie_t
**/
typedef struct xcb_glx_get_histogram_parameterfv_cookie_t {
unsigned int sequence;
} xcb_glx_get_histogram_parameterfv_cookie_t;
/** Opcode for xcb_glx_get_histogram_parameterfv. */
#define XCB_GLX_GET_HISTOGRAM_PARAMETERFV 155
/**
* @brief xcb_glx_get_histogram_parameterfv_request_t
**/
typedef struct xcb_glx_get_histogram_parameterfv_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t target;
uint32_t pname;
} xcb_glx_get_histogram_parameterfv_request_t;
/**
* @brief xcb_glx_get_histogram_parameterfv_reply_t
**/
typedef struct xcb_glx_get_histogram_parameterfv_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
xcb_glx_float32_t datum;
uint8_t pad2[12];
} xcb_glx_get_histogram_parameterfv_reply_t;
/**
* @brief xcb_glx_get_histogram_parameteriv_cookie_t
**/
typedef struct xcb_glx_get_histogram_parameteriv_cookie_t {
unsigned int sequence;
} xcb_glx_get_histogram_parameteriv_cookie_t;
/** Opcode for xcb_glx_get_histogram_parameteriv. */
#define XCB_GLX_GET_HISTOGRAM_PARAMETERIV 156
/**
* @brief xcb_glx_get_histogram_parameteriv_request_t
**/
typedef struct xcb_glx_get_histogram_parameteriv_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t target;
uint32_t pname;
} xcb_glx_get_histogram_parameteriv_request_t;
/**
* @brief xcb_glx_get_histogram_parameteriv_reply_t
**/
typedef struct xcb_glx_get_histogram_parameteriv_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
int32_t datum;
uint8_t pad2[12];
} xcb_glx_get_histogram_parameteriv_reply_t;
/**
* @brief xcb_glx_get_minmax_cookie_t
**/
typedef struct xcb_glx_get_minmax_cookie_t {
unsigned int sequence;
} xcb_glx_get_minmax_cookie_t;
/** Opcode for xcb_glx_get_minmax. */
#define XCB_GLX_GET_MINMAX 157
/**
* @brief xcb_glx_get_minmax_request_t
**/
typedef struct xcb_glx_get_minmax_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t target;
uint32_t format;
uint32_t type;
uint8_t swap_bytes;
uint8_t reset;
} xcb_glx_get_minmax_request_t;
/**
* @brief xcb_glx_get_minmax_reply_t
**/
typedef struct xcb_glx_get_minmax_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[24];
} xcb_glx_get_minmax_reply_t;
/**
* @brief xcb_glx_get_minmax_parameterfv_cookie_t
**/
typedef struct xcb_glx_get_minmax_parameterfv_cookie_t {
unsigned int sequence;
} xcb_glx_get_minmax_parameterfv_cookie_t;
/** Opcode for xcb_glx_get_minmax_parameterfv. */
#define XCB_GLX_GET_MINMAX_PARAMETERFV 158
/**
* @brief xcb_glx_get_minmax_parameterfv_request_t
**/
typedef struct xcb_glx_get_minmax_parameterfv_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t target;
uint32_t pname;
} xcb_glx_get_minmax_parameterfv_request_t;
/**
* @brief xcb_glx_get_minmax_parameterfv_reply_t
**/
typedef struct xcb_glx_get_minmax_parameterfv_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
xcb_glx_float32_t datum;
uint8_t pad2[12];
} xcb_glx_get_minmax_parameterfv_reply_t;
/**
* @brief xcb_glx_get_minmax_parameteriv_cookie_t
**/
typedef struct xcb_glx_get_minmax_parameteriv_cookie_t {
unsigned int sequence;
} xcb_glx_get_minmax_parameteriv_cookie_t;
/** Opcode for xcb_glx_get_minmax_parameteriv. */
#define XCB_GLX_GET_MINMAX_PARAMETERIV 159
/**
* @brief xcb_glx_get_minmax_parameteriv_request_t
**/
typedef struct xcb_glx_get_minmax_parameteriv_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t target;
uint32_t pname;
} xcb_glx_get_minmax_parameteriv_request_t;
/**
* @brief xcb_glx_get_minmax_parameteriv_reply_t
**/
typedef struct xcb_glx_get_minmax_parameteriv_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
int32_t datum;
uint8_t pad2[12];
} xcb_glx_get_minmax_parameteriv_reply_t;
/**
* @brief xcb_glx_get_compressed_tex_image_arb_cookie_t
**/
typedef struct xcb_glx_get_compressed_tex_image_arb_cookie_t {
unsigned int sequence;
} xcb_glx_get_compressed_tex_image_arb_cookie_t;
/** Opcode for xcb_glx_get_compressed_tex_image_arb. */
#define XCB_GLX_GET_COMPRESSED_TEX_IMAGE_ARB 160
/**
* @brief xcb_glx_get_compressed_tex_image_arb_request_t
**/
typedef struct xcb_glx_get_compressed_tex_image_arb_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t target;
int32_t level;
} xcb_glx_get_compressed_tex_image_arb_request_t;
/**
* @brief xcb_glx_get_compressed_tex_image_arb_reply_t
**/
typedef struct xcb_glx_get_compressed_tex_image_arb_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[8];
int32_t size;
uint8_t pad2[12];
} xcb_glx_get_compressed_tex_image_arb_reply_t;
/** Opcode for xcb_glx_delete_queries_arb. */
#define XCB_GLX_DELETE_QUERIES_ARB 161
/**
* @brief xcb_glx_delete_queries_arb_request_t
**/
typedef struct xcb_glx_delete_queries_arb_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
int32_t n;
} xcb_glx_delete_queries_arb_request_t;
/**
* @brief xcb_glx_gen_queries_arb_cookie_t
**/
typedef struct xcb_glx_gen_queries_arb_cookie_t {
unsigned int sequence;
} xcb_glx_gen_queries_arb_cookie_t;
/** Opcode for xcb_glx_gen_queries_arb. */
#define XCB_GLX_GEN_QUERIES_ARB 162
/**
* @brief xcb_glx_gen_queries_arb_request_t
**/
typedef struct xcb_glx_gen_queries_arb_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
int32_t n;
} xcb_glx_gen_queries_arb_request_t;
/**
* @brief xcb_glx_gen_queries_arb_reply_t
**/
typedef struct xcb_glx_gen_queries_arb_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[24];
} xcb_glx_gen_queries_arb_reply_t;
/**
* @brief xcb_glx_is_query_arb_cookie_t
**/
typedef struct xcb_glx_is_query_arb_cookie_t {
unsigned int sequence;
} xcb_glx_is_query_arb_cookie_t;
/** Opcode for xcb_glx_is_query_arb. */
#define XCB_GLX_IS_QUERY_ARB 163
/**
* @brief xcb_glx_is_query_arb_request_t
**/
typedef struct xcb_glx_is_query_arb_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t id;
} xcb_glx_is_query_arb_request_t;
/**
* @brief xcb_glx_is_query_arb_reply_t
**/
typedef struct xcb_glx_is_query_arb_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
xcb_glx_bool32_t ret_val;
} xcb_glx_is_query_arb_reply_t;
/**
* @brief xcb_glx_get_queryiv_arb_cookie_t
**/
typedef struct xcb_glx_get_queryiv_arb_cookie_t {
unsigned int sequence;
} xcb_glx_get_queryiv_arb_cookie_t;
/** Opcode for xcb_glx_get_queryiv_arb. */
#define XCB_GLX_GET_QUERYIV_ARB 164
/**
* @brief xcb_glx_get_queryiv_arb_request_t
**/
typedef struct xcb_glx_get_queryiv_arb_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t target;
uint32_t pname;
} xcb_glx_get_queryiv_arb_request_t;
/**
* @brief xcb_glx_get_queryiv_arb_reply_t
**/
typedef struct xcb_glx_get_queryiv_arb_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
int32_t datum;
uint8_t pad2[12];
} xcb_glx_get_queryiv_arb_reply_t;
/**
* @brief xcb_glx_get_query_objectiv_arb_cookie_t
**/
typedef struct xcb_glx_get_query_objectiv_arb_cookie_t {
unsigned int sequence;
} xcb_glx_get_query_objectiv_arb_cookie_t;
/** Opcode for xcb_glx_get_query_objectiv_arb. */
#define XCB_GLX_GET_QUERY_OBJECTIV_ARB 165
/**
* @brief xcb_glx_get_query_objectiv_arb_request_t
**/
typedef struct xcb_glx_get_query_objectiv_arb_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t id;
uint32_t pname;
} xcb_glx_get_query_objectiv_arb_request_t;
/**
* @brief xcb_glx_get_query_objectiv_arb_reply_t
**/
typedef struct xcb_glx_get_query_objectiv_arb_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
int32_t datum;
uint8_t pad2[12];
} xcb_glx_get_query_objectiv_arb_reply_t;
/**
* @brief xcb_glx_get_query_objectuiv_arb_cookie_t
**/
typedef struct xcb_glx_get_query_objectuiv_arb_cookie_t {
unsigned int sequence;
} xcb_glx_get_query_objectuiv_arb_cookie_t;
/** Opcode for xcb_glx_get_query_objectuiv_arb. */
#define XCB_GLX_GET_QUERY_OBJECTUIV_ARB 166
/**
* @brief xcb_glx_get_query_objectuiv_arb_request_t
**/
typedef struct xcb_glx_get_query_objectuiv_arb_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_glx_context_tag_t context_tag;
uint32_t id;
uint32_t pname;
} xcb_glx_get_query_objectuiv_arb_request_t;
/**
* @brief xcb_glx_get_query_objectuiv_arb_reply_t
**/
typedef struct xcb_glx_get_query_objectuiv_arb_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[4];
uint32_t n;
uint32_t datum;
uint8_t pad2[12];
} xcb_glx_get_query_objectuiv_arb_reply_t;
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_glx_pixmap_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_glx_pixmap_t)
*/
void
xcb_glx_pixmap_next (xcb_glx_pixmap_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_glx_pixmap_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_glx_pixmap_end (xcb_glx_pixmap_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_glx_context_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_glx_context_t)
*/
void
xcb_glx_context_next (xcb_glx_context_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_glx_context_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_glx_context_end (xcb_glx_context_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_glx_pbuffer_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_glx_pbuffer_t)
*/
void
xcb_glx_pbuffer_next (xcb_glx_pbuffer_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_glx_pbuffer_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_glx_pbuffer_end (xcb_glx_pbuffer_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_glx_window_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_glx_window_t)
*/
void
xcb_glx_window_next (xcb_glx_window_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_glx_window_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_glx_window_end (xcb_glx_window_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_glx_fbconfig_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_glx_fbconfig_t)
*/
void
xcb_glx_fbconfig_next (xcb_glx_fbconfig_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_glx_fbconfig_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_glx_fbconfig_end (xcb_glx_fbconfig_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_glx_drawable_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_glx_drawable_t)
*/
void
xcb_glx_drawable_next (xcb_glx_drawable_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_glx_drawable_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_glx_drawable_end (xcb_glx_drawable_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_glx_float32_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_glx_float32_t)
*/
void
xcb_glx_float32_next (xcb_glx_float32_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_glx_float32_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_glx_float32_end (xcb_glx_float32_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_glx_float64_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_glx_float64_t)
*/
void
xcb_glx_float64_next (xcb_glx_float64_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_glx_float64_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_glx_float64_end (xcb_glx_float64_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_glx_bool32_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_glx_bool32_t)
*/
void
xcb_glx_bool32_next (xcb_glx_bool32_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_glx_bool32_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_glx_bool32_end (xcb_glx_bool32_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_glx_context_tag_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_glx_context_tag_t)
*/
void
xcb_glx_context_tag_next (xcb_glx_context_tag_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_glx_context_tag_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_glx_context_tag_end (xcb_glx_context_tag_iterator_t i);
int
xcb_glx_render_sizeof (const void *_buffer,
uint32_t data_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_render_checked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t data_len,
const uint8_t *data);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_render (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t data_len,
const uint8_t *data);
uint8_t *
xcb_glx_render_data (const xcb_glx_render_request_t *R);
int
xcb_glx_render_data_length (const xcb_glx_render_request_t *R);
xcb_generic_iterator_t
xcb_glx_render_data_end (const xcb_glx_render_request_t *R);
int
xcb_glx_render_large_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_render_large_checked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint16_t request_num,
uint16_t request_total,
uint32_t data_len,
const uint8_t *data);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_render_large (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint16_t request_num,
uint16_t request_total,
uint32_t data_len,
const uint8_t *data);
uint8_t *
xcb_glx_render_large_data (const xcb_glx_render_large_request_t *R);
int
xcb_glx_render_large_data_length (const xcb_glx_render_large_request_t *R);
xcb_generic_iterator_t
xcb_glx_render_large_data_end (const xcb_glx_render_large_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_create_context_checked (xcb_connection_t *c,
xcb_glx_context_t context,
xcb_visualid_t visual,
uint32_t screen,
xcb_glx_context_t share_list,
uint8_t is_direct);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_create_context (xcb_connection_t *c,
xcb_glx_context_t context,
xcb_visualid_t visual,
uint32_t screen,
xcb_glx_context_t share_list,
uint8_t is_direct);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_destroy_context_checked (xcb_connection_t *c,
xcb_glx_context_t context);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_destroy_context (xcb_connection_t *c,
xcb_glx_context_t context);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_make_current_cookie_t
xcb_glx_make_current (xcb_connection_t *c,
xcb_glx_drawable_t drawable,
xcb_glx_context_t context,
xcb_glx_context_tag_t old_context_tag);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_make_current_cookie_t
xcb_glx_make_current_unchecked (xcb_connection_t *c,
xcb_glx_drawable_t drawable,
xcb_glx_context_t context,
xcb_glx_context_tag_t old_context_tag);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_make_current_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_make_current_reply_t *
xcb_glx_make_current_reply (xcb_connection_t *c,
xcb_glx_make_current_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_is_direct_cookie_t
xcb_glx_is_direct (xcb_connection_t *c,
xcb_glx_context_t context);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_is_direct_cookie_t
xcb_glx_is_direct_unchecked (xcb_connection_t *c,
xcb_glx_context_t context);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_is_direct_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_is_direct_reply_t *
xcb_glx_is_direct_reply (xcb_connection_t *c,
xcb_glx_is_direct_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_query_version_cookie_t
xcb_glx_query_version (xcb_connection_t *c,
uint32_t major_version,
uint32_t minor_version);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_query_version_cookie_t
xcb_glx_query_version_unchecked (xcb_connection_t *c,
uint32_t major_version,
uint32_t minor_version);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_query_version_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_query_version_reply_t *
xcb_glx_query_version_reply (xcb_connection_t *c,
xcb_glx_query_version_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_wait_gl_checked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_wait_gl (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_wait_x_checked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_wait_x (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_copy_context_checked (xcb_connection_t *c,
xcb_glx_context_t src,
xcb_glx_context_t dest,
uint32_t mask,
xcb_glx_context_tag_t src_context_tag);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_copy_context (xcb_connection_t *c,
xcb_glx_context_t src,
xcb_glx_context_t dest,
uint32_t mask,
xcb_glx_context_tag_t src_context_tag);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_swap_buffers_checked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
xcb_glx_drawable_t drawable);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_swap_buffers (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
xcb_glx_drawable_t drawable);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_use_x_font_checked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
xcb_font_t font,
uint32_t first,
uint32_t count,
uint32_t list_base);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_use_x_font (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
xcb_font_t font,
uint32_t first,
uint32_t count,
uint32_t list_base);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_create_glx_pixmap_checked (xcb_connection_t *c,
uint32_t screen,
xcb_visualid_t visual,
xcb_pixmap_t pixmap,
xcb_glx_pixmap_t glx_pixmap);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_create_glx_pixmap (xcb_connection_t *c,
uint32_t screen,
xcb_visualid_t visual,
xcb_pixmap_t pixmap,
xcb_glx_pixmap_t glx_pixmap);
int
xcb_glx_get_visual_configs_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_visual_configs_cookie_t
xcb_glx_get_visual_configs (xcb_connection_t *c,
uint32_t screen);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_visual_configs_cookie_t
xcb_glx_get_visual_configs_unchecked (xcb_connection_t *c,
uint32_t screen);
uint32_t *
xcb_glx_get_visual_configs_property_list (const xcb_glx_get_visual_configs_reply_t *R);
int
xcb_glx_get_visual_configs_property_list_length (const xcb_glx_get_visual_configs_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_visual_configs_property_list_end (const xcb_glx_get_visual_configs_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_visual_configs_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_visual_configs_reply_t *
xcb_glx_get_visual_configs_reply (xcb_connection_t *c,
xcb_glx_get_visual_configs_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_destroy_glx_pixmap_checked (xcb_connection_t *c,
xcb_glx_pixmap_t glx_pixmap);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_destroy_glx_pixmap (xcb_connection_t *c,
xcb_glx_pixmap_t glx_pixmap);
int
xcb_glx_vendor_private_sizeof (const void *_buffer,
uint32_t data_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_vendor_private_checked (xcb_connection_t *c,
uint32_t vendor_code,
xcb_glx_context_tag_t context_tag,
uint32_t data_len,
const uint8_t *data);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_vendor_private (xcb_connection_t *c,
uint32_t vendor_code,
xcb_glx_context_tag_t context_tag,
uint32_t data_len,
const uint8_t *data);
uint8_t *
xcb_glx_vendor_private_data (const xcb_glx_vendor_private_request_t *R);
int
xcb_glx_vendor_private_data_length (const xcb_glx_vendor_private_request_t *R);
xcb_generic_iterator_t
xcb_glx_vendor_private_data_end (const xcb_glx_vendor_private_request_t *R);
int
xcb_glx_vendor_private_with_reply_sizeof (const void *_buffer,
uint32_t data_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_vendor_private_with_reply_cookie_t
xcb_glx_vendor_private_with_reply (xcb_connection_t *c,
uint32_t vendor_code,
xcb_glx_context_tag_t context_tag,
uint32_t data_len,
const uint8_t *data);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_vendor_private_with_reply_cookie_t
xcb_glx_vendor_private_with_reply_unchecked (xcb_connection_t *c,
uint32_t vendor_code,
xcb_glx_context_tag_t context_tag,
uint32_t data_len,
const uint8_t *data);
uint8_t *
xcb_glx_vendor_private_with_reply_data_2 (const xcb_glx_vendor_private_with_reply_reply_t *R);
int
xcb_glx_vendor_private_with_reply_data_2_length (const xcb_glx_vendor_private_with_reply_reply_t *R);
xcb_generic_iterator_t
xcb_glx_vendor_private_with_reply_data_2_end (const xcb_glx_vendor_private_with_reply_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_vendor_private_with_reply_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_vendor_private_with_reply_reply_t *
xcb_glx_vendor_private_with_reply_reply (xcb_connection_t *c,
xcb_glx_vendor_private_with_reply_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_query_extensions_string_cookie_t
xcb_glx_query_extensions_string (xcb_connection_t *c,
uint32_t screen);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_query_extensions_string_cookie_t
xcb_glx_query_extensions_string_unchecked (xcb_connection_t *c,
uint32_t screen);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_query_extensions_string_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_query_extensions_string_reply_t *
xcb_glx_query_extensions_string_reply (xcb_connection_t *c,
xcb_glx_query_extensions_string_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_query_server_string_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_query_server_string_cookie_t
xcb_glx_query_server_string (xcb_connection_t *c,
uint32_t screen,
uint32_t name);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_query_server_string_cookie_t
xcb_glx_query_server_string_unchecked (xcb_connection_t *c,
uint32_t screen,
uint32_t name);
char *
xcb_glx_query_server_string_string (const xcb_glx_query_server_string_reply_t *R);
int
xcb_glx_query_server_string_string_length (const xcb_glx_query_server_string_reply_t *R);
xcb_generic_iterator_t
xcb_glx_query_server_string_string_end (const xcb_glx_query_server_string_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_query_server_string_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_query_server_string_reply_t *
xcb_glx_query_server_string_reply (xcb_connection_t *c,
xcb_glx_query_server_string_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_client_info_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_client_info_checked (xcb_connection_t *c,
uint32_t major_version,
uint32_t minor_version,
uint32_t str_len,
const char *string);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_client_info (xcb_connection_t *c,
uint32_t major_version,
uint32_t minor_version,
uint32_t str_len,
const char *string);
char *
xcb_glx_client_info_string (const xcb_glx_client_info_request_t *R);
int
xcb_glx_client_info_string_length (const xcb_glx_client_info_request_t *R);
xcb_generic_iterator_t
xcb_glx_client_info_string_end (const xcb_glx_client_info_request_t *R);
int
xcb_glx_get_fb_configs_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_fb_configs_cookie_t
xcb_glx_get_fb_configs (xcb_connection_t *c,
uint32_t screen);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_fb_configs_cookie_t
xcb_glx_get_fb_configs_unchecked (xcb_connection_t *c,
uint32_t screen);
uint32_t *
xcb_glx_get_fb_configs_property_list (const xcb_glx_get_fb_configs_reply_t *R);
int
xcb_glx_get_fb_configs_property_list_length (const xcb_glx_get_fb_configs_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_fb_configs_property_list_end (const xcb_glx_get_fb_configs_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_fb_configs_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_fb_configs_reply_t *
xcb_glx_get_fb_configs_reply (xcb_connection_t *c,
xcb_glx_get_fb_configs_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_create_pixmap_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_create_pixmap_checked (xcb_connection_t *c,
uint32_t screen,
xcb_glx_fbconfig_t fbconfig,
xcb_pixmap_t pixmap,
xcb_glx_pixmap_t glx_pixmap,
uint32_t num_attribs,
const uint32_t *attribs);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_create_pixmap (xcb_connection_t *c,
uint32_t screen,
xcb_glx_fbconfig_t fbconfig,
xcb_pixmap_t pixmap,
xcb_glx_pixmap_t glx_pixmap,
uint32_t num_attribs,
const uint32_t *attribs);
uint32_t *
xcb_glx_create_pixmap_attribs (const xcb_glx_create_pixmap_request_t *R);
int
xcb_glx_create_pixmap_attribs_length (const xcb_glx_create_pixmap_request_t *R);
xcb_generic_iterator_t
xcb_glx_create_pixmap_attribs_end (const xcb_glx_create_pixmap_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_destroy_pixmap_checked (xcb_connection_t *c,
xcb_glx_pixmap_t glx_pixmap);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_destroy_pixmap (xcb_connection_t *c,
xcb_glx_pixmap_t glx_pixmap);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_create_new_context_checked (xcb_connection_t *c,
xcb_glx_context_t context,
xcb_glx_fbconfig_t fbconfig,
uint32_t screen,
uint32_t render_type,
xcb_glx_context_t share_list,
uint8_t is_direct);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_create_new_context (xcb_connection_t *c,
xcb_glx_context_t context,
xcb_glx_fbconfig_t fbconfig,
uint32_t screen,
uint32_t render_type,
xcb_glx_context_t share_list,
uint8_t is_direct);
int
xcb_glx_query_context_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_query_context_cookie_t
xcb_glx_query_context (xcb_connection_t *c,
xcb_glx_context_t context);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_query_context_cookie_t
xcb_glx_query_context_unchecked (xcb_connection_t *c,
xcb_glx_context_t context);
uint32_t *
xcb_glx_query_context_attribs (const xcb_glx_query_context_reply_t *R);
int
xcb_glx_query_context_attribs_length (const xcb_glx_query_context_reply_t *R);
xcb_generic_iterator_t
xcb_glx_query_context_attribs_end (const xcb_glx_query_context_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_query_context_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_query_context_reply_t *
xcb_glx_query_context_reply (xcb_connection_t *c,
xcb_glx_query_context_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_make_context_current_cookie_t
xcb_glx_make_context_current (xcb_connection_t *c,
xcb_glx_context_tag_t old_context_tag,
xcb_glx_drawable_t drawable,
xcb_glx_drawable_t read_drawable,
xcb_glx_context_t context);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_make_context_current_cookie_t
xcb_glx_make_context_current_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t old_context_tag,
xcb_glx_drawable_t drawable,
xcb_glx_drawable_t read_drawable,
xcb_glx_context_t context);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_make_context_current_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_make_context_current_reply_t *
xcb_glx_make_context_current_reply (xcb_connection_t *c,
xcb_glx_make_context_current_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_create_pbuffer_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_create_pbuffer_checked (xcb_connection_t *c,
uint32_t screen,
xcb_glx_fbconfig_t fbconfig,
xcb_glx_pbuffer_t pbuffer,
uint32_t num_attribs,
const uint32_t *attribs);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_create_pbuffer (xcb_connection_t *c,
uint32_t screen,
xcb_glx_fbconfig_t fbconfig,
xcb_glx_pbuffer_t pbuffer,
uint32_t num_attribs,
const uint32_t *attribs);
uint32_t *
xcb_glx_create_pbuffer_attribs (const xcb_glx_create_pbuffer_request_t *R);
int
xcb_glx_create_pbuffer_attribs_length (const xcb_glx_create_pbuffer_request_t *R);
xcb_generic_iterator_t
xcb_glx_create_pbuffer_attribs_end (const xcb_glx_create_pbuffer_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_destroy_pbuffer_checked (xcb_connection_t *c,
xcb_glx_pbuffer_t pbuffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_destroy_pbuffer (xcb_connection_t *c,
xcb_glx_pbuffer_t pbuffer);
int
xcb_glx_get_drawable_attributes_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_drawable_attributes_cookie_t
xcb_glx_get_drawable_attributes (xcb_connection_t *c,
xcb_glx_drawable_t drawable);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_drawable_attributes_cookie_t
xcb_glx_get_drawable_attributes_unchecked (xcb_connection_t *c,
xcb_glx_drawable_t drawable);
uint32_t *
xcb_glx_get_drawable_attributes_attribs (const xcb_glx_get_drawable_attributes_reply_t *R);
int
xcb_glx_get_drawable_attributes_attribs_length (const xcb_glx_get_drawable_attributes_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_drawable_attributes_attribs_end (const xcb_glx_get_drawable_attributes_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_drawable_attributes_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_drawable_attributes_reply_t *
xcb_glx_get_drawable_attributes_reply (xcb_connection_t *c,
xcb_glx_get_drawable_attributes_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_change_drawable_attributes_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_change_drawable_attributes_checked (xcb_connection_t *c,
xcb_glx_drawable_t drawable,
uint32_t num_attribs,
const uint32_t *attribs);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_change_drawable_attributes (xcb_connection_t *c,
xcb_glx_drawable_t drawable,
uint32_t num_attribs,
const uint32_t *attribs);
uint32_t *
xcb_glx_change_drawable_attributes_attribs (const xcb_glx_change_drawable_attributes_request_t *R);
int
xcb_glx_change_drawable_attributes_attribs_length (const xcb_glx_change_drawable_attributes_request_t *R);
xcb_generic_iterator_t
xcb_glx_change_drawable_attributes_attribs_end (const xcb_glx_change_drawable_attributes_request_t *R);
int
xcb_glx_create_window_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_create_window_checked (xcb_connection_t *c,
uint32_t screen,
xcb_glx_fbconfig_t fbconfig,
xcb_window_t window,
xcb_glx_window_t glx_window,
uint32_t num_attribs,
const uint32_t *attribs);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_create_window (xcb_connection_t *c,
uint32_t screen,
xcb_glx_fbconfig_t fbconfig,
xcb_window_t window,
xcb_glx_window_t glx_window,
uint32_t num_attribs,
const uint32_t *attribs);
uint32_t *
xcb_glx_create_window_attribs (const xcb_glx_create_window_request_t *R);
int
xcb_glx_create_window_attribs_length (const xcb_glx_create_window_request_t *R);
xcb_generic_iterator_t
xcb_glx_create_window_attribs_end (const xcb_glx_create_window_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_delete_window_checked (xcb_connection_t *c,
xcb_glx_window_t glxwindow);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_delete_window (xcb_connection_t *c,
xcb_glx_window_t glxwindow);
int
xcb_glx_set_client_info_arb_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_set_client_info_arb_checked (xcb_connection_t *c,
uint32_t major_version,
uint32_t minor_version,
uint32_t num_versions,
uint32_t gl_str_len,
uint32_t glx_str_len,
const uint32_t *gl_versions,
const char *gl_extension_string,
const char *glx_extension_string);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_set_client_info_arb (xcb_connection_t *c,
uint32_t major_version,
uint32_t minor_version,
uint32_t num_versions,
uint32_t gl_str_len,
uint32_t glx_str_len,
const uint32_t *gl_versions,
const char *gl_extension_string,
const char *glx_extension_string);
uint32_t *
xcb_glx_set_client_info_arb_gl_versions (const xcb_glx_set_client_info_arb_request_t *R);
int
xcb_glx_set_client_info_arb_gl_versions_length (const xcb_glx_set_client_info_arb_request_t *R);
xcb_generic_iterator_t
xcb_glx_set_client_info_arb_gl_versions_end (const xcb_glx_set_client_info_arb_request_t *R);
char *
xcb_glx_set_client_info_arb_gl_extension_string (const xcb_glx_set_client_info_arb_request_t *R);
int
xcb_glx_set_client_info_arb_gl_extension_string_length (const xcb_glx_set_client_info_arb_request_t *R);
xcb_generic_iterator_t
xcb_glx_set_client_info_arb_gl_extension_string_end (const xcb_glx_set_client_info_arb_request_t *R);
char *
xcb_glx_set_client_info_arb_glx_extension_string (const xcb_glx_set_client_info_arb_request_t *R);
int
xcb_glx_set_client_info_arb_glx_extension_string_length (const xcb_glx_set_client_info_arb_request_t *R);
xcb_generic_iterator_t
xcb_glx_set_client_info_arb_glx_extension_string_end (const xcb_glx_set_client_info_arb_request_t *R);
int
xcb_glx_create_context_attribs_arb_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_create_context_attribs_arb_checked (xcb_connection_t *c,
xcb_glx_context_t context,
xcb_glx_fbconfig_t fbconfig,
uint32_t screen,
xcb_glx_context_t share_list,
uint8_t is_direct,
uint32_t num_attribs,
const uint32_t *attribs);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_create_context_attribs_arb (xcb_connection_t *c,
xcb_glx_context_t context,
xcb_glx_fbconfig_t fbconfig,
uint32_t screen,
xcb_glx_context_t share_list,
uint8_t is_direct,
uint32_t num_attribs,
const uint32_t *attribs);
uint32_t *
xcb_glx_create_context_attribs_arb_attribs (const xcb_glx_create_context_attribs_arb_request_t *R);
int
xcb_glx_create_context_attribs_arb_attribs_length (const xcb_glx_create_context_attribs_arb_request_t *R);
xcb_generic_iterator_t
xcb_glx_create_context_attribs_arb_attribs_end (const xcb_glx_create_context_attribs_arb_request_t *R);
int
xcb_glx_set_client_info_2arb_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_set_client_info_2arb_checked (xcb_connection_t *c,
uint32_t major_version,
uint32_t minor_version,
uint32_t num_versions,
uint32_t gl_str_len,
uint32_t glx_str_len,
const uint32_t *gl_versions,
const char *gl_extension_string,
const char *glx_extension_string);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_set_client_info_2arb (xcb_connection_t *c,
uint32_t major_version,
uint32_t minor_version,
uint32_t num_versions,
uint32_t gl_str_len,
uint32_t glx_str_len,
const uint32_t *gl_versions,
const char *gl_extension_string,
const char *glx_extension_string);
uint32_t *
xcb_glx_set_client_info_2arb_gl_versions (const xcb_glx_set_client_info_2arb_request_t *R);
int
xcb_glx_set_client_info_2arb_gl_versions_length (const xcb_glx_set_client_info_2arb_request_t *R);
xcb_generic_iterator_t
xcb_glx_set_client_info_2arb_gl_versions_end (const xcb_glx_set_client_info_2arb_request_t *R);
char *
xcb_glx_set_client_info_2arb_gl_extension_string (const xcb_glx_set_client_info_2arb_request_t *R);
int
xcb_glx_set_client_info_2arb_gl_extension_string_length (const xcb_glx_set_client_info_2arb_request_t *R);
xcb_generic_iterator_t
xcb_glx_set_client_info_2arb_gl_extension_string_end (const xcb_glx_set_client_info_2arb_request_t *R);
char *
xcb_glx_set_client_info_2arb_glx_extension_string (const xcb_glx_set_client_info_2arb_request_t *R);
int
xcb_glx_set_client_info_2arb_glx_extension_string_length (const xcb_glx_set_client_info_2arb_request_t *R);
xcb_generic_iterator_t
xcb_glx_set_client_info_2arb_glx_extension_string_end (const xcb_glx_set_client_info_2arb_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_new_list_checked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t list,
uint32_t mode);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_new_list (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t list,
uint32_t mode);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_end_list_checked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_end_list (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_delete_lists_checked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t list,
int32_t range);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_delete_lists (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t list,
int32_t range);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_gen_lists_cookie_t
xcb_glx_gen_lists (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
int32_t range);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_gen_lists_cookie_t
xcb_glx_gen_lists_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
int32_t range);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_gen_lists_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_gen_lists_reply_t *
xcb_glx_gen_lists_reply (xcb_connection_t *c,
xcb_glx_gen_lists_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_feedback_buffer_checked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
int32_t size,
int32_t type);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_feedback_buffer (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
int32_t size,
int32_t type);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_select_buffer_checked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
int32_t size);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_select_buffer (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
int32_t size);
int
xcb_glx_render_mode_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_render_mode_cookie_t
xcb_glx_render_mode (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t mode);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_render_mode_cookie_t
xcb_glx_render_mode_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t mode);
uint32_t *
xcb_glx_render_mode_data (const xcb_glx_render_mode_reply_t *R);
int
xcb_glx_render_mode_data_length (const xcb_glx_render_mode_reply_t *R);
xcb_generic_iterator_t
xcb_glx_render_mode_data_end (const xcb_glx_render_mode_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_render_mode_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_render_mode_reply_t *
xcb_glx_render_mode_reply (xcb_connection_t *c,
xcb_glx_render_mode_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_finish_cookie_t
xcb_glx_finish (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_finish_cookie_t
xcb_glx_finish_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_finish_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_finish_reply_t *
xcb_glx_finish_reply (xcb_connection_t *c,
xcb_glx_finish_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_pixel_storef_checked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t pname,
xcb_glx_float32_t datum);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_pixel_storef (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t pname,
xcb_glx_float32_t datum);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_pixel_storei_checked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t pname,
int32_t datum);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_pixel_storei (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t pname,
int32_t datum);
int
xcb_glx_read_pixels_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_read_pixels_cookie_t
xcb_glx_read_pixels (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
int32_t x,
int32_t y,
int32_t width,
int32_t height,
uint32_t format,
uint32_t type,
uint8_t swap_bytes,
uint8_t lsb_first);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_read_pixels_cookie_t
xcb_glx_read_pixels_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
int32_t x,
int32_t y,
int32_t width,
int32_t height,
uint32_t format,
uint32_t type,
uint8_t swap_bytes,
uint8_t lsb_first);
uint8_t *
xcb_glx_read_pixels_data (const xcb_glx_read_pixels_reply_t *R);
int
xcb_glx_read_pixels_data_length (const xcb_glx_read_pixels_reply_t *R);
xcb_generic_iterator_t
xcb_glx_read_pixels_data_end (const xcb_glx_read_pixels_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_read_pixels_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_read_pixels_reply_t *
xcb_glx_read_pixels_reply (xcb_connection_t *c,
xcb_glx_read_pixels_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_booleanv_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_booleanv_cookie_t
xcb_glx_get_booleanv (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
int32_t pname);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_booleanv_cookie_t
xcb_glx_get_booleanv_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
int32_t pname);
uint8_t *
xcb_glx_get_booleanv_data (const xcb_glx_get_booleanv_reply_t *R);
int
xcb_glx_get_booleanv_data_length (const xcb_glx_get_booleanv_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_booleanv_data_end (const xcb_glx_get_booleanv_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_booleanv_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_booleanv_reply_t *
xcb_glx_get_booleanv_reply (xcb_connection_t *c,
xcb_glx_get_booleanv_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_clip_plane_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_clip_plane_cookie_t
xcb_glx_get_clip_plane (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
int32_t plane);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_clip_plane_cookie_t
xcb_glx_get_clip_plane_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
int32_t plane);
xcb_glx_float64_t *
xcb_glx_get_clip_plane_data (const xcb_glx_get_clip_plane_reply_t *R);
int
xcb_glx_get_clip_plane_data_length (const xcb_glx_get_clip_plane_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_clip_plane_data_end (const xcb_glx_get_clip_plane_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_clip_plane_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_clip_plane_reply_t *
xcb_glx_get_clip_plane_reply (xcb_connection_t *c,
xcb_glx_get_clip_plane_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_doublev_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_doublev_cookie_t
xcb_glx_get_doublev (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t pname);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_doublev_cookie_t
xcb_glx_get_doublev_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t pname);
xcb_glx_float64_t *
xcb_glx_get_doublev_data (const xcb_glx_get_doublev_reply_t *R);
int
xcb_glx_get_doublev_data_length (const xcb_glx_get_doublev_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_doublev_data_end (const xcb_glx_get_doublev_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_doublev_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_doublev_reply_t *
xcb_glx_get_doublev_reply (xcb_connection_t *c,
xcb_glx_get_doublev_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_error_cookie_t
xcb_glx_get_error (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_error_cookie_t
xcb_glx_get_error_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_error_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_error_reply_t *
xcb_glx_get_error_reply (xcb_connection_t *c,
xcb_glx_get_error_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_floatv_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_floatv_cookie_t
xcb_glx_get_floatv (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t pname);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_floatv_cookie_t
xcb_glx_get_floatv_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t pname);
xcb_glx_float32_t *
xcb_glx_get_floatv_data (const xcb_glx_get_floatv_reply_t *R);
int
xcb_glx_get_floatv_data_length (const xcb_glx_get_floatv_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_floatv_data_end (const xcb_glx_get_floatv_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_floatv_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_floatv_reply_t *
xcb_glx_get_floatv_reply (xcb_connection_t *c,
xcb_glx_get_floatv_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_integerv_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_integerv_cookie_t
xcb_glx_get_integerv (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t pname);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_integerv_cookie_t
xcb_glx_get_integerv_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t pname);
int32_t *
xcb_glx_get_integerv_data (const xcb_glx_get_integerv_reply_t *R);
int
xcb_glx_get_integerv_data_length (const xcb_glx_get_integerv_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_integerv_data_end (const xcb_glx_get_integerv_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_integerv_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_integerv_reply_t *
xcb_glx_get_integerv_reply (xcb_connection_t *c,
xcb_glx_get_integerv_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_lightfv_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_lightfv_cookie_t
xcb_glx_get_lightfv (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t light,
uint32_t pname);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_lightfv_cookie_t
xcb_glx_get_lightfv_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t light,
uint32_t pname);
xcb_glx_float32_t *
xcb_glx_get_lightfv_data (const xcb_glx_get_lightfv_reply_t *R);
int
xcb_glx_get_lightfv_data_length (const xcb_glx_get_lightfv_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_lightfv_data_end (const xcb_glx_get_lightfv_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_lightfv_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_lightfv_reply_t *
xcb_glx_get_lightfv_reply (xcb_connection_t *c,
xcb_glx_get_lightfv_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_lightiv_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_lightiv_cookie_t
xcb_glx_get_lightiv (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t light,
uint32_t pname);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_lightiv_cookie_t
xcb_glx_get_lightiv_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t light,
uint32_t pname);
int32_t *
xcb_glx_get_lightiv_data (const xcb_glx_get_lightiv_reply_t *R);
int
xcb_glx_get_lightiv_data_length (const xcb_glx_get_lightiv_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_lightiv_data_end (const xcb_glx_get_lightiv_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_lightiv_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_lightiv_reply_t *
xcb_glx_get_lightiv_reply (xcb_connection_t *c,
xcb_glx_get_lightiv_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_mapdv_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_mapdv_cookie_t
xcb_glx_get_mapdv (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t query);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_mapdv_cookie_t
xcb_glx_get_mapdv_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t query);
xcb_glx_float64_t *
xcb_glx_get_mapdv_data (const xcb_glx_get_mapdv_reply_t *R);
int
xcb_glx_get_mapdv_data_length (const xcb_glx_get_mapdv_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_mapdv_data_end (const xcb_glx_get_mapdv_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_mapdv_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_mapdv_reply_t *
xcb_glx_get_mapdv_reply (xcb_connection_t *c,
xcb_glx_get_mapdv_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_mapfv_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_mapfv_cookie_t
xcb_glx_get_mapfv (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t query);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_mapfv_cookie_t
xcb_glx_get_mapfv_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t query);
xcb_glx_float32_t *
xcb_glx_get_mapfv_data (const xcb_glx_get_mapfv_reply_t *R);
int
xcb_glx_get_mapfv_data_length (const xcb_glx_get_mapfv_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_mapfv_data_end (const xcb_glx_get_mapfv_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_mapfv_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_mapfv_reply_t *
xcb_glx_get_mapfv_reply (xcb_connection_t *c,
xcb_glx_get_mapfv_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_mapiv_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_mapiv_cookie_t
xcb_glx_get_mapiv (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t query);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_mapiv_cookie_t
xcb_glx_get_mapiv_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t query);
int32_t *
xcb_glx_get_mapiv_data (const xcb_glx_get_mapiv_reply_t *R);
int
xcb_glx_get_mapiv_data_length (const xcb_glx_get_mapiv_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_mapiv_data_end (const xcb_glx_get_mapiv_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_mapiv_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_mapiv_reply_t *
xcb_glx_get_mapiv_reply (xcb_connection_t *c,
xcb_glx_get_mapiv_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_materialfv_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_materialfv_cookie_t
xcb_glx_get_materialfv (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t face,
uint32_t pname);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_materialfv_cookie_t
xcb_glx_get_materialfv_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t face,
uint32_t pname);
xcb_glx_float32_t *
xcb_glx_get_materialfv_data (const xcb_glx_get_materialfv_reply_t *R);
int
xcb_glx_get_materialfv_data_length (const xcb_glx_get_materialfv_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_materialfv_data_end (const xcb_glx_get_materialfv_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_materialfv_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_materialfv_reply_t *
xcb_glx_get_materialfv_reply (xcb_connection_t *c,
xcb_glx_get_materialfv_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_materialiv_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_materialiv_cookie_t
xcb_glx_get_materialiv (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t face,
uint32_t pname);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_materialiv_cookie_t
xcb_glx_get_materialiv_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t face,
uint32_t pname);
int32_t *
xcb_glx_get_materialiv_data (const xcb_glx_get_materialiv_reply_t *R);
int
xcb_glx_get_materialiv_data_length (const xcb_glx_get_materialiv_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_materialiv_data_end (const xcb_glx_get_materialiv_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_materialiv_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_materialiv_reply_t *
xcb_glx_get_materialiv_reply (xcb_connection_t *c,
xcb_glx_get_materialiv_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_pixel_mapfv_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_pixel_mapfv_cookie_t
xcb_glx_get_pixel_mapfv (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t map);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_pixel_mapfv_cookie_t
xcb_glx_get_pixel_mapfv_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t map);
xcb_glx_float32_t *
xcb_glx_get_pixel_mapfv_data (const xcb_glx_get_pixel_mapfv_reply_t *R);
int
xcb_glx_get_pixel_mapfv_data_length (const xcb_glx_get_pixel_mapfv_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_pixel_mapfv_data_end (const xcb_glx_get_pixel_mapfv_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_pixel_mapfv_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_pixel_mapfv_reply_t *
xcb_glx_get_pixel_mapfv_reply (xcb_connection_t *c,
xcb_glx_get_pixel_mapfv_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_pixel_mapuiv_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_pixel_mapuiv_cookie_t
xcb_glx_get_pixel_mapuiv (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t map);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_pixel_mapuiv_cookie_t
xcb_glx_get_pixel_mapuiv_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t map);
uint32_t *
xcb_glx_get_pixel_mapuiv_data (const xcb_glx_get_pixel_mapuiv_reply_t *R);
int
xcb_glx_get_pixel_mapuiv_data_length (const xcb_glx_get_pixel_mapuiv_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_pixel_mapuiv_data_end (const xcb_glx_get_pixel_mapuiv_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_pixel_mapuiv_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_pixel_mapuiv_reply_t *
xcb_glx_get_pixel_mapuiv_reply (xcb_connection_t *c,
xcb_glx_get_pixel_mapuiv_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_pixel_mapusv_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_pixel_mapusv_cookie_t
xcb_glx_get_pixel_mapusv (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t map);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_pixel_mapusv_cookie_t
xcb_glx_get_pixel_mapusv_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t map);
uint16_t *
xcb_glx_get_pixel_mapusv_data (const xcb_glx_get_pixel_mapusv_reply_t *R);
int
xcb_glx_get_pixel_mapusv_data_length (const xcb_glx_get_pixel_mapusv_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_pixel_mapusv_data_end (const xcb_glx_get_pixel_mapusv_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_pixel_mapusv_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_pixel_mapusv_reply_t *
xcb_glx_get_pixel_mapusv_reply (xcb_connection_t *c,
xcb_glx_get_pixel_mapusv_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_polygon_stipple_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_polygon_stipple_cookie_t
xcb_glx_get_polygon_stipple (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint8_t lsb_first);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_polygon_stipple_cookie_t
xcb_glx_get_polygon_stipple_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint8_t lsb_first);
uint8_t *
xcb_glx_get_polygon_stipple_data (const xcb_glx_get_polygon_stipple_reply_t *R);
int
xcb_glx_get_polygon_stipple_data_length (const xcb_glx_get_polygon_stipple_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_polygon_stipple_data_end (const xcb_glx_get_polygon_stipple_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_polygon_stipple_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_polygon_stipple_reply_t *
xcb_glx_get_polygon_stipple_reply (xcb_connection_t *c,
xcb_glx_get_polygon_stipple_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_string_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_string_cookie_t
xcb_glx_get_string (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t name);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_string_cookie_t
xcb_glx_get_string_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t name);
char *
xcb_glx_get_string_string (const xcb_glx_get_string_reply_t *R);
int
xcb_glx_get_string_string_length (const xcb_glx_get_string_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_string_string_end (const xcb_glx_get_string_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_string_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_string_reply_t *
xcb_glx_get_string_reply (xcb_connection_t *c,
xcb_glx_get_string_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_tex_envfv_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_tex_envfv_cookie_t
xcb_glx_get_tex_envfv (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t pname);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_tex_envfv_cookie_t
xcb_glx_get_tex_envfv_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t pname);
xcb_glx_float32_t *
xcb_glx_get_tex_envfv_data (const xcb_glx_get_tex_envfv_reply_t *R);
int
xcb_glx_get_tex_envfv_data_length (const xcb_glx_get_tex_envfv_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_tex_envfv_data_end (const xcb_glx_get_tex_envfv_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_tex_envfv_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_tex_envfv_reply_t *
xcb_glx_get_tex_envfv_reply (xcb_connection_t *c,
xcb_glx_get_tex_envfv_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_tex_enviv_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_tex_enviv_cookie_t
xcb_glx_get_tex_enviv (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t pname);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_tex_enviv_cookie_t
xcb_glx_get_tex_enviv_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t pname);
int32_t *
xcb_glx_get_tex_enviv_data (const xcb_glx_get_tex_enviv_reply_t *R);
int
xcb_glx_get_tex_enviv_data_length (const xcb_glx_get_tex_enviv_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_tex_enviv_data_end (const xcb_glx_get_tex_enviv_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_tex_enviv_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_tex_enviv_reply_t *
xcb_glx_get_tex_enviv_reply (xcb_connection_t *c,
xcb_glx_get_tex_enviv_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_tex_gendv_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_tex_gendv_cookie_t
xcb_glx_get_tex_gendv (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t coord,
uint32_t pname);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_tex_gendv_cookie_t
xcb_glx_get_tex_gendv_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t coord,
uint32_t pname);
xcb_glx_float64_t *
xcb_glx_get_tex_gendv_data (const xcb_glx_get_tex_gendv_reply_t *R);
int
xcb_glx_get_tex_gendv_data_length (const xcb_glx_get_tex_gendv_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_tex_gendv_data_end (const xcb_glx_get_tex_gendv_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_tex_gendv_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_tex_gendv_reply_t *
xcb_glx_get_tex_gendv_reply (xcb_connection_t *c,
xcb_glx_get_tex_gendv_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_tex_genfv_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_tex_genfv_cookie_t
xcb_glx_get_tex_genfv (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t coord,
uint32_t pname);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_tex_genfv_cookie_t
xcb_glx_get_tex_genfv_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t coord,
uint32_t pname);
xcb_glx_float32_t *
xcb_glx_get_tex_genfv_data (const xcb_glx_get_tex_genfv_reply_t *R);
int
xcb_glx_get_tex_genfv_data_length (const xcb_glx_get_tex_genfv_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_tex_genfv_data_end (const xcb_glx_get_tex_genfv_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_tex_genfv_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_tex_genfv_reply_t *
xcb_glx_get_tex_genfv_reply (xcb_connection_t *c,
xcb_glx_get_tex_genfv_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_tex_geniv_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_tex_geniv_cookie_t
xcb_glx_get_tex_geniv (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t coord,
uint32_t pname);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_tex_geniv_cookie_t
xcb_glx_get_tex_geniv_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t coord,
uint32_t pname);
int32_t *
xcb_glx_get_tex_geniv_data (const xcb_glx_get_tex_geniv_reply_t *R);
int
xcb_glx_get_tex_geniv_data_length (const xcb_glx_get_tex_geniv_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_tex_geniv_data_end (const xcb_glx_get_tex_geniv_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_tex_geniv_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_tex_geniv_reply_t *
xcb_glx_get_tex_geniv_reply (xcb_connection_t *c,
xcb_glx_get_tex_geniv_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_tex_image_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_tex_image_cookie_t
xcb_glx_get_tex_image (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
int32_t level,
uint32_t format,
uint32_t type,
uint8_t swap_bytes);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_tex_image_cookie_t
xcb_glx_get_tex_image_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
int32_t level,
uint32_t format,
uint32_t type,
uint8_t swap_bytes);
uint8_t *
xcb_glx_get_tex_image_data (const xcb_glx_get_tex_image_reply_t *R);
int
xcb_glx_get_tex_image_data_length (const xcb_glx_get_tex_image_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_tex_image_data_end (const xcb_glx_get_tex_image_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_tex_image_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_tex_image_reply_t *
xcb_glx_get_tex_image_reply (xcb_connection_t *c,
xcb_glx_get_tex_image_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_tex_parameterfv_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_tex_parameterfv_cookie_t
xcb_glx_get_tex_parameterfv (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t pname);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_tex_parameterfv_cookie_t
xcb_glx_get_tex_parameterfv_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t pname);
xcb_glx_float32_t *
xcb_glx_get_tex_parameterfv_data (const xcb_glx_get_tex_parameterfv_reply_t *R);
int
xcb_glx_get_tex_parameterfv_data_length (const xcb_glx_get_tex_parameterfv_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_tex_parameterfv_data_end (const xcb_glx_get_tex_parameterfv_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_tex_parameterfv_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_tex_parameterfv_reply_t *
xcb_glx_get_tex_parameterfv_reply (xcb_connection_t *c,
xcb_glx_get_tex_parameterfv_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_tex_parameteriv_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_tex_parameteriv_cookie_t
xcb_glx_get_tex_parameteriv (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t pname);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_tex_parameteriv_cookie_t
xcb_glx_get_tex_parameteriv_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t pname);
int32_t *
xcb_glx_get_tex_parameteriv_data (const xcb_glx_get_tex_parameteriv_reply_t *R);
int
xcb_glx_get_tex_parameteriv_data_length (const xcb_glx_get_tex_parameteriv_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_tex_parameteriv_data_end (const xcb_glx_get_tex_parameteriv_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_tex_parameteriv_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_tex_parameteriv_reply_t *
xcb_glx_get_tex_parameteriv_reply (xcb_connection_t *c,
xcb_glx_get_tex_parameteriv_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_tex_level_parameterfv_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_tex_level_parameterfv_cookie_t
xcb_glx_get_tex_level_parameterfv (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
int32_t level,
uint32_t pname);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_tex_level_parameterfv_cookie_t
xcb_glx_get_tex_level_parameterfv_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
int32_t level,
uint32_t pname);
xcb_glx_float32_t *
xcb_glx_get_tex_level_parameterfv_data (const xcb_glx_get_tex_level_parameterfv_reply_t *R);
int
xcb_glx_get_tex_level_parameterfv_data_length (const xcb_glx_get_tex_level_parameterfv_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_tex_level_parameterfv_data_end (const xcb_glx_get_tex_level_parameterfv_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_tex_level_parameterfv_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_tex_level_parameterfv_reply_t *
xcb_glx_get_tex_level_parameterfv_reply (xcb_connection_t *c,
xcb_glx_get_tex_level_parameterfv_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_tex_level_parameteriv_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_tex_level_parameteriv_cookie_t
xcb_glx_get_tex_level_parameteriv (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
int32_t level,
uint32_t pname);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_tex_level_parameteriv_cookie_t
xcb_glx_get_tex_level_parameteriv_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
int32_t level,
uint32_t pname);
int32_t *
xcb_glx_get_tex_level_parameteriv_data (const xcb_glx_get_tex_level_parameteriv_reply_t *R);
int
xcb_glx_get_tex_level_parameteriv_data_length (const xcb_glx_get_tex_level_parameteriv_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_tex_level_parameteriv_data_end (const xcb_glx_get_tex_level_parameteriv_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_tex_level_parameteriv_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_tex_level_parameteriv_reply_t *
xcb_glx_get_tex_level_parameteriv_reply (xcb_connection_t *c,
xcb_glx_get_tex_level_parameteriv_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_is_enabled_cookie_t
xcb_glx_is_enabled (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t capability);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_is_enabled_cookie_t
xcb_glx_is_enabled_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t capability);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_is_enabled_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_is_enabled_reply_t *
xcb_glx_is_enabled_reply (xcb_connection_t *c,
xcb_glx_is_enabled_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_is_list_cookie_t
xcb_glx_is_list (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t list);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_is_list_cookie_t
xcb_glx_is_list_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t list);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_is_list_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_is_list_reply_t *
xcb_glx_is_list_reply (xcb_connection_t *c,
xcb_glx_is_list_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_flush_checked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_flush (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag);
int
xcb_glx_are_textures_resident_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_are_textures_resident_cookie_t
xcb_glx_are_textures_resident (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
int32_t n,
const uint32_t *textures);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_are_textures_resident_cookie_t
xcb_glx_are_textures_resident_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
int32_t n,
const uint32_t *textures);
uint8_t *
xcb_glx_are_textures_resident_data (const xcb_glx_are_textures_resident_reply_t *R);
int
xcb_glx_are_textures_resident_data_length (const xcb_glx_are_textures_resident_reply_t *R);
xcb_generic_iterator_t
xcb_glx_are_textures_resident_data_end (const xcb_glx_are_textures_resident_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_are_textures_resident_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_are_textures_resident_reply_t *
xcb_glx_are_textures_resident_reply (xcb_connection_t *c,
xcb_glx_are_textures_resident_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_delete_textures_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_delete_textures_checked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
int32_t n,
const uint32_t *textures);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_delete_textures (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
int32_t n,
const uint32_t *textures);
uint32_t *
xcb_glx_delete_textures_textures (const xcb_glx_delete_textures_request_t *R);
int
xcb_glx_delete_textures_textures_length (const xcb_glx_delete_textures_request_t *R);
xcb_generic_iterator_t
xcb_glx_delete_textures_textures_end (const xcb_glx_delete_textures_request_t *R);
int
xcb_glx_gen_textures_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_gen_textures_cookie_t
xcb_glx_gen_textures (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
int32_t n);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_gen_textures_cookie_t
xcb_glx_gen_textures_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
int32_t n);
uint32_t *
xcb_glx_gen_textures_data (const xcb_glx_gen_textures_reply_t *R);
int
xcb_glx_gen_textures_data_length (const xcb_glx_gen_textures_reply_t *R);
xcb_generic_iterator_t
xcb_glx_gen_textures_data_end (const xcb_glx_gen_textures_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_gen_textures_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_gen_textures_reply_t *
xcb_glx_gen_textures_reply (xcb_connection_t *c,
xcb_glx_gen_textures_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_is_texture_cookie_t
xcb_glx_is_texture (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t texture);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_is_texture_cookie_t
xcb_glx_is_texture_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t texture);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_is_texture_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_is_texture_reply_t *
xcb_glx_is_texture_reply (xcb_connection_t *c,
xcb_glx_is_texture_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_color_table_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_color_table_cookie_t
xcb_glx_get_color_table (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t format,
uint32_t type,
uint8_t swap_bytes);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_color_table_cookie_t
xcb_glx_get_color_table_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t format,
uint32_t type,
uint8_t swap_bytes);
uint8_t *
xcb_glx_get_color_table_data (const xcb_glx_get_color_table_reply_t *R);
int
xcb_glx_get_color_table_data_length (const xcb_glx_get_color_table_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_color_table_data_end (const xcb_glx_get_color_table_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_color_table_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_color_table_reply_t *
xcb_glx_get_color_table_reply (xcb_connection_t *c,
xcb_glx_get_color_table_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_color_table_parameterfv_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_color_table_parameterfv_cookie_t
xcb_glx_get_color_table_parameterfv (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t pname);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_color_table_parameterfv_cookie_t
xcb_glx_get_color_table_parameterfv_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t pname);
xcb_glx_float32_t *
xcb_glx_get_color_table_parameterfv_data (const xcb_glx_get_color_table_parameterfv_reply_t *R);
int
xcb_glx_get_color_table_parameterfv_data_length (const xcb_glx_get_color_table_parameterfv_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_color_table_parameterfv_data_end (const xcb_glx_get_color_table_parameterfv_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_color_table_parameterfv_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_color_table_parameterfv_reply_t *
xcb_glx_get_color_table_parameterfv_reply (xcb_connection_t *c,
xcb_glx_get_color_table_parameterfv_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_color_table_parameteriv_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_color_table_parameteriv_cookie_t
xcb_glx_get_color_table_parameteriv (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t pname);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_color_table_parameteriv_cookie_t
xcb_glx_get_color_table_parameteriv_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t pname);
int32_t *
xcb_glx_get_color_table_parameteriv_data (const xcb_glx_get_color_table_parameteriv_reply_t *R);
int
xcb_glx_get_color_table_parameteriv_data_length (const xcb_glx_get_color_table_parameteriv_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_color_table_parameteriv_data_end (const xcb_glx_get_color_table_parameteriv_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_color_table_parameteriv_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_color_table_parameteriv_reply_t *
xcb_glx_get_color_table_parameteriv_reply (xcb_connection_t *c,
xcb_glx_get_color_table_parameteriv_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_convolution_filter_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_convolution_filter_cookie_t
xcb_glx_get_convolution_filter (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t format,
uint32_t type,
uint8_t swap_bytes);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_convolution_filter_cookie_t
xcb_glx_get_convolution_filter_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t format,
uint32_t type,
uint8_t swap_bytes);
uint8_t *
xcb_glx_get_convolution_filter_data (const xcb_glx_get_convolution_filter_reply_t *R);
int
xcb_glx_get_convolution_filter_data_length (const xcb_glx_get_convolution_filter_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_convolution_filter_data_end (const xcb_glx_get_convolution_filter_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_convolution_filter_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_convolution_filter_reply_t *
xcb_glx_get_convolution_filter_reply (xcb_connection_t *c,
xcb_glx_get_convolution_filter_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_convolution_parameterfv_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_convolution_parameterfv_cookie_t
xcb_glx_get_convolution_parameterfv (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t pname);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_convolution_parameterfv_cookie_t
xcb_glx_get_convolution_parameterfv_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t pname);
xcb_glx_float32_t *
xcb_glx_get_convolution_parameterfv_data (const xcb_glx_get_convolution_parameterfv_reply_t *R);
int
xcb_glx_get_convolution_parameterfv_data_length (const xcb_glx_get_convolution_parameterfv_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_convolution_parameterfv_data_end (const xcb_glx_get_convolution_parameterfv_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_convolution_parameterfv_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_convolution_parameterfv_reply_t *
xcb_glx_get_convolution_parameterfv_reply (xcb_connection_t *c,
xcb_glx_get_convolution_parameterfv_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_convolution_parameteriv_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_convolution_parameteriv_cookie_t
xcb_glx_get_convolution_parameteriv (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t pname);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_convolution_parameteriv_cookie_t
xcb_glx_get_convolution_parameteriv_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t pname);
int32_t *
xcb_glx_get_convolution_parameteriv_data (const xcb_glx_get_convolution_parameteriv_reply_t *R);
int
xcb_glx_get_convolution_parameteriv_data_length (const xcb_glx_get_convolution_parameteriv_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_convolution_parameteriv_data_end (const xcb_glx_get_convolution_parameteriv_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_convolution_parameteriv_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_convolution_parameteriv_reply_t *
xcb_glx_get_convolution_parameteriv_reply (xcb_connection_t *c,
xcb_glx_get_convolution_parameteriv_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_separable_filter_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_separable_filter_cookie_t
xcb_glx_get_separable_filter (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t format,
uint32_t type,
uint8_t swap_bytes);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_separable_filter_cookie_t
xcb_glx_get_separable_filter_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t format,
uint32_t type,
uint8_t swap_bytes);
uint8_t *
xcb_glx_get_separable_filter_rows_and_cols (const xcb_glx_get_separable_filter_reply_t *R);
int
xcb_glx_get_separable_filter_rows_and_cols_length (const xcb_glx_get_separable_filter_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_separable_filter_rows_and_cols_end (const xcb_glx_get_separable_filter_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_separable_filter_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_separable_filter_reply_t *
xcb_glx_get_separable_filter_reply (xcb_connection_t *c,
xcb_glx_get_separable_filter_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_histogram_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_histogram_cookie_t
xcb_glx_get_histogram (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t format,
uint32_t type,
uint8_t swap_bytes,
uint8_t reset);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_histogram_cookie_t
xcb_glx_get_histogram_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t format,
uint32_t type,
uint8_t swap_bytes,
uint8_t reset);
uint8_t *
xcb_glx_get_histogram_data (const xcb_glx_get_histogram_reply_t *R);
int
xcb_glx_get_histogram_data_length (const xcb_glx_get_histogram_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_histogram_data_end (const xcb_glx_get_histogram_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_histogram_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_histogram_reply_t *
xcb_glx_get_histogram_reply (xcb_connection_t *c,
xcb_glx_get_histogram_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_histogram_parameterfv_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_histogram_parameterfv_cookie_t
xcb_glx_get_histogram_parameterfv (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t pname);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_histogram_parameterfv_cookie_t
xcb_glx_get_histogram_parameterfv_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t pname);
xcb_glx_float32_t *
xcb_glx_get_histogram_parameterfv_data (const xcb_glx_get_histogram_parameterfv_reply_t *R);
int
xcb_glx_get_histogram_parameterfv_data_length (const xcb_glx_get_histogram_parameterfv_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_histogram_parameterfv_data_end (const xcb_glx_get_histogram_parameterfv_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_histogram_parameterfv_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_histogram_parameterfv_reply_t *
xcb_glx_get_histogram_parameterfv_reply (xcb_connection_t *c,
xcb_glx_get_histogram_parameterfv_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_histogram_parameteriv_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_histogram_parameteriv_cookie_t
xcb_glx_get_histogram_parameteriv (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t pname);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_histogram_parameteriv_cookie_t
xcb_glx_get_histogram_parameteriv_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t pname);
int32_t *
xcb_glx_get_histogram_parameteriv_data (const xcb_glx_get_histogram_parameteriv_reply_t *R);
int
xcb_glx_get_histogram_parameteriv_data_length (const xcb_glx_get_histogram_parameteriv_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_histogram_parameteriv_data_end (const xcb_glx_get_histogram_parameteriv_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_histogram_parameteriv_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_histogram_parameteriv_reply_t *
xcb_glx_get_histogram_parameteriv_reply (xcb_connection_t *c,
xcb_glx_get_histogram_parameteriv_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_minmax_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_minmax_cookie_t
xcb_glx_get_minmax (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t format,
uint32_t type,
uint8_t swap_bytes,
uint8_t reset);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_minmax_cookie_t
xcb_glx_get_minmax_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t format,
uint32_t type,
uint8_t swap_bytes,
uint8_t reset);
uint8_t *
xcb_glx_get_minmax_data (const xcb_glx_get_minmax_reply_t *R);
int
xcb_glx_get_minmax_data_length (const xcb_glx_get_minmax_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_minmax_data_end (const xcb_glx_get_minmax_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_minmax_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_minmax_reply_t *
xcb_glx_get_minmax_reply (xcb_connection_t *c,
xcb_glx_get_minmax_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_minmax_parameterfv_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_minmax_parameterfv_cookie_t
xcb_glx_get_minmax_parameterfv (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t pname);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_minmax_parameterfv_cookie_t
xcb_glx_get_minmax_parameterfv_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t pname);
xcb_glx_float32_t *
xcb_glx_get_minmax_parameterfv_data (const xcb_glx_get_minmax_parameterfv_reply_t *R);
int
xcb_glx_get_minmax_parameterfv_data_length (const xcb_glx_get_minmax_parameterfv_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_minmax_parameterfv_data_end (const xcb_glx_get_minmax_parameterfv_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_minmax_parameterfv_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_minmax_parameterfv_reply_t *
xcb_glx_get_minmax_parameterfv_reply (xcb_connection_t *c,
xcb_glx_get_minmax_parameterfv_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_minmax_parameteriv_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_minmax_parameteriv_cookie_t
xcb_glx_get_minmax_parameteriv (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t pname);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_minmax_parameteriv_cookie_t
xcb_glx_get_minmax_parameteriv_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t pname);
int32_t *
xcb_glx_get_minmax_parameteriv_data (const xcb_glx_get_minmax_parameteriv_reply_t *R);
int
xcb_glx_get_minmax_parameteriv_data_length (const xcb_glx_get_minmax_parameteriv_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_minmax_parameteriv_data_end (const xcb_glx_get_minmax_parameteriv_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_minmax_parameteriv_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_minmax_parameteriv_reply_t *
xcb_glx_get_minmax_parameteriv_reply (xcb_connection_t *c,
xcb_glx_get_minmax_parameteriv_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_compressed_tex_image_arb_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_compressed_tex_image_arb_cookie_t
xcb_glx_get_compressed_tex_image_arb (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
int32_t level);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_compressed_tex_image_arb_cookie_t
xcb_glx_get_compressed_tex_image_arb_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
int32_t level);
uint8_t *
xcb_glx_get_compressed_tex_image_arb_data (const xcb_glx_get_compressed_tex_image_arb_reply_t *R);
int
xcb_glx_get_compressed_tex_image_arb_data_length (const xcb_glx_get_compressed_tex_image_arb_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_compressed_tex_image_arb_data_end (const xcb_glx_get_compressed_tex_image_arb_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_compressed_tex_image_arb_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_compressed_tex_image_arb_reply_t *
xcb_glx_get_compressed_tex_image_arb_reply (xcb_connection_t *c,
xcb_glx_get_compressed_tex_image_arb_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_delete_queries_arb_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_glx_delete_queries_arb_checked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
int32_t n,
const uint32_t *ids);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_glx_delete_queries_arb (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
int32_t n,
const uint32_t *ids);
uint32_t *
xcb_glx_delete_queries_arb_ids (const xcb_glx_delete_queries_arb_request_t *R);
int
xcb_glx_delete_queries_arb_ids_length (const xcb_glx_delete_queries_arb_request_t *R);
xcb_generic_iterator_t
xcb_glx_delete_queries_arb_ids_end (const xcb_glx_delete_queries_arb_request_t *R);
int
xcb_glx_gen_queries_arb_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_gen_queries_arb_cookie_t
xcb_glx_gen_queries_arb (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
int32_t n);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_gen_queries_arb_cookie_t
xcb_glx_gen_queries_arb_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
int32_t n);
uint32_t *
xcb_glx_gen_queries_arb_data (const xcb_glx_gen_queries_arb_reply_t *R);
int
xcb_glx_gen_queries_arb_data_length (const xcb_glx_gen_queries_arb_reply_t *R);
xcb_generic_iterator_t
xcb_glx_gen_queries_arb_data_end (const xcb_glx_gen_queries_arb_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_gen_queries_arb_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_gen_queries_arb_reply_t *
xcb_glx_gen_queries_arb_reply (xcb_connection_t *c,
xcb_glx_gen_queries_arb_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_is_query_arb_cookie_t
xcb_glx_is_query_arb (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t id);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_is_query_arb_cookie_t
xcb_glx_is_query_arb_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t id);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_is_query_arb_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_is_query_arb_reply_t *
xcb_glx_is_query_arb_reply (xcb_connection_t *c,
xcb_glx_is_query_arb_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_queryiv_arb_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_queryiv_arb_cookie_t
xcb_glx_get_queryiv_arb (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t pname);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_queryiv_arb_cookie_t
xcb_glx_get_queryiv_arb_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t target,
uint32_t pname);
int32_t *
xcb_glx_get_queryiv_arb_data (const xcb_glx_get_queryiv_arb_reply_t *R);
int
xcb_glx_get_queryiv_arb_data_length (const xcb_glx_get_queryiv_arb_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_queryiv_arb_data_end (const xcb_glx_get_queryiv_arb_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_queryiv_arb_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_queryiv_arb_reply_t *
xcb_glx_get_queryiv_arb_reply (xcb_connection_t *c,
xcb_glx_get_queryiv_arb_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_query_objectiv_arb_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_query_objectiv_arb_cookie_t
xcb_glx_get_query_objectiv_arb (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t id,
uint32_t pname);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_query_objectiv_arb_cookie_t
xcb_glx_get_query_objectiv_arb_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t id,
uint32_t pname);
int32_t *
xcb_glx_get_query_objectiv_arb_data (const xcb_glx_get_query_objectiv_arb_reply_t *R);
int
xcb_glx_get_query_objectiv_arb_data_length (const xcb_glx_get_query_objectiv_arb_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_query_objectiv_arb_data_end (const xcb_glx_get_query_objectiv_arb_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_query_objectiv_arb_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_query_objectiv_arb_reply_t *
xcb_glx_get_query_objectiv_arb_reply (xcb_connection_t *c,
xcb_glx_get_query_objectiv_arb_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_glx_get_query_objectuiv_arb_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_glx_get_query_objectuiv_arb_cookie_t
xcb_glx_get_query_objectuiv_arb (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t id,
uint32_t pname);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_glx_get_query_objectuiv_arb_cookie_t
xcb_glx_get_query_objectuiv_arb_unchecked (xcb_connection_t *c,
xcb_glx_context_tag_t context_tag,
uint32_t id,
uint32_t pname);
uint32_t *
xcb_glx_get_query_objectuiv_arb_data (const xcb_glx_get_query_objectuiv_arb_reply_t *R);
int
xcb_glx_get_query_objectuiv_arb_data_length (const xcb_glx_get_query_objectuiv_arb_reply_t *R);
xcb_generic_iterator_t
xcb_glx_get_query_objectuiv_arb_data_end (const xcb_glx_get_query_objectuiv_arb_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_glx_get_query_objectuiv_arb_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_glx_get_query_objectuiv_arb_reply_t *
xcb_glx_get_query_objectuiv_arb_reply (xcb_connection_t *c,
xcb_glx_get_query_objectuiv_arb_cookie_t cookie /**< */,
xcb_generic_error_t **e);
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/
xcb/xcbext.h 0000644 00000033246 15201526705 0007001 0 ustar 00 /*
* Copyright (C) 2001-2004 Bart Massey and Jamey Sharp.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the names of the authors or their
* institutions shall not be used in advertising or otherwise to promote the
* sale, use or other dealings in this Software without prior written
* authorization from the authors.
*/
#ifndef __XCBEXT_H
#define __XCBEXT_H
#include "xcb.h"
#ifdef __cplusplus
extern "C" {
#endif
/* xcb_ext.c */
struct xcb_extension_t {
const char *name;
int global_id;
};
/* xcb_out.c */
typedef struct {
size_t count;
xcb_extension_t *ext;
uint8_t opcode;
uint8_t isvoid;
} xcb_protocol_request_t;
enum xcb_send_request_flags_t {
XCB_REQUEST_CHECKED = 1 << 0,
XCB_REQUEST_RAW = 1 << 1,
XCB_REQUEST_DISCARD_REPLY = 1 << 2,
XCB_REQUEST_REPLY_FDS = 1 << 3
};
/**
* @brief Send a request to the server.
* @param c The connection to the X server.
* @param flags A combination of flags from the xcb_send_request_flags_t enumeration.
* @param vector Data to send; must have two iovecs before start for internal use.
* @param request Information about the request to be sent.
* @return The request's sequence number on success, 0 otherwise.
*
* This function sends a new request to the X server. The data of the request is
* given as an array of @c iovecs in the @p vector argument. The length of that
* array and the necessary management information are given in the @p request
* argument.
*
* When this function returns, the request might or might not be sent already.
* Use xcb_flush() to make sure that it really was sent.
*
* Please note that this function is not the preferred way for sending requests.
* It's better to use the generated wrapper functions.
*
* Please note that xcb might use index -1 and -2 of the @p vector array internally,
* so they must be valid!
*/
unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *request);
/**
* @brief Send a request to the server.
* @param c The connection to the X server.
* @param flags A combination of flags from the xcb_send_request_flags_t enumeration.
* @param vector Data to send; must have two iovecs before start for internal use.
* @param request Information about the request to be sent.
* @param num_fds Number of additional file descriptors to send to the server
* @param fds Additional file descriptors that should be send to the server.
* @return The request's sequence number on success, 0 otherwise.
*
* This function sends a new request to the X server. The data of the request is
* given as an array of @c iovecs in the @p vector argument. The length of that
* array and the necessary management information are given in the @p request
* argument.
*
* If @p num_fds is non-zero, @p fds points to an array of file descriptors that
* will be sent to the X server along with this request. After this function
* returns, all file descriptors sent are owned by xcb and will be closed
* eventually.
*
* When this function returns, the request might or might not be sent already.
* Use xcb_flush() to make sure that it really was sent.
*
* Please note that this function is not the preferred way for sending requests.
*
* Please note that xcb might use index -1 and -2 of the @p vector array internally,
* so they must be valid!
*/
unsigned int xcb_send_request_with_fds(xcb_connection_t *c, int flags, struct iovec *vector,
const xcb_protocol_request_t *request, unsigned int num_fds, int *fds);
/**
* @brief Send a request to the server, with 64-bit sequence number returned.
* @param c The connection to the X server.
* @param flags A combination of flags from the xcb_send_request_flags_t enumeration.
* @param vector Data to send; must have two iovecs before start for internal use.
* @param request Information about the request to be sent.
* @return The request's sequence number on success, 0 otherwise.
*
* This function sends a new request to the X server. The data of the request is
* given as an array of @c iovecs in the @p vector argument. The length of that
* array and the necessary management information are given in the @p request
* argument.
*
* When this function returns, the request might or might not be sent already.
* Use xcb_flush() to make sure that it really was sent.
*
* Please note that this function is not the preferred way for sending requests.
* It's better to use the generated wrapper functions.
*
* Please note that xcb might use index -1 and -2 of the @p vector array internally,
* so they must be valid!
*/
uint64_t xcb_send_request64(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *request);
/**
* @brief Send a request to the server, with 64-bit sequence number returned.
* @param c The connection to the X server.
* @param flags A combination of flags from the xcb_send_request_flags_t enumeration.
* @param vector Data to send; must have two iovecs before start for internal use.
* @param request Information about the request to be sent.
* @param num_fds Number of additional file descriptors to send to the server
* @param fds Additional file descriptors that should be send to the server.
* @return The request's sequence number on success, 0 otherwise.
*
* This function sends a new request to the X server. The data of the request is
* given as an array of @c iovecs in the @p vector argument. The length of that
* array and the necessary management information are given in the @p request
* argument.
*
* If @p num_fds is non-zero, @p fds points to an array of file descriptors that
* will be sent to the X server along with this request. After this function
* returns, all file descriptors sent are owned by xcb and will be closed
* eventually.
*
* When this function returns, the request might or might not be sent already.
* Use xcb_flush() to make sure that it really was sent.
*
* Please note that this function is not the preferred way for sending requests.
* It's better to use the generated wrapper functions.
*
* Please note that xcb might use index -1 and -2 of the @p vector array internally,
* so they must be valid!
*/
uint64_t xcb_send_request_with_fds64(xcb_connection_t *c, int flags, struct iovec *vector,
const xcb_protocol_request_t *request, unsigned int num_fds, int *fds);
/**
* @brief Send a file descriptor to the server in the next call to xcb_send_request.
* @param c The connection to the X server.
* @param fd The file descriptor to send.
*
* After this function returns, the file descriptor given is owned by xcb and
* will be closed eventually.
*
* @deprecated This function cannot be used in a thread-safe way. Two threads
* that run xcb_send_fd(); xcb_send_request(); could mix up their file
* descriptors. Instead, xcb_send_request_with_fds() should be used.
*/
void xcb_send_fd(xcb_connection_t *c, int fd);
/**
* @brief Take over the write side of the socket
* @param c The connection to the X server.
* @param return_socket Callback function that will be called when xcb wants
* to use the socket again.
* @param closure Argument to the callback function.
* @param flags A combination of flags from the xcb_send_request_flags_t enumeration.
* @param sent Location to the sequence number of the last sequence request.
* Must not be NULL.
* @return 1 on success, else 0.
*
* xcb_take_socket allows external code to ask XCB for permission to
* take over the write side of the socket and send raw data with
* xcb_writev. xcb_take_socket provides the sequence number of the last
* request XCB sent. The caller of xcb_take_socket must supply a
* callback which XCB can call when it wants the write side of the
* socket back to make a request. This callback synchronizes with the
* external socket owner and flushes any output queues if appropriate.
* If you are sending requests which won't cause a reply, please note the
* comment for xcb_writev which explains some sequence number wrap issues.
*
* All replies that are generated while the socket is owned externally have
* @p flags applied to them. For example, use XCB_REQUEST_CHECK if you don't
* want errors to go to xcb's normal error handling, but instead having to be
* picked up via xcb_wait_for_reply(), xcb_poll_for_reply() or
* xcb_request_check().
*/
int xcb_take_socket(xcb_connection_t *c, void (*return_socket)(void *closure), void *closure, int flags, uint64_t *sent);
/**
* @brief Send raw data to the X server.
* @param c The connection to the X server.
* @param vector Array of data to be sent.
* @param count Number of entries in @p vector.
* @param requests Number of requests that are being sent.
* @return 1 on success, else 0.
*
* You must own the write-side of the socket (you've called
* xcb_take_socket, and haven't returned from return_socket yet) to call
* xcb_writev. Also, the iovec must have at least 1 byte of data in it.
* You have to make sure that xcb can detect sequence number wraps correctly.
* This means that the first request you send after xcb_take_socket must cause a
* reply (e.g. just insert a GetInputFocus request). After every (1 << 16) - 1
* requests without a reply, you have to insert a request which will cause a
* reply. You can again use GetInputFocus for this. You do not have to wait for
* any of the GetInputFocus replies, but can instead handle them via
* xcb_discard_reply().
*/
int xcb_writev(xcb_connection_t *c, struct iovec *vector, int count, uint64_t requests);
/* xcb_in.c */
/**
* @brief Wait for the reply of a given request.
* @param c The connection to the X server.
* @param request Sequence number of the request as returned by xcb_send_request().
* @param e Location to store errors in, or NULL. Ignored for unchecked requests.
*
* Returns the reply to the given request or returns null in the event of
* errors. Blocks until the reply or error for the request arrives, or an I/O
* error occurs.
*/
void *xcb_wait_for_reply(xcb_connection_t *c, unsigned int request, xcb_generic_error_t **e);
/**
* @brief Wait for the reply of a given request, with 64-bit sequence number
* @param c The connection to the X server.
* @param request 64-bit sequence number of the request as returned by xcb_send_request64().
* @param e Location to store errors in, or NULL. Ignored for unchecked requests.
*
* Returns the reply to the given request or returns null in the event of
* errors. Blocks until the reply or error for the request arrives, or an I/O
* error occurs.
*
* Unlike its xcb_wait_for_reply() counterpart, the given sequence number is not
* automatically "widened" to 64-bit.
*/
void *xcb_wait_for_reply64(xcb_connection_t *c, uint64_t request, xcb_generic_error_t **e);
/**
* @brief Poll for the reply of a given request.
* @param c The connection to the X server.
* @param request Sequence number of the request as returned by xcb_send_request().
* @param reply Location to store the reply in, must not be NULL.
* @param error Location to store errors in, or NULL. Ignored for unchecked requests.
* @return 1 when the reply to the request was returned, else 0.
*
* Checks if the reply to the given request already received. Does not block.
*/
int xcb_poll_for_reply(xcb_connection_t *c, unsigned int request, void **reply, xcb_generic_error_t **error);
/**
* @brief Poll for the reply of a given request, with 64-bit sequence number.
* @param c The connection to the X server.
* @param request 64-bit sequence number of the request as returned by xcb_send_request().
* @param reply Location to store the reply in, must not be NULL.
* @param error Location to store errors in, or NULL. Ignored for unchecked requests.
* @return 1 when the reply to the request was returned, else 0.
*
* Checks if the reply to the given request already received. Does not block.
*
* Unlike its xcb_poll_for_reply() counterpart, the given sequence number is not
* automatically "widened" to 64-bit.
*/
int xcb_poll_for_reply64(xcb_connection_t *c, uint64_t request, void **reply, xcb_generic_error_t **error);
/**
* @brief Don't use this, only needed by the generated code.
* @param c The connection to the X server.
* @param reply A reply that was received from the server
* @param replylen The size of the reply.
* @return Pointer to the location where received file descriptors are stored.
*/
int *xcb_get_reply_fds(xcb_connection_t *c, void *reply, size_t replylen);
/* xcb_util.c */
/**
* @param mask The mask to check
* @return The number of set bits in the mask
*/
int xcb_popcount(uint32_t mask);
/**
* @param list The base of an array
* @param len The length of the array
* @return The sum of all entries in the array.
*/
int xcb_sumof(uint8_t *list, int len);
#ifdef __cplusplus
}
#endif
#endif
xcb/sync.h 0000644 00000125354 15201526705 0006462 0 ustar 00 /*
* This file generated automatically from sync.xml by c_client.py.
* Edit at your peril.
*/
/**
* @defgroup XCB_Sync_API XCB Sync API
* @brief Sync XCB Protocol Implementation.
* @{
**/
#ifndef __SYNC_H
#define __SYNC_H
#include "xcb.h"
#include "xproto.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XCB_SYNC_MAJOR_VERSION 3
#define XCB_SYNC_MINOR_VERSION 1
extern xcb_extension_t xcb_sync_id;
typedef uint32_t xcb_sync_alarm_t;
/**
* @brief xcb_sync_alarm_iterator_t
**/
typedef struct xcb_sync_alarm_iterator_t {
xcb_sync_alarm_t *data;
int rem;
int index;
} xcb_sync_alarm_iterator_t;
typedef enum xcb_sync_alarmstate_t {
XCB_SYNC_ALARMSTATE_ACTIVE = 0,
XCB_SYNC_ALARMSTATE_INACTIVE = 1,
XCB_SYNC_ALARMSTATE_DESTROYED = 2
} xcb_sync_alarmstate_t;
typedef uint32_t xcb_sync_counter_t;
/**
* @brief xcb_sync_counter_iterator_t
**/
typedef struct xcb_sync_counter_iterator_t {
xcb_sync_counter_t *data;
int rem;
int index;
} xcb_sync_counter_iterator_t;
typedef uint32_t xcb_sync_fence_t;
/**
* @brief xcb_sync_fence_iterator_t
**/
typedef struct xcb_sync_fence_iterator_t {
xcb_sync_fence_t *data;
int rem;
int index;
} xcb_sync_fence_iterator_t;
typedef enum xcb_sync_testtype_t {
XCB_SYNC_TESTTYPE_POSITIVE_TRANSITION = 0,
XCB_SYNC_TESTTYPE_NEGATIVE_TRANSITION = 1,
XCB_SYNC_TESTTYPE_POSITIVE_COMPARISON = 2,
XCB_SYNC_TESTTYPE_NEGATIVE_COMPARISON = 3
} xcb_sync_testtype_t;
typedef enum xcb_sync_valuetype_t {
XCB_SYNC_VALUETYPE_ABSOLUTE = 0,
XCB_SYNC_VALUETYPE_RELATIVE = 1
} xcb_sync_valuetype_t;
typedef enum xcb_sync_ca_t {
XCB_SYNC_CA_COUNTER = 1,
XCB_SYNC_CA_VALUE_TYPE = 2,
XCB_SYNC_CA_VALUE = 4,
XCB_SYNC_CA_TEST_TYPE = 8,
XCB_SYNC_CA_DELTA = 16,
XCB_SYNC_CA_EVENTS = 32
} xcb_sync_ca_t;
/**
* @brief xcb_sync_int64_t
**/
typedef struct xcb_sync_int64_t {
int32_t hi;
uint32_t lo;
} xcb_sync_int64_t;
/**
* @brief xcb_sync_int64_iterator_t
**/
typedef struct xcb_sync_int64_iterator_t {
xcb_sync_int64_t *data;
int rem;
int index;
} xcb_sync_int64_iterator_t;
/**
* @brief xcb_sync_systemcounter_t
**/
typedef struct xcb_sync_systemcounter_t {
xcb_sync_counter_t counter;
xcb_sync_int64_t resolution;
uint16_t name_len;
} xcb_sync_systemcounter_t;
/**
* @brief xcb_sync_systemcounter_iterator_t
**/
typedef struct xcb_sync_systemcounter_iterator_t {
xcb_sync_systemcounter_t *data;
int rem;
int index;
} xcb_sync_systemcounter_iterator_t;
/**
* @brief xcb_sync_trigger_t
**/
typedef struct xcb_sync_trigger_t {
xcb_sync_counter_t counter;
uint32_t wait_type;
xcb_sync_int64_t wait_value;
uint32_t test_type;
} xcb_sync_trigger_t;
/**
* @brief xcb_sync_trigger_iterator_t
**/
typedef struct xcb_sync_trigger_iterator_t {
xcb_sync_trigger_t *data;
int rem;
int index;
} xcb_sync_trigger_iterator_t;
/**
* @brief xcb_sync_waitcondition_t
**/
typedef struct xcb_sync_waitcondition_t {
xcb_sync_trigger_t trigger;
xcb_sync_int64_t event_threshold;
} xcb_sync_waitcondition_t;
/**
* @brief xcb_sync_waitcondition_iterator_t
**/
typedef struct xcb_sync_waitcondition_iterator_t {
xcb_sync_waitcondition_t *data;
int rem;
int index;
} xcb_sync_waitcondition_iterator_t;
/** Opcode for xcb_sync_counter. */
#define XCB_SYNC_COUNTER 0
/**
* @brief xcb_sync_counter_error_t
**/
typedef struct xcb_sync_counter_error_t {
uint8_t response_type;
uint8_t error_code;
uint16_t sequence;
uint32_t bad_counter;
uint16_t minor_opcode;
uint8_t major_opcode;
} xcb_sync_counter_error_t;
/** Opcode for xcb_sync_alarm. */
#define XCB_SYNC_ALARM 1
/**
* @brief xcb_sync_alarm_error_t
**/
typedef struct xcb_sync_alarm_error_t {
uint8_t response_type;
uint8_t error_code;
uint16_t sequence;
uint32_t bad_alarm;
uint16_t minor_opcode;
uint8_t major_opcode;
} xcb_sync_alarm_error_t;
/**
* @brief xcb_sync_initialize_cookie_t
**/
typedef struct xcb_sync_initialize_cookie_t {
unsigned int sequence;
} xcb_sync_initialize_cookie_t;
/** Opcode for xcb_sync_initialize. */
#define XCB_SYNC_INITIALIZE 0
/**
* @brief xcb_sync_initialize_request_t
**/
typedef struct xcb_sync_initialize_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t desired_major_version;
uint8_t desired_minor_version;
} xcb_sync_initialize_request_t;
/**
* @brief xcb_sync_initialize_reply_t
**/
typedef struct xcb_sync_initialize_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t major_version;
uint8_t minor_version;
uint8_t pad1[22];
} xcb_sync_initialize_reply_t;
/**
* @brief xcb_sync_list_system_counters_cookie_t
**/
typedef struct xcb_sync_list_system_counters_cookie_t {
unsigned int sequence;
} xcb_sync_list_system_counters_cookie_t;
/** Opcode for xcb_sync_list_system_counters. */
#define XCB_SYNC_LIST_SYSTEM_COUNTERS 1
/**
* @brief xcb_sync_list_system_counters_request_t
**/
typedef struct xcb_sync_list_system_counters_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_sync_list_system_counters_request_t;
/**
* @brief xcb_sync_list_system_counters_reply_t
**/
typedef struct xcb_sync_list_system_counters_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t counters_len;
uint8_t pad1[20];
} xcb_sync_list_system_counters_reply_t;
/** Opcode for xcb_sync_create_counter. */
#define XCB_SYNC_CREATE_COUNTER 2
/**
* @brief xcb_sync_create_counter_request_t
**/
typedef struct xcb_sync_create_counter_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_sync_counter_t id;
xcb_sync_int64_t initial_value;
} xcb_sync_create_counter_request_t;
/** Opcode for xcb_sync_destroy_counter. */
#define XCB_SYNC_DESTROY_COUNTER 6
/**
* @brief xcb_sync_destroy_counter_request_t
**/
typedef struct xcb_sync_destroy_counter_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_sync_counter_t counter;
} xcb_sync_destroy_counter_request_t;
/**
* @brief xcb_sync_query_counter_cookie_t
**/
typedef struct xcb_sync_query_counter_cookie_t {
unsigned int sequence;
} xcb_sync_query_counter_cookie_t;
/** Opcode for xcb_sync_query_counter. */
#define XCB_SYNC_QUERY_COUNTER 5
/**
* @brief xcb_sync_query_counter_request_t
**/
typedef struct xcb_sync_query_counter_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_sync_counter_t counter;
} xcb_sync_query_counter_request_t;
/**
* @brief xcb_sync_query_counter_reply_t
**/
typedef struct xcb_sync_query_counter_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
xcb_sync_int64_t counter_value;
} xcb_sync_query_counter_reply_t;
/** Opcode for xcb_sync_await. */
#define XCB_SYNC_AWAIT 7
/**
* @brief xcb_sync_await_request_t
**/
typedef struct xcb_sync_await_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_sync_await_request_t;
/** Opcode for xcb_sync_change_counter. */
#define XCB_SYNC_CHANGE_COUNTER 4
/**
* @brief xcb_sync_change_counter_request_t
**/
typedef struct xcb_sync_change_counter_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_sync_counter_t counter;
xcb_sync_int64_t amount;
} xcb_sync_change_counter_request_t;
/** Opcode for xcb_sync_set_counter. */
#define XCB_SYNC_SET_COUNTER 3
/**
* @brief xcb_sync_set_counter_request_t
**/
typedef struct xcb_sync_set_counter_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_sync_counter_t counter;
xcb_sync_int64_t value;
} xcb_sync_set_counter_request_t;
/**
* @brief xcb_sync_create_alarm_value_list_t
**/
typedef struct xcb_sync_create_alarm_value_list_t {
xcb_sync_counter_t counter;
uint32_t valueType;
xcb_sync_int64_t value;
uint32_t testType;
xcb_sync_int64_t delta;
uint32_t events;
} xcb_sync_create_alarm_value_list_t;
/** Opcode for xcb_sync_create_alarm. */
#define XCB_SYNC_CREATE_ALARM 8
/**
* @brief xcb_sync_create_alarm_request_t
**/
typedef struct xcb_sync_create_alarm_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_sync_alarm_t id;
uint32_t value_mask;
} xcb_sync_create_alarm_request_t;
/**
* @brief xcb_sync_change_alarm_value_list_t
**/
typedef struct xcb_sync_change_alarm_value_list_t {
xcb_sync_counter_t counter;
uint32_t valueType;
xcb_sync_int64_t value;
uint32_t testType;
xcb_sync_int64_t delta;
uint32_t events;
} xcb_sync_change_alarm_value_list_t;
/** Opcode for xcb_sync_change_alarm. */
#define XCB_SYNC_CHANGE_ALARM 9
/**
* @brief xcb_sync_change_alarm_request_t
**/
typedef struct xcb_sync_change_alarm_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_sync_alarm_t id;
uint32_t value_mask;
} xcb_sync_change_alarm_request_t;
/** Opcode for xcb_sync_destroy_alarm. */
#define XCB_SYNC_DESTROY_ALARM 11
/**
* @brief xcb_sync_destroy_alarm_request_t
**/
typedef struct xcb_sync_destroy_alarm_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_sync_alarm_t alarm;
} xcb_sync_destroy_alarm_request_t;
/**
* @brief xcb_sync_query_alarm_cookie_t
**/
typedef struct xcb_sync_query_alarm_cookie_t {
unsigned int sequence;
} xcb_sync_query_alarm_cookie_t;
/** Opcode for xcb_sync_query_alarm. */
#define XCB_SYNC_QUERY_ALARM 10
/**
* @brief xcb_sync_query_alarm_request_t
**/
typedef struct xcb_sync_query_alarm_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_sync_alarm_t alarm;
} xcb_sync_query_alarm_request_t;
/**
* @brief xcb_sync_query_alarm_reply_t
**/
typedef struct xcb_sync_query_alarm_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
xcb_sync_trigger_t trigger;
xcb_sync_int64_t delta;
uint8_t events;
uint8_t state;
uint8_t pad1[2];
} xcb_sync_query_alarm_reply_t;
/** Opcode for xcb_sync_set_priority. */
#define XCB_SYNC_SET_PRIORITY 12
/**
* @brief xcb_sync_set_priority_request_t
**/
typedef struct xcb_sync_set_priority_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t id;
int32_t priority;
} xcb_sync_set_priority_request_t;
/**
* @brief xcb_sync_get_priority_cookie_t
**/
typedef struct xcb_sync_get_priority_cookie_t {
unsigned int sequence;
} xcb_sync_get_priority_cookie_t;
/** Opcode for xcb_sync_get_priority. */
#define XCB_SYNC_GET_PRIORITY 13
/**
* @brief xcb_sync_get_priority_request_t
**/
typedef struct xcb_sync_get_priority_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t id;
} xcb_sync_get_priority_request_t;
/**
* @brief xcb_sync_get_priority_reply_t
**/
typedef struct xcb_sync_get_priority_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
int32_t priority;
} xcb_sync_get_priority_reply_t;
/** Opcode for xcb_sync_create_fence. */
#define XCB_SYNC_CREATE_FENCE 14
/**
* @brief xcb_sync_create_fence_request_t
**/
typedef struct xcb_sync_create_fence_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_drawable_t drawable;
xcb_sync_fence_t fence;
uint8_t initially_triggered;
} xcb_sync_create_fence_request_t;
/** Opcode for xcb_sync_trigger_fence. */
#define XCB_SYNC_TRIGGER_FENCE 15
/**
* @brief xcb_sync_trigger_fence_request_t
**/
typedef struct xcb_sync_trigger_fence_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_sync_fence_t fence;
} xcb_sync_trigger_fence_request_t;
/** Opcode for xcb_sync_reset_fence. */
#define XCB_SYNC_RESET_FENCE 16
/**
* @brief xcb_sync_reset_fence_request_t
**/
typedef struct xcb_sync_reset_fence_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_sync_fence_t fence;
} xcb_sync_reset_fence_request_t;
/** Opcode for xcb_sync_destroy_fence. */
#define XCB_SYNC_DESTROY_FENCE 17
/**
* @brief xcb_sync_destroy_fence_request_t
**/
typedef struct xcb_sync_destroy_fence_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_sync_fence_t fence;
} xcb_sync_destroy_fence_request_t;
/**
* @brief xcb_sync_query_fence_cookie_t
**/
typedef struct xcb_sync_query_fence_cookie_t {
unsigned int sequence;
} xcb_sync_query_fence_cookie_t;
/** Opcode for xcb_sync_query_fence. */
#define XCB_SYNC_QUERY_FENCE 18
/**
* @brief xcb_sync_query_fence_request_t
**/
typedef struct xcb_sync_query_fence_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_sync_fence_t fence;
} xcb_sync_query_fence_request_t;
/**
* @brief xcb_sync_query_fence_reply_t
**/
typedef struct xcb_sync_query_fence_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t triggered;
uint8_t pad1[23];
} xcb_sync_query_fence_reply_t;
/** Opcode for xcb_sync_await_fence. */
#define XCB_SYNC_AWAIT_FENCE 19
/**
* @brief xcb_sync_await_fence_request_t
**/
typedef struct xcb_sync_await_fence_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_sync_await_fence_request_t;
/** Opcode for xcb_sync_counter_notify. */
#define XCB_SYNC_COUNTER_NOTIFY 0
/**
* @brief xcb_sync_counter_notify_event_t
**/
typedef struct xcb_sync_counter_notify_event_t {
uint8_t response_type;
uint8_t kind;
uint16_t sequence;
xcb_sync_counter_t counter;
xcb_sync_int64_t wait_value;
xcb_sync_int64_t counter_value;
xcb_timestamp_t timestamp;
uint16_t count;
uint8_t destroyed;
uint8_t pad0;
} xcb_sync_counter_notify_event_t;
/** Opcode for xcb_sync_alarm_notify. */
#define XCB_SYNC_ALARM_NOTIFY 1
/**
* @brief xcb_sync_alarm_notify_event_t
**/
typedef struct xcb_sync_alarm_notify_event_t {
uint8_t response_type;
uint8_t kind;
uint16_t sequence;
xcb_sync_alarm_t alarm;
xcb_sync_int64_t counter_value;
xcb_sync_int64_t alarm_value;
xcb_timestamp_t timestamp;
uint8_t state;
uint8_t pad0[3];
} xcb_sync_alarm_notify_event_t;
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_sync_alarm_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_sync_alarm_t)
*/
void
xcb_sync_alarm_next (xcb_sync_alarm_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_sync_alarm_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_sync_alarm_end (xcb_sync_alarm_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_sync_counter_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_sync_counter_t)
*/
void
xcb_sync_counter_next (xcb_sync_counter_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_sync_counter_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_sync_counter_end (xcb_sync_counter_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_sync_fence_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_sync_fence_t)
*/
void
xcb_sync_fence_next (xcb_sync_fence_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_sync_fence_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_sync_fence_end (xcb_sync_fence_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_sync_int64_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_sync_int64_t)
*/
void
xcb_sync_int64_next (xcb_sync_int64_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_sync_int64_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_sync_int64_end (xcb_sync_int64_iterator_t i);
int
xcb_sync_systemcounter_sizeof (const void *_buffer);
char *
xcb_sync_systemcounter_name (const xcb_sync_systemcounter_t *R);
int
xcb_sync_systemcounter_name_length (const xcb_sync_systemcounter_t *R);
xcb_generic_iterator_t
xcb_sync_systemcounter_name_end (const xcb_sync_systemcounter_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_sync_systemcounter_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_sync_systemcounter_t)
*/
void
xcb_sync_systemcounter_next (xcb_sync_systemcounter_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_sync_systemcounter_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_sync_systemcounter_end (xcb_sync_systemcounter_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_sync_trigger_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_sync_trigger_t)
*/
void
xcb_sync_trigger_next (xcb_sync_trigger_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_sync_trigger_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_sync_trigger_end (xcb_sync_trigger_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_sync_waitcondition_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_sync_waitcondition_t)
*/
void
xcb_sync_waitcondition_next (xcb_sync_waitcondition_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_sync_waitcondition_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_sync_waitcondition_end (xcb_sync_waitcondition_iterator_t i);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_sync_initialize_cookie_t
xcb_sync_initialize (xcb_connection_t *c,
uint8_t desired_major_version,
uint8_t desired_minor_version);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_sync_initialize_cookie_t
xcb_sync_initialize_unchecked (xcb_connection_t *c,
uint8_t desired_major_version,
uint8_t desired_minor_version);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_sync_initialize_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_sync_initialize_reply_t *
xcb_sync_initialize_reply (xcb_connection_t *c,
xcb_sync_initialize_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_sync_list_system_counters_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_sync_list_system_counters_cookie_t
xcb_sync_list_system_counters (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_sync_list_system_counters_cookie_t
xcb_sync_list_system_counters_unchecked (xcb_connection_t *c);
int
xcb_sync_list_system_counters_counters_length (const xcb_sync_list_system_counters_reply_t *R);
xcb_sync_systemcounter_iterator_t
xcb_sync_list_system_counters_counters_iterator (const xcb_sync_list_system_counters_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_sync_list_system_counters_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_sync_list_system_counters_reply_t *
xcb_sync_list_system_counters_reply (xcb_connection_t *c,
xcb_sync_list_system_counters_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_sync_create_counter_checked (xcb_connection_t *c,
xcb_sync_counter_t id,
xcb_sync_int64_t initial_value);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_sync_create_counter (xcb_connection_t *c,
xcb_sync_counter_t id,
xcb_sync_int64_t initial_value);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_sync_destroy_counter_checked (xcb_connection_t *c,
xcb_sync_counter_t counter);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_sync_destroy_counter (xcb_connection_t *c,
xcb_sync_counter_t counter);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_sync_query_counter_cookie_t
xcb_sync_query_counter (xcb_connection_t *c,
xcb_sync_counter_t counter);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_sync_query_counter_cookie_t
xcb_sync_query_counter_unchecked (xcb_connection_t *c,
xcb_sync_counter_t counter);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_sync_query_counter_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_sync_query_counter_reply_t *
xcb_sync_query_counter_reply (xcb_connection_t *c,
xcb_sync_query_counter_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_sync_await_sizeof (const void *_buffer,
uint32_t wait_list_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_sync_await_checked (xcb_connection_t *c,
uint32_t wait_list_len,
const xcb_sync_waitcondition_t *wait_list);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_sync_await (xcb_connection_t *c,
uint32_t wait_list_len,
const xcb_sync_waitcondition_t *wait_list);
xcb_sync_waitcondition_t *
xcb_sync_await_wait_list (const xcb_sync_await_request_t *R);
int
xcb_sync_await_wait_list_length (const xcb_sync_await_request_t *R);
xcb_sync_waitcondition_iterator_t
xcb_sync_await_wait_list_iterator (const xcb_sync_await_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_sync_change_counter_checked (xcb_connection_t *c,
xcb_sync_counter_t counter,
xcb_sync_int64_t amount);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_sync_change_counter (xcb_connection_t *c,
xcb_sync_counter_t counter,
xcb_sync_int64_t amount);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_sync_set_counter_checked (xcb_connection_t *c,
xcb_sync_counter_t counter,
xcb_sync_int64_t value);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_sync_set_counter (xcb_connection_t *c,
xcb_sync_counter_t counter,
xcb_sync_int64_t value);
int
xcb_sync_create_alarm_value_list_serialize (void **_buffer,
uint32_t value_mask,
const xcb_sync_create_alarm_value_list_t *_aux);
int
xcb_sync_create_alarm_value_list_unpack (const void *_buffer,
uint32_t value_mask,
xcb_sync_create_alarm_value_list_t *_aux);
int
xcb_sync_create_alarm_value_list_sizeof (const void *_buffer,
uint32_t value_mask);
int
xcb_sync_create_alarm_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_sync_create_alarm_checked (xcb_connection_t *c,
xcb_sync_alarm_t id,
uint32_t value_mask,
const void *value_list);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_sync_create_alarm (xcb_connection_t *c,
xcb_sync_alarm_t id,
uint32_t value_mask,
const void *value_list);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_sync_create_alarm_aux_checked (xcb_connection_t *c,
xcb_sync_alarm_t id,
uint32_t value_mask,
const xcb_sync_create_alarm_value_list_t *value_list);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_sync_create_alarm_aux (xcb_connection_t *c,
xcb_sync_alarm_t id,
uint32_t value_mask,
const xcb_sync_create_alarm_value_list_t *value_list);
void *
xcb_sync_create_alarm_value_list (const xcb_sync_create_alarm_request_t *R);
int
xcb_sync_change_alarm_value_list_serialize (void **_buffer,
uint32_t value_mask,
const xcb_sync_change_alarm_value_list_t *_aux);
int
xcb_sync_change_alarm_value_list_unpack (const void *_buffer,
uint32_t value_mask,
xcb_sync_change_alarm_value_list_t *_aux);
int
xcb_sync_change_alarm_value_list_sizeof (const void *_buffer,
uint32_t value_mask);
int
xcb_sync_change_alarm_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_sync_change_alarm_checked (xcb_connection_t *c,
xcb_sync_alarm_t id,
uint32_t value_mask,
const void *value_list);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_sync_change_alarm (xcb_connection_t *c,
xcb_sync_alarm_t id,
uint32_t value_mask,
const void *value_list);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_sync_change_alarm_aux_checked (xcb_connection_t *c,
xcb_sync_alarm_t id,
uint32_t value_mask,
const xcb_sync_change_alarm_value_list_t *value_list);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_sync_change_alarm_aux (xcb_connection_t *c,
xcb_sync_alarm_t id,
uint32_t value_mask,
const xcb_sync_change_alarm_value_list_t *value_list);
void *
xcb_sync_change_alarm_value_list (const xcb_sync_change_alarm_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_sync_destroy_alarm_checked (xcb_connection_t *c,
xcb_sync_alarm_t alarm);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_sync_destroy_alarm (xcb_connection_t *c,
xcb_sync_alarm_t alarm);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_sync_query_alarm_cookie_t
xcb_sync_query_alarm (xcb_connection_t *c,
xcb_sync_alarm_t alarm);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_sync_query_alarm_cookie_t
xcb_sync_query_alarm_unchecked (xcb_connection_t *c,
xcb_sync_alarm_t alarm);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_sync_query_alarm_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_sync_query_alarm_reply_t *
xcb_sync_query_alarm_reply (xcb_connection_t *c,
xcb_sync_query_alarm_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_sync_set_priority_checked (xcb_connection_t *c,
uint32_t id,
int32_t priority);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_sync_set_priority (xcb_connection_t *c,
uint32_t id,
int32_t priority);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_sync_get_priority_cookie_t
xcb_sync_get_priority (xcb_connection_t *c,
uint32_t id);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_sync_get_priority_cookie_t
xcb_sync_get_priority_unchecked (xcb_connection_t *c,
uint32_t id);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_sync_get_priority_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_sync_get_priority_reply_t *
xcb_sync_get_priority_reply (xcb_connection_t *c,
xcb_sync_get_priority_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_sync_create_fence_checked (xcb_connection_t *c,
xcb_drawable_t drawable,
xcb_sync_fence_t fence,
uint8_t initially_triggered);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_sync_create_fence (xcb_connection_t *c,
xcb_drawable_t drawable,
xcb_sync_fence_t fence,
uint8_t initially_triggered);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_sync_trigger_fence_checked (xcb_connection_t *c,
xcb_sync_fence_t fence);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_sync_trigger_fence (xcb_connection_t *c,
xcb_sync_fence_t fence);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_sync_reset_fence_checked (xcb_connection_t *c,
xcb_sync_fence_t fence);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_sync_reset_fence (xcb_connection_t *c,
xcb_sync_fence_t fence);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_sync_destroy_fence_checked (xcb_connection_t *c,
xcb_sync_fence_t fence);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_sync_destroy_fence (xcb_connection_t *c,
xcb_sync_fence_t fence);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_sync_query_fence_cookie_t
xcb_sync_query_fence (xcb_connection_t *c,
xcb_sync_fence_t fence);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_sync_query_fence_cookie_t
xcb_sync_query_fence_unchecked (xcb_connection_t *c,
xcb_sync_fence_t fence);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_sync_query_fence_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_sync_query_fence_reply_t *
xcb_sync_query_fence_reply (xcb_connection_t *c,
xcb_sync_query_fence_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_sync_await_fence_sizeof (const void *_buffer,
uint32_t fence_list_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_sync_await_fence_checked (xcb_connection_t *c,
uint32_t fence_list_len,
const xcb_sync_fence_t *fence_list);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_sync_await_fence (xcb_connection_t *c,
uint32_t fence_list_len,
const xcb_sync_fence_t *fence_list);
xcb_sync_fence_t *
xcb_sync_await_fence_fence_list (const xcb_sync_await_fence_request_t *R);
int
xcb_sync_await_fence_fence_list_length (const xcb_sync_await_fence_request_t *R);
xcb_generic_iterator_t
xcb_sync_await_fence_fence_list_end (const xcb_sync_await_fence_request_t *R);
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/
xcb/record.h 0000644 00000066410 15201526705 0006761 0 ustar 00 /*
* This file generated automatically from record.xml by c_client.py.
* Edit at your peril.
*/
/**
* @defgroup XCB_Record_API XCB Record API
* @brief Record XCB Protocol Implementation.
* @{
**/
#ifndef __RECORD_H
#define __RECORD_H
#include "xcb.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XCB_RECORD_MAJOR_VERSION 1
#define XCB_RECORD_MINOR_VERSION 13
extern xcb_extension_t xcb_record_id;
typedef uint32_t xcb_record_context_t;
/**
* @brief xcb_record_context_iterator_t
**/
typedef struct xcb_record_context_iterator_t {
xcb_record_context_t *data;
int rem;
int index;
} xcb_record_context_iterator_t;
/**
* @brief xcb_record_range_8_t
**/
typedef struct xcb_record_range_8_t {
uint8_t first;
uint8_t last;
} xcb_record_range_8_t;
/**
* @brief xcb_record_range_8_iterator_t
**/
typedef struct xcb_record_range_8_iterator_t {
xcb_record_range_8_t *data;
int rem;
int index;
} xcb_record_range_8_iterator_t;
/**
* @brief xcb_record_range_16_t
**/
typedef struct xcb_record_range_16_t {
uint16_t first;
uint16_t last;
} xcb_record_range_16_t;
/**
* @brief xcb_record_range_16_iterator_t
**/
typedef struct xcb_record_range_16_iterator_t {
xcb_record_range_16_t *data;
int rem;
int index;
} xcb_record_range_16_iterator_t;
/**
* @brief xcb_record_ext_range_t
**/
typedef struct xcb_record_ext_range_t {
xcb_record_range_8_t major;
xcb_record_range_16_t minor;
} xcb_record_ext_range_t;
/**
* @brief xcb_record_ext_range_iterator_t
**/
typedef struct xcb_record_ext_range_iterator_t {
xcb_record_ext_range_t *data;
int rem;
int index;
} xcb_record_ext_range_iterator_t;
/**
* @brief xcb_record_range_t
**/
typedef struct xcb_record_range_t {
xcb_record_range_8_t core_requests;
xcb_record_range_8_t core_replies;
xcb_record_ext_range_t ext_requests;
xcb_record_ext_range_t ext_replies;
xcb_record_range_8_t delivered_events;
xcb_record_range_8_t device_events;
xcb_record_range_8_t errors;
uint8_t client_started;
uint8_t client_died;
} xcb_record_range_t;
/**
* @brief xcb_record_range_iterator_t
**/
typedef struct xcb_record_range_iterator_t {
xcb_record_range_t *data;
int rem;
int index;
} xcb_record_range_iterator_t;
typedef uint8_t xcb_record_element_header_t;
/**
* @brief xcb_record_element_header_iterator_t
**/
typedef struct xcb_record_element_header_iterator_t {
xcb_record_element_header_t *data;
int rem;
int index;
} xcb_record_element_header_iterator_t;
typedef enum xcb_record_h_type_t {
XCB_RECORD_H_TYPE_FROM_SERVER_TIME = 1,
XCB_RECORD_H_TYPE_FROM_CLIENT_TIME = 2,
XCB_RECORD_H_TYPE_FROM_CLIENT_SEQUENCE = 4
} xcb_record_h_type_t;
typedef uint32_t xcb_record_client_spec_t;
/**
* @brief xcb_record_client_spec_iterator_t
**/
typedef struct xcb_record_client_spec_iterator_t {
xcb_record_client_spec_t *data;
int rem;
int index;
} xcb_record_client_spec_iterator_t;
typedef enum xcb_record_cs_t {
XCB_RECORD_CS_CURRENT_CLIENTS = 1,
XCB_RECORD_CS_FUTURE_CLIENTS = 2,
XCB_RECORD_CS_ALL_CLIENTS = 3
} xcb_record_cs_t;
/**
* @brief xcb_record_client_info_t
**/
typedef struct xcb_record_client_info_t {
xcb_record_client_spec_t client_resource;
uint32_t num_ranges;
} xcb_record_client_info_t;
/**
* @brief xcb_record_client_info_iterator_t
**/
typedef struct xcb_record_client_info_iterator_t {
xcb_record_client_info_t *data;
int rem;
int index;
} xcb_record_client_info_iterator_t;
/** Opcode for xcb_record_bad_context. */
#define XCB_RECORD_BAD_CONTEXT 0
/**
* @brief xcb_record_bad_context_error_t
**/
typedef struct xcb_record_bad_context_error_t {
uint8_t response_type;
uint8_t error_code;
uint16_t sequence;
uint32_t invalid_record;
} xcb_record_bad_context_error_t;
/**
* @brief xcb_record_query_version_cookie_t
**/
typedef struct xcb_record_query_version_cookie_t {
unsigned int sequence;
} xcb_record_query_version_cookie_t;
/** Opcode for xcb_record_query_version. */
#define XCB_RECORD_QUERY_VERSION 0
/**
* @brief xcb_record_query_version_request_t
**/
typedef struct xcb_record_query_version_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint16_t major_version;
uint16_t minor_version;
} xcb_record_query_version_request_t;
/**
* @brief xcb_record_query_version_reply_t
**/
typedef struct xcb_record_query_version_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t major_version;
uint16_t minor_version;
} xcb_record_query_version_reply_t;
/** Opcode for xcb_record_create_context. */
#define XCB_RECORD_CREATE_CONTEXT 1
/**
* @brief xcb_record_create_context_request_t
**/
typedef struct xcb_record_create_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_record_context_t context;
xcb_record_element_header_t element_header;
uint8_t pad0[3];
uint32_t num_client_specs;
uint32_t num_ranges;
} xcb_record_create_context_request_t;
/** Opcode for xcb_record_register_clients. */
#define XCB_RECORD_REGISTER_CLIENTS 2
/**
* @brief xcb_record_register_clients_request_t
**/
typedef struct xcb_record_register_clients_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_record_context_t context;
xcb_record_element_header_t element_header;
uint8_t pad0[3];
uint32_t num_client_specs;
uint32_t num_ranges;
} xcb_record_register_clients_request_t;
/** Opcode for xcb_record_unregister_clients. */
#define XCB_RECORD_UNREGISTER_CLIENTS 3
/**
* @brief xcb_record_unregister_clients_request_t
**/
typedef struct xcb_record_unregister_clients_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_record_context_t context;
uint32_t num_client_specs;
} xcb_record_unregister_clients_request_t;
/**
* @brief xcb_record_get_context_cookie_t
**/
typedef struct xcb_record_get_context_cookie_t {
unsigned int sequence;
} xcb_record_get_context_cookie_t;
/** Opcode for xcb_record_get_context. */
#define XCB_RECORD_GET_CONTEXT 4
/**
* @brief xcb_record_get_context_request_t
**/
typedef struct xcb_record_get_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_record_context_t context;
} xcb_record_get_context_request_t;
/**
* @brief xcb_record_get_context_reply_t
**/
typedef struct xcb_record_get_context_reply_t {
uint8_t response_type;
uint8_t enabled;
uint16_t sequence;
uint32_t length;
xcb_record_element_header_t element_header;
uint8_t pad0[3];
uint32_t num_intercepted_clients;
uint8_t pad1[16];
} xcb_record_get_context_reply_t;
/**
* @brief xcb_record_enable_context_cookie_t
**/
typedef struct xcb_record_enable_context_cookie_t {
unsigned int sequence;
} xcb_record_enable_context_cookie_t;
/** Opcode for xcb_record_enable_context. */
#define XCB_RECORD_ENABLE_CONTEXT 5
/**
* @brief xcb_record_enable_context_request_t
**/
typedef struct xcb_record_enable_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_record_context_t context;
} xcb_record_enable_context_request_t;
/**
* @brief xcb_record_enable_context_reply_t
**/
typedef struct xcb_record_enable_context_reply_t {
uint8_t response_type;
uint8_t category;
uint16_t sequence;
uint32_t length;
xcb_record_element_header_t element_header;
uint8_t client_swapped;
uint8_t pad0[2];
uint32_t xid_base;
uint32_t server_time;
uint32_t rec_sequence_num;
uint8_t pad1[8];
} xcb_record_enable_context_reply_t;
/** Opcode for xcb_record_disable_context. */
#define XCB_RECORD_DISABLE_CONTEXT 6
/**
* @brief xcb_record_disable_context_request_t
**/
typedef struct xcb_record_disable_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_record_context_t context;
} xcb_record_disable_context_request_t;
/** Opcode for xcb_record_free_context. */
#define XCB_RECORD_FREE_CONTEXT 7
/**
* @brief xcb_record_free_context_request_t
**/
typedef struct xcb_record_free_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_record_context_t context;
} xcb_record_free_context_request_t;
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_record_context_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_record_context_t)
*/
void
xcb_record_context_next (xcb_record_context_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_record_context_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_record_context_end (xcb_record_context_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_record_range_8_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_record_range_8_t)
*/
void
xcb_record_range_8_next (xcb_record_range_8_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_record_range_8_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_record_range_8_end (xcb_record_range_8_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_record_range_16_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_record_range_16_t)
*/
void
xcb_record_range_16_next (xcb_record_range_16_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_record_range_16_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_record_range_16_end (xcb_record_range_16_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_record_ext_range_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_record_ext_range_t)
*/
void
xcb_record_ext_range_next (xcb_record_ext_range_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_record_ext_range_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_record_ext_range_end (xcb_record_ext_range_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_record_range_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_record_range_t)
*/
void
xcb_record_range_next (xcb_record_range_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_record_range_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_record_range_end (xcb_record_range_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_record_element_header_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_record_element_header_t)
*/
void
xcb_record_element_header_next (xcb_record_element_header_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_record_element_header_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_record_element_header_end (xcb_record_element_header_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_record_client_spec_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_record_client_spec_t)
*/
void
xcb_record_client_spec_next (xcb_record_client_spec_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_record_client_spec_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_record_client_spec_end (xcb_record_client_spec_iterator_t i);
int
xcb_record_client_info_sizeof (const void *_buffer);
xcb_record_range_t *
xcb_record_client_info_ranges (const xcb_record_client_info_t *R);
int
xcb_record_client_info_ranges_length (const xcb_record_client_info_t *R);
xcb_record_range_iterator_t
xcb_record_client_info_ranges_iterator (const xcb_record_client_info_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_record_client_info_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_record_client_info_t)
*/
void
xcb_record_client_info_next (xcb_record_client_info_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_record_client_info_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_record_client_info_end (xcb_record_client_info_iterator_t i);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_record_query_version_cookie_t
xcb_record_query_version (xcb_connection_t *c,
uint16_t major_version,
uint16_t minor_version);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_record_query_version_cookie_t
xcb_record_query_version_unchecked (xcb_connection_t *c,
uint16_t major_version,
uint16_t minor_version);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_record_query_version_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_record_query_version_reply_t *
xcb_record_query_version_reply (xcb_connection_t *c,
xcb_record_query_version_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_record_create_context_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_record_create_context_checked (xcb_connection_t *c,
xcb_record_context_t context,
xcb_record_element_header_t element_header,
uint32_t num_client_specs,
uint32_t num_ranges,
const xcb_record_client_spec_t *client_specs,
const xcb_record_range_t *ranges);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_record_create_context (xcb_connection_t *c,
xcb_record_context_t context,
xcb_record_element_header_t element_header,
uint32_t num_client_specs,
uint32_t num_ranges,
const xcb_record_client_spec_t *client_specs,
const xcb_record_range_t *ranges);
xcb_record_client_spec_t *
xcb_record_create_context_client_specs (const xcb_record_create_context_request_t *R);
int
xcb_record_create_context_client_specs_length (const xcb_record_create_context_request_t *R);
xcb_generic_iterator_t
xcb_record_create_context_client_specs_end (const xcb_record_create_context_request_t *R);
xcb_record_range_t *
xcb_record_create_context_ranges (const xcb_record_create_context_request_t *R);
int
xcb_record_create_context_ranges_length (const xcb_record_create_context_request_t *R);
xcb_record_range_iterator_t
xcb_record_create_context_ranges_iterator (const xcb_record_create_context_request_t *R);
int
xcb_record_register_clients_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_record_register_clients_checked (xcb_connection_t *c,
xcb_record_context_t context,
xcb_record_element_header_t element_header,
uint32_t num_client_specs,
uint32_t num_ranges,
const xcb_record_client_spec_t *client_specs,
const xcb_record_range_t *ranges);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_record_register_clients (xcb_connection_t *c,
xcb_record_context_t context,
xcb_record_element_header_t element_header,
uint32_t num_client_specs,
uint32_t num_ranges,
const xcb_record_client_spec_t *client_specs,
const xcb_record_range_t *ranges);
xcb_record_client_spec_t *
xcb_record_register_clients_client_specs (const xcb_record_register_clients_request_t *R);
int
xcb_record_register_clients_client_specs_length (const xcb_record_register_clients_request_t *R);
xcb_generic_iterator_t
xcb_record_register_clients_client_specs_end (const xcb_record_register_clients_request_t *R);
xcb_record_range_t *
xcb_record_register_clients_ranges (const xcb_record_register_clients_request_t *R);
int
xcb_record_register_clients_ranges_length (const xcb_record_register_clients_request_t *R);
xcb_record_range_iterator_t
xcb_record_register_clients_ranges_iterator (const xcb_record_register_clients_request_t *R);
int
xcb_record_unregister_clients_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_record_unregister_clients_checked (xcb_connection_t *c,
xcb_record_context_t context,
uint32_t num_client_specs,
const xcb_record_client_spec_t *client_specs);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_record_unregister_clients (xcb_connection_t *c,
xcb_record_context_t context,
uint32_t num_client_specs,
const xcb_record_client_spec_t *client_specs);
xcb_record_client_spec_t *
xcb_record_unregister_clients_client_specs (const xcb_record_unregister_clients_request_t *R);
int
xcb_record_unregister_clients_client_specs_length (const xcb_record_unregister_clients_request_t *R);
xcb_generic_iterator_t
xcb_record_unregister_clients_client_specs_end (const xcb_record_unregister_clients_request_t *R);
int
xcb_record_get_context_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_record_get_context_cookie_t
xcb_record_get_context (xcb_connection_t *c,
xcb_record_context_t context);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_record_get_context_cookie_t
xcb_record_get_context_unchecked (xcb_connection_t *c,
xcb_record_context_t context);
int
xcb_record_get_context_intercepted_clients_length (const xcb_record_get_context_reply_t *R);
xcb_record_client_info_iterator_t
xcb_record_get_context_intercepted_clients_iterator (const xcb_record_get_context_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_record_get_context_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_record_get_context_reply_t *
xcb_record_get_context_reply (xcb_connection_t *c,
xcb_record_get_context_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_record_enable_context_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_record_enable_context_cookie_t
xcb_record_enable_context (xcb_connection_t *c,
xcb_record_context_t context);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_record_enable_context_cookie_t
xcb_record_enable_context_unchecked (xcb_connection_t *c,
xcb_record_context_t context);
uint8_t *
xcb_record_enable_context_data (const xcb_record_enable_context_reply_t *R);
int
xcb_record_enable_context_data_length (const xcb_record_enable_context_reply_t *R);
xcb_generic_iterator_t
xcb_record_enable_context_data_end (const xcb_record_enable_context_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_record_enable_context_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_record_enable_context_reply_t *
xcb_record_enable_context_reply (xcb_connection_t *c,
xcb_record_enable_context_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_record_disable_context_checked (xcb_connection_t *c,
xcb_record_context_t context);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_record_disable_context (xcb_connection_t *c,
xcb_record_context_t context);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_record_free_context_checked (xcb_connection_t *c,
xcb_record_context_t context);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_record_free_context (xcb_connection_t *c,
xcb_record_context_t context);
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/
xcb/xcb.h 0000644 00000051725 15201526705 0006262 0 ustar 00 /*
* Copyright (C) 2001-2006 Bart Massey, Jamey Sharp, and Josh Triplett.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the names of the authors or their
* institutions shall not be used in advertising or otherwise to promote the
* sale, use or other dealings in this Software without prior written
* authorization from the authors.
*/
#ifndef __XCB_H__
#define __XCB_H__
#include <sys/types.h>
#if defined(__solaris__)
#include <inttypes.h>
#else
#include <stdint.h>
#endif
#ifndef _WIN32
#include <sys/uio.h>
#else
#include "xcb_windefs.h"
#endif
#include <pthread.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @file xcb.h
*/
#define XCB_PACKED __attribute__((__packed__))
/**
* @defgroup XCB_Core_API XCB Core API
* @brief Core API of the XCB library.
*
* @{
*/
/* Pre-defined constants */
/** Current protocol version */
#define X_PROTOCOL 11
/** Current minor version */
#define X_PROTOCOL_REVISION 0
/** X_TCP_PORT + display number = server port for TCP transport */
#define X_TCP_PORT 6000
/** xcb connection errors because of socket, pipe and other stream errors. */
#define XCB_CONN_ERROR 1
/** xcb connection shutdown because of extension not supported */
#define XCB_CONN_CLOSED_EXT_NOTSUPPORTED 2
/** malloc(), calloc() and realloc() error upon failure, for eg ENOMEM */
#define XCB_CONN_CLOSED_MEM_INSUFFICIENT 3
/** Connection closed, exceeding request length that server accepts. */
#define XCB_CONN_CLOSED_REQ_LEN_EXCEED 4
/** Connection closed, error during parsing display string. */
#define XCB_CONN_CLOSED_PARSE_ERR 5
/** Connection closed because the server does not have a screen matching the display. */
#define XCB_CONN_CLOSED_INVALID_SCREEN 6
/** Connection closed because some FD passing operation failed */
#define XCB_CONN_CLOSED_FDPASSING_FAILED 7
#define XCB_TYPE_PAD(T,I) (-(I) & (sizeof(T) > 4 ? 3 : sizeof(T) - 1))
/* Opaque structures */
/**
* @brief XCB Connection structure.
*
* A structure that contain all data that XCB needs to communicate with an X server.
*/
typedef struct xcb_connection_t xcb_connection_t; /**< Opaque structure containing all data that XCB needs to communicate with an X server. */
/* Other types */
/**
* @brief Generic iterator.
*
* A generic iterator structure.
*/
typedef struct {
void *data; /**< Data of the current iterator */
int rem; /**< remaining elements */
int index; /**< index of the current iterator */
} xcb_generic_iterator_t;
/**
* @brief Generic reply.
*
* A generic reply structure.
*/
typedef struct {
uint8_t response_type; /**< Type of the response */
uint8_t pad0; /**< Padding */
uint16_t sequence; /**< Sequence number */
uint32_t length; /**< Length of the response */
} xcb_generic_reply_t;
/**
* @brief Generic event.
*
* A generic event structure.
*/
typedef struct {
uint8_t response_type; /**< Type of the response */
uint8_t pad0; /**< Padding */
uint16_t sequence; /**< Sequence number */
uint32_t pad[7]; /**< Padding */
uint32_t full_sequence; /**< full sequence */
} xcb_generic_event_t;
/**
* @brief Raw Generic event.
*
* A generic event structure as used on the wire, i.e., without the full_sequence field
*/
typedef struct {
uint8_t response_type; /**< Type of the response */
uint8_t pad0; /**< Padding */
uint16_t sequence; /**< Sequence number */
uint32_t pad[7]; /**< Padding */
} xcb_raw_generic_event_t;
/**
* @brief GE event
*
* An event as sent by the XGE extension. The length field specifies the
* number of 4-byte blocks trailing the struct.
*
* @deprecated Since some fields in this struct have unfortunate names, it is
* recommended to use xcb_ge_generic_event_t instead.
*/
typedef struct {
uint8_t response_type; /**< Type of the response */
uint8_t pad0; /**< Padding */
uint16_t sequence; /**< Sequence number */
uint32_t length;
uint16_t event_type;
uint16_t pad1;
uint32_t pad[5]; /**< Padding */
uint32_t full_sequence; /**< full sequence */
} xcb_ge_event_t;
/**
* @brief Generic error.
*
* A generic error structure.
*/
typedef struct {
uint8_t response_type; /**< Type of the response */
uint8_t error_code; /**< Error code */
uint16_t sequence; /**< Sequence number */
uint32_t resource_id; /** < Resource ID for requests with side effects only */
uint16_t minor_code; /** < Minor opcode of the failed request */
uint8_t major_code; /** < Major opcode of the failed request */
uint8_t pad0;
uint32_t pad[5]; /**< Padding */
uint32_t full_sequence; /**< full sequence */
} xcb_generic_error_t;
/**
* @brief Generic cookie.
*
* A generic cookie structure.
*/
typedef struct {
unsigned int sequence; /**< Sequence number */
} xcb_void_cookie_t;
/* Include the generated xproto header. */
#include "xproto.h"
/** XCB_NONE is the universal null resource or null atom parameter value for many core X requests */
#define XCB_NONE 0L
/** XCB_COPY_FROM_PARENT can be used for many xcb_create_window parameters */
#define XCB_COPY_FROM_PARENT 0L
/** XCB_CURRENT_TIME can be used in most requests that take an xcb_timestamp_t */
#define XCB_CURRENT_TIME 0L
/** XCB_NO_SYMBOL fills in unused entries in xcb_keysym_t tables */
#define XCB_NO_SYMBOL 0L
/* xcb_auth.c */
/**
* @brief Container for authorization information.
*
* A container for authorization information to be sent to the X server.
*/
typedef struct xcb_auth_info_t {
int namelen; /**< Length of the string name (as returned by strlen). */
char *name; /**< String containing the authentication protocol name, such as "MIT-MAGIC-COOKIE-1" or "XDM-AUTHORIZATION-1". */
int datalen; /**< Length of the data member. */
char *data; /**< Data interpreted in a protocol-specific manner. */
} xcb_auth_info_t;
/* xcb_out.c */
/**
* @brief Forces any buffered output to be written to the server.
* @param c The connection to the X server.
* @return > @c 0 on success, <= @c 0 otherwise.
*
* Forces any buffered output to be written to the server. Blocks
* until the write is complete.
*/
int xcb_flush(xcb_connection_t *c);
/**
* @brief Returns the maximum request length that this server accepts.
* @param c The connection to the X server.
* @return The maximum request length field.
*
* In the absence of the BIG-REQUESTS extension, returns the
* maximum request length field from the connection setup data, which
* may be as much as 65535. If the server supports BIG-REQUESTS, then
* the maximum request length field from the reply to the
* BigRequestsEnable request will be returned instead.
*
* Note that this length is measured in four-byte units, making the
* theoretical maximum lengths roughly 256kB without BIG-REQUESTS and
* 16GB with.
*/
uint32_t xcb_get_maximum_request_length(xcb_connection_t *c);
/**
* @brief Prefetch the maximum request length without blocking.
* @param c The connection to the X server.
*
* Without blocking, does as much work as possible toward computing
* the maximum request length accepted by the X server.
*
* Invoking this function may cause a call to xcb_big_requests_enable,
* but will not block waiting for the reply.
* xcb_get_maximum_request_length will return the prefetched data
* after possibly blocking while the reply is retrieved.
*
* Note that in order for this function to be fully non-blocking, the
* application must previously have called
* xcb_prefetch_extension_data(c, &xcb_big_requests_id) and the reply
* must have already arrived.
*/
void xcb_prefetch_maximum_request_length(xcb_connection_t *c);
/* xcb_in.c */
/**
* @brief Returns the next event or error from the server.
* @param c The connection to the X server.
* @return The next event from the server.
*
* Returns the next event or error from the server, or returns null in
* the event of an I/O error. Blocks until either an event or error
* arrive, or an I/O error occurs.
*/
xcb_generic_event_t *xcb_wait_for_event(xcb_connection_t *c);
/**
* @brief Returns the next event or error from the server.
* @param c The connection to the X server.
* @return The next event from the server.
*
* Returns the next event or error from the server, if one is
* available, or returns @c NULL otherwise. If no event is available, that
* might be because an I/O error like connection close occurred while
* attempting to read the next event, in which case the connection is
* shut down when this function returns.
*/
xcb_generic_event_t *xcb_poll_for_event(xcb_connection_t *c);
/**
* @brief Returns the next event without reading from the connection.
* @param c The connection to the X server.
* @return The next already queued event from the server.
*
* This is a version of xcb_poll_for_event that only examines the
* event queue for new events. The function doesn't try to read new
* events from the connection if no queued events are found.
*
* This function is useful for callers that know in advance that all
* interesting events have already been read from the connection. For
* example, callers might use xcb_wait_for_reply and be interested
* only of events that preceded a specific reply.
*/
xcb_generic_event_t *xcb_poll_for_queued_event(xcb_connection_t *c);
typedef struct xcb_special_event xcb_special_event_t;
/**
* @brief Returns the next event from a special queue
*/
xcb_generic_event_t *xcb_poll_for_special_event(xcb_connection_t *c,
xcb_special_event_t *se);
/**
* @brief Returns the next event from a special queue, blocking until one arrives
*/
xcb_generic_event_t *xcb_wait_for_special_event(xcb_connection_t *c,
xcb_special_event_t *se);
/**
* @typedef typedef struct xcb_extension_t xcb_extension_t
*/
typedef struct xcb_extension_t xcb_extension_t; /**< Opaque structure used as key for xcb_get_extension_data_t. */
/**
* @brief Listen for a special event
*/
xcb_special_event_t *xcb_register_for_special_xge(xcb_connection_t *c,
xcb_extension_t *ext,
uint32_t eid,
uint32_t *stamp);
/**
* @brief Stop listening for a special event
*/
void xcb_unregister_for_special_event(xcb_connection_t *c,
xcb_special_event_t *se);
/**
* @brief Return the error for a request, or NULL if none can ever arrive.
* @param c The connection to the X server.
* @param cookie The request cookie.
* @return The error for the request, or NULL if none can ever arrive.
*
* The xcb_void_cookie_t cookie supplied to this function must have resulted
* from a call to xcb_[request_name]_checked(). This function will block
* until one of two conditions happens. If an error is received, it will be
* returned. If a reply to a subsequent request has already arrived, no error
* can arrive for this request, so this function will return NULL.
*
* Note that this function will perform a sync if needed to ensure that the
* sequence number will advance beyond that provided in cookie; this is a
* convenience to avoid races in determining whether the sync is needed.
*/
xcb_generic_error_t *xcb_request_check(xcb_connection_t *c, xcb_void_cookie_t cookie);
/**
* @brief Discards the reply for a request.
* @param c The connection to the X server.
* @param sequence The request sequence number from a cookie.
*
* Discards the reply for a request. Additionally, any error generated
* by the request is also discarded (unless it was an _unchecked request
* and the error has already arrived).
*
* This function will not block even if the reply is not yet available.
*
* Note that the sequence really does have to come from an xcb cookie;
* this function is not designed to operate on socket-handoff replies.
*/
void xcb_discard_reply(xcb_connection_t *c, unsigned int sequence);
/**
* @brief Discards the reply for a request, given by a 64bit sequence number
* @param c The connection to the X server.
* @param sequence 64-bit sequence number as returned by xcb_send_request64().
*
* Discards the reply for a request. Additionally, any error generated
* by the request is also discarded (unless it was an _unchecked request
* and the error has already arrived).
*
* This function will not block even if the reply is not yet available.
*
* Note that the sequence really does have to come from xcb_send_request64();
* the cookie sequence number is defined as "unsigned" int and therefore
* not 64-bit on all platforms.
* This function is not designed to operate on socket-handoff replies.
*
* Unlike its xcb_discard_reply() counterpart, the given sequence number is not
* automatically "widened" to 64-bit.
*/
void xcb_discard_reply64(xcb_connection_t *c, uint64_t sequence);
/* xcb_ext.c */
/**
* @brief Caches reply information from QueryExtension requests.
* @param c The connection.
* @param ext The extension data.
* @return A pointer to the xcb_query_extension_reply_t for the extension.
*
* This function is the primary interface to the "extension cache",
* which caches reply information from QueryExtension
* requests. Invoking this function may cause a call to
* xcb_query_extension to retrieve extension information from the
* server, and may block until extension data is received from the
* server.
*
* The result must not be freed. This storage is managed by the cache
* itself.
*/
const struct xcb_query_extension_reply_t *xcb_get_extension_data(xcb_connection_t *c, xcb_extension_t *ext);
/**
* @brief Prefetch of extension data into the extension cache
* @param c The connection.
* @param ext The extension data.
*
* This function allows a "prefetch" of extension data into the
* extension cache. Invoking the function may cause a call to
* xcb_query_extension, but will not block waiting for the
* reply. xcb_get_extension_data will return the prefetched data after
* possibly blocking while it is retrieved.
*/
void xcb_prefetch_extension_data(xcb_connection_t *c, xcb_extension_t *ext);
/* xcb_conn.c */
/**
* @brief Access the data returned by the server.
* @param c The connection.
* @return A pointer to an xcb_setup_t structure.
*
* Accessor for the data returned by the server when the xcb_connection_t
* was initialized. This data includes
* - the server's required format for images,
* - a list of available visuals,
* - a list of available screens,
* - the server's maximum request length (in the absence of the
* BIG-REQUESTS extension),
* - and other assorted information.
*
* See the X protocol specification for more details.
*
* The result must not be freed.
*/
const struct xcb_setup_t *xcb_get_setup(xcb_connection_t *c);
/**
* @brief Access the file descriptor of the connection.
* @param c The connection.
* @return The file descriptor.
*
* Accessor for the file descriptor that was passed to the
* xcb_connect_to_fd call that returned @p c.
*/
int xcb_get_file_descriptor(xcb_connection_t *c);
/**
* @brief Test whether the connection has shut down due to a fatal error.
* @param c The connection.
* @return > 0 if the connection is in an error state; 0 otherwise.
*
* Some errors that occur in the context of an xcb_connection_t
* are unrecoverable. When such an error occurs, the
* connection is shut down and further operations on the
* xcb_connection_t have no effect, but memory will not be freed until
* xcb_disconnect() is called on the xcb_connection_t.
*
* @return XCB_CONN_ERROR, because of socket errors, pipe errors or other stream errors.
* @return XCB_CONN_CLOSED_EXT_NOTSUPPORTED, when extension not supported.
* @return XCB_CONN_CLOSED_MEM_INSUFFICIENT, when memory not available.
* @return XCB_CONN_CLOSED_REQ_LEN_EXCEED, exceeding request length that server accepts.
* @return XCB_CONN_CLOSED_PARSE_ERR, error during parsing display string.
* @return XCB_CONN_CLOSED_INVALID_SCREEN, because the server does not have a screen matching the display.
*/
int xcb_connection_has_error(xcb_connection_t *c);
/**
* @brief Connects to the X server.
* @param fd The file descriptor.
* @param auth_info Authentication data.
* @return A newly allocated xcb_connection_t structure.
*
* Connects to an X server, given the open socket @p fd and the
* xcb_auth_info_t @p auth_info. The file descriptor @p fd is
* bidirectionally connected to an X server. If the connection
* should be unauthenticated, @p auth_info must be @c
* NULL.
*
* Always returns a non-NULL pointer to a xcb_connection_t, even on failure.
* Callers need to use xcb_connection_has_error() to check for failure.
* When finished, use xcb_disconnect() to close the connection and free
* the structure.
*/
xcb_connection_t *xcb_connect_to_fd(int fd, xcb_auth_info_t *auth_info);
/**
* @brief Closes the connection.
* @param c The connection.
*
* Closes the file descriptor and frees all memory associated with the
* connection @c c. If @p c is @c NULL, nothing is done.
*/
void xcb_disconnect(xcb_connection_t *c);
/* xcb_util.c */
/**
* @brief Parses a display string name in the form documented by X(7x).
* @param name The name of the display.
* @param host A pointer to a malloc'd copy of the hostname.
* @param display A pointer to the display number.
* @param screen A pointer to the screen number.
* @return 0 on failure, non 0 otherwise.
*
* Parses the display string name @p display_name in the form
* documented by X(7x). Has no side effects on failure. If
* @p displayname is @c NULL or empty, it uses the environment
* variable DISPLAY. @p hostp is a pointer to a newly allocated string
* that contain the host name. @p displayp is set to the display
* number and @p screenp to the preferred screen number. @p screenp
* can be @c NULL. If @p displayname does not contain a screen number,
* it is set to @c 0.
*/
int xcb_parse_display(const char *name, char **host, int *display, int *screen);
/**
* @brief Connects to the X server.
* @param displayname The name of the display.
* @param screenp A pointer to a preferred screen number.
* @return A newly allocated xcb_connection_t structure.
*
* Connects to the X server specified by @p displayname. If @p
* displayname is @c NULL, uses the value of the DISPLAY environment
* variable. If a particular screen on that server is preferred, the
* int pointed to by @p screenp (if not @c NULL) will be set to that
* screen; otherwise the screen will be set to 0.
*
* Always returns a non-NULL pointer to a xcb_connection_t, even on failure.
* Callers need to use xcb_connection_has_error() to check for failure.
* When finished, use xcb_disconnect() to close the connection and free
* the structure.
*/
xcb_connection_t *xcb_connect(const char *displayname, int *screenp);
/**
* @brief Connects to the X server, using an authorization information.
* @param display The name of the display.
* @param auth The authorization information.
* @param screen A pointer to a preferred screen number.
* @return A newly allocated xcb_connection_t structure.
*
* Connects to the X server specified by @p displayname, using the
* authorization @p auth. If a particular screen on that server is
* preferred, the int pointed to by @p screenp (if not @c NULL) will
* be set to that screen; otherwise @p screenp will be set to 0.
*
* Always returns a non-NULL pointer to a xcb_connection_t, even on failure.
* Callers need to use xcb_connection_has_error() to check for failure.
* When finished, use xcb_disconnect() to close the connection and free
* the structure.
*/
xcb_connection_t *xcb_connect_to_display_with_auth_info(const char *display, xcb_auth_info_t *auth, int *screen);
/* xcb_xid.c */
/**
* @brief Allocates an XID for a new object.
* @param c The connection.
* @return A newly allocated XID.
*
* Allocates an XID for a new object. Typically used just prior to
* various object creation functions, such as xcb_create_window.
*/
uint32_t xcb_generate_id(xcb_connection_t *c);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __XCB_H__ */
xcb/xkb.h 0000644 00000741260 15201526705 0006272 0 ustar 00 /*
* This file generated automatically from xkb.xml by c_client.py.
* Edit at your peril.
*/
/**
* @defgroup XCB_xkb_API XCB xkb API
* @brief xkb XCB Protocol Implementation.
* @{
**/
#ifndef __XKB_H
#define __XKB_H
#include "xcb.h"
#include "xproto.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XCB_XKB_MAJOR_VERSION 1
#define XCB_XKB_MINOR_VERSION 0
extern xcb_extension_t xcb_xkb_id;
typedef enum xcb_xkb_const_t {
XCB_XKB_CONST_MAX_LEGAL_KEY_CODE = 255,
XCB_XKB_CONST_PER_KEY_BIT_ARRAY_SIZE = 32,
XCB_XKB_CONST_KEY_NAME_LENGTH = 4
} xcb_xkb_const_t;
typedef enum xcb_xkb_event_type_t {
XCB_XKB_EVENT_TYPE_NEW_KEYBOARD_NOTIFY = 1,
XCB_XKB_EVENT_TYPE_MAP_NOTIFY = 2,
XCB_XKB_EVENT_TYPE_STATE_NOTIFY = 4,
XCB_XKB_EVENT_TYPE_CONTROLS_NOTIFY = 8,
XCB_XKB_EVENT_TYPE_INDICATOR_STATE_NOTIFY = 16,
XCB_XKB_EVENT_TYPE_INDICATOR_MAP_NOTIFY = 32,
XCB_XKB_EVENT_TYPE_NAMES_NOTIFY = 64,
XCB_XKB_EVENT_TYPE_COMPAT_MAP_NOTIFY = 128,
XCB_XKB_EVENT_TYPE_BELL_NOTIFY = 256,
XCB_XKB_EVENT_TYPE_ACTION_MESSAGE = 512,
XCB_XKB_EVENT_TYPE_ACCESS_X_NOTIFY = 1024,
XCB_XKB_EVENT_TYPE_EXTENSION_DEVICE_NOTIFY = 2048
} xcb_xkb_event_type_t;
typedef enum xcb_xkb_nkn_detail_t {
XCB_XKB_NKN_DETAIL_KEYCODES = 1,
XCB_XKB_NKN_DETAIL_GEOMETRY = 2,
XCB_XKB_NKN_DETAIL_DEVICE_ID = 4
} xcb_xkb_nkn_detail_t;
typedef enum xcb_xkb_axn_detail_t {
XCB_XKB_AXN_DETAIL_SK_PRESS = 1,
XCB_XKB_AXN_DETAIL_SK_ACCEPT = 2,
XCB_XKB_AXN_DETAIL_SK_REJECT = 4,
XCB_XKB_AXN_DETAIL_SK_RELEASE = 8,
XCB_XKB_AXN_DETAIL_BK_ACCEPT = 16,
XCB_XKB_AXN_DETAIL_BK_REJECT = 32,
XCB_XKB_AXN_DETAIL_AXK_WARNING = 64
} xcb_xkb_axn_detail_t;
typedef enum xcb_xkb_map_part_t {
XCB_XKB_MAP_PART_KEY_TYPES = 1,
XCB_XKB_MAP_PART_KEY_SYMS = 2,
XCB_XKB_MAP_PART_MODIFIER_MAP = 4,
XCB_XKB_MAP_PART_EXPLICIT_COMPONENTS = 8,
XCB_XKB_MAP_PART_KEY_ACTIONS = 16,
XCB_XKB_MAP_PART_KEY_BEHAVIORS = 32,
XCB_XKB_MAP_PART_VIRTUAL_MODS = 64,
XCB_XKB_MAP_PART_VIRTUAL_MOD_MAP = 128
} xcb_xkb_map_part_t;
typedef enum xcb_xkb_set_map_flags_t {
XCB_XKB_SET_MAP_FLAGS_RESIZE_TYPES = 1,
XCB_XKB_SET_MAP_FLAGS_RECOMPUTE_ACTIONS = 2
} xcb_xkb_set_map_flags_t;
typedef enum xcb_xkb_state_part_t {
XCB_XKB_STATE_PART_MODIFIER_STATE = 1,
XCB_XKB_STATE_PART_MODIFIER_BASE = 2,
XCB_XKB_STATE_PART_MODIFIER_LATCH = 4,
XCB_XKB_STATE_PART_MODIFIER_LOCK = 8,
XCB_XKB_STATE_PART_GROUP_STATE = 16,
XCB_XKB_STATE_PART_GROUP_BASE = 32,
XCB_XKB_STATE_PART_GROUP_LATCH = 64,
XCB_XKB_STATE_PART_GROUP_LOCK = 128,
XCB_XKB_STATE_PART_COMPAT_STATE = 256,
XCB_XKB_STATE_PART_GRAB_MODS = 512,
XCB_XKB_STATE_PART_COMPAT_GRAB_MODS = 1024,
XCB_XKB_STATE_PART_LOOKUP_MODS = 2048,
XCB_XKB_STATE_PART_COMPAT_LOOKUP_MODS = 4096,
XCB_XKB_STATE_PART_POINTER_BUTTONS = 8192
} xcb_xkb_state_part_t;
typedef enum xcb_xkb_bool_ctrl_t {
XCB_XKB_BOOL_CTRL_REPEAT_KEYS = 1,
XCB_XKB_BOOL_CTRL_SLOW_KEYS = 2,
XCB_XKB_BOOL_CTRL_BOUNCE_KEYS = 4,
XCB_XKB_BOOL_CTRL_STICKY_KEYS = 8,
XCB_XKB_BOOL_CTRL_MOUSE_KEYS = 16,
XCB_XKB_BOOL_CTRL_MOUSE_KEYS_ACCEL = 32,
XCB_XKB_BOOL_CTRL_ACCESS_X_KEYS = 64,
XCB_XKB_BOOL_CTRL_ACCESS_X_TIMEOUT_MASK = 128,
XCB_XKB_BOOL_CTRL_ACCESS_X_FEEDBACK_MASK = 256,
XCB_XKB_BOOL_CTRL_AUDIBLE_BELL_MASK = 512,
XCB_XKB_BOOL_CTRL_OVERLAY_1_MASK = 1024,
XCB_XKB_BOOL_CTRL_OVERLAY_2_MASK = 2048,
XCB_XKB_BOOL_CTRL_IGNORE_GROUP_LOCK_MASK = 4096
} xcb_xkb_bool_ctrl_t;
typedef enum xcb_xkb_control_t {
XCB_XKB_CONTROL_GROUPS_WRAP = 134217728,
XCB_XKB_CONTROL_INTERNAL_MODS = 268435456,
XCB_XKB_CONTROL_IGNORE_LOCK_MODS = 536870912,
XCB_XKB_CONTROL_PER_KEY_REPEAT = 1073741824,
XCB_XKB_CONTROL_CONTROLS_ENABLED = 2147483648
} xcb_xkb_control_t;
typedef enum xcb_xkb_ax_option_t {
XCB_XKB_AX_OPTION_SK_PRESS_FB = 1,
XCB_XKB_AX_OPTION_SK_ACCEPT_FB = 2,
XCB_XKB_AX_OPTION_FEATURE_FB = 4,
XCB_XKB_AX_OPTION_SLOW_WARN_FB = 8,
XCB_XKB_AX_OPTION_INDICATOR_FB = 16,
XCB_XKB_AX_OPTION_STICKY_KEYS_FB = 32,
XCB_XKB_AX_OPTION_TWO_KEYS = 64,
XCB_XKB_AX_OPTION_LATCH_TO_LOCK = 128,
XCB_XKB_AX_OPTION_SK_RELEASE_FB = 256,
XCB_XKB_AX_OPTION_SK_REJECT_FB = 512,
XCB_XKB_AX_OPTION_BK_REJECT_FB = 1024,
XCB_XKB_AX_OPTION_DUMB_BELL = 2048
} xcb_xkb_ax_option_t;
typedef uint16_t xcb_xkb_device_spec_t;
/**
* @brief xcb_xkb_device_spec_iterator_t
**/
typedef struct xcb_xkb_device_spec_iterator_t {
xcb_xkb_device_spec_t *data;
int rem;
int index;
} xcb_xkb_device_spec_iterator_t;
typedef enum xcb_xkb_led_class_result_t {
XCB_XKB_LED_CLASS_RESULT_KBD_FEEDBACK_CLASS = 0,
XCB_XKB_LED_CLASS_RESULT_LED_FEEDBACK_CLASS = 4
} xcb_xkb_led_class_result_t;
typedef enum xcb_xkb_led_class_t {
XCB_XKB_LED_CLASS_KBD_FEEDBACK_CLASS = 0,
XCB_XKB_LED_CLASS_LED_FEEDBACK_CLASS = 4,
XCB_XKB_LED_CLASS_DFLT_XI_CLASS = 768,
XCB_XKB_LED_CLASS_ALL_XI_CLASSES = 1280
} xcb_xkb_led_class_t;
typedef uint16_t xcb_xkb_led_class_spec_t;
/**
* @brief xcb_xkb_led_class_spec_iterator_t
**/
typedef struct xcb_xkb_led_class_spec_iterator_t {
xcb_xkb_led_class_spec_t *data;
int rem;
int index;
} xcb_xkb_led_class_spec_iterator_t;
typedef enum xcb_xkb_bell_class_result_t {
XCB_XKB_BELL_CLASS_RESULT_KBD_FEEDBACK_CLASS = 0,
XCB_XKB_BELL_CLASS_RESULT_BELL_FEEDBACK_CLASS = 5
} xcb_xkb_bell_class_result_t;
typedef enum xcb_xkb_bell_class_t {
XCB_XKB_BELL_CLASS_KBD_FEEDBACK_CLASS = 0,
XCB_XKB_BELL_CLASS_BELL_FEEDBACK_CLASS = 5,
XCB_XKB_BELL_CLASS_DFLT_XI_CLASS = 768
} xcb_xkb_bell_class_t;
typedef uint16_t xcb_xkb_bell_class_spec_t;
/**
* @brief xcb_xkb_bell_class_spec_iterator_t
**/
typedef struct xcb_xkb_bell_class_spec_iterator_t {
xcb_xkb_bell_class_spec_t *data;
int rem;
int index;
} xcb_xkb_bell_class_spec_iterator_t;
typedef enum xcb_xkb_id_t {
XCB_XKB_ID_USE_CORE_KBD = 256,
XCB_XKB_ID_USE_CORE_PTR = 512,
XCB_XKB_ID_DFLT_XI_CLASS = 768,
XCB_XKB_ID_DFLT_XI_ID = 1024,
XCB_XKB_ID_ALL_XI_CLASS = 1280,
XCB_XKB_ID_ALL_XI_ID = 1536,
XCB_XKB_ID_XI_NONE = 65280
} xcb_xkb_id_t;
typedef uint16_t xcb_xkb_id_spec_t;
/**
* @brief xcb_xkb_id_spec_iterator_t
**/
typedef struct xcb_xkb_id_spec_iterator_t {
xcb_xkb_id_spec_t *data;
int rem;
int index;
} xcb_xkb_id_spec_iterator_t;
typedef enum xcb_xkb_group_t {
XCB_XKB_GROUP_1 = 0,
XCB_XKB_GROUP_2 = 1,
XCB_XKB_GROUP_3 = 2,
XCB_XKB_GROUP_4 = 3
} xcb_xkb_group_t;
typedef enum xcb_xkb_groups_t {
XCB_XKB_GROUPS_ANY = 254,
XCB_XKB_GROUPS_ALL = 255
} xcb_xkb_groups_t;
typedef enum xcb_xkb_set_of_group_t {
XCB_XKB_SET_OF_GROUP_GROUP_1 = 1,
XCB_XKB_SET_OF_GROUP_GROUP_2 = 2,
XCB_XKB_SET_OF_GROUP_GROUP_3 = 4,
XCB_XKB_SET_OF_GROUP_GROUP_4 = 8
} xcb_xkb_set_of_group_t;
typedef enum xcb_xkb_set_of_groups_t {
XCB_XKB_SET_OF_GROUPS_ANY = 128
} xcb_xkb_set_of_groups_t;
typedef enum xcb_xkb_groups_wrap_t {
XCB_XKB_GROUPS_WRAP_WRAP_INTO_RANGE = 0,
XCB_XKB_GROUPS_WRAP_CLAMP_INTO_RANGE = 64,
XCB_XKB_GROUPS_WRAP_REDIRECT_INTO_RANGE = 128
} xcb_xkb_groups_wrap_t;
typedef enum xcb_xkb_v_mods_high_t {
XCB_XKB_V_MODS_HIGH_15 = 128,
XCB_XKB_V_MODS_HIGH_14 = 64,
XCB_XKB_V_MODS_HIGH_13 = 32,
XCB_XKB_V_MODS_HIGH_12 = 16,
XCB_XKB_V_MODS_HIGH_11 = 8,
XCB_XKB_V_MODS_HIGH_10 = 4,
XCB_XKB_V_MODS_HIGH_9 = 2,
XCB_XKB_V_MODS_HIGH_8 = 1
} xcb_xkb_v_mods_high_t;
typedef enum xcb_xkb_v_mods_low_t {
XCB_XKB_V_MODS_LOW_7 = 128,
XCB_XKB_V_MODS_LOW_6 = 64,
XCB_XKB_V_MODS_LOW_5 = 32,
XCB_XKB_V_MODS_LOW_4 = 16,
XCB_XKB_V_MODS_LOW_3 = 8,
XCB_XKB_V_MODS_LOW_2 = 4,
XCB_XKB_V_MODS_LOW_1 = 2,
XCB_XKB_V_MODS_LOW_0 = 1
} xcb_xkb_v_mods_low_t;
typedef enum xcb_xkb_v_mod_t {
XCB_XKB_V_MOD_15 = 32768,
XCB_XKB_V_MOD_14 = 16384,
XCB_XKB_V_MOD_13 = 8192,
XCB_XKB_V_MOD_12 = 4096,
XCB_XKB_V_MOD_11 = 2048,
XCB_XKB_V_MOD_10 = 1024,
XCB_XKB_V_MOD_9 = 512,
XCB_XKB_V_MOD_8 = 256,
XCB_XKB_V_MOD_7 = 128,
XCB_XKB_V_MOD_6 = 64,
XCB_XKB_V_MOD_5 = 32,
XCB_XKB_V_MOD_4 = 16,
XCB_XKB_V_MOD_3 = 8,
XCB_XKB_V_MOD_2 = 4,
XCB_XKB_V_MOD_1 = 2,
XCB_XKB_V_MOD_0 = 1
} xcb_xkb_v_mod_t;
typedef enum xcb_xkb_explicit_t {
XCB_XKB_EXPLICIT_V_MOD_MAP = 128,
XCB_XKB_EXPLICIT_BEHAVIOR = 64,
XCB_XKB_EXPLICIT_AUTO_REPEAT = 32,
XCB_XKB_EXPLICIT_INTERPRET = 16,
XCB_XKB_EXPLICIT_KEY_TYPE_4 = 8,
XCB_XKB_EXPLICIT_KEY_TYPE_3 = 4,
XCB_XKB_EXPLICIT_KEY_TYPE_2 = 2,
XCB_XKB_EXPLICIT_KEY_TYPE_1 = 1
} xcb_xkb_explicit_t;
typedef enum xcb_xkb_sym_interpret_match_t {
XCB_XKB_SYM_INTERPRET_MATCH_NONE_OF = 0,
XCB_XKB_SYM_INTERPRET_MATCH_ANY_OF_OR_NONE = 1,
XCB_XKB_SYM_INTERPRET_MATCH_ANY_OF = 2,
XCB_XKB_SYM_INTERPRET_MATCH_ALL_OF = 3,
XCB_XKB_SYM_INTERPRET_MATCH_EXACTLY = 4
} xcb_xkb_sym_interpret_match_t;
typedef enum xcb_xkb_sym_interp_match_t {
XCB_XKB_SYM_INTERP_MATCH_LEVEL_ONE_ONLY = 128,
XCB_XKB_SYM_INTERP_MATCH_OP_MASK = 127
} xcb_xkb_sym_interp_match_t;
typedef enum xcb_xkb_im_flag_t {
XCB_XKB_IM_FLAG_NO_EXPLICIT = 128,
XCB_XKB_IM_FLAG_NO_AUTOMATIC = 64,
XCB_XKB_IM_FLAG_LED_DRIVES_KB = 32
} xcb_xkb_im_flag_t;
typedef enum xcb_xkb_im_mods_which_t {
XCB_XKB_IM_MODS_WHICH_USE_COMPAT = 16,
XCB_XKB_IM_MODS_WHICH_USE_EFFECTIVE = 8,
XCB_XKB_IM_MODS_WHICH_USE_LOCKED = 4,
XCB_XKB_IM_MODS_WHICH_USE_LATCHED = 2,
XCB_XKB_IM_MODS_WHICH_USE_BASE = 1
} xcb_xkb_im_mods_which_t;
typedef enum xcb_xkb_im_groups_which_t {
XCB_XKB_IM_GROUPS_WHICH_USE_COMPAT = 16,
XCB_XKB_IM_GROUPS_WHICH_USE_EFFECTIVE = 8,
XCB_XKB_IM_GROUPS_WHICH_USE_LOCKED = 4,
XCB_XKB_IM_GROUPS_WHICH_USE_LATCHED = 2,
XCB_XKB_IM_GROUPS_WHICH_USE_BASE = 1
} xcb_xkb_im_groups_which_t;
/**
* @brief xcb_xkb_indicator_map_t
**/
typedef struct xcb_xkb_indicator_map_t {
uint8_t flags;
uint8_t whichGroups;
uint8_t groups;
uint8_t whichMods;
uint8_t mods;
uint8_t realMods;
uint16_t vmods;
uint32_t ctrls;
} xcb_xkb_indicator_map_t;
/**
* @brief xcb_xkb_indicator_map_iterator_t
**/
typedef struct xcb_xkb_indicator_map_iterator_t {
xcb_xkb_indicator_map_t *data;
int rem;
int index;
} xcb_xkb_indicator_map_iterator_t;
typedef enum xcb_xkb_cm_detail_t {
XCB_XKB_CM_DETAIL_SYM_INTERP = 1,
XCB_XKB_CM_DETAIL_GROUP_COMPAT = 2
} xcb_xkb_cm_detail_t;
typedef enum xcb_xkb_name_detail_t {
XCB_XKB_NAME_DETAIL_KEYCODES = 1,
XCB_XKB_NAME_DETAIL_GEOMETRY = 2,
XCB_XKB_NAME_DETAIL_SYMBOLS = 4,
XCB_XKB_NAME_DETAIL_PHYS_SYMBOLS = 8,
XCB_XKB_NAME_DETAIL_TYPES = 16,
XCB_XKB_NAME_DETAIL_COMPAT = 32,
XCB_XKB_NAME_DETAIL_KEY_TYPE_NAMES = 64,
XCB_XKB_NAME_DETAIL_KT_LEVEL_NAMES = 128,
XCB_XKB_NAME_DETAIL_INDICATOR_NAMES = 256,
XCB_XKB_NAME_DETAIL_KEY_NAMES = 512,
XCB_XKB_NAME_DETAIL_KEY_ALIASES = 1024,
XCB_XKB_NAME_DETAIL_VIRTUAL_MOD_NAMES = 2048,
XCB_XKB_NAME_DETAIL_GROUP_NAMES = 4096,
XCB_XKB_NAME_DETAIL_RG_NAMES = 8192
} xcb_xkb_name_detail_t;
typedef enum xcb_xkb_gbn_detail_t {
XCB_XKB_GBN_DETAIL_TYPES = 1,
XCB_XKB_GBN_DETAIL_COMPAT_MAP = 2,
XCB_XKB_GBN_DETAIL_CLIENT_SYMBOLS = 4,
XCB_XKB_GBN_DETAIL_SERVER_SYMBOLS = 8,
XCB_XKB_GBN_DETAIL_INDICATOR_MAPS = 16,
XCB_XKB_GBN_DETAIL_KEY_NAMES = 32,
XCB_XKB_GBN_DETAIL_GEOMETRY = 64,
XCB_XKB_GBN_DETAIL_OTHER_NAMES = 128
} xcb_xkb_gbn_detail_t;
typedef enum xcb_xkb_xi_feature_t {
XCB_XKB_XI_FEATURE_KEYBOARDS = 1,
XCB_XKB_XI_FEATURE_BUTTON_ACTIONS = 2,
XCB_XKB_XI_FEATURE_INDICATOR_NAMES = 4,
XCB_XKB_XI_FEATURE_INDICATOR_MAPS = 8,
XCB_XKB_XI_FEATURE_INDICATOR_STATE = 16
} xcb_xkb_xi_feature_t;
typedef enum xcb_xkb_per_client_flag_t {
XCB_XKB_PER_CLIENT_FLAG_DETECTABLE_AUTO_REPEAT = 1,
XCB_XKB_PER_CLIENT_FLAG_GRABS_USE_XKB_STATE = 2,
XCB_XKB_PER_CLIENT_FLAG_AUTO_RESET_CONTROLS = 4,
XCB_XKB_PER_CLIENT_FLAG_LOOKUP_STATE_WHEN_GRABBED = 8,
XCB_XKB_PER_CLIENT_FLAG_SEND_EVENT_USES_XKB_STATE = 16
} xcb_xkb_per_client_flag_t;
/**
* @brief xcb_xkb_mod_def_t
**/
typedef struct xcb_xkb_mod_def_t {
uint8_t mask;
uint8_t realMods;
uint16_t vmods;
} xcb_xkb_mod_def_t;
/**
* @brief xcb_xkb_mod_def_iterator_t
**/
typedef struct xcb_xkb_mod_def_iterator_t {
xcb_xkb_mod_def_t *data;
int rem;
int index;
} xcb_xkb_mod_def_iterator_t;
/**
* @brief xcb_xkb_key_name_t
**/
typedef struct xcb_xkb_key_name_t {
char name[4];
} xcb_xkb_key_name_t;
/**
* @brief xcb_xkb_key_name_iterator_t
**/
typedef struct xcb_xkb_key_name_iterator_t {
xcb_xkb_key_name_t *data;
int rem;
int index;
} xcb_xkb_key_name_iterator_t;
/**
* @brief xcb_xkb_key_alias_t
**/
typedef struct xcb_xkb_key_alias_t {
char real[4];
char alias[4];
} xcb_xkb_key_alias_t;
/**
* @brief xcb_xkb_key_alias_iterator_t
**/
typedef struct xcb_xkb_key_alias_iterator_t {
xcb_xkb_key_alias_t *data;
int rem;
int index;
} xcb_xkb_key_alias_iterator_t;
/**
* @brief xcb_xkb_counted_string_16_t
**/
typedef struct xcb_xkb_counted_string_16_t {
uint16_t length;
} xcb_xkb_counted_string_16_t;
/**
* @brief xcb_xkb_counted_string_16_iterator_t
**/
typedef struct xcb_xkb_counted_string_16_iterator_t {
xcb_xkb_counted_string_16_t *data;
int rem;
int index;
} xcb_xkb_counted_string_16_iterator_t;
/**
* @brief xcb_xkb_kt_map_entry_t
**/
typedef struct xcb_xkb_kt_map_entry_t {
uint8_t active;
uint8_t mods_mask;
uint8_t level;
uint8_t mods_mods;
uint16_t mods_vmods;
uint8_t pad0[2];
} xcb_xkb_kt_map_entry_t;
/**
* @brief xcb_xkb_kt_map_entry_iterator_t
**/
typedef struct xcb_xkb_kt_map_entry_iterator_t {
xcb_xkb_kt_map_entry_t *data;
int rem;
int index;
} xcb_xkb_kt_map_entry_iterator_t;
/**
* @brief xcb_xkb_key_type_t
**/
typedef struct xcb_xkb_key_type_t {
uint8_t mods_mask;
uint8_t mods_mods;
uint16_t mods_vmods;
uint8_t numLevels;
uint8_t nMapEntries;
uint8_t hasPreserve;
uint8_t pad0;
} xcb_xkb_key_type_t;
/**
* @brief xcb_xkb_key_type_iterator_t
**/
typedef struct xcb_xkb_key_type_iterator_t {
xcb_xkb_key_type_t *data;
int rem;
int index;
} xcb_xkb_key_type_iterator_t;
/**
* @brief xcb_xkb_key_sym_map_t
**/
typedef struct xcb_xkb_key_sym_map_t {
uint8_t kt_index[4];
uint8_t groupInfo;
uint8_t width;
uint16_t nSyms;
} xcb_xkb_key_sym_map_t;
/**
* @brief xcb_xkb_key_sym_map_iterator_t
**/
typedef struct xcb_xkb_key_sym_map_iterator_t {
xcb_xkb_key_sym_map_t *data;
int rem;
int index;
} xcb_xkb_key_sym_map_iterator_t;
/**
* @brief xcb_xkb_common_behavior_t
**/
typedef struct xcb_xkb_common_behavior_t {
uint8_t type;
uint8_t data;
} xcb_xkb_common_behavior_t;
/**
* @brief xcb_xkb_common_behavior_iterator_t
**/
typedef struct xcb_xkb_common_behavior_iterator_t {
xcb_xkb_common_behavior_t *data;
int rem;
int index;
} xcb_xkb_common_behavior_iterator_t;
/**
* @brief xcb_xkb_default_behavior_t
**/
typedef struct xcb_xkb_default_behavior_t {
uint8_t type;
uint8_t pad0;
} xcb_xkb_default_behavior_t;
/**
* @brief xcb_xkb_default_behavior_iterator_t
**/
typedef struct xcb_xkb_default_behavior_iterator_t {
xcb_xkb_default_behavior_t *data;
int rem;
int index;
} xcb_xkb_default_behavior_iterator_t;
/**
* @brief xcb_xkb_lock_behavior_t
**/
typedef struct xcb_xkb_lock_behavior_t {
uint8_t type;
uint8_t pad0;
} xcb_xkb_lock_behavior_t;
/**
* @brief xcb_xkb_lock_behavior_iterator_t
**/
typedef struct xcb_xkb_lock_behavior_iterator_t {
xcb_xkb_lock_behavior_t *data;
int rem;
int index;
} xcb_xkb_lock_behavior_iterator_t;
/**
* @brief xcb_xkb_radio_group_behavior_t
**/
typedef struct xcb_xkb_radio_group_behavior_t {
uint8_t type;
uint8_t group;
} xcb_xkb_radio_group_behavior_t;
/**
* @brief xcb_xkb_radio_group_behavior_iterator_t
**/
typedef struct xcb_xkb_radio_group_behavior_iterator_t {
xcb_xkb_radio_group_behavior_t *data;
int rem;
int index;
} xcb_xkb_radio_group_behavior_iterator_t;
/**
* @brief xcb_xkb_overlay_behavior_t
**/
typedef struct xcb_xkb_overlay_behavior_t {
uint8_t type;
xcb_keycode_t key;
} xcb_xkb_overlay_behavior_t;
/**
* @brief xcb_xkb_overlay_behavior_iterator_t
**/
typedef struct xcb_xkb_overlay_behavior_iterator_t {
xcb_xkb_overlay_behavior_t *data;
int rem;
int index;
} xcb_xkb_overlay_behavior_iterator_t;
/**
* @brief xcb_xkb_permament_lock_behavior_t
**/
typedef struct xcb_xkb_permament_lock_behavior_t {
uint8_t type;
uint8_t pad0;
} xcb_xkb_permament_lock_behavior_t;
/**
* @brief xcb_xkb_permament_lock_behavior_iterator_t
**/
typedef struct xcb_xkb_permament_lock_behavior_iterator_t {
xcb_xkb_permament_lock_behavior_t *data;
int rem;
int index;
} xcb_xkb_permament_lock_behavior_iterator_t;
/**
* @brief xcb_xkb_permament_radio_group_behavior_t
**/
typedef struct xcb_xkb_permament_radio_group_behavior_t {
uint8_t type;
uint8_t group;
} xcb_xkb_permament_radio_group_behavior_t;
/**
* @brief xcb_xkb_permament_radio_group_behavior_iterator_t
**/
typedef struct xcb_xkb_permament_radio_group_behavior_iterator_t {
xcb_xkb_permament_radio_group_behavior_t *data;
int rem;
int index;
} xcb_xkb_permament_radio_group_behavior_iterator_t;
/**
* @brief xcb_xkb_permament_overlay_behavior_t
**/
typedef struct xcb_xkb_permament_overlay_behavior_t {
uint8_t type;
xcb_keycode_t key;
} xcb_xkb_permament_overlay_behavior_t;
/**
* @brief xcb_xkb_permament_overlay_behavior_iterator_t
**/
typedef struct xcb_xkb_permament_overlay_behavior_iterator_t {
xcb_xkb_permament_overlay_behavior_t *data;
int rem;
int index;
} xcb_xkb_permament_overlay_behavior_iterator_t;
/**
* @brief xcb_xkb_behavior_t
**/
typedef union xcb_xkb_behavior_t {
xcb_xkb_common_behavior_t common;
xcb_xkb_default_behavior_t _default;
xcb_xkb_lock_behavior_t lock;
xcb_xkb_radio_group_behavior_t radioGroup;
xcb_xkb_overlay_behavior_t overlay1;
xcb_xkb_overlay_behavior_t overlay2;
xcb_xkb_permament_lock_behavior_t permamentLock;
xcb_xkb_permament_radio_group_behavior_t permamentRadioGroup;
xcb_xkb_permament_overlay_behavior_t permamentOverlay1;
xcb_xkb_permament_overlay_behavior_t permamentOverlay2;
uint8_t type;
} xcb_xkb_behavior_t;
/**
* @brief xcb_xkb_behavior_iterator_t
**/
typedef struct xcb_xkb_behavior_iterator_t {
xcb_xkb_behavior_t *data;
int rem;
int index;
} xcb_xkb_behavior_iterator_t;
typedef enum xcb_xkb_behavior_type_t {
XCB_XKB_BEHAVIOR_TYPE_DEFAULT = 0,
XCB_XKB_BEHAVIOR_TYPE_LOCK = 1,
XCB_XKB_BEHAVIOR_TYPE_RADIO_GROUP = 2,
XCB_XKB_BEHAVIOR_TYPE_OVERLAY_1 = 3,
XCB_XKB_BEHAVIOR_TYPE_OVERLAY_2 = 4,
XCB_XKB_BEHAVIOR_TYPE_PERMAMENT_LOCK = 129,
XCB_XKB_BEHAVIOR_TYPE_PERMAMENT_RADIO_GROUP = 130,
XCB_XKB_BEHAVIOR_TYPE_PERMAMENT_OVERLAY_1 = 131,
XCB_XKB_BEHAVIOR_TYPE_PERMAMENT_OVERLAY_2 = 132
} xcb_xkb_behavior_type_t;
/**
* @brief xcb_xkb_set_behavior_t
**/
typedef struct xcb_xkb_set_behavior_t {
xcb_keycode_t keycode;
xcb_xkb_behavior_t behavior;
uint8_t pad0;
} xcb_xkb_set_behavior_t;
/**
* @brief xcb_xkb_set_behavior_iterator_t
**/
typedef struct xcb_xkb_set_behavior_iterator_t {
xcb_xkb_set_behavior_t *data;
int rem;
int index;
} xcb_xkb_set_behavior_iterator_t;
/**
* @brief xcb_xkb_set_explicit_t
**/
typedef struct xcb_xkb_set_explicit_t {
xcb_keycode_t keycode;
uint8_t explicit;
} xcb_xkb_set_explicit_t;
/**
* @brief xcb_xkb_set_explicit_iterator_t
**/
typedef struct xcb_xkb_set_explicit_iterator_t {
xcb_xkb_set_explicit_t *data;
int rem;
int index;
} xcb_xkb_set_explicit_iterator_t;
/**
* @brief xcb_xkb_key_mod_map_t
**/
typedef struct xcb_xkb_key_mod_map_t {
xcb_keycode_t keycode;
uint8_t mods;
} xcb_xkb_key_mod_map_t;
/**
* @brief xcb_xkb_key_mod_map_iterator_t
**/
typedef struct xcb_xkb_key_mod_map_iterator_t {
xcb_xkb_key_mod_map_t *data;
int rem;
int index;
} xcb_xkb_key_mod_map_iterator_t;
/**
* @brief xcb_xkb_key_v_mod_map_t
**/
typedef struct xcb_xkb_key_v_mod_map_t {
xcb_keycode_t keycode;
uint8_t pad0;
uint16_t vmods;
} xcb_xkb_key_v_mod_map_t;
/**
* @brief xcb_xkb_key_v_mod_map_iterator_t
**/
typedef struct xcb_xkb_key_v_mod_map_iterator_t {
xcb_xkb_key_v_mod_map_t *data;
int rem;
int index;
} xcb_xkb_key_v_mod_map_iterator_t;
/**
* @brief xcb_xkb_kt_set_map_entry_t
**/
typedef struct xcb_xkb_kt_set_map_entry_t {
uint8_t level;
uint8_t realMods;
uint16_t virtualMods;
} xcb_xkb_kt_set_map_entry_t;
/**
* @brief xcb_xkb_kt_set_map_entry_iterator_t
**/
typedef struct xcb_xkb_kt_set_map_entry_iterator_t {
xcb_xkb_kt_set_map_entry_t *data;
int rem;
int index;
} xcb_xkb_kt_set_map_entry_iterator_t;
/**
* @brief xcb_xkb_set_key_type_t
**/
typedef struct xcb_xkb_set_key_type_t {
uint8_t mask;
uint8_t realMods;
uint16_t virtualMods;
uint8_t numLevels;
uint8_t nMapEntries;
uint8_t preserve;
uint8_t pad0;
} xcb_xkb_set_key_type_t;
/**
* @brief xcb_xkb_set_key_type_iterator_t
**/
typedef struct xcb_xkb_set_key_type_iterator_t {
xcb_xkb_set_key_type_t *data;
int rem;
int index;
} xcb_xkb_set_key_type_iterator_t;
typedef char xcb_xkb_string8_t;
/**
* @brief xcb_xkb_string8_iterator_t
**/
typedef struct xcb_xkb_string8_iterator_t {
xcb_xkb_string8_t *data;
int rem;
int index;
} xcb_xkb_string8_iterator_t;
/**
* @brief xcb_xkb_outline_t
**/
typedef struct xcb_xkb_outline_t {
uint8_t nPoints;
uint8_t cornerRadius;
uint8_t pad0[2];
} xcb_xkb_outline_t;
/**
* @brief xcb_xkb_outline_iterator_t
**/
typedef struct xcb_xkb_outline_iterator_t {
xcb_xkb_outline_t *data;
int rem;
int index;
} xcb_xkb_outline_iterator_t;
/**
* @brief xcb_xkb_shape_t
**/
typedef struct xcb_xkb_shape_t {
xcb_atom_t name;
uint8_t nOutlines;
uint8_t primaryNdx;
uint8_t approxNdx;
uint8_t pad0;
} xcb_xkb_shape_t;
/**
* @brief xcb_xkb_shape_iterator_t
**/
typedef struct xcb_xkb_shape_iterator_t {
xcb_xkb_shape_t *data;
int rem;
int index;
} xcb_xkb_shape_iterator_t;
/**
* @brief xcb_xkb_key_t
**/
typedef struct xcb_xkb_key_t {
xcb_xkb_string8_t name[4];
int16_t gap;
uint8_t shapeNdx;
uint8_t colorNdx;
} xcb_xkb_key_t;
/**
* @brief xcb_xkb_key_iterator_t
**/
typedef struct xcb_xkb_key_iterator_t {
xcb_xkb_key_t *data;
int rem;
int index;
} xcb_xkb_key_iterator_t;
/**
* @brief xcb_xkb_overlay_key_t
**/
typedef struct xcb_xkb_overlay_key_t {
xcb_xkb_string8_t over[4];
xcb_xkb_string8_t under[4];
} xcb_xkb_overlay_key_t;
/**
* @brief xcb_xkb_overlay_key_iterator_t
**/
typedef struct xcb_xkb_overlay_key_iterator_t {
xcb_xkb_overlay_key_t *data;
int rem;
int index;
} xcb_xkb_overlay_key_iterator_t;
/**
* @brief xcb_xkb_overlay_row_t
**/
typedef struct xcb_xkb_overlay_row_t {
uint8_t rowUnder;
uint8_t nKeys;
uint8_t pad0[2];
} xcb_xkb_overlay_row_t;
/**
* @brief xcb_xkb_overlay_row_iterator_t
**/
typedef struct xcb_xkb_overlay_row_iterator_t {
xcb_xkb_overlay_row_t *data;
int rem;
int index;
} xcb_xkb_overlay_row_iterator_t;
/**
* @brief xcb_xkb_overlay_t
**/
typedef struct xcb_xkb_overlay_t {
xcb_atom_t name;
uint8_t nRows;
uint8_t pad0[3];
} xcb_xkb_overlay_t;
/**
* @brief xcb_xkb_overlay_iterator_t
**/
typedef struct xcb_xkb_overlay_iterator_t {
xcb_xkb_overlay_t *data;
int rem;
int index;
} xcb_xkb_overlay_iterator_t;
/**
* @brief xcb_xkb_row_t
**/
typedef struct xcb_xkb_row_t {
int16_t top;
int16_t left;
uint8_t nKeys;
uint8_t vertical;
uint8_t pad0[2];
} xcb_xkb_row_t;
/**
* @brief xcb_xkb_row_iterator_t
**/
typedef struct xcb_xkb_row_iterator_t {
xcb_xkb_row_t *data;
int rem;
int index;
} xcb_xkb_row_iterator_t;
typedef enum xcb_xkb_doodad_type_t {
XCB_XKB_DOODAD_TYPE_OUTLINE = 1,
XCB_XKB_DOODAD_TYPE_SOLID = 2,
XCB_XKB_DOODAD_TYPE_TEXT = 3,
XCB_XKB_DOODAD_TYPE_INDICATOR = 4,
XCB_XKB_DOODAD_TYPE_LOGO = 5
} xcb_xkb_doodad_type_t;
/**
* @brief xcb_xkb_listing_t
**/
typedef struct xcb_xkb_listing_t {
uint16_t flags;
uint16_t length;
} xcb_xkb_listing_t;
/**
* @brief xcb_xkb_listing_iterator_t
**/
typedef struct xcb_xkb_listing_iterator_t {
xcb_xkb_listing_t *data;
int rem;
int index;
} xcb_xkb_listing_iterator_t;
/**
* @brief xcb_xkb_device_led_info_t
**/
typedef struct xcb_xkb_device_led_info_t {
xcb_xkb_led_class_spec_t ledClass;
xcb_xkb_id_spec_t ledID;
uint32_t namesPresent;
uint32_t mapsPresent;
uint32_t physIndicators;
uint32_t state;
} xcb_xkb_device_led_info_t;
/**
* @brief xcb_xkb_device_led_info_iterator_t
**/
typedef struct xcb_xkb_device_led_info_iterator_t {
xcb_xkb_device_led_info_t *data;
int rem;
int index;
} xcb_xkb_device_led_info_iterator_t;
typedef enum xcb_xkb_error_t {
XCB_XKB_ERROR_BAD_DEVICE = 255,
XCB_XKB_ERROR_BAD_CLASS = 254,
XCB_XKB_ERROR_BAD_ID = 253
} xcb_xkb_error_t;
/** Opcode for xcb_xkb_keyboard. */
#define XCB_XKB_KEYBOARD 0
/**
* @brief xcb_xkb_keyboard_error_t
**/
typedef struct xcb_xkb_keyboard_error_t {
uint8_t response_type;
uint8_t error_code;
uint16_t sequence;
uint32_t value;
uint16_t minorOpcode;
uint8_t majorOpcode;
uint8_t pad0[21];
} xcb_xkb_keyboard_error_t;
typedef enum xcb_xkb_sa_t {
XCB_XKB_SA_CLEAR_LOCKS = 1,
XCB_XKB_SA_LATCH_TO_LOCK = 2,
XCB_XKB_SA_USE_MOD_MAP_MODS = 4,
XCB_XKB_SA_GROUP_ABSOLUTE = 4
} xcb_xkb_sa_t;
typedef enum xcb_xkb_sa_type_t {
XCB_XKB_SA_TYPE_NO_ACTION = 0,
XCB_XKB_SA_TYPE_SET_MODS = 1,
XCB_XKB_SA_TYPE_LATCH_MODS = 2,
XCB_XKB_SA_TYPE_LOCK_MODS = 3,
XCB_XKB_SA_TYPE_SET_GROUP = 4,
XCB_XKB_SA_TYPE_LATCH_GROUP = 5,
XCB_XKB_SA_TYPE_LOCK_GROUP = 6,
XCB_XKB_SA_TYPE_MOVE_PTR = 7,
XCB_XKB_SA_TYPE_PTR_BTN = 8,
XCB_XKB_SA_TYPE_LOCK_PTR_BTN = 9,
XCB_XKB_SA_TYPE_SET_PTR_DFLT = 10,
XCB_XKB_SA_TYPE_ISO_LOCK = 11,
XCB_XKB_SA_TYPE_TERMINATE = 12,
XCB_XKB_SA_TYPE_SWITCH_SCREEN = 13,
XCB_XKB_SA_TYPE_SET_CONTROLS = 14,
XCB_XKB_SA_TYPE_LOCK_CONTROLS = 15,
XCB_XKB_SA_TYPE_ACTION_MESSAGE = 16,
XCB_XKB_SA_TYPE_REDIRECT_KEY = 17,
XCB_XKB_SA_TYPE_DEVICE_BTN = 18,
XCB_XKB_SA_TYPE_LOCK_DEVICE_BTN = 19,
XCB_XKB_SA_TYPE_DEVICE_VALUATOR = 20
} xcb_xkb_sa_type_t;
/**
* @brief xcb_xkb_sa_no_action_t
**/
typedef struct xcb_xkb_sa_no_action_t {
uint8_t type;
uint8_t pad0[7];
} xcb_xkb_sa_no_action_t;
/**
* @brief xcb_xkb_sa_no_action_iterator_t
**/
typedef struct xcb_xkb_sa_no_action_iterator_t {
xcb_xkb_sa_no_action_t *data;
int rem;
int index;
} xcb_xkb_sa_no_action_iterator_t;
/**
* @brief xcb_xkb_sa_set_mods_t
**/
typedef struct xcb_xkb_sa_set_mods_t {
uint8_t type;
uint8_t flags;
uint8_t mask;
uint8_t realMods;
uint8_t vmodsHigh;
uint8_t vmodsLow;
uint8_t pad0[2];
} xcb_xkb_sa_set_mods_t;
/**
* @brief xcb_xkb_sa_set_mods_iterator_t
**/
typedef struct xcb_xkb_sa_set_mods_iterator_t {
xcb_xkb_sa_set_mods_t *data;
int rem;
int index;
} xcb_xkb_sa_set_mods_iterator_t;
/**
* @brief xcb_xkb_sa_latch_mods_t
**/
typedef struct xcb_xkb_sa_latch_mods_t {
uint8_t type;
uint8_t flags;
uint8_t mask;
uint8_t realMods;
uint8_t vmodsHigh;
uint8_t vmodsLow;
uint8_t pad0[2];
} xcb_xkb_sa_latch_mods_t;
/**
* @brief xcb_xkb_sa_latch_mods_iterator_t
**/
typedef struct xcb_xkb_sa_latch_mods_iterator_t {
xcb_xkb_sa_latch_mods_t *data;
int rem;
int index;
} xcb_xkb_sa_latch_mods_iterator_t;
/**
* @brief xcb_xkb_sa_lock_mods_t
**/
typedef struct xcb_xkb_sa_lock_mods_t {
uint8_t type;
uint8_t flags;
uint8_t mask;
uint8_t realMods;
uint8_t vmodsHigh;
uint8_t vmodsLow;
uint8_t pad0[2];
} xcb_xkb_sa_lock_mods_t;
/**
* @brief xcb_xkb_sa_lock_mods_iterator_t
**/
typedef struct xcb_xkb_sa_lock_mods_iterator_t {
xcb_xkb_sa_lock_mods_t *data;
int rem;
int index;
} xcb_xkb_sa_lock_mods_iterator_t;
/**
* @brief xcb_xkb_sa_set_group_t
**/
typedef struct xcb_xkb_sa_set_group_t {
uint8_t type;
uint8_t flags;
int8_t group;
uint8_t pad0[5];
} xcb_xkb_sa_set_group_t;
/**
* @brief xcb_xkb_sa_set_group_iterator_t
**/
typedef struct xcb_xkb_sa_set_group_iterator_t {
xcb_xkb_sa_set_group_t *data;
int rem;
int index;
} xcb_xkb_sa_set_group_iterator_t;
/**
* @brief xcb_xkb_sa_latch_group_t
**/
typedef struct xcb_xkb_sa_latch_group_t {
uint8_t type;
uint8_t flags;
int8_t group;
uint8_t pad0[5];
} xcb_xkb_sa_latch_group_t;
/**
* @brief xcb_xkb_sa_latch_group_iterator_t
**/
typedef struct xcb_xkb_sa_latch_group_iterator_t {
xcb_xkb_sa_latch_group_t *data;
int rem;
int index;
} xcb_xkb_sa_latch_group_iterator_t;
/**
* @brief xcb_xkb_sa_lock_group_t
**/
typedef struct xcb_xkb_sa_lock_group_t {
uint8_t type;
uint8_t flags;
int8_t group;
uint8_t pad0[5];
} xcb_xkb_sa_lock_group_t;
/**
* @brief xcb_xkb_sa_lock_group_iterator_t
**/
typedef struct xcb_xkb_sa_lock_group_iterator_t {
xcb_xkb_sa_lock_group_t *data;
int rem;
int index;
} xcb_xkb_sa_lock_group_iterator_t;
typedef enum xcb_xkb_sa_move_ptr_flag_t {
XCB_XKB_SA_MOVE_PTR_FLAG_NO_ACCELERATION = 1,
XCB_XKB_SA_MOVE_PTR_FLAG_MOVE_ABSOLUTE_X = 2,
XCB_XKB_SA_MOVE_PTR_FLAG_MOVE_ABSOLUTE_Y = 4
} xcb_xkb_sa_move_ptr_flag_t;
/**
* @brief xcb_xkb_sa_move_ptr_t
**/
typedef struct xcb_xkb_sa_move_ptr_t {
uint8_t type;
uint8_t flags;
int8_t xHigh;
uint8_t xLow;
int8_t yHigh;
uint8_t yLow;
uint8_t pad0[2];
} xcb_xkb_sa_move_ptr_t;
/**
* @brief xcb_xkb_sa_move_ptr_iterator_t
**/
typedef struct xcb_xkb_sa_move_ptr_iterator_t {
xcb_xkb_sa_move_ptr_t *data;
int rem;
int index;
} xcb_xkb_sa_move_ptr_iterator_t;
/**
* @brief xcb_xkb_sa_ptr_btn_t
**/
typedef struct xcb_xkb_sa_ptr_btn_t {
uint8_t type;
uint8_t flags;
uint8_t count;
uint8_t button;
uint8_t pad0[4];
} xcb_xkb_sa_ptr_btn_t;
/**
* @brief xcb_xkb_sa_ptr_btn_iterator_t
**/
typedef struct xcb_xkb_sa_ptr_btn_iterator_t {
xcb_xkb_sa_ptr_btn_t *data;
int rem;
int index;
} xcb_xkb_sa_ptr_btn_iterator_t;
/**
* @brief xcb_xkb_sa_lock_ptr_btn_t
**/
typedef struct xcb_xkb_sa_lock_ptr_btn_t {
uint8_t type;
uint8_t flags;
uint8_t pad0;
uint8_t button;
uint8_t pad1[4];
} xcb_xkb_sa_lock_ptr_btn_t;
/**
* @brief xcb_xkb_sa_lock_ptr_btn_iterator_t
**/
typedef struct xcb_xkb_sa_lock_ptr_btn_iterator_t {
xcb_xkb_sa_lock_ptr_btn_t *data;
int rem;
int index;
} xcb_xkb_sa_lock_ptr_btn_iterator_t;
typedef enum xcb_xkb_sa_set_ptr_dflt_flag_t {
XCB_XKB_SA_SET_PTR_DFLT_FLAG_DFLT_BTN_ABSOLUTE = 4,
XCB_XKB_SA_SET_PTR_DFLT_FLAG_AFFECT_DFLT_BUTTON = 1
} xcb_xkb_sa_set_ptr_dflt_flag_t;
/**
* @brief xcb_xkb_sa_set_ptr_dflt_t
**/
typedef struct xcb_xkb_sa_set_ptr_dflt_t {
uint8_t type;
uint8_t flags;
uint8_t affect;
int8_t value;
uint8_t pad0[4];
} xcb_xkb_sa_set_ptr_dflt_t;
/**
* @brief xcb_xkb_sa_set_ptr_dflt_iterator_t
**/
typedef struct xcb_xkb_sa_set_ptr_dflt_iterator_t {
xcb_xkb_sa_set_ptr_dflt_t *data;
int rem;
int index;
} xcb_xkb_sa_set_ptr_dflt_iterator_t;
typedef enum xcb_xkb_sa_iso_lock_flag_t {
XCB_XKB_SA_ISO_LOCK_FLAG_NO_LOCK = 1,
XCB_XKB_SA_ISO_LOCK_FLAG_NO_UNLOCK = 2,
XCB_XKB_SA_ISO_LOCK_FLAG_USE_MOD_MAP_MODS = 4,
XCB_XKB_SA_ISO_LOCK_FLAG_GROUP_ABSOLUTE = 4,
XCB_XKB_SA_ISO_LOCK_FLAG_ISO_DFLT_IS_GROUP = 8
} xcb_xkb_sa_iso_lock_flag_t;
typedef enum xcb_xkb_sa_iso_lock_no_affect_t {
XCB_XKB_SA_ISO_LOCK_NO_AFFECT_CTRLS = 8,
XCB_XKB_SA_ISO_LOCK_NO_AFFECT_PTR = 16,
XCB_XKB_SA_ISO_LOCK_NO_AFFECT_GROUP = 32,
XCB_XKB_SA_ISO_LOCK_NO_AFFECT_MODS = 64
} xcb_xkb_sa_iso_lock_no_affect_t;
/**
* @brief xcb_xkb_sa_iso_lock_t
**/
typedef struct xcb_xkb_sa_iso_lock_t {
uint8_t type;
uint8_t flags;
uint8_t mask;
uint8_t realMods;
int8_t group;
uint8_t affect;
uint8_t vmodsHigh;
uint8_t vmodsLow;
} xcb_xkb_sa_iso_lock_t;
/**
* @brief xcb_xkb_sa_iso_lock_iterator_t
**/
typedef struct xcb_xkb_sa_iso_lock_iterator_t {
xcb_xkb_sa_iso_lock_t *data;
int rem;
int index;
} xcb_xkb_sa_iso_lock_iterator_t;
/**
* @brief xcb_xkb_sa_terminate_t
**/
typedef struct xcb_xkb_sa_terminate_t {
uint8_t type;
uint8_t pad0[7];
} xcb_xkb_sa_terminate_t;
/**
* @brief xcb_xkb_sa_terminate_iterator_t
**/
typedef struct xcb_xkb_sa_terminate_iterator_t {
xcb_xkb_sa_terminate_t *data;
int rem;
int index;
} xcb_xkb_sa_terminate_iterator_t;
typedef enum xcb_xkb_switch_screen_flag_t {
XCB_XKB_SWITCH_SCREEN_FLAG_APPLICATION = 1,
XCB_XKB_SWITCH_SCREEN_FLAG_ABSOLUTE = 4
} xcb_xkb_switch_screen_flag_t;
/**
* @brief xcb_xkb_sa_switch_screen_t
**/
typedef struct xcb_xkb_sa_switch_screen_t {
uint8_t type;
uint8_t flags;
int8_t newScreen;
uint8_t pad0[5];
} xcb_xkb_sa_switch_screen_t;
/**
* @brief xcb_xkb_sa_switch_screen_iterator_t
**/
typedef struct xcb_xkb_sa_switch_screen_iterator_t {
xcb_xkb_sa_switch_screen_t *data;
int rem;
int index;
} xcb_xkb_sa_switch_screen_iterator_t;
typedef enum xcb_xkb_bool_ctrls_high_t {
XCB_XKB_BOOL_CTRLS_HIGH_ACCESS_X_FEEDBACK = 1,
XCB_XKB_BOOL_CTRLS_HIGH_AUDIBLE_BELL = 2,
XCB_XKB_BOOL_CTRLS_HIGH_OVERLAY_1 = 4,
XCB_XKB_BOOL_CTRLS_HIGH_OVERLAY_2 = 8,
XCB_XKB_BOOL_CTRLS_HIGH_IGNORE_GROUP_LOCK = 16
} xcb_xkb_bool_ctrls_high_t;
typedef enum xcb_xkb_bool_ctrls_low_t {
XCB_XKB_BOOL_CTRLS_LOW_REPEAT_KEYS = 1,
XCB_XKB_BOOL_CTRLS_LOW_SLOW_KEYS = 2,
XCB_XKB_BOOL_CTRLS_LOW_BOUNCE_KEYS = 4,
XCB_XKB_BOOL_CTRLS_LOW_STICKY_KEYS = 8,
XCB_XKB_BOOL_CTRLS_LOW_MOUSE_KEYS = 16,
XCB_XKB_BOOL_CTRLS_LOW_MOUSE_KEYS_ACCEL = 32,
XCB_XKB_BOOL_CTRLS_LOW_ACCESS_X_KEYS = 64,
XCB_XKB_BOOL_CTRLS_LOW_ACCESS_X_TIMEOUT = 128
} xcb_xkb_bool_ctrls_low_t;
/**
* @brief xcb_xkb_sa_set_controls_t
**/
typedef struct xcb_xkb_sa_set_controls_t {
uint8_t type;
uint8_t pad0[3];
uint8_t boolCtrlsHigh;
uint8_t boolCtrlsLow;
uint8_t pad1[2];
} xcb_xkb_sa_set_controls_t;
/**
* @brief xcb_xkb_sa_set_controls_iterator_t
**/
typedef struct xcb_xkb_sa_set_controls_iterator_t {
xcb_xkb_sa_set_controls_t *data;
int rem;
int index;
} xcb_xkb_sa_set_controls_iterator_t;
/**
* @brief xcb_xkb_sa_lock_controls_t
**/
typedef struct xcb_xkb_sa_lock_controls_t {
uint8_t type;
uint8_t pad0[3];
uint8_t boolCtrlsHigh;
uint8_t boolCtrlsLow;
uint8_t pad1[2];
} xcb_xkb_sa_lock_controls_t;
/**
* @brief xcb_xkb_sa_lock_controls_iterator_t
**/
typedef struct xcb_xkb_sa_lock_controls_iterator_t {
xcb_xkb_sa_lock_controls_t *data;
int rem;
int index;
} xcb_xkb_sa_lock_controls_iterator_t;
typedef enum xcb_xkb_action_message_flag_t {
XCB_XKB_ACTION_MESSAGE_FLAG_ON_PRESS = 1,
XCB_XKB_ACTION_MESSAGE_FLAG_ON_RELEASE = 2,
XCB_XKB_ACTION_MESSAGE_FLAG_GEN_KEY_EVENT = 4
} xcb_xkb_action_message_flag_t;
/**
* @brief xcb_xkb_sa_action_message_t
**/
typedef struct xcb_xkb_sa_action_message_t {
uint8_t type;
uint8_t flags;
uint8_t message[6];
} xcb_xkb_sa_action_message_t;
/**
* @brief xcb_xkb_sa_action_message_iterator_t
**/
typedef struct xcb_xkb_sa_action_message_iterator_t {
xcb_xkb_sa_action_message_t *data;
int rem;
int index;
} xcb_xkb_sa_action_message_iterator_t;
/**
* @brief xcb_xkb_sa_redirect_key_t
**/
typedef struct xcb_xkb_sa_redirect_key_t {
uint8_t type;
xcb_keycode_t newkey;
uint8_t mask;
uint8_t realModifiers;
uint8_t vmodsMaskHigh;
uint8_t vmodsMaskLow;
uint8_t vmodsHigh;
uint8_t vmodsLow;
} xcb_xkb_sa_redirect_key_t;
/**
* @brief xcb_xkb_sa_redirect_key_iterator_t
**/
typedef struct xcb_xkb_sa_redirect_key_iterator_t {
xcb_xkb_sa_redirect_key_t *data;
int rem;
int index;
} xcb_xkb_sa_redirect_key_iterator_t;
/**
* @brief xcb_xkb_sa_device_btn_t
**/
typedef struct xcb_xkb_sa_device_btn_t {
uint8_t type;
uint8_t flags;
uint8_t count;
uint8_t button;
uint8_t device;
uint8_t pad0[3];
} xcb_xkb_sa_device_btn_t;
/**
* @brief xcb_xkb_sa_device_btn_iterator_t
**/
typedef struct xcb_xkb_sa_device_btn_iterator_t {
xcb_xkb_sa_device_btn_t *data;
int rem;
int index;
} xcb_xkb_sa_device_btn_iterator_t;
typedef enum xcb_xkb_lock_device_flags_t {
XCB_XKB_LOCK_DEVICE_FLAGS_NO_LOCK = 1,
XCB_XKB_LOCK_DEVICE_FLAGS_NO_UNLOCK = 2
} xcb_xkb_lock_device_flags_t;
/**
* @brief xcb_xkb_sa_lock_device_btn_t
**/
typedef struct xcb_xkb_sa_lock_device_btn_t {
uint8_t type;
uint8_t flags;
uint8_t pad0;
uint8_t button;
uint8_t device;
uint8_t pad1[3];
} xcb_xkb_sa_lock_device_btn_t;
/**
* @brief xcb_xkb_sa_lock_device_btn_iterator_t
**/
typedef struct xcb_xkb_sa_lock_device_btn_iterator_t {
xcb_xkb_sa_lock_device_btn_t *data;
int rem;
int index;
} xcb_xkb_sa_lock_device_btn_iterator_t;
typedef enum xcb_xkb_sa_val_what_t {
XCB_XKB_SA_VAL_WHAT_IGNORE_VAL = 0,
XCB_XKB_SA_VAL_WHAT_SET_VAL_MIN = 1,
XCB_XKB_SA_VAL_WHAT_SET_VAL_CENTER = 2,
XCB_XKB_SA_VAL_WHAT_SET_VAL_MAX = 3,
XCB_XKB_SA_VAL_WHAT_SET_VAL_RELATIVE = 4,
XCB_XKB_SA_VAL_WHAT_SET_VAL_ABSOLUTE = 5
} xcb_xkb_sa_val_what_t;
/**
* @brief xcb_xkb_sa_device_valuator_t
**/
typedef struct xcb_xkb_sa_device_valuator_t {
uint8_t type;
uint8_t device;
uint8_t val1what;
uint8_t val1index;
uint8_t val1value;
uint8_t val2what;
uint8_t val2index;
uint8_t val2value;
} xcb_xkb_sa_device_valuator_t;
/**
* @brief xcb_xkb_sa_device_valuator_iterator_t
**/
typedef struct xcb_xkb_sa_device_valuator_iterator_t {
xcb_xkb_sa_device_valuator_t *data;
int rem;
int index;
} xcb_xkb_sa_device_valuator_iterator_t;
/**
* @brief xcb_xkb_si_action_t
**/
typedef struct xcb_xkb_si_action_t {
uint8_t type;
uint8_t data[7];
} xcb_xkb_si_action_t;
/**
* @brief xcb_xkb_si_action_iterator_t
**/
typedef struct xcb_xkb_si_action_iterator_t {
xcb_xkb_si_action_t *data;
int rem;
int index;
} xcb_xkb_si_action_iterator_t;
/**
* @brief xcb_xkb_sym_interpret_t
**/
typedef struct xcb_xkb_sym_interpret_t {
xcb_keysym_t sym;
uint8_t mods;
uint8_t match;
uint8_t virtualMod;
uint8_t flags;
xcb_xkb_si_action_t action;
} xcb_xkb_sym_interpret_t;
/**
* @brief xcb_xkb_sym_interpret_iterator_t
**/
typedef struct xcb_xkb_sym_interpret_iterator_t {
xcb_xkb_sym_interpret_t *data;
int rem;
int index;
} xcb_xkb_sym_interpret_iterator_t;
/**
* @brief xcb_xkb_action_t
**/
typedef union xcb_xkb_action_t {
xcb_xkb_sa_no_action_t noaction;
xcb_xkb_sa_set_mods_t setmods;
xcb_xkb_sa_latch_mods_t latchmods;
xcb_xkb_sa_lock_mods_t lockmods;
xcb_xkb_sa_set_group_t setgroup;
xcb_xkb_sa_latch_group_t latchgroup;
xcb_xkb_sa_lock_group_t lockgroup;
xcb_xkb_sa_move_ptr_t moveptr;
xcb_xkb_sa_ptr_btn_t ptrbtn;
xcb_xkb_sa_lock_ptr_btn_t lockptrbtn;
xcb_xkb_sa_set_ptr_dflt_t setptrdflt;
xcb_xkb_sa_iso_lock_t isolock;
xcb_xkb_sa_terminate_t terminate;
xcb_xkb_sa_switch_screen_t switchscreen;
xcb_xkb_sa_set_controls_t setcontrols;
xcb_xkb_sa_lock_controls_t lockcontrols;
xcb_xkb_sa_action_message_t message;
xcb_xkb_sa_redirect_key_t redirect;
xcb_xkb_sa_device_btn_t devbtn;
xcb_xkb_sa_lock_device_btn_t lockdevbtn;
xcb_xkb_sa_device_valuator_t devval;
uint8_t type;
} xcb_xkb_action_t;
/**
* @brief xcb_xkb_action_iterator_t
**/
typedef struct xcb_xkb_action_iterator_t {
xcb_xkb_action_t *data;
int rem;
int index;
} xcb_xkb_action_iterator_t;
/**
* @brief xcb_xkb_use_extension_cookie_t
**/
typedef struct xcb_xkb_use_extension_cookie_t {
unsigned int sequence;
} xcb_xkb_use_extension_cookie_t;
/** Opcode for xcb_xkb_use_extension. */
#define XCB_XKB_USE_EXTENSION 0
/**
* @brief xcb_xkb_use_extension_request_t
**/
typedef struct xcb_xkb_use_extension_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint16_t wantedMajor;
uint16_t wantedMinor;
} xcb_xkb_use_extension_request_t;
/**
* @brief xcb_xkb_use_extension_reply_t
**/
typedef struct xcb_xkb_use_extension_reply_t {
uint8_t response_type;
uint8_t supported;
uint16_t sequence;
uint32_t length;
uint16_t serverMajor;
uint16_t serverMinor;
uint8_t pad0[20];
} xcb_xkb_use_extension_reply_t;
/**
* @brief xcb_xkb_select_events_details_t
**/
typedef struct xcb_xkb_select_events_details_t {
uint16_t affectNewKeyboard;
uint16_t newKeyboardDetails;
uint16_t affectState;
uint16_t stateDetails;
uint32_t affectCtrls;
uint32_t ctrlDetails;
uint32_t affectIndicatorState;
uint32_t indicatorStateDetails;
uint32_t affectIndicatorMap;
uint32_t indicatorMapDetails;
uint16_t affectNames;
uint16_t namesDetails;
uint8_t affectCompat;
uint8_t compatDetails;
uint8_t affectBell;
uint8_t bellDetails;
uint8_t affectMsgDetails;
uint8_t msgDetails;
uint16_t affectAccessX;
uint16_t accessXDetails;
uint16_t affectExtDev;
uint16_t extdevDetails;
} xcb_xkb_select_events_details_t;
/** Opcode for xcb_xkb_select_events. */
#define XCB_XKB_SELECT_EVENTS 1
/**
* @brief xcb_xkb_select_events_request_t
**/
typedef struct xcb_xkb_select_events_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xkb_device_spec_t deviceSpec;
uint16_t affectWhich;
uint16_t clear;
uint16_t selectAll;
uint16_t affectMap;
uint16_t map;
} xcb_xkb_select_events_request_t;
/** Opcode for xcb_xkb_bell. */
#define XCB_XKB_BELL 3
/**
* @brief xcb_xkb_bell_request_t
**/
typedef struct xcb_xkb_bell_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xkb_device_spec_t deviceSpec;
xcb_xkb_bell_class_spec_t bellClass;
xcb_xkb_id_spec_t bellID;
int8_t percent;
uint8_t forceSound;
uint8_t eventOnly;
uint8_t pad0;
int16_t pitch;
int16_t duration;
uint8_t pad1[2];
xcb_atom_t name;
xcb_window_t window;
} xcb_xkb_bell_request_t;
/**
* @brief xcb_xkb_get_state_cookie_t
**/
typedef struct xcb_xkb_get_state_cookie_t {
unsigned int sequence;
} xcb_xkb_get_state_cookie_t;
/** Opcode for xcb_xkb_get_state. */
#define XCB_XKB_GET_STATE 4
/**
* @brief xcb_xkb_get_state_request_t
**/
typedef struct xcb_xkb_get_state_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xkb_device_spec_t deviceSpec;
uint8_t pad0[2];
} xcb_xkb_get_state_request_t;
/**
* @brief xcb_xkb_get_state_reply_t
**/
typedef struct xcb_xkb_get_state_reply_t {
uint8_t response_type;
uint8_t deviceID;
uint16_t sequence;
uint32_t length;
uint8_t mods;
uint8_t baseMods;
uint8_t latchedMods;
uint8_t lockedMods;
uint8_t group;
uint8_t lockedGroup;
int16_t baseGroup;
int16_t latchedGroup;
uint8_t compatState;
uint8_t grabMods;
uint8_t compatGrabMods;
uint8_t lookupMods;
uint8_t compatLookupMods;
uint8_t pad0;
uint16_t ptrBtnState;
uint8_t pad1[6];
} xcb_xkb_get_state_reply_t;
/** Opcode for xcb_xkb_latch_lock_state. */
#define XCB_XKB_LATCH_LOCK_STATE 5
/**
* @brief xcb_xkb_latch_lock_state_request_t
**/
typedef struct xcb_xkb_latch_lock_state_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xkb_device_spec_t deviceSpec;
uint8_t affectModLocks;
uint8_t modLocks;
uint8_t lockGroup;
uint8_t groupLock;
uint8_t affectModLatches;
uint8_t pad0;
uint8_t pad1;
uint8_t latchGroup;
uint16_t groupLatch;
} xcb_xkb_latch_lock_state_request_t;
/**
* @brief xcb_xkb_get_controls_cookie_t
**/
typedef struct xcb_xkb_get_controls_cookie_t {
unsigned int sequence;
} xcb_xkb_get_controls_cookie_t;
/** Opcode for xcb_xkb_get_controls. */
#define XCB_XKB_GET_CONTROLS 6
/**
* @brief xcb_xkb_get_controls_request_t
**/
typedef struct xcb_xkb_get_controls_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xkb_device_spec_t deviceSpec;
uint8_t pad0[2];
} xcb_xkb_get_controls_request_t;
/**
* @brief xcb_xkb_get_controls_reply_t
**/
typedef struct xcb_xkb_get_controls_reply_t {
uint8_t response_type;
uint8_t deviceID;
uint16_t sequence;
uint32_t length;
uint8_t mouseKeysDfltBtn;
uint8_t numGroups;
uint8_t groupsWrap;
uint8_t internalModsMask;
uint8_t ignoreLockModsMask;
uint8_t internalModsRealMods;
uint8_t ignoreLockModsRealMods;
uint8_t pad0;
uint16_t internalModsVmods;
uint16_t ignoreLockModsVmods;
uint16_t repeatDelay;
uint16_t repeatInterval;
uint16_t slowKeysDelay;
uint16_t debounceDelay;
uint16_t mouseKeysDelay;
uint16_t mouseKeysInterval;
uint16_t mouseKeysTimeToMax;
uint16_t mouseKeysMaxSpeed;
int16_t mouseKeysCurve;
uint16_t accessXOption;
uint16_t accessXTimeout;
uint16_t accessXTimeoutOptionsMask;
uint16_t accessXTimeoutOptionsValues;
uint8_t pad1[2];
uint32_t accessXTimeoutMask;
uint32_t accessXTimeoutValues;
uint32_t enabledControls;
uint8_t perKeyRepeat[32];
} xcb_xkb_get_controls_reply_t;
/** Opcode for xcb_xkb_set_controls. */
#define XCB_XKB_SET_CONTROLS 7
/**
* @brief xcb_xkb_set_controls_request_t
**/
typedef struct xcb_xkb_set_controls_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xkb_device_spec_t deviceSpec;
uint8_t affectInternalRealMods;
uint8_t internalRealMods;
uint8_t affectIgnoreLockRealMods;
uint8_t ignoreLockRealMods;
uint16_t affectInternalVirtualMods;
uint16_t internalVirtualMods;
uint16_t affectIgnoreLockVirtualMods;
uint16_t ignoreLockVirtualMods;
uint8_t mouseKeysDfltBtn;
uint8_t groupsWrap;
uint16_t accessXOptions;
uint8_t pad0[2];
uint32_t affectEnabledControls;
uint32_t enabledControls;
uint32_t changeControls;
uint16_t repeatDelay;
uint16_t repeatInterval;
uint16_t slowKeysDelay;
uint16_t debounceDelay;
uint16_t mouseKeysDelay;
uint16_t mouseKeysInterval;
uint16_t mouseKeysTimeToMax;
uint16_t mouseKeysMaxSpeed;
int16_t mouseKeysCurve;
uint16_t accessXTimeout;
uint32_t accessXTimeoutMask;
uint32_t accessXTimeoutValues;
uint16_t accessXTimeoutOptionsMask;
uint16_t accessXTimeoutOptionsValues;
uint8_t perKeyRepeat[32];
} xcb_xkb_set_controls_request_t;
/**
* @brief xcb_xkb_get_map_cookie_t
**/
typedef struct xcb_xkb_get_map_cookie_t {
unsigned int sequence;
} xcb_xkb_get_map_cookie_t;
/** Opcode for xcb_xkb_get_map. */
#define XCB_XKB_GET_MAP 8
/**
* @brief xcb_xkb_get_map_request_t
**/
typedef struct xcb_xkb_get_map_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xkb_device_spec_t deviceSpec;
uint16_t full;
uint16_t partial;
uint8_t firstType;
uint8_t nTypes;
xcb_keycode_t firstKeySym;
uint8_t nKeySyms;
xcb_keycode_t firstKeyAction;
uint8_t nKeyActions;
xcb_keycode_t firstKeyBehavior;
uint8_t nKeyBehaviors;
uint16_t virtualMods;
xcb_keycode_t firstKeyExplicit;
uint8_t nKeyExplicit;
xcb_keycode_t firstModMapKey;
uint8_t nModMapKeys;
xcb_keycode_t firstVModMapKey;
uint8_t nVModMapKeys;
uint8_t pad0[2];
} xcb_xkb_get_map_request_t;
/**
* @brief xcb_xkb_get_map_map_t
**/
typedef struct xcb_xkb_get_map_map_t {
xcb_xkb_key_type_t *types_rtrn;
xcb_xkb_key_sym_map_t *syms_rtrn;
uint8_t *acts_rtrn_count;
uint8_t *pad2;
xcb_xkb_action_t *acts_rtrn_acts;
xcb_xkb_set_behavior_t *behaviors_rtrn;
uint8_t *vmods_rtrn;
uint8_t *pad3;
xcb_xkb_set_explicit_t *explicit_rtrn;
uint8_t *pad4;
xcb_xkb_key_mod_map_t *modmap_rtrn;
uint8_t *pad5;
xcb_xkb_key_v_mod_map_t *vmodmap_rtrn;
} xcb_xkb_get_map_map_t;
/**
* @brief xcb_xkb_get_map_reply_t
**/
typedef struct xcb_xkb_get_map_reply_t {
uint8_t response_type;
uint8_t deviceID;
uint16_t sequence;
uint32_t length;
uint8_t pad0[2];
xcb_keycode_t minKeyCode;
xcb_keycode_t maxKeyCode;
uint16_t present;
uint8_t firstType;
uint8_t nTypes;
uint8_t totalTypes;
xcb_keycode_t firstKeySym;
uint16_t totalSyms;
uint8_t nKeySyms;
xcb_keycode_t firstKeyAction;
uint16_t totalActions;
uint8_t nKeyActions;
xcb_keycode_t firstKeyBehavior;
uint8_t nKeyBehaviors;
uint8_t totalKeyBehaviors;
xcb_keycode_t firstKeyExplicit;
uint8_t nKeyExplicit;
uint8_t totalKeyExplicit;
xcb_keycode_t firstModMapKey;
uint8_t nModMapKeys;
uint8_t totalModMapKeys;
xcb_keycode_t firstVModMapKey;
uint8_t nVModMapKeys;
uint8_t totalVModMapKeys;
uint8_t pad1;
uint16_t virtualMods;
} xcb_xkb_get_map_reply_t;
/**
* @brief xcb_xkb_set_map_values_t
**/
typedef struct xcb_xkb_set_map_values_t {
xcb_xkb_set_key_type_t *types;
xcb_xkb_key_sym_map_t *syms;
uint8_t *actionsCount;
xcb_xkb_action_t *actions;
xcb_xkb_set_behavior_t *behaviors;
uint8_t *vmods;
xcb_xkb_set_explicit_t *explicit;
xcb_xkb_key_mod_map_t *modmap;
xcb_xkb_key_v_mod_map_t *vmodmap;
} xcb_xkb_set_map_values_t;
/** Opcode for xcb_xkb_set_map. */
#define XCB_XKB_SET_MAP 9
/**
* @brief xcb_xkb_set_map_request_t
**/
typedef struct xcb_xkb_set_map_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xkb_device_spec_t deviceSpec;
uint16_t present;
uint16_t flags;
xcb_keycode_t minKeyCode;
xcb_keycode_t maxKeyCode;
uint8_t firstType;
uint8_t nTypes;
xcb_keycode_t firstKeySym;
uint8_t nKeySyms;
uint16_t totalSyms;
xcb_keycode_t firstKeyAction;
uint8_t nKeyActions;
uint16_t totalActions;
xcb_keycode_t firstKeyBehavior;
uint8_t nKeyBehaviors;
uint8_t totalKeyBehaviors;
xcb_keycode_t firstKeyExplicit;
uint8_t nKeyExplicit;
uint8_t totalKeyExplicit;
xcb_keycode_t firstModMapKey;
uint8_t nModMapKeys;
uint8_t totalModMapKeys;
xcb_keycode_t firstVModMapKey;
uint8_t nVModMapKeys;
uint8_t totalVModMapKeys;
uint16_t virtualMods;
} xcb_xkb_set_map_request_t;
/**
* @brief xcb_xkb_get_compat_map_cookie_t
**/
typedef struct xcb_xkb_get_compat_map_cookie_t {
unsigned int sequence;
} xcb_xkb_get_compat_map_cookie_t;
/** Opcode for xcb_xkb_get_compat_map. */
#define XCB_XKB_GET_COMPAT_MAP 10
/**
* @brief xcb_xkb_get_compat_map_request_t
**/
typedef struct xcb_xkb_get_compat_map_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xkb_device_spec_t deviceSpec;
uint8_t groups;
uint8_t getAllSI;
uint16_t firstSI;
uint16_t nSI;
} xcb_xkb_get_compat_map_request_t;
/**
* @brief xcb_xkb_get_compat_map_reply_t
**/
typedef struct xcb_xkb_get_compat_map_reply_t {
uint8_t response_type;
uint8_t deviceID;
uint16_t sequence;
uint32_t length;
uint8_t groupsRtrn;
uint8_t pad0;
uint16_t firstSIRtrn;
uint16_t nSIRtrn;
uint16_t nTotalSI;
uint8_t pad1[16];
} xcb_xkb_get_compat_map_reply_t;
/** Opcode for xcb_xkb_set_compat_map. */
#define XCB_XKB_SET_COMPAT_MAP 11
/**
* @brief xcb_xkb_set_compat_map_request_t
**/
typedef struct xcb_xkb_set_compat_map_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xkb_device_spec_t deviceSpec;
uint8_t pad0;
uint8_t recomputeActions;
uint8_t truncateSI;
uint8_t groups;
uint16_t firstSI;
uint16_t nSI;
uint8_t pad1[2];
} xcb_xkb_set_compat_map_request_t;
/**
* @brief xcb_xkb_get_indicator_state_cookie_t
**/
typedef struct xcb_xkb_get_indicator_state_cookie_t {
unsigned int sequence;
} xcb_xkb_get_indicator_state_cookie_t;
/** Opcode for xcb_xkb_get_indicator_state. */
#define XCB_XKB_GET_INDICATOR_STATE 12
/**
* @brief xcb_xkb_get_indicator_state_request_t
**/
typedef struct xcb_xkb_get_indicator_state_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xkb_device_spec_t deviceSpec;
uint8_t pad0[2];
} xcb_xkb_get_indicator_state_request_t;
/**
* @brief xcb_xkb_get_indicator_state_reply_t
**/
typedef struct xcb_xkb_get_indicator_state_reply_t {
uint8_t response_type;
uint8_t deviceID;
uint16_t sequence;
uint32_t length;
uint32_t state;
uint8_t pad0[20];
} xcb_xkb_get_indicator_state_reply_t;
/**
* @brief xcb_xkb_get_indicator_map_cookie_t
**/
typedef struct xcb_xkb_get_indicator_map_cookie_t {
unsigned int sequence;
} xcb_xkb_get_indicator_map_cookie_t;
/** Opcode for xcb_xkb_get_indicator_map. */
#define XCB_XKB_GET_INDICATOR_MAP 13
/**
* @brief xcb_xkb_get_indicator_map_request_t
**/
typedef struct xcb_xkb_get_indicator_map_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xkb_device_spec_t deviceSpec;
uint8_t pad0[2];
uint32_t which;
} xcb_xkb_get_indicator_map_request_t;
/**
* @brief xcb_xkb_get_indicator_map_reply_t
**/
typedef struct xcb_xkb_get_indicator_map_reply_t {
uint8_t response_type;
uint8_t deviceID;
uint16_t sequence;
uint32_t length;
uint32_t which;
uint32_t realIndicators;
uint8_t nIndicators;
uint8_t pad0[15];
} xcb_xkb_get_indicator_map_reply_t;
/** Opcode for xcb_xkb_set_indicator_map. */
#define XCB_XKB_SET_INDICATOR_MAP 14
/**
* @brief xcb_xkb_set_indicator_map_request_t
**/
typedef struct xcb_xkb_set_indicator_map_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xkb_device_spec_t deviceSpec;
uint8_t pad0[2];
uint32_t which;
} xcb_xkb_set_indicator_map_request_t;
/**
* @brief xcb_xkb_get_named_indicator_cookie_t
**/
typedef struct xcb_xkb_get_named_indicator_cookie_t {
unsigned int sequence;
} xcb_xkb_get_named_indicator_cookie_t;
/** Opcode for xcb_xkb_get_named_indicator. */
#define XCB_XKB_GET_NAMED_INDICATOR 15
/**
* @brief xcb_xkb_get_named_indicator_request_t
**/
typedef struct xcb_xkb_get_named_indicator_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xkb_device_spec_t deviceSpec;
xcb_xkb_led_class_spec_t ledClass;
xcb_xkb_id_spec_t ledID;
uint8_t pad0[2];
xcb_atom_t indicator;
} xcb_xkb_get_named_indicator_request_t;
/**
* @brief xcb_xkb_get_named_indicator_reply_t
**/
typedef struct xcb_xkb_get_named_indicator_reply_t {
uint8_t response_type;
uint8_t deviceID;
uint16_t sequence;
uint32_t length;
xcb_atom_t indicator;
uint8_t found;
uint8_t on;
uint8_t realIndicator;
uint8_t ndx;
uint8_t map_flags;
uint8_t map_whichGroups;
uint8_t map_groups;
uint8_t map_whichMods;
uint8_t map_mods;
uint8_t map_realMods;
uint16_t map_vmod;
uint32_t map_ctrls;
uint8_t supported;
uint8_t pad0[3];
} xcb_xkb_get_named_indicator_reply_t;
/** Opcode for xcb_xkb_set_named_indicator. */
#define XCB_XKB_SET_NAMED_INDICATOR 16
/**
* @brief xcb_xkb_set_named_indicator_request_t
**/
typedef struct xcb_xkb_set_named_indicator_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xkb_device_spec_t deviceSpec;
xcb_xkb_led_class_spec_t ledClass;
xcb_xkb_id_spec_t ledID;
uint8_t pad0[2];
xcb_atom_t indicator;
uint8_t setState;
uint8_t on;
uint8_t setMap;
uint8_t createMap;
uint8_t pad1;
uint8_t map_flags;
uint8_t map_whichGroups;
uint8_t map_groups;
uint8_t map_whichMods;
uint8_t map_realMods;
uint16_t map_vmods;
uint32_t map_ctrls;
} xcb_xkb_set_named_indicator_request_t;
/**
* @brief xcb_xkb_get_names_cookie_t
**/
typedef struct xcb_xkb_get_names_cookie_t {
unsigned int sequence;
} xcb_xkb_get_names_cookie_t;
/** Opcode for xcb_xkb_get_names. */
#define XCB_XKB_GET_NAMES 17
/**
* @brief xcb_xkb_get_names_request_t
**/
typedef struct xcb_xkb_get_names_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xkb_device_spec_t deviceSpec;
uint8_t pad0[2];
uint32_t which;
} xcb_xkb_get_names_request_t;
/**
* @brief xcb_xkb_get_names_value_list_t
**/
typedef struct xcb_xkb_get_names_value_list_t {
xcb_atom_t keycodesName;
xcb_atom_t geometryName;
xcb_atom_t symbolsName;
xcb_atom_t physSymbolsName;
xcb_atom_t typesName;
xcb_atom_t compatName;
xcb_atom_t *typeNames;
uint8_t *nLevelsPerType;
uint8_t *pad1;
xcb_atom_t *ktLevelNames;
xcb_atom_t *indicatorNames;
xcb_atom_t *virtualModNames;
xcb_atom_t *groups;
xcb_xkb_key_name_t *keyNames;
xcb_xkb_key_alias_t *keyAliases;
xcb_atom_t *radioGroupNames;
} xcb_xkb_get_names_value_list_t;
/**
* @brief xcb_xkb_get_names_reply_t
**/
typedef struct xcb_xkb_get_names_reply_t {
uint8_t response_type;
uint8_t deviceID;
uint16_t sequence;
uint32_t length;
uint32_t which;
xcb_keycode_t minKeyCode;
xcb_keycode_t maxKeyCode;
uint8_t nTypes;
uint8_t groupNames;
uint16_t virtualMods;
xcb_keycode_t firstKey;
uint8_t nKeys;
uint32_t indicators;
uint8_t nRadioGroups;
uint8_t nKeyAliases;
uint16_t nKTLevels;
uint8_t pad0[4];
} xcb_xkb_get_names_reply_t;
/**
* @brief xcb_xkb_set_names_values_t
**/
typedef struct xcb_xkb_set_names_values_t {
xcb_atom_t keycodesName;
xcb_atom_t geometryName;
xcb_atom_t symbolsName;
xcb_atom_t physSymbolsName;
xcb_atom_t typesName;
xcb_atom_t compatName;
xcb_atom_t *typeNames;
uint8_t *nLevelsPerType;
xcb_atom_t *ktLevelNames;
xcb_atom_t *indicatorNames;
xcb_atom_t *virtualModNames;
xcb_atom_t *groups;
xcb_xkb_key_name_t *keyNames;
xcb_xkb_key_alias_t *keyAliases;
xcb_atom_t *radioGroupNames;
} xcb_xkb_set_names_values_t;
/** Opcode for xcb_xkb_set_names. */
#define XCB_XKB_SET_NAMES 18
/**
* @brief xcb_xkb_set_names_request_t
**/
typedef struct xcb_xkb_set_names_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xkb_device_spec_t deviceSpec;
uint16_t virtualMods;
uint32_t which;
uint8_t firstType;
uint8_t nTypes;
uint8_t firstKTLevelt;
uint8_t nKTLevels;
uint32_t indicators;
uint8_t groupNames;
uint8_t nRadioGroups;
xcb_keycode_t firstKey;
uint8_t nKeys;
uint8_t nKeyAliases;
uint8_t pad0;
uint16_t totalKTLevelNames;
} xcb_xkb_set_names_request_t;
/**
* @brief xcb_xkb_per_client_flags_cookie_t
**/
typedef struct xcb_xkb_per_client_flags_cookie_t {
unsigned int sequence;
} xcb_xkb_per_client_flags_cookie_t;
/** Opcode for xcb_xkb_per_client_flags. */
#define XCB_XKB_PER_CLIENT_FLAGS 21
/**
* @brief xcb_xkb_per_client_flags_request_t
**/
typedef struct xcb_xkb_per_client_flags_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xkb_device_spec_t deviceSpec;
uint8_t pad0[2];
uint32_t change;
uint32_t value;
uint32_t ctrlsToChange;
uint32_t autoCtrls;
uint32_t autoCtrlsValues;
} xcb_xkb_per_client_flags_request_t;
/**
* @brief xcb_xkb_per_client_flags_reply_t
**/
typedef struct xcb_xkb_per_client_flags_reply_t {
uint8_t response_type;
uint8_t deviceID;
uint16_t sequence;
uint32_t length;
uint32_t supported;
uint32_t value;
uint32_t autoCtrls;
uint32_t autoCtrlsValues;
uint8_t pad0[8];
} xcb_xkb_per_client_flags_reply_t;
/**
* @brief xcb_xkb_list_components_cookie_t
**/
typedef struct xcb_xkb_list_components_cookie_t {
unsigned int sequence;
} xcb_xkb_list_components_cookie_t;
/** Opcode for xcb_xkb_list_components. */
#define XCB_XKB_LIST_COMPONENTS 22
/**
* @brief xcb_xkb_list_components_request_t
**/
typedef struct xcb_xkb_list_components_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xkb_device_spec_t deviceSpec;
uint16_t maxNames;
} xcb_xkb_list_components_request_t;
/**
* @brief xcb_xkb_list_components_reply_t
**/
typedef struct xcb_xkb_list_components_reply_t {
uint8_t response_type;
uint8_t deviceID;
uint16_t sequence;
uint32_t length;
uint16_t nKeymaps;
uint16_t nKeycodes;
uint16_t nTypes;
uint16_t nCompatMaps;
uint16_t nSymbols;
uint16_t nGeometries;
uint16_t extra;
uint8_t pad0[10];
} xcb_xkb_list_components_reply_t;
/**
* @brief xcb_xkb_get_kbd_by_name_cookie_t
**/
typedef struct xcb_xkb_get_kbd_by_name_cookie_t {
unsigned int sequence;
} xcb_xkb_get_kbd_by_name_cookie_t;
/** Opcode for xcb_xkb_get_kbd_by_name. */
#define XCB_XKB_GET_KBD_BY_NAME 23
/**
* @brief xcb_xkb_get_kbd_by_name_request_t
**/
typedef struct xcb_xkb_get_kbd_by_name_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xkb_device_spec_t deviceSpec;
uint16_t need;
uint16_t want;
uint8_t load;
uint8_t pad0;
} xcb_xkb_get_kbd_by_name_request_t;
/**
* @brief xcb_xkb_get_kbd_by_name_replies_types_map_t
**/
typedef struct xcb_xkb_get_kbd_by_name_replies_types_map_t {
xcb_xkb_key_type_t *types_rtrn;
xcb_xkb_key_sym_map_t *syms_rtrn;
uint8_t *acts_rtrn_count;
xcb_xkb_action_t *acts_rtrn_acts;
xcb_xkb_set_behavior_t *behaviors_rtrn;
uint8_t *vmods_rtrn;
xcb_xkb_set_explicit_t *explicit_rtrn;
xcb_xkb_key_mod_map_t *modmap_rtrn;
xcb_xkb_key_v_mod_map_t *vmodmap_rtrn;
} xcb_xkb_get_kbd_by_name_replies_types_map_t;
/**
* @brief xcb_xkb_get_kbd_by_name_replies_key_names_value_list_t
**/
typedef struct xcb_xkb_get_kbd_by_name_replies_key_names_value_list_t {
xcb_atom_t keycodesName;
xcb_atom_t geometryName;
xcb_atom_t symbolsName;
xcb_atom_t physSymbolsName;
xcb_atom_t typesName;
xcb_atom_t compatName;
xcb_atom_t *typeNames;
uint8_t *nLevelsPerType;
xcb_atom_t *ktLevelNames;
xcb_atom_t *indicatorNames;
xcb_atom_t *virtualModNames;
xcb_atom_t *groups;
xcb_xkb_key_name_t *keyNames;
xcb_xkb_key_alias_t *keyAliases;
xcb_atom_t *radioGroupNames;
} xcb_xkb_get_kbd_by_name_replies_key_names_value_list_t;
/**
* @brief xcb_xkb_get_kbd_by_name_replies_t
**/
typedef struct xcb_xkb_get_kbd_by_name_replies_t {
struct {
uint8_t getmap_type;
uint8_t typeDeviceID;
uint16_t getmap_sequence;
uint32_t getmap_length;
uint8_t pad1[2];
xcb_keycode_t typeMinKeyCode;
xcb_keycode_t typeMaxKeyCode;
uint16_t present;
uint8_t firstType;
uint8_t nTypes;
uint8_t totalTypes;
xcb_keycode_t firstKeySym;
uint16_t totalSyms;
uint8_t nKeySyms;
xcb_keycode_t firstKeyAction;
uint16_t totalActions;
uint8_t nKeyActions;
xcb_keycode_t firstKeyBehavior;
uint8_t nKeyBehaviors;
uint8_t totalKeyBehaviors;
xcb_keycode_t firstKeyExplicit;
uint8_t nKeyExplicit;
uint8_t totalKeyExplicit;
xcb_keycode_t firstModMapKey;
uint8_t nModMapKeys;
uint8_t totalModMapKeys;
xcb_keycode_t firstVModMapKey;
uint8_t nVModMapKeys;
uint8_t totalVModMapKeys;
uint8_t pad2;
uint16_t virtualMods;
xcb_xkb_get_kbd_by_name_replies_types_map_t map;
} types;
struct {
uint8_t compatmap_type;
uint8_t compatDeviceID;
uint16_t compatmap_sequence;
uint32_t compatmap_length;
uint8_t groupsRtrn;
uint8_t pad7;
uint16_t firstSIRtrn;
uint16_t nSIRtrn;
uint16_t nTotalSI;
uint8_t pad8[16];
xcb_xkb_sym_interpret_t *si_rtrn;
xcb_xkb_mod_def_t *group_rtrn;
} compat_map;
struct {
uint8_t indicatormap_type;
uint8_t indicatorDeviceID;
uint16_t indicatormap_sequence;
uint32_t indicatormap_length;
uint32_t which;
uint32_t realIndicators;
uint8_t nIndicators;
uint8_t pad9[15];
xcb_xkb_indicator_map_t *maps;
} indicator_maps;
struct {
uint8_t keyname_type;
uint8_t keyDeviceID;
uint16_t keyname_sequence;
uint32_t keyname_length;
uint32_t which;
xcb_keycode_t keyMinKeyCode;
xcb_keycode_t keyMaxKeyCode;
uint8_t nTypes;
uint8_t groupNames;
uint16_t virtualMods;
xcb_keycode_t firstKey;
uint8_t nKeys;
uint32_t indicators;
uint8_t nRadioGroups;
uint8_t nKeyAliases;
uint16_t nKTLevels;
uint8_t pad10[4];
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_t valueList;
} key_names;
struct {
uint8_t geometry_type;
uint8_t geometryDeviceID;
uint16_t geometry_sequence;
uint32_t geometry_length;
xcb_atom_t name;
uint8_t geometryFound;
uint8_t pad12;
uint16_t widthMM;
uint16_t heightMM;
uint16_t nProperties;
uint16_t nColors;
uint16_t nShapes;
uint16_t nSections;
uint16_t nDoodads;
uint16_t nKeyAliases;
uint8_t baseColorNdx;
uint8_t labelColorNdx;
xcb_xkb_counted_string_16_t *labelFont;
} geometry;
} xcb_xkb_get_kbd_by_name_replies_t;
xcb_xkb_get_kbd_by_name_replies_types_map_t *
xcb_xkb_get_kbd_by_name_replies_types_map (const xcb_xkb_get_kbd_by_name_replies_t *R);
/**
* @brief xcb_xkb_get_kbd_by_name_reply_t
**/
typedef struct xcb_xkb_get_kbd_by_name_reply_t {
uint8_t response_type;
uint8_t deviceID;
uint16_t sequence;
uint32_t length;
xcb_keycode_t minKeyCode;
xcb_keycode_t maxKeyCode;
uint8_t loaded;
uint8_t newKeyboard;
uint16_t found;
uint16_t reported;
uint8_t pad0[16];
} xcb_xkb_get_kbd_by_name_reply_t;
/**
* @brief xcb_xkb_get_device_info_cookie_t
**/
typedef struct xcb_xkb_get_device_info_cookie_t {
unsigned int sequence;
} xcb_xkb_get_device_info_cookie_t;
/** Opcode for xcb_xkb_get_device_info. */
#define XCB_XKB_GET_DEVICE_INFO 24
/**
* @brief xcb_xkb_get_device_info_request_t
**/
typedef struct xcb_xkb_get_device_info_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xkb_device_spec_t deviceSpec;
uint16_t wanted;
uint8_t allButtons;
uint8_t firstButton;
uint8_t nButtons;
uint8_t pad0;
xcb_xkb_led_class_spec_t ledClass;
xcb_xkb_id_spec_t ledID;
} xcb_xkb_get_device_info_request_t;
/**
* @brief xcb_xkb_get_device_info_reply_t
**/
typedef struct xcb_xkb_get_device_info_reply_t {
uint8_t response_type;
uint8_t deviceID;
uint16_t sequence;
uint32_t length;
uint16_t present;
uint16_t supported;
uint16_t unsupported;
uint16_t nDeviceLedFBs;
uint8_t firstBtnWanted;
uint8_t nBtnsWanted;
uint8_t firstBtnRtrn;
uint8_t nBtnsRtrn;
uint8_t totalBtns;
uint8_t hasOwnState;
uint16_t dfltKbdFB;
uint16_t dfltLedFB;
uint8_t pad0[2];
xcb_atom_t devType;
uint16_t nameLen;
} xcb_xkb_get_device_info_reply_t;
/** Opcode for xcb_xkb_set_device_info. */
#define XCB_XKB_SET_DEVICE_INFO 25
/**
* @brief xcb_xkb_set_device_info_request_t
**/
typedef struct xcb_xkb_set_device_info_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xkb_device_spec_t deviceSpec;
uint8_t firstBtn;
uint8_t nBtns;
uint16_t change;
uint16_t nDeviceLedFBs;
} xcb_xkb_set_device_info_request_t;
/**
* @brief xcb_xkb_set_debugging_flags_cookie_t
**/
typedef struct xcb_xkb_set_debugging_flags_cookie_t {
unsigned int sequence;
} xcb_xkb_set_debugging_flags_cookie_t;
/** Opcode for xcb_xkb_set_debugging_flags. */
#define XCB_XKB_SET_DEBUGGING_FLAGS 101
/**
* @brief xcb_xkb_set_debugging_flags_request_t
**/
typedef struct xcb_xkb_set_debugging_flags_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint16_t msgLength;
uint8_t pad0[2];
uint32_t affectFlags;
uint32_t flags;
uint32_t affectCtrls;
uint32_t ctrls;
} xcb_xkb_set_debugging_flags_request_t;
/**
* @brief xcb_xkb_set_debugging_flags_reply_t
**/
typedef struct xcb_xkb_set_debugging_flags_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t currentFlags;
uint32_t currentCtrls;
uint32_t supportedFlags;
uint32_t supportedCtrls;
uint8_t pad1[8];
} xcb_xkb_set_debugging_flags_reply_t;
/** Opcode for xcb_xkb_new_keyboard_notify. */
#define XCB_XKB_NEW_KEYBOARD_NOTIFY 0
/**
* @brief xcb_xkb_new_keyboard_notify_event_t
**/
typedef struct xcb_xkb_new_keyboard_notify_event_t {
uint8_t response_type;
uint8_t xkbType;
uint16_t sequence;
xcb_timestamp_t time;
uint8_t deviceID;
uint8_t oldDeviceID;
xcb_keycode_t minKeyCode;
xcb_keycode_t maxKeyCode;
xcb_keycode_t oldMinKeyCode;
xcb_keycode_t oldMaxKeyCode;
uint8_t requestMajor;
uint8_t requestMinor;
uint16_t changed;
uint8_t pad0[14];
} xcb_xkb_new_keyboard_notify_event_t;
/** Opcode for xcb_xkb_map_notify. */
#define XCB_XKB_MAP_NOTIFY 1
/**
* @brief xcb_xkb_map_notify_event_t
**/
typedef struct xcb_xkb_map_notify_event_t {
uint8_t response_type;
uint8_t xkbType;
uint16_t sequence;
xcb_timestamp_t time;
uint8_t deviceID;
uint8_t ptrBtnActions;
uint16_t changed;
xcb_keycode_t minKeyCode;
xcb_keycode_t maxKeyCode;
uint8_t firstType;
uint8_t nTypes;
xcb_keycode_t firstKeySym;
uint8_t nKeySyms;
xcb_keycode_t firstKeyAct;
uint8_t nKeyActs;
xcb_keycode_t firstKeyBehavior;
uint8_t nKeyBehavior;
xcb_keycode_t firstKeyExplicit;
uint8_t nKeyExplicit;
xcb_keycode_t firstModMapKey;
uint8_t nModMapKeys;
xcb_keycode_t firstVModMapKey;
uint8_t nVModMapKeys;
uint16_t virtualMods;
uint8_t pad0[2];
} xcb_xkb_map_notify_event_t;
/** Opcode for xcb_xkb_state_notify. */
#define XCB_XKB_STATE_NOTIFY 2
/**
* @brief xcb_xkb_state_notify_event_t
**/
typedef struct xcb_xkb_state_notify_event_t {
uint8_t response_type;
uint8_t xkbType;
uint16_t sequence;
xcb_timestamp_t time;
uint8_t deviceID;
uint8_t mods;
uint8_t baseMods;
uint8_t latchedMods;
uint8_t lockedMods;
uint8_t group;
int16_t baseGroup;
int16_t latchedGroup;
uint8_t lockedGroup;
uint8_t compatState;
uint8_t grabMods;
uint8_t compatGrabMods;
uint8_t lookupMods;
uint8_t compatLoockupMods;
uint16_t ptrBtnState;
uint16_t changed;
xcb_keycode_t keycode;
uint8_t eventType;
uint8_t requestMajor;
uint8_t requestMinor;
} xcb_xkb_state_notify_event_t;
/** Opcode for xcb_xkb_controls_notify. */
#define XCB_XKB_CONTROLS_NOTIFY 3
/**
* @brief xcb_xkb_controls_notify_event_t
**/
typedef struct xcb_xkb_controls_notify_event_t {
uint8_t response_type;
uint8_t xkbType;
uint16_t sequence;
xcb_timestamp_t time;
uint8_t deviceID;
uint8_t numGroups;
uint8_t pad0[2];
uint32_t changedControls;
uint32_t enabledControls;
uint32_t enabledControlChanges;
xcb_keycode_t keycode;
uint8_t eventType;
uint8_t requestMajor;
uint8_t requestMinor;
uint8_t pad1[4];
} xcb_xkb_controls_notify_event_t;
/** Opcode for xcb_xkb_indicator_state_notify. */
#define XCB_XKB_INDICATOR_STATE_NOTIFY 4
/**
* @brief xcb_xkb_indicator_state_notify_event_t
**/
typedef struct xcb_xkb_indicator_state_notify_event_t {
uint8_t response_type;
uint8_t xkbType;
uint16_t sequence;
xcb_timestamp_t time;
uint8_t deviceID;
uint8_t pad0[3];
uint32_t state;
uint32_t stateChanged;
uint8_t pad1[12];
} xcb_xkb_indicator_state_notify_event_t;
/** Opcode for xcb_xkb_indicator_map_notify. */
#define XCB_XKB_INDICATOR_MAP_NOTIFY 5
/**
* @brief xcb_xkb_indicator_map_notify_event_t
**/
typedef struct xcb_xkb_indicator_map_notify_event_t {
uint8_t response_type;
uint8_t xkbType;
uint16_t sequence;
xcb_timestamp_t time;
uint8_t deviceID;
uint8_t pad0[3];
uint32_t state;
uint32_t mapChanged;
uint8_t pad1[12];
} xcb_xkb_indicator_map_notify_event_t;
/** Opcode for xcb_xkb_names_notify. */
#define XCB_XKB_NAMES_NOTIFY 6
/**
* @brief xcb_xkb_names_notify_event_t
**/
typedef struct xcb_xkb_names_notify_event_t {
uint8_t response_type;
uint8_t xkbType;
uint16_t sequence;
xcb_timestamp_t time;
uint8_t deviceID;
uint8_t pad0;
uint16_t changed;
uint8_t firstType;
uint8_t nTypes;
uint8_t firstLevelName;
uint8_t nLevelNames;
uint8_t pad1;
uint8_t nRadioGroups;
uint8_t nKeyAliases;
uint8_t changedGroupNames;
uint16_t changedVirtualMods;
xcb_keycode_t firstKey;
uint8_t nKeys;
uint32_t changedIndicators;
uint8_t pad2[4];
} xcb_xkb_names_notify_event_t;
/** Opcode for xcb_xkb_compat_map_notify. */
#define XCB_XKB_COMPAT_MAP_NOTIFY 7
/**
* @brief xcb_xkb_compat_map_notify_event_t
**/
typedef struct xcb_xkb_compat_map_notify_event_t {
uint8_t response_type;
uint8_t xkbType;
uint16_t sequence;
xcb_timestamp_t time;
uint8_t deviceID;
uint8_t changedGroups;
uint16_t firstSI;
uint16_t nSI;
uint16_t nTotalSI;
uint8_t pad0[16];
} xcb_xkb_compat_map_notify_event_t;
/** Opcode for xcb_xkb_bell_notify. */
#define XCB_XKB_BELL_NOTIFY 8
/**
* @brief xcb_xkb_bell_notify_event_t
**/
typedef struct xcb_xkb_bell_notify_event_t {
uint8_t response_type;
uint8_t xkbType;
uint16_t sequence;
xcb_timestamp_t time;
uint8_t deviceID;
uint8_t bellClass;
uint8_t bellID;
uint8_t percent;
uint16_t pitch;
uint16_t duration;
xcb_atom_t name;
xcb_window_t window;
uint8_t eventOnly;
uint8_t pad0[7];
} xcb_xkb_bell_notify_event_t;
/** Opcode for xcb_xkb_action_message. */
#define XCB_XKB_ACTION_MESSAGE 9
/**
* @brief xcb_xkb_action_message_event_t
**/
typedef struct xcb_xkb_action_message_event_t {
uint8_t response_type;
uint8_t xkbType;
uint16_t sequence;
xcb_timestamp_t time;
uint8_t deviceID;
xcb_keycode_t keycode;
uint8_t press;
uint8_t keyEventFollows;
uint8_t mods;
uint8_t group;
xcb_xkb_string8_t message[8];
uint8_t pad0[10];
} xcb_xkb_action_message_event_t;
/** Opcode for xcb_xkb_access_x_notify. */
#define XCB_XKB_ACCESS_X_NOTIFY 10
/**
* @brief xcb_xkb_access_x_notify_event_t
**/
typedef struct xcb_xkb_access_x_notify_event_t {
uint8_t response_type;
uint8_t xkbType;
uint16_t sequence;
xcb_timestamp_t time;
uint8_t deviceID;
xcb_keycode_t keycode;
uint16_t detailt;
uint16_t slowKeysDelay;
uint16_t debounceDelay;
uint8_t pad0[16];
} xcb_xkb_access_x_notify_event_t;
/** Opcode for xcb_xkb_extension_device_notify. */
#define XCB_XKB_EXTENSION_DEVICE_NOTIFY 11
/**
* @brief xcb_xkb_extension_device_notify_event_t
**/
typedef struct xcb_xkb_extension_device_notify_event_t {
uint8_t response_type;
uint8_t xkbType;
uint16_t sequence;
xcb_timestamp_t time;
uint8_t deviceID;
uint8_t pad0;
uint16_t reason;
uint16_t ledClass;
uint16_t ledID;
uint32_t ledsDefined;
uint32_t ledState;
uint8_t firstButton;
uint8_t nButtons;
uint16_t supported;
uint16_t unsupported;
uint8_t pad1[2];
} xcb_xkb_extension_device_notify_event_t;
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_device_spec_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_device_spec_t)
*/
void
xcb_xkb_device_spec_next (xcb_xkb_device_spec_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_device_spec_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_device_spec_end (xcb_xkb_device_spec_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_led_class_spec_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_led_class_spec_t)
*/
void
xcb_xkb_led_class_spec_next (xcb_xkb_led_class_spec_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_led_class_spec_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_led_class_spec_end (xcb_xkb_led_class_spec_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_bell_class_spec_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_bell_class_spec_t)
*/
void
xcb_xkb_bell_class_spec_next (xcb_xkb_bell_class_spec_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_bell_class_spec_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_bell_class_spec_end (xcb_xkb_bell_class_spec_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_id_spec_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_id_spec_t)
*/
void
xcb_xkb_id_spec_next (xcb_xkb_id_spec_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_id_spec_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_id_spec_end (xcb_xkb_id_spec_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_indicator_map_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_indicator_map_t)
*/
void
xcb_xkb_indicator_map_next (xcb_xkb_indicator_map_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_indicator_map_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_indicator_map_end (xcb_xkb_indicator_map_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_mod_def_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_mod_def_t)
*/
void
xcb_xkb_mod_def_next (xcb_xkb_mod_def_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_mod_def_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_mod_def_end (xcb_xkb_mod_def_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_key_name_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_key_name_t)
*/
void
xcb_xkb_key_name_next (xcb_xkb_key_name_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_key_name_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_key_name_end (xcb_xkb_key_name_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_key_alias_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_key_alias_t)
*/
void
xcb_xkb_key_alias_next (xcb_xkb_key_alias_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_key_alias_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_key_alias_end (xcb_xkb_key_alias_iterator_t i);
int
xcb_xkb_counted_string_16_sizeof (const void *_buffer);
char *
xcb_xkb_counted_string_16_string (const xcb_xkb_counted_string_16_t *R);
int
xcb_xkb_counted_string_16_string_length (const xcb_xkb_counted_string_16_t *R);
xcb_generic_iterator_t
xcb_xkb_counted_string_16_string_end (const xcb_xkb_counted_string_16_t *R);
void *
xcb_xkb_counted_string_16_alignment_pad (const xcb_xkb_counted_string_16_t *R);
int
xcb_xkb_counted_string_16_alignment_pad_length (const xcb_xkb_counted_string_16_t *R);
xcb_generic_iterator_t
xcb_xkb_counted_string_16_alignment_pad_end (const xcb_xkb_counted_string_16_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_counted_string_16_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_counted_string_16_t)
*/
void
xcb_xkb_counted_string_16_next (xcb_xkb_counted_string_16_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_counted_string_16_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_counted_string_16_end (xcb_xkb_counted_string_16_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_kt_map_entry_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_kt_map_entry_t)
*/
void
xcb_xkb_kt_map_entry_next (xcb_xkb_kt_map_entry_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_kt_map_entry_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_kt_map_entry_end (xcb_xkb_kt_map_entry_iterator_t i);
int
xcb_xkb_key_type_sizeof (const void *_buffer);
xcb_xkb_kt_map_entry_t *
xcb_xkb_key_type_map (const xcb_xkb_key_type_t *R);
int
xcb_xkb_key_type_map_length (const xcb_xkb_key_type_t *R);
xcb_xkb_kt_map_entry_iterator_t
xcb_xkb_key_type_map_iterator (const xcb_xkb_key_type_t *R);
xcb_xkb_mod_def_t *
xcb_xkb_key_type_preserve (const xcb_xkb_key_type_t *R);
int
xcb_xkb_key_type_preserve_length (const xcb_xkb_key_type_t *R);
xcb_xkb_mod_def_iterator_t
xcb_xkb_key_type_preserve_iterator (const xcb_xkb_key_type_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_key_type_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_key_type_t)
*/
void
xcb_xkb_key_type_next (xcb_xkb_key_type_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_key_type_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_key_type_end (xcb_xkb_key_type_iterator_t i);
int
xcb_xkb_key_sym_map_sizeof (const void *_buffer);
xcb_keysym_t *
xcb_xkb_key_sym_map_syms (const xcb_xkb_key_sym_map_t *R);
int
xcb_xkb_key_sym_map_syms_length (const xcb_xkb_key_sym_map_t *R);
xcb_generic_iterator_t
xcb_xkb_key_sym_map_syms_end (const xcb_xkb_key_sym_map_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_key_sym_map_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_key_sym_map_t)
*/
void
xcb_xkb_key_sym_map_next (xcb_xkb_key_sym_map_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_key_sym_map_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_key_sym_map_end (xcb_xkb_key_sym_map_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_common_behavior_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_common_behavior_t)
*/
void
xcb_xkb_common_behavior_next (xcb_xkb_common_behavior_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_common_behavior_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_common_behavior_end (xcb_xkb_common_behavior_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_default_behavior_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_default_behavior_t)
*/
void
xcb_xkb_default_behavior_next (xcb_xkb_default_behavior_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_default_behavior_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_default_behavior_end (xcb_xkb_default_behavior_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_lock_behavior_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_lock_behavior_t)
*/
void
xcb_xkb_lock_behavior_next (xcb_xkb_lock_behavior_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_lock_behavior_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_lock_behavior_end (xcb_xkb_lock_behavior_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_radio_group_behavior_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_radio_group_behavior_t)
*/
void
xcb_xkb_radio_group_behavior_next (xcb_xkb_radio_group_behavior_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_radio_group_behavior_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_radio_group_behavior_end (xcb_xkb_radio_group_behavior_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_overlay_behavior_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_overlay_behavior_t)
*/
void
xcb_xkb_overlay_behavior_next (xcb_xkb_overlay_behavior_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_overlay_behavior_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_overlay_behavior_end (xcb_xkb_overlay_behavior_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_permament_lock_behavior_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_permament_lock_behavior_t)
*/
void
xcb_xkb_permament_lock_behavior_next (xcb_xkb_permament_lock_behavior_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_permament_lock_behavior_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_permament_lock_behavior_end (xcb_xkb_permament_lock_behavior_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_permament_radio_group_behavior_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_permament_radio_group_behavior_t)
*/
void
xcb_xkb_permament_radio_group_behavior_next (xcb_xkb_permament_radio_group_behavior_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_permament_radio_group_behavior_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_permament_radio_group_behavior_end (xcb_xkb_permament_radio_group_behavior_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_permament_overlay_behavior_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_permament_overlay_behavior_t)
*/
void
xcb_xkb_permament_overlay_behavior_next (xcb_xkb_permament_overlay_behavior_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_permament_overlay_behavior_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_permament_overlay_behavior_end (xcb_xkb_permament_overlay_behavior_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_behavior_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_behavior_t)
*/
void
xcb_xkb_behavior_next (xcb_xkb_behavior_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_behavior_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_behavior_end (xcb_xkb_behavior_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_set_behavior_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_set_behavior_t)
*/
void
xcb_xkb_set_behavior_next (xcb_xkb_set_behavior_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_set_behavior_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_set_behavior_end (xcb_xkb_set_behavior_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_set_explicit_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_set_explicit_t)
*/
void
xcb_xkb_set_explicit_next (xcb_xkb_set_explicit_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_set_explicit_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_set_explicit_end (xcb_xkb_set_explicit_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_key_mod_map_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_key_mod_map_t)
*/
void
xcb_xkb_key_mod_map_next (xcb_xkb_key_mod_map_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_key_mod_map_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_key_mod_map_end (xcb_xkb_key_mod_map_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_key_v_mod_map_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_key_v_mod_map_t)
*/
void
xcb_xkb_key_v_mod_map_next (xcb_xkb_key_v_mod_map_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_key_v_mod_map_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_key_v_mod_map_end (xcb_xkb_key_v_mod_map_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_kt_set_map_entry_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_kt_set_map_entry_t)
*/
void
xcb_xkb_kt_set_map_entry_next (xcb_xkb_kt_set_map_entry_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_kt_set_map_entry_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_kt_set_map_entry_end (xcb_xkb_kt_set_map_entry_iterator_t i);
int
xcb_xkb_set_key_type_sizeof (const void *_buffer);
xcb_xkb_kt_set_map_entry_t *
xcb_xkb_set_key_type_entries (const xcb_xkb_set_key_type_t *R);
int
xcb_xkb_set_key_type_entries_length (const xcb_xkb_set_key_type_t *R);
xcb_xkb_kt_set_map_entry_iterator_t
xcb_xkb_set_key_type_entries_iterator (const xcb_xkb_set_key_type_t *R);
xcb_xkb_kt_set_map_entry_t *
xcb_xkb_set_key_type_preserve_entries (const xcb_xkb_set_key_type_t *R);
int
xcb_xkb_set_key_type_preserve_entries_length (const xcb_xkb_set_key_type_t *R);
xcb_xkb_kt_set_map_entry_iterator_t
xcb_xkb_set_key_type_preserve_entries_iterator (const xcb_xkb_set_key_type_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_set_key_type_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_set_key_type_t)
*/
void
xcb_xkb_set_key_type_next (xcb_xkb_set_key_type_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_set_key_type_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_set_key_type_end (xcb_xkb_set_key_type_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_string8_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_string8_t)
*/
void
xcb_xkb_string8_next (xcb_xkb_string8_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_string8_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_string8_end (xcb_xkb_string8_iterator_t i);
int
xcb_xkb_outline_sizeof (const void *_buffer);
xcb_point_t *
xcb_xkb_outline_points (const xcb_xkb_outline_t *R);
int
xcb_xkb_outline_points_length (const xcb_xkb_outline_t *R);
xcb_point_iterator_t
xcb_xkb_outline_points_iterator (const xcb_xkb_outline_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_outline_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_outline_t)
*/
void
xcb_xkb_outline_next (xcb_xkb_outline_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_outline_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_outline_end (xcb_xkb_outline_iterator_t i);
int
xcb_xkb_shape_sizeof (const void *_buffer);
int
xcb_xkb_shape_outlines_length (const xcb_xkb_shape_t *R);
xcb_xkb_outline_iterator_t
xcb_xkb_shape_outlines_iterator (const xcb_xkb_shape_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_shape_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_shape_t)
*/
void
xcb_xkb_shape_next (xcb_xkb_shape_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_shape_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_shape_end (xcb_xkb_shape_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_key_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_key_t)
*/
void
xcb_xkb_key_next (xcb_xkb_key_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_key_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_key_end (xcb_xkb_key_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_overlay_key_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_overlay_key_t)
*/
void
xcb_xkb_overlay_key_next (xcb_xkb_overlay_key_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_overlay_key_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_overlay_key_end (xcb_xkb_overlay_key_iterator_t i);
int
xcb_xkb_overlay_row_sizeof (const void *_buffer);
xcb_xkb_overlay_key_t *
xcb_xkb_overlay_row_keys (const xcb_xkb_overlay_row_t *R);
int
xcb_xkb_overlay_row_keys_length (const xcb_xkb_overlay_row_t *R);
xcb_xkb_overlay_key_iterator_t
xcb_xkb_overlay_row_keys_iterator (const xcb_xkb_overlay_row_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_overlay_row_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_overlay_row_t)
*/
void
xcb_xkb_overlay_row_next (xcb_xkb_overlay_row_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_overlay_row_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_overlay_row_end (xcb_xkb_overlay_row_iterator_t i);
int
xcb_xkb_overlay_sizeof (const void *_buffer);
int
xcb_xkb_overlay_rows_length (const xcb_xkb_overlay_t *R);
xcb_xkb_overlay_row_iterator_t
xcb_xkb_overlay_rows_iterator (const xcb_xkb_overlay_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_overlay_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_overlay_t)
*/
void
xcb_xkb_overlay_next (xcb_xkb_overlay_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_overlay_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_overlay_end (xcb_xkb_overlay_iterator_t i);
int
xcb_xkb_row_sizeof (const void *_buffer);
xcb_xkb_key_t *
xcb_xkb_row_keys (const xcb_xkb_row_t *R);
int
xcb_xkb_row_keys_length (const xcb_xkb_row_t *R);
xcb_xkb_key_iterator_t
xcb_xkb_row_keys_iterator (const xcb_xkb_row_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_row_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_row_t)
*/
void
xcb_xkb_row_next (xcb_xkb_row_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_row_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_row_end (xcb_xkb_row_iterator_t i);
int
xcb_xkb_listing_sizeof (const void *_buffer);
xcb_xkb_string8_t *
xcb_xkb_listing_string (const xcb_xkb_listing_t *R);
int
xcb_xkb_listing_string_length (const xcb_xkb_listing_t *R);
xcb_generic_iterator_t
xcb_xkb_listing_string_end (const xcb_xkb_listing_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_listing_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_listing_t)
*/
void
xcb_xkb_listing_next (xcb_xkb_listing_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_listing_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_listing_end (xcb_xkb_listing_iterator_t i);
int
xcb_xkb_device_led_info_sizeof (const void *_buffer);
xcb_atom_t *
xcb_xkb_device_led_info_names (const xcb_xkb_device_led_info_t *R);
int
xcb_xkb_device_led_info_names_length (const xcb_xkb_device_led_info_t *R);
xcb_generic_iterator_t
xcb_xkb_device_led_info_names_end (const xcb_xkb_device_led_info_t *R);
xcb_xkb_indicator_map_t *
xcb_xkb_device_led_info_maps (const xcb_xkb_device_led_info_t *R);
int
xcb_xkb_device_led_info_maps_length (const xcb_xkb_device_led_info_t *R);
xcb_xkb_indicator_map_iterator_t
xcb_xkb_device_led_info_maps_iterator (const xcb_xkb_device_led_info_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_device_led_info_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_device_led_info_t)
*/
void
xcb_xkb_device_led_info_next (xcb_xkb_device_led_info_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_device_led_info_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_device_led_info_end (xcb_xkb_device_led_info_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_sa_no_action_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_sa_no_action_t)
*/
void
xcb_xkb_sa_no_action_next (xcb_xkb_sa_no_action_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_sa_no_action_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_sa_no_action_end (xcb_xkb_sa_no_action_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_sa_set_mods_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_sa_set_mods_t)
*/
void
xcb_xkb_sa_set_mods_next (xcb_xkb_sa_set_mods_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_sa_set_mods_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_sa_set_mods_end (xcb_xkb_sa_set_mods_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_sa_latch_mods_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_sa_latch_mods_t)
*/
void
xcb_xkb_sa_latch_mods_next (xcb_xkb_sa_latch_mods_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_sa_latch_mods_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_sa_latch_mods_end (xcb_xkb_sa_latch_mods_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_sa_lock_mods_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_sa_lock_mods_t)
*/
void
xcb_xkb_sa_lock_mods_next (xcb_xkb_sa_lock_mods_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_sa_lock_mods_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_sa_lock_mods_end (xcb_xkb_sa_lock_mods_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_sa_set_group_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_sa_set_group_t)
*/
void
xcb_xkb_sa_set_group_next (xcb_xkb_sa_set_group_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_sa_set_group_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_sa_set_group_end (xcb_xkb_sa_set_group_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_sa_latch_group_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_sa_latch_group_t)
*/
void
xcb_xkb_sa_latch_group_next (xcb_xkb_sa_latch_group_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_sa_latch_group_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_sa_latch_group_end (xcb_xkb_sa_latch_group_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_sa_lock_group_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_sa_lock_group_t)
*/
void
xcb_xkb_sa_lock_group_next (xcb_xkb_sa_lock_group_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_sa_lock_group_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_sa_lock_group_end (xcb_xkb_sa_lock_group_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_sa_move_ptr_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_sa_move_ptr_t)
*/
void
xcb_xkb_sa_move_ptr_next (xcb_xkb_sa_move_ptr_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_sa_move_ptr_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_sa_move_ptr_end (xcb_xkb_sa_move_ptr_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_sa_ptr_btn_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_sa_ptr_btn_t)
*/
void
xcb_xkb_sa_ptr_btn_next (xcb_xkb_sa_ptr_btn_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_sa_ptr_btn_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_sa_ptr_btn_end (xcb_xkb_sa_ptr_btn_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_sa_lock_ptr_btn_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_sa_lock_ptr_btn_t)
*/
void
xcb_xkb_sa_lock_ptr_btn_next (xcb_xkb_sa_lock_ptr_btn_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_sa_lock_ptr_btn_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_sa_lock_ptr_btn_end (xcb_xkb_sa_lock_ptr_btn_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_sa_set_ptr_dflt_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_sa_set_ptr_dflt_t)
*/
void
xcb_xkb_sa_set_ptr_dflt_next (xcb_xkb_sa_set_ptr_dflt_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_sa_set_ptr_dflt_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_sa_set_ptr_dflt_end (xcb_xkb_sa_set_ptr_dflt_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_sa_iso_lock_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_sa_iso_lock_t)
*/
void
xcb_xkb_sa_iso_lock_next (xcb_xkb_sa_iso_lock_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_sa_iso_lock_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_sa_iso_lock_end (xcb_xkb_sa_iso_lock_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_sa_terminate_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_sa_terminate_t)
*/
void
xcb_xkb_sa_terminate_next (xcb_xkb_sa_terminate_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_sa_terminate_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_sa_terminate_end (xcb_xkb_sa_terminate_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_sa_switch_screen_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_sa_switch_screen_t)
*/
void
xcb_xkb_sa_switch_screen_next (xcb_xkb_sa_switch_screen_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_sa_switch_screen_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_sa_switch_screen_end (xcb_xkb_sa_switch_screen_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_sa_set_controls_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_sa_set_controls_t)
*/
void
xcb_xkb_sa_set_controls_next (xcb_xkb_sa_set_controls_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_sa_set_controls_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_sa_set_controls_end (xcb_xkb_sa_set_controls_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_sa_lock_controls_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_sa_lock_controls_t)
*/
void
xcb_xkb_sa_lock_controls_next (xcb_xkb_sa_lock_controls_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_sa_lock_controls_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_sa_lock_controls_end (xcb_xkb_sa_lock_controls_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_sa_action_message_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_sa_action_message_t)
*/
void
xcb_xkb_sa_action_message_next (xcb_xkb_sa_action_message_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_sa_action_message_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_sa_action_message_end (xcb_xkb_sa_action_message_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_sa_redirect_key_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_sa_redirect_key_t)
*/
void
xcb_xkb_sa_redirect_key_next (xcb_xkb_sa_redirect_key_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_sa_redirect_key_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_sa_redirect_key_end (xcb_xkb_sa_redirect_key_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_sa_device_btn_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_sa_device_btn_t)
*/
void
xcb_xkb_sa_device_btn_next (xcb_xkb_sa_device_btn_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_sa_device_btn_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_sa_device_btn_end (xcb_xkb_sa_device_btn_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_sa_lock_device_btn_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_sa_lock_device_btn_t)
*/
void
xcb_xkb_sa_lock_device_btn_next (xcb_xkb_sa_lock_device_btn_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_sa_lock_device_btn_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_sa_lock_device_btn_end (xcb_xkb_sa_lock_device_btn_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_sa_device_valuator_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_sa_device_valuator_t)
*/
void
xcb_xkb_sa_device_valuator_next (xcb_xkb_sa_device_valuator_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_sa_device_valuator_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_sa_device_valuator_end (xcb_xkb_sa_device_valuator_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_si_action_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_si_action_t)
*/
void
xcb_xkb_si_action_next (xcb_xkb_si_action_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_si_action_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_si_action_end (xcb_xkb_si_action_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_sym_interpret_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_sym_interpret_t)
*/
void
xcb_xkb_sym_interpret_next (xcb_xkb_sym_interpret_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_sym_interpret_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_sym_interpret_end (xcb_xkb_sym_interpret_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xkb_action_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xkb_action_t)
*/
void
xcb_xkb_action_next (xcb_xkb_action_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xkb_action_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xkb_action_end (xcb_xkb_action_iterator_t i);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xkb_use_extension_cookie_t
xcb_xkb_use_extension (xcb_connection_t *c,
uint16_t wantedMajor,
uint16_t wantedMinor);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xkb_use_extension_cookie_t
xcb_xkb_use_extension_unchecked (xcb_connection_t *c,
uint16_t wantedMajor,
uint16_t wantedMinor);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xkb_use_extension_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xkb_use_extension_reply_t *
xcb_xkb_use_extension_reply (xcb_connection_t *c,
xcb_xkb_use_extension_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_xkb_select_events_details_serialize (void **_buffer,
uint16_t affectWhich,
uint16_t clear,
uint16_t selectAll,
const xcb_xkb_select_events_details_t *_aux);
int
xcb_xkb_select_events_details_unpack (const void *_buffer,
uint16_t affectWhich,
uint16_t clear,
uint16_t selectAll,
xcb_xkb_select_events_details_t *_aux);
int
xcb_xkb_select_events_details_sizeof (const void *_buffer,
uint16_t affectWhich,
uint16_t clear,
uint16_t selectAll);
int
xcb_xkb_select_events_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xkb_select_events_checked (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint16_t affectWhich,
uint16_t clear,
uint16_t selectAll,
uint16_t affectMap,
uint16_t map,
const void *details);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xkb_select_events (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint16_t affectWhich,
uint16_t clear,
uint16_t selectAll,
uint16_t affectMap,
uint16_t map,
const void *details);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xkb_select_events_aux_checked (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint16_t affectWhich,
uint16_t clear,
uint16_t selectAll,
uint16_t affectMap,
uint16_t map,
const xcb_xkb_select_events_details_t *details);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xkb_select_events_aux (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint16_t affectWhich,
uint16_t clear,
uint16_t selectAll,
uint16_t affectMap,
uint16_t map,
const xcb_xkb_select_events_details_t *details);
void *
xcb_xkb_select_events_details (const xcb_xkb_select_events_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xkb_bell_checked (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
xcb_xkb_bell_class_spec_t bellClass,
xcb_xkb_id_spec_t bellID,
int8_t percent,
uint8_t forceSound,
uint8_t eventOnly,
int16_t pitch,
int16_t duration,
xcb_atom_t name,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xkb_bell (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
xcb_xkb_bell_class_spec_t bellClass,
xcb_xkb_id_spec_t bellID,
int8_t percent,
uint8_t forceSound,
uint8_t eventOnly,
int16_t pitch,
int16_t duration,
xcb_atom_t name,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xkb_get_state_cookie_t
xcb_xkb_get_state (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xkb_get_state_cookie_t
xcb_xkb_get_state_unchecked (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xkb_get_state_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xkb_get_state_reply_t *
xcb_xkb_get_state_reply (xcb_connection_t *c,
xcb_xkb_get_state_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xkb_latch_lock_state_checked (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint8_t affectModLocks,
uint8_t modLocks,
uint8_t lockGroup,
uint8_t groupLock,
uint8_t affectModLatches,
uint8_t latchGroup,
uint16_t groupLatch);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xkb_latch_lock_state (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint8_t affectModLocks,
uint8_t modLocks,
uint8_t lockGroup,
uint8_t groupLock,
uint8_t affectModLatches,
uint8_t latchGroup,
uint16_t groupLatch);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xkb_get_controls_cookie_t
xcb_xkb_get_controls (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xkb_get_controls_cookie_t
xcb_xkb_get_controls_unchecked (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xkb_get_controls_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xkb_get_controls_reply_t *
xcb_xkb_get_controls_reply (xcb_connection_t *c,
xcb_xkb_get_controls_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xkb_set_controls_checked (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint8_t affectInternalRealMods,
uint8_t internalRealMods,
uint8_t affectIgnoreLockRealMods,
uint8_t ignoreLockRealMods,
uint16_t affectInternalVirtualMods,
uint16_t internalVirtualMods,
uint16_t affectIgnoreLockVirtualMods,
uint16_t ignoreLockVirtualMods,
uint8_t mouseKeysDfltBtn,
uint8_t groupsWrap,
uint16_t accessXOptions,
uint32_t affectEnabledControls,
uint32_t enabledControls,
uint32_t changeControls,
uint16_t repeatDelay,
uint16_t repeatInterval,
uint16_t slowKeysDelay,
uint16_t debounceDelay,
uint16_t mouseKeysDelay,
uint16_t mouseKeysInterval,
uint16_t mouseKeysTimeToMax,
uint16_t mouseKeysMaxSpeed,
int16_t mouseKeysCurve,
uint16_t accessXTimeout,
uint32_t accessXTimeoutMask,
uint32_t accessXTimeoutValues,
uint16_t accessXTimeoutOptionsMask,
uint16_t accessXTimeoutOptionsValues,
const uint8_t *perKeyRepeat);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xkb_set_controls (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint8_t affectInternalRealMods,
uint8_t internalRealMods,
uint8_t affectIgnoreLockRealMods,
uint8_t ignoreLockRealMods,
uint16_t affectInternalVirtualMods,
uint16_t internalVirtualMods,
uint16_t affectIgnoreLockVirtualMods,
uint16_t ignoreLockVirtualMods,
uint8_t mouseKeysDfltBtn,
uint8_t groupsWrap,
uint16_t accessXOptions,
uint32_t affectEnabledControls,
uint32_t enabledControls,
uint32_t changeControls,
uint16_t repeatDelay,
uint16_t repeatInterval,
uint16_t slowKeysDelay,
uint16_t debounceDelay,
uint16_t mouseKeysDelay,
uint16_t mouseKeysInterval,
uint16_t mouseKeysTimeToMax,
uint16_t mouseKeysMaxSpeed,
int16_t mouseKeysCurve,
uint16_t accessXTimeout,
uint32_t accessXTimeoutMask,
uint32_t accessXTimeoutValues,
uint16_t accessXTimeoutOptionsMask,
uint16_t accessXTimeoutOptionsValues,
const uint8_t *perKeyRepeat);
int
xcb_xkb_get_map_map_types_rtrn_length (const xcb_xkb_get_map_reply_t *R,
const xcb_xkb_get_map_map_t *S);
xcb_xkb_key_type_iterator_t
xcb_xkb_get_map_map_types_rtrn_iterator (const xcb_xkb_get_map_reply_t *R,
const xcb_xkb_get_map_map_t *S);
int
xcb_xkb_get_map_map_syms_rtrn_length (const xcb_xkb_get_map_reply_t *R,
const xcb_xkb_get_map_map_t *S);
xcb_xkb_key_sym_map_iterator_t
xcb_xkb_get_map_map_syms_rtrn_iterator (const xcb_xkb_get_map_reply_t *R,
const xcb_xkb_get_map_map_t *S);
uint8_t *
xcb_xkb_get_map_map_acts_rtrn_count (const xcb_xkb_get_map_map_t *S);
int
xcb_xkb_get_map_map_acts_rtrn_count_length (const xcb_xkb_get_map_reply_t *R,
const xcb_xkb_get_map_map_t *S);
xcb_generic_iterator_t
xcb_xkb_get_map_map_acts_rtrn_count_end (const xcb_xkb_get_map_reply_t *R,
const xcb_xkb_get_map_map_t *S);
xcb_xkb_action_t *
xcb_xkb_get_map_map_acts_rtrn_acts (const xcb_xkb_get_map_map_t *S);
int
xcb_xkb_get_map_map_acts_rtrn_acts_length (const xcb_xkb_get_map_reply_t *R,
const xcb_xkb_get_map_map_t *S);
xcb_xkb_action_iterator_t
xcb_xkb_get_map_map_acts_rtrn_acts_iterator (const xcb_xkb_get_map_reply_t *R,
const xcb_xkb_get_map_map_t *S);
xcb_xkb_set_behavior_t *
xcb_xkb_get_map_map_behaviors_rtrn (const xcb_xkb_get_map_map_t *S);
int
xcb_xkb_get_map_map_behaviors_rtrn_length (const xcb_xkb_get_map_reply_t *R,
const xcb_xkb_get_map_map_t *S);
xcb_xkb_set_behavior_iterator_t
xcb_xkb_get_map_map_behaviors_rtrn_iterator (const xcb_xkb_get_map_reply_t *R,
const xcb_xkb_get_map_map_t *S);
uint8_t *
xcb_xkb_get_map_map_vmods_rtrn (const xcb_xkb_get_map_map_t *S);
int
xcb_xkb_get_map_map_vmods_rtrn_length (const xcb_xkb_get_map_reply_t *R,
const xcb_xkb_get_map_map_t *S);
xcb_generic_iterator_t
xcb_xkb_get_map_map_vmods_rtrn_end (const xcb_xkb_get_map_reply_t *R,
const xcb_xkb_get_map_map_t *S);
xcb_xkb_set_explicit_t *
xcb_xkb_get_map_map_explicit_rtrn (const xcb_xkb_get_map_map_t *S);
int
xcb_xkb_get_map_map_explicit_rtrn_length (const xcb_xkb_get_map_reply_t *R,
const xcb_xkb_get_map_map_t *S);
xcb_xkb_set_explicit_iterator_t
xcb_xkb_get_map_map_explicit_rtrn_iterator (const xcb_xkb_get_map_reply_t *R,
const xcb_xkb_get_map_map_t *S);
xcb_xkb_key_mod_map_t *
xcb_xkb_get_map_map_modmap_rtrn (const xcb_xkb_get_map_map_t *S);
int
xcb_xkb_get_map_map_modmap_rtrn_length (const xcb_xkb_get_map_reply_t *R,
const xcb_xkb_get_map_map_t *S);
xcb_xkb_key_mod_map_iterator_t
xcb_xkb_get_map_map_modmap_rtrn_iterator (const xcb_xkb_get_map_reply_t *R,
const xcb_xkb_get_map_map_t *S);
xcb_xkb_key_v_mod_map_t *
xcb_xkb_get_map_map_vmodmap_rtrn (const xcb_xkb_get_map_map_t *S);
int
xcb_xkb_get_map_map_vmodmap_rtrn_length (const xcb_xkb_get_map_reply_t *R,
const xcb_xkb_get_map_map_t *S);
xcb_xkb_key_v_mod_map_iterator_t
xcb_xkb_get_map_map_vmodmap_rtrn_iterator (const xcb_xkb_get_map_reply_t *R,
const xcb_xkb_get_map_map_t *S);
int
xcb_xkb_get_map_map_serialize (void **_buffer,
uint8_t nTypes,
uint8_t nKeySyms,
uint8_t nKeyActions,
uint16_t totalActions,
uint8_t totalKeyBehaviors,
uint16_t virtualMods,
uint8_t totalKeyExplicit,
uint8_t totalModMapKeys,
uint8_t totalVModMapKeys,
uint16_t present,
const xcb_xkb_get_map_map_t *_aux);
int
xcb_xkb_get_map_map_unpack (const void *_buffer,
uint8_t nTypes,
uint8_t nKeySyms,
uint8_t nKeyActions,
uint16_t totalActions,
uint8_t totalKeyBehaviors,
uint16_t virtualMods,
uint8_t totalKeyExplicit,
uint8_t totalModMapKeys,
uint8_t totalVModMapKeys,
uint16_t present,
xcb_xkb_get_map_map_t *_aux);
int
xcb_xkb_get_map_map_sizeof (const void *_buffer,
uint8_t nTypes,
uint8_t nKeySyms,
uint8_t nKeyActions,
uint16_t totalActions,
uint8_t totalKeyBehaviors,
uint16_t virtualMods,
uint8_t totalKeyExplicit,
uint8_t totalModMapKeys,
uint8_t totalVModMapKeys,
uint16_t present);
int
xcb_xkb_get_map_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xkb_get_map_cookie_t
xcb_xkb_get_map (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint16_t full,
uint16_t partial,
uint8_t firstType,
uint8_t nTypes,
xcb_keycode_t firstKeySym,
uint8_t nKeySyms,
xcb_keycode_t firstKeyAction,
uint8_t nKeyActions,
xcb_keycode_t firstKeyBehavior,
uint8_t nKeyBehaviors,
uint16_t virtualMods,
xcb_keycode_t firstKeyExplicit,
uint8_t nKeyExplicit,
xcb_keycode_t firstModMapKey,
uint8_t nModMapKeys,
xcb_keycode_t firstVModMapKey,
uint8_t nVModMapKeys);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xkb_get_map_cookie_t
xcb_xkb_get_map_unchecked (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint16_t full,
uint16_t partial,
uint8_t firstType,
uint8_t nTypes,
xcb_keycode_t firstKeySym,
uint8_t nKeySyms,
xcb_keycode_t firstKeyAction,
uint8_t nKeyActions,
xcb_keycode_t firstKeyBehavior,
uint8_t nKeyBehaviors,
uint16_t virtualMods,
xcb_keycode_t firstKeyExplicit,
uint8_t nKeyExplicit,
xcb_keycode_t firstModMapKey,
uint8_t nModMapKeys,
xcb_keycode_t firstVModMapKey,
uint8_t nVModMapKeys);
void *
xcb_xkb_get_map_map (const xcb_xkb_get_map_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xkb_get_map_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xkb_get_map_reply_t *
xcb_xkb_get_map_reply (xcb_connection_t *c,
xcb_xkb_get_map_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_xkb_set_map_values_types_length (const xcb_xkb_set_map_request_t *R,
const xcb_xkb_set_map_values_t *S);
xcb_xkb_set_key_type_iterator_t
xcb_xkb_set_map_values_types_iterator (const xcb_xkb_set_map_request_t *R,
const xcb_xkb_set_map_values_t *S);
int
xcb_xkb_set_map_values_syms_length (const xcb_xkb_set_map_request_t *R,
const xcb_xkb_set_map_values_t *S);
xcb_xkb_key_sym_map_iterator_t
xcb_xkb_set_map_values_syms_iterator (const xcb_xkb_set_map_request_t *R,
const xcb_xkb_set_map_values_t *S);
uint8_t *
xcb_xkb_set_map_values_actions_count (const xcb_xkb_set_map_values_t *S);
int
xcb_xkb_set_map_values_actions_count_length (const xcb_xkb_set_map_request_t *R,
const xcb_xkb_set_map_values_t *S);
xcb_generic_iterator_t
xcb_xkb_set_map_values_actions_count_end (const xcb_xkb_set_map_request_t *R,
const xcb_xkb_set_map_values_t *S);
xcb_xkb_action_t *
xcb_xkb_set_map_values_actions (const xcb_xkb_set_map_values_t *S);
int
xcb_xkb_set_map_values_actions_length (const xcb_xkb_set_map_request_t *R,
const xcb_xkb_set_map_values_t *S);
xcb_xkb_action_iterator_t
xcb_xkb_set_map_values_actions_iterator (const xcb_xkb_set_map_request_t *R,
const xcb_xkb_set_map_values_t *S);
xcb_xkb_set_behavior_t *
xcb_xkb_set_map_values_behaviors (const xcb_xkb_set_map_values_t *S);
int
xcb_xkb_set_map_values_behaviors_length (const xcb_xkb_set_map_request_t *R,
const xcb_xkb_set_map_values_t *S);
xcb_xkb_set_behavior_iterator_t
xcb_xkb_set_map_values_behaviors_iterator (const xcb_xkb_set_map_request_t *R,
const xcb_xkb_set_map_values_t *S);
uint8_t *
xcb_xkb_set_map_values_vmods (const xcb_xkb_set_map_values_t *S);
int
xcb_xkb_set_map_values_vmods_length (const xcb_xkb_set_map_request_t *R,
const xcb_xkb_set_map_values_t *S);
xcb_generic_iterator_t
xcb_xkb_set_map_values_vmods_end (const xcb_xkb_set_map_request_t *R,
const xcb_xkb_set_map_values_t *S);
xcb_xkb_set_explicit_t *
xcb_xkb_set_map_values_explicit (const xcb_xkb_set_map_values_t *S);
int
xcb_xkb_set_map_values_explicit_length (const xcb_xkb_set_map_request_t *R,
const xcb_xkb_set_map_values_t *S);
xcb_xkb_set_explicit_iterator_t
xcb_xkb_set_map_values_explicit_iterator (const xcb_xkb_set_map_request_t *R,
const xcb_xkb_set_map_values_t *S);
xcb_xkb_key_mod_map_t *
xcb_xkb_set_map_values_modmap (const xcb_xkb_set_map_values_t *S);
int
xcb_xkb_set_map_values_modmap_length (const xcb_xkb_set_map_request_t *R,
const xcb_xkb_set_map_values_t *S);
xcb_xkb_key_mod_map_iterator_t
xcb_xkb_set_map_values_modmap_iterator (const xcb_xkb_set_map_request_t *R,
const xcb_xkb_set_map_values_t *S);
xcb_xkb_key_v_mod_map_t *
xcb_xkb_set_map_values_vmodmap (const xcb_xkb_set_map_values_t *S);
int
xcb_xkb_set_map_values_vmodmap_length (const xcb_xkb_set_map_request_t *R,
const xcb_xkb_set_map_values_t *S);
xcb_xkb_key_v_mod_map_iterator_t
xcb_xkb_set_map_values_vmodmap_iterator (const xcb_xkb_set_map_request_t *R,
const xcb_xkb_set_map_values_t *S);
int
xcb_xkb_set_map_values_serialize (void **_buffer,
uint8_t nTypes,
uint8_t nKeySyms,
uint8_t nKeyActions,
uint16_t totalActions,
uint8_t totalKeyBehaviors,
uint16_t virtualMods,
uint8_t totalKeyExplicit,
uint8_t totalModMapKeys,
uint8_t totalVModMapKeys,
uint16_t present,
const xcb_xkb_set_map_values_t *_aux);
int
xcb_xkb_set_map_values_unpack (const void *_buffer,
uint8_t nTypes,
uint8_t nKeySyms,
uint8_t nKeyActions,
uint16_t totalActions,
uint8_t totalKeyBehaviors,
uint16_t virtualMods,
uint8_t totalKeyExplicit,
uint8_t totalModMapKeys,
uint8_t totalVModMapKeys,
uint16_t present,
xcb_xkb_set_map_values_t *_aux);
int
xcb_xkb_set_map_values_sizeof (const void *_buffer,
uint8_t nTypes,
uint8_t nKeySyms,
uint8_t nKeyActions,
uint16_t totalActions,
uint8_t totalKeyBehaviors,
uint16_t virtualMods,
uint8_t totalKeyExplicit,
uint8_t totalModMapKeys,
uint8_t totalVModMapKeys,
uint16_t present);
int
xcb_xkb_set_map_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xkb_set_map_checked (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint16_t present,
uint16_t flags,
xcb_keycode_t minKeyCode,
xcb_keycode_t maxKeyCode,
uint8_t firstType,
uint8_t nTypes,
xcb_keycode_t firstKeySym,
uint8_t nKeySyms,
uint16_t totalSyms,
xcb_keycode_t firstKeyAction,
uint8_t nKeyActions,
uint16_t totalActions,
xcb_keycode_t firstKeyBehavior,
uint8_t nKeyBehaviors,
uint8_t totalKeyBehaviors,
xcb_keycode_t firstKeyExplicit,
uint8_t nKeyExplicit,
uint8_t totalKeyExplicit,
xcb_keycode_t firstModMapKey,
uint8_t nModMapKeys,
uint8_t totalModMapKeys,
xcb_keycode_t firstVModMapKey,
uint8_t nVModMapKeys,
uint8_t totalVModMapKeys,
uint16_t virtualMods,
const void *values);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xkb_set_map (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint16_t present,
uint16_t flags,
xcb_keycode_t minKeyCode,
xcb_keycode_t maxKeyCode,
uint8_t firstType,
uint8_t nTypes,
xcb_keycode_t firstKeySym,
uint8_t nKeySyms,
uint16_t totalSyms,
xcb_keycode_t firstKeyAction,
uint8_t nKeyActions,
uint16_t totalActions,
xcb_keycode_t firstKeyBehavior,
uint8_t nKeyBehaviors,
uint8_t totalKeyBehaviors,
xcb_keycode_t firstKeyExplicit,
uint8_t nKeyExplicit,
uint8_t totalKeyExplicit,
xcb_keycode_t firstModMapKey,
uint8_t nModMapKeys,
uint8_t totalModMapKeys,
xcb_keycode_t firstVModMapKey,
uint8_t nVModMapKeys,
uint8_t totalVModMapKeys,
uint16_t virtualMods,
const void *values);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xkb_set_map_aux_checked (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint16_t present,
uint16_t flags,
xcb_keycode_t minKeyCode,
xcb_keycode_t maxKeyCode,
uint8_t firstType,
uint8_t nTypes,
xcb_keycode_t firstKeySym,
uint8_t nKeySyms,
uint16_t totalSyms,
xcb_keycode_t firstKeyAction,
uint8_t nKeyActions,
uint16_t totalActions,
xcb_keycode_t firstKeyBehavior,
uint8_t nKeyBehaviors,
uint8_t totalKeyBehaviors,
xcb_keycode_t firstKeyExplicit,
uint8_t nKeyExplicit,
uint8_t totalKeyExplicit,
xcb_keycode_t firstModMapKey,
uint8_t nModMapKeys,
uint8_t totalModMapKeys,
xcb_keycode_t firstVModMapKey,
uint8_t nVModMapKeys,
uint8_t totalVModMapKeys,
uint16_t virtualMods,
const xcb_xkb_set_map_values_t *values);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xkb_set_map_aux (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint16_t present,
uint16_t flags,
xcb_keycode_t minKeyCode,
xcb_keycode_t maxKeyCode,
uint8_t firstType,
uint8_t nTypes,
xcb_keycode_t firstKeySym,
uint8_t nKeySyms,
uint16_t totalSyms,
xcb_keycode_t firstKeyAction,
uint8_t nKeyActions,
uint16_t totalActions,
xcb_keycode_t firstKeyBehavior,
uint8_t nKeyBehaviors,
uint8_t totalKeyBehaviors,
xcb_keycode_t firstKeyExplicit,
uint8_t nKeyExplicit,
uint8_t totalKeyExplicit,
xcb_keycode_t firstModMapKey,
uint8_t nModMapKeys,
uint8_t totalModMapKeys,
xcb_keycode_t firstVModMapKey,
uint8_t nVModMapKeys,
uint8_t totalVModMapKeys,
uint16_t virtualMods,
const xcb_xkb_set_map_values_t *values);
void *
xcb_xkb_set_map_values (const xcb_xkb_set_map_request_t *R);
int
xcb_xkb_get_compat_map_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xkb_get_compat_map_cookie_t
xcb_xkb_get_compat_map (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint8_t groups,
uint8_t getAllSI,
uint16_t firstSI,
uint16_t nSI);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xkb_get_compat_map_cookie_t
xcb_xkb_get_compat_map_unchecked (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint8_t groups,
uint8_t getAllSI,
uint16_t firstSI,
uint16_t nSI);
xcb_xkb_sym_interpret_t *
xcb_xkb_get_compat_map_si_rtrn (const xcb_xkb_get_compat_map_reply_t *R);
int
xcb_xkb_get_compat_map_si_rtrn_length (const xcb_xkb_get_compat_map_reply_t *R);
xcb_xkb_sym_interpret_iterator_t
xcb_xkb_get_compat_map_si_rtrn_iterator (const xcb_xkb_get_compat_map_reply_t *R);
xcb_xkb_mod_def_t *
xcb_xkb_get_compat_map_group_rtrn (const xcb_xkb_get_compat_map_reply_t *R);
int
xcb_xkb_get_compat_map_group_rtrn_length (const xcb_xkb_get_compat_map_reply_t *R);
xcb_xkb_mod_def_iterator_t
xcb_xkb_get_compat_map_group_rtrn_iterator (const xcb_xkb_get_compat_map_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xkb_get_compat_map_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xkb_get_compat_map_reply_t *
xcb_xkb_get_compat_map_reply (xcb_connection_t *c,
xcb_xkb_get_compat_map_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_xkb_set_compat_map_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xkb_set_compat_map_checked (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint8_t recomputeActions,
uint8_t truncateSI,
uint8_t groups,
uint16_t firstSI,
uint16_t nSI,
const xcb_xkb_sym_interpret_t *si,
const xcb_xkb_mod_def_t *groupMaps);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xkb_set_compat_map (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint8_t recomputeActions,
uint8_t truncateSI,
uint8_t groups,
uint16_t firstSI,
uint16_t nSI,
const xcb_xkb_sym_interpret_t *si,
const xcb_xkb_mod_def_t *groupMaps);
xcb_xkb_sym_interpret_t *
xcb_xkb_set_compat_map_si (const xcb_xkb_set_compat_map_request_t *R);
int
xcb_xkb_set_compat_map_si_length (const xcb_xkb_set_compat_map_request_t *R);
xcb_xkb_sym_interpret_iterator_t
xcb_xkb_set_compat_map_si_iterator (const xcb_xkb_set_compat_map_request_t *R);
xcb_xkb_mod_def_t *
xcb_xkb_set_compat_map_group_maps (const xcb_xkb_set_compat_map_request_t *R);
int
xcb_xkb_set_compat_map_group_maps_length (const xcb_xkb_set_compat_map_request_t *R);
xcb_xkb_mod_def_iterator_t
xcb_xkb_set_compat_map_group_maps_iterator (const xcb_xkb_set_compat_map_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xkb_get_indicator_state_cookie_t
xcb_xkb_get_indicator_state (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xkb_get_indicator_state_cookie_t
xcb_xkb_get_indicator_state_unchecked (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xkb_get_indicator_state_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xkb_get_indicator_state_reply_t *
xcb_xkb_get_indicator_state_reply (xcb_connection_t *c,
xcb_xkb_get_indicator_state_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_xkb_get_indicator_map_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xkb_get_indicator_map_cookie_t
xcb_xkb_get_indicator_map (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint32_t which);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xkb_get_indicator_map_cookie_t
xcb_xkb_get_indicator_map_unchecked (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint32_t which);
xcb_xkb_indicator_map_t *
xcb_xkb_get_indicator_map_maps (const xcb_xkb_get_indicator_map_reply_t *R);
int
xcb_xkb_get_indicator_map_maps_length (const xcb_xkb_get_indicator_map_reply_t *R);
xcb_xkb_indicator_map_iterator_t
xcb_xkb_get_indicator_map_maps_iterator (const xcb_xkb_get_indicator_map_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xkb_get_indicator_map_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xkb_get_indicator_map_reply_t *
xcb_xkb_get_indicator_map_reply (xcb_connection_t *c,
xcb_xkb_get_indicator_map_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_xkb_set_indicator_map_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xkb_set_indicator_map_checked (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint32_t which,
const xcb_xkb_indicator_map_t *maps);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xkb_set_indicator_map (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint32_t which,
const xcb_xkb_indicator_map_t *maps);
xcb_xkb_indicator_map_t *
xcb_xkb_set_indicator_map_maps (const xcb_xkb_set_indicator_map_request_t *R);
int
xcb_xkb_set_indicator_map_maps_length (const xcb_xkb_set_indicator_map_request_t *R);
xcb_xkb_indicator_map_iterator_t
xcb_xkb_set_indicator_map_maps_iterator (const xcb_xkb_set_indicator_map_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xkb_get_named_indicator_cookie_t
xcb_xkb_get_named_indicator (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
xcb_xkb_led_class_spec_t ledClass,
xcb_xkb_id_spec_t ledID,
xcb_atom_t indicator);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xkb_get_named_indicator_cookie_t
xcb_xkb_get_named_indicator_unchecked (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
xcb_xkb_led_class_spec_t ledClass,
xcb_xkb_id_spec_t ledID,
xcb_atom_t indicator);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xkb_get_named_indicator_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xkb_get_named_indicator_reply_t *
xcb_xkb_get_named_indicator_reply (xcb_connection_t *c,
xcb_xkb_get_named_indicator_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xkb_set_named_indicator_checked (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
xcb_xkb_led_class_spec_t ledClass,
xcb_xkb_id_spec_t ledID,
xcb_atom_t indicator,
uint8_t setState,
uint8_t on,
uint8_t setMap,
uint8_t createMap,
uint8_t map_flags,
uint8_t map_whichGroups,
uint8_t map_groups,
uint8_t map_whichMods,
uint8_t map_realMods,
uint16_t map_vmods,
uint32_t map_ctrls);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xkb_set_named_indicator (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
xcb_xkb_led_class_spec_t ledClass,
xcb_xkb_id_spec_t ledID,
xcb_atom_t indicator,
uint8_t setState,
uint8_t on,
uint8_t setMap,
uint8_t createMap,
uint8_t map_flags,
uint8_t map_whichGroups,
uint8_t map_groups,
uint8_t map_whichMods,
uint8_t map_realMods,
uint16_t map_vmods,
uint32_t map_ctrls);
xcb_atom_t *
xcb_xkb_get_names_value_list_type_names (const xcb_xkb_get_names_value_list_t *S);
int
xcb_xkb_get_names_value_list_type_names_length (const xcb_xkb_get_names_reply_t *R,
const xcb_xkb_get_names_value_list_t *S);
xcb_generic_iterator_t
xcb_xkb_get_names_value_list_type_names_end (const xcb_xkb_get_names_reply_t *R,
const xcb_xkb_get_names_value_list_t *S);
uint8_t *
xcb_xkb_get_names_value_list_n_levels_per_type (const xcb_xkb_get_names_value_list_t *S);
int
xcb_xkb_get_names_value_list_n_levels_per_type_length (const xcb_xkb_get_names_reply_t *R,
const xcb_xkb_get_names_value_list_t *S);
xcb_generic_iterator_t
xcb_xkb_get_names_value_list_n_levels_per_type_end (const xcb_xkb_get_names_reply_t *R,
const xcb_xkb_get_names_value_list_t *S);
xcb_atom_t *
xcb_xkb_get_names_value_list_kt_level_names (const xcb_xkb_get_names_value_list_t *S);
int
xcb_xkb_get_names_value_list_kt_level_names_length (const xcb_xkb_get_names_reply_t *R,
const xcb_xkb_get_names_value_list_t *S);
xcb_generic_iterator_t
xcb_xkb_get_names_value_list_kt_level_names_end (const xcb_xkb_get_names_reply_t *R,
const xcb_xkb_get_names_value_list_t *S);
xcb_atom_t *
xcb_xkb_get_names_value_list_indicator_names (const xcb_xkb_get_names_value_list_t *S);
int
xcb_xkb_get_names_value_list_indicator_names_length (const xcb_xkb_get_names_reply_t *R,
const xcb_xkb_get_names_value_list_t *S);
xcb_generic_iterator_t
xcb_xkb_get_names_value_list_indicator_names_end (const xcb_xkb_get_names_reply_t *R,
const xcb_xkb_get_names_value_list_t *S);
xcb_atom_t *
xcb_xkb_get_names_value_list_virtual_mod_names (const xcb_xkb_get_names_value_list_t *S);
int
xcb_xkb_get_names_value_list_virtual_mod_names_length (const xcb_xkb_get_names_reply_t *R,
const xcb_xkb_get_names_value_list_t *S);
xcb_generic_iterator_t
xcb_xkb_get_names_value_list_virtual_mod_names_end (const xcb_xkb_get_names_reply_t *R,
const xcb_xkb_get_names_value_list_t *S);
xcb_atom_t *
xcb_xkb_get_names_value_list_groups (const xcb_xkb_get_names_value_list_t *S);
int
xcb_xkb_get_names_value_list_groups_length (const xcb_xkb_get_names_reply_t *R,
const xcb_xkb_get_names_value_list_t *S);
xcb_generic_iterator_t
xcb_xkb_get_names_value_list_groups_end (const xcb_xkb_get_names_reply_t *R,
const xcb_xkb_get_names_value_list_t *S);
xcb_xkb_key_name_t *
xcb_xkb_get_names_value_list_key_names (const xcb_xkb_get_names_value_list_t *S);
int
xcb_xkb_get_names_value_list_key_names_length (const xcb_xkb_get_names_reply_t *R,
const xcb_xkb_get_names_value_list_t *S);
xcb_xkb_key_name_iterator_t
xcb_xkb_get_names_value_list_key_names_iterator (const xcb_xkb_get_names_reply_t *R,
const xcb_xkb_get_names_value_list_t *S);
xcb_xkb_key_alias_t *
xcb_xkb_get_names_value_list_key_aliases (const xcb_xkb_get_names_value_list_t *S);
int
xcb_xkb_get_names_value_list_key_aliases_length (const xcb_xkb_get_names_reply_t *R,
const xcb_xkb_get_names_value_list_t *S);
xcb_xkb_key_alias_iterator_t
xcb_xkb_get_names_value_list_key_aliases_iterator (const xcb_xkb_get_names_reply_t *R,
const xcb_xkb_get_names_value_list_t *S);
xcb_atom_t *
xcb_xkb_get_names_value_list_radio_group_names (const xcb_xkb_get_names_value_list_t *S);
int
xcb_xkb_get_names_value_list_radio_group_names_length (const xcb_xkb_get_names_reply_t *R,
const xcb_xkb_get_names_value_list_t *S);
xcb_generic_iterator_t
xcb_xkb_get_names_value_list_radio_group_names_end (const xcb_xkb_get_names_reply_t *R,
const xcb_xkb_get_names_value_list_t *S);
int
xcb_xkb_get_names_value_list_serialize (void **_buffer,
uint8_t nTypes,
uint32_t indicators,
uint16_t virtualMods,
uint8_t groupNames,
uint8_t nKeys,
uint8_t nKeyAliases,
uint8_t nRadioGroups,
uint32_t which,
const xcb_xkb_get_names_value_list_t *_aux);
int
xcb_xkb_get_names_value_list_unpack (const void *_buffer,
uint8_t nTypes,
uint32_t indicators,
uint16_t virtualMods,
uint8_t groupNames,
uint8_t nKeys,
uint8_t nKeyAliases,
uint8_t nRadioGroups,
uint32_t which,
xcb_xkb_get_names_value_list_t *_aux);
int
xcb_xkb_get_names_value_list_sizeof (const void *_buffer,
uint8_t nTypes,
uint32_t indicators,
uint16_t virtualMods,
uint8_t groupNames,
uint8_t nKeys,
uint8_t nKeyAliases,
uint8_t nRadioGroups,
uint32_t which);
int
xcb_xkb_get_names_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xkb_get_names_cookie_t
xcb_xkb_get_names (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint32_t which);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xkb_get_names_cookie_t
xcb_xkb_get_names_unchecked (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint32_t which);
void *
xcb_xkb_get_names_value_list (const xcb_xkb_get_names_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xkb_get_names_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xkb_get_names_reply_t *
xcb_xkb_get_names_reply (xcb_connection_t *c,
xcb_xkb_get_names_cookie_t cookie /**< */,
xcb_generic_error_t **e);
xcb_atom_t *
xcb_xkb_set_names_values_type_names (const xcb_xkb_set_names_values_t *S);
int
xcb_xkb_set_names_values_type_names_length (const xcb_xkb_set_names_request_t *R,
const xcb_xkb_set_names_values_t *S);
xcb_generic_iterator_t
xcb_xkb_set_names_values_type_names_end (const xcb_xkb_set_names_request_t *R,
const xcb_xkb_set_names_values_t *S);
uint8_t *
xcb_xkb_set_names_values_n_levels_per_type (const xcb_xkb_set_names_values_t *S);
int
xcb_xkb_set_names_values_n_levels_per_type_length (const xcb_xkb_set_names_request_t *R,
const xcb_xkb_set_names_values_t *S);
xcb_generic_iterator_t
xcb_xkb_set_names_values_n_levels_per_type_end (const xcb_xkb_set_names_request_t *R,
const xcb_xkb_set_names_values_t *S);
xcb_atom_t *
xcb_xkb_set_names_values_kt_level_names (const xcb_xkb_set_names_values_t *S);
int
xcb_xkb_set_names_values_kt_level_names_length (const xcb_xkb_set_names_request_t *R,
const xcb_xkb_set_names_values_t *S);
xcb_generic_iterator_t
xcb_xkb_set_names_values_kt_level_names_end (const xcb_xkb_set_names_request_t *R,
const xcb_xkb_set_names_values_t *S);
xcb_atom_t *
xcb_xkb_set_names_values_indicator_names (const xcb_xkb_set_names_values_t *S);
int
xcb_xkb_set_names_values_indicator_names_length (const xcb_xkb_set_names_request_t *R,
const xcb_xkb_set_names_values_t *S);
xcb_generic_iterator_t
xcb_xkb_set_names_values_indicator_names_end (const xcb_xkb_set_names_request_t *R,
const xcb_xkb_set_names_values_t *S);
xcb_atom_t *
xcb_xkb_set_names_values_virtual_mod_names (const xcb_xkb_set_names_values_t *S);
int
xcb_xkb_set_names_values_virtual_mod_names_length (const xcb_xkb_set_names_request_t *R,
const xcb_xkb_set_names_values_t *S);
xcb_generic_iterator_t
xcb_xkb_set_names_values_virtual_mod_names_end (const xcb_xkb_set_names_request_t *R,
const xcb_xkb_set_names_values_t *S);
xcb_atom_t *
xcb_xkb_set_names_values_groups (const xcb_xkb_set_names_values_t *S);
int
xcb_xkb_set_names_values_groups_length (const xcb_xkb_set_names_request_t *R,
const xcb_xkb_set_names_values_t *S);
xcb_generic_iterator_t
xcb_xkb_set_names_values_groups_end (const xcb_xkb_set_names_request_t *R,
const xcb_xkb_set_names_values_t *S);
xcb_xkb_key_name_t *
xcb_xkb_set_names_values_key_names (const xcb_xkb_set_names_values_t *S);
int
xcb_xkb_set_names_values_key_names_length (const xcb_xkb_set_names_request_t *R,
const xcb_xkb_set_names_values_t *S);
xcb_xkb_key_name_iterator_t
xcb_xkb_set_names_values_key_names_iterator (const xcb_xkb_set_names_request_t *R,
const xcb_xkb_set_names_values_t *S);
xcb_xkb_key_alias_t *
xcb_xkb_set_names_values_key_aliases (const xcb_xkb_set_names_values_t *S);
int
xcb_xkb_set_names_values_key_aliases_length (const xcb_xkb_set_names_request_t *R,
const xcb_xkb_set_names_values_t *S);
xcb_xkb_key_alias_iterator_t
xcb_xkb_set_names_values_key_aliases_iterator (const xcb_xkb_set_names_request_t *R,
const xcb_xkb_set_names_values_t *S);
xcb_atom_t *
xcb_xkb_set_names_values_radio_group_names (const xcb_xkb_set_names_values_t *S);
int
xcb_xkb_set_names_values_radio_group_names_length (const xcb_xkb_set_names_request_t *R,
const xcb_xkb_set_names_values_t *S);
xcb_generic_iterator_t
xcb_xkb_set_names_values_radio_group_names_end (const xcb_xkb_set_names_request_t *R,
const xcb_xkb_set_names_values_t *S);
int
xcb_xkb_set_names_values_serialize (void **_buffer,
uint8_t nTypes,
uint32_t indicators,
uint16_t virtualMods,
uint8_t groupNames,
uint8_t nKeys,
uint8_t nKeyAliases,
uint8_t nRadioGroups,
uint32_t which,
const xcb_xkb_set_names_values_t *_aux);
int
xcb_xkb_set_names_values_unpack (const void *_buffer,
uint8_t nTypes,
uint32_t indicators,
uint16_t virtualMods,
uint8_t groupNames,
uint8_t nKeys,
uint8_t nKeyAliases,
uint8_t nRadioGroups,
uint32_t which,
xcb_xkb_set_names_values_t *_aux);
int
xcb_xkb_set_names_values_sizeof (const void *_buffer,
uint8_t nTypes,
uint32_t indicators,
uint16_t virtualMods,
uint8_t groupNames,
uint8_t nKeys,
uint8_t nKeyAliases,
uint8_t nRadioGroups,
uint32_t which);
int
xcb_xkb_set_names_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xkb_set_names_checked (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint16_t virtualMods,
uint32_t which,
uint8_t firstType,
uint8_t nTypes,
uint8_t firstKTLevelt,
uint8_t nKTLevels,
uint32_t indicators,
uint8_t groupNames,
uint8_t nRadioGroups,
xcb_keycode_t firstKey,
uint8_t nKeys,
uint8_t nKeyAliases,
uint16_t totalKTLevelNames,
const void *values);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xkb_set_names (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint16_t virtualMods,
uint32_t which,
uint8_t firstType,
uint8_t nTypes,
uint8_t firstKTLevelt,
uint8_t nKTLevels,
uint32_t indicators,
uint8_t groupNames,
uint8_t nRadioGroups,
xcb_keycode_t firstKey,
uint8_t nKeys,
uint8_t nKeyAliases,
uint16_t totalKTLevelNames,
const void *values);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xkb_set_names_aux_checked (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint16_t virtualMods,
uint32_t which,
uint8_t firstType,
uint8_t nTypes,
uint8_t firstKTLevelt,
uint8_t nKTLevels,
uint32_t indicators,
uint8_t groupNames,
uint8_t nRadioGroups,
xcb_keycode_t firstKey,
uint8_t nKeys,
uint8_t nKeyAliases,
uint16_t totalKTLevelNames,
const xcb_xkb_set_names_values_t *values);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xkb_set_names_aux (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint16_t virtualMods,
uint32_t which,
uint8_t firstType,
uint8_t nTypes,
uint8_t firstKTLevelt,
uint8_t nKTLevels,
uint32_t indicators,
uint8_t groupNames,
uint8_t nRadioGroups,
xcb_keycode_t firstKey,
uint8_t nKeys,
uint8_t nKeyAliases,
uint16_t totalKTLevelNames,
const xcb_xkb_set_names_values_t *values);
void *
xcb_xkb_set_names_values (const xcb_xkb_set_names_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xkb_per_client_flags_cookie_t
xcb_xkb_per_client_flags (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint32_t change,
uint32_t value,
uint32_t ctrlsToChange,
uint32_t autoCtrls,
uint32_t autoCtrlsValues);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xkb_per_client_flags_cookie_t
xcb_xkb_per_client_flags_unchecked (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint32_t change,
uint32_t value,
uint32_t ctrlsToChange,
uint32_t autoCtrls,
uint32_t autoCtrlsValues);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xkb_per_client_flags_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xkb_per_client_flags_reply_t *
xcb_xkb_per_client_flags_reply (xcb_connection_t *c,
xcb_xkb_per_client_flags_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_xkb_list_components_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xkb_list_components_cookie_t
xcb_xkb_list_components (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint16_t maxNames);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xkb_list_components_cookie_t
xcb_xkb_list_components_unchecked (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint16_t maxNames);
int
xcb_xkb_list_components_keymaps_length (const xcb_xkb_list_components_reply_t *R);
xcb_xkb_listing_iterator_t
xcb_xkb_list_components_keymaps_iterator (const xcb_xkb_list_components_reply_t *R);
int
xcb_xkb_list_components_keycodes_length (const xcb_xkb_list_components_reply_t *R);
xcb_xkb_listing_iterator_t
xcb_xkb_list_components_keycodes_iterator (const xcb_xkb_list_components_reply_t *R);
int
xcb_xkb_list_components_types_length (const xcb_xkb_list_components_reply_t *R);
xcb_xkb_listing_iterator_t
xcb_xkb_list_components_types_iterator (const xcb_xkb_list_components_reply_t *R);
int
xcb_xkb_list_components_compat_maps_length (const xcb_xkb_list_components_reply_t *R);
xcb_xkb_listing_iterator_t
xcb_xkb_list_components_compat_maps_iterator (const xcb_xkb_list_components_reply_t *R);
int
xcb_xkb_list_components_symbols_length (const xcb_xkb_list_components_reply_t *R);
xcb_xkb_listing_iterator_t
xcb_xkb_list_components_symbols_iterator (const xcb_xkb_list_components_reply_t *R);
int
xcb_xkb_list_components_geometries_length (const xcb_xkb_list_components_reply_t *R);
xcb_xkb_listing_iterator_t
xcb_xkb_list_components_geometries_iterator (const xcb_xkb_list_components_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xkb_list_components_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xkb_list_components_reply_t *
xcb_xkb_list_components_reply (xcb_connection_t *c,
xcb_xkb_list_components_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_xkb_get_kbd_by_name_replies_types_map_types_rtrn_length (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_xkb_key_type_iterator_t
xcb_xkb_get_kbd_by_name_replies_types_map_types_rtrn_iterator (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
int
xcb_xkb_get_kbd_by_name_replies_types_map_syms_rtrn_length (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_xkb_key_sym_map_iterator_t
xcb_xkb_get_kbd_by_name_replies_types_map_syms_rtrn_iterator (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
uint8_t *
xcb_xkb_get_kbd_by_name_replies_types_map_acts_rtrn_count (const xcb_xkb_get_kbd_by_name_replies_t *S);
int
xcb_xkb_get_kbd_by_name_replies_types_map_acts_rtrn_count_length (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_generic_iterator_t
xcb_xkb_get_kbd_by_name_replies_types_map_acts_rtrn_count_end (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_xkb_action_t *
xcb_xkb_get_kbd_by_name_replies_types_map_acts_rtrn_acts (const xcb_xkb_get_kbd_by_name_replies_t *S);
int
xcb_xkb_get_kbd_by_name_replies_types_map_acts_rtrn_acts_length (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_xkb_action_iterator_t
xcb_xkb_get_kbd_by_name_replies_types_map_acts_rtrn_acts_iterator (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_xkb_set_behavior_t *
xcb_xkb_get_kbd_by_name_replies_types_map_behaviors_rtrn (const xcb_xkb_get_kbd_by_name_replies_t *S);
int
xcb_xkb_get_kbd_by_name_replies_types_map_behaviors_rtrn_length (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_xkb_set_behavior_iterator_t
xcb_xkb_get_kbd_by_name_replies_types_map_behaviors_rtrn_iterator (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
uint8_t *
xcb_xkb_get_kbd_by_name_replies_types_map_vmods_rtrn (const xcb_xkb_get_kbd_by_name_replies_t *S);
int
xcb_xkb_get_kbd_by_name_replies_types_map_vmods_rtrn_length (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_generic_iterator_t
xcb_xkb_get_kbd_by_name_replies_types_map_vmods_rtrn_end (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_xkb_set_explicit_t *
xcb_xkb_get_kbd_by_name_replies_types_map_explicit_rtrn (const xcb_xkb_get_kbd_by_name_replies_t *S);
int
xcb_xkb_get_kbd_by_name_replies_types_map_explicit_rtrn_length (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_xkb_set_explicit_iterator_t
xcb_xkb_get_kbd_by_name_replies_types_map_explicit_rtrn_iterator (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_xkb_key_mod_map_t *
xcb_xkb_get_kbd_by_name_replies_types_map_modmap_rtrn (const xcb_xkb_get_kbd_by_name_replies_t *S);
int
xcb_xkb_get_kbd_by_name_replies_types_map_modmap_rtrn_length (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_xkb_key_mod_map_iterator_t
xcb_xkb_get_kbd_by_name_replies_types_map_modmap_rtrn_iterator (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_xkb_key_v_mod_map_t *
xcb_xkb_get_kbd_by_name_replies_types_map_vmodmap_rtrn (const xcb_xkb_get_kbd_by_name_replies_t *S);
int
xcb_xkb_get_kbd_by_name_replies_types_map_vmodmap_rtrn_length (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_xkb_key_v_mod_map_iterator_t
xcb_xkb_get_kbd_by_name_replies_types_map_vmodmap_rtrn_iterator (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
int
xcb_xkb_get_kbd_by_name_replies_types_map_serialize (void **_buffer,
uint8_t nTypes,
uint8_t nKeySyms,
uint8_t nKeyActions,
uint16_t totalActions,
uint8_t totalKeyBehaviors,
uint16_t virtualMods,
uint8_t totalKeyExplicit,
uint8_t totalModMapKeys,
uint8_t totalVModMapKeys,
uint16_t present,
const xcb_xkb_get_kbd_by_name_replies_types_map_t *_aux);
int
xcb_xkb_get_kbd_by_name_replies_types_map_unpack (const void *_buffer,
uint8_t nTypes,
uint8_t nKeySyms,
uint8_t nKeyActions,
uint16_t totalActions,
uint8_t totalKeyBehaviors,
uint16_t virtualMods,
uint8_t totalKeyExplicit,
uint8_t totalModMapKeys,
uint8_t totalVModMapKeys,
uint16_t present,
xcb_xkb_get_kbd_by_name_replies_types_map_t *_aux);
int
xcb_xkb_get_kbd_by_name_replies_types_map_sizeof (const void *_buffer,
uint8_t nTypes,
uint8_t nKeySyms,
uint8_t nKeyActions,
uint16_t totalActions,
uint8_t totalKeyBehaviors,
uint16_t virtualMods,
uint8_t totalKeyExplicit,
uint8_t totalModMapKeys,
uint8_t totalVModMapKeys,
uint16_t present);
xcb_atom_t *
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_type_names (const xcb_xkb_get_kbd_by_name_replies_t *S);
int
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_type_names_length (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_generic_iterator_t
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_type_names_end (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
uint8_t *
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_n_levels_per_type (const xcb_xkb_get_kbd_by_name_replies_t *S);
int
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_n_levels_per_type_length (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_generic_iterator_t
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_n_levels_per_type_end (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_atom_t *
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_kt_level_names (const xcb_xkb_get_kbd_by_name_replies_t *S);
int
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_kt_level_names_length (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_generic_iterator_t
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_kt_level_names_end (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_atom_t *
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_indicator_names (const xcb_xkb_get_kbd_by_name_replies_t *S);
int
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_indicator_names_length (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_generic_iterator_t
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_indicator_names_end (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_atom_t *
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_virtual_mod_names (const xcb_xkb_get_kbd_by_name_replies_t *S);
int
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_virtual_mod_names_length (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_generic_iterator_t
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_virtual_mod_names_end (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_atom_t *
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_groups (const xcb_xkb_get_kbd_by_name_replies_t *S);
int
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_groups_length (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_generic_iterator_t
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_groups_end (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_xkb_key_name_t *
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_key_names (const xcb_xkb_get_kbd_by_name_replies_t *S);
int
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_key_names_length (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_xkb_key_name_iterator_t
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_key_names_iterator (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_xkb_key_alias_t *
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_key_aliases (const xcb_xkb_get_kbd_by_name_replies_t *S);
int
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_key_aliases_length (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_xkb_key_alias_iterator_t
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_key_aliases_iterator (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_atom_t *
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_radio_group_names (const xcb_xkb_get_kbd_by_name_replies_t *S);
int
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_radio_group_names_length (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_generic_iterator_t
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_radio_group_names_end (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
int
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_serialize (void **_buffer,
uint8_t nTypes,
uint32_t indicators,
uint16_t virtualMods,
uint8_t groupNames,
uint8_t nKeys,
uint8_t nKeyAliases,
uint8_t nRadioGroups,
uint32_t which,
const xcb_xkb_get_kbd_by_name_replies_key_names_value_list_t *_aux);
int
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_unpack (const void *_buffer,
uint8_t nTypes,
uint32_t indicators,
uint16_t virtualMods,
uint8_t groupNames,
uint8_t nKeys,
uint8_t nKeyAliases,
uint8_t nRadioGroups,
uint32_t which,
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_t *_aux);
int
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_sizeof (const void *_buffer,
uint8_t nTypes,
uint32_t indicators,
uint16_t virtualMods,
uint8_t groupNames,
uint8_t nKeys,
uint8_t nKeyAliases,
uint8_t nRadioGroups,
uint32_t which);
xcb_xkb_sym_interpret_t *
xcb_xkb_get_kbd_by_name_replies_compat_map_si_rtrn (const xcb_xkb_get_kbd_by_name_replies_t *S);
int
xcb_xkb_get_kbd_by_name_replies_compat_map_si_rtrn_length (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_xkb_sym_interpret_iterator_t
xcb_xkb_get_kbd_by_name_replies_compat_map_si_rtrn_iterator (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_xkb_mod_def_t *
xcb_xkb_get_kbd_by_name_replies_compat_map_group_rtrn (const xcb_xkb_get_kbd_by_name_replies_t *S);
int
xcb_xkb_get_kbd_by_name_replies_compat_map_group_rtrn_length (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_xkb_mod_def_iterator_t
xcb_xkb_get_kbd_by_name_replies_compat_map_group_rtrn_iterator (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_xkb_indicator_map_t *
xcb_xkb_get_kbd_by_name_replies_indicator_maps_maps (const xcb_xkb_get_kbd_by_name_replies_t *S);
int
xcb_xkb_get_kbd_by_name_replies_indicator_maps_maps_length (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_xkb_indicator_map_iterator_t
xcb_xkb_get_kbd_by_name_replies_indicator_maps_maps_iterator (const xcb_xkb_get_kbd_by_name_reply_t *R,
const xcb_xkb_get_kbd_by_name_replies_t *S);
xcb_xkb_get_kbd_by_name_replies_key_names_value_list_t *
xcb_xkb_get_kbd_by_name_replies_key_names_value_list (const xcb_xkb_get_kbd_by_name_replies_t *R);
xcb_xkb_counted_string_16_t *
xcb_xkb_get_kbd_by_name_replies_geometry_label_font (const xcb_xkb_get_kbd_by_name_replies_t *R);
int
xcb_xkb_get_kbd_by_name_replies_serialize (void **_buffer,
uint16_t reported,
const xcb_xkb_get_kbd_by_name_replies_t *_aux);
int
xcb_xkb_get_kbd_by_name_replies_unpack (const void *_buffer,
uint16_t reported,
xcb_xkb_get_kbd_by_name_replies_t *_aux);
int
xcb_xkb_get_kbd_by_name_replies_sizeof (const void *_buffer,
uint16_t reported);
int
xcb_xkb_get_kbd_by_name_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xkb_get_kbd_by_name_cookie_t
xcb_xkb_get_kbd_by_name (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint16_t need,
uint16_t want,
uint8_t load);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xkb_get_kbd_by_name_cookie_t
xcb_xkb_get_kbd_by_name_unchecked (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint16_t need,
uint16_t want,
uint8_t load);
void *
xcb_xkb_get_kbd_by_name_replies (const xcb_xkb_get_kbd_by_name_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xkb_get_kbd_by_name_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xkb_get_kbd_by_name_reply_t *
xcb_xkb_get_kbd_by_name_reply (xcb_connection_t *c,
xcb_xkb_get_kbd_by_name_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_xkb_get_device_info_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xkb_get_device_info_cookie_t
xcb_xkb_get_device_info (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint16_t wanted,
uint8_t allButtons,
uint8_t firstButton,
uint8_t nButtons,
xcb_xkb_led_class_spec_t ledClass,
xcb_xkb_id_spec_t ledID);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xkb_get_device_info_cookie_t
xcb_xkb_get_device_info_unchecked (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint16_t wanted,
uint8_t allButtons,
uint8_t firstButton,
uint8_t nButtons,
xcb_xkb_led_class_spec_t ledClass,
xcb_xkb_id_spec_t ledID);
xcb_xkb_string8_t *
xcb_xkb_get_device_info_name (const xcb_xkb_get_device_info_reply_t *R);
int
xcb_xkb_get_device_info_name_length (const xcb_xkb_get_device_info_reply_t *R);
xcb_generic_iterator_t
xcb_xkb_get_device_info_name_end (const xcb_xkb_get_device_info_reply_t *R);
xcb_xkb_action_t *
xcb_xkb_get_device_info_btn_actions (const xcb_xkb_get_device_info_reply_t *R);
int
xcb_xkb_get_device_info_btn_actions_length (const xcb_xkb_get_device_info_reply_t *R);
xcb_xkb_action_iterator_t
xcb_xkb_get_device_info_btn_actions_iterator (const xcb_xkb_get_device_info_reply_t *R);
int
xcb_xkb_get_device_info_leds_length (const xcb_xkb_get_device_info_reply_t *R);
xcb_xkb_device_led_info_iterator_t
xcb_xkb_get_device_info_leds_iterator (const xcb_xkb_get_device_info_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xkb_get_device_info_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xkb_get_device_info_reply_t *
xcb_xkb_get_device_info_reply (xcb_connection_t *c,
xcb_xkb_get_device_info_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_xkb_set_device_info_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xkb_set_device_info_checked (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint8_t firstBtn,
uint8_t nBtns,
uint16_t change,
uint16_t nDeviceLedFBs,
const xcb_xkb_action_t *btnActions,
const xcb_xkb_device_led_info_t *leds);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xkb_set_device_info (xcb_connection_t *c,
xcb_xkb_device_spec_t deviceSpec,
uint8_t firstBtn,
uint8_t nBtns,
uint16_t change,
uint16_t nDeviceLedFBs,
const xcb_xkb_action_t *btnActions,
const xcb_xkb_device_led_info_t *leds);
xcb_xkb_action_t *
xcb_xkb_set_device_info_btn_actions (const xcb_xkb_set_device_info_request_t *R);
int
xcb_xkb_set_device_info_btn_actions_length (const xcb_xkb_set_device_info_request_t *R);
xcb_xkb_action_iterator_t
xcb_xkb_set_device_info_btn_actions_iterator (const xcb_xkb_set_device_info_request_t *R);
int
xcb_xkb_set_device_info_leds_length (const xcb_xkb_set_device_info_request_t *R);
xcb_xkb_device_led_info_iterator_t
xcb_xkb_set_device_info_leds_iterator (const xcb_xkb_set_device_info_request_t *R);
int
xcb_xkb_set_debugging_flags_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xkb_set_debugging_flags_cookie_t
xcb_xkb_set_debugging_flags (xcb_connection_t *c,
uint16_t msgLength,
uint32_t affectFlags,
uint32_t flags,
uint32_t affectCtrls,
uint32_t ctrls,
const xcb_xkb_string8_t *message);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xkb_set_debugging_flags_cookie_t
xcb_xkb_set_debugging_flags_unchecked (xcb_connection_t *c,
uint16_t msgLength,
uint32_t affectFlags,
uint32_t flags,
uint32_t affectCtrls,
uint32_t ctrls,
const xcb_xkb_string8_t *message);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xkb_set_debugging_flags_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xkb_set_debugging_flags_reply_t *
xcb_xkb_set_debugging_flags_reply (xcb_connection_t *c,
xcb_xkb_set_debugging_flags_cookie_t cookie /**< */,
xcb_generic_error_t **e);
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/
xcb/xprint.h 0000644 00000157543 15201526705 0007037 0 ustar 00 /*
* This file generated automatically from xprint.xml by c_client.py.
* Edit at your peril.
*/
/**
* @defgroup XCB_XPrint_API XCB XPrint API
* @brief XPrint XCB Protocol Implementation.
* @{
**/
#ifndef __XPRINT_H
#define __XPRINT_H
#include "xcb.h"
#include "xproto.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XCB_XPRINT_MAJOR_VERSION 1
#define XCB_XPRINT_MINOR_VERSION 0
extern xcb_extension_t xcb_x_print_id;
typedef char xcb_x_print_string8_t;
/**
* @brief xcb_x_print_string8_iterator_t
**/
typedef struct xcb_x_print_string8_iterator_t {
xcb_x_print_string8_t *data;
int rem;
int index;
} xcb_x_print_string8_iterator_t;
/**
* @brief xcb_x_print_printer_t
**/
typedef struct xcb_x_print_printer_t {
uint32_t nameLen;
uint32_t descLen;
} xcb_x_print_printer_t;
/**
* @brief xcb_x_print_printer_iterator_t
**/
typedef struct xcb_x_print_printer_iterator_t {
xcb_x_print_printer_t *data;
int rem;
int index;
} xcb_x_print_printer_iterator_t;
typedef uint32_t xcb_x_print_pcontext_t;
/**
* @brief xcb_x_print_pcontext_iterator_t
**/
typedef struct xcb_x_print_pcontext_iterator_t {
xcb_x_print_pcontext_t *data;
int rem;
int index;
} xcb_x_print_pcontext_iterator_t;
typedef enum xcb_x_print_get_doc_t {
XCB_X_PRINT_GET_DOC_FINISHED = 0,
XCB_X_PRINT_GET_DOC_SECOND_CONSUMER = 1
} xcb_x_print_get_doc_t;
typedef enum xcb_x_print_ev_mask_t {
XCB_X_PRINT_EV_MASK_NO_EVENT_MASK = 0,
XCB_X_PRINT_EV_MASK_PRINT_MASK = 1,
XCB_X_PRINT_EV_MASK_ATTRIBUTE_MASK = 2
} xcb_x_print_ev_mask_t;
typedef enum xcb_x_print_detail_t {
XCB_X_PRINT_DETAIL_START_JOB_NOTIFY = 1,
XCB_X_PRINT_DETAIL_END_JOB_NOTIFY = 2,
XCB_X_PRINT_DETAIL_START_DOC_NOTIFY = 3,
XCB_X_PRINT_DETAIL_END_DOC_NOTIFY = 4,
XCB_X_PRINT_DETAIL_START_PAGE_NOTIFY = 5,
XCB_X_PRINT_DETAIL_END_PAGE_NOTIFY = 6
} xcb_x_print_detail_t;
typedef enum xcb_x_print_attr_t {
XCB_X_PRINT_ATTR_JOB_ATTR = 1,
XCB_X_PRINT_ATTR_DOC_ATTR = 2,
XCB_X_PRINT_ATTR_PAGE_ATTR = 3,
XCB_X_PRINT_ATTR_PRINTER_ATTR = 4,
XCB_X_PRINT_ATTR_SERVER_ATTR = 5,
XCB_X_PRINT_ATTR_MEDIUM_ATTR = 6,
XCB_X_PRINT_ATTR_SPOOLER_ATTR = 7
} xcb_x_print_attr_t;
/**
* @brief xcb_x_print_print_query_version_cookie_t
**/
typedef struct xcb_x_print_print_query_version_cookie_t {
unsigned int sequence;
} xcb_x_print_print_query_version_cookie_t;
/** Opcode for xcb_x_print_print_query_version. */
#define XCB_X_PRINT_PRINT_QUERY_VERSION 0
/**
* @brief xcb_x_print_print_query_version_request_t
**/
typedef struct xcb_x_print_print_query_version_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_x_print_print_query_version_request_t;
/**
* @brief xcb_x_print_print_query_version_reply_t
**/
typedef struct xcb_x_print_print_query_version_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t major_version;
uint16_t minor_version;
} xcb_x_print_print_query_version_reply_t;
/**
* @brief xcb_x_print_print_get_printer_list_cookie_t
**/
typedef struct xcb_x_print_print_get_printer_list_cookie_t {
unsigned int sequence;
} xcb_x_print_print_get_printer_list_cookie_t;
/** Opcode for xcb_x_print_print_get_printer_list. */
#define XCB_X_PRINT_PRINT_GET_PRINTER_LIST 1
/**
* @brief xcb_x_print_print_get_printer_list_request_t
**/
typedef struct xcb_x_print_print_get_printer_list_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t printerNameLen;
uint32_t localeLen;
} xcb_x_print_print_get_printer_list_request_t;
/**
* @brief xcb_x_print_print_get_printer_list_reply_t
**/
typedef struct xcb_x_print_print_get_printer_list_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t listCount;
uint8_t pad1[20];
} xcb_x_print_print_get_printer_list_reply_t;
/** Opcode for xcb_x_print_print_rehash_printer_list. */
#define XCB_X_PRINT_PRINT_REHASH_PRINTER_LIST 20
/**
* @brief xcb_x_print_print_rehash_printer_list_request_t
**/
typedef struct xcb_x_print_print_rehash_printer_list_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_x_print_print_rehash_printer_list_request_t;
/** Opcode for xcb_x_print_create_context. */
#define XCB_X_PRINT_CREATE_CONTEXT 2
/**
* @brief xcb_x_print_create_context_request_t
**/
typedef struct xcb_x_print_create_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t context_id;
uint32_t printerNameLen;
uint32_t localeLen;
} xcb_x_print_create_context_request_t;
/** Opcode for xcb_x_print_print_set_context. */
#define XCB_X_PRINT_PRINT_SET_CONTEXT 3
/**
* @brief xcb_x_print_print_set_context_request_t
**/
typedef struct xcb_x_print_print_set_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t context;
} xcb_x_print_print_set_context_request_t;
/**
* @brief xcb_x_print_print_get_context_cookie_t
**/
typedef struct xcb_x_print_print_get_context_cookie_t {
unsigned int sequence;
} xcb_x_print_print_get_context_cookie_t;
/** Opcode for xcb_x_print_print_get_context. */
#define XCB_X_PRINT_PRINT_GET_CONTEXT 4
/**
* @brief xcb_x_print_print_get_context_request_t
**/
typedef struct xcb_x_print_print_get_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_x_print_print_get_context_request_t;
/**
* @brief xcb_x_print_print_get_context_reply_t
**/
typedef struct xcb_x_print_print_get_context_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t context;
} xcb_x_print_print_get_context_reply_t;
/** Opcode for xcb_x_print_print_destroy_context. */
#define XCB_X_PRINT_PRINT_DESTROY_CONTEXT 5
/**
* @brief xcb_x_print_print_destroy_context_request_t
**/
typedef struct xcb_x_print_print_destroy_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t context;
} xcb_x_print_print_destroy_context_request_t;
/**
* @brief xcb_x_print_print_get_screen_of_context_cookie_t
**/
typedef struct xcb_x_print_print_get_screen_of_context_cookie_t {
unsigned int sequence;
} xcb_x_print_print_get_screen_of_context_cookie_t;
/** Opcode for xcb_x_print_print_get_screen_of_context. */
#define XCB_X_PRINT_PRINT_GET_SCREEN_OF_CONTEXT 6
/**
* @brief xcb_x_print_print_get_screen_of_context_request_t
**/
typedef struct xcb_x_print_print_get_screen_of_context_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_x_print_print_get_screen_of_context_request_t;
/**
* @brief xcb_x_print_print_get_screen_of_context_reply_t
**/
typedef struct xcb_x_print_print_get_screen_of_context_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
xcb_window_t root;
} xcb_x_print_print_get_screen_of_context_reply_t;
/** Opcode for xcb_x_print_print_start_job. */
#define XCB_X_PRINT_PRINT_START_JOB 7
/**
* @brief xcb_x_print_print_start_job_request_t
**/
typedef struct xcb_x_print_print_start_job_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t output_mode;
} xcb_x_print_print_start_job_request_t;
/** Opcode for xcb_x_print_print_end_job. */
#define XCB_X_PRINT_PRINT_END_JOB 8
/**
* @brief xcb_x_print_print_end_job_request_t
**/
typedef struct xcb_x_print_print_end_job_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t cancel;
} xcb_x_print_print_end_job_request_t;
/** Opcode for xcb_x_print_print_start_doc. */
#define XCB_X_PRINT_PRINT_START_DOC 9
/**
* @brief xcb_x_print_print_start_doc_request_t
**/
typedef struct xcb_x_print_print_start_doc_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t driver_mode;
} xcb_x_print_print_start_doc_request_t;
/** Opcode for xcb_x_print_print_end_doc. */
#define XCB_X_PRINT_PRINT_END_DOC 10
/**
* @brief xcb_x_print_print_end_doc_request_t
**/
typedef struct xcb_x_print_print_end_doc_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t cancel;
} xcb_x_print_print_end_doc_request_t;
/** Opcode for xcb_x_print_print_put_document_data. */
#define XCB_X_PRINT_PRINT_PUT_DOCUMENT_DATA 11
/**
* @brief xcb_x_print_print_put_document_data_request_t
**/
typedef struct xcb_x_print_print_put_document_data_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_drawable_t drawable;
uint32_t len_data;
uint16_t len_fmt;
uint16_t len_options;
} xcb_x_print_print_put_document_data_request_t;
/**
* @brief xcb_x_print_print_get_document_data_cookie_t
**/
typedef struct xcb_x_print_print_get_document_data_cookie_t {
unsigned int sequence;
} xcb_x_print_print_get_document_data_cookie_t;
/** Opcode for xcb_x_print_print_get_document_data. */
#define XCB_X_PRINT_PRINT_GET_DOCUMENT_DATA 12
/**
* @brief xcb_x_print_print_get_document_data_request_t
**/
typedef struct xcb_x_print_print_get_document_data_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_x_print_pcontext_t context;
uint32_t max_bytes;
} xcb_x_print_print_get_document_data_request_t;
/**
* @brief xcb_x_print_print_get_document_data_reply_t
**/
typedef struct xcb_x_print_print_get_document_data_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t status_code;
uint32_t finished_flag;
uint32_t dataLen;
uint8_t pad1[12];
} xcb_x_print_print_get_document_data_reply_t;
/** Opcode for xcb_x_print_print_start_page. */
#define XCB_X_PRINT_PRINT_START_PAGE 13
/**
* @brief xcb_x_print_print_start_page_request_t
**/
typedef struct xcb_x_print_print_start_page_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
} xcb_x_print_print_start_page_request_t;
/** Opcode for xcb_x_print_print_end_page. */
#define XCB_X_PRINT_PRINT_END_PAGE 14
/**
* @brief xcb_x_print_print_end_page_request_t
**/
typedef struct xcb_x_print_print_end_page_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t cancel;
uint8_t pad0[3];
} xcb_x_print_print_end_page_request_t;
/** Opcode for xcb_x_print_print_select_input. */
#define XCB_X_PRINT_PRINT_SELECT_INPUT 15
/**
* @brief xcb_x_print_print_select_input_request_t
**/
typedef struct xcb_x_print_print_select_input_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_x_print_pcontext_t context;
uint32_t event_mask;
} xcb_x_print_print_select_input_request_t;
/**
* @brief xcb_x_print_print_input_selected_cookie_t
**/
typedef struct xcb_x_print_print_input_selected_cookie_t {
unsigned int sequence;
} xcb_x_print_print_input_selected_cookie_t;
/** Opcode for xcb_x_print_print_input_selected. */
#define XCB_X_PRINT_PRINT_INPUT_SELECTED 16
/**
* @brief xcb_x_print_print_input_selected_request_t
**/
typedef struct xcb_x_print_print_input_selected_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_x_print_pcontext_t context;
} xcb_x_print_print_input_selected_request_t;
/**
* @brief xcb_x_print_print_input_selected_reply_t
**/
typedef struct xcb_x_print_print_input_selected_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t event_mask;
uint32_t all_events_mask;
} xcb_x_print_print_input_selected_reply_t;
/**
* @brief xcb_x_print_print_get_attributes_cookie_t
**/
typedef struct xcb_x_print_print_get_attributes_cookie_t {
unsigned int sequence;
} xcb_x_print_print_get_attributes_cookie_t;
/** Opcode for xcb_x_print_print_get_attributes. */
#define XCB_X_PRINT_PRINT_GET_ATTRIBUTES 17
/**
* @brief xcb_x_print_print_get_attributes_request_t
**/
typedef struct xcb_x_print_print_get_attributes_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_x_print_pcontext_t context;
uint8_t pool;
uint8_t pad0[3];
} xcb_x_print_print_get_attributes_request_t;
/**
* @brief xcb_x_print_print_get_attributes_reply_t
**/
typedef struct xcb_x_print_print_get_attributes_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t stringLen;
uint8_t pad1[20];
} xcb_x_print_print_get_attributes_reply_t;
/**
* @brief xcb_x_print_print_get_one_attributes_cookie_t
**/
typedef struct xcb_x_print_print_get_one_attributes_cookie_t {
unsigned int sequence;
} xcb_x_print_print_get_one_attributes_cookie_t;
/** Opcode for xcb_x_print_print_get_one_attributes. */
#define XCB_X_PRINT_PRINT_GET_ONE_ATTRIBUTES 19
/**
* @brief xcb_x_print_print_get_one_attributes_request_t
**/
typedef struct xcb_x_print_print_get_one_attributes_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_x_print_pcontext_t context;
uint32_t nameLen;
uint8_t pool;
uint8_t pad0[3];
} xcb_x_print_print_get_one_attributes_request_t;
/**
* @brief xcb_x_print_print_get_one_attributes_reply_t
**/
typedef struct xcb_x_print_print_get_one_attributes_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t valueLen;
uint8_t pad1[20];
} xcb_x_print_print_get_one_attributes_reply_t;
/** Opcode for xcb_x_print_print_set_attributes. */
#define XCB_X_PRINT_PRINT_SET_ATTRIBUTES 18
/**
* @brief xcb_x_print_print_set_attributes_request_t
**/
typedef struct xcb_x_print_print_set_attributes_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_x_print_pcontext_t context;
uint32_t stringLen;
uint8_t pool;
uint8_t rule;
uint8_t pad0[2];
} xcb_x_print_print_set_attributes_request_t;
/**
* @brief xcb_x_print_print_get_page_dimensions_cookie_t
**/
typedef struct xcb_x_print_print_get_page_dimensions_cookie_t {
unsigned int sequence;
} xcb_x_print_print_get_page_dimensions_cookie_t;
/** Opcode for xcb_x_print_print_get_page_dimensions. */
#define XCB_X_PRINT_PRINT_GET_PAGE_DIMENSIONS 21
/**
* @brief xcb_x_print_print_get_page_dimensions_request_t
**/
typedef struct xcb_x_print_print_get_page_dimensions_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_x_print_pcontext_t context;
} xcb_x_print_print_get_page_dimensions_request_t;
/**
* @brief xcb_x_print_print_get_page_dimensions_reply_t
**/
typedef struct xcb_x_print_print_get_page_dimensions_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t width;
uint16_t height;
uint16_t offset_x;
uint16_t offset_y;
uint16_t reproducible_width;
uint16_t reproducible_height;
} xcb_x_print_print_get_page_dimensions_reply_t;
/**
* @brief xcb_x_print_print_query_screens_cookie_t
**/
typedef struct xcb_x_print_print_query_screens_cookie_t {
unsigned int sequence;
} xcb_x_print_print_query_screens_cookie_t;
/** Opcode for xcb_x_print_print_query_screens. */
#define XCB_X_PRINT_PRINT_QUERY_SCREENS 22
/**
* @brief xcb_x_print_print_query_screens_request_t
**/
typedef struct xcb_x_print_print_query_screens_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_x_print_print_query_screens_request_t;
/**
* @brief xcb_x_print_print_query_screens_reply_t
**/
typedef struct xcb_x_print_print_query_screens_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t listCount;
uint8_t pad1[20];
} xcb_x_print_print_query_screens_reply_t;
/**
* @brief xcb_x_print_print_set_image_resolution_cookie_t
**/
typedef struct xcb_x_print_print_set_image_resolution_cookie_t {
unsigned int sequence;
} xcb_x_print_print_set_image_resolution_cookie_t;
/** Opcode for xcb_x_print_print_set_image_resolution. */
#define XCB_X_PRINT_PRINT_SET_IMAGE_RESOLUTION 23
/**
* @brief xcb_x_print_print_set_image_resolution_request_t
**/
typedef struct xcb_x_print_print_set_image_resolution_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_x_print_pcontext_t context;
uint16_t image_resolution;
} xcb_x_print_print_set_image_resolution_request_t;
/**
* @brief xcb_x_print_print_set_image_resolution_reply_t
**/
typedef struct xcb_x_print_print_set_image_resolution_reply_t {
uint8_t response_type;
uint8_t status;
uint16_t sequence;
uint32_t length;
uint16_t previous_resolutions;
} xcb_x_print_print_set_image_resolution_reply_t;
/**
* @brief xcb_x_print_print_get_image_resolution_cookie_t
**/
typedef struct xcb_x_print_print_get_image_resolution_cookie_t {
unsigned int sequence;
} xcb_x_print_print_get_image_resolution_cookie_t;
/** Opcode for xcb_x_print_print_get_image_resolution. */
#define XCB_X_PRINT_PRINT_GET_IMAGE_RESOLUTION 24
/**
* @brief xcb_x_print_print_get_image_resolution_request_t
**/
typedef struct xcb_x_print_print_get_image_resolution_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_x_print_pcontext_t context;
} xcb_x_print_print_get_image_resolution_request_t;
/**
* @brief xcb_x_print_print_get_image_resolution_reply_t
**/
typedef struct xcb_x_print_print_get_image_resolution_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t image_resolution;
} xcb_x_print_print_get_image_resolution_reply_t;
/** Opcode for xcb_x_print_notify. */
#define XCB_X_PRINT_NOTIFY 0
/**
* @brief xcb_x_print_notify_event_t
**/
typedef struct xcb_x_print_notify_event_t {
uint8_t response_type;
uint8_t detail;
uint16_t sequence;
xcb_x_print_pcontext_t context;
uint8_t cancel;
} xcb_x_print_notify_event_t;
/** Opcode for xcb_x_print_attribut_notify. */
#define XCB_X_PRINT_ATTRIBUT_NOTIFY 1
/**
* @brief xcb_x_print_attribut_notify_event_t
**/
typedef struct xcb_x_print_attribut_notify_event_t {
uint8_t response_type;
uint8_t detail;
uint16_t sequence;
xcb_x_print_pcontext_t context;
} xcb_x_print_attribut_notify_event_t;
/** Opcode for xcb_x_print_bad_context. */
#define XCB_X_PRINT_BAD_CONTEXT 0
/**
* @brief xcb_x_print_bad_context_error_t
**/
typedef struct xcb_x_print_bad_context_error_t {
uint8_t response_type;
uint8_t error_code;
uint16_t sequence;
} xcb_x_print_bad_context_error_t;
/** Opcode for xcb_x_print_bad_sequence. */
#define XCB_X_PRINT_BAD_SEQUENCE 1
/**
* @brief xcb_x_print_bad_sequence_error_t
**/
typedef struct xcb_x_print_bad_sequence_error_t {
uint8_t response_type;
uint8_t error_code;
uint16_t sequence;
} xcb_x_print_bad_sequence_error_t;
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_x_print_string8_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_x_print_string8_t)
*/
void
xcb_x_print_string8_next (xcb_x_print_string8_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_x_print_string8_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_x_print_string8_end (xcb_x_print_string8_iterator_t i);
int
xcb_x_print_printer_serialize (void **_buffer,
const xcb_x_print_printer_t *_aux,
const xcb_x_print_string8_t *name,
const xcb_x_print_string8_t *description);
int
xcb_x_print_printer_unserialize (const void *_buffer,
xcb_x_print_printer_t **_aux);
int
xcb_x_print_printer_sizeof (const void *_buffer);
xcb_x_print_string8_t *
xcb_x_print_printer_name (const xcb_x_print_printer_t *R);
int
xcb_x_print_printer_name_length (const xcb_x_print_printer_t *R);
xcb_generic_iterator_t
xcb_x_print_printer_name_end (const xcb_x_print_printer_t *R);
xcb_x_print_string8_t *
xcb_x_print_printer_description (const xcb_x_print_printer_t *R);
int
xcb_x_print_printer_description_length (const xcb_x_print_printer_t *R);
xcb_generic_iterator_t
xcb_x_print_printer_description_end (const xcb_x_print_printer_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_x_print_printer_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_x_print_printer_t)
*/
void
xcb_x_print_printer_next (xcb_x_print_printer_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_x_print_printer_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_x_print_printer_end (xcb_x_print_printer_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_x_print_pcontext_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_x_print_pcontext_t)
*/
void
xcb_x_print_pcontext_next (xcb_x_print_pcontext_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_x_print_pcontext_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_x_print_pcontext_end (xcb_x_print_pcontext_iterator_t i);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_x_print_print_query_version_cookie_t
xcb_x_print_print_query_version (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_x_print_print_query_version_cookie_t
xcb_x_print_print_query_version_unchecked (xcb_connection_t *c);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_x_print_print_query_version_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_x_print_print_query_version_reply_t *
xcb_x_print_print_query_version_reply (xcb_connection_t *c,
xcb_x_print_print_query_version_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_x_print_print_get_printer_list_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_x_print_print_get_printer_list_cookie_t
xcb_x_print_print_get_printer_list (xcb_connection_t *c,
uint32_t printerNameLen,
uint32_t localeLen,
const xcb_x_print_string8_t *printer_name,
const xcb_x_print_string8_t *locale);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_x_print_print_get_printer_list_cookie_t
xcb_x_print_print_get_printer_list_unchecked (xcb_connection_t *c,
uint32_t printerNameLen,
uint32_t localeLen,
const xcb_x_print_string8_t *printer_name,
const xcb_x_print_string8_t *locale);
int
xcb_x_print_print_get_printer_list_printers_length (const xcb_x_print_print_get_printer_list_reply_t *R);
xcb_x_print_printer_iterator_t
xcb_x_print_print_get_printer_list_printers_iterator (const xcb_x_print_print_get_printer_list_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_x_print_print_get_printer_list_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_x_print_print_get_printer_list_reply_t *
xcb_x_print_print_get_printer_list_reply (xcb_connection_t *c,
xcb_x_print_print_get_printer_list_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_x_print_print_rehash_printer_list_checked (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_x_print_print_rehash_printer_list (xcb_connection_t *c);
int
xcb_x_print_create_context_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_x_print_create_context_checked (xcb_connection_t *c,
uint32_t context_id,
uint32_t printerNameLen,
uint32_t localeLen,
const xcb_x_print_string8_t *printerName,
const xcb_x_print_string8_t *locale);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_x_print_create_context (xcb_connection_t *c,
uint32_t context_id,
uint32_t printerNameLen,
uint32_t localeLen,
const xcb_x_print_string8_t *printerName,
const xcb_x_print_string8_t *locale);
xcb_x_print_string8_t *
xcb_x_print_create_context_printer_name (const xcb_x_print_create_context_request_t *R);
int
xcb_x_print_create_context_printer_name_length (const xcb_x_print_create_context_request_t *R);
xcb_generic_iterator_t
xcb_x_print_create_context_printer_name_end (const xcb_x_print_create_context_request_t *R);
xcb_x_print_string8_t *
xcb_x_print_create_context_locale (const xcb_x_print_create_context_request_t *R);
int
xcb_x_print_create_context_locale_length (const xcb_x_print_create_context_request_t *R);
xcb_generic_iterator_t
xcb_x_print_create_context_locale_end (const xcb_x_print_create_context_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_x_print_print_set_context_checked (xcb_connection_t *c,
uint32_t context);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_x_print_print_set_context (xcb_connection_t *c,
uint32_t context);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_x_print_print_get_context_cookie_t
xcb_x_print_print_get_context (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_x_print_print_get_context_cookie_t
xcb_x_print_print_get_context_unchecked (xcb_connection_t *c);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_x_print_print_get_context_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_x_print_print_get_context_reply_t *
xcb_x_print_print_get_context_reply (xcb_connection_t *c,
xcb_x_print_print_get_context_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_x_print_print_destroy_context_checked (xcb_connection_t *c,
uint32_t context);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_x_print_print_destroy_context (xcb_connection_t *c,
uint32_t context);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_x_print_print_get_screen_of_context_cookie_t
xcb_x_print_print_get_screen_of_context (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_x_print_print_get_screen_of_context_cookie_t
xcb_x_print_print_get_screen_of_context_unchecked (xcb_connection_t *c);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_x_print_print_get_screen_of_context_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_x_print_print_get_screen_of_context_reply_t *
xcb_x_print_print_get_screen_of_context_reply (xcb_connection_t *c,
xcb_x_print_print_get_screen_of_context_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_x_print_print_start_job_checked (xcb_connection_t *c,
uint8_t output_mode);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_x_print_print_start_job (xcb_connection_t *c,
uint8_t output_mode);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_x_print_print_end_job_checked (xcb_connection_t *c,
uint8_t cancel);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_x_print_print_end_job (xcb_connection_t *c,
uint8_t cancel);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_x_print_print_start_doc_checked (xcb_connection_t *c,
uint8_t driver_mode);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_x_print_print_start_doc (xcb_connection_t *c,
uint8_t driver_mode);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_x_print_print_end_doc_checked (xcb_connection_t *c,
uint8_t cancel);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_x_print_print_end_doc (xcb_connection_t *c,
uint8_t cancel);
int
xcb_x_print_print_put_document_data_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_x_print_print_put_document_data_checked (xcb_connection_t *c,
xcb_drawable_t drawable,
uint32_t len_data,
uint16_t len_fmt,
uint16_t len_options,
const uint8_t *data,
const xcb_x_print_string8_t *doc_format,
const xcb_x_print_string8_t *options);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_x_print_print_put_document_data (xcb_connection_t *c,
xcb_drawable_t drawable,
uint32_t len_data,
uint16_t len_fmt,
uint16_t len_options,
const uint8_t *data,
const xcb_x_print_string8_t *doc_format,
const xcb_x_print_string8_t *options);
uint8_t *
xcb_x_print_print_put_document_data_data (const xcb_x_print_print_put_document_data_request_t *R);
int
xcb_x_print_print_put_document_data_data_length (const xcb_x_print_print_put_document_data_request_t *R);
xcb_generic_iterator_t
xcb_x_print_print_put_document_data_data_end (const xcb_x_print_print_put_document_data_request_t *R);
xcb_x_print_string8_t *
xcb_x_print_print_put_document_data_doc_format (const xcb_x_print_print_put_document_data_request_t *R);
int
xcb_x_print_print_put_document_data_doc_format_length (const xcb_x_print_print_put_document_data_request_t *R);
xcb_generic_iterator_t
xcb_x_print_print_put_document_data_doc_format_end (const xcb_x_print_print_put_document_data_request_t *R);
xcb_x_print_string8_t *
xcb_x_print_print_put_document_data_options (const xcb_x_print_print_put_document_data_request_t *R);
int
xcb_x_print_print_put_document_data_options_length (const xcb_x_print_print_put_document_data_request_t *R);
xcb_generic_iterator_t
xcb_x_print_print_put_document_data_options_end (const xcb_x_print_print_put_document_data_request_t *R);
int
xcb_x_print_print_get_document_data_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_x_print_print_get_document_data_cookie_t
xcb_x_print_print_get_document_data (xcb_connection_t *c,
xcb_x_print_pcontext_t context,
uint32_t max_bytes);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_x_print_print_get_document_data_cookie_t
xcb_x_print_print_get_document_data_unchecked (xcb_connection_t *c,
xcb_x_print_pcontext_t context,
uint32_t max_bytes);
uint8_t *
xcb_x_print_print_get_document_data_data (const xcb_x_print_print_get_document_data_reply_t *R);
int
xcb_x_print_print_get_document_data_data_length (const xcb_x_print_print_get_document_data_reply_t *R);
xcb_generic_iterator_t
xcb_x_print_print_get_document_data_data_end (const xcb_x_print_print_get_document_data_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_x_print_print_get_document_data_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_x_print_print_get_document_data_reply_t *
xcb_x_print_print_get_document_data_reply (xcb_connection_t *c,
xcb_x_print_print_get_document_data_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_x_print_print_start_page_checked (xcb_connection_t *c,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_x_print_print_start_page (xcb_connection_t *c,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_x_print_print_end_page_checked (xcb_connection_t *c,
uint8_t cancel);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_x_print_print_end_page (xcb_connection_t *c,
uint8_t cancel);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_x_print_print_select_input_checked (xcb_connection_t *c,
xcb_x_print_pcontext_t context,
uint32_t event_mask);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_x_print_print_select_input (xcb_connection_t *c,
xcb_x_print_pcontext_t context,
uint32_t event_mask);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_x_print_print_input_selected_cookie_t
xcb_x_print_print_input_selected (xcb_connection_t *c,
xcb_x_print_pcontext_t context);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_x_print_print_input_selected_cookie_t
xcb_x_print_print_input_selected_unchecked (xcb_connection_t *c,
xcb_x_print_pcontext_t context);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_x_print_print_input_selected_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_x_print_print_input_selected_reply_t *
xcb_x_print_print_input_selected_reply (xcb_connection_t *c,
xcb_x_print_print_input_selected_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_x_print_print_get_attributes_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_x_print_print_get_attributes_cookie_t
xcb_x_print_print_get_attributes (xcb_connection_t *c,
xcb_x_print_pcontext_t context,
uint8_t pool);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_x_print_print_get_attributes_cookie_t
xcb_x_print_print_get_attributes_unchecked (xcb_connection_t *c,
xcb_x_print_pcontext_t context,
uint8_t pool);
xcb_x_print_string8_t *
xcb_x_print_print_get_attributes_attributes (const xcb_x_print_print_get_attributes_reply_t *R);
int
xcb_x_print_print_get_attributes_attributes_length (const xcb_x_print_print_get_attributes_reply_t *R);
xcb_generic_iterator_t
xcb_x_print_print_get_attributes_attributes_end (const xcb_x_print_print_get_attributes_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_x_print_print_get_attributes_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_x_print_print_get_attributes_reply_t *
xcb_x_print_print_get_attributes_reply (xcb_connection_t *c,
xcb_x_print_print_get_attributes_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_x_print_print_get_one_attributes_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_x_print_print_get_one_attributes_cookie_t
xcb_x_print_print_get_one_attributes (xcb_connection_t *c,
xcb_x_print_pcontext_t context,
uint32_t nameLen,
uint8_t pool,
const xcb_x_print_string8_t *name);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_x_print_print_get_one_attributes_cookie_t
xcb_x_print_print_get_one_attributes_unchecked (xcb_connection_t *c,
xcb_x_print_pcontext_t context,
uint32_t nameLen,
uint8_t pool,
const xcb_x_print_string8_t *name);
xcb_x_print_string8_t *
xcb_x_print_print_get_one_attributes_value (const xcb_x_print_print_get_one_attributes_reply_t *R);
int
xcb_x_print_print_get_one_attributes_value_length (const xcb_x_print_print_get_one_attributes_reply_t *R);
xcb_generic_iterator_t
xcb_x_print_print_get_one_attributes_value_end (const xcb_x_print_print_get_one_attributes_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_x_print_print_get_one_attributes_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_x_print_print_get_one_attributes_reply_t *
xcb_x_print_print_get_one_attributes_reply (xcb_connection_t *c,
xcb_x_print_print_get_one_attributes_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_x_print_print_set_attributes_sizeof (const void *_buffer,
uint32_t attributes_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_x_print_print_set_attributes_checked (xcb_connection_t *c,
xcb_x_print_pcontext_t context,
uint32_t stringLen,
uint8_t pool,
uint8_t rule,
uint32_t attributes_len,
const xcb_x_print_string8_t *attributes);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_x_print_print_set_attributes (xcb_connection_t *c,
xcb_x_print_pcontext_t context,
uint32_t stringLen,
uint8_t pool,
uint8_t rule,
uint32_t attributes_len,
const xcb_x_print_string8_t *attributes);
xcb_x_print_string8_t *
xcb_x_print_print_set_attributes_attributes (const xcb_x_print_print_set_attributes_request_t *R);
int
xcb_x_print_print_set_attributes_attributes_length (const xcb_x_print_print_set_attributes_request_t *R);
xcb_generic_iterator_t
xcb_x_print_print_set_attributes_attributes_end (const xcb_x_print_print_set_attributes_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_x_print_print_get_page_dimensions_cookie_t
xcb_x_print_print_get_page_dimensions (xcb_connection_t *c,
xcb_x_print_pcontext_t context);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_x_print_print_get_page_dimensions_cookie_t
xcb_x_print_print_get_page_dimensions_unchecked (xcb_connection_t *c,
xcb_x_print_pcontext_t context);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_x_print_print_get_page_dimensions_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_x_print_print_get_page_dimensions_reply_t *
xcb_x_print_print_get_page_dimensions_reply (xcb_connection_t *c,
xcb_x_print_print_get_page_dimensions_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_x_print_print_query_screens_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_x_print_print_query_screens_cookie_t
xcb_x_print_print_query_screens (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_x_print_print_query_screens_cookie_t
xcb_x_print_print_query_screens_unchecked (xcb_connection_t *c);
xcb_window_t *
xcb_x_print_print_query_screens_roots (const xcb_x_print_print_query_screens_reply_t *R);
int
xcb_x_print_print_query_screens_roots_length (const xcb_x_print_print_query_screens_reply_t *R);
xcb_generic_iterator_t
xcb_x_print_print_query_screens_roots_end (const xcb_x_print_print_query_screens_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_x_print_print_query_screens_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_x_print_print_query_screens_reply_t *
xcb_x_print_print_query_screens_reply (xcb_connection_t *c,
xcb_x_print_print_query_screens_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_x_print_print_set_image_resolution_cookie_t
xcb_x_print_print_set_image_resolution (xcb_connection_t *c,
xcb_x_print_pcontext_t context,
uint16_t image_resolution);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_x_print_print_set_image_resolution_cookie_t
xcb_x_print_print_set_image_resolution_unchecked (xcb_connection_t *c,
xcb_x_print_pcontext_t context,
uint16_t image_resolution);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_x_print_print_set_image_resolution_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_x_print_print_set_image_resolution_reply_t *
xcb_x_print_print_set_image_resolution_reply (xcb_connection_t *c,
xcb_x_print_print_set_image_resolution_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_x_print_print_get_image_resolution_cookie_t
xcb_x_print_print_get_image_resolution (xcb_connection_t *c,
xcb_x_print_pcontext_t context);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_x_print_print_get_image_resolution_cookie_t
xcb_x_print_print_get_image_resolution_unchecked (xcb_connection_t *c,
xcb_x_print_pcontext_t context);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_x_print_print_get_image_resolution_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_x_print_print_get_image_resolution_reply_t *
xcb_x_print_print_get_image_resolution_reply (xcb_connection_t *c,
xcb_x_print_print_get_image_resolution_cookie_t cookie /**< */,
xcb_generic_error_t **e);
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/
xcb/bigreq.h 0000644 00000004547 15201526705 0006757 0 ustar 00 /*
* This file generated automatically from bigreq.xml by c_client.py.
* Edit at your peril.
*/
/**
* @defgroup XCB_BigRequests_API XCB BigRequests API
* @brief BigRequests XCB Protocol Implementation.
* @{
**/
#ifndef __BIGREQ_H
#define __BIGREQ_H
#include "xcb.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XCB_BIGREQUESTS_MAJOR_VERSION 0
#define XCB_BIGREQUESTS_MINOR_VERSION 0
extern xcb_extension_t xcb_big_requests_id;
/**
* @brief xcb_big_requests_enable_cookie_t
**/
typedef struct xcb_big_requests_enable_cookie_t {
unsigned int sequence;
} xcb_big_requests_enable_cookie_t;
/** Opcode for xcb_big_requests_enable. */
#define XCB_BIG_REQUESTS_ENABLE 0
/**
* @brief xcb_big_requests_enable_request_t
**/
typedef struct xcb_big_requests_enable_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_big_requests_enable_request_t;
/**
* @brief xcb_big_requests_enable_reply_t
**/
typedef struct xcb_big_requests_enable_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t maximum_request_length;
} xcb_big_requests_enable_reply_t;
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_big_requests_enable_cookie_t
xcb_big_requests_enable (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_big_requests_enable_cookie_t
xcb_big_requests_enable_unchecked (xcb_connection_t *c);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_big_requests_enable_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_big_requests_enable_reply_t *
xcb_big_requests_enable_reply (xcb_connection_t *c,
xcb_big_requests_enable_cookie_t cookie /**< */,
xcb_generic_error_t **e);
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/
xcb/xc_misc.h 0000644 00000015741 15201526705 0007131 0 ustar 00 /*
* This file generated automatically from xc_misc.xml by c_client.py.
* Edit at your peril.
*/
/**
* @defgroup XCB_XCMisc_API XCB XCMisc API
* @brief XCMisc XCB Protocol Implementation.
* @{
**/
#ifndef __XC_MISC_H
#define __XC_MISC_H
#include "xcb.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XCB_XCMISC_MAJOR_VERSION 1
#define XCB_XCMISC_MINOR_VERSION 1
extern xcb_extension_t xcb_xc_misc_id;
/**
* @brief xcb_xc_misc_get_version_cookie_t
**/
typedef struct xcb_xc_misc_get_version_cookie_t {
unsigned int sequence;
} xcb_xc_misc_get_version_cookie_t;
/** Opcode for xcb_xc_misc_get_version. */
#define XCB_XC_MISC_GET_VERSION 0
/**
* @brief xcb_xc_misc_get_version_request_t
**/
typedef struct xcb_xc_misc_get_version_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint16_t client_major_version;
uint16_t client_minor_version;
} xcb_xc_misc_get_version_request_t;
/**
* @brief xcb_xc_misc_get_version_reply_t
**/
typedef struct xcb_xc_misc_get_version_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t server_major_version;
uint16_t server_minor_version;
} xcb_xc_misc_get_version_reply_t;
/**
* @brief xcb_xc_misc_get_xid_range_cookie_t
**/
typedef struct xcb_xc_misc_get_xid_range_cookie_t {
unsigned int sequence;
} xcb_xc_misc_get_xid_range_cookie_t;
/** Opcode for xcb_xc_misc_get_xid_range. */
#define XCB_XC_MISC_GET_XID_RANGE 1
/**
* @brief xcb_xc_misc_get_xid_range_request_t
**/
typedef struct xcb_xc_misc_get_xid_range_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_xc_misc_get_xid_range_request_t;
/**
* @brief xcb_xc_misc_get_xid_range_reply_t
**/
typedef struct xcb_xc_misc_get_xid_range_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t start_id;
uint32_t count;
} xcb_xc_misc_get_xid_range_reply_t;
/**
* @brief xcb_xc_misc_get_xid_list_cookie_t
**/
typedef struct xcb_xc_misc_get_xid_list_cookie_t {
unsigned int sequence;
} xcb_xc_misc_get_xid_list_cookie_t;
/** Opcode for xcb_xc_misc_get_xid_list. */
#define XCB_XC_MISC_GET_XID_LIST 2
/**
* @brief xcb_xc_misc_get_xid_list_request_t
**/
typedef struct xcb_xc_misc_get_xid_list_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t count;
} xcb_xc_misc_get_xid_list_request_t;
/**
* @brief xcb_xc_misc_get_xid_list_reply_t
**/
typedef struct xcb_xc_misc_get_xid_list_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t ids_len;
uint8_t pad1[20];
} xcb_xc_misc_get_xid_list_reply_t;
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xc_misc_get_version_cookie_t
xcb_xc_misc_get_version (xcb_connection_t *c,
uint16_t client_major_version,
uint16_t client_minor_version);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xc_misc_get_version_cookie_t
xcb_xc_misc_get_version_unchecked (xcb_connection_t *c,
uint16_t client_major_version,
uint16_t client_minor_version);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xc_misc_get_version_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xc_misc_get_version_reply_t *
xcb_xc_misc_get_version_reply (xcb_connection_t *c,
xcb_xc_misc_get_version_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xc_misc_get_xid_range_cookie_t
xcb_xc_misc_get_xid_range (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xc_misc_get_xid_range_cookie_t
xcb_xc_misc_get_xid_range_unchecked (xcb_connection_t *c);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xc_misc_get_xid_range_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xc_misc_get_xid_range_reply_t *
xcb_xc_misc_get_xid_range_reply (xcb_connection_t *c,
xcb_xc_misc_get_xid_range_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_xc_misc_get_xid_list_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xc_misc_get_xid_list_cookie_t
xcb_xc_misc_get_xid_list (xcb_connection_t *c,
uint32_t count);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xc_misc_get_xid_list_cookie_t
xcb_xc_misc_get_xid_list_unchecked (xcb_connection_t *c,
uint32_t count);
uint32_t *
xcb_xc_misc_get_xid_list_ids (const xcb_xc_misc_get_xid_list_reply_t *R);
int
xcb_xc_misc_get_xid_list_ids_length (const xcb_xc_misc_get_xid_list_reply_t *R);
xcb_generic_iterator_t
xcb_xc_misc_get_xid_list_ids_end (const xcb_xc_misc_get_xid_list_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xc_misc_get_xid_list_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xc_misc_get_xid_list_reply_t *
xcb_xc_misc_get_xid_list_reply (xcb_connection_t *c,
xcb_xc_misc_get_xid_list_cookie_t cookie /**< */,
xcb_generic_error_t **e);
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/
xcb/present.h 0000644 00000045534 15201526705 0007167 0 ustar 00 /*
* This file generated automatically from present.xml by c_client.py.
* Edit at your peril.
*/
/**
* @defgroup XCB_Present_API XCB Present API
* @brief Present XCB Protocol Implementation.
* @{
**/
#ifndef __PRESENT_H
#define __PRESENT_H
#include "xcb.h"
#include "xproto.h"
#include "randr.h"
#include "xfixes.h"
#include "sync.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XCB_PRESENT_MAJOR_VERSION 1
#define XCB_PRESENT_MINOR_VERSION 2
extern xcb_extension_t xcb_present_id;
typedef enum xcb_present_event_enum_t {
XCB_PRESENT_EVENT_CONFIGURE_NOTIFY = 0,
XCB_PRESENT_EVENT_COMPLETE_NOTIFY = 1,
XCB_PRESENT_EVENT_IDLE_NOTIFY = 2,
XCB_PRESENT_EVENT_REDIRECT_NOTIFY = 3
} xcb_present_event_enum_t;
typedef enum xcb_present_event_mask_t {
XCB_PRESENT_EVENT_MASK_NO_EVENT = 0,
XCB_PRESENT_EVENT_MASK_CONFIGURE_NOTIFY = 1,
XCB_PRESENT_EVENT_MASK_COMPLETE_NOTIFY = 2,
XCB_PRESENT_EVENT_MASK_IDLE_NOTIFY = 4,
XCB_PRESENT_EVENT_MASK_REDIRECT_NOTIFY = 8
} xcb_present_event_mask_t;
typedef enum xcb_present_option_t {
XCB_PRESENT_OPTION_NONE = 0,
XCB_PRESENT_OPTION_ASYNC = 1,
XCB_PRESENT_OPTION_COPY = 2,
XCB_PRESENT_OPTION_UST = 4,
XCB_PRESENT_OPTION_SUBOPTIMAL = 8
} xcb_present_option_t;
typedef enum xcb_present_capability_t {
XCB_PRESENT_CAPABILITY_NONE = 0,
XCB_PRESENT_CAPABILITY_ASYNC = 1,
XCB_PRESENT_CAPABILITY_FENCE = 2,
XCB_PRESENT_CAPABILITY_UST = 4
} xcb_present_capability_t;
typedef enum xcb_present_complete_kind_t {
XCB_PRESENT_COMPLETE_KIND_PIXMAP = 0,
XCB_PRESENT_COMPLETE_KIND_NOTIFY_MSC = 1
} xcb_present_complete_kind_t;
typedef enum xcb_present_complete_mode_t {
XCB_PRESENT_COMPLETE_MODE_COPY = 0,
XCB_PRESENT_COMPLETE_MODE_FLIP = 1,
XCB_PRESENT_COMPLETE_MODE_SKIP = 2,
XCB_PRESENT_COMPLETE_MODE_SUBOPTIMAL_COPY = 3
} xcb_present_complete_mode_t;
/**
* @brief xcb_present_notify_t
**/
typedef struct xcb_present_notify_t {
xcb_window_t window;
uint32_t serial;
} xcb_present_notify_t;
/**
* @brief xcb_present_notify_iterator_t
**/
typedef struct xcb_present_notify_iterator_t {
xcb_present_notify_t *data;
int rem;
int index;
} xcb_present_notify_iterator_t;
/**
* @brief xcb_present_query_version_cookie_t
**/
typedef struct xcb_present_query_version_cookie_t {
unsigned int sequence;
} xcb_present_query_version_cookie_t;
/** Opcode for xcb_present_query_version. */
#define XCB_PRESENT_QUERY_VERSION 0
/**
* @brief xcb_present_query_version_request_t
**/
typedef struct xcb_present_query_version_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t major_version;
uint32_t minor_version;
} xcb_present_query_version_request_t;
/**
* @brief xcb_present_query_version_reply_t
**/
typedef struct xcb_present_query_version_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t major_version;
uint32_t minor_version;
} xcb_present_query_version_reply_t;
/** Opcode for xcb_present_pixmap. */
#define XCB_PRESENT_PIXMAP 1
/**
* @brief xcb_present_pixmap_request_t
**/
typedef struct xcb_present_pixmap_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
xcb_pixmap_t pixmap;
uint32_t serial;
xcb_xfixes_region_t valid;
xcb_xfixes_region_t update;
int16_t x_off;
int16_t y_off;
xcb_randr_crtc_t target_crtc;
xcb_sync_fence_t wait_fence;
xcb_sync_fence_t idle_fence;
uint32_t options;
uint8_t pad0[4];
uint64_t target_msc;
uint64_t divisor;
uint64_t remainder;
} xcb_present_pixmap_request_t;
/** Opcode for xcb_present_notify_msc. */
#define XCB_PRESENT_NOTIFY_MSC 2
/**
* @brief xcb_present_notify_msc_request_t
**/
typedef struct xcb_present_notify_msc_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
uint32_t serial;
uint8_t pad0[4];
uint64_t target_msc;
uint64_t divisor;
uint64_t remainder;
} xcb_present_notify_msc_request_t;
typedef uint32_t xcb_present_event_t;
/**
* @brief xcb_present_event_iterator_t
**/
typedef struct xcb_present_event_iterator_t {
xcb_present_event_t *data;
int rem;
int index;
} xcb_present_event_iterator_t;
/** Opcode for xcb_present_select_input. */
#define XCB_PRESENT_SELECT_INPUT 3
/**
* @brief xcb_present_select_input_request_t
**/
typedef struct xcb_present_select_input_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_present_event_t eid;
xcb_window_t window;
uint32_t event_mask;
} xcb_present_select_input_request_t;
/**
* @brief xcb_present_query_capabilities_cookie_t
**/
typedef struct xcb_present_query_capabilities_cookie_t {
unsigned int sequence;
} xcb_present_query_capabilities_cookie_t;
/** Opcode for xcb_present_query_capabilities. */
#define XCB_PRESENT_QUERY_CAPABILITIES 4
/**
* @brief xcb_present_query_capabilities_request_t
**/
typedef struct xcb_present_query_capabilities_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t target;
} xcb_present_query_capabilities_request_t;
/**
* @brief xcb_present_query_capabilities_reply_t
**/
typedef struct xcb_present_query_capabilities_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t capabilities;
} xcb_present_query_capabilities_reply_t;
/** Opcode for xcb_present_generic. */
#define XCB_PRESENT_GENERIC 0
/**
* @brief xcb_present_generic_event_t
**/
typedef struct xcb_present_generic_event_t {
uint8_t response_type;
uint8_t extension;
uint16_t sequence;
uint32_t length;
uint16_t evtype;
uint8_t pad0[2];
xcb_present_event_t event;
} xcb_present_generic_event_t;
/** Opcode for xcb_present_configure_notify. */
#define XCB_PRESENT_CONFIGURE_NOTIFY 0
/**
* @brief xcb_present_configure_notify_event_t
**/
typedef struct xcb_present_configure_notify_event_t {
uint8_t response_type;
uint8_t extension;
uint16_t sequence;
uint32_t length;
uint16_t event_type;
uint8_t pad0[2];
xcb_present_event_t event;
xcb_window_t window;
int16_t x;
int16_t y;
uint16_t width;
uint16_t height;
int16_t off_x;
int16_t off_y;
uint32_t full_sequence;
uint16_t pixmap_width;
uint16_t pixmap_height;
uint32_t pixmap_flags;
} xcb_present_configure_notify_event_t;
/** Opcode for xcb_present_complete_notify. */
#define XCB_PRESENT_COMPLETE_NOTIFY 1
/**
* @brief xcb_present_complete_notify_event_t
**/
typedef struct xcb_present_complete_notify_event_t {
uint8_t response_type;
uint8_t extension;
uint16_t sequence;
uint32_t length;
uint16_t event_type;
uint8_t kind;
uint8_t mode;
xcb_present_event_t event;
xcb_window_t window;
uint32_t serial;
uint64_t ust;
uint32_t full_sequence;
uint64_t msc;
} XCB_PACKED xcb_present_complete_notify_event_t;
/** Opcode for xcb_present_idle_notify. */
#define XCB_PRESENT_IDLE_NOTIFY 2
/**
* @brief xcb_present_idle_notify_event_t
**/
typedef struct xcb_present_idle_notify_event_t {
uint8_t response_type;
uint8_t extension;
uint16_t sequence;
uint32_t length;
uint16_t event_type;
uint8_t pad0[2];
xcb_present_event_t event;
xcb_window_t window;
uint32_t serial;
xcb_pixmap_t pixmap;
xcb_sync_fence_t idle_fence;
uint32_t full_sequence;
} xcb_present_idle_notify_event_t;
/** Opcode for xcb_present_redirect_notify. */
#define XCB_PRESENT_REDIRECT_NOTIFY 3
/**
* @brief xcb_present_redirect_notify_event_t
**/
typedef struct xcb_present_redirect_notify_event_t {
uint8_t response_type;
uint8_t extension;
uint16_t sequence;
uint32_t length;
uint16_t event_type;
uint8_t update_window;
uint8_t pad0;
xcb_present_event_t event;
xcb_window_t event_window;
xcb_window_t window;
xcb_pixmap_t pixmap;
uint32_t serial;
uint32_t full_sequence;
xcb_xfixes_region_t valid_region;
xcb_xfixes_region_t update_region;
xcb_rectangle_t valid_rect;
xcb_rectangle_t update_rect;
int16_t x_off;
int16_t y_off;
xcb_randr_crtc_t target_crtc;
xcb_sync_fence_t wait_fence;
xcb_sync_fence_t idle_fence;
uint32_t options;
uint8_t pad1[4];
uint64_t target_msc;
uint64_t divisor;
uint64_t remainder;
} XCB_PACKED xcb_present_redirect_notify_event_t;
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_present_notify_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_present_notify_t)
*/
void
xcb_present_notify_next (xcb_present_notify_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_present_notify_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_present_notify_end (xcb_present_notify_iterator_t i);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_present_query_version_cookie_t
xcb_present_query_version (xcb_connection_t *c,
uint32_t major_version,
uint32_t minor_version);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_present_query_version_cookie_t
xcb_present_query_version_unchecked (xcb_connection_t *c,
uint32_t major_version,
uint32_t minor_version);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_present_query_version_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_present_query_version_reply_t *
xcb_present_query_version_reply (xcb_connection_t *c,
xcb_present_query_version_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_present_pixmap_sizeof (const void *_buffer,
uint32_t notifies_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_present_pixmap_checked (xcb_connection_t *c,
xcb_window_t window,
xcb_pixmap_t pixmap,
uint32_t serial,
xcb_xfixes_region_t valid,
xcb_xfixes_region_t update,
int16_t x_off,
int16_t y_off,
xcb_randr_crtc_t target_crtc,
xcb_sync_fence_t wait_fence,
xcb_sync_fence_t idle_fence,
uint32_t options,
uint64_t target_msc,
uint64_t divisor,
uint64_t remainder,
uint32_t notifies_len,
const xcb_present_notify_t *notifies);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_present_pixmap (xcb_connection_t *c,
xcb_window_t window,
xcb_pixmap_t pixmap,
uint32_t serial,
xcb_xfixes_region_t valid,
xcb_xfixes_region_t update,
int16_t x_off,
int16_t y_off,
xcb_randr_crtc_t target_crtc,
xcb_sync_fence_t wait_fence,
xcb_sync_fence_t idle_fence,
uint32_t options,
uint64_t target_msc,
uint64_t divisor,
uint64_t remainder,
uint32_t notifies_len,
const xcb_present_notify_t *notifies);
xcb_present_notify_t *
xcb_present_pixmap_notifies (const xcb_present_pixmap_request_t *R);
int
xcb_present_pixmap_notifies_length (const xcb_present_pixmap_request_t *R);
xcb_present_notify_iterator_t
xcb_present_pixmap_notifies_iterator (const xcb_present_pixmap_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_present_notify_msc_checked (xcb_connection_t *c,
xcb_window_t window,
uint32_t serial,
uint64_t target_msc,
uint64_t divisor,
uint64_t remainder);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_present_notify_msc (xcb_connection_t *c,
xcb_window_t window,
uint32_t serial,
uint64_t target_msc,
uint64_t divisor,
uint64_t remainder);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_present_event_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_present_event_t)
*/
void
xcb_present_event_next (xcb_present_event_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_present_event_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_present_event_end (xcb_present_event_iterator_t i);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_present_select_input_checked (xcb_connection_t *c,
xcb_present_event_t eid,
xcb_window_t window,
uint32_t event_mask);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_present_select_input (xcb_connection_t *c,
xcb_present_event_t eid,
xcb_window_t window,
uint32_t event_mask);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_present_query_capabilities_cookie_t
xcb_present_query_capabilities (xcb_connection_t *c,
uint32_t target);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_present_query_capabilities_cookie_t
xcb_present_query_capabilities_unchecked (xcb_connection_t *c,
uint32_t target);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_present_query_capabilities_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_present_query_capabilities_reply_t *
xcb_present_query_capabilities_reply (xcb_connection_t *c,
xcb_present_query_capabilities_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_present_redirect_notify_sizeof (const void *_buffer,
uint32_t notifies_len);
xcb_present_notify_t *
xcb_present_redirect_notify_notifies (const xcb_present_redirect_notify_event_t *R);
int
xcb_present_redirect_notify_notifies_length (const xcb_present_redirect_notify_event_t *R);
xcb_present_notify_iterator_t
xcb_present_redirect_notify_notifies_iterator (const xcb_present_redirect_notify_event_t *R);
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/
xcb/composite.h 0000644 00000033053 15201526705 0007502 0 ustar 00 /*
* This file generated automatically from composite.xml by c_client.py.
* Edit at your peril.
*/
/**
* @defgroup XCB_Composite_API XCB Composite API
* @brief Composite XCB Protocol Implementation.
* @{
**/
#ifndef __COMPOSITE_H
#define __COMPOSITE_H
#include "xcb.h"
#include "xproto.h"
#include "xfixes.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XCB_COMPOSITE_MAJOR_VERSION 0
#define XCB_COMPOSITE_MINOR_VERSION 4
extern xcb_extension_t xcb_composite_id;
typedef enum xcb_composite_redirect_t {
XCB_COMPOSITE_REDIRECT_AUTOMATIC = 0,
XCB_COMPOSITE_REDIRECT_MANUAL = 1
} xcb_composite_redirect_t;
/**
* @brief xcb_composite_query_version_cookie_t
**/
typedef struct xcb_composite_query_version_cookie_t {
unsigned int sequence;
} xcb_composite_query_version_cookie_t;
/** Opcode for xcb_composite_query_version. */
#define XCB_COMPOSITE_QUERY_VERSION 0
/**
* @brief xcb_composite_query_version_request_t
**/
typedef struct xcb_composite_query_version_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t client_major_version;
uint32_t client_minor_version;
} xcb_composite_query_version_request_t;
/**
* @brief xcb_composite_query_version_reply_t
**/
typedef struct xcb_composite_query_version_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t major_version;
uint32_t minor_version;
uint8_t pad1[16];
} xcb_composite_query_version_reply_t;
/** Opcode for xcb_composite_redirect_window. */
#define XCB_COMPOSITE_REDIRECT_WINDOW 1
/**
* @brief xcb_composite_redirect_window_request_t
**/
typedef struct xcb_composite_redirect_window_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
uint8_t update;
uint8_t pad0[3];
} xcb_composite_redirect_window_request_t;
/** Opcode for xcb_composite_redirect_subwindows. */
#define XCB_COMPOSITE_REDIRECT_SUBWINDOWS 2
/**
* @brief xcb_composite_redirect_subwindows_request_t
**/
typedef struct xcb_composite_redirect_subwindows_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
uint8_t update;
uint8_t pad0[3];
} xcb_composite_redirect_subwindows_request_t;
/** Opcode for xcb_composite_unredirect_window. */
#define XCB_COMPOSITE_UNREDIRECT_WINDOW 3
/**
* @brief xcb_composite_unredirect_window_request_t
**/
typedef struct xcb_composite_unredirect_window_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
uint8_t update;
uint8_t pad0[3];
} xcb_composite_unredirect_window_request_t;
/** Opcode for xcb_composite_unredirect_subwindows. */
#define XCB_COMPOSITE_UNREDIRECT_SUBWINDOWS 4
/**
* @brief xcb_composite_unredirect_subwindows_request_t
**/
typedef struct xcb_composite_unredirect_subwindows_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
uint8_t update;
uint8_t pad0[3];
} xcb_composite_unredirect_subwindows_request_t;
/** Opcode for xcb_composite_create_region_from_border_clip. */
#define XCB_COMPOSITE_CREATE_REGION_FROM_BORDER_CLIP 5
/**
* @brief xcb_composite_create_region_from_border_clip_request_t
**/
typedef struct xcb_composite_create_region_from_border_clip_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xfixes_region_t region;
xcb_window_t window;
} xcb_composite_create_region_from_border_clip_request_t;
/** Opcode for xcb_composite_name_window_pixmap. */
#define XCB_COMPOSITE_NAME_WINDOW_PIXMAP 6
/**
* @brief xcb_composite_name_window_pixmap_request_t
**/
typedef struct xcb_composite_name_window_pixmap_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
xcb_pixmap_t pixmap;
} xcb_composite_name_window_pixmap_request_t;
/**
* @brief xcb_composite_get_overlay_window_cookie_t
**/
typedef struct xcb_composite_get_overlay_window_cookie_t {
unsigned int sequence;
} xcb_composite_get_overlay_window_cookie_t;
/** Opcode for xcb_composite_get_overlay_window. */
#define XCB_COMPOSITE_GET_OVERLAY_WINDOW 7
/**
* @brief xcb_composite_get_overlay_window_request_t
**/
typedef struct xcb_composite_get_overlay_window_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
} xcb_composite_get_overlay_window_request_t;
/**
* @brief xcb_composite_get_overlay_window_reply_t
**/
typedef struct xcb_composite_get_overlay_window_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
xcb_window_t overlay_win;
uint8_t pad1[20];
} xcb_composite_get_overlay_window_reply_t;
/** Opcode for xcb_composite_release_overlay_window. */
#define XCB_COMPOSITE_RELEASE_OVERLAY_WINDOW 8
/**
* @brief xcb_composite_release_overlay_window_request_t
**/
typedef struct xcb_composite_release_overlay_window_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
} xcb_composite_release_overlay_window_request_t;
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_composite_query_version_cookie_t
xcb_composite_query_version (xcb_connection_t *c,
uint32_t client_major_version,
uint32_t client_minor_version);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_composite_query_version_cookie_t
xcb_composite_query_version_unchecked (xcb_connection_t *c,
uint32_t client_major_version,
uint32_t client_minor_version);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_composite_query_version_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_composite_query_version_reply_t *
xcb_composite_query_version_reply (xcb_connection_t *c,
xcb_composite_query_version_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_composite_redirect_window_checked (xcb_connection_t *c,
xcb_window_t window,
uint8_t update);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_composite_redirect_window (xcb_connection_t *c,
xcb_window_t window,
uint8_t update);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_composite_redirect_subwindows_checked (xcb_connection_t *c,
xcb_window_t window,
uint8_t update);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_composite_redirect_subwindows (xcb_connection_t *c,
xcb_window_t window,
uint8_t update);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_composite_unredirect_window_checked (xcb_connection_t *c,
xcb_window_t window,
uint8_t update);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_composite_unredirect_window (xcb_connection_t *c,
xcb_window_t window,
uint8_t update);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_composite_unredirect_subwindows_checked (xcb_connection_t *c,
xcb_window_t window,
uint8_t update);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_composite_unredirect_subwindows (xcb_connection_t *c,
xcb_window_t window,
uint8_t update);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_composite_create_region_from_border_clip_checked (xcb_connection_t *c,
xcb_xfixes_region_t region,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_composite_create_region_from_border_clip (xcb_connection_t *c,
xcb_xfixes_region_t region,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_composite_name_window_pixmap_checked (xcb_connection_t *c,
xcb_window_t window,
xcb_pixmap_t pixmap);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_composite_name_window_pixmap (xcb_connection_t *c,
xcb_window_t window,
xcb_pixmap_t pixmap);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_composite_get_overlay_window_cookie_t
xcb_composite_get_overlay_window (xcb_connection_t *c,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_composite_get_overlay_window_cookie_t
xcb_composite_get_overlay_window_unchecked (xcb_connection_t *c,
xcb_window_t window);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_composite_get_overlay_window_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_composite_get_overlay_window_reply_t *
xcb_composite_get_overlay_window_reply (xcb_connection_t *c,
xcb_composite_get_overlay_window_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_composite_release_overlay_window_checked (xcb_connection_t *c,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_composite_release_overlay_window (xcb_connection_t *c,
xcb_window_t window);
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/
xcb/xproto.h 0000644 00001361410 15201526705 0007035 0 ustar 00 /*
* This file generated automatically from xproto.xml by c_client.py.
* Edit at your peril.
*/
/**
* @defgroup XCB__API XCB API
* @brief XCB Protocol Implementation.
* @{
**/
#ifndef __XPROTO_H
#define __XPROTO_H
#include "xcb.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief xcb_char2b_t
**/
typedef struct xcb_char2b_t {
uint8_t byte1;
uint8_t byte2;
} xcb_char2b_t;
/**
* @brief xcb_char2b_iterator_t
**/
typedef struct xcb_char2b_iterator_t {
xcb_char2b_t *data;
int rem;
int index;
} xcb_char2b_iterator_t;
typedef uint32_t xcb_window_t;
/**
* @brief xcb_window_iterator_t
**/
typedef struct xcb_window_iterator_t {
xcb_window_t *data;
int rem;
int index;
} xcb_window_iterator_t;
typedef uint32_t xcb_pixmap_t;
/**
* @brief xcb_pixmap_iterator_t
**/
typedef struct xcb_pixmap_iterator_t {
xcb_pixmap_t *data;
int rem;
int index;
} xcb_pixmap_iterator_t;
typedef uint32_t xcb_cursor_t;
/**
* @brief xcb_cursor_iterator_t
**/
typedef struct xcb_cursor_iterator_t {
xcb_cursor_t *data;
int rem;
int index;
} xcb_cursor_iterator_t;
typedef uint32_t xcb_font_t;
/**
* @brief xcb_font_iterator_t
**/
typedef struct xcb_font_iterator_t {
xcb_font_t *data;
int rem;
int index;
} xcb_font_iterator_t;
typedef uint32_t xcb_gcontext_t;
/**
* @brief xcb_gcontext_iterator_t
**/
typedef struct xcb_gcontext_iterator_t {
xcb_gcontext_t *data;
int rem;
int index;
} xcb_gcontext_iterator_t;
typedef uint32_t xcb_colormap_t;
/**
* @brief xcb_colormap_iterator_t
**/
typedef struct xcb_colormap_iterator_t {
xcb_colormap_t *data;
int rem;
int index;
} xcb_colormap_iterator_t;
typedef uint32_t xcb_atom_t;
/**
* @brief xcb_atom_iterator_t
**/
typedef struct xcb_atom_iterator_t {
xcb_atom_t *data;
int rem;
int index;
} xcb_atom_iterator_t;
typedef uint32_t xcb_drawable_t;
/**
* @brief xcb_drawable_iterator_t
**/
typedef struct xcb_drawable_iterator_t {
xcb_drawable_t *data;
int rem;
int index;
} xcb_drawable_iterator_t;
typedef uint32_t xcb_fontable_t;
/**
* @brief xcb_fontable_iterator_t
**/
typedef struct xcb_fontable_iterator_t {
xcb_fontable_t *data;
int rem;
int index;
} xcb_fontable_iterator_t;
typedef uint32_t xcb_bool32_t;
/**
* @brief xcb_bool32_iterator_t
**/
typedef struct xcb_bool32_iterator_t {
xcb_bool32_t *data;
int rem;
int index;
} xcb_bool32_iterator_t;
typedef uint32_t xcb_visualid_t;
/**
* @brief xcb_visualid_iterator_t
**/
typedef struct xcb_visualid_iterator_t {
xcb_visualid_t *data;
int rem;
int index;
} xcb_visualid_iterator_t;
typedef uint32_t xcb_timestamp_t;
/**
* @brief xcb_timestamp_iterator_t
**/
typedef struct xcb_timestamp_iterator_t {
xcb_timestamp_t *data;
int rem;
int index;
} xcb_timestamp_iterator_t;
typedef uint32_t xcb_keysym_t;
/**
* @brief xcb_keysym_iterator_t
**/
typedef struct xcb_keysym_iterator_t {
xcb_keysym_t *data;
int rem;
int index;
} xcb_keysym_iterator_t;
typedef uint8_t xcb_keycode_t;
/**
* @brief xcb_keycode_iterator_t
**/
typedef struct xcb_keycode_iterator_t {
xcb_keycode_t *data;
int rem;
int index;
} xcb_keycode_iterator_t;
typedef uint32_t xcb_keycode32_t;
/**
* @brief xcb_keycode32_iterator_t
**/
typedef struct xcb_keycode32_iterator_t {
xcb_keycode32_t *data;
int rem;
int index;
} xcb_keycode32_iterator_t;
typedef uint8_t xcb_button_t;
/**
* @brief xcb_button_iterator_t
**/
typedef struct xcb_button_iterator_t {
xcb_button_t *data;
int rem;
int index;
} xcb_button_iterator_t;
/**
* @brief xcb_point_t
**/
typedef struct xcb_point_t {
int16_t x;
int16_t y;
} xcb_point_t;
/**
* @brief xcb_point_iterator_t
**/
typedef struct xcb_point_iterator_t {
xcb_point_t *data;
int rem;
int index;
} xcb_point_iterator_t;
/**
* @brief xcb_rectangle_t
**/
typedef struct xcb_rectangle_t {
int16_t x;
int16_t y;
uint16_t width;
uint16_t height;
} xcb_rectangle_t;
/**
* @brief xcb_rectangle_iterator_t
**/
typedef struct xcb_rectangle_iterator_t {
xcb_rectangle_t *data;
int rem;
int index;
} xcb_rectangle_iterator_t;
/**
* @brief xcb_arc_t
**/
typedef struct xcb_arc_t {
int16_t x;
int16_t y;
uint16_t width;
uint16_t height;
int16_t angle1;
int16_t angle2;
} xcb_arc_t;
/**
* @brief xcb_arc_iterator_t
**/
typedef struct xcb_arc_iterator_t {
xcb_arc_t *data;
int rem;
int index;
} xcb_arc_iterator_t;
/**
* @brief xcb_format_t
**/
typedef struct xcb_format_t {
uint8_t depth;
uint8_t bits_per_pixel;
uint8_t scanline_pad;
uint8_t pad0[5];
} xcb_format_t;
/**
* @brief xcb_format_iterator_t
**/
typedef struct xcb_format_iterator_t {
xcb_format_t *data;
int rem;
int index;
} xcb_format_iterator_t;
typedef enum xcb_visual_class_t {
XCB_VISUAL_CLASS_STATIC_GRAY = 0,
XCB_VISUAL_CLASS_GRAY_SCALE = 1,
XCB_VISUAL_CLASS_STATIC_COLOR = 2,
XCB_VISUAL_CLASS_PSEUDO_COLOR = 3,
XCB_VISUAL_CLASS_TRUE_COLOR = 4,
XCB_VISUAL_CLASS_DIRECT_COLOR = 5
} xcb_visual_class_t;
/**
* @brief xcb_visualtype_t
**/
typedef struct xcb_visualtype_t {
xcb_visualid_t visual_id;
uint8_t _class;
uint8_t bits_per_rgb_value;
uint16_t colormap_entries;
uint32_t red_mask;
uint32_t green_mask;
uint32_t blue_mask;
uint8_t pad0[4];
} xcb_visualtype_t;
/**
* @brief xcb_visualtype_iterator_t
**/
typedef struct xcb_visualtype_iterator_t {
xcb_visualtype_t *data;
int rem;
int index;
} xcb_visualtype_iterator_t;
/**
* @brief xcb_depth_t
**/
typedef struct xcb_depth_t {
uint8_t depth;
uint8_t pad0;
uint16_t visuals_len;
uint8_t pad1[4];
} xcb_depth_t;
/**
* @brief xcb_depth_iterator_t
**/
typedef struct xcb_depth_iterator_t {
xcb_depth_t *data;
int rem;
int index;
} xcb_depth_iterator_t;
typedef enum xcb_event_mask_t {
XCB_EVENT_MASK_NO_EVENT = 0,
XCB_EVENT_MASK_KEY_PRESS = 1,
XCB_EVENT_MASK_KEY_RELEASE = 2,
XCB_EVENT_MASK_BUTTON_PRESS = 4,
XCB_EVENT_MASK_BUTTON_RELEASE = 8,
XCB_EVENT_MASK_ENTER_WINDOW = 16,
XCB_EVENT_MASK_LEAVE_WINDOW = 32,
XCB_EVENT_MASK_POINTER_MOTION = 64,
XCB_EVENT_MASK_POINTER_MOTION_HINT = 128,
XCB_EVENT_MASK_BUTTON_1_MOTION = 256,
XCB_EVENT_MASK_BUTTON_2_MOTION = 512,
XCB_EVENT_MASK_BUTTON_3_MOTION = 1024,
XCB_EVENT_MASK_BUTTON_4_MOTION = 2048,
XCB_EVENT_MASK_BUTTON_5_MOTION = 4096,
XCB_EVENT_MASK_BUTTON_MOTION = 8192,
XCB_EVENT_MASK_KEYMAP_STATE = 16384,
XCB_EVENT_MASK_EXPOSURE = 32768,
XCB_EVENT_MASK_VISIBILITY_CHANGE = 65536,
XCB_EVENT_MASK_STRUCTURE_NOTIFY = 131072,
XCB_EVENT_MASK_RESIZE_REDIRECT = 262144,
XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY = 524288,
XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT = 1048576,
XCB_EVENT_MASK_FOCUS_CHANGE = 2097152,
XCB_EVENT_MASK_PROPERTY_CHANGE = 4194304,
XCB_EVENT_MASK_COLOR_MAP_CHANGE = 8388608,
XCB_EVENT_MASK_OWNER_GRAB_BUTTON = 16777216
} xcb_event_mask_t;
typedef enum xcb_backing_store_t {
XCB_BACKING_STORE_NOT_USEFUL = 0,
XCB_BACKING_STORE_WHEN_MAPPED = 1,
XCB_BACKING_STORE_ALWAYS = 2
} xcb_backing_store_t;
/**
* @brief xcb_screen_t
**/
typedef struct xcb_screen_t {
xcb_window_t root;
xcb_colormap_t default_colormap;
uint32_t white_pixel;
uint32_t black_pixel;
uint32_t current_input_masks;
uint16_t width_in_pixels;
uint16_t height_in_pixels;
uint16_t width_in_millimeters;
uint16_t height_in_millimeters;
uint16_t min_installed_maps;
uint16_t max_installed_maps;
xcb_visualid_t root_visual;
uint8_t backing_stores;
uint8_t save_unders;
uint8_t root_depth;
uint8_t allowed_depths_len;
} xcb_screen_t;
/**
* @brief xcb_screen_iterator_t
**/
typedef struct xcb_screen_iterator_t {
xcb_screen_t *data;
int rem;
int index;
} xcb_screen_iterator_t;
/**
* @brief xcb_setup_request_t
**/
typedef struct xcb_setup_request_t {
uint8_t byte_order;
uint8_t pad0;
uint16_t protocol_major_version;
uint16_t protocol_minor_version;
uint16_t authorization_protocol_name_len;
uint16_t authorization_protocol_data_len;
uint8_t pad1[2];
} xcb_setup_request_t;
/**
* @brief xcb_setup_request_iterator_t
**/
typedef struct xcb_setup_request_iterator_t {
xcb_setup_request_t *data;
int rem;
int index;
} xcb_setup_request_iterator_t;
/**
* @brief xcb_setup_failed_t
**/
typedef struct xcb_setup_failed_t {
uint8_t status;
uint8_t reason_len;
uint16_t protocol_major_version;
uint16_t protocol_minor_version;
uint16_t length;
} xcb_setup_failed_t;
/**
* @brief xcb_setup_failed_iterator_t
**/
typedef struct xcb_setup_failed_iterator_t {
xcb_setup_failed_t *data;
int rem;
int index;
} xcb_setup_failed_iterator_t;
/**
* @brief xcb_setup_authenticate_t
**/
typedef struct xcb_setup_authenticate_t {
uint8_t status;
uint8_t pad0[5];
uint16_t length;
} xcb_setup_authenticate_t;
/**
* @brief xcb_setup_authenticate_iterator_t
**/
typedef struct xcb_setup_authenticate_iterator_t {
xcb_setup_authenticate_t *data;
int rem;
int index;
} xcb_setup_authenticate_iterator_t;
typedef enum xcb_image_order_t {
XCB_IMAGE_ORDER_LSB_FIRST = 0,
XCB_IMAGE_ORDER_MSB_FIRST = 1
} xcb_image_order_t;
/**
* @brief xcb_setup_t
**/
typedef struct xcb_setup_t {
uint8_t status;
uint8_t pad0;
uint16_t protocol_major_version;
uint16_t protocol_minor_version;
uint16_t length;
uint32_t release_number;
uint32_t resource_id_base;
uint32_t resource_id_mask;
uint32_t motion_buffer_size;
uint16_t vendor_len;
uint16_t maximum_request_length;
uint8_t roots_len;
uint8_t pixmap_formats_len;
uint8_t image_byte_order;
uint8_t bitmap_format_bit_order;
uint8_t bitmap_format_scanline_unit;
uint8_t bitmap_format_scanline_pad;
xcb_keycode_t min_keycode;
xcb_keycode_t max_keycode;
uint8_t pad1[4];
} xcb_setup_t;
/**
* @brief xcb_setup_iterator_t
**/
typedef struct xcb_setup_iterator_t {
xcb_setup_t *data;
int rem;
int index;
} xcb_setup_iterator_t;
typedef enum xcb_mod_mask_t {
XCB_MOD_MASK_SHIFT = 1,
XCB_MOD_MASK_LOCK = 2,
XCB_MOD_MASK_CONTROL = 4,
XCB_MOD_MASK_1 = 8,
XCB_MOD_MASK_2 = 16,
XCB_MOD_MASK_3 = 32,
XCB_MOD_MASK_4 = 64,
XCB_MOD_MASK_5 = 128,
XCB_MOD_MASK_ANY = 32768
} xcb_mod_mask_t;
typedef enum xcb_key_but_mask_t {
XCB_KEY_BUT_MASK_SHIFT = 1,
XCB_KEY_BUT_MASK_LOCK = 2,
XCB_KEY_BUT_MASK_CONTROL = 4,
XCB_KEY_BUT_MASK_MOD_1 = 8,
XCB_KEY_BUT_MASK_MOD_2 = 16,
XCB_KEY_BUT_MASK_MOD_3 = 32,
XCB_KEY_BUT_MASK_MOD_4 = 64,
XCB_KEY_BUT_MASK_MOD_5 = 128,
XCB_KEY_BUT_MASK_BUTTON_1 = 256,
XCB_KEY_BUT_MASK_BUTTON_2 = 512,
XCB_KEY_BUT_MASK_BUTTON_3 = 1024,
XCB_KEY_BUT_MASK_BUTTON_4 = 2048,
XCB_KEY_BUT_MASK_BUTTON_5 = 4096
} xcb_key_but_mask_t;
typedef enum xcb_window_enum_t {
XCB_WINDOW_NONE = 0
} xcb_window_enum_t;
/** Opcode for xcb_key_press. */
#define XCB_KEY_PRESS 2
/**
* @brief xcb_key_press_event_t
**/
typedef struct xcb_key_press_event_t {
uint8_t response_type;
xcb_keycode_t detail;
uint16_t sequence;
xcb_timestamp_t time;
xcb_window_t root;
xcb_window_t event;
xcb_window_t child;
int16_t root_x;
int16_t root_y;
int16_t event_x;
int16_t event_y;
uint16_t state;
uint8_t same_screen;
uint8_t pad0;
} xcb_key_press_event_t;
/** Opcode for xcb_key_release. */
#define XCB_KEY_RELEASE 3
typedef xcb_key_press_event_t xcb_key_release_event_t;
typedef enum xcb_button_mask_t {
XCB_BUTTON_MASK_1 = 256,
XCB_BUTTON_MASK_2 = 512,
XCB_BUTTON_MASK_3 = 1024,
XCB_BUTTON_MASK_4 = 2048,
XCB_BUTTON_MASK_5 = 4096,
XCB_BUTTON_MASK_ANY = 32768
} xcb_button_mask_t;
/** Opcode for xcb_button_press. */
#define XCB_BUTTON_PRESS 4
/**
* @brief xcb_button_press_event_t
**/
typedef struct xcb_button_press_event_t {
uint8_t response_type;
xcb_button_t detail;
uint16_t sequence;
xcb_timestamp_t time;
xcb_window_t root;
xcb_window_t event;
xcb_window_t child;
int16_t root_x;
int16_t root_y;
int16_t event_x;
int16_t event_y;
uint16_t state;
uint8_t same_screen;
uint8_t pad0;
} xcb_button_press_event_t;
/** Opcode for xcb_button_release. */
#define XCB_BUTTON_RELEASE 5
typedef xcb_button_press_event_t xcb_button_release_event_t;
typedef enum xcb_motion_t {
XCB_MOTION_NORMAL = 0,
XCB_MOTION_HINT = 1
} xcb_motion_t;
/** Opcode for xcb_motion_notify. */
#define XCB_MOTION_NOTIFY 6
/**
* @brief xcb_motion_notify_event_t
**/
typedef struct xcb_motion_notify_event_t {
uint8_t response_type;
uint8_t detail;
uint16_t sequence;
xcb_timestamp_t time;
xcb_window_t root;
xcb_window_t event;
xcb_window_t child;
int16_t root_x;
int16_t root_y;
int16_t event_x;
int16_t event_y;
uint16_t state;
uint8_t same_screen;
uint8_t pad0;
} xcb_motion_notify_event_t;
typedef enum xcb_notify_detail_t {
XCB_NOTIFY_DETAIL_ANCESTOR = 0,
XCB_NOTIFY_DETAIL_VIRTUAL = 1,
XCB_NOTIFY_DETAIL_INFERIOR = 2,
XCB_NOTIFY_DETAIL_NONLINEAR = 3,
XCB_NOTIFY_DETAIL_NONLINEAR_VIRTUAL = 4,
XCB_NOTIFY_DETAIL_POINTER = 5,
XCB_NOTIFY_DETAIL_POINTER_ROOT = 6,
XCB_NOTIFY_DETAIL_NONE = 7
} xcb_notify_detail_t;
typedef enum xcb_notify_mode_t {
XCB_NOTIFY_MODE_NORMAL = 0,
XCB_NOTIFY_MODE_GRAB = 1,
XCB_NOTIFY_MODE_UNGRAB = 2,
XCB_NOTIFY_MODE_WHILE_GRABBED = 3
} xcb_notify_mode_t;
/** Opcode for xcb_enter_notify. */
#define XCB_ENTER_NOTIFY 7
/**
* @brief xcb_enter_notify_event_t
**/
typedef struct xcb_enter_notify_event_t {
uint8_t response_type;
uint8_t detail;
uint16_t sequence;
xcb_timestamp_t time;
xcb_window_t root;
xcb_window_t event;
xcb_window_t child;
int16_t root_x;
int16_t root_y;
int16_t event_x;
int16_t event_y;
uint16_t state;
uint8_t mode;
uint8_t same_screen_focus;
} xcb_enter_notify_event_t;
/** Opcode for xcb_leave_notify. */
#define XCB_LEAVE_NOTIFY 8
typedef xcb_enter_notify_event_t xcb_leave_notify_event_t;
/** Opcode for xcb_focus_in. */
#define XCB_FOCUS_IN 9
/**
* @brief xcb_focus_in_event_t
**/
typedef struct xcb_focus_in_event_t {
uint8_t response_type;
uint8_t detail;
uint16_t sequence;
xcb_window_t event;
uint8_t mode;
uint8_t pad0[3];
} xcb_focus_in_event_t;
/** Opcode for xcb_focus_out. */
#define XCB_FOCUS_OUT 10
typedef xcb_focus_in_event_t xcb_focus_out_event_t;
/** Opcode for xcb_keymap_notify. */
#define XCB_KEYMAP_NOTIFY 11
/**
* @brief xcb_keymap_notify_event_t
**/
typedef struct xcb_keymap_notify_event_t {
uint8_t response_type;
uint8_t keys[31];
} xcb_keymap_notify_event_t;
/** Opcode for xcb_expose. */
#define XCB_EXPOSE 12
/**
* @brief xcb_expose_event_t
**/
typedef struct xcb_expose_event_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
xcb_window_t window;
uint16_t x;
uint16_t y;
uint16_t width;
uint16_t height;
uint16_t count;
uint8_t pad1[2];
} xcb_expose_event_t;
/** Opcode for xcb_graphics_exposure. */
#define XCB_GRAPHICS_EXPOSURE 13
/**
* @brief xcb_graphics_exposure_event_t
**/
typedef struct xcb_graphics_exposure_event_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
xcb_drawable_t drawable;
uint16_t x;
uint16_t y;
uint16_t width;
uint16_t height;
uint16_t minor_opcode;
uint16_t count;
uint8_t major_opcode;
uint8_t pad1[3];
} xcb_graphics_exposure_event_t;
/** Opcode for xcb_no_exposure. */
#define XCB_NO_EXPOSURE 14
/**
* @brief xcb_no_exposure_event_t
**/
typedef struct xcb_no_exposure_event_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
xcb_drawable_t drawable;
uint16_t minor_opcode;
uint8_t major_opcode;
uint8_t pad1;
} xcb_no_exposure_event_t;
typedef enum xcb_visibility_t {
XCB_VISIBILITY_UNOBSCURED = 0,
XCB_VISIBILITY_PARTIALLY_OBSCURED = 1,
XCB_VISIBILITY_FULLY_OBSCURED = 2
} xcb_visibility_t;
/** Opcode for xcb_visibility_notify. */
#define XCB_VISIBILITY_NOTIFY 15
/**
* @brief xcb_visibility_notify_event_t
**/
typedef struct xcb_visibility_notify_event_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
xcb_window_t window;
uint8_t state;
uint8_t pad1[3];
} xcb_visibility_notify_event_t;
/** Opcode for xcb_create_notify. */
#define XCB_CREATE_NOTIFY 16
/**
* @brief xcb_create_notify_event_t
**/
typedef struct xcb_create_notify_event_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
xcb_window_t parent;
xcb_window_t window;
int16_t x;
int16_t y;
uint16_t width;
uint16_t height;
uint16_t border_width;
uint8_t override_redirect;
uint8_t pad1;
} xcb_create_notify_event_t;
/** Opcode for xcb_destroy_notify. */
#define XCB_DESTROY_NOTIFY 17
/**
* @brief xcb_destroy_notify_event_t
**/
typedef struct xcb_destroy_notify_event_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
xcb_window_t event;
xcb_window_t window;
} xcb_destroy_notify_event_t;
/** Opcode for xcb_unmap_notify. */
#define XCB_UNMAP_NOTIFY 18
/**
* @brief xcb_unmap_notify_event_t
**/
typedef struct xcb_unmap_notify_event_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
xcb_window_t event;
xcb_window_t window;
uint8_t from_configure;
uint8_t pad1[3];
} xcb_unmap_notify_event_t;
/** Opcode for xcb_map_notify. */
#define XCB_MAP_NOTIFY 19
/**
* @brief xcb_map_notify_event_t
**/
typedef struct xcb_map_notify_event_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
xcb_window_t event;
xcb_window_t window;
uint8_t override_redirect;
uint8_t pad1[3];
} xcb_map_notify_event_t;
/** Opcode for xcb_map_request. */
#define XCB_MAP_REQUEST 20
/**
* @brief xcb_map_request_event_t
**/
typedef struct xcb_map_request_event_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
xcb_window_t parent;
xcb_window_t window;
} xcb_map_request_event_t;
/** Opcode for xcb_reparent_notify. */
#define XCB_REPARENT_NOTIFY 21
/**
* @brief xcb_reparent_notify_event_t
**/
typedef struct xcb_reparent_notify_event_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
xcb_window_t event;
xcb_window_t window;
xcb_window_t parent;
int16_t x;
int16_t y;
uint8_t override_redirect;
uint8_t pad1[3];
} xcb_reparent_notify_event_t;
/** Opcode for xcb_configure_notify. */
#define XCB_CONFIGURE_NOTIFY 22
/**
* @brief xcb_configure_notify_event_t
**/
typedef struct xcb_configure_notify_event_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
xcb_window_t event;
xcb_window_t window;
xcb_window_t above_sibling;
int16_t x;
int16_t y;
uint16_t width;
uint16_t height;
uint16_t border_width;
uint8_t override_redirect;
uint8_t pad1;
} xcb_configure_notify_event_t;
/** Opcode for xcb_configure_request. */
#define XCB_CONFIGURE_REQUEST 23
/**
* @brief xcb_configure_request_event_t
**/
typedef struct xcb_configure_request_event_t {
uint8_t response_type;
uint8_t stack_mode;
uint16_t sequence;
xcb_window_t parent;
xcb_window_t window;
xcb_window_t sibling;
int16_t x;
int16_t y;
uint16_t width;
uint16_t height;
uint16_t border_width;
uint16_t value_mask;
} xcb_configure_request_event_t;
/** Opcode for xcb_gravity_notify. */
#define XCB_GRAVITY_NOTIFY 24
/**
* @brief xcb_gravity_notify_event_t
**/
typedef struct xcb_gravity_notify_event_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
xcb_window_t event;
xcb_window_t window;
int16_t x;
int16_t y;
} xcb_gravity_notify_event_t;
/** Opcode for xcb_resize_request. */
#define XCB_RESIZE_REQUEST 25
/**
* @brief xcb_resize_request_event_t
**/
typedef struct xcb_resize_request_event_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
xcb_window_t window;
uint16_t width;
uint16_t height;
} xcb_resize_request_event_t;
typedef enum xcb_place_t {
XCB_PLACE_ON_TOP = 0,
/**< The window is now on top of all siblings. */
XCB_PLACE_ON_BOTTOM = 1
/**< The window is now below all siblings. */
} xcb_place_t;
/** Opcode for xcb_circulate_notify. */
#define XCB_CIRCULATE_NOTIFY 26
/**
* @brief xcb_circulate_notify_event_t
**/
typedef struct xcb_circulate_notify_event_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
xcb_window_t event;
xcb_window_t window;
uint8_t pad1[4];
uint8_t place;
uint8_t pad2[3];
} xcb_circulate_notify_event_t;
/** Opcode for xcb_circulate_request. */
#define XCB_CIRCULATE_REQUEST 27
typedef xcb_circulate_notify_event_t xcb_circulate_request_event_t;
typedef enum xcb_property_t {
XCB_PROPERTY_NEW_VALUE = 0,
XCB_PROPERTY_DELETE = 1
} xcb_property_t;
/** Opcode for xcb_property_notify. */
#define XCB_PROPERTY_NOTIFY 28
/**
* @brief xcb_property_notify_event_t
**/
typedef struct xcb_property_notify_event_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
xcb_window_t window;
xcb_atom_t atom;
xcb_timestamp_t time;
uint8_t state;
uint8_t pad1[3];
} xcb_property_notify_event_t;
/** Opcode for xcb_selection_clear. */
#define XCB_SELECTION_CLEAR 29
/**
* @brief xcb_selection_clear_event_t
**/
typedef struct xcb_selection_clear_event_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
xcb_timestamp_t time;
xcb_window_t owner;
xcb_atom_t selection;
} xcb_selection_clear_event_t;
typedef enum xcb_time_t {
XCB_TIME_CURRENT_TIME = 0
} xcb_time_t;
typedef enum xcb_atom_enum_t {
XCB_ATOM_NONE = 0,
XCB_ATOM_ANY = 0,
XCB_ATOM_PRIMARY = 1,
XCB_ATOM_SECONDARY = 2,
XCB_ATOM_ARC = 3,
XCB_ATOM_ATOM = 4,
XCB_ATOM_BITMAP = 5,
XCB_ATOM_CARDINAL = 6,
XCB_ATOM_COLORMAP = 7,
XCB_ATOM_CURSOR = 8,
XCB_ATOM_CUT_BUFFER0 = 9,
XCB_ATOM_CUT_BUFFER1 = 10,
XCB_ATOM_CUT_BUFFER2 = 11,
XCB_ATOM_CUT_BUFFER3 = 12,
XCB_ATOM_CUT_BUFFER4 = 13,
XCB_ATOM_CUT_BUFFER5 = 14,
XCB_ATOM_CUT_BUFFER6 = 15,
XCB_ATOM_CUT_BUFFER7 = 16,
XCB_ATOM_DRAWABLE = 17,
XCB_ATOM_FONT = 18,
XCB_ATOM_INTEGER = 19,
XCB_ATOM_PIXMAP = 20,
XCB_ATOM_POINT = 21,
XCB_ATOM_RECTANGLE = 22,
XCB_ATOM_RESOURCE_MANAGER = 23,
XCB_ATOM_RGB_COLOR_MAP = 24,
XCB_ATOM_RGB_BEST_MAP = 25,
XCB_ATOM_RGB_BLUE_MAP = 26,
XCB_ATOM_RGB_DEFAULT_MAP = 27,
XCB_ATOM_RGB_GRAY_MAP = 28,
XCB_ATOM_RGB_GREEN_MAP = 29,
XCB_ATOM_RGB_RED_MAP = 30,
XCB_ATOM_STRING = 31,
XCB_ATOM_VISUALID = 32,
XCB_ATOM_WINDOW = 33,
XCB_ATOM_WM_COMMAND = 34,
XCB_ATOM_WM_HINTS = 35,
XCB_ATOM_WM_CLIENT_MACHINE = 36,
XCB_ATOM_WM_ICON_NAME = 37,
XCB_ATOM_WM_ICON_SIZE = 38,
XCB_ATOM_WM_NAME = 39,
XCB_ATOM_WM_NORMAL_HINTS = 40,
XCB_ATOM_WM_SIZE_HINTS = 41,
XCB_ATOM_WM_ZOOM_HINTS = 42,
XCB_ATOM_MIN_SPACE = 43,
XCB_ATOM_NORM_SPACE = 44,
XCB_ATOM_MAX_SPACE = 45,
XCB_ATOM_END_SPACE = 46,
XCB_ATOM_SUPERSCRIPT_X = 47,
XCB_ATOM_SUPERSCRIPT_Y = 48,
XCB_ATOM_SUBSCRIPT_X = 49,
XCB_ATOM_SUBSCRIPT_Y = 50,
XCB_ATOM_UNDERLINE_POSITION = 51,
XCB_ATOM_UNDERLINE_THICKNESS = 52,
XCB_ATOM_STRIKEOUT_ASCENT = 53,
XCB_ATOM_STRIKEOUT_DESCENT = 54,
XCB_ATOM_ITALIC_ANGLE = 55,
XCB_ATOM_X_HEIGHT = 56,
XCB_ATOM_QUAD_WIDTH = 57,
XCB_ATOM_WEIGHT = 58,
XCB_ATOM_POINT_SIZE = 59,
XCB_ATOM_RESOLUTION = 60,
XCB_ATOM_COPYRIGHT = 61,
XCB_ATOM_NOTICE = 62,
XCB_ATOM_FONT_NAME = 63,
XCB_ATOM_FAMILY_NAME = 64,
XCB_ATOM_FULL_NAME = 65,
XCB_ATOM_CAP_HEIGHT = 66,
XCB_ATOM_WM_CLASS = 67,
XCB_ATOM_WM_TRANSIENT_FOR = 68
} xcb_atom_enum_t;
/** Opcode for xcb_selection_request. */
#define XCB_SELECTION_REQUEST 30
/**
* @brief xcb_selection_request_event_t
**/
typedef struct xcb_selection_request_event_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
xcb_timestamp_t time;
xcb_window_t owner;
xcb_window_t requestor;
xcb_atom_t selection;
xcb_atom_t target;
xcb_atom_t property;
} xcb_selection_request_event_t;
/** Opcode for xcb_selection_notify. */
#define XCB_SELECTION_NOTIFY 31
/**
* @brief xcb_selection_notify_event_t
**/
typedef struct xcb_selection_notify_event_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
xcb_timestamp_t time;
xcb_window_t requestor;
xcb_atom_t selection;
xcb_atom_t target;
xcb_atom_t property;
} xcb_selection_notify_event_t;
typedef enum xcb_colormap_state_t {
XCB_COLORMAP_STATE_UNINSTALLED = 0,
/**< The colormap was uninstalled. */
XCB_COLORMAP_STATE_INSTALLED = 1
/**< The colormap was installed. */
} xcb_colormap_state_t;
typedef enum xcb_colormap_enum_t {
XCB_COLORMAP_NONE = 0
} xcb_colormap_enum_t;
/** Opcode for xcb_colormap_notify. */
#define XCB_COLORMAP_NOTIFY 32
/**
* @brief xcb_colormap_notify_event_t
**/
typedef struct xcb_colormap_notify_event_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
xcb_window_t window;
xcb_colormap_t colormap;
uint8_t _new;
uint8_t state;
uint8_t pad1[2];
} xcb_colormap_notify_event_t;
/**
* @brief xcb_client_message_data_t
**/
typedef union xcb_client_message_data_t {
uint8_t data8[20];
uint16_t data16[10];
uint32_t data32[5];
} xcb_client_message_data_t;
/**
* @brief xcb_client_message_data_iterator_t
**/
typedef struct xcb_client_message_data_iterator_t {
xcb_client_message_data_t *data;
int rem;
int index;
} xcb_client_message_data_iterator_t;
/** Opcode for xcb_client_message. */
#define XCB_CLIENT_MESSAGE 33
/**
* @brief xcb_client_message_event_t
**/
typedef struct xcb_client_message_event_t {
uint8_t response_type;
uint8_t format;
uint16_t sequence;
xcb_window_t window;
xcb_atom_t type;
xcb_client_message_data_t data;
} xcb_client_message_event_t;
typedef enum xcb_mapping_t {
XCB_MAPPING_MODIFIER = 0,
XCB_MAPPING_KEYBOARD = 1,
XCB_MAPPING_POINTER = 2
} xcb_mapping_t;
/** Opcode for xcb_mapping_notify. */
#define XCB_MAPPING_NOTIFY 34
/**
* @brief xcb_mapping_notify_event_t
**/
typedef struct xcb_mapping_notify_event_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint8_t request;
xcb_keycode_t first_keycode;
uint8_t count;
uint8_t pad1;
} xcb_mapping_notify_event_t;
/** Opcode for xcb_ge_generic. */
#define XCB_GE_GENERIC 35
/**
* @brief xcb_ge_generic_event_t
**/
typedef struct xcb_ge_generic_event_t {
uint8_t response_type;
uint8_t extension;
uint16_t sequence;
uint32_t length;
uint16_t event_type;
uint8_t pad0[22];
uint32_t full_sequence;
} xcb_ge_generic_event_t;
/** Opcode for xcb_request. */
#define XCB_REQUEST 1
/**
* @brief xcb_request_error_t
**/
typedef struct xcb_request_error_t {
uint8_t response_type;
uint8_t error_code;
uint16_t sequence;
uint32_t bad_value;
uint16_t minor_opcode;
uint8_t major_opcode;
uint8_t pad0;
} xcb_request_error_t;
/** Opcode for xcb_value. */
#define XCB_VALUE 2
/**
* @brief xcb_value_error_t
**/
typedef struct xcb_value_error_t {
uint8_t response_type;
uint8_t error_code;
uint16_t sequence;
uint32_t bad_value;
uint16_t minor_opcode;
uint8_t major_opcode;
uint8_t pad0;
} xcb_value_error_t;
/** Opcode for xcb_window. */
#define XCB_WINDOW 3
typedef xcb_value_error_t xcb_window_error_t;
/** Opcode for xcb_pixmap. */
#define XCB_PIXMAP 4
typedef xcb_value_error_t xcb_pixmap_error_t;
/** Opcode for xcb_atom. */
#define XCB_ATOM 5
typedef xcb_value_error_t xcb_atom_error_t;
/** Opcode for xcb_cursor. */
#define XCB_CURSOR 6
typedef xcb_value_error_t xcb_cursor_error_t;
/** Opcode for xcb_font. */
#define XCB_FONT 7
typedef xcb_value_error_t xcb_font_error_t;
/** Opcode for xcb_match. */
#define XCB_MATCH 8
typedef xcb_request_error_t xcb_match_error_t;
/** Opcode for xcb_drawable. */
#define XCB_DRAWABLE 9
typedef xcb_value_error_t xcb_drawable_error_t;
/** Opcode for xcb_access. */
#define XCB_ACCESS 10
typedef xcb_request_error_t xcb_access_error_t;
/** Opcode for xcb_alloc. */
#define XCB_ALLOC 11
typedef xcb_request_error_t xcb_alloc_error_t;
/** Opcode for xcb_colormap. */
#define XCB_COLORMAP 12
typedef xcb_value_error_t xcb_colormap_error_t;
/** Opcode for xcb_g_context. */
#define XCB_G_CONTEXT 13
typedef xcb_value_error_t xcb_g_context_error_t;
/** Opcode for xcb_id_choice. */
#define XCB_ID_CHOICE 14
typedef xcb_value_error_t xcb_id_choice_error_t;
/** Opcode for xcb_name. */
#define XCB_NAME 15
typedef xcb_request_error_t xcb_name_error_t;
/** Opcode for xcb_length. */
#define XCB_LENGTH 16
typedef xcb_request_error_t xcb_length_error_t;
/** Opcode for xcb_implementation. */
#define XCB_IMPLEMENTATION 17
typedef xcb_request_error_t xcb_implementation_error_t;
typedef enum xcb_window_class_t {
XCB_WINDOW_CLASS_COPY_FROM_PARENT = 0,
XCB_WINDOW_CLASS_INPUT_OUTPUT = 1,
XCB_WINDOW_CLASS_INPUT_ONLY = 2
} xcb_window_class_t;
typedef enum xcb_cw_t {
XCB_CW_BACK_PIXMAP = 1,
/**< Overrides the default background-pixmap. The background pixmap and window must
have the same root and same depth. Any size pixmap can be used, although some
sizes may be faster than others.
If `XCB_BACK_PIXMAP_NONE` is specified, the window has no defined background.
The server may fill the contents with the previous screen contents or with
contents of its own choosing.
If `XCB_BACK_PIXMAP_PARENT_RELATIVE` is specified, the parent's background is
used, but the window must have the same depth as the parent (or a Match error
results). The parent's background is tracked, and the current version is
used each time the window background is required. */
XCB_CW_BACK_PIXEL = 2,
/**< Overrides `BackPixmap`. A pixmap of undefined size filled with the specified
background pixel is used for the background. Range-checking is not performed,
the background pixel is truncated to the appropriate number of bits. */
XCB_CW_BORDER_PIXMAP = 4,
/**< Overrides the default border-pixmap. The border pixmap and window must have the
same root and the same depth. Any size pixmap can be used, although some sizes
may be faster than others.
The special value `XCB_COPY_FROM_PARENT` means the parent's border pixmap is
copied (subsequent changes to the parent's border attribute do not affect the
child), but the window must have the same depth as the parent. */
XCB_CW_BORDER_PIXEL = 8,
/**< Overrides `BorderPixmap`. A pixmap of undefined size filled with the specified
border pixel is used for the border. Range checking is not performed on the
border-pixel value, it is truncated to the appropriate number of bits. */
XCB_CW_BIT_GRAVITY = 16,
/**< Defines which region of the window should be retained if the window is resized. */
XCB_CW_WIN_GRAVITY = 32,
/**< Defines how the window should be repositioned if the parent is resized (see
`ConfigureWindow`). */
XCB_CW_BACKING_STORE = 64,
/**< A backing-store of `WhenMapped` advises the server that maintaining contents of
obscured regions when the window is mapped would be beneficial. A backing-store
of `Always` advises the server that maintaining contents even when the window
is unmapped would be beneficial. In this case, the server may generate an
exposure event when the window is created. A value of `NotUseful` advises the
server that maintaining contents is unnecessary, although a server may still
choose to maintain contents while the window is mapped. Note that if the server
maintains contents, then the server should maintain complete contents not just
the region within the parent boundaries, even if the window is larger than its
parent. While the server maintains contents, exposure events will not normally
be generated, but the server may stop maintaining contents at any time. */
XCB_CW_BACKING_PLANES = 128,
/**< The backing-planes indicates (with bits set to 1) which bit planes of the
window hold dynamic data that must be preserved in backing-stores and during
save-unders. */
XCB_CW_BACKING_PIXEL = 256,
/**< The backing-pixel specifies what value to use in planes not covered by
backing-planes. The server is free to save only the specified bit planes in the
backing-store or save-under and regenerate the remaining planes with the
specified pixel value. Any bits beyond the specified depth of the window in
these values are simply ignored. */
XCB_CW_OVERRIDE_REDIRECT = 512,
/**< The override-redirect specifies whether map and configure requests on this
window should override a SubstructureRedirect on the parent, typically to
inform a window manager not to tamper with the window. */
XCB_CW_SAVE_UNDER = 1024,
/**< If 1, the server is advised that when this window is mapped, saving the
contents of windows it obscures would be beneficial. */
XCB_CW_EVENT_MASK = 2048,
/**< The event-mask defines which events the client is interested in for this window
(or for some event types, inferiors of the window). */
XCB_CW_DONT_PROPAGATE = 4096,
/**< The do-not-propagate-mask defines which events should not be propagated to
ancestor windows when no client has the event type selected in this window. */
XCB_CW_COLORMAP = 8192,
/**< The colormap specifies the colormap that best reflects the true colors of the window. Servers
capable of supporting multiple hardware colormaps may use this information, and window man-
agers may use it for InstallColormap requests. The colormap must have the same visual type
and root as the window (or a Match error results). If CopyFromParent is specified, the parent's
colormap is copied (subsequent changes to the parent's colormap attribute do not affect the child).
However, the window must have the same visual type as the parent (or a Match error results),
and the parent must not have a colormap of None (or a Match error results). For an explanation
of None, see FreeColormap request. The colormap is copied by sharing the colormap object
between the child and the parent, not by making a complete copy of the colormap contents. */
XCB_CW_CURSOR = 16384
/**< If a cursor is specified, it will be used whenever the pointer is in the window. If None is speci-
fied, the parent's cursor will be used when the pointer is in the window, and any change in the
parent's cursor will cause an immediate change in the displayed cursor. */
} xcb_cw_t;
typedef enum xcb_back_pixmap_t {
XCB_BACK_PIXMAP_NONE = 0,
XCB_BACK_PIXMAP_PARENT_RELATIVE = 1
} xcb_back_pixmap_t;
typedef enum xcb_gravity_t {
XCB_GRAVITY_BIT_FORGET = 0,
XCB_GRAVITY_WIN_UNMAP = 0,
XCB_GRAVITY_NORTH_WEST = 1,
XCB_GRAVITY_NORTH = 2,
XCB_GRAVITY_NORTH_EAST = 3,
XCB_GRAVITY_WEST = 4,
XCB_GRAVITY_CENTER = 5,
XCB_GRAVITY_EAST = 6,
XCB_GRAVITY_SOUTH_WEST = 7,
XCB_GRAVITY_SOUTH = 8,
XCB_GRAVITY_SOUTH_EAST = 9,
XCB_GRAVITY_STATIC = 10
} xcb_gravity_t;
/**
* @brief xcb_create_window_value_list_t
**/
typedef struct xcb_create_window_value_list_t {
xcb_pixmap_t background_pixmap;
uint32_t background_pixel;
xcb_pixmap_t border_pixmap;
uint32_t border_pixel;
uint32_t bit_gravity;
uint32_t win_gravity;
uint32_t backing_store;
uint32_t backing_planes;
uint32_t backing_pixel;
xcb_bool32_t override_redirect;
xcb_bool32_t save_under;
uint32_t event_mask;
uint32_t do_not_propogate_mask;
xcb_colormap_t colormap;
xcb_cursor_t cursor;
} xcb_create_window_value_list_t;
/** Opcode for xcb_create_window. */
#define XCB_CREATE_WINDOW 1
/**
* @brief xcb_create_window_request_t
**/
typedef struct xcb_create_window_request_t {
uint8_t major_opcode;
uint8_t depth;
uint16_t length;
xcb_window_t wid;
xcb_window_t parent;
int16_t x;
int16_t y;
uint16_t width;
uint16_t height;
uint16_t border_width;
uint16_t _class;
xcb_visualid_t visual;
uint32_t value_mask;
} xcb_create_window_request_t;
/**
* @brief xcb_change_window_attributes_value_list_t
**/
typedef struct xcb_change_window_attributes_value_list_t {
xcb_pixmap_t background_pixmap;
uint32_t background_pixel;
xcb_pixmap_t border_pixmap;
uint32_t border_pixel;
uint32_t bit_gravity;
uint32_t win_gravity;
uint32_t backing_store;
uint32_t backing_planes;
uint32_t backing_pixel;
xcb_bool32_t override_redirect;
xcb_bool32_t save_under;
uint32_t event_mask;
uint32_t do_not_propogate_mask;
xcb_colormap_t colormap;
xcb_cursor_t cursor;
} xcb_change_window_attributes_value_list_t;
/** Opcode for xcb_change_window_attributes. */
#define XCB_CHANGE_WINDOW_ATTRIBUTES 2
/**
* @brief xcb_change_window_attributes_request_t
**/
typedef struct xcb_change_window_attributes_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_window_t window;
uint32_t value_mask;
} xcb_change_window_attributes_request_t;
typedef enum xcb_map_state_t {
XCB_MAP_STATE_UNMAPPED = 0,
XCB_MAP_STATE_UNVIEWABLE = 1,
XCB_MAP_STATE_VIEWABLE = 2
} xcb_map_state_t;
/**
* @brief xcb_get_window_attributes_cookie_t
**/
typedef struct xcb_get_window_attributes_cookie_t {
unsigned int sequence;
} xcb_get_window_attributes_cookie_t;
/** Opcode for xcb_get_window_attributes. */
#define XCB_GET_WINDOW_ATTRIBUTES 3
/**
* @brief xcb_get_window_attributes_request_t
**/
typedef struct xcb_get_window_attributes_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_window_t window;
} xcb_get_window_attributes_request_t;
/**
* @brief xcb_get_window_attributes_reply_t
**/
typedef struct xcb_get_window_attributes_reply_t {
uint8_t response_type;
uint8_t backing_store;
uint16_t sequence;
uint32_t length;
xcb_visualid_t visual;
uint16_t _class;
uint8_t bit_gravity;
uint8_t win_gravity;
uint32_t backing_planes;
uint32_t backing_pixel;
uint8_t save_under;
uint8_t map_is_installed;
uint8_t map_state;
uint8_t override_redirect;
xcb_colormap_t colormap;
uint32_t all_event_masks;
uint32_t your_event_mask;
uint16_t do_not_propagate_mask;
uint8_t pad0[2];
} xcb_get_window_attributes_reply_t;
/** Opcode for xcb_destroy_window. */
#define XCB_DESTROY_WINDOW 4
/**
* @brief xcb_destroy_window_request_t
**/
typedef struct xcb_destroy_window_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_window_t window;
} xcb_destroy_window_request_t;
/** Opcode for xcb_destroy_subwindows. */
#define XCB_DESTROY_SUBWINDOWS 5
/**
* @brief xcb_destroy_subwindows_request_t
**/
typedef struct xcb_destroy_subwindows_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_window_t window;
} xcb_destroy_subwindows_request_t;
typedef enum xcb_set_mode_t {
XCB_SET_MODE_INSERT = 0,
XCB_SET_MODE_DELETE = 1
} xcb_set_mode_t;
/** Opcode for xcb_change_save_set. */
#define XCB_CHANGE_SAVE_SET 6
/**
* @brief xcb_change_save_set_request_t
**/
typedef struct xcb_change_save_set_request_t {
uint8_t major_opcode;
uint8_t mode;
uint16_t length;
xcb_window_t window;
} xcb_change_save_set_request_t;
/** Opcode for xcb_reparent_window. */
#define XCB_REPARENT_WINDOW 7
/**
* @brief xcb_reparent_window_request_t
**/
typedef struct xcb_reparent_window_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_window_t window;
xcb_window_t parent;
int16_t x;
int16_t y;
} xcb_reparent_window_request_t;
/** Opcode for xcb_map_window. */
#define XCB_MAP_WINDOW 8
/**
* @brief xcb_map_window_request_t
**/
typedef struct xcb_map_window_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_window_t window;
} xcb_map_window_request_t;
/** Opcode for xcb_map_subwindows. */
#define XCB_MAP_SUBWINDOWS 9
/**
* @brief xcb_map_subwindows_request_t
**/
typedef struct xcb_map_subwindows_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_window_t window;
} xcb_map_subwindows_request_t;
/** Opcode for xcb_unmap_window. */
#define XCB_UNMAP_WINDOW 10
/**
* @brief xcb_unmap_window_request_t
**/
typedef struct xcb_unmap_window_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_window_t window;
} xcb_unmap_window_request_t;
/** Opcode for xcb_unmap_subwindows. */
#define XCB_UNMAP_SUBWINDOWS 11
/**
* @brief xcb_unmap_subwindows_request_t
**/
typedef struct xcb_unmap_subwindows_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_window_t window;
} xcb_unmap_subwindows_request_t;
typedef enum xcb_config_window_t {
XCB_CONFIG_WINDOW_X = 1,
XCB_CONFIG_WINDOW_Y = 2,
XCB_CONFIG_WINDOW_WIDTH = 4,
XCB_CONFIG_WINDOW_HEIGHT = 8,
XCB_CONFIG_WINDOW_BORDER_WIDTH = 16,
XCB_CONFIG_WINDOW_SIBLING = 32,
XCB_CONFIG_WINDOW_STACK_MODE = 64
} xcb_config_window_t;
typedef enum xcb_stack_mode_t {
XCB_STACK_MODE_ABOVE = 0,
XCB_STACK_MODE_BELOW = 1,
XCB_STACK_MODE_TOP_IF = 2,
XCB_STACK_MODE_BOTTOM_IF = 3,
XCB_STACK_MODE_OPPOSITE = 4
} xcb_stack_mode_t;
/**
* @brief xcb_configure_window_value_list_t
**/
typedef struct xcb_configure_window_value_list_t {
int32_t x;
int32_t y;
uint32_t width;
uint32_t height;
uint32_t border_width;
xcb_window_t sibling;
uint32_t stack_mode;
} xcb_configure_window_value_list_t;
/** Opcode for xcb_configure_window. */
#define XCB_CONFIGURE_WINDOW 12
/**
* @brief xcb_configure_window_request_t
**/
typedef struct xcb_configure_window_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_window_t window;
uint16_t value_mask;
uint8_t pad1[2];
} xcb_configure_window_request_t;
typedef enum xcb_circulate_t {
XCB_CIRCULATE_RAISE_LOWEST = 0,
XCB_CIRCULATE_LOWER_HIGHEST = 1
} xcb_circulate_t;
/** Opcode for xcb_circulate_window. */
#define XCB_CIRCULATE_WINDOW 13
/**
* @brief xcb_circulate_window_request_t
**/
typedef struct xcb_circulate_window_request_t {
uint8_t major_opcode;
uint8_t direction;
uint16_t length;
xcb_window_t window;
} xcb_circulate_window_request_t;
/**
* @brief xcb_get_geometry_cookie_t
**/
typedef struct xcb_get_geometry_cookie_t {
unsigned int sequence;
} xcb_get_geometry_cookie_t;
/** Opcode for xcb_get_geometry. */
#define XCB_GET_GEOMETRY 14
/**
* @brief xcb_get_geometry_request_t
**/
typedef struct xcb_get_geometry_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_drawable_t drawable;
} xcb_get_geometry_request_t;
/**
* @brief xcb_get_geometry_reply_t
**/
typedef struct xcb_get_geometry_reply_t {
uint8_t response_type;
uint8_t depth;
uint16_t sequence;
uint32_t length;
xcb_window_t root;
int16_t x;
int16_t y;
uint16_t width;
uint16_t height;
uint16_t border_width;
uint8_t pad0[2];
} xcb_get_geometry_reply_t;
/**
* @brief xcb_query_tree_cookie_t
**/
typedef struct xcb_query_tree_cookie_t {
unsigned int sequence;
} xcb_query_tree_cookie_t;
/** Opcode for xcb_query_tree. */
#define XCB_QUERY_TREE 15
/**
* @brief xcb_query_tree_request_t
**/
typedef struct xcb_query_tree_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_window_t window;
} xcb_query_tree_request_t;
/**
* @brief xcb_query_tree_reply_t
**/
typedef struct xcb_query_tree_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
xcb_window_t root;
xcb_window_t parent;
uint16_t children_len;
uint8_t pad1[14];
} xcb_query_tree_reply_t;
/**
* @brief xcb_intern_atom_cookie_t
**/
typedef struct xcb_intern_atom_cookie_t {
unsigned int sequence;
} xcb_intern_atom_cookie_t;
/** Opcode for xcb_intern_atom. */
#define XCB_INTERN_ATOM 16
/**
* @brief xcb_intern_atom_request_t
**/
typedef struct xcb_intern_atom_request_t {
uint8_t major_opcode;
uint8_t only_if_exists;
uint16_t length;
uint16_t name_len;
uint8_t pad0[2];
} xcb_intern_atom_request_t;
/**
* @brief xcb_intern_atom_reply_t
**/
typedef struct xcb_intern_atom_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
xcb_atom_t atom;
} xcb_intern_atom_reply_t;
/**
* @brief xcb_get_atom_name_cookie_t
**/
typedef struct xcb_get_atom_name_cookie_t {
unsigned int sequence;
} xcb_get_atom_name_cookie_t;
/** Opcode for xcb_get_atom_name. */
#define XCB_GET_ATOM_NAME 17
/**
* @brief xcb_get_atom_name_request_t
**/
typedef struct xcb_get_atom_name_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_atom_t atom;
} xcb_get_atom_name_request_t;
/**
* @brief xcb_get_atom_name_reply_t
**/
typedef struct xcb_get_atom_name_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t name_len;
uint8_t pad1[22];
} xcb_get_atom_name_reply_t;
typedef enum xcb_prop_mode_t {
XCB_PROP_MODE_REPLACE = 0,
/**< Discard the previous property value and store the new data. */
XCB_PROP_MODE_PREPEND = 1,
/**< Insert the new data before the beginning of existing data. The `format` must
match existing property value. If the property is undefined, it is treated as
defined with the correct type and format with zero-length data. */
XCB_PROP_MODE_APPEND = 2
/**< Insert the new data after the beginning of existing data. The `format` must
match existing property value. If the property is undefined, it is treated as
defined with the correct type and format with zero-length data. */
} xcb_prop_mode_t;
/** Opcode for xcb_change_property. */
#define XCB_CHANGE_PROPERTY 18
/**
* @brief xcb_change_property_request_t
**/
typedef struct xcb_change_property_request_t {
uint8_t major_opcode;
uint8_t mode;
uint16_t length;
xcb_window_t window;
xcb_atom_t property;
xcb_atom_t type;
uint8_t format;
uint8_t pad0[3];
uint32_t data_len;
} xcb_change_property_request_t;
/** Opcode for xcb_delete_property. */
#define XCB_DELETE_PROPERTY 19
/**
* @brief xcb_delete_property_request_t
**/
typedef struct xcb_delete_property_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_window_t window;
xcb_atom_t property;
} xcb_delete_property_request_t;
typedef enum xcb_get_property_type_t {
XCB_GET_PROPERTY_TYPE_ANY = 0
} xcb_get_property_type_t;
/**
* @brief xcb_get_property_cookie_t
**/
typedef struct xcb_get_property_cookie_t {
unsigned int sequence;
} xcb_get_property_cookie_t;
/** Opcode for xcb_get_property. */
#define XCB_GET_PROPERTY 20
/**
* @brief xcb_get_property_request_t
**/
typedef struct xcb_get_property_request_t {
uint8_t major_opcode;
uint8_t _delete;
uint16_t length;
xcb_window_t window;
xcb_atom_t property;
xcb_atom_t type;
uint32_t long_offset;
uint32_t long_length;
} xcb_get_property_request_t;
/**
* @brief xcb_get_property_reply_t
**/
typedef struct xcb_get_property_reply_t {
uint8_t response_type;
uint8_t format;
uint16_t sequence;
uint32_t length;
xcb_atom_t type;
uint32_t bytes_after;
uint32_t value_len;
uint8_t pad0[12];
} xcb_get_property_reply_t;
/**
* @brief xcb_list_properties_cookie_t
**/
typedef struct xcb_list_properties_cookie_t {
unsigned int sequence;
} xcb_list_properties_cookie_t;
/** Opcode for xcb_list_properties. */
#define XCB_LIST_PROPERTIES 21
/**
* @brief xcb_list_properties_request_t
**/
typedef struct xcb_list_properties_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_window_t window;
} xcb_list_properties_request_t;
/**
* @brief xcb_list_properties_reply_t
**/
typedef struct xcb_list_properties_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t atoms_len;
uint8_t pad1[22];
} xcb_list_properties_reply_t;
/** Opcode for xcb_set_selection_owner. */
#define XCB_SET_SELECTION_OWNER 22
/**
* @brief xcb_set_selection_owner_request_t
**/
typedef struct xcb_set_selection_owner_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_window_t owner;
xcb_atom_t selection;
xcb_timestamp_t time;
} xcb_set_selection_owner_request_t;
/**
* @brief xcb_get_selection_owner_cookie_t
**/
typedef struct xcb_get_selection_owner_cookie_t {
unsigned int sequence;
} xcb_get_selection_owner_cookie_t;
/** Opcode for xcb_get_selection_owner. */
#define XCB_GET_SELECTION_OWNER 23
/**
* @brief xcb_get_selection_owner_request_t
**/
typedef struct xcb_get_selection_owner_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_atom_t selection;
} xcb_get_selection_owner_request_t;
/**
* @brief xcb_get_selection_owner_reply_t
**/
typedef struct xcb_get_selection_owner_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
xcb_window_t owner;
} xcb_get_selection_owner_reply_t;
/** Opcode for xcb_convert_selection. */
#define XCB_CONVERT_SELECTION 24
/**
* @brief xcb_convert_selection_request_t
**/
typedef struct xcb_convert_selection_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_window_t requestor;
xcb_atom_t selection;
xcb_atom_t target;
xcb_atom_t property;
xcb_timestamp_t time;
} xcb_convert_selection_request_t;
typedef enum xcb_send_event_dest_t {
XCB_SEND_EVENT_DEST_POINTER_WINDOW = 0,
XCB_SEND_EVENT_DEST_ITEM_FOCUS = 1
} xcb_send_event_dest_t;
/** Opcode for xcb_send_event. */
#define XCB_SEND_EVENT 25
/**
* @brief xcb_send_event_request_t
**/
typedef struct xcb_send_event_request_t {
uint8_t major_opcode;
uint8_t propagate;
uint16_t length;
xcb_window_t destination;
uint32_t event_mask;
char event[32];
} xcb_send_event_request_t;
typedef enum xcb_grab_mode_t {
XCB_GRAB_MODE_SYNC = 0,
/**< The state of the keyboard appears to freeze: No further keyboard events are
generated by the server until the grabbing client issues a releasing
`AllowEvents` request or until the keyboard grab is released. */
XCB_GRAB_MODE_ASYNC = 1
/**< Keyboard event processing continues normally. */
} xcb_grab_mode_t;
typedef enum xcb_grab_status_t {
XCB_GRAB_STATUS_SUCCESS = 0,
XCB_GRAB_STATUS_ALREADY_GRABBED = 1,
XCB_GRAB_STATUS_INVALID_TIME = 2,
XCB_GRAB_STATUS_NOT_VIEWABLE = 3,
XCB_GRAB_STATUS_FROZEN = 4
} xcb_grab_status_t;
typedef enum xcb_cursor_enum_t {
XCB_CURSOR_NONE = 0
} xcb_cursor_enum_t;
/**
* @brief xcb_grab_pointer_cookie_t
**/
typedef struct xcb_grab_pointer_cookie_t {
unsigned int sequence;
} xcb_grab_pointer_cookie_t;
/** Opcode for xcb_grab_pointer. */
#define XCB_GRAB_POINTER 26
/**
* @brief xcb_grab_pointer_request_t
**/
typedef struct xcb_grab_pointer_request_t {
uint8_t major_opcode;
uint8_t owner_events;
uint16_t length;
xcb_window_t grab_window;
uint16_t event_mask;
uint8_t pointer_mode;
uint8_t keyboard_mode;
xcb_window_t confine_to;
xcb_cursor_t cursor;
xcb_timestamp_t time;
} xcb_grab_pointer_request_t;
/**
* @brief xcb_grab_pointer_reply_t
**/
typedef struct xcb_grab_pointer_reply_t {
uint8_t response_type;
uint8_t status;
uint16_t sequence;
uint32_t length;
} xcb_grab_pointer_reply_t;
/** Opcode for xcb_ungrab_pointer. */
#define XCB_UNGRAB_POINTER 27
/**
* @brief xcb_ungrab_pointer_request_t
**/
typedef struct xcb_ungrab_pointer_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_timestamp_t time;
} xcb_ungrab_pointer_request_t;
typedef enum xcb_button_index_t {
XCB_BUTTON_INDEX_ANY = 0,
/**< Any of the following (or none): */
XCB_BUTTON_INDEX_1 = 1,
/**< The left mouse button. */
XCB_BUTTON_INDEX_2 = 2,
/**< The right mouse button. */
XCB_BUTTON_INDEX_3 = 3,
/**< The middle mouse button. */
XCB_BUTTON_INDEX_4 = 4,
/**< Scroll wheel. TODO: direction? */
XCB_BUTTON_INDEX_5 = 5
/**< Scroll wheel. TODO: direction? */
} xcb_button_index_t;
/** Opcode for xcb_grab_button. */
#define XCB_GRAB_BUTTON 28
/**
* @brief xcb_grab_button_request_t
**/
typedef struct xcb_grab_button_request_t {
uint8_t major_opcode;
uint8_t owner_events;
uint16_t length;
xcb_window_t grab_window;
uint16_t event_mask;
uint8_t pointer_mode;
uint8_t keyboard_mode;
xcb_window_t confine_to;
xcb_cursor_t cursor;
uint8_t button;
uint8_t pad0;
uint16_t modifiers;
} xcb_grab_button_request_t;
/** Opcode for xcb_ungrab_button. */
#define XCB_UNGRAB_BUTTON 29
/**
* @brief xcb_ungrab_button_request_t
**/
typedef struct xcb_ungrab_button_request_t {
uint8_t major_opcode;
uint8_t button;
uint16_t length;
xcb_window_t grab_window;
uint16_t modifiers;
uint8_t pad0[2];
} xcb_ungrab_button_request_t;
/** Opcode for xcb_change_active_pointer_grab. */
#define XCB_CHANGE_ACTIVE_POINTER_GRAB 30
/**
* @brief xcb_change_active_pointer_grab_request_t
**/
typedef struct xcb_change_active_pointer_grab_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_cursor_t cursor;
xcb_timestamp_t time;
uint16_t event_mask;
uint8_t pad1[2];
} xcb_change_active_pointer_grab_request_t;
/**
* @brief xcb_grab_keyboard_cookie_t
**/
typedef struct xcb_grab_keyboard_cookie_t {
unsigned int sequence;
} xcb_grab_keyboard_cookie_t;
/** Opcode for xcb_grab_keyboard. */
#define XCB_GRAB_KEYBOARD 31
/**
* @brief xcb_grab_keyboard_request_t
**/
typedef struct xcb_grab_keyboard_request_t {
uint8_t major_opcode;
uint8_t owner_events;
uint16_t length;
xcb_window_t grab_window;
xcb_timestamp_t time;
uint8_t pointer_mode;
uint8_t keyboard_mode;
uint8_t pad0[2];
} xcb_grab_keyboard_request_t;
/**
* @brief xcb_grab_keyboard_reply_t
**/
typedef struct xcb_grab_keyboard_reply_t {
uint8_t response_type;
uint8_t status;
uint16_t sequence;
uint32_t length;
} xcb_grab_keyboard_reply_t;
/** Opcode for xcb_ungrab_keyboard. */
#define XCB_UNGRAB_KEYBOARD 32
/**
* @brief xcb_ungrab_keyboard_request_t
**/
typedef struct xcb_ungrab_keyboard_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_timestamp_t time;
} xcb_ungrab_keyboard_request_t;
typedef enum xcb_grab_t {
XCB_GRAB_ANY = 0
} xcb_grab_t;
/** Opcode for xcb_grab_key. */
#define XCB_GRAB_KEY 33
/**
* @brief xcb_grab_key_request_t
**/
typedef struct xcb_grab_key_request_t {
uint8_t major_opcode;
uint8_t owner_events;
uint16_t length;
xcb_window_t grab_window;
uint16_t modifiers;
xcb_keycode_t key;
uint8_t pointer_mode;
uint8_t keyboard_mode;
uint8_t pad0[3];
} xcb_grab_key_request_t;
/** Opcode for xcb_ungrab_key. */
#define XCB_UNGRAB_KEY 34
/**
* @brief xcb_ungrab_key_request_t
**/
typedef struct xcb_ungrab_key_request_t {
uint8_t major_opcode;
xcb_keycode_t key;
uint16_t length;
xcb_window_t grab_window;
uint16_t modifiers;
uint8_t pad0[2];
} xcb_ungrab_key_request_t;
typedef enum xcb_allow_t {
XCB_ALLOW_ASYNC_POINTER = 0,
/**< For AsyncPointer, if the pointer is frozen by the client, pointer event
processing continues normally. If the pointer is frozen twice by the client on
behalf of two separate grabs, AsyncPointer thaws for both. AsyncPointer has no
effect if the pointer is not frozen by the client, but the pointer need not be
grabbed by the client.
TODO: rewrite this in more understandable terms. */
XCB_ALLOW_SYNC_POINTER = 1,
/**< For SyncPointer, if the pointer is frozen and actively grabbed by the client,
pointer event processing continues normally until the next ButtonPress or
ButtonRelease event is reported to the client, at which time the pointer again
appears to freeze. However, if the reported event causes the pointer grab to be
released, then the pointer does not freeze. SyncPointer has no effect if the
pointer is not frozen by the client or if the pointer is not grabbed by the
client. */
XCB_ALLOW_REPLAY_POINTER = 2,
/**< For ReplayPointer, if the pointer is actively grabbed by the client and is
frozen as the result of an event having been sent to the client (either from
the activation of a GrabButton or from a previous AllowEvents with mode
SyncPointer but not from a GrabPointer), then the pointer grab is released and
that event is completely reprocessed, this time ignoring any passive grabs at
or above (towards the root) the grab-window of the grab just released. The
request has no effect if the pointer is not grabbed by the client or if the
pointer is not frozen as the result of an event. */
XCB_ALLOW_ASYNC_KEYBOARD = 3,
/**< For AsyncKeyboard, if the keyboard is frozen by the client, keyboard event
processing continues normally. If the keyboard is frozen twice by the client on
behalf of two separate grabs, AsyncKeyboard thaws for both. AsyncKeyboard has
no effect if the keyboard is not frozen by the client, but the keyboard need
not be grabbed by the client. */
XCB_ALLOW_SYNC_KEYBOARD = 4,
/**< For SyncKeyboard, if the keyboard is frozen and actively grabbed by the client,
keyboard event processing continues normally until the next KeyPress or
KeyRelease event is reported to the client, at which time the keyboard again
appears to freeze. However, if the reported event causes the keyboard grab to
be released, then the keyboard does not freeze. SyncKeyboard has no effect if
the keyboard is not frozen by the client or if the keyboard is not grabbed by
the client. */
XCB_ALLOW_REPLAY_KEYBOARD = 5,
/**< For ReplayKeyboard, if the keyboard is actively grabbed by the client and is
frozen as the result of an event having been sent to the client (either from
the activation of a GrabKey or from a previous AllowEvents with mode
SyncKeyboard but not from a GrabKeyboard), then the keyboard grab is released
and that event is completely reprocessed, this time ignoring any passive grabs
at or above (towards the root) the grab-window of the grab just released. The
request has no effect if the keyboard is not grabbed by the client or if the
keyboard is not frozen as the result of an event. */
XCB_ALLOW_ASYNC_BOTH = 6,
/**< For AsyncBoth, if the pointer and the keyboard are frozen by the client, event
processing for both devices continues normally. If a device is frozen twice by
the client on behalf of two separate grabs, AsyncBoth thaws for both. AsyncBoth
has no effect unless both pointer and keyboard are frozen by the client. */
XCB_ALLOW_SYNC_BOTH = 7
/**< For SyncBoth, if both pointer and keyboard are frozen by the client, event
processing (for both devices) continues normally until the next ButtonPress,
ButtonRelease, KeyPress, or KeyRelease event is reported to the client for a
grabbed device (button event for the pointer, key event for the keyboard), at
which time the devices again appear to freeze. However, if the reported event
causes the grab to be released, then the devices do not freeze (but if the
other device is still grabbed, then a subsequent event for it will still cause
both devices to freeze). SyncBoth has no effect unless both pointer and
keyboard are frozen by the client. If the pointer or keyboard is frozen twice
by the client on behalf of two separate grabs, SyncBoth thaws for both (but a
subsequent freeze for SyncBoth will only freeze each device once). */
} xcb_allow_t;
/** Opcode for xcb_allow_events. */
#define XCB_ALLOW_EVENTS 35
/**
* @brief xcb_allow_events_request_t
**/
typedef struct xcb_allow_events_request_t {
uint8_t major_opcode;
uint8_t mode;
uint16_t length;
xcb_timestamp_t time;
} xcb_allow_events_request_t;
/** Opcode for xcb_grab_server. */
#define XCB_GRAB_SERVER 36
/**
* @brief xcb_grab_server_request_t
**/
typedef struct xcb_grab_server_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
} xcb_grab_server_request_t;
/** Opcode for xcb_ungrab_server. */
#define XCB_UNGRAB_SERVER 37
/**
* @brief xcb_ungrab_server_request_t
**/
typedef struct xcb_ungrab_server_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
} xcb_ungrab_server_request_t;
/**
* @brief xcb_query_pointer_cookie_t
**/
typedef struct xcb_query_pointer_cookie_t {
unsigned int sequence;
} xcb_query_pointer_cookie_t;
/** Opcode for xcb_query_pointer. */
#define XCB_QUERY_POINTER 38
/**
* @brief xcb_query_pointer_request_t
**/
typedef struct xcb_query_pointer_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_window_t window;
} xcb_query_pointer_request_t;
/**
* @brief xcb_query_pointer_reply_t
**/
typedef struct xcb_query_pointer_reply_t {
uint8_t response_type;
uint8_t same_screen;
uint16_t sequence;
uint32_t length;
xcb_window_t root;
xcb_window_t child;
int16_t root_x;
int16_t root_y;
int16_t win_x;
int16_t win_y;
uint16_t mask;
uint8_t pad0[2];
} xcb_query_pointer_reply_t;
/**
* @brief xcb_timecoord_t
**/
typedef struct xcb_timecoord_t {
xcb_timestamp_t time;
int16_t x;
int16_t y;
} xcb_timecoord_t;
/**
* @brief xcb_timecoord_iterator_t
**/
typedef struct xcb_timecoord_iterator_t {
xcb_timecoord_t *data;
int rem;
int index;
} xcb_timecoord_iterator_t;
/**
* @brief xcb_get_motion_events_cookie_t
**/
typedef struct xcb_get_motion_events_cookie_t {
unsigned int sequence;
} xcb_get_motion_events_cookie_t;
/** Opcode for xcb_get_motion_events. */
#define XCB_GET_MOTION_EVENTS 39
/**
* @brief xcb_get_motion_events_request_t
**/
typedef struct xcb_get_motion_events_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_window_t window;
xcb_timestamp_t start;
xcb_timestamp_t stop;
} xcb_get_motion_events_request_t;
/**
* @brief xcb_get_motion_events_reply_t
**/
typedef struct xcb_get_motion_events_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t events_len;
uint8_t pad1[20];
} xcb_get_motion_events_reply_t;
/**
* @brief xcb_translate_coordinates_cookie_t
**/
typedef struct xcb_translate_coordinates_cookie_t {
unsigned int sequence;
} xcb_translate_coordinates_cookie_t;
/** Opcode for xcb_translate_coordinates. */
#define XCB_TRANSLATE_COORDINATES 40
/**
* @brief xcb_translate_coordinates_request_t
**/
typedef struct xcb_translate_coordinates_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_window_t src_window;
xcb_window_t dst_window;
int16_t src_x;
int16_t src_y;
} xcb_translate_coordinates_request_t;
/**
* @brief xcb_translate_coordinates_reply_t
**/
typedef struct xcb_translate_coordinates_reply_t {
uint8_t response_type;
uint8_t same_screen;
uint16_t sequence;
uint32_t length;
xcb_window_t child;
int16_t dst_x;
int16_t dst_y;
} xcb_translate_coordinates_reply_t;
/** Opcode for xcb_warp_pointer. */
#define XCB_WARP_POINTER 41
/**
* @brief xcb_warp_pointer_request_t
**/
typedef struct xcb_warp_pointer_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_window_t src_window;
xcb_window_t dst_window;
int16_t src_x;
int16_t src_y;
uint16_t src_width;
uint16_t src_height;
int16_t dst_x;
int16_t dst_y;
} xcb_warp_pointer_request_t;
typedef enum xcb_input_focus_t {
XCB_INPUT_FOCUS_NONE = 0,
/**< The focus reverts to `XCB_NONE`, so no window will have the input focus. */
XCB_INPUT_FOCUS_POINTER_ROOT = 1,
/**< The focus reverts to `XCB_POINTER_ROOT` respectively. When the focus reverts,
FocusIn and FocusOut events are generated, but the last-focus-change time is
not changed. */
XCB_INPUT_FOCUS_PARENT = 2,
/**< The focus reverts to the parent (or closest viewable ancestor) and the new
revert_to value is `XCB_INPUT_FOCUS_NONE`. */
XCB_INPUT_FOCUS_FOLLOW_KEYBOARD = 3
/**< NOT YET DOCUMENTED. Only relevant for the xinput extension. */
} xcb_input_focus_t;
/** Opcode for xcb_set_input_focus. */
#define XCB_SET_INPUT_FOCUS 42
/**
* @brief xcb_set_input_focus_request_t
**/
typedef struct xcb_set_input_focus_request_t {
uint8_t major_opcode;
uint8_t revert_to;
uint16_t length;
xcb_window_t focus;
xcb_timestamp_t time;
} xcb_set_input_focus_request_t;
/**
* @brief xcb_get_input_focus_cookie_t
**/
typedef struct xcb_get_input_focus_cookie_t {
unsigned int sequence;
} xcb_get_input_focus_cookie_t;
/** Opcode for xcb_get_input_focus. */
#define XCB_GET_INPUT_FOCUS 43
/**
* @brief xcb_get_input_focus_request_t
**/
typedef struct xcb_get_input_focus_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
} xcb_get_input_focus_request_t;
/**
* @brief xcb_get_input_focus_reply_t
**/
typedef struct xcb_get_input_focus_reply_t {
uint8_t response_type;
uint8_t revert_to;
uint16_t sequence;
uint32_t length;
xcb_window_t focus;
} xcb_get_input_focus_reply_t;
/**
* @brief xcb_query_keymap_cookie_t
**/
typedef struct xcb_query_keymap_cookie_t {
unsigned int sequence;
} xcb_query_keymap_cookie_t;
/** Opcode for xcb_query_keymap. */
#define XCB_QUERY_KEYMAP 44
/**
* @brief xcb_query_keymap_request_t
**/
typedef struct xcb_query_keymap_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
} xcb_query_keymap_request_t;
/**
* @brief xcb_query_keymap_reply_t
**/
typedef struct xcb_query_keymap_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t keys[32];
} xcb_query_keymap_reply_t;
/** Opcode for xcb_open_font. */
#define XCB_OPEN_FONT 45
/**
* @brief xcb_open_font_request_t
**/
typedef struct xcb_open_font_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_font_t fid;
uint16_t name_len;
uint8_t pad1[2];
} xcb_open_font_request_t;
/** Opcode for xcb_close_font. */
#define XCB_CLOSE_FONT 46
/**
* @brief xcb_close_font_request_t
**/
typedef struct xcb_close_font_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_font_t font;
} xcb_close_font_request_t;
typedef enum xcb_font_draw_t {
XCB_FONT_DRAW_LEFT_TO_RIGHT = 0,
XCB_FONT_DRAW_RIGHT_TO_LEFT = 1
} xcb_font_draw_t;
/**
* @brief xcb_fontprop_t
**/
typedef struct xcb_fontprop_t {
xcb_atom_t name;
uint32_t value;
} xcb_fontprop_t;
/**
* @brief xcb_fontprop_iterator_t
**/
typedef struct xcb_fontprop_iterator_t {
xcb_fontprop_t *data;
int rem;
int index;
} xcb_fontprop_iterator_t;
/**
* @brief xcb_charinfo_t
**/
typedef struct xcb_charinfo_t {
int16_t left_side_bearing;
int16_t right_side_bearing;
int16_t character_width;
int16_t ascent;
int16_t descent;
uint16_t attributes;
} xcb_charinfo_t;
/**
* @brief xcb_charinfo_iterator_t
**/
typedef struct xcb_charinfo_iterator_t {
xcb_charinfo_t *data;
int rem;
int index;
} xcb_charinfo_iterator_t;
/**
* @brief xcb_query_font_cookie_t
**/
typedef struct xcb_query_font_cookie_t {
unsigned int sequence;
} xcb_query_font_cookie_t;
/** Opcode for xcb_query_font. */
#define XCB_QUERY_FONT 47
/**
* @brief xcb_query_font_request_t
**/
typedef struct xcb_query_font_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_fontable_t font;
} xcb_query_font_request_t;
/**
* @brief xcb_query_font_reply_t
**/
typedef struct xcb_query_font_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
xcb_charinfo_t min_bounds;
uint8_t pad1[4];
xcb_charinfo_t max_bounds;
uint8_t pad2[4];
uint16_t min_char_or_byte2;
uint16_t max_char_or_byte2;
uint16_t default_char;
uint16_t properties_len;
uint8_t draw_direction;
uint8_t min_byte1;
uint8_t max_byte1;
uint8_t all_chars_exist;
int16_t font_ascent;
int16_t font_descent;
uint32_t char_infos_len;
} xcb_query_font_reply_t;
/**
* @brief xcb_query_text_extents_cookie_t
**/
typedef struct xcb_query_text_extents_cookie_t {
unsigned int sequence;
} xcb_query_text_extents_cookie_t;
/** Opcode for xcb_query_text_extents. */
#define XCB_QUERY_TEXT_EXTENTS 48
/**
* @brief xcb_query_text_extents_request_t
**/
typedef struct xcb_query_text_extents_request_t {
uint8_t major_opcode;
uint8_t odd_length;
uint16_t length;
xcb_fontable_t font;
} xcb_query_text_extents_request_t;
/**
* @brief xcb_query_text_extents_reply_t
**/
typedef struct xcb_query_text_extents_reply_t {
uint8_t response_type;
uint8_t draw_direction;
uint16_t sequence;
uint32_t length;
int16_t font_ascent;
int16_t font_descent;
int16_t overall_ascent;
int16_t overall_descent;
int32_t overall_width;
int32_t overall_left;
int32_t overall_right;
} xcb_query_text_extents_reply_t;
/**
* @brief xcb_str_t
**/
typedef struct xcb_str_t {
uint8_t name_len;
} xcb_str_t;
/**
* @brief xcb_str_iterator_t
**/
typedef struct xcb_str_iterator_t {
xcb_str_t *data;
int rem;
int index;
} xcb_str_iterator_t;
/**
* @brief xcb_list_fonts_cookie_t
**/
typedef struct xcb_list_fonts_cookie_t {
unsigned int sequence;
} xcb_list_fonts_cookie_t;
/** Opcode for xcb_list_fonts. */
#define XCB_LIST_FONTS 49
/**
* @brief xcb_list_fonts_request_t
**/
typedef struct xcb_list_fonts_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
uint16_t max_names;
uint16_t pattern_len;
} xcb_list_fonts_request_t;
/**
* @brief xcb_list_fonts_reply_t
**/
typedef struct xcb_list_fonts_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t names_len;
uint8_t pad1[22];
} xcb_list_fonts_reply_t;
/**
* @brief xcb_list_fonts_with_info_cookie_t
**/
typedef struct xcb_list_fonts_with_info_cookie_t {
unsigned int sequence;
} xcb_list_fonts_with_info_cookie_t;
/** Opcode for xcb_list_fonts_with_info. */
#define XCB_LIST_FONTS_WITH_INFO 50
/**
* @brief xcb_list_fonts_with_info_request_t
**/
typedef struct xcb_list_fonts_with_info_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
uint16_t max_names;
uint16_t pattern_len;
} xcb_list_fonts_with_info_request_t;
/**
* @brief xcb_list_fonts_with_info_reply_t
**/
typedef struct xcb_list_fonts_with_info_reply_t {
uint8_t response_type;
uint8_t name_len;
uint16_t sequence;
uint32_t length;
xcb_charinfo_t min_bounds;
uint8_t pad0[4];
xcb_charinfo_t max_bounds;
uint8_t pad1[4];
uint16_t min_char_or_byte2;
uint16_t max_char_or_byte2;
uint16_t default_char;
uint16_t properties_len;
uint8_t draw_direction;
uint8_t min_byte1;
uint8_t max_byte1;
uint8_t all_chars_exist;
int16_t font_ascent;
int16_t font_descent;
uint32_t replies_hint;
} xcb_list_fonts_with_info_reply_t;
/** Opcode for xcb_set_font_path. */
#define XCB_SET_FONT_PATH 51
/**
* @brief xcb_set_font_path_request_t
**/
typedef struct xcb_set_font_path_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
uint16_t font_qty;
uint8_t pad1[2];
} xcb_set_font_path_request_t;
/**
* @brief xcb_get_font_path_cookie_t
**/
typedef struct xcb_get_font_path_cookie_t {
unsigned int sequence;
} xcb_get_font_path_cookie_t;
/** Opcode for xcb_get_font_path. */
#define XCB_GET_FONT_PATH 52
/**
* @brief xcb_get_font_path_request_t
**/
typedef struct xcb_get_font_path_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
} xcb_get_font_path_request_t;
/**
* @brief xcb_get_font_path_reply_t
**/
typedef struct xcb_get_font_path_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t path_len;
uint8_t pad1[22];
} xcb_get_font_path_reply_t;
/** Opcode for xcb_create_pixmap. */
#define XCB_CREATE_PIXMAP 53
/**
* @brief xcb_create_pixmap_request_t
**/
typedef struct xcb_create_pixmap_request_t {
uint8_t major_opcode;
uint8_t depth;
uint16_t length;
xcb_pixmap_t pid;
xcb_drawable_t drawable;
uint16_t width;
uint16_t height;
} xcb_create_pixmap_request_t;
/** Opcode for xcb_free_pixmap. */
#define XCB_FREE_PIXMAP 54
/**
* @brief xcb_free_pixmap_request_t
**/
typedef struct xcb_free_pixmap_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_pixmap_t pixmap;
} xcb_free_pixmap_request_t;
typedef enum xcb_gc_t {
XCB_GC_FUNCTION = 1,
/**< TODO: Refer to GX */
XCB_GC_PLANE_MASK = 2,
/**< In graphics operations, given a source and destination pixel, the result is
computed bitwise on corresponding bits of the pixels; that is, a Boolean
operation is performed in each bit plane. The plane-mask restricts the
operation to a subset of planes, so the result is:
((src FUNC dst) AND plane-mask) OR (dst AND (NOT plane-mask)) */
XCB_GC_FOREGROUND = 4,
/**< Foreground colorpixel. */
XCB_GC_BACKGROUND = 8,
/**< Background colorpixel. */
XCB_GC_LINE_WIDTH = 16,
/**< The line-width is measured in pixels and can be greater than or equal to one, a wide line, or the
special value zero, a thin line. */
XCB_GC_LINE_STYLE = 32,
/**< The line-style defines which sections of a line are drawn:
Solid The full path of the line is drawn.
DoubleDash The full path of the line is drawn, but the even dashes are filled differently
than the odd dashes (see fill-style), with Butt cap-style used where even and
odd dashes meet.
OnOffDash Only the even dashes are drawn, and cap-style applies to all internal ends of
the individual dashes (except NotLast is treated as Butt). */
XCB_GC_CAP_STYLE = 64,
/**< The cap-style defines how the endpoints of a path are drawn:
NotLast The result is equivalent to Butt, except that for a line-width of zero the final
endpoint is not drawn.
Butt The result is square at the endpoint (perpendicular to the slope of the line)
with no projection beyond.
Round The result is a circular arc with its diameter equal to the line-width, centered
on the endpoint; it is equivalent to Butt for line-width zero.
Projecting The result is square at the end, but the path continues beyond the endpoint for
a distance equal to half the line-width; it is equivalent to Butt for line-width
zero. */
XCB_GC_JOIN_STYLE = 128,
/**< The join-style defines how corners are drawn for wide lines:
Miter The outer edges of the two lines extend to meet at an angle. However, if the
angle is less than 11 degrees, a Bevel join-style is used instead.
Round The result is a circular arc with a diameter equal to the line-width, centered
on the joinpoint.
Bevel The result is Butt endpoint styles, and then the triangular notch is filled. */
XCB_GC_FILL_STYLE = 256,
/**< The fill-style defines the contents of the source for line, text, and fill requests. For all text and fill
requests (for example, PolyText8, PolyText16, PolyFillRectangle, FillPoly, and PolyFillArc)
as well as for line requests with line-style Solid, (for example, PolyLine, PolySegment,
PolyRectangle, PolyArc) and for the even dashes for line requests with line-style OnOffDash
or DoubleDash:
Solid Foreground
Tiled Tile
OpaqueStippled A tile with the same width and height as stipple but with background
everywhere stipple has a zero and with foreground everywhere stipple
has a one
Stippled Foreground masked by stipple
For the odd dashes for line requests with line-style DoubleDash:
Solid Background
Tiled Same as for even dashes
OpaqueStippled Same as for even dashes
Stippled Background masked by stipple */
XCB_GC_FILL_RULE = 512,
/**< */
XCB_GC_TILE = 1024,
/**< The tile/stipple represents an infinite two-dimensional plane with the tile/stipple replicated in all
dimensions. When that plane is superimposed on the drawable for use in a graphics operation,
the upper-left corner of some instance of the tile/stipple is at the coordinates within the drawable
specified by the tile/stipple origin. The tile/stipple and clip origins are interpreted relative to the
origin of whatever destination drawable is specified in a graphics request.
The tile pixmap must have the same root and depth as the gcontext (or a Match error results).
The stipple pixmap must have depth one and must have the same root as the gcontext (or a
Match error results). For fill-style Stippled (but not fill-style
OpaqueStippled), the stipple pattern is tiled in a single plane and acts as an
additional clip mask to be ANDed with the clip-mask.
Any size pixmap can be used for tiling or stippling, although some sizes may be faster to use than
others. */
XCB_GC_STIPPLE = 2048,
/**< The tile/stipple represents an infinite two-dimensional plane with the tile/stipple replicated in all
dimensions. When that plane is superimposed on the drawable for use in a graphics operation,
the upper-left corner of some instance of the tile/stipple is at the coordinates within the drawable
specified by the tile/stipple origin. The tile/stipple and clip origins are interpreted relative to the
origin of whatever destination drawable is specified in a graphics request.
The tile pixmap must have the same root and depth as the gcontext (or a Match error results).
The stipple pixmap must have depth one and must have the same root as the gcontext (or a
Match error results). For fill-style Stippled (but not fill-style
OpaqueStippled), the stipple pattern is tiled in a single plane and acts as an
additional clip mask to be ANDed with the clip-mask.
Any size pixmap can be used for tiling or stippling, although some sizes may be faster to use than
others. */
XCB_GC_TILE_STIPPLE_ORIGIN_X = 4096,
/**< TODO */
XCB_GC_TILE_STIPPLE_ORIGIN_Y = 8192,
/**< TODO */
XCB_GC_FONT = 16384,
/**< Which font to use for the `ImageText8` and `ImageText16` requests. */
XCB_GC_SUBWINDOW_MODE = 32768,
/**< For ClipByChildren, both source and destination windows are additionally
clipped by all viewable InputOutput children. For IncludeInferiors, neither
source nor destination window is
clipped by inferiors. This will result in including subwindow contents in the source and drawing
through subwindow boundaries of the destination. The use of IncludeInferiors with a source or
destination window of one depth with mapped inferiors of differing depth is not illegal, but the
semantics is undefined by the core protocol. */
XCB_GC_GRAPHICS_EXPOSURES = 65536,
/**< Whether ExposureEvents should be generated (1) or not (0).
The default is 1. */
XCB_GC_CLIP_ORIGIN_X = 131072,
/**< TODO */
XCB_GC_CLIP_ORIGIN_Y = 262144,
/**< TODO */
XCB_GC_CLIP_MASK = 524288,
/**< The clip-mask restricts writes to the destination drawable. Only pixels where the clip-mask has
bits set to 1 are drawn. Pixels are not drawn outside the area covered by the clip-mask or where
the clip-mask has bits set to 0. The clip-mask affects all graphics requests, but it does not clip
sources. The clip-mask origin is interpreted relative to the origin of whatever destination drawable is specified in a graphics request. If a pixmap is specified as the clip-mask, it must have
depth 1 and have the same root as the gcontext (or a Match error results). If clip-mask is None,
then pixels are always drawn, regardless of the clip origin. The clip-mask can also be set with the
SetClipRectangles request. */
XCB_GC_DASH_OFFSET = 1048576,
/**< TODO */
XCB_GC_DASH_LIST = 2097152,
/**< TODO */
XCB_GC_ARC_MODE = 4194304
/**< TODO */
} xcb_gc_t;
typedef enum xcb_gx_t {
XCB_GX_CLEAR = 0,
XCB_GX_AND = 1,
XCB_GX_AND_REVERSE = 2,
XCB_GX_COPY = 3,
XCB_GX_AND_INVERTED = 4,
XCB_GX_NOOP = 5,
XCB_GX_XOR = 6,
XCB_GX_OR = 7,
XCB_GX_NOR = 8,
XCB_GX_EQUIV = 9,
XCB_GX_INVERT = 10,
XCB_GX_OR_REVERSE = 11,
XCB_GX_COPY_INVERTED = 12,
XCB_GX_OR_INVERTED = 13,
XCB_GX_NAND = 14,
XCB_GX_SET = 15
} xcb_gx_t;
typedef enum xcb_line_style_t {
XCB_LINE_STYLE_SOLID = 0,
XCB_LINE_STYLE_ON_OFF_DASH = 1,
XCB_LINE_STYLE_DOUBLE_DASH = 2
} xcb_line_style_t;
typedef enum xcb_cap_style_t {
XCB_CAP_STYLE_NOT_LAST = 0,
XCB_CAP_STYLE_BUTT = 1,
XCB_CAP_STYLE_ROUND = 2,
XCB_CAP_STYLE_PROJECTING = 3
} xcb_cap_style_t;
typedef enum xcb_join_style_t {
XCB_JOIN_STYLE_MITER = 0,
XCB_JOIN_STYLE_ROUND = 1,
XCB_JOIN_STYLE_BEVEL = 2
} xcb_join_style_t;
typedef enum xcb_fill_style_t {
XCB_FILL_STYLE_SOLID = 0,
XCB_FILL_STYLE_TILED = 1,
XCB_FILL_STYLE_STIPPLED = 2,
XCB_FILL_STYLE_OPAQUE_STIPPLED = 3
} xcb_fill_style_t;
typedef enum xcb_fill_rule_t {
XCB_FILL_RULE_EVEN_ODD = 0,
XCB_FILL_RULE_WINDING = 1
} xcb_fill_rule_t;
typedef enum xcb_subwindow_mode_t {
XCB_SUBWINDOW_MODE_CLIP_BY_CHILDREN = 0,
XCB_SUBWINDOW_MODE_INCLUDE_INFERIORS = 1
} xcb_subwindow_mode_t;
typedef enum xcb_arc_mode_t {
XCB_ARC_MODE_CHORD = 0,
XCB_ARC_MODE_PIE_SLICE = 1
} xcb_arc_mode_t;
/**
* @brief xcb_create_gc_value_list_t
**/
typedef struct xcb_create_gc_value_list_t {
uint32_t function;
uint32_t plane_mask;
uint32_t foreground;
uint32_t background;
uint32_t line_width;
uint32_t line_style;
uint32_t cap_style;
uint32_t join_style;
uint32_t fill_style;
uint32_t fill_rule;
xcb_pixmap_t tile;
xcb_pixmap_t stipple;
int32_t tile_stipple_x_origin;
int32_t tile_stipple_y_origin;
xcb_font_t font;
uint32_t subwindow_mode;
xcb_bool32_t graphics_exposures;
int32_t clip_x_origin;
int32_t clip_y_origin;
xcb_pixmap_t clip_mask;
uint32_t dash_offset;
uint32_t dashes;
uint32_t arc_mode;
} xcb_create_gc_value_list_t;
/** Opcode for xcb_create_gc. */
#define XCB_CREATE_GC 55
/**
* @brief xcb_create_gc_request_t
**/
typedef struct xcb_create_gc_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_gcontext_t cid;
xcb_drawable_t drawable;
uint32_t value_mask;
} xcb_create_gc_request_t;
/**
* @brief xcb_change_gc_value_list_t
**/
typedef struct xcb_change_gc_value_list_t {
uint32_t function;
uint32_t plane_mask;
uint32_t foreground;
uint32_t background;
uint32_t line_width;
uint32_t line_style;
uint32_t cap_style;
uint32_t join_style;
uint32_t fill_style;
uint32_t fill_rule;
xcb_pixmap_t tile;
xcb_pixmap_t stipple;
int32_t tile_stipple_x_origin;
int32_t tile_stipple_y_origin;
xcb_font_t font;
uint32_t subwindow_mode;
xcb_bool32_t graphics_exposures;
int32_t clip_x_origin;
int32_t clip_y_origin;
xcb_pixmap_t clip_mask;
uint32_t dash_offset;
uint32_t dashes;
uint32_t arc_mode;
} xcb_change_gc_value_list_t;
/** Opcode for xcb_change_gc. */
#define XCB_CHANGE_GC 56
/**
* @brief xcb_change_gc_request_t
**/
typedef struct xcb_change_gc_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_gcontext_t gc;
uint32_t value_mask;
} xcb_change_gc_request_t;
/** Opcode for xcb_copy_gc. */
#define XCB_COPY_GC 57
/**
* @brief xcb_copy_gc_request_t
**/
typedef struct xcb_copy_gc_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_gcontext_t src_gc;
xcb_gcontext_t dst_gc;
uint32_t value_mask;
} xcb_copy_gc_request_t;
/** Opcode for xcb_set_dashes. */
#define XCB_SET_DASHES 58
/**
* @brief xcb_set_dashes_request_t
**/
typedef struct xcb_set_dashes_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_gcontext_t gc;
uint16_t dash_offset;
uint16_t dashes_len;
} xcb_set_dashes_request_t;
typedef enum xcb_clip_ordering_t {
XCB_CLIP_ORDERING_UNSORTED = 0,
XCB_CLIP_ORDERING_Y_SORTED = 1,
XCB_CLIP_ORDERING_YX_SORTED = 2,
XCB_CLIP_ORDERING_YX_BANDED = 3
} xcb_clip_ordering_t;
/** Opcode for xcb_set_clip_rectangles. */
#define XCB_SET_CLIP_RECTANGLES 59
/**
* @brief xcb_set_clip_rectangles_request_t
**/
typedef struct xcb_set_clip_rectangles_request_t {
uint8_t major_opcode;
uint8_t ordering;
uint16_t length;
xcb_gcontext_t gc;
int16_t clip_x_origin;
int16_t clip_y_origin;
} xcb_set_clip_rectangles_request_t;
/** Opcode for xcb_free_gc. */
#define XCB_FREE_GC 60
/**
* @brief xcb_free_gc_request_t
**/
typedef struct xcb_free_gc_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_gcontext_t gc;
} xcb_free_gc_request_t;
/** Opcode for xcb_clear_area. */
#define XCB_CLEAR_AREA 61
/**
* @brief xcb_clear_area_request_t
**/
typedef struct xcb_clear_area_request_t {
uint8_t major_opcode;
uint8_t exposures;
uint16_t length;
xcb_window_t window;
int16_t x;
int16_t y;
uint16_t width;
uint16_t height;
} xcb_clear_area_request_t;
/** Opcode for xcb_copy_area. */
#define XCB_COPY_AREA 62
/**
* @brief xcb_copy_area_request_t
**/
typedef struct xcb_copy_area_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_drawable_t src_drawable;
xcb_drawable_t dst_drawable;
xcb_gcontext_t gc;
int16_t src_x;
int16_t src_y;
int16_t dst_x;
int16_t dst_y;
uint16_t width;
uint16_t height;
} xcb_copy_area_request_t;
/** Opcode for xcb_copy_plane. */
#define XCB_COPY_PLANE 63
/**
* @brief xcb_copy_plane_request_t
**/
typedef struct xcb_copy_plane_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_drawable_t src_drawable;
xcb_drawable_t dst_drawable;
xcb_gcontext_t gc;
int16_t src_x;
int16_t src_y;
int16_t dst_x;
int16_t dst_y;
uint16_t width;
uint16_t height;
uint32_t bit_plane;
} xcb_copy_plane_request_t;
typedef enum xcb_coord_mode_t {
XCB_COORD_MODE_ORIGIN = 0,
/**< Treats all coordinates as relative to the origin. */
XCB_COORD_MODE_PREVIOUS = 1
/**< Treats all coordinates after the first as relative to the previous coordinate. */
} xcb_coord_mode_t;
/** Opcode for xcb_poly_point. */
#define XCB_POLY_POINT 64
/**
* @brief xcb_poly_point_request_t
**/
typedef struct xcb_poly_point_request_t {
uint8_t major_opcode;
uint8_t coordinate_mode;
uint16_t length;
xcb_drawable_t drawable;
xcb_gcontext_t gc;
} xcb_poly_point_request_t;
/** Opcode for xcb_poly_line. */
#define XCB_POLY_LINE 65
/**
* @brief xcb_poly_line_request_t
**/
typedef struct xcb_poly_line_request_t {
uint8_t major_opcode;
uint8_t coordinate_mode;
uint16_t length;
xcb_drawable_t drawable;
xcb_gcontext_t gc;
} xcb_poly_line_request_t;
/**
* @brief xcb_segment_t
**/
typedef struct xcb_segment_t {
int16_t x1;
int16_t y1;
int16_t x2;
int16_t y2;
} xcb_segment_t;
/**
* @brief xcb_segment_iterator_t
**/
typedef struct xcb_segment_iterator_t {
xcb_segment_t *data;
int rem;
int index;
} xcb_segment_iterator_t;
/** Opcode for xcb_poly_segment. */
#define XCB_POLY_SEGMENT 66
/**
* @brief xcb_poly_segment_request_t
**/
typedef struct xcb_poly_segment_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_drawable_t drawable;
xcb_gcontext_t gc;
} xcb_poly_segment_request_t;
/** Opcode for xcb_poly_rectangle. */
#define XCB_POLY_RECTANGLE 67
/**
* @brief xcb_poly_rectangle_request_t
**/
typedef struct xcb_poly_rectangle_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_drawable_t drawable;
xcb_gcontext_t gc;
} xcb_poly_rectangle_request_t;
/** Opcode for xcb_poly_arc. */
#define XCB_POLY_ARC 68
/**
* @brief xcb_poly_arc_request_t
**/
typedef struct xcb_poly_arc_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_drawable_t drawable;
xcb_gcontext_t gc;
} xcb_poly_arc_request_t;
typedef enum xcb_poly_shape_t {
XCB_POLY_SHAPE_COMPLEX = 0,
XCB_POLY_SHAPE_NONCONVEX = 1,
XCB_POLY_SHAPE_CONVEX = 2
} xcb_poly_shape_t;
/** Opcode for xcb_fill_poly. */
#define XCB_FILL_POLY 69
/**
* @brief xcb_fill_poly_request_t
**/
typedef struct xcb_fill_poly_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_drawable_t drawable;
xcb_gcontext_t gc;
uint8_t shape;
uint8_t coordinate_mode;
uint8_t pad1[2];
} xcb_fill_poly_request_t;
/** Opcode for xcb_poly_fill_rectangle. */
#define XCB_POLY_FILL_RECTANGLE 70
/**
* @brief xcb_poly_fill_rectangle_request_t
**/
typedef struct xcb_poly_fill_rectangle_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_drawable_t drawable;
xcb_gcontext_t gc;
} xcb_poly_fill_rectangle_request_t;
/** Opcode for xcb_poly_fill_arc. */
#define XCB_POLY_FILL_ARC 71
/**
* @brief xcb_poly_fill_arc_request_t
**/
typedef struct xcb_poly_fill_arc_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_drawable_t drawable;
xcb_gcontext_t gc;
} xcb_poly_fill_arc_request_t;
typedef enum xcb_image_format_t {
XCB_IMAGE_FORMAT_XY_BITMAP = 0,
XCB_IMAGE_FORMAT_XY_PIXMAP = 1,
XCB_IMAGE_FORMAT_Z_PIXMAP = 2
} xcb_image_format_t;
/** Opcode for xcb_put_image. */
#define XCB_PUT_IMAGE 72
/**
* @brief xcb_put_image_request_t
**/
typedef struct xcb_put_image_request_t {
uint8_t major_opcode;
uint8_t format;
uint16_t length;
xcb_drawable_t drawable;
xcb_gcontext_t gc;
uint16_t width;
uint16_t height;
int16_t dst_x;
int16_t dst_y;
uint8_t left_pad;
uint8_t depth;
uint8_t pad0[2];
} xcb_put_image_request_t;
/**
* @brief xcb_get_image_cookie_t
**/
typedef struct xcb_get_image_cookie_t {
unsigned int sequence;
} xcb_get_image_cookie_t;
/** Opcode for xcb_get_image. */
#define XCB_GET_IMAGE 73
/**
* @brief xcb_get_image_request_t
**/
typedef struct xcb_get_image_request_t {
uint8_t major_opcode;
uint8_t format;
uint16_t length;
xcb_drawable_t drawable;
int16_t x;
int16_t y;
uint16_t width;
uint16_t height;
uint32_t plane_mask;
} xcb_get_image_request_t;
/**
* @brief xcb_get_image_reply_t
**/
typedef struct xcb_get_image_reply_t {
uint8_t response_type;
uint8_t depth;
uint16_t sequence;
uint32_t length;
xcb_visualid_t visual;
uint8_t pad0[20];
} xcb_get_image_reply_t;
/** Opcode for xcb_poly_text_8. */
#define XCB_POLY_TEXT_8 74
/**
* @brief xcb_poly_text_8_request_t
**/
typedef struct xcb_poly_text_8_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_drawable_t drawable;
xcb_gcontext_t gc;
int16_t x;
int16_t y;
} xcb_poly_text_8_request_t;
/** Opcode for xcb_poly_text_16. */
#define XCB_POLY_TEXT_16 75
/**
* @brief xcb_poly_text_16_request_t
**/
typedef struct xcb_poly_text_16_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_drawable_t drawable;
xcb_gcontext_t gc;
int16_t x;
int16_t y;
} xcb_poly_text_16_request_t;
/** Opcode for xcb_image_text_8. */
#define XCB_IMAGE_TEXT_8 76
/**
* @brief xcb_image_text_8_request_t
**/
typedef struct xcb_image_text_8_request_t {
uint8_t major_opcode;
uint8_t string_len;
uint16_t length;
xcb_drawable_t drawable;
xcb_gcontext_t gc;
int16_t x;
int16_t y;
} xcb_image_text_8_request_t;
/** Opcode for xcb_image_text_16. */
#define XCB_IMAGE_TEXT_16 77
/**
* @brief xcb_image_text_16_request_t
**/
typedef struct xcb_image_text_16_request_t {
uint8_t major_opcode;
uint8_t string_len;
uint16_t length;
xcb_drawable_t drawable;
xcb_gcontext_t gc;
int16_t x;
int16_t y;
} xcb_image_text_16_request_t;
typedef enum xcb_colormap_alloc_t {
XCB_COLORMAP_ALLOC_NONE = 0,
XCB_COLORMAP_ALLOC_ALL = 1
} xcb_colormap_alloc_t;
/** Opcode for xcb_create_colormap. */
#define XCB_CREATE_COLORMAP 78
/**
* @brief xcb_create_colormap_request_t
**/
typedef struct xcb_create_colormap_request_t {
uint8_t major_opcode;
uint8_t alloc;
uint16_t length;
xcb_colormap_t mid;
xcb_window_t window;
xcb_visualid_t visual;
} xcb_create_colormap_request_t;
/** Opcode for xcb_free_colormap. */
#define XCB_FREE_COLORMAP 79
/**
* @brief xcb_free_colormap_request_t
**/
typedef struct xcb_free_colormap_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_colormap_t cmap;
} xcb_free_colormap_request_t;
/** Opcode for xcb_copy_colormap_and_free. */
#define XCB_COPY_COLORMAP_AND_FREE 80
/**
* @brief xcb_copy_colormap_and_free_request_t
**/
typedef struct xcb_copy_colormap_and_free_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_colormap_t mid;
xcb_colormap_t src_cmap;
} xcb_copy_colormap_and_free_request_t;
/** Opcode for xcb_install_colormap. */
#define XCB_INSTALL_COLORMAP 81
/**
* @brief xcb_install_colormap_request_t
**/
typedef struct xcb_install_colormap_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_colormap_t cmap;
} xcb_install_colormap_request_t;
/** Opcode for xcb_uninstall_colormap. */
#define XCB_UNINSTALL_COLORMAP 82
/**
* @brief xcb_uninstall_colormap_request_t
**/
typedef struct xcb_uninstall_colormap_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_colormap_t cmap;
} xcb_uninstall_colormap_request_t;
/**
* @brief xcb_list_installed_colormaps_cookie_t
**/
typedef struct xcb_list_installed_colormaps_cookie_t {
unsigned int sequence;
} xcb_list_installed_colormaps_cookie_t;
/** Opcode for xcb_list_installed_colormaps. */
#define XCB_LIST_INSTALLED_COLORMAPS 83
/**
* @brief xcb_list_installed_colormaps_request_t
**/
typedef struct xcb_list_installed_colormaps_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_window_t window;
} xcb_list_installed_colormaps_request_t;
/**
* @brief xcb_list_installed_colormaps_reply_t
**/
typedef struct xcb_list_installed_colormaps_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t cmaps_len;
uint8_t pad1[22];
} xcb_list_installed_colormaps_reply_t;
/**
* @brief xcb_alloc_color_cookie_t
**/
typedef struct xcb_alloc_color_cookie_t {
unsigned int sequence;
} xcb_alloc_color_cookie_t;
/** Opcode for xcb_alloc_color. */
#define XCB_ALLOC_COLOR 84
/**
* @brief xcb_alloc_color_request_t
**/
typedef struct xcb_alloc_color_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_colormap_t cmap;
uint16_t red;
uint16_t green;
uint16_t blue;
uint8_t pad1[2];
} xcb_alloc_color_request_t;
/**
* @brief xcb_alloc_color_reply_t
**/
typedef struct xcb_alloc_color_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t red;
uint16_t green;
uint16_t blue;
uint8_t pad1[2];
uint32_t pixel;
} xcb_alloc_color_reply_t;
/**
* @brief xcb_alloc_named_color_cookie_t
**/
typedef struct xcb_alloc_named_color_cookie_t {
unsigned int sequence;
} xcb_alloc_named_color_cookie_t;
/** Opcode for xcb_alloc_named_color. */
#define XCB_ALLOC_NAMED_COLOR 85
/**
* @brief xcb_alloc_named_color_request_t
**/
typedef struct xcb_alloc_named_color_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_colormap_t cmap;
uint16_t name_len;
uint8_t pad1[2];
} xcb_alloc_named_color_request_t;
/**
* @brief xcb_alloc_named_color_reply_t
**/
typedef struct xcb_alloc_named_color_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t pixel;
uint16_t exact_red;
uint16_t exact_green;
uint16_t exact_blue;
uint16_t visual_red;
uint16_t visual_green;
uint16_t visual_blue;
} xcb_alloc_named_color_reply_t;
/**
* @brief xcb_alloc_color_cells_cookie_t
**/
typedef struct xcb_alloc_color_cells_cookie_t {
unsigned int sequence;
} xcb_alloc_color_cells_cookie_t;
/** Opcode for xcb_alloc_color_cells. */
#define XCB_ALLOC_COLOR_CELLS 86
/**
* @brief xcb_alloc_color_cells_request_t
**/
typedef struct xcb_alloc_color_cells_request_t {
uint8_t major_opcode;
uint8_t contiguous;
uint16_t length;
xcb_colormap_t cmap;
uint16_t colors;
uint16_t planes;
} xcb_alloc_color_cells_request_t;
/**
* @brief xcb_alloc_color_cells_reply_t
**/
typedef struct xcb_alloc_color_cells_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t pixels_len;
uint16_t masks_len;
uint8_t pad1[20];
} xcb_alloc_color_cells_reply_t;
/**
* @brief xcb_alloc_color_planes_cookie_t
**/
typedef struct xcb_alloc_color_planes_cookie_t {
unsigned int sequence;
} xcb_alloc_color_planes_cookie_t;
/** Opcode for xcb_alloc_color_planes. */
#define XCB_ALLOC_COLOR_PLANES 87
/**
* @brief xcb_alloc_color_planes_request_t
**/
typedef struct xcb_alloc_color_planes_request_t {
uint8_t major_opcode;
uint8_t contiguous;
uint16_t length;
xcb_colormap_t cmap;
uint16_t colors;
uint16_t reds;
uint16_t greens;
uint16_t blues;
} xcb_alloc_color_planes_request_t;
/**
* @brief xcb_alloc_color_planes_reply_t
**/
typedef struct xcb_alloc_color_planes_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t pixels_len;
uint8_t pad1[2];
uint32_t red_mask;
uint32_t green_mask;
uint32_t blue_mask;
uint8_t pad2[8];
} xcb_alloc_color_planes_reply_t;
/** Opcode for xcb_free_colors. */
#define XCB_FREE_COLORS 88
/**
* @brief xcb_free_colors_request_t
**/
typedef struct xcb_free_colors_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_colormap_t cmap;
uint32_t plane_mask;
} xcb_free_colors_request_t;
typedef enum xcb_color_flag_t {
XCB_COLOR_FLAG_RED = 1,
XCB_COLOR_FLAG_GREEN = 2,
XCB_COLOR_FLAG_BLUE = 4
} xcb_color_flag_t;
/**
* @brief xcb_coloritem_t
**/
typedef struct xcb_coloritem_t {
uint32_t pixel;
uint16_t red;
uint16_t green;
uint16_t blue;
uint8_t flags;
uint8_t pad0;
} xcb_coloritem_t;
/**
* @brief xcb_coloritem_iterator_t
**/
typedef struct xcb_coloritem_iterator_t {
xcb_coloritem_t *data;
int rem;
int index;
} xcb_coloritem_iterator_t;
/** Opcode for xcb_store_colors. */
#define XCB_STORE_COLORS 89
/**
* @brief xcb_store_colors_request_t
**/
typedef struct xcb_store_colors_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_colormap_t cmap;
} xcb_store_colors_request_t;
/** Opcode for xcb_store_named_color. */
#define XCB_STORE_NAMED_COLOR 90
/**
* @brief xcb_store_named_color_request_t
**/
typedef struct xcb_store_named_color_request_t {
uint8_t major_opcode;
uint8_t flags;
uint16_t length;
xcb_colormap_t cmap;
uint32_t pixel;
uint16_t name_len;
uint8_t pad0[2];
} xcb_store_named_color_request_t;
/**
* @brief xcb_rgb_t
**/
typedef struct xcb_rgb_t {
uint16_t red;
uint16_t green;
uint16_t blue;
uint8_t pad0[2];
} xcb_rgb_t;
/**
* @brief xcb_rgb_iterator_t
**/
typedef struct xcb_rgb_iterator_t {
xcb_rgb_t *data;
int rem;
int index;
} xcb_rgb_iterator_t;
/**
* @brief xcb_query_colors_cookie_t
**/
typedef struct xcb_query_colors_cookie_t {
unsigned int sequence;
} xcb_query_colors_cookie_t;
/** Opcode for xcb_query_colors. */
#define XCB_QUERY_COLORS 91
/**
* @brief xcb_query_colors_request_t
**/
typedef struct xcb_query_colors_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_colormap_t cmap;
} xcb_query_colors_request_t;
/**
* @brief xcb_query_colors_reply_t
**/
typedef struct xcb_query_colors_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t colors_len;
uint8_t pad1[22];
} xcb_query_colors_reply_t;
/**
* @brief xcb_lookup_color_cookie_t
**/
typedef struct xcb_lookup_color_cookie_t {
unsigned int sequence;
} xcb_lookup_color_cookie_t;
/** Opcode for xcb_lookup_color. */
#define XCB_LOOKUP_COLOR 92
/**
* @brief xcb_lookup_color_request_t
**/
typedef struct xcb_lookup_color_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_colormap_t cmap;
uint16_t name_len;
uint8_t pad1[2];
} xcb_lookup_color_request_t;
/**
* @brief xcb_lookup_color_reply_t
**/
typedef struct xcb_lookup_color_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t exact_red;
uint16_t exact_green;
uint16_t exact_blue;
uint16_t visual_red;
uint16_t visual_green;
uint16_t visual_blue;
} xcb_lookup_color_reply_t;
typedef enum xcb_pixmap_enum_t {
XCB_PIXMAP_NONE = 0
} xcb_pixmap_enum_t;
/** Opcode for xcb_create_cursor. */
#define XCB_CREATE_CURSOR 93
/**
* @brief xcb_create_cursor_request_t
**/
typedef struct xcb_create_cursor_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_cursor_t cid;
xcb_pixmap_t source;
xcb_pixmap_t mask;
uint16_t fore_red;
uint16_t fore_green;
uint16_t fore_blue;
uint16_t back_red;
uint16_t back_green;
uint16_t back_blue;
uint16_t x;
uint16_t y;
} xcb_create_cursor_request_t;
typedef enum xcb_font_enum_t {
XCB_FONT_NONE = 0
} xcb_font_enum_t;
/** Opcode for xcb_create_glyph_cursor. */
#define XCB_CREATE_GLYPH_CURSOR 94
/**
* @brief xcb_create_glyph_cursor_request_t
**/
typedef struct xcb_create_glyph_cursor_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_cursor_t cid;
xcb_font_t source_font;
xcb_font_t mask_font;
uint16_t source_char;
uint16_t mask_char;
uint16_t fore_red;
uint16_t fore_green;
uint16_t fore_blue;
uint16_t back_red;
uint16_t back_green;
uint16_t back_blue;
} xcb_create_glyph_cursor_request_t;
/** Opcode for xcb_free_cursor. */
#define XCB_FREE_CURSOR 95
/**
* @brief xcb_free_cursor_request_t
**/
typedef struct xcb_free_cursor_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_cursor_t cursor;
} xcb_free_cursor_request_t;
/** Opcode for xcb_recolor_cursor. */
#define XCB_RECOLOR_CURSOR 96
/**
* @brief xcb_recolor_cursor_request_t
**/
typedef struct xcb_recolor_cursor_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_cursor_t cursor;
uint16_t fore_red;
uint16_t fore_green;
uint16_t fore_blue;
uint16_t back_red;
uint16_t back_green;
uint16_t back_blue;
} xcb_recolor_cursor_request_t;
typedef enum xcb_query_shape_of_t {
XCB_QUERY_SHAPE_OF_LARGEST_CURSOR = 0,
XCB_QUERY_SHAPE_OF_FASTEST_TILE = 1,
XCB_QUERY_SHAPE_OF_FASTEST_STIPPLE = 2
} xcb_query_shape_of_t;
/**
* @brief xcb_query_best_size_cookie_t
**/
typedef struct xcb_query_best_size_cookie_t {
unsigned int sequence;
} xcb_query_best_size_cookie_t;
/** Opcode for xcb_query_best_size. */
#define XCB_QUERY_BEST_SIZE 97
/**
* @brief xcb_query_best_size_request_t
**/
typedef struct xcb_query_best_size_request_t {
uint8_t major_opcode;
uint8_t _class;
uint16_t length;
xcb_drawable_t drawable;
uint16_t width;
uint16_t height;
} xcb_query_best_size_request_t;
/**
* @brief xcb_query_best_size_reply_t
**/
typedef struct xcb_query_best_size_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t width;
uint16_t height;
} xcb_query_best_size_reply_t;
/**
* @brief xcb_query_extension_cookie_t
**/
typedef struct xcb_query_extension_cookie_t {
unsigned int sequence;
} xcb_query_extension_cookie_t;
/** Opcode for xcb_query_extension. */
#define XCB_QUERY_EXTENSION 98
/**
* @brief xcb_query_extension_request_t
**/
typedef struct xcb_query_extension_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
uint16_t name_len;
uint8_t pad1[2];
} xcb_query_extension_request_t;
/**
* @brief xcb_query_extension_reply_t
**/
typedef struct xcb_query_extension_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t present;
uint8_t major_opcode;
uint8_t first_event;
uint8_t first_error;
} xcb_query_extension_reply_t;
/**
* @brief xcb_list_extensions_cookie_t
**/
typedef struct xcb_list_extensions_cookie_t {
unsigned int sequence;
} xcb_list_extensions_cookie_t;
/** Opcode for xcb_list_extensions. */
#define XCB_LIST_EXTENSIONS 99
/**
* @brief xcb_list_extensions_request_t
**/
typedef struct xcb_list_extensions_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
} xcb_list_extensions_request_t;
/**
* @brief xcb_list_extensions_reply_t
**/
typedef struct xcb_list_extensions_reply_t {
uint8_t response_type;
uint8_t names_len;
uint16_t sequence;
uint32_t length;
uint8_t pad0[24];
} xcb_list_extensions_reply_t;
/** Opcode for xcb_change_keyboard_mapping. */
#define XCB_CHANGE_KEYBOARD_MAPPING 100
/**
* @brief xcb_change_keyboard_mapping_request_t
**/
typedef struct xcb_change_keyboard_mapping_request_t {
uint8_t major_opcode;
uint8_t keycode_count;
uint16_t length;
xcb_keycode_t first_keycode;
uint8_t keysyms_per_keycode;
uint8_t pad0[2];
} xcb_change_keyboard_mapping_request_t;
/**
* @brief xcb_get_keyboard_mapping_cookie_t
**/
typedef struct xcb_get_keyboard_mapping_cookie_t {
unsigned int sequence;
} xcb_get_keyboard_mapping_cookie_t;
/** Opcode for xcb_get_keyboard_mapping. */
#define XCB_GET_KEYBOARD_MAPPING 101
/**
* @brief xcb_get_keyboard_mapping_request_t
**/
typedef struct xcb_get_keyboard_mapping_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_keycode_t first_keycode;
uint8_t count;
} xcb_get_keyboard_mapping_request_t;
/**
* @brief xcb_get_keyboard_mapping_reply_t
**/
typedef struct xcb_get_keyboard_mapping_reply_t {
uint8_t response_type;
uint8_t keysyms_per_keycode;
uint16_t sequence;
uint32_t length;
uint8_t pad0[24];
} xcb_get_keyboard_mapping_reply_t;
typedef enum xcb_kb_t {
XCB_KB_KEY_CLICK_PERCENT = 1,
XCB_KB_BELL_PERCENT = 2,
XCB_KB_BELL_PITCH = 4,
XCB_KB_BELL_DURATION = 8,
XCB_KB_LED = 16,
XCB_KB_LED_MODE = 32,
XCB_KB_KEY = 64,
XCB_KB_AUTO_REPEAT_MODE = 128
} xcb_kb_t;
typedef enum xcb_led_mode_t {
XCB_LED_MODE_OFF = 0,
XCB_LED_MODE_ON = 1
} xcb_led_mode_t;
typedef enum xcb_auto_repeat_mode_t {
XCB_AUTO_REPEAT_MODE_OFF = 0,
XCB_AUTO_REPEAT_MODE_ON = 1,
XCB_AUTO_REPEAT_MODE_DEFAULT = 2
} xcb_auto_repeat_mode_t;
/**
* @brief xcb_change_keyboard_control_value_list_t
**/
typedef struct xcb_change_keyboard_control_value_list_t {
int32_t key_click_percent;
int32_t bell_percent;
int32_t bell_pitch;
int32_t bell_duration;
uint32_t led;
uint32_t led_mode;
xcb_keycode32_t key;
uint32_t auto_repeat_mode;
} xcb_change_keyboard_control_value_list_t;
/** Opcode for xcb_change_keyboard_control. */
#define XCB_CHANGE_KEYBOARD_CONTROL 102
/**
* @brief xcb_change_keyboard_control_request_t
**/
typedef struct xcb_change_keyboard_control_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
uint32_t value_mask;
} xcb_change_keyboard_control_request_t;
/**
* @brief xcb_get_keyboard_control_cookie_t
**/
typedef struct xcb_get_keyboard_control_cookie_t {
unsigned int sequence;
} xcb_get_keyboard_control_cookie_t;
/** Opcode for xcb_get_keyboard_control. */
#define XCB_GET_KEYBOARD_CONTROL 103
/**
* @brief xcb_get_keyboard_control_request_t
**/
typedef struct xcb_get_keyboard_control_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
} xcb_get_keyboard_control_request_t;
/**
* @brief xcb_get_keyboard_control_reply_t
**/
typedef struct xcb_get_keyboard_control_reply_t {
uint8_t response_type;
uint8_t global_auto_repeat;
uint16_t sequence;
uint32_t length;
uint32_t led_mask;
uint8_t key_click_percent;
uint8_t bell_percent;
uint16_t bell_pitch;
uint16_t bell_duration;
uint8_t pad0[2];
uint8_t auto_repeats[32];
} xcb_get_keyboard_control_reply_t;
/** Opcode for xcb_bell. */
#define XCB_BELL 104
/**
* @brief xcb_bell_request_t
**/
typedef struct xcb_bell_request_t {
uint8_t major_opcode;
int8_t percent;
uint16_t length;
} xcb_bell_request_t;
/** Opcode for xcb_change_pointer_control. */
#define XCB_CHANGE_POINTER_CONTROL 105
/**
* @brief xcb_change_pointer_control_request_t
**/
typedef struct xcb_change_pointer_control_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
int16_t acceleration_numerator;
int16_t acceleration_denominator;
int16_t threshold;
uint8_t do_acceleration;
uint8_t do_threshold;
} xcb_change_pointer_control_request_t;
/**
* @brief xcb_get_pointer_control_cookie_t
**/
typedef struct xcb_get_pointer_control_cookie_t {
unsigned int sequence;
} xcb_get_pointer_control_cookie_t;
/** Opcode for xcb_get_pointer_control. */
#define XCB_GET_POINTER_CONTROL 106
/**
* @brief xcb_get_pointer_control_request_t
**/
typedef struct xcb_get_pointer_control_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
} xcb_get_pointer_control_request_t;
/**
* @brief xcb_get_pointer_control_reply_t
**/
typedef struct xcb_get_pointer_control_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t acceleration_numerator;
uint16_t acceleration_denominator;
uint16_t threshold;
uint8_t pad1[18];
} xcb_get_pointer_control_reply_t;
typedef enum xcb_blanking_t {
XCB_BLANKING_NOT_PREFERRED = 0,
XCB_BLANKING_PREFERRED = 1,
XCB_BLANKING_DEFAULT = 2
} xcb_blanking_t;
typedef enum xcb_exposures_t {
XCB_EXPOSURES_NOT_ALLOWED = 0,
XCB_EXPOSURES_ALLOWED = 1,
XCB_EXPOSURES_DEFAULT = 2
} xcb_exposures_t;
/** Opcode for xcb_set_screen_saver. */
#define XCB_SET_SCREEN_SAVER 107
/**
* @brief xcb_set_screen_saver_request_t
**/
typedef struct xcb_set_screen_saver_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
int16_t timeout;
int16_t interval;
uint8_t prefer_blanking;
uint8_t allow_exposures;
} xcb_set_screen_saver_request_t;
/**
* @brief xcb_get_screen_saver_cookie_t
**/
typedef struct xcb_get_screen_saver_cookie_t {
unsigned int sequence;
} xcb_get_screen_saver_cookie_t;
/** Opcode for xcb_get_screen_saver. */
#define XCB_GET_SCREEN_SAVER 108
/**
* @brief xcb_get_screen_saver_request_t
**/
typedef struct xcb_get_screen_saver_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
} xcb_get_screen_saver_request_t;
/**
* @brief xcb_get_screen_saver_reply_t
**/
typedef struct xcb_get_screen_saver_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t timeout;
uint16_t interval;
uint8_t prefer_blanking;
uint8_t allow_exposures;
uint8_t pad1[18];
} xcb_get_screen_saver_reply_t;
typedef enum xcb_host_mode_t {
XCB_HOST_MODE_INSERT = 0,
XCB_HOST_MODE_DELETE = 1
} xcb_host_mode_t;
typedef enum xcb_family_t {
XCB_FAMILY_INTERNET = 0,
XCB_FAMILY_DECNET = 1,
XCB_FAMILY_CHAOS = 2,
XCB_FAMILY_SERVER_INTERPRETED = 5,
XCB_FAMILY_INTERNET_6 = 6
} xcb_family_t;
/** Opcode for xcb_change_hosts. */
#define XCB_CHANGE_HOSTS 109
/**
* @brief xcb_change_hosts_request_t
**/
typedef struct xcb_change_hosts_request_t {
uint8_t major_opcode;
uint8_t mode;
uint16_t length;
uint8_t family;
uint8_t pad0;
uint16_t address_len;
} xcb_change_hosts_request_t;
/**
* @brief xcb_host_t
**/
typedef struct xcb_host_t {
uint8_t family;
uint8_t pad0;
uint16_t address_len;
} xcb_host_t;
/**
* @brief xcb_host_iterator_t
**/
typedef struct xcb_host_iterator_t {
xcb_host_t *data;
int rem;
int index;
} xcb_host_iterator_t;
/**
* @brief xcb_list_hosts_cookie_t
**/
typedef struct xcb_list_hosts_cookie_t {
unsigned int sequence;
} xcb_list_hosts_cookie_t;
/** Opcode for xcb_list_hosts. */
#define XCB_LIST_HOSTS 110
/**
* @brief xcb_list_hosts_request_t
**/
typedef struct xcb_list_hosts_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
} xcb_list_hosts_request_t;
/**
* @brief xcb_list_hosts_reply_t
**/
typedef struct xcb_list_hosts_reply_t {
uint8_t response_type;
uint8_t mode;
uint16_t sequence;
uint32_t length;
uint16_t hosts_len;
uint8_t pad0[22];
} xcb_list_hosts_reply_t;
typedef enum xcb_access_control_t {
XCB_ACCESS_CONTROL_DISABLE = 0,
XCB_ACCESS_CONTROL_ENABLE = 1
} xcb_access_control_t;
/** Opcode for xcb_set_access_control. */
#define XCB_SET_ACCESS_CONTROL 111
/**
* @brief xcb_set_access_control_request_t
**/
typedef struct xcb_set_access_control_request_t {
uint8_t major_opcode;
uint8_t mode;
uint16_t length;
} xcb_set_access_control_request_t;
typedef enum xcb_close_down_t {
XCB_CLOSE_DOWN_DESTROY_ALL = 0,
XCB_CLOSE_DOWN_RETAIN_PERMANENT = 1,
XCB_CLOSE_DOWN_RETAIN_TEMPORARY = 2
} xcb_close_down_t;
/** Opcode for xcb_set_close_down_mode. */
#define XCB_SET_CLOSE_DOWN_MODE 112
/**
* @brief xcb_set_close_down_mode_request_t
**/
typedef struct xcb_set_close_down_mode_request_t {
uint8_t major_opcode;
uint8_t mode;
uint16_t length;
} xcb_set_close_down_mode_request_t;
typedef enum xcb_kill_t {
XCB_KILL_ALL_TEMPORARY = 0
} xcb_kill_t;
/** Opcode for xcb_kill_client. */
#define XCB_KILL_CLIENT 113
/**
* @brief xcb_kill_client_request_t
**/
typedef struct xcb_kill_client_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
uint32_t resource;
} xcb_kill_client_request_t;
/** Opcode for xcb_rotate_properties. */
#define XCB_ROTATE_PROPERTIES 114
/**
* @brief xcb_rotate_properties_request_t
**/
typedef struct xcb_rotate_properties_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
xcb_window_t window;
uint16_t atoms_len;
int16_t delta;
} xcb_rotate_properties_request_t;
typedef enum xcb_screen_saver_t {
XCB_SCREEN_SAVER_RESET = 0,
XCB_SCREEN_SAVER_ACTIVE = 1
} xcb_screen_saver_t;
/** Opcode for xcb_force_screen_saver. */
#define XCB_FORCE_SCREEN_SAVER 115
/**
* @brief xcb_force_screen_saver_request_t
**/
typedef struct xcb_force_screen_saver_request_t {
uint8_t major_opcode;
uint8_t mode;
uint16_t length;
} xcb_force_screen_saver_request_t;
typedef enum xcb_mapping_status_t {
XCB_MAPPING_STATUS_SUCCESS = 0,
XCB_MAPPING_STATUS_BUSY = 1,
XCB_MAPPING_STATUS_FAILURE = 2
} xcb_mapping_status_t;
/**
* @brief xcb_set_pointer_mapping_cookie_t
**/
typedef struct xcb_set_pointer_mapping_cookie_t {
unsigned int sequence;
} xcb_set_pointer_mapping_cookie_t;
/** Opcode for xcb_set_pointer_mapping. */
#define XCB_SET_POINTER_MAPPING 116
/**
* @brief xcb_set_pointer_mapping_request_t
**/
typedef struct xcb_set_pointer_mapping_request_t {
uint8_t major_opcode;
uint8_t map_len;
uint16_t length;
} xcb_set_pointer_mapping_request_t;
/**
* @brief xcb_set_pointer_mapping_reply_t
**/
typedef struct xcb_set_pointer_mapping_reply_t {
uint8_t response_type;
uint8_t status;
uint16_t sequence;
uint32_t length;
} xcb_set_pointer_mapping_reply_t;
/**
* @brief xcb_get_pointer_mapping_cookie_t
**/
typedef struct xcb_get_pointer_mapping_cookie_t {
unsigned int sequence;
} xcb_get_pointer_mapping_cookie_t;
/** Opcode for xcb_get_pointer_mapping. */
#define XCB_GET_POINTER_MAPPING 117
/**
* @brief xcb_get_pointer_mapping_request_t
**/
typedef struct xcb_get_pointer_mapping_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
} xcb_get_pointer_mapping_request_t;
/**
* @brief xcb_get_pointer_mapping_reply_t
**/
typedef struct xcb_get_pointer_mapping_reply_t {
uint8_t response_type;
uint8_t map_len;
uint16_t sequence;
uint32_t length;
uint8_t pad0[24];
} xcb_get_pointer_mapping_reply_t;
typedef enum xcb_map_index_t {
XCB_MAP_INDEX_SHIFT = 0,
XCB_MAP_INDEX_LOCK = 1,
XCB_MAP_INDEX_CONTROL = 2,
XCB_MAP_INDEX_1 = 3,
XCB_MAP_INDEX_2 = 4,
XCB_MAP_INDEX_3 = 5,
XCB_MAP_INDEX_4 = 6,
XCB_MAP_INDEX_5 = 7
} xcb_map_index_t;
/**
* @brief xcb_set_modifier_mapping_cookie_t
**/
typedef struct xcb_set_modifier_mapping_cookie_t {
unsigned int sequence;
} xcb_set_modifier_mapping_cookie_t;
/** Opcode for xcb_set_modifier_mapping. */
#define XCB_SET_MODIFIER_MAPPING 118
/**
* @brief xcb_set_modifier_mapping_request_t
**/
typedef struct xcb_set_modifier_mapping_request_t {
uint8_t major_opcode;
uint8_t keycodes_per_modifier;
uint16_t length;
} xcb_set_modifier_mapping_request_t;
/**
* @brief xcb_set_modifier_mapping_reply_t
**/
typedef struct xcb_set_modifier_mapping_reply_t {
uint8_t response_type;
uint8_t status;
uint16_t sequence;
uint32_t length;
} xcb_set_modifier_mapping_reply_t;
/**
* @brief xcb_get_modifier_mapping_cookie_t
**/
typedef struct xcb_get_modifier_mapping_cookie_t {
unsigned int sequence;
} xcb_get_modifier_mapping_cookie_t;
/** Opcode for xcb_get_modifier_mapping. */
#define XCB_GET_MODIFIER_MAPPING 119
/**
* @brief xcb_get_modifier_mapping_request_t
**/
typedef struct xcb_get_modifier_mapping_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
} xcb_get_modifier_mapping_request_t;
/**
* @brief xcb_get_modifier_mapping_reply_t
**/
typedef struct xcb_get_modifier_mapping_reply_t {
uint8_t response_type;
uint8_t keycodes_per_modifier;
uint16_t sequence;
uint32_t length;
uint8_t pad0[24];
} xcb_get_modifier_mapping_reply_t;
/** Opcode for xcb_no_operation. */
#define XCB_NO_OPERATION 127
/**
* @brief xcb_no_operation_request_t
**/
typedef struct xcb_no_operation_request_t {
uint8_t major_opcode;
uint8_t pad0;
uint16_t length;
} xcb_no_operation_request_t;
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_char2b_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_char2b_t)
*/
void
xcb_char2b_next (xcb_char2b_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_char2b_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_char2b_end (xcb_char2b_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_window_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_window_t)
*/
void
xcb_window_next (xcb_window_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_window_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_window_end (xcb_window_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_pixmap_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_pixmap_t)
*/
void
xcb_pixmap_next (xcb_pixmap_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_pixmap_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_pixmap_end (xcb_pixmap_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_cursor_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_cursor_t)
*/
void
xcb_cursor_next (xcb_cursor_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_cursor_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_cursor_end (xcb_cursor_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_font_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_font_t)
*/
void
xcb_font_next (xcb_font_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_font_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_font_end (xcb_font_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_gcontext_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_gcontext_t)
*/
void
xcb_gcontext_next (xcb_gcontext_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_gcontext_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_gcontext_end (xcb_gcontext_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_colormap_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_colormap_t)
*/
void
xcb_colormap_next (xcb_colormap_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_colormap_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_colormap_end (xcb_colormap_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_atom_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_atom_t)
*/
void
xcb_atom_next (xcb_atom_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_atom_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_atom_end (xcb_atom_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_drawable_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_drawable_t)
*/
void
xcb_drawable_next (xcb_drawable_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_drawable_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_drawable_end (xcb_drawable_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_fontable_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_fontable_t)
*/
void
xcb_fontable_next (xcb_fontable_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_fontable_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_fontable_end (xcb_fontable_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_bool32_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_bool32_t)
*/
void
xcb_bool32_next (xcb_bool32_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_bool32_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_bool32_end (xcb_bool32_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_visualid_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_visualid_t)
*/
void
xcb_visualid_next (xcb_visualid_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_visualid_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_visualid_end (xcb_visualid_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_timestamp_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_timestamp_t)
*/
void
xcb_timestamp_next (xcb_timestamp_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_timestamp_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_timestamp_end (xcb_timestamp_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_keysym_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_keysym_t)
*/
void
xcb_keysym_next (xcb_keysym_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_keysym_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_keysym_end (xcb_keysym_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_keycode_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_keycode_t)
*/
void
xcb_keycode_next (xcb_keycode_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_keycode_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_keycode_end (xcb_keycode_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_keycode32_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_keycode32_t)
*/
void
xcb_keycode32_next (xcb_keycode32_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_keycode32_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_keycode32_end (xcb_keycode32_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_button_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_button_t)
*/
void
xcb_button_next (xcb_button_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_button_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_button_end (xcb_button_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_point_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_point_t)
*/
void
xcb_point_next (xcb_point_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_point_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_point_end (xcb_point_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_rectangle_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_rectangle_t)
*/
void
xcb_rectangle_next (xcb_rectangle_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_rectangle_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_rectangle_end (xcb_rectangle_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_arc_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_arc_t)
*/
void
xcb_arc_next (xcb_arc_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_arc_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_arc_end (xcb_arc_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_format_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_format_t)
*/
void
xcb_format_next (xcb_format_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_format_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_format_end (xcb_format_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_visualtype_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_visualtype_t)
*/
void
xcb_visualtype_next (xcb_visualtype_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_visualtype_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_visualtype_end (xcb_visualtype_iterator_t i);
int
xcb_depth_sizeof (const void *_buffer);
xcb_visualtype_t *
xcb_depth_visuals (const xcb_depth_t *R);
int
xcb_depth_visuals_length (const xcb_depth_t *R);
xcb_visualtype_iterator_t
xcb_depth_visuals_iterator (const xcb_depth_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_depth_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_depth_t)
*/
void
xcb_depth_next (xcb_depth_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_depth_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_depth_end (xcb_depth_iterator_t i);
int
xcb_screen_sizeof (const void *_buffer);
int
xcb_screen_allowed_depths_length (const xcb_screen_t *R);
xcb_depth_iterator_t
xcb_screen_allowed_depths_iterator (const xcb_screen_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_screen_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_screen_t)
*/
void
xcb_screen_next (xcb_screen_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_screen_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_screen_end (xcb_screen_iterator_t i);
int
xcb_setup_request_sizeof (const void *_buffer);
char *
xcb_setup_request_authorization_protocol_name (const xcb_setup_request_t *R);
int
xcb_setup_request_authorization_protocol_name_length (const xcb_setup_request_t *R);
xcb_generic_iterator_t
xcb_setup_request_authorization_protocol_name_end (const xcb_setup_request_t *R);
char *
xcb_setup_request_authorization_protocol_data (const xcb_setup_request_t *R);
int
xcb_setup_request_authorization_protocol_data_length (const xcb_setup_request_t *R);
xcb_generic_iterator_t
xcb_setup_request_authorization_protocol_data_end (const xcb_setup_request_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_setup_request_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_setup_request_t)
*/
void
xcb_setup_request_next (xcb_setup_request_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_setup_request_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_setup_request_end (xcb_setup_request_iterator_t i);
int
xcb_setup_failed_sizeof (const void *_buffer);
char *
xcb_setup_failed_reason (const xcb_setup_failed_t *R);
int
xcb_setup_failed_reason_length (const xcb_setup_failed_t *R);
xcb_generic_iterator_t
xcb_setup_failed_reason_end (const xcb_setup_failed_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_setup_failed_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_setup_failed_t)
*/
void
xcb_setup_failed_next (xcb_setup_failed_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_setup_failed_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_setup_failed_end (xcb_setup_failed_iterator_t i);
int
xcb_setup_authenticate_sizeof (const void *_buffer);
char *
xcb_setup_authenticate_reason (const xcb_setup_authenticate_t *R);
int
xcb_setup_authenticate_reason_length (const xcb_setup_authenticate_t *R);
xcb_generic_iterator_t
xcb_setup_authenticate_reason_end (const xcb_setup_authenticate_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_setup_authenticate_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_setup_authenticate_t)
*/
void
xcb_setup_authenticate_next (xcb_setup_authenticate_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_setup_authenticate_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_setup_authenticate_end (xcb_setup_authenticate_iterator_t i);
int
xcb_setup_sizeof (const void *_buffer);
char *
xcb_setup_vendor (const xcb_setup_t *R);
int
xcb_setup_vendor_length (const xcb_setup_t *R);
xcb_generic_iterator_t
xcb_setup_vendor_end (const xcb_setup_t *R);
xcb_format_t *
xcb_setup_pixmap_formats (const xcb_setup_t *R);
int
xcb_setup_pixmap_formats_length (const xcb_setup_t *R);
xcb_format_iterator_t
xcb_setup_pixmap_formats_iterator (const xcb_setup_t *R);
int
xcb_setup_roots_length (const xcb_setup_t *R);
xcb_screen_iterator_t
xcb_setup_roots_iterator (const xcb_setup_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_setup_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_setup_t)
*/
void
xcb_setup_next (xcb_setup_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_setup_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_setup_end (xcb_setup_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_client_message_data_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_client_message_data_t)
*/
void
xcb_client_message_data_next (xcb_client_message_data_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_client_message_data_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_client_message_data_end (xcb_client_message_data_iterator_t i);
int
xcb_create_window_value_list_serialize (void **_buffer,
uint32_t value_mask,
const xcb_create_window_value_list_t *_aux);
int
xcb_create_window_value_list_unpack (const void *_buffer,
uint32_t value_mask,
xcb_create_window_value_list_t *_aux);
int
xcb_create_window_value_list_sizeof (const void *_buffer,
uint32_t value_mask);
int
xcb_create_window_sizeof (const void *_buffer);
/**
* @brief Creates a window
*
* @param c The connection
* @param depth Specifies the new window's depth (TODO: what unit?).
* \n
* The special value `XCB_COPY_FROM_PARENT` means the depth is taken from the
* \a parent window.
* @param wid The ID with which you will refer to the new window, created by
* `xcb_generate_id`.
* @param parent The parent window of the new window.
* @param x The X coordinate of the new window.
* @param y The Y coordinate of the new window.
* @param width The width of the new window.
* @param height The height of the new window.
* @param border_width TODO:
* \n
* Must be zero if the `class` is `InputOnly` or a `xcb_match_error_t` occurs.
* @param _class A bitmask of #xcb_window_class_t values.
* @param _class \n
* @param visual Specifies the id for the new window's visual.
* \n
* The special value `XCB_COPY_FROM_PARENT` means the visual is taken from the
* \a parent window.
* @param value_mask A bitmask of #xcb_cw_t values.
* @return A cookie
*
* Creates an unmapped window as child of the specified \a parent window. A
* CreateNotify event will be generated. The new window is placed on top in the
* stacking order with respect to siblings.
*
* The coordinate system has the X axis horizontal and the Y axis vertical with
* the origin [0, 0] at the upper-left corner. Coordinates are integral, in terms
* of pixels, and coincide with pixel centers. Each window and pixmap has its own
* coordinate system. For a window, the origin is inside the border at the inside,
* upper-left corner.
*
* The created window is not yet displayed (mapped), call `xcb_map_window` to
* display it.
*
* The created window will initially use the same cursor as its parent.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_create_window_checked (xcb_connection_t *c,
uint8_t depth,
xcb_window_t wid,
xcb_window_t parent,
int16_t x,
int16_t y,
uint16_t width,
uint16_t height,
uint16_t border_width,
uint16_t _class,
xcb_visualid_t visual,
uint32_t value_mask,
const void *value_list);
/**
* @brief Creates a window
*
* @param c The connection
* @param depth Specifies the new window's depth (TODO: what unit?).
* \n
* The special value `XCB_COPY_FROM_PARENT` means the depth is taken from the
* \a parent window.
* @param wid The ID with which you will refer to the new window, created by
* `xcb_generate_id`.
* @param parent The parent window of the new window.
* @param x The X coordinate of the new window.
* @param y The Y coordinate of the new window.
* @param width The width of the new window.
* @param height The height of the new window.
* @param border_width TODO:
* \n
* Must be zero if the `class` is `InputOnly` or a `xcb_match_error_t` occurs.
* @param _class A bitmask of #xcb_window_class_t values.
* @param _class \n
* @param visual Specifies the id for the new window's visual.
* \n
* The special value `XCB_COPY_FROM_PARENT` means the visual is taken from the
* \a parent window.
* @param value_mask A bitmask of #xcb_cw_t values.
* @return A cookie
*
* Creates an unmapped window as child of the specified \a parent window. A
* CreateNotify event will be generated. The new window is placed on top in the
* stacking order with respect to siblings.
*
* The coordinate system has the X axis horizontal and the Y axis vertical with
* the origin [0, 0] at the upper-left corner. Coordinates are integral, in terms
* of pixels, and coincide with pixel centers. Each window and pixmap has its own
* coordinate system. For a window, the origin is inside the border at the inside,
* upper-left corner.
*
* The created window is not yet displayed (mapped), call `xcb_map_window` to
* display it.
*
* The created window will initially use the same cursor as its parent.
*
*/
xcb_void_cookie_t
xcb_create_window (xcb_connection_t *c,
uint8_t depth,
xcb_window_t wid,
xcb_window_t parent,
int16_t x,
int16_t y,
uint16_t width,
uint16_t height,
uint16_t border_width,
uint16_t _class,
xcb_visualid_t visual,
uint32_t value_mask,
const void *value_list);
/**
* @brief Creates a window
*
* @param c The connection
* @param depth Specifies the new window's depth (TODO: what unit?).
* \n
* The special value `XCB_COPY_FROM_PARENT` means the depth is taken from the
* \a parent window.
* @param wid The ID with which you will refer to the new window, created by
* `xcb_generate_id`.
* @param parent The parent window of the new window.
* @param x The X coordinate of the new window.
* @param y The Y coordinate of the new window.
* @param width The width of the new window.
* @param height The height of the new window.
* @param border_width TODO:
* \n
* Must be zero if the `class` is `InputOnly` or a `xcb_match_error_t` occurs.
* @param _class A bitmask of #xcb_window_class_t values.
* @param _class \n
* @param visual Specifies the id for the new window's visual.
* \n
* The special value `XCB_COPY_FROM_PARENT` means the visual is taken from the
* \a parent window.
* @param value_mask A bitmask of #xcb_cw_t values.
* @return A cookie
*
* Creates an unmapped window as child of the specified \a parent window. A
* CreateNotify event will be generated. The new window is placed on top in the
* stacking order with respect to siblings.
*
* The coordinate system has the X axis horizontal and the Y axis vertical with
* the origin [0, 0] at the upper-left corner. Coordinates are integral, in terms
* of pixels, and coincide with pixel centers. Each window and pixmap has its own
* coordinate system. For a window, the origin is inside the border at the inside,
* upper-left corner.
*
* The created window is not yet displayed (mapped), call `xcb_map_window` to
* display it.
*
* The created window will initially use the same cursor as its parent.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_create_window_aux_checked (xcb_connection_t *c,
uint8_t depth,
xcb_window_t wid,
xcb_window_t parent,
int16_t x,
int16_t y,
uint16_t width,
uint16_t height,
uint16_t border_width,
uint16_t _class,
xcb_visualid_t visual,
uint32_t value_mask,
const xcb_create_window_value_list_t *value_list);
/**
* @brief Creates a window
*
* @param c The connection
* @param depth Specifies the new window's depth (TODO: what unit?).
* \n
* The special value `XCB_COPY_FROM_PARENT` means the depth is taken from the
* \a parent window.
* @param wid The ID with which you will refer to the new window, created by
* `xcb_generate_id`.
* @param parent The parent window of the new window.
* @param x The X coordinate of the new window.
* @param y The Y coordinate of the new window.
* @param width The width of the new window.
* @param height The height of the new window.
* @param border_width TODO:
* \n
* Must be zero if the `class` is `InputOnly` or a `xcb_match_error_t` occurs.
* @param _class A bitmask of #xcb_window_class_t values.
* @param _class \n
* @param visual Specifies the id for the new window's visual.
* \n
* The special value `XCB_COPY_FROM_PARENT` means the visual is taken from the
* \a parent window.
* @param value_mask A bitmask of #xcb_cw_t values.
* @return A cookie
*
* Creates an unmapped window as child of the specified \a parent window. A
* CreateNotify event will be generated. The new window is placed on top in the
* stacking order with respect to siblings.
*
* The coordinate system has the X axis horizontal and the Y axis vertical with
* the origin [0, 0] at the upper-left corner. Coordinates are integral, in terms
* of pixels, and coincide with pixel centers. Each window and pixmap has its own
* coordinate system. For a window, the origin is inside the border at the inside,
* upper-left corner.
*
* The created window is not yet displayed (mapped), call `xcb_map_window` to
* display it.
*
* The created window will initially use the same cursor as its parent.
*
*/
xcb_void_cookie_t
xcb_create_window_aux (xcb_connection_t *c,
uint8_t depth,
xcb_window_t wid,
xcb_window_t parent,
int16_t x,
int16_t y,
uint16_t width,
uint16_t height,
uint16_t border_width,
uint16_t _class,
xcb_visualid_t visual,
uint32_t value_mask,
const xcb_create_window_value_list_t *value_list);
void *
xcb_create_window_value_list (const xcb_create_window_request_t *R);
int
xcb_change_window_attributes_value_list_serialize (void **_buffer,
uint32_t value_mask,
const xcb_change_window_attributes_value_list_t *_aux);
int
xcb_change_window_attributes_value_list_unpack (const void *_buffer,
uint32_t value_mask,
xcb_change_window_attributes_value_list_t *_aux);
int
xcb_change_window_attributes_value_list_sizeof (const void *_buffer,
uint32_t value_mask);
int
xcb_change_window_attributes_sizeof (const void *_buffer);
/**
* @brief change window attributes
*
* @param c The connection
* @param window The window to change.
* @param value_mask A bitmask of #xcb_cw_t values.
* @param value_mask \n
* @param value_list Values for each of the attributes specified in the bitmask \a value_mask. The
* order has to correspond to the order of possible \a value_mask bits. See the
* example.
* @return A cookie
*
* Changes the attributes specified by \a value_mask for the specified \a window.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_change_window_attributes_checked (xcb_connection_t *c,
xcb_window_t window,
uint32_t value_mask,
const void *value_list);
/**
* @brief change window attributes
*
* @param c The connection
* @param window The window to change.
* @param value_mask A bitmask of #xcb_cw_t values.
* @param value_mask \n
* @param value_list Values for each of the attributes specified in the bitmask \a value_mask. The
* order has to correspond to the order of possible \a value_mask bits. See the
* example.
* @return A cookie
*
* Changes the attributes specified by \a value_mask for the specified \a window.
*
*/
xcb_void_cookie_t
xcb_change_window_attributes (xcb_connection_t *c,
xcb_window_t window,
uint32_t value_mask,
const void *value_list);
/**
* @brief change window attributes
*
* @param c The connection
* @param window The window to change.
* @param value_mask A bitmask of #xcb_cw_t values.
* @param value_mask \n
* @param value_list Values for each of the attributes specified in the bitmask \a value_mask. The
* order has to correspond to the order of possible \a value_mask bits. See the
* example.
* @return A cookie
*
* Changes the attributes specified by \a value_mask for the specified \a window.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_change_window_attributes_aux_checked (xcb_connection_t *c,
xcb_window_t window,
uint32_t value_mask,
const xcb_change_window_attributes_value_list_t *value_list);
/**
* @brief change window attributes
*
* @param c The connection
* @param window The window to change.
* @param value_mask A bitmask of #xcb_cw_t values.
* @param value_mask \n
* @param value_list Values for each of the attributes specified in the bitmask \a value_mask. The
* order has to correspond to the order of possible \a value_mask bits. See the
* example.
* @return A cookie
*
* Changes the attributes specified by \a value_mask for the specified \a window.
*
*/
xcb_void_cookie_t
xcb_change_window_attributes_aux (xcb_connection_t *c,
xcb_window_t window,
uint32_t value_mask,
const xcb_change_window_attributes_value_list_t *value_list);
void *
xcb_change_window_attributes_value_list (const xcb_change_window_attributes_request_t *R);
/**
* @brief Gets window attributes
*
* @param c The connection
* @param window The window to get the attributes from.
* @return A cookie
*
* Gets the current attributes for the specified \a window.
*
*/
xcb_get_window_attributes_cookie_t
xcb_get_window_attributes (xcb_connection_t *c,
xcb_window_t window);
/**
* @brief Gets window attributes
*
* @param c The connection
* @param window The window to get the attributes from.
* @return A cookie
*
* Gets the current attributes for the specified \a window.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_get_window_attributes_cookie_t
xcb_get_window_attributes_unchecked (xcb_connection_t *c,
xcb_window_t window);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_get_window_attributes_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_get_window_attributes_reply_t *
xcb_get_window_attributes_reply (xcb_connection_t *c,
xcb_get_window_attributes_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
* @brief Destroys a window
*
* @param c The connection
* @param window The window to destroy.
* @return A cookie
*
* Destroys the specified window and all of its subwindows. A DestroyNotify event
* is generated for each destroyed window (a DestroyNotify event is first generated
* for any given window's inferiors). If the window was mapped, it will be
* automatically unmapped before destroying.
*
* Calling DestroyWindow on the root window will do nothing.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_destroy_window_checked (xcb_connection_t *c,
xcb_window_t window);
/**
* @brief Destroys a window
*
* @param c The connection
* @param window The window to destroy.
* @return A cookie
*
* Destroys the specified window and all of its subwindows. A DestroyNotify event
* is generated for each destroyed window (a DestroyNotify event is first generated
* for any given window's inferiors). If the window was mapped, it will be
* automatically unmapped before destroying.
*
* Calling DestroyWindow on the root window will do nothing.
*
*/
xcb_void_cookie_t
xcb_destroy_window (xcb_connection_t *c,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_destroy_subwindows_checked (xcb_connection_t *c,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_destroy_subwindows (xcb_connection_t *c,
xcb_window_t window);
/**
* @brief Changes a client's save set
*
* @param c The connection
* @param mode A bitmask of #xcb_set_mode_t values.
* @param mode Insert to add the specified window to the save set or Delete to delete it from the save set.
* @param window The window to add or delete to/from your save set.
* @return A cookie
*
* TODO: explain what the save set is for.
*
* This function either adds or removes the specified window to the client's (your
* application's) save set.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_change_save_set_checked (xcb_connection_t *c,
uint8_t mode,
xcb_window_t window);
/**
* @brief Changes a client's save set
*
* @param c The connection
* @param mode A bitmask of #xcb_set_mode_t values.
* @param mode Insert to add the specified window to the save set or Delete to delete it from the save set.
* @param window The window to add or delete to/from your save set.
* @return A cookie
*
* TODO: explain what the save set is for.
*
* This function either adds or removes the specified window to the client's (your
* application's) save set.
*
*/
xcb_void_cookie_t
xcb_change_save_set (xcb_connection_t *c,
uint8_t mode,
xcb_window_t window);
/**
* @brief Reparents a window
*
* @param c The connection
* @param window The window to reparent.
* @param parent The new parent of the window.
* @param x The X position of the window within its new parent.
* @param y The Y position of the window within its new parent.
* @return A cookie
*
* Makes the specified window a child of the specified parent window. If the
* window is mapped, it will automatically be unmapped before reparenting and
* re-mapped after reparenting. The window is placed in the stacking order on top
* with respect to sibling windows.
*
* After reparenting, a ReparentNotify event is generated.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_reparent_window_checked (xcb_connection_t *c,
xcb_window_t window,
xcb_window_t parent,
int16_t x,
int16_t y);
/**
* @brief Reparents a window
*
* @param c The connection
* @param window The window to reparent.
* @param parent The new parent of the window.
* @param x The X position of the window within its new parent.
* @param y The Y position of the window within its new parent.
* @return A cookie
*
* Makes the specified window a child of the specified parent window. If the
* window is mapped, it will automatically be unmapped before reparenting and
* re-mapped after reparenting. The window is placed in the stacking order on top
* with respect to sibling windows.
*
* After reparenting, a ReparentNotify event is generated.
*
*/
xcb_void_cookie_t
xcb_reparent_window (xcb_connection_t *c,
xcb_window_t window,
xcb_window_t parent,
int16_t x,
int16_t y);
/**
* @brief Makes a window visible
*
* @param c The connection
* @param window The window to make visible.
* @return A cookie
*
* Maps the specified window. This means making the window visible (as long as its
* parent is visible).
*
* This MapWindow request will be translated to a MapRequest request if a window
* manager is running. The window manager then decides to either map the window or
* not. Set the override-redirect window attribute to true if you want to bypass
* this mechanism.
*
* If the window manager decides to map the window (or if no window manager is
* running), a MapNotify event is generated.
*
* If the window becomes viewable and no earlier contents for it are remembered,
* the X server tiles the window with its background. If the window's background
* is undefined, the existing screen contents are not altered, and the X server
* generates zero or more Expose events.
*
* If the window type is InputOutput, an Expose event will be generated when the
* window becomes visible. The normal response to an Expose event should be to
* repaint the window.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_map_window_checked (xcb_connection_t *c,
xcb_window_t window);
/**
* @brief Makes a window visible
*
* @param c The connection
* @param window The window to make visible.
* @return A cookie
*
* Maps the specified window. This means making the window visible (as long as its
* parent is visible).
*
* This MapWindow request will be translated to a MapRequest request if a window
* manager is running. The window manager then decides to either map the window or
* not. Set the override-redirect window attribute to true if you want to bypass
* this mechanism.
*
* If the window manager decides to map the window (or if no window manager is
* running), a MapNotify event is generated.
*
* If the window becomes viewable and no earlier contents for it are remembered,
* the X server tiles the window with its background. If the window's background
* is undefined, the existing screen contents are not altered, and the X server
* generates zero or more Expose events.
*
* If the window type is InputOutput, an Expose event will be generated when the
* window becomes visible. The normal response to an Expose event should be to
* repaint the window.
*
*/
xcb_void_cookie_t
xcb_map_window (xcb_connection_t *c,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_map_subwindows_checked (xcb_connection_t *c,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_map_subwindows (xcb_connection_t *c,
xcb_window_t window);
/**
* @brief Makes a window invisible
*
* @param c The connection
* @param window The window to make invisible.
* @return A cookie
*
* Unmaps the specified window. This means making the window invisible (and all
* its child windows).
*
* Unmapping a window leads to the `UnmapNotify` event being generated. Also,
* `Expose` events are generated for formerly obscured windows.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_unmap_window_checked (xcb_connection_t *c,
xcb_window_t window);
/**
* @brief Makes a window invisible
*
* @param c The connection
* @param window The window to make invisible.
* @return A cookie
*
* Unmaps the specified window. This means making the window invisible (and all
* its child windows).
*
* Unmapping a window leads to the `UnmapNotify` event being generated. Also,
* `Expose` events are generated for formerly obscured windows.
*
*/
xcb_void_cookie_t
xcb_unmap_window (xcb_connection_t *c,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_unmap_subwindows_checked (xcb_connection_t *c,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_unmap_subwindows (xcb_connection_t *c,
xcb_window_t window);
int
xcb_configure_window_value_list_serialize (void **_buffer,
uint16_t value_mask,
const xcb_configure_window_value_list_t *_aux);
int
xcb_configure_window_value_list_unpack (const void *_buffer,
uint16_t value_mask,
xcb_configure_window_value_list_t *_aux);
int
xcb_configure_window_value_list_sizeof (const void *_buffer,
uint16_t value_mask);
int
xcb_configure_window_sizeof (const void *_buffer);
/**
* @brief Configures window attributes
*
* @param c The connection
* @param window The window to configure.
* @param value_mask Bitmask of attributes to change.
* @param value_list New values, corresponding to the attributes in value_mask. The order has to
* correspond to the order of possible \a value_mask bits. See the example.
* @return A cookie
*
* Configures a window's size, position, border width and stacking order.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_configure_window_checked (xcb_connection_t *c,
xcb_window_t window,
uint16_t value_mask,
const void *value_list);
/**
* @brief Configures window attributes
*
* @param c The connection
* @param window The window to configure.
* @param value_mask Bitmask of attributes to change.
* @param value_list New values, corresponding to the attributes in value_mask. The order has to
* correspond to the order of possible \a value_mask bits. See the example.
* @return A cookie
*
* Configures a window's size, position, border width and stacking order.
*
*/
xcb_void_cookie_t
xcb_configure_window (xcb_connection_t *c,
xcb_window_t window,
uint16_t value_mask,
const void *value_list);
/**
* @brief Configures window attributes
*
* @param c The connection
* @param window The window to configure.
* @param value_mask Bitmask of attributes to change.
* @param value_list New values, corresponding to the attributes in value_mask. The order has to
* correspond to the order of possible \a value_mask bits. See the example.
* @return A cookie
*
* Configures a window's size, position, border width and stacking order.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_configure_window_aux_checked (xcb_connection_t *c,
xcb_window_t window,
uint16_t value_mask,
const xcb_configure_window_value_list_t *value_list);
/**
* @brief Configures window attributes
*
* @param c The connection
* @param window The window to configure.
* @param value_mask Bitmask of attributes to change.
* @param value_list New values, corresponding to the attributes in value_mask. The order has to
* correspond to the order of possible \a value_mask bits. See the example.
* @return A cookie
*
* Configures a window's size, position, border width and stacking order.
*
*/
xcb_void_cookie_t
xcb_configure_window_aux (xcb_connection_t *c,
xcb_window_t window,
uint16_t value_mask,
const xcb_configure_window_value_list_t *value_list);
void *
xcb_configure_window_value_list (const xcb_configure_window_request_t *R);
/**
* @brief Change window stacking order
*
* @param c The connection
* @param direction A bitmask of #xcb_circulate_t values.
* @param direction \n
* @param window The window to raise/lower (depending on \a direction).
* @return A cookie
*
* If \a direction is `XCB_CIRCULATE_RAISE_LOWEST`, the lowest mapped child (if
* any) will be raised to the top of the stack.
*
* If \a direction is `XCB_CIRCULATE_LOWER_HIGHEST`, the highest mapped child will
* be lowered to the bottom of the stack.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_circulate_window_checked (xcb_connection_t *c,
uint8_t direction,
xcb_window_t window);
/**
* @brief Change window stacking order
*
* @param c The connection
* @param direction A bitmask of #xcb_circulate_t values.
* @param direction \n
* @param window The window to raise/lower (depending on \a direction).
* @return A cookie
*
* If \a direction is `XCB_CIRCULATE_RAISE_LOWEST`, the lowest mapped child (if
* any) will be raised to the top of the stack.
*
* If \a direction is `XCB_CIRCULATE_LOWER_HIGHEST`, the highest mapped child will
* be lowered to the bottom of the stack.
*
*/
xcb_void_cookie_t
xcb_circulate_window (xcb_connection_t *c,
uint8_t direction,
xcb_window_t window);
/**
* @brief Get current window geometry
*
* @param c The connection
* @param drawable The drawable (`Window` or `Pixmap`) of which the geometry will be received.
* @return A cookie
*
* Gets the current geometry of the specified drawable (either `Window` or `Pixmap`).
*
*/
xcb_get_geometry_cookie_t
xcb_get_geometry (xcb_connection_t *c,
xcb_drawable_t drawable);
/**
* @brief Get current window geometry
*
* @param c The connection
* @param drawable The drawable (`Window` or `Pixmap`) of which the geometry will be received.
* @return A cookie
*
* Gets the current geometry of the specified drawable (either `Window` or `Pixmap`).
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_get_geometry_cookie_t
xcb_get_geometry_unchecked (xcb_connection_t *c,
xcb_drawable_t drawable);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_get_geometry_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_get_geometry_reply_t *
xcb_get_geometry_reply (xcb_connection_t *c,
xcb_get_geometry_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_query_tree_sizeof (const void *_buffer);
/**
* @brief query the window tree
*
* @param c The connection
* @param window The \a window to query.
* @return A cookie
*
* Gets the root window ID, parent window ID and list of children windows for the
* specified \a window. The children are listed in bottom-to-top stacking order.
*
*/
xcb_query_tree_cookie_t
xcb_query_tree (xcb_connection_t *c,
xcb_window_t window);
/**
* @brief query the window tree
*
* @param c The connection
* @param window The \a window to query.
* @return A cookie
*
* Gets the root window ID, parent window ID and list of children windows for the
* specified \a window. The children are listed in bottom-to-top stacking order.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_query_tree_cookie_t
xcb_query_tree_unchecked (xcb_connection_t *c,
xcb_window_t window);
xcb_window_t *
xcb_query_tree_children (const xcb_query_tree_reply_t *R);
int
xcb_query_tree_children_length (const xcb_query_tree_reply_t *R);
xcb_generic_iterator_t
xcb_query_tree_children_end (const xcb_query_tree_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_query_tree_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_query_tree_reply_t *
xcb_query_tree_reply (xcb_connection_t *c,
xcb_query_tree_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_intern_atom_sizeof (const void *_buffer);
/**
* @brief Get atom identifier by name
*
* @param c The connection
* @param only_if_exists Return a valid atom id only if the atom already exists.
* @param name_len The length of the following \a name.
* @param name The name of the atom.
* @return A cookie
*
* Retrieves the identifier (xcb_atom_t TODO) for the atom with the specified
* name. Atoms are used in protocols like EWMH, for example to store window titles
* (`_NET_WM_NAME` atom) as property of a window.
*
* If \a only_if_exists is 0, the atom will be created if it does not already exist.
* If \a only_if_exists is 1, `XCB_ATOM_NONE` will be returned if the atom does
* not yet exist.
*
*/
xcb_intern_atom_cookie_t
xcb_intern_atom (xcb_connection_t *c,
uint8_t only_if_exists,
uint16_t name_len,
const char *name);
/**
* @brief Get atom identifier by name
*
* @param c The connection
* @param only_if_exists Return a valid atom id only if the atom already exists.
* @param name_len The length of the following \a name.
* @param name The name of the atom.
* @return A cookie
*
* Retrieves the identifier (xcb_atom_t TODO) for the atom with the specified
* name. Atoms are used in protocols like EWMH, for example to store window titles
* (`_NET_WM_NAME` atom) as property of a window.
*
* If \a only_if_exists is 0, the atom will be created if it does not already exist.
* If \a only_if_exists is 1, `XCB_ATOM_NONE` will be returned if the atom does
* not yet exist.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_intern_atom_cookie_t
xcb_intern_atom_unchecked (xcb_connection_t *c,
uint8_t only_if_exists,
uint16_t name_len,
const char *name);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_intern_atom_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_intern_atom_reply_t *
xcb_intern_atom_reply (xcb_connection_t *c,
xcb_intern_atom_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_get_atom_name_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_get_atom_name_cookie_t
xcb_get_atom_name (xcb_connection_t *c,
xcb_atom_t atom);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_get_atom_name_cookie_t
xcb_get_atom_name_unchecked (xcb_connection_t *c,
xcb_atom_t atom);
char *
xcb_get_atom_name_name (const xcb_get_atom_name_reply_t *R);
int
xcb_get_atom_name_name_length (const xcb_get_atom_name_reply_t *R);
xcb_generic_iterator_t
xcb_get_atom_name_name_end (const xcb_get_atom_name_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_get_atom_name_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_get_atom_name_reply_t *
xcb_get_atom_name_reply (xcb_connection_t *c,
xcb_get_atom_name_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_change_property_sizeof (const void *_buffer);
/**
* @brief Changes a window property
*
* @param c The connection
* @param mode A bitmask of #xcb_prop_mode_t values.
* @param mode \n
* @param window The window whose property you want to change.
* @param property The property you want to change (an atom).
* @param type The type of the property you want to change (an atom).
* @param format Specifies whether the data should be viewed as a list of 8-bit, 16-bit or
* 32-bit quantities. Possible values are 8, 16 and 32. This information allows
* the X server to correctly perform byte-swap operations as necessary.
* @param data_len Specifies the number of elements (see \a format).
* @param data The property data.
* @return A cookie
*
* Sets or updates a property on the specified \a window. Properties are for
* example the window title (`WM_NAME`) or its minimum size (`WM_NORMAL_HINTS`).
* Protocols such as EWMH also use properties - for example EWMH defines the
* window title, encoded as UTF-8 string, in the `_NET_WM_NAME` property.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_change_property_checked (xcb_connection_t *c,
uint8_t mode,
xcb_window_t window,
xcb_atom_t property,
xcb_atom_t type,
uint8_t format,
uint32_t data_len,
const void *data);
/**
* @brief Changes a window property
*
* @param c The connection
* @param mode A bitmask of #xcb_prop_mode_t values.
* @param mode \n
* @param window The window whose property you want to change.
* @param property The property you want to change (an atom).
* @param type The type of the property you want to change (an atom).
* @param format Specifies whether the data should be viewed as a list of 8-bit, 16-bit or
* 32-bit quantities. Possible values are 8, 16 and 32. This information allows
* the X server to correctly perform byte-swap operations as necessary.
* @param data_len Specifies the number of elements (see \a format).
* @param data The property data.
* @return A cookie
*
* Sets or updates a property on the specified \a window. Properties are for
* example the window title (`WM_NAME`) or its minimum size (`WM_NORMAL_HINTS`).
* Protocols such as EWMH also use properties - for example EWMH defines the
* window title, encoded as UTF-8 string, in the `_NET_WM_NAME` property.
*
*/
xcb_void_cookie_t
xcb_change_property (xcb_connection_t *c,
uint8_t mode,
xcb_window_t window,
xcb_atom_t property,
xcb_atom_t type,
uint8_t format,
uint32_t data_len,
const void *data);
void *
xcb_change_property_data (const xcb_change_property_request_t *R);
int
xcb_change_property_data_length (const xcb_change_property_request_t *R);
xcb_generic_iterator_t
xcb_change_property_data_end (const xcb_change_property_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_delete_property_checked (xcb_connection_t *c,
xcb_window_t window,
xcb_atom_t property);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_delete_property (xcb_connection_t *c,
xcb_window_t window,
xcb_atom_t property);
int
xcb_get_property_sizeof (const void *_buffer);
/**
* @brief Gets a window property
*
* @param c The connection
* @param _delete Whether the property should actually be deleted. For deleting a property, the
* specified \a type has to match the actual property type.
* @param window The window whose property you want to get.
* @param property The property you want to get (an atom).
* @param type The type of the property you want to get (an atom).
* @param long_offset Specifies the offset (in 32-bit multiples) in the specified property where the
* data is to be retrieved.
* @param long_length Specifies how many 32-bit multiples of data should be retrieved (e.g. if you
* set \a long_length to 4, you will receive 16 bytes of data).
* @return A cookie
*
* Gets the specified \a property from the specified \a window. Properties are for
* example the window title (`WM_NAME`) or its minimum size (`WM_NORMAL_HINTS`).
* Protocols such as EWMH also use properties - for example EWMH defines the
* window title, encoded as UTF-8 string, in the `_NET_WM_NAME` property.
*
* TODO: talk about \a type
*
* TODO: talk about `delete`
*
* TODO: talk about the offset/length thing. what's a valid use case?
*
*/
xcb_get_property_cookie_t
xcb_get_property (xcb_connection_t *c,
uint8_t _delete,
xcb_window_t window,
xcb_atom_t property,
xcb_atom_t type,
uint32_t long_offset,
uint32_t long_length);
/**
* @brief Gets a window property
*
* @param c The connection
* @param _delete Whether the property should actually be deleted. For deleting a property, the
* specified \a type has to match the actual property type.
* @param window The window whose property you want to get.
* @param property The property you want to get (an atom).
* @param type The type of the property you want to get (an atom).
* @param long_offset Specifies the offset (in 32-bit multiples) in the specified property where the
* data is to be retrieved.
* @param long_length Specifies how many 32-bit multiples of data should be retrieved (e.g. if you
* set \a long_length to 4, you will receive 16 bytes of data).
* @return A cookie
*
* Gets the specified \a property from the specified \a window. Properties are for
* example the window title (`WM_NAME`) or its minimum size (`WM_NORMAL_HINTS`).
* Protocols such as EWMH also use properties - for example EWMH defines the
* window title, encoded as UTF-8 string, in the `_NET_WM_NAME` property.
*
* TODO: talk about \a type
*
* TODO: talk about `delete`
*
* TODO: talk about the offset/length thing. what's a valid use case?
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_get_property_cookie_t
xcb_get_property_unchecked (xcb_connection_t *c,
uint8_t _delete,
xcb_window_t window,
xcb_atom_t property,
xcb_atom_t type,
uint32_t long_offset,
uint32_t long_length);
void *
xcb_get_property_value (const xcb_get_property_reply_t *R);
int
xcb_get_property_value_length (const xcb_get_property_reply_t *R);
xcb_generic_iterator_t
xcb_get_property_value_end (const xcb_get_property_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_get_property_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_get_property_reply_t *
xcb_get_property_reply (xcb_connection_t *c,
xcb_get_property_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_list_properties_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_list_properties_cookie_t
xcb_list_properties (xcb_connection_t *c,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_list_properties_cookie_t
xcb_list_properties_unchecked (xcb_connection_t *c,
xcb_window_t window);
xcb_atom_t *
xcb_list_properties_atoms (const xcb_list_properties_reply_t *R);
int
xcb_list_properties_atoms_length (const xcb_list_properties_reply_t *R);
xcb_generic_iterator_t
xcb_list_properties_atoms_end (const xcb_list_properties_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_list_properties_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_list_properties_reply_t *
xcb_list_properties_reply (xcb_connection_t *c,
xcb_list_properties_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
* @brief Sets the owner of a selection
*
* @param c The connection
* @param owner The new owner of the selection.
* \n
* The special value `XCB_NONE` means that the selection will have no owner.
* @param selection The selection.
* @param time Timestamp to avoid race conditions when running X over the network.
* \n
* The selection will not be changed if \a time is earlier than the current
* last-change time of the \a selection or is later than the current X server time.
* Otherwise, the last-change time is set to the specified time.
* \n
* The special value `XCB_CURRENT_TIME` will be replaced with the current server
* time.
* @return A cookie
*
* Makes `window` the owner of the selection \a selection and updates the
* last-change time of the specified selection.
*
* TODO: briefly explain what a selection is.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_set_selection_owner_checked (xcb_connection_t *c,
xcb_window_t owner,
xcb_atom_t selection,
xcb_timestamp_t time);
/**
* @brief Sets the owner of a selection
*
* @param c The connection
* @param owner The new owner of the selection.
* \n
* The special value `XCB_NONE` means that the selection will have no owner.
* @param selection The selection.
* @param time Timestamp to avoid race conditions when running X over the network.
* \n
* The selection will not be changed if \a time is earlier than the current
* last-change time of the \a selection or is later than the current X server time.
* Otherwise, the last-change time is set to the specified time.
* \n
* The special value `XCB_CURRENT_TIME` will be replaced with the current server
* time.
* @return A cookie
*
* Makes `window` the owner of the selection \a selection and updates the
* last-change time of the specified selection.
*
* TODO: briefly explain what a selection is.
*
*/
xcb_void_cookie_t
xcb_set_selection_owner (xcb_connection_t *c,
xcb_window_t owner,
xcb_atom_t selection,
xcb_timestamp_t time);
/**
* @brief Gets the owner of a selection
*
* @param c The connection
* @param selection The selection.
* @return A cookie
*
* Gets the owner of the specified selection.
*
* TODO: briefly explain what a selection is.
*
*/
xcb_get_selection_owner_cookie_t
xcb_get_selection_owner (xcb_connection_t *c,
xcb_atom_t selection);
/**
* @brief Gets the owner of a selection
*
* @param c The connection
* @param selection The selection.
* @return A cookie
*
* Gets the owner of the specified selection.
*
* TODO: briefly explain what a selection is.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_get_selection_owner_cookie_t
xcb_get_selection_owner_unchecked (xcb_connection_t *c,
xcb_atom_t selection);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_get_selection_owner_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_get_selection_owner_reply_t *
xcb_get_selection_owner_reply (xcb_connection_t *c,
xcb_get_selection_owner_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_convert_selection_checked (xcb_connection_t *c,
xcb_window_t requestor,
xcb_atom_t selection,
xcb_atom_t target,
xcb_atom_t property,
xcb_timestamp_t time);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_convert_selection (xcb_connection_t *c,
xcb_window_t requestor,
xcb_atom_t selection,
xcb_atom_t target,
xcb_atom_t property,
xcb_timestamp_t time);
/**
* @brief send an event
*
* @param c The connection
* @param propagate If \a propagate is true and no clients have selected any event on \a destination,
* the destination is replaced with the closest ancestor of \a destination for
* which some client has selected a type in \a event_mask and for which no
* intervening window has that type in its do-not-propagate-mask. If no such
* window exists or if the window is an ancestor of the focus window and
* `InputFocus` was originally specified as the destination, the event is not sent
* to any clients. Otherwise, the event is reported to every client selecting on
* the final destination any of the types specified in \a event_mask.
* @param destination The window to send this event to. Every client which selects any event within
* \a event_mask on \a destination will get the event.
* \n
* The special value `XCB_SEND_EVENT_DEST_POINTER_WINDOW` refers to the window
* that contains the mouse pointer.
* \n
* The special value `XCB_SEND_EVENT_DEST_ITEM_FOCUS` refers to the window which
* has the keyboard focus.
* @param event_mask Event_mask for determining which clients should receive the specified event.
* See \a destination and \a propagate.
* @param event The event to send to the specified \a destination.
* @return A cookie
*
* Identifies the \a destination window, determines which clients should receive
* the specified event and ignores any active grabs.
*
* The \a event must be one of the core events or an event defined by an extension,
* so that the X server can correctly byte-swap the contents as necessary. The
* contents of \a event are otherwise unaltered and unchecked except for the
* `send_event` field which is forced to 'true'.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_send_event_checked (xcb_connection_t *c,
uint8_t propagate,
xcb_window_t destination,
uint32_t event_mask,
const char *event);
/**
* @brief send an event
*
* @param c The connection
* @param propagate If \a propagate is true and no clients have selected any event on \a destination,
* the destination is replaced with the closest ancestor of \a destination for
* which some client has selected a type in \a event_mask and for which no
* intervening window has that type in its do-not-propagate-mask. If no such
* window exists or if the window is an ancestor of the focus window and
* `InputFocus` was originally specified as the destination, the event is not sent
* to any clients. Otherwise, the event is reported to every client selecting on
* the final destination any of the types specified in \a event_mask.
* @param destination The window to send this event to. Every client which selects any event within
* \a event_mask on \a destination will get the event.
* \n
* The special value `XCB_SEND_EVENT_DEST_POINTER_WINDOW` refers to the window
* that contains the mouse pointer.
* \n
* The special value `XCB_SEND_EVENT_DEST_ITEM_FOCUS` refers to the window which
* has the keyboard focus.
* @param event_mask Event_mask for determining which clients should receive the specified event.
* See \a destination and \a propagate.
* @param event The event to send to the specified \a destination.
* @return A cookie
*
* Identifies the \a destination window, determines which clients should receive
* the specified event and ignores any active grabs.
*
* The \a event must be one of the core events or an event defined by an extension,
* so that the X server can correctly byte-swap the contents as necessary. The
* contents of \a event are otherwise unaltered and unchecked except for the
* `send_event` field which is forced to 'true'.
*
*/
xcb_void_cookie_t
xcb_send_event (xcb_connection_t *c,
uint8_t propagate,
xcb_window_t destination,
uint32_t event_mask,
const char *event);
/**
* @brief Grab the pointer
*
* @param c The connection
* @param owner_events If 1, the \a grab_window will still get the pointer events. If 0, events are not
* reported to the \a grab_window.
* @param grab_window Specifies the window on which the pointer should be grabbed.
* @param event_mask Specifies which pointer events are reported to the client.
* \n
* TODO: which values?
* @param pointer_mode A bitmask of #xcb_grab_mode_t values.
* @param pointer_mode \n
* @param keyboard_mode A bitmask of #xcb_grab_mode_t values.
* @param keyboard_mode \n
* @param confine_to Specifies the window to confine the pointer in (the user will not be able to
* move the pointer out of that window).
* \n
* The special value `XCB_NONE` means don't confine the pointer.
* @param cursor Specifies the cursor that should be displayed or `XCB_NONE` to not change the
* cursor.
* @param time The time argument allows you to avoid certain circumstances that come up if
* applications take a long time to respond or if there are long network delays.
* Consider a situation where you have two applications, both of which normally
* grab the pointer when clicked on. If both applications specify the timestamp
* from the event, the second application may wake up faster and successfully grab
* the pointer before the first application. The first application then will get
* an indication that the other application grabbed the pointer before its request
* was processed.
* \n
* The special value `XCB_CURRENT_TIME` will be replaced with the current server
* time.
* @return A cookie
*
* Actively grabs control of the pointer. Further pointer events are reported only to the grabbing client. Overrides any active pointer grab by this client.
*
*/
xcb_grab_pointer_cookie_t
xcb_grab_pointer (xcb_connection_t *c,
uint8_t owner_events,
xcb_window_t grab_window,
uint16_t event_mask,
uint8_t pointer_mode,
uint8_t keyboard_mode,
xcb_window_t confine_to,
xcb_cursor_t cursor,
xcb_timestamp_t time);
/**
* @brief Grab the pointer
*
* @param c The connection
* @param owner_events If 1, the \a grab_window will still get the pointer events. If 0, events are not
* reported to the \a grab_window.
* @param grab_window Specifies the window on which the pointer should be grabbed.
* @param event_mask Specifies which pointer events are reported to the client.
* \n
* TODO: which values?
* @param pointer_mode A bitmask of #xcb_grab_mode_t values.
* @param pointer_mode \n
* @param keyboard_mode A bitmask of #xcb_grab_mode_t values.
* @param keyboard_mode \n
* @param confine_to Specifies the window to confine the pointer in (the user will not be able to
* move the pointer out of that window).
* \n
* The special value `XCB_NONE` means don't confine the pointer.
* @param cursor Specifies the cursor that should be displayed or `XCB_NONE` to not change the
* cursor.
* @param time The time argument allows you to avoid certain circumstances that come up if
* applications take a long time to respond or if there are long network delays.
* Consider a situation where you have two applications, both of which normally
* grab the pointer when clicked on. If both applications specify the timestamp
* from the event, the second application may wake up faster and successfully grab
* the pointer before the first application. The first application then will get
* an indication that the other application grabbed the pointer before its request
* was processed.
* \n
* The special value `XCB_CURRENT_TIME` will be replaced with the current server
* time.
* @return A cookie
*
* Actively grabs control of the pointer. Further pointer events are reported only to the grabbing client. Overrides any active pointer grab by this client.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_grab_pointer_cookie_t
xcb_grab_pointer_unchecked (xcb_connection_t *c,
uint8_t owner_events,
xcb_window_t grab_window,
uint16_t event_mask,
uint8_t pointer_mode,
uint8_t keyboard_mode,
xcb_window_t confine_to,
xcb_cursor_t cursor,
xcb_timestamp_t time);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_grab_pointer_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_grab_pointer_reply_t *
xcb_grab_pointer_reply (xcb_connection_t *c,
xcb_grab_pointer_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
* @brief release the pointer
*
* @param c The connection
* @param time Timestamp to avoid race conditions when running X over the network.
* \n
* The pointer will not be released if \a time is earlier than the
* last-pointer-grab time or later than the current X server time.
* @return A cookie
*
* Releases the pointer and any queued events if you actively grabbed the pointer
* before using `xcb_grab_pointer`, `xcb_grab_button` or within a normal button
* press.
*
* EnterNotify and LeaveNotify events are generated.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_ungrab_pointer_checked (xcb_connection_t *c,
xcb_timestamp_t time);
/**
* @brief release the pointer
*
* @param c The connection
* @param time Timestamp to avoid race conditions when running X over the network.
* \n
* The pointer will not be released if \a time is earlier than the
* last-pointer-grab time or later than the current X server time.
* @return A cookie
*
* Releases the pointer and any queued events if you actively grabbed the pointer
* before using `xcb_grab_pointer`, `xcb_grab_button` or within a normal button
* press.
*
* EnterNotify and LeaveNotify events are generated.
*
*/
xcb_void_cookie_t
xcb_ungrab_pointer (xcb_connection_t *c,
xcb_timestamp_t time);
/**
* @brief Grab pointer button(s)
*
* @param c The connection
* @param owner_events If 1, the \a grab_window will still get the pointer events. If 0, events are not
* reported to the \a grab_window.
* @param grab_window Specifies the window on which the pointer should be grabbed.
* @param event_mask Specifies which pointer events are reported to the client.
* \n
* TODO: which values?
* @param pointer_mode A bitmask of #xcb_grab_mode_t values.
* @param pointer_mode \n
* @param keyboard_mode A bitmask of #xcb_grab_mode_t values.
* @param keyboard_mode \n
* @param confine_to Specifies the window to confine the pointer in (the user will not be able to
* move the pointer out of that window).
* \n
* The special value `XCB_NONE` means don't confine the pointer.
* @param cursor Specifies the cursor that should be displayed or `XCB_NONE` to not change the
* cursor.
* @param button A bitmask of #xcb_button_index_t values.
* @param button \n
* @param modifiers The modifiers to grab.
* \n
* Using the special value `XCB_MOD_MASK_ANY` means grab the pointer with all
* possible modifier combinations.
* @return A cookie
*
* This request establishes a passive grab. The pointer is actively grabbed as
* described in GrabPointer, the last-pointer-grab time is set to the time at
* which the button was pressed (as transmitted in the ButtonPress event), and the
* ButtonPress event is reported if all of the following conditions are true:
*
* The pointer is not grabbed and the specified button is logically pressed when
* the specified modifier keys are logically down, and no other buttons or
* modifier keys are logically down.
*
* The grab-window contains the pointer.
*
* The confine-to window (if any) is viewable.
*
* A passive grab on the same button/key combination does not exist on any
* ancestor of grab-window.
*
* The interpretation of the remaining arguments is the same as for GrabPointer.
* The active grab is terminated automatically when the logical state of the
* pointer has all buttons released, independent of the logical state of modifier
* keys. Note that the logical state of a device (as seen by means of the
* protocol) may lag the physical state if device event processing is frozen. This
* request overrides all previous passive grabs by the same client on the same
* button/key combinations on the same window. A modifier of AnyModifier is
* equivalent to issuing the request for all possible modifier combinations
* (including the combination of no modifiers). It is not required that all
* specified modifiers have currently assigned keycodes. A button of AnyButton is
* equivalent to issuing the request for all possible buttons. Otherwise, it is
* not required that the button specified currently be assigned to a physical
* button.
*
* An Access error is generated if some other client has already issued a
* GrabButton request with the same button/key combination on the same window.
* When using AnyModifier or AnyButton, the request fails completely (no grabs are
* established), and an Access error is generated if there is a conflicting grab
* for any combination. The request has no effect on an active grab.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_grab_button_checked (xcb_connection_t *c,
uint8_t owner_events,
xcb_window_t grab_window,
uint16_t event_mask,
uint8_t pointer_mode,
uint8_t keyboard_mode,
xcb_window_t confine_to,
xcb_cursor_t cursor,
uint8_t button,
uint16_t modifiers);
/**
* @brief Grab pointer button(s)
*
* @param c The connection
* @param owner_events If 1, the \a grab_window will still get the pointer events. If 0, events are not
* reported to the \a grab_window.
* @param grab_window Specifies the window on which the pointer should be grabbed.
* @param event_mask Specifies which pointer events are reported to the client.
* \n
* TODO: which values?
* @param pointer_mode A bitmask of #xcb_grab_mode_t values.
* @param pointer_mode \n
* @param keyboard_mode A bitmask of #xcb_grab_mode_t values.
* @param keyboard_mode \n
* @param confine_to Specifies the window to confine the pointer in (the user will not be able to
* move the pointer out of that window).
* \n
* The special value `XCB_NONE` means don't confine the pointer.
* @param cursor Specifies the cursor that should be displayed or `XCB_NONE` to not change the
* cursor.
* @param button A bitmask of #xcb_button_index_t values.
* @param button \n
* @param modifiers The modifiers to grab.
* \n
* Using the special value `XCB_MOD_MASK_ANY` means grab the pointer with all
* possible modifier combinations.
* @return A cookie
*
* This request establishes a passive grab. The pointer is actively grabbed as
* described in GrabPointer, the last-pointer-grab time is set to the time at
* which the button was pressed (as transmitted in the ButtonPress event), and the
* ButtonPress event is reported if all of the following conditions are true:
*
* The pointer is not grabbed and the specified button is logically pressed when
* the specified modifier keys are logically down, and no other buttons or
* modifier keys are logically down.
*
* The grab-window contains the pointer.
*
* The confine-to window (if any) is viewable.
*
* A passive grab on the same button/key combination does not exist on any
* ancestor of grab-window.
*
* The interpretation of the remaining arguments is the same as for GrabPointer.
* The active grab is terminated automatically when the logical state of the
* pointer has all buttons released, independent of the logical state of modifier
* keys. Note that the logical state of a device (as seen by means of the
* protocol) may lag the physical state if device event processing is frozen. This
* request overrides all previous passive grabs by the same client on the same
* button/key combinations on the same window. A modifier of AnyModifier is
* equivalent to issuing the request for all possible modifier combinations
* (including the combination of no modifiers). It is not required that all
* specified modifiers have currently assigned keycodes. A button of AnyButton is
* equivalent to issuing the request for all possible buttons. Otherwise, it is
* not required that the button specified currently be assigned to a physical
* button.
*
* An Access error is generated if some other client has already issued a
* GrabButton request with the same button/key combination on the same window.
* When using AnyModifier or AnyButton, the request fails completely (no grabs are
* established), and an Access error is generated if there is a conflicting grab
* for any combination. The request has no effect on an active grab.
*
*/
xcb_void_cookie_t
xcb_grab_button (xcb_connection_t *c,
uint8_t owner_events,
xcb_window_t grab_window,
uint16_t event_mask,
uint8_t pointer_mode,
uint8_t keyboard_mode,
xcb_window_t confine_to,
xcb_cursor_t cursor,
uint8_t button,
uint16_t modifiers);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_ungrab_button_checked (xcb_connection_t *c,
uint8_t button,
xcb_window_t grab_window,
uint16_t modifiers);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_ungrab_button (xcb_connection_t *c,
uint8_t button,
xcb_window_t grab_window,
uint16_t modifiers);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_change_active_pointer_grab_checked (xcb_connection_t *c,
xcb_cursor_t cursor,
xcb_timestamp_t time,
uint16_t event_mask);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_change_active_pointer_grab (xcb_connection_t *c,
xcb_cursor_t cursor,
xcb_timestamp_t time,
uint16_t event_mask);
/**
* @brief Grab the keyboard
*
* @param c The connection
* @param owner_events If 1, the \a grab_window will still get the pointer events. If 0, events are not
* reported to the \a grab_window.
* @param grab_window Specifies the window on which the pointer should be grabbed.
* @param time Timestamp to avoid race conditions when running X over the network.
* \n
* The special value `XCB_CURRENT_TIME` will be replaced with the current server
* time.
* @param pointer_mode A bitmask of #xcb_grab_mode_t values.
* @param pointer_mode \n
* @param keyboard_mode A bitmask of #xcb_grab_mode_t values.
* @param keyboard_mode \n
* @return A cookie
*
* Actively grabs control of the keyboard and generates FocusIn and FocusOut
* events. Further key events are reported only to the grabbing client.
*
* Any active keyboard grab by this client is overridden. If the keyboard is
* actively grabbed by some other client, `AlreadyGrabbed` is returned. If
* \a grab_window is not viewable, `GrabNotViewable` is returned. If the keyboard
* is frozen by an active grab of another client, `GrabFrozen` is returned. If the
* specified \a time is earlier than the last-keyboard-grab time or later than the
* current X server time, `GrabInvalidTime` is returned. Otherwise, the
* last-keyboard-grab time is set to the specified time.
*
*/
xcb_grab_keyboard_cookie_t
xcb_grab_keyboard (xcb_connection_t *c,
uint8_t owner_events,
xcb_window_t grab_window,
xcb_timestamp_t time,
uint8_t pointer_mode,
uint8_t keyboard_mode);
/**
* @brief Grab the keyboard
*
* @param c The connection
* @param owner_events If 1, the \a grab_window will still get the pointer events. If 0, events are not
* reported to the \a grab_window.
* @param grab_window Specifies the window on which the pointer should be grabbed.
* @param time Timestamp to avoid race conditions when running X over the network.
* \n
* The special value `XCB_CURRENT_TIME` will be replaced with the current server
* time.
* @param pointer_mode A bitmask of #xcb_grab_mode_t values.
* @param pointer_mode \n
* @param keyboard_mode A bitmask of #xcb_grab_mode_t values.
* @param keyboard_mode \n
* @return A cookie
*
* Actively grabs control of the keyboard and generates FocusIn and FocusOut
* events. Further key events are reported only to the grabbing client.
*
* Any active keyboard grab by this client is overridden. If the keyboard is
* actively grabbed by some other client, `AlreadyGrabbed` is returned. If
* \a grab_window is not viewable, `GrabNotViewable` is returned. If the keyboard
* is frozen by an active grab of another client, `GrabFrozen` is returned. If the
* specified \a time is earlier than the last-keyboard-grab time or later than the
* current X server time, `GrabInvalidTime` is returned. Otherwise, the
* last-keyboard-grab time is set to the specified time.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_grab_keyboard_cookie_t
xcb_grab_keyboard_unchecked (xcb_connection_t *c,
uint8_t owner_events,
xcb_window_t grab_window,
xcb_timestamp_t time,
uint8_t pointer_mode,
uint8_t keyboard_mode);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_grab_keyboard_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_grab_keyboard_reply_t *
xcb_grab_keyboard_reply (xcb_connection_t *c,
xcb_grab_keyboard_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_ungrab_keyboard_checked (xcb_connection_t *c,
xcb_timestamp_t time);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_ungrab_keyboard (xcb_connection_t *c,
xcb_timestamp_t time);
/**
* @brief Grab keyboard key(s)
*
* @param c The connection
* @param owner_events If 1, the \a grab_window will still get the pointer events. If 0, events are not
* reported to the \a grab_window.
* @param grab_window Specifies the window on which the pointer should be grabbed.
* @param modifiers The modifiers to grab.
* \n
* Using the special value `XCB_MOD_MASK_ANY` means grab the pointer with all
* possible modifier combinations.
* @param key The keycode of the key to grab.
* \n
* The special value `XCB_GRAB_ANY` means grab any key.
* @param pointer_mode A bitmask of #xcb_grab_mode_t values.
* @param pointer_mode \n
* @param keyboard_mode A bitmask of #xcb_grab_mode_t values.
* @param keyboard_mode \n
* @return A cookie
*
* Establishes a passive grab on the keyboard. In the future, the keyboard is
* actively grabbed (as for `GrabKeyboard`), the last-keyboard-grab time is set to
* the time at which the key was pressed (as transmitted in the KeyPress event),
* and the KeyPress event is reported if all of the following conditions are true:
*
* The keyboard is not grabbed and the specified key (which can itself be a
* modifier key) is logically pressed when the specified modifier keys are
* logically down, and no other modifier keys are logically down.
*
* Either the grab_window is an ancestor of (or is) the focus window, or the
* grab_window is a descendant of the focus window and contains the pointer.
*
* A passive grab on the same key combination does not exist on any ancestor of
* grab_window.
*
* The interpretation of the remaining arguments is as for XGrabKeyboard. The active grab is terminated
* automatically when the logical state of the keyboard has the specified key released (independent of the
* logical state of the modifier keys), at which point a KeyRelease event is reported to the grabbing window.
*
* Note that the logical state of a device (as seen by client applications) may lag the physical state if
* device event processing is frozen.
*
* A modifiers argument of AnyModifier is equivalent to issuing the request for all possible modifier combinations (including the combination of no modifiers). It is not required that all modifiers specified
* have currently assigned KeyCodes. A keycode argument of AnyKey is equivalent to issuing the request for
* all possible KeyCodes. Otherwise, the specified keycode must be in the range specified by min_keycode
* and max_keycode in the connection setup, or a BadValue error results.
*
* If some other client has issued a XGrabKey with the same key combination on the same window, a BadAccess
* error results. When using AnyModifier or AnyKey, the request fails completely, and a BadAccess error
* results (no grabs are established) if there is a conflicting grab for any combination.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_grab_key_checked (xcb_connection_t *c,
uint8_t owner_events,
xcb_window_t grab_window,
uint16_t modifiers,
xcb_keycode_t key,
uint8_t pointer_mode,
uint8_t keyboard_mode);
/**
* @brief Grab keyboard key(s)
*
* @param c The connection
* @param owner_events If 1, the \a grab_window will still get the pointer events. If 0, events are not
* reported to the \a grab_window.
* @param grab_window Specifies the window on which the pointer should be grabbed.
* @param modifiers The modifiers to grab.
* \n
* Using the special value `XCB_MOD_MASK_ANY` means grab the pointer with all
* possible modifier combinations.
* @param key The keycode of the key to grab.
* \n
* The special value `XCB_GRAB_ANY` means grab any key.
* @param pointer_mode A bitmask of #xcb_grab_mode_t values.
* @param pointer_mode \n
* @param keyboard_mode A bitmask of #xcb_grab_mode_t values.
* @param keyboard_mode \n
* @return A cookie
*
* Establishes a passive grab on the keyboard. In the future, the keyboard is
* actively grabbed (as for `GrabKeyboard`), the last-keyboard-grab time is set to
* the time at which the key was pressed (as transmitted in the KeyPress event),
* and the KeyPress event is reported if all of the following conditions are true:
*
* The keyboard is not grabbed and the specified key (which can itself be a
* modifier key) is logically pressed when the specified modifier keys are
* logically down, and no other modifier keys are logically down.
*
* Either the grab_window is an ancestor of (or is) the focus window, or the
* grab_window is a descendant of the focus window and contains the pointer.
*
* A passive grab on the same key combination does not exist on any ancestor of
* grab_window.
*
* The interpretation of the remaining arguments is as for XGrabKeyboard. The active grab is terminated
* automatically when the logical state of the keyboard has the specified key released (independent of the
* logical state of the modifier keys), at which point a KeyRelease event is reported to the grabbing window.
*
* Note that the logical state of a device (as seen by client applications) may lag the physical state if
* device event processing is frozen.
*
* A modifiers argument of AnyModifier is equivalent to issuing the request for all possible modifier combinations (including the combination of no modifiers). It is not required that all modifiers specified
* have currently assigned KeyCodes. A keycode argument of AnyKey is equivalent to issuing the request for
* all possible KeyCodes. Otherwise, the specified keycode must be in the range specified by min_keycode
* and max_keycode in the connection setup, or a BadValue error results.
*
* If some other client has issued a XGrabKey with the same key combination on the same window, a BadAccess
* error results. When using AnyModifier or AnyKey, the request fails completely, and a BadAccess error
* results (no grabs are established) if there is a conflicting grab for any combination.
*
*/
xcb_void_cookie_t
xcb_grab_key (xcb_connection_t *c,
uint8_t owner_events,
xcb_window_t grab_window,
uint16_t modifiers,
xcb_keycode_t key,
uint8_t pointer_mode,
uint8_t keyboard_mode);
/**
* @brief release a key combination
*
* @param c The connection
* @param key The keycode of the specified key combination.
* \n
* Using the special value `XCB_GRAB_ANY` means releasing all possible key codes.
* @param grab_window The window on which the grabbed key combination will be released.
* @param modifiers The modifiers of the specified key combination.
* \n
* Using the special value `XCB_MOD_MASK_ANY` means releasing the key combination
* with every possible modifier combination.
* @return A cookie
*
* Releases the key combination on \a grab_window if you grabbed it using
* `xcb_grab_key` before.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_ungrab_key_checked (xcb_connection_t *c,
xcb_keycode_t key,
xcb_window_t grab_window,
uint16_t modifiers);
/**
* @brief release a key combination
*
* @param c The connection
* @param key The keycode of the specified key combination.
* \n
* Using the special value `XCB_GRAB_ANY` means releasing all possible key codes.
* @param grab_window The window on which the grabbed key combination will be released.
* @param modifiers The modifiers of the specified key combination.
* \n
* Using the special value `XCB_MOD_MASK_ANY` means releasing the key combination
* with every possible modifier combination.
* @return A cookie
*
* Releases the key combination on \a grab_window if you grabbed it using
* `xcb_grab_key` before.
*
*/
xcb_void_cookie_t
xcb_ungrab_key (xcb_connection_t *c,
xcb_keycode_t key,
xcb_window_t grab_window,
uint16_t modifiers);
/**
* @brief release queued events
*
* @param c The connection
* @param mode A bitmask of #xcb_allow_t values.
* @param mode \n
* @param time Timestamp to avoid race conditions when running X over the network.
* \n
* The special value `XCB_CURRENT_TIME` will be replaced with the current server
* time.
* @return A cookie
*
* Releases queued events if the client has caused a device (pointer/keyboard) to
* freeze due to grabbing it actively. This request has no effect if \a time is
* earlier than the last-grab time of the most recent active grab for this client
* or if \a time is later than the current X server time.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_allow_events_checked (xcb_connection_t *c,
uint8_t mode,
xcb_timestamp_t time);
/**
* @brief release queued events
*
* @param c The connection
* @param mode A bitmask of #xcb_allow_t values.
* @param mode \n
* @param time Timestamp to avoid race conditions when running X over the network.
* \n
* The special value `XCB_CURRENT_TIME` will be replaced with the current server
* time.
* @return A cookie
*
* Releases queued events if the client has caused a device (pointer/keyboard) to
* freeze due to grabbing it actively. This request has no effect if \a time is
* earlier than the last-grab time of the most recent active grab for this client
* or if \a time is later than the current X server time.
*
*/
xcb_void_cookie_t
xcb_allow_events (xcb_connection_t *c,
uint8_t mode,
xcb_timestamp_t time);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_grab_server_checked (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_grab_server (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_ungrab_server_checked (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_ungrab_server (xcb_connection_t *c);
/**
* @brief get pointer coordinates
*
* @param c The connection
* @param window A window to check if the pointer is on the same screen as \a window (see the
* `same_screen` field in the reply).
* @return A cookie
*
* Gets the root window the pointer is logically on and the pointer coordinates
* relative to the root window's origin.
*
*/
xcb_query_pointer_cookie_t
xcb_query_pointer (xcb_connection_t *c,
xcb_window_t window);
/**
* @brief get pointer coordinates
*
* @param c The connection
* @param window A window to check if the pointer is on the same screen as \a window (see the
* `same_screen` field in the reply).
* @return A cookie
*
* Gets the root window the pointer is logically on and the pointer coordinates
* relative to the root window's origin.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_query_pointer_cookie_t
xcb_query_pointer_unchecked (xcb_connection_t *c,
xcb_window_t window);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_query_pointer_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_query_pointer_reply_t *
xcb_query_pointer_reply (xcb_connection_t *c,
xcb_query_pointer_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_timecoord_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_timecoord_t)
*/
void
xcb_timecoord_next (xcb_timecoord_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_timecoord_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_timecoord_end (xcb_timecoord_iterator_t i);
int
xcb_get_motion_events_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_get_motion_events_cookie_t
xcb_get_motion_events (xcb_connection_t *c,
xcb_window_t window,
xcb_timestamp_t start,
xcb_timestamp_t stop);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_get_motion_events_cookie_t
xcb_get_motion_events_unchecked (xcb_connection_t *c,
xcb_window_t window,
xcb_timestamp_t start,
xcb_timestamp_t stop);
xcb_timecoord_t *
xcb_get_motion_events_events (const xcb_get_motion_events_reply_t *R);
int
xcb_get_motion_events_events_length (const xcb_get_motion_events_reply_t *R);
xcb_timecoord_iterator_t
xcb_get_motion_events_events_iterator (const xcb_get_motion_events_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_get_motion_events_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_get_motion_events_reply_t *
xcb_get_motion_events_reply (xcb_connection_t *c,
xcb_get_motion_events_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_translate_coordinates_cookie_t
xcb_translate_coordinates (xcb_connection_t *c,
xcb_window_t src_window,
xcb_window_t dst_window,
int16_t src_x,
int16_t src_y);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_translate_coordinates_cookie_t
xcb_translate_coordinates_unchecked (xcb_connection_t *c,
xcb_window_t src_window,
xcb_window_t dst_window,
int16_t src_x,
int16_t src_y);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_translate_coordinates_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_translate_coordinates_reply_t *
xcb_translate_coordinates_reply (xcb_connection_t *c,
xcb_translate_coordinates_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
* @brief move mouse pointer
*
* @param c The connection
* @param src_window If \a src_window is not `XCB_NONE` (TODO), the move will only take place if the
* pointer is inside \a src_window and within the rectangle specified by (\a src_x,
* \a src_y, \a src_width, \a src_height). The rectangle coordinates are relative to
* \a src_window.
* @param dst_window If \a dst_window is not `XCB_NONE` (TODO), the pointer will be moved to the
* offsets (\a dst_x, \a dst_y) relative to \a dst_window. If \a dst_window is
* `XCB_NONE` (TODO), the pointer will be moved by the offsets (\a dst_x, \a dst_y)
* relative to the current position of the pointer.
* @return A cookie
*
* Moves the mouse pointer to the specified position.
*
* If \a src_window is not `XCB_NONE` (TODO), the move will only take place if the
* pointer is inside \a src_window and within the rectangle specified by (\a src_x,
* \a src_y, \a src_width, \a src_height). The rectangle coordinates are relative to
* \a src_window.
*
* If \a dst_window is not `XCB_NONE` (TODO), the pointer will be moved to the
* offsets (\a dst_x, \a dst_y) relative to \a dst_window. If \a dst_window is
* `XCB_NONE` (TODO), the pointer will be moved by the offsets (\a dst_x, \a dst_y)
* relative to the current position of the pointer.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_warp_pointer_checked (xcb_connection_t *c,
xcb_window_t src_window,
xcb_window_t dst_window,
int16_t src_x,
int16_t src_y,
uint16_t src_width,
uint16_t src_height,
int16_t dst_x,
int16_t dst_y);
/**
* @brief move mouse pointer
*
* @param c The connection
* @param src_window If \a src_window is not `XCB_NONE` (TODO), the move will only take place if the
* pointer is inside \a src_window and within the rectangle specified by (\a src_x,
* \a src_y, \a src_width, \a src_height). The rectangle coordinates are relative to
* \a src_window.
* @param dst_window If \a dst_window is not `XCB_NONE` (TODO), the pointer will be moved to the
* offsets (\a dst_x, \a dst_y) relative to \a dst_window. If \a dst_window is
* `XCB_NONE` (TODO), the pointer will be moved by the offsets (\a dst_x, \a dst_y)
* relative to the current position of the pointer.
* @return A cookie
*
* Moves the mouse pointer to the specified position.
*
* If \a src_window is not `XCB_NONE` (TODO), the move will only take place if the
* pointer is inside \a src_window and within the rectangle specified by (\a src_x,
* \a src_y, \a src_width, \a src_height). The rectangle coordinates are relative to
* \a src_window.
*
* If \a dst_window is not `XCB_NONE` (TODO), the pointer will be moved to the
* offsets (\a dst_x, \a dst_y) relative to \a dst_window. If \a dst_window is
* `XCB_NONE` (TODO), the pointer will be moved by the offsets (\a dst_x, \a dst_y)
* relative to the current position of the pointer.
*
*/
xcb_void_cookie_t
xcb_warp_pointer (xcb_connection_t *c,
xcb_window_t src_window,
xcb_window_t dst_window,
int16_t src_x,
int16_t src_y,
uint16_t src_width,
uint16_t src_height,
int16_t dst_x,
int16_t dst_y);
/**
* @brief Sets input focus
*
* @param c The connection
* @param revert_to A bitmask of #xcb_input_focus_t values.
* @param revert_to Specifies what happens when the \a focus window becomes unviewable (if \a focus
* is neither `XCB_NONE` nor `XCB_POINTER_ROOT`).
* @param focus The window to focus. All keyboard events will be reported to this window. The
* window must be viewable (TODO), or a `xcb_match_error_t` occurs (TODO).
* \n
* If \a focus is `XCB_NONE` (TODO), all keyboard events are
* discarded until a new focus window is set.
* \n
* If \a focus is `XCB_POINTER_ROOT` (TODO), focus is on the root window of the
* screen on which the pointer is on currently.
* @param time Timestamp to avoid race conditions when running X over the network.
* \n
* The special value `XCB_CURRENT_TIME` will be replaced with the current server
* time.
* @return A cookie
*
* Changes the input focus and the last-focus-change time. If the specified \a time
* is earlier than the current last-focus-change time, the request is ignored (to
* avoid race conditions when running X over the network).
*
* A FocusIn and FocusOut event is generated when focus is changed.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_set_input_focus_checked (xcb_connection_t *c,
uint8_t revert_to,
xcb_window_t focus,
xcb_timestamp_t time);
/**
* @brief Sets input focus
*
* @param c The connection
* @param revert_to A bitmask of #xcb_input_focus_t values.
* @param revert_to Specifies what happens when the \a focus window becomes unviewable (if \a focus
* is neither `XCB_NONE` nor `XCB_POINTER_ROOT`).
* @param focus The window to focus. All keyboard events will be reported to this window. The
* window must be viewable (TODO), or a `xcb_match_error_t` occurs (TODO).
* \n
* If \a focus is `XCB_NONE` (TODO), all keyboard events are
* discarded until a new focus window is set.
* \n
* If \a focus is `XCB_POINTER_ROOT` (TODO), focus is on the root window of the
* screen on which the pointer is on currently.
* @param time Timestamp to avoid race conditions when running X over the network.
* \n
* The special value `XCB_CURRENT_TIME` will be replaced with the current server
* time.
* @return A cookie
*
* Changes the input focus and the last-focus-change time. If the specified \a time
* is earlier than the current last-focus-change time, the request is ignored (to
* avoid race conditions when running X over the network).
*
* A FocusIn and FocusOut event is generated when focus is changed.
*
*/
xcb_void_cookie_t
xcb_set_input_focus (xcb_connection_t *c,
uint8_t revert_to,
xcb_window_t focus,
xcb_timestamp_t time);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_get_input_focus_cookie_t
xcb_get_input_focus (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_get_input_focus_cookie_t
xcb_get_input_focus_unchecked (xcb_connection_t *c);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_get_input_focus_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_get_input_focus_reply_t *
xcb_get_input_focus_reply (xcb_connection_t *c,
xcb_get_input_focus_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_query_keymap_cookie_t
xcb_query_keymap (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_query_keymap_cookie_t
xcb_query_keymap_unchecked (xcb_connection_t *c);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_query_keymap_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_query_keymap_reply_t *
xcb_query_keymap_reply (xcb_connection_t *c,
xcb_query_keymap_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_open_font_sizeof (const void *_buffer);
/**
* @brief opens a font
*
* @param c The connection
* @param fid The ID with which you will refer to the font, created by `xcb_generate_id`.
* @param name_len Length (in bytes) of \a name.
* @param name A pattern describing an X core font.
* @return A cookie
*
* Opens any X core font matching the given \a name (for example "-misc-fixed-*").
*
* Note that X core fonts are deprecated (but still supported) in favor of
* client-side rendering using Xft.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_open_font_checked (xcb_connection_t *c,
xcb_font_t fid,
uint16_t name_len,
const char *name);
/**
* @brief opens a font
*
* @param c The connection
* @param fid The ID with which you will refer to the font, created by `xcb_generate_id`.
* @param name_len Length (in bytes) of \a name.
* @param name A pattern describing an X core font.
* @return A cookie
*
* Opens any X core font matching the given \a name (for example "-misc-fixed-*").
*
* Note that X core fonts are deprecated (but still supported) in favor of
* client-side rendering using Xft.
*
*/
xcb_void_cookie_t
xcb_open_font (xcb_connection_t *c,
xcb_font_t fid,
uint16_t name_len,
const char *name);
char *
xcb_open_font_name (const xcb_open_font_request_t *R);
int
xcb_open_font_name_length (const xcb_open_font_request_t *R);
xcb_generic_iterator_t
xcb_open_font_name_end (const xcb_open_font_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_close_font_checked (xcb_connection_t *c,
xcb_font_t font);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_close_font (xcb_connection_t *c,
xcb_font_t font);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_fontprop_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_fontprop_t)
*/
void
xcb_fontprop_next (xcb_fontprop_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_fontprop_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_fontprop_end (xcb_fontprop_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_charinfo_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_charinfo_t)
*/
void
xcb_charinfo_next (xcb_charinfo_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_charinfo_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_charinfo_end (xcb_charinfo_iterator_t i);
int
xcb_query_font_sizeof (const void *_buffer);
/**
* @brief query font metrics
*
* @param c The connection
* @param font The fontable (Font or Graphics Context) to query.
* @return A cookie
*
* Queries information associated with the font.
*
*/
xcb_query_font_cookie_t
xcb_query_font (xcb_connection_t *c,
xcb_fontable_t font);
/**
* @brief query font metrics
*
* @param c The connection
* @param font The fontable (Font or Graphics Context) to query.
* @return A cookie
*
* Queries information associated with the font.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_query_font_cookie_t
xcb_query_font_unchecked (xcb_connection_t *c,
xcb_fontable_t font);
xcb_fontprop_t *
xcb_query_font_properties (const xcb_query_font_reply_t *R);
int
xcb_query_font_properties_length (const xcb_query_font_reply_t *R);
xcb_fontprop_iterator_t
xcb_query_font_properties_iterator (const xcb_query_font_reply_t *R);
xcb_charinfo_t *
xcb_query_font_char_infos (const xcb_query_font_reply_t *R);
int
xcb_query_font_char_infos_length (const xcb_query_font_reply_t *R);
xcb_charinfo_iterator_t
xcb_query_font_char_infos_iterator (const xcb_query_font_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_query_font_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_query_font_reply_t *
xcb_query_font_reply (xcb_connection_t *c,
xcb_query_font_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_query_text_extents_sizeof (const void *_buffer,
uint32_t string_len);
/**
* @brief get text extents
*
* @param c The connection
* @param font The \a font to calculate text extents in. You can also pass a graphics context.
* @param string_len The number of characters in \a string.
* @param string The text to get text extents for.
* @return A cookie
*
* Query text extents from the X11 server. This request returns the bounding box
* of the specified 16-bit character string in the specified \a font or the font
* contained in the specified graphics context.
*
* `font_ascent` is set to the maximum of the ascent metrics of all characters in
* the string. `font_descent` is set to the maximum of the descent metrics.
* `overall_width` is set to the sum of the character-width metrics of all
* characters in the string. For each character in the string, let W be the sum of
* the character-width metrics of all characters preceding it in the string. Let L
* be the left-side-bearing metric of the character plus W. Let R be the
* right-side-bearing metric of the character plus W. The lbearing member is set
* to the minimum L of all characters in the string. The rbearing member is set to
* the maximum R.
*
* For fonts defined with linear indexing rather than 2-byte matrix indexing, each
* `xcb_char2b_t` structure is interpreted as a 16-bit number with byte1 as the
* most significant byte. If the font has no defined default character, undefined
* characters in the string are taken to have all zero metrics.
*
* Characters with all zero metrics are ignored. If the font has no defined
* default_char, the undefined characters in the string are also ignored.
*
*/
xcb_query_text_extents_cookie_t
xcb_query_text_extents (xcb_connection_t *c,
xcb_fontable_t font,
uint32_t string_len,
const xcb_char2b_t *string);
/**
* @brief get text extents
*
* @param c The connection
* @param font The \a font to calculate text extents in. You can also pass a graphics context.
* @param string_len The number of characters in \a string.
* @param string The text to get text extents for.
* @return A cookie
*
* Query text extents from the X11 server. This request returns the bounding box
* of the specified 16-bit character string in the specified \a font or the font
* contained in the specified graphics context.
*
* `font_ascent` is set to the maximum of the ascent metrics of all characters in
* the string. `font_descent` is set to the maximum of the descent metrics.
* `overall_width` is set to the sum of the character-width metrics of all
* characters in the string. For each character in the string, let W be the sum of
* the character-width metrics of all characters preceding it in the string. Let L
* be the left-side-bearing metric of the character plus W. Let R be the
* right-side-bearing metric of the character plus W. The lbearing member is set
* to the minimum L of all characters in the string. The rbearing member is set to
* the maximum R.
*
* For fonts defined with linear indexing rather than 2-byte matrix indexing, each
* `xcb_char2b_t` structure is interpreted as a 16-bit number with byte1 as the
* most significant byte. If the font has no defined default character, undefined
* characters in the string are taken to have all zero metrics.
*
* Characters with all zero metrics are ignored. If the font has no defined
* default_char, the undefined characters in the string are also ignored.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_query_text_extents_cookie_t
xcb_query_text_extents_unchecked (xcb_connection_t *c,
xcb_fontable_t font,
uint32_t string_len,
const xcb_char2b_t *string);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_query_text_extents_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_query_text_extents_reply_t *
xcb_query_text_extents_reply (xcb_connection_t *c,
xcb_query_text_extents_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_str_sizeof (const void *_buffer);
char *
xcb_str_name (const xcb_str_t *R);
int
xcb_str_name_length (const xcb_str_t *R);
xcb_generic_iterator_t
xcb_str_name_end (const xcb_str_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_str_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_str_t)
*/
void
xcb_str_next (xcb_str_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_str_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_str_end (xcb_str_iterator_t i);
int
xcb_list_fonts_sizeof (const void *_buffer);
/**
* @brief get matching font names
*
* @param c The connection
* @param max_names The maximum number of fonts to be returned.
* @param pattern_len The length (in bytes) of \a pattern.
* @param pattern A font pattern, for example "-misc-fixed-*".
* \n
* The asterisk (*) is a wildcard for any number of characters. The question mark
* (?) is a wildcard for a single character. Use of uppercase or lowercase does
* not matter.
* @return A cookie
*
* Gets a list of available font names which match the given \a pattern.
*
*/
xcb_list_fonts_cookie_t
xcb_list_fonts (xcb_connection_t *c,
uint16_t max_names,
uint16_t pattern_len,
const char *pattern);
/**
* @brief get matching font names
*
* @param c The connection
* @param max_names The maximum number of fonts to be returned.
* @param pattern_len The length (in bytes) of \a pattern.
* @param pattern A font pattern, for example "-misc-fixed-*".
* \n
* The asterisk (*) is a wildcard for any number of characters. The question mark
* (?) is a wildcard for a single character. Use of uppercase or lowercase does
* not matter.
* @return A cookie
*
* Gets a list of available font names which match the given \a pattern.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_list_fonts_cookie_t
xcb_list_fonts_unchecked (xcb_connection_t *c,
uint16_t max_names,
uint16_t pattern_len,
const char *pattern);
int
xcb_list_fonts_names_length (const xcb_list_fonts_reply_t *R);
xcb_str_iterator_t
xcb_list_fonts_names_iterator (const xcb_list_fonts_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_list_fonts_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_list_fonts_reply_t *
xcb_list_fonts_reply (xcb_connection_t *c,
xcb_list_fonts_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_list_fonts_with_info_sizeof (const void *_buffer);
/**
* @brief get matching font names and information
*
* @param c The connection
* @param max_names The maximum number of fonts to be returned.
* @param pattern_len The length (in bytes) of \a pattern.
* @param pattern A font pattern, for example "-misc-fixed-*".
* \n
* The asterisk (*) is a wildcard for any number of characters. The question mark
* (?) is a wildcard for a single character. Use of uppercase or lowercase does
* not matter.
* @return A cookie
*
* Gets a list of available font names which match the given \a pattern.
*
*/
xcb_list_fonts_with_info_cookie_t
xcb_list_fonts_with_info (xcb_connection_t *c,
uint16_t max_names,
uint16_t pattern_len,
const char *pattern);
/**
* @brief get matching font names and information
*
* @param c The connection
* @param max_names The maximum number of fonts to be returned.
* @param pattern_len The length (in bytes) of \a pattern.
* @param pattern A font pattern, for example "-misc-fixed-*".
* \n
* The asterisk (*) is a wildcard for any number of characters. The question mark
* (?) is a wildcard for a single character. Use of uppercase or lowercase does
* not matter.
* @return A cookie
*
* Gets a list of available font names which match the given \a pattern.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_list_fonts_with_info_cookie_t
xcb_list_fonts_with_info_unchecked (xcb_connection_t *c,
uint16_t max_names,
uint16_t pattern_len,
const char *pattern);
xcb_fontprop_t *
xcb_list_fonts_with_info_properties (const xcb_list_fonts_with_info_reply_t *R);
int
xcb_list_fonts_with_info_properties_length (const xcb_list_fonts_with_info_reply_t *R);
xcb_fontprop_iterator_t
xcb_list_fonts_with_info_properties_iterator (const xcb_list_fonts_with_info_reply_t *R);
char *
xcb_list_fonts_with_info_name (const xcb_list_fonts_with_info_reply_t *R);
int
xcb_list_fonts_with_info_name_length (const xcb_list_fonts_with_info_reply_t *R);
xcb_generic_iterator_t
xcb_list_fonts_with_info_name_end (const xcb_list_fonts_with_info_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_list_fonts_with_info_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_list_fonts_with_info_reply_t *
xcb_list_fonts_with_info_reply (xcb_connection_t *c,
xcb_list_fonts_with_info_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_set_font_path_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_set_font_path_checked (xcb_connection_t *c,
uint16_t font_qty,
const xcb_str_t *font);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_set_font_path (xcb_connection_t *c,
uint16_t font_qty,
const xcb_str_t *font);
int
xcb_set_font_path_font_length (const xcb_set_font_path_request_t *R);
xcb_str_iterator_t
xcb_set_font_path_font_iterator (const xcb_set_font_path_request_t *R);
int
xcb_get_font_path_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_get_font_path_cookie_t
xcb_get_font_path (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_get_font_path_cookie_t
xcb_get_font_path_unchecked (xcb_connection_t *c);
int
xcb_get_font_path_path_length (const xcb_get_font_path_reply_t *R);
xcb_str_iterator_t
xcb_get_font_path_path_iterator (const xcb_get_font_path_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_get_font_path_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_get_font_path_reply_t *
xcb_get_font_path_reply (xcb_connection_t *c,
xcb_get_font_path_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
* @brief Creates a pixmap
*
* @param c The connection
* @param depth TODO
* @param pid The ID with which you will refer to the new pixmap, created by
* `xcb_generate_id`.
* @param drawable Drawable to get the screen from.
* @param width The width of the new pixmap.
* @param height The height of the new pixmap.
* @return A cookie
*
* Creates a pixmap. The pixmap can only be used on the same screen as \a drawable
* is on and only with drawables of the same \a depth.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_create_pixmap_checked (xcb_connection_t *c,
uint8_t depth,
xcb_pixmap_t pid,
xcb_drawable_t drawable,
uint16_t width,
uint16_t height);
/**
* @brief Creates a pixmap
*
* @param c The connection
* @param depth TODO
* @param pid The ID with which you will refer to the new pixmap, created by
* `xcb_generate_id`.
* @param drawable Drawable to get the screen from.
* @param width The width of the new pixmap.
* @param height The height of the new pixmap.
* @return A cookie
*
* Creates a pixmap. The pixmap can only be used on the same screen as \a drawable
* is on and only with drawables of the same \a depth.
*
*/
xcb_void_cookie_t
xcb_create_pixmap (xcb_connection_t *c,
uint8_t depth,
xcb_pixmap_t pid,
xcb_drawable_t drawable,
uint16_t width,
uint16_t height);
/**
* @brief Destroys a pixmap
*
* @param c The connection
* @param pixmap The pixmap to destroy.
* @return A cookie
*
* Deletes the association between the pixmap ID and the pixmap. The pixmap
* storage will be freed when there are no more references to it.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_free_pixmap_checked (xcb_connection_t *c,
xcb_pixmap_t pixmap);
/**
* @brief Destroys a pixmap
*
* @param c The connection
* @param pixmap The pixmap to destroy.
* @return A cookie
*
* Deletes the association between the pixmap ID and the pixmap. The pixmap
* storage will be freed when there are no more references to it.
*
*/
xcb_void_cookie_t
xcb_free_pixmap (xcb_connection_t *c,
xcb_pixmap_t pixmap);
int
xcb_create_gc_value_list_serialize (void **_buffer,
uint32_t value_mask,
const xcb_create_gc_value_list_t *_aux);
int
xcb_create_gc_value_list_unpack (const void *_buffer,
uint32_t value_mask,
xcb_create_gc_value_list_t *_aux);
int
xcb_create_gc_value_list_sizeof (const void *_buffer,
uint32_t value_mask);
int
xcb_create_gc_sizeof (const void *_buffer);
/**
* @brief Creates a graphics context
*
* @param c The connection
* @param cid The ID with which you will refer to the graphics context, created by
* `xcb_generate_id`.
* @param drawable Drawable to get the root/depth from.
* @return A cookie
*
* Creates a graphics context. The graphics context can be used with any drawable
* that has the same root and depth as the specified drawable.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_create_gc_checked (xcb_connection_t *c,
xcb_gcontext_t cid,
xcb_drawable_t drawable,
uint32_t value_mask,
const void *value_list);
/**
* @brief Creates a graphics context
*
* @param c The connection
* @param cid The ID with which you will refer to the graphics context, created by
* `xcb_generate_id`.
* @param drawable Drawable to get the root/depth from.
* @return A cookie
*
* Creates a graphics context. The graphics context can be used with any drawable
* that has the same root and depth as the specified drawable.
*
*/
xcb_void_cookie_t
xcb_create_gc (xcb_connection_t *c,
xcb_gcontext_t cid,
xcb_drawable_t drawable,
uint32_t value_mask,
const void *value_list);
/**
* @brief Creates a graphics context
*
* @param c The connection
* @param cid The ID with which you will refer to the graphics context, created by
* `xcb_generate_id`.
* @param drawable Drawable to get the root/depth from.
* @return A cookie
*
* Creates a graphics context. The graphics context can be used with any drawable
* that has the same root and depth as the specified drawable.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_create_gc_aux_checked (xcb_connection_t *c,
xcb_gcontext_t cid,
xcb_drawable_t drawable,
uint32_t value_mask,
const xcb_create_gc_value_list_t *value_list);
/**
* @brief Creates a graphics context
*
* @param c The connection
* @param cid The ID with which you will refer to the graphics context, created by
* `xcb_generate_id`.
* @param drawable Drawable to get the root/depth from.
* @return A cookie
*
* Creates a graphics context. The graphics context can be used with any drawable
* that has the same root and depth as the specified drawable.
*
*/
xcb_void_cookie_t
xcb_create_gc_aux (xcb_connection_t *c,
xcb_gcontext_t cid,
xcb_drawable_t drawable,
uint32_t value_mask,
const xcb_create_gc_value_list_t *value_list);
void *
xcb_create_gc_value_list (const xcb_create_gc_request_t *R);
int
xcb_change_gc_value_list_serialize (void **_buffer,
uint32_t value_mask,
const xcb_change_gc_value_list_t *_aux);
int
xcb_change_gc_value_list_unpack (const void *_buffer,
uint32_t value_mask,
xcb_change_gc_value_list_t *_aux);
int
xcb_change_gc_value_list_sizeof (const void *_buffer,
uint32_t value_mask);
int
xcb_change_gc_sizeof (const void *_buffer);
/**
* @brief change graphics context components
*
* @param c The connection
* @param gc The graphics context to change.
* @param value_mask A bitmask of #xcb_gc_t values.
* @param value_mask \n
* @param value_list Values for each of the components specified in the bitmask \a value_mask. The
* order has to correspond to the order of possible \a value_mask bits. See the
* example.
* @return A cookie
*
* Changes the components specified by \a value_mask for the specified graphics context.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_change_gc_checked (xcb_connection_t *c,
xcb_gcontext_t gc,
uint32_t value_mask,
const void *value_list);
/**
* @brief change graphics context components
*
* @param c The connection
* @param gc The graphics context to change.
* @param value_mask A bitmask of #xcb_gc_t values.
* @param value_mask \n
* @param value_list Values for each of the components specified in the bitmask \a value_mask. The
* order has to correspond to the order of possible \a value_mask bits. See the
* example.
* @return A cookie
*
* Changes the components specified by \a value_mask for the specified graphics context.
*
*/
xcb_void_cookie_t
xcb_change_gc (xcb_connection_t *c,
xcb_gcontext_t gc,
uint32_t value_mask,
const void *value_list);
/**
* @brief change graphics context components
*
* @param c The connection
* @param gc The graphics context to change.
* @param value_mask A bitmask of #xcb_gc_t values.
* @param value_mask \n
* @param value_list Values for each of the components specified in the bitmask \a value_mask. The
* order has to correspond to the order of possible \a value_mask bits. See the
* example.
* @return A cookie
*
* Changes the components specified by \a value_mask for the specified graphics context.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_change_gc_aux_checked (xcb_connection_t *c,
xcb_gcontext_t gc,
uint32_t value_mask,
const xcb_change_gc_value_list_t *value_list);
/**
* @brief change graphics context components
*
* @param c The connection
* @param gc The graphics context to change.
* @param value_mask A bitmask of #xcb_gc_t values.
* @param value_mask \n
* @param value_list Values for each of the components specified in the bitmask \a value_mask. The
* order has to correspond to the order of possible \a value_mask bits. See the
* example.
* @return A cookie
*
* Changes the components specified by \a value_mask for the specified graphics context.
*
*/
xcb_void_cookie_t
xcb_change_gc_aux (xcb_connection_t *c,
xcb_gcontext_t gc,
uint32_t value_mask,
const xcb_change_gc_value_list_t *value_list);
void *
xcb_change_gc_value_list (const xcb_change_gc_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_copy_gc_checked (xcb_connection_t *c,
xcb_gcontext_t src_gc,
xcb_gcontext_t dst_gc,
uint32_t value_mask);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_copy_gc (xcb_connection_t *c,
xcb_gcontext_t src_gc,
xcb_gcontext_t dst_gc,
uint32_t value_mask);
int
xcb_set_dashes_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_set_dashes_checked (xcb_connection_t *c,
xcb_gcontext_t gc,
uint16_t dash_offset,
uint16_t dashes_len,
const uint8_t *dashes);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_set_dashes (xcb_connection_t *c,
xcb_gcontext_t gc,
uint16_t dash_offset,
uint16_t dashes_len,
const uint8_t *dashes);
uint8_t *
xcb_set_dashes_dashes (const xcb_set_dashes_request_t *R);
int
xcb_set_dashes_dashes_length (const xcb_set_dashes_request_t *R);
xcb_generic_iterator_t
xcb_set_dashes_dashes_end (const xcb_set_dashes_request_t *R);
int
xcb_set_clip_rectangles_sizeof (const void *_buffer,
uint32_t rectangles_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_set_clip_rectangles_checked (xcb_connection_t *c,
uint8_t ordering,
xcb_gcontext_t gc,
int16_t clip_x_origin,
int16_t clip_y_origin,
uint32_t rectangles_len,
const xcb_rectangle_t *rectangles);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_set_clip_rectangles (xcb_connection_t *c,
uint8_t ordering,
xcb_gcontext_t gc,
int16_t clip_x_origin,
int16_t clip_y_origin,
uint32_t rectangles_len,
const xcb_rectangle_t *rectangles);
xcb_rectangle_t *
xcb_set_clip_rectangles_rectangles (const xcb_set_clip_rectangles_request_t *R);
int
xcb_set_clip_rectangles_rectangles_length (const xcb_set_clip_rectangles_request_t *R);
xcb_rectangle_iterator_t
xcb_set_clip_rectangles_rectangles_iterator (const xcb_set_clip_rectangles_request_t *R);
/**
* @brief Destroys a graphics context
*
* @param c The connection
* @param gc The graphics context to destroy.
* @return A cookie
*
* Destroys the specified \a gc and all associated storage.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_free_gc_checked (xcb_connection_t *c,
xcb_gcontext_t gc);
/**
* @brief Destroys a graphics context
*
* @param c The connection
* @param gc The graphics context to destroy.
* @return A cookie
*
* Destroys the specified \a gc and all associated storage.
*
*/
xcb_void_cookie_t
xcb_free_gc (xcb_connection_t *c,
xcb_gcontext_t gc);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_clear_area_checked (xcb_connection_t *c,
uint8_t exposures,
xcb_window_t window,
int16_t x,
int16_t y,
uint16_t width,
uint16_t height);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_clear_area (xcb_connection_t *c,
uint8_t exposures,
xcb_window_t window,
int16_t x,
int16_t y,
uint16_t width,
uint16_t height);
/**
* @brief copy areas
*
* @param c The connection
* @param src_drawable The source drawable (Window or Pixmap).
* @param dst_drawable The destination drawable (Window or Pixmap).
* @param gc The graphics context to use.
* @param src_x The source X coordinate.
* @param src_y The source Y coordinate.
* @param dst_x The destination X coordinate.
* @param dst_y The destination Y coordinate.
* @param width The width of the area to copy (in pixels).
* @param height The height of the area to copy (in pixels).
* @return A cookie
*
* Copies the specified rectangle from \a src_drawable to \a dst_drawable.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_copy_area_checked (xcb_connection_t *c,
xcb_drawable_t src_drawable,
xcb_drawable_t dst_drawable,
xcb_gcontext_t gc,
int16_t src_x,
int16_t src_y,
int16_t dst_x,
int16_t dst_y,
uint16_t width,
uint16_t height);
/**
* @brief copy areas
*
* @param c The connection
* @param src_drawable The source drawable (Window or Pixmap).
* @param dst_drawable The destination drawable (Window or Pixmap).
* @param gc The graphics context to use.
* @param src_x The source X coordinate.
* @param src_y The source Y coordinate.
* @param dst_x The destination X coordinate.
* @param dst_y The destination Y coordinate.
* @param width The width of the area to copy (in pixels).
* @param height The height of the area to copy (in pixels).
* @return A cookie
*
* Copies the specified rectangle from \a src_drawable to \a dst_drawable.
*
*/
xcb_void_cookie_t
xcb_copy_area (xcb_connection_t *c,
xcb_drawable_t src_drawable,
xcb_drawable_t dst_drawable,
xcb_gcontext_t gc,
int16_t src_x,
int16_t src_y,
int16_t dst_x,
int16_t dst_y,
uint16_t width,
uint16_t height);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_copy_plane_checked (xcb_connection_t *c,
xcb_drawable_t src_drawable,
xcb_drawable_t dst_drawable,
xcb_gcontext_t gc,
int16_t src_x,
int16_t src_y,
int16_t dst_x,
int16_t dst_y,
uint16_t width,
uint16_t height,
uint32_t bit_plane);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_copy_plane (xcb_connection_t *c,
xcb_drawable_t src_drawable,
xcb_drawable_t dst_drawable,
xcb_gcontext_t gc,
int16_t src_x,
int16_t src_y,
int16_t dst_x,
int16_t dst_y,
uint16_t width,
uint16_t height,
uint32_t bit_plane);
int
xcb_poly_point_sizeof (const void *_buffer,
uint32_t points_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_poly_point_checked (xcb_connection_t *c,
uint8_t coordinate_mode,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
uint32_t points_len,
const xcb_point_t *points);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_poly_point (xcb_connection_t *c,
uint8_t coordinate_mode,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
uint32_t points_len,
const xcb_point_t *points);
xcb_point_t *
xcb_poly_point_points (const xcb_poly_point_request_t *R);
int
xcb_poly_point_points_length (const xcb_poly_point_request_t *R);
xcb_point_iterator_t
xcb_poly_point_points_iterator (const xcb_poly_point_request_t *R);
int
xcb_poly_line_sizeof (const void *_buffer,
uint32_t points_len);
/**
* @brief draw lines
*
* @param c The connection
* @param coordinate_mode A bitmask of #xcb_coord_mode_t values.
* @param coordinate_mode \n
* @param drawable The drawable to draw the line(s) on.
* @param gc The graphics context to use.
* @param points_len The number of `xcb_point_t` structures in \a points.
* @param points An array of points.
* @return A cookie
*
* Draws \a points_len-1 lines between each pair of points (point[i], point[i+1])
* in the \a points array. The lines are drawn in the order listed in the array.
* They join correctly at all intermediate points, and if the first and last
* points coincide, the first and last lines also join correctly. For any given
* line, a pixel is not drawn more than once. If thin (zero line-width) lines
* intersect, the intersecting pixels are drawn multiple times. If wide lines
* intersect, the intersecting pixels are drawn only once, as though the entire
* request were a single, filled shape.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_poly_line_checked (xcb_connection_t *c,
uint8_t coordinate_mode,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
uint32_t points_len,
const xcb_point_t *points);
/**
* @brief draw lines
*
* @param c The connection
* @param coordinate_mode A bitmask of #xcb_coord_mode_t values.
* @param coordinate_mode \n
* @param drawable The drawable to draw the line(s) on.
* @param gc The graphics context to use.
* @param points_len The number of `xcb_point_t` structures in \a points.
* @param points An array of points.
* @return A cookie
*
* Draws \a points_len-1 lines between each pair of points (point[i], point[i+1])
* in the \a points array. The lines are drawn in the order listed in the array.
* They join correctly at all intermediate points, and if the first and last
* points coincide, the first and last lines also join correctly. For any given
* line, a pixel is not drawn more than once. If thin (zero line-width) lines
* intersect, the intersecting pixels are drawn multiple times. If wide lines
* intersect, the intersecting pixels are drawn only once, as though the entire
* request were a single, filled shape.
*
*/
xcb_void_cookie_t
xcb_poly_line (xcb_connection_t *c,
uint8_t coordinate_mode,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
uint32_t points_len,
const xcb_point_t *points);
xcb_point_t *
xcb_poly_line_points (const xcb_poly_line_request_t *R);
int
xcb_poly_line_points_length (const xcb_poly_line_request_t *R);
xcb_point_iterator_t
xcb_poly_line_points_iterator (const xcb_poly_line_request_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_segment_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_segment_t)
*/
void
xcb_segment_next (xcb_segment_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_segment_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_segment_end (xcb_segment_iterator_t i);
int
xcb_poly_segment_sizeof (const void *_buffer,
uint32_t segments_len);
/**
* @brief draw lines
*
* @param c The connection
* @param drawable A drawable (Window or Pixmap) to draw on.
* @param gc The graphics context to use.
* \n
* TODO: document which attributes of a gc are used
* @param segments_len The number of `xcb_segment_t` structures in \a segments.
* @param segments An array of `xcb_segment_t` structures.
* @return A cookie
*
* Draws multiple, unconnected lines. For each segment, a line is drawn between
* (x1, y1) and (x2, y2). The lines are drawn in the order listed in the array of
* `xcb_segment_t` structures and does not perform joining at coincident
* endpoints. For any given line, a pixel is not drawn more than once. If lines
* intersect, the intersecting pixels are drawn multiple times.
*
* TODO: include the xcb_segment_t data structure
*
* TODO: an example
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_poly_segment_checked (xcb_connection_t *c,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
uint32_t segments_len,
const xcb_segment_t *segments);
/**
* @brief draw lines
*
* @param c The connection
* @param drawable A drawable (Window or Pixmap) to draw on.
* @param gc The graphics context to use.
* \n
* TODO: document which attributes of a gc are used
* @param segments_len The number of `xcb_segment_t` structures in \a segments.
* @param segments An array of `xcb_segment_t` structures.
* @return A cookie
*
* Draws multiple, unconnected lines. For each segment, a line is drawn between
* (x1, y1) and (x2, y2). The lines are drawn in the order listed in the array of
* `xcb_segment_t` structures and does not perform joining at coincident
* endpoints. For any given line, a pixel is not drawn more than once. If lines
* intersect, the intersecting pixels are drawn multiple times.
*
* TODO: include the xcb_segment_t data structure
*
* TODO: an example
*
*/
xcb_void_cookie_t
xcb_poly_segment (xcb_connection_t *c,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
uint32_t segments_len,
const xcb_segment_t *segments);
xcb_segment_t *
xcb_poly_segment_segments (const xcb_poly_segment_request_t *R);
int
xcb_poly_segment_segments_length (const xcb_poly_segment_request_t *R);
xcb_segment_iterator_t
xcb_poly_segment_segments_iterator (const xcb_poly_segment_request_t *R);
int
xcb_poly_rectangle_sizeof (const void *_buffer,
uint32_t rectangles_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_poly_rectangle_checked (xcb_connection_t *c,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
uint32_t rectangles_len,
const xcb_rectangle_t *rectangles);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_poly_rectangle (xcb_connection_t *c,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
uint32_t rectangles_len,
const xcb_rectangle_t *rectangles);
xcb_rectangle_t *
xcb_poly_rectangle_rectangles (const xcb_poly_rectangle_request_t *R);
int
xcb_poly_rectangle_rectangles_length (const xcb_poly_rectangle_request_t *R);
xcb_rectangle_iterator_t
xcb_poly_rectangle_rectangles_iterator (const xcb_poly_rectangle_request_t *R);
int
xcb_poly_arc_sizeof (const void *_buffer,
uint32_t arcs_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_poly_arc_checked (xcb_connection_t *c,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
uint32_t arcs_len,
const xcb_arc_t *arcs);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_poly_arc (xcb_connection_t *c,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
uint32_t arcs_len,
const xcb_arc_t *arcs);
xcb_arc_t *
xcb_poly_arc_arcs (const xcb_poly_arc_request_t *R);
int
xcb_poly_arc_arcs_length (const xcb_poly_arc_request_t *R);
xcb_arc_iterator_t
xcb_poly_arc_arcs_iterator (const xcb_poly_arc_request_t *R);
int
xcb_fill_poly_sizeof (const void *_buffer,
uint32_t points_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_fill_poly_checked (xcb_connection_t *c,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
uint8_t shape,
uint8_t coordinate_mode,
uint32_t points_len,
const xcb_point_t *points);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_fill_poly (xcb_connection_t *c,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
uint8_t shape,
uint8_t coordinate_mode,
uint32_t points_len,
const xcb_point_t *points);
xcb_point_t *
xcb_fill_poly_points (const xcb_fill_poly_request_t *R);
int
xcb_fill_poly_points_length (const xcb_fill_poly_request_t *R);
xcb_point_iterator_t
xcb_fill_poly_points_iterator (const xcb_fill_poly_request_t *R);
int
xcb_poly_fill_rectangle_sizeof (const void *_buffer,
uint32_t rectangles_len);
/**
* @brief Fills rectangles
*
* @param c The connection
* @param drawable The drawable (Window or Pixmap) to draw on.
* @param gc The graphics context to use.
* \n
* The following graphics context components are used: function, plane-mask,
* fill-style, subwindow-mode, clip-x-origin, clip-y-origin, and clip-mask.
* \n
* The following graphics context mode-dependent components are used:
* foreground, background, tile, stipple, tile-stipple-x-origin, and
* tile-stipple-y-origin.
* @param rectangles_len The number of `xcb_rectangle_t` structures in \a rectangles.
* @param rectangles The rectangles to fill.
* @return A cookie
*
* Fills the specified rectangle(s) in the order listed in the array. For any
* given rectangle, each pixel is not drawn more than once. If rectangles
* intersect, the intersecting pixels are drawn multiple times.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_poly_fill_rectangle_checked (xcb_connection_t *c,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
uint32_t rectangles_len,
const xcb_rectangle_t *rectangles);
/**
* @brief Fills rectangles
*
* @param c The connection
* @param drawable The drawable (Window or Pixmap) to draw on.
* @param gc The graphics context to use.
* \n
* The following graphics context components are used: function, plane-mask,
* fill-style, subwindow-mode, clip-x-origin, clip-y-origin, and clip-mask.
* \n
* The following graphics context mode-dependent components are used:
* foreground, background, tile, stipple, tile-stipple-x-origin, and
* tile-stipple-y-origin.
* @param rectangles_len The number of `xcb_rectangle_t` structures in \a rectangles.
* @param rectangles The rectangles to fill.
* @return A cookie
*
* Fills the specified rectangle(s) in the order listed in the array. For any
* given rectangle, each pixel is not drawn more than once. If rectangles
* intersect, the intersecting pixels are drawn multiple times.
*
*/
xcb_void_cookie_t
xcb_poly_fill_rectangle (xcb_connection_t *c,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
uint32_t rectangles_len,
const xcb_rectangle_t *rectangles);
xcb_rectangle_t *
xcb_poly_fill_rectangle_rectangles (const xcb_poly_fill_rectangle_request_t *R);
int
xcb_poly_fill_rectangle_rectangles_length (const xcb_poly_fill_rectangle_request_t *R);
xcb_rectangle_iterator_t
xcb_poly_fill_rectangle_rectangles_iterator (const xcb_poly_fill_rectangle_request_t *R);
int
xcb_poly_fill_arc_sizeof (const void *_buffer,
uint32_t arcs_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_poly_fill_arc_checked (xcb_connection_t *c,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
uint32_t arcs_len,
const xcb_arc_t *arcs);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_poly_fill_arc (xcb_connection_t *c,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
uint32_t arcs_len,
const xcb_arc_t *arcs);
xcb_arc_t *
xcb_poly_fill_arc_arcs (const xcb_poly_fill_arc_request_t *R);
int
xcb_poly_fill_arc_arcs_length (const xcb_poly_fill_arc_request_t *R);
xcb_arc_iterator_t
xcb_poly_fill_arc_arcs_iterator (const xcb_poly_fill_arc_request_t *R);
int
xcb_put_image_sizeof (const void *_buffer,
uint32_t data_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_put_image_checked (xcb_connection_t *c,
uint8_t format,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
uint16_t width,
uint16_t height,
int16_t dst_x,
int16_t dst_y,
uint8_t left_pad,
uint8_t depth,
uint32_t data_len,
const uint8_t *data);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_put_image (xcb_connection_t *c,
uint8_t format,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
uint16_t width,
uint16_t height,
int16_t dst_x,
int16_t dst_y,
uint8_t left_pad,
uint8_t depth,
uint32_t data_len,
const uint8_t *data);
uint8_t *
xcb_put_image_data (const xcb_put_image_request_t *R);
int
xcb_put_image_data_length (const xcb_put_image_request_t *R);
xcb_generic_iterator_t
xcb_put_image_data_end (const xcb_put_image_request_t *R);
int
xcb_get_image_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_get_image_cookie_t
xcb_get_image (xcb_connection_t *c,
uint8_t format,
xcb_drawable_t drawable,
int16_t x,
int16_t y,
uint16_t width,
uint16_t height,
uint32_t plane_mask);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_get_image_cookie_t
xcb_get_image_unchecked (xcb_connection_t *c,
uint8_t format,
xcb_drawable_t drawable,
int16_t x,
int16_t y,
uint16_t width,
uint16_t height,
uint32_t plane_mask);
uint8_t *
xcb_get_image_data (const xcb_get_image_reply_t *R);
int
xcb_get_image_data_length (const xcb_get_image_reply_t *R);
xcb_generic_iterator_t
xcb_get_image_data_end (const xcb_get_image_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_get_image_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_get_image_reply_t *
xcb_get_image_reply (xcb_connection_t *c,
xcb_get_image_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_poly_text_8_sizeof (const void *_buffer,
uint32_t items_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_poly_text_8_checked (xcb_connection_t *c,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
int16_t x,
int16_t y,
uint32_t items_len,
const uint8_t *items);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_poly_text_8 (xcb_connection_t *c,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
int16_t x,
int16_t y,
uint32_t items_len,
const uint8_t *items);
uint8_t *
xcb_poly_text_8_items (const xcb_poly_text_8_request_t *R);
int
xcb_poly_text_8_items_length (const xcb_poly_text_8_request_t *R);
xcb_generic_iterator_t
xcb_poly_text_8_items_end (const xcb_poly_text_8_request_t *R);
int
xcb_poly_text_16_sizeof (const void *_buffer,
uint32_t items_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_poly_text_16_checked (xcb_connection_t *c,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
int16_t x,
int16_t y,
uint32_t items_len,
const uint8_t *items);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_poly_text_16 (xcb_connection_t *c,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
int16_t x,
int16_t y,
uint32_t items_len,
const uint8_t *items);
uint8_t *
xcb_poly_text_16_items (const xcb_poly_text_16_request_t *R);
int
xcb_poly_text_16_items_length (const xcb_poly_text_16_request_t *R);
xcb_generic_iterator_t
xcb_poly_text_16_items_end (const xcb_poly_text_16_request_t *R);
int
xcb_image_text_8_sizeof (const void *_buffer);
/**
* @brief Draws text
*
* @param c The connection
* @param string_len The length of the \a string. Note that this parameter limited by 255 due to
* using 8 bits!
* @param drawable The drawable (Window or Pixmap) to draw text on.
* @param gc The graphics context to use.
* \n
* The following graphics context components are used: plane-mask, foreground,
* background, font, subwindow-mode, clip-x-origin, clip-y-origin, and clip-mask.
* @param x The x coordinate of the first character, relative to the origin of \a drawable.
* @param y The y coordinate of the first character, relative to the origin of \a drawable.
* @param string The string to draw. Only the first 255 characters are relevant due to the data
* type of \a string_len.
* @return A cookie
*
* Fills the destination rectangle with the background pixel from \a gc, then
* paints the text with the foreground pixel from \a gc. The upper-left corner of
* the filled rectangle is at [x, y - font-ascent]. The width is overall-width,
* the height is font-ascent + font-descent. The overall-width, font-ascent and
* font-descent are as returned by `xcb_query_text_extents` (TODO).
*
* Note that using X core fonts is deprecated (but still supported) in favor of
* client-side rendering using Xft.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_image_text_8_checked (xcb_connection_t *c,
uint8_t string_len,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
int16_t x,
int16_t y,
const char *string);
/**
* @brief Draws text
*
* @param c The connection
* @param string_len The length of the \a string. Note that this parameter limited by 255 due to
* using 8 bits!
* @param drawable The drawable (Window or Pixmap) to draw text on.
* @param gc The graphics context to use.
* \n
* The following graphics context components are used: plane-mask, foreground,
* background, font, subwindow-mode, clip-x-origin, clip-y-origin, and clip-mask.
* @param x The x coordinate of the first character, relative to the origin of \a drawable.
* @param y The y coordinate of the first character, relative to the origin of \a drawable.
* @param string The string to draw. Only the first 255 characters are relevant due to the data
* type of \a string_len.
* @return A cookie
*
* Fills the destination rectangle with the background pixel from \a gc, then
* paints the text with the foreground pixel from \a gc. The upper-left corner of
* the filled rectangle is at [x, y - font-ascent]. The width is overall-width,
* the height is font-ascent + font-descent. The overall-width, font-ascent and
* font-descent are as returned by `xcb_query_text_extents` (TODO).
*
* Note that using X core fonts is deprecated (but still supported) in favor of
* client-side rendering using Xft.
*
*/
xcb_void_cookie_t
xcb_image_text_8 (xcb_connection_t *c,
uint8_t string_len,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
int16_t x,
int16_t y,
const char *string);
char *
xcb_image_text_8_string (const xcb_image_text_8_request_t *R);
int
xcb_image_text_8_string_length (const xcb_image_text_8_request_t *R);
xcb_generic_iterator_t
xcb_image_text_8_string_end (const xcb_image_text_8_request_t *R);
int
xcb_image_text_16_sizeof (const void *_buffer);
/**
* @brief Draws text
*
* @param c The connection
* @param string_len The length of the \a string in characters. Note that this parameter limited by
* 255 due to using 8 bits!
* @param drawable The drawable (Window or Pixmap) to draw text on.
* @param gc The graphics context to use.
* \n
* The following graphics context components are used: plane-mask, foreground,
* background, font, subwindow-mode, clip-x-origin, clip-y-origin, and clip-mask.
* @param x The x coordinate of the first character, relative to the origin of \a drawable.
* @param y The y coordinate of the first character, relative to the origin of \a drawable.
* @param string The string to draw. Only the first 255 characters are relevant due to the data
* type of \a string_len. Every character uses 2 bytes (hence the 16 in this
* request's name).
* @return A cookie
*
* Fills the destination rectangle with the background pixel from \a gc, then
* paints the text with the foreground pixel from \a gc. The upper-left corner of
* the filled rectangle is at [x, y - font-ascent]. The width is overall-width,
* the height is font-ascent + font-descent. The overall-width, font-ascent and
* font-descent are as returned by `xcb_query_text_extents` (TODO).
*
* Note that using X core fonts is deprecated (but still supported) in favor of
* client-side rendering using Xft.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_image_text_16_checked (xcb_connection_t *c,
uint8_t string_len,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
int16_t x,
int16_t y,
const xcb_char2b_t *string);
/**
* @brief Draws text
*
* @param c The connection
* @param string_len The length of the \a string in characters. Note that this parameter limited by
* 255 due to using 8 bits!
* @param drawable The drawable (Window or Pixmap) to draw text on.
* @param gc The graphics context to use.
* \n
* The following graphics context components are used: plane-mask, foreground,
* background, font, subwindow-mode, clip-x-origin, clip-y-origin, and clip-mask.
* @param x The x coordinate of the first character, relative to the origin of \a drawable.
* @param y The y coordinate of the first character, relative to the origin of \a drawable.
* @param string The string to draw. Only the first 255 characters are relevant due to the data
* type of \a string_len. Every character uses 2 bytes (hence the 16 in this
* request's name).
* @return A cookie
*
* Fills the destination rectangle with the background pixel from \a gc, then
* paints the text with the foreground pixel from \a gc. The upper-left corner of
* the filled rectangle is at [x, y - font-ascent]. The width is overall-width,
* the height is font-ascent + font-descent. The overall-width, font-ascent and
* font-descent are as returned by `xcb_query_text_extents` (TODO).
*
* Note that using X core fonts is deprecated (but still supported) in favor of
* client-side rendering using Xft.
*
*/
xcb_void_cookie_t
xcb_image_text_16 (xcb_connection_t *c,
uint8_t string_len,
xcb_drawable_t drawable,
xcb_gcontext_t gc,
int16_t x,
int16_t y,
const xcb_char2b_t *string);
xcb_char2b_t *
xcb_image_text_16_string (const xcb_image_text_16_request_t *R);
int
xcb_image_text_16_string_length (const xcb_image_text_16_request_t *R);
xcb_char2b_iterator_t
xcb_image_text_16_string_iterator (const xcb_image_text_16_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_create_colormap_checked (xcb_connection_t *c,
uint8_t alloc,
xcb_colormap_t mid,
xcb_window_t window,
xcb_visualid_t visual);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_create_colormap (xcb_connection_t *c,
uint8_t alloc,
xcb_colormap_t mid,
xcb_window_t window,
xcb_visualid_t visual);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_free_colormap_checked (xcb_connection_t *c,
xcb_colormap_t cmap);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_free_colormap (xcb_connection_t *c,
xcb_colormap_t cmap);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_copy_colormap_and_free_checked (xcb_connection_t *c,
xcb_colormap_t mid,
xcb_colormap_t src_cmap);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_copy_colormap_and_free (xcb_connection_t *c,
xcb_colormap_t mid,
xcb_colormap_t src_cmap);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_install_colormap_checked (xcb_connection_t *c,
xcb_colormap_t cmap);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_install_colormap (xcb_connection_t *c,
xcb_colormap_t cmap);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_uninstall_colormap_checked (xcb_connection_t *c,
xcb_colormap_t cmap);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_uninstall_colormap (xcb_connection_t *c,
xcb_colormap_t cmap);
int
xcb_list_installed_colormaps_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_list_installed_colormaps_cookie_t
xcb_list_installed_colormaps (xcb_connection_t *c,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_list_installed_colormaps_cookie_t
xcb_list_installed_colormaps_unchecked (xcb_connection_t *c,
xcb_window_t window);
xcb_colormap_t *
xcb_list_installed_colormaps_cmaps (const xcb_list_installed_colormaps_reply_t *R);
int
xcb_list_installed_colormaps_cmaps_length (const xcb_list_installed_colormaps_reply_t *R);
xcb_generic_iterator_t
xcb_list_installed_colormaps_cmaps_end (const xcb_list_installed_colormaps_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_list_installed_colormaps_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_list_installed_colormaps_reply_t *
xcb_list_installed_colormaps_reply (xcb_connection_t *c,
xcb_list_installed_colormaps_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
* @brief Allocate a color
*
* @param c The connection
* @param cmap TODO
* @param red The red value of your color.
* @param green The green value of your color.
* @param blue The blue value of your color.
* @return A cookie
*
* Allocates a read-only colormap entry corresponding to the closest RGB value
* supported by the hardware. If you are using TrueColor, you can take a shortcut
* and directly calculate the color pixel value to avoid the round trip. But, for
* example, on 16-bit color setups (VNC), you can easily get the closest supported
* RGB value to the RGB value you are specifying.
*
*/
xcb_alloc_color_cookie_t
xcb_alloc_color (xcb_connection_t *c,
xcb_colormap_t cmap,
uint16_t red,
uint16_t green,
uint16_t blue);
/**
* @brief Allocate a color
*
* @param c The connection
* @param cmap TODO
* @param red The red value of your color.
* @param green The green value of your color.
* @param blue The blue value of your color.
* @return A cookie
*
* Allocates a read-only colormap entry corresponding to the closest RGB value
* supported by the hardware. If you are using TrueColor, you can take a shortcut
* and directly calculate the color pixel value to avoid the round trip. But, for
* example, on 16-bit color setups (VNC), you can easily get the closest supported
* RGB value to the RGB value you are specifying.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_alloc_color_cookie_t
xcb_alloc_color_unchecked (xcb_connection_t *c,
xcb_colormap_t cmap,
uint16_t red,
uint16_t green,
uint16_t blue);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_alloc_color_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_alloc_color_reply_t *
xcb_alloc_color_reply (xcb_connection_t *c,
xcb_alloc_color_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_alloc_named_color_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_alloc_named_color_cookie_t
xcb_alloc_named_color (xcb_connection_t *c,
xcb_colormap_t cmap,
uint16_t name_len,
const char *name);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_alloc_named_color_cookie_t
xcb_alloc_named_color_unchecked (xcb_connection_t *c,
xcb_colormap_t cmap,
uint16_t name_len,
const char *name);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_alloc_named_color_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_alloc_named_color_reply_t *
xcb_alloc_named_color_reply (xcb_connection_t *c,
xcb_alloc_named_color_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_alloc_color_cells_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_alloc_color_cells_cookie_t
xcb_alloc_color_cells (xcb_connection_t *c,
uint8_t contiguous,
xcb_colormap_t cmap,
uint16_t colors,
uint16_t planes);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_alloc_color_cells_cookie_t
xcb_alloc_color_cells_unchecked (xcb_connection_t *c,
uint8_t contiguous,
xcb_colormap_t cmap,
uint16_t colors,
uint16_t planes);
uint32_t *
xcb_alloc_color_cells_pixels (const xcb_alloc_color_cells_reply_t *R);
int
xcb_alloc_color_cells_pixels_length (const xcb_alloc_color_cells_reply_t *R);
xcb_generic_iterator_t
xcb_alloc_color_cells_pixels_end (const xcb_alloc_color_cells_reply_t *R);
uint32_t *
xcb_alloc_color_cells_masks (const xcb_alloc_color_cells_reply_t *R);
int
xcb_alloc_color_cells_masks_length (const xcb_alloc_color_cells_reply_t *R);
xcb_generic_iterator_t
xcb_alloc_color_cells_masks_end (const xcb_alloc_color_cells_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_alloc_color_cells_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_alloc_color_cells_reply_t *
xcb_alloc_color_cells_reply (xcb_connection_t *c,
xcb_alloc_color_cells_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_alloc_color_planes_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_alloc_color_planes_cookie_t
xcb_alloc_color_planes (xcb_connection_t *c,
uint8_t contiguous,
xcb_colormap_t cmap,
uint16_t colors,
uint16_t reds,
uint16_t greens,
uint16_t blues);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_alloc_color_planes_cookie_t
xcb_alloc_color_planes_unchecked (xcb_connection_t *c,
uint8_t contiguous,
xcb_colormap_t cmap,
uint16_t colors,
uint16_t reds,
uint16_t greens,
uint16_t blues);
uint32_t *
xcb_alloc_color_planes_pixels (const xcb_alloc_color_planes_reply_t *R);
int
xcb_alloc_color_planes_pixels_length (const xcb_alloc_color_planes_reply_t *R);
xcb_generic_iterator_t
xcb_alloc_color_planes_pixels_end (const xcb_alloc_color_planes_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_alloc_color_planes_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_alloc_color_planes_reply_t *
xcb_alloc_color_planes_reply (xcb_connection_t *c,
xcb_alloc_color_planes_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_free_colors_sizeof (const void *_buffer,
uint32_t pixels_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_free_colors_checked (xcb_connection_t *c,
xcb_colormap_t cmap,
uint32_t plane_mask,
uint32_t pixels_len,
const uint32_t *pixels);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_free_colors (xcb_connection_t *c,
xcb_colormap_t cmap,
uint32_t plane_mask,
uint32_t pixels_len,
const uint32_t *pixels);
uint32_t *
xcb_free_colors_pixels (const xcb_free_colors_request_t *R);
int
xcb_free_colors_pixels_length (const xcb_free_colors_request_t *R);
xcb_generic_iterator_t
xcb_free_colors_pixels_end (const xcb_free_colors_request_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_coloritem_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_coloritem_t)
*/
void
xcb_coloritem_next (xcb_coloritem_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_coloritem_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_coloritem_end (xcb_coloritem_iterator_t i);
int
xcb_store_colors_sizeof (const void *_buffer,
uint32_t items_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_store_colors_checked (xcb_connection_t *c,
xcb_colormap_t cmap,
uint32_t items_len,
const xcb_coloritem_t *items);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_store_colors (xcb_connection_t *c,
xcb_colormap_t cmap,
uint32_t items_len,
const xcb_coloritem_t *items);
xcb_coloritem_t *
xcb_store_colors_items (const xcb_store_colors_request_t *R);
int
xcb_store_colors_items_length (const xcb_store_colors_request_t *R);
xcb_coloritem_iterator_t
xcb_store_colors_items_iterator (const xcb_store_colors_request_t *R);
int
xcb_store_named_color_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_store_named_color_checked (xcb_connection_t *c,
uint8_t flags,
xcb_colormap_t cmap,
uint32_t pixel,
uint16_t name_len,
const char *name);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_store_named_color (xcb_connection_t *c,
uint8_t flags,
xcb_colormap_t cmap,
uint32_t pixel,
uint16_t name_len,
const char *name);
char *
xcb_store_named_color_name (const xcb_store_named_color_request_t *R);
int
xcb_store_named_color_name_length (const xcb_store_named_color_request_t *R);
xcb_generic_iterator_t
xcb_store_named_color_name_end (const xcb_store_named_color_request_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_rgb_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_rgb_t)
*/
void
xcb_rgb_next (xcb_rgb_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_rgb_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_rgb_end (xcb_rgb_iterator_t i);
int
xcb_query_colors_sizeof (const void *_buffer,
uint32_t pixels_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_query_colors_cookie_t
xcb_query_colors (xcb_connection_t *c,
xcb_colormap_t cmap,
uint32_t pixels_len,
const uint32_t *pixels);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_query_colors_cookie_t
xcb_query_colors_unchecked (xcb_connection_t *c,
xcb_colormap_t cmap,
uint32_t pixels_len,
const uint32_t *pixels);
xcb_rgb_t *
xcb_query_colors_colors (const xcb_query_colors_reply_t *R);
int
xcb_query_colors_colors_length (const xcb_query_colors_reply_t *R);
xcb_rgb_iterator_t
xcb_query_colors_colors_iterator (const xcb_query_colors_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_query_colors_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_query_colors_reply_t *
xcb_query_colors_reply (xcb_connection_t *c,
xcb_query_colors_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_lookup_color_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_lookup_color_cookie_t
xcb_lookup_color (xcb_connection_t *c,
xcb_colormap_t cmap,
uint16_t name_len,
const char *name);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_lookup_color_cookie_t
xcb_lookup_color_unchecked (xcb_connection_t *c,
xcb_colormap_t cmap,
uint16_t name_len,
const char *name);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_lookup_color_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_lookup_color_reply_t *
xcb_lookup_color_reply (xcb_connection_t *c,
xcb_lookup_color_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_create_cursor_checked (xcb_connection_t *c,
xcb_cursor_t cid,
xcb_pixmap_t source,
xcb_pixmap_t mask,
uint16_t fore_red,
uint16_t fore_green,
uint16_t fore_blue,
uint16_t back_red,
uint16_t back_green,
uint16_t back_blue,
uint16_t x,
uint16_t y);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_create_cursor (xcb_connection_t *c,
xcb_cursor_t cid,
xcb_pixmap_t source,
xcb_pixmap_t mask,
uint16_t fore_red,
uint16_t fore_green,
uint16_t fore_blue,
uint16_t back_red,
uint16_t back_green,
uint16_t back_blue,
uint16_t x,
uint16_t y);
/**
* @brief create cursor
*
* @param c The connection
* @param cid The ID with which you will refer to the cursor, created by `xcb_generate_id`.
* @param source_font In which font to look for the cursor glyph.
* @param mask_font In which font to look for the mask glyph.
* @param source_char The glyph of \a source_font to use.
* @param mask_char The glyph of \a mask_font to use as a mask: Pixels which are set to 1 define
* which source pixels are displayed. All pixels which are set to 0 are not
* displayed.
* @param fore_red The red value of the foreground color.
* @param fore_green The green value of the foreground color.
* @param fore_blue The blue value of the foreground color.
* @param back_red The red value of the background color.
* @param back_green The green value of the background color.
* @param back_blue The blue value of the background color.
* @return A cookie
*
* Creates a cursor from a font glyph. X provides a set of standard cursor shapes
* in a special font named cursor. Applications are encouraged to use this
* interface for their cursors because the font can be customized for the
* individual display type.
*
* All pixels which are set to 1 in the source will use the foreground color (as
* specified by \a fore_red, \a fore_green and \a fore_blue). All pixels set to 0
* will use the background color (as specified by \a back_red, \a back_green and
* \a back_blue).
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_create_glyph_cursor_checked (xcb_connection_t *c,
xcb_cursor_t cid,
xcb_font_t source_font,
xcb_font_t mask_font,
uint16_t source_char,
uint16_t mask_char,
uint16_t fore_red,
uint16_t fore_green,
uint16_t fore_blue,
uint16_t back_red,
uint16_t back_green,
uint16_t back_blue);
/**
* @brief create cursor
*
* @param c The connection
* @param cid The ID with which you will refer to the cursor, created by `xcb_generate_id`.
* @param source_font In which font to look for the cursor glyph.
* @param mask_font In which font to look for the mask glyph.
* @param source_char The glyph of \a source_font to use.
* @param mask_char The glyph of \a mask_font to use as a mask: Pixels which are set to 1 define
* which source pixels are displayed. All pixels which are set to 0 are not
* displayed.
* @param fore_red The red value of the foreground color.
* @param fore_green The green value of the foreground color.
* @param fore_blue The blue value of the foreground color.
* @param back_red The red value of the background color.
* @param back_green The green value of the background color.
* @param back_blue The blue value of the background color.
* @return A cookie
*
* Creates a cursor from a font glyph. X provides a set of standard cursor shapes
* in a special font named cursor. Applications are encouraged to use this
* interface for their cursors because the font can be customized for the
* individual display type.
*
* All pixels which are set to 1 in the source will use the foreground color (as
* specified by \a fore_red, \a fore_green and \a fore_blue). All pixels set to 0
* will use the background color (as specified by \a back_red, \a back_green and
* \a back_blue).
*
*/
xcb_void_cookie_t
xcb_create_glyph_cursor (xcb_connection_t *c,
xcb_cursor_t cid,
xcb_font_t source_font,
xcb_font_t mask_font,
uint16_t source_char,
uint16_t mask_char,
uint16_t fore_red,
uint16_t fore_green,
uint16_t fore_blue,
uint16_t back_red,
uint16_t back_green,
uint16_t back_blue);
/**
* @brief Deletes a cursor
*
* @param c The connection
* @param cursor The cursor to destroy.
* @return A cookie
*
* Deletes the association between the cursor resource ID and the specified
* cursor. The cursor is freed when no other resource references it.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_free_cursor_checked (xcb_connection_t *c,
xcb_cursor_t cursor);
/**
* @brief Deletes a cursor
*
* @param c The connection
* @param cursor The cursor to destroy.
* @return A cookie
*
* Deletes the association between the cursor resource ID and the specified
* cursor. The cursor is freed when no other resource references it.
*
*/
xcb_void_cookie_t
xcb_free_cursor (xcb_connection_t *c,
xcb_cursor_t cursor);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_recolor_cursor_checked (xcb_connection_t *c,
xcb_cursor_t cursor,
uint16_t fore_red,
uint16_t fore_green,
uint16_t fore_blue,
uint16_t back_red,
uint16_t back_green,
uint16_t back_blue);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_recolor_cursor (xcb_connection_t *c,
xcb_cursor_t cursor,
uint16_t fore_red,
uint16_t fore_green,
uint16_t fore_blue,
uint16_t back_red,
uint16_t back_green,
uint16_t back_blue);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_query_best_size_cookie_t
xcb_query_best_size (xcb_connection_t *c,
uint8_t _class,
xcb_drawable_t drawable,
uint16_t width,
uint16_t height);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_query_best_size_cookie_t
xcb_query_best_size_unchecked (xcb_connection_t *c,
uint8_t _class,
xcb_drawable_t drawable,
uint16_t width,
uint16_t height);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_query_best_size_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_query_best_size_reply_t *
xcb_query_best_size_reply (xcb_connection_t *c,
xcb_query_best_size_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_query_extension_sizeof (const void *_buffer);
/**
* @brief check if extension is present
*
* @param c The connection
* @param name_len The length of \a name in bytes.
* @param name The name of the extension to query, for example "RANDR". This is case
* sensitive!
* @return A cookie
*
* Determines if the specified extension is present on this X11 server.
*
* Every extension has a unique `major_opcode` to identify requests, the minor
* opcodes and request formats are extension-specific. If the extension provides
* events and errors, the `first_event` and `first_error` fields in the reply are
* set accordingly.
*
* There should rarely be a need to use this request directly, XCB provides the
* `xcb_get_extension_data` function instead.
*
*/
xcb_query_extension_cookie_t
xcb_query_extension (xcb_connection_t *c,
uint16_t name_len,
const char *name);
/**
* @brief check if extension is present
*
* @param c The connection
* @param name_len The length of \a name in bytes.
* @param name The name of the extension to query, for example "RANDR". This is case
* sensitive!
* @return A cookie
*
* Determines if the specified extension is present on this X11 server.
*
* Every extension has a unique `major_opcode` to identify requests, the minor
* opcodes and request formats are extension-specific. If the extension provides
* events and errors, the `first_event` and `first_error` fields in the reply are
* set accordingly.
*
* There should rarely be a need to use this request directly, XCB provides the
* `xcb_get_extension_data` function instead.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_query_extension_cookie_t
xcb_query_extension_unchecked (xcb_connection_t *c,
uint16_t name_len,
const char *name);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_query_extension_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_query_extension_reply_t *
xcb_query_extension_reply (xcb_connection_t *c,
xcb_query_extension_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_list_extensions_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_list_extensions_cookie_t
xcb_list_extensions (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_list_extensions_cookie_t
xcb_list_extensions_unchecked (xcb_connection_t *c);
int
xcb_list_extensions_names_length (const xcb_list_extensions_reply_t *R);
xcb_str_iterator_t
xcb_list_extensions_names_iterator (const xcb_list_extensions_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_list_extensions_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_list_extensions_reply_t *
xcb_list_extensions_reply (xcb_connection_t *c,
xcb_list_extensions_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_change_keyboard_mapping_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_change_keyboard_mapping_checked (xcb_connection_t *c,
uint8_t keycode_count,
xcb_keycode_t first_keycode,
uint8_t keysyms_per_keycode,
const xcb_keysym_t *keysyms);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_change_keyboard_mapping (xcb_connection_t *c,
uint8_t keycode_count,
xcb_keycode_t first_keycode,
uint8_t keysyms_per_keycode,
const xcb_keysym_t *keysyms);
xcb_keysym_t *
xcb_change_keyboard_mapping_keysyms (const xcb_change_keyboard_mapping_request_t *R);
int
xcb_change_keyboard_mapping_keysyms_length (const xcb_change_keyboard_mapping_request_t *R);
xcb_generic_iterator_t
xcb_change_keyboard_mapping_keysyms_end (const xcb_change_keyboard_mapping_request_t *R);
int
xcb_get_keyboard_mapping_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_get_keyboard_mapping_cookie_t
xcb_get_keyboard_mapping (xcb_connection_t *c,
xcb_keycode_t first_keycode,
uint8_t count);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_get_keyboard_mapping_cookie_t
xcb_get_keyboard_mapping_unchecked (xcb_connection_t *c,
xcb_keycode_t first_keycode,
uint8_t count);
xcb_keysym_t *
xcb_get_keyboard_mapping_keysyms (const xcb_get_keyboard_mapping_reply_t *R);
int
xcb_get_keyboard_mapping_keysyms_length (const xcb_get_keyboard_mapping_reply_t *R);
xcb_generic_iterator_t
xcb_get_keyboard_mapping_keysyms_end (const xcb_get_keyboard_mapping_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_get_keyboard_mapping_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_get_keyboard_mapping_reply_t *
xcb_get_keyboard_mapping_reply (xcb_connection_t *c,
xcb_get_keyboard_mapping_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_change_keyboard_control_value_list_serialize (void **_buffer,
uint32_t value_mask,
const xcb_change_keyboard_control_value_list_t *_aux);
int
xcb_change_keyboard_control_value_list_unpack (const void *_buffer,
uint32_t value_mask,
xcb_change_keyboard_control_value_list_t *_aux);
int
xcb_change_keyboard_control_value_list_sizeof (const void *_buffer,
uint32_t value_mask);
int
xcb_change_keyboard_control_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_change_keyboard_control_checked (xcb_connection_t *c,
uint32_t value_mask,
const void *value_list);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_change_keyboard_control (xcb_connection_t *c,
uint32_t value_mask,
const void *value_list);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_change_keyboard_control_aux_checked (xcb_connection_t *c,
uint32_t value_mask,
const xcb_change_keyboard_control_value_list_t *value_list);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_change_keyboard_control_aux (xcb_connection_t *c,
uint32_t value_mask,
const xcb_change_keyboard_control_value_list_t *value_list);
void *
xcb_change_keyboard_control_value_list (const xcb_change_keyboard_control_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_get_keyboard_control_cookie_t
xcb_get_keyboard_control (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_get_keyboard_control_cookie_t
xcb_get_keyboard_control_unchecked (xcb_connection_t *c);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_get_keyboard_control_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_get_keyboard_control_reply_t *
xcb_get_keyboard_control_reply (xcb_connection_t *c,
xcb_get_keyboard_control_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_bell_checked (xcb_connection_t *c,
int8_t percent);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_bell (xcb_connection_t *c,
int8_t percent);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_change_pointer_control_checked (xcb_connection_t *c,
int16_t acceleration_numerator,
int16_t acceleration_denominator,
int16_t threshold,
uint8_t do_acceleration,
uint8_t do_threshold);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_change_pointer_control (xcb_connection_t *c,
int16_t acceleration_numerator,
int16_t acceleration_denominator,
int16_t threshold,
uint8_t do_acceleration,
uint8_t do_threshold);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_get_pointer_control_cookie_t
xcb_get_pointer_control (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_get_pointer_control_cookie_t
xcb_get_pointer_control_unchecked (xcb_connection_t *c);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_get_pointer_control_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_get_pointer_control_reply_t *
xcb_get_pointer_control_reply (xcb_connection_t *c,
xcb_get_pointer_control_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_set_screen_saver_checked (xcb_connection_t *c,
int16_t timeout,
int16_t interval,
uint8_t prefer_blanking,
uint8_t allow_exposures);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_set_screen_saver (xcb_connection_t *c,
int16_t timeout,
int16_t interval,
uint8_t prefer_blanking,
uint8_t allow_exposures);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_get_screen_saver_cookie_t
xcb_get_screen_saver (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_get_screen_saver_cookie_t
xcb_get_screen_saver_unchecked (xcb_connection_t *c);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_get_screen_saver_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_get_screen_saver_reply_t *
xcb_get_screen_saver_reply (xcb_connection_t *c,
xcb_get_screen_saver_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_change_hosts_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_change_hosts_checked (xcb_connection_t *c,
uint8_t mode,
uint8_t family,
uint16_t address_len,
const uint8_t *address);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_change_hosts (xcb_connection_t *c,
uint8_t mode,
uint8_t family,
uint16_t address_len,
const uint8_t *address);
uint8_t *
xcb_change_hosts_address (const xcb_change_hosts_request_t *R);
int
xcb_change_hosts_address_length (const xcb_change_hosts_request_t *R);
xcb_generic_iterator_t
xcb_change_hosts_address_end (const xcb_change_hosts_request_t *R);
int
xcb_host_sizeof (const void *_buffer);
uint8_t *
xcb_host_address (const xcb_host_t *R);
int
xcb_host_address_length (const xcb_host_t *R);
xcb_generic_iterator_t
xcb_host_address_end (const xcb_host_t *R);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_host_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_host_t)
*/
void
xcb_host_next (xcb_host_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_host_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_host_end (xcb_host_iterator_t i);
int
xcb_list_hosts_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_list_hosts_cookie_t
xcb_list_hosts (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_list_hosts_cookie_t
xcb_list_hosts_unchecked (xcb_connection_t *c);
int
xcb_list_hosts_hosts_length (const xcb_list_hosts_reply_t *R);
xcb_host_iterator_t
xcb_list_hosts_hosts_iterator (const xcb_list_hosts_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_list_hosts_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_list_hosts_reply_t *
xcb_list_hosts_reply (xcb_connection_t *c,
xcb_list_hosts_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_set_access_control_checked (xcb_connection_t *c,
uint8_t mode);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_set_access_control (xcb_connection_t *c,
uint8_t mode);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_set_close_down_mode_checked (xcb_connection_t *c,
uint8_t mode);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_set_close_down_mode (xcb_connection_t *c,
uint8_t mode);
/**
* @brief kills a client
*
* @param c The connection
* @param resource Any resource belonging to the client (for example a Window), used to identify
* the client connection.
* \n
* The special value of `XCB_KILL_ALL_TEMPORARY`, the resources of all clients
* that have terminated in `RetainTemporary` (TODO) are destroyed.
* @return A cookie
*
* Forces a close down of the client that created the specified \a resource.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_kill_client_checked (xcb_connection_t *c,
uint32_t resource);
/**
* @brief kills a client
*
* @param c The connection
* @param resource Any resource belonging to the client (for example a Window), used to identify
* the client connection.
* \n
* The special value of `XCB_KILL_ALL_TEMPORARY`, the resources of all clients
* that have terminated in `RetainTemporary` (TODO) are destroyed.
* @return A cookie
*
* Forces a close down of the client that created the specified \a resource.
*
*/
xcb_void_cookie_t
xcb_kill_client (xcb_connection_t *c,
uint32_t resource);
int
xcb_rotate_properties_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_rotate_properties_checked (xcb_connection_t *c,
xcb_window_t window,
uint16_t atoms_len,
int16_t delta,
const xcb_atom_t *atoms);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_rotate_properties (xcb_connection_t *c,
xcb_window_t window,
uint16_t atoms_len,
int16_t delta,
const xcb_atom_t *atoms);
xcb_atom_t *
xcb_rotate_properties_atoms (const xcb_rotate_properties_request_t *R);
int
xcb_rotate_properties_atoms_length (const xcb_rotate_properties_request_t *R);
xcb_generic_iterator_t
xcb_rotate_properties_atoms_end (const xcb_rotate_properties_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_force_screen_saver_checked (xcb_connection_t *c,
uint8_t mode);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_force_screen_saver (xcb_connection_t *c,
uint8_t mode);
int
xcb_set_pointer_mapping_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_set_pointer_mapping_cookie_t
xcb_set_pointer_mapping (xcb_connection_t *c,
uint8_t map_len,
const uint8_t *map);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_set_pointer_mapping_cookie_t
xcb_set_pointer_mapping_unchecked (xcb_connection_t *c,
uint8_t map_len,
const uint8_t *map);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_set_pointer_mapping_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_set_pointer_mapping_reply_t *
xcb_set_pointer_mapping_reply (xcb_connection_t *c,
xcb_set_pointer_mapping_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_get_pointer_mapping_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_get_pointer_mapping_cookie_t
xcb_get_pointer_mapping (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_get_pointer_mapping_cookie_t
xcb_get_pointer_mapping_unchecked (xcb_connection_t *c);
uint8_t *
xcb_get_pointer_mapping_map (const xcb_get_pointer_mapping_reply_t *R);
int
xcb_get_pointer_mapping_map_length (const xcb_get_pointer_mapping_reply_t *R);
xcb_generic_iterator_t
xcb_get_pointer_mapping_map_end (const xcb_get_pointer_mapping_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_get_pointer_mapping_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_get_pointer_mapping_reply_t *
xcb_get_pointer_mapping_reply (xcb_connection_t *c,
xcb_get_pointer_mapping_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_set_modifier_mapping_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_set_modifier_mapping_cookie_t
xcb_set_modifier_mapping (xcb_connection_t *c,
uint8_t keycodes_per_modifier,
const xcb_keycode_t *keycodes);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_set_modifier_mapping_cookie_t
xcb_set_modifier_mapping_unchecked (xcb_connection_t *c,
uint8_t keycodes_per_modifier,
const xcb_keycode_t *keycodes);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_set_modifier_mapping_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_set_modifier_mapping_reply_t *
xcb_set_modifier_mapping_reply (xcb_connection_t *c,
xcb_set_modifier_mapping_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_get_modifier_mapping_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_get_modifier_mapping_cookie_t
xcb_get_modifier_mapping (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_get_modifier_mapping_cookie_t
xcb_get_modifier_mapping_unchecked (xcb_connection_t *c);
xcb_keycode_t *
xcb_get_modifier_mapping_keycodes (const xcb_get_modifier_mapping_reply_t *R);
int
xcb_get_modifier_mapping_keycodes_length (const xcb_get_modifier_mapping_reply_t *R);
xcb_generic_iterator_t
xcb_get_modifier_mapping_keycodes_end (const xcb_get_modifier_mapping_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_get_modifier_mapping_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_get_modifier_mapping_reply_t *
xcb_get_modifier_mapping_reply (xcb_connection_t *c,
xcb_get_modifier_mapping_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_no_operation_checked (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_no_operation (xcb_connection_t *c);
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/
xcb/damage.h 0000644 00000022105 15201526705 0006712 0 ustar 00 /*
* This file generated automatically from damage.xml by c_client.py.
* Edit at your peril.
*/
/**
* @defgroup XCB_Damage_API XCB Damage API
* @brief Damage XCB Protocol Implementation.
* @{
**/
#ifndef __DAMAGE_H
#define __DAMAGE_H
#include "xcb.h"
#include "xproto.h"
#include "xfixes.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XCB_DAMAGE_MAJOR_VERSION 1
#define XCB_DAMAGE_MINOR_VERSION 1
extern xcb_extension_t xcb_damage_id;
typedef uint32_t xcb_damage_damage_t;
/**
* @brief xcb_damage_damage_iterator_t
**/
typedef struct xcb_damage_damage_iterator_t {
xcb_damage_damage_t *data;
int rem;
int index;
} xcb_damage_damage_iterator_t;
typedef enum xcb_damage_report_level_t {
XCB_DAMAGE_REPORT_LEVEL_RAW_RECTANGLES = 0,
XCB_DAMAGE_REPORT_LEVEL_DELTA_RECTANGLES = 1,
XCB_DAMAGE_REPORT_LEVEL_BOUNDING_BOX = 2,
XCB_DAMAGE_REPORT_LEVEL_NON_EMPTY = 3
} xcb_damage_report_level_t;
/** Opcode for xcb_damage_bad_damage. */
#define XCB_DAMAGE_BAD_DAMAGE 0
/**
* @brief xcb_damage_bad_damage_error_t
**/
typedef struct xcb_damage_bad_damage_error_t {
uint8_t response_type;
uint8_t error_code;
uint16_t sequence;
} xcb_damage_bad_damage_error_t;
/**
* @brief xcb_damage_query_version_cookie_t
**/
typedef struct xcb_damage_query_version_cookie_t {
unsigned int sequence;
} xcb_damage_query_version_cookie_t;
/** Opcode for xcb_damage_query_version. */
#define XCB_DAMAGE_QUERY_VERSION 0
/**
* @brief xcb_damage_query_version_request_t
**/
typedef struct xcb_damage_query_version_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t client_major_version;
uint32_t client_minor_version;
} xcb_damage_query_version_request_t;
/**
* @brief xcb_damage_query_version_reply_t
**/
typedef struct xcb_damage_query_version_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t major_version;
uint32_t minor_version;
uint8_t pad1[16];
} xcb_damage_query_version_reply_t;
/** Opcode for xcb_damage_create. */
#define XCB_DAMAGE_CREATE 1
/**
* @brief xcb_damage_create_request_t
**/
typedef struct xcb_damage_create_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_damage_damage_t damage;
xcb_drawable_t drawable;
uint8_t level;
uint8_t pad0[3];
} xcb_damage_create_request_t;
/** Opcode for xcb_damage_destroy. */
#define XCB_DAMAGE_DESTROY 2
/**
* @brief xcb_damage_destroy_request_t
**/
typedef struct xcb_damage_destroy_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_damage_damage_t damage;
} xcb_damage_destroy_request_t;
/** Opcode for xcb_damage_subtract. */
#define XCB_DAMAGE_SUBTRACT 3
/**
* @brief xcb_damage_subtract_request_t
**/
typedef struct xcb_damage_subtract_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_damage_damage_t damage;
xcb_xfixes_region_t repair;
xcb_xfixes_region_t parts;
} xcb_damage_subtract_request_t;
/** Opcode for xcb_damage_add. */
#define XCB_DAMAGE_ADD 4
/**
* @brief xcb_damage_add_request_t
**/
typedef struct xcb_damage_add_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_drawable_t drawable;
xcb_xfixes_region_t region;
} xcb_damage_add_request_t;
/** Opcode for xcb_damage_notify. */
#define XCB_DAMAGE_NOTIFY 0
/**
* @brief xcb_damage_notify_event_t
**/
typedef struct xcb_damage_notify_event_t {
uint8_t response_type;
uint8_t level;
uint16_t sequence;
xcb_drawable_t drawable;
xcb_damage_damage_t damage;
xcb_timestamp_t timestamp;
xcb_rectangle_t area;
xcb_rectangle_t geometry;
} xcb_damage_notify_event_t;
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_damage_damage_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_damage_damage_t)
*/
void
xcb_damage_damage_next (xcb_damage_damage_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_damage_damage_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_damage_damage_end (xcb_damage_damage_iterator_t i);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_damage_query_version_cookie_t
xcb_damage_query_version (xcb_connection_t *c,
uint32_t client_major_version,
uint32_t client_minor_version);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_damage_query_version_cookie_t
xcb_damage_query_version_unchecked (xcb_connection_t *c,
uint32_t client_major_version,
uint32_t client_minor_version);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_damage_query_version_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_damage_query_version_reply_t *
xcb_damage_query_version_reply (xcb_connection_t *c,
xcb_damage_query_version_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_damage_create_checked (xcb_connection_t *c,
xcb_damage_damage_t damage,
xcb_drawable_t drawable,
uint8_t level);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_damage_create (xcb_connection_t *c,
xcb_damage_damage_t damage,
xcb_drawable_t drawable,
uint8_t level);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_damage_destroy_checked (xcb_connection_t *c,
xcb_damage_damage_t damage);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_damage_destroy (xcb_connection_t *c,
xcb_damage_damage_t damage);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_damage_subtract_checked (xcb_connection_t *c,
xcb_damage_damage_t damage,
xcb_xfixes_region_t repair,
xcb_xfixes_region_t parts);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_damage_subtract (xcb_connection_t *c,
xcb_damage_damage_t damage,
xcb_xfixes_region_t repair,
xcb_xfixes_region_t parts);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_damage_add_checked (xcb_connection_t *c,
xcb_drawable_t drawable,
xcb_xfixes_region_t region);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_damage_add (xcb_connection_t *c,
xcb_drawable_t drawable,
xcb_xfixes_region_t region);
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/
xcb/xfixes.h 0000644 00000161337 15201526705 0007015 0 ustar 00 /*
* This file generated automatically from xfixes.xml by c_client.py.
* Edit at your peril.
*/
/**
* @defgroup XCB_XFixes_API XCB XFixes API
* @brief XFixes XCB Protocol Implementation.
* @{
**/
#ifndef __XFIXES_H
#define __XFIXES_H
#include "xcb.h"
#include "xproto.h"
#include "render.h"
#include "shape.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XCB_XFIXES_MAJOR_VERSION 5
#define XCB_XFIXES_MINOR_VERSION 0
extern xcb_extension_t xcb_xfixes_id;
/**
* @brief xcb_xfixes_query_version_cookie_t
**/
typedef struct xcb_xfixes_query_version_cookie_t {
unsigned int sequence;
} xcb_xfixes_query_version_cookie_t;
/** Opcode for xcb_xfixes_query_version. */
#define XCB_XFIXES_QUERY_VERSION 0
/**
* @brief xcb_xfixes_query_version_request_t
**/
typedef struct xcb_xfixes_query_version_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t client_major_version;
uint32_t client_minor_version;
} xcb_xfixes_query_version_request_t;
/**
* @brief xcb_xfixes_query_version_reply_t
**/
typedef struct xcb_xfixes_query_version_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t major_version;
uint32_t minor_version;
uint8_t pad1[16];
} xcb_xfixes_query_version_reply_t;
typedef enum xcb_xfixes_save_set_mode_t {
XCB_XFIXES_SAVE_SET_MODE_INSERT = 0,
XCB_XFIXES_SAVE_SET_MODE_DELETE = 1
} xcb_xfixes_save_set_mode_t;
typedef enum xcb_xfixes_save_set_target_t {
XCB_XFIXES_SAVE_SET_TARGET_NEAREST = 0,
XCB_XFIXES_SAVE_SET_TARGET_ROOT = 1
} xcb_xfixes_save_set_target_t;
typedef enum xcb_xfixes_save_set_mapping_t {
XCB_XFIXES_SAVE_SET_MAPPING_MAP = 0,
XCB_XFIXES_SAVE_SET_MAPPING_UNMAP = 1
} xcb_xfixes_save_set_mapping_t;
/** Opcode for xcb_xfixes_change_save_set. */
#define XCB_XFIXES_CHANGE_SAVE_SET 1
/**
* @brief xcb_xfixes_change_save_set_request_t
**/
typedef struct xcb_xfixes_change_save_set_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t mode;
uint8_t target;
uint8_t map;
uint8_t pad0;
xcb_window_t window;
} xcb_xfixes_change_save_set_request_t;
typedef enum xcb_xfixes_selection_event_t {
XCB_XFIXES_SELECTION_EVENT_SET_SELECTION_OWNER = 0,
XCB_XFIXES_SELECTION_EVENT_SELECTION_WINDOW_DESTROY = 1,
XCB_XFIXES_SELECTION_EVENT_SELECTION_CLIENT_CLOSE = 2
} xcb_xfixes_selection_event_t;
typedef enum xcb_xfixes_selection_event_mask_t {
XCB_XFIXES_SELECTION_EVENT_MASK_SET_SELECTION_OWNER = 1,
XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_WINDOW_DESTROY = 2,
XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_CLIENT_CLOSE = 4
} xcb_xfixes_selection_event_mask_t;
/** Opcode for xcb_xfixes_selection_notify. */
#define XCB_XFIXES_SELECTION_NOTIFY 0
/**
* @brief xcb_xfixes_selection_notify_event_t
**/
typedef struct xcb_xfixes_selection_notify_event_t {
uint8_t response_type;
uint8_t subtype;
uint16_t sequence;
xcb_window_t window;
xcb_window_t owner;
xcb_atom_t selection;
xcb_timestamp_t timestamp;
xcb_timestamp_t selection_timestamp;
uint8_t pad0[8];
} xcb_xfixes_selection_notify_event_t;
/** Opcode for xcb_xfixes_select_selection_input. */
#define XCB_XFIXES_SELECT_SELECTION_INPUT 2
/**
* @brief xcb_xfixes_select_selection_input_request_t
**/
typedef struct xcb_xfixes_select_selection_input_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
xcb_atom_t selection;
uint32_t event_mask;
} xcb_xfixes_select_selection_input_request_t;
typedef enum xcb_xfixes_cursor_notify_t {
XCB_XFIXES_CURSOR_NOTIFY_DISPLAY_CURSOR = 0
} xcb_xfixes_cursor_notify_t;
typedef enum xcb_xfixes_cursor_notify_mask_t {
XCB_XFIXES_CURSOR_NOTIFY_MASK_DISPLAY_CURSOR = 1
} xcb_xfixes_cursor_notify_mask_t;
/** Opcode for xcb_xfixes_cursor_notify. */
#define XCB_XFIXES_CURSOR_NOTIFY 1
/**
* @brief xcb_xfixes_cursor_notify_event_t
**/
typedef struct xcb_xfixes_cursor_notify_event_t {
uint8_t response_type;
uint8_t subtype;
uint16_t sequence;
xcb_window_t window;
uint32_t cursor_serial;
xcb_timestamp_t timestamp;
xcb_atom_t name;
uint8_t pad0[12];
} xcb_xfixes_cursor_notify_event_t;
/** Opcode for xcb_xfixes_select_cursor_input. */
#define XCB_XFIXES_SELECT_CURSOR_INPUT 3
/**
* @brief xcb_xfixes_select_cursor_input_request_t
**/
typedef struct xcb_xfixes_select_cursor_input_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
uint32_t event_mask;
} xcb_xfixes_select_cursor_input_request_t;
/**
* @brief xcb_xfixes_get_cursor_image_cookie_t
**/
typedef struct xcb_xfixes_get_cursor_image_cookie_t {
unsigned int sequence;
} xcb_xfixes_get_cursor_image_cookie_t;
/** Opcode for xcb_xfixes_get_cursor_image. */
#define XCB_XFIXES_GET_CURSOR_IMAGE 4
/**
* @brief xcb_xfixes_get_cursor_image_request_t
**/
typedef struct xcb_xfixes_get_cursor_image_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_xfixes_get_cursor_image_request_t;
/**
* @brief xcb_xfixes_get_cursor_image_reply_t
**/
typedef struct xcb_xfixes_get_cursor_image_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
int16_t x;
int16_t y;
uint16_t width;
uint16_t height;
uint16_t xhot;
uint16_t yhot;
uint32_t cursor_serial;
uint8_t pad1[8];
} xcb_xfixes_get_cursor_image_reply_t;
typedef uint32_t xcb_xfixes_region_t;
/**
* @brief xcb_xfixes_region_iterator_t
**/
typedef struct xcb_xfixes_region_iterator_t {
xcb_xfixes_region_t *data;
int rem;
int index;
} xcb_xfixes_region_iterator_t;
/** Opcode for xcb_xfixes_bad_region. */
#define XCB_XFIXES_BAD_REGION 0
/**
* @brief xcb_xfixes_bad_region_error_t
**/
typedef struct xcb_xfixes_bad_region_error_t {
uint8_t response_type;
uint8_t error_code;
uint16_t sequence;
} xcb_xfixes_bad_region_error_t;
typedef enum xcb_xfixes_region_enum_t {
XCB_XFIXES_REGION_NONE = 0
} xcb_xfixes_region_enum_t;
/** Opcode for xcb_xfixes_create_region. */
#define XCB_XFIXES_CREATE_REGION 5
/**
* @brief xcb_xfixes_create_region_request_t
**/
typedef struct xcb_xfixes_create_region_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xfixes_region_t region;
} xcb_xfixes_create_region_request_t;
/** Opcode for xcb_xfixes_create_region_from_bitmap. */
#define XCB_XFIXES_CREATE_REGION_FROM_BITMAP 6
/**
* @brief xcb_xfixes_create_region_from_bitmap_request_t
**/
typedef struct xcb_xfixes_create_region_from_bitmap_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xfixes_region_t region;
xcb_pixmap_t bitmap;
} xcb_xfixes_create_region_from_bitmap_request_t;
/** Opcode for xcb_xfixes_create_region_from_window. */
#define XCB_XFIXES_CREATE_REGION_FROM_WINDOW 7
/**
* @brief xcb_xfixes_create_region_from_window_request_t
**/
typedef struct xcb_xfixes_create_region_from_window_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xfixes_region_t region;
xcb_window_t window;
xcb_shape_kind_t kind;
uint8_t pad0[3];
} xcb_xfixes_create_region_from_window_request_t;
/** Opcode for xcb_xfixes_create_region_from_gc. */
#define XCB_XFIXES_CREATE_REGION_FROM_GC 8
/**
* @brief xcb_xfixes_create_region_from_gc_request_t
**/
typedef struct xcb_xfixes_create_region_from_gc_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xfixes_region_t region;
xcb_gcontext_t gc;
} xcb_xfixes_create_region_from_gc_request_t;
/** Opcode for xcb_xfixes_create_region_from_picture. */
#define XCB_XFIXES_CREATE_REGION_FROM_PICTURE 9
/**
* @brief xcb_xfixes_create_region_from_picture_request_t
**/
typedef struct xcb_xfixes_create_region_from_picture_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xfixes_region_t region;
xcb_render_picture_t picture;
} xcb_xfixes_create_region_from_picture_request_t;
/** Opcode for xcb_xfixes_destroy_region. */
#define XCB_XFIXES_DESTROY_REGION 10
/**
* @brief xcb_xfixes_destroy_region_request_t
**/
typedef struct xcb_xfixes_destroy_region_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xfixes_region_t region;
} xcb_xfixes_destroy_region_request_t;
/** Opcode for xcb_xfixes_set_region. */
#define XCB_XFIXES_SET_REGION 11
/**
* @brief xcb_xfixes_set_region_request_t
**/
typedef struct xcb_xfixes_set_region_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xfixes_region_t region;
} xcb_xfixes_set_region_request_t;
/** Opcode for xcb_xfixes_copy_region. */
#define XCB_XFIXES_COPY_REGION 12
/**
* @brief xcb_xfixes_copy_region_request_t
**/
typedef struct xcb_xfixes_copy_region_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xfixes_region_t source;
xcb_xfixes_region_t destination;
} xcb_xfixes_copy_region_request_t;
/** Opcode for xcb_xfixes_union_region. */
#define XCB_XFIXES_UNION_REGION 13
/**
* @brief xcb_xfixes_union_region_request_t
**/
typedef struct xcb_xfixes_union_region_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xfixes_region_t source1;
xcb_xfixes_region_t source2;
xcb_xfixes_region_t destination;
} xcb_xfixes_union_region_request_t;
/** Opcode for xcb_xfixes_intersect_region. */
#define XCB_XFIXES_INTERSECT_REGION 14
/**
* @brief xcb_xfixes_intersect_region_request_t
**/
typedef struct xcb_xfixes_intersect_region_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xfixes_region_t source1;
xcb_xfixes_region_t source2;
xcb_xfixes_region_t destination;
} xcb_xfixes_intersect_region_request_t;
/** Opcode for xcb_xfixes_subtract_region. */
#define XCB_XFIXES_SUBTRACT_REGION 15
/**
* @brief xcb_xfixes_subtract_region_request_t
**/
typedef struct xcb_xfixes_subtract_region_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xfixes_region_t source1;
xcb_xfixes_region_t source2;
xcb_xfixes_region_t destination;
} xcb_xfixes_subtract_region_request_t;
/** Opcode for xcb_xfixes_invert_region. */
#define XCB_XFIXES_INVERT_REGION 16
/**
* @brief xcb_xfixes_invert_region_request_t
**/
typedef struct xcb_xfixes_invert_region_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xfixes_region_t source;
xcb_rectangle_t bounds;
xcb_xfixes_region_t destination;
} xcb_xfixes_invert_region_request_t;
/** Opcode for xcb_xfixes_translate_region. */
#define XCB_XFIXES_TRANSLATE_REGION 17
/**
* @brief xcb_xfixes_translate_region_request_t
**/
typedef struct xcb_xfixes_translate_region_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xfixes_region_t region;
int16_t dx;
int16_t dy;
} xcb_xfixes_translate_region_request_t;
/** Opcode for xcb_xfixes_region_extents. */
#define XCB_XFIXES_REGION_EXTENTS 18
/**
* @brief xcb_xfixes_region_extents_request_t
**/
typedef struct xcb_xfixes_region_extents_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xfixes_region_t source;
xcb_xfixes_region_t destination;
} xcb_xfixes_region_extents_request_t;
/**
* @brief xcb_xfixes_fetch_region_cookie_t
**/
typedef struct xcb_xfixes_fetch_region_cookie_t {
unsigned int sequence;
} xcb_xfixes_fetch_region_cookie_t;
/** Opcode for xcb_xfixes_fetch_region. */
#define XCB_XFIXES_FETCH_REGION 19
/**
* @brief xcb_xfixes_fetch_region_request_t
**/
typedef struct xcb_xfixes_fetch_region_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xfixes_region_t region;
} xcb_xfixes_fetch_region_request_t;
/**
* @brief xcb_xfixes_fetch_region_reply_t
**/
typedef struct xcb_xfixes_fetch_region_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
xcb_rectangle_t extents;
uint8_t pad1[16];
} xcb_xfixes_fetch_region_reply_t;
/** Opcode for xcb_xfixes_set_gc_clip_region. */
#define XCB_XFIXES_SET_GC_CLIP_REGION 20
/**
* @brief xcb_xfixes_set_gc_clip_region_request_t
**/
typedef struct xcb_xfixes_set_gc_clip_region_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_gcontext_t gc;
xcb_xfixes_region_t region;
int16_t x_origin;
int16_t y_origin;
} xcb_xfixes_set_gc_clip_region_request_t;
/** Opcode for xcb_xfixes_set_window_shape_region. */
#define XCB_XFIXES_SET_WINDOW_SHAPE_REGION 21
/**
* @brief xcb_xfixes_set_window_shape_region_request_t
**/
typedef struct xcb_xfixes_set_window_shape_region_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t dest;
xcb_shape_kind_t dest_kind;
uint8_t pad0[3];
int16_t x_offset;
int16_t y_offset;
xcb_xfixes_region_t region;
} xcb_xfixes_set_window_shape_region_request_t;
/** Opcode for xcb_xfixes_set_picture_clip_region. */
#define XCB_XFIXES_SET_PICTURE_CLIP_REGION 22
/**
* @brief xcb_xfixes_set_picture_clip_region_request_t
**/
typedef struct xcb_xfixes_set_picture_clip_region_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_render_picture_t picture;
xcb_xfixes_region_t region;
int16_t x_origin;
int16_t y_origin;
} xcb_xfixes_set_picture_clip_region_request_t;
/** Opcode for xcb_xfixes_set_cursor_name. */
#define XCB_XFIXES_SET_CURSOR_NAME 23
/**
* @brief xcb_xfixes_set_cursor_name_request_t
**/
typedef struct xcb_xfixes_set_cursor_name_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_cursor_t cursor;
uint16_t nbytes;
uint8_t pad0[2];
} xcb_xfixes_set_cursor_name_request_t;
/**
* @brief xcb_xfixes_get_cursor_name_cookie_t
**/
typedef struct xcb_xfixes_get_cursor_name_cookie_t {
unsigned int sequence;
} xcb_xfixes_get_cursor_name_cookie_t;
/** Opcode for xcb_xfixes_get_cursor_name. */
#define XCB_XFIXES_GET_CURSOR_NAME 24
/**
* @brief xcb_xfixes_get_cursor_name_request_t
**/
typedef struct xcb_xfixes_get_cursor_name_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_cursor_t cursor;
} xcb_xfixes_get_cursor_name_request_t;
/**
* @brief xcb_xfixes_get_cursor_name_reply_t
**/
typedef struct xcb_xfixes_get_cursor_name_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
xcb_atom_t atom;
uint16_t nbytes;
uint8_t pad1[18];
} xcb_xfixes_get_cursor_name_reply_t;
/**
* @brief xcb_xfixes_get_cursor_image_and_name_cookie_t
**/
typedef struct xcb_xfixes_get_cursor_image_and_name_cookie_t {
unsigned int sequence;
} xcb_xfixes_get_cursor_image_and_name_cookie_t;
/** Opcode for xcb_xfixes_get_cursor_image_and_name. */
#define XCB_XFIXES_GET_CURSOR_IMAGE_AND_NAME 25
/**
* @brief xcb_xfixes_get_cursor_image_and_name_request_t
**/
typedef struct xcb_xfixes_get_cursor_image_and_name_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_xfixes_get_cursor_image_and_name_request_t;
/**
* @brief xcb_xfixes_get_cursor_image_and_name_reply_t
**/
typedef struct xcb_xfixes_get_cursor_image_and_name_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
int16_t x;
int16_t y;
uint16_t width;
uint16_t height;
uint16_t xhot;
uint16_t yhot;
uint32_t cursor_serial;
xcb_atom_t cursor_atom;
uint16_t nbytes;
uint8_t pad1[2];
} xcb_xfixes_get_cursor_image_and_name_reply_t;
/** Opcode for xcb_xfixes_change_cursor. */
#define XCB_XFIXES_CHANGE_CURSOR 26
/**
* @brief xcb_xfixes_change_cursor_request_t
**/
typedef struct xcb_xfixes_change_cursor_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_cursor_t source;
xcb_cursor_t destination;
} xcb_xfixes_change_cursor_request_t;
/** Opcode for xcb_xfixes_change_cursor_by_name. */
#define XCB_XFIXES_CHANGE_CURSOR_BY_NAME 27
/**
* @brief xcb_xfixes_change_cursor_by_name_request_t
**/
typedef struct xcb_xfixes_change_cursor_by_name_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_cursor_t src;
uint16_t nbytes;
uint8_t pad0[2];
} xcb_xfixes_change_cursor_by_name_request_t;
/** Opcode for xcb_xfixes_expand_region. */
#define XCB_XFIXES_EXPAND_REGION 28
/**
* @brief xcb_xfixes_expand_region_request_t
**/
typedef struct xcb_xfixes_expand_region_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xfixes_region_t source;
xcb_xfixes_region_t destination;
uint16_t left;
uint16_t right;
uint16_t top;
uint16_t bottom;
} xcb_xfixes_expand_region_request_t;
/** Opcode for xcb_xfixes_hide_cursor. */
#define XCB_XFIXES_HIDE_CURSOR 29
/**
* @brief xcb_xfixes_hide_cursor_request_t
**/
typedef struct xcb_xfixes_hide_cursor_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
} xcb_xfixes_hide_cursor_request_t;
/** Opcode for xcb_xfixes_show_cursor. */
#define XCB_XFIXES_SHOW_CURSOR 30
/**
* @brief xcb_xfixes_show_cursor_request_t
**/
typedef struct xcb_xfixes_show_cursor_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
} xcb_xfixes_show_cursor_request_t;
typedef uint32_t xcb_xfixes_barrier_t;
/**
* @brief xcb_xfixes_barrier_iterator_t
**/
typedef struct xcb_xfixes_barrier_iterator_t {
xcb_xfixes_barrier_t *data;
int rem;
int index;
} xcb_xfixes_barrier_iterator_t;
typedef enum xcb_xfixes_barrier_directions_t {
XCB_XFIXES_BARRIER_DIRECTIONS_POSITIVE_X = 1,
XCB_XFIXES_BARRIER_DIRECTIONS_POSITIVE_Y = 2,
XCB_XFIXES_BARRIER_DIRECTIONS_NEGATIVE_X = 4,
XCB_XFIXES_BARRIER_DIRECTIONS_NEGATIVE_Y = 8
} xcb_xfixes_barrier_directions_t;
/** Opcode for xcb_xfixes_create_pointer_barrier. */
#define XCB_XFIXES_CREATE_POINTER_BARRIER 31
/**
* @brief xcb_xfixes_create_pointer_barrier_request_t
**/
typedef struct xcb_xfixes_create_pointer_barrier_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xfixes_barrier_t barrier;
xcb_window_t window;
uint16_t x1;
uint16_t y1;
uint16_t x2;
uint16_t y2;
uint32_t directions;
uint8_t pad0[2];
uint16_t num_devices;
} xcb_xfixes_create_pointer_barrier_request_t;
/** Opcode for xcb_xfixes_delete_pointer_barrier. */
#define XCB_XFIXES_DELETE_POINTER_BARRIER 32
/**
* @brief xcb_xfixes_delete_pointer_barrier_request_t
**/
typedef struct xcb_xfixes_delete_pointer_barrier_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xfixes_barrier_t barrier;
} xcb_xfixes_delete_pointer_barrier_request_t;
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xfixes_query_version_cookie_t
xcb_xfixes_query_version (xcb_connection_t *c,
uint32_t client_major_version,
uint32_t client_minor_version);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xfixes_query_version_cookie_t
xcb_xfixes_query_version_unchecked (xcb_connection_t *c,
uint32_t client_major_version,
uint32_t client_minor_version);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xfixes_query_version_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xfixes_query_version_reply_t *
xcb_xfixes_query_version_reply (xcb_connection_t *c,
xcb_xfixes_query_version_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xfixes_change_save_set_checked (xcb_connection_t *c,
uint8_t mode,
uint8_t target,
uint8_t map,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xfixes_change_save_set (xcb_connection_t *c,
uint8_t mode,
uint8_t target,
uint8_t map,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xfixes_select_selection_input_checked (xcb_connection_t *c,
xcb_window_t window,
xcb_atom_t selection,
uint32_t event_mask);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xfixes_select_selection_input (xcb_connection_t *c,
xcb_window_t window,
xcb_atom_t selection,
uint32_t event_mask);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xfixes_select_cursor_input_checked (xcb_connection_t *c,
xcb_window_t window,
uint32_t event_mask);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xfixes_select_cursor_input (xcb_connection_t *c,
xcb_window_t window,
uint32_t event_mask);
int
xcb_xfixes_get_cursor_image_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xfixes_get_cursor_image_cookie_t
xcb_xfixes_get_cursor_image (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xfixes_get_cursor_image_cookie_t
xcb_xfixes_get_cursor_image_unchecked (xcb_connection_t *c);
uint32_t *
xcb_xfixes_get_cursor_image_cursor_image (const xcb_xfixes_get_cursor_image_reply_t *R);
int
xcb_xfixes_get_cursor_image_cursor_image_length (const xcb_xfixes_get_cursor_image_reply_t *R);
xcb_generic_iterator_t
xcb_xfixes_get_cursor_image_cursor_image_end (const xcb_xfixes_get_cursor_image_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xfixes_get_cursor_image_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xfixes_get_cursor_image_reply_t *
xcb_xfixes_get_cursor_image_reply (xcb_connection_t *c,
xcb_xfixes_get_cursor_image_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xfixes_region_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xfixes_region_t)
*/
void
xcb_xfixes_region_next (xcb_xfixes_region_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xfixes_region_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xfixes_region_end (xcb_xfixes_region_iterator_t i);
int
xcb_xfixes_create_region_sizeof (const void *_buffer,
uint32_t rectangles_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xfixes_create_region_checked (xcb_connection_t *c,
xcb_xfixes_region_t region,
uint32_t rectangles_len,
const xcb_rectangle_t *rectangles);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xfixes_create_region (xcb_connection_t *c,
xcb_xfixes_region_t region,
uint32_t rectangles_len,
const xcb_rectangle_t *rectangles);
xcb_rectangle_t *
xcb_xfixes_create_region_rectangles (const xcb_xfixes_create_region_request_t *R);
int
xcb_xfixes_create_region_rectangles_length (const xcb_xfixes_create_region_request_t *R);
xcb_rectangle_iterator_t
xcb_xfixes_create_region_rectangles_iterator (const xcb_xfixes_create_region_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xfixes_create_region_from_bitmap_checked (xcb_connection_t *c,
xcb_xfixes_region_t region,
xcb_pixmap_t bitmap);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xfixes_create_region_from_bitmap (xcb_connection_t *c,
xcb_xfixes_region_t region,
xcb_pixmap_t bitmap);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xfixes_create_region_from_window_checked (xcb_connection_t *c,
xcb_xfixes_region_t region,
xcb_window_t window,
xcb_shape_kind_t kind);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xfixes_create_region_from_window (xcb_connection_t *c,
xcb_xfixes_region_t region,
xcb_window_t window,
xcb_shape_kind_t kind);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xfixes_create_region_from_gc_checked (xcb_connection_t *c,
xcb_xfixes_region_t region,
xcb_gcontext_t gc);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xfixes_create_region_from_gc (xcb_connection_t *c,
xcb_xfixes_region_t region,
xcb_gcontext_t gc);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xfixes_create_region_from_picture_checked (xcb_connection_t *c,
xcb_xfixes_region_t region,
xcb_render_picture_t picture);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xfixes_create_region_from_picture (xcb_connection_t *c,
xcb_xfixes_region_t region,
xcb_render_picture_t picture);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xfixes_destroy_region_checked (xcb_connection_t *c,
xcb_xfixes_region_t region);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xfixes_destroy_region (xcb_connection_t *c,
xcb_xfixes_region_t region);
int
xcb_xfixes_set_region_sizeof (const void *_buffer,
uint32_t rectangles_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xfixes_set_region_checked (xcb_connection_t *c,
xcb_xfixes_region_t region,
uint32_t rectangles_len,
const xcb_rectangle_t *rectangles);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xfixes_set_region (xcb_connection_t *c,
xcb_xfixes_region_t region,
uint32_t rectangles_len,
const xcb_rectangle_t *rectangles);
xcb_rectangle_t *
xcb_xfixes_set_region_rectangles (const xcb_xfixes_set_region_request_t *R);
int
xcb_xfixes_set_region_rectangles_length (const xcb_xfixes_set_region_request_t *R);
xcb_rectangle_iterator_t
xcb_xfixes_set_region_rectangles_iterator (const xcb_xfixes_set_region_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xfixes_copy_region_checked (xcb_connection_t *c,
xcb_xfixes_region_t source,
xcb_xfixes_region_t destination);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xfixes_copy_region (xcb_connection_t *c,
xcb_xfixes_region_t source,
xcb_xfixes_region_t destination);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xfixes_union_region_checked (xcb_connection_t *c,
xcb_xfixes_region_t source1,
xcb_xfixes_region_t source2,
xcb_xfixes_region_t destination);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xfixes_union_region (xcb_connection_t *c,
xcb_xfixes_region_t source1,
xcb_xfixes_region_t source2,
xcb_xfixes_region_t destination);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xfixes_intersect_region_checked (xcb_connection_t *c,
xcb_xfixes_region_t source1,
xcb_xfixes_region_t source2,
xcb_xfixes_region_t destination);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xfixes_intersect_region (xcb_connection_t *c,
xcb_xfixes_region_t source1,
xcb_xfixes_region_t source2,
xcb_xfixes_region_t destination);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xfixes_subtract_region_checked (xcb_connection_t *c,
xcb_xfixes_region_t source1,
xcb_xfixes_region_t source2,
xcb_xfixes_region_t destination);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xfixes_subtract_region (xcb_connection_t *c,
xcb_xfixes_region_t source1,
xcb_xfixes_region_t source2,
xcb_xfixes_region_t destination);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xfixes_invert_region_checked (xcb_connection_t *c,
xcb_xfixes_region_t source,
xcb_rectangle_t bounds,
xcb_xfixes_region_t destination);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xfixes_invert_region (xcb_connection_t *c,
xcb_xfixes_region_t source,
xcb_rectangle_t bounds,
xcb_xfixes_region_t destination);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xfixes_translate_region_checked (xcb_connection_t *c,
xcb_xfixes_region_t region,
int16_t dx,
int16_t dy);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xfixes_translate_region (xcb_connection_t *c,
xcb_xfixes_region_t region,
int16_t dx,
int16_t dy);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xfixes_region_extents_checked (xcb_connection_t *c,
xcb_xfixes_region_t source,
xcb_xfixes_region_t destination);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xfixes_region_extents (xcb_connection_t *c,
xcb_xfixes_region_t source,
xcb_xfixes_region_t destination);
int
xcb_xfixes_fetch_region_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xfixes_fetch_region_cookie_t
xcb_xfixes_fetch_region (xcb_connection_t *c,
xcb_xfixes_region_t region);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xfixes_fetch_region_cookie_t
xcb_xfixes_fetch_region_unchecked (xcb_connection_t *c,
xcb_xfixes_region_t region);
xcb_rectangle_t *
xcb_xfixes_fetch_region_rectangles (const xcb_xfixes_fetch_region_reply_t *R);
int
xcb_xfixes_fetch_region_rectangles_length (const xcb_xfixes_fetch_region_reply_t *R);
xcb_rectangle_iterator_t
xcb_xfixes_fetch_region_rectangles_iterator (const xcb_xfixes_fetch_region_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xfixes_fetch_region_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xfixes_fetch_region_reply_t *
xcb_xfixes_fetch_region_reply (xcb_connection_t *c,
xcb_xfixes_fetch_region_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xfixes_set_gc_clip_region_checked (xcb_connection_t *c,
xcb_gcontext_t gc,
xcb_xfixes_region_t region,
int16_t x_origin,
int16_t y_origin);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xfixes_set_gc_clip_region (xcb_connection_t *c,
xcb_gcontext_t gc,
xcb_xfixes_region_t region,
int16_t x_origin,
int16_t y_origin);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xfixes_set_window_shape_region_checked (xcb_connection_t *c,
xcb_window_t dest,
xcb_shape_kind_t dest_kind,
int16_t x_offset,
int16_t y_offset,
xcb_xfixes_region_t region);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xfixes_set_window_shape_region (xcb_connection_t *c,
xcb_window_t dest,
xcb_shape_kind_t dest_kind,
int16_t x_offset,
int16_t y_offset,
xcb_xfixes_region_t region);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xfixes_set_picture_clip_region_checked (xcb_connection_t *c,
xcb_render_picture_t picture,
xcb_xfixes_region_t region,
int16_t x_origin,
int16_t y_origin);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xfixes_set_picture_clip_region (xcb_connection_t *c,
xcb_render_picture_t picture,
xcb_xfixes_region_t region,
int16_t x_origin,
int16_t y_origin);
int
xcb_xfixes_set_cursor_name_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xfixes_set_cursor_name_checked (xcb_connection_t *c,
xcb_cursor_t cursor,
uint16_t nbytes,
const char *name);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xfixes_set_cursor_name (xcb_connection_t *c,
xcb_cursor_t cursor,
uint16_t nbytes,
const char *name);
char *
xcb_xfixes_set_cursor_name_name (const xcb_xfixes_set_cursor_name_request_t *R);
int
xcb_xfixes_set_cursor_name_name_length (const xcb_xfixes_set_cursor_name_request_t *R);
xcb_generic_iterator_t
xcb_xfixes_set_cursor_name_name_end (const xcb_xfixes_set_cursor_name_request_t *R);
int
xcb_xfixes_get_cursor_name_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xfixes_get_cursor_name_cookie_t
xcb_xfixes_get_cursor_name (xcb_connection_t *c,
xcb_cursor_t cursor);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xfixes_get_cursor_name_cookie_t
xcb_xfixes_get_cursor_name_unchecked (xcb_connection_t *c,
xcb_cursor_t cursor);
char *
xcb_xfixes_get_cursor_name_name (const xcb_xfixes_get_cursor_name_reply_t *R);
int
xcb_xfixes_get_cursor_name_name_length (const xcb_xfixes_get_cursor_name_reply_t *R);
xcb_generic_iterator_t
xcb_xfixes_get_cursor_name_name_end (const xcb_xfixes_get_cursor_name_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xfixes_get_cursor_name_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xfixes_get_cursor_name_reply_t *
xcb_xfixes_get_cursor_name_reply (xcb_connection_t *c,
xcb_xfixes_get_cursor_name_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_xfixes_get_cursor_image_and_name_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xfixes_get_cursor_image_and_name_cookie_t
xcb_xfixes_get_cursor_image_and_name (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xfixes_get_cursor_image_and_name_cookie_t
xcb_xfixes_get_cursor_image_and_name_unchecked (xcb_connection_t *c);
uint32_t *
xcb_xfixes_get_cursor_image_and_name_cursor_image (const xcb_xfixes_get_cursor_image_and_name_reply_t *R);
int
xcb_xfixes_get_cursor_image_and_name_cursor_image_length (const xcb_xfixes_get_cursor_image_and_name_reply_t *R);
xcb_generic_iterator_t
xcb_xfixes_get_cursor_image_and_name_cursor_image_end (const xcb_xfixes_get_cursor_image_and_name_reply_t *R);
char *
xcb_xfixes_get_cursor_image_and_name_name (const xcb_xfixes_get_cursor_image_and_name_reply_t *R);
int
xcb_xfixes_get_cursor_image_and_name_name_length (const xcb_xfixes_get_cursor_image_and_name_reply_t *R);
xcb_generic_iterator_t
xcb_xfixes_get_cursor_image_and_name_name_end (const xcb_xfixes_get_cursor_image_and_name_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xfixes_get_cursor_image_and_name_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xfixes_get_cursor_image_and_name_reply_t *
xcb_xfixes_get_cursor_image_and_name_reply (xcb_connection_t *c,
xcb_xfixes_get_cursor_image_and_name_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xfixes_change_cursor_checked (xcb_connection_t *c,
xcb_cursor_t source,
xcb_cursor_t destination);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xfixes_change_cursor (xcb_connection_t *c,
xcb_cursor_t source,
xcb_cursor_t destination);
int
xcb_xfixes_change_cursor_by_name_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xfixes_change_cursor_by_name_checked (xcb_connection_t *c,
xcb_cursor_t src,
uint16_t nbytes,
const char *name);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xfixes_change_cursor_by_name (xcb_connection_t *c,
xcb_cursor_t src,
uint16_t nbytes,
const char *name);
char *
xcb_xfixes_change_cursor_by_name_name (const xcb_xfixes_change_cursor_by_name_request_t *R);
int
xcb_xfixes_change_cursor_by_name_name_length (const xcb_xfixes_change_cursor_by_name_request_t *R);
xcb_generic_iterator_t
xcb_xfixes_change_cursor_by_name_name_end (const xcb_xfixes_change_cursor_by_name_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xfixes_expand_region_checked (xcb_connection_t *c,
xcb_xfixes_region_t source,
xcb_xfixes_region_t destination,
uint16_t left,
uint16_t right,
uint16_t top,
uint16_t bottom);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xfixes_expand_region (xcb_connection_t *c,
xcb_xfixes_region_t source,
xcb_xfixes_region_t destination,
uint16_t left,
uint16_t right,
uint16_t top,
uint16_t bottom);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xfixes_hide_cursor_checked (xcb_connection_t *c,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xfixes_hide_cursor (xcb_connection_t *c,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xfixes_show_cursor_checked (xcb_connection_t *c,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xfixes_show_cursor (xcb_connection_t *c,
xcb_window_t window);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xfixes_barrier_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xfixes_barrier_t)
*/
void
xcb_xfixes_barrier_next (xcb_xfixes_barrier_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xfixes_barrier_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xfixes_barrier_end (xcb_xfixes_barrier_iterator_t i);
int
xcb_xfixes_create_pointer_barrier_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xfixes_create_pointer_barrier_checked (xcb_connection_t *c,
xcb_xfixes_barrier_t barrier,
xcb_window_t window,
uint16_t x1,
uint16_t y1,
uint16_t x2,
uint16_t y2,
uint32_t directions,
uint16_t num_devices,
const uint16_t *devices);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xfixes_create_pointer_barrier (xcb_connection_t *c,
xcb_xfixes_barrier_t barrier,
xcb_window_t window,
uint16_t x1,
uint16_t y1,
uint16_t x2,
uint16_t y2,
uint32_t directions,
uint16_t num_devices,
const uint16_t *devices);
uint16_t *
xcb_xfixes_create_pointer_barrier_devices (const xcb_xfixes_create_pointer_barrier_request_t *R);
int
xcb_xfixes_create_pointer_barrier_devices_length (const xcb_xfixes_create_pointer_barrier_request_t *R);
xcb_generic_iterator_t
xcb_xfixes_create_pointer_barrier_devices_end (const xcb_xfixes_create_pointer_barrier_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_xfixes_delete_pointer_barrier_checked (xcb_connection_t *c,
xcb_xfixes_barrier_t barrier);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_xfixes_delete_pointer_barrier (xcb_connection_t *c,
xcb_xfixes_barrier_t barrier);
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/
xcb/ge.h 0000644 00000005645 15201526705 0006101 0 ustar 00 /*
* This file generated automatically from ge.xml by c_client.py.
* Edit at your peril.
*/
/**
* @defgroup XCB_GenericEvent_API XCB GenericEvent API
* @brief GenericEvent XCB Protocol Implementation.
* @{
**/
#ifndef __GE_H
#define __GE_H
#include "xcb.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XCB_GENERICEVENT_MAJOR_VERSION 1
#define XCB_GENERICEVENT_MINOR_VERSION 0
extern xcb_extension_t xcb_genericevent_id;
/**
* @brief xcb_genericevent_query_version_cookie_t
**/
typedef struct xcb_genericevent_query_version_cookie_t {
unsigned int sequence;
} xcb_genericevent_query_version_cookie_t;
/** Opcode for xcb_genericevent_query_version. */
#define XCB_GENERICEVENT_QUERY_VERSION 0
/**
* @brief xcb_genericevent_query_version_request_t
**/
typedef struct xcb_genericevent_query_version_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint16_t client_major_version;
uint16_t client_minor_version;
} xcb_genericevent_query_version_request_t;
/**
* @brief xcb_genericevent_query_version_reply_t
**/
typedef struct xcb_genericevent_query_version_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t major_version;
uint16_t minor_version;
uint8_t pad1[20];
} xcb_genericevent_query_version_reply_t;
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_genericevent_query_version_cookie_t
xcb_genericevent_query_version (xcb_connection_t *c,
uint16_t client_major_version,
uint16_t client_minor_version);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_genericevent_query_version_cookie_t
xcb_genericevent_query_version_unchecked (xcb_connection_t *c,
uint16_t client_major_version,
uint16_t client_minor_version);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_genericevent_query_version_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_genericevent_query_version_reply_t *
xcb_genericevent_query_version_reply (xcb_connection_t *c,
xcb_genericevent_query_version_cookie_t cookie /**< */,
xcb_generic_error_t **e);
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/
xcb/screensaver.h 0000644 00000040142 15201526705 0010015 0 ustar 00 /*
* This file generated automatically from screensaver.xml by c_client.py.
* Edit at your peril.
*/
/**
* @defgroup XCB_ScreenSaver_API XCB ScreenSaver API
* @brief ScreenSaver XCB Protocol Implementation.
* @{
**/
#ifndef __SCREENSAVER_H
#define __SCREENSAVER_H
#include "xcb.h"
#include "xproto.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XCB_SCREENSAVER_MAJOR_VERSION 1
#define XCB_SCREENSAVER_MINOR_VERSION 1
extern xcb_extension_t xcb_screensaver_id;
typedef enum xcb_screensaver_kind_t {
XCB_SCREENSAVER_KIND_BLANKED = 0,
XCB_SCREENSAVER_KIND_INTERNAL = 1,
XCB_SCREENSAVER_KIND_EXTERNAL = 2
} xcb_screensaver_kind_t;
typedef enum xcb_screensaver_event_t {
XCB_SCREENSAVER_EVENT_NOTIFY_MASK = 1,
XCB_SCREENSAVER_EVENT_CYCLE_MASK = 2
} xcb_screensaver_event_t;
typedef enum xcb_screensaver_state_t {
XCB_SCREENSAVER_STATE_OFF = 0,
XCB_SCREENSAVER_STATE_ON = 1,
XCB_SCREENSAVER_STATE_CYCLE = 2,
XCB_SCREENSAVER_STATE_DISABLED = 3
} xcb_screensaver_state_t;
/**
* @brief xcb_screensaver_query_version_cookie_t
**/
typedef struct xcb_screensaver_query_version_cookie_t {
unsigned int sequence;
} xcb_screensaver_query_version_cookie_t;
/** Opcode for xcb_screensaver_query_version. */
#define XCB_SCREENSAVER_QUERY_VERSION 0
/**
* @brief xcb_screensaver_query_version_request_t
**/
typedef struct xcb_screensaver_query_version_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t client_major_version;
uint8_t client_minor_version;
uint8_t pad0[2];
} xcb_screensaver_query_version_request_t;
/**
* @brief xcb_screensaver_query_version_reply_t
**/
typedef struct xcb_screensaver_query_version_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t server_major_version;
uint16_t server_minor_version;
uint8_t pad1[20];
} xcb_screensaver_query_version_reply_t;
/**
* @brief xcb_screensaver_query_info_cookie_t
**/
typedef struct xcb_screensaver_query_info_cookie_t {
unsigned int sequence;
} xcb_screensaver_query_info_cookie_t;
/** Opcode for xcb_screensaver_query_info. */
#define XCB_SCREENSAVER_QUERY_INFO 1
/**
* @brief xcb_screensaver_query_info_request_t
**/
typedef struct xcb_screensaver_query_info_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_drawable_t drawable;
} xcb_screensaver_query_info_request_t;
/**
* @brief xcb_screensaver_query_info_reply_t
**/
typedef struct xcb_screensaver_query_info_reply_t {
uint8_t response_type;
uint8_t state;
uint16_t sequence;
uint32_t length;
xcb_window_t saver_window;
uint32_t ms_until_server;
uint32_t ms_since_user_input;
uint32_t event_mask;
uint8_t kind;
uint8_t pad0[7];
} xcb_screensaver_query_info_reply_t;
/** Opcode for xcb_screensaver_select_input. */
#define XCB_SCREENSAVER_SELECT_INPUT 2
/**
* @brief xcb_screensaver_select_input_request_t
**/
typedef struct xcb_screensaver_select_input_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_drawable_t drawable;
uint32_t event_mask;
} xcb_screensaver_select_input_request_t;
/**
* @brief xcb_screensaver_set_attributes_value_list_t
**/
typedef struct xcb_screensaver_set_attributes_value_list_t {
xcb_pixmap_t background_pixmap;
uint32_t background_pixel;
xcb_pixmap_t border_pixmap;
uint32_t border_pixel;
uint32_t bit_gravity;
uint32_t win_gravity;
uint32_t backing_store;
uint32_t backing_planes;
uint32_t backing_pixel;
xcb_bool32_t override_redirect;
xcb_bool32_t save_under;
uint32_t event_mask;
uint32_t do_not_propogate_mask;
xcb_colormap_t colormap;
xcb_cursor_t cursor;
} xcb_screensaver_set_attributes_value_list_t;
/** Opcode for xcb_screensaver_set_attributes. */
#define XCB_SCREENSAVER_SET_ATTRIBUTES 3
/**
* @brief xcb_screensaver_set_attributes_request_t
**/
typedef struct xcb_screensaver_set_attributes_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_drawable_t drawable;
int16_t x;
int16_t y;
uint16_t width;
uint16_t height;
uint16_t border_width;
uint8_t _class;
uint8_t depth;
xcb_visualid_t visual;
uint32_t value_mask;
} xcb_screensaver_set_attributes_request_t;
/** Opcode for xcb_screensaver_unset_attributes. */
#define XCB_SCREENSAVER_UNSET_ATTRIBUTES 4
/**
* @brief xcb_screensaver_unset_attributes_request_t
**/
typedef struct xcb_screensaver_unset_attributes_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_drawable_t drawable;
} xcb_screensaver_unset_attributes_request_t;
/** Opcode for xcb_screensaver_suspend. */
#define XCB_SCREENSAVER_SUSPEND 5
/**
* @brief xcb_screensaver_suspend_request_t
**/
typedef struct xcb_screensaver_suspend_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t suspend;
uint8_t pad0[3];
} xcb_screensaver_suspend_request_t;
/** Opcode for xcb_screensaver_notify. */
#define XCB_SCREENSAVER_NOTIFY 0
/**
* @brief xcb_screensaver_notify_event_t
**/
typedef struct xcb_screensaver_notify_event_t {
uint8_t response_type;
uint8_t state;
uint16_t sequence;
xcb_timestamp_t time;
xcb_window_t root;
xcb_window_t window;
uint8_t kind;
uint8_t forced;
uint8_t pad0[14];
} xcb_screensaver_notify_event_t;
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_screensaver_query_version_cookie_t
xcb_screensaver_query_version (xcb_connection_t *c,
uint8_t client_major_version,
uint8_t client_minor_version);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_screensaver_query_version_cookie_t
xcb_screensaver_query_version_unchecked (xcb_connection_t *c,
uint8_t client_major_version,
uint8_t client_minor_version);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_screensaver_query_version_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_screensaver_query_version_reply_t *
xcb_screensaver_query_version_reply (xcb_connection_t *c,
xcb_screensaver_query_version_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_screensaver_query_info_cookie_t
xcb_screensaver_query_info (xcb_connection_t *c,
xcb_drawable_t drawable);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_screensaver_query_info_cookie_t
xcb_screensaver_query_info_unchecked (xcb_connection_t *c,
xcb_drawable_t drawable);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_screensaver_query_info_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_screensaver_query_info_reply_t *
xcb_screensaver_query_info_reply (xcb_connection_t *c,
xcb_screensaver_query_info_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_screensaver_select_input_checked (xcb_connection_t *c,
xcb_drawable_t drawable,
uint32_t event_mask);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_screensaver_select_input (xcb_connection_t *c,
xcb_drawable_t drawable,
uint32_t event_mask);
int
xcb_screensaver_set_attributes_value_list_serialize (void **_buffer,
uint32_t value_mask,
const xcb_screensaver_set_attributes_value_list_t *_aux);
int
xcb_screensaver_set_attributes_value_list_unpack (const void *_buffer,
uint32_t value_mask,
xcb_screensaver_set_attributes_value_list_t *_aux);
int
xcb_screensaver_set_attributes_value_list_sizeof (const void *_buffer,
uint32_t value_mask);
int
xcb_screensaver_set_attributes_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_screensaver_set_attributes_checked (xcb_connection_t *c,
xcb_drawable_t drawable,
int16_t x,
int16_t y,
uint16_t width,
uint16_t height,
uint16_t border_width,
uint8_t _class,
uint8_t depth,
xcb_visualid_t visual,
uint32_t value_mask,
const void *value_list);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_screensaver_set_attributes (xcb_connection_t *c,
xcb_drawable_t drawable,
int16_t x,
int16_t y,
uint16_t width,
uint16_t height,
uint16_t border_width,
uint8_t _class,
uint8_t depth,
xcb_visualid_t visual,
uint32_t value_mask,
const void *value_list);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_screensaver_set_attributes_aux_checked (xcb_connection_t *c,
xcb_drawable_t drawable,
int16_t x,
int16_t y,
uint16_t width,
uint16_t height,
uint16_t border_width,
uint8_t _class,
uint8_t depth,
xcb_visualid_t visual,
uint32_t value_mask,
const xcb_screensaver_set_attributes_value_list_t *value_list);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_screensaver_set_attributes_aux (xcb_connection_t *c,
xcb_drawable_t drawable,
int16_t x,
int16_t y,
uint16_t width,
uint16_t height,
uint16_t border_width,
uint8_t _class,
uint8_t depth,
xcb_visualid_t visual,
uint32_t value_mask,
const xcb_screensaver_set_attributes_value_list_t *value_list);
void *
xcb_screensaver_set_attributes_value_list (const xcb_screensaver_set_attributes_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_screensaver_unset_attributes_checked (xcb_connection_t *c,
xcb_drawable_t drawable);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_screensaver_unset_attributes (xcb_connection_t *c,
xcb_drawable_t drawable);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_screensaver_suspend_checked (xcb_connection_t *c,
uint8_t suspend);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_screensaver_suspend (xcb_connection_t *c,
uint8_t suspend);
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/
xcb/xinerama.h 0000644 00000035153 15201526705 0007307 0 ustar 00 /*
* This file generated automatically from xinerama.xml by c_client.py.
* Edit at your peril.
*/
/**
* @defgroup XCB_Xinerama_API XCB Xinerama API
* @brief Xinerama XCB Protocol Implementation.
* @{
**/
#ifndef __XINERAMA_H
#define __XINERAMA_H
#include "xcb.h"
#include "xproto.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XCB_XINERAMA_MAJOR_VERSION 1
#define XCB_XINERAMA_MINOR_VERSION 1
extern xcb_extension_t xcb_xinerama_id;
/**
* @brief xcb_xinerama_screen_info_t
**/
typedef struct xcb_xinerama_screen_info_t {
int16_t x_org;
int16_t y_org;
uint16_t width;
uint16_t height;
} xcb_xinerama_screen_info_t;
/**
* @brief xcb_xinerama_screen_info_iterator_t
**/
typedef struct xcb_xinerama_screen_info_iterator_t {
xcb_xinerama_screen_info_t *data;
int rem;
int index;
} xcb_xinerama_screen_info_iterator_t;
/**
* @brief xcb_xinerama_query_version_cookie_t
**/
typedef struct xcb_xinerama_query_version_cookie_t {
unsigned int sequence;
} xcb_xinerama_query_version_cookie_t;
/** Opcode for xcb_xinerama_query_version. */
#define XCB_XINERAMA_QUERY_VERSION 0
/**
* @brief xcb_xinerama_query_version_request_t
**/
typedef struct xcb_xinerama_query_version_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint8_t major;
uint8_t minor;
} xcb_xinerama_query_version_request_t;
/**
* @brief xcb_xinerama_query_version_reply_t
**/
typedef struct xcb_xinerama_query_version_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t major;
uint16_t minor;
} xcb_xinerama_query_version_reply_t;
/**
* @brief xcb_xinerama_get_state_cookie_t
**/
typedef struct xcb_xinerama_get_state_cookie_t {
unsigned int sequence;
} xcb_xinerama_get_state_cookie_t;
/** Opcode for xcb_xinerama_get_state. */
#define XCB_XINERAMA_GET_STATE 1
/**
* @brief xcb_xinerama_get_state_request_t
**/
typedef struct xcb_xinerama_get_state_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
} xcb_xinerama_get_state_request_t;
/**
* @brief xcb_xinerama_get_state_reply_t
**/
typedef struct xcb_xinerama_get_state_reply_t {
uint8_t response_type;
uint8_t state;
uint16_t sequence;
uint32_t length;
xcb_window_t window;
} xcb_xinerama_get_state_reply_t;
/**
* @brief xcb_xinerama_get_screen_count_cookie_t
**/
typedef struct xcb_xinerama_get_screen_count_cookie_t {
unsigned int sequence;
} xcb_xinerama_get_screen_count_cookie_t;
/** Opcode for xcb_xinerama_get_screen_count. */
#define XCB_XINERAMA_GET_SCREEN_COUNT 2
/**
* @brief xcb_xinerama_get_screen_count_request_t
**/
typedef struct xcb_xinerama_get_screen_count_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
} xcb_xinerama_get_screen_count_request_t;
/**
* @brief xcb_xinerama_get_screen_count_reply_t
**/
typedef struct xcb_xinerama_get_screen_count_reply_t {
uint8_t response_type;
uint8_t screen_count;
uint16_t sequence;
uint32_t length;
xcb_window_t window;
} xcb_xinerama_get_screen_count_reply_t;
/**
* @brief xcb_xinerama_get_screen_size_cookie_t
**/
typedef struct xcb_xinerama_get_screen_size_cookie_t {
unsigned int sequence;
} xcb_xinerama_get_screen_size_cookie_t;
/** Opcode for xcb_xinerama_get_screen_size. */
#define XCB_XINERAMA_GET_SCREEN_SIZE 3
/**
* @brief xcb_xinerama_get_screen_size_request_t
**/
typedef struct xcb_xinerama_get_screen_size_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
uint32_t screen;
} xcb_xinerama_get_screen_size_request_t;
/**
* @brief xcb_xinerama_get_screen_size_reply_t
**/
typedef struct xcb_xinerama_get_screen_size_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t width;
uint32_t height;
xcb_window_t window;
uint32_t screen;
} xcb_xinerama_get_screen_size_reply_t;
/**
* @brief xcb_xinerama_is_active_cookie_t
**/
typedef struct xcb_xinerama_is_active_cookie_t {
unsigned int sequence;
} xcb_xinerama_is_active_cookie_t;
/** Opcode for xcb_xinerama_is_active. */
#define XCB_XINERAMA_IS_ACTIVE 4
/**
* @brief xcb_xinerama_is_active_request_t
**/
typedef struct xcb_xinerama_is_active_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_xinerama_is_active_request_t;
/**
* @brief xcb_xinerama_is_active_reply_t
**/
typedef struct xcb_xinerama_is_active_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t state;
} xcb_xinerama_is_active_reply_t;
/**
* @brief xcb_xinerama_query_screens_cookie_t
**/
typedef struct xcb_xinerama_query_screens_cookie_t {
unsigned int sequence;
} xcb_xinerama_query_screens_cookie_t;
/** Opcode for xcb_xinerama_query_screens. */
#define XCB_XINERAMA_QUERY_SCREENS 5
/**
* @brief xcb_xinerama_query_screens_request_t
**/
typedef struct xcb_xinerama_query_screens_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_xinerama_query_screens_request_t;
/**
* @brief xcb_xinerama_query_screens_reply_t
**/
typedef struct xcb_xinerama_query_screens_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint32_t number;
uint8_t pad1[20];
} xcb_xinerama_query_screens_reply_t;
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xinerama_screen_info_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xinerama_screen_info_t)
*/
void
xcb_xinerama_screen_info_next (xcb_xinerama_screen_info_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xinerama_screen_info_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xinerama_screen_info_end (xcb_xinerama_screen_info_iterator_t i);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xinerama_query_version_cookie_t
xcb_xinerama_query_version (xcb_connection_t *c,
uint8_t major,
uint8_t minor);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xinerama_query_version_cookie_t
xcb_xinerama_query_version_unchecked (xcb_connection_t *c,
uint8_t major,
uint8_t minor);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xinerama_query_version_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xinerama_query_version_reply_t *
xcb_xinerama_query_version_reply (xcb_connection_t *c,
xcb_xinerama_query_version_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xinerama_get_state_cookie_t
xcb_xinerama_get_state (xcb_connection_t *c,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xinerama_get_state_cookie_t
xcb_xinerama_get_state_unchecked (xcb_connection_t *c,
xcb_window_t window);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xinerama_get_state_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xinerama_get_state_reply_t *
xcb_xinerama_get_state_reply (xcb_connection_t *c,
xcb_xinerama_get_state_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xinerama_get_screen_count_cookie_t
xcb_xinerama_get_screen_count (xcb_connection_t *c,
xcb_window_t window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xinerama_get_screen_count_cookie_t
xcb_xinerama_get_screen_count_unchecked (xcb_connection_t *c,
xcb_window_t window);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xinerama_get_screen_count_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xinerama_get_screen_count_reply_t *
xcb_xinerama_get_screen_count_reply (xcb_connection_t *c,
xcb_xinerama_get_screen_count_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xinerama_get_screen_size_cookie_t
xcb_xinerama_get_screen_size (xcb_connection_t *c,
xcb_window_t window,
uint32_t screen);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xinerama_get_screen_size_cookie_t
xcb_xinerama_get_screen_size_unchecked (xcb_connection_t *c,
xcb_window_t window,
uint32_t screen);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xinerama_get_screen_size_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xinerama_get_screen_size_reply_t *
xcb_xinerama_get_screen_size_reply (xcb_connection_t *c,
xcb_xinerama_get_screen_size_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xinerama_is_active_cookie_t
xcb_xinerama_is_active (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xinerama_is_active_cookie_t
xcb_xinerama_is_active_unchecked (xcb_connection_t *c);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xinerama_is_active_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xinerama_is_active_reply_t *
xcb_xinerama_is_active_reply (xcb_connection_t *c,
xcb_xinerama_is_active_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_xinerama_query_screens_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xinerama_query_screens_cookie_t
xcb_xinerama_query_screens (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xinerama_query_screens_cookie_t
xcb_xinerama_query_screens_unchecked (xcb_connection_t *c);
xcb_xinerama_screen_info_t *
xcb_xinerama_query_screens_screen_info (const xcb_xinerama_query_screens_reply_t *R);
int
xcb_xinerama_query_screens_screen_info_length (const xcb_xinerama_query_screens_reply_t *R);
xcb_xinerama_screen_info_iterator_t
xcb_xinerama_query_screens_screen_info_iterator (const xcb_xinerama_query_screens_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xinerama_query_screens_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xinerama_query_screens_reply_t *
xcb_xinerama_query_screens_reply (xcb_connection_t *c,
xcb_xinerama_query_screens_cookie_t cookie /**< */,
xcb_generic_error_t **e);
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/
xcb/xevie.h 0000644 00000026511 15201526705 0006621 0 ustar 00 /*
* This file generated automatically from xevie.xml by c_client.py.
* Edit at your peril.
*/
/**
* @defgroup XCB_Xevie_API XCB Xevie API
* @brief Xevie XCB Protocol Implementation.
* @{
**/
#ifndef __XEVIE_H
#define __XEVIE_H
#include "xcb.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XCB_XEVIE_MAJOR_VERSION 1
#define XCB_XEVIE_MINOR_VERSION 0
extern xcb_extension_t xcb_xevie_id;
/**
* @brief xcb_xevie_query_version_cookie_t
**/
typedef struct xcb_xevie_query_version_cookie_t {
unsigned int sequence;
} xcb_xevie_query_version_cookie_t;
/** Opcode for xcb_xevie_query_version. */
#define XCB_XEVIE_QUERY_VERSION 0
/**
* @brief xcb_xevie_query_version_request_t
**/
typedef struct xcb_xevie_query_version_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint16_t client_major_version;
uint16_t client_minor_version;
} xcb_xevie_query_version_request_t;
/**
* @brief xcb_xevie_query_version_reply_t
**/
typedef struct xcb_xevie_query_version_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t server_major_version;
uint16_t server_minor_version;
uint8_t pad1[20];
} xcb_xevie_query_version_reply_t;
/**
* @brief xcb_xevie_start_cookie_t
**/
typedef struct xcb_xevie_start_cookie_t {
unsigned int sequence;
} xcb_xevie_start_cookie_t;
/** Opcode for xcb_xevie_start. */
#define XCB_XEVIE_START 1
/**
* @brief xcb_xevie_start_request_t
**/
typedef struct xcb_xevie_start_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t screen;
} xcb_xevie_start_request_t;
/**
* @brief xcb_xevie_start_reply_t
**/
typedef struct xcb_xevie_start_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[24];
} xcb_xevie_start_reply_t;
/**
* @brief xcb_xevie_end_cookie_t
**/
typedef struct xcb_xevie_end_cookie_t {
unsigned int sequence;
} xcb_xevie_end_cookie_t;
/** Opcode for xcb_xevie_end. */
#define XCB_XEVIE_END 2
/**
* @brief xcb_xevie_end_request_t
**/
typedef struct xcb_xevie_end_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t cmap;
} xcb_xevie_end_request_t;
/**
* @brief xcb_xevie_end_reply_t
**/
typedef struct xcb_xevie_end_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[24];
} xcb_xevie_end_reply_t;
typedef enum xcb_xevie_datatype_t {
XCB_XEVIE_DATATYPE_UNMODIFIED = 0,
XCB_XEVIE_DATATYPE_MODIFIED = 1
} xcb_xevie_datatype_t;
/**
* @brief xcb_xevie_event_t
**/
typedef struct xcb_xevie_event_t {
uint8_t pad0[32];
} xcb_xevie_event_t;
/**
* @brief xcb_xevie_event_iterator_t
**/
typedef struct xcb_xevie_event_iterator_t {
xcb_xevie_event_t *data;
int rem;
int index;
} xcb_xevie_event_iterator_t;
/**
* @brief xcb_xevie_send_cookie_t
**/
typedef struct xcb_xevie_send_cookie_t {
unsigned int sequence;
} xcb_xevie_send_cookie_t;
/** Opcode for xcb_xevie_send. */
#define XCB_XEVIE_SEND 3
/**
* @brief xcb_xevie_send_request_t
**/
typedef struct xcb_xevie_send_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_xevie_event_t event;
uint32_t data_type;
uint8_t pad0[64];
} xcb_xevie_send_request_t;
/**
* @brief xcb_xevie_send_reply_t
**/
typedef struct xcb_xevie_send_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[24];
} xcb_xevie_send_reply_t;
/**
* @brief xcb_xevie_select_input_cookie_t
**/
typedef struct xcb_xevie_select_input_cookie_t {
unsigned int sequence;
} xcb_xevie_select_input_cookie_t;
/** Opcode for xcb_xevie_select_input. */
#define XCB_XEVIE_SELECT_INPUT 4
/**
* @brief xcb_xevie_select_input_request_t
**/
typedef struct xcb_xevie_select_input_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
uint32_t event_mask;
} xcb_xevie_select_input_request_t;
/**
* @brief xcb_xevie_select_input_reply_t
**/
typedef struct xcb_xevie_select_input_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t pad1[24];
} xcb_xevie_select_input_reply_t;
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xevie_query_version_cookie_t
xcb_xevie_query_version (xcb_connection_t *c,
uint16_t client_major_version,
uint16_t client_minor_version);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xevie_query_version_cookie_t
xcb_xevie_query_version_unchecked (xcb_connection_t *c,
uint16_t client_major_version,
uint16_t client_minor_version);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xevie_query_version_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xevie_query_version_reply_t *
xcb_xevie_query_version_reply (xcb_connection_t *c,
xcb_xevie_query_version_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xevie_start_cookie_t
xcb_xevie_start (xcb_connection_t *c,
uint32_t screen);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xevie_start_cookie_t
xcb_xevie_start_unchecked (xcb_connection_t *c,
uint32_t screen);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xevie_start_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xevie_start_reply_t *
xcb_xevie_start_reply (xcb_connection_t *c,
xcb_xevie_start_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xevie_end_cookie_t
xcb_xevie_end (xcb_connection_t *c,
uint32_t cmap);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xevie_end_cookie_t
xcb_xevie_end_unchecked (xcb_connection_t *c,
uint32_t cmap);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xevie_end_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xevie_end_reply_t *
xcb_xevie_end_reply (xcb_connection_t *c,
xcb_xevie_end_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_xevie_event_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_xevie_event_t)
*/
void
xcb_xevie_event_next (xcb_xevie_event_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_xevie_event_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_xevie_event_end (xcb_xevie_event_iterator_t i);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xevie_send_cookie_t
xcb_xevie_send (xcb_connection_t *c,
xcb_xevie_event_t event,
uint32_t data_type);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xevie_send_cookie_t
xcb_xevie_send_unchecked (xcb_connection_t *c,
xcb_xevie_event_t event,
uint32_t data_type);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xevie_send_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xevie_send_reply_t *
xcb_xevie_send_reply (xcb_connection_t *c,
xcb_xevie_send_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_xevie_select_input_cookie_t
xcb_xevie_select_input (xcb_connection_t *c,
uint32_t event_mask);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_xevie_select_input_cookie_t
xcb_xevie_select_input_unchecked (xcb_connection_t *c,
uint32_t event_mask);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_xevie_select_input_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_xevie_select_input_reply_t *
xcb_xevie_select_input_reply (xcb_connection_t *c,
xcb_xevie_select_input_cookie_t cookie /**< */,
xcb_generic_error_t **e);
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/
xcb/shape.h 0000644 00000050506 15201526705 0006602 0 ustar 00 /*
* This file generated automatically from shape.xml by c_client.py.
* Edit at your peril.
*/
/**
* @defgroup XCB_Shape_API XCB Shape API
* @brief Shape XCB Protocol Implementation.
* @{
**/
#ifndef __SHAPE_H
#define __SHAPE_H
#include "xcb.h"
#include "xproto.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XCB_SHAPE_MAJOR_VERSION 1
#define XCB_SHAPE_MINOR_VERSION 1
extern xcb_extension_t xcb_shape_id;
typedef uint8_t xcb_shape_op_t;
/**
* @brief xcb_shape_op_iterator_t
**/
typedef struct xcb_shape_op_iterator_t {
xcb_shape_op_t *data;
int rem;
int index;
} xcb_shape_op_iterator_t;
typedef uint8_t xcb_shape_kind_t;
/**
* @brief xcb_shape_kind_iterator_t
**/
typedef struct xcb_shape_kind_iterator_t {
xcb_shape_kind_t *data;
int rem;
int index;
} xcb_shape_kind_iterator_t;
typedef enum xcb_shape_so_t {
XCB_SHAPE_SO_SET = 0,
XCB_SHAPE_SO_UNION = 1,
XCB_SHAPE_SO_INTERSECT = 2,
XCB_SHAPE_SO_SUBTRACT = 3,
XCB_SHAPE_SO_INVERT = 4
} xcb_shape_so_t;
typedef enum xcb_shape_sk_t {
XCB_SHAPE_SK_BOUNDING = 0,
XCB_SHAPE_SK_CLIP = 1,
XCB_SHAPE_SK_INPUT = 2
} xcb_shape_sk_t;
/** Opcode for xcb_shape_notify. */
#define XCB_SHAPE_NOTIFY 0
/**
* @brief xcb_shape_notify_event_t
**/
typedef struct xcb_shape_notify_event_t {
uint8_t response_type;
xcb_shape_kind_t shape_kind;
uint16_t sequence;
xcb_window_t affected_window;
int16_t extents_x;
int16_t extents_y;
uint16_t extents_width;
uint16_t extents_height;
xcb_timestamp_t server_time;
uint8_t shaped;
uint8_t pad0[11];
} xcb_shape_notify_event_t;
/**
* @brief xcb_shape_query_version_cookie_t
**/
typedef struct xcb_shape_query_version_cookie_t {
unsigned int sequence;
} xcb_shape_query_version_cookie_t;
/** Opcode for xcb_shape_query_version. */
#define XCB_SHAPE_QUERY_VERSION 0
/**
* @brief xcb_shape_query_version_request_t
**/
typedef struct xcb_shape_query_version_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
} xcb_shape_query_version_request_t;
/**
* @brief xcb_shape_query_version_reply_t
**/
typedef struct xcb_shape_query_version_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t major_version;
uint16_t minor_version;
} xcb_shape_query_version_reply_t;
/** Opcode for xcb_shape_rectangles. */
#define XCB_SHAPE_RECTANGLES 1
/**
* @brief xcb_shape_rectangles_request_t
**/
typedef struct xcb_shape_rectangles_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_shape_op_t operation;
xcb_shape_kind_t destination_kind;
uint8_t ordering;
uint8_t pad0;
xcb_window_t destination_window;
int16_t x_offset;
int16_t y_offset;
} xcb_shape_rectangles_request_t;
/** Opcode for xcb_shape_mask. */
#define XCB_SHAPE_MASK 2
/**
* @brief xcb_shape_mask_request_t
**/
typedef struct xcb_shape_mask_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_shape_op_t operation;
xcb_shape_kind_t destination_kind;
uint8_t pad0[2];
xcb_window_t destination_window;
int16_t x_offset;
int16_t y_offset;
xcb_pixmap_t source_bitmap;
} xcb_shape_mask_request_t;
/** Opcode for xcb_shape_combine. */
#define XCB_SHAPE_COMBINE 3
/**
* @brief xcb_shape_combine_request_t
**/
typedef struct xcb_shape_combine_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_shape_op_t operation;
xcb_shape_kind_t destination_kind;
xcb_shape_kind_t source_kind;
uint8_t pad0;
xcb_window_t destination_window;
int16_t x_offset;
int16_t y_offset;
xcb_window_t source_window;
} xcb_shape_combine_request_t;
/** Opcode for xcb_shape_offset. */
#define XCB_SHAPE_OFFSET 4
/**
* @brief xcb_shape_offset_request_t
**/
typedef struct xcb_shape_offset_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_shape_kind_t destination_kind;
uint8_t pad0[3];
xcb_window_t destination_window;
int16_t x_offset;
int16_t y_offset;
} xcb_shape_offset_request_t;
/**
* @brief xcb_shape_query_extents_cookie_t
**/
typedef struct xcb_shape_query_extents_cookie_t {
unsigned int sequence;
} xcb_shape_query_extents_cookie_t;
/** Opcode for xcb_shape_query_extents. */
#define XCB_SHAPE_QUERY_EXTENTS 5
/**
* @brief xcb_shape_query_extents_request_t
**/
typedef struct xcb_shape_query_extents_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t destination_window;
} xcb_shape_query_extents_request_t;
/**
* @brief xcb_shape_query_extents_reply_t
**/
typedef struct xcb_shape_query_extents_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint8_t bounding_shaped;
uint8_t clip_shaped;
uint8_t pad1[2];
int16_t bounding_shape_extents_x;
int16_t bounding_shape_extents_y;
uint16_t bounding_shape_extents_width;
uint16_t bounding_shape_extents_height;
int16_t clip_shape_extents_x;
int16_t clip_shape_extents_y;
uint16_t clip_shape_extents_width;
uint16_t clip_shape_extents_height;
} xcb_shape_query_extents_reply_t;
/** Opcode for xcb_shape_select_input. */
#define XCB_SHAPE_SELECT_INPUT 6
/**
* @brief xcb_shape_select_input_request_t
**/
typedef struct xcb_shape_select_input_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t destination_window;
uint8_t enable;
uint8_t pad0[3];
} xcb_shape_select_input_request_t;
/**
* @brief xcb_shape_input_selected_cookie_t
**/
typedef struct xcb_shape_input_selected_cookie_t {
unsigned int sequence;
} xcb_shape_input_selected_cookie_t;
/** Opcode for xcb_shape_input_selected. */
#define XCB_SHAPE_INPUT_SELECTED 7
/**
* @brief xcb_shape_input_selected_request_t
**/
typedef struct xcb_shape_input_selected_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t destination_window;
} xcb_shape_input_selected_request_t;
/**
* @brief xcb_shape_input_selected_reply_t
**/
typedef struct xcb_shape_input_selected_reply_t {
uint8_t response_type;
uint8_t enabled;
uint16_t sequence;
uint32_t length;
} xcb_shape_input_selected_reply_t;
/**
* @brief xcb_shape_get_rectangles_cookie_t
**/
typedef struct xcb_shape_get_rectangles_cookie_t {
unsigned int sequence;
} xcb_shape_get_rectangles_cookie_t;
/** Opcode for xcb_shape_get_rectangles. */
#define XCB_SHAPE_GET_RECTANGLES 8
/**
* @brief xcb_shape_get_rectangles_request_t
**/
typedef struct xcb_shape_get_rectangles_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
xcb_shape_kind_t source_kind;
uint8_t pad0[3];
} xcb_shape_get_rectangles_request_t;
/**
* @brief xcb_shape_get_rectangles_reply_t
**/
typedef struct xcb_shape_get_rectangles_reply_t {
uint8_t response_type;
uint8_t ordering;
uint16_t sequence;
uint32_t length;
uint32_t rectangles_len;
uint8_t pad0[20];
} xcb_shape_get_rectangles_reply_t;
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_shape_op_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_shape_op_t)
*/
void
xcb_shape_op_next (xcb_shape_op_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_shape_op_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_shape_op_end (xcb_shape_op_iterator_t i);
/**
* Get the next element of the iterator
* @param i Pointer to a xcb_shape_kind_iterator_t
*
* Get the next element in the iterator. The member rem is
* decreased by one. The member data points to the next
* element. The member index is increased by sizeof(xcb_shape_kind_t)
*/
void
xcb_shape_kind_next (xcb_shape_kind_iterator_t *i);
/**
* Return the iterator pointing to the last element
* @param i An xcb_shape_kind_iterator_t
* @return The iterator pointing to the last element
*
* Set the current element in the iterator to the last element.
* The member rem is set to 0. The member data points to the
* last element.
*/
xcb_generic_iterator_t
xcb_shape_kind_end (xcb_shape_kind_iterator_t i);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_shape_query_version_cookie_t
xcb_shape_query_version (xcb_connection_t *c);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_shape_query_version_cookie_t
xcb_shape_query_version_unchecked (xcb_connection_t *c);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_shape_query_version_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_shape_query_version_reply_t *
xcb_shape_query_version_reply (xcb_connection_t *c,
xcb_shape_query_version_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_shape_rectangles_sizeof (const void *_buffer,
uint32_t rectangles_len);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_shape_rectangles_checked (xcb_connection_t *c,
xcb_shape_op_t operation,
xcb_shape_kind_t destination_kind,
uint8_t ordering,
xcb_window_t destination_window,
int16_t x_offset,
int16_t y_offset,
uint32_t rectangles_len,
const xcb_rectangle_t *rectangles);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_shape_rectangles (xcb_connection_t *c,
xcb_shape_op_t operation,
xcb_shape_kind_t destination_kind,
uint8_t ordering,
xcb_window_t destination_window,
int16_t x_offset,
int16_t y_offset,
uint32_t rectangles_len,
const xcb_rectangle_t *rectangles);
xcb_rectangle_t *
xcb_shape_rectangles_rectangles (const xcb_shape_rectangles_request_t *R);
int
xcb_shape_rectangles_rectangles_length (const xcb_shape_rectangles_request_t *R);
xcb_rectangle_iterator_t
xcb_shape_rectangles_rectangles_iterator (const xcb_shape_rectangles_request_t *R);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_shape_mask_checked (xcb_connection_t *c,
xcb_shape_op_t operation,
xcb_shape_kind_t destination_kind,
xcb_window_t destination_window,
int16_t x_offset,
int16_t y_offset,
xcb_pixmap_t source_bitmap);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_shape_mask (xcb_connection_t *c,
xcb_shape_op_t operation,
xcb_shape_kind_t destination_kind,
xcb_window_t destination_window,
int16_t x_offset,
int16_t y_offset,
xcb_pixmap_t source_bitmap);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_shape_combine_checked (xcb_connection_t *c,
xcb_shape_op_t operation,
xcb_shape_kind_t destination_kind,
xcb_shape_kind_t source_kind,
xcb_window_t destination_window,
int16_t x_offset,
int16_t y_offset,
xcb_window_t source_window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_shape_combine (xcb_connection_t *c,
xcb_shape_op_t operation,
xcb_shape_kind_t destination_kind,
xcb_shape_kind_t source_kind,
xcb_window_t destination_window,
int16_t x_offset,
int16_t y_offset,
xcb_window_t source_window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_shape_offset_checked (xcb_connection_t *c,
xcb_shape_kind_t destination_kind,
xcb_window_t destination_window,
int16_t x_offset,
int16_t y_offset);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_shape_offset (xcb_connection_t *c,
xcb_shape_kind_t destination_kind,
xcb_window_t destination_window,
int16_t x_offset,
int16_t y_offset);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_shape_query_extents_cookie_t
xcb_shape_query_extents (xcb_connection_t *c,
xcb_window_t destination_window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_shape_query_extents_cookie_t
xcb_shape_query_extents_unchecked (xcb_connection_t *c,
xcb_window_t destination_window);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_shape_query_extents_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_shape_query_extents_reply_t *
xcb_shape_query_extents_reply (xcb_connection_t *c,
xcb_shape_query_extents_cookie_t cookie /**< */,
xcb_generic_error_t **e);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will not cause
* a reply to be generated. Any returned error will be
* saved for handling by xcb_request_check().
*/
xcb_void_cookie_t
xcb_shape_select_input_checked (xcb_connection_t *c,
xcb_window_t destination_window,
uint8_t enable);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_void_cookie_t
xcb_shape_select_input (xcb_connection_t *c,
xcb_window_t destination_window,
uint8_t enable);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_shape_input_selected_cookie_t
xcb_shape_input_selected (xcb_connection_t *c,
xcb_window_t destination_window);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_shape_input_selected_cookie_t
xcb_shape_input_selected_unchecked (xcb_connection_t *c,
xcb_window_t destination_window);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_shape_input_selected_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_shape_input_selected_reply_t *
xcb_shape_input_selected_reply (xcb_connection_t *c,
xcb_shape_input_selected_cookie_t cookie /**< */,
xcb_generic_error_t **e);
int
xcb_shape_get_rectangles_sizeof (const void *_buffer);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
xcb_shape_get_rectangles_cookie_t
xcb_shape_get_rectangles (xcb_connection_t *c,
xcb_window_t window,
xcb_shape_kind_t source_kind);
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the request will cause
* a reply to be generated. Any returned error will be
* placed in the event queue.
*/
xcb_shape_get_rectangles_cookie_t
xcb_shape_get_rectangles_unchecked (xcb_connection_t *c,
xcb_window_t window,
xcb_shape_kind_t source_kind);
xcb_rectangle_t *
xcb_shape_get_rectangles_rectangles (const xcb_shape_get_rectangles_reply_t *R);
int
xcb_shape_get_rectangles_rectangles_length (const xcb_shape_get_rectangles_reply_t *R);
xcb_rectangle_iterator_t
xcb_shape_get_rectangles_rectangles_iterator (const xcb_shape_get_rectangles_reply_t *R);
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e The xcb_generic_error_t supplied
*
* Returns the reply of the request asked by
*
* The parameter @p e supplied to this function must be NULL if
* xcb_shape_get_rectangles_unchecked(). is used.
* Otherwise, it stores the error if any.
*
* The returned value must be freed by the caller using free().
*/
xcb_shape_get_rectangles_reply_t *
xcb_shape_get_rectangles_reply (xcb_connection_t *c,
xcb_shape_get_rectangles_cookie_t cookie /**< */,
xcb_generic_error_t **e);
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/
libpng16/pnglibconf.h 0000644 00000016617 15201526705 0010476 0 ustar 00 /* pnglibconf.h - library build configuration */
/* libpng version 1.6.34, September 29, 2017 */
/* Copyright (c) 1998-2017 Glenn Randers-Pehrson */
/* This code is released under the libpng license. */
/* For conditions of distribution and use, see the disclaimer */
/* and license in png.h */
/* pnglibconf.h */
/* Machine generated file: DO NOT EDIT */
/* Derived from: scripts/pnglibconf.dfa */
#ifndef PNGLCONF_H
#define PNGLCONF_H
/* options */
#define PNG_16BIT_SUPPORTED
#define PNG_ALIGNED_MEMORY_SUPPORTED
/*#undef PNG_ARM_NEON_API_SUPPORTED*/
/*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/
#define PNG_BENIGN_ERRORS_SUPPORTED
#define PNG_BENIGN_READ_ERRORS_SUPPORTED
/*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/
#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED
#define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
#define PNG_COLORSPACE_SUPPORTED
#define PNG_CONSOLE_IO_SUPPORTED
#define PNG_CONVERT_tIME_SUPPORTED
#define PNG_EASY_ACCESS_SUPPORTED
/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/
#define PNG_ERROR_TEXT_SUPPORTED
#define PNG_FIXED_POINT_SUPPORTED
#define PNG_FLOATING_ARITHMETIC_SUPPORTED
#define PNG_FLOATING_POINT_SUPPORTED
#define PNG_FORMAT_AFIRST_SUPPORTED
#define PNG_FORMAT_BGR_SUPPORTED
#define PNG_GAMMA_SUPPORTED
#define PNG_GET_PALETTE_MAX_SUPPORTED
#define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
#define PNG_INCH_CONVERSIONS_SUPPORTED
#define PNG_INFO_IMAGE_SUPPORTED
#define PNG_IO_STATE_SUPPORTED
#define PNG_MNG_FEATURES_SUPPORTED
#define PNG_POINTER_INDEXING_SUPPORTED
/*#undef PNG_POWERPC_VSX_API_SUPPORTED*/
/*#undef PNG_POWERPC_VSX_CHECK_SUPPORTED*/
#define PNG_PROGRESSIVE_READ_SUPPORTED
#define PNG_READ_16BIT_SUPPORTED
#define PNG_READ_ALPHA_MODE_SUPPORTED
#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
#define PNG_READ_BACKGROUND_SUPPORTED
#define PNG_READ_BGR_SUPPORTED
#define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
#define PNG_READ_COMPOSITE_NODIV_SUPPORTED
#define PNG_READ_COMPRESSED_TEXT_SUPPORTED
#define PNG_READ_EXPAND_16_SUPPORTED
#define PNG_READ_EXPAND_SUPPORTED
#define PNG_READ_FILLER_SUPPORTED
#define PNG_READ_GAMMA_SUPPORTED
#define PNG_READ_GET_PALETTE_MAX_SUPPORTED
#define PNG_READ_GRAY_TO_RGB_SUPPORTED
#define PNG_READ_INTERLACING_SUPPORTED
#define PNG_READ_INT_FUNCTIONS_SUPPORTED
#define PNG_READ_INVERT_ALPHA_SUPPORTED
#define PNG_READ_INVERT_SUPPORTED
#define PNG_READ_OPT_PLTE_SUPPORTED
#define PNG_READ_PACKSWAP_SUPPORTED
#define PNG_READ_PACK_SUPPORTED
#define PNG_READ_QUANTIZE_SUPPORTED
#define PNG_READ_RGB_TO_GRAY_SUPPORTED
#define PNG_READ_SCALE_16_TO_8_SUPPORTED
#define PNG_READ_SHIFT_SUPPORTED
#define PNG_READ_STRIP_16_TO_8_SUPPORTED
#define PNG_READ_STRIP_ALPHA_SUPPORTED
#define PNG_READ_SUPPORTED
#define PNG_READ_SWAP_ALPHA_SUPPORTED
#define PNG_READ_SWAP_SUPPORTED
#define PNG_READ_TEXT_SUPPORTED
#define PNG_READ_TRANSFORMS_SUPPORTED
#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_READ_USER_CHUNKS_SUPPORTED
#define PNG_READ_USER_TRANSFORM_SUPPORTED
#define PNG_READ_bKGD_SUPPORTED
#define PNG_READ_cHRM_SUPPORTED
#define PNG_READ_eXIf_SUPPORTED
#define PNG_READ_gAMA_SUPPORTED
#define PNG_READ_hIST_SUPPORTED
#define PNG_READ_iCCP_SUPPORTED
#define PNG_READ_iTXt_SUPPORTED
#define PNG_READ_oFFs_SUPPORTED
#define PNG_READ_pCAL_SUPPORTED
#define PNG_READ_pHYs_SUPPORTED
#define PNG_READ_sBIT_SUPPORTED
#define PNG_READ_sCAL_SUPPORTED
#define PNG_READ_sPLT_SUPPORTED
#define PNG_READ_sRGB_SUPPORTED
#define PNG_READ_tEXt_SUPPORTED
#define PNG_READ_tIME_SUPPORTED
#define PNG_READ_tRNS_SUPPORTED
#define PNG_READ_zTXt_SUPPORTED
#define PNG_SAVE_INT_32_SUPPORTED
#define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_SEQUENTIAL_READ_SUPPORTED
#define PNG_SETJMP_SUPPORTED
#define PNG_SET_OPTION_SUPPORTED
#define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_SET_USER_LIMITS_SUPPORTED
#define PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED
#define PNG_SIMPLIFIED_READ_BGR_SUPPORTED
#define PNG_SIMPLIFIED_READ_SUPPORTED
#define PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
#define PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED
#define PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED
#define PNG_SIMPLIFIED_WRITE_SUPPORTED
#define PNG_STDIO_SUPPORTED
#define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_TEXT_SUPPORTED
#define PNG_TIME_RFC1123_SUPPORTED
#define PNG_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_USER_CHUNKS_SUPPORTED
#define PNG_USER_LIMITS_SUPPORTED
#define PNG_USER_MEM_SUPPORTED
#define PNG_USER_TRANSFORM_INFO_SUPPORTED
#define PNG_USER_TRANSFORM_PTR_SUPPORTED
#define PNG_WARNINGS_SUPPORTED
#define PNG_WRITE_16BIT_SUPPORTED
#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
#define PNG_WRITE_BGR_SUPPORTED
#define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
#define PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
#define PNG_WRITE_FILLER_SUPPORTED
#define PNG_WRITE_FILTER_SUPPORTED
#define PNG_WRITE_FLUSH_SUPPORTED
#define PNG_WRITE_GET_PALETTE_MAX_SUPPORTED
#define PNG_WRITE_INTERLACING_SUPPORTED
#define PNG_WRITE_INT_FUNCTIONS_SUPPORTED
#define PNG_WRITE_INVERT_ALPHA_SUPPORTED
#define PNG_WRITE_INVERT_SUPPORTED
#define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
#define PNG_WRITE_PACKSWAP_SUPPORTED
#define PNG_WRITE_PACK_SUPPORTED
#define PNG_WRITE_SHIFT_SUPPORTED
#define PNG_WRITE_SUPPORTED
#define PNG_WRITE_SWAP_ALPHA_SUPPORTED
#define PNG_WRITE_SWAP_SUPPORTED
#define PNG_WRITE_TEXT_SUPPORTED
#define PNG_WRITE_TRANSFORMS_SUPPORTED
#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_WRITE_USER_TRANSFORM_SUPPORTED
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
#define PNG_WRITE_bKGD_SUPPORTED
#define PNG_WRITE_cHRM_SUPPORTED
#define PNG_WRITE_eXIf_SUPPORTED
#define PNG_WRITE_gAMA_SUPPORTED
#define PNG_WRITE_hIST_SUPPORTED
#define PNG_WRITE_iCCP_SUPPORTED
#define PNG_WRITE_iTXt_SUPPORTED
#define PNG_WRITE_oFFs_SUPPORTED
#define PNG_WRITE_pCAL_SUPPORTED
#define PNG_WRITE_pHYs_SUPPORTED
#define PNG_WRITE_sBIT_SUPPORTED
#define PNG_WRITE_sCAL_SUPPORTED
#define PNG_WRITE_sPLT_SUPPORTED
#define PNG_WRITE_sRGB_SUPPORTED
#define PNG_WRITE_tEXt_SUPPORTED
#define PNG_WRITE_tIME_SUPPORTED
#define PNG_WRITE_tRNS_SUPPORTED
#define PNG_WRITE_zTXt_SUPPORTED
#define PNG_bKGD_SUPPORTED
#define PNG_cHRM_SUPPORTED
#define PNG_eXIf_SUPPORTED
#define PNG_gAMA_SUPPORTED
#define PNG_hIST_SUPPORTED
#define PNG_iCCP_SUPPORTED
#define PNG_iTXt_SUPPORTED
#define PNG_oFFs_SUPPORTED
#define PNG_pCAL_SUPPORTED
#define PNG_pHYs_SUPPORTED
#define PNG_sBIT_SUPPORTED
#define PNG_sCAL_SUPPORTED
#define PNG_sPLT_SUPPORTED
#define PNG_sRGB_SUPPORTED
#define PNG_tEXt_SUPPORTED
#define PNG_tIME_SUPPORTED
#define PNG_tRNS_SUPPORTED
#define PNG_zTXt_SUPPORTED
/* end of options */
/* settings */
#define PNG_API_RULE 0
#define PNG_DEFAULT_READ_MACROS 1
#define PNG_GAMMA_THRESHOLD_FIXED 5000
#define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE
#define PNG_INFLATE_BUF_SIZE 1024
#define PNG_LINKAGE_API extern
#define PNG_LINKAGE_CALLBACK extern
#define PNG_LINKAGE_DATA extern
#define PNG_LINKAGE_FUNCTION extern
#define PNG_MAX_GAMMA_8 11
#define PNG_QUANTIZE_BLUE_BITS 5
#define PNG_QUANTIZE_GREEN_BITS 5
#define PNG_QUANTIZE_RED_BITS 5
#define PNG_TEXT_Z_DEFAULT_COMPRESSION (-1)
#define PNG_TEXT_Z_DEFAULT_STRATEGY 0
#define PNG_USER_CHUNK_CACHE_MAX 1000
#define PNG_USER_CHUNK_MALLOC_MAX 1000000000
#define PNG_USER_HEIGHT_MAX 1000000
#define PNG_USER_WIDTH_MAX 1000000
#define PNG_ZBUF_SIZE 8192
#define PNG_ZLIB_VERNUM 0x12b0
#define PNG_Z_DEFAULT_COMPRESSION (-1)
#define PNG_Z_DEFAULT_NOFILTER_STRATEGY 0
#define PNG_Z_DEFAULT_STRATEGY 1
#define PNG_sCAL_PRECISION 5
#define PNG_sRGB_PROFILE_CHECKS 2
/* end of settings */
#endif /* PNGLCONF_H */
stdio_ext.h 0000644 00000005357 15201526705 0006734 0 ustar 00 /* Functions to access FILE structure internals.
Copyright (C) 2000-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
/* This header contains the same definitions as the header of the same name
on Sun's Solaris OS. */
#ifndef _STDIO_EXT_H
#define _STDIO_EXT_H 1
#include <stdio.h>
enum
{
/* Query current state of the locking status. */
FSETLOCKING_QUERY = 0,
#define FSETLOCKING_QUERY FSETLOCKING_QUERY
/* The library protects all uses of the stream functions, except for
uses of the *_unlocked functions, by calls equivalent to flockfile(). */
FSETLOCKING_INTERNAL,
#define FSETLOCKING_INTERNAL FSETLOCKING_INTERNAL
/* The user will take care of locking. */
FSETLOCKING_BYCALLER
#define FSETLOCKING_BYCALLER FSETLOCKING_BYCALLER
};
__BEGIN_DECLS
/* Return the size of the buffer of FP in bytes currently in use by
the given stream. */
extern size_t __fbufsize (FILE *__fp) __THROW;
/* Return non-zero value iff the stream FP is opened readonly, or if the
last operation on the stream was a read operation. */
extern int __freading (FILE *__fp) __THROW;
/* Return non-zero value iff the stream FP is opened write-only or
append-only, or if the last operation on the stream was a write
operation. */
extern int __fwriting (FILE *__fp) __THROW;
/* Return non-zero value iff stream FP is not opened write-only or
append-only. */
extern int __freadable (FILE *__fp) __THROW;
/* Return non-zero value iff stream FP is not opened read-only. */
extern int __fwritable (FILE *__fp) __THROW;
/* Return non-zero value iff the stream FP is line-buffered. */
extern int __flbf (FILE *__fp) __THROW;
/* Discard all pending buffered I/O on the stream FP. */
extern void __fpurge (FILE *__fp) __THROW;
/* Return amount of output in bytes pending on a stream FP. */
extern size_t __fpending (FILE *__fp) __THROW;
/* Flush all line-buffered files. */
extern void _flushlbf (void);
/* Set locking status of stream FP to TYPE. */
extern int __fsetlocking (FILE *__fp, int __type) __THROW;
__END_DECLS
#endif /* stdio_ext.h */
jpegint.h 0000644 00000036342 15201526705 0006370 0 ustar 00 /*
* jpegint.h
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 1997-2009 by Guido Vollbeding.
* libjpeg-turbo Modifications:
* Copyright (C) 2015-2016, D. R. Commander.
* Copyright (C) 2015, Google, Inc.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
* This file provides common declarations for the various JPEG modules.
* These declarations are considered internal to the JPEG library; most
* applications using the library shouldn't need to include this file.
*/
/* Declarations for both compression & decompression */
typedef enum { /* Operating modes for buffer controllers */
JBUF_PASS_THRU, /* Plain stripwise operation */
/* Remaining modes require a full-image buffer to have been created */
JBUF_SAVE_SOURCE, /* Run source subobject only, save output */
JBUF_CRANK_DEST, /* Run dest subobject only, using saved data */
JBUF_SAVE_AND_PASS /* Run both subobjects, save output */
} J_BUF_MODE;
/* Values of global_state field (jdapi.c has some dependencies on ordering!) */
#define CSTATE_START 100 /* after create_compress */
#define CSTATE_SCANNING 101 /* start_compress done, write_scanlines OK */
#define CSTATE_RAW_OK 102 /* start_compress done, write_raw_data OK */
#define CSTATE_WRCOEFS 103 /* jpeg_write_coefficients done */
#define DSTATE_START 200 /* after create_decompress */
#define DSTATE_INHEADER 201 /* reading header markers, no SOS yet */
#define DSTATE_READY 202 /* found SOS, ready for start_decompress */
#define DSTATE_PRELOAD 203 /* reading multiscan file in start_decompress*/
#define DSTATE_PRESCAN 204 /* performing dummy pass for 2-pass quant */
#define DSTATE_SCANNING 205 /* start_decompress done, read_scanlines OK */
#define DSTATE_RAW_OK 206 /* start_decompress done, read_raw_data OK */
#define DSTATE_BUFIMAGE 207 /* expecting jpeg_start_output */
#define DSTATE_BUFPOST 208 /* looking for SOS/EOI in jpeg_finish_output */
#define DSTATE_RDCOEFS 209 /* reading file in jpeg_read_coefficients */
#define DSTATE_STOPPING 210 /* looking for EOI in jpeg_finish_decompress */
/* JLONG must hold at least signed 32-bit values. */
typedef long JLONG;
/*
* Left shift macro that handles a negative operand without causing any
* sanitizer warnings
*/
#define LEFT_SHIFT(a, b) ((JLONG)((unsigned long)(a) << (b)))
/* Declarations for compression modules */
/* Master control module */
struct jpeg_comp_master {
void (*prepare_for_pass) (j_compress_ptr cinfo);
void (*pass_startup) (j_compress_ptr cinfo);
void (*finish_pass) (j_compress_ptr cinfo);
/* State variables made visible to other modules */
boolean call_pass_startup; /* True if pass_startup must be called */
boolean is_last_pass; /* True during last pass */
};
/* Main buffer control (downsampled-data buffer) */
struct jpeg_c_main_controller {
void (*start_pass) (j_compress_ptr cinfo, J_BUF_MODE pass_mode);
void (*process_data) (j_compress_ptr cinfo, JSAMPARRAY input_buf,
JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail);
};
/* Compression preprocessing (downsampling input buffer control) */
struct jpeg_c_prep_controller {
void (*start_pass) (j_compress_ptr cinfo, J_BUF_MODE pass_mode);
void (*pre_process_data) (j_compress_ptr cinfo, JSAMPARRAY input_buf,
JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail,
JSAMPIMAGE output_buf,
JDIMENSION *out_row_group_ctr,
JDIMENSION out_row_groups_avail);
};
/* Coefficient buffer control */
struct jpeg_c_coef_controller {
void (*start_pass) (j_compress_ptr cinfo, J_BUF_MODE pass_mode);
boolean (*compress_data) (j_compress_ptr cinfo, JSAMPIMAGE input_buf);
};
/* Colorspace conversion */
struct jpeg_color_converter {
void (*start_pass) (j_compress_ptr cinfo);
void (*color_convert) (j_compress_ptr cinfo, JSAMPARRAY input_buf,
JSAMPIMAGE output_buf, JDIMENSION output_row,
int num_rows);
};
/* Downsampling */
struct jpeg_downsampler {
void (*start_pass) (j_compress_ptr cinfo);
void (*downsample) (j_compress_ptr cinfo, JSAMPIMAGE input_buf,
JDIMENSION in_row_index, JSAMPIMAGE output_buf,
JDIMENSION out_row_group_index);
boolean need_context_rows; /* TRUE if need rows above & below */
};
/* Forward DCT (also controls coefficient quantization) */
struct jpeg_forward_dct {
void (*start_pass) (j_compress_ptr cinfo);
/* perhaps this should be an array??? */
void (*forward_DCT) (j_compress_ptr cinfo, jpeg_component_info *compptr,
JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
JDIMENSION start_row, JDIMENSION start_col,
JDIMENSION num_blocks);
};
/* Entropy encoding */
struct jpeg_entropy_encoder {
void (*start_pass) (j_compress_ptr cinfo, boolean gather_statistics);
boolean (*encode_mcu) (j_compress_ptr cinfo, JBLOCKROW *MCU_data);
void (*finish_pass) (j_compress_ptr cinfo);
};
/* Marker writing */
struct jpeg_marker_writer {
void (*write_file_header) (j_compress_ptr cinfo);
void (*write_frame_header) (j_compress_ptr cinfo);
void (*write_scan_header) (j_compress_ptr cinfo);
void (*write_file_trailer) (j_compress_ptr cinfo);
void (*write_tables_only) (j_compress_ptr cinfo);
/* These routines are exported to allow insertion of extra markers */
/* Probably only COM and APPn markers should be written this way */
void (*write_marker_header) (j_compress_ptr cinfo, int marker,
unsigned int datalen);
void (*write_marker_byte) (j_compress_ptr cinfo, int val);
};
/* Declarations for decompression modules */
/* Master control module */
struct jpeg_decomp_master {
void (*prepare_for_output_pass) (j_decompress_ptr cinfo);
void (*finish_output_pass) (j_decompress_ptr cinfo);
/* State variables made visible to other modules */
boolean is_dummy_pass; /* True during 1st pass for 2-pass quant */
/* Partial decompression variables */
JDIMENSION first_iMCU_col;
JDIMENSION last_iMCU_col;
JDIMENSION first_MCU_col[MAX_COMPONENTS];
JDIMENSION last_MCU_col[MAX_COMPONENTS];
boolean jinit_upsampler_no_alloc;
};
/* Input control module */
struct jpeg_input_controller {
int (*consume_input) (j_decompress_ptr cinfo);
void (*reset_input_controller) (j_decompress_ptr cinfo);
void (*start_input_pass) (j_decompress_ptr cinfo);
void (*finish_input_pass) (j_decompress_ptr cinfo);
/* State variables made visible to other modules */
boolean has_multiple_scans; /* True if file has multiple scans */
boolean eoi_reached; /* True when EOI has been consumed */
};
/* Main buffer control (downsampled-data buffer) */
struct jpeg_d_main_controller {
void (*start_pass) (j_decompress_ptr cinfo, J_BUF_MODE pass_mode);
void (*process_data) (j_decompress_ptr cinfo, JSAMPARRAY output_buf,
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
};
/* Coefficient buffer control */
struct jpeg_d_coef_controller {
void (*start_input_pass) (j_decompress_ptr cinfo);
int (*consume_data) (j_decompress_ptr cinfo);
void (*start_output_pass) (j_decompress_ptr cinfo);
int (*decompress_data) (j_decompress_ptr cinfo, JSAMPIMAGE output_buf);
/* Pointer to array of coefficient virtual arrays, or NULL if none */
jvirt_barray_ptr *coef_arrays;
};
/* Decompression postprocessing (color quantization buffer control) */
struct jpeg_d_post_controller {
void (*start_pass) (j_decompress_ptr cinfo, J_BUF_MODE pass_mode);
void (*post_process_data) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
JDIMENSION *in_row_group_ctr,
JDIMENSION in_row_groups_avail,
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
JDIMENSION out_rows_avail);
};
/* Marker reading & parsing */
struct jpeg_marker_reader {
void (*reset_marker_reader) (j_decompress_ptr cinfo);
/* Read markers until SOS or EOI.
* Returns same codes as are defined for jpeg_consume_input:
* JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI.
*/
int (*read_markers) (j_decompress_ptr cinfo);
/* Read a restart marker --- exported for use by entropy decoder only */
jpeg_marker_parser_method read_restart_marker;
/* State of marker reader --- nominally internal, but applications
* supplying COM or APPn handlers might like to know the state.
*/
boolean saw_SOI; /* found SOI? */
boolean saw_SOF; /* found SOF? */
int next_restart_num; /* next restart number expected (0-7) */
unsigned int discarded_bytes; /* # of bytes skipped looking for a marker */
};
/* Entropy decoding */
struct jpeg_entropy_decoder {
void (*start_pass) (j_decompress_ptr cinfo);
boolean (*decode_mcu) (j_decompress_ptr cinfo, JBLOCKROW *MCU_data);
/* This is here to share code between baseline and progressive decoders; */
/* other modules probably should not use it */
boolean insufficient_data; /* set TRUE after emitting warning */
};
/* Inverse DCT (also performs dequantization) */
typedef void (*inverse_DCT_method_ptr) (j_decompress_ptr cinfo,
jpeg_component_info *compptr,
JCOEFPTR coef_block,
JSAMPARRAY output_buf,
JDIMENSION output_col);
struct jpeg_inverse_dct {
void (*start_pass) (j_decompress_ptr cinfo);
/* It is useful to allow each component to have a separate IDCT method. */
inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS];
};
/* Upsampling (note that upsampler must also call color converter) */
struct jpeg_upsampler {
void (*start_pass) (j_decompress_ptr cinfo);
void (*upsample) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
JDIMENSION *in_row_group_ctr,
JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf,
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
boolean need_context_rows; /* TRUE if need rows above & below */
};
/* Colorspace conversion */
struct jpeg_color_deconverter {
void (*start_pass) (j_decompress_ptr cinfo);
void (*color_convert) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
JDIMENSION input_row, JSAMPARRAY output_buf,
int num_rows);
};
/* Color quantization or color precision reduction */
struct jpeg_color_quantizer {
void (*start_pass) (j_decompress_ptr cinfo, boolean is_pre_scan);
void (*color_quantize) (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
JSAMPARRAY output_buf, int num_rows);
void (*finish_pass) (j_decompress_ptr cinfo);
void (*new_color_map) (j_decompress_ptr cinfo);
};
/* Miscellaneous useful macros */
#undef MAX
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#undef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b))
/* We assume that right shift corresponds to signed division by 2 with
* rounding towards minus infinity. This is correct for typical "arithmetic
* shift" instructions that shift in copies of the sign bit. But some
* C compilers implement >> with an unsigned shift. For these machines you
* must define RIGHT_SHIFT_IS_UNSIGNED.
* RIGHT_SHIFT provides a proper signed right shift of a JLONG quantity.
* It is only applied with constant shift counts. SHIFT_TEMPS must be
* included in the variables of any routine using RIGHT_SHIFT.
*/
#ifdef RIGHT_SHIFT_IS_UNSIGNED
#define SHIFT_TEMPS JLONG shift_temp;
#define RIGHT_SHIFT(x,shft) \
((shift_temp = (x)) < 0 ? \
(shift_temp >> (shft)) | ((~((JLONG) 0)) << (32-(shft))) : \
(shift_temp >> (shft)))
#else
#define SHIFT_TEMPS
#define RIGHT_SHIFT(x,shft) ((x) >> (shft))
#endif
/* Compression module initialization routines */
EXTERN(void) jinit_compress_master (j_compress_ptr cinfo);
EXTERN(void) jinit_c_master_control (j_compress_ptr cinfo,
boolean transcode_only);
EXTERN(void) jinit_c_main_controller (j_compress_ptr cinfo,
boolean need_full_buffer);
EXTERN(void) jinit_c_prep_controller (j_compress_ptr cinfo,
boolean need_full_buffer);
EXTERN(void) jinit_c_coef_controller (j_compress_ptr cinfo,
boolean need_full_buffer);
EXTERN(void) jinit_color_converter (j_compress_ptr cinfo);
EXTERN(void) jinit_downsampler (j_compress_ptr cinfo);
EXTERN(void) jinit_forward_dct (j_compress_ptr cinfo);
EXTERN(void) jinit_huff_encoder (j_compress_ptr cinfo);
EXTERN(void) jinit_phuff_encoder (j_compress_ptr cinfo);
EXTERN(void) jinit_arith_encoder (j_compress_ptr cinfo);
EXTERN(void) jinit_marker_writer (j_compress_ptr cinfo);
/* Decompression module initialization routines */
EXTERN(void) jinit_master_decompress (j_decompress_ptr cinfo);
EXTERN(void) jinit_d_main_controller (j_decompress_ptr cinfo,
boolean need_full_buffer);
EXTERN(void) jinit_d_coef_controller (j_decompress_ptr cinfo,
boolean need_full_buffer);
EXTERN(void) jinit_d_post_controller (j_decompress_ptr cinfo,
boolean need_full_buffer);
EXTERN(void) jinit_input_controller (j_decompress_ptr cinfo);
EXTERN(void) jinit_marker_reader (j_decompress_ptr cinfo);
EXTERN(void) jinit_huff_decoder (j_decompress_ptr cinfo);
EXTERN(void) jinit_phuff_decoder (j_decompress_ptr cinfo);
EXTERN(void) jinit_arith_decoder (j_decompress_ptr cinfo);
EXTERN(void) jinit_inverse_dct (j_decompress_ptr cinfo);
EXTERN(void) jinit_upsampler (j_decompress_ptr cinfo);
EXTERN(void) jinit_color_deconverter (j_decompress_ptr cinfo);
EXTERN(void) jinit_1pass_quantizer (j_decompress_ptr cinfo);
EXTERN(void) jinit_2pass_quantizer (j_decompress_ptr cinfo);
EXTERN(void) jinit_merged_upsampler (j_decompress_ptr cinfo);
/* Memory manager initialization */
EXTERN(void) jinit_memory_mgr (j_common_ptr cinfo);
/* Utility routines in jutils.c */
EXTERN(long) jdiv_round_up (long a, long b);
EXTERN(long) jround_up (long a, long b);
EXTERN(void) jcopy_sample_rows (JSAMPARRAY input_array, int source_row,
JSAMPARRAY output_array, int dest_row,
int num_rows, JDIMENSION num_cols);
EXTERN(void) jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row,
JDIMENSION num_blocks);
EXTERN(void) jzero_far (void *target, size_t bytestozero);
/* Constant tables in jutils.c */
#if 0 /* This table is not actually needed in v6a */
extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */
#endif
extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */
/* Arithmetic coding probability estimation tables in jaricom.c */
extern const JLONG jpeg_aritab[];
/* Suppress undefined-structure complaints if necessary. */
#ifdef INCOMPLETE_TYPES_BROKEN
#ifndef AM_MEMORY_MANAGER /* only jmemmgr.c defines these */
struct jvirt_sarray_control { long dummy; };
struct jvirt_barray_control { long dummy; };
#endif
#endif /* INCOMPLETE_TYPES_BROKEN */
idna.h 0000644 00000006754 15201526705 0005647 0 ustar 00 /* idna.h --- Prototypes for Internationalized Domain Name library.
Copyright (C) 2002-2016 Simon Josefsson
This file is part of GNU Libidn.
GNU Libidn is free software: you can redistribute it and/or
modify it under the terms of either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at
your option) any later version.
or
* the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at
your option) any later version.
or both in parallel, as here.
GNU Libidn is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received copies of the GNU General Public License and
the GNU Lesser General Public License along with this program. If
not, see <http://www.gnu.org/licenses/>. */
#ifndef IDNA_H
# define IDNA_H
# ifndef IDNAPI
# if defined LIBIDN_BUILDING && defined HAVE_VISIBILITY && HAVE_VISIBILITY
# define IDNAPI __attribute__((__visibility__("default")))
# elif defined LIBIDN_BUILDING && defined _MSC_VER && ! defined LIBIDN_STATIC
# define IDNAPI __declspec(dllexport)
# elif defined _MSC_VER && ! defined LIBIDN_STATIC
# define IDNAPI __declspec(dllimport)
# else
# define IDNAPI
# endif
# endif
# include <stddef.h> /* size_t */
# include <idn-int.h> /* uint32_t */
# ifdef __cplusplus
extern "C"
{
# endif
/* Error codes. */
typedef enum
{
IDNA_SUCCESS = 0,
IDNA_STRINGPREP_ERROR = 1,
IDNA_PUNYCODE_ERROR = 2,
IDNA_CONTAINS_NON_LDH = 3,
/* Workaround typo in earlier versions. */
IDNA_CONTAINS_LDH = IDNA_CONTAINS_NON_LDH,
IDNA_CONTAINS_MINUS = 4,
IDNA_INVALID_LENGTH = 5,
IDNA_NO_ACE_PREFIX = 6,
IDNA_ROUNDTRIP_VERIFY_ERROR = 7,
IDNA_CONTAINS_ACE_PREFIX = 8,
IDNA_ICONV_ERROR = 9,
/* Internal errors. */
IDNA_MALLOC_ERROR = 201,
IDNA_DLOPEN_ERROR = 202
} Idna_rc;
/* IDNA flags */
typedef enum
{
IDNA_ALLOW_UNASSIGNED = 0x0001,
IDNA_USE_STD3_ASCII_RULES = 0x0002
} Idna_flags;
# ifndef IDNA_ACE_PREFIX
# define IDNA_ACE_PREFIX "xn--"
# endif
extern IDNAPI const char *idna_strerror (Idna_rc rc);
/* Core functions */
extern IDNAPI int idna_to_ascii_4i (const uint32_t * in, size_t inlen,
char *out, int flags);
extern IDNAPI int idna_to_unicode_44i (const uint32_t * in, size_t inlen,
uint32_t * out, size_t * outlen,
int flags);
/* Wrappers that handle several labels */
extern IDNAPI int idna_to_ascii_4z (const uint32_t * input,
char **output, int flags);
extern IDNAPI int idna_to_ascii_8z (const char *input, char **output,
int flags);
extern IDNAPI int idna_to_ascii_lz (const char *input, char **output,
int flags);
extern IDNAPI int idna_to_unicode_4z4z (const uint32_t * input,
uint32_t ** output, int flags);
extern IDNAPI int idna_to_unicode_8z4z (const char *input,
uint32_t ** output, int flags);
extern IDNAPI int idna_to_unicode_8z8z (const char *input,
char **output, int flags);
extern IDNAPI int idna_to_unicode_8zlz (const char *input,
char **output, int flags);
extern IDNAPI int idna_to_unicode_lzlz (const char *input,
char **output, int flags);
# ifdef __cplusplus
}
# endif
#endif /* IDNA_H */
grp.h 0000644 00000015036 15201526705 0005515 0 ustar 00 /* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
/*
* POSIX Standard: 9.2.1 Group Database Access <grp.h>
*/
#ifndef _GRP_H
#define _GRP_H 1
#include <features.h>
__BEGIN_DECLS
#include <bits/types.h>
#define __need_size_t
#include <stddef.h>
/* For the Single Unix specification we must define this type here. */
#if (defined __USE_XOPEN || defined __USE_XOPEN2K) && !defined __gid_t_defined
typedef __gid_t gid_t;
# define __gid_t_defined
#endif
/* The group structure. */
struct group
{
char *gr_name; /* Group name. */
char *gr_passwd; /* Password. */
__gid_t gr_gid; /* Group ID. */
char **gr_mem; /* Member list. */
};
#ifdef __USE_MISC
# include <bits/types/FILE.h>
#endif
#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
/* Rewind the group-file stream.
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern void setgrent (void);
/* Close the group-file stream.
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern void endgrent (void);
/* Read an entry from the group-file stream, opening it if necessary.
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern struct group *getgrent (void);
#endif
#ifdef __USE_MISC
/* Read a group entry from STREAM.
This function is not part of POSIX and therefore no official
cancellation point. But due to similarity with an POSIX interface
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
extern struct group *fgetgrent (FILE *__stream);
#endif
#ifdef __USE_GNU
/* Write the given entry onto the given stream.
This function is not part of POSIX and therefore no official
cancellation point. But due to similarity with an POSIX interface
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
extern int putgrent (const struct group *__restrict __p,
FILE *__restrict __f);
#endif
/* Search for an entry with a matching group ID.
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern struct group *getgrgid (__gid_t __gid);
/* Search for an entry with a matching group name.
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern struct group *getgrnam (const char *__name);
#ifdef __USE_POSIX
# ifdef __USE_MISC
/* Reasonable value for the buffer sized used in the reentrant
functions below. But better use `sysconf'. */
# define NSS_BUFLEN_GROUP 1024
# endif
/* Reentrant versions of some of the functions above.
PLEASE NOTE: the `getgrent_r' function is not (yet) standardized.
The interface may change in later versions of this library. But
the interface is designed following the principals used for the
other reentrant functions so the chances are good this is what the
POSIX people would choose.
This function is not part of POSIX and therefore no official
cancellation point. But due to similarity with an POSIX interface
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
# ifdef __USE_GNU
extern int getgrent_r (struct group *__restrict __resultbuf,
char *__restrict __buffer, size_t __buflen,
struct group **__restrict __result);
# endif
/* Search for an entry with a matching group ID.
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern int getgrgid_r (__gid_t __gid, struct group *__restrict __resultbuf,
char *__restrict __buffer, size_t __buflen,
struct group **__restrict __result);
/* Search for an entry with a matching group name.
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern int getgrnam_r (const char *__restrict __name,
struct group *__restrict __resultbuf,
char *__restrict __buffer, size_t __buflen,
struct group **__restrict __result);
# ifdef __USE_MISC
/* Read a group entry from STREAM. This function is not standardized
an probably never will.
This function is not part of POSIX and therefore no official
cancellation point. But due to similarity with an POSIX interface
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
extern int fgetgrent_r (FILE *__restrict __stream,
struct group *__restrict __resultbuf,
char *__restrict __buffer, size_t __buflen,
struct group **__restrict __result);
# endif
#endif /* POSIX or reentrant */
#ifdef __USE_MISC
# define __need_size_t
# include <stddef.h>
/* Set the group set for the current user to GROUPS (N of them). */
extern int setgroups (size_t __n, const __gid_t *__groups) __THROW;
/* Store at most *NGROUPS members of the group set for USER into
*GROUPS. Also include GROUP. The actual number of groups found is
returned in *NGROUPS. Return -1 if the if *NGROUPS is too small.
This function is not part of POSIX and therefore no official
cancellation point. But due to similarity with an POSIX interface
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
extern int getgrouplist (const char *__user, __gid_t __group,
__gid_t *__groups, int *__ngroups);
/* Initialize the group set for the current user
by reading the group database and using all groups
of which USER is a member. Also include GROUP.
This function is not part of POSIX and therefore no official
cancellation point. But due to similarity with an POSIX interface
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
extern int initgroups (const char *__user, __gid_t __group);
#endif /* Use misc. */
__END_DECLS
#endif /* grp.h */
string.h 0000644 00000042263 15201526705 0006235 0 ustar 00 /* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
/*
* ISO C99 Standard: 7.21 String handling <string.h>
*/
#ifndef _STRING_H
#define _STRING_H 1
#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
#include <bits/libc-header-start.h>
__BEGIN_DECLS
/* Get size_t and NULL from <stddef.h>. */
#define __need_size_t
#define __need_NULL
#include <stddef.h>
/* Tell the caller that we provide correct C++ prototypes. */
#if defined __cplusplus && (__GNUC_PREREQ (4, 4) \
|| __glibc_clang_prereq (3, 5))
# define __CORRECT_ISO_CPP_STRING_H_PROTO
#endif
/* Copy N bytes of SRC to DEST. */
extern void *memcpy (void *__restrict __dest, const void *__restrict __src,
size_t __n) __THROW __nonnull ((1, 2));
/* Copy N bytes of SRC to DEST, guaranteeing
correct behavior for overlapping strings. */
extern void *memmove (void *__dest, const void *__src, size_t __n)
__THROW __nonnull ((1, 2));
/* Copy no more than N bytes of SRC to DEST, stopping when C is found.
Return the position in DEST one byte past where C was copied,
or NULL if C was not found in the first N bytes of SRC. */
#if defined __USE_MISC || defined __USE_XOPEN
extern void *memccpy (void *__restrict __dest, const void *__restrict __src,
int __c, size_t __n)
__THROW __nonnull ((1, 2));
#endif /* Misc || X/Open. */
/* Set N bytes of S to C. */
extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
/* Compare N bytes of S1 and S2. */
extern int memcmp (const void *__s1, const void *__s2, size_t __n)
__THROW __attribute_pure__ __nonnull ((1, 2));
/* Search N bytes of S for C. */
#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
extern "C++"
{
extern void *memchr (void *__s, int __c, size_t __n)
__THROW __asm ("memchr") __attribute_pure__ __nonnull ((1));
extern const void *memchr (const void *__s, int __c, size_t __n)
__THROW __asm ("memchr") __attribute_pure__ __nonnull ((1));
# ifdef __OPTIMIZE__
__extern_always_inline void *
memchr (void *__s, int __c, size_t __n) __THROW
{
return __builtin_memchr (__s, __c, __n);
}
__extern_always_inline const void *
memchr (const void *__s, int __c, size_t __n) __THROW
{
return __builtin_memchr (__s, __c, __n);
}
# endif
}
#else
extern void *memchr (const void *__s, int __c, size_t __n)
__THROW __attribute_pure__ __nonnull ((1));
#endif
#ifdef __USE_GNU
/* Search in S for C. This is similar to `memchr' but there is no
length limit. */
# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
extern "C++" void *rawmemchr (void *__s, int __c)
__THROW __asm ("rawmemchr") __attribute_pure__ __nonnull ((1));
extern "C++" const void *rawmemchr (const void *__s, int __c)
__THROW __asm ("rawmemchr") __attribute_pure__ __nonnull ((1));
# else
extern void *rawmemchr (const void *__s, int __c)
__THROW __attribute_pure__ __nonnull ((1));
# endif
/* Search N bytes of S for the final occurrence of C. */
# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
extern "C++" void *memrchr (void *__s, int __c, size_t __n)
__THROW __asm ("memrchr") __attribute_pure__ __nonnull ((1));
extern "C++" const void *memrchr (const void *__s, int __c, size_t __n)
__THROW __asm ("memrchr") __attribute_pure__ __nonnull ((1));
# else
extern void *memrchr (const void *__s, int __c, size_t __n)
__THROW __attribute_pure__ __nonnull ((1));
# endif
#endif
/* Copy SRC to DEST. */
extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
__THROW __nonnull ((1, 2));
/* Copy no more than N characters of SRC to DEST. */
extern char *strncpy (char *__restrict __dest,
const char *__restrict __src, size_t __n)
__THROW __nonnull ((1, 2));
/* Append SRC onto DEST. */
extern char *strcat (char *__restrict __dest, const char *__restrict __src)
__THROW __nonnull ((1, 2));
/* Append no more than N characters from SRC onto DEST. */
extern char *strncat (char *__restrict __dest, const char *__restrict __src,
size_t __n) __THROW __nonnull ((1, 2));
/* Compare S1 and S2. */
extern int strcmp (const char *__s1, const char *__s2)
__THROW __attribute_pure__ __nonnull ((1, 2));
/* Compare N characters of S1 and S2. */
extern int strncmp (const char *__s1, const char *__s2, size_t __n)
__THROW __attribute_pure__ __nonnull ((1, 2));
/* Compare the collated forms of S1 and S2. */
extern int strcoll (const char *__s1, const char *__s2)
__THROW __attribute_pure__ __nonnull ((1, 2));
/* Put a transformation of SRC into no more than N bytes of DEST. */
extern size_t strxfrm (char *__restrict __dest,
const char *__restrict __src, size_t __n)
__THROW __nonnull ((2));
#ifdef __USE_XOPEN2K8
/* POSIX.1-2008 extended locale interface (see locale.h). */
# include <bits/types/locale_t.h>
/* Compare the collated forms of S1 and S2, using sorting rules from L. */
extern int strcoll_l (const char *__s1, const char *__s2, locale_t __l)
__THROW __attribute_pure__ __nonnull ((1, 2, 3));
/* Put a transformation of SRC into no more than N bytes of DEST,
using sorting rules from L. */
extern size_t strxfrm_l (char *__dest, const char *__src, size_t __n,
locale_t __l) __THROW __nonnull ((2, 4));
#endif
#if (defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 \
|| __GLIBC_USE (LIB_EXT2))
/* Duplicate S, returning an identical malloc'd string. */
extern char *strdup (const char *__s)
__THROW __attribute_malloc__ __nonnull ((1));
#endif
/* Return a malloc'd copy of at most N bytes of STRING. The
resultant string is terminated even if no null terminator
appears before STRING[N]. */
#if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)
extern char *strndup (const char *__string, size_t __n)
__THROW __attribute_malloc__ __nonnull ((1));
#endif
#if defined __USE_GNU && defined __GNUC__
/* Duplicate S, returning an identical alloca'd string. */
# define strdupa(s) \
(__extension__ \
({ \
const char *__old = (s); \
size_t __len = strlen (__old) + 1; \
char *__new = (char *) __builtin_alloca (__len); \
(char *) memcpy (__new, __old, __len); \
}))
/* Return an alloca'd copy of at most N bytes of string. */
# define strndupa(s, n) \
(__extension__ \
({ \
const char *__old = (s); \
size_t __len = strnlen (__old, (n)); \
char *__new = (char *) __builtin_alloca (__len + 1); \
__new[__len] = '\0'; \
(char *) memcpy (__new, __old, __len); \
}))
#endif
/* Find the first occurrence of C in S. */
#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
extern "C++"
{
extern char *strchr (char *__s, int __c)
__THROW __asm ("strchr") __attribute_pure__ __nonnull ((1));
extern const char *strchr (const char *__s, int __c)
__THROW __asm ("strchr") __attribute_pure__ __nonnull ((1));
# ifdef __OPTIMIZE__
__extern_always_inline char *
strchr (char *__s, int __c) __THROW
{
return __builtin_strchr (__s, __c);
}
__extern_always_inline const char *
strchr (const char *__s, int __c) __THROW
{
return __builtin_strchr (__s, __c);
}
# endif
}
#else
extern char *strchr (const char *__s, int __c)
__THROW __attribute_pure__ __nonnull ((1));
#endif
/* Find the last occurrence of C in S. */
#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
extern "C++"
{
extern char *strrchr (char *__s, int __c)
__THROW __asm ("strrchr") __attribute_pure__ __nonnull ((1));
extern const char *strrchr (const char *__s, int __c)
__THROW __asm ("strrchr") __attribute_pure__ __nonnull ((1));
# ifdef __OPTIMIZE__
__extern_always_inline char *
strrchr (char *__s, int __c) __THROW
{
return __builtin_strrchr (__s, __c);
}
__extern_always_inline const char *
strrchr (const char *__s, int __c) __THROW
{
return __builtin_strrchr (__s, __c);
}
# endif
}
#else
extern char *strrchr (const char *__s, int __c)
__THROW __attribute_pure__ __nonnull ((1));
#endif
#ifdef __USE_GNU
/* This function is similar to `strchr'. But it returns a pointer to
the closing NUL byte in case C is not found in S. */
# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
extern "C++" char *strchrnul (char *__s, int __c)
__THROW __asm ("strchrnul") __attribute_pure__ __nonnull ((1));
extern "C++" const char *strchrnul (const char *__s, int __c)
__THROW __asm ("strchrnul") __attribute_pure__ __nonnull ((1));
# else
extern char *strchrnul (const char *__s, int __c)
__THROW __attribute_pure__ __nonnull ((1));
# endif
#endif
/* Return the length of the initial segment of S which
consists entirely of characters not in REJECT. */
extern size_t strcspn (const char *__s, const char *__reject)
__THROW __attribute_pure__ __nonnull ((1, 2));
/* Return the length of the initial segment of S which
consists entirely of characters in ACCEPT. */
extern size_t strspn (const char *__s, const char *__accept)
__THROW __attribute_pure__ __nonnull ((1, 2));
/* Find the first occurrence in S of any character in ACCEPT. */
#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
extern "C++"
{
extern char *strpbrk (char *__s, const char *__accept)
__THROW __asm ("strpbrk") __attribute_pure__ __nonnull ((1, 2));
extern const char *strpbrk (const char *__s, const char *__accept)
__THROW __asm ("strpbrk") __attribute_pure__ __nonnull ((1, 2));
# ifdef __OPTIMIZE__
__extern_always_inline char *
strpbrk (char *__s, const char *__accept) __THROW
{
return __builtin_strpbrk (__s, __accept);
}
__extern_always_inline const char *
strpbrk (const char *__s, const char *__accept) __THROW
{
return __builtin_strpbrk (__s, __accept);
}
# endif
}
#else
extern char *strpbrk (const char *__s, const char *__accept)
__THROW __attribute_pure__ __nonnull ((1, 2));
#endif
/* Find the first occurrence of NEEDLE in HAYSTACK. */
#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
extern "C++"
{
extern char *strstr (char *__haystack, const char *__needle)
__THROW __asm ("strstr") __attribute_pure__ __nonnull ((1, 2));
extern const char *strstr (const char *__haystack, const char *__needle)
__THROW __asm ("strstr") __attribute_pure__ __nonnull ((1, 2));
# ifdef __OPTIMIZE__
__extern_always_inline char *
strstr (char *__haystack, const char *__needle) __THROW
{
return __builtin_strstr (__haystack, __needle);
}
__extern_always_inline const char *
strstr (const char *__haystack, const char *__needle) __THROW
{
return __builtin_strstr (__haystack, __needle);
}
# endif
}
#else
extern char *strstr (const char *__haystack, const char *__needle)
__THROW __attribute_pure__ __nonnull ((1, 2));
#endif
/* Divide S into tokens separated by characters in DELIM. */
extern char *strtok (char *__restrict __s, const char *__restrict __delim)
__THROW __nonnull ((2));
/* Divide S into tokens separated by characters in DELIM. Information
passed between calls are stored in SAVE_PTR. */
extern char *__strtok_r (char *__restrict __s,
const char *__restrict __delim,
char **__restrict __save_ptr)
__THROW __nonnull ((2, 3));
#ifdef __USE_POSIX
extern char *strtok_r (char *__restrict __s, const char *__restrict __delim,
char **__restrict __save_ptr)
__THROW __nonnull ((2, 3));
#endif
#ifdef __USE_GNU
/* Similar to `strstr' but this function ignores the case of both strings. */
# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
extern "C++" char *strcasestr (char *__haystack, const char *__needle)
__THROW __asm ("strcasestr") __attribute_pure__ __nonnull ((1, 2));
extern "C++" const char *strcasestr (const char *__haystack,
const char *__needle)
__THROW __asm ("strcasestr") __attribute_pure__ __nonnull ((1, 2));
# else
extern char *strcasestr (const char *__haystack, const char *__needle)
__THROW __attribute_pure__ __nonnull ((1, 2));
# endif
#endif
#ifdef __USE_GNU
/* Find the first occurrence of NEEDLE in HAYSTACK.
NEEDLE is NEEDLELEN bytes long;
HAYSTACK is HAYSTACKLEN bytes long. */
extern void *memmem (const void *__haystack, size_t __haystacklen,
const void *__needle, size_t __needlelen)
__THROW __attribute_pure__ __nonnull ((1, 3));
/* Copy N bytes of SRC to DEST, return pointer to bytes after the
last written byte. */
extern void *__mempcpy (void *__restrict __dest,
const void *__restrict __src, size_t __n)
__THROW __nonnull ((1, 2));
extern void *mempcpy (void *__restrict __dest,
const void *__restrict __src, size_t __n)
__THROW __nonnull ((1, 2));
#endif
/* Return the length of S. */
extern size_t strlen (const char *__s)
__THROW __attribute_pure__ __nonnull ((1));
#ifdef __USE_XOPEN2K8
/* Find the length of STRING, but scan at most MAXLEN characters.
If no '\0' terminator is found in that many characters, return MAXLEN. */
extern size_t strnlen (const char *__string, size_t __maxlen)
__THROW __attribute_pure__ __nonnull ((1));
#endif
/* Return a string describing the meaning of the `errno' code in ERRNUM. */
extern char *strerror (int __errnum) __THROW;
#ifdef __USE_XOPEN2K
/* Reentrant version of `strerror'.
There are 2 flavors of `strerror_r', GNU which returns the string
and may or may not use the supplied temporary buffer and POSIX one
which fills the string into the buffer.
To use the POSIX version, -D_XOPEN_SOURCE=600 or -D_POSIX_C_SOURCE=200112L
without -D_GNU_SOURCE is needed, otherwise the GNU version is
preferred. */
# if defined __USE_XOPEN2K && !defined __USE_GNU
/* Fill BUF with a string describing the meaning of the `errno' code in
ERRNUM. */
# ifdef __REDIRECT_NTH
extern int __REDIRECT_NTH (strerror_r,
(int __errnum, char *__buf, size_t __buflen),
__xpg_strerror_r) __nonnull ((2));
# else
extern int __xpg_strerror_r (int __errnum, char *__buf, size_t __buflen)
__THROW __nonnull ((2));
# define strerror_r __xpg_strerror_r
# endif
# else
/* If a temporary buffer is required, at most BUFLEN bytes of BUF will be
used. */
extern char *strerror_r (int __errnum, char *__buf, size_t __buflen)
__THROW __nonnull ((2)) __wur;
# endif
#endif
#ifdef __USE_XOPEN2K8
/* Translate error number to string according to the locale L. */
extern char *strerror_l (int __errnum, locale_t __l) __THROW;
#endif
#ifdef __USE_MISC
# include <strings.h>
/* Set N bytes of S to 0. The compiler will not delete a call to this
function, even if S is dead after the call. */
extern void explicit_bzero (void *__s, size_t __n) __THROW __nonnull ((1));
/* Return the next DELIM-delimited token from *STRINGP,
terminating it with a '\0', and update *STRINGP to point past it. */
extern char *strsep (char **__restrict __stringp,
const char *__restrict __delim)
__THROW __nonnull ((1, 2));
#endif
#ifdef __USE_XOPEN2K8
/* Return a string describing the meaning of the signal number in SIG. */
extern char *strsignal (int __sig) __THROW;
/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */
extern char *__stpcpy (char *__restrict __dest, const char *__restrict __src)
__THROW __nonnull ((1, 2));
extern char *stpcpy (char *__restrict __dest, const char *__restrict __src)
__THROW __nonnull ((1, 2));
/* Copy no more than N characters of SRC to DEST, returning the address of
the last character written into DEST. */
extern char *__stpncpy (char *__restrict __dest,
const char *__restrict __src, size_t __n)
__THROW __nonnull ((1, 2));
extern char *stpncpy (char *__restrict __dest,
const char *__restrict __src, size_t __n)
__THROW __nonnull ((1, 2));
#endif
#ifdef __USE_GNU
/* Compare S1 and S2 as strings holding name & indices/version numbers. */
extern int strverscmp (const char *__s1, const char *__s2)
__THROW __attribute_pure__ __nonnull ((1, 2));
/* Sautee STRING briskly. */
extern char *strfry (char *__string) __THROW __nonnull ((1));
/* Frobnicate N bytes of S. */
extern void *memfrob (void *__s, size_t __n) __THROW __nonnull ((1));
# ifndef basename
/* Return the file name within directory of FILENAME. We don't
declare the function if the `basename' macro is available (defined
in <libgen.h>) which makes the XPG version of this function
available. */
# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
extern "C++" char *basename (char *__filename)
__THROW __asm ("basename") __nonnull ((1));
extern "C++" const char *basename (const char *__filename)
__THROW __asm ("basename") __nonnull ((1));
# else
extern char *basename (const char *__filename) __THROW __nonnull ((1));
# endif
# endif
#endif
#if __GNUC_PREREQ (3,4)
# if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
/* Functions with security checks. */
# include <bits/string_fortified.h>
# endif
#endif
__END_DECLS
#endif /* string.h */
malloc.h 0000644 00000013726 15201526705 0006200 0 ustar 00 /* Prototypes and definition for malloc implementation.
Copyright (C) 1996-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef _MALLOC_H
#define _MALLOC_H 1
#include <features.h>
#include <stddef.h>
#include <stdio.h>
#ifdef _LIBC
# define __MALLOC_HOOK_VOLATILE
# define __MALLOC_DEPRECATED
#else
# define __MALLOC_HOOK_VOLATILE volatile
# define __MALLOC_DEPRECATED __attribute_deprecated__
#endif
__BEGIN_DECLS
/* Allocate SIZE bytes of memory. */
extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur;
/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */
extern void *calloc (size_t __nmemb, size_t __size)
__THROW __attribute_malloc__ __wur;
/* Re-allocate the previously allocated block in __ptr, making the new
block SIZE bytes long. */
/* __attribute_malloc__ is not used, because if realloc returns
the same pointer that was passed to it, aliasing needs to be allowed
between objects pointed by the old and new pointers. */
extern void *realloc (void *__ptr, size_t __size)
__THROW __attribute_warn_unused_result__;
/* Re-allocate the previously allocated block in PTR, making the new
block large enough for NMEMB elements of SIZE bytes each. */
/* __attribute_malloc__ is not used, because if reallocarray returns
the same pointer that was passed to it, aliasing needs to be allowed
between objects pointed by the old and new pointers. */
extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)
__THROW __attribute_warn_unused_result__;
/* Free a block allocated by `malloc', `realloc' or `calloc'. */
extern void free (void *__ptr) __THROW;
/* Allocate SIZE bytes allocated to ALIGNMENT bytes. */
extern void *memalign (size_t __alignment, size_t __size)
__THROW __attribute_malloc__ __wur;
/* Allocate SIZE bytes on a page boundary. */
extern void *valloc (size_t __size) __THROW __attribute_malloc__ __wur;
/* Equivalent to valloc(minimum-page-that-holds(n)), that is, round up
__size to nearest pagesize. */
extern void *pvalloc (size_t __size) __THROW __attribute_malloc__ __wur;
/* Underlying allocation function; successive calls should return
contiguous pieces of memory. */
extern void *(*__morecore) (ptrdiff_t __size);
/* Default value of `__morecore'. */
extern void *__default_morecore (ptrdiff_t __size)
__THROW __attribute_malloc__;
/* SVID2/XPG mallinfo structure */
struct mallinfo
{
int arena; /* non-mmapped space allocated from system */
int ordblks; /* number of free chunks */
int smblks; /* number of fastbin blocks */
int hblks; /* number of mmapped regions */
int hblkhd; /* space in mmapped regions */
int usmblks; /* always 0, preserved for backwards compatibility */
int fsmblks; /* space available in freed fastbin blocks */
int uordblks; /* total allocated space */
int fordblks; /* total free space */
int keepcost; /* top-most, releasable (via malloc_trim) space */
};
/* Returns a copy of the updated current mallinfo. */
extern struct mallinfo mallinfo (void) __THROW;
/* SVID2/XPG mallopt options */
#ifndef M_MXFAST
# define M_MXFAST 1 /* maximum request size for "fastbins" */
#endif
#ifndef M_NLBLKS
# define M_NLBLKS 2 /* UNUSED in this malloc */
#endif
#ifndef M_GRAIN
# define M_GRAIN 3 /* UNUSED in this malloc */
#endif
#ifndef M_KEEP
# define M_KEEP 4 /* UNUSED in this malloc */
#endif
/* mallopt options that actually do something */
#define M_TRIM_THRESHOLD -1
#define M_TOP_PAD -2
#define M_MMAP_THRESHOLD -3
#define M_MMAP_MAX -4
#define M_CHECK_ACTION -5
#define M_PERTURB -6
#define M_ARENA_TEST -7
#define M_ARENA_MAX -8
/* General SVID/XPG interface to tunable parameters. */
extern int mallopt (int __param, int __val) __THROW;
/* Release all but __pad bytes of freed top-most memory back to the
system. Return 1 if successful, else 0. */
extern int malloc_trim (size_t __pad) __THROW;
/* Report the number of usable allocated bytes associated with allocated
chunk __ptr. */
extern size_t malloc_usable_size (void *__ptr) __THROW;
/* Prints brief summary statistics on stderr. */
extern void malloc_stats (void) __THROW;
/* Output information about state of allocator to stream FP. */
extern int malloc_info (int __options, FILE *__fp) __THROW;
/* Hooks for debugging and user-defined versions. */
extern void (*__MALLOC_HOOK_VOLATILE __free_hook) (void *__ptr,
const void *)
__MALLOC_DEPRECATED;
extern void *(*__MALLOC_HOOK_VOLATILE __malloc_hook)(size_t __size,
const void *)
__MALLOC_DEPRECATED;
extern void *(*__MALLOC_HOOK_VOLATILE __realloc_hook)(void *__ptr,
size_t __size,
const void *)
__MALLOC_DEPRECATED;
extern void *(*__MALLOC_HOOK_VOLATILE __memalign_hook)(size_t __alignment,
size_t __size,
const void *)
__MALLOC_DEPRECATED;
extern void (*__MALLOC_HOOK_VOLATILE __after_morecore_hook) (void);
/* Activate a standard set of debugging hooks. */
extern void __malloc_check_init (void) __THROW __MALLOC_DEPRECATED;
__END_DECLS
#endif /* malloc.h */
menu.h 0000644 00000027645 15201526705 0005702 0 ustar 00 /****************************************************************************
* Copyright (c) 1998-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included *
* in all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
* *
* Except as contained in this notice, the name(s) of the above copyright *
* holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written *
* authorization. *
****************************************************************************/
/****************************************************************************
* Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/* $Id: menu.h,v 1.23 2017/02/11 16:54:04 tom Exp $ */
#ifndef ETI_MENU
#define ETI_MENU
#ifdef AMIGA
#define TEXT TEXT_ncurses
#endif
#include <curses.h>
#include <eti.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef int Menu_Options;
typedef int Item_Options;
/* Menu options: */
#define O_ONEVALUE (0x01)
#define O_SHOWDESC (0x02)
#define O_ROWMAJOR (0x04)
#define O_IGNORECASE (0x08)
#define O_SHOWMATCH (0x10)
#define O_NONCYCLIC (0x20)
#define O_MOUSE_MENU (0x40)
/* Item options: */
#define O_SELECTABLE (0x01)
#if !NCURSES_OPAQUE_MENU
typedef struct
{
const char* str;
unsigned short length;
} TEXT;
#endif /* !NCURSES_OPAQUE_MENU */
struct tagMENU;
typedef struct tagITEM
#if !NCURSES_OPAQUE_MENU
{
TEXT name; /* name of menu item */
TEXT description; /* description of item, optional in display */
struct tagMENU *imenu; /* Pointer to parent menu */
void *userptr; /* Pointer to user defined per item data */
Item_Options opt; /* Item options */
short index; /* Item number if connected to a menu */
short y; /* y and x location of item in menu */
short x;
bool value; /* Selection value */
struct tagITEM *left; /* neighbor items */
struct tagITEM *right;
struct tagITEM *up;
struct tagITEM *down;
}
#endif /* !NCURSES_OPAQUE_MENU */
ITEM;
typedef void (*Menu_Hook)(struct tagMENU *);
typedef struct tagMENU
#if 1 /* not yet: !NCURSES_OPAQUE_MENU */
{
short height; /* Nr. of chars high */
short width; /* Nr. of chars wide */
short rows; /* Nr. of items high */
short cols; /* Nr. of items wide */
short frows; /* Nr. of formatted items high */
short fcols; /* Nr. of formatted items wide */
short arows; /* Nr. of items high (actual) */
short namelen; /* Max. name length */
short desclen; /* Max. description length */
short marklen; /* Length of mark, if any */
short itemlen; /* Length of one item */
short spc_desc; /* Spacing for descriptor */
short spc_cols; /* Spacing for columns */
short spc_rows; /* Spacing for rows */
char *pattern; /* Buffer to store match chars */
short pindex; /* Index into pattern buffer */
WINDOW *win; /* Window containing menu */
WINDOW *sub; /* Subwindow for menu display */
WINDOW *userwin; /* User's window */
WINDOW *usersub; /* User's subwindow */
ITEM **items; /* array of items */
short nitems; /* Nr. of items in menu */
ITEM *curitem; /* Current item */
short toprow; /* Top row of menu */
chtype fore; /* Selection attribute */
chtype back; /* Nonselection attribute */
chtype grey; /* Inactive attribute */
unsigned char pad; /* Pad character */
Menu_Hook menuinit; /* User hooks */
Menu_Hook menuterm;
Menu_Hook iteminit;
Menu_Hook itemterm;
void *userptr; /* Pointer to menus user data */
char *mark; /* Pointer to marker string */
Menu_Options opt; /* Menu options */
unsigned short status; /* Internal state of menu */
}
#endif /* !NCURSES_OPAQUE_MENU */
MENU;
/* Define keys */
#define REQ_LEFT_ITEM (KEY_MAX + 1)
#define REQ_RIGHT_ITEM (KEY_MAX + 2)
#define REQ_UP_ITEM (KEY_MAX + 3)
#define REQ_DOWN_ITEM (KEY_MAX + 4)
#define REQ_SCR_ULINE (KEY_MAX + 5)
#define REQ_SCR_DLINE (KEY_MAX + 6)
#define REQ_SCR_DPAGE (KEY_MAX + 7)
#define REQ_SCR_UPAGE (KEY_MAX + 8)
#define REQ_FIRST_ITEM (KEY_MAX + 9)
#define REQ_LAST_ITEM (KEY_MAX + 10)
#define REQ_NEXT_ITEM (KEY_MAX + 11)
#define REQ_PREV_ITEM (KEY_MAX + 12)
#define REQ_TOGGLE_ITEM (KEY_MAX + 13)
#define REQ_CLEAR_PATTERN (KEY_MAX + 14)
#define REQ_BACK_PATTERN (KEY_MAX + 15)
#define REQ_NEXT_MATCH (KEY_MAX + 16)
#define REQ_PREV_MATCH (KEY_MAX + 17)
#define MIN_MENU_COMMAND (KEY_MAX + 1)
#define MAX_MENU_COMMAND (KEY_MAX + 17)
/*
* Some AT&T code expects MAX_COMMAND to be out-of-band not
* just for menu commands but for forms ones as well.
*/
#if defined(MAX_COMMAND)
# if (MAX_MENU_COMMAND > MAX_COMMAND)
# error Something is wrong -- MAX_MENU_COMMAND is greater than MAX_COMMAND
# elif (MAX_COMMAND != (KEY_MAX + 128))
# error Something is wrong -- MAX_COMMAND is already inconsistently defined.
# endif
#else
# define MAX_COMMAND (KEY_MAX + 128)
#endif
/* --------- prototypes for libmenu functions ----------------------------- */
extern NCURSES_EXPORT(ITEM **) menu_items (const MENU *);
extern NCURSES_EXPORT(ITEM *) current_item (const MENU *);
extern NCURSES_EXPORT(ITEM *) new_item (const char *,const char *);
extern NCURSES_EXPORT(MENU *) new_menu (ITEM **);
extern NCURSES_EXPORT(Item_Options) item_opts (const ITEM *);
extern NCURSES_EXPORT(Menu_Options) menu_opts (const MENU *);
extern NCURSES_EXPORT(Menu_Hook) item_init (const MENU *);
extern NCURSES_EXPORT(Menu_Hook) item_term (const MENU *);
extern NCURSES_EXPORT(Menu_Hook) menu_init (const MENU *);
extern NCURSES_EXPORT(Menu_Hook) menu_term (const MENU *);
extern NCURSES_EXPORT(WINDOW *) menu_sub (const MENU *);
extern NCURSES_EXPORT(WINDOW *) menu_win (const MENU *);
extern NCURSES_EXPORT(const char *) item_description (const ITEM *);
extern NCURSES_EXPORT(const char *) item_name (const ITEM *);
extern NCURSES_EXPORT(const char *) menu_mark (const MENU *);
extern NCURSES_EXPORT(const char *) menu_request_name (int);
extern NCURSES_EXPORT(char *) menu_pattern (const MENU *);
extern NCURSES_EXPORT(void *) menu_userptr (const MENU *);
extern NCURSES_EXPORT(void *) item_userptr (const ITEM *);
extern NCURSES_EXPORT(chtype) menu_back (const MENU *);
extern NCURSES_EXPORT(chtype) menu_fore (const MENU *);
extern NCURSES_EXPORT(chtype) menu_grey (const MENU *);
extern NCURSES_EXPORT(int) free_item (ITEM *);
extern NCURSES_EXPORT(int) free_menu (MENU *);
extern NCURSES_EXPORT(int) item_count (const MENU *);
extern NCURSES_EXPORT(int) item_index (const ITEM *);
extern NCURSES_EXPORT(int) item_opts_off (ITEM *,Item_Options);
extern NCURSES_EXPORT(int) item_opts_on (ITEM *,Item_Options);
extern NCURSES_EXPORT(int) menu_driver (MENU *,int);
extern NCURSES_EXPORT(int) menu_opts_off (MENU *,Menu_Options);
extern NCURSES_EXPORT(int) menu_opts_on (MENU *,Menu_Options);
extern NCURSES_EXPORT(int) menu_pad (const MENU *);
extern NCURSES_EXPORT(int) pos_menu_cursor (const MENU *);
extern NCURSES_EXPORT(int) post_menu (MENU *);
extern NCURSES_EXPORT(int) scale_menu (const MENU *,int *,int *);
extern NCURSES_EXPORT(int) set_current_item (MENU *menu,ITEM *item);
extern NCURSES_EXPORT(int) set_item_init (MENU *, Menu_Hook);
extern NCURSES_EXPORT(int) set_item_opts (ITEM *,Item_Options);
extern NCURSES_EXPORT(int) set_item_term (MENU *, Menu_Hook);
extern NCURSES_EXPORT(int) set_item_userptr (ITEM *, void *);
extern NCURSES_EXPORT(int) set_item_value (ITEM *,bool);
extern NCURSES_EXPORT(int) set_menu_back (MENU *,chtype);
extern NCURSES_EXPORT(int) set_menu_fore (MENU *,chtype);
extern NCURSES_EXPORT(int) set_menu_format (MENU *,int,int);
extern NCURSES_EXPORT(int) set_menu_grey (MENU *,chtype);
extern NCURSES_EXPORT(int) set_menu_init (MENU *, Menu_Hook);
extern NCURSES_EXPORT(int) set_menu_items (MENU *,ITEM **);
extern NCURSES_EXPORT(int) set_menu_mark (MENU *, const char *);
extern NCURSES_EXPORT(int) set_menu_opts (MENU *,Menu_Options);
extern NCURSES_EXPORT(int) set_menu_pad (MENU *,int);
extern NCURSES_EXPORT(int) set_menu_pattern (MENU *,const char *);
extern NCURSES_EXPORT(int) set_menu_sub (MENU *,WINDOW *);
extern NCURSES_EXPORT(int) set_menu_term (MENU *, Menu_Hook);
extern NCURSES_EXPORT(int) set_menu_userptr (MENU *,void *);
extern NCURSES_EXPORT(int) set_menu_win (MENU *,WINDOW *);
extern NCURSES_EXPORT(int) set_top_row (MENU *,int);
extern NCURSES_EXPORT(int) top_row (const MENU *);
extern NCURSES_EXPORT(int) unpost_menu (MENU *);
extern NCURSES_EXPORT(int) menu_request_by_name (const char *);
extern NCURSES_EXPORT(int) set_menu_spacing (MENU *,int,int,int);
extern NCURSES_EXPORT(int) menu_spacing (const MENU *,int *,int *,int *);
extern NCURSES_EXPORT(bool) item_value (const ITEM *);
extern NCURSES_EXPORT(bool) item_visible (const ITEM *);
extern NCURSES_EXPORT(void) menu_format (const MENU *,int *,int *);
#if NCURSES_SP_FUNCS
extern NCURSES_EXPORT(MENU *) NCURSES_SP_NAME(new_menu) (SCREEN*, ITEM **);
#endif
#ifdef __cplusplus
}
#endif
#endif /* ETI_MENU */
cursesf.h 0000644 00000066311 15201526705 0006401 0 ustar 00 // * This makes emacs happy -*-Mode: C++;-*-
/****************************************************************************
* Copyright (c) 1998-2012,2014 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included *
* in all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
* *
* Except as contained in this notice, the name(s) of the above copyright *
* holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written *
* authorization. *
****************************************************************************/
/****************************************************************************
* Author: Juergen Pfeifer, 1997 *
****************************************************************************/
// $Id: cursesf.h,v 1.32 2014/08/09 22:06:11 Adam.Jiang Exp $
#ifndef NCURSES_CURSESF_H_incl
#define NCURSES_CURSESF_H_incl 1
#include <cursesp.h>
#ifndef __EXT_QNX
#include <string.h>
#endif
extern "C" {
# include <form.h>
}
//
// -------------------------------------------------------------------------
// The abstract base class for buitin and user defined Fieldtypes.
// -------------------------------------------------------------------------
//
class NCURSES_IMPEXP NCursesFormField; // forward declaration
// Class to represent builtin field types as well as C++ written new
// fieldtypes (see classes UserDefineFieldType...
class NCURSES_IMPEXP NCursesFieldType
{
friend class NCursesFormField;
protected:
FIELDTYPE* fieldtype;
inline void OnError(int err) const THROW2(NCursesException const, NCursesFormException) {
if (err!=E_OK)
THROW(new NCursesFormException (err));
}
NCursesFieldType(FIELDTYPE *f) : fieldtype(f) {
}
virtual ~NCursesFieldType() {}
// Set the fields f fieldtype to this one.
virtual void set(NCursesFormField& f) = 0;
public:
NCursesFieldType()
: fieldtype(STATIC_CAST(FIELDTYPE*)(0))
{
}
NCursesFieldType& operator=(const NCursesFieldType& rhs)
{
if (this != &rhs) {
*this = rhs;
}
return *this;
}
NCursesFieldType(const NCursesFieldType& rhs)
: fieldtype(rhs.fieldtype)
{
}
};
//
// -------------------------------------------------------------------------
// The class representing a forms field, wrapping the lowlevel FIELD struct
// -------------------------------------------------------------------------
//
class NCURSES_IMPEXP NCursesFormField
{
friend class NCursesForm;
protected:
FIELD *field; // lowlevel structure
NCursesFieldType* ftype; // Associated field type
// Error handler
inline void OnError (int err) const THROW2(NCursesException const, NCursesFormException) {
if (err != E_OK)
THROW(new NCursesFormException (err));
}
public:
// Create a 'Null' field. Can be used to delimit a field list
NCursesFormField()
: field(STATIC_CAST(FIELD*)(0)),
ftype(STATIC_CAST(NCursesFieldType*)(0))
{
}
// Create a new field
NCursesFormField (int rows,
int ncols,
int first_row = 0,
int first_col = 0,
int offscreen_rows = 0,
int additional_buffers = 0)
: field(0),
ftype(STATIC_CAST(NCursesFieldType*)(0))
{
field = ::new_field(rows, ncols, first_row, first_col,
offscreen_rows, additional_buffers);
if (!field)
OnError(errno);
}
NCursesFormField& operator=(const NCursesFormField& rhs)
{
if (this != &rhs) {
*this = rhs;
}
return *this;
}
NCursesFormField(const NCursesFormField& rhs)
: field(rhs.field), ftype(rhs.ftype)
{
}
virtual ~NCursesFormField ();
// Duplicate the field at a new position
inline NCursesFormField* dup(int first_row, int first_col)
{
NCursesFormField* f = new NCursesFormField();
if (!f)
OnError(E_SYSTEM_ERROR);
else {
f->ftype = ftype;
f->field = ::dup_field(field,first_row,first_col);
if (!f->field)
OnError(errno);
}
return f;
}
// Link the field to a new location
inline NCursesFormField* link(int first_row, int first_col) {
NCursesFormField* f = new NCursesFormField();
if (!f)
OnError(E_SYSTEM_ERROR);
else {
f->ftype = ftype;
f->field = ::link_field(field,first_row,first_col);
if (!f->field)
OnError(errno);
}
return f;
}
// Get the lowlevel field representation
inline FIELD* get_field() const {
return field;
}
// Retrieve info about the field
inline void info(int& rows, int& ncols,
int& first_row, int& first_col,
int& offscreen_rows, int& additional_buffers) const {
OnError(::field_info(field, &rows, &ncols,
&first_row, &first_col,
&offscreen_rows, &additional_buffers));
}
// Retrieve info about the fields dynamic properties.
inline void dynamic_info(int& dynamic_rows, int& dynamic_cols,
int& max_growth) const {
OnError(::dynamic_field_info(field, &dynamic_rows, &dynamic_cols,
&max_growth));
}
// For a dynamic field you may set the maximum growth limit.
// A zero means unlimited growth.
inline void set_maximum_growth(int growth = 0) {
OnError(::set_max_field(field,growth));
}
// Move the field to a new position
inline void move(int row, int col) {
OnError(::move_field(field,row,col));
}
// Mark the field to start a new page
inline void new_page(bool pageFlag = FALSE) {
OnError(::set_new_page(field,pageFlag));
}
// Retrieve whether or not the field starts a new page.
inline bool is_new_page() const {
return ::new_page(field);
}
// Set the justification for the field
inline void set_justification(int just) {
OnError(::set_field_just(field,just));
}
// Retrieve the fields justification
inline int justification() const {
return ::field_just(field);
}
// Set the foreground attribute for the field
inline void set_foreground(chtype foreground) {
OnError(::set_field_fore(field,foreground));
}
// Retrieve the fields foreground attribute
inline chtype fore() const {
return ::field_fore(field);
}
// Set the background attribute for the field
inline void set_background(chtype background) {
OnError(::set_field_back(field,background));
}
// Retrieve the fields background attribute
inline chtype back() const {
return ::field_back(field);
}
// Set the padding character for the field
inline void set_pad_character(int padding) {
OnError(::set_field_pad(field, padding));
}
// Retrieve the fields padding character
inline int pad() const {
return ::field_pad(field);
}
// Switch on the fields options
inline void options_on (Field_Options opts) {
OnError (::field_opts_on (field, opts));
}
// Switch off the fields options
inline void options_off (Field_Options opts) {
OnError (::field_opts_off (field, opts));
}
// Retrieve the fields options
inline Field_Options options () const {
return ::field_opts (field);
}
// Set the fields options
inline void set_options (Field_Options opts) {
OnError (::set_field_opts (field, opts));
}
// Mark the field as changed
inline void set_changed(bool changeFlag = TRUE) {
OnError(::set_field_status(field,changeFlag));
}
// Test whether or not the field is marked as changed
inline bool changed() const {
return ::field_status(field);
}
// Return the index of the field in the field array of a form
// or -1 if the field is not associated to a form
inline int (index)() const {
return ::field_index(field);
}
// Store a value in a fields buffer. The default buffer is nr. 0
inline void set_value(const char *val, int buffer = 0) {
OnError(::set_field_buffer(field,buffer,val));
}
// Retrieve the value of a fields buffer. The default buffer is nr. 0
inline char* value(int buffer = 0) const {
return ::field_buffer(field,buffer);
}
// Set the validation type of the field.
inline void set_fieldtype(NCursesFieldType& f) {
ftype = &f;
f.set(*this); // A good friend may do that...
}
// Retrieve the validation type of the field.
inline NCursesFieldType* fieldtype() const {
return ftype;
}
};
// This are the built-in hook functions in this C++ binding. In C++ we use
// virtual member functions (see below On_..._Init and On_..._Termination)
// to provide this functionality in an object oriented manner.
extern "C" {
void _nc_xx_frm_init(FORM *);
void _nc_xx_frm_term(FORM *);
void _nc_xx_fld_init(FORM *);
void _nc_xx_fld_term(FORM *);
}
//
// -------------------------------------------------------------------------
// The class representing a form, wrapping the lowlevel FORM struct
// -------------------------------------------------------------------------
//
class NCURSES_IMPEXP NCursesForm : public NCursesPanel
{
protected:
FORM* form; // the lowlevel structure
private:
NCursesWindow* sub; // the subwindow object
bool b_sub_owner; // is this our own subwindow?
bool b_framed; // has the form a border?
bool b_autoDelete; // Delete fields when deleting form?
NCursesFormField** my_fields; // The array of fields for this form
// This structure is used for the form's user data field to link the
// FORM* to the C++ object and to provide extra space for a user pointer.
typedef struct {
void* m_user; // the pointer for the user's data
const NCursesForm* m_back; // backward pointer to C++ object
const FORM* m_owner;
} UserHook;
// Get the backward pointer to the C++ object from a FORM
static inline NCursesForm* getHook(const FORM *f) {
UserHook* hook = reinterpret_cast<UserHook*>(::form_userptr(f));
assert(hook != 0 && hook->m_owner==f);
return const_cast<NCursesForm*>(hook->m_back);
}
friend void _nc_xx_frm_init(FORM *);
friend void _nc_xx_frm_term(FORM *);
friend void _nc_xx_fld_init(FORM *);
friend void _nc_xx_fld_term(FORM *);
// Calculate FIELD* array for the menu
FIELD** mapFields(NCursesFormField* nfields[]);
protected:
// internal routines
inline void set_user(void *user) {
UserHook* uptr = reinterpret_cast<UserHook*>(::form_userptr (form));
assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==form);
uptr->m_user = user;
}
inline void *get_user() {
UserHook* uptr = reinterpret_cast<UserHook*>(::form_userptr (form));
assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==form);
return uptr->m_user;
}
void InitForm (NCursesFormField* Fields[],
bool with_frame,
bool autoDeleteFields);
inline void OnError (int err) const THROW2(NCursesException const, NCursesFormException) {
if (err != E_OK)
THROW(new NCursesFormException (err));
}
// this wraps the form_driver call.
virtual int driver (int c) ;
// 'Internal' constructor, builds an object without association to a
// field array.
NCursesForm( int nlines,
int ncols,
int begin_y = 0,
int begin_x = 0)
: NCursesPanel(nlines, ncols, begin_y, begin_x),
form (STATIC_CAST(FORM*)(0)),
sub(0),
b_sub_owner(0),
b_framed(0),
b_autoDelete(0),
my_fields(0)
{
}
public:
// Create form for the default panel.
NCursesForm (NCursesFormField* Fields[],
bool with_frame=FALSE, // reserve space for a frame?
bool autoDelete_Fields=FALSE) // do automatic cleanup?
: NCursesPanel(),
form(0),
sub(0),
b_sub_owner(0),
b_framed(0),
b_autoDelete(0),
my_fields(0)
{
InitForm(Fields, with_frame, autoDelete_Fields);
}
// Create a form in a panel with the given position and size.
NCursesForm (NCursesFormField* Fields[],
int nlines,
int ncols,
int begin_y,
int begin_x,
bool with_frame=FALSE, // reserve space for a frame?
bool autoDelete_Fields=FALSE) // do automatic cleanup?
: NCursesPanel(nlines, ncols, begin_y, begin_x),
form(0),
sub(0),
b_sub_owner(0),
b_framed(0),
b_autoDelete(0),
my_fields(0)
{
InitForm(Fields, with_frame, autoDelete_Fields);
}
NCursesForm& operator=(const NCursesForm& rhs)
{
if (this != &rhs) {
*this = rhs;
NCursesPanel::operator=(rhs);
}
return *this;
}
NCursesForm(const NCursesForm& rhs)
: NCursesPanel(rhs),
form(rhs.form),
sub(rhs.sub),
b_sub_owner(rhs.b_sub_owner),
b_framed(rhs.b_framed),
b_autoDelete(rhs.b_autoDelete),
my_fields(rhs.my_fields)
{
}
virtual ~NCursesForm();
// Set the default attributes for the form
virtual void setDefaultAttributes();
// Retrieve current field of the form.
inline NCursesFormField* current_field() const {
return my_fields[::field_index(::current_field(form))];
}
// Set the forms subwindow
void setSubWindow(NCursesWindow& sub);
// Set these fields for the form
inline void setFields(NCursesFormField* Fields[]) {
OnError(::set_form_fields(form,mapFields(Fields)));
}
// Remove the form from the screen
inline void unpost (void) {
OnError (::unpost_form (form));
}
// Post the form to the screen if flag is true, unpost it otherwise
inline void post(bool flag = TRUE) {
OnError (flag ? ::post_form(form) : ::unpost_form (form));
}
// Decorations
inline void frame(const char *title=NULL, const char* btitle=NULL) {
if (b_framed)
NCursesPanel::frame(title,btitle);
else
OnError(E_SYSTEM_ERROR);
}
inline void boldframe(const char *title=NULL, const char* btitle=NULL) {
if (b_framed)
NCursesPanel::boldframe(title,btitle);
else
OnError(E_SYSTEM_ERROR);
}
inline void label(const char *topLabel, const char *bottomLabel) {
if (b_framed)
NCursesPanel::label(topLabel,bottomLabel);
else
OnError(E_SYSTEM_ERROR);
}
// -----
// Hooks
// -----
// Called after the form gets repositioned in its window.
// This is especially true if the form is posted.
virtual void On_Form_Init();
// Called before the form gets repositioned in its window.
// This is especially true if the form is unposted.
virtual void On_Form_Termination();
// Called after the field became the current field
virtual void On_Field_Init(NCursesFormField& field);
// Called before this field is left as current field.
virtual void On_Field_Termination(NCursesFormField& field);
// Calculate required window size for the form.
void scale(int& rows, int& ncols) const {
OnError(::scale_form(form,&rows,&ncols));
}
// Retrieve number of fields in the form.
int count() const {
return ::field_count(form);
}
// Make the page the current page of the form.
void set_page(int pageNum) {
OnError(::set_form_page(form, pageNum));
}
// Retrieve current page number
int page() const {
return ::form_page(form);
}
// Switch on the forms options
inline void options_on (Form_Options opts) {
OnError (::form_opts_on (form, opts));
}
// Switch off the forms options
inline void options_off (Form_Options opts) {
OnError (::form_opts_off (form, opts));
}
// Retrieve the forms options
inline Form_Options options () const {
return ::form_opts (form);
}
// Set the forms options
inline void set_options (Form_Options opts) {
OnError (::set_form_opts (form, opts));
}
// Are there more data in the current field after the data shown
inline bool data_ahead() const {
return ::data_ahead(form);
}
// Are there more data in the current field before the data shown
inline bool data_behind() const {
return ::data_behind(form);
}
// Position the cursor to the current field
inline void position_cursor () {
OnError (::pos_form_cursor (form));
}
// Set the current field
inline void set_current(NCursesFormField& F) {
OnError (::set_current_field(form, F.field));
}
// Provide a default key virtualization. Translate the keyboard
// code c into a form request code.
// The default implementation provides a hopefully straightforward
// mapping for the most common keystrokes and form requests.
virtual int virtualize(int c);
// Operators
inline NCursesFormField* operator[](int i) const {
if ( (i < 0) || (i >= ::field_count (form)) )
OnError (E_BAD_ARGUMENT);
return my_fields[i];
}
// Perform the menu's operation
// Return the field where you left the form.
virtual NCursesFormField* operator()(void);
// Exception handlers. The default is a Beep.
virtual void On_Request_Denied(int c) const;
virtual void On_Invalid_Field(int c) const;
virtual void On_Unknown_Command(int c) const;
};
//
// -------------------------------------------------------------------------
// This is the typical C++ typesafe way to allow to attach
// user data to a field of a form. Its assumed that the user
// data belongs to some class T. Use T as template argument
// to create a UserField.
// -------------------------------------------------------------------------
template<class T> class NCURSES_IMPEXP NCursesUserField : public NCursesFormField
{
public:
NCursesUserField (int rows,
int ncols,
int first_row = 0,
int first_col = 0,
const T* p_UserData = STATIC_CAST(T*)(0),
int offscreen_rows = 0,
int additional_buffers = 0)
: NCursesFormField (rows, ncols,
first_row, first_col,
offscreen_rows, additional_buffers) {
if (field)
OnError(::set_field_userptr(field, STATIC_CAST(void *)(p_UserData)));
}
virtual ~NCursesUserField() {};
inline const T* UserData (void) const {
return reinterpret_cast<const T*>(::field_userptr (field));
}
inline virtual void setUserData(const T* p_UserData) {
if (field)
OnError (::set_field_userptr (field, STATIC_CAST(void *)(p_UserData)));
}
};
//
// -------------------------------------------------------------------------
// The same mechanism is used to attach user data to a form
// -------------------------------------------------------------------------
//
template<class T> class NCURSES_IMPEXP NCursesUserForm : public NCursesForm
{
protected:
// 'Internal' constructor, builds an object without association to a
// field array.
NCursesUserForm( int nlines,
int ncols,
int begin_y = 0,
int begin_x = 0,
const T* p_UserData = STATIC_CAST(T*)(0))
: NCursesForm(nlines,ncols,begin_y,begin_x) {
if (form)
set_user (const_cast<void *>(reinterpret_cast<const void*>
(p_UserData)));
}
public:
NCursesUserForm (NCursesFormField* Fields[],
const T* p_UserData = STATIC_CAST(T*)(0),
bool with_frame=FALSE,
bool autoDelete_Fields=FALSE)
: NCursesForm (Fields, with_frame, autoDelete_Fields) {
if (form)
set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
};
NCursesUserForm (NCursesFormField* Fields[],
int nlines,
int ncols,
int begin_y = 0,
int begin_x = 0,
const T* p_UserData = STATIC_CAST(T*)(0),
bool with_frame=FALSE,
bool autoDelete_Fields=FALSE)
: NCursesForm (Fields, nlines, ncols, begin_y, begin_x,
with_frame, autoDelete_Fields) {
if (form)
set_user (const_cast<void *>(reinterpret_cast<const void*>
(p_UserData)));
};
virtual ~NCursesUserForm() {
};
inline T* UserData (void) {
return reinterpret_cast<T*>(get_user ());
};
inline virtual void setUserData (const T* p_UserData) {
if (form)
set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
}
};
//
// -------------------------------------------------------------------------
// Builtin Fieldtypes
// -------------------------------------------------------------------------
//
class NCURSES_IMPEXP Alpha_Field : public NCursesFieldType
{
private:
int min_field_width;
void set(NCursesFormField& f) {
OnError(::set_field_type(f.get_field(),fieldtype,min_field_width));
}
public:
Alpha_Field(int width)
: NCursesFieldType(TYPE_ALPHA),
min_field_width(width) {
}
};
class NCURSES_IMPEXP Alphanumeric_Field : public NCursesFieldType
{
private:
int min_field_width;
void set(NCursesFormField& f) {
OnError(::set_field_type(f.get_field(),fieldtype,min_field_width));
}
public:
Alphanumeric_Field(int width)
: NCursesFieldType(TYPE_ALNUM),
min_field_width(width) {
}
};
class NCURSES_IMPEXP Integer_Field : public NCursesFieldType
{
private:
int precision;
long lower_limit, upper_limit;
void set(NCursesFormField& f) {
OnError(::set_field_type(f.get_field(),fieldtype,
precision,lower_limit,upper_limit));
}
public:
Integer_Field(int prec, long low=0L, long high=0L)
: NCursesFieldType(TYPE_INTEGER),
precision(prec), lower_limit(low), upper_limit(high) {
}
};
class NCURSES_IMPEXP Numeric_Field : public NCursesFieldType
{
private:
int precision;
double lower_limit, upper_limit;
void set(NCursesFormField& f) {
OnError(::set_field_type(f.get_field(),fieldtype,
precision,lower_limit,upper_limit));
}
public:
Numeric_Field(int prec, double low=0.0, double high=0.0)
: NCursesFieldType(TYPE_NUMERIC),
precision(prec), lower_limit(low), upper_limit(high) {
}
};
class NCURSES_IMPEXP Regular_Expression_Field : public NCursesFieldType
{
private:
char* regex;
void set(NCursesFormField& f) {
OnError(::set_field_type(f.get_field(),fieldtype,regex));
}
void copy_regex(const char *source)
{
regex = new char[1 + ::strlen(source)];
(::strcpy)(regex, source);
}
public:
Regular_Expression_Field(const char *expr)
: NCursesFieldType(TYPE_REGEXP),
regex(NULL)
{
copy_regex(expr);
}
Regular_Expression_Field& operator=(const Regular_Expression_Field& rhs)
{
if (this != &rhs) {
*this = rhs;
copy_regex(rhs.regex);
NCursesFieldType::operator=(rhs);
}
return *this;
}
Regular_Expression_Field(const Regular_Expression_Field& rhs)
: NCursesFieldType(rhs),
regex(NULL)
{
copy_regex(rhs.regex);
}
~Regular_Expression_Field() {
delete[] regex;
}
};
class NCURSES_IMPEXP Enumeration_Field : public NCursesFieldType
{
private:
const char** list;
int case_sensitive;
int non_unique_matches;
void set(NCursesFormField& f) {
OnError(::set_field_type(f.get_field(),fieldtype,
list,case_sensitive,non_unique_matches));
}
public:
Enumeration_Field(const char* enums[],
bool case_sens=FALSE,
bool non_unique=FALSE)
: NCursesFieldType(TYPE_ENUM),
list(enums),
case_sensitive(case_sens ? -1 : 0),
non_unique_matches(non_unique ? -1 : 0) {
}
Enumeration_Field& operator=(const Enumeration_Field& rhs)
{
if (this != &rhs) {
*this = rhs;
NCursesFieldType::operator=(rhs);
}
return *this;
}
Enumeration_Field(const Enumeration_Field& rhs)
: NCursesFieldType(rhs),
list(rhs.list),
case_sensitive(rhs.case_sensitive),
non_unique_matches(rhs.non_unique_matches)
{
}
};
class NCURSES_IMPEXP IPV4_Address_Field : public NCursesFieldType
{
private:
void set(NCursesFormField& f) {
OnError(::set_field_type(f.get_field(),fieldtype));
}
public:
IPV4_Address_Field() : NCursesFieldType(TYPE_IPV4) {
}
};
extern "C" {
bool _nc_xx_fld_fcheck(FIELD *, const void*);
bool _nc_xx_fld_ccheck(int c, const void *);
void* _nc_xx_fld_makearg(va_list*);
}
//
// -------------------------------------------------------------------------
// Abstract base class for User-Defined Fieldtypes
// -------------------------------------------------------------------------
//
class NCURSES_IMPEXP UserDefinedFieldType : public NCursesFieldType
{
friend class UDF_Init; // Internal helper to set up statics
private:
// For all C++ defined fieldtypes we need only one generic lowlevel
// FIELDTYPE* element.
static FIELDTYPE* generic_fieldtype;
protected:
// This are the functions required by the low level libforms functions
// to construct a fieldtype.
friend bool _nc_xx_fld_fcheck(FIELD *, const void*);
friend bool _nc_xx_fld_ccheck(int c, const void *);
friend void* _nc_xx_fld_makearg(va_list*);
void set(NCursesFormField& f) {
OnError(::set_field_type(f.get_field(),fieldtype,&f));
}
protected:
// Redefine this function to do a field validation. The argument
// is a reference to the field you should validate.
virtual bool field_check(NCursesFormField& f) = 0;
// Redefine this function to do a character validation. The argument
// is the character to be validated.
virtual bool char_check (int c) = 0;
public:
UserDefinedFieldType() : NCursesFieldType(generic_fieldtype) {
}
};
extern "C" {
bool _nc_xx_next_choice(FIELD*, const void *);
bool _nc_xx_prev_choice(FIELD*, const void *);
}
//
// -------------------------------------------------------------------------
// Abstract base class for User-Defined Fieldtypes with Choice functions
// -------------------------------------------------------------------------
//
class NCURSES_IMPEXP UserDefinedFieldType_With_Choice : public UserDefinedFieldType
{
friend class UDF_Init; // Internal helper to set up statics
private:
// For all C++ defined fieldtypes with choice functions we need only one
// generic lowlevel FIELDTYPE* element.
static FIELDTYPE* generic_fieldtype_with_choice;
// This are the functions required by the low level libforms functions
// to construct a fieldtype with choice functions.
friend bool _nc_xx_next_choice(FIELD*, const void *);
friend bool _nc_xx_prev_choice(FIELD*, const void *);
protected:
// Redefine this function to do the retrieval of the next choice value.
// The argument is a reference to the field tobe examined.
virtual bool next (NCursesFormField& f) = 0;
// Redefine this function to do the retrieval of the previous choice value.
// The argument is a reference to the field tobe examined.
virtual bool previous(NCursesFormField& f) = 0;
public:
UserDefinedFieldType_With_Choice() {
fieldtype = generic_fieldtype_with_choice;
}
};
#endif /* NCURSES_CURSESF_H_incl */
unctrl.h 0000644 00000006033 15201526705 0006231 0 ustar 00 /****************************************************************************
* Copyright (c) 1998-2008,2009 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included *
* in all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
* *
* Except as contained in this notice, the name(s) of the above copyright *
* holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written *
* authorization. *
****************************************************************************/
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
/*
* unctrl.h
*
* Display a printable version of a control character.
* Control characters are displayed in caret notation (^x), DELETE is displayed
* as ^?. Printable characters are displayed as is.
*/
/* $Id: unctrl.h.in,v 1.11 2009/04/18 21:00:52 tom Exp $ */
#ifndef NCURSES_UNCTRL_H_incl
#define NCURSES_UNCTRL_H_incl 1
#undef NCURSES_VERSION
#define NCURSES_VERSION "6.1"
#ifdef __cplusplus
extern "C" {
#endif
#include <curses.h>
#undef unctrl
NCURSES_EXPORT(NCURSES_CONST char *) unctrl (chtype);
#if 1
NCURSES_EXPORT(NCURSES_CONST char *) NCURSES_SP_NAME(unctrl) (SCREEN*, chtype);
#endif
#ifdef __cplusplus
}
#endif
#endif /* NCURSES_UNCTRL_H_incl */
term.h 0000644 00000120346 15201526705 0005675 0 ustar 00 /****************************************************************************
* Copyright (c) 1998-2013,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included *
* in all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
* *
* Except as contained in this notice, the name(s) of the above copyright *
* holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written *
* authorization. *
****************************************************************************/
/****************************************************************************/
/* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 */
/* and: Eric S. Raymond <esr@snark.thyrsus.com> */
/* and: Thomas E. Dickey 1995-on */
/****************************************************************************/
/* $Id: MKterm.h.awk.in,v 1.67 2017/04/06 00:19:26 tom Exp $ */
/*
** term.h -- Definition of struct term
*/
#ifndef NCURSES_TERM_H_incl
#define NCURSES_TERM_H_incl 1
#undef NCURSES_VERSION
#define NCURSES_VERSION "6.1"
#include <ncurses_dll.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Make this file self-contained by providing defaults for the HAVE_TERMIO[S]_H
* definition (based on the system for which this was configured).
*/
#undef NCURSES_CONST
#define NCURSES_CONST const
#undef NCURSES_SBOOL
#define NCURSES_SBOOL char
#undef NCURSES_USE_DATABASE
#define NCURSES_USE_DATABASE 1
#undef NCURSES_USE_TERMCAP
#define NCURSES_USE_TERMCAP 0
#undef NCURSES_XNAMES
#define NCURSES_XNAMES 1
/* We will use these symbols to hide differences between
* termios/termio/sgttyb interfaces.
*/
#undef TTY
#undef SET_TTY
#undef GET_TTY
/* Assume POSIX termio if we have the header and function */
/* #if HAVE_TERMIOS_H && HAVE_TCGETATTR */
#if 1 && 1
#undef TERMIOS
#define TERMIOS 1
#include <termios.h>
#define TTY struct termios
#else /* !HAVE_TERMIOS_H */
/* #if HAVE_TERMIO_H */
#if 1
#undef TERMIOS
#define TERMIOS 1
#include <termio.h>
#define TTY struct termio
#else /* !HAVE_TERMIO_H */
#if __MINGW32__
# include <ncurses_mingw.h>
# define TTY struct termios
#else
#undef TERMIOS
#include <sgtty.h>
#include <sys/ioctl.h>
#define TTY struct sgttyb
#endif /* MINGW32 */
#endif /* HAVE_TERMIO_H */
#endif /* HAVE_TERMIOS_H */
#ifdef TERMIOS
#define GET_TTY(fd, buf) tcgetattr(fd, buf)
#define SET_TTY(fd, buf) tcsetattr(fd, TCSADRAIN, buf)
#else
#define GET_TTY(fd, buf) gtty(fd, buf)
#define SET_TTY(fd, buf) stty(fd, buf)
#endif
#define NAMESIZE 256
/* The cast works because TERMTYPE is the first data in TERMINAL */
#define CUR ((TERMTYPE *)(cur_term))->
#define auto_left_margin CUR Booleans[0]
#define auto_right_margin CUR Booleans[1]
#define no_esc_ctlc CUR Booleans[2]
#define ceol_standout_glitch CUR Booleans[3]
#define eat_newline_glitch CUR Booleans[4]
#define erase_overstrike CUR Booleans[5]
#define generic_type CUR Booleans[6]
#define hard_copy CUR Booleans[7]
#define has_meta_key CUR Booleans[8]
#define has_status_line CUR Booleans[9]
#define insert_null_glitch CUR Booleans[10]
#define memory_above CUR Booleans[11]
#define memory_below CUR Booleans[12]
#define move_insert_mode CUR Booleans[13]
#define move_standout_mode CUR Booleans[14]
#define over_strike CUR Booleans[15]
#define status_line_esc_ok CUR Booleans[16]
#define dest_tabs_magic_smso CUR Booleans[17]
#define tilde_glitch CUR Booleans[18]
#define transparent_underline CUR Booleans[19]
#define xon_xoff CUR Booleans[20]
#define needs_xon_xoff CUR Booleans[21]
#define prtr_silent CUR Booleans[22]
#define hard_cursor CUR Booleans[23]
#define non_rev_rmcup CUR Booleans[24]
#define no_pad_char CUR Booleans[25]
#define non_dest_scroll_region CUR Booleans[26]
#define can_change CUR Booleans[27]
#define back_color_erase CUR Booleans[28]
#define hue_lightness_saturation CUR Booleans[29]
#define col_addr_glitch CUR Booleans[30]
#define cr_cancels_micro_mode CUR Booleans[31]
#define has_print_wheel CUR Booleans[32]
#define row_addr_glitch CUR Booleans[33]
#define semi_auto_right_margin CUR Booleans[34]
#define cpi_changes_res CUR Booleans[35]
#define lpi_changes_res CUR Booleans[36]
#define columns CUR Numbers[0]
#define init_tabs CUR Numbers[1]
#define lines CUR Numbers[2]
#define lines_of_memory CUR Numbers[3]
#define magic_cookie_glitch CUR Numbers[4]
#define padding_baud_rate CUR Numbers[5]
#define virtual_terminal CUR Numbers[6]
#define width_status_line CUR Numbers[7]
#define num_labels CUR Numbers[8]
#define label_height CUR Numbers[9]
#define label_width CUR Numbers[10]
#define max_attributes CUR Numbers[11]
#define maximum_windows CUR Numbers[12]
#define max_colors CUR Numbers[13]
#define max_pairs CUR Numbers[14]
#define no_color_video CUR Numbers[15]
#define buffer_capacity CUR Numbers[16]
#define dot_vert_spacing CUR Numbers[17]
#define dot_horz_spacing CUR Numbers[18]
#define max_micro_address CUR Numbers[19]
#define max_micro_jump CUR Numbers[20]
#define micro_col_size CUR Numbers[21]
#define micro_line_size CUR Numbers[22]
#define number_of_pins CUR Numbers[23]
#define output_res_char CUR Numbers[24]
#define output_res_line CUR Numbers[25]
#define output_res_horz_inch CUR Numbers[26]
#define output_res_vert_inch CUR Numbers[27]
#define print_rate CUR Numbers[28]
#define wide_char_size CUR Numbers[29]
#define buttons CUR Numbers[30]
#define bit_image_entwining CUR Numbers[31]
#define bit_image_type CUR Numbers[32]
#define back_tab CUR Strings[0]
#define bell CUR Strings[1]
#define carriage_return CUR Strings[2]
#define change_scroll_region CUR Strings[3]
#define clear_all_tabs CUR Strings[4]
#define clear_screen CUR Strings[5]
#define clr_eol CUR Strings[6]
#define clr_eos CUR Strings[7]
#define column_address CUR Strings[8]
#define command_character CUR Strings[9]
#define cursor_address CUR Strings[10]
#define cursor_down CUR Strings[11]
#define cursor_home CUR Strings[12]
#define cursor_invisible CUR Strings[13]
#define cursor_left CUR Strings[14]
#define cursor_mem_address CUR Strings[15]
#define cursor_normal CUR Strings[16]
#define cursor_right CUR Strings[17]
#define cursor_to_ll CUR Strings[18]
#define cursor_up CUR Strings[19]
#define cursor_visible CUR Strings[20]
#define delete_character CUR Strings[21]
#define delete_line CUR Strings[22]
#define dis_status_line CUR Strings[23]
#define down_half_line CUR Strings[24]
#define enter_alt_charset_mode CUR Strings[25]
#define enter_blink_mode CUR Strings[26]
#define enter_bold_mode CUR Strings[27]
#define enter_ca_mode CUR Strings[28]
#define enter_delete_mode CUR Strings[29]
#define enter_dim_mode CUR Strings[30]
#define enter_insert_mode CUR Strings[31]
#define enter_secure_mode CUR Strings[32]
#define enter_protected_mode CUR Strings[33]
#define enter_reverse_mode CUR Strings[34]
#define enter_standout_mode CUR Strings[35]
#define enter_underline_mode CUR Strings[36]
#define erase_chars CUR Strings[37]
#define exit_alt_charset_mode CUR Strings[38]
#define exit_attribute_mode CUR Strings[39]
#define exit_ca_mode CUR Strings[40]
#define exit_delete_mode CUR Strings[41]
#define exit_insert_mode CUR Strings[42]
#define exit_standout_mode CUR Strings[43]
#define exit_underline_mode CUR Strings[44]
#define flash_screen CUR Strings[45]
#define form_feed CUR Strings[46]
#define from_status_line CUR Strings[47]
#define init_1string CUR Strings[48]
#define init_2string CUR Strings[49]
#define init_3string CUR Strings[50]
#define init_file CUR Strings[51]
#define insert_character CUR Strings[52]
#define insert_line CUR Strings[53]
#define insert_padding CUR Strings[54]
#define key_backspace CUR Strings[55]
#define key_catab CUR Strings[56]
#define key_clear CUR Strings[57]
#define key_ctab CUR Strings[58]
#define key_dc CUR Strings[59]
#define key_dl CUR Strings[60]
#define key_down CUR Strings[61]
#define key_eic CUR Strings[62]
#define key_eol CUR Strings[63]
#define key_eos CUR Strings[64]
#define key_f0 CUR Strings[65]
#define key_f1 CUR Strings[66]
#define key_f10 CUR Strings[67]
#define key_f2 CUR Strings[68]
#define key_f3 CUR Strings[69]
#define key_f4 CUR Strings[70]
#define key_f5 CUR Strings[71]
#define key_f6 CUR Strings[72]
#define key_f7 CUR Strings[73]
#define key_f8 CUR Strings[74]
#define key_f9 CUR Strings[75]
#define key_home CUR Strings[76]
#define key_ic CUR Strings[77]
#define key_il CUR Strings[78]
#define key_left CUR Strings[79]
#define key_ll CUR Strings[80]
#define key_npage CUR Strings[81]
#define key_ppage CUR Strings[82]
#define key_right CUR Strings[83]
#define key_sf CUR Strings[84]
#define key_sr CUR Strings[85]
#define key_stab CUR Strings[86]
#define key_up CUR Strings[87]
#define keypad_local CUR Strings[88]
#define keypad_xmit CUR Strings[89]
#define lab_f0 CUR Strings[90]
#define lab_f1 CUR Strings[91]
#define lab_f10 CUR Strings[92]
#define lab_f2 CUR Strings[93]
#define lab_f3 CUR Strings[94]
#define lab_f4 CUR Strings[95]
#define lab_f5 CUR Strings[96]
#define lab_f6 CUR Strings[97]
#define lab_f7 CUR Strings[98]
#define lab_f8 CUR Strings[99]
#define lab_f9 CUR Strings[100]
#define meta_off CUR Strings[101]
#define meta_on CUR Strings[102]
#define newline CUR Strings[103]
#define pad_char CUR Strings[104]
#define parm_dch CUR Strings[105]
#define parm_delete_line CUR Strings[106]
#define parm_down_cursor CUR Strings[107]
#define parm_ich CUR Strings[108]
#define parm_index CUR Strings[109]
#define parm_insert_line CUR Strings[110]
#define parm_left_cursor CUR Strings[111]
#define parm_right_cursor CUR Strings[112]
#define parm_rindex CUR Strings[113]
#define parm_up_cursor CUR Strings[114]
#define pkey_key CUR Strings[115]
#define pkey_local CUR Strings[116]
#define pkey_xmit CUR Strings[117]
#define print_screen CUR Strings[118]
#define prtr_off CUR Strings[119]
#define prtr_on CUR Strings[120]
#define repeat_char CUR Strings[121]
#define reset_1string CUR Strings[122]
#define reset_2string CUR Strings[123]
#define reset_3string CUR Strings[124]
#define reset_file CUR Strings[125]
#define restore_cursor CUR Strings[126]
#define row_address CUR Strings[127]
#define save_cursor CUR Strings[128]
#define scroll_forward CUR Strings[129]
#define scroll_reverse CUR Strings[130]
#define set_attributes CUR Strings[131]
#define set_tab CUR Strings[132]
#define set_window CUR Strings[133]
#define tab CUR Strings[134]
#define to_status_line CUR Strings[135]
#define underline_char CUR Strings[136]
#define up_half_line CUR Strings[137]
#define init_prog CUR Strings[138]
#define key_a1 CUR Strings[139]
#define key_a3 CUR Strings[140]
#define key_b2 CUR Strings[141]
#define key_c1 CUR Strings[142]
#define key_c3 CUR Strings[143]
#define prtr_non CUR Strings[144]
#define char_padding CUR Strings[145]
#define acs_chars CUR Strings[146]
#define plab_norm CUR Strings[147]
#define key_btab CUR Strings[148]
#define enter_xon_mode CUR Strings[149]
#define exit_xon_mode CUR Strings[150]
#define enter_am_mode CUR Strings[151]
#define exit_am_mode CUR Strings[152]
#define xon_character CUR Strings[153]
#define xoff_character CUR Strings[154]
#define ena_acs CUR Strings[155]
#define label_on CUR Strings[156]
#define label_off CUR Strings[157]
#define key_beg CUR Strings[158]
#define key_cancel CUR Strings[159]
#define key_close CUR Strings[160]
#define key_command CUR Strings[161]
#define key_copy CUR Strings[162]
#define key_create CUR Strings[163]
#define key_end CUR Strings[164]
#define key_enter CUR Strings[165]
#define key_exit CUR Strings[166]
#define key_find CUR Strings[167]
#define key_help CUR Strings[168]
#define key_mark CUR Strings[169]
#define key_message CUR Strings[170]
#define key_move CUR Strings[171]
#define key_next CUR Strings[172]
#define key_open CUR Strings[173]
#define key_options CUR Strings[174]
#define key_previous CUR Strings[175]
#define key_print CUR Strings[176]
#define key_redo CUR Strings[177]
#define key_reference CUR Strings[178]
#define key_refresh CUR Strings[179]
#define key_replace CUR Strings[180]
#define key_restart CUR Strings[181]
#define key_resume CUR Strings[182]
#define key_save CUR Strings[183]
#define key_suspend CUR Strings[184]
#define key_undo CUR Strings[185]
#define key_sbeg CUR Strings[186]
#define key_scancel CUR Strings[187]
#define key_scommand CUR Strings[188]
#define key_scopy CUR Strings[189]
#define key_screate CUR Strings[190]
#define key_sdc CUR Strings[191]
#define key_sdl CUR Strings[192]
#define key_select CUR Strings[193]
#define key_send CUR Strings[194]
#define key_seol CUR Strings[195]
#define key_sexit CUR Strings[196]
#define key_sfind CUR Strings[197]
#define key_shelp CUR Strings[198]
#define key_shome CUR Strings[199]
#define key_sic CUR Strings[200]
#define key_sleft CUR Strings[201]
#define key_smessage CUR Strings[202]
#define key_smove CUR Strings[203]
#define key_snext CUR Strings[204]
#define key_soptions CUR Strings[205]
#define key_sprevious CUR Strings[206]
#define key_sprint CUR Strings[207]
#define key_sredo CUR Strings[208]
#define key_sreplace CUR Strings[209]
#define key_sright CUR Strings[210]
#define key_srsume CUR Strings[211]
#define key_ssave CUR Strings[212]
#define key_ssuspend CUR Strings[213]
#define key_sundo CUR Strings[214]
#define req_for_input CUR Strings[215]
#define key_f11 CUR Strings[216]
#define key_f12 CUR Strings[217]
#define key_f13 CUR Strings[218]
#define key_f14 CUR Strings[219]
#define key_f15 CUR Strings[220]
#define key_f16 CUR Strings[221]
#define key_f17 CUR Strings[222]
#define key_f18 CUR Strings[223]
#define key_f19 CUR Strings[224]
#define key_f20 CUR Strings[225]
#define key_f21 CUR Strings[226]
#define key_f22 CUR Strings[227]
#define key_f23 CUR Strings[228]
#define key_f24 CUR Strings[229]
#define key_f25 CUR Strings[230]
#define key_f26 CUR Strings[231]
#define key_f27 CUR Strings[232]
#define key_f28 CUR Strings[233]
#define key_f29 CUR Strings[234]
#define key_f30 CUR Strings[235]
#define key_f31 CUR Strings[236]
#define key_f32 CUR Strings[237]
#define key_f33 CUR Strings[238]
#define key_f34 CUR Strings[239]
#define key_f35 CUR Strings[240]
#define key_f36 CUR Strings[241]
#define key_f37 CUR Strings[242]
#define key_f38 CUR Strings[243]
#define key_f39 CUR Strings[244]
#define key_f40 CUR Strings[245]
#define key_f41 CUR Strings[246]
#define key_f42 CUR Strings[247]
#define key_f43 CUR Strings[248]
#define key_f44 CUR Strings[249]
#define key_f45 CUR Strings[250]
#define key_f46 CUR Strings[251]
#define key_f47 CUR Strings[252]
#define key_f48 CUR Strings[253]
#define key_f49 CUR Strings[254]
#define key_f50 CUR Strings[255]
#define key_f51 CUR Strings[256]
#define key_f52 CUR Strings[257]
#define key_f53 CUR Strings[258]
#define key_f54 CUR Strings[259]
#define key_f55 CUR Strings[260]
#define key_f56 CUR Strings[261]
#define key_f57 CUR Strings[262]
#define key_f58 CUR Strings[263]
#define key_f59 CUR Strings[264]
#define key_f60 CUR Strings[265]
#define key_f61 CUR Strings[266]
#define key_f62 CUR Strings[267]
#define key_f63 CUR Strings[268]
#define clr_bol CUR Strings[269]
#define clear_margins CUR Strings[270]
#define set_left_margin CUR Strings[271]
#define set_right_margin CUR Strings[272]
#define label_format CUR Strings[273]
#define set_clock CUR Strings[274]
#define display_clock CUR Strings[275]
#define remove_clock CUR Strings[276]
#define create_window CUR Strings[277]
#define goto_window CUR Strings[278]
#define hangup CUR Strings[279]
#define dial_phone CUR Strings[280]
#define quick_dial CUR Strings[281]
#define tone CUR Strings[282]
#define pulse CUR Strings[283]
#define flash_hook CUR Strings[284]
#define fixed_pause CUR Strings[285]
#define wait_tone CUR Strings[286]
#define user0 CUR Strings[287]
#define user1 CUR Strings[288]
#define user2 CUR Strings[289]
#define user3 CUR Strings[290]
#define user4 CUR Strings[291]
#define user5 CUR Strings[292]
#define user6 CUR Strings[293]
#define user7 CUR Strings[294]
#define user8 CUR Strings[295]
#define user9 CUR Strings[296]
#define orig_pair CUR Strings[297]
#define orig_colors CUR Strings[298]
#define initialize_color CUR Strings[299]
#define initialize_pair CUR Strings[300]
#define set_color_pair CUR Strings[301]
#define set_foreground CUR Strings[302]
#define set_background CUR Strings[303]
#define change_char_pitch CUR Strings[304]
#define change_line_pitch CUR Strings[305]
#define change_res_horz CUR Strings[306]
#define change_res_vert CUR Strings[307]
#define define_char CUR Strings[308]
#define enter_doublewide_mode CUR Strings[309]
#define enter_draft_quality CUR Strings[310]
#define enter_italics_mode CUR Strings[311]
#define enter_leftward_mode CUR Strings[312]
#define enter_micro_mode CUR Strings[313]
#define enter_near_letter_quality CUR Strings[314]
#define enter_normal_quality CUR Strings[315]
#define enter_shadow_mode CUR Strings[316]
#define enter_subscript_mode CUR Strings[317]
#define enter_superscript_mode CUR Strings[318]
#define enter_upward_mode CUR Strings[319]
#define exit_doublewide_mode CUR Strings[320]
#define exit_italics_mode CUR Strings[321]
#define exit_leftward_mode CUR Strings[322]
#define exit_micro_mode CUR Strings[323]
#define exit_shadow_mode CUR Strings[324]
#define exit_subscript_mode CUR Strings[325]
#define exit_superscript_mode CUR Strings[326]
#define exit_upward_mode CUR Strings[327]
#define micro_column_address CUR Strings[328]
#define micro_down CUR Strings[329]
#define micro_left CUR Strings[330]
#define micro_right CUR Strings[331]
#define micro_row_address CUR Strings[332]
#define micro_up CUR Strings[333]
#define order_of_pins CUR Strings[334]
#define parm_down_micro CUR Strings[335]
#define parm_left_micro CUR Strings[336]
#define parm_right_micro CUR Strings[337]
#define parm_up_micro CUR Strings[338]
#define select_char_set CUR Strings[339]
#define set_bottom_margin CUR Strings[340]
#define set_bottom_margin_parm CUR Strings[341]
#define set_left_margin_parm CUR Strings[342]
#define set_right_margin_parm CUR Strings[343]
#define set_top_margin CUR Strings[344]
#define set_top_margin_parm CUR Strings[345]
#define start_bit_image CUR Strings[346]
#define start_char_set_def CUR Strings[347]
#define stop_bit_image CUR Strings[348]
#define stop_char_set_def CUR Strings[349]
#define subscript_characters CUR Strings[350]
#define superscript_characters CUR Strings[351]
#define these_cause_cr CUR Strings[352]
#define zero_motion CUR Strings[353]
#define char_set_names CUR Strings[354]
#define key_mouse CUR Strings[355]
#define mouse_info CUR Strings[356]
#define req_mouse_pos CUR Strings[357]
#define get_mouse CUR Strings[358]
#define set_a_foreground CUR Strings[359]
#define set_a_background CUR Strings[360]
#define pkey_plab CUR Strings[361]
#define device_type CUR Strings[362]
#define code_set_init CUR Strings[363]
#define set0_des_seq CUR Strings[364]
#define set1_des_seq CUR Strings[365]
#define set2_des_seq CUR Strings[366]
#define set3_des_seq CUR Strings[367]
#define set_lr_margin CUR Strings[368]
#define set_tb_margin CUR Strings[369]
#define bit_image_repeat CUR Strings[370]
#define bit_image_newline CUR Strings[371]
#define bit_image_carriage_return CUR Strings[372]
#define color_names CUR Strings[373]
#define define_bit_image_region CUR Strings[374]
#define end_bit_image_region CUR Strings[375]
#define set_color_band CUR Strings[376]
#define set_page_length CUR Strings[377]
#define display_pc_char CUR Strings[378]
#define enter_pc_charset_mode CUR Strings[379]
#define exit_pc_charset_mode CUR Strings[380]
#define enter_scancode_mode CUR Strings[381]
#define exit_scancode_mode CUR Strings[382]
#define pc_term_options CUR Strings[383]
#define scancode_escape CUR Strings[384]
#define alt_scancode_esc CUR Strings[385]
#define enter_horizontal_hl_mode CUR Strings[386]
#define enter_left_hl_mode CUR Strings[387]
#define enter_low_hl_mode CUR Strings[388]
#define enter_right_hl_mode CUR Strings[389]
#define enter_top_hl_mode CUR Strings[390]
#define enter_vertical_hl_mode CUR Strings[391]
#define set_a_attributes CUR Strings[392]
#define set_pglen_inch CUR Strings[393]
#define BOOLWRITE 37
#define NUMWRITE 33
#define STRWRITE 394
/* older synonyms for some capabilities */
#define beehive_glitch no_esc_ctlc
#define teleray_glitch dest_tabs_magic_smso
#define micro_char_size micro_col_size
#ifdef __INTERNAL_CAPS_VISIBLE
#define termcap_init2 CUR Strings[394]
#define termcap_reset CUR Strings[395]
#define magic_cookie_glitch_ul CUR Numbers[33]
#define backspaces_with_bs CUR Booleans[37]
#define crt_no_scrolling CUR Booleans[38]
#define no_correctly_working_cr CUR Booleans[39]
#define carriage_return_delay CUR Numbers[34]
#define new_line_delay CUR Numbers[35]
#define linefeed_if_not_lf CUR Strings[396]
#define backspace_if_not_bs CUR Strings[397]
#define gnu_has_meta_key CUR Booleans[40]
#define linefeed_is_newline CUR Booleans[41]
#define backspace_delay CUR Numbers[36]
#define horizontal_tab_delay CUR Numbers[37]
#define number_of_function_keys CUR Numbers[38]
#define other_non_function_keys CUR Strings[398]
#define arrow_key_map CUR Strings[399]
#define has_hardware_tabs CUR Booleans[42]
#define return_does_clr_eol CUR Booleans[43]
#define acs_ulcorner CUR Strings[400]
#define acs_llcorner CUR Strings[401]
#define acs_urcorner CUR Strings[402]
#define acs_lrcorner CUR Strings[403]
#define acs_ltee CUR Strings[404]
#define acs_rtee CUR Strings[405]
#define acs_btee CUR Strings[406]
#define acs_ttee CUR Strings[407]
#define acs_hline CUR Strings[408]
#define acs_vline CUR Strings[409]
#define acs_plus CUR Strings[410]
#define memory_lock CUR Strings[411]
#define memory_unlock CUR Strings[412]
#define box_chars_1 CUR Strings[413]
#endif /* __INTERNAL_CAPS_VISIBLE */
/*
* Predefined terminfo array sizes
*/
#define BOOLCOUNT 44
#define NUMCOUNT 39
#define STRCOUNT 414
/* used by code for comparing entries */
#define acs_chars_index 146
typedef struct termtype { /* in-core form of terminfo data */
char *term_names; /* str_table offset of term names */
char *str_table; /* pointer to string table */
NCURSES_SBOOL *Booleans; /* array of boolean values */
short *Numbers; /* array of integer values */
char **Strings; /* array of string offsets */
#if NCURSES_XNAMES
char *ext_str_table; /* pointer to extended string table */
char **ext_Names; /* corresponding names */
unsigned short num_Booleans;/* count total Booleans */
unsigned short num_Numbers; /* count total Numbers */
unsigned short num_Strings; /* count total Strings */
unsigned short ext_Booleans;/* count extensions to Booleans */
unsigned short ext_Numbers; /* count extensions to Numbers */
unsigned short ext_Strings; /* count extensions to Strings */
#endif /* NCURSES_XNAMES */
} TERMTYPE;
/*
* The only reason these structures are visible is for read-only use.
* Programs which modify the data are not, never were, portable across
* curses implementations.
*/
#ifdef NCURSES_INTERNALS
typedef struct termtype2 { /* in-core form of terminfo data */
char *term_names; /* str_table offset of term names */
char *str_table; /* pointer to string table */
NCURSES_SBOOL *Booleans; /* array of boolean values */
int *Numbers; /* array of integer values */
char **Strings; /* array of string offsets */
#if NCURSES_XNAMES
char *ext_str_table; /* pointer to extended string table */
char **ext_Names; /* corresponding names */
unsigned short num_Booleans;/* count total Booleans */
unsigned short num_Numbers; /* count total Numbers */
unsigned short num_Strings; /* count total Strings */
unsigned short ext_Booleans;/* count extensions to Booleans */
unsigned short ext_Numbers; /* count extensions to Numbers */
unsigned short ext_Strings; /* count extensions to Strings */
#endif /* NCURSES_XNAMES */
} TERMTYPE2;
typedef struct term { /* describe an actual terminal */
TERMTYPE type; /* terminal type description */
short Filedes; /* file description being written to */
TTY Ottyb; /* original state of the terminal */
TTY Nttyb; /* current state of the terminal */
int _baudrate; /* used to compute padding */
char * _termname; /* used for termname() */
TERMTYPE2 type2; /* extended terminal type description */
} TERMINAL;
#else
typedef struct term TERMINAL;
#endif /* NCURSES_INTERNALS */
#if 0 && !0
extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;
#elif 0
NCURSES_WRAPPED_VAR(TERMINAL *, cur_term);
#define cur_term NCURSES_PUBLIC_VAR(cur_term())
#else
extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;
#endif
#if 0 || 0
NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolnames);
NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolcodes);
NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolfnames);
NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numnames);
NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numcodes);
NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numfnames);
NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strnames);
NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strcodes);
NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strfnames);
#define boolnames NCURSES_PUBLIC_VAR(boolnames())
#define boolcodes NCURSES_PUBLIC_VAR(boolcodes())
#define boolfnames NCURSES_PUBLIC_VAR(boolfnames())
#define numnames NCURSES_PUBLIC_VAR(numnames())
#define numcodes NCURSES_PUBLIC_VAR(numcodes())
#define numfnames NCURSES_PUBLIC_VAR(numfnames())
#define strnames NCURSES_PUBLIC_VAR(strnames())
#define strcodes NCURSES_PUBLIC_VAR(strcodes())
#define strfnames NCURSES_PUBLIC_VAR(strfnames())
#else
extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolnames[];
extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolcodes[];
extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolfnames[];
extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numnames[];
extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numcodes[];
extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numfnames[];
extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strnames[];
extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strcodes[];
extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strfnames[];
#endif
/*
* These entrypoints are used only by the ncurses utilities such as tic.
*/
#ifdef NCURSES_INTERNALS
extern NCURSES_EXPORT(int) _nc_set_tty_mode (TTY *buf);
extern NCURSES_EXPORT(int) _nc_read_entry2 (const char * const, char * const, TERMTYPE2 *const);
extern NCURSES_EXPORT(int) _nc_read_file_entry (const char *const, TERMTYPE2 *);
extern NCURSES_EXPORT(int) _nc_read_termtype (TERMTYPE2 *, char *, int);
extern NCURSES_EXPORT(char *) _nc_first_name (const char *const);
extern NCURSES_EXPORT(int) _nc_name_match (const char *const, const char *const, const char *const);
#endif /* NCURSES_INTERNALS */
/*
* These entrypoints are used by tack.
*/
extern NCURSES_EXPORT(const TERMTYPE *) _nc_fallback (const char *);
extern NCURSES_EXPORT(int) _nc_read_entry (const char * const, char * const, TERMTYPE *const);
/* Normal entry points */
extern NCURSES_EXPORT(TERMINAL *) set_curterm (TERMINAL *);
extern NCURSES_EXPORT(int) del_curterm (TERMINAL *);
/* miscellaneous entry points */
extern NCURSES_EXPORT(int) restartterm (NCURSES_CONST char *, int, int *);
extern NCURSES_EXPORT(int) setupterm (NCURSES_CONST char *,int,int *);
/* terminfo entry points, also declared in curses.h */
#if !defined(__NCURSES_H)
extern NCURSES_EXPORT(char *) tigetstr (NCURSES_CONST char *);
extern NCURSES_EXPORT_VAR(char) ttytype[];
extern NCURSES_EXPORT(int) putp (const char *);
extern NCURSES_EXPORT(int) tigetflag (NCURSES_CONST char *);
extern NCURSES_EXPORT(int) tigetnum (NCURSES_CONST char *);
#if 1 /* NCURSES_TPARM_VARARGS */
extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, ...); /* special */
#else
extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, long,long,long,long,long,long,long,long,long); /* special */
extern NCURSES_EXPORT(char *) tparm_varargs (NCURSES_CONST char *, ...); /* special */
#endif
extern NCURSES_EXPORT(char *) tiparm (const char *, ...); /* special */
#endif /* __NCURSES_H */
/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */
#if !defined(NCURSES_TERMCAP_H_incl)
extern NCURSES_EXPORT(char *) tgetstr (NCURSES_CONST char *, char **);
extern NCURSES_EXPORT(char *) tgoto (const char *, int, int);
extern NCURSES_EXPORT(int) tgetent (char *, const char *);
extern NCURSES_EXPORT(int) tgetflag (NCURSES_CONST char *);
extern NCURSES_EXPORT(int) tgetnum (NCURSES_CONST char *);
extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int));
#endif /* NCURSES_TERMCAP_H_incl */
/*
* Include curses.h before term.h to enable these extensions.
*/
#if defined(NCURSES_SP_FUNCS) && (NCURSES_SP_FUNCS != 0)
extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tigetstr) (SCREEN*, NCURSES_CONST char *);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(putp) (SCREEN*, const char *);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tigetflag) (SCREEN*, NCURSES_CONST char *);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tigetnum) (SCREEN*, NCURSES_CONST char *);
#if 1 /* NCURSES_TPARM_VARARGS */
extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tparm) (SCREEN*, NCURSES_CONST char *, ...); /* special */
#else
extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tparm) (SCREEN*, NCURSES_CONST char *, long,long,long,long,long,long,long,long,long); /* special */
extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tparm_varargs) (SCREEN*, NCURSES_CONST char *, ...); /* special */
#endif
/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */
extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tgetstr) (SCREEN*, NCURSES_CONST char *, char **);
extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tgoto) (SCREEN*, const char *, int, int);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetent) (SCREEN*, char *, const char *);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetflag) (SCREEN*, NCURSES_CONST char *);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetnum) (SCREEN*, NCURSES_CONST char *);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tputs) (SCREEN*, const char *, int, NCURSES_SP_OUTC);
extern NCURSES_EXPORT(TERMINAL *) NCURSES_SP_NAME(set_curterm) (SCREEN*, TERMINAL *);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(del_curterm) (SCREEN*, TERMINAL *);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(restartterm) (SCREEN*, NCURSES_CONST char *, int, int *);
#endif /* NCURSES_SP_FUNCS */
#ifdef __cplusplus
}
#endif
#endif /* NCURSES_TERM_H_incl */
panel.h 0000644 00000010033 15201526705 0006014 0 ustar 00 /****************************************************************************
* Copyright (c) 1998-2009,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included *
* in all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
* *
* Except as contained in this notice, the name(s) of the above copyright *
* holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written *
* authorization. *
****************************************************************************/
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
* and: Juergen Pfeifer 1996-1999,2008 *
****************************************************************************/
/* $Id: panel.h,v 1.12 2017/02/11 16:50:28 tom Exp $ */
/* panel.h -- interface file for panels library */
#ifndef NCURSES_PANEL_H_incl
#define NCURSES_PANEL_H_incl 1
#include <curses.h>
typedef struct panel
#if !NCURSES_OPAQUE_PANEL
{
WINDOW *win;
struct panel *below;
struct panel *above;
NCURSES_CONST void *user;
}
#endif /* !NCURSES_OPAQUE_PANEL */
PANEL;
#if defined(__cplusplus)
extern "C" {
#endif
extern NCURSES_EXPORT(WINDOW*) panel_window (const PANEL *);
extern NCURSES_EXPORT(void) update_panels (void);
extern NCURSES_EXPORT(int) hide_panel (PANEL *);
extern NCURSES_EXPORT(int) show_panel (PANEL *);
extern NCURSES_EXPORT(int) del_panel (PANEL *);
extern NCURSES_EXPORT(int) top_panel (PANEL *);
extern NCURSES_EXPORT(int) bottom_panel (PANEL *);
extern NCURSES_EXPORT(PANEL*) new_panel (WINDOW *);
extern NCURSES_EXPORT(PANEL*) panel_above (const PANEL *);
extern NCURSES_EXPORT(PANEL*) panel_below (const PANEL *);
extern NCURSES_EXPORT(int) set_panel_userptr (PANEL *, NCURSES_CONST void *);
extern NCURSES_EXPORT(NCURSES_CONST void*) panel_userptr (const PANEL *);
extern NCURSES_EXPORT(int) move_panel (PANEL *, int, int);
extern NCURSES_EXPORT(int) replace_panel (PANEL *,WINDOW *);
extern NCURSES_EXPORT(int) panel_hidden (const PANEL *);
#if NCURSES_SP_FUNCS
extern NCURSES_EXPORT(PANEL *) ground_panel(SCREEN *);
extern NCURSES_EXPORT(PANEL *) ceiling_panel(SCREEN *);
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(update_panels) (SCREEN*);
#endif
#if defined(__cplusplus)
}
#endif
#endif /* NCURSES_PANEL_H_incl */
/* end of panel.h */
tic.h 0000644 00000032506 15201526705 0005505 0 ustar 00 /****************************************************************************
* Copyright (c) 1998-2012,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included *
* in all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
* *
* Except as contained in this notice, the name(s) of the above copyright *
* holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written *
* authorization. *
****************************************************************************/
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
* and: Thomas E. Dickey 1996 on *
****************************************************************************/
/*
* $Id: tic.h,v 1.75 2017/07/29 23:21:06 tom Exp $
* tic.h - Global variables and structures for the terminfo compiler.
*/
#ifndef __TIC_H
#define __TIC_H
/* *INDENT-OFF* */
#ifdef __cplusplus
extern "C" {
#endif
#include <ncurses_cfg.h>
#include <curses.h> /* for the _tracef() prototype, ERR/OK, bool defs */
/*
** The format of SVr2 compiled terminfo files is as follows:
**
** Header (12 bytes), containing information given below
** Names Section, containing the names of the terminal
** Boolean Section, containing the values of all of the
** boolean capabilities
** A null byte may be inserted here to make
** sure that the Number Section begins on an
** even word boundary.
** Number Section, containing the values of all of the numeric
** capabilities, each as a short integer
** String Section, containing short integer offsets into the
** String Table, one per string capability
** String Table, containing the actual characters of the string
** capabilities.
**
** In the SVr2 format, "short" means signed 16-bit numbers, which is sometimes
** inconvenient. The numbers are signed, to provide for absent and canceled
** values. ncurses6.1 introduced an extension to this compiled format, by
** making the Number Section a list of signed 32-bit integers.
**
** NOTE that all short integers in the file are stored using VAX/PDP-style
** byte-order, i.e., least-significant byte first.
**
** There is no structure definition here because it would only confuse
** matters. Terminfo format is a raw byte layout, not a structure
** dump. If you happen to be on a little-endian machine with 16-bit
** shorts that requires no padding between short members in a struct,
** then there is a natural C structure that captures the header, but
** not very helpfully.
*/
#define MAGIC 0432 /* first two bytes of a compiled entry */
#define MAGIC2 01036 /* first two bytes of a compiled 32-bit entry */
#undef BYTE
#define BYTE(p,n) (unsigned char)((p)[n])
#define IS_NEG1(p) ((BYTE(p,0) == 0377) && (BYTE(p,1) == 0377))
#define IS_NEG2(p) ((BYTE(p,0) == 0376) && (BYTE(p,1) == 0377))
#define LOW_MSB(p) (BYTE(p,0) + 256*BYTE(p,1))
#define IS_TIC_MAGIC(p) (LOW_MSB(p) == MAGIC || LOW_MSB(p) == MAGIC2)
#define quick_prefix(s) (!strncmp((s), "b64:", 4) || !strncmp((s), "hex:", 4))
/*
* The "maximum" here is misleading; XSI guarantees minimum values, which a
* given implementation may exceed.
*/
#define MAX_NAME_SIZE 512 /* maximum legal name field size (XSI:127) */
#define MAX_ENTRY_SIZE1 4096 /* maximum legal entry size (SVr2) */
#define MAX_ENTRY_SIZE2 32768 /* maximum legal entry size (ncurses6.1) */
#if NCURSES_EXT_COLORS && HAVE_INIT_EXTENDED_COLOR
#define MAX_ENTRY_SIZE MAX_ENTRY_SIZE2
#else
#define MAX_ENTRY_SIZE MAX_ENTRY_SIZE1
#endif
/*
* The maximum size of individual name or alias is guaranteed in XSI to be at
* least 14, since that corresponds to the older filename lengths. Newer
* systems allow longer aliases, though not many terminal descriptions are
* written to use them. The MAX_ALIAS symbol is used for warnings.
*/
#if HAVE_LONG_FILE_NAMES
#define MAX_ALIAS 32 /* smaller than POSIX minimum for PATH_MAX */
#else
#define MAX_ALIAS 14 /* SVr3 filename length */
#endif
/* location of user's personal info directory */
#define PRIVATE_INFO "%s/.terminfo" /* plug getenv("HOME") into %s */
/*
* Some traces are designed to be used via tic's verbose option (and similar in
* infocmp and toe) rather than the 'trace()' function. So we use the bits
* above the normal trace() parameter as a debug-level.
*/
#define MAX_DEBUG_LEVEL 15
#define DEBUG_LEVEL(n) ((n) << TRACE_SHIFT)
#define set_trace_level(n) \
_nc_tracing &= DEBUG_LEVEL(MAX_DEBUG_LEVEL) \
+ DEBUG_LEVEL(MAX_DEBUG_LEVEL) - 1, \
_nc_tracing |= DEBUG_LEVEL(n)
#ifdef TRACE
#define DEBUG(n, a) if (_nc_tracing >= DEBUG_LEVEL(n)) _tracef a
#else
#define DEBUG(n, a) /*nothing*/
#endif
/*
* These are the types of tokens returned by the scanner. The first
* three are also used in the hash table of capability names. The scanner
* returns one of these values after loading the specifics into the global
* structure curr_token.
*/
#define BOOLEAN 0 /* Boolean capability */
#define NUMBER 1 /* Numeric capability */
#define STRING 2 /* String-valued capability */
#define CANCEL 3 /* Capability to be cancelled in following tc's */
#define NAMES 4 /* The names for a terminal type */
#define UNDEF 5 /* Undefined */
#define NO_PUSHBACK -1 /* used in pushtype to indicate no pushback */
/*
* The global structure in which the specific parts of a
* scanned token are returned.
*/
struct token
{
char *tk_name; /* name of capability */
int tk_valnumber; /* value of capability (if a number) */
char *tk_valstring; /* value of capability (if a string) */
};
/*
* Offsets to string capabilities, with the corresponding functionkey codes.
*/
struct tinfo_fkeys {
unsigned offset;
chtype code;
};
typedef short HashValue;
/*
* The file comp_captab.c contains an array of these structures, one per
* possible capability. These are indexed by a hash table array of pointers to
* the same structures for use by the parser.
*/
struct name_table_entry
{
const char *nte_name; /* name to hash on */
int nte_type; /* BOOLEAN, NUMBER or STRING */
HashValue nte_index; /* index of associated variable in its array */
HashValue nte_link; /* index in table of next hash, or -1 */
};
/*
* Use this structure to hide differences between terminfo and termcap tables.
*/
typedef struct {
unsigned table_size;
const HashValue *table_data;
HashValue (*hash_of)(const char *);
int (*compare_names)(const char *, const char *);
} HashData;
struct alias
{
const char *from;
const char *to;
const char *source;
};
#define NOTFOUND ((struct name_table_entry *) 0)
/*
* The casts are required for correct sign-propagation with systems such as
* AIX, IRIX64, Solaris which default to unsigned characters. The C standard
* leaves this detail unspecified.
*/
/* out-of-band values for representing absent capabilities */
#define ABSENT_BOOLEAN ((signed char)-1) /* 255 */
#define ABSENT_NUMERIC (-1)
#define ABSENT_STRING (char *)0
/* out-of-band values for representing cancels */
#define CANCELLED_BOOLEAN ((signed char)-2) /* 254 */
#define CANCELLED_NUMERIC (-2)
#define CANCELLED_STRING (char *)(-1)
#define VALID_BOOLEAN(s) ((unsigned char)(s) <= 1) /* reject "-1" */
#define VALID_NUMERIC(s) ((s) >= 0)
#define VALID_STRING(s) ((s) != CANCELLED_STRING && (s) != ABSENT_STRING)
/* termcap entries longer than this may break old binaries */
#define MAX_TERMCAP_LENGTH 1023
/* this is a documented limitation of terminfo */
#define MAX_TERMINFO_LENGTH 4096
#ifndef TERMINFO
#define TERMINFO "/usr/share/terminfo"
#endif
#ifdef NCURSES_TERM_ENTRY_H_incl
/*
* These entrypoints are used only by the ncurses utilities such as tic.
*/
#ifdef NCURSES_INTERNALS
/* access.c */
extern NCURSES_EXPORT(unsigned) _nc_pathlast (const char *);
extern NCURSES_EXPORT(bool) _nc_is_abs_path (const char *);
extern NCURSES_EXPORT(bool) _nc_is_dir_path (const char *);
extern NCURSES_EXPORT(bool) _nc_is_file_path (const char *);
extern NCURSES_EXPORT(char *) _nc_basename (char *);
extern NCURSES_EXPORT(char *) _nc_rootname (char *);
/* comp_captab.c */
extern NCURSES_EXPORT(const struct name_table_entry *) _nc_get_table (bool);
extern NCURSES_EXPORT(const HashData *) _nc_get_hash_info (bool);
extern NCURSES_EXPORT(const struct alias *) _nc_get_alias_table (bool);
/* comp_hash.c: name lookup */
extern NCURSES_EXPORT(struct name_table_entry const *) _nc_find_type_entry
(const char *, int, bool);
/* comp_scan.c: lexical analysis */
extern NCURSES_EXPORT(int) _nc_get_token (bool);
extern NCURSES_EXPORT(void) _nc_panic_mode (char);
extern NCURSES_EXPORT(void) _nc_push_token (int);
extern NCURSES_EXPORT_VAR(int) _nc_curr_col;
extern NCURSES_EXPORT_VAR(int) _nc_curr_line;
extern NCURSES_EXPORT_VAR(int) _nc_syntax;
extern NCURSES_EXPORT_VAR(int) _nc_strict_bsd;
extern NCURSES_EXPORT_VAR(long) _nc_comment_end;
extern NCURSES_EXPORT_VAR(long) _nc_comment_start;
extern NCURSES_EXPORT_VAR(long) _nc_curr_file_pos;
extern NCURSES_EXPORT_VAR(long) _nc_start_line;
#define SYN_TERMINFO 0
#define SYN_TERMCAP 1
/* comp_error.c: warning & abort messages */
extern NCURSES_EXPORT(const char *) _nc_get_source (void);
extern NCURSES_EXPORT(void) _nc_err_abort (const char *const,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
extern NCURSES_EXPORT(void) _nc_get_type (char *name);
extern NCURSES_EXPORT(void) _nc_set_source (const char *const);
extern NCURSES_EXPORT(void) _nc_set_type (const char *const);
extern NCURSES_EXPORT(void) _nc_syserr_abort (const char *const,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
extern NCURSES_EXPORT(void) _nc_warning (const char *const,...) GCC_PRINTFLIKE(1,2);
extern NCURSES_EXPORT_VAR(bool) _nc_suppress_warnings;
/* comp_scan.c */
extern NCURSES_EXPORT_VAR(struct token) _nc_curr_token;
/* captoinfo.c: capability conversion */
extern NCURSES_EXPORT(char *) _nc_captoinfo (const char *, const char *, int const);
extern NCURSES_EXPORT(char *) _nc_infotocap (const char *, const char *, int const);
/* home_terminfo.c */
extern NCURSES_EXPORT(char *) _nc_home_terminfo (void);
/* init_keytry.c */
#if BROKEN_LINKER
#define _nc_tinfo_fkeys _nc_tinfo_fkeysf()
extern NCURSES_EXPORT(const struct tinfo_fkeys *) _nc_tinfo_fkeysf (void);
#else
extern NCURSES_EXPORT_VAR(const struct tinfo_fkeys) _nc_tinfo_fkeys[];
#endif
/* lib_tparm.c */
#define NUM_PARM 9
extern NCURSES_EXPORT_VAR(int) _nc_tparm_err;
extern NCURSES_EXPORT(int) _nc_tparm_analyze(const char *, char **, int *);
/* lib_trace.c */
extern NCURSES_EXPORT_VAR(unsigned) _nc_tracing;
extern NCURSES_EXPORT(const char *) _nc_visbuf (const char *);
extern NCURSES_EXPORT(const char *) _nc_visbuf2 (int, const char *);
/* lib_tputs.c */
extern NCURSES_EXPORT_VAR(int) _nc_nulls_sent; /* Add one for every null sent */
/* comp_main.c: compiler main */
extern const char * _nc_progname;
/* db_iterator.c */
extern NCURSES_EXPORT(const char *) _nc_next_db(DBDIRS *, int *);
extern NCURSES_EXPORT(const char *) _nc_tic_dir (const char *);
extern NCURSES_EXPORT(void) _nc_first_db(DBDIRS *, int *);
extern NCURSES_EXPORT(void) _nc_last_db(void);
/* write_entry.c */
extern NCURSES_EXPORT(int) _nc_tic_written (void);
#endif /* NCURSES_INTERNALS */
/*
* These entrypoints are used by tack.
*/
/* comp_hash.c: name lookup */
extern NCURSES_EXPORT(struct name_table_entry const *) _nc_find_entry
(const char *, const HashValue *);
extern NCURSES_EXPORT(const HashValue *) _nc_get_hash_table (bool);
/* comp_scan.c: lexical analysis */
extern NCURSES_EXPORT(void) _nc_reset_input (FILE *, char *);
/* comp_expand.c: expand string into readable form */
extern NCURSES_EXPORT(char *) _nc_tic_expand (const char *, bool, int);
/* comp_scan.c: decode string from readable form */
extern NCURSES_EXPORT(int) _nc_trans_string (char *, char *);
#endif /* NCURSES_TERM_ENTRY_H_incl */
#ifdef __cplusplus
}
#endif
/* *INDENT-ON* */
#endif /* __TIC_H */
eti.h 0000644 00000005513 15201526705 0005505 0 ustar 00 /****************************************************************************
* Copyright (c) 1998-2002,2003 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included *
* in all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
* *
* Except as contained in this notice, the name(s) of the above copyright *
* holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written *
* authorization. *
****************************************************************************/
/****************************************************************************
* Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/* $Id: eti.h,v 1.8 2003/10/25 15:24:29 tom Exp $ */
#ifndef NCURSES_ETI_H_incl
#define NCURSES_ETI_H_incl 1
#define E_OK (0)
#define E_SYSTEM_ERROR (-1)
#define E_BAD_ARGUMENT (-2)
#define E_POSTED (-3)
#define E_CONNECTED (-4)
#define E_BAD_STATE (-5)
#define E_NO_ROOM (-6)
#define E_NOT_POSTED (-7)
#define E_UNKNOWN_COMMAND (-8)
#define E_NO_MATCH (-9)
#define E_NOT_SELECTABLE (-10)
#define E_NOT_CONNECTED (-11)
#define E_REQUEST_DENIED (-12)
#define E_INVALID_FIELD (-13)
#define E_CURRENT (-14)
#endif
cursesp.h 0000644 00000020631 15201526705 0006406 0 ustar 00 // * This makes emacs happy -*-Mode: C++;-*-
/****************************************************************************
* Copyright (c) 1998-2012,2014 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included *
* in all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
* *
* Except as contained in this notice, the name(s) of the above copyright *
* holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written *
* authorization. *
****************************************************************************/
/****************************************************************************
* Author: Juergen Pfeifer, 1997 *
****************************************************************************/
#ifndef NCURSES_CURSESP_H_incl
#define NCURSES_CURSESP_H_incl 1
// $Id: cursesp.h,v 1.31 2014/08/09 22:06:26 Adam.Jiang Exp $
#include <cursesw.h>
extern "C" {
# include <panel.h>
}
class NCURSES_IMPEXP NCursesPanel
: public NCursesWindow
{
protected:
PANEL *p;
static NCursesPanel *dummy;
private:
// This structure is used for the panel's user data field to link the
// PANEL* to the C++ object and to provide extra space for a user pointer.
typedef struct {
void* m_user; // the pointer for the user's data
const NCursesPanel* m_back; // backward pointer to C++ object
const PANEL* m_owner; // the panel itself
} UserHook;
inline UserHook *UserPointer()
{
UserHook* uptr = reinterpret_cast<UserHook*>(
const_cast<void *>(::panel_userptr (p)));
return uptr;
}
void init(); // Initialize the panel object
protected:
void set_user(void *user)
{
UserHook* uptr = UserPointer();
if (uptr != 0 && uptr->m_back==this && uptr->m_owner==p) {
uptr->m_user = user;
}
}
// Set the user pointer of the panel.
void *get_user()
{
UserHook* uptr = UserPointer();
void *result = 0;
if (uptr != 0 && uptr->m_back==this && uptr->m_owner==p)
result = uptr->m_user;
return result;
}
void OnError (int err) const THROW2(NCursesException const, NCursesPanelException)
{
if (err==ERR)
THROW(new NCursesPanelException (this, err));
}
// If err is equal to the curses error indicator ERR, an error handler
// is called.
// Get a keystroke. Default implementation calls getch()
virtual int getKey(void);
public:
NCursesPanel(int nlines,
int ncols,
int begin_y = 0,
int begin_x = 0)
: NCursesWindow(nlines,ncols,begin_y,begin_x), p(0)
{
init();
}
// Create a panel with this size starting at the requested position.
NCursesPanel()
: NCursesWindow(::stdscr), p(0)
{
init();
}
// This constructor creates the default Panel associated with the
// ::stdscr window
NCursesPanel& operator=(const NCursesPanel& rhs)
{
if (this != &rhs) {
*this = rhs;
NCursesWindow::operator=(rhs);
}
return *this;
}
NCursesPanel(const NCursesPanel& rhs)
: NCursesWindow(rhs),
p(rhs.p)
{
}
virtual ~NCursesPanel();
// basic manipulation
inline void hide()
{
OnError (::hide_panel(p));
}
// Hide the panel. It stays in the stack but becomes invisible.
inline void show()
{
OnError (::show_panel(p));
}
// Show the panel, i.e. make it visible.
inline void top()
{
OnError (::top_panel(p));
}
// Make this panel the top panel in the stack.
inline void bottom()
{
OnError (::bottom_panel(p));
}
// Make this panel the bottom panel in the stack.
// N.B.: The panel associated with ::stdscr is always on the bottom. So
// actually bottom() makes the panel the first above ::stdscr.
virtual int mvwin(int y, int x)
{
OnError(::move_panel(p, y, x));
return OK;
}
inline bool hidden() const
{
return (::panel_hidden (p) ? TRUE : FALSE);
}
// Return TRUE if the panel is hidden, FALSE otherwise.
/* The functions panel_above() and panel_below() are not reflected in
the NCursesPanel class. The reason for this is, that we cannot
assume that a panel retrieved by those operations is one wrapped
by a C++ class. Although this situation might be handled, we also
need a reverse mapping from PANEL to NCursesPanel which needs some
redesign of the low level stuff. At the moment, we define them in the
interface but they will always produce an error. */
inline NCursesPanel& above() const
{
OnError(ERR);
return *dummy;
}
inline NCursesPanel& below() const
{
OnError(ERR);
return *dummy;
}
// Those two are rewrites of the corresponding virtual members of
// NCursesWindow
virtual int refresh();
// Propagate all panel changes to the virtual screen and update the
// physical screen.
virtual int noutrefresh();
// Propagate all panel changes to the virtual screen.
static void redraw();
// Redraw all panels.
// decorations
virtual void frame(const char* title=NULL,
const char* btitle=NULL);
// Put a frame around the panel and put the title centered in the top line
// and btitle in the bottom line.
virtual void boldframe(const char* title=NULL,
const char* btitle=NULL);
// Same as frame(), but use highlighted attributes.
virtual void label(const char* topLabel,
const char* bottomLabel);
// Put the title centered in the top line and btitle in the bottom line.
virtual void centertext(int row,const char* label);
// Put the label text centered in the specified row.
};
/* We use templates to provide a typesafe mechanism to associate
* user data with a panel. A NCursesUserPanel<T> is a panel
* associated with some user data of type T.
*/
template<class T> class NCursesUserPanel : public NCursesPanel
{
public:
NCursesUserPanel (int nlines,
int ncols,
int begin_y = 0,
int begin_x = 0,
const T* p_UserData = STATIC_CAST(T*)(0))
: NCursesPanel (nlines, ncols, begin_y, begin_x)
{
if (p)
set_user (const_cast<void *>(reinterpret_cast<const void*>
(p_UserData)));
};
// This creates an user panel of the requested size with associated
// user data pointed to by p_UserData.
NCursesUserPanel(const T* p_UserData = STATIC_CAST(T*)(0)) : NCursesPanel()
{
if (p)
set_user(const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
};
// This creates an user panel associated with the ::stdscr and user data
// pointed to by p_UserData.
virtual ~NCursesUserPanel() {};
T* UserData (void)
{
return reinterpret_cast<T*>(get_user ());
};
// Retrieve the user data associated with the panel.
virtual void setUserData (const T* p_UserData)
{
if (p)
set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
}
// Associate the user panel with the user data pointed to by p_UserData.
};
#endif /* NCURSES_CURSESP_H_incl */
form.h 0000644 00000044251 15201526705 0005671 0 ustar 00 /****************************************************************************
* Copyright (c) 1998-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included *
* in all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
* *
* Except as contained in this notice, the name(s) of the above copyright *
* holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written *
* authorization. *
****************************************************************************/
/****************************************************************************
* Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/* $Id: form.h,v 0.27 2017/02/11 16:35:42 tom Exp $ */
#ifndef FORM_H
#define FORM_H
/* *INDENT-OFF*/
#include <curses.h>
#include <eti.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef FORM_PRIV_H
typedef void *FIELD_CELL;
#endif
#ifndef NCURSES_FIELD_INTERNALS
#define NCURSES_FIELD_INTERNALS /* nothing */
#endif
typedef int Form_Options;
typedef int Field_Options;
/**********
* _PAGE *
**********/
typedef struct pagenode
#if !NCURSES_OPAQUE_FORM
{
short pmin; /* index of first field on page */
short pmax; /* index of last field on page */
short smin; /* index of top leftmost field on page */
short smax; /* index of bottom rightmost field on page */
}
#endif /* !NCURSES_OPAQUE_FORM */
_PAGE;
/**********
* FIELD *
**********/
typedef struct fieldnode
#if 1 /* not yet: !NCURSES_OPAQUE_FORM */
{
unsigned short status; /* flags */
short rows; /* size in rows */
short cols; /* size in cols */
short frow; /* first row */
short fcol; /* first col */
int drows; /* dynamic rows */
int dcols; /* dynamic cols */
int maxgrow; /* maximum field growth */
int nrow; /* off-screen rows */
short nbuf; /* additional buffers */
short just; /* justification */
short page; /* page on form */
short index; /* into form -> field */
int pad; /* pad character */
chtype fore; /* foreground attribute */
chtype back; /* background attribute */
Field_Options opts; /* options */
struct fieldnode * snext; /* sorted order pointer */
struct fieldnode * sprev; /* sorted order pointer */
struct fieldnode * link; /* linked field chain */
struct formnode * form; /* containing form */
struct typenode * type; /* field type */
void * arg; /* argument for type */
FIELD_CELL * buf; /* field buffers */
void * usrptr; /* user pointer */
/*
* The wide-character configuration requires extra information. Because
* there are existing applications that manipulate the members of FIELD
* directly, we cannot make the struct opaque, except by changing the ABI.
* Offsets of members up to this point are the same in the narrow- and
* wide-character configuration. But note that the type of buf depends on
* the configuration, and is made opaque for that reason.
*/
NCURSES_FIELD_INTERNALS
}
#endif /* NCURSES_OPAQUE_FORM */
FIELD;
/*********
* FORM *
*********/
typedef struct formnode
#if 1 /* not yet: !NCURSES_OPAQUE_FORM */
{
unsigned short status; /* flags */
short rows; /* size in rows */
short cols; /* size in cols */
int currow; /* current row in field window */
int curcol; /* current col in field window */
int toprow; /* in scrollable field window */
int begincol; /* in horiz. scrollable field */
short maxfield; /* number of fields */
short maxpage; /* number of pages */
short curpage; /* index into page */
Form_Options opts; /* options */
WINDOW * win; /* window */
WINDOW * sub; /* subwindow */
WINDOW * w; /* window for current field */
FIELD ** field; /* field [maxfield] */
FIELD * current; /* current field */
_PAGE * page; /* page [maxpage] */
void * usrptr; /* user pointer */
void (*forminit)(struct formnode *);
void (*formterm)(struct formnode *);
void (*fieldinit)(struct formnode *);
void (*fieldterm)(struct formnode *);
}
#endif /* !NCURSES_OPAQUE_FORM */
FORM;
/**************
* FIELDTYPE *
**************/
typedef struct typenode
#if !NCURSES_OPAQUE_FORM
{
unsigned short status; /* flags */
long ref; /* reference count */
struct typenode * left; /* ptr to operand for | */
struct typenode * right; /* ptr to operand for | */
void* (*makearg)(va_list *); /* make fieldtype arg */
void* (*copyarg)(const void *); /* copy fieldtype arg */
void (*freearg)(void *); /* free fieldtype arg */
#if NCURSES_INTEROP_FUNCS
union {
bool (*ofcheck)(FIELD *,const void *); /* field validation */
bool (*gfcheck)(FORM*,FIELD *,const void*); /* generic field validation */
} fieldcheck;
union {
bool (*occheck)(int,const void *); /* character validation */
bool (*gccheck)(int,FORM*,
FIELD*,const void*); /* generic char validation */
} charcheck;
union {
bool (*onext)(FIELD *,const void *); /* enumerate next value */
bool (*gnext)(FORM*,FIELD*,const void*); /* generic enumerate next */
} enum_next;
union {
bool (*oprev)(FIELD *,const void *); /* enumerate prev value */
bool (*gprev)(FORM*,FIELD*,const void*); /* generic enumerate prev */
} enum_prev;
void* (*genericarg)(void*); /* Alternate Arg method */
#else
bool (*fcheck)(FIELD *,const void *); /* field validation */
bool (*ccheck)(int,const void *); /* character validation */
bool (*next)(FIELD *,const void *); /* enumerate next value */
bool (*prev)(FIELD *,const void *); /* enumerate prev value */
#endif
}
#endif /* !NCURSES_OPAQUE_FORM */
FIELDTYPE;
typedef void (*Form_Hook)(FORM *);
/***************************
* miscellaneous #defines *
***************************/
/* field justification */
#define NO_JUSTIFICATION (0)
#define JUSTIFY_LEFT (1)
#define JUSTIFY_CENTER (2)
#define JUSTIFY_RIGHT (3)
/* field options */
#define O_VISIBLE (0x0001U)
#define O_ACTIVE (0x0002U)
#define O_PUBLIC (0x0004U)
#define O_EDIT (0x0008U)
#define O_WRAP (0x0010U)
#define O_BLANK (0x0020U)
#define O_AUTOSKIP (0x0040U)
#define O_NULLOK (0x0080U)
#define O_PASSOK (0x0100U)
#define O_STATIC (0x0200U)
#define O_DYNAMIC_JUSTIFY (0x0400U) /* ncurses extension */
#define O_NO_LEFT_STRIP (0x0800U) /* ncurses extension */
/* form options */
#define O_NL_OVERLOAD (0x0001U)
#define O_BS_OVERLOAD (0x0002U)
/* form driver commands */
#define REQ_NEXT_PAGE (KEY_MAX + 1) /* move to next page */
#define REQ_PREV_PAGE (KEY_MAX + 2) /* move to previous page */
#define REQ_FIRST_PAGE (KEY_MAX + 3) /* move to first page */
#define REQ_LAST_PAGE (KEY_MAX + 4) /* move to last page */
#define REQ_NEXT_FIELD (KEY_MAX + 5) /* move to next field */
#define REQ_PREV_FIELD (KEY_MAX + 6) /* move to previous field */
#define REQ_FIRST_FIELD (KEY_MAX + 7) /* move to first field */
#define REQ_LAST_FIELD (KEY_MAX + 8) /* move to last field */
#define REQ_SNEXT_FIELD (KEY_MAX + 9) /* move to sorted next field */
#define REQ_SPREV_FIELD (KEY_MAX + 10) /* move to sorted prev field */
#define REQ_SFIRST_FIELD (KEY_MAX + 11) /* move to sorted first field */
#define REQ_SLAST_FIELD (KEY_MAX + 12) /* move to sorted last field */
#define REQ_LEFT_FIELD (KEY_MAX + 13) /* move to left to field */
#define REQ_RIGHT_FIELD (KEY_MAX + 14) /* move to right to field */
#define REQ_UP_FIELD (KEY_MAX + 15) /* move to up to field */
#define REQ_DOWN_FIELD (KEY_MAX + 16) /* move to down to field */
#define REQ_NEXT_CHAR (KEY_MAX + 17) /* move to next char in field */
#define REQ_PREV_CHAR (KEY_MAX + 18) /* move to prev char in field */
#define REQ_NEXT_LINE (KEY_MAX + 19) /* move to next line in field */
#define REQ_PREV_LINE (KEY_MAX + 20) /* move to prev line in field */
#define REQ_NEXT_WORD (KEY_MAX + 21) /* move to next word in field */
#define REQ_PREV_WORD (KEY_MAX + 22) /* move to prev word in field */
#define REQ_BEG_FIELD (KEY_MAX + 23) /* move to first char in field */
#define REQ_END_FIELD (KEY_MAX + 24) /* move after last char in fld */
#define REQ_BEG_LINE (KEY_MAX + 25) /* move to beginning of line */
#define REQ_END_LINE (KEY_MAX + 26) /* move after last char in line */
#define REQ_LEFT_CHAR (KEY_MAX + 27) /* move left in field */
#define REQ_RIGHT_CHAR (KEY_MAX + 28) /* move right in field */
#define REQ_UP_CHAR (KEY_MAX + 29) /* move up in field */
#define REQ_DOWN_CHAR (KEY_MAX + 30) /* move down in field */
#define REQ_NEW_LINE (KEY_MAX + 31) /* insert/overlay new line */
#define REQ_INS_CHAR (KEY_MAX + 32) /* insert blank char at cursor */
#define REQ_INS_LINE (KEY_MAX + 33) /* insert blank line at cursor */
#define REQ_DEL_CHAR (KEY_MAX + 34) /* delete char at cursor */
#define REQ_DEL_PREV (KEY_MAX + 35) /* delete char before cursor */
#define REQ_DEL_LINE (KEY_MAX + 36) /* delete line at cursor */
#define REQ_DEL_WORD (KEY_MAX + 37) /* delete word at cursor */
#define REQ_CLR_EOL (KEY_MAX + 38) /* clear to end of line */
#define REQ_CLR_EOF (KEY_MAX + 39) /* clear to end of field */
#define REQ_CLR_FIELD (KEY_MAX + 40) /* clear entire field */
#define REQ_OVL_MODE (KEY_MAX + 41) /* begin overlay mode */
#define REQ_INS_MODE (KEY_MAX + 42) /* begin insert mode */
#define REQ_SCR_FLINE (KEY_MAX + 43) /* scroll field forward a line */
#define REQ_SCR_BLINE (KEY_MAX + 44) /* scroll field backward a line */
#define REQ_SCR_FPAGE (KEY_MAX + 45) /* scroll field forward a page */
#define REQ_SCR_BPAGE (KEY_MAX + 46) /* scroll field backward a page */
#define REQ_SCR_FHPAGE (KEY_MAX + 47) /* scroll field forward half page */
#define REQ_SCR_BHPAGE (KEY_MAX + 48) /* scroll field backward half page */
#define REQ_SCR_FCHAR (KEY_MAX + 49) /* horizontal scroll char */
#define REQ_SCR_BCHAR (KEY_MAX + 50) /* horizontal scroll char */
#define REQ_SCR_HFLINE (KEY_MAX + 51) /* horizontal scroll line */
#define REQ_SCR_HBLINE (KEY_MAX + 52) /* horizontal scroll line */
#define REQ_SCR_HFHALF (KEY_MAX + 53) /* horizontal scroll half line */
#define REQ_SCR_HBHALF (KEY_MAX + 54) /* horizontal scroll half line */
#define REQ_VALIDATION (KEY_MAX + 55) /* validate field */
#define REQ_NEXT_CHOICE (KEY_MAX + 56) /* display next field choice */
#define REQ_PREV_CHOICE (KEY_MAX + 57) /* display prev field choice */
#define MIN_FORM_COMMAND (KEY_MAX + 1) /* used by form_driver */
#define MAX_FORM_COMMAND (KEY_MAX + 57) /* used by form_driver */
#if defined(MAX_COMMAND)
# if (MAX_FORM_COMMAND > MAX_COMMAND)
# error Something is wrong -- MAX_FORM_COMMAND is greater than MAX_COMMAND
# elif (MAX_COMMAND != (KEY_MAX + 128))
# error Something is wrong -- MAX_COMMAND is already inconsistently defined.
# endif
#else
# define MAX_COMMAND (KEY_MAX + 128)
#endif
/*************************
* standard field types *
*************************/
extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_ALPHA;
extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_ALNUM;
extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_ENUM;
extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_INTEGER;
extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_NUMERIC;
extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_REGEXP;
/************************************
* built-in additional field types *
* They are not defined in SVr4 *
************************************/
extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_IPV4; /* Internet IP Version 4 address */
/***********************
* FIELDTYPE routines *
***********************/
extern NCURSES_EXPORT(FIELDTYPE *) new_fieldtype (
bool (* const field_check)(FIELD *,const void *),
bool (* const char_check)(int,const void *));
extern NCURSES_EXPORT(FIELDTYPE *) link_fieldtype(
FIELDTYPE *, FIELDTYPE *);
extern NCURSES_EXPORT(int) free_fieldtype (FIELDTYPE *);
extern NCURSES_EXPORT(int) set_fieldtype_arg (FIELDTYPE *,
void * (* const make_arg)(va_list *),
void * (* const copy_arg)(const void *),
void (* const free_arg)(void *));
extern NCURSES_EXPORT(int) set_fieldtype_choice (FIELDTYPE *,
bool (* const next_choice)(FIELD *,const void *),
bool (* const prev_choice)(FIELD *,const void *));
/*******************
* FIELD routines *
*******************/
extern NCURSES_EXPORT(FIELD *) new_field (int,int,int,int,int,int);
extern NCURSES_EXPORT(FIELD *) dup_field (FIELD *,int,int);
extern NCURSES_EXPORT(FIELD *) link_field (FIELD *,int,int);
extern NCURSES_EXPORT(int) free_field (FIELD *);
extern NCURSES_EXPORT(int) field_info (const FIELD *,int *,int *,int *,int *,int *,int *);
extern NCURSES_EXPORT(int) dynamic_field_info (const FIELD *,int *,int *,int *);
extern NCURSES_EXPORT(int) set_max_field ( FIELD *,int);
extern NCURSES_EXPORT(int) move_field (FIELD *,int,int);
extern NCURSES_EXPORT(int) set_field_type (FIELD *,FIELDTYPE *,...);
extern NCURSES_EXPORT(int) set_new_page (FIELD *,bool);
extern NCURSES_EXPORT(int) set_field_just (FIELD *,int);
extern NCURSES_EXPORT(int) field_just (const FIELD *);
extern NCURSES_EXPORT(int) set_field_fore (FIELD *,chtype);
extern NCURSES_EXPORT(int) set_field_back (FIELD *,chtype);
extern NCURSES_EXPORT(int) set_field_pad (FIELD *,int);
extern NCURSES_EXPORT(int) field_pad (const FIELD *);
extern NCURSES_EXPORT(int) set_field_buffer (FIELD *,int,const char *);
extern NCURSES_EXPORT(int) set_field_status (FIELD *,bool);
extern NCURSES_EXPORT(int) set_field_userptr (FIELD *, void *);
extern NCURSES_EXPORT(int) set_field_opts (FIELD *,Field_Options);
extern NCURSES_EXPORT(int) field_opts_on (FIELD *,Field_Options);
extern NCURSES_EXPORT(int) field_opts_off (FIELD *,Field_Options);
extern NCURSES_EXPORT(chtype) field_fore (const FIELD *);
extern NCURSES_EXPORT(chtype) field_back (const FIELD *);
extern NCURSES_EXPORT(bool) new_page (const FIELD *);
extern NCURSES_EXPORT(bool) field_status (const FIELD *);
extern NCURSES_EXPORT(void *) field_arg (const FIELD *);
extern NCURSES_EXPORT(void *) field_userptr (const FIELD *);
extern NCURSES_EXPORT(FIELDTYPE *) field_type (const FIELD *);
extern NCURSES_EXPORT(char *) field_buffer (const FIELD *,int);
extern NCURSES_EXPORT(Field_Options) field_opts (const FIELD *);
/******************
* FORM routines *
******************/
extern NCURSES_EXPORT(FORM *) new_form (FIELD **);
extern NCURSES_EXPORT(FIELD **) form_fields (const FORM *);
extern NCURSES_EXPORT(FIELD *) current_field (const FORM *);
extern NCURSES_EXPORT(WINDOW *) form_win (const FORM *);
extern NCURSES_EXPORT(WINDOW *) form_sub (const FORM *);
extern NCURSES_EXPORT(Form_Hook) form_init (const FORM *);
extern NCURSES_EXPORT(Form_Hook) form_term (const FORM *);
extern NCURSES_EXPORT(Form_Hook) field_init (const FORM *);
extern NCURSES_EXPORT(Form_Hook) field_term (const FORM *);
extern NCURSES_EXPORT(int) free_form (FORM *);
extern NCURSES_EXPORT(int) set_form_fields (FORM *,FIELD **);
extern NCURSES_EXPORT(int) field_count (const FORM *);
extern NCURSES_EXPORT(int) set_form_win (FORM *,WINDOW *);
extern NCURSES_EXPORT(int) set_form_sub (FORM *,WINDOW *);
extern NCURSES_EXPORT(int) set_current_field (FORM *,FIELD *);
extern NCURSES_EXPORT(int) unfocus_current_field (FORM *);
extern NCURSES_EXPORT(int) field_index (const FIELD *);
extern NCURSES_EXPORT(int) set_form_page (FORM *,int);
extern NCURSES_EXPORT(int) form_page (const FORM *);
extern NCURSES_EXPORT(int) scale_form (const FORM *,int *,int *);
extern NCURSES_EXPORT(int) set_form_init (FORM *,Form_Hook);
extern NCURSES_EXPORT(int) set_form_term (FORM *,Form_Hook);
extern NCURSES_EXPORT(int) set_field_init (FORM *,Form_Hook);
extern NCURSES_EXPORT(int) set_field_term (FORM *,Form_Hook);
extern NCURSES_EXPORT(int) post_form (FORM *);
extern NCURSES_EXPORT(int) unpost_form (FORM *);
extern NCURSES_EXPORT(int) pos_form_cursor (FORM *);
extern NCURSES_EXPORT(int) form_driver (FORM *,int);
# if NCURSES_WIDECHAR
extern NCURSES_EXPORT(int) form_driver_w (FORM *,int,wchar_t);
# endif
extern NCURSES_EXPORT(int) set_form_userptr (FORM *,void *);
extern NCURSES_EXPORT(int) set_form_opts (FORM *,Form_Options);
extern NCURSES_EXPORT(int) form_opts_on (FORM *,Form_Options);
extern NCURSES_EXPORT(int) form_opts_off (FORM *,Form_Options);
extern NCURSES_EXPORT(int) form_request_by_name (const char *);
extern NCURSES_EXPORT(const char *) form_request_name (int);
extern NCURSES_EXPORT(void *) form_userptr (const FORM *);
extern NCURSES_EXPORT(Form_Options) form_opts (const FORM *);
extern NCURSES_EXPORT(bool) data_ahead (const FORM *);
extern NCURSES_EXPORT(bool) data_behind (const FORM *);
#if NCURSES_SP_FUNCS
extern NCURSES_EXPORT(FORM *) NCURSES_SP_NAME(new_form) (SCREEN*, FIELD **);
#endif
#ifdef __cplusplus
}
#endif
/* *INDENT-ON*/
#endif /* FORM_H */
term_entry.h 0000644 00000021070 15201526705 0007110 0 ustar 00 /****************************************************************************
* Copyright (c) 1998-2015,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included *
* in all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
* *
* Except as contained in this notice, the name(s) of the above copyright *
* holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written *
* authorization. *
****************************************************************************/
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
* and: Thomas E. Dickey 1998-on *
****************************************************************************/
/* $Id: term_entry.h,v 1.55 2017/04/06 22:45:34 tom Exp $ */
/*
* term_entry.h -- interface to entry-manipulation code
*/
#ifndef NCURSES_TERM_ENTRY_H_incl
#define NCURSES_TERM_ENTRY_H_incl 1
/* *INDENT-OFF* */
#ifdef __cplusplus
extern "C" {
#endif
#include <term.h>
/*
* These macros may be used by programs that know about TERMTYPE:
*/
#if NCURSES_XNAMES
#define NUM_BOOLEANS(tp) (tp)->num_Booleans
#define NUM_NUMBERS(tp) (tp)->num_Numbers
#define NUM_STRINGS(tp) (tp)->num_Strings
#define EXT_NAMES(tp,i,limit,index,table) (i >= limit) ? tp->ext_Names[index] : table[i]
#else
#define NUM_BOOLEANS(tp) BOOLCOUNT
#define NUM_NUMBERS(tp) NUMCOUNT
#define NUM_STRINGS(tp) STRCOUNT
#define EXT_NAMES(tp,i,limit,index,table) table[i]
#endif
#define NUM_EXT_NAMES(tp) (unsigned) ((tp)->ext_Booleans + (tp)->ext_Numbers + (tp)->ext_Strings)
#define for_each_boolean(n,tp) for(n = 0; n < NUM_BOOLEANS(tp); n++)
#define for_each_number(n,tp) for(n = 0; n < NUM_NUMBERS(tp); n++)
#define for_each_string(n,tp) for(n = 0; n < NUM_STRINGS(tp); n++)
#if NCURSES_XNAMES
#define for_each_ext_boolean(n,tp) for(n = BOOLCOUNT; (int) n < (int) NUM_BOOLEANS(tp); n++)
#define for_each_ext_number(n,tp) for(n = NUMCOUNT; (int) n < (int) NUM_NUMBERS(tp); n++)
#define for_each_ext_string(n,tp) for(n = STRCOUNT; (int) n < (int) NUM_STRINGS(tp); n++)
#endif
#define ExtBoolname(tp,i,names) EXT_NAMES(tp, i, BOOLCOUNT, (i - (tp->num_Booleans - tp->ext_Booleans)), names)
#define ExtNumname(tp,i,names) EXT_NAMES(tp, i, NUMCOUNT, (i - (tp->num_Numbers - tp->ext_Numbers)) + tp->ext_Booleans, names)
#define ExtStrname(tp,i,names) EXT_NAMES(tp, i, STRCOUNT, (i - (tp->num_Strings - tp->ext_Strings)) + (tp->ext_Numbers + tp->ext_Booleans), names)
/*
* The remaining type-definitions and macros are used only internally by the
* ncurses utilities.
*/
#ifdef NCURSES_INTERNALS
/*
* see db_iterator.c - this enumeration lists the places searched for a
* terminal description and defines the order in which they are searched.
*/
typedef enum {
dbdTIC = 0, /* special, used by tic when writing entry */
#if NCURSES_USE_DATABASE
dbdEnvOnce, /* the $TERMINFO environment variable */
dbdHome, /* $HOME/.terminfo */
dbdEnvList, /* the $TERMINFO_DIRS environment variable */
dbdCfgList, /* the compiled-in TERMINFO_DIRS value */
dbdCfgOnce, /* the compiled-in TERMINFO value */
#endif
#if NCURSES_USE_TERMCAP
dbdEnvOnce2, /* the $TERMCAP environment variable */
dbdEnvList2, /* the $TERMPATH environment variable */
dbdCfgList2, /* the compiled-in TERMPATH */
#endif
dbdLAST
} DBDIRS;
#define MAX_USES 32
#define MAX_CROSSLINKS 16
typedef struct entry ENTRY;
typedef struct {
char *name;
ENTRY *link;
long line;
} ENTRY_USES;
struct entry {
TERMTYPE2 tterm;
unsigned nuses;
ENTRY_USES uses[MAX_USES];
int ncrosslinks;
ENTRY *crosslinks[MAX_CROSSLINKS];
long cstart;
long cend;
long startline;
ENTRY *next;
ENTRY *last;
};
extern NCURSES_EXPORT_VAR(ENTRY *) _nc_head;
extern NCURSES_EXPORT_VAR(ENTRY *) _nc_tail;
#define for_entry_list(qp) for (qp = _nc_head; qp; qp = qp->next)
#define MAX_LINE 132
#define NULLHOOK (bool(*)(ENTRY *))0
/*
* Note that WANTED and PRESENT are not simple inverses! If a capability
* has been explicitly cancelled, it's not considered WANTED.
*/
#define WANTED(s) ((s) == ABSENT_STRING)
#define PRESENT(s) (((s) != ABSENT_STRING) && ((s) != CANCELLED_STRING))
#define ANDMISSING(p,q) \
{ \
if (PRESENT(p) && !PRESENT(q)) \
_nc_warning(#p " but no " #q); \
}
#define PAIRED(p,q) \
{ \
if (PRESENT(q) && !PRESENT(p)) \
_nc_warning(#q " but no " #p); \
if (PRESENT(p) && !PRESENT(q)) \
_nc_warning(#p " but no " #q); \
}
/*
* These entrypoints are used only by the ncurses utilities such as tic.
*/
/* alloc_entry.c: elementary allocation code */
extern NCURSES_EXPORT(ENTRY *) _nc_copy_entry (ENTRY *oldp);
extern NCURSES_EXPORT(char *) _nc_save_str (const char *const);
extern NCURSES_EXPORT(void) _nc_init_entry (ENTRY *const);
extern NCURSES_EXPORT(void) _nc_merge_entry (ENTRY *const, ENTRY *const);
extern NCURSES_EXPORT(void) _nc_wrap_entry (ENTRY *const, bool);
/* alloc_ttype.c: elementary allocation code */
extern NCURSES_EXPORT(void) _nc_align_termtype (TERMTYPE2 *, TERMTYPE2 *);
/* free_ttype.c: elementary allocation code */
extern NCURSES_EXPORT(void) _nc_free_termtype2 (TERMTYPE2 *);
/* lib_termcap.c: trim sgr0 string for termcap users */
extern NCURSES_EXPORT(char *) _nc_trim_sgr0 (TERMTYPE2 *);
/* parse_entry.c: entry-parsing code */
#if NCURSES_XNAMES
extern NCURSES_EXPORT_VAR(bool) _nc_user_definable;
extern NCURSES_EXPORT_VAR(bool) _nc_disable_period;
#endif
extern NCURSES_EXPORT(int) _nc_parse_entry (ENTRY *, int, bool);
extern NCURSES_EXPORT(int) _nc_capcmp (const char *, const char *);
/* write_entry.c: writing an entry to the file system */
extern NCURSES_EXPORT(void) _nc_set_writedir (const char *);
extern NCURSES_EXPORT(void) _nc_write_entry (TERMTYPE2 *const);
extern NCURSES_EXPORT(int) _nc_write_object (TERMTYPE2 *, char *, unsigned *, unsigned);
/* comp_parse.c: entry list handling */
extern NCURSES_EXPORT(void) _nc_read_entry_source (FILE*, char*, int, bool, bool (*)(ENTRY*));
extern NCURSES_EXPORT(bool) _nc_entry_match (char *, char *);
extern NCURSES_EXPORT(int) _nc_resolve_uses (bool); /* obs 20040705 */
extern NCURSES_EXPORT(int) _nc_resolve_uses2 (bool, bool);
extern NCURSES_EXPORT(void) _nc_free_entries (ENTRY *);
extern NCURSES_IMPEXP void NCURSES_API (*_nc_check_termtype)(TERMTYPE *); /* obs 20040705 */
extern NCURSES_IMPEXP void NCURSES_API (*_nc_check_termtype2)(TERMTYPE2 *, bool);
/* trace_xnames.c */
extern NCURSES_EXPORT(void) _nc_trace_xnames (TERMTYPE *);
#endif /* NCURSES_INTERNALS */
/*
* These entrypoints are used by tack.
*/
/* alloc_ttype.c: elementary allocation code */
extern NCURSES_EXPORT(void) _nc_copy_termtype (TERMTYPE *, const TERMTYPE *);
/* lib_acs.c */
extern NCURSES_EXPORT(void) _nc_init_acs (void); /* corresponds to traditional 'init_acs()' */
/* free_ttype.c: elementary allocation code */
extern NCURSES_EXPORT(void) _nc_free_termtype (TERMTYPE *);
#ifdef __cplusplus
}
#endif
/* *INDENT-ON* */
#endif /* NCURSES_TERM_ENTRY_H_incl */
etip.h 0000644 00000022746 15201526705 0005674 0 ustar 00 // * This makes emacs happy -*-Mode: C++;-*-
/****************************************************************************
* Copyright (c) 1998-2012,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included *
* in all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
* *
* Except as contained in this notice, the name(s) of the above copyright *
* holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written *
* authorization. *
****************************************************************************/
/****************************************************************************
* Author: Juergen Pfeifer, 1997 *
****************************************************************************/
// $Id: etip.h.in,v 1.41 2017/06/24 21:57:16 tom Exp $
#ifndef NCURSES_ETIP_H_incl
#define NCURSES_ETIP_H_incl 1
// These are substituted at configure/build time
#ifndef HAVE_BUILTIN_H
#define HAVE_BUILTIN_H 0
#endif
#ifndef HAVE_GXX_BUILTIN_H
#define HAVE_GXX_BUILTIN_H 0
#endif
#ifndef HAVE_GPP_BUILTIN_H
#define HAVE_GPP_BUILTIN_H 0
#endif
#ifndef HAVE_IOSTREAM
#define HAVE_IOSTREAM 1
#endif
#ifndef HAVE_TYPEINFO
#define HAVE_TYPEINFO 1
#endif
#ifndef HAVE_VALUES_H
#define HAVE_VALUES_H 0
#endif
#ifndef ETIP_NEEDS_MATH_H
#define ETIP_NEEDS_MATH_H 0
#endif
#ifndef ETIP_NEEDS_MATH_EXCEPTION
#define ETIP_NEEDS_MATH_EXCEPTION 0
#endif
#ifndef CPP_HAS_PARAM_INIT
#define CPP_HAS_PARAM_INIT 0
#endif
#ifndef CPP_HAS_STATIC_CAST
#define CPP_HAS_STATIC_CAST 1
#endif
#ifndef IOSTREAM_NAMESPACE
#define IOSTREAM_NAMESPACE 1
#endif
#ifdef __GNUG__
# if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
# if HAVE_TYPEINFO
# include <typeinfo>
# endif
# endif
#endif
#if defined(__GNUG__)
# if HAVE_BUILTIN_H || HAVE_GXX_BUILTIN_H || HAVE_GPP_BUILTIN_H
# if ETIP_NEEDS_MATH_H
# if ETIP_NEEDS_MATH_EXCEPTION
# undef exception
# define exception math_exception
# endif
# include <math.h>
# endif
# undef exception
# define exception builtin_exception
# if HAVE_GPP_BUILTIN_H
# include <gpp/builtin.h>
# elif HAVE_GXX_BUILTIN_H
# include <g++/builtin.h>
# else
# include <builtin.h>
# endif
# undef exception
# endif
#elif defined (__SUNPRO_CC)
# include <generic.h>
#endif
#include <ncurses_dll.h>
extern "C" {
#if HAVE_VALUES_H
# include <values.h>
#endif
#include <assert.h>
#include <eti.h>
#include <errno.h>
}
// Language features
#if CPP_HAS_PARAM_INIT
#define NCURSES_PARAM_INIT(value) = value
#else
#define NCURSES_PARAM_INIT(value) /*nothing*/
#endif
#if CPP_HAS_STATIC_CAST
#define STATIC_CAST(s) static_cast<s>
#else
#define STATIC_CAST(s) (s)
#endif
// Forward Declarations
class NCURSES_IMPEXP NCursesPanel;
class NCURSES_IMPEXP NCursesMenu;
class NCURSES_IMPEXP NCursesForm;
class NCURSES_IMPEXP NCursesException
{
public:
const char *message;
int errorno;
NCursesException (const char* msg, int err)
: message(msg), errorno (err)
{};
NCursesException (const char* msg)
: message(msg), errorno (E_SYSTEM_ERROR)
{};
NCursesException& operator=(const NCursesException& rhs)
{
errorno = rhs.errorno;
return *this;
}
NCursesException(const NCursesException& rhs)
: message(rhs.message), errorno(rhs.errorno)
{
}
virtual const char *classname() const {
return "NCursesWindow";
}
virtual ~NCursesException()
{
}
};
class NCURSES_IMPEXP NCursesPanelException : public NCursesException
{
public:
const NCursesPanel* p;
NCursesPanelException (const char *msg, int err) :
NCursesException (msg, err),
p (0)
{};
NCursesPanelException (const NCursesPanel* panel,
const char *msg,
int err) :
NCursesException (msg, err),
p (panel)
{};
NCursesPanelException (int err) :
NCursesException ("panel library error", err),
p (0)
{};
NCursesPanelException (const NCursesPanel* panel,
int err) :
NCursesException ("panel library error", err),
p (panel)
{};
NCursesPanelException& operator=(const NCursesPanelException& rhs)
{
if (this != &rhs) {
NCursesException::operator=(rhs);
p = rhs.p;
}
return *this;
}
NCursesPanelException(const NCursesPanelException& rhs)
: NCursesException(rhs), p(rhs.p)
{
}
virtual const char *classname() const {
return "NCursesPanel";
}
virtual ~NCursesPanelException()
{
}
};
class NCURSES_IMPEXP NCursesMenuException : public NCursesException
{
public:
const NCursesMenu* m;
NCursesMenuException (const char *msg, int err) :
NCursesException (msg, err),
m (0)
{};
NCursesMenuException (const NCursesMenu* menu,
const char *msg,
int err) :
NCursesException (msg, err),
m (menu)
{};
NCursesMenuException (int err) :
NCursesException ("menu library error", err),
m (0)
{};
NCursesMenuException (const NCursesMenu* menu,
int err) :
NCursesException ("menu library error", err),
m (menu)
{};
NCursesMenuException& operator=(const NCursesMenuException& rhs)
{
if (this != &rhs) {
NCursesException::operator=(rhs);
m = rhs.m;
}
return *this;
}
NCursesMenuException(const NCursesMenuException& rhs)
: NCursesException(rhs), m(rhs.m)
{
}
virtual const char *classname() const {
return "NCursesMenu";
}
virtual ~NCursesMenuException()
{
}
};
class NCURSES_IMPEXP NCursesFormException : public NCursesException
{
public:
const NCursesForm* f;
NCursesFormException (const char *msg, int err) :
NCursesException (msg, err),
f (0)
{};
NCursesFormException (const NCursesForm* form,
const char *msg,
int err) :
NCursesException (msg, err),
f (form)
{};
NCursesFormException (int err) :
NCursesException ("form library error", err),
f (0)
{};
NCursesFormException (const NCursesForm* form,
int err) :
NCursesException ("form library error", err),
f (form)
{};
NCursesFormException& operator=(const NCursesFormException& rhs)
{
if (this != &rhs) {
NCursesException::operator=(rhs);
f = rhs.f;
}
return *this;
}
NCursesFormException(const NCursesFormException& rhs)
: NCursesException(rhs), f(rhs.f)
{
}
virtual const char *classname() const {
return "NCursesForm";
}
virtual ~NCursesFormException()
{
}
};
#if !((defined(__GNUG__) && defined(__EXCEPTIONS) && (__GNUG__ < 7)) || defined(__SUNPRO_CC))
# if HAVE_IOSTREAM
# include <iostream>
# if IOSTREAM_NAMESPACE
using std::cerr;
using std::endl;
# endif
# else
# include <iostream.h>
# endif
extern "C" void exit(int);
#endif
inline void THROW(const NCursesException *e) {
#if defined(__GNUG__) && defined(__EXCEPTIONS)
# if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
(*lib_error_handler)(e ? e->classname() : "", e ? e->message : "");
# elif (__GNUG__ >= 7)
// g++ 7.0 warns about deprecation, but lacks the predefined symbols
::endwin();
std::cerr << "Found a problem - goodbye" << std::endl;
exit(EXIT_FAILURE);
# else
# define CPP_HAS_TRY_CATCH 1
# endif
#elif defined(__SUNPRO_CC)
# if !defined(__SUNPRO_CC_COMPAT) || (__SUNPRO_CC_COMPAT < 5)
genericerror(1, ((e != 0) ? (char *)(e->message) : ""));
# else
# define CPP_HAS_TRY_CATCH 1
# endif
#else
if (e)
cerr << e->message << endl;
exit(0);
#endif
#ifndef CPP_HAS_TRY_CATCH
#define CPP_HAS_TRY_CATCH 0
#define NCURSES_CPP_TRY /* nothing */
#define NCURSES_CPP_CATCH(e) if (false)
#define THROWS(s) /* nothing */
#define THROW2(s,t) /* nothing */
#elif CPP_HAS_TRY_CATCH
throw *e;
#define NCURSES_CPP_TRY try
#define NCURSES_CPP_CATCH(e) catch(e)
#if defined(__cpp_noexcept_function_type) && (__cpp_noexcept_function_type >= 201510)
// C++17 deprecates the usage of throw().
#define THROWS(s) /* nothing */
#define THROW2(s,t) /* nothing */
#else
#define THROWS(s) throw(s)
#define THROW2(s,t) throw(s,t)
#endif
#endif
}
#endif /* NCURSES_ETIP_H_incl */
cursslk.h 0000644 00000016210 15201526705 0006406 0 ustar 00 // * this is for making emacs happy: -*-Mode: C++;-*-
/****************************************************************************
* Copyright (c) 1998-2003,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included *
* in all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
* *
* Except as contained in this notice, the name(s) of the above copyright *
* holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written *
* authorization. *
****************************************************************************/
/****************************************************************************
* Author: Juergen Pfeifer, 1997 *
****************************************************************************/
// $Id: cursslk.h,v 1.13 2005/05/28 21:58:18 tom Exp $
#ifndef NCURSES_CURSSLK_H_incl
#define NCURSES_CURSSLK_H_incl
#include <cursesw.h>
class NCURSES_IMPEXP Soft_Label_Key_Set {
public:
// This inner class represents the attributes of a Soft Label Key (SLK)
class NCURSES_IMPEXP Soft_Label_Key {
friend class Soft_Label_Key_Set;
public:
typedef enum { Left=0, Center=1, Right=2 } Justification;
private:
char *label; // The Text of the Label
Justification format; // The Justification
int num; // The number of the Label
Soft_Label_Key() : label(NULL), format(Left), num(-1) {
}
virtual ~Soft_Label_Key() {
delete[] label;
};
public:
// Set the text of the Label
Soft_Label_Key& operator=(char *text);
// Set the Justification of the Label
Soft_Label_Key& operator=(Justification just) {
format = just;
return *this;
}
// Retrieve the text of the label
inline char* operator()(void) const {
return label;
}
Soft_Label_Key& operator=(const Soft_Label_Key& rhs)
{
if (this != &rhs) {
*this = rhs;
}
return *this;
}
Soft_Label_Key(const Soft_Label_Key& rhs)
: label(NULL),
format(rhs.format),
num(rhs.num)
{
*this = rhs.label;
}
};
public:
typedef enum {
None = -1,
Three_Two_Three = 0,
Four_Four = 1,
PC_Style = 2,
PC_Style_With_Index = 3
} Label_Layout;
private:
static long NCURSES_IMPEXP count; // Number of Key Sets
static Label_Layout NCURSES_IMPEXP format; // Layout of the Key Sets
static int NCURSES_IMPEXP num_labels; // Number Of Labels in Key Sets
bool NCURSES_IMPEXP b_attrInit; // Are attributes initialized
Soft_Label_Key *slk_array; // The array of SLK's
// Init the Key Set
void init();
// Activate or Deactivate Label# i, Label counting starts with 1!
void activate_label(int i, bool bf=TRUE);
// Activate of Deactivate all Labels
void activate_labels(bool bf);
protected:
inline void Error (const char* msg) const THROWS(NCursesException) {
THROW(new NCursesException (msg));
}
// Remove SLK's from screen
void clear() {
if (ERR==::slk_clear())
Error("slk_clear");
}
// Restore them
void restore() {
if (ERR==::slk_restore())
Error("slk_restore");
}
public:
// Construct a Key Set, use the most comfortable layout as default.
// You must create a Soft_Label_Key_Set before you create any object of
// the NCursesWindow, NCursesPanel or derived classes. (Actually before
// ::initscr() is called).
Soft_Label_Key_Set(Label_Layout fmt);
// This constructor assumes, that you already constructed a Key Set
// with a layout by the constructor above. This layout will be reused.
NCURSES_IMPEXP Soft_Label_Key_Set();
Soft_Label_Key_Set& operator=(const Soft_Label_Key_Set& rhs)
{
if (this != &rhs) {
*this = rhs;
init(); // allocate a new slk_array[]
}
return *this;
}
Soft_Label_Key_Set(const Soft_Label_Key_Set& rhs)
: b_attrInit(rhs.b_attrInit),
slk_array(NULL)
{
init(); // allocate a new slk_array[]
}
virtual ~Soft_Label_Key_Set();
// Get Label# i. Label counting starts with 1!
NCURSES_IMPEXP Soft_Label_Key& operator[](int i);
// Retrieve number of Labels
inline int labels() const { return num_labels; }
// Refresh the SLK portion of the screen
inline void refresh() {
if (ERR==::slk_refresh())
Error("slk_refresh");
}
// Mark the SLK portion of the screen for refresh, defer actual refresh
// until next update call.
inline void noutrefresh() {
if (ERR==::slk_noutrefresh())
Error("slk_noutrefresh");
}
// Mark the whole SLK portion of the screen as modified
inline void touch() {
if (ERR==::slk_touch())
Error("slk_touch");
}
// Activate Label# i
inline void show(int i) {
activate_label(i,FALSE);
activate_label(i,TRUE);
}
// Hide Label# i
inline void hide(int i) {
activate_label(i,FALSE);
}
// Show all Labels
inline void show() {
activate_labels(FALSE);
activate_labels(TRUE);
}
// Hide all Labels
inline void hide() {
activate_labels(FALSE);
}
inline void attron(attr_t attrs) {
if (ERR==::slk_attron(attrs))
Error("slk_attron");
}
inline void attroff(attr_t attrs) {
if (ERR==::slk_attroff(attrs))
Error("slk_attroff");
}
inline void attrset(attr_t attrs) {
if (ERR==::slk_attrset(attrs))
Error("slk_attrset");
}
inline void color(short color_pair_number) {
if (ERR==::slk_color(color_pair_number))
Error("slk_color");
}
inline attr_t attr() const {
return ::slk_attr();
}
};
#endif /* NCURSES_CURSSLK_H_incl */
cursesm.h 0000644 00000046335 15201526705 0006414 0 ustar 00 // * This makes emacs happy -*-Mode: C++;-*-
/****************************************************************************
* Copyright (c) 1998-2012,2014 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included *
* in all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
* *
* Except as contained in this notice, the name(s) of the above copyright *
* holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written *
* authorization. *
****************************************************************************/
/****************************************************************************
* Author: Juergen Pfeifer, 1997 *
****************************************************************************/
// $Id: cursesm.h,v 1.30 2014/08/09 22:06:18 Adam.Jiang Exp $
#ifndef NCURSES_CURSESM_H_incl
#define NCURSES_CURSESM_H_incl 1
#include <cursesp.h>
extern "C" {
# include <menu.h>
}
//
// -------------------------------------------------------------------------
// This wraps the ITEM type of <menu.h>
// -------------------------------------------------------------------------
//
class NCURSES_IMPEXP NCursesMenuItem
{
friend class NCursesMenu;
protected:
ITEM *item;
inline void OnError (int err) const THROW2(NCursesException const, NCursesMenuException) {
if (err != E_OK)
THROW(new NCursesMenuException (err));
}
public:
NCursesMenuItem (const char* p_name = NULL,
const char* p_descript = NULL)
: item(0)
{
item = p_name ? ::new_item (p_name, p_descript) : STATIC_CAST(ITEM*)(0);
if (p_name && !item)
OnError (E_SYSTEM_ERROR);
}
// Create an item. If you pass both parameters as NULL, a delimiting
// item is constructed which can be used to terminate a list of
// NCursesMenu objects.
NCursesMenuItem& operator=(const NCursesMenuItem& rhs)
{
if (this != &rhs) {
*this = rhs;
}
return *this;
}
NCursesMenuItem(const NCursesMenuItem& rhs)
: item(0)
{
(void) rhs;
}
virtual ~NCursesMenuItem ();
// Release the items memory
inline const char* name () const {
return ::item_name (item);
}
// Name of the item
inline const char* description () const {
return ::item_description (item);
}
// Description of the item
inline int (index) (void) const {
return ::item_index (item);
}
// Index of the item in an item array (or -1)
inline void options_on (Item_Options opts) {
OnError (::item_opts_on (item, opts));
}
// Switch on the items options
inline void options_off (Item_Options opts) {
OnError (::item_opts_off (item, opts));
}
// Switch off the item's option
inline Item_Options options () const {
return ::item_opts (item);
}
// Retrieve the items options
inline void set_options (Item_Options opts) {
OnError (::set_item_opts (item, opts));
}
// Set the items options
inline void set_value (bool f) {
OnError (::set_item_value (item,f));
}
// Set/Reset the items selection state
inline bool value () const {
return ::item_value (item);
}
// Retrieve the items selection state
inline bool visible () const {
return ::item_visible (item);
}
// Retrieve visibility of the item
virtual bool action();
// Perform an action associated with this item; you may use this in an
// user supplied driver for a menu; you may derive from this class and
// overload action() to supply items with different actions.
// If an action returns true, the menu will be exited. The default action
// is to do nothing.
};
// Prototype for an items callback function.
typedef bool ITEMCALLBACK(NCursesMenuItem&);
// If you don't like to create a child class for individual items to
// overload action(), you may use this class and provide a callback
// function pointer for items.
class NCURSES_IMPEXP NCursesMenuCallbackItem : public NCursesMenuItem
{
private:
ITEMCALLBACK* p_fct;
public:
NCursesMenuCallbackItem(ITEMCALLBACK* fct = NULL,
const char* p_name = NULL,
const char* p_descript = NULL )
: NCursesMenuItem (p_name, p_descript),
p_fct (fct) {
}
NCursesMenuCallbackItem& operator=(const NCursesMenuCallbackItem& rhs)
{
if (this != &rhs) {
*this = rhs;
}
return *this;
}
NCursesMenuCallbackItem(const NCursesMenuCallbackItem& rhs)
: NCursesMenuItem(rhs),
p_fct(0)
{
}
virtual ~NCursesMenuCallbackItem();
bool action();
};
// This are the built-in hook functions in this C++ binding. In C++ we use
// virtual member functions (see below On_..._Init and On_..._Termination)
// to provide this functionality in an object oriented manner.
extern "C" {
void _nc_xx_mnu_init(MENU *);
void _nc_xx_mnu_term(MENU *);
void _nc_xx_itm_init(MENU *);
void _nc_xx_itm_term(MENU *);
}
//
// -------------------------------------------------------------------------
// This wraps the MENU type of <menu.h>
// -------------------------------------------------------------------------
//
class NCURSES_IMPEXP NCursesMenu : public NCursesPanel
{
protected:
MENU *menu;
private:
NCursesWindow* sub; // the subwindow object
bool b_sub_owner; // is this our own subwindow?
bool b_framed; // has the menu a border?
bool b_autoDelete; // Delete items when deleting menu?
NCursesMenuItem** my_items; // The array of items for this menu
// This structure is used for the menu's user data field to link the
// MENU* to the C++ object and to provide extra space for a user pointer.
typedef struct {
void* m_user; // the pointer for the user's data
const NCursesMenu* m_back; // backward pointer to C++ object
const MENU* m_owner;
} UserHook;
// Get the backward pointer to the C++ object from a MENU
static inline NCursesMenu* getHook(const MENU *m) {
UserHook* hook = STATIC_CAST(UserHook*)(::menu_userptr(m));
assert(hook != 0 && hook->m_owner==m);
return const_cast<NCursesMenu*>(hook->m_back);
}
friend void _nc_xx_mnu_init(MENU *);
friend void _nc_xx_mnu_term(MENU *);
friend void _nc_xx_itm_init(MENU *);
friend void _nc_xx_itm_term(MENU *);
// Calculate ITEM* array for the menu
ITEM** mapItems(NCursesMenuItem* nitems[]);
protected:
// internal routines
inline void set_user(void *user) {
UserHook* uptr = STATIC_CAST(UserHook*)(::menu_userptr (menu));
assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==menu);
uptr->m_user = user;
}
inline void *get_user() {
UserHook* uptr = STATIC_CAST(UserHook*)(::menu_userptr (menu));
assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==menu);
return uptr->m_user;
}
void InitMenu (NCursesMenuItem* menu[],
bool with_frame,
bool autoDeleteItems);
inline void OnError (int err) const THROW2(NCursesException const, NCursesMenuException) {
if (err != E_OK)
THROW(new NCursesMenuException (this, err));
}
// this wraps the menu_driver call.
virtual int driver (int c) ;
// 'Internal' constructor to create a menu without association to
// an array of items.
NCursesMenu( int nlines,
int ncols,
int begin_y = 0,
int begin_x = 0)
: NCursesPanel(nlines,ncols,begin_y,begin_x),
menu (STATIC_CAST(MENU*)(0)),
sub(0),
b_sub_owner(0),
b_framed(0),
b_autoDelete(0),
my_items(0)
{
}
public:
// Make a full window size menu
NCursesMenu (NCursesMenuItem* Items[],
bool with_frame=FALSE, // Reserve space for a frame?
bool autoDelete_Items=FALSE) // Autocleanup of Items?
: NCursesPanel(),
menu(0),
sub(0),
b_sub_owner(0),
b_framed(0),
b_autoDelete(0),
my_items(0)
{
InitMenu(Items, with_frame, autoDelete_Items);
}
// Make a menu with a window of this size.
NCursesMenu (NCursesMenuItem* Items[],
int nlines,
int ncols,
int begin_y = 0,
int begin_x = 0,
bool with_frame=FALSE, // Reserve space for a frame?
bool autoDelete_Items=FALSE) // Autocleanup of Items?
: NCursesPanel(nlines, ncols, begin_y, begin_x),
menu(0),
sub(0),
b_sub_owner(0),
b_framed(0),
b_autoDelete(0),
my_items(0)
{
InitMenu(Items, with_frame, autoDelete_Items);
}
NCursesMenu& operator=(const NCursesMenu& rhs)
{
if (this != &rhs) {
*this = rhs;
NCursesPanel::operator=(rhs);
}
return *this;
}
NCursesMenu(const NCursesMenu& rhs)
: NCursesPanel(rhs),
menu(rhs.menu),
sub(rhs.sub),
b_sub_owner(rhs.b_sub_owner),
b_framed(rhs.b_framed),
b_autoDelete(rhs.b_autoDelete),
my_items(rhs.my_items)
{
}
virtual ~NCursesMenu ();
// Retrieve the menus subwindow
inline NCursesWindow& subWindow() const {
assert(sub!=NULL);
return *sub;
}
// Set the menus subwindow
void setSubWindow(NCursesWindow& sub);
// Set these items for the menu
inline void setItems(NCursesMenuItem* Items[]) {
OnError(::set_menu_items(menu,mapItems(Items)));
}
// Remove the menu from the screen
inline void unpost (void) {
OnError (::unpost_menu (menu));
}
// Post the menu to the screen if flag is true, unpost it otherwise
inline void post(bool flag = TRUE) {
flag ? OnError (::post_menu(menu)) : OnError (::unpost_menu (menu));
}
// Get the numer of rows and columns for this menu
inline void scale (int& mrows, int& mcols) const {
OnError (::scale_menu (menu, &mrows, &mcols));
}
// Set the format of this menu
inline void set_format(int mrows, int mcols) {
OnError (::set_menu_format(menu, mrows, mcols));
}
// Get the format of this menu
inline void menu_format(int& rows,int& ncols) {
::menu_format(menu,&rows,&ncols);
}
// Items of the menu
inline NCursesMenuItem* items() const {
return *my_items;
}
// Get the number of items in this menu
inline int count() const {
return ::item_count(menu);
}
// Get the current item (i.e. the one the cursor is located)
inline NCursesMenuItem* current_item() const {
return my_items[::item_index(::current_item(menu))];
}
// Get the marker string
inline const char* mark() const {
return ::menu_mark(menu);
}
// Set the marker string
inline void set_mark(const char *marker) {
OnError (::set_menu_mark (menu, marker));
}
// Get the name of the request code c
inline static const char* request_name(int c) {
return ::menu_request_name(c);
}
// Get the current pattern
inline char* pattern() const {
return ::menu_pattern(menu);
}
// true if there is a pattern match, false otherwise.
bool set_pattern (const char *pat);
// set the default attributes for the menu
// i.e. set fore, back and grey attribute
virtual void setDefaultAttributes();
// Get the menus background attributes
inline chtype back() const {
return ::menu_back(menu);
}
// Get the menus foreground attributes
inline chtype fore() const {
return ::menu_fore(menu);
}
// Get the menus grey attributes (used for unselectable items)
inline chtype grey() const {
return ::menu_grey(menu);
}
// Set the menus background attributes
inline chtype set_background(chtype a) {
return ::set_menu_back(menu,a);
}
// Set the menus foreground attributes
inline chtype set_foreground(chtype a) {
return ::set_menu_fore(menu,a);
}
// Set the menus grey attributes (used for unselectable items)
inline chtype set_grey(chtype a) {
return ::set_menu_grey(menu,a);
}
inline void options_on (Menu_Options opts) {
OnError (::menu_opts_on (menu,opts));
}
inline void options_off(Menu_Options opts) {
OnError (::menu_opts_off(menu,opts));
}
inline Menu_Options options() const {
return ::menu_opts(menu);
}
inline void set_options (Menu_Options opts) {
OnError (::set_menu_opts (menu,opts));
}
inline int pad() const {
return ::menu_pad(menu);
}
inline void set_pad (int padch) {
OnError (::set_menu_pad (menu, padch));
}
// Position the cursor to the current item
inline void position_cursor () const {
OnError (::pos_menu_cursor (menu));
}
// Set the current item
inline void set_current(NCursesMenuItem& I) {
OnError (::set_current_item(menu, I.item));
}
// Get the current top row of the menu
inline int top_row (void) const {
return ::top_row (menu);
}
// Set the current top row of the menu
inline void set_top_row (int row) {
OnError (::set_top_row (menu, row));
}
// spacing control
// Set the spacing for the menu
inline void setSpacing(int spc_description,
int spc_rows,
int spc_columns) {
OnError(::set_menu_spacing(menu,
spc_description,
spc_rows,
spc_columns));
}
// Get the spacing info for the menu
inline void Spacing(int& spc_description,
int& spc_rows,
int& spc_columns) const {
OnError(::menu_spacing(menu,
&spc_description,
&spc_rows,
&spc_columns));
}
// Decorations
inline void frame(const char *title=NULL, const char* btitle=NULL) {
if (b_framed)
NCursesPanel::frame(title,btitle);
else
OnError(E_SYSTEM_ERROR);
}
inline void boldframe(const char *title=NULL, const char* btitle=NULL) {
if (b_framed)
NCursesPanel::boldframe(title,btitle);
else
OnError(E_SYSTEM_ERROR);
}
inline void label(const char *topLabel, const char *bottomLabel) {
if (b_framed)
NCursesPanel::label(topLabel,bottomLabel);
else
OnError(E_SYSTEM_ERROR);
}
// -----
// Hooks
// -----
// Called after the menu gets repositioned in its window.
// This is especially true if the menu is posted.
virtual void On_Menu_Init();
// Called before the menu gets repositioned in its window.
// This is especially true if the menu is unposted.
virtual void On_Menu_Termination();
// Called after the item became the current item
virtual void On_Item_Init(NCursesMenuItem& item);
// Called before this item is left as current item.
virtual void On_Item_Termination(NCursesMenuItem& item);
// Provide a default key virtualization. Translate the keyboard
// code c into a menu request code.
// The default implementation provides a hopefully straightforward
// mapping for the most common keystrokes and menu requests.
virtual int virtualize(int c);
// Operators
inline NCursesMenuItem* operator[](int i) const {
if ( (i < 0) || (i >= ::item_count (menu)) )
OnError (E_BAD_ARGUMENT);
return (my_items[i]);
}
// Perform the menu's operation
// Return the item where you left the selection mark for a single
// selection menu, or NULL for a multivalued menu.
virtual NCursesMenuItem* operator()(void);
// --------------------
// Exception handlers
// Called by operator()
// --------------------
// Called if the request is denied
virtual void On_Request_Denied(int c) const;
// Called if the item is not selectable
virtual void On_Not_Selectable(int c) const;
// Called if pattern doesn't match
virtual void On_No_Match(int c) const;
// Called if the command is unknown
virtual void On_Unknown_Command(int c) const;
};
//
// -------------------------------------------------------------------------
// This is the typical C++ typesafe way to allow to attach
// user data to an item of a menu. Its assumed that the user
// data belongs to some class T. Use T as template argument
// to create a UserItem.
// -------------------------------------------------------------------------
//
template<class T> class NCURSES_IMPEXP NCursesUserItem : public NCursesMenuItem
{
public:
NCursesUserItem (const char* p_name,
const char* p_descript = NULL,
const T* p_UserData = STATIC_CAST(T*)(0))
: NCursesMenuItem (p_name, p_descript) {
if (item)
OnError (::set_item_userptr (item, const_cast<void *>(reinterpret_cast<const void*>(p_UserData))));
}
virtual ~NCursesUserItem() {}
inline const T* UserData (void) const {
return reinterpret_cast<const T*>(::item_userptr (item));
};
inline virtual void setUserData(const T* p_UserData) {
if (item)
OnError (::set_item_userptr (item, const_cast<void *>(reinterpret_cast<const void *>(p_UserData))));
}
};
//
// -------------------------------------------------------------------------
// The same mechanism is used to attach user data to a menu
// -------------------------------------------------------------------------
//
template<class T> class NCURSES_IMPEXP NCursesUserMenu : public NCursesMenu
{
protected:
NCursesUserMenu( int nlines,
int ncols,
int begin_y = 0,
int begin_x = 0,
const T* p_UserData = STATIC_CAST(T*)(0))
: NCursesMenu(nlines,ncols,begin_y,begin_x) {
if (menu)
set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
}
public:
NCursesUserMenu (NCursesMenuItem* Items[],
const T* p_UserData = STATIC_CAST(T*)(0),
bool with_frame=FALSE,
bool autoDelete_Items=FALSE)
: NCursesMenu (Items, with_frame, autoDelete_Items) {
if (menu)
set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
};
NCursesUserMenu (NCursesMenuItem* Items[],
int nlines,
int ncols,
int begin_y = 0,
int begin_x = 0,
const T* p_UserData = STATIC_CAST(T*)(0),
bool with_frame=FALSE)
: NCursesMenu (Items, nlines, ncols, begin_y, begin_x, with_frame) {
if (menu)
set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
};
virtual ~NCursesUserMenu() {
};
inline T* UserData (void) {
return reinterpret_cast<T*>(get_user ());
};
inline virtual void setUserData (const T* p_UserData) {
if (menu)
set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
}
};
#endif /* NCURSES_CURSESM_H_incl */
cursesapp.h 0000644 00000015167 15201526705 0006737 0 ustar 00 // * This makes emacs happy -*-Mode: C++;-*-
/****************************************************************************
* Copyright (c) 1998-2005,2011 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included *
* in all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
* *
* Except as contained in this notice, the name(s) of the above copyright *
* holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written *
* authorization. *
****************************************************************************/
/****************************************************************************
* Author: Juergen Pfeifer, 1997 *
****************************************************************************/
// $Id: cursesapp.h,v 1.12 2011/09/17 22:12:10 tom Exp $
#ifndef NCURSES_CURSESAPP_H_incl
#define NCURSES_CURSESAPP_H_incl
#include <cursslk.h>
class NCURSES_IMPEXP NCursesApplication {
public:
typedef struct _slk_link { // This structure is used to maintain
struct _slk_link* prev; // a stack of SLKs
Soft_Label_Key_Set* SLKs;
} SLK_Link;
private:
static int rinit(NCursesWindow& w); // Internal Init function for title
static NCursesApplication* theApp; // Global ref. to the application
static SLK_Link* slk_stack;
protected:
static NCursesWindow* titleWindow; // The Title Window (if any)
bool b_Colors; // Is this a color application?
NCursesWindow* Root_Window; // This is the stdscr equiv.
// Initialization of attributes;
// Rewrite this in your derived class if you prefer other settings
virtual void init(bool bColors);
// The number of lines for the title window. Default is no title window
// You may rewrite this in your derived class
virtual int titlesize() const {
return 0;
}
// This method is called to put something into the title window initially
// You may rewrite this in your derived class
virtual void title() {
}
// The layout used for the Soft Label Keys. Default is to have no SLKs.
// You may rewrite this in your derived class
virtual Soft_Label_Key_Set::Label_Layout useSLKs() const {
return Soft_Label_Key_Set::None;
}
// This method is called to initialize the SLKs. Default is nothing.
// You may rewrite this in your derived class
virtual void init_labels(Soft_Label_Key_Set& S) const {
(void) S;
}
// Your derived class must implement this method. The return value must
// be the exit value of your application.
virtual int run() = 0;
// The constructor is protected, so you may use it in your derived
// class constructor. The argument tells whether or not you want colors.
NCursesApplication(bool wantColors = FALSE);
NCursesApplication& operator=(const NCursesApplication& rhs)
{
if (this != &rhs) {
*this = rhs;
}
return *this;
}
NCursesApplication(const NCursesApplication& rhs)
: b_Colors(rhs.b_Colors),
Root_Window(rhs.Root_Window)
{
}
public:
virtual ~NCursesApplication();
// Get a pointer to the current application object
static NCursesApplication* getApplication() {
return theApp;
}
// This method runs the application and returns its exit value
int operator()(void);
// Process the commandline arguments. The default implementation simply
// ignores them. Your derived class may rewrite this.
virtual void handleArgs(int argc, char* argv[]) {
(void) argc;
(void) argv;
}
// Does this application use colors?
inline bool useColors() const {
return b_Colors;
}
// Push the Key Set S onto the SLK Stack. S then becomes the current set
// of Soft Labelled Keys.
void push(Soft_Label_Key_Set& S);
// Throw away the current set of SLKs and make the previous one the
// new current set.
bool pop();
// Retrieve the current set of Soft Labelled Keys.
Soft_Label_Key_Set* top() const;
// Attributes to use for menu and forms foregrounds
virtual chtype foregrounds() const {
return b_Colors ? static_cast<chtype>(COLOR_PAIR(1)) : A_BOLD;
}
// Attributes to use for menu and forms backgrounds
virtual chtype backgrounds() const {
return b_Colors ? static_cast<chtype>(COLOR_PAIR(2)) : A_NORMAL;
}
// Attributes to use for inactive (menu) elements
virtual chtype inactives() const {
return b_Colors ? static_cast<chtype>(COLOR_PAIR(3)|A_DIM) : A_DIM;
}
// Attributes to use for (form) labels and SLKs
virtual chtype labels() const {
return b_Colors ? static_cast<chtype>(COLOR_PAIR(4)) : A_NORMAL;
}
// Attributes to use for form backgrounds
virtual chtype dialog_backgrounds() const {
return b_Colors ? static_cast<chtype>(COLOR_PAIR(4)) : A_NORMAL;
}
// Attributes to use as default for (form) window backgrounds
virtual chtype window_backgrounds() const {
return b_Colors ? static_cast<chtype>(COLOR_PAIR(5)) : A_NORMAL;
}
// Attributes to use for the title window
virtual chtype screen_titles() const {
return b_Colors ? static_cast<chtype>(COLOR_PAIR(6)) : A_BOLD;
}
};
#endif /* NCURSES_CURSESAPP_H_incl */
curses.h 0000644 00000302451 15201526705 0006231 0 ustar 00 /****************************************************************************
* Copyright (c) 1998-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included *
* in all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
* *
* Except as contained in this notice, the name(s) of the above copyright *
* holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written *
* authorization. *
****************************************************************************/
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
* and: Thomas E. Dickey 1996-on *
****************************************************************************/
/* $Id: curses.h.in,v 1.257 2017/11/21 00:11:37 tom Exp $ */
#ifndef __NCURSES_H
#define __NCURSES_H
#define CURSES 1
#define CURSES_H 1
/* These are defined only in curses.h, and are used for conditional compiles */
#define NCURSES_VERSION_MAJOR 6
#define NCURSES_VERSION_MINOR 1
#define NCURSES_VERSION_PATCH 20180224
/* This is defined in more than one ncurses header, for identification */
#undef NCURSES_VERSION
#define NCURSES_VERSION "6.1"
/*
* Identify the mouse encoding version.
*/
#define NCURSES_MOUSE_VERSION 2
/*
* Definitions to facilitate DLL's.
*/
#include <ncurses_dll.h>
#if 1
#include <stdint.h>
#endif
/*
* User-definable tweak to disable the include of <stdbool.h>.
*/
#ifndef NCURSES_ENABLE_STDBOOL_H
#define NCURSES_ENABLE_STDBOOL_H 1
#endif
/*
* NCURSES_ATTR_T is used to quiet compiler warnings when building ncurses
* configured using --disable-macros.
*/
#ifndef NCURSES_ATTR_T
#define NCURSES_ATTR_T int
#endif
/*
* Expands to 'const' if ncurses is configured using --enable-const. Note that
* doing so makes it incompatible with other implementations of X/Open Curses.
*/
#undef NCURSES_CONST
#define NCURSES_CONST const
#undef NCURSES_INLINE
#define NCURSES_INLINE inline
/*
* The standard type used for color values, and for color-pairs. The latter
* allows the curses library to enumerate the combinations of foreground and
* background colors used by an application, and is normally the product of the
* total foreground and background colors.
*
* X/Open uses "short" for both of these types, ultimately because they are
* numbers from the SVr4 terminal database, which uses 16-bit signed values.
*/
#undef NCURSES_COLOR_T
#define NCURSES_COLOR_T short
#undef NCURSES_PAIRS_T
#define NCURSES_PAIRS_T short
/*
* Definitions used to make WINDOW and similar structs opaque.
*/
#ifndef NCURSES_INTERNALS
#define NCURSES_OPAQUE 0
#define NCURSES_OPAQUE_FORM 0
#define NCURSES_OPAQUE_MENU 0
#define NCURSES_OPAQUE_PANEL 0
#endif
/*
* Definition used to optionally suppress wattr* macros to help with the
* transition from ncurses5 to ncurses6 by allowing the header files to
* be shared across development packages for ncursesw in both ABIs.
*/
#ifndef NCURSES_WATTR_MACROS
#define NCURSES_WATTR_MACROS 0
#endif
/*
* The reentrant code relies on the opaque setting, but adds features.
*/
#ifndef NCURSES_REENTRANT
#define NCURSES_REENTRANT 0
#endif
/*
* Control whether bindings for interop support are added.
*/
#undef NCURSES_INTEROP_FUNCS
#define NCURSES_INTEROP_FUNCS 1
/*
* The internal type used for window dimensions.
*/
#undef NCURSES_SIZE_T
#define NCURSES_SIZE_T short
/*
* Control whether tparm() supports varargs or fixed-parameter list.
*/
#undef NCURSES_TPARM_VARARGS
#define NCURSES_TPARM_VARARGS 1
/*
* Control type used for tparm's arguments. While X/Open equates long and
* char* values, this is not always workable for 64-bit platforms.
*/
#undef NCURSES_TPARM_ARG
#define NCURSES_TPARM_ARG intptr_t
/*
* Control whether ncurses uses wcwidth() for checking width of line-drawing
* characters.
*/
#undef NCURSES_WCWIDTH_GRAPHICS
#define NCURSES_WCWIDTH_GRAPHICS 1
/*
* NCURSES_CH_T is used in building the library, but not used otherwise in
* this header file, since that would make the normal/wide-character versions
* of the header incompatible.
*/
#undef NCURSES_CH_T
#define NCURSES_CH_T cchar_t
#if 1 && defined(_LP64)
typedef unsigned chtype;
typedef unsigned mmask_t;
#else
typedef uint32_t chtype;
typedef uint32_t mmask_t;
#endif
/*
* We need FILE, etc. Include this before checking any feature symbols.
*/
#include <stdio.h>
/*
* With XPG4, you must define _XOPEN_SOURCE_EXTENDED, it is redundant (or
* conflicting) when _XOPEN_SOURCE is 500 or greater. If NCURSES_WIDECHAR is
* not already defined, e.g., if the platform relies upon nonstandard feature
* test macros, define it at this point if the standard feature test macros
* indicate that it should be defined.
*/
#ifndef NCURSES_WIDECHAR
#if defined(_XOPEN_SOURCE_EXTENDED) || (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 >= 500))
#define NCURSES_WIDECHAR 1
#else
#define NCURSES_WIDECHAR 0
#endif
#endif /* NCURSES_WIDECHAR */
#include <stdarg.h> /* we need va_list */
#if NCURSES_WIDECHAR
#include <stddef.h> /* we want wchar_t */
#endif
/* X/Open and SVr4 specify that curses implements 'bool'. However, C++ may also
* implement it. If so, we must use the C++ compiler's type to avoid conflict
* with other interfaces.
*
* A further complication is that <stdbool.h> may declare 'bool' to be a
* different type, such as an enum which is not necessarily compatible with
* C++. If we have <stdbool.h>, make 'bool' a macro, so users may #undef it.
* Otherwise, let it remain a typedef to avoid conflicts with other #define's.
* In either case, make a typedef for NCURSES_BOOL which can be used if needed
* from either C or C++.
*/
#undef TRUE
#define TRUE 1
#undef FALSE
#define FALSE 0
typedef unsigned char NCURSES_BOOL;
#if defined(__cplusplus) /* __cplusplus, etc. */
/* use the C++ compiler's bool type */
#define NCURSES_BOOL bool
#else /* c89, c99, etc. */
#if NCURSES_ENABLE_STDBOOL_H
#include <stdbool.h>
/* use whatever the C compiler decides bool really is */
#define NCURSES_BOOL bool
#else
/* there is no predefined bool - use our own */
#undef bool
#define bool NCURSES_BOOL
#endif
#endif /* !__cplusplus, etc. */
#ifdef __cplusplus
extern "C" {
#define NCURSES_CAST(type,value) static_cast<type>(value)
#else
#define NCURSES_CAST(type,value) (type)(value)
#endif
#define NCURSES_OK_ADDR(p) (0 != NCURSES_CAST(const void *, (p)))
/*
* X/Open attributes. In the ncurses implementation, they are identical to the
* A_ attributes.
*/
#define WA_ATTRIBUTES A_ATTRIBUTES
#define WA_NORMAL A_NORMAL
#define WA_STANDOUT A_STANDOUT
#define WA_UNDERLINE A_UNDERLINE
#define WA_REVERSE A_REVERSE
#define WA_BLINK A_BLINK
#define WA_DIM A_DIM
#define WA_BOLD A_BOLD
#define WA_ALTCHARSET A_ALTCHARSET
#define WA_INVIS A_INVIS
#define WA_PROTECT A_PROTECT
#define WA_HORIZONTAL A_HORIZONTAL
#define WA_LEFT A_LEFT
#define WA_LOW A_LOW
#define WA_RIGHT A_RIGHT
#define WA_TOP A_TOP
#define WA_VERTICAL A_VERTICAL
#if 1
#define WA_ITALIC A_ITALIC /* ncurses extension */
#endif
/* colors */
#define COLOR_BLACK 0
#define COLOR_RED 1
#define COLOR_GREEN 2
#define COLOR_YELLOW 3
#define COLOR_BLUE 4
#define COLOR_MAGENTA 5
#define COLOR_CYAN 6
#define COLOR_WHITE 7
/* line graphics */
#if 0 || NCURSES_REENTRANT
NCURSES_WRAPPED_VAR(chtype*, acs_map);
#define acs_map NCURSES_PUBLIC_VAR(acs_map())
#else
extern NCURSES_EXPORT_VAR(chtype) acs_map[];
#endif
#define NCURSES_ACS(c) (acs_map[NCURSES_CAST(unsigned char,(c))])
/* VT100 symbols begin here */
#define ACS_ULCORNER NCURSES_ACS('l') /* upper left corner */
#define ACS_LLCORNER NCURSES_ACS('m') /* lower left corner */
#define ACS_URCORNER NCURSES_ACS('k') /* upper right corner */
#define ACS_LRCORNER NCURSES_ACS('j') /* lower right corner */
#define ACS_LTEE NCURSES_ACS('t') /* tee pointing right */
#define ACS_RTEE NCURSES_ACS('u') /* tee pointing left */
#define ACS_BTEE NCURSES_ACS('v') /* tee pointing up */
#define ACS_TTEE NCURSES_ACS('w') /* tee pointing down */
#define ACS_HLINE NCURSES_ACS('q') /* horizontal line */
#define ACS_VLINE NCURSES_ACS('x') /* vertical line */
#define ACS_PLUS NCURSES_ACS('n') /* large plus or crossover */
#define ACS_S1 NCURSES_ACS('o') /* scan line 1 */
#define ACS_S9 NCURSES_ACS('s') /* scan line 9 */
#define ACS_DIAMOND NCURSES_ACS('`') /* diamond */
#define ACS_CKBOARD NCURSES_ACS('a') /* checker board (stipple) */
#define ACS_DEGREE NCURSES_ACS('f') /* degree symbol */
#define ACS_PLMINUS NCURSES_ACS('g') /* plus/minus */
#define ACS_BULLET NCURSES_ACS('~') /* bullet */
/* Teletype 5410v1 symbols begin here */
#define ACS_LARROW NCURSES_ACS(',') /* arrow pointing left */
#define ACS_RARROW NCURSES_ACS('+') /* arrow pointing right */
#define ACS_DARROW NCURSES_ACS('.') /* arrow pointing down */
#define ACS_UARROW NCURSES_ACS('-') /* arrow pointing up */
#define ACS_BOARD NCURSES_ACS('h') /* board of squares */
#define ACS_LANTERN NCURSES_ACS('i') /* lantern symbol */
#define ACS_BLOCK NCURSES_ACS('0') /* solid square block */
/*
* These aren't documented, but a lot of System Vs have them anyway
* (you can spot pprryyzz{{||}} in a lot of AT&T terminfo strings).
* The ACS_names may not match AT&T's, our source didn't know them.
*/
#define ACS_S3 NCURSES_ACS('p') /* scan line 3 */
#define ACS_S7 NCURSES_ACS('r') /* scan line 7 */
#define ACS_LEQUAL NCURSES_ACS('y') /* less/equal */
#define ACS_GEQUAL NCURSES_ACS('z') /* greater/equal */
#define ACS_PI NCURSES_ACS('{') /* Pi */
#define ACS_NEQUAL NCURSES_ACS('|') /* not equal */
#define ACS_STERLING NCURSES_ACS('}') /* UK pound sign */
/*
* Line drawing ACS names are of the form ACS_trbl, where t is the top, r
* is the right, b is the bottom, and l is the left. t, r, b, and l might
* be B (blank), S (single), D (double), or T (thick). The subset defined
* here only uses B and S.
*/
#define ACS_BSSB ACS_ULCORNER
#define ACS_SSBB ACS_LLCORNER
#define ACS_BBSS ACS_URCORNER
#define ACS_SBBS ACS_LRCORNER
#define ACS_SBSS ACS_RTEE
#define ACS_SSSB ACS_LTEE
#define ACS_SSBS ACS_BTEE
#define ACS_BSSS ACS_TTEE
#define ACS_BSBS ACS_HLINE
#define ACS_SBSB ACS_VLINE
#define ACS_SSSS ACS_PLUS
#undef ERR
#define ERR (-1)
#undef OK
#define OK (0)
/* values for the _flags member */
#define _SUBWIN 0x01 /* is this a sub-window? */
#define _ENDLINE 0x02 /* is the window flush right? */
#define _FULLWIN 0x04 /* is the window full-screen? */
#define _SCROLLWIN 0x08 /* bottom edge is at screen bottom? */
#define _ISPAD 0x10 /* is this window a pad? */
#define _HASMOVED 0x20 /* has cursor moved since last refresh? */
#define _WRAPPED 0x40 /* cursor was just wrappped */
/*
* this value is used in the firstchar and lastchar fields to mark
* unchanged lines
*/
#define _NOCHANGE -1
/*
* this value is used in the oldindex field to mark lines created by insertions
* and scrolls.
*/
#define _NEWINDEX -1
typedef struct screen SCREEN;
typedef struct _win_st WINDOW;
typedef chtype attr_t; /* ...must be at least as wide as chtype */
#if NCURSES_WIDECHAR
#if 0
#ifdef mblen /* libutf8.h defines it w/o undefining first */
#undef mblen
#endif
#include <libutf8.h>
#endif
#if 1
#include <wchar.h> /* ...to get mbstate_t, etc. */
#endif
#if 0
typedef unsigned short wchar_t1;
#endif
#if 0
typedef unsigned int wint_t1;
#endif
/*
* cchar_t stores an array of CCHARW_MAX wide characters. The first is
* normally a spacing character. The others are non-spacing. If those
* (spacing and nonspacing) do not fill the array, a null L'\0' follows.
* Otherwise, a null is assumed to follow when extracting via getcchar().
*/
#define CCHARW_MAX 5
typedef struct
{
attr_t attr;
wchar_t chars[CCHARW_MAX];
#if 1
#undef NCURSES_EXT_COLORS
#define NCURSES_EXT_COLORS 20180224
int ext_color; /* color pair, must be more than 16-bits */
#endif
}
cchar_t;
#endif /* NCURSES_WIDECHAR */
#if !NCURSES_OPAQUE
struct ldat;
struct _win_st
{
NCURSES_SIZE_T _cury, _curx; /* current cursor position */
/* window location and size */
NCURSES_SIZE_T _maxy, _maxx; /* maximums of x and y, NOT window size */
NCURSES_SIZE_T _begy, _begx; /* screen coords of upper-left-hand corner */
short _flags; /* window state flags */
/* attribute tracking */
attr_t _attrs; /* current attribute for non-space character */
chtype _bkgd; /* current background char/attribute pair */
/* option values set by user */
bool _notimeout; /* no time out on function-key entry? */
bool _clear; /* consider all data in the window invalid? */
bool _leaveok; /* OK to not reset cursor on exit? */
bool _scroll; /* OK to scroll this window? */
bool _idlok; /* OK to use insert/delete line? */
bool _idcok; /* OK to use insert/delete char? */
bool _immed; /* window in immed mode? (not yet used) */
bool _sync; /* window in sync mode? */
bool _use_keypad; /* process function keys into KEY_ symbols? */
int _delay; /* 0 = nodelay, <0 = blocking, >0 = delay */
struct ldat *_line; /* the actual line data */
/* global screen state */
NCURSES_SIZE_T _regtop; /* top line of scrolling region */
NCURSES_SIZE_T _regbottom; /* bottom line of scrolling region */
/* these are used only if this is a sub-window */
int _parx; /* x coordinate of this window in parent */
int _pary; /* y coordinate of this window in parent */
WINDOW *_parent; /* pointer to parent if a sub-window */
/* these are used only if this is a pad */
struct pdat
{
NCURSES_SIZE_T _pad_y, _pad_x;
NCURSES_SIZE_T _pad_top, _pad_left;
NCURSES_SIZE_T _pad_bottom, _pad_right;
} _pad;
NCURSES_SIZE_T _yoffset; /* real begy is _begy + _yoffset */
#if NCURSES_WIDECHAR
cchar_t _bkgrnd; /* current background char/attribute pair */
#if 1
int _color; /* current color-pair for non-space character */
#endif
#endif
};
#endif /* NCURSES_OPAQUE */
/*
* This is an extension to support events...
*/
#if 1
#ifdef NCURSES_WGETCH_EVENTS
#if !defined(__BEOS__) || defined(__HAIKU__)
/* Fix _nc_timed_wait() on BEOS... */
# define NCURSES_EVENT_VERSION 1
#endif /* !defined(__BEOS__) */
/*
* Bits to set in _nc_event.data.flags
*/
# define _NC_EVENT_TIMEOUT_MSEC 1
# define _NC_EVENT_FILE 2
# define _NC_EVENT_FILE_READABLE 2
# if 0 /* Not supported yet... */
# define _NC_EVENT_FILE_WRITABLE 4
# define _NC_EVENT_FILE_EXCEPTION 8
# endif
typedef struct
{
int type;
union
{
long timeout_msec; /* _NC_EVENT_TIMEOUT_MSEC */
struct
{
unsigned int flags;
int fd;
unsigned int result;
} fev; /* _NC_EVENT_FILE */
} data;
} _nc_event;
typedef struct
{
int count;
int result_flags; /* _NC_EVENT_TIMEOUT_MSEC or _NC_EVENT_FILE_READABLE */
_nc_event *events[1];
} _nc_eventlist;
extern NCURSES_EXPORT(int) wgetch_events (WINDOW *, _nc_eventlist *); /* experimental */
extern NCURSES_EXPORT(int) wgetnstr_events (WINDOW *,char *,int,_nc_eventlist *);/* experimental */
#endif /* NCURSES_WGETCH_EVENTS */
#endif /* NCURSES_EXT_FUNCS */
/*
* GCC (and some other compilers) define '__attribute__'; we're using this
* macro to alert the compiler to flag inconsistencies in printf/scanf-like
* function calls. Just in case '__attribute__' isn't defined, make a dummy.
* Old versions of G++ do not accept it anyway, at least not consistently with
* GCC.
*/
#if !(defined(__GNUC__) || defined(__GNUG__) || defined(__attribute__))
#define __attribute__(p) /* nothing */
#endif
/*
* We cannot define these in ncurses_cfg.h, since they require parameters to be
* passed (that is non-portable). If you happen to be using gcc with warnings
* enabled, define
* GCC_PRINTF
* GCC_SCANF
* to improve checking of calls to printw(), etc.
*/
#ifndef GCC_PRINTFLIKE
#if defined(GCC_PRINTF) && !defined(printf)
#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
#else
#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
#endif
#endif
#ifndef GCC_SCANFLIKE
#if defined(GCC_SCANF) && !defined(scanf)
#define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
#else
#define GCC_SCANFLIKE(fmt,var) /*nothing*/
#endif
#endif
#ifndef GCC_NORETURN
#define GCC_NORETURN /* nothing */
#endif
#ifndef GCC_UNUSED
#define GCC_UNUSED /* nothing */
#endif
/*
* Curses uses a helper function. Define our type for this to simplify
* extending it for the sp-funcs feature.
*/
typedef int (*NCURSES_OUTC)(int);
/*
* Function prototypes. This is the complete X/Open Curses list of required
* functions. Those marked `generated' will have sources generated from the
* macro definitions later in this file, in order to satisfy XPG4.2
* requirements.
*/
extern NCURSES_EXPORT(int) addch (const chtype); /* generated */
extern NCURSES_EXPORT(int) addchnstr (const chtype *, int); /* generated */
extern NCURSES_EXPORT(int) addchstr (const chtype *); /* generated */
extern NCURSES_EXPORT(int) addnstr (const char *, int); /* generated */
extern NCURSES_EXPORT(int) addstr (const char *); /* generated */
extern NCURSES_EXPORT(int) attroff (NCURSES_ATTR_T); /* generated */
extern NCURSES_EXPORT(int) attron (NCURSES_ATTR_T); /* generated */
extern NCURSES_EXPORT(int) attrset (NCURSES_ATTR_T); /* generated */
extern NCURSES_EXPORT(int) attr_get (attr_t *, NCURSES_PAIRS_T *, void *); /* generated */
extern NCURSES_EXPORT(int) attr_off (attr_t, void *); /* generated */
extern NCURSES_EXPORT(int) attr_on (attr_t, void *); /* generated */
extern NCURSES_EXPORT(int) attr_set (attr_t, NCURSES_PAIRS_T, void *); /* generated */
extern NCURSES_EXPORT(int) baudrate (void); /* implemented */
extern NCURSES_EXPORT(int) beep (void); /* implemented */
extern NCURSES_EXPORT(int) bkgd (chtype); /* generated */
extern NCURSES_EXPORT(void) bkgdset (chtype); /* generated */
extern NCURSES_EXPORT(int) border (chtype,chtype,chtype,chtype,chtype,chtype,chtype,chtype); /* generated */
extern NCURSES_EXPORT(int) box (WINDOW *, chtype, chtype); /* generated */
extern NCURSES_EXPORT(bool) can_change_color (void); /* implemented */
extern NCURSES_EXPORT(int) cbreak (void); /* implemented */
extern NCURSES_EXPORT(int) chgat (int, attr_t, NCURSES_PAIRS_T, const void *); /* generated */
extern NCURSES_EXPORT(int) clear (void); /* generated */
extern NCURSES_EXPORT(int) clearok (WINDOW *,bool); /* implemented */
extern NCURSES_EXPORT(int) clrtobot (void); /* generated */
extern NCURSES_EXPORT(int) clrtoeol (void); /* generated */
extern NCURSES_EXPORT(int) color_content (NCURSES_COLOR_T,NCURSES_COLOR_T*,NCURSES_COLOR_T*,NCURSES_COLOR_T*); /* implemented */
extern NCURSES_EXPORT(int) color_set (NCURSES_PAIRS_T,void*); /* generated */
extern NCURSES_EXPORT(int) COLOR_PAIR (int); /* generated */
extern NCURSES_EXPORT(int) copywin (const WINDOW*,WINDOW*,int,int,int,int,int,int,int); /* implemented */
extern NCURSES_EXPORT(int) curs_set (int); /* implemented */
extern NCURSES_EXPORT(int) def_prog_mode (void); /* implemented */
extern NCURSES_EXPORT(int) def_shell_mode (void); /* implemented */
extern NCURSES_EXPORT(int) delay_output (int); /* implemented */
extern NCURSES_EXPORT(int) delch (void); /* generated */
extern NCURSES_EXPORT(void) delscreen (SCREEN *); /* implemented */
extern NCURSES_EXPORT(int) delwin (WINDOW *); /* implemented */
extern NCURSES_EXPORT(int) deleteln (void); /* generated */
extern NCURSES_EXPORT(WINDOW *) derwin (WINDOW *,int,int,int,int); /* implemented */
extern NCURSES_EXPORT(int) doupdate (void); /* implemented */
extern NCURSES_EXPORT(WINDOW *) dupwin (WINDOW *); /* implemented */
extern NCURSES_EXPORT(int) echo (void); /* implemented */
extern NCURSES_EXPORT(int) echochar (const chtype); /* generated */
extern NCURSES_EXPORT(int) erase (void); /* generated */
extern NCURSES_EXPORT(int) endwin (void); /* implemented */
extern NCURSES_EXPORT(char) erasechar (void); /* implemented */
extern NCURSES_EXPORT(void) filter (void); /* implemented */
extern NCURSES_EXPORT(int) flash (void); /* implemented */
extern NCURSES_EXPORT(int) flushinp (void); /* implemented */
extern NCURSES_EXPORT(chtype) getbkgd (WINDOW *); /* generated */
extern NCURSES_EXPORT(int) getch (void); /* generated */
extern NCURSES_EXPORT(int) getnstr (char *, int); /* generated */
extern NCURSES_EXPORT(int) getstr (char *); /* generated */
extern NCURSES_EXPORT(WINDOW *) getwin (FILE *); /* implemented */
extern NCURSES_EXPORT(int) halfdelay (int); /* implemented */
extern NCURSES_EXPORT(bool) has_colors (void); /* implemented */
extern NCURSES_EXPORT(bool) has_ic (void); /* implemented */
extern NCURSES_EXPORT(bool) has_il (void); /* implemented */
extern NCURSES_EXPORT(int) hline (chtype, int); /* generated */
extern NCURSES_EXPORT(void) idcok (WINDOW *, bool); /* implemented */
extern NCURSES_EXPORT(int) idlok (WINDOW *, bool); /* implemented */
extern NCURSES_EXPORT(void) immedok (WINDOW *, bool); /* implemented */
extern NCURSES_EXPORT(chtype) inch (void); /* generated */
extern NCURSES_EXPORT(int) inchnstr (chtype *, int); /* generated */
extern NCURSES_EXPORT(int) inchstr (chtype *); /* generated */
extern NCURSES_EXPORT(WINDOW *) initscr (void); /* implemented */
extern NCURSES_EXPORT(int) init_color (NCURSES_COLOR_T,NCURSES_COLOR_T,NCURSES_COLOR_T,NCURSES_COLOR_T); /* implemented */
extern NCURSES_EXPORT(int) init_pair (NCURSES_PAIRS_T,NCURSES_COLOR_T,NCURSES_COLOR_T); /* implemented */
extern NCURSES_EXPORT(int) innstr (char *, int); /* generated */
extern NCURSES_EXPORT(int) insch (chtype); /* generated */
extern NCURSES_EXPORT(int) insdelln (int); /* generated */
extern NCURSES_EXPORT(int) insertln (void); /* generated */
extern NCURSES_EXPORT(int) insnstr (const char *, int); /* generated */
extern NCURSES_EXPORT(int) insstr (const char *); /* generated */
extern NCURSES_EXPORT(int) instr (char *); /* generated */
extern NCURSES_EXPORT(int) intrflush (WINDOW *,bool); /* implemented */
extern NCURSES_EXPORT(bool) isendwin (void); /* implemented */
extern NCURSES_EXPORT(bool) is_linetouched (WINDOW *,int); /* implemented */
extern NCURSES_EXPORT(bool) is_wintouched (WINDOW *); /* implemented */
extern NCURSES_EXPORT(NCURSES_CONST char *) keyname (int); /* implemented */
extern NCURSES_EXPORT(int) keypad (WINDOW *,bool); /* implemented */
extern NCURSES_EXPORT(char) killchar (void); /* implemented */
extern NCURSES_EXPORT(int) leaveok (WINDOW *,bool); /* implemented */
extern NCURSES_EXPORT(char *) longname (void); /* implemented */
extern NCURSES_EXPORT(int) meta (WINDOW *,bool); /* implemented */
extern NCURSES_EXPORT(int) move (int, int); /* generated */
extern NCURSES_EXPORT(int) mvaddch (int, int, const chtype); /* generated */
extern NCURSES_EXPORT(int) mvaddchnstr (int, int, const chtype *, int); /* generated */
extern NCURSES_EXPORT(int) mvaddchstr (int, int, const chtype *); /* generated */
extern NCURSES_EXPORT(int) mvaddnstr (int, int, const char *, int); /* generated */
extern NCURSES_EXPORT(int) mvaddstr (int, int, const char *); /* generated */
extern NCURSES_EXPORT(int) mvchgat (int, int, int, attr_t, NCURSES_PAIRS_T, const void *); /* generated */
extern NCURSES_EXPORT(int) mvcur (int,int,int,int); /* implemented */
extern NCURSES_EXPORT(int) mvdelch (int, int); /* generated */
extern NCURSES_EXPORT(int) mvderwin (WINDOW *, int, int); /* implemented */
extern NCURSES_EXPORT(int) mvgetch (int, int); /* generated */
extern NCURSES_EXPORT(int) mvgetnstr (int, int, char *, int); /* generated */
extern NCURSES_EXPORT(int) mvgetstr (int, int, char *); /* generated */
extern NCURSES_EXPORT(int) mvhline (int, int, chtype, int); /* generated */
extern NCURSES_EXPORT(chtype) mvinch (int, int); /* generated */
extern NCURSES_EXPORT(int) mvinchnstr (int, int, chtype *, int); /* generated */
extern NCURSES_EXPORT(int) mvinchstr (int, int, chtype *); /* generated */
extern NCURSES_EXPORT(int) mvinnstr (int, int, char *, int); /* generated */
extern NCURSES_EXPORT(int) mvinsch (int, int, chtype); /* generated */
extern NCURSES_EXPORT(int) mvinsnstr (int, int, const char *, int); /* generated */
extern NCURSES_EXPORT(int) mvinsstr (int, int, const char *); /* generated */
extern NCURSES_EXPORT(int) mvinstr (int, int, char *); /* generated */
extern NCURSES_EXPORT(int) mvprintw (int,int, const char *,...) /* implemented */
GCC_PRINTFLIKE(3,4);
extern NCURSES_EXPORT(int) mvscanw (int,int, NCURSES_CONST char *,...) /* implemented */
GCC_SCANFLIKE(3,4);
extern NCURSES_EXPORT(int) mvvline (int, int, chtype, int); /* generated */
extern NCURSES_EXPORT(int) mvwaddch (WINDOW *, int, int, const chtype); /* generated */
extern NCURSES_EXPORT(int) mvwaddchnstr (WINDOW *, int, int, const chtype *, int);/* generated */
extern NCURSES_EXPORT(int) mvwaddchstr (WINDOW *, int, int, const chtype *); /* generated */
extern NCURSES_EXPORT(int) mvwaddnstr (WINDOW *, int, int, const char *, int); /* generated */
extern NCURSES_EXPORT(int) mvwaddstr (WINDOW *, int, int, const char *); /* generated */
extern NCURSES_EXPORT(int) mvwchgat (WINDOW *, int, int, int, attr_t, NCURSES_PAIRS_T, const void *);/* generated */
extern NCURSES_EXPORT(int) mvwdelch (WINDOW *, int, int); /* generated */
extern NCURSES_EXPORT(int) mvwgetch (WINDOW *, int, int); /* generated */
extern NCURSES_EXPORT(int) mvwgetnstr (WINDOW *, int, int, char *, int); /* generated */
extern NCURSES_EXPORT(int) mvwgetstr (WINDOW *, int, int, char *); /* generated */
extern NCURSES_EXPORT(int) mvwhline (WINDOW *, int, int, chtype, int); /* generated */
extern NCURSES_EXPORT(int) mvwin (WINDOW *,int,int); /* implemented */
extern NCURSES_EXPORT(chtype) mvwinch (WINDOW *, int, int); /* generated */
extern NCURSES_EXPORT(int) mvwinchnstr (WINDOW *, int, int, chtype *, int); /* generated */
extern NCURSES_EXPORT(int) mvwinchstr (WINDOW *, int, int, chtype *); /* generated */
extern NCURSES_EXPORT(int) mvwinnstr (WINDOW *, int, int, char *, int); /* generated */
extern NCURSES_EXPORT(int) mvwinsch (WINDOW *, int, int, chtype); /* generated */
extern NCURSES_EXPORT(int) mvwinsnstr (WINDOW *, int, int, const char *, int); /* generated */
extern NCURSES_EXPORT(int) mvwinsstr (WINDOW *, int, int, const char *); /* generated */
extern NCURSES_EXPORT(int) mvwinstr (WINDOW *, int, int, char *); /* generated */
extern NCURSES_EXPORT(int) mvwprintw (WINDOW*,int,int, const char *,...) /* implemented */
GCC_PRINTFLIKE(4,5);
extern NCURSES_EXPORT(int) mvwscanw (WINDOW *,int,int, NCURSES_CONST char *,...) /* implemented */
GCC_SCANFLIKE(4,5);
extern NCURSES_EXPORT(int) mvwvline (WINDOW *,int, int, chtype, int); /* generated */
extern NCURSES_EXPORT(int) napms (int); /* implemented */
extern NCURSES_EXPORT(WINDOW *) newpad (int,int); /* implemented */
extern NCURSES_EXPORT(SCREEN *) newterm (NCURSES_CONST char *,FILE *,FILE *); /* implemented */
extern NCURSES_EXPORT(WINDOW *) newwin (int,int,int,int); /* implemented */
extern NCURSES_EXPORT(int) nl (void); /* implemented */
extern NCURSES_EXPORT(int) nocbreak (void); /* implemented */
extern NCURSES_EXPORT(int) nodelay (WINDOW *,bool); /* implemented */
extern NCURSES_EXPORT(int) noecho (void); /* implemented */
extern NCURSES_EXPORT(int) nonl (void); /* implemented */
extern NCURSES_EXPORT(void) noqiflush (void); /* implemented */
extern NCURSES_EXPORT(int) noraw (void); /* implemented */
extern NCURSES_EXPORT(int) notimeout (WINDOW *,bool); /* implemented */
extern NCURSES_EXPORT(int) overlay (const WINDOW*,WINDOW *); /* implemented */
extern NCURSES_EXPORT(int) overwrite (const WINDOW*,WINDOW *); /* implemented */
extern NCURSES_EXPORT(int) pair_content (NCURSES_PAIRS_T,NCURSES_COLOR_T*,NCURSES_COLOR_T*); /* implemented */
extern NCURSES_EXPORT(int) PAIR_NUMBER (int); /* generated */
extern NCURSES_EXPORT(int) pechochar (WINDOW *, const chtype); /* implemented */
extern NCURSES_EXPORT(int) pnoutrefresh (WINDOW*,int,int,int,int,int,int);/* implemented */
extern NCURSES_EXPORT(int) prefresh (WINDOW *,int,int,int,int,int,int); /* implemented */
extern NCURSES_EXPORT(int) printw (const char *,...) /* implemented */
GCC_PRINTFLIKE(1,2);
extern NCURSES_EXPORT(int) putwin (WINDOW *, FILE *); /* implemented */
extern NCURSES_EXPORT(void) qiflush (void); /* implemented */
extern NCURSES_EXPORT(int) raw (void); /* implemented */
extern NCURSES_EXPORT(int) redrawwin (WINDOW *); /* generated */
extern NCURSES_EXPORT(int) refresh (void); /* generated */
extern NCURSES_EXPORT(int) resetty (void); /* implemented */
extern NCURSES_EXPORT(int) reset_prog_mode (void); /* implemented */
extern NCURSES_EXPORT(int) reset_shell_mode (void); /* implemented */
extern NCURSES_EXPORT(int) ripoffline (int, int (*)(WINDOW *, int)); /* implemented */
extern NCURSES_EXPORT(int) savetty (void); /* implemented */
extern NCURSES_EXPORT(int) scanw (NCURSES_CONST char *,...) /* implemented */
GCC_SCANFLIKE(1,2);
extern NCURSES_EXPORT(int) scr_dump (const char *); /* implemented */
extern NCURSES_EXPORT(int) scr_init (const char *); /* implemented */
extern NCURSES_EXPORT(int) scrl (int); /* generated */
extern NCURSES_EXPORT(int) scroll (WINDOW *); /* generated */
extern NCURSES_EXPORT(int) scrollok (WINDOW *,bool); /* implemented */
extern NCURSES_EXPORT(int) scr_restore (const char *); /* implemented */
extern NCURSES_EXPORT(int) scr_set (const char *); /* implemented */
extern NCURSES_EXPORT(int) setscrreg (int,int); /* generated */
extern NCURSES_EXPORT(SCREEN *) set_term (SCREEN *); /* implemented */
extern NCURSES_EXPORT(int) slk_attroff (const chtype); /* implemented */
extern NCURSES_EXPORT(int) slk_attr_off (const attr_t, void *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) slk_attron (const chtype); /* implemented */
extern NCURSES_EXPORT(int) slk_attr_on (attr_t,void*); /* generated:WIDEC */
extern NCURSES_EXPORT(int) slk_attrset (const chtype); /* implemented */
extern NCURSES_EXPORT(attr_t) slk_attr (void); /* implemented */
extern NCURSES_EXPORT(int) slk_attr_set (const attr_t,NCURSES_PAIRS_T,void*); /* implemented */
extern NCURSES_EXPORT(int) slk_clear (void); /* implemented */
extern NCURSES_EXPORT(int) slk_color (NCURSES_PAIRS_T); /* implemented */
extern NCURSES_EXPORT(int) slk_init (int); /* implemented */
extern NCURSES_EXPORT(char *) slk_label (int); /* implemented */
extern NCURSES_EXPORT(int) slk_noutrefresh (void); /* implemented */
extern NCURSES_EXPORT(int) slk_refresh (void); /* implemented */
extern NCURSES_EXPORT(int) slk_restore (void); /* implemented */
extern NCURSES_EXPORT(int) slk_set (int,const char *,int); /* implemented */
extern NCURSES_EXPORT(int) slk_touch (void); /* implemented */
extern NCURSES_EXPORT(int) standout (void); /* generated */
extern NCURSES_EXPORT(int) standend (void); /* generated */
extern NCURSES_EXPORT(int) start_color (void); /* implemented */
extern NCURSES_EXPORT(WINDOW *) subpad (WINDOW *, int, int, int, int); /* implemented */
extern NCURSES_EXPORT(WINDOW *) subwin (WINDOW *, int, int, int, int); /* implemented */
extern NCURSES_EXPORT(int) syncok (WINDOW *, bool); /* implemented */
extern NCURSES_EXPORT(chtype) termattrs (void); /* implemented */
extern NCURSES_EXPORT(char *) termname (void); /* implemented */
extern NCURSES_EXPORT(void) timeout (int); /* generated */
extern NCURSES_EXPORT(int) touchline (WINDOW *, int, int); /* generated */
extern NCURSES_EXPORT(int) touchwin (WINDOW *); /* generated */
extern NCURSES_EXPORT(int) typeahead (int); /* implemented */
extern NCURSES_EXPORT(int) ungetch (int); /* implemented */
extern NCURSES_EXPORT(int) untouchwin (WINDOW *); /* generated */
extern NCURSES_EXPORT(void) use_env (bool); /* implemented */
extern NCURSES_EXPORT(void) use_tioctl (bool); /* implemented */
extern NCURSES_EXPORT(int) vidattr (chtype); /* implemented */
extern NCURSES_EXPORT(int) vidputs (chtype, NCURSES_OUTC); /* implemented */
extern NCURSES_EXPORT(int) vline (chtype, int); /* generated */
extern NCURSES_EXPORT(int) vwprintw (WINDOW *, const char *,va_list); /* implemented */
extern NCURSES_EXPORT(int) vw_printw (WINDOW *, const char *,va_list); /* generated */
extern NCURSES_EXPORT(int) vwscanw (WINDOW *, NCURSES_CONST char *,va_list); /* implemented */
extern NCURSES_EXPORT(int) vw_scanw (WINDOW *, NCURSES_CONST char *,va_list); /* generated */
extern NCURSES_EXPORT(int) waddch (WINDOW *, const chtype); /* implemented */
extern NCURSES_EXPORT(int) waddchnstr (WINDOW *,const chtype *,int); /* implemented */
extern NCURSES_EXPORT(int) waddchstr (WINDOW *,const chtype *); /* generated */
extern NCURSES_EXPORT(int) waddnstr (WINDOW *,const char *,int); /* implemented */
extern NCURSES_EXPORT(int) waddstr (WINDOW *,const char *); /* generated */
extern NCURSES_EXPORT(int) wattron (WINDOW *, int); /* generated */
extern NCURSES_EXPORT(int) wattroff (WINDOW *, int); /* generated */
extern NCURSES_EXPORT(int) wattrset (WINDOW *, int); /* generated */
extern NCURSES_EXPORT(int) wattr_get (WINDOW *, attr_t *, NCURSES_PAIRS_T *, void *); /* generated */
extern NCURSES_EXPORT(int) wattr_on (WINDOW *, attr_t, void *); /* implemented */
extern NCURSES_EXPORT(int) wattr_off (WINDOW *, attr_t, void *); /* implemented */
extern NCURSES_EXPORT(int) wattr_set (WINDOW *, attr_t, NCURSES_PAIRS_T, void *); /* generated */
extern NCURSES_EXPORT(int) wbkgd (WINDOW *, chtype); /* implemented */
extern NCURSES_EXPORT(void) wbkgdset (WINDOW *,chtype); /* implemented */
extern NCURSES_EXPORT(int) wborder (WINDOW *,chtype,chtype,chtype,chtype,chtype,chtype,chtype,chtype); /* implemented */
extern NCURSES_EXPORT(int) wchgat (WINDOW *, int, attr_t, NCURSES_PAIRS_T, const void *);/* implemented */
extern NCURSES_EXPORT(int) wclear (WINDOW *); /* implemented */
extern NCURSES_EXPORT(int) wclrtobot (WINDOW *); /* implemented */
extern NCURSES_EXPORT(int) wclrtoeol (WINDOW *); /* implemented */
extern NCURSES_EXPORT(int) wcolor_set (WINDOW*,NCURSES_PAIRS_T,void*); /* implemented */
extern NCURSES_EXPORT(void) wcursyncup (WINDOW *); /* implemented */
extern NCURSES_EXPORT(int) wdelch (WINDOW *); /* implemented */
extern NCURSES_EXPORT(int) wdeleteln (WINDOW *); /* generated */
extern NCURSES_EXPORT(int) wechochar (WINDOW *, const chtype); /* implemented */
extern NCURSES_EXPORT(int) werase (WINDOW *); /* implemented */
extern NCURSES_EXPORT(int) wgetch (WINDOW *); /* implemented */
extern NCURSES_EXPORT(int) wgetnstr (WINDOW *,char *,int); /* implemented */
extern NCURSES_EXPORT(int) wgetstr (WINDOW *, char *); /* generated */
extern NCURSES_EXPORT(int) whline (WINDOW *, chtype, int); /* implemented */
extern NCURSES_EXPORT(chtype) winch (WINDOW *); /* implemented */
extern NCURSES_EXPORT(int) winchnstr (WINDOW *, chtype *, int); /* implemented */
extern NCURSES_EXPORT(int) winchstr (WINDOW *, chtype *); /* generated */
extern NCURSES_EXPORT(int) winnstr (WINDOW *, char *, int); /* implemented */
extern NCURSES_EXPORT(int) winsch (WINDOW *, chtype); /* implemented */
extern NCURSES_EXPORT(int) winsdelln (WINDOW *,int); /* implemented */
extern NCURSES_EXPORT(int) winsertln (WINDOW *); /* generated */
extern NCURSES_EXPORT(int) winsnstr (WINDOW *, const char *,int); /* implemented */
extern NCURSES_EXPORT(int) winsstr (WINDOW *, const char *); /* generated */
extern NCURSES_EXPORT(int) winstr (WINDOW *, char *); /* generated */
extern NCURSES_EXPORT(int) wmove (WINDOW *,int,int); /* implemented */
extern NCURSES_EXPORT(int) wnoutrefresh (WINDOW *); /* implemented */
extern NCURSES_EXPORT(int) wprintw (WINDOW *, const char *,...) /* implemented */
GCC_PRINTFLIKE(2,3);
extern NCURSES_EXPORT(int) wredrawln (WINDOW *,int,int); /* implemented */
extern NCURSES_EXPORT(int) wrefresh (WINDOW *); /* implemented */
extern NCURSES_EXPORT(int) wscanw (WINDOW *, NCURSES_CONST char *,...) /* implemented */
GCC_SCANFLIKE(2,3);
extern NCURSES_EXPORT(int) wscrl (WINDOW *,int); /* implemented */
extern NCURSES_EXPORT(int) wsetscrreg (WINDOW *,int,int); /* implemented */
extern NCURSES_EXPORT(int) wstandout (WINDOW *); /* generated */
extern NCURSES_EXPORT(int) wstandend (WINDOW *); /* generated */
extern NCURSES_EXPORT(void) wsyncdown (WINDOW *); /* implemented */
extern NCURSES_EXPORT(void) wsyncup (WINDOW *); /* implemented */
extern NCURSES_EXPORT(void) wtimeout (WINDOW *,int); /* implemented */
extern NCURSES_EXPORT(int) wtouchln (WINDOW *,int,int,int); /* implemented */
extern NCURSES_EXPORT(int) wvline (WINDOW *,chtype,int); /* implemented */
/*
* These are also declared in <term.h>:
*/
extern NCURSES_EXPORT(int) tigetflag (NCURSES_CONST char *); /* implemented */
extern NCURSES_EXPORT(int) tigetnum (NCURSES_CONST char *); /* implemented */
extern NCURSES_EXPORT(char *) tigetstr (NCURSES_CONST char *); /* implemented */
extern NCURSES_EXPORT(int) putp (const char *); /* implemented */
#if NCURSES_TPARM_VARARGS
extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, ...); /* special */
#else
extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG); /* special */
extern NCURSES_EXPORT(char *) tparm_varargs (NCURSES_CONST char *, ...); /* special */
#endif
extern NCURSES_EXPORT(char *) tiparm (const char *, ...); /* special */
/*
* X/Open says this returns a bool; SVr4 also checked for out-of-range line.
* The macro provides compatibility:
*/
#define is_linetouched(w,l) ((!(w) || ((l) > getmaxy(w)) || ((l) < 0)) ? ERR : (is_linetouched)((w),(l)))
/*
* These functions are not in X/Open, but we use them in macro definitions:
*/
extern NCURSES_EXPORT(int) getattrs (const WINDOW *); /* generated */
extern NCURSES_EXPORT(int) getcurx (const WINDOW *); /* generated */
extern NCURSES_EXPORT(int) getcury (const WINDOW *); /* generated */
extern NCURSES_EXPORT(int) getbegx (const WINDOW *); /* generated */
extern NCURSES_EXPORT(int) getbegy (const WINDOW *); /* generated */
extern NCURSES_EXPORT(int) getmaxx (const WINDOW *); /* generated */
extern NCURSES_EXPORT(int) getmaxy (const WINDOW *); /* generated */
extern NCURSES_EXPORT(int) getparx (const WINDOW *); /* generated */
extern NCURSES_EXPORT(int) getpary (const WINDOW *); /* generated */
/*
* vid_attr() was implemented originally based on a draft of X/Open curses.
*/
#if !NCURSES_WIDECHAR
#define vid_attr(a,pair,opts) vidattr(a)
#endif
/*
* These functions are extensions - not in X/Open Curses.
*/
#if 1
#undef NCURSES_EXT_FUNCS
#define NCURSES_EXT_FUNCS 20180224
typedef int (*NCURSES_WINDOW_CB)(WINDOW *, void *);
typedef int (*NCURSES_SCREEN_CB)(SCREEN *, void *);
extern NCURSES_EXPORT(bool) is_term_resized (int, int);
extern NCURSES_EXPORT(char *) keybound (int, int);
extern NCURSES_EXPORT(const char *) curses_version (void);
extern NCURSES_EXPORT(int) alloc_pair (int, int);
extern NCURSES_EXPORT(int) assume_default_colors (int, int);
extern NCURSES_EXPORT(int) define_key (const char *, int);
extern NCURSES_EXPORT(int) extended_color_content(int, int *, int *, int *);
extern NCURSES_EXPORT(int) extended_pair_content(int, int *, int *);
extern NCURSES_EXPORT(int) extended_slk_color(int);
extern NCURSES_EXPORT(int) find_pair (int, int);
extern NCURSES_EXPORT(int) free_pair (int);
extern NCURSES_EXPORT(int) get_escdelay (void);
extern NCURSES_EXPORT(int) init_extended_color(int, int, int, int);
extern NCURSES_EXPORT(int) init_extended_pair(int, int, int);
extern NCURSES_EXPORT(int) key_defined (const char *);
extern NCURSES_EXPORT(int) keyok (int, bool);
extern NCURSES_EXPORT(void) reset_color_pairs (void);
extern NCURSES_EXPORT(int) resize_term (int, int);
extern NCURSES_EXPORT(int) resizeterm (int, int);
extern NCURSES_EXPORT(int) set_escdelay (int);
extern NCURSES_EXPORT(int) set_tabsize (int);
extern NCURSES_EXPORT(int) use_default_colors (void);
extern NCURSES_EXPORT(int) use_extended_names (bool);
extern NCURSES_EXPORT(int) use_legacy_coding (int);
extern NCURSES_EXPORT(int) use_screen (SCREEN *, NCURSES_SCREEN_CB, void *);
extern NCURSES_EXPORT(int) use_window (WINDOW *, NCURSES_WINDOW_CB, void *);
extern NCURSES_EXPORT(int) wresize (WINDOW *, int, int);
extern NCURSES_EXPORT(void) nofilter(void);
/*
* These extensions provide access to information stored in the WINDOW even
* when NCURSES_OPAQUE is set:
*/
extern NCURSES_EXPORT(WINDOW *) wgetparent (const WINDOW *); /* generated */
extern NCURSES_EXPORT(bool) is_cleared (const WINDOW *); /* generated */
extern NCURSES_EXPORT(bool) is_idcok (const WINDOW *); /* generated */
extern NCURSES_EXPORT(bool) is_idlok (const WINDOW *); /* generated */
extern NCURSES_EXPORT(bool) is_immedok (const WINDOW *); /* generated */
extern NCURSES_EXPORT(bool) is_keypad (const WINDOW *); /* generated */
extern NCURSES_EXPORT(bool) is_leaveok (const WINDOW *); /* generated */
extern NCURSES_EXPORT(bool) is_nodelay (const WINDOW *); /* generated */
extern NCURSES_EXPORT(bool) is_notimeout (const WINDOW *); /* generated */
extern NCURSES_EXPORT(bool) is_pad (const WINDOW *); /* generated */
extern NCURSES_EXPORT(bool) is_scrollok (const WINDOW *); /* generated */
extern NCURSES_EXPORT(bool) is_subwin (const WINDOW *); /* generated */
extern NCURSES_EXPORT(bool) is_syncok (const WINDOW *); /* generated */
extern NCURSES_EXPORT(int) wgetdelay (const WINDOW *); /* generated */
extern NCURSES_EXPORT(int) wgetscrreg (const WINDOW *, int *, int *); /* generated */
#else
#define curses_version() NCURSES_VERSION
#endif
/*
* Extra extension-functions, which pass a SCREEN pointer rather than using
* a global variable SP.
*/
#if 1
#undef NCURSES_SP_FUNCS
#define NCURSES_SP_FUNCS 20180224
#define NCURSES_SP_NAME(name) name##_sp
/* Define the sp-funcs helper function */
#define NCURSES_SP_OUTC NCURSES_SP_NAME(NCURSES_OUTC)
typedef int (*NCURSES_SP_OUTC)(SCREEN*, int);
extern NCURSES_EXPORT(SCREEN *) new_prescr (void); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(baudrate) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(beep) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(can_change_color) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(cbreak) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(curs_set) (SCREEN*, int); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(color_content) (SCREEN*, NCURSES_PAIRS_T, NCURSES_COLOR_T*, NCURSES_COLOR_T*, NCURSES_COLOR_T*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(def_prog_mode) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(def_shell_mode) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(delay_output) (SCREEN*, int); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(doupdate) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(echo) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(endwin) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(char) NCURSES_SP_NAME(erasechar) (SCREEN*);/* implemented:SP_FUNC */
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(filter) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(flash) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(flushinp) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(getwin) (SCREEN*, FILE *); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(halfdelay) (SCREEN*, int); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_colors) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_ic) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_il) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_color) (SCREEN*, NCURSES_COLOR_T, NCURSES_COLOR_T, NCURSES_COLOR_T, NCURSES_COLOR_T); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_pair) (SCREEN*, NCURSES_PAIRS_T, NCURSES_COLOR_T, NCURSES_COLOR_T); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(intrflush) (SCREEN*, WINDOW*, bool); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(isendwin) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(NCURSES_CONST char *) NCURSES_SP_NAME(keyname) (SCREEN*, int); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(char) NCURSES_SP_NAME(killchar) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(longname) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(mvcur) (SCREEN*, int, int, int, int); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(napms) (SCREEN*, int); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(newpad) (SCREEN*, int, int); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(SCREEN *) NCURSES_SP_NAME(newterm) (SCREEN*, NCURSES_CONST char *, FILE *, FILE *); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(newwin) (SCREEN*, int, int, int, int); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nl) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nocbreak) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(noecho) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nonl) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(noqiflush) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(noraw) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(pair_content) (SCREEN*, NCURSES_PAIRS_T, NCURSES_COLOR_T*, NCURSES_COLOR_T*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(qiflush) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(raw) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(reset_prog_mode) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(reset_shell_mode) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resetty) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(ripoffline) (SCREEN*, int, int (*)(WINDOW *, int)); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(savetty) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_init) (SCREEN*, const char *); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_restore) (SCREEN*, const char *); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_set) (SCREEN*, const char *); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attroff) (SCREEN*, const chtype); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attron) (SCREEN*, const chtype); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attrset) (SCREEN*, const chtype); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(attr_t) NCURSES_SP_NAME(slk_attr) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attr_set) (SCREEN*, const attr_t, NCURSES_PAIRS_T, void*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_clear) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_color) (SCREEN*, NCURSES_PAIRS_T); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_init) (SCREEN*, int); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(slk_label) (SCREEN*, int); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_noutrefresh) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_refresh) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_restore) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_set) (SCREEN*, int, const char *, int); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_touch) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(start_color) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(chtype) NCURSES_SP_NAME(termattrs) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(termname) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(typeahead) (SCREEN*, int); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(ungetch) (SCREEN*, int); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(use_env) (SCREEN*, bool); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(use_tioctl) (SCREEN*, bool); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vidattr) (SCREEN*, chtype); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vidputs) (SCREEN*, chtype, NCURSES_SP_OUTC); /* implemented:SP_FUNC */
#if 1
extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(keybound) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(alloc_pair) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(assume_default_colors) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(define_key) (SCREEN*, const char *, int); /* implemented:EXT_SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(extended_color_content) (SCREEN*, int, int *, int *, int *); /* implemented:EXT_SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(extended_pair_content) (SCREEN*, int, int *, int *); /* implemented:EXT_SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(extended_slk_color) (SCREEN*, int); /* implemented:EXT_SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(get_escdelay) (SCREEN*); /* implemented:EXT_SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(find_pair) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(free_pair) (SCREEN*, int); /* implemented:EXT_SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_extended_color) (SCREEN*, int, int, int, int); /* implemented:EXT_SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_extended_pair) (SCREEN*, int, int, int); /* implemented:EXT_SP_FUNC */
extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(is_term_resized) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(key_defined) (SCREEN*, const char *); /* implemented:EXT_SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(keyok) (SCREEN*, int, bool); /* implemented:EXT_SP_FUNC */
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(nofilter) (SCREEN*); /* implemented */ /* implemented:EXT_SP_FUNC */
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(reset_color_pairs) (SCREEN*); /* implemented:EXT_SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resize_term) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resizeterm) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(set_escdelay) (SCREEN*, int); /* implemented:EXT_SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(set_tabsize) (SCREEN*, int); /* implemented:EXT_SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(use_default_colors) (SCREEN*); /* implemented:EXT_SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(use_legacy_coding) (SCREEN*, int); /* implemented:EXT_SP_FUNC */
#endif
#else
#undef NCURSES_SP_FUNCS
#define NCURSES_SP_FUNCS 0
#define NCURSES_SP_NAME(name) name
#define NCURSES_SP_OUTC NCURSES_OUTC
#endif
/* attributes */
#define NCURSES_ATTR_SHIFT 8
#define NCURSES_BITS(mask,shift) (NCURSES_CAST(chtype,(mask)) << ((shift) + NCURSES_ATTR_SHIFT))
#define A_NORMAL (1U - 1U)
#define A_ATTRIBUTES NCURSES_BITS(~(1U - 1U),0)
#define A_CHARTEXT (NCURSES_BITS(1U,0) - 1U)
#define A_COLOR NCURSES_BITS(((1U) << 8) - 1U,0)
#define A_STANDOUT NCURSES_BITS(1U,8)
#define A_UNDERLINE NCURSES_BITS(1U,9)
#define A_REVERSE NCURSES_BITS(1U,10)
#define A_BLINK NCURSES_BITS(1U,11)
#define A_DIM NCURSES_BITS(1U,12)
#define A_BOLD NCURSES_BITS(1U,13)
#define A_ALTCHARSET NCURSES_BITS(1U,14)
#define A_INVIS NCURSES_BITS(1U,15)
#define A_PROTECT NCURSES_BITS(1U,16)
#define A_HORIZONTAL NCURSES_BITS(1U,17)
#define A_LEFT NCURSES_BITS(1U,18)
#define A_LOW NCURSES_BITS(1U,19)
#define A_RIGHT NCURSES_BITS(1U,20)
#define A_TOP NCURSES_BITS(1U,21)
#define A_VERTICAL NCURSES_BITS(1U,22)
#if 1
#define A_ITALIC NCURSES_BITS(1U,23) /* ncurses extension */
#endif
/*
* Most of the pseudo functions are macros that either provide compatibility
* with older versions of curses, or provide inline functionality to improve
* performance.
*/
/*
* These pseudo functions are always implemented as macros:
*/
#define getyx(win,y,x) (y = getcury(win), x = getcurx(win))
#define getbegyx(win,y,x) (y = getbegy(win), x = getbegx(win))
#define getmaxyx(win,y,x) (y = getmaxy(win), x = getmaxx(win))
#define getparyx(win,y,x) (y = getpary(win), x = getparx(win))
#define getsyx(y,x) do { if (newscr) { \
if (is_leaveok(newscr)) \
(y) = (x) = -1; \
else \
getyx(newscr,(y), (x)); \
} \
} while(0)
#define setsyx(y,x) do { if (newscr) { \
if ((y) == -1 && (x) == -1) \
leaveok(newscr, TRUE); \
else { \
leaveok(newscr, FALSE); \
wmove(newscr, (y), (x)); \
} \
} \
} while(0)
#ifndef NCURSES_NOMACROS
/*
* These miscellaneous pseudo functions are provided for compatibility:
*/
#define wgetstr(w, s) wgetnstr(w, s, -1)
#define getnstr(s, n) wgetnstr(stdscr, s, (n))
#define setterm(term) setupterm(term, 1, (int *)0)
#define fixterm() reset_prog_mode()
#define resetterm() reset_shell_mode()
#define saveterm() def_prog_mode()
#define crmode() cbreak()
#define nocrmode() nocbreak()
#define gettmode()
/* It seems older SYSV curses versions define these */
#if !NCURSES_OPAQUE
#define getattrs(win) NCURSES_CAST(int, NCURSES_OK_ADDR(win) ? (win)->_attrs : A_NORMAL)
#define getcurx(win) (NCURSES_OK_ADDR(win) ? (win)->_curx : ERR)
#define getcury(win) (NCURSES_OK_ADDR(win) ? (win)->_cury : ERR)
#define getbegx(win) (NCURSES_OK_ADDR(win) ? (win)->_begx : ERR)
#define getbegy(win) (NCURSES_OK_ADDR(win) ? (win)->_begy : ERR)
#define getmaxx(win) (NCURSES_OK_ADDR(win) ? ((win)->_maxx + 1) : ERR)
#define getmaxy(win) (NCURSES_OK_ADDR(win) ? ((win)->_maxy + 1) : ERR)
#define getparx(win) (NCURSES_OK_ADDR(win) ? (win)->_parx : ERR)
#define getpary(win) (NCURSES_OK_ADDR(win) ? (win)->_pary : ERR)
#endif /* NCURSES_OPAQUE */
#define wstandout(win) (wattrset(win,A_STANDOUT))
#define wstandend(win) (wattrset(win,A_NORMAL))
#define wattron(win,at) wattr_on(win, NCURSES_CAST(attr_t, at), NULL)
#define wattroff(win,at) wattr_off(win, NCURSES_CAST(attr_t, at), NULL)
#if !NCURSES_OPAQUE
#if NCURSES_WATTR_MACROS
#if NCURSES_WIDECHAR && 1
#define wattrset(win,at) \
(NCURSES_OK_ADDR(win) \
? ((win)->_color = NCURSES_CAST(int, PAIR_NUMBER(at)), \
(win)->_attrs = NCURSES_CAST(attr_t, at), \
OK) \
: ERR)
#else
#define wattrset(win,at) \
(NCURSES_OK_ADDR(win) \
? ((win)->_attrs = NCURSES_CAST(attr_t, at), \
OK) \
: ERR)
#endif
#endif /* NCURSES_WATTR_MACROS */
#endif /* NCURSES_OPAQUE */
#define scroll(win) wscrl(win,1)
#define touchwin(win) wtouchln((win), 0, getmaxy(win), 1)
#define touchline(win, s, c) wtouchln((win), s, c, 1)
#define untouchwin(win) wtouchln((win), 0, getmaxy(win), 0)
#define box(win, v, h) wborder(win, v, v, h, h, 0, 0, 0, 0)
#define border(ls, rs, ts, bs, tl, tr, bl, br) wborder(stdscr, ls, rs, ts, bs, tl, tr, bl, br)
#define hline(ch, n) whline(stdscr, ch, (n))
#define vline(ch, n) wvline(stdscr, ch, (n))
#define winstr(w, s) winnstr(w, s, -1)
#define winchstr(w, s) winchnstr(w, s, -1)
#define winsstr(w, s) winsnstr(w, s, -1)
#if !NCURSES_OPAQUE
#define redrawwin(win) wredrawln(win, 0, (NCURSES_OK_ADDR(win) ? (win)->_maxy+1 : -1))
#endif /* NCURSES_OPAQUE */
#define waddstr(win,str) waddnstr(win,str,-1)
#define waddchstr(win,str) waddchnstr(win,str,-1)
/*
* These apply to the first 256 color pairs.
*/
#define COLOR_PAIR(n) (NCURSES_BITS((n), 0) & A_COLOR)
#define PAIR_NUMBER(a) (NCURSES_CAST(int,((NCURSES_CAST(unsigned long,(a)) & A_COLOR) >> NCURSES_ATTR_SHIFT)))
/*
* pseudo functions for standard screen
*/
#define addch(ch) waddch(stdscr,(ch))
#define addchnstr(str,n) waddchnstr(stdscr,(str),(n))
#define addchstr(str) waddchstr(stdscr,(str))
#define addnstr(str,n) waddnstr(stdscr,(str),(n))
#define addstr(str) waddnstr(stdscr,(str),-1)
#define attr_get(ap,cp,o) wattr_get(stdscr,(ap),(cp),(o))
#define attr_off(a,o) wattr_off(stdscr,(a),(o))
#define attr_on(a,o) wattr_on(stdscr,(a),(o))
#define attr_set(a,c,o) wattr_set(stdscr,(a),(c),(o))
#define attroff(at) wattroff(stdscr,(at))
#define attron(at) wattron(stdscr,(at))
#define attrset(at) wattrset(stdscr,(at))
#define bkgd(ch) wbkgd(stdscr,(ch))
#define bkgdset(ch) wbkgdset(stdscr,(ch))
#define chgat(n,a,c,o) wchgat(stdscr,(n),(a),(c),(o))
#define clear() wclear(stdscr)
#define clrtobot() wclrtobot(stdscr)
#define clrtoeol() wclrtoeol(stdscr)
#define color_set(c,o) wcolor_set(stdscr,(c),(o))
#define delch() wdelch(stdscr)
#define deleteln() winsdelln(stdscr,-1)
#define echochar(c) wechochar(stdscr,(c))
#define erase() werase(stdscr)
#define getch() wgetch(stdscr)
#define getstr(str) wgetstr(stdscr,(str))
#define inch() winch(stdscr)
#define inchnstr(s,n) winchnstr(stdscr,(s),(n))
#define inchstr(s) winchstr(stdscr,(s))
#define innstr(s,n) winnstr(stdscr,(s),(n))
#define insch(c) winsch(stdscr,(c))
#define insdelln(n) winsdelln(stdscr,(n))
#define insertln() winsdelln(stdscr,1)
#define insnstr(s,n) winsnstr(stdscr,(s),(n))
#define insstr(s) winsstr(stdscr,(s))
#define instr(s) winstr(stdscr,(s))
#define move(y,x) wmove(stdscr,(y),(x))
#define refresh() wrefresh(stdscr)
#define scrl(n) wscrl(stdscr,(n))
#define setscrreg(t,b) wsetscrreg(stdscr,(t),(b))
#define standend() wstandend(stdscr)
#define standout() wstandout(stdscr)
#define timeout(delay) wtimeout(stdscr,(delay))
#define wdeleteln(win) winsdelln(win,-1)
#define winsertln(win) winsdelln(win,1)
/*
* mv functions
*/
#define mvwaddch(win,y,x,ch) (wmove((win),(y),(x)) == ERR ? ERR : waddch((win),(ch)))
#define mvwaddchnstr(win,y,x,str,n) (wmove((win),(y),(x)) == ERR ? ERR : waddchnstr((win),(str),(n)))
#define mvwaddchstr(win,y,x,str) (wmove((win),(y),(x)) == ERR ? ERR : waddchnstr((win),(str),-1))
#define mvwaddnstr(win,y,x,str,n) (wmove((win),(y),(x)) == ERR ? ERR : waddnstr((win),(str),(n)))
#define mvwaddstr(win,y,x,str) (wmove((win),(y),(x)) == ERR ? ERR : waddnstr((win),(str),-1))
#define mvwchgat(win,y,x,n,a,c,o) (wmove((win),(y),(x)) == ERR ? ERR : wchgat((win),(n),(a),(c),(o)))
#define mvwdelch(win,y,x) (wmove((win),(y),(x)) == ERR ? ERR : wdelch(win))
#define mvwgetch(win,y,x) (wmove((win),(y),(x)) == ERR ? ERR : wgetch(win))
#define mvwgetnstr(win,y,x,str,n) (wmove((win),(y),(x)) == ERR ? ERR : wgetnstr((win),(str),(n)))
#define mvwgetstr(win,y,x,str) (wmove((win),(y),(x)) == ERR ? ERR : wgetstr((win),(str)))
#define mvwhline(win,y,x,c,n) (wmove((win),(y),(x)) == ERR ? ERR : whline((win),(c),(n)))
#define mvwinch(win,y,x) (wmove((win),(y),(x)) == ERR ? NCURSES_CAST(chtype, ERR) : winch(win))
#define mvwinchnstr(win,y,x,s,n) (wmove((win),(y),(x)) == ERR ? ERR : winchnstr((win),(s),(n)))
#define mvwinchstr(win,y,x,s) (wmove((win),(y),(x)) == ERR ? ERR : winchstr((win),(s)))
#define mvwinnstr(win,y,x,s,n) (wmove((win),(y),(x)) == ERR ? ERR : winnstr((win),(s),(n)))
#define mvwinsch(win,y,x,c) (wmove((win),(y),(x)) == ERR ? ERR : winsch((win),(c)))
#define mvwinsnstr(win,y,x,s,n) (wmove((win),(y),(x)) == ERR ? ERR : winsnstr((win),(s),(n)))
#define mvwinsstr(win,y,x,s) (wmove((win),(y),(x)) == ERR ? ERR : winsstr((win),(s)))
#define mvwinstr(win,y,x,s) (wmove((win),(y),(x)) == ERR ? ERR : winstr((win),(s)))
#define mvwvline(win,y,x,c,n) (wmove((win),(y),(x)) == ERR ? ERR : wvline((win),(c),(n)))
#define mvaddch(y,x,ch) mvwaddch(stdscr,(y),(x),(ch))
#define mvaddchnstr(y,x,str,n) mvwaddchnstr(stdscr,(y),(x),(str),(n))
#define mvaddchstr(y,x,str) mvwaddchstr(stdscr,(y),(x),(str))
#define mvaddnstr(y,x,str,n) mvwaddnstr(stdscr,(y),(x),(str),(n))
#define mvaddstr(y,x,str) mvwaddstr(stdscr,(y),(x),(str))
#define mvchgat(y,x,n,a,c,o) mvwchgat(stdscr,(y),(x),(n),(a),(c),(o))
#define mvdelch(y,x) mvwdelch(stdscr,(y),(x))
#define mvgetch(y,x) mvwgetch(stdscr,(y),(x))
#define mvgetnstr(y,x,str,n) mvwgetnstr(stdscr,(y),(x),(str),(n))
#define mvgetstr(y,x,str) mvwgetstr(stdscr,(y),(x),(str))
#define mvhline(y,x,c,n) mvwhline(stdscr,(y),(x),(c),(n))
#define mvinch(y,x) mvwinch(stdscr,(y),(x))
#define mvinchnstr(y,x,s,n) mvwinchnstr(stdscr,(y),(x),(s),(n))
#define mvinchstr(y,x,s) mvwinchstr(stdscr,(y),(x),(s))
#define mvinnstr(y,x,s,n) mvwinnstr(stdscr,(y),(x),(s),(n))
#define mvinsch(y,x,c) mvwinsch(stdscr,(y),(x),(c))
#define mvinsnstr(y,x,s,n) mvwinsnstr(stdscr,(y),(x),(s),(n))
#define mvinsstr(y,x,s) mvwinsstr(stdscr,(y),(x),(s))
#define mvinstr(y,x,s) mvwinstr(stdscr,(y),(x),(s))
#define mvvline(y,x,c,n) mvwvline(stdscr,(y),(x),(c),(n))
/*
* Some wide-character functions can be implemented without the extensions.
*/
#if !NCURSES_OPAQUE
#define getbkgd(win) (NCURSES_OK_ADDR(win) ? ((win)->_bkgd) : 0)
#endif /* NCURSES_OPAQUE */
#define slk_attr_off(a,v) ((v) ? ERR : slk_attroff(a))
#define slk_attr_on(a,v) ((v) ? ERR : slk_attron(a))
#if !NCURSES_OPAQUE
#if NCURSES_WATTR_MACROS
#if NCURSES_WIDECHAR && 1
#define wattr_set(win,a,p,opts) \
(NCURSES_OK_ADDR(win) \
? ((void)((win)->_attrs = ((a) & ~A_COLOR), \
(win)->_color = (opts) ? *(int *)(opts) : (p)), \
OK) \
: ERR)
#define wattr_get(win,a,p,opts) \
(NCURSES_OK_ADDR(win) \
? ((void)(NCURSES_OK_ADDR(a) \
? (*(a) = (win)->_attrs) \
: OK), \
(void)(NCURSES_OK_ADDR(p) \
? (*(p) = (NCURSES_PAIRS_T) (win)->_color) \
: OK), \
(void)(NCURSES_OK_ADDR(opts) \
? (*(int *)(opts) = (win)->_color) \
: OK), \
OK) \
: ERR)
#else /* !(NCURSES_WIDECHAR && NCURSES_EXE_COLORS) */
#define wattr_set(win,a,p,opts) \
(NCURSES_OK_ADDR(win) \
? ((void)((win)->_attrs = (((a) & ~A_COLOR) | \
(attr_t)COLOR_PAIR(p))), \
OK) \
: ERR)
#define wattr_get(win,a,p,opts) \
(NCURSES_OK_ADDR(win) \
? ((void)(NCURSES_OK_ADDR(a) \
? (*(a) = (win)->_attrs) \
: OK), \
(void)(NCURSES_OK_ADDR(p) \
? (*(p) = (NCURSES_PAIRS_T) PAIR_NUMBER((win)->_attrs)) \
: OK), \
OK) \
: ERR)
#endif /* (NCURSES_WIDECHAR && NCURSES_EXE_COLORS) */
#endif /* NCURSES_WATTR_MACROS */
#endif /* NCURSES_OPAQUE */
/*
* X/Open curses deprecates SVr4 vwprintw/vwscanw, which are supposed to use
* varargs.h. It adds new calls vw_printw/vw_scanw, which are supposed to
* use POSIX stdarg.h. The ncurses versions of vwprintw/vwscanw already
* use stdarg.h, so...
*/
#define vw_printw vwprintw
#define vw_scanw vwscanw
/*
* Export fallback function for use in C++ binding.
*/
#if !1
#define vsscanf(a,b,c) _nc_vsscanf(a,b,c)
NCURSES_EXPORT(int) vsscanf(const char *, const char *, va_list);
#endif
/*
* These macros are extensions - not in X/Open Curses.
*/
#if 1
#if !NCURSES_OPAQUE
#define is_cleared(win) (NCURSES_OK_ADDR(win) ? (win)->_clear : FALSE)
#define is_idcok(win) (NCURSES_OK_ADDR(win) ? (win)->_idcok : FALSE)
#define is_idlok(win) (NCURSES_OK_ADDR(win) ? (win)->_idlok : FALSE)
#define is_immedok(win) (NCURSES_OK_ADDR(win) ? (win)->_immed : FALSE)
#define is_keypad(win) (NCURSES_OK_ADDR(win) ? (win)->_use_keypad : FALSE)
#define is_leaveok(win) (NCURSES_OK_ADDR(win) ? (win)->_leaveok : FALSE)
#define is_nodelay(win) (NCURSES_OK_ADDR(win) ? ((win)->_delay == 0) : FALSE)
#define is_notimeout(win) (NCURSES_OK_ADDR(win) ? (win)->_notimeout : FALSE)
#define is_pad(win) (NCURSES_OK_ADDR(win) ? ((win)->_flags & _ISPAD) != 0 : FALSE)
#define is_scrollok(win) (NCURSES_OK_ADDR(win) ? (win)->_scroll : FALSE)
#define is_subwin(win) (NCURSES_OK_ADDR(win) ? ((win)->_flags & _SUBWIN) != 0 : FALSE)
#define is_syncok(win) (NCURSES_OK_ADDR(win) ? (win)->_sync : FALSE)
#define wgetdelay(win) (NCURSES_OK_ADDR(win) ? (win)->_delay : 0)
#define wgetparent(win) (NCURSES_OK_ADDR(win) ? (win)->_parent : 0)
#define wgetscrreg(win,t,b) (NCURSES_OK_ADDR(win) ? (*(t) = (win)->_regtop, *(b) = (win)->_regbottom, OK) : ERR)
#endif
#endif
#endif /* NCURSES_NOMACROS */
/*
* Public variables.
*
* Notes:
* a. ESCDELAY was an undocumented feature under AIX curses.
* It gives the ESC expire time in milliseconds.
* b. ttytype is needed for backward compatibility
*/
#if NCURSES_REENTRANT
NCURSES_WRAPPED_VAR(WINDOW *, curscr);
NCURSES_WRAPPED_VAR(WINDOW *, newscr);
NCURSES_WRAPPED_VAR(WINDOW *, stdscr);
NCURSES_WRAPPED_VAR(char *, ttytype);
NCURSES_WRAPPED_VAR(int, COLORS);
NCURSES_WRAPPED_VAR(int, COLOR_PAIRS);
NCURSES_WRAPPED_VAR(int, COLS);
NCURSES_WRAPPED_VAR(int, ESCDELAY);
NCURSES_WRAPPED_VAR(int, LINES);
NCURSES_WRAPPED_VAR(int, TABSIZE);
#define curscr NCURSES_PUBLIC_VAR(curscr())
#define newscr NCURSES_PUBLIC_VAR(newscr())
#define stdscr NCURSES_PUBLIC_VAR(stdscr())
#define ttytype NCURSES_PUBLIC_VAR(ttytype())
#define COLORS NCURSES_PUBLIC_VAR(COLORS())
#define COLOR_PAIRS NCURSES_PUBLIC_VAR(COLOR_PAIRS())
#define COLS NCURSES_PUBLIC_VAR(COLS())
#define ESCDELAY NCURSES_PUBLIC_VAR(ESCDELAY())
#define LINES NCURSES_PUBLIC_VAR(LINES())
#define TABSIZE NCURSES_PUBLIC_VAR(TABSIZE())
#else
extern NCURSES_EXPORT_VAR(WINDOW *) curscr;
extern NCURSES_EXPORT_VAR(WINDOW *) newscr;
extern NCURSES_EXPORT_VAR(WINDOW *) stdscr;
extern NCURSES_EXPORT_VAR(char) ttytype[];
extern NCURSES_EXPORT_VAR(int) COLORS;
extern NCURSES_EXPORT_VAR(int) COLOR_PAIRS;
extern NCURSES_EXPORT_VAR(int) COLS;
extern NCURSES_EXPORT_VAR(int) ESCDELAY;
extern NCURSES_EXPORT_VAR(int) LINES;
extern NCURSES_EXPORT_VAR(int) TABSIZE;
#endif
/*
* Pseudo-character tokens outside ASCII range. The curses wgetch() function
* will return any given one of these only if the corresponding k- capability
* is defined in your terminal's terminfo entry.
*
* Some keys (KEY_A1, etc) are arranged like this:
* a1 up a3
* left b2 right
* c1 down c3
*
* A few key codes do not depend upon the terminfo entry.
*/
#define KEY_CODE_YES 0400 /* A wchar_t contains a key code */
#define KEY_MIN 0401 /* Minimum curses key */
#define KEY_BREAK 0401 /* Break key (unreliable) */
#define KEY_SRESET 0530 /* Soft (partial) reset (unreliable) */
#define KEY_RESET 0531 /* Reset or hard reset (unreliable) */
/*
* These definitions were generated by ./MKkey_defs.sh ./Caps
*/
#define KEY_DOWN 0402 /* down-arrow key */
#define KEY_UP 0403 /* up-arrow key */
#define KEY_LEFT 0404 /* left-arrow key */
#define KEY_RIGHT 0405 /* right-arrow key */
#define KEY_HOME 0406 /* home key */
#define KEY_BACKSPACE 0407 /* backspace key */
#define KEY_F0 0410 /* Function keys. Space for 64 */
#define KEY_F(n) (KEY_F0+(n)) /* Value of function key n */
#define KEY_DL 0510 /* delete-line key */
#define KEY_IL 0511 /* insert-line key */
#define KEY_DC 0512 /* delete-character key */
#define KEY_IC 0513 /* insert-character key */
#define KEY_EIC 0514 /* sent by rmir or smir in insert mode */
#define KEY_CLEAR 0515 /* clear-screen or erase key */
#define KEY_EOS 0516 /* clear-to-end-of-screen key */
#define KEY_EOL 0517 /* clear-to-end-of-line key */
#define KEY_SF 0520 /* scroll-forward key */
#define KEY_SR 0521 /* scroll-backward key */
#define KEY_NPAGE 0522 /* next-page key */
#define KEY_PPAGE 0523 /* previous-page key */
#define KEY_STAB 0524 /* set-tab key */
#define KEY_CTAB 0525 /* clear-tab key */
#define KEY_CATAB 0526 /* clear-all-tabs key */
#define KEY_ENTER 0527 /* enter/send key */
#define KEY_PRINT 0532 /* print key */
#define KEY_LL 0533 /* lower-left key (home down) */
#define KEY_A1 0534 /* upper left of keypad */
#define KEY_A3 0535 /* upper right of keypad */
#define KEY_B2 0536 /* center of keypad */
#define KEY_C1 0537 /* lower left of keypad */
#define KEY_C3 0540 /* lower right of keypad */
#define KEY_BTAB 0541 /* back-tab key */
#define KEY_BEG 0542 /* begin key */
#define KEY_CANCEL 0543 /* cancel key */
#define KEY_CLOSE 0544 /* close key */
#define KEY_COMMAND 0545 /* command key */
#define KEY_COPY 0546 /* copy key */
#define KEY_CREATE 0547 /* create key */
#define KEY_END 0550 /* end key */
#define KEY_EXIT 0551 /* exit key */
#define KEY_FIND 0552 /* find key */
#define KEY_HELP 0553 /* help key */
#define KEY_MARK 0554 /* mark key */
#define KEY_MESSAGE 0555 /* message key */
#define KEY_MOVE 0556 /* move key */
#define KEY_NEXT 0557 /* next key */
#define KEY_OPEN 0560 /* open key */
#define KEY_OPTIONS 0561 /* options key */
#define KEY_PREVIOUS 0562 /* previous key */
#define KEY_REDO 0563 /* redo key */
#define KEY_REFERENCE 0564 /* reference key */
#define KEY_REFRESH 0565 /* refresh key */
#define KEY_REPLACE 0566 /* replace key */
#define KEY_RESTART 0567 /* restart key */
#define KEY_RESUME 0570 /* resume key */
#define KEY_SAVE 0571 /* save key */
#define KEY_SBEG 0572 /* shifted begin key */
#define KEY_SCANCEL 0573 /* shifted cancel key */
#define KEY_SCOMMAND 0574 /* shifted command key */
#define KEY_SCOPY 0575 /* shifted copy key */
#define KEY_SCREATE 0576 /* shifted create key */
#define KEY_SDC 0577 /* shifted delete-character key */
#define KEY_SDL 0600 /* shifted delete-line key */
#define KEY_SELECT 0601 /* select key */
#define KEY_SEND 0602 /* shifted end key */
#define KEY_SEOL 0603 /* shifted clear-to-end-of-line key */
#define KEY_SEXIT 0604 /* shifted exit key */
#define KEY_SFIND 0605 /* shifted find key */
#define KEY_SHELP 0606 /* shifted help key */
#define KEY_SHOME 0607 /* shifted home key */
#define KEY_SIC 0610 /* shifted insert-character key */
#define KEY_SLEFT 0611 /* shifted left-arrow key */
#define KEY_SMESSAGE 0612 /* shifted message key */
#define KEY_SMOVE 0613 /* shifted move key */
#define KEY_SNEXT 0614 /* shifted next key */
#define KEY_SOPTIONS 0615 /* shifted options key */
#define KEY_SPREVIOUS 0616 /* shifted previous key */
#define KEY_SPRINT 0617 /* shifted print key */
#define KEY_SREDO 0620 /* shifted redo key */
#define KEY_SREPLACE 0621 /* shifted replace key */
#define KEY_SRIGHT 0622 /* shifted right-arrow key */
#define KEY_SRSUME 0623 /* shifted resume key */
#define KEY_SSAVE 0624 /* shifted save key */
#define KEY_SSUSPEND 0625 /* shifted suspend key */
#define KEY_SUNDO 0626 /* shifted undo key */
#define KEY_SUSPEND 0627 /* suspend key */
#define KEY_UNDO 0630 /* undo key */
#define KEY_MOUSE 0631 /* Mouse event has occurred */
#define KEY_RESIZE 0632 /* Terminal resize event */
#define KEY_EVENT 0633 /* We were interrupted by an event */
#define KEY_MAX 0777 /* Maximum key value is 0633 */
/* $Id: curses.wide,v 1.50 2017/03/26 16:05:21 tom Exp $ */
/*
* vile:cmode:
* This file is part of ncurses, designed to be appended after curses.h.in
* (see that file for the relevant copyright).
*/
#define _XOPEN_CURSES 1
#if NCURSES_WIDECHAR
extern NCURSES_EXPORT_VAR(cchar_t *) _nc_wacs;
#define NCURSES_WACS(c) (&_nc_wacs[NCURSES_CAST(unsigned char,(c))])
#define WACS_BSSB NCURSES_WACS('l')
#define WACS_SSBB NCURSES_WACS('m')
#define WACS_BBSS NCURSES_WACS('k')
#define WACS_SBBS NCURSES_WACS('j')
#define WACS_SBSS NCURSES_WACS('u')
#define WACS_SSSB NCURSES_WACS('t')
#define WACS_SSBS NCURSES_WACS('v')
#define WACS_BSSS NCURSES_WACS('w')
#define WACS_BSBS NCURSES_WACS('q')
#define WACS_SBSB NCURSES_WACS('x')
#define WACS_SSSS NCURSES_WACS('n')
#define WACS_ULCORNER WACS_BSSB
#define WACS_LLCORNER WACS_SSBB
#define WACS_URCORNER WACS_BBSS
#define WACS_LRCORNER WACS_SBBS
#define WACS_RTEE WACS_SBSS
#define WACS_LTEE WACS_SSSB
#define WACS_BTEE WACS_SSBS
#define WACS_TTEE WACS_BSSS
#define WACS_HLINE WACS_BSBS
#define WACS_VLINE WACS_SBSB
#define WACS_PLUS WACS_SSSS
#define WACS_S1 NCURSES_WACS('o') /* scan line 1 */
#define WACS_S9 NCURSES_WACS('s') /* scan line 9 */
#define WACS_DIAMOND NCURSES_WACS('`') /* diamond */
#define WACS_CKBOARD NCURSES_WACS('a') /* checker board */
#define WACS_DEGREE NCURSES_WACS('f') /* degree symbol */
#define WACS_PLMINUS NCURSES_WACS('g') /* plus/minus */
#define WACS_BULLET NCURSES_WACS('~') /* bullet */
/* Teletype 5410v1 symbols */
#define WACS_LARROW NCURSES_WACS(',') /* arrow left */
#define WACS_RARROW NCURSES_WACS('+') /* arrow right */
#define WACS_DARROW NCURSES_WACS('.') /* arrow down */
#define WACS_UARROW NCURSES_WACS('-') /* arrow up */
#define WACS_BOARD NCURSES_WACS('h') /* board of squares */
#define WACS_LANTERN NCURSES_WACS('i') /* lantern symbol */
#define WACS_BLOCK NCURSES_WACS('0') /* solid square block */
/* ncurses extensions */
#define WACS_S3 NCURSES_WACS('p') /* scan line 3 */
#define WACS_S7 NCURSES_WACS('r') /* scan line 7 */
#define WACS_LEQUAL NCURSES_WACS('y') /* less/equal */
#define WACS_GEQUAL NCURSES_WACS('z') /* greater/equal */
#define WACS_PI NCURSES_WACS('{') /* Pi */
#define WACS_NEQUAL NCURSES_WACS('|') /* not equal */
#define WACS_STERLING NCURSES_WACS('}') /* UK pound sign */
/* double lines */
#define WACS_BDDB NCURSES_WACS('C')
#define WACS_DDBB NCURSES_WACS('D')
#define WACS_BBDD NCURSES_WACS('B')
#define WACS_DBBD NCURSES_WACS('A')
#define WACS_DBDD NCURSES_WACS('G')
#define WACS_DDDB NCURSES_WACS('F')
#define WACS_DDBD NCURSES_WACS('H')
#define WACS_BDDD NCURSES_WACS('I')
#define WACS_BDBD NCURSES_WACS('R')
#define WACS_DBDB NCURSES_WACS('Y')
#define WACS_DDDD NCURSES_WACS('E')
#define WACS_D_ULCORNER WACS_BDDB
#define WACS_D_LLCORNER WACS_DDBB
#define WACS_D_URCORNER WACS_BBDD
#define WACS_D_LRCORNER WACS_DBBD
#define WACS_D_RTEE WACS_DBDD
#define WACS_D_LTEE WACS_DDDB
#define WACS_D_BTEE WACS_DDBD
#define WACS_D_TTEE WACS_BDDD
#define WACS_D_HLINE WACS_BDBD
#define WACS_D_VLINE WACS_DBDB
#define WACS_D_PLUS WACS_DDDD
/* thick lines */
#define WACS_BTTB NCURSES_WACS('L')
#define WACS_TTBB NCURSES_WACS('M')
#define WACS_BBTT NCURSES_WACS('K')
#define WACS_TBBT NCURSES_WACS('J')
#define WACS_TBTT NCURSES_WACS('U')
#define WACS_TTTB NCURSES_WACS('T')
#define WACS_TTBT NCURSES_WACS('V')
#define WACS_BTTT NCURSES_WACS('W')
#define WACS_BTBT NCURSES_WACS('Q')
#define WACS_TBTB NCURSES_WACS('X')
#define WACS_TTTT NCURSES_WACS('N')
#define WACS_T_ULCORNER WACS_BTTB
#define WACS_T_LLCORNER WACS_TTBB
#define WACS_T_URCORNER WACS_BBTT
#define WACS_T_LRCORNER WACS_TBBT
#define WACS_T_RTEE WACS_TBTT
#define WACS_T_LTEE WACS_TTTB
#define WACS_T_BTEE WACS_TTBT
#define WACS_T_TTEE WACS_BTTT
#define WACS_T_HLINE WACS_BTBT
#define WACS_T_VLINE WACS_TBTB
#define WACS_T_PLUS WACS_TTTT
/*
* Function prototypes for wide-character operations.
*
* "generated" comments should include ":WIDEC" to make the corresponding
* functions ifdef'd in lib_gen.c
*
* "implemented" comments do not need this marker.
*/
extern NCURSES_EXPORT(int) add_wch (const cchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) add_wchnstr (const cchar_t *, int); /* generated:WIDEC */
extern NCURSES_EXPORT(int) add_wchstr (const cchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) addnwstr (const wchar_t *, int); /* generated:WIDEC */
extern NCURSES_EXPORT(int) addwstr (const wchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) bkgrnd (const cchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(void) bkgrndset (const cchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) border_set (const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*); /* generated:WIDEC */
extern NCURSES_EXPORT(int) box_set (WINDOW *, const cchar_t *, const cchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) echo_wchar (const cchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) erasewchar (wchar_t*); /* implemented */
extern NCURSES_EXPORT(int) get_wch (wint_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) get_wstr (wint_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) getbkgrnd (cchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) getcchar (const cchar_t *, wchar_t*, attr_t*, NCURSES_PAIRS_T*, void*); /* implemented */
extern NCURSES_EXPORT(int) getn_wstr (wint_t *, int); /* generated:WIDEC */
extern NCURSES_EXPORT(int) hline_set (const cchar_t *, int); /* generated:WIDEC */
extern NCURSES_EXPORT(int) in_wch (cchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) in_wchnstr (cchar_t *, int); /* generated:WIDEC */
extern NCURSES_EXPORT(int) in_wchstr (cchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) innwstr (wchar_t *, int); /* generated:WIDEC */
extern NCURSES_EXPORT(int) ins_nwstr (const wchar_t *, int); /* generated:WIDEC */
extern NCURSES_EXPORT(int) ins_wch (const cchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) ins_wstr (const wchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) inwstr (wchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(NCURSES_CONST char*) key_name (wchar_t); /* implemented */
extern NCURSES_EXPORT(int) killwchar (wchar_t *); /* implemented */
extern NCURSES_EXPORT(int) mvadd_wch (int, int, const cchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) mvadd_wchnstr (int, int, const cchar_t *, int);/* generated:WIDEC */
extern NCURSES_EXPORT(int) mvadd_wchstr (int, int, const cchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) mvaddnwstr (int, int, const wchar_t *, int); /* generated:WIDEC */
extern NCURSES_EXPORT(int) mvaddwstr (int, int, const wchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) mvget_wch (int, int, wint_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) mvget_wstr (int, int, wint_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) mvgetn_wstr (int, int, wint_t *, int); /* generated:WIDEC */
extern NCURSES_EXPORT(int) mvhline_set (int, int, const cchar_t *, int); /* generated:WIDEC */
extern NCURSES_EXPORT(int) mvin_wch (int, int, cchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) mvin_wchnstr (int, int, cchar_t *, int); /* generated:WIDEC */
extern NCURSES_EXPORT(int) mvin_wchstr (int, int, cchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) mvinnwstr (int, int, wchar_t *, int); /* generated:WIDEC */
extern NCURSES_EXPORT(int) mvins_nwstr (int, int, const wchar_t *, int); /* generated:WIDEC */
extern NCURSES_EXPORT(int) mvins_wch (int, int, const cchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) mvins_wstr (int, int, const wchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) mvinwstr (int, int, wchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) mvvline_set (int, int, const cchar_t *, int); /* generated:WIDEC */
extern NCURSES_EXPORT(int) mvwadd_wch (WINDOW *, int, int, const cchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) mvwadd_wchnstr (WINDOW *, int, int, const cchar_t *, int); /* generated:WIDEC */
extern NCURSES_EXPORT(int) mvwadd_wchstr (WINDOW *, int, int, const cchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) mvwaddnwstr (WINDOW *, int, int, const wchar_t *, int);/* generated:WIDEC */
extern NCURSES_EXPORT(int) mvwaddwstr (WINDOW *, int, int, const wchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) mvwget_wch (WINDOW *, int, int, wint_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) mvwget_wstr (WINDOW *, int, int, wint_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) mvwgetn_wstr (WINDOW *, int, int, wint_t *, int);/* generated:WIDEC */
extern NCURSES_EXPORT(int) mvwhline_set (WINDOW *, int, int, const cchar_t *, int);/* generated:WIDEC */
extern NCURSES_EXPORT(int) mvwin_wch (WINDOW *, int, int, cchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) mvwin_wchnstr (WINDOW *, int,int, cchar_t *,int); /* generated:WIDEC */
extern NCURSES_EXPORT(int) mvwin_wchstr (WINDOW *, int, int, cchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) mvwinnwstr (WINDOW *, int, int, wchar_t *, int); /* generated:WIDEC */
extern NCURSES_EXPORT(int) mvwins_nwstr (WINDOW *, int,int, const wchar_t *,int); /* generated:WIDEC */
extern NCURSES_EXPORT(int) mvwins_wch (WINDOW *, int, int, const cchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) mvwins_wstr (WINDOW *, int, int, const wchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) mvwinwstr (WINDOW *, int, int, wchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) mvwvline_set (WINDOW *, int,int, const cchar_t *,int); /* generated:WIDEC */
extern NCURSES_EXPORT(int) pecho_wchar (WINDOW *, const cchar_t *); /* implemented */
extern NCURSES_EXPORT(int) setcchar (cchar_t *, const wchar_t *, const attr_t, NCURSES_PAIRS_T, const void *); /* implemented */
extern NCURSES_EXPORT(int) slk_wset (int, const wchar_t *, int); /* implemented */
extern NCURSES_EXPORT(attr_t) term_attrs (void); /* implemented */
extern NCURSES_EXPORT(int) unget_wch (const wchar_t); /* implemented */
extern NCURSES_EXPORT(int) vid_attr (attr_t, NCURSES_PAIRS_T, void *); /* implemented */
extern NCURSES_EXPORT(int) vid_puts (attr_t, NCURSES_PAIRS_T, void *, NCURSES_OUTC); /* implemented */
extern NCURSES_EXPORT(int) vline_set (const cchar_t *, int); /* generated:WIDEC */
extern NCURSES_EXPORT(int) wadd_wch (WINDOW *,const cchar_t *); /* implemented */
extern NCURSES_EXPORT(int) wadd_wchnstr (WINDOW *,const cchar_t *,int); /* implemented */
extern NCURSES_EXPORT(int) wadd_wchstr (WINDOW *,const cchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) waddnwstr (WINDOW *,const wchar_t *,int); /* implemented */
extern NCURSES_EXPORT(int) waddwstr (WINDOW *,const wchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) wbkgrnd (WINDOW *,const cchar_t *); /* implemented */
extern NCURSES_EXPORT(void) wbkgrndset (WINDOW *,const cchar_t *); /* implemented */
extern NCURSES_EXPORT(int) wborder_set (WINDOW *,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*); /* implemented */
extern NCURSES_EXPORT(int) wecho_wchar (WINDOW *, const cchar_t *); /* implemented */
extern NCURSES_EXPORT(int) wget_wch (WINDOW *, wint_t *); /* implemented */
extern NCURSES_EXPORT(int) wget_wstr (WINDOW *, wint_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) wgetbkgrnd (WINDOW *, cchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) wgetn_wstr (WINDOW *, wint_t *, int); /* implemented */
extern NCURSES_EXPORT(int) whline_set (WINDOW *, const cchar_t *, int); /* implemented */
extern NCURSES_EXPORT(int) win_wch (WINDOW *, cchar_t *); /* implemented */
extern NCURSES_EXPORT(int) win_wchnstr (WINDOW *, cchar_t *, int); /* implemented */
extern NCURSES_EXPORT(int) win_wchstr (WINDOW *, cchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) winnwstr (WINDOW *, wchar_t *, int); /* implemented */
extern NCURSES_EXPORT(int) wins_nwstr (WINDOW *, const wchar_t *, int); /* implemented */
extern NCURSES_EXPORT(int) wins_wch (WINDOW *, const cchar_t *); /* implemented */
extern NCURSES_EXPORT(int) wins_wstr (WINDOW *, const wchar_t *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) winwstr (WINDOW *, wchar_t *); /* implemented */
extern NCURSES_EXPORT(wchar_t*) wunctrl (cchar_t *); /* implemented */
extern NCURSES_EXPORT(int) wvline_set (WINDOW *, const cchar_t *, int); /* implemented */
#if NCURSES_SP_FUNCS
extern NCURSES_EXPORT(attr_t) NCURSES_SP_NAME(term_attrs) (SCREEN*); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(unget_wch) (SCREEN*, const wchar_t); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(wchar_t*) NCURSES_SP_NAME(wunctrl) (SCREEN*, cchar_t *); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vid_attr) (SCREEN*, attr_t, NCURSES_PAIRS_T, void *); /* implemented:SP_FUNC */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vid_puts) (SCREEN*, attr_t, NCURSES_PAIRS_T, void *, NCURSES_SP_OUTC); /* implemented:SP_FUNC */
#endif
#ifndef NCURSES_NOMACROS
/*
* XSI curses macros for XPG4 conformance.
*/
#define add_wch(c) wadd_wch(stdscr,(c))
#define add_wchnstr(str,n) wadd_wchnstr(stdscr,(str),(n))
#define add_wchstr(str) wadd_wchstr(stdscr,(str))
#define addnwstr(wstr,n) waddnwstr(stdscr,(wstr),(n))
#define addwstr(wstr) waddwstr(stdscr,(wstr))
#define bkgrnd(c) wbkgrnd(stdscr,(c))
#define bkgrndset(c) wbkgrndset(stdscr,(c))
#define border_set(l,r,t,b,tl,tr,bl,br) wborder_set(stdscr,(l),(r),(t),(b),tl,tr,bl,br)
#define box_set(w,v,h) wborder_set((w),(v),(v),(h),(h),0,0,0,0)
#define echo_wchar(c) wecho_wchar(stdscr,(c))
#define get_wch(c) wget_wch(stdscr,(c))
#define get_wstr(t) wget_wstr(stdscr,(t))
#define getbkgrnd(wch) wgetbkgrnd(stdscr,(wch))
#define getn_wstr(t,n) wgetn_wstr(stdscr,(t),(n))
#define hline_set(c,n) whline_set(stdscr,(c),(n))
#define in_wch(c) win_wch(stdscr,(c))
#define in_wchnstr(c,n) win_wchnstr(stdscr,(c),(n))
#define in_wchstr(c) win_wchstr(stdscr,(c))
#define innwstr(c,n) winnwstr(stdscr,(c),(n))
#define ins_nwstr(t,n) wins_nwstr(stdscr,(t),(n))
#define ins_wch(c) wins_wch(stdscr,(c))
#define ins_wstr(t) wins_wstr(stdscr,(t))
#define inwstr(c) winwstr(stdscr,(c))
#define vline_set(c,n) wvline_set(stdscr,(c),(n))
#define wadd_wchstr(win,str) wadd_wchnstr((win),(str),-1)
#define waddwstr(win,wstr) waddnwstr((win),(wstr),-1)
#define wget_wstr(w,t) wgetn_wstr((w),(t),-1)
#define win_wchstr(w,c) win_wchnstr((w),(c),-1)
#define wins_wstr(w,t) wins_nwstr((w),(t),-1)
#if !NCURSES_OPAQUE
#define wgetbkgrnd(win,wch) (NCURSES_OK_ADDR(wch) ? ((win) ? (*(wch) = (win)->_bkgrnd) : *(wch), OK) : ERR)
#endif
#define mvadd_wch(y,x,c) mvwadd_wch(stdscr,(y),(x),(c))
#define mvadd_wchnstr(y,x,s,n) mvwadd_wchnstr(stdscr,(y),(x),(s),(n))
#define mvadd_wchstr(y,x,s) mvwadd_wchstr(stdscr,(y),(x),(s))
#define mvaddnwstr(y,x,wstr,n) mvwaddnwstr(stdscr,(y),(x),(wstr),(n))
#define mvaddwstr(y,x,wstr) mvwaddwstr(stdscr,(y),(x),(wstr))
#define mvget_wch(y,x,c) mvwget_wch(stdscr,(y),(x),(c))
#define mvget_wstr(y,x,t) mvwget_wstr(stdscr,(y),(x),(t))
#define mvgetn_wstr(y,x,t,n) mvwgetn_wstr(stdscr,(y),(x),(t),(n))
#define mvhline_set(y,x,c,n) mvwhline_set(stdscr,(y),(x),(c),(n))
#define mvin_wch(y,x,c) mvwin_wch(stdscr,(y),(x),(c))
#define mvin_wchnstr(y,x,c,n) mvwin_wchnstr(stdscr,(y),(x),(c),(n))
#define mvin_wchstr(y,x,c) mvwin_wchstr(stdscr,(y),(x),(c))
#define mvinnwstr(y,x,c,n) mvwinnwstr(stdscr,(y),(x),(c),(n))
#define mvins_nwstr(y,x,t,n) mvwins_nwstr(stdscr,(y),(x),(t),(n))
#define mvins_wch(y,x,c) mvwins_wch(stdscr,(y),(x),(c))
#define mvins_wstr(y,x,t) mvwins_wstr(stdscr,(y),(x),(t))
#define mvinwstr(y,x,c) mvwinwstr(stdscr,(y),(x),(c))
#define mvvline_set(y,x,c,n) mvwvline_set(stdscr,(y),(x),(c),(n))
#define mvwadd_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : wadd_wch((win),(c)))
#define mvwadd_wchnstr(win,y,x,s,n) (wmove(win,(y),(x)) == ERR ? ERR : wadd_wchnstr((win),(s),(n)))
#define mvwadd_wchstr(win,y,x,s) (wmove(win,(y),(x)) == ERR ? ERR : wadd_wchstr((win),(s)))
#define mvwaddnwstr(win,y,x,wstr,n) (wmove(win,(y),(x)) == ERR ? ERR : waddnwstr((win),(wstr),(n)))
#define mvwaddwstr(win,y,x,wstr) (wmove(win,(y),(x)) == ERR ? ERR : waddwstr((win),(wstr)))
#define mvwget_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : wget_wch((win),(c)))
#define mvwget_wstr(win,y,x,t) (wmove(win,(y),(x)) == ERR ? ERR : wget_wstr((win),(t)))
#define mvwgetn_wstr(win,y,x,t,n) (wmove(win,(y),(x)) == ERR ? ERR : wgetn_wstr((win),(t),(n)))
#define mvwhline_set(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : whline_set((win),(c),(n)))
#define mvwin_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : win_wch((win),(c)))
#define mvwin_wchnstr(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : win_wchnstr((win),(c),(n)))
#define mvwin_wchstr(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : win_wchstr((win),(c)))
#define mvwinnwstr(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : winnwstr((win),(c),(n)))
#define mvwins_nwstr(win,y,x,t,n) (wmove(win,(y),(x)) == ERR ? ERR : wins_nwstr((win),(t),(n)))
#define mvwins_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : wins_wch((win),(c)))
#define mvwins_wstr(win,y,x,t) (wmove(win,(y),(x)) == ERR ? ERR : wins_wstr((win),(t)))
#define mvwinwstr(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : winwstr((win),(c)))
#define mvwvline_set(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : wvline_set((win),(c),(n)))
#endif /* NCURSES_NOMACROS */
#if defined(TRACE) || defined(NCURSES_TEST)
extern NCURSES_EXPORT(const char *) _nc_viswbuf(const wchar_t *);
extern NCURSES_EXPORT(const char *) _nc_viswibuf(const wint_t *);
#endif
#endif /* NCURSES_WIDECHAR */
/* $Id: curses.tail,v 1.23 2016/02/13 16:37:45 tom Exp $ */
/*
* vile:cmode:
* This file is part of ncurses, designed to be appended after curses.h.in
* (see that file for the relevant copyright).
*/
/* mouse interface */
#if NCURSES_MOUSE_VERSION > 1
#define NCURSES_MOUSE_MASK(b,m) ((m) << (((b) - 1) * 5))
#else
#define NCURSES_MOUSE_MASK(b,m) ((m) << (((b) - 1) * 6))
#endif
#define NCURSES_BUTTON_RELEASED 001L
#define NCURSES_BUTTON_PRESSED 002L
#define NCURSES_BUTTON_CLICKED 004L
#define NCURSES_DOUBLE_CLICKED 010L
#define NCURSES_TRIPLE_CLICKED 020L
#define NCURSES_RESERVED_EVENT 040L
/* event masks */
#define BUTTON1_RELEASED NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_RELEASED)
#define BUTTON1_PRESSED NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_PRESSED)
#define BUTTON1_CLICKED NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_CLICKED)
#define BUTTON1_DOUBLE_CLICKED NCURSES_MOUSE_MASK(1, NCURSES_DOUBLE_CLICKED)
#define BUTTON1_TRIPLE_CLICKED NCURSES_MOUSE_MASK(1, NCURSES_TRIPLE_CLICKED)
#define BUTTON2_RELEASED NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_RELEASED)
#define BUTTON2_PRESSED NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_PRESSED)
#define BUTTON2_CLICKED NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_CLICKED)
#define BUTTON2_DOUBLE_CLICKED NCURSES_MOUSE_MASK(2, NCURSES_DOUBLE_CLICKED)
#define BUTTON2_TRIPLE_CLICKED NCURSES_MOUSE_MASK(2, NCURSES_TRIPLE_CLICKED)
#define BUTTON3_RELEASED NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_RELEASED)
#define BUTTON3_PRESSED NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_PRESSED)
#define BUTTON3_CLICKED NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_CLICKED)
#define BUTTON3_DOUBLE_CLICKED NCURSES_MOUSE_MASK(3, NCURSES_DOUBLE_CLICKED)
#define BUTTON3_TRIPLE_CLICKED NCURSES_MOUSE_MASK(3, NCURSES_TRIPLE_CLICKED)
#define BUTTON4_RELEASED NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_RELEASED)
#define BUTTON4_PRESSED NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_PRESSED)
#define BUTTON4_CLICKED NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_CLICKED)
#define BUTTON4_DOUBLE_CLICKED NCURSES_MOUSE_MASK(4, NCURSES_DOUBLE_CLICKED)
#define BUTTON4_TRIPLE_CLICKED NCURSES_MOUSE_MASK(4, NCURSES_TRIPLE_CLICKED)
/*
* In 32 bits the version-1 scheme does not provide enough space for a 5th
* button, unless we choose to change the ABI by omitting the reserved-events.
*/
#if NCURSES_MOUSE_VERSION > 1
#define BUTTON5_RELEASED NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_RELEASED)
#define BUTTON5_PRESSED NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_PRESSED)
#define BUTTON5_CLICKED NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_CLICKED)
#define BUTTON5_DOUBLE_CLICKED NCURSES_MOUSE_MASK(5, NCURSES_DOUBLE_CLICKED)
#define BUTTON5_TRIPLE_CLICKED NCURSES_MOUSE_MASK(5, NCURSES_TRIPLE_CLICKED)
#define BUTTON_CTRL NCURSES_MOUSE_MASK(6, 0001L)
#define BUTTON_SHIFT NCURSES_MOUSE_MASK(6, 0002L)
#define BUTTON_ALT NCURSES_MOUSE_MASK(6, 0004L)
#define REPORT_MOUSE_POSITION NCURSES_MOUSE_MASK(6, 0010L)
#else
#define BUTTON1_RESERVED_EVENT NCURSES_MOUSE_MASK(1, NCURSES_RESERVED_EVENT)
#define BUTTON2_RESERVED_EVENT NCURSES_MOUSE_MASK(2, NCURSES_RESERVED_EVENT)
#define BUTTON3_RESERVED_EVENT NCURSES_MOUSE_MASK(3, NCURSES_RESERVED_EVENT)
#define BUTTON4_RESERVED_EVENT NCURSES_MOUSE_MASK(4, NCURSES_RESERVED_EVENT)
#define BUTTON_CTRL NCURSES_MOUSE_MASK(5, 0001L)
#define BUTTON_SHIFT NCURSES_MOUSE_MASK(5, 0002L)
#define BUTTON_ALT NCURSES_MOUSE_MASK(5, 0004L)
#define REPORT_MOUSE_POSITION NCURSES_MOUSE_MASK(5, 0010L)
#endif
#define ALL_MOUSE_EVENTS (REPORT_MOUSE_POSITION - 1)
/* macros to extract single event-bits from masks */
#define BUTTON_RELEASE(e, x) ((e) & NCURSES_MOUSE_MASK(x, 001))
#define BUTTON_PRESS(e, x) ((e) & NCURSES_MOUSE_MASK(x, 002))
#define BUTTON_CLICK(e, x) ((e) & NCURSES_MOUSE_MASK(x, 004))
#define BUTTON_DOUBLE_CLICK(e, x) ((e) & NCURSES_MOUSE_MASK(x, 010))
#define BUTTON_TRIPLE_CLICK(e, x) ((e) & NCURSES_MOUSE_MASK(x, 020))
#define BUTTON_RESERVED_EVENT(e, x) ((e) & NCURSES_MOUSE_MASK(x, 040))
typedef struct
{
short id; /* ID to distinguish multiple devices */
int x, y, z; /* event coordinates (character-cell) */
mmask_t bstate; /* button state bits */
}
MEVENT;
extern NCURSES_EXPORT(bool) has_mouse(void);
extern NCURSES_EXPORT(int) getmouse (MEVENT *);
extern NCURSES_EXPORT(int) ungetmouse (MEVENT *);
extern NCURSES_EXPORT(mmask_t) mousemask (mmask_t, mmask_t *);
extern NCURSES_EXPORT(bool) wenclose (const WINDOW *, int, int);
extern NCURSES_EXPORT(int) mouseinterval (int);
extern NCURSES_EXPORT(bool) wmouse_trafo (const WINDOW*, int*, int*, bool);
extern NCURSES_EXPORT(bool) mouse_trafo (int*, int*, bool); /* generated */
#if NCURSES_SP_FUNCS
extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_mouse) (SCREEN*);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(getmouse) (SCREEN*, MEVENT *);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(ungetmouse) (SCREEN*,MEVENT *);
extern NCURSES_EXPORT(mmask_t) NCURSES_SP_NAME(mousemask) (SCREEN*, mmask_t, mmask_t *);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(mouseinterval) (SCREEN*, int);
#endif
#ifndef NCURSES_NOMACROS
#define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen)
#endif
/* other non-XSI functions */
extern NCURSES_EXPORT(int) mcprint (char *, int); /* direct data to printer */
extern NCURSES_EXPORT(int) has_key (int); /* do we have given key? */
#if NCURSES_SP_FUNCS
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(has_key) (SCREEN*, int); /* do we have given key? */
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(mcprint) (SCREEN*, char *, int); /* direct data to printer */
#endif
/* Debugging : use with libncurses_g.a */
extern NCURSES_EXPORT(void) _tracef (const char *, ...) GCC_PRINTFLIKE(1,2);
extern NCURSES_EXPORT(char *) _traceattr (attr_t);
extern NCURSES_EXPORT(char *) _traceattr2 (int, chtype);
extern NCURSES_EXPORT(char *) _tracechar (int);
extern NCURSES_EXPORT(char *) _tracechtype (chtype);
extern NCURSES_EXPORT(char *) _tracechtype2 (int, chtype);
#if NCURSES_WIDECHAR
#define _tracech_t _tracecchar_t
extern NCURSES_EXPORT(char *) _tracecchar_t (const cchar_t *);
#define _tracech_t2 _tracecchar_t2
extern NCURSES_EXPORT(char *) _tracecchar_t2 (int, const cchar_t *);
#else
#define _tracech_t _tracechtype
#define _tracech_t2 _tracechtype2
#endif
extern NCURSES_EXPORT(void) trace (const unsigned int);
/* trace masks */
#define TRACE_DISABLE 0x0000 /* turn off tracing */
#define TRACE_TIMES 0x0001 /* trace user and system times of updates */
#define TRACE_TPUTS 0x0002 /* trace tputs calls */
#define TRACE_UPDATE 0x0004 /* trace update actions, old & new screens */
#define TRACE_MOVE 0x0008 /* trace cursor moves and scrolls */
#define TRACE_CHARPUT 0x0010 /* trace all character outputs */
#define TRACE_ORDINARY 0x001F /* trace all update actions */
#define TRACE_CALLS 0x0020 /* trace all curses calls */
#define TRACE_VIRTPUT 0x0040 /* trace virtual character puts */
#define TRACE_IEVENT 0x0080 /* trace low-level input processing */
#define TRACE_BITS 0x0100 /* trace state of TTY control bits */
#define TRACE_ICALLS 0x0200 /* trace internal/nested calls */
#define TRACE_CCALLS 0x0400 /* trace per-character calls */
#define TRACE_DATABASE 0x0800 /* trace read/write of terminfo/termcap data */
#define TRACE_ATTRS 0x1000 /* trace attribute updates */
#define TRACE_SHIFT 13 /* number of bits in the trace masks */
#define TRACE_MAXIMUM ((1 << TRACE_SHIFT) - 1) /* maximum trace level */
#if defined(TRACE) || defined(NCURSES_TEST)
extern NCURSES_EXPORT_VAR(int) _nc_optimize_enable; /* enable optimizations */
extern NCURSES_EXPORT(const char *) _nc_visbuf (const char *);
#define OPTIMIZE_MVCUR 0x01 /* cursor movement optimization */
#define OPTIMIZE_HASHMAP 0x02 /* diff hashing to detect scrolls */
#define OPTIMIZE_SCROLL 0x04 /* scroll optimization */
#define OPTIMIZE_ALL 0xff /* enable all optimizations (dflt) */
#endif
#include <unctrl.h>
#ifdef __cplusplus
#ifndef NCURSES_NOMACROS
/* these names conflict with STL */
#undef box
#undef clear
#undef erase
#undef move
#undef refresh
#endif /* NCURSES_NOMACROS */
}
#endif
#endif /* __NCURSES_H */
termcap.h 0000644 00000006621 15201526705 0006360 0 ustar 00 /****************************************************************************
* Copyright (c) 1998-2000,2001 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included *
* in all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
* *
* Except as contained in this notice, the name(s) of the above copyright *
* holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written *
* authorization. *
****************************************************************************/
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
/* $Id: termcap.h.in,v 1.17 2001/03/24 21:53:27 tom Exp $ */
#ifndef NCURSES_TERMCAP_H_incl
#define NCURSES_TERMCAP_H_incl 1
#undef NCURSES_VERSION
#define NCURSES_VERSION "6.1"
#include <ncurses_dll.h>
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
#include <sys/types.h>
#undef NCURSES_CONST
#define NCURSES_CONST const
#undef NCURSES_OSPEED
#define NCURSES_OSPEED unsigned
extern NCURSES_EXPORT_VAR(char) PC;
extern NCURSES_EXPORT_VAR(char *) UP;
extern NCURSES_EXPORT_VAR(char *) BC;
extern NCURSES_EXPORT_VAR(NCURSES_OSPEED) ospeed;
#if !defined(NCURSES_TERM_H_incl)
extern NCURSES_EXPORT(char *) tgetstr (NCURSES_CONST char *, char **);
extern NCURSES_EXPORT(char *) tgoto (const char *, int, int);
extern NCURSES_EXPORT(int) tgetent (char *, const char *);
extern NCURSES_EXPORT(int) tgetflag (NCURSES_CONST char *);
extern NCURSES_EXPORT(int) tgetnum (NCURSES_CONST char *);
extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int));
#endif
#ifdef __cplusplus
}
#endif
#endif /* NCURSES_TERMCAP_H_incl */
nc_tparm.h 0000644 00000010145 15201526705 0006524 0 ustar 00 /****************************************************************************
* Copyright (c) 2006-2012,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included *
* in all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
* *
* Except as contained in this notice, the name(s) of the above copyright *
* holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written *
* authorization. *
****************************************************************************/
/****************************************************************************
* Author: Thomas E. Dickey 2006 *
****************************************************************************/
/* $Id: nc_tparm.h,v 1.8 2017/07/22 17:09:46 tom Exp $ */
#ifndef NC_TPARM_included
#define NC_TPARM_included 1
#include <ncurses_cfg.h>
#include <curses.h>
/*
* Cast parameters past the formatting-string for tparm() to match the
* assumption of the varargs code.
*/
#ifndef TPARM_ARG
#ifdef NCURSES_TPARM_ARG
#define TPARM_ARG NCURSES_TPARM_ARG
#else
#define TPARM_ARG long
#endif
#endif /* TPARAM_ARG */
#define TPARM_N(n) (TPARM_ARG)(n)
#define TPARM_9(a,b,c,d,e,f,g,h,i,j) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f),TPARM_N(g),TPARM_N(h),TPARM_N(i),TPARM_N(j))
#if NCURSES_TPARM_VARARGS
#define TPARM_8(a,b,c,d,e,f,g,h,i) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f),TPARM_N(g),TPARM_N(h),TPARM_N(i))
#define TPARM_7(a,b,c,d,e,f,g,h) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f),TPARM_N(g),TPARM_N(h))
#define TPARM_6(a,b,c,d,e,f,g) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f),TPARM_N(g))
#define TPARM_5(a,b,c,d,e,f) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f))
#define TPARM_4(a,b,c,d,e) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e))
#define TPARM_3(a,b,c,d) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d))
#define TPARM_2(a,b,c) tparm(a,TPARM_N(b),TPARM_N(c))
#define TPARM_1(a,b) tparm(a,TPARM_N(b))
#define TPARM_0(a) tparm(a)
#else
#define TPARM_8(a,b,c,d,e,f,g,h,i) TPARM_9(a,b,c,d,e,f,g,h,i,0)
#define TPARM_7(a,b,c,d,e,f,g,h) TPARM_8(a,b,c,d,e,f,g,h,0)
#define TPARM_6(a,b,c,d,e,f,g) TPARM_7(a,b,c,d,e,f,g,0)
#define TPARM_5(a,b,c,d,e,f) TPARM_6(a,b,c,d,e,f,0)
#define TPARM_4(a,b,c,d,e) TPARM_5(a,b,c,d,e,0)
#define TPARM_3(a,b,c,d) TPARM_4(a,b,c,d,0)
#define TPARM_2(a,b,c) TPARM_3(a,b,c,0)
#define TPARM_1(a,b) TPARM_2(a,b,0)
#define TPARM_1(a,b) TPARM_2(a,b,0)
#define TPARM_0(a) TPARM_1(a,0)
#endif
#endif /* NC_TPARM_included */
cursesw.h 0000644 00000141067 15201526705 0006424 0 ustar 00 // * This makes emacs happy -*-Mode: C++;-*-
// vile:cppmode
/****************************************************************************
* Copyright (c) 1998-2014,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included *
* in all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
* *
* Except as contained in this notice, the name(s) of the above copyright *
* holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written *
* authorization. *
****************************************************************************/
#ifndef NCURSES_CURSESW_H_incl
#define NCURSES_CURSESW_H_incl 1
// $Id: cursesw.h,v 1.53 2017/11/21 00:37:23 tom Exp $
extern "C" {
# include <curses.h>
}
#include <etip.h>
/* SCO 3.2v4 curses.h includes term.h, which defines lines as a macro.
Undefine it here, because NCursesWindow uses lines as a method. */
#undef lines
/* "Convert" macros to inlines. We'll define it as another symbol to avoid
* conflict with library symbols.
*/
#undef UNDEF
#define UNDEF(name) CUR_ ##name
#ifdef addch
inline int UNDEF(addch)(chtype ch) { return addch(ch); }
#undef addch
#define addch UNDEF(addch)
#endif
#ifdef addchstr
inline int UNDEF(addchstr)(chtype *at) { return addchstr(at); }
#undef addchstr
#define addchstr UNDEF(addchstr)
#endif
#ifdef addnstr
inline int UNDEF(addnstr)(const char *str, int n)
{ return addnstr(str, n); }
#undef addnstr
#define addnstr UNDEF(addnstr)
#endif
#ifdef addstr
inline int UNDEF(addstr)(const char * str) { return addstr(str); }
#undef addstr
#define addstr UNDEF(addstr)
#endif
#ifdef attroff
inline int UNDEF(attroff)(chtype at) { return attroff(at); }
#undef attroff
#define attroff UNDEF(attroff)
#endif
#ifdef attron
inline int UNDEF(attron)(chtype at) { return attron(at); }
#undef attron
#define attron UNDEF(attron)
#endif
#ifdef attrset
inline chtype UNDEF(attrset)(chtype at) { return attrset(at); }
#undef attrset
#define attrset UNDEF(attrset)
#endif
#ifdef bkgd
inline int UNDEF(bkgd)(chtype ch) { return bkgd(ch); }
#undef bkgd
#define bkgd UNDEF(bkgd)
#endif
#ifdef bkgdset
inline void UNDEF(bkgdset)(chtype ch) { bkgdset(ch); }
#undef bkgdset
#define bkgdset UNDEF(bkgdset)
#endif
#ifdef border
inline int UNDEF(border)(chtype ls, chtype rs, chtype ts, chtype bs, chtype tl, chtype tr, chtype bl, chtype br)
{ return border(ls, rs, ts, bs, tl, tr, bl, br); }
#undef border
#define border UNDEF(border)
#endif
#ifdef box
inline int UNDEF(box)(WINDOW *win, int v, int h) { return box(win, v, h); }
#undef box
#define box UNDEF(box)
#endif
#ifdef chgat
inline int UNDEF(chgat)(int n, attr_t attr, NCURSES_PAIRS_T color, const void *opts) {
return chgat(n, attr, color, opts); }
#undef chgat
#define chgat UNDEF(chgat)
#endif
#ifdef clear
inline int UNDEF(clear)() { return clear(); }
#undef clear
#define clear UNDEF(clear)
#endif
#ifdef clearok
inline int UNDEF(clearok)(WINDOW* win, bool bf) { return clearok(win, bf); }
#undef clearok
#define clearok UNDEF(clearok)
#else
extern "C" NCURSES_IMPEXP int NCURSES_API clearok(WINDOW*, bool);
#endif
#ifdef clrtobot
inline int UNDEF(clrtobot)() { return clrtobot(); }
#undef clrtobot
#define clrtobot UNDEF(clrtobot)
#endif
#ifdef clrtoeol
inline int UNDEF(clrtoeol)() { return clrtoeol(); }
#undef clrtoeol
#define clrtoeol UNDEF(clrtoeol)
#endif
#ifdef color_set
inline chtype UNDEF(color_set)(NCURSES_PAIRS_T p, void* opts) { return color_set(p, opts); }
#undef color_set
#define color_set UNDEF(color_set)
#endif
#ifdef crmode
inline int UNDEF(crmode)(void) { return crmode(); }
#undef crmode
#define crmode UNDEF(crmode)
#endif
#ifdef delch
inline int UNDEF(delch)() { return delch(); }
#undef delch
#define delch UNDEF(delch)
#endif
#ifdef deleteln
inline int UNDEF(deleteln)() { return deleteln(); }
#undef deleteln
#define deleteln UNDEF(deleteln)
#endif
#ifdef echochar
inline int UNDEF(echochar)(chtype ch) { return echochar(ch); }
#undef echochar
#define echochar UNDEF(echochar)
#endif
#ifdef erase
inline int UNDEF(erase)() { return erase(); }
#undef erase
#define erase UNDEF(erase)
#endif
#ifdef fixterm
inline int UNDEF(fixterm)(void) { return fixterm(); }
#undef fixterm
#define fixterm UNDEF(fixterm)
#endif
#ifdef flushok
inline int UNDEF(flushok)(WINDOW* _win, bool _bf) {
return flushok(_win, _bf); }
#undef flushok
#define flushok UNDEF(flushok)
#else
#define _no_flushok
#endif
#ifdef getattrs
inline int UNDEF(getattrs)(WINDOW *win) { return getattrs(win); }
#undef getattrs
#define getattrs UNDEF(getattrs)
#endif
#ifdef getbegyx
inline void UNDEF(getbegyx)(WINDOW* win, int& y, int& x) { getbegyx(win, y, x); }
#undef getbegyx
#define getbegyx UNDEF(getbegyx)
#endif
#ifdef getbkgd
inline chtype UNDEF(getbkgd)(const WINDOW *win) { return getbkgd(win); }
#undef getbkgd
#define getbkgd UNDEF(getbkgd)
#endif
#ifdef getch
inline int UNDEF(getch)() { return getch(); }
#undef getch
#define getch UNDEF(getch)
#endif
#ifdef getmaxyx
inline void UNDEF(getmaxyx)(WINDOW* win, int& y, int& x) { getmaxyx(win, y, x); }
#undef getmaxyx
#define getmaxyx UNDEF(getmaxyx)
#endif
#ifdef getnstr
inline int UNDEF(getnstr)(char *_str, int n) { return getnstr(_str, n); }
#undef getnstr
#define getnstr UNDEF(getnstr)
#endif
#ifdef getparyx
inline void UNDEF(getparyx)(WINDOW* win, int& y, int& x) { getparyx(win, y, x); }
#undef getparyx
#define getparyx UNDEF(getparyx)
#endif
#ifdef getstr
inline int UNDEF(getstr)(char *_str) { return getstr(_str); }
#undef getstr
#define getstr UNDEF(getstr)
#endif
#ifdef getyx
inline void UNDEF(getyx)(const WINDOW* win, int& y, int& x) {
getyx(win, y, x); }
#undef getyx
#define getyx UNDEF(getyx)
#endif
#ifdef hline
inline int UNDEF(hline)(chtype ch, int n) { return hline(ch, n); }
#undef hline
#define hline UNDEF(hline)
#endif
#ifdef inch
inline chtype UNDEF(inch)() { return inch(); }
#undef inch
#define inch UNDEF(inch)
#endif
#ifdef inchstr
inline int UNDEF(inchstr)(chtype *str) { return inchstr(str); }
#undef inchstr
#define inchstr UNDEF(inchstr)
#endif
#ifdef innstr
inline int UNDEF(innstr)(char *_str, int n) { return innstr(_str, n); }
#undef innstr
#define innstr UNDEF(innstr)
#endif
#ifdef insch
inline int UNDEF(insch)(chtype c) { return insch(c); }
#undef insch
#define insch UNDEF(insch)
#endif
#ifdef insdelln
inline int UNDEF(insdelln)(int n) { return insdelln(n); }
#undef insdelln
#define insdelln UNDEF(insdelln)
#endif
#ifdef insertln
inline int UNDEF(insertln)() { return insertln(); }
#undef insertln
#define insertln UNDEF(insertln)
#endif
#ifdef insnstr
inline int UNDEF(insnstr)(const char *_str, int n) {
return insnstr(_str, n); }
#undef insnstr
#define insnstr UNDEF(insnstr)
#endif
#ifdef insstr
inline int UNDEF(insstr)(const char *_str) {
return insstr(_str); }
#undef insstr
#define insstr UNDEF(insstr)
#endif
#ifdef instr
inline int UNDEF(instr)(char *_str) { return instr(_str); }
#undef instr
#define instr UNDEF(instr)
#endif
#ifdef intrflush
inline void UNDEF(intrflush)(WINDOW *win, bool bf) { intrflush(); }
#undef intrflush
#define intrflush UNDEF(intrflush)
#endif
#ifdef is_linetouched
inline int UNDEF(is_linetouched)(WINDOW *w, int l) { return is_linetouched(w,l); }
#undef is_linetouched
#define is_linetouched UNDEF(is_linetouched)
#endif
#ifdef leaveok
inline int UNDEF(leaveok)(WINDOW* win, bool bf) { return leaveok(win, bf); }
#undef leaveok
#define leaveok UNDEF(leaveok)
#else
extern "C" NCURSES_IMPEXP int NCURSES_API leaveok(WINDOW* win, bool bf);
#endif
#ifdef move
inline int UNDEF(move)(int x, int y) { return move(x, y); }
#undef move
#define move UNDEF(move)
#endif
#ifdef mvaddch
inline int UNDEF(mvaddch)(int y, int x, chtype ch)
{ return mvaddch(y, x, ch); }
#undef mvaddch
#define mvaddch UNDEF(mvaddch)
#endif
#ifdef mvaddnstr
inline int UNDEF(mvaddnstr)(int y, int x, const char *str, int n)
{ return mvaddnstr(y, x, str, n); }
#undef mvaddnstr
#define mvaddnstr UNDEF(mvaddnstr)
#endif
#ifdef mvaddstr
inline int UNDEF(mvaddstr)(int y, int x, const char * str)
{ return mvaddstr(y, x, str); }
#undef mvaddstr
#define mvaddstr UNDEF(mvaddstr)
#endif
#ifdef mvchgat
inline int UNDEF(mvchgat)(int y, int x, int n,
attr_t attr, NCURSES_PAIRS_T color, const void *opts) {
return mvchgat(y, x, n, attr, color, opts); }
#undef mvchgat
#define mvchgat UNDEF(mvchgat)
#endif
#ifdef mvdelch
inline int UNDEF(mvdelch)(int y, int x) { return mvdelch(y, x);}
#undef mvdelch
#define mvdelch UNDEF(mvdelch)
#endif
#ifdef mvgetch
inline int UNDEF(mvgetch)(int y, int x) { return mvgetch(y, x);}
#undef mvgetch
#define mvgetch UNDEF(mvgetch)
#endif
#ifdef mvgetnstr
inline int UNDEF(mvgetnstr)(int y, int x, char *str, int n) {
return mvgetnstr(y, x, str, n);}
#undef mvgetnstr
#define mvgetnstr UNDEF(mvgetnstr)
#endif
#ifdef mvgetstr
inline int UNDEF(mvgetstr)(int y, int x, char *str) {return mvgetstr(y, x, str);}
#undef mvgetstr
#define mvgetstr UNDEF(mvgetstr)
#endif
#ifdef mvinch
inline chtype UNDEF(mvinch)(int y, int x) { return mvinch(y, x);}
#undef mvinch
#define mvinch UNDEF(mvinch)
#endif
#ifdef mvinnstr
inline int UNDEF(mvinnstr)(int y, int x, char *_str, int n) {
return mvinnstr(y, x, _str, n); }
#undef mvinnstr
#define mvinnstr UNDEF(mvinnstr)
#endif
#ifdef mvinsch
inline int UNDEF(mvinsch)(int y, int x, chtype c)
{ return mvinsch(y, x, c); }
#undef mvinsch
#define mvinsch UNDEF(mvinsch)
#endif
#ifdef mvinsnstr
inline int UNDEF(mvinsnstr)(int y, int x, const char *_str, int n) {
return mvinsnstr(y, x, _str, n); }
#undef mvinsnstr
#define mvinsnstr UNDEF(mvinsnstr)
#endif
#ifdef mvinsstr
inline int UNDEF(mvinsstr)(int y, int x, const char *_str) {
return mvinsstr(y, x, _str); }
#undef mvinsstr
#define mvinsstr UNDEF(mvinsstr)
#endif
#ifdef mvwaddch
inline int UNDEF(mvwaddch)(WINDOW *win, int y, int x, const chtype ch)
{ return mvwaddch(win, y, x, ch); }
#undef mvwaddch
#define mvwaddch UNDEF(mvwaddch)
#endif
#ifdef mvwaddchnstr
inline int UNDEF(mvwaddchnstr)(WINDOW *win, int y, int x, const chtype *str, int n)
{ return mvwaddchnstr(win, y, x, str, n); }
#undef mvwaddchnstr
#define mvwaddchnstr UNDEF(mvwaddchnstr)
#endif
#ifdef mvwaddchstr
inline int UNDEF(mvwaddchstr)(WINDOW *win, int y, int x, const chtype *str)
{ return mvwaddchstr(win, y, x, str); }
#undef mvwaddchstr
#define mvwaddchstr UNDEF(mvwaddchstr)
#endif
#ifdef mvwaddnstr
inline int UNDEF(mvwaddnstr)(WINDOW *win, int y, int x, const char *str, int n)
{ return mvwaddnstr(win, y, x, str, n); }
#undef mvwaddnstr
#define mvwaddnstr UNDEF(mvwaddnstr)
#endif
#ifdef mvwaddstr
inline int UNDEF(mvwaddstr)(WINDOW *win, int y, int x, const char * str)
{ return mvwaddstr(win, y, x, str); }
#undef mvwaddstr
#define mvwaddstr UNDEF(mvwaddstr)
#endif
#ifdef mvwchgat
inline int UNDEF(mvwchgat)(WINDOW *win, int y, int x, int n,
attr_t attr, NCURSES_PAIRS_T color, const void *opts) {
return mvwchgat(win, y, x, n, attr, color, opts); }
#undef mvwchgat
#define mvwchgat UNDEF(mvwchgat)
#endif
#ifdef mvwdelch
inline int UNDEF(mvwdelch)(WINDOW *win, int y, int x)
{ return mvwdelch(win, y, x); }
#undef mvwdelch
#define mvwdelch UNDEF(mvwdelch)
#endif
#ifdef mvwgetch
inline int UNDEF(mvwgetch)(WINDOW *win, int y, int x) { return mvwgetch(win, y, x);}
#undef mvwgetch
#define mvwgetch UNDEF(mvwgetch)
#endif
#ifdef mvwgetnstr
inline int UNDEF(mvwgetnstr)(WINDOW *win, int y, int x, char *str, int n)
{return mvwgetnstr(win, y, x, str, n);}
#undef mvwgetnstr
#define mvwgetnstr UNDEF(mvwgetnstr)
#endif
#ifdef mvwgetstr
inline int UNDEF(mvwgetstr)(WINDOW *win, int y, int x, char *str)
{return mvwgetstr(win, y, x, str);}
#undef mvwgetstr
#define mvwgetstr UNDEF(mvwgetstr)
#endif
#ifdef mvwhline
inline int UNDEF(mvwhline)(WINDOW *win, int y, int x, chtype c, int n) {
return mvwhline(win, y, x, c, n); }
#undef mvwhline
#define mvwhline UNDEF(mvwhline)
#endif
#ifdef mvwinch
inline chtype UNDEF(mvwinch)(WINDOW *win, int y, int x) {
return mvwinch(win, y, x);}
#undef mvwinch
#define mvwinch UNDEF(mvwinch)
#endif
#ifdef mvwinchnstr
inline int UNDEF(mvwinchnstr)(WINDOW *win, int y, int x, chtype *str, int n) { return mvwinchnstr(win, y, x, str, n); }
#undef mvwinchnstr
#define mvwinchnstr UNDEF(mvwinchnstr)
#endif
#ifdef mvwinchstr
inline int UNDEF(mvwinchstr)(WINDOW *win, int y, int x, chtype *str) { return mvwinchstr(win, y, x, str); }
#undef mvwinchstr
#define mvwinchstr UNDEF(mvwinchstr)
#endif
#ifdef mvwinnstr
inline int UNDEF(mvwinnstr)(WINDOW *win, int y, int x, char *_str, int n) {
return mvwinnstr(win, y, x, _str, n); }
#undef mvwinnstr
#define mvwinnstr UNDEF(mvwinnstr)
#endif
#ifdef mvwinsch
inline int UNDEF(mvwinsch)(WINDOW *win, int y, int x, chtype c)
{ return mvwinsch(win, y, x, c); }
#undef mvwinsch
#define mvwinsch UNDEF(mvwinsch)
#endif
#ifdef mvwinsnstr
inline int UNDEF(mvwinsnstr)(WINDOW *w, int y, int x, const char *_str, int n) {
return mvwinsnstr(w, y, x, _str, n); }
#undef mvwinsnstr
#define mvwinsnstr UNDEF(mvwinsnstr)
#endif
#ifdef mvwinsstr
inline int UNDEF(mvwinsstr)(WINDOW *w, int y, int x, const char *_str) {
return mvwinsstr(w, y, x, _str); }
#undef mvwinsstr
#define mvwinsstr UNDEF(mvwinsstr)
#endif
#ifdef mvwvline
inline int UNDEF(mvwvline)(WINDOW *win, int y, int x, chtype c, int n) {
return mvwvline(win, y, x, c, n); }
#undef mvwvline
#define mvwvline UNDEF(mvwvline)
#endif
#ifdef napms
inline void UNDEF(napms)(unsigned long x) { napms(x); }
#undef napms
#define napms UNDEF(napms)
#endif
#ifdef nocrmode
inline int UNDEF(nocrmode)(void) { return nocrmode(); }
#undef nocrmode
#define nocrmode UNDEF(nocrmode)
#endif
#ifdef nodelay
inline void UNDEF(nodelay)() { nodelay(); }
#undef nodelay
#define nodelay UNDEF(nodelay)
#endif
#ifdef redrawwin
inline int UNDEF(redrawwin)(WINDOW *win) { return redrawwin(win); }
#undef redrawwin
#define redrawwin UNDEF(redrawwin)
#endif
#ifdef refresh
inline int UNDEF(refresh)() { return refresh(); }
#undef refresh
#define refresh UNDEF(refresh)
#endif
#ifdef resetterm
inline int UNDEF(resetterm)(void) { return resetterm(); }
#undef resetterm
#define resetterm UNDEF(resetterm)
#endif
#ifdef saveterm
inline int UNDEF(saveterm)(void) { return saveterm(); }
#undef saveterm
#define saveterm UNDEF(saveterm)
#endif
#ifdef scrl
inline int UNDEF(scrl)(int l) { return scrl(l); }
#undef scrl
#define scrl UNDEF(scrl)
#endif
#ifdef scroll
inline int UNDEF(scroll)(WINDOW *win) { return scroll(win); }
#undef scroll
#define scroll UNDEF(scroll)
#endif
#ifdef scrollok
inline int UNDEF(scrollok)(WINDOW* win, bool bf) { return scrollok(win, bf); }
#undef scrollok
#define scrollok UNDEF(scrollok)
#else
#if defined(__NCURSES_H)
extern "C" NCURSES_IMPEXP int NCURSES_API scrollok(WINDOW*, bool);
#else
extern "C" NCURSES_IMPEXP int NCURSES_API scrollok(WINDOW*, char);
#endif
#endif
#ifdef setscrreg
inline int UNDEF(setscrreg)(int t, int b) { return setscrreg(t, b); }
#undef setscrreg
#define setscrreg UNDEF(setscrreg)
#endif
#ifdef standend
inline int UNDEF(standend)() { return standend(); }
#undef standend
#define standend UNDEF(standend)
#endif
#ifdef standout
inline int UNDEF(standout)() { return standout(); }
#undef standout
#define standout UNDEF(standout)
#endif
#ifdef subpad
inline WINDOW *UNDEF(subpad)(WINDOW *p, int l, int c, int y, int x)
{ return derwin(p, l, c, y, x); }
#undef subpad
#define subpad UNDEF(subpad)
#endif
#ifdef timeout
inline void UNDEF(timeout)(int delay) { timeout(delay); }
#undef timeout
#define timeout UNDEF(timeout)
#endif
#ifdef touchline
inline int UNDEF(touchline)(WINDOW *win, int s, int c)
{ return touchline(win, s, c); }
#undef touchline
#define touchline UNDEF(touchline)
#endif
#ifdef touchwin
inline int UNDEF(touchwin)(WINDOW *win) { return touchwin(win); }
#undef touchwin
#define touchwin UNDEF(touchwin)
#endif
#ifdef untouchwin
inline int UNDEF(untouchwin)(WINDOW *win) { return untouchwin(win); }
#undef untouchwin
#define untouchwin UNDEF(untouchwin)
#endif
#ifdef vline
inline int UNDEF(vline)(chtype ch, int n) { return vline(ch, n); }
#undef vline
#define vline UNDEF(vline)
#endif
#ifdef waddchstr
inline int UNDEF(waddchstr)(WINDOW *win, chtype *at) { return waddchstr(win, at); }
#undef waddchstr
#define waddchstr UNDEF(waddchstr)
#endif
#ifdef waddstr
inline int UNDEF(waddstr)(WINDOW *win, char *str) { return waddstr(win, str); }
#undef waddstr
#define waddstr UNDEF(waddstr)
#endif
#ifdef wattroff
inline int UNDEF(wattroff)(WINDOW *win, int att) { return wattroff(win, att); }
#undef wattroff
#define wattroff UNDEF(wattroff)
#endif
#ifdef wattrset
inline int UNDEF(wattrset)(WINDOW *win, int att) { return wattrset(win, att); }
#undef wattrset
#define wattrset UNDEF(wattrset)
#endif
#ifdef winch
inline chtype UNDEF(winch)(const WINDOW* win) { return winch(win); }
#undef winch
#define winch UNDEF(winch)
#endif
#ifdef winchnstr
inline int UNDEF(winchnstr)(WINDOW *win, chtype *str, int n) { return winchnstr(win, str, n); }
#undef winchnstr
#define winchnstr UNDEF(winchnstr)
#endif
#ifdef winchstr
inline int UNDEF(winchstr)(WINDOW *win, chtype *str) { return winchstr(win, str); }
#undef winchstr
#define winchstr UNDEF(winchstr)
#endif
#ifdef winsstr
inline int UNDEF(winsstr)(WINDOW *w, const char *_str) {
return winsstr(w, _str); }
#undef winsstr
#define winsstr UNDEF(winsstr)
#endif
#ifdef wstandend
inline int UNDEF(wstandend)(WINDOW *win) { return wstandend(win); }
#undef wstandend
#define wstandend UNDEF(wstandend)
#endif
#ifdef wstandout
inline int UNDEF(wstandout)(WINDOW *win) { return wstandout(win); }
#undef wstandout
#define wstandout UNDEF(wstandout)
#endif
/*
*
* C++ class for windows.
*
*/
extern "C" int _nc_ripoffline(int, int (*init)(WINDOW*, int));
extern "C" int _nc_xx_ripoff_init(WINDOW *, int);
extern "C" int _nc_has_mouse(void);
class NCURSES_IMPEXP NCursesWindow
{
friend class NCursesMenu;
friend class NCursesForm;
private:
static bool b_initialized;
static void initialize();
void constructing();
friend int _nc_xx_ripoff_init(WINDOW *, int);
void set_keyboard();
NCURSES_COLOR_T getcolor(int getback) const;
NCURSES_PAIRS_T getPair() const;
static int setpalette(NCURSES_COLOR_T fore, NCURSES_COLOR_T back, NCURSES_PAIRS_T pair);
static int colorInitialized;
// This private constructor is only used during the initialization
// of windows generated by ripoffline() calls.
NCursesWindow(WINDOW* win, int ncols);
protected:
virtual void err_handler(const char *) const THROWS(NCursesException);
// Signal an error with the given message text.
static long count; // count of all active windows:
// We rely on the c++ promise that
// all otherwise uninitialized
// static class vars are set to 0
WINDOW* w; // the curses WINDOW
bool alloced; // TRUE if we own the WINDOW
NCursesWindow* par; // parent, if subwindow
NCursesWindow* subwins; // head of subwindows list
NCursesWindow* sib; // next subwindow of parent
void kill_subwindows(); // disable all subwindows
// Destroy all subwindows.
/* Only for use by derived classes. They are then in charge to
fill the member variables correctly. */
NCursesWindow();
public:
NCursesWindow(WINDOW* window); // useful only for stdscr
NCursesWindow(int nlines, // number of lines
int ncols, // number of columns
int begin_y, // line origin
int begin_x); // col origin
NCursesWindow(NCursesWindow& par,// parent window
int nlines, // number of lines
int ncols, // number of columns
int begin_y, // absolute or relative
int begin_x, // origins:
char absrel = 'a');// if `a', begin_y & begin_x are
// absolute screen pos, else if `r', they are relative to par origin
NCursesWindow(NCursesWindow& par,// parent window
bool do_box = TRUE);
// this is the very common case that we want to create the subwindow that
// is two lines and two columns smaller and begins at (1,1).
// We may automatically request the box around it.
NCursesWindow& operator=(const NCursesWindow& rhs)
{
if (this != &rhs)
*this = rhs;
return *this;
}
NCursesWindow(const NCursesWindow& rhs)
: w(rhs.w), alloced(rhs.alloced), par(rhs.par), subwins(rhs.subwins), sib(rhs.sib)
{
}
virtual ~NCursesWindow();
NCursesWindow Clone();
// Make an exact copy of the window.
// Initialization.
static void useColors(void);
// Call this routine very early if you want to have colors.
static int ripoffline(int ripoff_lines,
int (*init)(NCursesWindow& win));
// This function is used to generate a window of ripped-of lines.
// If the argument is positive, lines are removed from the top, if it
// is negative lines are removed from the bottom. This enhances the
// lowlevel ripoffline() function because it uses the internal
// implementation that allows to remove more than just a single line.
// This function must be called before any other ncurses function. The
// creation of the window is deferred until ncurses gets initialized.
// The initialization function is then called.
// -------------------------------------------------------------------------
// terminal status
// -------------------------------------------------------------------------
int lines() const { initialize(); return LINES; }
// Number of lines on terminal, *not* window
int cols() const { initialize(); return COLS; }
// Number of cols on terminal, *not* window
int tabsize() const { initialize(); return TABSIZE; }
// Size of a tab on terminal, *not* window
static int NumberOfColors();
// Number of available colors
int colors() const { return NumberOfColors(); }
// Number of available colors
// -------------------------------------------------------------------------
// window status
// -------------------------------------------------------------------------
int height() const { return maxy() + 1; }
// Number of lines in this window
int width() const { return maxx() + 1; }
// Number of columns in this window
int begx() const { return getbegx(w); }
// Column of top left corner relative to stdscr
int begy() const { return getbegy(w); }
// Line of top left corner relative to stdscr
int curx() const { return getcurx(w); }
// Column of top left corner relative to stdscr
int cury() const { return getcury(w); }
// Line of top left corner relative to stdscr
int maxx() const { return getmaxx(w) == ERR ? ERR : getmaxx(w)-1; }
// Largest x coord in window
int maxy() const { return getmaxy(w) == ERR ? ERR : getmaxy(w)-1; }
// Largest y coord in window
NCURSES_PAIRS_T getcolor() const;
// Actual color pair
NCURSES_COLOR_T foreground() const { return getcolor(0); }
// Actual foreground color
NCURSES_COLOR_T background() const { return getcolor(1); }
// Actual background color
int setpalette(NCURSES_COLOR_T fore, NCURSES_COLOR_T back);
// Set color palette entry
int setcolor(NCURSES_PAIRS_T pair);
// Set actually used palette entry
// -------------------------------------------------------------------------
// window positioning
// -------------------------------------------------------------------------
virtual int mvwin(int begin_y, int begin_x) {
return ::mvwin(w, begin_y, begin_x); }
// Move window to new position with the new position as top left corner.
// This is virtual because it is redefined in NCursesPanel.
// -------------------------------------------------------------------------
// coordinate positioning
// -------------------------------------------------------------------------
int move(int y, int x) { return ::wmove(w, y, x); }
// Move cursor the this position
void getyx(int& y, int& x) const { ::getyx(w, y, x); }
// Get current position of the cursor
void getbegyx(int& y, int& x) const { ::getbegyx(w, y, x); }
// Get beginning of the window
void getmaxyx(int& y, int& x) const { ::getmaxyx(w, y, x); }
// Get size of the window
void getparyx(int& y, int& x) const { ::getparyx(w, y, x); }
// Get parent's beginning of the window
int mvcur(int oldrow, int oldcol, int newrow, int newcol) const {
return ::mvcur(oldrow, oldcol, newrow, newcol); }
// Perform lowlevel cursor motion that takes effect immediately.
// -------------------------------------------------------------------------
// input
// -------------------------------------------------------------------------
int getch() { return ::wgetch(w); }
// Get a keystroke from the window.
int getch(int y, int x) { return ::mvwgetch(w, y, x); }
// Move cursor to position and get a keystroke from the window
int getstr(char* str, int n=-1) {
return ::wgetnstr(w, str, n); }
// Read a series of characters into str until a newline or carriage return
// is received. Read at most n characters. If n is negative, the limit is
// ignored.
int getstr(int y, int x, char* str, int n=-1) {
return ::mvwgetnstr(w, y, x, str, n); }
// Move the cursor to the requested position and then perform the getstr()
// as described above.
int instr(char *s, int n=-1) { return ::winnstr(w, s, n); }
// Get a string of characters from the window into the buffer s. Retrieve
// at most n characters, if n is negative retrieve all characters up to the
// end of the current line. Attributes are stripped from the characters.
int instr(int y, int x, char *s, int n=-1) {
return ::mvwinnstr(w, y, x, s, n); }
// Move the cursor to the requested position and then perform the instr()
// as described above.
int scanw(const char* fmt, ...)
// Perform a scanw function from the window.
#if __GNUG__ >= 2
__attribute__ ((format (scanf, 2, 3)));
#else
;
#endif
int scanw(const char*, va_list);
// Perform a scanw function from the window.
int scanw(int y, int x, const char* fmt, ...)
// Move the cursor to the requested position and then perform a scanw
// from the window.
#if __GNUG__ >= 2
__attribute__ ((format (scanf, 4, 5)));
#else
;
#endif
int scanw(int y, int x, const char* fmt, va_list);
// Move the cursor to the requested position and then perform a scanw
// from the window.
// -------------------------------------------------------------------------
// output
// -------------------------------------------------------------------------
int addch(const chtype ch) { return ::waddch(w, ch); }
// Put attributed character to the window.
int addch(int y, int x, const chtype ch) {
return ::mvwaddch(w, y, x, ch); }
// Move cursor to the requested position and then put attributed character
// to the window.
int echochar(const chtype ch) { return ::wechochar(w, ch); }
// Put attributed character to the window and refresh it immediately.
int addstr(const char* str, int n=-1) {
return ::waddnstr(w, str, n); }
// Write the string str to the window, stop writing if the terminating
// NUL or the limit n is reached. If n is negative, it is ignored.
int addstr(int y, int x, const char * str, int n=-1) {
return ::mvwaddnstr(w, y, x, str, n); }
// Move the cursor to the requested position and then perform the addchstr
// as described above.
int addchstr(const chtype* str, int n=-1) {
return ::waddchnstr(w, str, n); }
// Write the string str to the window, stop writing if the terminating
// NUL or the limit n is reached. If n is negative, it is ignored.
int addchstr(int y, int x, const chtype * str, int n=-1) {
return ::mvwaddchnstr(w, y, x, str, n); }
// Move the cursor to the requested position and then perform the addchstr
// as described above.
int printw(const char* fmt, ...)
// Do a formatted print to the window.
#if (__GNUG__ >= 2) && !defined(printf)
__attribute__ ((format (printf, 2, 3)));
#else
;
#endif
int printw(int y, int x, const char * fmt, ...)
// Move the cursor and then do a formatted print to the window.
#if (__GNUG__ >= 2) && !defined(printf)
__attribute__ ((format (printf, 4, 5)));
#else
;
#endif
int printw(const char* fmt, va_list args);
// Do a formatted print to the window.
int printw(int y, int x, const char * fmt, va_list args);
// Move the cursor and then do a formatted print to the window.
chtype inch() const { return ::winch(w); }
// Retrieve attributed character under the current cursor position.
chtype inch(int y, int x) { return ::mvwinch(w, y, x); }
// Move cursor to requested position and then retrieve attributed character
// at this position.
int inchstr(chtype* str, int n=-1) {
return ::winchnstr(w, str, n); }
// Read the string str from the window, stop reading if the terminating
// NUL or the limit n is reached. If n is negative, it is ignored.
int inchstr(int y, int x, chtype * str, int n=-1) {
return ::mvwinchnstr(w, y, x, str, n); }
// Move the cursor to the requested position and then perform the inchstr
// as described above.
int insch(chtype ch) { return ::winsch(w, ch); }
// Insert attributed character into the window before current cursor
// position.
int insch(int y, int x, chtype ch) {
return ::mvwinsch(w, y, x, ch); }
// Move cursor to requested position and then insert the attributed
// character before that position.
int insertln() { return ::winsdelln(w, 1); }
// Insert an empty line above the current line.
int insdelln(int n=1) { return ::winsdelln(w, n); }
// If n>0 insert that many lines above the current line. If n<0 delete
// that many lines beginning with the current line.
int insstr(const char *s, int n=-1) {
return ::winsnstr(w, s, n); }
// Insert the string into the window before the current cursor position.
// Insert stops at end of string or when the limit n is reached. If n is
// negative, it is ignored.
int insstr(int y, int x, const char *s, int n=-1) {
return ::mvwinsnstr(w, y, x, s, n); }
// Move the cursor to the requested position and then perform the insstr()
// as described above.
int attron (chtype at) { return ::wattron (w, at); }
// Switch on the window attributes;
int attroff(chtype at) { return ::wattroff(w, static_cast<int>(at)); }
// Switch off the window attributes;
int attrset(chtype at) { return ::wattrset(w, static_cast<int>(at)); }
// Set the window attributes;
chtype attrget() { return ::getattrs(w); }
// Get the window attributes;
int color_set(NCURSES_PAIRS_T color_pair_number, void* opts=NULL) {
return ::wcolor_set(w, color_pair_number, opts); }
// Set the window color attribute;
int chgat(int n, attr_t attr, NCURSES_PAIRS_T color, const void *opts=NULL) {
return ::wchgat(w, n, attr, color, opts); }
// Change the attributes of the next n characters in the current line. If
// n is negative or greater than the number of remaining characters in the
// line, the attributes will be changed up to the end of the line.
int chgat(int y, int x,
int n, attr_t attr, NCURSES_PAIRS_T color, const void *opts=NULL) {
return ::mvwchgat(w, y, x, n, attr, color, opts); }
// Move the cursor to the requested position and then perform chgat() as
// described above.
// -------------------------------------------------------------------------
// background
// -------------------------------------------------------------------------
chtype getbkgd() const { return ::getbkgd(w); }
// Get current background setting.
int bkgd(const chtype ch) { return ::wbkgd(w, ch); }
// Set the background property and apply it to the window.
void bkgdset(chtype ch) { ::wbkgdset(w, ch); }
// Set the background property.
// -------------------------------------------------------------------------
// borders
// -------------------------------------------------------------------------
int box(chtype vert=0, chtype hor=0) {
return ::wborder(w, vert, vert, hor, hor, 0, 0, 0, 0); }
// Draw a box around the window with the given vertical and horizontal
// drawing characters. If you specify a zero as character, curses will try
// to find a "nice" character.
int border(chtype left=0, chtype right=0,
chtype top =0, chtype bottom=0,
chtype top_left =0, chtype top_right=0,
chtype bottom_left =0, chtype bottom_right=0) {
return ::wborder(w, left, right, top, bottom, top_left, top_right,
bottom_left, bottom_right); }
// Draw a border around the window with the given characters for the
// various parts of the border. If you pass zero for a character, curses
// will try to find "nice" characters.
// -------------------------------------------------------------------------
// lines and boxes
// -------------------------------------------------------------------------
int hline(int len, chtype ch=0) { return ::whline(w, ch, len); }
// Draw a horizontal line of len characters with the given character. If
// you pass zero for the character, curses will try to find a "nice" one.
int hline(int y, int x, int len, chtype ch=0) {
return ::mvwhline(w, y, x, ch, len); }
// Move the cursor to the requested position and then draw a horizontal line.
int vline(int len, chtype ch=0) { return ::wvline(w, ch, len); }
// Draw a vertical line of len characters with the given character. If
// you pass zero for the character, curses will try to find a "nice" one.
int vline(int y, int x, int len, chtype ch=0) {
return ::mvwvline(w, y, x, ch, len); }
// Move the cursor to the requested position and then draw a vertical line.
// -------------------------------------------------------------------------
// erasure
// -------------------------------------------------------------------------
int erase() { return ::werase(w); }
// Erase the window.
int clear() { return ::wclear(w); }
// Clear the window.
int clearok(bool bf) { return ::clearok(w, bf); }
// Set/Reset the clear flag. If set, the next refresh() will clear the
// screen.
int clrtobot() { return ::wclrtobot(w); }
// Clear to the end of the window.
int clrtoeol() { return ::wclrtoeol(w); }
// Clear to the end of the line.
int delch() { return ::wdelch(w); }
// Delete character under the cursor.
int delch(int y, int x) { return ::mvwdelch(w, y, x); }
// Move cursor to requested position and delete the character under the
// cursor.
int deleteln() { return ::winsdelln(w, -1); }
// Delete the current line.
// -------------------------------------------------------------------------
// screen control
// -------------------------------------------------------------------------
int scroll(int amount=1) { return ::wscrl(w, amount); }
// Scroll amount lines. If amount is positive, scroll up, otherwise
// scroll down.
int scrollok(bool bf) { return ::scrollok(w, bf); }
// If bf is TRUE, window scrolls if cursor is moved off the bottom
// edge of the window or a scrolling region, otherwise the cursor is left
// at the bottom line.
int setscrreg(int from, int to) {
return ::wsetscrreg(w, from, to); }
// Define a soft scrolling region.
int idlok(bool bf) { return ::idlok(w, bf); }
// If bf is TRUE, use insert/delete line hardware support if possible.
// Otherwise do it in software.
void idcok(bool bf) { ::idcok(w, bf); }
// If bf is TRUE, use insert/delete character hardware support if possible.
// Otherwise do it in software.
int touchline(int s, int c) { return ::touchline(w, s, c); }
// Mark the given lines as modified.
int touchwin() { return ::wtouchln(w, 0, height(), 1); }
// Mark the whole window as modified.
int untouchwin() { return ::wtouchln(w, 0, height(), 0); }
// Mark the whole window as unmodified.
int touchln(int s, int cnt, bool changed=TRUE) {
return ::wtouchln(w, s, cnt, static_cast<int>(changed ? 1 : 0)); }
// Mark cnt lines beginning from line s as changed or unchanged, depending
// on the value of the changed flag.
bool is_linetouched(int line) const {
return (::is_linetouched(w, line) == TRUE ? TRUE:FALSE); }
// Return TRUE if line is marked as changed, FALSE otherwise
bool is_wintouched() const {
return (::is_wintouched(w) ? TRUE:FALSE); }
// Return TRUE if window is marked as changed, FALSE otherwise
int leaveok(bool bf) { return ::leaveok(w, bf); }
// If bf is TRUE, curses will leave the cursor after an update whereever
// it is after the update.
int redrawln(int from, int n) { return ::wredrawln(w, from, n); }
// Redraw n lines starting from the requested line
int redrawwin() { return ::wredrawln(w, 0, height()); }
// Redraw the whole window
int doupdate() { return ::doupdate(); }
// Do all outputs to make the physical screen looking like the virtual one
void syncdown() { ::wsyncdown(w); }
// Propagate the changes down to all descendant windows
void syncup() { ::wsyncup(w); }
// Propagate the changes up in the hierarchy
void cursyncup() { ::wcursyncup(w); }
// Position the cursor in all ancestor windows corresponding to our setting
int syncok(bool bf) { return ::syncok(w, bf); }
// If called with bf=TRUE, syncup() is called whenever the window is changed
#ifndef _no_flushok
int flushok(bool bf) { return ::flushok(w, bf); }
#endif
void immedok(bool bf) { ::immedok(w, bf); }
// If called with bf=TRUE, any change in the window will cause an
// automatic immediate refresh()
int intrflush(bool bf) { return ::intrflush(w, bf); }
int keypad(bool bf) { return ::keypad(w, bf); }
// If called with bf=TRUE, the application will interpret function keys.
int nodelay(bool bf) { return ::nodelay(w, bf); }
int meta(bool bf) { return ::meta(w, bf); }
// If called with bf=TRUE, keys may generate 8-Bit characters. Otherwise
// 7-Bit characters are generated.
int standout() { return ::wstandout(w); }
// Enable "standout" attributes
int standend() { return ::wstandend(w); }
// Disable "standout" attributes
// -------------------------------------------------------------------------
// The next two are virtual, because we redefine them in the
// NCursesPanel class.
// -------------------------------------------------------------------------
virtual int refresh() { return ::wrefresh(w); }
// Propagate the changes in this window to the virtual screen and call
// doupdate(). This is redefined in NCursesPanel.
virtual int noutrefresh() { return ::wnoutrefresh(w); }
// Propagate the changes in this window to the virtual screen. This is
// redefined in NCursesPanel.
// -------------------------------------------------------------------------
// multiple window control
// -------------------------------------------------------------------------
int overlay(NCursesWindow& win) {
return ::overlay(w, win.w); }
// Overlay this window over win.
int overwrite(NCursesWindow& win) {
return ::overwrite(w, win.w); }
// Overwrite win with this window.
int copywin(NCursesWindow& win,
int sminrow, int smincol,
int dminrow, int dmincol,
int dmaxrow, int dmaxcol, bool overlaywin=TRUE) {
return ::copywin(w, win.w, sminrow, smincol, dminrow, dmincol,
dmaxrow, dmaxcol, static_cast<int>(overlaywin ? 1 : 0)); }
// Overlay or overwrite the rectangle in win given by dminrow,dmincol,
// dmaxrow,dmaxcol with the rectangle in this window beginning at
// sminrow,smincol.
// -------------------------------------------------------------------------
// Extended functions
// -------------------------------------------------------------------------
#if defined(NCURSES_EXT_FUNCS) && (NCURSES_EXT_FUNCS != 0)
int wresize(int newLines, int newColumns) {
return ::wresize(w, newLines, newColumns); }
#endif
// -------------------------------------------------------------------------
// Mouse related
// -------------------------------------------------------------------------
bool has_mouse() const;
// Return TRUE if terminal supports a mouse, FALSE otherwise
// -------------------------------------------------------------------------
// traversal support
// -------------------------------------------------------------------------
NCursesWindow* child() { return subwins; }
// Get the first child window.
NCursesWindow* sibling() { return sib; }
// Get the next child of my parent.
NCursesWindow* parent() { return par; }
// Get my parent.
bool isDescendant(NCursesWindow& win);
// Return TRUE if win is a descendant of this.
};
// -------------------------------------------------------------------------
// We leave this here for compatibility reasons.
// -------------------------------------------------------------------------
class NCURSES_IMPEXP NCursesColorWindow : public NCursesWindow
{
public:
NCursesColorWindow(WINDOW* &window) // useful only for stdscr
: NCursesWindow(window) {
useColors(); }
NCursesColorWindow(int nlines, // number of lines
int ncols, // number of columns
int begin_y, // line origin
int begin_x) // col origin
: NCursesWindow(nlines, ncols, begin_y, begin_x) {
useColors(); }
NCursesColorWindow(NCursesWindow& parentWin,// parent window
int nlines, // number of lines
int ncols, // number of columns
int begin_y, // absolute or relative
int begin_x, // origins:
char absrel = 'a') // if `a', by & bx are
: NCursesWindow(parentWin,
nlines, ncols, // absolute screen pos,
begin_y, begin_x, // else if `r', they are
absrel ) { // relative to par origin
useColors(); }
};
// These enum definitions really belong inside the NCursesPad class, but only
// recent compilers support that feature.
typedef enum {
REQ_PAD_REFRESH = KEY_MAX + 1,
REQ_PAD_UP,
REQ_PAD_DOWN,
REQ_PAD_LEFT,
REQ_PAD_RIGHT,
REQ_PAD_EXIT
} Pad_Request;
const Pad_Request PAD_LOW = REQ_PAD_REFRESH; // lowest op-code
const Pad_Request PAD_HIGH = REQ_PAD_EXIT; // highest op-code
// -------------------------------------------------------------------------
// Pad Support. We allow an association of a pad with a "real" window
// through which the pad may be viewed.
// -------------------------------------------------------------------------
class NCURSES_IMPEXP NCursesPad : public NCursesWindow
{
private:
NCursesWindow* viewWin; // the "viewport" window
NCursesWindow* viewSub; // the "viewport" subwindow
int h_gridsize, v_gridsize;
protected:
int min_row, min_col; // top left row/col of the pads display area
NCursesWindow* Win(void) const {
// Get the window into which the pad should be copied (if any)
return (viewSub?viewSub:(viewWin?viewWin:0));
}
NCursesWindow* getWindow(void) const {
return viewWin;
}
NCursesWindow* getSubWindow(void) const {
return viewSub;
}
virtual int driver (int key); // Virtualize keystroke key
// The driver translates the keystroke c into an Pad_Request
virtual void OnUnknownOperation(int pad_req) {
(void) pad_req;
::beep();
}
// This is called if the driver returns an unknown op-code
virtual void OnNavigationError(int pad_req) {
(void) pad_req;
::beep();
}
// This is called if a navigation request couldn't be satisfied
virtual void OnOperation(int pad_req) {
(void) pad_req;
};
// OnOperation is called if a Pad_Operation was executed and just before
// the refresh() operation is done.
public:
NCursesPad(int nlines, int ncols);
// create a pad with the given size
NCursesPad& operator=(const NCursesPad& rhs)
{
if (this != &rhs) {
*this = rhs;
NCursesWindow::operator=(rhs);
}
return *this;
}
NCursesPad(const NCursesPad& rhs)
: NCursesWindow(rhs),
viewWin(rhs.viewWin),
viewSub(rhs.viewSub),
h_gridsize(rhs.h_gridsize),
v_gridsize(rhs.v_gridsize),
min_row(rhs.min_row),
min_col(rhs.min_col)
{
}
virtual ~NCursesPad() {}
int echochar(const chtype ch) { return ::pechochar(w, ch); }
// Put the attributed character onto the pad and immediately do a
// prefresh().
int refresh();
// If a viewport is defined the pad is displayed in this window, otherwise
// this is a noop.
int refresh(int pminrow, int pmincol,
int sminrow, int smincol,
int smaxrow, int smaxcol) {
return ::prefresh(w, pminrow, pmincol,
sminrow, smincol, smaxrow, smaxcol);
}
// The coordinates sminrow,smincol,smaxrow,smaxcol describe a rectangle
// on the screen. <b>refresh</b> copies a rectangle of this size beginning
// with top left corner pminrow,pmincol onto the screen and calls doupdate().
int noutrefresh();
// If a viewport is defined the pad is displayed in this window, otherwise
// this is a noop.
int noutrefresh(int pminrow, int pmincol,
int sminrow, int smincol,
int smaxrow, int smaxcol) {
return ::pnoutrefresh(w, pminrow, pmincol,
sminrow, smincol, smaxrow, smaxcol);
}
// Does the same as refresh() but without calling doupdate().
virtual void setWindow(NCursesWindow& view, int v_grid = 1, int h_grid = 1);
// Add the window "view" as viewing window to the pad.
virtual void setSubWindow(NCursesWindow& sub);
// Use the subwindow "sub" of the viewport window for the actual viewing.
// The full viewport window is usually used to provide some decorations
// like frames, titles etc.
virtual void operator() (void);
// Perform Pad's operation
};
// A FramedPad is constructed always with a viewport window. This viewport
// will be framed (by a box() command) and the interior of the box is the
// viewport subwindow. On the frame we display scrollbar sliders.
class NCURSES_IMPEXP NCursesFramedPad : public NCursesPad
{
protected:
virtual void OnOperation(int pad_req);
public:
NCursesFramedPad(NCursesWindow& win, int nlines, int ncols,
int v_grid = 1, int h_grid = 1)
: NCursesPad(nlines, ncols) {
NCursesPad::setWindow(win, v_grid, h_grid);
NCursesPad::setSubWindow(*(new NCursesWindow(win)));
}
// Construct the FramedPad with the given Window win as viewport.
virtual ~NCursesFramedPad() {
delete getSubWindow();
}
void setWindow(NCursesWindow& view, int v_grid = 1, int h_grid = 1) {
(void) view;
(void) v_grid;
(void) h_grid;
err_handler("Operation not allowed");
}
// Disable this call; the viewport is already defined
void setSubWindow(NCursesWindow& sub) {
(void) sub;
err_handler("Operation not allowed");
}
// Disable this call; the viewport subwindow is already defined
};
#endif /* NCURSES_CURSESW_H_incl */
ncurses_dll.h 0000644 00000010265 15201526705 0007241 0 ustar 00 /****************************************************************************
* Copyright (c) 1998-2009,2014 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included *
* in all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
* *
* Except as contained in this notice, the name(s) of the above copyright *
* holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written *
* authorization. *
****************************************************************************/
/* $Id: ncurses_dll.h.in,v 1.9 2014/08/02 21:30:20 tom Exp $ */
#ifndef NCURSES_DLL_H_incl
#define NCURSES_DLL_H_incl 1
/* 2014-08-02 workaround for broken MinGW compiler.
* Oddly, only TRACE is mapped to trace - the other -D's are okay.
* suggest TDM as an alternative.
*/
#if defined(__MINGW64__)
#elif defined(__MINGW32__)
#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
#ifdef trace
#undef trace
#define TRACE
#endif
#endif /* broken compiler */
#endif /* MingW */
/*
* For reentrant code, we map the various global variables into SCREEN by
* using functions to access them.
*/
#define NCURSES_PUBLIC_VAR(name) _nc_##name
#define NCURSES_WRAPPED_VAR(type,name) extern type NCURSES_PUBLIC_VAR(name)(void)
/* no longer needed on cygwin or mingw, thanks to auto-import */
/* but this structure may be useful at some point for an MSVC build */
/* so, for now unconditionally define the important flags */
/* "the right way" for proper static and dll+auto-import behavior */
#undef NCURSES_DLL
#define NCURSES_STATIC
#if defined(__CYGWIN__) || defined(__MINGW32__)
# if defined(NCURSES_DLL)
# if defined(NCURSES_STATIC)
# undef NCURSES_STATIC
# endif
# endif
# undef NCURSES_IMPEXP
# undef NCURSES_API
# undef NCURSES_EXPORT
# undef NCURSES_EXPORT_VAR
# if defined(NCURSES_DLL)
/* building a DLL */
# define NCURSES_IMPEXP __declspec(dllexport)
# elif defined(NCURSES_STATIC)
/* building or linking to a static library */
# define NCURSES_IMPEXP /* nothing */
# else
/* linking to the DLL */
# define NCURSES_IMPEXP __declspec(dllimport)
# endif
# define NCURSES_API __cdecl
# define NCURSES_EXPORT(type) NCURSES_IMPEXP type NCURSES_API
# define NCURSES_EXPORT_VAR(type) NCURSES_IMPEXP type
#endif
/* Take care of non-cygwin platforms */
#if !defined(NCURSES_IMPEXP)
# define NCURSES_IMPEXP /* nothing */
#endif
#if !defined(NCURSES_API)
# define NCURSES_API /* nothing */
#endif
#if !defined(NCURSES_EXPORT)
# define NCURSES_EXPORT(type) NCURSES_IMPEXP type NCURSES_API
#endif
#if !defined(NCURSES_EXPORT_VAR)
# define NCURSES_EXPORT_VAR(type) NCURSES_IMPEXP type
#endif
#endif /* NCURSES_DLL_H_incl */
com_err.h 0000644 00000004106 15201526705 0006347 0 ustar 00 /*
* Header file for common error description library.
*
* Copyright 1988, Student Information Processing Board of the
* Massachusetts Institute of Technology.
*
* For copyright and distribution info, see the documentation supplied
* with this package.
*/
#if !defined(__COM_ERR_H) && !defined(__COM_ERR_H__)
#ifdef __GNUC__
#define COM_ERR_ATTR(x) __attribute__(x)
#else
#define COM_ERR_ATTR(x)
#endif
#include <stddef.h>
#include <stdarg.h>
typedef long errcode_t;
struct error_table {
char const * const * msgs;
long base;
int n_msgs;
};
struct et_list;
extern void com_err (const char *, long, const char *, ...)
COM_ERR_ATTR((format(printf, 3, 4)));
extern void com_err_va (const char *whoami, errcode_t code, const char *fmt,
va_list args)
COM_ERR_ATTR((format(printf, 3, 0)));
extern char const *error_message (long);
extern void (*com_err_hook) (const char *, long, const char *, va_list);
extern void (*set_com_err_hook (void (*) (const char *, long,
const char *, va_list)))
(const char *, long, const char *, va_list);
extern void (*reset_com_err_hook (void)) (const char *, long,
const char *, va_list);
extern int init_error_table(const char * const *msgs, long base, int count);
extern char *(*set_com_err_gettext (char *(*) (const char *)))
(const char *);
extern errcode_t add_error_table(const struct error_table * et);
extern errcode_t remove_error_table(const struct error_table * et);
extern void add_to_error_table(struct et_list *new_table);
/* Provided for Heimdall compatibility */
extern const char *com_right(struct et_list *list, long code);
extern const char *com_right_r(struct et_list *list, long code, char *str, size_t len);
extern void initialize_error_table_r(struct et_list **list,
const char **messages,
int num_errors,
long base);
extern void free_error_table(struct et_list *et);
/* Provided for compatibility with other com_err libraries */
extern int et_list_lock(void);
extern int et_list_unlock(void);
#define __COM_ERR_H
#define __COM_ERR_H__
#endif /* !defined(__COM_ERR_H) && !defined(__COM_ERR_H__)*/
proc_service.h 0000644 00000006624 15201526705 0007413 0 ustar 00 /* Callback interface for libthread_db, functions users must define.
Copyright (C) 1999-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef _PROC_SERVICE_H
#define _PROC_SERVICE_H 1
/* The definitions in this file must correspond to those in the debugger. */
#include <sys/procfs.h>
__BEGIN_DECLS
/* Functions in this interface return one of these status codes. */
typedef enum
{
PS_OK, /* Generic "call succeeded". */
PS_ERR, /* Generic error. */
PS_BADPID, /* Bad process handle. */
PS_BADLID, /* Bad LWP identifier. */
PS_BADADDR, /* Bad address. */
PS_NOSYM, /* Could not find given symbol. */
PS_NOFREGS /* FPU register set not available for given LWP. */
} ps_err_e;
/* This type is opaque in this interface.
It's defined by the user of libthread_db. */
struct ps_prochandle;
/* Read or write process memory at the given address. */
extern ps_err_e ps_pdread (struct ps_prochandle *,
psaddr_t, void *, size_t);
extern ps_err_e ps_pdwrite (struct ps_prochandle *,
psaddr_t, const void *, size_t);
extern ps_err_e ps_ptread (struct ps_prochandle *,
psaddr_t, void *, size_t);
extern ps_err_e ps_ptwrite (struct ps_prochandle *,
psaddr_t, const void *, size_t);
/* Get and set the given LWP's general or FPU register set. */
extern ps_err_e ps_lgetregs (struct ps_prochandle *,
lwpid_t, prgregset_t);
extern ps_err_e ps_lsetregs (struct ps_prochandle *,
lwpid_t, const prgregset_t);
extern ps_err_e ps_lgetfpregs (struct ps_prochandle *,
lwpid_t, prfpregset_t *);
extern ps_err_e ps_lsetfpregs (struct ps_prochandle *,
lwpid_t, const prfpregset_t *);
/* Return the PID of the process. */
extern pid_t ps_getpid (struct ps_prochandle *);
/* Fetch the special per-thread address associated with the given LWP.
This call is only used on a few platforms (most use a normal register).
The meaning of the `int' parameter is machine-dependent. */
extern ps_err_e ps_get_thread_area (struct ps_prochandle *,
lwpid_t, int, psaddr_t *);
/* Look up the named symbol in the named DSO in the symbol tables
associated with the process being debugged, filling in *SYM_ADDR
with the corresponding run-time address. */
extern ps_err_e ps_pglobal_lookup (struct ps_prochandle *,
const char *object_name,
const char *sym_name,
psaddr_t *sym_addr);
/* Stop or continue the entire process. */
extern ps_err_e ps_pstop (struct ps_prochandle *);
extern ps_err_e ps_pcontinue (struct ps_prochandle *);
/* Stop or continue the given LWP alone. */
extern ps_err_e ps_lstop (struct ps_prochandle *, lwpid_t);
extern ps_err_e ps_lcontinue (struct ps_prochandle *, lwpid_t);
__END_DECLS
#endif /* proc_service.h */
krad.h 0000644 00000021345 15201526705 0005646 0 ustar 00 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* Copyright 2013 Red Hat, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* This API is not considered as stable as the main krb5 API.
*
* - We may make arbitrary incompatible changes between feature releases
* (e.g. from 1.12 to 1.13).
* - We will make some effort to avoid making incompatible changes for
* bugfix releases, but will make them if necessary.
*/
#ifndef KRAD_H_
#define KRAD_H_
#include <krb5.h>
#include <verto.h>
#include <stddef.h>
#include <stdio.h>
#define KRAD_PACKET_SIZE_MAX 4096
#define KRAD_SERVICE_TYPE_LOGIN 1
#define KRAD_SERVICE_TYPE_FRAMED 2
#define KRAD_SERVICE_TYPE_CALLBACK_LOGIN 3
#define KRAD_SERVICE_TYPE_CALLBACK_FRAMED 4
#define KRAD_SERVICE_TYPE_OUTBOUND 5
#define KRAD_SERVICE_TYPE_ADMINISTRATIVE 6
#define KRAD_SERVICE_TYPE_NAS_PROMPT 7
#define KRAD_SERVICE_TYPE_AUTHENTICATE_ONLY 8
#define KRAD_SERVICE_TYPE_CALLBACK_NAS_PROMPT 9
#define KRAD_SERVICE_TYPE_CALL_CHECK 10
#define KRAD_SERVICE_TYPE_CALLBACK_ADMINISTRATIVE 11
typedef struct krad_attrset_st krad_attrset;
typedef struct krad_packet_st krad_packet;
typedef struct krad_client_st krad_client;
typedef unsigned char krad_code;
typedef unsigned char krad_attr;
/* Called when a response is received or the request times out. */
typedef void
(*krad_cb)(krb5_error_code retval, const krad_packet *request,
const krad_packet *response, void *data);
/*
* Called to iterate over a set of requests. Either the callback will be
* called until it returns NULL, or it will be called with cancel = TRUE to
* terminate in the middle of an iteration.
*/
typedef const krad_packet *
(*krad_packet_iter_cb)(void *data, krb5_boolean cancel);
/*
* Code
*/
/* Convert a code name to its number. Only works for codes defined
* by RFC 2875 or 2882. Returns 0 if the name was not found. */
krad_code
krad_code_name2num(const char *name);
/* Convert a code number to its name. Only works for attributes defined
* by RFC 2865 or 2882. Returns NULL if the name was not found. */
const char *
krad_code_num2name(krad_code code);
/*
* Attribute
*/
/* Convert an attribute name to its number. Only works for attributes defined
* by RFC 2865. Returns 0 if the name was not found. */
krad_attr
krad_attr_name2num(const char *name);
/* Convert an attribute number to its name. Only works for attributes defined
* by RFC 2865. Returns NULL if the name was not found. */
const char *
krad_attr_num2name(krad_attr type);
/*
* Attribute set
*/
/* Create a new attribute set. */
krb5_error_code
krad_attrset_new(krb5_context ctx, krad_attrset **set);
/* Create a deep copy of an attribute set. */
krb5_error_code
krad_attrset_copy(const krad_attrset *set, krad_attrset **copy);
/* Free an attribute set. */
void
krad_attrset_free(krad_attrset *set);
/* Add an attribute to a set. */
krb5_error_code
krad_attrset_add(krad_attrset *set, krad_attr type, const krb5_data *data);
/* Add a four-octet unsigned number attribute to the given set. */
krb5_error_code
krad_attrset_add_number(krad_attrset *set, krad_attr type, krb5_ui_4 num);
/* Delete the specified attribute. */
void
krad_attrset_del(krad_attrset *set, krad_attr type, size_t indx);
/* Get the specified attribute. */
const krb5_data *
krad_attrset_get(const krad_attrset *set, krad_attr type, size_t indx);
/*
* Packet
*/
/* Determine the bytes needed from the socket to get the whole packet. Don't
* cache the return value as it can change! Returns -1 on EBADMSG. */
ssize_t
krad_packet_bytes_needed(const krb5_data *buffer);
/* Free a packet. */
void
krad_packet_free(krad_packet *pkt);
/*
* Create a new request packet.
*
* This function takes the attributes specified in set and converts them into a
* radius packet. The packet will have a randomized id. If cb is not NULL, it
* will be called passing data as the argument to iterate over a set of
* outstanding requests. In this case, the id will be both random and unique
* across the set of requests.
*/
krb5_error_code
krad_packet_new_request(krb5_context ctx, const char *secret, krad_code code,
const krad_attrset *set, krad_packet_iter_cb cb,
void *data, krad_packet **request);
/*
* Create a new response packet.
*
* This function is similar to krad_packet_new_requst() except that it crafts a
* packet in response to a request packet. This new packet will borrow values
* from the request such as the id and the authenticator.
*/
krb5_error_code
krad_packet_new_response(krb5_context ctx, const char *secret, krad_code code,
const krad_attrset *set, const krad_packet *request,
krad_packet **response);
/*
* Decode a request radius packet from krb5_data.
*
* The resulting decoded packet will be a request packet stored in *reqpkt.
*
* If cb is NULL, *duppkt will always be NULL.
*
* If cb is not NULL, it will be called (with the data argument) to iterate
* over a set of requests currently being processed. In this case, if the
* packet is a duplicate of an already received request, the original request
* will be set in *duppkt.
*/
krb5_error_code
krad_packet_decode_request(krb5_context ctx, const char *secret,
const krb5_data *buffer, krad_packet_iter_cb cb,
void *data, const krad_packet **duppkt,
krad_packet **reqpkt);
/*
* Decode a response radius packet from krb5_data.
*
* The resulting decoded packet will be a response packet stored in *rsppkt.
*
* If cb is NULL, *reqpkt will always be NULL.
*
* If cb is not NULL, it will be called (with the data argument) to iterate
* over a set of requests awaiting responses. In this case, if the response
* packet matches one of these requests, the original request will be set in
* *reqpkt.
*/
krb5_error_code
krad_packet_decode_response(krb5_context ctx, const char *secret,
const krb5_data *buffer, krad_packet_iter_cb cb,
void *data, const krad_packet **reqpkt,
krad_packet **rsppkt);
/* Encode packet. */
const krb5_data *
krad_packet_encode(const krad_packet *pkt);
/* Get the code for the given packet. */
krad_code
krad_packet_get_code(const krad_packet *pkt);
/* Get the specified attribute. */
const krb5_data *
krad_packet_get_attr(const krad_packet *pkt, krad_attr type, size_t indx);
/*
* Client
*/
/* Create a new client. */
krb5_error_code
krad_client_new(krb5_context kctx, verto_ctx *vctx, krad_client **client);
/* Free the client. */
void
krad_client_free(krad_client *client);
/*
* Send a request to a radius server.
*
* The remote host may be specified by one of the following formats:
* - /path/to/unix.socket
* - IPv4
* - IPv4:port
* - IPv4:service
* - [IPv6]
* - [IPv6]:port
* - [IPv6]:service
* - hostname
* - hostname:port
* - hostname:service
*
* The timeout parameter (milliseconds) is the total timeout across all remote
* hosts (when DNS returns multiple entries) and all retries. For stream
* sockets, the retries parameter is ignored and no retries are performed.
*
* The cb function will be called with the data argument when either a response
* is received or the request times out on all possible remote hosts.
*/
krb5_error_code
krad_client_send(krad_client *rc, krad_code code, const krad_attrset *attrs,
const char *remote, const char *secret, int timeout,
size_t retries, krad_cb cb, void *data);
#endif /* KRAD_H_ */
jemalloc/jemalloc.h 0000644 00000034311 15201526705 0010276 0 ustar 00 #ifndef JEMALLOC_H_
#define JEMALLOC_H_
#ifdef __cplusplus
extern "C" {
#endif
/* Defined if __attribute__((...)) syntax is supported. */
#define JEMALLOC_HAVE_ATTR
/* Defined if alloc_size attribute is supported. */
#define JEMALLOC_HAVE_ATTR_ALLOC_SIZE
/* Defined if format_arg(...) attribute is supported. */
#define JEMALLOC_HAVE_ATTR_FORMAT_ARG
/* Defined if format(gnu_printf, ...) attribute is supported. */
#define JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF
/* Defined if format(printf, ...) attribute is supported. */
#define JEMALLOC_HAVE_ATTR_FORMAT_PRINTF
/*
* Define overrides for non-standard allocator-related functions if they are
* present on the system.
*/
#define JEMALLOC_OVERRIDE_MEMALIGN
#define JEMALLOC_OVERRIDE_VALLOC
/*
* At least Linux omits the "const" in:
*
* size_t malloc_usable_size(const void *ptr);
*
* Match the operating system's prototype.
*/
#define JEMALLOC_USABLE_SIZE_CONST
/*
* If defined, specify throw() for the public function prototypes when compiling
* with C++. The only justification for this is to match the prototypes that
* glibc defines.
*/
#define JEMALLOC_USE_CXX_THROW
#ifdef _MSC_VER
# ifdef _WIN64
# define LG_SIZEOF_PTR_WIN 3
# else
# define LG_SIZEOF_PTR_WIN 2
# endif
#endif
/* sizeof(void *) == 2^LG_SIZEOF_PTR. */
#define LG_SIZEOF_PTR 3
/*
* Name mangling for public symbols is controlled by --with-mangling and
* --with-jemalloc-prefix. With default settings the je_ prefix is stripped by
* these macro definitions.
*/
#ifndef JEMALLOC_NO_RENAME
# define je_aligned_alloc aligned_alloc
# define je_calloc calloc
# define je_dallocx dallocx
# define je_free free
# define je_mallctl mallctl
# define je_mallctlbymib mallctlbymib
# define je_mallctlnametomib mallctlnametomib
# define je_malloc malloc
# define je_malloc_conf malloc_conf
# define je_malloc_message malloc_message
# define je_malloc_stats_print malloc_stats_print
# define je_malloc_usable_size malloc_usable_size
# define je_mallocx mallocx
# define je_smallocx_ea6b3e973b477b8061e0076bb257dbd7f3faa756 smallocx_ea6b3e973b477b8061e0076bb257dbd7f3faa756
# define je_nallocx nallocx
# define je_posix_memalign posix_memalign
# define je_rallocx rallocx
# define je_realloc realloc
# define je_sallocx sallocx
# define je_sdallocx sdallocx
# define je_xallocx xallocx
# define je_memalign memalign
# define je_valloc valloc
#endif
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <limits.h>
#include <strings.h>
#define JEMALLOC_VERSION "5.2.1-0-gea6b3e973b477b8061e0076bb257dbd7f3faa756"
#define JEMALLOC_VERSION_MAJOR 5
#define JEMALLOC_VERSION_MINOR 2
#define JEMALLOC_VERSION_BUGFIX 1
#define JEMALLOC_VERSION_NREV 0
#define JEMALLOC_VERSION_GID "ea6b3e973b477b8061e0076bb257dbd7f3faa756"
#define JEMALLOC_VERSION_GID_IDENT ea6b3e973b477b8061e0076bb257dbd7f3faa756
#define MALLOCX_LG_ALIGN(la) ((int)(la))
#if LG_SIZEOF_PTR == 2
# define MALLOCX_ALIGN(a) ((int)(ffs((int)(a))-1))
#else
# define MALLOCX_ALIGN(a) \
((int)(((size_t)(a) < (size_t)INT_MAX) ? ffs((int)(a))-1 : \
ffs((int)(((size_t)(a))>>32))+31))
#endif
#define MALLOCX_ZERO ((int)0x40)
/*
* Bias tcache index bits so that 0 encodes "automatic tcache management", and 1
* encodes MALLOCX_TCACHE_NONE.
*/
#define MALLOCX_TCACHE(tc) ((int)(((tc)+2) << 8))
#define MALLOCX_TCACHE_NONE MALLOCX_TCACHE(-1)
/*
* Bias arena index bits so that 0 encodes "use an automatically chosen arena".
*/
#define MALLOCX_ARENA(a) ((((int)(a))+1) << 20)
/*
* Use as arena index in "arena.<i>.{purge,decay,dss}" and
* "stats.arenas.<i>.*" mallctl interfaces to select all arenas. This
* definition is intentionally specified in raw decimal format to support
* cpp-based string concatenation, e.g.
*
* #define STRINGIFY_HELPER(x) #x
* #define STRINGIFY(x) STRINGIFY_HELPER(x)
*
* mallctl("arena." STRINGIFY(MALLCTL_ARENAS_ALL) ".purge", NULL, NULL, NULL,
* 0);
*/
#define MALLCTL_ARENAS_ALL 4096
/*
* Use as arena index in "stats.arenas.<i>.*" mallctl interfaces to select
* destroyed arenas.
*/
#define MALLCTL_ARENAS_DESTROYED 4097
#if defined(__cplusplus) && defined(JEMALLOC_USE_CXX_THROW)
# define JEMALLOC_CXX_THROW throw()
#else
# define JEMALLOC_CXX_THROW
#endif
#if defined(_MSC_VER)
# define JEMALLOC_ATTR(s)
# define JEMALLOC_ALIGNED(s) __declspec(align(s))
# define JEMALLOC_ALLOC_SIZE(s)
# define JEMALLOC_ALLOC_SIZE2(s1, s2)
# ifndef JEMALLOC_EXPORT
# ifdef DLLEXPORT
# define JEMALLOC_EXPORT __declspec(dllexport)
# else
# define JEMALLOC_EXPORT __declspec(dllimport)
# endif
# endif
# define JEMALLOC_FORMAT_ARG(i)
# define JEMALLOC_FORMAT_PRINTF(s, i)
# define JEMALLOC_NOINLINE __declspec(noinline)
# ifdef __cplusplus
# define JEMALLOC_NOTHROW __declspec(nothrow)
# else
# define JEMALLOC_NOTHROW
# endif
# define JEMALLOC_SECTION(s) __declspec(allocate(s))
# define JEMALLOC_RESTRICT_RETURN __declspec(restrict)
# if _MSC_VER >= 1900 && !defined(__EDG__)
# define JEMALLOC_ALLOCATOR __declspec(allocator)
# else
# define JEMALLOC_ALLOCATOR
# endif
#elif defined(JEMALLOC_HAVE_ATTR)
# define JEMALLOC_ATTR(s) __attribute__((s))
# define JEMALLOC_ALIGNED(s) JEMALLOC_ATTR(aligned(s))
# ifdef JEMALLOC_HAVE_ATTR_ALLOC_SIZE
# define JEMALLOC_ALLOC_SIZE(s) JEMALLOC_ATTR(alloc_size(s))
# define JEMALLOC_ALLOC_SIZE2(s1, s2) JEMALLOC_ATTR(alloc_size(s1, s2))
# else
# define JEMALLOC_ALLOC_SIZE(s)
# define JEMALLOC_ALLOC_SIZE2(s1, s2)
# endif
# ifndef JEMALLOC_EXPORT
# define JEMALLOC_EXPORT JEMALLOC_ATTR(visibility("default"))
# endif
# ifdef JEMALLOC_HAVE_ATTR_FORMAT_ARG
# define JEMALLOC_FORMAT_ARG(i) JEMALLOC_ATTR(__format_arg__(3))
# else
# define JEMALLOC_FORMAT_ARG(i)
# endif
# ifdef JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF
# define JEMALLOC_FORMAT_PRINTF(s, i) JEMALLOC_ATTR(format(gnu_printf, s, i))
# elif defined(JEMALLOC_HAVE_ATTR_FORMAT_PRINTF)
# define JEMALLOC_FORMAT_PRINTF(s, i) JEMALLOC_ATTR(format(printf, s, i))
# else
# define JEMALLOC_FORMAT_PRINTF(s, i)
# endif
# define JEMALLOC_NOINLINE JEMALLOC_ATTR(noinline)
# define JEMALLOC_NOTHROW JEMALLOC_ATTR(nothrow)
# define JEMALLOC_SECTION(s) JEMALLOC_ATTR(section(s))
# define JEMALLOC_RESTRICT_RETURN
# define JEMALLOC_ALLOCATOR
#else
# define JEMALLOC_ATTR(s)
# define JEMALLOC_ALIGNED(s)
# define JEMALLOC_ALLOC_SIZE(s)
# define JEMALLOC_ALLOC_SIZE2(s1, s2)
# define JEMALLOC_EXPORT
# define JEMALLOC_FORMAT_PRINTF(s, i)
# define JEMALLOC_NOINLINE
# define JEMALLOC_NOTHROW
# define JEMALLOC_SECTION(s)
# define JEMALLOC_RESTRICT_RETURN
# define JEMALLOC_ALLOCATOR
#endif
/*
* The je_ prefix on the following public symbol declarations is an artifact
* of namespace management, and should be omitted in application code unless
* JEMALLOC_NO_DEMANGLE is defined (see jemalloc_mangle.h).
*/
extern JEMALLOC_EXPORT const char *je_malloc_conf;
extern JEMALLOC_EXPORT void (*je_malloc_message)(void *cbopaque,
const char *s);
JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
void JEMALLOC_NOTHROW *je_malloc(size_t size)
JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc) JEMALLOC_ALLOC_SIZE(1);
JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
void JEMALLOC_NOTHROW *je_calloc(size_t num, size_t size)
JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc) JEMALLOC_ALLOC_SIZE2(1, 2);
JEMALLOC_EXPORT int JEMALLOC_NOTHROW je_posix_memalign(void **memptr,
size_t alignment, size_t size) JEMALLOC_CXX_THROW JEMALLOC_ATTR(nonnull(1));
JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
void JEMALLOC_NOTHROW *je_aligned_alloc(size_t alignment,
size_t size) JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc)
JEMALLOC_ALLOC_SIZE(2);
JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
void JEMALLOC_NOTHROW *je_realloc(void *ptr, size_t size)
JEMALLOC_CXX_THROW JEMALLOC_ALLOC_SIZE(2);
JEMALLOC_EXPORT void JEMALLOC_NOTHROW je_free(void *ptr)
JEMALLOC_CXX_THROW;
JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
void JEMALLOC_NOTHROW *je_mallocx(size_t size, int flags)
JEMALLOC_ATTR(malloc) JEMALLOC_ALLOC_SIZE(1);
JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
void JEMALLOC_NOTHROW *je_rallocx(void *ptr, size_t size,
int flags) JEMALLOC_ALLOC_SIZE(2);
JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW je_xallocx(void *ptr, size_t size,
size_t extra, int flags);
JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW je_sallocx(const void *ptr,
int flags) JEMALLOC_ATTR(pure);
JEMALLOC_EXPORT void JEMALLOC_NOTHROW je_dallocx(void *ptr, int flags);
JEMALLOC_EXPORT void JEMALLOC_NOTHROW je_sdallocx(void *ptr, size_t size,
int flags);
JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW je_nallocx(size_t size, int flags)
JEMALLOC_ATTR(pure);
JEMALLOC_EXPORT int JEMALLOC_NOTHROW je_mallctl(const char *name,
void *oldp, size_t *oldlenp, void *newp, size_t newlen);
JEMALLOC_EXPORT int JEMALLOC_NOTHROW je_mallctlnametomib(const char *name,
size_t *mibp, size_t *miblenp);
JEMALLOC_EXPORT int JEMALLOC_NOTHROW je_mallctlbymib(const size_t *mib,
size_t miblen, void *oldp, size_t *oldlenp, void *newp, size_t newlen);
JEMALLOC_EXPORT void JEMALLOC_NOTHROW je_malloc_stats_print(
void (*write_cb)(void *, const char *), void *je_cbopaque,
const char *opts);
JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW je_malloc_usable_size(
JEMALLOC_USABLE_SIZE_CONST void *ptr) JEMALLOC_CXX_THROW;
#ifdef JEMALLOC_OVERRIDE_MEMALIGN
JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
void JEMALLOC_NOTHROW *je_memalign(size_t alignment, size_t size)
JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc);
#endif
#ifdef JEMALLOC_OVERRIDE_VALLOC
JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
void JEMALLOC_NOTHROW *je_valloc(size_t size) JEMALLOC_CXX_THROW
JEMALLOC_ATTR(malloc);
#endif
typedef struct extent_hooks_s extent_hooks_t;
/*
* void *
* extent_alloc(extent_hooks_t *extent_hooks, void *new_addr, size_t size,
* size_t alignment, bool *zero, bool *commit, unsigned arena_ind);
*/
typedef void *(extent_alloc_t)(extent_hooks_t *, void *, size_t, size_t, bool *,
bool *, unsigned);
/*
* bool
* extent_dalloc(extent_hooks_t *extent_hooks, void *addr, size_t size,
* bool committed, unsigned arena_ind);
*/
typedef bool (extent_dalloc_t)(extent_hooks_t *, void *, size_t, bool,
unsigned);
/*
* void
* extent_destroy(extent_hooks_t *extent_hooks, void *addr, size_t size,
* bool committed, unsigned arena_ind);
*/
typedef void (extent_destroy_t)(extent_hooks_t *, void *, size_t, bool,
unsigned);
/*
* bool
* extent_commit(extent_hooks_t *extent_hooks, void *addr, size_t size,
* size_t offset, size_t length, unsigned arena_ind);
*/
typedef bool (extent_commit_t)(extent_hooks_t *, void *, size_t, size_t, size_t,
unsigned);
/*
* bool
* extent_decommit(extent_hooks_t *extent_hooks, void *addr, size_t size,
* size_t offset, size_t length, unsigned arena_ind);
*/
typedef bool (extent_decommit_t)(extent_hooks_t *, void *, size_t, size_t,
size_t, unsigned);
/*
* bool
* extent_purge(extent_hooks_t *extent_hooks, void *addr, size_t size,
* size_t offset, size_t length, unsigned arena_ind);
*/
typedef bool (extent_purge_t)(extent_hooks_t *, void *, size_t, size_t, size_t,
unsigned);
/*
* bool
* extent_split(extent_hooks_t *extent_hooks, void *addr, size_t size,
* size_t size_a, size_t size_b, bool committed, unsigned arena_ind);
*/
typedef bool (extent_split_t)(extent_hooks_t *, void *, size_t, size_t, size_t,
bool, unsigned);
/*
* bool
* extent_merge(extent_hooks_t *extent_hooks, void *addr_a, size_t size_a,
* void *addr_b, size_t size_b, bool committed, unsigned arena_ind);
*/
typedef bool (extent_merge_t)(extent_hooks_t *, void *, size_t, void *, size_t,
bool, unsigned);
struct extent_hooks_s {
extent_alloc_t *alloc;
extent_dalloc_t *dalloc;
extent_destroy_t *destroy;
extent_commit_t *commit;
extent_decommit_t *decommit;
extent_purge_t *purge_lazy;
extent_purge_t *purge_forced;
extent_split_t *split;
extent_merge_t *merge;
};
/*
* By default application code must explicitly refer to mangled symbol names,
* so that it is possible to use jemalloc in conjunction with another allocator
* in the same application. Define JEMALLOC_MANGLE in order to cause automatic
* name mangling that matches the API prefixing that happened as a result of
* --with-mangling and/or --with-jemalloc-prefix configuration settings.
*/
#ifdef JEMALLOC_MANGLE
# ifndef JEMALLOC_NO_DEMANGLE
# define JEMALLOC_NO_DEMANGLE
# endif
# define aligned_alloc je_aligned_alloc
# define calloc je_calloc
# define dallocx je_dallocx
# define free je_free
# define mallctl je_mallctl
# define mallctlbymib je_mallctlbymib
# define mallctlnametomib je_mallctlnametomib
# define malloc je_malloc
# define malloc_conf je_malloc_conf
# define malloc_message je_malloc_message
# define malloc_stats_print je_malloc_stats_print
# define malloc_usable_size je_malloc_usable_size
# define mallocx je_mallocx
# define smallocx_ea6b3e973b477b8061e0076bb257dbd7f3faa756 je_smallocx_ea6b3e973b477b8061e0076bb257dbd7f3faa756
# define nallocx je_nallocx
# define posix_memalign je_posix_memalign
# define rallocx je_rallocx
# define realloc je_realloc
# define sallocx je_sallocx
# define sdallocx je_sdallocx
# define xallocx je_xallocx
# define memalign je_memalign
# define valloc je_valloc
#endif
/*
* The je_* macros can be used as stable alternative names for the
* public jemalloc API if JEMALLOC_NO_DEMANGLE is defined. This is primarily
* meant for use in jemalloc itself, but it can be used by application code to
* provide isolation from the name mangling specified via --with-mangling
* and/or --with-jemalloc-prefix.
*/
#ifndef JEMALLOC_NO_DEMANGLE
# undef je_aligned_alloc
# undef je_calloc
# undef je_dallocx
# undef je_free
# undef je_mallctl
# undef je_mallctlbymib
# undef je_mallctlnametomib
# undef je_malloc
# undef je_malloc_conf
# undef je_malloc_message
# undef je_malloc_stats_print
# undef je_malloc_usable_size
# undef je_mallocx
# undef je_smallocx_ea6b3e973b477b8061e0076bb257dbd7f3faa756
# undef je_nallocx
# undef je_posix_memalign
# undef je_rallocx
# undef je_realloc
# undef je_sallocx
# undef je_sdallocx
# undef je_xallocx
# undef je_memalign
# undef je_valloc
#endif
#ifdef __cplusplus
}
#endif
#endif /* JEMALLOC_H_ */
ext2fs/ext2fs.h 0000644 00000215322 15201526705 0007353 0 ustar 00 /*
* ext2fs.h --- ext2fs
*
* Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Library
* General Public License, version 2.
* %End-Header%
*/
#ifndef _EXT2FS_EXT2FS_H
#define _EXT2FS_EXT2FS_H
#ifdef __GNUC__
#define EXT2FS_ATTR(x) __attribute__(x)
#else
#define EXT2FS_ATTR(x)
#endif
#ifdef CONFIG_TDB
#define EXT2FS_NO_TDB_UNUSED
#else
#define EXT2FS_NO_TDB_UNUSED EXT2FS_ATTR((unused))
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* Non-GNU C compilers won't necessarily understand inline
*/
#if (!defined(__GNUC__) && !defined(__WATCOMC__))
#define NO_INLINE_FUNCS
#endif
/*
* Where the master copy of the superblock is located, and how big
* superblocks are supposed to be. We define SUPERBLOCK_SIZE because
* the size of the superblock structure is not necessarily trustworthy
* (some versions have the padding set up so that the superblock is
* 1032 bytes long).
*/
#define SUPERBLOCK_OFFSET 1024
#define SUPERBLOCK_SIZE 1024
#define UUID_STR_SIZE 37
/*
* The last ext2fs revision level that this version of the library is
* able to support.
*/
#define EXT2_LIB_CURRENT_REV EXT2_DYNAMIC_REV
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <errno.h>
#if EXT2_FLAT_INCLUDES
#include "e2_types.h"
#include "ext2_fs.h"
#include "ext3_extents.h"
#else
#include <ext2fs/ext2_types.h>
#include <ext2fs/ext2_fs.h>
#include <ext2fs/ext3_extents.h>
#endif /* EXT2_FLAT_INCLUDES */
typedef __u32 __bitwise ext2_ino_t;
typedef __u32 __bitwise blk_t;
typedef __u64 __bitwise blk64_t;
typedef __u32 __bitwise dgrp_t;
typedef __s32 __bitwise ext2_off_t;
typedef __s64 __bitwise ext2_off64_t;
typedef __s64 __bitwise e2_blkcnt_t;
typedef __u32 __bitwise ext2_dirhash_t;
#if EXT2_FLAT_INCLUDES
#include "com_err.h"
#include "ext2_io.h"
#include "ext2_err.h"
#include "ext2_ext_attr.h"
#else
#include <et/com_err.h>
#include <ext2fs/ext2_io.h>
#include <ext2fs/ext2_err.h>
#include <ext2fs/ext2_ext_attr.h>
#endif
#include "hashmap.h"
/*
* Portability help for Microsoft Visual C++
*/
#ifdef _MSC_VER
#define EXT2_QSORT_TYPE int __cdecl
#else
#define EXT2_QSORT_TYPE int
#endif
typedef struct struct_ext2_filsys *ext2_filsys;
#define EXT2FS_MARK_ERROR 0
#define EXT2FS_UNMARK_ERROR 1
#define EXT2FS_TEST_ERROR 2
typedef struct ext2fs_struct_generic_bitmap *ext2fs_generic_bitmap;
typedef struct ext2fs_struct_generic_bitmap *ext2fs_inode_bitmap;
typedef struct ext2fs_struct_generic_bitmap *ext2fs_block_bitmap;
#define EXT2_FIRST_INODE(s) EXT2_FIRST_INO(s)
/*
* Badblocks list definitions
*/
typedef struct ext2_struct_u32_list *ext2_badblocks_list;
typedef struct ext2_struct_u32_iterate *ext2_badblocks_iterate;
typedef struct ext2_struct_u32_list *ext2_u32_list;
typedef struct ext2_struct_u32_iterate *ext2_u32_iterate;
/* old */
typedef struct ext2_struct_u32_list *badblocks_list;
typedef struct ext2_struct_u32_iterate *badblocks_iterate;
#define BADBLOCKS_FLAG_DIRTY 1
/*
* ext2_dblist structure and abstractions (see dblist.c)
*/
struct ext2_db_entry2 {
ext2_ino_t ino;
blk64_t blk;
e2_blkcnt_t blockcnt;
};
/* Ye Olde 32-bit version */
struct ext2_db_entry {
ext2_ino_t ino;
blk_t blk;
int blockcnt;
};
typedef struct ext2_struct_dblist *ext2_dblist;
#define DBLIST_ABORT 1
/*
* ext2_fileio definitions
*/
#define EXT2_FILE_WRITE 0x0001
#define EXT2_FILE_CREATE 0x0002
#define EXT2_FILE_MASK 0x00FF
#define EXT2_FILE_BUF_DIRTY 0x4000
#define EXT2_FILE_BUF_VALID 0x2000
typedef struct ext2_file *ext2_file_t;
#define EXT2_SEEK_SET 0
#define EXT2_SEEK_CUR 1
#define EXT2_SEEK_END 2
/*
* Flags for the ext2_filsys structure and for ext2fs_open()
*/
#define EXT2_FLAG_RW 0x01
#define EXT2_FLAG_CHANGED 0x02
#define EXT2_FLAG_DIRTY 0x04
#define EXT2_FLAG_VALID 0x08
#define EXT2_FLAG_IB_DIRTY 0x10
#define EXT2_FLAG_BB_DIRTY 0x20
#define EXT2_FLAG_SWAP_BYTES 0x40
#define EXT2_FLAG_SWAP_BYTES_READ 0x80
#define EXT2_FLAG_SWAP_BYTES_WRITE 0x100
#define EXT2_FLAG_MASTER_SB_ONLY 0x200
#define EXT2_FLAG_FORCE 0x400
#define EXT2_FLAG_SUPER_ONLY 0x800
#define EXT2_FLAG_JOURNAL_DEV_OK 0x1000
#define EXT2_FLAG_IMAGE_FILE 0x2000
#define EXT2_FLAG_EXCLUSIVE 0x4000
#define EXT2_FLAG_SOFTSUPP_FEATURES 0x8000
#define EXT2_FLAG_NOFREE_ON_ERROR 0x10000
#define EXT2_FLAG_64BITS 0x20000
#define EXT2_FLAG_PRINT_PROGRESS 0x40000
#define EXT2_FLAG_DIRECT_IO 0x80000
#define EXT2_FLAG_SKIP_MMP 0x100000
#define EXT2_FLAG_IGNORE_CSUM_ERRORS 0x200000
#define EXT2_FLAG_SHARE_DUP 0x400000
#define EXT2_FLAG_IGNORE_SB_ERRORS 0x800000
#define EXT2_FLAG_BBITMAP_TAIL_PROBLEM 0x1000000
#define EXT2_FLAG_IBITMAP_TAIL_PROBLEM 0x2000000
/*
* Special flag in the ext2 inode i_flag field that means that this is
* a new inode. (So that ext2_write_inode() can clear extra fields.)
*/
#define EXT2_NEW_INODE_FL 0x80000000
/*
* Flags for mkjournal
*/
#define EXT2_MKJOURNAL_V1_SUPER 0x0000001 /* create V1 superblock (deprecated) */
#define EXT2_MKJOURNAL_LAZYINIT 0x0000002 /* don't zero journal inode before use*/
#define EXT2_MKJOURNAL_NO_MNT_CHECK 0x0000004 /* don't check mount status */
struct blk_alloc_ctx;
struct opaque_ext2_group_desc;
struct struct_ext2_filsys {
errcode_t magic;
io_channel io;
int flags;
char * device_name;
struct ext2_super_block * super;
unsigned int blocksize;
int fragsize;
dgrp_t group_desc_count;
unsigned long desc_blocks;
struct opaque_ext2_group_desc * group_desc;
unsigned int inode_blocks_per_group;
ext2fs_inode_bitmap inode_map;
ext2fs_block_bitmap block_map;
/* XXX FIXME-64: not 64-bit safe, but not used? */
errcode_t (*get_blocks)(ext2_filsys fs, ext2_ino_t ino, blk_t *blocks);
errcode_t (*check_directory)(ext2_filsys fs, ext2_ino_t ino);
errcode_t (*write_bitmaps)(ext2_filsys fs);
errcode_t (*read_inode)(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode *inode);
errcode_t (*write_inode)(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode *inode);
ext2_badblocks_list badblocks;
ext2_dblist dblist;
__u32 stride; /* for mke2fs */
struct ext2_super_block * orig_super;
struct ext2_image_hdr * image_header;
__u32 umask;
time_t now;
int cluster_ratio_bits;
__u16 default_bitmap_type;
__u16 pad;
/*
* RedHat specific change to prevent ABI change by using 8
* reserved bytes
*/
const struct ext2fs_nls_table *encoding;
/*
* Reserved for future expansion
*/
__u32 reserved[5 - (sizeof(long int)/4)];
/*
* Reserved for the use of the calling application.
*/
void * priv_data;
/*
* Inode cache
*/
struct ext2_inode_cache *icache;
io_channel image_io;
/*
* More callback functions
*/
errcode_t (*get_alloc_block)(ext2_filsys fs, blk64_t goal,
blk64_t *ret);
errcode_t (*get_alloc_block2)(ext2_filsys fs, blk64_t goal,
blk64_t *ret, struct blk_alloc_ctx *ctx);
void (*block_alloc_stats)(ext2_filsys fs, blk64_t blk, int inuse);
/*
* Buffers for Multiple mount protection(MMP) block.
*/
void *mmp_buf;
void *mmp_cmp;
int mmp_fd;
/*
* Time at which e2fsck last updated the MMP block.
*/
long mmp_last_written;
/* progress operation functions */
struct ext2fs_progress_ops *progress_ops;
/* Precomputed FS UUID checksum for seeding other checksums */
__u32 csum_seed;
io_channel journal_io;
char *journal_name;
/* New block range allocation hooks */
errcode_t (*new_range)(ext2_filsys fs, int flags, blk64_t goal,
blk64_t len, blk64_t *pblk, blk64_t *plen);
void (*block_alloc_stats_range)(ext2_filsys fs, blk64_t blk, blk_t num,
int inuse);
/* hashmap for SHA of data blocks */
struct ext2fs_hashmap* block_sha_map;
};
#if EXT2_FLAT_INCLUDES
#include "e2_bitops.h"
#else
#include <ext2fs/bitops.h>
#endif
/*
* 64-bit bitmap backend types
*/
#define EXT2FS_BMAP64_BITARRAY 1
#define EXT2FS_BMAP64_RBTREE 2
#define EXT2FS_BMAP64_AUTODIR 3
/*
* Return flags for the block iterator functions
*/
#define BLOCK_CHANGED 1
#define BLOCK_ABORT 2
#define BLOCK_ERROR 4
#define BLOCK_INLINE_DATA_CHANGED 8
/*
* Block interate flags
*
* BLOCK_FLAG_APPEND, or BLOCK_FLAG_HOLE, indicates that the interator
* function should be called on blocks where the block number is zero.
* This is used by ext2fs_expand_dir() to be able to add a new block
* to an inode. It can also be used for programs that want to be able
* to deal with files that contain "holes".
*
* BLOCK_FLAG_DEPTH_TRAVERSE indicates that the iterator function for
* the indirect, doubly indirect, etc. blocks should be called after
* all of the blocks contained in the indirect blocks are processed.
* This is useful if you are going to be deallocating blocks from an
* inode.
*
* BLOCK_FLAG_DATA_ONLY indicates that the iterator function should be
* called for data blocks only.
*
* BLOCK_FLAG_READ_ONLY is a promise by the caller that it will not
* modify returned block number.
*
* BLOCK_FLAG_NO_LARGE is for internal use only. It informs
* ext2fs_block_iterate2 that large files won't be accepted.
*/
#define BLOCK_FLAG_APPEND 1
#define BLOCK_FLAG_HOLE 1
#define BLOCK_FLAG_DEPTH_TRAVERSE 2
#define BLOCK_FLAG_DATA_ONLY 4
#define BLOCK_FLAG_READ_ONLY 8
#define BLOCK_FLAG_NO_LARGE 0x1000
/*
* Magic "block count" return values for the block iterator function.
*/
#define BLOCK_COUNT_IND (-1)
#define BLOCK_COUNT_DIND (-2)
#define BLOCK_COUNT_TIND (-3)
#define BLOCK_COUNT_TRANSLATOR (-4)
#define BLOCK_ALLOC_UNKNOWN 0
#define BLOCK_ALLOC_DATA 1
#define BLOCK_ALLOC_METADATA 2
struct blk_alloc_ctx {
ext2_ino_t ino;
struct ext2_inode *inode;
blk64_t lblk;
int flags;
};
#if 0
/*
* Flags for ext2fs_move_blocks
*/
#define EXT2_BMOVE_GET_DBLIST 0x0001
#define EXT2_BMOVE_DEBUG 0x0002
#endif
/*
* Generic (non-filesystem layout specific) extents structure
*/
#define EXT2_EXTENT_FLAGS_LEAF 0x0001
#define EXT2_EXTENT_FLAGS_UNINIT 0x0002
#define EXT2_EXTENT_FLAGS_SECOND_VISIT 0x0004
struct ext2fs_extent {
blk64_t e_pblk; /* first physical block */
blk64_t e_lblk; /* first logical block extent covers */
__u32 e_len; /* number of blocks covered by extent */
__u32 e_flags; /* extent flags */
};
typedef struct ext2_extent_handle *ext2_extent_handle_t;
typedef struct ext2_extent_path *ext2_extent_path_t;
/*
* Flags used by ext2fs_extent_get()
*/
#define EXT2_EXTENT_CURRENT 0x0000
#define EXT2_EXTENT_MOVE_MASK 0x000F
#define EXT2_EXTENT_ROOT 0x0001
#define EXT2_EXTENT_LAST_LEAF 0x0002
#define EXT2_EXTENT_FIRST_SIB 0x0003
#define EXT2_EXTENT_LAST_SIB 0x0004
#define EXT2_EXTENT_NEXT_SIB 0x0005
#define EXT2_EXTENT_PREV_SIB 0x0006
#define EXT2_EXTENT_NEXT_LEAF 0x0007
#define EXT2_EXTENT_PREV_LEAF 0x0008
#define EXT2_EXTENT_NEXT 0x0009
#define EXT2_EXTENT_PREV 0x000A
#define EXT2_EXTENT_UP 0x000B
#define EXT2_EXTENT_DOWN 0x000C
#define EXT2_EXTENT_DOWN_AND_LAST 0x000D
/*
* Flags used by ext2fs_extent_insert()
*/
#define EXT2_EXTENT_INSERT_AFTER 0x0001 /* insert after handle loc'n */
#define EXT2_EXTENT_INSERT_NOSPLIT 0x0002 /* insert may not cause split */
/*
* Flags used by ext2fs_extent_delete()
*/
#define EXT2_EXTENT_DELETE_KEEP_EMPTY 0x001 /* keep node if last extent gone */
/*
* Flags used by ext2fs_extent_set_bmap()
*/
#define EXT2_EXTENT_SET_BMAP_UNINIT 0x0001
/*
* Data structure returned by ext2fs_extent_get_info()
*/
struct ext2_extent_info {
int curr_entry;
int curr_level;
int num_entries;
int max_entries;
int max_depth;
int bytes_avail;
blk64_t max_lblk;
blk64_t max_pblk;
__u32 max_len;
__u32 max_uninit_len;
};
/*
* Flags for directory block reading and writing functions
*/
#define EXT2_DIRBLOCK_V2_STRUCT 0x0001
/*
* Return flags for the directory iterator functions
*/
#define DIRENT_CHANGED 1
#define DIRENT_ABORT 2
#define DIRENT_ERROR 3
/*
* Directory iterator flags
*/
#define DIRENT_FLAG_INCLUDE_EMPTY 1
#define DIRENT_FLAG_INCLUDE_REMOVED 2
#define DIRENT_FLAG_INCLUDE_CSUM 4
#define DIRENT_FLAG_INCLUDE_INLINE_DATA 8
#define DIRENT_DOT_FILE 1
#define DIRENT_DOT_DOT_FILE 2
#define DIRENT_OTHER_FILE 3
#define DIRENT_DELETED_FILE 4
#define DIRENT_CHECKSUM 5
/*
* Inode scan definitions
*/
typedef struct ext2_struct_inode_scan *ext2_inode_scan;
/*
* ext2fs_scan flags
*/
#define EXT2_SF_CHK_BADBLOCKS 0x0001
#define EXT2_SF_BAD_INODE_BLK 0x0002
#define EXT2_SF_BAD_EXTRA_BYTES 0x0004
#define EXT2_SF_SKIP_MISSING_ITABLE 0x0008
#define EXT2_SF_DO_LAZY 0x0010
#define EXT2_SF_WARN_GARBAGE_INODES 0x0020
/*
* ext2fs_check_if_mounted flags
*/
#define EXT2_MF_MOUNTED 1
#define EXT2_MF_ISROOT 2
#define EXT2_MF_READONLY 4
#define EXT2_MF_SWAP 8
#define EXT2_MF_BUSY 16
/*
* Ext2/linux mode flags. We define them here so that we don't need
* to depend on the OS's sys/stat.h, since we may be compiling on a
* non-Linux system.
*/
#define LINUX_S_IFMT 00170000
#define LINUX_S_IFSOCK 0140000
#define LINUX_S_IFLNK 0120000
#define LINUX_S_IFREG 0100000
#define LINUX_S_IFBLK 0060000
#define LINUX_S_IFDIR 0040000
#define LINUX_S_IFCHR 0020000
#define LINUX_S_IFIFO 0010000
#define LINUX_S_ISUID 0004000
#define LINUX_S_ISGID 0002000
#define LINUX_S_ISVTX 0001000
#define LINUX_S_IRWXU 00700
#define LINUX_S_IRUSR 00400
#define LINUX_S_IWUSR 00200
#define LINUX_S_IXUSR 00100
#define LINUX_S_IRWXG 00070
#define LINUX_S_IRGRP 00040
#define LINUX_S_IWGRP 00020
#define LINUX_S_IXGRP 00010
#define LINUX_S_IRWXO 00007
#define LINUX_S_IROTH 00004
#define LINUX_S_IWOTH 00002
#define LINUX_S_IXOTH 00001
#define LINUX_S_ISLNK(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFLNK)
#define LINUX_S_ISREG(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFREG)
#define LINUX_S_ISDIR(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFDIR)
#define LINUX_S_ISCHR(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFCHR)
#define LINUX_S_ISBLK(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFBLK)
#define LINUX_S_ISFIFO(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFIFO)
#define LINUX_S_ISSOCK(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFSOCK)
/*
* ext2 size of an inode
*/
#define EXT2_I_SIZE(i) ((i)->i_size | ((__u64) (i)->i_size_high << 32))
/*
* ext2_icount_t abstraction
*/
#define EXT2_ICOUNT_OPT_INCREMENT 0x01
#define EXT2_ICOUNT_OPT_FULLMAP 0x02
typedef struct ext2_icount *ext2_icount_t;
/*
* Flags for ext2fs_bmap
*/
#define BMAP_ALLOC 0x0001
#define BMAP_SET 0x0002
#define BMAP_UNINIT 0x0004
#define BMAP_ZERO 0x0008
/*
* Returned flags from ext2fs_bmap
*/
#define BMAP_RET_UNINIT 0x0001
/*
* Flags for ext2fs_read_inode2
*/
#define READ_INODE_NOCSUM 0x0001
/*
* Flags for ext2fs_write_inode2
*/
#define WRITE_INODE_NOCSUM 0x0001
/*
* Flags for imager.c functions
*/
#define IMAGER_FLAG_INODEMAP 1
#define IMAGER_FLAG_SPARSEWRITE 2
/*
* For checking structure magic numbers...
*/
#define EXT2_CHECK_MAGIC(struct, code) \
if ((struct)->magic != (code)) return (code)
/*
* Features supported by this version of the library
*/
#define EXT2_LIB_FEATURE_COMPAT_SUPP (EXT2_FEATURE_COMPAT_DIR_PREALLOC|\
EXT2_FEATURE_COMPAT_IMAGIC_INODES|\
EXT3_FEATURE_COMPAT_HAS_JOURNAL|\
EXT2_FEATURE_COMPAT_RESIZE_INODE|\
EXT2_FEATURE_COMPAT_DIR_INDEX|\
EXT2_FEATURE_COMPAT_EXT_ATTR|\
EXT4_FEATURE_COMPAT_SPARSE_SUPER2)
#ifdef CONFIG_MMP
#define EXT4_LIB_INCOMPAT_MMP EXT4_FEATURE_INCOMPAT_MMP
#else
#define EXT4_LIB_INCOMPAT_MMP (0)
#endif
#define EXT2_LIB_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE|\
EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|\
EXT2_FEATURE_INCOMPAT_META_BG|\
EXT3_FEATURE_INCOMPAT_RECOVER|\
EXT3_FEATURE_INCOMPAT_EXTENTS|\
EXT4_FEATURE_INCOMPAT_FLEX_BG|\
EXT4_FEATURE_INCOMPAT_EA_INODE|\
EXT4_LIB_INCOMPAT_MMP|\
EXT4_FEATURE_INCOMPAT_64BIT|\
EXT4_FEATURE_INCOMPAT_INLINE_DATA|\
EXT4_FEATURE_INCOMPAT_ENCRYPT|\
EXT4_FEATURE_INCOMPAT_CASEFOLD|\
EXT4_FEATURE_INCOMPAT_CSUM_SEED|\
EXT4_FEATURE_INCOMPAT_LARGEDIR)
#define EXT2_LIB_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|\
EXT4_FEATURE_RO_COMPAT_HUGE_FILE|\
EXT2_FEATURE_RO_COMPAT_LARGE_FILE|\
EXT4_FEATURE_RO_COMPAT_DIR_NLINK|\
EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE|\
EXT4_FEATURE_RO_COMPAT_GDT_CSUM|\
EXT4_FEATURE_RO_COMPAT_BIGALLOC|\
EXT4_FEATURE_RO_COMPAT_QUOTA|\
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM|\
EXT4_FEATURE_RO_COMPAT_READONLY |\
EXT4_FEATURE_RO_COMPAT_PROJECT |\
EXT4_FEATURE_RO_COMPAT_SHARED_BLOCKS |\
EXT4_FEATURE_RO_COMPAT_VERITY)
/*
* These features are only allowed if EXT2_FLAG_SOFTSUPP_FEATURES is passed
* to ext2fs_openfs()
*/
#define EXT2_LIB_SOFTSUPP_INCOMPAT (0)
#define EXT2_LIB_SOFTSUPP_RO_COMPAT (EXT4_FEATURE_RO_COMPAT_REPLICA)
/* Translate a block number to a cluster number */
#define EXT2FS_CLUSTER_RATIO(fs) (1 << (fs)->cluster_ratio_bits)
#define EXT2FS_CLUSTER_MASK(fs) (EXT2FS_CLUSTER_RATIO(fs) - 1)
#define EXT2FS_B2C(fs, blk) ((blk) >> (fs)->cluster_ratio_bits)
/* Translate a cluster number to a block number */
#define EXT2FS_C2B(fs, cluster) ((cluster) << (fs)->cluster_ratio_bits)
/* Translate # of blks to # of clusters */
#define EXT2FS_NUM_B2C(fs, blks) (((blks) + EXT2FS_CLUSTER_MASK(fs)) >> \
(fs)->cluster_ratio_bits)
#if defined(HAVE_FSTAT64) && !defined(__OSX_AVAILABLE_BUT_DEPRECATED)
typedef struct stat64 ext2fs_struct_stat;
#else
typedef struct stat ext2fs_struct_stat;
#endif
/*
* For ext2fs_close2() and ext2fs_flush2(), this flag allows you to
* avoid the fsync call.
*/
#define EXT2_FLAG_FLUSH_NO_SYNC 1
/*
* Modify and iterate extended attributes
*/
struct ext2_xattr_handle;
#define XATTR_ABORT 1
#define XATTR_CHANGED 2
/*
* function prototypes
*/
static inline int ext2fs_has_group_desc_csum(ext2_filsys fs)
{
return ext2fs_has_feature_metadata_csum(fs->super) ||
ext2fs_has_feature_gdt_csum(fs->super);
}
/* The LARGE_FILE feature should be set if we have stored files 2GB+ in size */
static inline int ext2fs_needs_large_file_feature(unsigned long long file_size)
{
return file_size >= 0x80000000ULL;
}
/* alloc.c */
extern void ext2fs_clear_block_uninit(ext2_filsys fs, dgrp_t group);
extern errcode_t ext2fs_new_inode(ext2_filsys fs, ext2_ino_t dir, int mode,
ext2fs_inode_bitmap map, ext2_ino_t *ret);
extern errcode_t ext2fs_new_block(ext2_filsys fs, blk_t goal,
ext2fs_block_bitmap map, blk_t *ret);
extern errcode_t ext2fs_new_block2(ext2_filsys fs, blk64_t goal,
ext2fs_block_bitmap map, blk64_t *ret);
extern errcode_t ext2fs_new_block3(ext2_filsys fs, blk64_t goal,
ext2fs_block_bitmap map, blk64_t *ret,
struct blk_alloc_ctx *ctx);
extern errcode_t ext2fs_get_free_blocks(ext2_filsys fs, blk_t start,
blk_t finish, int num,
ext2fs_block_bitmap map,
blk_t *ret);
extern errcode_t ext2fs_get_free_blocks2(ext2_filsys fs, blk64_t start,
blk64_t finish, int num,
ext2fs_block_bitmap map,
blk64_t *ret);
extern errcode_t ext2fs_alloc_block(ext2_filsys fs, blk_t goal,
char *block_buf, blk_t *ret);
extern errcode_t ext2fs_alloc_block2(ext2_filsys fs, blk64_t goal,
char *block_buf, blk64_t *ret);
extern errcode_t ext2fs_alloc_block3(ext2_filsys fs, blk64_t goal,
char *block_buf, blk64_t *ret,
struct blk_alloc_ctx *ctx);
extern void ext2fs_set_alloc_block_callback(ext2_filsys fs,
errcode_t (*func)(ext2_filsys fs,
blk64_t goal,
blk64_t *ret),
errcode_t (**old)(ext2_filsys fs,
blk64_t goal,
blk64_t *ret));
blk64_t ext2fs_find_inode_goal(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode *inode, blk64_t lblk);
extern void ext2fs_set_new_range_callback(ext2_filsys fs,
errcode_t (*func)(ext2_filsys fs, int flags, blk64_t goal,
blk64_t len, blk64_t *pblk, blk64_t *plen),
errcode_t (**old)(ext2_filsys fs, int flags, blk64_t goal,
blk64_t len, blk64_t *pblk, blk64_t *plen));
extern void ext2fs_set_block_alloc_stats_range_callback(ext2_filsys fs,
void (*func)(ext2_filsys fs, blk64_t blk,
blk_t num, int inuse),
void (**old)(ext2_filsys fs, blk64_t blk,
blk_t num, int inuse));
#define EXT2_NEWRANGE_FIXED_GOAL (0x1)
#define EXT2_NEWRANGE_MIN_LENGTH (0x2)
#define EXT2_NEWRANGE_ALL_FLAGS (0x3)
errcode_t ext2fs_new_range(ext2_filsys fs, int flags, blk64_t goal,
blk64_t len, ext2fs_block_bitmap map, blk64_t *pblk,
blk64_t *plen);
#define EXT2_ALLOCRANGE_FIXED_GOAL (0x1)
#define EXT2_ALLOCRANGE_ZERO_BLOCKS (0x2)
#define EXT2_ALLOCRANGE_ALL_FLAGS (0x3)
errcode_t ext2fs_alloc_range(ext2_filsys fs, int flags, blk64_t goal,
blk_t len, blk64_t *ret);
/* alloc_sb.c */
extern int ext2fs_reserve_super_and_bgd(ext2_filsys fs,
dgrp_t group,
ext2fs_block_bitmap bmap);
extern void ext2fs_set_block_alloc_stats_callback(ext2_filsys fs,
void (*func)(ext2_filsys fs,
blk64_t blk,
int inuse),
void (**old)(ext2_filsys fs,
blk64_t blk,
int inuse));
/* alloc_stats.c */
void ext2fs_inode_alloc_stats(ext2_filsys fs, ext2_ino_t ino, int inuse);
void ext2fs_inode_alloc_stats2(ext2_filsys fs, ext2_ino_t ino,
int inuse, int isdir);
void ext2fs_block_alloc_stats(ext2_filsys fs, blk_t blk, int inuse);
void ext2fs_block_alloc_stats2(ext2_filsys fs, blk64_t blk, int inuse);
void ext2fs_block_alloc_stats_range(ext2_filsys fs, blk64_t blk,
blk_t num, int inuse);
/* alloc_tables.c */
extern errcode_t ext2fs_allocate_tables(ext2_filsys fs);
extern errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
ext2fs_block_bitmap bmap);
/* badblocks.c */
extern errcode_t ext2fs_u32_list_create(ext2_u32_list *ret, int size);
extern errcode_t ext2fs_u32_list_add(ext2_u32_list bb, __u32 blk);
extern int ext2fs_u32_list_find(ext2_u32_list bb, __u32 blk);
extern int ext2fs_u32_list_test(ext2_u32_list bb, blk_t blk);
extern errcode_t ext2fs_u32_list_iterate_begin(ext2_u32_list bb,
ext2_u32_iterate *ret);
extern int ext2fs_u32_list_iterate(ext2_u32_iterate iter, blk_t *blk);
extern void ext2fs_u32_list_iterate_end(ext2_u32_iterate iter);
extern errcode_t ext2fs_u32_copy(ext2_u32_list src, ext2_u32_list *dest);
extern int ext2fs_u32_list_equal(ext2_u32_list bb1, ext2_u32_list bb2);
extern errcode_t ext2fs_badblocks_list_create(ext2_badblocks_list *ret,
int size);
extern errcode_t ext2fs_badblocks_list_add(ext2_badblocks_list bb,
blk_t blk);
extern int ext2fs_badblocks_list_test(ext2_badblocks_list bb,
blk_t blk);
extern int ext2fs_u32_list_del(ext2_u32_list bb, __u32 blk);
extern void ext2fs_badblocks_list_del(ext2_u32_list bb, __u32 blk);
extern errcode_t
ext2fs_badblocks_list_iterate_begin(ext2_badblocks_list bb,
ext2_badblocks_iterate *ret);
extern int ext2fs_badblocks_list_iterate(ext2_badblocks_iterate iter,
blk_t *blk);
extern void ext2fs_badblocks_list_iterate_end(ext2_badblocks_iterate iter);
extern errcode_t ext2fs_badblocks_copy(ext2_badblocks_list src,
ext2_badblocks_list *dest);
extern int ext2fs_badblocks_equal(ext2_badblocks_list bb1,
ext2_badblocks_list bb2);
extern int ext2fs_u32_list_count(ext2_u32_list bb);
/* bb_compat */
extern errcode_t badblocks_list_create(badblocks_list *ret, int size);
extern errcode_t badblocks_list_add(badblocks_list bb, blk_t blk);
extern int badblocks_list_test(badblocks_list bb, blk_t blk);
extern errcode_t badblocks_list_iterate_begin(badblocks_list bb,
badblocks_iterate *ret);
extern int badblocks_list_iterate(badblocks_iterate iter, blk_t *blk);
extern void badblocks_list_iterate_end(badblocks_iterate iter);
extern void badblocks_list_free(badblocks_list bb);
/* bb_inode.c */
extern errcode_t ext2fs_update_bb_inode(ext2_filsys fs,
ext2_badblocks_list bb_list);
/* bitmaps.c */
extern void ext2fs_free_block_bitmap(ext2fs_block_bitmap bitmap);
extern void ext2fs_free_inode_bitmap(ext2fs_inode_bitmap bitmap);
extern errcode_t ext2fs_copy_bitmap(ext2fs_generic_bitmap src,
ext2fs_generic_bitmap *dest);
extern errcode_t ext2fs_write_inode_bitmap(ext2_filsys fs);
extern errcode_t ext2fs_write_block_bitmap (ext2_filsys fs);
extern errcode_t ext2fs_read_inode_bitmap (ext2_filsys fs);
extern errcode_t ext2fs_read_block_bitmap(ext2_filsys fs);
extern errcode_t ext2fs_allocate_block_bitmap(ext2_filsys fs,
const char *descr,
ext2fs_block_bitmap *ret);
extern errcode_t ext2fs_allocate_subcluster_bitmap(ext2_filsys fs,
const char *descr,
ext2fs_block_bitmap *ret);
extern int ext2fs_get_bitmap_granularity(ext2fs_block_bitmap bitmap);
extern errcode_t ext2fs_allocate_inode_bitmap(ext2_filsys fs,
const char *descr,
ext2fs_inode_bitmap *ret);
extern errcode_t ext2fs_fudge_inode_bitmap_end(ext2fs_inode_bitmap bitmap,
ext2_ino_t end, ext2_ino_t *oend);
extern errcode_t ext2fs_fudge_block_bitmap_end(ext2fs_block_bitmap bitmap,
blk_t end, blk_t *oend);
extern errcode_t ext2fs_fudge_block_bitmap_end2(ext2fs_block_bitmap bitmap,
blk64_t end, blk64_t *oend);
extern void ext2fs_clear_inode_bitmap(ext2fs_inode_bitmap bitmap);
extern void ext2fs_clear_block_bitmap(ext2fs_block_bitmap bitmap);
extern errcode_t ext2fs_read_bitmaps(ext2_filsys fs);
extern errcode_t ext2fs_write_bitmaps(ext2_filsys fs);
extern errcode_t ext2fs_resize_inode_bitmap(__u32 new_end, __u32 new_real_end,
ext2fs_inode_bitmap bmap);
extern errcode_t ext2fs_resize_inode_bitmap2(__u64 new_end,
__u64 new_real_end,
ext2fs_inode_bitmap bmap);
extern errcode_t ext2fs_resize_block_bitmap(__u32 new_end, __u32 new_real_end,
ext2fs_block_bitmap bmap);
extern errcode_t ext2fs_resize_block_bitmap2(__u64 new_end,
__u64 new_real_end,
ext2fs_block_bitmap bmap);
extern errcode_t ext2fs_compare_block_bitmap(ext2fs_block_bitmap bm1,
ext2fs_block_bitmap bm2);
extern errcode_t ext2fs_compare_inode_bitmap(ext2fs_inode_bitmap bm1,
ext2fs_inode_bitmap bm2);
extern errcode_t ext2fs_set_inode_bitmap_range(ext2fs_inode_bitmap bmap,
ext2_ino_t start, unsigned int num,
void *in);
extern errcode_t ext2fs_set_inode_bitmap_range2(ext2fs_inode_bitmap bmap,
__u64 start, size_t num,
void *in);
extern errcode_t ext2fs_get_inode_bitmap_range(ext2fs_inode_bitmap bmap,
ext2_ino_t start, unsigned int num,
void *out);
extern errcode_t ext2fs_get_inode_bitmap_range2(ext2fs_inode_bitmap bmap,
__u64 start, size_t num,
void *out);
extern errcode_t ext2fs_set_block_bitmap_range(ext2fs_block_bitmap bmap,
blk_t start, unsigned int num,
void *in);
extern errcode_t ext2fs_set_block_bitmap_range2(ext2fs_block_bitmap bmap,
blk64_t start, size_t num,
void *in);
extern errcode_t ext2fs_get_block_bitmap_range(ext2fs_block_bitmap bmap,
blk_t start, unsigned int num,
void *out);
extern errcode_t ext2fs_get_block_bitmap_range2(ext2fs_block_bitmap bmap,
blk64_t start, size_t num,
void *out);
/* blknum.c */
extern __u32 ext2fs_inode_bitmap_checksum(ext2_filsys fs, dgrp_t group);
extern __u32 ext2fs_block_bitmap_checksum(ext2_filsys fs, dgrp_t group);
extern dgrp_t ext2fs_group_of_blk2(ext2_filsys fs, blk64_t);
extern blk64_t ext2fs_group_first_block2(ext2_filsys fs, dgrp_t group);
extern blk64_t ext2fs_group_last_block2(ext2_filsys fs, dgrp_t group);
extern int ext2fs_group_blocks_count(ext2_filsys fs, dgrp_t group);
extern blk64_t ext2fs_inode_data_blocks2(ext2_filsys fs,
struct ext2_inode *inode);
extern blk64_t ext2fs_inode_i_blocks(ext2_filsys fs,
struct ext2_inode *inode);
extern blk64_t ext2fs_get_stat_i_blocks(ext2_filsys fs,
struct ext2_inode *inode);
extern blk64_t ext2fs_blocks_count(struct ext2_super_block *super);
extern void ext2fs_blocks_count_set(struct ext2_super_block *super,
blk64_t blk);
extern void ext2fs_blocks_count_add(struct ext2_super_block *super,
blk64_t blk);
extern blk64_t ext2fs_r_blocks_count(struct ext2_super_block *super);
extern void ext2fs_r_blocks_count_set(struct ext2_super_block *super,
blk64_t blk);
extern void ext2fs_r_blocks_count_add(struct ext2_super_block *super,
blk64_t blk);
extern blk64_t ext2fs_free_blocks_count(struct ext2_super_block *super);
extern void ext2fs_free_blocks_count_set(struct ext2_super_block *super,
blk64_t blk);
extern void ext2fs_free_blocks_count_add(struct ext2_super_block *super,
blk64_t blk);
/* Block group descriptor accessor functions */
extern struct ext2_group_desc *ext2fs_group_desc(ext2_filsys fs,
struct opaque_ext2_group_desc *gdp,
dgrp_t group);
extern blk64_t ext2fs_block_bitmap_csum(ext2_filsys fs, dgrp_t group);
extern blk64_t ext2fs_block_bitmap_loc(ext2_filsys fs, dgrp_t group);
extern void ext2fs_block_bitmap_loc_set(ext2_filsys fs, dgrp_t group,
blk64_t blk);
extern __u32 ext2fs_inode_bitmap_csum(ext2_filsys fs, dgrp_t group);
extern blk64_t ext2fs_inode_bitmap_loc(ext2_filsys fs, dgrp_t group);
extern void ext2fs_inode_bitmap_loc_set(ext2_filsys fs, dgrp_t group,
blk64_t blk);
extern blk64_t ext2fs_inode_table_loc(ext2_filsys fs, dgrp_t group);
extern void ext2fs_inode_table_loc_set(ext2_filsys fs, dgrp_t group,
blk64_t blk);
extern __u32 ext2fs_bg_free_blocks_count(ext2_filsys fs, dgrp_t group);
extern void ext2fs_bg_free_blocks_count_set(ext2_filsys fs, dgrp_t group,
__u32 n);
extern __u32 ext2fs_bg_free_inodes_count(ext2_filsys fs, dgrp_t group);
extern void ext2fs_bg_free_inodes_count_set(ext2_filsys fs, dgrp_t group,
__u32 n);
extern __u32 ext2fs_bg_used_dirs_count(ext2_filsys fs, dgrp_t group);
extern void ext2fs_bg_used_dirs_count_set(ext2_filsys fs, dgrp_t group,
__u32 n);
extern __u32 ext2fs_bg_itable_unused(ext2_filsys fs, dgrp_t group);
extern void ext2fs_bg_itable_unused_set(ext2_filsys fs, dgrp_t group,
__u32 n);
extern __u16 ext2fs_bg_flags(ext2_filsys fs, dgrp_t group);
extern void ext2fs_bg_flags_zap(ext2_filsys fs, dgrp_t group);
extern int ext2fs_bg_flags_test(ext2_filsys fs, dgrp_t group, __u16 bg_flag);
extern void ext2fs_bg_flags_set(ext2_filsys fs, dgrp_t group, __u16 bg_flags);
extern void ext2fs_bg_flags_clear(ext2_filsys fs, dgrp_t group, __u16 bg_flags);
extern __u16 ext2fs_bg_checksum(ext2_filsys fs, dgrp_t group);
extern void ext2fs_bg_checksum_set(ext2_filsys fs, dgrp_t group, __u16 checksum);
extern blk64_t ext2fs_file_acl_block(ext2_filsys fs,
const struct ext2_inode *inode);
extern void ext2fs_file_acl_block_set(ext2_filsys fs,
struct ext2_inode *inode, blk64_t blk);
extern errcode_t ext2fs_inode_size_set(ext2_filsys fs, struct ext2_inode *inode,
ext2_off64_t size);
/* block.c */
extern errcode_t ext2fs_block_iterate(ext2_filsys fs,
ext2_ino_t ino,
int flags,
char *block_buf,
int (*func)(ext2_filsys fs,
blk_t *blocknr,
int blockcnt,
void *priv_data),
void *priv_data);
errcode_t ext2fs_block_iterate2(ext2_filsys fs,
ext2_ino_t ino,
int flags,
char *block_buf,
int (*func)(ext2_filsys fs,
blk_t *blocknr,
e2_blkcnt_t blockcnt,
blk_t ref_blk,
int ref_offset,
void *priv_data),
void *priv_data);
errcode_t ext2fs_block_iterate3(ext2_filsys fs,
ext2_ino_t ino,
int flags,
char *block_buf,
int (*func)(ext2_filsys fs,
blk64_t *blocknr,
e2_blkcnt_t blockcnt,
blk64_t ref_blk,
int ref_offset,
void *priv_data),
void *priv_data);
/* bmap.c */
extern errcode_t ext2fs_bmap(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode *inode,
char *block_buf, int bmap_flags,
blk_t block, blk_t *phys_blk);
extern errcode_t ext2fs_bmap2(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode *inode,
char *block_buf, int bmap_flags, blk64_t block,
int *ret_flags, blk64_t *phys_blk);
errcode_t ext2fs_map_cluster_block(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode *inode, blk64_t lblk,
blk64_t *pblk);
#if 0
/* bmove.c */
extern errcode_t ext2fs_move_blocks(ext2_filsys fs,
ext2fs_block_bitmap reserve,
ext2fs_block_bitmap alloc_map,
int flags);
#endif
/* check_desc.c */
extern errcode_t ext2fs_check_desc(ext2_filsys fs);
/* closefs.c */
extern errcode_t ext2fs_close(ext2_filsys fs);
extern errcode_t ext2fs_close2(ext2_filsys fs, int flags);
extern errcode_t ext2fs_close_free(ext2_filsys *fs);
extern errcode_t ext2fs_flush(ext2_filsys fs);
extern errcode_t ext2fs_flush2(ext2_filsys fs, int flags);
extern int ext2fs_bg_has_super(ext2_filsys fs, dgrp_t group_block);
extern errcode_t ext2fs_super_and_bgd_loc2(ext2_filsys fs,
dgrp_t group,
blk64_t *ret_super_blk,
blk64_t *ret_old_desc_blk,
blk64_t *ret_new_desc_blk,
blk_t *ret_used_blks);
extern int ext2fs_super_and_bgd_loc(ext2_filsys fs,
dgrp_t group,
blk_t *ret_super_blk,
blk_t *ret_old_desc_blk,
blk_t *ret_new_desc_blk,
int *ret_meta_bg);
extern void ext2fs_update_dynamic_rev(ext2_filsys fs);
/* crc32c.c */
extern __u32 ext2fs_crc32_be(__u32 crc, unsigned char const *p, size_t len);
extern __u32 ext2fs_crc32c_le(__u32 crc, unsigned char const *p, size_t len);
/* csum.c */
extern void ext2fs_init_csum_seed(ext2_filsys fs);
extern errcode_t ext2fs_mmp_csum_set(ext2_filsys fs, struct mmp_struct *mmp);
extern int ext2fs_mmp_csum_verify(ext2_filsys, struct mmp_struct *mmp);
extern int ext2fs_verify_csum_type(ext2_filsys fs, struct ext2_super_block *sb);
extern errcode_t ext2fs_superblock_csum_set(ext2_filsys fs,
struct ext2_super_block *sb);
extern int ext2fs_superblock_csum_verify(ext2_filsys fs,
struct ext2_super_block *sb);
extern errcode_t ext2fs_ext_attr_block_csum_set(ext2_filsys fs,
ext2_ino_t inum, blk64_t block,
struct ext2_ext_attr_header *hdr);
extern int ext2fs_ext_attr_block_csum_verify(ext2_filsys fs, ext2_ino_t inum,
blk64_t block,
struct ext2_ext_attr_header *hdr);
#define EXT2_DIRENT_TAIL(block, blocksize) \
((struct ext2_dir_entry_tail *)(((char *)(block)) + \
(blocksize) - sizeof(struct ext2_dir_entry_tail)))
extern void ext2fs_initialize_dirent_tail(ext2_filsys fs,
struct ext2_dir_entry_tail *t);
extern int ext2fs_dirent_has_tail(ext2_filsys fs,
struct ext2_dir_entry *dirent);
extern int ext2fs_dirent_csum_verify(ext2_filsys fs, ext2_ino_t inum,
struct ext2_dir_entry *dirent);
extern int ext2fs_dir_block_csum_verify(ext2_filsys fs, ext2_ino_t inum,
struct ext2_dir_entry *dirent);
extern errcode_t ext2fs_dir_block_csum_set(ext2_filsys fs, ext2_ino_t inum,
struct ext2_dir_entry *dirent);
extern errcode_t ext2fs_get_dx_countlimit(ext2_filsys fs,
struct ext2_dir_entry *dirent,
struct ext2_dx_countlimit **cc,
int *offset);
extern errcode_t ext2fs_extent_block_csum_set(ext2_filsys fs,
ext2_ino_t inum,
struct ext3_extent_header *eh);
extern int ext2fs_extent_block_csum_verify(ext2_filsys fs,
ext2_ino_t inum,
struct ext3_extent_header *eh);
extern errcode_t ext2fs_block_bitmap_csum_set(ext2_filsys fs, dgrp_t group,
char *bitmap, int size);
extern int ext2fs_block_bitmap_csum_verify(ext2_filsys fs, dgrp_t group,
char *bitmap, int size);
extern errcode_t ext2fs_inode_bitmap_csum_set(ext2_filsys fs, dgrp_t group,
char *bitmap, int size);
extern int ext2fs_inode_bitmap_csum_verify(ext2_filsys fs, dgrp_t group,
char *bitmap, int size);
extern errcode_t ext2fs_inode_csum_set(ext2_filsys fs, ext2_ino_t inum,
struct ext2_inode_large *inode);
extern int ext2fs_inode_csum_verify(ext2_filsys fs, ext2_ino_t inum,
struct ext2_inode_large *inode);
extern void ext2fs_group_desc_csum_set(ext2_filsys fs, dgrp_t group);
extern int ext2fs_group_desc_csum_verify(ext2_filsys fs, dgrp_t group);
extern errcode_t ext2fs_set_gdt_csum(ext2_filsys fs);
extern __u16 ext2fs_group_desc_csum(ext2_filsys fs, dgrp_t group);
/* dblist.c */
extern errcode_t ext2fs_init_dblist(ext2_filsys fs, ext2_dblist *ret_dblist);
extern errcode_t ext2fs_add_dir_block(ext2_dblist dblist, ext2_ino_t ino,
blk_t blk, int blockcnt);
extern errcode_t ext2fs_add_dir_block2(ext2_dblist dblist, ext2_ino_t ino,
blk64_t blk, e2_blkcnt_t blockcnt);
extern void ext2fs_dblist_sort(ext2_dblist dblist,
EXT2_QSORT_TYPE (*sortfunc)(const void *,
const void *));
extern void ext2fs_dblist_sort2(ext2_dblist dblist,
EXT2_QSORT_TYPE (*sortfunc)(const void *,
const void *));
extern errcode_t ext2fs_dblist_iterate(ext2_dblist dblist,
int (*func)(ext2_filsys fs, struct ext2_db_entry *db_info,
void *priv_data),
void *priv_data);
extern errcode_t ext2fs_dblist_iterate2(ext2_dblist dblist,
int (*func)(ext2_filsys fs, struct ext2_db_entry2 *db_info,
void *priv_data),
void *priv_data);
extern errcode_t ext2fs_dblist_iterate3(ext2_dblist dblist,
int (*func)(ext2_filsys fs, struct ext2_db_entry2 *db_info,
void *priv_data),
unsigned long long start,
unsigned long long count,
void *priv_data);
extern errcode_t ext2fs_set_dir_block(ext2_dblist dblist, ext2_ino_t ino,
blk_t blk, int blockcnt);
extern errcode_t ext2fs_set_dir_block2(ext2_dblist dblist, ext2_ino_t ino,
blk64_t blk, e2_blkcnt_t blockcnt);
extern errcode_t ext2fs_copy_dblist(ext2_dblist src,
ext2_dblist *dest);
extern int ext2fs_dblist_count(ext2_dblist dblist);
extern blk64_t ext2fs_dblist_count2(ext2_dblist dblist);
extern errcode_t ext2fs_dblist_get_last(ext2_dblist dblist,
struct ext2_db_entry **entry);
extern errcode_t ext2fs_dblist_get_last2(ext2_dblist dblist,
struct ext2_db_entry2 **entry);
extern errcode_t ext2fs_dblist_drop_last(ext2_dblist dblist);
/* dblist_dir.c */
extern errcode_t
ext2fs_dblist_dir_iterate(ext2_dblist dblist,
int flags,
char *block_buf,
int (*func)(ext2_ino_t dir,
int entry,
struct ext2_dir_entry *dirent,
int offset,
int blocksize,
char *buf,
void *priv_data),
void *priv_data);
#if 0
/* digest_encode.c */
#define EXT2FS_DIGEST_SIZE EXT2FS_SHA256_LENGTH
extern int ext2fs_digest_encode(const char *src, int len, char *dst);
extern int ext2fs_digest_decode(const char *src, int len, char *dst);
#endif
/* dirblock.c */
extern errcode_t ext2fs_read_dir_block(ext2_filsys fs, blk_t block,
void *buf);
extern errcode_t ext2fs_read_dir_block2(ext2_filsys fs, blk_t block,
void *buf, int flags);
extern errcode_t ext2fs_read_dir_block3(ext2_filsys fs, blk64_t block,
void *buf, int flags);
extern errcode_t ext2fs_read_dir_block4(ext2_filsys fs, blk64_t block,
void *buf, int flags, ext2_ino_t ino);
extern errcode_t ext2fs_write_dir_block(ext2_filsys fs, blk_t block,
void *buf);
extern errcode_t ext2fs_write_dir_block2(ext2_filsys fs, blk_t block,
void *buf, int flags);
extern errcode_t ext2fs_write_dir_block3(ext2_filsys fs, blk64_t block,
void *buf, int flags);
extern errcode_t ext2fs_write_dir_block4(ext2_filsys fs, blk64_t block,
void *buf, int flags, ext2_ino_t ino);
/* dirhash.c */
extern errcode_t ext2fs_dirhash(int version, const char *name, int len,
const __u32 *seed,
ext2_dirhash_t *ret_hash,
ext2_dirhash_t *ret_minor_hash);
extern errcode_t ext2fs_dirhash2(int version, const char *name, int len,
const struct ext2fs_nls_table *charset,
int hash_flags,
const __u32 *seed,
ext2_dirhash_t *ret_hash,
ext2_dirhash_t *ret_minor_hash);
/* dir_iterate.c */
extern errcode_t ext2fs_get_rec_len(ext2_filsys fs,
struct ext2_dir_entry *dirent,
unsigned int *rec_len);
extern errcode_t ext2fs_set_rec_len(ext2_filsys fs,
unsigned int len,
struct ext2_dir_entry *dirent);
extern errcode_t ext2fs_dir_iterate(ext2_filsys fs,
ext2_ino_t dir,
int flags,
char *block_buf,
int (*func)(struct ext2_dir_entry *dirent,
int offset,
int blocksize,
char *buf,
void *priv_data),
void *priv_data);
extern errcode_t ext2fs_dir_iterate2(ext2_filsys fs,
ext2_ino_t dir,
int flags,
char *block_buf,
int (*func)(ext2_ino_t dir,
int entry,
struct ext2_dir_entry *dirent,
int offset,
int blocksize,
char *buf,
void *priv_data),
void *priv_data);
/* dupfs.c */
extern errcode_t ext2fs_dup_handle(ext2_filsys src, ext2_filsys *dest);
/* expanddir.c */
extern errcode_t ext2fs_expand_dir(ext2_filsys fs, ext2_ino_t dir);
/* ext_attr.c */
extern __u32 ext2fs_ext_attr_hash_entry(struct ext2_ext_attr_entry *entry,
void *data);
extern errcode_t ext2fs_ext_attr_hash_entry2(ext2_filsys fs,
struct ext2_ext_attr_entry *entry,
void *data, __u32 *hash);
extern errcode_t ext2fs_read_ext_attr(ext2_filsys fs, blk_t block, void *buf);
extern errcode_t ext2fs_read_ext_attr2(ext2_filsys fs, blk64_t block,
void *buf);
extern errcode_t ext2fs_read_ext_attr3(ext2_filsys fs, blk64_t block,
void *buf, ext2_ino_t inum);
extern errcode_t ext2fs_write_ext_attr(ext2_filsys fs, blk_t block,
void *buf);
extern errcode_t ext2fs_write_ext_attr2(ext2_filsys fs, blk64_t block,
void *buf);
extern errcode_t ext2fs_write_ext_attr3(ext2_filsys fs, blk64_t block,
void *buf, ext2_ino_t inum);
extern errcode_t ext2fs_adjust_ea_refcount(ext2_filsys fs, blk_t blk,
char *block_buf,
int adjust, __u32 *newcount);
extern errcode_t ext2fs_adjust_ea_refcount2(ext2_filsys fs, blk64_t blk,
char *block_buf,
int adjust, __u32 *newcount);
extern errcode_t ext2fs_adjust_ea_refcount3(ext2_filsys fs, blk64_t blk,
char *block_buf,
int adjust, __u32 *newcount,
ext2_ino_t inum);
errcode_t ext2fs_xattrs_write(struct ext2_xattr_handle *handle);
errcode_t ext2fs_xattrs_read(struct ext2_xattr_handle *handle);
errcode_t ext2fs_xattrs_iterate(struct ext2_xattr_handle *h,
int (*func)(char *name, char *value,
size_t value_len, void *data),
void *data);
errcode_t ext2fs_xattr_get(struct ext2_xattr_handle *h, const char *key,
void **value, size_t *value_len);
errcode_t ext2fs_xattr_set(struct ext2_xattr_handle *handle,
const char *key,
const void *value,
size_t value_len);
errcode_t ext2fs_xattr_remove(struct ext2_xattr_handle *handle,
const char *key);
errcode_t ext2fs_xattrs_open(ext2_filsys fs, ext2_ino_t ino,
struct ext2_xattr_handle **handle);
errcode_t ext2fs_xattrs_close(struct ext2_xattr_handle **handle);
errcode_t ext2fs_free_ext_attr(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode_large *inode);
errcode_t ext2fs_xattrs_count(struct ext2_xattr_handle *handle, size_t *count);
errcode_t ext2fs_xattr_inode_max_size(ext2_filsys fs, ext2_ino_t ino,
size_t *size);
#define XATTR_HANDLE_FLAG_RAW 0x0001
errcode_t ext2fs_xattrs_flags(struct ext2_xattr_handle *handle,
unsigned int *new_flags, unsigned int *old_flags);
extern void ext2fs_ext_attr_block_rehash(struct ext2_ext_attr_header *header,
struct ext2_ext_attr_entry *end);
extern __u32 ext2fs_get_ea_inode_hash(struct ext2_inode *inode);
extern void ext2fs_set_ea_inode_hash(struct ext2_inode *inode, __u32 hash);
extern __u64 ext2fs_get_ea_inode_ref(struct ext2_inode *inode);
extern void ext2fs_set_ea_inode_ref(struct ext2_inode *inode, __u64 ref_count);
/* extent.c */
extern errcode_t ext2fs_extent_header_verify(void *ptr, int size);
extern errcode_t ext2fs_extent_open(ext2_filsys fs, ext2_ino_t ino,
ext2_extent_handle_t *handle);
extern errcode_t ext2fs_extent_open2(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode *inode,
ext2_extent_handle_t *ret_handle);
extern void ext2fs_extent_free(ext2_extent_handle_t handle);
extern errcode_t ext2fs_extent_get(ext2_extent_handle_t handle,
int flags, struct ext2fs_extent *extent);
extern errcode_t ext2fs_extent_node_split(ext2_extent_handle_t handle);
extern errcode_t ext2fs_extent_replace(ext2_extent_handle_t handle, int flags,
struct ext2fs_extent *extent);
extern errcode_t ext2fs_extent_insert(ext2_extent_handle_t handle, int flags,
struct ext2fs_extent *extent);
extern errcode_t ext2fs_extent_set_bmap(ext2_extent_handle_t handle,
blk64_t logical, blk64_t physical,
int flags);
extern errcode_t ext2fs_extent_delete(ext2_extent_handle_t handle, int flags);
extern errcode_t ext2fs_extent_get_info(ext2_extent_handle_t handle,
struct ext2_extent_info *info);
extern errcode_t ext2fs_extent_goto(ext2_extent_handle_t handle,
blk64_t blk);
extern errcode_t ext2fs_extent_goto2(ext2_extent_handle_t handle,
int leaf_level, blk64_t blk);
extern errcode_t ext2fs_extent_fix_parents(ext2_extent_handle_t handle);
extern size_t ext2fs_max_extent_depth(ext2_extent_handle_t handle);
extern errcode_t ext2fs_fix_extents_checksums(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode *inode);
/* fallocate.c */
#define EXT2_FALLOCATE_ZERO_BLOCKS (0x1)
#define EXT2_FALLOCATE_FORCE_INIT (0x2)
#define EXT2_FALLOCATE_FORCE_UNINIT (0x4)
#define EXT2_FALLOCATE_INIT_BEYOND_EOF (0x8)
#define EXT2_FALLOCATE_ALL_FLAGS (0xF)
errcode_t ext2fs_fallocate(ext2_filsys fs, int flags, ext2_ino_t ino,
struct ext2_inode *inode, blk64_t goal,
blk64_t start, blk64_t len);
/* fileio.c */
extern errcode_t ext2fs_file_open2(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode *inode,
int flags, ext2_file_t *ret);
extern errcode_t ext2fs_file_open(ext2_filsys fs, ext2_ino_t ino,
int flags, ext2_file_t *ret);
extern ext2_filsys ext2fs_file_get_fs(ext2_file_t file);
struct ext2_inode *ext2fs_file_get_inode(ext2_file_t file);
extern ext2_ino_t ext2fs_file_get_inode_num(ext2_file_t file);
extern errcode_t ext2fs_file_close(ext2_file_t file);
extern errcode_t ext2fs_file_flush(ext2_file_t file);
extern errcode_t ext2fs_file_read(ext2_file_t file, void *buf,
unsigned int wanted, unsigned int *got);
extern errcode_t ext2fs_file_write(ext2_file_t file, const void *buf,
unsigned int nbytes, unsigned int *written);
extern errcode_t ext2fs_file_llseek(ext2_file_t file, __u64 offset,
int whence, __u64 *ret_pos);
extern errcode_t ext2fs_file_lseek(ext2_file_t file, ext2_off_t offset,
int whence, ext2_off_t *ret_pos);
errcode_t ext2fs_file_get_lsize(ext2_file_t file, __u64 *ret_size);
extern ext2_off_t ext2fs_file_get_size(ext2_file_t file);
extern errcode_t ext2fs_file_set_size(ext2_file_t file, ext2_off_t size);
extern errcode_t ext2fs_file_set_size2(ext2_file_t file, ext2_off64_t size);
/* finddev.c */
extern char *ext2fs_find_block_device(dev_t device);
/* flushb.c */
extern errcode_t ext2fs_sync_device(int fd, int flushb);
/* freefs.c */
extern void ext2fs_free(ext2_filsys fs);
extern void ext2fs_free_dblist(ext2_dblist dblist);
extern void ext2fs_badblocks_list_free(ext2_badblocks_list bb);
extern void ext2fs_u32_list_free(ext2_u32_list bb);
/* gen_bitmap.c */
extern void ext2fs_free_generic_bitmap(ext2fs_inode_bitmap bitmap);
extern errcode_t ext2fs_make_generic_bitmap(errcode_t magic, ext2_filsys fs,
__u32 start, __u32 end,
__u32 real_end,
const char *descr, char *init_map,
ext2fs_generic_bitmap *ret);
extern errcode_t ext2fs_allocate_generic_bitmap(__u32 start,
__u32 end,
__u32 real_end,
const char *descr,
ext2fs_generic_bitmap *ret);
extern errcode_t ext2fs_copy_generic_bitmap(ext2fs_generic_bitmap src,
ext2fs_generic_bitmap *dest);
extern void ext2fs_clear_generic_bitmap(ext2fs_generic_bitmap bitmap);
extern errcode_t ext2fs_fudge_generic_bitmap_end(ext2fs_inode_bitmap bitmap,
errcode_t magic,
errcode_t neq,
ext2_ino_t end,
ext2_ino_t *oend);
extern void ext2fs_set_generic_bitmap_padding(ext2fs_generic_bitmap map);
extern errcode_t ext2fs_resize_generic_bitmap(errcode_t magic,
__u32 new_end,
__u32 new_real_end,
ext2fs_generic_bitmap bmap);
extern errcode_t ext2fs_compare_generic_bitmap(errcode_t magic, errcode_t neq,
ext2fs_generic_bitmap bm1,
ext2fs_generic_bitmap bm2);
extern errcode_t ext2fs_get_generic_bitmap_range(ext2fs_generic_bitmap bmap,
errcode_t magic,
__u32 start, __u32 num,
void *out);
extern errcode_t ext2fs_set_generic_bitmap_range(ext2fs_generic_bitmap bmap,
errcode_t magic,
__u32 start, __u32 num,
void *in);
extern errcode_t ext2fs_find_first_zero_generic_bitmap(ext2fs_generic_bitmap bitmap,
__u32 start, __u32 end,
__u32 *out);
extern errcode_t ext2fs_find_first_set_generic_bitmap(ext2fs_generic_bitmap bitmap,
__u32 start, __u32 end,
__u32 *out);
/* gen_bitmap64.c */
void ext2fs_free_generic_bmap(ext2fs_generic_bitmap bmap);
errcode_t ext2fs_alloc_generic_bmap(ext2_filsys fs, errcode_t magic,
int type, __u64 start, __u64 end,
__u64 real_end,
const char *descr,
ext2fs_generic_bitmap *ret);
errcode_t ext2fs_copy_generic_bmap(ext2fs_generic_bitmap src,
ext2fs_generic_bitmap *dest);
void ext2fs_clear_generic_bmap(ext2fs_generic_bitmap bitmap);
errcode_t ext2fs_fudge_generic_bmap_end(ext2fs_generic_bitmap bitmap,
errcode_t neq,
__u64 end, __u64 *oend);
void ext2fs_set_generic_bmap_padding(ext2fs_generic_bitmap bmap);
errcode_t ext2fs_resize_generic_bmap(ext2fs_generic_bitmap bmap,
__u64 new_end,
__u64 new_real_end);
errcode_t ext2fs_compare_generic_bmap(errcode_t neq,
ext2fs_generic_bitmap bm1,
ext2fs_generic_bitmap bm2);
errcode_t ext2fs_get_generic_bmap_range(ext2fs_generic_bitmap bmap,
__u64 start, unsigned int num,
void *out);
errcode_t ext2fs_set_generic_bmap_range(ext2fs_generic_bitmap bmap,
__u64 start, unsigned int num,
void *in);
errcode_t ext2fs_convert_subcluster_bitmap(ext2_filsys fs,
ext2fs_block_bitmap *bitmap);
/* get_num_dirs.c */
extern errcode_t ext2fs_get_num_dirs(ext2_filsys fs, ext2_ino_t *ret_num_dirs);
/* getsize.c */
extern errcode_t ext2fs_get_device_size(const char *file, int blocksize,
blk_t *retblocks);
extern errcode_t ext2fs_get_device_size2(const char *file, int blocksize,
blk64_t *retblocks);
/* getsectsize.c */
extern int ext2fs_get_dio_alignment(int fd);
errcode_t ext2fs_get_device_sectsize(const char *file, int *sectsize);
errcode_t ext2fs_get_device_phys_sectsize(const char *file, int *sectsize);
/* i_block.c */
errcode_t ext2fs_iblk_add_blocks(ext2_filsys fs, struct ext2_inode *inode,
blk64_t num_blocks);
errcode_t ext2fs_iblk_sub_blocks(ext2_filsys fs, struct ext2_inode *inode,
blk64_t num_blocks);
errcode_t ext2fs_iblk_set(ext2_filsys fs, struct ext2_inode *inode, blk64_t b);
/* imager.c */
extern errcode_t ext2fs_image_inode_write(ext2_filsys fs, int fd, int flags);
extern errcode_t ext2fs_image_inode_read(ext2_filsys fs, int fd, int flags);
extern errcode_t ext2fs_image_super_write(ext2_filsys fs, int fd, int flags);
extern errcode_t ext2fs_image_super_read(ext2_filsys fs, int fd, int flags);
extern errcode_t ext2fs_image_bitmap_write(ext2_filsys fs, int fd, int flags);
extern errcode_t ext2fs_image_bitmap_read(ext2_filsys fs, int fd, int flags);
/* ind_block.c */
errcode_t ext2fs_read_ind_block(ext2_filsys fs, blk_t blk, void *buf);
errcode_t ext2fs_write_ind_block(ext2_filsys fs, blk_t blk, void *buf);
/* initialize.c */
extern errcode_t ext2fs_initialize(const char *name, int flags,
struct ext2_super_block *param,
io_manager manager, ext2_filsys *ret_fs);
/* icount.c */
extern void ext2fs_free_icount(ext2_icount_t icount);
extern errcode_t ext2fs_create_icount_tdb(ext2_filsys fs, char *tdb_dir,
int flags, ext2_icount_t *ret);
extern errcode_t ext2fs_create_icount2(ext2_filsys fs, int flags,
unsigned int size,
ext2_icount_t hint, ext2_icount_t *ret);
extern errcode_t ext2fs_create_icount(ext2_filsys fs, int flags,
unsigned int size,
ext2_icount_t *ret);
extern errcode_t ext2fs_icount_fetch(ext2_icount_t icount, ext2_ino_t ino,
__u16 *ret);
extern errcode_t ext2fs_icount_increment(ext2_icount_t icount, ext2_ino_t ino,
__u16 *ret);
extern errcode_t ext2fs_icount_decrement(ext2_icount_t icount, ext2_ino_t ino,
__u16 *ret);
extern errcode_t ext2fs_icount_store(ext2_icount_t icount, ext2_ino_t ino,
__u16 count);
extern ext2_ino_t ext2fs_get_icount_size(ext2_icount_t icount);
errcode_t ext2fs_icount_validate(ext2_icount_t icount, FILE *);
/* inline.c */
extern errcode_t ext2fs_get_memalign(unsigned long size,
unsigned long align, void *ptr);
/* inline_data.c */
extern errcode_t ext2fs_inline_data_init(ext2_filsys fs, ext2_ino_t ino);
extern errcode_t ext2fs_inline_data_size(ext2_filsys fs, ext2_ino_t ino,
size_t *size);
extern errcode_t ext2fs_inline_data_get(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode *inode,
void *buf, size_t *size);
extern errcode_t ext2fs_inline_data_set(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode *inode,
void *buf, size_t size);
/* inode.c */
extern errcode_t ext2fs_create_inode_cache(ext2_filsys fs,
unsigned int cache_size);
extern void ext2fs_free_inode_cache(struct ext2_inode_cache *icache);
extern errcode_t ext2fs_flush_icache(ext2_filsys fs);
extern errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan,
ext2_ino_t *ino,
struct ext2_inode *inode,
int bufsize);
#define EXT2_INODE_SCAN_DEFAULT_BUFFER_BLOCKS 8
extern errcode_t ext2fs_open_inode_scan(ext2_filsys fs, int buffer_blocks,
ext2_inode_scan *ret_scan);
extern void ext2fs_close_inode_scan(ext2_inode_scan scan);
extern errcode_t ext2fs_get_next_inode(ext2_inode_scan scan, ext2_ino_t *ino,
struct ext2_inode *inode);
extern errcode_t ext2fs_inode_scan_goto_blockgroup(ext2_inode_scan scan,
int group);
extern void ext2fs_set_inode_callback
(ext2_inode_scan scan,
errcode_t (*done_group)(ext2_filsys fs,
ext2_inode_scan scan,
dgrp_t group,
void * priv_data),
void *done_group_data);
extern int ext2fs_inode_scan_flags(ext2_inode_scan scan, int set_flags,
int clear_flags);
extern errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode * inode,
int bufsize);
extern errcode_t ext2fs_read_inode(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode * inode);
extern errcode_t ext2fs_read_inode2(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode * inode,
int bufsize, int flags);
extern errcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode * inode,
int bufsize);
extern errcode_t ext2fs_write_inode(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode * inode);
extern errcode_t ext2fs_write_inode2(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode * inode,
int bufsize, int flags);
extern errcode_t ext2fs_write_new_inode(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode * inode);
extern errcode_t ext2fs_get_blocks(ext2_filsys fs, ext2_ino_t ino, blk_t *blocks);
extern errcode_t ext2fs_check_directory(ext2_filsys fs, ext2_ino_t ino);
/* inode_io.c */
extern io_manager inode_io_manager;
extern errcode_t ext2fs_inode_io_intern(ext2_filsys fs, ext2_ino_t ino,
char **name);
extern errcode_t ext2fs_inode_io_intern2(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode *inode,
char **name);
/* ismounted.c */
extern errcode_t ext2fs_check_if_mounted(const char *file, int *mount_flags);
extern errcode_t ext2fs_check_mount_point(const char *device, int *mount_flags,
char *mtpt, int mtlen);
/* punch.c */
/*
* NOTE: This function removes from an inode the blocks "start", "end", and
* every block in between.
*/
extern errcode_t ext2fs_punch(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode *inode,
char *block_buf, blk64_t start,
blk64_t end);
/* namei.c */
extern errcode_t ext2fs_lookup(ext2_filsys fs, ext2_ino_t dir, const char *name,
int namelen, char *buf, ext2_ino_t *inode);
extern errcode_t ext2fs_namei(ext2_filsys fs, ext2_ino_t root, ext2_ino_t cwd,
const char *name, ext2_ino_t *inode);
errcode_t ext2fs_namei_follow(ext2_filsys fs, ext2_ino_t root, ext2_ino_t cwd,
const char *name, ext2_ino_t *inode);
extern errcode_t ext2fs_follow_link(ext2_filsys fs, ext2_ino_t root, ext2_ino_t cwd,
ext2_ino_t inode, ext2_ino_t *res_inode);
/* native.c */
int ext2fs_native_flag(void);
/* newdir.c */
extern errcode_t ext2fs_new_dir_block(ext2_filsys fs, ext2_ino_t dir_ino,
ext2_ino_t parent_ino, char **block);
extern errcode_t ext2fs_new_dir_inline_data(ext2_filsys fs, ext2_ino_t dir_ino,
ext2_ino_t parent_ino, __u32 *iblock);
/* nls_utf8.c */
extern const struct ext2fs_nls_table *ext2fs_load_nls_table(int encoding);
/* mkdir.c */
extern errcode_t ext2fs_mkdir(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t inum,
const char *name);
/* mkjournal.c */
extern errcode_t ext2fs_zero_blocks(ext2_filsys fs, blk_t blk, int num,
blk_t *ret_blk, int *ret_count);
extern errcode_t ext2fs_zero_blocks2(ext2_filsys fs, blk64_t blk, int num,
blk64_t *ret_blk, int *ret_count);
extern errcode_t ext2fs_create_journal_superblock(ext2_filsys fs,
__u32 num_blocks, int flags,
char **ret_jsb);
extern errcode_t ext2fs_add_journal_device(ext2_filsys fs,
ext2_filsys journal_dev);
extern errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t num_blocks,
int flags);
extern errcode_t ext2fs_add_journal_inode2(ext2_filsys fs, blk_t num_blocks,
blk64_t goal, int flags);
extern int ext2fs_default_journal_size(__u64 num_blocks);
extern int ext2fs_journal_sb_start(int blocksize);
/* openfs.c */
extern errcode_t ext2fs_open(const char *name, int flags, int superblock,
unsigned int block_size, io_manager manager,
ext2_filsys *ret_fs);
extern errcode_t ext2fs_open2(const char *name, const char *io_options,
int flags, int superblock,
unsigned int block_size, io_manager manager,
ext2_filsys *ret_fs);
/*
* The dgrp_t argument to these two functions is not actually a group number
* but a block number offset within a group table! Convert with the formula
* (group_number / groups_per_block).
*/
extern blk64_t ext2fs_descriptor_block_loc2(ext2_filsys fs,
blk64_t group_block, dgrp_t i);
extern blk_t ext2fs_descriptor_block_loc(ext2_filsys fs, blk_t group_block,
dgrp_t i);
errcode_t ext2fs_get_data_io(ext2_filsys fs, io_channel *old_io);
errcode_t ext2fs_set_data_io(ext2_filsys fs, io_channel new_io);
errcode_t ext2fs_rewrite_to_io(ext2_filsys fs, io_channel new_io);
/* get_pathname.c */
extern errcode_t ext2fs_get_pathname(ext2_filsys fs, ext2_ino_t dir, ext2_ino_t ino,
char **name);
/* link.c */
errcode_t ext2fs_link(ext2_filsys fs, ext2_ino_t dir, const char *name,
ext2_ino_t ino, int flags);
errcode_t ext2fs_unlink(ext2_filsys fs, ext2_ino_t dir, const char *name,
ext2_ino_t ino, int flags);
/* symlink.c */
errcode_t ext2fs_symlink(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t ino,
const char *name, const char *target);
int ext2fs_is_fast_symlink(struct ext2_inode *inode);
/* mmp.c */
errcode_t ext2fs_mmp_read(ext2_filsys fs, blk64_t mmp_blk, void *buf);
errcode_t ext2fs_mmp_write(ext2_filsys fs, blk64_t mmp_blk, void *buf);
errcode_t ext2fs_mmp_clear(ext2_filsys fs);
errcode_t ext2fs_mmp_init(ext2_filsys fs);
errcode_t ext2fs_mmp_start(ext2_filsys fs);
errcode_t ext2fs_mmp_update(ext2_filsys fs);
errcode_t ext2fs_mmp_update2(ext2_filsys fs, int immediately);
errcode_t ext2fs_mmp_stop(ext2_filsys fs);
unsigned ext2fs_mmp_new_seq(void);
/* read_bb.c */
extern errcode_t ext2fs_read_bb_inode(ext2_filsys fs,
ext2_badblocks_list *bb_list);
/* read_bb_file.c */
extern errcode_t ext2fs_read_bb_FILE2(ext2_filsys fs, FILE *f,
ext2_badblocks_list *bb_list,
void *priv_data,
void (*invalid)(ext2_filsys fs,
blk_t blk,
char *badstr,
void *priv_data));
extern errcode_t ext2fs_read_bb_FILE(ext2_filsys fs, FILE *f,
ext2_badblocks_list *bb_list,
void (*invalid)(ext2_filsys fs,
blk_t blk));
/* res_gdt.c */
extern errcode_t ext2fs_create_resize_inode(ext2_filsys fs);
/*sha256.c */
#define EXT2FS_SHA256_LENGTH 32
#if 0
extern void ext2fs_sha256(const unsigned char *in, unsigned long in_size,
unsigned char out[EXT2FS_SHA256_LENGTH]);
#endif
/* sha512.c */
#define EXT2FS_SHA512_LENGTH 64
extern void ext2fs_sha512(const unsigned char *in, unsigned long in_size,
unsigned char out[EXT2FS_SHA512_LENGTH]);
/* swapfs.c */
extern errcode_t ext2fs_dirent_swab_in2(ext2_filsys fs, char *buf, size_t size,
int flags);
extern errcode_t ext2fs_dirent_swab_in(ext2_filsys fs, char *buf, int flags);
extern errcode_t ext2fs_dirent_swab_out2(ext2_filsys fs, char *buf, size_t size,
int flags);
extern errcode_t ext2fs_dirent_swab_out(ext2_filsys fs, char *buf, int flags);
extern void ext2fs_swap_ext_attr(char *to, char *from, int bufsize,
int has_header);
extern void ext2fs_swap_ext_attr_header(struct ext2_ext_attr_header *to_header,
struct ext2_ext_attr_header *from_hdr);
extern void ext2fs_swap_ext_attr_entry(struct ext2_ext_attr_entry *to_entry,
struct ext2_ext_attr_entry *from_entry);
extern void ext2fs_swap_super(struct ext2_super_block * super);
extern void ext2fs_swap_group_desc(struct ext2_group_desc *gdp);
extern void ext2fs_swap_group_desc2(ext2_filsys, struct ext2_group_desc *gdp);
extern void ext2fs_swap_inode_full(ext2_filsys fs, struct ext2_inode_large *t,
struct ext2_inode_large *f, int hostorder,
int bufsize);
extern void ext2fs_swap_inode(ext2_filsys fs,struct ext2_inode *t,
struct ext2_inode *f, int hostorder);
extern void ext2fs_swap_mmp(struct mmp_struct *mmp);
/* unix_io.c */
extern int ext2fs_open_file(const char *pathname, int flags, mode_t mode);
extern int ext2fs_stat(const char *path, ext2fs_struct_stat *buf);
extern int ext2fs_fstat(int fd, ext2fs_struct_stat *buf);
/* valid_blk.c */
extern int ext2fs_inode_has_valid_blocks(struct ext2_inode *inode);
extern int ext2fs_inode_has_valid_blocks2(ext2_filsys fs,
struct ext2_inode *inode);
/* version.c */
extern int ext2fs_parse_version_string(const char *ver_string);
extern int ext2fs_get_library_version(const char **ver_string,
const char **date_string);
/* write_bb_file.c */
extern errcode_t ext2fs_write_bb_FILE(ext2_badblocks_list bb_list,
unsigned int flags,
FILE *f);
/* inline functions */
#ifdef NO_INLINE_FUNCS
extern errcode_t ext2fs_get_mem(unsigned long size, void *ptr);
extern errcode_t ext2fs_get_memzero(unsigned long size, void *ptr);
extern errcode_t ext2fs_get_array(unsigned long count,
unsigned long size, void *ptr);
extern errcode_t ext2fs_get_arrayzero(unsigned long count,
unsigned long size, void *ptr);
extern errcode_t ext2fs_free_mem(void *ptr);
extern errcode_t ext2fs_resize_mem(unsigned long old_size,
unsigned long size, void *ptr);
extern errcode_t ext2fs_resize_array(unsigned long old_count, unsigned long count,
unsigned long size, void *ptr);
extern void ext2fs_mark_super_dirty(ext2_filsys fs);
extern void ext2fs_mark_changed(ext2_filsys fs);
extern int ext2fs_test_changed(ext2_filsys fs);
extern void ext2fs_mark_valid(ext2_filsys fs);
extern void ext2fs_unmark_valid(ext2_filsys fs);
extern int ext2fs_test_valid(ext2_filsys fs);
extern void ext2fs_mark_ib_dirty(ext2_filsys fs);
extern void ext2fs_mark_bb_dirty(ext2_filsys fs);
extern int ext2fs_test_ib_dirty(ext2_filsys fs);
extern int ext2fs_test_bb_dirty(ext2_filsys fs);
extern dgrp_t ext2fs_group_of_blk(ext2_filsys fs, blk_t blk);
extern dgrp_t ext2fs_group_of_ino(ext2_filsys fs, ext2_ino_t ino);
extern blk_t ext2fs_group_first_block(ext2_filsys fs, dgrp_t group);
extern blk_t ext2fs_group_last_block(ext2_filsys fs, dgrp_t group);
extern blk_t ext2fs_inode_data_blocks(ext2_filsys fs,
struct ext2_inode *inode);
extern int ext2fs_htree_intnode_maxrecs(ext2_filsys fs, int blocks);
extern unsigned int ext2fs_div_ceil(unsigned int a, unsigned int b);
extern __u64 ext2fs_div64_ceil(__u64 a, __u64 b);
extern int ext2fs_dirent_name_len(const struct ext2_dir_entry *entry);
extern void ext2fs_dirent_set_name_len(struct ext2_dir_entry *entry, int len);
extern int ext2fs_dirent_file_type(const struct ext2_dir_entry *entry);
extern void ext2fs_dirent_set_file_type(struct ext2_dir_entry *entry, int type);
extern struct ext2_inode *ext2fs_inode(struct ext2_inode_large * large_inode);
extern const struct ext2_inode *ext2fs_const_inode(const struct ext2_inode_large * large_inode);
#endif
/*
* The actual inlined functions definitions themselves...
*
* If NO_INLINE_FUNCS is defined, then we won't try to do inline
* functions at all!
*/
#if (defined(INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS))
#ifdef INCLUDE_INLINE_FUNCS
#define _INLINE_ extern
#else
#if (__STDC_VERSION__ >= 199901L)
#define _INLINE_ inline
#else
#ifdef __GNUC__
#define _INLINE_ extern __inline__
#else /* For Watcom C */
#define _INLINE_ extern inline
#endif /* __GNUC__ */
#endif /* __STDC_VERSION__ >= 199901L */
#endif
#ifndef EXT2_CUSTOM_MEMORY_ROUTINES
#include <string.h>
/*
* Allocate memory. The 'ptr' arg must point to a pointer.
*/
_INLINE_ errcode_t ext2fs_get_mem(unsigned long size, void *ptr)
{
void *pp;
pp = malloc(size);
if (!pp)
return EXT2_ET_NO_MEMORY;
memcpy(ptr, &pp, sizeof (pp));
return 0;
}
_INLINE_ errcode_t ext2fs_get_memzero(unsigned long size, void *ptr)
{
void *pp;
pp = malloc(size);
if (!pp)
return EXT2_ET_NO_MEMORY;
memset(pp, 0, size);
memcpy(ptr, &pp, sizeof(pp));
return 0;
}
_INLINE_ errcode_t ext2fs_get_array(unsigned long count, unsigned long size,
void *ptr)
{
if (count && (~0UL)/count < size)
return EXT2_ET_NO_MEMORY;
return ext2fs_get_mem(count*size, ptr);
}
_INLINE_ errcode_t ext2fs_get_arrayzero(unsigned long count,
unsigned long size, void *ptr)
{
if (count && (~0UL)/count < size)
return EXT2_ET_NO_MEMORY;
return ext2fs_get_memzero((size_t)count * size, ptr);
}
/*
* Free memory. The 'ptr' arg must point to a pointer.
*/
_INLINE_ errcode_t ext2fs_free_mem(void *ptr)
{
void *p;
memcpy(&p, ptr, sizeof(p));
free(p);
p = 0;
memcpy(ptr, &p, sizeof(p));
return 0;
}
/*
* Resize memory. The 'ptr' arg must point to a pointer.
*/
_INLINE_ errcode_t ext2fs_resize_mem(unsigned long EXT2FS_ATTR((unused)) old_size,
unsigned long size, void *ptr)
{
void *p;
/* Use "memcpy" for pointer assignments here to avoid problems
* with C99 strict type aliasing rules. */
memcpy(&p, ptr, sizeof(p));
p = realloc(p, size);
if (!p)
return EXT2_ET_NO_MEMORY;
memcpy(ptr, &p, sizeof(p));
return 0;
}
/*
* Resize array. The 'ptr' arg must point to a pointer.
*/
_INLINE_ errcode_t ext2fs_resize_array(unsigned long size,
unsigned long old_count,
unsigned long count, void *ptr)
{
unsigned long old_size;
errcode_t retval;
if (count && (~0UL)/count < size)
return EXT2_ET_NO_MEMORY;
size *= count;
old_size = size * old_count;
retval = ext2fs_resize_mem(old_size, size, ptr);
if (retval)
return retval;
if (size > old_size) {
void *p;
memcpy(&p, ptr, sizeof(p));
memset((char *)p + old_size, 0, size - old_size);
memcpy(ptr, &p, sizeof(p));
}
return 0;
}
#endif /* Custom memory routines */
/*
* Mark a filesystem superblock as dirty
*/
_INLINE_ void ext2fs_mark_super_dirty(ext2_filsys fs)
{
fs->flags |= EXT2_FLAG_DIRTY | EXT2_FLAG_CHANGED;
}
/*
* Mark a filesystem as changed
*/
_INLINE_ void ext2fs_mark_changed(ext2_filsys fs)
{
fs->flags |= EXT2_FLAG_CHANGED;
}
/*
* Check to see if a filesystem has changed
*/
_INLINE_ int ext2fs_test_changed(ext2_filsys fs)
{
return (fs->flags & EXT2_FLAG_CHANGED);
}
/*
* Mark a filesystem as valid
*/
_INLINE_ void ext2fs_mark_valid(ext2_filsys fs)
{
fs->flags |= EXT2_FLAG_VALID;
}
/*
* Mark a filesystem as NOT valid
*/
_INLINE_ void ext2fs_unmark_valid(ext2_filsys fs)
{
fs->flags &= ~EXT2_FLAG_VALID;
}
/*
* Check to see if a filesystem is valid
*/
_INLINE_ int ext2fs_test_valid(ext2_filsys fs)
{
return (fs->flags & EXT2_FLAG_VALID);
}
/*
* Mark the inode bitmap as dirty
*/
_INLINE_ void ext2fs_mark_ib_dirty(ext2_filsys fs)
{
fs->flags |= EXT2_FLAG_IB_DIRTY | EXT2_FLAG_CHANGED;
}
/*
* Mark the block bitmap as dirty
*/
_INLINE_ void ext2fs_mark_bb_dirty(ext2_filsys fs)
{
fs->flags |= EXT2_FLAG_BB_DIRTY | EXT2_FLAG_CHANGED;
}
/*
* Check to see if a filesystem's inode bitmap is dirty
*/
_INLINE_ int ext2fs_test_ib_dirty(ext2_filsys fs)
{
return (fs->flags & EXT2_FLAG_IB_DIRTY);
}
/*
* Check to see if a filesystem's block bitmap is dirty
*/
_INLINE_ int ext2fs_test_bb_dirty(ext2_filsys fs)
{
return (fs->flags & EXT2_FLAG_BB_DIRTY);
}
/*
* Return the group # of a block
*/
_INLINE_ dgrp_t ext2fs_group_of_blk(ext2_filsys fs, blk_t blk)
{
return ext2fs_group_of_blk2(fs, blk);
}
/*
* Return the group # of an inode number
*/
_INLINE_ dgrp_t ext2fs_group_of_ino(ext2_filsys fs, ext2_ino_t ino)
{
return (ino - 1) / fs->super->s_inodes_per_group;
}
/*
* Return the first block (inclusive) in a group
*/
_INLINE_ blk_t ext2fs_group_first_block(ext2_filsys fs, dgrp_t group)
{
return (blk_t) ext2fs_group_first_block2(fs, group);
}
/*
* Return the last block (inclusive) in a group
*/
_INLINE_ blk_t ext2fs_group_last_block(ext2_filsys fs, dgrp_t group)
{
return (blk_t) ext2fs_group_last_block2(fs, group);
}
_INLINE_ blk_t ext2fs_inode_data_blocks(ext2_filsys fs,
struct ext2_inode *inode)
{
return (blk_t) ext2fs_inode_data_blocks2(fs, inode);
}
_INLINE_ int ext2fs_htree_intnode_maxrecs(ext2_filsys fs, int blocks)
{
int csum_size = 0;
if ((EXT2_SB(fs->super)->s_feature_ro_compat &
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) != 0)
csum_size = sizeof(struct ext2_dx_tail);
return blocks * ((fs->blocksize - (8 + csum_size)) /
sizeof(struct ext2_dx_entry));
}
/*
* This is an efficient, overflow safe way of calculating ceil((1.0 * a) / b)
*/
_INLINE_ unsigned int ext2fs_div_ceil(unsigned int a, unsigned int b)
{
if (!a)
return 0;
return ((a - 1) / b) + 1;
}
_INLINE_ __u64 ext2fs_div64_ceil(__u64 a, __u64 b)
{
if (!a)
return 0;
return ((a - 1) / b) + 1;
}
_INLINE_ int ext2fs_dirent_name_len(const struct ext2_dir_entry *entry)
{
return entry->name_len & 0xff;
}
_INLINE_ void ext2fs_dirent_set_name_len(struct ext2_dir_entry *entry, int len)
{
entry->name_len = (entry->name_len & 0xff00) | (len & 0xff);
}
_INLINE_ int ext2fs_dirent_file_type(const struct ext2_dir_entry *entry)
{
return entry->name_len >> 8;
}
_INLINE_ void ext2fs_dirent_set_file_type(struct ext2_dir_entry *entry, int type)
{
entry->name_len = (entry->name_len & 0xff) | (type << 8);
}
_INLINE_ struct ext2_inode *ext2fs_inode(struct ext2_inode_large * large_inode)
{
/* It is always safe to convert large inode to a small inode */
return (struct ext2_inode *) large_inode;
}
_INLINE_ const struct ext2_inode *
ext2fs_const_inode(const struct ext2_inode_large * large_inode)
{
/* It is always safe to convert large inode to a small inode */
return (const struct ext2_inode *) large_inode;
}
#undef _INLINE_
#endif
/* htree levels for ext4 */
#define EXT4_HTREE_LEVEL_COMPAT 2
#define EXT4_HTREE_LEVEL 3
static inline unsigned int ext2_dir_htree_level(ext2_filsys fs)
{
if (ext2fs_has_feature_largedir(fs->super))
return EXT4_HTREE_LEVEL;
return EXT4_HTREE_LEVEL_COMPAT;
}
#ifdef __cplusplus
}
#endif
#endif /* _EXT2FS_EXT2FS_H */
ext2fs/ext2_types.h 0000644 00000002337 15201526705 0010246 0 ustar 00 /*
* Kluge to support multilib installation of both 32- and 64-bit RPMS:
* we need to arrange that header files that appear in both RPMs are
* identical. Hence, this file is architecture-independent and calls
* in an arch-dependent file that will appear in just one RPM.
*
* To avoid breaking arches not explicitly supported by Red Hat, we
* use this indirection file *only* on known multilib arches.
*
* We pay attention to include _only_ the original multilib-unclean
* header file. Including any other system-header file could cause
* unpredictable include-ordering issues (rhbz#1412274, comment #16).
*
* Note: this may well fail if user tries to use gcc's -I- option.
* But that option is deprecated anyway.
*/
#if defined(__x86_64__)
#include "ext2_types-x86_64.h"
#elif defined(__i386__)
#include "ext2_types-i386.h"
#elif defined(__ppc64__) || defined(__powerpc64__)
#include "ext2_types-ppc64.h"
#elif defined(__ppc__) || defined(__powerpc__)
#include "ext2_types-ppc.h"
#elif defined(__s390x__)
#include "ext2_types-s390x.h"
#elif defined(__s390__)
#include "ext2_types-s390.h"
#elif defined(__sparc__) && defined(__arch64__)
#include "ext2_types-sparc64.h"
#elif defined(__sparc__)
#include "ext2_types-sparc.h"
#endif
ext2fs/tdb.h 0000644 00000021247 15201526705 0006712 0 ustar 00 #ifndef __TDB_H__
#define __TDB_H__
/*
Unix SMB/CIFS implementation.
trivial database library
Copyright (C) Andrew Tridgell 1999-2004
** NOTE! The following LGPL license applies to the tdb
** library. This does NOT imply that all of Samba is released
** under the LGPL
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifdef __cplusplus
extern "C" {
#endif
/* flags to tdb_store() */
#define TDB_REPLACE 1
#define TDB_INSERT 2
#define TDB_MODIFY 3
/* flags for tdb_open() */
#define TDB_DEFAULT 0 /* just a readability place holder */
#define TDB_CLEAR_IF_FIRST 1
#define TDB_INTERNAL 2 /* don't store on disk */
#define TDB_NOLOCK 4 /* don't do any locking */
#define TDB_NOMMAP 8 /* don't use mmap */
#define TDB_CONVERT 16 /* convert endian (internal use) */
#define TDB_BIGENDIAN 32 /* header is big-endian (internal use) */
#define TDB_NOSYNC 64 /* don't use synchronous transactions */
#define TDB_SEQNUM 128 /* maintain a sequence number */
#define TDB_ERRCODE(code, ret) ((tdb->ecode = (code)), ret)
/* error codes */
enum TDB_ERROR {TDB_SUCCESS=0, TDB_ERR_CORRUPT, TDB_ERR_IO, TDB_ERR_LOCK,
TDB_ERR_OOM, TDB_ERR_EXISTS, TDB_ERR_NOLOCK, TDB_ERR_LOCK_TIMEOUT,
TDB_ERR_NOEXIST, TDB_ERR_EINVAL, TDB_ERR_RDONLY};
/* debugging uses one of the following levels */
enum tdb_debug_level {TDB_DEBUG_FATAL = 0, TDB_DEBUG_ERROR,
TDB_DEBUG_WARNING, TDB_DEBUG_TRACE};
typedef struct TDB_DATA {
unsigned char *dptr;
size_t dsize;
} TDB_DATA;
#ifndef PRINTF_ATTRIBUTE
#if (__GNUC__ >= 3)
/** Use gcc attribute to check printf fns. a1 is the 1-based index of
* the parameter containing the format, and a2 the index of the first
* argument. Note that some gcc 2.x versions don't handle this
* properly **/
#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
#else
#define PRINTF_ATTRIBUTE(a1, a2)
#endif
#endif
/* ext2fs tdb renames */
#define tdb_open ext2fs_tdb_open
#define tdb_open_ex ext2fs_tdb_open_ex
#define tdb_set_max_dead ext2fs_tdb_set_max_dead
#define tdb_reopen ext2fs_tdb_reopen
#define tdb_reopen_all ext2fs_tdb_reopen_all
#define tdb_set_logging_function ext2fs_tdb_set_logging_function
#define tdb_error ext2fs_tdb_error
#define tdb_errorstr ext2fs_tdb_errorstr
#define tdb_fetch ext2fs_tdb_fetch
#define tdb_parse_record ext2fs_tdb_parse_record
#define tdb_delete ext2fs_tdb_delete
#define tdb_store ext2fs_tdb_store
#define tdb_append ext2fs_tdb_append
#define tdb_close ext2fs_tdb_close
#define tdb_firstkey ext2fs_tdb_firstkey
#define tdb_nextkey ext2fs_tdb_nextkey
#define tdb_traverse ext2fs_tdb_traverse
#define tdb_traverse_read ext2fs_tdb_traverse_read
#define tdb_exists ext2fs_tdb_exists
#define tdb_lockall ext2fs_tdb_lockall
#define tdb_unlockall ext2fs_tdb_unlockall
#define tdb_lockall_read ext2fs_tdb_lockall_read
#define tdb_unlockall_read ext2fs_tdb_unlockall_read
#define tdb_name ext2fs_tdb_name
#define tdb_fd ext2fs_tdb_fd
#define tdb_log_fn ext2fs_tdb_log_fn
#define tdb_get_logging_private ext2fs_tdb_get_logging_private
#define tdb_transaction_start ext2fs_tdb_transaction_start
#define tdb_transaction_commit ext2fs_tdb_transaction_commit
#define tdb_transaction_cancel ext2fs_tdb_transaction_cancel
#define tdb_transaction_recover ext2fs_tdb_transaction_recover
#define tdb_get_seqnum ext2fs_tdb_get_seqnum
#define tdb_hash_size ext2fs_tdb_hash_size
#define tdb_map_size ext2fs_tdb_map_size
#define tdb_get_flags ext2fs_tdb_get_flags
#define tdb_chainlock ext2fs_tdb_chainlock
#define tdb_chainunlock ext2fs_tdb_chainunlock
#define tdb_chainlock_read ext2fs_tdb_chainlock_read
#define tdb_chainunlock_read ext2fs_tdb_chainunlock_read
#define tdb_dump_all ext2fs_tdb_dump_all
#define tdb_printfreelist ext2fs_tdb_printfreelist
#define tdb_validate_freelist ext2fs_tdb_validate_freelist
#define tdb_chainlock_mark ext2fs_tdb_chainlock_mark
#define tdb_chainlock_nonblock ext2fs_tdb_chainlock_nonblock
#define tdb_chainlock_unmark ext2fs_tdb_chainlock_unmark
#define tdb_enable_seqnum ext2fs_tdb_enable_seqnum
#define tdb_increment_seqnum_nonblock ext2fs_tdb_increment_seqnum_nonblock
#define tdb_lock_nonblock ext2fs_tdb_lock_nonblock
#define tdb_lockall_mark ext2fs_tdb_lockall_mark
#define tdb_lockall_nonblock ext2fs_tdb_lockall_nonblock
#define tdb_lockall_read_nonblock ext2fs_tdb_lockall_read_nonblock
#define tdb_lockall_unmark ext2fs_tdb_lockall_unmark
#define tdb_flush ext2fs_tdb_flush
/* this is the context structure that is returned from a db open */
typedef struct tdb_context TDB_CONTEXT;
typedef int (*tdb_traverse_func)(struct tdb_context *, TDB_DATA, TDB_DATA, void *);
typedef void (*tdb_log_func)(struct tdb_context *, enum tdb_debug_level, const char *, ...) PRINTF_ATTRIBUTE(3, 4);
typedef unsigned int (*tdb_hash_func)(TDB_DATA *key);
struct tdb_logging_context {
tdb_log_func log_fn;
void *log_private;
};
struct tdb_context *tdb_open(const char *name, int hash_size, int tdb_flags,
int open_flags, mode_t mode);
struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
int open_flags, mode_t mode,
const struct tdb_logging_context *log_ctx,
tdb_hash_func hash_fn);
void tdb_set_max_dead(struct tdb_context *tdb, int max_dead);
int tdb_reopen(struct tdb_context *tdb);
int tdb_reopen_all(int parent_longlived);
void tdb_set_logging_function(struct tdb_context *tdb, const struct tdb_logging_context *log_ctx);
enum TDB_ERROR tdb_error(struct tdb_context *tdb);
const char *tdb_errorstr(struct tdb_context *tdb);
TDB_DATA tdb_fetch(struct tdb_context *tdb, TDB_DATA key);
int tdb_parse_record(struct tdb_context *tdb, TDB_DATA key,
int (*parser)(TDB_DATA key, TDB_DATA data,
void *private_data),
void *private_data);
int tdb_delete(struct tdb_context *tdb, TDB_DATA key);
int tdb_store(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf, int flag);
int tdb_append(struct tdb_context *tdb, TDB_DATA key, TDB_DATA new_dbuf);
int tdb_close(struct tdb_context *tdb);
TDB_DATA tdb_firstkey(struct tdb_context *tdb);
TDB_DATA tdb_nextkey(struct tdb_context *tdb, TDB_DATA key);
int tdb_traverse(struct tdb_context *tdb, tdb_traverse_func fn, void *);
int tdb_traverse_read(struct tdb_context *tdb, tdb_traverse_func fn, void *);
int tdb_exists(struct tdb_context *tdb, TDB_DATA key);
int tdb_lockall(struct tdb_context *tdb);
int tdb_lockall_nonblock(struct tdb_context *tdb);
int tdb_unlockall(struct tdb_context *tdb);
int tdb_lockall_read(struct tdb_context *tdb);
int tdb_lockall_read_nonblock(struct tdb_context *tdb);
int tdb_unlockall_read(struct tdb_context *tdb);
int tdb_lockall_mark(struct tdb_context *tdb);
int tdb_lockall_unmark(struct tdb_context *tdb);
const char *tdb_name(struct tdb_context *tdb);
int tdb_fd(struct tdb_context *tdb);
tdb_log_func tdb_log_fn(struct tdb_context *tdb);
void *tdb_get_logging_private(struct tdb_context *tdb);
int tdb_transaction_start(struct tdb_context *tdb);
int tdb_transaction_commit(struct tdb_context *tdb);
int tdb_transaction_cancel(struct tdb_context *tdb);
int tdb_transaction_recover(struct tdb_context *tdb);
int tdb_get_seqnum(struct tdb_context *tdb);
int tdb_hash_size(struct tdb_context *tdb);
size_t tdb_map_size(struct tdb_context *tdb);
int tdb_get_flags(struct tdb_context *tdb);
void tdb_enable_seqnum(struct tdb_context *tdb);
void tdb_increment_seqnum_nonblock(struct tdb_context *tdb);
int tdb_flush(struct tdb_context *tdb);
/* Low level locking functions: use with care */
int tdb_chainlock(struct tdb_context *tdb, TDB_DATA key);
int tdb_chainlock_nonblock(struct tdb_context *tdb, TDB_DATA key);
int tdb_chainunlock(struct tdb_context *tdb, TDB_DATA key);
int tdb_chainlock_read(struct tdb_context *tdb, TDB_DATA key);
int tdb_chainunlock_read(struct tdb_context *tdb, TDB_DATA key);
int tdb_chainlock_mark(struct tdb_context *tdb, TDB_DATA key);
int tdb_chainlock_unmark(struct tdb_context *tdb, TDB_DATA key);
/* Debug functions. Not used in production. */
void tdb_dump_all(struct tdb_context *tdb);
int tdb_printfreelist(struct tdb_context *tdb);
int tdb_validate_freelist(struct tdb_context *tdb, int *pnum_entries);
#ifdef __cplusplus
}
#endif
#endif /* tdb.h */
ext2fs/ext2_ext_attr.h 0000644 00000005124 15201526705 0010731 0 ustar 00 /*
File: linux/ext2_ext_attr.h
On-disk format of extended attributes for the ext2 filesystem.
(C) 2000 Andreas Gruenbacher, <a.gruenbacher@computer.org>
*/
#ifndef _EXT2_EXT_ATTR_H
#define _EXT2_EXT_ATTR_H
/* Magic value in attribute blocks */
#define EXT2_EXT_ATTR_MAGIC_v1 0xEA010000
#define EXT2_EXT_ATTR_MAGIC 0xEA020000
/* Maximum number of references to one attribute block */
#define EXT2_EXT_ATTR_REFCOUNT_MAX 1024
struct ext2_ext_attr_header {
__u32 h_magic; /* magic number for identification */
__u32 h_refcount; /* reference count */
__u32 h_blocks; /* number of disk blocks used */
__u32 h_hash; /* hash value of all attributes */
__u32 h_checksum; /* crc32c(uuid+id+xattrs) */
/* id = inum if refcount = 1, else blknum */
__u32 h_reserved[3]; /* zero right now */
};
struct ext2_ext_attr_entry {
__u8 e_name_len; /* length of name */
__u8 e_name_index; /* attribute name index */
__u16 e_value_offs; /* offset in disk block of value */
__u32 e_value_inum; /* inode in which the value is stored */
__u32 e_value_size; /* size of attribute value */
__u32 e_hash; /* hash value of name and value */
#if 0
char e_name[0]; /* attribute name */
#endif
};
#define EXT2_EXT_ATTR_PAD_BITS 2
#define EXT2_EXT_ATTR_PAD ((unsigned) 1<<EXT2_EXT_ATTR_PAD_BITS)
#define EXT2_EXT_ATTR_ROUND (EXT2_EXT_ATTR_PAD-1)
#define EXT2_EXT_ATTR_LEN(name_len) \
(((name_len) + EXT2_EXT_ATTR_ROUND + \
sizeof(struct ext2_ext_attr_entry)) & ~EXT2_EXT_ATTR_ROUND)
#define EXT2_EXT_ATTR_NEXT(entry) \
( (struct ext2_ext_attr_entry *)( \
(char *)(entry) + EXT2_EXT_ATTR_LEN((entry)->e_name_len)) )
#define EXT2_EXT_ATTR_SIZE(size) \
(((size) + EXT2_EXT_ATTR_ROUND) & ~EXT2_EXT_ATTR_ROUND)
#define EXT2_EXT_IS_LAST_ENTRY(entry) (*((__u32 *)(entry)) == 0UL)
#define EXT2_EXT_ATTR_NAME(entry) \
(((char *) (entry)) + sizeof(struct ext2_ext_attr_entry))
#define EXT2_XATTR_LEN(name_len) \
(((name_len) + EXT2_EXT_ATTR_ROUND + \
sizeof(struct ext2_xattr_entry)) & ~EXT2_EXT_ATTR_ROUND)
#define EXT2_XATTR_SIZE(size) \
(((size) + EXT2_EXT_ATTR_ROUND) & ~EXT2_EXT_ATTR_ROUND)
#ifdef __KERNEL__
# ifdef CONFIG_EXT2_FS_EXT_ATTR
extern int ext2_get_ext_attr(struct inode *, const char *, char *, size_t, int);
extern int ext2_set_ext_attr(struct inode *, const char *, char *, size_t, int);
extern void ext2_ext_attr_free_inode(struct inode *inode);
extern void ext2_ext_attr_put_super(struct super_block *sb);
extern int ext2_ext_attr_init(void);
extern void ext2_ext_attr_done(void);
# else
# define ext2_get_ext_attr NULL
# define ext2_set_ext_attr NULL
# endif
#endif /* __KERNEL__ */
#endif /* _EXT2_EXT_ATTR_H */
ext2fs/ext2_fs.h 0000644 00000122133 15201526705 0007507 0 ustar 00 /*
* linux/include/linux/ext2_fs.h
*
* Copyright (C) 1992, 1993, 1994, 1995
* Remy Card (card@masi.ibp.fr)
* Laboratoire MASI - Institut Blaise Pascal
* Universite Pierre et Marie Curie (Paris VI)
*
* from
*
* linux/include/linux/minix_fs.h
*
* Copyright (C) 1991, 1992 Linus Torvalds
*/
#ifndef _LINUX_EXT2_FS_H
#define _LINUX_EXT2_FS_H
#include <ext2fs/ext2_types.h> /* Changed from linux/types.h */
#ifndef __GNUC_PREREQ
#if defined(__GNUC__) && defined(__GNUC_MINOR__)
#define __GNUC_PREREQ(maj, min) \
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
#else
#define __GNUC_PREREQ(maj, min) 0
#endif
#endif
/*
* The second extended filesystem constants/structures
*/
/*
* Define EXT2FS_DEBUG to produce debug messages
*/
#undef EXT2FS_DEBUG
/*
* Define EXT2_PREALLOCATE to preallocate data blocks for expanding files
*/
#define EXT2_PREALLOCATE
#define EXT2_DEFAULT_PREALLOC_BLOCKS 8
/*
* The second extended file system version
*/
#define EXT2FS_DATE "95/08/09"
#define EXT2FS_VERSION "0.5b"
/*
* Special inode numbers
*/
#define EXT2_BAD_INO 1 /* Bad blocks inode */
#define EXT2_ROOT_INO 2 /* Root inode */
#define EXT4_USR_QUOTA_INO 3 /* User quota inode */
#define EXT4_GRP_QUOTA_INO 4 /* Group quota inode */
#define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */
#define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */
#define EXT2_RESIZE_INO 7 /* Reserved group descriptors inode */
#define EXT2_JOURNAL_INO 8 /* Journal inode */
#define EXT2_EXCLUDE_INO 9 /* The "exclude" inode, for snapshots */
#define EXT4_REPLICA_INO 10 /* Used by non-upstream feature */
/* First non-reserved inode for old ext2 filesystems */
#define EXT2_GOOD_OLD_FIRST_INO 11
/*
* The second extended file system magic number
*/
#define EXT2_SUPER_MAGIC 0xEF53
#ifdef __KERNEL__
#define EXT2_SB(sb) (&((sb)->u.ext2_sb))
#else
/* Assume that user mode programs are passing in an ext2fs superblock, not
* a kernel struct super_block. This will allow us to call the feature-test
* macros from user land. */
#define EXT2_SB(sb) (sb)
#endif
/*
* Maximal count of links to a file
*/
#define EXT2_LINK_MAX 65000
/*
* Macro-instructions used to manage several block sizes
*/
#define EXT2_MIN_BLOCK_LOG_SIZE 10 /* 1024 */
#define EXT2_MAX_BLOCK_LOG_SIZE 16 /* 65536 */
#define EXT2_MIN_BLOCK_SIZE (1 << EXT2_MIN_BLOCK_LOG_SIZE)
#define EXT2_MAX_BLOCK_SIZE (1 << EXT2_MAX_BLOCK_LOG_SIZE)
#ifdef __KERNEL__
#define EXT2_BLOCK_SIZE(s) ((s)->s_blocksize)
#define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
#define EXT2_ADDR_PER_BLOCK_BITS(s) (EXT2_SB(s)->addr_per_block_bits)
#define EXT2_INODE_SIZE(s) (EXT2_SB(s)->s_inode_size)
#define EXT2_FIRST_INO(s) (EXT2_SB(s)->s_first_ino)
#else
#define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
#define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
#define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
EXT2_GOOD_OLD_INODE_SIZE : (s)->s_inode_size)
#define EXT2_FIRST_INO(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
EXT2_GOOD_OLD_FIRST_INO : (s)->s_first_ino)
#endif
#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof(__u32))
/*
* Macro-instructions used to manage allocation clusters
*/
#define EXT2_MIN_CLUSTER_LOG_SIZE EXT2_MIN_BLOCK_LOG_SIZE
#define EXT2_MAX_CLUSTER_LOG_SIZE 29 /* 512MB */
#define EXT2_MIN_CLUSTER_SIZE EXT2_MIN_BLOCK_SIZE
#define EXT2_MAX_CLUSTER_SIZE (1 << EXT2_MAX_CLUSTER_LOG_SIZE)
#define EXT2_CLUSTER_SIZE(s) (EXT2_MIN_BLOCK_SIZE << \
(s)->s_log_cluster_size)
#define EXT2_CLUSTER_SIZE_BITS(s) ((s)->s_log_cluster_size + 10)
/*
* Macro-instructions used to manage fragments
*
* Note: for backwards compatibility only, for the dump program.
* Ext2/3/4 will never support fragments....
*/
#define EXT2_MIN_FRAG_SIZE EXT2_MIN_BLOCK_SIZE
#define EXT2_MAX_FRAG_SIZE EXT2_MAX_BLOCK_SIZE
#define EXT2_MIN_FRAG_LOG_SIZE EXT2_MIN_BLOCK_LOG_SIZE
#define EXT2_FRAG_SIZE(s) EXT2_BLOCK_SIZE(s)
#define EXT2_FRAGS_PER_BLOCK(s) 1
/*
* ACL structures
*/
struct ext2_acl_header /* Header of Access Control Lists */
{
__u32 aclh_size;
__u32 aclh_file_count;
__u32 aclh_acle_count;
__u32 aclh_first_acle;
};
struct ext2_acl_entry /* Access Control List Entry */
{
__u32 acle_size;
__u16 acle_perms; /* Access permissions */
__u16 acle_type; /* Type of entry */
__u16 acle_tag; /* User or group identity */
__u16 acle_pad1;
__u32 acle_next; /* Pointer on next entry for the */
/* same inode or on next free entry */
};
/*
* Structure of a blocks group descriptor
*/
struct ext2_group_desc
{
__u32 bg_block_bitmap; /* Blocks bitmap block */
__u32 bg_inode_bitmap; /* Inodes bitmap block */
__u32 bg_inode_table; /* Inodes table block */
__u16 bg_free_blocks_count; /* Free blocks count */
__u16 bg_free_inodes_count; /* Free inodes count */
__u16 bg_used_dirs_count; /* Directories count */
__u16 bg_flags;
__u32 bg_exclude_bitmap_lo; /* Exclude bitmap for snapshots */
__u16 bg_block_bitmap_csum_lo;/* crc32c(s_uuid+grp_num+bitmap) LSB */
__u16 bg_inode_bitmap_csum_lo;/* crc32c(s_uuid+grp_num+bitmap) LSB */
__u16 bg_itable_unused; /* Unused inodes count */
__u16 bg_checksum; /* crc16(s_uuid+group_num+group_desc)*/
};
/*
* Structure of a blocks group descriptor
*/
struct ext4_group_desc
{
__u32 bg_block_bitmap; /* Blocks bitmap block */
__u32 bg_inode_bitmap; /* Inodes bitmap block */
__u32 bg_inode_table; /* Inodes table block */
__u16 bg_free_blocks_count; /* Free blocks count */
__u16 bg_free_inodes_count; /* Free inodes count */
__u16 bg_used_dirs_count; /* Directories count */
__u16 bg_flags; /* EXT4_BG_flags (INODE_UNINIT, etc) */
__u32 bg_exclude_bitmap_lo; /* Exclude bitmap for snapshots */
__u16 bg_block_bitmap_csum_lo;/* crc32c(s_uuid+grp_num+bitmap) LSB */
__u16 bg_inode_bitmap_csum_lo;/* crc32c(s_uuid+grp_num+bitmap) LSB */
__u16 bg_itable_unused; /* Unused inodes count */
__u16 bg_checksum; /* crc16(sb_uuid+group+desc) */
__u32 bg_block_bitmap_hi; /* Blocks bitmap block MSB */
__u32 bg_inode_bitmap_hi; /* Inodes bitmap block MSB */
__u32 bg_inode_table_hi; /* Inodes table block MSB */
__u16 bg_free_blocks_count_hi;/* Free blocks count MSB */
__u16 bg_free_inodes_count_hi;/* Free inodes count MSB */
__u16 bg_used_dirs_count_hi; /* Directories count MSB */
__u16 bg_itable_unused_hi; /* Unused inodes count MSB */
__u32 bg_exclude_bitmap_hi; /* Exclude bitmap block MSB */
__u16 bg_block_bitmap_csum_hi;/* crc32c(s_uuid+grp_num+bitmap) MSB */
__u16 bg_inode_bitmap_csum_hi;/* crc32c(s_uuid+grp_num+bitmap) MSB */
__u32 bg_reserved;
};
#define EXT4_BG_INODE_BITMAP_CSUM_HI_END \
(offsetof(struct ext4_group_desc, bg_inode_bitmap_csum_hi) + \
sizeof(__u16))
#define EXT4_BG_BLOCK_BITMAP_CSUM_HI_LOCATION \
(offsetof(struct ext4_group_desc, bg_block_bitmap_csum_hi) + \
sizeof(__u16))
#define EXT2_BG_INODE_UNINIT 0x0001 /* Inode table/bitmap not initialized */
#define EXT2_BG_BLOCK_UNINIT 0x0002 /* Block bitmap not initialized */
#define EXT2_BG_INODE_ZEROED 0x0004 /* On-disk itable initialized to zero */
/*
* Data structures used by the directory indexing feature
*
* Note: all of the multibyte integer fields are little endian.
*/
/*
* Note: dx_root_info is laid out so that if it should somehow get
* overlaid by a dirent the two low bits of the hash version will be
* zero. Therefore, the hash version mod 4 should never be 0.
* Sincerely, the paranoia department.
*/
struct ext2_dx_root_info {
__u32 reserved_zero;
__u8 hash_version; /* 0 now, 1 at release */
__u8 info_length; /* 8 */
__u8 indirect_levels;
__u8 unused_flags;
};
#define EXT2_HASH_LEGACY 0
#define EXT2_HASH_HALF_MD4 1
#define EXT2_HASH_TEA 2
#define EXT2_HASH_LEGACY_UNSIGNED 3 /* reserved for userspace lib */
#define EXT2_HASH_HALF_MD4_UNSIGNED 4 /* reserved for userspace lib */
#define EXT2_HASH_TEA_UNSIGNED 5 /* reserved for userspace lib */
#define EXT2_HASH_FLAG_INCOMPAT 0x1
#define EXT4_DX_BLOCK_MASK 0x0fffffff
struct ext2_dx_entry {
__le32 hash;
__le32 block;
};
struct ext2_dx_countlimit {
__le16 limit;
__le16 count;
};
/*
* This goes at the end of each htree block.
*/
struct ext2_dx_tail {
__le32 dt_reserved;
__le32 dt_checksum; /* crc32c(uuid+inum+dxblock) */
};
/*
* Macro-instructions used to manage group descriptors
*/
#define EXT2_MIN_DESC_SIZE 32
#define EXT2_MIN_DESC_SIZE_64BIT 64
#define EXT2_MAX_DESC_SIZE EXT2_MIN_BLOCK_SIZE
#define EXT2_DESC_SIZE(s) \
((EXT2_SB(s)->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT) ? \
(s)->s_desc_size : EXT2_MIN_DESC_SIZE)
#define EXT2_BLOCKS_PER_GROUP(s) (EXT2_SB(s)->s_blocks_per_group)
#define EXT2_INODES_PER_GROUP(s) (EXT2_SB(s)->s_inodes_per_group)
#define EXT2_CLUSTERS_PER_GROUP(s) (EXT2_SB(s)->s_clusters_per_group)
#define EXT2_INODES_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s)/EXT2_INODE_SIZE(s))
/* limits imposed by 16-bit value gd_free_{blocks,inode}_count */
#define EXT2_MAX_BLOCKS_PER_GROUP(s) ((((unsigned) 1 << 16) - 8) * \
(EXT2_CLUSTER_SIZE(s) / \
EXT2_BLOCK_SIZE(s)))
#define EXT2_MAX_CLUSTERS_PER_GROUP(s) (((unsigned) 1 << 16) - 8)
#define EXT2_MAX_INODES_PER_GROUP(s) (((unsigned) 1 << 16) - \
EXT2_INODES_PER_BLOCK(s))
#ifdef __KERNEL__
#define EXT2_DESC_PER_BLOCK(s) (EXT2_SB(s)->s_desc_per_block)
#define EXT2_DESC_PER_BLOCK_BITS(s) (EXT2_SB(s)->s_desc_per_block_bits)
#else
#define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_DESC_SIZE(s))
#endif
#define EXT2_GROUPS_TO_BLOCKS(s, g) ((blk64_t) EXT2_BLOCKS_PER_GROUP(s) * \
(g))
#define EXT2_GROUPS_TO_CLUSTERS(s, g) ((blk64_t) EXT2_CLUSTERS_PER_GROUP(s) * \
(g))
/*
* Constants relative to the data blocks
*/
#define EXT2_NDIR_BLOCKS 12
#define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS
#define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1)
#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1)
#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1)
/*
* Inode flags
*/
#define EXT2_SECRM_FL 0x00000001 /* Secure deletion */
#define EXT2_UNRM_FL 0x00000002 /* Undelete */
#define EXT2_COMPR_FL 0x00000004 /* Compress file */
#define EXT2_SYNC_FL 0x00000008 /* Synchronous updates */
#define EXT2_IMMUTABLE_FL 0x00000010 /* Immutable file */
#define EXT2_APPEND_FL 0x00000020 /* writes to file may only append */
#define EXT2_NODUMP_FL 0x00000040 /* do not dump file */
#define EXT2_NOATIME_FL 0x00000080 /* do not update atime */
/* Reserved for compression usage... */
#define EXT2_DIRTY_FL 0x00000100
#define EXT2_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */
#define EXT2_NOCOMPR_FL 0x00000400 /* Access raw compressed data */
/* nb: was previously EXT2_ECOMPR_FL */
#define EXT4_ENCRYPT_FL 0x00000800 /* encrypted inode */
/* End compression flags --- maybe not all used */
#define EXT2_BTREE_FL 0x00001000 /* btree format dir */
#define EXT2_INDEX_FL 0x00001000 /* hash-indexed directory */
#define EXT2_IMAGIC_FL 0x00002000
#define EXT3_JOURNAL_DATA_FL 0x00004000 /* file data should be journaled */
#define EXT2_NOTAIL_FL 0x00008000 /* file tail should not be merged */
#define EXT2_DIRSYNC_FL 0x00010000 /* Synchronous directory modifications */
#define EXT2_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
#define EXT4_HUGE_FILE_FL 0x00040000 /* Set to each huge file */
#define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
#define EXT4_VERITY_FL 0x00100000 /* Verity protected inode */
#define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */
/* EXT4_EOFBLOCKS_FL 0x00400000 was here */
#define FS_NOCOW_FL 0x00800000 /* Do not cow file */
#define EXT4_SNAPFILE_FL 0x01000000 /* Inode is a snapshot */
#define EXT4_SNAPFILE_DELETED_FL 0x04000000 /* Snapshot is being deleted */
#define EXT4_SNAPFILE_SHRUNK_FL 0x08000000 /* Snapshot shrink has completed */
#define EXT4_INLINE_DATA_FL 0x10000000 /* Inode has inline data */
#define EXT4_PROJINHERIT_FL 0x20000000 /* Create with parents projid */
#define EXT4_CASEFOLD_FL 0x40000000 /* Casefolded file */
#define EXT2_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
#define EXT2_FL_USER_VISIBLE 0x604BDFFF /* User visible flags */
#define EXT2_FL_USER_MODIFIABLE 0x604B80FF /* User modifiable flags */
/*
* ioctl commands
*/
/* Used for online resize */
struct ext2_new_group_input {
__u32 group; /* Group number for this data */
__u32 block_bitmap; /* Absolute block number of block bitmap */
__u32 inode_bitmap; /* Absolute block number of inode bitmap */
__u32 inode_table; /* Absolute block number of inode table start */
__u32 blocks_count; /* Total number of blocks in this group */
__u16 reserved_blocks; /* Number of reserved blocks in this group */
__u16 unused; /* Number of reserved GDT blocks in group */
};
struct ext4_new_group_input {
__u32 group; /* Group number for this data */
__u64 block_bitmap; /* Absolute block number of block bitmap */
__u64 inode_bitmap; /* Absolute block number of inode bitmap */
__u64 inode_table; /* Absolute block number of inode table start */
__u32 blocks_count; /* Total number of blocks in this group */
__u16 reserved_blocks; /* Number of reserved blocks in this group */
__u16 unused;
};
#ifdef __GNU__ /* Needed for the Hurd */
#define _IOT_ext2_new_group_input _IOT (_IOTS(__u32), 5, _IOTS(__u16), 2, 0, 0)
#endif
#define EXT2_IOC_GETFLAGS _IOR('f', 1, long)
#define EXT2_IOC_SETFLAGS _IOW('f', 2, long)
#define EXT2_IOC_GETVERSION _IOR('v', 1, long)
#define EXT2_IOC_SETVERSION _IOW('v', 2, long)
#define EXT2_IOC_GETVERSION_NEW _IOR('f', 3, long)
#define EXT2_IOC_SETVERSION_NEW _IOW('f', 4, long)
#define EXT2_IOC_GROUP_EXTEND _IOW('f', 7, unsigned long)
#define EXT2_IOC_GROUP_ADD _IOW('f', 8,struct ext2_new_group_input)
#define EXT4_IOC_GROUP_ADD _IOW('f', 8,struct ext4_new_group_input)
#define EXT4_IOC_RESIZE_FS _IOW('f', 16, __u64)
/*
* Structure of an inode on the disk
*/
struct ext2_inode {
/*00*/ __u16 i_mode; /* File mode */
__u16 i_uid; /* Low 16 bits of Owner Uid */
__u32 i_size; /* Size in bytes */
__u32 i_atime; /* Access time */
__u32 i_ctime; /* Inode change time */
/*10*/ __u32 i_mtime; /* Modification time */
__u32 i_dtime; /* Deletion Time */
__u16 i_gid; /* Low 16 bits of Group Id */
__u16 i_links_count; /* Links count */
__u32 i_blocks; /* Blocks count */
/*20*/ __u32 i_flags; /* File flags */
union {
struct {
__u32 l_i_version; /* was l_i_reserved1 */
} linux1;
struct {
__u32 h_i_translator;
} hurd1;
} osd1; /* OS dependent 1 */
/*28*/ __u32 i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
/*64*/ __u32 i_generation; /* File version (for NFS) */
__u32 i_file_acl; /* File ACL */
__u32 i_size_high;
/*70*/ __u32 i_faddr; /* Fragment address */
union {
struct {
__u16 l_i_blocks_hi;
__u16 l_i_file_acl_high;
__u16 l_i_uid_high; /* these 2 fields */
__u16 l_i_gid_high; /* were reserved2[0] */
__u16 l_i_checksum_lo; /* crc32c(uuid+inum+inode) */
__u16 l_i_reserved;
} linux2;
struct {
__u8 h_i_frag; /* Fragment number */
__u8 h_i_fsize; /* Fragment size */
__u16 h_i_mode_high;
__u16 h_i_uid_high;
__u16 h_i_gid_high;
__u32 h_i_author;
} hurd2;
} osd2; /* OS dependent 2 */
};
/*
* Permanent part of an large inode on the disk
*/
struct ext2_inode_large {
/*00*/ __u16 i_mode; /* File mode */
__u16 i_uid; /* Low 16 bits of Owner Uid */
__u32 i_size; /* Size in bytes */
__u32 i_atime; /* Access time */
__u32 i_ctime; /* Inode Change time */
/*10*/ __u32 i_mtime; /* Modification time */
__u32 i_dtime; /* Deletion Time */
__u16 i_gid; /* Low 16 bits of Group Id */
__u16 i_links_count; /* Links count */
__u32 i_blocks; /* Blocks count */
/*20*/ __u32 i_flags; /* File flags */
union {
struct {
__u32 l_i_version; /* was l_i_reserved1 */
} linux1;
struct {
__u32 h_i_translator;
} hurd1;
} osd1; /* OS dependent 1 */
/*28*/ __u32 i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
/*64*/ __u32 i_generation; /* File version (for NFS) */
__u32 i_file_acl; /* File ACL */
__u32 i_size_high;
/*70*/ __u32 i_faddr; /* Fragment address */
union {
struct {
__u16 l_i_blocks_hi;
__u16 l_i_file_acl_high;
__u16 l_i_uid_high; /* these 2 fields */
__u16 l_i_gid_high; /* were reserved2[0] */
__u16 l_i_checksum_lo; /* crc32c(uuid+inum+inode) */
__u16 l_i_reserved;
} linux2;
struct {
__u8 h_i_frag; /* Fragment number */
__u8 h_i_fsize; /* Fragment size */
__u16 h_i_mode_high;
__u16 h_i_uid_high;
__u16 h_i_gid_high;
__u32 h_i_author;
} hurd2;
} osd2; /* OS dependent 2 */
/*80*/ __u16 i_extra_isize;
__u16 i_checksum_hi; /* crc32c(uuid+inum+inode) */
__u32 i_ctime_extra; /* extra Change time (nsec << 2 | epoch) */
__u32 i_mtime_extra; /* extra Modification time (nsec << 2 | epoch) */
__u32 i_atime_extra; /* extra Access time (nsec << 2 | epoch) */
/*90*/ __u32 i_crtime; /* File creation time */
__u32 i_crtime_extra; /* extra File creation time (nsec << 2 | epoch)*/
__u32 i_version_hi; /* high 32 bits for 64-bit version */
/*9c*/ __u32 i_projid; /* Project ID */
};
#define EXT4_INODE_CSUM_HI_EXTRA_END \
(offsetof(struct ext2_inode_large, i_checksum_hi) + sizeof(__u16) - \
EXT2_GOOD_OLD_INODE_SIZE)
#define EXT4_EPOCH_BITS 2
#define EXT4_EPOCH_MASK ((1 << EXT4_EPOCH_BITS) - 1)
#define i_checksum_lo osd2.linux2.l_i_checksum_lo
#define inode_includes(size, field) \
(size >= (sizeof(((struct ext2_inode_large *)0)->field) + \
offsetof(struct ext2_inode_large, field)))
#if defined(__KERNEL__) || defined(__linux__)
#define i_reserved1 osd1.linux1.l_i_reserved1
#define i_frag osd2.linux2.l_i_frag
#define i_fsize osd2.linux2.l_i_fsize
#define i_uid_low i_uid
#define i_gid_low i_gid
#define i_uid_high osd2.linux2.l_i_uid_high
#define i_gid_high osd2.linux2.l_i_gid_high
#else
#if defined(__GNU__)
#define i_translator osd1.hurd1.h_i_translator
#define i_frag osd2.hurd2.h_i_frag;
#define i_fsize osd2.hurd2.h_i_fsize;
#define i_uid_high osd2.hurd2.h_i_uid_high
#define i_gid_high osd2.hurd2.h_i_gid_high
#define i_author osd2.hurd2.h_i_author
#endif /* __GNU__ */
#endif /* defined(__KERNEL__) || defined(__linux__) */
#define inode_uid(inode) ((inode).i_uid | (inode).osd2.linux2.l_i_uid_high << 16)
#define inode_gid(inode) ((inode).i_gid | (inode).osd2.linux2.l_i_gid_high << 16)
#define inode_projid(inode) ((inode).i_projid)
#define ext2fs_set_i_uid_high(inode,x) ((inode).osd2.linux2.l_i_uid_high = (x))
#define ext2fs_set_i_gid_high(inode,x) ((inode).osd2.linux2.l_i_gid_high = (x))
static inline
struct ext2_inode *EXT2_INODE(struct ext2_inode_large *large_inode)
{
return (struct ext2_inode *) large_inode;
}
/*
* File system states
*/
#define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */
#define EXT2_ERROR_FS 0x0002 /* Errors detected */
#define EXT3_ORPHAN_FS 0x0004 /* Orphans being recovered */
/*
* Misc. filesystem flags
*/
#define EXT2_FLAGS_SIGNED_HASH 0x0001 /* Signed dirhash in use */
#define EXT2_FLAGS_UNSIGNED_HASH 0x0002 /* Unsigned dirhash in use */
#define EXT2_FLAGS_TEST_FILESYS 0x0004 /* OK for use on development code */
#define EXT2_FLAGS_IS_SNAPSHOT 0x0010 /* This is a snapshot image */
#define EXT2_FLAGS_FIX_SNAPSHOT 0x0020 /* Snapshot inodes corrupted */
#define EXT2_FLAGS_FIX_EXCLUDE 0x0040 /* Exclude bitmaps corrupted */
/*
* Mount flags
*/
#define EXT2_MOUNT_CHECK 0x0001 /* Do mount-time checks */
#define EXT2_MOUNT_GRPID 0x0004 /* Create files with directory's group */
#define EXT2_MOUNT_DEBUG 0x0008 /* Some debugging messages */
#define EXT2_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */
#define EXT2_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */
#define EXT2_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */
#define EXT2_MOUNT_MINIX_DF 0x0080 /* Mimics the Minix statfs */
#define EXT2_MOUNT_NO_UID32 0x0200 /* Disable 32-bit UIDs */
#define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
#define set_opt(o, opt) o |= EXT2_MOUNT_##opt
#define test_opt(sb, opt) (EXT2_SB(sb)->s_mount_opt & \
EXT2_MOUNT_##opt)
/*
* Maximal mount counts between two filesystem checks
*/
#define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */
#define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */
/*
* Behaviour when detecting errors
*/
#define EXT2_ERRORS_CONTINUE 1 /* Continue execution */
#define EXT2_ERRORS_RO 2 /* Remount fs read-only */
#define EXT2_ERRORS_PANIC 3 /* Panic */
#define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE
#if (__GNUC__ >= 4)
#define ext4_offsetof(TYPE,MEMBER) __builtin_offsetof(TYPE,MEMBER)
#else
#define ext4_offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif
/* Metadata checksum algorithms */
#define EXT2_CRC32C_CHKSUM 1
/* Encryption algorithms, key size and key reference len */
#define EXT4_ENCRYPTION_MODE_INVALID 0
#define EXT4_ENCRYPTION_MODE_AES_256_XTS 1
#define EXT4_ENCRYPTION_MODE_AES_256_GCM 2
#define EXT4_ENCRYPTION_MODE_AES_256_CBC 3
#define EXT4_ENCRYPTION_MODE_AES_256_CTS 4
#define EXT4_AES_256_XTS_KEY_SIZE 64
#define EXT4_AES_256_GCM_KEY_SIZE 32
#define EXT4_AES_256_CBC_KEY_SIZE 32
#define EXT4_AES_256_CTS_KEY_SIZE 32
#define EXT4_MAX_KEY_SIZE 64
#define EXT4_KEY_DESCRIPTOR_SIZE 8
#define EXT4_CRYPTO_BLOCK_SIZE 16
/* Password derivation constants */
#define EXT4_MAX_PASSPHRASE_SIZE 1024
#define EXT4_MAX_SALT_SIZE 256
#define EXT4_PBKDF2_ITERATIONS 0xFFFF
#define EXT2_LABEL_LEN 16
/*
* Policy provided via an ioctl on the topmost directory. This
* structure is also in the kernel.
*/
struct ext4_encryption_policy {
char version;
char contents_encryption_mode;
char filenames_encryption_mode;
char flags;
char master_key_descriptor[EXT4_KEY_DESCRIPTOR_SIZE];
} __attribute__((__packed__));
struct ext4_encryption_key {
__u32 mode;
char raw[EXT4_MAX_KEY_SIZE];
__u32 size;
} __attribute__((__packed__));
/*
* Structure of the super block
*/
struct ext2_super_block {
/*000*/ __u32 s_inodes_count; /* Inodes count */
__u32 s_blocks_count; /* Blocks count */
__u32 s_r_blocks_count; /* Reserved blocks count */
__u32 s_free_blocks_count; /* Free blocks count */
/*010*/ __u32 s_free_inodes_count; /* Free inodes count */
__u32 s_first_data_block; /* First Data Block */
__u32 s_log_block_size; /* Block size */
__u32 s_log_cluster_size; /* Allocation cluster size */
/*020*/ __u32 s_blocks_per_group; /* # Blocks per group */
__u32 s_clusters_per_group; /* # Fragments per group */
__u32 s_inodes_per_group; /* # Inodes per group */
__u32 s_mtime; /* Mount time */
/*030*/ __u32 s_wtime; /* Write time */
__u16 s_mnt_count; /* Mount count */
__s16 s_max_mnt_count; /* Maximal mount count */
__u16 s_magic; /* Magic signature */
__u16 s_state; /* File system state */
__u16 s_errors; /* Behaviour when detecting errors */
__u16 s_minor_rev_level; /* minor revision level */
/*040*/ __u32 s_lastcheck; /* time of last check */
__u32 s_checkinterval; /* max. time between checks */
__u32 s_creator_os; /* OS */
__u32 s_rev_level; /* Revision level */
/*050*/ __u16 s_def_resuid; /* Default uid for reserved blocks */
__u16 s_def_resgid; /* Default gid for reserved blocks */
/*
* These fields are for EXT2_DYNAMIC_REV superblocks only.
*
* Note: the difference between the compatible feature set and
* the incompatible feature set is that if there is a bit set
* in the incompatible feature set that the kernel doesn't
* know about, it should refuse to mount the filesystem.
*
* e2fsck's requirements are more strict; if it doesn't know
* about a feature in either the compatible or incompatible
* feature set, it must abort and not try to meddle with
* things it doesn't understand...
*/
__u32 s_first_ino; /* First non-reserved inode */
__u16 s_inode_size; /* size of inode structure */
__u16 s_block_group_nr; /* block group # of this superblock */
__u32 s_feature_compat; /* compatible feature set */
/*060*/ __u32 s_feature_incompat; /* incompatible feature set */
__u32 s_feature_ro_compat; /* readonly-compatible feature set */
/*068*/ __u8 s_uuid[16]; /* 128-bit uuid for volume */
/*078*/ __u8 s_volume_name[EXT2_LABEL_LEN]; /* volume name, no NUL? */
/*088*/ __u8 s_last_mounted[64]; /* directory last mounted on, no NUL? */
/*0c8*/ __u32 s_algorithm_usage_bitmap; /* For compression */
/*
* Performance hints. Directory preallocation should only
* happen if the EXT2_FEATURE_COMPAT_DIR_PREALLOC flag is on.
*/
__u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
__u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
__u16 s_reserved_gdt_blocks; /* Per group table for online growth */
/*
* Journaling support valid if EXT2_FEATURE_COMPAT_HAS_JOURNAL set.
*/
/*0d0*/ __u8 s_journal_uuid[16]; /* uuid of journal superblock */
/*0e0*/ __u32 s_journal_inum; /* inode number of journal file */
__u32 s_journal_dev; /* device number of journal file */
__u32 s_last_orphan; /* start of list of inodes to delete */
/*0ec*/ __u32 s_hash_seed[4]; /* HTREE hash seed */
/*0fc*/ __u8 s_def_hash_version; /* Default hash version to use */
__u8 s_jnl_backup_type; /* Default type of journal backup */
__u16 s_desc_size; /* Group desc. size: INCOMPAT_64BIT */
/*100*/ __u32 s_default_mount_opts; /* default EXT2_MOUNT_* flags used */
__u32 s_first_meta_bg; /* First metablock group */
__u32 s_mkfs_time; /* When the filesystem was created */
/*10c*/ __u32 s_jnl_blocks[17]; /* Backup of the journal inode */
/*150*/ __u32 s_blocks_count_hi; /* Blocks count high 32bits */
__u32 s_r_blocks_count_hi; /* Reserved blocks count high 32 bits*/
__u32 s_free_blocks_hi; /* Free blocks count */
__u16 s_min_extra_isize; /* All inodes have at least # bytes */
__u16 s_want_extra_isize; /* New inodes should reserve # bytes */
/*160*/ __u32 s_flags; /* Miscellaneous flags */
__u16 s_raid_stride; /* RAID stride in blocks */
__u16 s_mmp_update_interval; /* # seconds to wait in MMP checking */
__u64 s_mmp_block; /* Block for multi-mount protection */
/*170*/ __u32 s_raid_stripe_width; /* blocks on all data disks (N*stride)*/
__u8 s_log_groups_per_flex; /* FLEX_BG group size */
__u8 s_checksum_type; /* metadata checksum algorithm */
__u8 s_encryption_level; /* versioning level for encryption */
__u8 s_reserved_pad; /* Padding to next 32bits */
__u64 s_kbytes_written; /* nr of lifetime kilobytes written */
/*180*/ __u32 s_snapshot_inum; /* Inode number of active snapshot */
__u32 s_snapshot_id; /* sequential ID of active snapshot */
__u64 s_snapshot_r_blocks_count; /* active snapshot reserved blocks */
/*190*/ __u32 s_snapshot_list; /* inode number of disk snapshot list */
#define EXT4_S_ERR_START ext4_offsetof(struct ext2_super_block, s_error_count)
__u32 s_error_count; /* number of fs errors */
__u32 s_first_error_time; /* first time an error happened */
__u32 s_first_error_ino; /* inode involved in first error */
/*1a0*/ __u64 s_first_error_block; /* block involved in first error */
__u8 s_first_error_func[32]; /* function where error hit, no NUL? */
/*1c8*/ __u32 s_first_error_line; /* line number where error happened */
__u32 s_last_error_time; /* most recent time of an error */
/*1d0*/ __u32 s_last_error_ino; /* inode involved in last error */
__u32 s_last_error_line; /* line number where error happened */
__u64 s_last_error_block; /* block involved of last error */
/*1e0*/ __u8 s_last_error_func[32]; /* function where error hit, no NUL? */
#define EXT4_S_ERR_END ext4_offsetof(struct ext2_super_block, s_mount_opts)
/*200*/ __u8 s_mount_opts[64]; /* default mount options, no NUL? */
/*240*/ __u32 s_usr_quota_inum; /* inode number of user quota file */
__u32 s_grp_quota_inum; /* inode number of group quota file */
__u32 s_overhead_blocks; /* overhead blocks/clusters in fs */
/*24c*/ __u32 s_backup_bgs[2]; /* If sparse_super2 enabled */
/*254*/ __u8 s_encrypt_algos[4]; /* Encryption algorithms in use */
/*258*/ __u8 s_encrypt_pw_salt[16]; /* Salt used for string2key algorithm */
/*268*/ __le32 s_lpf_ino; /* Location of the lost+found inode */
__le32 s_prj_quota_inum; /* inode for tracking project quota */
/*270*/ __le32 s_checksum_seed; /* crc32c(orig_uuid) if csum_seed set */
/*274*/ __u8 s_wtime_hi;
__u8 s_mtime_hi;
__u8 s_mkfs_time_hi;
__u8 s_lastcheck_hi;
__u8 s_first_error_time_hi;
__u8 s_last_error_time_hi;
__u8 s_pad[2];
/*27c*/ __le16 s_encoding; /* Filename charset encoding */
__le16 s_encoding_flags; /* Filename charset encoding flags */
__le32 s_reserved[95]; /* Padding to the end of the block */
/*3fc*/ __u32 s_checksum; /* crc32c(superblock) */
};
#define EXT4_S_ERR_LEN (EXT4_S_ERR_END - EXT4_S_ERR_START)
#define EXT2_LEN_STR(buf) (int)sizeof(buf), (char *)buf
/*
* Codes for operating systems
*/
#define EXT2_OS_LINUX 0
#define EXT2_OS_HURD 1
#define EXT2_OBSO_OS_MASIX 2
#define EXT2_OS_FREEBSD 3
#define EXT2_OS_LITES 4
/*
* Revision levels
*/
#define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */
#define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */
#define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV
#define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV
#define EXT2_GOOD_OLD_INODE_SIZE 128
/*
* Journal inode backup types
*/
#define EXT3_JNL_BACKUP_BLOCKS 1
/*
* Feature set definitions
*/
#define EXT2_HAS_COMPAT_FEATURE(sb,mask) \
( EXT2_SB(sb)->s_feature_compat & (mask) )
#define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask) \
( EXT2_SB(sb)->s_feature_ro_compat & (mask) )
#define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \
( EXT2_SB(sb)->s_feature_incompat & (mask) )
#define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001
#define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002
#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
#define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008
#define EXT2_FEATURE_COMPAT_RESIZE_INODE 0x0010
#define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020
#define EXT2_FEATURE_COMPAT_LAZY_BG 0x0040
/* #define EXT2_FEATURE_COMPAT_EXCLUDE_INODE 0x0080 not used, legacy */
#define EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP 0x0100
#define EXT4_FEATURE_COMPAT_SPARSE_SUPER2 0x0200
#define EXT4_FEATURE_COMPAT_FAST_COMMIT 0x0400
#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
/* #define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 not used */
#define EXT4_FEATURE_RO_COMPAT_HUGE_FILE 0x0008
#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010
#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020
#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
#define EXT4_FEATURE_RO_COMPAT_HAS_SNAPSHOT 0x0080
#define EXT4_FEATURE_RO_COMPAT_QUOTA 0x0100
#define EXT4_FEATURE_RO_COMPAT_BIGALLOC 0x0200
/*
* METADATA_CSUM implies GDT_CSUM. When METADATA_CSUM is set, group
* descriptor checksums use the same algorithm as all other data
* structures' checksums.
*/
#define EXT4_FEATURE_RO_COMPAT_METADATA_CSUM 0x0400
#define EXT4_FEATURE_RO_COMPAT_REPLICA 0x0800
#define EXT4_FEATURE_RO_COMPAT_READONLY 0x1000
#define EXT4_FEATURE_RO_COMPAT_PROJECT 0x2000 /* Project quota */
#define EXT4_FEATURE_RO_COMPAT_SHARED_BLOCKS 0x4000
#define EXT4_FEATURE_RO_COMPAT_VERITY 0x8000
#define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001
#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */
#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */
#define EXT2_FEATURE_INCOMPAT_META_BG 0x0010
#define EXT3_FEATURE_INCOMPAT_EXTENTS 0x0040
#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
#define EXT4_FEATURE_INCOMPAT_MMP 0x0100
#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
#define EXT4_FEATURE_INCOMPAT_EA_INODE 0x0400
#define EXT4_FEATURE_INCOMPAT_DIRDATA 0x1000
#define EXT4_FEATURE_INCOMPAT_CSUM_SEED 0x2000
#define EXT4_FEATURE_INCOMPAT_LARGEDIR 0x4000 /* >2GB or 3-lvl htree */
#define EXT4_FEATURE_INCOMPAT_INLINE_DATA 0x8000 /* data in inode */
#define EXT4_FEATURE_INCOMPAT_ENCRYPT 0x10000
#define EXT4_FEATURE_INCOMPAT_CASEFOLD 0x20000
#define EXT4_FEATURE_COMPAT_FUNCS(name, ver, flagname) \
static inline int ext2fs_has_feature_##name(struct ext2_super_block *sb) \
{ \
return ((EXT2_SB(sb)->s_feature_compat & \
EXT##ver##_FEATURE_COMPAT_##flagname) != 0); \
} \
static inline void ext2fs_set_feature_##name(struct ext2_super_block *sb) \
{ \
EXT2_SB(sb)->s_feature_compat |= \
EXT##ver##_FEATURE_COMPAT_##flagname; \
} \
static inline void ext2fs_clear_feature_##name(struct ext2_super_block *sb) \
{ \
EXT2_SB(sb)->s_feature_compat &= \
~EXT##ver##_FEATURE_COMPAT_##flagname; \
}
#define EXT4_FEATURE_RO_COMPAT_FUNCS(name, ver, flagname) \
static inline int ext2fs_has_feature_##name(struct ext2_super_block *sb) \
{ \
return ((EXT2_SB(sb)->s_feature_ro_compat & \
EXT##ver##_FEATURE_RO_COMPAT_##flagname) != 0); \
} \
static inline void ext2fs_set_feature_##name(struct ext2_super_block *sb) \
{ \
EXT2_SB(sb)->s_feature_ro_compat |= \
EXT##ver##_FEATURE_RO_COMPAT_##flagname; \
} \
static inline void ext2fs_clear_feature_##name(struct ext2_super_block *sb) \
{ \
EXT2_SB(sb)->s_feature_ro_compat &= \
~EXT##ver##_FEATURE_RO_COMPAT_##flagname; \
}
#define EXT4_FEATURE_INCOMPAT_FUNCS(name, ver, flagname) \
static inline int ext2fs_has_feature_##name(struct ext2_super_block *sb) \
{ \
return ((EXT2_SB(sb)->s_feature_incompat & \
EXT##ver##_FEATURE_INCOMPAT_##flagname) != 0); \
} \
static inline void ext2fs_set_feature_##name(struct ext2_super_block *sb) \
{ \
EXT2_SB(sb)->s_feature_incompat |= \
EXT##ver##_FEATURE_INCOMPAT_##flagname; \
} \
static inline void ext2fs_clear_feature_##name(struct ext2_super_block *sb) \
{ \
EXT2_SB(sb)->s_feature_incompat &= \
~EXT##ver##_FEATURE_INCOMPAT_##flagname; \
}
EXT4_FEATURE_COMPAT_FUNCS(dir_prealloc, 2, DIR_PREALLOC)
EXT4_FEATURE_COMPAT_FUNCS(imagic_inodes, 2, IMAGIC_INODES)
EXT4_FEATURE_COMPAT_FUNCS(journal, 3, HAS_JOURNAL)
EXT4_FEATURE_COMPAT_FUNCS(xattr, 2, EXT_ATTR)
EXT4_FEATURE_COMPAT_FUNCS(resize_inode, 2, RESIZE_INODE)
EXT4_FEATURE_COMPAT_FUNCS(dir_index, 2, DIR_INDEX)
EXT4_FEATURE_COMPAT_FUNCS(lazy_bg, 2, LAZY_BG)
EXT4_FEATURE_COMPAT_FUNCS(exclude_bitmap, 2, EXCLUDE_BITMAP)
EXT4_FEATURE_COMPAT_FUNCS(sparse_super2, 4, SPARSE_SUPER2)
EXT4_FEATURE_COMPAT_FUNCS(fast_commit, 4, FAST_COMMIT)
EXT4_FEATURE_RO_COMPAT_FUNCS(sparse_super, 2, SPARSE_SUPER)
EXT4_FEATURE_RO_COMPAT_FUNCS(large_file, 2, LARGE_FILE)
EXT4_FEATURE_RO_COMPAT_FUNCS(huge_file, 4, HUGE_FILE)
EXT4_FEATURE_RO_COMPAT_FUNCS(gdt_csum, 4, GDT_CSUM)
EXT4_FEATURE_RO_COMPAT_FUNCS(dir_nlink, 4, DIR_NLINK)
EXT4_FEATURE_RO_COMPAT_FUNCS(extra_isize, 4, EXTRA_ISIZE)
EXT4_FEATURE_RO_COMPAT_FUNCS(has_snapshot, 4, HAS_SNAPSHOT)
EXT4_FEATURE_RO_COMPAT_FUNCS(quota, 4, QUOTA)
EXT4_FEATURE_RO_COMPAT_FUNCS(bigalloc, 4, BIGALLOC)
EXT4_FEATURE_RO_COMPAT_FUNCS(metadata_csum, 4, METADATA_CSUM)
EXT4_FEATURE_RO_COMPAT_FUNCS(replica, 4, REPLICA)
EXT4_FEATURE_RO_COMPAT_FUNCS(readonly, 4, READONLY)
EXT4_FEATURE_RO_COMPAT_FUNCS(project, 4, PROJECT)
EXT4_FEATURE_RO_COMPAT_FUNCS(shared_blocks, 4, SHARED_BLOCKS)
EXT4_FEATURE_RO_COMPAT_FUNCS(verity, 4, VERITY)
EXT4_FEATURE_INCOMPAT_FUNCS(compression, 2, COMPRESSION)
EXT4_FEATURE_INCOMPAT_FUNCS(filetype, 2, FILETYPE)
EXT4_FEATURE_INCOMPAT_FUNCS(journal_needs_recovery, 3, RECOVER)
EXT4_FEATURE_INCOMPAT_FUNCS(journal_dev, 3, JOURNAL_DEV)
EXT4_FEATURE_INCOMPAT_FUNCS(meta_bg, 2, META_BG)
EXT4_FEATURE_INCOMPAT_FUNCS(extents, 3, EXTENTS)
EXT4_FEATURE_INCOMPAT_FUNCS(64bit, 4, 64BIT)
EXT4_FEATURE_INCOMPAT_FUNCS(mmp, 4, MMP)
EXT4_FEATURE_INCOMPAT_FUNCS(flex_bg, 4, FLEX_BG)
EXT4_FEATURE_INCOMPAT_FUNCS(ea_inode, 4, EA_INODE)
EXT4_FEATURE_INCOMPAT_FUNCS(dirdata, 4, DIRDATA)
EXT4_FEATURE_INCOMPAT_FUNCS(csum_seed, 4, CSUM_SEED)
EXT4_FEATURE_INCOMPAT_FUNCS(largedir, 4, LARGEDIR)
EXT4_FEATURE_INCOMPAT_FUNCS(inline_data, 4, INLINE_DATA)
EXT4_FEATURE_INCOMPAT_FUNCS(encrypt, 4, ENCRYPT)
EXT4_FEATURE_INCOMPAT_FUNCS(casefold, 4, CASEFOLD)
#define EXT2_FEATURE_COMPAT_SUPP 0
#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \
EXT4_FEATURE_INCOMPAT_MMP| \
EXT4_FEATURE_INCOMPAT_LARGEDIR| \
EXT4_FEATURE_INCOMPAT_EA_INODE)
#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
EXT4_FEATURE_RO_COMPAT_DIR_NLINK| \
EXT2_FEATURE_RO_COMPAT_BTREE_DIR| \
EXT4_FEATURE_RO_COMPAT_VERITY)
/*
* Default values for user and/or group using reserved blocks
*/
#define EXT2_DEF_RESUID 0
#define EXT2_DEF_RESGID 0
/*
* Default mount options
*/
#define EXT2_DEFM_DEBUG 0x0001
#define EXT2_DEFM_BSDGROUPS 0x0002
#define EXT2_DEFM_XATTR_USER 0x0004
#define EXT2_DEFM_ACL 0x0008
#define EXT2_DEFM_UID16 0x0010
#define EXT3_DEFM_JMODE 0x0060
#define EXT3_DEFM_JMODE_DATA 0x0020
#define EXT3_DEFM_JMODE_ORDERED 0x0040
#define EXT3_DEFM_JMODE_WBACK 0x0060
#define EXT4_DEFM_NOBARRIER 0x0100
#define EXT4_DEFM_BLOCK_VALIDITY 0x0200
#define EXT4_DEFM_DISCARD 0x0400
#define EXT4_DEFM_NODELALLOC 0x0800
/*
* Structure of a directory entry
*/
#define EXT2_NAME_LEN 255
struct ext2_dir_entry {
__u32 inode; /* Inode number */
__u16 rec_len; /* Directory entry length */
__u16 name_len; /* Name length */
char name[EXT2_NAME_LEN]; /* File name */
};
/*
* The new version of the directory entry. Since EXT2 structures are
* stored in intel byte order, and the name_len field could never be
* bigger than 255 chars, it's safe to reclaim the extra byte for the
* file_type field.
*
* This structure is deprecated due to endian issues. Please use struct
* ext2_dir_entry and accessor functions
* ext2fs_dirent_name_len
* ext2fs_dirent_set_name_len
* ext2fs_dirent_file_type
* ext2fs_dirent_set_file_type
* to get and set name_len and file_type fields.
*/
struct ext2_dir_entry_2 {
__u32 inode; /* Inode number */
__u16 rec_len; /* Directory entry length */
__u8 name_len; /* Name length */
__u8 file_type;
char name[EXT2_NAME_LEN]; /* File name */
};
/*
* This is a bogus directory entry at the end of each leaf block that
* records checksums.
*/
struct ext2_dir_entry_tail {
__u32 det_reserved_zero1; /* Pretend to be unused */
__u16 det_rec_len; /* 12 */
__u16 det_reserved_name_len; /* 0xDE00, fake namelen/filetype */
__u32 det_checksum; /* crc32c(uuid+inode+dirent) */
};
/*
* Ext2 directory file types. Only the low 3 bits are used. The
* other bits are reserved for now.
*/
#define EXT2_FT_UNKNOWN 0
#define EXT2_FT_REG_FILE 1
#define EXT2_FT_DIR 2
#define EXT2_FT_CHRDEV 3
#define EXT2_FT_BLKDEV 4
#define EXT2_FT_FIFO 5
#define EXT2_FT_SOCK 6
#define EXT2_FT_SYMLINK 7
#define EXT2_FT_MAX 8
/*
* Annoyingly, e2fsprogs always swab16s ext2_dir_entry.name_len, so we
* have to build ext2_dir_entry_tail with that assumption too. This
* constant helps to build the dir_entry_tail to look like it has an
* "invalid" file type.
*/
#define EXT2_DIR_NAME_LEN_CSUM 0xDE00
/*
* EXT2_DIR_PAD defines the directory entries boundaries
*
* NOTE: It must be a multiple of 4
*/
#define EXT2_DIR_ENTRY_HEADER_LEN 8
#define EXT2_DIR_PAD 4
#define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1)
#define EXT2_DIR_REC_LEN(name_len) (((name_len) + \
EXT2_DIR_ENTRY_HEADER_LEN + \
EXT2_DIR_ROUND) & \
~EXT2_DIR_ROUND)
/*
* Constants for ext4's extended time encoding
*/
#define EXT4_EPOCH_BITS 2
#define EXT4_EPOCH_MASK ((1 << EXT4_EPOCH_BITS) - 1)
#define EXT4_NSEC_MASK (~0UL << EXT4_EPOCH_BITS)
/*
* This structure is used for multiple mount protection. It is written
* into the block number saved in the s_mmp_block field in the superblock.
* Programs that check MMP should assume that if SEQ_FSCK (or any unknown
* code above SEQ_MAX) is present then it is NOT safe to use the filesystem,
* regardless of how old the timestamp is.
*
* The timestamp in the MMP structure will be updated by e2fsck at some
* arbitrary intervals (start of passes, after every few groups of inodes
* in pass1 and pass1b). There is no guarantee that e2fsck is updating
* the MMP block in a timely manner, and the updates it does are purely
* for the convenience of the sysadmin and not for automatic validation.
*
* Note: Only the mmp_seq value is used to determine whether the MMP block
* is being updated. The mmp_time, mmp_nodename, and mmp_bdevname
* fields are only for informational purposes for the administrator,
* due to clock skew between nodes and hostname HA service takeover.
*/
#define EXT4_MMP_MAGIC 0x004D4D50U /* ASCII for MMP */
#define EXT4_MMP_SEQ_CLEAN 0xFF4D4D50U /* mmp_seq value for clean unmount */
#define EXT4_MMP_SEQ_FSCK 0xE24D4D50U /* mmp_seq value when being fscked */
#define EXT4_MMP_SEQ_MAX 0xE24D4D4FU /* maximum valid mmp_seq value */
/* Not endian-annotated; it's swapped at read/write time */
struct mmp_struct {
__u32 mmp_magic; /* Magic number for MMP */
__u32 mmp_seq; /* Sequence no. updated periodically */
__u64 mmp_time; /* Time last updated (seconds) */
__u8 mmp_nodename[64]; /* Node updating MMP block, no NUL? */
__u8 mmp_bdevname[32]; /* Bdev updating MMP block, no NUL? */
__u16 mmp_check_interval; /* Changed mmp_check_interval */
__u16 mmp_pad1;
__u32 mmp_pad2[226];
__u32 mmp_checksum; /* crc32c(uuid+mmp_block) */
};
/*
* Default interval for MMP update in seconds.
*/
#define EXT4_MMP_UPDATE_INTERVAL 5
/*
* Maximum interval for MMP update in seconds.
*/
#define EXT4_MMP_MAX_UPDATE_INTERVAL 300
/*
* Minimum interval for MMP checking in seconds.
*/
#define EXT4_MMP_MIN_CHECK_INTERVAL 5
/*
* Minimum size of inline data.
*/
#define EXT4_MIN_INLINE_DATA_SIZE ((sizeof(__u32) * EXT2_N_BLOCKS))
/*
* Size of a parent inode in inline data directory.
*/
#define EXT4_INLINE_DATA_DOTDOT_SIZE (4)
#define EXT4_ENC_UTF8_12_1 1
#define EXT4_ENC_STRICT_MODE_FL (1 << 0) /* Reject invalid sequences */
#endif /* _LINUX_EXT2_FS_H */
ext2fs/qcow2.h 0000644 00000005034 15201526705 0007170 0 ustar 00 /*
* qcow2.h --- structures and function prototypes for qcow2.c to generate
* qcow2 formatted disk images. This format is used originally by QEMU
* for virtual machines, and stores the filesystem data on disk in a
* packed format to avoid creating sparse image files that need lots of
* seeking to read and write.
*
* The qcow2 format supports zlib compression, but that is not yet
* implemented.
*
* It is possible to directly mount a qcow2 image using qemu-nbd:
*
* [root]# modprobe nbd max_part=63
* [root]# qemu-nbd -c /dev/nbd0 image.img
* [root]# mount /dev/nbd0p1 /mnt/qemu
*
* Format details at http://people.gnome.org/~markmc/qcow-image-format.html
*
* Copyright (C) 2010 Red Hat, Inc., Lukas Czerner <lczerner@redhat.com>
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Public
* License.
* %End-Header%
*/
/* Number of l2 tables in memory before writeback */
#define L2_CACHE_PREALLOC 512
#define QCOW_MAGIC (('Q' << 24) | ('F' << 16) | ('I' << 8) | 0xfb)
#define QCOW_VERSION 2
#define QCOW_OFLAG_COPIED (1ULL << 63)
#define QCOW_OFLAG_COMPRESSED (1ULL << 62)
#define QCOW_COMPRESSED 1
#define QCOW_ENCRYPTED 2
#define QCOW_CORRUPTED 3
struct ext2_qcow2_hdr {
__u32 magic;
__u32 version;
__u64 backing_file_offset;
__u32 backing_file_size;
__u32 cluster_bits;
__u64 size;
__u32 crypt_method;
__u32 l1_size;
__u64 l1_table_offset;
__u64 refcount_table_offset;
__u32 refcount_table_clusters;
__u32 nb_snapshots;
__u64 snapshots_offset;
};
typedef struct ext2_qcow2_l2_table L2_CACHE_HEAD;
struct ext2_qcow2_l2_table {
__u32 l1_index;
__u64 offset;
__u64 *data;
L2_CACHE_HEAD *next;
};
struct ext2_qcow2_l2_cache {
L2_CACHE_HEAD *used_head;
L2_CACHE_HEAD *used_tail;
L2_CACHE_HEAD *free_head;
__u32 free;
__u32 count;
__u64 next_offset;
};
struct ext2_qcow2_refcount {
__u64 *refcount_table;
__u64 refcount_table_offset;
__u64 refcount_block_offset;
__u32 refcount_table_clusters;
__u32 refcount_table_index;
__u32 refcount_block_index;
__u16 *refcount_block;
};
struct ext2_qcow2_image {
int fd;
struct ext2_qcow2_hdr *hdr;
struct ext2_qcow2_l2_cache *l2_cache;
struct ext2_qcow2_refcount refcount;
__u32 cluster_size;
__u32 cluster_bits;
__u32 l1_size;
__u32 l2_size;
__u64 *l1_table;
__u64 l2_offset;
__u64 l1_offset;
__u64 image_size;
};
/* Function prototypes */
/* qcow2.c */
/* Functions for converting qcow2 image into raw image */
struct ext2_qcow2_hdr *qcow2_read_header(int);
int qcow2_write_raw_image(int, int, struct ext2_qcow2_hdr *);
ext2fs/ext2_io.h 0000644 00000012417 15201526705 0007511 0 ustar 00 /*
* io.h --- the I/O manager abstraction
*
* Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Library
* General Public License, version 2.
* %End-Header%
*/
#ifndef _EXT2FS_EXT2_IO_H
#define _EXT2FS_EXT2_IO_H
#include <ext2fs/ext2_types.h>
/*
* ext2_loff_t is defined here since unix_io.c needs it.
*/
#if defined(__GNUC__) || defined(HAS_LONG_LONG)
typedef long long ext2_loff_t;
#else
typedef long ext2_loff_t;
#endif
/* llseek.c */
ext2_loff_t ext2fs_llseek (int, ext2_loff_t, int);
typedef struct struct_io_manager *io_manager;
typedef struct struct_io_channel *io_channel;
typedef struct struct_io_stats *io_stats;
#define CHANNEL_FLAGS_WRITETHROUGH 0x01
#define CHANNEL_FLAGS_DISCARD_ZEROES 0x02
#define CHANNEL_FLAGS_BLOCK_DEVICE 0x04
#define io_channel_discard_zeroes_data(i) (i->flags & CHANNEL_FLAGS_DISCARD_ZEROES)
struct struct_io_channel {
errcode_t magic;
io_manager manager;
char *name;
int block_size;
errcode_t (*read_error)(io_channel channel,
unsigned long block,
int count,
void *data,
size_t size,
int actual_bytes_read,
errcode_t error);
errcode_t (*write_error)(io_channel channel,
unsigned long block,
int count,
const void *data,
size_t size,
int actual_bytes_written,
errcode_t error);
int refcount;
int flags;
long reserved[14];
void *private_data;
void *app_data;
int align;
};
struct struct_io_stats {
int num_fields;
int reserved;
unsigned long long bytes_read;
unsigned long long bytes_written;
};
struct struct_io_manager {
errcode_t magic;
const char *name;
errcode_t (*open)(const char *name, int flags, io_channel *channel);
errcode_t (*close)(io_channel channel);
errcode_t (*set_blksize)(io_channel channel, int blksize);
errcode_t (*read_blk)(io_channel channel, unsigned long block,
int count, void *data);
errcode_t (*write_blk)(io_channel channel, unsigned long block,
int count, const void *data);
errcode_t (*flush)(io_channel channel);
errcode_t (*write_byte)(io_channel channel, unsigned long offset,
int count, const void *data);
errcode_t (*set_option)(io_channel channel, const char *option,
const char *arg);
errcode_t (*get_stats)(io_channel channel, io_stats *io_stats);
errcode_t (*read_blk64)(io_channel channel, unsigned long long block,
int count, void *data);
errcode_t (*write_blk64)(io_channel channel, unsigned long long block,
int count, const void *data);
errcode_t (*discard)(io_channel channel, unsigned long long block,
unsigned long long count);
errcode_t (*cache_readahead)(io_channel channel,
unsigned long long block,
unsigned long long count);
errcode_t (*zeroout)(io_channel channel, unsigned long long block,
unsigned long long count);
long reserved[14];
};
#define IO_FLAG_RW 0x0001
#define IO_FLAG_EXCLUSIVE 0x0002
#define IO_FLAG_DIRECT_IO 0x0004
#define IO_FLAG_FORCE_BOUNCE 0x0008
/*
* Convenience functions....
*/
#define io_channel_close(c) ((c)->manager->close((c)))
#define io_channel_set_blksize(c,s) ((c)->manager->set_blksize((c),s))
#define io_channel_read_blk(c,b,n,d) ((c)->manager->read_blk((c),b,n,d))
#define io_channel_write_blk(c,b,n,d) ((c)->manager->write_blk((c),b,n,d))
#define io_channel_flush(c) ((c)->manager->flush((c)))
#define io_channel_bumpcount(c) ((c)->refcount++)
/* io_manager.c */
extern errcode_t io_channel_set_options(io_channel channel,
const char *options);
extern errcode_t io_channel_write_byte(io_channel channel,
unsigned long offset,
int count, const void *data);
extern errcode_t io_channel_read_blk64(io_channel channel,
unsigned long long block,
int count, void *data);
extern errcode_t io_channel_write_blk64(io_channel channel,
unsigned long long block,
int count, const void *data);
extern errcode_t io_channel_discard(io_channel channel,
unsigned long long block,
unsigned long long count);
extern errcode_t io_channel_zeroout(io_channel channel,
unsigned long long block,
unsigned long long count);
extern errcode_t io_channel_alloc_buf(io_channel channel,
int count, void *ptr);
extern errcode_t io_channel_cache_readahead(io_channel io,
unsigned long long block,
unsigned long long count);
/* unix_io.c */
extern io_manager unix_io_manager;
extern io_manager unixfd_io_manager;
/* sparse_io.c */
extern io_manager sparse_io_manager;
extern io_manager sparsefd_io_manager;
/* undo_io.c */
extern io_manager undo_io_manager;
extern errcode_t set_undo_io_backing_manager(io_manager manager);
extern errcode_t set_undo_io_backup_file(char *file_name);
/* test_io.c */
extern io_manager test_io_manager, test_io_backing_manager;
extern void (*test_io_cb_read_blk)
(unsigned long block, int count, errcode_t err);
extern void (*test_io_cb_write_blk)
(unsigned long block, int count, errcode_t err);
extern void (*test_io_cb_read_blk64)
(unsigned long long block, int count, errcode_t err);
extern void (*test_io_cb_write_blk64)
(unsigned long long block, int count, errcode_t err);
extern void (*test_io_cb_set_blksize)
(int blksize, errcode_t err);
#endif /* _EXT2FS_EXT2_IO_H */
ext2fs/ext2_types-x86_64.h 0000644 00000010164 15201526705 0011177 0 ustar 00 /*
* If linux/types.h is already been included, assume it has defined
* everything we need. (cross fingers) Other header files may have
* also defined the types that we need.
*/
#if (!defined(_LINUX_TYPES_H) && !defined(_BLKID_TYPES_H) && \
!defined(_EXT2_TYPES_H))
#define _EXT2_TYPES_H
#define __S8_TYPEDEF __signed__ char
#define __U8_TYPEDEF unsigned char
#define __S16_TYPEDEF __signed__ short
#define __U16_TYPEDEF unsigned short
#define __S32_TYPEDEF __signed__ int
#define __U32_TYPEDEF unsigned int
#define __S64_TYPEDEF __signed__ long long
#define __U64_TYPEDEF unsigned long long
#ifndef HAVE___U8
#define HAVE___U8
#ifdef __U8_TYPEDEF
typedef __U8_TYPEDEF __u8;
#else
typedef unsigned char __u8;
#endif
#endif /* HAVE___U8 */
#ifndef HAVE___S8
#define HAVE___S8
#ifdef __S8_TYPEDEF
typedef __S8_TYPEDEF __s8;
#else
typedef signed char __s8;
#endif
#endif /* HAVE___S8 */
#ifndef HAVE___U16
#define HAVE___U16
#ifdef __U16_TYPEDEF
typedef __U16_TYPEDEF __u16;
#else
#if (4 == 2)
typedef unsigned int __u16;
#else
#if (2 == 2)
typedef unsigned short __u16;
#else
#undef HAVE___U16
?==error: undefined 16 bit type
#endif /* SIZEOF_SHORT == 2 */
#endif /* SIZEOF_INT == 2 */
#endif /* __U16_TYPEDEF */
#endif /* HAVE___U16 */
#ifndef HAVE___S16
#define HAVE___S16
#ifdef __S16_TYPEDEF
typedef __S16_TYPEDEF __s16;
#else
#if (4 == 2)
typedef int __s16;
#else
#if (2 == 2)
typedef short __s16;
#else
#undef HAVE___S16
?==error: undefined 16 bit type
#endif /* SIZEOF_SHORT == 2 */
#endif /* SIZEOF_INT == 2 */
#endif /* __S16_TYPEDEF */
#endif /* HAVE___S16 */
#ifndef HAVE___U32
#define HAVE___U32
#ifdef __U32_TYPEDEF
typedef __U32_TYPEDEF __u32;
#else
#if (4 == 4)
typedef unsigned int __u32;
#else
#if (8 == 4)
typedef unsigned long __u32;
#else
#if (2 == 4)
typedef unsigned short __u32;
#else
#undef HAVE___U32
?== error: undefined 32 bit type
#endif /* SIZEOF_SHORT == 4 */
#endif /* SIZEOF_LONG == 4 */
#endif /* SIZEOF_INT == 4 */
#endif /* __U32_TYPEDEF */
#endif /* HAVE___U32 */
#ifndef HAVE___S32
#define HAVE___S32
#ifdef __S32_TYPEDEF
typedef __S32_TYPEDEF __s32;
#else
#if (4 == 4)
typedef int __s32;
#else
#if (8 == 4)
typedef long __s32;
#else
#if (2 == 4)
typedef short __s32;
#else
#undef HAVE___S32
?== error: undefined 32 bit type
#endif /* SIZEOF_SHORT == 4 */
#endif /* SIZEOF_LONG == 4 */
#endif /* SIZEOF_INT == 4 */
#endif /* __S32_TYPEDEF */
#endif /* HAVE___S32 */
#ifndef HAVE___U64
#define HAVE___U64
#ifdef __U64_TYPEDEF
typedef __U64_TYPEDEF __u64;
#else
#if (4 == 8)
typedef unsigned int __u64;
#else
#if (8 == 8)
typedef unsigned long long __u64;
#else
#if (8 == 8)
typedef unsigned long __u64;
#else
#undef HAVE___U64
?== error: undefined 64 bit type
#endif /* SIZEOF_LONG_LONG == 8 */
#endif /* SIZEOF_LONG == 8 */
#endif /* SIZEOF_INT == 8 */
#endif /* __U64_TYPEDEF */
#endif /* HAVE___U64 */
#ifndef HAVE___S64
#define HAVE___S64
#ifdef __S64_TYPEDEF
typedef __S64_TYPEDEF __s64;
#else
#if (4 == 8)
typedef int __s64;
#else
#if (8 == 8)
#if defined(__GNUC__)
typedef __signed__ long long __s64;
#else
typedef signed long long __s64;
#endif /* __GNUC__ */
#else
#if (8 == 8)
typedef long __s64;
#else
#undef HAVE___S64
?== error: undefined 64 bit type
#endif /* SIZEOF_LONG_LONG == 8 */
#endif /* SIZEOF_LONG == 8 */
#endif /* SIZEOF_INT == 8 */
#endif /* __S64_TYPEDEF */
#endif /* HAVE___S64 */
#undef __S8_TYPEDEF
#undef __U8_TYPEDEF
#undef __S16_TYPEDEF
#undef __U16_TYPEDEF
#undef __S32_TYPEDEF
#undef __U32_TYPEDEF
#undef __S64_TYPEDEF
#undef __U64_TYPEDEF
#endif /* _*_TYPES_H */
#include <stdint.h>
/* endian checking stuff */
#ifndef EXT2_ENDIAN_H_
#define EXT2_ENDIAN_H_
#ifdef __CHECKER__
# ifndef __bitwise
# define __bitwise __attribute__((bitwise))
# endif
#define __force __attribute__((force))
#else
# ifndef __bitwise
# define __bitwise
# endif
#define __force
#endif
typedef __u16 __bitwise __le16;
typedef __u32 __bitwise __le32;
typedef __u64 __bitwise __le64;
typedef __u16 __bitwise __be16;
typedef __u32 __bitwise __be32;
typedef __u64 __bitwise __be64;
#endif /* EXT2_ENDIAN_H_ */
/* These defines are needed for the public ext2fs.h header file */
#define HAVE_SYS_TYPES_H 1
#undef WORDS_BIGENDIAN
ext2fs/ext2_err.h 0000644 00000027206 15201526705 0007674 0 ustar 00 /*
* ext2_err.h:
* This file is automatically generated; please do not edit it.
*/
#include <et/com_err.h>
#define EXT2_ET_BASE (2133571328L)
#define EXT2_ET_MAGIC_EXT2FS_FILSYS (2133571329L)
#define EXT2_ET_MAGIC_BADBLOCKS_LIST (2133571330L)
#define EXT2_ET_MAGIC_BADBLOCKS_ITERATE (2133571331L)
#define EXT2_ET_MAGIC_INODE_SCAN (2133571332L)
#define EXT2_ET_MAGIC_IO_CHANNEL (2133571333L)
#define EXT2_ET_MAGIC_UNIX_IO_CHANNEL (2133571334L)
#define EXT2_ET_MAGIC_IO_MANAGER (2133571335L)
#define EXT2_ET_MAGIC_BLOCK_BITMAP (2133571336L)
#define EXT2_ET_MAGIC_INODE_BITMAP (2133571337L)
#define EXT2_ET_MAGIC_GENERIC_BITMAP (2133571338L)
#define EXT2_ET_MAGIC_TEST_IO_CHANNEL (2133571339L)
#define EXT2_ET_MAGIC_DBLIST (2133571340L)
#define EXT2_ET_MAGIC_ICOUNT (2133571341L)
#define EXT2_ET_MAGIC_PQ_IO_CHANNEL (2133571342L)
#define EXT2_ET_MAGIC_EXT2_FILE (2133571343L)
#define EXT2_ET_MAGIC_E2IMAGE (2133571344L)
#define EXT2_ET_MAGIC_INODE_IO_CHANNEL (2133571345L)
#define EXT2_ET_MAGIC_EXTENT_HANDLE (2133571346L)
#define EXT2_ET_BAD_MAGIC (2133571347L)
#define EXT2_ET_REV_TOO_HIGH (2133571348L)
#define EXT2_ET_RO_FILSYS (2133571349L)
#define EXT2_ET_GDESC_READ (2133571350L)
#define EXT2_ET_GDESC_WRITE (2133571351L)
#define EXT2_ET_GDESC_BAD_BLOCK_MAP (2133571352L)
#define EXT2_ET_GDESC_BAD_INODE_MAP (2133571353L)
#define EXT2_ET_GDESC_BAD_INODE_TABLE (2133571354L)
#define EXT2_ET_INODE_BITMAP_WRITE (2133571355L)
#define EXT2_ET_INODE_BITMAP_READ (2133571356L)
#define EXT2_ET_BLOCK_BITMAP_WRITE (2133571357L)
#define EXT2_ET_BLOCK_BITMAP_READ (2133571358L)
#define EXT2_ET_INODE_TABLE_WRITE (2133571359L)
#define EXT2_ET_INODE_TABLE_READ (2133571360L)
#define EXT2_ET_NEXT_INODE_READ (2133571361L)
#define EXT2_ET_UNEXPECTED_BLOCK_SIZE (2133571362L)
#define EXT2_ET_DIR_CORRUPTED (2133571363L)
#define EXT2_ET_SHORT_READ (2133571364L)
#define EXT2_ET_SHORT_WRITE (2133571365L)
#define EXT2_ET_DIR_NO_SPACE (2133571366L)
#define EXT2_ET_NO_INODE_BITMAP (2133571367L)
#define EXT2_ET_NO_BLOCK_BITMAP (2133571368L)
#define EXT2_ET_BAD_INODE_NUM (2133571369L)
#define EXT2_ET_BAD_BLOCK_NUM (2133571370L)
#define EXT2_ET_EXPAND_DIR_ERR (2133571371L)
#define EXT2_ET_TOOSMALL (2133571372L)
#define EXT2_ET_BAD_BLOCK_MARK (2133571373L)
#define EXT2_ET_BAD_BLOCK_UNMARK (2133571374L)
#define EXT2_ET_BAD_BLOCK_TEST (2133571375L)
#define EXT2_ET_BAD_INODE_MARK (2133571376L)
#define EXT2_ET_BAD_INODE_UNMARK (2133571377L)
#define EXT2_ET_BAD_INODE_TEST (2133571378L)
#define EXT2_ET_FUDGE_BLOCK_BITMAP_END (2133571379L)
#define EXT2_ET_FUDGE_INODE_BITMAP_END (2133571380L)
#define EXT2_ET_BAD_IND_BLOCK (2133571381L)
#define EXT2_ET_BAD_DIND_BLOCK (2133571382L)
#define EXT2_ET_BAD_TIND_BLOCK (2133571383L)
#define EXT2_ET_NEQ_BLOCK_BITMAP (2133571384L)
#define EXT2_ET_NEQ_INODE_BITMAP (2133571385L)
#define EXT2_ET_BAD_DEVICE_NAME (2133571386L)
#define EXT2_ET_MISSING_INODE_TABLE (2133571387L)
#define EXT2_ET_CORRUPT_SUPERBLOCK (2133571388L)
#define EXT2_ET_BAD_GENERIC_MARK (2133571389L)
#define EXT2_ET_BAD_GENERIC_UNMARK (2133571390L)
#define EXT2_ET_BAD_GENERIC_TEST (2133571391L)
#define EXT2_ET_SYMLINK_LOOP (2133571392L)
#define EXT2_ET_CALLBACK_NOTHANDLED (2133571393L)
#define EXT2_ET_BAD_BLOCK_IN_INODE_TABLE (2133571394L)
#define EXT2_ET_UNSUPP_FEATURE (2133571395L)
#define EXT2_ET_RO_UNSUPP_FEATURE (2133571396L)
#define EXT2_ET_LLSEEK_FAILED (2133571397L)
#define EXT2_ET_NO_MEMORY (2133571398L)
#define EXT2_ET_INVALID_ARGUMENT (2133571399L)
#define EXT2_ET_BLOCK_ALLOC_FAIL (2133571400L)
#define EXT2_ET_INODE_ALLOC_FAIL (2133571401L)
#define EXT2_ET_NO_DIRECTORY (2133571402L)
#define EXT2_ET_TOO_MANY_REFS (2133571403L)
#define EXT2_ET_FILE_NOT_FOUND (2133571404L)
#define EXT2_ET_FILE_RO (2133571405L)
#define EXT2_ET_DB_NOT_FOUND (2133571406L)
#define EXT2_ET_DIR_EXISTS (2133571407L)
#define EXT2_ET_UNIMPLEMENTED (2133571408L)
#define EXT2_ET_CANCEL_REQUESTED (2133571409L)
#define EXT2_ET_FILE_TOO_BIG (2133571410L)
#define EXT2_ET_JOURNAL_NOT_BLOCK (2133571411L)
#define EXT2_ET_NO_JOURNAL_SB (2133571412L)
#define EXT2_ET_JOURNAL_TOO_SMALL (2133571413L)
#define EXT2_ET_JOURNAL_UNSUPP_VERSION (2133571414L)
#define EXT2_ET_LOAD_EXT_JOURNAL (2133571415L)
#define EXT2_ET_NO_JOURNAL (2133571416L)
#define EXT2_ET_DIRHASH_UNSUPP (2133571417L)
#define EXT2_ET_BAD_EA_BLOCK_NUM (2133571418L)
#define EXT2_ET_TOO_MANY_INODES (2133571419L)
#define EXT2_ET_NOT_IMAGE_FILE (2133571420L)
#define EXT2_ET_RES_GDT_BLOCKS (2133571421L)
#define EXT2_ET_RESIZE_INODE_CORRUPT (2133571422L)
#define EXT2_ET_SET_BMAP_NO_IND (2133571423L)
#define EXT2_ET_TDB_SUCCESS (2133571424L)
#define EXT2_ET_TDB_ERR_CORRUPT (2133571425L)
#define EXT2_ET_TDB_ERR_IO (2133571426L)
#define EXT2_ET_TDB_ERR_LOCK (2133571427L)
#define EXT2_ET_TDB_ERR_OOM (2133571428L)
#define EXT2_ET_TDB_ERR_EXISTS (2133571429L)
#define EXT2_ET_TDB_ERR_NOLOCK (2133571430L)
#define EXT2_ET_TDB_ERR_EINVAL (2133571431L)
#define EXT2_ET_TDB_ERR_NOEXIST (2133571432L)
#define EXT2_ET_TDB_ERR_RDONLY (2133571433L)
#define EXT2_ET_DBLIST_EMPTY (2133571434L)
#define EXT2_ET_RO_BLOCK_ITERATE (2133571435L)
#define EXT2_ET_MAGIC_EXTENT_PATH (2133571436L)
#define EXT2_ET_MAGIC_GENERIC_BITMAP64 (2133571437L)
#define EXT2_ET_MAGIC_BLOCK_BITMAP64 (2133571438L)
#define EXT2_ET_MAGIC_INODE_BITMAP64 (2133571439L)
#define EXT2_ET_MAGIC_RESERVED_13 (2133571440L)
#define EXT2_ET_MAGIC_RESERVED_14 (2133571441L)
#define EXT2_ET_MAGIC_RESERVED_15 (2133571442L)
#define EXT2_ET_MAGIC_RESERVED_16 (2133571443L)
#define EXT2_ET_MAGIC_RESERVED_17 (2133571444L)
#define EXT2_ET_MAGIC_RESERVED_18 (2133571445L)
#define EXT2_ET_MAGIC_RESERVED_19 (2133571446L)
#define EXT2_ET_EXTENT_HEADER_BAD (2133571447L)
#define EXT2_ET_EXTENT_INDEX_BAD (2133571448L)
#define EXT2_ET_EXTENT_LEAF_BAD (2133571449L)
#define EXT2_ET_EXTENT_NO_SPACE (2133571450L)
#define EXT2_ET_INODE_NOT_EXTENT (2133571451L)
#define EXT2_ET_EXTENT_NO_NEXT (2133571452L)
#define EXT2_ET_EXTENT_NO_PREV (2133571453L)
#define EXT2_ET_EXTENT_NO_UP (2133571454L)
#define EXT2_ET_EXTENT_NO_DOWN (2133571455L)
#define EXT2_ET_NO_CURRENT_NODE (2133571456L)
#define EXT2_ET_OP_NOT_SUPPORTED (2133571457L)
#define EXT2_ET_CANT_INSERT_EXTENT (2133571458L)
#define EXT2_ET_CANT_SPLIT_EXTENT (2133571459L)
#define EXT2_ET_EXTENT_NOT_FOUND (2133571460L)
#define EXT2_ET_EXTENT_NOT_SUPPORTED (2133571461L)
#define EXT2_ET_EXTENT_INVALID_LENGTH (2133571462L)
#define EXT2_ET_IO_CHANNEL_NO_SUPPORT_64 (2133571463L)
#define EXT2_ET_NO_MTAB_FILE (2133571464L)
#define EXT2_ET_CANT_USE_LEGACY_BITMAPS (2133571465L)
#define EXT2_ET_MMP_MAGIC_INVALID (2133571466L)
#define EXT2_ET_MMP_FAILED (2133571467L)
#define EXT2_ET_MMP_FSCK_ON (2133571468L)
#define EXT2_ET_MMP_BAD_BLOCK (2133571469L)
#define EXT2_ET_MMP_UNKNOWN_SEQ (2133571470L)
#define EXT2_ET_MMP_CHANGE_ABORT (2133571471L)
#define EXT2_ET_MMP_OPEN_DIRECT (2133571472L)
#define EXT2_ET_BAD_DESC_SIZE (2133571473L)
#define EXT2_ET_INODE_CSUM_INVALID (2133571474L)
#define EXT2_ET_INODE_BITMAP_CSUM_INVALID (2133571475L)
#define EXT2_ET_EXTENT_CSUM_INVALID (2133571476L)
#define EXT2_ET_DIR_NO_SPACE_FOR_CSUM (2133571477L)
#define EXT2_ET_DIR_CSUM_INVALID (2133571478L)
#define EXT2_ET_EXT_ATTR_CSUM_INVALID (2133571479L)
#define EXT2_ET_SB_CSUM_INVALID (2133571480L)
#define EXT2_ET_UNKNOWN_CSUM (2133571481L)
#define EXT2_ET_MMP_CSUM_INVALID (2133571482L)
#define EXT2_ET_FILE_EXISTS (2133571483L)
#define EXT2_ET_BLOCK_BITMAP_CSUM_INVALID (2133571484L)
#define EXT2_ET_INLINE_DATA_CANT_ITERATE (2133571485L)
#define EXT2_ET_EA_BAD_NAME_LEN (2133571486L)
#define EXT2_ET_EA_BAD_VALUE_SIZE (2133571487L)
#define EXT2_ET_BAD_EA_HASH (2133571488L)
#define EXT2_ET_BAD_EA_HEADER (2133571489L)
#define EXT2_ET_EA_KEY_NOT_FOUND (2133571490L)
#define EXT2_ET_EA_NO_SPACE (2133571491L)
#define EXT2_ET_MISSING_EA_FEATURE (2133571492L)
#define EXT2_ET_NO_INLINE_DATA (2133571493L)
#define EXT2_ET_INLINE_DATA_NO_BLOCK (2133571494L)
#define EXT2_ET_INLINE_DATA_NO_SPACE (2133571495L)
#define EXT2_ET_MAGIC_EA_HANDLE (2133571496L)
#define EXT2_ET_INODE_IS_GARBAGE (2133571497L)
#define EXT2_ET_EA_BAD_VALUE_OFFSET (2133571498L)
#define EXT2_ET_JOURNAL_FLAGS_WRONG (2133571499L)
#define EXT2_ET_UNDO_FILE_CORRUPT (2133571500L)
#define EXT2_ET_UNDO_FILE_WRONG (2133571501L)
#define EXT2_ET_FILESYSTEM_CORRUPTED (2133571502L)
#define EXT2_ET_BAD_CRC (2133571503L)
#define EXT2_ET_CORRUPT_JOURNAL_SB (2133571504L)
#define EXT2_ET_INODE_CORRUPTED (2133571505L)
#define EXT2_ET_EA_INODE_CORRUPTED (2133571506L)
#define EXT2_ET_NO_GDESC (2133571507L)
#define EXT2_FILSYS_CORRUPTED (2133571508L)
extern const struct error_table et_ext2_error_table;
extern void initialize_ext2_error_table(void);
/* For compatibility with Heimdal */
extern void initialize_ext2_error_table_r(struct et_list **list);
#define ERROR_TABLE_BASE_ext2 (2133571328L)
/* for compatibility with older versions... */
#define init_ext2_err_tbl initialize_ext2_error_table
#define ext2_err_base ERROR_TABLE_BASE_ext2
ext2fs/hashmap.h 0000644 00000002762 15201526705 0007563 0 ustar 00 #ifndef HASHMAP_H
# define HASHMAP_H
# include <stdlib.h>
# include <stdint.h>
#ifndef __GNUC_PREREQ
#if defined(__GNUC__) && defined(__GNUC_MINOR__)
#define __GNUC_PREREQ(maj, min) \
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
#else
#define __GNUC_PREREQ(maj, min) 0
#endif
#endif
struct ext2fs_hashmap {
uint32_t size;
uint32_t(*hash)(const void *key, size_t len);
void(*free)(void*);
struct ext2fs_hashmap_entry *first;
struct ext2fs_hashmap_entry *last;
struct ext2fs_hashmap_entry {
void *data;
const void *key;
size_t key_len;
struct ext2fs_hashmap_entry *next;
struct ext2fs_hashmap_entry *list_next;
struct ext2fs_hashmap_entry *list_prev;
#if __GNUC_PREREQ (4, 8)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
#endif
} *entries[0];
#if __GNUC_PREREQ (4, 8)
#pragma GCC diagnostic pop
#endif
};
struct ext2fs_hashmap *ext2fs_hashmap_create(
uint32_t(*hash_fct)(const void*, size_t),
void(*free_fct)(void*), size_t size);
void ext2fs_hashmap_add(struct ext2fs_hashmap *h, void *data, const void *key,
size_t key_len);
void *ext2fs_hashmap_lookup(struct ext2fs_hashmap *h, const void *key,
size_t key_len);
void *ext2fs_hashmap_iter_in_order(struct ext2fs_hashmap *h,
struct ext2fs_hashmap_entry **it);
void ext2fs_hashmap_del(struct ext2fs_hashmap *h,
struct ext2fs_hashmap_entry *e);
void ext2fs_hashmap_free(struct ext2fs_hashmap *h);
uint32_t ext2fs_djb2_hash(const void *str, size_t size);
#endif /* !HASHMAP_H */
ext2fs/bitops.h 0000644 00000053204 15201526705 0007437 0 ustar 00 /*
* bitops.h --- Bitmap frobbing code. The byte swapping routines are
* also included here.
*
* Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Library
* General Public License, version 2.
* %End-Header%
*/
#ifdef WORDS_BIGENDIAN
#define ext2fs_cpu_to_le64(x) ((__force __le64)ext2fs_swab64((__u64)(x)))
#define ext2fs_le64_to_cpu(x) ext2fs_swab64((__force __u64)(__le64)(x))
#define ext2fs_cpu_to_le32(x) ((__force __le32)ext2fs_swab32((__u32)(x)))
#define ext2fs_le32_to_cpu(x) ext2fs_swab32((__force __u32)(__le32)(x))
#define ext2fs_cpu_to_le16(x) ((__force __le16)ext2fs_swab16((__u16)(x)))
#define ext2fs_le16_to_cpu(x) ext2fs_swab16((__force __u16)(__le16)(x))
#define ext2fs_cpu_to_be64(x) ((__force __be64)(__u64)(x))
#define ext2fs_be64_to_cpu(x) ((__force __u64)(__be64)(x))
#define ext2fs_cpu_to_be32(x) ((__force __be32)(__u32)(x))
#define ext2fs_be32_to_cpu(x) ((__force __u32)(__be32)(x))
#define ext2fs_cpu_to_be16(x) ((__force __be16)(__u16)(x))
#define ext2fs_be16_to_cpu(x) ((__force __u16)(__be16)(x))
#else
#define ext2fs_cpu_to_le64(x) ((__force __le64)(__u64)(x))
#define ext2fs_le64_to_cpu(x) ((__force __u64)(__le64)(x))
#define ext2fs_cpu_to_le32(x) ((__force __le32)(__u32)(x))
#define ext2fs_le32_to_cpu(x) ((__force __u32)(__le32)(x))
#define ext2fs_cpu_to_le16(x) ((__force __le16)(__u16)(x))
#define ext2fs_le16_to_cpu(x) ((__force __u16)(__le16)(x))
#define ext2fs_cpu_to_be64(x) ((__force __be64)ext2fs_swab64((__u64)(x)))
#define ext2fs_be64_to_cpu(x) ext2fs_swab64((__force __u64)(__be64)(x))
#define ext2fs_cpu_to_be32(x) ((__force __be32)ext2fs_swab32((__u32)(x)))
#define ext2fs_be32_to_cpu(x) ext2fs_swab32((__force __u32)(__be32)(x))
#define ext2fs_cpu_to_be16(x) ((__force __be16)ext2fs_swab16((__u16)(x)))
#define ext2fs_be16_to_cpu(x) ext2fs_swab16((__force __u16)(__be16)(x))
#endif
/*
* EXT2FS bitmap manipulation routines.
*/
/* Support for sending warning messages from the inline subroutines */
extern const char *ext2fs_block_string;
extern const char *ext2fs_inode_string;
extern const char *ext2fs_mark_string;
extern const char *ext2fs_unmark_string;
extern const char *ext2fs_test_string;
extern void ext2fs_warn_bitmap(errcode_t errcode, unsigned long arg,
const char *description);
extern void ext2fs_warn_bitmap2(ext2fs_generic_bitmap bitmap,
int code, unsigned long arg);
#ifdef NO_INLINE_FUNCS
extern void ext2fs_fast_set_bit(unsigned int nr,void * addr);
extern void ext2fs_fast_clear_bit(unsigned int nr, void * addr);
extern void ext2fs_fast_set_bit64(__u64 nr,void * addr);
extern void ext2fs_fast_clear_bit64(__u64 nr, void * addr);
extern __u16 ext2fs_swab16(__u16 val);
extern __u32 ext2fs_swab32(__u32 val);
extern __u64 ext2fs_swab64(__u64 val);
extern int ext2fs_mark_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block);
extern int ext2fs_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
blk_t block);
extern int ext2fs_test_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block);
extern int ext2fs_mark_inode_bitmap(ext2fs_inode_bitmap bitmap, ext2_ino_t inode);
extern int ext2fs_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode);
extern int ext2fs_test_inode_bitmap(ext2fs_inode_bitmap bitmap, ext2_ino_t inode);
extern void ext2fs_fast_mark_block_bitmap(ext2fs_block_bitmap bitmap,
blk_t block);
extern void ext2fs_fast_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
blk_t block);
extern int ext2fs_fast_test_block_bitmap(ext2fs_block_bitmap bitmap,
blk_t block);
extern void ext2fs_fast_mark_inode_bitmap(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode);
extern void ext2fs_fast_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode);
extern int ext2fs_fast_test_inode_bitmap(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode);
extern blk_t ext2fs_get_block_bitmap_start(ext2fs_block_bitmap bitmap);
extern ext2_ino_t ext2fs_get_inode_bitmap_start(ext2fs_inode_bitmap bitmap);
extern blk_t ext2fs_get_block_bitmap_end(ext2fs_block_bitmap bitmap);
extern ext2_ino_t ext2fs_get_inode_bitmap_end(ext2fs_inode_bitmap bitmap);
extern void ext2fs_fast_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
blk_t block, int num);
extern void ext2fs_fast_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
blk_t block, int num);
extern int ext2fs_fast_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
blk_t block, int num);
#endif
/* These functions routines moved to gen_bitmap.c */
extern void ext2fs_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
blk_t block, int num);
extern void ext2fs_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
blk_t block, int num);
extern int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
blk_t block, int num);
extern int ext2fs_test_inode_bitmap_range(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode, int num);
extern int ext2fs_mark_generic_bitmap(ext2fs_generic_bitmap bitmap,
__u32 bitno);
extern int ext2fs_unmark_generic_bitmap(ext2fs_generic_bitmap bitmap,
blk_t bitno);
extern int ext2fs_test_generic_bitmap(ext2fs_generic_bitmap bitmap,
blk_t bitno);
extern int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
blk_t block, int num);
extern void ext2fs_set_bitmap_padding(ext2fs_generic_bitmap map);
extern __u32 ext2fs_get_generic_bitmap_start(ext2fs_generic_bitmap bitmap);
extern __u32 ext2fs_get_generic_bitmap_end(ext2fs_generic_bitmap bitmap);
/* 64-bit versions */
#ifdef NO_INLINE_FUNCS
extern int ext2fs_mark_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t block);
extern int ext2fs_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t block);
extern int ext2fs_test_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t block);
extern int ext2fs_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode);
extern int ext2fs_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode);
extern int ext2fs_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode);
extern void ext2fs_fast_mark_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t block);
extern void ext2fs_fast_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t block);
extern int ext2fs_fast_test_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t block);
extern void ext2fs_fast_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode);
extern void ext2fs_fast_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode);
extern int ext2fs_fast_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode);
extern errcode_t ext2fs_find_first_zero_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t start,
blk64_t end,
blk64_t *out);
extern errcode_t ext2fs_find_first_zero_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t start,
ext2_ino_t end,
ext2_ino_t *out);
extern errcode_t ext2fs_find_first_set_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t start,
blk64_t end,
blk64_t *out);
extern errcode_t ext2fs_find_first_set_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t start,
ext2_ino_t end,
ext2_ino_t *out);
extern blk64_t ext2fs_get_block_bitmap_start2(ext2fs_block_bitmap bitmap);
extern ext2_ino_t ext2fs_get_inode_bitmap_start2(ext2fs_inode_bitmap bitmap);
extern blk64_t ext2fs_get_block_bitmap_end2(ext2fs_block_bitmap bitmap);
extern ext2_ino_t ext2fs_get_inode_bitmap_end2(ext2fs_inode_bitmap bitmap);
extern int ext2fs_fast_test_block_bitmap_range2(ext2fs_block_bitmap bitmap,
blk64_t block,
unsigned int num);
extern void ext2fs_fast_mark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
blk64_t block,
unsigned int num);
extern void ext2fs_fast_unmark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
blk64_t block,
unsigned int num);
#endif
/* These routines moved to gen_bitmap64.c */
extern void ext2fs_clear_generic_bmap(ext2fs_generic_bitmap bitmap);
extern errcode_t ext2fs_compare_generic_bmap(errcode_t neq,
ext2fs_generic_bitmap bm1,
ext2fs_generic_bitmap bm2);
extern void ext2fs_set_generic_bmap_padding(ext2fs_generic_bitmap bmap);
extern int ext2fs_mark_generic_bmap(ext2fs_generic_bitmap bitmap,
blk64_t bitno);
extern int ext2fs_unmark_generic_bmap(ext2fs_generic_bitmap bitmap,
blk64_t bitno);
extern int ext2fs_test_generic_bmap(ext2fs_generic_bitmap bitmap,
blk64_t bitno);
extern int ext2fs_test_block_bitmap_range2(ext2fs_block_bitmap bitmap,
blk64_t block, unsigned int num);
extern __u64 ext2fs_get_generic_bmap_start(ext2fs_generic_bitmap bitmap);
extern __u64 ext2fs_get_generic_bmap_end(ext2fs_generic_bitmap bitmap);
extern int ext2fs_test_block_bitmap_range2(ext2fs_block_bitmap bitmap,
blk64_t block, unsigned int num);
extern void ext2fs_mark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
blk64_t block, unsigned int num);
extern void ext2fs_unmark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
blk64_t block, unsigned int num);
extern errcode_t ext2fs_find_first_zero_generic_bmap(ext2fs_generic_bitmap bitmap,
__u64 start, __u64 end,
__u64 *out);
extern errcode_t ext2fs_find_first_set_generic_bmap(ext2fs_generic_bitmap bitmap,
__u64 start, __u64 end,
__u64 *out);
/*
* The inline routines themselves...
*
* If NO_INLINE_FUNCS is defined, then we won't try to do inline
* functions at all; they will be included as normal functions in
* inline.c
*/
#ifdef NO_INLINE_FUNCS
#if (defined(__GNUC__) && (defined(__i386__) || defined(__i486__) || \
defined(__i586__)))
/* This prevents bitops.c from trying to include the C */
/* function version of these functions */
#define _EXT2_HAVE_ASM_BITOPS_
#endif
#endif /* NO_INLINE_FUNCS */
#if (defined(INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS))
#ifdef INCLUDE_INLINE_FUNCS
#if (__STDC_VERSION__ >= 199901L)
#define _INLINE_ extern inline
#else
#define _INLINE_ inline
#endif
#else /* !INCLUDE_INLINE FUNCS */
#if (__STDC_VERSION__ >= 199901L)
#define _INLINE_ inline
#else /* not C99 */
#ifdef __GNUC__
#define _INLINE_ extern __inline__
#else /* For Watcom C */
#define _INLINE_ extern inline
#endif /* __GNUC__ */
#endif /* __STDC_VERSION__ >= 199901L */
#endif /* INCLUDE_INLINE_FUNCS */
/*
* Fast bit set/clear functions that doesn't need to return the
* previous bit value.
*/
_INLINE_ void ext2fs_fast_set_bit(unsigned int nr,void * addr)
{
unsigned char *ADDR = (unsigned char *) addr;
ADDR += nr >> 3;
*ADDR |= (unsigned char) (1 << (nr & 0x07));
}
_INLINE_ void ext2fs_fast_clear_bit(unsigned int nr, void * addr)
{
unsigned char *ADDR = (unsigned char *) addr;
ADDR += nr >> 3;
*ADDR &= (unsigned char) ~(1 << (nr & 0x07));
}
_INLINE_ void ext2fs_fast_set_bit64(__u64 nr, void * addr)
{
unsigned char *ADDR = (unsigned char *) addr;
ADDR += nr >> 3;
*ADDR |= (unsigned char) (1 << (nr & 0x07));
}
_INLINE_ void ext2fs_fast_clear_bit64(__u64 nr, void * addr)
{
unsigned char *ADDR = (unsigned char *) addr;
ADDR += nr >> 3;
*ADDR &= (unsigned char) ~(1 << (nr & 0x07));
}
#if ((defined __GNUC__) && !defined(_EXT2_USE_C_VERSIONS_) && \
(defined(__i386__) || defined(__i486__) || defined(__i586__)))
#define _EXT2_HAVE_ASM_BITOPS_
#define _EXT2_HAVE_ASM_SWAB_
/*
* These are done by inline assembly for speed reasons.....
*
* All bitoperations return 0 if the bit was cleared before the
* operation and != 0 if it was not. Bit 0 is the LSB of addr; bit 32
* is the LSB of (addr+1).
*/
/*
* Some hacks to defeat gcc over-optimizations..
*/
struct __dummy_h { unsigned long a[100]; };
#define EXT2FS_ADDR (*(struct __dummy_h *) addr)
#define EXT2FS_CONST_ADDR (*(const struct __dummy_h *) addr)
_INLINE_ int ext2fs_set_bit(unsigned int nr, void * addr)
{
int oldbit;
addr = (void *) (((unsigned char *) addr) + (nr >> 3));
__asm__ __volatile__("btsl %2,%1\n\tsbbl %0,%0"
:"=r" (oldbit),"+m" (EXT2FS_ADDR)
:"r" (nr & 7));
return oldbit;
}
_INLINE_ int ext2fs_clear_bit(unsigned int nr, void * addr)
{
int oldbit;
addr = (void *) (((unsigned char *) addr) + (nr >> 3));
__asm__ __volatile__("btrl %2,%1\n\tsbbl %0,%0"
:"=r" (oldbit),"+m" (EXT2FS_ADDR)
:"r" (nr & 7));
return oldbit;
}
_INLINE_ int ext2fs_test_bit(unsigned int nr, const void * addr)
{
int oldbit;
addr = (const void *) (((const unsigned char *) addr) + (nr >> 3));
__asm__ __volatile__("btl %2,%1\n\tsbbl %0,%0"
:"=r" (oldbit)
:"m" (EXT2FS_CONST_ADDR),"r" (nr & 7));
return oldbit;
}
_INLINE_ __u32 ext2fs_swab32(__u32 val)
{
#ifdef EXT2FS_REQUIRE_486
__asm__("bswap %0" : "=r" (val) : "0" (val));
#else
__asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */
"rorl $16,%0\n\t" /* swap words */
"xchgb %b0,%h0" /* swap higher bytes */
:"=q" (val)
: "0" (val));
#endif
return val;
}
_INLINE_ __u16 ext2fs_swab16(__u16 val)
{
__asm__("xchgb %b0,%h0" /* swap bytes */ \
: "=q" (val) \
: "0" (val)); \
return val;
}
#undef EXT2FS_ADDR
#endif /* i386 */
#if !defined(_EXT2_HAVE_ASM_SWAB_)
_INLINE_ __u16 ext2fs_swab16(__u16 val)
{
return (val >> 8) | (__u16) (val << 8);
}
_INLINE_ __u32 ext2fs_swab32(__u32 val)
{
return ((val>>24) | ((val>>8)&0xFF00) |
((val<<8)&0xFF0000) | (val<<24));
}
#endif /* !_EXT2_HAVE_ASM_SWAB */
_INLINE_ __u64 ext2fs_swab64(__u64 val)
{
return (ext2fs_swab32((__u32) (val >> 32)) |
(((__u64)ext2fs_swab32(val & 0xFFFFFFFFUL)) << 32));
}
_INLINE_ int ext2fs_mark_block_bitmap(ext2fs_block_bitmap bitmap,
blk_t block)
{
return ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap,
block);
}
_INLINE_ int ext2fs_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
blk_t block)
{
return ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap,
block);
}
_INLINE_ int ext2fs_test_block_bitmap(ext2fs_block_bitmap bitmap,
blk_t block)
{
return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap,
block);
}
_INLINE_ int ext2fs_mark_inode_bitmap(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode)
{
return ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap,
inode);
}
_INLINE_ int ext2fs_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode)
{
return ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap,
inode);
}
_INLINE_ int ext2fs_test_inode_bitmap(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode)
{
return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap,
inode);
}
_INLINE_ void ext2fs_fast_mark_block_bitmap(ext2fs_block_bitmap bitmap,
blk_t block)
{
ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap, block);
}
_INLINE_ void ext2fs_fast_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
blk_t block)
{
ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap, block);
}
_INLINE_ int ext2fs_fast_test_block_bitmap(ext2fs_block_bitmap bitmap,
blk_t block)
{
return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap,
block);
}
_INLINE_ void ext2fs_fast_mark_inode_bitmap(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode)
{
ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap, inode);
}
_INLINE_ void ext2fs_fast_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode)
{
ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap, inode);
}
_INLINE_ int ext2fs_fast_test_inode_bitmap(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode)
{
return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap,
inode);
}
_INLINE_ blk_t ext2fs_get_block_bitmap_start(ext2fs_block_bitmap bitmap)
{
return ext2fs_get_generic_bitmap_start((ext2fs_generic_bitmap) bitmap);
}
_INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_start(ext2fs_inode_bitmap bitmap)
{
return ext2fs_get_generic_bitmap_start((ext2fs_generic_bitmap) bitmap);
}
_INLINE_ blk_t ext2fs_get_block_bitmap_end(ext2fs_block_bitmap bitmap)
{
return ext2fs_get_generic_bitmap_end((ext2fs_generic_bitmap) bitmap);
}
_INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_end(ext2fs_inode_bitmap bitmap)
{
return ext2fs_get_generic_bitmap_end((ext2fs_generic_bitmap) bitmap);
}
_INLINE_ int ext2fs_fast_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
blk_t block, int num)
{
return ext2fs_test_block_bitmap_range(bitmap, block, num);
}
_INLINE_ void ext2fs_fast_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
blk_t block, int num)
{
ext2fs_mark_block_bitmap_range(bitmap, block, num);
}
_INLINE_ void ext2fs_fast_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
blk_t block, int num)
{
ext2fs_unmark_block_bitmap_range(bitmap, block, num);
}
/* 64-bit versions */
_INLINE_ int ext2fs_mark_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t block)
{
return ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap,
block);
}
_INLINE_ int ext2fs_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t block)
{
return ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap, block);
}
_INLINE_ int ext2fs_test_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t block)
{
return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap,
block);
}
_INLINE_ int ext2fs_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode)
{
return ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap,
inode);
}
_INLINE_ int ext2fs_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode)
{
return ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap,
inode);
}
_INLINE_ int ext2fs_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode)
{
return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap,
inode);
}
_INLINE_ void ext2fs_fast_mark_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t block)
{
ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap, block);
}
_INLINE_ void ext2fs_fast_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t block)
{
ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap, block);
}
_INLINE_ int ext2fs_fast_test_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t block)
{
return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap,
block);
}
_INLINE_ void ext2fs_fast_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode)
{
ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap, inode);
}
_INLINE_ void ext2fs_fast_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode)
{
ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap, inode);
}
_INLINE_ int ext2fs_fast_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode)
{
return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap,
inode);
}
_INLINE_ errcode_t ext2fs_find_first_zero_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t start,
blk64_t end,
blk64_t *out)
{
__u64 o;
errcode_t rv;
rv = ext2fs_find_first_zero_generic_bmap((ext2fs_generic_bitmap) bitmap,
start, end, &o);
if (!rv)
*out = o;
return rv;
}
_INLINE_ errcode_t ext2fs_find_first_zero_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t start,
ext2_ino_t end,
ext2_ino_t *out)
{
__u64 o;
errcode_t rv;
rv = ext2fs_find_first_zero_generic_bmap((ext2fs_generic_bitmap) bitmap,
start, end, &o);
if (!rv)
*out = (ext2_ino_t) o;
return rv;
}
_INLINE_ errcode_t ext2fs_find_first_set_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t start,
blk64_t end,
blk64_t *out)
{
__u64 o;
errcode_t rv;
rv = ext2fs_find_first_set_generic_bmap((ext2fs_generic_bitmap) bitmap,
start, end, &o);
if (!rv)
*out = o;
return rv;
}
_INLINE_ errcode_t ext2fs_find_first_set_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t start,
ext2_ino_t end,
ext2_ino_t *out)
{
__u64 o;
errcode_t rv;
rv = ext2fs_find_first_set_generic_bmap((ext2fs_generic_bitmap) bitmap,
start, end, &o);
if (!rv)
*out = (ext2_ino_t) o;
return rv;
}
_INLINE_ blk64_t ext2fs_get_block_bitmap_start2(ext2fs_block_bitmap bitmap)
{
return ext2fs_get_generic_bmap_start((ext2fs_generic_bitmap) bitmap);
}
_INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_start2(ext2fs_inode_bitmap bitmap)
{
return (ext2_ino_t) ext2fs_get_generic_bmap_start((ext2fs_generic_bitmap) bitmap);
}
_INLINE_ blk64_t ext2fs_get_block_bitmap_end2(ext2fs_block_bitmap bitmap)
{
return ext2fs_get_generic_bmap_end((ext2fs_generic_bitmap) bitmap);
}
_INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_end2(ext2fs_inode_bitmap bitmap)
{
return (ext2_ino_t) ext2fs_get_generic_bmap_end((ext2fs_generic_bitmap) bitmap);
}
_INLINE_ int ext2fs_fast_test_block_bitmap_range2(ext2fs_block_bitmap bitmap,
blk64_t block,
unsigned int num)
{
return ext2fs_test_block_bitmap_range2(bitmap, block, num);
}
_INLINE_ void ext2fs_fast_mark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
blk64_t block,
unsigned int num)
{
ext2fs_mark_block_bitmap_range2(bitmap, block, num);
}
_INLINE_ void ext2fs_fast_unmark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
blk64_t block,
unsigned int num)
{
ext2fs_unmark_block_bitmap_range2(bitmap, block, num);
}
#undef _INLINE_
#endif
#ifndef _EXT2_HAVE_ASM_BITOPS_
extern int ext2fs_set_bit(unsigned int nr,void * addr);
extern int ext2fs_clear_bit(unsigned int nr, void * addr);
extern int ext2fs_test_bit(unsigned int nr, const void * addr);
#endif
extern int ext2fs_set_bit64(__u64 nr,void * addr);
extern int ext2fs_clear_bit64(__u64 nr, void * addr);
extern int ext2fs_test_bit64(__u64 nr, const void * addr);
extern unsigned int ext2fs_bitcount(const void *addr, unsigned int nbytes);
ext2fs/ext3_extents.h 0000644 00000010716 15201526705 0010575 0 ustar 00 /*
* Copyright (c) 2003,2004 Cluster File Systems, Inc, info@clusterfs.com
* Written by Alex Tomas <alex@clusterfs.com>
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Library
* General Public License, version 2.
* %End-Header%
*/
#ifndef _LINUX_EXT3_EXTENTS
#define _LINUX_EXT3_EXTENTS
/*
* ext3_inode has i_block array (total 60 bytes)
* first 4 bytes are used to store:
* - tree depth (0 mean there is no tree yet. all extents in the inode)
* - number of alive extents in the inode
*/
/*
* This is extent tail on-disk structure.
* All other extent structures are 12 bytes long. It turns out that
* block_size % 12 >= 4 for at least all powers of 2 greater than 512, which
* covers all valid ext4 block sizes. Therefore, this tail structure can be
* crammed into the end of the block without having to rebalance the tree.
*/
struct ext3_extent_tail {
__le32 et_checksum; /* crc32c(uuid+inum+extent_block) */
};
/*
* this is extent on-disk structure
* it's used at the bottom of the tree
*/
struct ext3_extent {
__le32 ee_block; /* first logical block extent covers */
__le16 ee_len; /* number of blocks covered by extent */
__le16 ee_start_hi; /* high 16 bits of physical block */
__le32 ee_start; /* low 32 bigs of physical block */
};
/*
* this is index on-disk structure
* it's used at all the levels, but the bottom
*/
struct ext3_extent_idx {
__le32 ei_block; /* index covers logical blocks from 'block' */
__le32 ei_leaf; /* pointer to the physical block of the next *
* level. leaf or next index could bet here */
__le16 ei_leaf_hi; /* high 16 bits of physical block */
__le16 ei_unused;
};
/*
* each block (leaves and indexes), even inode-stored has header
*/
struct ext3_extent_header {
__le16 eh_magic; /* probably will support different formats */
__le16 eh_entries; /* number of valid entries */
__le16 eh_max; /* capacity of store in entries */
__le16 eh_depth; /* has tree real underlying blocks? */
__le32 eh_generation; /* generation of the tree */
};
#define EXT3_EXT_MAGIC 0xf30a
/*
* array of ext3_ext_path contains path to some extent
* creation/lookup routines use it for traversal/splitting/etc
* truncate uses it to simulate recursive walking
*/
struct ext3_ext_path {
__u32 p_block;
__u16 p_depth;
struct ext3_extent *p_ext;
struct ext3_extent_idx *p_idx;
struct ext3_extent_header *p_hdr;
struct buffer_head *p_bh;
};
/*
* EXT_INIT_MAX_LEN is the maximum number of blocks we can have in an
* initialized extent. This is 2^15 and not (2^16 - 1), since we use the
* MSB of ee_len field in the extent datastructure to signify if this
* particular extent is an initialized extent or an uninitialized (i.e.
* preallocated).
* EXT_UNINIT_MAX_LEN is the maximum number of blocks we can have in an
* uninitialized extent.
* If ee_len is <= 0x8000, it is an initialized extent. Otherwise, it is an
* uninitialized one. In other words, if MSB of ee_len is set, it is an
* uninitialized extent with only one special scenario when ee_len = 0x8000.
* In this case we can not have an uninitialized extent of zero length and
* thus we make it as a special case of initialized extent with 0x8000 length.
* This way we get better extent-to-group alignment for initialized extents.
* Hence, the maximum number of blocks we can have in an *initialized*
* extent is 2^15 (32768) and in an *uninitialized* extent is 2^15-1 (32767).
*/
#define EXT_INIT_MAX_LEN (1UL << 15)
#define EXT_UNINIT_MAX_LEN (EXT_INIT_MAX_LEN - 1)
#define EXT_MAX_EXTENT_LBLK (((__u64) 1 << 32) - 1)
#define EXT_MAX_EXTENT_PBLK (((__u64) 1 << 48) - 1)
#define EXT_FIRST_EXTENT(__hdr__) \
((struct ext3_extent *) (((char *) (__hdr__)) + \
sizeof(struct ext3_extent_header)))
#define EXT_FIRST_INDEX(__hdr__) \
((struct ext3_extent_idx *) (((char *) (__hdr__)) + \
sizeof(struct ext3_extent_header)))
#define EXT_HAS_FREE_INDEX(__path__) \
(ext2fs_le16_to_cpu((__path__)->p_hdr->eh_entries) < \
ext2fs_le16_to_cpu((__path__)->p_hdr->eh_max))
#define EXT_LAST_EXTENT(__hdr__) \
(EXT_FIRST_EXTENT((__hdr__)) + \
ext2fs_le16_to_cpu((__hdr__)->eh_entries) - 1)
#define EXT_LAST_INDEX(__hdr__) \
(EXT_FIRST_INDEX((__hdr__)) + \
ext2fs_le16_to_cpu((__hdr__)->eh_entries) - 1)
#define EXT_MAX_EXTENT(__hdr__) \
(EXT_FIRST_EXTENT((__hdr__)) + \
ext2fs_le16_to_cpu((__hdr__)->eh_max) - 1)
#define EXT_MAX_INDEX(__hdr__) \
(EXT_FIRST_INDEX((__hdr__)) + \
ext2fs_le16_to_cpu((__hdr__)->eh_max) - 1)
#endif /* _LINUX_EXT3_EXTENTS */
crypt.h 0000644 00000021636 15201526705 0006071 0 ustar 00 /* High-level libcrypt interfaces.
Copyright (C) 1991-2017 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation; either version 2.1 of
the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, see
<https://www.gnu.org/licenses/>. */
#ifndef _CRYPT_H
#define _CRYPT_H 1
#include <sys/cdefs.h>
__BEGIN_DECLS
/* The strings returned by crypt, crypt_r, crypt_rn, and crypt_ra will
be no longer than this, counting the terminating NUL. (Existing
algorithms all produce much shorter strings, but we have reserved
generous space for future expansion.) This is NOT the appropriate
size to use in allocating the buffer supplied to crypt_rn; use
sizeof (struct crypt_data) instead. */
#define CRYPT_OUTPUT_SIZE 384
/* Passphrases longer than this (counting the terminating NUL) are not
supported. Note that some hash algorithms have lower limits. */
#define CRYPT_MAX_PASSPHRASE_SIZE 512
/* The strings returned by crypt_gensalt, crypt_gensalt_rn, and
crypt_gensalt_ra will be no longer than this. This IS the
appropriate size to use when allocating the buffer supplied to
crypt_gensalt_rn. (Again, existing algorithms all produce
much shorter strings, but we have reserved generous space for
future expansion.) */
#define CRYPT_GENSALT_OUTPUT_SIZE 192
/* One-way hash the passphrase PHRASE as specified by SETTING, and
return a string suitable for storage in a Unix-style "passwd" file.
If SETTING is a previously hashed passphrase, the string returned
will be equal to SETTING if and only if PHRASE is the same as the
passphrase that was previously hashed. See the documentation for
other ways to use this function.
The string returned by this function is stored in a statically-
allocated buffer, and will be overwritten if the function is called
again. It is not safe to call this function from multiple threads
concurrently.
If an error occurs (such as SETTING being nonsense or unsupported)
the string returned will begin with '*', and will not be equal to
SETTING nor to any valid hashed passphrase. Otherwise, the string
will not begin with '*'. */
extern char *crypt (const char *__phrase, const char *__setting)
__THROW __nonnull ((1, 2));
/* These sizes are chosen to make sizeof (struct crypt_data) add up to
exactly 32768 bytes. */
#define CRYPT_DATA_RESERVED_SIZE 767
#define CRYPT_DATA_INTERNAL_SIZE 30720
/* Memory area used by crypt_r. */
struct crypt_data
{
/* crypt_r writes the hashed password to this field of its 'data'
argument. crypt_rn and crypt_ra do the same, treating the
untyped data area they are supplied with as this struct. */
char output[CRYPT_OUTPUT_SIZE];
/* Applications are encouraged, but not required, to use this field
to store the "setting" string that must be passed to crypt_*.
Future extensions to the API may make this more ergonomic.
A valid "setting" is either previously hashed password or the
string produced by one of the crypt_gensalt functions; see the
crypt_gensalt documentation for further details. */
char setting[CRYPT_OUTPUT_SIZE];
/* Applications are encouraged, but not required, to use this field
to store the unhashed passphrase they will pass to crypt_*.
Future extensions to the API may make this more ergonomic. */
char input[CRYPT_MAX_PASSPHRASE_SIZE];
/* Reserved for future application-visible fields. For maximum
forward compatibility, applications should set this field to all
bytes zero before calling crypt_r, crypt_rn, or crypt_ra for the
first time with a just-allocated 'struct crypt_data'. Future
extensions to the API may make this more ergonomic. */
char reserved[CRYPT_DATA_RESERVED_SIZE];
/* This field should be set to 0 before calling crypt_r, crypt_rn,
or crypt_ra for the first time with a just-allocated
'struct crypt_data'. This is not required if crypt_ra is allowed
to do the allocation itself (i.e. if the *DATA argument is a null
pointer). Future extensions to the API may make this more ergonomic. */
char initialized;
/* Scratch space used internally. Applications should not read or
write this field. All data written to this area is erased before
returning from the library. */
char internal[CRYPT_DATA_INTERNAL_SIZE];
};
/* Thread-safe version of crypt. Instead of writing to a static
storage area, the string returned by this function will be within
DATA->output. Otherwise, behaves exactly the same as crypt. */
extern char *crypt_r (const char *__phrase, const char *__setting,
struct crypt_data *__restrict __data)
__THROW __nonnull ((1, 2, 3));
/* Another thread-safe version of crypt. Instead of writing to a
static storage area, the string returned by this function will be
somewhere within the space provided at DATA, which is of length SIZE
bytes. SIZE must be at least sizeof (struct crypt_data).
Also, if an error occurs, this function returns a null pointer,
not a special string. (However, the string returned on success
still will never begin with '*'.) */
extern char *crypt_rn (const char *__phrase, const char *__setting,
void *__data, int __size)
__THROW __nonnull ((1, 2, 3));
/* Yet a third thread-safe version of crypt; this one works like
getline(3). *DATA must be either 0 or a pointer to memory
allocated by malloc, and *SIZE must be the size of the allocation.
This space will be allocated or reallocated as necessary and the
values updated. The string returned by this function will be
somewhere within the space at *DATA. It is safe to deallocate
this space with free when it is no longer needed.
Like crypt_rn, this function returns a null pointer on failure, not
a special string. */
extern char *crypt_ra (const char *__phrase, const char *__setting,
void **__data, int *__size)
__THROW __nonnull ((1, 2, 3, 4));
/* Generate a string suitable for use as the setting when hashing a
new passphrase. PREFIX controls which hash function will be used,
COUNT controls the computational cost of the hash (for functions
where this is tunable), and RBYTES should point to NRBYTES bytes of
random data. If PREFIX is a null pointer, the current best default
is used; if RBYTES is a null pointer, random data will be retrieved
from the operating system if possible. (Caution: setting PREFIX to
an *empty string* selects the use of the oldest and least secure
hash in the library. Don't do that.)
The string returned is stored in a statically-allocated buffer, and
will be overwritten if the function is called again. It is not
safe to call this function from multiple threads concurrently.
However, within a single thread, it is safe to pass the string as
the SETTING argument to crypt without copying it first; the two
functions use separate buffers.
If an error occurs (e.g. a prefix that does not correspond to a
supported hash function, or an inadequate amount of random data),
this function returns a null pointer. */
extern char *crypt_gensalt (const char *__prefix, unsigned long __count,
const char *__rbytes, int __nrbytes)
__THROW;
/* Thread-safe version of crypt_gensalt; instead of a
statically-allocated buffer, the generated setting string is
written to OUTPUT, which is OUTPUT_SIZE bytes long. OUTPUT_SIZE
must be at least CRYPT_GENSALT_OUTPUT_SIZE (see above).
If an error occurs, this function returns a null pointer and writes
a string that does not correspond to any valid setting into OUTPUT. */
extern char *crypt_gensalt_rn (const char *__prefix, unsigned long __count,
const char *__rbytes, int __nrbytes,
char *__output, int __output_size)
__THROW __nonnull ((5));
/* Another thread-safe version of crypt_gensalt; the generated setting
string is in storage allocated by malloc, and should be deallocated
with free when it is no longer needed. */
extern char *crypt_gensalt_ra (const char *__prefix, unsigned long __count,
const char *__rbytes, int __nrbytes)
__THROW;
/* These macros could be checked by portable users of crypt_gensalt*
functions to find out whether null pointers could be specified
as PREFIX and RBYTES arguments. */
#define CRYPT_GENSALT_IMPLEMENTS_DEFAULT_PREFIX 1
#define CRYPT_GENSALT_IMPLEMENTS_AUTO_ENTROPY 1
__END_DECLS
#endif /* crypt.h */
expat_external.h 0000644 00000013615 15201526705 0007751 0 ustar 00 /*
__ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
| __// \| |_) | (_| | |_
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2000-2004 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2001-2002 Greg Stein <gstein@users.sourceforge.net>
Copyright (c) 2002-2006 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2016 Cristian Rodríguez <crrodriguez@opensuse.org>
Copyright (c) 2016-2019 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Copyright (c) 2018 Yury Gribov <tetra2005@gmail.com>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef Expat_External_INCLUDED
#define Expat_External_INCLUDED 1
/* External API definitions */
/* Expat tries very hard to make the API boundary very specifically
defined. There are two macros defined to control this boundary;
each of these can be defined before including this header to
achieve some different behavior, but doing so it not recommended or
tested frequently.
XMLCALL - The calling convention to use for all calls across the
"library boundary." This will default to cdecl, and
try really hard to tell the compiler that's what we
want.
XMLIMPORT - Whatever magic is needed to note that a function is
to be imported from a dynamically loaded library
(.dll, .so, or .sl, depending on your platform).
The XMLCALL macro was added in Expat 1.95.7. The only one which is
expected to be directly useful in client code is XMLCALL.
Note that on at least some Unix versions, the Expat library must be
compiled with the cdecl calling convention as the default since
system headers may assume the cdecl convention.
*/
#ifndef XMLCALL
# if defined(_MSC_VER)
# define XMLCALL __cdecl
# elif defined(__GNUC__) && defined(__i386) && ! defined(__INTEL_COMPILER)
# define XMLCALL __attribute__((cdecl))
# else
/* For any platform which uses this definition and supports more than
one calling convention, we need to extend this definition to
declare the convention used on that platform, if it's possible to
do so.
If this is the case for your platform, please file a bug report
with information on how to identify your platform via the C
pre-processor and how to specify the same calling convention as the
platform's malloc() implementation.
*/
# define XMLCALL
# endif
#endif /* not defined XMLCALL */
#if ! defined(XML_STATIC) && ! defined(XMLIMPORT)
# ifndef XML_BUILDING_EXPAT
/* using Expat from an application */
# if defined(_MSC_EXTENSIONS) && ! defined(__BEOS__) && ! defined(__CYGWIN__)
# define XMLIMPORT __declspec(dllimport)
# endif
# endif
#endif /* not defined XML_STATIC */
#ifndef XML_ENABLE_VISIBILITY
# define XML_ENABLE_VISIBILITY 0
#endif
#if ! defined(XMLIMPORT) && XML_ENABLE_VISIBILITY
# define XMLIMPORT __attribute__((visibility("default")))
#endif
/* If we didn't define it above, define it away: */
#ifndef XMLIMPORT
# define XMLIMPORT
#endif
#if defined(__GNUC__) \
&& (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))
# define XML_ATTR_MALLOC __attribute__((__malloc__))
#else
# define XML_ATTR_MALLOC
#endif
#if defined(__GNUC__) \
&& ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
# define XML_ATTR_ALLOC_SIZE(x) __attribute__((__alloc_size__(x)))
#else
# define XML_ATTR_ALLOC_SIZE(x)
#endif
#define XMLPARSEAPI(type) XMLIMPORT type XMLCALL
#ifdef __cplusplus
extern "C" {
#endif
#ifdef XML_UNICODE_WCHAR_T
# ifndef XML_UNICODE
# define XML_UNICODE
# endif
# if defined(__SIZEOF_WCHAR_T__) && (__SIZEOF_WCHAR_T__ != 2)
# error "sizeof(wchar_t) != 2; Need -fshort-wchar for both Expat and libc"
# endif
#endif
#ifdef XML_UNICODE /* Information is UTF-16 encoded. */
# ifdef XML_UNICODE_WCHAR_T
typedef wchar_t XML_Char;
typedef wchar_t XML_LChar;
# else
typedef unsigned short XML_Char;
typedef char XML_LChar;
# endif /* XML_UNICODE_WCHAR_T */
#else /* Information is UTF-8 encoded. */
typedef char XML_Char;
typedef char XML_LChar;
#endif /* XML_UNICODE */
#ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */
typedef long long XML_Index;
typedef unsigned long long XML_Size;
#else
typedef long XML_Index;
typedef unsigned long XML_Size;
#endif /* XML_LARGE_SIZE */
#ifdef __cplusplus
}
#endif
#endif /* not Expat_External_INCLUDED */
strings.h 0000644 00000011220 15201526705 0006405 0 ustar 00 /* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef _STRINGS_H
#define _STRINGS_H 1
#include <features.h>
#define __need_size_t
#include <stddef.h>
/* Tell the caller that we provide correct C++ prototypes. */
#if defined __cplusplus && __GNUC_PREREQ (4, 4)
# define __CORRECT_ISO_CPP_STRINGS_H_PROTO
#endif
__BEGIN_DECLS
#if defined __USE_MISC || !defined __USE_XOPEN2K8
/* Compare N bytes of S1 and S2 (same as memcmp). */
extern int bcmp (const void *__s1, const void *__s2, size_t __n)
__THROW __attribute_pure__ __nonnull ((1, 2));
/* Copy N bytes of SRC to DEST (like memmove, but args reversed). */
extern void bcopy (const void *__src, void *__dest, size_t __n)
__THROW __nonnull ((1, 2));
/* Set N bytes of S to 0. */
extern void bzero (void *__s, size_t __n) __THROW __nonnull ((1));
/* Find the first occurrence of C in S (same as strchr). */
# ifdef __CORRECT_ISO_CPP_STRINGS_H_PROTO
extern "C++"
{
extern char *index (char *__s, int __c)
__THROW __asm ("index") __attribute_pure__ __nonnull ((1));
extern const char *index (const char *__s, int __c)
__THROW __asm ("index") __attribute_pure__ __nonnull ((1));
# if defined __OPTIMIZE__
__extern_always_inline char *
index (char *__s, int __c) __THROW
{
return __builtin_index (__s, __c);
}
__extern_always_inline const char *
index (const char *__s, int __c) __THROW
{
return __builtin_index (__s, __c);
}
# endif
}
# else
extern char *index (const char *__s, int __c)
__THROW __attribute_pure__ __nonnull ((1));
# endif
/* Find the last occurrence of C in S (same as strrchr). */
# ifdef __CORRECT_ISO_CPP_STRINGS_H_PROTO
extern "C++"
{
extern char *rindex (char *__s, int __c)
__THROW __asm ("rindex") __attribute_pure__ __nonnull ((1));
extern const char *rindex (const char *__s, int __c)
__THROW __asm ("rindex") __attribute_pure__ __nonnull ((1));
# if defined __OPTIMIZE__
__extern_always_inline char *
rindex (char *__s, int __c) __THROW
{
return __builtin_rindex (__s, __c);
}
__extern_always_inline const char *
rindex (const char *__s, int __c) __THROW
{
return __builtin_rindex (__s, __c);
}
# endif
}
# else
extern char *rindex (const char *__s, int __c)
__THROW __attribute_pure__ __nonnull ((1));
# endif
#endif
#if defined __USE_MISC || !defined __USE_XOPEN2K8 || defined __USE_XOPEN2K8XSI
/* Return the position of the first bit set in I, or 0 if none are set.
The least-significant bit is position 1, the most-significant 32. */
extern int ffs (int __i) __THROW __attribute_const__;
#endif
/* The following two functions are non-standard but necessary for non-32 bit
platforms. */
# ifdef __USE_MISC
extern int ffsl (long int __l) __THROW __attribute_const__;
__extension__ extern int ffsll (long long int __ll)
__THROW __attribute_const__;
# endif
/* Compare S1 and S2, ignoring case. */
extern int strcasecmp (const char *__s1, const char *__s2)
__THROW __attribute_pure__ __nonnull ((1, 2));
/* Compare no more than N chars of S1 and S2, ignoring case. */
extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
__THROW __attribute_pure__ __nonnull ((1, 2));
#ifdef __USE_XOPEN2K8
/* POSIX.1-2008 extended locale interface (see locale.h). */
# include <bits/types/locale_t.h>
/* Compare S1 and S2, ignoring case, using collation rules from LOC. */
extern int strcasecmp_l (const char *__s1, const char *__s2, locale_t __loc)
__THROW __attribute_pure__ __nonnull ((1, 2, 3));
/* Compare no more than N chars of S1 and S2, ignoring case, using
collation rules from LOC. */
extern int strncasecmp_l (const char *__s1, const char *__s2,
size_t __n, locale_t __loc)
__THROW __attribute_pure__ __nonnull ((1, 2, 4));
#endif
__END_DECLS
#if __GNUC_PREREQ (3,4) && __USE_FORTIFY_LEVEL > 0 \
&& defined __fortify_function
/* Functions with security checks. */
# if defined __USE_MISC || !defined __USE_XOPEN2K8
# include <bits/strings_fortified.h>
# endif
#endif
#endif /* strings.h */
gdbm.h 0000644 00000024151 15201526705 0005634 0 ustar 00 /* gdbm.h - The include file for dbm users. -*- c -*- */
/* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson.
Copyright (C) 1990-1991, 1993, 2011, 2016-2018 Free Software
Foundation, Inc.
GDBM is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GDBM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GDBM. If not, see <http://www.gnu.org/licenses/>.
You may contact the author by:
e-mail: phil@cs.wwu.edu
us-mail: Philip A. Nelson
Computer Science Department
Western Washington University
Bellingham, WA 98226
*************************************************************************/
/* Protection for multiple includes. */
#ifndef _GDBM_H_
# define _GDBM_H_
# include <stdio.h>
/* GDBM C++ support */
# if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
# endif
/* Parameters to gdbm_open for READERS, WRITERS, and WRITERS who
can create the database. */
# define GDBM_READER 0 /* A reader. */
# define GDBM_WRITER 1 /* A writer. */
# define GDBM_WRCREAT 2 /* A writer. Create the db if needed. */
# define GDBM_NEWDB 3 /* A writer. Always create a new db. */
# define GDBM_OPENMASK 7 /* Mask for the above. */
# define GDBM_FAST 0x010 /* Write fast! => No fsyncs. OBSOLETE. */
# define GDBM_SYNC 0x020 /* Sync operations to the disk. */
# define GDBM_NOLOCK 0x040 /* Don't do file locking operations. */
# define GDBM_NOMMAP 0x080 /* Don't use mmap(). */
# define GDBM_CLOEXEC 0x100 /* Close the underlying fd on exec(3) */
# define GDBM_BSEXACT 0x200 /* Don't adjust block_size. Bail out with
GDBM_BLOCK_SIZE_ERROR error if unable to
set it. */
# define GDBM_CLOERROR 0x400 /* Only for gdbm_fd_open: close fd on error. */
/* Parameters to gdbm_store for simple insertion or replacement in the
case that the key is already in the database. */
# define GDBM_INSERT 0 /* Never replace old data with new. */
# define GDBM_REPLACE 1 /* Always replace old data with new. */
/* Parameters to gdbm_setopt, specifing the type of operation to perform. */
# define GDBM_SETCACHESIZE 1 /* Set the cache size. */
# define GDBM_FASTMODE 2 /* Toggle fast mode. OBSOLETE. */
# define GDBM_SETSYNCMODE 3 /* Turn on or off sync operations. */
# define GDBM_SETCENTFREE 4 /* Keep all free blocks in the header. */
# define GDBM_SETCOALESCEBLKS 5 /* Attempt to coalesce free blocks. */
# define GDBM_SETMAXMAPSIZE 6 /* Set maximum mapped memory size */
# define GDBM_SETMMAP 7 /* Toggle mmap mode */
/* Compatibility defines: */
# define GDBM_CACHESIZE GDBM_SETCACHESIZE
# define GDBM_SYNCMODE GDBM_SETSYNCMODE
# define GDBM_CENTFREE GDBM_SETCENTFREE
# define GDBM_COALESCEBLKS GDBM_SETCOALESCEBLKS
# define GDBM_GETFLAGS 8 /* Get gdbm_open flags */
# define GDBM_GETMMAP 9 /* Get mmap status */
# define GDBM_GETCACHESIZE 10 /* Get current cache side */
# define GDBM_GETSYNCMODE 11 /* Get synch mode */
# define GDBM_GETCENTFREE 12 /* Get "centfree" status */
# define GDBM_GETCOALESCEBLKS 13 /* Get free block coalesce status */
# define GDBM_GETMAXMAPSIZE 14 /* Get maximum mapped memory size */
# define GDBM_GETDBNAME 15 /* Return database file name */
# define GDBM_GETBLOCKSIZE 16 /* Return block size */
typedef unsigned long long int gdbm_count_t;
/* The data and key structure. */
typedef struct
{
char *dptr;
int dsize;
} datum;
/* A pointer to the GDBM file. */
typedef struct gdbm_file_info *GDBM_FILE;
/* External variable, the gdbm build release string. */
extern const char *gdbm_version;
# define GDBM_VERSION_MAJOR 1
# define GDBM_VERSION_MINOR 18
# define GDBM_VERSION_PATCH 0
extern int const gdbm_version_number[3];
/* GDBM external functions. */
extern GDBM_FILE gdbm_fd_open (int fd, const char *file_name, int block_size,
int flags, void (*fatal_func) (const char *));
extern GDBM_FILE gdbm_open (const char *, int, int, int,
void (*)(const char *));
extern int gdbm_close (GDBM_FILE);
extern int gdbm_store (GDBM_FILE, datum, datum, int);
extern datum gdbm_fetch (GDBM_FILE, datum);
extern int gdbm_delete (GDBM_FILE, datum);
extern datum gdbm_firstkey (GDBM_FILE);
extern datum gdbm_nextkey (GDBM_FILE, datum);
extern int gdbm_reorganize (GDBM_FILE);
extern int gdbm_sync (GDBM_FILE);
extern int gdbm_exists (GDBM_FILE, datum);
extern int gdbm_setopt (GDBM_FILE, int, void *, int);
extern int gdbm_fdesc (GDBM_FILE);
extern int gdbm_export (GDBM_FILE, const char *, int, int);
extern int gdbm_export_to_file (GDBM_FILE dbf, FILE *fp);
extern int gdbm_import (GDBM_FILE, const char *, int);
extern int gdbm_import_from_file (GDBM_FILE dbf, FILE *fp, int flag);
extern int gdbm_count (GDBM_FILE dbf, gdbm_count_t *pcount);
typedef struct gdbm_recovery_s
{
/* Input members.
These are initialized before call to gdbm_recover. The flags argument
specifies which of them are initialized. */
void (*errfun) (void *data, char const *fmt, ...);
void *data;
size_t max_failed_keys;
size_t max_failed_buckets;
size_t max_failures;
/* Output members.
The gdbm_recover function fills these before returning. */
size_t recovered_keys;
size_t recovered_buckets;
size_t failed_keys;
size_t failed_buckets;
size_t duplicate_keys;
char *backup_name;
} gdbm_recovery;
#define GDBM_RCVR_DEFAULT 0x00 /* Default settings */
#define GDBM_RCVR_ERRFUN 0x01 /* errfun is initialized */
#define GDBM_RCVR_MAX_FAILED_KEYS 0x02 /* max_failed_keys is initialized */
#define GDBM_RCVR_MAX_FAILED_BUCKETS 0x04 /* max_failed_buckets is initialized */
#define GDBM_RCVR_MAX_FAILURES 0x08 /* max_failures is initialized */
#define GDBM_RCVR_BACKUP 0x10 /* Keep backup copy of the
original database on success */
#define GDBM_RCVR_FORCE 0x20 /* Force recovery by skipping the
check pass */
extern int gdbm_recover (GDBM_FILE dbf, gdbm_recovery *rcvr, int flags);
#define GDBM_DUMP_FMT_BINARY 0
#define GDBM_DUMP_FMT_ASCII 1
#define GDBM_META_MASK_MODE 0x01
#define GDBM_META_MASK_OWNER 0x02
extern int gdbm_dump (GDBM_FILE, const char *, int fmt, int open_flags,
int mode);
extern int gdbm_dump_to_file (GDBM_FILE, FILE *, int fmt);
extern int gdbm_load (GDBM_FILE *, const char *, int replace,
int meta_flags,
unsigned long *line);
extern int gdbm_load_from_file (GDBM_FILE *, FILE *, int replace,
int meta_flags,
unsigned long *line);
extern int gdbm_copy_meta (GDBM_FILE dst, GDBM_FILE src);
# define GDBM_NO_ERROR 0
# define GDBM_MALLOC_ERROR 1
# define GDBM_BLOCK_SIZE_ERROR 2
# define GDBM_FILE_OPEN_ERROR 3
# define GDBM_FILE_WRITE_ERROR 4
# define GDBM_FILE_SEEK_ERROR 5
# define GDBM_FILE_READ_ERROR 6
# define GDBM_BAD_MAGIC_NUMBER 7
# define GDBM_EMPTY_DATABASE 8
# define GDBM_CANT_BE_READER 9
# define GDBM_CANT_BE_WRITER 10
# define GDBM_READER_CANT_DELETE 11
# define GDBM_READER_CANT_STORE 12
# define GDBM_READER_CANT_REORGANIZE 13
# define GDBM_UNKNOWN_ERROR 14
# define GDBM_ITEM_NOT_FOUND 15
# define GDBM_REORGANIZE_FAILED 16
# define GDBM_CANNOT_REPLACE 17
# define GDBM_ILLEGAL_DATA 18
# define GDBM_OPT_ALREADY_SET 19
# define GDBM_OPT_ILLEGAL 20
# define GDBM_BYTE_SWAPPED 21
# define GDBM_BAD_FILE_OFFSET 22
# define GDBM_BAD_OPEN_FLAGS 23
# define GDBM_FILE_STAT_ERROR 24
# define GDBM_FILE_EOF 25
# define GDBM_NO_DBNAME 26
# define GDBM_ERR_FILE_OWNER 27
# define GDBM_ERR_FILE_MODE 28
# define GDBM_NEED_RECOVERY 29
# define GDBM_BACKUP_FAILED 30
# define GDBM_DIR_OVERFLOW 31
# define GDBM_BAD_BUCKET 32
# define GDBM_BAD_HEADER 33
# define GDBM_BAD_AVAIL 34
# define GDBM_BAD_HASH_TABLE 35
# define GDBM_BAD_DIR_ENTRY 36
# define GDBM_FILE_CLOSE_ERROR 37
# define GDBM_FILE_SYNC_ERROR 38
# define GDBM_FILE_TRUNCATE_ERROR 39
# define _GDBM_MIN_ERRNO 0
# define _GDBM_MAX_ERRNO GDBM_FILE_TRUNCATE_ERROR
/* This one was never used and will be removed in the future */
# define GDBM_UNKNOWN_UPDATE GDBM_UNKNOWN_ERROR
typedef int gdbm_error;
extern int *gdbm_errno_location (void);
#define gdbm_errno (*gdbm_errno_location ())
extern const char * const gdbm_errlist[];
extern int const gdbm_syserr[];
extern gdbm_error gdbm_last_errno (GDBM_FILE dbf);
extern int gdbm_last_syserr (GDBM_FILE dbf);
extern void gdbm_set_errno (GDBM_FILE dbf, gdbm_error ec, int fatal);
extern void gdbm_clear_error (GDBM_FILE dbf);
extern int gdbm_needs_recovery (GDBM_FILE dbf);
extern int gdbm_check_syserr (gdbm_error n);
/* extra prototypes */
extern const char *gdbm_strerror (gdbm_error);
extern const char *gdbm_db_strerror (GDBM_FILE dbf);
extern int gdbm_version_cmp (int const a[], int const b[]);
#if 0
# define GDBM_DEBUG_ENABLE 1
typedef void (*gdbm_debug_printer_t) (char const *, ...);
extern gdbm_debug_printer_t gdbm_debug_printer;
extern int gdbm_debug_flags;
# define GDBM_DEBUG_ERR 0x00000001
# define GDBM_DEBUG_OPEN 0x00000002
# define GDBM_DEBUG_READ 0x00000004
# define GDBM_DEBUG_STORE 0x00000008
# define GDBM_DEBUG_LOOKUP 0x00000010
# define GDBM_DEBUG_ALL 0xffffffff
extern int gdbm_debug_token (char const *tok);
extern void gdbm_debug_parse_state (int (*f) (void *, int, char const *),
void *d);
extern void gdbm_debug_datum (datum dat, char const *pfx);
#endif
# if defined(__cplusplus) || defined(c_plusplus)
}
# endif
#endif
libltdl/lt_system.h 0000644 00000012336 15201526705 0010376 0 ustar 00 /* lt_system.h -- system portability abstraction layer
Copyright (C) 2004, 2007, 2010-2015 Free Software Foundation, Inc.
Written by Gary V. Vaughan, 2004
NOTE: The canonical source of this file is maintained with the
GNU Libtool package. Report bugs to bug-libtool@gnu.org.
GNU Libltdl is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
As a special exception to the GNU Lesser General Public License,
if you distribute this file as part of a program or library that
is built using GNU Libtool, you may include this file under the
same distribution terms that you use for the rest of that program.
GNU Libltdl is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with GNU Libltdl; see the file COPYING.LIB. If not, a
copy can be downloaded from http://www.gnu.org/licenses/lgpl.html,
or obtained by writing to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#if !defined LT_SYSTEM_H
#define LT_SYSTEM_H 1
#include <stddef.h>
#include <stdlib.h>
#include <sys/types.h>
/* Some systems do not define EXIT_*, even with STDC_HEADERS. */
#if !defined EXIT_SUCCESS
# define EXIT_SUCCESS 0
#endif
#if !defined EXIT_FAILURE
# define EXIT_FAILURE 1
#endif
/* Just pick a big number... */
#define LT_FILENAME_MAX 2048
/* Saves on those hard to debug '\0' typos.... */
#define LT_EOS_CHAR '\0'
/* LTDL_BEGIN_C_DECLS should be used at the beginning of your declarations,
so that C++ compilers don't mangle their names. Use LTDL_END_C_DECLS at
the end of C declarations. */
#if defined __cplusplus
# define LT_BEGIN_C_DECLS extern "C" {
# define LT_END_C_DECLS }
#else
# define LT_BEGIN_C_DECLS /* empty */
# define LT_END_C_DECLS /* empty */
#endif
/* LT_STMT_START/END are used to create macros that expand to a
a single compound statement in a portable way. */
#if defined __GNUC__ && !defined __STRICT_ANSI__ && !defined __cplusplus
# define LT_STMT_START (void)(
# define LT_STMT_END )
#else
# if (defined sun || defined __sun__)
# define LT_STMT_START if (1)
# define LT_STMT_END else (void)0
# else
# define LT_STMT_START do
# define LT_STMT_END while (0)
# endif
#endif
/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */
#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
/* DATA imports from DLLs on WIN32 can't be const, because runtime
relocations are performed -- see ld's documentation on pseudo-relocs. */
# define LT_DLSYM_CONST
#elif defined __osf__
/* This system does not cope well with relocations in const data. */
# define LT_DLSYM_CONST
#else
# define LT_DLSYM_CONST const
#endif
/* Canonicalise Windows and Cygwin recognition macros.
To match the values set by recent Cygwin compilers, make sure that if
__CYGWIN__ is defined (after canonicalisation), __WINDOWS__ is NOT! */
#if defined __CYGWIN32__ && !defined __CYGWIN__
# define __CYGWIN__ __CYGWIN32__
#endif
#if defined __CYGWIN__
# if defined __WINDOWS__
# undef __WINDOWS__
# endif
#elif defined _WIN32
# define __WINDOWS__ _WIN32
#elif defined WIN32
# define __WINDOWS__ WIN32
#endif
#if defined __CYGWIN__ && defined __WINDOWS__
# undef __WINDOWS__
#endif
/* DLL building support on win32 hosts; mostly to workaround their
ridiculous implementation of data symbol exporting. */
#if !defined LT_SCOPE
# if defined __WINDOWS__ || defined __CYGWIN__
# if defined DLL_EXPORT /* defined by libtool (if required) */
# define LT_SCOPE extern __declspec(dllexport)
# endif
# if defined LIBLTDL_DLL_IMPORT /* define if linking with this dll */
/* note: cygwin/mingw compilers can rely instead on auto-import */
# define LT_SCOPE extern __declspec(dllimport)
# endif
# endif
# if !defined LT_SCOPE /* static linking or !__WINDOWS__ */
# define LT_SCOPE extern
# endif
#endif
#if defined __WINDOWS__
/* LT_DIRSEP_CHAR is accepted *in addition* to '/' as a directory
separator when it is set. */
# define LT_DIRSEP_CHAR '\\'
# define LT_PATHSEP_CHAR ';'
#else
# define LT_PATHSEP_CHAR ':'
#endif
#if defined _MSC_VER /* Visual Studio */
# define R_OK 4
#endif
/* fopen() mode flags for reading a text file */
#undef LT_READTEXT_MODE
#if defined __WINDOWS__ || defined __CYGWIN__
# define LT_READTEXT_MODE "rt"
#else
# define LT_READTEXT_MODE "r"
#endif
/* The extra indirection to the LT__STR and LT__CONC macros is required so
that if the arguments to LT_STR() (or LT_CONC()) are themselves macros,
they will be expanded before being quoted. */
#ifndef LT_STR
# define LT__STR(arg) #arg
# define LT_STR(arg) LT__STR(arg)
#endif
#ifndef LT_CONC
# define LT__CONC(a, b) a##b
# define LT_CONC(a, b) LT__CONC(a, b)
#endif
#ifndef LT_CONC3
# define LT__CONC3(a, b, c) a##b##c
# define LT_CONC3(a, b, c) LT__CONC3(a, b, c)
#endif
#endif /*!defined LT_SYSTEM_H*/
libltdl/lt_error.h 0000644 00000007077 15201526705 0010211 0 ustar 00 /* lt_error.h -- error propagation interface
Copyright (C) 1999-2001, 2004, 2007, 2011-2015 Free Software
Foundation, Inc.
Written by Thomas Tanner, 1999
NOTE: The canonical source of this file is maintained with the
GNU Libtool package. Report bugs to bug-libtool@gnu.org.
GNU Libltdl is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
As a special exception to the GNU Lesser General Public License,
if you distribute this file as part of a program or library that
is built using GNU Libtool, you may include this file under the
same distribution terms that you use for the rest of that program.
GNU Libltdl is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with GNU Libltdl; see the file COPYING.LIB. If not, a
copy can be downloaded from http://www.gnu.org/licenses/lgpl.html,
or obtained by writing to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/* Only include this header file once. */
#if !defined LT_ERROR_H
#define LT_ERROR_H 1
#include <libltdl/lt_system.h>
LT_BEGIN_C_DECLS
/* Defining error strings alongside their symbolic names in a macro in
this way allows us to expand the macro in different contexts with
confidence that the enumeration of symbolic names will map correctly
onto the table of error strings. \0 is appended to the strings to
expilicitely initialize the string terminator. */
#define lt_dlerror_table \
LT_ERROR(UNKNOWN, "unknown error\0") \
LT_ERROR(DLOPEN_NOT_SUPPORTED, "dlopen support not available\0") \
LT_ERROR(INVALID_LOADER, "invalid loader\0") \
LT_ERROR(INIT_LOADER, "loader initialization failed\0") \
LT_ERROR(REMOVE_LOADER, "loader removal failed\0") \
LT_ERROR(FILE_NOT_FOUND, "file not found\0") \
LT_ERROR(DEPLIB_NOT_FOUND, "dependency library not found\0") \
LT_ERROR(NO_SYMBOLS, "no symbols defined\0") \
LT_ERROR(CANNOT_OPEN, "can't open the module\0") \
LT_ERROR(CANNOT_CLOSE, "can't close the module\0") \
LT_ERROR(SYMBOL_NOT_FOUND, "symbol not found\0") \
LT_ERROR(NO_MEMORY, "not enough memory\0") \
LT_ERROR(INVALID_HANDLE, "invalid module handle\0") \
LT_ERROR(BUFFER_OVERFLOW, "internal buffer overflow\0") \
LT_ERROR(INVALID_ERRORCODE, "invalid errorcode\0") \
LT_ERROR(SHUTDOWN, "library already shutdown\0") \
LT_ERROR(CLOSE_RESIDENT_MODULE, "can't close resident module\0") \
LT_ERROR(INVALID_MUTEX_ARGS, "internal error (code withdrawn)\0")\
LT_ERROR(INVALID_POSITION, "invalid search path insert position\0")\
LT_ERROR(CONFLICTING_FLAGS, "symbol visibility can be global or local\0")
/* Enumerate the symbolic error names. */
enum {
#define LT_ERROR(name, diagnostic) LT_CONC(LT_ERROR_, name),
lt_dlerror_table
#undef LT_ERROR
LT_ERROR_MAX
};
/* Should be max of the error string lengths above (plus one for C++) */
#define LT_ERROR_LEN_MAX (41)
/* These functions are only useful from inside custom module loaders. */
LT_SCOPE int lt_dladderror (const char *diagnostic);
LT_SCOPE int lt_dlseterror (int errorcode);
LT_END_C_DECLS
#endif /*!defined LT_ERROR_H*/
libltdl/lt_dlloader.h 0000644 00000006213 15201526705 0010635 0 ustar 00 /* lt_dlloader.h -- dynamic library loader interface
Copyright (C) 2004, 2007-2008, 2011-2015 Free Software Foundation,
Inc.
Written by Gary V. Vaughan, 2004
NOTE: The canonical source of this file is maintained with the
GNU Libtool package. Report bugs to bug-libtool@gnu.org.
GNU Libltdl is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
As a special exception to the GNU Lesser General Public License,
if you distribute this file as part of a program or library that
is built using GNU Libtool, you may include this file under the
same distribution terms that you use for the rest of that program.
GNU Libltdl is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with GNU Libltdl; see the file COPYING.LIB. If not, a
copy can be downloaded from http://www.gnu.org/licenses/lgpl.html,
or obtained by writing to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#if !defined LT_DLLOADER_H
#define LT_DLLOADER_H 1
#include <libltdl/lt_system.h>
LT_BEGIN_C_DECLS
typedef void * lt_dlloader;
typedef void * lt_module;
typedef void * lt_user_data;
typedef struct lt__advise * lt_dladvise;
/* Function pointer types for module loader vtable entries: */
typedef lt_module lt_module_open (lt_user_data data,
const char *filename,
lt_dladvise advise);
typedef int lt_module_close (lt_user_data data,
lt_module module);
typedef void * lt_find_sym (lt_user_data data, lt_module module,
const char *symbolname);
typedef int lt_dlloader_init (lt_user_data data);
typedef int lt_dlloader_exit (lt_user_data data);
/* Default priority is LT_DLLOADER_PREPEND if none is explicitly given. */
typedef enum {
LT_DLLOADER_PREPEND = 0, LT_DLLOADER_APPEND
} lt_dlloader_priority;
/* This structure defines a module loader, as populated by the get_vtable
entry point of each loader. */
typedef struct {
const char * name;
const char * sym_prefix;
lt_module_open * module_open;
lt_module_close * module_close;
lt_find_sym * find_sym;
lt_dlloader_init * dlloader_init;
lt_dlloader_exit * dlloader_exit;
lt_user_data dlloader_data;
lt_dlloader_priority priority;
} lt_dlvtable;
LT_SCOPE int lt_dlloader_add (const lt_dlvtable *vtable);
LT_SCOPE lt_dlloader lt_dlloader_next (const lt_dlloader loader);
LT_SCOPE lt_dlvtable * lt_dlloader_remove (const char *name);
LT_SCOPE const lt_dlvtable *lt_dlloader_find (const char *name);
LT_SCOPE const lt_dlvtable *lt_dlloader_get (lt_dlloader loader);
/* Type of a function to get a loader's vtable: */
typedef const lt_dlvtable *lt_get_vtable (lt_user_data data);
#ifdef LT_DEBUG_LOADERS
LT_SCOPE void lt_dlloader_dump (void);
#endif
LT_END_C_DECLS
#endif /*!defined LT_DLLOADER_H*/
webp/mux.h 0000644 00000054450 15201526705 0006476 0 ustar 00 // Copyright 2011 Google Inc. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the COPYING file in the root of the source
// tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// -----------------------------------------------------------------------------
//
// RIFF container manipulation and encoding for WebP images.
//
// Authors: Urvang (urvang@google.com)
// Vikas (vikasa@google.com)
#ifndef WEBP_WEBP_MUX_H_
#define WEBP_WEBP_MUX_H_
#include "./mux_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define WEBP_MUX_ABI_VERSION 0x0108 // MAJOR(8b) + MINOR(8b)
//------------------------------------------------------------------------------
// Mux API
//
// This API allows manipulation of WebP container images containing features
// like color profile, metadata, animation.
//
// Code Example#1: Create a WebPMux object with image data, color profile and
// XMP metadata.
/*
int copy_data = 0;
WebPMux* mux = WebPMuxNew();
// ... (Prepare image data).
WebPMuxSetImage(mux, &image, copy_data);
// ... (Prepare ICCP color profile data).
WebPMuxSetChunk(mux, "ICCP", &icc_profile, copy_data);
// ... (Prepare XMP metadata).
WebPMuxSetChunk(mux, "XMP ", &xmp, copy_data);
// Get data from mux in WebP RIFF format.
WebPMuxAssemble(mux, &output_data);
WebPMuxDelete(mux);
// ... (Consume output_data; e.g. write output_data.bytes to file).
WebPDataClear(&output_data);
*/
// Code Example#2: Get image and color profile data from a WebP file.
/*
int copy_data = 0;
// ... (Read data from file).
WebPMux* mux = WebPMuxCreate(&data, copy_data);
WebPMuxGetFrame(mux, 1, &image);
// ... (Consume image; e.g. call WebPDecode() to decode the data).
WebPMuxGetChunk(mux, "ICCP", &icc_profile);
// ... (Consume icc_data).
WebPMuxDelete(mux);
free(data);
*/
// Note: forward declaring enumerations is not allowed in (strict) C and C++,
// the types are left here for reference.
// typedef enum WebPMuxError WebPMuxError;
// typedef enum WebPChunkId WebPChunkId;
typedef struct WebPMux WebPMux; // main opaque object.
typedef struct WebPMuxFrameInfo WebPMuxFrameInfo;
typedef struct WebPMuxAnimParams WebPMuxAnimParams;
typedef struct WebPAnimEncoderOptions WebPAnimEncoderOptions;
// Error codes
typedef enum WebPMuxError {
WEBP_MUX_OK = 1,
WEBP_MUX_NOT_FOUND = 0,
WEBP_MUX_INVALID_ARGUMENT = -1,
WEBP_MUX_BAD_DATA = -2,
WEBP_MUX_MEMORY_ERROR = -3,
WEBP_MUX_NOT_ENOUGH_DATA = -4
} WebPMuxError;
// IDs for different types of chunks.
typedef enum WebPChunkId {
WEBP_CHUNK_VP8X, // VP8X
WEBP_CHUNK_ICCP, // ICCP
WEBP_CHUNK_ANIM, // ANIM
WEBP_CHUNK_ANMF, // ANMF
WEBP_CHUNK_DEPRECATED, // (deprecated from FRGM)
WEBP_CHUNK_ALPHA, // ALPH
WEBP_CHUNK_IMAGE, // VP8/VP8L
WEBP_CHUNK_EXIF, // EXIF
WEBP_CHUNK_XMP, // XMP
WEBP_CHUNK_UNKNOWN, // Other chunks.
WEBP_CHUNK_NIL
} WebPChunkId;
//------------------------------------------------------------------------------
// Returns the version number of the mux library, packed in hexadecimal using
// 8bits for each of major/minor/revision. E.g: v2.5.7 is 0x020507.
WEBP_EXTERN int WebPGetMuxVersion(void);
//------------------------------------------------------------------------------
// Life of a Mux object
// Internal, version-checked, entry point
WEBP_EXTERN WebPMux* WebPNewInternal(int);
// Creates an empty mux object.
// Returns:
// A pointer to the newly created empty mux object.
// Or NULL in case of memory error.
static WEBP_INLINE WebPMux* WebPMuxNew(void) {
return WebPNewInternal(WEBP_MUX_ABI_VERSION);
}
// Deletes the mux object.
// Parameters:
// mux - (in/out) object to be deleted
WEBP_EXTERN void WebPMuxDelete(WebPMux* mux);
//------------------------------------------------------------------------------
// Mux creation.
// Internal, version-checked, entry point
WEBP_EXTERN WebPMux* WebPMuxCreateInternal(const WebPData*, int, int);
// Creates a mux object from raw data given in WebP RIFF format.
// Parameters:
// bitstream - (in) the bitstream data in WebP RIFF format
// copy_data - (in) value 1 indicates given data WILL be copied to the mux
// object and value 0 indicates data will NOT be copied.
// Returns:
// A pointer to the mux object created from given data - on success.
// NULL - In case of invalid data or memory error.
static WEBP_INLINE WebPMux* WebPMuxCreate(const WebPData* bitstream,
int copy_data) {
return WebPMuxCreateInternal(bitstream, copy_data, WEBP_MUX_ABI_VERSION);
}
//------------------------------------------------------------------------------
// Non-image chunks.
// Note: Only non-image related chunks should be managed through chunk APIs.
// (Image related chunks are: "ANMF", "VP8 ", "VP8L" and "ALPH").
// To add, get and delete images, use WebPMuxSetImage(), WebPMuxPushFrame(),
// WebPMuxGetFrame() and WebPMuxDeleteFrame().
// Adds a chunk with id 'fourcc' and data 'chunk_data' in the mux object.
// Any existing chunk(s) with the same id will be removed.
// Parameters:
// mux - (in/out) object to which the chunk is to be added
// fourcc - (in) a character array containing the fourcc of the given chunk;
// e.g., "ICCP", "XMP ", "EXIF" etc.
// chunk_data - (in) the chunk data to be added
// copy_data - (in) value 1 indicates given data WILL be copied to the mux
// object and value 0 indicates data will NOT be copied.
// Returns:
// WEBP_MUX_INVALID_ARGUMENT - if mux, fourcc or chunk_data is NULL
// or if fourcc corresponds to an image chunk.
// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
// WEBP_MUX_OK - on success.
WEBP_EXTERN WebPMuxError WebPMuxSetChunk(
WebPMux* mux, const char fourcc[4], const WebPData* chunk_data,
int copy_data);
// Gets a reference to the data of the chunk with id 'fourcc' in the mux object.
// The caller should NOT free the returned data.
// Parameters:
// mux - (in) object from which the chunk data is to be fetched
// fourcc - (in) a character array containing the fourcc of the chunk;
// e.g., "ICCP", "XMP ", "EXIF" etc.
// chunk_data - (out) returned chunk data
// Returns:
// WEBP_MUX_INVALID_ARGUMENT - if mux, fourcc or chunk_data is NULL
// or if fourcc corresponds to an image chunk.
// WEBP_MUX_NOT_FOUND - If mux does not contain a chunk with the given id.
// WEBP_MUX_OK - on success.
WEBP_EXTERN WebPMuxError WebPMuxGetChunk(
const WebPMux* mux, const char fourcc[4], WebPData* chunk_data);
// Deletes the chunk with the given 'fourcc' from the mux object.
// Parameters:
// mux - (in/out) object from which the chunk is to be deleted
// fourcc - (in) a character array containing the fourcc of the chunk;
// e.g., "ICCP", "XMP ", "EXIF" etc.
// Returns:
// WEBP_MUX_INVALID_ARGUMENT - if mux or fourcc is NULL
// or if fourcc corresponds to an image chunk.
// WEBP_MUX_NOT_FOUND - If mux does not contain a chunk with the given fourcc.
// WEBP_MUX_OK - on success.
WEBP_EXTERN WebPMuxError WebPMuxDeleteChunk(
WebPMux* mux, const char fourcc[4]);
//------------------------------------------------------------------------------
// Images.
// Encapsulates data about a single frame.
struct WebPMuxFrameInfo {
WebPData bitstream; // image data: can be a raw VP8/VP8L bitstream
// or a single-image WebP file.
int x_offset; // x-offset of the frame.
int y_offset; // y-offset of the frame.
int duration; // duration of the frame (in milliseconds).
WebPChunkId id; // frame type: should be one of WEBP_CHUNK_ANMF
// or WEBP_CHUNK_IMAGE
WebPMuxAnimDispose dispose_method; // Disposal method for the frame.
WebPMuxAnimBlend blend_method; // Blend operation for the frame.
uint32_t pad[1]; // padding for later use
};
// Sets the (non-animated) image in the mux object.
// Note: Any existing images (including frames) will be removed.
// Parameters:
// mux - (in/out) object in which the image is to be set
// bitstream - (in) can be a raw VP8/VP8L bitstream or a single-image
// WebP file (non-animated)
// copy_data - (in) value 1 indicates given data WILL be copied to the mux
// object and value 0 indicates data will NOT be copied.
// Returns:
// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL or bitstream is NULL.
// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
// WEBP_MUX_OK - on success.
WEBP_EXTERN WebPMuxError WebPMuxSetImage(
WebPMux* mux, const WebPData* bitstream, int copy_data);
// Adds a frame at the end of the mux object.
// Notes: (1) frame.id should be WEBP_CHUNK_ANMF
// (2) For setting a non-animated image, use WebPMuxSetImage() instead.
// (3) Type of frame being pushed must be same as the frames in mux.
// (4) As WebP only supports even offsets, any odd offset will be snapped
// to an even location using: offset &= ~1
// Parameters:
// mux - (in/out) object to which the frame is to be added
// frame - (in) frame data.
// copy_data - (in) value 1 indicates given data WILL be copied to the mux
// object and value 0 indicates data will NOT be copied.
// Returns:
// WEBP_MUX_INVALID_ARGUMENT - if mux or frame is NULL
// or if content of 'frame' is invalid.
// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
// WEBP_MUX_OK - on success.
WEBP_EXTERN WebPMuxError WebPMuxPushFrame(
WebPMux* mux, const WebPMuxFrameInfo* frame, int copy_data);
// Gets the nth frame from the mux object.
// The content of 'frame->bitstream' is allocated using malloc(), and NOT
// owned by the 'mux' object. It MUST be deallocated by the caller by calling
// WebPDataClear().
// nth=0 has a special meaning - last position.
// Parameters:
// mux - (in) object from which the info is to be fetched
// nth - (in) index of the frame in the mux object
// frame - (out) data of the returned frame
// Returns:
// WEBP_MUX_INVALID_ARGUMENT - if mux or frame is NULL.
// WEBP_MUX_NOT_FOUND - if there are less than nth frames in the mux object.
// WEBP_MUX_BAD_DATA - if nth frame chunk in mux is invalid.
// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
// WEBP_MUX_OK - on success.
WEBP_EXTERN WebPMuxError WebPMuxGetFrame(
const WebPMux* mux, uint32_t nth, WebPMuxFrameInfo* frame);
// Deletes a frame from the mux object.
// nth=0 has a special meaning - last position.
// Parameters:
// mux - (in/out) object from which a frame is to be deleted
// nth - (in) The position from which the frame is to be deleted
// Returns:
// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL.
// WEBP_MUX_NOT_FOUND - If there are less than nth frames in the mux object
// before deletion.
// WEBP_MUX_OK - on success.
WEBP_EXTERN WebPMuxError WebPMuxDeleteFrame(WebPMux* mux, uint32_t nth);
//------------------------------------------------------------------------------
// Animation.
// Animation parameters.
struct WebPMuxAnimParams {
uint32_t bgcolor; // Background color of the canvas stored (in MSB order) as:
// Bits 00 to 07: Alpha.
// Bits 08 to 15: Red.
// Bits 16 to 23: Green.
// Bits 24 to 31: Blue.
int loop_count; // Number of times to repeat the animation [0 = infinite].
};
// Sets the animation parameters in the mux object. Any existing ANIM chunks
// will be removed.
// Parameters:
// mux - (in/out) object in which ANIM chunk is to be set/added
// params - (in) animation parameters.
// Returns:
// WEBP_MUX_INVALID_ARGUMENT - if mux or params is NULL.
// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
// WEBP_MUX_OK - on success.
WEBP_EXTERN WebPMuxError WebPMuxSetAnimationParams(
WebPMux* mux, const WebPMuxAnimParams* params);
// Gets the animation parameters from the mux object.
// Parameters:
// mux - (in) object from which the animation parameters to be fetched
// params - (out) animation parameters extracted from the ANIM chunk
// Returns:
// WEBP_MUX_INVALID_ARGUMENT - if mux or params is NULL.
// WEBP_MUX_NOT_FOUND - if ANIM chunk is not present in mux object.
// WEBP_MUX_OK - on success.
WEBP_EXTERN WebPMuxError WebPMuxGetAnimationParams(
const WebPMux* mux, WebPMuxAnimParams* params);
//------------------------------------------------------------------------------
// Misc Utilities.
// Sets the canvas size for the mux object. The width and height can be
// specified explicitly or left as zero (0, 0).
// * When width and height are specified explicitly, then this frame bound is
// enforced during subsequent calls to WebPMuxAssemble() and an error is
// reported if any animated frame does not completely fit within the canvas.
// * When unspecified (0, 0), the constructed canvas will get the frame bounds
// from the bounding-box over all frames after calling WebPMuxAssemble().
// Parameters:
// mux - (in) object to which the canvas size is to be set
// width - (in) canvas width
// height - (in) canvas height
// Returns:
// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL; or
// width or height are invalid or out of bounds
// WEBP_MUX_OK - on success.
WEBP_EXTERN WebPMuxError WebPMuxSetCanvasSize(WebPMux* mux,
int width, int height);
// Gets the canvas size from the mux object.
// Note: This method assumes that the VP8X chunk, if present, is up-to-date.
// That is, the mux object hasn't been modified since the last call to
// WebPMuxAssemble() or WebPMuxCreate().
// Parameters:
// mux - (in) object from which the canvas size is to be fetched
// width - (out) canvas width
// height - (out) canvas height
// Returns:
// WEBP_MUX_INVALID_ARGUMENT - if mux, width or height is NULL.
// WEBP_MUX_BAD_DATA - if VP8X/VP8/VP8L chunk or canvas size is invalid.
// WEBP_MUX_OK - on success.
WEBP_EXTERN WebPMuxError WebPMuxGetCanvasSize(const WebPMux* mux,
int* width, int* height);
// Gets the feature flags from the mux object.
// Note: This method assumes that the VP8X chunk, if present, is up-to-date.
// That is, the mux object hasn't been modified since the last call to
// WebPMuxAssemble() or WebPMuxCreate().
// Parameters:
// mux - (in) object from which the features are to be fetched
// flags - (out) the flags specifying which features are present in the
// mux object. This will be an OR of various flag values.
// Enum 'WebPFeatureFlags' can be used to test individual flag values.
// Returns:
// WEBP_MUX_INVALID_ARGUMENT - if mux or flags is NULL.
// WEBP_MUX_BAD_DATA - if VP8X/VP8/VP8L chunk or canvas size is invalid.
// WEBP_MUX_OK - on success.
WEBP_EXTERN WebPMuxError WebPMuxGetFeatures(const WebPMux* mux,
uint32_t* flags);
// Gets number of chunks with the given 'id' in the mux object.
// Parameters:
// mux - (in) object from which the info is to be fetched
// id - (in) chunk id specifying the type of chunk
// num_elements - (out) number of chunks with the given chunk id
// Returns:
// WEBP_MUX_INVALID_ARGUMENT - if mux, or num_elements is NULL.
// WEBP_MUX_OK - on success.
WEBP_EXTERN WebPMuxError WebPMuxNumChunks(const WebPMux* mux,
WebPChunkId id, int* num_elements);
// Assembles all chunks in WebP RIFF format and returns in 'assembled_data'.
// This function also validates the mux object.
// Note: The content of 'assembled_data' will be ignored and overwritten.
// Also, the content of 'assembled_data' is allocated using malloc(), and NOT
// owned by the 'mux' object. It MUST be deallocated by the caller by calling
// WebPDataClear(). It's always safe to call WebPDataClear() upon return,
// even in case of error.
// Parameters:
// mux - (in/out) object whose chunks are to be assembled
// assembled_data - (out) assembled WebP data
// Returns:
// WEBP_MUX_BAD_DATA - if mux object is invalid.
// WEBP_MUX_INVALID_ARGUMENT - if mux or assembled_data is NULL.
// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
// WEBP_MUX_OK - on success.
WEBP_EXTERN WebPMuxError WebPMuxAssemble(WebPMux* mux,
WebPData* assembled_data);
//------------------------------------------------------------------------------
// WebPAnimEncoder API
//
// This API allows encoding (possibly) animated WebP images.
//
// Code Example:
/*
WebPAnimEncoderOptions enc_options;
WebPAnimEncoderOptionsInit(&enc_options);
// Tune 'enc_options' as needed.
WebPAnimEncoder* enc = WebPAnimEncoderNew(width, height, &enc_options);
while(<there are more frames>) {
WebPConfig config;
WebPConfigInit(&config);
// Tune 'config' as needed.
WebPAnimEncoderAdd(enc, frame, timestamp_ms, &config);
}
WebPAnimEncoderAdd(enc, NULL, timestamp_ms, NULL);
WebPAnimEncoderAssemble(enc, webp_data);
WebPAnimEncoderDelete(enc);
// Write the 'webp_data' to a file, or re-mux it further.
*/
typedef struct WebPAnimEncoder WebPAnimEncoder; // Main opaque object.
// Forward declarations. Defined in encode.h.
struct WebPPicture;
struct WebPConfig;
// Global options.
struct WebPAnimEncoderOptions {
WebPMuxAnimParams anim_params; // Animation parameters.
int minimize_size; // If true, minimize the output size (slow). Implicitly
// disables key-frame insertion.
int kmin;
int kmax; // Minimum and maximum distance between consecutive key
// frames in the output. The library may insert some key
// frames as needed to satisfy this criteria.
// Note that these conditions should hold: kmax > kmin
// and kmin >= kmax / 2 + 1. Also, if kmax <= 0, then
// key-frame insertion is disabled; and if kmax == 1,
// then all frames will be key-frames (kmin value does
// not matter for these special cases).
int allow_mixed; // If true, use mixed compression mode; may choose
// either lossy and lossless for each frame.
int verbose; // If true, print info and warning messages to stderr.
uint32_t padding[4]; // Padding for later use.
};
// Internal, version-checked, entry point.
WEBP_EXTERN int WebPAnimEncoderOptionsInitInternal(
WebPAnimEncoderOptions*, int);
// Should always be called, to initialize a fresh WebPAnimEncoderOptions
// structure before modification. Returns false in case of version mismatch.
// WebPAnimEncoderOptionsInit() must have succeeded before using the
// 'enc_options' object.
static WEBP_INLINE int WebPAnimEncoderOptionsInit(
WebPAnimEncoderOptions* enc_options) {
return WebPAnimEncoderOptionsInitInternal(enc_options, WEBP_MUX_ABI_VERSION);
}
// Internal, version-checked, entry point.
WEBP_EXTERN WebPAnimEncoder* WebPAnimEncoderNewInternal(
int, int, const WebPAnimEncoderOptions*, int);
// Creates and initializes a WebPAnimEncoder object.
// Parameters:
// width/height - (in) canvas width and height of the animation.
// enc_options - (in) encoding options; can be passed NULL to pick
// reasonable defaults.
// Returns:
// A pointer to the newly created WebPAnimEncoder object.
// Or NULL in case of memory error.
static WEBP_INLINE WebPAnimEncoder* WebPAnimEncoderNew(
int width, int height, const WebPAnimEncoderOptions* enc_options) {
return WebPAnimEncoderNewInternal(width, height, enc_options,
WEBP_MUX_ABI_VERSION);
}
// Optimize the given frame for WebP, encode it and add it to the
// WebPAnimEncoder object.
// The last call to 'WebPAnimEncoderAdd' should be with frame = NULL, which
// indicates that no more frames are to be added. This call is also used to
// determine the duration of the last frame.
// Parameters:
// enc - (in/out) object to which the frame is to be added.
// frame - (in/out) frame data in ARGB or YUV(A) format. If it is in YUV(A)
// format, it will be converted to ARGB, which incurs a small loss.
// timestamp_ms - (in) timestamp of this frame in milliseconds.
// Duration of a frame would be calculated as
// "timestamp of next frame - timestamp of this frame".
// Hence, timestamps should be in non-decreasing order.
// config - (in) encoding options; can be passed NULL to pick
// reasonable defaults.
// Returns:
// On error, returns false and frame->error_code is set appropriately.
// Otherwise, returns true.
WEBP_EXTERN int WebPAnimEncoderAdd(
WebPAnimEncoder* enc, struct WebPPicture* frame, int timestamp_ms,
const struct WebPConfig* config);
// Assemble all frames added so far into a WebP bitstream.
// This call should be preceded by a call to 'WebPAnimEncoderAdd' with
// frame = NULL; if not, the duration of the last frame will be internally
// estimated.
// Parameters:
// enc - (in/out) object from which the frames are to be assembled.
// webp_data - (out) generated WebP bitstream.
// Returns:
// True on success.
WEBP_EXTERN int WebPAnimEncoderAssemble(WebPAnimEncoder* enc,
WebPData* webp_data);
// Get error string corresponding to the most recent call using 'enc'. The
// returned string is owned by 'enc' and is valid only until the next call to
// WebPAnimEncoderAdd() or WebPAnimEncoderAssemble() or WebPAnimEncoderDelete().
// Parameters:
// enc - (in/out) object from which the error string is to be fetched.
// Returns:
// NULL if 'enc' is NULL. Otherwise, returns the error string if the last call
// to 'enc' had an error, or an empty string if the last call was a success.
WEBP_EXTERN const char* WebPAnimEncoderGetError(WebPAnimEncoder* enc);
// Deletes the WebPAnimEncoder object.
// Parameters:
// enc - (in/out) object to be deleted
WEBP_EXTERN void WebPAnimEncoderDelete(WebPAnimEncoder* enc);
//------------------------------------------------------------------------------
#ifdef __cplusplus
} // extern "C"
#endif
#endif /* WEBP_WEBP_MUX_H_ */
webp/decode.h 0000644 00000055156 15201526705 0007114 0 ustar 00 // Copyright 2010 Google Inc. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the COPYING file in the root of the source
// tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// -----------------------------------------------------------------------------
//
// Main decoding functions for WebP images.
//
// Author: Skal (pascal.massimino@gmail.com)
#ifndef WEBP_WEBP_DECODE_H_
#define WEBP_WEBP_DECODE_H_
#include "./types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define WEBP_DECODER_ABI_VERSION 0x0208 // MAJOR(8b) + MINOR(8b)
// Note: forward declaring enumerations is not allowed in (strict) C and C++,
// the types are left here for reference.
// typedef enum VP8StatusCode VP8StatusCode;
// typedef enum WEBP_CSP_MODE WEBP_CSP_MODE;
typedef struct WebPRGBABuffer WebPRGBABuffer;
typedef struct WebPYUVABuffer WebPYUVABuffer;
typedef struct WebPDecBuffer WebPDecBuffer;
typedef struct WebPIDecoder WebPIDecoder;
typedef struct WebPBitstreamFeatures WebPBitstreamFeatures;
typedef struct WebPDecoderOptions WebPDecoderOptions;
typedef struct WebPDecoderConfig WebPDecoderConfig;
// Return the decoder's version number, packed in hexadecimal using 8bits for
// each of major/minor/revision. E.g: v2.5.7 is 0x020507.
WEBP_EXTERN int WebPGetDecoderVersion(void);
// Retrieve basic header information: width, height.
// This function will also validate the header, returning true on success,
// false otherwise. '*width' and '*height' are only valid on successful return.
// Pointers 'width' and 'height' can be passed NULL if deemed irrelevant.
WEBP_EXTERN int WebPGetInfo(const uint8_t* data, size_t data_size,
int* width, int* height);
// Decodes WebP images pointed to by 'data' and returns RGBA samples, along
// with the dimensions in *width and *height. The ordering of samples in
// memory is R, G, B, A, R, G, B, A... in scan order (endian-independent).
// The returned pointer should be deleted calling WebPFree().
// Returns NULL in case of error.
WEBP_EXTERN uint8_t* WebPDecodeRGBA(const uint8_t* data, size_t data_size,
int* width, int* height);
// Same as WebPDecodeRGBA, but returning A, R, G, B, A, R, G, B... ordered data.
WEBP_EXTERN uint8_t* WebPDecodeARGB(const uint8_t* data, size_t data_size,
int* width, int* height);
// Same as WebPDecodeRGBA, but returning B, G, R, A, B, G, R, A... ordered data.
WEBP_EXTERN uint8_t* WebPDecodeBGRA(const uint8_t* data, size_t data_size,
int* width, int* height);
// Same as WebPDecodeRGBA, but returning R, G, B, R, G, B... ordered data.
// If the bitstream contains transparency, it is ignored.
WEBP_EXTERN uint8_t* WebPDecodeRGB(const uint8_t* data, size_t data_size,
int* width, int* height);
// Same as WebPDecodeRGB, but returning B, G, R, B, G, R... ordered data.
WEBP_EXTERN uint8_t* WebPDecodeBGR(const uint8_t* data, size_t data_size,
int* width, int* height);
// Decode WebP images pointed to by 'data' to Y'UV format(*). The pointer
// returned is the Y samples buffer. Upon return, *u and *v will point to
// the U and V chroma data. These U and V buffers need NOT be passed to
// WebPFree(), unlike the returned Y luma one. The dimension of the U and V
// planes are both (*width + 1) / 2 and (*height + 1)/ 2.
// Upon return, the Y buffer has a stride returned as '*stride', while U and V
// have a common stride returned as '*uv_stride'.
// Return NULL in case of error.
// (*) Also named Y'CbCr. See: http://en.wikipedia.org/wiki/YCbCr
WEBP_EXTERN uint8_t* WebPDecodeYUV(const uint8_t* data, size_t data_size,
int* width, int* height,
uint8_t** u, uint8_t** v,
int* stride, int* uv_stride);
// Releases memory returned by the WebPDecode*() functions above.
WEBP_EXTERN void WebPFree(void* ptr);
// These five functions are variants of the above ones, that decode the image
// directly into a pre-allocated buffer 'output_buffer'. The maximum storage
// available in this buffer is indicated by 'output_buffer_size'. If this
// storage is not sufficient (or an error occurred), NULL is returned.
// Otherwise, output_buffer is returned, for convenience.
// The parameter 'output_stride' specifies the distance (in bytes)
// between scanlines. Hence, output_buffer_size is expected to be at least
// output_stride x picture-height.
WEBP_EXTERN uint8_t* WebPDecodeRGBAInto(
const uint8_t* data, size_t data_size,
uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
WEBP_EXTERN uint8_t* WebPDecodeARGBInto(
const uint8_t* data, size_t data_size,
uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
WEBP_EXTERN uint8_t* WebPDecodeBGRAInto(
const uint8_t* data, size_t data_size,
uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
// RGB and BGR variants. Here too the transparency information, if present,
// will be dropped and ignored.
WEBP_EXTERN uint8_t* WebPDecodeRGBInto(
const uint8_t* data, size_t data_size,
uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
WEBP_EXTERN uint8_t* WebPDecodeBGRInto(
const uint8_t* data, size_t data_size,
uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
// WebPDecodeYUVInto() is a variant of WebPDecodeYUV() that operates directly
// into pre-allocated luma/chroma plane buffers. This function requires the
// strides to be passed: one for the luma plane and one for each of the
// chroma ones. The size of each plane buffer is passed as 'luma_size',
// 'u_size' and 'v_size' respectively.
// Pointer to the luma plane ('*luma') is returned or NULL if an error occurred
// during decoding (or because some buffers were found to be too small).
WEBP_EXTERN uint8_t* WebPDecodeYUVInto(
const uint8_t* data, size_t data_size,
uint8_t* luma, size_t luma_size, int luma_stride,
uint8_t* u, size_t u_size, int u_stride,
uint8_t* v, size_t v_size, int v_stride);
//------------------------------------------------------------------------------
// Output colorspaces and buffer
// Colorspaces
// Note: the naming describes the byte-ordering of packed samples in memory.
// For instance, MODE_BGRA relates to samples ordered as B,G,R,A,B,G,R,A,...
// Non-capital names (e.g.:MODE_Argb) relates to pre-multiplied RGB channels.
// RGBA-4444 and RGB-565 colorspaces are represented by following byte-order:
// RGBA-4444: [r3 r2 r1 r0 g3 g2 g1 g0], [b3 b2 b1 b0 a3 a2 a1 a0], ...
// RGB-565: [r4 r3 r2 r1 r0 g5 g4 g3], [g2 g1 g0 b4 b3 b2 b1 b0], ...
// In the case WEBP_SWAP_16BITS_CSP is defined, the bytes are swapped for
// these two modes:
// RGBA-4444: [b3 b2 b1 b0 a3 a2 a1 a0], [r3 r2 r1 r0 g3 g2 g1 g0], ...
// RGB-565: [g2 g1 g0 b4 b3 b2 b1 b0], [r4 r3 r2 r1 r0 g5 g4 g3], ...
typedef enum WEBP_CSP_MODE {
MODE_RGB = 0, MODE_RGBA = 1,
MODE_BGR = 2, MODE_BGRA = 3,
MODE_ARGB = 4, MODE_RGBA_4444 = 5,
MODE_RGB_565 = 6,
// RGB-premultiplied transparent modes (alpha value is preserved)
MODE_rgbA = 7,
MODE_bgrA = 8,
MODE_Argb = 9,
MODE_rgbA_4444 = 10,
// YUV modes must come after RGB ones.
MODE_YUV = 11, MODE_YUVA = 12, // yuv 4:2:0
MODE_LAST = 13
} WEBP_CSP_MODE;
// Some useful macros:
static WEBP_INLINE int WebPIsPremultipliedMode(WEBP_CSP_MODE mode) {
return (mode == MODE_rgbA || mode == MODE_bgrA || mode == MODE_Argb ||
mode == MODE_rgbA_4444);
}
static WEBP_INLINE int WebPIsAlphaMode(WEBP_CSP_MODE mode) {
return (mode == MODE_RGBA || mode == MODE_BGRA || mode == MODE_ARGB ||
mode == MODE_RGBA_4444 || mode == MODE_YUVA ||
WebPIsPremultipliedMode(mode));
}
static WEBP_INLINE int WebPIsRGBMode(WEBP_CSP_MODE mode) {
return (mode < MODE_YUV);
}
//------------------------------------------------------------------------------
// WebPDecBuffer: Generic structure for describing the output sample buffer.
struct WebPRGBABuffer { // view as RGBA
uint8_t* rgba; // pointer to RGBA samples
int stride; // stride in bytes from one scanline to the next.
size_t size; // total size of the *rgba buffer.
};
struct WebPYUVABuffer { // view as YUVA
uint8_t* y, *u, *v, *a; // pointer to luma, chroma U/V, alpha samples
int y_stride; // luma stride
int u_stride, v_stride; // chroma strides
int a_stride; // alpha stride
size_t y_size; // luma plane size
size_t u_size, v_size; // chroma planes size
size_t a_size; // alpha-plane size
};
// Output buffer
struct WebPDecBuffer {
WEBP_CSP_MODE colorspace; // Colorspace.
int width, height; // Dimensions.
int is_external_memory; // If non-zero, 'internal_memory' pointer is not
// used. If value is '2' or more, the external
// memory is considered 'slow' and multiple
// read/write will be avoided.
union {
WebPRGBABuffer RGBA;
WebPYUVABuffer YUVA;
} u; // Nameless union of buffer parameters.
uint32_t pad[4]; // padding for later use
uint8_t* private_memory; // Internally allocated memory (only when
// is_external_memory is 0). Should not be used
// externally, but accessed via the buffer union.
};
// Internal, version-checked, entry point
WEBP_EXTERN int WebPInitDecBufferInternal(WebPDecBuffer*, int);
// Initialize the structure as empty. Must be called before any other use.
// Returns false in case of version mismatch
static WEBP_INLINE int WebPInitDecBuffer(WebPDecBuffer* buffer) {
return WebPInitDecBufferInternal(buffer, WEBP_DECODER_ABI_VERSION);
}
// Free any memory associated with the buffer. Must always be called last.
// Note: doesn't free the 'buffer' structure itself.
WEBP_EXTERN void WebPFreeDecBuffer(WebPDecBuffer* buffer);
//------------------------------------------------------------------------------
// Enumeration of the status codes
typedef enum VP8StatusCode {
VP8_STATUS_OK = 0,
VP8_STATUS_OUT_OF_MEMORY,
VP8_STATUS_INVALID_PARAM,
VP8_STATUS_BITSTREAM_ERROR,
VP8_STATUS_UNSUPPORTED_FEATURE,
VP8_STATUS_SUSPENDED,
VP8_STATUS_USER_ABORT,
VP8_STATUS_NOT_ENOUGH_DATA
} VP8StatusCode;
//------------------------------------------------------------------------------
// Incremental decoding
//
// This API allows streamlined decoding of partial data.
// Picture can be incrementally decoded as data become available thanks to the
// WebPIDecoder object. This object can be left in a SUSPENDED state if the
// picture is only partially decoded, pending additional input.
// Code example:
//
// WebPInitDecBuffer(&output_buffer);
// output_buffer.colorspace = mode;
// ...
// WebPIDecoder* idec = WebPINewDecoder(&output_buffer);
// while (additional_data_is_available) {
// // ... (get additional data in some new_data[] buffer)
// status = WebPIAppend(idec, new_data, new_data_size);
// if (status != VP8_STATUS_OK && status != VP8_STATUS_SUSPENDED) {
// break; // an error occurred.
// }
//
// // The above call decodes the current available buffer.
// // Part of the image can now be refreshed by calling
// // WebPIDecGetRGB()/WebPIDecGetYUVA() etc.
// }
// WebPIDelete(idec);
// Creates a new incremental decoder with the supplied buffer parameter.
// This output_buffer can be passed NULL, in which case a default output buffer
// is used (with MODE_RGB). Otherwise, an internal reference to 'output_buffer'
// is kept, which means that the lifespan of 'output_buffer' must be larger than
// that of the returned WebPIDecoder object.
// The supplied 'output_buffer' content MUST NOT be changed between calls to
// WebPIAppend() or WebPIUpdate() unless 'output_buffer.is_external_memory' is
// not set to 0. In such a case, it is allowed to modify the pointers, size and
// stride of output_buffer.u.RGBA or output_buffer.u.YUVA, provided they remain
// within valid bounds.
// All other fields of WebPDecBuffer MUST remain constant between calls.
// Returns NULL if the allocation failed.
WEBP_EXTERN WebPIDecoder* WebPINewDecoder(WebPDecBuffer* output_buffer);
// This function allocates and initializes an incremental-decoder object, which
// will output the RGB/A samples specified by 'csp' into a preallocated
// buffer 'output_buffer'. The size of this buffer is at least
// 'output_buffer_size' and the stride (distance in bytes between two scanlines)
// is specified by 'output_stride'.
// Additionally, output_buffer can be passed NULL in which case the output
// buffer will be allocated automatically when the decoding starts. The
// colorspace 'csp' is taken into account for allocating this buffer. All other
// parameters are ignored.
// Returns NULL if the allocation failed, or if some parameters are invalid.
WEBP_EXTERN WebPIDecoder* WebPINewRGB(
WEBP_CSP_MODE csp,
uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
// This function allocates and initializes an incremental-decoder object, which
// will output the raw luma/chroma samples into a preallocated planes if
// supplied. The luma plane is specified by its pointer 'luma', its size
// 'luma_size' and its stride 'luma_stride'. Similarly, the chroma-u plane
// is specified by the 'u', 'u_size' and 'u_stride' parameters, and the chroma-v
// plane by 'v' and 'v_size'. And same for the alpha-plane. The 'a' pointer
// can be pass NULL in case one is not interested in the transparency plane.
// Conversely, 'luma' can be passed NULL if no preallocated planes are supplied.
// In this case, the output buffer will be automatically allocated (using
// MODE_YUVA) when decoding starts. All parameters are then ignored.
// Returns NULL if the allocation failed or if a parameter is invalid.
WEBP_EXTERN WebPIDecoder* WebPINewYUVA(
uint8_t* luma, size_t luma_size, int luma_stride,
uint8_t* u, size_t u_size, int u_stride,
uint8_t* v, size_t v_size, int v_stride,
uint8_t* a, size_t a_size, int a_stride);
// Deprecated version of the above, without the alpha plane.
// Kept for backward compatibility.
WEBP_EXTERN WebPIDecoder* WebPINewYUV(
uint8_t* luma, size_t luma_size, int luma_stride,
uint8_t* u, size_t u_size, int u_stride,
uint8_t* v, size_t v_size, int v_stride);
// Deletes the WebPIDecoder object and associated memory. Must always be called
// if WebPINewDecoder, WebPINewRGB or WebPINewYUV succeeded.
WEBP_EXTERN void WebPIDelete(WebPIDecoder* idec);
// Copies and decodes the next available data. Returns VP8_STATUS_OK when
// the image is successfully decoded. Returns VP8_STATUS_SUSPENDED when more
// data is expected. Returns error in other cases.
WEBP_EXTERN VP8StatusCode WebPIAppend(
WebPIDecoder* idec, const uint8_t* data, size_t data_size);
// A variant of the above function to be used when data buffer contains
// partial data from the beginning. In this case data buffer is not copied
// to the internal memory.
// Note that the value of the 'data' pointer can change between calls to
// WebPIUpdate, for instance when the data buffer is resized to fit larger data.
WEBP_EXTERN VP8StatusCode WebPIUpdate(
WebPIDecoder* idec, const uint8_t* data, size_t data_size);
// Returns the RGB/A image decoded so far. Returns NULL if output params
// are not initialized yet. The RGB/A output type corresponds to the colorspace
// specified during call to WebPINewDecoder() or WebPINewRGB().
// *last_y is the index of last decoded row in raster scan order. Some pointers
// (*last_y, *width etc.) can be NULL if corresponding information is not
// needed. The values in these pointers are only valid on successful (non-NULL)
// return.
WEBP_EXTERN uint8_t* WebPIDecGetRGB(
const WebPIDecoder* idec, int* last_y,
int* width, int* height, int* stride);
// Same as above function to get a YUVA image. Returns pointer to the luma
// plane or NULL in case of error. If there is no alpha information
// the alpha pointer '*a' will be returned NULL.
WEBP_EXTERN uint8_t* WebPIDecGetYUVA(
const WebPIDecoder* idec, int* last_y,
uint8_t** u, uint8_t** v, uint8_t** a,
int* width, int* height, int* stride, int* uv_stride, int* a_stride);
// Deprecated alpha-less version of WebPIDecGetYUVA(): it will ignore the
// alpha information (if present). Kept for backward compatibility.
static WEBP_INLINE uint8_t* WebPIDecGetYUV(
const WebPIDecoder* idec, int* last_y, uint8_t** u, uint8_t** v,
int* width, int* height, int* stride, int* uv_stride) {
return WebPIDecGetYUVA(idec, last_y, u, v, NULL, width, height,
stride, uv_stride, NULL);
}
// Generic call to retrieve information about the displayable area.
// If non NULL, the left/right/width/height pointers are filled with the visible
// rectangular area so far.
// Returns NULL in case the incremental decoder object is in an invalid state.
// Otherwise returns the pointer to the internal representation. This structure
// is read-only, tied to WebPIDecoder's lifespan and should not be modified.
WEBP_EXTERN const WebPDecBuffer* WebPIDecodedArea(
const WebPIDecoder* idec, int* left, int* top, int* width, int* height);
//------------------------------------------------------------------------------
// Advanced decoding parametrization
//
// Code sample for using the advanced decoding API
/*
// A) Init a configuration object
WebPDecoderConfig config;
CHECK(WebPInitDecoderConfig(&config));
// B) optional: retrieve the bitstream's features.
CHECK(WebPGetFeatures(data, data_size, &config.input) == VP8_STATUS_OK);
// C) Adjust 'config', if needed
config.no_fancy_upsampling = 1;
config.output.colorspace = MODE_BGRA;
// etc.
// Note that you can also make config.output point to an externally
// supplied memory buffer, provided it's big enough to store the decoded
// picture. Otherwise, config.output will just be used to allocate memory
// and store the decoded picture.
// D) Decode!
CHECK(WebPDecode(data, data_size, &config) == VP8_STATUS_OK);
// E) Decoded image is now in config.output (and config.output.u.RGBA)
// F) Reclaim memory allocated in config's object. It's safe to call
// this function even if the memory is external and wasn't allocated
// by WebPDecode().
WebPFreeDecBuffer(&config.output);
*/
// Features gathered from the bitstream
struct WebPBitstreamFeatures {
int width; // Width in pixels, as read from the bitstream.
int height; // Height in pixels, as read from the bitstream.
int has_alpha; // True if the bitstream contains an alpha channel.
int has_animation; // True if the bitstream is an animation.
int format; // 0 = undefined (/mixed), 1 = lossy, 2 = lossless
uint32_t pad[5]; // padding for later use
};
// Internal, version-checked, entry point
WEBP_EXTERN VP8StatusCode WebPGetFeaturesInternal(
const uint8_t*, size_t, WebPBitstreamFeatures*, int);
// Retrieve features from the bitstream. The *features structure is filled
// with information gathered from the bitstream.
// Returns VP8_STATUS_OK when the features are successfully retrieved. Returns
// VP8_STATUS_NOT_ENOUGH_DATA when more data is needed to retrieve the
// features from headers. Returns error in other cases.
static WEBP_INLINE VP8StatusCode WebPGetFeatures(
const uint8_t* data, size_t data_size,
WebPBitstreamFeatures* features) {
return WebPGetFeaturesInternal(data, data_size, features,
WEBP_DECODER_ABI_VERSION);
}
// Decoding options
struct WebPDecoderOptions {
int bypass_filtering; // if true, skip the in-loop filtering
int no_fancy_upsampling; // if true, use faster pointwise upsampler
int use_cropping; // if true, cropping is applied _first_
int crop_left, crop_top; // top-left position for cropping.
// Will be snapped to even values.
int crop_width, crop_height; // dimension of the cropping area
int use_scaling; // if true, scaling is applied _afterward_
int scaled_width, scaled_height; // final resolution
int use_threads; // if true, use multi-threaded decoding
int dithering_strength; // dithering strength (0=Off, 100=full)
int flip; // flip output vertically
int alpha_dithering_strength; // alpha dithering strength in [0..100]
uint32_t pad[5]; // padding for later use
};
// Main object storing the configuration for advanced decoding.
struct WebPDecoderConfig {
WebPBitstreamFeatures input; // Immutable bitstream features (optional)
WebPDecBuffer output; // Output buffer (can point to external mem)
WebPDecoderOptions options; // Decoding options
};
// Internal, version-checked, entry point
WEBP_EXTERN int WebPInitDecoderConfigInternal(WebPDecoderConfig*, int);
// Initialize the configuration as empty. This function must always be
// called first, unless WebPGetFeatures() is to be called.
// Returns false in case of mismatched version.
static WEBP_INLINE int WebPInitDecoderConfig(WebPDecoderConfig* config) {
return WebPInitDecoderConfigInternal(config, WEBP_DECODER_ABI_VERSION);
}
// Instantiate a new incremental decoder object with the requested
// configuration. The bitstream can be passed using 'data' and 'data_size'
// parameter, in which case the features will be parsed and stored into
// config->input. Otherwise, 'data' can be NULL and no parsing will occur.
// Note that 'config' can be NULL too, in which case a default configuration
// is used. If 'config' is not NULL, it must outlive the WebPIDecoder object
// as some references to its fields will be used. No internal copy of 'config'
// is made.
// The return WebPIDecoder object must always be deleted calling WebPIDelete().
// Returns NULL in case of error (and config->status will then reflect
// the error condition, if available).
WEBP_EXTERN WebPIDecoder* WebPIDecode(const uint8_t* data, size_t data_size,
WebPDecoderConfig* config);
// Non-incremental version. This version decodes the full data at once, taking
// 'config' into account. Returns decoding status (which should be VP8_STATUS_OK
// if the decoding was successful). Note that 'config' cannot be NULL.
WEBP_EXTERN VP8StatusCode WebPDecode(const uint8_t* data, size_t data_size,
WebPDecoderConfig* config);
#ifdef __cplusplus
} // extern "C"
#endif
#endif /* WEBP_WEBP_DECODE_H_ */
webp/demux.h 0000644 00000036366 15201526705 0007015 0 ustar 00 // Copyright 2012 Google Inc. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the COPYING file in the root of the source
// tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// -----------------------------------------------------------------------------
//
// Demux API.
// Enables extraction of image and extended format data from WebP files.
// Code Example: Demuxing WebP data to extract all the frames, ICC profile
// and EXIF/XMP metadata.
/*
WebPDemuxer* demux = WebPDemux(&webp_data);
uint32_t width = WebPDemuxGetI(demux, WEBP_FF_CANVAS_WIDTH);
uint32_t height = WebPDemuxGetI(demux, WEBP_FF_CANVAS_HEIGHT);
// ... (Get information about the features present in the WebP file).
uint32_t flags = WebPDemuxGetI(demux, WEBP_FF_FORMAT_FLAGS);
// ... (Iterate over all frames).
WebPIterator iter;
if (WebPDemuxGetFrame(demux, 1, &iter)) {
do {
// ... (Consume 'iter'; e.g. Decode 'iter.fragment' with WebPDecode(),
// ... and get other frame properties like width, height, offsets etc.
// ... see 'struct WebPIterator' below for more info).
} while (WebPDemuxNextFrame(&iter));
WebPDemuxReleaseIterator(&iter);
}
// ... (Extract metadata).
WebPChunkIterator chunk_iter;
if (flags & ICCP_FLAG) WebPDemuxGetChunk(demux, "ICCP", 1, &chunk_iter);
// ... (Consume the ICC profile in 'chunk_iter.chunk').
WebPDemuxReleaseChunkIterator(&chunk_iter);
if (flags & EXIF_FLAG) WebPDemuxGetChunk(demux, "EXIF", 1, &chunk_iter);
// ... (Consume the EXIF metadata in 'chunk_iter.chunk').
WebPDemuxReleaseChunkIterator(&chunk_iter);
if (flags & XMP_FLAG) WebPDemuxGetChunk(demux, "XMP ", 1, &chunk_iter);
// ... (Consume the XMP metadata in 'chunk_iter.chunk').
WebPDemuxReleaseChunkIterator(&chunk_iter);
WebPDemuxDelete(demux);
*/
#ifndef WEBP_WEBP_DEMUX_H_
#define WEBP_WEBP_DEMUX_H_
#include "./decode.h" // for WEBP_CSP_MODE
#include "./mux_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define WEBP_DEMUX_ABI_VERSION 0x0107 // MAJOR(8b) + MINOR(8b)
// Note: forward declaring enumerations is not allowed in (strict) C and C++,
// the types are left here for reference.
// typedef enum WebPDemuxState WebPDemuxState;
// typedef enum WebPFormatFeature WebPFormatFeature;
typedef struct WebPDemuxer WebPDemuxer;
typedef struct WebPIterator WebPIterator;
typedef struct WebPChunkIterator WebPChunkIterator;
typedef struct WebPAnimInfo WebPAnimInfo;
typedef struct WebPAnimDecoderOptions WebPAnimDecoderOptions;
//------------------------------------------------------------------------------
// Returns the version number of the demux library, packed in hexadecimal using
// 8bits for each of major/minor/revision. E.g: v2.5.7 is 0x020507.
WEBP_EXTERN int WebPGetDemuxVersion(void);
//------------------------------------------------------------------------------
// Life of a Demux object
typedef enum WebPDemuxState {
WEBP_DEMUX_PARSE_ERROR = -1, // An error occurred while parsing.
WEBP_DEMUX_PARSING_HEADER = 0, // Not enough data to parse full header.
WEBP_DEMUX_PARSED_HEADER = 1, // Header parsing complete,
// data may be available.
WEBP_DEMUX_DONE = 2 // Entire file has been parsed.
} WebPDemuxState;
// Internal, version-checked, entry point
WEBP_EXTERN WebPDemuxer* WebPDemuxInternal(
const WebPData*, int, WebPDemuxState*, int);
// Parses the full WebP file given by 'data'. For single images the WebP file
// header alone or the file header and the chunk header may be absent.
// Returns a WebPDemuxer object on successful parse, NULL otherwise.
static WEBP_INLINE WebPDemuxer* WebPDemux(const WebPData* data) {
return WebPDemuxInternal(data, 0, NULL, WEBP_DEMUX_ABI_VERSION);
}
// Parses the possibly incomplete WebP file given by 'data'.
// If 'state' is non-NULL it will be set to indicate the status of the demuxer.
// Returns NULL in case of error or if there isn't enough data to start parsing;
// and a WebPDemuxer object on successful parse.
// Note that WebPDemuxer keeps internal pointers to 'data' memory segment.
// If this data is volatile, the demuxer object should be deleted (by calling
// WebPDemuxDelete()) and WebPDemuxPartial() called again on the new data.
// This is usually an inexpensive operation.
static WEBP_INLINE WebPDemuxer* WebPDemuxPartial(
const WebPData* data, WebPDemuxState* state) {
return WebPDemuxInternal(data, 1, state, WEBP_DEMUX_ABI_VERSION);
}
// Frees memory associated with 'dmux'.
WEBP_EXTERN void WebPDemuxDelete(WebPDemuxer* dmux);
//------------------------------------------------------------------------------
// Data/information extraction.
typedef enum WebPFormatFeature {
WEBP_FF_FORMAT_FLAGS, // bit-wise combination of WebPFeatureFlags
// corresponding to the 'VP8X' chunk (if present).
WEBP_FF_CANVAS_WIDTH,
WEBP_FF_CANVAS_HEIGHT,
WEBP_FF_LOOP_COUNT, // only relevant for animated file
WEBP_FF_BACKGROUND_COLOR, // idem.
WEBP_FF_FRAME_COUNT // Number of frames present in the demux object.
// In case of a partial demux, this is the number
// of frames seen so far, with the last frame
// possibly being partial.
} WebPFormatFeature;
// Get the 'feature' value from the 'dmux'.
// NOTE: values are only valid if WebPDemux() was used or WebPDemuxPartial()
// returned a state > WEBP_DEMUX_PARSING_HEADER.
// If 'feature' is WEBP_FF_FORMAT_FLAGS, the returned value is a bit-wise
// combination of WebPFeatureFlags values.
// If 'feature' is WEBP_FF_LOOP_COUNT, WEBP_FF_BACKGROUND_COLOR, the returned
// value is only meaningful if the bitstream is animated.
WEBP_EXTERN uint32_t WebPDemuxGetI(
const WebPDemuxer* dmux, WebPFormatFeature feature);
//------------------------------------------------------------------------------
// Frame iteration.
struct WebPIterator {
int frame_num;
int num_frames; // equivalent to WEBP_FF_FRAME_COUNT.
int x_offset, y_offset; // offset relative to the canvas.
int width, height; // dimensions of this frame.
int duration; // display duration in milliseconds.
WebPMuxAnimDispose dispose_method; // dispose method for the frame.
int complete; // true if 'fragment' contains a full frame. partial images
// may still be decoded with the WebP incremental decoder.
WebPData fragment; // The frame given by 'frame_num'. Note for historical
// reasons this is called a fragment.
int has_alpha; // True if the frame contains transparency.
WebPMuxAnimBlend blend_method; // Blend operation for the frame.
uint32_t pad[2]; // padding for later use.
void* private_; // for internal use only.
};
// Retrieves frame 'frame_number' from 'dmux'.
// 'iter->fragment' points to the frame on return from this function.
// Setting 'frame_number' equal to 0 will return the last frame of the image.
// Returns false if 'dmux' is NULL or frame 'frame_number' is not present.
// Call WebPDemuxReleaseIterator() when use of the iterator is complete.
// NOTE: 'dmux' must persist for the lifetime of 'iter'.
WEBP_EXTERN int WebPDemuxGetFrame(
const WebPDemuxer* dmux, int frame_number, WebPIterator* iter);
// Sets 'iter->fragment' to point to the next ('iter->frame_num' + 1) or
// previous ('iter->frame_num' - 1) frame. These functions do not loop.
// Returns true on success, false otherwise.
WEBP_EXTERN int WebPDemuxNextFrame(WebPIterator* iter);
WEBP_EXTERN int WebPDemuxPrevFrame(WebPIterator* iter);
// Releases any memory associated with 'iter'.
// Must be called before any subsequent calls to WebPDemuxGetChunk() on the same
// iter. Also, must be called before destroying the associated WebPDemuxer with
// WebPDemuxDelete().
WEBP_EXTERN void WebPDemuxReleaseIterator(WebPIterator* iter);
//------------------------------------------------------------------------------
// Chunk iteration.
struct WebPChunkIterator {
// The current and total number of chunks with the fourcc given to
// WebPDemuxGetChunk().
int chunk_num;
int num_chunks;
WebPData chunk; // The payload of the chunk.
uint32_t pad[6]; // padding for later use
void* private_;
};
// Retrieves the 'chunk_number' instance of the chunk with id 'fourcc' from
// 'dmux'.
// 'fourcc' is a character array containing the fourcc of the chunk to return,
// e.g., "ICCP", "XMP ", "EXIF", etc.
// Setting 'chunk_number' equal to 0 will return the last chunk in a set.
// Returns true if the chunk is found, false otherwise. Image related chunk
// payloads are accessed through WebPDemuxGetFrame() and related functions.
// Call WebPDemuxReleaseChunkIterator() when use of the iterator is complete.
// NOTE: 'dmux' must persist for the lifetime of the iterator.
WEBP_EXTERN int WebPDemuxGetChunk(const WebPDemuxer* dmux,
const char fourcc[4], int chunk_number,
WebPChunkIterator* iter);
// Sets 'iter->chunk' to point to the next ('iter->chunk_num' + 1) or previous
// ('iter->chunk_num' - 1) chunk. These functions do not loop.
// Returns true on success, false otherwise.
WEBP_EXTERN int WebPDemuxNextChunk(WebPChunkIterator* iter);
WEBP_EXTERN int WebPDemuxPrevChunk(WebPChunkIterator* iter);
// Releases any memory associated with 'iter'.
// Must be called before destroying the associated WebPDemuxer with
// WebPDemuxDelete().
WEBP_EXTERN void WebPDemuxReleaseChunkIterator(WebPChunkIterator* iter);
//------------------------------------------------------------------------------
// WebPAnimDecoder API
//
// This API allows decoding (possibly) animated WebP images.
//
// Code Example:
/*
WebPAnimDecoderOptions dec_options;
WebPAnimDecoderOptionsInit(&dec_options);
// Tune 'dec_options' as needed.
WebPAnimDecoder* dec = WebPAnimDecoderNew(webp_data, &dec_options);
WebPAnimInfo anim_info;
WebPAnimDecoderGetInfo(dec, &anim_info);
for (uint32_t i = 0; i < anim_info.loop_count; ++i) {
while (WebPAnimDecoderHasMoreFrames(dec)) {
uint8_t* buf;
int timestamp;
WebPAnimDecoderGetNext(dec, &buf, ×tamp);
// ... (Render 'buf' based on 'timestamp').
// ... (Do NOT free 'buf', as it is owned by 'dec').
}
WebPAnimDecoderReset(dec);
}
const WebPDemuxer* demuxer = WebPAnimDecoderGetDemuxer(dec);
// ... (Do something using 'demuxer'; e.g. get EXIF/XMP/ICC data).
WebPAnimDecoderDelete(dec);
*/
typedef struct WebPAnimDecoder WebPAnimDecoder; // Main opaque object.
// Global options.
struct WebPAnimDecoderOptions {
// Output colorspace. Only the following modes are supported:
// MODE_RGBA, MODE_BGRA, MODE_rgbA and MODE_bgrA.
WEBP_CSP_MODE color_mode;
int use_threads; // If true, use multi-threaded decoding.
uint32_t padding[7]; // Padding for later use.
};
// Internal, version-checked, entry point.
WEBP_EXTERN int WebPAnimDecoderOptionsInitInternal(
WebPAnimDecoderOptions*, int);
// Should always be called, to initialize a fresh WebPAnimDecoderOptions
// structure before modification. Returns false in case of version mismatch.
// WebPAnimDecoderOptionsInit() must have succeeded before using the
// 'dec_options' object.
static WEBP_INLINE int WebPAnimDecoderOptionsInit(
WebPAnimDecoderOptions* dec_options) {
return WebPAnimDecoderOptionsInitInternal(dec_options,
WEBP_DEMUX_ABI_VERSION);
}
// Internal, version-checked, entry point.
WEBP_EXTERN WebPAnimDecoder* WebPAnimDecoderNewInternal(
const WebPData*, const WebPAnimDecoderOptions*, int);
// Creates and initializes a WebPAnimDecoder object.
// Parameters:
// webp_data - (in) WebP bitstream. This should remain unchanged during the
// lifetime of the output WebPAnimDecoder object.
// dec_options - (in) decoding options. Can be passed NULL to choose
// reasonable defaults (in particular, color mode MODE_RGBA
// will be picked).
// Returns:
// A pointer to the newly created WebPAnimDecoder object, or NULL in case of
// parsing error, invalid option or memory error.
static WEBP_INLINE WebPAnimDecoder* WebPAnimDecoderNew(
const WebPData* webp_data, const WebPAnimDecoderOptions* dec_options) {
return WebPAnimDecoderNewInternal(webp_data, dec_options,
WEBP_DEMUX_ABI_VERSION);
}
// Global information about the animation..
struct WebPAnimInfo {
uint32_t canvas_width;
uint32_t canvas_height;
uint32_t loop_count;
uint32_t bgcolor;
uint32_t frame_count;
uint32_t pad[4]; // padding for later use
};
// Get global information about the animation.
// Parameters:
// dec - (in) decoder instance to get information from.
// info - (out) global information fetched from the animation.
// Returns:
// True on success.
WEBP_EXTERN int WebPAnimDecoderGetInfo(const WebPAnimDecoder* dec,
WebPAnimInfo* info);
// Fetch the next frame from 'dec' based on options supplied to
// WebPAnimDecoderNew(). This will be a fully reconstructed canvas of size
// 'canvas_width * 4 * canvas_height', and not just the frame sub-rectangle. The
// returned buffer 'buf' is valid only until the next call to
// WebPAnimDecoderGetNext(), WebPAnimDecoderReset() or WebPAnimDecoderDelete().
// Parameters:
// dec - (in/out) decoder instance from which the next frame is to be fetched.
// buf - (out) decoded frame.
// timestamp - (out) timestamp of the frame in milliseconds.
// Returns:
// False if any of the arguments are NULL, or if there is a parsing or
// decoding error, or if there are no more frames. Otherwise, returns true.
WEBP_EXTERN int WebPAnimDecoderGetNext(WebPAnimDecoder* dec,
uint8_t** buf, int* timestamp);
// Check if there are more frames left to decode.
// Parameters:
// dec - (in) decoder instance to be checked.
// Returns:
// True if 'dec' is not NULL and some frames are yet to be decoded.
// Otherwise, returns false.
WEBP_EXTERN int WebPAnimDecoderHasMoreFrames(const WebPAnimDecoder* dec);
// Resets the WebPAnimDecoder object, so that next call to
// WebPAnimDecoderGetNext() will restart decoding from 1st frame. This would be
// helpful when all frames need to be decoded multiple times (e.g.
// info.loop_count times) without destroying and recreating the 'dec' object.
// Parameters:
// dec - (in/out) decoder instance to be reset
WEBP_EXTERN void WebPAnimDecoderReset(WebPAnimDecoder* dec);
// Grab the internal demuxer object.
// Getting the demuxer object can be useful if one wants to use operations only
// available through demuxer; e.g. to get XMP/EXIF/ICC metadata. The returned
// demuxer object is owned by 'dec' and is valid only until the next call to
// WebPAnimDecoderDelete().
//
// Parameters:
// dec - (in) decoder instance from which the demuxer object is to be fetched.
WEBP_EXTERN const WebPDemuxer* WebPAnimDecoderGetDemuxer(
const WebPAnimDecoder* dec);
// Deletes the WebPAnimDecoder object.
// Parameters:
// dec - (in/out) decoder instance to be deleted
WEBP_EXTERN void WebPAnimDecoderDelete(WebPAnimDecoder* dec);
#ifdef __cplusplus
} // extern "C"
#endif
#endif /* WEBP_WEBP_DEMUX_H_ */
webp/types.h 0000644 00000003201 15201526705 0007015 0 ustar 00 // Copyright 2010 Google Inc. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the COPYING file in the root of the source
// tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// -----------------------------------------------------------------------------
//
// Common types
//
// Author: Skal (pascal.massimino@gmail.com)
#ifndef WEBP_WEBP_TYPES_H_
#define WEBP_WEBP_TYPES_H_
#include <stddef.h> // for size_t
#ifndef _MSC_VER
#include <inttypes.h>
#if defined(__cplusplus) || !defined(__STRICT_ANSI__) || \
(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
#define WEBP_INLINE inline
#else
#define WEBP_INLINE
#endif
#else
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
typedef unsigned long long int uint64_t;
typedef long long int int64_t;
#define WEBP_INLINE __forceinline
#endif /* _MSC_VER */
#ifndef WEBP_EXTERN
// This explicitly marks library functions and allows for changing the
// signature for e.g., Windows DLL builds.
# if defined(__GNUC__) && __GNUC__ >= 4
# define WEBP_EXTERN extern __attribute__ ((visibility ("default")))
# else
# define WEBP_EXTERN extern
# endif /* __GNUC__ >= 4 */
#endif /* WEBP_EXTERN */
// Macro to check ABI compatibility (same major revision number)
#define WEBP_ABI_IS_INCOMPATIBLE(a, b) (((a) >> 8) != ((b) >> 8))
#endif /* WEBP_WEBP_TYPES_H_ */
webp/encode.h 0000644 00000065531 15201526705 0007124 0 ustar 00 // Copyright 2011 Google Inc. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the COPYING file in the root of the source
// tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// -----------------------------------------------------------------------------
//
// WebP encoder: main interface
//
// Author: Skal (pascal.massimino@gmail.com)
#ifndef WEBP_WEBP_ENCODE_H_
#define WEBP_WEBP_ENCODE_H_
#include "./types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define WEBP_ENCODER_ABI_VERSION 0x020e // MAJOR(8b) + MINOR(8b)
// Note: forward declaring enumerations is not allowed in (strict) C and C++,
// the types are left here for reference.
// typedef enum WebPImageHint WebPImageHint;
// typedef enum WebPEncCSP WebPEncCSP;
// typedef enum WebPPreset WebPPreset;
// typedef enum WebPEncodingError WebPEncodingError;
typedef struct WebPConfig WebPConfig;
typedef struct WebPPicture WebPPicture; // main structure for I/O
typedef struct WebPAuxStats WebPAuxStats;
typedef struct WebPMemoryWriter WebPMemoryWriter;
// Return the encoder's version number, packed in hexadecimal using 8bits for
// each of major/minor/revision. E.g: v2.5.7 is 0x020507.
WEBP_EXTERN int WebPGetEncoderVersion(void);
//------------------------------------------------------------------------------
// One-stop-shop call! No questions asked:
// Returns the size of the compressed data (pointed to by *output), or 0 if
// an error occurred. The compressed data must be released by the caller
// using the call 'WebPFree(*output)'.
// These functions compress using the lossy format, and the quality_factor
// can go from 0 (smaller output, lower quality) to 100 (best quality,
// larger output).
WEBP_EXTERN size_t WebPEncodeRGB(const uint8_t* rgb,
int width, int height, int stride,
float quality_factor, uint8_t** output);
WEBP_EXTERN size_t WebPEncodeBGR(const uint8_t* bgr,
int width, int height, int stride,
float quality_factor, uint8_t** output);
WEBP_EXTERN size_t WebPEncodeRGBA(const uint8_t* rgba,
int width, int height, int stride,
float quality_factor, uint8_t** output);
WEBP_EXTERN size_t WebPEncodeBGRA(const uint8_t* bgra,
int width, int height, int stride,
float quality_factor, uint8_t** output);
// These functions are the equivalent of the above, but compressing in a
// lossless manner. Files are usually larger than lossy format, but will
// not suffer any compression loss.
WEBP_EXTERN size_t WebPEncodeLosslessRGB(const uint8_t* rgb,
int width, int height, int stride,
uint8_t** output);
WEBP_EXTERN size_t WebPEncodeLosslessBGR(const uint8_t* bgr,
int width, int height, int stride,
uint8_t** output);
WEBP_EXTERN size_t WebPEncodeLosslessRGBA(const uint8_t* rgba,
int width, int height, int stride,
uint8_t** output);
WEBP_EXTERN size_t WebPEncodeLosslessBGRA(const uint8_t* bgra,
int width, int height, int stride,
uint8_t** output);
// Releases memory returned by the WebPEncode*() functions above.
WEBP_EXTERN void WebPFree(void* ptr);
//------------------------------------------------------------------------------
// Coding parameters
// Image characteristics hint for the underlying encoder.
typedef enum WebPImageHint {
WEBP_HINT_DEFAULT = 0, // default preset.
WEBP_HINT_PICTURE, // digital picture, like portrait, inner shot
WEBP_HINT_PHOTO, // outdoor photograph, with natural lighting
WEBP_HINT_GRAPH, // Discrete tone image (graph, map-tile etc).
WEBP_HINT_LAST
} WebPImageHint;
// Compression parameters.
struct WebPConfig {
int lossless; // Lossless encoding (0=lossy(default), 1=lossless).
float quality; // between 0 and 100. For lossy, 0 gives the smallest
// size and 100 the largest. For lossless, this
// parameter is the amount of effort put into the
// compression: 0 is the fastest but gives larger
// files compared to the slowest, but best, 100.
int method; // quality/speed trade-off (0=fast, 6=slower-better)
WebPImageHint image_hint; // Hint for image type (lossless only for now).
int target_size; // if non-zero, set the desired target size in bytes.
// Takes precedence over the 'compression' parameter.
float target_PSNR; // if non-zero, specifies the minimal distortion to
// try to achieve. Takes precedence over target_size.
int segments; // maximum number of segments to use, in [1..4]
int sns_strength; // Spatial Noise Shaping. 0=off, 100=maximum.
int filter_strength; // range: [0 = off .. 100 = strongest]
int filter_sharpness; // range: [0 = off .. 7 = least sharp]
int filter_type; // filtering type: 0 = simple, 1 = strong (only used
// if filter_strength > 0 or autofilter > 0)
int autofilter; // Auto adjust filter's strength [0 = off, 1 = on]
int alpha_compression; // Algorithm for encoding the alpha plane (0 = none,
// 1 = compressed with WebP lossless). Default is 1.
int alpha_filtering; // Predictive filtering method for alpha plane.
// 0: none, 1: fast, 2: best. Default if 1.
int alpha_quality; // Between 0 (smallest size) and 100 (lossless).
// Default is 100.
int pass; // number of entropy-analysis passes (in [1..10]).
int show_compressed; // if true, export the compressed picture back.
// In-loop filtering is not applied.
int preprocessing; // preprocessing filter:
// 0=none, 1=segment-smooth, 2=pseudo-random dithering
int partitions; // log2(number of token partitions) in [0..3]. Default
// is set to 0 for easier progressive decoding.
int partition_limit; // quality degradation allowed to fit the 512k limit
// on prediction modes coding (0: no degradation,
// 100: maximum possible degradation).
int emulate_jpeg_size; // If true, compression parameters will be remapped
// to better match the expected output size from
// JPEG compression. Generally, the output size will
// be similar but the degradation will be lower.
int thread_level; // If non-zero, try and use multi-threaded encoding.
int low_memory; // If set, reduce memory usage (but increase CPU use).
int near_lossless; // Near lossless encoding [0 = max loss .. 100 = off
// (default)].
int exact; // if non-zero, preserve the exact RGB values under
// transparent area. Otherwise, discard this invisible
// RGB information for better compression. The default
// value is 0.
int use_delta_palette; // reserved for future lossless feature
int use_sharp_yuv; // if needed, use sharp (and slow) RGB->YUV conversion
uint32_t pad[2]; // padding for later use
};
// Enumerate some predefined settings for WebPConfig, depending on the type
// of source picture. These presets are used when calling WebPConfigPreset().
typedef enum WebPPreset {
WEBP_PRESET_DEFAULT = 0, // default preset.
WEBP_PRESET_PICTURE, // digital picture, like portrait, inner shot
WEBP_PRESET_PHOTO, // outdoor photograph, with natural lighting
WEBP_PRESET_DRAWING, // hand or line drawing, with high-contrast details
WEBP_PRESET_ICON, // small-sized colorful images
WEBP_PRESET_TEXT // text-like
} WebPPreset;
// Internal, version-checked, entry point
WEBP_EXTERN int WebPConfigInitInternal(WebPConfig*, WebPPreset, float, int);
// Should always be called, to initialize a fresh WebPConfig structure before
// modification. Returns false in case of version mismatch. WebPConfigInit()
// must have succeeded before using the 'config' object.
// Note that the default values are lossless=0 and quality=75.
static WEBP_INLINE int WebPConfigInit(WebPConfig* config) {
return WebPConfigInitInternal(config, WEBP_PRESET_DEFAULT, 75.f,
WEBP_ENCODER_ABI_VERSION);
}
// This function will initialize the configuration according to a predefined
// set of parameters (referred to by 'preset') and a given quality factor.
// This function can be called as a replacement to WebPConfigInit(). Will
// return false in case of error.
static WEBP_INLINE int WebPConfigPreset(WebPConfig* config,
WebPPreset preset, float quality) {
return WebPConfigInitInternal(config, preset, quality,
WEBP_ENCODER_ABI_VERSION);
}
// Activate the lossless compression mode with the desired efficiency level
// between 0 (fastest, lowest compression) and 9 (slower, best compression).
// A good default level is '6', providing a fair tradeoff between compression
// speed and final compressed size.
// This function will overwrite several fields from config: 'method', 'quality'
// and 'lossless'. Returns false in case of parameter error.
WEBP_EXTERN int WebPConfigLosslessPreset(WebPConfig* config, int level);
// Returns true if 'config' is non-NULL and all configuration parameters are
// within their valid ranges.
WEBP_EXTERN int WebPValidateConfig(const WebPConfig* config);
//------------------------------------------------------------------------------
// Input / Output
// Structure for storing auxiliary statistics.
struct WebPAuxStats {
int coded_size; // final size
float PSNR[5]; // peak-signal-to-noise ratio for Y/U/V/All/Alpha
int block_count[3]; // number of intra4/intra16/skipped macroblocks
int header_bytes[2]; // approximate number of bytes spent for header
// and mode-partition #0
int residual_bytes[3][4]; // approximate number of bytes spent for
// DC/AC/uv coefficients for each (0..3) segments.
int segment_size[4]; // number of macroblocks in each segments
int segment_quant[4]; // quantizer values for each segments
int segment_level[4]; // filtering strength for each segments [0..63]
int alpha_data_size; // size of the transparency data
int layer_data_size; // size of the enhancement layer data
// lossless encoder statistics
uint32_t lossless_features; // bit0:predictor bit1:cross-color transform
// bit2:subtract-green bit3:color indexing
int histogram_bits; // number of precision bits of histogram
int transform_bits; // precision bits for transform
int cache_bits; // number of bits for color cache lookup
int palette_size; // number of color in palette, if used
int lossless_size; // final lossless size
int lossless_hdr_size; // lossless header (transform, huffman etc) size
int lossless_data_size; // lossless image data size
uint32_t pad[2]; // padding for later use
};
// Signature for output function. Should return true if writing was successful.
// data/data_size is the segment of data to write, and 'picture' is for
// reference (and so one can make use of picture->custom_ptr).
typedef int (*WebPWriterFunction)(const uint8_t* data, size_t data_size,
const WebPPicture* picture);
// WebPMemoryWrite: a special WebPWriterFunction that writes to memory using
// the following WebPMemoryWriter object (to be set as a custom_ptr).
struct WebPMemoryWriter {
uint8_t* mem; // final buffer (of size 'max_size', larger than 'size').
size_t size; // final size
size_t max_size; // total capacity
uint32_t pad[1]; // padding for later use
};
// The following must be called first before any use.
WEBP_EXTERN void WebPMemoryWriterInit(WebPMemoryWriter* writer);
// The following must be called to deallocate writer->mem memory. The 'writer'
// object itself is not deallocated.
WEBP_EXTERN void WebPMemoryWriterClear(WebPMemoryWriter* writer);
// The custom writer to be used with WebPMemoryWriter as custom_ptr. Upon
// completion, writer.mem and writer.size will hold the coded data.
// writer.mem must be freed by calling WebPMemoryWriterClear.
WEBP_EXTERN int WebPMemoryWrite(const uint8_t* data, size_t data_size,
const WebPPicture* picture);
// Progress hook, called from time to time to report progress. It can return
// false to request an abort of the encoding process, or true otherwise if
// everything is OK.
typedef int (*WebPProgressHook)(int percent, const WebPPicture* picture);
// Color spaces.
typedef enum WebPEncCSP {
// chroma sampling
WEBP_YUV420 = 0, // 4:2:0
WEBP_YUV420A = 4, // alpha channel variant
WEBP_CSP_UV_MASK = 3, // bit-mask to get the UV sampling factors
WEBP_CSP_ALPHA_BIT = 4 // bit that is set if alpha is present
} WebPEncCSP;
// Encoding error conditions.
typedef enum WebPEncodingError {
VP8_ENC_OK = 0,
VP8_ENC_ERROR_OUT_OF_MEMORY, // memory error allocating objects
VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY, // memory error while flushing bits
VP8_ENC_ERROR_NULL_PARAMETER, // a pointer parameter is NULL
VP8_ENC_ERROR_INVALID_CONFIGURATION, // configuration is invalid
VP8_ENC_ERROR_BAD_DIMENSION, // picture has invalid width/height
VP8_ENC_ERROR_PARTITION0_OVERFLOW, // partition is bigger than 512k
VP8_ENC_ERROR_PARTITION_OVERFLOW, // partition is bigger than 16M
VP8_ENC_ERROR_BAD_WRITE, // error while flushing bytes
VP8_ENC_ERROR_FILE_TOO_BIG, // file is bigger than 4G
VP8_ENC_ERROR_USER_ABORT, // abort request by user
VP8_ENC_ERROR_LAST // list terminator. always last.
} WebPEncodingError;
// maximum width/height allowed (inclusive), in pixels
#define WEBP_MAX_DIMENSION 16383
// Main exchange structure (input samples, output bytes, statistics)
struct WebPPicture {
// INPUT
//////////////
// Main flag for encoder selecting between ARGB or YUV input.
// It is recommended to use ARGB input (*argb, argb_stride) for lossless
// compression, and YUV input (*y, *u, *v, etc.) for lossy compression
// since these are the respective native colorspace for these formats.
int use_argb;
// YUV input (mostly used for input to lossy compression)
WebPEncCSP colorspace; // colorspace: should be YUV420 for now (=Y'CbCr).
int width, height; // dimensions (less or equal to WEBP_MAX_DIMENSION)
uint8_t *y, *u, *v; // pointers to luma/chroma planes.
int y_stride, uv_stride; // luma/chroma strides.
uint8_t* a; // pointer to the alpha plane
int a_stride; // stride of the alpha plane
uint32_t pad1[2]; // padding for later use
// ARGB input (mostly used for input to lossless compression)
uint32_t* argb; // Pointer to argb (32 bit) plane.
int argb_stride; // This is stride in pixels units, not bytes.
uint32_t pad2[3]; // padding for later use
// OUTPUT
///////////////
// Byte-emission hook, to store compressed bytes as they are ready.
WebPWriterFunction writer; // can be NULL
void* custom_ptr; // can be used by the writer.
// map for extra information (only for lossy compression mode)
int extra_info_type; // 1: intra type, 2: segment, 3: quant
// 4: intra-16 prediction mode,
// 5: chroma prediction mode,
// 6: bit cost, 7: distortion
uint8_t* extra_info; // if not NULL, points to an array of size
// ((width + 15) / 16) * ((height + 15) / 16) that
// will be filled with a macroblock map, depending
// on extra_info_type.
// STATS AND REPORTS
///////////////////////////
// Pointer to side statistics (updated only if not NULL)
WebPAuxStats* stats;
// Error code for the latest error encountered during encoding
WebPEncodingError error_code;
// If not NULL, report progress during encoding.
WebPProgressHook progress_hook;
void* user_data; // this field is free to be set to any value and
// used during callbacks (like progress-report e.g.).
uint32_t pad3[3]; // padding for later use
// Unused for now
uint8_t *pad4, *pad5;
uint32_t pad6[8]; // padding for later use
// PRIVATE FIELDS
////////////////////
void* memory_; // row chunk of memory for yuva planes
void* memory_argb_; // and for argb too.
void* pad7[2]; // padding for later use
};
// Internal, version-checked, entry point
WEBP_EXTERN int WebPPictureInitInternal(WebPPicture*, int);
// Should always be called, to initialize the structure. Returns false in case
// of version mismatch. WebPPictureInit() must have succeeded before using the
// 'picture' object.
// Note that, by default, use_argb is false and colorspace is WEBP_YUV420.
static WEBP_INLINE int WebPPictureInit(WebPPicture* picture) {
return WebPPictureInitInternal(picture, WEBP_ENCODER_ABI_VERSION);
}
//------------------------------------------------------------------------------
// WebPPicture utils
// Convenience allocation / deallocation based on picture->width/height:
// Allocate y/u/v buffers as per colorspace/width/height specification.
// Note! This function will free the previous buffer if needed.
// Returns false in case of memory error.
WEBP_EXTERN int WebPPictureAlloc(WebPPicture* picture);
// Release the memory allocated by WebPPictureAlloc() or WebPPictureImport*().
// Note that this function does _not_ free the memory used by the 'picture'
// object itself.
// Besides memory (which is reclaimed) all other fields of 'picture' are
// preserved.
WEBP_EXTERN void WebPPictureFree(WebPPicture* picture);
// Copy the pixels of *src into *dst, using WebPPictureAlloc. Upon return, *dst
// will fully own the copied pixels (this is not a view). The 'dst' picture need
// not be initialized as its content is overwritten.
// Returns false in case of memory allocation error.
WEBP_EXTERN int WebPPictureCopy(const WebPPicture* src, WebPPicture* dst);
// Compute the single distortion for packed planes of samples.
// 'src' will be compared to 'ref', and the raw distortion stored into
// '*distortion'. The refined metric (log(MSE), log(1 - ssim),...' will be
// stored in '*result'.
// 'x_step' is the horizontal stride (in bytes) between samples.
// 'src/ref_stride' is the byte distance between rows.
// Returns false in case of error (bad parameter, memory allocation error, ...).
WEBP_EXTERN int WebPPlaneDistortion(const uint8_t* src, size_t src_stride,
const uint8_t* ref, size_t ref_stride,
int width, int height,
size_t x_step,
int type, // 0 = PSNR, 1 = SSIM, 2 = LSIM
float* distortion, float* result);
// Compute PSNR, SSIM or LSIM distortion metric between two pictures. Results
// are in dB, stored in result[] in the B/G/R/A/All order. The distortion is
// always performed using ARGB samples. Hence if the input is YUV(A), the
// picture will be internally converted to ARGB (just for the measurement).
// Warning: this function is rather CPU-intensive.
WEBP_EXTERN int WebPPictureDistortion(
const WebPPicture* src, const WebPPicture* ref,
int metric_type, // 0 = PSNR, 1 = SSIM, 2 = LSIM
float result[5]);
// self-crops a picture to the rectangle defined by top/left/width/height.
// Returns false in case of memory allocation error, or if the rectangle is
// outside of the source picture.
// The rectangle for the view is defined by the top-left corner pixel
// coordinates (left, top) as well as its width and height. This rectangle
// must be fully be comprised inside the 'src' source picture. If the source
// picture uses the YUV420 colorspace, the top and left coordinates will be
// snapped to even values.
WEBP_EXTERN int WebPPictureCrop(WebPPicture* picture,
int left, int top, int width, int height);
// Extracts a view from 'src' picture into 'dst'. The rectangle for the view
// is defined by the top-left corner pixel coordinates (left, top) as well
// as its width and height. This rectangle must be fully be comprised inside
// the 'src' source picture. If the source picture uses the YUV420 colorspace,
// the top and left coordinates will be snapped to even values.
// Picture 'src' must out-live 'dst' picture. Self-extraction of view is allowed
// ('src' equal to 'dst') as a mean of fast-cropping (but note that doing so,
// the original dimension will be lost). Picture 'dst' need not be initialized
// with WebPPictureInit() if it is different from 'src', since its content will
// be overwritten.
// Returns false in case of memory allocation error or invalid parameters.
WEBP_EXTERN int WebPPictureView(const WebPPicture* src,
int left, int top, int width, int height,
WebPPicture* dst);
// Returns true if the 'picture' is actually a view and therefore does
// not own the memory for pixels.
WEBP_EXTERN int WebPPictureIsView(const WebPPicture* picture);
// Rescale a picture to new dimension width x height.
// If either 'width' or 'height' (but not both) is 0 the corresponding
// dimension will be calculated preserving the aspect ratio.
// No gamma correction is applied.
// Returns false in case of error (invalid parameter or insufficient memory).
WEBP_EXTERN int WebPPictureRescale(WebPPicture* pic, int width, int height);
// Colorspace conversion function to import RGB samples.
// Previous buffer will be free'd, if any.
// *rgb buffer should have a size of at least height * rgb_stride.
// Returns false in case of memory error.
WEBP_EXTERN int WebPPictureImportRGB(
WebPPicture* picture, const uint8_t* rgb, int rgb_stride);
// Same, but for RGBA buffer.
WEBP_EXTERN int WebPPictureImportRGBA(
WebPPicture* picture, const uint8_t* rgba, int rgba_stride);
// Same, but for RGBA buffer. Imports the RGB direct from the 32-bit format
// input buffer ignoring the alpha channel. Avoids needing to copy the data
// to a temporary 24-bit RGB buffer to import the RGB only.
WEBP_EXTERN int WebPPictureImportRGBX(
WebPPicture* picture, const uint8_t* rgbx, int rgbx_stride);
// Variants of the above, but taking BGR(A|X) input.
WEBP_EXTERN int WebPPictureImportBGR(
WebPPicture* picture, const uint8_t* bgr, int bgr_stride);
WEBP_EXTERN int WebPPictureImportBGRA(
WebPPicture* picture, const uint8_t* bgra, int bgra_stride);
WEBP_EXTERN int WebPPictureImportBGRX(
WebPPicture* picture, const uint8_t* bgrx, int bgrx_stride);
// Converts picture->argb data to the YUV420A format. The 'colorspace'
// parameter is deprecated and should be equal to WEBP_YUV420.
// Upon return, picture->use_argb is set to false. The presence of real
// non-opaque transparent values is detected, and 'colorspace' will be
// adjusted accordingly. Note that this method is lossy.
// Returns false in case of error.
WEBP_EXTERN int WebPPictureARGBToYUVA(WebPPicture* picture,
WebPEncCSP /*colorspace = WEBP_YUV420*/);
// Same as WebPPictureARGBToYUVA(), but the conversion is done using
// pseudo-random dithering with a strength 'dithering' between
// 0.0 (no dithering) and 1.0 (maximum dithering). This is useful
// for photographic picture.
WEBP_EXTERN int WebPPictureARGBToYUVADithered(
WebPPicture* picture, WebPEncCSP colorspace, float dithering);
// Performs 'sharp' RGBA->YUVA420 downsampling and colorspace conversion.
// Downsampling is handled with extra care in case of color clipping. This
// method is roughly 2x slower than WebPPictureARGBToYUVA() but produces better
// and sharper YUV representation.
// Returns false in case of error.
WEBP_EXTERN int WebPPictureSharpARGBToYUVA(WebPPicture* picture);
// kept for backward compatibility:
WEBP_EXTERN int WebPPictureSmartARGBToYUVA(WebPPicture* picture);
// Converts picture->yuv to picture->argb and sets picture->use_argb to true.
// The input format must be YUV_420 or YUV_420A. The conversion from YUV420 to
// ARGB incurs a small loss too.
// Note that the use of this colorspace is discouraged if one has access to the
// raw ARGB samples, since using YUV420 is comparatively lossy.
// Returns false in case of error.
WEBP_EXTERN int WebPPictureYUVAToARGB(WebPPicture* picture);
// Helper function: given a width x height plane of RGBA or YUV(A) samples
// clean-up or smoothen the YUV or RGB samples under fully transparent area,
// to help compressibility (no guarantee, though).
WEBP_EXTERN void WebPCleanupTransparentArea(WebPPicture* picture);
// Scan the picture 'picture' for the presence of non fully opaque alpha values.
// Returns true in such case. Otherwise returns false (indicating that the
// alpha plane can be ignored altogether e.g.).
WEBP_EXTERN int WebPPictureHasTransparency(const WebPPicture* picture);
// Remove the transparency information (if present) by blending the color with
// the background color 'background_rgb' (specified as 24bit RGB triplet).
// After this call, all alpha values are reset to 0xff.
WEBP_EXTERN void WebPBlendAlpha(WebPPicture* pic, uint32_t background_rgb);
//------------------------------------------------------------------------------
// Main call
// Main encoding call, after config and picture have been initialized.
// 'picture' must be less than 16384x16384 in dimension (cf WEBP_MAX_DIMENSION),
// and the 'config' object must be a valid one.
// Returns false in case of error, true otherwise.
// In case of error, picture->error_code is updated accordingly.
// 'picture' can hold the source samples in both YUV(A) or ARGB input, depending
// on the value of 'picture->use_argb'. It is highly recommended to use
// the former for lossy encoding, and the latter for lossless encoding
// (when config.lossless is true). Automatic conversion from one format to
// another is provided but they both incur some loss.
WEBP_EXTERN int WebPEncode(const WebPConfig* config, WebPPicture* picture);
//------------------------------------------------------------------------------
#ifdef __cplusplus
} // extern "C"
#endif
#endif /* WEBP_WEBP_ENCODE_H_ */
webp/mux_types.h 0000644 00000006116 15201526705 0007716 0 ustar 00 // Copyright 2012 Google Inc. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the COPYING file in the root of the source
// tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// -----------------------------------------------------------------------------
//
// Data-types common to the mux and demux libraries.
//
// Author: Urvang (urvang@google.com)
#ifndef WEBP_WEBP_MUX_TYPES_H_
#define WEBP_WEBP_MUX_TYPES_H_
#include <stdlib.h> // free()
#include <string.h> // memset()
#include "./types.h"
#ifdef __cplusplus
extern "C" {
#endif
// Note: forward declaring enumerations is not allowed in (strict) C and C++,
// the types are left here for reference.
// typedef enum WebPFeatureFlags WebPFeatureFlags;
// typedef enum WebPMuxAnimDispose WebPMuxAnimDispose;
// typedef enum WebPMuxAnimBlend WebPMuxAnimBlend;
typedef struct WebPData WebPData;
// VP8X Feature Flags.
typedef enum WebPFeatureFlags {
ANIMATION_FLAG = 0x00000002,
XMP_FLAG = 0x00000004,
EXIF_FLAG = 0x00000008,
ALPHA_FLAG = 0x00000010,
ICCP_FLAG = 0x00000020,
ALL_VALID_FLAGS = 0x0000003e
} WebPFeatureFlags;
// Dispose method (animation only). Indicates how the area used by the current
// frame is to be treated before rendering the next frame on the canvas.
typedef enum WebPMuxAnimDispose {
WEBP_MUX_DISPOSE_NONE, // Do not dispose.
WEBP_MUX_DISPOSE_BACKGROUND // Dispose to background color.
} WebPMuxAnimDispose;
// Blend operation (animation only). Indicates how transparent pixels of the
// current frame are blended with those of the previous canvas.
typedef enum WebPMuxAnimBlend {
WEBP_MUX_BLEND, // Blend.
WEBP_MUX_NO_BLEND // Do not blend.
} WebPMuxAnimBlend;
// Data type used to describe 'raw' data, e.g., chunk data
// (ICC profile, metadata) and WebP compressed image data.
struct WebPData {
const uint8_t* bytes;
size_t size;
};
// Initializes the contents of the 'webp_data' object with default values.
static WEBP_INLINE void WebPDataInit(WebPData* webp_data) {
if (webp_data != NULL) {
memset(webp_data, 0, sizeof(*webp_data));
}
}
// Clears the contents of the 'webp_data' object by calling free(). Does not
// deallocate the object itself.
static WEBP_INLINE void WebPDataClear(WebPData* webp_data) {
if (webp_data != NULL) {
free((void*)webp_data->bytes);
WebPDataInit(webp_data);
}
}
// Allocates necessary storage for 'dst' and copies the contents of 'src'.
// Returns true on success.
static WEBP_INLINE int WebPDataCopy(const WebPData* src, WebPData* dst) {
if (src == NULL || dst == NULL) return 0;
WebPDataInit(dst);
if (src->bytes != NULL && src->size != 0) {
dst->bytes = (uint8_t*)malloc(src->size);
if (dst->bytes == NULL) return 0;
memcpy((void*)dst->bytes, src->bytes, src->size);
dst->size = src->size;
}
return 1;
}
#ifdef __cplusplus
} // extern "C"
#endif
#endif /* WEBP_WEBP_MUX_TYPES_H_ */
evhttp.h 0000644 00000003763 15201526705 0006243 0 ustar 00 /*
* Copyright 2000-2007 Niels Provos <provos@citi.umich.edu>
* Copyright 2007-2012 Niels Provos and Nick Mathewson
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef EVENT1_EVHTTP_H_INCLUDED_
#define EVENT1_EVHTTP_H_INCLUDED_
/** @file evhttp.h
An http implementation subsystem for Libevent.
The <evhttp.h> header is deprecated in Libevent 2.0 and later; please
use <event2/http.h> instead. Depending on what functionality you
need, you may also want to include more of the other <event2/...>
headers.
*/
#include <event.h>
#include <event2/http.h>
#include <event2/http_struct.h>
#include <event2/http_compat.h>
#endif /* EVENT1_EVHTTP_H_INCLUDED_ */
complex.h 0000644 00000015773 15201526705 0006404 0 ustar 00 /* Copyright (C) 1997-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
/*
* ISO C99: 7.3 Complex arithmetic <complex.h>
*/
#ifndef _COMPLEX_H
#define _COMPLEX_H 1
#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
#include <bits/libc-header-start.h>
/* Get general and ISO C99 specific information. */
#include <bits/mathdef.h>
/* Gather machine-dependent _FloatN type support. */
#include <bits/floatn.h>
__BEGIN_DECLS
/* We might need to add support for more compilers here. But since ISO
C99 is out hopefully all maintained compilers will soon provide the data
types `float complex' and `double complex'. */
#if __GNUC_PREREQ (2, 7) && !__GNUC_PREREQ (2, 97)
# define _Complex __complex__
#endif
#define complex _Complex
/* Narrowest imaginary unit. This depends on the floating-point
evaluation method.
XXX This probably has to go into a gcc related file. */
#define _Complex_I (__extension__ 1.0iF)
/* Another more descriptive name is `I'.
XXX Once we have the imaginary support switch this to _Imaginary_I. */
#undef I
#define I _Complex_I
#if defined __USE_ISOC11 && __GNUC_PREREQ (4, 7)
/* Macros to expand into expression of specified complex type. */
# define CMPLX(x, y) __builtin_complex ((double) (x), (double) (y))
# define CMPLXF(x, y) __builtin_complex ((float) (x), (float) (y))
# define CMPLXL(x, y) __builtin_complex ((long double) (x), (long double) (y))
#endif
#if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT)
# define CMPLXF16(x, y) __builtin_complex ((_Float16) (x), (_Float16) (y))
#endif
#if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT)
# define CMPLXF32(x, y) __builtin_complex ((_Float32) (x), (_Float32) (y))
#endif
#if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT)
# define CMPLXF64(x, y) __builtin_complex ((_Float64) (x), (_Float64) (y))
#endif
#if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)
# define CMPLXF128(x, y) __builtin_complex ((_Float128) (x), (_Float128) (y))
#endif
#if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT)
# define CMPLXF32X(x, y) __builtin_complex ((_Float32x) (x), (_Float32x) (y))
#endif
#if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT)
# define CMPLXF64X(x, y) __builtin_complex ((_Float64x) (x), (_Float64x) (y))
#endif
#if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT)
# define CMPLXF128X(x, y) \
__builtin_complex ((_Float128x) (x), (_Float128x) (y))
#endif
/* The file <bits/cmathcalls.h> contains the prototypes for all the
actual math functions. These macros are used for those prototypes,
so we can easily declare each function as both `name' and `__name',
and can declare the float versions `namef' and `__namef'. */
#define __MATHCALL(function, args) \
__MATHDECL (_Mdouble_complex_,function, args)
#define __MATHDECL(type, function, args) \
__MATHDECL_1(type, function, args); \
__MATHDECL_1(type, __CONCAT(__,function), args)
#define __MATHDECL_1(type, function, args) \
extern type __MATH_PRECNAME(function) args __THROW
#define _Mdouble_ double
#define __MATH_PRECNAME(name) name
#include <bits/cmathcalls.h>
#undef _Mdouble_
#undef __MATH_PRECNAME
/* Now the float versions. */
#define _Mdouble_ float
#define __MATH_PRECNAME(name) name##f
#include <bits/cmathcalls.h>
#undef _Mdouble_
#undef __MATH_PRECNAME
/* And the long double versions. It is non-critical to define them
here unconditionally since `long double' is required in ISO C99. */
#if !(defined __NO_LONG_DOUBLE_MATH && defined _LIBC) \
|| defined __LDBL_COMPAT
# ifdef __LDBL_COMPAT
# undef __MATHDECL_1
# define __MATHDECL_1(type, function, args) \
extern type __REDIRECT_NTH(__MATH_PRECNAME(function), args, function)
# endif
# define _Mdouble_ long double
# define __MATH_PRECNAME(name) name##l
# include <bits/cmathcalls.h>
#endif
#undef _Mdouble_
#undef __MATH_PRECNAME
#if (__HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !defined _LIBC)) \
&& __GLIBC_USE (IEC_60559_TYPES_EXT)
# undef _Mdouble_complex_
# define _Mdouble_complex_ __CFLOAT16
# define _Mdouble_ _Float16
# define __MATH_PRECNAME(name) name##f16
# include <bits/cmathcalls.h>
# undef _Mdouble_
# undef __MATH_PRECNAME
# undef _Mdouble_complex_
#endif
#if (__HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !defined _LIBC)) \
&& __GLIBC_USE (IEC_60559_TYPES_EXT)
# undef _Mdouble_complex_
# define _Mdouble_complex_ __CFLOAT32
# define _Mdouble_ _Float32
# define __MATH_PRECNAME(name) name##f32
# include <bits/cmathcalls.h>
# undef _Mdouble_
# undef __MATH_PRECNAME
# undef _Mdouble_complex_
#endif
#if (__HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !defined _LIBC)) \
&& __GLIBC_USE (IEC_60559_TYPES_EXT)
# undef _Mdouble_complex_
# define _Mdouble_complex_ __CFLOAT64
# define _Mdouble_ _Float64
# define __MATH_PRECNAME(name) name##f64
# include <bits/cmathcalls.h>
# undef _Mdouble_
# undef __MATH_PRECNAME
# undef _Mdouble_complex_
#endif
#if (__HAVE_DISTINCT_FLOAT128 || (__HAVE_FLOAT128 && !defined _LIBC)) \
&& __GLIBC_USE (IEC_60559_TYPES_EXT)
# undef _Mdouble_complex_
# define _Mdouble_complex_ __CFLOAT128
# define _Mdouble_ _Float128
# define __MATH_PRECNAME(name) name##f128
# include <bits/cmathcalls.h>
# undef _Mdouble_
# undef __MATH_PRECNAME
# undef _Mdouble_complex_
#endif
#if (__HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !defined _LIBC)) \
&& __GLIBC_USE (IEC_60559_TYPES_EXT)
# undef _Mdouble_complex_
# define _Mdouble_complex_ __CFLOAT32X
# define _Mdouble_ _Float32x
# define __MATH_PRECNAME(name) name##f32x
# include <bits/cmathcalls.h>
# undef _Mdouble_
# undef __MATH_PRECNAME
# undef _Mdouble_complex_
#endif
#if (__HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !defined _LIBC)) \
&& __GLIBC_USE (IEC_60559_TYPES_EXT)
# undef _Mdouble_complex_
# define _Mdouble_complex_ __CFLOAT64X
# define _Mdouble_ _Float64x
# define __MATH_PRECNAME(name) name##f64x
# include <bits/cmathcalls.h>
# undef _Mdouble_
# undef __MATH_PRECNAME
# undef _Mdouble_complex_
#endif
#if (__HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !defined _LIBC)) \
&& __GLIBC_USE (IEC_60559_TYPES_EXT)
# undef _Mdouble_complex_
# define _Mdouble_complex_ __CFLOAT128X
# define _Mdouble_ _Float128x
# define __MATH_PRECNAME(name) name##f128x
# include <bits/cmathcalls.h>
# undef _Mdouble_
# undef __MATH_PRECNAME
# undef _Mdouble_complex_
#endif
#undef __MATHDECL_1
#undef __MATHDECL
#undef __MATHCALL
__END_DECLS
#endif /* complex.h */
tiffconf.h 0000644 00000000372 15201526705 0006520 0 ustar 00 #ifndef TIFFCONF_H_MULTILIB
#define TIFFCONF_H_MULTILIB
#include <bits/wordsize.h>
#if __WORDSIZE == 32
# include "tiffconf-32.h"
#elif __WORDSIZE == 64
# include "tiffconf-64.h"
#else
# error "unexpected value for __WORDSIZE macro"
#endif
#endif
tiffvers.h 0000644 00000000632 15201526705 0006551 0 ustar 00 #define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.0.9\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc."
/*
* This define can be used in code that requires
* compilation-related definitions specific to a
* version or versions of the library. Runtime
* version checking should be done based on the
* string returned by TIFFGetVersion.
*/
#define TIFFLIB_VERSION 20171118
ulimit.h 0000644 00000003057 15201526705 0006230 0 ustar 00 /* Copyright (C) 1997-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef _ULIMIT_H
#define _ULIMIT_H 1
#include <features.h>
/* Constants used as the first parameter for `ulimit'. They denote limits
which can be set or retrieved using this function. */
enum
{
UL_GETFSIZE = 1, /* Return limit on the size of a file,
in units of 512 bytes. */
#define UL_GETFSIZE UL_GETFSIZE
UL_SETFSIZE, /* Set limit on the size of a file to
second argument. */
#define UL_SETFSIZE UL_SETFSIZE
__UL_GETMAXBRK, /* Return the maximum possible address
of the data segment. */
__UL_GETOPENMAX /* Return the maximum number of files
that the calling process can open.*/
};
__BEGIN_DECLS
/* Control process limits according to CMD. */
extern long int ulimit (int __cmd, ...) __THROW;
__END_DECLS
#endif /* ulimit.h */
langinfo.h 0000644 00000042670 15201526705 0006526 0 ustar 00 /* Access to locale-dependent parameters.
Copyright (C) 1995-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef _LANGINFO_H
#define _LANGINFO_H 1
/* Get the type definition. */
#include <nl_types.h>
#include <bits/locale.h> /* Define the __LC_* category names. */
__BEGIN_DECLS
/* Construct an `nl_item' value for `nl_langinfo' from a locale category
(LC_*) and an item index within the category. Some code may depend on
the item values within a category increasing monotonically with the
indices. */
#define _NL_ITEM(category, index) (((category) << 16) | (index))
/* Extract the category and item index from a constructed `nl_item' value. */
#define _NL_ITEM_CATEGORY(item) ((int) (item) >> 16)
#define _NL_ITEM_INDEX(item) ((int) (item) & 0xffff)
/* Enumeration of locale items that can be queried with `nl_langinfo'. */
enum
{
/* LC_TIME category: date and time formatting. */
/* Abbreviated days of the week. */
ABDAY_1 = _NL_ITEM (__LC_TIME, 0), /* Sun */
#define ABDAY_1 ABDAY_1
ABDAY_2,
#define ABDAY_2 ABDAY_2
ABDAY_3,
#define ABDAY_3 ABDAY_3
ABDAY_4,
#define ABDAY_4 ABDAY_4
ABDAY_5,
#define ABDAY_5 ABDAY_5
ABDAY_6,
#define ABDAY_6 ABDAY_6
ABDAY_7,
#define ABDAY_7 ABDAY_7
/* Long-named days of the week. */
DAY_1, /* Sunday */
#define DAY_1 DAY_1
DAY_2, /* Monday */
#define DAY_2 DAY_2
DAY_3, /* Tuesday */
#define DAY_3 DAY_3
DAY_4, /* Wednesday */
#define DAY_4 DAY_4
DAY_5, /* Thursday */
#define DAY_5 DAY_5
DAY_6, /* Friday */
#define DAY_6 DAY_6
DAY_7, /* Saturday */
#define DAY_7 DAY_7
/* Abbreviated month names, in the grammatical form used when the month
is a part of a complete date. */
ABMON_1, /* Jan */
#define ABMON_1 ABMON_1
ABMON_2,
#define ABMON_2 ABMON_2
ABMON_3,
#define ABMON_3 ABMON_3
ABMON_4,
#define ABMON_4 ABMON_4
ABMON_5,
#define ABMON_5 ABMON_5
ABMON_6,
#define ABMON_6 ABMON_6
ABMON_7,
#define ABMON_7 ABMON_7
ABMON_8,
#define ABMON_8 ABMON_8
ABMON_9,
#define ABMON_9 ABMON_9
ABMON_10,
#define ABMON_10 ABMON_10
ABMON_11,
#define ABMON_11 ABMON_11
ABMON_12,
#define ABMON_12 ABMON_12
/* Long month names, in the grammatical form used when the month
is a part of a complete date. */
MON_1, /* January */
#define MON_1 MON_1
MON_2,
#define MON_2 MON_2
MON_3,
#define MON_3 MON_3
MON_4,
#define MON_4 MON_4
MON_5,
#define MON_5 MON_5
MON_6,
#define MON_6 MON_6
MON_7,
#define MON_7 MON_7
MON_8,
#define MON_8 MON_8
MON_9,
#define MON_9 MON_9
MON_10,
#define MON_10 MON_10
MON_11,
#define MON_11 MON_11
MON_12,
#define MON_12 MON_12
AM_STR, /* Ante meridiem string. */
#define AM_STR AM_STR
PM_STR, /* Post meridiem string. */
#define PM_STR PM_STR
D_T_FMT, /* Date and time format for strftime. */
#define D_T_FMT D_T_FMT
D_FMT, /* Date format for strftime. */
#define D_FMT D_FMT
T_FMT, /* Time format for strftime. */
#define T_FMT T_FMT
T_FMT_AMPM, /* 12-hour time format for strftime. */
#define T_FMT_AMPM T_FMT_AMPM
ERA, /* Alternate era. */
#define ERA ERA
__ERA_YEAR, /* Year in alternate era format. */
#ifdef __USE_GNU
# define ERA_YEAR __ERA_YEAR
#endif
ERA_D_FMT, /* Date in alternate era format. */
#define ERA_D_FMT ERA_D_FMT
ALT_DIGITS, /* Alternate symbols for digits. */
#define ALT_DIGITS ALT_DIGITS
ERA_D_T_FMT, /* Date and time in alternate era format. */
#define ERA_D_T_FMT ERA_D_T_FMT
ERA_T_FMT, /* Time in alternate era format. */
#define ERA_T_FMT ERA_T_FMT
_NL_TIME_ERA_NUM_ENTRIES, /* Number entries in the era arrays. */
_NL_TIME_ERA_ENTRIES, /* Structure with era entries in usable form.*/
_NL_WABDAY_1, /* Sun */
_NL_WABDAY_2,
_NL_WABDAY_3,
_NL_WABDAY_4,
_NL_WABDAY_5,
_NL_WABDAY_6,
_NL_WABDAY_7,
/* Long-named days of the week. */
_NL_WDAY_1, /* Sunday */
_NL_WDAY_2, /* Monday */
_NL_WDAY_3, /* Tuesday */
_NL_WDAY_4, /* Wednesday */
_NL_WDAY_5, /* Thursday */
_NL_WDAY_6, /* Friday */
_NL_WDAY_7, /* Saturday */
/* Abbreviated month names, in the grammatical form used when the month
is a part of a complete date. */
_NL_WABMON_1, /* Jan */
_NL_WABMON_2,
_NL_WABMON_3,
_NL_WABMON_4,
_NL_WABMON_5,
_NL_WABMON_6,
_NL_WABMON_7,
_NL_WABMON_8,
_NL_WABMON_9,
_NL_WABMON_10,
_NL_WABMON_11,
_NL_WABMON_12,
/* Long month names, in the grammatical form used when the month
is a part of a complete date. */
_NL_WMON_1, /* January */
_NL_WMON_2,
_NL_WMON_3,
_NL_WMON_4,
_NL_WMON_5,
_NL_WMON_6,
_NL_WMON_7,
_NL_WMON_8,
_NL_WMON_9,
_NL_WMON_10,
_NL_WMON_11,
_NL_WMON_12,
_NL_WAM_STR, /* Ante meridiem string. */
_NL_WPM_STR, /* Post meridiem string. */
_NL_WD_T_FMT, /* Date and time format for strftime. */
_NL_WD_FMT, /* Date format for strftime. */
_NL_WT_FMT, /* Time format for strftime. */
_NL_WT_FMT_AMPM, /* 12-hour time format for strftime. */
_NL_WERA_YEAR, /* Year in alternate era format. */
_NL_WERA_D_FMT, /* Date in alternate era format. */
_NL_WALT_DIGITS, /* Alternate symbols for digits. */
_NL_WERA_D_T_FMT, /* Date and time in alternate era format. */
_NL_WERA_T_FMT, /* Time in alternate era format. */
_NL_TIME_WEEK_NDAYS,
_NL_TIME_WEEK_1STDAY,
_NL_TIME_WEEK_1STWEEK,
_NL_TIME_FIRST_WEEKDAY,
_NL_TIME_FIRST_WORKDAY,
_NL_TIME_CAL_DIRECTION,
_NL_TIME_TIMEZONE,
_DATE_FMT, /* strftime format for date. */
#define _DATE_FMT _DATE_FMT
_NL_W_DATE_FMT,
_NL_TIME_CODESET,
/* Long month names, in the grammatical form used when the month
is named by itself. */
__ALTMON_1, /* January */
__ALTMON_2,
__ALTMON_3,
__ALTMON_4,
__ALTMON_5,
__ALTMON_6,
__ALTMON_7,
__ALTMON_8,
__ALTMON_9,
__ALTMON_10,
__ALTMON_11,
__ALTMON_12,
#ifdef __USE_GNU
# define ALTMON_1 __ALTMON_1
# define ALTMON_2 __ALTMON_2
# define ALTMON_3 __ALTMON_3
# define ALTMON_4 __ALTMON_4
# define ALTMON_5 __ALTMON_5
# define ALTMON_6 __ALTMON_6
# define ALTMON_7 __ALTMON_7
# define ALTMON_8 __ALTMON_8
# define ALTMON_9 __ALTMON_9
# define ALTMON_10 __ALTMON_10
# define ALTMON_11 __ALTMON_11
# define ALTMON_12 __ALTMON_12
#endif
/* Long month names, in the grammatical form used when the month
is named by itself. */
_NL_WALTMON_1, /* January */
_NL_WALTMON_2,
_NL_WALTMON_3,
_NL_WALTMON_4,
_NL_WALTMON_5,
_NL_WALTMON_6,
_NL_WALTMON_7,
_NL_WALTMON_8,
_NL_WALTMON_9,
_NL_WALTMON_10,
_NL_WALTMON_11,
_NL_WALTMON_12,
/* Abbreviated month names, in the grammatical form used when the month
is named by itself. */
_NL_ABALTMON_1, /* Jan */
_NL_ABALTMON_2,
_NL_ABALTMON_3,
_NL_ABALTMON_4,
_NL_ABALTMON_5,
_NL_ABALTMON_6,
_NL_ABALTMON_7,
_NL_ABALTMON_8,
_NL_ABALTMON_9,
_NL_ABALTMON_10,
_NL_ABALTMON_11,
_NL_ABALTMON_12,
/* Abbreviated month names, in the grammatical form used when the month
is named by itself. */
_NL_WABALTMON_1, /* Jan */
_NL_WABALTMON_2,
_NL_WABALTMON_3,
_NL_WABALTMON_4,
_NL_WABALTMON_5,
_NL_WABALTMON_6,
_NL_WABALTMON_7,
_NL_WABALTMON_8,
_NL_WABALTMON_9,
_NL_WABALTMON_10,
_NL_WABALTMON_11,
_NL_WABALTMON_12,
_NL_NUM_LC_TIME, /* Number of indices in LC_TIME category. */
/* LC_COLLATE category: text sorting.
This information is accessed by the strcoll and strxfrm functions.
These `nl_langinfo' names are used only internally. */
_NL_COLLATE_NRULES = _NL_ITEM (__LC_COLLATE, 0),
_NL_COLLATE_RULESETS,
_NL_COLLATE_TABLEMB,
_NL_COLLATE_WEIGHTMB,
_NL_COLLATE_EXTRAMB,
_NL_COLLATE_INDIRECTMB,
_NL_COLLATE_GAP1,
_NL_COLLATE_GAP2,
_NL_COLLATE_GAP3,
_NL_COLLATE_TABLEWC,
_NL_COLLATE_WEIGHTWC,
_NL_COLLATE_EXTRAWC,
_NL_COLLATE_INDIRECTWC,
_NL_COLLATE_SYMB_HASH_SIZEMB,
_NL_COLLATE_SYMB_TABLEMB,
_NL_COLLATE_SYMB_EXTRAMB,
_NL_COLLATE_COLLSEQMB,
_NL_COLLATE_COLLSEQWC,
_NL_COLLATE_CODESET,
_NL_NUM_LC_COLLATE,
/* LC_CTYPE category: character classification.
This information is accessed by the functions in <ctype.h>.
These `nl_langinfo' names are used only internally. */
_NL_CTYPE_CLASS = _NL_ITEM (__LC_CTYPE, 0),
_NL_CTYPE_TOUPPER,
_NL_CTYPE_GAP1,
_NL_CTYPE_TOLOWER,
_NL_CTYPE_GAP2,
_NL_CTYPE_CLASS32,
_NL_CTYPE_GAP3,
_NL_CTYPE_GAP4,
_NL_CTYPE_GAP5,
_NL_CTYPE_GAP6,
_NL_CTYPE_CLASS_NAMES,
_NL_CTYPE_MAP_NAMES,
_NL_CTYPE_WIDTH,
_NL_CTYPE_MB_CUR_MAX,
_NL_CTYPE_CODESET_NAME,
CODESET = _NL_CTYPE_CODESET_NAME,
#define CODESET CODESET
_NL_CTYPE_TOUPPER32,
_NL_CTYPE_TOLOWER32,
_NL_CTYPE_CLASS_OFFSET,
_NL_CTYPE_MAP_OFFSET,
_NL_CTYPE_INDIGITS_MB_LEN,
_NL_CTYPE_INDIGITS0_MB,
_NL_CTYPE_INDIGITS1_MB,
_NL_CTYPE_INDIGITS2_MB,
_NL_CTYPE_INDIGITS3_MB,
_NL_CTYPE_INDIGITS4_MB,
_NL_CTYPE_INDIGITS5_MB,
_NL_CTYPE_INDIGITS6_MB,
_NL_CTYPE_INDIGITS7_MB,
_NL_CTYPE_INDIGITS8_MB,
_NL_CTYPE_INDIGITS9_MB,
_NL_CTYPE_INDIGITS_WC_LEN,
_NL_CTYPE_INDIGITS0_WC,
_NL_CTYPE_INDIGITS1_WC,
_NL_CTYPE_INDIGITS2_WC,
_NL_CTYPE_INDIGITS3_WC,
_NL_CTYPE_INDIGITS4_WC,
_NL_CTYPE_INDIGITS5_WC,
_NL_CTYPE_INDIGITS6_WC,
_NL_CTYPE_INDIGITS7_WC,
_NL_CTYPE_INDIGITS8_WC,
_NL_CTYPE_INDIGITS9_WC,
_NL_CTYPE_OUTDIGIT0_MB,
_NL_CTYPE_OUTDIGIT1_MB,
_NL_CTYPE_OUTDIGIT2_MB,
_NL_CTYPE_OUTDIGIT3_MB,
_NL_CTYPE_OUTDIGIT4_MB,
_NL_CTYPE_OUTDIGIT5_MB,
_NL_CTYPE_OUTDIGIT6_MB,
_NL_CTYPE_OUTDIGIT7_MB,
_NL_CTYPE_OUTDIGIT8_MB,
_NL_CTYPE_OUTDIGIT9_MB,
_NL_CTYPE_OUTDIGIT0_WC,
_NL_CTYPE_OUTDIGIT1_WC,
_NL_CTYPE_OUTDIGIT2_WC,
_NL_CTYPE_OUTDIGIT3_WC,
_NL_CTYPE_OUTDIGIT4_WC,
_NL_CTYPE_OUTDIGIT5_WC,
_NL_CTYPE_OUTDIGIT6_WC,
_NL_CTYPE_OUTDIGIT7_WC,
_NL_CTYPE_OUTDIGIT8_WC,
_NL_CTYPE_OUTDIGIT9_WC,
_NL_CTYPE_TRANSLIT_TAB_SIZE,
_NL_CTYPE_TRANSLIT_FROM_IDX,
_NL_CTYPE_TRANSLIT_FROM_TBL,
_NL_CTYPE_TRANSLIT_TO_IDX,
_NL_CTYPE_TRANSLIT_TO_TBL,
_NL_CTYPE_TRANSLIT_DEFAULT_MISSING_LEN,
_NL_CTYPE_TRANSLIT_DEFAULT_MISSING,
_NL_CTYPE_TRANSLIT_IGNORE_LEN,
_NL_CTYPE_TRANSLIT_IGNORE,
_NL_CTYPE_MAP_TO_NONASCII,
_NL_CTYPE_NONASCII_CASE,
_NL_CTYPE_EXTRA_MAP_1,
_NL_CTYPE_EXTRA_MAP_2,
_NL_CTYPE_EXTRA_MAP_3,
_NL_CTYPE_EXTRA_MAP_4,
_NL_CTYPE_EXTRA_MAP_5,
_NL_CTYPE_EXTRA_MAP_6,
_NL_CTYPE_EXTRA_MAP_7,
_NL_CTYPE_EXTRA_MAP_8,
_NL_CTYPE_EXTRA_MAP_9,
_NL_CTYPE_EXTRA_MAP_10,
_NL_CTYPE_EXTRA_MAP_11,
_NL_CTYPE_EXTRA_MAP_12,
_NL_CTYPE_EXTRA_MAP_13,
_NL_CTYPE_EXTRA_MAP_14,
_NL_NUM_LC_CTYPE,
/* LC_MONETARY category: formatting of monetary quantities.
These items each correspond to a member of `struct lconv',
defined in <locale.h>. */
__INT_CURR_SYMBOL = _NL_ITEM (__LC_MONETARY, 0),
#ifdef __USE_GNU
# define INT_CURR_SYMBOL __INT_CURR_SYMBOL
#endif
__CURRENCY_SYMBOL,
#ifdef __USE_GNU
# define CURRENCY_SYMBOL __CURRENCY_SYMBOL
#endif
__MON_DECIMAL_POINT,
#ifdef __USE_GNU
# define MON_DECIMAL_POINT __MON_DECIMAL_POINT
#endif
__MON_THOUSANDS_SEP,
#ifdef __USE_GNU
# define MON_THOUSANDS_SEP __MON_THOUSANDS_SEP
#endif
__MON_GROUPING,
#ifdef __USE_GNU
# define MON_GROUPING __MON_GROUPING
#endif
__POSITIVE_SIGN,
#ifdef __USE_GNU
# define POSITIVE_SIGN __POSITIVE_SIGN
#endif
__NEGATIVE_SIGN,
#ifdef __USE_GNU
# define NEGATIVE_SIGN __NEGATIVE_SIGN
#endif
__INT_FRAC_DIGITS,
#ifdef __USE_GNU
# define INT_FRAC_DIGITS __INT_FRAC_DIGITS
#endif
__FRAC_DIGITS,
#ifdef __USE_GNU
# define FRAC_DIGITS __FRAC_DIGITS
#endif
__P_CS_PRECEDES,
#ifdef __USE_GNU
# define P_CS_PRECEDES __P_CS_PRECEDES
#endif
__P_SEP_BY_SPACE,
#ifdef __USE_GNU
# define P_SEP_BY_SPACE __P_SEP_BY_SPACE
#endif
__N_CS_PRECEDES,
#ifdef __USE_GNU
# define N_CS_PRECEDES __N_CS_PRECEDES
#endif
__N_SEP_BY_SPACE,
#ifdef __USE_GNU
# define N_SEP_BY_SPACE __N_SEP_BY_SPACE
#endif
__P_SIGN_POSN,
#ifdef __USE_GNU
# define P_SIGN_POSN __P_SIGN_POSN
#endif
__N_SIGN_POSN,
#ifdef __USE_GNU
# define N_SIGN_POSN __N_SIGN_POSN
#endif
_NL_MONETARY_CRNCYSTR,
#define CRNCYSTR _NL_MONETARY_CRNCYSTR
__INT_P_CS_PRECEDES,
#ifdef __USE_GNU
# define INT_P_CS_PRECEDES __INT_P_CS_PRECEDES
#endif
__INT_P_SEP_BY_SPACE,
#ifdef __USE_GNU
# define INT_P_SEP_BY_SPACE __INT_P_SEP_BY_SPACE
#endif
__INT_N_CS_PRECEDES,
#ifdef __USE_GNU
# define INT_N_CS_PRECEDES __INT_N_CS_PRECEDES
#endif
__INT_N_SEP_BY_SPACE,
#ifdef __USE_GNU
# define INT_N_SEP_BY_SPACE __INT_N_SEP_BY_SPACE
#endif
__INT_P_SIGN_POSN,
#ifdef __USE_GNU
# define INT_P_SIGN_POSN __INT_P_SIGN_POSN
#endif
__INT_N_SIGN_POSN,
#ifdef __USE_GNU
# define INT_N_SIGN_POSN __INT_N_SIGN_POSN
#endif
_NL_MONETARY_DUO_INT_CURR_SYMBOL,
_NL_MONETARY_DUO_CURRENCY_SYMBOL,
_NL_MONETARY_DUO_INT_FRAC_DIGITS,
_NL_MONETARY_DUO_FRAC_DIGITS,
_NL_MONETARY_DUO_P_CS_PRECEDES,
_NL_MONETARY_DUO_P_SEP_BY_SPACE,
_NL_MONETARY_DUO_N_CS_PRECEDES,
_NL_MONETARY_DUO_N_SEP_BY_SPACE,
_NL_MONETARY_DUO_INT_P_CS_PRECEDES,
_NL_MONETARY_DUO_INT_P_SEP_BY_SPACE,
_NL_MONETARY_DUO_INT_N_CS_PRECEDES,
_NL_MONETARY_DUO_INT_N_SEP_BY_SPACE,
_NL_MONETARY_DUO_P_SIGN_POSN,
_NL_MONETARY_DUO_N_SIGN_POSN,
_NL_MONETARY_DUO_INT_P_SIGN_POSN,
_NL_MONETARY_DUO_INT_N_SIGN_POSN,
_NL_MONETARY_UNO_VALID_FROM,
_NL_MONETARY_UNO_VALID_TO,
_NL_MONETARY_DUO_VALID_FROM,
_NL_MONETARY_DUO_VALID_TO,
_NL_MONETARY_CONVERSION_RATE,
_NL_MONETARY_DECIMAL_POINT_WC,
_NL_MONETARY_THOUSANDS_SEP_WC,
_NL_MONETARY_CODESET,
_NL_NUM_LC_MONETARY,
/* LC_NUMERIC category: formatting of numbers.
These also correspond to members of `struct lconv'; see <locale.h>. */
__DECIMAL_POINT = _NL_ITEM (__LC_NUMERIC, 0),
#ifdef __USE_GNU
# define DECIMAL_POINT __DECIMAL_POINT
#endif
RADIXCHAR = __DECIMAL_POINT,
#define RADIXCHAR RADIXCHAR
__THOUSANDS_SEP,
#ifdef __USE_GNU
# define THOUSANDS_SEP __THOUSANDS_SEP
#endif
THOUSEP = __THOUSANDS_SEP,
#define THOUSEP THOUSEP
__GROUPING,
#ifdef __USE_GNU
# define GROUPING __GROUPING
#endif
_NL_NUMERIC_DECIMAL_POINT_WC,
_NL_NUMERIC_THOUSANDS_SEP_WC,
_NL_NUMERIC_CODESET,
_NL_NUM_LC_NUMERIC,
__YESEXPR = _NL_ITEM (__LC_MESSAGES, 0), /* Regex matching ``yes'' input. */
#define YESEXPR __YESEXPR
__NOEXPR, /* Regex matching ``no'' input. */
#define NOEXPR __NOEXPR
__YESSTR, /* Output string for ``yes''. */
#if defined __USE_GNU || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
# define YESSTR __YESSTR
#endif
__NOSTR, /* Output string for ``no''. */
#if defined __USE_GNU || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
# define NOSTR __NOSTR
#endif
_NL_MESSAGES_CODESET,
_NL_NUM_LC_MESSAGES,
_NL_PAPER_HEIGHT = _NL_ITEM (__LC_PAPER, 0),
_NL_PAPER_WIDTH,
_NL_PAPER_CODESET,
_NL_NUM_LC_PAPER,
_NL_NAME_NAME_FMT = _NL_ITEM (__LC_NAME, 0),
_NL_NAME_NAME_GEN,
_NL_NAME_NAME_MR,
_NL_NAME_NAME_MRS,
_NL_NAME_NAME_MISS,
_NL_NAME_NAME_MS,
_NL_NAME_CODESET,
_NL_NUM_LC_NAME,
_NL_ADDRESS_POSTAL_FMT = _NL_ITEM (__LC_ADDRESS, 0),
_NL_ADDRESS_COUNTRY_NAME,
_NL_ADDRESS_COUNTRY_POST,
_NL_ADDRESS_COUNTRY_AB2,
_NL_ADDRESS_COUNTRY_AB3,
_NL_ADDRESS_COUNTRY_CAR,
_NL_ADDRESS_COUNTRY_NUM,
_NL_ADDRESS_COUNTRY_ISBN,
_NL_ADDRESS_LANG_NAME,
_NL_ADDRESS_LANG_AB,
_NL_ADDRESS_LANG_TERM,
_NL_ADDRESS_LANG_LIB,
_NL_ADDRESS_CODESET,
_NL_NUM_LC_ADDRESS,
_NL_TELEPHONE_TEL_INT_FMT = _NL_ITEM (__LC_TELEPHONE, 0),
_NL_TELEPHONE_TEL_DOM_FMT,
_NL_TELEPHONE_INT_SELECT,
_NL_TELEPHONE_INT_PREFIX,
_NL_TELEPHONE_CODESET,
_NL_NUM_LC_TELEPHONE,
_NL_MEASUREMENT_MEASUREMENT = _NL_ITEM (__LC_MEASUREMENT, 0),
_NL_MEASUREMENT_CODESET,
_NL_NUM_LC_MEASUREMENT,
_NL_IDENTIFICATION_TITLE = _NL_ITEM (__LC_IDENTIFICATION, 0),
_NL_IDENTIFICATION_SOURCE,
_NL_IDENTIFICATION_ADDRESS,
_NL_IDENTIFICATION_CONTACT,
_NL_IDENTIFICATION_EMAIL,
_NL_IDENTIFICATION_TEL,
_NL_IDENTIFICATION_FAX,
_NL_IDENTIFICATION_LANGUAGE,
_NL_IDENTIFICATION_TERRITORY,
_NL_IDENTIFICATION_AUDIENCE,
_NL_IDENTIFICATION_APPLICATION,
_NL_IDENTIFICATION_ABBREVIATION,
_NL_IDENTIFICATION_REVISION,
_NL_IDENTIFICATION_DATE,
_NL_IDENTIFICATION_CATEGORY,
_NL_IDENTIFICATION_CODESET,
_NL_NUM_LC_IDENTIFICATION,
/* This marks the highest value used. */
_NL_NUM
};
/* This macro produces an item you can pass to `nl_langinfo' or
`nl_langinfo_l' to get the name of the locale in use for CATEGORY. */
#define _NL_LOCALE_NAME(category) _NL_ITEM ((category), \
_NL_ITEM_INDEX (-1))
#ifdef __USE_GNU
# define NL_LOCALE_NAME(category) _NL_LOCALE_NAME (category)
#endif
/* Return the current locale's value for ITEM.
If ITEM is invalid, an empty string is returned.
The string returned will not change until `setlocale' is called;
it is usually in read-only memory and cannot be modified. */
extern char *nl_langinfo (nl_item __item) __THROW;
#ifdef __USE_XOPEN2K8
/* POSIX.1-2008 extended locale interface (see locale.h). */
# include <bits/types/locale_t.h>
/* Just like nl_langinfo but get the information from the locale object L. */
extern char *nl_langinfo_l (nl_item __item, locale_t __l);
#endif
__END_DECLS
#endif /* langinfo.h */
syslog.h 0000644 00000000030 15201526705 0006231 0 ustar 00 #include <sys/syslog.h>
criu/criu.h 0000644 00000033113 15201526705 0006625 0 ustar 00 /*
* (C) Copyright 2013 Parallels, Inc. (www.parallels.com).
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser General Public License
* (LGPL) version 2.1 which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-2.1.html
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, you can find it here:
* www.gnu.org/licenses/lgpl.html
*/
#ifndef __CRIU_LIB_H__
#define __CRIU_LIB_H__
#include <stdbool.h>
#include "version.h"
#include "rpc.pb-c.h"
#ifdef __GNUG__
extern "C" {
#endif
#define CRIU_LOG_UNSET (-1)
#define CRIU_LOG_MSG (0) /* Print message regardless of log level */
#define CRIU_LOG_ERROR (1) /* Errors only */
#define CRIU_LOG_WARN (2) /* Warnings */
#define CRIU_LOG_INFO (3) /* Informative */
#define CRIU_LOG_DEBUG (4) /* Debug only */
enum criu_service_comm { CRIU_COMM_SK, CRIU_COMM_FD, CRIU_COMM_BIN };
enum criu_cg_mode {
CRIU_CG_MODE_IGNORE,
CRIU_CG_MODE_NONE,
CRIU_CG_MODE_PROPS,
CRIU_CG_MODE_SOFT,
CRIU_CG_MODE_FULL,
CRIU_CG_MODE_STRICT,
CRIU_CG_MODE_DEFAULT,
};
enum criu_network_lock_method {
CRIU_NETWORK_LOCK_IPTABLES = 1,
CRIU_NETWORK_LOCK_NFTABLES = 2,
CRIU_NETWORK_LOCK_SKIP = 3,
};
enum criu_pre_dump_mode { CRIU_PRE_DUMP_SPLICE = 1, CRIU_PRE_DUMP_READ = 2 };
int criu_set_service_address(const char *path);
void criu_set_service_fd(int fd);
int criu_set_service_binary(const char *path);
void criu_set_service_comm(enum criu_service_comm comm);
void criu_set_root_only(bool root_only);
/*
* Set opts to defaults. _Must_ be called first before using any functions from
* the list down below. 0 on success, -1 on fail.
*/
int criu_init_opts(void);
void criu_free_opts(void);
void criu_set_pid(int pid);
void criu_set_images_dir_fd(int fd); /* must be set for dump/restore */
int criu_set_parent_images(const char *path);
void criu_set_work_dir_fd(int fd);
void criu_set_leave_running(bool leave_running);
void criu_set_ext_unix_sk(bool ext_unix_sk);
int criu_add_unix_sk(unsigned int inode);
void criu_set_tcp_established(bool tcp_established);
void criu_set_tcp_skip_in_flight(bool tcp_skip_in_flight);
void criu_set_tcp_close(bool tcp_close);
void criu_set_weak_sysctls(bool val);
void criu_set_evasive_devices(bool evasive_devices);
void criu_set_shell_job(bool shell_job);
void criu_set_skip_file_rwx_check(bool skip_file_rwx_check);
void criu_set_unprivileged(bool unprivileged);
void criu_set_orphan_pts_master(bool orphan_pts_master);
void criu_set_file_locks(bool file_locks);
void criu_set_track_mem(bool track_mem);
void criu_set_auto_dedup(bool auto_dedup);
void criu_set_force_irmap(bool force_irmap);
void criu_set_link_remap(bool link_remap);
void criu_set_log_level(int log_level);
int criu_set_log_file(const char *log_file);
void criu_set_cpu_cap(unsigned int cap);
int criu_set_root(const char *root);
void criu_set_manage_cgroups(bool manage);
void criu_set_manage_cgroups_mode(enum criu_cg_mode mode);
int criu_set_freeze_cgroup(const char *name);
int criu_set_lsm_profile(const char *name);
int criu_set_lsm_mount_context(const char *name);
void criu_set_timeout(unsigned int timeout);
void criu_set_auto_ext_mnt(bool val);
void criu_set_ext_sharing(bool val);
void criu_set_ext_masters(bool val);
int criu_set_exec_cmd(int argc, char *argv[]);
int criu_add_ext_mount(const char *key, const char *val);
int criu_add_veth_pair(const char *in, const char *out);
int criu_add_cg_root(const char *ctrl, const char *path);
int criu_add_enable_fs(const char *fs);
int criu_add_skip_mnt(const char *mnt);
void criu_set_ghost_limit(unsigned int limit);
int criu_add_irmap_path(const char *path);
int criu_add_inherit_fd(int fd, const char *key);
int criu_add_external(const char *key);
int criu_set_page_server_address_port(const char *address, int port);
int criu_set_pre_dump_mode(enum criu_pre_dump_mode mode);
void criu_set_pidfd_store_sk(int sk);
int criu_set_network_lock(enum criu_network_lock_method method);
int criu_join_ns_add(const char *ns, const char *ns_file, const char *extra_opt);
void criu_set_mntns_compat_mode(bool val);
int criu_set_config_file(const char *path);
/*
* The criu_notify_arg_t na argument is an opaque
* value that callbacks (cb-s) should pass into
* criu_notify_xxx() calls to fetch arbitrary values
* from notification. If the value is not available
* some non-existing one is reported.
*/
typedef CriuNotify *criu_notify_arg_t;
void criu_set_notify_cb(int (*cb)(char *action, criu_notify_arg_t na));
/* Get pid of root task. 0 if not available */
int criu_notify_pid(criu_notify_arg_t na);
/*
* If CRIU sends and FD in the case of 'orphan-pts-master',
* this FD can be retrieved with criu_get_orphan_pts_master_fd().
*
* If no FD has been received this will return -1.
*
* To make sure the FD returned is valid this function has to be
* called after the callback with the 'action' 'orphan-pts-master'.
*/
int criu_get_orphan_pts_master_fd(void);
/* Here is a table of return values and errno's of functions
* from the list down below.
*
* Return value errno Description
* ----------------------------------------------------------------------------
* 0 undefined Success.
*
* >0 undefined Success(criu_restore() only).
*
* -BADE rpc err (0 for now) RPC has returned fail.
*
* -ECONNREFUSED errno Unable to connect to CRIU.
*
* -ECOMM errno Unable to send/recv msg to/from CRIU.
*
* -EINVAL undefined CRIU doesn't support this type of request.
* You should probably update CRIU.
*
* -EBADMSG undefined Unexpected response from CRIU.
* You should probably update CRIU.
*/
int criu_check(void);
int criu_dump(void);
int criu_pre_dump(void);
int criu_restore(void);
int criu_restore_child(void);
/*
* Perform dumping but with preliminary iterations. Each
* time an iteration ends the ->more callback is called.
* The callback's return value is
* - positive -- one more iteration starts
* - zero -- final dump is performed and call exits
* - negative -- dump is aborted, the value is returned
* back from criu_dump_iters
*
* The @pi argument is an opaque value that caller may
* use to request pre-dump statistics (not yet implemented).
*/
typedef void *criu_predump_info;
int criu_dump_iters(int (*more)(criu_predump_info pi));
/*
* Get the version of the actual binary used for RPC.
*
* As this library is just forwarding all tasks to an
* independent (of this library) CRIU binary, the actual
* version of the CRIU binary can be different then the
* hardcoded values in the library (version.h).
* To be able to easily check the version of the CRIU binary
* the function criu_get_version() returns the version
* in the following format:
*
* (major * 10000) + (minor * 100) + sublevel
*
* If the CRIU binary has been built from a git checkout
* minor will increased by one.
*/
int criu_get_version(void);
/*
* Check if the version of the CRIU binary is at least
* 'minimum'. Version has to be in the same format as
* described for criu_get_version().
*
* Returns 1 if CRIU is at least 'minimum'.
* Returns 0 if CRIU is too old.
* Returns < 0 if there was an error.
*/
int criu_check_version(int minimum);
/*
* Same as the list above, but lets you have your very own options
* structure and lets you set individual options in it.
*/
typedef struct criu_opts criu_opts;
int criu_local_init_opts(criu_opts **opts);
void criu_local_free_opts(criu_opts *opts);
void criu_local_set_root_only(criu_opts *opts, bool root_only);
int criu_local_set_service_address(criu_opts *opts, const char *path);
void criu_local_set_service_fd(criu_opts *opts, int fd);
void criu_local_set_service_fd(criu_opts *opts, int fd);
void criu_local_set_pid(criu_opts *opts, int pid);
void criu_local_set_images_dir_fd(criu_opts *opts, int fd); /* must be set for dump/restore */
int criu_local_set_parent_images(criu_opts *opts, const char *path);
int criu_local_set_service_binary(criu_opts *opts, const char *path);
void criu_local_set_work_dir_fd(criu_opts *opts, int fd);
void criu_local_set_leave_running(criu_opts *opts, bool leave_running);
void criu_local_set_ext_unix_sk(criu_opts *opts, bool ext_unix_sk);
int criu_local_add_unix_sk(criu_opts *opts, unsigned int inode);
void criu_local_set_tcp_established(criu_opts *opts, bool tcp_established);
void criu_local_set_tcp_skip_in_flight(criu_opts *opts, bool tcp_skip_in_flight);
void criu_local_set_tcp_close(criu_opts *opts, bool tcp_close);
void criu_local_set_weak_sysctls(criu_opts *opts, bool val);
void criu_local_set_evasive_devices(criu_opts *opts, bool evasive_devices);
void criu_local_set_shell_job(criu_opts *opts, bool shell_job);
void criu_local_set_skip_file_rwx_check(criu_opts *opts, bool skip_file_rwx_check);
void criu_local_set_orphan_pts_master(criu_opts *opts, bool orphan_pts_master);
void criu_local_set_file_locks(criu_opts *opts, bool file_locks);
void criu_local_set_track_mem(criu_opts *opts, bool track_mem);
void criu_local_set_auto_dedup(criu_opts *opts, bool auto_dedup);
void criu_local_set_force_irmap(criu_opts *opts, bool force_irmap);
void criu_local_set_link_remap(criu_opts *opts, bool link_remap);
void criu_local_set_log_level(criu_opts *opts, int log_level);
int criu_local_set_log_file(criu_opts *opts, const char *log_file);
void criu_local_set_cpu_cap(criu_opts *opts, unsigned int cap);
int criu_local_set_root(criu_opts *opts, const char *root);
void criu_local_set_manage_cgroups(criu_opts *opts, bool manage);
void criu_local_set_manage_cgroups_mode(criu_opts *opts, enum criu_cg_mode mode);
int criu_local_set_freeze_cgroup(criu_opts *opts, const char *name);
int criu_local_set_lsm_profile(criu_opts *opts, const char *name);
int criu_local_set_lsm_mount_context(criu_opts *opts, const char *name);
void criu_local_set_timeout(criu_opts *opts, unsigned int timeout);
void criu_local_set_auto_ext_mnt(criu_opts *opts, bool val);
void criu_local_set_ext_sharing(criu_opts *opts, bool val);
void criu_local_set_ext_masters(criu_opts *opts, bool val);
int criu_local_set_exec_cmd(criu_opts *opts, int argc, char *argv[]);
int criu_local_add_ext_mount(criu_opts *opts, const char *key, const char *val);
int criu_local_add_veth_pair(criu_opts *opts, const char *in, const char *out);
int criu_local_add_cg_root(criu_opts *opts, const char *ctrl, const char *path);
int criu_local_add_enable_fs(criu_opts *opts, const char *fs);
int criu_local_add_skip_mnt(criu_opts *opts, const char *mnt);
void criu_local_set_ghost_limit(criu_opts *opts, unsigned int limit);
int criu_local_add_irmap_path(criu_opts *opts, const char *path);
int criu_local_add_cg_props(criu_opts *opts, const char *stream);
int criu_local_add_cg_props_file(criu_opts *opts, const char *path);
int criu_local_add_cg_dump_controller(criu_opts *opts, const char *name);
int criu_local_add_cg_yard(criu_opts *opts, const char *path);
int criu_local_add_inherit_fd(criu_opts *opts, int fd, const char *key);
int criu_local_add_external(criu_opts *opts, const char *key);
int criu_local_set_page_server_address_port(criu_opts *opts, const char *address, int port);
int criu_local_set_pre_dump_mode(criu_opts *opts, enum criu_pre_dump_mode mode);
void criu_local_set_pidfd_store_sk(criu_opts *opts, int sk);
int criu_local_set_network_lock(criu_opts *opts, enum criu_network_lock_method method);
int criu_local_join_ns_add(criu_opts *opts, const char *ns, const char *ns_file, const char *extra_opt);
void criu_local_set_mntns_compat_mode(criu_opts *opts, bool val);
int criu_local_set_config_file(criu_opts *opts, const char *path);
void criu_local_set_notify_cb(criu_opts *opts, int (*cb)(char *action, criu_notify_arg_t na));
int criu_local_check(criu_opts *opts);
int criu_local_dump(criu_opts *opts);
int criu_local_pre_dump(criu_opts *opts);
int criu_local_restore(criu_opts *opts);
int criu_local_restore_child(criu_opts *opts);
int criu_local_dump_iters(criu_opts *opts, int (*more)(criu_predump_info pi));
int criu_local_get_version(criu_opts *opts);
int criu_local_check_version(criu_opts *opts, int minimum);
/*
* Feature checking allows the user to check if CRIU supports
* certain features. There are CRIU features which do not depend
* on the version of CRIU but on kernel features or architecture.
*
* One example is memory tracking. Memory tracking can be disabled
* in the kernel or there are architectures which do not support
* it (aarch64 for example). By using the feature check a libcriu
* user can easily query CRIU if a certain feature is available.
*
* The features which should be checked can be marked in the
* structure 'struct criu_feature_check'. Each structure member
* that is set to true will result in CRIU checking for the
* availability of that feature in the current combination of
* CRIU/kernel/architecture.
*
* Available features will be set to true when the function
* returns successfully. Missing features will be set to false.
*/
struct criu_feature_check {
bool mem_track;
bool lazy_pages;
bool pidfd_store;
};
int criu_feature_check(struct criu_feature_check *features, size_t size);
int criu_local_feature_check(criu_opts *opts, struct criu_feature_check *features, size_t size);
void criu_local_set_empty_ns(criu_opts *opts, int namespaces);
void criu_set_empty_ns(int namespaces);
#ifdef __GNUG__
}
#endif
#endif /* __CRIU_LIB_H__ */
criu/criu-plugin.h 0000644 00000012733 15201526705 0010126 0 ustar 00 /*
* This file defines types and macros for CRIU plugins.
* Copyright (C) 2013-2014 Parallels, Inc
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __CRIU_PLUGIN_H__
#define __CRIU_PLUGIN_H__
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <sys/stat.h>
#define CRIU_PLUGIN_GEN_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c))
#define CRIU_PLUGIN_VERSION_MAJOR 0
#define CRIU_PLUGIN_VERSION_MINOR 2
#define CRIU_PLUGIN_VERSION_SUBLEVEL 0
#define CRIU_PLUGIN_VERSION_OLD CRIU_PLUGIN_GEN_VERSION(0, 1, 0)
#define CRIU_PLUGIN_VERSION \
CRIU_PLUGIN_GEN_VERSION(CRIU_PLUGIN_VERSION_MAJOR, CRIU_PLUGIN_VERSION_MINOR, CRIU_PLUGIN_VERSION_SUBLEVEL)
/*
* Plugin hook points and their arguments in hooks.
*/
enum {
CR_PLUGIN_HOOK__DUMP_UNIX_SK = 0,
CR_PLUGIN_HOOK__RESTORE_UNIX_SK = 1,
CR_PLUGIN_HOOK__DUMP_EXT_FILE = 2,
CR_PLUGIN_HOOK__RESTORE_EXT_FILE = 3,
CR_PLUGIN_HOOK__DUMP_EXT_MOUNT = 4,
CR_PLUGIN_HOOK__RESTORE_EXT_MOUNT = 5,
CR_PLUGIN_HOOK__DUMP_EXT_LINK = 6,
CR_PLUGIN_HOOK__HANDLE_DEVICE_VMA = 7,
CR_PLUGIN_HOOK__UPDATE_VMA_MAP = 8,
CR_PLUGIN_HOOK__RESUME_DEVICES_LATE = 9,
CR_PLUGIN_HOOK__PAUSE_DEVICES = 10,
CR_PLUGIN_HOOK__CHECKPOINT_DEVICES = 11,
CR_PLUGIN_HOOK__POST_FORKING = 12,
CR_PLUGIN_HOOK__MAX
};
#define DECLARE_PLUGIN_HOOK_ARGS(__hook, ...) typedef int(__hook##_t)(__VA_ARGS__)
DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__DUMP_UNIX_SK, int fd, int id);
DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__RESTORE_UNIX_SK, int id);
DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__DUMP_EXT_FILE, int fd, int id);
DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__RESTORE_EXT_FILE, int id);
DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__DUMP_EXT_MOUNT, char *mountpoint, int id);
DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__RESTORE_EXT_MOUNT, int id, char *mountpoint, char *old_root, int *is_file);
DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__DUMP_EXT_LINK, int index, int type, char *kind);
DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__HANDLE_DEVICE_VMA, int fd, const struct stat *stat);
DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__UPDATE_VMA_MAP, const char *path, const uint64_t addr,
const uint64_t old_pgoff, uint64_t *new_pgoff, int *plugin_fd);
DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__RESUME_DEVICES_LATE, int pid);
DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__PAUSE_DEVICES, int pid);
DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__CHECKPOINT_DEVICES, int pid);
DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__POST_FORKING, void);
enum {
CR_PLUGIN_STAGE__DUMP,
CR_PLUGIN_STAGE__PRE_DUMP,
CR_PLUGIN_STAGE__RESTORE,
CR_PLUGIN_STAGE_MAX
};
/*
* Plugin descriptor.
*/
typedef struct {
const char *name;
int (*init)(int stage);
void (*exit)(int stage, int ret);
unsigned int version;
unsigned int max_hooks;
void *hooks[CR_PLUGIN_HOOK__MAX];
} cr_plugin_desc_t;
extern cr_plugin_desc_t CR_PLUGIN_DESC;
#define CR_PLUGIN_REGISTER(___name, ___init, ___exit) \
cr_plugin_desc_t CR_PLUGIN_DESC = { \
.name = ___name, \
.init = ___init, \
.exit = ___exit, \
.version = CRIU_PLUGIN_VERSION, \
.max_hooks = CR_PLUGIN_HOOK__MAX, \
};
static inline int cr_plugin_dummy_init(int stage)
{
return 0;
}
static inline void cr_plugin_dummy_exit(int stage, int ret)
{
}
#define CR_PLUGIN_REGISTER_DUMMY(___name) \
cr_plugin_desc_t CR_PLUGIN_DESC = { \
.name = ___name, \
.init = cr_plugin_dummy_init, \
.exit = cr_plugin_dummy_exit, \
.version = CRIU_PLUGIN_VERSION, \
.max_hooks = CR_PLUGIN_HOOK__MAX, \
};
#define CR_PLUGIN_REGISTER_HOOK(__hook, __func) \
static void __attribute__((constructor)) cr_plugin_register_hook_##__func(void) \
{ \
CR_PLUGIN_DESC.hooks[__hook] = (void *)__func; \
}
/* Public API */
extern int criu_get_image_dir(void);
/*
* Deprecated, will be removed in next version.
*/
typedef int(cr_plugin_init_t)(void);
typedef void(cr_plugin_fini_t)(void);
typedef int(cr_plugin_dump_unix_sk_t)(int fd, int id);
typedef int(cr_plugin_restore_unix_sk_t)(int id);
typedef int(cr_plugin_dump_file_t)(int fd, int id);
typedef int(cr_plugin_restore_file_t)(int id);
typedef int(cr_plugin_dump_ext_mount_t)(char *mountpoint, int id);
typedef int(cr_plugin_restore_ext_mount_t)(int id, char *mountpoint, char *old_root, int *is_file);
typedef int(cr_plugin_dump_ext_link_t)(int index, int type, char *kind);
typedef int(cr_plugin_handle_device_vma_t)(int fd, const struct stat *stat);
typedef int(cr_plugin_update_vma_map_t)(const char *path, const uint64_t addr, const uint64_t old_pgoff,
uint64_t *new_pgoff, int *plugin_fd);
typedef int(cr_plugin_resume_devices_late_t)(int pid);
typedef int(cr_plugin_post_forking_t)(void);
#endif /* __CRIU_PLUGIN_H__ */
criu/rpc.proto 0000644 00000014255 15201526705 0007371 0 ustar 00 // SPDX-License-Identifier: MIT
syntax = "proto2";
message criu_page_server_info {
optional string address = 1;
optional int32 port = 2;
optional int32 pid = 3;
optional int32 fd = 4;
}
message criu_veth_pair {
required string if_in = 1;
required string if_out = 2;
};
message ext_mount_map {
required string key = 1;
required string val = 2;
};
message join_namespace {
required string ns = 1;
required string ns_file = 2;
optional string extra_opt = 3;
}
message inherit_fd {
required string key = 1;
required int32 fd = 2;
};
message cgroup_root {
optional string ctrl = 1;
required string path = 2;
};
message unix_sk {
required uint32 inode = 1;
};
enum criu_cg_mode {
IGNORE = 0;
CG_NONE = 1;
PROPS = 2;
SOFT = 3;
FULL = 4;
STRICT = 5;
DEFAULT = 6;
};
enum criu_network_lock_method {
IPTABLES = 1;
NFTABLES = 2;
SKIP = 3;
};
enum criu_pre_dump_mode {
SPLICE = 1;
VM_READ = 2;
};
message criu_opts {
required int32 images_dir_fd = 1 [default = -1];
optional string images_dir = 68; /* used only if images_dir_fd == -1 */
optional int32 pid = 2; /* if not set on dump, will dump requesting process */
optional bool leave_running = 3;
optional bool ext_unix_sk = 4;
optional bool tcp_established = 5;
optional bool evasive_devices = 6;
optional bool shell_job = 7;
optional bool file_locks = 8;
optional int32 log_level = 9 [default = 2];
optional string log_file = 10; /* No subdirs are allowed. Consider using work-dir */
optional criu_page_server_info ps = 11;
optional bool notify_scripts = 12;
optional string root = 13;
optional string parent_img = 14;
optional bool track_mem = 15;
optional bool auto_dedup = 16;
optional int32 work_dir_fd = 17;
optional bool link_remap = 18;
repeated criu_veth_pair veths = 19; /* DEPRECATED, use external instead */
optional uint32 cpu_cap = 20 [default = 0xffffffff];
optional bool force_irmap = 21;
repeated string exec_cmd = 22;
repeated ext_mount_map ext_mnt = 23; /* DEPRECATED, use external instead */
optional bool manage_cgroups = 24; /* backward compatibility */
repeated cgroup_root cg_root = 25;
optional bool rst_sibling = 26; /* swrk only */
repeated inherit_fd inherit_fd = 27; /* swrk only */
optional bool auto_ext_mnt = 28;
optional bool ext_sharing = 29;
optional bool ext_masters = 30;
repeated string skip_mnt = 31;
repeated string enable_fs = 32;
repeated unix_sk unix_sk_ino = 33; /* DEPRECATED, use external instead */
optional criu_cg_mode manage_cgroups_mode = 34;
optional uint32 ghost_limit = 35 [default = 0x100000];
repeated string irmap_scan_paths = 36;
repeated string external = 37;
optional uint32 empty_ns = 38;
repeated join_namespace join_ns = 39;
optional string cgroup_props = 41;
optional string cgroup_props_file = 42;
repeated string cgroup_dump_controller = 43;
optional string freeze_cgroup = 44;
optional uint32 timeout = 45;
optional bool tcp_skip_in_flight = 46;
optional bool weak_sysctls = 47;
optional bool lazy_pages = 48;
optional int32 status_fd = 49;
optional bool orphan_pts_master = 50;
optional string config_file = 51;
optional bool tcp_close = 52;
optional string lsm_profile = 53;
optional string tls_cacert = 54;
optional string tls_cacrl = 55;
optional string tls_cert = 56;
optional string tls_key = 57;
optional bool tls = 58;
optional bool tls_no_cn_verify = 59;
optional string cgroup_yard = 60;
optional criu_pre_dump_mode pre_dump_mode = 61 [default = SPLICE];
optional int32 pidfd_store_sk = 62;
optional string lsm_mount_context = 63;
optional criu_network_lock_method network_lock = 64 [default = IPTABLES];
optional bool mntns_compat_mode = 65;
optional bool skip_file_rwx_check = 66;
optional bool unprivileged = 67;
optional bool leave_stopped = 69;
optional bool display_stats = 70;
optional bool log_to_stderr = 71;
/* CloudLinux LVE: match CLI --root-only (see cr_options.h / config.c) */
optional bool root_only = 72;
/* optional bool check_mounts = 128; */
}
message criu_dump_resp {
optional bool restored = 1;
}
message criu_restore_resp {
required int32 pid = 1;
}
message criu_notify {
optional string script = 1;
optional int32 pid = 2;
}
enum criu_req_type {
EMPTY = 0;
DUMP = 1;
RESTORE = 2;
CHECK = 3;
PRE_DUMP = 4;
PAGE_SERVER = 5;
NOTIFY = 6;
CPUINFO_DUMP = 7;
CPUINFO_CHECK = 8;
FEATURE_CHECK = 9;
VERSION = 10;
WAIT_PID = 11;
PAGE_SERVER_CHLD = 12;
SINGLE_PRE_DUMP = 13;
}
/*
* List of features which can queried via
* CRIU_REQ_TYPE__FEATURE_CHECK
*/
message criu_features {
optional bool mem_track = 1;
optional bool lazy_pages = 2;
optional bool pidfd_store = 3;
}
/*
* Request -- each type corresponds to must-be-there
* request arguments of respective type
*/
message criu_req {
required criu_req_type type = 1;
optional criu_opts opts = 2;
optional bool notify_success = 3;
/*
* When set service won't close the connection but
* will wait for more req-s to appear. Works not
* for all request types.
*/
optional bool keep_open = 4;
/*
* 'features' can be used to query which features
* are supported by the installed criu/kernel
* via RPC.
*/
optional criu_features features = 5;
/* 'pid' is used for WAIT_PID */
optional uint32 pid = 6;
}
/*
* Response -- it states whether the request was served
* and additional request-specific information
*/
message criu_resp {
required criu_req_type type = 1;
required bool success = 2;
optional criu_dump_resp dump = 3;
optional criu_restore_resp restore = 4;
optional criu_notify notify = 5;
optional criu_page_server_info ps = 6;
optional int32 cr_errno = 7;
optional criu_features features = 8;
optional string cr_errmsg = 9;
optional criu_version version = 10;
optional int32 status = 11;
}
/* Answer for criu_req_type.VERSION requests */
message criu_version {
required int32 major_number = 1;
required int32 minor_number = 2;
optional string gitid = 3;
optional int32 sublevel = 4;
optional int32 extra = 5;
optional string name = 6;
}
criu/criu-log.h 0000644 00000003003 15201526705 0007377 0 ustar 00 /*
This file defines types and macros for CRIU plugins.
Copyright (C) 2013 Parallels, Inc
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __CRIU_LOG_H__
#define __CRIU_LOG_H__
#include "log.h"
#include <sys/types.h>
extern int log_init(const char *output);
extern void log_fini(void);
extern int log_init_by_pid(pid_t pid);
extern int log_keep_err(void);
extern char *log_first_err(void);
extern void log_set_fd(int fd);
extern int log_get_fd(void);
extern void log_set_loglevel(unsigned int loglevel);
extern unsigned int log_get_loglevel(void);
struct timeval;
extern void log_get_logstart(struct timeval *);
extern int write_pidfile(int pid);
#define DEFAULT_LOG_FILENAME "criu.log"
static inline int pr_quelled(unsigned int loglevel)
{
return log_get_loglevel() < loglevel && loglevel != LOG_MSG;
}
#endif /* __CR_LOG_LEVELS_H__ */
criu/version.h 0000644 00000000337 15201526705 0007352 0 ustar 00 /* Autogenerated, do not edit */
#ifndef __CR_VERSION_H__
#define __CR_VERSION_H__
#define CRIU_VERSION "4.2"
#define CRIU_VERSION_MAJOR 4
#define CRIU_VERSION_MINOR 2
#define CRIU_GITID "0"
#endif /* __CR_VERSION_H__ */
jmorecfg.h 0000644 00000035311 15201526705 0006517 0 ustar 00 /*
* jmorecfg.h
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 1997-2009 by Guido Vollbeding.
* libjpeg-turbo Modifications:
* Copyright (C) 2009, 2011, 2014-2015, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
* This file contains additional configuration options that customize the
* JPEG software for special applications or support machine-dependent
* optimizations. Most users will not need to touch this file.
*/
/*
* Maximum number of components (color channels) allowed in JPEG image.
* To meet the letter of the JPEG spec, set this to 255. However, darn
* few applications need more than 4 channels (maybe 5 for CMYK + alpha
* mask). We recommend 10 as a reasonable compromise; use 4 if you are
* really short on memory. (Each allowed component costs a hundred or so
* bytes of storage, whether actually used in an image or not.)
*/
#define MAX_COMPONENTS 10 /* maximum number of image components */
/*
* Basic data types.
* You may need to change these if you have a machine with unusual data
* type sizes; for example, "char" not 8 bits, "short" not 16 bits,
* or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits,
* but it had better be at least 16.
*/
/* Representation of a single sample (pixel element value).
* We frequently allocate large arrays of these, so it's important to keep
* them small. But if you have memory to burn and access to char or short
* arrays is very slow on your hardware, you might want to change these.
*/
#if BITS_IN_JSAMPLE == 8
/* JSAMPLE should be the smallest type that will hold the values 0..255.
* You can use a signed char by having GETJSAMPLE mask it with 0xFF.
*/
#ifdef HAVE_UNSIGNED_CHAR
typedef unsigned char JSAMPLE;
#define GETJSAMPLE(value) ((int) (value))
#else /* not HAVE_UNSIGNED_CHAR */
typedef char JSAMPLE;
#ifdef __CHAR_UNSIGNED__
#define GETJSAMPLE(value) ((int) (value))
#else
#define GETJSAMPLE(value) ((int) (value) & 0xFF)
#endif /* __CHAR_UNSIGNED__ */
#endif /* HAVE_UNSIGNED_CHAR */
#define MAXJSAMPLE 255
#define CENTERJSAMPLE 128
#endif /* BITS_IN_JSAMPLE == 8 */
#if BITS_IN_JSAMPLE == 12
/* JSAMPLE should be the smallest type that will hold the values 0..4095.
* On nearly all machines "short" will do nicely.
*/
typedef short JSAMPLE;
#define GETJSAMPLE(value) ((int) (value))
#define MAXJSAMPLE 4095
#define CENTERJSAMPLE 2048
#endif /* BITS_IN_JSAMPLE == 12 */
/* Representation of a DCT frequency coefficient.
* This should be a signed value of at least 16 bits; "short" is usually OK.
* Again, we allocate large arrays of these, but you can change to int
* if you have memory to burn and "short" is really slow.
*/
typedef short JCOEF;
/* Compressed datastreams are represented as arrays of JOCTET.
* These must be EXACTLY 8 bits wide, at least once they are written to
* external storage. Note that when using the stdio data source/destination
* managers, this is also the data type passed to fread/fwrite.
*/
#ifdef HAVE_UNSIGNED_CHAR
typedef unsigned char JOCTET;
#define GETJOCTET(value) (value)
#else /* not HAVE_UNSIGNED_CHAR */
typedef char JOCTET;
#ifdef __CHAR_UNSIGNED__
#define GETJOCTET(value) (value)
#else
#define GETJOCTET(value) ((value) & 0xFF)
#endif /* __CHAR_UNSIGNED__ */
#endif /* HAVE_UNSIGNED_CHAR */
/* These typedefs are used for various table entries and so forth.
* They must be at least as wide as specified; but making them too big
* won't cost a huge amount of memory, so we don't provide special
* extraction code like we did for JSAMPLE. (In other words, these
* typedefs live at a different point on the speed/space tradeoff curve.)
*/
/* UINT8 must hold at least the values 0..255. */
#ifdef HAVE_UNSIGNED_CHAR
typedef unsigned char UINT8;
#else /* not HAVE_UNSIGNED_CHAR */
#ifdef __CHAR_UNSIGNED__
typedef char UINT8;
#else /* not __CHAR_UNSIGNED__ */
typedef short UINT8;
#endif /* __CHAR_UNSIGNED__ */
#endif /* HAVE_UNSIGNED_CHAR */
/* UINT16 must hold at least the values 0..65535. */
#ifdef HAVE_UNSIGNED_SHORT
typedef unsigned short UINT16;
#else /* not HAVE_UNSIGNED_SHORT */
typedef unsigned int UINT16;
#endif /* HAVE_UNSIGNED_SHORT */
/* INT16 must hold at least the values -32768..32767. */
#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */
typedef short INT16;
#endif
/* INT32 must hold at least signed 32-bit values.
*
* NOTE: The INT32 typedef dates back to libjpeg v5 (1994.) Integers were
* sometimes 16-bit back then (MS-DOS), which is why INT32 is typedef'd to
* long. It also wasn't common (or at least as common) in 1994 for INT32 to be
* defined by platform headers. Since then, however, INT32 is defined in
* several other common places:
*
* Xmd.h (X11 header) typedefs INT32 to int on 64-bit platforms and long on
* 32-bit platforms (i.e always a 32-bit signed type.)
*
* basetsd.h (Win32 header) typedefs INT32 to int (always a 32-bit signed type
* on modern platforms.)
*
* qglobal.h (Qt header) typedefs INT32 to int (always a 32-bit signed type on
* modern platforms.)
*
* This is a recipe for conflict, since "long" and "int" aren't always
* compatible types. Since the definition of INT32 has technically been part
* of the libjpeg API for more than 20 years, we can't remove it, but we do not
* use it internally any longer. We instead define a separate type (JLONG)
* for internal use, which ensures that internal behavior will always be the
* same regardless of any external headers that may be included.
*/
#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */
#ifndef _BASETSD_H_ /* Microsoft defines it in basetsd.h */
#ifndef _BASETSD_H /* MinGW is slightly different */
#ifndef QGLOBAL_H /* Qt defines it in qglobal.h */
typedef long INT32;
#endif
#endif
#endif
#endif
/* Datatype used for image dimensions. The JPEG standard only supports
* images up to 64K*64K due to 16-bit fields in SOF markers. Therefore
* "unsigned int" is sufficient on all machines. However, if you need to
* handle larger images and you don't mind deviating from the spec, you
* can change this datatype. (Note that changing this datatype will
* potentially require modifying the SIMD code. The x86-64 SIMD extensions,
* in particular, assume a 32-bit JDIMENSION.)
*/
typedef unsigned int JDIMENSION;
#define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */
/* These macros are used in all function definitions and extern declarations.
* You could modify them if you need to change function linkage conventions;
* in particular, you'll need to do that to make the library a Windows DLL.
* Another application is to make all functions global for use with debuggers
* or code profilers that require it.
*/
/* a function called through method pointers: */
#define METHODDEF(type) static type
/* a function used only in its module: */
#define LOCAL(type) static type
/* a function referenced thru EXTERNs: */
#define GLOBAL(type) type
/* a reference to a GLOBAL function: */
#define EXTERN(type) extern type
/* Originally, this macro was used as a way of defining function prototypes
* for both modern compilers as well as older compilers that did not support
* prototype parameters. libjpeg-turbo has never supported these older,
* non-ANSI compilers, but the macro is still included because there is some
* software out there that uses it.
*/
#define JMETHOD(type,methodname,arglist) type (*methodname) arglist
/* libjpeg-turbo no longer supports platforms that have far symbols (MS-DOS),
* but again, some software relies on this macro.
*/
#undef FAR
#define FAR
/*
* On a few systems, type boolean and/or its values FALSE, TRUE may appear
* in standard header files. Or you may have conflicts with application-
* specific header files that you want to include together with these files.
* Defining HAVE_BOOLEAN before including jpeglib.h should make it work.
*/
#ifndef HAVE_BOOLEAN
typedef int boolean;
#endif
#ifndef FALSE /* in case these macros already exist */
#define FALSE 0 /* values of boolean */
#endif
#ifndef TRUE
#define TRUE 1
#endif
/*
* The remaining options affect code selection within the JPEG library,
* but they don't need to be visible to most applications using the library.
* To minimize application namespace pollution, the symbols won't be
* defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined.
*/
#ifdef JPEG_INTERNALS
#define JPEG_INTERNAL_OPTIONS
#endif
#ifdef JPEG_INTERNAL_OPTIONS
/*
* These defines indicate whether to include various optional functions.
* Undefining some of these symbols will produce a smaller but less capable
* library. Note that you can leave certain source files out of the
* compilation/linking process if you've #undef'd the corresponding symbols.
* (You may HAVE to do that if your compiler doesn't like null source files.)
*/
/* Capability options common to encoder and decoder: */
#define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */
#define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */
#define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */
/* Encoder capability options: */
#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */
/* Note: if you selected 12-bit data precision, it is dangerous to turn off
* ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit
* precision, so jchuff.c normally uses entropy optimization to compute
* usable tables for higher precision. If you don't want to do optimization,
* you'll have to supply different default Huffman tables.
* The exact same statements apply for progressive JPEG: the default tables
* don't work for progressive mode. (This may get fixed, however.)
*/
#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */
/* Decoder capability options: */
#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */
#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */
#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */
#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */
#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */
#define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */
#define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */
/* more capability options later, no doubt */
/*
* The RGB_RED, RGB_GREEN, RGB_BLUE, and RGB_PIXELSIZE macros are a vestigial
* feature of libjpeg. The idea was that, if an application developer needed
* to compress from/decompress to a BGR/BGRX/RGBX/XBGR/XRGB buffer, they could
* change these macros, rebuild libjpeg, and link their application statically
* with it. In reality, few people ever did this, because there were some
* severe restrictions involved (cjpeg and djpeg no longer worked properly,
* compressing/decompressing RGB JPEGs no longer worked properly, and the color
* quantizer wouldn't work with pixel sizes other than 3.) Further, since all
* of the O/S-supplied versions of libjpeg were built with the default values
* of RGB_RED, RGB_GREEN, RGB_BLUE, and RGB_PIXELSIZE, many applications have
* come to regard these values as immutable.
*
* The libjpeg-turbo colorspace extensions provide a much cleaner way of
* compressing from/decompressing to buffers with arbitrary component orders
* and pixel sizes. Thus, we do not support changing the values of RGB_RED,
* RGB_GREEN, RGB_BLUE, or RGB_PIXELSIZE. In addition to the restrictions
* listed above, changing these values will also break the SIMD extensions and
* the regression tests.
*/
#define RGB_RED 0 /* Offset of Red in an RGB scanline element */
#define RGB_GREEN 1 /* Offset of Green */
#define RGB_BLUE 2 /* Offset of Blue */
#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */
#define JPEG_NUMCS 17
#define EXT_RGB_RED 0
#define EXT_RGB_GREEN 1
#define EXT_RGB_BLUE 2
#define EXT_RGB_PIXELSIZE 3
#define EXT_RGBX_RED 0
#define EXT_RGBX_GREEN 1
#define EXT_RGBX_BLUE 2
#define EXT_RGBX_PIXELSIZE 4
#define EXT_BGR_RED 2
#define EXT_BGR_GREEN 1
#define EXT_BGR_BLUE 0
#define EXT_BGR_PIXELSIZE 3
#define EXT_BGRX_RED 2
#define EXT_BGRX_GREEN 1
#define EXT_BGRX_BLUE 0
#define EXT_BGRX_PIXELSIZE 4
#define EXT_XBGR_RED 3
#define EXT_XBGR_GREEN 2
#define EXT_XBGR_BLUE 1
#define EXT_XBGR_PIXELSIZE 4
#define EXT_XRGB_RED 1
#define EXT_XRGB_GREEN 2
#define EXT_XRGB_BLUE 3
#define EXT_XRGB_PIXELSIZE 4
static const int rgb_red[JPEG_NUMCS] = {
-1, -1, RGB_RED, -1, -1, -1, EXT_RGB_RED, EXT_RGBX_RED,
EXT_BGR_RED, EXT_BGRX_RED, EXT_XBGR_RED, EXT_XRGB_RED,
EXT_RGBX_RED, EXT_BGRX_RED, EXT_XBGR_RED, EXT_XRGB_RED,
-1
};
static const int rgb_green[JPEG_NUMCS] = {
-1, -1, RGB_GREEN, -1, -1, -1, EXT_RGB_GREEN, EXT_RGBX_GREEN,
EXT_BGR_GREEN, EXT_BGRX_GREEN, EXT_XBGR_GREEN, EXT_XRGB_GREEN,
EXT_RGBX_GREEN, EXT_BGRX_GREEN, EXT_XBGR_GREEN, EXT_XRGB_GREEN,
-1
};
static const int rgb_blue[JPEG_NUMCS] = {
-1, -1, RGB_BLUE, -1, -1, -1, EXT_RGB_BLUE, EXT_RGBX_BLUE,
EXT_BGR_BLUE, EXT_BGRX_BLUE, EXT_XBGR_BLUE, EXT_XRGB_BLUE,
EXT_RGBX_BLUE, EXT_BGRX_BLUE, EXT_XBGR_BLUE, EXT_XRGB_BLUE,
-1
};
static const int rgb_pixelsize[JPEG_NUMCS] = {
-1, -1, RGB_PIXELSIZE, -1, -1, -1, EXT_RGB_PIXELSIZE, EXT_RGBX_PIXELSIZE,
EXT_BGR_PIXELSIZE, EXT_BGRX_PIXELSIZE, EXT_XBGR_PIXELSIZE, EXT_XRGB_PIXELSIZE,
EXT_RGBX_PIXELSIZE, EXT_BGRX_PIXELSIZE, EXT_XBGR_PIXELSIZE, EXT_XRGB_PIXELSIZE,
-1
};
/* Definitions for speed-related optimizations. */
/* On some machines (notably 68000 series) "int" is 32 bits, but multiplying
* two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER
* as short on such a machine. MULTIPLIER must be at least 16 bits wide.
*/
#ifndef MULTIPLIER
#ifndef WITH_SIMD
#define MULTIPLIER int /* type for fastest integer multiply */
#else
#define MULTIPLIER short /* prefer 16-bit with SIMD for parellelism */
#endif
#endif
/* FAST_FLOAT should be either float or double, whichever is done faster
* by your compiler. (Note that this type is only used in the floating point
* DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.)
*/
#ifndef FAST_FLOAT
#define FAST_FLOAT float
#endif
#endif /* JPEG_INTERNAL_OPTIONS */
pcre_stringpiece.h 0000644 00000014250 15201526705 0010247 0 ustar 00 // Copyright (c) 2005, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: Sanjay Ghemawat
//
// A string like object that points into another piece of memory.
// Useful for providing an interface that allows clients to easily
// pass in either a "const char*" or a "string".
//
// Arghh! I wish C++ literals were automatically of type "string".
#ifndef _PCRE_STRINGPIECE_H
#define _PCRE_STRINGPIECE_H
#include <cstring>
#include <string>
#include <iosfwd> // for ostream forward-declaration
#if 0
#define HAVE_TYPE_TRAITS
#include <type_traits.h>
#elif 0
#define HAVE_TYPE_TRAITS
#include <bits/type_traits.h>
#endif
#include <pcre.h>
namespace pcrecpp {
using std::memcmp;
using std::strlen;
using std::string;
class PCRECPP_EXP_DEFN StringPiece {
private:
const char* ptr_;
int length_;
public:
// We provide non-explicit singleton constructors so users can pass
// in a "const char*" or a "string" wherever a "StringPiece" is
// expected.
StringPiece()
: ptr_(NULL), length_(0) { }
StringPiece(const char* str)
: ptr_(str), length_(static_cast<int>(strlen(ptr_))) { }
StringPiece(const unsigned char* str)
: ptr_(reinterpret_cast<const char*>(str)),
length_(static_cast<int>(strlen(ptr_))) { }
StringPiece(const string& str)
: ptr_(str.data()), length_(static_cast<int>(str.size())) { }
StringPiece(const char* offset, int len)
: ptr_(offset), length_(len) { }
// data() may return a pointer to a buffer with embedded NULs, and the
// returned buffer may or may not be null terminated. Therefore it is
// typically a mistake to pass data() to a routine that expects a NUL
// terminated string. Use "as_string().c_str()" if you really need to do
// this. Or better yet, change your routine so it does not rely on NUL
// termination.
const char* data() const { return ptr_; }
int size() const { return length_; }
bool empty() const { return length_ == 0; }
void clear() { ptr_ = NULL; length_ = 0; }
void set(const char* buffer, int len) { ptr_ = buffer; length_ = len; }
void set(const char* str) {
ptr_ = str;
length_ = static_cast<int>(strlen(str));
}
void set(const void* buffer, int len) {
ptr_ = reinterpret_cast<const char*>(buffer);
length_ = len;
}
char operator[](int i) const { return ptr_[i]; }
void remove_prefix(int n) {
ptr_ += n;
length_ -= n;
}
void remove_suffix(int n) {
length_ -= n;
}
bool operator==(const StringPiece& x) const {
return ((length_ == x.length_) &&
(memcmp(ptr_, x.ptr_, length_) == 0));
}
bool operator!=(const StringPiece& x) const {
return !(*this == x);
}
#define STRINGPIECE_BINARY_PREDICATE(cmp,auxcmp) \
bool operator cmp (const StringPiece& x) const { \
int r = memcmp(ptr_, x.ptr_, length_ < x.length_ ? length_ : x.length_); \
return ((r auxcmp 0) || ((r == 0) && (length_ cmp x.length_))); \
}
STRINGPIECE_BINARY_PREDICATE(<, <);
STRINGPIECE_BINARY_PREDICATE(<=, <);
STRINGPIECE_BINARY_PREDICATE(>=, >);
STRINGPIECE_BINARY_PREDICATE(>, >);
#undef STRINGPIECE_BINARY_PREDICATE
int compare(const StringPiece& x) const {
int r = memcmp(ptr_, x.ptr_, length_ < x.length_ ? length_ : x.length_);
if (r == 0) {
if (length_ < x.length_) r = -1;
else if (length_ > x.length_) r = +1;
}
return r;
}
string as_string() const {
return string(data(), size());
}
void CopyToString(string* target) const {
target->assign(ptr_, length_);
}
// Does "this" start with "x"
bool starts_with(const StringPiece& x) const {
return ((length_ >= x.length_) && (memcmp(ptr_, x.ptr_, x.length_) == 0));
}
};
} // namespace pcrecpp
// ------------------------------------------------------------------
// Functions used to create STL containers that use StringPiece
// Remember that a StringPiece's lifetime had better be less than
// that of the underlying string or char*. If it is not, then you
// cannot safely store a StringPiece into an STL container
// ------------------------------------------------------------------
#ifdef HAVE_TYPE_TRAITS
// This makes vector<StringPiece> really fast for some STL implementations
template<> struct __type_traits<pcrecpp::StringPiece> {
typedef __true_type has_trivial_default_constructor;
typedef __true_type has_trivial_copy_constructor;
typedef __true_type has_trivial_assignment_operator;
typedef __true_type has_trivial_destructor;
typedef __true_type is_POD_type;
};
#endif
// allow StringPiece to be logged
PCRECPP_EXP_DECL std::ostream& operator<<(std::ostream& o,
const pcrecpp::StringPiece& piece);
#endif /* _PCRE_STRINGPIECE_H */
protobuf-c/protobuf-c.h 0000644 00000101422 15201526705 0011060 0 ustar 00 /*
* Copyright (c) 2008-2017, Dave Benson and the protobuf-c authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*! \file
* \mainpage Introduction
*
* This is [protobuf-c], a C implementation of [Protocol Buffers].
*
* This file defines the public API for the `libprotobuf-c` support library.
* This API includes interfaces that can be used directly by client code as well
* as the interfaces used by the code generated by the `protoc-c` compiler.
*
* The `libprotobuf-c` support library performs the actual serialization and
* deserialization of Protocol Buffers messages. It interacts with structures,
* definitions, and metadata generated by the `protoc-c` compiler from .proto
* files.
*
* \authors Dave Benson and the `protobuf-c` authors.
*
* \copyright 2008-2014. Licensed under the terms of the [BSD-2-Clause] license.
*
* [protobuf-c]: https://github.com/protobuf-c/protobuf-c
* [Protocol Buffers]: https://developers.google.com/protocol-buffers/
* [BSD-2-Clause]: http://opensource.org/licenses/BSD-2-Clause
*
* \page gencode Generated Code
*
* For each enum, we generate a C enum. For each message, we generate a C
* structure which can be cast to a `ProtobufCMessage`.
*
* For each enum and message, we generate a descriptor object that allows us to
* implement a kind of reflection on the structures.
*
* First, some naming conventions:
*
* - The name of the type for enums and messages and services is camel case
* (meaning WordsAreCrammedTogether) except that double underscores are used
* to delimit scopes. For example, the following `.proto` file:
*
~~~{.proto}
package foo.bar;
message BazBah {
optional int32 val = 1;
}
~~~
*
* would generate a C type `Foo__Bar__BazBah`.
*
* - Identifiers for functions and globals are all lowercase, with camel case
* words separated by single underscores. For example, one of the function
* prototypes generated by `protoc-c` for the above example:
*
~~~{.c}
Foo__Bar__BazBah *
foo__bar__baz_bah__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
~~~
*
* - Identifiers for enum values contain an uppercase prefix which embeds the
* package name and the enum type name.
*
* - A double underscore is used to separate further components of identifier
* names.
*
* For example, in the name of the unpack function above, the package name
* `foo.bar` has become `foo__bar`, the message name BazBah has become
* `baz_bah`, and the method name is `unpack`. These are all joined with double
* underscores to form the C identifier `foo__bar__baz_bah__unpack`.
*
* We also generate descriptor objects for messages and enums. These are
* declared in the `.pb-c.h` files:
*
~~~{.c}
extern const ProtobufCMessageDescriptor foo__bar__baz_bah__descriptor;
~~~
*
* The message structures all begin with `ProtobufCMessageDescriptor *` which is
* sufficient to allow them to be cast to `ProtobufCMessage`.
*
* For each message defined in a `.proto` file, we generate a number of
* functions and macros. Each function name contains a prefix based on the
* package name and message name in order to make it a unique C identifier.
*
* - `INIT`. Statically initializes a message object, initializing its
* descriptor and setting its fields to default values. Uninitialized
* messages cannot be processed by the protobuf-c library.
*
~~~{.c}
#define FOO__BAR__BAZ_BAH__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&foo__bar__baz_bah__descriptor), 0 }
~~~
* - `init()`. Initializes a message object, initializing its descriptor and
* setting its fields to default values. Uninitialized messages cannot be
* processed by the protobuf-c library.
*
~~~{.c}
void foo__bar__baz_bah__init
(Foo__Bar__BazBah *message);
~~~
* - `unpack()`. Unpacks data for a particular message format. Note that the
* `allocator` parameter is usually `NULL` to indicate that the system's
* `malloc()` and `free()` functions should be used for dynamically allocating
* memory.
*
~~~{.c}
Foo__Bar__BazBah *
foo__bar__baz_bah__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
~~~
*
* - `free_unpacked()`. Frees a message object obtained with the `unpack()`
* method. Freeing `NULL` is allowed (the same as with `free()`).
*
~~~{.c}
void foo__bar__baz_bah__free_unpacked
(Foo__Bar__BazBah *message,
ProtobufCAllocator *allocator);
~~~
*
* - `get_packed_size()`. Calculates the length in bytes of the serialized
* representation of the message object.
*
~~~{.c}
size_t foo__bar__baz_bah__get_packed_size
(const Foo__Bar__BazBah *message);
~~~
*
* - `pack()`. Pack a message object into a preallocated buffer. Assumes that
* the buffer is large enough. (Use `get_packed_size()` first.)
*
~~~{.c}
size_t foo__bar__baz_bah__pack
(const Foo__Bar__BazBah *message,
uint8_t *out);
~~~
*
* - `pack_to_buffer()`. Packs a message into a "virtual buffer". This is an
* object which defines an "append bytes" callback to consume data as it is
* serialized.
*
~~~{.c}
size_t foo__bar__baz_bah__pack_to_buffer
(const Foo__Bar__BazBah *message,
ProtobufCBuffer *buffer);
~~~
*
* \page pack Packing and unpacking messages
*
* To pack a message, first compute the packed size of the message with
* protobuf_c_message_get_packed_size(), then allocate a buffer of at least
* that size, then call protobuf_c_message_pack().
*
* Alternatively, a message can be serialized without calculating the final size
* first. Use the protobuf_c_message_pack_to_buffer() function and provide a
* ProtobufCBuffer object which implements an "append" method that consumes
* data.
*
* To unpack a message, call the protobuf_c_message_unpack() function. The
* result can be cast to an object of the type that matches the descriptor for
* the message.
*
* The result of unpacking a message should be freed with
* protobuf_c_message_free_unpacked().
*/
#ifndef PROTOBUF_C_H
#define PROTOBUF_C_H
#include <assert.h>
#include <limits.h>
#include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus
# define PROTOBUF_C__BEGIN_DECLS extern "C" {
# define PROTOBUF_C__END_DECLS }
#else
# define PROTOBUF_C__BEGIN_DECLS
# define PROTOBUF_C__END_DECLS
#endif
PROTOBUF_C__BEGIN_DECLS
#if defined(_WIN32) && defined(PROTOBUF_C_USE_SHARED_LIB)
# ifdef PROTOBUF_C_EXPORT
# define PROTOBUF_C__API __declspec(dllexport)
# else
# define PROTOBUF_C__API __declspec(dllimport)
# endif
#else
# define PROTOBUF_C__API
#endif
#if !defined(PROTOBUF_C__NO_DEPRECATED) && \
((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
# define PROTOBUF_C__DEPRECATED __attribute__((__deprecated__))
#else
# define PROTOBUF_C__DEPRECATED
#endif
#ifndef PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE
#define PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(enum_name) \
, _##enum_name##_IS_INT_SIZE = INT_MAX
#endif
#define PROTOBUF_C__SERVICE_DESCRIPTOR_MAGIC 0x14159bc3
#define PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC 0x28aaeef9
#define PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC 0x114315af
/* Empty string used for initializers */
extern const char protobuf_c_empty_string[];
/**
* \defgroup api Public API
*
* This is the public API for `libprotobuf-c`. These interfaces are stable and
* subject to Semantic Versioning guarantees.
*
* @{
*/
/**
* Values for the `flags` word in `ProtobufCFieldDescriptor`.
*/
typedef enum {
/** Set if the field is repeated and marked with the `packed` option. */
PROTOBUF_C_FIELD_FLAG_PACKED = (1 << 0),
/** Set if the field is marked with the `deprecated` option. */
PROTOBUF_C_FIELD_FLAG_DEPRECATED = (1 << 1),
/** Set if the field is a member of a oneof (union). */
PROTOBUF_C_FIELD_FLAG_ONEOF = (1 << 2),
} ProtobufCFieldFlag;
/**
* Message field rules.
*
* \see [Defining A Message Type] in the Protocol Buffers documentation.
*
* [Defining A Message Type]:
* https://developers.google.com/protocol-buffers/docs/proto#simple
*/
typedef enum {
/** A well-formed message must have exactly one of this field. */
PROTOBUF_C_LABEL_REQUIRED,
/**
* A well-formed message can have zero or one of this field (but not
* more than one).
*/
PROTOBUF_C_LABEL_OPTIONAL,
/**
* This field can be repeated any number of times (including zero) in a
* well-formed message. The order of the repeated values will be
* preserved.
*/
PROTOBUF_C_LABEL_REPEATED,
/**
* This field has no label. This is valid only in proto3 and is
* equivalent to OPTIONAL but no "has" quantifier will be consulted.
*/
PROTOBUF_C_LABEL_NONE,
} ProtobufCLabel;
/**
* Field value types.
*
* \see [Scalar Value Types] in the Protocol Buffers documentation.
*
* [Scalar Value Types]:
* https://developers.google.com/protocol-buffers/docs/proto#scalar
*/
typedef enum {
PROTOBUF_C_TYPE_INT32, /**< int32 */
PROTOBUF_C_TYPE_SINT32, /**< signed int32 */
PROTOBUF_C_TYPE_SFIXED32, /**< signed int32 (4 bytes) */
PROTOBUF_C_TYPE_INT64, /**< int64 */
PROTOBUF_C_TYPE_SINT64, /**< signed int64 */
PROTOBUF_C_TYPE_SFIXED64, /**< signed int64 (8 bytes) */
PROTOBUF_C_TYPE_UINT32, /**< unsigned int32 */
PROTOBUF_C_TYPE_FIXED32, /**< unsigned int32 (4 bytes) */
PROTOBUF_C_TYPE_UINT64, /**< unsigned int64 */
PROTOBUF_C_TYPE_FIXED64, /**< unsigned int64 (8 bytes) */
PROTOBUF_C_TYPE_FLOAT, /**< float */
PROTOBUF_C_TYPE_DOUBLE, /**< double */
PROTOBUF_C_TYPE_BOOL, /**< boolean */
PROTOBUF_C_TYPE_ENUM, /**< enumerated type */
PROTOBUF_C_TYPE_STRING, /**< UTF-8 or ASCII string */
PROTOBUF_C_TYPE_BYTES, /**< arbitrary byte sequence */
PROTOBUF_C_TYPE_MESSAGE, /**< nested message */
} ProtobufCType;
/**
* Field wire types.
*
* \see [Message Structure] in the Protocol Buffers documentation.
*
* [Message Structure]:
* https://developers.google.com/protocol-buffers/docs/encoding#structure
*/
typedef enum {
PROTOBUF_C_WIRE_TYPE_VARINT = 0,
PROTOBUF_C_WIRE_TYPE_64BIT = 1,
PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED = 2,
/* "Start group" and "end group" wire types are unsupported. */
PROTOBUF_C_WIRE_TYPE_32BIT = 5,
} ProtobufCWireType;
struct ProtobufCAllocator;
struct ProtobufCBinaryData;
struct ProtobufCBuffer;
struct ProtobufCBufferSimple;
struct ProtobufCEnumDescriptor;
struct ProtobufCEnumValue;
struct ProtobufCEnumValueIndex;
struct ProtobufCFieldDescriptor;
struct ProtobufCIntRange;
struct ProtobufCMessage;
struct ProtobufCMessageDescriptor;
struct ProtobufCMessageUnknownField;
struct ProtobufCMethodDescriptor;
struct ProtobufCService;
struct ProtobufCServiceDescriptor;
typedef struct ProtobufCAllocator ProtobufCAllocator;
typedef struct ProtobufCBinaryData ProtobufCBinaryData;
typedef struct ProtobufCBuffer ProtobufCBuffer;
typedef struct ProtobufCBufferSimple ProtobufCBufferSimple;
typedef struct ProtobufCEnumDescriptor ProtobufCEnumDescriptor;
typedef struct ProtobufCEnumValue ProtobufCEnumValue;
typedef struct ProtobufCEnumValueIndex ProtobufCEnumValueIndex;
typedef struct ProtobufCFieldDescriptor ProtobufCFieldDescriptor;
typedef struct ProtobufCIntRange ProtobufCIntRange;
typedef struct ProtobufCMessage ProtobufCMessage;
typedef struct ProtobufCMessageDescriptor ProtobufCMessageDescriptor;
typedef struct ProtobufCMessageUnknownField ProtobufCMessageUnknownField;
typedef struct ProtobufCMethodDescriptor ProtobufCMethodDescriptor;
typedef struct ProtobufCService ProtobufCService;
typedef struct ProtobufCServiceDescriptor ProtobufCServiceDescriptor;
/** Boolean type. */
typedef int protobuf_c_boolean;
typedef void (*ProtobufCClosure)(const ProtobufCMessage *, void *closure_data);
typedef void (*ProtobufCMessageInit)(ProtobufCMessage *);
typedef void (*ProtobufCServiceDestroy)(ProtobufCService *);
/**
* Structure for defining a custom memory allocator.
*/
struct ProtobufCAllocator {
/** Function to allocate memory. */
void *(*alloc)(void *allocator_data, size_t size);
/** Function to free memory. */
void (*free)(void *allocator_data, void *pointer);
/** Opaque pointer passed to `alloc` and `free` functions. */
void *allocator_data;
};
/**
* Structure for the protobuf `bytes` scalar type.
*
* The data contained in a `ProtobufCBinaryData` is an arbitrary sequence of
* bytes. It may contain embedded `NUL` characters and is not required to be
* `NUL`-terminated.
*/
struct ProtobufCBinaryData {
size_t len; /**< Number of bytes in the `data` field. */
uint8_t *data; /**< Data bytes. */
};
/**
* Structure for defining a virtual append-only buffer. Used by
* protobuf_c_message_pack_to_buffer() to abstract the consumption of serialized
* bytes.
*
* `ProtobufCBuffer` "subclasses" may be defined on the stack. For example, to
* write to a `FILE` object:
*
~~~{.c}
typedef struct {
ProtobufCBuffer base;
FILE *fp;
} BufferAppendToFile;
static void
my_buffer_file_append(ProtobufCBuffer *buffer,
size_t len,
const uint8_t *data)
{
BufferAppendToFile *file_buf = (BufferAppendToFile *) buffer;
fwrite(data, len, 1, file_buf->fp); // XXX: No error handling!
}
~~~
*
* To use this new type of ProtobufCBuffer, it could be called as follows:
*
~~~{.c}
...
BufferAppendToFile tmp = {0};
tmp.base.append = my_buffer_file_append;
tmp.fp = fp;
protobuf_c_message_pack_to_buffer(&message, &tmp);
...
~~~
*/
struct ProtobufCBuffer {
/** Append function. Consumes the `len` bytes stored at `data`. */
void (*append)(ProtobufCBuffer *buffer,
size_t len,
const uint8_t *data);
};
/**
* Simple buffer "subclass" of `ProtobufCBuffer`.
*
* A `ProtobufCBufferSimple` object is declared on the stack and uses a
* scratch buffer provided by the user for the initial allocation. It performs
* exponential resizing, using dynamically allocated memory. A
* `ProtobufCBufferSimple` object can be created and used as follows:
*
~~~{.c}
uint8_t pad[128];
ProtobufCBufferSimple simple = PROTOBUF_C_BUFFER_SIMPLE_INIT(pad);
ProtobufCBuffer *buffer = (ProtobufCBuffer *) &simple;
~~~
*
* `buffer` can now be used with `protobuf_c_message_pack_to_buffer()`. Once a
* message has been serialized to a `ProtobufCBufferSimple` object, the
* serialized data bytes can be accessed from the `.data` field.
*
* To free the memory allocated by a `ProtobufCBufferSimple` object, if any,
* call PROTOBUF_C_BUFFER_SIMPLE_CLEAR() on the object, for example:
*
~~~{.c}
PROTOBUF_C_BUFFER_SIMPLE_CLEAR(&simple);
~~~
*
* \see PROTOBUF_C_BUFFER_SIMPLE_INIT
* \see PROTOBUF_C_BUFFER_SIMPLE_CLEAR
*/
struct ProtobufCBufferSimple {
/** "Base class". */
ProtobufCBuffer base;
/** Number of bytes allocated in `data`. */
size_t alloced;
/** Number of bytes currently stored in `data`. */
size_t len;
/** Data bytes. */
uint8_t *data;
/** Whether `data` must be freed. */
protobuf_c_boolean must_free_data;
/** Allocator to use. May be NULL to indicate the system allocator. */
ProtobufCAllocator *allocator;
};
/**
* Describes an enumeration as a whole, with all of its values.
*/
struct ProtobufCEnumDescriptor {
/** Magic value checked to ensure that the API is used correctly. */
uint32_t magic;
/** The qualified name (e.g., "namespace.Type"). */
const char *name;
/** The unqualified name as given in the .proto file (e.g., "Type"). */
const char *short_name;
/** Identifier used in generated C code. */
const char *c_name;
/** The dot-separated namespace. */
const char *package_name;
/** Number elements in `values`. */
unsigned n_values;
/** Array of distinct values, sorted by numeric value. */
const ProtobufCEnumValue *values;
/** Number of elements in `values_by_name`. */
unsigned n_value_names;
/** Array of named values, including aliases, sorted by name. */
const ProtobufCEnumValueIndex *values_by_name;
/** Number of elements in `value_ranges`. */
unsigned n_value_ranges;
/** Value ranges, for faster lookups by numeric value. */
const ProtobufCIntRange *value_ranges;
/** Reserved for future use. */
void *reserved1;
/** Reserved for future use. */
void *reserved2;
/** Reserved for future use. */
void *reserved3;
/** Reserved for future use. */
void *reserved4;
};
/**
* Represents a single value of an enumeration.
*/
struct ProtobufCEnumValue {
/** The string identifying this value in the .proto file. */
const char *name;
/** The string identifying this value in generated C code. */
const char *c_name;
/** The numeric value assigned in the .proto file. */
int value;
};
/**
* Used by `ProtobufCEnumDescriptor` to look up enum values.
*/
struct ProtobufCEnumValueIndex {
/** Name of the enum value. */
const char *name;
/** Index into values[] array. */
unsigned index;
};
/**
* Describes a single field in a message.
*/
struct ProtobufCFieldDescriptor {
/** Name of the field as given in the .proto file. */
const char *name;
/** Tag value of the field as given in the .proto file. */
uint32_t id;
/** Whether the field is `REQUIRED`, `OPTIONAL`, or `REPEATED`. */
ProtobufCLabel label;
/** The type of the field. */
ProtobufCType type;
/**
* The offset in bytes of the message's C structure's quantifier field
* (the `has_MEMBER` field for optional members or the `n_MEMBER` field
* for repeated members or the case enum for oneofs).
*/
unsigned quantifier_offset;
/**
* The offset in bytes into the message's C structure for the member
* itself.
*/
unsigned offset;
/**
* A type-specific descriptor.
*
* If `type` is `PROTOBUF_C_TYPE_ENUM`, then `descriptor` points to the
* corresponding `ProtobufCEnumDescriptor`.
*
* If `type` is `PROTOBUF_C_TYPE_MESSAGE`, then `descriptor` points to
* the corresponding `ProtobufCMessageDescriptor`.
*
* Otherwise this field is NULL.
*/
const void *descriptor; /* for MESSAGE and ENUM types */
/** The default value for this field, if defined. May be NULL. */
const void *default_value;
/**
* A flag word. Zero or more of the bits defined in the
* `ProtobufCFieldFlag` enum may be set.
*/
uint32_t flags;
/** Reserved for future use. */
unsigned reserved_flags;
/** Reserved for future use. */
void *reserved2;
/** Reserved for future use. */
void *reserved3;
};
/**
* Helper structure for optimizing int => index lookups in the case
* where the keys are mostly consecutive values, as they presumably are for
* enums and fields.
*
* The data structures requires that the values in the original array are
* sorted.
*/
struct ProtobufCIntRange {
int start_value;
unsigned orig_index;
/*
* NOTE: the number of values in the range can be inferred by looking
* at the next element's orig_index. A dummy element is added to make
* this simple.
*/
};
/**
* An instance of a message.
*
* `ProtobufCMessage` is a light-weight "base class" for all messages.
*
* In particular, `ProtobufCMessage` doesn't have any allocation policy
* associated with it. That's because it's common to create `ProtobufCMessage`
* objects on the stack. In fact, that's what we recommend for sending messages.
* If the object is allocated from the stack, you can't really have a memory
* leak.
*
* This means that calls to functions like protobuf_c_message_unpack() which
* return a `ProtobufCMessage` must be paired with a call to a free function,
* like protobuf_c_message_free_unpacked().
*/
struct ProtobufCMessage {
/** The descriptor for this message type. */
const ProtobufCMessageDescriptor *descriptor;
/** The number of elements in `unknown_fields`. */
unsigned n_unknown_fields;
/** The fields that weren't recognized by the parser. */
ProtobufCMessageUnknownField *unknown_fields;
};
/**
* Describes a message.
*/
struct ProtobufCMessageDescriptor {
/** Magic value checked to ensure that the API is used correctly. */
uint32_t magic;
/** The qualified name (e.g., "namespace.Type"). */
const char *name;
/** The unqualified name as given in the .proto file (e.g., "Type"). */
const char *short_name;
/** Identifier used in generated C code. */
const char *c_name;
/** The dot-separated namespace. */
const char *package_name;
/**
* Size in bytes of the C structure representing an instance of this
* type of message.
*/
size_t sizeof_message;
/** Number of elements in `fields`. */
unsigned n_fields;
/** Field descriptors, sorted by tag number. */
const ProtobufCFieldDescriptor *fields;
/** Used for looking up fields by name. */
const unsigned *fields_sorted_by_name;
/** Number of elements in `field_ranges`. */
unsigned n_field_ranges;
/** Used for looking up fields by id. */
const ProtobufCIntRange *field_ranges;
/** Message initialisation function. */
ProtobufCMessageInit message_init;
/** Reserved for future use. */
void *reserved1;
/** Reserved for future use. */
void *reserved2;
/** Reserved for future use. */
void *reserved3;
};
/**
* An unknown message field.
*/
struct ProtobufCMessageUnknownField {
/** The tag number. */
uint32_t tag;
/** The wire type of the field. */
ProtobufCWireType wire_type;
/** Number of bytes in `data`. */
size_t len;
/** Field data. */
uint8_t *data;
};
/**
* Method descriptor.
*/
struct ProtobufCMethodDescriptor {
/** Method name. */
const char *name;
/** Input message descriptor. */
const ProtobufCMessageDescriptor *input;
/** Output message descriptor. */
const ProtobufCMessageDescriptor *output;
};
/**
* Service.
*/
struct ProtobufCService {
/** Service descriptor. */
const ProtobufCServiceDescriptor *descriptor;
/** Function to invoke the service. */
void (*invoke)(ProtobufCService *service,
unsigned method_index,
const ProtobufCMessage *input,
ProtobufCClosure closure,
void *closure_data);
/** Function to destroy the service. */
void (*destroy)(ProtobufCService *service);
};
/**
* Service descriptor.
*/
struct ProtobufCServiceDescriptor {
/** Magic value checked to ensure that the API is used correctly. */
uint32_t magic;
/** Service name. */
const char *name;
/** Short version of service name. */
const char *short_name;
/** C identifier for the service name. */
const char *c_name;
/** Package name. */
const char *package;
/** Number of elements in `methods`. */
unsigned n_methods;
/** Method descriptors, in the order defined in the .proto file. */
const ProtobufCMethodDescriptor *methods;
/** Sort index of methods. */
const unsigned *method_indices_by_name;
};
/**
* Get the version of the protobuf-c library. Note that this is the version of
* the library linked against, not the version of the headers compiled against.
*
* \return A string containing the version number of protobuf-c.
*/
PROTOBUF_C__API
const char *
protobuf_c_version(void);
/**
* Get the version of the protobuf-c library. Note that this is the version of
* the library linked against, not the version of the headers compiled against.
*
* \return A 32 bit unsigned integer containing the version number of
* protobuf-c, represented in base-10 as (MAJOR*1E6) + (MINOR*1E3) + PATCH.
*/
PROTOBUF_C__API
uint32_t
protobuf_c_version_number(void);
/**
* The version of the protobuf-c headers, represented as a string using the same
* format as protobuf_c_version().
*/
#define PROTOBUF_C_VERSION "1.3.0"
/**
* The version of the protobuf-c headers, represented as an integer using the
* same format as protobuf_c_version_number().
*/
#define PROTOBUF_C_VERSION_NUMBER 1003000
/**
* The minimum protoc-c version which works with the current version of the
* protobuf-c headers.
*/
#define PROTOBUF_C_MIN_COMPILER_VERSION 1000000
/**
* Look up a `ProtobufCEnumValue` from a `ProtobufCEnumDescriptor` by name.
*
* \param desc
* The `ProtobufCEnumDescriptor` object.
* \param name
* The `name` field from the corresponding `ProtobufCEnumValue` object to
* match.
* \return
* A `ProtobufCEnumValue` object.
* \retval NULL
* If not found or if the optimize_for = CODE_SIZE option was set.
*/
PROTOBUF_C__API
const ProtobufCEnumValue *
protobuf_c_enum_descriptor_get_value_by_name(
const ProtobufCEnumDescriptor *desc,
const char *name);
/**
* Look up a `ProtobufCEnumValue` from a `ProtobufCEnumDescriptor` by numeric
* value.
*
* \param desc
* The `ProtobufCEnumDescriptor` object.
* \param value
* The `value` field from the corresponding `ProtobufCEnumValue` object to
* match.
*
* \return
* A `ProtobufCEnumValue` object.
* \retval NULL
* If not found.
*/
PROTOBUF_C__API
const ProtobufCEnumValue *
protobuf_c_enum_descriptor_get_value(
const ProtobufCEnumDescriptor *desc,
int value);
/**
* Look up a `ProtobufCFieldDescriptor` from a `ProtobufCMessageDescriptor` by
* the name of the field.
*
* \param desc
* The `ProtobufCMessageDescriptor` object.
* \param name
* The name of the field.
* \return
* A `ProtobufCFieldDescriptor` object.
* \retval NULL
* If not found or if the optimize_for = CODE_SIZE option was set.
*/
PROTOBUF_C__API
const ProtobufCFieldDescriptor *
protobuf_c_message_descriptor_get_field_by_name(
const ProtobufCMessageDescriptor *desc,
const char *name);
/**
* Look up a `ProtobufCFieldDescriptor` from a `ProtobufCMessageDescriptor` by
* the tag value of the field.
*
* \param desc
* The `ProtobufCMessageDescriptor` object.
* \param value
* The tag value of the field.
* \return
* A `ProtobufCFieldDescriptor` object.
* \retval NULL
* If not found.
*/
PROTOBUF_C__API
const ProtobufCFieldDescriptor *
protobuf_c_message_descriptor_get_field(
const ProtobufCMessageDescriptor *desc,
unsigned value);
/**
* Determine the number of bytes required to store the serialised message.
*
* \param message
* The message object to serialise.
* \return
* Number of bytes.
*/
PROTOBUF_C__API
size_t
protobuf_c_message_get_packed_size(const ProtobufCMessage *message);
/**
* Serialise a message from its in-memory representation.
*
* This function stores the serialised bytes of the message in a pre-allocated
* buffer.
*
* \param message
* The message object to serialise.
* \param[out] out
* Buffer to store the bytes of the serialised message. This buffer must
* have enough space to store the packed message. Use
* protobuf_c_message_get_packed_size() to determine the number of bytes
* required.
* \return
* Number of bytes stored in `out`.
*/
PROTOBUF_C__API
size_t
protobuf_c_message_pack(const ProtobufCMessage *message, uint8_t *out);
/**
* Serialise a message from its in-memory representation to a virtual buffer.
*
* This function calls the `append` method of a `ProtobufCBuffer` object to
* consume the bytes generated by the serialiser.
*
* \param message
* The message object to serialise.
* \param buffer
* The virtual buffer object.
* \return
* Number of bytes passed to the virtual buffer.
*/
PROTOBUF_C__API
size_t
protobuf_c_message_pack_to_buffer(
const ProtobufCMessage *message,
ProtobufCBuffer *buffer);
/**
* Unpack a serialised message into an in-memory representation.
*
* \param descriptor
* The message descriptor.
* \param allocator
* `ProtobufCAllocator` to use for memory allocation. May be NULL to
* specify the default allocator.
* \param len
* Length in bytes of the serialised message.
* \param data
* Pointer to the serialised message.
* \return
* An unpacked message object.
* \retval NULL
* If an error occurred during unpacking.
*/
PROTOBUF_C__API
ProtobufCMessage *
protobuf_c_message_unpack(
const ProtobufCMessageDescriptor *descriptor,
ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
/**
* Free an unpacked message object.
*
* This function should be used to deallocate the memory used by a call to
* protobuf_c_message_unpack().
*
* \param message
* The message object to free. May be NULL.
* \param allocator
* `ProtobufCAllocator` to use for memory deallocation. May be NULL to
* specify the default allocator.
*/
PROTOBUF_C__API
void
protobuf_c_message_free_unpacked(
ProtobufCMessage *message,
ProtobufCAllocator *allocator);
/**
* Check the validity of a message object.
*
* Makes sure all required fields (`PROTOBUF_C_LABEL_REQUIRED`) are present.
* Recursively checks nested messages.
*
* \retval TRUE
* Message is valid.
* \retval FALSE
* Message is invalid.
*/
PROTOBUF_C__API
protobuf_c_boolean
protobuf_c_message_check(const ProtobufCMessage *);
/** Message initialiser. */
#define PROTOBUF_C_MESSAGE_INIT(descriptor) { descriptor, 0, NULL }
/**
* Initialise a message object from a message descriptor.
*
* \param descriptor
* Message descriptor.
* \param message
* Allocated block of memory of size `descriptor->sizeof_message`.
*/
PROTOBUF_C__API
void
protobuf_c_message_init(
const ProtobufCMessageDescriptor *descriptor,
void *message);
/**
* Free a service.
*
* \param service
* The service object to free.
*/
PROTOBUF_C__API
void
protobuf_c_service_destroy(ProtobufCService *service);
/**
* Look up a `ProtobufCMethodDescriptor` by name.
*
* \param desc
* Service descriptor.
* \param name
* Name of the method.
*
* \return
* A `ProtobufCMethodDescriptor` object.
* \retval NULL
* If not found or if the optimize_for = CODE_SIZE option was set.
*/
PROTOBUF_C__API
const ProtobufCMethodDescriptor *
protobuf_c_service_descriptor_get_method_by_name(
const ProtobufCServiceDescriptor *desc,
const char *name);
/**
* Initialise a `ProtobufCBufferSimple` object.
*/
#define PROTOBUF_C_BUFFER_SIMPLE_INIT(array_of_bytes) \
{ \
{ protobuf_c_buffer_simple_append }, \
sizeof(array_of_bytes), \
0, \
(array_of_bytes), \
0, \
NULL \
}
/**
* Clear a `ProtobufCBufferSimple` object, freeing any allocated memory.
*/
#define PROTOBUF_C_BUFFER_SIMPLE_CLEAR(simp_buf) \
do { \
if ((simp_buf)->must_free_data) { \
if ((simp_buf)->allocator != NULL) \
(simp_buf)->allocator->free( \
(simp_buf)->allocator, \
(simp_buf)->data); \
else \
free((simp_buf)->data); \
} \
} while (0)
/**
* The `append` method for `ProtobufCBufferSimple`.
*
* \param buffer
* The buffer object to append to. Must actually be a
* `ProtobufCBufferSimple` object.
* \param len
* Number of bytes in `data`.
* \param data
* Data to append.
*/
PROTOBUF_C__API
void
protobuf_c_buffer_simple_append(
ProtobufCBuffer *buffer,
size_t len,
const unsigned char *data);
PROTOBUF_C__API
void
protobuf_c_service_generated_init(
ProtobufCService *service,
const ProtobufCServiceDescriptor *descriptor,
ProtobufCServiceDestroy destroy);
PROTOBUF_C__API
void
protobuf_c_service_invoke_internal(
ProtobufCService *service,
unsigned method_index,
const ProtobufCMessage *input,
ProtobufCClosure closure,
void *closure_data);
/**@}*/
PROTOBUF_C__END_DECLS
#endif /* PROTOBUF_C_H */
fcntl.h 0000644 00000025316 15201526705 0006035 0 ustar 00 /* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
/*
* POSIX Standard: 6.5 File Control Operations <fcntl.h>
*/
#ifndef _FCNTL_H
#define _FCNTL_H 1
#include <features.h>
/* This must be early so <bits/fcntl.h> can define types winningly. */
__BEGIN_DECLS
/* Get __mode_t, __dev_t and __off_t .*/
#include <bits/types.h>
/* Get the definitions of O_*, F_*, FD_*: all the
numbers and flag bits for `open', `fcntl', et al. */
#include <bits/fcntl.h>
/* Detect if open needs mode as a third argument (or for openat as a fourth
argument). */
#ifdef __O_TMPFILE
# define __OPEN_NEEDS_MODE(oflag) \
(((oflag) & O_CREAT) != 0 || ((oflag) & __O_TMPFILE) == __O_TMPFILE)
#else
# define __OPEN_NEEDS_MODE(oflag) (((oflag) & O_CREAT) != 0)
#endif
/* POSIX.1-2001 specifies that these types are defined by <fcntl.h>.
Earlier POSIX standards permitted any type ending in `_t' to be defined
by any POSIX header, so we don't conditionalize the definitions here. */
#ifndef __mode_t_defined
typedef __mode_t mode_t;
# define __mode_t_defined
#endif
#ifndef __off_t_defined
# ifndef __USE_FILE_OFFSET64
typedef __off_t off_t;
# else
typedef __off64_t off_t;
# endif
# define __off_t_defined
#endif
#if defined __USE_LARGEFILE64 && !defined __off64_t_defined
typedef __off64_t off64_t;
# define __off64_t_defined
#endif
#ifndef __pid_t_defined
typedef __pid_t pid_t;
# define __pid_t_defined
#endif
/* For XPG all symbols from <sys/stat.h> should also be available. */
#ifdef __USE_XOPEN2K8
# include <bits/types/struct_timespec.h>
#endif
#if defined __USE_XOPEN || defined __USE_XOPEN2K8
# include <bits/stat.h>
# define S_IFMT __S_IFMT
# define S_IFDIR __S_IFDIR
# define S_IFCHR __S_IFCHR
# define S_IFBLK __S_IFBLK
# define S_IFREG __S_IFREG
# ifdef __S_IFIFO
# define S_IFIFO __S_IFIFO
# endif
# ifdef __S_IFLNK
# define S_IFLNK __S_IFLNK
# endif
# if (defined __USE_UNIX98 || defined __USE_XOPEN2K8) && defined __S_IFSOCK
# define S_IFSOCK __S_IFSOCK
# endif
/* Protection bits. */
# define S_ISUID __S_ISUID /* Set user ID on execution. */
# define S_ISGID __S_ISGID /* Set group ID on execution. */
# if defined __USE_MISC || defined __USE_XOPEN
/* Save swapped text after use (sticky bit). This is pretty well obsolete. */
# define S_ISVTX __S_ISVTX
# endif
# define S_IRUSR __S_IREAD /* Read by owner. */
# define S_IWUSR __S_IWRITE /* Write by owner. */
# define S_IXUSR __S_IEXEC /* Execute by owner. */
/* Read, write, and execute by owner. */
# define S_IRWXU (__S_IREAD|__S_IWRITE|__S_IEXEC)
# define S_IRGRP (S_IRUSR >> 3) /* Read by group. */
# define S_IWGRP (S_IWUSR >> 3) /* Write by group. */
# define S_IXGRP (S_IXUSR >> 3) /* Execute by group. */
/* Read, write, and execute by group. */
# define S_IRWXG (S_IRWXU >> 3)
# define S_IROTH (S_IRGRP >> 3) /* Read by others. */
# define S_IWOTH (S_IWGRP >> 3) /* Write by others. */
# define S_IXOTH (S_IXGRP >> 3) /* Execute by others. */
/* Read, write, and execute by others. */
# define S_IRWXO (S_IRWXG >> 3)
#endif
#ifdef __USE_MISC
# ifndef R_OK /* Verbatim from <unistd.h>. Ugh. */
/* Values for the second argument to access.
These may be OR'd together. */
# define R_OK 4 /* Test for read permission. */
# define W_OK 2 /* Test for write permission. */
# define X_OK 1 /* Test for execute permission. */
# define F_OK 0 /* Test for existence. */
# endif
#endif /* Use misc. */
/* XPG wants the following symbols. <stdio.h> has the same definitions. */
#if defined __USE_XOPEN || defined __USE_XOPEN2K8
# define SEEK_SET 0 /* Seek from beginning of file. */
# define SEEK_CUR 1 /* Seek from current position. */
# define SEEK_END 2 /* Seek from end of file. */
#endif /* XPG */
/* The constants AT_REMOVEDIR and AT_EACCESS have the same value. AT_EACCESS
is meaningful only to faccessat, while AT_REMOVEDIR is meaningful only to
unlinkat. The two functions do completely different things and therefore,
the flags can be allowed to overlap. For example, passing AT_REMOVEDIR to
faccessat would be undefined behavior and thus treating it equivalent to
AT_EACCESS is valid undefined behavior. */
#ifdef __USE_ATFILE
# define AT_FDCWD -100 /* Special value used to indicate
the *at functions should use the
current working directory. */
# define AT_SYMLINK_NOFOLLOW 0x100 /* Do not follow symbolic links. */
# define AT_REMOVEDIR 0x200 /* Remove directory instead of
unlinking file. */
# define AT_SYMLINK_FOLLOW 0x400 /* Follow symbolic links. */
# ifdef __USE_GNU
# define AT_NO_AUTOMOUNT 0x800 /* Suppress terminal automount
traversal. */
# define AT_EMPTY_PATH 0x1000 /* Allow empty relative pathname. */
# define AT_STATX_SYNC_TYPE 0x6000
# define AT_STATX_SYNC_AS_STAT 0x0000
# define AT_STATX_FORCE_SYNC 0x2000
# define AT_STATX_DONT_SYNC 0x4000
# endif
# define AT_EACCESS 0x200 /* Test access permitted for
effective IDs, not real IDs. */
#endif
/* Do the file control operation described by CMD on FD.
The remaining arguments are interpreted depending on CMD.
This function is a cancellation point and therefore not marked with
__THROW. */
#ifndef __USE_FILE_OFFSET64
extern int fcntl (int __fd, int __cmd, ...);
#else
# ifdef __REDIRECT
extern int __REDIRECT (fcntl, (int __fd, int __cmd, ...), fcntl64);
# else
# define fcntl fcntl64
# endif
#endif
#ifdef __USE_LARGEFILE64
extern int fcntl64 (int __fd, int __cmd, ...);
#endif
/* Open FILE and return a new file descriptor for it, or -1 on error.
OFLAG determines the type of access used. If O_CREAT or O_TMPFILE is set
in OFLAG, the third argument is taken as a `mode_t', the mode of the
created file.
This function is a cancellation point and therefore not marked with
__THROW. */
#ifndef __USE_FILE_OFFSET64
extern int open (const char *__file, int __oflag, ...) __nonnull ((1));
#else
# ifdef __REDIRECT
extern int __REDIRECT (open, (const char *__file, int __oflag, ...), open64)
__nonnull ((1));
# else
# define open open64
# endif
#endif
#ifdef __USE_LARGEFILE64
extern int open64 (const char *__file, int __oflag, ...) __nonnull ((1));
#endif
#ifdef __USE_ATFILE
/* Similar to `open' but a relative path name is interpreted relative to
the directory for which FD is a descriptor.
NOTE: some other `openat' implementation support additional functionality
through this interface, especially using the O_XATTR flag. This is not
yet supported here.
This function is a cancellation point and therefore not marked with
__THROW. */
# ifndef __USE_FILE_OFFSET64
extern int openat (int __fd, const char *__file, int __oflag, ...)
__nonnull ((2));
# else
# ifdef __REDIRECT
extern int __REDIRECT (openat, (int __fd, const char *__file, int __oflag,
...), openat64) __nonnull ((2));
# else
# define openat openat64
# endif
# endif
# ifdef __USE_LARGEFILE64
extern int openat64 (int __fd, const char *__file, int __oflag, ...)
__nonnull ((2));
# endif
#endif
/* Create and open FILE, with mode MODE. This takes an `int' MODE
argument because that is what `mode_t' will be widened to.
This function is a cancellation point and therefore not marked with
__THROW. */
#ifndef __USE_FILE_OFFSET64
extern int creat (const char *__file, mode_t __mode) __nonnull ((1));
#else
# ifdef __REDIRECT
extern int __REDIRECT (creat, (const char *__file, mode_t __mode),
creat64) __nonnull ((1));
# else
# define creat creat64
# endif
#endif
#ifdef __USE_LARGEFILE64
extern int creat64 (const char *__file, mode_t __mode) __nonnull ((1));
#endif
#if !defined F_LOCK && (defined __USE_MISC || (defined __USE_XOPEN_EXTENDED \
&& !defined __USE_POSIX))
/* NOTE: These declarations also appear in <unistd.h>; be sure to keep both
files consistent. Some systems have them there and some here, and some
software depends on the macros being defined without including both. */
/* `lockf' is a simpler interface to the locking facilities of `fcntl'.
LEN is always relative to the current file position.
The CMD argument is one of the following. */
# define F_ULOCK 0 /* Unlock a previously locked region. */
# define F_LOCK 1 /* Lock a region for exclusive use. */
# define F_TLOCK 2 /* Test and lock a region for exclusive use. */
# define F_TEST 3 /* Test a region for other processes locks. */
# ifndef __USE_FILE_OFFSET64
extern int lockf (int __fd, int __cmd, off_t __len);
# else
# ifdef __REDIRECT
extern int __REDIRECT (lockf, (int __fd, int __cmd, __off64_t __len), lockf64);
# else
# define lockf lockf64
# endif
# endif
# ifdef __USE_LARGEFILE64
extern int lockf64 (int __fd, int __cmd, off64_t __len);
# endif
#endif
#ifdef __USE_XOPEN2K
/* Advice the system about the expected behaviour of the application with
respect to the file associated with FD. */
# ifndef __USE_FILE_OFFSET64
extern int posix_fadvise (int __fd, off_t __offset, off_t __len,
int __advise) __THROW;
# else
# ifdef __REDIRECT_NTH
extern int __REDIRECT_NTH (posix_fadvise, (int __fd, __off64_t __offset,
__off64_t __len, int __advise),
posix_fadvise64);
# else
# define posix_fadvise posix_fadvise64
# endif
# endif
# ifdef __USE_LARGEFILE64
extern int posix_fadvise64 (int __fd, off64_t __offset, off64_t __len,
int __advise) __THROW;
# endif
/* Reserve storage for the data of the file associated with FD.
This function is a possible cancellation point and therefore not
marked with __THROW. */
# ifndef __USE_FILE_OFFSET64
extern int posix_fallocate (int __fd, off_t __offset, off_t __len);
# else
# ifdef __REDIRECT
extern int __REDIRECT (posix_fallocate, (int __fd, __off64_t __offset,
__off64_t __len),
posix_fallocate64);
# else
# define posix_fallocate posix_fallocate64
# endif
# endif
# ifdef __USE_LARGEFILE64
extern int posix_fallocate64 (int __fd, off64_t __offset, off64_t __len);
# endif
#endif
/* Define some inlines helping to catch common problems. */
#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function \
&& defined __va_arg_pack_len
# include <bits/fcntl2.h>
#endif
__END_DECLS
#endif /* fcntl.h */
termio.h 0000644 00000000326 15201526705 0006220 0 ustar 00 /* Compatible <termio.h> for old `struct termio' ioctl interface.
This is obsolete; use the POSIX.1 `struct termios' interface
defined in <termios.h> instead. */
#include <termios.h>
#include <sys/ioctl.h>
utmp.h 0000644 00000006226 15201526705 0005713 0 ustar 00 /* Copyright (C) 1993-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef _UTMP_H
#define _UTMP_H 1
#include <features.h>
#include <sys/types.h>
__BEGIN_DECLS
/* Get system dependent values and data structures. */
#include <bits/utmp.h>
/* Compatibility names for the strings of the canonical file names. */
#define UTMP_FILE _PATH_UTMP
#define UTMP_FILENAME _PATH_UTMP
#define WTMP_FILE _PATH_WTMP
#define WTMP_FILENAME _PATH_WTMP
/* Make FD be the controlling terminal, stdin, stdout, and stderr;
then close FD. Returns 0 on success, nonzero on error. */
extern int login_tty (int __fd) __THROW;
/* Write the given entry into utmp and wtmp. */
extern void login (const struct utmp *__entry) __THROW;
/* Write the utmp entry to say the user on UT_LINE has logged out. */
extern int logout (const char *__ut_line) __THROW;
/* Append to wtmp an entry for the current time and the given info. */
extern void logwtmp (const char *__ut_line, const char *__ut_name,
const char *__ut_host) __THROW;
/* Append entry UTMP to the wtmp-like file WTMP_FILE. */
extern void updwtmp (const char *__wtmp_file, const struct utmp *__utmp)
__THROW;
/* Change name of the utmp file to be examined. */
extern int utmpname (const char *__file) __THROW;
/* Read next entry from a utmp-like file. */
extern struct utmp *getutent (void) __THROW;
/* Reset the input stream to the beginning of the file. */
extern void setutent (void) __THROW;
/* Close the current open file. */
extern void endutent (void) __THROW;
/* Search forward from the current point in the utmp file until the
next entry with a ut_type matching ID->ut_type. */
extern struct utmp *getutid (const struct utmp *__id) __THROW;
/* Search forward from the current point in the utmp file until the
next entry with a ut_line matching LINE->ut_line. */
extern struct utmp *getutline (const struct utmp *__line) __THROW;
/* Write out entry pointed to by UTMP_PTR into the utmp file. */
extern struct utmp *pututline (const struct utmp *__utmp_ptr) __THROW;
#ifdef __USE_MISC
/* Reentrant versions of the file for handling utmp files. */
extern int getutent_r (struct utmp *__buffer, struct utmp **__result) __THROW;
extern int getutid_r (const struct utmp *__id, struct utmp *__buffer,
struct utmp **__result) __THROW;
extern int getutline_r (const struct utmp *__line,
struct utmp *__buffer, struct utmp **__result) __THROW;
#endif /* Use misc. */
__END_DECLS
#endif /* utmp.h */
pcrecpp.h 0000644 00000063641 15201526705 0006366 0 ustar 00 // Copyright (c) 2005, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: Sanjay Ghemawat
// Support for PCRE_XXX modifiers added by Giuseppe Maxia, July 2005
#ifndef _PCRECPP_H
#define _PCRECPP_H
// C++ interface to the pcre regular-expression library. RE supports
// Perl-style regular expressions (with extensions like \d, \w, \s,
// ...).
//
// -----------------------------------------------------------------------
// REGEXP SYNTAX:
//
// This module is part of the pcre library and hence supports its syntax
// for regular expressions.
//
// The syntax is pretty similar to Perl's. For those not familiar
// with Perl's regular expressions, here are some examples of the most
// commonly used extensions:
//
// "hello (\\w+) world" -- \w matches a "word" character
// "version (\\d+)" -- \d matches a digit
// "hello\\s+world" -- \s matches any whitespace character
// "\\b(\\w+)\\b" -- \b matches empty string at a word boundary
// "(?i)hello" -- (?i) turns on case-insensitive matching
// "/\\*(.*?)\\*/" -- .*? matches . minimum no. of times possible
//
// -----------------------------------------------------------------------
// MATCHING INTERFACE:
//
// The "FullMatch" operation checks that supplied text matches a
// supplied pattern exactly.
//
// Example: successful match
// pcrecpp::RE re("h.*o");
// re.FullMatch("hello");
//
// Example: unsuccessful match (requires full match):
// pcrecpp::RE re("e");
// !re.FullMatch("hello");
//
// Example: creating a temporary RE object:
// pcrecpp::RE("h.*o").FullMatch("hello");
//
// You can pass in a "const char*" or a "string" for "text". The
// examples below tend to use a const char*.
//
// You can, as in the different examples above, store the RE object
// explicitly in a variable or use a temporary RE object. The
// examples below use one mode or the other arbitrarily. Either
// could correctly be used for any of these examples.
//
// -----------------------------------------------------------------------
// MATCHING WITH SUB-STRING EXTRACTION:
//
// You can supply extra pointer arguments to extract matched subpieces.
//
// Example: extracts "ruby" into "s" and 1234 into "i"
// int i;
// string s;
// pcrecpp::RE re("(\\w+):(\\d+)");
// re.FullMatch("ruby:1234", &s, &i);
//
// Example: does not try to extract any extra sub-patterns
// re.FullMatch("ruby:1234", &s);
//
// Example: does not try to extract into NULL
// re.FullMatch("ruby:1234", NULL, &i);
//
// Example: integer overflow causes failure
// !re.FullMatch("ruby:1234567891234", NULL, &i);
//
// Example: fails because there aren't enough sub-patterns:
// !pcrecpp::RE("\\w+:\\d+").FullMatch("ruby:1234", &s);
//
// Example: fails because string cannot be stored in integer
// !pcrecpp::RE("(.*)").FullMatch("ruby", &i);
//
// The provided pointer arguments can be pointers to any scalar numeric
// type, or one of
// string (matched piece is copied to string)
// StringPiece (StringPiece is mutated to point to matched piece)
// T (where "bool T::ParseFrom(const char*, int)" exists)
// NULL (the corresponding matched sub-pattern is not copied)
//
// CAVEAT: An optional sub-pattern that does not exist in the matched
// string is assigned the empty string. Therefore, the following will
// return false (because the empty string is not a valid number):
// int number;
// pcrecpp::RE::FullMatch("abc", "[a-z]+(\\d+)?", &number);
//
// -----------------------------------------------------------------------
// DO_MATCH
//
// The matching interface supports at most 16 arguments per call.
// If you need more, consider using the more general interface
// pcrecpp::RE::DoMatch(). See pcrecpp.h for the signature for DoMatch.
//
// -----------------------------------------------------------------------
// PARTIAL MATCHES
//
// You can use the "PartialMatch" operation when you want the pattern
// to match any substring of the text.
//
// Example: simple search for a string:
// pcrecpp::RE("ell").PartialMatch("hello");
//
// Example: find first number in a string:
// int number;
// pcrecpp::RE re("(\\d+)");
// re.PartialMatch("x*100 + 20", &number);
// assert(number == 100);
//
// -----------------------------------------------------------------------
// UTF-8 AND THE MATCHING INTERFACE:
//
// By default, pattern and text are plain text, one byte per character.
// The UTF8 flag, passed to the constructor, causes both pattern
// and string to be treated as UTF-8 text, still a byte stream but
// potentially multiple bytes per character. In practice, the text
// is likelier to be UTF-8 than the pattern, but the match returned
// may depend on the UTF8 flag, so always use it when matching
// UTF8 text. E.g., "." will match one byte normally but with UTF8
// set may match up to three bytes of a multi-byte character.
//
// Example:
// pcrecpp::RE_Options options;
// options.set_utf8();
// pcrecpp::RE re(utf8_pattern, options);
// re.FullMatch(utf8_string);
//
// Example: using the convenience function UTF8():
// pcrecpp::RE re(utf8_pattern, pcrecpp::UTF8());
// re.FullMatch(utf8_string);
//
// NOTE: The UTF8 option is ignored if pcre was not configured with the
// --enable-utf8 flag.
//
// -----------------------------------------------------------------------
// PASSING MODIFIERS TO THE REGULAR EXPRESSION ENGINE
//
// PCRE defines some modifiers to change the behavior of the regular
// expression engine.
// The C++ wrapper defines an auxiliary class, RE_Options, as a vehicle
// to pass such modifiers to a RE class.
//
// Currently, the following modifiers are supported
//
// modifier description Perl corresponding
//
// PCRE_CASELESS case insensitive match /i
// PCRE_MULTILINE multiple lines match /m
// PCRE_DOTALL dot matches newlines /s
// PCRE_DOLLAR_ENDONLY $ matches only at end N/A
// PCRE_EXTRA strict escape parsing N/A
// PCRE_EXTENDED ignore whitespaces /x
// PCRE_UTF8 handles UTF8 chars built-in
// PCRE_UNGREEDY reverses * and *? N/A
// PCRE_NO_AUTO_CAPTURE disables matching parens N/A (*)
//
// (For a full account on how each modifier works, please check the
// PCRE API reference manual).
//
// (*) Both Perl and PCRE allow non matching parentheses by means of the
// "?:" modifier within the pattern itself. e.g. (?:ab|cd) does not
// capture, while (ab|cd) does.
//
// For each modifier, there are two member functions whose name is made
// out of the modifier in lowercase, without the "PCRE_" prefix. For
// instance, PCRE_CASELESS is handled by
// bool caseless(),
// which returns true if the modifier is set, and
// RE_Options & set_caseless(bool),
// which sets or unsets the modifier.
//
// Moreover, PCRE_EXTRA_MATCH_LIMIT can be accessed through the
// set_match_limit() and match_limit() member functions.
// Setting match_limit to a non-zero value will limit the executation of
// pcre to keep it from doing bad things like blowing the stack or taking
// an eternity to return a result. A value of 5000 is good enough to stop
// stack blowup in a 2MB thread stack. Setting match_limit to zero will
// disable match limiting. Alternately, you can set match_limit_recursion()
// which uses PCRE_EXTRA_MATCH_LIMIT_RECURSION to limit how much pcre
// recurses. match_limit() caps the number of matches pcre does;
// match_limit_recrusion() caps the depth of recursion.
//
// Normally, to pass one or more modifiers to a RE class, you declare
// a RE_Options object, set the appropriate options, and pass this
// object to a RE constructor. Example:
//
// RE_options opt;
// opt.set_caseless(true);
//
// if (RE("HELLO", opt).PartialMatch("hello world")) ...
//
// RE_options has two constructors. The default constructor takes no
// arguments and creates a set of flags that are off by default.
//
// The optional parameter 'option_flags' is to facilitate transfer
// of legacy code from C programs. This lets you do
// RE(pattern, RE_Options(PCRE_CASELESS|PCRE_MULTILINE)).PartialMatch(str);
//
// But new code is better off doing
// RE(pattern,
// RE_Options().set_caseless(true).set_multiline(true)).PartialMatch(str);
// (See below)
//
// If you are going to pass one of the most used modifiers, there are some
// convenience functions that return a RE_Options class with the
// appropriate modifier already set:
// CASELESS(), UTF8(), MULTILINE(), DOTALL(), EXTENDED()
//
// If you need to set several options at once, and you don't want to go
// through the pains of declaring a RE_Options object and setting several
// options, there is a parallel method that give you such ability on the
// fly. You can concatenate several set_xxxxx member functions, since each
// of them returns a reference to its class object. e.g.: to pass
// PCRE_CASELESS, PCRE_EXTENDED, and PCRE_MULTILINE to a RE with one
// statement, you may write
//
// RE(" ^ xyz \\s+ .* blah$", RE_Options()
// .set_caseless(true)
// .set_extended(true)
// .set_multiline(true)).PartialMatch(sometext);
//
// -----------------------------------------------------------------------
// SCANNING TEXT INCREMENTALLY
//
// The "Consume" operation may be useful if you want to repeatedly
// match regular expressions at the front of a string and skip over
// them as they match. This requires use of the "StringPiece" type,
// which represents a sub-range of a real string. Like RE, StringPiece
// is defined in the pcrecpp namespace.
//
// Example: read lines of the form "var = value" from a string.
// string contents = ...; // Fill string somehow
// pcrecpp::StringPiece input(contents); // Wrap in a StringPiece
//
// string var;
// int value;
// pcrecpp::RE re("(\\w+) = (\\d+)\n");
// while (re.Consume(&input, &var, &value)) {
// ...;
// }
//
// Each successful call to "Consume" will set "var/value", and also
// advance "input" so it points past the matched text.
//
// The "FindAndConsume" operation is similar to "Consume" but does not
// anchor your match at the beginning of the string. For example, you
// could extract all words from a string by repeatedly calling
// pcrecpp::RE("(\\w+)").FindAndConsume(&input, &word)
//
// -----------------------------------------------------------------------
// PARSING HEX/OCTAL/C-RADIX NUMBERS
//
// By default, if you pass a pointer to a numeric value, the
// corresponding text is interpreted as a base-10 number. You can
// instead wrap the pointer with a call to one of the operators Hex(),
// Octal(), or CRadix() to interpret the text in another base. The
// CRadix operator interprets C-style "0" (base-8) and "0x" (base-16)
// prefixes, but defaults to base-10.
//
// Example:
// int a, b, c, d;
// pcrecpp::RE re("(.*) (.*) (.*) (.*)");
// re.FullMatch("100 40 0100 0x40",
// pcrecpp::Octal(&a), pcrecpp::Hex(&b),
// pcrecpp::CRadix(&c), pcrecpp::CRadix(&d));
// will leave 64 in a, b, c, and d.
//
// -----------------------------------------------------------------------
// REPLACING PARTS OF STRINGS
//
// You can replace the first match of "pattern" in "str" with
// "rewrite". Within "rewrite", backslash-escaped digits (\1 to \9)
// can be used to insert text matching corresponding parenthesized
// group from the pattern. \0 in "rewrite" refers to the entire
// matching text. E.g.,
//
// string s = "yabba dabba doo";
// pcrecpp::RE("b+").Replace("d", &s);
//
// will leave "s" containing "yada dabba doo". The result is true if
// the pattern matches and a replacement occurs, or false otherwise.
//
// GlobalReplace() is like Replace(), except that it replaces all
// occurrences of the pattern in the string with the rewrite.
// Replacements are not subject to re-matching. E.g.,
//
// string s = "yabba dabba doo";
// pcrecpp::RE("b+").GlobalReplace("d", &s);
//
// will leave "s" containing "yada dada doo". It returns the number
// of replacements made.
//
// Extract() is like Replace(), except that if the pattern matches,
// "rewrite" is copied into "out" (an additional argument) with
// substitutions. The non-matching portions of "text" are ignored.
// Returns true iff a match occurred and the extraction happened
// successfully. If no match occurs, the string is left unaffected.
#include <string>
#include <pcre.h>
#include <pcrecpparg.h> // defines the Arg class
// This isn't technically needed here, but we include it
// anyway so folks who include pcrecpp.h don't have to.
#include <pcre_stringpiece.h>
namespace pcrecpp {
#define PCRE_SET_OR_CLEAR(b, o) \
if (b) all_options_ |= (o); else all_options_ &= ~(o); \
return *this
#define PCRE_IS_SET(o) \
(all_options_ & o) == o
/***** Compiling regular expressions: the RE class *****/
// RE_Options allow you to set options to be passed along to pcre,
// along with other options we put on top of pcre.
// Only 9 modifiers, plus match_limit and match_limit_recursion,
// are supported now.
class PCRECPP_EXP_DEFN RE_Options {
public:
// constructor
RE_Options() : match_limit_(0), match_limit_recursion_(0), all_options_(0) {}
// alternative constructor.
// To facilitate transfer of legacy code from C programs
//
// This lets you do
// RE(pattern, RE_Options(PCRE_CASELESS|PCRE_MULTILINE)).PartialMatch(str);
// But new code is better off doing
// RE(pattern,
// RE_Options().set_caseless(true).set_multiline(true)).PartialMatch(str);
RE_Options(int option_flags) : match_limit_(0), match_limit_recursion_(0),
all_options_(option_flags) {}
// we're fine with the default destructor, copy constructor, etc.
// accessors and mutators
int match_limit() const { return match_limit_; };
RE_Options &set_match_limit(int limit) {
match_limit_ = limit;
return *this;
}
int match_limit_recursion() const { return match_limit_recursion_; };
RE_Options &set_match_limit_recursion(int limit) {
match_limit_recursion_ = limit;
return *this;
}
bool caseless() const {
return PCRE_IS_SET(PCRE_CASELESS);
}
RE_Options &set_caseless(bool x) {
PCRE_SET_OR_CLEAR(x, PCRE_CASELESS);
}
bool multiline() const {
return PCRE_IS_SET(PCRE_MULTILINE);
}
RE_Options &set_multiline(bool x) {
PCRE_SET_OR_CLEAR(x, PCRE_MULTILINE);
}
bool dotall() const {
return PCRE_IS_SET(PCRE_DOTALL);
}
RE_Options &set_dotall(bool x) {
PCRE_SET_OR_CLEAR(x, PCRE_DOTALL);
}
bool extended() const {
return PCRE_IS_SET(PCRE_EXTENDED);
}
RE_Options &set_extended(bool x) {
PCRE_SET_OR_CLEAR(x, PCRE_EXTENDED);
}
bool dollar_endonly() const {
return PCRE_IS_SET(PCRE_DOLLAR_ENDONLY);
}
RE_Options &set_dollar_endonly(bool x) {
PCRE_SET_OR_CLEAR(x, PCRE_DOLLAR_ENDONLY);
}
bool extra() const {
return PCRE_IS_SET(PCRE_EXTRA);
}
RE_Options &set_extra(bool x) {
PCRE_SET_OR_CLEAR(x, PCRE_EXTRA);
}
bool ungreedy() const {
return PCRE_IS_SET(PCRE_UNGREEDY);
}
RE_Options &set_ungreedy(bool x) {
PCRE_SET_OR_CLEAR(x, PCRE_UNGREEDY);
}
bool utf8() const {
return PCRE_IS_SET(PCRE_UTF8);
}
RE_Options &set_utf8(bool x) {
PCRE_SET_OR_CLEAR(x, PCRE_UTF8);
}
bool no_auto_capture() const {
return PCRE_IS_SET(PCRE_NO_AUTO_CAPTURE);
}
RE_Options &set_no_auto_capture(bool x) {
PCRE_SET_OR_CLEAR(x, PCRE_NO_AUTO_CAPTURE);
}
RE_Options &set_all_options(int opt) {
all_options_ = opt;
return *this;
}
int all_options() const {
return all_options_ ;
}
// TODO: add other pcre flags
private:
int match_limit_;
int match_limit_recursion_;
int all_options_;
};
// These functions return some common RE_Options
static inline RE_Options UTF8() {
return RE_Options().set_utf8(true);
}
static inline RE_Options CASELESS() {
return RE_Options().set_caseless(true);
}
static inline RE_Options MULTILINE() {
return RE_Options().set_multiline(true);
}
static inline RE_Options DOTALL() {
return RE_Options().set_dotall(true);
}
static inline RE_Options EXTENDED() {
return RE_Options().set_extended(true);
}
// Interface for regular expression matching. Also corresponds to a
// pre-compiled regular expression. An "RE" object is safe for
// concurrent use by multiple threads.
class PCRECPP_EXP_DEFN RE {
public:
// We provide implicit conversions from strings so that users can
// pass in a string or a "const char*" wherever an "RE" is expected.
RE(const string& pat) { Init(pat, NULL); }
RE(const string& pat, const RE_Options& option) { Init(pat, &option); }
RE(const char* pat) { Init(pat, NULL); }
RE(const char* pat, const RE_Options& option) { Init(pat, &option); }
RE(const unsigned char* pat) {
Init(reinterpret_cast<const char*>(pat), NULL);
}
RE(const unsigned char* pat, const RE_Options& option) {
Init(reinterpret_cast<const char*>(pat), &option);
}
// Copy constructor & assignment - note that these are expensive
// because they recompile the expression.
RE(const RE& re) { Init(re.pattern_, &re.options_); }
const RE& operator=(const RE& re) {
if (this != &re) {
Cleanup();
// This is the code that originally came from Google
// Init(re.pattern_.c_str(), &re.options_);
// This is the replacement from Ari Pollak
Init(re.pattern_, &re.options_);
}
return *this;
}
~RE();
// The string specification for this RE. E.g.
// RE re("ab*c?d+");
// re.pattern(); // "ab*c?d+"
const string& pattern() const { return pattern_; }
// If RE could not be created properly, returns an error string.
// Else returns the empty string.
const string& error() const { return *error_; }
/***** The useful part: the matching interface *****/
// This is provided so one can do pattern.ReplaceAll() just as
// easily as ReplaceAll(pattern-text, ....)
bool FullMatch(const StringPiece& text,
const Arg& ptr1 = no_arg,
const Arg& ptr2 = no_arg,
const Arg& ptr3 = no_arg,
const Arg& ptr4 = no_arg,
const Arg& ptr5 = no_arg,
const Arg& ptr6 = no_arg,
const Arg& ptr7 = no_arg,
const Arg& ptr8 = no_arg,
const Arg& ptr9 = no_arg,
const Arg& ptr10 = no_arg,
const Arg& ptr11 = no_arg,
const Arg& ptr12 = no_arg,
const Arg& ptr13 = no_arg,
const Arg& ptr14 = no_arg,
const Arg& ptr15 = no_arg,
const Arg& ptr16 = no_arg) const;
bool PartialMatch(const StringPiece& text,
const Arg& ptr1 = no_arg,
const Arg& ptr2 = no_arg,
const Arg& ptr3 = no_arg,
const Arg& ptr4 = no_arg,
const Arg& ptr5 = no_arg,
const Arg& ptr6 = no_arg,
const Arg& ptr7 = no_arg,
const Arg& ptr8 = no_arg,
const Arg& ptr9 = no_arg,
const Arg& ptr10 = no_arg,
const Arg& ptr11 = no_arg,
const Arg& ptr12 = no_arg,
const Arg& ptr13 = no_arg,
const Arg& ptr14 = no_arg,
const Arg& ptr15 = no_arg,
const Arg& ptr16 = no_arg) const;
bool Consume(StringPiece* input,
const Arg& ptr1 = no_arg,
const Arg& ptr2 = no_arg,
const Arg& ptr3 = no_arg,
const Arg& ptr4 = no_arg,
const Arg& ptr5 = no_arg,
const Arg& ptr6 = no_arg,
const Arg& ptr7 = no_arg,
const Arg& ptr8 = no_arg,
const Arg& ptr9 = no_arg,
const Arg& ptr10 = no_arg,
const Arg& ptr11 = no_arg,
const Arg& ptr12 = no_arg,
const Arg& ptr13 = no_arg,
const Arg& ptr14 = no_arg,
const Arg& ptr15 = no_arg,
const Arg& ptr16 = no_arg) const;
bool FindAndConsume(StringPiece* input,
const Arg& ptr1 = no_arg,
const Arg& ptr2 = no_arg,
const Arg& ptr3 = no_arg,
const Arg& ptr4 = no_arg,
const Arg& ptr5 = no_arg,
const Arg& ptr6 = no_arg,
const Arg& ptr7 = no_arg,
const Arg& ptr8 = no_arg,
const Arg& ptr9 = no_arg,
const Arg& ptr10 = no_arg,
const Arg& ptr11 = no_arg,
const Arg& ptr12 = no_arg,
const Arg& ptr13 = no_arg,
const Arg& ptr14 = no_arg,
const Arg& ptr15 = no_arg,
const Arg& ptr16 = no_arg) const;
bool Replace(const StringPiece& rewrite,
string *str) const;
int GlobalReplace(const StringPiece& rewrite,
string *str) const;
bool Extract(const StringPiece &rewrite,
const StringPiece &text,
string *out) const;
// Escapes all potentially meaningful regexp characters in
// 'unquoted'. The returned string, used as a regular expression,
// will exactly match the original string. For example,
// 1.5-2.0?
// may become:
// 1\.5\-2\.0\?
// Note QuoteMeta behaves the same as perl's QuoteMeta function,
// *except* that it escapes the NUL character (\0) as backslash + 0,
// rather than backslash + NUL.
static string QuoteMeta(const StringPiece& unquoted);
/***** Generic matching interface *****/
// Type of match (TODO: Should be restructured as part of RE_Options)
enum Anchor {
UNANCHORED, // No anchoring
ANCHOR_START, // Anchor at start only
ANCHOR_BOTH // Anchor at start and end
};
// General matching routine. Stores the length of the match in
// "*consumed" if successful.
bool DoMatch(const StringPiece& text,
Anchor anchor,
int* consumed,
const Arg* const* args, int n) const;
// Return the number of capturing subpatterns, or -1 if the
// regexp wasn't valid on construction.
int NumberOfCapturingGroups() const;
// The default value for an argument, to indicate the end of the argument
// list. This must be used only in optional argument defaults. It should NOT
// be passed explicitly. Some people have tried to use it like this:
//
// FullMatch(x, y, &z, no_arg, &w);
//
// This is a mistake, and will not work.
static Arg no_arg;
private:
void Init(const string& pattern, const RE_Options* options);
void Cleanup();
// Match against "text", filling in "vec" (up to "vecsize" * 2/3) with
// pairs of integers for the beginning and end positions of matched
// text. The first pair corresponds to the entire matched text;
// subsequent pairs correspond, in order, to parentheses-captured
// matches. Returns the number of pairs (one more than the number of
// the last subpattern with a match) if matching was successful
// and zero if the match failed.
// I.e. for RE("(foo)|(bar)|(baz)") it will return 2, 3, and 4 when matching
// against "foo", "bar", and "baz" respectively.
// When matching RE("(foo)|hello") against "hello", it will return 1.
// But the values for all subpattern are filled in into "vec".
int TryMatch(const StringPiece& text,
int startpos,
Anchor anchor,
bool empty_ok,
int *vec,
int vecsize) const;
// Append the "rewrite" string, with backslash subsitutions from "text"
// and "vec", to string "out".
bool Rewrite(string *out,
const StringPiece& rewrite,
const StringPiece& text,
int *vec,
int veclen) const;
// internal implementation for DoMatch
bool DoMatchImpl(const StringPiece& text,
Anchor anchor,
int* consumed,
const Arg* const args[],
int n,
int* vec,
int vecsize) const;
// Compile the regexp for the specified anchoring mode
pcre* Compile(Anchor anchor);
string pattern_;
RE_Options options_;
pcre* re_full_; // For full matches
pcre* re_partial_; // For partial matches
const string* error_; // Error indicator (or points to empty string)
};
} // namespace pcrecpp
#endif /* _PCRECPP_H */
fpu_control.h 0000644 00000006777 15201526705 0007273 0 ustar 00 /* FPU control word bits. x86 version.
Copyright (C) 1993-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Olaf Flebbe.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef _FPU_CONTROL_H
#define _FPU_CONTROL_H 1
/* Note that this file sets on x86-64 only the x87 FPU, it does not
touch the SSE unit. */
/* Here is the dirty part. Set up your 387 through the control word
* (cw) register.
*
* 15-13 12 11-10 9-8 7-6 5 4 3 2 1 0
* | reserved | IC | RC | PC | reserved | PM | UM | OM | ZM | DM | IM
*
* IM: Invalid operation mask
* DM: Denormalized operand mask
* ZM: Zero-divide mask
* OM: Overflow mask
* UM: Underflow mask
* PM: Precision (inexact result) mask
*
* Mask bit is 1 means no interrupt.
*
* PC: Precision control
* 11 - round to extended precision
* 10 - round to double precision
* 00 - round to single precision
*
* RC: Rounding control
* 00 - rounding to nearest
* 01 - rounding down (toward - infinity)
* 10 - rounding up (toward + infinity)
* 11 - rounding toward zero
*
* IC: Infinity control
* That is for 8087 and 80287 only.
*
* The hardware default is 0x037f which we use.
*/
#include <features.h>
/* masking of interrupts */
#define _FPU_MASK_IM 0x01
#define _FPU_MASK_DM 0x02
#define _FPU_MASK_ZM 0x04
#define _FPU_MASK_OM 0x08
#define _FPU_MASK_UM 0x10
#define _FPU_MASK_PM 0x20
/* precision control */
#define _FPU_EXTENDED 0x300 /* libm requires double extended precision. */
#define _FPU_DOUBLE 0x200
#define _FPU_SINGLE 0x0
/* rounding control */
#define _FPU_RC_NEAREST 0x0 /* RECOMMENDED */
#define _FPU_RC_DOWN 0x400
#define _FPU_RC_UP 0x800
#define _FPU_RC_ZERO 0xC00
#define _FPU_RESERVED 0xF0C0 /* Reserved bits in cw */
/* The fdlibm code requires strict IEEE double precision arithmetic,
and no interrupts for exceptions, rounding to nearest. */
#define _FPU_DEFAULT 0x037f
/* IEEE: same as above. */
#define _FPU_IEEE 0x037f
/* Type of the control word. */
typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
/* Macros for accessing the hardware control word. "*&" is used to
work around a bug in older versions of GCC. __volatile__ is used
to support combination of writing the control register and reading
it back. Without __volatile__, the old value may be used for reading
back under compiler optimization.
Note that the use of these macros is not sufficient anymore with
recent hardware nor on x86-64. Some floating point operations are
executed in the SSE/SSE2 engines which have their own control and
status register. */
#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
/* Default control word set at startup. */
extern fpu_control_t __fpu_control;
#endif /* fpu_control.h */
obstack.h 0000644 00000051472 15201526705 0006357 0 ustar 00 /* obstack.h - object stack macros
Copyright (C) 1988-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
/* Summary:
All the apparent functions defined here are macros. The idea
is that you would use these pre-tested macros to solve a
very specific set of problems, and they would run fast.
Caution: no side-effects in arguments please!! They may be
evaluated MANY times!!
These macros operate a stack of objects. Each object starts life
small, and may grow to maturity. (Consider building a word syllable
by syllable.) An object can move while it is growing. Once it has
been "finished" it never changes address again. So the "top of the
stack" is typically an immature growing object, while the rest of the
stack is of mature, fixed size and fixed address objects.
These routines grab large chunks of memory, using a function you
supply, called 'obstack_chunk_alloc'. On occasion, they free chunks,
by calling 'obstack_chunk_free'. You must define them and declare
them before using any obstack macros.
Each independent stack is represented by a 'struct obstack'.
Each of the obstack macros expects a pointer to such a structure
as the first argument.
One motivation for this package is the problem of growing char strings
in symbol tables. Unless you are "fascist pig with a read-only mind"
--Gosper's immortal quote from HAKMEM item 154, out of context--you
would not like to put any arbitrary upper limit on the length of your
symbols.
In practice this often means you will build many short symbols and a
few long symbols. At the time you are reading a symbol you don't know
how long it is. One traditional method is to read a symbol into a
buffer, realloc()ating the buffer every time you try to read a symbol
that is longer than the buffer. This is beaut, but you still will
want to copy the symbol from the buffer to a more permanent
symbol-table entry say about half the time.
With obstacks, you can work differently. Use one obstack for all symbol
names. As you read a symbol, grow the name in the obstack gradually.
When the name is complete, finalize it. Then, if the symbol exists already,
free the newly read name.
The way we do this is to take a large chunk, allocating memory from
low addresses. When you want to build a symbol in the chunk you just
add chars above the current "high water mark" in the chunk. When you
have finished adding chars, because you got to the end of the symbol,
you know how long the chars are, and you can create a new object.
Mostly the chars will not burst over the highest address of the chunk,
because you would typically expect a chunk to be (say) 100 times as
long as an average object.
In case that isn't clear, when we have enough chars to make up
the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed)
so we just point to it where it lies. No moving of chars is
needed and this is the second win: potentially long strings need
never be explicitly shuffled. Once an object is formed, it does not
change its address during its lifetime.
When the chars burst over a chunk boundary, we allocate a larger
chunk, and then copy the partly formed object from the end of the old
chunk to the beginning of the new larger chunk. We then carry on
accreting characters to the end of the object as we normally would.
A special macro is provided to add a single char at a time to a
growing object. This allows the use of register variables, which
break the ordinary 'growth' macro.
Summary:
We allocate large chunks.
We carve out one object at a time from the current chunk.
Once carved, an object never moves.
We are free to append data of any size to the currently
growing object.
Exactly one object is growing in an obstack at any one time.
You can run one obstack per control block.
You may have as many control blocks as you dare.
Because of the way we do it, you can "unwind" an obstack
back to a previous state. (You may remove objects much
as you would with a stack.)
*/
/* Don't do the contents of this file more than once. */
#ifndef _OBSTACK_H
#define _OBSTACK_H 1
/* We need the type of a pointer subtraction. If __PTRDIFF_TYPE__ is
defined, as with GNU C, use that; that way we don't pollute the
namespace with <stddef.h>'s symbols. Otherwise, include <stddef.h>
and use ptrdiff_t. */
#ifdef __PTRDIFF_TYPE__
# define PTR_INT_TYPE __PTRDIFF_TYPE__
#else
# include <stddef.h>
# define PTR_INT_TYPE ptrdiff_t
#endif
/* If B is the base of an object addressed by P, return the result of
aligning P to the next multiple of A + 1. B and P must be of type
char *. A + 1 must be a power of 2. */
#define __BPTR_ALIGN(B, P, A) ((B) + (((P) - (B) + (A)) & ~(A)))
/* Similar to _BPTR_ALIGN (B, P, A), except optimize the common case
where pointers can be converted to integers, aligned as integers,
and converted back again. If PTR_INT_TYPE is narrower than a
pointer (e.g., the AS/400), play it safe and compute the alignment
relative to B. Otherwise, use the faster strategy of computing the
alignment relative to 0. */
#define __PTR_ALIGN(B, P, A) \
__BPTR_ALIGN (sizeof (PTR_INT_TYPE) < sizeof (void *) ? (B) : (char *) 0, \
P, A)
#include <string.h>
#ifndef __attribute_pure__
# define __attribute_pure__ _GL_ATTRIBUTE_PURE
#endif
#ifdef __cplusplus
extern "C" {
#endif
struct _obstack_chunk /* Lives at front of each chunk. */
{
char *limit; /* 1 past end of this chunk */
struct _obstack_chunk *prev; /* address of prior chunk or NULL */
char contents[4]; /* objects begin here */
};
struct obstack /* control current object in current chunk */
{
long chunk_size; /* preferred size to allocate chunks in */
struct _obstack_chunk *chunk; /* address of current struct obstack_chunk */
char *object_base; /* address of object we are building */
char *next_free; /* where to add next char to current object */
char *chunk_limit; /* address of char after current chunk */
union
{
PTR_INT_TYPE tempint;
void *tempptr;
} temp; /* Temporary for some macros. */
int alignment_mask; /* Mask of alignment for each object. */
/* These prototypes vary based on 'use_extra_arg', and we use
casts to the prototypeless function type in all assignments,
but having prototypes here quiets -Wstrict-prototypes. */
struct _obstack_chunk *(*chunkfun) (void *, long);
void (*freefun) (void *, struct _obstack_chunk *);
void *extra_arg; /* first arg for chunk alloc/dealloc funcs */
unsigned use_extra_arg : 1; /* chunk alloc/dealloc funcs take extra arg */
unsigned maybe_empty_object : 1; /* There is a possibility that the current
chunk contains a zero-length object. This
prevents freeing the chunk if we allocate
a bigger chunk to replace it. */
unsigned alloc_failed : 1; /* No longer used, as we now call the failed
handler on error, but retained for binary
compatibility. */
};
/* Declare the external functions we use; they are in obstack.c. */
extern void _obstack_newchunk (struct obstack *, int);
extern int _obstack_begin (struct obstack *, int, int,
void *(*)(long), void (*)(void *));
extern int _obstack_begin_1 (struct obstack *, int, int,
void *(*)(void *, long),
void (*)(void *, void *), void *);
extern int _obstack_memory_used (struct obstack *) __attribute_pure__;
/* The default name of the function for freeing a chunk is 'obstack_free',
but gnulib users can override this by defining '__obstack_free'. */
#ifndef __obstack_free
# define __obstack_free obstack_free
#endif
extern void __obstack_free (struct obstack *, void *);
/* Error handler called when 'obstack_chunk_alloc' failed to allocate
more memory. This can be set to a user defined function which
should either abort gracefully or use longjump - but shouldn't
return. The default action is to print a message and abort. */
extern void (*obstack_alloc_failed_handler) (void);
/* Exit value used when 'print_and_abort' is used. */
extern int obstack_exit_failure;
/* Pointer to beginning of object being allocated or to be allocated next.
Note that this might not be the final address of the object
because a new chunk might be needed to hold the final size. */
#define obstack_base(h) ((void *) (h)->object_base)
/* Size for allocating ordinary chunks. */
#define obstack_chunk_size(h) ((h)->chunk_size)
/* Pointer to next byte not yet allocated in current chunk. */
#define obstack_next_free(h) ((h)->next_free)
/* Mask specifying low bits that should be clear in address of an object. */
#define obstack_alignment_mask(h) ((h)->alignment_mask)
/* To prevent prototype warnings provide complete argument list. */
#define obstack_init(h) \
_obstack_begin ((h), 0, 0, \
(void *(*)(long))obstack_chunk_alloc, \
(void (*)(void *))obstack_chunk_free)
#define obstack_begin(h, size) \
_obstack_begin ((h), (size), 0, \
(void *(*)(long))obstack_chunk_alloc, \
(void (*)(void *))obstack_chunk_free)
#define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \
_obstack_begin ((h), (size), (alignment), \
(void *(*)(long))(chunkfun), \
(void (*)(void *))(freefun))
#define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \
_obstack_begin_1 ((h), (size), (alignment), \
(void *(*)(void *, long))(chunkfun), \
(void (*)(void *, void *))(freefun), (arg))
#define obstack_chunkfun(h, newchunkfun) \
((h)->chunkfun = (struct _obstack_chunk *(*)(void *, long))(newchunkfun))
#define obstack_freefun(h, newfreefun) \
((h)->freefun = (void (*)(void *, struct _obstack_chunk *))(newfreefun))
#define obstack_1grow_fast(h, achar) (*((h)->next_free)++ = (achar))
#define obstack_blank_fast(h, n) ((h)->next_free += (n))
#define obstack_memory_used(h) _obstack_memory_used (h)
#if defined __GNUC__
# if ! (2 < __GNUC__ + (8 <= __GNUC_MINOR__))
# define __extension__
# endif
/* For GNU C, if not -traditional,
we can define these macros to compute all args only once
without using a global variable.
Also, we can avoid using the 'temp' slot, to make faster code. */
# define obstack_object_size(OBSTACK) \
__extension__ \
({ struct obstack const *__o = (OBSTACK); \
(unsigned) (__o->next_free - __o->object_base); })
# define obstack_room(OBSTACK) \
__extension__ \
({ struct obstack const *__o = (OBSTACK); \
(unsigned) (__o->chunk_limit - __o->next_free); })
# define obstack_make_room(OBSTACK, length) \
__extension__ \
({ struct obstack *__o = (OBSTACK); \
int __len = (length); \
if (__o->chunk_limit - __o->next_free < __len) \
_obstack_newchunk (__o, __len); \
(void) 0; })
# define obstack_empty_p(OBSTACK) \
__extension__ \
({ struct obstack const *__o = (OBSTACK); \
(__o->chunk->prev == 0 \
&& __o->next_free == __PTR_ALIGN ((char *) __o->chunk, \
__o->chunk->contents, \
__o->alignment_mask)); })
# define obstack_grow(OBSTACK, where, length) \
__extension__ \
({ struct obstack *__o = (OBSTACK); \
int __len = (length); \
if (__o->next_free + __len > __o->chunk_limit) \
_obstack_newchunk (__o, __len); \
memcpy (__o->next_free, where, __len); \
__o->next_free += __len; \
(void) 0; })
# define obstack_grow0(OBSTACK, where, length) \
__extension__ \
({ struct obstack *__o = (OBSTACK); \
int __len = (length); \
if (__o->next_free + __len + 1 > __o->chunk_limit) \
_obstack_newchunk (__o, __len + 1); \
memcpy (__o->next_free, where, __len); \
__o->next_free += __len; \
*(__o->next_free)++ = 0; \
(void) 0; })
# define obstack_1grow(OBSTACK, datum) \
__extension__ \
({ struct obstack *__o = (OBSTACK); \
if (__o->next_free + 1 > __o->chunk_limit) \
_obstack_newchunk (__o, 1); \
obstack_1grow_fast (__o, datum); \
(void) 0; })
/* These assume that the obstack alignment is good enough for pointers
or ints, and that the data added so far to the current object
shares that much alignment. */
# define obstack_ptr_grow(OBSTACK, datum) \
__extension__ \
({ struct obstack *__o = (OBSTACK); \
if (__o->next_free + sizeof (void *) > __o->chunk_limit) \
_obstack_newchunk (__o, sizeof (void *)); \
obstack_ptr_grow_fast (__o, datum); }) \
# define obstack_int_grow(OBSTACK, datum) \
__extension__ \
({ struct obstack *__o = (OBSTACK); \
if (__o->next_free + sizeof (int) > __o->chunk_limit) \
_obstack_newchunk (__o, sizeof (int)); \
obstack_int_grow_fast (__o, datum); })
# define obstack_ptr_grow_fast(OBSTACK, aptr) \
__extension__ \
({ struct obstack *__o1 = (OBSTACK); \
void *__p1 = __o1->next_free; \
*(const void **) __p1 = (aptr); \
__o1->next_free += sizeof (const void *); \
(void) 0; })
# define obstack_int_grow_fast(OBSTACK, aint) \
__extension__ \
({ struct obstack *__o1 = (OBSTACK); \
void *__p1 = __o1->next_free; \
*(int *) __p1 = (aint); \
__o1->next_free += sizeof (int); \
(void) 0; })
# define obstack_blank(OBSTACK, length) \
__extension__ \
({ struct obstack *__o = (OBSTACK); \
int __len = (length); \
if (__o->chunk_limit - __o->next_free < __len) \
_obstack_newchunk (__o, __len); \
obstack_blank_fast (__o, __len); \
(void) 0; })
# define obstack_alloc(OBSTACK, length) \
__extension__ \
({ struct obstack *__h = (OBSTACK); \
obstack_blank (__h, (length)); \
obstack_finish (__h); })
# define obstack_copy(OBSTACK, where, length) \
__extension__ \
({ struct obstack *__h = (OBSTACK); \
obstack_grow (__h, (where), (length)); \
obstack_finish (__h); })
# define obstack_copy0(OBSTACK, where, length) \
__extension__ \
({ struct obstack *__h = (OBSTACK); \
obstack_grow0 (__h, (where), (length)); \
obstack_finish (__h); })
/* The local variable is named __o1 to avoid a name conflict
when obstack_blank is called. */
# define obstack_finish(OBSTACK) \
__extension__ \
({ struct obstack *__o1 = (OBSTACK); \
void *__value = (void *) __o1->object_base; \
if (__o1->next_free == __value) \
__o1->maybe_empty_object = 1; \
__o1->next_free \
= __PTR_ALIGN (__o1->object_base, __o1->next_free, \
__o1->alignment_mask); \
if (__o1->next_free - (char *) __o1->chunk \
> __o1->chunk_limit - (char *) __o1->chunk) \
__o1->next_free = __o1->chunk_limit; \
__o1->object_base = __o1->next_free; \
__value; })
# define obstack_free(OBSTACK, OBJ) \
__extension__ \
({ struct obstack *__o = (OBSTACK); \
void *__obj = (OBJ); \
if (__obj > (void *) __o->chunk && __obj < (void *) __o->chunk_limit) \
__o->next_free = __o->object_base = (char *) __obj; \
else (__obstack_free) (__o, __obj); })
#else /* not __GNUC__ */
# define obstack_object_size(h) \
(unsigned) ((h)->next_free - (h)->object_base)
# define obstack_room(h) \
(unsigned) ((h)->chunk_limit - (h)->next_free)
# define obstack_empty_p(h) \
((h)->chunk->prev == 0 \
&& (h)->next_free == __PTR_ALIGN ((char *) (h)->chunk, \
(h)->chunk->contents, \
(h)->alignment_mask))
/* Note that the call to _obstack_newchunk is enclosed in (..., 0)
so that we can avoid having void expressions
in the arms of the conditional expression.
Casting the third operand to void was tried before,
but some compilers won't accept it. */
# define obstack_make_room(h, length) \
((h)->temp.tempint = (length), \
(((h)->next_free + (h)->temp.tempint > (h)->chunk_limit) \
? (_obstack_newchunk ((h), (h)->temp.tempint), 0) : 0))
# define obstack_grow(h, where, length) \
((h)->temp.tempint = (length), \
(((h)->next_free + (h)->temp.tempint > (h)->chunk_limit) \
? (_obstack_newchunk ((h), (h)->temp.tempint), 0) : 0), \
memcpy ((h)->next_free, where, (h)->temp.tempint), \
(h)->next_free += (h)->temp.tempint)
# define obstack_grow0(h, where, length) \
((h)->temp.tempint = (length), \
(((h)->next_free + (h)->temp.tempint + 1 > (h)->chunk_limit) \
? (_obstack_newchunk ((h), (h)->temp.tempint + 1), 0) : 0), \
memcpy ((h)->next_free, where, (h)->temp.tempint), \
(h)->next_free += (h)->temp.tempint, \
*((h)->next_free)++ = 0)
# define obstack_1grow(h, datum) \
((((h)->next_free + 1 > (h)->chunk_limit) \
? (_obstack_newchunk ((h), 1), 0) : 0), \
obstack_1grow_fast (h, datum))
# define obstack_ptr_grow(h, datum) \
((((h)->next_free + sizeof (char *) > (h)->chunk_limit) \
? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \
obstack_ptr_grow_fast (h, datum))
# define obstack_int_grow(h, datum) \
((((h)->next_free + sizeof (int) > (h)->chunk_limit) \
? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \
obstack_int_grow_fast (h, datum))
# define obstack_ptr_grow_fast(h, aptr) \
(((const void **) ((h)->next_free += sizeof (void *)))[-1] = (aptr))
# define obstack_int_grow_fast(h, aint) \
(((int *) ((h)->next_free += sizeof (int)))[-1] = (aint))
# define obstack_blank(h, length) \
((h)->temp.tempint = (length), \
(((h)->chunk_limit - (h)->next_free < (h)->temp.tempint) \
? (_obstack_newchunk ((h), (h)->temp.tempint), 0) : 0), \
obstack_blank_fast (h, (h)->temp.tempint))
# define obstack_alloc(h, length) \
(obstack_blank ((h), (length)), obstack_finish ((h)))
# define obstack_copy(h, where, length) \
(obstack_grow ((h), (where), (length)), obstack_finish ((h)))
# define obstack_copy0(h, where, length) \
(obstack_grow0 ((h), (where), (length)), obstack_finish ((h)))
# define obstack_finish(h) \
(((h)->next_free == (h)->object_base \
? (((h)->maybe_empty_object = 1), 0) \
: 0), \
(h)->temp.tempptr = (h)->object_base, \
(h)->next_free \
= __PTR_ALIGN ((h)->object_base, (h)->next_free, \
(h)->alignment_mask), \
(((h)->next_free - (char *) (h)->chunk \
> (h)->chunk_limit - (char *) (h)->chunk) \
? ((h)->next_free = (h)->chunk_limit) : 0), \
(h)->object_base = (h)->next_free, \
(h)->temp.tempptr)
# define obstack_free(h, obj) \
((h)->temp.tempint = (char *) (obj) - (char *) (h)->chunk, \
((((h)->temp.tempint > 0 \
&& (h)->temp.tempint < (h)->chunk_limit - (char *) (h)->chunk)) \
? (void) ((h)->next_free = (h)->object_base \
= (h)->temp.tempint + (char *) (h)->chunk) \
: (__obstack_free) (h, (h)->temp.tempint + (char *) (h)->chunk)))
#endif /* not __GNUC__ */
#ifdef __cplusplus
} /* C++ */
#endif
#endif /* obstack.h */
gdb/jit-reader.h 0000644 00000027465 15201526705 0007520 0 ustar 00 /* JIT declarations for GDB, the GNU Debugger.
Copyright (C) 2011-2018 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef GDB_JIT_READER_H
#define GDB_JIT_READER_H
#ifdef __cplusplus
extern "C" {
#endif
/* Versioning information. See gdb_reader_funcs. */
#define GDB_READER_INTERFACE_VERSION 1
/* Readers must be released under a GPL compatible license. To
declare that the reader is indeed released under a GPL compatible
license, invoke the macro GDB_DECLARE_GPL_COMPATIBLE in a source
file. */
#ifdef __cplusplus
#define GDB_DECLARE_GPL_COMPATIBLE_READER \
extern "C" { \
extern int plugin_is_GPL_compatible (void); \
extern int plugin_is_GPL_compatible (void) \
{ \
return 0; \
} \
}
#else
#define GDB_DECLARE_GPL_COMPATIBLE_READER \
extern int plugin_is_GPL_compatible (void); \
extern int plugin_is_GPL_compatible (void) \
{ \
return 0; \
}
#endif
/* Represents an address on the target system. */
typedef unsigned long long GDB_CORE_ADDR;
/* Return status codes. */
enum gdb_status {
GDB_FAIL = 0,
GDB_SUCCESS = 1
};
struct gdb_object;
struct gdb_symtab;
struct gdb_block;
struct gdb_symbol_callbacks;
/* An array of these are used to represent a map from code addresses to line
numbers in the source file. */
struct gdb_line_mapping
{
int line;
GDB_CORE_ADDR pc;
};
/* Create a new GDB code object. Each code object can have one or
more symbol tables, each representing a compiled source file. */
typedef struct gdb_object *(gdb_object_open) (struct gdb_symbol_callbacks *cb);
/* The callback used to create new symbol table. CB is the
gdb_symbol_callbacks which the structure is part of. FILE_NAME is
an (optionally NULL) file name to associate with this new symbol
table.
Returns a new instance to gdb_symtab that can later be passed to
gdb_block_new, gdb_symtab_add_line_mapping and gdb_symtab_close. */
typedef struct gdb_symtab *(gdb_symtab_open) (struct gdb_symbol_callbacks *cb,
struct gdb_object *obj,
const char *file_name);
/* Creates a new block in a given symbol table. A symbol table is a
forest of blocks, each block representing an code address range and
a corresponding (optionally NULL) NAME. In case the block
corresponds to a function, the NAME passed should be the name of
the function.
If the new block to be created is a child of (i.e. is nested in)
another block, the parent block can be passed in PARENT. SYMTAB is
the symbol table the new block is to belong in. BEGIN, END is the
code address range the block corresponds to.
Returns a new instance of gdb_block, which, as of now, has no use.
Note that the gdb_block returned must not be freed by the
caller. */
typedef struct gdb_block *(gdb_block_open) (struct gdb_symbol_callbacks *cb,
struct gdb_symtab *symtab,
struct gdb_block *parent,
GDB_CORE_ADDR begin,
GDB_CORE_ADDR end,
const char *name);
/* Adds a PC to line number mapping for the symbol table SYMTAB.
NLINES is the number of elements in LINES, each element
corresponding to one (PC, line) pair. */
typedef void (gdb_symtab_add_line_mapping) (struct gdb_symbol_callbacks *cb,
struct gdb_symtab *symtab,
int nlines,
struct gdb_line_mapping *lines);
/* Close the symtab SYMTAB. This signals to GDB that no more blocks
will be opened on this symtab. */
typedef void (gdb_symtab_close) (struct gdb_symbol_callbacks *cb,
struct gdb_symtab *symtab);
/* Closes the gdb_object OBJ and adds the emitted information into
GDB's internal structures. Once this is done, the debug
information will be picked up and used; this will usually be the
last operation in gdb_read_debug_info. */
typedef void (gdb_object_close) (struct gdb_symbol_callbacks *cb,
struct gdb_object *obj);
/* Reads LEN bytes from TARGET_MEM in the target's virtual address
space into GDB_BUF.
Returns GDB_FAIL on failure, and GDB_SUCCESS on success. */
typedef enum gdb_status (gdb_target_read) (GDB_CORE_ADDR target_mem,
void *gdb_buf, int len);
/* The list of callbacks that are passed to read. These callbacks are
to be used to construct the symbol table. The functions have been
described above. */
struct gdb_symbol_callbacks
{
gdb_object_open *object_open;
gdb_symtab_open *symtab_open;
gdb_block_open *block_open;
gdb_symtab_close *symtab_close;
gdb_object_close *object_close;
gdb_symtab_add_line_mapping *line_mapping_add;
gdb_target_read *target_read;
/* For internal use by GDB. */
void *priv_data;
};
/* Forward declaration. */
struct gdb_reg_value;
/* A function of this type is used to free a gdb_reg_value. See the
comment on `free' in struct gdb_reg_value. */
typedef void (gdb_reg_value_free) (struct gdb_reg_value *);
/* Denotes the value of a register. */
struct gdb_reg_value
{
/* The size of the register in bytes. The reader need not set this
field. This will be set for (defined) register values being read
from GDB using reg_get. */
int size;
/* Set to non-zero if the value for the register is known. The
registers for which the reader does not call reg_set are also
assumed to be undefined */
int defined;
/* Since gdb_reg_value is a variable sized structure, it will
usually be allocated on the heap. This function is expected to
contain the corresponding "free" function.
When a pointer to gdb_reg_value is being sent from GDB to the
reader (via gdb_unwind_reg_get), the reader is expected to call
this function (with the same gdb_reg_value as argument) once it
is done with the value.
When the function sends the a gdb_reg_value to GDB (via
gdb_unwind_reg_set), it is expected to set this field to point to
an appropriate cleanup routine (or to NULL if no cleanup is
required). */
gdb_reg_value_free *free;
/* The value of the register. */
unsigned char value[1];
};
/* get_frame_id in gdb_reader_funcs is to return a gdb_frame_id
corresponding to the current frame. The registers corresponding to
the current frame can be read using reg_get. Calling get_frame_id
on a particular frame should return the same gdb_frame_id
throughout its lifetime (i.e. till before it gets unwound). One
way to do this is by having the CODE_ADDRESS point to the
function's first instruction and STACK_ADDRESS point to the value
of the stack pointer when entering the function. */
struct gdb_frame_id
{
GDB_CORE_ADDR code_address;
GDB_CORE_ADDR stack_address;
};
/* Forward declaration. */
struct gdb_unwind_callbacks;
/* Returns the value of a particular register in the current frame.
The current frame is the frame that needs to be unwound into the
outer (earlier) frame.
CB is the struct gdb_unwind_callbacks * the callback belongs to.
REGNUM is the DWARF register number of the register that needs to
be unwound.
Returns the gdb_reg_value corresponding to the register requested.
In case the value of the register has been optimized away or
otherwise unavailable, the defined flag in the returned
gdb_reg_value will be zero. */
typedef struct gdb_reg_value *(gdb_unwind_reg_get)
(struct gdb_unwind_callbacks *cb, int regnum);
/* Sets the previous value of a particular register. REGNUM is the
(DWARF) register number whose value is to be set. VAL is the value
the register is to be set to.
VAL is *not* copied, so the memory allocated to it cannot be
reused. Once GDB no longer needs the value, it is deallocated
using the FREE function (see gdb_reg_value).
A register can also be "set" to an undefined value by setting the
defined in VAL to zero. */
typedef void (gdb_unwind_reg_set) (struct gdb_unwind_callbacks *cb, int regnum,
struct gdb_reg_value *val);
/* This struct is passed to unwind in gdb_reader_funcs, and is to be
used to unwind the current frame (current being the frame whose
registers can be read using reg_get) into the earlier frame. The
functions have been described above. */
struct gdb_unwind_callbacks
{
gdb_unwind_reg_get *reg_get;
gdb_unwind_reg_set *reg_set;
gdb_target_read *target_read;
/* For internal use by GDB. */
void *priv_data;
};
/* Forward declaration. */
struct gdb_reader_funcs;
/* Parse the debug info off a block of memory, pointed to by MEMORY
(already copied to GDB's address space) and MEMORY_SZ bytes long.
The implementation has to use the functions in CB to actually emit
the parsed data into GDB. SELF is the same structure returned by
gdb_init_reader.
Return GDB_FAIL on failure and GDB_SUCCESS on success. */
typedef enum gdb_status (gdb_read_debug_info) (struct gdb_reader_funcs *self,
struct gdb_symbol_callbacks *cb,
void *memory, long memory_sz);
/* Unwind the current frame, CB is the set of unwind callbacks that
are to be used to do this.
Return GDB_FAIL on failure and GDB_SUCCESS on success. */
typedef enum gdb_status (gdb_unwind_frame) (struct gdb_reader_funcs *self,
struct gdb_unwind_callbacks *cb);
/* Return the frame ID corresponding to the current frame, using C to
read the current register values. See the comment on struct
gdb_frame_id. */
typedef struct gdb_frame_id (gdb_get_frame_id) (struct gdb_reader_funcs *self,
struct gdb_unwind_callbacks *c);
/* Called when a reader is being unloaded. This function should also
free SELF, if required. */
typedef void (gdb_destroy_reader) (struct gdb_reader_funcs *self);
/* Called when the reader is loaded. Must either return a properly
populated gdb_reader_funcs or NULL. The memory allocated for the
gdb_reader_funcs is to be managed by the reader itself (i.e. if it
is allocated from the heap, it must also be freed in
gdb_destroy_reader). */
extern struct gdb_reader_funcs *gdb_init_reader (void);
/* Pointer to the functions which implement the reader's
functionality. The individual functions have been documented
above.
None of the fields are optional. */
struct gdb_reader_funcs
{
/* Must be set to GDB_READER_INTERFACE_VERSION. */
int reader_version;
/* For use by the reader. */
void *priv_data;
gdb_read_debug_info *read;
gdb_unwind_frame *unwind;
gdb_get_frame_id *get_frame_id;
gdb_destroy_reader *destroy;
};
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif
ctype.h 0000644 00000025323 15201526705 0006051 0 ustar 00 /* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
/*
* ISO C99 Standard 7.4: Character handling <ctype.h>
*/
#ifndef _CTYPE_H
#define _CTYPE_H 1
#include <features.h>
#include <bits/types.h>
__BEGIN_DECLS
#ifndef _ISbit
/* These are all the characteristics of characters.
If there get to be more than 16 distinct characteristics,
many things must be changed that use `unsigned short int's.
The characteristics are stored always in network byte order (big
endian). We define the bit value interpretations here dependent on the
machine's byte order. */
# include <endian.h>
# if __BYTE_ORDER == __BIG_ENDIAN
# define _ISbit(bit) (1 << (bit))
# else /* __BYTE_ORDER == __LITTLE_ENDIAN */
# define _ISbit(bit) ((bit) < 8 ? ((1 << (bit)) << 8) : ((1 << (bit)) >> 8))
# endif
enum
{
_ISupper = _ISbit (0), /* UPPERCASE. */
_ISlower = _ISbit (1), /* lowercase. */
_ISalpha = _ISbit (2), /* Alphabetic. */
_ISdigit = _ISbit (3), /* Numeric. */
_ISxdigit = _ISbit (4), /* Hexadecimal numeric. */
_ISspace = _ISbit (5), /* Whitespace. */
_ISprint = _ISbit (6), /* Printing. */
_ISgraph = _ISbit (7), /* Graphical. */
_ISblank = _ISbit (8), /* Blank (usually SPC and TAB). */
_IScntrl = _ISbit (9), /* Control character. */
_ISpunct = _ISbit (10), /* Punctuation. */
_ISalnum = _ISbit (11) /* Alphanumeric. */
};
#endif /* ! _ISbit */
/* These are defined in ctype-info.c.
The declarations here must match those in localeinfo.h.
In the thread-specific locale model (see `uselocale' in <locale.h>)
we cannot use global variables for these as was done in the past.
Instead, the following accessor functions return the address of
each variable, which is local to the current thread if multithreaded.
These point into arrays of 384, so they can be indexed by any `unsigned
char' value [0,255]; by EOF (-1); or by any `signed char' value
[-128,-1). ISO C requires that the ctype functions work for `unsigned
char' values and for EOF; we also support negative `signed char' values
for broken old programs. The case conversion arrays are of `int's
rather than `unsigned char's because tolower (EOF) must be EOF, which
doesn't fit into an `unsigned char'. But today more important is that
the arrays are also used for multi-byte character sets. */
extern const unsigned short int **__ctype_b_loc (void)
__THROW __attribute__ ((__const__));
extern const __int32_t **__ctype_tolower_loc (void)
__THROW __attribute__ ((__const__));
extern const __int32_t **__ctype_toupper_loc (void)
__THROW __attribute__ ((__const__));
#ifndef __cplusplus
# define __isctype(c, type) \
((*__ctype_b_loc ())[(int) (c)] & (unsigned short int) type)
#elif defined __USE_EXTERN_INLINES
# define __isctype_f(type) \
__extern_inline int \
is##type (int __c) __THROW \
{ \
return (*__ctype_b_loc ())[(int) (__c)] & (unsigned short int) _IS##type; \
}
#endif
#define __isascii(c) (((c) & ~0x7f) == 0) /* If C is a 7 bit value. */
#define __toascii(c) ((c) & 0x7f) /* Mask off high bits. */
#define __exctype(name) extern int name (int) __THROW
/* The following names are all functions:
int isCHARACTERISTIC(int c);
which return nonzero iff C has CHARACTERISTIC.
For the meaning of the characteristic names, see the `enum' above. */
__exctype (isalnum);
__exctype (isalpha);
__exctype (iscntrl);
__exctype (isdigit);
__exctype (islower);
__exctype (isgraph);
__exctype (isprint);
__exctype (ispunct);
__exctype (isspace);
__exctype (isupper);
__exctype (isxdigit);
/* Return the lowercase version of C. */
extern int tolower (int __c) __THROW;
/* Return the uppercase version of C. */
extern int toupper (int __c) __THROW;
/* ISO C99 introduced one new function. */
#ifdef __USE_ISOC99
__exctype (isblank);
#endif
#ifdef __USE_GNU
/* Test C for a set of character classes according to MASK. */
extern int isctype (int __c, int __mask) __THROW;
#endif
#if defined __USE_MISC || defined __USE_XOPEN
/* Return nonzero iff C is in the ASCII set
(i.e., is no more than 7 bits wide). */
extern int isascii (int __c) __THROW;
/* Return the part of C that is in the ASCII set
(i.e., the low-order 7 bits of C). */
extern int toascii (int __c) __THROW;
/* These are the same as `toupper' and `tolower' except that they do not
check the argument for being in the range of a `char'. */
__exctype (_toupper);
__exctype (_tolower);
#endif /* Use X/Open or use misc. */
/* This code is needed for the optimized mapping functions. */
#define __tobody(c, f, a, args) \
(__extension__ \
({ int __res; \
if (sizeof (c) > 1) \
{ \
if (__builtin_constant_p (c)) \
{ \
int __c = (c); \
__res = __c < -128 || __c > 255 ? __c : (a)[__c]; \
} \
else \
__res = f args; \
} \
else \
__res = (a)[(int) (c)]; \
__res; }))
#if !defined __NO_CTYPE
# ifdef __isctype_f
__isctype_f (alnum)
__isctype_f (alpha)
__isctype_f (cntrl)
__isctype_f (digit)
__isctype_f (lower)
__isctype_f (graph)
__isctype_f (print)
__isctype_f (punct)
__isctype_f (space)
__isctype_f (upper)
__isctype_f (xdigit)
# ifdef __USE_ISOC99
__isctype_f (blank)
# endif
# elif defined __isctype
# define isalnum(c) __isctype((c), _ISalnum)
# define isalpha(c) __isctype((c), _ISalpha)
# define iscntrl(c) __isctype((c), _IScntrl)
# define isdigit(c) __isctype((c), _ISdigit)
# define islower(c) __isctype((c), _ISlower)
# define isgraph(c) __isctype((c), _ISgraph)
# define isprint(c) __isctype((c), _ISprint)
# define ispunct(c) __isctype((c), _ISpunct)
# define isspace(c) __isctype((c), _ISspace)
# define isupper(c) __isctype((c), _ISupper)
# define isxdigit(c) __isctype((c), _ISxdigit)
# ifdef __USE_ISOC99
# define isblank(c) __isctype((c), _ISblank)
# endif
# endif
# ifdef __USE_EXTERN_INLINES
__extern_inline int
__NTH (tolower (int __c))
{
return __c >= -128 && __c < 256 ? (*__ctype_tolower_loc ())[__c] : __c;
}
__extern_inline int
__NTH (toupper (int __c))
{
return __c >= -128 && __c < 256 ? (*__ctype_toupper_loc ())[__c] : __c;
}
# endif
# if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus
# define tolower(c) __tobody (c, tolower, *__ctype_tolower_loc (), (c))
# define toupper(c) __tobody (c, toupper, *__ctype_toupper_loc (), (c))
# endif /* Optimizing gcc */
# if defined __USE_MISC || defined __USE_XOPEN
# define isascii(c) __isascii (c)
# define toascii(c) __toascii (c)
# define _tolower(c) ((int) (*__ctype_tolower_loc ())[(int) (c)])
# define _toupper(c) ((int) (*__ctype_toupper_loc ())[(int) (c)])
# endif
#endif /* Not __NO_CTYPE. */
#ifdef __USE_XOPEN2K8
/* POSIX.1-2008 extended locale interface (see locale.h). */
# include <bits/types/locale_t.h>
/* These definitions are similar to the ones above but all functions
take as an argument a handle for the locale which shall be used. */
# define __isctype_l(c, type, locale) \
((locale)->__ctype_b[(int) (c)] & (unsigned short int) type)
# define __exctype_l(name) \
extern int name (int, locale_t) __THROW
/* The following names are all functions:
int isCHARACTERISTIC(int c, locale_t *locale);
which return nonzero iff C has CHARACTERISTIC.
For the meaning of the characteristic names, see the `enum' above. */
__exctype_l (isalnum_l);
__exctype_l (isalpha_l);
__exctype_l (iscntrl_l);
__exctype_l (isdigit_l);
__exctype_l (islower_l);
__exctype_l (isgraph_l);
__exctype_l (isprint_l);
__exctype_l (ispunct_l);
__exctype_l (isspace_l);
__exctype_l (isupper_l);
__exctype_l (isxdigit_l);
__exctype_l (isblank_l);
/* Return the lowercase version of C in locale L. */
extern int __tolower_l (int __c, locale_t __l) __THROW;
extern int tolower_l (int __c, locale_t __l) __THROW;
/* Return the uppercase version of C. */
extern int __toupper_l (int __c, locale_t __l) __THROW;
extern int toupper_l (int __c, locale_t __l) __THROW;
# if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus
# define __tolower_l(c, locale) \
__tobody (c, __tolower_l, (locale)->__ctype_tolower, (c, locale))
# define __toupper_l(c, locale) \
__tobody (c, __toupper_l, (locale)->__ctype_toupper, (c, locale))
# define tolower_l(c, locale) __tolower_l ((c), (locale))
# define toupper_l(c, locale) __toupper_l ((c), (locale))
# endif /* Optimizing gcc */
# ifndef __NO_CTYPE
# define __isalnum_l(c,l) __isctype_l((c), _ISalnum, (l))
# define __isalpha_l(c,l) __isctype_l((c), _ISalpha, (l))
# define __iscntrl_l(c,l) __isctype_l((c), _IScntrl, (l))
# define __isdigit_l(c,l) __isctype_l((c), _ISdigit, (l))
# define __islower_l(c,l) __isctype_l((c), _ISlower, (l))
# define __isgraph_l(c,l) __isctype_l((c), _ISgraph, (l))
# define __isprint_l(c,l) __isctype_l((c), _ISprint, (l))
# define __ispunct_l(c,l) __isctype_l((c), _ISpunct, (l))
# define __isspace_l(c,l) __isctype_l((c), _ISspace, (l))
# define __isupper_l(c,l) __isctype_l((c), _ISupper, (l))
# define __isxdigit_l(c,l) __isctype_l((c), _ISxdigit, (l))
# define __isblank_l(c,l) __isctype_l((c), _ISblank, (l))
# ifdef __USE_MISC
# define __isascii_l(c,l) ((l), __isascii (c))
# define __toascii_l(c,l) ((l), __toascii (c))
# endif
# define isalnum_l(c,l) __isalnum_l ((c), (l))
# define isalpha_l(c,l) __isalpha_l ((c), (l))
# define iscntrl_l(c,l) __iscntrl_l ((c), (l))
# define isdigit_l(c,l) __isdigit_l ((c), (l))
# define islower_l(c,l) __islower_l ((c), (l))
# define isgraph_l(c,l) __isgraph_l ((c), (l))
# define isprint_l(c,l) __isprint_l ((c), (l))
# define ispunct_l(c,l) __ispunct_l ((c), (l))
# define isspace_l(c,l) __isspace_l ((c), (l))
# define isupper_l(c,l) __isupper_l ((c), (l))
# define isxdigit_l(c,l) __isxdigit_l ((c), (l))
# define isblank_l(c,l) __isblank_l ((c), (l))
# ifdef __USE_MISC
# define isascii_l(c,l) __isascii_l ((c), (l))
# define toascii_l(c,l) __toascii_l ((c), (l))
# endif
# endif /* Not __NO_CTYPE. */
#endif /* Use POSIX 2008. */
__END_DECLS
#endif /* ctype.h */
getopt.h 0000644 00000002674 15201526705 0006233 0 ustar 00 /* Declarations for getopt.
Copyright (C) 1989-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Unlike the bulk of the getopt implementation, this file is NOT part
of gnulib; gnulib also has a getopt.h but it is different.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef _GETOPT_H
#define _GETOPT_H 1
#include <features.h>
/* The type of the 'argv' argument to getopt_long and getopt_long_only
is properly 'char **', since both functions may write to the array
(in order to move all the options to the beginning). However, for
compatibility with old versions of LSB, glibc has to use 'char *const *'
instead. */
#ifndef __getopt_argv_const
# define __getopt_argv_const const
#endif
#include <bits/getopt_core.h>
#include <bits/getopt_ext.h>
#endif /* getopt.h */
sepol/boolean_record.h 0000644 00000003017 15201526705 0011020 0 ustar 00 #ifndef _SEPOL_BOOLEAN_RECORD_H_
#define _SEPOL_BOOLEAN_RECORD_H_
#include <stddef.h>
#include <sepol/handle.h>
#ifdef __cplusplus
extern "C" {
#endif
struct sepol_bool;
struct sepol_bool_key;
typedef struct sepol_bool sepol_bool_t;
typedef struct sepol_bool_key sepol_bool_key_t;
/* Key */
extern int sepol_bool_key_create(sepol_handle_t * handle,
const char *name, sepol_bool_key_t ** key);
extern void sepol_bool_key_unpack(const sepol_bool_key_t * key,
const char **name);
extern int sepol_bool_key_extract(sepol_handle_t * handle,
const sepol_bool_t * boolean,
sepol_bool_key_t ** key_ptr);
extern void sepol_bool_key_free(sepol_bool_key_t * key);
extern int sepol_bool_compare(const sepol_bool_t * boolean,
const sepol_bool_key_t * key);
extern int sepol_bool_compare2(const sepol_bool_t * boolean,
const sepol_bool_t * boolean2);
/* Name */
extern const char *sepol_bool_get_name(const sepol_bool_t * boolean);
extern int sepol_bool_set_name(sepol_handle_t * handle,
sepol_bool_t * boolean, const char *name);
/* Value */
extern int sepol_bool_get_value(const sepol_bool_t * boolean);
extern void sepol_bool_set_value(sepol_bool_t * boolean, int value);
/* Create/Clone/Destroy */
extern int sepol_bool_create(sepol_handle_t * handle, sepol_bool_t ** bool_ptr);
extern int sepol_bool_clone(sepol_handle_t * handle,
const sepol_bool_t * boolean,
sepol_bool_t ** bool_ptr);
extern void sepol_bool_free(sepol_bool_t * boolean);
#ifdef __cplusplus
}
#endif
#endif
sepol/context.h 0000644 00000001360 15201526705 0007526 0 ustar 00 #ifndef _SEPOL_CONTEXT_H_
#define _SEPOL_CONTEXT_H_
#include <sepol/context_record.h>
#include <sepol/policydb.h>
#include <sepol/handle.h>
#ifdef __cplusplus
extern "C" {
#endif
/* -- Deprecated -- */
extern int sepol_check_context(const char *context);
/* -- End deprecated -- */
extern int sepol_context_check(sepol_handle_t * handle,
const sepol_policydb_t * policydb,
const sepol_context_t * context);
extern int sepol_mls_contains(sepol_handle_t * handle,
const sepol_policydb_t * policydb,
const char *mls1,
const char *mls2, int *response);
extern int sepol_mls_check(sepol_handle_t * handle,
const sepol_policydb_t * policydb, const char *mls);
#ifdef __cplusplus
}
#endif
#endif
sepol/ports.h 0000644 00000002440 15201526705 0007211 0 ustar 00 #ifndef _SEPOL_PORTS_H_
#define _SEPOL_PORTS_H_
#include <sepol/handle.h>
#include <sepol/policydb.h>
#include <sepol/port_record.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Return the number of ports */
extern int sepol_port_count(sepol_handle_t * handle,
const sepol_policydb_t * p, unsigned int *response);
/* Check if a port exists */
extern int sepol_port_exists(sepol_handle_t * handle,
const sepol_policydb_t * policydb,
const sepol_port_key_t * key, int *response);
/* Query a port - returns the port, or NULL if not found */
extern int sepol_port_query(sepol_handle_t * handle,
const sepol_policydb_t * policydb,
const sepol_port_key_t * key,
sepol_port_t ** response);
/* Modify a port, or add it, if the key is not found */
extern int sepol_port_modify(sepol_handle_t * handle,
sepol_policydb_t * policydb,
const sepol_port_key_t * key,
const sepol_port_t * data);
/* Iterate the ports
* The handler may return:
* -1 to signal an error condition,
* 1 to signal successful exit
* 0 to signal continue */
extern int sepol_port_iterate(sepol_handle_t * handle,
const sepol_policydb_t * policydb,
int (*fn) (const sepol_port_t * port,
void *fn_arg), void *arg);
#ifdef __cplusplus
}
#endif
#endif
sepol/users.h 0000644 00000003747 15201526705 0007216 0 ustar 00 #ifndef _SEPOL_USERS_H_
#define _SEPOL_USERS_H_
#include <sepol/policydb.h>
#include <sepol/user_record.h>
#include <sepol/handle.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
/*---------compatibility------------*/
/* Given an existing binary policy (starting at 'data with length 'len')
and user configurations living in 'usersdir', generate a new binary
policy for the new user configurations. Sets '*newdata' and '*newlen'
to refer to the new binary policy image. */
extern int sepol_genusers(void *data, size_t len,
const char *usersdir,
void **newdata, size_t * newlen);
/* Enable or disable deletion of users by sepol_genusers(3) when
a user in original binary policy image is not defined by the
new user configurations. Defaults to disabled. */
extern void sepol_set_delusers(int on);
/*--------end compatibility----------*/
/* Modify the user, or add it, if the key is not found */
extern int sepol_user_modify(sepol_handle_t * handle,
sepol_policydb_t * policydb,
const sepol_user_key_t * key,
const sepol_user_t * data);
/* Return the number of users */
extern int sepol_user_count(sepol_handle_t * handle,
const sepol_policydb_t * p, unsigned int *response);
/* Check if the specified user exists */
extern int sepol_user_exists(sepol_handle_t * handle,
const sepol_policydb_t * policydb,
const sepol_user_key_t * key, int *response);
/* Query a user - returns the user or NULL if not found */
extern int sepol_user_query(sepol_handle_t * handle,
const sepol_policydb_t * p,
const sepol_user_key_t * key,
sepol_user_t ** response);
/* Iterate the users
* The handler may return:
* -1 to signal an error condition,
* 1 to signal successful exit
* 0 to signal continue */
extern int sepol_user_iterate(sepol_handle_t * handle,
const sepol_policydb_t * policydb,
int (*fn) (const sepol_user_t * user,
void *fn_arg), void *arg);
#ifdef __cplusplus
}
#endif
#endif
sepol/cil/cil.h 0000644 00000006645 15201526705 0007373 0 ustar 00 /*
* Copyright 2011 Tresys Technology, LLC. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY TRESYS TECHNOLOGY, LLC ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL TRESYS TECHNOLOGY, LLC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of Tresys Technology, LLC.
*/
#ifndef CIL_H_
#define CIL_H_
#include <sepol/policydb/policydb.h>
#ifdef __cplusplus
extern "C" {
#endif
struct cil_db;
typedef struct cil_db cil_db_t;
extern void cil_db_init(cil_db_t **db);
extern void cil_db_destroy(cil_db_t **db);
extern int cil_add_file(cil_db_t *db, char *name, char *data, size_t size);
extern int cil_compile(cil_db_t *db);
extern int cil_build_policydb(cil_db_t *db, sepol_policydb_t **sepol_db);
extern int cil_userprefixes_to_string(cil_db_t *db, char **out, size_t *size);
extern int cil_selinuxusers_to_string(cil_db_t *db, char **out, size_t *size);
extern int cil_filecons_to_string(cil_db_t *db, char **out, size_t *size);
extern void cil_set_disable_dontaudit(cil_db_t *db, int disable_dontaudit);
extern void cil_set_multiple_decls(cil_db_t *db, int multiple_decls);
extern void cil_set_disable_neverallow(cil_db_t *db, int disable_neverallow);
extern void cil_set_preserve_tunables(cil_db_t *db, int preserve_tunables);
extern int cil_set_handle_unknown(cil_db_t *db, int handle_unknown);
extern void cil_set_mls(cil_db_t *db, int mls);
extern void cil_set_attrs_expand_generated(struct cil_db *db, int attrs_expand_generated);
extern void cil_set_attrs_expand_size(struct cil_db *db, unsigned attrs_expand_size);
extern void cil_set_target_platform(cil_db_t *db, int target_platform);
extern void cil_set_policy_version(cil_db_t *db, int policy_version);
extern void cil_write_policy_conf(FILE *out, struct cil_db *db);
enum cil_log_level {
CIL_ERR = 1,
CIL_WARN,
CIL_INFO
};
extern void cil_set_log_level(enum cil_log_level lvl);
extern void cil_set_log_handler(void (*handler)(int lvl, char *msg));
#ifdef __GNUC__
__attribute__ ((format(printf, 2, 3)))
#endif
extern void cil_log(enum cil_log_level lvl, const char *msg, ...);
extern void cil_set_malloc_error_handler(void (*handler)(void));
#ifdef __cplusplus
}
#endif
#endif
sepol/module_to_cil.h 0000644 00000000511 15201526705 0010655 0 ustar 00 #include <stdlib.h>
#include <sepol/module.h>
#include <sepol/policydb/policydb.h>
int sepol_module_policydb_to_cil(FILE *fp, struct policydb *pdb, int linked);
int sepol_module_package_to_cil(FILE *fp, struct sepol_module_package *mod_pkg);
int sepol_ppfile_to_module_package(FILE *fp, struct sepol_module_package **mod_pkg);
sepol/ibpkeys.h 0000644 00000002503 15201526705 0007510 0 ustar 00 #ifndef _SEPOL_IBPKEYS_H_
#define _SEPOL_IBPKEYS_H_
#include <sepol/handle.h>
#include <sepol/policydb.h>
#include <sepol/ibpkey_record.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Return the number of ibpkeys */
extern int sepol_ibpkey_count(sepol_handle_t *handle,
const sepol_policydb_t *p, unsigned int *response);
/* Check if a ibpkey exists */
extern int sepol_ibpkey_exists(sepol_handle_t *handle,
const sepol_policydb_t *policydb,
const sepol_ibpkey_key_t *key, int *response);
/* Query a ibpkey - returns the ibpkey, or NULL if not found */
extern int sepol_ibpkey_query(sepol_handle_t *handle,
const sepol_policydb_t *policydb,
const sepol_ibpkey_key_t *key,
sepol_ibpkey_t **response);
/* Modify a ibpkey, or add it, if the key is not found */
extern int sepol_ibpkey_modify(sepol_handle_t *handle,
sepol_policydb_t *policydb,
const sepol_ibpkey_key_t *key,
const sepol_ibpkey_t *data);
/* Iterate the ibpkeys
* The handler may return:
* -1 to signal an error condition,
* 1 to signal successful exit
* 0 to signal continue
*/
extern int sepol_ibpkey_iterate(sepol_handle_t *handle,
const sepol_policydb_t *policydb,
int (*fn)(const sepol_ibpkey_t *ibpkey,
void *fn_arg), void *arg);
#ifdef __cplusplus
}
#endif
#endif
sepol/ibendport_record.h 0000644 00000004206 15201526705 0011370 0 ustar 00 #ifndef _SEPOL_IBENDPORT_RECORD_H_
#define _SEPOL_IBENDPORT_RECORD_H_
#include <stddef.h>
#include <sepol/context_record.h>
#include <sepol/handle.h>
#ifdef __cplusplus
extern "C" {
#endif
struct sepol_ibendport;
struct sepol_ibendport_key;
typedef struct sepol_ibendport sepol_ibendport_t;
typedef struct sepol_ibendport_key sepol_ibendport_key_t;
extern int sepol_ibendport_compare(const sepol_ibendport_t *ibendport,
const sepol_ibendport_key_t *key);
extern int sepol_ibendport_compare2(const sepol_ibendport_t *ibendport,
const sepol_ibendport_t *ibendport2);
extern int sepol_ibendport_key_create(sepol_handle_t *handle,
const char *ibdev_name,
int port,
sepol_ibendport_key_t **key_ptr);
extern void sepol_ibendport_key_unpack(const sepol_ibendport_key_t *key,
const char **ibdev_name,
int *port);
extern int sepol_ibendport_alloc_ibdev_name(sepol_handle_t *handle,
char **ibdev_name);
extern int sepol_ibendport_key_extract(sepol_handle_t *handle,
const sepol_ibendport_t *ibendport,
sepol_ibendport_key_t **key_ptr);
extern void sepol_ibendport_key_free(sepol_ibendport_key_t *key);
extern void sepol_ibendport_set_port(sepol_ibendport_t *ibendport, int port);
extern int sepol_ibendport_get_port(const sepol_ibendport_t *ibendport);
extern int sepol_ibendport_get_ibdev_name(sepol_handle_t *handle,
const sepol_ibendport_t *ibendport,
char **ibdev_name);
extern int sepol_ibendport_set_ibdev_name(sepol_handle_t *handle,
sepol_ibendport_t *ibendport,
const char *ibdev_name);
extern sepol_context_t *sepol_ibendport_get_con(const sepol_ibendport_t *ibendport);
extern int sepol_ibendport_set_con(sepol_handle_t *handle,
sepol_ibendport_t *ibendport,
sepol_context_t *con);
extern int sepol_ibendport_create(sepol_handle_t *handle,
sepol_ibendport_t **ibendport_ptr);
extern int sepol_ibendport_clone(sepol_handle_t *handle,
const sepol_ibendport_t *ibendport,
sepol_ibendport_t **ibendport_ptr);
extern void sepol_ibendport_free(sepol_ibendport_t *ibendport);
#ifdef __cplusplus
}
#endif
#endif
sepol/roles.h 0000644 00000000523 15201526705 0007166 0 ustar 00 #ifndef _SEPOL_ROLES_H_
#define _SEPOL_ROLES_H_
#ifdef __cplusplus
extern "C" {
#endif
extern int sepol_role_exists(const sepol_policydb_t * policydb,
const char *role, int *response);
extern int sepol_role_list(const sepol_policydb_t * policydb,
char ***roles, unsigned int *nroles);
#ifdef __cplusplus
}
#endif
#endif
sepol/sepol.h 0000644 00000001536 15201526705 0007171 0 ustar 00 #ifndef _SEPOL_H_
#define _SEPOL_H_
#include <stddef.h>
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <sepol/user_record.h>
#include <sepol/context_record.h>
#include <sepol/iface_record.h>
#include <sepol/ibpkey_record.h>
#include <sepol/ibendport_record.h>
#include <sepol/port_record.h>
#include <sepol/boolean_record.h>
#include <sepol/node_record.h>
#include <sepol/booleans.h>
#include <sepol/interfaces.h>
#include <sepol/ibpkeys.h>
#include <sepol/ibendports.h>
#include <sepol/ports.h>
#include <sepol/nodes.h>
#include <sepol/users.h>
#include <sepol/handle.h>
#include <sepol/debug.h>
#include <sepol/policydb.h>
#include <sepol/module.h>
#include <sepol/context.h>
/* Set internal policydb from a file for subsequent service calls. */
extern int sepol_set_policydb_from_file(FILE * fp);
#ifdef __cplusplus
}
#endif
#endif
sepol/module.h 0000644 00000005170 15201526705 0007332 0 ustar 00 #ifndef _SEPOL_MODULE_H_
#define _SEPOL_MODULE_H_
#include <stddef.h>
#include <stdio.h>
#include <stdint.h>
#include <sepol/handle.h>
#include <sepol/policydb.h>
#ifdef __cplusplus
extern "C" {
#endif
struct sepol_module_package;
typedef struct sepol_module_package sepol_module_package_t;
/* Module package public interfaces. */
extern int sepol_module_package_create(sepol_module_package_t ** p);
extern void sepol_module_package_free(sepol_module_package_t * p);
extern char *sepol_module_package_get_file_contexts(sepol_module_package_t * p);
extern size_t sepol_module_package_get_file_contexts_len(sepol_module_package_t
* p);
extern int sepol_module_package_set_file_contexts(sepol_module_package_t * p,
char *data, size_t len);
extern char *sepol_module_package_get_seusers(sepol_module_package_t * p);
extern size_t sepol_module_package_get_seusers_len(sepol_module_package_t * p);
extern int sepol_module_package_set_seusers(sepol_module_package_t * p,
char *data, size_t len);
extern char *sepol_module_package_get_user_extra(sepol_module_package_t * p);
extern size_t sepol_module_package_get_user_extra_len(sepol_module_package_t *
p);
extern int sepol_module_package_set_user_extra(sepol_module_package_t * p,
char *data, size_t len);
extern char *sepol_module_package_get_netfilter_contexts(sepol_module_package_t
* p);
extern size_t
sepol_module_package_get_netfilter_contexts_len(sepol_module_package_t * p);
extern int sepol_module_package_set_netfilter_contexts(sepol_module_package_t *
p, char *data,
size_t len);
extern sepol_policydb_t *sepol_module_package_get_policy(sepol_module_package_t
* p);
extern int sepol_link_packages(sepol_handle_t * handle,
sepol_module_package_t * base,
sepol_module_package_t ** modules,
int num_modules, int verbose);
extern int sepol_module_package_read(sepol_module_package_t * mod,
struct sepol_policy_file *file,
int verbose);
extern int sepol_module_package_info(struct sepol_policy_file *file,
int *type, char **name, char **version);
extern int sepol_module_package_write(sepol_module_package_t * p,
struct sepol_policy_file *file);
/* Module linking/expanding public interfaces. */
extern int sepol_link_modules(sepol_handle_t * handle,
sepol_policydb_t * base,
sepol_policydb_t ** modules,
size_t len, int verbose);
extern int sepol_expand_module(sepol_handle_t * handle,
sepol_policydb_t * base,
sepol_policydb_t * out, int verbose, int check);
#ifdef __cplusplus
}
#endif
#endif
sepol/errcodes.h 0000644 00000001523 15201526705 0007651 0 ustar 00 /* Author: Karl MacMillan <kmacmillan@mentalrootkit.com> */
#ifndef __sepol_errno_h__
#define __sepol_errno_h__
#include <errno.h>
#ifdef __cplusplus
extern "C" {
#endif
#define SEPOL_OK 0
/* These first error codes are defined for compatibility with
* previous version of libsepol. In the future, custom error
* codes that don't map to system error codes should be defined
* outside of the range of system error codes.
*/
#define SEPOL_ERR -1
#define SEPOL_ENOTSUP -2 /* feature not supported in module language */
#define SEPOL_EREQ -3 /* requirements not met */
/* Error codes that map to system error codes */
#define SEPOL_ENOMEM -ENOMEM
#define SEPOL_ERANGE -ERANGE
#define SEPOL_EEXIST -EEXIST
#define SEPOL_ENOENT -ENOENT
#ifdef __cplusplus
}
#endif
#endif
sepol/ibendports.h 0000644 00000002553 15201526705 0010220 0 ustar 00 #ifndef _SEPOL_IBENDPORTS_H_
#define _SEPOL_IBENDPORTS_H_
#include <sepol/handle.h>
#include <sepol/policydb.h>
#include <sepol/ibendport_record.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Return the number of ibendports */
extern int sepol_ibendport_count(sepol_handle_t *handle,
const sepol_policydb_t *p,
unsigned int *response);
/* Check if a ibendport exists */
extern int sepol_ibendport_exists(sepol_handle_t *handle,
const sepol_policydb_t *policydb,
const sepol_ibendport_key_t *key, int *response);
/* Query a ibendport - returns the ibendport, or NULL if not found */
extern int sepol_ibendport_query(sepol_handle_t *handle,
const sepol_policydb_t *policydb,
const sepol_ibendport_key_t *key,
sepol_ibendport_t **response);
/* Modify a ibendport, or add it, if the key is not found */
extern int sepol_ibendport_modify(sepol_handle_t *handle,
sepol_policydb_t *policydb,
const sepol_ibendport_key_t *key,
const sepol_ibendport_t *data);
/* Iterate the ibendports
* The handler may return:
* -1 to signal an error condition,
* 1 to signal successful exit
* 0 to signal continue
*/
extern int sepol_ibendport_iterate(sepol_handle_t *handle,
const sepol_policydb_t *policydb,
int (*fn)(const sepol_ibendport_t *ibendport,
void *fn_arg), void *arg);
#ifdef __cplusplus
}
#endif
#endif
sepol/interfaces.h 0000644 00000002573 15201526705 0010174 0 ustar 00 #ifndef __SEPOL_INTERFACES_H_
#define __SEPOL_INTERFACES_H_
#include <sepol/policydb.h>
#include <sepol/iface_record.h>
#include <sepol/handle.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Return the number of interfaces */
extern int sepol_iface_count(sepol_handle_t * handle,
const sepol_policydb_t * policydb,
unsigned int *response);
/* Check if an interface exists */
extern int sepol_iface_exists(sepol_handle_t * handle,
const sepol_policydb_t * policydb,
const sepol_iface_key_t * key, int *response);
/* Query an interface - returns the interface,
* or NULL if not found */
extern int sepol_iface_query(sepol_handle_t * handle,
const sepol_policydb_t * policydb,
const sepol_iface_key_t * key,
sepol_iface_t ** response);
/* Modify an interface, or add it, if the key
* is not found */
extern int sepol_iface_modify(sepol_handle_t * handle,
sepol_policydb_t * policydb,
const sepol_iface_key_t * key,
const sepol_iface_t * data);
/* Iterate the interfaces
* The handler may return:
* -1 to signal an error condition,
* 1 to signal successful exit
* 0 to signal continue */
extern int sepol_iface_iterate(sepol_handle_t * handle,
const sepol_policydb_t * policydb,
int (*fn) (const sepol_iface_t * iface,
void *fn_arg), void *arg);
#ifdef __cplusplus
}
#endif
#endif
sepol/context_record.h 0000644 00000003206 15201526705 0011065 0 ustar 00 #ifndef _SEPOL_CONTEXT_RECORD_H_
#define _SEPOL_CONTEXT_RECORD_H_
#include <sepol/handle.h>
#ifdef __cplusplus
extern "C" {
#endif
struct sepol_context;
typedef struct sepol_context sepol_context_t;
/* We don't need a key, because the context is never stored
* in a data collection by itself */
/* User */
extern const char *sepol_context_get_user(const sepol_context_t * con);
extern int sepol_context_set_user(sepol_handle_t * handle,
sepol_context_t * con, const char *user);
/* Role */
extern const char *sepol_context_get_role(const sepol_context_t * con);
extern int sepol_context_set_role(sepol_handle_t * handle,
sepol_context_t * con, const char *role);
/* Type */
extern const char *sepol_context_get_type(const sepol_context_t * con);
extern int sepol_context_set_type(sepol_handle_t * handle,
sepol_context_t * con, const char *type);
/* MLS */
extern const char *sepol_context_get_mls(const sepol_context_t * con);
extern int sepol_context_set_mls(sepol_handle_t * handle,
sepol_context_t * con, const char *mls_range);
/* Create/Clone/Destroy */
extern int sepol_context_create(sepol_handle_t * handle,
sepol_context_t ** con_ptr);
extern int sepol_context_clone(sepol_handle_t * handle,
const sepol_context_t * con,
sepol_context_t ** con_ptr);
extern void sepol_context_free(sepol_context_t * con);
/* Parse to/from string */
extern int sepol_context_from_string(sepol_handle_t * handle,
const char *str, sepol_context_t ** con);
extern int sepol_context_to_string(sepol_handle_t * handle,
const sepol_context_t * con, char **str_ptr);
#ifdef __cplusplus
}
#endif
#endif
sepol/policydb/context.h 0000644 00000006404 15201526705 0011337 0 ustar 00 /* Author : Stephen Smalley, <sds@tycho.nsa.gov> */
/* FLASK */
/*
* A security context is a set of security attributes
* associated with each subject and object controlled
* by the security policy. Security contexts are
* externally represented as variable-length strings
* that can be interpreted by a user or application
* with an understanding of the security policy.
* Internally, the security server uses a simple
* structure. This structure is private to the
* security server and can be changed without affecting
* clients of the security server.
*/
#ifndef _SEPOL_POLICYDB_CONTEXT_H_
#define _SEPOL_POLICYDB_CONTEXT_H_
#include <stddef.h>
#include <sepol/policydb/ebitmap.h>
#include <sepol/policydb/mls_types.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* A security context consists of an authenticated user
* identity, a role, a type and a MLS range.
*/
typedef struct context_struct {
uint32_t user;
uint32_t role;
uint32_t type;
mls_range_t range;
} context_struct_t;
static inline void mls_context_init(context_struct_t * c)
{
mls_range_init(&c->range);
}
static inline int mls_context_cpy(context_struct_t * dst,
context_struct_t * src)
{
if (mls_range_cpy(&dst->range, &src->range) < 0)
return -1;
return 0;
}
/*
* Sets both levels in the MLS range of 'dst' to the low level of 'src'.
*/
static inline int mls_context_cpy_low(context_struct_t *dst, context_struct_t *src)
{
int rc;
dst->range.level[0].sens = src->range.level[0].sens;
rc = ebitmap_cpy(&dst->range.level[0].cat, &src->range.level[0].cat);
if (rc)
goto out;
dst->range.level[1].sens = src->range.level[0].sens;
rc = ebitmap_cpy(&dst->range.level[1].cat, &src->range.level[0].cat);
if (rc)
ebitmap_destroy(&dst->range.level[0].cat);
out:
return rc;
}
/*
* Sets both levels in the MLS range of 'dst' to the high level of 'src'.
*/
static inline int mls_context_cpy_high(context_struct_t *dst, context_struct_t *src)
{
int rc;
dst->range.level[0].sens = src->range.level[1].sens;
rc = ebitmap_cpy(&dst->range.level[0].cat, &src->range.level[1].cat);
if (rc)
goto out;
dst->range.level[1].sens = src->range.level[1].sens;
rc = ebitmap_cpy(&dst->range.level[1].cat, &src->range.level[1].cat);
if (rc)
ebitmap_destroy(&dst->range.level[0].cat);
out:
return rc;
}
static inline int mls_context_cmp(context_struct_t * c1, context_struct_t * c2)
{
return (mls_level_eq(&c1->range.level[0], &c2->range.level[0]) &&
mls_level_eq(&c1->range.level[1], &c2->range.level[1]));
}
static inline void mls_context_destroy(context_struct_t * c)
{
if (c == NULL)
return;
mls_range_destroy(&c->range);
mls_context_init(c);
}
static inline void context_init(context_struct_t * c)
{
memset(c, 0, sizeof(*c));
}
static inline int context_cpy(context_struct_t * dst, context_struct_t * src)
{
dst->user = src->user;
dst->role = src->role;
dst->type = src->type;
return mls_context_cpy(dst, src);
}
static inline void context_destroy(context_struct_t * c)
{
if (c == NULL)
return;
c->user = c->role = c->type = 0;
mls_context_destroy(c);
}
static inline int context_cmp(context_struct_t * c1, context_struct_t * c2)
{
return ((c1->user == c2->user) &&
(c1->role == c2->role) &&
(c1->type == c2->type) && mls_context_cmp(c1, c2));
}
#ifdef __cplusplus
}
#endif
#endif
sepol/policydb/ebitmap.h 0000644 00000006150 15201526705 0011272 0 ustar 00 /* Author : Stephen Smalley, <sds@tycho.nsa.gov> */
/* FLASK */
/*
* An extensible bitmap is a bitmap that supports an
* arbitrary number of bits. Extensible bitmaps are
* used to represent sets of values, such as types,
* roles, categories, and classes.
*
* Each extensible bitmap is implemented as a linked
* list of bitmap nodes, where each bitmap node has
* an explicitly specified starting bit position within
* the total bitmap.
*/
#ifndef _SEPOL_POLICYDB_EBITMAP_H_
#define _SEPOL_POLICYDB_EBITMAP_H_
#include <stdint.h>
#include <string.h>
#ifdef __cplusplus
extern "C" {
#endif
#define MAPTYPE uint64_t /* portion of bitmap in each node */
#define MAPSIZE (sizeof(MAPTYPE) * 8) /* number of bits in node bitmap */
#define MAPBIT 1ULL /* a bit in the node bitmap */
typedef struct ebitmap_node {
uint32_t startbit; /* starting position in the total bitmap */
MAPTYPE map; /* this node's portion of the bitmap */
struct ebitmap_node *next;
} ebitmap_node_t;
typedef struct ebitmap {
ebitmap_node_t *node; /* first node in the bitmap */
uint32_t highbit; /* highest position in the total bitmap */
} ebitmap_t;
#define ebitmap_length(e) ((e)->highbit)
#define ebitmap_startbit(e) ((e)->node ? (e)->node->startbit : 0)
#define ebitmap_startnode(e) ((e)->node)
static inline unsigned int ebitmap_start(const ebitmap_t * e,
ebitmap_node_t ** n)
{
*n = e->node;
return ebitmap_startbit(e);
}
static inline void ebitmap_init(ebitmap_t * e)
{
memset(e, 0, sizeof(*e));
}
static inline unsigned int ebitmap_next(ebitmap_node_t ** n, unsigned int bit)
{
if ((bit == ((*n)->startbit + MAPSIZE - 1)) && (*n)->next) {
*n = (*n)->next;
return (*n)->startbit;
}
return (bit + 1);
}
static inline int ebitmap_node_get_bit(ebitmap_node_t * n, unsigned int bit)
{
if (n->map & (MAPBIT << (bit - n->startbit)))
return 1;
return 0;
}
#define ebitmap_for_each_bit(e, n, bit) \
for (bit = ebitmap_start(e, &n); bit < ebitmap_length(e); bit = ebitmap_next(&n, bit)) \
extern int ebitmap_cmp(const ebitmap_t * e1, const ebitmap_t * e2);
extern int ebitmap_or(ebitmap_t * dst, const ebitmap_t * e1, const ebitmap_t * e2);
extern int ebitmap_union(ebitmap_t * dst, const ebitmap_t * e1);
extern int ebitmap_and(ebitmap_t *dst, ebitmap_t *e1, ebitmap_t *e2);
extern int ebitmap_xor(ebitmap_t *dst, ebitmap_t *e1, ebitmap_t *e2);
extern int ebitmap_not(ebitmap_t *dst, ebitmap_t *e1, unsigned int maxbit);
extern int ebitmap_andnot(ebitmap_t *dst, ebitmap_t *e1, ebitmap_t *e2, unsigned int maxbit);
extern unsigned int ebitmap_cardinality(ebitmap_t *e1);
extern int ebitmap_hamming_distance(ebitmap_t * e1, ebitmap_t * e2);
extern int ebitmap_cpy(ebitmap_t * dst, const ebitmap_t * src);
extern int ebitmap_contains(const ebitmap_t * e1, const ebitmap_t * e2);
extern int ebitmap_match_any(const ebitmap_t *e1, const ebitmap_t *e2);
extern int ebitmap_get_bit(const ebitmap_t * e, unsigned int bit);
extern int ebitmap_set_bit(ebitmap_t * e, unsigned int bit, int value);
extern void ebitmap_destroy(ebitmap_t * e);
extern int ebitmap_read(ebitmap_t * e, void *fp);
#ifdef __cplusplus
}
#endif
#endif /* _EBITMAP_H_ */
/* FLASK */
sepol/policydb/constraint.h 0000644 00000005013 15201526705 0012032 0 ustar 00 /* Author : Stephen Smalley, <sds@tycho.nsa.gov> */
/* FLASK */
/*
* A constraint is a condition that must be satisfied in
* order for one or more permissions to be granted.
* Constraints are used to impose additional restrictions
* beyond the type-based rules in `te' or the role-based
* transition rules in `rbac'. Constraints are typically
* used to prevent a process from transitioning to a new user
* identity or role unless it is in a privileged type.
* Constraints are likewise typically used to prevent a
* process from labeling an object with a different user
* identity.
*/
#ifndef _SEPOL_POLICYDB_CONSTRAINT_H_
#define _SEPOL_POLICYDB_CONSTRAINT_H_
#include <sepol/policydb/policydb.h>
#include <sepol/policydb/ebitmap.h>
#include <sepol/policydb/flask_types.h>
#ifdef __cplusplus
extern "C" {
#endif
#define CEXPR_MAXDEPTH 5
struct type_set;
typedef struct constraint_expr {
#define CEXPR_NOT 1 /* not expr */
#define CEXPR_AND 2 /* expr and expr */
#define CEXPR_OR 3 /* expr or expr */
#define CEXPR_ATTR 4 /* attr op attr */
#define CEXPR_NAMES 5 /* attr op names */
uint32_t expr_type; /* expression type */
#define CEXPR_USER 1 /* user */
#define CEXPR_ROLE 2 /* role */
#define CEXPR_TYPE 4 /* type */
#define CEXPR_TARGET 8 /* target if set, source otherwise */
#define CEXPR_XTARGET 16 /* special 3rd target for validatetrans rule */
#define CEXPR_L1L2 32 /* low level 1 vs. low level 2 */
#define CEXPR_L1H2 64 /* low level 1 vs. high level 2 */
#define CEXPR_H1L2 128 /* high level 1 vs. low level 2 */
#define CEXPR_H1H2 256 /* high level 1 vs. high level 2 */
#define CEXPR_L1H1 512 /* low level 1 vs. high level 1 */
#define CEXPR_L2H2 1024 /* low level 2 vs. high level 2 */
uint32_t attr; /* attribute */
#define CEXPR_EQ 1 /* == or eq */
#define CEXPR_NEQ 2 /* != */
#define CEXPR_DOM 3 /* dom */
#define CEXPR_DOMBY 4 /* domby */
#define CEXPR_INCOMP 5 /* incomp */
uint32_t op; /* operator */
ebitmap_t names; /* names */
struct type_set *type_names;
struct constraint_expr *next; /* next expression */
} constraint_expr_t;
typedef struct constraint_node {
sepol_access_vector_t permissions; /* constrained permissions */
constraint_expr_t *expr; /* constraint on permissions */
struct constraint_node *next; /* next constraint */
} constraint_node_t;
struct policydb;
extern int constraint_expr_init(constraint_expr_t * expr);
extern void constraint_expr_destroy(constraint_expr_t * expr);
#ifdef __cplusplus
}
#endif
#endif /* _CONSTRAINT_H_ */
/* FLASK */
sepol/policydb/symtab.h 0000644 00000002116 15201526705 0011146 0 ustar 00
/* Author : Stephen Smalley, <sds@tycho.nsa.gov> */
/* FLASK */
/*
* A symbol table (symtab) maintains associations between symbol
* strings and datum values. The type of the datum values
* is arbitrary. The symbol table type is implemented
* using the hash table type (hashtab).
*/
#ifndef _SEPOL_POLICYDB_SYMTAB_H_
#define _SEPOL_POLICYDB_SYMTAB_H_
#include <sepol/policydb/hashtab.h>
#ifdef __cplusplus
extern "C" {
#endif
/* The symtab_datum struct stores the common information for
* all symtab datums. It should the first element in every
* struct that will be used in a symtab to allow the specific
* datum types to be freely cast to this type.
*
* The values start at 1 - 0 is never a valid value.
*/
typedef struct symtab_datum {
uint32_t value;
} symtab_datum_t;
typedef struct {
hashtab_t table; /* hash table (keyed on a string) */
uint32_t nprim; /* number of primary names in table */
} symtab_t;
extern int symtab_init(symtab_t *, unsigned int size);
extern void symtab_destroy(symtab_t *);
#ifdef __cplusplus
}
#endif
#endif /* _SYMTAB_H_ */
/* FLASK */
sepol/policydb/mls_types.h 0000644 00000010430 15201526705 0011664 0 ustar 00 /* Author : Stephen Smalley, <sds@tycho.nsa.gov> */
/*
* Updated: Trusted Computer Solutions, Inc. <dgoeddel@trustedcs.com>
*
* Support for enhanced MLS infrastructure.
*
* Copyright (C) 2004-2005 Trusted Computer Solutions, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* FLASK */
/*
* Type definitions for the multi-level security (MLS) policy.
*/
#ifndef _SEPOL_POLICYDB_MLS_TYPES_H_
#define _SEPOL_POLICYDB_MLS_TYPES_H_
#include <stdint.h>
#include <stdlib.h>
#include <sepol/policydb/ebitmap.h>
#include <sepol/policydb/flask_types.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct mls_level {
uint32_t sens; /* sensitivity */
ebitmap_t cat; /* category set */
} mls_level_t;
typedef struct mls_range {
mls_level_t level[2]; /* low == level[0], high == level[1] */
} mls_range_t;
static inline int mls_level_cpy(struct mls_level *dst, struct mls_level *src)
{
dst->sens = src->sens;
if (ebitmap_cpy(&dst->cat, &src->cat) < 0)
return -1;
return 0;
}
static inline void mls_level_init(struct mls_level *level)
{
memset(level, 0, sizeof(mls_level_t));
}
static inline void mls_level_destroy(struct mls_level *level)
{
if (level == NULL)
return;
ebitmap_destroy(&level->cat);
mls_level_init(level);
}
static inline int mls_level_eq(const struct mls_level *l1, const struct mls_level *l2)
{
return ((l1->sens == l2->sens) && ebitmap_cmp(&l1->cat, &l2->cat));
}
static inline int mls_level_dom(const struct mls_level *l1, const struct mls_level *l2)
{
return ((l1->sens >= l2->sens) && ebitmap_contains(&l1->cat, &l2->cat));
}
#define mls_level_incomp(l1, l2) \
(!mls_level_dom((l1), (l2)) && !mls_level_dom((l2), (l1)))
#define mls_level_between(l1, l2, l3) \
(mls_level_dom((l1), (l2)) && mls_level_dom((l3), (l1)))
#define mls_range_contains(r1, r2) \
(mls_level_dom(&(r2).level[0], &(r1).level[0]) && \
mls_level_dom(&(r1).level[1], &(r2).level[1]))
static inline int mls_range_cpy(mls_range_t * dst, mls_range_t * src)
{
if (mls_level_cpy(&dst->level[0], &src->level[0]) < 0)
goto err;
if (mls_level_cpy(&dst->level[1], &src->level[1]) < 0)
goto err_destroy;
return 0;
err_destroy:
mls_level_destroy(&dst->level[0]);
err:
return -1;
}
static inline void mls_range_init(struct mls_range *r)
{
mls_level_init(&r->level[0]);
mls_level_init(&r->level[1]);
}
static inline void mls_range_destroy(struct mls_range *r)
{
mls_level_destroy(&r->level[0]);
mls_level_destroy(&r->level[1]);
}
static inline int mls_range_eq(struct mls_range *r1, struct mls_range *r2)
{
return (mls_level_eq(&r1->level[0], &r2->level[0]) &&
mls_level_eq(&r1->level[1], &r2->level[1]));
}
typedef struct mls_semantic_cat {
uint32_t low; /* first bit this struct represents */
uint32_t high; /* last bit represented - equals low for a single cat */
struct mls_semantic_cat *next;
} mls_semantic_cat_t;
typedef struct mls_semantic_level {
uint32_t sens;
mls_semantic_cat_t *cat;
} mls_semantic_level_t;
typedef struct mls_semantic_range {
mls_semantic_level_t level[2];
} mls_semantic_range_t;
extern void mls_semantic_cat_init(mls_semantic_cat_t *c);
extern void mls_semantic_cat_destroy(mls_semantic_cat_t *c);
extern void mls_semantic_level_init(mls_semantic_level_t *l);
extern void mls_semantic_level_destroy(mls_semantic_level_t *l);
extern int mls_semantic_level_cpy(mls_semantic_level_t *dst, mls_semantic_level_t *src);
extern void mls_semantic_range_init(mls_semantic_range_t *r);
extern void mls_semantic_range_destroy(mls_semantic_range_t *r);
extern int mls_semantic_range_cpy(mls_semantic_range_t *dst, mls_semantic_range_t *src);
#ifdef __cplusplus
}
#endif
#endif
sepol/policydb/module.h 0000644 00000002774 15201526705 0011146 0 ustar 00 /* Author: Karl MacMillan <kmacmillan@tresys.com>
*
* Copyright (C) 2004-2005 Tresys Technology, LLC
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _SEPOL_POLICYDB_MODULE_H_
#define _SEPOL_POLICYDB_MODULE_H_
#include <stdlib.h>
#include <stddef.h>
#include <sepol/module.h>
#include <sepol/policydb/policydb.h>
#include <sepol/policydb/conditional.h>
#define SEPOL_MODULE_PACKAGE_MAGIC 0xf97cff8f
#ifdef __cplusplus
extern "C" {
#endif
struct sepol_module_package {
sepol_policydb_t *policy;
uint32_t version;
char *file_contexts;
size_t file_contexts_len;
char *seusers;
size_t seusers_len;
char *user_extra;
size_t user_extra_len;
char *netfilter_contexts;
size_t netfilter_contexts_len;
};
extern int sepol_module_package_init(sepol_module_package_t * p);
#ifdef __cplusplus
}
#endif
#endif
sepol/policydb/avrule_block.h 0000644 00000003145 15201526705 0012322 0 ustar 00 /* Authors: Jason Tang <jtang@tresys.com>
*
* Copyright (C) 2005 Tresys Technology, LLC
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _SEPOL_AVRULE_BLOCK_H_
#define _SEPOL_AVRULE_BLOCK_H_
#include <sepol/policydb/policydb.h>
#ifdef __cplusplus
extern "C" {
#endif
extern avrule_block_t *avrule_block_create(void);
extern void avrule_block_destroy(avrule_block_t * x);
extern avrule_decl_t *avrule_decl_create(uint32_t decl_id);
extern void avrule_decl_destroy(avrule_decl_t * x);
extern void avrule_block_list_destroy(avrule_block_t * x);
extern avrule_decl_t *get_avrule_decl(policydb_t * p, uint32_t decl_id);
extern cond_list_t *get_decl_cond_list(policydb_t * p,
avrule_decl_t * decl,
cond_list_t * cond);
extern int is_id_enabled(char *id, policydb_t * p, int symbol_table);
extern int is_perm_enabled(char *class_id, char *perm_id, policydb_t * p);
#ifdef __cplusplus
}
#endif
#endif
sepol/policydb/link.h 0000644 00000001005 15201526705 0010600 0 ustar 00 /* Authors: Jason Tang <jtang@tresys.com>
* Joshua Brindle <jbrindle@tresys.com>
* Karl MacMillan <kmacmillan@mentalrootkit.com>
*/
#ifndef _SEPOL_POLICYDB_LINK_H
#define _SEPOL_POLICYDB_LINK_H
#include <sepol/handle.h>
#include <sepol/errcodes.h>
#include <sepol/policydb/policydb.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
extern int link_modules(sepol_handle_t * handle,
policydb_t * b, policydb_t ** mods, int len,
int verbose);
#ifdef __cplusplus
}
#endif
#endif
sepol/policydb/services.h 0000644 00000020607 15201526705 0011477 0 ustar 00
/* -*- linux-c -*- */
/*
* Author : Stephen Smalley, <sds@tycho.nsa.gov>
*/
#ifndef _SEPOL_POLICYDB_SERVICES_H_
#define _SEPOL_POLICYDB_SERVICES_H_
/*
* Security server interface.
*/
#include <sepol/policydb/flask_types.h>
#include <sepol/policydb/policydb.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Set the policydb and sidtab structures to be used by
the service functions. If not set, then these default
to private structures within libsepol that can only be
initialized and accessed via the service functions themselves.
Setting the structures explicitly allows a program to directly
manipulate them, e.g. checkpolicy populates the structures directly
from a source policy rather than from a binary policy. */
extern int sepol_set_policydb(policydb_t * p);
extern int sepol_set_sidtab(sidtab_t * s);
/* Modify a policydb for boolean settings. */
int sepol_genbools_policydb(policydb_t * policydb, const char *booleans);
/* Modify a policydb for user settings. */
int sepol_genusers_policydb(policydb_t * policydb, const char *usersdir);
/* Load the security policy. This initializes the policydb
and sidtab based on the provided binary policy. */
extern int sepol_load_policy(void *data, size_t len);
/*
* Compute access vectors based on a SID pair for
* the permissions in a particular class.
*/
extern int sepol_compute_av(sepol_security_id_t ssid, /* IN */
sepol_security_id_t tsid, /* IN */
sepol_security_class_t tclass, /* IN */
sepol_access_vector_t requested, /* IN */
struct sepol_av_decision *avd); /* OUT */
/* Same as above, but also return the reason(s) for any
denials of the requested permissions. */
#define SEPOL_COMPUTEAV_TE 0x1U
#define SEPOL_COMPUTEAV_CONS 0x2U
#define SEPOL_COMPUTEAV_RBAC 0x4U
#define SEPOL_COMPUTEAV_BOUNDS 0x8U
extern int sepol_compute_av_reason(sepol_security_id_t ssid,
sepol_security_id_t tsid,
sepol_security_class_t tclass,
sepol_access_vector_t requested,
struct sepol_av_decision *avd,
unsigned int *reason);
/*
* Same as above, but also returns the constraint expression calculations
* whether allowed or denied in a buffer. This buffer is allocated by
* this call and must be free'd by the caller using free(3). The contraint
* buffer will contain any constraints in infix notation.
* If the SHOW_GRANTED flag is set it will show granted and denied
* constraints. The default is to show only denied constraints.
*/
#define SHOW_GRANTED 1
extern int sepol_compute_av_reason_buffer(sepol_security_id_t ssid,
sepol_security_id_t tsid,
sepol_security_class_t tclass,
sepol_access_vector_t requested,
struct sepol_av_decision *avd,
unsigned int *reason,
char **reason_buf,
unsigned int flags);
/*
* Returns the mls/validatetrans constraint expression calculations in
* a buffer that must be free'd by the caller using free(3).
* If the SHOW_GRANTED flag is set it will show granted and denied
* mls/validatetrans (the default is to show only those denied).
*/
extern int sepol_validate_transition_reason_buffer(sepol_security_id_t oldsid,
sepol_security_id_t newsid,
sepol_security_id_t tasksid,
sepol_security_class_t tclass,
char **reason_buf,
unsigned int flags);
/*
* Return a class ID associated with the class string representation
* specified by `class_name'.
*/
extern int sepol_string_to_security_class(const char *class_name,
sepol_security_class_t *tclass);
/*
* Return a permission av bit associated with tclass and the string
* representation of the `perm_name'.
*/
extern int sepol_string_to_av_perm(sepol_security_class_t tclass,
const char *perm_name,
sepol_access_vector_t *av);
/*
* Compute a SID to use for labeling a new object in the
* class `tclass' based on a SID pair.
*/
extern int sepol_transition_sid(sepol_security_id_t ssid, /* IN */
sepol_security_id_t tsid, /* IN */
sepol_security_class_t tclass, /* IN */
sepol_security_id_t * out_sid); /* OUT */
/*
* Compute a SID to use when selecting a member of a
* polyinstantiated object of class `tclass' based on
* a SID pair.
*/
extern int sepol_member_sid(sepol_security_id_t ssid, /* IN */
sepol_security_id_t tsid, /* IN */
sepol_security_class_t tclass, /* IN */
sepol_security_id_t * out_sid); /* OUT */
/*
* Compute a SID to use for relabeling an object in the
* class `tclass' based on a SID pair.
*/
extern int sepol_change_sid(sepol_security_id_t ssid, /* IN */
sepol_security_id_t tsid, /* IN */
sepol_security_class_t tclass, /* IN */
sepol_security_id_t * out_sid); /* OUT */
/*
* Write the security context string representation of
* the context associated with `sid' into a dynamically
* allocated string of the correct size. Set `*scontext'
* to point to this string and set `*scontext_len' to
* the length of the string.
*/
extern int sepol_sid_to_context(sepol_security_id_t sid, /* IN */
sepol_security_context_t * scontext, /* OUT */
size_t * scontext_len); /* OUT */
/*
* Return a SID associated with the security context that
* has the string representation specified by `scontext'.
*/
extern int sepol_context_to_sid(const sepol_security_context_t scontext, /* IN */
size_t scontext_len, /* IN */
sepol_security_id_t * out_sid); /* OUT */
/*
* Generate the set of SIDs for legal security contexts
* for a given user that can be reached by `fromsid'.
* Set `*sids' to point to a dynamically allocated
* array containing the set of SIDs. Set `*nel' to the
* number of elements in the array.
*/
extern int sepol_get_user_sids(sepol_security_id_t callsid,
char *username,
sepol_security_id_t ** sids, uint32_t * nel);
/*
* Return the SIDs to use for an unlabeled file system
* that is being mounted from the device with the
* the kdevname `name'. The `fs_sid' SID is returned for
* the file system and the `file_sid' SID is returned
* for all files within that file system.
*/
extern int sepol_fs_sid(char *dev, /* IN */
sepol_security_id_t * fs_sid, /* OUT */
sepol_security_id_t * file_sid); /* OUT */
/*
* Return the SID of the port specified by
* `domain', `type', `protocol', and `port'.
*/
extern int sepol_port_sid(uint16_t domain,
uint16_t type,
uint8_t protocol,
uint16_t port, sepol_security_id_t * out_sid);
/*
* Return the SID of the ibpkey specified by
* `subnet prefix', and `pkey'.
*/
extern int sepol_ibpkey_sid(uint64_t subnet_prefix_p,
uint16_t pkey,
sepol_security_id_t *out_sid);
/*
* Return the SID of the ibendport specified by
* `dev_name', and `port'.
*/
extern int sepol_ibendport_sid(char *dev_name,
uint8_t port,
sepol_security_id_t *out_sid);
/*
* Return the SIDs to use for a network interface
* with the name `name'. The `if_sid' SID is returned for
* the interface and the `msg_sid' SID is returned as
* the default SID for messages received on the
* interface.
*/
extern int sepol_netif_sid(char *name,
sepol_security_id_t * if_sid,
sepol_security_id_t * msg_sid);
/*
* Return the SID of the node specified by the address
* `addr' where `addrlen' is the length of the address
* in bytes and `domain' is the communications domain or
* address family in which the address should be interpreted.
*/
extern int sepol_node_sid(uint16_t domain,
void *addr,
size_t addrlen, sepol_security_id_t * out_sid);
/*
* Return a value indicating how to handle labeling for the
* the specified filesystem type, and optionally return a SID
* for the filesystem object.
*/
#define SECURITY_FS_USE_XATTR 1 /* use xattr */
#define SECURITY_FS_USE_TRANS 2 /* use transition SIDs, e.g. devpts/tmpfs */
#define SECURITY_FS_USE_TASK 3 /* use task SIDs, e.g. pipefs/sockfs */
#define SECURITY_FS_USE_GENFS 4 /* use the genfs support */
#define SECURITY_FS_USE_NONE 5 /* no labeling support */
extern int sepol_fs_use(const char *fstype, /* IN */
unsigned int *behavior, /* OUT */
sepol_security_id_t * sid); /* OUT */
/*
* Return the SID to use for a file in a filesystem
* that cannot support a persistent label mapping or use another
* fixed labeling behavior like transition SIDs or task SIDs.
*/
extern int sepol_genfs_sid(const char *fstype, /* IN */
const char *name, /* IN */
sepol_security_class_t sclass, /* IN */
sepol_security_id_t * sid); /* OUT */
#ifdef __cplusplus
}
#endif
#endif
sepol/policydb/avtab.h 0000644 00000011207 15201526705 0010745 0 ustar 00
/* Author : Stephen Smalley, <sds@tycho.nsa.gov> */
/*
* Updated: Yuichi Nakamura <ynakam@hitachisoft.jp>
* Tuned number of hash slots for avtab to reduce memory usage
*/
/* Updated: Frank Mayer <mayerf@tresys.com> and Karl MacMillan <kmacmillan@tresys.com>
*
* Added conditional policy language extensions
*
* Copyright (C) 2003 Tresys Technology, LLC
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* FLASK */
/*
* An access vector table (avtab) is a hash table
* of access vectors and transition types indexed
* by a type pair and a class. An access vector
* table is used to represent the type enforcement
* tables.
*/
#ifndef _SEPOL_POLICYDB_AVTAB_H_
#define _SEPOL_POLICYDB_AVTAB_H_
#include <sys/types.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct avtab_key {
uint16_t source_type;
uint16_t target_type;
uint16_t target_class;
#define AVTAB_ALLOWED 0x0001
#define AVTAB_AUDITALLOW 0x0002
#define AVTAB_AUDITDENY 0x0004
#define AVTAB_NEVERALLOW 0x0080
#define AVTAB_AV (AVTAB_ALLOWED | AVTAB_AUDITALLOW | AVTAB_AUDITDENY)
#define AVTAB_TRANSITION 0x0010
#define AVTAB_MEMBER 0x0020
#define AVTAB_CHANGE 0x0040
#define AVTAB_TYPE (AVTAB_TRANSITION | AVTAB_MEMBER | AVTAB_CHANGE)
#define AVTAB_XPERMS_ALLOWED 0x0100
#define AVTAB_XPERMS_AUDITALLOW 0x0200
#define AVTAB_XPERMS_DONTAUDIT 0x0400
#define AVTAB_XPERMS_NEVERALLOW 0x0800
#define AVTAB_XPERMS (AVTAB_XPERMS_ALLOWED | AVTAB_XPERMS_AUDITALLOW | AVTAB_XPERMS_DONTAUDIT)
#define AVTAB_ENABLED_OLD 0x80000000
#define AVTAB_ENABLED 0x8000 /* reserved for used in cond_avtab */
uint16_t specified; /* what fields are specified */
} avtab_key_t;
typedef struct avtab_extended_perms {
#define AVTAB_XPERMS_IOCTLFUNCTION 0x01
#define AVTAB_XPERMS_IOCTLDRIVER 0x02
/* extension of the avtab_key specified */
uint8_t specified;
uint8_t driver;
uint32_t perms[8];
} avtab_extended_perms_t;
typedef struct avtab_datum {
uint32_t data; /* access vector or type */
avtab_extended_perms_t *xperms;
} avtab_datum_t;
typedef struct avtab_node *avtab_ptr_t;
struct avtab_node {
avtab_key_t key;
avtab_datum_t datum;
avtab_ptr_t next;
void *parse_context; /* generic context pointer used by parser;
* not saved in binary policy */
unsigned merged; /* flag for avtab_write only;
not saved in binary policy */
};
typedef struct avtab {
avtab_ptr_t *htable;
uint32_t nel; /* number of elements */
uint32_t nslot; /* number of hash slots */
uint32_t mask; /* mask to compute hash func */
} avtab_t;
extern int avtab_init(avtab_t *);
extern int avtab_alloc(avtab_t *, uint32_t);
extern int avtab_insert(avtab_t * h, avtab_key_t * k, avtab_datum_t * d);
extern avtab_datum_t *avtab_search(avtab_t * h, avtab_key_t * k);
extern void avtab_destroy(avtab_t * h);
extern int avtab_map(avtab_t * h,
int (*apply) (avtab_key_t * k,
avtab_datum_t * d, void *args), void *args);
extern void avtab_hash_eval(avtab_t * h, char *tag);
struct policy_file;
extern int avtab_read_item(struct policy_file *fp, uint32_t vers, avtab_t * a,
int (*insert) (avtab_t * a, avtab_key_t * k,
avtab_datum_t * d, void *p), void *p);
extern int avtab_read(avtab_t * a, struct policy_file *fp, uint32_t vers);
extern avtab_ptr_t avtab_insert_nonunique(avtab_t * h, avtab_key_t * key,
avtab_datum_t * datum);
extern avtab_ptr_t avtab_insert_with_parse_context(avtab_t * h,
avtab_key_t * key,
avtab_datum_t * datum,
void *parse_context);
extern avtab_ptr_t avtab_search_node(avtab_t * h, avtab_key_t * key);
extern avtab_ptr_t avtab_search_node_next(avtab_ptr_t node, int specified);
#define MAX_AVTAB_HASH_BITS 20
#define MAX_AVTAB_HASH_BUCKETS (1 << MAX_AVTAB_HASH_BITS)
#define MAX_AVTAB_HASH_MASK (MAX_AVTAB_HASH_BUCKETS-1)
/* avtab_alloc uses one bucket per 2-4 elements, so adjust to get maximum buckets */
#define MAX_AVTAB_SIZE (MAX_AVTAB_HASH_BUCKETS << 1)
#ifdef __cplusplus
}
#endif
#endif /* _AVTAB_H_ */
/* FLASK */
sepol/policydb/flask_types.h 0000644 00000003363 15201526705 0012200 0 ustar 00 /* -*- linux-c -*- */
/*
* Author : Stephen Smalley, <sds@tycho.nsa.gov>
*/
#ifndef _SEPOL_POLICYDB_FLASK_TYPES_H_
#define _SEPOL_POLICYDB_FLASK_TYPES_H_
/*
* The basic Flask types and constants.
*/
#include <sys/types.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* A security context is a set of security attributes
* associated with each subject and object controlled
* by the security policy. The security context type
* is defined as a variable-length string that can be
* interpreted by any application or user with an
* understanding of the security policy.
*/
typedef char *sepol_security_context_t;
/*
* An access vector (AV) is a collection of related permissions
* for a pair of SIDs. The bits within an access vector
* are interpreted differently depending on the class of
* the object. The access vector interpretations are specified
* in flask/access_vectors, and the corresponding constants
* for permissions are defined in the automatically generated
* header file av_permissions.h.
*/
typedef uint32_t sepol_access_vector_t;
/*
* Each object class is identified by a fixed-size value.
* The set of security classes is specified in flask/security_classes,
* with the corresponding constants defined in the automatically
* generated header file flask.h.
*/
typedef uint16_t sepol_security_class_t;
#define SEPOL_SECCLASS_NULL 0x0000 /* no class */
#define SELINUX_MAGIC 0xf97cff8c
#define SELINUX_MOD_MAGIC 0xf97cff8d
typedef uint32_t sepol_security_id_t;
#define SEPOL_SECSID_NULL 0
struct sepol_av_decision {
sepol_access_vector_t allowed;
sepol_access_vector_t decided;
sepol_access_vector_t auditallow;
sepol_access_vector_t auditdeny;
uint32_t seqno;
};
#ifdef __cplusplus
}
#endif
#endif
sepol/policydb/polcaps.h 0000644 00000001321 15201526705 0011305 0 ustar 00 #ifndef _SEPOL_POLICYDB_POLCAPS_H_
#define _SEPOL_POLICYDB_POLCAPS_H_
#ifdef __cplusplus
extern "C" {
#endif
/* Policy capabilities */
enum {
POLICYDB_CAPABILITY_NETPEER,
POLICYDB_CAPABILITY_OPENPERM,
POLICYDB_CAPABILITY_EXTSOCKCLASS,
POLICYDB_CAPABILITY_ALWAYSNETWORK,
POLICYDB_CAPABILITY_CGROUPSECLABEL,
POLICYDB_CAPABILITY_NNP_NOSUID_TRANSITION,
__POLICYDB_CAPABILITY_MAX
};
#define POLICYDB_CAPABILITY_MAX (__POLICYDB_CAPABILITY_MAX - 1)
/* Convert a capability name to number. */
extern int sepol_polcap_getnum(const char *name);
/* Convert a capability number to name. */
extern const char *sepol_polcap_getname(unsigned int capnum);
#ifdef __cplusplus
}
#endif
#endif /* _SEPOL_POLICYDB_POLCAPS_H_ */
sepol/policydb/flask.h 0000644 00000011600 15201526705 0010745 0 ustar 00 /* This file is automatically generated. Do not edit. */
#ifndef _SEPOL_POLICYDB_FLASK_H_
#define _SEPOL_POLICYDB_FLASK_H_
/*
* Security object class definitions
*/
#define SECCLASS_SECURITY 1
#define SECCLASS_PROCESS 2
#define SECCLASS_SYSTEM 3
#define SECCLASS_CAPABILITY 4
#define SECCLASS_FILESYSTEM 5
#define SECCLASS_FILE 6
#define SECCLASS_DIR 7
#define SECCLASS_FD 8
#define SECCLASS_LNK_FILE 9
#define SECCLASS_CHR_FILE 10
#define SECCLASS_BLK_FILE 11
#define SECCLASS_SOCK_FILE 12
#define SECCLASS_FIFO_FILE 13
#define SECCLASS_SOCKET 14
#define SECCLASS_TCP_SOCKET 15
#define SECCLASS_UDP_SOCKET 16
#define SECCLASS_RAWIP_SOCKET 17
#define SECCLASS_NODE 18
#define SECCLASS_NETIF 19
#define SECCLASS_NETLINK_SOCKET 20
#define SECCLASS_PACKET_SOCKET 21
#define SECCLASS_KEY_SOCKET 22
#define SECCLASS_UNIX_STREAM_SOCKET 23
#define SECCLASS_UNIX_DGRAM_SOCKET 24
#define SECCLASS_SEM 25
#define SECCLASS_MSG 26
#define SECCLASS_MSGQ 27
#define SECCLASS_SHM 28
#define SECCLASS_IPC 29
#define SECCLASS_PASSWD 30
#define SECCLASS_DRAWABLE 31
#define SECCLASS_WINDOW 32
#define SECCLASS_GC 33
#define SECCLASS_FONT 34
#define SECCLASS_COLORMAP 35
#define SECCLASS_PROPERTY 36
#define SECCLASS_CURSOR 37
#define SECCLASS_XCLIENT 38
#define SECCLASS_XINPUT 39
#define SECCLASS_XSERVER 40
#define SECCLASS_XEXTENSION 41
#define SECCLASS_PAX 42
#define SECCLASS_NETLINK_ROUTE_SOCKET 43
#define SECCLASS_NETLINK_FIREWALL_SOCKET 44
#define SECCLASS_NETLINK_TCPDIAG_SOCKET 45
#define SECCLASS_NETLINK_NFLOG_SOCKET 46
#define SECCLASS_NETLINK_XFRM_SOCKET 47
#define SECCLASS_NETLINK_SELINUX_SOCKET 48
#define SECCLASS_NETLINK_AUDIT_SOCKET 49
#define SECCLASS_NETLINK_IP6FW_SOCKET 50
#define SECCLASS_NETLINK_DNRT_SOCKET 51
#define SECCLASS_DBUS 52
/*
* Security identifier indices for initial entities
*/
#define SECINITSID_KERNEL 1
#define SECINITSID_SECURITY 2
#define SECINITSID_UNLABELED 3
#define SECINITSID_FS 4
#define SECINITSID_FILE 5
#define SECINITSID_FILE_LABELS 6
#define SECINITSID_INIT 7
#define SECINITSID_ANY_SOCKET 8
#define SECINITSID_PORT 9
#define SECINITSID_NETIF 10
#define SECINITSID_NETMSG 11
#define SECINITSID_NODE 12
#define SECINITSID_IGMP_PACKET 13
#define SECINITSID_ICMP_SOCKET 14
#define SECINITSID_TCP_SOCKET 15
#define SECINITSID_SYSCTL_MODPROBE 16
#define SECINITSID_SYSCTL 17
#define SECINITSID_SYSCTL_FS 18
#define SECINITSID_SYSCTL_KERNEL 19
#define SECINITSID_SYSCTL_NET 20
#define SECINITSID_SYSCTL_NET_UNIX 21
#define SECINITSID_SYSCTL_VM 22
#define SECINITSID_SYSCTL_DEV 23
#define SECINITSID_KMOD 24
#define SECINITSID_POLICY 25
#define SECINITSID_SCMP_PACKET 26
#define SECINITSID_DEVNULL 27
#define SECINITSID_NUM 27
#endif
sepol/policydb/policydb.h 0000644 00000062570 15201526705 0011466 0 ustar 00 /* Author : Stephen Smalley, <sds@tycho.nsa.gov> */
/*
* Updated: Joshua Brindle <jbrindle@tresys.com>
* Karl MacMillan <kmacmillan@tresys.com>
* Jason Tang <jtang@tresys.com>
*
* Module support
*
* Updated: Trusted Computer Solutions, Inc. <dgoeddel@trustedcs.com>
*
* Support for enhanced MLS infrastructure.
*
* Updated: Frank Mayer <mayerf@tresys.com> and Karl MacMillan <kmacmillan@tresys.com>
*
* Added conditional policy language extensions
*
* Updated: Red Hat, Inc. James Morris <jmorris@redhat.com>
*
* Fine-grained netlink support
* IPv6 support
* Code cleanup
*
* Copyright (C) 2004-2005 Trusted Computer Solutions, Inc.
* Copyright (C) 2003 - 2004 Tresys Technology, LLC
* Copyright (C) 2003 - 2004 Red Hat, Inc.
* Copyright (C) 2017 Mellanox Techonolgies Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* FLASK */
/*
* A policy database (policydb) specifies the
* configuration data for the security policy.
*/
#ifndef _SEPOL_POLICYDB_POLICYDB_H_
#define _SEPOL_POLICYDB_POLICYDB_H_
#include <stdio.h>
#include <stddef.h>
#include <sepol/policydb.h>
#include <sepol/policydb/flask_types.h>
#include <sepol/policydb/symtab.h>
#include <sepol/policydb/avtab.h>
#include <sepol/policydb/context.h>
#include <sepol/policydb/constraint.h>
#include <sepol/policydb/sidtab.h>
#define ERRMSG_LEN 1024
#define POLICYDB_SUCCESS 0
#define POLICYDB_ERROR -1
#define POLICYDB_UNSUPPORTED -2
#ifdef __cplusplus
extern "C" {
#endif
#define IB_DEVICE_NAME_MAX 64
/*
* A datum type is defined for each kind of symbol
* in the configuration data: individual permissions,
* common prefixes for access vectors, classes,
* users, roles, types, sensitivities, categories, etc.
*/
/* type set preserves data needed by modules such as *, ~ and attributes */
typedef struct type_set {
ebitmap_t types;
ebitmap_t negset;
#define TYPE_STAR 1
#define TYPE_COMP 2
uint32_t flags;
} type_set_t;
typedef struct role_set {
ebitmap_t roles;
#define ROLE_STAR 1
#define ROLE_COMP 2
uint32_t flags;
} role_set_t;
/* Permission attributes */
typedef struct perm_datum {
symtab_datum_t s;
} perm_datum_t;
/* Attributes of a common prefix for access vectors */
typedef struct common_datum {
symtab_datum_t s;
symtab_t permissions; /* common permissions */
} common_datum_t;
/* Class attributes */
typedef struct class_datum {
symtab_datum_t s;
char *comkey; /* common name */
common_datum_t *comdatum; /* common datum */
symtab_t permissions; /* class-specific permission symbol table */
constraint_node_t *constraints; /* constraints on class permissions */
constraint_node_t *validatetrans; /* special transition rules */
/* Options how a new object user and role should be decided */
#define DEFAULT_SOURCE 1
#define DEFAULT_TARGET 2
char default_user;
char default_role;
char default_type;
/* Options how a new object range should be decided */
#define DEFAULT_SOURCE_LOW 1
#define DEFAULT_SOURCE_HIGH 2
#define DEFAULT_SOURCE_LOW_HIGH 3
#define DEFAULT_TARGET_LOW 4
#define DEFAULT_TARGET_HIGH 5
#define DEFAULT_TARGET_LOW_HIGH 6
char default_range;
} class_datum_t;
/* Role attributes */
typedef struct role_datum {
symtab_datum_t s;
ebitmap_t dominates; /* set of roles dominated by this role */
type_set_t types; /* set of authorized types for role */
ebitmap_t cache; /* This is an expanded set used for context validation during parsing */
uint32_t bounds; /* bounds role, if exist */
#define ROLE_ROLE 0 /* regular role in kernel policies */
#define ROLE_ATTRIB 1 /* attribute */
uint32_t flavor;
ebitmap_t roles; /* roles with this attribute */
} role_datum_t;
typedef struct role_trans {
uint32_t role; /* current role */
uint32_t type; /* program executable type, or new object type */
uint32_t tclass; /* process class, or new object class */
uint32_t new_role; /* new role */
struct role_trans *next;
} role_trans_t;
typedef struct role_allow {
uint32_t role; /* current role */
uint32_t new_role; /* new role */
struct role_allow *next;
} role_allow_t;
/* filename_trans rules */
typedef struct filename_trans {
uint32_t stype;
uint32_t ttype;
uint32_t tclass;
char *name;
} filename_trans_t;
typedef struct filename_trans_datum {
uint32_t otype; /* expected of new object */
} filename_trans_datum_t;
/* Type attributes */
typedef struct type_datum {
symtab_datum_t s;
uint32_t primary; /* primary name? can be set to primary value if below is TYPE_ */
#define TYPE_TYPE 0 /* regular type or alias in kernel policies */
#define TYPE_ATTRIB 1 /* attribute */
#define TYPE_ALIAS 2 /* alias in modular policy */
uint32_t flavor;
ebitmap_t types; /* types with this attribute */
#define TYPE_FLAGS_PERMISSIVE (1 << 0)
#define TYPE_FLAGS_EXPAND_ATTR_TRUE (1 << 1)
#define TYPE_FLAGS_EXPAND_ATTR_FALSE (1 << 2)
#define TYPE_FLAGS_EXPAND_ATTR (TYPE_FLAGS_EXPAND_ATTR_TRUE | \
TYPE_FLAGS_EXPAND_ATTR_FALSE)
uint32_t flags;
uint32_t bounds; /* bounds type, if exist */
} type_datum_t;
/*
* Properties of type_datum
* available on the policy version >= (MOD_)POLICYDB_VERSION_BOUNDARY
*/
#define TYPEDATUM_PROPERTY_PRIMARY 0x0001
#define TYPEDATUM_PROPERTY_ATTRIBUTE 0x0002
#define TYPEDATUM_PROPERTY_ALIAS 0x0004 /* userspace only */
#define TYPEDATUM_PROPERTY_PERMISSIVE 0x0008 /* userspace only */
/* User attributes */
typedef struct user_datum {
symtab_datum_t s;
role_set_t roles; /* set of authorized roles for user */
mls_semantic_range_t range; /* MLS range (min. - max.) for user */
mls_semantic_level_t dfltlevel; /* default login MLS level for user */
ebitmap_t cache; /* This is an expanded set used for context validation during parsing */
mls_range_t exp_range; /* expanded range used for validation */
mls_level_t exp_dfltlevel; /* expanded range used for validation */
uint32_t bounds; /* bounds user, if exist */
} user_datum_t;
/* Sensitivity attributes */
typedef struct level_datum {
mls_level_t *level; /* sensitivity and associated categories */
unsigned char isalias; /* is this sensitivity an alias for another? */
unsigned char defined;
} level_datum_t;
/* Category attributes */
typedef struct cat_datum {
symtab_datum_t s;
unsigned char isalias; /* is this category an alias for another? */
} cat_datum_t;
typedef struct range_trans {
uint32_t source_type;
uint32_t target_type;
uint32_t target_class;
} range_trans_t;
/* Boolean data type */
typedef struct cond_bool_datum {
symtab_datum_t s;
int state;
#define COND_BOOL_FLAGS_TUNABLE 0x01 /* is this a tunable? */
uint32_t flags;
} cond_bool_datum_t;
struct cond_node;
typedef struct cond_node cond_list_t;
struct cond_av_list;
typedef struct class_perm_node {
uint32_t tclass;
uint32_t data; /* permissions or new type */
struct class_perm_node *next;
} class_perm_node_t;
#define xperm_test(x, p) (1 & (p[x >> 5] >> (x & 0x1f)))
#define xperm_set(x, p) (p[x >> 5] |= (1 << (x & 0x1f)))
#define xperm_clear(x, p) (p[x >> 5] &= ~(1 << (x & 0x1f)))
#define EXTENDED_PERMS_LEN 8
typedef struct av_extended_perms {
#define AVRULE_XPERMS_IOCTLFUNCTION 0x01
#define AVRULE_XPERMS_IOCTLDRIVER 0x02
uint8_t specified;
uint8_t driver;
/* 256 bits of permissions */
uint32_t perms[EXTENDED_PERMS_LEN];
} av_extended_perms_t;
typedef struct avrule {
/* these typedefs are almost exactly the same as those in avtab.h - they are
* here because of the need to include neverallow and dontaudit messages */
#define AVRULE_ALLOWED AVTAB_ALLOWED
#define AVRULE_AUDITALLOW AVTAB_AUDITALLOW
#define AVRULE_AUDITDENY AVTAB_AUDITDENY
#define AVRULE_DONTAUDIT 0x0008
#define AVRULE_NEVERALLOW AVTAB_NEVERALLOW
#define AVRULE_AV (AVRULE_ALLOWED | AVRULE_AUDITALLOW | AVRULE_AUDITDENY | AVRULE_DONTAUDIT | AVRULE_NEVERALLOW)
#define AVRULE_TRANSITION AVTAB_TRANSITION
#define AVRULE_MEMBER AVTAB_MEMBER
#define AVRULE_CHANGE AVTAB_CHANGE
#define AVRULE_TYPE (AVRULE_TRANSITION | AVRULE_MEMBER | AVRULE_CHANGE)
#define AVRULE_XPERMS_ALLOWED AVTAB_XPERMS_ALLOWED
#define AVRULE_XPERMS_AUDITALLOW AVTAB_XPERMS_AUDITALLOW
#define AVRULE_XPERMS_DONTAUDIT AVTAB_XPERMS_DONTAUDIT
#define AVRULE_XPERMS_NEVERALLOW AVTAB_XPERMS_NEVERALLOW
#define AVRULE_XPERMS (AVRULE_XPERMS_ALLOWED | AVRULE_XPERMS_AUDITALLOW | \
AVRULE_XPERMS_DONTAUDIT | AVRULE_XPERMS_NEVERALLOW)
uint32_t specified;
#define RULE_SELF 1
uint32_t flags;
type_set_t stypes;
type_set_t ttypes;
class_perm_node_t *perms;
av_extended_perms_t *xperms;
unsigned long line; /* line number from policy.conf where
* this rule originated */
/* source file name and line number (e.g. .te file) */
char *source_filename;
unsigned long source_line;
struct avrule *next;
} avrule_t;
typedef struct role_trans_rule {
role_set_t roles; /* current role */
type_set_t types; /* program executable type, or new object type */
ebitmap_t classes; /* process class, or new object class */
uint32_t new_role; /* new role */
struct role_trans_rule *next;
} role_trans_rule_t;
typedef struct role_allow_rule {
role_set_t roles; /* current role */
role_set_t new_roles; /* new roles */
struct role_allow_rule *next;
} role_allow_rule_t;
typedef struct filename_trans_rule {
type_set_t stypes;
type_set_t ttypes;
uint32_t tclass;
char *name;
uint32_t otype; /* new type */
struct filename_trans_rule *next;
} filename_trans_rule_t;
typedef struct range_trans_rule {
type_set_t stypes;
type_set_t ttypes;
ebitmap_t tclasses;
mls_semantic_range_t trange;
struct range_trans_rule *next;
} range_trans_rule_t;
/*
* The configuration data includes security contexts for
* initial SIDs, unlabeled file systems, TCP and UDP port numbers,
* network interfaces, and nodes. This structure stores the
* relevant data for one such entry. Entries of the same kind
* (e.g. all initial SIDs) are linked together into a list.
*/
typedef struct ocontext {
union {
char *name; /* name of initial SID, fs, netif, fstype, path */
struct {
uint8_t protocol;
uint16_t low_port;
uint16_t high_port;
} port; /* TCP or UDP port information */
struct {
uint32_t addr; /* network order */
uint32_t mask; /* network order */
} node; /* node information */
struct {
uint32_t addr[4]; /* network order */
uint32_t mask[4]; /* network order */
} node6; /* IPv6 node information */
uint32_t device;
uint16_t pirq;
struct {
uint64_t low_iomem;
uint64_t high_iomem;
} iomem;
struct {
uint32_t low_ioport;
uint32_t high_ioport;
} ioport;
struct {
uint64_t subnet_prefix;
uint16_t low_pkey;
uint16_t high_pkey;
} ibpkey;
struct {
char *dev_name;
uint8_t port;
} ibendport;
} u;
union {
uint32_t sclass; /* security class for genfs */
uint32_t behavior; /* labeling behavior for fs_use */
} v;
context_struct_t context[2]; /* security context(s) */
sepol_security_id_t sid[2]; /* SID(s) */
struct ocontext *next;
} ocontext_t;
typedef struct genfs {
char *fstype;
struct ocontext *head;
struct genfs *next;
} genfs_t;
/* symbol table array indices */
#define SYM_COMMONS 0
#define SYM_CLASSES 1
#define SYM_ROLES 2
#define SYM_TYPES 3
#define SYM_USERS 4
#define SYM_BOOLS 5
#define SYM_LEVELS 6
#define SYM_CATS 7
#define SYM_NUM 8
/* object context array indices */
#define OCON_ISID 0 /* initial SIDs */
#define OCON_FS 1 /* unlabeled file systems */
#define OCON_PORT 2 /* TCP and UDP port numbers */
#define OCON_NETIF 3 /* network interfaces */
#define OCON_NODE 4 /* nodes */
#define OCON_FSUSE 5 /* fs_use */
#define OCON_NODE6 6 /* IPv6 nodes */
#define OCON_IBPKEY 7 /* Infiniband PKEY */
#define OCON_IBENDPORT 8 /* Infiniband End Port */
/* object context array indices for Xen */
#define OCON_XEN_ISID 0 /* initial SIDs */
#define OCON_XEN_PIRQ 1 /* physical irqs */
#define OCON_XEN_IOPORT 2 /* io ports */
#define OCON_XEN_IOMEM 3 /* io memory */
#define OCON_XEN_PCIDEVICE 4 /* pci devices */
#define OCON_XEN_DEVICETREE 5 /* device tree node */
/* OCON_NUM needs to be the largest index in any platform's ocontext array */
#define OCON_NUM 9
/* section: module information */
/* scope_index_t holds all of the symbols that are in scope in a
* particular situation. The bitmaps are indices (and thus must
* subtract one) into the global policydb->scope array. */
typedef struct scope_index {
ebitmap_t scope[SYM_NUM];
#define p_classes_scope scope[SYM_CLASSES]
#define p_roles_scope scope[SYM_ROLES]
#define p_types_scope scope[SYM_TYPES]
#define p_users_scope scope[SYM_USERS]
#define p_bools_scope scope[SYM_BOOLS]
#define p_sens_scope scope[SYM_LEVELS]
#define p_cat_scope scope[SYM_CATS]
/* this array maps from class->value to the permissions within
* scope. if bit (perm->value - 1) is set in map
* class_perms_map[class->value - 1] then that permission is
* enabled for this class within this decl. */
ebitmap_t *class_perms_map;
/* total number of classes in class_perms_map array */
uint32_t class_perms_len;
} scope_index_t;
/* a list of declarations for a particular avrule_decl */
/* These two structs declare a block of policy that has TE and RBAC
* statements and declarations. The root block (the global policy)
* can never have an ELSE branch. */
typedef struct avrule_decl {
uint32_t decl_id;
uint32_t enabled; /* whether this block is enabled */
cond_list_t *cond_list;
avrule_t *avrules;
role_trans_rule_t *role_tr_rules;
role_allow_rule_t *role_allow_rules;
range_trans_rule_t *range_tr_rules;
scope_index_t required; /* symbols needed to activate this block */
scope_index_t declared; /* symbols declared within this block */
/* type transition rules with a 'name' component */
filename_trans_rule_t *filename_trans_rules;
/* for additive statements (type attribute, roles, and users) */
symtab_t symtab[SYM_NUM];
/* In a linked module this will contain the name of the module
* from which this avrule_decl originated. */
char *module_name;
struct avrule_decl *next;
} avrule_decl_t;
typedef struct avrule_block {
avrule_decl_t *branch_list;
avrule_decl_t *enabled; /* pointer to which branch is enabled. this is
used in linking and never written to disk */
#define AVRULE_OPTIONAL 1
uint32_t flags; /* any flags for this block, currently just optional */
struct avrule_block *next;
} avrule_block_t;
/* Every identifier has its own scope datum. The datum describes if
* the item is to be included into the final policy during
* expansion. */
typedef struct scope_datum {
/* Required for this decl */
#define SCOPE_REQ 1
/* Declared in this decl */
#define SCOPE_DECL 2
uint32_t scope;
uint32_t *decl_ids;
uint32_t decl_ids_len;
/* decl_ids is a list of avrule_decl's that declare/require
* this symbol. If scope==SCOPE_DECL then this is a list of
* declarations. If the symbol may only be declared once
* (types, bools) then decl_ids_len will be exactly 1. For
* implicitly declared things (roles, users) then decl_ids_len
* will be at least 1. */
} scope_datum_t;
/* The policy database */
typedef struct policydb {
#define POLICY_KERN SEPOL_POLICY_KERN
#define POLICY_BASE SEPOL_POLICY_BASE
#define POLICY_MOD SEPOL_POLICY_MOD
uint32_t policy_type;
char *name;
char *version;
int target_platform;
/* Set when the policydb is modified such that writing is unsupported */
int unsupported_format;
/* Whether this policydb is mls, should always be set */
int mls;
/* symbol tables */
symtab_t symtab[SYM_NUM];
#define p_commons symtab[SYM_COMMONS]
#define p_classes symtab[SYM_CLASSES]
#define p_roles symtab[SYM_ROLES]
#define p_types symtab[SYM_TYPES]
#define p_users symtab[SYM_USERS]
#define p_bools symtab[SYM_BOOLS]
#define p_levels symtab[SYM_LEVELS]
#define p_cats symtab[SYM_CATS]
/* symbol names indexed by (value - 1) */
char **sym_val_to_name[SYM_NUM];
#define p_common_val_to_name sym_val_to_name[SYM_COMMONS]
#define p_class_val_to_name sym_val_to_name[SYM_CLASSES]
#define p_role_val_to_name sym_val_to_name[SYM_ROLES]
#define p_type_val_to_name sym_val_to_name[SYM_TYPES]
#define p_user_val_to_name sym_val_to_name[SYM_USERS]
#define p_bool_val_to_name sym_val_to_name[SYM_BOOLS]
#define p_sens_val_to_name sym_val_to_name[SYM_LEVELS]
#define p_cat_val_to_name sym_val_to_name[SYM_CATS]
/* class, role, and user attributes indexed by (value - 1) */
class_datum_t **class_val_to_struct;
role_datum_t **role_val_to_struct;
user_datum_t **user_val_to_struct;
type_datum_t **type_val_to_struct;
/* module stuff section -- used in parsing and for modules */
/* keep track of the scope for every identifier. these are
* hash tables, where the key is the identifier name and value
* a scope_datum_t. as a convenience, one may use the
* p_*_macros (cf. struct scope_index_t declaration). */
symtab_t scope[SYM_NUM];
/* module rule storage */
avrule_block_t *global;
/* avrule_decl index used for link/expand */
avrule_decl_t **decl_val_to_struct;
/* compiled storage of rules - use for the kernel policy */
/* type enforcement access vectors and transitions */
avtab_t te_avtab;
/* bools indexed by (value - 1) */
cond_bool_datum_t **bool_val_to_struct;
/* type enforcement conditional access vectors and transitions */
avtab_t te_cond_avtab;
/* linked list indexing te_cond_avtab by conditional */
cond_list_t *cond_list;
/* role transitions */
role_trans_t *role_tr;
/* role allows */
role_allow_t *role_allow;
/* security contexts of initial SIDs, unlabeled file systems,
TCP or UDP port numbers, network interfaces and nodes */
ocontext_t *ocontexts[OCON_NUM];
/* security contexts for files in filesystems that cannot support
a persistent label mapping or use another
fixed labeling behavior. */
genfs_t *genfs;
/* range transitions table (range_trans_key -> mls_range) */
hashtab_t range_tr;
/* file transitions with the last path component */
hashtab_t filename_trans;
ebitmap_t *type_attr_map;
ebitmap_t *attr_type_map; /* not saved in the binary policy */
ebitmap_t policycaps;
/* this bitmap is referenced by type NOT the typical type-1 used in other
bitmaps. Someday the 0 bit may be used for global permissive */
ebitmap_t permissive_map;
unsigned policyvers;
unsigned handle_unknown;
} policydb_t;
struct sepol_policydb {
struct policydb p;
};
extern int policydb_init(policydb_t * p);
extern int policydb_from_image(sepol_handle_t * handle,
void *data, size_t len, policydb_t * policydb);
extern int policydb_to_image(sepol_handle_t * handle,
policydb_t * policydb, void **newdata,
size_t * newlen);
extern int policydb_index_classes(policydb_t * p);
extern int policydb_index_bools(policydb_t * p);
extern int policydb_index_others(sepol_handle_t * handle, policydb_t * p,
unsigned int verbose);
extern int policydb_role_cache(hashtab_key_t key,
hashtab_datum_t datum,
void *arg);
extern int policydb_user_cache(hashtab_key_t key,
hashtab_datum_t datum,
void *arg);
extern int policydb_reindex_users(policydb_t * p);
extern void policydb_destroy(policydb_t * p);
extern int policydb_load_isids(policydb_t * p, sidtab_t * s);
extern int policydb_sort_ocontexts(policydb_t *p);
/* Deprecated */
extern int policydb_context_isvalid(const policydb_t * p,
const context_struct_t * c);
extern void symtabs_destroy(symtab_t * symtab);
extern int scope_destroy(hashtab_key_t key, hashtab_datum_t datum, void *p);
extern void class_perm_node_init(class_perm_node_t * x);
extern void type_set_init(type_set_t * x);
extern void type_set_destroy(type_set_t * x);
extern int type_set_cpy(type_set_t * dst, type_set_t * src);
extern int type_set_or_eq(type_set_t * dst, type_set_t * other);
extern void role_set_init(role_set_t * x);
extern void role_set_destroy(role_set_t * x);
extern void avrule_init(avrule_t * x);
extern void avrule_destroy(avrule_t * x);
extern void avrule_list_destroy(avrule_t * x);
extern void role_trans_rule_init(role_trans_rule_t * x);
extern void role_trans_rule_list_destroy(role_trans_rule_t * x);
extern void filename_trans_rule_init(filename_trans_rule_t * x);
extern void filename_trans_rule_list_destroy(filename_trans_rule_t * x);
extern void role_datum_init(role_datum_t * x);
extern void role_datum_destroy(role_datum_t * x);
extern void role_allow_rule_init(role_allow_rule_t * x);
extern void role_allow_rule_destroy(role_allow_rule_t * x);
extern void role_allow_rule_list_destroy(role_allow_rule_t * x);
extern void range_trans_rule_init(range_trans_rule_t *x);
extern void range_trans_rule_destroy(range_trans_rule_t *x);
extern void range_trans_rule_list_destroy(range_trans_rule_t *x);
extern void type_datum_init(type_datum_t * x);
extern void type_datum_destroy(type_datum_t * x);
extern void user_datum_init(user_datum_t * x);
extern void user_datum_destroy(user_datum_t * x);
extern void level_datum_init(level_datum_t * x);
extern void level_datum_destroy(level_datum_t * x);
extern void cat_datum_init(cat_datum_t * x);
extern void cat_datum_destroy(cat_datum_t * x);
extern int check_assertion(policydb_t *p, avrule_t *avrule);
extern int check_assertions(sepol_handle_t * handle,
policydb_t * p, avrule_t * avrules);
extern int symtab_insert(policydb_t * x, uint32_t sym,
hashtab_key_t key, hashtab_datum_t datum,
uint32_t scope, uint32_t avrule_decl_id,
uint32_t * value);
/* A policy "file" may be a memory region referenced by a (data, len) pair
or a file referenced by a FILE pointer. */
typedef struct policy_file {
#define PF_USE_MEMORY 0
#define PF_USE_STDIO 1
#define PF_LEN 2 /* total up length in len field */
unsigned type;
char *data;
size_t len;
size_t size;
FILE *fp;
struct sepol_handle *handle;
} policy_file_t;
struct sepol_policy_file {
struct policy_file pf;
};
extern void policy_file_init(policy_file_t * x);
extern int policydb_read(policydb_t * p, struct policy_file *fp,
unsigned int verbose);
extern int avrule_read_list(policydb_t * p, avrule_t ** avrules,
struct policy_file *fp);
extern int policydb_write(struct policydb *p, struct policy_file *pf);
extern int policydb_set_target_platform(policydb_t *p, int platform);
#define PERM_SYMTAB_SIZE 32
/* Identify specific policy version changes */
#define POLICYDB_VERSION_BASE 15
#define POLICYDB_VERSION_BOOL 16
#define POLICYDB_VERSION_IPV6 17
#define POLICYDB_VERSION_NLCLASS 18
#define POLICYDB_VERSION_VALIDATETRANS 19
#define POLICYDB_VERSION_MLS 19
#define POLICYDB_VERSION_AVTAB 20
#define POLICYDB_VERSION_RANGETRANS 21
#define POLICYDB_VERSION_POLCAP 22
#define POLICYDB_VERSION_PERMISSIVE 23
#define POLICYDB_VERSION_BOUNDARY 24
#define POLICYDB_VERSION_FILENAME_TRANS 25
#define POLICYDB_VERSION_ROLETRANS 26
#define POLICYDB_VERSION_NEW_OBJECT_DEFAULTS 27
#define POLICYDB_VERSION_DEFAULT_TYPE 28
#define POLICYDB_VERSION_CONSTRAINT_NAMES 29
#define POLICYDB_VERSION_XEN_DEVICETREE 30 /* Xen-specific */
#define POLICYDB_VERSION_XPERMS_IOCTL 30 /* Linux-specific */
#define POLICYDB_VERSION_INFINIBAND 31 /* Linux-specific */
/* Range of policy versions we understand*/
#define POLICYDB_VERSION_MIN POLICYDB_VERSION_BASE
#define POLICYDB_VERSION_MAX POLICYDB_VERSION_INFINIBAND
/* Module versions and specific changes*/
#define MOD_POLICYDB_VERSION_BASE 4
#define MOD_POLICYDB_VERSION_VALIDATETRANS 5
#define MOD_POLICYDB_VERSION_MLS 5
#define MOD_POLICYDB_VERSION_RANGETRANS 6
#define MOD_POLICYDB_VERSION_MLS_USERS 6
#define MOD_POLICYDB_VERSION_POLCAP 7
#define MOD_POLICYDB_VERSION_PERMISSIVE 8
#define MOD_POLICYDB_VERSION_BOUNDARY 9
#define MOD_POLICYDB_VERSION_BOUNDARY_ALIAS 10
#define MOD_POLICYDB_VERSION_FILENAME_TRANS 11
#define MOD_POLICYDB_VERSION_ROLETRANS 12
#define MOD_POLICYDB_VERSION_ROLEATTRIB 13
#define MOD_POLICYDB_VERSION_TUNABLE_SEP 14
#define MOD_POLICYDB_VERSION_NEW_OBJECT_DEFAULTS 15
#define MOD_POLICYDB_VERSION_DEFAULT_TYPE 16
#define MOD_POLICYDB_VERSION_CONSTRAINT_NAMES 17
#define MOD_POLICYDB_VERSION_XPERMS_IOCTL 18
#define MOD_POLICYDB_VERSION_INFINIBAND 19
#define MOD_POLICYDB_VERSION_MIN MOD_POLICYDB_VERSION_BASE
#define MOD_POLICYDB_VERSION_MAX MOD_POLICYDB_VERSION_INFINIBAND
#define POLICYDB_CONFIG_MLS 1
/* macros to check policy feature */
/* TODO: add other features here */
#define policydb_has_boundary_feature(p) \
(((p)->policy_type == POLICY_KERN \
&& p->policyvers >= POLICYDB_VERSION_BOUNDARY) || \
((p)->policy_type != POLICY_KERN \
&& p->policyvers >= MOD_POLICYDB_VERSION_BOUNDARY))
/* the config flags related to unknown classes/perms are bits 2 and 3 */
#define DENY_UNKNOWN SEPOL_DENY_UNKNOWN
#define REJECT_UNKNOWN SEPOL_REJECT_UNKNOWN
#define ALLOW_UNKNOWN SEPOL_ALLOW_UNKNOWN
#define POLICYDB_CONFIG_UNKNOWN_MASK (DENY_UNKNOWN | REJECT_UNKNOWN | ALLOW_UNKNOWN)
#define OBJECT_R "object_r"
#define OBJECT_R_VAL 1
#define POLICYDB_MAGIC SELINUX_MAGIC
#define POLICYDB_STRING "SE Linux"
#define POLICYDB_XEN_STRING "XenFlask"
#define POLICYDB_STRING_MAX_LENGTH 32
#define POLICYDB_MOD_MAGIC SELINUX_MOD_MAGIC
#define POLICYDB_MOD_STRING "SE Linux Module"
#ifdef __cplusplus
}
#endif
#endif /* _POLICYDB_H_ */
/* FLASK */
sepol/policydb/sidtab.h 0000644 00000003670 15201526705 0011123 0 ustar 00 /* Author : Stephen Smalley, <sds@tycho.nsa.gov> */
/* FLASK */
/*
* A security identifier table (sidtab) is a hash table
* of security context structures indexed by SID value.
*/
#ifndef _SEPOL_POLICYDB_SIDTAB_H_
#define _SEPOL_POLICYDB_SIDTAB_H_
#include <sepol/policydb/context.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct sidtab_node {
sepol_security_id_t sid; /* security identifier */
context_struct_t context; /* security context structure */
struct sidtab_node *next;
} sidtab_node_t;
typedef struct sidtab_node *sidtab_ptr_t;
#define SIDTAB_HASH_BITS 7
#define SIDTAB_HASH_BUCKETS (1 << SIDTAB_HASH_BITS)
#define SIDTAB_HASH_MASK (SIDTAB_HASH_BUCKETS-1)
#define SIDTAB_SIZE SIDTAB_HASH_BUCKETS
typedef struct {
sidtab_ptr_t *htable;
unsigned int nel; /* number of elements */
unsigned int next_sid; /* next SID to allocate */
unsigned char shutdown;
} sidtab_t;
extern int sepol_sidtab_init(sidtab_t * s);
extern int sepol_sidtab_insert(sidtab_t * s,
sepol_security_id_t sid,
context_struct_t * context);
extern context_struct_t *sepol_sidtab_search(sidtab_t * s,
sepol_security_id_t sid);
extern int sepol_sidtab_map(sidtab_t * s,
int (*apply) (sepol_security_id_t sid,
context_struct_t * context,
void *args), void *args);
extern void sepol_sidtab_map_remove_on_error(sidtab_t * s,
int (*apply) (sepol_security_id_t
s,
context_struct_t *
context, void *args),
void *args);
extern int sepol_sidtab_context_to_sid(sidtab_t * s, /* IN */
context_struct_t * context, /* IN */
sepol_security_id_t * sid); /* OUT */
extern void sepol_sidtab_hash_eval(sidtab_t * h, char *tag);
extern void sepol_sidtab_destroy(sidtab_t * s);
extern void sepol_sidtab_set(sidtab_t * dst, sidtab_t * src);
extern void sepol_sidtab_shutdown(sidtab_t * s);
#ifdef __cplusplus
}
#endif
#endif /* _SIDTAB_H_ */
/* FLASK */
sepol/policydb/util.h 0000644 00000002665 15201526705 0010635 0 ustar 00 /* Authors: Karl MacMillan <kmacmillan@tresys.com>
*
* A set of utility functions that aid policy decision when dealing
* with hierarchal namespaces.
*
* Copyright (C) 2006 Tresys Technology, LLC
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __SEPOL_UTIL_H__
#define __SEPOL_UTIL_H__
#ifdef __cplusplus
extern "C" {
#endif
extern int add_i_to_a(uint32_t i, uint32_t * cnt, uint32_t ** a);
extern char *sepol_av_to_string(policydb_t * policydbp, uint32_t tclass,
sepol_access_vector_t av);
char *sepol_extended_perms_to_string(avtab_extended_perms_t *xperms);
/*
* The tokenize function may be used to
* replace sscanf
*/
extern int tokenize(char *line_buf, char delim, int num_args, ...);
#ifdef __cplusplus
}
#endif
#endif
sepol/policydb/conditional.h 0000644 00000011175 15201526705 0012157 0 ustar 00 /* Authors: Karl MacMillan <kmacmillan@tresys.com>
* Frank Mayer <mayerf@tresys.com>
*
* Copyright (C) 2003 - 2005 Tresys Technology, LLC
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _SEPOL_POLICYDB_CONDITIONAL_H_
#define _SEPOL_POLICYDB_CONDITIONAL_H_
#include <sepol/policydb/flask_types.h>
#include <sepol/policydb/avtab.h>
#include <sepol/policydb/symtab.h>
#include <sepol/policydb/policydb.h>
#ifdef __cplusplus
extern "C" {
#endif
#define COND_EXPR_MAXDEPTH 10
/* this is the max unique bools in a conditional expression
* for which we precompute all outcomes for the expression.
*
* NOTE - do _NOT_ use value greater than 5 because
* cond_node_t->expr_pre_comp can only hold at most 32 values
*/
#define COND_MAX_BOOLS 5
/*
* A conditional expression is a list of operators and operands
* in reverse polish notation.
*/
typedef struct cond_expr {
#define COND_BOOL 1 /* plain bool */
#define COND_NOT 2 /* !bool */
#define COND_OR 3 /* bool || bool */
#define COND_AND 4 /* bool && bool */
#define COND_XOR 5 /* bool ^ bool */
#define COND_EQ 6 /* bool == bool */
#define COND_NEQ 7 /* bool != bool */
#define COND_LAST COND_NEQ
uint32_t expr_type;
uint32_t bool;
struct cond_expr *next;
} cond_expr_t;
/*
* Each cond_node_t contains a list of rules to be enabled/disabled
* depending on the current value of the conditional expression. This
* struct is for that list.
*/
typedef struct cond_av_list {
avtab_ptr_t node;
struct cond_av_list *next;
} cond_av_list_t;
/*
* A cond node represents a conditional block in a policy. It
* contains a conditional expression, the current state of the expression,
* two lists of rules to enable/disable depending on the value of the
* expression (the true list corresponds to if and the false list corresponds
* to else)..
*/
typedef struct cond_node {
int cur_state;
cond_expr_t *expr;
/* these true/false lists point into te_avtab when that is used */
cond_av_list_t *true_list;
cond_av_list_t *false_list;
/* and these are used during parsing and for modules */
avrule_t *avtrue_list;
avrule_t *avfalse_list;
/* these fields are not written to binary policy */
unsigned int nbools;
uint32_t bool_ids[COND_MAX_BOOLS];
uint32_t expr_pre_comp;
struct cond_node *next;
/* a tunable conditional, calculated and used at expansion */
#define COND_NODE_FLAGS_TUNABLE 0x01
uint32_t flags;
} cond_node_t;
extern int cond_evaluate_expr(policydb_t * p, cond_expr_t * expr);
extern cond_expr_t *cond_copy_expr(cond_expr_t * expr);
extern int cond_expr_equal(cond_node_t * a, cond_node_t * b);
extern int cond_normalize_expr(policydb_t * p, cond_node_t * cn);
extern void cond_node_destroy(cond_node_t * node);
extern void cond_expr_destroy(cond_expr_t * expr);
extern cond_node_t *cond_node_find(policydb_t * p,
cond_node_t * needle, cond_node_t * haystack,
int *was_created);
extern cond_node_t *cond_node_create(policydb_t * p, cond_node_t * node);
extern cond_node_t *cond_node_search(policydb_t * p, cond_node_t * list,
cond_node_t * cn);
extern int evaluate_conds(policydb_t * p);
extern avtab_datum_t *cond_av_list_search(avtab_key_t * key,
cond_av_list_t * cond_list);
extern void cond_av_list_destroy(cond_av_list_t * list);
extern void cond_optimize_lists(cond_list_t * cl);
extern int cond_policydb_init(policydb_t * p);
extern void cond_policydb_destroy(policydb_t * p);
extern void cond_list_destroy(cond_list_t * list);
extern int cond_init_bool_indexes(policydb_t * p);
extern int cond_destroy_bool(hashtab_key_t key, hashtab_datum_t datum, void *p);
extern int cond_index_bool(hashtab_key_t key, hashtab_datum_t datum,
void *datap);
extern int cond_read_bool(policydb_t * p, hashtab_t h, struct policy_file *fp);
extern int cond_read_list(policydb_t * p, cond_list_t ** list, void *fp);
extern void cond_compute_av(avtab_t * ctab, avtab_key_t * key,
struct sepol_av_decision *avd);
#ifdef __cplusplus
}
#endif
#endif /* _CONDITIONAL_H_ */
sepol/policydb/expand.h 0000644 00000007110 15201526705 0011125 0 ustar 00 /* Authors: Jason Tang <jtang@tresys.com>
* Joshua Brindle <jbrindle@tresys.com>
* Karl MacMillan <kmacmillan@tresys.com>
*
* A set of utility functions that aid policy decision when dealing
* with hierarchal items.
*
* Copyright (C) 2005 Tresys Technology, LLC
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _SEPOL_POLICYDB_EXPAND_H
#define _SEPOL_POLICYDB_EXPAND_H
#include <stddef.h>
#include <sepol/handle.h>
#include <sepol/policydb/conditional.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Expand only the avrules for a module. It is valid for this function
* to expand base into itself (i.e. base == out); the typemap for
* this special case should map type[i] to i+1. Likewise the boolmap
* should map bool[i] to i + 1. This function optionally expands
* neverallow rules. If neverallow rules are expanded, there is no
* need to copy them and doing so could cause duplicate entries when
* base == out. If the neverallow rules are not expanded, they are
* just copied to the destination policy so that assertion checking
* can be performed after expand. No assertion or hierarchy checking
* is performed by this function.
*/
extern int expand_module_avrules(sepol_handle_t * handle, policydb_t * base,
policydb_t * out, uint32_t * typemap, uint32_t * boolmap,
uint32_t * rolemap, uint32_t * usermap,
int verbose, int expand_neverallow);
/*
* Expand all parts of a module. Neverallow rules are not expanded (only
* copied). It is not valid to expand base into itself. If check is non-zero,
* performs hierarchy and assertion checking.
*/
extern int expand_module(sepol_handle_t * handle,
policydb_t * base, policydb_t * out,
int verbose, int check);
extern int convert_type_ebitmap(ebitmap_t * src, ebitmap_t * dst,
uint32_t * typemap);
extern int expand_convert_type_set(policydb_t * p, uint32_t * typemap,
type_set_t * set, ebitmap_t * types,
unsigned char alwaysexpand);
extern int type_set_expand(type_set_t * set, ebitmap_t * t, policydb_t * p,
unsigned char alwaysexpand);
extern int role_set_expand(role_set_t * x, ebitmap_t * r, policydb_t * out, policydb_t * base, uint32_t * rolemap);
extern int mls_semantic_level_expand(mls_semantic_level_t *sl, mls_level_t *l,
policydb_t *p, sepol_handle_t *h);
extern int mls_semantic_range_expand(mls_semantic_range_t *sr, mls_range_t *r,
policydb_t *p, sepol_handle_t *h);
extern int expand_rule(sepol_handle_t * handle,
policydb_t * source_pol,
avrule_t * source_rule, avtab_t * dest_avtab,
cond_av_list_t ** cond, cond_av_list_t ** other,
int enabled);
extern int expand_avtab(policydb_t * p, avtab_t * a, avtab_t * expa);
extern int expand_cond_av_list(policydb_t * p, cond_av_list_t * l,
cond_av_list_t ** newl, avtab_t * expa);
#ifdef __cplusplus
}
#endif
#endif
sepol/policydb/hashtab.h 0000644 00000010450 15201526705 0011261 0 ustar 00 /* Author : Stephen Smalley, <sds@tycho.nsa.gov> */
/* FLASK */
/*
* A hash table (hashtab) maintains associations between
* key values and datum values. The type of the key values
* and the type of the datum values is arbitrary. The
* functions for hash computation and key comparison are
* provided by the creator of the table.
*/
#ifndef _SEPOL_POLICYDB_HASHTAB_H_
#define _SEPOL_POLICYDB_HASHTAB_H_
#include <sepol/errcodes.h>
#include <stdint.h>
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef char *hashtab_key_t; /* generic key type */
typedef const char *const_hashtab_key_t; /* constant generic key type */
typedef void *hashtab_datum_t; /* generic datum type */
typedef struct hashtab_node *hashtab_ptr_t;
typedef struct hashtab_node {
hashtab_key_t key;
hashtab_datum_t datum;
hashtab_ptr_t next;
} hashtab_node_t;
typedef struct hashtab_val {
hashtab_ptr_t *htable; /* hash table */
unsigned int size; /* number of slots in hash table */
uint32_t nel; /* number of elements in hash table */
unsigned int (*hash_value) (struct hashtab_val * h, const_hashtab_key_t key); /* hash function */
int (*keycmp) (struct hashtab_val * h, const_hashtab_key_t key1, const_hashtab_key_t key2); /* key comparison function */
} hashtab_val_t;
typedef hashtab_val_t *hashtab_t;
/*
Creates a new hash table with the specified characteristics.
Returns NULL if insufficent space is available or
the new hash table otherwise.
*/
extern hashtab_t hashtab_create(unsigned int (*hash_value) (hashtab_t h,
const_hashtab_key_t
key),
int (*keycmp) (hashtab_t h,
const_hashtab_key_t key1,
const_hashtab_key_t key2),
unsigned int size);
/*
Inserts the specified (key, datum) pair into the specified hash table.
Returns SEPOL_ENOMEM if insufficient space is available or
SEPOL_EEXIST if there is already an entry with the same key or
SEPOL_OK otherwise.
*/
extern int hashtab_insert(hashtab_t h, hashtab_key_t k, hashtab_datum_t d);
/*
Removes the entry with the specified key from the hash table.
Applies the specified destroy function to (key,datum,args) for
the entry.
Returns SEPOL_ENOENT if no entry has the specified key or
SEPOL_OK otherwise.
*/
extern int hashtab_remove(hashtab_t h, hashtab_key_t k,
void (*destroy) (hashtab_key_t k,
hashtab_datum_t d,
void *args), void *args);
/*
Insert or replace the specified (key, datum) pair in the specified
hash table. If an entry for the specified key already exists,
then the specified destroy function is applied to (key,datum,args)
for the entry prior to replacing the entry's contents.
Returns SEPOL_ENOMEM if insufficient space is available or
SEPOL_OK otherwise.
*/
extern int hashtab_replace(hashtab_t h, hashtab_key_t k, hashtab_datum_t d,
void (*destroy) (hashtab_key_t k,
hashtab_datum_t d,
void *args), void *args);
/*
Searches for the entry with the specified key in the hash table.
Returns NULL if no entry has the specified key or
the datum of the entry otherwise.
*/
extern hashtab_datum_t hashtab_search(hashtab_t h, const_hashtab_key_t k);
/*
Destroys the specified hash table.
*/
extern void hashtab_destroy(hashtab_t h);
/*
Applies the specified apply function to (key,datum,args)
for each entry in the specified hash table.
The order in which the function is applied to the entries
is dependent upon the internal structure of the hash table.
If apply returns a non-zero status, then hashtab_map will cease
iterating through the hash table and will propagate the error
return to its caller.
*/
extern int hashtab_map(hashtab_t h,
int (*apply) (hashtab_key_t k,
hashtab_datum_t d,
void *args), void *args);
/*
Same as hashtab_map, except that if apply returns a non-zero status,
then the (key,datum) pair will be removed from the hashtab and the
destroy function will be applied to (key,datum,args).
*/
extern void hashtab_map_remove_on_error(hashtab_t h,
int (*apply) (hashtab_key_t k,
hashtab_datum_t d,
void *args),
void (*destroy) (hashtab_key_t k,
hashtab_datum_t d,
void *args),
void *args);
extern void hashtab_hash_eval(hashtab_t h, char *tag);
#ifdef __cplusplus
}
#endif
#endif
sepol/policydb/hierarchy.h 0000644 00000003432 15201526705 0011627 0 ustar 00 /* Authors: Jason Tang <jtang@tresys.com>
* Joshua Brindle <jbrindle@tresys.com>
* Karl MacMillan <kmacmillan@tresys.com>
*
* A set of utility functions that aid policy decision when dealing
* with hierarchal items.
*
* Copyright (C) 2005 Tresys Technology, LLC
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _SEPOL_POLICYDB_HIERARCHY_H_
#define _SEPOL_POLICYDB_HIERARCHY_H_
#include <sepol/policydb/avtab.h>
#include <sepol/policydb/policydb.h>
#ifdef __cplusplus
extern "C" {
#endif
extern int hierarchy_add_bounds(sepol_handle_t *handle, policydb_t *p);
extern void bounds_destroy_bad(avtab_ptr_t cur);
extern int bounds_check_type(sepol_handle_t *handle, policydb_t *p, uint32_t child,
uint32_t parent, avtab_ptr_t *bad, int *numbad);
extern int bounds_check_users(sepol_handle_t *handle, policydb_t *p);
extern int bounds_check_roles(sepol_handle_t *handle, policydb_t *p);
extern int bounds_check_types(sepol_handle_t *handle, policydb_t *p);
extern int hierarchy_check_constraints(sepol_handle_t * handle, policydb_t * p);
#ifdef __cplusplus
}
#endif
#endif
sepol/handle.h 0000644 00000002561 15201526705 0007301 0 ustar 00 #ifndef _SEPOL_HANDLE_H_
#define _SEPOL_HANDLE_H_
#ifdef __cplusplus
extern "C" {
#endif
struct sepol_handle;
typedef struct sepol_handle sepol_handle_t;
/* Create and return a sepol handle. */
sepol_handle_t *sepol_handle_create(void);
/* Get whether or not dontaudits will be disabled, same values as
* specified by set_disable_dontaudit. This value reflects the state
* your system will be set to upon commit, not necessarily its
* current state.*/
int sepol_get_disable_dontaudit(sepol_handle_t * sh);
/* Set whether or not to disable dontaudits, 0 is default and does
* not disable dontaudits, 1 disables them */
void sepol_set_disable_dontaudit(sepol_handle_t * sh, int disable_dontaudit);
/* Set whether module_expand() should consume the base policy passed in.
* This should reduce the amount of memory required to expand the policy. */
void sepol_set_expand_consume_base(sepol_handle_t * sh, int consume_base);
/* Destroy a sepol handle. */
void sepol_handle_destroy(sepol_handle_t *);
/* Get whether or not needless unused branch of tunables would be preserved */
int sepol_get_preserve_tunables(sepol_handle_t * sh);
/* Set whether or not to preserve the needless unused branch of tunables,
* 0 is default and discard such branch, 1 preserves them */
void sepol_set_preserve_tunables(sepol_handle_t * sh, int preserve_tunables);
#ifdef __cplusplus
}
#endif
#endif
sepol/user_record.h 0000644 00000004520 15201526705 0010357 0 ustar 00 #ifndef _SEPOL_USER_RECORD_H_
#define _SEPOL_USER_RECORD_H_
#include <stddef.h>
#include <sepol/handle.h>
#ifdef __cplusplus
extern "C" {
#endif
struct sepol_user;
struct sepol_user_key;
typedef struct sepol_user sepol_user_t;
typedef struct sepol_user_key sepol_user_key_t;
/* Key */
extern int sepol_user_key_create(sepol_handle_t * handle,
const char *name, sepol_user_key_t ** key);
extern void sepol_user_key_unpack(const sepol_user_key_t * key,
const char **name);
extern int sepol_user_key_extract(sepol_handle_t * handle,
const sepol_user_t * user,
sepol_user_key_t ** key_ptr);
extern void sepol_user_key_free(sepol_user_key_t * key);
extern int sepol_user_compare(const sepol_user_t * user,
const sepol_user_key_t * key);
extern int sepol_user_compare2(const sepol_user_t * user,
const sepol_user_t * user2);
/* Name */
extern const char *sepol_user_get_name(const sepol_user_t * user);
extern int sepol_user_set_name(sepol_handle_t * handle,
sepol_user_t * user, const char *name);
/* MLS */
extern const char *sepol_user_get_mlslevel(const sepol_user_t * user);
extern int sepol_user_set_mlslevel(sepol_handle_t * handle,
sepol_user_t * user, const char *mls_level);
extern const char *sepol_user_get_mlsrange(const sepol_user_t * user);
extern int sepol_user_set_mlsrange(sepol_handle_t * handle,
sepol_user_t * user, const char *mls_range);
/* Role management */
extern int sepol_user_get_num_roles(const sepol_user_t * user);
extern int sepol_user_add_role(sepol_handle_t * handle,
sepol_user_t * user, const char *role);
extern void sepol_user_del_role(sepol_user_t * user, const char *role);
extern int sepol_user_has_role(const sepol_user_t * user, const char *role);
extern int sepol_user_get_roles(sepol_handle_t * handle,
const sepol_user_t * user,
const char ***roles_arr,
unsigned int *num_roles);
extern int sepol_user_set_roles(sepol_handle_t * handle,
sepol_user_t * user,
const char **roles_arr, unsigned int num_roles);
/* Create/Clone/Destroy */
extern int sepol_user_create(sepol_handle_t * handle, sepol_user_t ** user_ptr);
extern int sepol_user_clone(sepol_handle_t * handle,
const sepol_user_t * user,
sepol_user_t ** user_ptr);
extern void sepol_user_free(sepol_user_t * user);
#ifdef __cplusplus
}
#endif
#endif
sepol/policydb.h 0000644 00000011127 15201526705 0007651 0 ustar 00 #ifndef _SEPOL_POLICYDB_H_
#define _SEPOL_POLICYDB_H_
#include <stddef.h>
#include <stdio.h>
#include <sepol/handle.h>
#ifdef __cplusplus
extern "C" {
#endif
struct sepol_policy_file;
typedef struct sepol_policy_file sepol_policy_file_t;
struct sepol_policydb;
typedef struct sepol_policydb sepol_policydb_t;
/* Policy file public interfaces. */
/* Create and free memory associated with a policy file. */
extern int sepol_policy_file_create(sepol_policy_file_t ** pf);
extern void sepol_policy_file_free(sepol_policy_file_t * pf);
/*
* Set the policy file to represent a binary policy memory image.
* Subsequent operations using the policy file will read and write
* the image located at the specified address with the specified length.
* If 'len' is 0, then merely compute the necessary length upon
* subsequent policydb write operations in order to determine the
* necessary buffer size to allocate.
*/
extern void sepol_policy_file_set_mem(sepol_policy_file_t * pf,
char *data, size_t len);
/*
* Get the size of the buffer needed to store a policydb write
* previously done on this policy file.
*/
extern int sepol_policy_file_get_len(sepol_policy_file_t * pf, size_t * len);
/*
* Set the policy file to represent a FILE.
* Subsequent operations using the policy file will read and write
* to the FILE.
*/
extern void sepol_policy_file_set_fp(sepol_policy_file_t * pf, FILE * fp);
/*
* Associate a handle with a policy file, for use in
* error reporting from subsequent calls that take the
* policy file as an argument.
*/
extern void sepol_policy_file_set_handle(sepol_policy_file_t * pf,
sepol_handle_t * handle);
/* Policydb public interfaces. */
/* Create and free memory associated with a policydb. */
extern int sepol_policydb_create(sepol_policydb_t ** p);
extern void sepol_policydb_free(sepol_policydb_t * p);
/* Legal types of policies that the policydb can represent. */
#define SEPOL_POLICY_KERN 0
#define SEPOL_POLICY_BASE 1
#define SEPOL_POLICY_MOD 2
/*
* Range of policy versions for the kernel policy type supported
* by this library.
*/
extern int sepol_policy_kern_vers_min(void);
extern int sepol_policy_kern_vers_max(void);
/*
* Set the policy type as specified, and automatically initialize the
* policy version accordingly to the maximum version supported for the
* policy type.
* Returns -1 if the policy type is not legal.
*/
extern int sepol_policydb_set_typevers(sepol_policydb_t * p, unsigned int type);
/*
* Set the policy version to a different value.
* Returns -1 if the policy version is not in the supported range for
* the (previously set) policy type.
*/
extern int sepol_policydb_set_vers(sepol_policydb_t * p, unsigned int vers);
/* Set how to handle unknown class/perms. */
#define SEPOL_DENY_UNKNOWN 0
#define SEPOL_REJECT_UNKNOWN 2
#define SEPOL_ALLOW_UNKNOWN 4
extern int sepol_policydb_set_handle_unknown(sepol_policydb_t * p,
unsigned int handle_unknown);
/* Set the target platform */
#define SEPOL_TARGET_SELINUX 0
#define SEPOL_TARGET_XEN 1
extern int sepol_policydb_set_target_platform(sepol_policydb_t * p,
int target_platform);
/*
* Read a policydb from a policy file.
* This automatically sets the type and version based on the
* image contents.
*/
extern int sepol_policydb_read(sepol_policydb_t * p, sepol_policy_file_t * pf);
/*
* Write a policydb to a policy file.
* The generated image will be in the binary format corresponding
* to the policy version associated with the policydb.
*/
extern int sepol_policydb_write(sepol_policydb_t * p, sepol_policy_file_t * pf);
/*
* Extract a policydb from a binary policy memory image.
* This is equivalent to sepol_policydb_read with a policy file
* set to refer to memory.
*/
extern int sepol_policydb_from_image(sepol_handle_t * handle,
void *data, size_t len,
sepol_policydb_t * p);
/*
* Generate a binary policy memory image from a policydb.
* This is equivalent to sepol_policydb_write with a policy file
* set to refer to memory, but internally handles computing the
* necessary length and allocating an appropriately sized memory
* buffer for the caller.
*/
extern int sepol_policydb_to_image(sepol_handle_t * handle,
sepol_policydb_t * p,
void **newdata, size_t * newlen);
/*
* Check whether the policydb has MLS enabled.
*/
extern int sepol_policydb_mls_enabled(const sepol_policydb_t * p);
/*
* Check whether the compatibility mode for SELinux network
* checks should be enabled when using this policy.
*/
extern int sepol_policydb_compat_net(const sepol_policydb_t * p);
#ifdef __cplusplus
}
#endif
#endif
sepol/node_record.h 0000644 00000005366 15201526705 0010337 0 ustar 00 #ifndef _SEPOL_NODE_RECORD_H_
#define _SEPOL_NODE_RECORD_H_
#include <stddef.h>
#include <sepol/context_record.h>
#include <sepol/handle.h>
#ifdef __cplusplus
extern "C" {
#endif
struct sepol_node;
struct sepol_node_key;
typedef struct sepol_node sepol_node_t;
typedef struct sepol_node_key sepol_node_key_t;
#define SEPOL_PROTO_IP4 0
#define SEPOL_PROTO_IP6 1
/* Key */
extern int sepol_node_compare(const sepol_node_t * node,
const sepol_node_key_t * key);
extern int sepol_node_compare2(const sepol_node_t * node,
const sepol_node_t * node2);
extern int sepol_node_key_create(sepol_handle_t * handle,
const char *addr,
const char *mask,
int proto, sepol_node_key_t ** key_ptr);
extern void sepol_node_key_unpack(const sepol_node_key_t * key,
const char **addr,
const char **mask, int *proto);
extern int sepol_node_key_extract(sepol_handle_t * handle,
const sepol_node_t * node,
sepol_node_key_t ** key_ptr);
extern void sepol_node_key_free(sepol_node_key_t * key);
/* Address */
extern int sepol_node_get_addr(sepol_handle_t * handle,
const sepol_node_t * node, char **addr);
extern int sepol_node_get_addr_bytes(sepol_handle_t * handle,
const sepol_node_t * node,
char **addr, size_t * addr_sz);
extern int sepol_node_set_addr(sepol_handle_t * handle,
sepol_node_t * node,
int proto, const char *addr);
extern int sepol_node_set_addr_bytes(sepol_handle_t * handle,
sepol_node_t * node,
const char *addr, size_t addr_sz);
/* Netmask */
extern int sepol_node_get_mask(sepol_handle_t * handle,
const sepol_node_t * node, char **mask);
extern int sepol_node_get_mask_bytes(sepol_handle_t * handle,
const sepol_node_t * node,
char **mask, size_t * mask_sz);
extern int sepol_node_set_mask(sepol_handle_t * handle,
sepol_node_t * node,
int proto, const char *mask);
extern int sepol_node_set_mask_bytes(sepol_handle_t * handle,
sepol_node_t * node,
const char *mask, size_t mask_sz);
/* Protocol */
extern int sepol_node_get_proto(const sepol_node_t * node);
extern void sepol_node_set_proto(sepol_node_t * node, int proto);
extern const char *sepol_node_get_proto_str(int proto);
/* Context */
extern sepol_context_t *sepol_node_get_con(const sepol_node_t * node);
extern int sepol_node_set_con(sepol_handle_t * handle,
sepol_node_t * node, sepol_context_t * con);
/* Create/Clone/Destroy */
extern int sepol_node_create(sepol_handle_t * handle, sepol_node_t ** node_ptr);
extern int sepol_node_clone(sepol_handle_t * handle,
const sepol_node_t * node,
sepol_node_t ** node_ptr);
extern void sepol_node_free(sepol_node_t * node);
#ifdef __cplusplus
}
#endif
#endif
sepol/ibpkey_record.h 0000644 00000004375 15201526705 0010674 0 ustar 00 #ifndef _SEPOL_IBPKEY_RECORD_H_
#define _SEPOL_IBPKEY_RECORD_H_
#include <stddef.h>
#include <stdint.h>
#include <sepol/context_record.h>
#include <sepol/handle.h>
#define INET6_ADDRLEN 16
#ifdef __cplusplus
extern "C" {
#endif
struct sepol_ibpkey;
struct sepol_ibpkey_key;
typedef struct sepol_ibpkey sepol_ibpkey_t;
typedef struct sepol_ibpkey_key sepol_ibpkey_key_t;
extern int sepol_ibpkey_compare(const sepol_ibpkey_t *ibpkey,
const sepol_ibpkey_key_t *key);
extern int sepol_ibpkey_compare2(const sepol_ibpkey_t *ibpkey,
const sepol_ibpkey_t *ibpkey2);
extern int sepol_ibpkey_key_create(sepol_handle_t *handle,
const char *subnet_prefix,
int low, int high,
sepol_ibpkey_key_t **key_ptr);
extern void sepol_ibpkey_key_unpack(const sepol_ibpkey_key_t *key,
uint64_t *subnet_prefix,
int *low, int *high);
extern int sepol_ibpkey_key_extract(sepol_handle_t *handle,
const sepol_ibpkey_t *ibpkey,
sepol_ibpkey_key_t **key_ptr);
extern void sepol_ibpkey_key_free(sepol_ibpkey_key_t *key);
extern int sepol_ibpkey_get_low(const sepol_ibpkey_t *ibpkey);
extern int sepol_ibpkey_get_high(const sepol_ibpkey_t *ibpkey);
extern void sepol_ibpkey_set_pkey(sepol_ibpkey_t *ibpkey, int pkey_num);
extern void sepol_ibpkey_set_range(sepol_ibpkey_t *ibpkey, int low, int high);
extern int sepol_ibpkey_get_subnet_prefix(sepol_handle_t *handle,
const sepol_ibpkey_t *ibpkey,
char **subnet_prefix);
extern uint64_t sepol_ibpkey_get_subnet_prefix_bytes(const sepol_ibpkey_t *ibpkey);
extern int sepol_ibpkey_set_subnet_prefix(sepol_handle_t *handle,
sepol_ibpkey_t *ibpkey,
const char *subnet_prefix);
extern void sepol_ibpkey_set_subnet_prefix_bytes(sepol_ibpkey_t *ibpkey,
uint64_t subnet_prefix);
extern sepol_context_t *sepol_ibpkey_get_con(const sepol_ibpkey_t *ibpkey);
extern int sepol_ibpkey_set_con(sepol_handle_t *handle,
sepol_ibpkey_t *ibpkey, sepol_context_t *con);
extern int sepol_ibpkey_create(sepol_handle_t *handle, sepol_ibpkey_t **ibpkey_ptr);
extern int sepol_ibpkey_clone(sepol_handle_t *handle,
const sepol_ibpkey_t *ibpkey,
sepol_ibpkey_t **ibpkey_ptr);
extern void sepol_ibpkey_free(sepol_ibpkey_t *ibpkey);
#ifdef __cplusplus
}
#endif
#endif
sepol/kernel_to_conf.h 0000644 00000000176 15201526705 0011035 0 ustar 00 #include <stdlib.h>
#include <sepol/policydb/policydb.h>
int sepol_kernel_policydb_to_conf(FILE *fp, struct policydb *pdb);
sepol/iface_record.h 0000644 00000003460 15201526705 0010452 0 ustar 00 #ifndef _SEPOL_IFACE_RECORD_H_
#define _SEPOL_IFACE_RECORD_H_
#include <sepol/handle.h>
#include <sepol/context_record.h>
#ifdef __cplusplus
extern "C" {
#endif
struct sepol_iface;
struct sepol_iface_key;
typedef struct sepol_iface sepol_iface_t;
typedef struct sepol_iface_key sepol_iface_key_t;
/* Key */
extern int sepol_iface_compare(const sepol_iface_t * iface,
const sepol_iface_key_t * key);
extern int sepol_iface_compare2(const sepol_iface_t * iface,
const sepol_iface_t * iface2);
extern void sepol_iface_key_unpack(const sepol_iface_key_t * key,
const char **name);
extern int sepol_iface_key_create(sepol_handle_t * handle,
const char *name,
sepol_iface_key_t ** key_ptr);
extern int sepol_iface_key_extract(sepol_handle_t * handle,
const sepol_iface_t * iface,
sepol_iface_key_t ** key_ptr);
extern void sepol_iface_key_free(sepol_iface_key_t * key);
/* Name */
extern const char *sepol_iface_get_name(const sepol_iface_t * iface);
extern int sepol_iface_set_name(sepol_handle_t * handle,
sepol_iface_t * iface, const char *name);
/* Context */
extern sepol_context_t *sepol_iface_get_ifcon(const sepol_iface_t * iface);
extern int sepol_iface_set_ifcon(sepol_handle_t * handle,
sepol_iface_t * iface, sepol_context_t * con);
extern sepol_context_t *sepol_iface_get_msgcon(const sepol_iface_t * iface);
extern int sepol_iface_set_msgcon(sepol_handle_t * handle,
sepol_iface_t * iface, sepol_context_t * con);
/* Create/Clone/Destroy */
extern int sepol_iface_create(sepol_handle_t * handle,
sepol_iface_t ** iface_ptr);
extern int sepol_iface_clone(sepol_handle_t * handle,
const sepol_iface_t * iface,
sepol_iface_t ** iface_ptr);
extern void sepol_iface_free(sepol_iface_t * iface);
#ifdef __cplusplus
}
#endif
#endif
sepol/debug.h 0000644 00000001717 15201526705 0007136 0 ustar 00 #ifndef _SEPOL_DEBUG_H_
#define _SEPOL_DEBUG_H_
#include <sepol/handle.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Deprecated */
extern void sepol_debug(int on);
/* End deprecated */
#define SEPOL_MSG_ERR 1
#define SEPOL_MSG_WARN 2
#define SEPOL_MSG_INFO 3
extern int sepol_msg_get_level(sepol_handle_t * handle);
extern const char *sepol_msg_get_channel(sepol_handle_t * handle);
extern const char *sepol_msg_get_fname(sepol_handle_t * handle);
/* Set the messaging callback.
* By the default, the callback will print
* the message on standard output, in a
* particular format. Passing NULL here
* indicates that messaging should be suppressed */
extern void sepol_msg_set_callback(sepol_handle_t * handle,
#ifdef __GNUC__
__attribute__ ((format(printf, 3, 4)))
#endif
void (*msg_callback) (void *varg,
sepol_handle_t *
handle,
const char *fmt, ...),
void *msg_callback_arg);
#ifdef __cplusplus
}
#endif
#endif
sepol/booleans.h 0000644 00000004304 15201526705 0007645 0 ustar 00 #ifndef _SEPOL_BOOLEANS_H_
#define _SEPOL_BOOLEANS_H_
#include <stddef.h>
#include <sepol/policydb.h>
#include <sepol/boolean_record.h>
#include <sepol/handle.h>
#ifdef __cplusplus
extern "C" {
#endif
/*--------------compatibility--------------*/
/* Given an existing binary policy (starting at 'data', with length 'len')
and a boolean configuration file named by 'boolpath', rewrite the binary
policy for the boolean settings in the boolean configuration file.
The binary policy is rewritten in place in memory.
Returns 0 upon success, or -1 otherwise. */
extern int sepol_genbools(void *data, size_t len, const char *boolpath);
/* Given an existing binary policy (starting at 'data', with length 'len')
and boolean settings specified by the parallel arrays ('names', 'values')
with 'nel' elements, rewrite the binary policy for the boolean settings.
The binary policy is rewritten in place in memory.
Returns 0 upon success or -1 otherwise. */
extern int sepol_genbools_array(void *data, size_t len,
char **names, int *values, int nel);
/*---------------end compatbility------------*/
/* Set the specified boolean */
extern int sepol_bool_set(sepol_handle_t * handle,
sepol_policydb_t * policydb,
const sepol_bool_key_t * key,
const sepol_bool_t * data);
/* Return the number of booleans */
extern int sepol_bool_count(sepol_handle_t * handle,
const sepol_policydb_t * p, unsigned int *response);
/* Check if the specified boolean exists */
extern int sepol_bool_exists(sepol_handle_t * handle,
const sepol_policydb_t * policydb,
const sepol_bool_key_t * key, int *response);
/* Query a boolean - returns the boolean, or NULL if not found */
extern int sepol_bool_query(sepol_handle_t * handle,
const sepol_policydb_t * p,
const sepol_bool_key_t * key,
sepol_bool_t ** response);
/* Iterate the booleans
* The handler may return:
* -1 to signal an error condition,
* 1 to signal successful exit
* 0 to signal continue */
extern int sepol_bool_iterate(sepol_handle_t * handle,
const sepol_policydb_t * policydb,
int (*fn) (const sepol_bool_t * boolean,
void *fn_arg), void *arg);
#ifdef __cplusplus
}
#endif
#endif
sepol/nodes.h 0000644 00000002440 15201526705 0007152 0 ustar 00 #ifndef _SEPOL_NODES_H_
#define _SEPOL_NODES_H_
#include <sepol/handle.h>
#include <sepol/policydb.h>
#include <sepol/node_record.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Return the number of nodes */
extern int sepol_node_count(sepol_handle_t * handle,
const sepol_policydb_t * p, unsigned int *response);
/* Check if a node exists */
extern int sepol_node_exists(sepol_handle_t * handle,
const sepol_policydb_t * policydb,
const sepol_node_key_t * key, int *response);
/* Query a node - returns the node, or NULL if not found */
extern int sepol_node_query(sepol_handle_t * handle,
const sepol_policydb_t * policydb,
const sepol_node_key_t * key,
sepol_node_t ** response);
/* Modify a node, or add it, if the key is not found */
extern int sepol_node_modify(sepol_handle_t * handle,
sepol_policydb_t * policydb,
const sepol_node_key_t * key,
const sepol_node_t * data);
/* Iterate the nodes
* The handler may return:
* -1 to signal an error condition,
* 1 to signal successful exit
* 0 to signal continue */
extern int sepol_node_iterate(sepol_handle_t * handle,
const sepol_policydb_t * policydb,
int (*fn) (const sepol_node_t * node,
void *fn_arg), void *arg);
#ifdef __cplusplus
}
#endif
#endif
sepol/port_record.h 0000644 00000003737 15201526705 0010376 0 ustar 00 #ifndef _SEPOL_PORT_RECORD_H_
#define _SEPOL_PORT_RECORD_H_
#include <sepol/context_record.h>
#include <sepol/handle.h>
#ifdef __cplusplus
extern "C" {
#endif
struct sepol_port;
struct sepol_port_key;
typedef struct sepol_port sepol_port_t;
typedef struct sepol_port_key sepol_port_key_t;
#define SEPOL_PROTO_UDP 0
#define SEPOL_PROTO_TCP 1
#define SEPOL_PROTO_DCCP 2
#define SEPOL_PROTO_SCTP 3
/* Key */
extern int sepol_port_compare(const sepol_port_t * port,
const sepol_port_key_t * key);
extern int sepol_port_compare2(const sepol_port_t * port,
const sepol_port_t * port2);
extern int sepol_port_key_create(sepol_handle_t * handle,
int low, int high, int proto,
sepol_port_key_t ** key_ptr);
extern void sepol_port_key_unpack(const sepol_port_key_t * key,
int *low, int *high, int *proto);
extern int sepol_port_key_extract(sepol_handle_t * handle,
const sepol_port_t * port,
sepol_port_key_t ** key_ptr);
extern void sepol_port_key_free(sepol_port_key_t * key);
/* Protocol */
extern int sepol_port_get_proto(const sepol_port_t * port);
extern void sepol_port_set_proto(sepol_port_t * port, int proto);
extern const char *sepol_port_get_proto_str(int proto);
/* Port */
extern int sepol_port_get_low(const sepol_port_t * port);
extern int sepol_port_get_high(const sepol_port_t * port);
extern void sepol_port_set_port(sepol_port_t * port, int port_num);
extern void sepol_port_set_range(sepol_port_t * port, int low, int high);
/* Context */
extern sepol_context_t *sepol_port_get_con(const sepol_port_t * port);
extern int sepol_port_set_con(sepol_handle_t * handle,
sepol_port_t * port, sepol_context_t * con);
/* Create/Clone/Destroy */
extern int sepol_port_create(sepol_handle_t * handle, sepol_port_t ** port_ptr);
extern int sepol_port_clone(sepol_handle_t * handle,
const sepol_port_t * port,
sepol_port_t ** port_ptr);
extern void sepol_port_free(sepol_port_t * port);
#ifdef __cplusplus
}
#endif
#endif
sepol/kernel_to_cil.h 0000644 00000000175 15201526705 0010656 0 ustar 00 #include <stdlib.h>
#include <sepol/policydb/policydb.h>
int sepol_kernel_policydb_to_cil(FILE *fp, struct policydb *pdb);
aio.h 0000644 00000016440 15201526705 0005475 0 ustar 00 /* Copyright (C) 1996-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
/*
* ISO/IEC 9945-1:1996 6.7: Asynchronous Input and Output
*/
#ifndef _AIO_H
#define _AIO_H 1
#include <features.h>
#include <sys/types.h>
#include <bits/types/sigevent_t.h>
#include <bits/sigevent-consts.h>
#include <bits/types/struct_timespec.h>
__BEGIN_DECLS
/* Asynchronous I/O control block. */
struct aiocb
{
int aio_fildes; /* File desriptor. */
int aio_lio_opcode; /* Operation to be performed. */
int aio_reqprio; /* Request priority offset. */
volatile void *aio_buf; /* Location of buffer. */
size_t aio_nbytes; /* Length of transfer. */
struct sigevent aio_sigevent; /* Signal number and value. */
/* Internal members. */
struct aiocb *__next_prio;
int __abs_prio;
int __policy;
int __error_code;
__ssize_t __return_value;
#ifndef __USE_FILE_OFFSET64
__off_t aio_offset; /* File offset. */
char __pad[sizeof (__off64_t) - sizeof (__off_t)];
#else
__off64_t aio_offset; /* File offset. */
#endif
char __glibc_reserved[32];
};
/* The same for the 64bit offsets. Please note that the members aio_fildes
to __return_value have to be the same in aiocb and aiocb64. */
#ifdef __USE_LARGEFILE64
struct aiocb64
{
int aio_fildes; /* File desriptor. */
int aio_lio_opcode; /* Operation to be performed. */
int aio_reqprio; /* Request priority offset. */
volatile void *aio_buf; /* Location of buffer. */
size_t aio_nbytes; /* Length of transfer. */
struct sigevent aio_sigevent; /* Signal number and value. */
/* Internal members. */
struct aiocb *__next_prio;
int __abs_prio;
int __policy;
int __error_code;
__ssize_t __return_value;
__off64_t aio_offset; /* File offset. */
char __glibc_reserved[32];
};
#endif
#ifdef __USE_GNU
/* To customize the implementation one can use the following struct.
This implementation follows the one in Irix. */
struct aioinit
{
int aio_threads; /* Maximal number of threads. */
int aio_num; /* Number of expected simultanious requests. */
int aio_locks; /* Not used. */
int aio_usedba; /* Not used. */
int aio_debug; /* Not used. */
int aio_numusers; /* Not used. */
int aio_idle_time; /* Number of seconds before idle thread
terminates. */
int aio_reserved;
};
#endif
/* Return values of cancelation function. */
enum
{
AIO_CANCELED,
#define AIO_CANCELED AIO_CANCELED
AIO_NOTCANCELED,
#define AIO_NOTCANCELED AIO_NOTCANCELED
AIO_ALLDONE
#define AIO_ALLDONE AIO_ALLDONE
};
/* Operation codes for `aio_lio_opcode'. */
enum
{
LIO_READ,
#define LIO_READ LIO_READ
LIO_WRITE,
#define LIO_WRITE LIO_WRITE
LIO_NOP
#define LIO_NOP LIO_NOP
};
/* Synchronization options for `lio_listio' function. */
enum
{
LIO_WAIT,
#define LIO_WAIT LIO_WAIT
LIO_NOWAIT
#define LIO_NOWAIT LIO_NOWAIT
};
/* Allow user to specify optimization. */
#ifdef __USE_GNU
extern void aio_init (const struct aioinit *__init) __THROW __nonnull ((1));
#endif
#ifndef __USE_FILE_OFFSET64
/* Enqueue read request for given number of bytes and the given priority. */
extern int aio_read (struct aiocb *__aiocbp) __THROW __nonnull ((1));
/* Enqueue write request for given number of bytes and the given priority. */
extern int aio_write (struct aiocb *__aiocbp) __THROW __nonnull ((1));
/* Initiate list of I/O requests. */
extern int lio_listio (int __mode,
struct aiocb *const __list[__restrict_arr],
int __nent, struct sigevent *__restrict __sig)
__THROW __nonnull ((2));
/* Retrieve error status associated with AIOCBP. */
extern int aio_error (const struct aiocb *__aiocbp) __THROW __nonnull ((1));
/* Return status associated with AIOCBP. */
extern __ssize_t aio_return (struct aiocb *__aiocbp) __THROW __nonnull ((1));
/* Try to cancel asynchronous I/O requests outstanding against file
descriptor FILDES. */
extern int aio_cancel (int __fildes, struct aiocb *__aiocbp) __THROW;
/* Suspend calling thread until at least one of the asynchronous I/O
operations referenced by LIST has completed.
This function is a cancellation point and therefore not marked with
__THROW. */
extern int aio_suspend (const struct aiocb *const __list[], int __nent,
const struct timespec *__restrict __timeout)
__nonnull ((1));
/* Force all operations associated with file desriptor described by
`aio_fildes' member of AIOCBP. */
extern int aio_fsync (int __operation, struct aiocb *__aiocbp)
__THROW __nonnull ((2));
#else
# ifdef __REDIRECT_NTH
extern int __REDIRECT_NTH (aio_read, (struct aiocb *__aiocbp), aio_read64)
__nonnull ((1));
extern int __REDIRECT_NTH (aio_write, (struct aiocb *__aiocbp), aio_write64)
__nonnull ((1));
extern int __REDIRECT_NTH (lio_listio,
(int __mode,
struct aiocb *const __list[__restrict_arr],
int __nent, struct sigevent *__restrict __sig),
lio_listio64) __nonnull ((2));
extern int __REDIRECT_NTH (aio_error, (const struct aiocb *__aiocbp),
aio_error64) __nonnull ((1));
extern __ssize_t __REDIRECT_NTH (aio_return, (struct aiocb *__aiocbp),
aio_return64) __nonnull ((1));
extern int __REDIRECT_NTH (aio_cancel,
(int __fildes, struct aiocb *__aiocbp),
aio_cancel64);
extern int __REDIRECT_NTH (aio_suspend,
(const struct aiocb *const __list[], int __nent,
const struct timespec *__restrict __timeout),
aio_suspend64) __nonnull ((1));
extern int __REDIRECT_NTH (aio_fsync,
(int __operation, struct aiocb *__aiocbp),
aio_fsync64) __nonnull ((2));
# else
# define aio_read aio_read64
# define aio_write aio_write64
# define lio_listio lio_listio64
# define aio_error aio_error64
# define aio_return aio_return64
# define aio_cancel aio_cancel64
# define aio_suspend aio_suspend64
# define aio_fsync aio_fsync64
# endif
#endif
#ifdef __USE_LARGEFILE64
extern int aio_read64 (struct aiocb64 *__aiocbp) __THROW __nonnull ((1));
extern int aio_write64 (struct aiocb64 *__aiocbp) __THROW __nonnull ((1));
extern int lio_listio64 (int __mode,
struct aiocb64 *const __list[__restrict_arr],
int __nent, struct sigevent *__restrict __sig)
__THROW __nonnull ((2));
extern int aio_error64 (const struct aiocb64 *__aiocbp)
__THROW __nonnull ((1));
extern __ssize_t aio_return64 (struct aiocb64 *__aiocbp)
__THROW __nonnull ((1));
extern int aio_cancel64 (int __fildes, struct aiocb64 *__aiocbp) __THROW;
extern int aio_suspend64 (const struct aiocb64 *const __list[], int __nent,
const struct timespec *__restrict __timeout)
__THROW __nonnull ((1));
extern int aio_fsync64 (int __operation, struct aiocb64 *__aiocbp)
__THROW __nonnull ((2));
#endif
__END_DECLS
#endif /* aio.h */
pcrecpparg.h 0000644 00000015177 15201526705 0007061 0 ustar 00 // Copyright (c) 2005, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: Sanjay Ghemawat
#ifndef _PCRECPPARG_H
#define _PCRECPPARG_H
#include <stdlib.h> // for NULL
#include <string>
#include <pcre.h>
namespace pcrecpp {
class StringPiece;
// Hex/Octal/Binary?
// Special class for parsing into objects that define a ParseFrom() method
template <class T>
class _RE_MatchObject {
public:
static inline bool Parse(const char* str, int n, void* dest) {
if (dest == NULL) return true;
T* object = reinterpret_cast<T*>(dest);
return object->ParseFrom(str, n);
}
};
class PCRECPP_EXP_DEFN Arg {
public:
// Empty constructor so we can declare arrays of Arg
Arg();
// Constructor specially designed for NULL arguments
Arg(void*);
typedef bool (*Parser)(const char* str, int n, void* dest);
// Type-specific parsers
#define PCRE_MAKE_PARSER(type,name) \
Arg(type* p) : arg_(p), parser_(name) { } \
Arg(type* p, Parser parser) : arg_(p), parser_(parser) { }
PCRE_MAKE_PARSER(char, parse_char);
PCRE_MAKE_PARSER(unsigned char, parse_uchar);
PCRE_MAKE_PARSER(short, parse_short);
PCRE_MAKE_PARSER(unsigned short, parse_ushort);
PCRE_MAKE_PARSER(int, parse_int);
PCRE_MAKE_PARSER(unsigned int, parse_uint);
PCRE_MAKE_PARSER(long, parse_long);
PCRE_MAKE_PARSER(unsigned long, parse_ulong);
#if 1
PCRE_MAKE_PARSER(long long, parse_longlong);
#endif
#if 1
PCRE_MAKE_PARSER(unsigned long long, parse_ulonglong);
#endif
PCRE_MAKE_PARSER(float, parse_float);
PCRE_MAKE_PARSER(double, parse_double);
PCRE_MAKE_PARSER(std::string, parse_string);
PCRE_MAKE_PARSER(StringPiece, parse_stringpiece);
#undef PCRE_MAKE_PARSER
// Generic constructor
template <class T> Arg(T*, Parser parser);
// Generic constructor template
template <class T> Arg(T* p)
: arg_(p), parser_(_RE_MatchObject<T>::Parse) {
}
// Parse the data
bool Parse(const char* str, int n) const;
private:
void* arg_;
Parser parser_;
static bool parse_null (const char* str, int n, void* dest);
static bool parse_char (const char* str, int n, void* dest);
static bool parse_uchar (const char* str, int n, void* dest);
static bool parse_float (const char* str, int n, void* dest);
static bool parse_double (const char* str, int n, void* dest);
static bool parse_string (const char* str, int n, void* dest);
static bool parse_stringpiece (const char* str, int n, void* dest);
#define PCRE_DECLARE_INTEGER_PARSER(name) \
private: \
static bool parse_ ## name(const char* str, int n, void* dest); \
static bool parse_ ## name ## _radix( \
const char* str, int n, void* dest, int radix); \
public: \
static bool parse_ ## name ## _hex(const char* str, int n, void* dest); \
static bool parse_ ## name ## _octal(const char* str, int n, void* dest); \
static bool parse_ ## name ## _cradix(const char* str, int n, void* dest)
PCRE_DECLARE_INTEGER_PARSER(short);
PCRE_DECLARE_INTEGER_PARSER(ushort);
PCRE_DECLARE_INTEGER_PARSER(int);
PCRE_DECLARE_INTEGER_PARSER(uint);
PCRE_DECLARE_INTEGER_PARSER(long);
PCRE_DECLARE_INTEGER_PARSER(ulong);
PCRE_DECLARE_INTEGER_PARSER(longlong);
PCRE_DECLARE_INTEGER_PARSER(ulonglong);
#undef PCRE_DECLARE_INTEGER_PARSER
};
inline Arg::Arg() : arg_(NULL), parser_(parse_null) { }
inline Arg::Arg(void* p) : arg_(p), parser_(parse_null) { }
inline bool Arg::Parse(const char* str, int n) const {
return (*parser_)(str, n, arg_);
}
// This part of the parser, appropriate only for ints, deals with bases
#define MAKE_INTEGER_PARSER(type, name) \
inline Arg Hex(type* ptr) { \
return Arg(ptr, Arg::parse_ ## name ## _hex); } \
inline Arg Octal(type* ptr) { \
return Arg(ptr, Arg::parse_ ## name ## _octal); } \
inline Arg CRadix(type* ptr) { \
return Arg(ptr, Arg::parse_ ## name ## _cradix); }
MAKE_INTEGER_PARSER(short, short) /* */
MAKE_INTEGER_PARSER(unsigned short, ushort) /* */
MAKE_INTEGER_PARSER(int, int) /* Don't use semicolons */
MAKE_INTEGER_PARSER(unsigned int, uint) /* after these statement */
MAKE_INTEGER_PARSER(long, long) /* because they can cause */
MAKE_INTEGER_PARSER(unsigned long, ulong) /* compiler warnings if */
#if 1 /* the checking level is */
MAKE_INTEGER_PARSER(long long, longlong) /* turned up high enough. */
#endif /* */
#if 1 /* */
MAKE_INTEGER_PARSER(unsigned long long, ulonglong) /* */
#endif
#undef PCRE_IS_SET
#undef PCRE_SET_OR_CLEAR
#undef MAKE_INTEGER_PARSER
} // namespace pcrecpp
#endif /* _PCRECPPARG_H */
jconfig.h 0000644 00000000366 15201526705 0006344 0 ustar 00 #ifndef JCONFIG_H_MULTILIB
#define JCONFIG_H_MULTILIB
#include <bits/wordsize.h>
#if __WORDSIZE == 32
# include "jconfig-32.h"
#elif __WORDSIZE == 64
# include "jconfig-64.h"
#else
# error "unexpected value for __WORDSIZE macro"
#endif
#endif
json-c/printbuf.h 0000644 00000007422 15201526705 0007747 0 ustar 00 /*
* $Id: printbuf.h,v 1.4 2006/01/26 02:16:28 mclark Exp $
*
* Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
* Michael Clark <michael@metaparadigm.com>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See COPYING for details.
*
*
* Copyright (c) 2008-2009 Yahoo! Inc. All rights reserved.
* The copyrights to the contents of this file are licensed under the MIT License
* (http://www.opensource.org/licenses/mit-license.php)
*/
/**
* @file
* @brief Internal string buffer handing. Unless you're writing a
* json_object_to_json_string_fn implementation for use with
* json_object_set_serializer() direct use of this is not
* recommended.
*/
#ifndef _printbuf_h_
#define _printbuf_h_
#ifdef __cplusplus
extern "C" {
#endif
struct printbuf {
char *buf;
int bpos;
int size;
};
typedef struct printbuf printbuf;
extern struct printbuf*
printbuf_new(void);
/* As an optimization, printbuf_memappend_fast() is defined as a macro
* that handles copying data if the buffer is large enough; otherwise
* it invokes printbuf_memappend() which performs the heavy
* lifting of realloc()ing the buffer and copying data.
*
* Your code should not use printbuf_memappend() directly unless it
* checks the return code. Use printbuf_memappend_fast() instead.
*/
extern int
printbuf_memappend(struct printbuf *p, const char *buf, int size);
#define printbuf_memappend_fast(p, bufptr, bufsize) \
do { \
if ((p->size - p->bpos) > bufsize) { \
memcpy(p->buf + p->bpos, (bufptr), bufsize); \
p->bpos += bufsize; \
p->buf[p->bpos]= '\0'; \
} else { printbuf_memappend(p, (bufptr), bufsize); } \
} while (0)
#define printbuf_length(p) ((p)->bpos)
/**
* Results in a compile error if the argument is not a string literal.
*/
#define _printbuf_check_literal(mystr) ("" mystr)
/**
* This is an optimization wrapper around printbuf_memappend() that is useful
* for appending string literals. Since the size of string constants is known
* at compile time, using this macro can avoid a costly strlen() call. This is
* especially helpful when a constant string must be appended many times. If
* you got here because of a compilation error caused by passing something
* other than a string literal, use printbuf_memappend_fast() in conjunction
* with strlen().
*
* See also:
* printbuf_memappend_fast()
* printbuf_memappend()
* sprintbuf()
*/
#define printbuf_strappend(pb, str) \
printbuf_memappend ((pb), _printbuf_check_literal(str), sizeof(str) - 1)
/**
* Set len bytes of the buffer to charvalue, starting at offset offset.
* Similar to calling memset(x, charvalue, len);
*
* The memory allocated for the buffer is extended as necessary.
*
* If offset is -1, this starts at the end of the current data in the buffer.
*/
extern int
printbuf_memset(struct printbuf *pb, int offset, int charvalue, int len);
/**
* Formatted print to printbuf.
*
* This function is the most expensive of the available functions for appending
* string data to a printbuf and should be used only where convenience is more
* important than speed. Avoid using this function in high performance code or
* tight loops; in these scenarios, consider using snprintf() with a static
* buffer in conjunction with one of the printbuf_*append() functions.
*
* See also:
* printbuf_memappend_fast()
* printbuf_memappend()
* printbuf_strappend()
*/
extern int
sprintbuf(struct printbuf *p, const char *msg, ...);
extern void
printbuf_reset(struct printbuf *p);
extern void
printbuf_free(struct printbuf *p);
#ifdef __cplusplus
}
#endif
#endif
json-c/bits.h 0000644 00000001363 15201526705 0007055 0 ustar 00 /**
* @file
* @brief Do not use, only contains deprecated defines.
* @deprecated Use json_util.h instead.
*
* $Id: bits.h,v 1.10 2006/01/30 23:07:57 mclark Exp $
*
* Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
* Michael Clark <michael@metaparadigm.com>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See COPYING for details.
*
*/
#ifndef _bits_h_
#define _bits_h_
/**
* @deprecated
*/
#define hexdigit(x) (((x) <= '9') ? (x) - '0' : ((x) & 7) + 9)
/**
* @deprecated
*/
#define error_ptr(error) ((void*)error)
/**
* @deprecated
*/
#define error_description(error) (json_tokener_get_error(error))
/**
* @deprecated
*/
#define is_error(ptr) (ptr == NULL)
#endif
json-c/json.h 0000644 00000001452 15201526705 0007064 0 ustar 00 /*
* $Id: json.h,v 1.6 2006/01/26 02:16:28 mclark Exp $
*
* Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
* Michael Clark <michael@metaparadigm.com>
* Copyright (c) 2009 Hewlett-Packard Development Company, L.P.
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See COPYING for details.
*
*/
/**
* @file
* @brief A convenience header that may be included instead of other individual ones.
*/
#ifndef _json_h_
#define _json_h_
#ifdef __cplusplus
extern "C" {
#endif
#include "debug.h"
#include "linkhash.h"
#include "arraylist.h"
#include "json_util.h"
#include "json_object.h"
#include "json_pointer.h"
#include "json_tokener.h"
#include "json_object_iterator.h"
#include "json_c_version.h"
#ifdef __cplusplus
}
#endif
#endif
json-c/json_config.h 0000644 00000000243 15201526705 0010406 0 ustar 00 /* json_config.h. Generated from json_config.h.in by configure. */
/* Define to 1 if you have the <inttypes.h> header file. */
#define JSON_C_HAVE_INTTYPES_H 1
json-c/json_object_iterator.h 0000644 00000020122 15201526705 0012316 0 ustar 00 /**
*******************************************************************************
* @file json_object_iterator.h
*
* Copyright (c) 2009-2012 Hewlett-Packard Development Company, L.P.
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See COPYING for details.
*
* @brief An API for iterating over json_type_object objects,
* styled to be familiar to C++ programmers.
* Unlike json_object_object_foreach() and
* json_object_object_foreachC(), this avoids the need to expose
* json-c internals like lh_entry.
*
* API attributes: <br>
* * Thread-safe: NO<br>
* * Reentrant: NO
*
*******************************************************************************
*/
#ifndef JSON_OBJECT_ITERATOR_H
#define JSON_OBJECT_ITERATOR_H
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* Forward declaration for the opaque iterator information.
*/
struct json_object_iter_info_;
/**
* The opaque iterator that references a name/value pair within
* a JSON Object instance or the "end" iterator value.
*/
struct json_object_iterator {
const void* opaque_;
};
/**
* forward declaration of json-c's JSON value instance structure
*/
struct json_object;
/**
* Initializes an iterator structure to a "default" value that
* is convenient for initializing an iterator variable to a
* default state (e.g., initialization list in a class'
* constructor).
*
* @code
* struct json_object_iterator iter = json_object_iter_init_default();
* MyClass() : iter_(json_object_iter_init_default())
* @endcode
*
* @note The initialized value doesn't reference any specific
* pair, is considered an invalid iterator, and MUST NOT
* be passed to any json-c API that expects a valid
* iterator.
*
* @note User and internal code MUST NOT make any assumptions
* about and dependencies on the value of the "default"
* iterator value.
*
* @return json_object_iterator
*/
struct json_object_iterator
json_object_iter_init_default(void);
/** Retrieves an iterator to the first pair of the JSON Object.
*
* @warning Any modification of the underlying pair invalidates all
* iterators to that pair.
*
* @param obj JSON Object instance (MUST be of type json_object)
*
* @return json_object_iterator If the JSON Object has at
* least one pair, on return, the iterator refers
* to the first pair. If the JSON Object doesn't
* have any pairs, the returned iterator is
* equivalent to the "end" iterator for the same
* JSON Object instance.
*
* @code
* struct json_object_iterator it;
* struct json_object_iterator itEnd;
* struct json_object* obj;
*
* obj = json_tokener_parse("{'first':'george', 'age':100}");
* it = json_object_iter_begin(obj);
* itEnd = json_object_iter_end(obj);
*
* while (!json_object_iter_equal(&it, &itEnd)) {
* printf("%s\n",
* json_object_iter_peek_name(&it));
* json_object_iter_next(&it);
* }
*
* @endcode
*/
struct json_object_iterator
json_object_iter_begin(struct json_object* obj);
/** Retrieves the iterator that represents the position beyond the
* last pair of the given JSON Object instance.
*
* @warning Do NOT write code that assumes that the "end"
* iterator value is NULL, even if it is so in a
* particular instance of the implementation.
*
* @note The reason we do not (and MUST NOT) provide
* "json_object_iter_is_end(json_object_iterator* iter)"
* type of API is because it would limit the underlying
* representation of name/value containment (or force us
* to add additional, otherwise unnecessary, fields to
* the iterator structure). The "end" iterator and the
* equality test method, on the other hand, permit us to
* cleanly abstract pretty much any reasonable underlying
* representation without burdening the iterator
* structure with unnecessary data.
*
* @note For performance reasons, memorize the "end" iterator prior
* to any loop.
*
* @param obj JSON Object instance (MUST be of type json_object)
*
* @return json_object_iterator On return, the iterator refers
* to the "end" of the Object instance's pairs
* (i.e., NOT the last pair, but "beyond the last
* pair" value)
*/
struct json_object_iterator
json_object_iter_end(const struct json_object* obj);
/** Returns an iterator to the next pair, if any
*
* @warning Any modification of the underlying pair
* invalidates all iterators to that pair.
*
* @param iter [IN/OUT] Pointer to iterator that references a
* name/value pair; MUST be a valid, non-end iterator.
* WARNING: bad things will happen if invalid or "end"
* iterator is passed. Upon return will contain the
* reference to the next pair if there is one; if there
* are no more pairs, will contain the "end" iterator
* value, which may be compared against the return value
* of json_object_iter_end() for the same JSON Object
* instance.
*/
void
json_object_iter_next(struct json_object_iterator* iter);
/** Returns a const pointer to the name of the pair referenced
* by the given iterator.
*
* @param iter pointer to iterator that references a name/value
* pair; MUST be a valid, non-end iterator.
*
* @warning bad things will happen if an invalid or
* "end" iterator is passed.
*
* @return const char* Pointer to the name of the referenced
* name/value pair. The name memory belongs to the
* name/value pair, will be freed when the pair is
* deleted or modified, and MUST NOT be modified or
* freed by the user.
*/
const char*
json_object_iter_peek_name(const struct json_object_iterator* iter);
/** Returns a pointer to the json-c instance representing the
* value of the referenced name/value pair, without altering
* the instance's reference count.
*
* @param iter pointer to iterator that references a name/value
* pair; MUST be a valid, non-end iterator.
*
* @warning bad things will happen if invalid or
* "end" iterator is passed.
*
* @return struct json_object* Pointer to the json-c value
* instance of the referenced name/value pair; the
* value's reference count is not changed by this
* function: if you plan to hold on to this json-c node,
* take a look at json_object_get() and
* json_object_put(). IMPORTANT: json-c API represents
* the JSON Null value as a NULL json_object instance
* pointer.
*/
struct json_object*
json_object_iter_peek_value(const struct json_object_iterator* iter);
/** Tests two iterators for equality. Typically used to test
* for end of iteration by comparing an iterator to the
* corresponding "end" iterator (that was derived from the same
* JSON Object instance).
*
* @note The reason we do not (and MUST NOT) provide
* "json_object_iter_is_end(json_object_iterator* iter)"
* type of API is because it would limit the underlying
* representation of name/value containment (or force us
* to add additional, otherwise unnecessary, fields to
* the iterator structure). The equality test method, on
* the other hand, permits us to cleanly abstract pretty
* much any reasonable underlying representation.
*
* @param iter1 Pointer to first valid, non-NULL iterator
* @param iter2 POinter to second valid, non-NULL iterator
*
* @warning if a NULL iterator pointer or an uninitialized
* or invalid iterator, or iterators derived from
* different JSON Object instances are passed, bad things
* will happen!
*
* @return json_bool non-zero if iterators are equal (i.e., both
* reference the same name/value pair or are both at
* "end"); zero if they are not equal.
*/
json_bool
json_object_iter_equal(const struct json_object_iterator* iter1,
const struct json_object_iterator* iter2);
#ifdef __cplusplus
}
#endif
#endif /* JSON_OBJECT_ITERATOR_H */
json-c/json_c_version.h 0000644 00000002240 15201526705 0011127 0 ustar 00 /*
* Copyright (c) 2012,2017 Eric Haszlakiewicz
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See COPYING for details.
*/
/**
* @file
* @brief Methods for retrieving the json-c version.
*/
#ifndef _json_c_version_h_
#define _json_c_version_h_
#define JSON_C_MAJOR_VERSION 0
#define JSON_C_MINOR_VERSION 13
#define JSON_C_MICRO_VERSION 01
#define JSON_C_VERSION_NUM ((JSON_C_MAJOR_VERSION << 16) | \
(JSON_C_MINOR_VERSION << 8) | \
JSON_C_MICRO_VERSION)
#define JSON_C_VERSION "0.13.1"
/**
* @see JSON_C_VERSION
* @return the version of the json-c library as a string
*/
const char *json_c_version(void); /* Returns JSON_C_VERSION */
/**
* The json-c version encoded into an int, with the low order 8 bits
* being the micro version, the next higher 8 bits being the minor version
* and the next higher 8 bits being the major version.
* For example, 7.12.99 would be 0x00070B63.
*
* @see JSON_C_VERSION_NUM
* @return the version of the json-c library as an int
*/
int json_c_version_num(void); /* Returns JSON_C_VERSION_NUM */
#endif
json-c/json_inttypes.h 0000644 00000000536 15201526705 0011025 0 ustar 00
/**
* @file
* @brief Do not use, json-c internal, may be changed or removed at any time.
*/
#ifndef _json_inttypes_h_
#define _json_inttypes_h_
#include "json_config.h"
#ifdef JSON_C_HAVE_INTTYPES_H
/* inttypes.h includes stdint.h */
#include <inttypes.h>
#else
#include <stdint.h>
#define PRId64 "I64d"
#define SCNd64 "I64d"
#endif
#endif
json-c/arraylist.h 0000644 00000003025 15201526705 0010123 0 ustar 00 /*
* $Id: arraylist.h,v 1.4 2006/01/26 02:16:28 mclark Exp $
*
* Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
* Michael Clark <michael@metaparadigm.com>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See COPYING for details.
*
*/
/**
* @file
* @brief Internal methods for working with json_type_array objects.
* Although this is exposed by the json_object_get_array() method,
* it is not recommended for direct use.
*/
#ifndef _arraylist_h_
#define _arraylist_h_
#ifdef __cplusplus
extern "C" {
#endif
#define ARRAY_LIST_DEFAULT_SIZE 32
typedef void (array_list_free_fn) (void *data);
struct array_list
{
void **array;
size_t length;
size_t size;
array_list_free_fn *free_fn;
};
typedef struct array_list array_list;
extern struct array_list*
array_list_new(array_list_free_fn *free_fn);
extern void
array_list_free(struct array_list *al);
extern void*
array_list_get_idx(struct array_list *al, size_t i);
extern int
array_list_put_idx(struct array_list *al, size_t i, void *data);
extern int
array_list_add(struct array_list *al, void *data);
extern size_t
array_list_length(struct array_list *al);
extern void
array_list_sort(struct array_list *arr, int(*compar)(const void *, const void *));
extern void* array_list_bsearch(const void **key,
struct array_list *arr,
int (*sort_fn)(const void *, const void *));
extern int
array_list_del_idx(struct array_list *arr, size_t idx, size_t count);
#ifdef __cplusplus
}
#endif
#endif
json-c/json_util.h 0000644 00000005665 15201526705 0010133 0 ustar 00 /*
* $Id: json_util.h,v 1.4 2006/01/30 23:07:57 mclark Exp $
*
* Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
* Michael Clark <michael@metaparadigm.com>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See COPYING for details.
*
*/
/**
* @file
* @brief Miscllaneous utility functions and macros.
*/
#ifndef _json_util_h_
#define _json_util_h_
#include "json_object.h"
#ifndef json_min
#define json_min(a,b) ((a) < (b) ? (a) : (b))
#endif
#ifndef json_max
#define json_max(a,b) ((a) > (b) ? (a) : (b))
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define JSON_FILE_BUF_SIZE 4096
/* utility functions */
/**
* Read the full contents of the given file, then convert it to a
* json_object using json_tokener_parse().
*
* Returns -1 if something fails. See json_util_get_last_err() for details.
*/
extern struct json_object* json_object_from_file(const char *filename);
/**
* Create a JSON object from already opened file descriptor.
*
* This function can be helpful, when you opened the file already,
* e.g. when you have a temp file.
* Note, that the fd must be readable at the actual position, i.e.
* use lseek(fd, 0, SEEK_SET) before.
*
* Returns -1 if something fails. See json_util_get_last_err() for details.
*/
extern struct json_object* json_object_from_fd(int fd);
/**
* Equivalent to:
* json_object_to_file_ext(filename, obj, JSON_C_TO_STRING_PLAIN);
*
* Returns -1 if something fails. See json_util_get_last_err() for details.
*/
extern int json_object_to_file(const char *filename, struct json_object *obj);
/**
* Open and truncate the given file, creating it if necessary, then
* convert the json_object to a string and write it to the file.
*
* Returns -1 if something fails. See json_util_get_last_err() for details.
*/
extern int json_object_to_file_ext(const char *filename, struct json_object *obj, int flags);
/**
* Convert the json_object to a string and write it to the file descriptor.
* Handles partial writes and will keep writing until done, or an error
* occurs.
*
* @param fd an open, writable file descriptor to write to
* @param obj the object to serializer and write
* @param flags flags to pass to json_object_to_json_string_ext()
* @return -1 if something fails. See json_util_get_last_err() for details.
*/
extern int json_object_to_fd(int fd, struct json_object *obj, int flags);
/**
* Return the last error from various json-c functions, including:
* json_object_to_file{,_ext}, json_object_to_fd() or
* json_object_from_{file,fd}, or NULL if there is none.
*/
const char *json_util_get_last_err(void);
extern int json_parse_int64(const char *buf, int64_t *retval);
extern int json_parse_double(const char *buf, double *retval);
/**
* Return a string describing the type of the object.
* e.g. "int", or "object", etc...
*/
extern const char *json_type_to_name(enum json_type o_type);
#ifdef __cplusplus
}
#endif
#endif
json-c/json_visit.h 0000644 00000006155 15201526705 0010307 0 ustar 00
#ifndef _json_c_json_visit_h_
#define _json_c_json_visit_h_
/**
* @file
* @brief Methods for walking a tree of objects.
*/
#include "json_object.h"
typedef int (json_c_visit_userfunc)(json_object *jso, int flags,
json_object *parent_jso, const char *jso_key,
size_t *jso_index, void *userarg);
/**
* Visit each object in the JSON hierarchy starting at jso.
* For each object, userfunc is called, passing the object and userarg.
* If the object has a parent (i.e. anything other than jso itself)
* its parent will be passed as parent_jso, and either jso_key or jso_index
* will be set, depending on whether the parent is an object or an array.
*
* Nodes will be visited depth first, but containers (arrays and objects)
* will be visited twice, the second time with JSON_C_VISIT_SECOND set in
* flags.
*
* userfunc must return one of the defined return values, to indicate
* whether and how to continue visiting nodes, or one of various ways to stop.
*
* Returns 0 if nodes were visited successfully, even if some were
* intentionally skipped due to what userfunc returned.
* Returns <0 if an error occurred during iteration, including if
* userfunc returned JSON_C_VISIT_RETURN_ERROR.
*/
int json_c_visit(json_object *jso, int future_flags,
json_c_visit_userfunc *userfunc, void *userarg);
/**
* Passed to json_c_visit_userfunc as one of the flags values to indicate
* that this is the second time a container (array or object) is being
* called, after all of it's members have been iterated over.
*/
#define JSON_C_VISIT_SECOND 0x02
/**
* This json_c_visit_userfunc return value indicates that iteration
* should proceed normally.
*/
#define JSON_C_VISIT_RETURN_CONTINUE 0
/**
* This json_c_visit_userfunc return value indicates that iteration
* over the members of the current object should be skipped.
* If the current object isn't a container (array or object), this
* is no different than JSON_C_VISIT_RETURN_CONTINUE.
*/
#define JSON_C_VISIT_RETURN_SKIP 7547
/**
* This json_c_visit_userfunc return value indicates that iteration
* of the fields/elements of the <b>containing</b> object should stop
* and continue "popped up" a level of the object hierarchy.
* For example, returning this when handling arg will result in
* arg3 and any other fields being skipped. The next call to userfunc
* will be the JSON_C_VISIT_SECOND call on "foo", followed by a userfunc
* call on "bar".
* <pre>
* {
* "foo": {
* "arg1": 1,
* "arg2": 2,
* "arg3": 3,
* ...
* },
* "bar": {
* ...
* }
* }
* </pre>
*/
#define JSON_C_VISIT_RETURN_POP 767
/**
* This json_c_visit_userfunc return value indicates that iteration
* should stop immediately, and cause json_c_visit to return success.
*/
#define JSON_C_VISIT_RETURN_STOP 7867
/**
* This json_c_visit_userfunc return value indicates that iteration
* should stop immediately, and cause json_c_visit to return an error.
*/
#define JSON_C_VISIT_RETURN_ERROR -1
#endif /* _json_c_json_visit_h_ */
json-c/json_tokener.h 0000644 00000015664 15201526705 0010625 0 ustar 00 /*
* $Id: json_tokener.h,v 1.10 2006/07/25 03:24:50 mclark Exp $
*
* Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
* Michael Clark <michael@metaparadigm.com>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See COPYING for details.
*
*/
/**
* @file
* @brief Methods to parse an input string into a tree of json_object objects.
*/
#ifndef _json_tokener_h_
#define _json_tokener_h_
#include <stddef.h>
#include "json_object.h"
#ifdef __cplusplus
extern "C" {
#endif
enum json_tokener_error {
json_tokener_success,
json_tokener_continue,
json_tokener_error_depth,
json_tokener_error_parse_eof,
json_tokener_error_parse_unexpected,
json_tokener_error_parse_null,
json_tokener_error_parse_boolean,
json_tokener_error_parse_number,
json_tokener_error_parse_array,
json_tokener_error_parse_object_key_name,
json_tokener_error_parse_object_key_sep,
json_tokener_error_parse_object_value_sep,
json_tokener_error_parse_string,
json_tokener_error_parse_comment,
json_tokener_error_size
};
enum json_tokener_state {
json_tokener_state_eatws,
json_tokener_state_start,
json_tokener_state_finish,
json_tokener_state_null,
json_tokener_state_comment_start,
json_tokener_state_comment,
json_tokener_state_comment_eol,
json_tokener_state_comment_end,
json_tokener_state_string,
json_tokener_state_string_escape,
json_tokener_state_escape_unicode,
json_tokener_state_boolean,
json_tokener_state_number,
json_tokener_state_array,
json_tokener_state_array_add,
json_tokener_state_array_sep,
json_tokener_state_object_field_start,
json_tokener_state_object_field,
json_tokener_state_object_field_end,
json_tokener_state_object_value,
json_tokener_state_object_value_add,
json_tokener_state_object_sep,
json_tokener_state_array_after_sep,
json_tokener_state_object_field_start_after_sep,
json_tokener_state_inf
};
struct json_tokener_srec
{
enum json_tokener_state state, saved_state;
struct json_object *obj;
struct json_object *current;
char *obj_field_name;
};
#define JSON_TOKENER_DEFAULT_DEPTH 32
struct json_tokener
{
char *str;
struct printbuf *pb;
int max_depth, depth, is_double, st_pos, char_offset;
enum json_tokener_error err;
unsigned int ucs_char;
char quote_char;
struct json_tokener_srec *stack;
int flags;
};
/**
* @deprecated Unused in json-c code
*/
typedef struct json_tokener json_tokener;
/**
* Be strict when parsing JSON input. Use caution with
* this flag as what is considered valid may become more
* restrictive from one release to the next, causing your
* code to fail on previously working input.
*
* This flag is not set by default.
*
* @see json_tokener_set_flags()
*/
#define JSON_TOKENER_STRICT 0x01
/**
* Given an error previously returned by json_tokener_get_error(),
* return a human readable description of the error.
*
* @return a generic error message is returned if an invalid error value is provided.
*/
const char *json_tokener_error_desc(enum json_tokener_error jerr);
/**
* Retrieve the error caused by the last call to json_tokener_parse_ex(),
* or json_tokener_success if there is no error.
*
* When parsing a JSON string in pieces, if the tokener is in the middle
* of parsing this will return json_tokener_continue.
*
* See also json_tokener_error_desc().
*/
JSON_EXPORT enum json_tokener_error json_tokener_get_error(struct json_tokener *tok);
JSON_EXPORT struct json_tokener* json_tokener_new(void);
JSON_EXPORT struct json_tokener* json_tokener_new_ex(int depth);
JSON_EXPORT void json_tokener_free(struct json_tokener *tok);
JSON_EXPORT void json_tokener_reset(struct json_tokener *tok);
JSON_EXPORT struct json_object* json_tokener_parse(const char *str);
JSON_EXPORT struct json_object* json_tokener_parse_verbose(const char *str, enum json_tokener_error *error);
/**
* Set flags that control how parsing will be done.
*/
JSON_EXPORT void json_tokener_set_flags(struct json_tokener *tok, int flags);
/**
* Parse a string and return a non-NULL json_object if a valid JSON value
* is found. The string does not need to be a JSON object or array;
* it can also be a string, number or boolean value.
*
* A partial JSON string can be parsed. If the parsing is incomplete,
* NULL will be returned and json_tokener_get_error() will return
* json_tokener_continue.
* json_tokener_parse_ex() can then be called with additional bytes in str
* to continue the parsing.
*
* If json_tokener_parse_ex() returns NULL and the error is anything other than
* json_tokener_continue, a fatal error has occurred and parsing must be
* halted. Then, the tok object must not be reused until json_tokener_reset() is
* called.
*
* When a valid JSON value is parsed, a non-NULL json_object will be
* returned. Also, json_tokener_get_error() will return json_tokener_success.
* Be sure to check the type with json_object_is_type() or
* json_object_get_type() before using the object.
*
* @b XXX this shouldn't use internal fields:
* Trailing characters after the parsed value do not automatically cause an
* error. It is up to the caller to decide whether to treat this as an
* error or to handle the additional characters, perhaps by parsing another
* json value starting from that point.
*
* Extra characters can be detected by comparing the tok->char_offset against
* the length of the last len parameter passed in.
*
* The tokener does \b not maintain an internal buffer so the caller is
* responsible for calling json_tokener_parse_ex with an appropriate str
* parameter starting with the extra characters.
*
* This interface is presently not 64-bit clean due to the int len argument
* so the function limits the maximum string size to INT32_MAX (2GB).
* If the function is called with len == -1 then strlen is called to check
* the string length is less than INT32_MAX (2GB)
*
* Example:
* @code
json_object *jobj = NULL;
const char *mystring = NULL;
int stringlen = 0;
enum json_tokener_error jerr;
do {
mystring = ... // get JSON string, e.g. read from file, etc...
stringlen = strlen(mystring);
jobj = json_tokener_parse_ex(tok, mystring, stringlen);
} while ((jerr = json_tokener_get_error(tok)) == json_tokener_continue);
if (jerr != json_tokener_success)
{
fprintf(stderr, "Error: %s\n", json_tokener_error_desc(jerr));
// Handle errors, as appropriate for your application.
}
if (tok->char_offset < stringlen) // XXX shouldn't access internal fields
{
// Handle extra characters after parsed object as desired.
// e.g. issue an error, parse another object from that point, etc...
}
// Success, use jobj here.
@endcode
*
* @param tok a json_tokener previously allocated with json_tokener_new()
* @param str an string with any valid JSON expression, or portion of. This does not need to be null terminated.
* @param len the length of str
*/
JSON_EXPORT struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
const char *str, int len);
#ifdef __cplusplus
}
#endif
#endif
json-c/json_object.h 0000644 00000112150 15201526705 0010410 0 ustar 00 /*
* $Id: json_object.h,v 1.12 2006/01/30 23:07:57 mclark Exp $
*
* Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
* Michael Clark <michael@metaparadigm.com>
* Copyright (c) 2009 Hewlett-Packard Development Company, L.P.
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See COPYING for details.
*
*/
/**
* @file
* @brief Core json-c API. Start here, or with json_tokener.h
*/
#ifndef _json_object_h_
#define _json_object_h_
#ifdef __GNUC__
#define THIS_FUNCTION_IS_DEPRECATED(func) func __attribute__ ((deprecated))
#elif defined(_MSC_VER)
#define THIS_FUNCTION_IS_DEPRECATED(func) __declspec(deprecated) func
#elif defined(__clang__)
#define THIS_FUNCTION_IS_DEPRECATED(func) func __deprecated
#else
#define THIS_FUNCTION_IS_DEPRECATED(func) func
#endif
#ifdef __GNUC__
#define JSON_C_CONST_FUNCTION(func) func __attribute__((const))
#else
#define JSON_C_CONST_FUNCTION(func) func
#endif
#if defined(_MSC_VER)
#define JSON_EXPORT __declspec(dllexport)
#else
#define JSON_EXPORT extern
#endif
#include <stddef.h>
#include "json_inttypes.h"
#include "printbuf.h"
#ifdef __cplusplus
extern "C" {
#endif
#define JSON_OBJECT_DEF_HASH_ENTRIES 16
/**
* A flag for the json_object_to_json_string_ext() and
* json_object_to_file_ext() functions which causes the output
* to have no extra whitespace or formatting applied.
*/
#define JSON_C_TO_STRING_PLAIN 0
/**
* A flag for the json_object_to_json_string_ext() and
* json_object_to_file_ext() functions which causes the output to have
* minimal whitespace inserted to make things slightly more readable.
*/
#define JSON_C_TO_STRING_SPACED (1<<0)
/**
* A flag for the json_object_to_json_string_ext() and
* json_object_to_file_ext() functions which causes
* the output to be formatted.
*
* See the "Two Space Tab" option at http://jsonformatter.curiousconcept.com/
* for an example of the format.
*/
#define JSON_C_TO_STRING_PRETTY (1<<1)
/**
* A flag for the json_object_to_json_string_ext() and
* json_object_to_file_ext() functions which causes
* the output to be formatted.
*
* Instead of a "Two Space Tab" this gives a single tab character.
*/
#define JSON_C_TO_STRING_PRETTY_TAB (1<<3)
/**
* A flag to drop trailing zero for float values
*/
#define JSON_C_TO_STRING_NOZERO (1<<2)
/**
* Don't escape forward slashes.
*/
#define JSON_C_TO_STRING_NOSLASHESCAPE (1<<4)
/**
* A flag for the json_object_object_add_ex function which
* causes the value to be added without a check if it already exists.
* Note: it is the responsibilty of the caller to ensure that no
* key is added multiple times. If this is done, results are
* unpredictable. While this option is somewhat dangerous, it
* permits potentially large performance savings in code that
* knows for sure the key values are unique (e.g. because the
* code adds a well-known set of constant key values).
*/
#define JSON_C_OBJECT_ADD_KEY_IS_NEW (1<<1)
/**
* A flag for the json_object_object_add_ex function which
* flags the key as being constant memory. This means that
* the key will NOT be copied via strdup(), resulting in a
* potentially huge performance win (malloc, strdup and
* free are usually performance hogs). It is acceptable to
* use this flag for keys in non-constant memory blocks if
* the caller ensure that the memory holding the key lives
* longer than the corresponding json object. However, this
* is somewhat dangerous and should only be done if really
* justified.
* The general use-case for this flag is cases where the
* key is given as a real constant value in the function
* call, e.g. as in
* json_object_object_add_ex(obj, "ip", json,
* JSON_C_OBJECT_KEY_IS_CONSTANT);
*/
#define JSON_C_OBJECT_KEY_IS_CONSTANT (1<<2)
#undef FALSE
#define FALSE ((json_bool)0)
#undef TRUE
#define TRUE ((json_bool)1)
/**
* Set the global value of an option, which will apply to all
* current and future threads that have not set a thread-local value.
*
* @see json_c_set_serialization_double_format
*/
#define JSON_C_OPTION_GLOBAL (0)
/**
* Set a thread-local value of an option, overriding the global value.
* This will fail if json-c is not compiled with threading enabled, and
* with the __thread specifier (or equivalent) available.
*
* @see json_c_set_serialization_double_format
*/
#define JSON_C_OPTION_THREAD (1)
/**
* A structure to use with json_object_object_foreachC() loops.
* Contains key, val and entry members.
*/
struct json_object_iter
{
char *key;
struct json_object *val;
struct lh_entry *entry;
};
typedef struct json_object_iter json_object_iter;
typedef int json_bool;
/**
* @brief The core type for all type of JSON objects handled by json-c
*/
typedef struct json_object json_object;
/**
* Type of custom user delete functions. See json_object_set_serializer.
*/
typedef void (json_object_delete_fn)(struct json_object *jso, void *userdata);
/**
* Type of a custom serialization function. See json_object_set_serializer.
*/
typedef int (json_object_to_json_string_fn)(struct json_object *jso,
struct printbuf *pb,
int level,
int flags);
/* supported object types */
typedef enum json_type {
/* If you change this, be sure to update json_type_to_name() too */
json_type_null,
json_type_boolean,
json_type_double,
json_type_int,
json_type_object,
json_type_array,
json_type_string
} json_type;
/* reference counting functions */
/**
* Increment the reference count of json_object, thereby grabbing shared
* ownership of obj.
*
* @param obj the json_object instance
*/
JSON_EXPORT struct json_object* json_object_get(struct json_object *obj);
/**
* Decrement the reference count of json_object and free if it reaches zero.
* You must have ownership of obj prior to doing this or you will cause an
* imbalance in the reference count.
*
* @param obj the json_object instance
* @returns 1 if the object was freed.
*/
JSON_EXPORT int json_object_put(struct json_object *obj);
/**
* Check if the json_object is of a given type
* @param obj the json_object instance
* @param type one of:
json_type_null (i.e. obj == NULL),
json_type_boolean,
json_type_double,
json_type_int,
json_type_object,
json_type_array,
json_type_string
*/
JSON_EXPORT int json_object_is_type(const struct json_object *obj, enum json_type type);
/**
* Get the type of the json_object. See also json_type_to_name() to turn this
* into a string suitable, for instance, for logging.
*
* @param obj the json_object instance
* @returns type being one of:
json_type_null (i.e. obj == NULL),
json_type_boolean,
json_type_double,
json_type_int,
json_type_object,
json_type_array,
json_type_string
*/
JSON_EXPORT enum json_type json_object_get_type(const struct json_object *obj);
/** Stringify object to json format.
* Equivalent to json_object_to_json_string_ext(obj, JSON_C_TO_STRING_SPACED)
* The pointer you get is an internal of your json object. You don't
* have to free it, later use of json_object_put() should be sufficient.
* If you can not ensure there's no concurrent access to *obj use
* strdup().
* @param obj the json_object instance
* @returns a string in JSON format
*/
JSON_EXPORT const char* json_object_to_json_string(struct json_object *obj);
/** Stringify object to json format
* @see json_object_to_json_string() for details on how to free string.
* @param obj the json_object instance
* @param flags formatting options, see JSON_C_TO_STRING_PRETTY and other constants
* @returns a string in JSON format
*/
JSON_EXPORT const char* json_object_to_json_string_ext(struct json_object *obj, int
flags);
/** Stringify object to json format
* @see json_object_to_json_string() for details on how to free string.
* @param obj the json_object instance
* @param flags formatting options, see JSON_C_TO_STRING_PRETTY and other constants
* @param length a pointer where, if not NULL, the length (without null) is stored
* @returns a string in JSON format and the length if not NULL
*/
JSON_EXPORT const char* json_object_to_json_string_length(struct json_object *obj, int
flags, size_t *length);
/**
* Returns the userdata set by json_object_set_userdata() or
* json_object_set_serializer()
*
* @param jso the object to return the userdata for
*/
JSON_EXPORT void* json_object_get_userdata(json_object *jso);
/**
* Set an opaque userdata value for an object
*
* The userdata can be retrieved using json_object_get_userdata().
*
* If custom userdata is already set on this object, any existing user_delete
* function is called before the new one is set.
*
* The user_delete parameter is optional and may be passed as NULL, even if
* the userdata parameter is non-NULL. It will be called just before the
* json_object is deleted, after it's reference count goes to zero
* (see json_object_put()).
* If this is not provided, it is up to the caller to free the userdata at
* an appropriate time. (i.e. after the json_object is deleted)
*
* Note: Objects created by parsing strings may have custom serializers set
* which expect the userdata to contain specific data (due to use of
* json_object_new_double_s()). In this case, json_object_set_serialiser() with
* NULL as to_string_func should be used instead to set the userdata and reset
* the serializer to its default value.
*
* @param jso the object to set the userdata for
* @param userdata an optional opaque cookie
* @param user_delete an optional function from freeing userdata
*/
JSON_EXPORT void json_object_set_userdata(json_object *jso, void *userdata,
json_object_delete_fn *user_delete);
/**
* Set a custom serialization function to be used when this particular object
* is converted to a string by json_object_to_json_string.
*
* If custom userdata is already set on this object, any existing user_delete
* function is called before the new one is set.
*
* If to_string_func is NULL the default behaviour is reset (but the userdata
* and user_delete fields are still set).
*
* The userdata parameter is optional and may be passed as NULL. It can be used
* to provide additional data for to_string_func to use. This parameter may
* be NULL even if user_delete is non-NULL.
*
* The user_delete parameter is optional and may be passed as NULL, even if
* the userdata parameter is non-NULL. It will be called just before the
* json_object is deleted, after it's reference count goes to zero
* (see json_object_put()).
* If this is not provided, it is up to the caller to free the userdata at
* an appropriate time. (i.e. after the json_object is deleted)
*
* Note that the userdata is the same as set by json_object_set_userdata(), so
* care must be taken not to overwrite the value when both a custom serializer
* and json_object_set_userdata() are used.
*
* @param jso the object to customize
* @param to_string_func the custom serialization function
* @param userdata an optional opaque cookie
* @param user_delete an optional function from freeing userdata
*/
JSON_EXPORT void json_object_set_serializer(json_object *jso,
json_object_to_json_string_fn *to_string_func,
void *userdata,
json_object_delete_fn *user_delete);
#ifdef __clang__
/*
* Clang doesn't pay attention to the parameters defined in the
* function typedefs used here, so turn off spurious doc warnings.
* {
*/
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdocumentation"
#endif
/**
* Simply call free on the userdata pointer.
* Can be used with json_object_set_serializer().
*
* @param jso unused
* @param userdata the pointer that is passed to free().
*/
json_object_delete_fn json_object_free_userdata;
/**
* Copy the jso->_userdata string over to pb as-is.
* Can be used with json_object_set_serializer().
*
* @param jso The object whose _userdata is used.
* @param pb The destination buffer.
* @param level Ignored.
* @param flags Ignored.
*/
json_object_to_json_string_fn json_object_userdata_to_json_string;
#ifdef __clang__
/* } */
#pragma clang diagnostic pop
#endif
/* object type methods */
/** Create a new empty object with a reference count of 1. The caller of
* this object initially has sole ownership. Remember, when using
* json_object_object_add or json_object_array_put_idx, ownership will
* transfer to the object/array. Call json_object_get if you want to maintain
* shared ownership or also add this object as a child of multiple objects or
* arrays. Any ownerships you acquired but did not transfer must be released
* through json_object_put.
*
* @returns a json_object of type json_type_object
*/
JSON_EXPORT struct json_object* json_object_new_object(void);
/** Get the hashtable of a json_object of type json_type_object
* @param obj the json_object instance
* @returns a linkhash
*/
JSON_EXPORT struct lh_table* json_object_get_object(const struct json_object *obj);
/** Get the size of an object in terms of the number of fields it has.
* @param obj the json_object whose length to return
*/
JSON_EXPORT int json_object_object_length(const struct json_object* obj);
/** Get the sizeof (struct json_object).
* @returns a size_t with the sizeof (struct json_object)
*/
JSON_C_CONST_FUNCTION(JSON_EXPORT size_t json_c_object_sizeof(void));
/** Add an object field to a json_object of type json_type_object
*
* The reference count will *not* be incremented. This is to make adding
* fields to objects in code more compact. If you want to retain a reference
* to an added object, independent of the lifetime of obj, you must wrap the
* passed object with json_object_get.
*
* Upon calling this, the ownership of val transfers to obj. Thus you must
* make sure that you do in fact have ownership over this object. For instance,
* json_object_new_object will give you ownership until you transfer it,
* whereas json_object_object_get does not.
*
* @param obj the json_object instance
* @param key the object field name (a private copy will be duplicated)
* @param val a json_object or NULL member to associate with the given field
*
* @return On success, <code>0</code> is returned.
* On error, a negative value is returned.
*/
JSON_EXPORT int json_object_object_add(struct json_object* obj, const char *key,
struct json_object *val);
/** Add an object field to a json_object of type json_type_object
*
* The semantics are identical to json_object_object_add, except that an
* additional flag fields gives you more control over some detail aspects
* of processing. See the description of JSON_C_OBJECT_ADD_* flags for more
* details.
*
* @param obj the json_object instance
* @param key the object field name (a private copy will be duplicated)
* @param val a json_object or NULL member to associate with the given field
* @param opts process-modifying options. To specify multiple options, use
* arithmetic or (OPT1|OPT2)
*/
JSON_EXPORT int json_object_object_add_ex(struct json_object* obj,
const char *const key,
struct json_object *const val,
const unsigned opts);
/** Get the json_object associate with a given object field.
* Deprecated/discouraged: used json_object_object_get_ex instead.
*
* This returns NULL if the field is found but its value is null, or if
* the field is not found, or if obj is not a json_type_object. If you
* need to distinguis between these cases, use json_object_object_get_ex().
*
* *No* reference counts will be changed. There is no need to manually adjust
* reference counts through the json_object_put/json_object_get methods unless
* you need to have the child (value) reference maintain a different lifetime
* than the owning parent (obj). Ownership of the returned value is retained
* by obj (do not do json_object_put unless you have done a json_object_get).
* If you delete the value from obj (json_object_object_del) and wish to access
* the returned reference afterwards, make sure you have first gotten shared
* ownership through json_object_get (& don't forget to do a json_object_put
* or transfer ownership to prevent a memory leak).
*
* @param obj the json_object instance
* @param key the object field name
* @returns the json_object associated with the given field name
*/
JSON_EXPORT struct json_object* json_object_object_get(const struct json_object* obj,
const char *key);
/** Get the json_object associated with a given object field.
*
* This returns true if the key is found, false in all other cases (including
* if obj isn't a json_type_object).
*
* *No* reference counts will be changed. There is no need to manually adjust
* reference counts through the json_object_put/json_object_get methods unless
* you need to have the child (value) reference maintain a different lifetime
* than the owning parent (obj). Ownership of value is retained by obj.
*
* @param obj the json_object instance
* @param key the object field name
* @param value a pointer where to store a reference to the json_object
* associated with the given field name.
*
* It is safe to pass a NULL value.
* @returns whether or not the key exists
*/
JSON_EXPORT json_bool json_object_object_get_ex(const struct json_object* obj,
const char *key,
struct json_object **value);
/** Delete the given json_object field
*
* The reference count will be decremented for the deleted object. If there
* are no more owners of the value represented by this key, then the value is
* freed. Otherwise, the reference to the value will remain in memory.
*
* @param obj the json_object instance
* @param key the object field name
*/
JSON_EXPORT void json_object_object_del(struct json_object* obj, const char *key);
/**
* Iterate through all keys and values of an object.
*
* Adding keys to the object while iterating is NOT allowed.
*
* Deleting an existing key, or replacing an existing key with a
* new value IS allowed.
*
* @param obj the json_object instance
* @param key the local name for the char* key variable defined in the body
* @param val the local name for the json_object* object variable defined in
* the body
*/
#if defined(__GNUC__) && !defined(__STRICT_ANSI__) && __STDC_VERSION__ >= 199901L
# define json_object_object_foreach(obj,key,val) \
char *key = NULL; \
struct json_object *val __attribute__((__unused__)) = NULL; \
for(struct lh_entry *entry ## key = json_object_get_object(obj)->head, *entry_next ## key = NULL; \
({ if(entry ## key) { \
key = (char*)lh_entry_k(entry ## key); \
val = (struct json_object*)lh_entry_v(entry ## key); \
entry_next ## key = entry ## key->next; \
} ; entry ## key; }); \
entry ## key = entry_next ## key )
#else /* ANSI C or MSC */
# define json_object_object_foreach(obj,key,val) \
char *key = NULL;\
struct json_object *val = NULL; \
struct lh_entry *entry ## key; \
struct lh_entry *entry_next ## key = NULL; \
for(entry ## key = json_object_get_object(obj)->head; \
(entry ## key ? ( \
key = (char*)lh_entry_k(entry ## key), \
val = (struct json_object*)lh_entry_v(entry ## key), \
entry_next ## key = entry ## key->next, \
entry ## key) : 0); \
entry ## key = entry_next ## key)
#endif /* defined(__GNUC__) && !defined(__STRICT_ANSI__) && __STDC_VERSION__ >= 199901L */
/** Iterate through all keys and values of an object (ANSI C Safe)
* @param obj the json_object instance
* @param iter the object iterator, use type json_object_iter
*/
#define json_object_object_foreachC(obj,iter) \
for(iter.entry = json_object_get_object(obj)->head; \
(iter.entry ? (iter.key = (char*)lh_entry_k(iter.entry), iter.val = (struct json_object*)lh_entry_v(iter.entry), iter.entry) : 0); \
iter.entry = iter.entry->next)
/* Array type methods */
/** Create a new empty json_object of type json_type_array
* @returns a json_object of type json_type_array
*/
JSON_EXPORT struct json_object* json_object_new_array(void);
/** Get the arraylist of a json_object of type json_type_array
* @param obj the json_object instance
* @returns an arraylist
*/
JSON_EXPORT struct array_list* json_object_get_array(const struct json_object *obj);
/** Get the length of a json_object of type json_type_array
* @param obj the json_object instance
* @returns an int
*/
JSON_EXPORT size_t json_object_array_length(const struct json_object *obj);
/** Sorts the elements of jso of type json_type_array
*
* Pointers to the json_object pointers will be passed as the two arguments
* to sort_fn
*
* @param jso the json_object instance
* @param sort_fn a sorting function
*/
JSON_EXPORT void json_object_array_sort(struct json_object *jso, int(*sort_fn)(const void *, const void *));
/** Binary search a sorted array for a specified key object.
*
* It depends on your compare function what's sufficient as a key.
* Usually you create some dummy object with the parameter compared in
* it, to identify the right item you're actually looking for.
*
* @see json_object_array_sort() for hints on the compare function.
*
* @param key a dummy json_object with the right key
* @param jso the array object we're searching
* @param sort_fn the sort/compare function
*
* @return the wanted json_object instance
*/
JSON_EXPORT struct json_object* json_object_array_bsearch(
const struct json_object *key,
const struct json_object *jso,
int (*sort_fn)(const void *, const void *));
/** Add an element to the end of a json_object of type json_type_array
*
* The reference count will *not* be incremented. This is to make adding
* fields to objects in code more compact. If you want to retain a reference
* to an added object you must wrap the passed object with json_object_get
*
* @param obj the json_object instance
* @param val the json_object to be added
*/
JSON_EXPORT int json_object_array_add(struct json_object *obj,
struct json_object *val);
/** Insert or replace an element at a specified index in an array (a json_object of type json_type_array)
*
* The reference count will *not* be incremented. This is to make adding
* fields to objects in code more compact. If you want to retain a reference
* to an added object you must wrap the passed object with json_object_get
*
* The reference count of a replaced object will be decremented.
*
* The array size will be automatically be expanded to the size of the
* index if the index is larger than the current size.
*
* @param obj the json_object instance
* @param idx the index to insert the element at
* @param val the json_object to be added
*/
JSON_EXPORT int json_object_array_put_idx(struct json_object *obj, size_t idx,
struct json_object *val);
/** Get the element at specificed index of the array (a json_object of type json_type_array)
* @param obj the json_object instance
* @param idx the index to get the element at
* @returns the json_object at the specified index (or NULL)
*/
JSON_EXPORT struct json_object* json_object_array_get_idx(const struct json_object *obj,
size_t idx);
/** Delete an elements from a specified index in an array (a json_object of type json_type_array)
*
* The reference count will be decremented for each of the deleted objects. If there
* are no more owners of an element that is being deleted, then the value is
* freed. Otherwise, the reference to the value will remain in memory.
*
* @param obj the json_object instance
* @param idx the index to start deleting elements at
* @param count the number of elements to delete
* @returns 0 if the elements were successfully deleted
*/
JSON_EXPORT int json_object_array_del_idx(struct json_object *obj, size_t idx, size_t count);
/* json_bool type methods */
/** Create a new empty json_object of type json_type_boolean
* @param b a json_bool TRUE or FALSE (1 or 0)
* @returns a json_object of type json_type_boolean
*/
JSON_EXPORT struct json_object* json_object_new_boolean(json_bool b);
/** Get the json_bool value of a json_object
*
* The type is coerced to a json_bool if the passed object is not a json_bool.
* integer and double objects will return FALSE if there value is zero
* or TRUE otherwise. If the passed object is a string it will return
* TRUE if it has a non zero length. If any other object type is passed
* TRUE will be returned if the object is not NULL.
*
* @param obj the json_object instance
* @returns a json_bool
*/
JSON_EXPORT json_bool json_object_get_boolean(const struct json_object *obj);
/** Set the json_bool value of a json_object
*
* The type of obj is checked to be a json_type_boolean and 0 is returned
* if it is not without any further actions. If type of obj is json_type_boolean
* the obect value is chaned to new_value
*
* @param obj the json_object instance
* @param new_value the value to be set
* @returns 1 if value is set correctly, 0 otherwise
*/
JSON_EXPORT int json_object_set_boolean(struct json_object *obj,json_bool new_value);
/* int type methods */
/** Create a new empty json_object of type json_type_int
* Note that values are stored as 64-bit values internally.
* To ensure the full range is maintained, use json_object_new_int64 instead.
* @param i the integer
* @returns a json_object of type json_type_int
*/
JSON_EXPORT struct json_object* json_object_new_int(int32_t i);
/** Create a new empty json_object of type json_type_int
* @param i the integer
* @returns a json_object of type json_type_int
*/
JSON_EXPORT struct json_object* json_object_new_int64(int64_t i);
/** Get the int value of a json_object
*
* The type is coerced to a int if the passed object is not a int.
* double objects will return their integer conversion. Strings will be
* parsed as an integer. If no conversion exists then 0 is returned
* and errno is set to EINVAL. null is equivalent to 0 (no error values set)
*
* Note that integers are stored internally as 64-bit values.
* If the value of too big or too small to fit into 32-bit, INT32_MAX or
* INT32_MIN are returned, respectively.
*
* @param obj the json_object instance
* @returns an int
*/
JSON_EXPORT int32_t json_object_get_int(const struct json_object *obj);
/** Set the int value of a json_object
*
* The type of obj is checked to be a json_type_int and 0 is returned
* if it is not without any further actions. If type of obj is json_type_int
* the obect value is changed to new_value
*
* @param obj the json_object instance
* @param new_value the value to be set
* @returns 1 if value is set correctly, 0 otherwise
*/
JSON_EXPORT int json_object_set_int(struct json_object *obj,int new_value);
/** Increment a json_type_int object by the given amount, which may be negative.
*
* If the type of obj is not json_type_int then 0 is returned with no further
* action taken.
* If the addition would result in a overflow, the object value
* is set to INT64_MAX.
* If the addition would result in a underflow, the object value
* is set to INT64_MIN.
* Neither overflow nor underflow affect the return value.
*
* @param obj the json_object instance
* @param val the value to add
* @returns 1 if the increment succeded, 0 otherwise
*/
JSON_EXPORT int json_object_int_inc(struct json_object *obj, int64_t val);
/** Get the int value of a json_object
*
* The type is coerced to a int64 if the passed object is not a int64.
* double objects will return their int64 conversion. Strings will be
* parsed as an int64. If no conversion exists then 0 is returned.
*
* NOTE: Set errno to 0 directly before a call to this function to determine
* whether or not conversion was successful (it does not clear the value for
* you).
*
* @param obj the json_object instance
* @returns an int64
*/
JSON_EXPORT int64_t json_object_get_int64(const struct json_object *obj);
/** Set the int64_t value of a json_object
*
* The type of obj is checked to be a json_type_int and 0 is returned
* if it is not without any further actions. If type of obj is json_type_int
* the obect value is chaned to new_value
*
* @param obj the json_object instance
* @param new_value the value to be set
* @returns 1 if value is set correctly, 0 otherwise
*/
JSON_EXPORT int json_object_set_int64(struct json_object *obj,int64_t new_value);
/* double type methods */
/** Create a new empty json_object of type json_type_double
*
* @see json_object_double_to_json_string() for how to set a custom format string.
*
* @param d the double
* @returns a json_object of type json_type_double
*/
JSON_EXPORT struct json_object* json_object_new_double(double d);
/**
* Create a new json_object of type json_type_double, using
* the exact serialized representation of the value.
*
* This allows for numbers that would otherwise get displayed
* inefficiently (e.g. 12.3 => "12.300000000000001") to be
* serialized with the more convenient form.
*
* Notes:
*
* This is used by json_tokener_parse_ex() to allow for
* an exact re-serialization of a parsed object.
*
* The userdata field is used to store the string representation, so it
* can't be used for other data if this function is used.
*
* An equivalent sequence of calls is:
* @code
* jso = json_object_new_double(d);
* json_object_set_serializer(jso, json_object_userdata_to_json_string,
* strdup(ds), json_object_free_userdata);
* @endcode
*
* @param d the numeric value of the double.
* @param ds the string representation of the double. This will be copied.
*/
JSON_EXPORT struct json_object* json_object_new_double_s(double d, const char *ds);
/**
* Set a global or thread-local json-c option, depending on whether
* JSON_C_OPTION_GLOBAL or JSON_C_OPTION_THREAD is passed.
* Thread-local options default to undefined, and inherit from the global
* value, even if the global value is changed after the thread is created.
* Attempting to set thread-local options when threading is not compiled in
* will result in an error. Be sure to check the return value.
*
* double_format is a "%g" printf format, such as "%.20g"
*
* @return -1 on errors, 0 on success.
*/
int json_c_set_serialization_double_format(const char *double_format, int global_or_thread);
/** Serialize a json_object of type json_type_double to a string.
*
* This function isn't meant to be called directly. Instead, you can set a
* custom format string for the serialization of this double using the
* following call (where "%.17g" actually is the default):
*
* @code
* jso = json_object_new_double(d);
* json_object_set_serializer(jso, json_object_double_to_json_string,
* "%.17g", NULL);
* @endcode
*
* @see printf(3) man page for format strings
*
* @param jso The json_type_double object that is serialized.
* @param pb The destination buffer.
* @param level Ignored.
* @param flags Ignored.
*/
JSON_EXPORT int json_object_double_to_json_string(struct json_object* jso,
struct printbuf *pb,
int level,
int flags);
/** Get the double floating point value of a json_object
*
* The type is coerced to a double if the passed object is not a double.
* integer objects will return their double conversion. Strings will be
* parsed as a double. If no conversion exists then 0.0 is returned and
* errno is set to EINVAL. null is equivalent to 0 (no error values set)
*
* If the value is too big to fit in a double, then the value is set to
* the closest infinity with errno set to ERANGE. If strings cannot be
* converted to their double value, then EINVAL is set & NaN is returned.
*
* Arrays of length 0 are interpreted as 0 (with no error flags set).
* Arrays of length 1 are effectively cast to the equivalent object and
* converted using the above rules. All other arrays set the error to
* EINVAL & return NaN.
*
* NOTE: Set errno to 0 directly before a call to this function to
* determine whether or not conversion was successful (it does not clear
* the value for you).
*
* @param obj the json_object instance
* @returns a double floating point number
*/
JSON_EXPORT double json_object_get_double(const struct json_object *obj);
/** Set the double value of a json_object
*
* The type of obj is checked to be a json_type_double and 0 is returned
* if it is not without any further actions. If type of obj is json_type_double
* the obect value is chaned to new_value
*
* @param obj the json_object instance
* @param new_value the value to be set
* @returns 1 if value is set correctly, 0 otherwise
*/
JSON_EXPORT int json_object_set_double(struct json_object *obj,double new_value);
/* string type methods */
/** Create a new empty json_object of type json_type_string
*
* A copy of the string is made and the memory is managed by the json_object
*
* @param s the string
* @returns a json_object of type json_type_string
*/
JSON_EXPORT struct json_object* json_object_new_string(const char *s);
JSON_EXPORT struct json_object* json_object_new_string_len(const char *s, int len);
/** Get the string value of a json_object
*
* If the passed object is of type json_type_null (i.e. obj == NULL),
* NULL is returned.
*
* If the passed object of type json_type_string, the string contents
* are returned.
*
* Otherwise the JSON representation of the object is returned.
*
* The returned string memory is managed by the json_object and will
* be freed when the reference count of the json_object drops to zero.
*
* @param obj the json_object instance
* @returns a string or NULL
*/
JSON_EXPORT const char* json_object_get_string(struct json_object *obj);
/** Get the string length of a json_object
*
* If the passed object is not of type json_type_string then zero
* will be returned.
*
* @param obj the json_object instance
* @returns int
*/
JSON_EXPORT int json_object_get_string_len(const struct json_object *obj);
/** Set the string value of a json_object with zero terminated strings
* equivalent to json_object_set_string_len (obj, new_value, strlen(new_value))
* @returns 1 if value is set correctly, 0 otherwise
*/
JSON_EXPORT int json_object_set_string(json_object* obj, const char* new_value);
/** Set the string value of a json_object str
*
* The type of obj is checked to be a json_type_string and 0 is returned
* if it is not without any further actions. If type of obj is json_type_string
* the obect value is chaned to new_value
*
* @param obj the json_object instance
* @param new_value the value to be set; Since string legth is given in len this need not be zero terminated
* @param len the length of new_value
* @returns 1 if value is set correctly, 0 otherwise
*/
JSON_EXPORT int json_object_set_string_len(json_object* obj, const char* new_value, int len);
/** Check if two json_object's are equal
*
* If the passed objects are equal 1 will be returned.
* Equality is defined as follows:
* - json_objects of different types are never equal
* - json_objects of the same primitive type are equal if the
* c-representation of their value is equal
* - json-arrays are considered equal if all values at the same
* indices are equal (same order)
* - Complex json_objects are considered equal if all
* contained objects referenced by their key are equal,
* regardless their order.
*
* @param obj1 the first json_object instance
* @param obj2 the second json_object instance
* @returns whether both objects are equal or not
*/
JSON_EXPORT int json_object_equal(struct json_object *obj1,
struct json_object *obj2);
/**
* Perform a shallow copy of src into *dst as part of an overall json_object_deep_copy().
*
* If src is part of a containing object or array, parent will be non-NULL,
* and key or index will be provided.
* When shallow_copy is called *dst will be NULL, and must be non-NULL when it returns.
* src will never be NULL.
*
* If shallow_copy sets the serializer on an object, return 2 to indicate to
* json_object_deep_copy that it should not attempt to use the standard userdata
* copy function.
*
* @return On success 1 or 2, -1 on errors
*/
typedef int (json_c_shallow_copy_fn)(json_object *src, json_object *parent, const char *key, size_t index, json_object **dst);
/**
* The default shallow copy implementation for use with json_object_deep_copy().
* This simply calls the appropriate json_object_new_<type>() function and
* copies over the serializer function (_to_json_string internal field of
* the json_object structure) but not any _userdata or _user_delete values.
*
* If you're writing a custom shallow_copy function, perhaps because you're using
* your own custom serializer, you can call this first to create the new object
* before customizing it with json_object_set_serializer().
*
* @return 1 on success, -1 on errors, but never 2.
*/
json_c_shallow_copy_fn json_c_shallow_copy_default;
/**
* Copy the contents of the JSON object.
* The destination object must be initialized to NULL,
* to make sure this function won't overwrite an existing JSON object.
*
* This does roughly the same thing as
* `json_tokener_parse(json_object_get_string(src))`.
*
* @param src source JSON object whose contents will be copied
* @param dst pointer to the destination object where the contents of `src`;
* make sure this pointer is initialized to NULL
* @param shallow_copy an optional function to copy individual objects, needed
* when custom serializers are in use. See also
* json_object set_serializer.
*
* @returns 0 if the copy went well, -1 if an error occured during copy
* or if the destination pointer is non-NULL
*/
JSON_EXPORT int json_object_deep_copy(struct json_object *src, struct json_object **dst, json_c_shallow_copy_fn *shallow_copy);
#ifdef __cplusplus
}
#endif
#endif
json-c/linkhash.h 0000644 00000025617 15201526705 0007725 0 ustar 00 /*
* $Id: linkhash.h,v 1.6 2006/01/30 23:07:57 mclark Exp $
*
* Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
* Michael Clark <michael@metaparadigm.com>
* Copyright (c) 2009 Hewlett-Packard Development Company, L.P.
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See COPYING for details.
*
*/
/**
* @file
* @brief Internal methods for working with json_type_object objects. Although
* this is exposed by the json_object_get_object() function and within the
* json_object_iter type, it is not recommended for direct use.
*/
#ifndef _linkhash_h_
#define _linkhash_h_
#include "json_object.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* golden prime used in hash functions
*/
#define LH_PRIME 0x9e370001UL
/**
* The fraction of filled hash buckets until an insert will cause the table
* to be resized.
* This can range from just above 0 up to 1.0.
*/
#define LH_LOAD_FACTOR 0.66
/**
* sentinel pointer value for empty slots
*/
#define LH_EMPTY (void*)-1
/**
* sentinel pointer value for freed slots
*/
#define LH_FREED (void*)-2
/**
* default string hash function
*/
#define JSON_C_STR_HASH_DFLT 0
/**
* perl-like string hash function
*/
#define JSON_C_STR_HASH_PERLLIKE 1
/**
* This function sets the hash function to be used for strings.
* Must be one of the JSON_C_STR_HASH_* values.
* @returns 0 - ok, -1 if parameter was invalid
*/
int json_global_set_string_hash(const int h);
struct lh_entry;
/**
* callback function prototypes
*/
typedef void (lh_entry_free_fn) (struct lh_entry *e);
/**
* callback function prototypes
*/
typedef unsigned long (lh_hash_fn) (const void *k);
/**
* callback function prototypes
*/
typedef int (lh_equal_fn) (const void *k1, const void *k2);
/**
* An entry in the hash table
*/
struct lh_entry {
/**
* The key. Use lh_entry_k() instead of accessing this directly.
*/
const void *k;
/**
* A flag for users of linkhash to know whether or not they
* need to free k.
*/
int k_is_constant;
/**
* The value. Use lh_entry_v() instead of accessing this directly.
*/
const void *v;
/**
* The next entry
*/
struct lh_entry *next;
/**
* The previous entry.
*/
struct lh_entry *prev;
};
/**
* The hash table structure.
*/
struct lh_table {
/**
* Size of our hash.
*/
int size;
/**
* Numbers of entries.
*/
int count;
/**
* The first entry.
*/
struct lh_entry *head;
/**
* The last entry.
*/
struct lh_entry *tail;
struct lh_entry *table;
/**
* A pointer onto the function responsible for freeing an entry.
*/
lh_entry_free_fn *free_fn;
lh_hash_fn *hash_fn;
lh_equal_fn *equal_fn;
};
typedef struct lh_table lh_table;
/**
* Convenience list iterator.
*/
#define lh_foreach(table, entry) \
for(entry = table->head; entry; entry = entry->next)
/**
* lh_foreach_safe allows calling of deletion routine while iterating.
*
* @param table a struct lh_table * to iterate over
* @param entry a struct lh_entry * variable to hold each element
* @param tmp a struct lh_entry * variable to hold a temporary pointer to the next element
*/
#define lh_foreach_safe(table, entry, tmp) \
for(entry = table->head; entry && ((tmp = entry->next) || 1); entry = tmp)
/**
* Create a new linkhash table.
*
* @param size initial table size. The table is automatically resized
* although this incurs a performance penalty.
* @param free_fn callback function used to free memory for entries
* when lh_table_free or lh_table_delete is called.
* If NULL is provided, then memory for keys and values
* must be freed by the caller.
* @param hash_fn function used to hash keys. 2 standard ones are defined:
* lh_ptr_hash and lh_char_hash for hashing pointer values
* and C strings respectively.
* @param equal_fn comparison function to compare keys. 2 standard ones defined:
* lh_ptr_hash and lh_char_hash for comparing pointer values
* and C strings respectively.
* @return On success, a pointer to the new linkhash table is returned.
* On error, a null pointer is returned.
*/
extern struct lh_table* lh_table_new(int size,
lh_entry_free_fn *free_fn,
lh_hash_fn *hash_fn,
lh_equal_fn *equal_fn);
/**
* Convenience function to create a new linkhash table with char keys.
*
* @param size initial table size.
* @param free_fn callback function used to free memory for entries.
* @return On success, a pointer to the new linkhash table is returned.
* On error, a null pointer is returned.
*/
extern struct lh_table* lh_kchar_table_new(int size,
lh_entry_free_fn *free_fn);
/**
* Convenience function to create a new linkhash table with ptr keys.
*
* @param size initial table size.
* @param free_fn callback function used to free memory for entries.
* @return On success, a pointer to the new linkhash table is returned.
* On error, a null pointer is returned.
*/
extern struct lh_table* lh_kptr_table_new(int size,
lh_entry_free_fn *free_fn);
/**
* Free a linkhash table.
*
* If a lh_entry_free_fn callback free function was provided then it is
* called for all entries in the table.
*
* @param t table to free.
*/
extern void lh_table_free(struct lh_table *t);
/**
* Insert a record into the table.
*
* @param t the table to insert into.
* @param k a pointer to the key to insert.
* @param v a pointer to the value to insert.
*
* @return On success, <code>0</code> is returned.
* On error, a negative value is returned.
*/
extern int lh_table_insert(struct lh_table *t, const void *k, const void *v);
/**
* Insert a record into the table using a precalculated key hash.
*
* The hash h, which should be calculated with lh_get_hash() on k, is provided by
* the caller, to allow for optimization when multiple operations with the same
* key are known to be needed.
*
* @param t the table to insert into.
* @param k a pointer to the key to insert.
* @param v a pointer to the value to insert.
* @param h hash value of the key to insert
* @param opts if set to JSON_C_OBJECT_KEY_IS_CONSTANT, sets lh_entry.k_is_constant
* so t's free function knows to avoid freeing the key.
*/
extern int lh_table_insert_w_hash(struct lh_table *t, const void *k, const void *v, const unsigned long h, const unsigned opts);
/**
* Lookup a record in the table.
*
* @param t the table to lookup
* @param k a pointer to the key to lookup
* @return a pointer to the record structure of the value or NULL if it does not exist.
*/
extern struct lh_entry* lh_table_lookup_entry(struct lh_table *t, const void *k);
/**
* Lookup a record in the table using a precalculated key hash.
*
* The hash h, which should be calculated with lh_get_hash() on k, is provided by
* the caller, to allow for optimization when multiple operations with the same
* key are known to be needed.
*
* @param t the table to lookup
* @param k a pointer to the key to lookup
* @param h hash value of the key to lookup
* @return a pointer to the record structure of the value or NULL if it does not exist.
*/
extern struct lh_entry* lh_table_lookup_entry_w_hash(struct lh_table *t, const void *k, const unsigned long h);
/**
* Lookup a record into the table.
*
* @param t the table to lookup
* @param k a pointer to the key to lookup
* @return a pointer to the found value or NULL if it does not exist.
* @deprecated Use lh_table_lookup_ex() instead.
*/
THIS_FUNCTION_IS_DEPRECATED(extern const void* lh_table_lookup(struct lh_table *t, const void *k));
/**
* Lookup a record in the table.
*
* @param t the table to lookup
* @param k a pointer to the key to lookup
* @param v a pointer to a where to store the found value (set to NULL if it doesn't exist).
* @return whether or not the key was found
*/
extern json_bool lh_table_lookup_ex(struct lh_table *t, const void *k, void **v);
/**
* Delete a record from the table.
*
* If a callback free function is provided then it is called for the
* for the item being deleted.
* @param t the table to delete from.
* @param e a pointer to the entry to delete.
* @return 0 if the item was deleted.
* @return -1 if it was not found.
*/
extern int lh_table_delete_entry(struct lh_table *t, struct lh_entry *e);
/**
* Delete a record from the table.
*
* If a callback free function is provided then it is called for the
* for the item being deleted.
* @param t the table to delete from.
* @param k a pointer to the key to delete.
* @return 0 if the item was deleted.
* @return -1 if it was not found.
*/
extern int lh_table_delete(struct lh_table *t, const void *k);
extern int lh_table_length(struct lh_table *t);
/**
* Prints a message to <code>stdout</code>,
* then exits the program with an exit code of <code>1</code>.
*
* @param msg Message format string, like for <code>printf</code>.
* @param ... Format args.
*
* @deprecated Since it is not a good idea to exit the entire program
* because of an internal library failure, json-c will no longer
* use this function internally.
* However, because its interface is public, it will remain part of
* the API on the off chance of legacy software using it externally.
*/
THIS_FUNCTION_IS_DEPRECATED(void lh_abort(const char *msg, ...));
/**
* Resizes the specified table.
*
* @param t Pointer to table to resize.
* @param new_size New table size. Must be positive.
*
* @return On success, <code>0</code> is returned.
* On error, a negative value is returned.
*/
int lh_table_resize(struct lh_table *t, int new_size);
/**
* @deprecated Don't use this outside of linkhash.h:
*/
#if !defined(_MSC_VER) || (_MSC_VER > 1800)
/* VS2010 can't handle inline funcs, so skip it there */
#define _LH_INLINE inline
#else
#define _LH_INLINE
#endif
/**
* Calculate the hash of a key for a given table.
*
* This is an exension to support functions that need to calculate
* the hash several times and allows them to do it just once and then pass
* in the hash to all utility functions. Depending on use case, this can be a
* considerable performance improvement.
* @param t the table (used to obtain hash function)
* @param k a pointer to the key to lookup
* @return the key's hash
*/
static _LH_INLINE unsigned long lh_get_hash(const struct lh_table *t, const void *k)
{
return t->hash_fn(k);
}
#undef _LH_INLINE
/**
* @deprecated Don't use this outside of linkhash.h:
*/
#ifdef __UNCONST
#define _LH_UNCONST(a) __UNCONST(a)
#else
#define _LH_UNCONST(a) ((void *)(uintptr_t)(const void *)(a))
#endif
/**
* Return a non-const version of lh_entry.k.
*
* lh_entry.k is const to indicate and help ensure that linkhash itself doesn't modify
* it, but callers are allowed to do what they want with it.
* See also lh_entry.k_is_constant
*/
#define lh_entry_k(entry) _LH_UNCONST((entry)->k)
/**
* Return a non-const version of lh_entry.v.
*
* v is const to indicate and help ensure that linkhash itself doesn't modify
* it, but callers are allowed to do what they want with it.
*/
#define lh_entry_v(entry) _LH_UNCONST((entry)->v)
#ifdef __cplusplus
}
#endif
#endif
json-c/debug.h 0000644 00000003274 15201526705 0007205 0 ustar 00 /*
* $Id: debug.h,v 1.5 2006/01/30 23:07:57 mclark Exp $
*
* Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
* Michael Clark <michael@metaparadigm.com>
* Copyright (c) 2009 Hewlett-Packard Development Company, L.P.
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See COPYING for details.
*
*/
/**
* @file
* @brief Do not use, json-c internal, may be changed or removed at any time.
*/
#ifndef _DEBUG_H_
#define _DEBUG_H_
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
extern void mc_set_debug(int debug);
extern int mc_get_debug(void);
extern void mc_set_syslog(int syslog);
extern void mc_debug(const char *msg, ...);
extern void mc_error(const char *msg, ...);
extern void mc_info(const char *msg, ...);
#ifndef __STRING
#define __STRING(x) #x
#endif
#ifndef PARSER_BROKEN_FIXED
#define JASSERT(cond) do {} while(0)
#else
#define JASSERT(cond) do { \
if (!(cond)) { \
mc_error("cjson assert failure %s:%d : cond \"" __STRING(cond) "failed\n", __FILE__, __LINE__); \
*(int *)0 = 1;\
abort(); \
}\
} while(0)
#endif
#define MC_ERROR(x, ...) mc_error(x, ##__VA_ARGS__)
#ifdef MC_MAINTAINER_MODE
#define MC_SET_DEBUG(x) mc_set_debug(x)
#define MC_GET_DEBUG() mc_get_debug()
#define MC_SET_SYSLOG(x) mc_set_syslog(x)
#define MC_DEBUG(x, ...) mc_debug(x, ##__VA_ARGS__)
#define MC_INFO(x, ...) mc_info(x, ##__VA_ARGS__)
#else
#define MC_SET_DEBUG(x) if (0) mc_set_debug(x)
#define MC_GET_DEBUG() (0)
#define MC_SET_SYSLOG(x) if (0) mc_set_syslog(x)
#define MC_DEBUG(x, ...) if (0) mc_debug(x, ##__VA_ARGS__)
#define MC_INFO(x, ...) if (0) mc_info(x, ##__VA_ARGS__)
#endif
#ifdef __cplusplus
}
#endif
#endif
json-c/json_pointer.h 0000644 00000011340 15201526705 0010621 0 ustar 00 /*
* Copyright (c) 2016 Alexadru Ardelean.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See COPYING for details.
*
*/
/**
* @file
* @brief JSON Pointer (RFC 6901) implementation for retrieving
* objects from a json-c object tree.
*/
#ifndef _json_pointer_h_
#define _json_pointer_h_
#include "json_object.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Retrieves a JSON sub-object from inside another JSON object
* using the JSON pointer notation as defined in RFC 6901
* https://tools.ietf.org/html/rfc6901
*
* The returned JSON sub-object is equivalent to parsing manually the
* 'obj' JSON tree ; i.e. it's not a new object that is created, but rather
* a pointer inside the JSON tree.
*
* Internally, this is equivalent to doing a series of 'json_object_object_get()'
* and 'json_object_array_get_idx()' along the given 'path'.
*
* Note that the 'path' string supports 'printf()' type arguments, so, whatever
* is added after the 'res' param will be treated as an argument for 'path'
* Example: json_pointer_get(obj, "/foo/%d/%s", &res, 0, bar)
* This means, that you need to escape '%' with '%%' (just like in printf())
*
* @param obj the json_object instance/tree from where to retrieve sub-objects
* @param path a (RFC6901) string notation for the sub-object to retrieve
* @param res a pointer where to store a reference to the json_object
* associated with the given path
*
* @return negative if an error (or not found), or 0 if succeeded
*/
int json_pointer_get(struct json_object *obj, const char *path, struct json_object **res);
/**
* This is a variant of 'json_pointer_get()' that supports printf() style arguments.
*
* Example: json_pointer_getf(obj, res, "/foo/%d/%s", 0, bak)
* This also means that you need to escape '%' with '%%' (just like in printf())
*
* Please take into consideration all recommended 'printf()' format security
* aspects when using this function.
*
* @param obj the json_object instance/tree to which to add a sub-object
* @param res a pointer where to store a reference to the json_object
* associated with the given path
* @param path_fmt a printf() style format for the path
*
* @return negative if an error (or not found), or 0 if succeeded
*/
int json_pointer_getf(struct json_object *obj, struct json_object **res, const char *path_fmt, ...);
/**
* Sets JSON object 'value' in the 'obj' tree at the location specified
* by the 'path'. 'path' is JSON pointer notation as defined in RFC 6901
* https://tools.ietf.org/html/rfc6901
*
* Note that 'obj' is a double pointer, mostly for the "" (empty string)
* case, where the entire JSON object would be replaced by 'value'.
* In the case of the "" path, the object at '*obj' will have it's refcount
* decremented with 'json_object_put()' and the 'value' object will be assigned to it.
*
* For other cases (JSON sub-objects) ownership of 'value' will be transferred into
* '*obj' via 'json_object_object_add()' & 'json_object_array_put_idx()', so the
* only time the refcount should be decremented for 'value' is when the return value of
* 'json_pointer_set()' is negative (meaning the 'value' object did not get set into '*obj').
*
* That also implies that 'json_pointer_set()' does not do any refcount incrementing.
* (Just that single decrement that was mentioned above).
*
* Note that the 'path' string supports 'printf()' type arguments, so, whatever
* is added after the 'value' param will be treated as an argument for 'path'
* Example: json_pointer_set(obj, "/foo/%d/%s", value, 0, bak)
* This means, that you need to escape '%' with '%%' (just like in printf())
*
* @param obj the json_object instance/tree to which to add a sub-object
* @param path a (RFC6901) string notation for the sub-object to set in the tree
* @param value object to set at path
*
* @return negative if an error (or not found), or 0 if succeeded
*/
int json_pointer_set(struct json_object **obj, const char *path, struct json_object *value);
/**
* This is a variant of 'json_pointer_set()' that supports printf() style arguments.
*
* Example: json_pointer_setf(obj, value, "/foo/%d/%s", 0, bak)
* This also means that you need to escape '%' with '%%' (just like in printf())
*
* Please take into consideration all recommended 'printf()' format security
* aspects when using this function.
*
* @param obj the json_object instance/tree to which to add a sub-object
* @param value object to set at path
* @param path_fmt a printf() style format for the path
*
* @return negative if an error (or not found), or 0 if succeeded
*/
int json_pointer_setf(struct json_object **obj, struct json_object *value, const char *path_fmt, ...);
#ifdef __cplusplus
}
#endif
#endif
verto.h 0000644 00000045755 15201526705 0006077 0 ustar 00 /*
* Copyright 2011 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef VERTO_H_
#define VERTO_H_
#include <time.h> /* For time_t */
#include <unistd.h> /* For pid_t */
#ifdef WIN32
#include <windows.h>
typedef HANDLE verto_proc;
typedef DWORD verto_proc_status;
#else
#include <sys/types.h>
typedef pid_t verto_proc;
typedef int verto_proc_status;
#endif
#define VERTO_SIG_IGN ((verto_callback *) 1)
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
typedef struct verto_ctx verto_ctx;
typedef struct verto_ev verto_ev;
typedef enum {
VERTO_EV_TYPE_NONE = 0,
VERTO_EV_TYPE_IO = 1,
VERTO_EV_TYPE_TIMEOUT = 1 << 1,
VERTO_EV_TYPE_IDLE = 1 << 2,
VERTO_EV_TYPE_SIGNAL = 1 << 3,
VERTO_EV_TYPE_CHILD = 1 << 4
} verto_ev_type;
typedef enum {
VERTO_EV_FLAG_NONE = 0,
VERTO_EV_FLAG_PERSIST = 1,
VERTO_EV_FLAG_PRIORITY_LOW = 1 << 1,
VERTO_EV_FLAG_PRIORITY_MEDIUM = 1 << 2,
VERTO_EV_FLAG_PRIORITY_HIGH = 1 << 3,
VERTO_EV_FLAG_IO_READ = 1 << 4,
VERTO_EV_FLAG_IO_WRITE = 1 << 5,
VERTO_EV_FLAG_IO_ERROR = 1 << 7,
VERTO_EV_FLAG_IO_CLOSE_FD = 1 << 8,
VERTO_EV_FLAG_REINITIABLE = 1 << 6,
_VERTO_EV_FLAG_MUTABLE_MASK = VERTO_EV_FLAG_PRIORITY_LOW
| VERTO_EV_FLAG_PRIORITY_MEDIUM
| VERTO_EV_FLAG_PRIORITY_HIGH
| VERTO_EV_FLAG_IO_READ
| VERTO_EV_FLAG_IO_WRITE,
_VERTO_EV_FLAG_MAX = VERTO_EV_FLAG_IO_CLOSE_FD
} verto_ev_flag;
typedef void (verto_callback)(verto_ctx *ctx, verto_ev *ev);
/**
* Creates a new event context using an optionally specified implementation
* and/or optionally specified required features.
*
* If you are an application that has already decided on using a particular
* event loop implementation, you should not call this function, but instead
* import the verto-NAME.h header and link against the verto-NAME.so, where
* NAME is the implementation you wish to use.
*
* If you are a library, you should generally avoid creating event contexts
* on your own but allow applications to pass in a verto_ctx you can use.
*
* There are two cases where you should use this function. The first is
* where you have a need to choose an implementation at run time, usually
* for testing purposes. The second and more common is when you simply
* wish to remain implementation agnostic. In this later case, you should
* always call like this: verto_new(NULL, ...). This lets verto choose the best
* implementation to use.
*
* If impl is not NULL, a new context is returned which is backed by the
* implementation specified. If the implementation specified is not
* available or if the required types (reqtypes) are not provided by the
* named implementation, NULL is returned. The parameter 'impl' can specify:
* * The full path to an implementation library
* * The name of the implementation library (i.e. - "glib" or "libev")
*
* If impl is NULL, verto will attempt to automatically determine the
* best implementation to use.
*
* First, verto will attempt to use an existing, previously loaded
* implementation. This is handled automatically by internal caching of either
* the first implementation loaded or the one specified by verto_set_default().
*
* Second, verto will attempt to discern if you are already linked to any
* of the supported implementations (to avoid wasting memory by loading
* extra unnecessary libraries). If you are linked to one supported
* implementation, that implementation will be chosen. If you are linked
* to more than one supported implementation one of the ones linked to
* will be chosen, but the order of the particular choice is undefined.
*
* Third, verto will attempt to load the compile-time default, if defined at
* build time and available at runtime.
*
* Last, verto will attempt to load any implementation installed. The specific
* order of this step is undefined.
*
* In all cases above, if the implementation does not support all the specified
* features (reqtypes), it will be skipped and processing will continue from
* where it left off. This means that if verto_new() returns non-NULL it is
* guaranteed to support the features you specified.
*
* @see verto_set_default()
* @param impl The implementation to use, or NULL.
* @param reqtypes A bitwise or'd list of required event type features.
* @return A new verto_ctx, or NULL on error. Call verto_free() when done.
*/
verto_ctx *
verto_new(const char *impl, verto_ev_type reqtypes);
/**
* Gets the default event context using an optionally specified implementation.
*
* This function is essentially a singleton version of verto_new(). However,
* since this function must return the same loop as the *_default() call of
* the underlying implementation (if such a function exists), it is NOT a
* global singleton, but a per-implementation singleton. For this reason, you
* must call verto_free() when you are done with this loop. Even after calling
* verto_free() on the default verto_ctx, you can safely call verto_default()
* again and receive a new reference to the same (internally default) loop.
*
* In all other respects, verto_default() acts exactly like verto_new().
*
* @see verto_new()
* @see verto_free()
* @param impl The implementation to use, or NULL.
* @param reqtypes A bitwise or'd list of required event type features.
* @return The default verto_ctx, or NULL on error. Call verto_free() when done.
*/
verto_ctx *
verto_default(const char *impl, verto_ev_type reqtypes);
/**
* Sets the default implementation to use by its name.
*
* This function returns 1 on success and 0 on failure. It can fail for the
* following reasons:
* 1. The default implementation was already set via verto_set_default().
* 2. The implementation specified could not be found.
* 3. The implementation specified didn't support the features specified.
* 4. The impl argument was NULL.
* 5. verto_new() was already called.
* 6. verto_default() was already called.
* 7. verto_new_NAME() was already called.
* 8. verto_default_NAME() was already called.
* 9. verto_convert_NAME() was already called.
*
* @see verto_new()
* @see verto_default()
* @param impl The implementation to use.
* @param reqtypes A bitwise or'd list of required event type features.
* @return The default verto_ctx, or NULL on error. Call verto_free() when done.
*/
int
verto_set_default(const char *impl, verto_ev_type reqtypes);
/**
* Sets the allocator to use for verto_ctx and verto_ev objects.
*
* If you plan to set the allocator, you MUST call this function before any
* other verto_*() calls.
*
* @see verto_new()
* @see verto_default()
* @see verto_add_io()
* @see verto_add_timeout()
* @see verto_add_idle()
* @see verto_add_signal()
* @see verto_add_child()
* @param resize The allocator to use (behaves like realloc();
* resize(ptr, 0) must free memory at ptr.)
* @param hierarchical Zero if the allocator is not hierarchical
*/
int
verto_set_allocator(void *(*resize)(void *mem, size_t size), int hierarchical);
/**
* Frees a verto_ctx.
*
* When called on a default verto_ctx, the reference will be freed but the
* internal default loop will still be available via another call to
* verto_default().
*
* @see verto_new()
* @see verto_default()
* @param ctx The verto_ctx to free.
*/
void
verto_free(verto_ctx *ctx);
/**
* Frees global state.
*
* Remove and free all allocated global state. Call only when no further
* contexts exist and all threads have exited.
*
* @see verto_new()
* @see verto_free()
* @see verto_default()
*/
void
verto_cleanup(void);
/**
* Run the verto_ctx forever, or at least until verto_break() is called.
*
* @see verto_break()
* @param ctx The verto_ctx to run.
*/
void
verto_run(verto_ctx *ctx);
/**
* Run the verto_ctx once. May block.
*
* @param ctx The verto_ctx to run once.
*/
void
verto_run_once(verto_ctx *ctx);
/**
* Exits the currently running verto_ctx.
*
* @see verto_run()
* @param ctx The verto_ctx to exit.
*/
void
verto_break(verto_ctx *ctx);
/**
* Re-initializes the verto_ctx.
*
* This function deletes all events, except those which have set the
* VERTO_EV_FLAG_REINITIABLE flag. If you fork(), you MUST call this in the
* child process after the fork!
*
* If this function fails it indicates that at least one
* VERTO_EV_FLAG_REINITIABLE event was not rearmed or that ctx was NULL.
*
* @see verto_new()
* @see verto_default()
* @param ctx The verto_ctx to re-initialize.
* @return Non-zero on success, 0 on error.
*/
int
verto_reinitialize(verto_ctx *ctx);
/**
* Adds a callback executed when a file descriptor is ready to be read/written.
*
* All verto_ev events are automatically freed when their parent verto_ctx is
* freed. You do not need to free them manually. If VERTO_EV_FLAG_PERSIST is
* provided, the event will repeat until verto_del() is called. If
* VERTO_EV_FLAG_PERSIST is not provided, the event will be freed automatically
* after its execution. In either case, you may call verto_del() at any time
* to prevent the event from executing.
* If VERTO_EV_FLAG_IO_CLOSE_FD is provided the passed in fd is automatically
* closed when the event is freed with verto_del()
*
* NOTE: On Windows, the underlying select() only works with sockets. As such,
* any attempt to add a non-socket io event on Windows will produce undefined
* results and may even crash.
*
* @see verto_del()
* @param ctx The verto_ctx which will fire the callback.
* @param flags The flags to set (at least one VERTO_EV_FLAG_IO* required).
* @param callback The callback to fire.
* @param fd The file descriptor to watch for reads.
* @return The verto_ev registered with the event context or NULL on error.
*/
verto_ev *
verto_add_io(verto_ctx *ctx, verto_ev_flag flags,
verto_callback *callback, int fd);
/**
* Adds a callback executed after a period of time.
*
* All verto_ev events are automatically freed when their parent verto_ctx is
* freed. You do not need to free them manually. If VERTO_EV_FLAG_PERSIST is
* provided, the event will repeat until verto_del() is called. If
* VERTO_EV_FLAG_PERSIST is not provided, the event will be freed automatically
* after its execution. In either case, you may call verto_del() at any time
* to prevent the event from executing.
*
* @see verto_del()
* @param ctx The verto_ctx which will fire the callback.
* @param flags The flags to set.
* @param callback The callback to fire.
* @param interval Time period to wait before firing (in milliseconds).
* @return The verto_ev registered with the event context.
*/
verto_ev *
verto_add_timeout(verto_ctx *ctx, verto_ev_flag flags,
verto_callback *callback, time_t interval);
/**
* Adds a callback executed when there is nothing else to do.
*
* All verto_ev events are automatically freed when their parent verto_ctx is
* freed. You do not need to free them manually. If VERTO_EV_FLAG_PERSIST is
* provided, the event will repeat until verto_del() is called. If
* VERTO_EV_FLAG_PERSIST is not provided, the event will be freed automatically
* after its execution. In either case, you may call verto_del() at any time
* to prevent the event from executing.
*
* @see verto_del()
* @param ctx The verto_ctx which will fire the callback.
* @param flags The flags to set.
* @param callback The callback to fire.
* @return The verto_ev registered with the event context.
*/
verto_ev *
verto_add_idle(verto_ctx *ctx, verto_ev_flag flags,
verto_callback *callback);
/**
* Adds a callback executed when a signal is received.
*
* All verto_ev events are automatically freed when their parent verto_ctx is
* freed. You do not need to free them manually. If VERTO_EV_FLAG_PERSIST is
* provided, the event will repeat until verto_del() is called. If
* VERTO_EV_FLAG_PERSIST is not provided, the event will be freed automatically
* after its execution. In either case, you may call verto_del() at any time
* to prevent the event from executing.
*
* NOTE: If you attempt to ignore a signal without the VERTO_EV_FLAG_PERSIST
* flag, this function fails.
*
* NOTE: SIGCHLD is expressly not supported. If you want this notification,
* please use verto_add_child().
*
* WARNNIG: Signal events can only be reliably received in the default verto_ctx
* in some implementations. Attempting to receive signal events in non-default
* loops may result in assert() failures.
*
* WARNING: While verto does its best to protect you from crashes, there is
* essentially no way to do signal events if you mix multiple implementations in
* a single process. Attempting to do so will result in undefined behavior,
* and potentially even a crash. You have been warned.
*
* @see verto_add_child()
* @see verto_repeat()
* @see verto_del()
* @param ctx The verto_ctx which will fire the callback.
* @param flags The flags to set.
* @param callback The callback to fire.
* @param signal The signal to watch for.
* @return The verto_ev registered with the event context.
*/
verto_ev *
verto_add_signal(verto_ctx *ctx, verto_ev_flag flags,
verto_callback *callback, int signal);
/**
* Adds a callback executed when a child process exits.
*
* This event will be freed automatically after its execution. Due to the
* nature of a process' life-cycle, child events cannot persist (processes only
* exit once). This function returns NULL if you attempt to use
* VERTO_EV_FLAG_PERSIST. You may, of course, call verto_del() at any time to
* prevent the callback from firing.
*
* @see verto_del()
* @param ctx The verto_ctx which will fire the callback.
* @param flags The flags to set.
* @param callback The callback to fire.
* @param child The pid (POSIX) or handle (Win32) of the child to watch for.
* @return The verto_ev registered with the event context.
*/
verto_ev *
verto_add_child(verto_ctx *ctx, verto_ev_flag flags,
verto_callback *callback, verto_proc proc);
/**
* Sets the private pointer of the verto_ev.
*
* The free callback will be called in two cases:
* 1. When the event is deleted (manually or automatically)
* 2. When verto_set_private() is called again, unless
* free is NULL.
*
* @see verto_get_private()
* @param ev The verto_ev
* @param priv The private value to store
* @param free The callback used to free the data or NULL
*/
void
verto_set_private(verto_ev *ev, void *priv, verto_callback *free);
/**
* Gets the private pointer of the verto_ev.
*
* @see verto_set_private()
* @param ev The verto_ev
* @return The verto_ev private pointer
*/
void *
verto_get_private(const verto_ev *ev);
/**
* Gets the type of the verto_ev.
*
* @see verto_add_io()
* @see verto_add_timeout()
* @see verto_add_idle()
* @see verto_add_signal()
* @see verto_add_child()
* @param ev The verto_ev
* @return The verto_ev type
*/
verto_ev_type
verto_get_type(const verto_ev *ev);
/**
* Gets the flags associated with the given verto_ev.
*
* @see verto_add_io()
* @see verto_add_timeout()
* @see verto_add_idle()
* @see verto_add_signal()
* @see verto_add_child()
* @see verto_set_flags()
* @param ev The verto_ev
* @return The verto_ev type
*/
verto_ev_flag
verto_get_flags(const verto_ev *ev);
/**
* Sets the flags associated with the given verto_ev.
*
* See _VERTO_EV_FLAG_MUTABLE_MASK for the flags that can be changed
* with this function. All others will be ignored. If the flags specified
* are the same as the flags the event already has, this function is a no-op.
*
* @see verto_add_io()
* @see verto_add_timeout()
* @see verto_add_idle()
* @see verto_add_signal()
* @see verto_add_child()
* @see verto_get_flags()
* @param ev The verto_ev
* @param flags The flags for the event
*/
void
verto_set_flags(verto_ev *ev, verto_ev_flag flags);
/**
* Gets the file descriptor associated with a read/write verto_ev.
*
* @see verto_add_io()
* @param ev The verto_ev to retrieve the file descriptor from.
* @return The file descriptor, or -1 if not a read/write event.
*/
int
verto_get_fd(const verto_ev *ev);
/**
* Gets the file descriptor state from when the event fires.
*
* @see verto_add_io()
* @param ev The verto_ev to retrieve the fd state from.
* @return The fd state.
*/
verto_ev_flag
verto_get_fd_state(const verto_ev *ev);
/**
* Gets the interval associated with a timeout verto_ev.
*
* @see verto_add_timeout()
* @param ev The verto_ev to retrieve the interval from.
* @return The interval, or 0 if not a timeout event.
*/
time_t
verto_get_interval(const verto_ev *ev);
/**
* Gets the signal associated with a signal verto_ev.
*
* @see verto_add_signal()
* @param ev The verto_ev to retrieve the signal from.
* @return The signal, or -1 if not a signal event.
*/
int
verto_get_signal(const verto_ev *ev);
/**
* Gets the process associated with a child verto_ev.
*
* @see verto_add_child()
* @param ev The verto_ev to retrieve the process from.
* @return The pid/handle, or 0/NULL if not a child event (POSIX/Win32).
*/
verto_proc
verto_get_proc(const verto_ev *ev);
/**
* Gets the status of the process which caused this event to fire.
*
* @see verto_add_child()
* @param ev The verto_ev to retrieve the status from.
* @return The pid/handle status.
*/
verto_proc_status
verto_get_proc_status(const verto_ev *ev);
/**
* Gets the verto_ctx associated with a verto_ev.
*
* This is a borrowed reference, don't attempt to free it!
*
* @param ev The verto_ev to retrieve the verto_ctx from.
* @return The verto_ctx.
*/
verto_ctx *
verto_get_ctx(const verto_ev *ev);
/**
* Removes an event from from the event context and frees it.
*
* The event and its contents cannot be used after this call.
*
* @see verto_add_io()
* @see verto_add_timeout()
* @see verto_add_idle()
* @see verto_add_signal()
* @see verto_add_child()
* @param ev The event to delete.
*/
void
verto_del(verto_ev *ev);
/**
* Returns the event types supported by this implementation.
*
* @param ctx The verto_ctx to query.
* @return The event types supported.
*/
verto_ev_type
verto_get_supported_types(verto_ctx *ctx);
#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */
#endif /* VERTO_H_ */
c++/8/parallel/checkers.h 0000644 00000004374 15201526705 0011032 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/checkers.h
* @brief Routines for checking the correctness of algorithm results.
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Johannes Singler.
#ifndef _GLIBCXX_PARALLEL_CHECKERS_H
#define _GLIBCXX_PARALLEL_CHECKERS_H 1
#include <cstdio>
#include <bits/stl_algobase.h>
#include <bits/stl_function.h>
namespace __gnu_parallel
{
/**
* @brief Check whether @c [__begin, @c __end) is sorted according
* to @c __comp.
* @param __begin Begin iterator of sequence.
* @param __end End iterator of sequence.
* @param __comp Comparator.
* @return @c true if sorted, @c false otherwise.
*/
template<typename _IIter, typename _Compare>
bool
__is_sorted(_IIter __begin, _IIter __end, _Compare __comp)
{
if (__begin == __end)
return true;
_IIter __current(__begin), __recent(__begin);
unsigned long long __position = 1;
for (__current++; __current != __end; __current++)
{
if (__comp(*__current, *__recent))
{
return false;
}
__recent = __current;
__position++;
}
return true;
}
}
#endif /* _GLIBCXX_PARALLEL_CHECKERS_H */
c++/8/parallel/losertree.h 0000644 00000067660 15201526705 0011256 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/losertree.h
* @brief Many generic loser tree variants.
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Johannes Singler.
#ifndef _GLIBCXX_PARALLEL_LOSERTREE_H
#define _GLIBCXX_PARALLEL_LOSERTREE_H 1
#include <bits/stl_algobase.h>
#include <bits/stl_function.h>
#include <parallel/features.h>
#include <parallel/base.h>
namespace __gnu_parallel
{
/**
* @brief Guarded loser/tournament tree.
*
* The smallest element is at the top.
*
* Guarding is done explicitly through one flag _M_sup per element,
* inf is not needed due to a better initialization routine. This
* is a well-performing variant.
*
* @param _Tp the element type
* @param _Compare the comparator to use, defaults to std::less<_Tp>
*/
template<typename _Tp, typename _Compare>
class _LoserTreeBase
{
protected:
/** @brief Internal representation of a _LoserTree element. */
struct _Loser
{
/** @brief flag, true iff this is a "maximum" __sentinel. */
bool _M_sup;
/** @brief __index of the __source __sequence. */
int _M_source;
/** @brief _M_key of the element in the _LoserTree. */
_Tp _M_key;
};
unsigned int _M_ik, _M_k, _M_offset;
/** log_2{_M_k} */
unsigned int _M_log_k;
/** @brief _LoserTree __elements. */
_Loser* _M_losers;
/** @brief _Compare to use. */
_Compare _M_comp;
/**
* @brief State flag that determines whether the _LoserTree is empty.
*
* Only used for building the _LoserTree.
*/
bool _M_first_insert;
public:
/**
* @brief The constructor.
*
* @param __k The number of sequences to merge.
* @param __comp The comparator to use.
*/
_LoserTreeBase(unsigned int __k, _Compare __comp)
: _M_comp(__comp)
{
_M_ik = __k;
// Compute log_2{_M_k} for the _Loser Tree
_M_log_k = __rd_log2(_M_ik - 1) + 1;
// Next greater power of 2.
_M_k = 1 << _M_log_k;
_M_offset = _M_k;
// Avoid default-constructing _M_losers[]._M_key
_M_losers = static_cast<_Loser*>(::operator new(2 * _M_k
* sizeof(_Loser)));
for (unsigned int __i = _M_ik - 1; __i < _M_k; ++__i)
_M_losers[__i + _M_k]._M_sup = true;
_M_first_insert = true;
}
/**
* @brief The destructor.
*/
~_LoserTreeBase()
{
for (unsigned int __i = 0; __i < (2 * _M_k); ++__i)
_M_losers[__i].~_Loser();
::operator delete(_M_losers);
}
/**
* @brief Initializes the sequence "_M_source" with the element "__key".
*
* @param __key the element to insert
* @param __source __index of the __source __sequence
* @param __sup flag that determines whether the value to insert is an
* explicit __supremum.
*/
void
__insert_start(const _Tp& __key, int __source, bool __sup)
{
unsigned int __pos = _M_k + __source;
if (_M_first_insert)
{
// Construct all keys, so we can easily destruct them.
for (unsigned int __i = 0; __i < (2 * _M_k); ++__i)
::new(&(_M_losers[__i]._M_key)) _Tp(__key);
_M_first_insert = false;
}
else
_M_losers[__pos]._M_key = __key;
_M_losers[__pos]._M_sup = __sup;
_M_losers[__pos]._M_source = __source;
}
/**
* @return the index of the sequence with the smallest element.
*/
int __get_min_source()
{ return _M_losers[0]._M_source; }
};
/**
* @brief Stable _LoserTree variant.
*
* Provides the stable implementations of insert_start, __init_winner,
* __init and __delete_min_insert.
*
* Unstable variant is done using partial specialisation below.
*/
template<bool __stable/* default == true */, typename _Tp,
typename _Compare>
class _LoserTree
: public _LoserTreeBase<_Tp, _Compare>
{
typedef _LoserTreeBase<_Tp, _Compare> _Base;
using _Base::_M_k;
using _Base::_M_comp;
using _Base::_M_losers;
using _Base::_M_first_insert;
public:
_LoserTree(unsigned int __k, _Compare __comp)
: _Base::_LoserTreeBase(__k, __comp)
{ }
unsigned int
__init_winner(unsigned int __root)
{
if (__root >= _M_k)
return __root;
else
{
unsigned int __left = __init_winner(2 * __root);
unsigned int __right = __init_winner(2 * __root + 1);
if (_M_losers[__right]._M_sup
|| (!_M_losers[__left]._M_sup
&& !_M_comp(_M_losers[__right]._M_key,
_M_losers[__left]._M_key)))
{
// Left one is less or equal.
_M_losers[__root] = _M_losers[__right];
return __left;
}
else
{
// Right one is less.
_M_losers[__root] = _M_losers[__left];
return __right;
}
}
}
void __init()
{ _M_losers[0] = _M_losers[__init_winner(1)]; }
/**
* @brief Delete the smallest element and insert a new element from
* the previously smallest element's sequence.
*
* This implementation is stable.
*/
// Do not pass a const reference since __key will be used as
// local variable.
void
__delete_min_insert(_Tp __key, bool __sup)
{
using std::swap;
#if _GLIBCXX_PARALLEL_ASSERTIONS
// no dummy sequence can ever be at the top!
_GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1);
#endif
int __source = _M_losers[0]._M_source;
for (unsigned int __pos = (_M_k + __source) / 2; __pos > 0;
__pos /= 2)
{
// The smaller one gets promoted, ties are broken by _M_source.
if ((__sup && (!_M_losers[__pos]._M_sup
|| _M_losers[__pos]._M_source < __source))
|| (!__sup && !_M_losers[__pos]._M_sup
&& ((_M_comp(_M_losers[__pos]._M_key, __key))
|| (!_M_comp(__key, _M_losers[__pos]._M_key)
&& _M_losers[__pos]._M_source < __source))))
{
// The other one is smaller.
std::swap(_M_losers[__pos]._M_sup, __sup);
std::swap(_M_losers[__pos]._M_source, __source);
swap(_M_losers[__pos]._M_key, __key);
}
}
_M_losers[0]._M_sup = __sup;
_M_losers[0]._M_source = __source;
_M_losers[0]._M_key = __key;
}
};
/**
* @brief Unstable _LoserTree variant.
*
* Stability (non-stable here) is selected with partial specialization.
*/
template<typename _Tp, typename _Compare>
class _LoserTree</* __stable == */false, _Tp, _Compare>
: public _LoserTreeBase<_Tp, _Compare>
{
typedef _LoserTreeBase<_Tp, _Compare> _Base;
using _Base::_M_log_k;
using _Base::_M_k;
using _Base::_M_comp;
using _Base::_M_losers;
using _Base::_M_first_insert;
public:
_LoserTree(unsigned int __k, _Compare __comp)
: _Base::_LoserTreeBase(__k, __comp)
{ }
/**
* Computes the winner of the competition at position "__root".
*
* Called recursively (starting at 0) to build the initial tree.
*
* @param __root __index of the "game" to start.
*/
unsigned int
__init_winner(unsigned int __root)
{
if (__root >= _M_k)
return __root;
else
{
unsigned int __left = __init_winner(2 * __root);
unsigned int __right = __init_winner(2 * __root + 1);
if (_M_losers[__right]._M_sup
|| (!_M_losers[__left]._M_sup
&& !_M_comp(_M_losers[__right]._M_key,
_M_losers[__left]._M_key)))
{
// Left one is less or equal.
_M_losers[__root] = _M_losers[__right];
return __left;
}
else
{
// Right one is less.
_M_losers[__root] = _M_losers[__left];
return __right;
}
}
}
void
__init()
{ _M_losers[0] = _M_losers[__init_winner(1)]; }
/**
* Delete the _M_key smallest element and insert the element __key
* instead.
*
* @param __key the _M_key to insert
* @param __sup true iff __key is an explicitly marked supremum
*/
// Do not pass a const reference since __key will be used as local
// variable.
void
__delete_min_insert(_Tp __key, bool __sup)
{
using std::swap;
#if _GLIBCXX_PARALLEL_ASSERTIONS
// no dummy sequence can ever be at the top!
_GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1);
#endif
int __source = _M_losers[0]._M_source;
for (unsigned int __pos = (_M_k + __source) / 2; __pos > 0;
__pos /= 2)
{
// The smaller one gets promoted.
if (__sup || (!_M_losers[__pos]._M_sup
&& _M_comp(_M_losers[__pos]._M_key, __key)))
{
// The other one is smaller.
std::swap(_M_losers[__pos]._M_sup, __sup);
std::swap(_M_losers[__pos]._M_source, __source);
swap(_M_losers[__pos]._M_key, __key);
}
}
_M_losers[0]._M_sup = __sup;
_M_losers[0]._M_source = __source;
_M_losers[0]._M_key = __key;
}
};
/**
* @brief Base class of _Loser Tree implementation using pointers.
*/
template<typename _Tp, typename _Compare>
class _LoserTreePointerBase
{
protected:
/** @brief Internal representation of _LoserTree __elements. */
struct _Loser
{
bool _M_sup;
int _M_source;
const _Tp* _M_keyp;
};
unsigned int _M_ik, _M_k, _M_offset;
_Loser* _M_losers;
_Compare _M_comp;
public:
_LoserTreePointerBase(unsigned int __k,
_Compare __comp = std::less<_Tp>())
: _M_comp(__comp)
{
_M_ik = __k;
// Next greater power of 2.
_M_k = 1 << (__rd_log2(_M_ik - 1) + 1);
_M_offset = _M_k;
_M_losers = new _Loser[_M_k * 2];
for (unsigned int __i = _M_ik - 1; __i < _M_k; __i++)
_M_losers[__i + _M_k]._M_sup = true;
}
~_LoserTreePointerBase()
{ delete[] _M_losers; }
int __get_min_source()
{ return _M_losers[0]._M_source; }
void __insert_start(const _Tp& __key, int __source, bool __sup)
{
unsigned int __pos = _M_k + __source;
_M_losers[__pos]._M_sup = __sup;
_M_losers[__pos]._M_source = __source;
_M_losers[__pos]._M_keyp = &__key;
}
};
/**
* @brief Stable _LoserTree implementation.
*
* The unstable variant is implemented using partial instantiation below.
*/
template<bool __stable/* default == true */, typename _Tp, typename _Compare>
class _LoserTreePointer
: public _LoserTreePointerBase<_Tp, _Compare>
{
typedef _LoserTreePointerBase<_Tp, _Compare> _Base;
using _Base::_M_k;
using _Base::_M_comp;
using _Base::_M_losers;
public:
_LoserTreePointer(unsigned int __k, _Compare __comp = std::less<_Tp>())
: _Base::_LoserTreePointerBase(__k, __comp)
{ }
unsigned int
__init_winner(unsigned int __root)
{
if (__root >= _M_k)
return __root;
else
{
unsigned int __left = __init_winner(2 * __root);
unsigned int __right = __init_winner(2 * __root + 1);
if (_M_losers[__right]._M_sup
|| (!_M_losers[__left]._M_sup
&& !_M_comp(*_M_losers[__right]._M_keyp,
*_M_losers[__left]._M_keyp)))
{
// Left one is less or equal.
_M_losers[__root] = _M_losers[__right];
return __left;
}
else
{
// Right one is less.
_M_losers[__root] = _M_losers[__left];
return __right;
}
}
}
void __init()
{ _M_losers[0] = _M_losers[__init_winner(1)]; }
void __delete_min_insert(const _Tp& __key, bool __sup)
{
#if _GLIBCXX_PARALLEL_ASSERTIONS
// no dummy sequence can ever be at the top!
_GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1);
#endif
const _Tp* __keyp = &__key;
int __source = _M_losers[0]._M_source;
for (unsigned int __pos = (_M_k + __source) / 2; __pos > 0;
__pos /= 2)
{
// The smaller one gets promoted, ties are broken by __source.
if ((__sup && (!_M_losers[__pos]._M_sup
|| _M_losers[__pos]._M_source < __source))
|| (!__sup && !_M_losers[__pos]._M_sup &&
((_M_comp(*_M_losers[__pos]._M_keyp, *__keyp))
|| (!_M_comp(*__keyp, *_M_losers[__pos]._M_keyp)
&& _M_losers[__pos]._M_source < __source))))
{
// The other one is smaller.
std::swap(_M_losers[__pos]._M_sup, __sup);
std::swap(_M_losers[__pos]._M_source, __source);
std::swap(_M_losers[__pos]._M_keyp, __keyp);
}
}
_M_losers[0]._M_sup = __sup;
_M_losers[0]._M_source = __source;
_M_losers[0]._M_keyp = __keyp;
}
};
/**
* @brief Unstable _LoserTree implementation.
*
* The stable variant is above.
*/
template<typename _Tp, typename _Compare>
class _LoserTreePointer</* __stable == */false, _Tp, _Compare>
: public _LoserTreePointerBase<_Tp, _Compare>
{
typedef _LoserTreePointerBase<_Tp, _Compare> _Base;
using _Base::_M_k;
using _Base::_M_comp;
using _Base::_M_losers;
public:
_LoserTreePointer(unsigned int __k, _Compare __comp = std::less<_Tp>())
: _Base::_LoserTreePointerBase(__k, __comp)
{ }
unsigned int
__init_winner(unsigned int __root)
{
if (__root >= _M_k)
return __root;
else
{
unsigned int __left = __init_winner(2 * __root);
unsigned int __right = __init_winner(2 * __root + 1);
if (_M_losers[__right]._M_sup
|| (!_M_losers[__left]._M_sup
&& !_M_comp(*_M_losers[__right]._M_keyp,
*_M_losers[__left]._M_keyp)))
{
// Left one is less or equal.
_M_losers[__root] = _M_losers[__right];
return __left;
}
else
{
// Right one is less.
_M_losers[__root] = _M_losers[__left];
return __right;
}
}
}
void __init()
{ _M_losers[0] = _M_losers[__init_winner(1)]; }
void __delete_min_insert(const _Tp& __key, bool __sup)
{
#if _GLIBCXX_PARALLEL_ASSERTIONS
// no dummy sequence can ever be at the top!
_GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1);
#endif
const _Tp* __keyp = &__key;
int __source = _M_losers[0]._M_source;
for (unsigned int __pos = (_M_k + __source) / 2; __pos > 0;
__pos /= 2)
{
// The smaller one gets promoted.
if (__sup || (!_M_losers[__pos]._M_sup
&& _M_comp(*_M_losers[__pos]._M_keyp, *__keyp)))
{
// The other one is smaller.
std::swap(_M_losers[__pos]._M_sup, __sup);
std::swap(_M_losers[__pos]._M_source, __source);
std::swap(_M_losers[__pos]._M_keyp, __keyp);
}
}
_M_losers[0]._M_sup = __sup;
_M_losers[0]._M_source = __source;
_M_losers[0]._M_keyp = __keyp;
}
};
/** @brief Base class for unguarded _LoserTree implementation.
*
* The whole element is copied into the tree structure.
*
* No guarding is done, therefore not a single input sequence must
* run empty. Unused __sequence heads are marked with a sentinel which
* is > all elements that are to be merged.
*
* This is a very fast variant.
*/
template<typename _Tp, typename _Compare>
class _LoserTreeUnguardedBase
{
protected:
struct _Loser
{
int _M_source;
_Tp _M_key;
};
unsigned int _M_ik, _M_k, _M_offset;
_Loser* _M_losers;
_Compare _M_comp;
public:
_LoserTreeUnguardedBase(unsigned int __k, const _Tp& __sentinel,
_Compare __comp = std::less<_Tp>())
: _M_comp(__comp)
{
_M_ik = __k;
// Next greater power of 2.
_M_k = 1 << (__rd_log2(_M_ik - 1) + 1);
_M_offset = _M_k;
// Avoid default-constructing _M_losers[]._M_key
_M_losers = static_cast<_Loser*>(::operator new(2 * _M_k
* sizeof(_Loser)));
for (unsigned int __i = 0; __i < _M_k; ++__i)
{
::new(&(_M_losers[__i]._M_key)) _Tp(__sentinel);
_M_losers[__i]._M_source = -1;
}
for (unsigned int __i = _M_k + _M_ik - 1; __i < (2 * _M_k); ++__i)
{
::new(&(_M_losers[__i]._M_key)) _Tp(__sentinel);
_M_losers[__i]._M_source = -1;
}
}
~_LoserTreeUnguardedBase()
{
for (unsigned int __i = 0; __i < (2 * _M_k); ++__i)
_M_losers[__i].~_Loser();
::operator delete(_M_losers);
}
int
__get_min_source()
{
#if _GLIBCXX_PARALLEL_ASSERTIONS
// no dummy sequence can ever be at the top!
_GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1);
#endif
return _M_losers[0]._M_source;
}
void
__insert_start(const _Tp& __key, int __source, bool)
{
unsigned int __pos = _M_k + __source;
::new(&(_M_losers[__pos]._M_key)) _Tp(__key);
_M_losers[__pos]._M_source = __source;
}
};
/**
* @brief Stable implementation of unguarded _LoserTree.
*
* Unstable variant is selected below with partial specialization.
*/
template<bool __stable/* default == true */, typename _Tp, typename _Compare>
class _LoserTreeUnguarded
: public _LoserTreeUnguardedBase<_Tp, _Compare>
{
typedef _LoserTreeUnguardedBase<_Tp, _Compare> _Base;
using _Base::_M_k;
using _Base::_M_comp;
using _Base::_M_losers;
public:
_LoserTreeUnguarded(unsigned int __k, const _Tp& __sentinel,
_Compare __comp = std::less<_Tp>())
: _Base::_LoserTreeUnguardedBase(__k, __sentinel, __comp)
{ }
unsigned int
__init_winner(unsigned int __root)
{
if (__root >= _M_k)
return __root;
else
{
unsigned int __left = __init_winner(2 * __root);
unsigned int __right = __init_winner(2 * __root + 1);
if (!_M_comp(_M_losers[__right]._M_key,
_M_losers[__left]._M_key))
{
// Left one is less or equal.
_M_losers[__root] = _M_losers[__right];
return __left;
}
else
{
// Right one is less.
_M_losers[__root] = _M_losers[__left];
return __right;
}
}
}
void
__init()
{
_M_losers[0] = _M_losers[__init_winner(1)];
#if _GLIBCXX_PARALLEL_ASSERTIONS
// no dummy sequence can ever be at the top at the beginning
// (0 sequences!)
_GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1);
#endif
}
// Do not pass a const reference since __key will be used as
// local variable.
void
__delete_min_insert(_Tp __key, bool)
{
using std::swap;
#if _GLIBCXX_PARALLEL_ASSERTIONS
// no dummy sequence can ever be at the top!
_GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1);
#endif
int __source = _M_losers[0]._M_source;
for (unsigned int __pos = (_M_k + __source) / 2; __pos > 0;
__pos /= 2)
{
// The smaller one gets promoted, ties are broken by _M_source.
if (_M_comp(_M_losers[__pos]._M_key, __key)
|| (!_M_comp(__key, _M_losers[__pos]._M_key)
&& _M_losers[__pos]._M_source < __source))
{
// The other one is smaller.
std::swap(_M_losers[__pos]._M_source, __source);
swap(_M_losers[__pos]._M_key, __key);
}
}
_M_losers[0]._M_source = __source;
_M_losers[0]._M_key = __key;
}
};
/**
* @brief Non-Stable implementation of unguarded _LoserTree.
*
* Stable implementation is above.
*/
template<typename _Tp, typename _Compare>
class _LoserTreeUnguarded</* __stable == */false, _Tp, _Compare>
: public _LoserTreeUnguardedBase<_Tp, _Compare>
{
typedef _LoserTreeUnguardedBase<_Tp, _Compare> _Base;
using _Base::_M_k;
using _Base::_M_comp;
using _Base::_M_losers;
public:
_LoserTreeUnguarded(unsigned int __k, const _Tp& __sentinel,
_Compare __comp = std::less<_Tp>())
: _Base::_LoserTreeUnguardedBase(__k, __sentinel, __comp)
{ }
unsigned int
__init_winner(unsigned int __root)
{
if (__root >= _M_k)
return __root;
else
{
unsigned int __left = __init_winner(2 * __root);
unsigned int __right = __init_winner(2 * __root + 1);
#if _GLIBCXX_PARALLEL_ASSERTIONS
// If __left one is sentinel then __right one must be, too.
if (_M_losers[__left]._M_source == -1)
_GLIBCXX_PARALLEL_ASSERT(_M_losers[__right]._M_source == -1);
#endif
if (!_M_comp(_M_losers[__right]._M_key,
_M_losers[__left]._M_key))
{
// Left one is less or equal.
_M_losers[__root] = _M_losers[__right];
return __left;
}
else
{
// Right one is less.
_M_losers[__root] = _M_losers[__left];
return __right;
}
}
}
void
__init()
{
_M_losers[0] = _M_losers[__init_winner(1)];
#if _GLIBCXX_PARALLEL_ASSERTIONS
// no dummy sequence can ever be at the top at the beginning
// (0 sequences!)
_GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1);
#endif
}
// Do not pass a const reference since __key will be used as
// local variable.
void
__delete_min_insert(_Tp __key, bool)
{
using std::swap;
#if _GLIBCXX_PARALLEL_ASSERTIONS
// no dummy sequence can ever be at the top!
_GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1);
#endif
int __source = _M_losers[0]._M_source;
for (unsigned int __pos = (_M_k + __source) / 2; __pos > 0;
__pos /= 2)
{
// The smaller one gets promoted.
if (_M_comp(_M_losers[__pos]._M_key, __key))
{
// The other one is smaller.
std::swap(_M_losers[__pos]._M_source, __source);
swap(_M_losers[__pos]._M_key, __key);
}
}
_M_losers[0]._M_source = __source;
_M_losers[0]._M_key = __key;
}
};
/** @brief Unguarded loser tree, keeping only pointers to the
* elements in the tree structure.
*
* No guarding is done, therefore not a single input sequence must
* run empty. This is a very fast variant.
*/
template<typename _Tp, typename _Compare>
class _LoserTreePointerUnguardedBase
{
protected:
struct _Loser
{
int _M_source;
const _Tp* _M_keyp;
};
unsigned int _M_ik, _M_k, _M_offset;
_Loser* _M_losers;
_Compare _M_comp;
public:
_LoserTreePointerUnguardedBase(unsigned int __k, const _Tp& __sentinel,
_Compare __comp = std::less<_Tp>())
: _M_comp(__comp)
{
_M_ik = __k;
// Next greater power of 2.
_M_k = 1 << (__rd_log2(_M_ik - 1) + 1);
_M_offset = _M_k;
// Avoid default-constructing _M_losers[]._M_key
_M_losers = new _Loser[2 * _M_k];
for (unsigned int __i = _M_k + _M_ik - 1; __i < (2 * _M_k); ++__i)
{
_M_losers[__i]._M_keyp = &__sentinel;
_M_losers[__i]._M_source = -1;
}
}
~_LoserTreePointerUnguardedBase()
{ delete[] _M_losers; }
int
__get_min_source()
{
#if _GLIBCXX_PARALLEL_ASSERTIONS
// no dummy sequence can ever be at the top!
_GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1);
#endif
return _M_losers[0]._M_source;
}
void
__insert_start(const _Tp& __key, int __source, bool)
{
unsigned int __pos = _M_k + __source;
_M_losers[__pos]._M_keyp = &__key;
_M_losers[__pos]._M_source = __source;
}
};
/**
* @brief Stable unguarded _LoserTree variant storing pointers.
*
* Unstable variant is implemented below using partial specialization.
*/
template<bool __stable/* default == true */, typename _Tp, typename _Compare>
class _LoserTreePointerUnguarded
: public _LoserTreePointerUnguardedBase<_Tp, _Compare>
{
typedef _LoserTreePointerUnguardedBase<_Tp, _Compare> _Base;
using _Base::_M_k;
using _Base::_M_comp;
using _Base::_M_losers;
public:
_LoserTreePointerUnguarded(unsigned int __k, const _Tp& __sentinel,
_Compare __comp = std::less<_Tp>())
: _Base::_LoserTreePointerUnguardedBase(__k, __sentinel, __comp)
{ }
unsigned int
__init_winner(unsigned int __root)
{
if (__root >= _M_k)
return __root;
else
{
unsigned int __left = __init_winner(2 * __root);
unsigned int __right = __init_winner(2 * __root + 1);
if (!_M_comp(*_M_losers[__right]._M_keyp,
*_M_losers[__left]._M_keyp))
{
// Left one is less or equal.
_M_losers[__root] = _M_losers[__right];
return __left;
}
else
{
// Right one is less.
_M_losers[__root] = _M_losers[__left];
return __right;
}
}
}
void
__init()
{
_M_losers[0] = _M_losers[__init_winner(1)];
#if _GLIBCXX_PARALLEL_ASSERTIONS
// no dummy sequence can ever be at the top at the beginning
// (0 sequences!)
_GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1);
#endif
}
void
__delete_min_insert(const _Tp& __key, bool __sup)
{
#if _GLIBCXX_PARALLEL_ASSERTIONS
// no dummy sequence can ever be at the top!
_GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1);
#endif
const _Tp* __keyp = &__key;
int __source = _M_losers[0]._M_source;
for (unsigned int __pos = (_M_k + __source) / 2; __pos > 0;
__pos /= 2)
{
// The smaller one gets promoted, ties are broken by _M_source.
if (_M_comp(*_M_losers[__pos]._M_keyp, *__keyp)
|| (!_M_comp(*__keyp, *_M_losers[__pos]._M_keyp)
&& _M_losers[__pos]._M_source < __source))
{
// The other one is smaller.
std::swap(_M_losers[__pos]._M_source, __source);
std::swap(_M_losers[__pos]._M_keyp, __keyp);
}
}
_M_losers[0]._M_source = __source;
_M_losers[0]._M_keyp = __keyp;
}
};
/**
* @brief Unstable unguarded _LoserTree variant storing pointers.
*
* Stable variant is above.
*/
template<typename _Tp, typename _Compare>
class _LoserTreePointerUnguarded</* __stable == */false, _Tp, _Compare>
: public _LoserTreePointerUnguardedBase<_Tp, _Compare>
{
typedef _LoserTreePointerUnguardedBase<_Tp, _Compare> _Base;
using _Base::_M_k;
using _Base::_M_comp;
using _Base::_M_losers;
public:
_LoserTreePointerUnguarded(unsigned int __k, const _Tp& __sentinel,
_Compare __comp = std::less<_Tp>())
: _Base::_LoserTreePointerUnguardedBase(__k, __sentinel, __comp)
{ }
unsigned int
__init_winner(unsigned int __root)
{
if (__root >= _M_k)
return __root;
else
{
unsigned int __left = __init_winner(2 * __root);
unsigned int __right = __init_winner(2 * __root + 1);
#if _GLIBCXX_PARALLEL_ASSERTIONS
// If __left one is sentinel then __right one must be, too.
if (_M_losers[__left]._M_source == -1)
_GLIBCXX_PARALLEL_ASSERT(_M_losers[__right]._M_source == -1);
#endif
if (!_M_comp(*_M_losers[__right]._M_keyp,
*_M_losers[__left]._M_keyp))
{
// Left one is less or equal.
_M_losers[__root] = _M_losers[__right];
return __left;
}
else
{
// Right one is less.
_M_losers[__root] = _M_losers[__left];
return __right;
}
}
}
void
__init()
{
_M_losers[0] = _M_losers[__init_winner(1)];
#if _GLIBCXX_PARALLEL_ASSERTIONS
// no dummy sequence can ever be at the top at the beginning
// (0 sequences!)
_GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1);
#endif
}
void
__delete_min_insert(const _Tp& __key, bool __sup)
{
#if _GLIBCXX_PARALLEL_ASSERTIONS
// no dummy sequence can ever be at the top!
_GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1);
#endif
const _Tp* __keyp = &__key;
int __source = _M_losers[0]._M_source;
for (unsigned int __pos = (_M_k + __source) / 2; __pos > 0;
__pos /= 2)
{
// The smaller one gets promoted.
if (_M_comp(*(_M_losers[__pos]._M_keyp), *__keyp))
{
// The other one is smaller.
std::swap(_M_losers[__pos]._M_source, __source);
std::swap(_M_losers[__pos]._M_keyp, __keyp);
}
}
_M_losers[0]._M_source = __source;
_M_losers[0]._M_keyp = __keyp;
}
};
} // namespace __gnu_parallel
#endif /* _GLIBCXX_PARALLEL_LOSERTREE_H */
c++/8/parallel/numericfwd.h 0000644 00000016514 15201526705 0011405 0 ustar 00 // <parallel/numeric> Forward declarations -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/numericfwd.h
* This file is a GNU parallel extension to the Standard C++ Library.
*/
#ifndef _GLIBCXX_PARALLEL_NUMERICFWD_H
#define _GLIBCXX_PARALLEL_NUMERICFWD_H 1
#pragma GCC system_header
#include <parallel/tags.h>
#include <parallel/settings.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __parallel
{
template<typename _IIter, typename _Tp>
_Tp
accumulate(_IIter, _IIter, _Tp);
template<typename _IIter, typename _Tp>
_Tp
accumulate(_IIter, _IIter, _Tp, __gnu_parallel::sequential_tag);
template<typename _IIter, typename _Tp>
_Tp
accumulate(_IIter, _IIter, _Tp, __gnu_parallel::_Parallelism);
template<typename _IIter, typename _Tp, typename _Tag>
_Tp
__accumulate_switch(_IIter, _IIter, _Tp, _Tag);
template<typename _IIter, typename _Tp, typename _BinaryOper>
_Tp
accumulate(_IIter, _IIter, _Tp, _BinaryOper);
template<typename _IIter, typename _Tp, typename _BinaryOper>
_Tp
accumulate(_IIter, _IIter, _Tp, _BinaryOper,
__gnu_parallel::sequential_tag);
template<typename _IIter, typename _Tp, typename _BinaryOper>
_Tp
accumulate(_IIter, _IIter, _Tp, _BinaryOper,
__gnu_parallel::_Parallelism);
template<typename _IIter, typename _Tp, typename _BinaryOper,
typename _Tag>
_Tp
__accumulate_switch(_IIter, _IIter, _Tp, _BinaryOper, _Tag);
template<typename _RAIter, typename _Tp, typename _BinaryOper>
_Tp
__accumulate_switch(_RAIter, _RAIter, _Tp, _BinaryOper,
random_access_iterator_tag,
__gnu_parallel::_Parallelism __parallelism
= __gnu_parallel::parallel_unbalanced);
template<typename _IIter, typename _OIter>
_OIter
adjacent_difference(_IIter, _IIter, _OIter);
template<typename _IIter, typename _OIter, typename _BinaryOper>
_OIter
adjacent_difference(_IIter, _IIter, _OIter, _BinaryOper);
template<typename _IIter, typename _OIter>
_OIter
adjacent_difference(_IIter, _IIter, _OIter,
__gnu_parallel::sequential_tag);
template<typename _IIter, typename _OIter, typename _BinaryOper>
_OIter
adjacent_difference(_IIter, _IIter, _OIter, _BinaryOper,
__gnu_parallel::sequential_tag);
template<typename _IIter, typename _OIter>
_OIter
adjacent_difference(_IIter, _IIter, _OIter,
__gnu_parallel::_Parallelism);
template<typename _IIter, typename _OIter, typename _BinaryOper>
_OIter
adjacent_difference(_IIter, _IIter, _OIter, _BinaryOper,
__gnu_parallel::_Parallelism);
template<typename _IIter, typename _OIter, typename _BinaryOper,
typename _Tag1, typename _Tag2>
_OIter
__adjacent_difference_switch(_IIter, _IIter, _OIter, _BinaryOper,
_Tag1, _Tag2);
template<typename _IIter, typename _OIter, typename _BinaryOper>
_OIter
__adjacent_difference_switch(_IIter, _IIter, _OIter, _BinaryOper,
random_access_iterator_tag,
random_access_iterator_tag,
__gnu_parallel::_Parallelism __parallelism
= __gnu_parallel::parallel_unbalanced);
template<typename _IIter1, typename _IIter2, typename _Tp>
_Tp
inner_product(_IIter1, _IIter1, _IIter2, _Tp);
template<typename _IIter1, typename _IIter2, typename _Tp>
_Tp
inner_product(_IIter1, _IIter1, _IIter2, _Tp,
__gnu_parallel::sequential_tag);
template<typename _IIter1, typename _IIter2, typename _Tp>
_Tp
inner_product(_IIter1, _IIter1, _IIter2, _Tp,
__gnu_parallel::_Parallelism);
template<typename _IIter1, typename _IIter2, typename _Tp,
typename _BinaryFunction1, typename _BinaryFunction2>
_Tp
inner_product(_IIter1, _IIter1, _IIter2, _Tp,
_BinaryFunction1, _BinaryFunction2);
template<typename _IIter1, typename _IIter2, typename _Tp,
typename _BinaryFunction1, typename _BinaryFunction2>
_Tp
inner_product(_IIter1, _IIter1, _IIter2, _Tp, _BinaryFunction1,
_BinaryFunction2, __gnu_parallel::sequential_tag);
template<typename _IIter1, typename _IIter2, typename _Tp,
typename BinaryFunction1, typename BinaryFunction2>
_Tp
inner_product(_IIter1, _IIter1, _IIter2, _Tp, BinaryFunction1,
BinaryFunction2, __gnu_parallel::_Parallelism);
template<typename _RAIter1, typename _RAIter2, typename _Tp,
typename BinaryFunction1, typename BinaryFunction2>
_Tp
__inner_product_switch(_RAIter1, _RAIter1, _RAIter2, _Tp, BinaryFunction1,
BinaryFunction2, random_access_iterator_tag,
random_access_iterator_tag,
__gnu_parallel::_Parallelism
= __gnu_parallel::parallel_unbalanced);
template<typename _IIter1, typename _IIter2, typename _Tp,
typename _BinaryFunction1, typename _BinaryFunction2,
typename _Tag1, typename _Tag2>
_Tp
__inner_product_switch(_IIter1, _IIter1, _IIter2, _Tp, _BinaryFunction1,
_BinaryFunction2, _Tag1, _Tag2);
template<typename _IIter, typename _OIter>
_OIter
partial_sum(_IIter, _IIter, _OIter, __gnu_parallel::sequential_tag);
template<typename _IIter, typename _OIter, typename _BinaryOper>
_OIter
partial_sum(_IIter, _IIter, _OIter, _BinaryOper,
__gnu_parallel::sequential_tag);
template<typename _IIter, typename _OIter>
_OIter
partial_sum(_IIter, _IIter, _OIter __result);
template<typename _IIter, typename _OIter, typename _BinaryOper>
_OIter
partial_sum(_IIter, _IIter, _OIter, _BinaryOper);
template<typename _IIter, typename _OIter, typename _BinaryOper,
typename _Tag1, typename _Tag2>
_OIter
__partial_sum_switch(_IIter, _IIter, _OIter, _BinaryOper, _Tag1, _Tag2);
template<typename _IIter, typename _OIter, typename _BinaryOper>
_OIter
__partial_sum_switch(_IIter, _IIter, _OIter, _BinaryOper,
random_access_iterator_tag, random_access_iterator_tag);
} // end namespace
} // end namespace
#endif /* _GLIBCXX_PARALLEL_NUMERICFWD_H */
c++/8/parallel/quicksort.h 0000644 00000013756 15201526705 0011273 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/quicksort.h
* @brief Implementation of a unbalanced parallel quicksort (in-place).
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Johannes Singler.
#ifndef _GLIBCXX_PARALLEL_QUICKSORT_H
#define _GLIBCXX_PARALLEL_QUICKSORT_H 1
#include <parallel/parallel.h>
#include <parallel/partition.h>
namespace __gnu_parallel
{
/** @brief Unbalanced quicksort divide step.
* @param __begin Begin iterator of subsequence.
* @param __end End iterator of subsequence.
* @param __comp Comparator.
* @param __pivot_rank Desired __rank of the pivot.
* @param __num_samples Choose pivot from that many samples.
* @param __num_threads Number of threads that are allowed to work on
* this part.
*/
template<typename _RAIter, typename _Compare>
typename std::iterator_traits<_RAIter>::difference_type
__parallel_sort_qs_divide(_RAIter __begin, _RAIter __end,
_Compare __comp, typename std::iterator_traits
<_RAIter>::difference_type __pivot_rank,
typename std::iterator_traits
<_RAIter>::difference_type
__num_samples, _ThreadIndex __num_threads)
{
typedef std::iterator_traits<_RAIter> _TraitsType;
typedef typename _TraitsType::value_type _ValueType;
typedef typename _TraitsType::difference_type _DifferenceType;
_DifferenceType __n = __end - __begin;
__num_samples = std::min(__num_samples, __n);
// Allocate uninitialized, to avoid default constructor.
_ValueType* __samples = static_cast<_ValueType*>
(::operator new(__num_samples * sizeof(_ValueType)));
for (_DifferenceType __s = 0; __s < __num_samples; ++__s)
{
const unsigned long long __index = static_cast<unsigned long long>
(__s) * __n / __num_samples;
::new(&(__samples[__s])) _ValueType(__begin[__index]);
}
__gnu_sequential::sort(__samples, __samples + __num_samples, __comp);
_ValueType& __pivot = __samples[__pivot_rank * __num_samples / __n];
__gnu_parallel::__binder2nd<_Compare, _ValueType, _ValueType, bool>
__pred(__comp, __pivot);
_DifferenceType __split = __parallel_partition(__begin, __end,
__pred, __num_threads);
for (_DifferenceType __s = 0; __s < __num_samples; ++__s)
__samples[__s].~_ValueType();
::operator delete(__samples);
return __split;
}
/** @brief Unbalanced quicksort conquer step.
* @param __begin Begin iterator of subsequence.
* @param __end End iterator of subsequence.
* @param __comp Comparator.
* @param __num_threads Number of threads that are allowed to work on
* this part.
*/
template<typename _RAIter, typename _Compare>
void
__parallel_sort_qs_conquer(_RAIter __begin, _RAIter __end,
_Compare __comp,
_ThreadIndex __num_threads)
{
typedef std::iterator_traits<_RAIter> _TraitsType;
typedef typename _TraitsType::value_type _ValueType;
typedef typename _TraitsType::difference_type _DifferenceType;
if (__num_threads <= 1)
{
__gnu_sequential::sort(__begin, __end, __comp);
return;
}
_DifferenceType __n = __end - __begin, __pivot_rank;
if (__n <= 1)
return;
_ThreadIndex __num_threads_left;
if ((__num_threads % 2) == 1)
__num_threads_left = __num_threads / 2 + 1;
else
__num_threads_left = __num_threads / 2;
__pivot_rank = __n * __num_threads_left / __num_threads;
_DifferenceType __split = __parallel_sort_qs_divide
(__begin, __end, __comp, __pivot_rank,
_Settings::get().sort_qs_num_samples_preset, __num_threads);
#pragma omp parallel sections num_threads(2)
{
#pragma omp section
__parallel_sort_qs_conquer(__begin, __begin + __split,
__comp, __num_threads_left);
#pragma omp section
__parallel_sort_qs_conquer(__begin + __split, __end,
__comp, __num_threads - __num_threads_left);
}
}
/** @brief Unbalanced quicksort main call.
* @param __begin Begin iterator of input sequence.
* @param __end End iterator input sequence, ignored.
* @param __comp Comparator.
* @param __num_threads Number of threads that are allowed to work on
* this part.
*/
template<typename _RAIter, typename _Compare>
void
__parallel_sort_qs(_RAIter __begin, _RAIter __end,
_Compare __comp,
_ThreadIndex __num_threads)
{
_GLIBCXX_CALL(__n)
typedef std::iterator_traits<_RAIter> _TraitsType;
typedef typename _TraitsType::value_type _ValueType;
typedef typename _TraitsType::difference_type _DifferenceType;
_DifferenceType __n = __end - __begin;
// At least one element per processor.
if (__num_threads > __n)
__num_threads = static_cast<_ThreadIndex>(__n);
__parallel_sort_qs_conquer(
__begin, __begin + __n, __comp, __num_threads);
}
} //namespace __gnu_parallel
#endif /* _GLIBCXX_PARALLEL_QUICKSORT_H */
c++/8/parallel/balanced_quicksort.h 0000644 00000041070 15201526705 0013072 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/balanced_quicksort.h
* @brief Implementation of a dynamically load-balanced parallel quicksort.
*
* It works in-place and needs only logarithmic extra memory.
* The algorithm is similar to the one proposed in
*
* P. Tsigas and Y. Zhang.
* A simple, fast parallel implementation of quicksort and
* its performance evaluation on SUN enterprise 10000.
* In 11th Euromicro Conference on Parallel, Distributed and
* Network-Based Processing, page 372, 2003.
*
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Johannes Singler.
#ifndef _GLIBCXX_PARALLEL_BALANCED_QUICKSORT_H
#define _GLIBCXX_PARALLEL_BALANCED_QUICKSORT_H 1
#include <parallel/basic_iterator.h>
#include <bits/stl_algo.h>
#include <bits/stl_function.h>
#include <parallel/settings.h>
#include <parallel/partition.h>
#include <parallel/random_number.h>
#include <parallel/queue.h>
#if _GLIBCXX_PARALLEL_ASSERTIONS
#include <parallel/checkers.h>
#ifdef _GLIBCXX_HAVE_UNISTD_H
#include <unistd.h>
#endif
#endif
namespace __gnu_parallel
{
/** @brief Information local to one thread in the parallel quicksort run. */
template<typename _RAIter>
struct _QSBThreadLocal
{
typedef std::iterator_traits<_RAIter> _TraitsType;
typedef typename _TraitsType::difference_type _DifferenceType;
/** @brief Continuous part of the sequence, described by an
iterator pair. */
typedef std::pair<_RAIter, _RAIter> _Piece;
/** @brief Initial piece to work on. */
_Piece _M_initial;
/** @brief Work-stealing queue. */
_RestrictedBoundedConcurrentQueue<_Piece> _M_leftover_parts;
/** @brief Number of threads involved in this algorithm. */
_ThreadIndex _M_num_threads;
/** @brief Pointer to a counter of elements left over to sort. */
volatile _DifferenceType* _M_elements_leftover;
/** @brief The complete sequence to sort. */
_Piece _M_global;
/** @brief Constructor.
* @param __queue_size size of the work-stealing queue. */
_QSBThreadLocal(int __queue_size) : _M_leftover_parts(__queue_size) { }
};
/** @brief Balanced quicksort divide step.
* @param __begin Begin iterator of subsequence.
* @param __end End iterator of subsequence.
* @param __comp Comparator.
* @param __num_threads Number of threads that are allowed to work on
* this part.
* @pre @c (__end-__begin)>=1 */
template<typename _RAIter, typename _Compare>
typename std::iterator_traits<_RAIter>::difference_type
__qsb_divide(_RAIter __begin, _RAIter __end,
_Compare __comp, _ThreadIndex __num_threads)
{
_GLIBCXX_PARALLEL_ASSERT(__num_threads > 0);
typedef std::iterator_traits<_RAIter> _TraitsType;
typedef typename _TraitsType::value_type _ValueType;
typedef typename _TraitsType::difference_type _DifferenceType;
_RAIter __pivot_pos =
__median_of_three_iterators(__begin, __begin + (__end - __begin) / 2,
__end - 1, __comp);
#if defined(_GLIBCXX_PARALLEL_ASSERTIONS)
// Must be in between somewhere.
_DifferenceType __n = __end - __begin;
_GLIBCXX_PARALLEL_ASSERT((!__comp(*__pivot_pos, *__begin)
&& !__comp(*(__begin + __n / 2),
*__pivot_pos))
|| (!__comp(*__pivot_pos, *__begin)
&& !__comp(*(__end - 1), *__pivot_pos))
|| (!__comp(*__pivot_pos, *(__begin + __n / 2))
&& !__comp(*__begin, *__pivot_pos))
|| (!__comp(*__pivot_pos, *(__begin + __n / 2))
&& !__comp(*(__end - 1), *__pivot_pos))
|| (!__comp(*__pivot_pos, *(__end - 1))
&& !__comp(*__begin, *__pivot_pos))
|| (!__comp(*__pivot_pos, *(__end - 1))
&& !__comp(*(__begin + __n / 2),
*__pivot_pos)));
#endif
// Swap pivot value to end.
if (__pivot_pos != (__end - 1))
std::iter_swap(__pivot_pos, __end - 1);
__pivot_pos = __end - 1;
__gnu_parallel::__binder2nd<_Compare, _ValueType, _ValueType, bool>
__pred(__comp, *__pivot_pos);
// Divide, returning __end - __begin - 1 in the worst case.
_DifferenceType __split_pos = __parallel_partition(__begin, __end - 1,
__pred,
__num_threads);
// Swap back pivot to middle.
std::iter_swap(__begin + __split_pos, __pivot_pos);
__pivot_pos = __begin + __split_pos;
#if _GLIBCXX_PARALLEL_ASSERTIONS
_RAIter __r;
for (__r = __begin; __r != __pivot_pos; ++__r)
_GLIBCXX_PARALLEL_ASSERT(__comp(*__r, *__pivot_pos));
for (; __r != __end; ++__r)
_GLIBCXX_PARALLEL_ASSERT(!__comp(*__r, *__pivot_pos));
#endif
return __split_pos;
}
/** @brief Quicksort conquer step.
* @param __tls Array of thread-local storages.
* @param __begin Begin iterator of subsequence.
* @param __end End iterator of subsequence.
* @param __comp Comparator.
* @param __iam Number of the thread processing this function.
* @param __num_threads
* Number of threads that are allowed to work on this part. */
template<typename _RAIter, typename _Compare>
void
__qsb_conquer(_QSBThreadLocal<_RAIter>** __tls,
_RAIter __begin, _RAIter __end,
_Compare __comp,
_ThreadIndex __iam, _ThreadIndex __num_threads,
bool __parent_wait)
{
typedef std::iterator_traits<_RAIter> _TraitsType;
typedef typename _TraitsType::value_type _ValueType;
typedef typename _TraitsType::difference_type _DifferenceType;
_DifferenceType __n = __end - __begin;
if (__num_threads <= 1 || __n <= 1)
{
__tls[__iam]->_M_initial.first = __begin;
__tls[__iam]->_M_initial.second = __end;
__qsb_local_sort_with_helping(__tls, __comp, __iam, __parent_wait);
return;
}
// Divide step.
_DifferenceType __split_pos =
__qsb_divide(__begin, __end, __comp, __num_threads);
#if _GLIBCXX_PARALLEL_ASSERTIONS
_GLIBCXX_PARALLEL_ASSERT(0 <= __split_pos &&
__split_pos < (__end - __begin));
#endif
_ThreadIndex
__num_threads_leftside = std::max<_ThreadIndex>
(1, std::min<_ThreadIndex>(__num_threads - 1, __split_pos
* __num_threads / __n));
# pragma omp atomic
*__tls[__iam]->_M_elements_leftover -= (_DifferenceType)1;
// Conquer step.
# pragma omp parallel num_threads(2)
{
bool __wait;
if(omp_get_num_threads() < 2)
__wait = false;
else
__wait = __parent_wait;
# pragma omp sections
{
# pragma omp section
{
__qsb_conquer(__tls, __begin, __begin + __split_pos, __comp,
__iam, __num_threads_leftside, __wait);
__wait = __parent_wait;
}
// The pivot_pos is left in place, to ensure termination.
# pragma omp section
{
__qsb_conquer(__tls, __begin + __split_pos + 1, __end, __comp,
__iam + __num_threads_leftside,
__num_threads - __num_threads_leftside, __wait);
__wait = __parent_wait;
}
}
}
}
/**
* @brief Quicksort step doing load-balanced local sort.
* @param __tls Array of thread-local storages.
* @param __comp Comparator.
* @param __iam Number of the thread processing this function.
*/
template<typename _RAIter, typename _Compare>
void
__qsb_local_sort_with_helping(_QSBThreadLocal<_RAIter>** __tls,
_Compare& __comp, _ThreadIndex __iam,
bool __wait)
{
typedef std::iterator_traits<_RAIter> _TraitsType;
typedef typename _TraitsType::value_type _ValueType;
typedef typename _TraitsType::difference_type _DifferenceType;
typedef std::pair<_RAIter, _RAIter> _Piece;
_QSBThreadLocal<_RAIter>& __tl = *__tls[__iam];
_DifferenceType
__base_case_n = _Settings::get().sort_qsb_base_case_maximal_n;
if (__base_case_n < 2)
__base_case_n = 2;
_ThreadIndex __num_threads = __tl._M_num_threads;
// Every thread has its own random number generator.
_RandomNumber __rng(__iam + 1);
_Piece __current = __tl._M_initial;
_DifferenceType __elements_done = 0;
#if _GLIBCXX_PARALLEL_ASSERTIONS
_DifferenceType __total_elements_done = 0;
#endif
for (;;)
{
// Invariant: __current must be a valid (maybe empty) range.
_RAIter __begin = __current.first, __end = __current.second;
_DifferenceType __n = __end - __begin;
if (__n > __base_case_n)
{
// Divide.
_RAIter __pivot_pos = __begin + __rng(__n);
// Swap __pivot_pos value to end.
if (__pivot_pos != (__end - 1))
std::iter_swap(__pivot_pos, __end - 1);
__pivot_pos = __end - 1;
__gnu_parallel::__binder2nd
<_Compare, _ValueType, _ValueType, bool>
__pred(__comp, *__pivot_pos);
// Divide, leave pivot unchanged in last place.
_RAIter __split_pos1, __split_pos2;
__split_pos1 = __gnu_sequential::partition(__begin, __end - 1,
__pred);
// Left side: < __pivot_pos; __right side: >= __pivot_pos.
#if _GLIBCXX_PARALLEL_ASSERTIONS
_GLIBCXX_PARALLEL_ASSERT(__begin <= __split_pos1
&& __split_pos1 < __end);
#endif
// Swap pivot back to middle.
if (__split_pos1 != __pivot_pos)
std::iter_swap(__split_pos1, __pivot_pos);
__pivot_pos = __split_pos1;
// In case all elements are equal, __split_pos1 == 0.
if ((__split_pos1 + 1 - __begin) < (__n >> 7)
|| (__end - __split_pos1) < (__n >> 7))
{
// Very unequal split, one part smaller than one 128th
// elements not strictly larger than the pivot.
__gnu_parallel::__unary_negate<__gnu_parallel::__binder1st
<_Compare, _ValueType, _ValueType, bool>, _ValueType>
__pred(__gnu_parallel::__binder1st
<_Compare, _ValueType, _ValueType, bool>
(__comp, *__pivot_pos));
// Find other end of pivot-equal range.
__split_pos2 = __gnu_sequential::partition(__split_pos1 + 1,
__end, __pred);
}
else
// Only skip the pivot.
__split_pos2 = __split_pos1 + 1;
// Elements equal to pivot are done.
__elements_done += (__split_pos2 - __split_pos1);
#if _GLIBCXX_PARALLEL_ASSERTIONS
__total_elements_done += (__split_pos2 - __split_pos1);
#endif
// Always push larger part onto stack.
if (((__split_pos1 + 1) - __begin) < (__end - (__split_pos2)))
{
// Right side larger.
if ((__split_pos2) != __end)
__tl._M_leftover_parts.push_front
(std::make_pair(__split_pos2, __end));
//__current.first = __begin; //already set anyway
__current.second = __split_pos1;
continue;
}
else
{
// Left side larger.
if (__begin != __split_pos1)
__tl._M_leftover_parts.push_front(std::make_pair
(__begin, __split_pos1));
__current.first = __split_pos2;
//__current.second = __end; //already set anyway
continue;
}
}
else
{
__gnu_sequential::sort(__begin, __end, __comp);
__elements_done += __n;
#if _GLIBCXX_PARALLEL_ASSERTIONS
__total_elements_done += __n;
#endif
// Prefer own stack, small pieces.
if (__tl._M_leftover_parts.pop_front(__current))
continue;
# pragma omp atomic
*__tl._M_elements_leftover -= __elements_done;
__elements_done = 0;
#if _GLIBCXX_PARALLEL_ASSERTIONS
double __search_start = omp_get_wtime();
#endif
// Look for new work.
bool __successfully_stolen = false;
while (__wait && *__tl._M_elements_leftover > 0
&& !__successfully_stolen
#if _GLIBCXX_PARALLEL_ASSERTIONS
// Possible dead-lock.
&& (omp_get_wtime() < (__search_start + 1.0))
#endif
)
{
_ThreadIndex __victim;
__victim = __rng(__num_threads);
// Large pieces.
__successfully_stolen = (__victim != __iam)
&& __tls[__victim]->_M_leftover_parts.pop_back(__current);
if (!__successfully_stolen)
__yield();
#if !defined(__ICC) && !defined(__ECC)
# pragma omp flush
#endif
}
#if _GLIBCXX_PARALLEL_ASSERTIONS
if (omp_get_wtime() >= (__search_start + 1.0))
{
sleep(1);
_GLIBCXX_PARALLEL_ASSERT(omp_get_wtime()
< (__search_start + 1.0));
}
#endif
if (!__successfully_stolen)
{
#if _GLIBCXX_PARALLEL_ASSERTIONS
_GLIBCXX_PARALLEL_ASSERT(*__tl._M_elements_leftover == 0);
#endif
return;
}
}
}
}
/** @brief Top-level quicksort routine.
* @param __begin Begin iterator of sequence.
* @param __end End iterator of sequence.
* @param __comp Comparator.
* @param __num_threads Number of threads that are allowed to work on
* this part.
*/
template<typename _RAIter, typename _Compare>
void
__parallel_sort_qsb(_RAIter __begin, _RAIter __end,
_Compare __comp, _ThreadIndex __num_threads)
{
_GLIBCXX_CALL(__end - __begin)
typedef std::iterator_traits<_RAIter> _TraitsType;
typedef typename _TraitsType::value_type _ValueType;
typedef typename _TraitsType::difference_type _DifferenceType;
typedef std::pair<_RAIter, _RAIter> _Piece;
typedef _QSBThreadLocal<_RAIter> _TLSType;
_DifferenceType __n = __end - __begin;
if (__n <= 1)
return;
// At least one element per processor.
if (__num_threads > __n)
__num_threads = static_cast<_ThreadIndex>(__n);
// Initialize thread local storage
_TLSType** __tls = new _TLSType*[__num_threads];
_DifferenceType __queue_size = (__num_threads
* (_ThreadIndex)(__rd_log2(__n) + 1));
for (_ThreadIndex __t = 0; __t < __num_threads; ++__t)
__tls[__t] = new _QSBThreadLocal<_RAIter>(__queue_size);
// There can never be more than ceil(__rd_log2(__n)) ranges on the
// stack, because
// 1. Only one processor pushes onto the stack
// 2. The largest range has at most length __n
// 3. Each range is larger than half of the range remaining
volatile _DifferenceType __elements_leftover = __n;
for (_ThreadIndex __i = 0; __i < __num_threads; ++__i)
{
__tls[__i]->_M_elements_leftover = &__elements_leftover;
__tls[__i]->_M_num_threads = __num_threads;
__tls[__i]->_M_global = std::make_pair(__begin, __end);
// Just in case nothing is left to assign.
__tls[__i]->_M_initial = std::make_pair(__end, __end);
}
// Main recursion call.
__qsb_conquer(__tls, __begin, __begin + __n, __comp, 0,
__num_threads, true);
#if _GLIBCXX_PARALLEL_ASSERTIONS
// All stack must be empty.
_Piece __dummy;
for (_ThreadIndex __i = 1; __i < __num_threads; ++__i)
_GLIBCXX_PARALLEL_ASSERT(
!__tls[__i]->_M_leftover_parts.pop_back(__dummy));
#endif
for (_ThreadIndex __i = 0; __i < __num_threads; ++__i)
delete __tls[__i];
delete[] __tls;
}
} // namespace __gnu_parallel
#endif /* _GLIBCXX_PARALLEL_BALANCED_QUICKSORT_H */
c++/8/parallel/parallel.h 0000644 00000003050 15201526705 0011025 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/parallel.h
* @brief End-user include file. Provides advanced settings and
* tuning options.
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Felix Putze and Johannes Singler.
#ifndef _GLIBCXX_PARALLEL_PARALLEL_H
#define _GLIBCXX_PARALLEL_PARALLEL_H 1
#include <parallel/features.h>
#include <parallel/compiletime_settings.h>
#include <parallel/types.h>
#include <parallel/tags.h>
#include <parallel/settings.h>
#endif /* _GLIBCXX_PARALLEL_PARALLEL_H */
c++/8/parallel/tags.h 0000644 00000013536 15201526705 0010201 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/**
* @file parallel/tags.h
* @brief Tags for compile-time selection.
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Johannes Singler and Felix Putze.
#ifndef _GLIBCXX_PARALLEL_TAGS_H
#define _GLIBCXX_PARALLEL_TAGS_H 1
#include <omp.h>
#include <parallel/types.h>
namespace __gnu_parallel
{
/** @brief Forces sequential execution at compile time. */
struct sequential_tag { };
/** @brief Recommends parallel execution at compile time,
* optionally using a user-specified number of threads. */
struct parallel_tag
{
private:
_ThreadIndex _M_num_threads;
public:
/** @brief Default constructor. Use default number of threads. */
parallel_tag()
{ _M_num_threads = 0; }
/** @brief Default constructor. Recommend number of threads to use.
* @param __num_threads Desired number of threads. */
parallel_tag(_ThreadIndex __num_threads)
{ _M_num_threads = __num_threads; }
/** @brief Find out desired number of threads.
* @return Desired number of threads. */
_ThreadIndex __get_num_threads()
{
if(_M_num_threads == 0)
return omp_get_max_threads();
else
return _M_num_threads;
}
/** @brief Set the desired number of threads.
* @param __num_threads Desired number of threads. */
void set_num_threads(_ThreadIndex __num_threads)
{ _M_num_threads = __num_threads; }
};
/** @brief Recommends parallel execution using the
default parallel algorithm. */
struct default_parallel_tag : public parallel_tag
{
default_parallel_tag() { }
default_parallel_tag(_ThreadIndex __num_threads)
: parallel_tag(__num_threads) { }
};
/** @brief Recommends parallel execution using dynamic
load-balancing at compile time. */
struct balanced_tag : public parallel_tag { };
/** @brief Recommends parallel execution using static
load-balancing at compile time. */
struct unbalanced_tag : public parallel_tag { };
/** @brief Recommends parallel execution using OpenMP dynamic
load-balancing at compile time. */
struct omp_loop_tag : public parallel_tag { };
/** @brief Recommends parallel execution using OpenMP static
load-balancing at compile time. */
struct omp_loop_static_tag : public parallel_tag { };
/** @brief Base class for for std::find() variants. */
struct find_tag { };
/** @brief Forces parallel merging
* with exact splitting, at compile time. */
struct exact_tag : public parallel_tag
{
exact_tag() { }
exact_tag(_ThreadIndex __num_threads)
: parallel_tag(__num_threads) { }
};
/** @brief Forces parallel merging
* with exact splitting, at compile time. */
struct sampling_tag : public parallel_tag
{
sampling_tag() { }
sampling_tag(_ThreadIndex __num_threads)
: parallel_tag(__num_threads) { }
};
/** @brief Forces parallel sorting using multiway mergesort
* at compile time. */
struct multiway_mergesort_tag : public parallel_tag
{
multiway_mergesort_tag() { }
multiway_mergesort_tag(_ThreadIndex __num_threads)
: parallel_tag(__num_threads) { }
};
/** @brief Forces parallel sorting using multiway mergesort
* with exact splitting at compile time. */
struct multiway_mergesort_exact_tag : public parallel_tag
{
multiway_mergesort_exact_tag() { }
multiway_mergesort_exact_tag(_ThreadIndex __num_threads)
: parallel_tag(__num_threads) { }
};
/** @brief Forces parallel sorting using multiway mergesort
* with splitting by sampling at compile time. */
struct multiway_mergesort_sampling_tag : public parallel_tag
{
multiway_mergesort_sampling_tag() { }
multiway_mergesort_sampling_tag(_ThreadIndex __num_threads)
: parallel_tag(__num_threads) { }
};
/** @brief Forces parallel sorting using unbalanced quicksort
* at compile time. */
struct quicksort_tag : public parallel_tag
{
quicksort_tag() { }
quicksort_tag(_ThreadIndex __num_threads)
: parallel_tag(__num_threads) { }
};
/** @brief Forces parallel sorting using balanced quicksort
* at compile time. */
struct balanced_quicksort_tag : public parallel_tag
{
balanced_quicksort_tag() { }
balanced_quicksort_tag(_ThreadIndex __num_threads)
: parallel_tag(__num_threads) { }
};
/** @brief Selects the growing block size variant for std::find().
@see _GLIBCXX_FIND_GROWING_BLOCKS */
struct growing_blocks_tag : public find_tag { };
/** @brief Selects the constant block size variant for std::find().
@see _GLIBCXX_FIND_CONSTANT_SIZE_BLOCKS */
struct constant_size_blocks_tag : public find_tag { };
/** @brief Selects the equal splitting variant for std::find().
@see _GLIBCXX_FIND_EQUAL_SPLIT */
struct equal_split_tag : public find_tag { };
}
#endif /* _GLIBCXX_PARALLEL_TAGS_H */
c++/8/parallel/list_partition.h 0000644 00000014616 15201526705 0012307 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute __it and/or modify __it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that __it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/list_partition.h
* @brief _Functionality to split __sequence referenced by only input
* iterators.
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Leonor Frias Moya and Johannes Singler.
#ifndef _GLIBCXX_PARALLEL_LIST_PARTITION_H
#define _GLIBCXX_PARALLEL_LIST_PARTITION_H 1
#include <parallel/parallel.h>
#include <vector>
namespace __gnu_parallel
{
/** @brief Shrinks and doubles the ranges.
* @param __os_starts Start positions worked on (oversampled).
* @param __count_to_two Counts up to 2.
* @param __range_length Current length of a chunk.
* @param __make_twice Whether the @c __os_starts is allowed to be
* grown or not
*/
template<typename _IIter>
void
__shrink_and_double(std::vector<_IIter>& __os_starts,
size_t& __count_to_two, size_t& __range_length,
const bool __make_twice)
{
++__count_to_two;
if (!__make_twice || __count_to_two < 2)
__shrink(__os_starts, __count_to_two, __range_length);
else
{
__os_starts.resize((__os_starts.size() - 1) * 2 + 1);
__count_to_two = 0;
}
}
/** @brief Combines two ranges into one and thus halves the number of ranges.
* @param __os_starts Start positions worked on (oversampled).
* @param __count_to_two Counts up to 2.
* @param __range_length Current length of a chunk. */
template<typename _IIter>
void
__shrink(std::vector<_IIter>& __os_starts, size_t& __count_to_two,
size_t& __range_length)
{
for (typename std::vector<_IIter>::size_type __i = 0;
__i <= (__os_starts.size() / 2); ++__i)
__os_starts[__i] = __os_starts[__i * 2];
__range_length *= 2;
}
/** @brief Splits a sequence given by input iterators into parts of
* almost equal size
*
* The function needs only one pass over the sequence.
* @param __begin Begin iterator of input sequence.
* @param __end End iterator of input sequence.
* @param __starts Start iterators for the resulting parts, dimension
* @c __num_parts+1. For convenience, @c __starts @c [__num_parts]
* contains the end iterator of the sequence.
* @param __lengths Length of the resulting parts.
* @param __num_parts Number of parts to split the sequence into.
* @param __f Functor to be applied to each element by traversing __it
* @param __oversampling Oversampling factor. If 0, then the
* partitions will differ in at most
* \f$\sqrt{\mathrm{end} - \mathrm{begin}}\f$
* elements. Otherwise, the ratio between the
* longest and the shortest part is bounded by
* \f$1/(\mathrm{oversampling} \cdot \mathrm{num\_parts})\f$
* @return Length of the whole sequence.
*/
template<typename _IIter, typename _FunctorType>
size_t
list_partition(const _IIter __begin, const _IIter __end,
_IIter* __starts, size_t* __lengths, const int __num_parts,
_FunctorType& __f, int __oversampling = 0)
{
bool __make_twice = false;
// The resizing algorithm is chosen according to the oversampling factor.
if (__oversampling == 0)
{
__make_twice = true;
__oversampling = 1;
}
std::vector<_IIter> __os_starts(2 * __oversampling * __num_parts + 1);
__os_starts[0] = __begin;
_IIter __prev = __begin, __it = __begin;
size_t __dist_limit = 0, __dist = 0;
size_t __cur = 1, __next = 1;
size_t __range_length = 1;
size_t __count_to_two = 0;
while (__it != __end)
{
__cur = __next;
for (; __cur < __os_starts.size() and __it != __end; ++__cur)
{
for (__dist_limit += __range_length;
__dist < __dist_limit and __it != __end; ++__dist)
{
__f(__it);
++__it;
}
__os_starts[__cur] = __it;
}
// Must compare for end and not __cur < __os_starts.size() , because
// __cur could be == __os_starts.size() as well
if (__it == __end)
break;
__shrink_and_double(__os_starts, __count_to_two, __range_length,
__make_twice);
__next = __os_starts.size() / 2 + 1;
}
// Calculation of the parts (one must be extracted from __current
// because the partition beginning at end, consists only of
// itself).
size_t __size_part = (__cur - 1) / __num_parts;
int __size_greater = static_cast<int>((__cur - 1) % __num_parts);
__starts[0] = __os_starts[0];
size_t __index = 0;
// Smallest partitions.
for (int __i = 1; __i < (__num_parts + 1 - __size_greater); ++__i)
{
__lengths[__i - 1] = __size_part * __range_length;
__index += __size_part;
__starts[__i] = __os_starts[__index];
}
// Biggest partitions.
for (int __i = __num_parts + 1 - __size_greater; __i <= __num_parts;
++__i)
{
__lengths[__i - 1] = (__size_part+1) * __range_length;
__index += (__size_part+1);
__starts[__i] = __os_starts[__index];
}
// Correction of the end size (the end iteration has not finished).
__lengths[__num_parts - 1] -= (__dist_limit - __dist);
return __dist;
}
}
#endif /* _GLIBCXX_PARALLEL_LIST_PARTITION_H */
c++/8/parallel/random_shuffle.h 0000644 00000044363 15201526705 0012241 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/random_shuffle.h
* @brief Parallel implementation of std::random_shuffle().
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Johannes Singler.
#ifndef _GLIBCXX_PARALLEL_RANDOM_SHUFFLE_H
#define _GLIBCXX_PARALLEL_RANDOM_SHUFFLE_H 1
#include <limits>
#include <bits/stl_numeric.h>
#include <parallel/parallel.h>
#include <parallel/random_number.h>
namespace __gnu_parallel
{
/** @brief Type to hold the index of a bin.
*
* Since many variables of this type are allocated, it should be
* chosen as small as possible.
*/
typedef unsigned short _BinIndex;
/** @brief Data known to every thread participating in
__gnu_parallel::__parallel_random_shuffle(). */
template<typename _RAIter>
struct _DRandomShufflingGlobalData
{
typedef std::iterator_traits<_RAIter> _TraitsType;
typedef typename _TraitsType::value_type _ValueType;
typedef typename _TraitsType::difference_type _DifferenceType;
/** @brief Begin iterator of the __source. */
_RAIter& _M_source;
/** @brief Temporary arrays for each thread. */
_ValueType** _M_temporaries;
/** @brief Two-dimensional array to hold the thread-bin distribution.
*
* Dimensions (_M_num_threads + 1) __x (_M_num_bins + 1). */
_DifferenceType** _M_dist;
/** @brief Start indexes of the threads' __chunks. */
_DifferenceType* _M_starts;
/** @brief Number of the thread that will further process the
corresponding bin. */
_ThreadIndex* _M_bin_proc;
/** @brief Number of bins to distribute to. */
int _M_num_bins;
/** @brief Number of bits needed to address the bins. */
int _M_num_bits;
/** @brief Constructor. */
_DRandomShufflingGlobalData(_RAIter& __source)
: _M_source(__source) { }
};
/** @brief Local data for a thread participating in
__gnu_parallel::__parallel_random_shuffle().
*/
template<typename _RAIter, typename _RandomNumberGenerator>
struct _DRSSorterPU
{
/** @brief Number of threads participating in total. */
int _M_num_threads;
/** @brief Begin index for bins taken care of by this thread. */
_BinIndex _M_bins_begin;
/** @brief End index for bins taken care of by this thread. */
_BinIndex __bins_end;
/** @brief Random _M_seed for this thread. */
uint32_t _M_seed;
/** @brief Pointer to global data. */
_DRandomShufflingGlobalData<_RAIter>* _M_sd;
};
/** @brief Generate a random number in @c [0,2^__logp).
* @param __logp Logarithm (basis 2) of the upper range __bound.
* @param __rng Random number generator to use.
*/
template<typename _RandomNumberGenerator>
inline int
__random_number_pow2(int __logp, _RandomNumberGenerator& __rng)
{ return __rng.__genrand_bits(__logp); }
/** @brief Random shuffle code executed by each thread.
* @param __pus Array of thread-local data records. */
template<typename _RAIter, typename _RandomNumberGenerator>
void
__parallel_random_shuffle_drs_pu(_DRSSorterPU<_RAIter,
_RandomNumberGenerator>* __pus)
{
typedef std::iterator_traits<_RAIter> _TraitsType;
typedef typename _TraitsType::value_type _ValueType;
typedef typename _TraitsType::difference_type _DifferenceType;
_ThreadIndex __iam = omp_get_thread_num();
_DRSSorterPU<_RAIter, _RandomNumberGenerator>* __d = &__pus[__iam];
_DRandomShufflingGlobalData<_RAIter>* __sd = __d->_M_sd;
// Indexing: _M_dist[bin][processor]
_DifferenceType __length = (__sd->_M_starts[__iam + 1]
- __sd->_M_starts[__iam]);
_BinIndex* __oracles = new _BinIndex[__length];
_DifferenceType* __dist = new _DifferenceType[__sd->_M_num_bins + 1];
_BinIndex* __bin_proc = new _BinIndex[__sd->_M_num_bins];
_ValueType** __temporaries = new _ValueType*[__d->_M_num_threads];
// Compute oracles and count appearances.
for (_BinIndex __b = 0; __b < __sd->_M_num_bins + 1; ++__b)
__dist[__b] = 0;
int __num_bits = __sd->_M_num_bits;
_RandomNumber __rng(__d->_M_seed);
// First main loop.
for (_DifferenceType __i = 0; __i < __length; ++__i)
{
_BinIndex __oracle = __random_number_pow2(__num_bits, __rng);
__oracles[__i] = __oracle;
// To allow prefix (partial) sum.
++(__dist[__oracle + 1]);
}
for (_BinIndex __b = 0; __b < __sd->_M_num_bins + 1; ++__b)
__sd->_M_dist[__b][__iam + 1] = __dist[__b];
# pragma omp barrier
# pragma omp single
{
// Sum up bins, __sd->_M_dist[__s + 1][__d->_M_num_threads] now
// contains the total number of items in bin __s
for (_BinIndex __s = 0; __s < __sd->_M_num_bins; ++__s)
__gnu_sequential::partial_sum(__sd->_M_dist[__s + 1],
__sd->_M_dist[__s + 1]
+ __d->_M_num_threads + 1,
__sd->_M_dist[__s + 1]);
}
# pragma omp barrier
_SequenceIndex __offset = 0, __global_offset = 0;
for (_BinIndex __s = 0; __s < __d->_M_bins_begin; ++__s)
__global_offset += __sd->_M_dist[__s + 1][__d->_M_num_threads];
# pragma omp barrier
for (_BinIndex __s = __d->_M_bins_begin; __s < __d->__bins_end; ++__s)
{
for (int __t = 0; __t < __d->_M_num_threads + 1; ++__t)
__sd->_M_dist[__s + 1][__t] += __offset;
__offset = __sd->_M_dist[__s + 1][__d->_M_num_threads];
}
__sd->_M_temporaries[__iam] = static_cast<_ValueType*>
(::operator new(sizeof(_ValueType) * __offset));
# pragma omp barrier
// Draw local copies to avoid false sharing.
for (_BinIndex __b = 0; __b < __sd->_M_num_bins + 1; ++__b)
__dist[__b] = __sd->_M_dist[__b][__iam];
for (_BinIndex __b = 0; __b < __sd->_M_num_bins; ++__b)
__bin_proc[__b] = __sd->_M_bin_proc[__b];
for (_ThreadIndex __t = 0; __t < __d->_M_num_threads; ++__t)
__temporaries[__t] = __sd->_M_temporaries[__t];
_RAIter __source = __sd->_M_source;
_DifferenceType __start = __sd->_M_starts[__iam];
// Distribute according to oracles, second main loop.
for (_DifferenceType __i = 0; __i < __length; ++__i)
{
_BinIndex __target_bin = __oracles[__i];
_ThreadIndex __target_p = __bin_proc[__target_bin];
// Last column [__d->_M_num_threads] stays unchanged.
::new(&(__temporaries[__target_p][__dist[__target_bin + 1]++]))
_ValueType(*(__source + __i + __start));
}
delete[] __oracles;
delete[] __dist;
delete[] __bin_proc;
delete[] __temporaries;
# pragma omp barrier
// Shuffle bins internally.
for (_BinIndex __b = __d->_M_bins_begin; __b < __d->__bins_end; ++__b)
{
_ValueType* __begin =
(__sd->_M_temporaries[__iam]
+ (__b == __d->_M_bins_begin
? 0 : __sd->_M_dist[__b][__d->_M_num_threads])),
*__end = (__sd->_M_temporaries[__iam]
+ __sd->_M_dist[__b + 1][__d->_M_num_threads]);
__sequential_random_shuffle(__begin, __end, __rng);
std::copy(__begin, __end, __sd->_M_source + __global_offset
+ (__b == __d->_M_bins_begin
? 0 : __sd->_M_dist[__b][__d->_M_num_threads]));
}
for (_SequenceIndex __i = 0; __i < __offset; ++__i)
__sd->_M_temporaries[__iam][__i].~_ValueType();
::operator delete(__sd->_M_temporaries[__iam]);
}
/** @brief Round up to the next greater power of 2.
* @param __x _Integer to round up */
template<typename _Tp>
_Tp
__round_up_to_pow2(_Tp __x)
{
if (__x <= 1)
return 1;
else
return (_Tp)1 << (__rd_log2(__x - 1) + 1);
}
/** @brief Main parallel random shuffle step.
* @param __begin Begin iterator of sequence.
* @param __end End iterator of sequence.
* @param __n Length of sequence.
* @param __num_threads Number of threads to use.
* @param __rng Random number generator to use.
*/
template<typename _RAIter, typename _RandomNumberGenerator>
void
__parallel_random_shuffle_drs(_RAIter __begin, _RAIter __end,
typename std::iterator_traits
<_RAIter>::difference_type __n,
_ThreadIndex __num_threads,
_RandomNumberGenerator& __rng)
{
typedef std::iterator_traits<_RAIter> _TraitsType;
typedef typename _TraitsType::value_type _ValueType;
typedef typename _TraitsType::difference_type _DifferenceType;
_GLIBCXX_CALL(__n)
const _Settings& __s = _Settings::get();
if (__num_threads > __n)
__num_threads = static_cast<_ThreadIndex>(__n);
_BinIndex __num_bins, __num_bins_cache;
#if _GLIBCXX_RANDOM_SHUFFLE_CONSIDER_L1
// Try the L1 cache first.
// Must fit into L1.
__num_bins_cache =
std::max<_DifferenceType>(1, __n / (__s.L1_cache_size_lb
/ sizeof(_ValueType)));
__num_bins_cache = __round_up_to_pow2(__num_bins_cache);
// No more buckets than TLB entries, power of 2
// Power of 2 and at least one element per bin, at most the TLB size.
__num_bins = std::min<_DifferenceType>(__n, __num_bins_cache);
#if _GLIBCXX_RANDOM_SHUFFLE_CONSIDER_TLB
// 2 TLB entries needed per bin.
__num_bins = std::min<_DifferenceType>(__s.TLB_size / 2, __num_bins);
#endif
__num_bins = __round_up_to_pow2(__num_bins);
if (__num_bins < __num_bins_cache)
{
#endif
// Now try the L2 cache
// Must fit into L2
__num_bins_cache = static_cast<_BinIndex>
(std::max<_DifferenceType>(1, __n / (__s.L2_cache_size
/ sizeof(_ValueType))));
__num_bins_cache = __round_up_to_pow2(__num_bins_cache);
// No more buckets than TLB entries, power of 2.
__num_bins = static_cast<_BinIndex>
(std::min(__n, static_cast<_DifferenceType>(__num_bins_cache)));
// Power of 2 and at least one element per bin, at most the TLB size.
#if _GLIBCXX_RANDOM_SHUFFLE_CONSIDER_TLB
// 2 TLB entries needed per bin.
__num_bins = std::min(static_cast<_DifferenceType>(__s.TLB_size / 2),
__num_bins);
#endif
__num_bins = __round_up_to_pow2(__num_bins);
#if _GLIBCXX_RANDOM_SHUFFLE_CONSIDER_L1
}
#endif
__num_bins = __round_up_to_pow2(
std::max<_BinIndex>(__num_threads, __num_bins));
if (__num_threads <= 1)
{
_RandomNumber __derived_rng(
__rng(std::numeric_limits<uint32_t>::max()));
__sequential_random_shuffle(__begin, __end, __derived_rng);
return;
}
_DRandomShufflingGlobalData<_RAIter> __sd(__begin);
_DRSSorterPU<_RAIter, _RandomNumber >* __pus;
_DifferenceType* __starts;
# pragma omp parallel num_threads(__num_threads)
{
_ThreadIndex __num_threads = omp_get_num_threads();
# pragma omp single
{
__pus = new _DRSSorterPU<_RAIter, _RandomNumber>[__num_threads];
__sd._M_temporaries = new _ValueType*[__num_threads];
__sd._M_dist = new _DifferenceType*[__num_bins + 1];
__sd._M_bin_proc = new _ThreadIndex[__num_bins];
for (_BinIndex __b = 0; __b < __num_bins + 1; ++__b)
__sd._M_dist[__b] = new _DifferenceType[__num_threads + 1];
for (_BinIndex __b = 0; __b < (__num_bins + 1); ++__b)
{
__sd._M_dist[0][0] = 0;
__sd._M_dist[__b][0] = 0;
}
__starts = __sd._M_starts = new _DifferenceType[__num_threads + 1];
int __bin_cursor = 0;
__sd._M_num_bins = __num_bins;
__sd._M_num_bits = __rd_log2(__num_bins);
_DifferenceType __chunk_length = __n / __num_threads,
__split = __n % __num_threads,
__start = 0;
_DifferenceType __bin_chunk_length = __num_bins / __num_threads,
__bin_split = __num_bins % __num_threads;
for (_ThreadIndex __i = 0; __i < __num_threads; ++__i)
{
__starts[__i] = __start;
__start += (__i < __split
? (__chunk_length + 1) : __chunk_length);
int __j = __pus[__i]._M_bins_begin = __bin_cursor;
// Range of bins for this processor.
__bin_cursor += (__i < __bin_split
? (__bin_chunk_length + 1)
: __bin_chunk_length);
__pus[__i].__bins_end = __bin_cursor;
for (; __j < __bin_cursor; ++__j)
__sd._M_bin_proc[__j] = __i;
__pus[__i]._M_num_threads = __num_threads;
__pus[__i]._M_seed = __rng(std::numeric_limits<uint32_t>::max());
__pus[__i]._M_sd = &__sd;
}
__starts[__num_threads] = __start;
} //single
// Now shuffle in parallel.
__parallel_random_shuffle_drs_pu(__pus);
} // parallel
delete[] __starts;
delete[] __sd._M_bin_proc;
for (int __s = 0; __s < (__num_bins + 1); ++__s)
delete[] __sd._M_dist[__s];
delete[] __sd._M_dist;
delete[] __sd._M_temporaries;
delete[] __pus;
}
/** @brief Sequential cache-efficient random shuffle.
* @param __begin Begin iterator of sequence.
* @param __end End iterator of sequence.
* @param __rng Random number generator to use.
*/
template<typename _RAIter, typename _RandomNumberGenerator>
void
__sequential_random_shuffle(_RAIter __begin, _RAIter __end,
_RandomNumberGenerator& __rng)
{
typedef std::iterator_traits<_RAIter> _TraitsType;
typedef typename _TraitsType::value_type _ValueType;
typedef typename _TraitsType::difference_type _DifferenceType;
_DifferenceType __n = __end - __begin;
const _Settings& __s = _Settings::get();
_BinIndex __num_bins, __num_bins_cache;
#if _GLIBCXX_RANDOM_SHUFFLE_CONSIDER_L1
// Try the L1 cache first, must fit into L1.
__num_bins_cache = std::max<_DifferenceType>
(1, __n / (__s.L1_cache_size_lb / sizeof(_ValueType)));
__num_bins_cache = __round_up_to_pow2(__num_bins_cache);
// No more buckets than TLB entries, power of 2
// Power of 2 and at least one element per bin, at most the TLB size
__num_bins = std::min(__n, (_DifferenceType)__num_bins_cache);
#if _GLIBCXX_RANDOM_SHUFFLE_CONSIDER_TLB
// 2 TLB entries needed per bin
__num_bins = std::min((_DifferenceType)__s.TLB_size / 2, __num_bins);
#endif
__num_bins = __round_up_to_pow2(__num_bins);
if (__num_bins < __num_bins_cache)
{
#endif
// Now try the L2 cache, must fit into L2.
__num_bins_cache = static_cast<_BinIndex>
(std::max<_DifferenceType>(1, __n / (__s.L2_cache_size
/ sizeof(_ValueType))));
__num_bins_cache = __round_up_to_pow2(__num_bins_cache);
// No more buckets than TLB entries, power of 2
// Power of 2 and at least one element per bin, at most the TLB size.
__num_bins = static_cast<_BinIndex>
(std::min(__n, static_cast<_DifferenceType>(__num_bins_cache)));
#if _GLIBCXX_RANDOM_SHUFFLE_CONSIDER_TLB
// 2 TLB entries needed per bin
__num_bins = std::min<_DifferenceType>(__s.TLB_size / 2, __num_bins);
#endif
__num_bins = __round_up_to_pow2(__num_bins);
#if _GLIBCXX_RANDOM_SHUFFLE_CONSIDER_L1
}
#endif
int __num_bits = __rd_log2(__num_bins);
if (__num_bins > 1)
{
_ValueType* __target =
static_cast<_ValueType*>(::operator new(sizeof(_ValueType) * __n));
_BinIndex* __oracles = new _BinIndex[__n];
_DifferenceType* __dist0 = new _DifferenceType[__num_bins + 1],
* __dist1 = new _DifferenceType[__num_bins + 1];
for (int __b = 0; __b < __num_bins + 1; ++__b)
__dist0[__b] = 0;
_RandomNumber __bitrng(__rng(0xFFFFFFFF));
for (_DifferenceType __i = 0; __i < __n; ++__i)
{
_BinIndex __oracle = __random_number_pow2(__num_bits, __bitrng);
__oracles[__i] = __oracle;
// To allow prefix (partial) sum.
++(__dist0[__oracle + 1]);
}
// Sum up bins.
__gnu_sequential::partial_sum(__dist0, __dist0 + __num_bins + 1,
__dist0);
for (int __b = 0; __b < __num_bins + 1; ++__b)
__dist1[__b] = __dist0[__b];
// Distribute according to oracles.
for (_DifferenceType __i = 0; __i < __n; ++__i)
::new(&(__target[(__dist0[__oracles[__i]])++]))
_ValueType(*(__begin + __i));
for (int __b = 0; __b < __num_bins; ++__b)
__sequential_random_shuffle(__target + __dist1[__b],
__target + __dist1[__b + 1], __rng);
// Copy elements back.
std::copy(__target, __target + __n, __begin);
delete[] __dist0;
delete[] __dist1;
delete[] __oracles;
for (_DifferenceType __i = 0; __i < __n; ++__i)
__target[__i].~_ValueType();
::operator delete(__target);
}
else
__gnu_sequential::random_shuffle(__begin, __end, __rng);
}
/** @brief Parallel random public call.
* @param __begin Begin iterator of sequence.
* @param __end End iterator of sequence.
* @param __rng Random number generator to use.
*/
template<typename _RAIter, typename _RandomNumberGenerator>
inline void
__parallel_random_shuffle(_RAIter __begin, _RAIter __end,
_RandomNumberGenerator __rng = _RandomNumber())
{
typedef std::iterator_traits<_RAIter> _TraitsType;
typedef typename _TraitsType::difference_type _DifferenceType;
_DifferenceType __n = __end - __begin;
__parallel_random_shuffle_drs(__begin, __end, __n,
__get_max_threads(), __rng);
}
}
#endif /* _GLIBCXX_PARALLEL_RANDOM_SHUFFLE_H */
c++/8/parallel/queue.h 0000644 00000012646 15201526705 0010370 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/queue.h
* @brief Lock-free double-ended queue.
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Johannes Singler.
#ifndef _GLIBCXX_PARALLEL_QUEUE_H
#define _GLIBCXX_PARALLEL_QUEUE_H 1
#include <parallel/types.h>
#include <parallel/base.h>
#include <parallel/compatibility.h>
/** @brief Decide whether to declare certain variable volatile in this file. */
#define _GLIBCXX_VOLATILE volatile
namespace __gnu_parallel
{
/**@brief Double-ended queue of bounded size, allowing lock-free
* atomic access. push_front() and pop_front() must not be called
* concurrently to each other, while pop_back() can be called
* concurrently at all times.
* @c empty(), @c size(), and @c top() are intentionally not provided.
* Calling them would not make sense in a concurrent setting.
* @param _Tp Contained element type. */
template<typename _Tp>
class _RestrictedBoundedConcurrentQueue
{
private:
/** @brief Array of elements, seen as cyclic buffer. */
_Tp* _M_base;
/** @brief Maximal number of elements contained at the same time. */
_SequenceIndex _M_max_size;
/** @brief Cyclic __begin and __end pointers contained in one
atomically changeable value. */
_GLIBCXX_VOLATILE _CASable _M_borders;
public:
/** @brief Constructor. Not to be called concurrent, of course.
* @param __max_size Maximal number of elements to be contained. */
_RestrictedBoundedConcurrentQueue(_SequenceIndex __max_size)
{
_M_max_size = __max_size;
_M_base = new _Tp[__max_size];
_M_borders = __encode2(0, 0);
#pragma omp flush
}
/** @brief Destructor. Not to be called concurrent, of course. */
~_RestrictedBoundedConcurrentQueue()
{ delete[] _M_base; }
/** @brief Pushes one element into the queue at the front end.
* Must not be called concurrently with pop_front(). */
void
push_front(const _Tp& __t)
{
_CASable __former_borders = _M_borders;
int __former_front, __former_back;
__decode2(__former_borders, __former_front, __former_back);
*(_M_base + __former_front % _M_max_size) = __t;
#if _GLIBCXX_PARALLEL_ASSERTIONS
// Otherwise: front - back > _M_max_size eventually.
_GLIBCXX_PARALLEL_ASSERT(((__former_front + 1) - __former_back)
<= _M_max_size);
#endif
__fetch_and_add(&_M_borders, __encode2(1, 0));
}
/** @brief Pops one element from the queue at the front end.
* Must not be called concurrently with pop_front(). */
bool
pop_front(_Tp& __t)
{
int __former_front, __former_back;
#pragma omp flush
__decode2(_M_borders, __former_front, __former_back);
while (__former_front > __former_back)
{
// Chance.
_CASable __former_borders = __encode2(__former_front,
__former_back);
_CASable __new_borders = __encode2(__former_front - 1,
__former_back);
if (__compare_and_swap(&_M_borders, __former_borders,
__new_borders))
{
__t = *(_M_base + (__former_front - 1) % _M_max_size);
return true;
}
#pragma omp flush
__decode2(_M_borders, __former_front, __former_back);
}
return false;
}
/** @brief Pops one element from the queue at the front end.
* Must not be called concurrently with pop_front(). */
bool
pop_back(_Tp& __t) //queue behavior
{
int __former_front, __former_back;
#pragma omp flush
__decode2(_M_borders, __former_front, __former_back);
while (__former_front > __former_back)
{
// Chance.
_CASable __former_borders = __encode2(__former_front,
__former_back);
_CASable __new_borders = __encode2(__former_front,
__former_back + 1);
if (__compare_and_swap(&_M_borders, __former_borders,
__new_borders))
{
__t = *(_M_base + __former_back % _M_max_size);
return true;
}
#pragma omp flush
__decode2(_M_borders, __former_front, __former_back);
}
return false;
}
};
} //namespace __gnu_parallel
#undef _GLIBCXX_VOLATILE
#endif /* _GLIBCXX_PARALLEL_QUEUE_H */
c++/8/parallel/algobase.h 0000644 00000041403 15201526705 0011012 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/algobase.h
* @brief Parallel STL function calls corresponding to the
* stl_algobase.h header. The functions defined here mainly do case
* switches and call the actual parallelized versions in other files.
* Inlining policy: Functions that basically only contain one
* function call, are declared inline.
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Johannes Singler and Felix Putze.
#ifndef _GLIBCXX_PARALLEL_ALGOBASE_H
#define _GLIBCXX_PARALLEL_ALGOBASE_H 1
#include <bits/stl_algobase.h>
#include <parallel/base.h>
#include <parallel/algorithmfwd.h>
#include <parallel/find.h>
#include <parallel/find_selectors.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __parallel
{
// NB: equal and lexicographical_compare require mismatch.
// Sequential fallback
template<typename _IIter1, typename _IIter2>
inline pair<_IIter1, _IIter2>
mismatch(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::mismatch(__begin1, __end1, __begin2); }
// Sequential fallback
template<typename _IIter1, typename _IIter2, typename _Predicate>
inline pair<_IIter1, _IIter2>
mismatch(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2,
_Predicate __pred, __gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::mismatch(__begin1, __end1, __begin2, __pred); }
// Sequential fallback for input iterator case
template<typename _IIter1, typename _IIter2,
typename _Predicate, typename _IteratorTag1, typename _IteratorTag2>
inline pair<_IIter1, _IIter2>
__mismatch_switch(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2,
_Predicate __pred, _IteratorTag1, _IteratorTag2)
{ return _GLIBCXX_STD_A::mismatch(__begin1, __end1, __begin2, __pred); }
// Parallel mismatch for random access iterators
template<typename _RAIter1, typename _RAIter2, typename _Predicate>
pair<_RAIter1, _RAIter2>
__mismatch_switch(_RAIter1 __begin1, _RAIter1 __end1,
_RAIter2 __begin2, _Predicate __pred,
random_access_iterator_tag, random_access_iterator_tag)
{
if (_GLIBCXX_PARALLEL_CONDITION(true))
{
_RAIter1 __res =
__gnu_parallel::__find_template(__begin1, __end1, __begin2, __pred,
__gnu_parallel::
__mismatch_selector()).first;
return make_pair(__res , __begin2 + (__res - __begin1));
}
else
return _GLIBCXX_STD_A::mismatch(__begin1, __end1, __begin2, __pred);
}
// Public interface
template<typename _IIter1, typename _IIter2>
inline pair<_IIter1, _IIter2>
mismatch(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2)
{
typedef __gnu_parallel::_EqualTo<
typename std::iterator_traits<_IIter1>::value_type,
typename std::iterator_traits<_IIter2>::value_type> _EqualTo;
return __mismatch_switch(__begin1, __end1, __begin2, _EqualTo(),
std::__iterator_category(__begin1),
std::__iterator_category(__begin2));
}
// Public interface
template<typename _IIter1, typename _IIter2, typename _Predicate>
inline pair<_IIter1, _IIter2>
mismatch(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2,
_Predicate __pred)
{
return __mismatch_switch(__begin1, __end1, __begin2, __pred,
std::__iterator_category(__begin1),
std::__iterator_category(__begin2));
}
#if __cplusplus > 201103L
// Sequential fallback.
template<typename _InputIterator1, typename _InputIterator2>
inline pair<_InputIterator1, _InputIterator2>
mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::mismatch(__first1, __last1, __first2, __last2); }
// Sequential fallback.
template<typename _InputIterator1, typename _InputIterator2,
typename _BinaryPredicate>
inline pair<_InputIterator1, _InputIterator2>
mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2,
_BinaryPredicate __binary_pred,
__gnu_parallel::sequential_tag)
{
return _GLIBCXX_STD_A::mismatch(__first1, __last1, __first2, __last2,
__binary_pred);
}
// Sequential fallback for input iterator case
template<typename _IIter1, typename _IIter2,
typename _Predicate, typename _IteratorTag1, typename _IteratorTag2>
inline pair<_IIter1, _IIter2>
__mismatch_switch(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _IIter2 __end2, _Predicate __pred,
_IteratorTag1, _IteratorTag2)
{
return _GLIBCXX_STD_A::mismatch(__begin1, __end1,
__begin2, __end2, __pred);
}
// Parallel mismatch for random access iterators
template<typename _RAIter1, typename _RAIter2, typename _Predicate>
pair<_RAIter1, _RAIter2>
__mismatch_switch(_RAIter1 __begin1, _RAIter1 __end1,
_RAIter2 __begin2, _RAIter2 __end2, _Predicate __pred,
random_access_iterator_tag, random_access_iterator_tag)
{
if (_GLIBCXX_PARALLEL_CONDITION(true))
{
if ((__end2 - __begin2) < (__end1 - __begin1))
__end1 = __begin1 + (__end2 - __begin2);
_RAIter1 __res =
__gnu_parallel::__find_template(__begin1, __end1, __begin2, __pred,
__gnu_parallel::
__mismatch_selector()).first;
return make_pair(__res , __begin2 + (__res - __begin1));
}
else
return _GLIBCXX_STD_A::mismatch(__begin1, __end1,
__begin2, __end2, __pred);
}
template<typename _IIter1, typename _IIter2>
inline pair<_IIter1, _IIter2>
mismatch(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2)
{
typedef __gnu_parallel::_EqualTo<
typename std::iterator_traits<_IIter1>::value_type,
typename std::iterator_traits<_IIter2>::value_type> _EqualTo;
return __mismatch_switch(__begin1, __end1, __begin2, __end2, _EqualTo(),
std::__iterator_category(__begin1),
std::__iterator_category(__begin2));
}
template<typename _InputIterator1, typename _InputIterator2,
typename _BinaryPredicate>
inline pair<_InputIterator1, _InputIterator2>
mismatch(_InputIterator1 __begin1, _InputIterator1 __end1,
_InputIterator2 __begin2, _InputIterator2 __end2,
_BinaryPredicate __binary_pred)
{
return __mismatch_switch(__begin1, __end1, __begin2, __end2,
__binary_pred,
std::__iterator_category(__begin1),
std::__iterator_category(__begin2));
}
#endif
// Sequential fallback
template<typename _IIter1, typename _IIter2>
inline bool
equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::equal(__begin1, __end1, __begin2); }
// Sequential fallback
template<typename _IIter1, typename _IIter2, typename _Predicate>
inline bool
equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2,
_Predicate __pred, __gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::equal(__begin1, __end1, __begin2, __pred); }
// Public interface
template<typename _IIter1, typename _IIter2>
inline bool
equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2)
{
return __gnu_parallel::mismatch(__begin1, __end1, __begin2).first
== __end1;
}
// Public interface
template<typename _IIter1, typename _IIter2, typename _Predicate>
inline bool
equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2,
_Predicate __pred)
{
return __gnu_parallel::mismatch(__begin1, __end1, __begin2, __pred).first
== __end1;
}
#if __cplusplus > 201103L
// Sequential fallback
template<typename _IIter1, typename _IIter2>
inline bool
equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2,
__gnu_parallel::sequential_tag)
{
return _GLIBCXX_STD_A::equal(__begin1, __end1, __begin2, __end2);
}
// Sequential fallback
template<typename _IIter1, typename _IIter2, typename _BinaryPredicate>
inline bool
equal(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _IIter2 __end2, _BinaryPredicate __binary_pred,
__gnu_parallel::sequential_tag)
{
return _GLIBCXX_STD_A::equal(__begin1, __end1, __begin2, __end2,
__binary_pred);
}
// Sequential fallback for input iterator case
template<typename _IIter1, typename _IIter2,
typename _Predicate, typename _IteratorTag1, typename _IteratorTag2>
inline bool
__equal_switch(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _IIter2 __end2, _Predicate __pred,
_IteratorTag1, _IteratorTag2)
{
return _GLIBCXX_STD_A::equal(__begin1, __end1,
__begin2, __end2, __pred);
}
// Parallel equal for random access iterators
template<typename _RAIter1, typename _RAIter2, typename _Predicate>
inline bool
__equal_switch(_RAIter1 __begin1, _RAIter1 __end1,
_RAIter2 __begin2, _RAIter2 __end2, _Predicate __pred,
random_access_iterator_tag, random_access_iterator_tag)
{
if (_GLIBCXX_PARALLEL_CONDITION(true))
{
if (std::distance(__begin1, __end1)
!= std::distance(__begin2, __end2))
return false;
return __gnu_parallel::mismatch(__begin1, __end1, __begin2, __end2,
__pred).first == __end1;
}
else
return _GLIBCXX_STD_A::equal(__begin1, __end1,
__begin2, __end2, __pred);
}
template<typename _IIter1, typename _IIter2>
inline bool
equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2)
{
typedef __gnu_parallel::_EqualTo<
typename std::iterator_traits<_IIter1>::value_type,
typename std::iterator_traits<_IIter2>::value_type> _EqualTo;
return __equal_switch(__begin1, __end1, __begin2, __end2, _EqualTo(),
std::__iterator_category(__begin1),
std::__iterator_category(__begin2));
}
template<typename _IIter1, typename _IIter2, typename _BinaryPredicate>
inline bool
equal(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _IIter2 __end2, _BinaryPredicate __binary_pred)
{
return __equal_switch(__begin1, __end1, __begin2, __end2, __binary_pred,
std::__iterator_category(__begin1),
std::__iterator_category(__begin2));
}
#endif
// Sequential fallback
template<typename _IIter1, typename _IIter2>
inline bool
lexicographical_compare(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _IIter2 __end2,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::lexicographical_compare(__begin1, __end1,
__begin2, __end2); }
// Sequential fallback
template<typename _IIter1, typename _IIter2, typename _Predicate>
inline bool
lexicographical_compare(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _IIter2 __end2,
_Predicate __pred, __gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::lexicographical_compare(
__begin1, __end1, __begin2, __end2, __pred); }
// Sequential fallback for input iterator case
template<typename _IIter1, typename _IIter2,
typename _Predicate, typename _IteratorTag1, typename _IteratorTag2>
inline bool
__lexicographical_compare_switch(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _IIter2 __end2,
_Predicate __pred,
_IteratorTag1, _IteratorTag2)
{ return _GLIBCXX_STD_A::lexicographical_compare(
__begin1, __end1, __begin2, __end2, __pred); }
// Parallel lexicographical_compare for random access iterators
// Limitation: Both valuetypes must be the same
template<typename _RAIter1, typename _RAIter2, typename _Predicate>
bool
__lexicographical_compare_switch(_RAIter1 __begin1, _RAIter1 __end1,
_RAIter2 __begin2, _RAIter2 __end2,
_Predicate __pred,
random_access_iterator_tag,
random_access_iterator_tag)
{
if (_GLIBCXX_PARALLEL_CONDITION(true))
{
typedef iterator_traits<_RAIter1> _TraitsType1;
typedef typename _TraitsType1::value_type _ValueType1;
typedef iterator_traits<_RAIter2> _TraitsType2;
typedef typename _TraitsType2::value_type _ValueType2;
typedef __gnu_parallel::
_EqualFromLess<_ValueType1, _ValueType2, _Predicate>
_EqualFromLessCompare;
// Longer sequence in first place.
if ((__end1 - __begin1) < (__end2 - __begin2))
{
typedef pair<_RAIter1, _RAIter2> _SpotType;
_SpotType __mm = __mismatch_switch(__begin1, __end1, __begin2,
_EqualFromLessCompare(__pred),
random_access_iterator_tag(),
random_access_iterator_tag());
return (__mm.first == __end1)
|| bool(__pred(*__mm.first, *__mm.second));
}
else
{
typedef pair<_RAIter2, _RAIter1> _SpotType;
_SpotType __mm = __mismatch_switch(__begin2, __end2, __begin1,
_EqualFromLessCompare(__pred),
random_access_iterator_tag(),
random_access_iterator_tag());
return (__mm.first != __end2)
&& bool(__pred(*__mm.second, *__mm.first));
}
}
else
return _GLIBCXX_STD_A::lexicographical_compare(
__begin1, __end1, __begin2, __end2, __pred);
}
// Public interface
template<typename _IIter1, typename _IIter2>
inline bool
lexicographical_compare(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _IIter2 __end2)
{
typedef iterator_traits<_IIter1> _TraitsType1;
typedef typename _TraitsType1::value_type _ValueType1;
typedef typename _TraitsType1::iterator_category _IteratorCategory1;
typedef iterator_traits<_IIter2> _TraitsType2;
typedef typename _TraitsType2::value_type _ValueType2;
typedef typename _TraitsType2::iterator_category _IteratorCategory2;
typedef __gnu_parallel::_Less<_ValueType1, _ValueType2> _LessType;
return __lexicographical_compare_switch(
__begin1, __end1, __begin2, __end2, _LessType(),
_IteratorCategory1(), _IteratorCategory2());
}
// Public interface
template<typename _IIter1, typename _IIter2, typename _Predicate>
inline bool
lexicographical_compare(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _IIter2 __end2,
_Predicate __pred)
{
typedef iterator_traits<_IIter1> _TraitsType1;
typedef typename _TraitsType1::iterator_category _IteratorCategory1;
typedef iterator_traits<_IIter2> _TraitsType2;
typedef typename _TraitsType2::iterator_category _IteratorCategory2;
return __lexicographical_compare_switch(
__begin1, __end1, __begin2, __end2, __pred,
_IteratorCategory1(), _IteratorCategory2());
}
} // end namespace
} // end namespace
#endif /* _GLIBCXX_PARALLEL_ALGOBASE_H */
c++/8/parallel/multiseq_selection.h 0000644 00000053073 15201526705 0013153 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/multiseq_selection.h
* @brief Functions to find elements of a certain global __rank in
* multiple sorted sequences. Also serves for splitting such
* sequence sets.
*
* The algorithm description can be found in
*
* P. J. Varman, S. D. Scheufler, B. R. Iyer, and G. R. Ricard.
* Merging Multiple Lists on Hierarchical-Memory Multiprocessors.
* Journal of Parallel and Distributed Computing, 12(2):171–177, 1991.
*
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Johannes Singler.
#ifndef _GLIBCXX_PARALLEL_MULTISEQ_SELECTION_H
#define _GLIBCXX_PARALLEL_MULTISEQ_SELECTION_H 1
#include <vector>
#include <queue>
#include <bits/stl_algo.h>
namespace __gnu_parallel
{
/** @brief Compare __a pair of types lexicographically, ascending. */
template<typename _T1, typename _T2, typename _Compare>
class _Lexicographic
: public std::binary_function<std::pair<_T1, _T2>,
std::pair<_T1, _T2>, bool>
{
private:
_Compare& _M_comp;
public:
_Lexicographic(_Compare& __comp) : _M_comp(__comp) { }
bool
operator()(const std::pair<_T1, _T2>& __p1,
const std::pair<_T1, _T2>& __p2) const
{
if (_M_comp(__p1.first, __p2.first))
return true;
if (_M_comp(__p2.first, __p1.first))
return false;
// Firsts are equal.
return __p1.second < __p2.second;
}
};
/** @brief Compare __a pair of types lexicographically, descending. */
template<typename _T1, typename _T2, typename _Compare>
class _LexicographicReverse : public std::binary_function<_T1, _T2, bool>
{
private:
_Compare& _M_comp;
public:
_LexicographicReverse(_Compare& __comp) : _M_comp(__comp) { }
bool
operator()(const std::pair<_T1, _T2>& __p1,
const std::pair<_T1, _T2>& __p2) const
{
if (_M_comp(__p2.first, __p1.first))
return true;
if (_M_comp(__p1.first, __p2.first))
return false;
// Firsts are equal.
return __p2.second < __p1.second;
}
};
/**
* @brief Splits several sorted sequences at a certain global __rank,
* resulting in a splitting point for each sequence.
* The sequences are passed via a sequence of random-access
* iterator pairs, none of the sequences may be empty. If there
* are several equal elements across the split, the ones on the
* __left side will be chosen from sequences with smaller number.
* @param __begin_seqs Begin of the sequence of iterator pairs.
* @param __end_seqs End of the sequence of iterator pairs.
* @param __rank The global rank to partition at.
* @param __begin_offsets A random-access __sequence __begin where the
* __result will be stored in. Each element of the sequence is an
* iterator that points to the first element on the greater part of
* the respective __sequence.
* @param __comp The ordering functor, defaults to std::less<_Tp>.
*/
template<typename _RanSeqs, typename _RankType, typename _RankIterator,
typename _Compare>
void
multiseq_partition(_RanSeqs __begin_seqs, _RanSeqs __end_seqs,
_RankType __rank,
_RankIterator __begin_offsets,
_Compare __comp = std::less<
typename std::iterator_traits<typename
std::iterator_traits<_RanSeqs>::value_type::
first_type>::value_type>()) // std::less<_Tp>
{
_GLIBCXX_CALL(__end_seqs - __begin_seqs)
typedef typename std::iterator_traits<_RanSeqs>::value_type::first_type
_It;
typedef typename std::iterator_traits<_RanSeqs>::difference_type
_SeqNumber;
typedef typename std::iterator_traits<_It>::difference_type
_DifferenceType;
typedef typename std::iterator_traits<_It>::value_type _ValueType;
_Lexicographic<_ValueType, _SeqNumber, _Compare> __lcomp(__comp);
_LexicographicReverse<_ValueType, _SeqNumber, _Compare> __lrcomp(__comp);
// Number of sequences, number of elements in total (possibly
// including padding).
_DifferenceType __m = std::distance(__begin_seqs, __end_seqs), __nn = 0,
__nmax, __n, __r;
for (_SeqNumber __i = 0; __i < __m; __i++)
{
__nn += std::distance(__begin_seqs[__i].first,
__begin_seqs[__i].second);
_GLIBCXX_PARALLEL_ASSERT(
std::distance(__begin_seqs[__i].first,
__begin_seqs[__i].second) > 0);
}
if (__rank == __nn)
{
for (_SeqNumber __i = 0; __i < __m; __i++)
__begin_offsets[__i] = __begin_seqs[__i].second; // Very end.
// Return __m - 1;
return;
}
_GLIBCXX_PARALLEL_ASSERT(__m != 0);
_GLIBCXX_PARALLEL_ASSERT(__nn != 0);
_GLIBCXX_PARALLEL_ASSERT(__rank >= 0);
_GLIBCXX_PARALLEL_ASSERT(__rank < __nn);
_DifferenceType* __ns = new _DifferenceType[__m];
_DifferenceType* __a = new _DifferenceType[__m];
_DifferenceType* __b = new _DifferenceType[__m];
_DifferenceType __l;
__ns[0] = std::distance(__begin_seqs[0].first, __begin_seqs[0].second);
__nmax = __ns[0];
for (_SeqNumber __i = 0; __i < __m; __i++)
{
__ns[__i] = std::distance(__begin_seqs[__i].first,
__begin_seqs[__i].second);
__nmax = std::max(__nmax, __ns[__i]);
}
__r = __rd_log2(__nmax) + 1;
// Pad all lists to this length, at least as long as any ns[__i],
// equality iff __nmax = 2^__k - 1.
__l = (1ULL << __r) - 1;
for (_SeqNumber __i = 0; __i < __m; __i++)
{
__a[__i] = 0;
__b[__i] = __l;
}
__n = __l / 2;
// Invariants:
// 0 <= __a[__i] <= __ns[__i], 0 <= __b[__i] <= __l
#define __S(__i) (__begin_seqs[__i].first)
// Initial partition.
std::vector<std::pair<_ValueType, _SeqNumber> > __sample;
for (_SeqNumber __i = 0; __i < __m; __i++)
if (__n < __ns[__i]) //__sequence long enough
__sample.push_back(std::make_pair(__S(__i)[__n], __i));
__gnu_sequential::sort(__sample.begin(), __sample.end(), __lcomp);
for (_SeqNumber __i = 0; __i < __m; __i++) //conceptual infinity
if (__n >= __ns[__i]) //__sequence too short, conceptual infinity
__sample.push_back(
std::make_pair(__S(__i)[0] /*__dummy element*/, __i));
_DifferenceType __localrank = __rank / __l;
_SeqNumber __j;
for (__j = 0;
__j < __localrank && ((__n + 1) <= __ns[__sample[__j].second]);
++__j)
__a[__sample[__j].second] += __n + 1;
for (; __j < __m; __j++)
__b[__sample[__j].second] -= __n + 1;
// Further refinement.
while (__n > 0)
{
__n /= 2;
_SeqNumber __lmax_seq = -1; // to avoid warning
const _ValueType* __lmax = 0; // impossible to avoid the warning?
for (_SeqNumber __i = 0; __i < __m; __i++)
{
if (__a[__i] > 0)
{
if (!__lmax)
{
__lmax = &(__S(__i)[__a[__i] - 1]);
__lmax_seq = __i;
}
else
{
// Max, favor rear sequences.
if (!__comp(__S(__i)[__a[__i] - 1], *__lmax))
{
__lmax = &(__S(__i)[__a[__i] - 1]);
__lmax_seq = __i;
}
}
}
}
_SeqNumber __i;
for (__i = 0; __i < __m; __i++)
{
_DifferenceType __middle = (__b[__i] + __a[__i]) / 2;
if (__lmax && __middle < __ns[__i] &&
__lcomp(std::make_pair(__S(__i)[__middle], __i),
std::make_pair(*__lmax, __lmax_seq)))
__a[__i] = std::min(__a[__i] + __n + 1, __ns[__i]);
else
__b[__i] -= __n + 1;
}
_DifferenceType __leftsize = 0;
for (_SeqNumber __i = 0; __i < __m; __i++)
__leftsize += __a[__i] / (__n + 1);
_DifferenceType __skew = __rank / (__n + 1) - __leftsize;
if (__skew > 0)
{
// Move to the left, find smallest.
std::priority_queue<std::pair<_ValueType, _SeqNumber>,
std::vector<std::pair<_ValueType, _SeqNumber> >,
_LexicographicReverse<_ValueType, _SeqNumber, _Compare> >
__pq(__lrcomp);
for (_SeqNumber __i = 0; __i < __m; __i++)
if (__b[__i] < __ns[__i])
__pq.push(std::make_pair(__S(__i)[__b[__i]], __i));
for (; __skew != 0 && !__pq.empty(); --__skew)
{
_SeqNumber __source = __pq.top().second;
__pq.pop();
__a[__source]
= std::min(__a[__source] + __n + 1, __ns[__source]);
__b[__source] += __n + 1;
if (__b[__source] < __ns[__source])
__pq.push(
std::make_pair(__S(__source)[__b[__source]], __source));
}
}
else if (__skew < 0)
{
// Move to the right, find greatest.
std::priority_queue<std::pair<_ValueType, _SeqNumber>,
std::vector<std::pair<_ValueType, _SeqNumber> >,
_Lexicographic<_ValueType, _SeqNumber, _Compare> >
__pq(__lcomp);
for (_SeqNumber __i = 0; __i < __m; __i++)
if (__a[__i] > 0)
__pq.push(std::make_pair(__S(__i)[__a[__i] - 1], __i));
for (; __skew != 0; ++__skew)
{
_SeqNumber __source = __pq.top().second;
__pq.pop();
__a[__source] -= __n + 1;
__b[__source] -= __n + 1;
if (__a[__source] > 0)
__pq.push(std::make_pair(
__S(__source)[__a[__source] - 1], __source));
}
}
}
// Postconditions:
// __a[__i] == __b[__i] in most cases, except when __a[__i] has been
// clamped because of having reached the boundary
// Now return the result, calculate the offset.
// Compare the keys on both edges of the border.
// Maximum of left edge, minimum of right edge.
_ValueType* __maxleft = 0;
_ValueType* __minright = 0;
for (_SeqNumber __i = 0; __i < __m; __i++)
{
if (__a[__i] > 0)
{
if (!__maxleft)
__maxleft = &(__S(__i)[__a[__i] - 1]);
else
{
// Max, favor rear sequences.
if (!__comp(__S(__i)[__a[__i] - 1], *__maxleft))
__maxleft = &(__S(__i)[__a[__i] - 1]);
}
}
if (__b[__i] < __ns[__i])
{
if (!__minright)
__minright = &(__S(__i)[__b[__i]]);
else
{
// Min, favor fore sequences.
if (__comp(__S(__i)[__b[__i]], *__minright))
__minright = &(__S(__i)[__b[__i]]);
}
}
}
_SeqNumber __seq = 0;
for (_SeqNumber __i = 0; __i < __m; __i++)
__begin_offsets[__i] = __S(__i) + __a[__i];
delete[] __ns;
delete[] __a;
delete[] __b;
}
/**
* @brief Selects the element at a certain global __rank from several
* sorted sequences.
*
* The sequences are passed via a sequence of random-access
* iterator pairs, none of the sequences may be empty.
* @param __begin_seqs Begin of the sequence of iterator pairs.
* @param __end_seqs End of the sequence of iterator pairs.
* @param __rank The global rank to partition at.
* @param __offset The rank of the selected element in the global
* subsequence of elements equal to the selected element. If the
* selected element is unique, this number is 0.
* @param __comp The ordering functor, defaults to std::less.
*/
template<typename _Tp, typename _RanSeqs, typename _RankType,
typename _Compare>
_Tp
multiseq_selection(_RanSeqs __begin_seqs, _RanSeqs __end_seqs,
_RankType __rank,
_RankType& __offset, _Compare __comp = std::less<_Tp>())
{
_GLIBCXX_CALL(__end_seqs - __begin_seqs)
typedef typename std::iterator_traits<_RanSeqs>::value_type::first_type
_It;
typedef typename std::iterator_traits<_RanSeqs>::difference_type
_SeqNumber;
typedef typename std::iterator_traits<_It>::difference_type
_DifferenceType;
_Lexicographic<_Tp, _SeqNumber, _Compare> __lcomp(__comp);
_LexicographicReverse<_Tp, _SeqNumber, _Compare> __lrcomp(__comp);
// Number of sequences, number of elements in total (possibly
// including padding).
_DifferenceType __m = std::distance(__begin_seqs, __end_seqs);
_DifferenceType __nn = 0;
_DifferenceType __nmax, __n, __r;
for (_SeqNumber __i = 0; __i < __m; __i++)
__nn += std::distance(__begin_seqs[__i].first,
__begin_seqs[__i].second);
if (__m == 0 || __nn == 0 || __rank < 0 || __rank >= __nn)
{
// result undefined if there is no data or __rank is outside bounds
throw std::exception();
}
_DifferenceType* __ns = new _DifferenceType[__m];
_DifferenceType* __a = new _DifferenceType[__m];
_DifferenceType* __b = new _DifferenceType[__m];
_DifferenceType __l;
__ns[0] = std::distance(__begin_seqs[0].first, __begin_seqs[0].second);
__nmax = __ns[0];
for (_SeqNumber __i = 0; __i < __m; ++__i)
{
__ns[__i] = std::distance(__begin_seqs[__i].first,
__begin_seqs[__i].second);
__nmax = std::max(__nmax, __ns[__i]);
}
__r = __rd_log2(__nmax) + 1;
// Pad all lists to this length, at least as long as any ns[__i],
// equality iff __nmax = 2^__k - 1
__l = __round_up_to_pow2(__r) - 1;
for (_SeqNumber __i = 0; __i < __m; ++__i)
{
__a[__i] = 0;
__b[__i] = __l;
}
__n = __l / 2;
// Invariants:
// 0 <= __a[__i] <= __ns[__i], 0 <= __b[__i] <= __l
#define __S(__i) (__begin_seqs[__i].first)
// Initial partition.
std::vector<std::pair<_Tp, _SeqNumber> > __sample;
for (_SeqNumber __i = 0; __i < __m; __i++)
if (__n < __ns[__i])
__sample.push_back(std::make_pair(__S(__i)[__n], __i));
__gnu_sequential::sort(__sample.begin(), __sample.end(),
__lcomp, sequential_tag());
// Conceptual infinity.
for (_SeqNumber __i = 0; __i < __m; __i++)
if (__n >= __ns[__i])
__sample.push_back(
std::make_pair(__S(__i)[0] /*__dummy element*/, __i));
_DifferenceType __localrank = __rank / __l;
_SeqNumber __j;
for (__j = 0;
__j < __localrank && ((__n + 1) <= __ns[__sample[__j].second]);
++__j)
__a[__sample[__j].second] += __n + 1;
for (; __j < __m; ++__j)
__b[__sample[__j].second] -= __n + 1;
// Further refinement.
while (__n > 0)
{
__n /= 2;
const _Tp* __lmax = 0;
for (_SeqNumber __i = 0; __i < __m; ++__i)
{
if (__a[__i] > 0)
{
if (!__lmax)
__lmax = &(__S(__i)[__a[__i] - 1]);
else
{
if (__comp(*__lmax, __S(__i)[__a[__i] - 1])) //max
__lmax = &(__S(__i)[__a[__i] - 1]);
}
}
}
_SeqNumber __i;
for (__i = 0; __i < __m; __i++)
{
_DifferenceType __middle = (__b[__i] + __a[__i]) / 2;
if (__lmax && __middle < __ns[__i]
&& __comp(__S(__i)[__middle], *__lmax))
__a[__i] = std::min(__a[__i] + __n + 1, __ns[__i]);
else
__b[__i] -= __n + 1;
}
_DifferenceType __leftsize = 0;
for (_SeqNumber __i = 0; __i < __m; ++__i)
__leftsize += __a[__i] / (__n + 1);
_DifferenceType __skew = __rank / (__n + 1) - __leftsize;
if (__skew > 0)
{
// Move to the left, find smallest.
std::priority_queue<std::pair<_Tp, _SeqNumber>,
std::vector<std::pair<_Tp, _SeqNumber> >,
_LexicographicReverse<_Tp, _SeqNumber, _Compare> >
__pq(__lrcomp);
for (_SeqNumber __i = 0; __i < __m; ++__i)
if (__b[__i] < __ns[__i])
__pq.push(std::make_pair(__S(__i)[__b[__i]], __i));
for (; __skew != 0 && !__pq.empty(); --__skew)
{
_SeqNumber __source = __pq.top().second;
__pq.pop();
__a[__source]
= std::min(__a[__source] + __n + 1, __ns[__source]);
__b[__source] += __n + 1;
if (__b[__source] < __ns[__source])
__pq.push(
std::make_pair(__S(__source)[__b[__source]], __source));
}
}
else if (__skew < 0)
{
// Move to the right, find greatest.
std::priority_queue<std::pair<_Tp, _SeqNumber>,
std::vector<std::pair<_Tp, _SeqNumber> >,
_Lexicographic<_Tp, _SeqNumber, _Compare> > __pq(__lcomp);
for (_SeqNumber __i = 0; __i < __m; ++__i)
if (__a[__i] > 0)
__pq.push(std::make_pair(__S(__i)[__a[__i] - 1], __i));
for (; __skew != 0; ++__skew)
{
_SeqNumber __source = __pq.top().second;
__pq.pop();
__a[__source] -= __n + 1;
__b[__source] -= __n + 1;
if (__a[__source] > 0)
__pq.push(std::make_pair(
__S(__source)[__a[__source] - 1], __source));
}
}
}
// Postconditions:
// __a[__i] == __b[__i] in most cases, except when __a[__i] has been
// clamped because of having reached the boundary
// Now return the result, calculate the offset.
// Compare the keys on both edges of the border.
// Maximum of left edge, minimum of right edge.
bool __maxleftset = false, __minrightset = false;
// Impossible to avoid the warning?
_Tp __maxleft, __minright;
for (_SeqNumber __i = 0; __i < __m; ++__i)
{
if (__a[__i] > 0)
{
if (!__maxleftset)
{
__maxleft = __S(__i)[__a[__i] - 1];
__maxleftset = true;
}
else
{
// Max.
if (__comp(__maxleft, __S(__i)[__a[__i] - 1]))
__maxleft = __S(__i)[__a[__i] - 1];
}
}
if (__b[__i] < __ns[__i])
{
if (!__minrightset)
{
__minright = __S(__i)[__b[__i]];
__minrightset = true;
}
else
{
// Min.
if (__comp(__S(__i)[__b[__i]], __minright))
__minright = __S(__i)[__b[__i]];
}
}
}
// Minright is the __splitter, in any case.
if (!__maxleftset || __comp(__minright, __maxleft))
{
// Good luck, everything is split unambiguously.
__offset = 0;
}
else
{
// We have to calculate an offset.
__offset = 0;
for (_SeqNumber __i = 0; __i < __m; ++__i)
{
_DifferenceType lb
= std::lower_bound(__S(__i), __S(__i) + __ns[__i],
__minright,
__comp) - __S(__i);
__offset += __a[__i] - lb;
}
}
delete[] __ns;
delete[] __a;
delete[] __b;
return __minright;
}
}
#undef __S
#endif /* _GLIBCXX_PARALLEL_MULTISEQ_SELECTION_H */
c++/8/parallel/omp_loop.h 0000644 00000007677 15201526705 0011100 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/omp_loop.h
* @brief Parallelization of embarrassingly parallel execution by
* means of an OpenMP for loop.
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Felix Putze.
#ifndef _GLIBCXX_PARALLEL_OMP_LOOP_H
#define _GLIBCXX_PARALLEL_OMP_LOOP_H 1
#include <omp.h>
#include <parallel/settings.h>
#include <parallel/basic_iterator.h>
#include <parallel/base.h>
namespace __gnu_parallel
{
/** @brief Embarrassingly parallel algorithm for random access
* iterators, using an OpenMP for loop.
*
* @param __begin Begin iterator of element sequence.
* @param __end End iterator of element sequence.
* @param __o User-supplied functor (comparator, predicate, adding
* functor, etc.).
* @param __f Functor to @a process an element with __op (depends on
* desired functionality, e. g. for std::for_each(), ...).
* @param __r Functor to @a add a single __result to the already
* processed elements (depends on functionality).
* @param __base Base value for reduction.
* @param __output Pointer to position where final result is written to
* @param __bound Maximum number of elements processed (e. g. for
* std::count_n()).
* @return User-supplied functor (that may contain a part of the result).
*/
template<typename _RAIter,
typename _Op,
typename _Fu,
typename _Red,
typename _Result>
_Op
__for_each_template_random_access_omp_loop(_RAIter __begin, _RAIter __end,
_Op __o, _Fu& __f, _Red __r,
_Result __base,
_Result& __output,
typename std::iterator_traits<_RAIter>::difference_type __bound)
{
typedef typename std::iterator_traits<_RAIter>::difference_type
_DifferenceType;
_DifferenceType __length = __end - __begin;
_ThreadIndex __num_threads = __gnu_parallel::min<_DifferenceType>
(__get_max_threads(), __length);
_Result *__thread_results;
# pragma omp parallel num_threads(__num_threads)
{
# pragma omp single
{
__num_threads = omp_get_num_threads();
__thread_results = new _Result[__num_threads];
for (_ThreadIndex __i = 0; __i < __num_threads; ++__i)
__thread_results[__i] = _Result();
}
_ThreadIndex __iam = omp_get_thread_num();
#pragma omp for schedule(dynamic, _Settings::get().workstealing_chunk_size)
for (_DifferenceType __pos = 0; __pos < __length; ++__pos)
__thread_results[__iam] = __r(__thread_results[__iam],
__f(__o, __begin+__pos));
} //parallel
for (_ThreadIndex __i = 0; __i < __num_threads; ++__i)
__output = __r(__output, __thread_results[__i]);
delete [] __thread_results;
// Points to last element processed (needed as return value for
// some algorithms like transform).
__f._M_finish_iterator = __begin + __length;
return __o;
}
} // end namespace
#endif /* _GLIBCXX_PARALLEL_OMP_LOOP_H */
c++/8/parallel/multiway_merge.h 0000644 00000211607 15201526705 0012274 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/multiway_merge.h
* @brief Implementation of sequential and parallel multiway merge.
*
* Explanations on the high-speed merging routines in the appendix of
*
* P. Sanders.
* Fast priority queues for cached memory.
* ACM Journal of Experimental Algorithmics, 5, 2000.
*
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Johannes Singler and Manuel Holtgrewe.
#ifndef _GLIBCXX_PARALLEL_MULTIWAY_MERGE_H
#define _GLIBCXX_PARALLEL_MULTIWAY_MERGE_H
#include <vector>
#include <bits/stl_algo.h>
#include <parallel/features.h>
#include <parallel/parallel.h>
#include <parallel/losertree.h>
#include <parallel/multiseq_selection.h>
#if _GLIBCXX_PARALLEL_ASSERTIONS
#include <parallel/checkers.h>
#endif
/** @brief Length of a sequence described by a pair of iterators. */
#define _GLIBCXX_PARALLEL_LENGTH(__s) ((__s).second - (__s).first)
namespace __gnu_parallel
{
template<typename _RAIter1, typename _RAIter2, typename _OutputIterator,
typename _DifferenceTp, typename _Compare>
_OutputIterator
__merge_advance(_RAIter1&, _RAIter1, _RAIter2&, _RAIter2,
_OutputIterator, _DifferenceTp, _Compare);
/** @brief _Iterator wrapper supporting an implicit supremum at the end
* of the sequence, dominating all comparisons.
*
* The implicit supremum comes with a performance cost.
*
* Deriving from _RAIter is not possible since
* _RAIter need not be a class.
*/
template<typename _RAIter, typename _Compare>
class _GuardedIterator
{
private:
/** @brief Current iterator __position. */
_RAIter _M_current;
/** @brief End iterator of the sequence. */
_RAIter _M_end;
/** @brief _Compare. */
_Compare& __comp;
public:
/** @brief Constructor. Sets iterator to beginning of sequence.
* @param __begin Begin iterator of sequence.
* @param __end End iterator of sequence.
* @param __comp Comparator provided for associated overloaded
* compare operators. */
_GuardedIterator(_RAIter __begin, _RAIter __end, _Compare& __comp)
: _M_current(__begin), _M_end(__end), __comp(__comp)
{ }
/** @brief Pre-increment operator.
* @return This. */
_GuardedIterator<_RAIter, _Compare>&
operator++()
{
++_M_current;
return *this;
}
/** @brief Dereference operator.
* @return Referenced element. */
typename std::iterator_traits<_RAIter>::value_type&
operator*()
{ return *_M_current; }
/** @brief Convert to wrapped iterator.
* @return Wrapped iterator. */
operator _RAIter()
{ return _M_current; }
/** @brief Compare two elements referenced by guarded iterators.
* @param __bi1 First iterator.
* @param __bi2 Second iterator.
* @return @c true if less. */
friend bool
operator<(_GuardedIterator<_RAIter, _Compare>& __bi1,
_GuardedIterator<_RAIter, _Compare>& __bi2)
{
if (__bi1._M_current == __bi1._M_end) // __bi1 is sup
return __bi2._M_current == __bi2._M_end; // __bi2 is not sup
if (__bi2._M_current == __bi2._M_end) // __bi2 is sup
return true;
return (__bi1.__comp)(*__bi1, *__bi2); // normal compare
}
/** @brief Compare two elements referenced by guarded iterators.
* @param __bi1 First iterator.
* @param __bi2 Second iterator.
* @return @c True if less equal. */
friend bool
operator<=(_GuardedIterator<_RAIter, _Compare>& __bi1,
_GuardedIterator<_RAIter, _Compare>& __bi2)
{
if (__bi2._M_current == __bi2._M_end) // __bi1 is sup
return __bi1._M_current != __bi1._M_end; // __bi2 is not sup
if (__bi1._M_current == __bi1._M_end) // __bi2 is sup
return false;
return !(__bi1.__comp)(*__bi2, *__bi1); // normal compare
}
};
template<typename _RAIter, typename _Compare>
class _UnguardedIterator
{
private:
/** @brief Current iterator __position. */
_RAIter _M_current;
/** @brief _Compare. */
_Compare& __comp;
public:
/** @brief Constructor. Sets iterator to beginning of sequence.
* @param __begin Begin iterator of sequence.
* @param __end Unused, only for compatibility.
* @param __comp Unused, only for compatibility. */
_UnguardedIterator(_RAIter __begin,
_RAIter /* __end */, _Compare& __comp)
: _M_current(__begin), __comp(__comp)
{ }
/** @brief Pre-increment operator.
* @return This. */
_UnguardedIterator<_RAIter, _Compare>&
operator++()
{
++_M_current;
return *this;
}
/** @brief Dereference operator.
* @return Referenced element. */
typename std::iterator_traits<_RAIter>::value_type&
operator*()
{ return *_M_current; }
/** @brief Convert to wrapped iterator.
* @return Wrapped iterator. */
operator _RAIter()
{ return _M_current; }
/** @brief Compare two elements referenced by unguarded iterators.
* @param __bi1 First iterator.
* @param __bi2 Second iterator.
* @return @c true if less. */
friend bool
operator<(_UnguardedIterator<_RAIter, _Compare>& __bi1,
_UnguardedIterator<_RAIter, _Compare>& __bi2)
{
// Normal compare.
return (__bi1.__comp)(*__bi1, *__bi2);
}
/** @brief Compare two elements referenced by unguarded iterators.
* @param __bi1 First iterator.
* @param __bi2 Second iterator.
* @return @c True if less equal. */
friend bool
operator<=(_UnguardedIterator<_RAIter, _Compare>& __bi1,
_UnguardedIterator<_RAIter, _Compare>& __bi2)
{
// Normal compare.
return !(__bi1.__comp)(*__bi2, *__bi1);
}
};
/** @brief Highly efficient 3-way merging procedure.
*
* Merging is done with the algorithm implementation described by Peter
* Sanders. Basically, the idea is to minimize the number of necessary
* comparison after merging an element. The implementation trick
* that makes this fast is that the order of the sequences is stored
* in the instruction pointer (translated into labels in C++).
*
* This works well for merging up to 4 sequences.
*
* Note that making the merging stable does @a not come at a
* performance hit.
*
* Whether the merging is done guarded or unguarded is selected by the
* used iterator class.
*
* @param __seqs_begin Begin iterator of iterator pair input sequence.
* @param __seqs_end End iterator of iterator pair input sequence.
* @param __target Begin iterator of output sequence.
* @param __comp Comparator.
* @param __length Maximum length to merge, less equal than the
* total number of elements available.
*
* @return End iterator of output sequence.
*/
template<template<typename RAI, typename C> class iterator,
typename _RAIterIterator,
typename _RAIter3,
typename _DifferenceTp,
typename _Compare>
_RAIter3
multiway_merge_3_variant(_RAIterIterator __seqs_begin,
_RAIterIterator __seqs_end,
_RAIter3 __target,
_DifferenceTp __length, _Compare __comp)
{
_GLIBCXX_CALL(__length);
typedef _DifferenceTp _DifferenceType;
typedef typename std::iterator_traits<_RAIterIterator>
::value_type::first_type
_RAIter1;
typedef typename std::iterator_traits<_RAIter1>::value_type
_ValueType;
if (__length == 0)
return __target;
#if _GLIBCXX_PARALLEL_ASSERTIONS
_DifferenceTp __orig_length = __length;
#endif
iterator<_RAIter1, _Compare>
__seq0(__seqs_begin[0].first, __seqs_begin[0].second, __comp),
__seq1(__seqs_begin[1].first, __seqs_begin[1].second, __comp),
__seq2(__seqs_begin[2].first, __seqs_begin[2].second, __comp);
if (__seq0 <= __seq1)
{
if (__seq1 <= __seq2)
goto __s012;
else
if (__seq2 < __seq0)
goto __s201;
else
goto __s021;
}
else
{
if (__seq1 <= __seq2)
{
if (__seq0 <= __seq2)
goto __s102;
else
goto __s120;
}
else
goto __s210;
}
#define _GLIBCXX_PARALLEL_MERGE_3_CASE(__a, __b, __c, __c0, __c1) \
__s ## __a ## __b ## __c : \
*__target = *__seq ## __a; \
++__target; \
--__length; \
++__seq ## __a; \
if (__length == 0) goto __finish; \
if (__seq ## __a __c0 __seq ## __b) goto __s ## __a ## __b ## __c; \
if (__seq ## __a __c1 __seq ## __c) goto __s ## __b ## __a ## __c; \
goto __s ## __b ## __c ## __a;
_GLIBCXX_PARALLEL_MERGE_3_CASE(0, 1, 2, <=, <=);
_GLIBCXX_PARALLEL_MERGE_3_CASE(1, 2, 0, <=, < );
_GLIBCXX_PARALLEL_MERGE_3_CASE(2, 0, 1, < , < );
_GLIBCXX_PARALLEL_MERGE_3_CASE(1, 0, 2, < , <=);
_GLIBCXX_PARALLEL_MERGE_3_CASE(0, 2, 1, <=, <=);
_GLIBCXX_PARALLEL_MERGE_3_CASE(2, 1, 0, < , < );
#undef _GLIBCXX_PARALLEL_MERGE_3_CASE
__finish:
;
#if _GLIBCXX_PARALLEL_ASSERTIONS
_GLIBCXX_PARALLEL_ASSERT(
((_RAIter1)__seq0 - __seqs_begin[0].first) +
((_RAIter1)__seq1 - __seqs_begin[1].first) +
((_RAIter1)__seq2 - __seqs_begin[2].first)
== __orig_length);
#endif
__seqs_begin[0].first = __seq0;
__seqs_begin[1].first = __seq1;
__seqs_begin[2].first = __seq2;
return __target;
}
/**
* @brief Highly efficient 4-way merging procedure.
*
* Merging is done with the algorithm implementation described by Peter
* Sanders. Basically, the idea is to minimize the number of necessary
* comparison after merging an element. The implementation trick
* that makes this fast is that the order of the sequences is stored
* in the instruction pointer (translated into goto labels in C++).
*
* This works well for merging up to 4 sequences.
*
* Note that making the merging stable does @a not come at a
* performance hit.
*
* Whether the merging is done guarded or unguarded is selected by the
* used iterator class.
*
* @param __seqs_begin Begin iterator of iterator pair input sequence.
* @param __seqs_end End iterator of iterator pair input sequence.
* @param __target Begin iterator of output sequence.
* @param __comp Comparator.
* @param __length Maximum length to merge, less equal than the
* total number of elements available.
*
* @return End iterator of output sequence.
*/
template<template<typename RAI, typename C> class iterator,
typename _RAIterIterator,
typename _RAIter3,
typename _DifferenceTp,
typename _Compare>
_RAIter3
multiway_merge_4_variant(_RAIterIterator __seqs_begin,
_RAIterIterator __seqs_end,
_RAIter3 __target,
_DifferenceTp __length, _Compare __comp)
{
_GLIBCXX_CALL(__length);
typedef _DifferenceTp _DifferenceType;
typedef typename std::iterator_traits<_RAIterIterator>
::value_type::first_type
_RAIter1;
typedef typename std::iterator_traits<_RAIter1>::value_type
_ValueType;
iterator<_RAIter1, _Compare>
__seq0(__seqs_begin[0].first, __seqs_begin[0].second, __comp),
__seq1(__seqs_begin[1].first, __seqs_begin[1].second, __comp),
__seq2(__seqs_begin[2].first, __seqs_begin[2].second, __comp),
__seq3(__seqs_begin[3].first, __seqs_begin[3].second, __comp);
#define _GLIBCXX_PARALLEL_DECISION(__a, __b, __c, __d) { \
if (__seq ## __d < __seq ## __a) \
goto __s ## __d ## __a ## __b ## __c; \
if (__seq ## __d < __seq ## __b) \
goto __s ## __a ## __d ## __b ## __c; \
if (__seq ## __d < __seq ## __c) \
goto __s ## __a ## __b ## __d ## __c; \
goto __s ## __a ## __b ## __c ## __d; }
if (__seq0 <= __seq1)
{
if (__seq1 <= __seq2)
_GLIBCXX_PARALLEL_DECISION(0,1,2,3)
else
if (__seq2 < __seq0)
_GLIBCXX_PARALLEL_DECISION(2,0,1,3)
else
_GLIBCXX_PARALLEL_DECISION(0,2,1,3)
}
else
{
if (__seq1 <= __seq2)
{
if (__seq0 <= __seq2)
_GLIBCXX_PARALLEL_DECISION(1,0,2,3)
else
_GLIBCXX_PARALLEL_DECISION(1,2,0,3)
}
else
_GLIBCXX_PARALLEL_DECISION(2,1,0,3)
}
#define _GLIBCXX_PARALLEL_MERGE_4_CASE(__a, __b, __c, __d, \
__c0, __c1, __c2) \
__s ## __a ## __b ## __c ## __d: \
if (__length == 0) goto __finish; \
*__target = *__seq ## __a; \
++__target; \
--__length; \
++__seq ## __a; \
if (__seq ## __a __c0 __seq ## __b) \
goto __s ## __a ## __b ## __c ## __d; \
if (__seq ## __a __c1 __seq ## __c) \
goto __s ## __b ## __a ## __c ## __d; \
if (__seq ## __a __c2 __seq ## __d) \
goto __s ## __b ## __c ## __a ## __d; \
goto __s ## __b ## __c ## __d ## __a;
_GLIBCXX_PARALLEL_MERGE_4_CASE(0, 1, 2, 3, <=, <=, <=);
_GLIBCXX_PARALLEL_MERGE_4_CASE(0, 1, 3, 2, <=, <=, <=);
_GLIBCXX_PARALLEL_MERGE_4_CASE(0, 2, 1, 3, <=, <=, <=);
_GLIBCXX_PARALLEL_MERGE_4_CASE(0, 2, 3, 1, <=, <=, <=);
_GLIBCXX_PARALLEL_MERGE_4_CASE(0, 3, 1, 2, <=, <=, <=);
_GLIBCXX_PARALLEL_MERGE_4_CASE(0, 3, 2, 1, <=, <=, <=);
_GLIBCXX_PARALLEL_MERGE_4_CASE(1, 0, 2, 3, < , <=, <=);
_GLIBCXX_PARALLEL_MERGE_4_CASE(1, 0, 3, 2, < , <=, <=);
_GLIBCXX_PARALLEL_MERGE_4_CASE(1, 2, 0, 3, <=, < , <=);
_GLIBCXX_PARALLEL_MERGE_4_CASE(1, 2, 3, 0, <=, <=, < );
_GLIBCXX_PARALLEL_MERGE_4_CASE(1, 3, 0, 2, <=, < , <=);
_GLIBCXX_PARALLEL_MERGE_4_CASE(1, 3, 2, 0, <=, <=, < );
_GLIBCXX_PARALLEL_MERGE_4_CASE(2, 0, 1, 3, < , < , <=);
_GLIBCXX_PARALLEL_MERGE_4_CASE(2, 0, 3, 1, < , <=, < );
_GLIBCXX_PARALLEL_MERGE_4_CASE(2, 1, 0, 3, < , < , <=);
_GLIBCXX_PARALLEL_MERGE_4_CASE(2, 1, 3, 0, < , <=, < );
_GLIBCXX_PARALLEL_MERGE_4_CASE(2, 3, 0, 1, <=, < , < );
_GLIBCXX_PARALLEL_MERGE_4_CASE(2, 3, 1, 0, <=, < , < );
_GLIBCXX_PARALLEL_MERGE_4_CASE(3, 0, 1, 2, < , < , < );
_GLIBCXX_PARALLEL_MERGE_4_CASE(3, 0, 2, 1, < , < , < );
_GLIBCXX_PARALLEL_MERGE_4_CASE(3, 1, 0, 2, < , < , < );
_GLIBCXX_PARALLEL_MERGE_4_CASE(3, 1, 2, 0, < , < , < );
_GLIBCXX_PARALLEL_MERGE_4_CASE(3, 2, 0, 1, < , < , < );
_GLIBCXX_PARALLEL_MERGE_4_CASE(3, 2, 1, 0, < , < , < );
#undef _GLIBCXX_PARALLEL_MERGE_4_CASE
#undef _GLIBCXX_PARALLEL_DECISION
__finish:
;
__seqs_begin[0].first = __seq0;
__seqs_begin[1].first = __seq1;
__seqs_begin[2].first = __seq2;
__seqs_begin[3].first = __seq3;
return __target;
}
/** @brief Multi-way merging procedure for a high branching factor,
* guarded case.
*
* This merging variant uses a LoserTree class as selected by <tt>_LT</tt>.
*
* Stability is selected through the used LoserTree class <tt>_LT</tt>.
*
* At least one non-empty sequence is required.
*
* @param __seqs_begin Begin iterator of iterator pair input sequence.
* @param __seqs_end End iterator of iterator pair input sequence.
* @param __target Begin iterator of output sequence.
* @param __comp Comparator.
* @param __length Maximum length to merge, less equal than the
* total number of elements available.
*
* @return End iterator of output sequence.
*/
template<typename _LT,
typename _RAIterIterator,
typename _RAIter3,
typename _DifferenceTp,
typename _Compare>
_RAIter3
multiway_merge_loser_tree(_RAIterIterator __seqs_begin,
_RAIterIterator __seqs_end,
_RAIter3 __target,
_DifferenceTp __length, _Compare __comp)
{
_GLIBCXX_CALL(__length)
typedef _DifferenceTp _DifferenceType;
typedef typename std::iterator_traits<_RAIterIterator>
::difference_type _SeqNumber;
typedef typename std::iterator_traits<_RAIterIterator>
::value_type::first_type
_RAIter1;
typedef typename std::iterator_traits<_RAIter1>::value_type
_ValueType;
_SeqNumber __k = static_cast<_SeqNumber>(__seqs_end - __seqs_begin);
_LT __lt(__k, __comp);
// Default value for potentially non-default-constructible types.
_ValueType* __arbitrary_element = 0;
for (_SeqNumber __t = 0; __t < __k; ++__t)
{
if(!__arbitrary_element
&& _GLIBCXX_PARALLEL_LENGTH(__seqs_begin[__t]) > 0)
__arbitrary_element = &(*__seqs_begin[__t].first);
}
for (_SeqNumber __t = 0; __t < __k; ++__t)
{
if (__seqs_begin[__t].first == __seqs_begin[__t].second)
__lt.__insert_start(*__arbitrary_element, __t, true);
else
__lt.__insert_start(*__seqs_begin[__t].first, __t, false);
}
__lt.__init();
_SeqNumber __source;
for (_DifferenceType __i = 0; __i < __length; ++__i)
{
//take out
__source = __lt.__get_min_source();
*(__target++) = *(__seqs_begin[__source].first++);
// Feed.
if (__seqs_begin[__source].first == __seqs_begin[__source].second)
__lt.__delete_min_insert(*__arbitrary_element, true);
else
// Replace from same __source.
__lt.__delete_min_insert(*__seqs_begin[__source].first, false);
}
return __target;
}
/** @brief Multi-way merging procedure for a high branching factor,
* unguarded case.
*
* Merging is done using the LoserTree class <tt>_LT</tt>.
*
* Stability is selected by the used LoserTrees.
*
* @pre No input will run out of elements during the merge.
*
* @param __seqs_begin Begin iterator of iterator pair input sequence.
* @param __seqs_end End iterator of iterator pair input sequence.
* @param __target Begin iterator of output sequence.
* @param __comp Comparator.
* @param __length Maximum length to merge, less equal than the
* total number of elements available.
*
* @return End iterator of output sequence.
*/
template<typename _LT,
typename _RAIterIterator,
typename _RAIter3,
typename _DifferenceTp, typename _Compare>
_RAIter3
multiway_merge_loser_tree_unguarded(_RAIterIterator __seqs_begin,
_RAIterIterator __seqs_end,
_RAIter3 __target,
const typename std::iterator_traits<typename std::iterator_traits<
_RAIterIterator>::value_type::first_type>::value_type&
__sentinel,
_DifferenceTp __length,
_Compare __comp)
{
_GLIBCXX_CALL(__length)
typedef _DifferenceTp _DifferenceType;
typedef typename std::iterator_traits<_RAIterIterator>
::difference_type _SeqNumber;
typedef typename std::iterator_traits<_RAIterIterator>
::value_type::first_type
_RAIter1;
typedef typename std::iterator_traits<_RAIter1>::value_type
_ValueType;
_SeqNumber __k = __seqs_end - __seqs_begin;
_LT __lt(__k, __sentinel, __comp);
for (_SeqNumber __t = 0; __t < __k; ++__t)
{
#if _GLIBCXX_PARALLEL_ASSERTIONS
_GLIBCXX_PARALLEL_ASSERT(__seqs_begin[__t].first
!= __seqs_begin[__t].second);
#endif
__lt.__insert_start(*__seqs_begin[__t].first, __t, false);
}
__lt.__init();
_SeqNumber __source;
#if _GLIBCXX_PARALLEL_ASSERTIONS
_DifferenceType __i = 0;
#endif
_RAIter3 __target_end = __target + __length;
while (__target < __target_end)
{
// Take out.
__source = __lt.__get_min_source();
#if _GLIBCXX_PARALLEL_ASSERTIONS
_GLIBCXX_PARALLEL_ASSERT(0 <= __source && __source < __k);
_GLIBCXX_PARALLEL_ASSERT(__i == 0
|| !__comp(*(__seqs_begin[__source].first), *(__target - 1)));
#endif
// Feed.
*(__target++) = *(__seqs_begin[__source].first++);
#if _GLIBCXX_PARALLEL_ASSERTIONS
++__i;
#endif
// Replace from same __source.
__lt.__delete_min_insert(*__seqs_begin[__source].first, false);
}
return __target;
}
/** @brief Multi-way merging procedure for a high branching factor,
* requiring sentinels to exist.
*
* @tparam UnguardedLoserTree _Loser Tree variant to use for the unguarded
* merging.
*
* @param __seqs_begin Begin iterator of iterator pair input sequence.
* @param __seqs_end End iterator of iterator pair input sequence.
* @param __target Begin iterator of output sequence.
* @param __comp Comparator.
* @param __length Maximum length to merge, less equal than the
* total number of elements available.
*
* @return End iterator of output sequence.
*/
template<typename UnguardedLoserTree,
typename _RAIterIterator,
typename _RAIter3,
typename _DifferenceTp,
typename _Compare>
_RAIter3
multiway_merge_loser_tree_sentinel(_RAIterIterator __seqs_begin,
_RAIterIterator __seqs_end,
_RAIter3 __target,
const typename std::iterator_traits<typename std::iterator_traits<
_RAIterIterator>::value_type::first_type>::value_type&
__sentinel,
_DifferenceTp __length,
_Compare __comp)
{
_GLIBCXX_CALL(__length)
typedef _DifferenceTp _DifferenceType;
typedef std::iterator_traits<_RAIterIterator> _TraitsType;
typedef typename std::iterator_traits<_RAIterIterator>
::value_type::first_type
_RAIter1;
typedef typename std::iterator_traits<_RAIter1>::value_type
_ValueType;
_RAIter3 __target_end;
for (_RAIterIterator __s = __seqs_begin; __s != __seqs_end; ++__s)
// Move the sequence ends to the sentinel. This has the
// effect that the sentinel appears to be within the sequence. Then,
// we can use the unguarded variant if we merge out as many
// non-sentinel elements as we have.
++((*__s).second);
__target_end = multiway_merge_loser_tree_unguarded<UnguardedLoserTree>
(__seqs_begin, __seqs_end, __target, __sentinel, __length, __comp);
#if _GLIBCXX_PARALLEL_ASSERTIONS
_GLIBCXX_PARALLEL_ASSERT(__target_end == __target + __length);
_GLIBCXX_PARALLEL_ASSERT(__is_sorted(__target, __target_end, __comp));
#endif
// Restore the sequence ends so the sentinels are not contained in the
// sequence any more (see comment in loop above).
for (_RAIterIterator __s = __seqs_begin; __s != __seqs_end; ++__s)
--((*__s).second);
return __target_end;
}
/**
* @brief Traits for determining whether the loser tree should
* use pointers or copies.
*
* The field "_M_use_pointer" is used to determine whether to use pointers
* in he loser trees or whether to copy the values into the loser tree.
*
* The default behavior is to use pointers if the data type is 4 times as
* big as the pointer to it.
*
* Specialize for your data type to customize the behavior.
*
* Example:
*
* template<>
* struct _LoserTreeTraits<int>
* { static const bool _M_use_pointer = false; };
*
* template<>
* struct _LoserTreeTraits<heavyweight_type>
* { static const bool _M_use_pointer = true; };
*
* @param _Tp type to give the loser tree traits for.
*/
template <typename _Tp>
struct _LoserTreeTraits
{
/**
* @brief True iff to use pointers instead of values in loser trees.
*
* The default behavior is to use pointers if the data type is four
* times as big as the pointer to it.
*/
static const bool _M_use_pointer = (sizeof(_Tp) > 4 * sizeof(_Tp*));
};
/**
* @brief Switch for 3-way merging with __sentinels turned off.
*
* Note that 3-way merging is always stable!
*/
template<bool __sentinels /*default == false*/,
typename _RAIterIterator,
typename _RAIter3,
typename _DifferenceTp,
typename _Compare>
struct __multiway_merge_3_variant_sentinel_switch
{
_RAIter3
operator()(_RAIterIterator __seqs_begin,
_RAIterIterator __seqs_end,
_RAIter3 __target,
_DifferenceTp __length, _Compare __comp)
{ return multiway_merge_3_variant<_GuardedIterator>
(__seqs_begin, __seqs_end, __target, __length, __comp); }
};
/**
* @brief Switch for 3-way merging with __sentinels turned on.
*
* Note that 3-way merging is always stable!
*/
template<typename _RAIterIterator,
typename _RAIter3,
typename _DifferenceTp,
typename _Compare>
struct __multiway_merge_3_variant_sentinel_switch<true, _RAIterIterator,
_RAIter3, _DifferenceTp,
_Compare>
{
_RAIter3
operator()(_RAIterIterator __seqs_begin,
_RAIterIterator __seqs_end,
_RAIter3 __target,
_DifferenceTp __length, _Compare __comp)
{ return multiway_merge_3_variant<_UnguardedIterator>
(__seqs_begin, __seqs_end, __target, __length, __comp); }
};
/**
* @brief Switch for 4-way merging with __sentinels turned off.
*
* Note that 4-way merging is always stable!
*/
template<bool __sentinels /*default == false*/,
typename _RAIterIterator,
typename _RAIter3,
typename _DifferenceTp,
typename _Compare>
struct __multiway_merge_4_variant_sentinel_switch
{
_RAIter3
operator()(_RAIterIterator __seqs_begin,
_RAIterIterator __seqs_end,
_RAIter3 __target,
_DifferenceTp __length, _Compare __comp)
{ return multiway_merge_4_variant<_GuardedIterator>
(__seqs_begin, __seqs_end, __target, __length, __comp); }
};
/**
* @brief Switch for 4-way merging with __sentinels turned on.
*
* Note that 4-way merging is always stable!
*/
template<typename _RAIterIterator,
typename _RAIter3,
typename _DifferenceTp,
typename _Compare>
struct __multiway_merge_4_variant_sentinel_switch<true, _RAIterIterator,
_RAIter3, _DifferenceTp,
_Compare>
{
_RAIter3
operator()(_RAIterIterator __seqs_begin,
_RAIterIterator __seqs_end,
_RAIter3 __target,
_DifferenceTp __length, _Compare __comp)
{ return multiway_merge_4_variant<_UnguardedIterator>
(__seqs_begin, __seqs_end, __target, __length, __comp); }
};
/**
* @brief Switch for k-way merging with __sentinels turned on.
*/
template<bool __sentinels,
bool __stable,
typename _RAIterIterator,
typename _RAIter3,
typename _DifferenceTp,
typename _Compare>
struct __multiway_merge_k_variant_sentinel_switch
{
_RAIter3
operator()(_RAIterIterator __seqs_begin,
_RAIterIterator __seqs_end,
_RAIter3 __target,
const typename std::iterator_traits<typename std::iterator_traits<
_RAIterIterator>::value_type::first_type>::value_type&
__sentinel,
_DifferenceTp __length, _Compare __comp)
{
typedef typename std::iterator_traits<_RAIterIterator>
::value_type::first_type
_RAIter1;
typedef typename std::iterator_traits<_RAIter1>::value_type
_ValueType;
return multiway_merge_loser_tree_sentinel<
typename __gnu_cxx::__conditional_type<
_LoserTreeTraits<_ValueType>::_M_use_pointer,
_LoserTreePointerUnguarded<__stable, _ValueType, _Compare>,
_LoserTreeUnguarded<__stable, _ValueType, _Compare>
>::__type>
(__seqs_begin, __seqs_end, __target, __sentinel, __length, __comp);
}
};
/**
* @brief Switch for k-way merging with __sentinels turned off.
*/
template<bool __stable,
typename _RAIterIterator,
typename _RAIter3,
typename _DifferenceTp,
typename _Compare>
struct __multiway_merge_k_variant_sentinel_switch<false, __stable,
_RAIterIterator,
_RAIter3, _DifferenceTp,
_Compare>
{
_RAIter3
operator()(_RAIterIterator __seqs_begin,
_RAIterIterator __seqs_end,
_RAIter3 __target,
const typename std::iterator_traits<typename std::iterator_traits<
_RAIterIterator>::value_type::first_type>::value_type&
__sentinel,
_DifferenceTp __length, _Compare __comp)
{
typedef typename std::iterator_traits<_RAIterIterator>
::value_type::first_type
_RAIter1;
typedef typename std::iterator_traits<_RAIter1>::value_type
_ValueType;
return multiway_merge_loser_tree<
typename __gnu_cxx::__conditional_type<
_LoserTreeTraits<_ValueType>::_M_use_pointer,
_LoserTreePointer<__stable, _ValueType, _Compare>,
_LoserTree<__stable, _ValueType, _Compare>
>::__type >(__seqs_begin, __seqs_end, __target, __length, __comp);
}
};
/** @brief Sequential multi-way merging switch.
*
* The _GLIBCXX_PARALLEL_DECISION is based on the branching factor and
* runtime settings.
* @param __seqs_begin Begin iterator of iterator pair input sequence.
* @param __seqs_end End iterator of iterator pair input sequence.
* @param __target Begin iterator of output sequence.
* @param __comp Comparator.
* @param __length Maximum length to merge, possibly larger than the
* number of elements available.
* @param __sentinel The sequences have __a __sentinel element.
* @return End iterator of output sequence. */
template<bool __stable,
bool __sentinels,
typename _RAIterIterator,
typename _RAIter3,
typename _DifferenceTp,
typename _Compare>
_RAIter3
__sequential_multiway_merge(_RAIterIterator __seqs_begin,
_RAIterIterator __seqs_end,
_RAIter3 __target,
const typename std::iterator_traits<typename std::iterator_traits<
_RAIterIterator>::value_type::first_type>::value_type&
__sentinel,
_DifferenceTp __length, _Compare __comp)
{
_GLIBCXX_CALL(__length)
typedef _DifferenceTp _DifferenceType;
typedef typename std::iterator_traits<_RAIterIterator>
::difference_type _SeqNumber;
typedef typename std::iterator_traits<_RAIterIterator>
::value_type::first_type
_RAIter1;
typedef typename std::iterator_traits<_RAIter1>::value_type
_ValueType;
#if _GLIBCXX_PARALLEL_ASSERTIONS
for (_RAIterIterator __s = __seqs_begin; __s != __seqs_end; ++__s)
{
_GLIBCXX_PARALLEL_ASSERT(__is_sorted((*__s).first,
(*__s).second, __comp));
}
#endif
_DifferenceTp __total_length = 0;
for (_RAIterIterator __s = __seqs_begin; __s != __seqs_end; ++__s)
__total_length += _GLIBCXX_PARALLEL_LENGTH(*__s);
__length = std::min<_DifferenceTp>(__length, __total_length);
if(__length == 0)
return __target;
_RAIter3 __return_target = __target;
_SeqNumber __k = static_cast<_SeqNumber>(__seqs_end - __seqs_begin);
switch (__k)
{
case 0:
break;
case 1:
__return_target = std::copy(__seqs_begin[0].first,
__seqs_begin[0].first + __length,
__target);
__seqs_begin[0].first += __length;
break;
case 2:
__return_target = __merge_advance(__seqs_begin[0].first,
__seqs_begin[0].second,
__seqs_begin[1].first,
__seqs_begin[1].second,
__target, __length, __comp);
break;
case 3:
__return_target = __multiway_merge_3_variant_sentinel_switch
<__sentinels, _RAIterIterator, _RAIter3, _DifferenceTp, _Compare>()
(__seqs_begin, __seqs_end, __target, __length, __comp);
break;
case 4:
__return_target = __multiway_merge_4_variant_sentinel_switch
<__sentinels, _RAIterIterator, _RAIter3, _DifferenceTp, _Compare>()
(__seqs_begin, __seqs_end, __target, __length, __comp);
break;
default:
__return_target = __multiway_merge_k_variant_sentinel_switch
<__sentinels, __stable, _RAIterIterator, _RAIter3, _DifferenceTp,
_Compare>()
(__seqs_begin, __seqs_end, __target, __sentinel, __length, __comp);
break;
}
#if _GLIBCXX_PARALLEL_ASSERTIONS
_GLIBCXX_PARALLEL_ASSERT(
__is_sorted(__target, __target + __length, __comp));
#endif
return __return_target;
}
/**
* @brief Stable sorting functor.
*
* Used to reduce code instanciation in multiway_merge_sampling_splitting.
*/
template<bool __stable, class _RAIter, class _StrictWeakOrdering>
struct _SamplingSorter
{
void
operator()(_RAIter __first, _RAIter __last, _StrictWeakOrdering __comp)
{ __gnu_sequential::stable_sort(__first, __last, __comp); }
};
/**
* @brief Non-__stable sorting functor.
*
* Used to reduce code instantiation in multiway_merge_sampling_splitting.
*/
template<class _RAIter, class _StrictWeakOrdering>
struct _SamplingSorter<false, _RAIter, _StrictWeakOrdering>
{
void
operator()(_RAIter __first, _RAIter __last, _StrictWeakOrdering __comp)
{ __gnu_sequential::sort(__first, __last, __comp); }
};
/**
* @brief Sampling based splitting for parallel multiway-merge routine.
*/
template<bool __stable,
typename _RAIterIterator,
typename _Compare,
typename _DifferenceType>
void
multiway_merge_sampling_splitting(_RAIterIterator __seqs_begin,
_RAIterIterator __seqs_end,
_DifferenceType __length,
_DifferenceType __total_length,
_Compare __comp,
std::vector<std::pair<_DifferenceType, _DifferenceType> > *__pieces)
{
typedef typename std::iterator_traits<_RAIterIterator>
::difference_type _SeqNumber;
typedef typename std::iterator_traits<_RAIterIterator>
::value_type::first_type
_RAIter1;
typedef typename std::iterator_traits<_RAIter1>::value_type
_ValueType;
// __k sequences.
const _SeqNumber __k
= static_cast<_SeqNumber>(__seqs_end - __seqs_begin);
const _ThreadIndex __num_threads = omp_get_num_threads();
const _DifferenceType __num_samples =
__gnu_parallel::_Settings::get().merge_oversampling * __num_threads;
_ValueType* __samples = static_cast<_ValueType*>
(::operator new(sizeof(_ValueType) * __k * __num_samples));
// Sample.
for (_SeqNumber __s = 0; __s < __k; ++__s)
for (_DifferenceType __i = 0; __i < __num_samples; ++__i)
{
_DifferenceType sample_index = static_cast<_DifferenceType>
(_GLIBCXX_PARALLEL_LENGTH(__seqs_begin[__s])
* (double(__i + 1) / (__num_samples + 1))
* (double(__length) / __total_length));
new(&(__samples[__s * __num_samples + __i]))
_ValueType(__seqs_begin[__s].first[sample_index]);
}
// Sort stable or non-stable, depending on value of template parameter
// "__stable".
_SamplingSorter<__stable, _ValueType*, _Compare>()
(__samples, __samples + (__num_samples * __k), __comp);
for (_ThreadIndex __slab = 0; __slab < __num_threads; ++__slab)
// For each slab / processor.
for (_SeqNumber __seq = 0; __seq < __k; ++__seq)
{
// For each sequence.
if (__slab > 0)
__pieces[__slab][__seq].first = std::upper_bound
(__seqs_begin[__seq].first, __seqs_begin[__seq].second,
__samples[__num_samples * __k * __slab / __num_threads],
__comp)
- __seqs_begin[__seq].first;
else
// Absolute beginning.
__pieces[__slab][__seq].first = 0;
if ((__slab + 1) < __num_threads)
__pieces[__slab][__seq].second = std::upper_bound
(__seqs_begin[__seq].first, __seqs_begin[__seq].second,
__samples[__num_samples * __k * (__slab + 1) / __num_threads],
__comp)
- __seqs_begin[__seq].first;
else
// Absolute end.
__pieces[__slab][__seq].second =
_GLIBCXX_PARALLEL_LENGTH(__seqs_begin[__seq]);
}
for (_SeqNumber __s = 0; __s < __k; ++__s)
for (_DifferenceType __i = 0; __i < __num_samples; ++__i)
__samples[__s * __num_samples + __i].~_ValueType();
::operator delete(__samples);
}
/**
* @brief Exact splitting for parallel multiway-merge routine.
*
* None of the passed sequences may be empty.
*/
template<bool __stable,
typename _RAIterIterator,
typename _Compare,
typename _DifferenceType>
void
multiway_merge_exact_splitting(_RAIterIterator __seqs_begin,
_RAIterIterator __seqs_end,
_DifferenceType __length,
_DifferenceType __total_length,
_Compare __comp,
std::vector<std::pair<_DifferenceType, _DifferenceType> > *__pieces)
{
typedef typename std::iterator_traits<_RAIterIterator>
::difference_type _SeqNumber;
typedef typename std::iterator_traits<_RAIterIterator>
::value_type::first_type
_RAIter1;
const bool __tight = (__total_length == __length);
// __k sequences.
const _SeqNumber __k = __seqs_end - __seqs_begin;
const _ThreadIndex __num_threads = omp_get_num_threads();
// (Settings::multiway_merge_splitting
// == __gnu_parallel::_Settings::EXACT).
std::vector<_RAIter1>* __offsets =
new std::vector<_RAIter1>[__num_threads];
std::vector<std::pair<_RAIter1, _RAIter1> > __se(__k);
copy(__seqs_begin, __seqs_end, __se.begin());
_DifferenceType* __borders =
new _DifferenceType[__num_threads + 1];
__equally_split(__length, __num_threads, __borders);
for (_ThreadIndex __s = 0; __s < (__num_threads - 1); ++__s)
{
__offsets[__s].resize(__k);
multiseq_partition(__se.begin(), __se.end(), __borders[__s + 1],
__offsets[__s].begin(), __comp);
// Last one also needed and available.
if (!__tight)
{
__offsets[__num_threads - 1].resize(__k);
multiseq_partition(__se.begin(), __se.end(),
_DifferenceType(__length),
__offsets[__num_threads - 1].begin(),
__comp);
}
}
delete[] __borders;
for (_ThreadIndex __slab = 0; __slab < __num_threads; ++__slab)
{
// For each slab / processor.
for (_SeqNumber __seq = 0; __seq < __k; ++__seq)
{
// For each sequence.
if (__slab == 0)
{
// Absolute beginning.
__pieces[__slab][__seq].first = 0;
}
else
__pieces[__slab][__seq].first =
__pieces[__slab - 1][__seq].second;
if (!__tight || __slab < (__num_threads - 1))
__pieces[__slab][__seq].second =
__offsets[__slab][__seq] - __seqs_begin[__seq].first;
else
{
// __slab == __num_threads - 1
__pieces[__slab][__seq].second =
_GLIBCXX_PARALLEL_LENGTH(__seqs_begin[__seq]);
}
}
}
delete[] __offsets;
}
/** @brief Parallel multi-way merge routine.
*
* The _GLIBCXX_PARALLEL_DECISION is based on the branching factor
* and runtime settings.
*
* Must not be called if the number of sequences is 1.
*
* @tparam _Splitter functor to split input (either __exact or sampling based)
* @tparam __stable Stable merging incurs a performance penalty.
* @tparam __sentinel Ignored.
*
* @param __seqs_begin Begin iterator of iterator pair input sequence.
* @param __seqs_end End iterator of iterator pair input sequence.
* @param __target Begin iterator of output sequence.
* @param __comp Comparator.
* @param __length Maximum length to merge, possibly larger than the
* number of elements available.
* @return End iterator of output sequence.
*/
template<bool __stable,
bool __sentinels,
typename _RAIterIterator,
typename _RAIter3,
typename _DifferenceTp,
typename _Splitter,
typename _Compare>
_RAIter3
parallel_multiway_merge(_RAIterIterator __seqs_begin,
_RAIterIterator __seqs_end,
_RAIter3 __target,
_Splitter __splitter,
_DifferenceTp __length,
_Compare __comp,
_ThreadIndex __num_threads)
{
#if _GLIBCXX_PARALLEL_ASSERTIONS
_GLIBCXX_PARALLEL_ASSERT(__seqs_end - __seqs_begin > 1);
#endif
_GLIBCXX_CALL(__length)
typedef _DifferenceTp _DifferenceType;
typedef typename std::iterator_traits<_RAIterIterator>
::difference_type _SeqNumber;
typedef typename std::iterator_traits<_RAIterIterator>
::value_type::first_type
_RAIter1;
typedef typename
std::iterator_traits<_RAIter1>::value_type _ValueType;
// Leave only non-empty sequences.
typedef std::pair<_RAIter1, _RAIter1> seq_type;
seq_type* __ne_seqs = new seq_type[__seqs_end - __seqs_begin];
_SeqNumber __k = 0;
_DifferenceType __total_length = 0;
for (_RAIterIterator __raii = __seqs_begin;
__raii != __seqs_end; ++__raii)
{
_DifferenceTp __seq_length = _GLIBCXX_PARALLEL_LENGTH(*__raii);
if(__seq_length > 0)
{
__total_length += __seq_length;
__ne_seqs[__k++] = *__raii;
}
}
_GLIBCXX_CALL(__total_length)
__length = std::min<_DifferenceTp>(__length, __total_length);
if (__total_length == 0 || __k == 0)
{
delete[] __ne_seqs;
return __target;
}
std::vector<std::pair<_DifferenceType, _DifferenceType> >* __pieces;
__num_threads = static_cast<_ThreadIndex>
(std::min<_DifferenceType>(__num_threads, __total_length));
# pragma omp parallel num_threads (__num_threads)
{
# pragma omp single
{
__num_threads = omp_get_num_threads();
// Thread __t will have to merge pieces[__iam][0..__k - 1]
__pieces = new std::vector<
std::pair<_DifferenceType, _DifferenceType> >[__num_threads];
for (_ThreadIndex __s = 0; __s < __num_threads; ++__s)
__pieces[__s].resize(__k);
_DifferenceType __num_samples =
__gnu_parallel::_Settings::get().merge_oversampling
* __num_threads;
__splitter(__ne_seqs, __ne_seqs + __k, __length, __total_length,
__comp, __pieces);
} //single
_ThreadIndex __iam = omp_get_thread_num();
_DifferenceType __target_position = 0;
for (_SeqNumber __c = 0; __c < __k; ++__c)
__target_position += __pieces[__iam][__c].first;
seq_type* __chunks = new seq_type[__k];
for (_SeqNumber __s = 0; __s < __k; ++__s)
__chunks[__s] = std::make_pair(__ne_seqs[__s].first
+ __pieces[__iam][__s].first,
__ne_seqs[__s].first
+ __pieces[__iam][__s].second);
if(__length > __target_position)
__sequential_multiway_merge<__stable, __sentinels>
(__chunks, __chunks + __k, __target + __target_position,
*(__seqs_begin->second), __length - __target_position, __comp);
delete[] __chunks;
} // parallel
#if _GLIBCXX_PARALLEL_ASSERTIONS
_GLIBCXX_PARALLEL_ASSERT(
__is_sorted(__target, __target + __length, __comp));
#endif
__k = 0;
// Update ends of sequences.
for (_RAIterIterator __raii = __seqs_begin;
__raii != __seqs_end; ++__raii)
{
_DifferenceTp __length = _GLIBCXX_PARALLEL_LENGTH(*__raii);
if(__length > 0)
(*__raii).first += __pieces[__num_threads - 1][__k++].second;
}
delete[] __pieces;
delete[] __ne_seqs;
return __target + __length;
}
/**
* @brief Multiway Merge Frontend.
*
* Merge the sequences specified by seqs_begin and __seqs_end into
* __target. __seqs_begin and __seqs_end must point to a sequence of
* pairs. These pairs must contain an iterator to the beginning
* of a sequence in their first entry and an iterator the _M_end of
* the same sequence in their second entry.
*
* Ties are broken arbitrarily. See stable_multiway_merge for a variant
* that breaks ties by sequence number but is slower.
*
* The first entries of the pairs (i.e. the begin iterators) will be moved
* forward.
*
* The output sequence has to provide enough space for all elements
* that are written to it.
*
* This function will merge the input sequences:
*
* - not stable
* - parallel, depending on the input size and Settings
* - using sampling for splitting
* - not using sentinels
*
* Example:
*
* <pre>
* int sequences[10][10];
* for (int __i = 0; __i < 10; ++__i)
* for (int __j = 0; __i < 10; ++__j)
* sequences[__i][__j] = __j;
*
* int __out[33];
* std::vector<std::pair<int*> > seqs;
* for (int __i = 0; __i < 10; ++__i)
* { seqs.push(std::make_pair<int*>(sequences[__i],
* sequences[__i] + 10)) }
*
* multiway_merge(seqs.begin(), seqs.end(), __target, std::less<int>(), 33);
* </pre>
*
* @see stable_multiway_merge
*
* @pre All input sequences must be sorted.
* @pre Target must provide enough space to merge out length elements or
* the number of elements in all sequences, whichever is smaller.
*
* @post [__target, return __value) contains merged __elements from the
* input sequences.
* @post return __value - __target = min(__length, number of elements in all
* sequences).
*
* @tparam _RAIterPairIterator iterator over sequence
* of pairs of iterators
* @tparam _RAIterOut iterator over target sequence
* @tparam _DifferenceTp difference type for the sequence
* @tparam _Compare strict weak ordering type to compare elements
* in sequences
*
* @param __seqs_begin __begin of sequence __sequence
* @param __seqs_end _M_end of sequence __sequence
* @param __target target sequence to merge to.
* @param __comp strict weak ordering to use for element comparison.
* @param __length Maximum length to merge, possibly larger than the
* number of elements available.
*
* @return _M_end iterator of output sequence
*/
// multiway_merge
// public interface
template<typename _RAIterPairIterator,
typename _RAIterOut,
typename _DifferenceTp,
typename _Compare>
_RAIterOut
multiway_merge(_RAIterPairIterator __seqs_begin,
_RAIterPairIterator __seqs_end,
_RAIterOut __target,
_DifferenceTp __length, _Compare __comp,
__gnu_parallel::sequential_tag)
{
typedef _DifferenceTp _DifferenceType;
_GLIBCXX_CALL(__seqs_end - __seqs_begin)
// catch special case: no sequences
if (__seqs_begin == __seqs_end)
return __target;
// Execute multiway merge *sequentially*.
return __sequential_multiway_merge
</* __stable = */ false, /* __sentinels = */ false>
(__seqs_begin, __seqs_end, __target,
*(__seqs_begin->second), __length, __comp);
}
// public interface
template<typename _RAIterPairIterator,
typename _RAIterOut,
typename _DifferenceTp,
typename _Compare>
_RAIterOut
multiway_merge(_RAIterPairIterator __seqs_begin,
_RAIterPairIterator __seqs_end,
_RAIterOut __target,
_DifferenceTp __length, _Compare __comp,
__gnu_parallel::exact_tag __tag)
{
typedef _DifferenceTp _DifferenceType;
_GLIBCXX_CALL(__seqs_end - __seqs_begin)
// catch special case: no sequences
if (__seqs_begin == __seqs_end)
return __target;
// Execute merge; maybe parallel, depending on the number of merged
// elements and the number of sequences and global thresholds in
// Settings.
if ((__seqs_end - __seqs_begin > 1)
&& _GLIBCXX_PARALLEL_CONDITION(
((__seqs_end - __seqs_begin) >=
__gnu_parallel::_Settings::get().multiway_merge_minimal_k)
&& ((_SequenceIndex)__length >=
__gnu_parallel::_Settings::get().multiway_merge_minimal_n)))
return parallel_multiway_merge
</* __stable = */ false, /* __sentinels = */ false>
(__seqs_begin, __seqs_end, __target,
multiway_merge_exact_splitting</* __stable = */ false,
typename std::iterator_traits<_RAIterPairIterator>
::value_type*, _Compare, _DifferenceTp>,
static_cast<_DifferenceType>(__length), __comp,
__tag.__get_num_threads());
else
return __sequential_multiway_merge
</* __stable = */ false, /* __sentinels = */ false>
(__seqs_begin, __seqs_end, __target,
*(__seqs_begin->second), __length, __comp);
}
// public interface
template<typename _RAIterPairIterator,
typename _RAIterOut,
typename _DifferenceTp,
typename _Compare>
_RAIterOut
multiway_merge(_RAIterPairIterator __seqs_begin,
_RAIterPairIterator __seqs_end,
_RAIterOut __target,
_DifferenceTp __length, _Compare __comp,
__gnu_parallel::sampling_tag __tag)
{
typedef _DifferenceTp _DifferenceType;
_GLIBCXX_CALL(__seqs_end - __seqs_begin)
// catch special case: no sequences
if (__seqs_begin == __seqs_end)
return __target;
// Execute merge; maybe parallel, depending on the number of merged
// elements and the number of sequences and global thresholds in
// Settings.
if ((__seqs_end - __seqs_begin > 1)
&& _GLIBCXX_PARALLEL_CONDITION(
((__seqs_end - __seqs_begin) >=
__gnu_parallel::_Settings::get().multiway_merge_minimal_k)
&& ((_SequenceIndex)__length >=
__gnu_parallel::_Settings::get().multiway_merge_minimal_n)))
return parallel_multiway_merge
</* __stable = */ false, /* __sentinels = */ false>
(__seqs_begin, __seqs_end, __target,
multiway_merge_exact_splitting</* __stable = */ false,
typename std::iterator_traits<_RAIterPairIterator>
::value_type*, _Compare, _DifferenceTp>,
static_cast<_DifferenceType>(__length), __comp,
__tag.__get_num_threads());
else
return __sequential_multiway_merge
</* __stable = */ false, /* __sentinels = */ false>
(__seqs_begin, __seqs_end, __target,
*(__seqs_begin->second), __length, __comp);
}
// public interface
template<typename _RAIterPairIterator,
typename _RAIterOut,
typename _DifferenceTp,
typename _Compare>
_RAIterOut
multiway_merge(_RAIterPairIterator __seqs_begin,
_RAIterPairIterator __seqs_end,
_RAIterOut __target,
_DifferenceTp __length, _Compare __comp,
parallel_tag __tag = parallel_tag(0))
{ return multiway_merge(__seqs_begin, __seqs_end, __target, __length,
__comp, exact_tag(__tag.__get_num_threads())); }
// public interface
template<typename _RAIterPairIterator,
typename _RAIterOut,
typename _DifferenceTp,
typename _Compare>
_RAIterOut
multiway_merge(_RAIterPairIterator __seqs_begin,
_RAIterPairIterator __seqs_end,
_RAIterOut __target,
_DifferenceTp __length, _Compare __comp,
default_parallel_tag __tag)
{ return multiway_merge(__seqs_begin, __seqs_end, __target, __length,
__comp, exact_tag(__tag.__get_num_threads())); }
// stable_multiway_merge
// public interface
template<typename _RAIterPairIterator,
typename _RAIterOut,
typename _DifferenceTp,
typename _Compare>
_RAIterOut
stable_multiway_merge(_RAIterPairIterator __seqs_begin,
_RAIterPairIterator __seqs_end,
_RAIterOut __target,
_DifferenceTp __length, _Compare __comp,
__gnu_parallel::sequential_tag)
{
typedef _DifferenceTp _DifferenceType;
_GLIBCXX_CALL(__seqs_end - __seqs_begin)
// catch special case: no sequences
if (__seqs_begin == __seqs_end)
return __target;
// Execute multiway merge *sequentially*.
return __sequential_multiway_merge
</* __stable = */ true, /* __sentinels = */ false>
(__seqs_begin, __seqs_end, __target,
*(__seqs_begin->second), __length, __comp);
}
// public interface
template<typename _RAIterPairIterator,
typename _RAIterOut,
typename _DifferenceTp,
typename _Compare>
_RAIterOut
stable_multiway_merge(_RAIterPairIterator __seqs_begin,
_RAIterPairIterator __seqs_end,
_RAIterOut __target,
_DifferenceTp __length, _Compare __comp,
__gnu_parallel::exact_tag __tag)
{
typedef _DifferenceTp _DifferenceType;
_GLIBCXX_CALL(__seqs_end - __seqs_begin)
// catch special case: no sequences
if (__seqs_begin == __seqs_end)
return __target;
// Execute merge; maybe parallel, depending on the number of merged
// elements and the number of sequences and global thresholds in
// Settings.
if ((__seqs_end - __seqs_begin > 1)
&& _GLIBCXX_PARALLEL_CONDITION(
((__seqs_end - __seqs_begin) >=
__gnu_parallel::_Settings::get().multiway_merge_minimal_k)
&& ((_SequenceIndex)__length >=
__gnu_parallel::_Settings::get().multiway_merge_minimal_n)))
return parallel_multiway_merge
</* __stable = */ true, /* __sentinels = */ false>
(__seqs_begin, __seqs_end, __target,
multiway_merge_exact_splitting</* __stable = */ true,
typename std::iterator_traits<_RAIterPairIterator>
::value_type*, _Compare, _DifferenceTp>,
static_cast<_DifferenceType>(__length), __comp,
__tag.__get_num_threads());
else
return __sequential_multiway_merge
</* __stable = */ true, /* __sentinels = */ false>
(__seqs_begin, __seqs_end, __target,
*(__seqs_begin->second), __length, __comp);
}
// public interface
template<typename _RAIterPairIterator,
typename _RAIterOut,
typename _DifferenceTp,
typename _Compare>
_RAIterOut
stable_multiway_merge(_RAIterPairIterator __seqs_begin,
_RAIterPairIterator __seqs_end,
_RAIterOut __target,
_DifferenceTp __length, _Compare __comp,
sampling_tag __tag)
{
typedef _DifferenceTp _DifferenceType;
_GLIBCXX_CALL(__seqs_end - __seqs_begin)
// catch special case: no sequences
if (__seqs_begin == __seqs_end)
return __target;
// Execute merge; maybe parallel, depending on the number of merged
// elements and the number of sequences and global thresholds in
// Settings.
if ((__seqs_end - __seqs_begin > 1)
&& _GLIBCXX_PARALLEL_CONDITION(
((__seqs_end - __seqs_begin) >=
__gnu_parallel::_Settings::get().multiway_merge_minimal_k)
&& ((_SequenceIndex)__length >=
__gnu_parallel::_Settings::get().multiway_merge_minimal_n)))
return parallel_multiway_merge
</* __stable = */ true, /* __sentinels = */ false>
(__seqs_begin, __seqs_end, __target,
multiway_merge_sampling_splitting</* __stable = */ true,
typename std::iterator_traits<_RAIterPairIterator>
::value_type*, _Compare, _DifferenceTp>,
static_cast<_DifferenceType>(__length), __comp,
__tag.__get_num_threads());
else
return __sequential_multiway_merge
</* __stable = */ true, /* __sentinels = */ false>
(__seqs_begin, __seqs_end, __target,
*(__seqs_begin->second), __length, __comp);
}
// public interface
template<typename _RAIterPairIterator,
typename _RAIterOut,
typename _DifferenceTp,
typename _Compare>
_RAIterOut
stable_multiway_merge(_RAIterPairIterator __seqs_begin,
_RAIterPairIterator __seqs_end,
_RAIterOut __target,
_DifferenceTp __length, _Compare __comp,
parallel_tag __tag = parallel_tag(0))
{
return stable_multiway_merge
(__seqs_begin, __seqs_end, __target, __length, __comp,
exact_tag(__tag.__get_num_threads()));
}
// public interface
template<typename _RAIterPairIterator,
typename _RAIterOut,
typename _DifferenceTp,
typename _Compare>
_RAIterOut
stable_multiway_merge(_RAIterPairIterator __seqs_begin,
_RAIterPairIterator __seqs_end,
_RAIterOut __target,
_DifferenceTp __length, _Compare __comp,
default_parallel_tag __tag)
{
return stable_multiway_merge
(__seqs_begin, __seqs_end, __target, __length, __comp,
exact_tag(__tag.__get_num_threads()));
}
/**
* @brief Multiway Merge Frontend.
*
* Merge the sequences specified by seqs_begin and __seqs_end into
* __target. __seqs_begin and __seqs_end must point to a sequence of
* pairs. These pairs must contain an iterator to the beginning
* of a sequence in their first entry and an iterator the _M_end of
* the same sequence in their second entry.
*
* Ties are broken arbitrarily. See stable_multiway_merge for a variant
* that breaks ties by sequence number but is slower.
*
* The first entries of the pairs (i.e. the begin iterators) will be moved
* forward accordingly.
*
* The output sequence has to provide enough space for all elements
* that are written to it.
*
* This function will merge the input sequences:
*
* - not stable
* - parallel, depending on the input size and Settings
* - using sampling for splitting
* - using sentinels
*
* You have to take care that the element the _M_end iterator points to is
* readable and contains a value that is greater than any other non-sentinel
* value in all sequences.
*
* Example:
*
* <pre>
* int sequences[10][11];
* for (int __i = 0; __i < 10; ++__i)
* for (int __j = 0; __i < 11; ++__j)
* sequences[__i][__j] = __j; // __last one is sentinel!
*
* int __out[33];
* std::vector<std::pair<int*> > seqs;
* for (int __i = 0; __i < 10; ++__i)
* { seqs.push(std::make_pair<int*>(sequences[__i],
* sequences[__i] + 10)) }
*
* multiway_merge(seqs.begin(), seqs.end(), __target, std::less<int>(), 33);
* </pre>
*
* @pre All input sequences must be sorted.
* @pre Target must provide enough space to merge out length elements or
* the number of elements in all sequences, whichever is smaller.
* @pre For each @c __i, @c __seqs_begin[__i].second must be the end
* marker of the sequence, but also reference the one more __sentinel
* element.
*
* @post [__target, return __value) contains merged __elements from the
* input sequences.
* @post return __value - __target = min(__length, number of elements in all
* sequences).
*
* @see stable_multiway_merge_sentinels
*
* @tparam _RAIterPairIterator iterator over sequence
* of pairs of iterators
* @tparam _RAIterOut iterator over target sequence
* @tparam _DifferenceTp difference type for the sequence
* @tparam _Compare strict weak ordering type to compare elements
* in sequences
*
* @param __seqs_begin __begin of sequence __sequence
* @param __seqs_end _M_end of sequence __sequence
* @param __target target sequence to merge to.
* @param __comp strict weak ordering to use for element comparison.
* @param __length Maximum length to merge, possibly larger than the
* number of elements available.
*
* @return _M_end iterator of output sequence
*/
// multiway_merge_sentinels
// public interface
template<typename _RAIterPairIterator,
typename _RAIterOut,
typename _DifferenceTp,
typename _Compare>
_RAIterOut
multiway_merge_sentinels(_RAIterPairIterator __seqs_begin,
_RAIterPairIterator __seqs_end,
_RAIterOut __target,
_DifferenceTp __length, _Compare __comp,
__gnu_parallel::sequential_tag)
{
typedef _DifferenceTp _DifferenceType;
_GLIBCXX_CALL(__seqs_end - __seqs_begin)
// catch special case: no sequences
if (__seqs_begin == __seqs_end)
return __target;
// Execute multiway merge *sequentially*.
return __sequential_multiway_merge
</* __stable = */ false, /* __sentinels = */ true>
(__seqs_begin, __seqs_end,
__target, *(__seqs_begin->second), __length, __comp);
}
// public interface
template<typename _RAIterPairIterator,
typename _RAIterOut,
typename _DifferenceTp,
typename _Compare>
_RAIterOut
multiway_merge_sentinels(_RAIterPairIterator __seqs_begin,
_RAIterPairIterator __seqs_end,
_RAIterOut __target,
_DifferenceTp __length, _Compare __comp,
__gnu_parallel::exact_tag __tag)
{
typedef _DifferenceTp _DifferenceType;
_GLIBCXX_CALL(__seqs_end - __seqs_begin)
// catch special case: no sequences
if (__seqs_begin == __seqs_end)
return __target;
// Execute merge; maybe parallel, depending on the number of merged
// elements and the number of sequences and global thresholds in
// Settings.
if ((__seqs_end - __seqs_begin > 1)
&& _GLIBCXX_PARALLEL_CONDITION(
((__seqs_end - __seqs_begin) >=
__gnu_parallel::_Settings::get().multiway_merge_minimal_k)
&& ((_SequenceIndex)__length >=
__gnu_parallel::_Settings::get().multiway_merge_minimal_n)))
return parallel_multiway_merge
</* __stable = */ false, /* __sentinels = */ true>
(__seqs_begin, __seqs_end, __target,
multiway_merge_exact_splitting</* __stable = */ false,
typename std::iterator_traits<_RAIterPairIterator>
::value_type*, _Compare, _DifferenceTp>,
static_cast<_DifferenceType>(__length), __comp,
__tag.__get_num_threads());
else
return __sequential_multiway_merge
</* __stable = */ false, /* __sentinels = */ true>
(__seqs_begin, __seqs_end, __target,
*(__seqs_begin->second), __length, __comp);
}
// public interface
template<typename _RAIterPairIterator,
typename _RAIterOut,
typename _DifferenceTp,
typename _Compare>
_RAIterOut
multiway_merge_sentinels(_RAIterPairIterator __seqs_begin,
_RAIterPairIterator __seqs_end,
_RAIterOut __target,
_DifferenceTp __length, _Compare __comp,
sampling_tag __tag)
{
typedef _DifferenceTp _DifferenceType;
_GLIBCXX_CALL(__seqs_end - __seqs_begin)
// catch special case: no sequences
if (__seqs_begin == __seqs_end)
return __target;
// Execute merge; maybe parallel, depending on the number of merged
// elements and the number of sequences and global thresholds in
// Settings.
if ((__seqs_end - __seqs_begin > 1)
&& _GLIBCXX_PARALLEL_CONDITION(
((__seqs_end - __seqs_begin) >=
__gnu_parallel::_Settings::get().multiway_merge_minimal_k)
&& ((_SequenceIndex)__length >=
__gnu_parallel::_Settings::get().multiway_merge_minimal_n)))
return parallel_multiway_merge
</* __stable = */ false, /* __sentinels = */ true>
(__seqs_begin, __seqs_end, __target,
multiway_merge_sampling_splitting</* __stable = */ false,
typename std::iterator_traits<_RAIterPairIterator>
::value_type*, _Compare, _DifferenceTp>,
static_cast<_DifferenceType>(__length), __comp,
__tag.__get_num_threads());
else
return __sequential_multiway_merge
</* __stable = */false, /* __sentinels = */ true>(
__seqs_begin, __seqs_end, __target,
*(__seqs_begin->second), __length, __comp);
}
// public interface
template<typename _RAIterPairIterator,
typename _RAIterOut,
typename _DifferenceTp,
typename _Compare>
_RAIterOut
multiway_merge_sentinels(_RAIterPairIterator __seqs_begin,
_RAIterPairIterator __seqs_end,
_RAIterOut __target,
_DifferenceTp __length, _Compare __comp,
parallel_tag __tag = parallel_tag(0))
{
return multiway_merge_sentinels
(__seqs_begin, __seqs_end, __target, __length, __comp,
exact_tag(__tag.__get_num_threads()));
}
// public interface
template<typename _RAIterPairIterator,
typename _RAIterOut,
typename _DifferenceTp,
typename _Compare>
_RAIterOut
multiway_merge_sentinels(_RAIterPairIterator __seqs_begin,
_RAIterPairIterator __seqs_end,
_RAIterOut __target,
_DifferenceTp __length, _Compare __comp,
default_parallel_tag __tag)
{
return multiway_merge_sentinels
(__seqs_begin, __seqs_end, __target, __length, __comp,
exact_tag(__tag.__get_num_threads()));
}
// stable_multiway_merge_sentinels
// public interface
template<typename _RAIterPairIterator,
typename _RAIterOut,
typename _DifferenceTp,
typename _Compare>
_RAIterOut
stable_multiway_merge_sentinels(_RAIterPairIterator __seqs_begin,
_RAIterPairIterator __seqs_end,
_RAIterOut __target,
_DifferenceTp __length, _Compare __comp,
__gnu_parallel::sequential_tag)
{
typedef _DifferenceTp _DifferenceType;
_GLIBCXX_CALL(__seqs_end - __seqs_begin)
// catch special case: no sequences
if (__seqs_begin == __seqs_end)
return __target;
// Execute multiway merge *sequentially*.
return __sequential_multiway_merge
</* __stable = */ true, /* __sentinels = */ true>
(__seqs_begin, __seqs_end, __target,
*(__seqs_begin->second), __length, __comp);
}
// public interface
template<typename _RAIterPairIterator,
typename _RAIterOut,
typename _DifferenceTp,
typename _Compare>
_RAIterOut
stable_multiway_merge_sentinels(_RAIterPairIterator __seqs_begin,
_RAIterPairIterator __seqs_end,
_RAIterOut __target,
_DifferenceTp __length, _Compare __comp,
__gnu_parallel::exact_tag __tag)
{
typedef _DifferenceTp _DifferenceType;
_GLIBCXX_CALL(__seqs_end - __seqs_begin)
// catch special case: no sequences
if (__seqs_begin == __seqs_end)
return __target;
// Execute merge; maybe parallel, depending on the number of merged
// elements and the number of sequences and global thresholds in
// Settings.
if ((__seqs_end - __seqs_begin > 1)
&& _GLIBCXX_PARALLEL_CONDITION(
((__seqs_end - __seqs_begin) >=
__gnu_parallel::_Settings::get().multiway_merge_minimal_k)
&& ((_SequenceIndex)__length >=
__gnu_parallel::_Settings::get().multiway_merge_minimal_n)))
return parallel_multiway_merge
</* __stable = */ true, /* __sentinels = */ true>
(__seqs_begin, __seqs_end, __target,
multiway_merge_exact_splitting</* __stable = */ true,
typename std::iterator_traits<_RAIterPairIterator>
::value_type*, _Compare, _DifferenceTp>,
static_cast<_DifferenceType>(__length), __comp,
__tag.__get_num_threads());
else
return __sequential_multiway_merge
</* __stable = */ true, /* __sentinels = */ true>
(__seqs_begin, __seqs_end, __target,
*(__seqs_begin->second), __length, __comp);
}
// public interface
template<typename _RAIterPairIterator,
typename _RAIterOut,
typename _DifferenceTp,
typename _Compare>
_RAIterOut
stable_multiway_merge_sentinels(_RAIterPairIterator __seqs_begin,
_RAIterPairIterator __seqs_end,
_RAIterOut __target,
_DifferenceTp __length,
_Compare __comp,
sampling_tag __tag)
{
typedef _DifferenceTp _DifferenceType;
_GLIBCXX_CALL(__seqs_end - __seqs_begin)
// catch special case: no sequences
if (__seqs_begin == __seqs_end)
return __target;
// Execute merge; maybe parallel, depending on the number of merged
// elements and the number of sequences and global thresholds in
// Settings.
if ((__seqs_end - __seqs_begin > 1)
&& _GLIBCXX_PARALLEL_CONDITION(
((__seqs_end - __seqs_begin) >=
__gnu_parallel::_Settings::get().multiway_merge_minimal_k)
&& ((_SequenceIndex)__length >=
__gnu_parallel::_Settings::get().multiway_merge_minimal_n)))
return parallel_multiway_merge
</* __stable = */ true, /* __sentinels = */ true>
(__seqs_begin, __seqs_end, __target,
multiway_merge_sampling_splitting</* __stable = */ true,
typename std::iterator_traits<_RAIterPairIterator>
::value_type*, _Compare, _DifferenceTp>,
static_cast<_DifferenceType>(__length), __comp,
__tag.__get_num_threads());
else
return __sequential_multiway_merge
</* __stable = */ true, /* __sentinels = */ true>
(__seqs_begin, __seqs_end, __target,
*(__seqs_begin->second), __length, __comp);
}
// public interface
template<typename _RAIterPairIterator,
typename _RAIterOut,
typename _DifferenceTp,
typename _Compare>
_RAIterOut
stable_multiway_merge_sentinels(_RAIterPairIterator __seqs_begin,
_RAIterPairIterator __seqs_end,
_RAIterOut __target,
_DifferenceTp __length,
_Compare __comp,
parallel_tag __tag = parallel_tag(0))
{
return stable_multiway_merge_sentinels
(__seqs_begin, __seqs_end, __target, __length, __comp,
exact_tag(__tag.__get_num_threads()));
}
// public interface
template<typename _RAIterPairIterator,
typename _RAIterOut,
typename _DifferenceTp,
typename _Compare>
_RAIterOut
stable_multiway_merge_sentinels(_RAIterPairIterator __seqs_begin,
_RAIterPairIterator __seqs_end,
_RAIterOut __target,
_DifferenceTp __length, _Compare __comp,
default_parallel_tag __tag)
{
return stable_multiway_merge_sentinels
(__seqs_begin, __seqs_end, __target, __length, __comp,
exact_tag(__tag.__get_num_threads()));
}
}; // namespace __gnu_parallel
#endif /* _GLIBCXX_PARALLEL_MULTIWAY_MERGE_H */
c++/8/parallel/for_each_selectors.h 0000644 00000024505 15201526705 0013072 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/for_each_selectors.h
* @brief Functors representing different tasks to be plugged into the
* generic parallelization methods for embarrassingly parallel functions.
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Felix Putze.
#ifndef _GLIBCXX_PARALLEL_FOR_EACH_SELECTORS_H
#define _GLIBCXX_PARALLEL_FOR_EACH_SELECTORS_H 1
#include <parallel/basic_iterator.h>
namespace __gnu_parallel
{
/** @brief Generic __selector for embarrassingly parallel functions. */
template<typename _It>
struct __generic_for_each_selector
{
/** @brief _Iterator on last element processed; needed for some
* algorithms (e. g. std::transform()).
*/
_It _M_finish_iterator;
};
/** @brief std::for_each() selector. */
template<typename _It>
struct __for_each_selector : public __generic_for_each_selector<_It>
{
/** @brief Functor execution.
* @param __o Operator.
* @param __i iterator referencing object. */
template<typename _Op>
bool
operator()(_Op& __o, _It __i)
{
__o(*__i);
return true;
}
};
/** @brief std::generate() selector. */
template<typename _It>
struct __generate_selector : public __generic_for_each_selector<_It>
{
/** @brief Functor execution.
* @param __o Operator.
* @param __i iterator referencing object. */
template<typename _Op>
bool
operator()(_Op& __o, _It __i)
{
*__i = __o();
return true;
}
};
/** @brief std::fill() selector. */
template<typename _It>
struct __fill_selector : public __generic_for_each_selector<_It>
{
/** @brief Functor execution.
* @param __v Current value.
* @param __i iterator referencing object. */
template<typename _ValueType>
bool
operator()(_ValueType& __v, _It __i)
{
*__i = __v;
return true;
}
};
/** @brief std::transform() __selector, one input sequence variant. */
template<typename _It>
struct __transform1_selector : public __generic_for_each_selector<_It>
{
/** @brief Functor execution.
* @param __o Operator.
* @param __i iterator referencing object. */
template<typename _Op>
bool
operator()(_Op& __o, _It __i)
{
*__i.second = __o(*__i.first);
return true;
}
};
/** @brief std::transform() __selector, two input sequences variant. */
template<typename _It>
struct __transform2_selector : public __generic_for_each_selector<_It>
{
/** @brief Functor execution.
* @param __o Operator.
* @param __i iterator referencing object. */
template<typename _Op>
bool
operator()(_Op& __o, _It __i)
{
*__i._M_third = __o(*__i._M_first, *__i._M_second);
return true;
}
};
/** @brief std::replace() selector. */
template<typename _It, typename _Tp>
struct __replace_selector : public __generic_for_each_selector<_It>
{
/** @brief Value to replace with. */
const _Tp& __new_val;
/** @brief Constructor
* @param __new_val Value to replace with. */
explicit
__replace_selector(const _Tp &__new_val) : __new_val(__new_val) {}
/** @brief Functor execution.
* @param __v Current value.
* @param __i iterator referencing object. */
bool
operator()(_Tp& __v, _It __i)
{
if (*__i == __v)
*__i = __new_val;
return true;
}
};
/** @brief std::replace() selector. */
template<typename _It, typename _Op, typename _Tp>
struct __replace_if_selector : public __generic_for_each_selector<_It>
{
/** @brief Value to replace with. */
const _Tp& __new_val;
/** @brief Constructor.
* @param __new_val Value to replace with. */
explicit
__replace_if_selector(const _Tp &__new_val) : __new_val(__new_val) { }
/** @brief Functor execution.
* @param __o Operator.
* @param __i iterator referencing object. */
bool
operator()(_Op& __o, _It __i)
{
if (__o(*__i))
*__i = __new_val;
return true;
}
};
/** @brief std::count() selector. */
template<typename _It, typename _Diff>
struct __count_selector : public __generic_for_each_selector<_It>
{
/** @brief Functor execution.
* @param __v Current value.
* @param __i iterator referencing object.
* @return 1 if count, 0 if does not count. */
template<typename _ValueType>
_Diff
operator()(_ValueType& __v, _It __i)
{ return (__v == *__i) ? 1 : 0; }
};
/** @brief std::count_if () selector. */
template<typename _It, typename _Diff>
struct __count_if_selector : public __generic_for_each_selector<_It>
{
/** @brief Functor execution.
* @param __o Operator.
* @param __i iterator referencing object.
* @return 1 if count, 0 if does not count. */
template<typename _Op>
_Diff
operator()(_Op& __o, _It __i)
{ return (__o(*__i)) ? 1 : 0; }
};
/** @brief std::accumulate() selector. */
template<typename _It>
struct __accumulate_selector : public __generic_for_each_selector<_It>
{
/** @brief Functor execution.
* @param __o Operator (unused).
* @param __i iterator referencing object.
* @return The current value. */
template<typename _Op>
typename std::iterator_traits<_It>::value_type
operator()(_Op __o, _It __i)
{ return *__i; }
};
/** @brief std::inner_product() selector. */
template<typename _It, typename _It2, typename _Tp>
struct __inner_product_selector : public __generic_for_each_selector<_It>
{
/** @brief Begin iterator of first sequence. */
_It __begin1_iterator;
/** @brief Begin iterator of second sequence. */
_It2 __begin2_iterator;
/** @brief Constructor.
* @param __b1 Begin iterator of first sequence.
* @param __b2 Begin iterator of second sequence. */
explicit
__inner_product_selector(_It __b1, _It2 __b2)
: __begin1_iterator(__b1), __begin2_iterator(__b2) { }
/** @brief Functor execution.
* @param __mult Multiplication functor.
* @param __current iterator referencing object.
* @return Inner product elemental __result. */
template<typename _Op>
_Tp
operator()(_Op __mult, _It __current)
{
typename std::iterator_traits<_It>::difference_type __position
= __current - __begin1_iterator;
return __mult(*__current, *(__begin2_iterator + __position));
}
};
/** @brief Selector that just returns the passed iterator. */
template<typename _It>
struct __identity_selector : public __generic_for_each_selector<_It>
{
/** @brief Functor execution.
* @param __o Operator (unused).
* @param __i iterator referencing object.
* @return Passed iterator. */
template<typename _Op>
_It
operator()(_Op __o, _It __i)
{ return __i; }
};
/** @brief Selector that returns the difference between two adjacent
* __elements.
*/
template<typename _It>
struct __adjacent_difference_selector
: public __generic_for_each_selector<_It>
{
template<typename _Op>
bool
operator()(_Op& __o, _It __i)
{
typename _It::first_type __go_back_one = __i.first;
--__go_back_one;
*__i.second = __o(*__i.first, *__go_back_one);
return true;
}
};
/** @brief Functor doing nothing
*
* For some __reduction tasks (this is not a function object, but is
* passed as __selector __dummy parameter.
*/
struct _Nothing
{
/** @brief Functor execution.
* @param __i iterator referencing object. */
template<typename _It>
void
operator()(_It __i) { }
};
/** @brief Reduction function doing nothing. */
struct _DummyReduct
{
bool
operator()(bool, bool) const
{ return true; }
};
/** @brief Reduction for finding the maximum element, using a comparator. */
template<typename _Compare, typename _It>
struct __min_element_reduct
{
_Compare& __comp;
explicit
__min_element_reduct(_Compare &__c) : __comp(__c) { }
_It
operator()(_It __x, _It __y)
{ return (__comp(*__x, *__y)) ? __x : __y; }
};
/** @brief Reduction for finding the maximum element, using a comparator. */
template<typename _Compare, typename _It>
struct __max_element_reduct
{
_Compare& __comp;
explicit
__max_element_reduct(_Compare& __c) : __comp(__c) { }
_It
operator()(_It __x, _It __y)
{ return (__comp(*__x, *__y)) ? __y : __x; }
};
/** @brief General reduction, using a binary operator. */
template<typename _BinOp>
struct __accumulate_binop_reduct
{
_BinOp& __binop;
explicit
__accumulate_binop_reduct(_BinOp& __b) : __binop(__b) { }
template<typename _Result, typename _Addend>
_Result
operator()(const _Result& __x, const _Addend& __y)
{ return __binop(__x, __y); }
};
}
#endif /* _GLIBCXX_PARALLEL_FOR_EACH_SELECTORS_H */
c++/8/parallel/multiway_mergesort.h 0000644 00000035647 15201526705 0013214 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/multiway_mergesort.h
* @brief Parallel multiway merge sort.
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Johannes Singler.
#ifndef _GLIBCXX_PARALLEL_MULTIWAY_MERGESORT_H
#define _GLIBCXX_PARALLEL_MULTIWAY_MERGESORT_H 1
#include <vector>
#include <parallel/basic_iterator.h>
#include <bits/stl_algo.h>
#include <parallel/parallel.h>
#include <parallel/multiway_merge.h>
namespace __gnu_parallel
{
/** @brief Subsequence description. */
template<typename _DifferenceTp>
struct _Piece
{
typedef _DifferenceTp _DifferenceType;
/** @brief Begin of subsequence. */
_DifferenceType _M_begin;
/** @brief End of subsequence. */
_DifferenceType _M_end;
};
/** @brief Data accessed by all threads.
*
* PMWMS = parallel multiway mergesort */
template<typename _RAIter>
struct _PMWMSSortingData
{
typedef std::iterator_traits<_RAIter> _TraitsType;
typedef typename _TraitsType::value_type _ValueType;
typedef typename _TraitsType::difference_type _DifferenceType;
/** @brief Number of threads involved. */
_ThreadIndex _M_num_threads;
/** @brief Input __begin. */
_RAIter _M_source;
/** @brief Start indices, per thread. */
_DifferenceType* _M_starts;
/** @brief Storage in which to sort. */
_ValueType** _M_temporary;
/** @brief Samples. */
_ValueType* _M_samples;
/** @brief Offsets to add to the found positions. */
_DifferenceType* _M_offsets;
/** @brief Pieces of data to merge @c [thread][__sequence] */
std::vector<_Piece<_DifferenceType> >* _M_pieces;
};
/**
* @brief Select _M_samples from a sequence.
* @param __sd Pointer to algorithm data. _Result will be placed in
* @c __sd->_M_samples.
* @param __num_samples Number of _M_samples to select.
*/
template<typename _RAIter, typename _DifferenceTp>
void
__determine_samples(_PMWMSSortingData<_RAIter>* __sd,
_DifferenceTp __num_samples)
{
typedef std::iterator_traits<_RAIter> _TraitsType;
typedef typename _TraitsType::value_type _ValueType;
typedef _DifferenceTp _DifferenceType;
_ThreadIndex __iam = omp_get_thread_num();
_DifferenceType* __es = new _DifferenceType[__num_samples + 2];
__equally_split(__sd->_M_starts[__iam + 1] - __sd->_M_starts[__iam],
__num_samples + 1, __es);
for (_DifferenceType __i = 0; __i < __num_samples; ++__i)
::new(&(__sd->_M_samples[__iam * __num_samples + __i]))
_ValueType(__sd->_M_source[__sd->_M_starts[__iam]
+ __es[__i + 1]]);
delete[] __es;
}
/** @brief Split consistently. */
template<bool __exact, typename _RAIter,
typename _Compare, typename _SortingPlacesIterator>
struct _SplitConsistently
{ };
/** @brief Split by exact splitting. */
template<typename _RAIter, typename _Compare,
typename _SortingPlacesIterator>
struct _SplitConsistently<true, _RAIter, _Compare, _SortingPlacesIterator>
{
void
operator()(const _ThreadIndex __iam,
_PMWMSSortingData<_RAIter>* __sd,
_Compare& __comp,
const typename
std::iterator_traits<_RAIter>::difference_type
__num_samples) const
{
# pragma omp barrier
std::vector<std::pair<_SortingPlacesIterator,
_SortingPlacesIterator> >
__seqs(__sd->_M_num_threads);
for (_ThreadIndex __s = 0; __s < __sd->_M_num_threads; __s++)
__seqs[__s] = std::make_pair(__sd->_M_temporary[__s],
__sd->_M_temporary[__s]
+ (__sd->_M_starts[__s + 1]
- __sd->_M_starts[__s]));
std::vector<_SortingPlacesIterator> __offsets(__sd->_M_num_threads);
// if not last thread
if (__iam < __sd->_M_num_threads - 1)
multiseq_partition(__seqs.begin(), __seqs.end(),
__sd->_M_starts[__iam + 1], __offsets.begin(),
__comp);
for (_ThreadIndex __seq = 0; __seq < __sd->_M_num_threads; __seq++)
{
// for each sequence
if (__iam < (__sd->_M_num_threads - 1))
__sd->_M_pieces[__iam][__seq]._M_end
= __offsets[__seq] - __seqs[__seq].first;
else
// very end of this sequence
__sd->_M_pieces[__iam][__seq]._M_end =
__sd->_M_starts[__seq + 1] - __sd->_M_starts[__seq];
}
# pragma omp barrier
for (_ThreadIndex __seq = 0; __seq < __sd->_M_num_threads; __seq++)
{
// For each sequence.
if (__iam > 0)
__sd->_M_pieces[__iam][__seq]._M_begin =
__sd->_M_pieces[__iam - 1][__seq]._M_end;
else
// Absolute beginning.
__sd->_M_pieces[__iam][__seq]._M_begin = 0;
}
}
};
/** @brief Split by sampling. */
template<typename _RAIter, typename _Compare,
typename _SortingPlacesIterator>
struct _SplitConsistently<false, _RAIter, _Compare, _SortingPlacesIterator>
{
void
operator()(const _ThreadIndex __iam,
_PMWMSSortingData<_RAIter>* __sd,
_Compare& __comp,
const typename
std::iterator_traits<_RAIter>::difference_type
__num_samples) const
{
typedef std::iterator_traits<_RAIter> _TraitsType;
typedef typename _TraitsType::value_type _ValueType;
typedef typename _TraitsType::difference_type _DifferenceType;
__determine_samples(__sd, __num_samples);
# pragma omp barrier
# pragma omp single
__gnu_sequential::sort(__sd->_M_samples,
__sd->_M_samples
+ (__num_samples * __sd->_M_num_threads),
__comp);
# pragma omp barrier
for (_ThreadIndex __s = 0; __s < __sd->_M_num_threads; ++__s)
{
// For each sequence.
if (__num_samples * __iam > 0)
__sd->_M_pieces[__iam][__s]._M_begin =
std::lower_bound(__sd->_M_temporary[__s],
__sd->_M_temporary[__s]
+ (__sd->_M_starts[__s + 1]
- __sd->_M_starts[__s]),
__sd->_M_samples[__num_samples * __iam],
__comp)
- __sd->_M_temporary[__s];
else
// Absolute beginning.
__sd->_M_pieces[__iam][__s]._M_begin = 0;
if ((__num_samples * (__iam + 1)) <
(__num_samples * __sd->_M_num_threads))
__sd->_M_pieces[__iam][__s]._M_end =
std::lower_bound(__sd->_M_temporary[__s],
__sd->_M_temporary[__s]
+ (__sd->_M_starts[__s + 1]
- __sd->_M_starts[__s]),
__sd->_M_samples[__num_samples * (__iam + 1)],
__comp)
- __sd->_M_temporary[__s];
else
// Absolute end.
__sd->_M_pieces[__iam][__s]._M_end = (__sd->_M_starts[__s + 1]
- __sd->_M_starts[__s]);
}
}
};
template<bool __stable, typename _RAIter, typename _Compare>
struct __possibly_stable_sort
{ };
template<typename _RAIter, typename _Compare>
struct __possibly_stable_sort<true, _RAIter, _Compare>
{
void operator()(const _RAIter& __begin,
const _RAIter& __end, _Compare& __comp) const
{ __gnu_sequential::stable_sort(__begin, __end, __comp); }
};
template<typename _RAIter, typename _Compare>
struct __possibly_stable_sort<false, _RAIter, _Compare>
{
void operator()(const _RAIter __begin,
const _RAIter __end, _Compare& __comp) const
{ __gnu_sequential::sort(__begin, __end, __comp); }
};
template<bool __stable, typename Seq_RAIter,
typename _RAIter, typename _Compare,
typename DiffType>
struct __possibly_stable_multiway_merge
{ };
template<typename Seq_RAIter, typename _RAIter,
typename _Compare, typename _DiffType>
struct __possibly_stable_multiway_merge<true, Seq_RAIter,
_RAIter, _Compare, _DiffType>
{
void operator()(const Seq_RAIter& __seqs_begin,
const Seq_RAIter& __seqs_end,
const _RAIter& __target,
_Compare& __comp,
_DiffType __length_am) const
{ stable_multiway_merge(__seqs_begin, __seqs_end, __target,
__length_am, __comp, sequential_tag()); }
};
template<typename Seq_RAIter, typename _RAIter,
typename _Compare, typename _DiffType>
struct __possibly_stable_multiway_merge<false, Seq_RAIter,
_RAIter, _Compare, _DiffType>
{
void operator()(const Seq_RAIter& __seqs_begin,
const Seq_RAIter& __seqs_end,
const _RAIter& __target,
_Compare& __comp,
_DiffType __length_am) const
{ multiway_merge(__seqs_begin, __seqs_end, __target, __length_am,
__comp, sequential_tag()); }
};
/** @brief PMWMS code executed by each thread.
* @param __sd Pointer to algorithm data.
* @param __comp Comparator.
*/
template<bool __stable, bool __exact, typename _RAIter,
typename _Compare>
void
parallel_sort_mwms_pu(_PMWMSSortingData<_RAIter>* __sd,
_Compare& __comp)
{
typedef std::iterator_traits<_RAIter> _TraitsType;
typedef typename _TraitsType::value_type _ValueType;
typedef typename _TraitsType::difference_type _DifferenceType;
_ThreadIndex __iam = omp_get_thread_num();
// Length of this thread's chunk, before merging.
_DifferenceType __length_local =
__sd->_M_starts[__iam + 1] - __sd->_M_starts[__iam];
// Sort in temporary storage, leave space for sentinel.
typedef _ValueType* _SortingPlacesIterator;
__sd->_M_temporary[__iam] =
static_cast<_ValueType*>(::operator new(sizeof(_ValueType)
* (__length_local + 1)));
// Copy there.
std::uninitialized_copy(__sd->_M_source + __sd->_M_starts[__iam],
__sd->_M_source + __sd->_M_starts[__iam]
+ __length_local,
__sd->_M_temporary[__iam]);
__possibly_stable_sort<__stable, _SortingPlacesIterator, _Compare>()
(__sd->_M_temporary[__iam],
__sd->_M_temporary[__iam] + __length_local,
__comp);
// Invariant: locally sorted subsequence in sd->_M_temporary[__iam],
// __sd->_M_temporary[__iam] + __length_local.
// No barrier here: Synchronization is done by the splitting routine.
_DifferenceType __num_samples =
_Settings::get().sort_mwms_oversampling * __sd->_M_num_threads - 1;
_SplitConsistently<__exact, _RAIter, _Compare, _SortingPlacesIterator>()
(__iam, __sd, __comp, __num_samples);
// Offset from __target __begin, __length after merging.
_DifferenceType __offset = 0, __length_am = 0;
for (_ThreadIndex __s = 0; __s < __sd->_M_num_threads; __s++)
{
__length_am += (__sd->_M_pieces[__iam][__s]._M_end
- __sd->_M_pieces[__iam][__s]._M_begin);
__offset += __sd->_M_pieces[__iam][__s]._M_begin;
}
typedef std::vector<
std::pair<_SortingPlacesIterator, _SortingPlacesIterator> >
_SeqVector;
_SeqVector __seqs(__sd->_M_num_threads);
for (_ThreadIndex __s = 0; __s < __sd->_M_num_threads; ++__s)
{
__seqs[__s] =
std::make_pair(__sd->_M_temporary[__s]
+ __sd->_M_pieces[__iam][__s]._M_begin,
__sd->_M_temporary[__s]
+ __sd->_M_pieces[__iam][__s]._M_end);
}
__possibly_stable_multiway_merge<
__stable, typename _SeqVector::iterator,
_RAIter, _Compare, _DifferenceType>()(__seqs.begin(), __seqs.end(),
__sd->_M_source + __offset, __comp,
__length_am);
# pragma omp barrier
for (_DifferenceType __i = 0; __i < __length_local; ++__i)
__sd->_M_temporary[__iam][__i].~_ValueType();
::operator delete(__sd->_M_temporary[__iam]);
}
/** @brief PMWMS main call.
* @param __begin Begin iterator of sequence.
* @param __end End iterator of sequence.
* @param __comp Comparator.
* @param __num_threads Number of threads to use.
*/
template<bool __stable, bool __exact, typename _RAIter,
typename _Compare>
void
parallel_sort_mwms(_RAIter __begin, _RAIter __end,
_Compare __comp,
_ThreadIndex __num_threads)
{
_GLIBCXX_CALL(__end - __begin)
typedef std::iterator_traits<_RAIter> _TraitsType;
typedef typename _TraitsType::value_type _ValueType;
typedef typename _TraitsType::difference_type _DifferenceType;
_DifferenceType __n = __end - __begin;
if (__n <= 1)
return;
// at least one element per thread
if (__num_threads > __n)
__num_threads = static_cast<_ThreadIndex>(__n);
// shared variables
_PMWMSSortingData<_RAIter> __sd;
_DifferenceType* __starts;
_DifferenceType __size;
# pragma omp parallel num_threads(__num_threads)
{
__num_threads = omp_get_num_threads(); //no more threads than requested
# pragma omp single
{
__sd._M_num_threads = __num_threads;
__sd._M_source = __begin;
__sd._M_temporary = new _ValueType*[__num_threads];
if (!__exact)
{
__size =
(_Settings::get().sort_mwms_oversampling * __num_threads - 1)
* __num_threads;
__sd._M_samples = static_cast<_ValueType*>
(::operator new(__size * sizeof(_ValueType)));
}
else
__sd._M_samples = 0;
__sd._M_offsets = new _DifferenceType[__num_threads - 1];
__sd._M_pieces
= new std::vector<_Piece<_DifferenceType> >[__num_threads];
for (_ThreadIndex __s = 0; __s < __num_threads; ++__s)
__sd._M_pieces[__s].resize(__num_threads);
__starts = __sd._M_starts = new _DifferenceType[__num_threads + 1];
_DifferenceType __chunk_length = __n / __num_threads;
_DifferenceType __split = __n % __num_threads;
_DifferenceType __pos = 0;
for (_ThreadIndex __i = 0; __i < __num_threads; ++__i)
{
__starts[__i] = __pos;
__pos += ((__i < __split)
? (__chunk_length + 1) : __chunk_length);
}
__starts[__num_threads] = __pos;
} //single
// Now sort in parallel.
parallel_sort_mwms_pu<__stable, __exact>(&__sd, __comp);
} //parallel
delete[] __starts;
delete[] __sd._M_temporary;
if (!__exact)
{
for (_DifferenceType __i = 0; __i < __size; ++__i)
__sd._M_samples[__i].~_ValueType();
::operator delete(__sd._M_samples);
}
delete[] __sd._M_offsets;
delete[] __sd._M_pieces;
}
} //namespace __gnu_parallel
#endif /* _GLIBCXX_PARALLEL_MULTIWAY_MERGESORT_H */
c++/8/parallel/types.h 0000644 00000007204 15201526705 0010402 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/types.h
* @brief Basic types and typedefs.
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Johannes Singler and Felix Putze.
#ifndef _GLIBCXX_PARALLEL_TYPES_H
#define _GLIBCXX_PARALLEL_TYPES_H 1
#include <cstdlib>
#include <limits>
#include <tr1/cstdint>
namespace __gnu_parallel
{
// Enumerated types.
/// Run-time equivalents for the compile-time tags.
enum _Parallelism
{
/// Not parallel.
sequential,
/// Parallel unbalanced (equal-sized chunks).
parallel_unbalanced,
/// Parallel balanced (work-stealing).
parallel_balanced,
/// Parallel with OpenMP dynamic load-balancing.
parallel_omp_loop,
/// Parallel with OpenMP static load-balancing.
parallel_omp_loop_static,
/// Parallel with OpenMP taskqueue construct.
parallel_taskqueue
};
/// Strategies for run-time algorithm selection:
// force_sequential, force_parallel, heuristic.
enum _AlgorithmStrategy
{
heuristic,
force_sequential,
force_parallel
};
/// Sorting algorithms:
// multi-way mergesort, quicksort, load-balanced quicksort.
enum _SortAlgorithm
{
MWMS,
QS,
QS_BALANCED
};
/// Merging algorithms:
// bubblesort-alike, loser-tree variants, enum __sentinel.
enum _MultiwayMergeAlgorithm
{
LOSER_TREE
};
/// Partial sum algorithms: recursive, linear.
enum _PartialSumAlgorithm
{
RECURSIVE,
LINEAR
};
/// Sorting/merging algorithms: sampling, __exact.
enum _SplittingAlgorithm
{
SAMPLING,
EXACT
};
/// Find algorithms:
// growing blocks, equal-sized blocks, equal splitting.
enum _FindAlgorithm
{
GROWING_BLOCKS,
CONSTANT_SIZE_BLOCKS,
EQUAL_SPLIT
};
/**
* @brief Unsigned integer to index __elements.
* The total number of elements for each algorithm must fit into this type.
*/
typedef uint64_t _SequenceIndex;
/**
* @brief Unsigned integer to index a thread number.
* The maximum thread number (for each processor) must fit into this type.
*/
typedef uint16_t _ThreadIndex;
// XXX atomics interface?
/// Longest compare-and-swappable integer type on this platform.
typedef int64_t _CASable;
/// Number of bits of _CASable.
static const int _CASable_bits = std::numeric_limits<_CASable>::digits;
/// ::_CASable with the right half of bits set to 1.
static const _CASable _CASable_mask =
((_CASable(1) << (_CASable_bits / 2)) - 1);
}
#endif /* _GLIBCXX_PARALLEL_TYPES_H */
c++/8/parallel/algo.h 0000644 00000234236 15201526705 0010167 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/algo.h
* @brief Parallel STL function calls corresponding to the stl_algo.h header.
*
* The functions defined here mainly do case switches and
* call the actual parallelized versions in other files.
* Inlining policy: Functions that basically only contain one function call,
* are declared inline.
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Johannes Singler and Felix Putze.
#ifndef _GLIBCXX_PARALLEL_ALGO_H
#define _GLIBCXX_PARALLEL_ALGO_H 1
#include <parallel/algorithmfwd.h>
#include <bits/stl_algobase.h>
#include <bits/stl_algo.h>
#include <parallel/iterator.h>
#include <parallel/base.h>
#include <parallel/sort.h>
#include <parallel/workstealing.h>
#include <parallel/par_loop.h>
#include <parallel/omp_loop.h>
#include <parallel/omp_loop_static.h>
#include <parallel/for_each_selectors.h>
#include <parallel/for_each.h>
#include <parallel/find.h>
#include <parallel/find_selectors.h>
#include <parallel/search.h>
#include <parallel/random_shuffle.h>
#include <parallel/partition.h>
#include <parallel/merge.h>
#include <parallel/unique_copy.h>
#include <parallel/set_operations.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __parallel
{
// Sequential fallback
template<typename _IIter, typename _Function>
inline _Function
for_each(_IIter __begin, _IIter __end, _Function __f,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::for_each(__begin, __end, __f); }
// Sequential fallback for input iterator case
template<typename _IIter, typename _Function, typename _IteratorTag>
inline _Function
__for_each_switch(_IIter __begin, _IIter __end, _Function __f,
_IteratorTag)
{ return for_each(__begin, __end, __f, __gnu_parallel::sequential_tag()); }
// Parallel algorithm for random access iterators
template<typename _RAIter, typename _Function>
_Function
__for_each_switch(_RAIter __begin, _RAIter __end,
_Function __f, random_access_iterator_tag,
__gnu_parallel::_Parallelism __parallelism_tag)
{
if (_GLIBCXX_PARALLEL_CONDITION(
static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin)
>= __gnu_parallel::_Settings::get().for_each_minimal_n
&& __gnu_parallel::__is_parallel(__parallelism_tag)))
{
bool __dummy;
__gnu_parallel::__for_each_selector<_RAIter> __functionality;
return __gnu_parallel::
__for_each_template_random_access(
__begin, __end, __f, __functionality,
__gnu_parallel::_DummyReduct(), true, __dummy, -1,
__parallelism_tag);
}
else
return for_each(__begin, __end, __f, __gnu_parallel::sequential_tag());
}
// Public interface
template<typename _Iterator, typename _Function>
inline _Function
for_each(_Iterator __begin, _Iterator __end, _Function __f,
__gnu_parallel::_Parallelism __parallelism_tag)
{
return __for_each_switch(__begin, __end, __f,
std::__iterator_category(__begin),
__parallelism_tag);
}
template<typename _Iterator, typename _Function>
inline _Function
for_each(_Iterator __begin, _Iterator __end, _Function __f)
{
return __for_each_switch(__begin, __end, __f,
std::__iterator_category(__begin));
}
// Sequential fallback
template<typename _IIter, typename _Tp>
inline _IIter
find(_IIter __begin, _IIter __end, const _Tp& __val,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::find(__begin, __end, __val); }
// Sequential fallback for input iterator case
template<typename _IIter, typename _Tp, typename _IteratorTag>
inline _IIter
__find_switch(_IIter __begin, _IIter __end, const _Tp& __val,
_IteratorTag)
{ return _GLIBCXX_STD_A::find(__begin, __end, __val); }
// Parallel find for random access iterators
template<typename _RAIter, typename _Tp>
_RAIter
__find_switch(_RAIter __begin, _RAIter __end,
const _Tp& __val, random_access_iterator_tag)
{
typedef iterator_traits<_RAIter> _TraitsType;
typedef typename _TraitsType::value_type _ValueType;
if (_GLIBCXX_PARALLEL_CONDITION(true))
{
__gnu_parallel::__binder2nd<__gnu_parallel::_EqualTo<_ValueType,
const _Tp&>,
_ValueType, const _Tp&, bool>
__comp(__gnu_parallel::_EqualTo<_ValueType, const _Tp&>(), __val);
return __gnu_parallel::__find_template(
__begin, __end, __begin, __comp,
__gnu_parallel::__find_if_selector()).first;
}
else
return _GLIBCXX_STD_A::find(__begin, __end, __val);
}
// Public interface
template<typename _IIter, typename _Tp>
inline _IIter
find(_IIter __begin, _IIter __end, const _Tp& __val)
{
return __find_switch(__begin, __end, __val,
std::__iterator_category(__begin));
}
// Sequential fallback
template<typename _IIter, typename _Predicate>
inline _IIter
find_if(_IIter __begin, _IIter __end, _Predicate __pred,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::find_if(__begin, __end, __pred); }
// Sequential fallback for input iterator case
template<typename _IIter, typename _Predicate, typename _IteratorTag>
inline _IIter
__find_if_switch(_IIter __begin, _IIter __end, _Predicate __pred,
_IteratorTag)
{ return _GLIBCXX_STD_A::find_if(__begin, __end, __pred); }
// Parallel find_if for random access iterators
template<typename _RAIter, typename _Predicate>
_RAIter
__find_if_switch(_RAIter __begin, _RAIter __end,
_Predicate __pred, random_access_iterator_tag)
{
if (_GLIBCXX_PARALLEL_CONDITION(true))
return __gnu_parallel::__find_template(__begin, __end, __begin, __pred,
__gnu_parallel::
__find_if_selector()).first;
else
return _GLIBCXX_STD_A::find_if(__begin, __end, __pred);
}
// Public interface
template<typename _IIter, typename _Predicate>
inline _IIter
find_if(_IIter __begin, _IIter __end, _Predicate __pred)
{
return __find_if_switch(__begin, __end, __pred,
std::__iterator_category(__begin));
}
// Sequential fallback
template<typename _IIter, typename _FIterator>
inline _IIter
find_first_of(_IIter __begin1, _IIter __end1,
_FIterator __begin2, _FIterator __end2,
__gnu_parallel::sequential_tag)
{
return _GLIBCXX_STD_A::find_first_of(__begin1, __end1, __begin2, __end2);
}
// Sequential fallback
template<typename _IIter, typename _FIterator,
typename _BinaryPredicate>
inline _IIter
find_first_of(_IIter __begin1, _IIter __end1,
_FIterator __begin2, _FIterator __end2,
_BinaryPredicate __comp, __gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::find_first_of(
__begin1, __end1, __begin2, __end2, __comp); }
// Sequential fallback for input iterator type
template<typename _IIter, typename _FIterator,
typename _IteratorTag1, typename _IteratorTag2>
inline _IIter
__find_first_of_switch(_IIter __begin1, _IIter __end1,
_FIterator __begin2, _FIterator __end2,
_IteratorTag1, _IteratorTag2)
{ return find_first_of(__begin1, __end1, __begin2, __end2,
__gnu_parallel::sequential_tag()); }
// Parallel algorithm for random access iterators
template<typename _RAIter, typename _FIterator,
typename _BinaryPredicate, typename _IteratorTag>
inline _RAIter
__find_first_of_switch(_RAIter __begin1,
_RAIter __end1,
_FIterator __begin2, _FIterator __end2,
_BinaryPredicate __comp, random_access_iterator_tag,
_IteratorTag)
{
return __gnu_parallel::
__find_template(__begin1, __end1, __begin1, __comp,
__gnu_parallel::__find_first_of_selector
<_FIterator>(__begin2, __end2)).first;
}
// Sequential fallback for input iterator type
template<typename _IIter, typename _FIterator,
typename _BinaryPredicate, typename _IteratorTag1,
typename _IteratorTag2>
inline _IIter
__find_first_of_switch(_IIter __begin1, _IIter __end1,
_FIterator __begin2, _FIterator __end2,
_BinaryPredicate __comp, _IteratorTag1, _IteratorTag2)
{ return find_first_of(__begin1, __end1, __begin2, __end2, __comp,
__gnu_parallel::sequential_tag()); }
// Public interface
template<typename _IIter, typename _FIterator,
typename _BinaryPredicate>
inline _IIter
find_first_of(_IIter __begin1, _IIter __end1,
_FIterator __begin2, _FIterator __end2,
_BinaryPredicate __comp)
{
return __find_first_of_switch(__begin1, __end1, __begin2, __end2, __comp,
std::__iterator_category(__begin1),
std::__iterator_category(__begin2));
}
// Public interface, insert default comparator
template<typename _IIter, typename _FIterator>
inline _IIter
find_first_of(_IIter __begin1, _IIter __end1,
_FIterator __begin2, _FIterator __end2)
{
typedef typename std::iterator_traits<_IIter>::value_type _IValueType;
typedef typename std::iterator_traits<_FIterator>::value_type _FValueType;
return __gnu_parallel::find_first_of(__begin1, __end1, __begin2, __end2,
__gnu_parallel::_EqualTo<_IValueType, _FValueType>());
}
// Sequential fallback
template<typename _IIter, typename _OutputIterator>
inline _OutputIterator
unique_copy(_IIter __begin1, _IIter __end1, _OutputIterator __out,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::unique_copy(__begin1, __end1, __out); }
// Sequential fallback
template<typename _IIter, typename _OutputIterator,
typename _Predicate>
inline _OutputIterator
unique_copy(_IIter __begin1, _IIter __end1, _OutputIterator __out,
_Predicate __pred, __gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::unique_copy(__begin1, __end1, __out, __pred); }
// Sequential fallback for input iterator case
template<typename _IIter, typename _OutputIterator,
typename _Predicate, typename _IteratorTag1, typename _IteratorTag2>
inline _OutputIterator
__unique_copy_switch(_IIter __begin, _IIter __last,
_OutputIterator __out, _Predicate __pred,
_IteratorTag1, _IteratorTag2)
{ return _GLIBCXX_STD_A::unique_copy(__begin, __last, __out, __pred); }
// Parallel unique_copy for random access iterators
template<typename _RAIter, typename RandomAccessOutputIterator,
typename _Predicate>
RandomAccessOutputIterator
__unique_copy_switch(_RAIter __begin, _RAIter __last,
RandomAccessOutputIterator __out, _Predicate __pred,
random_access_iterator_tag, random_access_iterator_tag)
{
if (_GLIBCXX_PARALLEL_CONDITION(
static_cast<__gnu_parallel::_SequenceIndex>(__last - __begin)
> __gnu_parallel::_Settings::get().unique_copy_minimal_n))
return __gnu_parallel::__parallel_unique_copy(
__begin, __last, __out, __pred);
else
return _GLIBCXX_STD_A::unique_copy(__begin, __last, __out, __pred);
}
// Public interface
template<typename _IIter, typename _OutputIterator>
inline _OutputIterator
unique_copy(_IIter __begin1, _IIter __end1, _OutputIterator __out)
{
typedef typename std::iterator_traits<_IIter>::value_type _ValueType;
return __unique_copy_switch(
__begin1, __end1, __out, equal_to<_ValueType>(),
std::__iterator_category(__begin1),
std::__iterator_category(__out));
}
// Public interface
template<typename _IIter, typename _OutputIterator, typename _Predicate>
inline _OutputIterator
unique_copy(_IIter __begin1, _IIter __end1, _OutputIterator __out,
_Predicate __pred)
{
return __unique_copy_switch(
__begin1, __end1, __out, __pred,
std::__iterator_category(__begin1),
std::__iterator_category(__out));
}
// Sequential fallback
template<typename _IIter1, typename _IIter2,
typename _OutputIterator>
inline _OutputIterator
set_union(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _IIter2 __end2,
_OutputIterator __out, __gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::set_union(
__begin1, __end1, __begin2, __end2, __out); }
// Sequential fallback
template<typename _IIter1, typename _IIter2,
typename _OutputIterator, typename _Predicate>
inline _OutputIterator
set_union(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _IIter2 __end2,
_OutputIterator __out, _Predicate __pred,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::set_union(__begin1, __end1,
__begin2, __end2, __out, __pred); }
// Sequential fallback for input iterator case
template<typename _IIter1, typename _IIter2, typename _Predicate,
typename _OutputIterator, typename _IteratorTag1,
typename _IteratorTag2, typename _IteratorTag3>
inline _OutputIterator
__set_union_switch(
_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2,
_OutputIterator __result, _Predicate __pred,
_IteratorTag1, _IteratorTag2, _IteratorTag3)
{ return _GLIBCXX_STD_A::set_union(__begin1, __end1,
__begin2, __end2, __result, __pred); }
// Parallel set_union for random access iterators
template<typename _RAIter1, typename _RAIter2,
typename _Output_RAIter, typename _Predicate>
_Output_RAIter
__set_union_switch(_RAIter1 __begin1, _RAIter1 __end1,
_RAIter2 __begin2, _RAIter2 __end2,
_Output_RAIter __result, _Predicate __pred,
random_access_iterator_tag, random_access_iterator_tag,
random_access_iterator_tag)
{
if (_GLIBCXX_PARALLEL_CONDITION(
static_cast<__gnu_parallel::_SequenceIndex>(__end1 - __begin1)
>= __gnu_parallel::_Settings::get().set_union_minimal_n
|| static_cast<__gnu_parallel::_SequenceIndex>(__end2 - __begin2)
>= __gnu_parallel::_Settings::get().set_union_minimal_n))
return __gnu_parallel::__parallel_set_union(
__begin1, __end1, __begin2, __end2, __result, __pred);
else
return _GLIBCXX_STD_A::set_union(__begin1, __end1,
__begin2, __end2, __result, __pred);
}
// Public interface
template<typename _IIter1, typename _IIter2,
typename _OutputIterator>
inline _OutputIterator
set_union(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _IIter2 __end2, _OutputIterator __out)
{
typedef typename std::iterator_traits<_IIter1>::value_type _ValueType1;
typedef typename std::iterator_traits<_IIter2>::value_type _ValueType2;
return __set_union_switch(
__begin1, __end1, __begin2, __end2, __out,
__gnu_parallel::_Less<_ValueType1, _ValueType2>(),
std::__iterator_category(__begin1),
std::__iterator_category(__begin2),
std::__iterator_category(__out));
}
// Public interface
template<typename _IIter1, typename _IIter2,
typename _OutputIterator, typename _Predicate>
inline _OutputIterator
set_union(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _IIter2 __end2,
_OutputIterator __out, _Predicate __pred)
{
return __set_union_switch(
__begin1, __end1, __begin2, __end2, __out, __pred,
std::__iterator_category(__begin1),
std::__iterator_category(__begin2),
std::__iterator_category(__out));
}
// Sequential fallback.
template<typename _IIter1, typename _IIter2,
typename _OutputIterator>
inline _OutputIterator
set_intersection(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _IIter2 __end2,
_OutputIterator __out, __gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::set_intersection(__begin1, __end1,
__begin2, __end2, __out); }
// Sequential fallback.
template<typename _IIter1, typename _IIter2,
typename _OutputIterator, typename _Predicate>
inline _OutputIterator
set_intersection(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _IIter2 __end2,
_OutputIterator __out, _Predicate __pred,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::set_intersection(
__begin1, __end1, __begin2, __end2, __out, __pred); }
// Sequential fallback for input iterator case
template<typename _IIter1, typename _IIter2,
typename _Predicate, typename _OutputIterator,
typename _IteratorTag1, typename _IteratorTag2,
typename _IteratorTag3>
inline _OutputIterator
__set_intersection_switch(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _IIter2 __end2,
_OutputIterator __result, _Predicate __pred,
_IteratorTag1, _IteratorTag2, _IteratorTag3)
{ return _GLIBCXX_STD_A::set_intersection(__begin1, __end1, __begin2,
__end2, __result, __pred); }
// Parallel set_intersection for random access iterators
template<typename _RAIter1, typename _RAIter2,
typename _Output_RAIter, typename _Predicate>
_Output_RAIter
__set_intersection_switch(_RAIter1 __begin1,
_RAIter1 __end1,
_RAIter2 __begin2,
_RAIter2 __end2,
_Output_RAIter __result,
_Predicate __pred,
random_access_iterator_tag,
random_access_iterator_tag,
random_access_iterator_tag)
{
if (_GLIBCXX_PARALLEL_CONDITION(
static_cast<__gnu_parallel::_SequenceIndex>(__end1 - __begin1)
>= __gnu_parallel::_Settings::get().set_union_minimal_n
|| static_cast<__gnu_parallel::_SequenceIndex>(__end2 - __begin2)
>= __gnu_parallel::_Settings::get().set_union_minimal_n))
return __gnu_parallel::__parallel_set_intersection(
__begin1, __end1, __begin2, __end2, __result, __pred);
else
return _GLIBCXX_STD_A::set_intersection(
__begin1, __end1, __begin2, __end2, __result, __pred);
}
// Public interface
template<typename _IIter1, typename _IIter2,
typename _OutputIterator>
inline _OutputIterator
set_intersection(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _IIter2 __end2,
_OutputIterator __out)
{
typedef typename std::iterator_traits<_IIter1>::value_type _ValueType1;
typedef typename std::iterator_traits<_IIter2>::value_type _ValueType2;
return __set_intersection_switch(
__begin1, __end1, __begin2, __end2, __out,
__gnu_parallel::_Less<_ValueType1, _ValueType2>(),
std::__iterator_category(__begin1),
std::__iterator_category(__begin2),
std::__iterator_category(__out));
}
template<typename _IIter1, typename _IIter2,
typename _OutputIterator, typename _Predicate>
inline _OutputIterator
set_intersection(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _IIter2 __end2,
_OutputIterator __out, _Predicate __pred)
{
return __set_intersection_switch(
__begin1, __end1, __begin2, __end2, __out, __pred,
std::__iterator_category(__begin1),
std::__iterator_category(__begin2),
std::__iterator_category(__out));
}
// Sequential fallback
template<typename _IIter1, typename _IIter2,
typename _OutputIterator>
inline _OutputIterator
set_symmetric_difference(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _IIter2 __end2,
_OutputIterator __out,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::set_symmetric_difference(
__begin1, __end1, __begin2, __end2, __out); }
// Sequential fallback
template<typename _IIter1, typename _IIter2,
typename _OutputIterator, typename _Predicate>
inline _OutputIterator
set_symmetric_difference(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _IIter2 __end2,
_OutputIterator __out, _Predicate __pred,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::set_symmetric_difference(
__begin1, __end1, __begin2, __end2, __out, __pred); }
// Sequential fallback for input iterator case
template<typename _IIter1, typename _IIter2,
typename _Predicate, typename _OutputIterator,
typename _IteratorTag1, typename _IteratorTag2,
typename _IteratorTag3>
inline _OutputIterator
__set_symmetric_difference_switch(
_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2,
_OutputIterator __result, _Predicate __pred,
_IteratorTag1, _IteratorTag2, _IteratorTag3)
{ return _GLIBCXX_STD_A::set_symmetric_difference(
__begin1, __end1, __begin2, __end2, __result, __pred); }
// Parallel set_symmetric_difference for random access iterators
template<typename _RAIter1, typename _RAIter2,
typename _Output_RAIter, typename _Predicate>
_Output_RAIter
__set_symmetric_difference_switch(_RAIter1 __begin1,
_RAIter1 __end1,
_RAIter2 __begin2,
_RAIter2 __end2,
_Output_RAIter __result,
_Predicate __pred,
random_access_iterator_tag,
random_access_iterator_tag,
random_access_iterator_tag)
{
if (_GLIBCXX_PARALLEL_CONDITION(
static_cast<__gnu_parallel::_SequenceIndex>(__end1 - __begin1)
>= __gnu_parallel::_Settings::get().set_symmetric_difference_minimal_n
|| static_cast<__gnu_parallel::_SequenceIndex>(__end2 - __begin2)
>= __gnu_parallel::_Settings::get().set_symmetric_difference_minimal_n))
return __gnu_parallel::__parallel_set_symmetric_difference(
__begin1, __end1, __begin2, __end2, __result, __pred);
else
return _GLIBCXX_STD_A::set_symmetric_difference(
__begin1, __end1, __begin2, __end2, __result, __pred);
}
// Public interface.
template<typename _IIter1, typename _IIter2,
typename _OutputIterator>
inline _OutputIterator
set_symmetric_difference(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _IIter2 __end2,
_OutputIterator __out)
{
typedef typename std::iterator_traits<_IIter1>::value_type _ValueType1;
typedef typename std::iterator_traits<_IIter2>::value_type _ValueType2;
return __set_symmetric_difference_switch(
__begin1, __end1, __begin2, __end2, __out,
__gnu_parallel::_Less<_ValueType1, _ValueType2>(),
std::__iterator_category(__begin1),
std::__iterator_category(__begin2),
std::__iterator_category(__out));
}
// Public interface.
template<typename _IIter1, typename _IIter2,
typename _OutputIterator, typename _Predicate>
inline _OutputIterator
set_symmetric_difference(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _IIter2 __end2,
_OutputIterator __out, _Predicate __pred)
{
return __set_symmetric_difference_switch(
__begin1, __end1, __begin2, __end2, __out, __pred,
std::__iterator_category(__begin1),
std::__iterator_category(__begin2),
std::__iterator_category(__out));
}
// Sequential fallback.
template<typename _IIter1, typename _IIter2,
typename _OutputIterator>
inline _OutputIterator
set_difference(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _IIter2 __end2,
_OutputIterator __out, __gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::set_difference(
__begin1,__end1, __begin2, __end2, __out); }
// Sequential fallback.
template<typename _IIter1, typename _IIter2,
typename _OutputIterator, typename _Predicate>
inline _OutputIterator
set_difference(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _IIter2 __end2,
_OutputIterator __out, _Predicate __pred,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::set_difference(__begin1, __end1,
__begin2, __end2, __out, __pred); }
// Sequential fallback for input iterator case.
template<typename _IIter1, typename _IIter2, typename _Predicate,
typename _OutputIterator, typename _IteratorTag1,
typename _IteratorTag2, typename _IteratorTag3>
inline _OutputIterator
__set_difference_switch(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _IIter2 __end2,
_OutputIterator __result, _Predicate __pred,
_IteratorTag1, _IteratorTag2, _IteratorTag3)
{ return _GLIBCXX_STD_A::set_difference(
__begin1, __end1, __begin2, __end2, __result, __pred); }
// Parallel set_difference for random access iterators
template<typename _RAIter1, typename _RAIter2,
typename _Output_RAIter, typename _Predicate>
_Output_RAIter
__set_difference_switch(_RAIter1 __begin1,
_RAIter1 __end1,
_RAIter2 __begin2,
_RAIter2 __end2,
_Output_RAIter __result, _Predicate __pred,
random_access_iterator_tag,
random_access_iterator_tag,
random_access_iterator_tag)
{
if (_GLIBCXX_PARALLEL_CONDITION(
static_cast<__gnu_parallel::_SequenceIndex>(__end1 - __begin1)
>= __gnu_parallel::_Settings::get().set_difference_minimal_n
|| static_cast<__gnu_parallel::_SequenceIndex>(__end2 - __begin2)
>= __gnu_parallel::_Settings::get().set_difference_minimal_n))
return __gnu_parallel::__parallel_set_difference(
__begin1, __end1, __begin2, __end2, __result, __pred);
else
return _GLIBCXX_STD_A::set_difference(
__begin1, __end1, __begin2, __end2, __result, __pred);
}
// Public interface
template<typename _IIter1, typename _IIter2,
typename _OutputIterator>
inline _OutputIterator
set_difference(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _IIter2 __end2,
_OutputIterator __out)
{
typedef typename std::iterator_traits<_IIter1>::value_type _ValueType1;
typedef typename std::iterator_traits<_IIter2>::value_type _ValueType2;
return __set_difference_switch(
__begin1, __end1, __begin2, __end2, __out,
__gnu_parallel::_Less<_ValueType1, _ValueType2>(),
std::__iterator_category(__begin1),
std::__iterator_category(__begin2),
std::__iterator_category(__out));
}
// Public interface
template<typename _IIter1, typename _IIter2,
typename _OutputIterator, typename _Predicate>
inline _OutputIterator
set_difference(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _IIter2 __end2,
_OutputIterator __out, _Predicate __pred)
{
return __set_difference_switch(
__begin1, __end1, __begin2, __end2, __out, __pred,
std::__iterator_category(__begin1),
std::__iterator_category(__begin2),
std::__iterator_category(__out));
}
// Sequential fallback
template<typename _FIterator>
inline _FIterator
adjacent_find(_FIterator __begin, _FIterator __end,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::adjacent_find(__begin, __end); }
// Sequential fallback
template<typename _FIterator, typename _BinaryPredicate>
inline _FIterator
adjacent_find(_FIterator __begin, _FIterator __end,
_BinaryPredicate __binary_pred,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::adjacent_find(__begin, __end, __binary_pred); }
// Parallel algorithm for random access iterators
template<typename _RAIter>
_RAIter
__adjacent_find_switch(_RAIter __begin, _RAIter __end,
random_access_iterator_tag)
{
typedef iterator_traits<_RAIter> _TraitsType;
typedef typename _TraitsType::value_type _ValueType;
if (_GLIBCXX_PARALLEL_CONDITION(true))
{
_RAIter __spot = __gnu_parallel::
__find_template(
__begin, __end - 1, __begin, equal_to<_ValueType>(),
__gnu_parallel::__adjacent_find_selector())
.first;
if (__spot == (__end - 1))
return __end;
else
return __spot;
}
else
return adjacent_find(__begin, __end, __gnu_parallel::sequential_tag());
}
// Sequential fallback for input iterator case
template<typename _FIterator, typename _IteratorTag>
inline _FIterator
__adjacent_find_switch(_FIterator __begin, _FIterator __end,
_IteratorTag)
{ return adjacent_find(__begin, __end, __gnu_parallel::sequential_tag()); }
// Public interface
template<typename _FIterator>
inline _FIterator
adjacent_find(_FIterator __begin, _FIterator __end)
{
return __adjacent_find_switch(__begin, __end,
std::__iterator_category(__begin));
}
// Sequential fallback for input iterator case
template<typename _FIterator, typename _BinaryPredicate,
typename _IteratorTag>
inline _FIterator
__adjacent_find_switch(_FIterator __begin, _FIterator __end,
_BinaryPredicate __pred, _IteratorTag)
{ return adjacent_find(__begin, __end, __pred,
__gnu_parallel::sequential_tag()); }
// Parallel algorithm for random access iterators
template<typename _RAIter, typename _BinaryPredicate>
_RAIter
__adjacent_find_switch(_RAIter __begin, _RAIter __end,
_BinaryPredicate __pred, random_access_iterator_tag)
{
if (_GLIBCXX_PARALLEL_CONDITION(true))
return __gnu_parallel::__find_template(__begin, __end, __begin, __pred,
__gnu_parallel::
__adjacent_find_selector()).first;
else
return adjacent_find(__begin, __end, __pred,
__gnu_parallel::sequential_tag());
}
// Public interface
template<typename _FIterator, typename _BinaryPredicate>
inline _FIterator
adjacent_find(_FIterator __begin, _FIterator __end,
_BinaryPredicate __pred)
{
return __adjacent_find_switch(__begin, __end, __pred,
std::__iterator_category(__begin));
}
// Sequential fallback
template<typename _IIter, typename _Tp>
inline typename iterator_traits<_IIter>::difference_type
count(_IIter __begin, _IIter __end, const _Tp& __value,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::count(__begin, __end, __value); }
// Parallel code for random access iterators
template<typename _RAIter, typename _Tp>
typename iterator_traits<_RAIter>::difference_type
__count_switch(_RAIter __begin, _RAIter __end,
const _Tp& __value, random_access_iterator_tag,
__gnu_parallel::_Parallelism __parallelism_tag)
{
typedef iterator_traits<_RAIter> _TraitsType;
typedef typename _TraitsType::value_type _ValueType;
typedef typename _TraitsType::difference_type _DifferenceType;
typedef __gnu_parallel::_SequenceIndex _SequenceIndex;
if (_GLIBCXX_PARALLEL_CONDITION(
static_cast<_SequenceIndex>(__end - __begin)
>= __gnu_parallel::_Settings::get().count_minimal_n
&& __gnu_parallel::__is_parallel(__parallelism_tag)))
{
__gnu_parallel::__count_selector<_RAIter, _DifferenceType>
__functionality;
_DifferenceType __res = 0;
__gnu_parallel::
__for_each_template_random_access(
__begin, __end, __value, __functionality,
std::plus<_SequenceIndex>(), __res, __res, -1,
__parallelism_tag);
return __res;
}
else
return count(__begin, __end, __value,
__gnu_parallel::sequential_tag());
}
// Sequential fallback for input iterator case.
template<typename _IIter, typename _Tp, typename _IteratorTag>
inline typename iterator_traits<_IIter>::difference_type
__count_switch(_IIter __begin, _IIter __end, const _Tp& __value,
_IteratorTag)
{ return count(__begin, __end, __value, __gnu_parallel::sequential_tag());
}
// Public interface.
template<typename _IIter, typename _Tp>
inline typename iterator_traits<_IIter>::difference_type
count(_IIter __begin, _IIter __end, const _Tp& __value,
__gnu_parallel::_Parallelism __parallelism_tag)
{
return __count_switch(__begin, __end, __value,
std::__iterator_category(__begin),
__parallelism_tag);
}
template<typename _IIter, typename _Tp>
inline typename iterator_traits<_IIter>::difference_type
count(_IIter __begin, _IIter __end, const _Tp& __value)
{
return __count_switch(__begin, __end, __value,
std::__iterator_category(__begin));
}
// Sequential fallback.
template<typename _IIter, typename _Predicate>
inline typename iterator_traits<_IIter>::difference_type
count_if(_IIter __begin, _IIter __end, _Predicate __pred,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::count_if(__begin, __end, __pred); }
// Parallel count_if for random access iterators
template<typename _RAIter, typename _Predicate>
typename iterator_traits<_RAIter>::difference_type
__count_if_switch(_RAIter __begin, _RAIter __end,
_Predicate __pred, random_access_iterator_tag,
__gnu_parallel::_Parallelism __parallelism_tag)
{
typedef iterator_traits<_RAIter> _TraitsType;
typedef typename _TraitsType::value_type _ValueType;
typedef typename _TraitsType::difference_type _DifferenceType;
typedef __gnu_parallel::_SequenceIndex _SequenceIndex;
if (_GLIBCXX_PARALLEL_CONDITION(
static_cast<_SequenceIndex>(__end - __begin)
>= __gnu_parallel::_Settings::get().count_minimal_n
&& __gnu_parallel::__is_parallel(__parallelism_tag)))
{
_DifferenceType __res = 0;
__gnu_parallel::
__count_if_selector<_RAIter, _DifferenceType>
__functionality;
__gnu_parallel::
__for_each_template_random_access(
__begin, __end, __pred, __functionality,
std::plus<_SequenceIndex>(), __res, __res, -1,
__parallelism_tag);
return __res;
}
else
return count_if(__begin, __end, __pred,
__gnu_parallel::sequential_tag());
}
// Sequential fallback for input iterator case.
template<typename _IIter, typename _Predicate, typename _IteratorTag>
inline typename iterator_traits<_IIter>::difference_type
__count_if_switch(_IIter __begin, _IIter __end, _Predicate __pred,
_IteratorTag)
{ return count_if(__begin, __end, __pred,
__gnu_parallel::sequential_tag()); }
// Public interface.
template<typename _IIter, typename _Predicate>
inline typename iterator_traits<_IIter>::difference_type
count_if(_IIter __begin, _IIter __end, _Predicate __pred,
__gnu_parallel::_Parallelism __parallelism_tag)
{
return __count_if_switch(__begin, __end, __pred,
std::__iterator_category(__begin),
__parallelism_tag);
}
template<typename _IIter, typename _Predicate>
inline typename iterator_traits<_IIter>::difference_type
count_if(_IIter __begin, _IIter __end, _Predicate __pred)
{
return __count_if_switch(__begin, __end, __pred,
std::__iterator_category(__begin));
}
// Sequential fallback.
template<typename _FIterator1, typename _FIterator2>
inline _FIterator1
search(_FIterator1 __begin1, _FIterator1 __end1,
_FIterator2 __begin2, _FIterator2 __end2,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::search(__begin1, __end1, __begin2, __end2); }
// Parallel algorithm for random access iterator
template<typename _RAIter1, typename _RAIter2>
_RAIter1
__search_switch(_RAIter1 __begin1, _RAIter1 __end1,
_RAIter2 __begin2, _RAIter2 __end2,
random_access_iterator_tag, random_access_iterator_tag)
{
typedef typename std::iterator_traits<_RAIter1>::value_type _ValueType1;
typedef typename std::iterator_traits<_RAIter2>::value_type _ValueType2;
if (_GLIBCXX_PARALLEL_CONDITION(
static_cast<__gnu_parallel::_SequenceIndex>(__end1 - __begin1)
>= __gnu_parallel::_Settings::get().search_minimal_n))
return __gnu_parallel::
__search_template(
__begin1, __end1, __begin2, __end2,
__gnu_parallel::_EqualTo<_ValueType1, _ValueType2>());
else
return search(__begin1, __end1, __begin2, __end2,
__gnu_parallel::sequential_tag());
}
// Sequential fallback for input iterator case
template<typename _FIterator1, typename _FIterator2,
typename _IteratorTag1, typename _IteratorTag2>
inline _FIterator1
__search_switch(_FIterator1 __begin1, _FIterator1 __end1,
_FIterator2 __begin2, _FIterator2 __end2,
_IteratorTag1, _IteratorTag2)
{ return search(__begin1, __end1, __begin2, __end2,
__gnu_parallel::sequential_tag()); }
// Public interface.
template<typename _FIterator1, typename _FIterator2>
inline _FIterator1
search(_FIterator1 __begin1, _FIterator1 __end1,
_FIterator2 __begin2, _FIterator2 __end2)
{
return __search_switch(__begin1, __end1, __begin2, __end2,
std::__iterator_category(__begin1),
std::__iterator_category(__begin2));
}
// Public interface.
template<typename _FIterator1, typename _FIterator2,
typename _BinaryPredicate>
inline _FIterator1
search(_FIterator1 __begin1, _FIterator1 __end1,
_FIterator2 __begin2, _FIterator2 __end2,
_BinaryPredicate __pred, __gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::search(
__begin1, __end1, __begin2, __end2, __pred); }
// Parallel algorithm for random access iterator.
template<typename _RAIter1, typename _RAIter2,
typename _BinaryPredicate>
_RAIter1
__search_switch(_RAIter1 __begin1, _RAIter1 __end1,
_RAIter2 __begin2, _RAIter2 __end2,
_BinaryPredicate __pred,
random_access_iterator_tag, random_access_iterator_tag)
{
if (_GLIBCXX_PARALLEL_CONDITION(
static_cast<__gnu_parallel::_SequenceIndex>(__end1 - __begin1)
>= __gnu_parallel::_Settings::get().search_minimal_n))
return __gnu_parallel::__search_template(__begin1, __end1,
__begin2, __end2, __pred);
else
return search(__begin1, __end1, __begin2, __end2, __pred,
__gnu_parallel::sequential_tag());
}
// Sequential fallback for input iterator case
template<typename _FIterator1, typename _FIterator2,
typename _BinaryPredicate, typename _IteratorTag1,
typename _IteratorTag2>
inline _FIterator1
__search_switch(_FIterator1 __begin1, _FIterator1 __end1,
_FIterator2 __begin2, _FIterator2 __end2,
_BinaryPredicate __pred, _IteratorTag1, _IteratorTag2)
{ return search(__begin1, __end1, __begin2, __end2, __pred,
__gnu_parallel::sequential_tag()); }
// Public interface
template<typename _FIterator1, typename _FIterator2,
typename _BinaryPredicate>
inline _FIterator1
search(_FIterator1 __begin1, _FIterator1 __end1,
_FIterator2 __begin2, _FIterator2 __end2,
_BinaryPredicate __pred)
{
return __search_switch(__begin1, __end1, __begin2, __end2, __pred,
std::__iterator_category(__begin1),
std::__iterator_category(__begin2));
}
// Sequential fallback
template<typename _FIterator, typename _Integer, typename _Tp>
inline _FIterator
search_n(_FIterator __begin, _FIterator __end, _Integer __count,
const _Tp& __val, __gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::search_n(__begin, __end, __count, __val); }
// Sequential fallback
template<typename _FIterator, typename _Integer, typename _Tp,
typename _BinaryPredicate>
inline _FIterator
search_n(_FIterator __begin, _FIterator __end, _Integer __count,
const _Tp& __val, _BinaryPredicate __binary_pred,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::search_n(
__begin, __end, __count, __val, __binary_pred); }
// Public interface.
template<typename _FIterator, typename _Integer, typename _Tp>
inline _FIterator
search_n(_FIterator __begin, _FIterator __end, _Integer __count,
const _Tp& __val)
{
typedef typename iterator_traits<_FIterator>::value_type _ValueType;
return __gnu_parallel::search_n(__begin, __end, __count, __val,
__gnu_parallel::_EqualTo<_ValueType, _Tp>());
}
// Parallel algorithm for random access iterators.
template<typename _RAIter, typename _Integer,
typename _Tp, typename _BinaryPredicate>
_RAIter
__search_n_switch(_RAIter __begin, _RAIter __end, _Integer __count,
const _Tp& __val, _BinaryPredicate __binary_pred,
random_access_iterator_tag)
{
if (_GLIBCXX_PARALLEL_CONDITION(
static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin)
>= __gnu_parallel::_Settings::get().search_minimal_n))
{
__gnu_parallel::_PseudoSequence<_Tp, _Integer> __ps(__val, __count);
return __gnu_parallel::__search_template(
__begin, __end, __ps.begin(), __ps.end(), __binary_pred);
}
else
return _GLIBCXX_STD_A::search_n(__begin, __end, __count, __val,
__binary_pred);
}
// Sequential fallback for input iterator case.
template<typename _FIterator, typename _Integer, typename _Tp,
typename _BinaryPredicate, typename _IteratorTag>
inline _FIterator
__search_n_switch(_FIterator __begin, _FIterator __end, _Integer __count,
const _Tp& __val, _BinaryPredicate __binary_pred,
_IteratorTag)
{ return _GLIBCXX_STD_A::search_n(__begin, __end, __count, __val,
__binary_pred); }
// Public interface.
template<typename _FIterator, typename _Integer, typename _Tp,
typename _BinaryPredicate>
inline _FIterator
search_n(_FIterator __begin, _FIterator __end, _Integer __count,
const _Tp& __val, _BinaryPredicate __binary_pred)
{
return __search_n_switch(__begin, __end, __count, __val, __binary_pred,
std::__iterator_category(__begin));
}
// Sequential fallback.
template<typename _IIter, typename _OutputIterator,
typename _UnaryOperation>
inline _OutputIterator
transform(_IIter __begin, _IIter __end, _OutputIterator __result,
_UnaryOperation __unary_op, __gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::transform(__begin, __end, __result, __unary_op); }
// Parallel unary transform for random access iterators.
template<typename _RAIter1, typename _RAIter2,
typename _UnaryOperation>
_RAIter2
__transform1_switch(_RAIter1 __begin, _RAIter1 __end,
_RAIter2 __result, _UnaryOperation __unary_op,
random_access_iterator_tag, random_access_iterator_tag,
__gnu_parallel::_Parallelism __parallelism_tag)
{
if (_GLIBCXX_PARALLEL_CONDITION(
static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin)
>= __gnu_parallel::_Settings::get().transform_minimal_n
&& __gnu_parallel::__is_parallel(__parallelism_tag)))
{
bool __dummy = true;
typedef __gnu_parallel::_IteratorPair<_RAIter1,
_RAIter2, random_access_iterator_tag> _ItTrip;
_ItTrip __begin_pair(__begin, __result),
__end_pair(__end, __result + (__end - __begin));
__gnu_parallel::__transform1_selector<_ItTrip> __functionality;
__gnu_parallel::
__for_each_template_random_access(
__begin_pair, __end_pair, __unary_op, __functionality,
__gnu_parallel::_DummyReduct(),
__dummy, __dummy, -1, __parallelism_tag);
return __functionality._M_finish_iterator;
}
else
return transform(__begin, __end, __result, __unary_op,
__gnu_parallel::sequential_tag());
}
// Sequential fallback for input iterator case.
template<typename _RAIter1, typename _RAIter2,
typename _UnaryOperation, typename _IteratorTag1,
typename _IteratorTag2>
inline _RAIter2
__transform1_switch(_RAIter1 __begin, _RAIter1 __end,
_RAIter2 __result, _UnaryOperation __unary_op,
_IteratorTag1, _IteratorTag2)
{ return transform(__begin, __end, __result, __unary_op,
__gnu_parallel::sequential_tag()); }
// Public interface.
template<typename _IIter, typename _OutputIterator,
typename _UnaryOperation>
inline _OutputIterator
transform(_IIter __begin, _IIter __end, _OutputIterator __result,
_UnaryOperation __unary_op,
__gnu_parallel::_Parallelism __parallelism_tag)
{
return __transform1_switch(__begin, __end, __result, __unary_op,
std::__iterator_category(__begin),
std::__iterator_category(__result),
__parallelism_tag);
}
template<typename _IIter, typename _OutputIterator,
typename _UnaryOperation>
inline _OutputIterator
transform(_IIter __begin, _IIter __end, _OutputIterator __result,
_UnaryOperation __unary_op)
{
return __transform1_switch(__begin, __end, __result, __unary_op,
std::__iterator_category(__begin),
std::__iterator_category(__result));
}
// Sequential fallback
template<typename _IIter1, typename _IIter2,
typename _OutputIterator, typename _BinaryOperation>
inline _OutputIterator
transform(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _OutputIterator __result,
_BinaryOperation __binary_op, __gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::transform(__begin1, __end1,
__begin2, __result, __binary_op); }
// Parallel binary transform for random access iterators.
template<typename _RAIter1, typename _RAIter2,
typename _RAIter3, typename _BinaryOperation>
_RAIter3
__transform2_switch(_RAIter1 __begin1, _RAIter1 __end1,
_RAIter2 __begin2,
_RAIter3 __result, _BinaryOperation __binary_op,
random_access_iterator_tag, random_access_iterator_tag,
random_access_iterator_tag,
__gnu_parallel::_Parallelism __parallelism_tag)
{
if (_GLIBCXX_PARALLEL_CONDITION(
(__end1 - __begin1) >=
__gnu_parallel::_Settings::get().transform_minimal_n
&& __gnu_parallel::__is_parallel(__parallelism_tag)))
{
bool __dummy = true;
typedef __gnu_parallel::_IteratorTriple<_RAIter1,
_RAIter2, _RAIter3,
random_access_iterator_tag> _ItTrip;
_ItTrip __begin_triple(__begin1, __begin2, __result),
__end_triple(__end1, __begin2 + (__end1 - __begin1),
__result + (__end1 - __begin1));
__gnu_parallel::__transform2_selector<_ItTrip> __functionality;
__gnu_parallel::
__for_each_template_random_access(__begin_triple, __end_triple,
__binary_op, __functionality,
__gnu_parallel::_DummyReduct(),
__dummy, __dummy, -1,
__parallelism_tag);
return __functionality._M_finish_iterator;
}
else
return transform(__begin1, __end1, __begin2, __result, __binary_op,
__gnu_parallel::sequential_tag());
}
// Sequential fallback for input iterator case.
template<typename _IIter1, typename _IIter2,
typename _OutputIterator, typename _BinaryOperation,
typename _Tag1, typename _Tag2, typename _Tag3>
inline _OutputIterator
__transform2_switch(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _OutputIterator __result,
_BinaryOperation __binary_op, _Tag1, _Tag2, _Tag3)
{ return transform(__begin1, __end1, __begin2, __result, __binary_op,
__gnu_parallel::sequential_tag()); }
// Public interface.
template<typename _IIter1, typename _IIter2,
typename _OutputIterator, typename _BinaryOperation>
inline _OutputIterator
transform(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _OutputIterator __result,
_BinaryOperation __binary_op,
__gnu_parallel::_Parallelism __parallelism_tag)
{
return __transform2_switch(
__begin1, __end1, __begin2, __result, __binary_op,
std::__iterator_category(__begin1),
std::__iterator_category(__begin2),
std::__iterator_category(__result),
__parallelism_tag);
}
template<typename _IIter1, typename _IIter2,
typename _OutputIterator, typename _BinaryOperation>
inline _OutputIterator
transform(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _OutputIterator __result,
_BinaryOperation __binary_op)
{
return __transform2_switch(
__begin1, __end1, __begin2, __result, __binary_op,
std::__iterator_category(__begin1),
std::__iterator_category(__begin2),
std::__iterator_category(__result));
}
// Sequential fallback
template<typename _FIterator, typename _Tp>
inline void
replace(_FIterator __begin, _FIterator __end, const _Tp& __old_value,
const _Tp& __new_value, __gnu_parallel::sequential_tag)
{ _GLIBCXX_STD_A::replace(__begin, __end, __old_value, __new_value); }
// Sequential fallback for input iterator case
template<typename _FIterator, typename _Tp, typename _IteratorTag>
inline void
__replace_switch(_FIterator __begin, _FIterator __end,
const _Tp& __old_value, const _Tp& __new_value,
_IteratorTag)
{ replace(__begin, __end, __old_value, __new_value,
__gnu_parallel::sequential_tag()); }
// Parallel replace for random access iterators
template<typename _RAIter, typename _Tp>
inline void
__replace_switch(_RAIter __begin, _RAIter __end,
const _Tp& __old_value, const _Tp& __new_value,
random_access_iterator_tag,
__gnu_parallel::_Parallelism __parallelism_tag)
{
// XXX parallel version is where?
replace(__begin, __end, __old_value, __new_value,
__gnu_parallel::sequential_tag());
}
// Public interface
template<typename _FIterator, typename _Tp>
inline void
replace(_FIterator __begin, _FIterator __end, const _Tp& __old_value,
const _Tp& __new_value,
__gnu_parallel::_Parallelism __parallelism_tag)
{
__replace_switch(__begin, __end, __old_value, __new_value,
std::__iterator_category(__begin),
__parallelism_tag);
}
template<typename _FIterator, typename _Tp>
inline void
replace(_FIterator __begin, _FIterator __end, const _Tp& __old_value,
const _Tp& __new_value)
{
__replace_switch(__begin, __end, __old_value, __new_value,
std::__iterator_category(__begin));
}
// Sequential fallback
template<typename _FIterator, typename _Predicate, typename _Tp>
inline void
replace_if(_FIterator __begin, _FIterator __end, _Predicate __pred,
const _Tp& __new_value, __gnu_parallel::sequential_tag)
{ _GLIBCXX_STD_A::replace_if(__begin, __end, __pred, __new_value); }
// Sequential fallback for input iterator case
template<typename _FIterator, typename _Predicate, typename _Tp,
typename _IteratorTag>
inline void
__replace_if_switch(_FIterator __begin, _FIterator __end,
_Predicate __pred, const _Tp& __new_value, _IteratorTag)
{ replace_if(__begin, __end, __pred, __new_value,
__gnu_parallel::sequential_tag()); }
// Parallel algorithm for random access iterators.
template<typename _RAIter, typename _Predicate, typename _Tp>
void
__replace_if_switch(_RAIter __begin, _RAIter __end,
_Predicate __pred, const _Tp& __new_value,
random_access_iterator_tag,
__gnu_parallel::_Parallelism __parallelism_tag)
{
if (_GLIBCXX_PARALLEL_CONDITION(
static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin)
>= __gnu_parallel::_Settings::get().replace_minimal_n
&& __gnu_parallel::__is_parallel(__parallelism_tag)))
{
bool __dummy;
__gnu_parallel::
__replace_if_selector<_RAIter, _Predicate, _Tp>
__functionality(__new_value);
__gnu_parallel::
__for_each_template_random_access(
__begin, __end, __pred, __functionality,
__gnu_parallel::_DummyReduct(),
true, __dummy, -1, __parallelism_tag);
}
else
replace_if(__begin, __end, __pred, __new_value,
__gnu_parallel::sequential_tag());
}
// Public interface.
template<typename _FIterator, typename _Predicate, typename _Tp>
inline void
replace_if(_FIterator __begin, _FIterator __end,
_Predicate __pred, const _Tp& __new_value,
__gnu_parallel::_Parallelism __parallelism_tag)
{
__replace_if_switch(__begin, __end, __pred, __new_value,
std::__iterator_category(__begin),
__parallelism_tag);
}
template<typename _FIterator, typename _Predicate, typename _Tp>
inline void
replace_if(_FIterator __begin, _FIterator __end,
_Predicate __pred, const _Tp& __new_value)
{
__replace_if_switch(__begin, __end, __pred, __new_value,
std::__iterator_category(__begin));
}
// Sequential fallback
template<typename _FIterator, typename _Generator>
inline void
generate(_FIterator __begin, _FIterator __end, _Generator __gen,
__gnu_parallel::sequential_tag)
{ _GLIBCXX_STD_A::generate(__begin, __end, __gen); }
// Sequential fallback for input iterator case.
template<typename _FIterator, typename _Generator, typename _IteratorTag>
inline void
__generate_switch(_FIterator __begin, _FIterator __end, _Generator __gen,
_IteratorTag)
{ generate(__begin, __end, __gen, __gnu_parallel::sequential_tag()); }
// Parallel algorithm for random access iterators.
template<typename _RAIter, typename _Generator>
void
__generate_switch(_RAIter __begin, _RAIter __end,
_Generator __gen, random_access_iterator_tag,
__gnu_parallel::_Parallelism __parallelism_tag)
{
if (_GLIBCXX_PARALLEL_CONDITION(
static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin)
>= __gnu_parallel::_Settings::get().generate_minimal_n
&& __gnu_parallel::__is_parallel(__parallelism_tag)))
{
bool __dummy;
__gnu_parallel::__generate_selector<_RAIter>
__functionality;
__gnu_parallel::
__for_each_template_random_access(
__begin, __end, __gen, __functionality,
__gnu_parallel::_DummyReduct(),
true, __dummy, -1, __parallelism_tag);
}
else
generate(__begin, __end, __gen, __gnu_parallel::sequential_tag());
}
// Public interface.
template<typename _FIterator, typename _Generator>
inline void
generate(_FIterator __begin, _FIterator __end,
_Generator __gen, __gnu_parallel::_Parallelism __parallelism_tag)
{
__generate_switch(__begin, __end, __gen,
std::__iterator_category(__begin),
__parallelism_tag);
}
template<typename _FIterator, typename _Generator>
inline void
generate(_FIterator __begin, _FIterator __end, _Generator __gen)
{
__generate_switch(__begin, __end, __gen,
std::__iterator_category(__begin));
}
// Sequential fallback.
template<typename _OutputIterator, typename _Size, typename _Generator>
inline _OutputIterator
generate_n(_OutputIterator __begin, _Size __n, _Generator __gen,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::generate_n(__begin, __n, __gen); }
// Sequential fallback for input iterator case.
template<typename _OutputIterator, typename _Size, typename _Generator,
typename _IteratorTag>
inline _OutputIterator
__generate_n_switch(_OutputIterator __begin, _Size __n, _Generator __gen,
_IteratorTag)
{ return generate_n(__begin, __n, __gen,
__gnu_parallel::sequential_tag()); }
// Parallel algorithm for random access iterators.
template<typename _RAIter, typename _Size, typename _Generator>
inline _RAIter
__generate_n_switch(_RAIter __begin, _Size __n, _Generator __gen,
random_access_iterator_tag,
__gnu_parallel::_Parallelism __parallelism_tag)
{
// XXX parallel version is where?
return generate_n(__begin, __n, __gen, __gnu_parallel::sequential_tag());
}
// Public interface.
template<typename _OutputIterator, typename _Size, typename _Generator>
inline _OutputIterator
generate_n(_OutputIterator __begin, _Size __n, _Generator __gen,
__gnu_parallel::_Parallelism __parallelism_tag)
{
return __generate_n_switch(__begin, __n, __gen,
std::__iterator_category(__begin),
__parallelism_tag);
}
template<typename _OutputIterator, typename _Size, typename _Generator>
inline _OutputIterator
generate_n(_OutputIterator __begin, _Size __n, _Generator __gen)
{
return __generate_n_switch(__begin, __n, __gen,
std::__iterator_category(__begin));
}
// Sequential fallback.
template<typename _RAIter>
inline void
random_shuffle(_RAIter __begin, _RAIter __end,
__gnu_parallel::sequential_tag)
{ _GLIBCXX_STD_A::random_shuffle(__begin, __end); }
// Sequential fallback.
template<typename _RAIter, typename _RandomNumberGenerator>
inline void
random_shuffle(_RAIter __begin, _RAIter __end,
_RandomNumberGenerator& __rand,
__gnu_parallel::sequential_tag)
{ _GLIBCXX_STD_A::random_shuffle(__begin, __end, __rand); }
/** @brief Functor wrapper for std::rand(). */
template<typename _MustBeInt = int>
struct _CRandNumber
{
int
operator()(int __limit)
{ return rand() % __limit; }
};
// Fill in random number generator.
template<typename _RAIter>
inline void
random_shuffle(_RAIter __begin, _RAIter __end)
{
_CRandNumber<> __r;
// Parallelization still possible.
__gnu_parallel::random_shuffle(__begin, __end, __r);
}
// Parallel algorithm for random access iterators.
template<typename _RAIter, typename _RandomNumberGenerator>
void
random_shuffle(_RAIter __begin, _RAIter __end,
#if __cplusplus >= 201103L
_RandomNumberGenerator&& __rand)
#else
_RandomNumberGenerator& __rand)
#endif
{
if (__begin == __end)
return;
if (_GLIBCXX_PARALLEL_CONDITION(
static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin)
>= __gnu_parallel::_Settings::get().random_shuffle_minimal_n))
__gnu_parallel::__parallel_random_shuffle(__begin, __end, __rand);
else
__gnu_parallel::__sequential_random_shuffle(__begin, __end, __rand);
}
// Sequential fallback.
template<typename _FIterator, typename _Predicate>
inline _FIterator
partition(_FIterator __begin, _FIterator __end,
_Predicate __pred, __gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::partition(__begin, __end, __pred); }
// Sequential fallback for input iterator case.
template<typename _FIterator, typename _Predicate, typename _IteratorTag>
inline _FIterator
__partition_switch(_FIterator __begin, _FIterator __end,
_Predicate __pred, _IteratorTag)
{ return partition(__begin, __end, __pred,
__gnu_parallel::sequential_tag()); }
// Parallel algorithm for random access iterators.
template<typename _RAIter, typename _Predicate>
_RAIter
__partition_switch(_RAIter __begin, _RAIter __end,
_Predicate __pred, random_access_iterator_tag)
{
if (_GLIBCXX_PARALLEL_CONDITION(
static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin)
>= __gnu_parallel::_Settings::get().partition_minimal_n))
{
typedef typename std::iterator_traits<_RAIter>::
difference_type _DifferenceType;
_DifferenceType __middle = __gnu_parallel::
__parallel_partition(__begin, __end, __pred,
__gnu_parallel::__get_max_threads());
return __begin + __middle;
}
else
return partition(__begin, __end, __pred,
__gnu_parallel::sequential_tag());
}
// Public interface.
template<typename _FIterator, typename _Predicate>
inline _FIterator
partition(_FIterator __begin, _FIterator __end, _Predicate __pred)
{
return __partition_switch(__begin, __end, __pred,
std::__iterator_category(__begin));
}
// sort interface
// Sequential fallback
template<typename _RAIter>
inline void
sort(_RAIter __begin, _RAIter __end,
__gnu_parallel::sequential_tag)
{ _GLIBCXX_STD_A::sort(__begin, __end); }
// Sequential fallback
template<typename _RAIter, typename _Compare>
inline void
sort(_RAIter __begin, _RAIter __end, _Compare __comp,
__gnu_parallel::sequential_tag)
{ _GLIBCXX_STD_A::sort<_RAIter, _Compare>(__begin, __end,
__comp); }
// Public interface
template<typename _RAIter, typename _Compare,
typename _Parallelism>
void
sort(_RAIter __begin, _RAIter __end, _Compare __comp,
_Parallelism __parallelism)
{
typedef typename iterator_traits<_RAIter>::value_type _ValueType;
if (__begin != __end)
{
if (_GLIBCXX_PARALLEL_CONDITION(
static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin) >=
__gnu_parallel::_Settings::get().sort_minimal_n))
__gnu_parallel::__parallel_sort<false>(
__begin, __end, __comp, __parallelism);
else
sort(__begin, __end, __comp, __gnu_parallel::sequential_tag());
}
}
// Public interface, insert default comparator
template<typename _RAIter>
inline void
sort(_RAIter __begin, _RAIter __end)
{
typedef typename iterator_traits<_RAIter>::value_type _ValueType;
sort(__begin, __end, std::less<_ValueType>(),
__gnu_parallel::default_parallel_tag());
}
// Public interface, insert default comparator
template<typename _RAIter>
inline void
sort(_RAIter __begin, _RAIter __end,
__gnu_parallel::default_parallel_tag __parallelism)
{
typedef typename iterator_traits<_RAIter>::value_type _ValueType;
sort(__begin, __end, std::less<_ValueType>(), __parallelism);
}
// Public interface, insert default comparator
template<typename _RAIter>
inline void
sort(_RAIter __begin, _RAIter __end,
__gnu_parallel::parallel_tag __parallelism)
{
typedef typename iterator_traits<_RAIter>::value_type _ValueType;
sort(__begin, __end, std::less<_ValueType>(), __parallelism);
}
// Public interface, insert default comparator
template<typename _RAIter>
inline void
sort(_RAIter __begin, _RAIter __end,
__gnu_parallel::multiway_mergesort_tag __parallelism)
{
typedef typename iterator_traits<_RAIter>::value_type _ValueType;
sort(__begin, __end, std::less<_ValueType>(), __parallelism);
}
// Public interface, insert default comparator
template<typename _RAIter>
inline void
sort(_RAIter __begin, _RAIter __end,
__gnu_parallel::multiway_mergesort_sampling_tag __parallelism)
{
typedef typename iterator_traits<_RAIter>::value_type _ValueType;
sort(__begin, __end, std::less<_ValueType>(), __parallelism);
}
// Public interface, insert default comparator
template<typename _RAIter>
inline void
sort(_RAIter __begin, _RAIter __end,
__gnu_parallel::multiway_mergesort_exact_tag __parallelism)
{
typedef typename iterator_traits<_RAIter>::value_type _ValueType;
sort(__begin, __end, std::less<_ValueType>(), __parallelism);
}
// Public interface, insert default comparator
template<typename _RAIter>
inline void
sort(_RAIter __begin, _RAIter __end,
__gnu_parallel::quicksort_tag __parallelism)
{
typedef typename iterator_traits<_RAIter>::value_type _ValueType;
sort(__begin, __end, std::less<_ValueType>(), __parallelism);
}
// Public interface, insert default comparator
template<typename _RAIter>
inline void
sort(_RAIter __begin, _RAIter __end,
__gnu_parallel::balanced_quicksort_tag __parallelism)
{
typedef typename iterator_traits<_RAIter>::value_type _ValueType;
sort(__begin, __end, std::less<_ValueType>(), __parallelism);
}
// Public interface
template<typename _RAIter, typename _Compare>
void
sort(_RAIter __begin, _RAIter __end, _Compare __comp)
{
typedef typename iterator_traits<_RAIter>::value_type _ValueType;
sort(__begin, __end, __comp, __gnu_parallel::default_parallel_tag());
}
// stable_sort interface
// Sequential fallback
template<typename _RAIter>
inline void
stable_sort(_RAIter __begin, _RAIter __end,
__gnu_parallel::sequential_tag)
{ _GLIBCXX_STD_A::stable_sort(__begin, __end); }
// Sequential fallback
template<typename _RAIter, typename _Compare>
inline void
stable_sort(_RAIter __begin, _RAIter __end,
_Compare __comp, __gnu_parallel::sequential_tag)
{ _GLIBCXX_STD_A::stable_sort<_RAIter, _Compare>(__begin, __end, __comp); }
// Public interface
template<typename _RAIter, typename _Compare,
typename _Parallelism>
void
stable_sort(_RAIter __begin, _RAIter __end,
_Compare __comp, _Parallelism __parallelism)
{
typedef iterator_traits<_RAIter> _TraitsType;
typedef typename _TraitsType::value_type _ValueType;
if (__begin != __end)
{
if (_GLIBCXX_PARALLEL_CONDITION(
static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin) >=
__gnu_parallel::_Settings::get().sort_minimal_n))
__gnu_parallel::__parallel_sort<true>(__begin, __end,
__comp, __parallelism);
else
stable_sort(__begin, __end, __comp,
__gnu_parallel::sequential_tag());
}
}
// Public interface, insert default comparator
template<typename _RAIter>
inline void
stable_sort(_RAIter __begin, _RAIter __end)
{
typedef typename iterator_traits<_RAIter>::value_type _ValueType;
stable_sort(__begin, __end, std::less<_ValueType>(),
__gnu_parallel::default_parallel_tag());
}
// Public interface, insert default comparator
template<typename _RAIter>
inline void
stable_sort(_RAIter __begin, _RAIter __end,
__gnu_parallel::default_parallel_tag __parallelism)
{
typedef typename iterator_traits<_RAIter>::value_type _ValueType;
stable_sort(__begin, __end, std::less<_ValueType>(), __parallelism);
}
// Public interface, insert default comparator
template<typename _RAIter>
inline void
stable_sort(_RAIter __begin, _RAIter __end,
__gnu_parallel::parallel_tag __parallelism)
{
typedef typename iterator_traits<_RAIter>::value_type _ValueType;
stable_sort(__begin, __end, std::less<_ValueType>(), __parallelism);
}
// Public interface, insert default comparator
template<typename _RAIter>
inline void
stable_sort(_RAIter __begin, _RAIter __end,
__gnu_parallel::multiway_mergesort_tag __parallelism)
{
typedef typename iterator_traits<_RAIter>::value_type _ValueType;
stable_sort(__begin, __end, std::less<_ValueType>(), __parallelism);
}
// Public interface, insert default comparator
template<typename _RAIter>
inline void
stable_sort(_RAIter __begin, _RAIter __end,
__gnu_parallel::quicksort_tag __parallelism)
{
typedef typename iterator_traits<_RAIter>::value_type _ValueType;
stable_sort(__begin, __end, std::less<_ValueType>(), __parallelism);
}
// Public interface, insert default comparator
template<typename _RAIter>
inline void
stable_sort(_RAIter __begin, _RAIter __end,
__gnu_parallel::balanced_quicksort_tag __parallelism)
{
typedef typename iterator_traits<_RAIter>::value_type _ValueType;
stable_sort(__begin, __end, std::less<_ValueType>(), __parallelism);
}
// Public interface
template<typename _RAIter, typename _Compare>
void
stable_sort(_RAIter __begin, _RAIter __end, _Compare __comp)
{
stable_sort(
__begin, __end, __comp, __gnu_parallel::default_parallel_tag());
}
// Sequential fallback
template<typename _IIter1, typename _IIter2,
typename _OutputIterator>
inline _OutputIterator
merge(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2,
_IIter2 __end2, _OutputIterator __result,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::merge(
__begin1, __end1, __begin2, __end2, __result); }
// Sequential fallback
template<typename _IIter1, typename _IIter2,
typename _OutputIterator, typename _Compare>
inline _OutputIterator
merge(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2,
_IIter2 __end2, _OutputIterator __result, _Compare __comp,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::merge(
__begin1, __end1, __begin2, __end2, __result, __comp); }
// Sequential fallback for input iterator case
template<typename _IIter1, typename _IIter2, typename _OutputIterator,
typename _Compare, typename _IteratorTag1,
typename _IteratorTag2, typename _IteratorTag3>
inline _OutputIterator
__merge_switch(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _IIter2 __end2,
_OutputIterator __result, _Compare __comp,
_IteratorTag1, _IteratorTag2, _IteratorTag3)
{ return _GLIBCXX_STD_A::merge(__begin1, __end1, __begin2, __end2,
__result, __comp); }
// Parallel algorithm for random access iterators
template<typename _IIter1, typename _IIter2,
typename _OutputIterator, typename _Compare>
_OutputIterator
__merge_switch(_IIter1 __begin1, _IIter1 __end1,
_IIter2 __begin2, _IIter2 __end2,
_OutputIterator __result, _Compare __comp,
random_access_iterator_tag, random_access_iterator_tag,
random_access_iterator_tag)
{
if (_GLIBCXX_PARALLEL_CONDITION(
(static_cast<__gnu_parallel::_SequenceIndex>(__end1 - __begin1)
>= __gnu_parallel::_Settings::get().merge_minimal_n
|| static_cast<__gnu_parallel::_SequenceIndex>(__end2 - __begin2)
>= __gnu_parallel::_Settings::get().merge_minimal_n)))
return __gnu_parallel::__parallel_merge_advance(
__begin1, __end1, __begin2, __end2, __result,
(__end1 - __begin1) + (__end2 - __begin2), __comp);
else
return __gnu_parallel::__merge_advance(
__begin1, __end1, __begin2, __end2, __result,
(__end1 - __begin1) + (__end2 - __begin2), __comp);
}
// Public interface
template<typename _IIter1, typename _IIter2,
typename _OutputIterator, typename _Compare>
inline _OutputIterator
merge(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2,
_IIter2 __end2, _OutputIterator __result, _Compare __comp)
{
return __merge_switch(
__begin1, __end1, __begin2, __end2, __result, __comp,
std::__iterator_category(__begin1),
std::__iterator_category(__begin2),
std::__iterator_category(__result));
}
// Public interface, insert default comparator
template<typename _IIter1, typename _IIter2,
typename _OutputIterator>
inline _OutputIterator
merge(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2,
_IIter2 __end2, _OutputIterator __result)
{
typedef typename std::iterator_traits<_IIter1>::value_type _ValueType1;
typedef typename std::iterator_traits<_IIter2>::value_type _ValueType2;
return __gnu_parallel::merge(__begin1, __end1, __begin2, __end2,
__result, __gnu_parallel::_Less<_ValueType1, _ValueType2>());
}
// Sequential fallback
template<typename _RAIter>
inline void
nth_element(_RAIter __begin, _RAIter __nth,
_RAIter __end, __gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::nth_element(__begin, __nth, __end); }
// Sequential fallback
template<typename _RAIter, typename _Compare>
inline void
nth_element(_RAIter __begin, _RAIter __nth,
_RAIter __end, _Compare __comp,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::nth_element(__begin, __nth, __end, __comp); }
// Public interface
template<typename _RAIter, typename _Compare>
inline void
nth_element(_RAIter __begin, _RAIter __nth,
_RAIter __end, _Compare __comp)
{
if (_GLIBCXX_PARALLEL_CONDITION(
static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin)
>= __gnu_parallel::_Settings::get().nth_element_minimal_n))
__gnu_parallel::__parallel_nth_element(__begin, __nth, __end, __comp);
else
nth_element(__begin, __nth, __end, __comp,
__gnu_parallel::sequential_tag());
}
// Public interface, insert default comparator
template<typename _RAIter>
inline void
nth_element(_RAIter __begin, _RAIter __nth,
_RAIter __end)
{
typedef typename iterator_traits<_RAIter>::value_type _ValueType;
__gnu_parallel::nth_element(__begin, __nth, __end,
std::less<_ValueType>());
}
// Sequential fallback
template<typename _RAIter, typename _Compare>
inline void
partial_sort(_RAIter __begin, _RAIter __middle,
_RAIter __end, _Compare __comp,
__gnu_parallel::sequential_tag)
{ _GLIBCXX_STD_A::partial_sort(__begin, __middle, __end, __comp); }
// Sequential fallback
template<typename _RAIter>
inline void
partial_sort(_RAIter __begin, _RAIter __middle,
_RAIter __end, __gnu_parallel::sequential_tag)
{ _GLIBCXX_STD_A::partial_sort(__begin, __middle, __end); }
// Public interface, parallel algorithm for random access iterators
template<typename _RAIter, typename _Compare>
void
partial_sort(_RAIter __begin, _RAIter __middle,
_RAIter __end, _Compare __comp)
{
if (_GLIBCXX_PARALLEL_CONDITION(
static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin)
>= __gnu_parallel::_Settings::get().partial_sort_minimal_n))
__gnu_parallel::
__parallel_partial_sort(__begin, __middle, __end, __comp);
else
partial_sort(__begin, __middle, __end, __comp,
__gnu_parallel::sequential_tag());
}
// Public interface, insert default comparator
template<typename _RAIter>
inline void
partial_sort(_RAIter __begin, _RAIter __middle,
_RAIter __end)
{
typedef iterator_traits<_RAIter> _TraitsType;
typedef typename _TraitsType::value_type _ValueType;
__gnu_parallel::partial_sort(__begin, __middle, __end,
std::less<_ValueType>());
}
// Sequential fallback
template<typename _FIterator>
inline _FIterator
max_element(_FIterator __begin, _FIterator __end,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::max_element(__begin, __end); }
// Sequential fallback
template<typename _FIterator, typename _Compare>
inline _FIterator
max_element(_FIterator __begin, _FIterator __end, _Compare __comp,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::max_element(__begin, __end, __comp); }
// Sequential fallback for input iterator case
template<typename _FIterator, typename _Compare, typename _IteratorTag>
inline _FIterator
__max_element_switch(_FIterator __begin, _FIterator __end,
_Compare __comp, _IteratorTag)
{ return max_element(__begin, __end, __comp,
__gnu_parallel::sequential_tag()); }
// Parallel algorithm for random access iterators
template<typename _RAIter, typename _Compare>
_RAIter
__max_element_switch(_RAIter __begin, _RAIter __end,
_Compare __comp, random_access_iterator_tag,
__gnu_parallel::_Parallelism __parallelism_tag)
{
if (_GLIBCXX_PARALLEL_CONDITION(
static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin)
>= __gnu_parallel::_Settings::get().max_element_minimal_n
&& __gnu_parallel::__is_parallel(__parallelism_tag)))
{
_RAIter __res(__begin);
__gnu_parallel::__identity_selector<_RAIter>
__functionality;
__gnu_parallel::
__for_each_template_random_access(
__begin, __end, __gnu_parallel::_Nothing(), __functionality,
__gnu_parallel::__max_element_reduct<_Compare, _RAIter>(__comp),
__res, __res, -1, __parallelism_tag);
return __res;
}
else
return max_element(__begin, __end, __comp,
__gnu_parallel::sequential_tag());
}
// Public interface, insert default comparator
template<typename _FIterator>
inline _FIterator
max_element(_FIterator __begin, _FIterator __end,
__gnu_parallel::_Parallelism __parallelism_tag)
{
typedef typename iterator_traits<_FIterator>::value_type _ValueType;
return max_element(__begin, __end, std::less<_ValueType>(),
__parallelism_tag);
}
template<typename _FIterator>
inline _FIterator
max_element(_FIterator __begin, _FIterator __end)
{
typedef typename iterator_traits<_FIterator>::value_type _ValueType;
return __gnu_parallel::max_element(__begin, __end,
std::less<_ValueType>());
}
// Public interface
template<typename _FIterator, typename _Compare>
inline _FIterator
max_element(_FIterator __begin, _FIterator __end, _Compare __comp,
__gnu_parallel::_Parallelism __parallelism_tag)
{
return __max_element_switch(__begin, __end, __comp,
std::__iterator_category(__begin),
__parallelism_tag);
}
template<typename _FIterator, typename _Compare>
inline _FIterator
max_element(_FIterator __begin, _FIterator __end, _Compare __comp)
{
return __max_element_switch(__begin, __end, __comp,
std::__iterator_category(__begin));
}
// Sequential fallback
template<typename _FIterator>
inline _FIterator
min_element(_FIterator __begin, _FIterator __end,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::min_element(__begin, __end); }
// Sequential fallback
template<typename _FIterator, typename _Compare>
inline _FIterator
min_element(_FIterator __begin, _FIterator __end, _Compare __comp,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::min_element(__begin, __end, __comp); }
// Sequential fallback for input iterator case
template<typename _FIterator, typename _Compare, typename _IteratorTag>
inline _FIterator
__min_element_switch(_FIterator __begin, _FIterator __end,
_Compare __comp, _IteratorTag)
{ return min_element(__begin, __end, __comp,
__gnu_parallel::sequential_tag()); }
// Parallel algorithm for random access iterators
template<typename _RAIter, typename _Compare>
_RAIter
__min_element_switch(_RAIter __begin, _RAIter __end,
_Compare __comp, random_access_iterator_tag,
__gnu_parallel::_Parallelism __parallelism_tag)
{
if (_GLIBCXX_PARALLEL_CONDITION(
static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin)
>= __gnu_parallel::_Settings::get().min_element_minimal_n
&& __gnu_parallel::__is_parallel(__parallelism_tag)))
{
_RAIter __res(__begin);
__gnu_parallel::__identity_selector<_RAIter>
__functionality;
__gnu_parallel::
__for_each_template_random_access(
__begin, __end, __gnu_parallel::_Nothing(), __functionality,
__gnu_parallel::__min_element_reduct<_Compare, _RAIter>(__comp),
__res, __res, -1, __parallelism_tag);
return __res;
}
else
return min_element(__begin, __end, __comp,
__gnu_parallel::sequential_tag());
}
// Public interface, insert default comparator
template<typename _FIterator>
inline _FIterator
min_element(_FIterator __begin, _FIterator __end,
__gnu_parallel::_Parallelism __parallelism_tag)
{
typedef typename iterator_traits<_FIterator>::value_type _ValueType;
return min_element(__begin, __end, std::less<_ValueType>(),
__parallelism_tag);
}
template<typename _FIterator>
inline _FIterator
min_element(_FIterator __begin, _FIterator __end)
{
typedef typename iterator_traits<_FIterator>::value_type _ValueType;
return __gnu_parallel::min_element(__begin, __end,
std::less<_ValueType>());
}
// Public interface
template<typename _FIterator, typename _Compare>
inline _FIterator
min_element(_FIterator __begin, _FIterator __end, _Compare __comp,
__gnu_parallel::_Parallelism __parallelism_tag)
{
return __min_element_switch(__begin, __end, __comp,
std::__iterator_category(__begin),
__parallelism_tag);
}
template<typename _FIterator, typename _Compare>
inline _FIterator
min_element(_FIterator __begin, _FIterator __end, _Compare __comp)
{
return __min_element_switch(__begin, __end, __comp,
std::__iterator_category(__begin));
}
} // end namespace
} // end namespace
#endif /* _GLIBCXX_PARALLEL_ALGO_H */
c++/8/parallel/for_each.h 0000644 00000007553 15201526705 0011013 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/for_each.h
* @brief Main interface for embarrassingly parallel functions.
*
* The explicit implementation are in other header files, like
* workstealing.h, par_loop.h, omp_loop.h, and omp_loop_static.h.
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Felix Putze.
#ifndef _GLIBCXX_PARALLEL_FOR_EACH_H
#define _GLIBCXX_PARALLEL_FOR_EACH_H 1
#include <parallel/settings.h>
#include <parallel/par_loop.h>
#include <parallel/omp_loop.h>
#include <parallel/workstealing.h>
namespace __gnu_parallel
{
/** @brief Chose the desired algorithm by evaluating @c __parallelism_tag.
* @param __begin Begin iterator of input sequence.
* @param __end End iterator of input sequence.
* @param __user_op A user-specified functor (comparator, predicate,
* associative operator,...)
* @param __functionality functor to @a process an element with
* __user_op (depends on desired functionality, e. g. accumulate,
* for_each,...
* @param __reduction Reduction functor.
* @param __reduction_start Initial value for reduction.
* @param __output Output iterator.
* @param __bound Maximum number of elements processed.
* @param __parallelism_tag Parallelization method */
template<typename _IIter, typename _UserOp,
typename _Functionality, typename _Red, typename _Result>
_UserOp
__for_each_template_random_access(_IIter __begin, _IIter __end,
_UserOp __user_op,
_Functionality& __functionality,
_Red __reduction,
_Result __reduction_start,
_Result& __output, typename
std::iterator_traits<_IIter>::
difference_type __bound,
_Parallelism __parallelism_tag)
{
if (__parallelism_tag == parallel_unbalanced)
return __for_each_template_random_access_ed
(__begin, __end, __user_op, __functionality, __reduction,
__reduction_start, __output, __bound);
else if (__parallelism_tag == parallel_omp_loop)
return __for_each_template_random_access_omp_loop
(__begin, __end, __user_op, __functionality, __reduction,
__reduction_start, __output, __bound);
else if (__parallelism_tag == parallel_omp_loop_static)
return __for_each_template_random_access_omp_loop
(__begin, __end, __user_op, __functionality, __reduction,
__reduction_start, __output, __bound);
else //e. g. parallel_balanced
return __for_each_template_random_access_workstealing
(__begin, __end, __user_op, __functionality, __reduction,
__reduction_start, __output, __bound);
}
}
#endif /* _GLIBCXX_PARALLEL_FOR_EACH_H */
c++/8/parallel/merge.h 0000644 00000022552 15201526705 0010340 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/merge.h
* @brief Parallel implementation of std::merge().
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Johannes Singler.
#ifndef _GLIBCXX_PARALLEL_MERGE_H
#define _GLIBCXX_PARALLEL_MERGE_H 1
#include <parallel/basic_iterator.h>
#include <bits/stl_algo.h>
namespace __gnu_parallel
{
/** @brief Merge routine being able to merge only the @c __max_length
* smallest elements.
*
* The @c __begin iterators are advanced accordingly, they might not
* reach @c __end, in contrast to the usual variant.
* @param __begin1 Begin iterator of first sequence.
* @param __end1 End iterator of first sequence.
* @param __begin2 Begin iterator of second sequence.
* @param __end2 End iterator of second sequence.
* @param __target Target begin iterator.
* @param __max_length Maximum number of elements to merge.
* @param __comp Comparator.
* @return Output end iterator. */
template<typename _RAIter1, typename _RAIter2,
typename _OutputIterator, typename _DifferenceTp,
typename _Compare>
_OutputIterator
__merge_advance_usual(_RAIter1& __begin1, _RAIter1 __end1,
_RAIter2& __begin2, _RAIter2 __end2,
_OutputIterator __target,
_DifferenceTp __max_length, _Compare __comp)
{
typedef _DifferenceTp _DifferenceType;
while (__begin1 != __end1 && __begin2 != __end2 && __max_length > 0)
{
// array1[__i1] < array0[i0]
if (__comp(*__begin2, *__begin1))
*__target++ = *__begin2++;
else
*__target++ = *__begin1++;
--__max_length;
}
if (__begin1 != __end1)
{
__target = std::copy(__begin1, __begin1 + __max_length, __target);
__begin1 += __max_length;
}
else
{
__target = std::copy(__begin2, __begin2 + __max_length, __target);
__begin2 += __max_length;
}
return __target;
}
/** @brief Merge routine being able to merge only the @c __max_length
* smallest elements.
*
* The @c __begin iterators are advanced accordingly, they might not
* reach @c __end, in contrast to the usual variant.
* Specially designed code should allow the compiler to generate
* conditional moves instead of branches.
* @param __begin1 Begin iterator of first sequence.
* @param __end1 End iterator of first sequence.
* @param __begin2 Begin iterator of second sequence.
* @param __end2 End iterator of second sequence.
* @param __target Target begin iterator.
* @param __max_length Maximum number of elements to merge.
* @param __comp Comparator.
* @return Output end iterator. */
template<typename _RAIter1, typename _RAIter2,
typename _OutputIterator, typename _DifferenceTp,
typename _Compare>
_OutputIterator
__merge_advance_movc(_RAIter1& __begin1, _RAIter1 __end1,
_RAIter2& __begin2, _RAIter2 __end2,
_OutputIterator __target,
_DifferenceTp __max_length, _Compare __comp)
{
typedef _DifferenceTp _DifferenceType;
typedef typename std::iterator_traits<_RAIter1>::value_type
_ValueType1;
typedef typename std::iterator_traits<_RAIter2>::value_type
_ValueType2;
#if _GLIBCXX_PARALLEL_ASSERTIONS
_GLIBCXX_PARALLEL_ASSERT(__max_length >= 0);
#endif
while (__begin1 != __end1 && __begin2 != __end2 && __max_length > 0)
{
_RAIter1 __next1 = __begin1 + 1;
_RAIter2 __next2 = __begin2 + 1;
_ValueType1 __element1 = *__begin1;
_ValueType2 __element2 = *__begin2;
if (__comp(__element2, __element1))
{
__element1 = __element2;
__begin2 = __next2;
}
else
__begin1 = __next1;
*__target = __element1;
++__target;
--__max_length;
}
if (__begin1 != __end1)
{
__target = std::copy(__begin1, __begin1 + __max_length, __target);
__begin1 += __max_length;
}
else
{
__target = std::copy(__begin2, __begin2 + __max_length, __target);
__begin2 += __max_length;
}
return __target;
}
/** @brief Merge routine being able to merge only the @c __max_length
* smallest elements.
*
* The @c __begin iterators are advanced accordingly, they might not
* reach @c __end, in contrast to the usual variant.
* Static switch on whether to use the conditional-move variant.
* @param __begin1 Begin iterator of first sequence.
* @param __end1 End iterator of first sequence.
* @param __begin2 Begin iterator of second sequence.
* @param __end2 End iterator of second sequence.
* @param __target Target begin iterator.
* @param __max_length Maximum number of elements to merge.
* @param __comp Comparator.
* @return Output end iterator. */
template<typename _RAIter1, typename _RAIter2,
typename _OutputIterator, typename _DifferenceTp,
typename _Compare>
inline _OutputIterator
__merge_advance(_RAIter1& __begin1, _RAIter1 __end1,
_RAIter2& __begin2, _RAIter2 __end2,
_OutputIterator __target, _DifferenceTp __max_length,
_Compare __comp)
{
_GLIBCXX_CALL(__max_length)
return __merge_advance_movc(__begin1, __end1, __begin2, __end2,
__target, __max_length, __comp);
}
/** @brief Merge routine fallback to sequential in case the
iterators of the two input sequences are of different type.
* @param __begin1 Begin iterator of first sequence.
* @param __end1 End iterator of first sequence.
* @param __begin2 Begin iterator of second sequence.
* @param __end2 End iterator of second sequence.
* @param __target Target begin iterator.
* @param __max_length Maximum number of elements to merge.
* @param __comp Comparator.
* @return Output end iterator. */
template<typename _RAIter1, typename _RAIter2,
typename _RAIter3, typename _Compare>
inline _RAIter3
__parallel_merge_advance(_RAIter1& __begin1, _RAIter1 __end1,
_RAIter2& __begin2,
// different iterators, parallel implementation
// not available
_RAIter2 __end2, _RAIter3 __target, typename
std::iterator_traits<_RAIter1>::
difference_type __max_length, _Compare __comp)
{ return __merge_advance(__begin1, __end1, __begin2, __end2, __target,
__max_length, __comp); }
/** @brief Parallel merge routine being able to merge only the @c
* __max_length smallest elements.
*
* The @c __begin iterators are advanced accordingly, they might not
* reach @c __end, in contrast to the usual variant.
* The functionality is projected onto parallel_multiway_merge.
* @param __begin1 Begin iterator of first sequence.
* @param __end1 End iterator of first sequence.
* @param __begin2 Begin iterator of second sequence.
* @param __end2 End iterator of second sequence.
* @param __target Target begin iterator.
* @param __max_length Maximum number of elements to merge.
* @param __comp Comparator.
* @return Output end iterator.
*/
template<typename _RAIter1, typename _RAIter3,
typename _Compare>
inline _RAIter3
__parallel_merge_advance(_RAIter1& __begin1, _RAIter1 __end1,
_RAIter1& __begin2, _RAIter1 __end2,
_RAIter3 __target, typename
std::iterator_traits<_RAIter1>::
difference_type __max_length, _Compare __comp)
{
typedef typename
std::iterator_traits<_RAIter1>::value_type _ValueType;
typedef typename std::iterator_traits<_RAIter1>::
difference_type _DifferenceType1 /* == difference_type2 */;
typedef typename std::iterator_traits<_RAIter3>::
difference_type _DifferenceType3;
typedef typename std::pair<_RAIter1, _RAIter1>
_IteratorPair;
_IteratorPair __seqs[2] = { std::make_pair(__begin1, __end1),
std::make_pair(__begin2, __end2) };
_RAIter3 __target_end = parallel_multiway_merge
< /* __stable = */ true, /* __sentinels = */ false>
(__seqs, __seqs + 2, __target, multiway_merge_exact_splitting
< /* __stable = */ true, _IteratorPair*,
_Compare, _DifferenceType1>, __max_length, __comp,
omp_get_max_threads());
return __target_end;
}
} //namespace __gnu_parallel
#endif /* _GLIBCXX_PARALLEL_MERGE_H */
c++/8/parallel/settings.h 0000644 00000030252 15201526705 0011075 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/settings.h
* @brief Runtime settings and tuning parameters, heuristics to decide
* whether to use parallelized algorithms.
* This file is a GNU parallel extension to the Standard C++ Library.
*
* @section parallelization_decision
* The decision whether to run an algorithm in parallel.
*
* There are several ways the user can switch on and __off the parallel
* execution of an algorithm, both at compile- and run-time.
*
* Only sequential execution can be forced at compile-time. This
* reduces code size and protects code parts that have
* non-thread-safe side effects.
*
* Ultimately, forcing parallel execution at compile-time makes
* sense. Often, the sequential algorithm implementation is used as
* a subroutine, so no reduction in code size can be achieved. Also,
* the machine the program is run on might have only one processor
* core, so to avoid overhead, the algorithm is executed
* sequentially.
*
* To force sequential execution of an algorithm ultimately at
* compile-time, the user must add the tag
* gnu_parallel::sequential_tag() to the end of the parameter list,
* e. g.
*
* \code
* std::sort(__v.begin(), __v.end(), __gnu_parallel::sequential_tag());
* \endcode
*
* This is compatible with all overloaded algorithm variants. No
* additional code will be instantiated, at all. The same holds for
* most algorithm calls with iterators not providing random access.
*
* If the algorithm call is not forced to be executed sequentially
* at compile-time, the decision is made at run-time.
* The global variable __gnu_parallel::_Settings::algorithm_strategy
* is checked. _It is a tristate variable corresponding to:
*
* a. force_sequential, meaning the sequential algorithm is executed.
* b. force_parallel, meaning the parallel algorithm is executed.
* c. heuristic
*
* For heuristic, the parallel algorithm implementation is called
* only if the input size is sufficiently large. For most
* algorithms, the input size is the (combined) length of the input
* sequence(__s). The threshold can be set by the user, individually
* for each algorithm. The according variables are called
* gnu_parallel::_Settings::[algorithm]_minimal_n .
*
* For some of the algorithms, there are even more tuning options,
* e. g. the ability to choose from multiple algorithm variants. See
* below for details.
*/
// Written by Johannes Singler and Felix Putze.
#ifndef _GLIBCXX_PARALLEL_SETTINGS_H
#define _GLIBCXX_PARALLEL_SETTINGS_H 1
#include <parallel/types.h>
/**
* @brief Determine at compile(?)-time if the parallel variant of an
* algorithm should be called.
* @param __c A condition that is convertible to bool that is overruled by
* __gnu_parallel::_Settings::algorithm_strategy. Usually a decision
* based on the input size.
*/
#define _GLIBCXX_PARALLEL_CONDITION(__c) \
(__gnu_parallel::_Settings::get().algorithm_strategy \
!= __gnu_parallel::force_sequential \
&& ((__gnu_parallel::__get_max_threads() > 1 && (__c)) \
|| __gnu_parallel::_Settings::get().algorithm_strategy \
== __gnu_parallel::force_parallel))
/*
inline bool
parallel_condition(bool __c)
{
bool ret = false;
const _Settings& __s = _Settings::get();
if (__s.algorithm_strategy != force_seqential)
{
if (__s.algorithm_strategy == force_parallel)
ret = true;
else
ret = __get_max_threads() > 1 && __c;
}
return ret;
}
*/
namespace __gnu_parallel
{
/// class _Settings
/// Run-time settings for the parallel mode including all tunable parameters.
struct _Settings
{
_AlgorithmStrategy algorithm_strategy;
_SortAlgorithm sort_algorithm;
_PartialSumAlgorithm partial_sum_algorithm;
_MultiwayMergeAlgorithm multiway_merge_algorithm;
_FindAlgorithm find_algorithm;
_SplittingAlgorithm sort_splitting;
_SplittingAlgorithm merge_splitting;
_SplittingAlgorithm multiway_merge_splitting;
// Per-algorithm settings.
/// Minimal input size for accumulate.
_SequenceIndex accumulate_minimal_n;
/// Minimal input size for adjacent_difference.
unsigned int adjacent_difference_minimal_n;
/// Minimal input size for count and count_if.
_SequenceIndex count_minimal_n;
/// Minimal input size for fill.
_SequenceIndex fill_minimal_n;
/// Block size increase factor for find.
double find_increasing_factor;
/// Initial block size for find.
_SequenceIndex find_initial_block_size;
/// Maximal block size for find.
_SequenceIndex find_maximum_block_size;
/// Start with looking for this many elements sequentially, for find.
_SequenceIndex find_sequential_search_size;
/// Minimal input size for for_each.
_SequenceIndex for_each_minimal_n;
/// Minimal input size for generate.
_SequenceIndex generate_minimal_n;
/// Minimal input size for max_element.
_SequenceIndex max_element_minimal_n;
/// Minimal input size for merge.
_SequenceIndex merge_minimal_n;
/// Oversampling factor for merge.
unsigned int merge_oversampling;
/// Minimal input size for min_element.
_SequenceIndex min_element_minimal_n;
/// Minimal input size for multiway_merge.
_SequenceIndex multiway_merge_minimal_n;
/// Oversampling factor for multiway_merge.
int multiway_merge_minimal_k;
/// Oversampling factor for multiway_merge.
unsigned int multiway_merge_oversampling;
/// Minimal input size for nth_element.
_SequenceIndex nth_element_minimal_n;
/// Chunk size for partition.
_SequenceIndex partition_chunk_size;
/// Chunk size for partition, relative to input size. If > 0.0,
/// this value overrides partition_chunk_size.
double partition_chunk_share;
/// Minimal input size for partition.
_SequenceIndex partition_minimal_n;
/// Minimal input size for partial_sort.
_SequenceIndex partial_sort_minimal_n;
/// Ratio for partial_sum. Assume "sum and write result" to be
/// this factor slower than just "sum".
float partial_sum_dilation;
/// Minimal input size for partial_sum.
unsigned int partial_sum_minimal_n;
/// Minimal input size for random_shuffle.
unsigned int random_shuffle_minimal_n;
/// Minimal input size for replace and replace_if.
_SequenceIndex replace_minimal_n;
/// Minimal input size for set_difference.
_SequenceIndex set_difference_minimal_n;
/// Minimal input size for set_intersection.
_SequenceIndex set_intersection_minimal_n;
/// Minimal input size for set_symmetric_difference.
_SequenceIndex set_symmetric_difference_minimal_n;
/// Minimal input size for set_union.
_SequenceIndex set_union_minimal_n;
/// Minimal input size for parallel sorting.
_SequenceIndex sort_minimal_n;
/// Oversampling factor for parallel std::sort (MWMS).
unsigned int sort_mwms_oversampling;
/// Such many samples to take to find a good pivot (quicksort).
unsigned int sort_qs_num_samples_preset;
/// Maximal subsequence __length to switch to unbalanced __base case.
/// Applies to std::sort with dynamically load-balanced quicksort.
_SequenceIndex sort_qsb_base_case_maximal_n;
/// Minimal input size for parallel std::transform.
_SequenceIndex transform_minimal_n;
/// Minimal input size for unique_copy.
_SequenceIndex unique_copy_minimal_n;
_SequenceIndex workstealing_chunk_size;
// Hardware dependent tuning parameters.
/// size of the L1 cache in bytes (underestimation).
unsigned long long L1_cache_size;
/// size of the L2 cache in bytes (underestimation).
unsigned long long L2_cache_size;
/// size of the Translation Lookaside Buffer (underestimation).
unsigned int TLB_size;
/// Overestimation of cache line size. Used to avoid false
/// sharing, i.e. elements of different threads are at least this
/// amount apart.
unsigned int cache_line_size;
// Statistics.
/// The number of stolen ranges in load-balanced quicksort.
_SequenceIndex qsb_steals;
/// Minimal input size for search and search_n.
_SequenceIndex search_minimal_n;
/// Block size scale-down factor with respect to current position.
float find_scale_factor;
/// Get the global settings.
_GLIBCXX_CONST static const _Settings&
get() throw();
/// Set the global settings.
static void
set(_Settings&) throw();
explicit
_Settings() :
algorithm_strategy(heuristic),
sort_algorithm(MWMS),
partial_sum_algorithm(LINEAR),
multiway_merge_algorithm(LOSER_TREE),
find_algorithm(CONSTANT_SIZE_BLOCKS),
sort_splitting(EXACT),
merge_splitting(EXACT),
multiway_merge_splitting(EXACT),
accumulate_minimal_n(1000),
adjacent_difference_minimal_n(1000),
count_minimal_n(1000),
fill_minimal_n(1000),
find_increasing_factor(2.0),
find_initial_block_size(256),
find_maximum_block_size(8192),
find_sequential_search_size(256),
for_each_minimal_n(1000),
generate_minimal_n(1000),
max_element_minimal_n(1000),
merge_minimal_n(1000),
merge_oversampling(10),
min_element_minimal_n(1000),
multiway_merge_minimal_n(1000),
multiway_merge_minimal_k(2), multiway_merge_oversampling(10),
nth_element_minimal_n(1000),
partition_chunk_size(1000),
partition_chunk_share(0.0),
partition_minimal_n(1000),
partial_sort_minimal_n(1000),
partial_sum_dilation(1.0f),
partial_sum_minimal_n(1000),
random_shuffle_minimal_n(1000),
replace_minimal_n(1000),
set_difference_minimal_n(1000),
set_intersection_minimal_n(1000),
set_symmetric_difference_minimal_n(1000),
set_union_minimal_n(1000),
sort_minimal_n(1000),
sort_mwms_oversampling(10),
sort_qs_num_samples_preset(100),
sort_qsb_base_case_maximal_n(100),
transform_minimal_n(1000),
unique_copy_minimal_n(10000),
workstealing_chunk_size(100),
L1_cache_size(16 << 10),
L2_cache_size(256 << 10),
TLB_size(128),
cache_line_size(64),
qsb_steals(0),
search_minimal_n(1000),
find_scale_factor(0.01f)
{ }
};
}
#endif /* _GLIBCXX_PARALLEL_SETTINGS_H */
c++/8/parallel/compiletime_settings.h 0000644 00000005467 15201526705 0013476 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/compiletime_settings.h
* @brief Defines on options concerning debugging and performance, at
* compile-time.
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Johannes Singler.
#include <cstdio>
/** @brief Determine verbosity level of the parallel mode.
* Level 1 prints a message each time a parallel-mode function is entered. */
#define _GLIBCXX_VERBOSE_LEVEL 0
/** @def _GLIBCXX_CALL
* @brief Macro to produce log message when entering a function.
* @param __n Input size.
* @see _GLIBCXX_VERBOSE_LEVEL */
#if (_GLIBCXX_VERBOSE_LEVEL == 0)
#define _GLIBCXX_CALL(__n)
#endif
#if (_GLIBCXX_VERBOSE_LEVEL == 1)
#define _GLIBCXX_CALL(__n) \
printf(" %__s:\niam = %d, __n = %ld, __num_threads = %d\n", \
__PRETTY_FUNCTION__, omp_get_thread_num(), (__n), __get_max_threads());
#endif
#ifndef _GLIBCXX_SCALE_DOWN_FPU
/** @brief Use floating-point scaling instead of modulo for mapping
* random numbers to a range. This can be faster on certain CPUs. */
#define _GLIBCXX_SCALE_DOWN_FPU 0
#endif
#ifndef _GLIBCXX_PARALLEL_ASSERTIONS
/** @brief Switch on many _GLIBCXX_PARALLEL_ASSERTions in parallel code.
* Should be switched on only locally. */
#define _GLIBCXX_PARALLEL_ASSERTIONS (_GLIBCXX_ASSERTIONS+0)
#endif
#ifndef _GLIBCXX_RANDOM_SHUFFLE_CONSIDER_L1
/** @brief Switch on many _GLIBCXX_PARALLEL_ASSERTions in parallel code.
* Consider the size of the L1 cache for
* gnu_parallel::__parallel_random_shuffle(). */
#define _GLIBCXX_RANDOM_SHUFFLE_CONSIDER_L1 0
#endif
#ifndef _GLIBCXX_RANDOM_SHUFFLE_CONSIDER_TLB
/** @brief Switch on many _GLIBCXX_PARALLEL_ASSERTions in parallel code.
* Consider the size of the TLB for
* gnu_parallel::__parallel_random_shuffle(). */
#define _GLIBCXX_RANDOM_SHUFFLE_CONSIDER_TLB 0
#endif
c++/8/parallel/features.h 0000644 00000006727 15201526705 0011065 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/features.h
* @brief Defines on whether to include algorithm variants.
*
* Less variants reduce executable size and compile time.
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Johannes Singler.
#ifndef _GLIBCXX_PARALLEL_FEATURES_H
#define _GLIBCXX_PARALLEL_FEATURES_H 1
#ifndef _GLIBCXX_MERGESORT
/** @def _GLIBCXX_MERGESORT
* @brief Include parallel multi-way mergesort.
* @see __gnu_parallel::_Settings::sort_algorithm */
#define _GLIBCXX_MERGESORT 1
#endif
#ifndef _GLIBCXX_QUICKSORT
/** @def _GLIBCXX_QUICKSORT
* @brief Include parallel unbalanced quicksort.
* @see __gnu_parallel::_Settings::sort_algorithm */
#define _GLIBCXX_QUICKSORT 1
#endif
#ifndef _GLIBCXX_BAL_QUICKSORT
/** @def _GLIBCXX_BAL_QUICKSORT
* @brief Include parallel dynamically load-balanced quicksort.
* @see __gnu_parallel::_Settings::sort_algorithm */
#define _GLIBCXX_BAL_QUICKSORT 1
#endif
#ifndef _GLIBCXX_FIND_GROWING_BLOCKS
/** @brief Include the growing blocks variant for std::find.
* @see __gnu_parallel::_Settings::find_algorithm */
#define _GLIBCXX_FIND_GROWING_BLOCKS 1
#endif
#ifndef _GLIBCXX_FIND_CONSTANT_SIZE_BLOCKS
/** @brief Include the equal-sized blocks variant for std::find.
* @see __gnu_parallel::_Settings::find_algorithm */
#define _GLIBCXX_FIND_CONSTANT_SIZE_BLOCKS 1
#endif
#ifndef _GLIBCXX_FIND_EQUAL_SPLIT
/** @def _GLIBCXX_FIND_EQUAL_SPLIT
* @brief Include the equal splitting variant for std::find.
* @see __gnu_parallel::_Settings::find_algorithm */
#define _GLIBCXX_FIND_EQUAL_SPLIT 1
#endif
#ifndef _GLIBCXX_TREE_INITIAL_SPLITTING
/** @def _GLIBCXX_TREE_INITIAL_SPLITTING
* @brief Include the initial splitting variant for
* _Rb_tree::insert_unique(_IIter beg, _IIter __end).
* @see __gnu_parallel::_Rb_tree */
#define _GLIBCXX_TREE_INITIAL_SPLITTING 1
#endif
#ifndef _GLIBCXX_TREE_DYNAMIC_BALANCING
/** @def _GLIBCXX_TREE_DYNAMIC_BALANCING
* @brief Include the dynamic balancing variant for
* _Rb_tree::insert_unique(_IIter beg, _IIter __end).
* @see __gnu_parallel::_Rb_tree */
#define _GLIBCXX_TREE_DYNAMIC_BALANCING 1
#endif
#ifndef _GLIBCXX_TREE_FULL_COPY
/** @def _GLIBCXX_TREE_FULL_COPY
* @brief In order to sort the input sequence of
* _Rb_tree::insert_unique(_IIter beg, _IIter __end) a
* full copy of the input elements is done.
* @see __gnu_parallel::_Rb_tree */
#define _GLIBCXX_TREE_FULL_COPY 1
#endif
#endif /* _GLIBCXX_PARALLEL_FEATURES_H */
c++/8/parallel/algorithmfwd.h 0000644 00000076716 15201526705 0011743 0 ustar 00 // <parallel/algorithm> Forward declarations -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/algorithmfwd.h
* This file is a GNU parallel extension to the Standard C++ Library.
*/
#ifndef _GLIBCXX_PARALLEL_ALGORITHMFWD_H
#define _GLIBCXX_PARALLEL_ALGORITHMFWD_H 1
#pragma GCC system_header
#include <parallel/tags.h>
#include <parallel/settings.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __parallel
{
template<typename _FIter>
_FIter
adjacent_find(_FIter, _FIter);
template<typename _FIter>
_FIter
adjacent_find(_FIter, _FIter, __gnu_parallel::sequential_tag);
template<typename _FIter, typename _IterTag>
_FIter
__adjacent_find_switch(_FIter, _FIter, _IterTag);
template<typename _RAIter>
_RAIter
__adjacent_find_switch(_RAIter, _RAIter, random_access_iterator_tag);
template<typename _FIter, typename _BiPredicate>
_FIter
adjacent_find(_FIter, _FIter, _BiPredicate);
template<typename _FIter, typename _BiPredicate>
_FIter
adjacent_find(_FIter, _FIter, _BiPredicate,
__gnu_parallel::sequential_tag);
template<typename _FIter, typename _BiPredicate, typename _IterTag>
_FIter
__adjacent_find_switch(_FIter, _FIter, _BiPredicate, _IterTag);
template<typename _RAIter, typename _BiPredicate>
_RAIter
__adjacent_find_switch(_RAIter, _RAIter, _BiPredicate,
random_access_iterator_tag);
template<typename _IIter, typename _Tp>
typename iterator_traits<_IIter>::difference_type
count(_IIter, _IIter, const _Tp&);
template<typename _IIter, typename _Tp>
typename iterator_traits<_IIter>::difference_type
count(_IIter, _IIter, const _Tp&, __gnu_parallel::sequential_tag);
template<typename _IIter, typename _Tp>
typename iterator_traits<_IIter>::difference_type
count(_IIter, _IIter, const _Tp&, __gnu_parallel::_Parallelism);
template<typename _IIter, typename _Tp, typename _IterTag>
typename iterator_traits<_IIter>::difference_type
__count_switch(_IIter, _IIter, const _Tp&, _IterTag);
template<typename _RAIter, typename _Tp>
typename iterator_traits<_RAIter>::difference_type
__count_switch(_RAIter, _RAIter, const _Tp&, random_access_iterator_tag,
__gnu_parallel::_Parallelism __parallelism
= __gnu_parallel::parallel_unbalanced);
template<typename _IIter, typename _Predicate>
typename iterator_traits<_IIter>::difference_type
count_if(_IIter, _IIter, _Predicate);
template<typename _IIter, typename _Predicate>
typename iterator_traits<_IIter>::difference_type
count_if(_IIter, _IIter, _Predicate, __gnu_parallel::sequential_tag);
template<typename _IIter, typename _Predicate>
typename iterator_traits<_IIter>::difference_type
count_if(_IIter, _IIter, _Predicate, __gnu_parallel::_Parallelism);
template<typename _IIter, typename _Predicate, typename _IterTag>
typename iterator_traits<_IIter>::difference_type
__count_if_switch(_IIter, _IIter, _Predicate, _IterTag);
template<typename _RAIter, typename _Predicate>
typename iterator_traits<_RAIter>::difference_type
__count_if_switch(_RAIter, _RAIter, _Predicate, random_access_iterator_tag,
__gnu_parallel::_Parallelism __parallelism
= __gnu_parallel::parallel_unbalanced);
// algobase.h
template<typename _IIter1, typename _IIter2>
bool
equal(_IIter1, _IIter1, _IIter2, __gnu_parallel::sequential_tag);
template<typename _IIter1, typename _IIter2, typename _Predicate>
bool
equal(_IIter1, _IIter1, _IIter2, _Predicate,
__gnu_parallel::sequential_tag);
template<typename _IIter1, typename _IIter2>
bool
equal(_IIter1, _IIter1, _IIter2);
template<typename _IIter1, typename _IIter2, typename _Predicate>
bool
equal(_IIter1, _IIter1, _IIter2, _Predicate);
template<typename _IIter, typename _Tp>
_IIter
find(_IIter, _IIter, const _Tp&, __gnu_parallel::sequential_tag);
template<typename _IIter, typename _Tp>
_IIter
find(_IIter, _IIter, const _Tp& __val);
template<typename _IIter, typename _Tp, typename _IterTag>
_IIter
__find_switch(_IIter, _IIter, const _Tp&, _IterTag);
template<typename _RAIter, typename _Tp>
_RAIter
__find_switch(_RAIter, _RAIter, const _Tp&, random_access_iterator_tag);
template<typename _IIter, typename _Predicate>
_IIter
find_if(_IIter, _IIter, _Predicate, __gnu_parallel::sequential_tag);
template<typename _IIter, typename _Predicate>
_IIter
find_if(_IIter, _IIter, _Predicate);
template<typename _IIter, typename _Predicate, typename _IterTag>
_IIter
__find_if_switch(_IIter, _IIter, _Predicate, _IterTag);
template<typename _RAIter, typename _Predicate>
_RAIter
__find_if_switch(_RAIter, _RAIter, _Predicate, random_access_iterator_tag);
template<typename _IIter, typename _FIter>
_IIter
find_first_of(_IIter, _IIter, _FIter, _FIter,
__gnu_parallel::sequential_tag);
template<typename _IIter, typename _FIter, typename _BiPredicate>
_IIter
find_first_of(_IIter, _IIter, _FIter, _FIter, _BiPredicate,
__gnu_parallel::sequential_tag);
template<typename _IIter, typename _FIter, typename _BiPredicate>
_IIter
find_first_of(_IIter, _IIter, _FIter, _FIter, _BiPredicate);
template<typename _IIter, typename _FIter>
_IIter
find_first_of(_IIter, _IIter, _FIter, _FIter);
template<typename _IIter, typename _FIter,
typename _IterTag1, typename _IterTag2>
_IIter
__find_first_of_switch(
_IIter, _IIter, _FIter, _FIter, _IterTag1, _IterTag2);
template<typename _RAIter, typename _FIter, typename _BiPredicate,
typename _IterTag>
_RAIter
__find_first_of_switch(_RAIter, _RAIter, _FIter, _FIter, _BiPredicate,
random_access_iterator_tag, _IterTag);
template<typename _IIter, typename _FIter, typename _BiPredicate,
typename _IterTag1, typename _IterTag2>
_IIter
__find_first_of_switch(_IIter, _IIter, _FIter, _FIter, _BiPredicate,
_IterTag1, _IterTag2);
template<typename _IIter, typename _Function>
_Function
for_each(_IIter, _IIter, _Function);
template<typename _IIter, typename _Function>
_Function
for_each(_IIter, _IIter, _Function, __gnu_parallel::sequential_tag);
template<typename _Iterator, typename _Function>
_Function
for_each(_Iterator, _Iterator, _Function, __gnu_parallel::_Parallelism);
template<typename _IIter, typename _Function, typename _IterTag>
_Function
__for_each_switch(_IIter, _IIter, _Function, _IterTag);
template<typename _RAIter, typename _Function>
_Function
__for_each_switch(_RAIter, _RAIter, _Function, random_access_iterator_tag,
__gnu_parallel::_Parallelism __parallelism
= __gnu_parallel::parallel_balanced);
template<typename _FIter, typename _Generator>
void
generate(_FIter, _FIter, _Generator);
template<typename _FIter, typename _Generator>
void
generate(_FIter, _FIter, _Generator, __gnu_parallel::sequential_tag);
template<typename _FIter, typename _Generator>
void
generate(_FIter, _FIter, _Generator, __gnu_parallel::_Parallelism);
template<typename _FIter, typename _Generator, typename _IterTag>
void
__generate_switch(_FIter, _FIter, _Generator, _IterTag);
template<typename _RAIter, typename _Generator>
void
__generate_switch(_RAIter, _RAIter, _Generator, random_access_iterator_tag,
__gnu_parallel::_Parallelism __parallelism
= __gnu_parallel::parallel_balanced);
template<typename _OIter, typename _Size, typename _Generator>
_OIter
generate_n(_OIter, _Size, _Generator);
template<typename _OIter, typename _Size, typename _Generator>
_OIter
generate_n(_OIter, _Size, _Generator, __gnu_parallel::sequential_tag);
template<typename _OIter, typename _Size, typename _Generator>
_OIter
generate_n(_OIter, _Size, _Generator, __gnu_parallel::_Parallelism);
template<typename _OIter, typename _Size, typename _Generator,
typename _IterTag>
_OIter
__generate_n_switch(_OIter, _Size, _Generator, _IterTag);
template<typename _RAIter, typename _Size, typename _Generator>
_RAIter
__generate_n_switch(_RAIter, _Size, _Generator, random_access_iterator_tag,
__gnu_parallel::_Parallelism __parallelism
= __gnu_parallel::parallel_balanced);
template<typename _IIter1, typename _IIter2>
bool
lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2,
__gnu_parallel::sequential_tag);
template<typename _IIter1, typename _IIter2, typename _Predicate>
bool
lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2, _Predicate,
__gnu_parallel::sequential_tag);
template<typename _IIter1, typename _IIter2>
bool
lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2);
template<typename _IIter1, typename _IIter2, typename _Predicate>
bool
lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2, _Predicate);
template<typename _IIter1, typename _IIter2,
typename _Predicate, typename _IterTag1, typename _IterTag2>
bool
__lexicographical_compare_switch(_IIter1, _IIter1, _IIter2, _IIter2,
_Predicate, _IterTag1, _IterTag2);
template<typename _RAIter1, typename _RAIter2, typename _Predicate>
bool
__lexicographical_compare_switch(_RAIter1, _RAIter1, _RAIter2, _RAIter2,
_Predicate, random_access_iterator_tag,
random_access_iterator_tag);
// algo.h
template<typename _IIter1, typename _IIter2>
pair<_IIter1, _IIter2>
mismatch(_IIter1, _IIter1, _IIter2, __gnu_parallel::sequential_tag);
template<typename _IIter1, typename _IIter2, typename _Predicate>
pair<_IIter1, _IIter2>
mismatch(_IIter1, _IIter1, _IIter2, _Predicate,
__gnu_parallel::sequential_tag);
template<typename _IIter1, typename _IIter2>
pair<_IIter1, _IIter2>
mismatch(_IIter1, _IIter1, _IIter2);
template<typename _IIter1, typename _IIter2, typename _Predicate>
pair<_IIter1, _IIter2>
mismatch(_IIter1, _IIter1, _IIter2, _Predicate);
template<typename _IIter1, typename _IIter2, typename _Predicate,
typename _IterTag1, typename _IterTag2>
pair<_IIter1, _IIter2>
__mismatch_switch(_IIter1, _IIter1, _IIter2, _Predicate,
_IterTag1, _IterTag2);
template<typename _RAIter1, typename _RAIter2, typename _Predicate>
pair<_RAIter1, _RAIter2>
__mismatch_switch(_RAIter1, _RAIter1, _RAIter2, _Predicate,
random_access_iterator_tag, random_access_iterator_tag);
template<typename _FIter1, typename _FIter2>
_FIter1
search(_FIter1, _FIter1, _FIter2, _FIter2, __gnu_parallel::sequential_tag);
template<typename _FIter1, typename _FIter2>
_FIter1
search(_FIter1, _FIter1, _FIter2, _FIter2);
template<typename _FIter1, typename _FIter2, typename _BiPredicate>
_FIter1
search(_FIter1, _FIter1, _FIter2, _FIter2, _BiPredicate,
__gnu_parallel::sequential_tag);
template<typename _FIter1, typename _FIter2, typename _BiPredicate>
_FIter1
search(_FIter1, _FIter1, _FIter2, _FIter2, _BiPredicate);
template<typename _RAIter1, typename _RAIter2>
_RAIter1
__search_switch(_RAIter1, _RAIter1, _RAIter2, _RAIter2,
random_access_iterator_tag, random_access_iterator_tag);
template<typename _FIter1, typename _FIter2, typename _IterTag1,
typename _IterTag2>
_FIter1
__search_switch(_FIter1, _FIter1, _FIter2, _FIter2, _IterTag1, _IterTag2);
template<typename _RAIter1, typename _RAIter2, typename _BiPredicate>
_RAIter1
__search_switch(_RAIter1, _RAIter1, _RAIter2, _RAIter2, _BiPredicate,
random_access_iterator_tag, random_access_iterator_tag);
template<typename _FIter1, typename _FIter2, typename _BiPredicate,
typename _IterTag1, typename _IterTag2>
_FIter1
__search_switch(_FIter1, _FIter1, _FIter2, _FIter2, _BiPredicate,
_IterTag1, _IterTag2);
template<typename _FIter, typename _Integer, typename _Tp>
_FIter
search_n(_FIter, _FIter, _Integer, const _Tp&,
__gnu_parallel::sequential_tag);
template<typename _FIter, typename _Integer, typename _Tp,
typename _BiPredicate>
_FIter
search_n(_FIter, _FIter, _Integer, const _Tp&, _BiPredicate,
__gnu_parallel::sequential_tag);
template<typename _FIter, typename _Integer, typename _Tp>
_FIter
search_n(_FIter, _FIter, _Integer, const _Tp&);
template<typename _FIter, typename _Integer, typename _Tp,
typename _BiPredicate>
_FIter
search_n(_FIter, _FIter, _Integer, const _Tp&, _BiPredicate);
template<typename _RAIter, typename _Integer, typename _Tp,
typename _BiPredicate>
_RAIter
__search_n_switch(_RAIter, _RAIter, _Integer, const _Tp&,
_BiPredicate, random_access_iterator_tag);
template<typename _FIter, typename _Integer, typename _Tp,
typename _BiPredicate, typename _IterTag>
_FIter
__search_n_switch(_FIter, _FIter, _Integer, const _Tp&,
_BiPredicate, _IterTag);
template<typename _IIter, typename _OIter, typename _UnaryOperation>
_OIter
transform(_IIter, _IIter, _OIter, _UnaryOperation);
template<typename _IIter, typename _OIter, typename _UnaryOperation>
_OIter
transform(_IIter, _IIter, _OIter, _UnaryOperation,
__gnu_parallel::sequential_tag);
template<typename _IIter, typename _OIter, typename _UnaryOperation>
_OIter
transform(_IIter, _IIter, _OIter, _UnaryOperation,
__gnu_parallel::_Parallelism);
template<typename _IIter, typename _OIter, typename _UnaryOperation,
typename _IterTag1, typename _IterTag2>
_OIter
__transform1_switch(_IIter, _IIter, _OIter, _UnaryOperation,
_IterTag1, _IterTag2);
template<typename _RAIIter, typename _RAOIter, typename _UnaryOperation>
_RAOIter
__transform1_switch(_RAIIter, _RAIIter, _RAOIter, _UnaryOperation,
random_access_iterator_tag, random_access_iterator_tag,
__gnu_parallel::_Parallelism __parallelism
= __gnu_parallel::parallel_balanced);
template<typename _IIter1, typename _IIter2, typename _OIter,
typename _BiOperation>
_OIter
transform(_IIter1, _IIter1, _IIter2, _OIter, _BiOperation);
template<typename _IIter1, typename _IIter2, typename _OIter,
typename _BiOperation>
_OIter
transform(_IIter1, _IIter1, _IIter2, _OIter, _BiOperation,
__gnu_parallel::sequential_tag);
template<typename _IIter1, typename _IIter2, typename _OIter,
typename _BiOperation>
_OIter
transform(_IIter1, _IIter1, _IIter2, _OIter, _BiOperation,
__gnu_parallel::_Parallelism);
template<typename _RAIter1, typename _RAIter2, typename _RAIter3,
typename _BiOperation>
_RAIter3
__transform2_switch(_RAIter1, _RAIter1, _RAIter2, _RAIter3, _BiOperation,
random_access_iterator_tag, random_access_iterator_tag,
random_access_iterator_tag,
__gnu_parallel::_Parallelism __parallelism
= __gnu_parallel::parallel_balanced);
template<typename _IIter1, typename _IIter2, typename _OIter,
typename _BiOperation, typename _Tag1,
typename _Tag2, typename _Tag3>
_OIter
__transform2_switch(_IIter1, _IIter1, _IIter2, _OIter, _BiOperation,
_Tag1, _Tag2, _Tag3);
template<typename _FIter, typename _Tp>
void
replace(_FIter, _FIter, const _Tp&, const _Tp&);
template<typename _FIter, typename _Tp>
void
replace(_FIter, _FIter, const _Tp&, const _Tp&,
__gnu_parallel::sequential_tag);
template<typename _FIter, typename _Tp>
void
replace(_FIter, _FIter, const _Tp&, const _Tp&,
__gnu_parallel::_Parallelism);
template<typename _FIter, typename _Tp, typename _IterTag>
void
__replace_switch(_FIter, _FIter, const _Tp&, const _Tp&, _IterTag);
template<typename _RAIter, typename _Tp>
void
__replace_switch(_RAIter, _RAIter, const _Tp&, const _Tp&,
random_access_iterator_tag, __gnu_parallel::_Parallelism);
template<typename _FIter, typename _Predicate, typename _Tp>
void
replace_if(_FIter, _FIter, _Predicate, const _Tp&);
template<typename _FIter, typename _Predicate, typename _Tp>
void
replace_if(_FIter, _FIter, _Predicate, const _Tp&,
__gnu_parallel::sequential_tag);
template<typename _FIter, typename _Predicate, typename _Tp>
void
replace_if(_FIter, _FIter, _Predicate, const _Tp&,
__gnu_parallel::_Parallelism);
template<typename _FIter, typename _Predicate, typename _Tp,
typename _IterTag>
void
__replace_if_switch(_FIter, _FIter, _Predicate, const _Tp&, _IterTag);
template<typename _RAIter, typename _Predicate, typename _Tp>
void
__replace_if_switch(_RAIter, _RAIter, _Predicate, const _Tp&,
random_access_iterator_tag,
__gnu_parallel::_Parallelism);
template<typename _FIter>
_FIter
max_element(_FIter, _FIter);
template<typename _FIter>
_FIter
max_element(_FIter, _FIter, __gnu_parallel::sequential_tag);
template<typename _FIter>
_FIter
max_element(_FIter, _FIter, __gnu_parallel::_Parallelism);
template<typename _FIter, typename _Compare>
_FIter
max_element(_FIter, _FIter, _Compare);
template<typename _FIter, typename _Compare>
_FIter
max_element(_FIter, _FIter, _Compare, __gnu_parallel::sequential_tag);
template<typename _FIter, typename _Compare>
_FIter
max_element(_FIter, _FIter, _Compare, __gnu_parallel::_Parallelism);
template<typename _FIter, typename _Compare, typename _IterTag>
_FIter
__max_element_switch(_FIter, _FIter, _Compare, _IterTag);
template<typename _RAIter, typename _Compare>
_RAIter
__max_element_switch(
_RAIter, _RAIter, _Compare, random_access_iterator_tag,
__gnu_parallel::_Parallelism __parallelism
= __gnu_parallel::parallel_balanced);
template<typename _IIter1, typename _IIter2, typename _OIter>
_OIter
merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter,
__gnu_parallel::sequential_tag);
template<typename _IIter1, typename _IIter2, typename _OIter,
typename _Compare>
_OIter
merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare,
__gnu_parallel::sequential_tag);
template<typename _IIter1, typename _IIter2, typename _OIter,
typename _Compare>
_OIter
merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare);
template<typename _IIter1, typename _IIter2, typename _OIter>
_OIter
merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter);
template<typename _IIter1, typename _IIter2, typename _OIter,
typename _Compare, typename _IterTag1, typename _IterTag2,
typename _IterTag3>
_OIter
__merge_switch(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare,
_IterTag1, _IterTag2, _IterTag3);
template<typename _IIter1, typename _IIter2, typename _OIter,
typename _Compare>
_OIter
__merge_switch(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare,
random_access_iterator_tag, random_access_iterator_tag,
random_access_iterator_tag);
template<typename _FIter>
_FIter
min_element(_FIter, _FIter);
template<typename _FIter>
_FIter
min_element(_FIter, _FIter, __gnu_parallel::sequential_tag);
template<typename _FIter>
_FIter
min_element(_FIter, _FIter,
__gnu_parallel::_Parallelism __parallelism_tag);
template<typename _FIter, typename _Compare>
_FIter
min_element(_FIter, _FIter, _Compare);
template<typename _FIter, typename _Compare>
_FIter
min_element(_FIter, _FIter, _Compare, __gnu_parallel::sequential_tag);
template<typename _FIter, typename _Compare>
_FIter
min_element(_FIter, _FIter, _Compare, __gnu_parallel::_Parallelism);
template<typename _FIter, typename _Compare, typename _IterTag>
_FIter
__min_element_switch(_FIter, _FIter, _Compare, _IterTag);
template<typename _RAIter, typename _Compare>
_RAIter
__min_element_switch(
_RAIter, _RAIter, _Compare, random_access_iterator_tag,
__gnu_parallel::_Parallelism __parallelism
= __gnu_parallel::parallel_balanced);
template<typename _RAIter>
void
nth_element(_RAIter, _RAIter, _RAIter, __gnu_parallel::sequential_tag);
template<typename _RAIter, typename _Compare>
void
nth_element(_RAIter, _RAIter, _RAIter, _Compare,
__gnu_parallel::sequential_tag);
template<typename _RAIter, typename _Compare>
void
nth_element(_RAIter, _RAIter, _RAIter, _Compare);
template<typename _RAIter>
void
nth_element(_RAIter, _RAIter, _RAIter);
template<typename _RAIter, typename _Compare>
void
partial_sort(_RAIter, _RAIter, _RAIter, _Compare,
__gnu_parallel::sequential_tag);
template<typename _RAIter>
void
partial_sort(_RAIter, _RAIter, _RAIter, __gnu_parallel::sequential_tag);
template<typename _RAIter, typename _Compare>
void
partial_sort(_RAIter, _RAIter, _RAIter, _Compare);
template<typename _RAIter>
void
partial_sort(_RAIter, _RAIter, _RAIter);
template<typename _FIter, typename _Predicate>
_FIter
partition(_FIter, _FIter, _Predicate, __gnu_parallel::sequential_tag);
template<typename _FIter, typename _Predicate>
_FIter
partition(_FIter, _FIter, _Predicate);
template<typename _FIter, typename _Predicate, typename _IterTag>
_FIter
__partition_switch(_FIter, _FIter, _Predicate, _IterTag);
template<typename _RAIter, typename _Predicate>
_RAIter
__partition_switch(
_RAIter, _RAIter, _Predicate, random_access_iterator_tag);
template<typename _RAIter>
void
random_shuffle(_RAIter, _RAIter, __gnu_parallel::sequential_tag);
template<typename _RAIter, typename _RandomNumberGenerator>
void
random_shuffle(_RAIter, _RAIter, _RandomNumberGenerator&,
__gnu_parallel::sequential_tag);
template<typename _RAIter>
void
random_shuffle(_RAIter, _RAIter);
template<typename _RAIter, typename _RandomNumberGenerator>
void
random_shuffle(_RAIter, _RAIter,
#if __cplusplus >= 201103L
_RandomNumberGenerator&&);
#else
_RandomNumberGenerator&);
#endif
template<typename _IIter1, typename _IIter2, typename _OIter>
_OIter
set_union(_IIter1, _IIter1, _IIter2, _IIter2, _OIter,
__gnu_parallel::sequential_tag);
template<typename _IIter1, typename _IIter2, typename _OIter,
typename _Predicate>
_OIter
set_union(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Predicate,
__gnu_parallel::sequential_tag);
template<typename _IIter1, typename _IIter2, typename _OIter>
_OIter
set_union(_IIter1, _IIter1, _IIter2, _IIter2, _OIter);
template<typename _IIter1, typename _IIter2, typename _OIter,
typename _Predicate>
_OIter
set_union(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Predicate);
template<typename _IIter1, typename _IIter2, typename _Predicate,
typename _OIter, typename _IterTag1, typename _IterTag2,
typename _IterTag3>
_OIter
__set_union_switch(_IIter1, _IIter1, _IIter2, _IIter2, _OIter,
_Predicate, _IterTag1, _IterTag2, _IterTag3);
template<typename _RAIter1, typename _RAIter2, typename _Output_RAIter,
typename _Predicate>
_Output_RAIter
__set_union_switch(_RAIter1, _RAIter1, _RAIter2, _RAIter2, _Output_RAIter,
_Predicate, random_access_iterator_tag,
random_access_iterator_tag, random_access_iterator_tag);
template<typename _IIter1, typename _IIter2, typename _OIter>
_OIter
set_intersection(_IIter1, _IIter1, _IIter2, _IIter2, _OIter,
__gnu_parallel::sequential_tag);
template<typename _IIter1, typename _IIter2, typename _OIter,
typename _Predicate>
_OIter
set_intersection(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Predicate,
__gnu_parallel::sequential_tag);
template<typename _IIter1, typename _IIter2, typename _OIter>
_OIter
set_intersection(_IIter1, _IIter1, _IIter2, _IIter2, _OIter);
template<typename _IIter1, typename _IIter2, typename _OIter,
typename _Predicate>
_OIter
set_intersection(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Predicate);
template<typename _IIter1, typename _IIter2, typename _Predicate,
typename _OIter, typename _IterTag1, typename _IterTag2,
typename _IterTag3>
_OIter
__set_intersection_switch(_IIter1, _IIter1, _IIter2, _IIter2, _OIter,
_Predicate, _IterTag1, _IterTag2, _IterTag3);
template<typename _RAIter1, typename _RAIter2, typename _Output_RAIter,
typename _Predicate>
_Output_RAIter
__set_intersection_switch(_RAIter1, _RAIter1, _RAIter2, _RAIter2,
_Output_RAIter, _Predicate,
random_access_iterator_tag,
random_access_iterator_tag,
random_access_iterator_tag);
template<typename _IIter1, typename _IIter2, typename _OIter>
_OIter
set_symmetric_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter,
__gnu_parallel::sequential_tag);
template<typename _IIter1, typename _IIter2, typename _OIter,
typename _Predicate>
_OIter
set_symmetric_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter,
_Predicate, __gnu_parallel::sequential_tag);
template<typename _IIter1, typename _IIter2, typename _OIter>
_OIter
set_symmetric_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter);
template<typename _IIter1, typename _IIter2, typename _OIter,
typename _Predicate>
_OIter
set_symmetric_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter,
_Predicate);
template<typename _IIter1, typename _IIter2, typename _Predicate,
typename _OIter, typename _IterTag1, typename _IterTag2,
typename _IterTag3>
_OIter
__set_symmetric_difference_switch(_IIter1, _IIter1, _IIter2, _IIter2,
_OIter, _Predicate, _IterTag1, _IterTag2,
_IterTag3);
template<typename _RAIter1, typename _RAIter2, typename _Output_RAIter,
typename _Predicate>
_Output_RAIter
__set_symmetric_difference_switch(_RAIter1, _RAIter1, _RAIter2, _RAIter2,
_Output_RAIter, _Predicate,
random_access_iterator_tag,
random_access_iterator_tag,
random_access_iterator_tag);
template<typename _IIter1, typename _IIter2, typename _OIter>
_OIter
set_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter,
__gnu_parallel::sequential_tag);
template<typename _IIter1, typename _IIter2, typename _OIter,
typename _Predicate>
_OIter
set_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Predicate,
__gnu_parallel::sequential_tag);
template<typename _IIter1, typename _IIter2, typename _OIter>
_OIter
set_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter);
template<typename _IIter1, typename _IIter2, typename _OIter,
typename _Predicate>
_OIter
set_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Predicate);
template<typename _IIter1, typename _IIter2, typename _Predicate,
typename _OIter, typename _IterTag1, typename _IterTag2,
typename _IterTag3>
_OIter
__set_difference_switch(_IIter1, _IIter1, _IIter2, _IIter2, _OIter,
_Predicate, _IterTag1, _IterTag2, _IterTag3);
template<typename _RAIter1, typename _RAIter2, typename _Output_RAIter,
typename _Predicate>
_Output_RAIter
__set_difference_switch(_RAIter1, _RAIter1, _RAIter2, _RAIter2,
_Output_RAIter, _Predicate,
random_access_iterator_tag,
random_access_iterator_tag,
random_access_iterator_tag);
template<typename _RAIter>
void
sort(_RAIter, _RAIter, __gnu_parallel::sequential_tag);
template<typename _RAIter, typename _Compare>
void
sort(_RAIter, _RAIter, _Compare, __gnu_parallel::sequential_tag);
template<typename _RAIter>
void
sort(_RAIter, _RAIter);
template<typename _RAIter, typename _Compare>
void
sort(_RAIter, _RAIter, _Compare);
template<typename _RAIter>
void
stable_sort(_RAIter, _RAIter, __gnu_parallel::sequential_tag);
template<typename _RAIter, typename _Compare>
void
stable_sort(_RAIter, _RAIter, _Compare, __gnu_parallel::sequential_tag);
template<typename _RAIter>
void
stable_sort(_RAIter, _RAIter);
template<typename _RAIter, typename _Compare>
void
stable_sort(_RAIter, _RAIter, _Compare);
template<typename _IIter, typename _OIter>
_OIter
unique_copy(_IIter, _IIter, _OIter, __gnu_parallel::sequential_tag);
template<typename _IIter, typename _OIter, typename _Predicate>
_OIter
unique_copy(_IIter, _IIter, _OIter, _Predicate,
__gnu_parallel::sequential_tag);
template<typename _IIter, typename _OIter>
_OIter
unique_copy(_IIter, _IIter, _OIter);
template<typename _IIter, typename _OIter, typename _Predicate>
_OIter
unique_copy(_IIter, _IIter, _OIter, _Predicate);
template<typename _IIter, typename _OIter, typename _Predicate,
typename _IterTag1, typename _IterTag2>
_OIter
__unique_copy_switch(_IIter, _IIter, _OIter, _Predicate,
_IterTag1, _IterTag2);
template<typename _RAIter, typename _RandomAccess_OIter, typename _Predicate>
_RandomAccess_OIter
__unique_copy_switch(_RAIter, _RAIter, _RandomAccess_OIter, _Predicate,
random_access_iterator_tag, random_access_iterator_tag);
} // end namespace __parallel
} // end namespace std
#endif /* _GLIBCXX_PARALLEL_ALGORITHMFWD_H */
c++/8/parallel/partial_sum.h 0000644 00000016462 15201526705 0011564 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/partial_sum.h
* @brief Parallel implementation of std::partial_sum(), i.e. prefix
* sums.
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Johannes Singler.
#ifndef _GLIBCXX_PARALLEL_PARTIAL_SUM_H
#define _GLIBCXX_PARALLEL_PARTIAL_SUM_H 1
#include <omp.h>
#include <new>
#include <bits/stl_algobase.h>
#include <parallel/parallel.h>
#include <parallel/numericfwd.h>
namespace __gnu_parallel
{
// Problem: there is no 0-element given.
/** @brief Base case prefix sum routine.
* @param __begin Begin iterator of input sequence.
* @param __end End iterator of input sequence.
* @param __result Begin iterator of output sequence.
* @param __bin_op Associative binary function.
* @param __value Start value. Must be passed since the neutral
* element is unknown in general.
* @return End iterator of output sequence. */
template<typename _IIter,
typename _OutputIterator,
typename _BinaryOperation>
_OutputIterator
__parallel_partial_sum_basecase(_IIter __begin, _IIter __end,
_OutputIterator __result,
_BinaryOperation __bin_op,
typename std::iterator_traits <_IIter>::value_type __value)
{
if (__begin == __end)
return __result;
while (__begin != __end)
{
__value = __bin_op(__value, *__begin);
*__result = __value;
++__result;
++__begin;
}
return __result;
}
/** @brief Parallel partial sum implementation, two-phase approach,
no recursion.
* @param __begin Begin iterator of input sequence.
* @param __end End iterator of input sequence.
* @param __result Begin iterator of output sequence.
* @param __bin_op Associative binary function.
* @param __n Length of sequence.
* @return End iterator of output sequence.
*/
template<typename _IIter,
typename _OutputIterator,
typename _BinaryOperation>
_OutputIterator
__parallel_partial_sum_linear(_IIter __begin, _IIter __end,
_OutputIterator __result,
_BinaryOperation __bin_op,
typename std::iterator_traits<_IIter>::difference_type __n)
{
typedef std::iterator_traits<_IIter> _TraitsType;
typedef typename _TraitsType::value_type _ValueType;
typedef typename _TraitsType::difference_type _DifferenceType;
if (__begin == __end)
return __result;
_ThreadIndex __num_threads =
std::min<_DifferenceType>(__get_max_threads(), __n - 1);
if (__num_threads < 2)
{
*__result = *__begin;
return __parallel_partial_sum_basecase(__begin + 1, __end,
__result + 1, __bin_op,
*__begin);
}
_DifferenceType* __borders;
_ValueType* __sums;
const _Settings& __s = _Settings::get();
# pragma omp parallel num_threads(__num_threads)
{
# pragma omp single
{
__num_threads = omp_get_num_threads();
__borders = new _DifferenceType[__num_threads + 2];
if (__s.partial_sum_dilation == 1.0f)
__equally_split(__n, __num_threads + 1, __borders);
else
{
_DifferenceType __first_part_length =
std::max<_DifferenceType>(1,
__n / (1.0f + __s.partial_sum_dilation * __num_threads));
_DifferenceType __chunk_length =
(__n - __first_part_length) / __num_threads;
_DifferenceType __borderstart =
__n - __num_threads * __chunk_length;
__borders[0] = 0;
for (_ThreadIndex __i = 1; __i < (__num_threads + 1); ++__i)
{
__borders[__i] = __borderstart;
__borderstart += __chunk_length;
}
__borders[__num_threads + 1] = __n;
}
__sums = static_cast<_ValueType*>(::operator new(sizeof(_ValueType)
* __num_threads));
_OutputIterator __target_end;
} //single
_ThreadIndex __iam = omp_get_thread_num();
if (__iam == 0)
{
*__result = *__begin;
__parallel_partial_sum_basecase(__begin + 1,
__begin + __borders[1],
__result + 1,
__bin_op, *__begin);
::new(&(__sums[__iam])) _ValueType(*(__result + __borders[1] - 1));
}
else
{
::new(&(__sums[__iam]))
_ValueType(__gnu_parallel::accumulate(
__begin + __borders[__iam] + 1,
__begin + __borders[__iam + 1],
*(__begin + __borders[__iam]),
__bin_op,
__gnu_parallel::sequential_tag()));
}
# pragma omp barrier
# pragma omp single
__parallel_partial_sum_basecase(__sums + 1, __sums + __num_threads,
__sums + 1, __bin_op, __sums[0]);
# pragma omp barrier
// Still same team.
__parallel_partial_sum_basecase(__begin + __borders[__iam + 1],
__begin + __borders[__iam + 2],
__result + __borders[__iam + 1],
__bin_op, __sums[__iam]);
} //parallel
for (_ThreadIndex __i = 0; __i < __num_threads; ++__i)
__sums[__i].~_ValueType();
::operator delete(__sums);
delete[] __borders;
return __result + __n;
}
/** @brief Parallel partial sum front-__end.
* @param __begin Begin iterator of input sequence.
* @param __end End iterator of input sequence.
* @param __result Begin iterator of output sequence.
* @param __bin_op Associative binary function.
* @return End iterator of output sequence. */
template<typename _IIter,
typename _OutputIterator,
typename _BinaryOperation>
_OutputIterator
__parallel_partial_sum(_IIter __begin, _IIter __end,
_OutputIterator __result, _BinaryOperation __bin_op)
{
_GLIBCXX_CALL(__begin - __end)
typedef std::iterator_traits<_IIter> _TraitsType;
typedef typename _TraitsType::value_type _ValueType;
typedef typename _TraitsType::difference_type _DifferenceType;
_DifferenceType __n = __end - __begin;
switch (_Settings::get().partial_sum_algorithm)
{
case LINEAR:
// Need an initial offset.
return __parallel_partial_sum_linear(__begin, __end, __result,
__bin_op, __n);
default:
// Partial_sum algorithm not implemented.
_GLIBCXX_PARALLEL_ASSERT(0);
return __result + __n;
}
}
}
#endif /* _GLIBCXX_PARALLEL_PARTIAL_SUM_H */
c++/8/parallel/numeric 0000644 00000050355 15201526705 0010457 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/**
* @file parallel/numeric
*
* @brief Parallel STL function calls corresponding to stl_numeric.h.
* The functions defined here mainly do case switches and
* call the actual parallelized versions in other files.
* Inlining policy: Functions that basically only contain one function call,
* are declared inline.
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Johannes Singler and Felix Putze.
#ifndef _GLIBCXX_PARALLEL_NUMERIC_H
#define _GLIBCXX_PARALLEL_NUMERIC_H 1
#include <numeric>
#include <bits/stl_function.h>
#include <parallel/numericfwd.h>
#include <parallel/iterator.h>
#include <parallel/for_each.h>
#include <parallel/for_each_selectors.h>
#include <parallel/partial_sum.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __parallel
{
// Sequential fallback.
template<typename _IIter, typename _Tp>
inline _Tp
accumulate(_IIter __begin, _IIter __end, _Tp __init,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::accumulate(__begin, __end, __init); }
template<typename _IIter, typename _Tp, typename _BinaryOperation>
inline _Tp
accumulate(_IIter __begin, _IIter __end, _Tp __init,
_BinaryOperation __binary_op, __gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::accumulate(__begin, __end, __init, __binary_op); }
// Sequential fallback for input iterator case.
template<typename _IIter, typename _Tp, typename _IteratorTag>
inline _Tp
__accumulate_switch(_IIter __begin, _IIter __end,
_Tp __init, _IteratorTag)
{ return accumulate(__begin, __end, __init,
__gnu_parallel::sequential_tag()); }
template<typename _IIter, typename _Tp, typename _BinaryOperation,
typename _IteratorTag>
inline _Tp
__accumulate_switch(_IIter __begin, _IIter __end, _Tp __init,
_BinaryOperation __binary_op, _IteratorTag)
{ return accumulate(__begin, __end, __init, __binary_op,
__gnu_parallel::sequential_tag()); }
// Parallel algorithm for random access iterators.
template<typename __RAIter, typename _Tp, typename _BinaryOperation>
_Tp
__accumulate_switch(__RAIter __begin, __RAIter __end,
_Tp __init, _BinaryOperation __binary_op,
random_access_iterator_tag,
__gnu_parallel::_Parallelism __parallelism_tag)
{
if (_GLIBCXX_PARALLEL_CONDITION(
static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin)
>= __gnu_parallel::_Settings::get().accumulate_minimal_n
&& __gnu_parallel::__is_parallel(__parallelism_tag)))
{
_Tp __res = __init;
__gnu_parallel::__accumulate_selector<__RAIter>
__my_selector;
__gnu_parallel::
__for_each_template_random_access_ed(__begin, __end,
__gnu_parallel::_Nothing(),
__my_selector,
__gnu_parallel::
__accumulate_binop_reduct
<_BinaryOperation>(__binary_op),
__res, __res, -1);
return __res;
}
else
return accumulate(__begin, __end, __init, __binary_op,
__gnu_parallel::sequential_tag());
}
// Public interface.
template<typename _IIter, typename _Tp>
inline _Tp
accumulate(_IIter __begin, _IIter __end, _Tp __init,
__gnu_parallel::_Parallelism __parallelism_tag)
{
typedef std::iterator_traits<_IIter> _IteratorTraits;
typedef typename _IteratorTraits::value_type _ValueType;
typedef typename _IteratorTraits::iterator_category _IteratorCategory;
return __accumulate_switch(__begin, __end, __init,
__gnu_parallel::_Plus<_Tp, _ValueType>(),
_IteratorCategory(), __parallelism_tag);
}
template<typename _IIter, typename _Tp>
inline _Tp
accumulate(_IIter __begin, _IIter __end, _Tp __init)
{
typedef std::iterator_traits<_IIter> _IteratorTraits;
typedef typename _IteratorTraits::value_type _ValueType;
typedef typename _IteratorTraits::iterator_category _IteratorCategory;
return __accumulate_switch(__begin, __end, __init,
__gnu_parallel::_Plus<_Tp, _ValueType>(),
_IteratorCategory());
}
template<typename _IIter, typename _Tp, typename _BinaryOperation>
inline _Tp
accumulate(_IIter __begin, _IIter __end, _Tp __init,
_BinaryOperation __binary_op,
__gnu_parallel::_Parallelism __parallelism_tag)
{
typedef iterator_traits<_IIter> _IteratorTraits;
typedef typename _IteratorTraits::iterator_category _IteratorCategory;
return __accumulate_switch(__begin, __end, __init, __binary_op,
_IteratorCategory(), __parallelism_tag);
}
template<typename _IIter, typename _Tp, typename _BinaryOperation>
inline _Tp
accumulate(_IIter __begin, _IIter __end, _Tp __init,
_BinaryOperation __binary_op)
{
typedef iterator_traits<_IIter> _IteratorTraits;
typedef typename _IteratorTraits::iterator_category _IteratorCategory;
return __accumulate_switch(__begin, __end, __init, __binary_op,
_IteratorCategory());
}
// Sequential fallback.
template<typename _IIter1, typename _IIter2, typename _Tp>
inline _Tp
inner_product(_IIter1 __first1, _IIter1 __last1,
_IIter2 __first2, _Tp __init,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::inner_product(
__first1, __last1, __first2, __init); }
template<typename _IIter1, typename _IIter2, typename _Tp,
typename _BinaryFunction1, typename _BinaryFunction2>
inline _Tp
inner_product(_IIter1 __first1, _IIter1 __last1,
_IIter2 __first2, _Tp __init, _BinaryFunction1 __binary_op1,
_BinaryFunction2 __binary_op2,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::inner_product(__first1, __last1, __first2, __init,
__binary_op1, __binary_op2); }
// Parallel algorithm for random access iterators.
template<typename _RAIter1, typename _RAIter2,
typename _Tp, typename _BinaryFunction1, typename _BinaryFunction2>
_Tp
__inner_product_switch(_RAIter1 __first1,
_RAIter1 __last1,
_RAIter2 __first2, _Tp __init,
_BinaryFunction1 __binary_op1,
_BinaryFunction2 __binary_op2,
random_access_iterator_tag,
random_access_iterator_tag,
__gnu_parallel::_Parallelism __parallelism_tag)
{
if (_GLIBCXX_PARALLEL_CONDITION((__last1 - __first1)
>= __gnu_parallel::_Settings::get().
accumulate_minimal_n
&& __gnu_parallel::
__is_parallel(__parallelism_tag)))
{
_Tp __res = __init;
__gnu_parallel::
__inner_product_selector<_RAIter1,
_RAIter2, _Tp> __my_selector(__first1, __first2);
__gnu_parallel::
__for_each_template_random_access_ed(
__first1, __last1, __binary_op2, __my_selector, __binary_op1,
__res, __res, -1);
return __res;
}
else
return inner_product(__first1, __last1, __first2, __init,
__gnu_parallel::sequential_tag());
}
// No parallelism for input iterators.
template<typename _IIter1, typename _IIter2, typename _Tp,
typename _BinaryFunction1, typename _BinaryFunction2,
typename _IteratorTag1, typename _IteratorTag2>
inline _Tp
__inner_product_switch(_IIter1 __first1, _IIter1 __last1,
_IIter2 __first2, _Tp __init,
_BinaryFunction1 __binary_op1,
_BinaryFunction2 __binary_op2,
_IteratorTag1, _IteratorTag2)
{ return inner_product(__first1, __last1, __first2, __init, __binary_op1,
__binary_op2, __gnu_parallel::sequential_tag()); }
template<typename _IIter1, typename _IIter2, typename _Tp,
typename _BinaryFunction1, typename _BinaryFunction2>
inline _Tp
inner_product(_IIter1 __first1, _IIter1 __last1,
_IIter2 __first2, _Tp __init, _BinaryFunction1 __binary_op1,
_BinaryFunction2 __binary_op2,
__gnu_parallel::_Parallelism __parallelism_tag)
{
typedef iterator_traits<_IIter1> _TraitsType1;
typedef typename _TraitsType1::iterator_category _IteratorCategory1;
typedef iterator_traits<_IIter2> _TraitsType2;
typedef typename _TraitsType2::iterator_category _IteratorCategory2;
return __inner_product_switch(__first1, __last1, __first2, __init,
__binary_op1, __binary_op2,
_IteratorCategory1(), _IteratorCategory2(),
__parallelism_tag);
}
template<typename _IIter1, typename _IIter2, typename _Tp,
typename _BinaryFunction1, typename _BinaryFunction2>
inline _Tp
inner_product(_IIter1 __first1, _IIter1 __last1,
_IIter2 __first2, _Tp __init, _BinaryFunction1 __binary_op1,
_BinaryFunction2 __binary_op2)
{
typedef iterator_traits<_IIter1> _TraitsType1;
typedef typename _TraitsType1::iterator_category _IteratorCategory1;
typedef iterator_traits<_IIter2> _TraitsType2;
typedef typename _TraitsType2::iterator_category _IteratorCategory2;
return __inner_product_switch(__first1, __last1, __first2, __init,
__binary_op1, __binary_op2,
_IteratorCategory1(),
_IteratorCategory2());
}
template<typename _IIter1, typename _IIter2, typename _Tp>
inline _Tp
inner_product(_IIter1 __first1, _IIter1 __last1,
_IIter2 __first2, _Tp __init,
__gnu_parallel::_Parallelism __parallelism_tag)
{
typedef iterator_traits<_IIter1> _TraitsType1;
typedef typename _TraitsType1::value_type _ValueType1;
typedef iterator_traits<_IIter2> _TraitsType2;
typedef typename _TraitsType2::value_type _ValueType2;
typedef typename
__gnu_parallel::_Multiplies<_ValueType1, _ValueType2>::result_type
_MultipliesResultType;
return __gnu_parallel::inner_product(__first1, __last1, __first2, __init,
__gnu_parallel::_Plus<_Tp, _MultipliesResultType>(),
__gnu_parallel::
_Multiplies<_ValueType1, _ValueType2>(),
__parallelism_tag);
}
template<typename _IIter1, typename _IIter2, typename _Tp>
inline _Tp
inner_product(_IIter1 __first1, _IIter1 __last1,
_IIter2 __first2, _Tp __init)
{
typedef iterator_traits<_IIter1> _TraitsType1;
typedef typename _TraitsType1::value_type _ValueType1;
typedef iterator_traits<_IIter2> _TraitsType2;
typedef typename _TraitsType2::value_type _ValueType2;
typedef typename
__gnu_parallel::_Multiplies<_ValueType1, _ValueType2>::result_type
_MultipliesResultType;
return __gnu_parallel::inner_product(__first1, __last1, __first2, __init,
__gnu_parallel::_Plus<_Tp, _MultipliesResultType>(),
__gnu_parallel::
_Multiplies<_ValueType1, _ValueType2>());
}
// Sequential fallback.
template<typename _IIter, typename _OutputIterator>
inline _OutputIterator
partial_sum(_IIter __begin, _IIter __end, _OutputIterator __result,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::partial_sum(__begin, __end, __result); }
// Sequential fallback.
template<typename _IIter, typename _OutputIterator,
typename _BinaryOperation>
inline _OutputIterator
partial_sum(_IIter __begin, _IIter __end, _OutputIterator __result,
_BinaryOperation __bin_op, __gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::partial_sum(__begin, __end, __result, __bin_op); }
// Sequential fallback for input iterator case.
template<typename _IIter, typename _OutputIterator,
typename _BinaryOperation, typename _IteratorTag1,
typename _IteratorTag2>
inline _OutputIterator
__partial_sum_switch(_IIter __begin, _IIter __end,
_OutputIterator __result, _BinaryOperation __bin_op,
_IteratorTag1, _IteratorTag2)
{ return _GLIBCXX_STD_A::partial_sum(__begin, __end, __result, __bin_op); }
// Parallel algorithm for random access iterators.
template<typename _IIter, typename _OutputIterator,
typename _BinaryOperation>
_OutputIterator
__partial_sum_switch(_IIter __begin, _IIter __end,
_OutputIterator __result, _BinaryOperation __bin_op,
random_access_iterator_tag,
random_access_iterator_tag)
{
if (_GLIBCXX_PARALLEL_CONDITION(
static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin)
>= __gnu_parallel::_Settings::get().partial_sum_minimal_n))
return __gnu_parallel::__parallel_partial_sum(__begin, __end,
__result, __bin_op);
else
return partial_sum(__begin, __end, __result, __bin_op,
__gnu_parallel::sequential_tag());
}
// Public interface.
template<typename _IIter, typename _OutputIterator>
inline _OutputIterator
partial_sum(_IIter __begin, _IIter __end, _OutputIterator __result)
{
typedef typename iterator_traits<_IIter>::value_type _ValueType;
return __gnu_parallel::partial_sum(__begin, __end,
__result, std::plus<_ValueType>());
}
// Public interface
template<typename _IIter, typename _OutputIterator,
typename _BinaryOperation>
inline _OutputIterator
partial_sum(_IIter __begin, _IIter __end, _OutputIterator __result,
_BinaryOperation __binary_op)
{
typedef iterator_traits<_IIter> _ITraitsType;
typedef typename _ITraitsType::iterator_category _IIteratorCategory;
typedef iterator_traits<_OutputIterator> _OTraitsType;
typedef typename _OTraitsType::iterator_category _OIterCategory;
return __partial_sum_switch(__begin, __end, __result, __binary_op,
_IIteratorCategory(), _OIterCategory());
}
// Sequential fallback.
template<typename _IIter, typename _OutputIterator>
inline _OutputIterator
adjacent_difference(_IIter __begin, _IIter __end, _OutputIterator __result,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::adjacent_difference(__begin, __end, __result); }
// Sequential fallback.
template<typename _IIter, typename _OutputIterator,
typename _BinaryOperation>
inline _OutputIterator
adjacent_difference(_IIter __begin, _IIter __end,
_OutputIterator __result, _BinaryOperation __bin_op,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_A::adjacent_difference(__begin, __end,
__result, __bin_op); }
// Sequential fallback for input iterator case.
template<typename _IIter, typename _OutputIterator,
typename _BinaryOperation, typename _IteratorTag1,
typename _IteratorTag2>
inline _OutputIterator
__adjacent_difference_switch(_IIter __begin, _IIter __end,
_OutputIterator __result,
_BinaryOperation __bin_op, _IteratorTag1,
_IteratorTag2)
{ return adjacent_difference(__begin, __end, __result, __bin_op,
__gnu_parallel::sequential_tag()); }
// Parallel algorithm for random access iterators.
template<typename _IIter, typename _OutputIterator,
typename _BinaryOperation>
_OutputIterator
__adjacent_difference_switch(_IIter __begin, _IIter __end,
_OutputIterator __result,
_BinaryOperation __bin_op,
random_access_iterator_tag,
random_access_iterator_tag,
__gnu_parallel::_Parallelism
__parallelism_tag)
{
if (_GLIBCXX_PARALLEL_CONDITION(
static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin)
>= __gnu_parallel::_Settings::get().adjacent_difference_minimal_n
&& __gnu_parallel::__is_parallel(__parallelism_tag)))
{
bool __dummy = true;
typedef __gnu_parallel::_IteratorPair<_IIter, _OutputIterator,
random_access_iterator_tag> _ItTrip;
*__result = *__begin;
_ItTrip __begin_pair(__begin + 1, __result + 1),
__end_pair(__end, __result + (__end - __begin));
__gnu_parallel::__adjacent_difference_selector<_ItTrip>
__functionality;
__gnu_parallel::
__for_each_template_random_access_ed(
__begin_pair, __end_pair, __bin_op, __functionality,
__gnu_parallel::_DummyReduct(), __dummy, __dummy, -1);
return __functionality._M_finish_iterator;
}
else
return adjacent_difference(__begin, __end, __result, __bin_op,
__gnu_parallel::sequential_tag());
}
// Public interface.
template<typename _IIter, typename _OutputIterator>
inline _OutputIterator
adjacent_difference(_IIter __begin, _IIter __end,
_OutputIterator __result,
__gnu_parallel::_Parallelism __parallelism_tag)
{
typedef iterator_traits<_IIter> _TraitsType;
typedef typename _TraitsType::value_type _ValueType;
return adjacent_difference(__begin, __end, __result,
std::minus<_ValueType>(),
__parallelism_tag);
}
template<typename _IIter, typename _OutputIterator>
inline _OutputIterator
adjacent_difference(_IIter __begin, _IIter __end,
_OutputIterator __result)
{
typedef iterator_traits<_IIter> _TraitsType;
typedef typename _TraitsType::value_type _ValueType;
return adjacent_difference(__begin, __end, __result,
std::minus<_ValueType>());
}
template<typename _IIter, typename _OutputIterator,
typename _BinaryOperation>
inline _OutputIterator
adjacent_difference(_IIter __begin, _IIter __end,
_OutputIterator __result, _BinaryOperation __binary_op,
__gnu_parallel::_Parallelism __parallelism_tag)
{
typedef iterator_traits<_IIter> _ITraitsType;
typedef typename _ITraitsType::iterator_category _IIteratorCategory;
typedef iterator_traits<_OutputIterator> _OTraitsType;
typedef typename _OTraitsType::iterator_category _OIterCategory;
return __adjacent_difference_switch(__begin, __end, __result,
__binary_op,
_IIteratorCategory(),
_OIterCategory(),
__parallelism_tag);
}
template<typename _IIter, typename _OutputIterator,
typename _BinaryOperation>
inline _OutputIterator
adjacent_difference(_IIter __begin, _IIter __end,
_OutputIterator __result, _BinaryOperation __binary_op)
{
typedef iterator_traits<_IIter> _ITraitsType;
typedef typename _ITraitsType::iterator_category _IIteratorCategory;
typedef iterator_traits<_OutputIterator> _OTraitsType;
typedef typename _OTraitsType::iterator_category _OIterCategory;
return __adjacent_difference_switch(__begin, __end, __result,
__binary_op,
_IIteratorCategory(),
_OIterCategory());
}
} // end namespace
} // end namespace
#endif /* _GLIBCXX_NUMERIC_H */
c++/8/parallel/find_selectors.h 0000644 00000015520 15201526705 0012241 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/find_selectors.h
* @brief _Function objects representing different tasks to be plugged
* into the parallel find algorithm.
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Felix Putze.
#ifndef _GLIBCXX_PARALLEL_FIND_SELECTORS_H
#define _GLIBCXX_PARALLEL_FIND_SELECTORS_H 1
#include <parallel/tags.h>
#include <parallel/basic_iterator.h>
#include <bits/stl_pair.h>
namespace __gnu_parallel
{
/** @brief Base class of all __gnu_parallel::__find_template selectors. */
struct __generic_find_selector
{ };
/**
* @brief Test predicate on a single element, used for std::find()
* and std::find_if ().
*/
struct __find_if_selector : public __generic_find_selector
{
/** @brief Test on one position.
* @param __i1 _Iterator on first sequence.
* @param __i2 _Iterator on second sequence (unused).
* @param __pred Find predicate.
*/
template<typename _RAIter1, typename _RAIter2,
typename _Pred>
bool
operator()(_RAIter1 __i1, _RAIter2 __i2, _Pred __pred)
{ return __pred(*__i1); }
/** @brief Corresponding sequential algorithm on a sequence.
* @param __begin1 Begin iterator of first sequence.
* @param __end1 End iterator of first sequence.
* @param __begin2 Begin iterator of second sequence.
* @param __pred Find predicate.
*/
template<typename _RAIter1, typename _RAIter2,
typename _Pred>
std::pair<_RAIter1, _RAIter2>
_M_sequential_algorithm(_RAIter1 __begin1,
_RAIter1 __end1,
_RAIter2 __begin2, _Pred __pred)
{ return std::make_pair(find_if(__begin1, __end1, __pred,
sequential_tag()), __begin2); }
};
/** @brief Test predicate on two adjacent elements. */
struct __adjacent_find_selector : public __generic_find_selector
{
/** @brief Test on one position.
* @param __i1 _Iterator on first sequence.
* @param __i2 _Iterator on second sequence (unused).
* @param __pred Find predicate.
*/
template<typename _RAIter1, typename _RAIter2,
typename _Pred>
bool
operator()(_RAIter1 __i1, _RAIter2 __i2, _Pred __pred)
{
// Passed end iterator is one short.
return __pred(*__i1, *(__i1 + 1));
}
/** @brief Corresponding sequential algorithm on a sequence.
* @param __begin1 Begin iterator of first sequence.
* @param __end1 End iterator of first sequence.
* @param __begin2 Begin iterator of second sequence.
* @param __pred Find predicate.
*/
template<typename _RAIter1, typename _RAIter2,
typename _Pred>
std::pair<_RAIter1, _RAIter2>
_M_sequential_algorithm(_RAIter1 __begin1,
_RAIter1 __end1,
_RAIter2 __begin2, _Pred __pred)
{
// Passed end iterator is one short.
_RAIter1 __spot = adjacent_find(__begin1, __end1 + 1,
__pred, sequential_tag());
if (__spot == (__end1 + 1))
__spot = __end1;
return std::make_pair(__spot, __begin2);
}
};
/** @brief Test inverted predicate on a single element. */
struct __mismatch_selector : public __generic_find_selector
{
/**
* @brief Test on one position.
* @param __i1 _Iterator on first sequence.
* @param __i2 _Iterator on second sequence (unused).
* @param __pred Find predicate.
*/
template<typename _RAIter1, typename _RAIter2,
typename _Pred>
bool
operator()(_RAIter1 __i1, _RAIter2 __i2, _Pred __pred)
{ return !__pred(*__i1, *__i2); }
/**
* @brief Corresponding sequential algorithm on a sequence.
* @param __begin1 Begin iterator of first sequence.
* @param __end1 End iterator of first sequence.
* @param __begin2 Begin iterator of second sequence.
* @param __pred Find predicate.
*/
template<typename _RAIter1, typename _RAIter2,
typename _Pred>
std::pair<_RAIter1, _RAIter2>
_M_sequential_algorithm(_RAIter1 __begin1,
_RAIter1 __end1,
_RAIter2 __begin2, _Pred __pred)
{ return mismatch(__begin1, __end1, __begin2,
__pred, sequential_tag()); }
};
/** @brief Test predicate on several elements. */
template<typename _FIterator>
struct __find_first_of_selector : public __generic_find_selector
{
_FIterator _M_begin;
_FIterator _M_end;
explicit __find_first_of_selector(_FIterator __begin,
_FIterator __end)
: _M_begin(__begin), _M_end(__end) { }
/** @brief Test on one position.
* @param __i1 _Iterator on first sequence.
* @param __i2 _Iterator on second sequence (unused).
* @param __pred Find predicate. */
template<typename _RAIter1, typename _RAIter2,
typename _Pred>
bool
operator()(_RAIter1 __i1, _RAIter2 __i2, _Pred __pred)
{
for (_FIterator __pos_in_candidates = _M_begin;
__pos_in_candidates != _M_end; ++__pos_in_candidates)
if (__pred(*__i1, *__pos_in_candidates))
return true;
return false;
}
/** @brief Corresponding sequential algorithm on a sequence.
* @param __begin1 Begin iterator of first sequence.
* @param __end1 End iterator of first sequence.
* @param __begin2 Begin iterator of second sequence.
* @param __pred Find predicate. */
template<typename _RAIter1, typename _RAIter2,
typename _Pred>
std::pair<_RAIter1, _RAIter2>
_M_sequential_algorithm(_RAIter1 __begin1,
_RAIter1 __end1,
_RAIter2 __begin2, _Pred __pred)
{
return std::make_pair(find_first_of(__begin1, __end1,
_M_begin, _M_end, __pred,
sequential_tag()), __begin2);
}
};
}
#endif /* _GLIBCXX_PARALLEL_FIND_SELECTORS_H */
c++/8/parallel/equally_split.h 0000644 00000006434 15201526705 0012131 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/equally_split.h
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Johannes Singler.
#ifndef _GLIBCXX_PARALLEL_EQUALLY_SPLIT_H
#define _GLIBCXX_PARALLEL_EQUALLY_SPLIT_H 1
namespace __gnu_parallel
{
/** @brief function to split a sequence into parts of almost equal size.
*
* The resulting sequence __s of length __num_threads+1 contains the
* splitting positions when splitting the range [0,__n) into parts of
* almost equal size (plus minus 1). The first entry is 0, the last
* one n. There may result empty parts.
* @param __n Number of elements
* @param __num_threads Number of parts
* @param __s Splitters
* @returns End of __splitter sequence, i.e. @c __s+__num_threads+1 */
template<typename _DifferenceType, typename _OutputIterator>
_OutputIterator
__equally_split(_DifferenceType __n, _ThreadIndex __num_threads,
_OutputIterator __s)
{
_DifferenceType __chunk_length = __n / __num_threads;
_DifferenceType __num_longer_chunks = __n % __num_threads;
_DifferenceType __pos = 0;
for (_ThreadIndex __i = 0; __i < __num_threads; ++__i)
{
*__s++ = __pos;
__pos += ((__i < __num_longer_chunks)
? (__chunk_length + 1) : __chunk_length);
}
*__s++ = __n;
return __s;
}
/** @brief function to split a sequence into parts of almost equal size.
*
* Returns the position of the splitting point between
* thread number __thread_no (included) and
* thread number __thread_no+1 (excluded).
* @param __n Number of elements
* @param __num_threads Number of parts
* @param __thread_no Number of threads
* @returns splitting point */
template<typename _DifferenceType>
_DifferenceType
__equally_split_point(_DifferenceType __n,
_ThreadIndex __num_threads,
_ThreadIndex __thread_no)
{
_DifferenceType __chunk_length = __n / __num_threads;
_DifferenceType __num_longer_chunks = __n % __num_threads;
if (__thread_no < __num_longer_chunks)
return __thread_no * (__chunk_length + 1);
else
return __num_longer_chunks * (__chunk_length + 1)
+ (__thread_no - __num_longer_chunks) * __chunk_length;
}
}
#endif /* _GLIBCXX_PARALLEL_EQUALLY_SPLIT_H */
c++/8/parallel/par_loop.h 0000644 00000010710 15201526705 0011045 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/par_loop.h
* @brief Parallelization of embarrassingly parallel execution by
* means of equal splitting.
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Felix Putze.
#ifndef _GLIBCXX_PARALLEL_PAR_LOOP_H
#define _GLIBCXX_PARALLEL_PAR_LOOP_H 1
#include <omp.h>
#include <parallel/settings.h>
#include <parallel/base.h>
#include <parallel/equally_split.h>
namespace __gnu_parallel
{
/** @brief Embarrassingly parallel algorithm for random access
* iterators, using hand-crafted parallelization by equal splitting
* the work.
*
* @param __begin Begin iterator of element sequence.
* @param __end End iterator of element sequence.
* @param __o User-supplied functor (comparator, predicate, adding
* functor, ...)
* @param __f Functor to "process" an element with __op (depends on
* desired functionality, e. g. for std::for_each(), ...).
* @param __r Functor to "add" a single __result to the already
* processed elements (depends on functionality).
* @param __base Base value for reduction.
* @param __output Pointer to position where final result is written to
* @param __bound Maximum number of elements processed (e. g. for
* std::count_n()).
* @return User-supplied functor (that may contain a part of the result).
*/
template<typename _RAIter,
typename _Op,
typename _Fu,
typename _Red,
typename _Result>
_Op
__for_each_template_random_access_ed(_RAIter __begin, _RAIter __end,
_Op __o, _Fu& __f, _Red __r,
_Result __base, _Result& __output,
typename std::iterator_traits<_RAIter>::difference_type __bound)
{
typedef std::iterator_traits<_RAIter> _TraitsType;
typedef typename _TraitsType::difference_type _DifferenceType;
const _DifferenceType __length = __end - __begin;
_Result *__thread_results;
bool* __constructed;
_ThreadIndex __num_threads = __gnu_parallel::min<_DifferenceType>
(__get_max_threads(), __length);
# pragma omp parallel num_threads(__num_threads)
{
# pragma omp single
{
__num_threads = omp_get_num_threads();
__thread_results = static_cast<_Result*>
(::operator new(__num_threads * sizeof(_Result)));
__constructed = new bool[__num_threads];
}
_ThreadIndex __iam = omp_get_thread_num();
// Neutral element.
_Result* __reduct;
_DifferenceType
__start = __equally_split_point(__length, __num_threads, __iam),
__stop = __equally_split_point(__length, __num_threads, __iam + 1);
if (__start < __stop)
{
__reduct = new _Result(__f(__o, __begin + __start));
++__start;
__constructed[__iam] = true;
}
else
__constructed[__iam] = false;
for (; __start < __stop; ++__start)
*__reduct = __r(*__reduct, __f(__o, __begin + __start));
if (__constructed[__iam])
{
::new(&__thread_results[__iam]) _Result(*__reduct);
delete __reduct;
}
} //parallel
for (_ThreadIndex __i = 0; __i < __num_threads; ++__i)
if (__constructed[__i])
{
__output = __r(__output, __thread_results[__i]);
__thread_results[__i].~_Result();
}
// Points to last element processed (needed as return value for
// some algorithms like transform).
__f._M_finish_iterator = __begin + __length;
::operator delete(__thread_results);
delete[] __constructed;
return __o;
}
} // end namespace
#endif /* _GLIBCXX_PARALLEL_PAR_LOOP_H */
c++/8/parallel/sort.h 0000644 00000017035 15201526705 0010230 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/sort.h
* @brief Parallel sorting algorithm switch.
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Johannes Singler.
#ifndef _GLIBCXX_PARALLEL_SORT_H
#define _GLIBCXX_PARALLEL_SORT_H 1
#include <parallel/basic_iterator.h>
#include <parallel/features.h>
#include <parallel/parallel.h>
#if _GLIBCXX_PARALLEL_ASSERTIONS
#include <parallel/checkers.h>
#endif
#if _GLIBCXX_MERGESORT
#include <parallel/multiway_mergesort.h>
#endif
#if _GLIBCXX_QUICKSORT
#include <parallel/quicksort.h>
#endif
#if _GLIBCXX_BAL_QUICKSORT
#include <parallel/balanced_quicksort.h>
#endif
namespace __gnu_parallel
{
//prototype
template<bool __stable, typename _RAIter,
typename _Compare, typename _Parallelism>
void
__parallel_sort(_RAIter __begin, _RAIter __end,
_Compare __comp, _Parallelism __parallelism);
/**
* @brief Choose multiway mergesort, splitting variant at run-time,
* for parallel sorting.
* @param __begin Begin iterator of input sequence.
* @param __end End iterator of input sequence.
* @param __comp Comparator.
* @tparam __stable Sort stable.
* @callgraph
*/
template<bool __stable, typename _RAIter, typename _Compare>
inline void
__parallel_sort(_RAIter __begin, _RAIter __end,
_Compare __comp, multiway_mergesort_tag __parallelism)
{
_GLIBCXX_CALL(__end - __begin)
if(_Settings::get().sort_splitting == EXACT)
parallel_sort_mwms<__stable, true>
(__begin, __end, __comp, __parallelism.__get_num_threads());
else
parallel_sort_mwms<__stable, false>
(__begin, __end, __comp, __parallelism.__get_num_threads());
}
/**
* @brief Choose multiway mergesort with exact splitting,
* for parallel sorting.
* @param __begin Begin iterator of input sequence.
* @param __end End iterator of input sequence.
* @param __comp Comparator.
* @tparam __stable Sort stable.
* @callgraph
*/
template<bool __stable, typename _RAIter, typename _Compare>
inline void
__parallel_sort(_RAIter __begin, _RAIter __end,
_Compare __comp,
multiway_mergesort_exact_tag __parallelism)
{
_GLIBCXX_CALL(__end - __begin)
parallel_sort_mwms<__stable, true>
(__begin, __end, __comp, __parallelism.__get_num_threads());
}
/**
* @brief Choose multiway mergesort with splitting by sampling,
* for parallel sorting.
* @param __begin Begin iterator of input sequence.
* @param __end End iterator of input sequence.
* @param __comp Comparator.
* @tparam __stable Sort stable.
* @callgraph
*/
template<bool __stable, typename _RAIter, typename _Compare>
inline void
__parallel_sort(_RAIter __begin, _RAIter __end,
_Compare __comp,
multiway_mergesort_sampling_tag __parallelism)
{
_GLIBCXX_CALL(__end - __begin)
parallel_sort_mwms<__stable, false>
(__begin, __end, __comp, __parallelism.__get_num_threads());
}
/**
* @brief Choose quicksort for parallel sorting.
* @param __begin Begin iterator of input sequence.
* @param __end End iterator of input sequence.
* @param __comp Comparator.
* @tparam __stable Sort stable.
* @callgraph
*/
template<bool __stable, typename _RAIter, typename _Compare>
inline void
__parallel_sort(_RAIter __begin, _RAIter __end,
_Compare __comp, quicksort_tag __parallelism)
{
_GLIBCXX_CALL(__end - __begin)
_GLIBCXX_PARALLEL_ASSERT(__stable == false);
__parallel_sort_qs(__begin, __end, __comp,
__parallelism.__get_num_threads());
}
/**
* @brief Choose balanced quicksort for parallel sorting.
* @param __begin Begin iterator of input sequence.
* @param __end End iterator of input sequence.
* @param __comp Comparator.
* @tparam __stable Sort stable.
* @callgraph
*/
template<bool __stable, typename _RAIter, typename _Compare>
inline void
__parallel_sort(_RAIter __begin, _RAIter __end,
_Compare __comp, balanced_quicksort_tag __parallelism)
{
_GLIBCXX_CALL(__end - __begin)
_GLIBCXX_PARALLEL_ASSERT(__stable == false);
__parallel_sort_qsb(__begin, __end, __comp,
__parallelism.__get_num_threads());
}
/**
* @brief Choose multiway mergesort with exact splitting,
* for parallel sorting.
* @param __begin Begin iterator of input sequence.
* @param __end End iterator of input sequence.
* @param __comp Comparator.
* @tparam __stable Sort stable.
* @callgraph
*/
template<bool __stable, typename _RAIter, typename _Compare>
inline void
__parallel_sort(_RAIter __begin, _RAIter __end,
_Compare __comp, default_parallel_tag __parallelism)
{
_GLIBCXX_CALL(__end - __begin)
__parallel_sort<__stable>
(__begin, __end, __comp,
multiway_mergesort_exact_tag(__parallelism.__get_num_threads()));
}
/**
* @brief Choose a parallel sorting algorithm.
* @param __begin Begin iterator of input sequence.
* @param __end End iterator of input sequence.
* @param __comp Comparator.
* @tparam __stable Sort stable.
* @callgraph
*/
template<bool __stable, typename _RAIter, typename _Compare>
inline void
__parallel_sort(_RAIter __begin, _RAIter __end,
_Compare __comp, parallel_tag __parallelism)
{
_GLIBCXX_CALL(__end - __begin)
typedef std::iterator_traits<_RAIter> _TraitsType;
typedef typename _TraitsType::value_type _ValueType;
typedef typename _TraitsType::difference_type _DifferenceType;
if (false) ;
#if _GLIBCXX_MERGESORT
else if (__stable || _Settings::get().sort_algorithm == MWMS)
{
if(_Settings::get().sort_splitting == EXACT)
parallel_sort_mwms<__stable, true>
(__begin, __end, __comp, __parallelism.__get_num_threads());
else
parallel_sort_mwms<false, false>
(__begin, __end, __comp, __parallelism.__get_num_threads());
}
#endif
#if _GLIBCXX_QUICKSORT
else if (_Settings::get().sort_algorithm == QS)
__parallel_sort_qs(__begin, __end, __comp,
__parallelism.__get_num_threads());
#endif
#if _GLIBCXX_BAL_QUICKSORT
else if (_Settings::get().sort_algorithm == QS_BALANCED)
__parallel_sort_qsb(__begin, __end, __comp,
__parallelism.__get_num_threads());
#endif
else
__gnu_sequential::sort(__begin, __end, __comp);
}
} // end namespace __gnu_parallel
#endif /* _GLIBCXX_PARALLEL_SORT_H */
c++/8/parallel/random_number.h 0000644 00000010203 15201526705 0012057 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/random_number.h
* @brief Random number generator based on the Mersenne twister.
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Johannes Singler.
#ifndef _GLIBCXX_PARALLEL_RANDOM_NUMBER_H
#define _GLIBCXX_PARALLEL_RANDOM_NUMBER_H 1
#include <parallel/types.h>
#include <tr1/random>
#include <limits>
namespace __gnu_parallel
{
/** @brief Random number generator, based on the Mersenne twister. */
class _RandomNumber
{
private:
std::tr1::mt19937 _M_mt;
uint64_t _M_supremum;
uint64_t _M_rand_sup;
double _M_supremum_reciprocal;
double _M_rand_sup_reciprocal;
// Assumed to be twice as long as the usual random number.
uint64_t __cache;
// Bit results.
int __bits_left;
static uint32_t
__scale_down(uint64_t __x,
#if _GLIBCXX_SCALE_DOWN_FPU
uint64_t /*_M_supremum*/, double _M_supremum_reciprocal)
#else
uint64_t _M_supremum, double /*_M_supremum_reciprocal*/)
#endif
{
#if _GLIBCXX_SCALE_DOWN_FPU
return uint32_t(__x * _M_supremum_reciprocal);
#else
return static_cast<uint32_t>(__x % _M_supremum);
#endif
}
public:
/** @brief Default constructor. Seed with 0. */
_RandomNumber()
: _M_mt(0), _M_supremum(0x100000000ULL),
_M_rand_sup(1ULL << std::numeric_limits<uint32_t>::digits),
_M_supremum_reciprocal(double(_M_supremum) / double(_M_rand_sup)),
_M_rand_sup_reciprocal(1.0 / double(_M_rand_sup)),
__cache(0), __bits_left(0) { }
/** @brief Constructor.
* @param __seed Random __seed.
* @param _M_supremum Generate integer random numbers in the
* interval @c [0,_M_supremum). */
_RandomNumber(uint32_t __seed, uint64_t _M_supremum = 0x100000000ULL)
: _M_mt(__seed), _M_supremum(_M_supremum),
_M_rand_sup(1ULL << std::numeric_limits<uint32_t>::digits),
_M_supremum_reciprocal(double(_M_supremum) / double(_M_rand_sup)),
_M_rand_sup_reciprocal(1.0 / double(_M_rand_sup)),
__cache(0), __bits_left(0) { }
/** @brief Generate unsigned random 32-bit integer. */
uint32_t
operator()()
{ return __scale_down(_M_mt(), _M_supremum, _M_supremum_reciprocal); }
/** @brief Generate unsigned random 32-bit integer in the
interval @c [0,local_supremum). */
uint32_t
operator()(uint64_t local_supremum)
{
return __scale_down(_M_mt(), local_supremum,
double(local_supremum * _M_rand_sup_reciprocal));
}
/** @brief Generate a number of random bits, run-time parameter.
* @param __bits Number of bits to generate. */
unsigned long
__genrand_bits(int __bits)
{
unsigned long __res = __cache & ((1 << __bits) - 1);
__cache = __cache >> __bits;
__bits_left -= __bits;
if (__bits_left < 32)
{
__cache |= ((uint64_t(_M_mt())) << __bits_left);
__bits_left += 32;
}
return __res;
}
};
} // namespace __gnu_parallel
#endif /* _GLIBCXX_PARALLEL_RANDOM_NUMBER_H */
c++/8/parallel/omp_loop_static.h 0000644 00000010010 15201526705 0012416 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/omp_loop_static.h
* @brief Parallelization of embarrassingly parallel execution by
* means of an OpenMP for loop with static scheduling.
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Felix Putze.
#ifndef _GLIBCXX_PARALLEL_OMP_LOOP_STATIC_H
#define _GLIBCXX_PARALLEL_OMP_LOOP_STATIC_H 1
#include <omp.h>
#include <parallel/settings.h>
#include <parallel/basic_iterator.h>
namespace __gnu_parallel
{
/** @brief Embarrassingly parallel algorithm for random access
* iterators, using an OpenMP for loop with static scheduling.
*
* @param __begin Begin iterator of element sequence.
* @param __end End iterator of element sequence.
* @param __o User-supplied functor (comparator, predicate, adding
* functor, ...).
* @param __f Functor to @a process an element with __op (depends on
* desired functionality, e. g. for std::for_each(), ...).
* @param __r Functor to @a add a single __result to the already processed
* __elements (depends on functionality).
* @param __base Base value for reduction.
* @param __output Pointer to position where final result is written to
* @param __bound Maximum number of elements processed (e. g. for
* std::count_n()).
* @return User-supplied functor (that may contain a part of the result).
*/
template<typename _RAIter,
typename _Op,
typename _Fu,
typename _Red,
typename _Result>
_Op
__for_each_template_random_access_omp_loop_static(_RAIter __begin,
_RAIter __end, _Op __o,
_Fu& __f, _Red __r,
_Result __base,
_Result& __output,
typename std::iterator_traits<_RAIter>::difference_type __bound)
{
typedef typename std::iterator_traits<_RAIter>::difference_type
_DifferenceType;
_DifferenceType __length = __end - __begin;
_ThreadIndex __num_threads = std::min<_DifferenceType>
(__get_max_threads(), __length);
_Result *__thread_results;
# pragma omp parallel num_threads(__num_threads)
{
# pragma omp single
{
__num_threads = omp_get_num_threads();
__thread_results = new _Result[__num_threads];
for (_ThreadIndex __i = 0; __i < __num_threads; ++__i)
__thread_results[__i] = _Result();
}
_ThreadIndex __iam = omp_get_thread_num();
#pragma omp for schedule(static, _Settings::get().workstealing_chunk_size)
for (_DifferenceType __pos = 0; __pos < __length; ++__pos)
__thread_results[__iam] = __r(__thread_results[__iam],
__f(__o, __begin+__pos));
} //parallel
for (_ThreadIndex __i = 0; __i < __num_threads; ++__i)
__output = __r(__output, __thread_results[__i]);
delete [] __thread_results;
// Points to last element processed (needed as return value for
// some algorithms like transform).
__f.finish_iterator = __begin + __length;
return __o;
}
} // end namespace
#endif /* _GLIBCXX_PARALLEL_OMP_LOOP_STATIC_H */
c++/8/parallel/find.h 0000644 00000032427 15201526705 0010163 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/find.h
* @brief Parallel implementation base for std::find(), std::equal()
* and related functions.
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Felix Putze and Johannes Singler.
#ifndef _GLIBCXX_PARALLEL_FIND_H
#define _GLIBCXX_PARALLEL_FIND_H 1
#include <bits/stl_algobase.h>
#include <parallel/features.h>
#include <parallel/parallel.h>
#include <parallel/compatibility.h>
#include <parallel/equally_split.h>
namespace __gnu_parallel
{
/**
* @brief Parallel std::find, switch for different algorithms.
* @param __begin1 Begin iterator of first sequence.
* @param __end1 End iterator of first sequence.
* @param __begin2 Begin iterator of second sequence. Must have same
* length as first sequence.
* @param __pred Find predicate.
* @param __selector _Functionality (e. g. std::find_if(), std::equal(),...)
* @return Place of finding in both sequences.
*/
template<typename _RAIter1,
typename _RAIter2,
typename _Pred,
typename _Selector>
inline std::pair<_RAIter1, _RAIter2>
__find_template(_RAIter1 __begin1, _RAIter1 __end1,
_RAIter2 __begin2, _Pred __pred, _Selector __selector)
{
switch (_Settings::get().find_algorithm)
{
case GROWING_BLOCKS:
return __find_template(__begin1, __end1, __begin2, __pred,
__selector, growing_blocks_tag());
case CONSTANT_SIZE_BLOCKS:
return __find_template(__begin1, __end1, __begin2, __pred,
__selector, constant_size_blocks_tag());
case EQUAL_SPLIT:
return __find_template(__begin1, __end1, __begin2, __pred,
__selector, equal_split_tag());
default:
_GLIBCXX_PARALLEL_ASSERT(false);
return std::make_pair(__begin1, __begin2);
}
}
#if _GLIBCXX_FIND_EQUAL_SPLIT
/**
* @brief Parallel std::find, equal splitting variant.
* @param __begin1 Begin iterator of first sequence.
* @param __end1 End iterator of first sequence.
* @param __begin2 Begin iterator of second sequence. Second __sequence
* must have same length as first sequence.
* @param __pred Find predicate.
* @param __selector _Functionality (e. g. std::find_if(), std::equal(),...)
* @return Place of finding in both sequences.
*/
template<typename _RAIter1,
typename _RAIter2,
typename _Pred,
typename _Selector>
std::pair<_RAIter1, _RAIter2>
__find_template(_RAIter1 __begin1, _RAIter1 __end1,
_RAIter2 __begin2, _Pred __pred,
_Selector __selector, equal_split_tag)
{
_GLIBCXX_CALL(__end1 - __begin1)
typedef std::iterator_traits<_RAIter1> _TraitsType;
typedef typename _TraitsType::difference_type _DifferenceType;
typedef typename _TraitsType::value_type _ValueType;
_DifferenceType __length = __end1 - __begin1;
_DifferenceType __result = __length;
_DifferenceType* __borders;
omp_lock_t __result_lock;
omp_init_lock(&__result_lock);
_ThreadIndex __num_threads = __get_max_threads();
# pragma omp parallel num_threads(__num_threads)
{
# pragma omp single
{
__num_threads = omp_get_num_threads();
__borders = new _DifferenceType[__num_threads + 1];
__equally_split(__length, __num_threads, __borders);
} //single
_ThreadIndex __iam = omp_get_thread_num();
_DifferenceType __start = __borders[__iam],
__stop = __borders[__iam + 1];
_RAIter1 __i1 = __begin1 + __start;
_RAIter2 __i2 = __begin2 + __start;
for (_DifferenceType __pos = __start; __pos < __stop; ++__pos)
{
# pragma omp flush(__result)
// Result has been set to something lower.
if (__result < __pos)
break;
if (__selector(__i1, __i2, __pred))
{
omp_set_lock(&__result_lock);
if (__pos < __result)
__result = __pos;
omp_unset_lock(&__result_lock);
break;
}
++__i1;
++__i2;
}
} //parallel
omp_destroy_lock(&__result_lock);
delete[] __borders;
return std::pair<_RAIter1, _RAIter2>(__begin1 + __result,
__begin2 + __result);
}
#endif
#if _GLIBCXX_FIND_GROWING_BLOCKS
/**
* @brief Parallel std::find, growing block size variant.
* @param __begin1 Begin iterator of first sequence.
* @param __end1 End iterator of first sequence.
* @param __begin2 Begin iterator of second sequence. Second __sequence
* must have same length as first sequence.
* @param __pred Find predicate.
* @param __selector _Functionality (e. g. std::find_if(), std::equal(),...)
* @return Place of finding in both sequences.
* @see __gnu_parallel::_Settings::find_sequential_search_size
* @see __gnu_parallel::_Settings::find_scale_factor
*
* There are two main differences between the growing blocks and
* the constant-size blocks variants.
* 1. For GB, the block size grows; for CSB, the block size is fixed.
* 2. For GB, the blocks are allocated dynamically;
* for CSB, the blocks are allocated in a predetermined manner,
* namely spacial round-robin.
*/
template<typename _RAIter1,
typename _RAIter2,
typename _Pred,
typename _Selector>
std::pair<_RAIter1, _RAIter2>
__find_template(_RAIter1 __begin1, _RAIter1 __end1,
_RAIter2 __begin2, _Pred __pred, _Selector __selector,
growing_blocks_tag)
{
_GLIBCXX_CALL(__end1 - __begin1)
typedef std::iterator_traits<_RAIter1> _TraitsType;
typedef typename _TraitsType::difference_type _DifferenceType;
typedef typename _TraitsType::value_type _ValueType;
const _Settings& __s = _Settings::get();
_DifferenceType __length = __end1 - __begin1;
_DifferenceType
__sequential_search_size = std::min<_DifferenceType>
(__length, __s.find_sequential_search_size);
// Try it sequentially first.
std::pair<_RAIter1, _RAIter2>
__find_seq_result = __selector._M_sequential_algorithm
(__begin1, __begin1 + __sequential_search_size,
__begin2, __pred);
if (__find_seq_result.first != (__begin1 + __sequential_search_size))
return __find_seq_result;
// Index of beginning of next free block (after sequential find).
_DifferenceType __next_block_start = __sequential_search_size;
_DifferenceType __result = __length;
omp_lock_t __result_lock;
omp_init_lock(&__result_lock);
const float __scale_factor = __s.find_scale_factor;
_ThreadIndex __num_threads = __get_max_threads();
# pragma omp parallel shared(__result) num_threads(__num_threads)
{
# pragma omp single
__num_threads = omp_get_num_threads();
// Not within first __k elements -> start parallel.
_ThreadIndex __iam = omp_get_thread_num();
_DifferenceType __block_size =
std::max<_DifferenceType>(1, __scale_factor * __next_block_start);
_DifferenceType __start = __fetch_and_add<_DifferenceType>
(&__next_block_start, __block_size);
// Get new block, update pointer to next block.
_DifferenceType __stop =
std::min<_DifferenceType>(__length, __start + __block_size);
std::pair<_RAIter1, _RAIter2> __local_result;
while (__start < __length)
{
# pragma omp flush(__result)
// Get new value of result.
if (__result < __start)
{
// No chance to find first element.
break;
}
__local_result = __selector._M_sequential_algorithm
(__begin1 + __start, __begin1 + __stop,
__begin2 + __start, __pred);
if (__local_result.first != (__begin1 + __stop))
{
omp_set_lock(&__result_lock);
if ((__local_result.first - __begin1) < __result)
{
__result = __local_result.first - __begin1;
// Result cannot be in future blocks, stop algorithm.
__fetch_and_add<_DifferenceType>(&__next_block_start,
__length);
}
omp_unset_lock(&__result_lock);
}
_DifferenceType __block_size =
std::max<_DifferenceType>(1, __scale_factor * __next_block_start);
// Get new block, update pointer to next block.
__start = __fetch_and_add<_DifferenceType>(&__next_block_start,
__block_size);
__stop =
std::min<_DifferenceType>(__length, __start + __block_size);
}
} //parallel
omp_destroy_lock(&__result_lock);
// Return iterator on found element.
return
std::pair<_RAIter1, _RAIter2>(__begin1 + __result,
__begin2 + __result);
}
#endif
#if _GLIBCXX_FIND_CONSTANT_SIZE_BLOCKS
/**
* @brief Parallel std::find, constant block size variant.
* @param __begin1 Begin iterator of first sequence.
* @param __end1 End iterator of first sequence.
* @param __begin2 Begin iterator of second sequence. Second __sequence
* must have same length as first sequence.
* @param __pred Find predicate.
* @param __selector _Functionality (e. g. std::find_if(), std::equal(),...)
* @return Place of finding in both sequences.
* @see __gnu_parallel::_Settings::find_sequential_search_size
* @see __gnu_parallel::_Settings::find_block_size
* There are two main differences between the growing blocks and the
* constant-size blocks variants.
* 1. For GB, the block size grows; for CSB, the block size is fixed.
* 2. For GB, the blocks are allocated dynamically; for CSB, the
* blocks are allocated in a predetermined manner, namely spacial
* round-robin.
*/
template<typename _RAIter1,
typename _RAIter2,
typename _Pred,
typename _Selector>
std::pair<_RAIter1, _RAIter2>
__find_template(_RAIter1 __begin1, _RAIter1 __end1,
_RAIter2 __begin2, _Pred __pred, _Selector __selector,
constant_size_blocks_tag)
{
_GLIBCXX_CALL(__end1 - __begin1)
typedef std::iterator_traits<_RAIter1> _TraitsType;
typedef typename _TraitsType::difference_type _DifferenceType;
typedef typename _TraitsType::value_type _ValueType;
const _Settings& __s = _Settings::get();
_DifferenceType __length = __end1 - __begin1;
_DifferenceType __sequential_search_size = std::min<_DifferenceType>
(__length, __s.find_sequential_search_size);
// Try it sequentially first.
std::pair<_RAIter1, _RAIter2>
__find_seq_result = __selector._M_sequential_algorithm
(__begin1, __begin1 + __sequential_search_size, __begin2, __pred);
if (__find_seq_result.first != (__begin1 + __sequential_search_size))
return __find_seq_result;
_DifferenceType __result = __length;
omp_lock_t __result_lock;
omp_init_lock(&__result_lock);
// Not within first __sequential_search_size elements -> start parallel.
_ThreadIndex __num_threads = __get_max_threads();
# pragma omp parallel shared(__result) num_threads(__num_threads)
{
# pragma omp single
__num_threads = omp_get_num_threads();
_ThreadIndex __iam = omp_get_thread_num();
_DifferenceType __block_size = __s.find_initial_block_size;
// First element of thread's current iteration.
_DifferenceType __iteration_start = __sequential_search_size;
// Where to work (initialization).
_DifferenceType __start = __iteration_start + __iam * __block_size;
_DifferenceType __stop = std::min<_DifferenceType>(__length,
__start
+ __block_size);
std::pair<_RAIter1, _RAIter2> __local_result;
while (__start < __length)
{
// Get new value of result.
# pragma omp flush(__result)
// No chance to find first element.
if (__result < __start)
break;
__local_result = __selector._M_sequential_algorithm
(__begin1 + __start, __begin1 + __stop,
__begin2 + __start, __pred);
if (__local_result.first != (__begin1 + __stop))
{
omp_set_lock(&__result_lock);
if ((__local_result.first - __begin1) < __result)
__result = __local_result.first - __begin1;
omp_unset_lock(&__result_lock);
// Will not find better value in its interval.
break;
}
__iteration_start += __num_threads * __block_size;
// Where to work.
__start = __iteration_start + __iam * __block_size;
__stop = std::min<_DifferenceType>(__length,
__start + __block_size);
}
} //parallel
omp_destroy_lock(&__result_lock);
// Return iterator on found element.
return std::pair<_RAIter1, _RAIter2>(__begin1 + __result,
__begin2 + __result);
}
#endif
} // end namespace
#endif /* _GLIBCXX_PARALLEL_FIND_H */
c++/8/parallel/unique_copy.h 0000644 00000014025 15201526705 0011575 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/unique_copy.h
* @brief Parallel implementations of std::unique_copy().
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Robert Geisberger and Robin Dapp.
#ifndef _GLIBCXX_PARALLEL_UNIQUE_COPY_H
#define _GLIBCXX_PARALLEL_UNIQUE_COPY_H 1
#include <parallel/parallel.h>
#include <parallel/multiseq_selection.h>
namespace __gnu_parallel
{
/** @brief Parallel std::unique_copy(), w/__o explicit equality predicate.
* @param __first Begin iterator of input sequence.
* @param __last End iterator of input sequence.
* @param __result Begin iterator of result __sequence.
* @param __binary_pred Equality predicate.
* @return End iterator of result __sequence. */
template<typename _IIter,
class _OutputIterator,
class _BinaryPredicate>
_OutputIterator
__parallel_unique_copy(_IIter __first, _IIter __last,
_OutputIterator __result,
_BinaryPredicate __binary_pred)
{
_GLIBCXX_CALL(__last - __first)
typedef std::iterator_traits<_IIter> _TraitsType;
typedef typename _TraitsType::value_type _ValueType;
typedef typename _TraitsType::difference_type _DifferenceType;
_DifferenceType __size = __last - __first;
if (__size == 0)
return __result;
// Let the first thread process two parts.
_DifferenceType *__counter;
_DifferenceType *__borders;
_ThreadIndex __num_threads = __get_max_threads();
// First part contains at least one element.
# pragma omp parallel num_threads(__num_threads)
{
# pragma omp single
{
__num_threads = omp_get_num_threads();
__borders = new _DifferenceType[__num_threads + 2];
__equally_split(__size, __num_threads + 1, __borders);
__counter = new _DifferenceType[__num_threads + 1];
}
_ThreadIndex __iam = omp_get_thread_num();
_DifferenceType __begin, __end;
// Check for length without duplicates
// Needed for position in output
_DifferenceType __i = 0;
_OutputIterator __out = __result;
if (__iam == 0)
{
__begin = __borders[0] + 1; // == 1
__end = __borders[__iam + 1];
++__i;
*__out++ = *__first;
for (_IIter __iter = __first + __begin; __iter < __first + __end;
++__iter)
{
if (!__binary_pred(*__iter, *(__iter - 1)))
{
++__i;
*__out++ = *__iter;
}
}
}
else
{
__begin = __borders[__iam]; //one part
__end = __borders[__iam + 1];
for (_IIter __iter = __first + __begin; __iter < __first + __end;
++__iter)
{
if (!__binary_pred(*__iter, *(__iter - 1)))
++__i;
}
}
__counter[__iam] = __i;
// Last part still untouched.
_DifferenceType __begin_output;
# pragma omp barrier
// Store result in output on calculated positions.
__begin_output = 0;
if (__iam == 0)
{
for (_ThreadIndex __t = 0; __t < __num_threads; ++__t)
__begin_output += __counter[__t];
__i = 0;
_OutputIterator __iter_out = __result + __begin_output;
__begin = __borders[__num_threads];
__end = __size;
for (_IIter __iter = __first + __begin; __iter < __first + __end;
++__iter)
{
if (__iter == __first
|| !__binary_pred(*__iter, *(__iter - 1)))
{
++__i;
*__iter_out++ = *__iter;
}
}
__counter[__num_threads] = __i;
}
else
{
for (_ThreadIndex __t = 0; __t < __iam; __t++)
__begin_output += __counter[__t];
_OutputIterator __iter_out = __result + __begin_output;
for (_IIter __iter = __first + __begin; __iter < __first + __end;
++__iter)
{
if (!__binary_pred(*__iter, *(__iter - 1)))
*__iter_out++ = *__iter;
}
}
}
_DifferenceType __end_output = 0;
for (_ThreadIndex __t = 0; __t < __num_threads + 1; __t++)
__end_output += __counter[__t];
delete[] __borders;
return __result + __end_output;
}
/** @brief Parallel std::unique_copy(), without explicit equality predicate
* @param __first Begin iterator of input sequence.
* @param __last End iterator of input sequence.
* @param __result Begin iterator of result __sequence.
* @return End iterator of result __sequence. */
template<typename _IIter, class _OutputIterator>
inline _OutputIterator
__parallel_unique_copy(_IIter __first, _IIter __last,
_OutputIterator __result)
{
typedef typename std::iterator_traits<_IIter>::value_type
_ValueType;
return __parallel_unique_copy(__first, __last, __result,
std::equal_to<_ValueType>());
}
}//namespace __gnu_parallel
#endif /* _GLIBCXX_PARALLEL_UNIQUE_COPY_H */
c++/8/parallel/compatibility.h 0000644 00000007316 15201526705 0012113 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/compatibility.h
* @brief Compatibility layer, mostly concerned with atomic operations.
*
* This file is a GNU parallel extension to the Standard C++ Library
* and contains implementation details for the library's internal use.
*/
// Written by Felix Putze.
#ifndef _GLIBCXX_PARALLEL_COMPATIBILITY_H
#define _GLIBCXX_PARALLEL_COMPATIBILITY_H 1
#include <parallel/types.h>
#include <parallel/base.h>
#if !defined(_WIN32) || defined (__CYGWIN__)
#include <sched.h>
#endif
#ifdef __MINGW32__
// Including <windows.h> will drag in all the windows32 names. Since
// that can cause user code portability problems, we just declare the
// one needed function here.
extern "C"
__attribute((dllimport)) void __attribute__((stdcall)) Sleep (unsigned long);
#endif
namespace __gnu_parallel
{
template<typename _Tp>
inline _Tp
__add_omp(volatile _Tp* __ptr, _Tp __addend)
{
int64_t __res;
#pragma omp critical
{
__res = *__ptr;
*(__ptr) += __addend;
}
return __res;
}
/** @brief Add a value to a variable, atomically.
*
* @param __ptr Pointer to a signed integer.
* @param __addend Value to add.
*/
template<typename _Tp>
inline _Tp
__fetch_and_add(volatile _Tp* __ptr, _Tp __addend)
{
if (__atomic_always_lock_free(sizeof(_Tp), __ptr))
return __atomic_fetch_add(__ptr, __addend, __ATOMIC_ACQ_REL);
return __add_omp(__ptr, __addend);
}
template<typename _Tp>
inline bool
__cas_omp(volatile _Tp* __ptr, _Tp __comparand, _Tp __replacement)
{
bool __res = false;
#pragma omp critical
{
if (*__ptr == __comparand)
{
*__ptr = __replacement;
__res = true;
}
}
return __res;
}
/** @brief Compare-and-swap
*
* Compare @c *__ptr and @c __comparand. If equal, let @c
* *__ptr=__replacement and return @c true, return @c false otherwise.
*
* @param __ptr Pointer to signed integer.
* @param __comparand Compare value.
* @param __replacement Replacement value.
*/
template<typename _Tp>
inline bool
__compare_and_swap(volatile _Tp* __ptr, _Tp __comparand, _Tp __replacement)
{
if (__atomic_always_lock_free(sizeof(_Tp), __ptr))
return __atomic_compare_exchange_n(__ptr, &__comparand, __replacement,
false, __ATOMIC_ACQ_REL,
__ATOMIC_RELAXED);
return __cas_omp(__ptr, __comparand, __replacement);
}
/** @brief Yield control to another thread, without waiting for
* the end of the time slice.
*/
inline void
__yield()
{
#if defined (_WIN32) && !defined (__CYGWIN__)
Sleep(0);
#else
sched_yield();
#endif
}
} // end namespace
#endif /* _GLIBCXX_PARALLEL_COMPATIBILITY_H */
c++/8/parallel/iterator.h 0000644 00000013056 15201526705 0011071 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/iterator.h
* @brief Helper iterator classes for the std::transform() functions.
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Johannes Singler.
#ifndef _GLIBCXX_PARALLEL_ITERATOR_H
#define _GLIBCXX_PARALLEL_ITERATOR_H 1
#include <parallel/basic_iterator.h>
#include <bits/stl_pair.h>
namespace __gnu_parallel
{
/** @brief A pair of iterators. The usual iterator operations are
* applied to both child iterators.
*/
template<typename _Iterator1, typename _Iterator2,
typename _IteratorCategory>
class _IteratorPair : public std::pair<_Iterator1, _Iterator2>
{
private:
typedef std::pair<_Iterator1, _Iterator2> _Base;
public:
typedef _IteratorCategory iterator_category;
typedef void value_type;
typedef std::iterator_traits<_Iterator1> _TraitsType;
typedef typename _TraitsType::difference_type difference_type;
typedef _IteratorPair* pointer;
typedef _IteratorPair& reference;
_IteratorPair() { }
_IteratorPair(const _Iterator1& __first, const _Iterator2& __second)
: _Base(__first, __second) { }
// Pre-increment operator.
_IteratorPair&
operator++()
{
++_Base::first;
++_Base::second;
return *this;
}
// Post-increment operator.
const _IteratorPair
operator++(int)
{ return _IteratorPair(_Base::first++, _Base::second++); }
// Pre-decrement operator.
_IteratorPair&
operator--()
{
--_Base::first;
--_Base::second;
return *this;
}
// Post-decrement operator.
const _IteratorPair
operator--(int)
{ return _IteratorPair(_Base::first--, _Base::second--); }
// Type conversion.
operator _Iterator2() const
{ return _Base::second; }
_IteratorPair&
operator=(const _IteratorPair& __other)
{
_Base::first = __other.first;
_Base::second = __other.second;
return *this;
}
_IteratorPair
operator+(difference_type __delta) const
{ return _IteratorPair(_Base::first + __delta, _Base::second + __delta);
}
difference_type
operator-(const _IteratorPair& __other) const
{ return _Base::first - __other.first; }
};
/** @brief A triple of iterators. The usual iterator operations are
applied to all three child iterators.
*/
template<typename _Iterator1, typename _Iterator2, typename _Iterator3,
typename _IteratorCategory>
class _IteratorTriple
{
public:
typedef _IteratorCategory iterator_category;
typedef void value_type;
typedef typename std::iterator_traits<_Iterator1>::difference_type
difference_type;
typedef _IteratorTriple* pointer;
typedef _IteratorTriple& reference;
_Iterator1 _M_first;
_Iterator2 _M_second;
_Iterator3 _M_third;
_IteratorTriple() { }
_IteratorTriple(const _Iterator1& __first, const _Iterator2& __second,
const _Iterator3& __third)
{
_M_first = __first;
_M_second = __second;
_M_third = __third;
}
// Pre-increment operator.
_IteratorTriple&
operator++()
{
++_M_first;
++_M_second;
++_M_third;
return *this;
}
// Post-increment operator.
const _IteratorTriple
operator++(int)
{ return _IteratorTriple(_M_first++, _M_second++, _M_third++); }
// Pre-decrement operator.
_IteratorTriple&
operator--()
{
--_M_first;
--_M_second;
--_M_third;
return *this;
}
// Post-decrement operator.
const _IteratorTriple
operator--(int)
{ return _IteratorTriple(_M_first--, _M_second--, _M_third--); }
// Type conversion.
operator _Iterator3() const
{ return _M_third; }
_IteratorTriple&
operator=(const _IteratorTriple& __other)
{
_M_first = __other._M_first;
_M_second = __other._M_second;
_M_third = __other._M_third;
return *this;
}
_IteratorTriple
operator+(difference_type __delta) const
{ return _IteratorTriple(_M_first + __delta, _M_second + __delta,
_M_third + __delta); }
difference_type
operator-(const _IteratorTriple& __other) const
{ return _M_first - __other._M_first; }
};
}
#endif /* _GLIBCXX_PARALLEL_ITERATOR_H */
c++/8/parallel/partition.h 0000644 00000035161 15201526705 0011252 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/partition.h
* @brief Parallel implementation of std::partition(),
* std::nth_element(), and std::partial_sort().
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Johannes Singler and Felix Putze.
#ifndef _GLIBCXX_PARALLEL_PARTITION_H
#define _GLIBCXX_PARALLEL_PARTITION_H 1
#include <parallel/basic_iterator.h>
#include <parallel/sort.h>
#include <parallel/random_number.h>
#include <bits/stl_algo.h>
#include <parallel/parallel.h>
/** @brief Decide whether to declare certain variables volatile. */
#define _GLIBCXX_VOLATILE volatile
namespace __gnu_parallel
{
/** @brief Parallel implementation of std::partition.
* @param __begin Begin iterator of input sequence to split.
* @param __end End iterator of input sequence to split.
* @param __pred Partition predicate, possibly including some kind
* of pivot.
* @param __num_threads Maximum number of threads to use for this task.
* @return Number of elements not fulfilling the predicate. */
template<typename _RAIter, typename _Predicate>
typename std::iterator_traits<_RAIter>::difference_type
__parallel_partition(_RAIter __begin, _RAIter __end,
_Predicate __pred, _ThreadIndex __num_threads)
{
typedef std::iterator_traits<_RAIter> _TraitsType;
typedef typename _TraitsType::value_type _ValueType;
typedef typename _TraitsType::difference_type _DifferenceType;
_DifferenceType __n = __end - __begin;
_GLIBCXX_CALL(__n)
const _Settings& __s = _Settings::get();
// shared
_GLIBCXX_VOLATILE _DifferenceType __left = 0, __right = __n - 1,
__dist = __n,
__leftover_left, __leftover_right,
__leftnew, __rightnew;
// just 0 or 1, but int to allow atomic operations
int* __reserved_left = 0, * __reserved_right = 0;
_DifferenceType __chunk_size = __s.partition_chunk_size;
//at least two chunks per thread
if (__dist >= 2 * __num_threads * __chunk_size)
# pragma omp parallel num_threads(__num_threads)
{
# pragma omp single
{
__num_threads = omp_get_num_threads();
__reserved_left = new int[__num_threads];
__reserved_right = new int[__num_threads];
if (__s.partition_chunk_share > 0.0)
__chunk_size = std::max<_DifferenceType>
(__s.partition_chunk_size, (double)__n
* __s.partition_chunk_share / (double)__num_threads);
else
__chunk_size = __s.partition_chunk_size;
}
while (__dist >= 2 * __num_threads * __chunk_size)
{
# pragma omp single
{
_DifferenceType __num_chunks = __dist / __chunk_size;
for (_ThreadIndex __r = 0; __r < __num_threads; ++__r)
{
__reserved_left [__r] = 0; // false
__reserved_right[__r] = 0; // false
}
__leftover_left = 0;
__leftover_right = 0;
} //implicit barrier
// Private.
_DifferenceType __thread_left, __thread_left_border,
__thread_right, __thread_right_border;
__thread_left = __left + 1;
// Just to satisfy the condition below.
__thread_left_border = __thread_left - 1;
__thread_right = __n - 1;
// Just to satisfy the condition below.
__thread_right_border = __thread_right + 1;
bool __iam_finished = false;
while (!__iam_finished)
{
if (__thread_left > __thread_left_border)
{
_DifferenceType __former_dist =
__fetch_and_add(&__dist, -__chunk_size);
if (__former_dist < __chunk_size)
{
__fetch_and_add(&__dist, __chunk_size);
__iam_finished = true;
break;
}
else
{
__thread_left =
__fetch_and_add(&__left, __chunk_size);
__thread_left_border =
__thread_left + (__chunk_size - 1);
}
}
if (__thread_right < __thread_right_border)
{
_DifferenceType __former_dist =
__fetch_and_add(&__dist, -__chunk_size);
if (__former_dist < __chunk_size)
{
__fetch_and_add(&__dist, __chunk_size);
__iam_finished = true;
break;
}
else
{
__thread_right =
__fetch_and_add(&__right, -__chunk_size);
__thread_right_border =
__thread_right - (__chunk_size - 1);
}
}
// Swap as usual.
while (__thread_left < __thread_right)
{
while (__pred(__begin[__thread_left])
&& __thread_left <= __thread_left_border)
++__thread_left;
while (!__pred(__begin[__thread_right])
&& __thread_right >= __thread_right_border)
--__thread_right;
if (__thread_left > __thread_left_border
|| __thread_right < __thread_right_border)
// Fetch new chunk(__s).
break;
std::iter_swap(__begin + __thread_left,
__begin + __thread_right);
++__thread_left;
--__thread_right;
}
}
// Now swap the leftover chunks to the right places.
if (__thread_left <= __thread_left_border)
# pragma omp atomic
++__leftover_left;
if (__thread_right >= __thread_right_border)
# pragma omp atomic
++__leftover_right;
# pragma omp barrier
_DifferenceType
__leftold = __left,
__leftnew = __left - __leftover_left * __chunk_size,
__rightold = __right,
__rightnew = __right + __leftover_right * __chunk_size;
// <=> __thread_left_border + (__chunk_size - 1) >= __leftnew
if (__thread_left <= __thread_left_border
&& __thread_left_border >= __leftnew)
{
// Chunk already in place, reserve spot.
__reserved_left[(__left - (__thread_left_border + 1))
/ __chunk_size] = 1;
}
// <=> __thread_right_border - (__chunk_size - 1) <= __rightnew
if (__thread_right >= __thread_right_border
&& __thread_right_border <= __rightnew)
{
// Chunk already in place, reserve spot.
__reserved_right[((__thread_right_border - 1) - __right)
/ __chunk_size] = 1;
}
# pragma omp barrier
if (__thread_left <= __thread_left_border
&& __thread_left_border < __leftnew)
{
// Find spot and swap.
_DifferenceType __swapstart = -1;
for (int __r = 0; __r < __leftover_left; ++__r)
if (__reserved_left[__r] == 0
&& __compare_and_swap(&(__reserved_left[__r]), 0, 1))
{
__swapstart = __leftold - (__r + 1) * __chunk_size;
break;
}
#if _GLIBCXX_PARALLEL_ASSERTIONS
_GLIBCXX_PARALLEL_ASSERT(__swapstart != -1);
#endif
std::swap_ranges(__begin + __thread_left_border
- (__chunk_size - 1),
__begin + __thread_left_border + 1,
__begin + __swapstart);
}
if (__thread_right >= __thread_right_border
&& __thread_right_border > __rightnew)
{
// Find spot and swap
_DifferenceType __swapstart = -1;
for (int __r = 0; __r < __leftover_right; ++__r)
if (__reserved_right[__r] == 0
&& __compare_and_swap(&(__reserved_right[__r]), 0, 1))
{
__swapstart = __rightold + __r * __chunk_size + 1;
break;
}
#if _GLIBCXX_PARALLEL_ASSERTIONS
_GLIBCXX_PARALLEL_ASSERT(__swapstart != -1);
#endif
std::swap_ranges(__begin + __thread_right_border,
__begin + __thread_right_border
+ __chunk_size, __begin + __swapstart);
}
#if _GLIBCXX_PARALLEL_ASSERTIONS
# pragma omp barrier
# pragma omp single
{
for (_DifferenceType __r = 0; __r < __leftover_left; ++__r)
_GLIBCXX_PARALLEL_ASSERT(__reserved_left[__r] == 1);
for (_DifferenceType __r = 0; __r < __leftover_right; ++__r)
_GLIBCXX_PARALLEL_ASSERT(__reserved_right[__r] == 1);
}
#endif
__left = __leftnew;
__right = __rightnew;
__dist = __right - __left + 1;
}
# pragma omp flush(__left, __right)
} // end "recursion" //parallel
_DifferenceType __final_left = __left, __final_right = __right;
while (__final_left < __final_right)
{
// Go right until key is geq than pivot.
while (__pred(__begin[__final_left])
&& __final_left < __final_right)
++__final_left;
// Go left until key is less than pivot.
while (!__pred(__begin[__final_right])
&& __final_left < __final_right)
--__final_right;
if (__final_left == __final_right)
break;
std::iter_swap(__begin + __final_left, __begin + __final_right);
++__final_left;
--__final_right;
}
// All elements on the left side are < piv, all elements on the
// right are >= piv
delete[] __reserved_left;
delete[] __reserved_right;
// Element "between" __final_left and __final_right might not have
// been regarded yet
if (__final_left < __n && !__pred(__begin[__final_left]))
// Really swapped.
return __final_left;
else
return __final_left + 1;
}
/**
* @brief Parallel implementation of std::nth_element().
* @param __begin Begin iterator of input sequence.
* @param __nth _Iterator of element that must be in position afterwards.
* @param __end End iterator of input sequence.
* @param __comp Comparator.
*/
template<typename _RAIter, typename _Compare>
void
__parallel_nth_element(_RAIter __begin, _RAIter __nth,
_RAIter __end, _Compare __comp)
{
typedef std::iterator_traits<_RAIter> _TraitsType;
typedef typename _TraitsType::value_type _ValueType;
typedef typename _TraitsType::difference_type _DifferenceType;
_GLIBCXX_CALL(__end - __begin)
_RAIter __split;
_RandomNumber __rng;
const _Settings& __s = _Settings::get();
_DifferenceType __minimum_length = std::max<_DifferenceType>(2,
std::max(__s.nth_element_minimal_n, __s.partition_minimal_n));
// Break if input range to small.
while (static_cast<_SequenceIndex>(__end - __begin) >= __minimum_length)
{
_DifferenceType __n = __end - __begin;
_RAIter __pivot_pos = __begin + __rng(__n);
// Swap __pivot_pos value to end.
if (__pivot_pos != (__end - 1))
std::iter_swap(__pivot_pos, __end - 1);
__pivot_pos = __end - 1;
// _Compare must have first_value_type, second_value_type,
// result_type
// _Compare ==
// __gnu_parallel::_Lexicographic<S, int,
// __gnu_parallel::_Less<S, S> >
// __pivot_pos == std::pair<S, int>*
__gnu_parallel::__binder2nd<_Compare, _ValueType, _ValueType, bool>
__pred(__comp, *__pivot_pos);
// Divide, leave pivot unchanged in last place.
_RAIter __split_pos1, __split_pos2;
__split_pos1 = __begin + __parallel_partition(__begin, __end - 1,
__pred,
__get_max_threads());
// Left side: < __pivot_pos; __right side: >= __pivot_pos
// Swap pivot back to middle.
if (__split_pos1 != __pivot_pos)
std::iter_swap(__split_pos1, __pivot_pos);
__pivot_pos = __split_pos1;
// In case all elements are equal, __split_pos1 == 0
if ((__split_pos1 + 1 - __begin) < (__n >> 7)
|| (__end - __split_pos1) < (__n >> 7))
{
// Very unequal split, one part smaller than one 128th
// elements not strictly larger than the pivot.
__gnu_parallel::__unary_negate<__gnu_parallel::
__binder1st<_Compare, _ValueType,
_ValueType, bool>, _ValueType>
__pred(__gnu_parallel::__binder1st<_Compare, _ValueType,
_ValueType, bool>(__comp, *__pivot_pos));
// Find other end of pivot-equal range.
__split_pos2 = __gnu_sequential::partition(__split_pos1 + 1,
__end, __pred);
}
else
// Only skip the pivot.
__split_pos2 = __split_pos1 + 1;
// Compare iterators.
if (__split_pos2 <= __nth)
__begin = __split_pos2;
else if (__nth < __split_pos1)
__end = __split_pos1;
else
break;
}
// Only at most _Settings::partition_minimal_n __elements __left.
__gnu_sequential::nth_element(__begin, __nth, __end, __comp);
}
/** @brief Parallel implementation of std::partial_sort().
* @param __begin Begin iterator of input sequence.
* @param __middle Sort until this position.
* @param __end End iterator of input sequence.
* @param __comp Comparator. */
template<typename _RAIter, typename _Compare>
void
__parallel_partial_sort(_RAIter __begin,
_RAIter __middle,
_RAIter __end, _Compare __comp)
{
__parallel_nth_element(__begin, __middle, __end, __comp);
std::sort(__begin, __middle, __comp);
}
} //namespace __gnu_parallel
#undef _GLIBCXX_VOLATILE
#endif /* _GLIBCXX_PARALLEL_PARTITION_H */
c++/8/parallel/base.h 0000644 00000030125 15201526705 0010146 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/base.h
* @brief Sequential helper functions.
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Johannes Singler.
#ifndef _GLIBCXX_PARALLEL_BASE_H
#define _GLIBCXX_PARALLEL_BASE_H 1
#include <bits/c++config.h>
#include <bits/stl_function.h>
#include <omp.h>
#include <parallel/features.h>
#include <parallel/basic_iterator.h>
#include <parallel/parallel.h>
// Parallel mode namespaces.
/**
* @namespace std::__parallel
* @brief GNU parallel code, replaces standard behavior with parallel behavior.
*/
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __parallel { }
}
/**
* @namespace __gnu_parallel
* @brief GNU parallel code for public use.
*/
namespace __gnu_parallel
{
// Import all the parallel versions of components in namespace std.
using namespace std::__parallel;
}
/**
* @namespace __gnu_sequential
* @brief GNU sequential classes for public use.
*/
namespace __gnu_sequential
{
// Import whatever is the serial version.
#ifdef _GLIBCXX_PARALLEL
using namespace std::_GLIBCXX_STD_A;
#else
using namespace std;
#endif
}
namespace __gnu_parallel
{
// NB: Including this file cannot produce (unresolved) symbols from
// the OpenMP runtime unless the parallel mode is actually invoked
// and active, which imples that the OpenMP runtime is actually
// going to be linked in.
inline _ThreadIndex
__get_max_threads()
{
_ThreadIndex __i = omp_get_max_threads();
return __i > 1 ? __i : 1;
}
inline bool
__is_parallel(const _Parallelism __p) { return __p != sequential; }
/** @brief Calculates the rounded-down logarithm of @c __n for base 2.
* @param __n Argument.
* @return Returns 0 for any argument <1.
*/
template<typename _Size>
inline _Size
__rd_log2(_Size __n)
{
_Size __k;
for (__k = 0; __n > 1; __n >>= 1)
++__k;
return __k;
}
/** @brief Encode two integers into one gnu_parallel::_CASable.
* @param __a First integer, to be encoded in the most-significant @c
* _CASable_bits/2 bits.
* @param __b Second integer, to be encoded in the least-significant
* @c _CASable_bits/2 bits.
* @return value encoding @c __a and @c __b.
* @see __decode2
*/
inline _CASable
__encode2(int __a, int __b) //must all be non-negative, actually
{
return (((_CASable)__a) << (_CASable_bits / 2)) | (((_CASable)__b) << 0);
}
/** @brief Decode two integers from one gnu_parallel::_CASable.
* @param __x __gnu_parallel::_CASable to decode integers from.
* @param __a First integer, to be decoded from the most-significant
* @c _CASable_bits/2 bits of @c __x.
* @param __b Second integer, to be encoded in the least-significant
* @c _CASable_bits/2 bits of @c __x.
* @see __encode2
*/
inline void
__decode2(_CASable __x, int& __a, int& __b)
{
__a = (int)((__x >> (_CASable_bits / 2)) & _CASable_mask);
__b = (int)((__x >> 0 ) & _CASable_mask);
}
//needed for parallel "numeric", even if "algorithm" not included
/** @brief Equivalent to std::min. */
template<typename _Tp>
inline const _Tp&
min(const _Tp& __a, const _Tp& __b)
{ return (__a < __b) ? __a : __b; }
/** @brief Equivalent to std::max. */
template<typename _Tp>
inline const _Tp&
max(const _Tp& __a, const _Tp& __b)
{ return (__a > __b) ? __a : __b; }
/** @brief Constructs predicate for equality from strict weak
* ordering predicate
*/
template<typename _T1, typename _T2, typename _Compare>
class _EqualFromLess : public std::binary_function<_T1, _T2, bool>
{
private:
_Compare& _M_comp;
public:
_EqualFromLess(_Compare& __comp) : _M_comp(__comp) { }
bool operator()(const _T1& __a, const _T2& __b)
{ return !_M_comp(__a, __b) && !_M_comp(__b, __a); }
};
/** @brief Similar to std::unary_negate,
* but giving the argument types explicitly. */
template<typename _Predicate, typename argument_type>
class __unary_negate
: public std::unary_function<argument_type, bool>
{
protected:
_Predicate _M_pred;
public:
explicit
__unary_negate(const _Predicate& __x) : _M_pred(__x) { }
bool
operator()(const argument_type& __x)
{ return !_M_pred(__x); }
};
/** @brief Similar to std::binder1st,
* but giving the argument types explicitly. */
template<typename _Operation, typename _FirstArgumentType,
typename _SecondArgumentType, typename _ResultType>
class __binder1st
: public std::unary_function<_SecondArgumentType, _ResultType>
{
protected:
_Operation _M_op;
_FirstArgumentType _M_value;
public:
__binder1st(const _Operation& __x, const _FirstArgumentType& __y)
: _M_op(__x), _M_value(__y) { }
_ResultType
operator()(const _SecondArgumentType& __x)
{ return _M_op(_M_value, __x); }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 109. Missing binders for non-const sequence elements
_ResultType
operator()(_SecondArgumentType& __x) const
{ return _M_op(_M_value, __x); }
};
/**
* @brief Similar to std::binder2nd, but giving the argument types
* explicitly.
*/
template<typename _Operation, typename _FirstArgumentType,
typename _SecondArgumentType, typename _ResultType>
class __binder2nd
: public std::unary_function<_FirstArgumentType, _ResultType>
{
protected:
_Operation _M_op;
_SecondArgumentType _M_value;
public:
__binder2nd(const _Operation& __x, const _SecondArgumentType& __y)
: _M_op(__x), _M_value(__y) { }
_ResultType
operator()(const _FirstArgumentType& __x) const
{ return _M_op(__x, _M_value); }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 109. Missing binders for non-const sequence elements
_ResultType
operator()(_FirstArgumentType& __x)
{ return _M_op(__x, _M_value); }
};
/** @brief Similar to std::equal_to, but allows two different types. */
template<typename _T1, typename _T2>
struct _EqualTo : std::binary_function<_T1, _T2, bool>
{
bool operator()(const _T1& __t1, const _T2& __t2) const
{ return __t1 == __t2; }
};
/** @brief Similar to std::less, but allows two different types. */
template<typename _T1, typename _T2>
struct _Less : std::binary_function<_T1, _T2, bool>
{
bool
operator()(const _T1& __t1, const _T2& __t2) const
{ return __t1 < __t2; }
bool
operator()(const _T2& __t2, const _T1& __t1) const
{ return __t2 < __t1; }
};
// Partial specialization for one type. Same as std::less.
template<typename _Tp>
struct _Less<_Tp, _Tp>
: public std::less<_Tp> { };
/** @brief Similar to std::plus, but allows two different types. */
template<typename _Tp1, typename _Tp2, typename _Result
= __typeof__(*static_cast<_Tp1*>(0)
+ *static_cast<_Tp2*>(0))>
struct _Plus : public std::binary_function<_Tp1, _Tp2, _Result>
{
_Result
operator()(const _Tp1& __x, const _Tp2& __y) const
{ return __x + __y; }
};
// Partial specialization for one type. Same as std::plus.
template<typename _Tp>
struct _Plus<_Tp, _Tp, _Tp>
: public std::plus<_Tp> { };
/** @brief Similar to std::multiplies, but allows two different types. */
template<typename _Tp1, typename _Tp2, typename _Result
= __typeof__(*static_cast<_Tp1*>(0)
* *static_cast<_Tp2*>(0))>
struct _Multiplies : public std::binary_function<_Tp1, _Tp2, _Result>
{
_Result
operator()(const _Tp1& __x, const _Tp2& __y) const
{ return __x * __y; }
};
// Partial specialization for one type. Same as std::multiplies.
template<typename _Tp>
struct _Multiplies<_Tp, _Tp, _Tp>
: public std::multiplies<_Tp> { };
/** @brief _Iterator associated with __gnu_parallel::_PseudoSequence.
* If features the usual random-access iterator functionality.
* @param _Tp Sequence _M_value type.
* @param _DifferenceTp Sequence difference type.
*/
template<typename _Tp, typename _DifferenceTp>
class _PseudoSequenceIterator
{
public:
typedef _DifferenceTp _DifferenceType;
_PseudoSequenceIterator(const _Tp& __val, _DifferenceType __pos)
: _M_val(__val), _M_pos(__pos) { }
// Pre-increment operator.
_PseudoSequenceIterator&
operator++()
{
++_M_pos;
return *this;
}
// Post-increment operator.
_PseudoSequenceIterator
operator++(int)
{ return _PseudoSequenceIterator(_M_pos++); }
const _Tp&
operator*() const
{ return _M_val; }
const _Tp&
operator[](_DifferenceType) const
{ return _M_val; }
bool
operator==(const _PseudoSequenceIterator& __i2)
{ return _M_pos == __i2._M_pos; }
bool
operator!=(const _PseudoSequenceIterator& __i2)
{ return _M_pos != __i2._M_pos; }
_DifferenceType
operator-(const _PseudoSequenceIterator& __i2)
{ return _M_pos - __i2._M_pos; }
private:
const _Tp& _M_val;
_DifferenceType _M_pos;
};
/** @brief Sequence that conceptually consists of multiple copies of
the same element.
* The copies are not stored explicitly, of course.
* @param _Tp Sequence _M_value type.
* @param _DifferenceTp Sequence difference type.
*/
template<typename _Tp, typename _DifferenceTp>
class _PseudoSequence
{
public:
typedef _DifferenceTp _DifferenceType;
// Better cast down to uint64_t, than up to _DifferenceTp.
typedef _PseudoSequenceIterator<_Tp, uint64_t> iterator;
/** @brief Constructor.
* @param __val Element of the sequence.
* @param __count Number of (virtual) copies.
*/
_PseudoSequence(const _Tp& __val, _DifferenceType __count)
: _M_val(__val), _M_count(__count) { }
/** @brief Begin iterator. */
iterator
begin() const
{ return iterator(_M_val, 0); }
/** @brief End iterator. */
iterator
end() const
{ return iterator(_M_val, _M_count); }
private:
const _Tp& _M_val;
_DifferenceType _M_count;
};
/** @brief Compute the median of three referenced elements,
according to @c __comp.
* @param __a First iterator.
* @param __b Second iterator.
* @param __c Third iterator.
* @param __comp Comparator.
*/
template<typename _RAIter, typename _Compare>
_RAIter
__median_of_three_iterators(_RAIter __a, _RAIter __b,
_RAIter __c, _Compare __comp)
{
if (__comp(*__a, *__b))
if (__comp(*__b, *__c))
return __b;
else
if (__comp(*__a, *__c))
return __c;
else
return __a;
else
{
// Just swap __a and __b.
if (__comp(*__a, *__c))
return __a;
else
if (__comp(*__b, *__c))
return __c;
else
return __b;
}
}
#if _GLIBCXX_PARALLEL_ASSERTIONS && defined(__glibcxx_assert_impl)
#define _GLIBCXX_PARALLEL_ASSERT(_Condition) __glibcxx_assert_impl(_Condition)
#else
#define _GLIBCXX_PARALLEL_ASSERT(_Condition)
#endif
} //namespace __gnu_parallel
#endif /* _GLIBCXX_PARALLEL_BASE_H */
c++/8/parallel/search.h 0000644 00000012417 15201526705 0010505 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/search.h
* @brief Parallel implementation base for std::search() and
* std::search_n().
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Felix Putze.
#ifndef _GLIBCXX_PARALLEL_SEARCH_H
#define _GLIBCXX_PARALLEL_SEARCH_H 1
#include <bits/stl_algobase.h>
#include <parallel/parallel.h>
#include <parallel/equally_split.h>
namespace __gnu_parallel
{
/**
* @brief Precalculate __advances for Knuth-Morris-Pratt algorithm.
* @param __elements Begin iterator of sequence to search for.
* @param __length Length of sequence to search for.
* @param __off Returned __offsets.
*/
template<typename _RAIter, typename _DifferenceTp>
void
__calc_borders(_RAIter __elements, _DifferenceTp __length,
_DifferenceTp* __off)
{
typedef _DifferenceTp _DifferenceType;
__off[0] = -1;
if (__length > 1)
__off[1] = 0;
_DifferenceType __k = 0;
for (_DifferenceType __j = 2; __j <= __length; __j++)
{
while ((__k >= 0) && !(__elements[__k] == __elements[__j-1]))
__k = __off[__k];
__off[__j] = ++__k;
}
}
// Generic parallel find algorithm (requires random access iterator).
/** @brief Parallel std::search.
* @param __begin1 Begin iterator of first sequence.
* @param __end1 End iterator of first sequence.
* @param __begin2 Begin iterator of second sequence.
* @param __end2 End iterator of second sequence.
* @param __pred Find predicate.
* @return Place of finding in first sequences. */
template<typename __RAIter1,
typename __RAIter2,
typename _Pred>
__RAIter1
__search_template(__RAIter1 __begin1, __RAIter1 __end1,
__RAIter2 __begin2, __RAIter2 __end2,
_Pred __pred)
{
typedef std::iterator_traits<__RAIter1> _TraitsType;
typedef typename _TraitsType::difference_type _DifferenceType;
_GLIBCXX_CALL((__end1 - __begin1) + (__end2 - __begin2));
_DifferenceType __pattern_length = __end2 - __begin2;
// Pattern too short.
if(__pattern_length <= 0)
return __end1;
// Last point to start search.
_DifferenceType __input_length = (__end1 - __begin1) - __pattern_length;
// Where is first occurrence of pattern? defaults to end.
_DifferenceType __result = (__end1 - __begin1);
_DifferenceType *__splitters;
// Pattern too long.
if (__input_length < 0)
return __end1;
omp_lock_t __result_lock;
omp_init_lock(&__result_lock);
_ThreadIndex __num_threads = std::max<_DifferenceType>
(1, std::min<_DifferenceType>(__input_length,
__get_max_threads()));
_DifferenceType __advances[__pattern_length];
__calc_borders(__begin2, __pattern_length, __advances);
# pragma omp parallel num_threads(__num_threads)
{
# pragma omp single
{
__num_threads = omp_get_num_threads();
__splitters = new _DifferenceType[__num_threads + 1];
__equally_split(__input_length, __num_threads, __splitters);
}
_ThreadIndex __iam = omp_get_thread_num();
_DifferenceType __start = __splitters[__iam],
__stop = __splitters[__iam + 1];
_DifferenceType __pos_in_pattern = 0;
bool __found_pattern = false;
while (__start <= __stop && !__found_pattern)
{
// Get new value of result.
#pragma omp flush(__result)
// No chance for this thread to find first occurrence.
if (__result < __start)
break;
while (__pred(__begin1[__start + __pos_in_pattern],
__begin2[__pos_in_pattern]))
{
++__pos_in_pattern;
if (__pos_in_pattern == __pattern_length)
{
// Found new candidate for result.
omp_set_lock(&__result_lock);
__result = std::min(__result, __start);
omp_unset_lock(&__result_lock);
__found_pattern = true;
break;
}
}
// Make safe jump.
__start += (__pos_in_pattern - __advances[__pos_in_pattern]);
__pos_in_pattern = (__advances[__pos_in_pattern] < 0
? 0 : __advances[__pos_in_pattern]);
}
} //parallel
omp_destroy_lock(&__result_lock);
delete[] __splitters;
// Return iterator on found element.
return (__begin1 + __result);
}
} // end namespace
#endif /* _GLIBCXX_PARALLEL_SEARCH_H */
c++/8/parallel/basic_iterator.h 0000644 00000003062 15201526705 0012226 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/basic_iterator.h
* @brief Includes the original header files concerned with iterators
* except for stream iterators.
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Johannes Singler.
#ifndef _GLIBCXX_PARALLEL_BASIC_ITERATOR_H
#define _GLIBCXX_PARALLEL_BASIC_ITERATOR_H 1
#include <bits/c++config.h>
#include <bits/stl_iterator_base_types.h>
#include <bits/stl_iterator_base_funcs.h>
#include <bits/stl_iterator.h>
#endif /* _GLIBCXX_PARALLEL_BASIC_ITERATOR_H */
c++/8/parallel/workstealing.h 0000644 00000022614 15201526705 0011751 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/workstealing.h
* @brief Parallelization of embarrassingly parallel execution by
* means of work-stealing.
*
* Work stealing is described in
*
* R. D. Blumofe and C. E. Leiserson.
* Scheduling multithreaded computations by work stealing.
* Journal of the ACM, 46(5):720–748, 1999.
*
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Felix Putze.
#ifndef _GLIBCXX_PARALLEL_WORKSTEALING_H
#define _GLIBCXX_PARALLEL_WORKSTEALING_H 1
#include <parallel/parallel.h>
#include <parallel/random_number.h>
#include <parallel/compatibility.h>
namespace __gnu_parallel
{
#define _GLIBCXX_JOB_VOLATILE volatile
/** @brief One __job for a certain thread. */
template<typename _DifferenceTp>
struct _Job
{
typedef _DifferenceTp _DifferenceType;
/** @brief First element.
*
* Changed by owning and stealing thread. By stealing thread,
* always incremented. */
_GLIBCXX_JOB_VOLATILE _DifferenceType _M_first;
/** @brief Last element.
*
* Changed by owning thread only. */
_GLIBCXX_JOB_VOLATILE _DifferenceType _M_last;
/** @brief Number of elements, i.e. @c _M_last-_M_first+1.
*
* Changed by owning thread only. */
_GLIBCXX_JOB_VOLATILE _DifferenceType _M_load;
};
/** @brief Work stealing algorithm for random access iterators.
*
* Uses O(1) additional memory. Synchronization at job lists is
* done with atomic operations.
* @param __begin Begin iterator of element sequence.
* @param __end End iterator of element sequence.
* @param __op User-supplied functor (comparator, predicate, adding
* functor, ...).
* @param __f Functor to @a process an element with __op (depends on
* desired functionality, e. g. for std::for_each(), ...).
* @param __r Functor to @a add a single __result to the already
* processed elements (depends on functionality).
* @param __base Base value for reduction.
* @param __output Pointer to position where final result is written to
* @param __bound Maximum number of elements processed (e. g. for
* std::count_n()).
* @return User-supplied functor (that may contain a part of the result).
*/
template<typename _RAIter,
typename _Op,
typename _Fu,
typename _Red,
typename _Result>
_Op
__for_each_template_random_access_workstealing(_RAIter __begin,
_RAIter __end, _Op __op,
_Fu& __f, _Red __r,
_Result __base,
_Result& __output,
typename std::iterator_traits<_RAIter>::difference_type __bound)
{
_GLIBCXX_CALL(__end - __begin)
typedef std::iterator_traits<_RAIter> _TraitsType;
typedef typename _TraitsType::difference_type _DifferenceType;
const _Settings& __s = _Settings::get();
_DifferenceType __chunk_size =
static_cast<_DifferenceType>(__s.workstealing_chunk_size);
// How many jobs?
_DifferenceType __length = (__bound < 0) ? (__end - __begin) : __bound;
// To avoid false sharing in a cache line.
const int __stride = (__s.cache_line_size * 10
/ sizeof(_Job<_DifferenceType>) + 1);
// Total number of threads currently working.
_ThreadIndex __busy = 0;
_Job<_DifferenceType> *__job;
omp_lock_t __output_lock;
omp_init_lock(&__output_lock);
// Write base value to output.
__output = __base;
// No more threads than jobs, at least one thread.
_ThreadIndex __num_threads = __gnu_parallel::max<_ThreadIndex>
(1, __gnu_parallel::min<_DifferenceType>(__length,
__get_max_threads()));
# pragma omp parallel shared(__busy) num_threads(__num_threads)
{
# pragma omp single
{
__num_threads = omp_get_num_threads();
// Create job description array.
__job = new _Job<_DifferenceType>[__num_threads * __stride];
}
// Initialization phase.
// Flags for every thread if it is doing productive work.
bool __iam_working = false;
// Thread id.
_ThreadIndex __iam = omp_get_thread_num();
// This job.
_Job<_DifferenceType>& __my_job = __job[__iam * __stride];
// Random number (for work stealing).
_ThreadIndex __victim;
// Local value for reduction.
_Result __result = _Result();
// Number of elements to steal in one attempt.
_DifferenceType __steal;
// Every thread has its own random number generator
// (modulo __num_threads).
_RandomNumber __rand_gen(__iam, __num_threads);
// This thread is currently working.
# pragma omp atomic
++__busy;
__iam_working = true;
// How many jobs per thread? last thread gets the rest.
__my_job._M_first = static_cast<_DifferenceType>
(__iam * (__length / __num_threads));
__my_job._M_last = (__iam == (__num_threads - 1)
? (__length - 1)
: ((__iam + 1) * (__length / __num_threads) - 1));
__my_job._M_load = __my_job._M_last - __my_job._M_first + 1;
// Init result with _M_first value (to have a base value for reduction)
if (__my_job._M_first <= __my_job._M_last)
{
// Cannot use volatile variable directly.
_DifferenceType __my_first = __my_job._M_first;
__result = __f(__op, __begin + __my_first);
++__my_job._M_first;
--__my_job._M_load;
}
_RAIter __current;
# pragma omp barrier
// Actual work phase
// Work on own or stolen current start
while (__busy > 0)
{
// Work until no productive thread left.
# pragma omp flush(__busy)
// Thread has own work to do
while (__my_job._M_first <= __my_job._M_last)
{
// fetch-and-add call
// Reserve current job block (size __chunk_size) in my queue.
_DifferenceType __current_job =
__fetch_and_add<_DifferenceType>(&(__my_job._M_first),
__chunk_size);
// Update _M_load, to make the three values consistent,
// _M_first might have been changed in the meantime
__my_job._M_load = __my_job._M_last - __my_job._M_first + 1;
for (_DifferenceType __job_counter = 0;
__job_counter < __chunk_size
&& __current_job <= __my_job._M_last;
++__job_counter)
{
// Yes: process it!
__current = __begin + __current_job;
++__current_job;
// Do actual work.
__result = __r(__result, __f(__op, __current));
}
# pragma omp flush(__busy)
}
// After reaching this point, a thread's __job list is empty.
if (__iam_working)
{
// This thread no longer has work.
# pragma omp atomic
--__busy;
__iam_working = false;
}
_DifferenceType __supposed_first, __supposed_last,
__supposed_load;
do
{
// Find random nonempty deque (not own), do consistency check.
__yield();
# pragma omp flush(__busy)
__victim = __rand_gen();
__supposed_first = __job[__victim * __stride]._M_first;
__supposed_last = __job[__victim * __stride]._M_last;
__supposed_load = __job[__victim * __stride]._M_load;
}
while (__busy > 0
&& ((__supposed_load <= 0)
|| ((__supposed_first + __supposed_load - 1)
!= __supposed_last)));
if (__busy == 0)
break;
if (__supposed_load > 0)
{
// Has work and work to do.
// Number of elements to steal (at least one).
__steal = (__supposed_load < 2) ? 1 : __supposed_load / 2;
// Push __victim's current start forward.
_DifferenceType __stolen_first =
__fetch_and_add<_DifferenceType>
(&(__job[__victim * __stride]._M_first), __steal);
_DifferenceType __stolen_try = (__stolen_first + __steal
- _DifferenceType(1));
__my_job._M_first = __stolen_first;
__my_job._M_last = __gnu_parallel::min(__stolen_try,
__supposed_last);
__my_job._M_load = __my_job._M_last - __my_job._M_first + 1;
// Has potential work again.
# pragma omp atomic
++__busy;
__iam_working = true;
# pragma omp flush(__busy)
}
# pragma omp flush(__busy)
} // end while __busy > 0
// Add accumulated result to output.
omp_set_lock(&__output_lock);
__output = __r(__output, __result);
omp_unset_lock(&__output_lock);
}
delete[] __job;
// Points to last element processed (needed as return value for
// some algorithms like transform)
__f._M_finish_iterator = __begin + __length;
omp_destroy_lock(&__output_lock);
return __op;
}
} // end namespace
#endif /* _GLIBCXX_PARALLEL_WORKSTEALING_H */
c++/8/parallel/set_operations.h 0000644 00000034376 15201526705 0012306 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/**
* @file parallel/set_operations.h
* @brief Parallel implementations of set operations for random-access
* iterators.
* This file is a GNU parallel extension to the Standard C++ Library.
*/
// Written by Marius Elvert and Felix Bondarenko.
#ifndef _GLIBCXX_PARALLEL_SET_OPERATIONS_H
#define _GLIBCXX_PARALLEL_SET_OPERATIONS_H 1
#include <omp.h>
#include <parallel/settings.h>
#include <parallel/multiseq_selection.h>
namespace __gnu_parallel
{
template<typename _IIter, typename _OutputIterator>
_OutputIterator
__copy_tail(std::pair<_IIter, _IIter> __b,
std::pair<_IIter, _IIter> __e, _OutputIterator __r)
{
if (__b.first != __e.first)
{
do
{
*__r++ = *__b.first++;
}
while (__b.first != __e.first);
}
else
{
while (__b.second != __e.second)
*__r++ = *__b.second++;
}
return __r;
}
template<typename _IIter,
typename _OutputIterator,
typename _Compare>
struct __symmetric_difference_func
{
typedef std::iterator_traits<_IIter> _TraitsType;
typedef typename _TraitsType::difference_type _DifferenceType;
typedef typename std::pair<_IIter, _IIter> _IteratorPair;
__symmetric_difference_func(_Compare __comp) : _M_comp(__comp) {}
_Compare _M_comp;
_OutputIterator
_M_invoke(_IIter __a, _IIter __b, _IIter __c, _IIter __d,
_OutputIterator __r) const
{
while (__a != __b && __c != __d)
{
if (_M_comp(*__a, *__c))
{
*__r = *__a;
++__a;
++__r;
}
else if (_M_comp(*__c, *__a))
{
*__r = *__c;
++__c;
++__r;
}
else
{
++__a;
++__c;
}
}
return std::copy(__c, __d, std::copy(__a, __b, __r));
}
_DifferenceType
__count(_IIter __a, _IIter __b, _IIter __c, _IIter __d) const
{
_DifferenceType __counter = 0;
while (__a != __b && __c != __d)
{
if (_M_comp(*__a, *__c))
{
++__a;
++__counter;
}
else if (_M_comp(*__c, *__a))
{
++__c;
++__counter;
}
else
{
++__a;
++__c;
}
}
return __counter + (__b - __a) + (__d - __c);
}
_OutputIterator
__first_empty(_IIter __c, _IIter __d, _OutputIterator __out) const
{ return std::copy(__c, __d, __out); }
_OutputIterator
__second_empty(_IIter __a, _IIter __b, _OutputIterator __out) const
{ return std::copy(__a, __b, __out); }
};
template<typename _IIter,
typename _OutputIterator,
typename _Compare>
struct __difference_func
{
typedef std::iterator_traits<_IIter> _TraitsType;
typedef typename _TraitsType::difference_type _DifferenceType;
typedef typename std::pair<_IIter, _IIter> _IteratorPair;
__difference_func(_Compare __comp) : _M_comp(__comp) {}
_Compare _M_comp;
_OutputIterator
_M_invoke(_IIter __a, _IIter __b, _IIter __c, _IIter __d,
_OutputIterator __r) const
{
while (__a != __b && __c != __d)
{
if (_M_comp(*__a, *__c))
{
*__r = *__a;
++__a;
++__r;
}
else if (_M_comp(*__c, *__a))
{ ++__c; }
else
{
++__a;
++__c;
}
}
return std::copy(__a, __b, __r);
}
_DifferenceType
__count(_IIter __a, _IIter __b,
_IIter __c, _IIter __d) const
{
_DifferenceType __counter = 0;
while (__a != __b && __c != __d)
{
if (_M_comp(*__a, *__c))
{
++__a;
++__counter;
}
else if (_M_comp(*__c, *__a))
{ ++__c; }
else
{ ++__a; ++__c; }
}
return __counter + (__b - __a);
}
_OutputIterator
__first_empty(_IIter, _IIter, _OutputIterator __out) const
{ return __out; }
_OutputIterator
__second_empty(_IIter __a, _IIter __b, _OutputIterator __out) const
{ return std::copy(__a, __b, __out); }
};
template<typename _IIter,
typename _OutputIterator,
typename _Compare>
struct __intersection_func
{
typedef std::iterator_traits<_IIter> _TraitsType;
typedef typename _TraitsType::difference_type _DifferenceType;
typedef typename std::pair<_IIter, _IIter> _IteratorPair;
__intersection_func(_Compare __comp) : _M_comp(__comp) {}
_Compare _M_comp;
_OutputIterator
_M_invoke(_IIter __a, _IIter __b, _IIter __c, _IIter __d,
_OutputIterator __r) const
{
while (__a != __b && __c != __d)
{
if (_M_comp(*__a, *__c))
{ ++__a; }
else if (_M_comp(*__c, *__a))
{ ++__c; }
else
{
*__r = *__a;
++__a;
++__c;
++__r;
}
}
return __r;
}
_DifferenceType
__count(_IIter __a, _IIter __b, _IIter __c, _IIter __d) const
{
_DifferenceType __counter = 0;
while (__a != __b && __c != __d)
{
if (_M_comp(*__a, *__c))
{ ++__a; }
else if (_M_comp(*__c, *__a))
{ ++__c; }
else
{
++__a;
++__c;
++__counter;
}
}
return __counter;
}
_OutputIterator
__first_empty(_IIter, _IIter, _OutputIterator __out) const
{ return __out; }
_OutputIterator
__second_empty(_IIter, _IIter, _OutputIterator __out) const
{ return __out; }
};
template<class _IIter, class _OutputIterator, class _Compare>
struct __union_func
{
typedef typename std::iterator_traits<_IIter>::difference_type
_DifferenceType;
__union_func(_Compare __comp) : _M_comp(__comp) {}
_Compare _M_comp;
_OutputIterator
_M_invoke(_IIter __a, const _IIter __b, _IIter __c,
const _IIter __d, _OutputIterator __r) const
{
while (__a != __b && __c != __d)
{
if (_M_comp(*__a, *__c))
{
*__r = *__a;
++__a;
}
else if (_M_comp(*__c, *__a))
{
*__r = *__c;
++__c;
}
else
{
*__r = *__a;
++__a;
++__c;
}
++__r;
}
return std::copy(__c, __d, std::copy(__a, __b, __r));
}
_DifferenceType
__count(_IIter __a, _IIter __b, _IIter __c, _IIter __d) const
{
_DifferenceType __counter = 0;
while (__a != __b && __c != __d)
{
if (_M_comp(*__a, *__c))
{ ++__a; }
else if (_M_comp(*__c, *__a))
{ ++__c; }
else
{
++__a;
++__c;
}
++__counter;
}
__counter += (__b - __a);
__counter += (__d - __c);
return __counter;
}
_OutputIterator
__first_empty(_IIter __c, _IIter __d, _OutputIterator __out) const
{ return std::copy(__c, __d, __out); }
_OutputIterator
__second_empty(_IIter __a, _IIter __b, _OutputIterator __out) const
{ return std::copy(__a, __b, __out); }
};
template<typename _IIter,
typename _OutputIterator,
typename _Operation>
_OutputIterator
__parallel_set_operation(_IIter __begin1, _IIter __end1,
_IIter __begin2, _IIter __end2,
_OutputIterator __result, _Operation __op)
{
_GLIBCXX_CALL((__end1 - __begin1) + (__end2 - __begin2))
typedef std::iterator_traits<_IIter> _TraitsType;
typedef typename _TraitsType::difference_type _DifferenceType;
typedef typename std::pair<_IIter, _IIter> _IteratorPair;
if (__begin1 == __end1)
return __op.__first_empty(__begin2, __end2, __result);
if (__begin2 == __end2)
return __op.__second_empty(__begin1, __end1, __result);
const _DifferenceType __size = (__end1 - __begin1) + (__end2 - __begin2);
const _IteratorPair __sequence[2] = { std::make_pair(__begin1, __end1),
std::make_pair(__begin2, __end2) };
_OutputIterator __return_value = __result;
_DifferenceType *__borders;
_IteratorPair *__block_begins;
_DifferenceType* __lengths;
_ThreadIndex __num_threads =
std::min<_DifferenceType>(__get_max_threads(),
std::min(__end1 - __begin1, __end2 - __begin2));
# pragma omp parallel num_threads(__num_threads)
{
# pragma omp single
{
__num_threads = omp_get_num_threads();
__borders = new _DifferenceType[__num_threads + 2];
__equally_split(__size, __num_threads + 1, __borders);
__block_begins = new _IteratorPair[__num_threads + 1];
// Very __start.
__block_begins[0] = std::make_pair(__begin1, __begin2);
__lengths = new _DifferenceType[__num_threads];
} //single
_ThreadIndex __iam = omp_get_thread_num();
// _Result from multiseq_partition.
_IIter __offset[2];
const _DifferenceType __rank = __borders[__iam + 1];
multiseq_partition(__sequence, __sequence + 2,
__rank, __offset, __op._M_comp);
// allowed to read?
// together
// *(__offset[ 0 ] - 1) == *__offset[ 1 ]
if (__offset[ 0 ] != __begin1 && __offset[1] != __end2
&& !__op._M_comp(*(__offset[0] - 1), *__offset[1])
&& !__op._M_comp(*__offset[1], *(__offset[0] - 1)))
{
// Avoid split between globally equal elements: move one to
// front in first sequence.
--__offset[0];
}
_IteratorPair __block_end = __block_begins[__iam + 1] =
_IteratorPair(__offset[0], __offset[1]);
// Make sure all threads have their block_begin result written out.
# pragma omp barrier
_IteratorPair __block_begin = __block_begins[__iam];
// Begin working for the first block, while the others except
// the last start to count.
if (__iam == 0)
{
// The first thread can copy already.
__lengths[ __iam ] =
__op._M_invoke(__block_begin.first, __block_end.first,
__block_begin.second, __block_end.second,
__result) - __result;
}
else
{
__lengths[ __iam ] =
__op.__count(__block_begin.first, __block_end.first,
__block_begin.second, __block_end.second);
}
// Make sure everyone wrote their lengths.
# pragma omp barrier
_OutputIterator __r = __result;
if (__iam == 0)
{
// Do the last block.
for (_ThreadIndex __i = 0; __i < __num_threads; ++__i)
__r += __lengths[__i];
__block_begin = __block_begins[__num_threads];
// Return the result iterator of the last block.
__return_value =
__op._M_invoke(__block_begin.first, __end1,
__block_begin.second, __end2, __r);
}
else
{
for (_ThreadIndex __i = 0; __i < __iam; ++__i)
__r += __lengths[ __i ];
// Reset begins for copy pass.
__op._M_invoke(__block_begin.first, __block_end.first,
__block_begin.second, __block_end.second, __r);
}
}
return __return_value;
}
template<typename _IIter,
typename _OutputIterator,
typename _Compare>
inline _OutputIterator
__parallel_set_union(_IIter __begin1, _IIter __end1,
_IIter __begin2, _IIter __end2,
_OutputIterator __result, _Compare __comp)
{
return __parallel_set_operation(__begin1, __end1, __begin2, __end2,
__result,
__union_func< _IIter, _OutputIterator,
_Compare>(__comp));
}
template<typename _IIter,
typename _OutputIterator,
typename _Compare>
inline _OutputIterator
__parallel_set_intersection(_IIter __begin1, _IIter __end1,
_IIter __begin2, _IIter __end2,
_OutputIterator __result, _Compare __comp)
{
return __parallel_set_operation(__begin1, __end1, __begin2, __end2,
__result,
__intersection_func<_IIter,
_OutputIterator, _Compare>(__comp));
}
template<typename _IIter,
typename _OutputIterator,
typename _Compare>
inline _OutputIterator
__parallel_set_difference(_IIter __begin1, _IIter __end1,
_IIter __begin2, _IIter __end2,
_OutputIterator __result, _Compare __comp)
{
return __parallel_set_operation(__begin1, __end1, __begin2, __end2,
__result,
__difference_func<_IIter,
_OutputIterator, _Compare>(__comp));
}
template<typename _IIter,
typename _OutputIterator,
typename _Compare>
inline _OutputIterator
__parallel_set_symmetric_difference(_IIter __begin1, _IIter __end1,
_IIter __begin2, _IIter __end2,
_OutputIterator __result,
_Compare __comp)
{
return __parallel_set_operation(__begin1, __end1, __begin2, __end2,
__result,
__symmetric_difference_func<_IIter,
_OutputIterator, _Compare>(__comp));
}
}
#endif /* _GLIBCXX_PARALLEL_SET_OPERATIONS_H */
c++/8/parallel/algorithm 0000644 00000002545 15201526705 0011001 0 ustar 00 // Algorithm extensions -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file parallel/algorithm
* This file is a GNU extension to the Standard C++ Library.
*/
#ifndef _PARALLEL_ALGORITHM
#define _PARALLEL_ALGORITHM 1
#pragma GCC system_header
#include <algorithm>
#include <parallel/algorithmfwd.h>
#include <parallel/algobase.h>
#include <parallel/algo.h>
#endif
c++/8/memory 0000644 00000011147 15201526705 0006525 0 ustar 00 // <memory> -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
* Copyright (c) 1997-1999
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*/
/** @file include/memory
* This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_MEMORY
#define _GLIBCXX_MEMORY 1
#pragma GCC system_header
/**
* @defgroup memory Memory
* @ingroup utilities
*
* Components for memory allocation, deallocation, and management.
*/
/**
* @defgroup pointer_abstractions Pointer Abstractions
* @ingroup memory
*
* Smart pointers, etc.
*/
#include <bits/stl_algobase.h>
#include <bits/allocator.h>
#include <bits/stl_construct.h>
#include <bits/stl_uninitialized.h>
#include <bits/stl_tempbuf.h>
#include <bits/stl_raw_storage_iter.h>
#if __cplusplus >= 201103L
# include <exception> // std::exception
# include <typeinfo> // std::type_info in get_deleter
# include <iosfwd> // std::basic_ostream
# include <ext/atomicity.h>
# include <ext/concurrence.h>
# include <bits/functexcept.h>
# include <bits/stl_function.h> // std::less
# include <bits/uses_allocator.h>
# include <type_traits>
# include <debug/debug.h>
# include <bits/unique_ptr.h>
# include <bits/shared_ptr.h>
# include <bits/shared_ptr_atomic.h>
# if _GLIBCXX_USE_DEPRECATED
# include <backward/auto_ptr.h>
# endif
#else
# include <backward/auto_ptr.h>
#endif
#if __cplusplus >= 201103L
# include <cstdint>
# ifdef _GLIBCXX_USE_C99_STDINT_TR1
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @brief Fit aligned storage in buffer.
*
* [ptr.align]
*
* This function tries to fit @a __size bytes of storage with alignment
* @a __align into the buffer @a __ptr of size @a __space bytes. If such
* a buffer fits then @a __ptr is changed to point to the first byte of the
* aligned storage and @a __space is reduced by the bytes used for alignment.
*
* @param __align A fundamental or extended alignment value.
* @param __size Size of the aligned storage required.
* @param __ptr Pointer to a buffer of @a __space bytes.
* @param __space Size of the buffer pointed to by @a __ptr.
* @return the updated pointer if the aligned storage fits, otherwise nullptr.
*/
inline void*
align(size_t __align, size_t __size, void*& __ptr, size_t& __space) noexcept
{
const auto __intptr = reinterpret_cast<uintptr_t>(__ptr);
const auto __aligned = (__intptr - 1u + __align) & -__align;
const auto __diff = __aligned - __intptr;
if ((__size + __diff) > __space)
return nullptr;
else
{
__space -= __diff;
return __ptr = reinterpret_cast<void*>(__aligned);
}
}
// 20.7.4 [util.dynamic.safety], pointer safety
enum class pointer_safety { relaxed, preferred, strict };
inline void
declare_reachable(void*) { }
template <typename _Tp>
inline _Tp*
undeclare_reachable(_Tp* __p) { return __p; }
inline void
declare_no_pointers(char*, size_t) { }
inline void
undeclare_no_pointers(char*, size_t) { }
inline pointer_safety
get_pointer_safety() noexcept { return pointer_safety::relaxed; }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif // _GLIBCXX_USE_C99_STDINT_TR1
#endif // C++11
#endif /* _GLIBCXX_MEMORY */
c++/8/typeinfo 0000644 00000017014 15201526705 0007051 0 ustar 00 // RTTI support for -*- C++ -*-
// Copyright (C) 1994-2018 Free Software Foundation, Inc.
//
// This file is part of GCC.
//
// GCC is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// GCC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file typeinfo
* This is a Standard C++ Library header.
*/
#ifndef _TYPEINFO
#define _TYPEINFO
#pragma GCC system_header
#include <bits/exception.h>
#if __cplusplus >= 201103L
#include <bits/hash_bytes.h>
#endif
#pragma GCC visibility push(default)
extern "C++" {
namespace __cxxabiv1
{
class __class_type_info;
} // namespace __cxxabiv1
// Determine whether typeinfo names for the same type are merged (in which
// case comparison can just compare pointers) or not (in which case strings
// must be compared), and whether comparison is to be implemented inline or
// not. We used to do inline pointer comparison by default if weak symbols
// are available, but even with weak symbols sometimes names are not merged
// when objects are loaded with RTLD_LOCAL, so now we always use strcmp by
// default. For ABI compatibility, we do the strcmp inline if weak symbols
// are available, and out-of-line if not. Out-of-line pointer comparison
// is used where the object files are to be portable to multiple systems,
// some of which may not be able to use pointer comparison, but the
// particular system for which libstdc++ is being built can use pointer
// comparison; in particular for most ARM EABI systems, where the ABI
// specifies out-of-line comparison. The compiler's target configuration
// can override the defaults by defining __GXX_TYPEINFO_EQUALITY_INLINE to
// 1 or 0 to indicate whether or not comparison is inline, and
// __GXX_MERGED_TYPEINFO_NAMES to 1 or 0 to indicate whether or not pointer
// comparison can be used.
#ifndef __GXX_MERGED_TYPEINFO_NAMES
// By default, typeinfo names are not merged.
#define __GXX_MERGED_TYPEINFO_NAMES 0
#endif
// By default follow the old inline rules to avoid ABI changes.
#ifndef __GXX_TYPEINFO_EQUALITY_INLINE
#if !__GXX_WEAK__
#define __GXX_TYPEINFO_EQUALITY_INLINE 0
#else
#define __GXX_TYPEINFO_EQUALITY_INLINE 1
#endif
#endif
namespace std
{
/**
* @brief Part of RTTI.
*
* The @c type_info class describes type information generated by
* an implementation.
*/
class type_info
{
public:
/** Destructor first. Being the first non-inline virtual function, this
* controls in which translation unit the vtable is emitted. The
* compiler makes use of that information to know where to emit
* the runtime-mandated type_info structures in the new-abi. */
virtual ~type_info();
/** Returns an @e implementation-defined byte string; this is not
* portable between compilers! */
const char* name() const _GLIBCXX_NOEXCEPT
{ return __name[0] == '*' ? __name + 1 : __name; }
#if !__GXX_TYPEINFO_EQUALITY_INLINE
// In old abi, or when weak symbols are not supported, there can
// be multiple instances of a type_info object for one
// type. Uniqueness must use the _name value, not object address.
bool before(const type_info& __arg) const _GLIBCXX_NOEXCEPT;
bool operator==(const type_info& __arg) const _GLIBCXX_NOEXCEPT;
#else
#if !__GXX_MERGED_TYPEINFO_NAMES
/** Returns true if @c *this precedes @c __arg in the implementation's
* collation order. */
// Even with the new abi, on systems that support dlopen
// we can run into cases where type_info names aren't merged,
// so we still need to do string comparison.
bool before(const type_info& __arg) const _GLIBCXX_NOEXCEPT
{ return (__name[0] == '*' && __arg.__name[0] == '*')
? __name < __arg.__name
: __builtin_strcmp (__name, __arg.__name) < 0; }
bool operator==(const type_info& __arg) const _GLIBCXX_NOEXCEPT
{
return ((__name == __arg.__name)
|| (__name[0] != '*' &&
__builtin_strcmp (__name, __arg.__name) == 0));
}
#else
// On some targets we can rely on type_info's NTBS being unique,
// and therefore address comparisons are sufficient.
bool before(const type_info& __arg) const _GLIBCXX_NOEXCEPT
{ return __name < __arg.__name; }
bool operator==(const type_info& __arg) const _GLIBCXX_NOEXCEPT
{ return __name == __arg.__name; }
#endif
#endif
bool operator!=(const type_info& __arg) const _GLIBCXX_NOEXCEPT
{ return !operator==(__arg); }
#if __cplusplus >= 201103L
size_t hash_code() const noexcept
{
# if !__GXX_MERGED_TYPEINFO_NAMES
return _Hash_bytes(name(), __builtin_strlen(name()),
static_cast<size_t>(0xc70f6907UL));
# else
return reinterpret_cast<size_t>(__name);
# endif
}
#endif // C++11
// Return true if this is a pointer type of some kind
virtual bool __is_pointer_p() const;
// Return true if this is a function type
virtual bool __is_function_p() const;
// Try and catch a thrown type. Store an adjusted pointer to the
// caught type in THR_OBJ. If THR_TYPE is not a pointer type, then
// THR_OBJ points to the thrown object. If THR_TYPE is a pointer
// type, then THR_OBJ is the pointer itself. OUTER indicates the
// number of outer pointers, and whether they were const
// qualified.
virtual bool __do_catch(const type_info *__thr_type, void **__thr_obj,
unsigned __outer) const;
// Internally used during catch matching
virtual bool __do_upcast(const __cxxabiv1::__class_type_info *__target,
void **__obj_ptr) const;
protected:
const char *__name;
explicit type_info(const char *__n): __name(__n) { }
private:
/// Assigning type_info is not supported.
type_info& operator=(const type_info&);
type_info(const type_info&);
};
/**
* @brief Thrown during incorrect typecasting.
* @ingroup exceptions
*
* If you attempt an invalid @c dynamic_cast expression, an instance of
* this class (or something derived from this class) is thrown. */
class bad_cast : public exception
{
public:
bad_cast() _GLIBCXX_USE_NOEXCEPT { }
// This declaration is not useless:
// http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118
virtual ~bad_cast() _GLIBCXX_USE_NOEXCEPT;
// See comment in eh_exception.cc.
virtual const char* what() const _GLIBCXX_USE_NOEXCEPT;
};
/**
* @brief Thrown when a NULL pointer in a @c typeid expression is used.
* @ingroup exceptions
*/
class bad_typeid : public exception
{
public:
bad_typeid () _GLIBCXX_USE_NOEXCEPT { }
// This declaration is not useless:
// http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118
virtual ~bad_typeid() _GLIBCXX_USE_NOEXCEPT;
// See comment in eh_exception.cc.
virtual const char* what() const _GLIBCXX_USE_NOEXCEPT;
};
} // namespace std
} // extern "C++"
#pragma GCC visibility pop
#endif
c++/8/cstdarg 0000644 00000003514 15201526705 0006643 0 ustar 00 // -*- C++ -*- forwarding header.
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/cstdarg
* This is a Standard C++ Library file. You should @c \#include this file
* in your programs, rather than any of the @a *.h implementation files.
*
* This is the C++ version of the Standard C Library header @c stdarg.h,
* and its contents are (mostly) the same as that header, but are all
* contained in the namespace @c std (except for names which are defined
* as macros in C).
*/
//
// ISO C++ 14882: 20.4.6 C library
//
#pragma GCC system_header
#undef __need___va_list
#include <bits/c++config.h>
#include <stdarg.h>
#ifndef _GLIBCXX_CSTDARG
#define _GLIBCXX_CSTDARG 1
// Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998
#ifndef va_end
#define va_end(ap) va_end (ap)
#endif
namespace std
{
using ::va_list;
} // namespace std
#endif
c++/8/cstdint 0000644 00000004167 15201526705 0006671 0 ustar 00 // <cstdint> -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/cstdint
* This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_CSTDINT
#define _GLIBCXX_CSTDINT 1
#pragma GCC system_header
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
#include <bits/c++config.h>
#if _GLIBCXX_HAVE_STDINT_H
# include <stdint.h>
#endif
#ifdef _GLIBCXX_USE_C99_STDINT_TR1
namespace std
{
using ::int8_t;
using ::int16_t;
using ::int32_t;
using ::int64_t;
using ::int_fast8_t;
using ::int_fast16_t;
using ::int_fast32_t;
using ::int_fast64_t;
using ::int_least8_t;
using ::int_least16_t;
using ::int_least32_t;
using ::int_least64_t;
using ::intmax_t;
using ::intptr_t;
using ::uint8_t;
using ::uint16_t;
using ::uint32_t;
using ::uint64_t;
using ::uint_fast8_t;
using ::uint_fast16_t;
using ::uint_fast32_t;
using ::uint_fast64_t;
using ::uint_least8_t;
using ::uint_least16_t;
using ::uint_least32_t;
using ::uint_least64_t;
using ::uintmax_t;
using ::uintptr_t;
} // namespace std
#endif // _GLIBCXX_USE_C99_STDINT_TR1
#endif // C++11
#endif // _GLIBCXX_CSTDINT
c++/8/cinttypes 0000644 00000004155 15201526705 0007240 0 ustar 00 // <cinttypes> -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/cinttypes
* This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_CINTTYPES
#define _GLIBCXX_CINTTYPES 1
#pragma GCC system_header
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
#include <cstdint>
// For 27.9.2/3 (see C99, Note 184)
#if _GLIBCXX_HAVE_INTTYPES_H
# ifndef __STDC_FORMAT_MACROS
# define _UNDEF__STDC_FORMAT_MACROS
# define __STDC_FORMAT_MACROS
# endif
# include <inttypes.h>
# ifdef _UNDEF__STDC_FORMAT_MACROS
# undef __STDC_FORMAT_MACROS
# undef _UNDEF__STDC_FORMAT_MACROS
# endif
#endif
#ifdef _GLIBCXX_USE_C99_INTTYPES_TR1
namespace std
{
// types
using ::imaxdiv_t;
// functions
using ::imaxabs;
using ::imaxdiv;
// GCC does not support extended integer types
// intmax_t abs(intmax_t)
// imaxdiv_t div(intmax_t, intmax_t)
using ::strtoimax;
using ::strtoumax;
#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1
using ::wcstoimax;
using ::wcstoumax;
#endif
} // namespace std
#endif // _GLIBCXX_USE_C99_INTTYPES_TR1
#endif // C++11
#endif // _GLIBCXX_CINTTYPES
c++/8/vector 0000644 00000005273 15201526705 0006522 0 ustar 00 // <vector> -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1996
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file include/vector
* This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_VECTOR
#define _GLIBCXX_VECTOR 1
#pragma GCC system_header
#include <bits/stl_algobase.h>
#include <bits/allocator.h>
#include <bits/stl_construct.h>
#include <bits/stl_uninitialized.h>
#include <bits/stl_vector.h>
#include <bits/stl_bvector.h>
#include <bits/range_access.h>
#ifndef _GLIBCXX_EXPORT_TEMPLATE
# include <bits/vector.tcc>
#endif
#ifdef _GLIBCXX_DEBUG
# include <debug/vector>
#endif
#ifdef _GLIBCXX_PROFILE
# include <profile/vector>
#endif
#endif /* _GLIBCXX_VECTOR */
c++/8/istream 0000644 00000100113 15201526705 0006651 0 ustar 00 // Input streams -*- C++ -*-
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 27.6.1 Input streams
//
/** @file include/istream
* This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_ISTREAM
#define _GLIBCXX_ISTREAM 1
#pragma GCC system_header
#include <ios>
#include <ostream>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @brief Template class basic_istream.
* @ingroup io
*
* @tparam _CharT Type of character stream.
* @tparam _Traits Traits for character type, defaults to
* char_traits<_CharT>.
*
* This is the base class for all input streams. It provides text
* formatting of all builtin types, and communicates with any class
* derived from basic_streambuf to do the actual input.
*/
template<typename _CharT, typename _Traits>
class basic_istream : virtual public basic_ios<_CharT, _Traits>
{
public:
// Types (inherited from basic_ios (27.4.4)):
typedef _CharT char_type;
typedef typename _Traits::int_type int_type;
typedef typename _Traits::pos_type pos_type;
typedef typename _Traits::off_type off_type;
typedef _Traits traits_type;
// Non-standard Types:
typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
typedef basic_ios<_CharT, _Traits> __ios_type;
typedef basic_istream<_CharT, _Traits> __istream_type;
typedef num_get<_CharT, istreambuf_iterator<_CharT, _Traits> >
__num_get_type;
typedef ctype<_CharT> __ctype_type;
protected:
// Data Members:
/**
* The number of characters extracted in the previous unformatted
* function; see gcount().
*/
streamsize _M_gcount;
public:
/**
* @brief Base constructor.
*
* This ctor is almost never called by the user directly, rather from
* derived classes' initialization lists, which pass a pointer to
* their own stream buffer.
*/
explicit
basic_istream(__streambuf_type* __sb)
: _M_gcount(streamsize(0))
{ this->init(__sb); }
/**
* @brief Base destructor.
*
* This does very little apart from providing a virtual base dtor.
*/
virtual
~basic_istream()
{ _M_gcount = streamsize(0); }
/// Safe prefix/suffix operations.
class sentry;
friend class sentry;
//@{
/**
* @brief Interface for manipulators.
*
* Manipulators such as @c std::ws and @c std::dec use these
* functions in constructs like
* <code>std::cin >> std::ws</code>.
* For more information, see the iomanip header.
*/
__istream_type&
operator>>(__istream_type& (*__pf)(__istream_type&))
{ return __pf(*this); }
__istream_type&
operator>>(__ios_type& (*__pf)(__ios_type&))
{
__pf(*this);
return *this;
}
__istream_type&
operator>>(ios_base& (*__pf)(ios_base&))
{
__pf(*this);
return *this;
}
//@}
//@{
/**
* @name Extractors
*
* All the @c operator>> functions (aka <em>formatted input
* functions</em>) have some common behavior. Each starts by
* constructing a temporary object of type std::basic_istream::sentry
* with the second argument (noskipws) set to false. This has several
* effects, concluding with the setting of a status flag; see the
* sentry documentation for more.
*
* If the sentry status is good, the function tries to extract
* whatever data is appropriate for the type of the argument.
*
* If an exception is thrown during extraction, ios_base::badbit
* will be turned on in the stream's error state (without causing an
* ios_base::failure to be thrown) and the original exception will
* be rethrown if badbit is set in the exceptions mask.
*/
//@{
/**
* @brief Integer arithmetic extractors
* @param __n A variable of builtin integral type.
* @return @c *this if successful
*
* These functions use the stream's current locale (specifically, the
* @c num_get facet) to parse the input data.
*/
__istream_type&
operator>>(bool& __n)
{ return _M_extract(__n); }
__istream_type&
operator>>(short& __n);
__istream_type&
operator>>(unsigned short& __n)
{ return _M_extract(__n); }
__istream_type&
operator>>(int& __n);
__istream_type&
operator>>(unsigned int& __n)
{ return _M_extract(__n); }
__istream_type&
operator>>(long& __n)
{ return _M_extract(__n); }
__istream_type&
operator>>(unsigned long& __n)
{ return _M_extract(__n); }
#ifdef _GLIBCXX_USE_LONG_LONG
__istream_type&
operator>>(long long& __n)
{ return _M_extract(__n); }
__istream_type&
operator>>(unsigned long long& __n)
{ return _M_extract(__n); }
#endif
//@}
//@{
/**
* @brief Floating point arithmetic extractors
* @param __f A variable of builtin floating point type.
* @return @c *this if successful
*
* These functions use the stream's current locale (specifically, the
* @c num_get facet) to parse the input data.
*/
__istream_type&
operator>>(float& __f)
{ return _M_extract(__f); }
__istream_type&
operator>>(double& __f)
{ return _M_extract(__f); }
__istream_type&
operator>>(long double& __f)
{ return _M_extract(__f); }
//@}
/**
* @brief Basic arithmetic extractors
* @param __p A variable of pointer type.
* @return @c *this if successful
*
* These functions use the stream's current locale (specifically, the
* @c num_get facet) to parse the input data.
*/
__istream_type&
operator>>(void*& __p)
{ return _M_extract(__p); }
/**
* @brief Extracting into another streambuf.
* @param __sb A pointer to a streambuf
*
* This function behaves like one of the basic arithmetic extractors,
* in that it also constructs a sentry object and has the same error
* handling behavior.
*
* If @p __sb is NULL, the stream will set failbit in its error state.
*
* Characters are extracted from this stream and inserted into the
* @p __sb streambuf until one of the following occurs:
*
* - the input stream reaches end-of-file,
* - insertion into the output buffer fails (in this case, the
* character that would have been inserted is not extracted), or
* - an exception occurs (and in this case is caught)
*
* If the function inserts no characters, failbit is set.
*/
__istream_type&
operator>>(__streambuf_type* __sb);
//@}
// [27.6.1.3] unformatted input
/**
* @brief Character counting
* @return The number of characters extracted by the previous
* unformatted input function dispatched for this stream.
*/
streamsize
gcount() const
{ return _M_gcount; }
//@{
/**
* @name Unformatted Input Functions
*
* All the unformatted input functions have some common behavior.
* Each starts by constructing a temporary object of type
* std::basic_istream::sentry with the second argument (noskipws)
* set to true. This has several effects, concluding with the
* setting of a status flag; see the sentry documentation for more.
*
* If the sentry status is good, the function tries to extract
* whatever data is appropriate for the type of the argument.
*
* The number of characters extracted is stored for later retrieval
* by gcount().
*
* If an exception is thrown during extraction, ios_base::badbit
* will be turned on in the stream's error state (without causing an
* ios_base::failure to be thrown) and the original exception will
* be rethrown if badbit is set in the exceptions mask.
*/
/**
* @brief Simple extraction.
* @return A character, or eof().
*
* Tries to extract a character. If none are available, sets failbit
* and returns traits::eof().
*/
int_type
get();
/**
* @brief Simple extraction.
* @param __c The character in which to store data.
* @return *this
*
* Tries to extract a character and store it in @a __c. If none are
* available, sets failbit and returns traits::eof().
*
* @note This function is not overloaded on signed char and
* unsigned char.
*/
__istream_type&
get(char_type& __c);
/**
* @brief Simple multiple-character extraction.
* @param __s Pointer to an array.
* @param __n Maximum number of characters to store in @a __s.
* @param __delim A "stop" character.
* @return *this
*
* Characters are extracted and stored into @a __s until one of the
* following happens:
*
* - @c __n-1 characters are stored
* - the input sequence reaches EOF
* - the next character equals @a __delim, in which case the character
* is not extracted
*
* If no characters are stored, failbit is set in the stream's error
* state.
*
* In any case, a null character is stored into the next location in
* the array.
*
* @note This function is not overloaded on signed char and
* unsigned char.
*/
__istream_type&
get(char_type* __s, streamsize __n, char_type __delim);
/**
* @brief Simple multiple-character extraction.
* @param __s Pointer to an array.
* @param __n Maximum number of characters to store in @a s.
* @return *this
*
* Returns @c get(__s,__n,widen('\\n')).
*/
__istream_type&
get(char_type* __s, streamsize __n)
{ return this->get(__s, __n, this->widen('\n')); }
/**
* @brief Extraction into another streambuf.
* @param __sb A streambuf in which to store data.
* @param __delim A "stop" character.
* @return *this
*
* Characters are extracted and inserted into @a __sb until one of the
* following happens:
*
* - the input sequence reaches EOF
* - insertion into the output buffer fails (in this case, the
* character that would have been inserted is not extracted)
* - the next character equals @a __delim (in this case, the character
* is not extracted)
* - an exception occurs (and in this case is caught)
*
* If no characters are stored, failbit is set in the stream's error
* state.
*/
__istream_type&
get(__streambuf_type& __sb, char_type __delim);
/**
* @brief Extraction into another streambuf.
* @param __sb A streambuf in which to store data.
* @return *this
*
* Returns @c get(__sb,widen('\\n')).
*/
__istream_type&
get(__streambuf_type& __sb)
{ return this->get(__sb, this->widen('\n')); }
/**
* @brief String extraction.
* @param __s A character array in which to store the data.
* @param __n Maximum number of characters to extract.
* @param __delim A "stop" character.
* @return *this
*
* Extracts and stores characters into @a __s until one of the
* following happens. Note that these criteria are required to be
* tested in the order listed here, to allow an input line to exactly
* fill the @a __s array without setting failbit.
*
* -# the input sequence reaches end-of-file, in which case eofbit
* is set in the stream error state
* -# the next character equals @c __delim, in which case the character
* is extracted (and therefore counted in @c gcount()) but not stored
* -# @c __n-1 characters are stored, in which case failbit is set
* in the stream error state
*
* If no characters are extracted, failbit is set. (An empty line of
* input should therefore not cause failbit to be set.)
*
* In any case, a null character is stored in the next location in
* the array.
*/
__istream_type&
getline(char_type* __s, streamsize __n, char_type __delim);
/**
* @brief String extraction.
* @param __s A character array in which to store the data.
* @param __n Maximum number of characters to extract.
* @return *this
*
* Returns @c getline(__s,__n,widen('\\n')).
*/
__istream_type&
getline(char_type* __s, streamsize __n)
{ return this->getline(__s, __n, this->widen('\n')); }
/**
* @brief Discarding characters
* @param __n Number of characters to discard.
* @param __delim A "stop" character.
* @return *this
*
* Extracts characters and throws them away until one of the
* following happens:
* - if @a __n @c != @c std::numeric_limits<int>::max(), @a __n
* characters are extracted
* - the input sequence reaches end-of-file
* - the next character equals @a __delim (in this case, the character
* is extracted); note that this condition will never occur if
* @a __delim equals @c traits::eof().
*
* NB: Provide three overloads, instead of the single function
* (with defaults) mandated by the Standard: this leads to a
* better performing implementation, while still conforming to
* the Standard.
*/
__istream_type&
ignore(streamsize __n, int_type __delim);
__istream_type&
ignore(streamsize __n);
__istream_type&
ignore();
/**
* @brief Looking ahead in the stream
* @return The next character, or eof().
*
* If, after constructing the sentry object, @c good() is false,
* returns @c traits::eof(). Otherwise reads but does not extract
* the next input character.
*/
int_type
peek();
/**
* @brief Extraction without delimiters.
* @param __s A character array.
* @param __n Maximum number of characters to store.
* @return *this
*
* If the stream state is @c good(), extracts characters and stores
* them into @a __s until one of the following happens:
* - @a __n characters are stored
* - the input sequence reaches end-of-file, in which case the error
* state is set to @c failbit|eofbit.
*
* @note This function is not overloaded on signed char and
* unsigned char.
*/
__istream_type&
read(char_type* __s, streamsize __n);
/**
* @brief Extraction until the buffer is exhausted, but no more.
* @param __s A character array.
* @param __n Maximum number of characters to store.
* @return The number of characters extracted.
*
* Extracts characters and stores them into @a __s depending on the
* number of characters remaining in the streambuf's buffer,
* @c rdbuf()->in_avail(), called @c A here:
* - if @c A @c == @c -1, sets eofbit and extracts no characters
* - if @c A @c == @c 0, extracts no characters
* - if @c A @c > @c 0, extracts @c min(A,n)
*
* The goal is to empty the current buffer, and to not request any
* more from the external input sequence controlled by the streambuf.
*/
streamsize
readsome(char_type* __s, streamsize __n);
/**
* @brief Unextracting a single character.
* @param __c The character to push back into the input stream.
* @return *this
*
* If @c rdbuf() is not null, calls @c rdbuf()->sputbackc(c).
*
* If @c rdbuf() is null or if @c sputbackc() fails, sets badbit in
* the error state.
*
* @note This function first clears eofbit. Since no characters
* are extracted, the next call to @c gcount() will return 0,
* as required by DR 60.
*/
__istream_type&
putback(char_type __c);
/**
* @brief Unextracting the previous character.
* @return *this
*
* If @c rdbuf() is not null, calls @c rdbuf()->sungetc(c).
*
* If @c rdbuf() is null or if @c sungetc() fails, sets badbit in
* the error state.
*
* @note This function first clears eofbit. Since no characters
* are extracted, the next call to @c gcount() will return 0,
* as required by DR 60.
*/
__istream_type&
unget();
/**
* @brief Synchronizing the stream buffer.
* @return 0 on success, -1 on failure
*
* If @c rdbuf() is a null pointer, returns -1.
*
* Otherwise, calls @c rdbuf()->pubsync(), and if that returns -1,
* sets badbit and returns -1.
*
* Otherwise, returns 0.
*
* @note This function does not count the number of characters
* extracted, if any, and therefore does not affect the next
* call to @c gcount().
*/
int
sync();
/**
* @brief Getting the current read position.
* @return A file position object.
*
* If @c fail() is not false, returns @c pos_type(-1) to indicate
* failure. Otherwise returns @c rdbuf()->pubseekoff(0,cur,in).
*
* @note This function does not count the number of characters
* extracted, if any, and therefore does not affect the next
* call to @c gcount(). At variance with putback, unget and
* seekg, eofbit is not cleared first.
*/
pos_type
tellg();
/**
* @brief Changing the current read position.
* @param __pos A file position object.
* @return *this
*
* If @c fail() is not true, calls @c rdbuf()->pubseekpos(__pos). If
* that function fails, sets failbit.
*
* @note This function first clears eofbit. It does not count the
* number of characters extracted, if any, and therefore does
* not affect the next call to @c gcount().
*/
__istream_type&
seekg(pos_type);
/**
* @brief Changing the current read position.
* @param __off A file offset object.
* @param __dir The direction in which to seek.
* @return *this
*
* If @c fail() is not true, calls @c rdbuf()->pubseekoff(__off,__dir).
* If that function fails, sets failbit.
*
* @note This function first clears eofbit. It does not count the
* number of characters extracted, if any, and therefore does
* not affect the next call to @c gcount().
*/
__istream_type&
seekg(off_type, ios_base::seekdir);
//@}
protected:
basic_istream()
: _M_gcount(streamsize(0))
{ this->init(0); }
#if __cplusplus >= 201103L
basic_istream(const basic_istream&) = delete;
basic_istream(basic_istream&& __rhs)
: __ios_type(), _M_gcount(__rhs._M_gcount)
{
__ios_type::move(__rhs);
__rhs._M_gcount = 0;
}
// 27.7.3.3 Assign/swap
basic_istream& operator=(const basic_istream&) = delete;
basic_istream&
operator=(basic_istream&& __rhs)
{
swap(__rhs);
return *this;
}
void
swap(basic_istream& __rhs)
{
__ios_type::swap(__rhs);
std::swap(_M_gcount, __rhs._M_gcount);
}
#endif
template<typename _ValueT>
__istream_type&
_M_extract(_ValueT& __v);
};
/// Explicit specialization declarations, defined in src/istream.cc.
template<>
basic_istream<char>&
basic_istream<char>::
getline(char_type* __s, streamsize __n, char_type __delim);
template<>
basic_istream<char>&
basic_istream<char>::
ignore(streamsize __n);
template<>
basic_istream<char>&
basic_istream<char>::
ignore(streamsize __n, int_type __delim);
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
basic_istream<wchar_t>&
basic_istream<wchar_t>::
getline(char_type* __s, streamsize __n, char_type __delim);
template<>
basic_istream<wchar_t>&
basic_istream<wchar_t>::
ignore(streamsize __n);
template<>
basic_istream<wchar_t>&
basic_istream<wchar_t>::
ignore(streamsize __n, int_type __delim);
#endif
/**
* @brief Performs setup work for input streams.
*
* Objects of this class are created before all of the standard
* extractors are run. It is responsible for <em>exception-safe
* prefix and suffix operations,</em> although only prefix actions
* are currently required by the standard.
*/
template<typename _CharT, typename _Traits>
class basic_istream<_CharT, _Traits>::sentry
{
// Data Members.
bool _M_ok;
public:
/// Easy access to dependent types.
typedef _Traits traits_type;
typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
typedef basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::__ctype_type __ctype_type;
typedef typename _Traits::int_type __int_type;
/**
* @brief The constructor performs all the work.
* @param __is The input stream to guard.
* @param __noskipws Whether to consume whitespace or not.
*
* If the stream state is good (@a __is.good() is true), then the
* following actions are performed, otherwise the sentry state
* is false (<em>not okay</em>) and failbit is set in the
* stream state.
*
* The sentry's preparatory actions are:
*
* -# if the stream is tied to an output stream, @c is.tie()->flush()
* is called to synchronize the output sequence
* -# if @a __noskipws is false, and @c ios_base::skipws is set in
* @c is.flags(), the sentry extracts and discards whitespace
* characters from the stream. The currently imbued locale is
* used to determine whether each character is whitespace.
*
* If the stream state is still good, then the sentry state becomes
* true (@a okay).
*/
explicit
sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false);
/**
* @brief Quick status checking.
* @return The sentry state.
*
* For ease of use, sentries may be converted to booleans. The
* return value is that of the sentry state (true == okay).
*/
#if __cplusplus >= 201103L
explicit
#endif
operator bool() const
{ return _M_ok; }
};
//@{
/**
* @brief Character extractors
* @param __in An input stream.
* @param __c A character reference.
* @return in
*
* Behaves like one of the formatted arithmetic extractors described in
* std::basic_istream. After constructing a sentry object with good
* status, this function extracts a character (if one is available) and
* stores it in @a __c. Otherwise, sets failbit in the input stream.
*/
template<typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c);
template<class _Traits>
inline basic_istream<char, _Traits>&
operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
{ return (__in >> reinterpret_cast<char&>(__c)); }
template<class _Traits>
inline basic_istream<char, _Traits>&
operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
{ return (__in >> reinterpret_cast<char&>(__c)); }
//@}
//@{
/**
* @brief Character string extractors
* @param __in An input stream.
* @param __s A pointer to a character array.
* @return __in
*
* Behaves like one of the formatted arithmetic extractors described in
* std::basic_istream. After constructing a sentry object with good
* status, this function extracts up to @c n characters and stores them
* into the array starting at @a __s. @c n is defined as:
*
* - if @c width() is greater than zero, @c n is width() otherwise
* - @c n is <em>the number of elements of the largest array of *
* - @c char_type that can store a terminating @c eos.</em>
* - [27.6.1.2.3]/6
*
* Characters are extracted and stored until one of the following happens:
* - @c n-1 characters are stored
* - EOF is reached
* - the next character is whitespace according to the current locale
* - the next character is a null byte (i.e., @c charT() )
*
* @c width(0) is then called for the input stream.
*
* If no characters are extracted, sets failbit.
*/
template<typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s);
// Explicit specialization declaration, defined in src/istream.cc.
template<>
basic_istream<char>&
operator>>(basic_istream<char>& __in, char* __s);
template<class _Traits>
inline basic_istream<char, _Traits>&
operator>>(basic_istream<char, _Traits>& __in, unsigned char* __s)
{ return (__in >> reinterpret_cast<char*>(__s)); }
template<class _Traits>
inline basic_istream<char, _Traits>&
operator>>(basic_istream<char, _Traits>& __in, signed char* __s)
{ return (__in >> reinterpret_cast<char*>(__s)); }
//@}
/**
* @brief Template class basic_iostream
* @ingroup io
*
* @tparam _CharT Type of character stream.
* @tparam _Traits Traits for character type, defaults to
* char_traits<_CharT>.
*
* This class multiply inherits from the input and output stream classes
* simply to provide a single interface.
*/
template<typename _CharT, typename _Traits>
class basic_iostream
: public basic_istream<_CharT, _Traits>,
public basic_ostream<_CharT, _Traits>
{
public:
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 271. basic_iostream missing typedefs
// Types (inherited):
typedef _CharT char_type;
typedef typename _Traits::int_type int_type;
typedef typename _Traits::pos_type pos_type;
typedef typename _Traits::off_type off_type;
typedef _Traits traits_type;
// Non-standard Types:
typedef basic_istream<_CharT, _Traits> __istream_type;
typedef basic_ostream<_CharT, _Traits> __ostream_type;
/**
* @brief Constructor does nothing.
*
* Both of the parent classes are initialized with the same
* streambuf pointer passed to this constructor.
*/
explicit
basic_iostream(basic_streambuf<_CharT, _Traits>* __sb)
: __istream_type(__sb), __ostream_type(__sb) { }
/**
* @brief Destructor does nothing.
*/
virtual
~basic_iostream() { }
protected:
basic_iostream()
: __istream_type(), __ostream_type() { }
#if __cplusplus >= 201103L
basic_iostream(const basic_iostream&) = delete;
basic_iostream(basic_iostream&& __rhs)
: __istream_type(std::move(__rhs)), __ostream_type(*this)
{ }
// 27.7.3.3 Assign/swap
basic_iostream& operator=(const basic_iostream&) = delete;
basic_iostream&
operator=(basic_iostream&& __rhs)
{
swap(__rhs);
return *this;
}
void
swap(basic_iostream& __rhs)
{ __istream_type::swap(__rhs); }
#endif
};
/**
* @brief Quick and easy way to eat whitespace
*
* This manipulator extracts whitespace characters, stopping when the
* next character is non-whitespace, or when the input sequence is empty.
* If the sequence is empty, @c eofbit is set in the stream, but not
* @c failbit.
*
* The current locale is used to distinguish whitespace characters.
*
* Example:
* @code
* MyClass mc;
*
* std::cin >> std::ws >> mc;
* @endcode
* will skip leading whitespace before calling operator>> on cin and your
* object. Note that the same effect can be achieved by creating a
* std::basic_istream::sentry inside your definition of operator>>.
*/
template<typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>&
ws(basic_istream<_CharT, _Traits>& __is);
#if __cplusplus >= 201103L
template<typename _Ch, typename _Up>
basic_istream<_Ch, _Up>&
__is_convertible_to_basic_istream_test(basic_istream<_Ch, _Up>*);
template<typename _Tp, typename = void>
struct __is_convertible_to_basic_istream_impl
{
using __istream_type = void;
};
template<typename _Tp>
using __do_is_convertible_to_basic_istream_impl =
decltype(__is_convertible_to_basic_istream_test
(declval<typename remove_reference<_Tp>::type*>()));
template<typename _Tp>
struct __is_convertible_to_basic_istream_impl
<_Tp,
__void_t<__do_is_convertible_to_basic_istream_impl<_Tp>>>
{
using __istream_type =
__do_is_convertible_to_basic_istream_impl<_Tp>;
};
template<typename _Tp>
struct __is_convertible_to_basic_istream
: __is_convertible_to_basic_istream_impl<_Tp>
{
public:
using type = __not_<is_void<
typename __is_convertible_to_basic_istream_impl<_Tp>::__istream_type>>;
constexpr static bool value = type::value;
};
template<typename _Istream, typename _Tp, typename = void>
struct __is_extractable : false_type {};
template<typename _Istream, typename _Tp>
struct __is_extractable<_Istream, _Tp,
__void_t<decltype(declval<_Istream&>()
>> declval<_Tp>())>>
: true_type {};
template<typename _Istream>
using __rvalue_istream_type =
typename __is_convertible_to_basic_istream<
_Istream>::__istream_type;
// [27.7.1.6] Rvalue stream extraction
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2328. Rvalue stream extraction should use perfect forwarding
/**
* @brief Generic extractor for rvalue stream
* @param __is An input stream.
* @param __x A reference to the extraction target.
* @return is
*
* This is just a forwarding function to allow extraction from
* rvalue streams since they won't bind to the extractor functions
* that take an lvalue reference.
*/
template<typename _Istream, typename _Tp>
inline
typename enable_if<__and_<__not_<is_lvalue_reference<_Istream>>,
__is_convertible_to_basic_istream<_Istream>,
__is_extractable<
__rvalue_istream_type<_Istream>,
_Tp&&>>::value,
__rvalue_istream_type<_Istream>>::type
operator>>(_Istream&& __is, _Tp&& __x)
{
__rvalue_istream_type<_Istream> __ret_is = __is;
__ret_is >> std::forward<_Tp>(__x);
return __ret_is;
}
#endif // C++11
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#include <bits/istream.tcc>
#endif /* _GLIBCXX_ISTREAM */
c++/8/string 0000644 00000003624 15201526705 0006524 0 ustar 00 // Components for manipulating sequences of characters -*- C++ -*-
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/string
* This is a Standard C++ Library header.
*/
//
// ISO C++ 14882: 21 Strings library
//
#ifndef _GLIBCXX_STRING
#define _GLIBCXX_STRING 1
#pragma GCC system_header
#include <bits/c++config.h>
#include <bits/stringfwd.h>
#include <bits/char_traits.h> // NB: In turn includes stl_algobase.h
#include <bits/allocator.h>
#include <bits/cpp_type_traits.h>
#include <bits/localefwd.h> // For operators >>, <<, and getline.
#include <bits/ostream_insert.h>
#include <bits/stl_iterator_base_types.h>
#include <bits/stl_iterator_base_funcs.h>
#include <bits/stl_iterator.h>
#include <bits/stl_function.h> // For less
#include <ext/numeric_traits.h>
#include <bits/stl_algobase.h>
#include <bits/range_access.h>
#include <bits/basic_string.h>
#include <bits/basic_string.tcc>
#endif /* _GLIBCXX_STRING */
c++/8/tuple 0000644 00000165676 15201526705 0006367 0 ustar 00 // <tuple> -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/tuple
* This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_TUPLE
#define _GLIBCXX_TUPLE 1
#pragma GCC system_header
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
#include <utility>
#include <array>
#include <bits/uses_allocator.h>
#include <bits/invoke.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @addtogroup utilities
* @{
*/
template<typename... _Elements>
class tuple;
template<typename _Tp>
struct __is_empty_non_tuple : is_empty<_Tp> { };
// Using EBO for elements that are tuples causes ambiguous base errors.
template<typename _El0, typename... _El>
struct __is_empty_non_tuple<tuple<_El0, _El...>> : false_type { };
// Use the Empty Base-class Optimization for empty, non-final types.
template<typename _Tp>
using __empty_not_final
= typename conditional<__is_final(_Tp), false_type,
__is_empty_non_tuple<_Tp>>::type;
template<std::size_t _Idx, typename _Head,
bool = __empty_not_final<_Head>::value>
struct _Head_base;
template<std::size_t _Idx, typename _Head>
struct _Head_base<_Idx, _Head, true>
: public _Head
{
constexpr _Head_base()
: _Head() { }
constexpr _Head_base(const _Head& __h)
: _Head(__h) { }
constexpr _Head_base(const _Head_base&) = default;
constexpr _Head_base(_Head_base&&) = default;
template<typename _UHead>
constexpr _Head_base(_UHead&& __h)
: _Head(std::forward<_UHead>(__h)) { }
_Head_base(allocator_arg_t, __uses_alloc0)
: _Head() { }
template<typename _Alloc>
_Head_base(allocator_arg_t, __uses_alloc1<_Alloc> __a)
: _Head(allocator_arg, *__a._M_a) { }
template<typename _Alloc>
_Head_base(allocator_arg_t, __uses_alloc2<_Alloc> __a)
: _Head(*__a._M_a) { }
template<typename _UHead>
_Head_base(__uses_alloc0, _UHead&& __uhead)
: _Head(std::forward<_UHead>(__uhead)) { }
template<typename _Alloc, typename _UHead>
_Head_base(__uses_alloc1<_Alloc> __a, _UHead&& __uhead)
: _Head(allocator_arg, *__a._M_a, std::forward<_UHead>(__uhead)) { }
template<typename _Alloc, typename _UHead>
_Head_base(__uses_alloc2<_Alloc> __a, _UHead&& __uhead)
: _Head(std::forward<_UHead>(__uhead), *__a._M_a) { }
static constexpr _Head&
_M_head(_Head_base& __b) noexcept { return __b; }
static constexpr const _Head&
_M_head(const _Head_base& __b) noexcept { return __b; }
};
template<std::size_t _Idx, typename _Head>
struct _Head_base<_Idx, _Head, false>
{
constexpr _Head_base()
: _M_head_impl() { }
constexpr _Head_base(const _Head& __h)
: _M_head_impl(__h) { }
constexpr _Head_base(const _Head_base&) = default;
constexpr _Head_base(_Head_base&&) = default;
template<typename _UHead>
constexpr _Head_base(_UHead&& __h)
: _M_head_impl(std::forward<_UHead>(__h)) { }
_Head_base(allocator_arg_t, __uses_alloc0)
: _M_head_impl() { }
template<typename _Alloc>
_Head_base(allocator_arg_t, __uses_alloc1<_Alloc> __a)
: _M_head_impl(allocator_arg, *__a._M_a) { }
template<typename _Alloc>
_Head_base(allocator_arg_t, __uses_alloc2<_Alloc> __a)
: _M_head_impl(*__a._M_a) { }
template<typename _UHead>
_Head_base(__uses_alloc0, _UHead&& __uhead)
: _M_head_impl(std::forward<_UHead>(__uhead)) { }
template<typename _Alloc, typename _UHead>
_Head_base(__uses_alloc1<_Alloc> __a, _UHead&& __uhead)
: _M_head_impl(allocator_arg, *__a._M_a, std::forward<_UHead>(__uhead))
{ }
template<typename _Alloc, typename _UHead>
_Head_base(__uses_alloc2<_Alloc> __a, _UHead&& __uhead)
: _M_head_impl(std::forward<_UHead>(__uhead), *__a._M_a) { }
static constexpr _Head&
_M_head(_Head_base& __b) noexcept { return __b._M_head_impl; }
static constexpr const _Head&
_M_head(const _Head_base& __b) noexcept { return __b._M_head_impl; }
_Head _M_head_impl;
};
/**
* Contains the actual implementation of the @c tuple template, stored
* as a recursive inheritance hierarchy from the first element (most
* derived class) to the last (least derived class). The @c Idx
* parameter gives the 0-based index of the element stored at this
* point in the hierarchy; we use it to implement a constant-time
* get() operation.
*/
template<std::size_t _Idx, typename... _Elements>
struct _Tuple_impl;
/**
* Recursive tuple implementation. Here we store the @c Head element
* and derive from a @c Tuple_impl containing the remaining elements
* (which contains the @c Tail).
*/
template<std::size_t _Idx, typename _Head, typename... _Tail>
struct _Tuple_impl<_Idx, _Head, _Tail...>
: public _Tuple_impl<_Idx + 1, _Tail...>,
private _Head_base<_Idx, _Head>
{
template<std::size_t, typename...> friend class _Tuple_impl;
typedef _Tuple_impl<_Idx + 1, _Tail...> _Inherited;
typedef _Head_base<_Idx, _Head> _Base;
static constexpr _Head&
_M_head(_Tuple_impl& __t) noexcept { return _Base::_M_head(__t); }
static constexpr const _Head&
_M_head(const _Tuple_impl& __t) noexcept { return _Base::_M_head(__t); }
static constexpr _Inherited&
_M_tail(_Tuple_impl& __t) noexcept { return __t; }
static constexpr const _Inherited&
_M_tail(const _Tuple_impl& __t) noexcept { return __t; }
constexpr _Tuple_impl()
: _Inherited(), _Base() { }
explicit
constexpr _Tuple_impl(const _Head& __head, const _Tail&... __tail)
: _Inherited(__tail...), _Base(__head) { }
template<typename _UHead, typename... _UTail, typename = typename
enable_if<sizeof...(_Tail) == sizeof...(_UTail)>::type>
explicit
constexpr _Tuple_impl(_UHead&& __head, _UTail&&... __tail)
: _Inherited(std::forward<_UTail>(__tail)...),
_Base(std::forward<_UHead>(__head)) { }
constexpr _Tuple_impl(const _Tuple_impl&) = default;
constexpr
_Tuple_impl(_Tuple_impl&& __in)
noexcept(__and_<is_nothrow_move_constructible<_Head>,
is_nothrow_move_constructible<_Inherited>>::value)
: _Inherited(std::move(_M_tail(__in))),
_Base(std::forward<_Head>(_M_head(__in))) { }
template<typename... _UElements>
constexpr _Tuple_impl(const _Tuple_impl<_Idx, _UElements...>& __in)
: _Inherited(_Tuple_impl<_Idx, _UElements...>::_M_tail(__in)),
_Base(_Tuple_impl<_Idx, _UElements...>::_M_head(__in)) { }
template<typename _UHead, typename... _UTails>
constexpr _Tuple_impl(_Tuple_impl<_Idx, _UHead, _UTails...>&& __in)
: _Inherited(std::move
(_Tuple_impl<_Idx, _UHead, _UTails...>::_M_tail(__in))),
_Base(std::forward<_UHead>
(_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in))) { }
template<typename _Alloc>
_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a)
: _Inherited(__tag, __a),
_Base(__tag, __use_alloc<_Head>(__a)) { }
template<typename _Alloc>
_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
const _Head& __head, const _Tail&... __tail)
: _Inherited(__tag, __a, __tail...),
_Base(__use_alloc<_Head, _Alloc, _Head>(__a), __head) { }
template<typename _Alloc, typename _UHead, typename... _UTail,
typename = typename enable_if<sizeof...(_Tail)
== sizeof...(_UTail)>::type>
_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
_UHead&& __head, _UTail&&... __tail)
: _Inherited(__tag, __a, std::forward<_UTail>(__tail)...),
_Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
std::forward<_UHead>(__head)) { }
template<typename _Alloc>
_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
const _Tuple_impl& __in)
: _Inherited(__tag, __a, _M_tail(__in)),
_Base(__use_alloc<_Head, _Alloc, _Head>(__a), _M_head(__in)) { }
template<typename _Alloc>
_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
_Tuple_impl&& __in)
: _Inherited(__tag, __a, std::move(_M_tail(__in))),
_Base(__use_alloc<_Head, _Alloc, _Head>(__a),
std::forward<_Head>(_M_head(__in))) { }
template<typename _Alloc, typename _UHead, typename... _UTails>
_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
const _Tuple_impl<_Idx, _UHead, _UTails...>& __in)
: _Inherited(__tag, __a,
_Tuple_impl<_Idx, _UHead, _UTails...>::_M_tail(__in)),
_Base(__use_alloc<_Head, _Alloc, const _UHead&>(__a),
_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in)) { }
template<typename _Alloc, typename _UHead, typename... _UTails>
_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
_Tuple_impl<_Idx, _UHead, _UTails...>&& __in)
: _Inherited(__tag, __a, std::move
(_Tuple_impl<_Idx, _UHead, _UTails...>::_M_tail(__in))),
_Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
std::forward<_UHead>
(_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in))) { }
_Tuple_impl&
operator=(const _Tuple_impl& __in)
{
_M_head(*this) = _M_head(__in);
_M_tail(*this) = _M_tail(__in);
return *this;
}
_Tuple_impl&
operator=(_Tuple_impl&& __in)
noexcept(__and_<is_nothrow_move_assignable<_Head>,
is_nothrow_move_assignable<_Inherited>>::value)
{
_M_head(*this) = std::forward<_Head>(_M_head(__in));
_M_tail(*this) = std::move(_M_tail(__in));
return *this;
}
template<typename... _UElements>
_Tuple_impl&
operator=(const _Tuple_impl<_Idx, _UElements...>& __in)
{
_M_head(*this) = _Tuple_impl<_Idx, _UElements...>::_M_head(__in);
_M_tail(*this) = _Tuple_impl<_Idx, _UElements...>::_M_tail(__in);
return *this;
}
template<typename _UHead, typename... _UTails>
_Tuple_impl&
operator=(_Tuple_impl<_Idx, _UHead, _UTails...>&& __in)
{
_M_head(*this) = std::forward<_UHead>
(_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in));
_M_tail(*this) = std::move
(_Tuple_impl<_Idx, _UHead, _UTails...>::_M_tail(__in));
return *this;
}
protected:
void
_M_swap(_Tuple_impl& __in)
noexcept(__is_nothrow_swappable<_Head>::value
&& noexcept(_M_tail(__in)._M_swap(_M_tail(__in))))
{
using std::swap;
swap(_M_head(*this), _M_head(__in));
_Inherited::_M_swap(_M_tail(__in));
}
};
// Basis case of inheritance recursion.
template<std::size_t _Idx, typename _Head>
struct _Tuple_impl<_Idx, _Head>
: private _Head_base<_Idx, _Head>
{
template<std::size_t, typename...> friend class _Tuple_impl;
typedef _Head_base<_Idx, _Head> _Base;
static constexpr _Head&
_M_head(_Tuple_impl& __t) noexcept { return _Base::_M_head(__t); }
static constexpr const _Head&
_M_head(const _Tuple_impl& __t) noexcept { return _Base::_M_head(__t); }
constexpr _Tuple_impl()
: _Base() { }
explicit
constexpr _Tuple_impl(const _Head& __head)
: _Base(__head) { }
template<typename _UHead>
explicit
constexpr _Tuple_impl(_UHead&& __head)
: _Base(std::forward<_UHead>(__head)) { }
constexpr _Tuple_impl(const _Tuple_impl&) = default;
constexpr
_Tuple_impl(_Tuple_impl&& __in)
noexcept(is_nothrow_move_constructible<_Head>::value)
: _Base(std::forward<_Head>(_M_head(__in))) { }
template<typename _UHead>
constexpr _Tuple_impl(const _Tuple_impl<_Idx, _UHead>& __in)
: _Base(_Tuple_impl<_Idx, _UHead>::_M_head(__in)) { }
template<typename _UHead>
constexpr _Tuple_impl(_Tuple_impl<_Idx, _UHead>&& __in)
: _Base(std::forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in)))
{ }
template<typename _Alloc>
_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a)
: _Base(__tag, __use_alloc<_Head>(__a)) { }
template<typename _Alloc>
_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
const _Head& __head)
: _Base(__use_alloc<_Head, _Alloc, _Head>(__a), __head) { }
template<typename _Alloc, typename _UHead>
_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
_UHead&& __head)
: _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
std::forward<_UHead>(__head)) { }
template<typename _Alloc>
_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
const _Tuple_impl& __in)
: _Base(__use_alloc<_Head, _Alloc, _Head>(__a), _M_head(__in)) { }
template<typename _Alloc>
_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
_Tuple_impl&& __in)
: _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
std::forward<_Head>(_M_head(__in))) { }
template<typename _Alloc, typename _UHead>
_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
const _Tuple_impl<_Idx, _UHead>& __in)
: _Base(__use_alloc<_Head, _Alloc, const _UHead&>(__a),
_Tuple_impl<_Idx, _UHead>::_M_head(__in)) { }
template<typename _Alloc, typename _UHead>
_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
_Tuple_impl<_Idx, _UHead>&& __in)
: _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
std::forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in)))
{ }
_Tuple_impl&
operator=(const _Tuple_impl& __in)
{
_M_head(*this) = _M_head(__in);
return *this;
}
_Tuple_impl&
operator=(_Tuple_impl&& __in)
noexcept(is_nothrow_move_assignable<_Head>::value)
{
_M_head(*this) = std::forward<_Head>(_M_head(__in));
return *this;
}
template<typename _UHead>
_Tuple_impl&
operator=(const _Tuple_impl<_Idx, _UHead>& __in)
{
_M_head(*this) = _Tuple_impl<_Idx, _UHead>::_M_head(__in);
return *this;
}
template<typename _UHead>
_Tuple_impl&
operator=(_Tuple_impl<_Idx, _UHead>&& __in)
{
_M_head(*this)
= std::forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in));
return *this;
}
protected:
void
_M_swap(_Tuple_impl& __in)
noexcept(__is_nothrow_swappable<_Head>::value)
{
using std::swap;
swap(_M_head(*this), _M_head(__in));
}
};
// Concept utility functions, reused in conditionally-explicit
// constructors.
template<bool, typename... _Elements>
struct _TC
{
template<typename... _UElements>
static constexpr bool _ConstructibleTuple()
{
return __and_<is_constructible<_Elements, const _UElements&>...>::value;
}
template<typename... _UElements>
static constexpr bool _ImplicitlyConvertibleTuple()
{
return __and_<is_convertible<const _UElements&, _Elements>...>::value;
}
template<typename... _UElements>
static constexpr bool _MoveConstructibleTuple()
{
return __and_<is_constructible<_Elements, _UElements&&>...>::value;
}
template<typename... _UElements>
static constexpr bool _ImplicitlyMoveConvertibleTuple()
{
return __and_<is_convertible<_UElements&&, _Elements>...>::value;
}
template<typename _SrcTuple>
static constexpr bool _NonNestedTuple()
{
return __and_<__not_<is_same<tuple<_Elements...>,
typename remove_cv<
typename remove_reference<_SrcTuple>::type
>::type>>,
__not_<is_convertible<_SrcTuple, _Elements...>>,
__not_<is_constructible<_Elements..., _SrcTuple>>
>::value;
}
template<typename... _UElements>
static constexpr bool _NotSameTuple()
{
return __not_<is_same<tuple<_Elements...>,
typename remove_const<
typename remove_reference<_UElements...>::type
>::type>>::value;
}
};
template<typename... _Elements>
struct _TC<false, _Elements...>
{
template<typename... _UElements>
static constexpr bool _ConstructibleTuple()
{
return false;
}
template<typename... _UElements>
static constexpr bool _ImplicitlyConvertibleTuple()
{
return false;
}
template<typename... _UElements>
static constexpr bool _MoveConstructibleTuple()
{
return false;
}
template<typename... _UElements>
static constexpr bool _ImplicitlyMoveConvertibleTuple()
{
return false;
}
template<typename... _UElements>
static constexpr bool _NonNestedTuple()
{
return true;
}
template<typename... _UElements>
static constexpr bool _NotSameTuple()
{
return true;
}
};
/// Primary class template, tuple
template<typename... _Elements>
class tuple : public _Tuple_impl<0, _Elements...>
{
typedef _Tuple_impl<0, _Elements...> _Inherited;
// Used for constraining the default constructor so
// that it becomes dependent on the constraints.
template<typename _Dummy>
struct _TC2
{
static constexpr bool _DefaultConstructibleTuple()
{
return __and_<is_default_constructible<_Elements>...>::value;
}
static constexpr bool _ImplicitlyDefaultConstructibleTuple()
{
return __and_<__is_implicitly_default_constructible<_Elements>...>
::value;
}
};
public:
template<typename _Dummy = void,
typename enable_if<_TC2<_Dummy>::
_ImplicitlyDefaultConstructibleTuple(),
bool>::type = true>
constexpr tuple()
: _Inherited() { }
template<typename _Dummy = void,
typename enable_if<_TC2<_Dummy>::
_DefaultConstructibleTuple()
&&
!_TC2<_Dummy>::
_ImplicitlyDefaultConstructibleTuple(),
bool>::type = false>
explicit constexpr tuple()
: _Inherited() { }
// Shortcut for the cases where constructors taking _Elements...
// need to be constrained.
template<typename _Dummy> using _TCC =
_TC<is_same<_Dummy, void>::value,
_Elements...>;
template<typename _Dummy = void,
typename enable_if<
_TCC<_Dummy>::template
_ConstructibleTuple<_Elements...>()
&& _TCC<_Dummy>::template
_ImplicitlyConvertibleTuple<_Elements...>()
&& (sizeof...(_Elements) >= 1),
bool>::type=true>
constexpr tuple(const _Elements&... __elements)
: _Inherited(__elements...) { }
template<typename _Dummy = void,
typename enable_if<
_TCC<_Dummy>::template
_ConstructibleTuple<_Elements...>()
&& !_TCC<_Dummy>::template
_ImplicitlyConvertibleTuple<_Elements...>()
&& (sizeof...(_Elements) >= 1),
bool>::type=false>
explicit constexpr tuple(const _Elements&... __elements)
: _Inherited(__elements...) { }
// Shortcut for the cases where constructors taking _UElements...
// need to be constrained.
template<typename... _UElements> using _TMC =
_TC<(sizeof...(_Elements) == sizeof...(_UElements))
&& (_TC<(sizeof...(_UElements)==1), _Elements...>::
template _NotSameTuple<_UElements...>()),
_Elements...>;
// Shortcut for the cases where constructors taking tuple<_UElements...>
// need to be constrained.
template<typename... _UElements> using _TMCT =
_TC<(sizeof...(_Elements) == sizeof...(_UElements))
&& !is_same<tuple<_Elements...>,
tuple<_UElements...>>::value,
_Elements...>;
template<typename... _UElements, typename
enable_if<
_TMC<_UElements...>::template
_MoveConstructibleTuple<_UElements...>()
&& _TMC<_UElements...>::template
_ImplicitlyMoveConvertibleTuple<_UElements...>()
&& (sizeof...(_Elements) >= 1),
bool>::type=true>
constexpr tuple(_UElements&&... __elements)
: _Inherited(std::forward<_UElements>(__elements)...) { }
template<typename... _UElements, typename
enable_if<
_TMC<_UElements...>::template
_MoveConstructibleTuple<_UElements...>()
&& !_TMC<_UElements...>::template
_ImplicitlyMoveConvertibleTuple<_UElements...>()
&& (sizeof...(_Elements) >= 1),
bool>::type=false>
explicit constexpr tuple(_UElements&&... __elements)
: _Inherited(std::forward<_UElements>(__elements)...) { }
constexpr tuple(const tuple&) = default;
constexpr tuple(tuple&&) = default;
// Shortcut for the cases where constructors taking tuples
// must avoid creating temporaries.
template<typename _Dummy> using _TNTC =
_TC<is_same<_Dummy, void>::value && sizeof...(_Elements) == 1,
_Elements...>;
template<typename... _UElements, typename _Dummy = void, typename
enable_if<_TMCT<_UElements...>::template
_ConstructibleTuple<_UElements...>()
&& _TMCT<_UElements...>::template
_ImplicitlyConvertibleTuple<_UElements...>()
&& _TNTC<_Dummy>::template
_NonNestedTuple<const tuple<_UElements...>&>(),
bool>::type=true>
constexpr tuple(const tuple<_UElements...>& __in)
: _Inherited(static_cast<const _Tuple_impl<0, _UElements...>&>(__in))
{ }
template<typename... _UElements, typename _Dummy = void, typename
enable_if<_TMCT<_UElements...>::template
_ConstructibleTuple<_UElements...>()
&& !_TMCT<_UElements...>::template
_ImplicitlyConvertibleTuple<_UElements...>()
&& _TNTC<_Dummy>::template
_NonNestedTuple<const tuple<_UElements...>&>(),
bool>::type=false>
explicit constexpr tuple(const tuple<_UElements...>& __in)
: _Inherited(static_cast<const _Tuple_impl<0, _UElements...>&>(__in))
{ }
template<typename... _UElements, typename _Dummy = void, typename
enable_if<_TMCT<_UElements...>::template
_MoveConstructibleTuple<_UElements...>()
&& _TMCT<_UElements...>::template
_ImplicitlyMoveConvertibleTuple<_UElements...>()
&& _TNTC<_Dummy>::template
_NonNestedTuple<tuple<_UElements...>&&>(),
bool>::type=true>
constexpr tuple(tuple<_UElements...>&& __in)
: _Inherited(static_cast<_Tuple_impl<0, _UElements...>&&>(__in)) { }
template<typename... _UElements, typename _Dummy = void, typename
enable_if<_TMCT<_UElements...>::template
_MoveConstructibleTuple<_UElements...>()
&& !_TMCT<_UElements...>::template
_ImplicitlyMoveConvertibleTuple<_UElements...>()
&& _TNTC<_Dummy>::template
_NonNestedTuple<tuple<_UElements...>&&>(),
bool>::type=false>
explicit constexpr tuple(tuple<_UElements...>&& __in)
: _Inherited(static_cast<_Tuple_impl<0, _UElements...>&&>(__in)) { }
// Allocator-extended constructors.
template<typename _Alloc>
tuple(allocator_arg_t __tag, const _Alloc& __a)
: _Inherited(__tag, __a) { }
template<typename _Alloc, typename _Dummy = void,
typename enable_if<
_TCC<_Dummy>::template
_ConstructibleTuple<_Elements...>()
&& _TCC<_Dummy>::template
_ImplicitlyConvertibleTuple<_Elements...>(),
bool>::type=true>
tuple(allocator_arg_t __tag, const _Alloc& __a,
const _Elements&... __elements)
: _Inherited(__tag, __a, __elements...) { }
template<typename _Alloc, typename _Dummy = void,
typename enable_if<
_TCC<_Dummy>::template
_ConstructibleTuple<_Elements...>()
&& !_TCC<_Dummy>::template
_ImplicitlyConvertibleTuple<_Elements...>(),
bool>::type=false>
explicit tuple(allocator_arg_t __tag, const _Alloc& __a,
const _Elements&... __elements)
: _Inherited(__tag, __a, __elements...) { }
template<typename _Alloc, typename... _UElements, typename
enable_if<_TMC<_UElements...>::template
_MoveConstructibleTuple<_UElements...>()
&& _TMC<_UElements...>::template
_ImplicitlyMoveConvertibleTuple<_UElements...>(),
bool>::type=true>
tuple(allocator_arg_t __tag, const _Alloc& __a,
_UElements&&... __elements)
: _Inherited(__tag, __a, std::forward<_UElements>(__elements)...)
{ }
template<typename _Alloc, typename... _UElements, typename
enable_if<_TMC<_UElements...>::template
_MoveConstructibleTuple<_UElements...>()
&& !_TMC<_UElements...>::template
_ImplicitlyMoveConvertibleTuple<_UElements...>(),
bool>::type=false>
explicit tuple(allocator_arg_t __tag, const _Alloc& __a,
_UElements&&... __elements)
: _Inherited(__tag, __a, std::forward<_UElements>(__elements)...)
{ }
template<typename _Alloc>
tuple(allocator_arg_t __tag, const _Alloc& __a, const tuple& __in)
: _Inherited(__tag, __a, static_cast<const _Inherited&>(__in)) { }
template<typename _Alloc>
tuple(allocator_arg_t __tag, const _Alloc& __a, tuple&& __in)
: _Inherited(__tag, __a, static_cast<_Inherited&&>(__in)) { }
template<typename _Alloc, typename _Dummy = void,
typename... _UElements, typename
enable_if<_TMCT<_UElements...>::template
_ConstructibleTuple<_UElements...>()
&& _TMCT<_UElements...>::template
_ImplicitlyConvertibleTuple<_UElements...>()
&& _TNTC<_Dummy>::template
_NonNestedTuple<tuple<_UElements...>&&>(),
bool>::type=true>
tuple(allocator_arg_t __tag, const _Alloc& __a,
const tuple<_UElements...>& __in)
: _Inherited(__tag, __a,
static_cast<const _Tuple_impl<0, _UElements...>&>(__in))
{ }
template<typename _Alloc, typename _Dummy = void,
typename... _UElements, typename
enable_if<_TMCT<_UElements...>::template
_ConstructibleTuple<_UElements...>()
&& !_TMCT<_UElements...>::template
_ImplicitlyConvertibleTuple<_UElements...>()
&& _TNTC<_Dummy>::template
_NonNestedTuple<tuple<_UElements...>&&>(),
bool>::type=false>
explicit tuple(allocator_arg_t __tag, const _Alloc& __a,
const tuple<_UElements...>& __in)
: _Inherited(__tag, __a,
static_cast<const _Tuple_impl<0, _UElements...>&>(__in))
{ }
template<typename _Alloc, typename _Dummy = void,
typename... _UElements, typename
enable_if<_TMCT<_UElements...>::template
_MoveConstructibleTuple<_UElements...>()
&& _TMCT<_UElements...>::template
_ImplicitlyMoveConvertibleTuple<_UElements...>()
&& _TNTC<_Dummy>::template
_NonNestedTuple<tuple<_UElements...>&&>(),
bool>::type=true>
tuple(allocator_arg_t __tag, const _Alloc& __a,
tuple<_UElements...>&& __in)
: _Inherited(__tag, __a,
static_cast<_Tuple_impl<0, _UElements...>&&>(__in))
{ }
template<typename _Alloc, typename _Dummy = void,
typename... _UElements, typename
enable_if<_TMCT<_UElements...>::template
_MoveConstructibleTuple<_UElements...>()
&& !_TMCT<_UElements...>::template
_ImplicitlyMoveConvertibleTuple<_UElements...>()
&& _TNTC<_Dummy>::template
_NonNestedTuple<tuple<_UElements...>&&>(),
bool>::type=false>
explicit tuple(allocator_arg_t __tag, const _Alloc& __a,
tuple<_UElements...>&& __in)
: _Inherited(__tag, __a,
static_cast<_Tuple_impl<0, _UElements...>&&>(__in))
{ }
tuple&
operator=(const tuple& __in)
{
static_cast<_Inherited&>(*this) = __in;
return *this;
}
tuple&
operator=(tuple&& __in)
noexcept(is_nothrow_move_assignable<_Inherited>::value)
{
static_cast<_Inherited&>(*this) = std::move(__in);
return *this;
}
template<typename... _UElements>
typename
enable_if<sizeof...(_UElements)
== sizeof...(_Elements), tuple&>::type
operator=(const tuple<_UElements...>& __in)
{
static_cast<_Inherited&>(*this) = __in;
return *this;
}
template<typename... _UElements>
typename
enable_if<sizeof...(_UElements)
== sizeof...(_Elements), tuple&>::type
operator=(tuple<_UElements...>&& __in)
{
static_cast<_Inherited&>(*this) = std::move(__in);
return *this;
}
void
swap(tuple& __in)
noexcept(noexcept(__in._M_swap(__in)))
{ _Inherited::_M_swap(__in); }
};
#if __cpp_deduction_guides >= 201606
template<typename... _UTypes>
tuple(_UTypes...) -> tuple<_UTypes...>;
template<typename _T1, typename _T2>
tuple(pair<_T1, _T2>) -> tuple<_T1, _T2>;
template<typename _Alloc, typename... _UTypes>
tuple(allocator_arg_t, _Alloc, _UTypes...) -> tuple<_UTypes...>;
template<typename _Alloc, typename _T1, typename _T2>
tuple(allocator_arg_t, _Alloc, pair<_T1, _T2>) -> tuple<_T1, _T2>;
template<typename _Alloc, typename... _UTypes>
tuple(allocator_arg_t, _Alloc, tuple<_UTypes...>) -> tuple<_UTypes...>;
#endif
// Explicit specialization, zero-element tuple.
template<>
class tuple<>
{
public:
void swap(tuple&) noexcept { /* no-op */ }
// We need the default since we're going to define no-op
// allocator constructors.
tuple() = default;
// No-op allocator constructors.
template<typename _Alloc>
tuple(allocator_arg_t, const _Alloc&) { }
template<typename _Alloc>
tuple(allocator_arg_t, const _Alloc&, const tuple&) { }
};
/// Partial specialization, 2-element tuple.
/// Includes construction and assignment from a pair.
template<typename _T1, typename _T2>
class tuple<_T1, _T2> : public _Tuple_impl<0, _T1, _T2>
{
typedef _Tuple_impl<0, _T1, _T2> _Inherited;
public:
template <typename _U1 = _T1,
typename _U2 = _T2,
typename enable_if<__and_<
__is_implicitly_default_constructible<_U1>,
__is_implicitly_default_constructible<_U2>>
::value, bool>::type = true>
constexpr tuple()
: _Inherited() { }
template <typename _U1 = _T1,
typename _U2 = _T2,
typename enable_if<
__and_<
is_default_constructible<_U1>,
is_default_constructible<_U2>,
__not_<
__and_<__is_implicitly_default_constructible<_U1>,
__is_implicitly_default_constructible<_U2>>>>
::value, bool>::type = false>
explicit constexpr tuple()
: _Inherited() { }
// Shortcut for the cases where constructors taking _T1, _T2
// need to be constrained.
template<typename _Dummy> using _TCC =
_TC<is_same<_Dummy, void>::value, _T1, _T2>;
template<typename _Dummy = void, typename
enable_if<_TCC<_Dummy>::template
_ConstructibleTuple<_T1, _T2>()
&& _TCC<_Dummy>::template
_ImplicitlyConvertibleTuple<_T1, _T2>(),
bool>::type = true>
constexpr tuple(const _T1& __a1, const _T2& __a2)
: _Inherited(__a1, __a2) { }
template<typename _Dummy = void, typename
enable_if<_TCC<_Dummy>::template
_ConstructibleTuple<_T1, _T2>()
&& !_TCC<_Dummy>::template
_ImplicitlyConvertibleTuple<_T1, _T2>(),
bool>::type = false>
explicit constexpr tuple(const _T1& __a1, const _T2& __a2)
: _Inherited(__a1, __a2) { }
// Shortcut for the cases where constructors taking _U1, _U2
// need to be constrained.
using _TMC = _TC<true, _T1, _T2>;
template<typename _U1, typename _U2, typename
enable_if<_TMC::template
_MoveConstructibleTuple<_U1, _U2>()
&& _TMC::template
_ImplicitlyMoveConvertibleTuple<_U1, _U2>()
&& !is_same<typename decay<_U1>::type,
allocator_arg_t>::value,
bool>::type = true>
constexpr tuple(_U1&& __a1, _U2&& __a2)
: _Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { }
template<typename _U1, typename _U2, typename
enable_if<_TMC::template
_MoveConstructibleTuple<_U1, _U2>()
&& !_TMC::template
_ImplicitlyMoveConvertibleTuple<_U1, _U2>()
&& !is_same<typename decay<_U1>::type,
allocator_arg_t>::value,
bool>::type = false>
explicit constexpr tuple(_U1&& __a1, _U2&& __a2)
: _Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { }
constexpr tuple(const tuple&) = default;
constexpr tuple(tuple&&) = default;
template<typename _U1, typename _U2, typename
enable_if<_TMC::template
_ConstructibleTuple<_U1, _U2>()
&& _TMC::template
_ImplicitlyConvertibleTuple<_U1, _U2>(),
bool>::type = true>
constexpr tuple(const tuple<_U1, _U2>& __in)
: _Inherited(static_cast<const _Tuple_impl<0, _U1, _U2>&>(__in)) { }
template<typename _U1, typename _U2, typename
enable_if<_TMC::template
_ConstructibleTuple<_U1, _U2>()
&& !_TMC::template
_ImplicitlyConvertibleTuple<_U1, _U2>(),
bool>::type = false>
explicit constexpr tuple(const tuple<_U1, _U2>& __in)
: _Inherited(static_cast<const _Tuple_impl<0, _U1, _U2>&>(__in)) { }
template<typename _U1, typename _U2, typename
enable_if<_TMC::template
_MoveConstructibleTuple<_U1, _U2>()
&& _TMC::template
_ImplicitlyMoveConvertibleTuple<_U1, _U2>(),
bool>::type = true>
constexpr tuple(tuple<_U1, _U2>&& __in)
: _Inherited(static_cast<_Tuple_impl<0, _U1, _U2>&&>(__in)) { }
template<typename _U1, typename _U2, typename
enable_if<_TMC::template
_MoveConstructibleTuple<_U1, _U2>()
&& !_TMC::template
_ImplicitlyMoveConvertibleTuple<_U1, _U2>(),
bool>::type = false>
explicit constexpr tuple(tuple<_U1, _U2>&& __in)
: _Inherited(static_cast<_Tuple_impl<0, _U1, _U2>&&>(__in)) { }
template<typename _U1, typename _U2, typename
enable_if<_TMC::template
_ConstructibleTuple<_U1, _U2>()
&& _TMC::template
_ImplicitlyConvertibleTuple<_U1, _U2>(),
bool>::type = true>
constexpr tuple(const pair<_U1, _U2>& __in)
: _Inherited(__in.first, __in.second) { }
template<typename _U1, typename _U2, typename
enable_if<_TMC::template
_ConstructibleTuple<_U1, _U2>()
&& !_TMC::template
_ImplicitlyConvertibleTuple<_U1, _U2>(),
bool>::type = false>
explicit constexpr tuple(const pair<_U1, _U2>& __in)
: _Inherited(__in.first, __in.second) { }
template<typename _U1, typename _U2, typename
enable_if<_TMC::template
_MoveConstructibleTuple<_U1, _U2>()
&& _TMC::template
_ImplicitlyMoveConvertibleTuple<_U1, _U2>(),
bool>::type = true>
constexpr tuple(pair<_U1, _U2>&& __in)
: _Inherited(std::forward<_U1>(__in.first),
std::forward<_U2>(__in.second)) { }
template<typename _U1, typename _U2, typename
enable_if<_TMC::template
_MoveConstructibleTuple<_U1, _U2>()
&& !_TMC::template
_ImplicitlyMoveConvertibleTuple<_U1, _U2>(),
bool>::type = false>
explicit constexpr tuple(pair<_U1, _U2>&& __in)
: _Inherited(std::forward<_U1>(__in.first),
std::forward<_U2>(__in.second)) { }
// Allocator-extended constructors.
template<typename _Alloc>
tuple(allocator_arg_t __tag, const _Alloc& __a)
: _Inherited(__tag, __a) { }
template<typename _Alloc, typename _Dummy = void,
typename enable_if<
_TCC<_Dummy>::template
_ConstructibleTuple<_T1, _T2>()
&& _TCC<_Dummy>::template
_ImplicitlyConvertibleTuple<_T1, _T2>(),
bool>::type=true>
tuple(allocator_arg_t __tag, const _Alloc& __a,
const _T1& __a1, const _T2& __a2)
: _Inherited(__tag, __a, __a1, __a2) { }
template<typename _Alloc, typename _Dummy = void,
typename enable_if<
_TCC<_Dummy>::template
_ConstructibleTuple<_T1, _T2>()
&& !_TCC<_Dummy>::template
_ImplicitlyConvertibleTuple<_T1, _T2>(),
bool>::type=false>
explicit tuple(allocator_arg_t __tag, const _Alloc& __a,
const _T1& __a1, const _T2& __a2)
: _Inherited(__tag, __a, __a1, __a2) { }
template<typename _Alloc, typename _U1, typename _U2, typename
enable_if<_TMC::template
_MoveConstructibleTuple<_U1, _U2>()
&& _TMC::template
_ImplicitlyMoveConvertibleTuple<_U1, _U2>(),
bool>::type = true>
tuple(allocator_arg_t __tag, const _Alloc& __a, _U1&& __a1, _U2&& __a2)
: _Inherited(__tag, __a, std::forward<_U1>(__a1),
std::forward<_U2>(__a2)) { }
template<typename _Alloc, typename _U1, typename _U2, typename
enable_if<_TMC::template
_MoveConstructibleTuple<_U1, _U2>()
&& !_TMC::template
_ImplicitlyMoveConvertibleTuple<_U1, _U2>(),
bool>::type = false>
explicit tuple(allocator_arg_t __tag, const _Alloc& __a,
_U1&& __a1, _U2&& __a2)
: _Inherited(__tag, __a, std::forward<_U1>(__a1),
std::forward<_U2>(__a2)) { }
template<typename _Alloc>
tuple(allocator_arg_t __tag, const _Alloc& __a, const tuple& __in)
: _Inherited(__tag, __a, static_cast<const _Inherited&>(__in)) { }
template<typename _Alloc>
tuple(allocator_arg_t __tag, const _Alloc& __a, tuple&& __in)
: _Inherited(__tag, __a, static_cast<_Inherited&&>(__in)) { }
template<typename _Alloc, typename _U1, typename _U2, typename
enable_if<_TMC::template
_ConstructibleTuple<_U1, _U2>()
&& _TMC::template
_ImplicitlyConvertibleTuple<_U1, _U2>(),
bool>::type = true>
tuple(allocator_arg_t __tag, const _Alloc& __a,
const tuple<_U1, _U2>& __in)
: _Inherited(__tag, __a,
static_cast<const _Tuple_impl<0, _U1, _U2>&>(__in))
{ }
template<typename _Alloc, typename _U1, typename _U2, typename
enable_if<_TMC::template
_ConstructibleTuple<_U1, _U2>()
&& !_TMC::template
_ImplicitlyConvertibleTuple<_U1, _U2>(),
bool>::type = false>
explicit tuple(allocator_arg_t __tag, const _Alloc& __a,
const tuple<_U1, _U2>& __in)
: _Inherited(__tag, __a,
static_cast<const _Tuple_impl<0, _U1, _U2>&>(__in))
{ }
template<typename _Alloc, typename _U1, typename _U2, typename
enable_if<_TMC::template
_MoveConstructibleTuple<_U1, _U2>()
&& _TMC::template
_ImplicitlyMoveConvertibleTuple<_U1, _U2>(),
bool>::type = true>
tuple(allocator_arg_t __tag, const _Alloc& __a, tuple<_U1, _U2>&& __in)
: _Inherited(__tag, __a, static_cast<_Tuple_impl<0, _U1, _U2>&&>(__in))
{ }
template<typename _Alloc, typename _U1, typename _U2, typename
enable_if<_TMC::template
_MoveConstructibleTuple<_U1, _U2>()
&& !_TMC::template
_ImplicitlyMoveConvertibleTuple<_U1, _U2>(),
bool>::type = false>
explicit tuple(allocator_arg_t __tag, const _Alloc& __a,
tuple<_U1, _U2>&& __in)
: _Inherited(__tag, __a, static_cast<_Tuple_impl<0, _U1, _U2>&&>(__in))
{ }
template<typename _Alloc, typename _U1, typename _U2, typename
enable_if<_TMC::template
_ConstructibleTuple<_U1, _U2>()
&& _TMC::template
_ImplicitlyConvertibleTuple<_U1, _U2>(),
bool>::type = true>
tuple(allocator_arg_t __tag, const _Alloc& __a,
const pair<_U1, _U2>& __in)
: _Inherited(__tag, __a, __in.first, __in.second) { }
template<typename _Alloc, typename _U1, typename _U2, typename
enable_if<_TMC::template
_ConstructibleTuple<_U1, _U2>()
&& !_TMC::template
_ImplicitlyConvertibleTuple<_U1, _U2>(),
bool>::type = false>
explicit tuple(allocator_arg_t __tag, const _Alloc& __a,
const pair<_U1, _U2>& __in)
: _Inherited(__tag, __a, __in.first, __in.second) { }
template<typename _Alloc, typename _U1, typename _U2, typename
enable_if<_TMC::template
_MoveConstructibleTuple<_U1, _U2>()
&& _TMC::template
_ImplicitlyMoveConvertibleTuple<_U1, _U2>(),
bool>::type = true>
tuple(allocator_arg_t __tag, const _Alloc& __a, pair<_U1, _U2>&& __in)
: _Inherited(__tag, __a, std::forward<_U1>(__in.first),
std::forward<_U2>(__in.second)) { }
template<typename _Alloc, typename _U1, typename _U2, typename
enable_if<_TMC::template
_MoveConstructibleTuple<_U1, _U2>()
&& !_TMC::template
_ImplicitlyMoveConvertibleTuple<_U1, _U2>(),
bool>::type = false>
explicit tuple(allocator_arg_t __tag, const _Alloc& __a,
pair<_U1, _U2>&& __in)
: _Inherited(__tag, __a, std::forward<_U1>(__in.first),
std::forward<_U2>(__in.second)) { }
tuple&
operator=(const tuple& __in)
{
static_cast<_Inherited&>(*this) = __in;
return *this;
}
tuple&
operator=(tuple&& __in)
noexcept(is_nothrow_move_assignable<_Inherited>::value)
{
static_cast<_Inherited&>(*this) = std::move(__in);
return *this;
}
template<typename _U1, typename _U2>
tuple&
operator=(const tuple<_U1, _U2>& __in)
{
static_cast<_Inherited&>(*this) = __in;
return *this;
}
template<typename _U1, typename _U2>
tuple&
operator=(tuple<_U1, _U2>&& __in)
{
static_cast<_Inherited&>(*this) = std::move(__in);
return *this;
}
template<typename _U1, typename _U2>
tuple&
operator=(const pair<_U1, _U2>& __in)
{
this->_M_head(*this) = __in.first;
this->_M_tail(*this)._M_head(*this) = __in.second;
return *this;
}
template<typename _U1, typename _U2>
tuple&
operator=(pair<_U1, _U2>&& __in)
{
this->_M_head(*this) = std::forward<_U1>(__in.first);
this->_M_tail(*this)._M_head(*this) = std::forward<_U2>(__in.second);
return *this;
}
void
swap(tuple& __in)
noexcept(noexcept(__in._M_swap(__in)))
{ _Inherited::_M_swap(__in); }
};
/// class tuple_size
template<typename... _Elements>
struct tuple_size<tuple<_Elements...>>
: public integral_constant<std::size_t, sizeof...(_Elements)> { };
#if __cplusplus > 201402L
template <typename _Tp>
inline constexpr size_t tuple_size_v = tuple_size<_Tp>::value;
#endif
/**
* Recursive case for tuple_element: strip off the first element in
* the tuple and retrieve the (i-1)th element of the remaining tuple.
*/
template<std::size_t __i, typename _Head, typename... _Tail>
struct tuple_element<__i, tuple<_Head, _Tail...> >
: tuple_element<__i - 1, tuple<_Tail...> > { };
/**
* Basis case for tuple_element: The first element is the one we're seeking.
*/
template<typename _Head, typename... _Tail>
struct tuple_element<0, tuple<_Head, _Tail...> >
{
typedef _Head type;
};
/**
* Error case for tuple_element: invalid index.
*/
template<size_t __i>
struct tuple_element<__i, tuple<>>
{
static_assert(__i < tuple_size<tuple<>>::value,
"tuple index is in range");
};
template<std::size_t __i, typename _Head, typename... _Tail>
constexpr _Head&
__get_helper(_Tuple_impl<__i, _Head, _Tail...>& __t) noexcept
{ return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
template<std::size_t __i, typename _Head, typename... _Tail>
constexpr const _Head&
__get_helper(const _Tuple_impl<__i, _Head, _Tail...>& __t) noexcept
{ return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
/// Return a reference to the ith element of a tuple.
template<std::size_t __i, typename... _Elements>
constexpr __tuple_element_t<__i, tuple<_Elements...>>&
get(tuple<_Elements...>& __t) noexcept
{ return std::__get_helper<__i>(__t); }
/// Return a const reference to the ith element of a const tuple.
template<std::size_t __i, typename... _Elements>
constexpr const __tuple_element_t<__i, tuple<_Elements...>>&
get(const tuple<_Elements...>& __t) noexcept
{ return std::__get_helper<__i>(__t); }
/// Return an rvalue reference to the ith element of a tuple rvalue.
template<std::size_t __i, typename... _Elements>
constexpr __tuple_element_t<__i, tuple<_Elements...>>&&
get(tuple<_Elements...>&& __t) noexcept
{
typedef __tuple_element_t<__i, tuple<_Elements...>> __element_type;
return std::forward<__element_type&&>(std::get<__i>(__t));
}
/// Return a const rvalue reference to the ith element of a const tuple rvalue.
template<std::size_t __i, typename... _Elements>
constexpr const __tuple_element_t<__i, tuple<_Elements...>>&&
get(const tuple<_Elements...>&& __t) noexcept
{
typedef __tuple_element_t<__i, tuple<_Elements...>> __element_type;
return std::forward<const __element_type&&>(std::get<__i>(__t));
}
#if __cplusplus > 201103L
#define __cpp_lib_tuples_by_type 201304
template<typename _Head, size_t __i, typename... _Tail>
constexpr _Head&
__get_helper2(_Tuple_impl<__i, _Head, _Tail...>& __t) noexcept
{ return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
template<typename _Head, size_t __i, typename... _Tail>
constexpr const _Head&
__get_helper2(const _Tuple_impl<__i, _Head, _Tail...>& __t) noexcept
{ return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
/// Return a reference to the unique element of type _Tp of a tuple.
template <typename _Tp, typename... _Types>
constexpr _Tp&
get(tuple<_Types...>& __t) noexcept
{ return std::__get_helper2<_Tp>(__t); }
/// Return a reference to the unique element of type _Tp of a tuple rvalue.
template <typename _Tp, typename... _Types>
constexpr _Tp&&
get(tuple<_Types...>&& __t) noexcept
{ return std::forward<_Tp&&>(std::__get_helper2<_Tp>(__t)); }
/// Return a const reference to the unique element of type _Tp of a tuple.
template <typename _Tp, typename... _Types>
constexpr const _Tp&
get(const tuple<_Types...>& __t) noexcept
{ return std::__get_helper2<_Tp>(__t); }
/// Return a const reference to the unique element of type _Tp of
/// a const tuple rvalue.
template <typename _Tp, typename... _Types>
constexpr const _Tp&&
get(const tuple<_Types...>&& __t) noexcept
{ return std::forward<const _Tp&&>(std::__get_helper2<_Tp>(__t)); }
#endif
// This class performs the comparison operations on tuples
template<typename _Tp, typename _Up, size_t __i, size_t __size>
struct __tuple_compare
{
static constexpr bool
__eq(const _Tp& __t, const _Up& __u)
{
return bool(std::get<__i>(__t) == std::get<__i>(__u))
&& __tuple_compare<_Tp, _Up, __i + 1, __size>::__eq(__t, __u);
}
static constexpr bool
__less(const _Tp& __t, const _Up& __u)
{
return bool(std::get<__i>(__t) < std::get<__i>(__u))
|| (!bool(std::get<__i>(__u) < std::get<__i>(__t))
&& __tuple_compare<_Tp, _Up, __i + 1, __size>::__less(__t, __u));
}
};
template<typename _Tp, typename _Up, size_t __size>
struct __tuple_compare<_Tp, _Up, __size, __size>
{
static constexpr bool
__eq(const _Tp&, const _Up&) { return true; }
static constexpr bool
__less(const _Tp&, const _Up&) { return false; }
};
template<typename... _TElements, typename... _UElements>
constexpr bool
operator==(const tuple<_TElements...>& __t,
const tuple<_UElements...>& __u)
{
static_assert(sizeof...(_TElements) == sizeof...(_UElements),
"tuple objects can only be compared if they have equal sizes.");
using __compare = __tuple_compare<tuple<_TElements...>,
tuple<_UElements...>,
0, sizeof...(_TElements)>;
return __compare::__eq(__t, __u);
}
template<typename... _TElements, typename... _UElements>
constexpr bool
operator<(const tuple<_TElements...>& __t,
const tuple<_UElements...>& __u)
{
static_assert(sizeof...(_TElements) == sizeof...(_UElements),
"tuple objects can only be compared if they have equal sizes.");
using __compare = __tuple_compare<tuple<_TElements...>,
tuple<_UElements...>,
0, sizeof...(_TElements)>;
return __compare::__less(__t, __u);
}
template<typename... _TElements, typename... _UElements>
constexpr bool
operator!=(const tuple<_TElements...>& __t,
const tuple<_UElements...>& __u)
{ return !(__t == __u); }
template<typename... _TElements, typename... _UElements>
constexpr bool
operator>(const tuple<_TElements...>& __t,
const tuple<_UElements...>& __u)
{ return __u < __t; }
template<typename... _TElements, typename... _UElements>
constexpr bool
operator<=(const tuple<_TElements...>& __t,
const tuple<_UElements...>& __u)
{ return !(__u < __t); }
template<typename... _TElements, typename... _UElements>
constexpr bool
operator>=(const tuple<_TElements...>& __t,
const tuple<_UElements...>& __u)
{ return !(__t < __u); }
// NB: DR 705.
template<typename... _Elements>
constexpr tuple<typename __decay_and_strip<_Elements>::__type...>
make_tuple(_Elements&&... __args)
{
typedef tuple<typename __decay_and_strip<_Elements>::__type...>
__result_type;
return __result_type(std::forward<_Elements>(__args)...);
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2275. Why is forward_as_tuple not constexpr?
template<typename... _Elements>
constexpr tuple<_Elements&&...>
forward_as_tuple(_Elements&&... __args) noexcept
{ return tuple<_Elements&&...>(std::forward<_Elements>(__args)...); }
template<size_t, typename, typename, size_t>
struct __make_tuple_impl;
template<size_t _Idx, typename _Tuple, typename... _Tp, size_t _Nm>
struct __make_tuple_impl<_Idx, tuple<_Tp...>, _Tuple, _Nm>
: __make_tuple_impl<_Idx + 1,
tuple<_Tp..., __tuple_element_t<_Idx, _Tuple>>,
_Tuple, _Nm>
{ };
template<std::size_t _Nm, typename _Tuple, typename... _Tp>
struct __make_tuple_impl<_Nm, tuple<_Tp...>, _Tuple, _Nm>
{
typedef tuple<_Tp...> __type;
};
template<typename _Tuple>
struct __do_make_tuple
: __make_tuple_impl<0, tuple<>, _Tuple, std::tuple_size<_Tuple>::value>
{ };
// Returns the std::tuple equivalent of a tuple-like type.
template<typename _Tuple>
struct __make_tuple
: public __do_make_tuple<typename std::remove_cv
<typename std::remove_reference<_Tuple>::type>::type>
{ };
// Combines several std::tuple's into a single one.
template<typename...>
struct __combine_tuples;
template<>
struct __combine_tuples<>
{
typedef tuple<> __type;
};
template<typename... _Ts>
struct __combine_tuples<tuple<_Ts...>>
{
typedef tuple<_Ts...> __type;
};
template<typename... _T1s, typename... _T2s, typename... _Rem>
struct __combine_tuples<tuple<_T1s...>, tuple<_T2s...>, _Rem...>
{
typedef typename __combine_tuples<tuple<_T1s..., _T2s...>,
_Rem...>::__type __type;
};
// Computes the result type of tuple_cat given a set of tuple-like types.
template<typename... _Tpls>
struct __tuple_cat_result
{
typedef typename __combine_tuples
<typename __make_tuple<_Tpls>::__type...>::__type __type;
};
// Helper to determine the index set for the first tuple-like
// type of a given set.
template<typename...>
struct __make_1st_indices;
template<>
struct __make_1st_indices<>
{
typedef std::_Index_tuple<> __type;
};
template<typename _Tp, typename... _Tpls>
struct __make_1st_indices<_Tp, _Tpls...>
{
typedef typename std::_Build_index_tuple<std::tuple_size<
typename std::remove_reference<_Tp>::type>::value>::__type __type;
};
// Performs the actual concatenation by step-wise expanding tuple-like
// objects into the elements, which are finally forwarded into the
// result tuple.
template<typename _Ret, typename _Indices, typename... _Tpls>
struct __tuple_concater;
template<typename _Ret, std::size_t... _Is, typename _Tp, typename... _Tpls>
struct __tuple_concater<_Ret, std::_Index_tuple<_Is...>, _Tp, _Tpls...>
{
template<typename... _Us>
static constexpr _Ret
_S_do(_Tp&& __tp, _Tpls&&... __tps, _Us&&... __us)
{
typedef typename __make_1st_indices<_Tpls...>::__type __idx;
typedef __tuple_concater<_Ret, __idx, _Tpls...> __next;
return __next::_S_do(std::forward<_Tpls>(__tps)...,
std::forward<_Us>(__us)...,
std::get<_Is>(std::forward<_Tp>(__tp))...);
}
};
template<typename _Ret>
struct __tuple_concater<_Ret, std::_Index_tuple<>>
{
template<typename... _Us>
static constexpr _Ret
_S_do(_Us&&... __us)
{
return _Ret(std::forward<_Us>(__us)...);
}
};
/// tuple_cat
template<typename... _Tpls, typename = typename
enable_if<__and_<__is_tuple_like<_Tpls>...>::value>::type>
constexpr auto
tuple_cat(_Tpls&&... __tpls)
-> typename __tuple_cat_result<_Tpls...>::__type
{
typedef typename __tuple_cat_result<_Tpls...>::__type __ret;
typedef typename __make_1st_indices<_Tpls...>::__type __idx;
typedef __tuple_concater<__ret, __idx, _Tpls...> __concater;
return __concater::_S_do(std::forward<_Tpls>(__tpls)...);
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2301. Why is tie not constexpr?
/// tie
template<typename... _Elements>
constexpr tuple<_Elements&...>
tie(_Elements&... __args) noexcept
{ return tuple<_Elements&...>(__args...); }
/// swap
template<typename... _Elements>
inline
#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
// Constrained free swap overload, see p0185r1
typename enable_if<__and_<__is_swappable<_Elements>...>::value
>::type
#else
void
#endif
swap(tuple<_Elements...>& __x, tuple<_Elements...>& __y)
noexcept(noexcept(__x.swap(__y)))
{ __x.swap(__y); }
#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
template<typename... _Elements>
typename enable_if<!__and_<__is_swappable<_Elements>...>::value>::type
swap(tuple<_Elements...>&, tuple<_Elements...>&) = delete;
#endif
// A class (and instance) which can be used in 'tie' when an element
// of a tuple is not required.
// _GLIBCXX14_CONSTEXPR
// 2933. PR for LWG 2773 could be clearer
struct _Swallow_assign
{
template<class _Tp>
_GLIBCXX14_CONSTEXPR const _Swallow_assign&
operator=(const _Tp&) const
{ return *this; }
};
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2773. Making std::ignore constexpr
_GLIBCXX17_INLINE constexpr _Swallow_assign ignore{};
/// Partial specialization for tuples
template<typename... _Types, typename _Alloc>
struct uses_allocator<tuple<_Types...>, _Alloc> : true_type { };
// See stl_pair.h...
template<class _T1, class _T2>
template<typename... _Args1, typename... _Args2>
inline
pair<_T1, _T2>::
pair(piecewise_construct_t,
tuple<_Args1...> __first, tuple<_Args2...> __second)
: pair(__first, __second,
typename _Build_index_tuple<sizeof...(_Args1)>::__type(),
typename _Build_index_tuple<sizeof...(_Args2)>::__type())
{ }
template<class _T1, class _T2>
template<typename... _Args1, std::size_t... _Indexes1,
typename... _Args2, std::size_t... _Indexes2>
inline
pair<_T1, _T2>::
pair(tuple<_Args1...>& __tuple1, tuple<_Args2...>& __tuple2,
_Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>)
: first(std::forward<_Args1>(std::get<_Indexes1>(__tuple1))...),
second(std::forward<_Args2>(std::get<_Indexes2>(__tuple2))...)
{ }
#if __cplusplus > 201402L
# define __cpp_lib_apply 201603
template <typename _Fn, typename _Tuple, size_t... _Idx>
constexpr decltype(auto)
__apply_impl(_Fn&& __f, _Tuple&& __t, index_sequence<_Idx...>)
{
return std::__invoke(std::forward<_Fn>(__f),
std::get<_Idx>(std::forward<_Tuple>(__t))...);
}
template <typename _Fn, typename _Tuple>
constexpr decltype(auto)
apply(_Fn&& __f, _Tuple&& __t)
{
using _Indices = make_index_sequence<tuple_size_v<decay_t<_Tuple>>>;
return std::__apply_impl(std::forward<_Fn>(__f),
std::forward<_Tuple>(__t),
_Indices{});
}
#define __cpp_lib_make_from_tuple 201606
template <typename _Tp, typename _Tuple, size_t... _Idx>
constexpr _Tp
__make_from_tuple_impl(_Tuple&& __t, index_sequence<_Idx...>)
{ return _Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...); }
template <typename _Tp, typename _Tuple>
constexpr _Tp
make_from_tuple(_Tuple&& __t)
{
return __make_from_tuple_impl<_Tp>(
std::forward<_Tuple>(__t),
make_index_sequence<tuple_size_v<decay_t<_Tuple>>>{});
}
#endif // C++17
/// @}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // C++11
#endif // _GLIBCXX_TUPLE
c++/8/shared_mutex 0000644 00000045721 15201526705 0007712 0 ustar 00 // <shared_mutex> -*- C++ -*-
// Copyright (C) 2013-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/shared_mutex
* This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_SHARED_MUTEX
#define _GLIBCXX_SHARED_MUTEX 1
#pragma GCC system_header
#if __cplusplus >= 201402L
#include <bits/c++config.h>
#include <condition_variable>
#include <bits/functexcept.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @ingroup mutexes
* @{
*/
#ifdef _GLIBCXX_USE_C99_STDINT_TR1
#ifdef _GLIBCXX_HAS_GTHREADS
#if __cplusplus >= 201703L
#define __cpp_lib_shared_mutex 201505
class shared_mutex;
#endif
#define __cpp_lib_shared_timed_mutex 201402
class shared_timed_mutex;
#if _GLIBCXX_USE_PTHREAD_RWLOCK_T
/// A shared mutex type implemented using pthread_rwlock_t.
class __shared_mutex_pthread
{
friend class shared_timed_mutex;
#ifdef PTHREAD_RWLOCK_INITIALIZER
pthread_rwlock_t _M_rwlock = PTHREAD_RWLOCK_INITIALIZER;
public:
__shared_mutex_pthread() = default;
~__shared_mutex_pthread() = default;
#else
pthread_rwlock_t _M_rwlock;
public:
__shared_mutex_pthread()
{
int __ret = pthread_rwlock_init(&_M_rwlock, NULL);
if (__ret == ENOMEM)
__throw_bad_alloc();
else if (__ret == EAGAIN)
__throw_system_error(int(errc::resource_unavailable_try_again));
else if (__ret == EPERM)
__throw_system_error(int(errc::operation_not_permitted));
// Errors not handled: EBUSY, EINVAL
__glibcxx_assert(__ret == 0);
}
~__shared_mutex_pthread()
{
int __ret __attribute((__unused__)) = pthread_rwlock_destroy(&_M_rwlock);
// Errors not handled: EBUSY, EINVAL
__glibcxx_assert(__ret == 0);
}
#endif
__shared_mutex_pthread(const __shared_mutex_pthread&) = delete;
__shared_mutex_pthread& operator=(const __shared_mutex_pthread&) = delete;
void
lock()
{
int __ret = pthread_rwlock_wrlock(&_M_rwlock);
if (__ret == EDEADLK)
__throw_system_error(int(errc::resource_deadlock_would_occur));
// Errors not handled: EINVAL
__glibcxx_assert(__ret == 0);
}
bool
try_lock()
{
int __ret = pthread_rwlock_trywrlock(&_M_rwlock);
if (__ret == EBUSY) return false;
// Errors not handled: EINVAL
__glibcxx_assert(__ret == 0);
return true;
}
void
unlock()
{
int __ret __attribute((__unused__)) = pthread_rwlock_unlock(&_M_rwlock);
// Errors not handled: EPERM, EBUSY, EINVAL
__glibcxx_assert(__ret == 0);
}
// Shared ownership
void
lock_shared()
{
int __ret;
// We retry if we exceeded the maximum number of read locks supported by
// the POSIX implementation; this can result in busy-waiting, but this
// is okay based on the current specification of forward progress
// guarantees by the standard.
do
__ret = pthread_rwlock_rdlock(&_M_rwlock);
while (__ret == EAGAIN);
if (__ret == EDEADLK)
__throw_system_error(int(errc::resource_deadlock_would_occur));
// Errors not handled: EINVAL
__glibcxx_assert(__ret == 0);
}
bool
try_lock_shared()
{
int __ret = pthread_rwlock_tryrdlock(&_M_rwlock);
// If the maximum number of read locks has been exceeded, we just fail
// to acquire the lock. Unlike for lock(), we are not allowed to throw
// an exception.
if (__ret == EBUSY || __ret == EAGAIN) return false;
// Errors not handled: EINVAL
__glibcxx_assert(__ret == 0);
return true;
}
void
unlock_shared()
{
unlock();
}
void* native_handle() { return &_M_rwlock; }
};
#endif
#if ! (_GLIBCXX_USE_PTHREAD_RWLOCK_T && _GTHREAD_USE_MUTEX_TIMEDLOCK)
/// A shared mutex type implemented using std::condition_variable.
class __shared_mutex_cv
{
friend class shared_timed_mutex;
// Based on Howard Hinnant's reference implementation from N2406.
// The high bit of _M_state is the write-entered flag which is set to
// indicate a writer has taken the lock or is queuing to take the lock.
// The remaining bits are the count of reader locks.
//
// To take a reader lock, block on gate1 while the write-entered flag is
// set or the maximum number of reader locks is held, then increment the
// reader lock count.
// To release, decrement the count, then if the write-entered flag is set
// and the count is zero then signal gate2 to wake a queued writer,
// otherwise if the maximum number of reader locks was held signal gate1
// to wake a reader.
//
// To take a writer lock, block on gate1 while the write-entered flag is
// set, then set the write-entered flag to start queueing, then block on
// gate2 while the number of reader locks is non-zero.
// To release, unset the write-entered flag and signal gate1 to wake all
// blocked readers and writers.
//
// This means that when no reader locks are held readers and writers get
// equal priority. When one or more reader locks is held a writer gets
// priority and no more reader locks can be taken while the writer is
// queued.
// Only locked when accessing _M_state or waiting on condition variables.
mutex _M_mut;
// Used to block while write-entered is set or reader count at maximum.
condition_variable _M_gate1;
// Used to block queued writers while reader count is non-zero.
condition_variable _M_gate2;
// The write-entered flag and reader count.
unsigned _M_state;
static constexpr unsigned _S_write_entered
= 1U << (sizeof(unsigned)*__CHAR_BIT__ - 1);
static constexpr unsigned _S_max_readers = ~_S_write_entered;
// Test whether the write-entered flag is set. _M_mut must be locked.
bool _M_write_entered() const { return _M_state & _S_write_entered; }
// The number of reader locks currently held. _M_mut must be locked.
unsigned _M_readers() const { return _M_state & _S_max_readers; }
public:
__shared_mutex_cv() : _M_state(0) {}
~__shared_mutex_cv()
{
__glibcxx_assert( _M_state == 0 );
}
__shared_mutex_cv(const __shared_mutex_cv&) = delete;
__shared_mutex_cv& operator=(const __shared_mutex_cv&) = delete;
// Exclusive ownership
void
lock()
{
unique_lock<mutex> __lk(_M_mut);
// Wait until we can set the write-entered flag.
_M_gate1.wait(__lk, [=]{ return !_M_write_entered(); });
_M_state |= _S_write_entered;
// Then wait until there are no more readers.
_M_gate2.wait(__lk, [=]{ return _M_readers() == 0; });
}
bool
try_lock()
{
unique_lock<mutex> __lk(_M_mut, try_to_lock);
if (__lk.owns_lock() && _M_state == 0)
{
_M_state = _S_write_entered;
return true;
}
return false;
}
void
unlock()
{
lock_guard<mutex> __lk(_M_mut);
__glibcxx_assert( _M_write_entered() );
_M_state = 0;
// call notify_all() while mutex is held so that another thread can't
// lock and unlock the mutex then destroy *this before we make the call.
_M_gate1.notify_all();
}
// Shared ownership
void
lock_shared()
{
unique_lock<mutex> __lk(_M_mut);
_M_gate1.wait(__lk, [=]{ return _M_state < _S_max_readers; });
++_M_state;
}
bool
try_lock_shared()
{
unique_lock<mutex> __lk(_M_mut, try_to_lock);
if (!__lk.owns_lock())
return false;
if (_M_state < _S_max_readers)
{
++_M_state;
return true;
}
return false;
}
void
unlock_shared()
{
lock_guard<mutex> __lk(_M_mut);
__glibcxx_assert( _M_readers() > 0 );
auto __prev = _M_state--;
if (_M_write_entered())
{
// Wake the queued writer if there are no more readers.
if (_M_readers() == 0)
_M_gate2.notify_one();
// No need to notify gate1 because we give priority to the queued
// writer, and that writer will eventually notify gate1 after it
// clears the write-entered flag.
}
else
{
// Wake any thread that was blocked on reader overflow.
if (__prev == _S_max_readers)
_M_gate1.notify_one();
}
}
};
#endif
#if __cplusplus > 201402L
/// The standard shared mutex type.
class shared_mutex
{
public:
shared_mutex() = default;
~shared_mutex() = default;
shared_mutex(const shared_mutex&) = delete;
shared_mutex& operator=(const shared_mutex&) = delete;
// Exclusive ownership
void lock() { _M_impl.lock(); }
bool try_lock() { return _M_impl.try_lock(); }
void unlock() { _M_impl.unlock(); }
// Shared ownership
void lock_shared() { _M_impl.lock_shared(); }
bool try_lock_shared() { return _M_impl.try_lock_shared(); }
void unlock_shared() { _M_impl.unlock_shared(); }
#if _GLIBCXX_USE_PTHREAD_RWLOCK_T
typedef void* native_handle_type;
native_handle_type native_handle() { return _M_impl.native_handle(); }
private:
__shared_mutex_pthread _M_impl;
#else
private:
__shared_mutex_cv _M_impl;
#endif
};
#endif // C++17
#if _GLIBCXX_USE_PTHREAD_RWLOCK_T && _GTHREAD_USE_MUTEX_TIMEDLOCK
using __shared_timed_mutex_base = __shared_mutex_pthread;
#else
using __shared_timed_mutex_base = __shared_mutex_cv;
#endif
/// The standard shared timed mutex type.
class shared_timed_mutex
: private __shared_timed_mutex_base
{
using _Base = __shared_timed_mutex_base;
// Must use the same clock as condition_variable for __shared_mutex_cv.
typedef chrono::system_clock __clock_t;
public:
shared_timed_mutex() = default;
~shared_timed_mutex() = default;
shared_timed_mutex(const shared_timed_mutex&) = delete;
shared_timed_mutex& operator=(const shared_timed_mutex&) = delete;
// Exclusive ownership
void lock() { _Base::lock(); }
bool try_lock() { return _Base::try_lock(); }
void unlock() { _Base::unlock(); }
template<typename _Rep, typename _Period>
bool
try_lock_for(const chrono::duration<_Rep, _Period>& __rel_time)
{
return try_lock_until(__clock_t::now() + __rel_time);
}
// Shared ownership
void lock_shared() { _Base::lock_shared(); }
bool try_lock_shared() { return _Base::try_lock_shared(); }
void unlock_shared() { _Base::unlock_shared(); }
template<typename _Rep, typename _Period>
bool
try_lock_shared_for(const chrono::duration<_Rep, _Period>& __rel_time)
{
return try_lock_shared_until(__clock_t::now() + __rel_time);
}
#if _GLIBCXX_USE_PTHREAD_RWLOCK_T && _GTHREAD_USE_MUTEX_TIMEDLOCK
// Exclusive ownership
template<typename _Duration>
bool
try_lock_until(const chrono::time_point<__clock_t, _Duration>& __atime)
{
auto __s = chrono::time_point_cast<chrono::seconds>(__atime);
auto __ns = chrono::duration_cast<chrono::nanoseconds>(__atime - __s);
__gthread_time_t __ts =
{
static_cast<std::time_t>(__s.time_since_epoch().count()),
static_cast<long>(__ns.count())
};
int __ret = pthread_rwlock_timedwrlock(&_M_rwlock, &__ts);
// On self-deadlock, we just fail to acquire the lock. Technically,
// the program violated the precondition.
if (__ret == ETIMEDOUT || __ret == EDEADLK)
return false;
// Errors not handled: EINVAL
__glibcxx_assert(__ret == 0);
return true;
}
template<typename _Clock, typename _Duration>
bool
try_lock_until(const chrono::time_point<_Clock, _Duration>& __abs_time)
{
// DR 887 - Sync unknown clock to known clock.
const typename _Clock::time_point __c_entry = _Clock::now();
const __clock_t::time_point __s_entry = __clock_t::now();
const auto __delta = __abs_time - __c_entry;
const auto __s_atime = __s_entry + __delta;
return try_lock_until(__s_atime);
}
// Shared ownership
template<typename _Duration>
bool
try_lock_shared_until(const chrono::time_point<__clock_t,
_Duration>& __atime)
{
auto __s = chrono::time_point_cast<chrono::seconds>(__atime);
auto __ns = chrono::duration_cast<chrono::nanoseconds>(__atime - __s);
__gthread_time_t __ts =
{
static_cast<std::time_t>(__s.time_since_epoch().count()),
static_cast<long>(__ns.count())
};
int __ret;
// Unlike for lock(), we are not allowed to throw an exception so if
// the maximum number of read locks has been exceeded, or we would
// deadlock, we just try to acquire the lock again (and will time out
// eventually).
// In cases where we would exceed the maximum number of read locks
// throughout the whole time until the timeout, we will fail to
// acquire the lock even if it would be logically free; however, this
// is allowed by the standard, and we made a "strong effort"
// (see C++14 30.4.1.4p26).
// For cases where the implementation detects a deadlock we
// intentionally block and timeout so that an early return isn't
// mistaken for a spurious failure, which might help users realise
// there is a deadlock.
do
__ret = pthread_rwlock_timedrdlock(&_M_rwlock, &__ts);
while (__ret == EAGAIN || __ret == EDEADLK);
if (__ret == ETIMEDOUT)
return false;
// Errors not handled: EINVAL
__glibcxx_assert(__ret == 0);
return true;
}
template<typename _Clock, typename _Duration>
bool
try_lock_shared_until(const chrono::time_point<_Clock,
_Duration>& __abs_time)
{
// DR 887 - Sync unknown clock to known clock.
const typename _Clock::time_point __c_entry = _Clock::now();
const __clock_t::time_point __s_entry = __clock_t::now();
const auto __delta = __abs_time - __c_entry;
const auto __s_atime = __s_entry + __delta;
return try_lock_shared_until(__s_atime);
}
#else // ! (_GLIBCXX_USE_PTHREAD_RWLOCK_T && _GTHREAD_USE_MUTEX_TIMEDLOCK)
// Exclusive ownership
template<typename _Clock, typename _Duration>
bool
try_lock_until(const chrono::time_point<_Clock, _Duration>& __abs_time)
{
unique_lock<mutex> __lk(_M_mut);
if (!_M_gate1.wait_until(__lk, __abs_time,
[=]{ return !_M_write_entered(); }))
{
return false;
}
_M_state |= _S_write_entered;
if (!_M_gate2.wait_until(__lk, __abs_time,
[=]{ return _M_readers() == 0; }))
{
_M_state ^= _S_write_entered;
// Wake all threads blocked while the write-entered flag was set.
_M_gate1.notify_all();
return false;
}
return true;
}
// Shared ownership
template <typename _Clock, typename _Duration>
bool
try_lock_shared_until(const chrono::time_point<_Clock,
_Duration>& __abs_time)
{
unique_lock<mutex> __lk(_M_mut);
if (!_M_gate1.wait_until(__lk, __abs_time,
[=]{ return _M_state < _S_max_readers; }))
{
return false;
}
++_M_state;
return true;
}
#endif // _GLIBCXX_USE_PTHREAD_RWLOCK_T && _GTHREAD_USE_MUTEX_TIMEDLOCK
};
#endif // _GLIBCXX_HAS_GTHREADS
/// shared_lock
template<typename _Mutex>
class shared_lock
{
public:
typedef _Mutex mutex_type;
// Shared locking
shared_lock() noexcept : _M_pm(nullptr), _M_owns(false) { }
explicit
shared_lock(mutex_type& __m)
: _M_pm(std::__addressof(__m)), _M_owns(true)
{ __m.lock_shared(); }
shared_lock(mutex_type& __m, defer_lock_t) noexcept
: _M_pm(std::__addressof(__m)), _M_owns(false) { }
shared_lock(mutex_type& __m, try_to_lock_t)
: _M_pm(std::__addressof(__m)), _M_owns(__m.try_lock_shared()) { }
shared_lock(mutex_type& __m, adopt_lock_t)
: _M_pm(std::__addressof(__m)), _M_owns(true) { }
template<typename _Clock, typename _Duration>
shared_lock(mutex_type& __m,
const chrono::time_point<_Clock, _Duration>& __abs_time)
: _M_pm(std::__addressof(__m)),
_M_owns(__m.try_lock_shared_until(__abs_time)) { }
template<typename _Rep, typename _Period>
shared_lock(mutex_type& __m,
const chrono::duration<_Rep, _Period>& __rel_time)
: _M_pm(std::__addressof(__m)),
_M_owns(__m.try_lock_shared_for(__rel_time)) { }
~shared_lock()
{
if (_M_owns)
_M_pm->unlock_shared();
}
shared_lock(shared_lock const&) = delete;
shared_lock& operator=(shared_lock const&) = delete;
shared_lock(shared_lock&& __sl) noexcept : shared_lock()
{ swap(__sl); }
shared_lock&
operator=(shared_lock&& __sl) noexcept
{
shared_lock(std::move(__sl)).swap(*this);
return *this;
}
void
lock()
{
_M_lockable();
_M_pm->lock_shared();
_M_owns = true;
}
bool
try_lock()
{
_M_lockable();
return _M_owns = _M_pm->try_lock_shared();
}
template<typename _Rep, typename _Period>
bool
try_lock_for(const chrono::duration<_Rep, _Period>& __rel_time)
{
_M_lockable();
return _M_owns = _M_pm->try_lock_shared_for(__rel_time);
}
template<typename _Clock, typename _Duration>
bool
try_lock_until(const chrono::time_point<_Clock, _Duration>& __abs_time)
{
_M_lockable();
return _M_owns = _M_pm->try_lock_shared_until(__abs_time);
}
void
unlock()
{
if (!_M_owns)
__throw_system_error(int(errc::resource_deadlock_would_occur));
_M_pm->unlock_shared();
_M_owns = false;
}
// Setters
void
swap(shared_lock& __u) noexcept
{
std::swap(_M_pm, __u._M_pm);
std::swap(_M_owns, __u._M_owns);
}
mutex_type*
release() noexcept
{
_M_owns = false;
return std::exchange(_M_pm, nullptr);
}
// Getters
bool owns_lock() const noexcept { return _M_owns; }
explicit operator bool() const noexcept { return _M_owns; }
mutex_type* mutex() const noexcept { return _M_pm; }
private:
void
_M_lockable() const
{
if (_M_pm == nullptr)
__throw_system_error(int(errc::operation_not_permitted));
if (_M_owns)
__throw_system_error(int(errc::resource_deadlock_would_occur));
}
mutex_type* _M_pm;
bool _M_owns;
};
/// Swap specialization for shared_lock
template<typename _Mutex>
void
swap(shared_lock<_Mutex>& __x, shared_lock<_Mutex>& __y) noexcept
{ __x.swap(__y); }
#endif // _GLIBCXX_USE_C99_STDINT_TR1
// @} group mutexes
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif // C++14
#endif // _GLIBCXX_SHARED_MUTEX
c++/8/complex.h 0000644 00000003074 15201526705 0007112 0 ustar 00 // -*- C++ -*- compatibility header.
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file complex.h
* This is a Standard C++ Library header.
*/
#include <bits/c++config.h>
#if __cplusplus >= 201103L
# include <ccomplex>
#endif
#if __cplusplus >= 201103L && defined(__STRICT_ANSI__)
// For strict modes do not include the C library's <complex.h>, see PR 82417.
#elif _GLIBCXX_HAVE_COMPLEX_H
# include_next <complex.h>
# ifdef _GLIBCXX_COMPLEX
// See PR56111, keep the macro in C++03 if possible.
# undef complex
# endif
#endif
#ifndef _GLIBCXX_COMPLEX_H
#define _GLIBCXX_COMPLEX_H 1
#endif
c++/8/initializer_list 0000644 00000005636 15201526705 0010601 0 ustar 00 // std::initializer_list support -*- C++ -*-
// Copyright (C) 2008-2018 Free Software Foundation, Inc.
//
// This file is part of GCC.
//
// GCC is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// GCC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file initializer_list
* This is a Standard C++ Library header.
*/
#ifndef _INITIALIZER_LIST
#define _INITIALIZER_LIST
#pragma GCC system_header
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else // C++0x
#pragma GCC visibility push(default)
#include <bits/c++config.h>
namespace std
{
/// initializer_list
template<class _E>
class initializer_list
{
public:
typedef _E value_type;
typedef const _E& reference;
typedef const _E& const_reference;
typedef size_t size_type;
typedef const _E* iterator;
typedef const _E* const_iterator;
private:
iterator _M_array;
size_type _M_len;
// The compiler can call a private constructor.
constexpr initializer_list(const_iterator __a, size_type __l)
: _M_array(__a), _M_len(__l) { }
public:
constexpr initializer_list() noexcept
: _M_array(0), _M_len(0) { }
// Number of elements.
constexpr size_type
size() const noexcept { return _M_len; }
// First element.
constexpr const_iterator
begin() const noexcept { return _M_array; }
// One past the last element.
constexpr const_iterator
end() const noexcept { return begin() + size(); }
};
/**
* @brief Return an iterator pointing to the first element of
* the initializer_list.
* @param __ils Initializer list.
*/
template<class _Tp>
constexpr const _Tp*
begin(initializer_list<_Tp> __ils) noexcept
{ return __ils.begin(); }
/**
* @brief Return an iterator pointing to one past the last element
* of the initializer_list.
* @param __ils Initializer list.
*/
template<class _Tp>
constexpr const _Tp*
end(initializer_list<_Tp> __ils) noexcept
{ return __ils.end(); }
}
#pragma GCC visibility pop
#endif // C++11
#endif // _INITIALIZER_LIST
c++/8/csignal 0000644 00000003477 15201526705 0006644 0 ustar 00 // -*- C++ -*- forwarding header.
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file csignal
* This is a Standard C++ Library file. You should @c \#include this file
* in your programs, rather than any of the @a *.h implementation files.
*
* This is the C++ version of the Standard C Library header @c signal.h,
* and its contents are (mostly) the same as that header, but are all
* contained in the namespace @c std (except for names which are defined
* as macros in C).
*/
//
// ISO C++ 14882: 20.4.6 C library
//
#pragma GCC system_header
#include <bits/c++config.h>
#include <signal.h>
#ifndef _GLIBCXX_CSIGNAL
#define _GLIBCXX_CSIGNAL 1
// Get rid of those macros defined in <signal.h> in lieu of real functions.
#undef raise
namespace std
{
using ::sig_atomic_t;
using ::signal;
using ::raise;
} // namespace std
#endif
c++/8/cfenv 0000644 00000004003 15201526705 0006307 0 ustar 00 // <cfenv> -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/cfenv
* This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_CFENV
#define _GLIBCXX_CFENV 1
#pragma GCC system_header
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
#include <bits/c++config.h>
#if _GLIBCXX_HAVE_FENV_H
# include <fenv.h>
#endif
#ifdef _GLIBCXX_USE_C99_FENV_TR1
#undef feclearexcept
#undef fegetexceptflag
#undef feraiseexcept
#undef fesetexceptflag
#undef fetestexcept
#undef fegetround
#undef fesetround
#undef fegetenv
#undef feholdexcept
#undef fesetenv
#undef feupdateenv
namespace std
{
// types
using ::fenv_t;
using ::fexcept_t;
// functions
using ::feclearexcept;
using ::fegetexceptflag;
using ::feraiseexcept;
using ::fesetexceptflag;
using ::fetestexcept;
using ::fegetround;
using ::fesetround;
using ::fegetenv;
using ::feholdexcept;
using ::fesetenv;
using ::feupdateenv;
} // namespace std
#endif // _GLIBCXX_USE_C99_FENV_TR1
#endif // C++11
#endif // _GLIBCXX_CFENV
c++/8/bitset 0000644 00000131526 15201526705 0006513 0 ustar 00 // <bitset> -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
* Copyright (c) 1998
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file include/bitset
* This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_BITSET
#define _GLIBCXX_BITSET 1
#pragma GCC system_header
#include <string>
#include <bits/functexcept.h> // For invalid_argument, out_of_range,
// overflow_error
#include <iosfwd>
#include <bits/cxxabi_forced.h>
#if __cplusplus >= 201103L
# include <bits/functional_hash.h>
#endif
#define _GLIBCXX_BITSET_BITS_PER_WORD (__CHAR_BIT__ * __SIZEOF_LONG__)
#define _GLIBCXX_BITSET_WORDS(__n) \
((__n) / _GLIBCXX_BITSET_BITS_PER_WORD + \
((__n) % _GLIBCXX_BITSET_BITS_PER_WORD == 0 ? 0 : 1))
#define _GLIBCXX_BITSET_BITS_PER_ULL (__CHAR_BIT__ * __SIZEOF_LONG_LONG__)
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
/**
* Base class, general case. It is a class invariant that _Nw will be
* nonnegative.
*
* See documentation for bitset.
*/
template<size_t _Nw>
struct _Base_bitset
{
typedef unsigned long _WordT;
/// 0 is the least significant word.
_WordT _M_w[_Nw];
_GLIBCXX_CONSTEXPR _Base_bitset() _GLIBCXX_NOEXCEPT
: _M_w() { }
#if __cplusplus >= 201103L
constexpr _Base_bitset(unsigned long long __val) noexcept
: _M_w{ _WordT(__val)
#if __SIZEOF_LONG_LONG__ > __SIZEOF_LONG__
, _WordT(__val >> _GLIBCXX_BITSET_BITS_PER_WORD)
#endif
} { }
#else
_Base_bitset(unsigned long __val)
: _M_w()
{ _M_w[0] = __val; }
#endif
static _GLIBCXX_CONSTEXPR size_t
_S_whichword(size_t __pos) _GLIBCXX_NOEXCEPT
{ return __pos / _GLIBCXX_BITSET_BITS_PER_WORD; }
static _GLIBCXX_CONSTEXPR size_t
_S_whichbyte(size_t __pos) _GLIBCXX_NOEXCEPT
{ return (__pos % _GLIBCXX_BITSET_BITS_PER_WORD) / __CHAR_BIT__; }
static _GLIBCXX_CONSTEXPR size_t
_S_whichbit(size_t __pos) _GLIBCXX_NOEXCEPT
{ return __pos % _GLIBCXX_BITSET_BITS_PER_WORD; }
static _GLIBCXX_CONSTEXPR _WordT
_S_maskbit(size_t __pos) _GLIBCXX_NOEXCEPT
{ return (static_cast<_WordT>(1)) << _S_whichbit(__pos); }
_WordT&
_M_getword(size_t __pos) _GLIBCXX_NOEXCEPT
{ return _M_w[_S_whichword(__pos)]; }
_GLIBCXX_CONSTEXPR _WordT
_M_getword(size_t __pos) const _GLIBCXX_NOEXCEPT
{ return _M_w[_S_whichword(__pos)]; }
#if __cplusplus >= 201103L
const _WordT*
_M_getdata() const noexcept
{ return _M_w; }
#endif
_WordT&
_M_hiword() _GLIBCXX_NOEXCEPT
{ return _M_w[_Nw - 1]; }
_GLIBCXX_CONSTEXPR _WordT
_M_hiword() const _GLIBCXX_NOEXCEPT
{ return _M_w[_Nw - 1]; }
void
_M_do_and(const _Base_bitset<_Nw>& __x) _GLIBCXX_NOEXCEPT
{
for (size_t __i = 0; __i < _Nw; __i++)
_M_w[__i] &= __x._M_w[__i];
}
void
_M_do_or(const _Base_bitset<_Nw>& __x) _GLIBCXX_NOEXCEPT
{
for (size_t __i = 0; __i < _Nw; __i++)
_M_w[__i] |= __x._M_w[__i];
}
void
_M_do_xor(const _Base_bitset<_Nw>& __x) _GLIBCXX_NOEXCEPT
{
for (size_t __i = 0; __i < _Nw; __i++)
_M_w[__i] ^= __x._M_w[__i];
}
void
_M_do_left_shift(size_t __shift) _GLIBCXX_NOEXCEPT;
void
_M_do_right_shift(size_t __shift) _GLIBCXX_NOEXCEPT;
void
_M_do_flip() _GLIBCXX_NOEXCEPT
{
for (size_t __i = 0; __i < _Nw; __i++)
_M_w[__i] = ~_M_w[__i];
}
void
_M_do_set() _GLIBCXX_NOEXCEPT
{
for (size_t __i = 0; __i < _Nw; __i++)
_M_w[__i] = ~static_cast<_WordT>(0);
}
void
_M_do_reset() _GLIBCXX_NOEXCEPT
{ __builtin_memset(_M_w, 0, _Nw * sizeof(_WordT)); }
bool
_M_is_equal(const _Base_bitset<_Nw>& __x) const _GLIBCXX_NOEXCEPT
{
for (size_t __i = 0; __i < _Nw; ++__i)
if (_M_w[__i] != __x._M_w[__i])
return false;
return true;
}
template<size_t _Nb>
bool
_M_are_all() const _GLIBCXX_NOEXCEPT
{
for (size_t __i = 0; __i < _Nw - 1; __i++)
if (_M_w[__i] != ~static_cast<_WordT>(0))
return false;
return _M_hiword() == (~static_cast<_WordT>(0)
>> (_Nw * _GLIBCXX_BITSET_BITS_PER_WORD
- _Nb));
}
bool
_M_is_any() const _GLIBCXX_NOEXCEPT
{
for (size_t __i = 0; __i < _Nw; __i++)
if (_M_w[__i] != static_cast<_WordT>(0))
return true;
return false;
}
size_t
_M_do_count() const _GLIBCXX_NOEXCEPT
{
size_t __result = 0;
for (size_t __i = 0; __i < _Nw; __i++)
__result += __builtin_popcountl(_M_w[__i]);
return __result;
}
unsigned long
_M_do_to_ulong() const;
#if __cplusplus >= 201103L
unsigned long long
_M_do_to_ullong() const;
#endif
// find first "on" bit
size_t
_M_do_find_first(size_t) const _GLIBCXX_NOEXCEPT;
// find the next "on" bit that follows "prev"
size_t
_M_do_find_next(size_t, size_t) const _GLIBCXX_NOEXCEPT;
};
// Definitions of non-inline functions from _Base_bitset.
template<size_t _Nw>
void
_Base_bitset<_Nw>::_M_do_left_shift(size_t __shift) _GLIBCXX_NOEXCEPT
{
if (__builtin_expect(__shift != 0, 1))
{
const size_t __wshift = __shift / _GLIBCXX_BITSET_BITS_PER_WORD;
const size_t __offset = __shift % _GLIBCXX_BITSET_BITS_PER_WORD;
if (__offset == 0)
for (size_t __n = _Nw - 1; __n >= __wshift; --__n)
_M_w[__n] = _M_w[__n - __wshift];
else
{
const size_t __sub_offset = (_GLIBCXX_BITSET_BITS_PER_WORD
- __offset);
for (size_t __n = _Nw - 1; __n > __wshift; --__n)
_M_w[__n] = ((_M_w[__n - __wshift] << __offset)
| (_M_w[__n - __wshift - 1] >> __sub_offset));
_M_w[__wshift] = _M_w[0] << __offset;
}
std::fill(_M_w + 0, _M_w + __wshift, static_cast<_WordT>(0));
}
}
template<size_t _Nw>
void
_Base_bitset<_Nw>::_M_do_right_shift(size_t __shift) _GLIBCXX_NOEXCEPT
{
if (__builtin_expect(__shift != 0, 1))
{
const size_t __wshift = __shift / _GLIBCXX_BITSET_BITS_PER_WORD;
const size_t __offset = __shift % _GLIBCXX_BITSET_BITS_PER_WORD;
const size_t __limit = _Nw - __wshift - 1;
if (__offset == 0)
for (size_t __n = 0; __n <= __limit; ++__n)
_M_w[__n] = _M_w[__n + __wshift];
else
{
const size_t __sub_offset = (_GLIBCXX_BITSET_BITS_PER_WORD
- __offset);
for (size_t __n = 0; __n < __limit; ++__n)
_M_w[__n] = ((_M_w[__n + __wshift] >> __offset)
| (_M_w[__n + __wshift + 1] << __sub_offset));
_M_w[__limit] = _M_w[_Nw-1] >> __offset;
}
std::fill(_M_w + __limit + 1, _M_w + _Nw, static_cast<_WordT>(0));
}
}
template<size_t _Nw>
unsigned long
_Base_bitset<_Nw>::_M_do_to_ulong() const
{
for (size_t __i = 1; __i < _Nw; ++__i)
if (_M_w[__i])
__throw_overflow_error(__N("_Base_bitset::_M_do_to_ulong"));
return _M_w[0];
}
#if __cplusplus >= 201103L
template<size_t _Nw>
unsigned long long
_Base_bitset<_Nw>::_M_do_to_ullong() const
{
const bool __dw = sizeof(unsigned long long) > sizeof(unsigned long);
for (size_t __i = 1 + __dw; __i < _Nw; ++__i)
if (_M_w[__i])
__throw_overflow_error(__N("_Base_bitset::_M_do_to_ullong"));
if (__dw)
return _M_w[0] + (static_cast<unsigned long long>(_M_w[1])
<< _GLIBCXX_BITSET_BITS_PER_WORD);
return _M_w[0];
}
#endif
template<size_t _Nw>
size_t
_Base_bitset<_Nw>::
_M_do_find_first(size_t __not_found) const _GLIBCXX_NOEXCEPT
{
for (size_t __i = 0; __i < _Nw; __i++)
{
_WordT __thisword = _M_w[__i];
if (__thisword != static_cast<_WordT>(0))
return (__i * _GLIBCXX_BITSET_BITS_PER_WORD
+ __builtin_ctzl(__thisword));
}
// not found, so return an indication of failure.
return __not_found;
}
template<size_t _Nw>
size_t
_Base_bitset<_Nw>::
_M_do_find_next(size_t __prev, size_t __not_found) const _GLIBCXX_NOEXCEPT
{
// make bound inclusive
++__prev;
// check out of bounds
if (__prev >= _Nw * _GLIBCXX_BITSET_BITS_PER_WORD)
return __not_found;
// search first word
size_t __i = _S_whichword(__prev);
_WordT __thisword = _M_w[__i];
// mask off bits below bound
__thisword &= (~static_cast<_WordT>(0)) << _S_whichbit(__prev);
if (__thisword != static_cast<_WordT>(0))
return (__i * _GLIBCXX_BITSET_BITS_PER_WORD
+ __builtin_ctzl(__thisword));
// check subsequent words
__i++;
for (; __i < _Nw; __i++)
{
__thisword = _M_w[__i];
if (__thisword != static_cast<_WordT>(0))
return (__i * _GLIBCXX_BITSET_BITS_PER_WORD
+ __builtin_ctzl(__thisword));
}
// not found, so return an indication of failure.
return __not_found;
} // end _M_do_find_next
/**
* Base class, specialization for a single word.
*
* See documentation for bitset.
*/
template<>
struct _Base_bitset<1>
{
typedef unsigned long _WordT;
_WordT _M_w;
_GLIBCXX_CONSTEXPR _Base_bitset() _GLIBCXX_NOEXCEPT
: _M_w(0)
{ }
#if __cplusplus >= 201103L
constexpr _Base_bitset(unsigned long long __val) noexcept
#else
_Base_bitset(unsigned long __val)
#endif
: _M_w(__val)
{ }
static _GLIBCXX_CONSTEXPR size_t
_S_whichword(size_t __pos) _GLIBCXX_NOEXCEPT
{ return __pos / _GLIBCXX_BITSET_BITS_PER_WORD; }
static _GLIBCXX_CONSTEXPR size_t
_S_whichbyte(size_t __pos) _GLIBCXX_NOEXCEPT
{ return (__pos % _GLIBCXX_BITSET_BITS_PER_WORD) / __CHAR_BIT__; }
static _GLIBCXX_CONSTEXPR size_t
_S_whichbit(size_t __pos) _GLIBCXX_NOEXCEPT
{ return __pos % _GLIBCXX_BITSET_BITS_PER_WORD; }
static _GLIBCXX_CONSTEXPR _WordT
_S_maskbit(size_t __pos) _GLIBCXX_NOEXCEPT
{ return (static_cast<_WordT>(1)) << _S_whichbit(__pos); }
_WordT&
_M_getword(size_t) _GLIBCXX_NOEXCEPT
{ return _M_w; }
_GLIBCXX_CONSTEXPR _WordT
_M_getword(size_t) const _GLIBCXX_NOEXCEPT
{ return _M_w; }
#if __cplusplus >= 201103L
const _WordT*
_M_getdata() const noexcept
{ return &_M_w; }
#endif
_WordT&
_M_hiword() _GLIBCXX_NOEXCEPT
{ return _M_w; }
_GLIBCXX_CONSTEXPR _WordT
_M_hiword() const _GLIBCXX_NOEXCEPT
{ return _M_w; }
void
_M_do_and(const _Base_bitset<1>& __x) _GLIBCXX_NOEXCEPT
{ _M_w &= __x._M_w; }
void
_M_do_or(const _Base_bitset<1>& __x) _GLIBCXX_NOEXCEPT
{ _M_w |= __x._M_w; }
void
_M_do_xor(const _Base_bitset<1>& __x) _GLIBCXX_NOEXCEPT
{ _M_w ^= __x._M_w; }
void
_M_do_left_shift(size_t __shift) _GLIBCXX_NOEXCEPT
{ _M_w <<= __shift; }
void
_M_do_right_shift(size_t __shift) _GLIBCXX_NOEXCEPT
{ _M_w >>= __shift; }
void
_M_do_flip() _GLIBCXX_NOEXCEPT
{ _M_w = ~_M_w; }
void
_M_do_set() _GLIBCXX_NOEXCEPT
{ _M_w = ~static_cast<_WordT>(0); }
void
_M_do_reset() _GLIBCXX_NOEXCEPT
{ _M_w = 0; }
bool
_M_is_equal(const _Base_bitset<1>& __x) const _GLIBCXX_NOEXCEPT
{ return _M_w == __x._M_w; }
template<size_t _Nb>
bool
_M_are_all() const _GLIBCXX_NOEXCEPT
{ return _M_w == (~static_cast<_WordT>(0)
>> (_GLIBCXX_BITSET_BITS_PER_WORD - _Nb)); }
bool
_M_is_any() const _GLIBCXX_NOEXCEPT
{ return _M_w != 0; }
size_t
_M_do_count() const _GLIBCXX_NOEXCEPT
{ return __builtin_popcountl(_M_w); }
unsigned long
_M_do_to_ulong() const _GLIBCXX_NOEXCEPT
{ return _M_w; }
#if __cplusplus >= 201103L
unsigned long long
_M_do_to_ullong() const noexcept
{ return _M_w; }
#endif
size_t
_M_do_find_first(size_t __not_found) const _GLIBCXX_NOEXCEPT
{
if (_M_w != 0)
return __builtin_ctzl(_M_w);
else
return __not_found;
}
// find the next "on" bit that follows "prev"
size_t
_M_do_find_next(size_t __prev, size_t __not_found) const
_GLIBCXX_NOEXCEPT
{
++__prev;
if (__prev >= ((size_t) _GLIBCXX_BITSET_BITS_PER_WORD))
return __not_found;
_WordT __x = _M_w >> __prev;
if (__x != 0)
return __builtin_ctzl(__x) + __prev;
else
return __not_found;
}
};
/**
* Base class, specialization for no storage (zero-length %bitset).
*
* See documentation for bitset.
*/
template<>
struct _Base_bitset<0>
{
typedef unsigned long _WordT;
_GLIBCXX_CONSTEXPR _Base_bitset() _GLIBCXX_NOEXCEPT
{ }
#if __cplusplus >= 201103L
constexpr _Base_bitset(unsigned long long) noexcept
#else
_Base_bitset(unsigned long)
#endif
{ }
static _GLIBCXX_CONSTEXPR size_t
_S_whichword(size_t __pos) _GLIBCXX_NOEXCEPT
{ return __pos / _GLIBCXX_BITSET_BITS_PER_WORD; }
static _GLIBCXX_CONSTEXPR size_t
_S_whichbyte(size_t __pos) _GLIBCXX_NOEXCEPT
{ return (__pos % _GLIBCXX_BITSET_BITS_PER_WORD) / __CHAR_BIT__; }
static _GLIBCXX_CONSTEXPR size_t
_S_whichbit(size_t __pos) _GLIBCXX_NOEXCEPT
{ return __pos % _GLIBCXX_BITSET_BITS_PER_WORD; }
static _GLIBCXX_CONSTEXPR _WordT
_S_maskbit(size_t __pos) _GLIBCXX_NOEXCEPT
{ return (static_cast<_WordT>(1)) << _S_whichbit(__pos); }
// This would normally give access to the data. The bounds-checking
// in the bitset class will prevent the user from getting this far,
// but (1) it must still return an lvalue to compile, and (2) the
// user might call _Unchecked_set directly, in which case this /needs/
// to fail. Let's not penalize zero-length users unless they actually
// make an unchecked call; all the memory ugliness is therefore
// localized to this single should-never-get-this-far function.
_WordT&
_M_getword(size_t) _GLIBCXX_NOEXCEPT
{
__throw_out_of_range(__N("_Base_bitset::_M_getword"));
return *new _WordT;
}
_GLIBCXX_CONSTEXPR _WordT
_M_getword(size_t) const _GLIBCXX_NOEXCEPT
{ return 0; }
_GLIBCXX_CONSTEXPR _WordT
_M_hiword() const _GLIBCXX_NOEXCEPT
{ return 0; }
void
_M_do_and(const _Base_bitset<0>&) _GLIBCXX_NOEXCEPT
{ }
void
_M_do_or(const _Base_bitset<0>&) _GLIBCXX_NOEXCEPT
{ }
void
_M_do_xor(const _Base_bitset<0>&) _GLIBCXX_NOEXCEPT
{ }
void
_M_do_left_shift(size_t) _GLIBCXX_NOEXCEPT
{ }
void
_M_do_right_shift(size_t) _GLIBCXX_NOEXCEPT
{ }
void
_M_do_flip() _GLIBCXX_NOEXCEPT
{ }
void
_M_do_set() _GLIBCXX_NOEXCEPT
{ }
void
_M_do_reset() _GLIBCXX_NOEXCEPT
{ }
// Are all empty bitsets equal to each other? Are they equal to
// themselves? How to compare a thing which has no state? What is
// the sound of one zero-length bitset clapping?
bool
_M_is_equal(const _Base_bitset<0>&) const _GLIBCXX_NOEXCEPT
{ return true; }
template<size_t _Nb>
bool
_M_are_all() const _GLIBCXX_NOEXCEPT
{ return true; }
bool
_M_is_any() const _GLIBCXX_NOEXCEPT
{ return false; }
size_t
_M_do_count() const _GLIBCXX_NOEXCEPT
{ return 0; }
unsigned long
_M_do_to_ulong() const _GLIBCXX_NOEXCEPT
{ return 0; }
#if __cplusplus >= 201103L
unsigned long long
_M_do_to_ullong() const noexcept
{ return 0; }
#endif
// Normally "not found" is the size, but that could also be
// misinterpreted as an index in this corner case. Oh well.
size_t
_M_do_find_first(size_t) const _GLIBCXX_NOEXCEPT
{ return 0; }
size_t
_M_do_find_next(size_t, size_t) const _GLIBCXX_NOEXCEPT
{ return 0; }
};
// Helper class to zero out the unused high-order bits in the highest word.
template<size_t _Extrabits>
struct _Sanitize
{
typedef unsigned long _WordT;
static void
_S_do_sanitize(_WordT& __val) _GLIBCXX_NOEXCEPT
{ __val &= ~((~static_cast<_WordT>(0)) << _Extrabits); }
};
template<>
struct _Sanitize<0>
{
typedef unsigned long _WordT;
static void
_S_do_sanitize(_WordT) _GLIBCXX_NOEXCEPT { }
};
#if __cplusplus >= 201103L
template<size_t _Nb, bool = (_Nb < _GLIBCXX_BITSET_BITS_PER_ULL)>
struct _Sanitize_val
{
static constexpr unsigned long long
_S_do_sanitize_val(unsigned long long __val)
{ return __val; }
};
template<size_t _Nb>
struct _Sanitize_val<_Nb, true>
{
static constexpr unsigned long long
_S_do_sanitize_val(unsigned long long __val)
{ return __val & ~((~static_cast<unsigned long long>(0)) << _Nb); }
};
#endif
/**
* @brief The %bitset class represents a @e fixed-size sequence of bits.
* @ingroup utilities
*
* (Note that %bitset does @e not meet the formal requirements of a
* <a href="tables.html#65">container</a>. Mainly, it lacks iterators.)
*
* The template argument, @a Nb, may be any non-negative number,
* specifying the number of bits (e.g., "0", "12", "1024*1024").
*
* In the general unoptimized case, storage is allocated in word-sized
* blocks. Let B be the number of bits in a word, then (Nb+(B-1))/B
* words will be used for storage. B - Nb%B bits are unused. (They are
* the high-order bits in the highest word.) It is a class invariant
* that those unused bits are always zero.
*
* If you think of %bitset as <em>a simple array of bits</em>, be
* aware that your mental picture is reversed: a %bitset behaves
* the same way as bits in integers do, with the bit at index 0 in
* the <em>least significant / right-hand</em> position, and the bit at
* index Nb-1 in the <em>most significant / left-hand</em> position.
* Thus, unlike other containers, a %bitset's index <em>counts from
* right to left</em>, to put it very loosely.
*
* This behavior is preserved when translating to and from strings. For
* example, the first line of the following program probably prints
* <em>b('a') is 0001100001</em> on a modern ASCII system.
*
* @code
* #include <bitset>
* #include <iostream>
* #include <sstream>
*
* using namespace std;
*
* int main()
* {
* long a = 'a';
* bitset<10> b(a);
*
* cout << "b('a') is " << b << endl;
*
* ostringstream s;
* s << b;
* string str = s.str();
* cout << "index 3 in the string is " << str[3] << " but\n"
* << "index 3 in the bitset is " << b[3] << endl;
* }
* @endcode
*
* Also see:
* https://gcc.gnu.org/onlinedocs/libstdc++/manual/ext_containers.html
* for a description of extensions.
*
* Most of the actual code isn't contained in %bitset<> itself, but in the
* base class _Base_bitset. The base class works with whole words, not with
* individual bits. This allows us to specialize _Base_bitset for the
* important special case where the %bitset is only a single word.
*
* Extra confusion can result due to the fact that the storage for
* _Base_bitset @e is a regular array, and is indexed as such. This is
* carefully encapsulated.
*/
template<size_t _Nb>
class bitset
: private _Base_bitset<_GLIBCXX_BITSET_WORDS(_Nb)>
{
private:
typedef _Base_bitset<_GLIBCXX_BITSET_WORDS(_Nb)> _Base;
typedef unsigned long _WordT;
template<class _CharT, class _Traits, class _Alloc>
void
_M_check_initial_position(const std::basic_string<_CharT, _Traits, _Alloc>& __s,
size_t __position) const
{
if (__position > __s.size())
__throw_out_of_range_fmt(__N("bitset::bitset: __position "
"(which is %zu) > __s.size() "
"(which is %zu)"),
__position, __s.size());
}
void _M_check(size_t __position, const char *__s) const
{
if (__position >= _Nb)
__throw_out_of_range_fmt(__N("%s: __position (which is %zu) "
">= _Nb (which is %zu)"),
__s, __position, _Nb);
}
void
_M_do_sanitize() _GLIBCXX_NOEXCEPT
{
typedef _Sanitize<_Nb % _GLIBCXX_BITSET_BITS_PER_WORD> __sanitize_type;
__sanitize_type::_S_do_sanitize(this->_M_hiword());
}
#if __cplusplus >= 201103L
friend struct std::hash<bitset>;
#endif
public:
/**
* This encapsulates the concept of a single bit. An instance of this
* class is a proxy for an actual bit; this way the individual bit
* operations are done as faster word-size bitwise instructions.
*
* Most users will never need to use this class directly; conversions
* to and from bool are automatic and should be transparent. Overloaded
* operators help to preserve the illusion.
*
* (On a typical system, this <em>bit %reference</em> is 64
* times the size of an actual bit. Ha.)
*/
class reference
{
friend class bitset;
_WordT* _M_wp;
size_t _M_bpos;
// left undefined
reference();
public:
reference(bitset& __b, size_t __pos) _GLIBCXX_NOEXCEPT
{
_M_wp = &__b._M_getword(__pos);
_M_bpos = _Base::_S_whichbit(__pos);
}
~reference() _GLIBCXX_NOEXCEPT
{ }
// For b[i] = __x;
reference&
operator=(bool __x) _GLIBCXX_NOEXCEPT
{
if (__x)
*_M_wp |= _Base::_S_maskbit(_M_bpos);
else
*_M_wp &= ~_Base::_S_maskbit(_M_bpos);
return *this;
}
// For b[i] = b[__j];
reference&
operator=(const reference& __j) _GLIBCXX_NOEXCEPT
{
if ((*(__j._M_wp) & _Base::_S_maskbit(__j._M_bpos)))
*_M_wp |= _Base::_S_maskbit(_M_bpos);
else
*_M_wp &= ~_Base::_S_maskbit(_M_bpos);
return *this;
}
// Flips the bit
bool
operator~() const _GLIBCXX_NOEXCEPT
{ return (*(_M_wp) & _Base::_S_maskbit(_M_bpos)) == 0; }
// For __x = b[i];
operator bool() const _GLIBCXX_NOEXCEPT
{ return (*(_M_wp) & _Base::_S_maskbit(_M_bpos)) != 0; }
// For b[i].flip();
reference&
flip() _GLIBCXX_NOEXCEPT
{
*_M_wp ^= _Base::_S_maskbit(_M_bpos);
return *this;
}
};
friend class reference;
// 23.3.5.1 constructors:
/// All bits set to zero.
_GLIBCXX_CONSTEXPR bitset() _GLIBCXX_NOEXCEPT
{ }
/// Initial bits bitwise-copied from a single word (others set to zero).
#if __cplusplus >= 201103L
constexpr bitset(unsigned long long __val) noexcept
: _Base(_Sanitize_val<_Nb>::_S_do_sanitize_val(__val)) { }
#else
bitset(unsigned long __val)
: _Base(__val)
{ _M_do_sanitize(); }
#endif
/**
* Use a subset of a string.
* @param __s A string of @a 0 and @a 1 characters.
* @param __position Index of the first character in @a __s to use;
* defaults to zero.
* @throw std::out_of_range If @a pos is bigger the size of @a __s.
* @throw std::invalid_argument If a character appears in the string
* which is neither @a 0 nor @a 1.
*/
template<class _CharT, class _Traits, class _Alloc>
explicit
bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __s,
size_t __position = 0)
: _Base()
{
_M_check_initial_position(__s, __position);
_M_copy_from_string(__s, __position,
std::basic_string<_CharT, _Traits, _Alloc>::npos,
_CharT('0'), _CharT('1'));
}
/**
* Use a subset of a string.
* @param __s A string of @a 0 and @a 1 characters.
* @param __position Index of the first character in @a __s to use.
* @param __n The number of characters to copy.
* @throw std::out_of_range If @a __position is bigger the size
* of @a __s.
* @throw std::invalid_argument If a character appears in the string
* which is neither @a 0 nor @a 1.
*/
template<class _CharT, class _Traits, class _Alloc>
bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __s,
size_t __position, size_t __n)
: _Base()
{
_M_check_initial_position(__s, __position);
_M_copy_from_string(__s, __position, __n, _CharT('0'), _CharT('1'));
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 396. what are characters zero and one.
template<class _CharT, class _Traits, class _Alloc>
bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __s,
size_t __position, size_t __n,
_CharT __zero, _CharT __one = _CharT('1'))
: _Base()
{
_M_check_initial_position(__s, __position);
_M_copy_from_string(__s, __position, __n, __zero, __one);
}
#if __cplusplus >= 201103L
/**
* Construct from a character %array.
* @param __str An %array of characters @a zero and @a one.
* @param __n The number of characters to use.
* @param __zero The character corresponding to the value 0.
* @param __one The character corresponding to the value 1.
* @throw std::invalid_argument If a character appears in the string
* which is neither @a __zero nor @a __one.
*/
template<typename _CharT>
explicit
bitset(const _CharT* __str,
typename std::basic_string<_CharT>::size_type __n
= std::basic_string<_CharT>::npos,
_CharT __zero = _CharT('0'), _CharT __one = _CharT('1'))
: _Base()
{
if (!__str)
__throw_logic_error(__N("bitset::bitset(const _CharT*, ...)"));
if (__n == std::basic_string<_CharT>::npos)
__n = std::char_traits<_CharT>::length(__str);
_M_copy_from_ptr<_CharT, std::char_traits<_CharT>>(__str, __n, 0,
__n, __zero,
__one);
}
#endif
// 23.3.5.2 bitset operations:
//@{
/**
* Operations on bitsets.
* @param __rhs A same-sized bitset.
*
* These should be self-explanatory.
*/
bitset<_Nb>&
operator&=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT
{
this->_M_do_and(__rhs);
return *this;
}
bitset<_Nb>&
operator|=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT
{
this->_M_do_or(__rhs);
return *this;
}
bitset<_Nb>&
operator^=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT
{
this->_M_do_xor(__rhs);
return *this;
}
//@}
//@{
/**
* Operations on bitsets.
* @param __position The number of places to shift.
*
* These should be self-explanatory.
*/
bitset<_Nb>&
operator<<=(size_t __position) _GLIBCXX_NOEXCEPT
{
if (__builtin_expect(__position < _Nb, 1))
{
this->_M_do_left_shift(__position);
this->_M_do_sanitize();
}
else
this->_M_do_reset();
return *this;
}
bitset<_Nb>&
operator>>=(size_t __position) _GLIBCXX_NOEXCEPT
{
if (__builtin_expect(__position < _Nb, 1))
{
this->_M_do_right_shift(__position);
this->_M_do_sanitize();
}
else
this->_M_do_reset();
return *this;
}
//@}
//@{
/**
* These versions of single-bit set, reset, flip, and test are
* extensions from the SGI version. They do no range checking.
* @ingroup SGIextensions
*/
bitset<_Nb>&
_Unchecked_set(size_t __pos) _GLIBCXX_NOEXCEPT
{
this->_M_getword(__pos) |= _Base::_S_maskbit(__pos);
return *this;
}
bitset<_Nb>&
_Unchecked_set(size_t __pos, int __val) _GLIBCXX_NOEXCEPT
{
if (__val)
this->_M_getword(__pos) |= _Base::_S_maskbit(__pos);
else
this->_M_getword(__pos) &= ~_Base::_S_maskbit(__pos);
return *this;
}
bitset<_Nb>&
_Unchecked_reset(size_t __pos) _GLIBCXX_NOEXCEPT
{
this->_M_getword(__pos) &= ~_Base::_S_maskbit(__pos);
return *this;
}
bitset<_Nb>&
_Unchecked_flip(size_t __pos) _GLIBCXX_NOEXCEPT
{
this->_M_getword(__pos) ^= _Base::_S_maskbit(__pos);
return *this;
}
_GLIBCXX_CONSTEXPR bool
_Unchecked_test(size_t __pos) const _GLIBCXX_NOEXCEPT
{ return ((this->_M_getword(__pos) & _Base::_S_maskbit(__pos))
!= static_cast<_WordT>(0)); }
//@}
// Set, reset, and flip.
/**
* @brief Sets every bit to true.
*/
bitset<_Nb>&
set() _GLIBCXX_NOEXCEPT
{
this->_M_do_set();
this->_M_do_sanitize();
return *this;
}
/**
* @brief Sets a given bit to a particular value.
* @param __position The index of the bit.
* @param __val Either true or false, defaults to true.
* @throw std::out_of_range If @a pos is bigger the size of the %set.
*/
bitset<_Nb>&
set(size_t __position, bool __val = true)
{
this->_M_check(__position, __N("bitset::set"));
return _Unchecked_set(__position, __val);
}
/**
* @brief Sets every bit to false.
*/
bitset<_Nb>&
reset() _GLIBCXX_NOEXCEPT
{
this->_M_do_reset();
return *this;
}
/**
* @brief Sets a given bit to false.
* @param __position The index of the bit.
* @throw std::out_of_range If @a pos is bigger the size of the %set.
*
* Same as writing @c set(pos,false).
*/
bitset<_Nb>&
reset(size_t __position)
{
this->_M_check(__position, __N("bitset::reset"));
return _Unchecked_reset(__position);
}
/**
* @brief Toggles every bit to its opposite value.
*/
bitset<_Nb>&
flip() _GLIBCXX_NOEXCEPT
{
this->_M_do_flip();
this->_M_do_sanitize();
return *this;
}
/**
* @brief Toggles a given bit to its opposite value.
* @param __position The index of the bit.
* @throw std::out_of_range If @a pos is bigger the size of the %set.
*/
bitset<_Nb>&
flip(size_t __position)
{
this->_M_check(__position, __N("bitset::flip"));
return _Unchecked_flip(__position);
}
/// See the no-argument flip().
bitset<_Nb>
operator~() const _GLIBCXX_NOEXCEPT
{ return bitset<_Nb>(*this).flip(); }
//@{
/**
* @brief Array-indexing support.
* @param __position Index into the %bitset.
* @return A bool for a <em>const %bitset</em>. For non-const
* bitsets, an instance of the reference proxy class.
* @note These operators do no range checking and throw no exceptions,
* as required by DR 11 to the standard.
*
* _GLIBCXX_RESOLVE_LIB_DEFECTS Note that this implementation already
* resolves DR 11 (items 1 and 2), but does not do the range-checking
* required by that DR's resolution. -pme
* The DR has since been changed: range-checking is a precondition
* (users' responsibility), and these functions must not throw. -pme
*/
reference
operator[](size_t __position)
{ return reference(*this, __position); }
_GLIBCXX_CONSTEXPR bool
operator[](size_t __position) const
{ return _Unchecked_test(__position); }
//@}
/**
* @brief Returns a numerical interpretation of the %bitset.
* @return The integral equivalent of the bits.
* @throw std::overflow_error If there are too many bits to be
* represented in an @c unsigned @c long.
*/
unsigned long
to_ulong() const
{ return this->_M_do_to_ulong(); }
#if __cplusplus >= 201103L
unsigned long long
to_ullong() const
{ return this->_M_do_to_ullong(); }
#endif
/**
* @brief Returns a character interpretation of the %bitset.
* @return The string equivalent of the bits.
*
* Note the ordering of the bits: decreasing character positions
* correspond to increasing bit positions (see the main class notes for
* an example).
*/
template<class _CharT, class _Traits, class _Alloc>
std::basic_string<_CharT, _Traits, _Alloc>
to_string() const
{
std::basic_string<_CharT, _Traits, _Alloc> __result;
_M_copy_to_string(__result, _CharT('0'), _CharT('1'));
return __result;
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 396. what are characters zero and one.
template<class _CharT, class _Traits, class _Alloc>
std::basic_string<_CharT, _Traits, _Alloc>
to_string(_CharT __zero, _CharT __one = _CharT('1')) const
{
std::basic_string<_CharT, _Traits, _Alloc> __result;
_M_copy_to_string(__result, __zero, __one);
return __result;
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 434. bitset::to_string() hard to use.
template<class _CharT, class _Traits>
std::basic_string<_CharT, _Traits, std::allocator<_CharT> >
to_string() const
{ return to_string<_CharT, _Traits, std::allocator<_CharT> >(); }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 853. to_string needs updating with zero and one.
template<class _CharT, class _Traits>
std::basic_string<_CharT, _Traits, std::allocator<_CharT> >
to_string(_CharT __zero, _CharT __one = _CharT('1')) const
{ return to_string<_CharT, _Traits,
std::allocator<_CharT> >(__zero, __one); }
template<class _CharT>
std::basic_string<_CharT, std::char_traits<_CharT>,
std::allocator<_CharT> >
to_string() const
{
return to_string<_CharT, std::char_traits<_CharT>,
std::allocator<_CharT> >();
}
template<class _CharT>
std::basic_string<_CharT, std::char_traits<_CharT>,
std::allocator<_CharT> >
to_string(_CharT __zero, _CharT __one = _CharT('1')) const
{
return to_string<_CharT, std::char_traits<_CharT>,
std::allocator<_CharT> >(__zero, __one);
}
std::basic_string<char, std::char_traits<char>, std::allocator<char> >
to_string() const
{
return to_string<char, std::char_traits<char>,
std::allocator<char> >();
}
std::basic_string<char, std::char_traits<char>, std::allocator<char> >
to_string(char __zero, char __one = '1') const
{
return to_string<char, std::char_traits<char>,
std::allocator<char> >(__zero, __one);
}
// Helper functions for string operations.
template<class _CharT, class _Traits>
void
_M_copy_from_ptr(const _CharT*, size_t, size_t, size_t,
_CharT, _CharT);
template<class _CharT, class _Traits, class _Alloc>
void
_M_copy_from_string(const std::basic_string<_CharT,
_Traits, _Alloc>& __s, size_t __pos, size_t __n,
_CharT __zero, _CharT __one)
{ _M_copy_from_ptr<_CharT, _Traits>(__s.data(), __s.size(), __pos, __n,
__zero, __one); }
template<class _CharT, class _Traits, class _Alloc>
void
_M_copy_to_string(std::basic_string<_CharT, _Traits, _Alloc>&,
_CharT, _CharT) const;
// NB: Backward compat.
template<class _CharT, class _Traits, class _Alloc>
void
_M_copy_from_string(const std::basic_string<_CharT,
_Traits, _Alloc>& __s, size_t __pos, size_t __n)
{ _M_copy_from_string(__s, __pos, __n, _CharT('0'), _CharT('1')); }
template<class _CharT, class _Traits, class _Alloc>
void
_M_copy_to_string(std::basic_string<_CharT, _Traits,_Alloc>& __s) const
{ _M_copy_to_string(__s, _CharT('0'), _CharT('1')); }
/// Returns the number of bits which are set.
size_t
count() const _GLIBCXX_NOEXCEPT
{ return this->_M_do_count(); }
/// Returns the total number of bits.
_GLIBCXX_CONSTEXPR size_t
size() const _GLIBCXX_NOEXCEPT
{ return _Nb; }
//@{
/// These comparisons for equality/inequality are, well, @e bitwise.
bool
operator==(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT
{ return this->_M_is_equal(__rhs); }
bool
operator!=(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT
{ return !this->_M_is_equal(__rhs); }
//@}
/**
* @brief Tests the value of a bit.
* @param __position The index of a bit.
* @return The value at @a pos.
* @throw std::out_of_range If @a pos is bigger the size of the %set.
*/
bool
test(size_t __position) const
{
this->_M_check(__position, __N("bitset::test"));
return _Unchecked_test(__position);
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 693. std::bitset::all() missing.
/**
* @brief Tests whether all the bits are on.
* @return True if all the bits are set.
*/
bool
all() const _GLIBCXX_NOEXCEPT
{ return this->template _M_are_all<_Nb>(); }
/**
* @brief Tests whether any of the bits are on.
* @return True if at least one bit is set.
*/
bool
any() const _GLIBCXX_NOEXCEPT
{ return this->_M_is_any(); }
/**
* @brief Tests whether any of the bits are on.
* @return True if none of the bits are set.
*/
bool
none() const _GLIBCXX_NOEXCEPT
{ return !this->_M_is_any(); }
//@{
/// Self-explanatory.
bitset<_Nb>
operator<<(size_t __position) const _GLIBCXX_NOEXCEPT
{ return bitset<_Nb>(*this) <<= __position; }
bitset<_Nb>
operator>>(size_t __position) const _GLIBCXX_NOEXCEPT
{ return bitset<_Nb>(*this) >>= __position; }
//@}
/**
* @brief Finds the index of the first "on" bit.
* @return The index of the first bit set, or size() if not found.
* @ingroup SGIextensions
* @sa _Find_next
*/
size_t
_Find_first() const _GLIBCXX_NOEXCEPT
{ return this->_M_do_find_first(_Nb); }
/**
* @brief Finds the index of the next "on" bit after prev.
* @return The index of the next bit set, or size() if not found.
* @param __prev Where to start searching.
* @ingroup SGIextensions
* @sa _Find_first
*/
size_t
_Find_next(size_t __prev) const _GLIBCXX_NOEXCEPT
{ return this->_M_do_find_next(__prev, _Nb); }
};
// Definitions of non-inline member functions.
template<size_t _Nb>
template<class _CharT, class _Traits>
void
bitset<_Nb>::
_M_copy_from_ptr(const _CharT* __s, size_t __len,
size_t __pos, size_t __n, _CharT __zero, _CharT __one)
{
reset();
const size_t __nbits = std::min(_Nb, std::min(__n, size_t(__len - __pos)));
for (size_t __i = __nbits; __i > 0; --__i)
{
const _CharT __c = __s[__pos + __nbits - __i];
if (_Traits::eq(__c, __zero))
;
else if (_Traits::eq(__c, __one))
_Unchecked_set(__i - 1);
else
__throw_invalid_argument(__N("bitset::_M_copy_from_ptr"));
}
}
template<size_t _Nb>
template<class _CharT, class _Traits, class _Alloc>
void
bitset<_Nb>::
_M_copy_to_string(std::basic_string<_CharT, _Traits, _Alloc>& __s,
_CharT __zero, _CharT __one) const
{
__s.assign(_Nb, __zero);
for (size_t __i = _Nb; __i > 0; --__i)
if (_Unchecked_test(__i - 1))
_Traits::assign(__s[_Nb - __i], __one);
}
// 23.3.5.3 bitset operations:
//@{
/**
* @brief Global bitwise operations on bitsets.
* @param __x A bitset.
* @param __y A bitset of the same size as @a __x.
* @return A new bitset.
*
* These should be self-explanatory.
*/
template<size_t _Nb>
inline bitset<_Nb>
operator&(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT
{
bitset<_Nb> __result(__x);
__result &= __y;
return __result;
}
template<size_t _Nb>
inline bitset<_Nb>
operator|(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT
{
bitset<_Nb> __result(__x);
__result |= __y;
return __result;
}
template <size_t _Nb>
inline bitset<_Nb>
operator^(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT
{
bitset<_Nb> __result(__x);
__result ^= __y;
return __result;
}
//@}
//@{
/**
* @brief Global I/O operators for bitsets.
*
* Direct I/O between streams and bitsets is supported. Output is
* straightforward. Input will skip whitespace, only accept @a 0 and @a 1
* characters, and will only extract as many digits as the %bitset will
* hold.
*/
template<class _CharT, class _Traits, size_t _Nb>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is, bitset<_Nb>& __x)
{
typedef typename _Traits::char_type char_type;
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
std::basic_string<_CharT, _Traits> __tmp;
__tmp.reserve(_Nb);
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 303. Bitset input operator underspecified
const char_type __zero = __is.widen('0');
const char_type __one = __is.widen('1');
typename __ios_base::iostate __state = __ios_base::goodbit;
typename __istream_type::sentry __sentry(__is);
if (__sentry)
{
__try
{
for (size_t __i = _Nb; __i > 0; --__i)
{
static typename _Traits::int_type __eof = _Traits::eof();
typename _Traits::int_type __c1 = __is.rdbuf()->sbumpc();
if (_Traits::eq_int_type(__c1, __eof))
{
__state |= __ios_base::eofbit;
break;
}
else
{
const char_type __c2 = _Traits::to_char_type(__c1);
if (_Traits::eq(__c2, __zero))
__tmp.push_back(__zero);
else if (_Traits::eq(__c2, __one))
__tmp.push_back(__one);
else if (_Traits::
eq_int_type(__is.rdbuf()->sputbackc(__c2),
__eof))
{
__state |= __ios_base::failbit;
break;
}
}
}
}
__catch(__cxxabiv1::__forced_unwind&)
{
__is._M_setstate(__ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ __is._M_setstate(__ios_base::badbit); }
}
if (__tmp.empty() && _Nb)
__state |= __ios_base::failbit;
else
__x._M_copy_from_string(__tmp, static_cast<size_t>(0), _Nb,
__zero, __one);
if (__state)
__is.setstate(__state);
return __is;
}
template <class _CharT, class _Traits, size_t _Nb>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const bitset<_Nb>& __x)
{
std::basic_string<_CharT, _Traits> __tmp;
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 396. what are characters zero and one.
const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__os.getloc());
__x._M_copy_to_string(__tmp, __ct.widen('0'), __ct.widen('1'));
return __os << __tmp;
}
//@}
_GLIBCXX_END_NAMESPACE_CONTAINER
} // namespace std
#undef _GLIBCXX_BITSET_WORDS
#undef _GLIBCXX_BITSET_BITS_PER_WORD
#undef _GLIBCXX_BITSET_BITS_PER_ULL
#if __cplusplus >= 201103L
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// DR 1182.
/// std::hash specialization for bitset.
template<size_t _Nb>
struct hash<_GLIBCXX_STD_C::bitset<_Nb>>
: public __hash_base<size_t, _GLIBCXX_STD_C::bitset<_Nb>>
{
size_t
operator()(const _GLIBCXX_STD_C::bitset<_Nb>& __b) const noexcept
{
const size_t __clength = (_Nb + __CHAR_BIT__ - 1) / __CHAR_BIT__;
return std::_Hash_impl::hash(__b._M_getdata(), __clength);
}
};
template<>
struct hash<_GLIBCXX_STD_C::bitset<0>>
: public __hash_base<size_t, _GLIBCXX_STD_C::bitset<0>>
{
size_t
operator()(const _GLIBCXX_STD_C::bitset<0>&) const noexcept
{ return 0; }
};
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif // C++11
#ifdef _GLIBCXX_DEBUG
# include <debug/bitset>
#endif
#ifdef _GLIBCXX_PROFILE
# include <profile/bitset>
#endif
#endif /* _GLIBCXX_BITSET */
c++/8/future 0000644 00000142766 15201526705 0006543 0 ustar 00 // <future> -*- C++ -*-
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/future
* This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_FUTURE
#define _GLIBCXX_FUTURE 1
#pragma GCC system_header
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
#include <mutex>
#include <thread>
#include <condition_variable>
#include <system_error>
#include <atomic>
#include <bits/atomic_futex.h>
#include <bits/functexcept.h>
#include <bits/invoke.h>
#include <bits/unique_ptr.h>
#include <bits/shared_ptr.h>
#include <bits/std_function.h>
#include <bits/uses_allocator.h>
#include <bits/allocated_ptr.h>
#include <ext/aligned_buffer.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @defgroup futures Futures
* @ingroup concurrency
*
* Classes for futures support.
* @{
*/
/// Error code for futures
enum class future_errc
{
future_already_retrieved = 1,
promise_already_satisfied,
no_state,
broken_promise
};
/// Specialization.
template<>
struct is_error_code_enum<future_errc> : public true_type { };
/// Points to a statically-allocated object derived from error_category.
const error_category&
future_category() noexcept;
/// Overload for make_error_code.
inline error_code
make_error_code(future_errc __errc) noexcept
{ return error_code(static_cast<int>(__errc), future_category()); }
/// Overload for make_error_condition.
inline error_condition
make_error_condition(future_errc __errc) noexcept
{ return error_condition(static_cast<int>(__errc), future_category()); }
/**
* @brief Exception type thrown by futures.
* @ingroup exceptions
*/
class future_error : public logic_error
{
public:
explicit
future_error(future_errc __errc)
: future_error(std::make_error_code(__errc))
{ }
virtual ~future_error() noexcept;
virtual const char*
what() const noexcept;
const error_code&
code() const noexcept { return _M_code; }
private:
explicit
future_error(error_code __ec)
: logic_error("std::future_error: " + __ec.message()), _M_code(__ec)
{ }
friend void __throw_future_error(int);
error_code _M_code;
};
// Forward declarations.
template<typename _Res>
class future;
template<typename _Res>
class shared_future;
template<typename _Signature>
class packaged_task;
template<typename _Res>
class promise;
/// Launch code for futures
enum class launch
{
async = 1,
deferred = 2
};
constexpr launch operator&(launch __x, launch __y)
{
return static_cast<launch>(
static_cast<int>(__x) & static_cast<int>(__y));
}
constexpr launch operator|(launch __x, launch __y)
{
return static_cast<launch>(
static_cast<int>(__x) | static_cast<int>(__y));
}
constexpr launch operator^(launch __x, launch __y)
{
return static_cast<launch>(
static_cast<int>(__x) ^ static_cast<int>(__y));
}
constexpr launch operator~(launch __x)
{ return static_cast<launch>(~static_cast<int>(__x)); }
inline launch& operator&=(launch& __x, launch __y)
{ return __x = __x & __y; }
inline launch& operator|=(launch& __x, launch __y)
{ return __x = __x | __y; }
inline launch& operator^=(launch& __x, launch __y)
{ return __x = __x ^ __y; }
/// Status code for futures
enum class future_status
{
ready,
timeout,
deferred
};
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2021. Further incorrect usages of result_of
template<typename _Fn, typename... _Args>
using __async_result_of = typename result_of<
typename decay<_Fn>::type(typename decay<_Args>::type...)>::type;
template<typename _Fn, typename... _Args>
future<__async_result_of<_Fn, _Args...>>
async(launch __policy, _Fn&& __fn, _Args&&... __args);
template<typename _Fn, typename... _Args>
future<__async_result_of<_Fn, _Args...>>
async(_Fn&& __fn, _Args&&... __args);
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
/// Base class and enclosing scope.
struct __future_base
{
/// Base class for results.
struct _Result_base
{
exception_ptr _M_error;
_Result_base(const _Result_base&) = delete;
_Result_base& operator=(const _Result_base&) = delete;
// _M_destroy() allows derived classes to control deallocation
virtual void _M_destroy() = 0;
struct _Deleter
{
void operator()(_Result_base* __fr) const { __fr->_M_destroy(); }
};
protected:
_Result_base();
virtual ~_Result_base();
};
/// A unique_ptr for result objects.
template<typename _Res>
using _Ptr = unique_ptr<_Res, _Result_base::_Deleter>;
/// A result object that has storage for an object of type _Res.
template<typename _Res>
struct _Result : _Result_base
{
private:
__gnu_cxx::__aligned_buffer<_Res> _M_storage;
bool _M_initialized;
public:
typedef _Res result_type;
_Result() noexcept : _M_initialized() { }
~_Result()
{
if (_M_initialized)
_M_value().~_Res();
}
// Return lvalue, future will add const or rvalue-reference
_Res&
_M_value() noexcept { return *_M_storage._M_ptr(); }
void
_M_set(const _Res& __res)
{
::new (_M_storage._M_addr()) _Res(__res);
_M_initialized = true;
}
void
_M_set(_Res&& __res)
{
::new (_M_storage._M_addr()) _Res(std::move(__res));
_M_initialized = true;
}
private:
void _M_destroy() { delete this; }
};
/// A result object that uses an allocator.
template<typename _Res, typename _Alloc>
struct _Result_alloc final : _Result<_Res>, _Alloc
{
using __allocator_type = __alloc_rebind<_Alloc, _Result_alloc>;
explicit
_Result_alloc(const _Alloc& __a) : _Result<_Res>(), _Alloc(__a)
{ }
private:
void _M_destroy()
{
__allocator_type __a(*this);
__allocated_ptr<__allocator_type> __guard_ptr{ __a, this };
this->~_Result_alloc();
}
};
// Create a result object that uses an allocator.
template<typename _Res, typename _Allocator>
static _Ptr<_Result_alloc<_Res, _Allocator>>
_S_allocate_result(const _Allocator& __a)
{
using __result_type = _Result_alloc<_Res, _Allocator>;
typename __result_type::__allocator_type __a2(__a);
auto __guard = std::__allocate_guarded(__a2);
__result_type* __p = ::new((void*)__guard.get()) __result_type{__a};
__guard = nullptr;
return _Ptr<__result_type>(__p);
}
// Keep it simple for std::allocator.
template<typename _Res, typename _Tp>
static _Ptr<_Result<_Res>>
_S_allocate_result(const std::allocator<_Tp>& __a)
{
return _Ptr<_Result<_Res>>(new _Result<_Res>);
}
// Base class for various types of shared state created by an
// asynchronous provider (such as a std::promise) and shared with one
// or more associated futures.
class _State_baseV2
{
typedef _Ptr<_Result_base> _Ptr_type;
enum _Status : unsigned {
__not_ready,
__ready
};
_Ptr_type _M_result;
__atomic_futex_unsigned<> _M_status;
atomic_flag _M_retrieved = ATOMIC_FLAG_INIT;
once_flag _M_once;
public:
_State_baseV2() noexcept : _M_result(), _M_status(_Status::__not_ready)
{ }
_State_baseV2(const _State_baseV2&) = delete;
_State_baseV2& operator=(const _State_baseV2&) = delete;
virtual ~_State_baseV2() = default;
_Result_base&
wait()
{
// Run any deferred function or join any asynchronous thread:
_M_complete_async();
// Acquire MO makes sure this synchronizes with the thread that made
// the future ready.
_M_status._M_load_when_equal(_Status::__ready, memory_order_acquire);
return *_M_result;
}
template<typename _Rep, typename _Period>
future_status
wait_for(const chrono::duration<_Rep, _Period>& __rel)
{
// First, check if the future has been made ready. Use acquire MO
// to synchronize with the thread that made it ready.
if (_M_status._M_load(memory_order_acquire) == _Status::__ready)
return future_status::ready;
if (_M_is_deferred_future())
return future_status::deferred;
if (_M_status._M_load_when_equal_for(_Status::__ready,
memory_order_acquire, __rel))
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2100. timed waiting functions must also join
// This call is a no-op by default except on an async future,
// in which case the async thread is joined. It's also not a
// no-op for a deferred future, but such a future will never
// reach this point because it returns future_status::deferred
// instead of waiting for the future to become ready (see
// above). Async futures synchronize in this call, so we need
// no further synchronization here.
_M_complete_async();
return future_status::ready;
}
return future_status::timeout;
}
template<typename _Clock, typename _Duration>
future_status
wait_until(const chrono::time_point<_Clock, _Duration>& __abs)
{
// First, check if the future has been made ready. Use acquire MO
// to synchronize with the thread that made it ready.
if (_M_status._M_load(memory_order_acquire) == _Status::__ready)
return future_status::ready;
if (_M_is_deferred_future())
return future_status::deferred;
if (_M_status._M_load_when_equal_until(_Status::__ready,
memory_order_acquire, __abs))
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2100. timed waiting functions must also join
// See wait_for(...) above.
_M_complete_async();
return future_status::ready;
}
return future_status::timeout;
}
// Provide a result to the shared state and make it ready.
// Calls at most once: _M_result = __res();
void
_M_set_result(function<_Ptr_type()> __res, bool __ignore_failure = false)
{
bool __did_set = false;
// all calls to this function are serialized,
// side-effects of invoking __res only happen once
call_once(_M_once, &_State_baseV2::_M_do_set, this,
std::__addressof(__res), std::__addressof(__did_set));
if (__did_set)
// Use release MO to synchronize with observers of the ready state.
_M_status._M_store_notify_all(_Status::__ready,
memory_order_release);
else if (!__ignore_failure)
__throw_future_error(int(future_errc::promise_already_satisfied));
}
// Provide a result to the shared state but delay making it ready
// until the calling thread exits.
// Calls at most once: _M_result = __res();
void
_M_set_delayed_result(function<_Ptr_type()> __res,
weak_ptr<_State_baseV2> __self)
{
bool __did_set = false;
unique_ptr<_Make_ready> __mr{new _Make_ready};
// all calls to this function are serialized,
// side-effects of invoking __res only happen once
call_once(_M_once, &_State_baseV2::_M_do_set, this,
std::__addressof(__res), std::__addressof(__did_set));
if (!__did_set)
__throw_future_error(int(future_errc::promise_already_satisfied));
__mr->_M_shared_state = std::move(__self);
__mr->_M_set();
__mr.release();
}
// Abandon this shared state.
void
_M_break_promise(_Ptr_type __res)
{
if (static_cast<bool>(__res))
{
__res->_M_error =
make_exception_ptr(future_error(future_errc::broken_promise));
// This function is only called when the last asynchronous result
// provider is abandoning this shared state, so noone can be
// trying to make the shared state ready at the same time, and
// we can access _M_result directly instead of through call_once.
_M_result.swap(__res);
// Use release MO to synchronize with observers of the ready state.
_M_status._M_store_notify_all(_Status::__ready,
memory_order_release);
}
}
// Called when this object is first passed to a future.
void
_M_set_retrieved_flag()
{
if (_M_retrieved.test_and_set())
__throw_future_error(int(future_errc::future_already_retrieved));
}
template<typename _Res, typename _Arg>
struct _Setter;
// set lvalues
template<typename _Res, typename _Arg>
struct _Setter<_Res, _Arg&>
{
// check this is only used by promise<R>::set_value(const R&)
// or promise<R&>::set_value(R&)
static_assert(is_same<_Res, _Arg&>::value // promise<R&>
|| is_same<const _Res, _Arg>::value, // promise<R>
"Invalid specialisation");
// Used by std::promise to copy construct the result.
typename promise<_Res>::_Ptr_type operator()() const
{
_M_promise->_M_storage->_M_set(*_M_arg);
return std::move(_M_promise->_M_storage);
}
promise<_Res>* _M_promise;
_Arg* _M_arg;
};
// set rvalues
template<typename _Res>
struct _Setter<_Res, _Res&&>
{
// Used by std::promise to move construct the result.
typename promise<_Res>::_Ptr_type operator()() const
{
_M_promise->_M_storage->_M_set(std::move(*_M_arg));
return std::move(_M_promise->_M_storage);
}
promise<_Res>* _M_promise;
_Res* _M_arg;
};
// set void
template<typename _Res>
struct _Setter<_Res, void>
{
static_assert(is_void<_Res>::value, "Only used for promise<void>");
typename promise<_Res>::_Ptr_type operator()() const
{ return std::move(_M_promise->_M_storage); }
promise<_Res>* _M_promise;
};
struct __exception_ptr_tag { };
// set exceptions
template<typename _Res>
struct _Setter<_Res, __exception_ptr_tag>
{
// Used by std::promise to store an exception as the result.
typename promise<_Res>::_Ptr_type operator()() const
{
_M_promise->_M_storage->_M_error = *_M_ex;
return std::move(_M_promise->_M_storage);
}
promise<_Res>* _M_promise;
exception_ptr* _M_ex;
};
template<typename _Res, typename _Arg>
static _Setter<_Res, _Arg&&>
__setter(promise<_Res>* __prom, _Arg&& __arg)
{
_S_check(__prom->_M_future);
return _Setter<_Res, _Arg&&>{ __prom, std::__addressof(__arg) };
}
template<typename _Res>
static _Setter<_Res, __exception_ptr_tag>
__setter(exception_ptr& __ex, promise<_Res>* __prom)
{
_S_check(__prom->_M_future);
return _Setter<_Res, __exception_ptr_tag>{ __prom, &__ex };
}
template<typename _Res>
static _Setter<_Res, void>
__setter(promise<_Res>* __prom)
{
_S_check(__prom->_M_future);
return _Setter<_Res, void>{ __prom };
}
template<typename _Tp>
static void
_S_check(const shared_ptr<_Tp>& __p)
{
if (!static_cast<bool>(__p))
__throw_future_error((int)future_errc::no_state);
}
private:
// The function invoked with std::call_once(_M_once, ...).
void
_M_do_set(function<_Ptr_type()>* __f, bool* __did_set)
{
_Ptr_type __res = (*__f)();
// Notify the caller that we did try to set; if we do not throw an
// exception, the caller will be aware that it did set (e.g., see
// _M_set_result).
*__did_set = true;
_M_result.swap(__res); // nothrow
}
// Wait for completion of async function.
virtual void _M_complete_async() { }
// Return true if state corresponds to a deferred function.
virtual bool _M_is_deferred_future() const { return false; }
struct _Make_ready final : __at_thread_exit_elt
{
weak_ptr<_State_baseV2> _M_shared_state;
static void _S_run(void*);
void _M_set();
};
};
#ifdef _GLIBCXX_ASYNC_ABI_COMPAT
class _State_base;
class _Async_state_common;
#else
using _State_base = _State_baseV2;
class _Async_state_commonV2;
#endif
template<typename _BoundFn,
typename _Res = decltype(std::declval<_BoundFn&>()())>
class _Deferred_state;
template<typename _BoundFn,
typename _Res = decltype(std::declval<_BoundFn&>()())>
class _Async_state_impl;
template<typename _Signature>
class _Task_state_base;
template<typename _Fn, typename _Alloc, typename _Signature>
class _Task_state;
template<typename _BoundFn>
static std::shared_ptr<_State_base>
_S_make_deferred_state(_BoundFn&& __fn);
template<typename _BoundFn>
static std::shared_ptr<_State_base>
_S_make_async_state(_BoundFn&& __fn);
template<typename _Res_ptr, typename _Fn,
typename _Res = typename _Res_ptr::element_type::result_type>
struct _Task_setter;
template<typename _Res_ptr, typename _BoundFn>
static _Task_setter<_Res_ptr, _BoundFn>
_S_task_setter(_Res_ptr& __ptr, _BoundFn& __call)
{
return { std::__addressof(__ptr), std::__addressof(__call) };
}
};
/// Partial specialization for reference types.
template<typename _Res>
struct __future_base::_Result<_Res&> : __future_base::_Result_base
{
typedef _Res& result_type;
_Result() noexcept : _M_value_ptr() { }
void
_M_set(_Res& __res) noexcept
{ _M_value_ptr = std::addressof(__res); }
_Res& _M_get() noexcept { return *_M_value_ptr; }
private:
_Res* _M_value_ptr;
void _M_destroy() { delete this; }
};
/// Explicit specialization for void.
template<>
struct __future_base::_Result<void> : __future_base::_Result_base
{
typedef void result_type;
private:
void _M_destroy() { delete this; }
};
#ifndef _GLIBCXX_ASYNC_ABI_COMPAT
// Allow _Setter objects to be stored locally in std::function
template<typename _Res, typename _Arg>
struct __is_location_invariant
<__future_base::_State_base::_Setter<_Res, _Arg>>
: true_type { };
// Allow _Task_setter objects to be stored locally in std::function
template<typename _Res_ptr, typename _Fn, typename _Res>
struct __is_location_invariant
<__future_base::_Task_setter<_Res_ptr, _Fn, _Res>>
: true_type { };
/// Common implementation for future and shared_future.
template<typename _Res>
class __basic_future : public __future_base
{
protected:
typedef shared_ptr<_State_base> __state_type;
typedef __future_base::_Result<_Res>& __result_type;
private:
__state_type _M_state;
public:
// Disable copying.
__basic_future(const __basic_future&) = delete;
__basic_future& operator=(const __basic_future&) = delete;
bool
valid() const noexcept { return static_cast<bool>(_M_state); }
void
wait() const
{
_State_base::_S_check(_M_state);
_M_state->wait();
}
template<typename _Rep, typename _Period>
future_status
wait_for(const chrono::duration<_Rep, _Period>& __rel) const
{
_State_base::_S_check(_M_state);
return _M_state->wait_for(__rel);
}
template<typename _Clock, typename _Duration>
future_status
wait_until(const chrono::time_point<_Clock, _Duration>& __abs) const
{
_State_base::_S_check(_M_state);
return _M_state->wait_until(__abs);
}
protected:
/// Wait for the state to be ready and rethrow any stored exception
__result_type
_M_get_result() const
{
_State_base::_S_check(_M_state);
_Result_base& __res = _M_state->wait();
if (!(__res._M_error == 0))
rethrow_exception(__res._M_error);
return static_cast<__result_type>(__res);
}
void _M_swap(__basic_future& __that) noexcept
{
_M_state.swap(__that._M_state);
}
// Construction of a future by promise::get_future()
explicit
__basic_future(const __state_type& __state) : _M_state(__state)
{
_State_base::_S_check(_M_state);
_M_state->_M_set_retrieved_flag();
}
// Copy construction from a shared_future
explicit
__basic_future(const shared_future<_Res>&) noexcept;
// Move construction from a shared_future
explicit
__basic_future(shared_future<_Res>&&) noexcept;
// Move construction from a future
explicit
__basic_future(future<_Res>&&) noexcept;
constexpr __basic_future() noexcept : _M_state() { }
struct _Reset
{
explicit _Reset(__basic_future& __fut) noexcept : _M_fut(__fut) { }
~_Reset() { _M_fut._M_state.reset(); }
__basic_future& _M_fut;
};
};
/// Primary template for future.
template<typename _Res>
class future : public __basic_future<_Res>
{
friend class promise<_Res>;
template<typename> friend class packaged_task;
template<typename _Fn, typename... _Args>
friend future<__async_result_of<_Fn, _Args...>>
async(launch, _Fn&&, _Args&&...);
typedef __basic_future<_Res> _Base_type;
typedef typename _Base_type::__state_type __state_type;
explicit
future(const __state_type& __state) : _Base_type(__state) { }
public:
constexpr future() noexcept : _Base_type() { }
/// Move constructor
future(future&& __uf) noexcept : _Base_type(std::move(__uf)) { }
// Disable copying
future(const future&) = delete;
future& operator=(const future&) = delete;
future& operator=(future&& __fut) noexcept
{
future(std::move(__fut))._M_swap(*this);
return *this;
}
/// Retrieving the value
_Res
get()
{
typename _Base_type::_Reset __reset(*this);
return std::move(this->_M_get_result()._M_value());
}
shared_future<_Res> share() noexcept;
};
/// Partial specialization for future<R&>
template<typename _Res>
class future<_Res&> : public __basic_future<_Res&>
{
friend class promise<_Res&>;
template<typename> friend class packaged_task;
template<typename _Fn, typename... _Args>
friend future<__async_result_of<_Fn, _Args...>>
async(launch, _Fn&&, _Args&&...);
typedef __basic_future<_Res&> _Base_type;
typedef typename _Base_type::__state_type __state_type;
explicit
future(const __state_type& __state) : _Base_type(__state) { }
public:
constexpr future() noexcept : _Base_type() { }
/// Move constructor
future(future&& __uf) noexcept : _Base_type(std::move(__uf)) { }
// Disable copying
future(const future&) = delete;
future& operator=(const future&) = delete;
future& operator=(future&& __fut) noexcept
{
future(std::move(__fut))._M_swap(*this);
return *this;
}
/// Retrieving the value
_Res&
get()
{
typename _Base_type::_Reset __reset(*this);
return this->_M_get_result()._M_get();
}
shared_future<_Res&> share() noexcept;
};
/// Explicit specialization for future<void>
template<>
class future<void> : public __basic_future<void>
{
friend class promise<void>;
template<typename> friend class packaged_task;
template<typename _Fn, typename... _Args>
friend future<__async_result_of<_Fn, _Args...>>
async(launch, _Fn&&, _Args&&...);
typedef __basic_future<void> _Base_type;
typedef typename _Base_type::__state_type __state_type;
explicit
future(const __state_type& __state) : _Base_type(__state) { }
public:
constexpr future() noexcept : _Base_type() { }
/// Move constructor
future(future&& __uf) noexcept : _Base_type(std::move(__uf)) { }
// Disable copying
future(const future&) = delete;
future& operator=(const future&) = delete;
future& operator=(future&& __fut) noexcept
{
future(std::move(__fut))._M_swap(*this);
return *this;
}
/// Retrieving the value
void
get()
{
typename _Base_type::_Reset __reset(*this);
this->_M_get_result();
}
shared_future<void> share() noexcept;
};
/// Primary template for shared_future.
template<typename _Res>
class shared_future : public __basic_future<_Res>
{
typedef __basic_future<_Res> _Base_type;
public:
constexpr shared_future() noexcept : _Base_type() { }
/// Copy constructor
shared_future(const shared_future& __sf) noexcept : _Base_type(__sf) { }
/// Construct from a future rvalue
shared_future(future<_Res>&& __uf) noexcept
: _Base_type(std::move(__uf))
{ }
/// Construct from a shared_future rvalue
shared_future(shared_future&& __sf) noexcept
: _Base_type(std::move(__sf))
{ }
shared_future& operator=(const shared_future& __sf) noexcept
{
shared_future(__sf)._M_swap(*this);
return *this;
}
shared_future& operator=(shared_future&& __sf) noexcept
{
shared_future(std::move(__sf))._M_swap(*this);
return *this;
}
/// Retrieving the value
const _Res&
get() const { return this->_M_get_result()._M_value(); }
};
/// Partial specialization for shared_future<R&>
template<typename _Res>
class shared_future<_Res&> : public __basic_future<_Res&>
{
typedef __basic_future<_Res&> _Base_type;
public:
constexpr shared_future() noexcept : _Base_type() { }
/// Copy constructor
shared_future(const shared_future& __sf) : _Base_type(__sf) { }
/// Construct from a future rvalue
shared_future(future<_Res&>&& __uf) noexcept
: _Base_type(std::move(__uf))
{ }
/// Construct from a shared_future rvalue
shared_future(shared_future&& __sf) noexcept
: _Base_type(std::move(__sf))
{ }
shared_future& operator=(const shared_future& __sf)
{
shared_future(__sf)._M_swap(*this);
return *this;
}
shared_future& operator=(shared_future&& __sf) noexcept
{
shared_future(std::move(__sf))._M_swap(*this);
return *this;
}
/// Retrieving the value
_Res&
get() const { return this->_M_get_result()._M_get(); }
};
/// Explicit specialization for shared_future<void>
template<>
class shared_future<void> : public __basic_future<void>
{
typedef __basic_future<void> _Base_type;
public:
constexpr shared_future() noexcept : _Base_type() { }
/// Copy constructor
shared_future(const shared_future& __sf) : _Base_type(__sf) { }
/// Construct from a future rvalue
shared_future(future<void>&& __uf) noexcept
: _Base_type(std::move(__uf))
{ }
/// Construct from a shared_future rvalue
shared_future(shared_future&& __sf) noexcept
: _Base_type(std::move(__sf))
{ }
shared_future& operator=(const shared_future& __sf)
{
shared_future(__sf)._M_swap(*this);
return *this;
}
shared_future& operator=(shared_future&& __sf) noexcept
{
shared_future(std::move(__sf))._M_swap(*this);
return *this;
}
// Retrieving the value
void
get() const { this->_M_get_result(); }
};
// Now we can define the protected __basic_future constructors.
template<typename _Res>
inline __basic_future<_Res>::
__basic_future(const shared_future<_Res>& __sf) noexcept
: _M_state(__sf._M_state)
{ }
template<typename _Res>
inline __basic_future<_Res>::
__basic_future(shared_future<_Res>&& __sf) noexcept
: _M_state(std::move(__sf._M_state))
{ }
template<typename _Res>
inline __basic_future<_Res>::
__basic_future(future<_Res>&& __uf) noexcept
: _M_state(std::move(__uf._M_state))
{ }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2556. Wide contract for future::share()
template<typename _Res>
inline shared_future<_Res>
future<_Res>::share() noexcept
{ return shared_future<_Res>(std::move(*this)); }
template<typename _Res>
inline shared_future<_Res&>
future<_Res&>::share() noexcept
{ return shared_future<_Res&>(std::move(*this)); }
inline shared_future<void>
future<void>::share() noexcept
{ return shared_future<void>(std::move(*this)); }
/// Primary template for promise
template<typename _Res>
class promise
{
typedef __future_base::_State_base _State;
typedef __future_base::_Result<_Res> _Res_type;
typedef __future_base::_Ptr<_Res_type> _Ptr_type;
template<typename, typename> friend class _State::_Setter;
friend _State;
shared_ptr<_State> _M_future;
_Ptr_type _M_storage;
public:
promise()
: _M_future(std::make_shared<_State>()),
_M_storage(new _Res_type())
{ }
promise(promise&& __rhs) noexcept
: _M_future(std::move(__rhs._M_future)),
_M_storage(std::move(__rhs._M_storage))
{ }
template<typename _Allocator>
promise(allocator_arg_t, const _Allocator& __a)
: _M_future(std::allocate_shared<_State>(__a)),
_M_storage(__future_base::_S_allocate_result<_Res>(__a))
{ }
template<typename _Allocator>
promise(allocator_arg_t, const _Allocator&, promise&& __rhs)
: _M_future(std::move(__rhs._M_future)),
_M_storage(std::move(__rhs._M_storage))
{ }
promise(const promise&) = delete;
~promise()
{
if (static_cast<bool>(_M_future) && !_M_future.unique())
_M_future->_M_break_promise(std::move(_M_storage));
}
// Assignment
promise&
operator=(promise&& __rhs) noexcept
{
promise(std::move(__rhs)).swap(*this);
return *this;
}
promise& operator=(const promise&) = delete;
void
swap(promise& __rhs) noexcept
{
_M_future.swap(__rhs._M_future);
_M_storage.swap(__rhs._M_storage);
}
// Retrieving the result
future<_Res>
get_future()
{ return future<_Res>(_M_future); }
// Setting the result
void
set_value(const _Res& __r)
{ _M_future->_M_set_result(_State::__setter(this, __r)); }
void
set_value(_Res&& __r)
{ _M_future->_M_set_result(_State::__setter(this, std::move(__r))); }
void
set_exception(exception_ptr __p)
{ _M_future->_M_set_result(_State::__setter(__p, this)); }
void
set_value_at_thread_exit(const _Res& __r)
{
_M_future->_M_set_delayed_result(_State::__setter(this, __r),
_M_future);
}
void
set_value_at_thread_exit(_Res&& __r)
{
_M_future->_M_set_delayed_result(
_State::__setter(this, std::move(__r)), _M_future);
}
void
set_exception_at_thread_exit(exception_ptr __p)
{
_M_future->_M_set_delayed_result(_State::__setter(__p, this),
_M_future);
}
};
template<typename _Res>
inline void
swap(promise<_Res>& __x, promise<_Res>& __y) noexcept
{ __x.swap(__y); }
template<typename _Res, typename _Alloc>
struct uses_allocator<promise<_Res>, _Alloc>
: public true_type { };
/// Partial specialization for promise<R&>
template<typename _Res>
class promise<_Res&>
{
typedef __future_base::_State_base _State;
typedef __future_base::_Result<_Res&> _Res_type;
typedef __future_base::_Ptr<_Res_type> _Ptr_type;
template<typename, typename> friend class _State::_Setter;
friend _State;
shared_ptr<_State> _M_future;
_Ptr_type _M_storage;
public:
promise()
: _M_future(std::make_shared<_State>()),
_M_storage(new _Res_type())
{ }
promise(promise&& __rhs) noexcept
: _M_future(std::move(__rhs._M_future)),
_M_storage(std::move(__rhs._M_storage))
{ }
template<typename _Allocator>
promise(allocator_arg_t, const _Allocator& __a)
: _M_future(std::allocate_shared<_State>(__a)),
_M_storage(__future_base::_S_allocate_result<_Res&>(__a))
{ }
template<typename _Allocator>
promise(allocator_arg_t, const _Allocator&, promise&& __rhs)
: _M_future(std::move(__rhs._M_future)),
_M_storage(std::move(__rhs._M_storage))
{ }
promise(const promise&) = delete;
~promise()
{
if (static_cast<bool>(_M_future) && !_M_future.unique())
_M_future->_M_break_promise(std::move(_M_storage));
}
// Assignment
promise&
operator=(promise&& __rhs) noexcept
{
promise(std::move(__rhs)).swap(*this);
return *this;
}
promise& operator=(const promise&) = delete;
void
swap(promise& __rhs) noexcept
{
_M_future.swap(__rhs._M_future);
_M_storage.swap(__rhs._M_storage);
}
// Retrieving the result
future<_Res&>
get_future()
{ return future<_Res&>(_M_future); }
// Setting the result
void
set_value(_Res& __r)
{ _M_future->_M_set_result(_State::__setter(this, __r)); }
void
set_exception(exception_ptr __p)
{ _M_future->_M_set_result(_State::__setter(__p, this)); }
void
set_value_at_thread_exit(_Res& __r)
{
_M_future->_M_set_delayed_result(_State::__setter(this, __r),
_M_future);
}
void
set_exception_at_thread_exit(exception_ptr __p)
{
_M_future->_M_set_delayed_result(_State::__setter(__p, this),
_M_future);
}
};
/// Explicit specialization for promise<void>
template<>
class promise<void>
{
typedef __future_base::_State_base _State;
typedef __future_base::_Result<void> _Res_type;
typedef __future_base::_Ptr<_Res_type> _Ptr_type;
template<typename, typename> friend class _State::_Setter;
friend _State;
shared_ptr<_State> _M_future;
_Ptr_type _M_storage;
public:
promise()
: _M_future(std::make_shared<_State>()),
_M_storage(new _Res_type())
{ }
promise(promise&& __rhs) noexcept
: _M_future(std::move(__rhs._M_future)),
_M_storage(std::move(__rhs._M_storage))
{ }
template<typename _Allocator>
promise(allocator_arg_t, const _Allocator& __a)
: _M_future(std::allocate_shared<_State>(__a)),
_M_storage(__future_base::_S_allocate_result<void>(__a))
{ }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2095. missing constructors needed for uses-allocator construction
template<typename _Allocator>
promise(allocator_arg_t, const _Allocator&, promise&& __rhs)
: _M_future(std::move(__rhs._M_future)),
_M_storage(std::move(__rhs._M_storage))
{ }
promise(const promise&) = delete;
~promise()
{
if (static_cast<bool>(_M_future) && !_M_future.unique())
_M_future->_M_break_promise(std::move(_M_storage));
}
// Assignment
promise&
operator=(promise&& __rhs) noexcept
{
promise(std::move(__rhs)).swap(*this);
return *this;
}
promise& operator=(const promise&) = delete;
void
swap(promise& __rhs) noexcept
{
_M_future.swap(__rhs._M_future);
_M_storage.swap(__rhs._M_storage);
}
// Retrieving the result
future<void>
get_future()
{ return future<void>(_M_future); }
// Setting the result
void
set_value()
{ _M_future->_M_set_result(_State::__setter(this)); }
void
set_exception(exception_ptr __p)
{ _M_future->_M_set_result(_State::__setter(__p, this)); }
void
set_value_at_thread_exit()
{ _M_future->_M_set_delayed_result(_State::__setter(this), _M_future); }
void
set_exception_at_thread_exit(exception_ptr __p)
{
_M_future->_M_set_delayed_result(_State::__setter(__p, this),
_M_future);
}
};
template<typename _Ptr_type, typename _Fn, typename _Res>
struct __future_base::_Task_setter
{
// Invoke the function and provide the result to the caller.
_Ptr_type operator()() const
{
__try
{
(*_M_result)->_M_set((*_M_fn)());
}
__catch(const __cxxabiv1::__forced_unwind&)
{
__throw_exception_again; // will cause broken_promise
}
__catch(...)
{
(*_M_result)->_M_error = current_exception();
}
return std::move(*_M_result);
}
_Ptr_type* _M_result;
_Fn* _M_fn;
};
template<typename _Ptr_type, typename _Fn>
struct __future_base::_Task_setter<_Ptr_type, _Fn, void>
{
_Ptr_type operator()() const
{
__try
{
(*_M_fn)();
}
__catch(const __cxxabiv1::__forced_unwind&)
{
__throw_exception_again; // will cause broken_promise
}
__catch(...)
{
(*_M_result)->_M_error = current_exception();
}
return std::move(*_M_result);
}
_Ptr_type* _M_result;
_Fn* _M_fn;
};
// Holds storage for a packaged_task's result.
template<typename _Res, typename... _Args>
struct __future_base::_Task_state_base<_Res(_Args...)>
: __future_base::_State_base
{
typedef _Res _Res_type;
template<typename _Alloc>
_Task_state_base(const _Alloc& __a)
: _M_result(_S_allocate_result<_Res>(__a))
{ }
// Invoke the stored task and make the state ready.
virtual void
_M_run(_Args&&... __args) = 0;
// Invoke the stored task and make the state ready at thread exit.
virtual void
_M_run_delayed(_Args&&... __args, weak_ptr<_State_base>) = 0;
virtual shared_ptr<_Task_state_base>
_M_reset() = 0;
typedef __future_base::_Ptr<_Result<_Res>> _Ptr_type;
_Ptr_type _M_result;
};
// Holds a packaged_task's stored task.
template<typename _Fn, typename _Alloc, typename _Res, typename... _Args>
struct __future_base::_Task_state<_Fn, _Alloc, _Res(_Args...)> final
: __future_base::_Task_state_base<_Res(_Args...)>
{
template<typename _Fn2>
_Task_state(_Fn2&& __fn, const _Alloc& __a)
: _Task_state_base<_Res(_Args...)>(__a),
_M_impl(std::forward<_Fn2>(__fn), __a)
{ }
private:
virtual void
_M_run(_Args&&... __args)
{
auto __boundfn = [&] () -> typename result_of<_Fn&(_Args&&...)>::type {
return std::__invoke(_M_impl._M_fn, std::forward<_Args>(__args)...);
};
this->_M_set_result(_S_task_setter(this->_M_result, __boundfn));
}
virtual void
_M_run_delayed(_Args&&... __args, weak_ptr<_State_base> __self)
{
auto __boundfn = [&] () -> typename result_of<_Fn&(_Args&&...)>::type {
return std::__invoke(_M_impl._M_fn, std::forward<_Args>(__args)...);
};
this->_M_set_delayed_result(_S_task_setter(this->_M_result, __boundfn),
std::move(__self));
}
virtual shared_ptr<_Task_state_base<_Res(_Args...)>>
_M_reset();
struct _Impl : _Alloc
{
template<typename _Fn2>
_Impl(_Fn2&& __fn, const _Alloc& __a)
: _Alloc(__a), _M_fn(std::forward<_Fn2>(__fn)) { }
_Fn _M_fn;
} _M_impl;
};
template<typename _Signature, typename _Fn, typename _Alloc>
static shared_ptr<__future_base::_Task_state_base<_Signature>>
__create_task_state(_Fn&& __fn, const _Alloc& __a)
{
typedef typename decay<_Fn>::type _Fn2;
typedef __future_base::_Task_state<_Fn2, _Alloc, _Signature> _State;
return std::allocate_shared<_State>(__a, std::forward<_Fn>(__fn), __a);
}
template<typename _Fn, typename _Alloc, typename _Res, typename... _Args>
shared_ptr<__future_base::_Task_state_base<_Res(_Args...)>>
__future_base::_Task_state<_Fn, _Alloc, _Res(_Args...)>::_M_reset()
{
return __create_task_state<_Res(_Args...)>(std::move(_M_impl._M_fn),
static_cast<_Alloc&>(_M_impl));
}
template<typename _Task, typename _Fn, bool
= is_same<_Task, typename decay<_Fn>::type>::value>
struct __constrain_pkgdtask
{ typedef void __type; };
template<typename _Task, typename _Fn>
struct __constrain_pkgdtask<_Task, _Fn, true>
{ };
/// packaged_task
template<typename _Res, typename... _ArgTypes>
class packaged_task<_Res(_ArgTypes...)>
{
typedef __future_base::_Task_state_base<_Res(_ArgTypes...)> _State_type;
shared_ptr<_State_type> _M_state;
public:
// Construction and destruction
packaged_task() noexcept { }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2095. missing constructors needed for uses-allocator construction
template<typename _Allocator>
packaged_task(allocator_arg_t, const _Allocator& __a) noexcept
{ }
template<typename _Fn, typename = typename
__constrain_pkgdtask<packaged_task, _Fn>::__type>
explicit
packaged_task(_Fn&& __fn)
: packaged_task(allocator_arg, std::allocator<int>(),
std::forward<_Fn>(__fn))
{ }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2097. packaged_task constructors should be constrained
// 2407. [this constructor should not be] explicit
template<typename _Fn, typename _Alloc, typename = typename
__constrain_pkgdtask<packaged_task, _Fn>::__type>
packaged_task(allocator_arg_t, const _Alloc& __a, _Fn&& __fn)
: _M_state(__create_task_state<_Res(_ArgTypes...)>(
std::forward<_Fn>(__fn), __a))
{ }
~packaged_task()
{
if (static_cast<bool>(_M_state) && !_M_state.unique())
_M_state->_M_break_promise(std::move(_M_state->_M_result));
}
// No copy
packaged_task(const packaged_task&) = delete;
packaged_task& operator=(const packaged_task&) = delete;
template<typename _Allocator>
packaged_task(allocator_arg_t, const _Allocator&,
const packaged_task&) = delete;
// Move support
packaged_task(packaged_task&& __other) noexcept
{ this->swap(__other); }
template<typename _Allocator>
packaged_task(allocator_arg_t, const _Allocator&,
packaged_task&& __other) noexcept
{ this->swap(__other); }
packaged_task& operator=(packaged_task&& __other) noexcept
{
packaged_task(std::move(__other)).swap(*this);
return *this;
}
void
swap(packaged_task& __other) noexcept
{ _M_state.swap(__other._M_state); }
bool
valid() const noexcept
{ return static_cast<bool>(_M_state); }
// Result retrieval
future<_Res>
get_future()
{ return future<_Res>(_M_state); }
// Execution
void
operator()(_ArgTypes... __args)
{
__future_base::_State_base::_S_check(_M_state);
_M_state->_M_run(std::forward<_ArgTypes>(__args)...);
}
void
make_ready_at_thread_exit(_ArgTypes... __args)
{
__future_base::_State_base::_S_check(_M_state);
_M_state->_M_run_delayed(std::forward<_ArgTypes>(__args)..., _M_state);
}
void
reset()
{
__future_base::_State_base::_S_check(_M_state);
packaged_task __tmp;
__tmp._M_state = _M_state;
_M_state = _M_state->_M_reset();
}
};
/// swap
template<typename _Res, typename... _ArgTypes>
inline void
swap(packaged_task<_Res(_ArgTypes...)>& __x,
packaged_task<_Res(_ArgTypes...)>& __y) noexcept
{ __x.swap(__y); }
template<typename _Res, typename _Alloc>
struct uses_allocator<packaged_task<_Res>, _Alloc>
: public true_type { };
// Shared state created by std::async().
// Holds a deferred function and storage for its result.
template<typename _BoundFn, typename _Res>
class __future_base::_Deferred_state final
: public __future_base::_State_base
{
public:
explicit
_Deferred_state(_BoundFn&& __fn)
: _M_result(new _Result<_Res>()), _M_fn(std::move(__fn))
{ }
private:
typedef __future_base::_Ptr<_Result<_Res>> _Ptr_type;
_Ptr_type _M_result;
_BoundFn _M_fn;
// Run the deferred function.
virtual void
_M_complete_async()
{
// Multiple threads can call a waiting function on the future and
// reach this point at the same time. The call_once in _M_set_result
// ensures only the first one run the deferred function, stores the
// result in _M_result, swaps that with the base _M_result and makes
// the state ready. Tell _M_set_result to ignore failure so all later
// calls do nothing.
_M_set_result(_S_task_setter(_M_result, _M_fn), true);
}
// Caller should check whether the state is ready first, because this
// function will return true even after the deferred function has run.
virtual bool _M_is_deferred_future() const { return true; }
};
// Common functionality hoisted out of the _Async_state_impl template.
class __future_base::_Async_state_commonV2
: public __future_base::_State_base
{
protected:
~_Async_state_commonV2() = default;
// Make waiting functions block until the thread completes, as if joined.
//
// This function is used by wait() to satisfy the first requirement below
// and by wait_for() / wait_until() to satisfy the second.
//
// [futures.async]:
//
// — a call to a waiting function on an asynchronous return object that
// shares the shared state created by this async call shall block until
// the associated thread has completed, as if joined, or else time out.
//
// — the associated thread completion synchronizes with the return from
// the first function that successfully detects the ready status of the
// shared state or with the return from the last function that releases
// the shared state, whichever happens first.
virtual void _M_complete_async() { _M_join(); }
void _M_join() { std::call_once(_M_once, &thread::join, &_M_thread); }
thread _M_thread;
once_flag _M_once;
};
// Shared state created by std::async().
// Starts a new thread that runs a function and makes the shared state ready.
template<typename _BoundFn, typename _Res>
class __future_base::_Async_state_impl final
: public __future_base::_Async_state_commonV2
{
public:
explicit
_Async_state_impl(_BoundFn&& __fn)
: _M_result(new _Result<_Res>()), _M_fn(std::move(__fn))
{
_M_thread = std::thread{ [this] {
__try
{
_M_set_result(_S_task_setter(_M_result, _M_fn));
}
__catch (const __cxxabiv1::__forced_unwind&)
{
// make the shared state ready on thread cancellation
if (static_cast<bool>(_M_result))
this->_M_break_promise(std::move(_M_result));
__throw_exception_again;
}
} };
}
// Must not destroy _M_result and _M_fn until the thread finishes.
// Call join() directly rather than through _M_join() because no other
// thread can be referring to this state if it is being destroyed.
~_Async_state_impl() { if (_M_thread.joinable()) _M_thread.join(); }
private:
typedef __future_base::_Ptr<_Result<_Res>> _Ptr_type;
_Ptr_type _M_result;
_BoundFn _M_fn;
};
template<typename _BoundFn>
inline std::shared_ptr<__future_base::_State_base>
__future_base::_S_make_deferred_state(_BoundFn&& __fn)
{
typedef typename remove_reference<_BoundFn>::type __fn_type;
typedef _Deferred_state<__fn_type> __state_type;
return std::make_shared<__state_type>(std::move(__fn));
}
template<typename _BoundFn>
inline std::shared_ptr<__future_base::_State_base>
__future_base::_S_make_async_state(_BoundFn&& __fn)
{
typedef typename remove_reference<_BoundFn>::type __fn_type;
typedef _Async_state_impl<__fn_type> __state_type;
return std::make_shared<__state_type>(std::move(__fn));
}
/// async
template<typename _Fn, typename... _Args>
future<__async_result_of<_Fn, _Args...>>
async(launch __policy, _Fn&& __fn, _Args&&... __args)
{
std::shared_ptr<__future_base::_State_base> __state;
if ((__policy & launch::async) == launch::async)
{
__try
{
__state = __future_base::_S_make_async_state(
std::thread::__make_invoker(std::forward<_Fn>(__fn),
std::forward<_Args>(__args)...)
);
}
#if __cpp_exceptions
catch(const system_error& __e)
{
if (__e.code() != errc::resource_unavailable_try_again
|| (__policy & launch::deferred) != launch::deferred)
throw;
}
#endif
}
if (!__state)
{
__state = __future_base::_S_make_deferred_state(
std::thread::__make_invoker(std::forward<_Fn>(__fn),
std::forward<_Args>(__args)...));
}
return future<__async_result_of<_Fn, _Args...>>(__state);
}
/// async, potential overload
template<typename _Fn, typename... _Args>
inline future<__async_result_of<_Fn, _Args...>>
async(_Fn&& __fn, _Args&&... __args)
{
return std::async(launch::async|launch::deferred,
std::forward<_Fn>(__fn),
std::forward<_Args>(__args)...);
}
#endif // _GLIBCXX_ASYNC_ABI_COMPAT
#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
// @} group futures
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif // C++11
#endif // _GLIBCXX_FUTURE
c++/8/cstring 0000644 00000006063 15201526705 0006667 0 ustar 00 // -*- C++ -*- forwarding header.
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file cstring
* This is a Standard C++ Library file. You should @c \#include this file
* in your programs, rather than any of the @a *.h implementation files.
*
* This is the C++ version of the Standard C Library header @c string.h,
* and its contents are (mostly) the same as that header, but are all
* contained in the namespace @c std (except for names which are defined
* as macros in C).
*/
//
// ISO C++ 14882: 20.4.6 C library
//
#pragma GCC system_header
#include <bits/c++config.h>
#include <string.h>
#ifndef _GLIBCXX_CSTRING
#define _GLIBCXX_CSTRING 1
// Get rid of those macros defined in <string.h> in lieu of real functions.
#undef memchr
#undef memcmp
#undef memcpy
#undef memmove
#undef memset
#undef strcat
#undef strchr
#undef strcmp
#undef strcoll
#undef strcpy
#undef strcspn
#undef strerror
#undef strlen
#undef strncat
#undef strncmp
#undef strncpy
#undef strpbrk
#undef strrchr
#undef strspn
#undef strstr
#undef strtok
#undef strxfrm
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using ::memchr;
using ::memcmp;
using ::memcpy;
using ::memmove;
using ::memset;
using ::strcat;
using ::strcmp;
using ::strcoll;
using ::strcpy;
using ::strcspn;
using ::strerror;
using ::strlen;
using ::strncat;
using ::strncmp;
using ::strncpy;
using ::strspn;
using ::strtok;
using ::strxfrm;
using ::strchr;
using ::strpbrk;
using ::strrchr;
using ::strstr;
#ifndef __CORRECT_ISO_CPP_STRING_H_PROTO
inline void*
memchr(void* __s, int __c, size_t __n)
{ return __builtin_memchr(__s, __c, __n); }
inline char*
strchr(char* __s, int __n)
{ return __builtin_strchr(__s, __n); }
inline char*
strpbrk(char* __s1, const char* __s2)
{ return __builtin_strpbrk(__s1, __s2); }
inline char*
strrchr(char* __s, int __n)
{ return __builtin_strrchr(__s, __n); }
inline char*
strstr(char* __s1, const char* __s2)
{ return __builtin_strstr(__s1, __s2); }
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/list 0000644 00000005042 15201526705 0006165 0 ustar 00 // <list> -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1996,1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file include/list
* This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_LIST
#define _GLIBCXX_LIST 1
#pragma GCC system_header
#include <bits/stl_algobase.h>
#include <bits/allocator.h>
#include <bits/range_access.h>
#include <bits/stl_list.h>
#include <bits/list.tcc>
#ifdef _GLIBCXX_DEBUG
# include <debug/list>
#endif
#ifdef _GLIBCXX_PROFILE
# include <profile/list>
#endif
#endif /* _GLIBCXX_LIST */
c++/8/tr2/dynamic_bitset 0000644 00000103023 15201526705 0010715 0 ustar 00 // TR2 <dynamic_bitset> -*- C++ -*-
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file tr2/dynamic_bitset
* This is a TR2 C++ Library header.
*/
#ifndef _GLIBCXX_TR2_DYNAMIC_BITSET
#define _GLIBCXX_TR2_DYNAMIC_BITSET 1
#pragma GCC system_header
#include <limits>
#include <vector>
#include <string>
#include <istream>
#include <bits/functexcept.h>
#include <bits/stl_algo.h> // For fill
#include <bits/cxxabi_forced.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
namespace tr2
{
/**
* @defgroup dynamic_bitset Dynamic Bitset.
* @ingroup extensions
*
* @{
*/
/**
* Base class, general case.
*
* See documentation for dynamic_bitset.
*/
template<typename _WordT = unsigned long long,
typename _Alloc = std::allocator<_WordT>>
struct __dynamic_bitset_base
{
static_assert(std::is_unsigned<_WordT>::value, "template argument "
"_WordT not an unsigned integral type");
typedef _WordT block_type;
typedef _Alloc allocator_type;
typedef size_t size_type;
static const size_type _S_bits_per_block = __CHAR_BIT__ * sizeof(block_type);
static const size_type npos = static_cast<size_type>(-1);
/// 0 is the least significant word.
std::vector<block_type, allocator_type> _M_w;
explicit
__dynamic_bitset_base(const allocator_type& __alloc)
: _M_w(__alloc)
{ }
__dynamic_bitset_base() = default;
__dynamic_bitset_base(const __dynamic_bitset_base&) = default;
__dynamic_bitset_base(__dynamic_bitset_base&& __b) = default;
__dynamic_bitset_base& operator=(const __dynamic_bitset_base&) = default;
__dynamic_bitset_base& operator=(__dynamic_bitset_base&&) = default;
~__dynamic_bitset_base() = default;
explicit
__dynamic_bitset_base(size_type __nbits, unsigned long long __val = 0ULL,
const allocator_type& __alloc = allocator_type())
: _M_w(__nbits / _S_bits_per_block + (__nbits % _S_bits_per_block > 0),
block_type(0), __alloc)
{
if (__nbits < std::numeric_limits<decltype(__val)>::digits)
__val &= ~(-1ULL << __nbits);
if (__val == 0)
return;
if _GLIBCXX17_CONSTEXPR (sizeof(__val) == sizeof(block_type))
_M_w[0] = __val;
else
{
const size_t __n
= std::min(_M_w.size(), sizeof(__val) / sizeof(block_type));
for (size_t __i = 0; __val && __i < __n; ++__i)
{
_M_w[__i] = static_cast<block_type>(__val);
__val >>= _S_bits_per_block;
}
}
}
void
_M_swap(__dynamic_bitset_base& __b) noexcept
{ this->_M_w.swap(__b._M_w); }
void
_M_clear() noexcept
{ this->_M_w.clear(); }
void
_M_resize(size_t __nbits, bool __value)
{
size_t __sz = __nbits / _S_bits_per_block;
if (__nbits % _S_bits_per_block > 0)
++__sz;
if (__sz != this->_M_w.size())
{
block_type __val = 0;
if (__value)
__val = std::numeric_limits<block_type>::max();
this->_M_w.resize(__sz, __val);
}
}
allocator_type
_M_get_allocator() const noexcept
{ return this->_M_w.get_allocator(); }
static size_type
_S_whichword(size_type __pos) noexcept
{ return __pos / _S_bits_per_block; }
static size_type
_S_whichbyte(size_type __pos) noexcept
{ return (__pos % _S_bits_per_block) / __CHAR_BIT__; }
static size_type
_S_whichbit(size_type __pos) noexcept
{ return __pos % _S_bits_per_block; }
static block_type
_S_maskbit(size_type __pos) noexcept
{ return (static_cast<block_type>(1)) << _S_whichbit(__pos); }
block_type&
_M_getword(size_type __pos) noexcept
{ return this->_M_w[_S_whichword(__pos)]; }
block_type
_M_getword(size_type __pos) const noexcept
{ return this->_M_w[_S_whichword(__pos)]; }
block_type&
_M_hiword() noexcept
{ return this->_M_w[_M_w.size() - 1]; }
block_type
_M_hiword() const noexcept
{ return this->_M_w[_M_w.size() - 1]; }
void
_M_do_and(const __dynamic_bitset_base& __x) noexcept
{
if (__x._M_w.size() == this->_M_w.size())
for (size_t __i = 0; __i < this->_M_w.size(); ++__i)
this->_M_w[__i] &= __x._M_w[__i];
else
return;
}
void
_M_do_or(const __dynamic_bitset_base& __x) noexcept
{
if (__x._M_w.size() == this->_M_w.size())
for (size_t __i = 0; __i < this->_M_w.size(); ++__i)
this->_M_w[__i] |= __x._M_w[__i];
else
return;
}
void
_M_do_xor(const __dynamic_bitset_base& __x) noexcept
{
if (__x._M_w.size() == this->_M_w.size())
for (size_t __i = 0; __i < this->_M_w.size(); ++__i)
this->_M_w[__i] ^= __x._M_w[__i];
else
return;
}
void
_M_do_dif(const __dynamic_bitset_base& __x) noexcept
{
if (__x._M_w.size() == this->_M_w.size())
for (size_t __i = 0; __i < this->_M_w.size(); ++__i)
this->_M_w[__i] &= ~__x._M_w[__i];
else
return;
}
void
_M_do_left_shift(size_t __shift);
void
_M_do_right_shift(size_t __shift);
void
_M_do_flip() noexcept
{
for (size_t __i = 0; __i < this->_M_w.size(); ++__i)
this->_M_w[__i] = ~this->_M_w[__i];
}
void
_M_do_set() noexcept
{
for (size_t __i = 0; __i < this->_M_w.size(); ++__i)
this->_M_w[__i] = static_cast<block_type>(-1);
}
void
_M_do_reset() noexcept
{
std::fill(_M_w.begin(), _M_w.end(), static_cast<block_type>(0));
}
bool
_M_is_equal(const __dynamic_bitset_base& __x) const noexcept
{
if (__x._M_w.size() == this->_M_w.size())
{
for (size_t __i = 0; __i < this->_M_w.size(); ++__i)
if (this->_M_w[__i] != __x._M_w[__i])
return false;
return true;
}
else
return false;
}
bool
_M_is_less(const __dynamic_bitset_base& __x) const noexcept
{
if (__x._M_w.size() == this->_M_w.size())
{
for (size_t __i = this->_M_w.size(); __i > 0; --__i)
{
if (this->_M_w[__i-1] < __x._M_w[__i-1])
return true;
else if (this->_M_w[__i-1] > __x._M_w[__i-1])
return false;
}
return false;
}
else
return false;
}
size_t
_M_are_all_aux() const noexcept
{
for (size_t __i = 0; __i < this->_M_w.size() - 1; ++__i)
if (_M_w[__i] != static_cast<block_type>(-1))
return 0;
return ((this->_M_w.size() - 1) * _S_bits_per_block
+ __builtin_popcountll(this->_M_hiword()));
}
bool
_M_is_any() const noexcept
{
for (size_t __i = 0; __i < this->_M_w.size(); ++__i)
if (this->_M_w[__i] != static_cast<block_type>(0))
return true;
return false;
}
bool
_M_is_subset_of(const __dynamic_bitset_base& __b) noexcept
{
if (__b._M_w.size() == this->_M_w.size())
{
for (size_t __i = 0; __i < this->_M_w.size(); ++__i)
if (this->_M_w[__i] != (this->_M_w[__i] | __b._M_w[__i]))
return false;
return true;
}
else
return false;
}
bool
_M_is_proper_subset_of(const __dynamic_bitset_base& __b) const noexcept
{
if (this->is_subset_of(__b))
{
if (*this == __b)
return false;
else
return true;
}
else
return false;
}
size_t
_M_do_count() const noexcept
{
size_t __result = 0;
for (size_t __i = 0; __i < this->_M_w.size(); ++__i)
__result += __builtin_popcountll(this->_M_w[__i]);
return __result;
}
size_type
_M_size() const noexcept
{ return this->_M_w.size(); }
unsigned long
_M_do_to_ulong() const;
unsigned long long
_M_do_to_ullong() const;
// find first "on" bit
size_type
_M_do_find_first(size_t __not_found) const;
// find the next "on" bit that follows "prev"
size_type
_M_do_find_next(size_t __prev, size_t __not_found) const;
// do append of block
void
_M_do_append_block(block_type __block, size_type __pos)
{
size_t __offset = __pos % _S_bits_per_block;
if (__offset == 0)
this->_M_w.push_back(__block);
else
{
this->_M_hiword() |= (__block << __offset);
this->_M_w.push_back(__block >> (_S_bits_per_block - __offset));
}
}
};
/**
* @brief The %dynamic_bitset class represents a sequence of bits.
*
* See N2050,
* Proposal to Add a Dynamically Sizeable Bitset to the Standard Library.
* http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2050.pdf
*
* In the general unoptimized case, storage is allocated in
* word-sized blocks. Let B be the number of bits in a word, then
* (Nb+(B-1))/B words will be used for storage. B - Nb%B bits are
* unused. (They are the high-order bits in the highest word.) It
* is a class invariant that those unused bits are always zero.
*
* If you think of %dynamic_bitset as "a simple array of bits," be
* aware that your mental picture is reversed: a %dynamic_bitset
* behaves the same way as bits in integers do, with the bit at
* index 0 in the "least significant / right-hand" position, and
* the bit at index Nb-1 in the "most significant / left-hand"
* position. Thus, unlike other containers, a %dynamic_bitset's
* index "counts from right to left," to put it very loosely.
*
* This behavior is preserved when translating to and from strings.
* For example, the first line of the following program probably
* prints "b('a') is 0001100001" on a modern ASCII system.
*
* @code
* #include <dynamic_bitset>
* #include <iostream>
* #include <sstream>
*
* using namespace std;
*
* int main()
* {
* long a = 'a';
* dynamic_bitset<> b(a);
*
* cout << "b('a') is " << b << endl;
*
* ostringstream s;
* s << b;
* string str = s.str();
* cout << "index 3 in the string is " << str[3] << " but\n"
* << "index 3 in the bitset is " << b[3] << endl;
* }
* @endcode
*
* Most of the actual code isn't contained in %dynamic_bitset<>
* itself, but in the base class __dynamic_bitset_base. The base
* class works with whole words, not with individual bits. This
* allows us to specialize __dynamic_bitset_base for the important
* special case where the %dynamic_bitset is only a single word.
*
* Extra confusion can result due to the fact that the storage for
* __dynamic_bitset_base @e is a vector, and is indexed as such. This is
* carefully encapsulated.
*/
template<typename _WordT = unsigned long long,
typename _Alloc = std::allocator<_WordT>>
class dynamic_bitset
: private __dynamic_bitset_base<_WordT, _Alloc>
{
static_assert(std::is_unsigned<_WordT>::value, "template argument "
"_WordT not an unsigned integral type");
public:
typedef __dynamic_bitset_base<_WordT, _Alloc> _Base;
typedef _WordT block_type;
typedef _Alloc allocator_type;
typedef size_t size_type;
static const size_type bits_per_block = __CHAR_BIT__ * sizeof(block_type);
// Use this: constexpr size_type std::numeric_limits<size_type>::max().
static const size_type npos = static_cast<size_type>(-1);
private:
// Clear the unused bits in the uppermost word.
void
_M_do_sanitize()
{
size_type __shift = this->_M_Nb % bits_per_block;
if (__shift > 0)
this->_M_hiword() &= block_type(~(block_type(-1) << __shift));
}
// Set the unused bits in the uppermost word.
void
_M_do_fill()
{
size_type __shift = this->_M_Nb % bits_per_block;
if (__shift > 0)
this->_M_hiword() |= block_type(block_type(-1) << __shift);
}
/**
* These versions of single-bit set, reset, flip, and test
* do no range checking.
*/
dynamic_bitset&
_M_unchecked_set(size_type __pos) noexcept
{
this->_M_getword(__pos) |= _Base::_S_maskbit(__pos);
return *this;
}
dynamic_bitset&
_M_unchecked_set(size_type __pos, int __val) noexcept
{
if (__val)
this->_M_getword(__pos) |= _Base::_S_maskbit(__pos);
else
this->_M_getword(__pos) &= ~_Base::_S_maskbit(__pos);
return *this;
}
dynamic_bitset&
_M_unchecked_reset(size_type __pos) noexcept
{
this->_M_getword(__pos) &= ~_Base::_S_maskbit(__pos);
return *this;
}
dynamic_bitset&
_M_unchecked_flip(size_type __pos) noexcept
{
this->_M_getword(__pos) ^= _Base::_S_maskbit(__pos);
return *this;
}
bool
_M_unchecked_test(size_type __pos) const noexcept
{ return ((this->_M_getword(__pos) & _Base::_S_maskbit(__pos))
!= static_cast<_WordT>(0)); }
size_type _M_Nb = 0;
public:
/**
* This encapsulates the concept of a single bit. An instance
* of this class is a proxy for an actual bit; this way the
* individual bit operations are done as faster word-size
* bitwise instructions.
*
* Most users will never need to use this class directly;
* conversions to and from bool are automatic and should be
* transparent. Overloaded operators help to preserve the
* illusion.
*
* (On a typical system, this "bit %reference" is 64 times the
* size of an actual bit. Ha.)
*/
class reference
{
friend class dynamic_bitset;
block_type *_M_wp;
size_type _M_bpos;
public:
reference(dynamic_bitset& __b, size_type __pos) noexcept
{
this->_M_wp = &__b._M_getword(__pos);
this->_M_bpos = _Base::_S_whichbit(__pos);
}
// For b[i] = __x;
reference&
operator=(bool __x) noexcept
{
if (__x)
*this->_M_wp |= _Base::_S_maskbit(this->_M_bpos);
else
*this->_M_wp &= ~_Base::_S_maskbit(this->_M_bpos);
return *this;
}
// For b[i] = b[__j];
reference&
operator=(const reference& __j) noexcept
{
if ((*(__j._M_wp) & _Base::_S_maskbit(__j._M_bpos)))
*this->_M_wp |= _Base::_S_maskbit(this->_M_bpos);
else
*this->_M_wp &= ~_Base::_S_maskbit(this->_M_bpos);
return *this;
}
// Flips the bit
bool
operator~() const noexcept
{ return (*(_M_wp) & _Base::_S_maskbit(this->_M_bpos)) == 0; }
// For __x = b[i];
operator bool() const noexcept
{ return (*(this->_M_wp) & _Base::_S_maskbit(this->_M_bpos)) != 0; }
// For b[i].flip();
reference&
flip() noexcept
{
*this->_M_wp ^= _Base::_S_maskbit(this->_M_bpos);
return *this;
}
};
friend class reference;
typedef bool const_reference;
// 23.3.5.1 constructors:
/// All bits set to zero.
dynamic_bitset() = default;
/// All bits set to zero.
explicit
dynamic_bitset(const allocator_type& __alloc)
: _Base(__alloc)
{ }
/// Initial bits bitwise-copied from a single word (others set to zero).
explicit
dynamic_bitset(size_type __nbits, unsigned long long __val = 0ULL,
const allocator_type& __alloc = allocator_type())
: _Base(__nbits, __val, __alloc),
_M_Nb(__nbits)
{ }
dynamic_bitset(initializer_list<block_type> __il,
const allocator_type& __alloc = allocator_type())
: _Base(__alloc)
{ this->append(__il); }
/**
* @brief Use a subset of a string.
* @param __str A string of '0' and '1' characters.
* @param __pos Index of the first character in @p __str to use.
* @param __n The number of characters to copy.
* @param __zero The character to use for unset bits.
* @param __one The character to use for set bits.
* @param __alloc An allocator.
* @throw std::out_of_range If @p __pos is bigger the size of @p __str.
* @throw std::invalid_argument If a character appears in the string
* which is neither '0' nor '1'.
*/
template<typename _CharT, typename _Traits, typename _Alloc1>
explicit
dynamic_bitset(const std::basic_string<_CharT, _Traits, _Alloc1>& __str,
typename basic_string<_CharT,_Traits,_Alloc1>::size_type
__pos = 0,
typename basic_string<_CharT,_Traits,_Alloc1>::size_type
__n = std::basic_string<_CharT, _Traits, _Alloc1>::npos,
_CharT __zero = _CharT('0'), _CharT __one = _CharT('1'),
const allocator_type& __alloc = allocator_type())
: _Base(__alloc)
{
if (__pos > __str.size())
__throw_out_of_range(__N("dynamic_bitset::bitset initial position "
"not valid"));
// Watch for npos.
this->_M_Nb = (__n > __str.size() ? __str.size() - __pos : __n);
this->resize(this->_M_Nb);
this->_M_copy_from_string(__str, __pos, __n);
}
/**
* @brief Construct from a string.
* @param __str A string of '0' and '1' characters.
* @param __alloc An allocator.
* @throw std::invalid_argument If a character appears in the string
* which is neither '0' nor '1'.
*/
explicit
dynamic_bitset(const char* __str,
const allocator_type& __alloc = allocator_type())
: _Base(__builtin_strlen(__str), 0ULL, __alloc),
_M_Nb(__builtin_strlen(__str))
{
this->_M_copy_from_ptr(__str, _M_Nb, 0, _M_Nb);
}
/// Copy constructor.
dynamic_bitset(const dynamic_bitset&) = default;
/// Move constructor.
dynamic_bitset(dynamic_bitset&& __b) noexcept
: _Base(std::move(__b)), _M_Nb(__b._M_Nb)
{ __b.clear(); }
/// Swap with another bitset.
void
swap(dynamic_bitset& __b) noexcept
{
this->_M_swap(__b);
std::swap(this->_M_Nb, __b._M_Nb);
}
/// Copy assignment operator.
dynamic_bitset& operator=(const dynamic_bitset&) = default;
/// Move assignment operator.
dynamic_bitset&
operator=(dynamic_bitset&& __b)
noexcept(std::is_nothrow_move_assignable<_Base>::value)
{
static_cast<_Base&>(*this) = static_cast<_Base&&>(__b);
_M_Nb = __b._M_Nb;
if _GLIBCXX17_CONSTEXPR (std::is_nothrow_move_assignable<_Base>::value)
__b._M_Nb = 0;
else if (get_allocator() == __b.get_allocator())
__b._M_Nb = 0;
return *this;
}
/**
* @brief Return the allocator for the bitset.
*/
allocator_type
get_allocator() const noexcept
{ return this->_M_get_allocator(); }
/**
* @brief Resize the bitset.
*/
void
resize(size_type __nbits, bool __value = false)
{
if (__value)
this->_M_do_fill();
this->_M_resize(__nbits, __value);
this->_M_Nb = __nbits;
this->_M_do_sanitize();
}
/**
* @brief Clear the bitset.
*/
void
clear()
{
this->_M_clear();
this->_M_Nb = 0;
}
/**
* @brief Push a bit onto the high end of the bitset.
*/
void
push_back(bool __bit)
{
if (size_t __offset = this->size() % bits_per_block == 0)
this->_M_do_append_block(block_type(0), this->_M_Nb);
++this->_M_Nb;
this->_M_unchecked_set(this->_M_Nb, __bit);
}
// XXX why is there no pop_back() member in the proposal?
/**
* @brief Append a block.
*/
void
append(block_type __block)
{
this->_M_do_append_block(__block, this->_M_Nb);
this->_M_Nb += bits_per_block;
}
/**
* @brief
*/
void
append(initializer_list<block_type> __il)
{ this->append(__il.begin(), __il.end()); }
/**
* @brief Append an iterator range of blocks.
*/
template <typename _BlockInputIterator>
void
append(_BlockInputIterator __first, _BlockInputIterator __last)
{
for (; __first != __last; ++__first)
this->append(*__first);
}
// 23.3.5.2 dynamic_bitset operations:
//@{
/**
* @brief Operations on dynamic_bitsets.
* @param __rhs A same-sized dynamic_bitset.
*
* These should be self-explanatory.
*/
dynamic_bitset&
operator&=(const dynamic_bitset& __rhs)
{
this->_M_do_and(__rhs);
return *this;
}
dynamic_bitset&
operator&=(dynamic_bitset&& __rhs)
{
this->_M_do_and(std::move(__rhs));
return *this;
}
dynamic_bitset&
operator|=(const dynamic_bitset& __rhs)
{
this->_M_do_or(__rhs);
return *this;
}
dynamic_bitset&
operator^=(const dynamic_bitset& __rhs)
{
this->_M_do_xor(__rhs);
return *this;
}
dynamic_bitset&
operator-=(const dynamic_bitset& __rhs)
{
this->_M_do_dif(__rhs);
return *this;
}
//@}
//@{
/**
* @brief Operations on dynamic_bitsets.
* @param __pos The number of places to shift.
*
* These should be self-explanatory.
*/
dynamic_bitset&
operator<<=(size_type __pos)
{
if (__builtin_expect(__pos < this->_M_Nb, 1))
{
this->_M_do_left_shift(__pos);
this->_M_do_sanitize();
}
else
this->_M_do_reset();
return *this;
}
dynamic_bitset&
operator>>=(size_type __pos)
{
if (__builtin_expect(__pos < this->_M_Nb, 1))
{
this->_M_do_right_shift(__pos);
this->_M_do_sanitize();
}
else
this->_M_do_reset();
return *this;
}
//@}
// Set, reset, and flip.
/**
* @brief Sets every bit to true.
*/
dynamic_bitset&
set()
{
this->_M_do_set();
this->_M_do_sanitize();
return *this;
}
/**
* @brief Sets a given bit to a particular value.
* @param __pos The index of the bit.
* @param __val Either true or false, defaults to true.
* @throw std::out_of_range If @a __pos is bigger the size of the %set.
*/
dynamic_bitset&
set(size_type __pos, bool __val = true)
{
if (__pos >= _M_Nb)
__throw_out_of_range(__N("dynamic_bitset::set"));
return this->_M_unchecked_set(__pos, __val);
}
/**
* @brief Sets every bit to false.
*/
dynamic_bitset&
reset()
{
this->_M_do_reset();
return *this;
}
/**
* @brief Sets a given bit to false.
* @param __pos The index of the bit.
* @throw std::out_of_range If @a __pos is bigger the size of the %set.
*
* Same as writing @c set(__pos, false).
*/
dynamic_bitset&
reset(size_type __pos)
{
if (__pos >= _M_Nb)
__throw_out_of_range(__N("dynamic_bitset::reset"));
return this->_M_unchecked_reset(__pos);
}
/**
* @brief Toggles every bit to its opposite value.
*/
dynamic_bitset&
flip()
{
this->_M_do_flip();
this->_M_do_sanitize();
return *this;
}
/**
* @brief Toggles a given bit to its opposite value.
* @param __pos The index of the bit.
* @throw std::out_of_range If @a __pos is bigger the size of the %set.
*/
dynamic_bitset&
flip(size_type __pos)
{
if (__pos >= _M_Nb)
__throw_out_of_range(__N("dynamic_bitset::flip"));
return this->_M_unchecked_flip(__pos);
}
/// See the no-argument flip().
dynamic_bitset
operator~() const
{ return dynamic_bitset<_WordT, _Alloc>(*this).flip(); }
//@{
/**
* @brief Array-indexing support.
* @param __pos Index into the %dynamic_bitset.
* @return A bool for a 'const %dynamic_bitset'. For non-const
* bitsets, an instance of the reference proxy class.
* @note These operators do no range checking and throw no
* exceptions, as required by DR 11 to the standard.
*/
reference
operator[](size_type __pos)
{ return reference(*this,__pos); }
const_reference
operator[](size_type __pos) const
{ return _M_unchecked_test(__pos); }
//@}
/**
* @brief Returns a numerical interpretation of the %dynamic_bitset.
* @return The integral equivalent of the bits.
* @throw std::overflow_error If there are too many bits to be
* represented in an @c unsigned @c long.
*/
unsigned long
to_ulong() const
{ return this->_M_do_to_ulong(); }
/**
* @brief Returns a numerical interpretation of the %dynamic_bitset.
* @return The integral equivalent of the bits.
* @throw std::overflow_error If there are too many bits to be
* represented in an @c unsigned @c long.
*/
unsigned long long
to_ullong() const
{ return this->_M_do_to_ullong(); }
/**
* @brief Returns a character interpretation of the %dynamic_bitset.
* @return The string equivalent of the bits.
*
* Note the ordering of the bits: decreasing character positions
* correspond to increasing bit positions (see the main class notes for
* an example).
*/
template<typename _CharT = char,
typename _Traits = std::char_traits<_CharT>,
typename _Alloc1 = std::allocator<_CharT>>
std::basic_string<_CharT, _Traits, _Alloc1>
to_string(_CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) const
{
std::basic_string<_CharT, _Traits, _Alloc1> __result;
_M_copy_to_string(__result, __zero, __one);
return __result;
}
// Helper functions for string operations.
template<typename _Traits = std::char_traits<char>,
typename _CharT = typename _Traits::char_type>
void
_M_copy_from_ptr(const _CharT*, size_t, size_t, size_t,
_CharT __zero = _CharT('0'),
_CharT __one = _CharT('1'));
template<typename _CharT, typename _Traits, typename _Alloc1>
void
_M_copy_from_string(const basic_string<_CharT, _Traits, _Alloc1>& __str,
size_t __pos, size_t __n,
_CharT __zero = _CharT('0'),
_CharT __one = _CharT('1'))
{
_M_copy_from_ptr<_Traits>(__str.data(), __str.size(), __pos, __n,
__zero, __one);
}
template<typename _CharT, typename _Traits, typename _Alloc1>
void
_M_copy_to_string(std::basic_string<_CharT, _Traits, _Alloc1>& __str,
_CharT __zero = _CharT('0'),
_CharT __one = _CharT('1')) const;
/// Returns the number of bits which are set.
size_type
count() const noexcept
{ return this->_M_do_count(); }
/// Returns the total number of bits.
size_type
size() const noexcept
{ return this->_M_Nb; }
/// Returns the total number of blocks.
size_type
num_blocks() const noexcept
{ return this->_M_size(); }
/// Returns true if the dynamic_bitset is empty.
bool
empty() const noexcept
{ return (this->_M_Nb == 0); }
/// Returns the maximum size of a dynamic_bitset object having the same
/// type as *this.
/// The real answer is max() * bits_per_block but is likely to overflow.
constexpr size_type
max_size() noexcept
{ return std::numeric_limits<block_type>::max(); }
/**
* @brief Tests the value of a bit.
* @param __pos The index of a bit.
* @return The value at @a __pos.
* @throw std::out_of_range If @a __pos is bigger the size of the %set.
*/
bool
test(size_type __pos) const
{
if (__pos >= _M_Nb)
__throw_out_of_range(__N("dynamic_bitset::test"));
return _M_unchecked_test(__pos);
}
/**
* @brief Tests whether all the bits are on.
* @return True if all the bits are set.
*/
bool
all() const
{ return this->_M_are_all_aux() == _M_Nb; }
/**
* @brief Tests whether any of the bits are on.
* @return True if at least one bit is set.
*/
bool
any() const
{ return this->_M_is_any(); }
/**
* @brief Tests whether any of the bits are on.
* @return True if none of the bits are set.
*/
bool
none() const
{ return !this->_M_is_any(); }
//@{
/// Self-explanatory.
dynamic_bitset
operator<<(size_type __pos) const
{ return dynamic_bitset(*this) <<= __pos; }
dynamic_bitset
operator>>(size_type __pos) const
{ return dynamic_bitset(*this) >>= __pos; }
//@}
/**
* @brief Finds the index of the first "on" bit.
* @return The index of the first bit set, or size() if not found.
* @sa find_next
*/
size_type
find_first() const
{ return this->_M_do_find_first(this->_M_Nb); }
/**
* @brief Finds the index of the next "on" bit after prev.
* @return The index of the next bit set, or size() if not found.
* @param __prev Where to start searching.
* @sa find_first
*/
size_type
find_next(size_t __prev) const
{ return this->_M_do_find_next(__prev, this->_M_Nb); }
bool
is_subset_of(const dynamic_bitset& __b) const
{ return this->_M_is_subset_of(__b); }
bool
is_proper_subset_of(const dynamic_bitset& __b) const
{ return this->_M_is_proper_subset_of(__b); }
friend bool
operator==(const dynamic_bitset& __lhs,
const dynamic_bitset& __rhs) noexcept
{ return __lhs._M_Nb == __rhs._M_Nb && __lhs._M_is_equal(__rhs); }
friend bool
operator<(const dynamic_bitset& __lhs,
const dynamic_bitset& __rhs) noexcept
{ return __lhs._M_is_less(__rhs) || __lhs._M_Nb < __rhs._M_Nb; }
};
template<typename _WordT, typename _Alloc>
template<typename _CharT, typename _Traits, typename _Alloc1>
inline void
dynamic_bitset<_WordT, _Alloc>::
_M_copy_to_string(std::basic_string<_CharT, _Traits, _Alloc1>& __str,
_CharT __zero, _CharT __one) const
{
__str.assign(_M_Nb, __zero);
for (size_t __i = _M_Nb; __i > 0; --__i)
if (_M_unchecked_test(__i - 1))
_Traits::assign(__str[_M_Nb - __i], __one);
}
//@{
/// These comparisons for equality/inequality are, well, @e bitwise.
template<typename _WordT, typename _Alloc>
inline bool
operator!=(const dynamic_bitset<_WordT, _Alloc>& __lhs,
const dynamic_bitset<_WordT, _Alloc>& __rhs)
{ return !(__lhs == __rhs); }
template<typename _WordT, typename _Alloc>
inline bool
operator<=(const dynamic_bitset<_WordT, _Alloc>& __lhs,
const dynamic_bitset<_WordT, _Alloc>& __rhs)
{ return !(__lhs > __rhs); }
template<typename _WordT, typename _Alloc>
inline bool
operator>(const dynamic_bitset<_WordT, _Alloc>& __lhs,
const dynamic_bitset<_WordT, _Alloc>& __rhs)
{ return __rhs < __lhs; }
template<typename _WordT, typename _Alloc>
inline bool
operator>=(const dynamic_bitset<_WordT, _Alloc>& __lhs,
const dynamic_bitset<_WordT, _Alloc>& __rhs)
{ return !(__lhs < __rhs); }
//@}
// 23.3.5.3 bitset operations:
//@{
/**
* @brief Global bitwise operations on bitsets.
* @param __x A bitset.
* @param __y A bitset of the same size as @a __x.
* @return A new bitset.
*
* These should be self-explanatory.
*/
template<typename _WordT, typename _Alloc>
inline dynamic_bitset<_WordT, _Alloc>
operator&(const dynamic_bitset<_WordT, _Alloc>& __x,
const dynamic_bitset<_WordT, _Alloc>& __y)
{
dynamic_bitset<_WordT, _Alloc> __result(__x);
__result &= __y;
return __result;
}
template<typename _WordT, typename _Alloc>
inline dynamic_bitset<_WordT, _Alloc>
operator|(const dynamic_bitset<_WordT, _Alloc>& __x,
const dynamic_bitset<_WordT, _Alloc>& __y)
{
dynamic_bitset<_WordT, _Alloc> __result(__x);
__result |= __y;
return __result;
}
template <typename _WordT, typename _Alloc>
inline dynamic_bitset<_WordT, _Alloc>
operator^(const dynamic_bitset<_WordT, _Alloc>& __x,
const dynamic_bitset<_WordT, _Alloc>& __y)
{
dynamic_bitset<_WordT, _Alloc> __result(__x);
__result ^= __y;
return __result;
}
template <typename _WordT, typename _Alloc>
inline dynamic_bitset<_WordT, _Alloc>
operator-(const dynamic_bitset<_WordT, _Alloc>& __x,
const dynamic_bitset<_WordT, _Alloc>& __y)
{
dynamic_bitset<_WordT, _Alloc> __result(__x);
__result -= __y;
return __result;
}
//@}
/// Stream output operator for dynamic_bitset.
template <typename _CharT, typename _Traits,
typename _WordT, typename _Alloc>
inline std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const dynamic_bitset<_WordT, _Alloc>& __x)
{
std::basic_string<_CharT, _Traits> __tmp;
const ctype<_CharT>& __ct = use_facet<ctype<_CharT>>(__os.getloc());
__x._M_copy_to_string(__tmp, __ct.widen('0'), __ct.widen('1'));
return __os << __tmp;
}
/**
* @}
*/
} // tr2
_GLIBCXX_END_NAMESPACE_VERSION
} // std
#include <tr2/dynamic_bitset.tcc>
#endif /* _GLIBCXX_TR2_DYNAMIC_BITSET */
c++/8/tr2/bool_set.tcc 0000644 00000020177 15201526705 0010305 0 ustar 00 // TR2 <bool_set> support files -*- C++ -*-
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file tr2/bool_set.tcc
* This is a TR2 C++ Library header.
*/
#ifndef _GLIBCXX_TR2_BOOL_SET_TCC
#define _GLIBCXX_TR2_BOOL_SET_TCC 1
#pragma GCC system_header
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
namespace tr2
{
bool_set::_Bool_set_val
bool_set::_S_not[4] =
{ _S_true_, _S_false, _S_indet, _S_empty };
bool_set::_Bool_set_val
bool_set::_S_xor[4][4] =
{ { _S_false, _S_true_, _S_indet, _S_empty },
{ _S_true_, _S_false, _S_indet, _S_empty },
{ _S_indet, _S_indet, _S_indet, _S_empty },
{ _S_empty, _S_empty, _S_empty, _S_empty } };
bool_set::_Bool_set_val
bool_set::_S_or[4][4] =
{ { _S_false, _S_true_, _S_indet, _S_empty },
{ _S_true_, _S_true_, _S_true_, _S_empty },
{ _S_indet, _S_true_, _S_indet, _S_empty },
{ _S_empty, _S_empty, _S_empty, _S_empty } };
bool_set::_Bool_set_val
bool_set::_S_and[4][4] =
{ { _S_false, _S_false, _S_false, _S_empty },
{ _S_false, _S_true_, _S_indet, _S_empty },
{ _S_false, _S_indet, _S_indet, _S_empty },
{ _S_empty, _S_empty, _S_empty, _S_empty } };
bool_set::_Bool_set_val
bool_set::_S_eq[4][4] =
{ { _S_true_, _S_false, _S_indet, _S_empty },
{ _S_false, _S_true_, _S_indet, _S_empty },
{ _S_indet, _S_indet, _S_indet, _S_empty },
{ _S_empty, _S_empty, _S_empty, _S_empty } };
}
_GLIBCXX_END_NAMESPACE_VERSION
}
// I object to these things.
// The stuff in locale facets are for basic types.
// I think we could hack operator<< and operator>>.
/**
* @brief Numeric parsing.
*
* Parses the input stream into the bool @a v. It does so by calling
* num_get::do_get().
*
* If ios_base::boolalpha is set, attempts to read
* ctype<CharT>::truename() or ctype<CharT>::falsename(). Sets
* @a v to true or false if successful. Sets err to
* ios_base::failbit if reading the string fails. Sets err to
* ios_base::eofbit if the stream is emptied.
*
* If ios_base::boolalpha is not set, proceeds as with reading a long,
* except if the value is 1, sets @a v to true, if the value is 0, sets
* @a v to false, and otherwise set err to ios_base::failbit.
*
* @param in Start of input stream.
* @param end End of input stream.
* @param io Source of locale and flags.
* @param err Error flags to set.
* @param v Value to format and insert.
* @return Iterator after reading.
iter_type
get(iter_type __in, iter_type __end, ios_base& __io,
ios_base::iostate& __err, bool& __v) const
{ return this->do_get(__in, __end, __io, __err, __v); }
*/
/*
template<typename _CharT, typename _InIter>
_InIter
num_get<_CharT, _InIter>::
do_get(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, bool_set& __v) const
{
if (!(__io.flags() & ios_base::boolalpha))
{
// Parse bool values as long.
// NB: We can't just call do_get(long) here, as it might
// refer to a derived class.
long __l = -1;
__beg = _M_extract_int(__beg, __end, __io, __err, __l);
if (__c >= _S_false && __c < _S_empty)
__b._M_b = static_cast<_Bool_set_val>(__c);
else
{
// What should we do here?
__v = true;
__err = ios_base::failbit;
if (__beg == __end)
__err |= ios_base::eofbit;
}
}
else
{
// Parse bool values as alphanumeric.
typedef __numpunct_cache<_CharT> __cache_type;
__use_cache<__cache_type> __uc;
const locale& __loc = __io._M_getloc();
const __cache_type* __lc = __uc(__loc);
bool __testf = true;
bool __testt = true;
bool __donef = __lc->_M_falsename_size == 0;
bool __donet = __lc->_M_truename_size == 0;
bool __testeof = false;
size_t __n = 0;
while (!__donef || !__donet)
{
if (__beg == __end)
{
__testeof = true;
break;
}
const char_type __c = *__beg;
if (!__donef)
__testf = __c == __lc->_M_falsename[__n];
if (!__testf && __donet)
break;
if (!__donet)
__testt = __c == __lc->_M_truename[__n];
if (!__testt && __donef)
break;
if (!__testt && !__testf)
break;
++__n;
++__beg;
__donef = !__testf || __n >= __lc->_M_falsename_size;
__donet = !__testt || __n >= __lc->_M_truename_size;
}
if (__testf && __n == __lc->_M_falsename_size && __n)
{
__v = false;
if (__testt && __n == __lc->_M_truename_size)
__err = ios_base::failbit;
else
__err = __testeof ? ios_base::eofbit : ios_base::goodbit;
}
else if (__testt && __n == __lc->_M_truename_size && __n)
{
__v = true;
__err = __testeof ? ios_base::eofbit : ios_base::goodbit;
}
else
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 23. Num_get overflow result.
__v = false;
__err = ios_base::failbit;
if (__testeof)
__err |= ios_base::eofbit;
}
}
return __beg;
}
*/
/**
* @brief Numeric formatting.
*
* Formats the boolean @a v and inserts it into a stream. It does so
* by calling num_put::do_put().
*
* If ios_base::boolalpha is set, writes ctype<CharT>::truename() or
* ctype<CharT>::falsename(). Otherwise formats @a v as an int.
*
* @param s Stream to write to.
* @param io Source of locale and flags.
* @param fill Char_type to use for filling.
* @param v Value to format and insert.
* @return Iterator after writing.
iter_type
put(iter_type __s, ios_base& __f, char_type __fill, bool __v) const
{ return this->do_put(__s, __f, __fill, __v); }
*/
/*
template<typename _CharT, typename _OutIter>
_OutIter
num_put<_CharT, _OutIter>::
do_put(iter_type __s, ios_base& __io, char_type __fill, bool_set __v) const
{
const ios_base::fmtflags __flags = __io.flags();
if ((__flags & ios_base::boolalpha) == 0)
{
const long __l = __v;
__s = _M_insert_int(__s, __io, __fill, __l);
}
else
{
typedef __numpunct_cache<_CharT> __cache_type;
__use_cache<__cache_type> __uc;
const locale& __loc = __io._M_getloc();
const __cache_type* __lc = __uc(__loc);
const _CharT* __name = __v ? __lc->_M_truename
: __lc->_M_falsename;
int __len = __v ? __lc->_M_truename_size
: __lc->_M_falsename_size;
const streamsize __w = __io.width();
if (__w > static_cast<streamsize>(__len))
{
const streamsize __plen = __w - __len;
_CharT* __ps
= static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
* __plen));
char_traits<_CharT>::assign(__ps, __plen, __fill);
__io.width(0);
if ((__flags & ios_base::adjustfield) == ios_base::left)
{
__s = std::__write(__s, __name, __len);
__s = std::__write(__s, __ps, __plen);
}
else
{
__s = std::__write(__s, __ps, __plen);
__s = std::__write(__s, __name, __len);
}
return __s;
}
__io.width(0);
__s = std::__write(__s, __name, __len);
}
return __s;
}
*/
#endif // _GLIBCXX_TR2_BOOL_SET_TCC
c++/8/tr2/type_traits 0000644 00000005213 15201526705 0010270 0 ustar 00 // TR2 <type_traits> -*- C++ -*-
// Copyright (C) 2011-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file tr2/type_traits
* This is a TR2 C++ Library header.
*/
#ifndef _GLIBCXX_TR2_TYPE_TRAITS
#define _GLIBCXX_TR2_TYPE_TRAITS 1
#pragma GCC system_header
#include <type_traits>
#include <bits/c++config.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
namespace tr2
{
/**
* @addtogroup metaprogramming
* @{
*/
/**
* See N2965: Type traits and base classes
* by Michael Spertus
*/
/**
* Simple typelist. Compile-time list of types.
*/
template<typename... _Elements>
struct __reflection_typelist;
/// Specialization for an empty typelist.
template<>
struct __reflection_typelist<>
{
typedef std::true_type empty;
};
/// Partial specialization.
template<typename _First, typename... _Rest>
struct __reflection_typelist<_First, _Rest...>
{
typedef std::false_type empty;
struct first
{
typedef _First type;
};
struct rest
{
typedef __reflection_typelist<_Rest...> type;
};
};
/// Sequence abstraction metafunctions for manipulating a typelist.
/// Enumerate all the base classes of a class. Form of a typelist.
template<typename _Tp>
struct bases
{
typedef __reflection_typelist<__bases(_Tp)...> type;
};
/// Enumerate all the direct base classes of a class. Form of a typelist.
template<typename _Tp>
struct direct_bases
{
typedef __reflection_typelist<__direct_bases(_Tp)...> type;
};
/// @} group metaprogramming
}
_GLIBCXX_END_NAMESPACE_VERSION
}
#endif // _GLIBCXX_TR2_TYPE_TRAITS
c++/8/tr2/dynamic_bitset.tcc 0000644 00000021335 15201526705 0011472 0 ustar 00 // TR2 <dynamic_bitset> -*- C++ -*-
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file tr2/dynamic_bitset.tcc
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{tr2/dynamic_bitset}
*/
#ifndef _GLIBCXX_TR2_DYNAMIC_BITSET_TCC
#define _GLIBCXX_TR2_DYNAMIC_BITSET_TCC 1
#pragma GCC system_header
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
namespace tr2
{
// Definitions of non-inline functions from __dynamic_bitset_base.
template<typename _WordT, typename _Alloc>
void
__dynamic_bitset_base<_WordT, _Alloc>::_M_do_left_shift(size_t __shift)
{
if (__builtin_expect(__shift != 0, 1))
{
const size_t __wshift = __shift / _S_bits_per_block;
const size_t __offset = __shift % _S_bits_per_block;
if (__offset == 0)
for (size_t __n = this->_M_w.size() - 1; __n >= __wshift; --__n)
this->_M_w[__n] = this->_M_w[__n - __wshift];
else
{
const size_t __sub_offset = _S_bits_per_block - __offset;
for (size_t __n = _M_w.size() - 1; __n > __wshift; --__n)
this->_M_w[__n] = ((this->_M_w[__n - __wshift] << __offset)
| (this->_M_w[__n - __wshift - 1] >> __sub_offset));
this->_M_w[__wshift] = this->_M_w[0] << __offset;
}
//// std::fill(this->_M_w.begin(), this->_M_w.begin() + __wshift,
//// static_cast<_WordT>(0));
}
}
template<typename _WordT, typename _Alloc>
void
__dynamic_bitset_base<_WordT, _Alloc>::_M_do_right_shift(size_t __shift)
{
if (__builtin_expect(__shift != 0, 1))
{
const size_t __wshift = __shift / _S_bits_per_block;
const size_t __offset = __shift % _S_bits_per_block;
const size_t __limit = this->_M_w.size() - __wshift - 1;
if (__offset == 0)
for (size_t __n = 0; __n <= __limit; ++__n)
this->_M_w[__n] = this->_M_w[__n + __wshift];
else
{
const size_t __sub_offset = (_S_bits_per_block
- __offset);
for (size_t __n = 0; __n < __limit; ++__n)
this->_M_w[__n] = ((this->_M_w[__n + __wshift] >> __offset)
| (this->_M_w[__n + __wshift + 1] << __sub_offset));
this->_M_w[__limit] = this->_M_w[_M_w.size()-1] >> __offset;
}
////std::fill(this->_M_w.begin() + __limit + 1, this->_M_w.end(),
//// static_cast<_WordT>(0));
}
}
template<typename _WordT, typename _Alloc>
unsigned long
__dynamic_bitset_base<_WordT, _Alloc>::_M_do_to_ulong() const
{
size_t __n = sizeof(unsigned long) / sizeof(block_type);
for (size_t __i = __n; __i < this->_M_w.size(); ++__i)
if (this->_M_w[__i])
__throw_overflow_error(__N("__dynamic_bitset_base::_M_do_to_ulong"));
unsigned long __res = 0UL;
for (size_t __i = 0; __i < __n && __i < this->_M_w.size(); ++__i)
__res += this->_M_w[__i] << (__i * _S_bits_per_block);
return __res;
}
template<typename _WordT, typename _Alloc>
unsigned long long
__dynamic_bitset_base<_WordT, _Alloc>::_M_do_to_ullong() const
{
size_t __n = sizeof(unsigned long long) / sizeof(block_type);
for (size_t __i = __n; __i < this->_M_w.size(); ++__i)
if (this->_M_w[__i])
__throw_overflow_error(__N("__dynamic_bitset_base::_M_do_to_ullong"));
unsigned long long __res = 0ULL;
for (size_t __i = 0; __i < __n && __i < this->_M_w.size(); ++__i)
__res += this->_M_w[__i] << (__i * _S_bits_per_block);
return __res;
}
template<typename _WordT, typename _Alloc>
size_t
__dynamic_bitset_base<_WordT, _Alloc>
::_M_do_find_first(size_t __not_found) const
{
for (size_t __i = 0; __i < this->_M_w.size(); ++__i)
{
_WordT __thisword = this->_M_w[__i];
if (__thisword != static_cast<_WordT>(0))
return (__i * _S_bits_per_block
+ __builtin_ctzll(__thisword));
}
// not found, so return an indication of failure.
return __not_found;
}
template<typename _WordT, typename _Alloc>
size_t
__dynamic_bitset_base<_WordT, _Alloc>
::_M_do_find_next(size_t __prev, size_t __not_found) const
{
// make bound inclusive
++__prev;
// check out of bounds
if (__prev >= this->_M_w.size() * _S_bits_per_block)
return __not_found;
// search first word
size_t __i = _S_whichword(__prev);
_WordT __thisword = this->_M_w[__i];
// mask off bits below bound
__thisword &= (~static_cast<_WordT>(0)) << _S_whichbit(__prev);
if (__thisword != static_cast<_WordT>(0))
return (__i * _S_bits_per_block
+ __builtin_ctzll(__thisword));
// check subsequent words
for (++__i; __i < this->_M_w.size(); ++__i)
{
__thisword = this->_M_w[__i];
if (__thisword != static_cast<_WordT>(0))
return (__i * _S_bits_per_block
+ __builtin_ctzll(__thisword));
}
// not found, so return an indication of failure.
return __not_found;
} // end _M_do_find_next
// Definitions of non-inline member functions.
template<typename _WordT, typename _Alloc>
template<typename _Traits, typename _CharT>
void
dynamic_bitset<_WordT, _Alloc>::
_M_copy_from_ptr(const _CharT* __str, size_t __len,
size_t __pos, size_t __n, _CharT __zero, _CharT __one)
{
reset();
const size_t __nbits = std::min(_M_Nb, std::min(__n, __len - __pos));
for (size_t __i = __nbits; __i > 0; --__i)
{
const _CharT __c = __str[__pos + __nbits - __i];
if (_Traits::eq(__c, __zero))
;
else if (_Traits::eq(__c, __one))
_M_unchecked_set(__i - 1);
else
__throw_invalid_argument(__N("dynamic_bitset::_M_copy_from_ptr"));
}
}
/**
* @brief Stream input operator for dynamic_bitset.
* @ingroup dynamic_bitset
*
* Input will skip whitespace and only accept '0' and '1' characters.
* The %dynamic_bitset will grow as necessary to hold the string of bits.
*/
template<typename _CharT, typename _Traits,
typename _WordT, typename _Alloc>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
dynamic_bitset<_WordT, _Alloc>& __x)
{
typedef typename _Traits::char_type char_type;
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
std::basic_string<_CharT, _Traits> __tmp;
__tmp.reserve(__x.size());
const char_type __zero = __is.widen('0');
const char_type __one = __is.widen('1');
typename __ios_base::iostate __state = __ios_base::goodbit;
typename __istream_type::sentry __sentry(__is);
if (__sentry)
{
__try
{
while (1)
{
static typename _Traits::int_type __eof = _Traits::eof();
typename _Traits::int_type __c1 = __is.rdbuf()->sbumpc();
if (_Traits::eq_int_type(__c1, __eof))
{
__state |= __ios_base::eofbit;
break;
}
else
{
const char_type __c2 = _Traits::to_char_type(__c1);
if (_Traits::eq(__c2, __zero))
__tmp.push_back(__zero);
else if (_Traits::eq(__c2, __one))
__tmp.push_back(__one);
else if (_Traits::
eq_int_type(__is.rdbuf()->sputbackc(__c2),
__eof))
{
__state |= __ios_base::failbit;
break;
}
else
break;
}
}
}
__catch(__cxxabiv1::__forced_unwind&)
{
__is._M_setstate(__ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ __is._M_setstate(__ios_base::badbit); }
}
__x.resize(__tmp.size());
if (__tmp.empty() && __x.size())
__state |= __ios_base::failbit;
else
__x._M_copy_from_string(__tmp, static_cast<size_t>(0), __x.size(),
__zero, __one);
if (__state)
__is.setstate(__state);
return __is;
}
} // tr2
_GLIBCXX_END_NAMESPACE_VERSION
} // std
#endif /* _GLIBCXX_TR2_DYNAMIC_BITSET_TCC */
c++/8/tr2/ratio 0000644 00000004122 15201526705 0007035 0 ustar 00 // TR2 <ratio> -*- C++ -*-
// Copyright (C) 2010-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file tr2/ratio
* This is a TR2 C++ Library header.
*/
#include <ratio>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
namespace tr2
{
template<intmax_t _Pn, size_t _Bit,
bool = _Bit < static_cast<size_t>
(std::numeric_limits<intmax_t>::digits)>
struct __safe_lshift
{ static const intmax_t __value = 0; };
template<intmax_t _Pn, size_t _Bit>
struct __safe_lshift<_Pn, _Bit, true>
{ static const intmax_t __value = _Pn << _Bit; };
/// Add binary prefixes (IEC 60027-2 A.2 and ISO/IEC 80000).
typedef ratio<__safe_lshift<1, 10>::__value, 1> kibi;
typedef ratio<__safe_lshift<1, 20>::__value, 1> mebi;
typedef ratio<__safe_lshift<1, 30>::__value, 1> gibi;
typedef ratio<__safe_lshift<1, 40>::__value, 1> tebi;
typedef ratio<__safe_lshift<1, 50>::__value, 1> pebi;
typedef ratio<__safe_lshift<1, 60>::__value, 1> exbi;
//typedef ratio<__safe_lshift<1, 70>::__value, 1> zebi;
//typedef ratio<__safe_lshift<1, 80>::__value, 1> yobi;
}
_GLIBCXX_END_NAMESPACE_VERSION
}
c++/8/tr2/bool_set 0000644 00000016312 15201526705 0007531 0 ustar 00 // TR2 <bool_set> -*- C++ -*-
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file tr2/bool_set
* This is a TR2 C++ Library header.
*/
#ifndef _GLIBCXX_TR2_BOOL_SET
#define _GLIBCXX_TR2_BOOL_SET 1
#pragma GCC system_header
#include <typeinfo>
#include <iostream>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
namespace tr2
{
/**
* bool_set
*
* See N2136, Bool_set: multi-valued logic
* by Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion.
*
* The implicit conversion to bool is slippery! I may use the new
* explicit conversion. This has been specialized in the language
* so that in contexts requiring a bool the conversion happens
* implicitly. Thus most objections should be eliminated.
*/
class bool_set
{
public:
/// Default constructor.
constexpr bool_set() : _M_b(_S_false) { }
/// Constructor from bool.
constexpr bool_set(bool __t) : _M_b(_Bool_set_val(__t)) { }
// I'm not sure about this.
bool contains(bool_set __b) const
{ return this->is_singleton() && this->equals(__b); }
/// Return true if states are equal.
bool equals(bool_set __b) const
{ return __b._M_b == _M_b; }
/// Return true if this is empty.
bool is_emptyset() const
{ return _M_b == _S_empty; }
/// Return true if this is indeterminate.
bool is_indeterminate() const
{ return _M_b == _S_indet; }
/// Return true if this is false or true (normal boolean).
bool is_singleton() const
{ return _M_b == _S_false || _M_b == _S_true_; }
/// Conversion to bool.
//explicit
operator bool() const
{
if (! is_singleton())
throw std::bad_cast();
return _M_b;
}
///
static bool_set indeterminate()
{
bool_set __b;
__b._M_b = _S_indet;
return __b;
}
///
static bool_set emptyset()
{
bool_set __b;
__b._M_b = _S_empty;
return __b;
}
friend bool_set
operator!(bool_set __b)
{ return __b._M_not(); }
friend bool_set
operator^(bool_set __s, bool_set __t)
{ return __s._M_xor(__t); }
friend bool_set
operator|(bool_set __s, bool_set __t)
{ return __s._M_or(__t); }
friend bool_set
operator&(bool_set __s, bool_set __t)
{ return __s._M_and(__t); }
friend bool_set
operator==(bool_set __s, bool_set __t)
{ return __s._M_eq(__t); }
// These overloads replace the facet additions in the paper!
template<typename CharT, typename Traits>
friend std::basic_ostream<CharT, Traits>&
operator<<(std::basic_ostream<CharT, Traits>& __out, bool_set __b)
{
int __a = __b._M_b;
__out << __a;
}
template<typename CharT, typename Traits>
friend std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& __in, bool_set& __b)
{
long __c;
__in >> __c;
if (__c >= _S_false && __c < _S_empty)
__b._M_b = static_cast<_Bool_set_val>(__c);
}
private:
///
enum _Bool_set_val: unsigned char
{
_S_false = 0,
_S_true_ = 1,
_S_indet = 2,
_S_empty = 3
};
/// Bool set state.
_Bool_set_val _M_b;
///
bool_set(_Bool_set_val __c) : _M_b(__c) { }
///
bool_set _M_not() const
{ return _S_not[this->_M_b]; }
///
bool_set _M_xor(bool_set __b) const
{ return _S_xor[this->_M_b][__b._M_b]; }
///
bool_set _M_or(bool_set __b) const
{ return _S_or[this->_M_b][__b._M_b]; }
///
bool_set _M_and(bool_set __b) const
{ return _S_and[this->_M_b][__b._M_b]; }
///
bool_set _M_eq(bool_set __b) const
{ return _S_eq[this->_M_b][__b._M_b]; }
///
static _Bool_set_val _S_not[4];
///
static _Bool_set_val _S_xor[4][4];
///
static _Bool_set_val _S_or[4][4];
///
static _Bool_set_val _S_and[4][4];
///
static _Bool_set_val _S_eq[4][4];
};
// 20.2.3.2 bool_set values
inline bool
contains(bool_set __s, bool_set __t)
{ return __s.contains(__t); }
inline bool
equals(bool_set __s, bool_set __t)
{ return __s.equals(__t); }
inline bool
is_emptyset(bool_set __b)
{ return __b.is_emptyset(); }
inline bool
is_indeterminate(bool_set __b)
{ return __b.is_indeterminate(); }
inline bool
is_singleton(bool_set __b)
{ return __b.is_singleton(); }
inline bool
certainly(bool_set __b)
{ return ! __b.contains(false); }
inline bool
possibly(bool_set __b)
{ return __b.contains(true); }
// 20.2.3.3 bool_set set operations
inline bool_set
set_union(bool __s, bool_set __t)
{ return bool_set(__s) | __t; }
inline bool_set
set_union(bool_set __s, bool __t)
{ return __s | bool_set(__t); }
inline bool_set
set_union(bool_set __s, bool_set __t)
{ return __s | __t; }
inline bool_set
set_intersection(bool __s, bool_set __t)
{ return bool_set(__s) & __t; }
inline bool_set
set_intersection(bool_set __s, bool __t)
{ return __s & bool_set(__t); }
inline bool_set
set_intersection(bool_set __s, bool_set __t)
{ return __s & __t; }
inline bool_set
set_complement(bool_set __b)
{ return ! __b; }
// 20.2.3.4 bool_set logical operators
inline bool_set
operator^(bool __s, bool_set __t)
{ return bool_set(__s) ^ __t; }
inline bool_set
operator^(bool_set __s, bool __t)
{ return __s ^ bool_set(__t); }
inline bool_set
operator|(bool __s, bool_set __t)
{ return bool_set(__s) | __t; }
inline bool_set
operator|(bool_set __s, bool __t)
{ return __s | bool_set(__t); }
inline bool_set
operator&(bool __s, bool_set __t)
{ return bool_set(__s) & __t; }
inline bool_set
operator&(bool_set __s, bool __t)
{ return __s & bool_set(__t); }
// 20.2.3.5 bool_set relational operators
inline bool_set
operator==(bool __s, bool_set __t)
{ return bool_set(__s) == __t; }
inline bool_set
operator==(bool_set __s, bool __t)
{ return __s == bool_set(__t); }
inline bool_set
operator!=(bool __s, bool_set __t)
{ return ! (__s == __t); }
inline bool_set
operator!=(bool_set __s, bool __t)
{ return ! (__s == __t); }
inline bool_set
operator!=(bool_set __s, bool_set __t)
{ return ! (__s == __t); }
}
_GLIBCXX_END_NAMESPACE_VERSION
}
#include <tr2/bool_set.tcc>
#endif // _GLIBCXX_TR2_BOOL_SET
c++/8/ios 0000644 00000003101 15201526705 0005776 0 ustar 00 // Iostreams base classes -*- C++ -*-
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/ios
* This is a Standard C++ Library header.
*/
//
// ISO C++ 14882: 27.4 Iostreams base classes
//
#ifndef _GLIBCXX_IOS
#define _GLIBCXX_IOS 1
#pragma GCC system_header
#include <iosfwd>
#include <exception> // For ios_base::failure
#include <bits/char_traits.h> // For char_traits, streamoff, streamsize, fpos
#include <bits/localefwd.h> // For class locale
#include <bits/ios_base.h> // For ios_base declarations.
#include <streambuf>
#include <bits/basic_ios.h>
#endif /* _GLIBCXX_IOS */
c++/8/thread 0000644 00000024427 15201526705 0006471 0 ustar 00 // <thread> -*- C++ -*-
// Copyright (C) 2008-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/thread
* This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_THREAD
#define _GLIBCXX_THREAD 1
#pragma GCC system_header
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
#include <chrono>
#include <memory>
#include <tuple>
#include <cerrno>
#include <bits/functexcept.h>
#include <bits/functional_hash.h>
#include <bits/invoke.h>
#include <bits/gthr.h>
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @defgroup threads Threads
* @ingroup concurrency
*
* Classes for thread support.
* @{
*/
/// thread
class thread
{
public:
// Abstract base class for types that wrap arbitrary functors to be
// invoked in the new thread of execution.
struct _State
{
virtual ~_State();
virtual void _M_run() = 0;
};
using _State_ptr = unique_ptr<_State>;
typedef __gthread_t native_handle_type;
/// thread::id
class id
{
native_handle_type _M_thread;
public:
id() noexcept : _M_thread() { }
explicit
id(native_handle_type __id) : _M_thread(__id) { }
private:
friend class thread;
friend class hash<thread::id>;
friend bool
operator==(thread::id __x, thread::id __y) noexcept;
friend bool
operator<(thread::id __x, thread::id __y) noexcept;
template<class _CharT, class _Traits>
friend basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __out, thread::id __id);
};
private:
id _M_id;
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2097. packaged_task constructors should be constrained
template<typename _Tp>
using __not_same = __not_<is_same<
typename remove_cv<typename remove_reference<_Tp>::type>::type,
thread>>;
public:
thread() noexcept = default;
template<typename _Callable, typename... _Args,
typename = _Require<__not_same<_Callable>>>
explicit
thread(_Callable&& __f, _Args&&... __args)
{
static_assert( __is_invocable<typename decay<_Callable>::type,
typename decay<_Args>::type...>::value,
"std::thread arguments must be invocable after conversion to rvalues"
);
#ifdef GTHR_ACTIVE_PROXY
// Create a reference to pthread_create, not just the gthr weak symbol.
auto __depend = reinterpret_cast<void(*)()>(&pthread_create);
#else
auto __depend = nullptr;
#endif
_M_start_thread(_S_make_state(
__make_invoker(std::forward<_Callable>(__f),
std::forward<_Args>(__args)...)),
__depend);
}
~thread()
{
if (joinable())
std::terminate();
}
thread(const thread&) = delete;
thread(thread&& __t) noexcept
{ swap(__t); }
thread& operator=(const thread&) = delete;
thread& operator=(thread&& __t) noexcept
{
if (joinable())
std::terminate();
swap(__t);
return *this;
}
void
swap(thread& __t) noexcept
{ std::swap(_M_id, __t._M_id); }
bool
joinable() const noexcept
{ return !(_M_id == id()); }
void
join();
void
detach();
thread::id
get_id() const noexcept
{ return _M_id; }
/** @pre thread is joinable
*/
native_handle_type
native_handle()
{ return _M_id._M_thread; }
// Returns a value that hints at the number of hardware thread contexts.
static unsigned int
hardware_concurrency() noexcept;
private:
template<typename _Callable>
struct _State_impl : public _State
{
_Callable _M_func;
_State_impl(_Callable&& __f) : _M_func(std::forward<_Callable>(__f))
{ }
void
_M_run() { _M_func(); }
};
void
_M_start_thread(_State_ptr, void (*)());
template<typename _Callable>
static _State_ptr
_S_make_state(_Callable&& __f)
{
using _Impl = _State_impl<_Callable>;
return _State_ptr{new _Impl{std::forward<_Callable>(__f)}};
}
#if _GLIBCXX_THREAD_ABI_COMPAT
public:
struct _Impl_base;
typedef shared_ptr<_Impl_base> __shared_base_type;
struct _Impl_base
{
__shared_base_type _M_this_ptr;
virtual ~_Impl_base() = default;
virtual void _M_run() = 0;
};
private:
void
_M_start_thread(__shared_base_type, void (*)());
void
_M_start_thread(__shared_base_type);
#endif
private:
// A call wrapper that does INVOKE(forwarded tuple elements...)
template<typename _Tuple>
struct _Invoker
{
_Tuple _M_t;
template<size_t _Index>
static __tuple_element_t<_Index, _Tuple>&&
_S_declval();
template<size_t... _Ind>
auto
_M_invoke(_Index_tuple<_Ind...>)
noexcept(noexcept(std::__invoke(_S_declval<_Ind>()...)))
-> decltype(std::__invoke(_S_declval<_Ind>()...))
{ return std::__invoke(std::get<_Ind>(std::move(_M_t))...); }
using _Indices
= typename _Build_index_tuple<tuple_size<_Tuple>::value>::__type;
auto
operator()()
noexcept(noexcept(std::declval<_Invoker&>()._M_invoke(_Indices())))
-> decltype(std::declval<_Invoker&>()._M_invoke(_Indices()))
{ return _M_invoke(_Indices()); }
};
template<typename... _Tp>
using __decayed_tuple = tuple<typename std::decay<_Tp>::type...>;
public:
// Returns a call wrapper that stores
// tuple{DECAY_COPY(__callable), DECAY_COPY(__args)...}.
template<typename _Callable, typename... _Args>
static _Invoker<__decayed_tuple<_Callable, _Args...>>
__make_invoker(_Callable&& __callable, _Args&&... __args)
{
return { __decayed_tuple<_Callable, _Args...>{
std::forward<_Callable>(__callable), std::forward<_Args>(__args)...
} };
}
};
inline void
swap(thread& __x, thread& __y) noexcept
{ __x.swap(__y); }
inline bool
operator==(thread::id __x, thread::id __y) noexcept
{
// pthread_equal is undefined if either thread ID is not valid, so we
// can't safely use __gthread_equal on default-constructed values (nor
// the non-zero value returned by this_thread::get_id() for
// single-threaded programs using GNU libc). Assume EqualityComparable.
return __x._M_thread == __y._M_thread;
}
inline bool
operator!=(thread::id __x, thread::id __y) noexcept
{ return !(__x == __y); }
inline bool
operator<(thread::id __x, thread::id __y) noexcept
{
// Pthreads doesn't define any way to do this, so we just have to
// assume native_handle_type is LessThanComparable.
return __x._M_thread < __y._M_thread;
}
inline bool
operator<=(thread::id __x, thread::id __y) noexcept
{ return !(__y < __x); }
inline bool
operator>(thread::id __x, thread::id __y) noexcept
{ return __y < __x; }
inline bool
operator>=(thread::id __x, thread::id __y) noexcept
{ return !(__x < __y); }
// DR 889.
/// std::hash specialization for thread::id.
template<>
struct hash<thread::id>
: public __hash_base<size_t, thread::id>
{
size_t
operator()(const thread::id& __id) const noexcept
{ return std::_Hash_impl::hash(__id._M_thread); }
};
template<class _CharT, class _Traits>
inline basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __out, thread::id __id)
{
if (__id == thread::id())
return __out << "thread::id of a non-executing thread";
else
return __out << __id._M_thread;
}
/** @namespace std::this_thread
* @brief ISO C++ 2011 entities sub-namespace for thread.
* 30.3.2 Namespace this_thread.
*/
namespace this_thread
{
/// get_id
inline thread::id
get_id() noexcept
{
#ifdef __GLIBC__
// For the GNU C library pthread_self() is usable without linking to
// libpthread.so but returns 0, so we cannot use it in single-threaded
// programs, because this_thread::get_id() != thread::id{} must be true.
// We know that pthread_t is an integral type in the GNU C library.
if (!__gthread_active_p())
return thread::id(1);
#endif
return thread::id(__gthread_self());
}
/// yield
inline void
yield() noexcept
{
#ifdef _GLIBCXX_USE_SCHED_YIELD
__gthread_yield();
#endif
}
void
__sleep_for(chrono::seconds, chrono::nanoseconds);
/// sleep_for
template<typename _Rep, typename _Period>
inline void
sleep_for(const chrono::duration<_Rep, _Period>& __rtime)
{
if (__rtime <= __rtime.zero())
return;
auto __s = chrono::duration_cast<chrono::seconds>(__rtime);
auto __ns = chrono::duration_cast<chrono::nanoseconds>(__rtime - __s);
#ifdef _GLIBCXX_USE_NANOSLEEP
__gthread_time_t __ts =
{
static_cast<std::time_t>(__s.count()),
static_cast<long>(__ns.count())
};
while (::nanosleep(&__ts, &__ts) == -1 && errno == EINTR)
{ }
#else
__sleep_for(__s, __ns);
#endif
}
/// sleep_until
template<typename _Clock, typename _Duration>
inline void
sleep_until(const chrono::time_point<_Clock, _Duration>& __atime)
{
auto __now = _Clock::now();
if (_Clock::is_steady)
{
if (__now < __atime)
sleep_for(__atime - __now);
return;
}
while (__now < __atime)
{
sleep_for(__atime - __now);
__now = _Clock::now();
}
}
}
// @} group threads
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
#endif // C++11
#endif // _GLIBCXX_THREAD
c++/8/clocale 0000644 00000003561 15201526705 0006620 0 ustar 00 // -*- C++ -*- forwarding header.
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file clocale
* This is a Standard C++ Library file. You should @c \#include this file
* in your programs, rather than any of the @a *.h implementation files.
*
* This is the C++ version of the Standard C Library header @c locale.h,
* and its contents are (mostly) the same as that header, but are all
* contained in the namespace @c std (except for names which are defined
* as macros in C).
*/
//
// ISO C++ 14882: 18.2.2 Implementation properties: C library
//
#pragma GCC system_header
#include <bits/c++config.h>
#include <locale.h>
#ifndef _GLIBCXX_CLOCALE
#define _GLIBCXX_CLOCALE 1
// Get rid of those macros defined in <locale.h> in lieu of real functions.
#undef setlocale
#undef localeconv
namespace std
{
using ::lconv;
using ::setlocale;
using ::localeconv;
} // namespace std
#endif
c++/8/cerrno 0000644 00000003352 15201526705 0006504 0 ustar 00 // The -*- C++ -*- forwarding header.
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file cerrno
* This is a Standard C++ Library file. You should @c \#include this file
* in your programs, rather than any of the @a *.h implementation files.
*
* This is the C++ version of the Standard C Library header @c errno.h,
* and its contents are (mostly) the same as that header, but are all
* contained in the namespace @c std (except for names which are defined
* as macros in C).
*/
//
// ISO C++ 14882: 19.3 Error numbers
//
#pragma GCC system_header
#include <bits/c++config.h>
#include <errno.h>
#ifndef _GLIBCXX_CERRNO
#define _GLIBCXX_CERRNO 1
// Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998
#ifndef errno
#define errno errno
#endif
#endif
c++/8/stdlib.h 0000644 00000004310 15201526705 0006716 0 ustar 00 // -*- C++ -*- compatibility header.
// Copyright (C) 2002-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file stdlib.h
* This is a Standard C++ Library header.
*/
#if !defined __cplusplus || defined _GLIBCXX_INCLUDE_NEXT_C_HEADERS
# include_next <stdlib.h>
#else
#ifndef _GLIBCXX_STDLIB_H
#define _GLIBCXX_STDLIB_H 1
# include <cstdlib>
using std::abort;
using std::atexit;
using std::exit;
#if __cplusplus >= 201103L
# ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT
using std::at_quick_exit;
# endif
# ifdef _GLIBCXX_HAVE_QUICK_EXIT
using std::quick_exit;
# endif
#endif
#if _GLIBCXX_HOSTED
using std::div_t;
using std::ldiv_t;
using std::abs;
using std::atof;
using std::atoi;
using std::atol;
using std::bsearch;
using std::calloc;
using std::div;
using std::free;
using std::getenv;
using std::labs;
using std::ldiv;
using std::malloc;
#ifdef _GLIBCXX_HAVE_MBSTATE_T
using std::mblen;
using std::mbstowcs;
using std::mbtowc;
#endif // _GLIBCXX_HAVE_MBSTATE_T
using std::qsort;
using std::rand;
using std::realloc;
using std::srand;
using std::strtod;
using std::strtol;
using std::strtoul;
using std::system;
#ifdef _GLIBCXX_USE_WCHAR_T
using std::wcstombs;
using std::wctomb;
#endif // _GLIBCXX_USE_WCHAR_T
#endif
#endif // _GLIBCXX_STDLIB_H
#endif // __cplusplus
c++/8/cxxabi.h 0000644 00000052731 15201526705 0006725 0 ustar 00 // ABI Support -*- C++ -*-
// Copyright (C) 2000-2018 Free Software Foundation, Inc.
//
// This file is part of GCC.
//
// GCC is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// GCC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Written by Nathan Sidwell, Codesourcery LLC, <nathan@codesourcery.com>
/* This file declares the new abi entry points into the runtime. It is not
normally necessary for user programs to include this header, or use the
entry points directly. However, this header is available should that be
needed.
Some of the entry points are intended for both C and C++, thus this header
is includable from both C and C++. Though the C++ specific parts are not
available in C, naturally enough. */
/** @file cxxabi.h
* The header provides an interface to the C++ ABI.
*/
#ifndef _CXXABI_H
#define _CXXABI_H 1
#pragma GCC system_header
#pragma GCC visibility push(default)
#include <stddef.h>
#include <bits/c++config.h>
#include <bits/cxxabi_tweaks.h>
#include <bits/cxxabi_forced.h>
#include <bits/cxxabi_init_exception.h>
#ifdef __cplusplus
namespace __cxxabiv1
{
extern "C"
{
#endif
typedef __cxa_cdtor_return_type (*__cxa_cdtor_type)(void *);
// Allocate array.
void*
__cxa_vec_new(size_t __element_count, size_t __element_size,
size_t __padding_size, __cxa_cdtor_type __constructor,
__cxa_cdtor_type __destructor);
void*
__cxa_vec_new2(size_t __element_count, size_t __element_size,
size_t __padding_size, __cxa_cdtor_type __constructor,
__cxa_cdtor_type __destructor, void *(*__alloc) (size_t),
void (*__dealloc) (void*));
void*
__cxa_vec_new3(size_t __element_count, size_t __element_size,
size_t __padding_size, __cxa_cdtor_type __constructor,
__cxa_cdtor_type __destructor, void *(*__alloc) (size_t),
void (*__dealloc) (void*, size_t));
// Construct array.
__cxa_vec_ctor_return_type
__cxa_vec_ctor(void* __array_address, size_t __element_count,
size_t __element_size, __cxa_cdtor_type __constructor,
__cxa_cdtor_type __destructor);
__cxa_vec_ctor_return_type
__cxa_vec_cctor(void* __dest_array, void* __src_array,
size_t __element_count, size_t __element_size,
__cxa_cdtor_return_type (*__constructor) (void*, void*),
__cxa_cdtor_type __destructor);
// Destruct array.
void
__cxa_vec_dtor(void* __array_address, size_t __element_count,
size_t __element_size, __cxa_cdtor_type __destructor);
void
__cxa_vec_cleanup(void* __array_address, size_t __element_count, size_t __s,
__cxa_cdtor_type __destructor) _GLIBCXX_NOTHROW;
// Destruct and release array.
void
__cxa_vec_delete(void* __array_address, size_t __element_size,
size_t __padding_size, __cxa_cdtor_type __destructor);
void
__cxa_vec_delete2(void* __array_address, size_t __element_size,
size_t __padding_size, __cxa_cdtor_type __destructor,
void (*__dealloc) (void*));
void
__cxa_vec_delete3(void* __array_address, size_t __element_size,
size_t __padding_size, __cxa_cdtor_type __destructor,
void (*__dealloc) (void*, size_t));
int
__cxa_guard_acquire(__guard*);
void
__cxa_guard_release(__guard*) _GLIBCXX_NOTHROW;
void
__cxa_guard_abort(__guard*) _GLIBCXX_NOTHROW;
// DSO destruction.
int
__cxa_atexit(void (*)(void*), void*, void*) _GLIBCXX_NOTHROW;
int
__cxa_finalize(void*);
// TLS destruction.
int
__cxa_thread_atexit(void (*)(void*), void*, void *) _GLIBCXX_NOTHROW;
// Pure virtual functions.
void
__cxa_pure_virtual(void) __attribute__ ((__noreturn__));
void
__cxa_deleted_virtual(void) __attribute__ ((__noreturn__));
// Exception handling auxiliary.
void
__cxa_bad_cast() __attribute__((__noreturn__));
void
__cxa_bad_typeid() __attribute__((__noreturn__));
void
__cxa_throw_bad_array_new_length() __attribute__((__noreturn__));
/**
* @brief Demangling routine.
* ABI-mandated entry point in the C++ runtime library for demangling.
*
* @param __mangled_name A NUL-terminated character string
* containing the name to be demangled.
*
* @param __output_buffer A region of memory, allocated with
* malloc, of @a *__length bytes, into which the demangled name is
* stored. If @a __output_buffer is not long enough, it is
* expanded using realloc. @a __output_buffer may instead be NULL;
* in that case, the demangled name is placed in a region of memory
* allocated with malloc.
*
* @param __length If @a __length is non-NULL, the length of the
* buffer containing the demangled name is placed in @a *__length.
*
* @param __status @a *__status is set to one of the following values:
* 0: The demangling operation succeeded.
* -1: A memory allocation failure occurred.
* -2: @a mangled_name is not a valid name under the C++ ABI mangling rules.
* -3: One of the arguments is invalid.
*
* @return A pointer to the start of the NUL-terminated demangled
* name, or NULL if the demangling fails. The caller is
* responsible for deallocating this memory using @c free.
*
* The demangling is performed using the C++ ABI mangling rules,
* with GNU extensions. For example, this function is used in
* __gnu_cxx::__verbose_terminate_handler.
*
* See https://gcc.gnu.org/onlinedocs/libstdc++/manual/ext_demangling.html
* for other examples of use.
*
* @note The same demangling functionality is available via
* libiberty (@c <libiberty/demangle.h> and @c libiberty.a) in GCC
* 3.1 and later, but that requires explicit installation (@c
* --enable-install-libiberty) and uses a different API, although
* the ABI is unchanged.
*/
char*
__cxa_demangle(const char* __mangled_name, char* __output_buffer,
size_t* __length, int* __status);
#ifdef __cplusplus
}
} // namespace __cxxabiv1
#endif
#ifdef __cplusplus
#include <typeinfo>
namespace __cxxabiv1
{
// Type information for int, float etc.
class __fundamental_type_info : public std::type_info
{
public:
explicit
__fundamental_type_info(const char* __n) : std::type_info(__n) { }
virtual
~__fundamental_type_info();
};
// Type information for array objects.
class __array_type_info : public std::type_info
{
public:
explicit
__array_type_info(const char* __n) : std::type_info(__n) { }
virtual
~__array_type_info();
};
// Type information for functions (both member and non-member).
class __function_type_info : public std::type_info
{
public:
explicit
__function_type_info(const char* __n) : std::type_info(__n) { }
virtual
~__function_type_info();
protected:
// Implementation defined member function.
virtual bool
__is_function_p() const;
};
// Type information for enumerations.
class __enum_type_info : public std::type_info
{
public:
explicit
__enum_type_info(const char* __n) : std::type_info(__n) { }
virtual
~__enum_type_info();
};
// Common type information for simple pointers and pointers to member.
class __pbase_type_info : public std::type_info
{
public:
unsigned int __flags; // Qualification of the target object.
const std::type_info* __pointee; // Type of pointed to object.
explicit
__pbase_type_info(const char* __n, int __quals,
const std::type_info* __type)
: std::type_info(__n), __flags(__quals), __pointee(__type)
{ }
virtual
~__pbase_type_info();
// Implementation defined type.
enum __masks
{
__const_mask = 0x1,
__volatile_mask = 0x2,
__restrict_mask = 0x4,
__incomplete_mask = 0x8,
__incomplete_class_mask = 0x10,
__transaction_safe_mask = 0x20,
__noexcept_mask = 0x40
};
protected:
__pbase_type_info(const __pbase_type_info&);
__pbase_type_info&
operator=(const __pbase_type_info&);
// Implementation defined member functions.
virtual bool
__do_catch(const std::type_info* __thr_type, void** __thr_obj,
unsigned int __outer) const;
inline virtual bool
__pointer_catch(const __pbase_type_info* __thr_type, void** __thr_obj,
unsigned __outer) const;
};
inline bool __pbase_type_info::
__pointer_catch (const __pbase_type_info *thrown_type,
void **thr_obj,
unsigned outer) const
{
return __pointee->__do_catch (thrown_type->__pointee, thr_obj, outer + 2);
}
// Type information for simple pointers.
class __pointer_type_info : public __pbase_type_info
{
public:
explicit
__pointer_type_info(const char* __n, int __quals,
const std::type_info* __type)
: __pbase_type_info (__n, __quals, __type) { }
virtual
~__pointer_type_info();
protected:
// Implementation defined member functions.
virtual bool
__is_pointer_p() const;
virtual bool
__pointer_catch(const __pbase_type_info* __thr_type, void** __thr_obj,
unsigned __outer) const;
};
class __class_type_info;
// Type information for a pointer to member variable.
class __pointer_to_member_type_info : public __pbase_type_info
{
public:
__class_type_info* __context; // Class of the member.
explicit
__pointer_to_member_type_info(const char* __n, int __quals,
const std::type_info* __type,
__class_type_info* __klass)
: __pbase_type_info(__n, __quals, __type), __context(__klass) { }
virtual
~__pointer_to_member_type_info();
protected:
__pointer_to_member_type_info(const __pointer_to_member_type_info&);
__pointer_to_member_type_info&
operator=(const __pointer_to_member_type_info&);
// Implementation defined member function.
virtual bool
__pointer_catch(const __pbase_type_info* __thr_type, void** __thr_obj,
unsigned __outer) const;
};
// Helper class for __vmi_class_type.
class __base_class_type_info
{
public:
const __class_type_info* __base_type; // Base class type.
#ifdef _GLIBCXX_LLP64
long long __offset_flags; // Offset and info.
#else
long __offset_flags; // Offset and info.
#endif
enum __offset_flags_masks
{
__virtual_mask = 0x1,
__public_mask = 0x2,
__hwm_bit = 2,
__offset_shift = 8 // Bits to shift offset.
};
// Implementation defined member functions.
bool
__is_virtual_p() const
{ return __offset_flags & __virtual_mask; }
bool
__is_public_p() const
{ return __offset_flags & __public_mask; }
ptrdiff_t
__offset() const
{
// This shift, being of a signed type, is implementation
// defined. GCC implements such shifts as arithmetic, which is
// what we want.
return static_cast<ptrdiff_t>(__offset_flags) >> __offset_shift;
}
};
// Type information for a class.
class __class_type_info : public std::type_info
{
public:
explicit
__class_type_info (const char *__n) : type_info(__n) { }
virtual
~__class_type_info ();
// Implementation defined types.
// The type sub_kind tells us about how a base object is contained
// within a derived object. We often do this lazily, hence the
// UNKNOWN value. At other times we may use NOT_CONTAINED to mean
// not publicly contained.
enum __sub_kind
{
// We have no idea.
__unknown = 0,
// Not contained within us (in some circumstances this might
// mean not contained publicly)
__not_contained,
// Contained ambiguously.
__contained_ambig,
// Via a virtual path.
__contained_virtual_mask = __base_class_type_info::__virtual_mask,
// Via a public path.
__contained_public_mask = __base_class_type_info::__public_mask,
// Contained within us.
__contained_mask = 1 << __base_class_type_info::__hwm_bit,
__contained_private = __contained_mask,
__contained_public = __contained_mask | __contained_public_mask
};
struct __upcast_result;
struct __dyncast_result;
protected:
// Implementation defined member functions.
virtual bool
__do_upcast(const __class_type_info* __dst_type, void**__obj_ptr) const;
virtual bool
__do_catch(const type_info* __thr_type, void** __thr_obj,
unsigned __outer) const;
public:
// Helper for upcast. See if DST is us, or one of our bases.
// Return false if not found, true if found.
virtual bool
__do_upcast(const __class_type_info* __dst, const void* __obj,
__upcast_result& __restrict __result) const;
// Indicate whether SRC_PTR of type SRC_TYPE is contained publicly
// within OBJ_PTR. OBJ_PTR points to a base object of our type,
// which is the destination type. SRC2DST indicates how SRC
// objects might be contained within this type. If SRC_PTR is one
// of our SRC_TYPE bases, indicate the virtuality. Returns
// not_contained for non containment or private containment.
inline __sub_kind
__find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr,
const __class_type_info* __src_type,
const void* __src_ptr) const;
// Helper for dynamic cast. ACCESS_PATH gives the access from the
// most derived object to this base. DST_TYPE indicates the
// desired type we want. OBJ_PTR points to a base of our type
// within the complete object. SRC_TYPE indicates the static type
// started from and SRC_PTR points to that base within the most
// derived object. Fill in RESULT with what we find. Return true
// if we have located an ambiguous match.
virtual bool
__do_dyncast(ptrdiff_t __src2dst, __sub_kind __access_path,
const __class_type_info* __dst_type, const void* __obj_ptr,
const __class_type_info* __src_type, const void* __src_ptr,
__dyncast_result& __result) const;
// Helper for find_public_subobj. SRC2DST indicates how SRC_TYPE
// bases are inherited by the type started from -- which is not
// necessarily the current type. The current type will be a base
// of the destination type. OBJ_PTR points to the current base.
virtual __sub_kind
__do_find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr,
const __class_type_info* __src_type,
const void* __src_ptr) const;
};
// Type information for a class with a single non-virtual base.
class __si_class_type_info : public __class_type_info
{
public:
const __class_type_info* __base_type;
explicit
__si_class_type_info(const char *__n, const __class_type_info *__base)
: __class_type_info(__n), __base_type(__base) { }
virtual
~__si_class_type_info();
protected:
__si_class_type_info(const __si_class_type_info&);
__si_class_type_info&
operator=(const __si_class_type_info&);
// Implementation defined member functions.
virtual bool
__do_dyncast(ptrdiff_t __src2dst, __sub_kind __access_path,
const __class_type_info* __dst_type, const void* __obj_ptr,
const __class_type_info* __src_type, const void* __src_ptr,
__dyncast_result& __result) const;
virtual __sub_kind
__do_find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr,
const __class_type_info* __src_type,
const void* __sub_ptr) const;
virtual bool
__do_upcast(const __class_type_info*__dst, const void*__obj,
__upcast_result& __restrict __result) const;
};
// Type information for a class with multiple and/or virtual bases.
class __vmi_class_type_info : public __class_type_info
{
public:
unsigned int __flags; // Details about the class hierarchy.
unsigned int __base_count; // Number of direct bases.
// The array of bases uses the trailing array struct hack so this
// class is not constructable with a normal constructor. It is
// internally generated by the compiler.
__base_class_type_info __base_info[1]; // Array of bases.
explicit
__vmi_class_type_info(const char* __n, int ___flags)
: __class_type_info(__n), __flags(___flags), __base_count(0) { }
virtual
~__vmi_class_type_info();
// Implementation defined types.
enum __flags_masks
{
__non_diamond_repeat_mask = 0x1, // Distinct instance of repeated base.
__diamond_shaped_mask = 0x2, // Diamond shaped multiple inheritance.
__flags_unknown_mask = 0x10
};
protected:
// Implementation defined member functions.
virtual bool
__do_dyncast(ptrdiff_t __src2dst, __sub_kind __access_path,
const __class_type_info* __dst_type, const void* __obj_ptr,
const __class_type_info* __src_type, const void* __src_ptr,
__dyncast_result& __result) const;
virtual __sub_kind
__do_find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr,
const __class_type_info* __src_type,
const void* __src_ptr) const;
virtual bool
__do_upcast(const __class_type_info* __dst, const void* __obj,
__upcast_result& __restrict __result) const;
};
// Exception handling forward declarations.
struct __cxa_exception;
struct __cxa_refcounted_exception;
struct __cxa_dependent_exception;
struct __cxa_eh_globals;
extern "C"
{
// Dynamic cast runtime.
// src2dst has the following possible values
// >-1: src_type is a unique public non-virtual base of dst_type
// dst_ptr + src2dst == src_ptr
// -1: unspecified relationship
// -2: src_type is not a public base of dst_type
// -3: src_type is a multiple public non-virtual base of dst_type
void*
__dynamic_cast(const void* __src_ptr, // Starting object.
const __class_type_info* __src_type, // Static type of object.
const __class_type_info* __dst_type, // Desired target type.
ptrdiff_t __src2dst); // How src and dst are related.
// Exception handling runtime.
// The __cxa_eh_globals for the current thread can be obtained by using
// either of the following functions. The "fast" version assumes at least
// one prior call of __cxa_get_globals has been made from the current
// thread, so no initialization is necessary.
__cxa_eh_globals*
__cxa_get_globals() _GLIBCXX_NOTHROW __attribute__ ((__const__));
__cxa_eh_globals*
__cxa_get_globals_fast() _GLIBCXX_NOTHROW __attribute__ ((__const__));
// Free the space allocated for the primary exception.
void
__cxa_free_exception(void*) _GLIBCXX_NOTHROW;
// Throw the exception.
void
__cxa_throw(void*, std::type_info*, void (_GLIBCXX_CDTOR_CALLABI *) (void *))
__attribute__((__noreturn__));
// Used to implement exception handlers.
void*
__cxa_get_exception_ptr(void*) _GLIBCXX_NOTHROW __attribute__ ((__pure__));
void*
__cxa_begin_catch(void*) _GLIBCXX_NOTHROW;
void
__cxa_end_catch();
void
__cxa_rethrow() __attribute__((__noreturn__));
// Returns the type_info for the currently handled exception [15.3/8], or
// null if there is none.
std::type_info*
__cxa_current_exception_type() _GLIBCXX_NOTHROW __attribute__ ((__pure__));
// GNU Extensions.
// Allocate memory for a dependent exception.
__cxa_dependent_exception*
__cxa_allocate_dependent_exception() _GLIBCXX_NOTHROW;
// Free the space allocated for the dependent exception.
void
__cxa_free_dependent_exception(__cxa_dependent_exception*) _GLIBCXX_NOTHROW;
} // extern "C"
// A magic placeholder class that can be caught by reference
// to recognize foreign exceptions.
class __foreign_exception
{
virtual ~__foreign_exception() throw();
virtual void __pure_dummy() = 0; // prevent catch by value
};
} // namespace __cxxabiv1
/** @namespace abi
* @brief The cross-vendor C++ Application Binary Interface. A
* namespace alias to __cxxabiv1, but user programs should use the
* alias 'abi'.
*
* A brief overview of an ABI is given in the libstdc++ FAQ, question
* 5.8 (you may have a copy of the FAQ locally, or you can view the online
* version at http://gcc.gnu.org/onlinedocs/libstdc++/faq.html#5_8 ).
*
* GCC subscribes to a cross-vendor ABI for C++, sometimes
* called the IA64 ABI because it happens to be the native ABI for that
* platform. It is summarized at http://www.codesourcery.com/cxx-abi/
* along with the current specification.
*
* For users of GCC greater than or equal to 3.x, entry points are
* available in <cxxabi.h>, which notes, <em>'It is not normally
* necessary for user programs to include this header, or use the
* entry points directly. However, this header is available should
* that be needed.'</em>
*/
namespace abi = __cxxabiv1;
namespace __gnu_cxx
{
/**
* @brief Exception thrown by __cxa_guard_acquire.
* @ingroup exceptions
*
* C++ 2011 6.7 [stmt.dcl]/4: If control re-enters the declaration
* recursively while the variable is being initialized, the behavior
* is undefined.
*
* Since we already have a library function to handle locking, we might
* as well check for this situation and throw an exception.
* We use the second byte of the guard variable to remember that we're
* in the middle of an initialization.
*/
class recursive_init_error: public std::exception
{
public:
recursive_init_error() _GLIBCXX_NOTHROW;
virtual ~recursive_init_error() _GLIBCXX_NOTHROW;
};
}
#endif // __cplusplus
#pragma GCC visibility pop
#endif // __CXXABI_H
c++/8/climits 0000644 00000003571 15201526705 0006663 0 ustar 00 // -*- C++ -*- forwarding header.
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/climits
* This is a Standard C++ Library file. You should @c \#include this file
* in your programs, rather than any of the @a *.h implementation files.
*
* This is the C++ version of the Standard C Library header @c limits.h,
* and its contents are (mostly) the same as that header, but are all
* contained in the namespace @c std (except for names which are defined
* as macros in C).
*/
//
// ISO C++ 14882: 18.2.2 Implementation properties: C library
//
#pragma GCC system_header
#include <bits/c++config.h>
#include <limits.h>
#ifndef _GLIBCXX_CLIMITS
#define _GLIBCXX_CLIMITS 1
#ifndef LLONG_MIN
#define LLONG_MIN (-__LONG_LONG_MAX__ - 1)
#endif
#ifndef LLONG_MAX
#define LLONG_MAX __LONG_LONG_MAX__
#endif
#ifndef ULLONG_MAX
#define ULLONG_MAX (__LONG_LONG_MAX__ * 2ULL + 1)
#endif
#endif
c++/8/optional 0000644 00000125673 15201526705 0007054 0 ustar 00 // <optional> -*- C++ -*-
// Copyright (C) 2013-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/optional
* This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_OPTIONAL
#define _GLIBCXX_OPTIONAL 1
#pragma GCC system_header
#if __cplusplus >= 201703L
#include <utility>
#include <type_traits>
#include <stdexcept>
#include <new>
#include <initializer_list>
#include <bits/functexcept.h>
#include <bits/functional_hash.h>
#include <bits/enable_special_members.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @addtogroup utilities
* @{
*/
#define __cpp_lib_optional 201606L
template<typename _Tp>
class optional;
/// Tag type to disengage optional objects.
struct nullopt_t
{
// Do not user-declare default constructor at all for
// optional_value = {} syntax to work.
// nullopt_t() = delete;
// Used for constructing nullopt.
enum class _Construct { _Token };
// Must be constexpr for nullopt_t to be literal.
explicit constexpr nullopt_t(_Construct) { }
};
/// Tag to disengage optional objects.
inline constexpr nullopt_t nullopt { nullopt_t::_Construct::_Token };
/**
* @brief Exception class thrown when a disengaged optional object is
* dereferenced.
* @ingroup exceptions
*/
class bad_optional_access : public exception
{
public:
bad_optional_access() { }
virtual const char* what() const noexcept override
{ return "bad optional access"; }
virtual ~bad_optional_access() noexcept = default;
};
void
__throw_bad_optional_access()
__attribute__((__noreturn__));
// XXX Does not belong here.
inline void
__throw_bad_optional_access()
{ _GLIBCXX_THROW_OR_ABORT(bad_optional_access()); }
// Payload for optionals with non-trivial destructor.
template <typename _Tp,
bool /*_HasTrivialDestructor*/ =
is_trivially_destructible_v<_Tp>,
bool /*_HasTrivialCopy */ =
is_trivially_copy_assignable_v<_Tp>
&& is_trivially_copy_constructible_v<_Tp>,
bool /*_HasTrivialMove */ =
is_trivially_move_assignable_v<_Tp>
&& is_trivially_move_constructible_v<_Tp>>
struct _Optional_payload
{
constexpr _Optional_payload() noexcept : _M_empty() { }
template <typename... _Args>
constexpr
_Optional_payload(in_place_t, _Args&&... __args)
: _M_payload(std::forward<_Args>(__args)...), _M_engaged(true) { }
template<typename _Up, typename... _Args>
constexpr
_Optional_payload(std::initializer_list<_Up> __il,
_Args&&... __args)
: _M_payload(__il, std::forward<_Args>(__args)...),
_M_engaged(true)
{ }
constexpr
_Optional_payload(bool __engaged, const _Optional_payload& __other)
: _Optional_payload(__other)
{ }
constexpr
_Optional_payload(bool __engaged, _Optional_payload&& __other)
: _Optional_payload(std::move(__other))
{ }
constexpr
_Optional_payload(const _Optional_payload& __other)
{
if (__other._M_engaged)
this->_M_construct(__other._M_payload);
}
constexpr
_Optional_payload(_Optional_payload&& __other)
{
if (__other._M_engaged)
this->_M_construct(std::move(__other._M_payload));
}
constexpr
_Optional_payload&
operator=(const _Optional_payload& __other)
{
if (this->_M_engaged && __other._M_engaged)
this->_M_get() = __other._M_get();
else
{
if (__other._M_engaged)
this->_M_construct(__other._M_get());
else
this->_M_reset();
}
return *this;
}
constexpr
_Optional_payload&
operator=(_Optional_payload&& __other)
noexcept(__and_<is_nothrow_move_constructible<_Tp>,
is_nothrow_move_assignable<_Tp>>())
{
if (this->_M_engaged && __other._M_engaged)
this->_M_get() = std::move(__other._M_get());
else
{
if (__other._M_engaged)
this->_M_construct(std::move(__other._M_get()));
else
this->_M_reset();
}
return *this;
}
using _Stored_type = remove_const_t<_Tp>;
struct _Empty_byte { };
union {
_Empty_byte _M_empty;
_Stored_type _M_payload;
};
bool _M_engaged = false;
~_Optional_payload()
{
if (_M_engaged)
_M_payload.~_Stored_type();
}
template<typename... _Args>
void
_M_construct(_Args&&... __args)
noexcept(is_nothrow_constructible<_Stored_type, _Args...>())
{
::new ((void *) std::__addressof(this->_M_payload))
_Stored_type(std::forward<_Args>(__args)...);
this->_M_engaged = true;
}
// The _M_get operations have _M_engaged as a precondition.
constexpr _Tp&
_M_get() noexcept
{ return this->_M_payload; }
constexpr const _Tp&
_M_get() const noexcept
{ return this->_M_payload; }
// _M_reset is a 'safe' operation with no precondition.
constexpr
void
_M_reset() noexcept
{
if (this->_M_engaged)
{
this->_M_engaged = false;
this->_M_payload.~_Stored_type();
}
}
};
// Payload for potentially-constexpr optionals.
template <typename _Tp>
struct _Optional_payload<_Tp, true, true, true>
{
constexpr _Optional_payload() noexcept
: _M_empty(), _M_engaged(false) { }
template<typename... _Args>
constexpr
_Optional_payload(in_place_t, _Args&&... __args)
: _M_payload(std::forward<_Args>(__args)...), _M_engaged(true)
{ }
template<typename _Up, typename... _Args>
constexpr
_Optional_payload(std::initializer_list<_Up> __il,
_Args&&... __args)
: _M_payload(__il, std::forward<_Args>(__args)...),
_M_engaged(true)
{ }
constexpr
_Optional_payload(bool __engaged, const _Optional_payload& __other)
: _M_engaged(__engaged)
{
if (__engaged)
_M_construct(__other._M_get());
}
constexpr
_Optional_payload(bool __engaged, _Optional_payload&& __other)
: _M_engaged(__engaged)
{
if (__engaged)
_M_construct(std::move(__other._M_get()));
}
using _Stored_type = remove_const_t<_Tp>;
struct _Empty_byte { };
union {
_Empty_byte _M_empty;
_Stored_type _M_payload;
};
bool _M_engaged;
// The _M_get operations have _M_engaged as a precondition.
constexpr _Tp&
_M_get() noexcept
{ return this->_M_payload; }
constexpr const _Tp&
_M_get() const noexcept
{ return this->_M_payload; }
};
// Payload for optionals with non-trivial copy assignment.
template <typename _Tp>
struct _Optional_payload<_Tp, true, false, true>
{
constexpr _Optional_payload() noexcept
: _M_empty(), _M_engaged(false) { }
template<typename... _Args>
constexpr
_Optional_payload(in_place_t, _Args&&... __args)
: _M_payload(std::forward<_Args>(__args)...), _M_engaged(true)
{ }
template<typename _Up, typename... _Args>
constexpr
_Optional_payload(std::initializer_list<_Up> __il,
_Args&&... __args)
: _M_payload(__il, std::forward<_Args>(__args)...),
_M_engaged(true)
{ }
constexpr
_Optional_payload(bool __engaged, const _Optional_payload& __other)
: _M_engaged(__engaged)
{
if (__engaged)
_M_construct(__other._M_get());
}
constexpr
_Optional_payload(bool __engaged, _Optional_payload&& __other)
: _M_engaged(__engaged)
{
if (__engaged)
_M_construct(std::move(__other._M_get()));
}
_Optional_payload(const _Optional_payload&) = default;
_Optional_payload(_Optional_payload&&) = default;
constexpr
_Optional_payload&
operator=(const _Optional_payload& __other)
{
if (this->_M_engaged && __other._M_engaged)
this->_M_get() = __other._M_get();
else
{
if (__other._M_engaged)
this->_M_construct(__other._M_get());
else
this->_M_reset();
}
return *this;
}
_Optional_payload&
operator=(_Optional_payload&& __other) = default;
using _Stored_type = remove_const_t<_Tp>;
struct _Empty_byte { };
union {
_Empty_byte _M_empty;
_Stored_type _M_payload;
};
bool _M_engaged;
template<typename... _Args>
void
_M_construct(_Args&&... __args)
noexcept(is_nothrow_constructible<_Stored_type, _Args...>())
{
::new ((void *) std::__addressof(this->_M_payload))
_Stored_type(std::forward<_Args>(__args)...);
this->_M_engaged = true;
}
// The _M_get operations have _M_engaged as a precondition.
constexpr _Tp&
_M_get() noexcept
{ return this->_M_payload; }
constexpr const _Tp&
_M_get() const noexcept
{ return this->_M_payload; }
// _M_reset is a 'safe' operation with no precondition.
constexpr
void
_M_reset() noexcept
{
if (this->_M_engaged)
{
this->_M_engaged = false;
this->_M_payload.~_Stored_type();
}
}
};
// Payload for optionals with non-trivial move assignment.
template <typename _Tp>
struct _Optional_payload<_Tp, true, true, false>
{
constexpr _Optional_payload() noexcept
: _M_empty(), _M_engaged(false) { }
template<typename... _Args>
constexpr
_Optional_payload(in_place_t, _Args&&... __args)
: _M_payload(std::forward<_Args>(__args)...),
_M_engaged(true)
{ }
template<typename _Up, typename... _Args>
constexpr
_Optional_payload(std::initializer_list<_Up> __il,
_Args&&... __args)
: _M_payload(__il, std::forward<_Args>(__args)...),
_M_engaged(true)
{ }
constexpr
_Optional_payload(bool __engaged, const _Optional_payload& __other)
: _M_engaged(__engaged)
{
if (__engaged)
_M_construct(__other._M_get());
}
constexpr
_Optional_payload(bool __engaged, _Optional_payload&& __other)
: _M_engaged(__engaged)
{
if (__engaged)
_M_construct(std::move(__other._M_get()));
}
_Optional_payload(const _Optional_payload&) = default;
_Optional_payload(_Optional_payload&&) = default;
_Optional_payload&
operator=(const _Optional_payload& __other) = default;
constexpr
_Optional_payload&
operator=(_Optional_payload&& __other)
noexcept(__and_<is_nothrow_move_constructible<_Tp>,
is_nothrow_move_assignable<_Tp>>())
{
if (this->_M_engaged && __other._M_engaged)
this->_M_get() = std::move(__other._M_get());
else
{
if (__other._M_engaged)
this->_M_construct(std::move(__other._M_get()));
else
this->_M_reset();
}
return *this;
}
using _Stored_type = remove_const_t<_Tp>;
struct _Empty_byte { };
union {
_Empty_byte _M_empty;
_Stored_type _M_payload;
};
bool _M_engaged;
template<typename... _Args>
void
_M_construct(_Args&&... __args)
noexcept(is_nothrow_constructible<_Stored_type, _Args...>())
{
::new ((void *) std::__addressof(this->_M_payload))
_Stored_type(std::forward<_Args>(__args)...);
this->_M_engaged = true;
}
// The _M_get operations have _M_engaged as a precondition.
constexpr _Tp&
_M_get() noexcept
{ return this->_M_payload; }
constexpr const _Tp&
_M_get() const noexcept
{ return this->_M_payload; }
// _M_reset is a 'safe' operation with no precondition.
constexpr
void
_M_reset() noexcept
{
if (this->_M_engaged)
{
this->_M_engaged = false;
this->_M_payload.~_Stored_type();
}
}
};
// Payload for optionals with non-trivial copy and move assignment.
template <typename _Tp>
struct _Optional_payload<_Tp, true, false, false>
{
constexpr _Optional_payload() noexcept
: _M_empty(), _M_engaged(false) {}
template<typename... _Args>
constexpr
_Optional_payload(in_place_t, _Args&&... __args)
: _M_payload(std::forward<_Args>(__args)...),
_M_engaged(true)
{ }
template<typename _Up, typename... _Args>
constexpr
_Optional_payload(std::initializer_list<_Up> __il,
_Args&&... __args)
: _M_payload(__il, std::forward<_Args>(__args)...),
_M_engaged(true)
{ }
constexpr
_Optional_payload(bool __engaged, const _Optional_payload& __other)
: _M_engaged(__engaged)
{
if (__engaged)
_M_construct(__other._M_get());
}
constexpr
_Optional_payload(bool __engaged, _Optional_payload&& __other)
: _M_engaged(__engaged)
{
if (__engaged)
_M_construct(std::move(__other._M_get()));
}
_Optional_payload(const _Optional_payload&) = default;
_Optional_payload(_Optional_payload&&) = default;
constexpr
_Optional_payload&
operator=(const _Optional_payload& __other)
{
if (this->_M_engaged && __other._M_engaged)
this->_M_get() = __other._M_get();
else
{
if (__other._M_engaged)
this->_M_construct(__other._M_get());
else
this->_M_reset();
}
return *this;
}
constexpr
_Optional_payload&
operator=(_Optional_payload&& __other)
noexcept(__and_<is_nothrow_move_constructible<_Tp>,
is_nothrow_move_assignable<_Tp>>())
{
if (this->_M_engaged && __other._M_engaged)
this->_M_get() = std::move(__other._M_get());
else
{
if (__other._M_engaged)
this->_M_construct(std::move(__other._M_get()));
else
this->_M_reset();
}
return *this;
}
using _Stored_type = remove_const_t<_Tp>;
struct _Empty_byte { };
union {
_Empty_byte _M_empty;
_Stored_type _M_payload;
};
bool _M_engaged;
template<typename... _Args>
void
_M_construct(_Args&&... __args)
noexcept(is_nothrow_constructible<_Stored_type, _Args...>())
{
::new ((void *) std::__addressof(this->_M_payload))
_Stored_type(std::forward<_Args>(__args)...);
this->_M_engaged = true;
}
// The _M_get operations have _M_engaged as a precondition.
constexpr _Tp&
_M_get() noexcept
{ return this->_M_payload; }
constexpr const _Tp&
_M_get() const noexcept
{ return this->_M_payload; }
// _M_reset is a 'safe' operation with no precondition.
constexpr
void
_M_reset() noexcept
{
if (this->_M_engaged)
{
this->_M_engaged = false;
this->_M_payload.~_Stored_type();
}
}
};
template<typename _Tp, typename _Dp>
class _Optional_base_impl
{
protected:
using _Stored_type = remove_const_t<_Tp>;
// The _M_construct operation has !_M_engaged as a precondition
// while _M_destruct has _M_engaged as a precondition.
template<typename... _Args>
void
_M_construct(_Args&&... __args)
noexcept(is_nothrow_constructible<_Stored_type, _Args...>())
{
::new
(std::__addressof(static_cast<_Dp*>(this)->_M_payload._M_payload))
_Stored_type(std::forward<_Args>(__args)...);
static_cast<_Dp*>(this)->_M_payload._M_engaged = true;
}
void
_M_destruct() noexcept
{
static_cast<_Dp*>(this)->_M_payload._M_engaged = false;
static_cast<_Dp*>(this)->_M_payload._M_payload.~_Stored_type();
}
// _M_reset is a 'safe' operation with no precondition.
constexpr
void
_M_reset() noexcept
{
if (static_cast<_Dp*>(this)->_M_payload._M_engaged)
static_cast<_Dp*>(this)->_M_destruct();
}
};
/**
* @brief Class template that takes care of copy/move constructors
of optional
*
* Such a separate base class template is necessary in order to
* conditionally make copy/move constructors trivial.
* @see optional, _Enable_special_members
*/
template<typename _Tp,
bool = is_trivially_copy_constructible_v<_Tp>,
bool = is_trivially_move_constructible_v<_Tp>>
class _Optional_base
// protected inheritance because optional needs to reach that base too
: protected _Optional_base_impl<_Tp, _Optional_base<_Tp>>
{
friend class _Optional_base_impl<_Tp, _Optional_base<_Tp>>;
public:
// Constructors for disengaged optionals.
constexpr _Optional_base() = default;
// Constructors for engaged optionals.
template<typename... _Args,
enable_if_t<is_constructible_v<_Tp, _Args&&...>, bool> = false>
constexpr explicit _Optional_base(in_place_t, _Args&&... __args)
: _M_payload(in_place,
std::forward<_Args>(__args)...) { }
template<typename _Up, typename... _Args,
enable_if_t<is_constructible_v<_Tp,
initializer_list<_Up>&,
_Args&&...>, bool> = false>
constexpr explicit _Optional_base(in_place_t,
initializer_list<_Up> __il,
_Args&&... __args)
: _M_payload(in_place,
__il, std::forward<_Args>(__args)...)
{ }
// Copy and move constructors.
constexpr _Optional_base(const _Optional_base& __other)
: _M_payload(__other._M_payload._M_engaged,
__other._M_payload)
{ }
constexpr _Optional_base(_Optional_base&& __other)
noexcept(is_nothrow_move_constructible<_Tp>())
: _M_payload(__other._M_payload._M_engaged,
std::move(__other._M_payload))
{ }
// Assignment operators.
_Optional_base& operator=(const _Optional_base&) = default;
_Optional_base& operator=(_Optional_base&&) = default;
protected:
constexpr bool _M_is_engaged() const noexcept
{ return this->_M_payload._M_engaged; }
// The _M_get operations have _M_engaged as a precondition.
constexpr _Tp&
_M_get() noexcept
{
__glibcxx_assert(this->_M_is_engaged());
return this->_M_payload._M_payload;
}
constexpr const _Tp&
_M_get() const noexcept
{
__glibcxx_assert(this->_M_is_engaged());
return this->_M_payload._M_payload;
}
private:
_Optional_payload<_Tp> _M_payload;
};
template<typename _Tp>
class _Optional_base<_Tp, false, true>
: protected _Optional_base_impl<_Tp, _Optional_base<_Tp>>
{
friend class _Optional_base_impl<_Tp, _Optional_base<_Tp>>;
public:
// Constructors for disengaged optionals.
constexpr _Optional_base() = default;
// Constructors for engaged optionals.
template<typename... _Args,
enable_if_t<is_constructible_v<_Tp, _Args&&...>, bool> = false>
constexpr explicit _Optional_base(in_place_t, _Args&&... __args)
: _M_payload(in_place,
std::forward<_Args>(__args)...) { }
template<typename _Up, typename... _Args,
enable_if_t<is_constructible_v<_Tp,
initializer_list<_Up>&,
_Args&&...>, bool> = false>
constexpr explicit _Optional_base(in_place_t,
initializer_list<_Up> __il,
_Args&&... __args)
: _M_payload(in_place,
__il, std::forward<_Args>(__args)...)
{ }
// Copy and move constructors.
constexpr _Optional_base(const _Optional_base& __other)
: _M_payload(__other._M_payload._M_engaged,
__other._M_payload)
{ }
constexpr _Optional_base(_Optional_base&& __other) = default;
// Assignment operators.
_Optional_base& operator=(const _Optional_base&) = default;
_Optional_base& operator=(_Optional_base&&) = default;
protected:
constexpr bool _M_is_engaged() const noexcept
{ return this->_M_payload._M_engaged; }
// The _M_get operations have _M_engaged as a precondition.
constexpr _Tp&
_M_get() noexcept
{
__glibcxx_assert(this->_M_is_engaged());
return this->_M_payload._M_payload;
}
constexpr const _Tp&
_M_get() const noexcept
{
__glibcxx_assert(this->_M_is_engaged());
return this->_M_payload._M_payload;
}
private:
_Optional_payload<_Tp> _M_payload;
};
template<typename _Tp>
class _Optional_base<_Tp, true, false>
: protected _Optional_base_impl<_Tp, _Optional_base<_Tp>>
{
friend class _Optional_base_impl<_Tp, _Optional_base<_Tp>>;
public:
// Constructors for disengaged optionals.
constexpr _Optional_base() = default;
// Constructors for engaged optionals.
template<typename... _Args,
enable_if_t<is_constructible_v<_Tp, _Args&&...>, bool> = false>
constexpr explicit _Optional_base(in_place_t, _Args&&... __args)
: _M_payload(in_place,
std::forward<_Args>(__args)...) { }
template<typename _Up, typename... _Args,
enable_if_t<is_constructible_v<_Tp,
initializer_list<_Up>&,
_Args&&...>, bool> = false>
constexpr explicit _Optional_base(in_place_t,
initializer_list<_Up> __il,
_Args&&... __args)
: _M_payload(in_place,
__il, std::forward<_Args>(__args)...)
{ }
// Copy and move constructors.
constexpr _Optional_base(const _Optional_base& __other) = default;
constexpr _Optional_base(_Optional_base&& __other)
noexcept(is_nothrow_move_constructible<_Tp>())
: _M_payload(__other._M_payload._M_engaged,
std::move(__other._M_payload))
{ }
// Assignment operators.
_Optional_base& operator=(const _Optional_base&) = default;
_Optional_base& operator=(_Optional_base&&) = default;
protected:
constexpr bool _M_is_engaged() const noexcept
{ return this->_M_payload._M_engaged; }
// The _M_get operations have _M_engaged as a precondition.
constexpr _Tp&
_M_get() noexcept
{
__glibcxx_assert(this->_M_is_engaged());
return this->_M_payload._M_payload;
}
constexpr const _Tp&
_M_get() const noexcept
{
__glibcxx_assert(this->_M_is_engaged());
return this->_M_payload._M_payload;
}
private:
_Optional_payload<_Tp> _M_payload;
};
template<typename _Tp>
class _Optional_base<_Tp, true, true>
: protected _Optional_base_impl<_Tp, _Optional_base<_Tp>>
{
friend class _Optional_base_impl<_Tp, _Optional_base<_Tp>>;
public:
// Constructors for disengaged optionals.
constexpr _Optional_base() = default;
// Constructors for engaged optionals.
template<typename... _Args,
enable_if_t<is_constructible_v<_Tp, _Args&&...>, bool> = false>
constexpr explicit _Optional_base(in_place_t, _Args&&... __args)
: _M_payload(in_place,
std::forward<_Args>(__args)...) { }
template<typename _Up, typename... _Args,
enable_if_t<is_constructible_v<_Tp,
initializer_list<_Up>&,
_Args&&...>, bool> = false>
constexpr explicit _Optional_base(in_place_t,
initializer_list<_Up> __il,
_Args&&... __args)
: _M_payload(in_place,
__il, std::forward<_Args>(__args)...)
{ }
// Copy and move constructors.
constexpr _Optional_base(const _Optional_base& __other) = default;
constexpr _Optional_base(_Optional_base&& __other) = default;
// Assignment operators.
_Optional_base& operator=(const _Optional_base&) = default;
_Optional_base& operator=(_Optional_base&&) = default;
protected:
constexpr bool _M_is_engaged() const noexcept
{ return this->_M_payload._M_engaged; }
// The _M_get operations have _M_engaged as a precondition.
constexpr _Tp&
_M_get() noexcept
{
__glibcxx_assert(this->_M_is_engaged());
return this->_M_payload._M_payload;
}
constexpr const _Tp&
_M_get() const noexcept
{
__glibcxx_assert(this->_M_is_engaged());
return this->_M_payload._M_payload;
}
private:
_Optional_payload<_Tp> _M_payload;
};
template<typename _Tp>
class optional;
template<typename _Tp, typename _Up>
using __converts_from_optional =
__or_<is_constructible<_Tp, const optional<_Up>&>,
is_constructible<_Tp, optional<_Up>&>,
is_constructible<_Tp, const optional<_Up>&&>,
is_constructible<_Tp, optional<_Up>&&>,
is_convertible<const optional<_Up>&, _Tp>,
is_convertible<optional<_Up>&, _Tp>,
is_convertible<const optional<_Up>&&, _Tp>,
is_convertible<optional<_Up>&&, _Tp>>;
template<typename _Tp, typename _Up>
using __assigns_from_optional =
__or_<is_assignable<_Tp&, const optional<_Up>&>,
is_assignable<_Tp&, optional<_Up>&>,
is_assignable<_Tp&, const optional<_Up>&&>,
is_assignable<_Tp&, optional<_Up>&&>>;
/**
* @brief Class template for optional values.
*/
template<typename _Tp>
class optional
: private _Optional_base<_Tp>,
private _Enable_copy_move<
// Copy constructor.
is_copy_constructible<_Tp>::value,
// Copy assignment.
__and_<is_copy_constructible<_Tp>, is_copy_assignable<_Tp>>::value,
// Move constructor.
is_move_constructible<_Tp>::value,
// Move assignment.
__and_<is_move_constructible<_Tp>, is_move_assignable<_Tp>>::value,
// Unique tag type.
optional<_Tp>>
{
static_assert(!is_same_v<remove_cv_t<_Tp>, nullopt_t>);
static_assert(!is_same_v<remove_cv_t<_Tp>, in_place_t>);
static_assert(!is_reference_v<_Tp>);
private:
using _Base = _Optional_base<_Tp>;
public:
using value_type = _Tp;
constexpr optional() = default;
constexpr optional(nullopt_t) noexcept { }
// Converting constructors for engaged optionals.
template <typename _Up = _Tp,
enable_if_t<__and_<
__not_<is_same<optional<_Tp>, decay_t<_Up>>>,
__not_<is_same<in_place_t, decay_t<_Up>>>,
is_constructible<_Tp, _Up&&>,
is_convertible<_Up&&, _Tp>
>::value, bool> = true>
constexpr optional(_Up&& __t)
: _Base(std::in_place, std::forward<_Up>(__t)) { }
template <typename _Up = _Tp,
enable_if_t<__and_<
__not_<is_same<optional<_Tp>, decay_t<_Up>>>,
__not_<is_same<in_place_t, decay_t<_Up>>>,
is_constructible<_Tp, _Up&&>,
__not_<is_convertible<_Up&&, _Tp>>
>::value, bool> = false>
explicit constexpr optional(_Up&& __t)
: _Base(std::in_place, std::forward<_Up>(__t)) { }
template <typename _Up,
enable_if_t<__and_<
__not_<is_same<_Tp, _Up>>,
is_constructible<_Tp, const _Up&>,
is_convertible<const _Up&, _Tp>,
__not_<__converts_from_optional<_Tp, _Up>>
>::value, bool> = true>
constexpr optional(const optional<_Up>& __t)
{
if (__t)
emplace(*__t);
}
template <typename _Up,
enable_if_t<__and_<
__not_<is_same<_Tp, _Up>>,
is_constructible<_Tp, const _Up&>,
__not_<is_convertible<const _Up&, _Tp>>,
__not_<__converts_from_optional<_Tp, _Up>>
>::value, bool> = false>
explicit constexpr optional(const optional<_Up>& __t)
{
if (__t)
emplace(*__t);
}
template <typename _Up,
enable_if_t<__and_<
__not_<is_same<_Tp, _Up>>,
is_constructible<_Tp, _Up&&>,
is_convertible<_Up&&, _Tp>,
__not_<__converts_from_optional<_Tp, _Up>>
>::value, bool> = true>
constexpr optional(optional<_Up>&& __t)
{
if (__t)
emplace(std::move(*__t));
}
template <typename _Up,
enable_if_t<__and_<
__not_<is_same<_Tp, _Up>>,
is_constructible<_Tp, _Up&&>,
__not_<is_convertible<_Up&&, _Tp>>,
__not_<__converts_from_optional<_Tp, _Up>>
>::value, bool> = false>
explicit constexpr optional(optional<_Up>&& __t)
{
if (__t)
emplace(std::move(*__t));
}
template<typename... _Args,
enable_if_t<is_constructible_v<_Tp, _Args&&...>, bool> = false>
explicit constexpr optional(in_place_t, _Args&&... __args)
: _Base(std::in_place, std::forward<_Args>(__args)...) { }
template<typename _Up, typename... _Args,
enable_if_t<is_constructible_v<_Tp,
initializer_list<_Up>&,
_Args&&...>, bool> = false>
explicit constexpr optional(in_place_t,
initializer_list<_Up> __il,
_Args&&... __args)
: _Base(std::in_place, __il, std::forward<_Args>(__args)...) { }
// Assignment operators.
optional&
operator=(nullopt_t) noexcept
{
this->_M_reset();
return *this;
}
template<typename _Up = _Tp>
enable_if_t<__and_<
__not_<is_same<optional<_Tp>, decay_t<_Up>>>,
is_constructible<_Tp, _Up>,
__not_<__and_<is_scalar<_Tp>,
is_same<_Tp, decay_t<_Up>>>>,
is_assignable<_Tp&, _Up>>::value,
optional&>
operator=(_Up&& __u)
{
if (this->_M_is_engaged())
this->_M_get() = std::forward<_Up>(__u);
else
this->_M_construct(std::forward<_Up>(__u));
return *this;
}
template<typename _Up>
enable_if_t<__and_<
__not_<is_same<_Tp, _Up>>,
is_constructible<_Tp, const _Up&>,
is_assignable<_Tp&, _Up>,
__not_<__converts_from_optional<_Tp, _Up>>,
__not_<__assigns_from_optional<_Tp, _Up>>
>::value,
optional&>
operator=(const optional<_Up>& __u)
{
if (__u)
{
if (this->_M_is_engaged())
this->_M_get() = *__u;
else
this->_M_construct(*__u);
}
else
{
this->_M_reset();
}
return *this;
}
template<typename _Up>
enable_if_t<__and_<
__not_<is_same<_Tp, _Up>>,
is_constructible<_Tp, _Up>,
is_assignable<_Tp&, _Up>,
__not_<__converts_from_optional<_Tp, _Up>>,
__not_<__assigns_from_optional<_Tp, _Up>>
>::value,
optional&>
operator=(optional<_Up>&& __u)
{
if (__u)
{
if (this->_M_is_engaged())
this->_M_get() = std::move(*__u);
else
this->_M_construct(std::move(*__u));
}
else
{
this->_M_reset();
}
return *this;
}
template<typename... _Args>
enable_if_t<is_constructible<_Tp, _Args&&...>::value, _Tp&>
emplace(_Args&&... __args)
{
this->_M_reset();
this->_M_construct(std::forward<_Args>(__args)...);
return this->_M_get();
}
template<typename _Up, typename... _Args>
enable_if_t<is_constructible<_Tp, initializer_list<_Up>&,
_Args&&...>::value, _Tp&>
emplace(initializer_list<_Up> __il, _Args&&... __args)
{
this->_M_reset();
this->_M_construct(__il, std::forward<_Args>(__args)...);
return this->_M_get();
}
// Destructor is implicit, implemented in _Optional_base.
// Swap.
void
swap(optional& __other)
noexcept(is_nothrow_move_constructible<_Tp>()
&& is_nothrow_swappable_v<_Tp>)
{
using std::swap;
if (this->_M_is_engaged() && __other._M_is_engaged())
swap(this->_M_get(), __other._M_get());
else if (this->_M_is_engaged())
{
__other._M_construct(std::move(this->_M_get()));
this->_M_destruct();
}
else if (__other._M_is_engaged())
{
this->_M_construct(std::move(__other._M_get()));
__other._M_destruct();
}
}
// Observers.
constexpr const _Tp*
operator->() const
{ return std::__addressof(this->_M_get()); }
constexpr
_Tp*
operator->()
{ return std::__addressof(this->_M_get()); }
constexpr const _Tp&
operator*() const&
{ return this->_M_get(); }
constexpr _Tp&
operator*()&
{ return this->_M_get(); }
constexpr _Tp&&
operator*()&&
{ return std::move(this->_M_get()); }
constexpr const _Tp&&
operator*() const&&
{ return std::move(this->_M_get()); }
constexpr explicit operator bool() const noexcept
{ return this->_M_is_engaged(); }
constexpr bool has_value() const noexcept
{ return this->_M_is_engaged(); }
constexpr const _Tp&
value() const&
{
return this->_M_is_engaged()
? this->_M_get()
: (__throw_bad_optional_access(),
this->_M_get());
}
constexpr _Tp&
value()&
{
return this->_M_is_engaged()
? this->_M_get()
: (__throw_bad_optional_access(),
this->_M_get());
}
constexpr _Tp&&
value()&&
{
return this->_M_is_engaged()
? std::move(this->_M_get())
: (__throw_bad_optional_access(),
std::move(this->_M_get()));
}
constexpr const _Tp&&
value() const&&
{
return this->_M_is_engaged()
? std::move(this->_M_get())
: (__throw_bad_optional_access(),
std::move(this->_M_get()));
}
template<typename _Up>
constexpr _Tp
value_or(_Up&& __u) const&
{
static_assert(is_copy_constructible_v<_Tp>);
static_assert(is_convertible_v<_Up&&, _Tp>);
return this->_M_is_engaged()
? this->_M_get()
: static_cast<_Tp>(std::forward<_Up>(__u));
}
template<typename _Up>
constexpr _Tp
value_or(_Up&& __u) &&
{
static_assert(is_move_constructible_v<_Tp>);
static_assert(is_convertible_v<_Up&&, _Tp>);
return this->_M_is_engaged()
? std::move(this->_M_get())
: static_cast<_Tp>(std::forward<_Up>(__u));
}
void reset() noexcept { this->_M_reset(); }
};
template<typename _Tp>
using __optional_relop_t =
enable_if_t<is_convertible<_Tp, bool>::value, bool>;
// Comparisons between optional values.
template<typename _Tp, typename _Up>
constexpr auto
operator==(const optional<_Tp>& __lhs, const optional<_Up>& __rhs)
-> __optional_relop_t<decltype(declval<_Tp>() == declval<_Up>())>
{
return static_cast<bool>(__lhs) == static_cast<bool>(__rhs)
&& (!__lhs || *__lhs == *__rhs);
}
template<typename _Tp, typename _Up>
constexpr auto
operator!=(const optional<_Tp>& __lhs, const optional<_Up>& __rhs)
-> __optional_relop_t<decltype(declval<_Tp>() != declval<_Up>())>
{
return static_cast<bool>(__lhs) != static_cast<bool>(__rhs)
|| (static_cast<bool>(__lhs) && *__lhs != *__rhs);
}
template<typename _Tp, typename _Up>
constexpr auto
operator<(const optional<_Tp>& __lhs, const optional<_Up>& __rhs)
-> __optional_relop_t<decltype(declval<_Tp>() < declval<_Up>())>
{
return static_cast<bool>(__rhs) && (!__lhs || *__lhs < *__rhs);
}
template<typename _Tp, typename _Up>
constexpr auto
operator>(const optional<_Tp>& __lhs, const optional<_Up>& __rhs)
-> __optional_relop_t<decltype(declval<_Tp>() > declval<_Up>())>
{
return static_cast<bool>(__lhs) && (!__rhs || *__lhs > *__rhs);
}
template<typename _Tp, typename _Up>
constexpr auto
operator<=(const optional<_Tp>& __lhs, const optional<_Up>& __rhs)
-> __optional_relop_t<decltype(declval<_Tp>() <= declval<_Up>())>
{
return !__lhs || (static_cast<bool>(__rhs) && *__lhs <= *__rhs);
}
template<typename _Tp, typename _Up>
constexpr auto
operator>=(const optional<_Tp>& __lhs, const optional<_Up>& __rhs)
-> __optional_relop_t<decltype(declval<_Tp>() >= declval<_Up>())>
{
return !__rhs || (static_cast<bool>(__lhs) && *__lhs >= *__rhs);
}
// Comparisons with nullopt.
template<typename _Tp>
constexpr bool
operator==(const optional<_Tp>& __lhs, nullopt_t) noexcept
{ return !__lhs; }
template<typename _Tp>
constexpr bool
operator==(nullopt_t, const optional<_Tp>& __rhs) noexcept
{ return !__rhs; }
template<typename _Tp>
constexpr bool
operator!=(const optional<_Tp>& __lhs, nullopt_t) noexcept
{ return static_cast<bool>(__lhs); }
template<typename _Tp>
constexpr bool
operator!=(nullopt_t, const optional<_Tp>& __rhs) noexcept
{ return static_cast<bool>(__rhs); }
template<typename _Tp>
constexpr bool
operator<(const optional<_Tp>& /* __lhs */, nullopt_t) noexcept
{ return false; }
template<typename _Tp>
constexpr bool
operator<(nullopt_t, const optional<_Tp>& __rhs) noexcept
{ return static_cast<bool>(__rhs); }
template<typename _Tp>
constexpr bool
operator>(const optional<_Tp>& __lhs, nullopt_t) noexcept
{ return static_cast<bool>(__lhs); }
template<typename _Tp>
constexpr bool
operator>(nullopt_t, const optional<_Tp>& /* __rhs */) noexcept
{ return false; }
template<typename _Tp>
constexpr bool
operator<=(const optional<_Tp>& __lhs, nullopt_t) noexcept
{ return !__lhs; }
template<typename _Tp>
constexpr bool
operator<=(nullopt_t, const optional<_Tp>& /* __rhs */) noexcept
{ return true; }
template<typename _Tp>
constexpr bool
operator>=(const optional<_Tp>& /* __lhs */, nullopt_t) noexcept
{ return true; }
template<typename _Tp>
constexpr bool
operator>=(nullopt_t, const optional<_Tp>& __rhs) noexcept
{ return !__rhs; }
// Comparisons with value type.
template<typename _Tp, typename _Up>
constexpr auto
operator==(const optional<_Tp>& __lhs, const _Up& __rhs)
-> __optional_relop_t<decltype(declval<_Tp>() == declval<_Up>())>
{ return __lhs && *__lhs == __rhs; }
template<typename _Tp, typename _Up>
constexpr auto
operator==(const _Up& __lhs, const optional<_Tp>& __rhs)
-> __optional_relop_t<decltype(declval<_Up>() == declval<_Tp>())>
{ return __rhs && __lhs == *__rhs; }
template<typename _Tp, typename _Up>
constexpr auto
operator!=(const optional<_Tp>& __lhs, const _Up& __rhs)
-> __optional_relop_t<decltype(declval<_Tp>() != declval<_Up>())>
{ return !__lhs || *__lhs != __rhs; }
template<typename _Tp, typename _Up>
constexpr auto
operator!=(const _Up& __lhs, const optional<_Tp>& __rhs)
-> __optional_relop_t<decltype(declval<_Up>() != declval<_Tp>())>
{ return !__rhs || __lhs != *__rhs; }
template<typename _Tp, typename _Up>
constexpr auto
operator<(const optional<_Tp>& __lhs, const _Up& __rhs)
-> __optional_relop_t<decltype(declval<_Tp>() < declval<_Up>())>
{ return !__lhs || *__lhs < __rhs; }
template<typename _Tp, typename _Up>
constexpr auto
operator<(const _Up& __lhs, const optional<_Tp>& __rhs)
-> __optional_relop_t<decltype(declval<_Up>() < declval<_Tp>())>
{ return __rhs && __lhs < *__rhs; }
template<typename _Tp, typename _Up>
constexpr auto
operator>(const optional<_Tp>& __lhs, const _Up& __rhs)
-> __optional_relop_t<decltype(declval<_Tp>() > declval<_Up>())>
{ return __lhs && *__lhs > __rhs; }
template<typename _Tp, typename _Up>
constexpr auto
operator>(const _Up& __lhs, const optional<_Tp>& __rhs)
-> __optional_relop_t<decltype(declval<_Up>() > declval<_Tp>())>
{ return !__rhs || __lhs > *__rhs; }
template<typename _Tp, typename _Up>
constexpr auto
operator<=(const optional<_Tp>& __lhs, const _Up& __rhs)
-> __optional_relop_t<decltype(declval<_Tp>() <= declval<_Up>())>
{ return !__lhs || *__lhs <= __rhs; }
template<typename _Tp, typename _Up>
constexpr auto
operator<=(const _Up& __lhs, const optional<_Tp>& __rhs)
-> __optional_relop_t<decltype(declval<_Up>() <= declval<_Tp>())>
{ return __rhs && __lhs <= *__rhs; }
template<typename _Tp, typename _Up>
constexpr auto
operator>=(const optional<_Tp>& __lhs, const _Up& __rhs)
-> __optional_relop_t<decltype(declval<_Tp>() >= declval<_Up>())>
{ return __lhs && *__lhs >= __rhs; }
template<typename _Tp, typename _Up>
constexpr auto
operator>=(const _Up& __lhs, const optional<_Tp>& __rhs)
-> __optional_relop_t<decltype(declval<_Up>() >= declval<_Tp>())>
{ return !__rhs || __lhs >= *__rhs; }
// Swap and creation functions.
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2748. swappable traits for optionals
template<typename _Tp>
inline enable_if_t<is_move_constructible_v<_Tp> && is_swappable_v<_Tp>>
swap(optional<_Tp>& __lhs, optional<_Tp>& __rhs)
noexcept(noexcept(__lhs.swap(__rhs)))
{ __lhs.swap(__rhs); }
template<typename _Tp>
enable_if_t<!(is_move_constructible_v<_Tp> && is_swappable_v<_Tp>)>
swap(optional<_Tp>&, optional<_Tp>&) = delete;
template<typename _Tp>
constexpr optional<decay_t<_Tp>>
make_optional(_Tp&& __t)
{ return optional<decay_t<_Tp>> { std::forward<_Tp>(__t) }; }
template<typename _Tp, typename ..._Args>
constexpr optional<_Tp>
make_optional(_Args&&... __args)
{ return optional<_Tp> { in_place, std::forward<_Args>(__args)... }; }
template<typename _Tp, typename _Up, typename ..._Args>
constexpr optional<_Tp>
make_optional(initializer_list<_Up> __il, _Args&&... __args)
{ return optional<_Tp> { in_place, __il, std::forward<_Args>(__args)... }; }
// Hash.
template<typename _Tp, typename _Up = remove_const_t<_Tp>,
bool = __poison_hash<_Up>::__enable_hash_call>
struct __optional_hash_call_base
{
size_t
operator()(const optional<_Tp>& __t) const
noexcept(noexcept(hash<_Up>{}(*__t)))
{
// We pick an arbitrary hash for disengaged optionals which hopefully
// usual values of _Tp won't typically hash to.
constexpr size_t __magic_disengaged_hash = static_cast<size_t>(-3333);
return __t ? hash<_Up>{}(*__t) : __magic_disengaged_hash;
}
};
template<typename _Tp, typename _Up>
struct __optional_hash_call_base<_Tp, _Up, false> {};
template<typename _Tp>
struct hash<optional<_Tp>>
: private __poison_hash<remove_const_t<_Tp>>,
public __optional_hash_call_base<_Tp>
{
using result_type [[__deprecated__]] = size_t;
using argument_type [[__deprecated__]] = optional<_Tp>;
};
template<typename _Tp>
struct __is_fast_hash<hash<optional<_Tp>>> : __is_fast_hash<hash<_Tp>>
{ };
/// @}
#if __cpp_deduction_guides >= 201606
template <typename _Tp> optional(_Tp) -> optional<_Tp>;
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // C++17
#endif // _GLIBCXX_OPTIONAL
c++/8/cwctype 0000644 00000005351 15201526705 0006673 0 ustar 00 // -*- C++ -*- forwarding header.
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/cwctype
* This is a Standard C++ Library file. You should @c \#include this file
* in your programs, rather than any of the @a *.h implementation files.
*
* This is the C++ version of the Standard C Library header @c wctype.h,
* and its contents are (mostly) the same as that header, but are all
* contained in the namespace @c std (except for names which are defined
* as macros in C).
*/
//
// ISO C++ 14882: <cwctype>
//
#pragma GCC system_header
#include <bits/c++config.h>
#if _GLIBCXX_HAVE_WCTYPE_H
#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 10
// Work around glibc BZ 9694
#include <stddef.h>
#endif
#include <wctype.h>
#endif // _GLIBCXX_HAVE_WCTYPE_H
#ifndef _GLIBCXX_CWCTYPE
#define _GLIBCXX_CWCTYPE 1
// Get rid of those macros defined in <wctype.h> in lieu of real functions.
#undef iswalnum
#undef iswalpha
#if _GLIBCXX_HAVE_ISWBLANK
# undef iswblank
#endif
#undef iswcntrl
#undef iswctype
#undef iswdigit
#undef iswgraph
#undef iswlower
#undef iswprint
#undef iswpunct
#undef iswspace
#undef iswupper
#undef iswxdigit
#undef towctrans
#undef towlower
#undef towupper
#undef wctrans
#undef wctype
#if _GLIBCXX_USE_WCHAR_T
namespace std
{
using ::wctrans_t;
using ::wctype_t;
using ::wint_t;
using ::iswalnum;
using ::iswalpha;
#if _GLIBCXX_HAVE_ISWBLANK
using ::iswblank;
#endif
using ::iswcntrl;
using ::iswctype;
using ::iswdigit;
using ::iswgraph;
using ::iswlower;
using ::iswprint;
using ::iswpunct;
using ::iswspace;
using ::iswupper;
using ::iswxdigit;
using ::towctrans;
using ::towlower;
using ::towupper;
using ::wctrans;
using ::wctype;
} // namespace
#endif //_GLIBCXX_USE_WCHAR_T
#endif // _GLIBCXX_CWCTYPE
c++/8/typeindex 0000644 00000006025 15201526705 0007225 0 ustar 00 // C++11 <typeindex> -*- C++ -*-
// Copyright (C) 2010-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/typeindex
* This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_TYPEINDEX
#define _GLIBCXX_TYPEINDEX 1
#pragma GCC system_header
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
#include <typeinfo>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @brief Class type_index
* @ingroup utilities
*
* The class type_index provides a simple wrapper for type_info
* which can be used as an index type in associative containers
* (23.6) and in unordered associative containers (23.7).
*/
struct type_index
{
type_index(const type_info& __rhs) noexcept
: _M_target(&__rhs) { }
bool
operator==(const type_index& __rhs) const noexcept
{ return *_M_target == *__rhs._M_target; }
bool
operator!=(const type_index& __rhs) const noexcept
{ return *_M_target != *__rhs._M_target; }
bool
operator<(const type_index& __rhs) const noexcept
{ return _M_target->before(*__rhs._M_target); }
bool
operator<=(const type_index& __rhs) const noexcept
{ return !__rhs._M_target->before(*_M_target); }
bool
operator>(const type_index& __rhs) const noexcept
{ return __rhs._M_target->before(*_M_target); }
bool
operator>=(const type_index& __rhs) const noexcept
{ return !_M_target->before(*__rhs._M_target); }
size_t
hash_code() const noexcept
{ return _M_target->hash_code(); }
const char*
name() const noexcept
{ return _M_target->name(); }
private:
const type_info* _M_target;
};
template<typename _Tp> struct hash;
/// std::hash specialization for type_index.
template<>
struct hash<type_index>
{
typedef size_t result_type;
typedef type_index argument_type;
size_t
operator()(const type_index& __ti) const noexcept
{ return __ti.hash_code(); }
};
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // C++11
#endif // _GLIBCXX_TYPEINDEX
c++/8/chrono 0000644 00000072262 15201526705 0006512 0 ustar 00 // <chrono> -*- C++ -*-
// Copyright (C) 2008-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/chrono
* This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_CHRONO
#define _GLIBCXX_CHRONO 1
#pragma GCC system_header
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
#include <ratio>
#include <type_traits>
#include <limits>
#include <ctime>
#include <bits/parse_numbers.h> // for literals support.
#ifdef _GLIBCXX_USE_C99_STDINT_TR1
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @defgroup chrono Time
* @ingroup utilities
*
* Classes and functions for time.
* @{
*/
/** @namespace std::chrono
* @brief ISO C++ 2011 entities sub-namespace for time and date.
*/
namespace chrono
{
template<typename _Rep, typename _Period = ratio<1>>
struct duration;
template<typename _Clock, typename _Dur = typename _Clock::duration>
struct time_point;
}
// 20.11.4.3 specialization of common_type (for duration, sfinae-friendly)
template<typename _CT, typename _Period1, typename _Period2>
struct __duration_common_type_wrapper
{
private:
typedef __static_gcd<_Period1::num, _Period2::num> __gcd_num;
typedef __static_gcd<_Period1::den, _Period2::den> __gcd_den;
typedef typename _CT::type __cr;
typedef ratio<__gcd_num::value,
(_Period1::den / __gcd_den::value) * _Period2::den> __r;
public:
typedef __success_type<chrono::duration<__cr, __r>> type;
};
template<typename _Period1, typename _Period2>
struct __duration_common_type_wrapper<__failure_type, _Period1, _Period2>
{ typedef __failure_type type; };
template<typename _Rep1, typename _Period1, typename _Rep2, typename _Period2>
struct common_type<chrono::duration<_Rep1, _Period1>,
chrono::duration<_Rep2, _Period2>>
: public __duration_common_type_wrapper<typename __member_type_wrapper<
common_type<_Rep1, _Rep2>>::type, _Period1, _Period2>::type
{ };
// 20.11.4.3 specialization of common_type (for time_point, sfinae-friendly)
template<typename _CT, typename _Clock>
struct __timepoint_common_type_wrapper
{
typedef __success_type<chrono::time_point<_Clock, typename _CT::type>>
type;
};
template<typename _Clock>
struct __timepoint_common_type_wrapper<__failure_type, _Clock>
{ typedef __failure_type type; };
template<typename _Clock, typename _Duration1, typename _Duration2>
struct common_type<chrono::time_point<_Clock, _Duration1>,
chrono::time_point<_Clock, _Duration2>>
: public __timepoint_common_type_wrapper<typename __member_type_wrapper<
common_type<_Duration1, _Duration2>>::type, _Clock>::type
{ };
namespace chrono
{
// Primary template for duration_cast impl.
template<typename _ToDur, typename _CF, typename _CR,
bool _NumIsOne = false, bool _DenIsOne = false>
struct __duration_cast_impl
{
template<typename _Rep, typename _Period>
static constexpr _ToDur
__cast(const duration<_Rep, _Period>& __d)
{
typedef typename _ToDur::rep __to_rep;
return _ToDur(static_cast<__to_rep>(static_cast<_CR>(__d.count())
* static_cast<_CR>(_CF::num)
/ static_cast<_CR>(_CF::den)));
}
};
template<typename _ToDur, typename _CF, typename _CR>
struct __duration_cast_impl<_ToDur, _CF, _CR, true, true>
{
template<typename _Rep, typename _Period>
static constexpr _ToDur
__cast(const duration<_Rep, _Period>& __d)
{
typedef typename _ToDur::rep __to_rep;
return _ToDur(static_cast<__to_rep>(__d.count()));
}
};
template<typename _ToDur, typename _CF, typename _CR>
struct __duration_cast_impl<_ToDur, _CF, _CR, true, false>
{
template<typename _Rep, typename _Period>
static constexpr _ToDur
__cast(const duration<_Rep, _Period>& __d)
{
typedef typename _ToDur::rep __to_rep;
return _ToDur(static_cast<__to_rep>(
static_cast<_CR>(__d.count()) / static_cast<_CR>(_CF::den)));
}
};
template<typename _ToDur, typename _CF, typename _CR>
struct __duration_cast_impl<_ToDur, _CF, _CR, false, true>
{
template<typename _Rep, typename _Period>
static constexpr _ToDur
__cast(const duration<_Rep, _Period>& __d)
{
typedef typename _ToDur::rep __to_rep;
return _ToDur(static_cast<__to_rep>(
static_cast<_CR>(__d.count()) * static_cast<_CR>(_CF::num)));
}
};
template<typename _Tp>
struct __is_duration
: std::false_type
{ };
template<typename _Rep, typename _Period>
struct __is_duration<duration<_Rep, _Period>>
: std::true_type
{ };
template<typename _Tp>
using __enable_if_is_duration
= typename enable_if<__is_duration<_Tp>::value, _Tp>::type;
template<typename _Tp>
using __disable_if_is_duration
= typename enable_if<!__is_duration<_Tp>::value, _Tp>::type;
/// duration_cast
template<typename _ToDur, typename _Rep, typename _Period>
constexpr __enable_if_is_duration<_ToDur>
duration_cast(const duration<_Rep, _Period>& __d)
{
typedef typename _ToDur::period __to_period;
typedef typename _ToDur::rep __to_rep;
typedef ratio_divide<_Period, __to_period> __cf;
typedef typename common_type<__to_rep, _Rep, intmax_t>::type
__cr;
typedef __duration_cast_impl<_ToDur, __cf, __cr,
__cf::num == 1, __cf::den == 1> __dc;
return __dc::__cast(__d);
}
/// treat_as_floating_point
template<typename _Rep>
struct treat_as_floating_point
: is_floating_point<_Rep>
{ };
#if __cplusplus > 201402L
template <typename _Rep>
inline constexpr bool treat_as_floating_point_v =
treat_as_floating_point<_Rep>::value;
#endif // C++17
#if __cplusplus >= 201703L
# define __cpp_lib_chrono 201611
template<typename _ToDur, typename _Rep, typename _Period>
constexpr __enable_if_is_duration<_ToDur>
floor(const duration<_Rep, _Period>& __d)
{
auto __to = chrono::duration_cast<_ToDur>(__d);
if (__to > __d)
return __to - _ToDur{1};
return __to;
}
template<typename _ToDur, typename _Rep, typename _Period>
constexpr __enable_if_is_duration<_ToDur>
ceil(const duration<_Rep, _Period>& __d)
{
auto __to = chrono::duration_cast<_ToDur>(__d);
if (__to < __d)
return __to + _ToDur{1};
return __to;
}
template <typename _ToDur, typename _Rep, typename _Period>
constexpr enable_if_t<
__and_<__is_duration<_ToDur>,
__not_<treat_as_floating_point<typename _ToDur::rep>>>::value,
_ToDur>
round(const duration<_Rep, _Period>& __d)
{
_ToDur __t0 = chrono::floor<_ToDur>(__d);
_ToDur __t1 = __t0 + _ToDur{1};
auto __diff0 = __d - __t0;
auto __diff1 = __t1 - __d;
if (__diff0 == __diff1)
{
if (__t0.count() & 1)
return __t1;
return __t0;
}
else if (__diff0 < __diff1)
return __t0;
return __t1;
}
template<typename _Rep, typename _Period>
constexpr
enable_if_t<numeric_limits<_Rep>::is_signed, duration<_Rep, _Period>>
abs(duration<_Rep, _Period> __d)
{
if (__d >= __d.zero())
return __d;
return -__d;
}
#endif // C++17
/// duration_values
template<typename _Rep>
struct duration_values
{
static constexpr _Rep
zero() noexcept
{ return _Rep(0); }
static constexpr _Rep
max() noexcept
{ return numeric_limits<_Rep>::max(); }
static constexpr _Rep
min() noexcept
{ return numeric_limits<_Rep>::lowest(); }
};
template<typename _Tp>
struct __is_ratio
: std::false_type
{ };
template<intmax_t _Num, intmax_t _Den>
struct __is_ratio<ratio<_Num, _Den>>
: std::true_type
{ };
/// duration
template<typename _Rep, typename _Period>
struct duration
{
private:
template<typename _Rep2>
using __is_float = treat_as_floating_point<_Rep2>;
// _Period2 is an exact multiple of _Period
template<typename _Period2>
using __is_harmonic
= __bool_constant<ratio_divide<_Period2, _Period>::den == 1>;
public:
typedef _Rep rep;
typedef _Period period;
static_assert(!__is_duration<_Rep>::value, "rep cannot be a duration");
static_assert(__is_ratio<_Period>::value,
"period must be a specialization of ratio");
static_assert(_Period::num > 0, "period must be positive");
// 20.11.5.1 construction / copy / destroy
constexpr duration() = default;
duration(const duration&) = default;
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 3050. Conversion specification problem in chrono::duration
template<typename _Rep2, typename = _Require<
is_convertible<const _Rep2&, rep>,
__or_<__is_float<rep>, __not_<__is_float<_Rep2>>>>>
constexpr explicit duration(const _Rep2& __rep)
: __r(static_cast<rep>(__rep)) { }
template<typename _Rep2, typename _Period2, typename = _Require<
__or_<__is_float<rep>,
__and_<__is_harmonic<_Period2>,
__not_<__is_float<_Rep2>>>>>>
constexpr duration(const duration<_Rep2, _Period2>& __d)
: __r(duration_cast<duration>(__d).count()) { }
~duration() = default;
duration& operator=(const duration&) = default;
// 20.11.5.2 observer
constexpr rep
count() const
{ return __r; }
// 20.11.5.3 arithmetic
constexpr duration
operator+() const
{ return *this; }
constexpr duration
operator-() const
{ return duration(-__r); }
_GLIBCXX17_CONSTEXPR duration&
operator++()
{
++__r;
return *this;
}
_GLIBCXX17_CONSTEXPR duration
operator++(int)
{ return duration(__r++); }
_GLIBCXX17_CONSTEXPR duration&
operator--()
{
--__r;
return *this;
}
_GLIBCXX17_CONSTEXPR duration
operator--(int)
{ return duration(__r--); }
_GLIBCXX17_CONSTEXPR duration&
operator+=(const duration& __d)
{
__r += __d.count();
return *this;
}
_GLIBCXX17_CONSTEXPR duration&
operator-=(const duration& __d)
{
__r -= __d.count();
return *this;
}
_GLIBCXX17_CONSTEXPR duration&
operator*=(const rep& __rhs)
{
__r *= __rhs;
return *this;
}
_GLIBCXX17_CONSTEXPR duration&
operator/=(const rep& __rhs)
{
__r /= __rhs;
return *this;
}
// DR 934.
template<typename _Rep2 = rep>
_GLIBCXX17_CONSTEXPR
typename enable_if<!treat_as_floating_point<_Rep2>::value,
duration&>::type
operator%=(const rep& __rhs)
{
__r %= __rhs;
return *this;
}
template<typename _Rep2 = rep>
_GLIBCXX17_CONSTEXPR
typename enable_if<!treat_as_floating_point<_Rep2>::value,
duration&>::type
operator%=(const duration& __d)
{
__r %= __d.count();
return *this;
}
// 20.11.5.4 special values
static constexpr duration
zero() noexcept
{ return duration(duration_values<rep>::zero()); }
static constexpr duration
min() noexcept
{ return duration(duration_values<rep>::min()); }
static constexpr duration
max() noexcept
{ return duration(duration_values<rep>::max()); }
private:
rep __r;
};
template<typename _Rep1, typename _Period1,
typename _Rep2, typename _Period2>
constexpr typename common_type<duration<_Rep1, _Period1>,
duration<_Rep2, _Period2>>::type
operator+(const duration<_Rep1, _Period1>& __lhs,
const duration<_Rep2, _Period2>& __rhs)
{
typedef duration<_Rep1, _Period1> __dur1;
typedef duration<_Rep2, _Period2> __dur2;
typedef typename common_type<__dur1,__dur2>::type __cd;
return __cd(__cd(__lhs).count() + __cd(__rhs).count());
}
template<typename _Rep1, typename _Period1,
typename _Rep2, typename _Period2>
constexpr typename common_type<duration<_Rep1, _Period1>,
duration<_Rep2, _Period2>>::type
operator-(const duration<_Rep1, _Period1>& __lhs,
const duration<_Rep2, _Period2>& __rhs)
{
typedef duration<_Rep1, _Period1> __dur1;
typedef duration<_Rep2, _Period2> __dur2;
typedef typename common_type<__dur1,__dur2>::type __cd;
return __cd(__cd(__lhs).count() - __cd(__rhs).count());
}
// SFINAE helper to obtain common_type<_Rep1, _Rep2> only if _Rep2
// is implicitly convertible to it.
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 3050. Conversion specification problem in chrono::duration constructor
template<typename _Rep1, typename _Rep2,
typename _CRep = typename common_type<_Rep1, _Rep2>::type>
using __common_rep_t = typename
enable_if<is_convertible<const _Rep2&, _CRep>::value, _CRep>::type;
template<typename _Rep1, typename _Period, typename _Rep2>
constexpr duration<__common_rep_t<_Rep1, _Rep2>, _Period>
operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
{
typedef duration<typename common_type<_Rep1, _Rep2>::type, _Period>
__cd;
return __cd(__cd(__d).count() * __s);
}
template<typename _Rep1, typename _Rep2, typename _Period>
constexpr duration<__common_rep_t<_Rep2, _Rep1>, _Period>
operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d)
{ return __d * __s; }
template<typename _Rep1, typename _Period, typename _Rep2>
constexpr
duration<__common_rep_t<_Rep1, __disable_if_is_duration<_Rep2>>, _Period>
operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
{
typedef duration<typename common_type<_Rep1, _Rep2>::type, _Period>
__cd;
return __cd(__cd(__d).count() / __s);
}
template<typename _Rep1, typename _Period1,
typename _Rep2, typename _Period2>
constexpr typename common_type<_Rep1, _Rep2>::type
operator/(const duration<_Rep1, _Period1>& __lhs,
const duration<_Rep2, _Period2>& __rhs)
{
typedef duration<_Rep1, _Period1> __dur1;
typedef duration<_Rep2, _Period2> __dur2;
typedef typename common_type<__dur1,__dur2>::type __cd;
return __cd(__lhs).count() / __cd(__rhs).count();
}
// DR 934.
template<typename _Rep1, typename _Period, typename _Rep2>
constexpr
duration<__common_rep_t<_Rep1, __disable_if_is_duration<_Rep2>>, _Period>
operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
{
typedef duration<typename common_type<_Rep1, _Rep2>::type, _Period>
__cd;
return __cd(__cd(__d).count() % __s);
}
template<typename _Rep1, typename _Period1,
typename _Rep2, typename _Period2>
constexpr typename common_type<duration<_Rep1, _Period1>,
duration<_Rep2, _Period2>>::type
operator%(const duration<_Rep1, _Period1>& __lhs,
const duration<_Rep2, _Period2>& __rhs)
{
typedef duration<_Rep1, _Period1> __dur1;
typedef duration<_Rep2, _Period2> __dur2;
typedef typename common_type<__dur1,__dur2>::type __cd;
return __cd(__cd(__lhs).count() % __cd(__rhs).count());
}
// comparisons
template<typename _Rep1, typename _Period1,
typename _Rep2, typename _Period2>
constexpr bool
operator==(const duration<_Rep1, _Period1>& __lhs,
const duration<_Rep2, _Period2>& __rhs)
{
typedef duration<_Rep1, _Period1> __dur1;
typedef duration<_Rep2, _Period2> __dur2;
typedef typename common_type<__dur1,__dur2>::type __ct;
return __ct(__lhs).count() == __ct(__rhs).count();
}
template<typename _Rep1, typename _Period1,
typename _Rep2, typename _Period2>
constexpr bool
operator<(const duration<_Rep1, _Period1>& __lhs,
const duration<_Rep2, _Period2>& __rhs)
{
typedef duration<_Rep1, _Period1> __dur1;
typedef duration<_Rep2, _Period2> __dur2;
typedef typename common_type<__dur1,__dur2>::type __ct;
return __ct(__lhs).count() < __ct(__rhs).count();
}
template<typename _Rep1, typename _Period1,
typename _Rep2, typename _Period2>
constexpr bool
operator!=(const duration<_Rep1, _Period1>& __lhs,
const duration<_Rep2, _Period2>& __rhs)
{ return !(__lhs == __rhs); }
template<typename _Rep1, typename _Period1,
typename _Rep2, typename _Period2>
constexpr bool
operator<=(const duration<_Rep1, _Period1>& __lhs,
const duration<_Rep2, _Period2>& __rhs)
{ return !(__rhs < __lhs); }
template<typename _Rep1, typename _Period1,
typename _Rep2, typename _Period2>
constexpr bool
operator>(const duration<_Rep1, _Period1>& __lhs,
const duration<_Rep2, _Period2>& __rhs)
{ return __rhs < __lhs; }
template<typename _Rep1, typename _Period1,
typename _Rep2, typename _Period2>
constexpr bool
operator>=(const duration<_Rep1, _Period1>& __lhs,
const duration<_Rep2, _Period2>& __rhs)
{ return !(__lhs < __rhs); }
/// nanoseconds
typedef duration<int64_t, nano> nanoseconds;
/// microseconds
typedef duration<int64_t, micro> microseconds;
/// milliseconds
typedef duration<int64_t, milli> milliseconds;
/// seconds
typedef duration<int64_t> seconds;
/// minutes
typedef duration<int64_t, ratio< 60>> minutes;
/// hours
typedef duration<int64_t, ratio<3600>> hours;
/// time_point
template<typename _Clock, typename _Dur>
struct time_point
{
typedef _Clock clock;
typedef _Dur duration;
typedef typename duration::rep rep;
typedef typename duration::period period;
constexpr time_point() : __d(duration::zero())
{ }
constexpr explicit time_point(const duration& __dur)
: __d(__dur)
{ }
// conversions
template<typename _Dur2,
typename = _Require<is_convertible<_Dur2, _Dur>>>
constexpr time_point(const time_point<clock, _Dur2>& __t)
: __d(__t.time_since_epoch())
{ }
// observer
constexpr duration
time_since_epoch() const
{ return __d; }
// arithmetic
_GLIBCXX17_CONSTEXPR time_point&
operator+=(const duration& __dur)
{
__d += __dur;
return *this;
}
_GLIBCXX17_CONSTEXPR time_point&
operator-=(const duration& __dur)
{
__d -= __dur;
return *this;
}
// special values
static constexpr time_point
min() noexcept
{ return time_point(duration::min()); }
static constexpr time_point
max() noexcept
{ return time_point(duration::max()); }
private:
duration __d;
};
/// time_point_cast
template<typename _ToDur, typename _Clock, typename _Dur>
constexpr typename enable_if<__is_duration<_ToDur>::value,
time_point<_Clock, _ToDur>>::type
time_point_cast(const time_point<_Clock, _Dur>& __t)
{
typedef time_point<_Clock, _ToDur> __time_point;
return __time_point(duration_cast<_ToDur>(__t.time_since_epoch()));
}
#if __cplusplus > 201402L
template<typename _ToDur, typename _Clock, typename _Dur>
constexpr
enable_if_t<__is_duration<_ToDur>::value, time_point<_Clock, _ToDur>>
floor(const time_point<_Clock, _Dur>& __tp)
{
return time_point<_Clock, _ToDur>{
chrono::floor<_ToDur>(__tp.time_since_epoch())};
}
template<typename _ToDur, typename _Clock, typename _Dur>
constexpr
enable_if_t<__is_duration<_ToDur>::value, time_point<_Clock, _ToDur>>
ceil(const time_point<_Clock, _Dur>& __tp)
{
return time_point<_Clock, _ToDur>{
chrono::ceil<_ToDur>(__tp.time_since_epoch())};
}
template<typename _ToDur, typename _Clock, typename _Dur>
constexpr enable_if_t<
__and_<__is_duration<_ToDur>,
__not_<treat_as_floating_point<typename _ToDur::rep>>>::value,
time_point<_Clock, _ToDur>>
round(const time_point<_Clock, _Dur>& __tp)
{
return time_point<_Clock, _ToDur>{
chrono::round<_ToDur>(__tp.time_since_epoch())};
}
#endif // C++17
template<typename _Clock, typename _Dur1,
typename _Rep2, typename _Period2>
constexpr time_point<_Clock,
typename common_type<_Dur1, duration<_Rep2, _Period2>>::type>
operator+(const time_point<_Clock, _Dur1>& __lhs,
const duration<_Rep2, _Period2>& __rhs)
{
typedef duration<_Rep2, _Period2> __dur2;
typedef typename common_type<_Dur1,__dur2>::type __ct;
typedef time_point<_Clock, __ct> __time_point;
return __time_point(__lhs.time_since_epoch() + __rhs);
}
template<typename _Rep1, typename _Period1,
typename _Clock, typename _Dur2>
constexpr time_point<_Clock,
typename common_type<duration<_Rep1, _Period1>, _Dur2>::type>
operator+(const duration<_Rep1, _Period1>& __lhs,
const time_point<_Clock, _Dur2>& __rhs)
{
typedef duration<_Rep1, _Period1> __dur1;
typedef typename common_type<__dur1,_Dur2>::type __ct;
typedef time_point<_Clock, __ct> __time_point;
return __time_point(__rhs.time_since_epoch() + __lhs);
}
template<typename _Clock, typename _Dur1,
typename _Rep2, typename _Period2>
constexpr time_point<_Clock,
typename common_type<_Dur1, duration<_Rep2, _Period2>>::type>
operator-(const time_point<_Clock, _Dur1>& __lhs,
const duration<_Rep2, _Period2>& __rhs)
{
typedef duration<_Rep2, _Period2> __dur2;
typedef typename common_type<_Dur1,__dur2>::type __ct;
typedef time_point<_Clock, __ct> __time_point;
return __time_point(__lhs.time_since_epoch() -__rhs);
}
template<typename _Clock, typename _Dur1, typename _Dur2>
constexpr typename common_type<_Dur1, _Dur2>::type
operator-(const time_point<_Clock, _Dur1>& __lhs,
const time_point<_Clock, _Dur2>& __rhs)
{ return __lhs.time_since_epoch() - __rhs.time_since_epoch(); }
template<typename _Clock, typename _Dur1, typename _Dur2>
constexpr bool
operator==(const time_point<_Clock, _Dur1>& __lhs,
const time_point<_Clock, _Dur2>& __rhs)
{ return __lhs.time_since_epoch() == __rhs.time_since_epoch(); }
template<typename _Clock, typename _Dur1, typename _Dur2>
constexpr bool
operator!=(const time_point<_Clock, _Dur1>& __lhs,
const time_point<_Clock, _Dur2>& __rhs)
{ return !(__lhs == __rhs); }
template<typename _Clock, typename _Dur1, typename _Dur2>
constexpr bool
operator<(const time_point<_Clock, _Dur1>& __lhs,
const time_point<_Clock, _Dur2>& __rhs)
{ return __lhs.time_since_epoch() < __rhs.time_since_epoch(); }
template<typename _Clock, typename _Dur1, typename _Dur2>
constexpr bool
operator<=(const time_point<_Clock, _Dur1>& __lhs,
const time_point<_Clock, _Dur2>& __rhs)
{ return !(__rhs < __lhs); }
template<typename _Clock, typename _Dur1, typename _Dur2>
constexpr bool
operator>(const time_point<_Clock, _Dur1>& __lhs,
const time_point<_Clock, _Dur2>& __rhs)
{ return __rhs < __lhs; }
template<typename _Clock, typename _Dur1, typename _Dur2>
constexpr bool
operator>=(const time_point<_Clock, _Dur1>& __lhs,
const time_point<_Clock, _Dur2>& __rhs)
{ return !(__lhs < __rhs); }
// Clocks.
// Why nanosecond resolution as the default?
// Why have std::system_clock always count in the highest
// resolution (ie nanoseconds), even if on some OSes the low 3
// or 9 decimal digits will be always zero? This allows later
// implementations to change the system_clock::now()
// implementation any time to provide better resolution without
// changing function signature or units.
// To support the (forward) evolution of the library's defined
// clocks, wrap inside inline namespace so that the current
// defintions of system_clock, steady_clock, and
// high_resolution_clock types are uniquely mangled. This way, new
// code can use the latests clocks, while the library can contain
// compatibility definitions for previous versions. At some
// point, when these clocks settle down, the inlined namespaces
// can be removed. XXX GLIBCXX_ABI Deprecated
inline namespace _V2 {
/**
* @brief System clock.
*
* Time returned represents wall time from the system-wide clock.
*/
struct system_clock
{
typedef chrono::nanoseconds duration;
typedef duration::rep rep;
typedef duration::period period;
typedef chrono::time_point<system_clock, duration> time_point;
static_assert(system_clock::duration::min()
< system_clock::duration::zero(),
"a clock's minimum duration cannot be less than its epoch");
static constexpr bool is_steady = false;
static time_point
now() noexcept;
// Map to C API
static std::time_t
to_time_t(const time_point& __t) noexcept
{
return std::time_t(duration_cast<chrono::seconds>
(__t.time_since_epoch()).count());
}
static time_point
from_time_t(std::time_t __t) noexcept
{
typedef chrono::time_point<system_clock, seconds> __from;
return time_point_cast<system_clock::duration>
(__from(chrono::seconds(__t)));
}
};
/**
* @brief Monotonic clock
*
* Time returned has the property of only increasing at a uniform rate.
*/
struct steady_clock
{
typedef chrono::nanoseconds duration;
typedef duration::rep rep;
typedef duration::period period;
typedef chrono::time_point<steady_clock, duration> time_point;
static constexpr bool is_steady = true;
static time_point
now() noexcept;
};
/**
* @brief Highest-resolution clock
*
* This is the clock "with the shortest tick period." Alias to
* std::system_clock until higher-than-nanosecond definitions
* become feasible.
*/
using high_resolution_clock = system_clock;
} // end inline namespace _V2
} // namespace chrono
#if __cplusplus > 201103L
#define __cpp_lib_chrono_udls 201304
inline namespace literals
{
inline namespace chrono_literals
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wliteral-suffix"
template<typename _Rep, unsigned long long _Val>
struct _Checked_integral_constant
: integral_constant<_Rep, static_cast<_Rep>(_Val)>
{
static_assert(_Checked_integral_constant::value >= 0
&& _Checked_integral_constant::value == _Val,
"literal value cannot be represented by duration type");
};
template<typename _Dur, char... _Digits>
constexpr _Dur __check_overflow()
{
using _Val = __parse_int::_Parse_int<_Digits...>;
using _Rep = typename _Dur::rep;
// TODO: should be simply integral_constant<_Rep, _Val::value>
// but GCC doesn't reject narrowing conversions to _Rep.
using _CheckedVal = _Checked_integral_constant<_Rep, _Val::value>;
return _Dur{_CheckedVal::value};
}
constexpr chrono::duration<long double, ratio<3600,1>>
operator""h(long double __hours)
{ return chrono::duration<long double, ratio<3600,1>>{__hours}; }
template <char... _Digits>
constexpr chrono::hours
operator""h()
{ return __check_overflow<chrono::hours, _Digits...>(); }
constexpr chrono::duration<long double, ratio<60,1>>
operator""min(long double __mins)
{ return chrono::duration<long double, ratio<60,1>>{__mins}; }
template <char... _Digits>
constexpr chrono::minutes
operator""min()
{ return __check_overflow<chrono::minutes, _Digits...>(); }
constexpr chrono::duration<long double>
operator""s(long double __secs)
{ return chrono::duration<long double>{__secs}; }
template <char... _Digits>
constexpr chrono::seconds
operator""s()
{ return __check_overflow<chrono::seconds, _Digits...>(); }
constexpr chrono::duration<long double, milli>
operator""ms(long double __msecs)
{ return chrono::duration<long double, milli>{__msecs}; }
template <char... _Digits>
constexpr chrono::milliseconds
operator""ms()
{ return __check_overflow<chrono::milliseconds, _Digits...>(); }
constexpr chrono::duration<long double, micro>
operator""us(long double __usecs)
{ return chrono::duration<long double, micro>{__usecs}; }
template <char... _Digits>
constexpr chrono::microseconds
operator""us()
{ return __check_overflow<chrono::microseconds, _Digits...>(); }
constexpr chrono::duration<long double, nano>
operator""ns(long double __nsecs)
{ return chrono::duration<long double, nano>{__nsecs}; }
template <char... _Digits>
constexpr chrono::nanoseconds
operator""ns()
{ return __check_overflow<chrono::nanoseconds, _Digits...>(); }
#pragma GCC diagnostic pop
} // inline namespace chrono_literals
} // inline namespace literals
namespace chrono
{
using namespace literals::chrono_literals;
} // namespace chrono
#endif // C++14
// @} group chrono
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif //_GLIBCXX_USE_C99_STDINT_TR1
#endif // C++11
#endif //_GLIBCXX_CHRONO
c++/8/streambuf 0000644 00000072501 15201526705 0007206 0 ustar 00 // Stream buffer classes -*- C++ -*-
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/streambuf
* This is a Standard C++ Library header.
*/
//
// ISO C++ 14882: 27.5 Stream buffers
//
#ifndef _GLIBXX_STREAMBUF
#define _GLIBXX_STREAMBUF 1
#pragma GCC system_header
#include <bits/c++config.h>
#include <iosfwd>
#include <bits/localefwd.h>
#include <bits/ios_base.h>
#include <bits/cpp_type_traits.h>
#include <ext/type_traits.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
#define _IsUnused __attribute__ ((__unused__))
template<typename _CharT, typename _Traits>
streamsize
__copy_streambufs_eof(basic_streambuf<_CharT, _Traits>*,
basic_streambuf<_CharT, _Traits>*, bool&);
/**
* @brief The actual work of input and output (interface).
* @ingroup io
*
* @tparam _CharT Type of character stream.
* @tparam _Traits Traits for character type, defaults to
* char_traits<_CharT>.
*
* This is a base class. Derived stream buffers each control a
* pair of character sequences: one for input, and one for output.
*
* Section [27.5.1] of the standard describes the requirements and
* behavior of stream buffer classes. That section (three paragraphs)
* is reproduced here, for simplicity and accuracy.
*
* -# Stream buffers can impose various constraints on the sequences
* they control. Some constraints are:
* - The controlled input sequence can be not readable.
* - The controlled output sequence can be not writable.
* - The controlled sequences can be associated with the contents of
* other representations for character sequences, such as external
* files.
* - The controlled sequences can support operations @e directly to or
* from associated sequences.
* - The controlled sequences can impose limitations on how the
* program can read characters from a sequence, write characters to
* a sequence, put characters back into an input sequence, or alter
* the stream position.
* .
* -# Each sequence is characterized by three pointers which, if non-null,
* all point into the same @c charT array object. The array object
* represents, at any moment, a (sub)sequence of characters from the
* sequence. Operations performed on a sequence alter the values
* stored in these pointers, perform reads and writes directly to or
* from associated sequences, and alter <em>the stream position</em> and
* conversion state as needed to maintain this subsequence relationship.
* The three pointers are:
* - the <em>beginning pointer</em>, or lowest element address in the
* array (called @e xbeg here);
* - the <em>next pointer</em>, or next element address that is a
* current candidate for reading or writing (called @e xnext here);
* - the <em>end pointer</em>, or first element address beyond the
* end of the array (called @e xend here).
* .
* -# The following semantic constraints shall always apply for any set
* of three pointers for a sequence, using the pointer names given
* immediately above:
* - If @e xnext is not a null pointer, then @e xbeg and @e xend shall
* also be non-null pointers into the same @c charT array, as
* described above; otherwise, @e xbeg and @e xend shall also be null.
* - If @e xnext is not a null pointer and @e xnext < @e xend for an
* output sequence, then a <em>write position</em> is available.
* In this case, @e *xnext shall be assignable as the next element
* to write (to put, or to store a character value, into the sequence).
* - If @e xnext is not a null pointer and @e xbeg < @e xnext for an
* input sequence, then a <em>putback position</em> is available.
* In this case, @e xnext[-1] shall have a defined value and is the
* next (preceding) element to store a character that is put back
* into the input sequence.
* - If @e xnext is not a null pointer and @e xnext< @e xend for an
* input sequence, then a <em>read position</em> is available.
* In this case, @e *xnext shall have a defined value and is the
* next element to read (to get, or to obtain a character value,
* from the sequence).
*/
template<typename _CharT, typename _Traits>
class basic_streambuf
{
public:
//@{
/**
* These are standard types. They permit a standardized way of
* referring to names of (or names dependent on) the template
* parameters, which are specific to the implementation.
*/
typedef _CharT char_type;
typedef _Traits traits_type;
typedef typename traits_type::int_type int_type;
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
//@}
//@{
/// This is a non-standard type.
typedef basic_streambuf<char_type, traits_type> __streambuf_type;
//@}
friend class basic_ios<char_type, traits_type>;
friend class basic_istream<char_type, traits_type>;
friend class basic_ostream<char_type, traits_type>;
friend class istreambuf_iterator<char_type, traits_type>;
friend class ostreambuf_iterator<char_type, traits_type>;
friend streamsize
__copy_streambufs_eof<>(basic_streambuf*, basic_streambuf*, bool&);
template<bool _IsMove, typename _CharT2>
friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value,
_CharT2*>::__type
__copy_move_a2(istreambuf_iterator<_CharT2>,
istreambuf_iterator<_CharT2>, _CharT2*);
template<typename _CharT2>
friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value,
istreambuf_iterator<_CharT2> >::__type
find(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>,
const _CharT2&);
template<typename _CharT2, typename _Distance>
friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value,
void>::__type
advance(istreambuf_iterator<_CharT2>&, _Distance);
template<typename _CharT2, typename _Traits2>
friend basic_istream<_CharT2, _Traits2>&
operator>>(basic_istream<_CharT2, _Traits2>&, _CharT2*);
template<typename _CharT2, typename _Traits2, typename _Alloc>
friend basic_istream<_CharT2, _Traits2>&
operator>>(basic_istream<_CharT2, _Traits2>&,
basic_string<_CharT2, _Traits2, _Alloc>&);
template<typename _CharT2, typename _Traits2, typename _Alloc>
friend basic_istream<_CharT2, _Traits2>&
getline(basic_istream<_CharT2, _Traits2>&,
basic_string<_CharT2, _Traits2, _Alloc>&, _CharT2);
protected:
/*
* This is based on _IO_FILE, just reordered to be more consistent,
* and is intended to be the most minimal abstraction for an
* internal buffer.
* - get == input == read
* - put == output == write
*/
char_type* _M_in_beg; ///< Start of get area.
char_type* _M_in_cur; ///< Current read area.
char_type* _M_in_end; ///< End of get area.
char_type* _M_out_beg; ///< Start of put area.
char_type* _M_out_cur; ///< Current put area.
char_type* _M_out_end; ///< End of put area.
/// Current locale setting.
locale _M_buf_locale;
public:
/// Destructor deallocates no buffer space.
virtual
~basic_streambuf()
{ }
// [27.5.2.2.1] locales
/**
* @brief Entry point for imbue().
* @param __loc The new locale.
* @return The previous locale.
*
* Calls the derived imbue(__loc).
*/
locale
pubimbue(const locale& __loc)
{
locale __tmp(this->getloc());
this->imbue(__loc);
_M_buf_locale = __loc;
return __tmp;
}
/**
* @brief Locale access.
* @return The current locale in effect.
*
* If pubimbue(loc) has been called, then the most recent @c loc
* is returned. Otherwise the global locale in effect at the time
* of construction is returned.
*/
locale
getloc() const
{ return _M_buf_locale; }
// [27.5.2.2.2] buffer management and positioning
//@{
/**
* @brief Entry points for derived buffer functions.
*
* The public versions of @c pubfoo dispatch to the protected
* derived @c foo member functions, passing the arguments (if any)
* and returning the result unchanged.
*/
basic_streambuf*
pubsetbuf(char_type* __s, streamsize __n)
{ return this->setbuf(__s, __n); }
/**
* @brief Alters the stream position.
* @param __off Offset.
* @param __way Value for ios_base::seekdir.
* @param __mode Value for ios_base::openmode.
*
* Calls virtual seekoff function.
*/
pos_type
pubseekoff(off_type __off, ios_base::seekdir __way,
ios_base::openmode __mode = ios_base::in | ios_base::out)
{ return this->seekoff(__off, __way, __mode); }
/**
* @brief Alters the stream position.
* @param __sp Position
* @param __mode Value for ios_base::openmode.
*
* Calls virtual seekpos function.
*/
pos_type
pubseekpos(pos_type __sp,
ios_base::openmode __mode = ios_base::in | ios_base::out)
{ return this->seekpos(__sp, __mode); }
/**
* @brief Calls virtual sync function.
*/
int
pubsync() { return this->sync(); }
//@}
// [27.5.2.2.3] get area
/**
* @brief Looking ahead into the stream.
* @return The number of characters available.
*
* If a read position is available, returns the number of characters
* available for reading before the buffer must be refilled.
* Otherwise returns the derived @c showmanyc().
*/
streamsize
in_avail()
{
const streamsize __ret = this->egptr() - this->gptr();
return __ret ? __ret : this->showmanyc();
}
/**
* @brief Getting the next character.
* @return The next character, or eof.
*
* Calls @c sbumpc(), and if that function returns
* @c traits::eof(), so does this function. Otherwise, @c sgetc().
*/
int_type
snextc()
{
int_type __ret = traits_type::eof();
if (__builtin_expect(!traits_type::eq_int_type(this->sbumpc(),
__ret), true))
__ret = this->sgetc();
return __ret;
}
/**
* @brief Getting the next character.
* @return The next character, or eof.
*
* If the input read position is available, returns that character
* and increments the read pointer, otherwise calls and returns
* @c uflow().
*/
int_type
sbumpc()
{
int_type __ret;
if (__builtin_expect(this->gptr() < this->egptr(), true))
{
__ret = traits_type::to_int_type(*this->gptr());
this->gbump(1);
}
else
__ret = this->uflow();
return __ret;
}
/**
* @brief Getting the next character.
* @return The next character, or eof.
*
* If the input read position is available, returns that character,
* otherwise calls and returns @c underflow(). Does not move the
* read position after fetching the character.
*/
int_type
sgetc()
{
int_type __ret;
if (__builtin_expect(this->gptr() < this->egptr(), true))
__ret = traits_type::to_int_type(*this->gptr());
else
__ret = this->underflow();
return __ret;
}
/**
* @brief Entry point for xsgetn.
* @param __s A buffer area.
* @param __n A count.
*
* Returns xsgetn(__s,__n). The effect is to fill @a __s[0] through
* @a __s[__n-1] with characters from the input sequence, if possible.
*/
streamsize
sgetn(char_type* __s, streamsize __n)
{ return this->xsgetn(__s, __n); }
// [27.5.2.2.4] putback
/**
* @brief Pushing characters back into the input stream.
* @param __c The character to push back.
* @return The previous character, if possible.
*
* Similar to sungetc(), but @a __c is pushed onto the stream
* instead of <em>the previous character.</em> If successful,
* the next character fetched from the input stream will be @a
* __c.
*/
int_type
sputbackc(char_type __c)
{
int_type __ret;
const bool __testpos = this->eback() < this->gptr();
if (__builtin_expect(!__testpos ||
!traits_type::eq(__c, this->gptr()[-1]), false))
__ret = this->pbackfail(traits_type::to_int_type(__c));
else
{
this->gbump(-1);
__ret = traits_type::to_int_type(*this->gptr());
}
return __ret;
}
/**
* @brief Moving backwards in the input stream.
* @return The previous character, if possible.
*
* If a putback position is available, this function decrements
* the input pointer and returns that character. Otherwise,
* calls and returns pbackfail(). The effect is to @a unget
* the last character @a gotten.
*/
int_type
sungetc()
{
int_type __ret;
if (__builtin_expect(this->eback() < this->gptr(), true))
{
this->gbump(-1);
__ret = traits_type::to_int_type(*this->gptr());
}
else
__ret = this->pbackfail();
return __ret;
}
// [27.5.2.2.5] put area
/**
* @brief Entry point for all single-character output functions.
* @param __c A character to output.
* @return @a __c, if possible.
*
* One of two public output functions.
*
* If a write position is available for the output sequence (i.e.,
* the buffer is not full), stores @a __c in that position, increments
* the position, and returns @c traits::to_int_type(__c). If a write
* position is not available, returns @c overflow(__c).
*/
int_type
sputc(char_type __c)
{
int_type __ret;
if (__builtin_expect(this->pptr() < this->epptr(), true))
{
*this->pptr() = __c;
this->pbump(1);
__ret = traits_type::to_int_type(__c);
}
else
__ret = this->overflow(traits_type::to_int_type(__c));
return __ret;
}
/**
* @brief Entry point for all single-character output functions.
* @param __s A buffer read area.
* @param __n A count.
*
* One of two public output functions.
*
*
* Returns xsputn(__s,__n). The effect is to write @a __s[0] through
* @a __s[__n-1] to the output sequence, if possible.
*/
streamsize
sputn(const char_type* __s, streamsize __n)
{ return this->xsputn(__s, __n); }
protected:
/**
* @brief Base constructor.
*
* Only called from derived constructors, and sets up all the
* buffer data to zero, including the pointers described in the
* basic_streambuf class description. Note that, as a result,
* - the class starts with no read nor write positions available,
* - this is not an error
*/
basic_streambuf()
: _M_in_beg(0), _M_in_cur(0), _M_in_end(0),
_M_out_beg(0), _M_out_cur(0), _M_out_end(0),
_M_buf_locale(locale())
{ }
// [27.5.2.3.1] get area access
//@{
/**
* @brief Access to the get area.
*
* These functions are only available to other protected functions,
* including derived classes.
*
* - eback() returns the beginning pointer for the input sequence
* - gptr() returns the next pointer for the input sequence
* - egptr() returns the end pointer for the input sequence
*/
char_type*
eback() const { return _M_in_beg; }
char_type*
gptr() const { return _M_in_cur; }
char_type*
egptr() const { return _M_in_end; }
//@}
/**
* @brief Moving the read position.
* @param __n The delta by which to move.
*
* This just advances the read position without returning any data.
*/
void
gbump(int __n) { _M_in_cur += __n; }
/**
* @brief Setting the three read area pointers.
* @param __gbeg A pointer.
* @param __gnext A pointer.
* @param __gend A pointer.
* @post @a __gbeg == @c eback(), @a __gnext == @c gptr(), and
* @a __gend == @c egptr()
*/
void
setg(char_type* __gbeg, char_type* __gnext, char_type* __gend)
{
_M_in_beg = __gbeg;
_M_in_cur = __gnext;
_M_in_end = __gend;
}
// [27.5.2.3.2] put area access
//@{
/**
* @brief Access to the put area.
*
* These functions are only available to other protected functions,
* including derived classes.
*
* - pbase() returns the beginning pointer for the output sequence
* - pptr() returns the next pointer for the output sequence
* - epptr() returns the end pointer for the output sequence
*/
char_type*
pbase() const { return _M_out_beg; }
char_type*
pptr() const { return _M_out_cur; }
char_type*
epptr() const { return _M_out_end; }
//@}
/**
* @brief Moving the write position.
* @param __n The delta by which to move.
*
* This just advances the write position without returning any data.
*/
void
pbump(int __n) { _M_out_cur += __n; }
/**
* @brief Setting the three write area pointers.
* @param __pbeg A pointer.
* @param __pend A pointer.
* @post @a __pbeg == @c pbase(), @a __pbeg == @c pptr(), and
* @a __pend == @c epptr()
*/
void
setp(char_type* __pbeg, char_type* __pend)
{
_M_out_beg = _M_out_cur = __pbeg;
_M_out_end = __pend;
}
// [27.5.2.4] virtual functions
// [27.5.2.4.1] locales
/**
* @brief Changes translations.
* @param __loc A new locale.
*
* Translations done during I/O which depend on the current
* locale are changed by this call. The standard adds,
* <em>Between invocations of this function a class derived
* from streambuf can safely cache results of calls to locale
* functions and to members of facets so obtained.</em>
*
* @note Base class version does nothing.
*/
virtual void
imbue(const locale& __loc _IsUnused)
{ }
// [27.5.2.4.2] buffer management and positioning
/**
* @brief Manipulates the buffer.
*
* Each derived class provides its own appropriate behavior. See
* the next-to-last paragraph of
* https://gcc.gnu.org/onlinedocs/libstdc++/manual/streambufs.html#io.streambuf.buffering
* for more on this function.
*
* @note Base class version does nothing, returns @c this.
*/
virtual basic_streambuf<char_type,_Traits>*
setbuf(char_type*, streamsize)
{ return this; }
/**
* @brief Alters the stream positions.
*
* Each derived class provides its own appropriate behavior.
* @note Base class version does nothing, returns a @c pos_type
* that represents an invalid stream position.
*/
virtual pos_type
seekoff(off_type, ios_base::seekdir,
ios_base::openmode /*__mode*/ = ios_base::in | ios_base::out)
{ return pos_type(off_type(-1)); }
/**
* @brief Alters the stream positions.
*
* Each derived class provides its own appropriate behavior.
* @note Base class version does nothing, returns a @c pos_type
* that represents an invalid stream position.
*/
virtual pos_type
seekpos(pos_type,
ios_base::openmode /*__mode*/ = ios_base::in | ios_base::out)
{ return pos_type(off_type(-1)); }
/**
* @brief Synchronizes the buffer arrays with the controlled sequences.
* @return -1 on failure.
*
* Each derived class provides its own appropriate behavior,
* including the definition of @a failure.
* @note Base class version does nothing, returns zero.
*/
virtual int
sync() { return 0; }
// [27.5.2.4.3] get area
/**
* @brief Investigating the data available.
* @return An estimate of the number of characters available in the
* input sequence, or -1.
*
* <em>If it returns a positive value, then successive calls to
* @c underflow() will not return @c traits::eof() until at
* least that number of characters have been supplied. If @c
* showmanyc() returns -1, then calls to @c underflow() or @c
* uflow() will fail.</em> [27.5.2.4.3]/1
*
* @note Base class version does nothing, returns zero.
* @note The standard adds that <em>the intention is not only that the
* calls [to underflow or uflow] will not return @c eof() but
* that they will return immediately.</em>
* @note The standard adds that <em>the morphemes of @c showmanyc are
* @b es-how-many-see, not @b show-manic.</em>
*/
virtual streamsize
showmanyc() { return 0; }
/**
* @brief Multiple character extraction.
* @param __s A buffer area.
* @param __n Maximum number of characters to assign.
* @return The number of characters assigned.
*
* Fills @a __s[0] through @a __s[__n-1] with characters from the input
* sequence, as if by @c sbumpc(). Stops when either @a __n characters
* have been copied, or when @c traits::eof() would be copied.
*
* It is expected that derived classes provide a more efficient
* implementation by overriding this definition.
*/
virtual streamsize
xsgetn(char_type* __s, streamsize __n);
/**
* @brief Fetches more data from the controlled sequence.
* @return The first character from the <em>pending sequence</em>.
*
* Informally, this function is called when the input buffer is
* exhausted (or does not exist, as buffering need not actually be
* done). If a buffer exists, it is @a refilled. In either case, the
* next available character is returned, or @c traits::eof() to
* indicate a null pending sequence.
*
* For a formal definition of the pending sequence, see a good text
* such as Langer & Kreft, or [27.5.2.4.3]/7-14.
*
* A functioning input streambuf can be created by overriding only
* this function (no buffer area will be used). For an example, see
* https://gcc.gnu.org/onlinedocs/libstdc++/manual/streambufs.html
*
* @note Base class version does nothing, returns eof().
*/
virtual int_type
underflow()
{ return traits_type::eof(); }
/**
* @brief Fetches more data from the controlled sequence.
* @return The first character from the <em>pending sequence</em>.
*
* Informally, this function does the same thing as @c underflow(),
* and in fact is required to call that function. It also returns
* the new character, like @c underflow() does. However, this
* function also moves the read position forward by one.
*/
virtual int_type
uflow()
{
int_type __ret = traits_type::eof();
const bool __testeof = traits_type::eq_int_type(this->underflow(),
__ret);
if (!__testeof)
{
__ret = traits_type::to_int_type(*this->gptr());
this->gbump(1);
}
return __ret;
}
// [27.5.2.4.4] putback
/**
* @brief Tries to back up the input sequence.
* @param __c The character to be inserted back into the sequence.
* @return eof() on failure, <em>some other value</em> on success
* @post The constraints of @c gptr(), @c eback(), and @c pptr()
* are the same as for @c underflow().
*
* @note Base class version does nothing, returns eof().
*/
virtual int_type
pbackfail(int_type __c _IsUnused = traits_type::eof())
{ return traits_type::eof(); }
// Put area:
/**
* @brief Multiple character insertion.
* @param __s A buffer area.
* @param __n Maximum number of characters to write.
* @return The number of characters written.
*
* Writes @a __s[0] through @a __s[__n-1] to the output sequence, as if
* by @c sputc(). Stops when either @a n characters have been
* copied, or when @c sputc() would return @c traits::eof().
*
* It is expected that derived classes provide a more efficient
* implementation by overriding this definition.
*/
virtual streamsize
xsputn(const char_type* __s, streamsize __n);
/**
* @brief Consumes data from the buffer; writes to the
* controlled sequence.
* @param __c An additional character to consume.
* @return eof() to indicate failure, something else (usually
* @a __c, or not_eof())
*
* Informally, this function is called when the output buffer
* is full (or does not exist, as buffering need not actually
* be done). If a buffer exists, it is @a consumed, with
* <em>some effect</em> on the controlled sequence.
* (Typically, the buffer is written out to the sequence
* verbatim.) In either case, the character @a c is also
* written out, if @a __c is not @c eof().
*
* For a formal definition of this function, see a good text
* such as Langer & Kreft, or [27.5.2.4.5]/3-7.
*
* A functioning output streambuf can be created by overriding only
* this function (no buffer area will be used).
*
* @note Base class version does nothing, returns eof().
*/
virtual int_type
overflow(int_type __c _IsUnused = traits_type::eof())
{ return traits_type::eof(); }
#if _GLIBCXX_USE_DEPRECATED && __cplusplus <= 201402L
// Annex D.6 (removed in C++17)
public:
/**
* @brief Tosses a character.
*
* Advances the read pointer, ignoring the character that would have
* been read.
*
* See http://gcc.gnu.org/ml/libstdc++/2002-05/msg00168.html
*/
#if __cplusplus >= 201103L
[[__deprecated__("stossc is deprecated, use sbumpc instead")]]
#endif
void
stossc()
{
if (this->gptr() < this->egptr())
this->gbump(1);
else
this->uflow();
}
#endif
// Also used by specializations for char and wchar_t in src.
void
__safe_gbump(streamsize __n) { _M_in_cur += __n; }
void
__safe_pbump(streamsize __n) { _M_out_cur += __n; }
#if __cplusplus < 201103L
private:
#else
protected:
#endif
basic_streambuf(const basic_streambuf&);
basic_streambuf&
operator=(const basic_streambuf&);
#if __cplusplus >= 201103L
void
swap(basic_streambuf& __sb)
{
std::swap(_M_in_beg, __sb._M_in_beg);
std::swap(_M_in_cur, __sb._M_in_cur);
std::swap(_M_in_end, __sb._M_in_end);
std::swap(_M_out_beg, __sb._M_out_beg);
std::swap(_M_out_cur, __sb._M_out_cur);
std::swap(_M_out_end, __sb._M_out_end);
std::swap(_M_buf_locale, __sb._M_buf_locale);
}
#endif
};
#if __cplusplus >= 201103L
template<typename _CharT, typename _Traits>
std::basic_streambuf<_CharT, _Traits>::
basic_streambuf(const basic_streambuf&) = default;
template<typename _CharT, typename _Traits>
std::basic_streambuf<_CharT, _Traits>&
std::basic_streambuf<_CharT, _Traits>::
operator=(const basic_streambuf&) = default;
#endif
// Explicit specialization declarations, defined in src/streambuf.cc.
template<>
streamsize
__copy_streambufs_eof(basic_streambuf<char>* __sbin,
basic_streambuf<char>* __sbout, bool& __ineof);
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
streamsize
__copy_streambufs_eof(basic_streambuf<wchar_t>* __sbin,
basic_streambuf<wchar_t>* __sbout, bool& __ineof);
#endif
#undef _IsUnused
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#include <bits/streambuf.tcc>
#endif /* _GLIBCXX_STREAMBUF */
c++/8/cstdio 0000644 00000010527 15201526705 0006503 0 ustar 00 // -*- C++ -*- forwarding header.
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/cstdio
* This is a Standard C++ Library file. You should @c \#include this file
* in your programs, rather than any of the @a *.h implementation files.
*
* This is the C++ version of the Standard C Library header @c stdio.h,
* and its contents are (mostly) the same as that header, but are all
* contained in the namespace @c std (except for names which are defined
* as macros in C).
*/
//
// ISO C++ 14882: 27.8.2 C Library files
//
#pragma GCC system_header
#include <bits/c++config.h>
#include <stdio.h>
#ifndef _GLIBCXX_CSTDIO
#define _GLIBCXX_CSTDIO 1
#if __cplusplus <= 201103L && !defined(_GLIBCXX_HAVE_GETS)
extern "C" char* gets (char* __s) __attribute__((__deprecated__));
#endif
// Get rid of those macros defined in <stdio.h> in lieu of real functions.
#undef clearerr
#undef fclose
#undef feof
#undef ferror
#undef fflush
#undef fgetc
#undef fgetpos
#undef fgets
#undef fopen
#undef fprintf
#undef fputc
#undef fputs
#undef fread
#undef freopen
#undef fscanf
#undef fseek
#undef fsetpos
#undef ftell
#undef fwrite
#undef getc
#undef getchar
#if __cplusplus <= 201103L
# undef gets
#endif
#undef perror
#undef printf
#undef putc
#undef putchar
#undef puts
#undef remove
#undef rename
#undef rewind
#undef scanf
#undef setbuf
#undef setvbuf
#undef sprintf
#undef sscanf
#undef tmpfile
#undef tmpnam
#undef ungetc
#undef vfprintf
#undef vprintf
#undef vsprintf
namespace std
{
using ::FILE;
using ::fpos_t;
using ::clearerr;
using ::fclose;
using ::feof;
using ::ferror;
using ::fflush;
using ::fgetc;
using ::fgetpos;
using ::fgets;
using ::fopen;
using ::fprintf;
using ::fputc;
using ::fputs;
using ::fread;
using ::freopen;
using ::fscanf;
using ::fseek;
using ::fsetpos;
using ::ftell;
using ::fwrite;
using ::getc;
using ::getchar;
#if __cplusplus <= 201103L
// LWG 2249
using ::gets;
#endif
using ::perror;
using ::printf;
using ::putc;
using ::putchar;
using ::puts;
using ::remove;
using ::rename;
using ::rewind;
using ::scanf;
using ::setbuf;
using ::setvbuf;
using ::sprintf;
using ::sscanf;
using ::tmpfile;
#if _GLIBCXX_USE_TMPNAM
using ::tmpnam;
#endif
using ::ungetc;
using ::vfprintf;
using ::vprintf;
using ::vsprintf;
} // namespace
#if _GLIBCXX_USE_C99_STDIO
#undef snprintf
#undef vfscanf
#undef vscanf
#undef vsnprintf
#undef vsscanf
namespace __gnu_cxx
{
#if _GLIBCXX_USE_C99_CHECK || _GLIBCXX_USE_C99_DYNAMIC
extern "C" int
(snprintf)(char * __restrict, std::size_t, const char * __restrict, ...)
throw ();
extern "C" int
(vfscanf)(FILE * __restrict, const char * __restrict, __gnuc_va_list);
extern "C" int (vscanf)(const char * __restrict, __gnuc_va_list);
extern "C" int
(vsnprintf)(char * __restrict, std::size_t, const char * __restrict,
__gnuc_va_list) throw ();
extern "C" int
(vsscanf)(const char * __restrict, const char * __restrict, __gnuc_va_list)
throw ();
#endif
#if !_GLIBCXX_USE_C99_DYNAMIC
using ::snprintf;
using ::vfscanf;
using ::vscanf;
using ::vsnprintf;
using ::vsscanf;
#endif
} // namespace __gnu_cxx
namespace std
{
using ::__gnu_cxx::snprintf;
using ::__gnu_cxx::vfscanf;
using ::__gnu_cxx::vscanf;
using ::__gnu_cxx::vsnprintf;
using ::__gnu_cxx::vsscanf;
} // namespace std
#endif // _GLIBCXX_USE_C99_STDIO
#endif
c++/8/cstdbool 0000644 00000002571 15201526705 0007027 0 ustar 00 // <cstdbool> -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/cstdbool
* This is a Standard C++ Library header.
*/
#pragma GCC system_header
#ifndef _GLIBCXX_CSTDBOOL
#define _GLIBCXX_CSTDBOOL 1
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
# include <bits/c++config.h>
# if _GLIBCXX_HAVE_STDBOOL_H
# include <stdbool.h>
# endif
#endif
#endif
c++/8/cuchar 0000644 00000004242 15201526705 0006460 0 ustar 00 // -*- C++ -*- forwarding header.
// Copyright (C) 2015-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/cuchar
* This is a Standard C++ Library file. You should @c \#include this file
* in your programs, rather than any of the @a *.h implementation files.
*
* This is the C++ version of the Standard C Library header @c uchar.h,
* and its contents are (mostly) the same as that header, but are all
* contained in the namespace @c std (except for names which are defined
* as macros in C).
*/
//
// ISO C++ 14882:2011 21.8
//
#ifndef _GLIBCXX_CUCHAR
#define _GLIBCXX_CUCHAR 1
#pragma GCC system_header
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
#include <bits/c++config.h>
#include <cwchar>
#if _GLIBCXX_USE_C11_UCHAR_CXX11
#include <uchar.h>
// Get rid of those macros defined in <uchar.h> in lieu of real functions.
#undef mbrtoc16
#undef c16rtomb
#undef mbrtoc32
#undef c32rtomb
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using ::mbrtoc16;
using ::c16rtomb;
using ::mbrtoc32;
using ::c32rtomb;
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // _GLIBCXX_USE_C11_UCHAR_CXX11
#endif // C++11
#endif // _GLIBCXX_CUCHAR
c++/8/functional 0000644 00000111566 15201526705 0007365 0 ustar 00 // <functional> -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
* Copyright (c) 1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*/
/** @file include/functional
* This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_FUNCTIONAL
#define _GLIBCXX_FUNCTIONAL 1
#pragma GCC system_header
#include <bits/c++config.h>
#include <bits/stl_function.h>
#if __cplusplus >= 201103L
#include <new>
#include <tuple>
#include <type_traits>
#include <bits/functional_hash.h>
#include <bits/invoke.h>
#include <bits/refwrap.h> // std::reference_wrapper and _Mem_fn_traits
#include <bits/std_function.h> // std::function
#if __cplusplus > 201402L
# include <unordered_map>
# include <vector>
# include <array>
# include <utility>
# include <bits/stl_algo.h>
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __cplusplus > 201402L
# define __cpp_lib_invoke 201411
/// Invoke a callable object.
template<typename _Callable, typename... _Args>
inline invoke_result_t<_Callable, _Args...>
invoke(_Callable&& __fn, _Args&&... __args)
noexcept(is_nothrow_invocable_v<_Callable, _Args...>)
{
return std::__invoke(std::forward<_Callable>(__fn),
std::forward<_Args>(__args)...);
}
#endif
template<typename _MemFunPtr,
bool __is_mem_fn = is_member_function_pointer<_MemFunPtr>::value>
class _Mem_fn_base
: public _Mem_fn_traits<_MemFunPtr>::__maybe_type
{
using _Traits = _Mem_fn_traits<_MemFunPtr>;
using _Arity = typename _Traits::__arity;
using _Varargs = typename _Traits::__vararg;
template<typename _Func, typename... _BoundArgs>
friend struct _Bind_check_arity;
_MemFunPtr _M_pmf;
public:
using result_type = typename _Traits::__result_type;
explicit constexpr
_Mem_fn_base(_MemFunPtr __pmf) noexcept : _M_pmf(__pmf) { }
template<typename... _Args>
auto
operator()(_Args&&... __args) const
noexcept(noexcept(
std::__invoke(_M_pmf, std::forward<_Args>(__args)...)))
-> decltype(std::__invoke(_M_pmf, std::forward<_Args>(__args)...))
{ return std::__invoke(_M_pmf, std::forward<_Args>(__args)...); }
};
// Partial specialization for member object pointers.
template<typename _MemObjPtr>
class _Mem_fn_base<_MemObjPtr, false>
{
using _Arity = integral_constant<size_t, 0>;
using _Varargs = false_type;
template<typename _Func, typename... _BoundArgs>
friend struct _Bind_check_arity;
_MemObjPtr _M_pm;
public:
explicit constexpr
_Mem_fn_base(_MemObjPtr __pm) noexcept : _M_pm(__pm) { }
template<typename _Tp>
auto
operator()(_Tp&& __obj) const
noexcept(noexcept(std::__invoke(_M_pm, std::forward<_Tp>(__obj))))
-> decltype(std::__invoke(_M_pm, std::forward<_Tp>(__obj)))
{ return std::__invoke(_M_pm, std::forward<_Tp>(__obj)); }
};
template<typename _MemberPointer>
struct _Mem_fn; // undefined
template<typename _Res, typename _Class>
struct _Mem_fn<_Res _Class::*>
: _Mem_fn_base<_Res _Class::*>
{
using _Mem_fn_base<_Res _Class::*>::_Mem_fn_base;
};
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2048. Unnecessary mem_fn overloads
/**
* @brief Returns a function object that forwards to the member
* pointer @a pm.
* @ingroup functors
*/
template<typename _Tp, typename _Class>
inline _Mem_fn<_Tp _Class::*>
mem_fn(_Tp _Class::* __pm) noexcept
{
return _Mem_fn<_Tp _Class::*>(__pm);
}
/**
* @brief Determines if the given type _Tp is a function object that
* should be treated as a subexpression when evaluating calls to
* function objects returned by bind().
*
* C++11 [func.bind.isbind].
* @ingroup binders
*/
template<typename _Tp>
struct is_bind_expression
: public false_type { };
/**
* @brief Determines if the given type _Tp is a placeholder in a
* bind() expression and, if so, which placeholder it is.
*
* C++11 [func.bind.isplace].
* @ingroup binders
*/
template<typename _Tp>
struct is_placeholder
: public integral_constant<int, 0>
{ };
#if __cplusplus > 201402L
template <typename _Tp> inline constexpr bool is_bind_expression_v
= is_bind_expression<_Tp>::value;
template <typename _Tp> inline constexpr int is_placeholder_v
= is_placeholder<_Tp>::value;
#endif // C++17
/** @brief The type of placeholder objects defined by libstdc++.
* @ingroup binders
*/
template<int _Num> struct _Placeholder { };
/** @namespace std::placeholders
* @brief ISO C++11 entities sub-namespace for functional.
* @ingroup binders
*/
namespace placeholders
{
/* Define a large number of placeholders. There is no way to
* simplify this with variadic templates, because we're introducing
* unique names for each.
*/
extern const _Placeholder<1> _1;
extern const _Placeholder<2> _2;
extern const _Placeholder<3> _3;
extern const _Placeholder<4> _4;
extern const _Placeholder<5> _5;
extern const _Placeholder<6> _6;
extern const _Placeholder<7> _7;
extern const _Placeholder<8> _8;
extern const _Placeholder<9> _9;
extern const _Placeholder<10> _10;
extern const _Placeholder<11> _11;
extern const _Placeholder<12> _12;
extern const _Placeholder<13> _13;
extern const _Placeholder<14> _14;
extern const _Placeholder<15> _15;
extern const _Placeholder<16> _16;
extern const _Placeholder<17> _17;
extern const _Placeholder<18> _18;
extern const _Placeholder<19> _19;
extern const _Placeholder<20> _20;
extern const _Placeholder<21> _21;
extern const _Placeholder<22> _22;
extern const _Placeholder<23> _23;
extern const _Placeholder<24> _24;
extern const _Placeholder<25> _25;
extern const _Placeholder<26> _26;
extern const _Placeholder<27> _27;
extern const _Placeholder<28> _28;
extern const _Placeholder<29> _29;
}
/**
* Partial specialization of is_placeholder that provides the placeholder
* number for the placeholder objects defined by libstdc++.
* @ingroup binders
*/
template<int _Num>
struct is_placeholder<_Placeholder<_Num> >
: public integral_constant<int, _Num>
{ };
template<int _Num>
struct is_placeholder<const _Placeholder<_Num> >
: public integral_constant<int, _Num>
{ };
// Like tuple_element_t but SFINAE-friendly.
template<std::size_t __i, typename _Tuple>
using _Safe_tuple_element_t
= typename enable_if<(__i < tuple_size<_Tuple>::value),
tuple_element<__i, _Tuple>>::type::type;
/**
* Maps an argument to bind() into an actual argument to the bound
* function object [func.bind.bind]/10. Only the first parameter should
* be specified: the rest are used to determine among the various
* implementations. Note that, although this class is a function
* object, it isn't entirely normal because it takes only two
* parameters regardless of the number of parameters passed to the
* bind expression. The first parameter is the bound argument and
* the second parameter is a tuple containing references to the
* rest of the arguments.
*/
template<typename _Arg,
bool _IsBindExp = is_bind_expression<_Arg>::value,
bool _IsPlaceholder = (is_placeholder<_Arg>::value > 0)>
class _Mu;
/**
* If the argument is reference_wrapper<_Tp>, returns the
* underlying reference.
* C++11 [func.bind.bind] p10 bullet 1.
*/
template<typename _Tp>
class _Mu<reference_wrapper<_Tp>, false, false>
{
public:
/* Note: This won't actually work for const volatile
* reference_wrappers, because reference_wrapper::get() is const
* but not volatile-qualified. This might be a defect in the TR.
*/
template<typename _CVRef, typename _Tuple>
_Tp&
operator()(_CVRef& __arg, _Tuple&) const volatile
{ return __arg.get(); }
};
/**
* If the argument is a bind expression, we invoke the underlying
* function object with the same cv-qualifiers as we are given and
* pass along all of our arguments (unwrapped).
* C++11 [func.bind.bind] p10 bullet 2.
*/
template<typename _Arg>
class _Mu<_Arg, true, false>
{
public:
template<typename _CVArg, typename... _Args>
auto
operator()(_CVArg& __arg,
tuple<_Args...>& __tuple) const volatile
-> decltype(__arg(declval<_Args>()...))
{
// Construct an index tuple and forward to __call
typedef typename _Build_index_tuple<sizeof...(_Args)>::__type
_Indexes;
return this->__call(__arg, __tuple, _Indexes());
}
private:
// Invokes the underlying function object __arg by unpacking all
// of the arguments in the tuple.
template<typename _CVArg, typename... _Args, std::size_t... _Indexes>
auto
__call(_CVArg& __arg, tuple<_Args...>& __tuple,
const _Index_tuple<_Indexes...>&) const volatile
-> decltype(__arg(declval<_Args>()...))
{
return __arg(std::get<_Indexes>(std::move(__tuple))...);
}
};
/**
* If the argument is a placeholder for the Nth argument, returns
* a reference to the Nth argument to the bind function object.
* C++11 [func.bind.bind] p10 bullet 3.
*/
template<typename _Arg>
class _Mu<_Arg, false, true>
{
public:
template<typename _Tuple>
_Safe_tuple_element_t<(is_placeholder<_Arg>::value - 1), _Tuple>&&
operator()(const volatile _Arg&, _Tuple& __tuple) const volatile
{
return
::std::get<(is_placeholder<_Arg>::value - 1)>(std::move(__tuple));
}
};
/**
* If the argument is just a value, returns a reference to that
* value. The cv-qualifiers on the reference are determined by the caller.
* C++11 [func.bind.bind] p10 bullet 4.
*/
template<typename _Arg>
class _Mu<_Arg, false, false>
{
public:
template<typename _CVArg, typename _Tuple>
_CVArg&&
operator()(_CVArg&& __arg, _Tuple&) const volatile
{ return std::forward<_CVArg>(__arg); }
};
// std::get<I> for volatile-qualified tuples
template<std::size_t _Ind, typename... _Tp>
inline auto
__volget(volatile tuple<_Tp...>& __tuple)
-> __tuple_element_t<_Ind, tuple<_Tp...>> volatile&
{ return std::get<_Ind>(const_cast<tuple<_Tp...>&>(__tuple)); }
// std::get<I> for const-volatile-qualified tuples
template<std::size_t _Ind, typename... _Tp>
inline auto
__volget(const volatile tuple<_Tp...>& __tuple)
-> __tuple_element_t<_Ind, tuple<_Tp...>> const volatile&
{ return std::get<_Ind>(const_cast<const tuple<_Tp...>&>(__tuple)); }
/// Type of the function object returned from bind().
template<typename _Signature>
struct _Bind;
template<typename _Functor, typename... _Bound_args>
class _Bind<_Functor(_Bound_args...)>
: public _Weak_result_type<_Functor>
{
typedef typename _Build_index_tuple<sizeof...(_Bound_args)>::__type
_Bound_indexes;
_Functor _M_f;
tuple<_Bound_args...> _M_bound_args;
// Call unqualified
template<typename _Result, typename... _Args, std::size_t... _Indexes>
_Result
__call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>)
{
return std::__invoke(_M_f,
_Mu<_Bound_args>()(std::get<_Indexes>(_M_bound_args), __args)...
);
}
// Call as const
template<typename _Result, typename... _Args, std::size_t... _Indexes>
_Result
__call_c(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>) const
{
return std::__invoke(_M_f,
_Mu<_Bound_args>()(std::get<_Indexes>(_M_bound_args), __args)...
);
}
// Call as volatile
template<typename _Result, typename... _Args, std::size_t... _Indexes>
_Result
__call_v(tuple<_Args...>&& __args,
_Index_tuple<_Indexes...>) volatile
{
return std::__invoke(_M_f,
_Mu<_Bound_args>()(__volget<_Indexes>(_M_bound_args), __args)...
);
}
// Call as const volatile
template<typename _Result, typename... _Args, std::size_t... _Indexes>
_Result
__call_c_v(tuple<_Args...>&& __args,
_Index_tuple<_Indexes...>) const volatile
{
return std::__invoke(_M_f,
_Mu<_Bound_args>()(__volget<_Indexes>(_M_bound_args), __args)...
);
}
template<typename _BoundArg, typename _CallArgs>
using _Mu_type = decltype(
_Mu<typename remove_cv<_BoundArg>::type>()(
std::declval<_BoundArg&>(), std::declval<_CallArgs&>()) );
template<typename _Fn, typename _CallArgs, typename... _BArgs>
using _Res_type_impl
= typename result_of< _Fn&(_Mu_type<_BArgs, _CallArgs>&&...) >::type;
template<typename _CallArgs>
using _Res_type = _Res_type_impl<_Functor, _CallArgs, _Bound_args...>;
template<typename _CallArgs>
using __dependent = typename
enable_if<bool(tuple_size<_CallArgs>::value+1), _Functor>::type;
template<typename _CallArgs, template<class> class __cv_quals>
using _Res_type_cv = _Res_type_impl<
typename __cv_quals<__dependent<_CallArgs>>::type,
_CallArgs,
typename __cv_quals<_Bound_args>::type...>;
public:
template<typename... _Args>
explicit _Bind(const _Functor& __f, _Args&&... __args)
: _M_f(__f), _M_bound_args(std::forward<_Args>(__args)...)
{ }
template<typename... _Args>
explicit _Bind(_Functor&& __f, _Args&&... __args)
: _M_f(std::move(__f)), _M_bound_args(std::forward<_Args>(__args)...)
{ }
_Bind(const _Bind&) = default;
_Bind(_Bind&& __b)
: _M_f(std::move(__b._M_f)), _M_bound_args(std::move(__b._M_bound_args))
{ }
// Call unqualified
template<typename... _Args,
typename _Result = _Res_type<tuple<_Args...>>>
_Result
operator()(_Args&&... __args)
{
return this->__call<_Result>(
std::forward_as_tuple(std::forward<_Args>(__args)...),
_Bound_indexes());
}
// Call as const
template<typename... _Args,
typename _Result = _Res_type_cv<tuple<_Args...>, add_const>>
_Result
operator()(_Args&&... __args) const
{
return this->__call_c<_Result>(
std::forward_as_tuple(std::forward<_Args>(__args)...),
_Bound_indexes());
}
#if __cplusplus > 201402L
# define _GLIBCXX_DEPR_BIND \
[[deprecated("std::bind does not support volatile in C++17")]]
#else
# define _GLIBCXX_DEPR_BIND
#endif
// Call as volatile
template<typename... _Args,
typename _Result = _Res_type_cv<tuple<_Args...>, add_volatile>>
_GLIBCXX_DEPR_BIND
_Result
operator()(_Args&&... __args) volatile
{
return this->__call_v<_Result>(
std::forward_as_tuple(std::forward<_Args>(__args)...),
_Bound_indexes());
}
// Call as const volatile
template<typename... _Args,
typename _Result = _Res_type_cv<tuple<_Args...>, add_cv>>
_GLIBCXX_DEPR_BIND
_Result
operator()(_Args&&... __args) const volatile
{
return this->__call_c_v<_Result>(
std::forward_as_tuple(std::forward<_Args>(__args)...),
_Bound_indexes());
}
};
/// Type of the function object returned from bind<R>().
template<typename _Result, typename _Signature>
struct _Bind_result;
template<typename _Result, typename _Functor, typename... _Bound_args>
class _Bind_result<_Result, _Functor(_Bound_args...)>
{
typedef typename _Build_index_tuple<sizeof...(_Bound_args)>::__type
_Bound_indexes;
_Functor _M_f;
tuple<_Bound_args...> _M_bound_args;
// sfinae types
template<typename _Res>
using __enable_if_void
= typename enable_if<is_void<_Res>{}>::type;
template<typename _Res>
using __disable_if_void
= typename enable_if<!is_void<_Res>{}, _Result>::type;
// Call unqualified
template<typename _Res, typename... _Args, std::size_t... _Indexes>
__disable_if_void<_Res>
__call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>)
{
return std::__invoke(_M_f, _Mu<_Bound_args>()
(std::get<_Indexes>(_M_bound_args), __args)...);
}
// Call unqualified, return void
template<typename _Res, typename... _Args, std::size_t... _Indexes>
__enable_if_void<_Res>
__call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>)
{
std::__invoke(_M_f, _Mu<_Bound_args>()
(std::get<_Indexes>(_M_bound_args), __args)...);
}
// Call as const
template<typename _Res, typename... _Args, std::size_t... _Indexes>
__disable_if_void<_Res>
__call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>) const
{
return std::__invoke(_M_f, _Mu<_Bound_args>()
(std::get<_Indexes>(_M_bound_args), __args)...);
}
// Call as const, return void
template<typename _Res, typename... _Args, std::size_t... _Indexes>
__enable_if_void<_Res>
__call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>) const
{
std::__invoke(_M_f, _Mu<_Bound_args>()
(std::get<_Indexes>(_M_bound_args), __args)...);
}
// Call as volatile
template<typename _Res, typename... _Args, std::size_t... _Indexes>
__disable_if_void<_Res>
__call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>) volatile
{
return std::__invoke(_M_f, _Mu<_Bound_args>()
(__volget<_Indexes>(_M_bound_args), __args)...);
}
// Call as volatile, return void
template<typename _Res, typename... _Args, std::size_t... _Indexes>
__enable_if_void<_Res>
__call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>) volatile
{
std::__invoke(_M_f, _Mu<_Bound_args>()
(__volget<_Indexes>(_M_bound_args), __args)...);
}
// Call as const volatile
template<typename _Res, typename... _Args, std::size_t... _Indexes>
__disable_if_void<_Res>
__call(tuple<_Args...>&& __args,
_Index_tuple<_Indexes...>) const volatile
{
return std::__invoke(_M_f, _Mu<_Bound_args>()
(__volget<_Indexes>(_M_bound_args), __args)...);
}
// Call as const volatile, return void
template<typename _Res, typename... _Args, std::size_t... _Indexes>
__enable_if_void<_Res>
__call(tuple<_Args...>&& __args,
_Index_tuple<_Indexes...>) const volatile
{
std::__invoke(_M_f, _Mu<_Bound_args>()
(__volget<_Indexes>(_M_bound_args), __args)...);
}
public:
typedef _Result result_type;
template<typename... _Args>
explicit _Bind_result(const _Functor& __f, _Args&&... __args)
: _M_f(__f), _M_bound_args(std::forward<_Args>(__args)...)
{ }
template<typename... _Args>
explicit _Bind_result(_Functor&& __f, _Args&&... __args)
: _M_f(std::move(__f)), _M_bound_args(std::forward<_Args>(__args)...)
{ }
_Bind_result(const _Bind_result&) = default;
_Bind_result(_Bind_result&& __b)
: _M_f(std::move(__b._M_f)), _M_bound_args(std::move(__b._M_bound_args))
{ }
// Call unqualified
template<typename... _Args>
result_type
operator()(_Args&&... __args)
{
return this->__call<_Result>(
std::forward_as_tuple(std::forward<_Args>(__args)...),
_Bound_indexes());
}
// Call as const
template<typename... _Args>
result_type
operator()(_Args&&... __args) const
{
return this->__call<_Result>(
std::forward_as_tuple(std::forward<_Args>(__args)...),
_Bound_indexes());
}
// Call as volatile
template<typename... _Args>
_GLIBCXX_DEPR_BIND
result_type
operator()(_Args&&... __args) volatile
{
return this->__call<_Result>(
std::forward_as_tuple(std::forward<_Args>(__args)...),
_Bound_indexes());
}
// Call as const volatile
template<typename... _Args>
_GLIBCXX_DEPR_BIND
result_type
operator()(_Args&&... __args) const volatile
{
return this->__call<_Result>(
std::forward_as_tuple(std::forward<_Args>(__args)...),
_Bound_indexes());
}
};
#undef _GLIBCXX_DEPR_BIND
/**
* @brief Class template _Bind is always a bind expression.
* @ingroup binders
*/
template<typename _Signature>
struct is_bind_expression<_Bind<_Signature> >
: public true_type { };
/**
* @brief Class template _Bind is always a bind expression.
* @ingroup binders
*/
template<typename _Signature>
struct is_bind_expression<const _Bind<_Signature> >
: public true_type { };
/**
* @brief Class template _Bind is always a bind expression.
* @ingroup binders
*/
template<typename _Signature>
struct is_bind_expression<volatile _Bind<_Signature> >
: public true_type { };
/**
* @brief Class template _Bind is always a bind expression.
* @ingroup binders
*/
template<typename _Signature>
struct is_bind_expression<const volatile _Bind<_Signature>>
: public true_type { };
/**
* @brief Class template _Bind_result is always a bind expression.
* @ingroup binders
*/
template<typename _Result, typename _Signature>
struct is_bind_expression<_Bind_result<_Result, _Signature>>
: public true_type { };
/**
* @brief Class template _Bind_result is always a bind expression.
* @ingroup binders
*/
template<typename _Result, typename _Signature>
struct is_bind_expression<const _Bind_result<_Result, _Signature>>
: public true_type { };
/**
* @brief Class template _Bind_result is always a bind expression.
* @ingroup binders
*/
template<typename _Result, typename _Signature>
struct is_bind_expression<volatile _Bind_result<_Result, _Signature>>
: public true_type { };
/**
* @brief Class template _Bind_result is always a bind expression.
* @ingroup binders
*/
template<typename _Result, typename _Signature>
struct is_bind_expression<const volatile _Bind_result<_Result, _Signature>>
: public true_type { };
template<typename _Func, typename... _BoundArgs>
struct _Bind_check_arity { };
template<typename _Ret, typename... _Args, typename... _BoundArgs>
struct _Bind_check_arity<_Ret (*)(_Args...), _BoundArgs...>
{
static_assert(sizeof...(_BoundArgs) == sizeof...(_Args),
"Wrong number of arguments for function");
};
template<typename _Ret, typename... _Args, typename... _BoundArgs>
struct _Bind_check_arity<_Ret (*)(_Args......), _BoundArgs...>
{
static_assert(sizeof...(_BoundArgs) >= sizeof...(_Args),
"Wrong number of arguments for function");
};
template<typename _Tp, typename _Class, typename... _BoundArgs>
struct _Bind_check_arity<_Tp _Class::*, _BoundArgs...>
{
using _Arity = typename _Mem_fn<_Tp _Class::*>::_Arity;
using _Varargs = typename _Mem_fn<_Tp _Class::*>::_Varargs;
static_assert(_Varargs::value
? sizeof...(_BoundArgs) >= _Arity::value + 1
: sizeof...(_BoundArgs) == _Arity::value + 1,
"Wrong number of arguments for pointer-to-member");
};
// Trait type used to remove std::bind() from overload set via SFINAE
// when first argument has integer type, so that std::bind() will
// not be a better match than ::bind() from the BSD Sockets API.
template<typename _Tp, typename _Tp2 = typename decay<_Tp>::type>
using __is_socketlike = __or_<is_integral<_Tp2>, is_enum<_Tp2>>;
template<bool _SocketLike, typename _Func, typename... _BoundArgs>
struct _Bind_helper
: _Bind_check_arity<typename decay<_Func>::type, _BoundArgs...>
{
typedef typename decay<_Func>::type __func_type;
typedef _Bind<__func_type(typename decay<_BoundArgs>::type...)> type;
};
// Partial specialization for is_socketlike == true, does not define
// nested type so std::bind() will not participate in overload resolution
// when the first argument might be a socket file descriptor.
template<typename _Func, typename... _BoundArgs>
struct _Bind_helper<true, _Func, _BoundArgs...>
{ };
/**
* @brief Function template for std::bind.
* @ingroup binders
*/
template<typename _Func, typename... _BoundArgs>
inline typename
_Bind_helper<__is_socketlike<_Func>::value, _Func, _BoundArgs...>::type
bind(_Func&& __f, _BoundArgs&&... __args)
{
typedef _Bind_helper<false, _Func, _BoundArgs...> __helper_type;
return typename __helper_type::type(std::forward<_Func>(__f),
std::forward<_BoundArgs>(__args)...);
}
template<typename _Result, typename _Func, typename... _BoundArgs>
struct _Bindres_helper
: _Bind_check_arity<typename decay<_Func>::type, _BoundArgs...>
{
typedef typename decay<_Func>::type __functor_type;
typedef _Bind_result<_Result,
__functor_type(typename decay<_BoundArgs>::type...)>
type;
};
/**
* @brief Function template for std::bind<R>.
* @ingroup binders
*/
template<typename _Result, typename _Func, typename... _BoundArgs>
inline
typename _Bindres_helper<_Result, _Func, _BoundArgs...>::type
bind(_Func&& __f, _BoundArgs&&... __args)
{
typedef _Bindres_helper<_Result, _Func, _BoundArgs...> __helper_type;
return typename __helper_type::type(std::forward<_Func>(__f),
std::forward<_BoundArgs>(__args)...);
}
#if __cplusplus >= 201402L
/// Generalized negator.
template<typename _Fn>
class _Not_fn
{
template<typename _Fn2, typename... _Args>
using __inv_res_t = typename __invoke_result<_Fn2, _Args...>::type;
template<typename _Tp>
static decltype(!std::declval<_Tp>())
_S_not() noexcept(noexcept(!std::declval<_Tp>()));
public:
template<typename _Fn2>
_Not_fn(_Fn2&& __fn, int)
: _M_fn(std::forward<_Fn2>(__fn)) { }
_Not_fn(const _Not_fn& __fn) = default;
_Not_fn(_Not_fn&& __fn) = default;
~_Not_fn() = default;
// Macro to define operator() with given cv-qualifiers ref-qualifiers,
// forwarding _M_fn and the function arguments with the same qualifiers,
// and deducing the return type and exception-specification.
#define _GLIBCXX_NOT_FN_CALL_OP( _QUALS ) \
template<typename... _Args> \
decltype(_S_not<__inv_res_t<_Fn _QUALS, _Args...>>()) \
operator()(_Args&&... __args) _QUALS \
noexcept(__is_nothrow_invocable<_Fn _QUALS, _Args...>::value \
&& noexcept(_S_not<__inv_res_t<_Fn _QUALS, _Args...>>())) \
{ \
return !std::__invoke(std::forward< _Fn _QUALS >(_M_fn), \
std::forward<_Args>(__args)...); \
}
_GLIBCXX_NOT_FN_CALL_OP( & )
_GLIBCXX_NOT_FN_CALL_OP( const & )
_GLIBCXX_NOT_FN_CALL_OP( && )
_GLIBCXX_NOT_FN_CALL_OP( const && )
#undef _GLIBCXX_NOT_FN_CALL
private:
_Fn _M_fn;
};
template<typename _Tp, typename _Pred>
struct __is_byte_like : false_type { };
template<typename _Tp>
struct __is_byte_like<_Tp, equal_to<_Tp>>
: __bool_constant<sizeof(_Tp) == 1 && is_integral<_Tp>::value> { };
template<typename _Tp>
struct __is_byte_like<_Tp, equal_to<void>>
: __bool_constant<sizeof(_Tp) == 1 && is_integral<_Tp>::value> { };
#if __cplusplus >= 201703L
// Declare std::byte (full definition is in <cstddef>).
enum class byte : unsigned char;
template<>
struct __is_byte_like<byte, equal_to<byte>>
: true_type { };
template<>
struct __is_byte_like<byte, equal_to<void>>
: true_type { };
#define __cpp_lib_not_fn 201603
/// [func.not_fn] Function template not_fn
template<typename _Fn>
inline auto
not_fn(_Fn&& __fn)
noexcept(std::is_nothrow_constructible<std::decay_t<_Fn>, _Fn&&>::value)
{
return _Not_fn<std::decay_t<_Fn>>{std::forward<_Fn>(__fn), 0};
}
// Searchers
#define __cpp_lib_boyer_moore_searcher 201603
template<typename _ForwardIterator1, typename _BinaryPredicate = equal_to<>>
class default_searcher
{
public:
default_searcher(_ForwardIterator1 __pat_first,
_ForwardIterator1 __pat_last,
_BinaryPredicate __pred = _BinaryPredicate())
: _M_m(__pat_first, __pat_last, std::move(__pred))
{ }
template<typename _ForwardIterator2>
pair<_ForwardIterator2, _ForwardIterator2>
operator()(_ForwardIterator2 __first, _ForwardIterator2 __last) const
{
_ForwardIterator2 __first_ret =
std::search(__first, __last, std::get<0>(_M_m), std::get<1>(_M_m),
std::get<2>(_M_m));
auto __ret = std::make_pair(__first_ret, __first_ret);
if (__ret.first != __last)
std::advance(__ret.second, std::distance(std::get<0>(_M_m),
std::get<1>(_M_m)));
return __ret;
}
private:
tuple<_ForwardIterator1, _ForwardIterator1, _BinaryPredicate> _M_m;
};
template<typename _Key, typename _Tp, typename _Hash, typename _Pred>
struct __boyer_moore_map_base
{
template<typename _RAIter>
__boyer_moore_map_base(_RAIter __pat, size_t __patlen,
_Hash&& __hf, _Pred&& __pred)
: _M_bad_char{ __patlen, std::move(__hf), std::move(__pred) }
{
if (__patlen > 0)
for (__diff_type __i = 0; __i < __patlen - 1; ++__i)
_M_bad_char[__pat[__i]] = __patlen - 1 - __i;
}
using __diff_type = _Tp;
__diff_type
_M_lookup(_Key __key, __diff_type __not_found) const
{
auto __iter = _M_bad_char.find(__key);
if (__iter == _M_bad_char.end())
return __not_found;
return __iter->second;
}
_Pred
_M_pred() const { return _M_bad_char.key_eq(); }
_GLIBCXX_STD_C::unordered_map<_Key, _Tp, _Hash, _Pred> _M_bad_char;
};
template<typename _Tp, size_t _Len, typename _Pred>
struct __boyer_moore_array_base
{
template<typename _RAIter, typename _Unused>
__boyer_moore_array_base(_RAIter __pat, size_t __patlen,
_Unused&&, _Pred&& __pred)
: _M_bad_char{ _GLIBCXX_STD_C::array<_Tp, _Len>{}, std::move(__pred) }
{
std::get<0>(_M_bad_char).fill(__patlen);
if (__patlen > 0)
for (__diff_type __i = 0; __i < __patlen - 1; ++__i)
{
auto __ch = __pat[__i];
using _UCh = make_unsigned_t<decltype(__ch)>;
auto __uch = static_cast<_UCh>(__ch);
std::get<0>(_M_bad_char)[__uch] = __patlen - 1 - __i;
}
}
using __diff_type = _Tp;
template<typename _Key>
__diff_type
_M_lookup(_Key __key, __diff_type __not_found) const
{
auto __ukey = static_cast<make_unsigned_t<_Key>>(__key);
if (__ukey >= _Len)
return __not_found;
return std::get<0>(_M_bad_char)[__ukey];
}
const _Pred&
_M_pred() const { return std::get<1>(_M_bad_char); }
tuple<_GLIBCXX_STD_C::array<_Tp, _Len>, _Pred> _M_bad_char;
};
// Use __boyer_moore_array_base when pattern consists of narrow characters
// (or std::byte) and uses std::equal_to as the predicate.
template<typename _RAIter, typename _Hash, typename _Pred,
typename _Val = typename iterator_traits<_RAIter>::value_type,
typename _Diff = typename iterator_traits<_RAIter>::difference_type>
using __boyer_moore_base_t
= conditional_t<__is_byte_like<_Val, _Pred>::value,
__boyer_moore_array_base<_Diff, 256, _Pred>,
__boyer_moore_map_base<_Val, _Diff, _Hash, _Pred>>;
template<typename _RAIter, typename _Hash
= hash<typename iterator_traits<_RAIter>::value_type>,
typename _BinaryPredicate = equal_to<>>
class boyer_moore_searcher
: __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate>
{
using _Base = __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate>;
using typename _Base::__diff_type;
public:
boyer_moore_searcher(_RAIter __pat_first, _RAIter __pat_last,
_Hash __hf = _Hash(),
_BinaryPredicate __pred = _BinaryPredicate());
template<typename _RandomAccessIterator2>
pair<_RandomAccessIterator2, _RandomAccessIterator2>
operator()(_RandomAccessIterator2 __first,
_RandomAccessIterator2 __last) const;
private:
bool
_M_is_prefix(_RAIter __word, __diff_type __len,
__diff_type __pos)
{
const auto& __pred = this->_M_pred();
__diff_type __suffixlen = __len - __pos;
for (__diff_type __i = 0; __i < __suffixlen; ++__i)
if (!__pred(__word[__i], __word[__pos + __i]))
return false;
return true;
}
__diff_type
_M_suffix_length(_RAIter __word, __diff_type __len,
__diff_type __pos)
{
const auto& __pred = this->_M_pred();
__diff_type __i = 0;
while (__pred(__word[__pos - __i], __word[__len - 1 - __i])
&& __i < __pos)
{
++__i;
}
return __i;
}
template<typename _Tp>
__diff_type
_M_bad_char_shift(_Tp __c) const
{ return this->_M_lookup(__c, _M_pat_end - _M_pat); }
_RAIter _M_pat;
_RAIter _M_pat_end;
_GLIBCXX_STD_C::vector<__diff_type> _M_good_suffix;
};
template<typename _RAIter, typename _Hash
= hash<typename iterator_traits<_RAIter>::value_type>,
typename _BinaryPredicate = equal_to<>>
class boyer_moore_horspool_searcher
: __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate>
{
using _Base = __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate>;
using typename _Base::__diff_type;
public:
boyer_moore_horspool_searcher(_RAIter __pat,
_RAIter __pat_end,
_Hash __hf = _Hash(),
_BinaryPredicate __pred
= _BinaryPredicate())
: _Base(__pat, __pat_end - __pat, std::move(__hf), std::move(__pred)),
_M_pat(__pat), _M_pat_end(__pat_end)
{ }
template<typename _RandomAccessIterator2>
pair<_RandomAccessIterator2, _RandomAccessIterator2>
operator()(_RandomAccessIterator2 __first,
_RandomAccessIterator2 __last) const
{
const auto& __pred = this->_M_pred();
auto __patlen = _M_pat_end - _M_pat;
if (__patlen == 0)
return std::make_pair(__first, __first);
auto __len = __last - __first;
while (__len >= __patlen)
{
for (auto __scan = __patlen - 1;
__pred(__first[__scan], _M_pat[__scan]); --__scan)
if (__scan == 0)
return std::make_pair(__first, __first + __patlen);
auto __shift = _M_bad_char_shift(__first[__patlen - 1]);
__len -= __shift;
__first += __shift;
}
return std::make_pair(__last, __last);
}
private:
template<typename _Tp>
__diff_type
_M_bad_char_shift(_Tp __c) const
{ return this->_M_lookup(__c, _M_pat_end - _M_pat); }
_RAIter _M_pat;
_RAIter _M_pat_end;
};
template<typename _RAIter, typename _Hash, typename _BinaryPredicate>
boyer_moore_searcher<_RAIter, _Hash, _BinaryPredicate>::
boyer_moore_searcher(_RAIter __pat, _RAIter __pat_end,
_Hash __hf, _BinaryPredicate __pred)
: _Base(__pat, __pat_end - __pat, std::move(__hf), std::move(__pred)),
_M_pat(__pat), _M_pat_end(__pat_end), _M_good_suffix(__pat_end - __pat)
{
auto __patlen = __pat_end - __pat;
if (__patlen == 0)
return;
__diff_type __last_prefix = __patlen - 1;
for (__diff_type __p = __patlen - 1; __p >= 0; --__p)
{
if (_M_is_prefix(__pat, __patlen, __p + 1))
__last_prefix = __p + 1;
_M_good_suffix[__p] = __last_prefix + (__patlen - 1 - __p);
}
for (__diff_type __p = 0; __p < __patlen - 1; ++__p)
{
auto __slen = _M_suffix_length(__pat, __patlen, __p);
auto __pos = __patlen - 1 - __slen;
if (!__pred(__pat[__p - __slen], __pat[__pos]))
_M_good_suffix[__pos] = __patlen - 1 - __p + __slen;
}
}
template<typename _RAIter, typename _Hash, typename _BinaryPredicate>
template<typename _RandomAccessIterator2>
pair<_RandomAccessIterator2, _RandomAccessIterator2>
boyer_moore_searcher<_RAIter, _Hash, _BinaryPredicate>::
operator()(_RandomAccessIterator2 __first,
_RandomAccessIterator2 __last) const
{
auto __patlen = _M_pat_end - _M_pat;
if (__patlen == 0)
return std::make_pair(__first, __first);
const auto& __pred = this->_M_pred();
__diff_type __i = __patlen - 1;
auto __stringlen = __last - __first;
while (__i < __stringlen)
{
__diff_type __j = __patlen - 1;
while (__j >= 0 && __pred(__first[__i], _M_pat[__j]))
{
--__i;
--__j;
}
if (__j < 0)
{
const auto __match = __first + __i + 1;
return std::make_pair(__match, __match + __patlen);
}
__i += std::max(_M_bad_char_shift(__first[__i]),
_M_good_suffix[__j]);
}
return std::make_pair(__last, __last);
}
#endif // C++17
#endif // C++14
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // C++11
#endif // _GLIBCXX_FUNCTIONAL
c++/8/iomanip 0000644 00000040243 15201526705 0006650 0 ustar 00 // Standard stream manipulators -*- C++ -*-
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/iomanip
* This is a Standard C++ Library header.
*/
//
// ISO C++ 14882: 27.6.3 Standard manipulators
//
#ifndef _GLIBCXX_IOMANIP
#define _GLIBCXX_IOMANIP 1
#pragma GCC system_header
#include <bits/c++config.h>
#include <iosfwd>
#include <bits/ios_base.h>
#if __cplusplus >= 201103L
#include <locale>
#if __cplusplus > 201103L
#include <bits/quoted_string.h>
#endif
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// [27.6.3] standard manipulators
// Also see DR 183.
struct _Resetiosflags { ios_base::fmtflags _M_mask; };
/**
* @brief Manipulator for @c setf.
* @param __mask A format flags mask.
*
* Sent to a stream object, this manipulator resets the specified flags,
* via @e stream.setf(0,__mask).
*/
inline _Resetiosflags
resetiosflags(ios_base::fmtflags __mask)
{ return { __mask }; }
template<typename _CharT, typename _Traits>
inline basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, _Resetiosflags __f)
{
__is.setf(ios_base::fmtflags(0), __f._M_mask);
return __is;
}
template<typename _CharT, typename _Traits>
inline basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, _Resetiosflags __f)
{
__os.setf(ios_base::fmtflags(0), __f._M_mask);
return __os;
}
struct _Setiosflags { ios_base::fmtflags _M_mask; };
/**
* @brief Manipulator for @c setf.
* @param __mask A format flags mask.
*
* Sent to a stream object, this manipulator sets the format flags
* to @a __mask.
*/
inline _Setiosflags
setiosflags(ios_base::fmtflags __mask)
{ return { __mask }; }
template<typename _CharT, typename _Traits>
inline basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, _Setiosflags __f)
{
__is.setf(__f._M_mask);
return __is;
}
template<typename _CharT, typename _Traits>
inline basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, _Setiosflags __f)
{
__os.setf(__f._M_mask);
return __os;
}
struct _Setbase { int _M_base; };
/**
* @brief Manipulator for @c setf.
* @param __base A numeric base.
*
* Sent to a stream object, this manipulator changes the
* @c ios_base::basefield flags to @c oct, @c dec, or @c hex when @a base
* is 8, 10, or 16, accordingly, and to 0 if @a __base is any other value.
*/
inline _Setbase
setbase(int __base)
{ return { __base }; }
template<typename _CharT, typename _Traits>
inline basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, _Setbase __f)
{
__is.setf(__f._M_base == 8 ? ios_base::oct :
__f._M_base == 10 ? ios_base::dec :
__f._M_base == 16 ? ios_base::hex :
ios_base::fmtflags(0), ios_base::basefield);
return __is;
}
template<typename _CharT, typename _Traits>
inline basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, _Setbase __f)
{
__os.setf(__f._M_base == 8 ? ios_base::oct :
__f._M_base == 10 ? ios_base::dec :
__f._M_base == 16 ? ios_base::hex :
ios_base::fmtflags(0), ios_base::basefield);
return __os;
}
template<typename _CharT>
struct _Setfill { _CharT _M_c; };
/**
* @brief Manipulator for @c fill.
* @param __c The new fill character.
*
* Sent to a stream object, this manipulator calls @c fill(__c) for that
* object.
*/
template<typename _CharT>
inline _Setfill<_CharT>
setfill(_CharT __c)
{ return { __c }; }
template<typename _CharT, typename _Traits>
inline basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, _Setfill<_CharT> __f)
{
__is.fill(__f._M_c);
return __is;
}
template<typename _CharT, typename _Traits>
inline basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, _Setfill<_CharT> __f)
{
__os.fill(__f._M_c);
return __os;
}
struct _Setprecision { int _M_n; };
/**
* @brief Manipulator for @c precision.
* @param __n The new precision.
*
* Sent to a stream object, this manipulator calls @c precision(__n) for
* that object.
*/
inline _Setprecision
setprecision(int __n)
{ return { __n }; }
template<typename _CharT, typename _Traits>
inline basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, _Setprecision __f)
{
__is.precision(__f._M_n);
return __is;
}
template<typename _CharT, typename _Traits>
inline basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, _Setprecision __f)
{
__os.precision(__f._M_n);
return __os;
}
struct _Setw { int _M_n; };
/**
* @brief Manipulator for @c width.
* @param __n The new width.
*
* Sent to a stream object, this manipulator calls @c width(__n) for
* that object.
*/
inline _Setw
setw(int __n)
{ return { __n }; }
template<typename _CharT, typename _Traits>
inline basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, _Setw __f)
{
__is.width(__f._M_n);
return __is;
}
template<typename _CharT, typename _Traits>
inline basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, _Setw __f)
{
__os.width(__f._M_n);
return __os;
}
#if __cplusplus >= 201103L
template<typename _MoneyT>
struct _Get_money { _MoneyT& _M_mon; bool _M_intl; };
/**
* @brief Extended manipulator for extracting money.
* @param __mon Either long double or a specialization of @c basic_string.
* @param __intl A bool indicating whether international format
* is to be used.
*
* Sent to a stream object, this manipulator extracts @a __mon.
*/
template<typename _MoneyT>
inline _Get_money<_MoneyT>
get_money(_MoneyT& __mon, bool __intl = false)
{ return { __mon, __intl }; }
template<typename _CharT, typename _Traits, typename _MoneyT>
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, _Get_money<_MoneyT> __f)
{
typename basic_istream<_CharT, _Traits>::sentry __cerb(__is, false);
if (__cerb)
{
ios_base::iostate __err = ios_base::goodbit;
__try
{
typedef istreambuf_iterator<_CharT, _Traits> _Iter;
typedef money_get<_CharT, _Iter> _MoneyGet;
const _MoneyGet& __mg = use_facet<_MoneyGet>(__is.getloc());
__mg.get(_Iter(__is.rdbuf()), _Iter(), __f._M_intl,
__is, __err, __f._M_mon);
}
__catch(__cxxabiv1::__forced_unwind&)
{
__is._M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ __is._M_setstate(ios_base::badbit); }
if (__err)
__is.setstate(__err);
}
return __is;
}
template<typename _MoneyT>
struct _Put_money { const _MoneyT& _M_mon; bool _M_intl; };
/**
* @brief Extended manipulator for inserting money.
* @param __mon Either long double or a specialization of @c basic_string.
* @param __intl A bool indicating whether international format
* is to be used.
*
* Sent to a stream object, this manipulator inserts @a __mon.
*/
template<typename _MoneyT>
inline _Put_money<_MoneyT>
put_money(const _MoneyT& __mon, bool __intl = false)
{ return { __mon, __intl }; }
template<typename _CharT, typename _Traits, typename _MoneyT>
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, _Put_money<_MoneyT> __f)
{
typename basic_ostream<_CharT, _Traits>::sentry __cerb(__os);
if (__cerb)
{
ios_base::iostate __err = ios_base::goodbit;
__try
{
typedef ostreambuf_iterator<_CharT, _Traits> _Iter;
typedef money_put<_CharT, _Iter> _MoneyPut;
const _MoneyPut& __mp = use_facet<_MoneyPut>(__os.getloc());
if (__mp.put(_Iter(__os.rdbuf()), __f._M_intl, __os,
__os.fill(), __f._M_mon).failed())
__err |= ios_base::badbit;
}
__catch(__cxxabiv1::__forced_unwind&)
{
__os._M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ __os._M_setstate(ios_base::badbit); }
if (__err)
__os.setstate(__err);
}
return __os;
}
template<typename _CharT>
struct _Put_time
{
const std::tm* _M_tmb;
const _CharT* _M_fmt;
};
/**
* @brief Extended manipulator for formatting time.
*
* This manipulator uses time_put::put to format time.
* [ext.manip]
*
* @param __tmb struct tm time data to format.
* @param __fmt format string.
*/
template<typename _CharT>
inline _Put_time<_CharT>
put_time(const std::tm* __tmb, const _CharT* __fmt)
{ return { __tmb, __fmt }; }
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, _Put_time<_CharT> __f)
{
typename basic_ostream<_CharT, _Traits>::sentry __cerb(__os);
if (__cerb)
{
ios_base::iostate __err = ios_base::goodbit;
__try
{
typedef ostreambuf_iterator<_CharT, _Traits> _Iter;
typedef time_put<_CharT, _Iter> _TimePut;
const _CharT* const __fmt_end = __f._M_fmt +
_Traits::length(__f._M_fmt);
const _TimePut& __mp = use_facet<_TimePut>(__os.getloc());
if (__mp.put(_Iter(__os.rdbuf()), __os, __os.fill(),
__f._M_tmb, __f._M_fmt, __fmt_end).failed())
__err |= ios_base::badbit;
}
__catch(__cxxabiv1::__forced_unwind&)
{
__os._M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ __os._M_setstate(ios_base::badbit); }
if (__err)
__os.setstate(__err);
}
return __os;
}
template<typename _CharT>
struct _Get_time
{
std::tm* _M_tmb;
const _CharT* _M_fmt;
};
/**
* @brief Extended manipulator for extracting time.
*
* This manipulator uses time_get::get to extract time.
* [ext.manip]
*
* @param __tmb struct to extract the time data to.
* @param __fmt format string.
*/
template<typename _CharT>
inline _Get_time<_CharT>
get_time(std::tm* __tmb, const _CharT* __fmt)
{ return { __tmb, __fmt }; }
template<typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, _Get_time<_CharT> __f)
{
typename basic_istream<_CharT, _Traits>::sentry __cerb(__is, false);
if (__cerb)
{
ios_base::iostate __err = ios_base::goodbit;
__try
{
typedef istreambuf_iterator<_CharT, _Traits> _Iter;
typedef time_get<_CharT, _Iter> _TimeGet;
const _CharT* const __fmt_end = __f._M_fmt +
_Traits::length(__f._M_fmt);
const _TimeGet& __mg = use_facet<_TimeGet>(__is.getloc());
__mg.get(_Iter(__is.rdbuf()), _Iter(), __is,
__err, __f._M_tmb, __f._M_fmt, __fmt_end);
}
__catch(__cxxabiv1::__forced_unwind&)
{
__is._M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ __is._M_setstate(ios_base::badbit); }
if (__err)
__is.setstate(__err);
}
return __is;
}
#if __cplusplus >= 201402L
#define __cpp_lib_quoted_string_io 201304
/**
* @brief Manipulator for quoted strings.
* @param __string String to quote.
* @param __delim Character to quote string with.
* @param __escape Escape character to escape itself or quote character.
*/
template<typename _CharT>
inline auto
quoted(const _CharT* __string,
_CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\'))
{
return __detail::_Quoted_string<const _CharT*, _CharT>(__string, __delim,
__escape);
}
template<typename _CharT, typename _Traits, typename _Alloc>
inline auto
quoted(const basic_string<_CharT, _Traits, _Alloc>& __string,
_CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\'))
{
return __detail::_Quoted_string<
const basic_string<_CharT, _Traits, _Alloc>&, _CharT>(
__string, __delim, __escape);
}
template<typename _CharT, typename _Traits, typename _Alloc>
inline auto
quoted(basic_string<_CharT, _Traits, _Alloc>& __string,
_CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\'))
{
return __detail::_Quoted_string<
basic_string<_CharT, _Traits, _Alloc>&, _CharT>(
__string, __delim, __escape);
}
#if __cplusplus >= 201703L
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2785. quoted should work with basic_string_view
template<typename _CharT, typename _Traits>
inline auto
quoted(basic_string_view<_CharT, _Traits> __sv,
_CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\'))
{
return __detail::_Quoted_string<
basic_string_view<_CharT, _Traits>, _CharT>(__sv, __delim, __escape);
}
#endif // C++17
#endif // C++14
#endif // __cplusplus >= 201103L
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
// NB: This syntax is a GNU extension.
#if _GLIBCXX_EXTERN_TEMPLATE
extern template ostream& operator<<(ostream&, _Setfill<char>);
extern template ostream& operator<<(ostream&, _Setiosflags);
extern template ostream& operator<<(ostream&, _Resetiosflags);
extern template ostream& operator<<(ostream&, _Setbase);
extern template ostream& operator<<(ostream&, _Setprecision);
extern template ostream& operator<<(ostream&, _Setw);
extern template istream& operator>>(istream&, _Setfill<char>);
extern template istream& operator>>(istream&, _Setiosflags);
extern template istream& operator>>(istream&, _Resetiosflags);
extern template istream& operator>>(istream&, _Setbase);
extern template istream& operator>>(istream&, _Setprecision);
extern template istream& operator>>(istream&, _Setw);
#ifdef _GLIBCXX_USE_WCHAR_T
extern template wostream& operator<<(wostream&, _Setfill<wchar_t>);
extern template wostream& operator<<(wostream&, _Setiosflags);
extern template wostream& operator<<(wostream&, _Resetiosflags);
extern template wostream& operator<<(wostream&, _Setbase);
extern template wostream& operator<<(wostream&, _Setprecision);
extern template wostream& operator<<(wostream&, _Setw);
extern template wistream& operator>>(wistream&, _Setfill<wchar_t>);
extern template wistream& operator>>(wistream&, _Setiosflags);
extern template wistream& operator>>(wistream&, _Resetiosflags);
extern template wistream& operator>>(wistream&, _Setbase);
extern template wistream& operator>>(wistream&, _Setprecision);
extern template wistream& operator>>(wistream&, _Setw);
#endif
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif /* _GLIBCXX_IOMANIP */
c++/8/any 0000644 00000044254 15201526705 0006011 0 ustar 00 // <any> -*- C++ -*-
// Copyright (C) 2014-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/any
* This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_ANY
#define _GLIBCXX_ANY 1
#pragma GCC system_header
#if __cplusplus >= 201703L
#include <typeinfo>
#include <new>
#include <utility>
#include <type_traits>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @addtogroup utilities
* @{
*/
/**
* @brief Exception class thrown by a failed @c any_cast
* @ingroup exceptions
*/
class bad_any_cast : public bad_cast
{
public:
virtual const char* what() const noexcept { return "bad any_cast"; }
};
[[gnu::noreturn]] inline void __throw_bad_any_cast()
{
#if __cpp_exceptions
throw bad_any_cast{};
#else
__builtin_abort();
#endif
}
#define __cpp_lib_any 201606L
/**
* @brief A type-safe container of any type.
*
* An @c any object's state is either empty or it stores a contained object
* of CopyConstructible type.
*/
class any
{
// Holds either pointer to a heap object or the contained object itself.
union _Storage
{
constexpr _Storage() : _M_ptr{nullptr} {}
// Prevent trivial copies of this type, buffer might hold a non-POD.
_Storage(const _Storage&) = delete;
_Storage& operator=(const _Storage&) = delete;
void* _M_ptr;
aligned_storage<sizeof(_M_ptr), alignof(void*)>::type _M_buffer;
};
template<typename _Tp, typename _Safe = is_nothrow_move_constructible<_Tp>,
bool _Fits = (sizeof(_Tp) <= sizeof(_Storage))
&& (alignof(_Tp) <= alignof(_Storage))>
using _Internal = std::integral_constant<bool, _Safe::value && _Fits>;
template<typename _Tp>
struct _Manager_internal; // uses small-object optimization
template<typename _Tp>
struct _Manager_external; // creates contained object on the heap
template<typename _Tp>
using _Manager = conditional_t<_Internal<_Tp>::value,
_Manager_internal<_Tp>,
_Manager_external<_Tp>>;
template<typename _Tp, typename _Decayed = decay_t<_Tp>>
using _Decay = enable_if_t<!is_same<_Decayed, any>::value, _Decayed>;
/// Emplace with an object created from @p __args as the contained object.
template <typename _Tp, typename... _Args,
typename _Mgr = _Manager<_Tp>>
void __do_emplace(_Args&&... __args)
{
reset();
_Mgr::_S_create(_M_storage, std::forward<_Args>(__args)...);
_M_manager = &_Mgr::_S_manage;
}
/// Emplace with an object created from @p __il and @p __args as
/// the contained object.
template <typename _Tp, typename _Up, typename... _Args,
typename _Mgr = _Manager<_Tp>>
void __do_emplace(initializer_list<_Up> __il, _Args&&... __args)
{
reset();
_Mgr::_S_create(_M_storage, __il, std::forward<_Args>(__args)...);
_M_manager = &_Mgr::_S_manage;
}
public:
// construct/destruct
/// Default constructor, creates an empty object.
constexpr any() noexcept : _M_manager(nullptr) { }
/// Copy constructor, copies the state of @p __other
any(const any& __other)
{
if (!__other.has_value())
_M_manager = nullptr;
else
{
_Arg __arg;
__arg._M_any = this;
__other._M_manager(_Op_clone, &__other, &__arg);
}
}
/**
* @brief Move constructor, transfer the state from @p __other
*
* @post @c !__other.has_value() (this postcondition is a GNU extension)
*/
any(any&& __other) noexcept
{
if (!__other.has_value())
_M_manager = nullptr;
else
{
_Arg __arg;
__arg._M_any = this;
__other._M_manager(_Op_xfer, &__other, &__arg);
}
}
template <typename _Res, typename _Tp, typename... _Args>
using __any_constructible =
enable_if<__and_<is_copy_constructible<_Tp>,
is_constructible<_Tp, _Args...>>::value,
_Res>;
template <typename _Tp, typename... _Args>
using __any_constructible_t =
typename __any_constructible<bool, _Tp, _Args...>::type;
/// Construct with a copy of @p __value as the contained object.
template <typename _ValueType, typename _Tp = _Decay<_ValueType>,
typename _Mgr = _Manager<_Tp>,
__any_constructible_t<_Tp, _ValueType&&> = true,
enable_if_t<!__is_in_place_type<_Tp>::value, bool> = true>
any(_ValueType&& __value)
: _M_manager(&_Mgr::_S_manage)
{
_Mgr::_S_create(_M_storage, std::forward<_ValueType>(__value));
}
/// Construct with a copy of @p __value as the contained object.
template <typename _ValueType, typename _Tp = _Decay<_ValueType>,
typename _Mgr = _Manager<_Tp>,
enable_if_t<__and_<is_copy_constructible<_Tp>,
__not_<is_constructible<_Tp, _ValueType&&>>,
__not_<__is_in_place_type<_Tp>>>::value,
bool> = false>
any(_ValueType&& __value)
: _M_manager(&_Mgr::_S_manage)
{
_Mgr::_S_create(_M_storage, __value);
}
/// Construct with an object created from @p __args as the contained object.
template <typename _ValueType, typename... _Args,
typename _Tp = _Decay<_ValueType>,
typename _Mgr = _Manager<_Tp>,
__any_constructible_t<_Tp, _Args&&...> = false>
explicit
any(in_place_type_t<_ValueType>, _Args&&... __args)
: _M_manager(&_Mgr::_S_manage)
{
_Mgr::_S_create(_M_storage, std::forward<_Args>(__args)...);
}
/// Construct with an object created from @p __il and @p __args as
/// the contained object.
template <typename _ValueType, typename _Up, typename... _Args,
typename _Tp = _Decay<_ValueType>,
typename _Mgr = _Manager<_Tp>,
__any_constructible_t<_Tp, initializer_list<_Up>,
_Args&&...> = false>
explicit
any(in_place_type_t<_ValueType>,
initializer_list<_Up> __il, _Args&&... __args)
: _M_manager(&_Mgr::_S_manage)
{
_Mgr::_S_create(_M_storage, __il, std::forward<_Args>(__args)...);
}
/// Destructor, calls @c reset()
~any() { reset(); }
// assignments
/// Copy the state of another object.
any& operator=(const any& __rhs)
{
*this = any(__rhs);
return *this;
}
/**
* @brief Move assignment operator
*
* @post @c !__rhs.has_value() (not guaranteed for other implementations)
*/
any& operator=(any&& __rhs) noexcept
{
if (!__rhs.has_value())
reset();
else if (this != &__rhs)
{
reset();
_Arg __arg;
__arg._M_any = this;
__rhs._M_manager(_Op_xfer, &__rhs, &__arg);
}
return *this;
}
/// Store a copy of @p __rhs as the contained object.
template<typename _ValueType>
enable_if_t<is_copy_constructible<_Decay<_ValueType>>::value, any&>
operator=(_ValueType&& __rhs)
{
*this = any(std::forward<_ValueType>(__rhs));
return *this;
}
/// Emplace with an object created from @p __args as the contained object.
template <typename _ValueType, typename... _Args>
typename __any_constructible<_Decay<_ValueType>&,
_Decay<_ValueType>, _Args&&...>::type
emplace(_Args&&... __args)
{
__do_emplace<_Decay<_ValueType>>(std::forward<_Args>(__args)...);
any::_Arg __arg;
this->_M_manager(any::_Op_access, this, &__arg);
return *static_cast<_Decay<_ValueType>*>(__arg._M_obj);
}
/// Emplace with an object created from @p __il and @p __args as
/// the contained object.
template <typename _ValueType, typename _Up, typename... _Args>
typename __any_constructible<_Decay<_ValueType>&,
_Decay<_ValueType>,
initializer_list<_Up>,
_Args&&...>::type
emplace(initializer_list<_Up> __il, _Args&&... __args)
{
__do_emplace<_Decay<_ValueType>, _Up>(__il,
std::forward<_Args>(__args)...);
any::_Arg __arg;
this->_M_manager(any::_Op_access, this, &__arg);
return *static_cast<_Decay<_ValueType>*>(__arg._M_obj);
}
// modifiers
/// If not empty, destroy the contained object.
void reset() noexcept
{
if (has_value())
{
_M_manager(_Op_destroy, this, nullptr);
_M_manager = nullptr;
}
}
/// Exchange state with another object.
void swap(any& __rhs) noexcept
{
if (!has_value() && !__rhs.has_value())
return;
if (has_value() && __rhs.has_value())
{
if (this == &__rhs)
return;
any __tmp;
_Arg __arg;
__arg._M_any = &__tmp;
__rhs._M_manager(_Op_xfer, &__rhs, &__arg);
__arg._M_any = &__rhs;
_M_manager(_Op_xfer, this, &__arg);
__arg._M_any = this;
__tmp._M_manager(_Op_xfer, &__tmp, &__arg);
}
else
{
any* __empty = !has_value() ? this : &__rhs;
any* __full = !has_value() ? &__rhs : this;
_Arg __arg;
__arg._M_any = __empty;
__full->_M_manager(_Op_xfer, __full, &__arg);
}
}
// observers
/// Reports whether there is a contained object or not.
bool has_value() const noexcept { return _M_manager != nullptr; }
#if __cpp_rtti
/// The @c typeid of the contained object, or @c typeid(void) if empty.
const type_info& type() const noexcept
{
if (!has_value())
return typeid(void);
_Arg __arg;
_M_manager(_Op_get_type_info, this, &__arg);
return *__arg._M_typeinfo;
}
#endif
template<typename _Tp>
static constexpr bool __is_valid_cast()
{ return __or_<is_reference<_Tp>, is_copy_constructible<_Tp>>::value; }
private:
enum _Op {
_Op_access, _Op_get_type_info, _Op_clone, _Op_destroy, _Op_xfer
};
union _Arg
{
void* _M_obj;
const std::type_info* _M_typeinfo;
any* _M_any;
};
void (*_M_manager)(_Op, const any*, _Arg*);
_Storage _M_storage;
template<typename _Tp>
friend void* __any_caster(const any* __any);
// Manage in-place contained object.
template<typename _Tp>
struct _Manager_internal
{
static void
_S_manage(_Op __which, const any* __anyp, _Arg* __arg);
template<typename _Up>
static void
_S_create(_Storage& __storage, _Up&& __value)
{
void* __addr = &__storage._M_buffer;
::new (__addr) _Tp(std::forward<_Up>(__value));
}
template<typename... _Args>
static void
_S_create(_Storage& __storage, _Args&&... __args)
{
void* __addr = &__storage._M_buffer;
::new (__addr) _Tp(std::forward<_Args>(__args)...);
}
};
// Manage external contained object.
template<typename _Tp>
struct _Manager_external
{
static void
_S_manage(_Op __which, const any* __anyp, _Arg* __arg);
template<typename _Up>
static void
_S_create(_Storage& __storage, _Up&& __value)
{
__storage._M_ptr = new _Tp(std::forward<_Up>(__value));
}
template<typename... _Args>
static void
_S_create(_Storage& __storage, _Args&&... __args)
{
__storage._M_ptr = new _Tp(std::forward<_Args>(__args)...);
}
};
};
/// Exchange the states of two @c any objects.
inline void swap(any& __x, any& __y) noexcept { __x.swap(__y); }
/// Create an any holding a @c _Tp constructed from @c __args.
template <typename _Tp, typename... _Args>
any make_any(_Args&&... __args)
{
return any(in_place_type<_Tp>, std::forward<_Args>(__args)...);
}
/// Create an any holding a @c _Tp constructed from @c __il and @c __args.
template <typename _Tp, typename _Up, typename... _Args>
any make_any(initializer_list<_Up> __il, _Args&&... __args)
{
return any(in_place_type<_Tp>, __il, std::forward<_Args>(__args)...);
}
/**
* @brief Access the contained object.
*
* @tparam _ValueType A const-reference or CopyConstructible type.
* @param __any The object to access.
* @return The contained object.
* @throw bad_any_cast If <code>
* __any.type() != typeid(remove_reference_t<_ValueType>)
* </code>
*/
template<typename _ValueType>
inline _ValueType any_cast(const any& __any)
{
using _Up = remove_cv_t<remove_reference_t<_ValueType>>;
static_assert(any::__is_valid_cast<_ValueType>(),
"Template argument must be a reference or CopyConstructible type");
static_assert(is_constructible_v<_ValueType, const _Up&>,
"Template argument must be constructible from a const value.");
auto __p = any_cast<_Up>(&__any);
if (__p)
return static_cast<_ValueType>(*__p);
__throw_bad_any_cast();
}
/**
* @brief Access the contained object.
*
* @tparam _ValueType A reference or CopyConstructible type.
* @param __any The object to access.
* @return The contained object.
* @throw bad_any_cast If <code>
* __any.type() != typeid(remove_reference_t<_ValueType>)
* </code>
*
* @{
*/
template<typename _ValueType>
inline _ValueType any_cast(any& __any)
{
using _Up = remove_cv_t<remove_reference_t<_ValueType>>;
static_assert(any::__is_valid_cast<_ValueType>(),
"Template argument must be a reference or CopyConstructible type");
static_assert(is_constructible_v<_ValueType, _Up&>,
"Template argument must be constructible from an lvalue.");
auto __p = any_cast<_Up>(&__any);
if (__p)
return static_cast<_ValueType>(*__p);
__throw_bad_any_cast();
}
template<typename _ValueType>
inline _ValueType any_cast(any&& __any)
{
using _Up = remove_cv_t<remove_reference_t<_ValueType>>;
static_assert(any::__is_valid_cast<_ValueType>(),
"Template argument must be a reference or CopyConstructible type");
static_assert(is_constructible_v<_ValueType, _Up>,
"Template argument must be constructible from an rvalue.");
auto __p = any_cast<_Up>(&__any);
if (__p)
return static_cast<_ValueType>(std::move(*__p));
__throw_bad_any_cast();
}
// @}
/// @cond undocumented
template<typename _Tp>
void* __any_caster(const any* __any)
{
// any_cast<T> returns non-null if __any->type() == typeid(T) and
// typeid(T) ignores cv-qualifiers so remove them:
using _Up = remove_cv_t<_Tp>;
// The contained value has a decayed type, so if decay_t<U> is not U,
// then it's not possible to have a contained value of type U:
if constexpr (!is_same_v<decay_t<_Up>, _Up>)
return nullptr;
// Only copy constructible types can be used for contained values:
else if constexpr (!is_copy_constructible_v<_Up>)
return nullptr;
// First try comparing function addresses, which works without RTTI
else if (__any->_M_manager == &any::_Manager<_Up>::_S_manage
#if __cpp_rtti
|| __any->type() == typeid(_Tp)
#endif
)
{
any::_Arg __arg;
__any->_M_manager(any::_Op_access, __any, &__arg);
return __arg._M_obj;
}
return nullptr;
}
/// @endcond
/**
* @brief Access the contained object.
*
* @tparam _ValueType The type of the contained object.
* @param __any A pointer to the object to access.
* @return The address of the contained object if <code>
* __any != nullptr && __any.type() == typeid(_ValueType)
* </code>, otherwise a null pointer.
*
* @{
*/
template<typename _ValueType>
inline const _ValueType* any_cast(const any* __any) noexcept
{
if constexpr (is_object_v<_ValueType>)
if (__any)
return static_cast<_ValueType*>(__any_caster<_ValueType>(__any));
return nullptr;
}
template<typename _ValueType>
inline _ValueType* any_cast(any* __any) noexcept
{
if constexpr (is_object_v<_ValueType>)
if (__any)
return static_cast<_ValueType*>(__any_caster<_ValueType>(__any));
return nullptr;
}
// @}
template<typename _Tp>
void
any::_Manager_internal<_Tp>::
_S_manage(_Op __which, const any* __any, _Arg* __arg)
{
// The contained object is in _M_storage._M_buffer
auto __ptr = reinterpret_cast<const _Tp*>(&__any->_M_storage._M_buffer);
switch (__which)
{
case _Op_access:
__arg->_M_obj = const_cast<_Tp*>(__ptr);
break;
case _Op_get_type_info:
#if __cpp_rtti
__arg->_M_typeinfo = &typeid(_Tp);
#endif
break;
case _Op_clone:
::new(&__arg->_M_any->_M_storage._M_buffer) _Tp(*__ptr);
__arg->_M_any->_M_manager = __any->_M_manager;
break;
case _Op_destroy:
__ptr->~_Tp();
break;
case _Op_xfer:
::new(&__arg->_M_any->_M_storage._M_buffer) _Tp
(std::move(*const_cast<_Tp*>(__ptr)));
__ptr->~_Tp();
__arg->_M_any->_M_manager = __any->_M_manager;
const_cast<any*>(__any)->_M_manager = nullptr;
break;
}
}
template<typename _Tp>
void
any::_Manager_external<_Tp>::
_S_manage(_Op __which, const any* __any, _Arg* __arg)
{
// The contained object is *_M_storage._M_ptr
auto __ptr = static_cast<const _Tp*>(__any->_M_storage._M_ptr);
switch (__which)
{
case _Op_access:
__arg->_M_obj = const_cast<_Tp*>(__ptr);
break;
case _Op_get_type_info:
#if __cpp_rtti
__arg->_M_typeinfo = &typeid(_Tp);
#endif
break;
case _Op_clone:
__arg->_M_any->_M_storage._M_ptr = new _Tp(*__ptr);
__arg->_M_any->_M_manager = __any->_M_manager;
break;
case _Op_destroy:
delete __ptr;
break;
case _Op_xfer:
__arg->_M_any->_M_storage._M_ptr = __any->_M_storage._M_ptr;
__arg->_M_any->_M_manager = __any->_M_manager;
const_cast<any*>(__any)->_M_manager = nullptr;
break;
}
}
/// @}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // C++14
#endif // _GLIBCXX_ANY
c++/8/ext/memory 0000644 00000015764 15201526705 0007336 0 ustar 00 // Memory extensions -*- C++ -*-
// Copyright (C) 2002-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1996
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file ext/memory
* This file is a GNU extension to the Standard C++ Library (possibly
* containing extensions from the HP/SGI STL subset).
*/
#ifndef _EXT_MEMORY
#define _EXT_MEMORY 1
#pragma GCC system_header
#include <memory>
#include <bits/stl_tempbuf.h>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using std::ptrdiff_t;
using std::pair;
using std::__iterator_category;
using std::_Temporary_buffer;
template<typename _InputIter, typename _Size, typename _ForwardIter>
pair<_InputIter, _ForwardIter>
__uninitialized_copy_n(_InputIter __first, _Size __count,
_ForwardIter __result, std::input_iterator_tag)
{
_ForwardIter __cur = __result;
__try
{
for (; __count > 0 ; --__count, ++__first, ++__cur)
std::_Construct(&*__cur, *__first);
return pair<_InputIter, _ForwardIter>(__first, __cur);
}
__catch(...)
{
std::_Destroy(__result, __cur);
__throw_exception_again;
}
}
template<typename _RandomAccessIter, typename _Size, typename _ForwardIter>
inline pair<_RandomAccessIter, _ForwardIter>
__uninitialized_copy_n(_RandomAccessIter __first, _Size __count,
_ForwardIter __result,
std::random_access_iterator_tag)
{
_RandomAccessIter __last = __first + __count;
return (pair<_RandomAccessIter, _ForwardIter>
(__last, std::uninitialized_copy(__first, __last, __result)));
}
template<typename _InputIter, typename _Size, typename _ForwardIter>
inline pair<_InputIter, _ForwardIter>
__uninitialized_copy_n(_InputIter __first, _Size __count,
_ForwardIter __result)
{ return __gnu_cxx::__uninitialized_copy_n(__first, __count, __result,
__iterator_category(__first)); }
/**
* @brief Copies the range [first,last) into result.
* @param __first An input iterator.
* @param __count Length
* @param __result An output iterator.
* @return __result + (__first + __count)
* @ingroup SGIextensions
*
* Like copy(), but does not require an initialized output range.
*/
template<typename _InputIter, typename _Size, typename _ForwardIter>
inline pair<_InputIter, _ForwardIter>
uninitialized_copy_n(_InputIter __first, _Size __count,
_ForwardIter __result)
{ return __gnu_cxx::__uninitialized_copy_n(__first, __count, __result,
__iterator_category(__first)); }
// An alternative version of uninitialized_copy_n that constructs
// and destroys objects with a user-provided allocator.
template<typename _InputIter, typename _Size, typename _ForwardIter,
typename _Allocator>
pair<_InputIter, _ForwardIter>
__uninitialized_copy_n_a(_InputIter __first, _Size __count,
_ForwardIter __result,
_Allocator __alloc)
{
_ForwardIter __cur = __result;
__try
{
for (; __count > 0 ; --__count, ++__first, ++__cur)
__alloc.construct(&*__cur, *__first);
return pair<_InputIter, _ForwardIter>(__first, __cur);
}
__catch(...)
{
std::_Destroy(__result, __cur, __alloc);
__throw_exception_again;
}
}
template<typename _InputIter, typename _Size, typename _ForwardIter,
typename _Tp>
inline pair<_InputIter, _ForwardIter>
__uninitialized_copy_n_a(_InputIter __first, _Size __count,
_ForwardIter __result,
std::allocator<_Tp>)
{
return __gnu_cxx::uninitialized_copy_n(__first, __count, __result);
}
/**
* This class provides similar behavior and semantics of the standard
* functions get_temporary_buffer() and return_temporary_buffer(), but
* encapsulated in a type vaguely resembling a standard container.
*
* By default, a temporary_buffer<Iter> stores space for objects of
* whatever type the Iter iterator points to. It is constructed from a
* typical [first,last) range, and provides the begin(), end(), size()
* functions, as well as requested_size(). For non-trivial types, copies
* of *first will be used to initialize the storage.
*
* @c malloc is used to obtain underlying storage.
*
* Like get_temporary_buffer(), not all the requested memory may be
* available. Ideally, the created buffer will be large enough to hold a
* copy of [first,last), but if size() is less than requested_size(),
* then this didn't happen.
*
* @ingroup SGIextensions
*/
template <class _ForwardIterator, class _Tp
= typename std::iterator_traits<_ForwardIterator>::value_type >
struct temporary_buffer : public _Temporary_buffer<_ForwardIterator, _Tp>
{
/// Requests storage large enough to hold a copy of [first,last).
temporary_buffer(_ForwardIterator __first, _ForwardIterator __last)
: _Temporary_buffer<_ForwardIterator, _Tp>(__first, __last) { }
/// Destroys objects and frees storage.
~temporary_buffer() { }
};
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/ext/array_allocator.h 0000644 00000012412 15201526705 0011415 0 ustar 00 // array allocator -*- C++ -*-
// Copyright (C) 2004-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file ext/array_allocator.h
* This file is a GNU extension to the Standard C++ Library.
*/
#ifndef _ARRAY_ALLOCATOR_H
#define _ARRAY_ALLOCATOR_H 1
#include <bits/c++config.h>
#include <new>
#include <bits/functexcept.h>
#include <tr1/array>
#include <bits/move.h>
#if __cplusplus >= 201103L
#include <type_traits>
#endif
// Suppress deprecated warning for this file.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using std::size_t;
using std::ptrdiff_t;
/// Base class.
template<typename _Tp>
class array_allocator_base
{
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef _Tp* pointer;
typedef const _Tp* const_pointer;
typedef _Tp& reference;
typedef const _Tp& const_reference;
typedef _Tp value_type;
pointer
address(reference __x) const _GLIBCXX_NOEXCEPT
{ return std::__addressof(__x); }
const_pointer
address(const_reference __x) const _GLIBCXX_NOEXCEPT
{ return std::__addressof(__x); }
void
deallocate(pointer, size_type)
{
// Does nothing.
}
size_type
max_size() const _GLIBCXX_USE_NOEXCEPT
{ return size_t(-1) / sizeof(_Tp); }
#if __cplusplus >= 201103L
template<typename _Up, typename... _Args>
void
construct(_Up* __p, _Args&&... __args)
{ ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
template<typename _Up>
void
destroy(_Up* __p) { __p->~_Up(); }
#else
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 402. wrong new expression in [some_] allocator::construct
void
construct(pointer __p, const _Tp& __val)
{ ::new((void *)__p) value_type(__val); }
void
destroy(pointer __p) { __p->~_Tp(); }
#endif
} _GLIBCXX_DEPRECATED;
/**
* @brief An allocator that uses previously allocated memory.
* This memory can be externally, globally, or otherwise allocated.
* @ingroup allocators
*/
template<typename _Tp, typename _Array = std::tr1::array<_Tp, 1> >
class array_allocator : public array_allocator_base<_Tp>
{
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef _Tp* pointer;
typedef const _Tp* const_pointer;
typedef _Tp& reference;
typedef const _Tp& const_reference;
typedef _Tp value_type;
typedef _Array array_type;
#if __cplusplus >= 201103L
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2103. std::allocator propagate_on_container_move_assignment
typedef std::true_type propagate_on_container_move_assignment;
typedef std::true_type is_always_equal;
#endif
private:
array_type* _M_array;
size_type _M_used;
public:
template<typename _Tp1, typename _Array1 = _Array>
struct rebind
{
typedef array_allocator<_Tp1, _Array1> other _GLIBCXX_DEPRECATED;
} _GLIBCXX_DEPRECATED;
array_allocator(array_type* __array = 0) _GLIBCXX_USE_NOEXCEPT
: _M_array(__array), _M_used(size_type()) { }
array_allocator(const array_allocator& __o) _GLIBCXX_USE_NOEXCEPT
: _M_array(__o._M_array), _M_used(__o._M_used) { }
template<typename _Tp1, typename _Array1>
array_allocator(const array_allocator<_Tp1, _Array1>&)
_GLIBCXX_USE_NOEXCEPT
: _M_array(0), _M_used(size_type()) { }
~array_allocator() _GLIBCXX_USE_NOEXCEPT { }
pointer
allocate(size_type __n, const void* = 0)
{
if (_M_array == 0 || _M_used + __n > _M_array->size())
std::__throw_bad_alloc();
pointer __ret = _M_array->begin() + _M_used;
_M_used += __n;
return __ret;
}
} _GLIBCXX_DEPRECATED;
template<typename _Tp, typename _Array>
inline bool
operator==(const array_allocator<_Tp, _Array>&,
const array_allocator<_Tp, _Array>&)
{ return true; }
template<typename _Tp, typename _Array>
inline bool
operator!=(const array_allocator<_Tp, _Array>&,
const array_allocator<_Tp, _Array>&)
{ return false; }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#pragma GCC diagnostic pop
#endif
c++/8/ext/slist 0000644 00000071643 15201526705 0007162 0 ustar 00 // Singly-linked list implementation -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
* Copyright (c) 1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*/
/** @file ext/slist
* This file is a GNU extension to the Standard C++ Library (possibly
* containing extensions from the HP/SGI STL subset).
*/
#ifndef _SLIST
#define _SLIST 1
#include <algorithm>
#include <bits/allocator.h>
#include <bits/stl_construct.h>
#include <bits/stl_uninitialized.h>
#include <bits/concept_check.h>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using std::size_t;
using std::ptrdiff_t;
using std::_Construct;
using std::_Destroy;
using std::allocator;
using std::__true_type;
using std::__false_type;
struct _Slist_node_base
{
_Slist_node_base* _M_next;
};
inline _Slist_node_base*
__slist_make_link(_Slist_node_base* __prev_node,
_Slist_node_base* __new_node)
{
__new_node->_M_next = __prev_node->_M_next;
__prev_node->_M_next = __new_node;
return __new_node;
}
inline _Slist_node_base*
__slist_previous(_Slist_node_base* __head,
const _Slist_node_base* __node)
{
while (__head && __head->_M_next != __node)
__head = __head->_M_next;
return __head;
}
inline const _Slist_node_base*
__slist_previous(const _Slist_node_base* __head,
const _Slist_node_base* __node)
{
while (__head && __head->_M_next != __node)
__head = __head->_M_next;
return __head;
}
inline void
__slist_splice_after(_Slist_node_base* __pos,
_Slist_node_base* __before_first,
_Slist_node_base* __before_last)
{
if (__pos != __before_first && __pos != __before_last)
{
_Slist_node_base* __first = __before_first->_M_next;
_Slist_node_base* __after = __pos->_M_next;
__before_first->_M_next = __before_last->_M_next;
__pos->_M_next = __first;
__before_last->_M_next = __after;
}
}
inline void
__slist_splice_after(_Slist_node_base* __pos, _Slist_node_base* __head)
{
_Slist_node_base* __before_last = __slist_previous(__head, 0);
if (__before_last != __head)
{
_Slist_node_base* __after = __pos->_M_next;
__pos->_M_next = __head->_M_next;
__head->_M_next = 0;
__before_last->_M_next = __after;
}
}
inline _Slist_node_base*
__slist_reverse(_Slist_node_base* __node)
{
_Slist_node_base* __result = __node;
__node = __node->_M_next;
__result->_M_next = 0;
while(__node)
{
_Slist_node_base* __next = __node->_M_next;
__node->_M_next = __result;
__result = __node;
__node = __next;
}
return __result;
}
inline size_t
__slist_size(_Slist_node_base* __node)
{
size_t __result = 0;
for (; __node != 0; __node = __node->_M_next)
++__result;
return __result;
}
template <class _Tp>
struct _Slist_node : public _Slist_node_base
{
_Tp _M_data;
};
struct _Slist_iterator_base
{
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef std::forward_iterator_tag iterator_category;
_Slist_node_base* _M_node;
_Slist_iterator_base(_Slist_node_base* __x)
: _M_node(__x) {}
void
_M_incr()
{ _M_node = _M_node->_M_next; }
bool
operator==(const _Slist_iterator_base& __x) const
{ return _M_node == __x._M_node; }
bool
operator!=(const _Slist_iterator_base& __x) const
{ return _M_node != __x._M_node; }
};
template <class _Tp, class _Ref, class _Ptr>
struct _Slist_iterator : public _Slist_iterator_base
{
typedef _Slist_iterator<_Tp, _Tp&, _Tp*> iterator;
typedef _Slist_iterator<_Tp, const _Tp&, const _Tp*> const_iterator;
typedef _Slist_iterator<_Tp, _Ref, _Ptr> _Self;
typedef _Tp value_type;
typedef _Ptr pointer;
typedef _Ref reference;
typedef _Slist_node<_Tp> _Node;
explicit
_Slist_iterator(_Node* __x)
: _Slist_iterator_base(__x) {}
_Slist_iterator()
: _Slist_iterator_base(0) {}
_Slist_iterator(const iterator& __x)
: _Slist_iterator_base(__x._M_node) {}
reference
operator*() const
{ return ((_Node*) _M_node)->_M_data; }
pointer
operator->() const
{ return &(operator*()); }
_Self&
operator++()
{
_M_incr();
return *this;
}
_Self
operator++(int)
{
_Self __tmp = *this;
_M_incr();
return __tmp;
}
};
template <class _Tp, class _Alloc>
struct _Slist_base
: public _Alloc::template rebind<_Slist_node<_Tp> >::other
{
typedef typename _Alloc::template rebind<_Slist_node<_Tp> >::other
_Node_alloc;
typedef _Alloc allocator_type;
allocator_type
get_allocator() const
{ return *static_cast<const _Node_alloc*>(this); }
_Slist_base(const allocator_type& __a)
: _Node_alloc(__a)
{ this->_M_head._M_next = 0; }
~_Slist_base()
{ _M_erase_after(&this->_M_head, 0); }
protected:
_Slist_node_base _M_head;
_Slist_node<_Tp>*
_M_get_node()
{ return _Node_alloc::allocate(1); }
void
_M_put_node(_Slist_node<_Tp>* __p)
{ _Node_alloc::deallocate(__p, 1); }
protected:
_Slist_node_base* _M_erase_after(_Slist_node_base* __pos)
{
_Slist_node<_Tp>* __next = (_Slist_node<_Tp>*) (__pos->_M_next);
_Slist_node_base* __next_next = __next->_M_next;
__pos->_M_next = __next_next;
get_allocator().destroy(&__next->_M_data);
_M_put_node(__next);
return __next_next;
}
_Slist_node_base* _M_erase_after(_Slist_node_base*, _Slist_node_base*);
};
template <class _Tp, class _Alloc>
_Slist_node_base*
_Slist_base<_Tp,_Alloc>::_M_erase_after(_Slist_node_base* __before_first,
_Slist_node_base* __last_node)
{
_Slist_node<_Tp>* __cur = (_Slist_node<_Tp>*) (__before_first->_M_next);
while (__cur != __last_node)
{
_Slist_node<_Tp>* __tmp = __cur;
__cur = (_Slist_node<_Tp>*) __cur->_M_next;
get_allocator().destroy(&__tmp->_M_data);
_M_put_node(__tmp);
}
__before_first->_M_next = __last_node;
return __last_node;
}
/**
* This is an SGI extension.
* @ingroup SGIextensions
* @doctodo
*/
template <class _Tp, class _Alloc = allocator<_Tp> >
class slist : private _Slist_base<_Tp,_Alloc>
{
// concept requirements
__glibcxx_class_requires(_Tp, _SGIAssignableConcept)
private:
typedef _Slist_base<_Tp,_Alloc> _Base;
public:
typedef _Tp value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef _Slist_iterator<_Tp, _Tp&, _Tp*> iterator;
typedef _Slist_iterator<_Tp, const _Tp&, const _Tp*> const_iterator;
typedef typename _Base::allocator_type allocator_type;
allocator_type
get_allocator() const
{ return _Base::get_allocator(); }
private:
typedef _Slist_node<_Tp> _Node;
typedef _Slist_node_base _Node_base;
typedef _Slist_iterator_base _Iterator_base;
_Node*
_M_create_node(const value_type& __x)
{
_Node* __node = this->_M_get_node();
__try
{
get_allocator().construct(&__node->_M_data, __x);
__node->_M_next = 0;
}
__catch(...)
{
this->_M_put_node(__node);
__throw_exception_again;
}
return __node;
}
_Node*
_M_create_node()
{
_Node* __node = this->_M_get_node();
__try
{
get_allocator().construct(&__node->_M_data, value_type());
__node->_M_next = 0;
}
__catch(...)
{
this->_M_put_node(__node);
__throw_exception_again;
}
return __node;
}
public:
explicit
slist(const allocator_type& __a = allocator_type())
: _Base(__a) {}
slist(size_type __n, const value_type& __x,
const allocator_type& __a = allocator_type())
: _Base(__a)
{ _M_insert_after_fill(&this->_M_head, __n, __x); }
explicit
slist(size_type __n)
: _Base(allocator_type())
{ _M_insert_after_fill(&this->_M_head, __n, value_type()); }
// We don't need any dispatching tricks here, because
// _M_insert_after_range already does them.
template <class _InputIterator>
slist(_InputIterator __first, _InputIterator __last,
const allocator_type& __a = allocator_type())
: _Base(__a)
{ _M_insert_after_range(&this->_M_head, __first, __last); }
slist(const slist& __x)
: _Base(__x.get_allocator())
{ _M_insert_after_range(&this->_M_head, __x.begin(), __x.end()); }
slist&
operator= (const slist& __x);
~slist() {}
public:
// assign(), a generalized assignment member function. Two
// versions: one that takes a count, and one that takes a range.
// The range version is a member template, so we dispatch on whether
// or not the type is an integer.
void
assign(size_type __n, const _Tp& __val)
{ _M_fill_assign(__n, __val); }
void
_M_fill_assign(size_type __n, const _Tp& __val);
template <class _InputIterator>
void
assign(_InputIterator __first, _InputIterator __last)
{
typedef typename std::__is_integer<_InputIterator>::__type _Integral;
_M_assign_dispatch(__first, __last, _Integral());
}
template <class _Integer>
void
_M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
{ _M_fill_assign((size_type) __n, (_Tp) __val); }
template <class _InputIterator>
void
_M_assign_dispatch(_InputIterator __first, _InputIterator __last,
__false_type);
public:
iterator
begin()
{ return iterator((_Node*)this->_M_head._M_next); }
const_iterator
begin() const
{ return const_iterator((_Node*)this->_M_head._M_next);}
iterator
end()
{ return iterator(0); }
const_iterator
end() const
{ return const_iterator(0); }
// Experimental new feature: before_begin() returns a
// non-dereferenceable iterator that, when incremented, yields
// begin(). This iterator may be used as the argument to
// insert_after, erase_after, etc. Note that even for an empty
// slist, before_begin() is not the same iterator as end(). It
// is always necessary to increment before_begin() at least once to
// obtain end().
iterator
before_begin()
{ return iterator((_Node*) &this->_M_head); }
const_iterator
before_begin() const
{ return const_iterator((_Node*) &this->_M_head); }
size_type
size() const
{ return __slist_size(this->_M_head._M_next); }
size_type
max_size() const
{ return size_type(-1); }
bool
empty() const
{ return this->_M_head._M_next == 0; }
void
swap(slist& __x)
{ std::swap(this->_M_head._M_next, __x._M_head._M_next); }
public:
reference
front()
{ return ((_Node*) this->_M_head._M_next)->_M_data; }
const_reference
front() const
{ return ((_Node*) this->_M_head._M_next)->_M_data; }
void
push_front(const value_type& __x)
{ __slist_make_link(&this->_M_head, _M_create_node(__x)); }
void
push_front()
{ __slist_make_link(&this->_M_head, _M_create_node()); }
void
pop_front()
{
_Node* __node = (_Node*) this->_M_head._M_next;
this->_M_head._M_next = __node->_M_next;
get_allocator().destroy(&__node->_M_data);
this->_M_put_node(__node);
}
iterator
previous(const_iterator __pos)
{ return iterator((_Node*) __slist_previous(&this->_M_head,
__pos._M_node)); }
const_iterator
previous(const_iterator __pos) const
{ return const_iterator((_Node*) __slist_previous(&this->_M_head,
__pos._M_node)); }
private:
_Node*
_M_insert_after(_Node_base* __pos, const value_type& __x)
{ return (_Node*) (__slist_make_link(__pos, _M_create_node(__x))); }
_Node*
_M_insert_after(_Node_base* __pos)
{ return (_Node*) (__slist_make_link(__pos, _M_create_node())); }
void
_M_insert_after_fill(_Node_base* __pos,
size_type __n, const value_type& __x)
{
for (size_type __i = 0; __i < __n; ++__i)
__pos = __slist_make_link(__pos, _M_create_node(__x));
}
// Check whether it's an integral type. If so, it's not an iterator.
template <class _InIterator>
void
_M_insert_after_range(_Node_base* __pos,
_InIterator __first, _InIterator __last)
{
typedef typename std::__is_integer<_InIterator>::__type _Integral;
_M_insert_after_range(__pos, __first, __last, _Integral());
}
template <class _Integer>
void
_M_insert_after_range(_Node_base* __pos, _Integer __n, _Integer __x,
__true_type)
{ _M_insert_after_fill(__pos, __n, __x); }
template <class _InIterator>
void
_M_insert_after_range(_Node_base* __pos,
_InIterator __first, _InIterator __last,
__false_type)
{
while (__first != __last)
{
__pos = __slist_make_link(__pos, _M_create_node(*__first));
++__first;
}
}
public:
iterator
insert_after(iterator __pos, const value_type& __x)
{ return iterator(_M_insert_after(__pos._M_node, __x)); }
iterator
insert_after(iterator __pos)
{ return insert_after(__pos, value_type()); }
void
insert_after(iterator __pos, size_type __n, const value_type& __x)
{ _M_insert_after_fill(__pos._M_node, __n, __x); }
// We don't need any dispatching tricks here, because
// _M_insert_after_range already does them.
template <class _InIterator>
void
insert_after(iterator __pos, _InIterator __first, _InIterator __last)
{ _M_insert_after_range(__pos._M_node, __first, __last); }
iterator
insert(iterator __pos, const value_type& __x)
{ return iterator(_M_insert_after(__slist_previous(&this->_M_head,
__pos._M_node),
__x)); }
iterator
insert(iterator __pos)
{ return iterator(_M_insert_after(__slist_previous(&this->_M_head,
__pos._M_node),
value_type())); }
void
insert(iterator __pos, size_type __n, const value_type& __x)
{ _M_insert_after_fill(__slist_previous(&this->_M_head, __pos._M_node),
__n, __x); }
// We don't need any dispatching tricks here, because
// _M_insert_after_range already does them.
template <class _InIterator>
void
insert(iterator __pos, _InIterator __first, _InIterator __last)
{ _M_insert_after_range(__slist_previous(&this->_M_head, __pos._M_node),
__first, __last); }
public:
iterator
erase_after(iterator __pos)
{ return iterator((_Node*) this->_M_erase_after(__pos._M_node)); }
iterator
erase_after(iterator __before_first, iterator __last)
{
return iterator((_Node*) this->_M_erase_after(__before_first._M_node,
__last._M_node));
}
iterator
erase(iterator __pos)
{
return iterator((_Node*) this->_M_erase_after
(__slist_previous(&this->_M_head, __pos._M_node)));
}
iterator
erase(iterator __first, iterator __last)
{
return iterator((_Node*) this->_M_erase_after
(__slist_previous(&this->_M_head, __first._M_node),
__last._M_node));
}
void
resize(size_type new_size, const _Tp& __x);
void
resize(size_type new_size)
{ resize(new_size, _Tp()); }
void
clear()
{ this->_M_erase_after(&this->_M_head, 0); }
public:
// Moves the range [__before_first + 1, __before_last + 1) to *this,
// inserting it immediately after __pos. This is constant time.
void
splice_after(iterator __pos,
iterator __before_first, iterator __before_last)
{
if (__before_first != __before_last)
__slist_splice_after(__pos._M_node, __before_first._M_node,
__before_last._M_node);
}
// Moves the element that follows __prev to *this, inserting it
// immediately after __pos. This is constant time.
void
splice_after(iterator __pos, iterator __prev)
{ __slist_splice_after(__pos._M_node,
__prev._M_node, __prev._M_node->_M_next); }
// Removes all of the elements from the list __x to *this, inserting
// them immediately after __pos. __x must not be *this. Complexity:
// linear in __x.size().
void
splice_after(iterator __pos, slist& __x)
{ __slist_splice_after(__pos._M_node, &__x._M_head); }
// Linear in distance(begin(), __pos), and linear in __x.size().
void
splice(iterator __pos, slist& __x)
{
if (__x._M_head._M_next)
__slist_splice_after(__slist_previous(&this->_M_head, __pos._M_node),
&__x._M_head,
__slist_previous(&__x._M_head, 0)); }
// Linear in distance(begin(), __pos), and in distance(__x.begin(), __i).
void
splice(iterator __pos, slist& __x, iterator __i)
{ __slist_splice_after(__slist_previous(&this->_M_head, __pos._M_node),
__slist_previous(&__x._M_head, __i._M_node),
__i._M_node); }
// Linear in distance(begin(), __pos), in distance(__x.begin(), __first),
// and in distance(__first, __last).
void
splice(iterator __pos, slist& __x, iterator __first, iterator __last)
{
if (__first != __last)
__slist_splice_after(__slist_previous(&this->_M_head, __pos._M_node),
__slist_previous(&__x._M_head, __first._M_node),
__slist_previous(__first._M_node,
__last._M_node));
}
public:
void
reverse()
{
if (this->_M_head._M_next)
this->_M_head._M_next = __slist_reverse(this->_M_head._M_next);
}
void
remove(const _Tp& __val);
void
unique();
void
merge(slist& __x);
void
sort();
template <class _Predicate>
void
remove_if(_Predicate __pred);
template <class _BinaryPredicate>
void
unique(_BinaryPredicate __pred);
template <class _StrictWeakOrdering>
void
merge(slist&, _StrictWeakOrdering);
template <class _StrictWeakOrdering>
void
sort(_StrictWeakOrdering __comp);
};
template <class _Tp, class _Alloc>
slist<_Tp, _Alloc>&
slist<_Tp, _Alloc>::operator=(const slist<_Tp, _Alloc>& __x)
{
if (&__x != this)
{
_Node_base* __p1 = &this->_M_head;
_Node* __n1 = (_Node*) this->_M_head._M_next;
const _Node* __n2 = (const _Node*) __x._M_head._M_next;
while (__n1 && __n2)
{
__n1->_M_data = __n2->_M_data;
__p1 = __n1;
__n1 = (_Node*) __n1->_M_next;
__n2 = (const _Node*) __n2->_M_next;
}
if (__n2 == 0)
this->_M_erase_after(__p1, 0);
else
_M_insert_after_range(__p1, const_iterator((_Node*)__n2),
const_iterator(0));
}
return *this;
}
template <class _Tp, class _Alloc>
void
slist<_Tp, _Alloc>::_M_fill_assign(size_type __n, const _Tp& __val)
{
_Node_base* __prev = &this->_M_head;
_Node* __node = (_Node*) this->_M_head._M_next;
for (; __node != 0 && __n > 0; --__n)
{
__node->_M_data = __val;
__prev = __node;
__node = (_Node*) __node->_M_next;
}
if (__n > 0)
_M_insert_after_fill(__prev, __n, __val);
else
this->_M_erase_after(__prev, 0);
}
template <class _Tp, class _Alloc>
template <class _InputIterator>
void
slist<_Tp, _Alloc>::_M_assign_dispatch(_InputIterator __first,
_InputIterator __last,
__false_type)
{
_Node_base* __prev = &this->_M_head;
_Node* __node = (_Node*) this->_M_head._M_next;
while (__node != 0 && __first != __last)
{
__node->_M_data = *__first;
__prev = __node;
__node = (_Node*) __node->_M_next;
++__first;
}
if (__first != __last)
_M_insert_after_range(__prev, __first, __last);
else
this->_M_erase_after(__prev, 0);
}
template <class _Tp, class _Alloc>
inline bool
operator==(const slist<_Tp, _Alloc>& _SL1, const slist<_Tp, _Alloc>& _SL2)
{
typedef typename slist<_Tp,_Alloc>::const_iterator const_iterator;
const_iterator __end1 = _SL1.end();
const_iterator __end2 = _SL2.end();
const_iterator __i1 = _SL1.begin();
const_iterator __i2 = _SL2.begin();
while (__i1 != __end1 && __i2 != __end2 && *__i1 == *__i2)
{
++__i1;
++__i2;
}
return __i1 == __end1 && __i2 == __end2;
}
template <class _Tp, class _Alloc>
inline bool
operator<(const slist<_Tp, _Alloc>& _SL1, const slist<_Tp, _Alloc>& _SL2)
{ return std::lexicographical_compare(_SL1.begin(), _SL1.end(),
_SL2.begin(), _SL2.end()); }
template <class _Tp, class _Alloc>
inline bool
operator!=(const slist<_Tp, _Alloc>& _SL1, const slist<_Tp, _Alloc>& _SL2)
{ return !(_SL1 == _SL2); }
template <class _Tp, class _Alloc>
inline bool
operator>(const slist<_Tp, _Alloc>& _SL1, const slist<_Tp, _Alloc>& _SL2)
{ return _SL2 < _SL1; }
template <class _Tp, class _Alloc>
inline bool
operator<=(const slist<_Tp, _Alloc>& _SL1, const slist<_Tp, _Alloc>& _SL2)
{ return !(_SL2 < _SL1); }
template <class _Tp, class _Alloc>
inline bool
operator>=(const slist<_Tp, _Alloc>& _SL1, const slist<_Tp, _Alloc>& _SL2)
{ return !(_SL1 < _SL2); }
template <class _Tp, class _Alloc>
inline void
swap(slist<_Tp, _Alloc>& __x, slist<_Tp, _Alloc>& __y)
{ __x.swap(__y); }
template <class _Tp, class _Alloc>
void
slist<_Tp, _Alloc>::resize(size_type __len, const _Tp& __x)
{
_Node_base* __cur = &this->_M_head;
while (__cur->_M_next != 0 && __len > 0)
{
--__len;
__cur = __cur->_M_next;
}
if (__cur->_M_next)
this->_M_erase_after(__cur, 0);
else
_M_insert_after_fill(__cur, __len, __x);
}
template <class _Tp, class _Alloc>
void
slist<_Tp, _Alloc>::remove(const _Tp& __val)
{
_Node_base* __cur = &this->_M_head;
while (__cur && __cur->_M_next)
{
if (((_Node*) __cur->_M_next)->_M_data == __val)
this->_M_erase_after(__cur);
else
__cur = __cur->_M_next;
}
}
template <class _Tp, class _Alloc>
void
slist<_Tp, _Alloc>::unique()
{
_Node_base* __cur = this->_M_head._M_next;
if (__cur)
{
while (__cur->_M_next)
{
if (((_Node*)__cur)->_M_data
== ((_Node*)(__cur->_M_next))->_M_data)
this->_M_erase_after(__cur);
else
__cur = __cur->_M_next;
}
}
}
template <class _Tp, class _Alloc>
void
slist<_Tp, _Alloc>::merge(slist<_Tp, _Alloc>& __x)
{
_Node_base* __n1 = &this->_M_head;
while (__n1->_M_next && __x._M_head._M_next)
{
if (((_Node*) __x._M_head._M_next)->_M_data
< ((_Node*) __n1->_M_next)->_M_data)
__slist_splice_after(__n1, &__x._M_head, __x._M_head._M_next);
__n1 = __n1->_M_next;
}
if (__x._M_head._M_next)
{
__n1->_M_next = __x._M_head._M_next;
__x._M_head._M_next = 0;
}
}
template <class _Tp, class _Alloc>
void
slist<_Tp, _Alloc>::sort()
{
if (this->_M_head._M_next && this->_M_head._M_next->_M_next)
{
slist __carry;
slist __counter[64];
int __fill = 0;
while (!empty())
{
__slist_splice_after(&__carry._M_head,
&this->_M_head, this->_M_head._M_next);
int __i = 0;
while (__i < __fill && !__counter[__i].empty())
{
__counter[__i].merge(__carry);
__carry.swap(__counter[__i]);
++__i;
}
__carry.swap(__counter[__i]);
if (__i == __fill)
++__fill;
}
for (int __i = 1; __i < __fill; ++__i)
__counter[__i].merge(__counter[__i-1]);
this->swap(__counter[__fill-1]);
}
}
template <class _Tp, class _Alloc>
template <class _Predicate>
void slist<_Tp, _Alloc>::remove_if(_Predicate __pred)
{
_Node_base* __cur = &this->_M_head;
while (__cur->_M_next)
{
if (__pred(((_Node*) __cur->_M_next)->_M_data))
this->_M_erase_after(__cur);
else
__cur = __cur->_M_next;
}
}
template <class _Tp, class _Alloc>
template <class _BinaryPredicate>
void
slist<_Tp, _Alloc>::unique(_BinaryPredicate __pred)
{
_Node* __cur = (_Node*) this->_M_head._M_next;
if (__cur)
{
while (__cur->_M_next)
{
if (__pred(((_Node*)__cur)->_M_data,
((_Node*)(__cur->_M_next))->_M_data))
this->_M_erase_after(__cur);
else
__cur = (_Node*) __cur->_M_next;
}
}
}
template <class _Tp, class _Alloc>
template <class _StrictWeakOrdering>
void
slist<_Tp, _Alloc>::merge(slist<_Tp, _Alloc>& __x,
_StrictWeakOrdering __comp)
{
_Node_base* __n1 = &this->_M_head;
while (__n1->_M_next && __x._M_head._M_next)
{
if (__comp(((_Node*) __x._M_head._M_next)->_M_data,
((_Node*) __n1->_M_next)->_M_data))
__slist_splice_after(__n1, &__x._M_head, __x._M_head._M_next);
__n1 = __n1->_M_next;
}
if (__x._M_head._M_next)
{
__n1->_M_next = __x._M_head._M_next;
__x._M_head._M_next = 0;
}
}
template <class _Tp, class _Alloc>
template <class _StrictWeakOrdering>
void
slist<_Tp, _Alloc>::sort(_StrictWeakOrdering __comp)
{
if (this->_M_head._M_next && this->_M_head._M_next->_M_next)
{
slist __carry;
slist __counter[64];
int __fill = 0;
while (!empty())
{
__slist_splice_after(&__carry._M_head,
&this->_M_head, this->_M_head._M_next);
int __i = 0;
while (__i < __fill && !__counter[__i].empty())
{
__counter[__i].merge(__carry, __comp);
__carry.swap(__counter[__i]);
++__i;
}
__carry.swap(__counter[__i]);
if (__i == __fill)
++__fill;
}
for (int __i = 1; __i < __fill; ++__i)
__counter[__i].merge(__counter[__i-1], __comp);
this->swap(__counter[__fill-1]);
}
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Specialization of insert_iterator so that insertions will be constant
// time rather than linear time.
template <class _Tp, class _Alloc>
class insert_iterator<__gnu_cxx::slist<_Tp, _Alloc> >
{
protected:
typedef __gnu_cxx::slist<_Tp, _Alloc> _Container;
_Container* container;
typename _Container::iterator iter;
public:
typedef _Container container_type;
typedef output_iterator_tag iterator_category;
typedef void value_type;
typedef void difference_type;
typedef void pointer;
typedef void reference;
insert_iterator(_Container& __x, typename _Container::iterator __i)
: container(&__x)
{
if (__i == __x.begin())
iter = __x.before_begin();
else
iter = __x.previous(__i);
}
insert_iterator<_Container>&
operator=(const typename _Container::value_type& __value)
{
iter = container->insert_after(iter, __value);
return *this;
}
insert_iterator<_Container>&
operator*()
{ return *this; }
insert_iterator<_Container>&
operator++()
{ return *this; }
insert_iterator<_Container>&
operator++(int)
{ return *this; }
};
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/ext/throw_allocator.h 0000644 00000057731 15201526705 0011457 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/** @file ext/throw_allocator.h
* This file is a GNU extension to the Standard C++ Library.
*
* Contains two exception-generating types (throw_value, throw_allocator)
* intended to be used as value and allocator types while testing
* exception safety in templatized containers and algorithms. The
* allocator has additional log and debug features. The exception
* generated is of type forced_exception_error.
*/
#ifndef _THROW_ALLOCATOR_H
#define _THROW_ALLOCATOR_H 1
#include <cmath>
#include <ctime>
#include <map>
#include <string>
#include <ostream>
#include <stdexcept>
#include <utility>
#include <bits/functexcept.h>
#include <bits/move.h>
#if __cplusplus >= 201103L
# include <functional>
# include <random>
#else
# include <tr1/functional>
# include <tr1/random>
#endif
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @brief Thown by exception safety machinery.
* @ingroup exceptions
*/
struct forced_error : public std::exception
{ };
// Substitute for forced_error object when -fno-exceptions.
inline void
__throw_forced_error()
{ _GLIBCXX_THROW_OR_ABORT(forced_error()); }
/**
* @brief Base class for checking address and label information
* about allocations. Create a std::map between the allocated
* address (void*) and a datum for annotations, which are a pair of
* numbers corresponding to label and allocated size.
*/
struct annotate_base
{
annotate_base()
{
label();
map_alloc();
}
static void
set_label(size_t l)
{ label() = l; }
static size_t
get_label()
{ return label(); }
void
insert(void* p, size_t size)
{
if (!p)
{
std::string error("annotate_base::insert null insert!\n");
log_to_string(error, make_entry(p, size));
std::__throw_logic_error(error.c_str());
}
const_iterator found = map_alloc().find(p);
if (found != map_alloc().end())
{
std::string error("annotate_base::insert double insert!\n");
log_to_string(error, make_entry(p, size));
log_to_string(error, *found);
std::__throw_logic_error(error.c_str());
}
map_alloc().insert(make_entry(p, size));
}
void
erase(void* p, size_t size)
{
check_allocated(p, size);
map_alloc().erase(p);
}
#if __cplusplus >= 201103L
void
insert_construct(void* p)
{
if (!p)
{
std::string error("annotate_base::insert_construct null!\n");
std::__throw_logic_error(error.c_str());
}
auto found = map_construct().find(p);
if (found != map_construct().end())
{
std::string error("annotate_base::insert_construct double insert!\n");
log_to_string(error, std::make_pair(p, get_label()));
log_to_string(error, *found);
std::__throw_logic_error(error.c_str());
}
map_construct().insert(std::make_pair(p, get_label()));
}
void
erase_construct(void* p)
{
check_constructed(p);
map_construct().erase(p);
}
#endif
// See if a particular address and allocation size has been saved.
inline void
check_allocated(void* p, size_t size)
{
const_iterator found = map_alloc().find(p);
if (found == map_alloc().end())
{
std::string error("annotate_base::check_allocated by value "
"null erase!\n");
log_to_string(error, make_entry(p, size));
std::__throw_logic_error(error.c_str());
}
if (found->second.second != size)
{
std::string error("annotate_base::check_allocated by value "
"wrong-size erase!\n");
log_to_string(error, make_entry(p, size));
log_to_string(error, *found);
std::__throw_logic_error(error.c_str());
}
}
// See if a given label has been allocated.
inline void
check(size_t label)
{
std::string found;
{
const_iterator beg = map_alloc().begin();
const_iterator end = map_alloc().end();
while (beg != end)
{
if (beg->second.first == label)
log_to_string(found, *beg);
++beg;
}
}
#if __cplusplus >= 201103L
{
auto beg = map_construct().begin();
auto end = map_construct().end();
while (beg != end)
{
if (beg->second == label)
log_to_string(found, *beg);
++beg;
}
}
#endif
if (!found.empty())
{
std::string error("annotate_base::check by label\n");
error += found;
std::__throw_logic_error(error.c_str());
}
}
// See if there is anything left allocated or constructed.
inline static void
check()
{
std::string found;
{
const_iterator beg = map_alloc().begin();
const_iterator end = map_alloc().end();
while (beg != end)
{
log_to_string(found, *beg);
++beg;
}
}
#if __cplusplus >= 201103L
{
auto beg = map_construct().begin();
auto end = map_construct().end();
while (beg != end)
{
log_to_string(found, *beg);
++beg;
}
}
#endif
if (!found.empty())
{
std::string error("annotate_base::check \n");
error += found;
std::__throw_logic_error(error.c_str());
}
}
#if __cplusplus >= 201103L
inline void
check_constructed(void* p)
{
auto found = map_construct().find(p);
if (found == map_construct().end())
{
std::string error("annotate_base::check_constructed not "
"constructed!\n");
log_to_string(error, std::make_pair(p, get_label()));
std::__throw_logic_error(error.c_str());
}
}
inline void
check_constructed(size_t label)
{
auto beg = map_construct().begin();
auto end = map_construct().end();
std::string found;
while (beg != end)
{
if (beg->second == label)
log_to_string(found, *beg);
++beg;
}
if (!found.empty())
{
std::string error("annotate_base::check_constructed by label\n");
error += found;
std::__throw_logic_error(error.c_str());
}
}
#endif
private:
typedef std::pair<size_t, size_t> data_type;
typedef std::map<void*, data_type> map_alloc_type;
typedef map_alloc_type::value_type entry_type;
typedef map_alloc_type::const_iterator const_iterator;
typedef map_alloc_type::const_reference const_reference;
#if __cplusplus >= 201103L
typedef std::map<void*, size_t> map_construct_type;
#endif
friend std::ostream&
operator<<(std::ostream&, const annotate_base&);
entry_type
make_entry(void* p, size_t size)
{ return std::make_pair(p, data_type(get_label(), size)); }
static void
log_to_string(std::string& s, const_reference ref)
{
char buf[40];
const char tab('\t');
s += "label: ";
unsigned long l = static_cast<unsigned long>(ref.second.first);
__builtin_sprintf(buf, "%lu", l);
s += buf;
s += tab;
s += "size: ";
l = static_cast<unsigned long>(ref.second.second);
__builtin_sprintf(buf, "%lu", l);
s += buf;
s += tab;
s += "address: ";
__builtin_sprintf(buf, "%p", ref.first);
s += buf;
s += '\n';
}
#if __cplusplus >= 201103L
static void
log_to_string(std::string& s, const std::pair<const void*, size_t>& ref)
{
char buf[40];
const char tab('\t');
s += "label: ";
unsigned long l = static_cast<unsigned long>(ref.second);
__builtin_sprintf(buf, "%lu", l);
s += buf;
s += tab;
s += "address: ";
__builtin_sprintf(buf, "%p", ref.first);
s += buf;
s += '\n';
}
#endif
static size_t&
label()
{
static size_t _S_label(std::numeric_limits<size_t>::max());
return _S_label;
}
static map_alloc_type&
map_alloc()
{
static map_alloc_type _S_map;
return _S_map;
}
#if __cplusplus >= 201103L
static map_construct_type&
map_construct()
{
static map_construct_type _S_map;
return _S_map;
}
#endif
};
inline std::ostream&
operator<<(std::ostream& os, const annotate_base& __b)
{
std::string error;
typedef annotate_base base_type;
{
base_type::const_iterator beg = __b.map_alloc().begin();
base_type::const_iterator end = __b.map_alloc().end();
for (; beg != end; ++beg)
__b.log_to_string(error, *beg);
}
#if __cplusplus >= 201103L
{
auto beg = __b.map_construct().begin();
auto end = __b.map_construct().end();
for (; beg != end; ++beg)
__b.log_to_string(error, *beg);
}
#endif
return os << error;
}
/**
* @brief Base struct for condition policy.
*
* Requires a public member function with the signature
* void throw_conditionally()
*/
struct condition_base
{
virtual ~condition_base() { };
};
/**
* @brief Base class for incremental control and throw.
*/
struct limit_condition : public condition_base
{
// Scope-level adjustor objects: set limit for throw at the
// beginning of a scope block, and restores to previous limit when
// object is destroyed on exiting the block.
struct adjustor_base
{
private:
const size_t _M_orig;
public:
adjustor_base() : _M_orig(limit()) { }
virtual
~adjustor_base() { set_limit(_M_orig); }
};
/// Never enter the condition.
struct never_adjustor : public adjustor_base
{
never_adjustor() { set_limit(std::numeric_limits<size_t>::max()); }
};
/// Always enter the condition.
struct always_adjustor : public adjustor_base
{
always_adjustor() { set_limit(count()); }
};
/// Enter the nth condition.
struct limit_adjustor : public adjustor_base
{
limit_adjustor(const size_t __l) { set_limit(__l); }
};
// Increment _S_count every time called.
// If _S_count matches the limit count, throw.
static void
throw_conditionally()
{
if (count() == limit())
__throw_forced_error();
++count();
}
static size_t&
count()
{
static size_t _S_count(0);
return _S_count;
}
static size_t&
limit()
{
static size_t _S_limit(std::numeric_limits<size_t>::max());
return _S_limit;
}
// Zero the throw counter, set limit to argument.
static void
set_limit(const size_t __l)
{
limit() = __l;
count() = 0;
}
};
/**
* @brief Base class for random probability control and throw.
*/
struct random_condition : public condition_base
{
// Scope-level adjustor objects: set probability for throw at the
// beginning of a scope block, and restores to previous
// probability when object is destroyed on exiting the block.
struct adjustor_base
{
private:
const double _M_orig;
public:
adjustor_base() : _M_orig(probability()) { }
virtual ~adjustor_base()
{ set_probability(_M_orig); }
};
/// Group condition.
struct group_adjustor : public adjustor_base
{
group_adjustor(size_t size)
{ set_probability(1 - std::pow(double(1 - probability()),
double(0.5 / (size + 1))));
}
};
/// Never enter the condition.
struct never_adjustor : public adjustor_base
{
never_adjustor() { set_probability(0); }
};
/// Always enter the condition.
struct always_adjustor : public adjustor_base
{
always_adjustor() { set_probability(1); }
};
random_condition()
{
probability();
engine();
}
static void
set_probability(double __p)
{ probability() = __p; }
static void
throw_conditionally()
{
if (generate() < probability())
__throw_forced_error();
}
void
seed(unsigned long __s)
{ engine().seed(__s); }
private:
#if __cplusplus >= 201103L
typedef std::uniform_real_distribution<double> distribution_type;
typedef std::mt19937 engine_type;
#else
typedef std::tr1::uniform_real<double> distribution_type;
typedef std::tr1::mt19937 engine_type;
#endif
static double
generate()
{
#if __cplusplus >= 201103L
const distribution_type distribution(0, 1);
static auto generator = std::bind(distribution, engine());
#else
// Use variate_generator to get normalized results.
typedef std::tr1::variate_generator<engine_type, distribution_type> gen_t;
distribution_type distribution(0, 1);
static gen_t generator(engine(), distribution);
#endif
double random = generator();
if (random < distribution.min() || random > distribution.max())
{
std::string __s("random_condition::generate");
__s += "\n";
__s += "random number generated is: ";
char buf[40];
__builtin_sprintf(buf, "%f", random);
__s += buf;
std::__throw_out_of_range(__s.c_str());
}
return random;
}
static double&
probability()
{
static double _S_p;
return _S_p;
}
static engine_type&
engine()
{
static engine_type _S_e;
return _S_e;
}
};
/**
* @brief Class with exception generation control. Intended to be
* used as a value_type in templatized code.
*
* Note: Destructor not allowed to throw.
*/
template<typename _Cond>
struct throw_value_base : public _Cond
{
typedef _Cond condition_type;
using condition_type::throw_conditionally;
std::size_t _M_i;
#ifndef _GLIBCXX_IS_AGGREGATE
throw_value_base() : _M_i(0)
{ throw_conditionally(); }
throw_value_base(const throw_value_base& __v) : _M_i(__v._M_i)
{ throw_conditionally(); }
#if __cplusplus >= 201103L
// Shall not throw.
throw_value_base(throw_value_base&&) = default;
#endif
explicit throw_value_base(const std::size_t __i) : _M_i(__i)
{ throw_conditionally(); }
#endif
throw_value_base&
operator=(const throw_value_base& __v)
{
throw_conditionally();
_M_i = __v._M_i;
return *this;
}
#if __cplusplus >= 201103L
// Shall not throw.
throw_value_base&
operator=(throw_value_base&&) = default;
#endif
throw_value_base&
operator++()
{
throw_conditionally();
++_M_i;
return *this;
}
};
template<typename _Cond>
inline void
swap(throw_value_base<_Cond>& __a, throw_value_base<_Cond>& __b)
{
typedef throw_value_base<_Cond> throw_value;
throw_value::throw_conditionally();
throw_value orig(__a);
__a = __b;
__b = orig;
}
// General instantiable types requirements.
template<typename _Cond>
inline bool
operator==(const throw_value_base<_Cond>& __a,
const throw_value_base<_Cond>& __b)
{
typedef throw_value_base<_Cond> throw_value;
throw_value::throw_conditionally();
bool __ret = __a._M_i == __b._M_i;
return __ret;
}
template<typename _Cond>
inline bool
operator<(const throw_value_base<_Cond>& __a,
const throw_value_base<_Cond>& __b)
{
typedef throw_value_base<_Cond> throw_value;
throw_value::throw_conditionally();
bool __ret = __a._M_i < __b._M_i;
return __ret;
}
// Numeric algorithms instantiable types requirements.
template<typename _Cond>
inline throw_value_base<_Cond>
operator+(const throw_value_base<_Cond>& __a,
const throw_value_base<_Cond>& __b)
{
typedef throw_value_base<_Cond> throw_value;
throw_value::throw_conditionally();
throw_value __ret(__a._M_i + __b._M_i);
return __ret;
}
template<typename _Cond>
inline throw_value_base<_Cond>
operator-(const throw_value_base<_Cond>& __a,
const throw_value_base<_Cond>& __b)
{
typedef throw_value_base<_Cond> throw_value;
throw_value::throw_conditionally();
throw_value __ret(__a._M_i - __b._M_i);
return __ret;
}
template<typename _Cond>
inline throw_value_base<_Cond>
operator*(const throw_value_base<_Cond>& __a,
const throw_value_base<_Cond>& __b)
{
typedef throw_value_base<_Cond> throw_value;
throw_value::throw_conditionally();
throw_value __ret(__a._M_i * __b._M_i);
return __ret;
}
/// Type throwing via limit condition.
struct throw_value_limit : public throw_value_base<limit_condition>
{
typedef throw_value_base<limit_condition> base_type;
#ifndef _GLIBCXX_IS_AGGREGATE
throw_value_limit() { }
throw_value_limit(const throw_value_limit& __other)
: base_type(__other._M_i) { }
#if __cplusplus >= 201103L
throw_value_limit(throw_value_limit&&) = default;
#endif
explicit throw_value_limit(const std::size_t __i) : base_type(__i) { }
#endif
throw_value_limit&
operator=(const throw_value_limit& __other)
{
base_type::operator=(__other);
return *this;
}
#if __cplusplus >= 201103L
throw_value_limit&
operator=(throw_value_limit&&) = default;
#endif
};
/// Type throwing via random condition.
struct throw_value_random : public throw_value_base<random_condition>
{
typedef throw_value_base<random_condition> base_type;
#ifndef _GLIBCXX_IS_AGGREGATE
throw_value_random() { }
throw_value_random(const throw_value_random& __other)
: base_type(__other._M_i) { }
#if __cplusplus >= 201103L
throw_value_random(throw_value_random&&) = default;
#endif
explicit throw_value_random(const std::size_t __i) : base_type(__i) { }
#endif
throw_value_random&
operator=(const throw_value_random& __other)
{
base_type::operator=(__other);
return *this;
}
#if __cplusplus >= 201103L
throw_value_random&
operator=(throw_value_random&&) = default;
#endif
};
/**
* @brief Allocator class with logging and exception generation control.
* Intended to be used as an allocator_type in templatized code.
* @ingroup allocators
*
* Note: Deallocate not allowed to throw.
*/
template<typename _Tp, typename _Cond>
class throw_allocator_base
: public annotate_base, public _Cond
{
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef _Tp value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
#if __cplusplus >= 201103L
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2103. std::allocator propagate_on_container_move_assignment
typedef std::true_type propagate_on_container_move_assignment;
#endif
private:
typedef _Cond condition_type;
std::allocator<value_type> _M_allocator;
using condition_type::throw_conditionally;
public:
size_type
max_size() const _GLIBCXX_USE_NOEXCEPT
{ return _M_allocator.max_size(); }
pointer
address(reference __x) const _GLIBCXX_NOEXCEPT
{ return std::__addressof(__x); }
const_pointer
address(const_reference __x) const _GLIBCXX_NOEXCEPT
{ return std::__addressof(__x); }
pointer
allocate(size_type __n, std::allocator<void>::const_pointer hint = 0)
{
if (__n > this->max_size())
std::__throw_bad_alloc();
throw_conditionally();
pointer const a = _M_allocator.allocate(__n, hint);
insert(a, sizeof(value_type) * __n);
return a;
}
#if __cplusplus >= 201103L
template<typename _Up, typename... _Args>
void
construct(_Up* __p, _Args&&... __args)
{
_M_allocator.construct(__p, std::forward<_Args>(__args)...);
insert_construct(__p);
}
template<typename _Up>
void
destroy(_Up* __p)
{
erase_construct(__p);
_M_allocator.destroy(__p);
}
#else
void
construct(pointer __p, const value_type& val)
{ return _M_allocator.construct(__p, val); }
void
destroy(pointer __p)
{ _M_allocator.destroy(__p); }
#endif
void
deallocate(pointer __p, size_type __n)
{
erase(__p, sizeof(value_type) * __n);
_M_allocator.deallocate(__p, __n);
}
void
check_allocated(pointer __p, size_type __n)
{
size_type __t = sizeof(value_type) * __n;
annotate_base::check_allocated(__p, __t);
}
void
check(size_type __n)
{ annotate_base::check(__n); }
};
template<typename _Tp, typename _Cond>
inline bool
operator==(const throw_allocator_base<_Tp, _Cond>&,
const throw_allocator_base<_Tp, _Cond>&)
{ return true; }
template<typename _Tp, typename _Cond>
inline bool
operator!=(const throw_allocator_base<_Tp, _Cond>&,
const throw_allocator_base<_Tp, _Cond>&)
{ return false; }
/// Allocator throwing via limit condition.
template<typename _Tp>
struct throw_allocator_limit
: public throw_allocator_base<_Tp, limit_condition>
{
template<typename _Tp1>
struct rebind
{ typedef throw_allocator_limit<_Tp1> other; };
throw_allocator_limit() _GLIBCXX_USE_NOEXCEPT { }
throw_allocator_limit(const throw_allocator_limit&)
_GLIBCXX_USE_NOEXCEPT { }
template<typename _Tp1>
throw_allocator_limit(const throw_allocator_limit<_Tp1>&)
_GLIBCXX_USE_NOEXCEPT { }
~throw_allocator_limit() _GLIBCXX_USE_NOEXCEPT { }
};
/// Allocator throwing via random condition.
template<typename _Tp>
struct throw_allocator_random
: public throw_allocator_base<_Tp, random_condition>
{
template<typename _Tp1>
struct rebind
{ typedef throw_allocator_random<_Tp1> other; };
throw_allocator_random() _GLIBCXX_USE_NOEXCEPT { }
throw_allocator_random(const throw_allocator_random&)
_GLIBCXX_USE_NOEXCEPT { }
template<typename _Tp1>
throw_allocator_random(const throw_allocator_random<_Tp1>&)
_GLIBCXX_USE_NOEXCEPT { }
~throw_allocator_random() _GLIBCXX_USE_NOEXCEPT { }
};
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#if __cplusplus >= 201103L
# include <bits/functional_hash.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
/// Explicit specialization of std::hash for __gnu_cxx::throw_value_limit.
template<>
struct hash<__gnu_cxx::throw_value_limit>
: public std::unary_function<__gnu_cxx::throw_value_limit, size_t>
{
size_t
operator()(const __gnu_cxx::throw_value_limit& __val) const
{
__gnu_cxx::throw_value_limit::throw_conditionally();
std::hash<std::size_t> __h;
size_t __result = __h(__val._M_i);
return __result;
}
};
/// Explicit specialization of std::hash for __gnu_cxx::throw_value_random.
template<>
struct hash<__gnu_cxx::throw_value_random>
: public std::unary_function<__gnu_cxx::throw_value_random, size_t>
{
size_t
operator()(const __gnu_cxx::throw_value_random& __val) const
{
__gnu_cxx::throw_value_random::throw_conditionally();
std::hash<std::size_t> __h;
size_t __result = __h(__val._M_i);
return __result;
}
};
} // end namespace std
#endif
#endif
c++/8/ext/random.tcc 0000644 00000165527 15201526705 0010061 0 ustar 00 // Random number extensions -*- C++ -*-
// Copyright (C) 2012-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file ext/random.tcc
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{ext/random}
*/
#ifndef _EXT_RANDOM_TCC
#define _EXT_RANDOM_TCC 1
#pragma GCC system_header
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
template<typename _UIntType, size_t __m,
size_t __pos1, size_t __sl1, size_t __sl2,
size_t __sr1, size_t __sr2,
uint32_t __msk1, uint32_t __msk2,
uint32_t __msk3, uint32_t __msk4,
uint32_t __parity1, uint32_t __parity2,
uint32_t __parity3, uint32_t __parity4>
void simd_fast_mersenne_twister_engine<_UIntType, __m,
__pos1, __sl1, __sl2, __sr1, __sr2,
__msk1, __msk2, __msk3, __msk4,
__parity1, __parity2, __parity3,
__parity4>::
seed(_UIntType __seed)
{
_M_state32[0] = static_cast<uint32_t>(__seed);
for (size_t __i = 1; __i < _M_nstate32; ++__i)
_M_state32[__i] = (1812433253UL
* (_M_state32[__i - 1] ^ (_M_state32[__i - 1] >> 30))
+ __i);
_M_pos = state_size;
_M_period_certification();
}
namespace {
inline uint32_t _Func1(uint32_t __x)
{
return (__x ^ (__x >> 27)) * UINT32_C(1664525);
}
inline uint32_t _Func2(uint32_t __x)
{
return (__x ^ (__x >> 27)) * UINT32_C(1566083941);
}
}
template<typename _UIntType, size_t __m,
size_t __pos1, size_t __sl1, size_t __sl2,
size_t __sr1, size_t __sr2,
uint32_t __msk1, uint32_t __msk2,
uint32_t __msk3, uint32_t __msk4,
uint32_t __parity1, uint32_t __parity2,
uint32_t __parity3, uint32_t __parity4>
template<typename _Sseq>
typename std::enable_if<std::is_class<_Sseq>::value>::type
simd_fast_mersenne_twister_engine<_UIntType, __m,
__pos1, __sl1, __sl2, __sr1, __sr2,
__msk1, __msk2, __msk3, __msk4,
__parity1, __parity2, __parity3,
__parity4>::
seed(_Sseq& __q)
{
size_t __lag;
if (_M_nstate32 >= 623)
__lag = 11;
else if (_M_nstate32 >= 68)
__lag = 7;
else if (_M_nstate32 >= 39)
__lag = 5;
else
__lag = 3;
const size_t __mid = (_M_nstate32 - __lag) / 2;
std::fill(_M_state32, _M_state32 + _M_nstate32, UINT32_C(0x8b8b8b8b));
uint32_t __arr[_M_nstate32];
__q.generate(__arr + 0, __arr + _M_nstate32);
uint32_t __r = _Func1(_M_state32[0] ^ _M_state32[__mid]
^ _M_state32[_M_nstate32 - 1]);
_M_state32[__mid] += __r;
__r += _M_nstate32;
_M_state32[__mid + __lag] += __r;
_M_state32[0] = __r;
for (size_t __i = 1, __j = 0; __j < _M_nstate32; ++__j)
{
__r = _Func1(_M_state32[__i]
^ _M_state32[(__i + __mid) % _M_nstate32]
^ _M_state32[(__i + _M_nstate32 - 1) % _M_nstate32]);
_M_state32[(__i + __mid) % _M_nstate32] += __r;
__r += __arr[__j] + __i;
_M_state32[(__i + __mid + __lag) % _M_nstate32] += __r;
_M_state32[__i] = __r;
__i = (__i + 1) % _M_nstate32;
}
for (size_t __j = 0; __j < _M_nstate32; ++__j)
{
const size_t __i = (__j + 1) % _M_nstate32;
__r = _Func2(_M_state32[__i]
+ _M_state32[(__i + __mid) % _M_nstate32]
+ _M_state32[(__i + _M_nstate32 - 1) % _M_nstate32]);
_M_state32[(__i + __mid) % _M_nstate32] ^= __r;
__r -= __i;
_M_state32[(__i + __mid + __lag) % _M_nstate32] ^= __r;
_M_state32[__i] = __r;
}
_M_pos = state_size;
_M_period_certification();
}
template<typename _UIntType, size_t __m,
size_t __pos1, size_t __sl1, size_t __sl2,
size_t __sr1, size_t __sr2,
uint32_t __msk1, uint32_t __msk2,
uint32_t __msk3, uint32_t __msk4,
uint32_t __parity1, uint32_t __parity2,
uint32_t __parity3, uint32_t __parity4>
void simd_fast_mersenne_twister_engine<_UIntType, __m,
__pos1, __sl1, __sl2, __sr1, __sr2,
__msk1, __msk2, __msk3, __msk4,
__parity1, __parity2, __parity3,
__parity4>::
_M_period_certification(void)
{
static const uint32_t __parity[4] = { __parity1, __parity2,
__parity3, __parity4 };
uint32_t __inner = 0;
for (size_t __i = 0; __i < 4; ++__i)
if (__parity[__i] != 0)
__inner ^= _M_state32[__i] & __parity[__i];
if (__builtin_parity(__inner) & 1)
return;
for (size_t __i = 0; __i < 4; ++__i)
if (__parity[__i] != 0)
{
_M_state32[__i] ^= 1 << (__builtin_ffs(__parity[__i]) - 1);
return;
}
__builtin_unreachable();
}
template<typename _UIntType, size_t __m,
size_t __pos1, size_t __sl1, size_t __sl2,
size_t __sr1, size_t __sr2,
uint32_t __msk1, uint32_t __msk2,
uint32_t __msk3, uint32_t __msk4,
uint32_t __parity1, uint32_t __parity2,
uint32_t __parity3, uint32_t __parity4>
void simd_fast_mersenne_twister_engine<_UIntType, __m,
__pos1, __sl1, __sl2, __sr1, __sr2,
__msk1, __msk2, __msk3, __msk4,
__parity1, __parity2, __parity3,
__parity4>::
discard(unsigned long long __z)
{
while (__z > state_size - _M_pos)
{
__z -= state_size - _M_pos;
_M_gen_rand();
}
_M_pos += __z;
}
#ifndef _GLIBCXX_OPT_HAVE_RANDOM_SFMT_GEN_READ
namespace {
template<size_t __shift>
inline void __rshift(uint32_t *__out, const uint32_t *__in)
{
uint64_t __th = ((static_cast<uint64_t>(__in[3]) << 32)
| static_cast<uint64_t>(__in[2]));
uint64_t __tl = ((static_cast<uint64_t>(__in[1]) << 32)
| static_cast<uint64_t>(__in[0]));
uint64_t __oh = __th >> (__shift * 8);
uint64_t __ol = __tl >> (__shift * 8);
__ol |= __th << (64 - __shift * 8);
__out[1] = static_cast<uint32_t>(__ol >> 32);
__out[0] = static_cast<uint32_t>(__ol);
__out[3] = static_cast<uint32_t>(__oh >> 32);
__out[2] = static_cast<uint32_t>(__oh);
}
template<size_t __shift>
inline void __lshift(uint32_t *__out, const uint32_t *__in)
{
uint64_t __th = ((static_cast<uint64_t>(__in[3]) << 32)
| static_cast<uint64_t>(__in[2]));
uint64_t __tl = ((static_cast<uint64_t>(__in[1]) << 32)
| static_cast<uint64_t>(__in[0]));
uint64_t __oh = __th << (__shift * 8);
uint64_t __ol = __tl << (__shift * 8);
__oh |= __tl >> (64 - __shift * 8);
__out[1] = static_cast<uint32_t>(__ol >> 32);
__out[0] = static_cast<uint32_t>(__ol);
__out[3] = static_cast<uint32_t>(__oh >> 32);
__out[2] = static_cast<uint32_t>(__oh);
}
template<size_t __sl1, size_t __sl2, size_t __sr1, size_t __sr2,
uint32_t __msk1, uint32_t __msk2, uint32_t __msk3, uint32_t __msk4>
inline void __recursion(uint32_t *__r,
const uint32_t *__a, const uint32_t *__b,
const uint32_t *__c, const uint32_t *__d)
{
uint32_t __x[4];
uint32_t __y[4];
__lshift<__sl2>(__x, __a);
__rshift<__sr2>(__y, __c);
__r[0] = (__a[0] ^ __x[0] ^ ((__b[0] >> __sr1) & __msk1)
^ __y[0] ^ (__d[0] << __sl1));
__r[1] = (__a[1] ^ __x[1] ^ ((__b[1] >> __sr1) & __msk2)
^ __y[1] ^ (__d[1] << __sl1));
__r[2] = (__a[2] ^ __x[2] ^ ((__b[2] >> __sr1) & __msk3)
^ __y[2] ^ (__d[2] << __sl1));
__r[3] = (__a[3] ^ __x[3] ^ ((__b[3] >> __sr1) & __msk4)
^ __y[3] ^ (__d[3] << __sl1));
}
}
template<typename _UIntType, size_t __m,
size_t __pos1, size_t __sl1, size_t __sl2,
size_t __sr1, size_t __sr2,
uint32_t __msk1, uint32_t __msk2,
uint32_t __msk3, uint32_t __msk4,
uint32_t __parity1, uint32_t __parity2,
uint32_t __parity3, uint32_t __parity4>
void simd_fast_mersenne_twister_engine<_UIntType, __m,
__pos1, __sl1, __sl2, __sr1, __sr2,
__msk1, __msk2, __msk3, __msk4,
__parity1, __parity2, __parity3,
__parity4>::
_M_gen_rand(void)
{
const uint32_t *__r1 = &_M_state32[_M_nstate32 - 8];
const uint32_t *__r2 = &_M_state32[_M_nstate32 - 4];
static constexpr size_t __pos1_32 = __pos1 * 4;
size_t __i;
for (__i = 0; __i < _M_nstate32 - __pos1_32; __i += 4)
{
__recursion<__sl1, __sl2, __sr1, __sr2,
__msk1, __msk2, __msk3, __msk4>
(&_M_state32[__i], &_M_state32[__i],
&_M_state32[__i + __pos1_32], __r1, __r2);
__r1 = __r2;
__r2 = &_M_state32[__i];
}
for (; __i < _M_nstate32; __i += 4)
{
__recursion<__sl1, __sl2, __sr1, __sr2,
__msk1, __msk2, __msk3, __msk4>
(&_M_state32[__i], &_M_state32[__i],
&_M_state32[__i + __pos1_32 - _M_nstate32], __r1, __r2);
__r1 = __r2;
__r2 = &_M_state32[__i];
}
_M_pos = 0;
}
#endif
#ifndef _GLIBCXX_OPT_HAVE_RANDOM_SFMT_OPERATOREQUAL
template<typename _UIntType, size_t __m,
size_t __pos1, size_t __sl1, size_t __sl2,
size_t __sr1, size_t __sr2,
uint32_t __msk1, uint32_t __msk2,
uint32_t __msk3, uint32_t __msk4,
uint32_t __parity1, uint32_t __parity2,
uint32_t __parity3, uint32_t __parity4>
bool
operator==(const __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType,
__m, __pos1, __sl1, __sl2, __sr1, __sr2,
__msk1, __msk2, __msk3, __msk4,
__parity1, __parity2, __parity3, __parity4>& __lhs,
const __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType,
__m, __pos1, __sl1, __sl2, __sr1, __sr2,
__msk1, __msk2, __msk3, __msk4,
__parity1, __parity2, __parity3, __parity4>& __rhs)
{
typedef __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType,
__m, __pos1, __sl1, __sl2, __sr1, __sr2,
__msk1, __msk2, __msk3, __msk4,
__parity1, __parity2, __parity3, __parity4> __engine;
return (std::equal(__lhs._M_stateT,
__lhs._M_stateT + __engine::state_size,
__rhs._M_stateT)
&& __lhs._M_pos == __rhs._M_pos);
}
#endif
template<typename _UIntType, size_t __m,
size_t __pos1, size_t __sl1, size_t __sl2,
size_t __sr1, size_t __sr2,
uint32_t __msk1, uint32_t __msk2,
uint32_t __msk3, uint32_t __msk4,
uint32_t __parity1, uint32_t __parity2,
uint32_t __parity3, uint32_t __parity4,
typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType,
__m, __pos1, __sl1, __sl2, __sr1, __sr2,
__msk1, __msk2, __msk3, __msk4,
__parity1, __parity2, __parity3, __parity4>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::dec | __ios_base::fixed | __ios_base::left);
__os.fill(__space);
for (size_t __i = 0; __i < __x._M_nstate32; ++__i)
__os << __x._M_state32[__i] << __space;
__os << __x._M_pos;
__os.flags(__flags);
__os.fill(__fill);
return __os;
}
template<typename _UIntType, size_t __m,
size_t __pos1, size_t __sl1, size_t __sl2,
size_t __sr1, size_t __sr2,
uint32_t __msk1, uint32_t __msk2,
uint32_t __msk3, uint32_t __msk4,
uint32_t __parity1, uint32_t __parity2,
uint32_t __parity3, uint32_t __parity4,
typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
__gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType,
__m, __pos1, __sl1, __sl2, __sr1, __sr2,
__msk1, __msk2, __msk3, __msk4,
__parity1, __parity2, __parity3, __parity4>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
for (size_t __i = 0; __i < __x._M_nstate32; ++__i)
__is >> __x._M_state32[__i];
__is >> __x._M_pos;
__is.flags(__flags);
return __is;
}
#endif // __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
/**
* Iteration method due to M.D. J<o:>hnk.
*
* M.D. J<o:>hnk, Erzeugung von betaverteilten und gammaverteilten
* Zufallszahlen, Metrika, Volume 8, 1964
*/
template<typename _RealType>
template<typename _UniformRandomNumberGenerator>
typename beta_distribution<_RealType>::result_type
beta_distribution<_RealType>::
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
std::__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
__aurng(__urng);
result_type __x, __y;
do
{
__x = std::exp(std::log(__aurng()) / __param.alpha());
__y = std::exp(std::log(__aurng()) / __param.beta());
}
while (__x + __y > result_type(1));
return __x / (__x + __y);
}
template<typename _RealType>
template<typename _OutputIterator,
typename _UniformRandomNumberGenerator>
void
beta_distribution<_RealType>::
__generate_impl(_OutputIterator __f, _OutputIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
result_type>)
std::__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
__aurng(__urng);
while (__f != __t)
{
result_type __x, __y;
do
{
__x = std::exp(std::log(__aurng()) / __param.alpha());
__y = std::exp(std::log(__aurng()) / __param.beta());
}
while (__x + __y > result_type(1));
*__f++ = __x / (__x + __y);
}
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const __gnu_cxx::beta_distribution<_RealType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__space);
__os.precision(std::numeric_limits<_RealType>::max_digits10);
__os << __x.alpha() << __space << __x.beta();
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
__gnu_cxx::beta_distribution<_RealType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __alpha_val, __beta_val;
__is >> __alpha_val >> __beta_val;
__x.param(typename __gnu_cxx::beta_distribution<_RealType>::
param_type(__alpha_val, __beta_val));
__is.flags(__flags);
return __is;
}
template<std::size_t _Dimen, typename _RealType>
template<typename _InputIterator1, typename _InputIterator2>
void
normal_mv_distribution<_Dimen, _RealType>::param_type::
_M_init_full(_InputIterator1 __meanbegin, _InputIterator1 __meanend,
_InputIterator2 __varcovbegin, _InputIterator2 __varcovend)
{
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
std::fill(std::copy(__meanbegin, __meanend, _M_mean.begin()),
_M_mean.end(), _RealType(0));
// Perform the Cholesky decomposition
auto __w = _M_t.begin();
for (size_t __j = 0; __j < _Dimen; ++__j)
{
_RealType __sum = _RealType(0);
auto __slitbegin = __w;
auto __cit = _M_t.begin();
for (size_t __i = 0; __i < __j; ++__i)
{
auto __slit = __slitbegin;
_RealType __s = *__varcovbegin++;
for (size_t __k = 0; __k < __i; ++__k)
__s -= *__slit++ * *__cit++;
*__w++ = __s /= *__cit++;
__sum += __s * __s;
}
__sum = *__varcovbegin - __sum;
if (__builtin_expect(__sum <= _RealType(0), 0))
std::__throw_runtime_error(__N("normal_mv_distribution::"
"param_type::_M_init_full"));
*__w++ = std::sqrt(__sum);
std::advance(__varcovbegin, _Dimen - __j);
}
}
template<std::size_t _Dimen, typename _RealType>
template<typename _InputIterator1, typename _InputIterator2>
void
normal_mv_distribution<_Dimen, _RealType>::param_type::
_M_init_lower(_InputIterator1 __meanbegin, _InputIterator1 __meanend,
_InputIterator2 __varcovbegin, _InputIterator2 __varcovend)
{
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
std::fill(std::copy(__meanbegin, __meanend, _M_mean.begin()),
_M_mean.end(), _RealType(0));
// Perform the Cholesky decomposition
auto __w = _M_t.begin();
for (size_t __j = 0; __j < _Dimen; ++__j)
{
_RealType __sum = _RealType(0);
auto __slitbegin = __w;
auto __cit = _M_t.begin();
for (size_t __i = 0; __i < __j; ++__i)
{
auto __slit = __slitbegin;
_RealType __s = *__varcovbegin++;
for (size_t __k = 0; __k < __i; ++__k)
__s -= *__slit++ * *__cit++;
*__w++ = __s /= *__cit++;
__sum += __s * __s;
}
__sum = *__varcovbegin++ - __sum;
if (__builtin_expect(__sum <= _RealType(0), 0))
std::__throw_runtime_error(__N("normal_mv_distribution::"
"param_type::_M_init_full"));
*__w++ = std::sqrt(__sum);
}
}
template<std::size_t _Dimen, typename _RealType>
template<typename _InputIterator1, typename _InputIterator2>
void
normal_mv_distribution<_Dimen, _RealType>::param_type::
_M_init_diagonal(_InputIterator1 __meanbegin, _InputIterator1 __meanend,
_InputIterator2 __varbegin, _InputIterator2 __varend)
{
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
std::fill(std::copy(__meanbegin, __meanend, _M_mean.begin()),
_M_mean.end(), _RealType(0));
auto __w = _M_t.begin();
size_t __step = 0;
while (__varbegin != __varend)
{
std::fill_n(__w, __step, _RealType(0));
__w += __step++;
if (__builtin_expect(*__varbegin < _RealType(0), 0))
std::__throw_runtime_error(__N("normal_mv_distribution::"
"param_type::_M_init_diagonal"));
*__w++ = std::sqrt(*__varbegin++);
}
}
template<std::size_t _Dimen, typename _RealType>
template<typename _UniformRandomNumberGenerator>
typename normal_mv_distribution<_Dimen, _RealType>::result_type
normal_mv_distribution<_Dimen, _RealType>::
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
result_type __ret;
_M_nd.__generate(__ret.begin(), __ret.end(), __urng);
auto __t_it = __param._M_t.crbegin();
for (size_t __i = _Dimen; __i > 0; --__i)
{
_RealType __sum = _RealType(0);
for (size_t __j = __i; __j > 0; --__j)
__sum += __ret[__j - 1] * *__t_it++;
__ret[__i - 1] = __sum;
}
return __ret;
}
template<std::size_t _Dimen, typename _RealType>
template<typename _ForwardIterator, typename _UniformRandomNumberGenerator>
void
normal_mv_distribution<_Dimen, _RealType>::
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
__glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
_ForwardIterator>)
while (__f != __t)
*__f++ = this->operator()(__urng, __param);
}
template<size_t _Dimen, typename _RealType>
bool
operator==(const __gnu_cxx::normal_mv_distribution<_Dimen, _RealType>&
__d1,
const __gnu_cxx::normal_mv_distribution<_Dimen, _RealType>&
__d2)
{
return __d1._M_param == __d2._M_param && __d1._M_nd == __d2._M_nd;
}
template<size_t _Dimen, typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const __gnu_cxx::normal_mv_distribution<_Dimen, _RealType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__space);
__os.precision(std::numeric_limits<_RealType>::max_digits10);
auto __mean = __x._M_param.mean();
for (auto __it : __mean)
__os << __it << __space;
auto __t = __x._M_param.varcov();
for (auto __it : __t)
__os << __it << __space;
__os << __x._M_nd;
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
template<size_t _Dimen, typename _RealType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
__gnu_cxx::normal_mv_distribution<_Dimen, _RealType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
std::array<_RealType, _Dimen> __mean;
for (auto& __it : __mean)
__is >> __it;
std::array<_RealType, _Dimen * (_Dimen + 1) / 2> __varcov;
for (auto& __it : __varcov)
__is >> __it;
__is >> __x._M_nd;
__x.param(typename normal_mv_distribution<_Dimen, _RealType>::
param_type(__mean.begin(), __mean.end(),
__varcov.begin(), __varcov.end()));
__is.flags(__flags);
return __is;
}
template<typename _RealType>
template<typename _OutputIterator,
typename _UniformRandomNumberGenerator>
void
rice_distribution<_RealType>::
__generate_impl(_OutputIterator __f, _OutputIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
result_type>)
while (__f != __t)
{
typename std::normal_distribution<result_type>::param_type
__px(__p.nu(), __p.sigma()), __py(result_type(0), __p.sigma());
result_type __x = this->_M_ndx(__px, __urng);
result_type __y = this->_M_ndy(__py, __urng);
#if _GLIBCXX_USE_C99_MATH_TR1
*__f++ = std::hypot(__x, __y);
#else
*__f++ = std::sqrt(__x * __x + __y * __y);
#endif
}
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const rice_distribution<_RealType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__space);
__os.precision(std::numeric_limits<_RealType>::max_digits10);
__os << __x.nu() << __space << __x.sigma();
__os << __space << __x._M_ndx;
__os << __space << __x._M_ndy;
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
rice_distribution<_RealType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __nu_val, __sigma_val;
__is >> __nu_val >> __sigma_val;
__is >> __x._M_ndx;
__is >> __x._M_ndy;
__x.param(typename rice_distribution<_RealType>::
param_type(__nu_val, __sigma_val));
__is.flags(__flags);
return __is;
}
template<typename _RealType>
template<typename _OutputIterator,
typename _UniformRandomNumberGenerator>
void
nakagami_distribution<_RealType>::
__generate_impl(_OutputIterator __f, _OutputIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
result_type>)
typename std::gamma_distribution<result_type>::param_type
__pg(__p.mu(), __p.omega() / __p.mu());
while (__f != __t)
*__f++ = std::sqrt(this->_M_gd(__pg, __urng));
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const nakagami_distribution<_RealType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__space);
__os.precision(std::numeric_limits<_RealType>::max_digits10);
__os << __x.mu() << __space << __x.omega();
__os << __space << __x._M_gd;
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
nakagami_distribution<_RealType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __mu_val, __omega_val;
__is >> __mu_val >> __omega_val;
__is >> __x._M_gd;
__x.param(typename nakagami_distribution<_RealType>::
param_type(__mu_val, __omega_val));
__is.flags(__flags);
return __is;
}
template<typename _RealType>
template<typename _OutputIterator,
typename _UniformRandomNumberGenerator>
void
pareto_distribution<_RealType>::
__generate_impl(_OutputIterator __f, _OutputIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
result_type>)
result_type __mu_val = __p.mu();
result_type __malphinv = -result_type(1) / __p.alpha();
while (__f != __t)
*__f++ = __mu_val * std::pow(this->_M_ud(__urng), __malphinv);
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const pareto_distribution<_RealType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__space);
__os.precision(std::numeric_limits<_RealType>::max_digits10);
__os << __x.alpha() << __space << __x.mu();
__os << __space << __x._M_ud;
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
pareto_distribution<_RealType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __alpha_val, __mu_val;
__is >> __alpha_val >> __mu_val;
__is >> __x._M_ud;
__x.param(typename pareto_distribution<_RealType>::
param_type(__alpha_val, __mu_val));
__is.flags(__flags);
return __is;
}
template<typename _RealType>
template<typename _UniformRandomNumberGenerator>
typename k_distribution<_RealType>::result_type
k_distribution<_RealType>::
operator()(_UniformRandomNumberGenerator& __urng)
{
result_type __x = this->_M_gd1(__urng);
result_type __y = this->_M_gd2(__urng);
return std::sqrt(__x * __y);
}
template<typename _RealType>
template<typename _UniformRandomNumberGenerator>
typename k_distribution<_RealType>::result_type
k_distribution<_RealType>::
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
typename std::gamma_distribution<result_type>::param_type
__p1(__p.lambda(), result_type(1) / __p.lambda()),
__p2(__p.nu(), __p.mu() / __p.nu());
result_type __x = this->_M_gd1(__p1, __urng);
result_type __y = this->_M_gd2(__p2, __urng);
return std::sqrt(__x * __y);
}
template<typename _RealType>
template<typename _OutputIterator,
typename _UniformRandomNumberGenerator>
void
k_distribution<_RealType>::
__generate_impl(_OutputIterator __f, _OutputIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
result_type>)
typename std::gamma_distribution<result_type>::param_type
__p1(__p.lambda(), result_type(1) / __p.lambda()),
__p2(__p.nu(), __p.mu() / __p.nu());
while (__f != __t)
{
result_type __x = this->_M_gd1(__p1, __urng);
result_type __y = this->_M_gd2(__p2, __urng);
*__f++ = std::sqrt(__x * __y);
}
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const k_distribution<_RealType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__space);
__os.precision(std::numeric_limits<_RealType>::max_digits10);
__os << __x.lambda() << __space << __x.mu() << __space << __x.nu();
__os << __space << __x._M_gd1;
__os << __space << __x._M_gd2;
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
k_distribution<_RealType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __lambda_val, __mu_val, __nu_val;
__is >> __lambda_val >> __mu_val >> __nu_val;
__is >> __x._M_gd1;
__is >> __x._M_gd2;
__x.param(typename k_distribution<_RealType>::
param_type(__lambda_val, __mu_val, __nu_val));
__is.flags(__flags);
return __is;
}
template<typename _RealType>
template<typename _OutputIterator,
typename _UniformRandomNumberGenerator>
void
arcsine_distribution<_RealType>::
__generate_impl(_OutputIterator __f, _OutputIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
result_type>)
result_type __dif = __p.b() - __p.a();
result_type __sum = __p.a() + __p.b();
while (__f != __t)
{
result_type __x = std::sin(this->_M_ud(__urng));
*__f++ = (__x * __dif + __sum) / result_type(2);
}
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const arcsine_distribution<_RealType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__space);
__os.precision(std::numeric_limits<_RealType>::max_digits10);
__os << __x.a() << __space << __x.b();
__os << __space << __x._M_ud;
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
arcsine_distribution<_RealType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __a, __b;
__is >> __a >> __b;
__is >> __x._M_ud;
__x.param(typename arcsine_distribution<_RealType>::
param_type(__a, __b));
__is.flags(__flags);
return __is;
}
template<typename _RealType>
template<typename _UniformRandomNumberGenerator>
typename hoyt_distribution<_RealType>::result_type
hoyt_distribution<_RealType>::
operator()(_UniformRandomNumberGenerator& __urng)
{
result_type __x = this->_M_ad(__urng);
result_type __y = this->_M_ed(__urng);
return (result_type(2) * this->q()
/ (result_type(1) + this->q() * this->q()))
* std::sqrt(this->omega() * __x * __y);
}
template<typename _RealType>
template<typename _UniformRandomNumberGenerator>
typename hoyt_distribution<_RealType>::result_type
hoyt_distribution<_RealType>::
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
result_type __q2 = __p.q() * __p.q();
result_type __num = result_type(0.5L) * (result_type(1) + __q2);
typename __gnu_cxx::arcsine_distribution<result_type>::param_type
__pa(__num, __num / __q2);
result_type __x = this->_M_ad(__pa, __urng);
result_type __y = this->_M_ed(__urng);
return (result_type(2) * __p.q() / (result_type(1) + __q2))
* std::sqrt(__p.omega() * __x * __y);
}
template<typename _RealType>
template<typename _OutputIterator,
typename _UniformRandomNumberGenerator>
void
hoyt_distribution<_RealType>::
__generate_impl(_OutputIterator __f, _OutputIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
result_type>)
result_type __2q = result_type(2) * __p.q();
result_type __q2 = __p.q() * __p.q();
result_type __q2p1 = result_type(1) + __q2;
result_type __num = result_type(0.5L) * __q2p1;
result_type __omega = __p.omega();
typename __gnu_cxx::arcsine_distribution<result_type>::param_type
__pa(__num, __num / __q2);
while (__f != __t)
{
result_type __x = this->_M_ad(__pa, __urng);
result_type __y = this->_M_ed(__urng);
*__f++ = (__2q / __q2p1) * std::sqrt(__omega * __x * __y);
}
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const hoyt_distribution<_RealType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__space);
__os.precision(std::numeric_limits<_RealType>::max_digits10);
__os << __x.q() << __space << __x.omega();
__os << __space << __x._M_ad;
__os << __space << __x._M_ed;
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
hoyt_distribution<_RealType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __q, __omega;
__is >> __q >> __omega;
__is >> __x._M_ad;
__is >> __x._M_ed;
__x.param(typename hoyt_distribution<_RealType>::
param_type(__q, __omega));
__is.flags(__flags);
return __is;
}
template<typename _RealType>
template<typename _OutputIterator,
typename _UniformRandomNumberGenerator>
void
triangular_distribution<_RealType>::
__generate_impl(_OutputIterator __f, _OutputIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
result_type>)
while (__f != __t)
*__f++ = this->operator()(__urng, __param);
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const __gnu_cxx::triangular_distribution<_RealType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__space);
__os.precision(std::numeric_limits<_RealType>::max_digits10);
__os << __x.a() << __space << __x.b() << __space << __x.c();
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
__gnu_cxx::triangular_distribution<_RealType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __a, __b, __c;
__is >> __a >> __b >> __c;
__x.param(typename __gnu_cxx::triangular_distribution<_RealType>::
param_type(__a, __b, __c));
__is.flags(__flags);
return __is;
}
template<typename _RealType>
template<typename _UniformRandomNumberGenerator>
typename von_mises_distribution<_RealType>::result_type
von_mises_distribution<_RealType>::
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
const result_type __pi
= __gnu_cxx::__math_constants<result_type>::__pi;
std::__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
__aurng(__urng);
result_type __f;
while (1)
{
result_type __rnd = std::cos(__pi * __aurng());
__f = (result_type(1) + __p._M_r * __rnd) / (__p._M_r + __rnd);
result_type __c = __p._M_kappa * (__p._M_r - __f);
result_type __rnd2 = __aurng();
if (__c * (result_type(2) - __c) > __rnd2)
break;
if (std::log(__c / __rnd2) >= __c - result_type(1))
break;
}
result_type __res = std::acos(__f);
#if _GLIBCXX_USE_C99_MATH_TR1
__res = std::copysign(__res, __aurng() - result_type(0.5));
#else
if (__aurng() < result_type(0.5))
__res = -__res;
#endif
__res += __p._M_mu;
if (__res > __pi)
__res -= result_type(2) * __pi;
else if (__res < -__pi)
__res += result_type(2) * __pi;
return __res;
}
template<typename _RealType>
template<typename _OutputIterator,
typename _UniformRandomNumberGenerator>
void
von_mises_distribution<_RealType>::
__generate_impl(_OutputIterator __f, _OutputIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
result_type>)
while (__f != __t)
*__f++ = this->operator()(__urng, __param);
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const __gnu_cxx::von_mises_distribution<_RealType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__space);
__os.precision(std::numeric_limits<_RealType>::max_digits10);
__os << __x.mu() << __space << __x.kappa();
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
__gnu_cxx::von_mises_distribution<_RealType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __mu, __kappa;
__is >> __mu >> __kappa;
__x.param(typename __gnu_cxx::von_mises_distribution<_RealType>::
param_type(__mu, __kappa));
__is.flags(__flags);
return __is;
}
template<typename _UIntType>
template<typename _UniformRandomNumberGenerator>
typename hypergeometric_distribution<_UIntType>::result_type
hypergeometric_distribution<_UIntType>::
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
std::__detail::_Adaptor<_UniformRandomNumberGenerator, double>
__aurng(__urng);
result_type __a = __param.successful_size();
result_type __b = __param.total_size();
result_type __k = 0;
if (__param.total_draws() < __param.total_size() / 2)
{
for (result_type __i = 0; __i < __param.total_draws(); ++__i)
{
if (__b * __aurng() < __a)
{
++__k;
if (__k == __param.successful_size())
return __k;
--__a;
}
--__b;
}
return __k;
}
else
{
for (result_type __i = 0; __i < __param.unsuccessful_size(); ++__i)
{
if (__b * __aurng() < __a)
{
++__k;
if (__k == __param.successful_size())
return __param.successful_size() - __k;
--__a;
}
--__b;
}
return __param.successful_size() - __k;
}
}
template<typename _UIntType>
template<typename _OutputIterator,
typename _UniformRandomNumberGenerator>
void
hypergeometric_distribution<_UIntType>::
__generate_impl(_OutputIterator __f, _OutputIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
result_type>)
while (__f != __t)
*__f++ = this->operator()(__urng);
}
template<typename _UIntType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const __gnu_cxx::hypergeometric_distribution<_UIntType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__space);
__os.precision(std::numeric_limits<_UIntType>::max_digits10);
__os << __x.total_size() << __space << __x.successful_size() << __space
<< __x.total_draws();
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
template<typename _UIntType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
__gnu_cxx::hypergeometric_distribution<_UIntType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
_UIntType __total_size, __successful_size, __total_draws;
__is >> __total_size >> __successful_size >> __total_draws;
__x.param(typename __gnu_cxx::hypergeometric_distribution<_UIntType>::
param_type(__total_size, __successful_size, __total_draws));
__is.flags(__flags);
return __is;
}
template<typename _RealType>
template<typename _UniformRandomNumberGenerator>
typename logistic_distribution<_RealType>::result_type
logistic_distribution<_RealType>::
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
std::__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
__aurng(__urng);
result_type __arg = result_type(1);
while (__arg == result_type(1) || __arg == result_type(0))
__arg = __aurng();
return __p.a()
+ __p.b() * std::log(__arg / (result_type(1) - __arg));
}
template<typename _RealType>
template<typename _OutputIterator,
typename _UniformRandomNumberGenerator>
void
logistic_distribution<_RealType>::
__generate_impl(_OutputIterator __f, _OutputIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
result_type>)
std::__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
__aurng(__urng);
while (__f != __t)
{
result_type __arg = result_type(1);
while (__arg == result_type(1) || __arg == result_type(0))
__arg = __aurng();
*__f++ = __p.a()
+ __p.b() * std::log(__arg / (result_type(1) - __arg));
}
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const logistic_distribution<_RealType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__space);
__os.precision(std::numeric_limits<_RealType>::max_digits10);
__os << __x.a() << __space << __x.b();
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
logistic_distribution<_RealType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __a, __b;
__is >> __a >> __b;
__x.param(typename logistic_distribution<_RealType>::
param_type(__a, __b));
__is.flags(__flags);
return __is;
}
namespace {
// Helper class for the uniform_on_sphere_distribution generation
// function.
template<std::size_t _Dimen, typename _RealType>
class uniform_on_sphere_helper
{
typedef typename uniform_on_sphere_distribution<_Dimen, _RealType>::
result_type result_type;
public:
template<typename _NormalDistribution,
typename _UniformRandomNumberGenerator>
result_type operator()(_NormalDistribution& __nd,
_UniformRandomNumberGenerator& __urng)
{
result_type __ret;
typename result_type::value_type __norm;
do
{
auto __sum = _RealType(0);
std::generate(__ret.begin(), __ret.end(),
[&__nd, &__urng, &__sum](){
_RealType __t = __nd(__urng);
__sum += __t * __t;
return __t; });
__norm = std::sqrt(__sum);
}
while (__norm == _RealType(0) || ! __builtin_isfinite(__norm));
std::transform(__ret.begin(), __ret.end(), __ret.begin(),
[__norm](_RealType __val){ return __val / __norm; });
return __ret;
}
};
template<typename _RealType>
class uniform_on_sphere_helper<2, _RealType>
{
typedef typename uniform_on_sphere_distribution<2, _RealType>::
result_type result_type;
public:
template<typename _NormalDistribution,
typename _UniformRandomNumberGenerator>
result_type operator()(_NormalDistribution&,
_UniformRandomNumberGenerator& __urng)
{
result_type __ret;
_RealType __sq;
std::__detail::_Adaptor<_UniformRandomNumberGenerator,
_RealType> __aurng(__urng);
do
{
__ret[0] = _RealType(2) * __aurng() - _RealType(1);
__ret[1] = _RealType(2) * __aurng() - _RealType(1);
__sq = __ret[0] * __ret[0] + __ret[1] * __ret[1];
}
while (__sq == _RealType(0) || __sq > _RealType(1));
#if _GLIBCXX_USE_C99_MATH_TR1
// Yes, we do not just use sqrt(__sq) because hypot() is more
// accurate.
auto __norm = std::hypot(__ret[0], __ret[1]);
#else
auto __norm = std::sqrt(__sq);
#endif
__ret[0] /= __norm;
__ret[1] /= __norm;
return __ret;
}
};
}
template<std::size_t _Dimen, typename _RealType>
template<typename _UniformRandomNumberGenerator>
typename uniform_on_sphere_distribution<_Dimen, _RealType>::result_type
uniform_on_sphere_distribution<_Dimen, _RealType>::
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
uniform_on_sphere_helper<_Dimen, _RealType> __helper;
return __helper(_M_nd, __urng);
}
template<std::size_t _Dimen, typename _RealType>
template<typename _OutputIterator,
typename _UniformRandomNumberGenerator>
void
uniform_on_sphere_distribution<_Dimen, _RealType>::
__generate_impl(_OutputIterator __f, _OutputIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
result_type>)
while (__f != __t)
*__f++ = this->operator()(__urng, __param);
}
template<std::size_t _Dimen, typename _RealType, typename _CharT,
typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const __gnu_cxx::uniform_on_sphere_distribution<_Dimen,
_RealType>& __x)
{
return __os << __x._M_nd;
}
template<std::size_t _Dimen, typename _RealType, typename _CharT,
typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
__gnu_cxx::uniform_on_sphere_distribution<_Dimen,
_RealType>& __x)
{
return __is >> __x._M_nd;
}
namespace {
// Helper class for the uniform_inside_sphere_distribution generation
// function.
template<std::size_t _Dimen, bool _SmallDimen, typename _RealType>
class uniform_inside_sphere_helper;
template<std::size_t _Dimen, typename _RealType>
class uniform_inside_sphere_helper<_Dimen, false, _RealType>
{
using result_type
= typename uniform_inside_sphere_distribution<_Dimen, _RealType>::
result_type;
public:
template<typename _UniformOnSphereDistribution,
typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformOnSphereDistribution& __uosd,
_UniformRandomNumberGenerator& __urng,
_RealType __radius)
{
std::__detail::_Adaptor<_UniformRandomNumberGenerator,
_RealType> __aurng(__urng);
_RealType __pow = 1 / _RealType(_Dimen);
_RealType __urt = __radius * std::pow(__aurng(), __pow);
result_type __ret = __uosd(__aurng);
std::transform(__ret.begin(), __ret.end(), __ret.begin(),
[__urt](_RealType __val)
{ return __val * __urt; });
return __ret;
}
};
// Helper class for the uniform_inside_sphere_distribution generation
// function specialized for small dimensions.
template<std::size_t _Dimen, typename _RealType>
class uniform_inside_sphere_helper<_Dimen, true, _RealType>
{
using result_type
= typename uniform_inside_sphere_distribution<_Dimen, _RealType>::
result_type;
public:
template<typename _UniformOnSphereDistribution,
typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformOnSphereDistribution&,
_UniformRandomNumberGenerator& __urng,
_RealType __radius)
{
result_type __ret;
_RealType __sq;
_RealType __radsq = __radius * __radius;
std::__detail::_Adaptor<_UniformRandomNumberGenerator,
_RealType> __aurng(__urng);
do
{
__sq = _RealType(0);
for (int i = 0; i < _Dimen; ++i)
{
__ret[i] = _RealType(2) * __aurng() - _RealType(1);
__sq += __ret[i] * __ret[i];
}
}
while (__sq > _RealType(1));
for (int i = 0; i < _Dimen; ++i)
__ret[i] *= __radius;
return __ret;
}
};
} // namespace
//
// Experiments have shown that rejection is more efficient than transform
// for dimensions less than 8.
//
template<std::size_t _Dimen, typename _RealType>
template<typename _UniformRandomNumberGenerator>
typename uniform_inside_sphere_distribution<_Dimen, _RealType>::result_type
uniform_inside_sphere_distribution<_Dimen, _RealType>::
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
uniform_inside_sphere_helper<_Dimen, _Dimen < 8, _RealType> __helper;
return __helper(_M_uosd, __urng, __p.radius());
}
template<std::size_t _Dimen, typename _RealType>
template<typename _OutputIterator,
typename _UniformRandomNumberGenerator>
void
uniform_inside_sphere_distribution<_Dimen, _RealType>::
__generate_impl(_OutputIterator __f, _OutputIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
result_type>)
while (__f != __t)
*__f++ = this->operator()(__urng, __param);
}
template<std::size_t _Dimen, typename _RealType, typename _CharT,
typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const __gnu_cxx::uniform_inside_sphere_distribution<_Dimen,
_RealType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__space);
__os.precision(std::numeric_limits<_RealType>::max_digits10);
__os << __x.radius() << __space << __x._M_uosd;
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
template<std::size_t _Dimen, typename _RealType, typename _CharT,
typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
__gnu_cxx::uniform_inside_sphere_distribution<_Dimen,
_RealType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __radius_val;
__is >> __radius_val >> __x._M_uosd;
__x.param(typename uniform_inside_sphere_distribution<_Dimen, _RealType>::
param_type(__radius_val));
__is.flags(__flags);
return __is;
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace __gnu_cxx
#endif // _EXT_RANDOM_TCC
c++/8/ext/hash_map 0000644 00000042557 15201526705 0007606 0 ustar 00 // Hashing map implementation -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
* Copyright (c) 1996
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*/
/** @file backward/hash_map
* This file is a GNU extension to the Standard C++ Library (possibly
* containing extensions from the HP/SGI STL subset).
*/
#ifndef _BACKWARD_HASH_MAP
#define _BACKWARD_HASH_MAP 1
#ifndef _GLIBCXX_PERMIT_BACKWARD_HASH
#include "backward_warning.h"
#endif
#include <bits/c++config.h>
#include <backward/hashtable.h>
#include <bits/concept_check.h>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using std::equal_to;
using std::allocator;
using std::pair;
using std::_Select1st;
/**
* This is an SGI extension.
* @ingroup SGIextensions
* @doctodo
*/
template<class _Key, class _Tp, class _HashFn = hash<_Key>,
class _EqualKey = equal_to<_Key>, class _Alloc = allocator<_Tp> >
class hash_map
{
private:
typedef hashtable<pair<const _Key, _Tp>,_Key, _HashFn,
_Select1st<pair<const _Key, _Tp> >,
_EqualKey, _Alloc> _Ht;
_Ht _M_ht;
public:
typedef typename _Ht::key_type key_type;
typedef _Tp data_type;
typedef _Tp mapped_type;
typedef typename _Ht::value_type value_type;
typedef typename _Ht::hasher hasher;
typedef typename _Ht::key_equal key_equal;
typedef typename _Ht::size_type size_type;
typedef typename _Ht::difference_type difference_type;
typedef typename _Ht::pointer pointer;
typedef typename _Ht::const_pointer const_pointer;
typedef typename _Ht::reference reference;
typedef typename _Ht::const_reference const_reference;
typedef typename _Ht::iterator iterator;
typedef typename _Ht::const_iterator const_iterator;
typedef typename _Ht::allocator_type allocator_type;
hasher
hash_funct() const
{ return _M_ht.hash_funct(); }
key_equal
key_eq() const
{ return _M_ht.key_eq(); }
allocator_type
get_allocator() const
{ return _M_ht.get_allocator(); }
hash_map()
: _M_ht(100, hasher(), key_equal(), allocator_type()) {}
explicit
hash_map(size_type __n)
: _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
hash_map(size_type __n, const hasher& __hf)
: _M_ht(__n, __hf, key_equal(), allocator_type()) {}
hash_map(size_type __n, const hasher& __hf, const key_equal& __eql,
const allocator_type& __a = allocator_type())
: _M_ht(__n, __hf, __eql, __a) {}
template<class _InputIterator>
hash_map(_InputIterator __f, _InputIterator __l)
: _M_ht(100, hasher(), key_equal(), allocator_type())
{ _M_ht.insert_unique(__f, __l); }
template<class _InputIterator>
hash_map(_InputIterator __f, _InputIterator __l, size_type __n)
: _M_ht(__n, hasher(), key_equal(), allocator_type())
{ _M_ht.insert_unique(__f, __l); }
template<class _InputIterator>
hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf)
: _M_ht(__n, __hf, key_equal(), allocator_type())
{ _M_ht.insert_unique(__f, __l); }
template<class _InputIterator>
hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf, const key_equal& __eql,
const allocator_type& __a = allocator_type())
: _M_ht(__n, __hf, __eql, __a)
{ _M_ht.insert_unique(__f, __l); }
size_type
size() const
{ return _M_ht.size(); }
size_type
max_size() const
{ return _M_ht.max_size(); }
bool
empty() const
{ return _M_ht.empty(); }
void
swap(hash_map& __hs)
{ _M_ht.swap(__hs._M_ht); }
template<class _K1, class _T1, class _HF, class _EqK, class _Al>
friend bool
operator== (const hash_map<_K1, _T1, _HF, _EqK, _Al>&,
const hash_map<_K1, _T1, _HF, _EqK, _Al>&);
iterator
begin()
{ return _M_ht.begin(); }
iterator
end()
{ return _M_ht.end(); }
const_iterator
begin() const
{ return _M_ht.begin(); }
const_iterator
end() const
{ return _M_ht.end(); }
pair<iterator, bool>
insert(const value_type& __obj)
{ return _M_ht.insert_unique(__obj); }
template<class _InputIterator>
void
insert(_InputIterator __f, _InputIterator __l)
{ _M_ht.insert_unique(__f, __l); }
pair<iterator, bool>
insert_noresize(const value_type& __obj)
{ return _M_ht.insert_unique_noresize(__obj); }
iterator
find(const key_type& __key)
{ return _M_ht.find(__key); }
const_iterator
find(const key_type& __key) const
{ return _M_ht.find(__key); }
_Tp&
operator[](const key_type& __key)
{ return _M_ht.find_or_insert(value_type(__key, _Tp())).second; }
size_type
count(const key_type& __key) const
{ return _M_ht.count(__key); }
pair<iterator, iterator>
equal_range(const key_type& __key)
{ return _M_ht.equal_range(__key); }
pair<const_iterator, const_iterator>
equal_range(const key_type& __key) const
{ return _M_ht.equal_range(__key); }
size_type
erase(const key_type& __key)
{return _M_ht.erase(__key); }
void
erase(iterator __it)
{ _M_ht.erase(__it); }
void
erase(iterator __f, iterator __l)
{ _M_ht.erase(__f, __l); }
void
clear()
{ _M_ht.clear(); }
void
resize(size_type __hint)
{ _M_ht.resize(__hint); }
size_type
bucket_count() const
{ return _M_ht.bucket_count(); }
size_type
max_bucket_count() const
{ return _M_ht.max_bucket_count(); }
size_type
elems_in_bucket(size_type __n) const
{ return _M_ht.elems_in_bucket(__n); }
};
template<class _Key, class _Tp, class _HashFn, class _EqlKey, class _Alloc>
inline bool
operator==(const hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm1,
const hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm2)
{ return __hm1._M_ht == __hm2._M_ht; }
template<class _Key, class _Tp, class _HashFn, class _EqlKey, class _Alloc>
inline bool
operator!=(const hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm1,
const hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm2)
{ return !(__hm1 == __hm2); }
template<class _Key, class _Tp, class _HashFn, class _EqlKey, class _Alloc>
inline void
swap(hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm1,
hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm2)
{ __hm1.swap(__hm2); }
/**
* This is an SGI extension.
* @ingroup SGIextensions
* @doctodo
*/
template<class _Key, class _Tp,
class _HashFn = hash<_Key>,
class _EqualKey = equal_to<_Key>,
class _Alloc = allocator<_Tp> >
class hash_multimap
{
// concept requirements
__glibcxx_class_requires(_Key, _SGIAssignableConcept)
__glibcxx_class_requires(_Tp, _SGIAssignableConcept)
__glibcxx_class_requires3(_HashFn, size_t, _Key, _UnaryFunctionConcept)
__glibcxx_class_requires3(_EqualKey, _Key, _Key, _BinaryPredicateConcept)
private:
typedef hashtable<pair<const _Key, _Tp>, _Key, _HashFn,
_Select1st<pair<const _Key, _Tp> >, _EqualKey, _Alloc>
_Ht;
_Ht _M_ht;
public:
typedef typename _Ht::key_type key_type;
typedef _Tp data_type;
typedef _Tp mapped_type;
typedef typename _Ht::value_type value_type;
typedef typename _Ht::hasher hasher;
typedef typename _Ht::key_equal key_equal;
typedef typename _Ht::size_type size_type;
typedef typename _Ht::difference_type difference_type;
typedef typename _Ht::pointer pointer;
typedef typename _Ht::const_pointer const_pointer;
typedef typename _Ht::reference reference;
typedef typename _Ht::const_reference const_reference;
typedef typename _Ht::iterator iterator;
typedef typename _Ht::const_iterator const_iterator;
typedef typename _Ht::allocator_type allocator_type;
hasher
hash_funct() const
{ return _M_ht.hash_funct(); }
key_equal
key_eq() const
{ return _M_ht.key_eq(); }
allocator_type
get_allocator() const
{ return _M_ht.get_allocator(); }
hash_multimap()
: _M_ht(100, hasher(), key_equal(), allocator_type()) {}
explicit
hash_multimap(size_type __n)
: _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
hash_multimap(size_type __n, const hasher& __hf)
: _M_ht(__n, __hf, key_equal(), allocator_type()) {}
hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql,
const allocator_type& __a = allocator_type())
: _M_ht(__n, __hf, __eql, __a) {}
template<class _InputIterator>
hash_multimap(_InputIterator __f, _InputIterator __l)
: _M_ht(100, hasher(), key_equal(), allocator_type())
{ _M_ht.insert_equal(__f, __l); }
template<class _InputIterator>
hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n)
: _M_ht(__n, hasher(), key_equal(), allocator_type())
{ _M_ht.insert_equal(__f, __l); }
template<class _InputIterator>
hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf)
: _M_ht(__n, __hf, key_equal(), allocator_type())
{ _M_ht.insert_equal(__f, __l); }
template<class _InputIterator>
hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf, const key_equal& __eql,
const allocator_type& __a = allocator_type())
: _M_ht(__n, __hf, __eql, __a)
{ _M_ht.insert_equal(__f, __l); }
size_type
size() const
{ return _M_ht.size(); }
size_type
max_size() const
{ return _M_ht.max_size(); }
bool
empty() const
{ return _M_ht.empty(); }
void
swap(hash_multimap& __hs)
{ _M_ht.swap(__hs._M_ht); }
template<class _K1, class _T1, class _HF, class _EqK, class _Al>
friend bool
operator==(const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&,
const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&);
iterator
begin()
{ return _M_ht.begin(); }
iterator
end()
{ return _M_ht.end(); }
const_iterator
begin() const
{ return _M_ht.begin(); }
const_iterator
end() const
{ return _M_ht.end(); }
iterator
insert(const value_type& __obj)
{ return _M_ht.insert_equal(__obj); }
template<class _InputIterator>
void
insert(_InputIterator __f, _InputIterator __l)
{ _M_ht.insert_equal(__f,__l); }
iterator
insert_noresize(const value_type& __obj)
{ return _M_ht.insert_equal_noresize(__obj); }
iterator
find(const key_type& __key)
{ return _M_ht.find(__key); }
const_iterator
find(const key_type& __key) const
{ return _M_ht.find(__key); }
size_type
count(const key_type& __key) const
{ return _M_ht.count(__key); }
pair<iterator, iterator>
equal_range(const key_type& __key)
{ return _M_ht.equal_range(__key); }
pair<const_iterator, const_iterator>
equal_range(const key_type& __key) const
{ return _M_ht.equal_range(__key); }
size_type
erase(const key_type& __key)
{ return _M_ht.erase(__key); }
void
erase(iterator __it)
{ _M_ht.erase(__it); }
void
erase(iterator __f, iterator __l)
{ _M_ht.erase(__f, __l); }
void
clear()
{ _M_ht.clear(); }
void
resize(size_type __hint)
{ _M_ht.resize(__hint); }
size_type
bucket_count() const
{ return _M_ht.bucket_count(); }
size_type
max_bucket_count() const
{ return _M_ht.max_bucket_count(); }
size_type
elems_in_bucket(size_type __n) const
{ return _M_ht.elems_in_bucket(__n); }
};
template<class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
inline bool
operator==(const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm1,
const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm2)
{ return __hm1._M_ht == __hm2._M_ht; }
template<class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
inline bool
operator!=(const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm1,
const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm2)
{ return !(__hm1 == __hm2); }
template<class _Key, class _Tp, class _HashFn, class _EqlKey, class _Alloc>
inline void
swap(hash_multimap<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm1,
hash_multimap<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm2)
{ __hm1.swap(__hm2); }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Specialization of insert_iterator so that it will work for hash_map
// and hash_multimap.
template<class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
class insert_iterator<__gnu_cxx::hash_map<_Key, _Tp, _HashFn,
_EqKey, _Alloc> >
{
protected:
typedef __gnu_cxx::hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>
_Container;
_Container* container;
public:
typedef _Container container_type;
typedef output_iterator_tag iterator_category;
typedef void value_type;
typedef void difference_type;
typedef void pointer;
typedef void reference;
insert_iterator(_Container& __x)
: container(&__x) {}
insert_iterator(_Container& __x, typename _Container::iterator)
: container(&__x) {}
insert_iterator<_Container>&
operator=(const typename _Container::value_type& __value)
{
container->insert(__value);
return *this;
}
insert_iterator<_Container>&
operator*()
{ return *this; }
insert_iterator<_Container>&
operator++() { return *this; }
insert_iterator<_Container>&
operator++(int)
{ return *this; }
};
template<class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
class insert_iterator<__gnu_cxx::hash_multimap<_Key, _Tp, _HashFn,
_EqKey, _Alloc> >
{
protected:
typedef __gnu_cxx::hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc>
_Container;
_Container* container;
typename _Container::iterator iter;
public:
typedef _Container container_type;
typedef output_iterator_tag iterator_category;
typedef void value_type;
typedef void difference_type;
typedef void pointer;
typedef void reference;
insert_iterator(_Container& __x)
: container(&__x) {}
insert_iterator(_Container& __x, typename _Container::iterator)
: container(&__x) {}
insert_iterator<_Container>&
operator=(const typename _Container::value_type& __value)
{
container->insert(__value);
return *this;
}
insert_iterator<_Container>&
operator*()
{ return *this; }
insert_iterator<_Container>&
operator++()
{ return *this; }
insert_iterator<_Container>&
operator++(int)
{ return *this; }
};
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/ext/extptr_allocator.h 0000644 00000014055 15201526705 0011632 0 ustar 00 // <extptr_allocator.h> -*- C++ -*-
// Copyright (C) 2008-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/**
* @file ext/extptr_allocator.h
* This file is a GNU extension to the Standard C++ Library.
*
* @author Bob Walters
*
* An example allocator which uses an alternative pointer type from
* bits/pointer.h. Supports test cases which confirm container support
* for alternative pointers.
*/
#ifndef _EXTPTR_ALLOCATOR_H
#define _EXTPTR_ALLOCATOR_H 1
#include <memory>
#include <ext/numeric_traits.h>
#include <ext/pointer.h>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @brief An example allocator which uses a non-standard pointer type.
* @ingroup allocators
*
* This allocator specifies that containers use a 'relative pointer' as it's
* pointer type. (See ext/pointer.h) Memory allocation in this example
* is still performed using std::allocator.
*/
template<typename _Tp>
class _ExtPtr_allocator
{
public:
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
// Note the non-standard pointer types.
typedef _Pointer_adapter<_Relative_pointer_impl<_Tp> > pointer;
typedef _Pointer_adapter<_Relative_pointer_impl<const _Tp> >
const_pointer;
typedef _Tp& reference;
typedef const _Tp& const_reference;
typedef _Tp value_type;
template<typename _Up>
struct rebind
{ typedef _ExtPtr_allocator<_Up> other; };
_ExtPtr_allocator() _GLIBCXX_USE_NOEXCEPT
: _M_real_alloc() { }
_ExtPtr_allocator(const _ExtPtr_allocator& __rarg) _GLIBCXX_USE_NOEXCEPT
: _M_real_alloc(__rarg._M_real_alloc) { }
template<typename _Up>
_ExtPtr_allocator(const _ExtPtr_allocator<_Up>& __rarg)
_GLIBCXX_USE_NOEXCEPT
: _M_real_alloc(__rarg._M_getUnderlyingImp()) { }
~_ExtPtr_allocator() _GLIBCXX_USE_NOEXCEPT
{ }
pointer address(reference __x) const _GLIBCXX_NOEXCEPT
{ return std::__addressof(__x); }
const_pointer address(const_reference __x) const _GLIBCXX_NOEXCEPT
{ return std::__addressof(__x); }
pointer allocate(size_type __n, void* __hint = 0)
{ return _M_real_alloc.allocate(__n,__hint); }
void deallocate(pointer __p, size_type __n)
{ _M_real_alloc.deallocate(__p.get(), __n); }
size_type max_size() const _GLIBCXX_USE_NOEXCEPT
{ return __numeric_traits<size_type>::__max / sizeof(_Tp); }
#if __cplusplus >= 201103L
template<typename _Up, typename... _Args>
void
construct(_Up* __p, _Args&&... __args)
{ ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
template<typename... _Args>
void
construct(pointer __p, _Args&&... __args)
{ construct(__p.get(), std::forward<_Args>(__args)...); }
template<typename _Up>
void
destroy(_Up* __p)
{ __p->~_Up(); }
void destroy(pointer __p)
{ destroy(__p.get()); }
#else
void construct(pointer __p, const _Tp& __val)
{ ::new(__p.get()) _Tp(__val); }
void destroy(pointer __p)
{ __p->~_Tp(); }
#endif
template<typename _Up>
inline bool
operator==(const _ExtPtr_allocator<_Up>& __rarg)
{ return _M_real_alloc == __rarg._M_getUnderlyingImp(); }
inline bool
operator==(const _ExtPtr_allocator& __rarg)
{ return _M_real_alloc == __rarg._M_real_alloc; }
template<typename _Up>
inline bool
operator!=(const _ExtPtr_allocator<_Up>& __rarg)
{ return _M_real_alloc != __rarg._M_getUnderlyingImp(); }
inline bool
operator!=(const _ExtPtr_allocator& __rarg)
{ return _M_real_alloc != __rarg._M_real_alloc; }
template<typename _Up>
inline friend void
swap(_ExtPtr_allocator<_Up>&, _ExtPtr_allocator<_Up>&);
// A method specific to this implementation.
const std::allocator<_Tp>&
_M_getUnderlyingImp() const
{ return _M_real_alloc; }
private:
std::allocator<_Tp> _M_real_alloc;
};
// _ExtPtr_allocator<void> specialization.
template<>
class _ExtPtr_allocator<void>
{
public:
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef void value_type;
// Note the non-standard pointer types
typedef _Pointer_adapter<_Relative_pointer_impl<void> > pointer;
typedef _Pointer_adapter<_Relative_pointer_impl<const void> >
const_pointer;
template<typename _Up>
struct rebind
{ typedef _ExtPtr_allocator<_Up> other; };
private:
std::allocator<void> _M_real_alloc;
};
template<typename _Tp>
inline void
swap(_ExtPtr_allocator<_Tp>& __larg, _ExtPtr_allocator<_Tp>& __rarg)
{
std::allocator<_Tp> __tmp( __rarg._M_real_alloc );
__rarg._M_real_alloc = __larg._M_real_alloc;
__larg._M_real_alloc = __tmp;
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif /* _EXTPTR_ALLOCATOR_H */
c++/8/ext/string_conversions.h 0000644 00000007015 15201526705 0012200 0 ustar 00 // String Conversions -*- C++ -*-
// Copyright (C) 2008-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file ext/string_conversions.h
* This file is a GNU extension to the Standard C++ Library.
*/
#ifndef _STRING_CONVERSIONS_H
#define _STRING_CONVERSIONS_H 1
#pragma GCC system_header
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
#include <bits/c++config.h>
#include <ext/numeric_traits.h>
#include <bits/functexcept.h>
#include <cstdlib>
#include <cwchar>
#include <cstdio>
#include <cerrno>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Helper for all the sto* functions.
template<typename _TRet, typename _Ret = _TRet, typename _CharT,
typename... _Base>
_Ret
__stoa(_TRet (*__convf) (const _CharT*, _CharT**, _Base...),
const char* __name, const _CharT* __str, std::size_t* __idx,
_Base... __base)
{
_Ret __ret;
_CharT* __endptr;
struct _Save_errno {
_Save_errno() : _M_errno(errno) { errno = 0; }
~_Save_errno() { if (errno == 0) errno = _M_errno; }
int _M_errno;
} const __save_errno;
struct _Range_chk {
static bool
_S_chk(_TRet, std::false_type) { return false; }
static bool
_S_chk(_TRet __val, std::true_type) // only called when _Ret is int
{
return __val < _TRet(__numeric_traits<int>::__min)
|| __val > _TRet(__numeric_traits<int>::__max);
}
};
const _TRet __tmp = __convf(__str, &__endptr, __base...);
if (__endptr == __str)
std::__throw_invalid_argument(__name);
else if (errno == ERANGE
|| _Range_chk::_S_chk(__tmp, std::is_same<_Ret, int>{}))
std::__throw_out_of_range(__name);
else
__ret = __tmp;
if (__idx)
*__idx = __endptr - __str;
return __ret;
}
// Helper for the to_string / to_wstring functions.
template<typename _String, typename _CharT = typename _String::value_type>
_String
__to_xstring(int (*__convf) (_CharT*, std::size_t, const _CharT*,
__builtin_va_list), std::size_t __n,
const _CharT* __fmt, ...)
{
// XXX Eventually the result should be constructed in-place in
// the __cxx11 string, likely with the help of internal hooks.
_CharT* __s = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
* __n));
__builtin_va_list __args;
__builtin_va_start(__args, __fmt);
const int __len = __convf(__s, __n, __fmt, __args);
__builtin_va_end(__args);
return _String(__s, __s + __len);
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif // C++11
#endif // _STRING_CONVERSIONS_H
c++/8/ext/rb_tree 0000644 00000006357 15201526705 0007446 0 ustar 00 // rb_tree extension -*- C++ -*-
// Copyright (C) 2002-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1996
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file ext/rb_tree
* This file is a GNU extension to the Standard C++ Library (possibly
* containing extensions from the HP/SGI STL subset).
*/
#ifndef _RB_TREE
#define _RB_TREE 1
#pragma GCC system_header
#include <bits/stl_tree.h>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using std::_Rb_tree;
using std::allocator;
// Class rb_tree is not part of the C++ standard. It is provided for
// compatibility with the HP STL.
/**
* This is an SGI extension.
* @ingroup SGIextensions
* @doctodo
*/
template <class _Key, class _Value, class _KeyOfValue, class _Compare,
class _Alloc = allocator<_Value> >
struct rb_tree
: public _Rb_tree<_Key, _Value, _KeyOfValue, _Compare, _Alloc>
{
typedef _Rb_tree<_Key, _Value, _KeyOfValue, _Compare, _Alloc> _Base;
typedef typename _Base::allocator_type allocator_type;
rb_tree(const _Compare& __comp = _Compare(),
const allocator_type& __a = allocator_type())
: _Base(__comp, __a) { }
~rb_tree() { }
};
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/ext/pod_char_traits.h 0000644 00000012664 15201526705 0011415 0 ustar 00 // POD character, std::char_traits specialization -*- C++ -*-
// Copyright (C) 2002-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file ext/pod_char_traits.h
* This file is a GNU extension to the Standard C++ Library.
*/
// Gabriel Dos Reis <gdr@integrable-solutions.net>
// Benjamin Kosnik <bkoz@redhat.com>
#ifndef _POD_CHAR_TRAITS_H
#define _POD_CHAR_TRAITS_H 1
#pragma GCC system_header
#include <string>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// POD character abstraction.
// NB: The char_type parameter is a subset of int_type, as to allow
// int_type to properly hold the full range of char_type values as
// well as EOF.
/// @brief A POD class that serves as a character abstraction class.
template<typename _Value, typename _Int, typename _St = std::mbstate_t>
struct character
{
typedef _Value value_type;
typedef _Int int_type;
typedef _St state_type;
typedef character<_Value, _Int, _St> char_type;
value_type value;
template<typename V2>
static char_type
from(const V2& v)
{
char_type ret = { static_cast<value_type>(v) };
return ret;
}
template<typename V2>
static V2
to(const char_type& c)
{
V2 ret = { static_cast<V2>(c.value) };
return ret;
}
};
template<typename _Value, typename _Int, typename _St>
inline bool
operator==(const character<_Value, _Int, _St>& lhs,
const character<_Value, _Int, _St>& rhs)
{ return lhs.value == rhs.value; }
template<typename _Value, typename _Int, typename _St>
inline bool
operator<(const character<_Value, _Int, _St>& lhs,
const character<_Value, _Int, _St>& rhs)
{ return lhs.value < rhs.value; }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/// char_traits<__gnu_cxx::character> specialization.
template<typename _Value, typename _Int, typename _St>
struct char_traits<__gnu_cxx::character<_Value, _Int, _St> >
{
typedef __gnu_cxx::character<_Value, _Int, _St> char_type;
typedef typename char_type::int_type int_type;
typedef typename char_type::state_type state_type;
typedef fpos<state_type> pos_type;
typedef streamoff off_type;
static void
assign(char_type& __c1, const char_type& __c2)
{ __c1 = __c2; }
static bool
eq(const char_type& __c1, const char_type& __c2)
{ return __c1 == __c2; }
static bool
lt(const char_type& __c1, const char_type& __c2)
{ return __c1 < __c2; }
static int
compare(const char_type* __s1, const char_type* __s2, size_t __n)
{
for (size_t __i = 0; __i < __n; ++__i)
if (!eq(__s1[__i], __s2[__i]))
return lt(__s1[__i], __s2[__i]) ? -1 : 1;
return 0;
}
static size_t
length(const char_type* __s)
{
const char_type* __p = __s;
while (__p->value)
++__p;
return (__p - __s);
}
static const char_type*
find(const char_type* __s, size_t __n, const char_type& __a)
{
for (const char_type* __p = __s; size_t(__p - __s) < __n; ++__p)
if (*__p == __a)
return __p;
return 0;
}
static char_type*
move(char_type* __s1, const char_type* __s2, size_t __n)
{
if (__n == 0)
return __s1;
return static_cast<char_type*>
(__builtin_memmove(__s1, __s2, __n * sizeof(char_type)));
}
static char_type*
copy(char_type* __s1, const char_type* __s2, size_t __n)
{
if (__n == 0)
return __s1;
std::copy(__s2, __s2 + __n, __s1);
return __s1;
}
static char_type*
assign(char_type* __s, size_t __n, char_type __a)
{
std::fill_n(__s, __n, __a);
return __s;
}
static char_type
to_char_type(const int_type& __i)
{ return char_type::template from(__i); }
static int_type
to_int_type(const char_type& __c)
{ return char_type::template to<int_type>(__c); }
static bool
eq_int_type(const int_type& __c1, const int_type& __c2)
{ return __c1 == __c2; }
static int_type
eof()
{
int_type __r = { static_cast<typename __gnu_cxx::__conditional_type
<std::__is_integer<int_type>::__value,
int_type, int>::__type>(-1) };
return __r;
}
static int_type
not_eof(const int_type& __c)
{ return eq_int_type(__c, eof()) ? int_type() : __c; }
};
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/ext/malloc_allocator.h 0000644 00000011736 15201526705 0011556 0 ustar 00 // Allocator that wraps "C" malloc -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file ext/malloc_allocator.h
* This file is a GNU extension to the Standard C++ Library.
*/
#ifndef _MALLOC_ALLOCATOR_H
#define _MALLOC_ALLOCATOR_H 1
#include <cstdlib>
#include <cstddef>
#include <new>
#include <bits/functexcept.h>
#include <bits/move.h>
#if __cplusplus >= 201103L
#include <type_traits>
#endif
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using std::size_t;
using std::ptrdiff_t;
/**
* @brief An allocator that uses malloc.
* @ingroup allocators
*
* This is precisely the allocator defined in the C++ Standard.
* - all allocation calls malloc
* - all deallocation calls free
*/
template<typename _Tp>
class malloc_allocator
{
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef _Tp* pointer;
typedef const _Tp* const_pointer;
typedef _Tp& reference;
typedef const _Tp& const_reference;
typedef _Tp value_type;
template<typename _Tp1>
struct rebind
{ typedef malloc_allocator<_Tp1> other; };
#if __cplusplus >= 201103L
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2103. propagate_on_container_move_assignment
typedef std::true_type propagate_on_container_move_assignment;
#endif
malloc_allocator() _GLIBCXX_USE_NOEXCEPT { }
malloc_allocator(const malloc_allocator&) _GLIBCXX_USE_NOEXCEPT { }
template<typename _Tp1>
malloc_allocator(const malloc_allocator<_Tp1>&)
_GLIBCXX_USE_NOEXCEPT { }
~malloc_allocator() _GLIBCXX_USE_NOEXCEPT { }
pointer
address(reference __x) const _GLIBCXX_NOEXCEPT
{ return std::__addressof(__x); }
const_pointer
address(const_reference __x) const _GLIBCXX_NOEXCEPT
{ return std::__addressof(__x); }
// NB: __n is permitted to be 0. The C++ standard says nothing
// about what the return value is when __n == 0.
pointer
allocate(size_type __n, const void* = 0)
{
if (__n > this->max_size())
std::__throw_bad_alloc();
pointer __ret = 0;
#if __cpp_aligned_new
#if __cplusplus > 201402L && _GLIBCXX_HAVE_ALIGNED_ALLOC
if (alignof(_Tp) > alignof(std::max_align_t))
{
__ret = static_cast<_Tp*>(::aligned_alloc(alignof(_Tp),
__n * sizeof(_Tp)));
}
#else
# define _GLIBCXX_CHECK_MALLOC_RESULT
#endif
#endif
if (!__ret)
__ret = static_cast<_Tp*>(std::malloc(__n * sizeof(_Tp)));
if (!__ret)
std::__throw_bad_alloc();
#ifdef _GLIBCXX_CHECK_MALLOC_RESULT
#undef _GLIBCXX_CHECK_MALLOC_RESULT
if (reinterpret_cast<std::size_t>(__ret) % alignof(_Tp))
{
// Memory returned by malloc is not suitably aligned for _Tp.
deallocate(__ret, __n);
std::__throw_bad_alloc();
}
#endif
return __ret;
}
// __p is not permitted to be a null pointer.
void
deallocate(pointer __p, size_type)
{ std::free(static_cast<void*>(__p)); }
size_type
max_size() const _GLIBCXX_USE_NOEXCEPT
{ return size_t(-1) / sizeof(_Tp); }
#if __cplusplus >= 201103L
template<typename _Up, typename... _Args>
void
construct(_Up* __p, _Args&&... __args)
{ ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
template<typename _Up>
void
destroy(_Up* __p) { __p->~_Up(); }
#else
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 402. wrong new expression in [some_] allocator::construct
void
construct(pointer __p, const _Tp& __val)
{ ::new((void *)__p) value_type(__val); }
void
destroy(pointer __p) { __p->~_Tp(); }
#endif
};
template<typename _Tp>
inline bool
operator==(const malloc_allocator<_Tp>&, const malloc_allocator<_Tp>&)
{ return true; }
template<typename _Tp>
inline bool
operator!=(const malloc_allocator<_Tp>&, const malloc_allocator<_Tp>&)
{ return false; }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/ext/new_allocator.h 0000644 00000011305 15201526705 0011070 0 ustar 00 // Allocator that wraps operator new -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file ext/new_allocator.h
* This file is a GNU extension to the Standard C++ Library.
*/
#ifndef _NEW_ALLOCATOR_H
#define _NEW_ALLOCATOR_H 1
#include <bits/c++config.h>
#include <new>
#include <bits/functexcept.h>
#include <bits/move.h>
#if __cplusplus >= 201103L
#include <type_traits>
#endif
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using std::size_t;
using std::ptrdiff_t;
/**
* @brief An allocator that uses global new, as per [20.4].
* @ingroup allocators
*
* This is precisely the allocator defined in the C++ Standard.
* - all allocation calls operator new
* - all deallocation calls operator delete
*
* @tparam _Tp Type of allocated object.
*/
template<typename _Tp>
class new_allocator
{
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef _Tp* pointer;
typedef const _Tp* const_pointer;
typedef _Tp& reference;
typedef const _Tp& const_reference;
typedef _Tp value_type;
template<typename _Tp1>
struct rebind
{ typedef new_allocator<_Tp1> other; };
#if __cplusplus >= 201103L
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2103. propagate_on_container_move_assignment
typedef std::true_type propagate_on_container_move_assignment;
#endif
new_allocator() _GLIBCXX_USE_NOEXCEPT { }
new_allocator(const new_allocator&) _GLIBCXX_USE_NOEXCEPT { }
template<typename _Tp1>
new_allocator(const new_allocator<_Tp1>&) _GLIBCXX_USE_NOEXCEPT { }
~new_allocator() _GLIBCXX_USE_NOEXCEPT { }
pointer
address(reference __x) const _GLIBCXX_NOEXCEPT
{ return std::__addressof(__x); }
const_pointer
address(const_reference __x) const _GLIBCXX_NOEXCEPT
{ return std::__addressof(__x); }
// NB: __n is permitted to be 0. The C++ standard says nothing
// about what the return value is when __n == 0.
pointer
allocate(size_type __n, const void* = static_cast<const void*>(0))
{
if (__n > this->max_size())
std::__throw_bad_alloc();
#if __cpp_aligned_new
if (alignof(_Tp) > __STDCPP_DEFAULT_NEW_ALIGNMENT__)
{
std::align_val_t __al = std::align_val_t(alignof(_Tp));
return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp), __al));
}
#endif
return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));
}
// __p is not permitted to be a null pointer.
void
deallocate(pointer __p, size_type)
{
#if __cpp_aligned_new
if (alignof(_Tp) > __STDCPP_DEFAULT_NEW_ALIGNMENT__)
{
::operator delete(__p, std::align_val_t(alignof(_Tp)));
return;
}
#endif
::operator delete(__p);
}
size_type
max_size() const _GLIBCXX_USE_NOEXCEPT
{ return size_t(-1) / sizeof(_Tp); }
#if __cplusplus >= 201103L
template<typename _Up, typename... _Args>
void
construct(_Up* __p, _Args&&... __args)
{ ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
template<typename _Up>
void
destroy(_Up* __p) { __p->~_Up(); }
#else
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 402. wrong new expression in [some_] allocator::construct
void
construct(pointer __p, const _Tp& __val)
{ ::new((void *)__p) _Tp(__val); }
void
destroy(pointer __p) { __p->~_Tp(); }
#endif
};
template<typename _Tp>
inline bool
operator==(const new_allocator<_Tp>&, const new_allocator<_Tp>&)
{ return true; }
template<typename _Tp>
inline bool
operator!=(const new_allocator<_Tp>&, const new_allocator<_Tp>&)
{ return false; }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/ext/functional 0000644 00000033724 15201526705 0010164 0 ustar 00 // Functional extensions -*- C++ -*-
// Copyright (C) 2002-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1996
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file ext/functional
* This file is a GNU extension to the Standard C++ Library (possibly
* containing extensions from the HP/SGI STL subset).
*/
#ifndef _EXT_FUNCTIONAL
#define _EXT_FUNCTIONAL 1
#pragma GCC system_header
#include <functional>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using std::size_t;
using std::unary_function;
using std::binary_function;
using std::mem_fun1_t;
using std::const_mem_fun1_t;
using std::mem_fun1_ref_t;
using std::const_mem_fun1_ref_t;
/** The @c identity_element functions are not part of the C++
* standard; SGI provided them as an extension. Its argument is an
* operation, and its return value is the identity element for that
* operation. It is overloaded for addition and multiplication,
* and you can overload it for your own nefarious operations.
*
* @addtogroup SGIextensions
* @{
*/
/// An \link SGIextensions SGI extension \endlink.
template <class _Tp>
inline _Tp
identity_element(std::plus<_Tp>)
{ return _Tp(0); }
/// An \link SGIextensions SGI extension \endlink.
template <class _Tp>
inline _Tp
identity_element(std::multiplies<_Tp>)
{ return _Tp(1); }
/** @} */
/** As an extension to the binders, SGI provided composition functors and
* wrapper functions to aid in their creation. The @c unary_compose
* functor is constructed from two functions/functors, @c f and @c g.
* Calling @c operator() with a single argument @c x returns @c f(g(x)).
* The function @c compose1 takes the two functions and constructs a
* @c unary_compose variable for you.
*
* @c binary_compose is constructed from three functors, @c f, @c g1,
* and @c g2. Its @c operator() returns @c f(g1(x),g2(x)). The function
* compose2 takes f, g1, and g2, and constructs the @c binary_compose
* instance for you. For example, if @c f returns an int, then
* \code
* int answer = (compose2(f,g1,g2))(x);
* \endcode
* is equivalent to
* \code
* int temp1 = g1(x);
* int temp2 = g2(x);
* int answer = f(temp1,temp2);
* \endcode
* But the first form is more compact, and can be passed around as a
* functor to other algorithms.
*
* @addtogroup SGIextensions
* @{
*/
/// An \link SGIextensions SGI extension \endlink.
template <class _Operation1, class _Operation2>
class unary_compose
: public unary_function<typename _Operation2::argument_type,
typename _Operation1::result_type>
{
protected:
_Operation1 _M_fn1;
_Operation2 _M_fn2;
public:
unary_compose(const _Operation1& __x, const _Operation2& __y)
: _M_fn1(__x), _M_fn2(__y) {}
typename _Operation1::result_type
operator()(const typename _Operation2::argument_type& __x) const
{ return _M_fn1(_M_fn2(__x)); }
};
/// An \link SGIextensions SGI extension \endlink.
template <class _Operation1, class _Operation2>
inline unary_compose<_Operation1, _Operation2>
compose1(const _Operation1& __fn1, const _Operation2& __fn2)
{ return unary_compose<_Operation1,_Operation2>(__fn1, __fn2); }
/// An \link SGIextensions SGI extension \endlink.
template <class _Operation1, class _Operation2, class _Operation3>
class binary_compose
: public unary_function<typename _Operation2::argument_type,
typename _Operation1::result_type>
{
protected:
_Operation1 _M_fn1;
_Operation2 _M_fn2;
_Operation3 _M_fn3;
public:
binary_compose(const _Operation1& __x, const _Operation2& __y,
const _Operation3& __z)
: _M_fn1(__x), _M_fn2(__y), _M_fn3(__z) { }
typename _Operation1::result_type
operator()(const typename _Operation2::argument_type& __x) const
{ return _M_fn1(_M_fn2(__x), _M_fn3(__x)); }
};
/// An \link SGIextensions SGI extension \endlink.
template <class _Operation1, class _Operation2, class _Operation3>
inline binary_compose<_Operation1, _Operation2, _Operation3>
compose2(const _Operation1& __fn1, const _Operation2& __fn2,
const _Operation3& __fn3)
{ return binary_compose<_Operation1, _Operation2, _Operation3>
(__fn1, __fn2, __fn3); }
/** @} */
/** As an extension, SGI provided a functor called @c identity. When a
* functor is required but no operations are desired, this can be used as a
* pass-through. Its @c operator() returns its argument unchanged.
*
* @addtogroup SGIextensions
*/
template <class _Tp>
struct identity
: public std::_Identity<_Tp> {};
/** @c select1st and @c select2nd are extensions provided by SGI. Their
* @c operator()s
* take a @c std::pair as an argument, and return either the first member
* or the second member, respectively. They can be used (especially with
* the composition functors) to @a strip data from a sequence before
* performing the remainder of an algorithm.
*
* @addtogroup SGIextensions
* @{
*/
/// An \link SGIextensions SGI extension \endlink.
template <class _Pair>
struct select1st
: public std::_Select1st<_Pair> {};
/// An \link SGIextensions SGI extension \endlink.
template <class _Pair>
struct select2nd
: public std::_Select2nd<_Pair> {};
/** @} */
// extension documented next
template <class _Arg1, class _Arg2>
struct _Project1st : public binary_function<_Arg1, _Arg2, _Arg1>
{
_Arg1
operator()(const _Arg1& __x, const _Arg2&) const
{ return __x; }
};
template <class _Arg1, class _Arg2>
struct _Project2nd : public binary_function<_Arg1, _Arg2, _Arg2>
{
_Arg2
operator()(const _Arg1&, const _Arg2& __y) const
{ return __y; }
};
/** The @c operator() of the @c project1st functor takes two arbitrary
* arguments and returns the first one, while @c project2nd returns the
* second one. They are extensions provided by SGI.
*
* @addtogroup SGIextensions
* @{
*/
/// An \link SGIextensions SGI extension \endlink.
template <class _Arg1, class _Arg2>
struct project1st : public _Project1st<_Arg1, _Arg2> {};
/// An \link SGIextensions SGI extension \endlink.
template <class _Arg1, class _Arg2>
struct project2nd : public _Project2nd<_Arg1, _Arg2> {};
/** @} */
// extension documented next
template <class _Result>
struct _Constant_void_fun
{
typedef _Result result_type;
result_type _M_val;
_Constant_void_fun(const result_type& __v) : _M_val(__v) {}
const result_type&
operator()() const
{ return _M_val; }
};
template <class _Result, class _Argument>
struct _Constant_unary_fun
{
typedef _Argument argument_type;
typedef _Result result_type;
result_type _M_val;
_Constant_unary_fun(const result_type& __v) : _M_val(__v) {}
const result_type&
operator()(const _Argument&) const
{ return _M_val; }
};
template <class _Result, class _Arg1, class _Arg2>
struct _Constant_binary_fun
{
typedef _Arg1 first_argument_type;
typedef _Arg2 second_argument_type;
typedef _Result result_type;
_Result _M_val;
_Constant_binary_fun(const _Result& __v) : _M_val(__v) {}
const result_type&
operator()(const _Arg1&, const _Arg2&) const
{ return _M_val; }
};
/** These three functors are each constructed from a single arbitrary
* variable/value. Later, their @c operator()s completely ignore any
* arguments passed, and return the stored value.
* - @c constant_void_fun's @c operator() takes no arguments
* - @c constant_unary_fun's @c operator() takes one argument (ignored)
* - @c constant_binary_fun's @c operator() takes two arguments (ignored)
*
* The helper creator functions @c constant0, @c constant1, and
* @c constant2 each take a @a result argument and construct variables of
* the appropriate functor type.
*
* @addtogroup SGIextensions
* @{
*/
/// An \link SGIextensions SGI extension \endlink.
template <class _Result>
struct constant_void_fun
: public _Constant_void_fun<_Result>
{
constant_void_fun(const _Result& __v)
: _Constant_void_fun<_Result>(__v) {}
};
/// An \link SGIextensions SGI extension \endlink.
template <class _Result, class _Argument = _Result>
struct constant_unary_fun : public _Constant_unary_fun<_Result, _Argument>
{
constant_unary_fun(const _Result& __v)
: _Constant_unary_fun<_Result, _Argument>(__v) {}
};
/// An \link SGIextensions SGI extension \endlink.
template <class _Result, class _Arg1 = _Result, class _Arg2 = _Arg1>
struct constant_binary_fun
: public _Constant_binary_fun<_Result, _Arg1, _Arg2>
{
constant_binary_fun(const _Result& __v)
: _Constant_binary_fun<_Result, _Arg1, _Arg2>(__v) {}
};
/// An \link SGIextensions SGI extension \endlink.
template <class _Result>
inline constant_void_fun<_Result>
constant0(const _Result& __val)
{ return constant_void_fun<_Result>(__val); }
/// An \link SGIextensions SGI extension \endlink.
template <class _Result>
inline constant_unary_fun<_Result, _Result>
constant1(const _Result& __val)
{ return constant_unary_fun<_Result, _Result>(__val); }
/// An \link SGIextensions SGI extension \endlink.
template <class _Result>
inline constant_binary_fun<_Result,_Result,_Result>
constant2(const _Result& __val)
{ return constant_binary_fun<_Result, _Result, _Result>(__val); }
/** @} */
/** The @c subtractive_rng class is documented on
* <a href="http://www.sgi.com/tech/stl/">SGI's site</a>.
* Note that this code assumes that @c int is 32 bits.
*
* @ingroup SGIextensions
*/
class subtractive_rng
: public unary_function<unsigned int, unsigned int>
{
private:
unsigned int _M_table[55];
size_t _M_index1;
size_t _M_index2;
public:
/// Returns a number less than the argument.
unsigned int
operator()(unsigned int __limit)
{
_M_index1 = (_M_index1 + 1) % 55;
_M_index2 = (_M_index2 + 1) % 55;
_M_table[_M_index1] = _M_table[_M_index1] - _M_table[_M_index2];
return _M_table[_M_index1] % __limit;
}
void
_M_initialize(unsigned int __seed)
{
unsigned int __k = 1;
_M_table[54] = __seed;
size_t __i;
for (__i = 0; __i < 54; __i++)
{
size_t __ii = (21 * (__i + 1) % 55) - 1;
_M_table[__ii] = __k;
__k = __seed - __k;
__seed = _M_table[__ii];
}
for (int __loop = 0; __loop < 4; __loop++)
{
for (__i = 0; __i < 55; __i++)
_M_table[__i] = _M_table[__i] - _M_table[(1 + __i + 30) % 55];
}
_M_index1 = 0;
_M_index2 = 31;
}
/// Ctor allowing you to initialize the seed.
subtractive_rng(unsigned int __seed)
{ _M_initialize(__seed); }
/// Default ctor; initializes its state with some number you don't see.
subtractive_rng()
{ _M_initialize(161803398u); }
};
// Mem_fun adaptor helper functions mem_fun1 and mem_fun1_ref,
// provided for backward compatibility, they are no longer part of
// the C++ standard.
template <class _Ret, class _Tp, class _Arg>
inline mem_fun1_t<_Ret, _Tp, _Arg>
mem_fun1(_Ret (_Tp::*__f)(_Arg))
{ return mem_fun1_t<_Ret, _Tp, _Arg>(__f); }
template <class _Ret, class _Tp, class _Arg>
inline const_mem_fun1_t<_Ret, _Tp, _Arg>
mem_fun1(_Ret (_Tp::*__f)(_Arg) const)
{ return const_mem_fun1_t<_Ret, _Tp, _Arg>(__f); }
template <class _Ret, class _Tp, class _Arg>
inline mem_fun1_ref_t<_Ret, _Tp, _Arg>
mem_fun1_ref(_Ret (_Tp::*__f)(_Arg))
{ return mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); }
template <class _Ret, class _Tp, class _Arg>
inline const_mem_fun1_ref_t<_Ret, _Tp, _Arg>
mem_fun1_ref(_Ret (_Tp::*__f)(_Arg) const)
{ return const_mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/ext/ropeimpl.h 0000644 00000136465 15201526705 0010105 0 ustar 00 // SGI's rope class implementation -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
* Copyright (c) 1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file ropeimpl.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{ext/rope}
*/
#include <cstdio>
#include <ostream>
#include <bits/functexcept.h>
#include <ext/algorithm> // For copy_n and lexicographical_compare_3way
#include <ext/memory> // For uninitialized_copy_n
#include <ext/numeric> // For power
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using std::size_t;
using std::printf;
using std::basic_ostream;
using std::__throw_length_error;
using std::_Destroy;
using std::__uninitialized_fill_n_a;
// Set buf_start, buf_end, and buf_ptr appropriately, filling tmp_buf
// if necessary. Assumes _M_path_end[leaf_index] and leaf_pos are correct.
// Results in a valid buf_ptr if the iterator can be legitimately
// dereferenced.
template <class _CharT, class _Alloc>
void
_Rope_iterator_base<_CharT, _Alloc>::
_S_setbuf(_Rope_iterator_base<_CharT, _Alloc>& __x)
{
const _RopeRep* __leaf = __x._M_path_end[__x._M_leaf_index];
size_t __leaf_pos = __x._M_leaf_pos;
size_t __pos = __x._M_current_pos;
switch(__leaf->_M_tag)
{
case __detail::_S_leaf:
__x._M_buf_start = ((_Rope_RopeLeaf<_CharT, _Alloc>*)__leaf)->_M_data;
__x._M_buf_ptr = __x._M_buf_start + (__pos - __leaf_pos);
__x._M_buf_end = __x._M_buf_start + __leaf->_M_size;
break;
case __detail::_S_function:
case __detail::_S_substringfn:
{
size_t __len = _S_iterator_buf_len;
size_t __buf_start_pos = __leaf_pos;
size_t __leaf_end = __leaf_pos + __leaf->_M_size;
char_producer<_CharT>* __fn = ((_Rope_RopeFunction<_CharT,
_Alloc>*)__leaf)->_M_fn;
if (__buf_start_pos + __len <= __pos)
{
__buf_start_pos = __pos - __len / 4;
if (__buf_start_pos + __len > __leaf_end)
__buf_start_pos = __leaf_end - __len;
}
if (__buf_start_pos + __len > __leaf_end)
__len = __leaf_end - __buf_start_pos;
(*__fn)(__buf_start_pos - __leaf_pos, __len, __x._M_tmp_buf);
__x._M_buf_ptr = __x._M_tmp_buf + (__pos - __buf_start_pos);
__x._M_buf_start = __x._M_tmp_buf;
__x._M_buf_end = __x._M_tmp_buf + __len;
}
break;
default:
break;
}
}
// Set path and buffer inside a rope iterator. We assume that
// pos and root are already set.
template <class _CharT, class _Alloc>
void
_Rope_iterator_base<_CharT, _Alloc>::
_S_setcache(_Rope_iterator_base<_CharT, _Alloc>& __x)
{
const _RopeRep* __path[int(__detail::_S_max_rope_depth) + 1];
const _RopeRep* __curr_rope;
int __curr_depth = -1; /* index into path */
size_t __curr_start_pos = 0;
size_t __pos = __x._M_current_pos;
unsigned char __dirns = 0; // Bit vector marking right turns in the path
if (__pos >= __x._M_root->_M_size)
{
__x._M_buf_ptr = 0;
return;
}
__curr_rope = __x._M_root;
if (0 != __curr_rope->_M_c_string)
{
/* Treat the root as a leaf. */
__x._M_buf_start = __curr_rope->_M_c_string;
__x._M_buf_end = __curr_rope->_M_c_string + __curr_rope->_M_size;
__x._M_buf_ptr = __curr_rope->_M_c_string + __pos;
__x._M_path_end[0] = __curr_rope;
__x._M_leaf_index = 0;
__x._M_leaf_pos = 0;
return;
}
for(;;)
{
++__curr_depth;
__path[__curr_depth] = __curr_rope;
switch(__curr_rope->_M_tag)
{
case __detail::_S_leaf:
case __detail::_S_function:
case __detail::_S_substringfn:
__x._M_leaf_pos = __curr_start_pos;
goto done;
case __detail::_S_concat:
{
_Rope_RopeConcatenation<_CharT, _Alloc>* __c =
(_Rope_RopeConcatenation<_CharT, _Alloc>*)__curr_rope;
_RopeRep* __left = __c->_M_left;
size_t __left_len = __left->_M_size;
__dirns <<= 1;
if (__pos >= __curr_start_pos + __left_len)
{
__dirns |= 1;
__curr_rope = __c->_M_right;
__curr_start_pos += __left_len;
}
else
__curr_rope = __left;
}
break;
}
}
done:
// Copy last section of path into _M_path_end.
{
int __i = -1;
int __j = __curr_depth + 1 - int(_S_path_cache_len);
if (__j < 0) __j = 0;
while (__j <= __curr_depth)
__x._M_path_end[++__i] = __path[__j++];
__x._M_leaf_index = __i;
}
__x._M_path_directions = __dirns;
_S_setbuf(__x);
}
// Specialized version of the above. Assumes that
// the path cache is valid for the previous position.
template <class _CharT, class _Alloc>
void
_Rope_iterator_base<_CharT, _Alloc>::
_S_setcache_for_incr(_Rope_iterator_base<_CharT, _Alloc>& __x)
{
int __current_index = __x._M_leaf_index;
const _RopeRep* __current_node = __x._M_path_end[__current_index];
size_t __len = __current_node->_M_size;
size_t __node_start_pos = __x._M_leaf_pos;
unsigned char __dirns = __x._M_path_directions;
_Rope_RopeConcatenation<_CharT, _Alloc>* __c;
if (__x._M_current_pos - __node_start_pos < __len)
{
/* More stuff in this leaf, we just didn't cache it. */
_S_setbuf(__x);
return;
}
// node_start_pos is starting position of last_node.
while (--__current_index >= 0)
{
if (!(__dirns & 1) /* Path turned left */)
break;
__current_node = __x._M_path_end[__current_index];
__c = (_Rope_RopeConcatenation<_CharT, _Alloc>*)__current_node;
// Otherwise we were in the right child. Thus we should pop
// the concatenation node.
__node_start_pos -= __c->_M_left->_M_size;
__dirns >>= 1;
}
if (__current_index < 0)
{
// We underflowed the cache. Punt.
_S_setcache(__x);
return;
}
__current_node = __x._M_path_end[__current_index];
__c = (_Rope_RopeConcatenation<_CharT, _Alloc>*)__current_node;
// current_node is a concatenation node. We are positioned on the first
// character in its right child.
// node_start_pos is starting position of current_node.
__node_start_pos += __c->_M_left->_M_size;
__current_node = __c->_M_right;
__x._M_path_end[++__current_index] = __current_node;
__dirns |= 1;
while (__detail::_S_concat == __current_node->_M_tag)
{
++__current_index;
if (int(_S_path_cache_len) == __current_index)
{
int __i;
for (__i = 0; __i < int(_S_path_cache_len) - 1; __i++)
__x._M_path_end[__i] = __x._M_path_end[__i+1];
--__current_index;
}
__current_node =
((_Rope_RopeConcatenation<_CharT, _Alloc>*)__current_node)->_M_left;
__x._M_path_end[__current_index] = __current_node;
__dirns <<= 1;
// node_start_pos is unchanged.
}
__x._M_leaf_index = __current_index;
__x._M_leaf_pos = __node_start_pos;
__x._M_path_directions = __dirns;
_S_setbuf(__x);
}
template <class _CharT, class _Alloc>
void
_Rope_iterator_base<_CharT, _Alloc>::
_M_incr(size_t __n)
{
_M_current_pos += __n;
if (0 != _M_buf_ptr)
{
size_t __chars_left = _M_buf_end - _M_buf_ptr;
if (__chars_left > __n)
_M_buf_ptr += __n;
else if (__chars_left == __n)
{
_M_buf_ptr += __n;
_S_setcache_for_incr(*this);
}
else
_M_buf_ptr = 0;
}
}
template <class _CharT, class _Alloc>
void
_Rope_iterator_base<_CharT, _Alloc>::
_M_decr(size_t __n)
{
if (0 != _M_buf_ptr)
{
size_t __chars_left = _M_buf_ptr - _M_buf_start;
if (__chars_left >= __n)
_M_buf_ptr -= __n;
else
_M_buf_ptr = 0;
}
_M_current_pos -= __n;
}
template <class _CharT, class _Alloc>
void
_Rope_iterator<_CharT, _Alloc>::
_M_check()
{
if (_M_root_rope->_M_tree_ptr != this->_M_root)
{
// _Rope was modified. Get things fixed up.
_RopeRep::_S_unref(this->_M_root);
this->_M_root = _M_root_rope->_M_tree_ptr;
_RopeRep::_S_ref(this->_M_root);
this->_M_buf_ptr = 0;
}
}
template <class _CharT, class _Alloc>
inline
_Rope_const_iterator<_CharT, _Alloc>::
_Rope_const_iterator(const _Rope_iterator<_CharT, _Alloc>& __x)
: _Rope_iterator_base<_CharT, _Alloc>(__x)
{ }
template <class _CharT, class _Alloc>
inline
_Rope_iterator<_CharT, _Alloc>::
_Rope_iterator(rope<_CharT, _Alloc>& __r, size_t __pos)
: _Rope_iterator_base<_CharT,_Alloc>(__r._M_tree_ptr, __pos),
_M_root_rope(&__r)
{ _RopeRep::_S_ref(this->_M_root); }
template <class _CharT, class _Alloc>
inline size_t
rope<_CharT, _Alloc>::
_S_char_ptr_len(const _CharT* __s)
{
const _CharT* __p = __s;
while (!_S_is0(*__p))
++__p;
return (__p - __s);
}
#ifndef __GC
template <class _CharT, class _Alloc>
inline void
_Rope_RopeRep<_CharT, _Alloc>::
_M_free_c_string()
{
_CharT* __cstr = _M_c_string;
if (0 != __cstr)
{
size_t __size = this->_M_size + 1;
_Destroy(__cstr, __cstr + __size, _M_get_allocator());
this->_Data_deallocate(__cstr, __size);
}
}
template <class _CharT, class _Alloc>
inline void
_Rope_RopeRep<_CharT, _Alloc>::
_S_free_string(_CharT* __s, size_t __n, allocator_type& __a)
{
if (!_S_is_basic_char_type((_CharT*)0))
_Destroy(__s, __s + __n, __a);
// This has to be a static member, so this gets a bit messy
__a.deallocate(__s,
_Rope_RopeLeaf<_CharT, _Alloc>::_S_rounded_up_size(__n));
}
// There are several reasons for not doing this with virtual destructors
// and a class specific delete operator:
// - A class specific delete operator can't easily get access to
// allocator instances if we need them.
// - Any virtual function would need a 4 or byte vtable pointer;
// this only requires a one byte tag per object.
template <class _CharT, class _Alloc>
void
_Rope_RopeRep<_CharT, _Alloc>::
_M_free_tree()
{
switch(_M_tag)
{
case __detail::_S_leaf:
{
_Rope_RopeLeaf<_CharT, _Alloc>* __l
= (_Rope_RopeLeaf<_CharT, _Alloc>*)this;
__l->_Rope_RopeLeaf<_CharT, _Alloc>::~_Rope_RopeLeaf();
this->_L_deallocate(__l, 1);
break;
}
case __detail::_S_concat:
{
_Rope_RopeConcatenation<_CharT,_Alloc>* __c
= (_Rope_RopeConcatenation<_CharT, _Alloc>*)this;
__c->_Rope_RopeConcatenation<_CharT, _Alloc>::
~_Rope_RopeConcatenation();
this->_C_deallocate(__c, 1);
break;
}
case __detail::_S_function:
{
_Rope_RopeFunction<_CharT, _Alloc>* __f
= (_Rope_RopeFunction<_CharT, _Alloc>*)this;
__f->_Rope_RopeFunction<_CharT, _Alloc>::~_Rope_RopeFunction();
this->_F_deallocate(__f, 1);
break;
}
case __detail::_S_substringfn:
{
_Rope_RopeSubstring<_CharT, _Alloc>* __ss =
(_Rope_RopeSubstring<_CharT, _Alloc>*)this;
__ss->_Rope_RopeSubstring<_CharT, _Alloc>::
~_Rope_RopeSubstring();
this->_S_deallocate(__ss, 1);
break;
}
}
}
#else
template <class _CharT, class _Alloc>
inline void
_Rope_RopeRep<_CharT, _Alloc>::
_S_free_string(const _CharT*, size_t, allocator_type)
{ }
#endif
// Concatenate a C string onto a leaf rope by copying the rope data.
// Used for short ropes.
template <class _CharT, class _Alloc>
typename rope<_CharT, _Alloc>::_RopeLeaf*
rope<_CharT, _Alloc>::
_S_leaf_concat_char_iter(_RopeLeaf* __r, const _CharT* __iter, size_t __len)
{
size_t __old_len = __r->_M_size;
_CharT* __new_data = (_CharT*)
rope::_Data_allocate(_S_rounded_up_size(__old_len + __len));
_RopeLeaf* __result;
uninitialized_copy_n(__r->_M_data, __old_len, __new_data);
uninitialized_copy_n(__iter, __len, __new_data + __old_len);
_S_cond_store_eos(__new_data[__old_len + __len]);
__try
{
__result = _S_new_RopeLeaf(__new_data, __old_len + __len,
__r->_M_get_allocator());
}
__catch(...)
{
_RopeRep::__STL_FREE_STRING(__new_data, __old_len + __len,
__r->_M_get_allocator());
__throw_exception_again;
}
return __result;
}
#ifndef __GC
// As above, but it's OK to clobber original if refcount is 1
template <class _CharT, class _Alloc>
typename rope<_CharT,_Alloc>::_RopeLeaf*
rope<_CharT, _Alloc>::
_S_destr_leaf_concat_char_iter(_RopeLeaf* __r, const _CharT* __iter,
size_t __len)
{
if (__r->_M_ref_count > 1)
return _S_leaf_concat_char_iter(__r, __iter, __len);
size_t __old_len = __r->_M_size;
if (_S_allocated_capacity(__old_len) >= __old_len + __len)
{
// The space has been partially initialized for the standard
// character types. But that doesn't matter for those types.
uninitialized_copy_n(__iter, __len, __r->_M_data + __old_len);
if (_S_is_basic_char_type((_CharT*)0))
_S_cond_store_eos(__r->_M_data[__old_len + __len]);
else if (__r->_M_c_string != __r->_M_data && 0 != __r->_M_c_string)
{
__r->_M_free_c_string();
__r->_M_c_string = 0;
}
__r->_M_size = __old_len + __len;
__r->_M_ref_count = 2;
return __r;
}
else
{
_RopeLeaf* __result = _S_leaf_concat_char_iter(__r, __iter, __len);
return __result;
}
}
#endif
// Assumes left and right are not 0.
// Does not increment (nor decrement on exception) child reference counts.
// Result has ref count 1.
template <class _CharT, class _Alloc>
typename rope<_CharT, _Alloc>::_RopeRep*
rope<_CharT, _Alloc>::
_S_tree_concat(_RopeRep* __left, _RopeRep* __right)
{
_RopeConcatenation* __result = _S_new_RopeConcatenation(__left, __right,
__left->
_M_get_allocator());
size_t __depth = __result->_M_depth;
if (__depth > 20
&& (__result->_M_size < 1000
|| __depth > size_t(__detail::_S_max_rope_depth)))
{
_RopeRep* __balanced;
__try
{
__balanced = _S_balance(__result);
__result->_M_unref_nonnil();
}
__catch(...)
{
rope::_C_deallocate(__result,1);
__throw_exception_again;
}
// In case of exception, we need to deallocate
// otherwise dangling result node. But caller
// still owns its children. Thus unref is
// inappropriate.
return __balanced;
}
else
return __result;
}
template <class _CharT, class _Alloc>
typename rope<_CharT, _Alloc>::_RopeRep*
rope<_CharT, _Alloc>::
_S_concat_char_iter(_RopeRep* __r, const _CharT*__s, size_t __slen)
{
_RopeRep* __result;
if (0 == __slen)
{
_S_ref(__r);
return __r;
}
if (0 == __r)
return __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __slen,
__r->_M_get_allocator());
if (__r->_M_tag == __detail::_S_leaf
&& __r->_M_size + __slen <= size_t(_S_copy_max))
{
__result = _S_leaf_concat_char_iter((_RopeLeaf*)__r, __s, __slen);
return __result;
}
if (__detail::_S_concat == __r->_M_tag
&& __detail::_S_leaf == ((_RopeConcatenation*) __r)->_M_right->_M_tag)
{
_RopeLeaf* __right =
(_RopeLeaf* )(((_RopeConcatenation* )__r)->_M_right);
if (__right->_M_size + __slen <= size_t(_S_copy_max))
{
_RopeRep* __left = ((_RopeConcatenation*)__r)->_M_left;
_RopeRep* __nright =
_S_leaf_concat_char_iter((_RopeLeaf*)__right, __s, __slen);
__left->_M_ref_nonnil();
__try
{ __result = _S_tree_concat(__left, __nright); }
__catch(...)
{
_S_unref(__left);
_S_unref(__nright);
__throw_exception_again;
}
return __result;
}
}
_RopeRep* __nright =
__STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __slen, __r->_M_get_allocator());
__try
{
__r->_M_ref_nonnil();
__result = _S_tree_concat(__r, __nright);
}
__catch(...)
{
_S_unref(__r);
_S_unref(__nright);
__throw_exception_again;
}
return __result;
}
#ifndef __GC
template <class _CharT, class _Alloc>
typename rope<_CharT,_Alloc>::_RopeRep*
rope<_CharT,_Alloc>::
_S_destr_concat_char_iter(_RopeRep* __r, const _CharT* __s, size_t __slen)
{
_RopeRep* __result;
if (0 == __r)
return __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __slen,
__r->_M_get_allocator());
size_t __count = __r->_M_ref_count;
size_t __orig_size = __r->_M_size;
if (__count > 1)
return _S_concat_char_iter(__r, __s, __slen);
if (0 == __slen)
{
__r->_M_ref_count = 2; // One more than before
return __r;
}
if (__orig_size + __slen <= size_t(_S_copy_max)
&& __detail::_S_leaf == __r->_M_tag)
{
__result = _S_destr_leaf_concat_char_iter((_RopeLeaf*)__r, __s,
__slen);
return __result;
}
if (__detail::_S_concat == __r->_M_tag)
{
_RopeLeaf* __right = (_RopeLeaf*)(((_RopeConcatenation*)
__r)->_M_right);
if (__detail::_S_leaf == __right->_M_tag
&& __right->_M_size + __slen <= size_t(_S_copy_max))
{
_RopeRep* __new_right =
_S_destr_leaf_concat_char_iter(__right, __s, __slen);
if (__right == __new_right)
__new_right->_M_ref_count = 1;
else
__right->_M_unref_nonnil();
__r->_M_ref_count = 2; // One more than before.
((_RopeConcatenation*)__r)->_M_right = __new_right;
__r->_M_size = __orig_size + __slen;
if (0 != __r->_M_c_string)
{
__r->_M_free_c_string();
__r->_M_c_string = 0;
}
return __r;
}
}
_RopeRep* __right =
__STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __slen, __r->_M_get_allocator());
__r->_M_ref_nonnil();
__try
{ __result = _S_tree_concat(__r, __right); }
__catch(...)
{
_S_unref(__r);
_S_unref(__right);
__throw_exception_again;
}
return __result;
}
#endif /* !__GC */
template <class _CharT, class _Alloc>
typename rope<_CharT, _Alloc>::_RopeRep*
rope<_CharT, _Alloc>::
_S_concat(_RopeRep* __left, _RopeRep* __right)
{
if (0 == __left)
{
_S_ref(__right);
return __right;
}
if (0 == __right)
{
__left->_M_ref_nonnil();
return __left;
}
if (__detail::_S_leaf == __right->_M_tag)
{
if (__detail::_S_leaf == __left->_M_tag)
{
if (__right->_M_size + __left->_M_size <= size_t(_S_copy_max))
return _S_leaf_concat_char_iter((_RopeLeaf*)__left,
((_RopeLeaf*)__right)->_M_data,
__right->_M_size);
}
else if (__detail::_S_concat == __left->_M_tag
&& __detail::_S_leaf == ((_RopeConcatenation*)
__left)->_M_right->_M_tag)
{
_RopeLeaf* __leftright =
(_RopeLeaf*)(((_RopeConcatenation*)__left)->_M_right);
if (__leftright->_M_size
+ __right->_M_size <= size_t(_S_copy_max))
{
_RopeRep* __leftleft = ((_RopeConcatenation*)__left)->_M_left;
_RopeRep* __rest = _S_leaf_concat_char_iter(__leftright,
((_RopeLeaf*)
__right)->
_M_data,
__right->_M_size);
__leftleft->_M_ref_nonnil();
__try
{ return(_S_tree_concat(__leftleft, __rest)); }
__catch(...)
{
_S_unref(__leftleft);
_S_unref(__rest);
__throw_exception_again;
}
}
}
}
__left->_M_ref_nonnil();
__right->_M_ref_nonnil();
__try
{ return(_S_tree_concat(__left, __right)); }
__catch(...)
{
_S_unref(__left);
_S_unref(__right);
__throw_exception_again;
}
}
template <class _CharT, class _Alloc>
typename rope<_CharT, _Alloc>::_RopeRep*
rope<_CharT, _Alloc>::
_S_substring(_RopeRep* __base, size_t __start, size_t __endp1)
{
if (0 == __base)
return 0;
size_t __len = __base->_M_size;
size_t __adj_endp1;
const size_t __lazy_threshold = 128;
if (__endp1 >= __len)
{
if (0 == __start)
{
__base->_M_ref_nonnil();
return __base;
}
else
__adj_endp1 = __len;
}
else
__adj_endp1 = __endp1;
switch(__base->_M_tag)
{
case __detail::_S_concat:
{
_RopeConcatenation* __c = (_RopeConcatenation*)__base;
_RopeRep* __left = __c->_M_left;
_RopeRep* __right = __c->_M_right;
size_t __left_len = __left->_M_size;
_RopeRep* __result;
if (__adj_endp1 <= __left_len)
return _S_substring(__left, __start, __endp1);
else if (__start >= __left_len)
return _S_substring(__right, __start - __left_len,
__adj_endp1 - __left_len);
_Self_destruct_ptr __left_result(_S_substring(__left,
__start,
__left_len));
_Self_destruct_ptr __right_result(_S_substring(__right, 0,
__endp1
- __left_len));
__result = _S_concat(__left_result, __right_result);
return __result;
}
case __detail::_S_leaf:
{
_RopeLeaf* __l = (_RopeLeaf*)__base;
_RopeLeaf* __result;
size_t __result_len;
if (__start >= __adj_endp1)
return 0;
__result_len = __adj_endp1 - __start;
if (__result_len > __lazy_threshold)
goto lazy;
#ifdef __GC
const _CharT* __section = __l->_M_data + __start;
__result = _S_new_RopeLeaf(__section, __result_len,
__base->_M_get_allocator());
__result->_M_c_string = 0; // Not eos terminated.
#else
// We should sometimes create substring node instead.
__result = __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__l->_M_data + __start,
__result_len,
__base->
_M_get_allocator());
#endif
return __result;
}
case __detail::_S_substringfn:
// Avoid introducing multiple layers of substring nodes.
{
_RopeSubstring* __old = (_RopeSubstring*)__base;
size_t __result_len;
if (__start >= __adj_endp1)
return 0;
__result_len = __adj_endp1 - __start;
if (__result_len > __lazy_threshold)
{
_RopeSubstring* __result =
_S_new_RopeSubstring(__old->_M_base,
__start + __old->_M_start,
__adj_endp1 - __start,
__base->_M_get_allocator());
return __result;
} // *** else fall through: ***
}
case __detail::_S_function:
{
_RopeFunction* __f = (_RopeFunction*)__base;
_CharT* __section;
size_t __result_len;
if (__start >= __adj_endp1)
return 0;
__result_len = __adj_endp1 - __start;
if (__result_len > __lazy_threshold)
goto lazy;
__section = (_CharT*)
rope::_Data_allocate(_S_rounded_up_size(__result_len));
__try
{ (*(__f->_M_fn))(__start, __result_len, __section); }
__catch(...)
{
_RopeRep::__STL_FREE_STRING(__section, __result_len,
__base->_M_get_allocator());
__throw_exception_again;
}
_S_cond_store_eos(__section[__result_len]);
return _S_new_RopeLeaf(__section, __result_len,
__base->_M_get_allocator());
}
}
lazy:
{
// Create substring node.
return _S_new_RopeSubstring(__base, __start, __adj_endp1 - __start,
__base->_M_get_allocator());
}
}
template<class _CharT>
class _Rope_flatten_char_consumer
: public _Rope_char_consumer<_CharT>
{
private:
_CharT* _M_buf_ptr;
public:
_Rope_flatten_char_consumer(_CharT* __buffer)
{ _M_buf_ptr = __buffer; }
~_Rope_flatten_char_consumer() {}
bool
operator()(const _CharT* __leaf, size_t __n)
{
uninitialized_copy_n(__leaf, __n, _M_buf_ptr);
_M_buf_ptr += __n;
return true;
}
};
template<class _CharT>
class _Rope_find_char_char_consumer
: public _Rope_char_consumer<_CharT>
{
private:
_CharT _M_pattern;
public:
size_t _M_count; // Number of nonmatching characters
_Rope_find_char_char_consumer(_CharT __p)
: _M_pattern(__p), _M_count(0) {}
~_Rope_find_char_char_consumer() {}
bool
operator()(const _CharT* __leaf, size_t __n)
{
size_t __i;
for (__i = 0; __i < __n; __i++)
{
if (__leaf[__i] == _M_pattern)
{
_M_count += __i;
return false;
}
}
_M_count += __n; return true;
}
};
template<class _CharT, class _Traits>
// Here _CharT is both the stream and rope character type.
class _Rope_insert_char_consumer
: public _Rope_char_consumer<_CharT>
{
private:
typedef basic_ostream<_CharT,_Traits> _Insert_ostream;
_Insert_ostream& _M_o;
public:
_Rope_insert_char_consumer(_Insert_ostream& __writer)
: _M_o(__writer) {}
~_Rope_insert_char_consumer() { }
// Caller is presumed to own the ostream
bool operator() (const _CharT* __leaf, size_t __n);
// Returns true to continue traversal.
};
template<class _CharT, class _Traits>
bool
_Rope_insert_char_consumer<_CharT, _Traits>::
operator()(const _CharT* __leaf, size_t __n)
{
size_t __i;
// We assume that formatting is set up correctly for each element.
for (__i = 0; __i < __n; __i++)
_M_o.put(__leaf[__i]);
return true;
}
template <class _CharT, class _Alloc>
bool
rope<_CharT, _Alloc>::
_S_apply_to_pieces(_Rope_char_consumer<_CharT>& __c,
const _RopeRep* __r, size_t __begin, size_t __end)
{
if (0 == __r)
return true;
switch(__r->_M_tag)
{
case __detail::_S_concat:
{
_RopeConcatenation* __conc = (_RopeConcatenation*)__r;
_RopeRep* __left = __conc->_M_left;
size_t __left_len = __left->_M_size;
if (__begin < __left_len)
{
size_t __left_end = std::min(__left_len, __end);
if (!_S_apply_to_pieces(__c, __left, __begin, __left_end))
return false;
}
if (__end > __left_len)
{
_RopeRep* __right = __conc->_M_right;
size_t __right_start = std::max(__left_len, __begin);
if (!_S_apply_to_pieces(__c, __right,
__right_start - __left_len,
__end - __left_len))
return false;
}
}
return true;
case __detail::_S_leaf:
{
_RopeLeaf* __l = (_RopeLeaf*)__r;
return __c(__l->_M_data + __begin, __end - __begin);
}
case __detail::_S_function:
case __detail::_S_substringfn:
{
_RopeFunction* __f = (_RopeFunction*)__r;
size_t __len = __end - __begin;
bool __result;
_CharT* __buffer =
(_CharT*)_Alloc().allocate(__len * sizeof(_CharT));
__try
{
(*(__f->_M_fn))(__begin, __len, __buffer);
__result = __c(__buffer, __len);
_Alloc().deallocate(__buffer, __len * sizeof(_CharT));
}
__catch(...)
{
_Alloc().deallocate(__buffer, __len * sizeof(_CharT));
__throw_exception_again;
}
return __result;
}
default:
return false;
}
}
template<class _CharT, class _Traits>
inline void
_Rope_fill(basic_ostream<_CharT, _Traits>& __o, size_t __n)
{
char __f = __o.fill();
size_t __i;
for (__i = 0; __i < __n; __i++)
__o.put(__f);
}
template <class _CharT>
inline bool
_Rope_is_simple(_CharT*)
{ return false; }
inline bool
_Rope_is_simple(char*)
{ return true; }
inline bool
_Rope_is_simple(wchar_t*)
{ return true; }
template<class _CharT, class _Traits, class _Alloc>
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __o,
const rope<_CharT, _Alloc>& __r)
{
size_t __w = __o.width();
bool __left = bool(__o.flags() & std::ios::left);
size_t __pad_len;
size_t __rope_len = __r.size();
_Rope_insert_char_consumer<_CharT, _Traits> __c(__o);
bool __is_simple = _Rope_is_simple((_CharT*)0);
if (__rope_len < __w)
__pad_len = __w - __rope_len;
else
__pad_len = 0;
if (!__is_simple)
__o.width(__w / __rope_len);
__try
{
if (__is_simple && !__left && __pad_len > 0)
_Rope_fill(__o, __pad_len);
__r.apply_to_pieces(0, __r.size(), __c);
if (__is_simple && __left && __pad_len > 0)
_Rope_fill(__o, __pad_len);
if (!__is_simple)
__o.width(__w);
}
__catch(...)
{
if (!__is_simple)
__o.width(__w);
__throw_exception_again;
}
return __o;
}
template <class _CharT, class _Alloc>
_CharT*
rope<_CharT, _Alloc>::
_S_flatten(_RopeRep* __r, size_t __start, size_t __len,
_CharT* __buffer)
{
_Rope_flatten_char_consumer<_CharT> __c(__buffer);
_S_apply_to_pieces(__c, __r, __start, __start + __len);
return(__buffer + __len);
}
template <class _CharT, class _Alloc>
size_t
rope<_CharT, _Alloc>::
find(_CharT __pattern, size_t __start) const
{
_Rope_find_char_char_consumer<_CharT> __c(__pattern);
_S_apply_to_pieces(__c, this->_M_tree_ptr, __start, size());
size_type __result_pos = __start + __c._M_count;
#ifndef __STL_OLD_ROPE_SEMANTICS
if (__result_pos == size())
__result_pos = npos;
#endif
return __result_pos;
}
template <class _CharT, class _Alloc>
_CharT*
rope<_CharT, _Alloc>::
_S_flatten(_RopeRep* __r, _CharT* __buffer)
{
if (0 == __r)
return __buffer;
switch(__r->_M_tag)
{
case __detail::_S_concat:
{
_RopeConcatenation* __c = (_RopeConcatenation*)__r;
_RopeRep* __left = __c->_M_left;
_RopeRep* __right = __c->_M_right;
_CharT* __rest = _S_flatten(__left, __buffer);
return _S_flatten(__right, __rest);
}
case __detail::_S_leaf:
{
_RopeLeaf* __l = (_RopeLeaf*)__r;
return copy_n(__l->_M_data, __l->_M_size, __buffer).second;
}
case __detail::_S_function:
case __detail::_S_substringfn:
// We don't yet do anything with substring nodes.
// This needs to be fixed before ropefiles will work well.
{
_RopeFunction* __f = (_RopeFunction*)__r;
(*(__f->_M_fn))(0, __f->_M_size, __buffer);
return __buffer + __f->_M_size;
}
default:
return 0;
}
}
// This needs work for _CharT != char
template <class _CharT, class _Alloc>
void
rope<_CharT, _Alloc>::
_S_dump(_RopeRep* __r, int __indent)
{
for (int __i = 0; __i < __indent; __i++)
putchar(' ');
if (0 == __r)
{
printf("NULL\n");
return;
}
if (__detail::_S_concat == __r->_M_tag)
{
_RopeConcatenation* __c = (_RopeConcatenation*)__r;
_RopeRep* __left = __c->_M_left;
_RopeRep* __right = __c->_M_right;
#ifdef __GC
printf("Concatenation %p (depth = %d, len = %ld, %s balanced)\n",
__r, __r->_M_depth, __r->_M_size,
__r->_M_is_balanced? "" : "not");
#else
printf("Concatenation %p (rc = %ld, depth = %d, "
"len = %ld, %s balanced)\n",
__r, __r->_M_ref_count, __r->_M_depth, __r->_M_size,
__r->_M_is_balanced? "" : "not");
#endif
_S_dump(__left, __indent + 2);
_S_dump(__right, __indent + 2);
return;
}
else
{
const char* __kind;
switch (__r->_M_tag)
{
case __detail::_S_leaf:
__kind = "Leaf";
break;
case __detail::_S_function:
__kind = "Function";
break;
case __detail::_S_substringfn:
__kind = "Function representing substring";
break;
default:
__kind = "(corrupted kind field!)";
}
#ifdef __GC
printf("%s %p (depth = %d, len = %ld) ",
__kind, __r, __r->_M_depth, __r->_M_size);
#else
printf("%s %p (rc = %ld, depth = %d, len = %ld) ",
__kind, __r, __r->_M_ref_count, __r->_M_depth, __r->_M_size);
#endif
if (_S_is_one_byte_char_type((_CharT*)0))
{
const int __max_len = 40;
_Self_destruct_ptr __prefix(_S_substring(__r, 0, __max_len));
_CharT __buffer[__max_len + 1];
bool __too_big = __r->_M_size > __prefix->_M_size;
_S_flatten(__prefix, __buffer);
__buffer[__prefix->_M_size] = _S_eos((_CharT*)0);
printf("%s%s\n", (char*)__buffer,
__too_big? "...\n" : "\n");
}
else
printf("\n");
}
}
template <class _CharT, class _Alloc>
const unsigned long
rope<_CharT, _Alloc>::
_S_min_len[int(__detail::_S_max_rope_depth) + 1] = {
/* 0 */1, /* 1 */2, /* 2 */3, /* 3 */5, /* 4 */8, /* 5 */13, /* 6 */21,
/* 7 */34, /* 8 */55, /* 9 */89, /* 10 */144, /* 11 */233, /* 12 */377,
/* 13 */610, /* 14 */987, /* 15 */1597, /* 16 */2584, /* 17 */4181,
/* 18 */6765, /* 19 */10946, /* 20 */17711, /* 21 */28657, /* 22 */46368,
/* 23 */75025, /* 24 */121393, /* 25 */196418, /* 26 */317811,
/* 27 */514229, /* 28 */832040, /* 29 */1346269, /* 30 */2178309,
/* 31 */3524578, /* 32 */5702887, /* 33 */9227465, /* 34 */14930352,
/* 35 */24157817, /* 36 */39088169, /* 37 */63245986, /* 38 */102334155,
/* 39 */165580141, /* 40 */267914296, /* 41 */433494437,
/* 42 */701408733, /* 43 */1134903170, /* 44 */1836311903,
/* 45 */2971215073u };
// These are Fibonacci numbers < 2**32.
template <class _CharT, class _Alloc>
typename rope<_CharT, _Alloc>::_RopeRep*
rope<_CharT, _Alloc>::
_S_balance(_RopeRep* __r)
{
_RopeRep* __forest[int(__detail::_S_max_rope_depth) + 1];
_RopeRep* __result = 0;
int __i;
// Invariant:
// The concatenation of forest in descending order is equal to __r.
// __forest[__i]._M_size >= _S_min_len[__i]
// __forest[__i]._M_depth = __i
// References from forest are included in refcount.
for (__i = 0; __i <= int(__detail::_S_max_rope_depth); ++__i)
__forest[__i] = 0;
__try
{
_S_add_to_forest(__r, __forest);
for (__i = 0; __i <= int(__detail::_S_max_rope_depth); ++__i)
if (0 != __forest[__i])
{
#ifndef __GC
_Self_destruct_ptr __old(__result);
#endif
__result = _S_concat(__forest[__i], __result);
__forest[__i]->_M_unref_nonnil();
#if !defined(__GC) && __cpp_exceptions
__forest[__i] = 0;
#endif
}
}
__catch(...)
{
for(__i = 0; __i <= int(__detail::_S_max_rope_depth); __i++)
_S_unref(__forest[__i]);
__throw_exception_again;
}
if (__result->_M_depth > int(__detail::_S_max_rope_depth))
__throw_length_error(__N("rope::_S_balance"));
return(__result);
}
template <class _CharT, class _Alloc>
void
rope<_CharT, _Alloc>::
_S_add_to_forest(_RopeRep* __r, _RopeRep** __forest)
{
if (__r->_M_is_balanced)
{
_S_add_leaf_to_forest(__r, __forest);
return;
}
{
_RopeConcatenation* __c = (_RopeConcatenation*)__r;
_S_add_to_forest(__c->_M_left, __forest);
_S_add_to_forest(__c->_M_right, __forest);
}
}
template <class _CharT, class _Alloc>
void
rope<_CharT, _Alloc>::
_S_add_leaf_to_forest(_RopeRep* __r, _RopeRep** __forest)
{
_RopeRep* __insertee; // included in refcount
_RopeRep* __too_tiny = 0; // included in refcount
int __i; // forest[0..__i-1] is empty
size_t __s = __r->_M_size;
for (__i = 0; __s >= _S_min_len[__i+1]/* not this bucket */; ++__i)
{
if (0 != __forest[__i])
{
#ifndef __GC
_Self_destruct_ptr __old(__too_tiny);
#endif
__too_tiny = _S_concat_and_set_balanced(__forest[__i],
__too_tiny);
__forest[__i]->_M_unref_nonnil();
__forest[__i] = 0;
}
}
{
#ifndef __GC
_Self_destruct_ptr __old(__too_tiny);
#endif
__insertee = _S_concat_and_set_balanced(__too_tiny, __r);
}
// Too_tiny dead, and no longer included in refcount.
// Insertee is live and included.
for (;; ++__i)
{
if (0 != __forest[__i])
{
#ifndef __GC
_Self_destruct_ptr __old(__insertee);
#endif
__insertee = _S_concat_and_set_balanced(__forest[__i],
__insertee);
__forest[__i]->_M_unref_nonnil();
__forest[__i] = 0;
}
if (__i == int(__detail::_S_max_rope_depth)
|| __insertee->_M_size < _S_min_len[__i+1])
{
__forest[__i] = __insertee;
// refcount is OK since __insertee is now dead.
return;
}
}
}
template <class _CharT, class _Alloc>
_CharT
rope<_CharT, _Alloc>::
_S_fetch(_RopeRep* __r, size_type __i)
{
__GC_CONST _CharT* __cstr = __r->_M_c_string;
if (0 != __cstr)
return __cstr[__i];
for(;;)
{
switch(__r->_M_tag)
{
case __detail::_S_concat:
{
_RopeConcatenation* __c = (_RopeConcatenation*)__r;
_RopeRep* __left = __c->_M_left;
size_t __left_len = __left->_M_size;
if (__i >= __left_len)
{
__i -= __left_len;
__r = __c->_M_right;
}
else
__r = __left;
}
break;
case __detail::_S_leaf:
{
_RopeLeaf* __l = (_RopeLeaf*)__r;
return __l->_M_data[__i];
}
case __detail::_S_function:
case __detail::_S_substringfn:
{
_RopeFunction* __f = (_RopeFunction*)__r;
_CharT __result;
(*(__f->_M_fn))(__i, 1, &__result);
return __result;
}
}
}
}
#ifndef __GC
// Return a uniquely referenced character slot for the given
// position, or 0 if that's not possible.
template <class _CharT, class _Alloc>
_CharT*
rope<_CharT, _Alloc>::
_S_fetch_ptr(_RopeRep* __r, size_type __i)
{
_RopeRep* __clrstack[__detail::_S_max_rope_depth];
size_t __csptr = 0;
for(;;)
{
if (__r->_M_ref_count > 1)
return 0;
switch(__r->_M_tag)
{
case __detail::_S_concat:
{
_RopeConcatenation* __c = (_RopeConcatenation*)__r;
_RopeRep* __left = __c->_M_left;
size_t __left_len = __left->_M_size;
if (__c->_M_c_string != 0)
__clrstack[__csptr++] = __c;
if (__i >= __left_len)
{
__i -= __left_len;
__r = __c->_M_right;
}
else
__r = __left;
}
break;
case __detail::_S_leaf:
{
_RopeLeaf* __l = (_RopeLeaf*)__r;
if (__l->_M_c_string != __l->_M_data && __l->_M_c_string != 0)
__clrstack[__csptr++] = __l;
while (__csptr > 0)
{
-- __csptr;
_RopeRep* __d = __clrstack[__csptr];
__d->_M_free_c_string();
__d->_M_c_string = 0;
}
return __l->_M_data + __i;
}
case __detail::_S_function:
case __detail::_S_substringfn:
return 0;
}
}
}
#endif /* __GC */
// The following could be implemented trivially using
// lexicographical_compare_3way.
// We do a little more work to avoid dealing with rope iterators for
// flat strings.
template <class _CharT, class _Alloc>
int
rope<_CharT, _Alloc>::
_S_compare (const _RopeRep* __left, const _RopeRep* __right)
{
size_t __left_len;
size_t __right_len;
if (0 == __right)
return 0 != __left;
if (0 == __left)
return -1;
__left_len = __left->_M_size;
__right_len = __right->_M_size;
if (__detail::_S_leaf == __left->_M_tag)
{
_RopeLeaf* __l = (_RopeLeaf*) __left;
if (__detail::_S_leaf == __right->_M_tag)
{
_RopeLeaf* __r = (_RopeLeaf*) __right;
return lexicographical_compare_3way(__l->_M_data,
__l->_M_data + __left_len,
__r->_M_data, __r->_M_data
+ __right_len);
}
else
{
const_iterator __rstart(__right, 0);
const_iterator __rend(__right, __right_len);
return lexicographical_compare_3way(__l->_M_data, __l->_M_data
+ __left_len,
__rstart, __rend);
}
}
else
{
const_iterator __lstart(__left, 0);
const_iterator __lend(__left, __left_len);
if (__detail::_S_leaf == __right->_M_tag)
{
_RopeLeaf* __r = (_RopeLeaf*) __right;
return lexicographical_compare_3way(__lstart, __lend,
__r->_M_data, __r->_M_data
+ __right_len);
}
else
{
const_iterator __rstart(__right, 0);
const_iterator __rend(__right, __right_len);
return lexicographical_compare_3way(__lstart, __lend,
__rstart, __rend);
}
}
}
// Assignment to reference proxies.
template <class _CharT, class _Alloc>
_Rope_char_ref_proxy<_CharT, _Alloc>&
_Rope_char_ref_proxy<_CharT, _Alloc>::
operator=(_CharT __c)
{
_RopeRep* __old = _M_root->_M_tree_ptr;
#ifndef __GC
// First check for the case in which everything is uniquely
// referenced. In that case we can do this destructively.
_CharT* __ptr = _My_rope::_S_fetch_ptr(__old, _M_pos);
if (0 != __ptr)
{
*__ptr = __c;
return *this;
}
#endif
_Self_destruct_ptr __left(_My_rope::_S_substring(__old, 0, _M_pos));
_Self_destruct_ptr __right(_My_rope::_S_substring(__old, _M_pos + 1,
__old->_M_size));
_Self_destruct_ptr __result_left(_My_rope::
_S_destr_concat_char_iter(__left,
&__c, 1));
_RopeRep* __result = _My_rope::_S_concat(__result_left, __right);
#ifndef __GC
_RopeRep::_S_unref(__old);
#endif
_M_root->_M_tree_ptr = __result;
return *this;
}
template <class _CharT, class _Alloc>
inline _Rope_char_ref_proxy<_CharT, _Alloc>::
operator _CharT() const
{
if (_M_current_valid)
return _M_current;
else
return _My_rope::_S_fetch(_M_root->_M_tree_ptr, _M_pos);
}
template <class _CharT, class _Alloc>
_Rope_char_ptr_proxy<_CharT, _Alloc>
_Rope_char_ref_proxy<_CharT, _Alloc>::
operator&() const
{ return _Rope_char_ptr_proxy<_CharT, _Alloc>(*this); }
template <class _CharT, class _Alloc>
rope<_CharT, _Alloc>::
rope(size_t __n, _CharT __c, const allocator_type& __a)
: _Base(__a)
{
rope<_CharT,_Alloc> __result;
const size_t __exponentiate_threshold = 32;
size_t __exponent;
size_t __rest;
_CharT* __rest_buffer;
_RopeRep* __remainder;
rope<_CharT, _Alloc> __remainder_rope;
if (0 == __n)
return;
__exponent = __n / __exponentiate_threshold;
__rest = __n % __exponentiate_threshold;
if (0 == __rest)
__remainder = 0;
else
{
__rest_buffer = this->_Data_allocate(_S_rounded_up_size(__rest));
__uninitialized_fill_n_a(__rest_buffer, __rest, __c,
_M_get_allocator());
_S_cond_store_eos(__rest_buffer[__rest]);
__try
{ __remainder = _S_new_RopeLeaf(__rest_buffer, __rest,
_M_get_allocator()); }
__catch(...)
{
_RopeRep::__STL_FREE_STRING(__rest_buffer, __rest,
_M_get_allocator());
__throw_exception_again;
}
}
__remainder_rope._M_tree_ptr = __remainder;
if (__exponent != 0)
{
_CharT* __base_buffer =
this->_Data_allocate(_S_rounded_up_size(__exponentiate_threshold));
_RopeLeaf* __base_leaf;
rope __base_rope;
__uninitialized_fill_n_a(__base_buffer, __exponentiate_threshold, __c,
_M_get_allocator());
_S_cond_store_eos(__base_buffer[__exponentiate_threshold]);
__try
{
__base_leaf = _S_new_RopeLeaf(__base_buffer,
__exponentiate_threshold,
_M_get_allocator());
}
__catch(...)
{
_RopeRep::__STL_FREE_STRING(__base_buffer,
__exponentiate_threshold,
_M_get_allocator());
__throw_exception_again;
}
__base_rope._M_tree_ptr = __base_leaf;
if (1 == __exponent)
__result = __base_rope;
else
__result = power(__base_rope, __exponent,
_Rope_Concat_fn<_CharT, _Alloc>());
if (0 != __remainder)
__result += __remainder_rope;
}
else
__result = __remainder_rope;
this->_M_tree_ptr = __result._M_tree_ptr;
this->_M_tree_ptr->_M_ref_nonnil();
}
template<class _CharT, class _Alloc>
_CharT
rope<_CharT, _Alloc>::_S_empty_c_str[1];
template<class _CharT, class _Alloc>
const _CharT*
rope<_CharT, _Alloc>::
c_str() const
{
if (0 == this->_M_tree_ptr)
{
_S_empty_c_str[0] = _S_eos((_CharT*)0); // Possibly redundant,
// but probably fast.
return _S_empty_c_str;
}
__gthread_mutex_lock (&this->_M_tree_ptr->_M_c_string_lock);
__GC_CONST _CharT* __result = this->_M_tree_ptr->_M_c_string;
if (0 == __result)
{
size_t __s = size();
__result = this->_Data_allocate(__s + 1);
_S_flatten(this->_M_tree_ptr, __result);
__result[__s] = _S_eos((_CharT*)0);
this->_M_tree_ptr->_M_c_string = __result;
}
__gthread_mutex_unlock (&this->_M_tree_ptr->_M_c_string_lock);
return(__result);
}
template<class _CharT, class _Alloc>
const _CharT* rope<_CharT, _Alloc>::
replace_with_c_str()
{
if (0 == this->_M_tree_ptr)
{
_S_empty_c_str[0] = _S_eos((_CharT*)0);
return _S_empty_c_str;
}
__GC_CONST _CharT* __old_c_string = this->_M_tree_ptr->_M_c_string;
if (__detail::_S_leaf == this->_M_tree_ptr->_M_tag
&& 0 != __old_c_string)
return(__old_c_string);
size_t __s = size();
_CharT* __result = this->_Data_allocate(_S_rounded_up_size(__s));
_S_flatten(this->_M_tree_ptr, __result);
__result[__s] = _S_eos((_CharT*)0);
this->_M_tree_ptr->_M_unref_nonnil();
this->_M_tree_ptr = _S_new_RopeLeaf(__result, __s,
this->_M_get_allocator());
return(__result);
}
// Algorithm specializations. More should be added.
template<class _Rope_iterator> // was templated on CharT and Alloc
void // VC++ workaround
_Rope_rotate(_Rope_iterator __first,
_Rope_iterator __middle,
_Rope_iterator __last)
{
typedef typename _Rope_iterator::value_type _CharT;
typedef typename _Rope_iterator::_allocator_type _Alloc;
rope<_CharT, _Alloc>& __r(__first.container());
rope<_CharT, _Alloc> __prefix = __r.substr(0, __first.index());
rope<_CharT, _Alloc> __suffix =
__r.substr(__last.index(), __r.size() - __last.index());
rope<_CharT, _Alloc> __part1 =
__r.substr(__middle.index(), __last.index() - __middle.index());
rope<_CharT, _Alloc> __part2 =
__r.substr(__first.index(), __middle.index() - __first.index());
__r = __prefix;
__r += __part1;
__r += __part2;
__r += __suffix;
}
#if !defined(__GNUC__)
// Appears to confuse g++
inline void
rotate(_Rope_iterator<char, __STL_DEFAULT_ALLOCATOR(char)> __first,
_Rope_iterator<char, __STL_DEFAULT_ALLOCATOR(char)> __middle,
_Rope_iterator<char, __STL_DEFAULT_ALLOCATOR(char)> __last)
{ _Rope_rotate(__first, __middle, __last); }
#endif
# if 0
// Probably not useful for several reasons:
// - for SGIs 7.1 compiler and probably some others,
// this forces lots of rope<wchar_t, ...> instantiations, creating a
// code bloat and compile time problem. (Fixed in 7.2.)
// - wchar_t is 4 bytes wide on most UNIX platforms, making it
// unattractive for unicode strings. Unsigned short may be a better
// character type.
inline void
rotate(_Rope_iterator<wchar_t, __STL_DEFAULT_ALLOCATOR(char)> __first,
_Rope_iterator<wchar_t, __STL_DEFAULT_ALLOCATOR(char)> __middle,
_Rope_iterator<wchar_t, __STL_DEFAULT_ALLOCATOR(char)> __last)
{ _Rope_rotate(__first, __middle, __last); }
# endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
c++/8/ext/vstring_fwd.h 0000644 00000006226 15201526705 0010601 0 ustar 00 // <vstring.h> Forward declarations -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file ext/vstring_fwd.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{ext/vstring.h}
*/
#ifndef _VSTRING_FWD_H
#define _VSTRING_FWD_H 1
#pragma GCC system_header
#include <bits/c++config.h>
#include <bits/char_traits.h>
#include <bits/allocator.h>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _CharT, typename _Traits, typename _Alloc>
class __sso_string_base;
template<typename _CharT, typename _Traits, typename _Alloc>
class __rc_string_base;
template<typename _CharT, typename _Traits = std::char_traits<_CharT>,
typename _Alloc = std::allocator<_CharT>,
template
<typename, typename, typename> class _Base = __sso_string_base>
class __versa_string;
typedef __versa_string<char> __vstring;
typedef __vstring __sso_string;
typedef
__versa_string<char, std::char_traits<char>,
std::allocator<char>, __rc_string_base> __rc_string;
#ifdef _GLIBCXX_USE_WCHAR_T
typedef __versa_string<wchar_t> __wvstring;
typedef __wvstring __wsso_string;
typedef
__versa_string<wchar_t, std::char_traits<wchar_t>,
std::allocator<wchar_t>, __rc_string_base> __wrc_string;
#endif
#if ((__cplusplus >= 201103L) \
&& defined(_GLIBCXX_USE_C99_STDINT_TR1))
typedef __versa_string<char16_t> __u16vstring;
typedef __u16vstring __u16sso_string;
typedef
__versa_string<char16_t, std::char_traits<char16_t>,
std::allocator<char16_t>, __rc_string_base> __u16rc_string;
typedef __versa_string<char32_t> __u32vstring;
typedef __u32vstring __u32sso_string;
typedef
__versa_string<char32_t, std::char_traits<char32_t>,
std::allocator<char32_t>, __rc_string_base> __u32rc_string;
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif /* _VSTRING_FWD_H */
c++/8/ext/type_traits.h 0000644 00000013432 15201526705 0010611 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file ext/type_traits.h
* This file is a GNU extension to the Standard C++ Library.
*/
#ifndef _EXT_TYPE_TRAITS
#define _EXT_TYPE_TRAITS 1
#pragma GCC system_header
#include <bits/c++config.h>
#include <bits/cpp_type_traits.h>
extern "C++" {
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Define a nested type if some predicate holds.
template<bool, typename>
struct __enable_if
{ };
template<typename _Tp>
struct __enable_if<true, _Tp>
{ typedef _Tp __type; };
// Conditional expression for types. If true, first, if false, second.
template<bool _Cond, typename _Iftrue, typename _Iffalse>
struct __conditional_type
{ typedef _Iftrue __type; };
template<typename _Iftrue, typename _Iffalse>
struct __conditional_type<false, _Iftrue, _Iffalse>
{ typedef _Iffalse __type; };
// Given an integral builtin type, return the corresponding unsigned type.
template<typename _Tp>
struct __add_unsigned
{
private:
typedef __enable_if<std::__is_integer<_Tp>::__value, _Tp> __if_type;
public:
typedef typename __if_type::__type __type;
};
template<>
struct __add_unsigned<char>
{ typedef unsigned char __type; };
template<>
struct __add_unsigned<signed char>
{ typedef unsigned char __type; };
template<>
struct __add_unsigned<short>
{ typedef unsigned short __type; };
template<>
struct __add_unsigned<int>
{ typedef unsigned int __type; };
template<>
struct __add_unsigned<long>
{ typedef unsigned long __type; };
template<>
struct __add_unsigned<long long>
{ typedef unsigned long long __type; };
// Declare but don't define.
template<>
struct __add_unsigned<bool>;
template<>
struct __add_unsigned<wchar_t>;
// Given an integral builtin type, return the corresponding signed type.
template<typename _Tp>
struct __remove_unsigned
{
private:
typedef __enable_if<std::__is_integer<_Tp>::__value, _Tp> __if_type;
public:
typedef typename __if_type::__type __type;
};
template<>
struct __remove_unsigned<char>
{ typedef signed char __type; };
template<>
struct __remove_unsigned<unsigned char>
{ typedef signed char __type; };
template<>
struct __remove_unsigned<unsigned short>
{ typedef short __type; };
template<>
struct __remove_unsigned<unsigned int>
{ typedef int __type; };
template<>
struct __remove_unsigned<unsigned long>
{ typedef long __type; };
template<>
struct __remove_unsigned<unsigned long long>
{ typedef long long __type; };
// Declare but don't define.
template<>
struct __remove_unsigned<bool>;
template<>
struct __remove_unsigned<wchar_t>;
// For use in string and vstring.
template<typename _Type>
inline bool
__is_null_pointer(_Type* __ptr)
{ return __ptr == 0; }
template<typename _Type>
inline bool
__is_null_pointer(_Type)
{ return false; }
#if __cplusplus >= 201103L
inline bool
__is_null_pointer(std::nullptr_t)
{ return true; }
#endif
// For complex and cmath
template<typename _Tp, bool = std::__is_integer<_Tp>::__value>
struct __promote
{ typedef double __type; };
// No nested __type member for non-integer non-floating point types,
// allows this type to be used for SFINAE to constrain overloads in
// <cmath> and <complex> to only the intended types.
template<typename _Tp>
struct __promote<_Tp, false>
{ };
template<>
struct __promote<long double>
{ typedef long double __type; };
template<>
struct __promote<double>
{ typedef double __type; };
template<>
struct __promote<float>
{ typedef float __type; };
template<typename _Tp, typename _Up,
typename _Tp2 = typename __promote<_Tp>::__type,
typename _Up2 = typename __promote<_Up>::__type>
struct __promote_2
{
typedef __typeof__(_Tp2() + _Up2()) __type;
};
template<typename _Tp, typename _Up, typename _Vp,
typename _Tp2 = typename __promote<_Tp>::__type,
typename _Up2 = typename __promote<_Up>::__type,
typename _Vp2 = typename __promote<_Vp>::__type>
struct __promote_3
{
typedef __typeof__(_Tp2() + _Up2() + _Vp2()) __type;
};
template<typename _Tp, typename _Up, typename _Vp, typename _Wp,
typename _Tp2 = typename __promote<_Tp>::__type,
typename _Up2 = typename __promote<_Up>::__type,
typename _Vp2 = typename __promote<_Vp>::__type,
typename _Wp2 = typename __promote<_Wp>::__type>
struct __promote_4
{
typedef __typeof__(_Tp2() + _Up2() + _Vp2() + _Wp2()) __type;
};
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
} // extern "C++"
#endif
c++/8/ext/hash_set 0000644 00000041453 15201526705 0007616 0 ustar 00 // Hashing set implementation -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
* Copyright (c) 1996
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*/
/** @file backward/hash_set
* This file is a GNU extension to the Standard C++ Library (possibly
* containing extensions from the HP/SGI STL subset).
*/
#ifndef _BACKWARD_HASH_SET
#define _BACKWARD_HASH_SET 1
#ifndef _GLIBCXX_PERMIT_BACKWARD_HASH
#include "backward_warning.h"
#endif
#include <bits/c++config.h>
#include <backward/hashtable.h>
#include <bits/concept_check.h>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using std::equal_to;
using std::allocator;
using std::pair;
using std::_Identity;
/**
* This is an SGI extension.
* @ingroup SGIextensions
* @doctodo
*/
template<class _Value, class _HashFcn = hash<_Value>,
class _EqualKey = equal_to<_Value>,
class _Alloc = allocator<_Value> >
class hash_set
{
// concept requirements
__glibcxx_class_requires(_Value, _SGIAssignableConcept)
__glibcxx_class_requires3(_HashFcn, size_t, _Value, _UnaryFunctionConcept)
__glibcxx_class_requires3(_EqualKey, _Value, _Value, _BinaryPredicateConcept)
private:
typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>,
_EqualKey, _Alloc> _Ht;
_Ht _M_ht;
public:
typedef typename _Ht::key_type key_type;
typedef typename _Ht::value_type value_type;
typedef typename _Ht::hasher hasher;
typedef typename _Ht::key_equal key_equal;
typedef typename _Ht::size_type size_type;
typedef typename _Ht::difference_type difference_type;
typedef typename _Alloc::pointer pointer;
typedef typename _Alloc::const_pointer const_pointer;
typedef typename _Alloc::reference reference;
typedef typename _Alloc::const_reference const_reference;
typedef typename _Ht::const_iterator iterator;
typedef typename _Ht::const_iterator const_iterator;
typedef typename _Ht::allocator_type allocator_type;
hasher
hash_funct() const
{ return _M_ht.hash_funct(); }
key_equal
key_eq() const
{ return _M_ht.key_eq(); }
allocator_type
get_allocator() const
{ return _M_ht.get_allocator(); }
hash_set()
: _M_ht(100, hasher(), key_equal(), allocator_type()) {}
explicit
hash_set(size_type __n)
: _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
hash_set(size_type __n, const hasher& __hf)
: _M_ht(__n, __hf, key_equal(), allocator_type()) {}
hash_set(size_type __n, const hasher& __hf, const key_equal& __eql,
const allocator_type& __a = allocator_type())
: _M_ht(__n, __hf, __eql, __a) {}
template<class _InputIterator>
hash_set(_InputIterator __f, _InputIterator __l)
: _M_ht(100, hasher(), key_equal(), allocator_type())
{ _M_ht.insert_unique(__f, __l); }
template<class _InputIterator>
hash_set(_InputIterator __f, _InputIterator __l, size_type __n)
: _M_ht(__n, hasher(), key_equal(), allocator_type())
{ _M_ht.insert_unique(__f, __l); }
template<class _InputIterator>
hash_set(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf)
: _M_ht(__n, __hf, key_equal(), allocator_type())
{ _M_ht.insert_unique(__f, __l); }
template<class _InputIterator>
hash_set(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf, const key_equal& __eql,
const allocator_type& __a = allocator_type())
: _M_ht(__n, __hf, __eql, __a)
{ _M_ht.insert_unique(__f, __l); }
size_type
size() const
{ return _M_ht.size(); }
size_type
max_size() const
{ return _M_ht.max_size(); }
bool
empty() const
{ return _M_ht.empty(); }
void
swap(hash_set& __hs)
{ _M_ht.swap(__hs._M_ht); }
template<class _Val, class _HF, class _EqK, class _Al>
friend bool
operator==(const hash_set<_Val, _HF, _EqK, _Al>&,
const hash_set<_Val, _HF, _EqK, _Al>&);
iterator
begin() const
{ return _M_ht.begin(); }
iterator
end() const
{ return _M_ht.end(); }
pair<iterator, bool>
insert(const value_type& __obj)
{
pair<typename _Ht::iterator, bool> __p = _M_ht.insert_unique(__obj);
return pair<iterator,bool>(__p.first, __p.second);
}
template<class _InputIterator>
void
insert(_InputIterator __f, _InputIterator __l)
{ _M_ht.insert_unique(__f, __l); }
pair<iterator, bool>
insert_noresize(const value_type& __obj)
{
pair<typename _Ht::iterator, bool> __p
= _M_ht.insert_unique_noresize(__obj);
return pair<iterator, bool>(__p.first, __p.second);
}
iterator
find(const key_type& __key) const
{ return _M_ht.find(__key); }
size_type
count(const key_type& __key) const
{ return _M_ht.count(__key); }
pair<iterator, iterator>
equal_range(const key_type& __key) const
{ return _M_ht.equal_range(__key); }
size_type
erase(const key_type& __key)
{return _M_ht.erase(__key); }
void
erase(iterator __it)
{ _M_ht.erase(__it); }
void
erase(iterator __f, iterator __l)
{ _M_ht.erase(__f, __l); }
void
clear()
{ _M_ht.clear(); }
void
resize(size_type __hint)
{ _M_ht.resize(__hint); }
size_type
bucket_count() const
{ return _M_ht.bucket_count(); }
size_type
max_bucket_count() const
{ return _M_ht.max_bucket_count(); }
size_type
elems_in_bucket(size_type __n) const
{ return _M_ht.elems_in_bucket(__n); }
};
template<class _Value, class _HashFcn, class _EqualKey, class _Alloc>
inline bool
operator==(const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs1,
const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs2)
{ return __hs1._M_ht == __hs2._M_ht; }
template<class _Value, class _HashFcn, class _EqualKey, class _Alloc>
inline bool
operator!=(const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs1,
const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs2)
{ return !(__hs1 == __hs2); }
template<class _Val, class _HashFcn, class _EqualKey, class _Alloc>
inline void
swap(hash_set<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
hash_set<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2)
{ __hs1.swap(__hs2); }
/**
* This is an SGI extension.
* @ingroup SGIextensions
* @doctodo
*/
template<class _Value,
class _HashFcn = hash<_Value>,
class _EqualKey = equal_to<_Value>,
class _Alloc = allocator<_Value> >
class hash_multiset
{
// concept requirements
__glibcxx_class_requires(_Value, _SGIAssignableConcept)
__glibcxx_class_requires3(_HashFcn, size_t, _Value, _UnaryFunctionConcept)
__glibcxx_class_requires3(_EqualKey, _Value, _Value, _BinaryPredicateConcept)
private:
typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>,
_EqualKey, _Alloc> _Ht;
_Ht _M_ht;
public:
typedef typename _Ht::key_type key_type;
typedef typename _Ht::value_type value_type;
typedef typename _Ht::hasher hasher;
typedef typename _Ht::key_equal key_equal;
typedef typename _Ht::size_type size_type;
typedef typename _Ht::difference_type difference_type;
typedef typename _Alloc::pointer pointer;
typedef typename _Alloc::const_pointer const_pointer;
typedef typename _Alloc::reference reference;
typedef typename _Alloc::const_reference const_reference;
typedef typename _Ht::const_iterator iterator;
typedef typename _Ht::const_iterator const_iterator;
typedef typename _Ht::allocator_type allocator_type;
hasher
hash_funct() const
{ return _M_ht.hash_funct(); }
key_equal
key_eq() const
{ return _M_ht.key_eq(); }
allocator_type
get_allocator() const
{ return _M_ht.get_allocator(); }
hash_multiset()
: _M_ht(100, hasher(), key_equal(), allocator_type()) {}
explicit
hash_multiset(size_type __n)
: _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
hash_multiset(size_type __n, const hasher& __hf)
: _M_ht(__n, __hf, key_equal(), allocator_type()) {}
hash_multiset(size_type __n, const hasher& __hf, const key_equal& __eql,
const allocator_type& __a = allocator_type())
: _M_ht(__n, __hf, __eql, __a) {}
template<class _InputIterator>
hash_multiset(_InputIterator __f, _InputIterator __l)
: _M_ht(100, hasher(), key_equal(), allocator_type())
{ _M_ht.insert_equal(__f, __l); }
template<class _InputIterator>
hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n)
: _M_ht(__n, hasher(), key_equal(), allocator_type())
{ _M_ht.insert_equal(__f, __l); }
template<class _InputIterator>
hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf)
: _M_ht(__n, __hf, key_equal(), allocator_type())
{ _M_ht.insert_equal(__f, __l); }
template<class _InputIterator>
hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf, const key_equal& __eql,
const allocator_type& __a = allocator_type())
: _M_ht(__n, __hf, __eql, __a)
{ _M_ht.insert_equal(__f, __l); }
size_type
size() const
{ return _M_ht.size(); }
size_type
max_size() const
{ return _M_ht.max_size(); }
bool
empty() const
{ return _M_ht.empty(); }
void
swap(hash_multiset& hs)
{ _M_ht.swap(hs._M_ht); }
template<class _Val, class _HF, class _EqK, class _Al>
friend bool
operator==(const hash_multiset<_Val, _HF, _EqK, _Al>&,
const hash_multiset<_Val, _HF, _EqK, _Al>&);
iterator
begin() const
{ return _M_ht.begin(); }
iterator
end() const
{ return _M_ht.end(); }
iterator
insert(const value_type& __obj)
{ return _M_ht.insert_equal(__obj); }
template<class _InputIterator>
void
insert(_InputIterator __f, _InputIterator __l)
{ _M_ht.insert_equal(__f,__l); }
iterator
insert_noresize(const value_type& __obj)
{ return _M_ht.insert_equal_noresize(__obj); }
iterator
find(const key_type& __key) const
{ return _M_ht.find(__key); }
size_type
count(const key_type& __key) const
{ return _M_ht.count(__key); }
pair<iterator, iterator>
equal_range(const key_type& __key) const
{ return _M_ht.equal_range(__key); }
size_type
erase(const key_type& __key)
{ return _M_ht.erase(__key); }
void
erase(iterator __it)
{ _M_ht.erase(__it); }
void
erase(iterator __f, iterator __l)
{ _M_ht.erase(__f, __l); }
void
clear()
{ _M_ht.clear(); }
void
resize(size_type __hint)
{ _M_ht.resize(__hint); }
size_type
bucket_count() const
{ return _M_ht.bucket_count(); }
size_type
max_bucket_count() const
{ return _M_ht.max_bucket_count(); }
size_type
elems_in_bucket(size_type __n) const
{ return _M_ht.elems_in_bucket(__n); }
};
template<class _Val, class _HashFcn, class _EqualKey, class _Alloc>
inline bool
operator==(const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2)
{ return __hs1._M_ht == __hs2._M_ht; }
template<class _Val, class _HashFcn, class _EqualKey, class _Alloc>
inline bool
operator!=(const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2)
{ return !(__hs1 == __hs2); }
template<class _Val, class _HashFcn, class _EqualKey, class _Alloc>
inline void
swap(hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2)
{ __hs1.swap(__hs2); }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Specialization of insert_iterator so that it will work for hash_set
// and hash_multiset.
template<class _Value, class _HashFcn, class _EqualKey, class _Alloc>
class insert_iterator<__gnu_cxx::hash_set<_Value, _HashFcn,
_EqualKey, _Alloc> >
{
protected:
typedef __gnu_cxx::hash_set<_Value, _HashFcn, _EqualKey, _Alloc>
_Container;
_Container* container;
public:
typedef _Container container_type;
typedef output_iterator_tag iterator_category;
typedef void value_type;
typedef void difference_type;
typedef void pointer;
typedef void reference;
insert_iterator(_Container& __x)
: container(&__x) {}
insert_iterator(_Container& __x, typename _Container::iterator)
: container(&__x) {}
insert_iterator<_Container>&
operator=(const typename _Container::value_type& __value)
{
container->insert(__value);
return *this;
}
insert_iterator<_Container>&
operator*()
{ return *this; }
insert_iterator<_Container>&
operator++()
{ return *this; }
insert_iterator<_Container>&
operator++(int)
{ return *this; }
};
template<class _Value, class _HashFcn, class _EqualKey, class _Alloc>
class insert_iterator<__gnu_cxx::hash_multiset<_Value, _HashFcn,
_EqualKey, _Alloc> >
{
protected:
typedef __gnu_cxx::hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc>
_Container;
_Container* container;
typename _Container::iterator iter;
public:
typedef _Container container_type;
typedef output_iterator_tag iterator_category;
typedef void value_type;
typedef void difference_type;
typedef void pointer;
typedef void reference;
insert_iterator(_Container& __x)
: container(&__x) {}
insert_iterator(_Container& __x, typename _Container::iterator)
: container(&__x) {}
insert_iterator<_Container>&
operator=(const typename _Container::value_type& __value)
{
container->insert(__value);
return *this;
}
insert_iterator<_Container>&
operator*()
{ return *this; }
insert_iterator<_Container>&
operator++()
{ return *this; }
insert_iterator<_Container>&
operator++(int) { return *this; }
};
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/ext/vstring.h 0000644 00000327760 15201526705 0007752 0 ustar 00 // Versatile string -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file ext/vstring.h
* This file is a GNU extension to the Standard C++ Library.
*/
#ifndef _VSTRING_H
#define _VSTRING_H 1
#pragma GCC system_header
#if __cplusplus >= 201103L
#include <initializer_list>
#endif
#include <ext/vstring_util.h>
#include <ext/rc_string_base.h>
#include <ext/sso_string_base.h>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @class __versa_string vstring.h
* @brief Template class __versa_string.
* @ingroup extensions
*
* Data structure managing sequences of characters and
* character-like objects.
*/
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
class __versa_string
: private _Base<_CharT, _Traits, _Alloc>
{
typedef _Base<_CharT, _Traits, _Alloc> __vstring_base;
typedef typename __vstring_base::_CharT_alloc_type _CharT_alloc_type;
// Types:
public:
typedef _Traits traits_type;
typedef typename _Traits::char_type value_type;
typedef _Alloc allocator_type;
typedef typename _CharT_alloc_type::size_type size_type;
typedef typename _CharT_alloc_type::difference_type difference_type;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef typename _CharT_alloc_type::pointer pointer;
typedef typename _CharT_alloc_type::const_pointer const_pointer;
typedef __gnu_cxx::__normal_iterator<pointer, __versa_string> iterator;
typedef __gnu_cxx::__normal_iterator<const_pointer, __versa_string>
const_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
// Data Member (public):
/// Value returned by various member functions when they fail.
static const size_type npos = static_cast<size_type>(-1);
private:
size_type
_M_check(size_type __pos, const char* __s) const
{
if (__pos > this->size())
std::__throw_out_of_range_fmt(__N("%s: __pos (which is %zu) > "
"this->size() (which is %zu)"),
__s, __pos, this->size());
return __pos;
}
void
_M_check_length(size_type __n1, size_type __n2, const char* __s) const
{
if (this->max_size() - (this->size() - __n1) < __n2)
std::__throw_length_error(__N(__s));
}
// NB: _M_limit doesn't check for a bad __pos value.
size_type
_M_limit(size_type __pos, size_type __off) const _GLIBCXX_NOEXCEPT
{
const bool __testoff = __off < this->size() - __pos;
return __testoff ? __off : this->size() - __pos;
}
// True if _Rep and source do not overlap.
bool
_M_disjunct(const _CharT* __s) const _GLIBCXX_NOEXCEPT
{
return (std::less<const _CharT*>()(__s, this->_M_data())
|| std::less<const _CharT*>()(this->_M_data()
+ this->size(), __s));
}
// For the internal use we have functions similar to `begin'/`end'
// but they do not call _M_leak.
iterator
_M_ibegin() const _GLIBCXX_NOEXCEPT
{ return iterator(this->_M_data()); }
iterator
_M_iend() const _GLIBCXX_NOEXCEPT
{ return iterator(this->_M_data() + this->_M_length()); }
public:
// Construct/copy/destroy:
// NB: We overload ctors in some cases instead of using default
// arguments, per 17.4.4.4 para. 2 item 2.
/**
* @brief Construct an empty string using allocator @a a.
*/
explicit
__versa_string(const _Alloc& __a = _Alloc()) _GLIBCXX_NOEXCEPT
: __vstring_base(__a) { }
// NB: per LWG issue 42, semantics different from IS:
/**
* @brief Construct string with copy of value of @a __str.
* @param __str Source string.
*/
__versa_string(const __versa_string& __str)
: __vstring_base(__str) { }
#if __cplusplus >= 201103L
/**
* @brief String move constructor.
* @param __str Source string.
*
* The newly-constructed %string contains the exact contents of
* @a __str. The contents of @a __str are a valid, but unspecified
* string.
*/
__versa_string(__versa_string&& __str) noexcept
: __vstring_base(std::move(__str)) { }
/**
* @brief Construct string from an initializer list.
* @param __l std::initializer_list of characters.
* @param __a Allocator to use (default is default allocator).
*/
__versa_string(std::initializer_list<_CharT> __l,
const _Alloc& __a = _Alloc())
: __vstring_base(__l.begin(), __l.end(), __a) { }
#endif
/**
* @brief Construct string as copy of a substring.
* @param __str Source string.
* @param __pos Index of first character to copy from.
* @param __n Number of characters to copy (default remainder).
*/
__versa_string(const __versa_string& __str, size_type __pos,
size_type __n = npos)
: __vstring_base(__str._M_data()
+ __str._M_check(__pos,
"__versa_string::__versa_string"),
__str._M_data() + __str._M_limit(__pos, __n)
+ __pos, _Alloc()) { }
/**
* @brief Construct string as copy of a substring.
* @param __str Source string.
* @param __pos Index of first character to copy from.
* @param __n Number of characters to copy.
* @param __a Allocator to use.
*/
__versa_string(const __versa_string& __str, size_type __pos,
size_type __n, const _Alloc& __a)
: __vstring_base(__str._M_data()
+ __str._M_check(__pos,
"__versa_string::__versa_string"),
__str._M_data() + __str._M_limit(__pos, __n)
+ __pos, __a) { }
/**
* @brief Construct string initialized by a character array.
* @param __s Source character array.
* @param __n Number of characters to copy.
* @param __a Allocator to use (default is default allocator).
*
* NB: @a __s must have at least @a __n characters, '\\0' has no special
* meaning.
*/
__versa_string(const _CharT* __s, size_type __n,
const _Alloc& __a = _Alloc())
: __vstring_base(__s, __s + __n, __a) { }
/**
* @brief Construct string as copy of a C string.
* @param __s Source C string.
* @param __a Allocator to use (default is default allocator).
*/
__versa_string(const _CharT* __s, const _Alloc& __a = _Alloc())
: __vstring_base(__s, __s ? __s + traits_type::length(__s) :
__s + npos, __a) { }
/**
* @brief Construct string as multiple characters.
* @param __n Number of characters.
* @param __c Character to use.
* @param __a Allocator to use (default is default allocator).
*/
__versa_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc())
: __vstring_base(__n, __c, __a) { }
/**
* @brief Construct string as copy of a range.
* @param __beg Start of range.
* @param __end End of range.
* @param __a Allocator to use (default is default allocator).
*/
#if __cplusplus >= 201103L
template<class _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
#else
template<class _InputIterator>
#endif
__versa_string(_InputIterator __beg, _InputIterator __end,
const _Alloc& __a = _Alloc())
: __vstring_base(__beg, __end, __a) { }
/**
* @brief Destroy the string instance.
*/
~__versa_string() _GLIBCXX_NOEXCEPT { }
/**
* @brief Assign the value of @a str to this string.
* @param __str Source string.
*/
__versa_string&
operator=(const __versa_string& __str)
{ return this->assign(__str); }
#if __cplusplus >= 201103L
/**
* @brief String move assignment operator.
* @param __str Source string.
*
* The contents of @a __str are moved into this string (without
* copying). @a __str is a valid, but unspecified string.
*/
__versa_string&
operator=(__versa_string&& __str) noexcept
{
// NB: DR 1204.
this->swap(__str);
return *this;
}
/**
* @brief Set value to string constructed from initializer list.
* @param __l std::initializer_list.
*/
__versa_string&
operator=(std::initializer_list<_CharT> __l)
{
this->assign(__l.begin(), __l.end());
return *this;
}
#endif
/**
* @brief Copy contents of @a __s into this string.
* @param __s Source null-terminated string.
*/
__versa_string&
operator=(const _CharT* __s)
{ return this->assign(__s); }
/**
* @brief Set value to string of length 1.
* @param __c Source character.
*
* Assigning to a character makes this string length 1 and
* (*this)[0] == @a __c.
*/
__versa_string&
operator=(_CharT __c)
{
this->assign(1, __c);
return *this;
}
// Iterators:
/**
* Returns a read/write iterator that points to the first character in
* the %string. Unshares the string.
*/
iterator
begin() _GLIBCXX_NOEXCEPT
{
this->_M_leak();
return iterator(this->_M_data());
}
/**
* Returns a read-only (constant) iterator that points to the first
* character in the %string.
*/
const_iterator
begin() const _GLIBCXX_NOEXCEPT
{ return const_iterator(this->_M_data()); }
/**
* Returns a read/write iterator that points one past the last
* character in the %string. Unshares the string.
*/
iterator
end() _GLIBCXX_NOEXCEPT
{
this->_M_leak();
return iterator(this->_M_data() + this->size());
}
/**
* Returns a read-only (constant) iterator that points one past the
* last character in the %string.
*/
const_iterator
end() const _GLIBCXX_NOEXCEPT
{ return const_iterator(this->_M_data() + this->size()); }
/**
* Returns a read/write reverse iterator that points to the last
* character in the %string. Iteration is done in reverse element
* order. Unshares the string.
*/
reverse_iterator
rbegin() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(this->end()); }
/**
* Returns a read-only (constant) reverse iterator that points
* to the last character in the %string. Iteration is done in
* reverse element order.
*/
const_reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(this->end()); }
/**
* Returns a read/write reverse iterator that points to one before the
* first character in the %string. Iteration is done in reverse
* element order. Unshares the string.
*/
reverse_iterator
rend() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(this->begin()); }
/**
* Returns a read-only (constant) reverse iterator that points
* to one before the first character in the %string. Iteration
* is done in reverse element order.
*/
const_reverse_iterator
rend() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(this->begin()); }
#if __cplusplus >= 201103L
/**
* Returns a read-only (constant) iterator that points to the first
* character in the %string.
*/
const_iterator
cbegin() const noexcept
{ return const_iterator(this->_M_data()); }
/**
* Returns a read-only (constant) iterator that points one past the
* last character in the %string.
*/
const_iterator
cend() const noexcept
{ return const_iterator(this->_M_data() + this->size()); }
/**
* Returns a read-only (constant) reverse iterator that points
* to the last character in the %string. Iteration is done in
* reverse element order.
*/
const_reverse_iterator
crbegin() const noexcept
{ return const_reverse_iterator(this->end()); }
/**
* Returns a read-only (constant) reverse iterator that points
* to one before the first character in the %string. Iteration
* is done in reverse element order.
*/
const_reverse_iterator
crend() const noexcept
{ return const_reverse_iterator(this->begin()); }
#endif
public:
// Capacity:
/// Returns the number of characters in the string, not including any
/// null-termination.
size_type
size() const _GLIBCXX_NOEXCEPT
{ return this->_M_length(); }
/// Returns the number of characters in the string, not including any
/// null-termination.
size_type
length() const _GLIBCXX_NOEXCEPT
{ return this->_M_length(); }
/// Returns the size() of the largest possible %string.
size_type
max_size() const _GLIBCXX_NOEXCEPT
{ return this->_M_max_size(); }
/**
* @brief Resizes the %string to the specified number of characters.
* @param __n Number of characters the %string should contain.
* @param __c Character to fill any new elements.
*
* This function will %resize the %string to the specified
* number of characters. If the number is smaller than the
* %string's current size the %string is truncated, otherwise
* the %string is extended and new elements are set to @a __c.
*/
void
resize(size_type __n, _CharT __c);
/**
* @brief Resizes the %string to the specified number of characters.
* @param __n Number of characters the %string should contain.
*
* This function will resize the %string to the specified
* length. If the new size is smaller than the %string's
* current size the %string is truncated, otherwise the %string
* is extended and new characters are default-constructed. For
* basic types such as char, this means setting them to 0.
*/
void
resize(size_type __n)
{ this->resize(__n, _CharT()); }
#if __cplusplus >= 201103L
/// A non-binding request to reduce capacity() to size().
void
shrink_to_fit() noexcept
{
if (capacity() > size())
{
__try
{ this->reserve(0); }
__catch(...)
{ }
}
}
#endif
/**
* Returns the total number of characters that the %string can
* hold before needing to allocate more memory.
*/
size_type
capacity() const _GLIBCXX_NOEXCEPT
{ return this->_M_capacity(); }
/**
* @brief Attempt to preallocate enough memory for specified number of
* characters.
* @param __res_arg Number of characters required.
* @throw std::length_error If @a __res_arg exceeds @c max_size().
*
* This function attempts to reserve enough memory for the
* %string to hold the specified number of characters. If the
* number requested is more than max_size(), length_error is
* thrown.
*
* The advantage of this function is that if optimal code is a
* necessity and the user can determine the string length that
* will be required, the user can reserve the memory in
* %advance, and thus prevent a possible reallocation of memory
* and copying of %string data.
*/
void
reserve(size_type __res_arg = 0)
{ this->_M_reserve(__res_arg); }
/**
* Erases the string, making it empty.
*/
void
clear() _GLIBCXX_NOEXCEPT
{ this->_M_clear(); }
/**
* Returns true if the %string is empty. Equivalent to
* <code>*this == ""</code>.
*/
bool
empty() const _GLIBCXX_NOEXCEPT
{ return this->size() == 0; }
// Element access:
/**
* @brief Subscript access to the data contained in the %string.
* @param __pos The index of the character to access.
* @return Read-only (constant) reference to the character.
*
* This operator allows for easy, array-style, data access.
* Note that data access with this operator is unchecked and
* out_of_range lookups are not defined. (For checked lookups
* see at().)
*/
const_reference
operator[] (size_type __pos) const _GLIBCXX_NOEXCEPT
{
__glibcxx_assert(__pos <= this->size());
return this->_M_data()[__pos];
}
/**
* @brief Subscript access to the data contained in the %string.
* @param __pos The index of the character to access.
* @return Read/write reference to the character.
*
* This operator allows for easy, array-style, data access.
* Note that data access with this operator is unchecked and
* out_of_range lookups are not defined. (For checked lookups
* see at().) Unshares the string.
*/
reference
operator[](size_type __pos) _GLIBCXX_NOEXCEPT
{
// Allow pos == size() both in C++98 mode, as v3 extension,
// and in C++11 mode.
__glibcxx_assert(__pos <= this->size());
// In pedantic mode be strict in C++98 mode.
_GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L
|| __pos < this->size());
this->_M_leak();
return this->_M_data()[__pos];
}
/**
* @brief Provides access to the data contained in the %string.
* @param __n The index of the character to access.
* @return Read-only (const) reference to the character.
* @throw std::out_of_range If @a __n is an invalid index.
*
* This function provides for safer data access. The parameter
* is first checked that it is in the range of the string. The
* function throws out_of_range if the check fails.
*/
const_reference
at(size_type __n) const
{
if (__n >= this->size())
std::__throw_out_of_range_fmt(__N("__versa_string::at: __n "
"(which is %zu) >= this->size() "
"(which is %zu)"),
__n, this->size());
return this->_M_data()[__n];
}
/**
* @brief Provides access to the data contained in the %string.
* @param __n The index of the character to access.
* @return Read/write reference to the character.
* @throw std::out_of_range If @a __n is an invalid index.
*
* This function provides for safer data access. The parameter
* is first checked that it is in the range of the string. The
* function throws out_of_range if the check fails. Success
* results in unsharing the string.
*/
reference
at(size_type __n)
{
if (__n >= this->size())
std::__throw_out_of_range_fmt(__N("__versa_string::at: __n "
"(which is %zu) >= this->size() "
"(which is %zu)"),
__n, this->size());
this->_M_leak();
return this->_M_data()[__n];
}
#if __cplusplus >= 201103L
/**
* Returns a read/write reference to the data at the first
* element of the %string.
*/
reference
front() noexcept
{ return operator[](0); }
/**
* Returns a read-only (constant) reference to the data at the first
* element of the %string.
*/
const_reference
front() const noexcept
{ return operator[](0); }
/**
* Returns a read/write reference to the data at the last
* element of the %string.
*/
reference
back() noexcept
{ return operator[](this->size() - 1); }
/**
* Returns a read-only (constant) reference to the data at the
* last element of the %string.
*/
const_reference
back() const noexcept
{ return operator[](this->size() - 1); }
#endif
// Modifiers:
/**
* @brief Append a string to this string.
* @param __str The string to append.
* @return Reference to this string.
*/
__versa_string&
operator+=(const __versa_string& __str)
{ return this->append(__str); }
/**
* @brief Append a C string.
* @param __s The C string to append.
* @return Reference to this string.
*/
__versa_string&
operator+=(const _CharT* __s)
{ return this->append(__s); }
/**
* @brief Append a character.
* @param __c The character to append.
* @return Reference to this string.
*/
__versa_string&
operator+=(_CharT __c)
{
this->push_back(__c);
return *this;
}
#if __cplusplus >= 201103L
/**
* @brief Append an initializer_list of characters.
* @param __l The initializer_list of characters to be appended.
* @return Reference to this string.
*/
__versa_string&
operator+=(std::initializer_list<_CharT> __l)
{ return this->append(__l.begin(), __l.end()); }
#endif // C++11
/**
* @brief Append a string to this string.
* @param __str The string to append.
* @return Reference to this string.
*/
__versa_string&
append(const __versa_string& __str)
{ return _M_append(__str._M_data(), __str.size()); }
/**
* @brief Append a substring.
* @param __str The string to append.
* @param __pos Index of the first character of str to append.
* @param __n The number of characters to append.
* @return Reference to this string.
* @throw std::out_of_range if @a pos is not a valid index.
*
* This function appends @a __n characters from @a __str
* starting at @a __pos to this string. If @a __n is is larger
* than the number of available characters in @a __str, the
* remainder of @a __str is appended.
*/
__versa_string&
append(const __versa_string& __str, size_type __pos, size_type __n)
{ return _M_append(__str._M_data()
+ __str._M_check(__pos, "__versa_string::append"),
__str._M_limit(__pos, __n)); }
/**
* @brief Append a C substring.
* @param __s The C string to append.
* @param __n The number of characters to append.
* @return Reference to this string.
*/
__versa_string&
append(const _CharT* __s, size_type __n)
{
__glibcxx_requires_string_len(__s, __n);
_M_check_length(size_type(0), __n, "__versa_string::append");
return _M_append(__s, __n);
}
/**
* @brief Append a C string.
* @param __s The C string to append.
* @return Reference to this string.
*/
__versa_string&
append(const _CharT* __s)
{
__glibcxx_requires_string(__s);
const size_type __n = traits_type::length(__s);
_M_check_length(size_type(0), __n, "__versa_string::append");
return _M_append(__s, __n);
}
/**
* @brief Append multiple characters.
* @param __n The number of characters to append.
* @param __c The character to use.
* @return Reference to this string.
*
* Appends n copies of c to this string.
*/
__versa_string&
append(size_type __n, _CharT __c)
{ return _M_replace_aux(this->size(), size_type(0), __n, __c); }
#if __cplusplus >= 201103L
/**
* @brief Append an initializer_list of characters.
* @param __l The initializer_list of characters to append.
* @return Reference to this string.
*/
__versa_string&
append(std::initializer_list<_CharT> __l)
{ return this->append(__l.begin(), __l.end()); }
#endif // C++11
/**
* @brief Append a range of characters.
* @param __first Iterator referencing the first character to append.
* @param __last Iterator marking the end of the range.
* @return Reference to this string.
*
* Appends characters in the range [first,last) to this string.
*/
#if __cplusplus >= 201103L
template<class _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
#else
template<class _InputIterator>
#endif
__versa_string&
append(_InputIterator __first, _InputIterator __last)
{ return this->replace(_M_iend(), _M_iend(), __first, __last); }
/**
* @brief Append a single character.
* @param __c Character to append.
*/
void
push_back(_CharT __c)
{
const size_type __size = this->size();
if (__size + 1 > this->capacity() || this->_M_is_shared())
this->_M_mutate(__size, size_type(0), 0, size_type(1));
traits_type::assign(this->_M_data()[__size], __c);
this->_M_set_length(__size + 1);
}
/**
* @brief Set value to contents of another string.
* @param __str Source string to use.
* @return Reference to this string.
*/
__versa_string&
assign(const __versa_string& __str)
{
this->_M_assign(__str);
return *this;
}
#if __cplusplus >= 201103L
/**
* @brief Set value to contents of another string.
* @param __str Source string to use.
* @return Reference to this string.
*
* This function sets this string to the exact contents of @a __str.
* @a __str is a valid, but unspecified string.
*/
__versa_string&
assign(__versa_string&& __str) noexcept
{
this->swap(__str);
return *this;
}
#endif // C++11
/**
* @brief Set value to a substring of a string.
* @param __str The string to use.
* @param __pos Index of the first character of str.
* @param __n Number of characters to use.
* @return Reference to this string.
* @throw std::out_of_range if @a __pos is not a valid index.
*
* This function sets this string to the substring of @a __str
* consisting of @a __n characters at @a __pos. If @a __n is
* is larger than the number of available characters in @a
* __str, the remainder of @a __str is used.
*/
__versa_string&
assign(const __versa_string& __str, size_type __pos, size_type __n)
{ return _M_replace(size_type(0), this->size(), __str._M_data()
+ __str._M_check(__pos, "__versa_string::assign"),
__str._M_limit(__pos, __n)); }
/**
* @brief Set value to a C substring.
* @param __s The C string to use.
* @param __n Number of characters to use.
* @return Reference to this string.
*
* This function sets the value of this string to the first @a
* __n characters of @a __s. If @a __n is is larger than the
* number of available characters in @a __s, the remainder of
* @a __s is used.
*/
__versa_string&
assign(const _CharT* __s, size_type __n)
{
__glibcxx_requires_string_len(__s, __n);
return _M_replace(size_type(0), this->size(), __s, __n);
}
/**
* @brief Set value to contents of a C string.
* @param __s The C string to use.
* @return Reference to this string.
*
* This function sets the value of this string to the value of
* @a __s. The data is copied, so there is no dependence on @a
* __s once the function returns.
*/
__versa_string&
assign(const _CharT* __s)
{
__glibcxx_requires_string(__s);
return _M_replace(size_type(0), this->size(), __s,
traits_type::length(__s));
}
/**
* @brief Set value to multiple characters.
* @param __n Length of the resulting string.
* @param __c The character to use.
* @return Reference to this string.
*
* This function sets the value of this string to @a __n copies of
* character @a __c.
*/
__versa_string&
assign(size_type __n, _CharT __c)
{ return _M_replace_aux(size_type(0), this->size(), __n, __c); }
/**
* @brief Set value to a range of characters.
* @param __first Iterator referencing the first character to append.
* @param __last Iterator marking the end of the range.
* @return Reference to this string.
*
* Sets value of string to characters in the range
* [first,last).
*/
#if __cplusplus >= 201103L
template<class _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
#else
template<class _InputIterator>
#endif
__versa_string&
assign(_InputIterator __first, _InputIterator __last)
{ return this->replace(_M_ibegin(), _M_iend(), __first, __last); }
#if __cplusplus >= 201103L
/**
* @brief Set value to an initializer_list of characters.
* @param __l The initializer_list of characters to assign.
* @return Reference to this string.
*/
__versa_string&
assign(std::initializer_list<_CharT> __l)
{ return this->assign(__l.begin(), __l.end()); }
#endif // C++11
#if __cplusplus >= 201103L
/**
* @brief Insert multiple characters.
* @param __p Const_iterator referencing location in string to
* insert at.
* @param __n Number of characters to insert
* @param __c The character to insert.
* @return Iterator referencing the first inserted char.
* @throw std::length_error If new length exceeds @c max_size().
*
* Inserts @a __n copies of character @a __c starting at the
* position referenced by iterator @a __p. If adding
* characters causes the length to exceed max_size(),
* length_error is thrown. The value of the string doesn't
* change if an error is thrown.
*/
iterator
insert(const_iterator __p, size_type __n, _CharT __c)
{
_GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
const size_type __pos = __p - _M_ibegin();
this->replace(__p, __p, __n, __c);
return iterator(this->_M_data() + __pos);
}
#else
/**
* @brief Insert multiple characters.
* @param __p Iterator referencing location in string to insert at.
* @param __n Number of characters to insert
* @param __c The character to insert.
* @throw std::length_error If new length exceeds @c max_size().
*
* Inserts @a __n copies of character @a __c starting at the
* position referenced by iterator @a __p. If adding
* characters causes the length to exceed max_size(),
* length_error is thrown. The value of the string doesn't
* change if an error is thrown.
*/
void
insert(iterator __p, size_type __n, _CharT __c)
{ this->replace(__p, __p, __n, __c); }
#endif
#if __cplusplus >= 201103L
/**
* @brief Insert a range of characters.
* @param __p Const_iterator referencing location in string to
* insert at.
* @param __beg Start of range.
* @param __end End of range.
* @return Iterator referencing the first inserted char.
* @throw std::length_error If new length exceeds @c max_size().
*
* Inserts characters in range [beg,end). If adding characters
* causes the length to exceed max_size(), length_error is
* thrown. The value of the string doesn't change if an error
* is thrown.
*/
template<class _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
iterator
insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
{
_GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
const size_type __pos = __p - _M_ibegin();
this->replace(__p, __p, __beg, __end);
return iterator(this->_M_data() + __pos);
}
#else
/**
* @brief Insert a range of characters.
* @param __p Iterator referencing location in string to insert at.
* @param __beg Start of range.
* @param __end End of range.
* @throw std::length_error If new length exceeds @c max_size().
*
* Inserts characters in range [beg,end). If adding characters
* causes the length to exceed max_size(), length_error is
* thrown. The value of the string doesn't change if an error
* is thrown.
*/
template<class _InputIterator>
void
insert(iterator __p, _InputIterator __beg, _InputIterator __end)
{ this->replace(__p, __p, __beg, __end); }
#endif
#if __cplusplus >= 201103L
/**
* @brief Insert an initializer_list of characters.
* @param __p Const_iterator referencing location in string to
* insert at.
* @param __l The initializer_list of characters to insert.
* @return Iterator referencing the first inserted char.
* @throw std::length_error If new length exceeds @c max_size().
*/
iterator
insert(const_iterator __p, std::initializer_list<_CharT> __l)
{ return this->insert(__p, __l.begin(), __l.end()); }
#endif // C++11
/**
* @brief Insert value of a string.
* @param __pos1 Iterator referencing location in string to insert at.
* @param __str The string to insert.
* @return Reference to this string.
* @throw std::length_error If new length exceeds @c max_size().
*
* Inserts value of @a __str starting at @a __pos1. If adding
* characters causes the length to exceed max_size(),
* length_error is thrown. The value of the string doesn't
* change if an error is thrown.
*/
__versa_string&
insert(size_type __pos1, const __versa_string& __str)
{ return this->replace(__pos1, size_type(0),
__str._M_data(), __str.size()); }
/**
* @brief Insert a substring.
* @param __pos1 Iterator referencing location in string to insert at.
* @param __str The string to insert.
* @param __pos2 Start of characters in str to insert.
* @param __n Number of characters to insert.
* @return Reference to this string.
* @throw std::length_error If new length exceeds @c max_size().
* @throw std::out_of_range If @a __pos1 > size() or
* @a __pos2 > @a __str.size().
*
* Starting at @a __pos1, insert @a __n character of @a __str
* beginning with @a __pos2. If adding characters causes the
* length to exceed max_size(), length_error is thrown. If @a
* __pos1 is beyond the end of this string or @a __pos2 is
* beyond the end of @a __str, out_of_range is thrown. The
* value of the string doesn't change if an error is thrown.
*/
__versa_string&
insert(size_type __pos1, const __versa_string& __str,
size_type __pos2, size_type __n)
{ return this->replace(__pos1, size_type(0), __str._M_data()
+ __str._M_check(__pos2, "__versa_string::insert"),
__str._M_limit(__pos2, __n)); }
/**
* @brief Insert a C substring.
* @param __pos Iterator referencing location in string to insert at.
* @param __s The C string to insert.
* @param __n The number of characters to insert.
* @return Reference to this string.
* @throw std::length_error If new length exceeds @c max_size().
* @throw std::out_of_range If @a __pos is beyond the end of this
* string.
*
* Inserts the first @a __n characters of @a __s starting at @a
* __pos. If adding characters causes the length to exceed
* max_size(), length_error is thrown. If @a __pos is beyond
* end(), out_of_range is thrown. The value of the string
* doesn't change if an error is thrown.
*/
__versa_string&
insert(size_type __pos, const _CharT* __s, size_type __n)
{ return this->replace(__pos, size_type(0), __s, __n); }
/**
* @brief Insert a C string.
* @param __pos Iterator referencing location in string to insert at.
* @param __s The C string to insert.
* @return Reference to this string.
* @throw std::length_error If new length exceeds @c max_size().
* @throw std::out_of_range If @a __pos is beyond the end of this
* string.
*
* Inserts the first @a __n characters of @a __s starting at @a
* __pos. If adding characters causes the length to exceed
* max_size(), length_error is thrown. If @a __pos is beyond
* end(), out_of_range is thrown. The value of the string
* doesn't change if an error is thrown.
*/
__versa_string&
insert(size_type __pos, const _CharT* __s)
{
__glibcxx_requires_string(__s);
return this->replace(__pos, size_type(0), __s,
traits_type::length(__s));
}
/**
* @brief Insert multiple characters.
* @param __pos Index in string to insert at.
* @param __n Number of characters to insert
* @param __c The character to insert.
* @return Reference to this string.
* @throw std::length_error If new length exceeds @c max_size().
* @throw std::out_of_range If @a __pos is beyond the end of this
* string.
*
* Inserts @a __n copies of character @a __c starting at index
* @a __pos. If adding characters causes the length to exceed
* max_size(), length_error is thrown. If @a __pos > length(),
* out_of_range is thrown. The value of the string doesn't
* change if an error is thrown.
*/
__versa_string&
insert(size_type __pos, size_type __n, _CharT __c)
{ return _M_replace_aux(_M_check(__pos, "__versa_string::insert"),
size_type(0), __n, __c); }
/**
* @brief Insert one character.
* @param __p Iterator referencing position in string to insert at.
* @param __c The character to insert.
* @return Iterator referencing newly inserted char.
* @throw std::length_error If new length exceeds @c max_size().
*
* Inserts character @a __c at position referenced by @a __p.
* If adding character causes the length to exceed max_size(),
* length_error is thrown. If @a __p is beyond end of string,
* out_of_range is thrown. The value of the string doesn't
* change if an error is thrown.
*/
iterator
#if __cplusplus >= 201103L
insert(const_iterator __p, _CharT __c)
#else
insert(iterator __p, _CharT __c)
#endif
{
_GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
const size_type __pos = __p - _M_ibegin();
_M_replace_aux(__pos, size_type(0), size_type(1), __c);
this->_M_set_leaked();
return iterator(this->_M_data() + __pos);
}
/**
* @brief Remove characters.
* @param __pos Index of first character to remove (default 0).
* @param __n Number of characters to remove (default remainder).
* @return Reference to this string.
* @throw std::out_of_range If @a __pos is beyond the end of this
* string.
*
* Removes @a __n characters from this string starting at @a
* __pos. The length of the string is reduced by @a __n. If
* there are < @a __n characters to remove, the remainder of
* the string is truncated. If @a __p is beyond end of string,
* out_of_range is thrown. The value of the string doesn't
* change if an error is thrown.
*/
__versa_string&
erase(size_type __pos = 0, size_type __n = npos)
{
this->_M_erase(_M_check(__pos, "__versa_string::erase"),
_M_limit(__pos, __n));
return *this;
}
/**
* @brief Remove one character.
* @param __position Iterator referencing the character to remove.
* @return iterator referencing same location after removal.
*
* Removes the character at @a __position from this string. The
* value of the string doesn't change if an error is thrown.
*/
iterator
#if __cplusplus >= 201103L
erase(const_iterator __position)
#else
erase(iterator __position)
#endif
{
_GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
&& __position < _M_iend());
const size_type __pos = __position - _M_ibegin();
this->_M_erase(__pos, size_type(1));
this->_M_set_leaked();
return iterator(this->_M_data() + __pos);
}
/**
* @brief Remove a range of characters.
* @param __first Iterator referencing the first character to remove.
* @param __last Iterator referencing the end of the range.
* @return Iterator referencing location of first after removal.
*
* Removes the characters in the range [first,last) from this
* string. The value of the string doesn't change if an error
* is thrown.
*/
iterator
#if __cplusplus >= 201103L
erase(const_iterator __first, const_iterator __last)
#else
erase(iterator __first, iterator __last)
#endif
{
_GLIBCXX_DEBUG_PEDASSERT(__first >= _M_ibegin() && __first <= __last
&& __last <= _M_iend());
const size_type __pos = __first - _M_ibegin();
this->_M_erase(__pos, __last - __first);
this->_M_set_leaked();
return iterator(this->_M_data() + __pos);
}
#if __cplusplus >= 201103L
/**
* @brief Remove the last character.
*
* The string must be non-empty.
*/
void
pop_back()
{ this->_M_erase(size()-1, 1); }
#endif // C++11
/**
* @brief Replace characters with value from another string.
* @param __pos Index of first character to replace.
* @param __n Number of characters to be replaced.
* @param __str String to insert.
* @return Reference to this string.
* @throw std::out_of_range If @a __pos is beyond the end of this
* string.
* @throw std::length_error If new length exceeds @c max_size().
*
* Removes the characters in the range [pos,pos+n) from this
* string. In place, the value of @a __str is inserted. If @a
* __pos is beyond end of string, out_of_range is thrown. If
* the length of the result exceeds max_size(), length_error is
* thrown. The value of the string doesn't change if an error
* is thrown.
*/
__versa_string&
replace(size_type __pos, size_type __n, const __versa_string& __str)
{ return this->replace(__pos, __n, __str._M_data(), __str.size()); }
/**
* @brief Replace characters with value from another string.
* @param __pos1 Index of first character to replace.
* @param __n1 Number of characters to be replaced.
* @param __str String to insert.
* @param __pos2 Index of first character of str to use.
* @param __n2 Number of characters from str to use.
* @return Reference to this string.
* @throw std::out_of_range If @a __pos1 > size() or @a __pos2 >
* str.size().
* @throw std::length_error If new length exceeds @c max_size().
*
* Removes the characters in the range [pos1,pos1 + n) from
* this string. In place, the value of @a __str is inserted.
* If @a __pos is beyond end of string, out_of_range is thrown.
* If the length of the result exceeds max_size(), length_error
* is thrown. The value of the string doesn't change if an
* error is thrown.
*/
__versa_string&
replace(size_type __pos1, size_type __n1, const __versa_string& __str,
size_type __pos2, size_type __n2)
{
return this->replace(__pos1, __n1, __str._M_data()
+ __str._M_check(__pos2,
"__versa_string::replace"),
__str._M_limit(__pos2, __n2));
}
/**
* @brief Replace characters with value of a C substring.
* @param __pos Index of first character to replace.
* @param __n1 Number of characters to be replaced.
* @param __s C string to insert.
* @param __n2 Number of characters from @a __s to use.
* @return Reference to this string.
* @throw std::out_of_range If @a __pos1 > size().
* @throw std::length_error If new length exceeds @c max_size().
*
* Removes the characters in the range [pos,pos + n1) from this
* string. In place, the first @a __n2 characters of @a __s
* are inserted, or all of @a __s if @a __n2 is too large. If
* @a __pos is beyond end of string, out_of_range is thrown.
* If the length of result exceeds max_size(), length_error is
* thrown. The value of the string doesn't change if an error
* is thrown.
*/
__versa_string&
replace(size_type __pos, size_type __n1, const _CharT* __s,
size_type __n2)
{
__glibcxx_requires_string_len(__s, __n2);
return _M_replace(_M_check(__pos, "__versa_string::replace"),
_M_limit(__pos, __n1), __s, __n2);
}
/**
* @brief Replace characters with value of a C string.
* @param __pos Index of first character to replace.
* @param __n1 Number of characters to be replaced.
* @param __s C string to insert.
* @return Reference to this string.
* @throw std::out_of_range If @a __pos > size().
* @throw std::length_error If new length exceeds @c max_size().
*
* Removes the characters in the range [pos,pos + n1) from this
* string. In place, the characters of @a __s are inserted. If
* @a pos is beyond end of string, out_of_range is thrown. If
* the length of result exceeds max_size(), length_error is thrown.
* The value of the string doesn't change if an error is thrown.
*/
__versa_string&
replace(size_type __pos, size_type __n1, const _CharT* __s)
{
__glibcxx_requires_string(__s);
return this->replace(__pos, __n1, __s, traits_type::length(__s));
}
/**
* @brief Replace characters with multiple characters.
* @param __pos Index of first character to replace.
* @param __n1 Number of characters to be replaced.
* @param __n2 Number of characters to insert.
* @param __c Character to insert.
* @return Reference to this string.
* @throw std::out_of_range If @a __pos > size().
* @throw std::length_error If new length exceeds @c max_size().
*
* Removes the characters in the range [pos,pos + n1) from this
* string. In place, @a __n2 copies of @a __c are inserted.
* If @a __pos is beyond end of string, out_of_range is thrown.
* If the length of result exceeds max_size(), length_error is
* thrown. The value of the string doesn't change if an error
* is thrown.
*/
__versa_string&
replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
{ return _M_replace_aux(_M_check(__pos, "__versa_string::replace"),
_M_limit(__pos, __n1), __n2, __c); }
/**
* @brief Replace range of characters with string.
* @param __i1 Iterator referencing start of range to replace.
* @param __i2 Iterator referencing end of range to replace.
* @param __str String value to insert.
* @return Reference to this string.
* @throw std::length_error If new length exceeds @c max_size().
*
* Removes the characters in the range [i1,i2). In place, the
* value of @a __str is inserted. If the length of result
* exceeds max_size(), length_error is thrown. The value of
* the string doesn't change if an error is thrown.
*/
__versa_string&
#if __cplusplus >= 201103L
replace(const_iterator __i1, const_iterator __i2,
const __versa_string& __str)
#else
replace(iterator __i1, iterator __i2, const __versa_string& __str)
#endif
{ return this->replace(__i1, __i2, __str._M_data(), __str.size()); }
/**
* @brief Replace range of characters with C substring.
* @param __i1 Iterator referencing start of range to replace.
* @param __i2 Iterator referencing end of range to replace.
* @param __s C string value to insert.
* @param __n Number of characters from s to insert.
* @return Reference to this string.
* @throw std::length_error If new length exceeds @c max_size().
*
* Removes the characters in the range [i1,i2). In place, the
* first @a n characters of @a __s are inserted. If the length
* of result exceeds max_size(), length_error is thrown. The
* value of the string doesn't change if an error is thrown.
*/
__versa_string&
#if __cplusplus >= 201103L
replace(const_iterator __i1, const_iterator __i2,
const _CharT* __s, size_type __n)
#else
replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n)
#endif
{
_GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
&& __i2 <= _M_iend());
return this->replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
}
/**
* @brief Replace range of characters with C string.
* @param __i1 Iterator referencing start of range to replace.
* @param __i2 Iterator referencing end of range to replace.
* @param __s C string value to insert.
* @return Reference to this string.
* @throw std::length_error If new length exceeds @c max_size().
*
* Removes the characters in the range [i1,i2). In place, the
* characters of @a __s are inserted. If the length of result
* exceeds max_size(), length_error is thrown. The value of
* the string doesn't change if an error is thrown.
*/
__versa_string&
#if __cplusplus >= 201103L
replace(const_iterator __i1, const_iterator __i2, const _CharT* __s)
#else
replace(iterator __i1, iterator __i2, const _CharT* __s)
#endif
{
__glibcxx_requires_string(__s);
return this->replace(__i1, __i2, __s, traits_type::length(__s));
}
/**
* @brief Replace range of characters with multiple characters
* @param __i1 Iterator referencing start of range to replace.
* @param __i2 Iterator referencing end of range to replace.
* @param __n Number of characters to insert.
* @param __c Character to insert.
* @return Reference to this string.
* @throw std::length_error If new length exceeds @c max_size().
*
* Removes the characters in the range [i1,i2). In place, @a
* __n copies of @a __c are inserted. If the length of result
* exceeds max_size(), length_error is thrown. The value of
* the string doesn't change if an error is thrown.
*/
__versa_string&
#if __cplusplus >= 201103L
replace(const_iterator __i1, const_iterator __i2, size_type __n,
_CharT __c)
#else
replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
#endif
{
_GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
&& __i2 <= _M_iend());
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
}
/**
* @brief Replace range of characters with range.
* @param __i1 Iterator referencing start of range to replace.
* @param __i2 Iterator referencing end of range to replace.
* @param __k1 Iterator referencing start of range to insert.
* @param __k2 Iterator referencing end of range to insert.
* @return Reference to this string.
* @throw std::length_error If new length exceeds @c max_size().
*
* Removes the characters in the range [i1,i2). In place,
* characters in the range [k1,k2) are inserted. If the length
* of result exceeds max_size(), length_error is thrown. The
* value of the string doesn't change if an error is thrown.
*/
#if __cplusplus >= 201103L
template<class _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
__versa_string&
replace(const_iterator __i1, const_iterator __i2,
_InputIterator __k1, _InputIterator __k2)
{
_GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
&& __i2 <= _M_iend());
__glibcxx_requires_valid_range(__k1, __k2);
return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
std::__false_type());
}
#else
template<class _InputIterator>
__versa_string&
replace(iterator __i1, iterator __i2,
_InputIterator __k1, _InputIterator __k2)
{
_GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
&& __i2 <= _M_iend());
__glibcxx_requires_valid_range(__k1, __k2);
typedef typename std::__is_integer<_InputIterator>::__type _Integral;
return this->_M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
}
#endif
// Specializations for the common case of pointer and iterator:
// useful to avoid the overhead of temporary buffering in _M_replace.
__versa_string&
#if __cplusplus >= 201103L
replace(const_iterator __i1, const_iterator __i2,
_CharT* __k1, _CharT* __k2)
#else
replace(iterator __i1, iterator __i2,
_CharT* __k1, _CharT* __k2)
#endif
{
_GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
&& __i2 <= _M_iend());
__glibcxx_requires_valid_range(__k1, __k2);
return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
__k1, __k2 - __k1);
}
__versa_string&
#if __cplusplus >= 201103L
replace(const_iterator __i1, const_iterator __i2,
const _CharT* __k1, const _CharT* __k2)
#else
replace(iterator __i1, iterator __i2,
const _CharT* __k1, const _CharT* __k2)
#endif
{
_GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
&& __i2 <= _M_iend());
__glibcxx_requires_valid_range(__k1, __k2);
return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
__k1, __k2 - __k1);
}
__versa_string&
#if __cplusplus >= 201103L
replace(const_iterator __i1, const_iterator __i2,
iterator __k1, iterator __k2)
#else
replace(iterator __i1, iterator __i2,
iterator __k1, iterator __k2)
#endif
{
_GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
&& __i2 <= _M_iend());
__glibcxx_requires_valid_range(__k1, __k2);
return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
__k1.base(), __k2 - __k1);
}
__versa_string&
#if __cplusplus >= 201103L
replace(const_iterator __i1, const_iterator __i2,
const_iterator __k1, const_iterator __k2)
#else
replace(iterator __i1, iterator __i2,
const_iterator __k1, const_iterator __k2)
#endif
{
_GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
&& __i2 <= _M_iend());
__glibcxx_requires_valid_range(__k1, __k2);
return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
__k1.base(), __k2 - __k1);
}
#if __cplusplus >= 201103L
/**
* @brief Replace range of characters with initializer_list.
* @param __i1 Iterator referencing start of range to replace.
* @param __i2 Iterator referencing end of range to replace.
* @param __l The initializer_list of characters to insert.
* @return Reference to this string.
* @throw std::length_error If new length exceeds @c max_size().
*
* Removes the characters in the range [i1,i2). In place,
* characters in the range [k1,k2) are inserted. If the length
* of result exceeds max_size(), length_error is thrown. The
* value of the string doesn't change if an error is thrown.
*/
__versa_string&
replace(const_iterator __i1, const_iterator __i2,
std::initializer_list<_CharT> __l)
{ return this->replace(__i1, __i2, __l.begin(), __l.end()); }
#endif // C++11
private:
template<class _Integer>
__versa_string&
_M_replace_dispatch(const_iterator __i1, const_iterator __i2,
_Integer __n, _Integer __val, std::__true_type)
{ return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
template<class _InputIterator>
__versa_string&
_M_replace_dispatch(const_iterator __i1, const_iterator __i2,
_InputIterator __k1, _InputIterator __k2,
std::__false_type);
__versa_string&
_M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
_CharT __c);
__versa_string&
_M_replace(size_type __pos, size_type __len1, const _CharT* __s,
const size_type __len2);
__versa_string&
_M_append(const _CharT* __s, size_type __n);
public:
/**
* @brief Copy substring into C string.
* @param __s C string to copy value into.
* @param __n Number of characters to copy.
* @param __pos Index of first character to copy.
* @return Number of characters actually copied
* @throw std::out_of_range If pos > size().
*
* Copies up to @a __n characters starting at @a __pos into the
* C string @a s. If @a __pos is greater than size(),
* out_of_range is thrown.
*/
size_type
copy(_CharT* __s, size_type __n, size_type __pos = 0) const;
/**
* @brief Swap contents with another string.
* @param __s String to swap with.
*
* Exchanges the contents of this string with that of @a __s in
* constant time.
*/
void
swap(__versa_string& __s) _GLIBCXX_NOEXCEPT
{ this->_M_swap(__s); }
// String operations:
/**
* @brief Return const pointer to null-terminated contents.
*
* This is a handle to internal data. Do not modify or dire things may
* happen.
*/
const _CharT*
c_str() const _GLIBCXX_NOEXCEPT
{ return this->_M_data(); }
/**
* @brief Return const pointer to contents.
*
* This is a handle to internal data. Do not modify or dire things may
* happen.
*/
const _CharT*
data() const _GLIBCXX_NOEXCEPT
{ return this->_M_data(); }
/**
* @brief Return copy of allocator used to construct this string.
*/
allocator_type
get_allocator() const _GLIBCXX_NOEXCEPT
{ return allocator_type(this->_M_get_allocator()); }
/**
* @brief Find position of a C substring.
* @param __s C string to locate.
* @param __pos Index of character to search from.
* @param __n Number of characters from @a __s to search for.
* @return Index of start of first occurrence.
*
* Starting from @a __pos, searches forward for the first @a
* __n characters in @a __s within this string. If found,
* returns the index where it begins. If not found, returns
* npos.
*/
size_type
find(const _CharT* __s, size_type __pos, size_type __n) const;
/**
* @brief Find position of a string.
* @param __str String to locate.
* @param __pos Index of character to search from (default 0).
* @return Index of start of first occurrence.
*
* Starting from @a __pos, searches forward for value of @a
* __str within this string. If found, returns the index where
* it begins. If not found, returns npos.
*/
size_type
find(const __versa_string& __str, size_type __pos = 0) const
_GLIBCXX_NOEXCEPT
{ return this->find(__str.data(), __pos, __str.size()); }
/**
* @brief Find position of a C string.
* @param __s C string to locate.
* @param __pos Index of character to search from (default 0).
* @return Index of start of first occurrence.
*
* Starting from @a __pos, searches forward for the value of @a
* __s within this string. If found, returns the index where
* it begins. If not found, returns npos.
*/
size_type
find(const _CharT* __s, size_type __pos = 0) const
{
__glibcxx_requires_string(__s);
return this->find(__s, __pos, traits_type::length(__s));
}
/**
* @brief Find position of a character.
* @param __c Character to locate.
* @param __pos Index of character to search from (default 0).
* @return Index of first occurrence.
*
* Starting from @a __pos, searches forward for @a __c within
* this string. If found, returns the index where it was
* found. If not found, returns npos.
*/
size_type
find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
/**
* @brief Find last position of a string.
* @param __str String to locate.
* @param __pos Index of character to search back from (default end).
* @return Index of start of last occurrence.
*
* Starting from @a __pos, searches backward for value of @a
* __str within this string. If found, returns the index where
* it begins. If not found, returns npos.
*/
size_type
rfind(const __versa_string& __str, size_type __pos = npos) const
_GLIBCXX_NOEXCEPT
{ return this->rfind(__str.data(), __pos, __str.size()); }
/**
* @brief Find last position of a C substring.
* @param __s C string to locate.
* @param __pos Index of character to search back from.
* @param __n Number of characters from s to search for.
* @return Index of start of last occurrence.
*
* Starting from @a __pos, searches backward for the first @a
* __n characters in @a __s within this string. If found,
* returns the index where it begins. If not found, returns
* npos.
*/
size_type
rfind(const _CharT* __s, size_type __pos, size_type __n) const;
/**
* @brief Find last position of a C string.
* @param __s C string to locate.
* @param __pos Index of character to start search at (default end).
* @return Index of start of last occurrence.
*
* Starting from @a __pos, searches backward for the value of
* @a __s within this string. If found, returns the index
* where it begins. If not found, returns npos.
*/
size_type
rfind(const _CharT* __s, size_type __pos = npos) const
{
__glibcxx_requires_string(__s);
return this->rfind(__s, __pos, traits_type::length(__s));
}
/**
* @brief Find last position of a character.
* @param __c Character to locate.
* @param __pos Index of character to search back from (default end).
* @return Index of last occurrence.
*
* Starting from @a __pos, searches backward for @a __c within
* this string. If found, returns the index where it was
* found. If not found, returns npos.
*/
size_type
rfind(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT;
/**
* @brief Find position of a character of string.
* @param __str String containing characters to locate.
* @param __pos Index of character to search from (default 0).
* @return Index of first occurrence.
*
* Starting from @a __pos, searches forward for one of the characters of
* @a __str within this string. If found, returns the index where it was
* found. If not found, returns npos.
*/
size_type
find_first_of(const __versa_string& __str, size_type __pos = 0) const
_GLIBCXX_NOEXCEPT
{ return this->find_first_of(__str.data(), __pos, __str.size()); }
/**
* @brief Find position of a character of C substring.
* @param __s String containing characters to locate.
* @param __pos Index of character to search from.
* @param __n Number of characters from s to search for.
* @return Index of first occurrence.
*
* Starting from @a __pos, searches forward for one of the
* first @a __n characters of @a __s within this string. If
* found, returns the index where it was found. If not found,
* returns npos.
*/
size_type
find_first_of(const _CharT* __s, size_type __pos, size_type __n) const;
/**
* @brief Find position of a character of C string.
* @param __s String containing characters to locate.
* @param __pos Index of character to search from (default 0).
* @return Index of first occurrence.
*
* Starting from @a __pos, searches forward for one of the
* characters of @a __s within this string. If found, returns
* the index where it was found. If not found, returns npos.
*/
size_type
find_first_of(const _CharT* __s, size_type __pos = 0) const
{
__glibcxx_requires_string(__s);
return this->find_first_of(__s, __pos, traits_type::length(__s));
}
/**
* @brief Find position of a character.
* @param __c Character to locate.
* @param __pos Index of character to search from (default 0).
* @return Index of first occurrence.
*
* Starting from @a __pos, searches forward for the character
* @a __c within this string. If found, returns the index
* where it was found. If not found, returns npos.
*
* Note: equivalent to find(c, pos).
*/
size_type
find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
{ return this->find(__c, __pos); }
/**
* @brief Find last position of a character of string.
* @param __str String containing characters to locate.
* @param __pos Index of character to search back from (default end).
* @return Index of last occurrence.
*
* Starting from @a __pos, searches backward for one of the
* characters of @a __str within this string. If found,
* returns the index where it was found. If not found, returns
* npos.
*/
size_type
find_last_of(const __versa_string& __str, size_type __pos = npos) const
_GLIBCXX_NOEXCEPT
{ return this->find_last_of(__str.data(), __pos, __str.size()); }
/**
* @brief Find last position of a character of C substring.
* @param __s C string containing characters to locate.
* @param __pos Index of character to search back from.
* @param __n Number of characters from s to search for.
* @return Index of last occurrence.
*
* Starting from @a __pos, searches backward for one of the
* first @a __n characters of @a __s within this string. If
* found, returns the index where it was found. If not found,
* returns npos.
*/
size_type
find_last_of(const _CharT* __s, size_type __pos, size_type __n) const;
/**
* @brief Find last position of a character of C string.
* @param __s C string containing characters to locate.
* @param __pos Index of character to search back from (default end).
* @return Index of last occurrence.
*
* Starting from @a __pos, searches backward for one of the
* characters of @a __s within this string. If found, returns
* the index where it was found. If not found, returns npos.
*/
size_type
find_last_of(const _CharT* __s, size_type __pos = npos) const
{
__glibcxx_requires_string(__s);
return this->find_last_of(__s, __pos, traits_type::length(__s));
}
/**
* @brief Find last position of a character.
* @param __c Character to locate.
* @param __pos Index of character to search back from (default end).
* @return Index of last occurrence.
*
* Starting from @a __pos, searches backward for @a __c within
* this string. If found, returns the index where it was
* found. If not found, returns npos.
*
* Note: equivalent to rfind(c, pos).
*/
size_type
find_last_of(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT
{ return this->rfind(__c, __pos); }
/**
* @brief Find position of a character not in string.
* @param __str String containing characters to avoid.
* @param __pos Index of character to search from (default 0).
* @return Index of first occurrence.
*
* Starting from @a __pos, searches forward for a character not
* contained in @a __str within this string. If found, returns
* the index where it was found. If not found, returns npos.
*/
size_type
find_first_not_of(const __versa_string& __str, size_type __pos = 0) const
_GLIBCXX_NOEXCEPT
{ return this->find_first_not_of(__str.data(), __pos, __str.size()); }
/**
* @brief Find position of a character not in C substring.
* @param __s C string containing characters to avoid.
* @param __pos Index of character to search from.
* @param __n Number of characters from s to consider.
* @return Index of first occurrence.
*
* Starting from @a __pos, searches forward for a character not
* contained in the first @a __n characters of @a __s within
* this string. If found, returns the index where it was
* found. If not found, returns npos.
*/
size_type
find_first_not_of(const _CharT* __s, size_type __pos,
size_type __n) const;
/**
* @brief Find position of a character not in C string.
* @param __s C string containing characters to avoid.
* @param __pos Index of character to search from (default 0).
* @return Index of first occurrence.
*
* Starting from @a __pos, searches forward for a character not
* contained in @a __s within this string. If found, returns
* the index where it was found. If not found, returns npos.
*/
size_type
find_first_not_of(const _CharT* __s, size_type __pos = 0) const
{
__glibcxx_requires_string(__s);
return this->find_first_not_of(__s, __pos, traits_type::length(__s));
}
/**
* @brief Find position of a different character.
* @param __c Character to avoid.
* @param __pos Index of character to search from (default 0).
* @return Index of first occurrence.
*
* Starting from @a __pos, searches forward for a character
* other than @a __c within this string. If found, returns the
* index where it was found. If not found, returns npos.
*/
size_type
find_first_not_of(_CharT __c, size_type __pos = 0) const
_GLIBCXX_NOEXCEPT;
/**
* @brief Find last position of a character not in string.
* @param __str String containing characters to avoid.
* @param __pos Index of character to search back from (default end).
* @return Index of last occurrence.
*
* Starting from @a __pos, searches backward for a character
* not contained in @a __str within this string. If found,
* returns the index where it was found. If not found, returns
* npos.
*/
size_type
find_last_not_of(const __versa_string& __str,
size_type __pos = npos) const _GLIBCXX_NOEXCEPT
{ return this->find_last_not_of(__str.data(), __pos, __str.size()); }
/**
* @brief Find last position of a character not in C substring.
* @param __s C string containing characters to avoid.
* @param __pos Index of character to search back from.
* @param __n Number of characters from s to consider.
* @return Index of last occurrence.
*
* Starting from @a __pos, searches backward for a character
* not contained in the first @a __n characters of @a __s
* within this string. If found, returns the index where it
* was found. If not found, returns npos.
*/
size_type
find_last_not_of(const _CharT* __s, size_type __pos,
size_type __n) const;
/**
* @brief Find last position of a character not in C string.
* @param __s C string containing characters to avoid.
* @param __pos Index of character to search back from (default end).
* @return Index of last occurrence.
*
* Starting from @a __pos, searches backward for a character
* not contained in @a __s within this string. If found,
* returns the index where it was found. If not found, returns
* npos.
*/
size_type
find_last_not_of(const _CharT* __s, size_type __pos = npos) const
{
__glibcxx_requires_string(__s);
return this->find_last_not_of(__s, __pos, traits_type::length(__s));
}
/**
* @brief Find last position of a different character.
* @param __c Character to avoid.
* @param __pos Index of character to search back from (default end).
* @return Index of last occurrence.
*
* Starting from @a __pos, searches backward for a character
* other than @a __c within this string. If found, returns the
* index where it was found. If not found, returns npos.
*/
size_type
find_last_not_of(_CharT __c, size_type __pos = npos) const
_GLIBCXX_NOEXCEPT;
/**
* @brief Get a substring.
* @param __pos Index of first character (default 0).
* @param __n Number of characters in substring (default remainder).
* @return The new string.
* @throw std::out_of_range If pos > size().
*
* Construct and return a new string using the @a __n
* characters starting at @a __pos. If the string is too
* short, use the remainder of the characters. If @a __pos is
* beyond the end of the string, out_of_range is thrown.
*/
__versa_string
substr(size_type __pos = 0, size_type __n = npos) const
{
return __versa_string(*this, _M_check(__pos, "__versa_string::substr"),
__n);
}
/**
* @brief Compare to a string.
* @param __str String to compare against.
* @return Integer < 0, 0, or > 0.
*
* Returns an integer < 0 if this string is ordered before @a
* __str, 0 if their values are equivalent, or > 0 if this
* string is ordered after @a __str. Determines the effective
* length rlen of the strings to compare as the smallest of
* size() and str.size(). The function then compares the two
* strings by calling traits::compare(data(), str.data(),rlen).
* If the result of the comparison is nonzero returns it,
* otherwise the shorter one is ordered first.
*/
int
compare(const __versa_string& __str) const
{
if (this->_M_compare(__str))
return 0;
const size_type __size = this->size();
const size_type __osize = __str.size();
const size_type __len = std::min(__size, __osize);
int __r = traits_type::compare(this->_M_data(), __str.data(), __len);
if (!__r)
__r = this->_S_compare(__size, __osize);
return __r;
}
/**
* @brief Compare substring to a string.
* @param __pos Index of first character of substring.
* @param __n Number of characters in substring.
* @param __str String to compare against.
* @return Integer < 0, 0, or > 0.
*
* Form the substring of this string from the @a __n characters
* starting at @a __pos. Returns an integer < 0 if the
* substring is ordered before @a __str, 0 if their values are
* equivalent, or > 0 if the substring is ordered after @a
* __str. Determines the effective length rlen of the strings
* to compare as the smallest of the length of the substring
* and @a __str.size(). The function then compares the two
* strings by calling
* traits::compare(substring.data(),str.data(),rlen). If the
* result of the comparison is nonzero returns it, otherwise
* the shorter one is ordered first.
*/
int
compare(size_type __pos, size_type __n,
const __versa_string& __str) const;
/**
* @brief Compare substring to a substring.
* @param __pos1 Index of first character of substring.
* @param __n1 Number of characters in substring.
* @param __str String to compare against.
* @param __pos2 Index of first character of substring of str.
* @param __n2 Number of characters in substring of str.
* @return Integer < 0, 0, or > 0.
*
* Form the substring of this string from the @a __n1
* characters starting at @a __pos1. Form the substring of @a
* __str from the @a __n2 characters starting at @a __pos2.
* Returns an integer < 0 if this substring is ordered before
* the substring of @a __str, 0 if their values are equivalent,
* or > 0 if this substring is ordered after the substring of
* @a __str. Determines the effective length rlen of the
* strings to compare as the smallest of the lengths of the
* substrings. The function then compares the two strings by
* calling
* traits::compare(substring.data(),str.substr(pos2,n2).data(),rlen).
* If the result of the comparison is nonzero returns it,
* otherwise the shorter one is ordered first.
*/
int
compare(size_type __pos1, size_type __n1, const __versa_string& __str,
size_type __pos2, size_type __n2) const;
/**
* @brief Compare to a C string.
* @param __s C string to compare against.
* @return Integer < 0, 0, or > 0.
*
* Returns an integer < 0 if this string is ordered before @a
* __s, 0 if their values are equivalent, or > 0 if this string
* is ordered after @a __s. Determines the effective length
* rlen of the strings to compare as the smallest of size() and
* the length of a string constructed from @a __s. The
* function then compares the two strings by calling
* traits::compare(data(),s,rlen). If the result of the
* comparison is nonzero returns it, otherwise the shorter one
* is ordered first.
*/
int
compare(const _CharT* __s) const;
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 5 String::compare specification questionable
/**
* @brief Compare substring to a C string.
* @param __pos Index of first character of substring.
* @param __n1 Number of characters in substring.
* @param __s C string to compare against.
* @return Integer < 0, 0, or > 0.
*
* Form the substring of this string from the @a __n1
* characters starting at @a __pos. Returns an integer < 0 if
* the substring is ordered before @a __s, 0 if their values
* are equivalent, or > 0 if the substring is ordered after @a
* __s. Determines the effective length rlen of the strings to
* compare as the smallest of the length of the substring and
* the length of a string constructed from @a __s. The
* function then compares the two string by calling
* traits::compare(substring.data(),s,rlen). If the result of
* the comparison is nonzero returns it, otherwise the shorter
* one is ordered first.
*/
int
compare(size_type __pos, size_type __n1, const _CharT* __s) const;
/**
* @brief Compare substring against a character array.
* @param __pos Index of first character of substring.
* @param __n1 Number of characters in substring.
* @param __s character array to compare against.
* @param __n2 Number of characters of s.
* @return Integer < 0, 0, or > 0.
*
* Form the substring of this string from the @a __n1
* characters starting at @a __pos. Form a string from the
* first @a __n2 characters of @a __s. Returns an integer < 0
* if this substring is ordered before the string from @a __s,
* 0 if their values are equivalent, or > 0 if this substring
* is ordered after the string from @a __s. Determines the
* effective length rlen of the strings to compare as the
* smallest of the length of the substring and @a __n2. The
* function then compares the two strings by calling
* traits::compare(substring.data(),__s,rlen). If the result of
* the comparison is nonzero returns it, otherwise the shorter
* one is ordered first.
*
* NB: __s must have at least n2 characters, <em>\\0</em> has no special
* meaning.
*/
int
compare(size_type __pos, size_type __n1, const _CharT* __s,
size_type __n2) const;
};
// operator+
/**
* @brief Concatenate two strings.
* @param __lhs First string.
* @param __rhs Last string.
* @return New string with value of @a __lhs followed by @a __rhs.
*/
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
__versa_string<_CharT, _Traits, _Alloc, _Base>
operator+(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs);
/**
* @brief Concatenate C string and string.
* @param __lhs First string.
* @param __rhs Last string.
* @return New string with value of @a __lhs followed by @a __rhs.
*/
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
__versa_string<_CharT, _Traits, _Alloc, _Base>
operator+(const _CharT* __lhs,
const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs);
/**
* @brief Concatenate character and string.
* @param __lhs First string.
* @param __rhs Last string.
* @return New string with @a __lhs followed by @a __rhs.
*/
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
__versa_string<_CharT, _Traits, _Alloc, _Base>
operator+(_CharT __lhs,
const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs);
/**
* @brief Concatenate string and C string.
* @param __lhs First string.
* @param __rhs Last string.
* @return New string with @a __lhs followed by @a __rhs.
*/
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
__versa_string<_CharT, _Traits, _Alloc, _Base>
operator+(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
const _CharT* __rhs);
/**
* @brief Concatenate string and character.
* @param __lhs First string.
* @param __rhs Last string.
* @return New string with @a __lhs followed by @a __rhs.
*/
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
__versa_string<_CharT, _Traits, _Alloc, _Base>
operator+(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
_CharT __rhs);
#if __cplusplus >= 201103L
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
inline __versa_string<_CharT, _Traits, _Alloc, _Base>
operator+(__versa_string<_CharT, _Traits, _Alloc, _Base>&& __lhs,
const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
{ return std::move(__lhs.append(__rhs)); }
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
inline __versa_string<_CharT, _Traits, _Alloc, _Base>
operator+(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
__versa_string<_CharT, _Traits, _Alloc, _Base>&& __rhs)
{ return std::move(__rhs.insert(0, __lhs)); }
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
inline __versa_string<_CharT, _Traits, _Alloc, _Base>
operator+(__versa_string<_CharT, _Traits, _Alloc, _Base>&& __lhs,
__versa_string<_CharT, _Traits, _Alloc, _Base>&& __rhs)
{
const auto __size = __lhs.size() + __rhs.size();
const bool __cond = (__size > __lhs.capacity()
&& __size <= __rhs.capacity());
return __cond ? std::move(__rhs.insert(0, __lhs))
: std::move(__lhs.append(__rhs));
}
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
inline __versa_string<_CharT, _Traits, _Alloc, _Base>
operator+(const _CharT* __lhs,
__versa_string<_CharT, _Traits, _Alloc, _Base>&& __rhs)
{ return std::move(__rhs.insert(0, __lhs)); }
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
inline __versa_string<_CharT, _Traits, _Alloc, _Base>
operator+(_CharT __lhs,
__versa_string<_CharT, _Traits, _Alloc, _Base>&& __rhs)
{ return std::move(__rhs.insert(0, 1, __lhs)); }
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
inline __versa_string<_CharT, _Traits, _Alloc, _Base>
operator+(__versa_string<_CharT, _Traits, _Alloc, _Base>&& __lhs,
const _CharT* __rhs)
{ return std::move(__lhs.append(__rhs)); }
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
inline __versa_string<_CharT, _Traits, _Alloc, _Base>
operator+(__versa_string<_CharT, _Traits, _Alloc, _Base>&& __lhs,
_CharT __rhs)
{ return std::move(__lhs.append(1, __rhs)); }
#endif
// operator ==
/**
* @brief Test equivalence of two strings.
* @param __lhs First string.
* @param __rhs Second string.
* @return True if @a __lhs.compare(@a __rhs) == 0. False otherwise.
*/
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
inline bool
operator==(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
{ return __lhs.compare(__rhs) == 0; }
template<typename _CharT,
template <typename, typename, typename> class _Base>
inline typename __enable_if<std::__is_char<_CharT>::__value, bool>::__type
operator==(const __versa_string<_CharT, std::char_traits<_CharT>,
std::allocator<_CharT>, _Base>& __lhs,
const __versa_string<_CharT, std::char_traits<_CharT>,
std::allocator<_CharT>, _Base>& __rhs)
{ return (__lhs.size() == __rhs.size()
&& !std::char_traits<_CharT>::compare(__lhs.data(), __rhs.data(),
__lhs.size())); }
/**
* @brief Test equivalence of C string and string.
* @param __lhs C string.
* @param __rhs String.
* @return True if @a __rhs.compare(@a __lhs) == 0. False otherwise.
*/
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
inline bool
operator==(const _CharT* __lhs,
const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
{ return __rhs.compare(__lhs) == 0; }
/**
* @brief Test equivalence of string and C string.
* @param __lhs String.
* @param __rhs C string.
* @return True if @a __lhs.compare(@a __rhs) == 0. False otherwise.
*/
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
inline bool
operator==(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
const _CharT* __rhs)
{ return __lhs.compare(__rhs) == 0; }
// operator !=
/**
* @brief Test difference of two strings.
* @param __lhs First string.
* @param __rhs Second string.
* @return True if @a __lhs.compare(@a __rhs) != 0. False otherwise.
*/
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
inline bool
operator!=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
{ return !(__lhs == __rhs); }
/**
* @brief Test difference of C string and string.
* @param __lhs C string.
* @param __rhs String.
* @return True if @a __rhs.compare(@a __lhs) != 0. False otherwise.
*/
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
inline bool
operator!=(const _CharT* __lhs,
const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
{ return !(__lhs == __rhs); }
/**
* @brief Test difference of string and C string.
* @param __lhs String.
* @param __rhs C string.
* @return True if @a __lhs.compare(@a __rhs) != 0. False otherwise.
*/
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
inline bool
operator!=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
const _CharT* __rhs)
{ return !(__lhs == __rhs); }
// operator <
/**
* @brief Test if string precedes string.
* @param __lhs First string.
* @param __rhs Second string.
* @return True if @a __lhs precedes @a __rhs. False otherwise.
*/
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
inline bool
operator<(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
{ return __lhs.compare(__rhs) < 0; }
/**
* @brief Test if string precedes C string.
* @param __lhs String.
* @param __rhs C string.
* @return True if @a __lhs precedes @a __rhs. False otherwise.
*/
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
inline bool
operator<(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
const _CharT* __rhs)
{ return __lhs.compare(__rhs) < 0; }
/**
* @brief Test if C string precedes string.
* @param __lhs C string.
* @param __rhs String.
* @return True if @a __lhs precedes @a __rhs. False otherwise.
*/
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
inline bool
operator<(const _CharT* __lhs,
const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
{ return __rhs.compare(__lhs) > 0; }
// operator >
/**
* @brief Test if string follows string.
* @param __lhs First string.
* @param __rhs Second string.
* @return True if @a __lhs follows @a __rhs. False otherwise.
*/
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
inline bool
operator>(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
{ return __lhs.compare(__rhs) > 0; }
/**
* @brief Test if string follows C string.
* @param __lhs String.
* @param __rhs C string.
* @return True if @a __lhs follows @a __rhs. False otherwise.
*/
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
inline bool
operator>(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
const _CharT* __rhs)
{ return __lhs.compare(__rhs) > 0; }
/**
* @brief Test if C string follows string.
* @param __lhs C string.
* @param __rhs String.
* @return True if @a __lhs follows @a __rhs. False otherwise.
*/
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
inline bool
operator>(const _CharT* __lhs,
const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
{ return __rhs.compare(__lhs) < 0; }
// operator <=
/**
* @brief Test if string doesn't follow string.
* @param __lhs First string.
* @param __rhs Second string.
* @return True if @a __lhs doesn't follow @a __rhs. False otherwise.
*/
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
inline bool
operator<=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
{ return __lhs.compare(__rhs) <= 0; }
/**
* @brief Test if string doesn't follow C string.
* @param __lhs String.
* @param __rhs C string.
* @return True if @a __lhs doesn't follow @a __rhs. False otherwise.
*/
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
inline bool
operator<=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
const _CharT* __rhs)
{ return __lhs.compare(__rhs) <= 0; }
/**
* @brief Test if C string doesn't follow string.
* @param __lhs C string.
* @param __rhs String.
* @return True if @a __lhs doesn't follow @a __rhs. False otherwise.
*/
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
inline bool
operator<=(const _CharT* __lhs,
const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
{ return __rhs.compare(__lhs) >= 0; }
// operator >=
/**
* @brief Test if string doesn't precede string.
* @param __lhs First string.
* @param __rhs Second string.
* @return True if @a __lhs doesn't precede @a __rhs. False otherwise.
*/
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
inline bool
operator>=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
{ return __lhs.compare(__rhs) >= 0; }
/**
* @brief Test if string doesn't precede C string.
* @param __lhs String.
* @param __rhs C string.
* @return True if @a __lhs doesn't precede @a __rhs. False otherwise.
*/
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
inline bool
operator>=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
const _CharT* __rhs)
{ return __lhs.compare(__rhs) >= 0; }
/**
* @brief Test if C string doesn't precede string.
* @param __lhs C string.
* @param __rhs String.
* @return True if @a __lhs doesn't precede @a __rhs. False otherwise.
*/
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
inline bool
operator>=(const _CharT* __lhs,
const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
{ return __rhs.compare(__lhs) <= 0; }
/**
* @brief Swap contents of two strings.
* @param __lhs First string.
* @param __rhs Second string.
*
* Exchanges the contents of @a __lhs and @a __rhs in constant time.
*/
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
inline void
swap(__versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
__versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
{ __lhs.swap(__rhs); }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @brief Read stream into a string.
* @param __is Input stream.
* @param __str Buffer to store into.
* @return Reference to the input stream.
*
* Stores characters from @a __is into @a __str until whitespace is
* found, the end of the stream is encountered, or str.max_size()
* is reached. If is.width() is non-zero, that is the limit on the
* number of characters stored into @a __str. Any previous
* contents of @a __str are erased.
*/
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
__gnu_cxx::__versa_string<_CharT, _Traits,
_Alloc, _Base>& __str);
/**
* @brief Write string to a stream.
* @param __os Output stream.
* @param __str String to write out.
* @return Reference to the output stream.
*
* Output characters of @a __str into os following the same rules as for
* writing a C string.
*/
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
inline basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
const __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc,
_Base>& __str)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 586. string inserter not a formatted function
return __ostream_insert(__os, __str.data(), __str.size());
}
/**
* @brief Read a line from stream into a string.
* @param __is Input stream.
* @param __str Buffer to store into.
* @param __delim Character marking end of line.
* @return Reference to the input stream.
*
* Stores characters from @a __is into @a __str until @a __delim is
* found, the end of the stream is encountered, or str.max_size()
* is reached. If is.width() is non-zero, that is the limit on the
* number of characters stored into @a __str. Any previous
* contents of @a __str are erased. If @a delim was encountered,
* it is extracted but not stored into @a __str.
*/
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
basic_istream<_CharT, _Traits>&
getline(basic_istream<_CharT, _Traits>& __is,
__gnu_cxx::__versa_string<_CharT, _Traits, _Alloc, _Base>& __str,
_CharT __delim);
/**
* @brief Read a line from stream into a string.
* @param __is Input stream.
* @param __str Buffer to store into.
* @return Reference to the input stream.
*
* Stores characters from is into @a __str until '\n' is
* found, the end of the stream is encountered, or str.max_size()
* is reached. If is.width() is non-zero, that is the limit on the
* number of characters stored into @a __str. Any previous
* contents of @a __str are erased. If end of line was
* encountered, it is extracted but not stored into @a __str.
*/
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
inline basic_istream<_CharT, _Traits>&
getline(basic_istream<_CharT, _Traits>& __is,
__gnu_cxx::__versa_string<_CharT, _Traits, _Alloc, _Base>& __str)
{ return getline(__is, __str, __is.widen('\n')); }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#if __cplusplus >= 201103L
#include <ext/string_conversions.h>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
#if _GLIBCXX_USE_C99_STDLIB
// 21.4 Numeric Conversions [string.conversions].
inline int
stoi(const __vstring& __str, std::size_t* __idx = 0, int __base = 10)
{ return __gnu_cxx::__stoa<long, int>(&std::strtol, "stoi", __str.c_str(),
__idx, __base); }
inline long
stol(const __vstring& __str, std::size_t* __idx = 0, int __base = 10)
{ return __gnu_cxx::__stoa(&std::strtol, "stol", __str.c_str(),
__idx, __base); }
inline unsigned long
stoul(const __vstring& __str, std::size_t* __idx = 0, int __base = 10)
{ return __gnu_cxx::__stoa(&std::strtoul, "stoul", __str.c_str(),
__idx, __base); }
inline long long
stoll(const __vstring& __str, std::size_t* __idx = 0, int __base = 10)
{ return __gnu_cxx::__stoa(&std::strtoll, "stoll", __str.c_str(),
__idx, __base); }
inline unsigned long long
stoull(const __vstring& __str, std::size_t* __idx, int __base = 10)
{ return __gnu_cxx::__stoa(&std::strtoull, "stoull", __str.c_str(),
__idx, __base); }
// NB: strtof vs strtod.
inline float
stof(const __vstring& __str, std::size_t* __idx = 0)
{ return __gnu_cxx::__stoa(&std::strtof, "stof", __str.c_str(), __idx); }
inline double
stod(const __vstring& __str, std::size_t* __idx = 0)
{ return __gnu_cxx::__stoa(&std::strtod, "stod", __str.c_str(), __idx); }
inline long double
stold(const __vstring& __str, std::size_t* __idx = 0)
{ return __gnu_cxx::__stoa(&std::strtold, "stold", __str.c_str(), __idx); }
#endif // _GLIBCXX_USE_C99_STDLIB
#if _GLIBCXX_USE_C99_STDIO
// NB: (v)snprintf vs sprintf.
// DR 1261.
inline __vstring
to_string(int __val)
{ return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf, 4 * sizeof(int),
"%d", __val); }
inline __vstring
to_string(unsigned __val)
{ return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf,
4 * sizeof(unsigned),
"%u", __val); }
inline __vstring
to_string(long __val)
{ return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf,
4 * sizeof(long),
"%ld", __val); }
inline __vstring
to_string(unsigned long __val)
{ return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf,
4 * sizeof(unsigned long),
"%lu", __val); }
inline __vstring
to_string(long long __val)
{ return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf,
4 * sizeof(long long),
"%lld", __val); }
inline __vstring
to_string(unsigned long long __val)
{ return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf,
4 * sizeof(unsigned long long),
"%llu", __val); }
inline __vstring
to_string(float __val)
{
const int __n = __numeric_traits<float>::__max_exponent10 + 20;
return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf, __n,
"%f", __val);
}
inline __vstring
to_string(double __val)
{
const int __n = __numeric_traits<double>::__max_exponent10 + 20;
return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf, __n,
"%f", __val);
}
inline __vstring
to_string(long double __val)
{
const int __n = __numeric_traits<long double>::__max_exponent10 + 20;
return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf, __n,
"%Lf", __val);
}
#endif // _GLIBCXX_USE_C99_STDIO
#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
inline int
stoi(const __wvstring& __str, std::size_t* __idx = 0, int __base = 10)
{ return __gnu_cxx::__stoa<long, int>(&std::wcstol, "stoi", __str.c_str(),
__idx, __base); }
inline long
stol(const __wvstring& __str, std::size_t* __idx = 0, int __base = 10)
{ return __gnu_cxx::__stoa(&std::wcstol, "stol", __str.c_str(),
__idx, __base); }
inline unsigned long
stoul(const __wvstring& __str, std::size_t* __idx = 0, int __base = 10)
{ return __gnu_cxx::__stoa(&std::wcstoul, "stoul", __str.c_str(),
__idx, __base); }
inline long long
stoll(const __wvstring& __str, std::size_t* __idx = 0, int __base = 10)
{ return __gnu_cxx::__stoa(&std::wcstoll, "stoll", __str.c_str(),
__idx, __base); }
inline unsigned long long
stoull(const __wvstring& __str, std::size_t* __idx = 0, int __base = 10)
{ return __gnu_cxx::__stoa(&std::wcstoull, "stoull", __str.c_str(),
__idx, __base); }
// NB: wcstof vs wcstod.
inline float
stof(const __wvstring& __str, std::size_t* __idx = 0)
{ return __gnu_cxx::__stoa(&std::wcstof, "stof", __str.c_str(), __idx); }
inline double
stod(const __wvstring& __str, std::size_t* __idx = 0)
{ return __gnu_cxx::__stoa(&std::wcstod, "stod", __str.c_str(), __idx); }
inline long double
stold(const __wvstring& __str, std::size_t* __idx = 0)
{ return __gnu_cxx::__stoa(&std::wcstold, "stold", __str.c_str(), __idx); }
#ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
// DR 1261.
inline __wvstring
to_wstring(int __val)
{ return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf,
4 * sizeof(int),
L"%d", __val); }
inline __wvstring
to_wstring(unsigned __val)
{ return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf,
4 * sizeof(unsigned),
L"%u", __val); }
inline __wvstring
to_wstring(long __val)
{ return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf,
4 * sizeof(long),
L"%ld", __val); }
inline __wvstring
to_wstring(unsigned long __val)
{ return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf,
4 * sizeof(unsigned long),
L"%lu", __val); }
inline __wvstring
to_wstring(long long __val)
{ return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf,
4 * sizeof(long long),
L"%lld", __val); }
inline __wvstring
to_wstring(unsigned long long __val)
{ return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf,
4 * sizeof(unsigned long long),
L"%llu", __val); }
inline __wvstring
to_wstring(float __val)
{
const int __n = __numeric_traits<float>::__max_exponent10 + 20;
return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf, __n,
L"%f", __val);
}
inline __wvstring
to_wstring(double __val)
{
const int __n = __numeric_traits<double>::__max_exponent10 + 20;
return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf, __n,
L"%f", __val);
}
inline __wvstring
to_wstring(long double __val)
{
const int __n = __numeric_traits<long double>::__max_exponent10 + 20;
return __gnu_cxx::__to_xstring<__wvstring>(&std::vswprintf, __n,
L"%Lf", __val);
}
#endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF
#endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
#if __cplusplus >= 201103L
#include <bits/functional_hash.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/// std::hash specialization for __vstring.
template<>
struct hash<__gnu_cxx::__vstring>
: public __hash_base<size_t, __gnu_cxx::__vstring>
{
size_t
operator()(const __gnu_cxx::__vstring& __s) const noexcept
{ return std::_Hash_impl::hash(__s.data(), __s.length()); }
};
#ifdef _GLIBCXX_USE_WCHAR_T
/// std::hash specialization for __wvstring.
template<>
struct hash<__gnu_cxx::__wvstring>
: public __hash_base<size_t, __gnu_cxx::__wvstring>
{
size_t
operator()(const __gnu_cxx::__wvstring& __s) const noexcept
{ return std::_Hash_impl::hash(__s.data(),
__s.length() * sizeof(wchar_t)); }
};
#endif
#ifdef _GLIBCXX_USE_C99_STDINT_TR1
/// std::hash specialization for __u16vstring.
template<>
struct hash<__gnu_cxx::__u16vstring>
: public __hash_base<size_t, __gnu_cxx::__u16vstring>
{
size_t
operator()(const __gnu_cxx::__u16vstring& __s) const noexcept
{ return std::_Hash_impl::hash(__s.data(),
__s.length() * sizeof(char16_t)); }
};
/// std::hash specialization for __u32vstring.
template<>
struct hash<__gnu_cxx::__u32vstring>
: public __hash_base<size_t, __gnu_cxx::__u32vstring>
{
size_t
operator()(const __gnu_cxx::__u32vstring& __s) const noexcept
{ return std::_Hash_impl::hash(__s.data(),
__s.length() * sizeof(char32_t)); }
};
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif // C++11
#include <ext/vstring.tcc>
#endif /* _VSTRING_H */
c++/8/ext/vstring_util.h 0000644 00000013207 15201526705 0010773 0 ustar 00 // Versatile string utility -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file ext/vstring_util.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{ext/vstring.h}
*/
#ifndef _VSTRING_UTIL_H
#define _VSTRING_UTIL_H 1
#pragma GCC system_header
#include <ext/vstring_fwd.h>
#include <debug/debug.h>
#include <bits/stl_function.h> // For less
#include <bits/functexcept.h>
#include <bits/localefwd.h>
#include <bits/ostream_insert.h>
#include <bits/stl_iterator.h>
#include <ext/numeric_traits.h>
#include <bits/move.h>
#include <bits/range_access.h>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _CharT, typename _Traits, typename _Alloc>
struct __vstring_utility
{
typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
typedef _Traits traits_type;
typedef typename _Traits::char_type value_type;
typedef typename _CharT_alloc_type::size_type size_type;
typedef typename _CharT_alloc_type::difference_type difference_type;
typedef typename _CharT_alloc_type::pointer pointer;
typedef typename _CharT_alloc_type::const_pointer const_pointer;
// For __sso_string.
typedef __gnu_cxx::
__normal_iterator<pointer, __gnu_cxx::
__versa_string<_CharT, _Traits, _Alloc,
__sso_string_base> >
__sso_iterator;
typedef __gnu_cxx::
__normal_iterator<const_pointer, __gnu_cxx::
__versa_string<_CharT, _Traits, _Alloc,
__sso_string_base> >
__const_sso_iterator;
// For __rc_string.
typedef __gnu_cxx::
__normal_iterator<pointer, __gnu_cxx::
__versa_string<_CharT, _Traits, _Alloc,
__rc_string_base> >
__rc_iterator;
typedef __gnu_cxx::
__normal_iterator<const_pointer, __gnu_cxx::
__versa_string<_CharT, _Traits, _Alloc,
__rc_string_base> >
__const_rc_iterator;
// NB: When the allocator is empty, deriving from it saves space
// (http://www.cantrip.org/emptyopt.html).
template<typename _Alloc1>
struct _Alloc_hider
: public _Alloc1
{
_Alloc_hider(_CharT* __ptr)
: _Alloc1(), _M_p(__ptr) { }
_Alloc_hider(const _Alloc1& __a, _CharT* __ptr)
: _Alloc1(__a), _M_p(__ptr) { }
_CharT* _M_p; // The actual data.
};
// When __n = 1 way faster than the general multichar
// traits_type::copy/move/assign.
static void
_S_copy(_CharT* __d, const _CharT* __s, size_type __n)
{
if (__n == 1)
traits_type::assign(*__d, *__s);
else
traits_type::copy(__d, __s, __n);
}
static void
_S_move(_CharT* __d, const _CharT* __s, size_type __n)
{
if (__n == 1)
traits_type::assign(*__d, *__s);
else
traits_type::move(__d, __s, __n);
}
static void
_S_assign(_CharT* __d, size_type __n, _CharT __c)
{
if (__n == 1)
traits_type::assign(*__d, __c);
else
traits_type::assign(__d, __n, __c);
}
// _S_copy_chars is a separate template to permit specialization
// to optimize for the common case of pointers as iterators.
template<typename _Iterator>
static void
_S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
{
for (; __k1 != __k2; ++__k1, ++__p)
traits_type::assign(*__p, *__k1); // These types are off.
}
static void
_S_copy_chars(_CharT* __p, __sso_iterator __k1, __sso_iterator __k2)
{ _S_copy_chars(__p, __k1.base(), __k2.base()); }
static void
_S_copy_chars(_CharT* __p, __const_sso_iterator __k1,
__const_sso_iterator __k2)
{ _S_copy_chars(__p, __k1.base(), __k2.base()); }
static void
_S_copy_chars(_CharT* __p, __rc_iterator __k1, __rc_iterator __k2)
{ _S_copy_chars(__p, __k1.base(), __k2.base()); }
static void
_S_copy_chars(_CharT* __p, __const_rc_iterator __k1,
__const_rc_iterator __k2)
{ _S_copy_chars(__p, __k1.base(), __k2.base()); }
static void
_S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2)
{ _S_copy(__p, __k1, __k2 - __k1); }
static void
_S_copy_chars(_CharT* __p, const _CharT* __k1, const _CharT* __k2)
{ _S_copy(__p, __k1, __k2 - __k1); }
static int
_S_compare(size_type __n1, size_type __n2)
{
const difference_type __d = difference_type(__n1 - __n2);
if (__d > __numeric_traits_integer<int>::__max)
return __numeric_traits_integer<int>::__max;
else if (__d < __numeric_traits_integer<int>::__min)
return __numeric_traits_integer<int>::__min;
else
return int(__d);
}
};
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif /* _VSTRING_UTIL_H */
c++/8/ext/alloc_traits.h 0000644 00000013106 15201526705 0010720 0 ustar 00 // Allocator traits -*- C++ -*-
// Copyright (C) 2011-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file ext/alloc_traits.h
* This file is a GNU extension to the Standard C++ Library.
*/
#ifndef _EXT_ALLOC_TRAITS_H
#define _EXT_ALLOC_TRAITS_H 1
#pragma GCC system_header
#if __cplusplus >= 201103L
# include <bits/move.h>
# include <bits/alloc_traits.h>
#else
# include <bits/allocator.h> // for __alloc_swap
#endif
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @brief Uniform interface to C++98 and C++11 allocators.
* @ingroup allocators
*/
template<typename _Alloc, typename = typename _Alloc::value_type>
struct __alloc_traits
#if __cplusplus >= 201103L
: std::allocator_traits<_Alloc>
#endif
{
typedef _Alloc allocator_type;
#if __cplusplus >= 201103L
typedef std::allocator_traits<_Alloc> _Base_type;
typedef typename _Base_type::value_type value_type;
typedef typename _Base_type::pointer pointer;
typedef typename _Base_type::const_pointer const_pointer;
typedef typename _Base_type::size_type size_type;
typedef typename _Base_type::difference_type difference_type;
// C++11 allocators do not define reference or const_reference
typedef value_type& reference;
typedef const value_type& const_reference;
using _Base_type::allocate;
using _Base_type::deallocate;
using _Base_type::construct;
using _Base_type::destroy;
using _Base_type::max_size;
private:
template<typename _Ptr>
using __is_custom_pointer
= std::__and_<std::is_same<pointer, _Ptr>,
std::__not_<std::is_pointer<_Ptr>>>;
public:
// overload construct for non-standard pointer types
template<typename _Ptr, typename... _Args>
static typename std::enable_if<__is_custom_pointer<_Ptr>::value>::type
construct(_Alloc& __a, _Ptr __p, _Args&&... __args)
{
_Base_type::construct(__a, std::__to_address(__p),
std::forward<_Args>(__args)...);
}
// overload destroy for non-standard pointer types
template<typename _Ptr>
static typename std::enable_if<__is_custom_pointer<_Ptr>::value>::type
destroy(_Alloc& __a, _Ptr __p)
{ _Base_type::destroy(__a, std::__to_address(__p)); }
static _Alloc _S_select_on_copy(const _Alloc& __a)
{ return _Base_type::select_on_container_copy_construction(__a); }
static void _S_on_swap(_Alloc& __a, _Alloc& __b)
{ std::__alloc_on_swap(__a, __b); }
static constexpr bool _S_propagate_on_copy_assign()
{ return _Base_type::propagate_on_container_copy_assignment::value; }
static constexpr bool _S_propagate_on_move_assign()
{ return _Base_type::propagate_on_container_move_assignment::value; }
static constexpr bool _S_propagate_on_swap()
{ return _Base_type::propagate_on_container_swap::value; }
static constexpr bool _S_always_equal()
{ return _Base_type::is_always_equal::value; }
static constexpr bool _S_nothrow_move()
{ return _S_propagate_on_move_assign() || _S_always_equal(); }
template<typename _Tp>
struct rebind
{ typedef typename _Base_type::template rebind_alloc<_Tp> other; };
#else
typedef typename _Alloc::pointer pointer;
typedef typename _Alloc::const_pointer const_pointer;
typedef typename _Alloc::value_type value_type;
typedef typename _Alloc::reference reference;
typedef typename _Alloc::const_reference const_reference;
typedef typename _Alloc::size_type size_type;
typedef typename _Alloc::difference_type difference_type;
static pointer
allocate(_Alloc& __a, size_type __n)
{ return __a.allocate(__n); }
static void deallocate(_Alloc& __a, pointer __p, size_type __n)
{ __a.deallocate(__p, __n); }
template<typename _Tp>
static void construct(_Alloc& __a, pointer __p, const _Tp& __arg)
{ __a.construct(__p, __arg); }
static void destroy(_Alloc& __a, pointer __p)
{ __a.destroy(__p); }
static size_type max_size(const _Alloc& __a)
{ return __a.max_size(); }
static const _Alloc& _S_select_on_copy(const _Alloc& __a) { return __a; }
static void _S_on_swap(_Alloc& __a, _Alloc& __b)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 431. Swapping containers with unequal allocators.
std::__alloc_swap<_Alloc>::_S_do_it(__a, __b);
}
template<typename _Tp>
struct rebind
{ typedef typename _Alloc::template rebind<_Tp>::other other; };
#endif
};
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace __gnu_cxx
#endif
c++/8/ext/concurrence.h 0000644 00000016673 15201526705 0010562 0 ustar 00 // Support for concurrent programing -*- C++ -*-
// Copyright (C) 2003-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file ext/concurrence.h
* This file is a GNU extension to the Standard C++ Library.
*/
#ifndef _CONCURRENCE_H
#define _CONCURRENCE_H 1
#pragma GCC system_header
#include <exception>
#include <bits/gthr.h>
#include <bits/functexcept.h>
#include <bits/cpp_type_traits.h>
#include <ext/type_traits.h>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Available locking policies:
// _S_single single-threaded code that doesn't need to be locked.
// _S_mutex multi-threaded code that requires additional support
// from gthr.h or abstraction layers in concurrence.h.
// _S_atomic multi-threaded code using atomic operations.
enum _Lock_policy { _S_single, _S_mutex, _S_atomic };
// Compile time constant that indicates prefered locking policy in
// the current configuration.
static const _Lock_policy __default_lock_policy =
#ifdef __GTHREADS
#if (defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2) \
&& defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4))
_S_atomic;
#else
_S_mutex;
#endif
#else
_S_single;
#endif
// NB: As this is used in libsupc++, need to only depend on
// exception. No stdexception classes, no use of std::string.
class __concurrence_lock_error : public std::exception
{
public:
virtual char const*
what() const throw()
{ return "__gnu_cxx::__concurrence_lock_error"; }
};
class __concurrence_unlock_error : public std::exception
{
public:
virtual char const*
what() const throw()
{ return "__gnu_cxx::__concurrence_unlock_error"; }
};
class __concurrence_broadcast_error : public std::exception
{
public:
virtual char const*
what() const throw()
{ return "__gnu_cxx::__concurrence_broadcast_error"; }
};
class __concurrence_wait_error : public std::exception
{
public:
virtual char const*
what() const throw()
{ return "__gnu_cxx::__concurrence_wait_error"; }
};
// Substitute for concurrence_error object in the case of -fno-exceptions.
inline void
__throw_concurrence_lock_error()
{ _GLIBCXX_THROW_OR_ABORT(__concurrence_lock_error()); }
inline void
__throw_concurrence_unlock_error()
{ _GLIBCXX_THROW_OR_ABORT(__concurrence_unlock_error()); }
#ifdef __GTHREAD_HAS_COND
inline void
__throw_concurrence_broadcast_error()
{ _GLIBCXX_THROW_OR_ABORT(__concurrence_broadcast_error()); }
inline void
__throw_concurrence_wait_error()
{ _GLIBCXX_THROW_OR_ABORT(__concurrence_wait_error()); }
#endif
class __mutex
{
private:
#if __GTHREADS && defined __GTHREAD_MUTEX_INIT
__gthread_mutex_t _M_mutex = __GTHREAD_MUTEX_INIT;
#else
__gthread_mutex_t _M_mutex;
#endif
__mutex(const __mutex&);
__mutex& operator=(const __mutex&);
public:
__mutex()
{
#if __GTHREADS && ! defined __GTHREAD_MUTEX_INIT
if (__gthread_active_p())
__GTHREAD_MUTEX_INIT_FUNCTION(&_M_mutex);
#endif
}
#if __GTHREADS && ! defined __GTHREAD_MUTEX_INIT
~__mutex()
{
if (__gthread_active_p())
__gthread_mutex_destroy(&_M_mutex);
}
#endif
void lock()
{
#if __GTHREADS
if (__gthread_active_p())
{
if (__gthread_mutex_lock(&_M_mutex) != 0)
__throw_concurrence_lock_error();
}
#endif
}
void unlock()
{
#if __GTHREADS
if (__gthread_active_p())
{
if (__gthread_mutex_unlock(&_M_mutex) != 0)
__throw_concurrence_unlock_error();
}
#endif
}
__gthread_mutex_t* gthread_mutex(void)
{ return &_M_mutex; }
};
class __recursive_mutex
{
private:
#if __GTHREADS && defined __GTHREAD_RECURSIVE_MUTEX_INIT
__gthread_recursive_mutex_t _M_mutex = __GTHREAD_RECURSIVE_MUTEX_INIT;
#else
__gthread_recursive_mutex_t _M_mutex;
#endif
__recursive_mutex(const __recursive_mutex&);
__recursive_mutex& operator=(const __recursive_mutex&);
public:
__recursive_mutex()
{
#if __GTHREADS && ! defined __GTHREAD_RECURSIVE_MUTEX_INIT
if (__gthread_active_p())
__GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION(&_M_mutex);
#endif
}
#if __GTHREADS && ! defined __GTHREAD_RECURSIVE_MUTEX_INIT
~__recursive_mutex()
{
if (__gthread_active_p())
__gthread_recursive_mutex_destroy(&_M_mutex);
}
#endif
void lock()
{
#if __GTHREADS
if (__gthread_active_p())
{
if (__gthread_recursive_mutex_lock(&_M_mutex) != 0)
__throw_concurrence_lock_error();
}
#endif
}
void unlock()
{
#if __GTHREADS
if (__gthread_active_p())
{
if (__gthread_recursive_mutex_unlock(&_M_mutex) != 0)
__throw_concurrence_unlock_error();
}
#endif
}
__gthread_recursive_mutex_t* gthread_recursive_mutex(void)
{ return &_M_mutex; }
};
/// Scoped lock idiom.
// Acquire the mutex here with a constructor call, then release with
// the destructor call in accordance with RAII style.
class __scoped_lock
{
public:
typedef __mutex __mutex_type;
private:
__mutex_type& _M_device;
__scoped_lock(const __scoped_lock&);
__scoped_lock& operator=(const __scoped_lock&);
public:
explicit __scoped_lock(__mutex_type& __name) : _M_device(__name)
{ _M_device.lock(); }
~__scoped_lock() throw()
{ _M_device.unlock(); }
};
#ifdef __GTHREAD_HAS_COND
class __cond
{
private:
#if __GTHREADS && defined __GTHREAD_COND_INIT
__gthread_cond_t _M_cond = __GTHREAD_COND_INIT;
#else
__gthread_cond_t _M_cond;
#endif
__cond(const __cond&);
__cond& operator=(const __cond&);
public:
__cond()
{
#if __GTHREADS && ! defined __GTHREAD_COND_INIT
if (__gthread_active_p())
__GTHREAD_COND_INIT_FUNCTION(&_M_cond);
#endif
}
#if __GTHREADS && ! defined __GTHREAD_COND_INIT
~__cond()
{
if (__gthread_active_p())
__gthread_cond_destroy(&_M_cond);
}
#endif
void broadcast()
{
#if __GTHREADS
if (__gthread_active_p())
{
if (__gthread_cond_broadcast(&_M_cond) != 0)
__throw_concurrence_broadcast_error();
}
#endif
}
void wait(__mutex *mutex)
{
#if __GTHREADS
{
if (__gthread_cond_wait(&_M_cond, mutex->gthread_mutex()) != 0)
__throw_concurrence_wait_error();
}
#endif
}
void wait_recursive(__recursive_mutex *mutex)
{
#if __GTHREADS
{
if (__gthread_cond_wait_recursive(&_M_cond,
mutex->gthread_recursive_mutex())
!= 0)
__throw_concurrence_wait_error();
}
#endif
}
};
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/ext/debug_allocator.h 0000644 00000013124 15201526705 0011366 0 ustar 00 // Allocators -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
* Copyright (c) 1996-1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file ext/debug_allocator.h
* This file is a GNU extension to the Standard C++ Library.
*/
#ifndef _DEBUG_ALLOCATOR_H
#define _DEBUG_ALLOCATOR_H 1
#include <stdexcept>
#include <bits/functexcept.h>
#include <ext/alloc_traits.h>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using std::size_t;
/**
* @brief A meta-allocator with debugging bits.
* @ingroup allocators
*
* This is precisely the allocator defined in the C++03 Standard.
*/
template<typename _Alloc>
class debug_allocator
{
template<typename> friend class debug_allocator;
typedef __alloc_traits<_Alloc> _Traits;
public:
typedef typename _Traits::size_type size_type;
typedef typename _Traits::difference_type difference_type;
typedef typename _Traits::pointer pointer;
typedef typename _Traits::const_pointer const_pointer;
typedef typename _Traits::reference reference;
typedef typename _Traits::const_reference const_reference;
typedef typename _Traits::value_type value_type;
template<typename _Up>
class rebind
{
typedef typename _Traits::template rebind<_Up>::other __other;
public:
typedef debug_allocator<__other> other;
};
private:
// _M_extra is the number of objects that correspond to the
// extra space where debug information is stored.
size_type _M_extra;
_Alloc _M_allocator;
template<typename _Alloc2,
typename = typename _Alloc2::template rebind<value_type>::other>
struct __convertible
{ };
template<typename _Alloc2>
struct __convertible<_Alloc2, _Alloc>
{
typedef void* __type;
};
size_type _S_extra()
{
const size_t __obj_size = sizeof(value_type);
return (sizeof(size_type) + __obj_size - 1) / __obj_size;
}
public:
debug_allocator() : _M_extra(_S_extra()) { }
template<typename _Alloc2>
debug_allocator(const debug_allocator<_Alloc2>& __a2,
typename __convertible<_Alloc2>::__type = 0)
: _M_allocator(__a2._M_allocator), _M_extra(_S_extra()) { }
debug_allocator(const _Alloc& __a)
: _M_allocator(__a), _M_extra(_S_extra()) { }
pointer
allocate(size_type __n)
{
pointer __res = _M_allocator.allocate(__n + _M_extra);
size_type* __ps = reinterpret_cast<size_type*>(__res);
*__ps = __n;
return __res + _M_extra;
}
pointer
allocate(size_type __n, const void* __hint)
{
pointer __res = _M_allocator.allocate(__n + _M_extra, __hint);
size_type* __ps = reinterpret_cast<size_type*>(__res);
*__ps = __n;
return __res + _M_extra;
}
void
deallocate(pointer __p, size_type __n)
{
using std::__throw_runtime_error;
if (__p)
{
pointer __real_p = __p - _M_extra;
if (*reinterpret_cast<size_type*>(__real_p) != __n)
__throw_runtime_error("debug_allocator::deallocate wrong size");
_M_allocator.deallocate(__real_p, __n + _M_extra);
}
else
__throw_runtime_error("debug_allocator::deallocate null pointer");
}
void
construct(pointer __p, const value_type& __val)
{ _Traits::construct(_M_allocator, __p, __val); }
#if __cplusplus >= 201103L
template<typename _Tp, typename... _Args>
void
construct(_Tp* __p, _Args&&... __args)
{
_Traits::construct(_M_allocator, __p,
std::forward<_Args>(__args)...);
}
#endif
template<typename _Tp>
void
destroy(_Tp* __p)
{ _Traits::destroy(_M_allocator, __p); }
size_type
max_size() const throw()
{ return _Traits::max_size(_M_allocator) - _M_extra; }
friend bool
operator==(const debug_allocator& __lhs, const debug_allocator& __rhs)
{ return __lhs._M_allocator == __rhs._M_allocator; }
};
template<typename _Alloc>
inline bool
operator!=(const debug_allocator<_Alloc>& __lhs,
const debug_allocator<_Alloc>& __rhs)
{ return !(__lhs == __rhs); }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/ext/stdio_filebuf.h 0000644 00000013046 15201526705 0011061 0 ustar 00 // File descriptor layer for filebuf -*- C++ -*-
// Copyright (C) 2002-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file ext/stdio_filebuf.h
* This file is a GNU extension to the Standard C++ Library.
*/
#ifndef _STDIO_FILEBUF_H
#define _STDIO_FILEBUF_H 1
#pragma GCC system_header
#include <fstream>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @brief Provides a layer of compatibility for C/POSIX.
* @ingroup io
*
* This GNU extension provides extensions for working with standard C
* FILE*'s and POSIX file descriptors. It must be instantiated by the
* user with the type of character used in the file stream, e.g.,
* stdio_filebuf<char>.
*/
template<typename _CharT, typename _Traits = std::char_traits<_CharT> >
class stdio_filebuf : public std::basic_filebuf<_CharT, _Traits>
{
public:
// Types:
typedef _CharT char_type;
typedef _Traits traits_type;
typedef typename traits_type::int_type int_type;
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
typedef std::size_t size_t;
public:
/**
* deferred initialization
*/
stdio_filebuf() : std::basic_filebuf<_CharT, _Traits>() {}
/**
* @param __fd An open file descriptor.
* @param __mode Same meaning as in a standard filebuf.
* @param __size Optimal or preferred size of internal buffer,
* in chars.
*
* This constructor associates a file stream buffer with an open
* POSIX file descriptor. The file descriptor will be automatically
* closed when the stdio_filebuf is closed/destroyed.
*/
stdio_filebuf(int __fd, std::ios_base::openmode __mode,
size_t __size = static_cast<size_t>(BUFSIZ));
/**
* @param __f An open @c FILE*.
* @param __mode Same meaning as in a standard filebuf.
* @param __size Optimal or preferred size of internal buffer,
* in chars. Defaults to system's @c BUFSIZ.
*
* This constructor associates a file stream buffer with an open
* C @c FILE*. The @c FILE* will not be automatically closed when the
* stdio_filebuf is closed/destroyed.
*/
stdio_filebuf(std::__c_file* __f, std::ios_base::openmode __mode,
size_t __size = static_cast<size_t>(BUFSIZ));
/**
* Closes the external data stream if the file descriptor constructor
* was used.
*/
virtual
~stdio_filebuf();
#if __cplusplus >= 201103L
stdio_filebuf(stdio_filebuf&&) = default;
stdio_filebuf& operator=(stdio_filebuf&&) = default;
void
swap(stdio_filebuf& __fb)
{ std::basic_filebuf<_CharT, _Traits>::swap(__fb); }
#endif
/**
* @return The underlying file descriptor.
*
* Once associated with an external data stream, this function can be
* used to access the underlying POSIX file descriptor. Note that
* there is no way for the library to track what you do with the
* descriptor, so be careful.
*/
int
fd() { return this->_M_file.fd(); }
/**
* @return The underlying FILE*.
*
* This function can be used to access the underlying "C" file pointer.
* Note that there is no way for the library to track what you do
* with the file, so be careful.
*/
std::__c_file*
file() { return this->_M_file.file(); }
};
template<typename _CharT, typename _Traits>
stdio_filebuf<_CharT, _Traits>::~stdio_filebuf()
{ }
template<typename _CharT, typename _Traits>
stdio_filebuf<_CharT, _Traits>::
stdio_filebuf(int __fd, std::ios_base::openmode __mode, size_t __size)
{
this->_M_file.sys_open(__fd, __mode);
if (this->is_open())
{
this->_M_mode = __mode;
this->_M_buf_size = __size;
this->_M_allocate_internal_buffer();
this->_M_reading = false;
this->_M_writing = false;
this->_M_set_buffer(-1);
}
}
template<typename _CharT, typename _Traits>
stdio_filebuf<_CharT, _Traits>::
stdio_filebuf(std::__c_file* __f, std::ios_base::openmode __mode,
size_t __size)
{
this->_M_file.sys_open(__f, __mode);
if (this->is_open())
{
this->_M_mode = __mode;
this->_M_buf_size = __size;
this->_M_allocate_internal_buffer();
this->_M_reading = false;
this->_M_writing = false;
this->_M_set_buffer(-1);
}
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/ext/pool_allocator.h 0000644 00000021165 15201526705 0011255 0 ustar 00 // Allocators -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
* Copyright (c) 1996-1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file ext/pool_allocator.h
* This file is a GNU extension to the Standard C++ Library.
*/
#ifndef _POOL_ALLOCATOR_H
#define _POOL_ALLOCATOR_H 1
#include <bits/c++config.h>
#include <cstdlib>
#include <new>
#include <bits/functexcept.h>
#include <ext/atomicity.h>
#include <ext/concurrence.h>
#include <bits/move.h>
#if __cplusplus >= 201103L
#include <type_traits>
#endif
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using std::size_t;
using std::ptrdiff_t;
/**
* @brief Base class for __pool_alloc.
*
* Uses various allocators to fulfill underlying requests (and makes as
* few requests as possible when in default high-speed pool mode).
*
* Important implementation properties:
* 0. If globally mandated, then allocate objects from new
* 1. If the clients request an object of size > _S_max_bytes, the resulting
* object will be obtained directly from new
* 2. In all other cases, we allocate an object of size exactly
* _S_round_up(requested_size). Thus the client has enough size
* information that we can return the object to the proper free list
* without permanently losing part of the object.
*/
class __pool_alloc_base
{
protected:
enum { _S_align = 8 };
enum { _S_max_bytes = 128 };
enum { _S_free_list_size = (size_t)_S_max_bytes / (size_t)_S_align };
union _Obj
{
union _Obj* _M_free_list_link;
char _M_client_data[1]; // The client sees this.
};
static _Obj* volatile _S_free_list[_S_free_list_size];
// Chunk allocation state.
static char* _S_start_free;
static char* _S_end_free;
static size_t _S_heap_size;
size_t
_M_round_up(size_t __bytes)
{ return ((__bytes + (size_t)_S_align - 1) & ~((size_t)_S_align - 1)); }
_GLIBCXX_CONST _Obj* volatile*
_M_get_free_list(size_t __bytes) throw ();
__mutex&
_M_get_mutex() throw ();
// Returns an object of size __n, and optionally adds to size __n
// free list.
void*
_M_refill(size_t __n);
// Allocates a chunk for nobjs of size size. nobjs may be reduced
// if it is inconvenient to allocate the requested number.
char*
_M_allocate_chunk(size_t __n, int& __nobjs);
};
/**
* @brief Allocator using a memory pool with a single lock.
* @ingroup allocators
*/
template<typename _Tp>
class __pool_alloc : private __pool_alloc_base
{
private:
static _Atomic_word _S_force_new;
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef _Tp* pointer;
typedef const _Tp* const_pointer;
typedef _Tp& reference;
typedef const _Tp& const_reference;
typedef _Tp value_type;
template<typename _Tp1>
struct rebind
{ typedef __pool_alloc<_Tp1> other; };
#if __cplusplus >= 201103L
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2103. propagate_on_container_move_assignment
typedef std::true_type propagate_on_container_move_assignment;
#endif
__pool_alloc() _GLIBCXX_USE_NOEXCEPT { }
__pool_alloc(const __pool_alloc&) _GLIBCXX_USE_NOEXCEPT { }
template<typename _Tp1>
__pool_alloc(const __pool_alloc<_Tp1>&) _GLIBCXX_USE_NOEXCEPT { }
~__pool_alloc() _GLIBCXX_USE_NOEXCEPT { }
pointer
address(reference __x) const _GLIBCXX_NOEXCEPT
{ return std::__addressof(__x); }
const_pointer
address(const_reference __x) const _GLIBCXX_NOEXCEPT
{ return std::__addressof(__x); }
size_type
max_size() const _GLIBCXX_USE_NOEXCEPT
{ return size_t(-1) / sizeof(_Tp); }
#if __cplusplus >= 201103L
template<typename _Up, typename... _Args>
void
construct(_Up* __p, _Args&&... __args)
{ ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
template<typename _Up>
void
destroy(_Up* __p) { __p->~_Up(); }
#else
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 402. wrong new expression in [some_] allocator::construct
void
construct(pointer __p, const _Tp& __val)
{ ::new((void *)__p) _Tp(__val); }
void
destroy(pointer __p) { __p->~_Tp(); }
#endif
pointer
allocate(size_type __n, const void* = 0);
void
deallocate(pointer __p, size_type __n);
};
template<typename _Tp>
inline bool
operator==(const __pool_alloc<_Tp>&, const __pool_alloc<_Tp>&)
{ return true; }
template<typename _Tp>
inline bool
operator!=(const __pool_alloc<_Tp>&, const __pool_alloc<_Tp>&)
{ return false; }
template<typename _Tp>
_Atomic_word
__pool_alloc<_Tp>::_S_force_new;
template<typename _Tp>
_Tp*
__pool_alloc<_Tp>::allocate(size_type __n, const void*)
{
pointer __ret = 0;
if (__builtin_expect(__n != 0, true))
{
if (__n > this->max_size())
std::__throw_bad_alloc();
const size_t __bytes = __n * sizeof(_Tp);
#if __cpp_aligned_new
if (alignof(_Tp) > __STDCPP_DEFAULT_NEW_ALIGNMENT__)
{
std::align_val_t __al = std::align_val_t(alignof(_Tp));
return static_cast<_Tp*>(::operator new(__bytes, __al));
}
#endif
// If there is a race through here, assume answer from getenv
// will resolve in same direction. Inspired by techniques
// to efficiently support threading found in basic_string.h.
if (_S_force_new == 0)
{
if (std::getenv("GLIBCXX_FORCE_NEW"))
__atomic_add_dispatch(&_S_force_new, 1);
else
__atomic_add_dispatch(&_S_force_new, -1);
}
if (__bytes > size_t(_S_max_bytes) || _S_force_new > 0)
__ret = static_cast<_Tp*>(::operator new(__bytes));
else
{
_Obj* volatile* __free_list = _M_get_free_list(__bytes);
__scoped_lock sentry(_M_get_mutex());
_Obj* __restrict__ __result = *__free_list;
if (__builtin_expect(__result == 0, 0))
__ret = static_cast<_Tp*>(_M_refill(_M_round_up(__bytes)));
else
{
*__free_list = __result->_M_free_list_link;
__ret = reinterpret_cast<_Tp*>(__result);
}
if (__ret == 0)
std::__throw_bad_alloc();
}
}
return __ret;
}
template<typename _Tp>
void
__pool_alloc<_Tp>::deallocate(pointer __p, size_type __n)
{
if (__builtin_expect(__n != 0 && __p != 0, true))
{
#if __cpp_aligned_new
if (alignof(_Tp) > __STDCPP_DEFAULT_NEW_ALIGNMENT__)
{
::operator delete(__p, std::align_val_t(alignof(_Tp)));
return;
}
#endif
const size_t __bytes = __n * sizeof(_Tp);
if (__bytes > static_cast<size_t>(_S_max_bytes) || _S_force_new > 0)
::operator delete(__p);
else
{
_Obj* volatile* __free_list = _M_get_free_list(__bytes);
_Obj* __q = reinterpret_cast<_Obj*>(__p);
__scoped_lock sentry(_M_get_mutex());
__q ->_M_free_list_link = *__free_list;
*__free_list = __q;
}
}
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/ext/rope 0000644 00000253125 15201526705 0006766 0 ustar 00 // SGI's rope class -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
* Copyright (c) 1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file ext/rope
* This file is a GNU extension to the Standard C++ Library (possibly
* containing extensions from the HP/SGI STL subset).
*/
#ifndef _ROPE
#define _ROPE 1
#pragma GCC system_header
#include <algorithm>
#include <iosfwd>
#include <bits/stl_construct.h>
#include <bits/stl_uninitialized.h>
#include <bits/stl_function.h>
#include <bits/stl_numeric.h>
#include <bits/allocator.h>
#include <bits/gthr.h>
#include <tr1/functional>
# ifdef __GC
# define __GC_CONST const
# else
# define __GC_CONST // constant except for deallocation
# endif
#include <ext/memory> // For uninitialized_copy_n
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
namespace __detail
{
enum { _S_max_rope_depth = 45 };
enum _Tag {_S_leaf, _S_concat, _S_substringfn, _S_function};
} // namespace __detail
using std::size_t;
using std::ptrdiff_t;
using std::allocator;
using std::_Destroy;
// See libstdc++/36832.
template<typename _ForwardIterator, typename _Allocator>
void
_Destroy_const(_ForwardIterator __first,
_ForwardIterator __last, _Allocator __alloc)
{
for (; __first != __last; ++__first)
__alloc.destroy(&*__first);
}
template<typename _ForwardIterator, typename _Tp>
inline void
_Destroy_const(_ForwardIterator __first,
_ForwardIterator __last, allocator<_Tp>)
{ _Destroy(__first, __last); }
// The _S_eos function is used for those functions that
// convert to/from C-like strings to detect the end of the string.
// The end-of-C-string character.
// This is what the draft standard says it should be.
template <class _CharT>
inline _CharT
_S_eos(_CharT*)
{ return _CharT(); }
// Test for basic character types.
// For basic character types leaves having a trailing eos.
template <class _CharT>
inline bool
_S_is_basic_char_type(_CharT*)
{ return false; }
template <class _CharT>
inline bool
_S_is_one_byte_char_type(_CharT*)
{ return false; }
inline bool
_S_is_basic_char_type(char*)
{ return true; }
inline bool
_S_is_one_byte_char_type(char*)
{ return true; }
inline bool
_S_is_basic_char_type(wchar_t*)
{ return true; }
// Store an eos iff _CharT is a basic character type.
// Do not reference _S_eos if it isn't.
template <class _CharT>
inline void
_S_cond_store_eos(_CharT&) { }
inline void
_S_cond_store_eos(char& __c)
{ __c = 0; }
inline void
_S_cond_store_eos(wchar_t& __c)
{ __c = 0; }
// char_producers are logically functions that generate a section of
// a string. These can be converted to ropes. The resulting rope
// invokes the char_producer on demand. This allows, for example,
// files to be viewed as ropes without reading the entire file.
template <class _CharT>
class char_producer
{
public:
virtual ~char_producer() { }
virtual void
operator()(size_t __start_pos, size_t __len,
_CharT* __buffer) = 0;
// Buffer should really be an arbitrary output iterator.
// That way we could flatten directly into an ostream, etc.
// This is thoroughly impossible, since iterator types don't
// have runtime descriptions.
};
// Sequence buffers:
//
// Sequence must provide an append operation that appends an
// array to the sequence. Sequence buffers are useful only if
// appending an entire array is cheaper than appending element by element.
// This is true for many string representations.
// This should perhaps inherit from ostream<sequence::value_type>
// and be implemented correspondingly, so that they can be used
// for formatted. For the sake of portability, we don't do this yet.
//
// For now, sequence buffers behave as output iterators. But they also
// behave a little like basic_ostringstream<sequence::value_type> and a
// little like containers.
template<class _Sequence, size_t _Buf_sz = 100>
class sequence_buffer
: public std::iterator<std::output_iterator_tag, void, void, void, void>
{
public:
typedef typename _Sequence::value_type value_type;
protected:
_Sequence* _M_prefix;
value_type _M_buffer[_Buf_sz];
size_t _M_buf_count;
public:
void
flush()
{
_M_prefix->append(_M_buffer, _M_buffer + _M_buf_count);
_M_buf_count = 0;
}
~sequence_buffer()
{ flush(); }
sequence_buffer()
: _M_prefix(0), _M_buf_count(0) { }
sequence_buffer(const sequence_buffer& __x)
{
_M_prefix = __x._M_prefix;
_M_buf_count = __x._M_buf_count;
std::copy(__x._M_buffer, __x._M_buffer + __x._M_buf_count, _M_buffer);
}
sequence_buffer(sequence_buffer& __x)
{
__x.flush();
_M_prefix = __x._M_prefix;
_M_buf_count = 0;
}
sequence_buffer(_Sequence& __s)
: _M_prefix(&__s), _M_buf_count(0) { }
sequence_buffer&
operator=(sequence_buffer& __x)
{
__x.flush();
_M_prefix = __x._M_prefix;
_M_buf_count = 0;
return *this;
}
sequence_buffer&
operator=(const sequence_buffer& __x)
{
_M_prefix = __x._M_prefix;
_M_buf_count = __x._M_buf_count;
std::copy(__x._M_buffer, __x._M_buffer + __x._M_buf_count, _M_buffer);
return *this;
}
void
push_back(value_type __x)
{
if (_M_buf_count < _Buf_sz)
{
_M_buffer[_M_buf_count] = __x;
++_M_buf_count;
}
else
{
flush();
_M_buffer[0] = __x;
_M_buf_count = 1;
}
}
void
append(value_type* __s, size_t __len)
{
if (__len + _M_buf_count <= _Buf_sz)
{
size_t __i = _M_buf_count;
for (size_t __j = 0; __j < __len; __i++, __j++)
_M_buffer[__i] = __s[__j];
_M_buf_count += __len;
}
else if (0 == _M_buf_count)
_M_prefix->append(__s, __s + __len);
else
{
flush();
append(__s, __len);
}
}
sequence_buffer&
write(value_type* __s, size_t __len)
{
append(__s, __len);
return *this;
}
sequence_buffer&
put(value_type __x)
{
push_back(__x);
return *this;
}
sequence_buffer&
operator=(const value_type& __rhs)
{
push_back(__rhs);
return *this;
}
sequence_buffer&
operator*()
{ return *this; }
sequence_buffer&
operator++()
{ return *this; }
sequence_buffer
operator++(int)
{ return *this; }
};
// The following should be treated as private, at least for now.
template<class _CharT>
class _Rope_char_consumer
{
public:
// If we had member templates, these should not be virtual.
// For now we need to use run-time parametrization where
// compile-time would do. Hence this should all be private
// for now.
// The symmetry with char_producer is accidental and temporary.
virtual ~_Rope_char_consumer() { }
virtual bool
operator()(const _CharT* __buffer, size_t __len) = 0;
};
// First a lot of forward declarations. The standard seems to require
// much stricter "declaration before use" than many of the implementations
// that preceded it.
template<class _CharT, class _Alloc = allocator<_CharT> >
class rope;
template<class _CharT, class _Alloc>
struct _Rope_RopeConcatenation;
template<class _CharT, class _Alloc>
struct _Rope_RopeLeaf;
template<class _CharT, class _Alloc>
struct _Rope_RopeFunction;
template<class _CharT, class _Alloc>
struct _Rope_RopeSubstring;
template<class _CharT, class _Alloc>
class _Rope_iterator;
template<class _CharT, class _Alloc>
class _Rope_const_iterator;
template<class _CharT, class _Alloc>
class _Rope_char_ref_proxy;
template<class _CharT, class _Alloc>
class _Rope_char_ptr_proxy;
template<class _CharT, class _Alloc>
bool
operator==(const _Rope_char_ptr_proxy<_CharT, _Alloc>& __x,
const _Rope_char_ptr_proxy<_CharT, _Alloc>& __y);
template<class _CharT, class _Alloc>
_Rope_const_iterator<_CharT, _Alloc>
operator-(const _Rope_const_iterator<_CharT, _Alloc>& __x,
ptrdiff_t __n);
template<class _CharT, class _Alloc>
_Rope_const_iterator<_CharT, _Alloc>
operator+(const _Rope_const_iterator<_CharT, _Alloc>& __x,
ptrdiff_t __n);
template<class _CharT, class _Alloc>
_Rope_const_iterator<_CharT, _Alloc>
operator+(ptrdiff_t __n,
const _Rope_const_iterator<_CharT, _Alloc>& __x);
template<class _CharT, class _Alloc>
bool
operator==(const _Rope_const_iterator<_CharT, _Alloc>& __x,
const _Rope_const_iterator<_CharT, _Alloc>& __y);
template<class _CharT, class _Alloc>
bool
operator<(const _Rope_const_iterator<_CharT, _Alloc>& __x,
const _Rope_const_iterator<_CharT, _Alloc>& __y);
template<class _CharT, class _Alloc>
ptrdiff_t
operator-(const _Rope_const_iterator<_CharT, _Alloc>& __x,
const _Rope_const_iterator<_CharT, _Alloc>& __y);
template<class _CharT, class _Alloc>
_Rope_iterator<_CharT, _Alloc>
operator-(const _Rope_iterator<_CharT, _Alloc>& __x, ptrdiff_t __n);
template<class _CharT, class _Alloc>
_Rope_iterator<_CharT, _Alloc>
operator+(const _Rope_iterator<_CharT, _Alloc>& __x, ptrdiff_t __n);
template<class _CharT, class _Alloc>
_Rope_iterator<_CharT, _Alloc>
operator+(ptrdiff_t __n, const _Rope_iterator<_CharT, _Alloc>& __x);
template<class _CharT, class _Alloc>
bool
operator==(const _Rope_iterator<_CharT, _Alloc>& __x,
const _Rope_iterator<_CharT, _Alloc>& __y);
template<class _CharT, class _Alloc>
bool
operator<(const _Rope_iterator<_CharT, _Alloc>& __x,
const _Rope_iterator<_CharT, _Alloc>& __y);
template<class _CharT, class _Alloc>
ptrdiff_t
operator-(const _Rope_iterator<_CharT, _Alloc>& __x,
const _Rope_iterator<_CharT, _Alloc>& __y);
template<class _CharT, class _Alloc>
rope<_CharT, _Alloc>
operator+(const rope<_CharT, _Alloc>& __left,
const rope<_CharT, _Alloc>& __right);
template<class _CharT, class _Alloc>
rope<_CharT, _Alloc>
operator+(const rope<_CharT, _Alloc>& __left, const _CharT* __right);
template<class _CharT, class _Alloc>
rope<_CharT, _Alloc>
operator+(const rope<_CharT, _Alloc>& __left, _CharT __right);
// Some helpers, so we can use power on ropes.
// See below for why this isn't local to the implementation.
// This uses a nonstandard refcount convention.
// The result has refcount 0.
template<class _CharT, class _Alloc>
struct _Rope_Concat_fn
: public std::binary_function<rope<_CharT, _Alloc>, rope<_CharT, _Alloc>,
rope<_CharT, _Alloc> >
{
rope<_CharT, _Alloc>
operator()(const rope<_CharT, _Alloc>& __x,
const rope<_CharT, _Alloc>& __y)
{ return __x + __y; }
};
template <class _CharT, class _Alloc>
inline rope<_CharT, _Alloc>
identity_element(_Rope_Concat_fn<_CharT, _Alloc>)
{ return rope<_CharT, _Alloc>(); }
// Class _Refcount_Base provides a type, _RC_t, a data member,
// _M_ref_count, and member functions _M_incr and _M_decr, which perform
// atomic preincrement/predecrement. The constructor initializes
// _M_ref_count.
struct _Refcount_Base
{
// The type _RC_t
typedef size_t _RC_t;
// The data member _M_ref_count
volatile _RC_t _M_ref_count;
// Constructor
#ifdef __GTHREAD_MUTEX_INIT
__gthread_mutex_t _M_ref_count_lock = __GTHREAD_MUTEX_INIT;
#else
__gthread_mutex_t _M_ref_count_lock;
#endif
_Refcount_Base(_RC_t __n) : _M_ref_count(__n)
{
#ifndef __GTHREAD_MUTEX_INIT
#ifdef __GTHREAD_MUTEX_INIT_FUNCTION
__GTHREAD_MUTEX_INIT_FUNCTION (&_M_ref_count_lock);
#else
#error __GTHREAD_MUTEX_INIT or __GTHREAD_MUTEX_INIT_FUNCTION should be defined by gthr.h abstraction layer, report problem to libstdc++@gcc.gnu.org.
#endif
#endif
}
#ifndef __GTHREAD_MUTEX_INIT
~_Refcount_Base()
{ __gthread_mutex_destroy(&_M_ref_count_lock); }
#endif
void
_M_incr()
{
__gthread_mutex_lock(&_M_ref_count_lock);
++_M_ref_count;
__gthread_mutex_unlock(&_M_ref_count_lock);
}
_RC_t
_M_decr()
{
__gthread_mutex_lock(&_M_ref_count_lock);
volatile _RC_t __tmp = --_M_ref_count;
__gthread_mutex_unlock(&_M_ref_count_lock);
return __tmp;
}
};
//
// What follows should really be local to rope. Unfortunately,
// that doesn't work, since it makes it impossible to define generic
// equality on rope iterators. According to the draft standard, the
// template parameters for such an equality operator cannot be inferred
// from the occurrence of a member class as a parameter.
// (SGI compilers in fact allow this, but the __result wouldn't be
// portable.)
// Similarly, some of the static member functions are member functions
// only to avoid polluting the global namespace, and to circumvent
// restrictions on type inference for template functions.
//
//
// The internal data structure for representing a rope. This is
// private to the implementation. A rope is really just a pointer
// to one of these.
//
// A few basic functions for manipulating this data structure
// are members of _RopeRep. Most of the more complex algorithms
// are implemented as rope members.
//
// Some of the static member functions of _RopeRep have identically
// named functions in rope that simply invoke the _RopeRep versions.
#define __ROPE_DEFINE_ALLOCS(__a) \
__ROPE_DEFINE_ALLOC(_CharT,_Data) /* character data */ \
typedef _Rope_RopeConcatenation<_CharT,__a> __C; \
__ROPE_DEFINE_ALLOC(__C,_C) \
typedef _Rope_RopeLeaf<_CharT,__a> __L; \
__ROPE_DEFINE_ALLOC(__L,_L) \
typedef _Rope_RopeFunction<_CharT,__a> __F; \
__ROPE_DEFINE_ALLOC(__F,_F) \
typedef _Rope_RopeSubstring<_CharT,__a> __S; \
__ROPE_DEFINE_ALLOC(__S,_S)
// Internal rope nodes potentially store a copy of the allocator
// instance used to allocate them. This is mostly redundant.
// But the alternative would be to pass allocator instances around
// in some form to nearly all internal functions, since any pointer
// assignment may result in a zero reference count and thus require
// deallocation.
#define __STATIC_IF_SGI_ALLOC /* not static */
template <class _CharT, class _Alloc>
struct _Rope_rep_base
: public _Alloc
{
typedef _Alloc allocator_type;
allocator_type
get_allocator() const
{ return *static_cast<const _Alloc*>(this); }
allocator_type&
_M_get_allocator()
{ return *static_cast<_Alloc*>(this); }
const allocator_type&
_M_get_allocator() const
{ return *static_cast<const _Alloc*>(this); }
_Rope_rep_base(size_t __size, const allocator_type&)
: _M_size(__size) { }
size_t _M_size;
# define __ROPE_DEFINE_ALLOC(_Tp, __name) \
typedef typename \
_Alloc::template rebind<_Tp>::other __name##Alloc; \
static _Tp* __name##_allocate(size_t __n) \
{ return __name##Alloc().allocate(__n); } \
static void __name##_deallocate(_Tp *__p, size_t __n) \
{ __name##Alloc().deallocate(__p, __n); }
__ROPE_DEFINE_ALLOCS(_Alloc)
# undef __ROPE_DEFINE_ALLOC
};
template<class _CharT, class _Alloc>
struct _Rope_RopeRep
: public _Rope_rep_base<_CharT, _Alloc>
# ifndef __GC
, _Refcount_Base
# endif
{
public:
__detail::_Tag _M_tag:8;
bool _M_is_balanced:8;
unsigned char _M_depth;
__GC_CONST _CharT* _M_c_string;
#ifdef __GTHREAD_MUTEX_INIT
__gthread_mutex_t _M_c_string_lock = __GTHREAD_MUTEX_INIT;
#else
__gthread_mutex_t _M_c_string_lock;
#endif
/* Flattened version of string, if needed. */
/* typically 0. */
/* If it's not 0, then the memory is owned */
/* by this node. */
/* In the case of a leaf, this may point to */
/* the same memory as the data field. */
typedef typename _Rope_rep_base<_CharT, _Alloc>::allocator_type
allocator_type;
using _Rope_rep_base<_CharT, _Alloc>::get_allocator;
using _Rope_rep_base<_CharT, _Alloc>::_M_get_allocator;
_Rope_RopeRep(__detail::_Tag __t, int __d, bool __b, size_t __size,
const allocator_type& __a)
: _Rope_rep_base<_CharT, _Alloc>(__size, __a),
#ifndef __GC
_Refcount_Base(1),
#endif
_M_tag(__t), _M_is_balanced(__b), _M_depth(__d), _M_c_string(0)
#ifdef __GTHREAD_MUTEX_INIT
{ }
#else
{ __GTHREAD_MUTEX_INIT_FUNCTION (&_M_c_string_lock); }
~_Rope_RopeRep()
{ __gthread_mutex_destroy (&_M_c_string_lock); }
#endif
#ifdef __GC
void
_M_incr () { }
#endif
static void
_S_free_string(__GC_CONST _CharT*, size_t __len,
allocator_type& __a);
#define __STL_FREE_STRING(__s, __l, __a) _S_free_string(__s, __l, __a);
// Deallocate data section of a leaf.
// This shouldn't be a member function.
// But its hard to do anything else at the
// moment, because it's templatized w.r.t.
// an allocator.
// Does nothing if __GC is defined.
#ifndef __GC
void _M_free_c_string();
void _M_free_tree();
// Deallocate t. Assumes t is not 0.
void
_M_unref_nonnil()
{
if (0 == _M_decr())
_M_free_tree();
}
void
_M_ref_nonnil()
{ _M_incr(); }
static void
_S_unref(_Rope_RopeRep* __t)
{
if (0 != __t)
__t->_M_unref_nonnil();
}
static void
_S_ref(_Rope_RopeRep* __t)
{
if (0 != __t)
__t->_M_incr();
}
static void
_S_free_if_unref(_Rope_RopeRep* __t)
{
if (0 != __t && 0 == __t->_M_ref_count)
__t->_M_free_tree();
}
# else /* __GC */
void _M_unref_nonnil() { }
void _M_ref_nonnil() { }
static void _S_unref(_Rope_RopeRep*) { }
static void _S_ref(_Rope_RopeRep*) { }
static void _S_free_if_unref(_Rope_RopeRep*) { }
# endif
protected:
_Rope_RopeRep&
operator=(const _Rope_RopeRep&);
_Rope_RopeRep(const _Rope_RopeRep&);
};
template<class _CharT, class _Alloc>
struct _Rope_RopeLeaf
: public _Rope_RopeRep<_CharT, _Alloc>
{
public:
// Apparently needed by VC++
// The data fields of leaves are allocated with some
// extra space, to accommodate future growth and for basic
// character types, to hold a trailing eos character.
enum { _S_alloc_granularity = 8 };
static size_t
_S_rounded_up_size(size_t __n)
{
size_t __size_with_eos;
if (_S_is_basic_char_type((_CharT*)0))
__size_with_eos = __n + 1;
else
__size_with_eos = __n;
#ifdef __GC
return __size_with_eos;
#else
// Allow slop for in-place expansion.
return ((__size_with_eos + size_t(_S_alloc_granularity) - 1)
&~ (size_t(_S_alloc_granularity) - 1));
#endif
}
__GC_CONST _CharT* _M_data; /* Not necessarily 0 terminated. */
/* The allocated size is */
/* _S_rounded_up_size(size), except */
/* in the GC case, in which it */
/* doesn't matter. */
typedef typename _Rope_rep_base<_CharT,_Alloc>::allocator_type
allocator_type;
_Rope_RopeLeaf(__GC_CONST _CharT* __d, size_t __size,
const allocator_type& __a)
: _Rope_RopeRep<_CharT, _Alloc>(__detail::_S_leaf, 0, true,
__size, __a), _M_data(__d)
{
if (_S_is_basic_char_type((_CharT *)0))
{
// already eos terminated.
this->_M_c_string = __d;
}
}
// The constructor assumes that d has been allocated with
// the proper allocator and the properly padded size.
// In contrast, the destructor deallocates the data:
#ifndef __GC
~_Rope_RopeLeaf() throw()
{
if (_M_data != this->_M_c_string)
this->_M_free_c_string();
this->__STL_FREE_STRING(_M_data, this->_M_size, this->_M_get_allocator());
}
#endif
protected:
_Rope_RopeLeaf&
operator=(const _Rope_RopeLeaf&);
_Rope_RopeLeaf(const _Rope_RopeLeaf&);
};
template<class _CharT, class _Alloc>
struct _Rope_RopeConcatenation
: public _Rope_RopeRep<_CharT, _Alloc>
{
public:
_Rope_RopeRep<_CharT, _Alloc>* _M_left;
_Rope_RopeRep<_CharT, _Alloc>* _M_right;
typedef typename _Rope_rep_base<_CharT, _Alloc>::allocator_type
allocator_type;
_Rope_RopeConcatenation(_Rope_RopeRep<_CharT, _Alloc>* __l,
_Rope_RopeRep<_CharT, _Alloc>* __r,
const allocator_type& __a)
: _Rope_RopeRep<_CharT, _Alloc>(__detail::_S_concat,
std::max(__l->_M_depth,
__r->_M_depth) + 1,
false,
__l->_M_size + __r->_M_size, __a),
_M_left(__l), _M_right(__r)
{ }
#ifndef __GC
~_Rope_RopeConcatenation() throw()
{
this->_M_free_c_string();
_M_left->_M_unref_nonnil();
_M_right->_M_unref_nonnil();
}
#endif
protected:
_Rope_RopeConcatenation&
operator=(const _Rope_RopeConcatenation&);
_Rope_RopeConcatenation(const _Rope_RopeConcatenation&);
};
template<class _CharT, class _Alloc>
struct _Rope_RopeFunction
: public _Rope_RopeRep<_CharT, _Alloc>
{
public:
char_producer<_CharT>* _M_fn;
#ifndef __GC
bool _M_delete_when_done; // Char_producer is owned by the
// rope and should be explicitly
// deleted when the rope becomes
// inaccessible.
#else
// In the GC case, we either register the rope for
// finalization, or not. Thus the field is unnecessary;
// the information is stored in the collector data structures.
// We do need a finalization procedure to be invoked by the
// collector.
static void
_S_fn_finalization_proc(void * __tree, void *)
{ delete ((_Rope_RopeFunction *)__tree) -> _M_fn; }
#endif
typedef typename _Rope_rep_base<_CharT, _Alloc>::allocator_type
allocator_type;
_Rope_RopeFunction(char_producer<_CharT>* __f, size_t __size,
bool __d, const allocator_type& __a)
: _Rope_RopeRep<_CharT, _Alloc>(__detail::_S_function, 0, true, __size, __a)
, _M_fn(__f)
#ifndef __GC
, _M_delete_when_done(__d)
#endif
{
#ifdef __GC
if (__d)
{
GC_REGISTER_FINALIZER(this, _Rope_RopeFunction::
_S_fn_finalization_proc, 0, 0, 0);
}
#endif
}
#ifndef __GC
~_Rope_RopeFunction() throw()
{
this->_M_free_c_string();
if (_M_delete_when_done)
delete _M_fn;
}
# endif
protected:
_Rope_RopeFunction&
operator=(const _Rope_RopeFunction&);
_Rope_RopeFunction(const _Rope_RopeFunction&);
};
// Substring results are usually represented using just
// concatenation nodes. But in the case of very long flat ropes
// or ropes with a functional representation that isn't practical.
// In that case, we represent the __result as a special case of
// RopeFunction, whose char_producer points back to the rope itself.
// In all cases except repeated substring operations and
// deallocation, we treat the __result as a RopeFunction.
template<class _CharT, class _Alloc>
struct _Rope_RopeSubstring
: public _Rope_RopeFunction<_CharT, _Alloc>,
public char_producer<_CharT>
{
public:
// XXX this whole class should be rewritten.
_Rope_RopeRep<_CharT,_Alloc>* _M_base; // not 0
size_t _M_start;
virtual void
operator()(size_t __start_pos, size_t __req_len,
_CharT* __buffer)
{
switch(_M_base->_M_tag)
{
case __detail::_S_function:
case __detail::_S_substringfn:
{
char_producer<_CharT>* __fn =
((_Rope_RopeFunction<_CharT,_Alloc>*)_M_base)->_M_fn;
(*__fn)(__start_pos + _M_start, __req_len, __buffer);
}
break;
case __detail::_S_leaf:
{
__GC_CONST _CharT* __s =
((_Rope_RopeLeaf<_CharT,_Alloc>*)_M_base)->_M_data;
uninitialized_copy_n(__s + __start_pos + _M_start, __req_len,
__buffer);
}
break;
default:
break;
}
}
typedef typename _Rope_rep_base<_CharT, _Alloc>::allocator_type
allocator_type;
_Rope_RopeSubstring(_Rope_RopeRep<_CharT, _Alloc>* __b, size_t __s,
size_t __l, const allocator_type& __a)
: _Rope_RopeFunction<_CharT, _Alloc>(this, __l, false, __a),
char_producer<_CharT>(), _M_base(__b), _M_start(__s)
{
#ifndef __GC
_M_base->_M_ref_nonnil();
#endif
this->_M_tag = __detail::_S_substringfn;
}
virtual ~_Rope_RopeSubstring() throw()
{
#ifndef __GC
_M_base->_M_unref_nonnil();
// _M_free_c_string(); -- done by parent class
#endif
}
};
// Self-destructing pointers to Rope_rep.
// These are not conventional smart pointers. Their
// only purpose in life is to ensure that unref is called
// on the pointer either at normal exit or if an exception
// is raised. It is the caller's responsibility to
// adjust reference counts when these pointers are initialized
// or assigned to. (This convention significantly reduces
// the number of potentially expensive reference count
// updates.)
#ifndef __GC
template<class _CharT, class _Alloc>
struct _Rope_self_destruct_ptr
{
_Rope_RopeRep<_CharT, _Alloc>* _M_ptr;
~_Rope_self_destruct_ptr()
{ _Rope_RopeRep<_CharT, _Alloc>::_S_unref(_M_ptr); }
#if __cpp_exceptions
_Rope_self_destruct_ptr() : _M_ptr(0) { }
#else
_Rope_self_destruct_ptr() { }
#endif
_Rope_self_destruct_ptr(_Rope_RopeRep<_CharT, _Alloc>* __p)
: _M_ptr(__p) { }
_Rope_RopeRep<_CharT, _Alloc>&
operator*()
{ return *_M_ptr; }
_Rope_RopeRep<_CharT, _Alloc>*
operator->()
{ return _M_ptr; }
operator _Rope_RopeRep<_CharT, _Alloc>*()
{ return _M_ptr; }
_Rope_self_destruct_ptr&
operator=(_Rope_RopeRep<_CharT, _Alloc>* __x)
{ _M_ptr = __x; return *this; }
};
#endif
// Dereferencing a nonconst iterator has to return something
// that behaves almost like a reference. It's not possible to
// return an actual reference since assignment requires extra
// work. And we would get into the same problems as with the
// CD2 version of basic_string.
template<class _CharT, class _Alloc>
class _Rope_char_ref_proxy
{
friend class rope<_CharT, _Alloc>;
friend class _Rope_iterator<_CharT, _Alloc>;
friend class _Rope_char_ptr_proxy<_CharT, _Alloc>;
#ifdef __GC
typedef _Rope_RopeRep<_CharT, _Alloc>* _Self_destruct_ptr;
#else
typedef _Rope_self_destruct_ptr<_CharT, _Alloc> _Self_destruct_ptr;
#endif
typedef _Rope_RopeRep<_CharT, _Alloc> _RopeRep;
typedef rope<_CharT, _Alloc> _My_rope;
size_t _M_pos;
_CharT _M_current;
bool _M_current_valid;
_My_rope* _M_root; // The whole rope.
public:
_Rope_char_ref_proxy(_My_rope* __r, size_t __p)
: _M_pos(__p), _M_current(), _M_current_valid(false), _M_root(__r) { }
_Rope_char_ref_proxy(const _Rope_char_ref_proxy& __x)
: _M_pos(__x._M_pos), _M_current(__x._M_current),
_M_current_valid(false), _M_root(__x._M_root) { }
// Don't preserve cache if the reference can outlive the
// expression. We claim that's not possible without calling
// a copy constructor or generating reference to a proxy
// reference. We declare the latter to have undefined semantics.
_Rope_char_ref_proxy(_My_rope* __r, size_t __p, _CharT __c)
: _M_pos(__p), _M_current(__c), _M_current_valid(true), _M_root(__r) { }
inline operator _CharT () const;
_Rope_char_ref_proxy&
operator=(_CharT __c);
_Rope_char_ptr_proxy<_CharT, _Alloc> operator&() const;
_Rope_char_ref_proxy&
operator=(const _Rope_char_ref_proxy& __c)
{ return operator=((_CharT)__c); }
};
template<class _CharT, class __Alloc>
inline void
swap(_Rope_char_ref_proxy <_CharT, __Alloc > __a,
_Rope_char_ref_proxy <_CharT, __Alloc > __b)
{
_CharT __tmp = __a;
__a = __b;
__b = __tmp;
}
template<class _CharT, class _Alloc>
class _Rope_char_ptr_proxy
{
// XXX this class should be rewritten.
friend class _Rope_char_ref_proxy<_CharT, _Alloc>;
size_t _M_pos;
rope<_CharT,_Alloc>* _M_root; // The whole rope.
public:
_Rope_char_ptr_proxy(const _Rope_char_ref_proxy<_CharT,_Alloc>& __x)
: _M_pos(__x._M_pos), _M_root(__x._M_root) { }
_Rope_char_ptr_proxy(const _Rope_char_ptr_proxy& __x)
: _M_pos(__x._M_pos), _M_root(__x._M_root) { }
_Rope_char_ptr_proxy() { }
_Rope_char_ptr_proxy(_CharT* __x)
: _M_root(0), _M_pos(0) { }
_Rope_char_ptr_proxy&
operator=(const _Rope_char_ptr_proxy& __x)
{
_M_pos = __x._M_pos;
_M_root = __x._M_root;
return *this;
}
template<class _CharT2, class _Alloc2>
friend bool
operator==(const _Rope_char_ptr_proxy<_CharT2, _Alloc2>& __x,
const _Rope_char_ptr_proxy<_CharT2, _Alloc2>& __y);
_Rope_char_ref_proxy<_CharT, _Alloc> operator*() const
{ return _Rope_char_ref_proxy<_CharT, _Alloc>(_M_root, _M_pos); }
};
// Rope iterators:
// Unlike in the C version, we cache only part of the stack
// for rope iterators, since they must be efficiently copyable.
// When we run out of cache, we have to reconstruct the iterator
// value.
// Pointers from iterators are not included in reference counts.
// Iterators are assumed to be thread private. Ropes can
// be shared.
template<class _CharT, class _Alloc>
class _Rope_iterator_base
: public std::iterator<std::random_access_iterator_tag, _CharT>
{
friend class rope<_CharT, _Alloc>;
public:
typedef _Alloc _allocator_type; // used in _Rope_rotate, VC++ workaround
typedef _Rope_RopeRep<_CharT, _Alloc> _RopeRep;
// Borland doesn't want this to be protected.
protected:
enum { _S_path_cache_len = 4 }; // Must be <= 9.
enum { _S_iterator_buf_len = 15 };
size_t _M_current_pos;
_RopeRep* _M_root; // The whole rope.
size_t _M_leaf_pos; // Starting position for current leaf
__GC_CONST _CharT* _M_buf_start;
// Buffer possibly
// containing current char.
__GC_CONST _CharT* _M_buf_ptr;
// Pointer to current char in buffer.
// != 0 ==> buffer valid.
__GC_CONST _CharT* _M_buf_end;
// One past __last valid char in buffer.
// What follows is the path cache. We go out of our
// way to make this compact.
// Path_end contains the bottom section of the path from
// the root to the current leaf.
const _RopeRep* _M_path_end[_S_path_cache_len];
int _M_leaf_index; // Last valid __pos in path_end;
// _M_path_end[0] ... _M_path_end[leaf_index-1]
// point to concatenation nodes.
unsigned char _M_path_directions;
// (path_directions >> __i) & 1 is 1
// iff we got from _M_path_end[leaf_index - __i - 1]
// to _M_path_end[leaf_index - __i] by going to the
// __right. Assumes path_cache_len <= 9.
_CharT _M_tmp_buf[_S_iterator_buf_len];
// Short buffer for surrounding chars.
// This is useful primarily for
// RopeFunctions. We put the buffer
// here to avoid locking in the
// multithreaded case.
// The cached path is generally assumed to be valid
// only if the buffer is valid.
static void _S_setbuf(_Rope_iterator_base& __x);
// Set buffer contents given
// path cache.
static void _S_setcache(_Rope_iterator_base& __x);
// Set buffer contents and
// path cache.
static void _S_setcache_for_incr(_Rope_iterator_base& __x);
// As above, but assumes path
// cache is valid for previous posn.
_Rope_iterator_base() { }
_Rope_iterator_base(_RopeRep* __root, size_t __pos)
: _M_current_pos(__pos), _M_root(__root), _M_buf_ptr(0) { }
void _M_incr(size_t __n);
void _M_decr(size_t __n);
public:
size_t
index() const
{ return _M_current_pos; }
_Rope_iterator_base(const _Rope_iterator_base& __x)
{
if (0 != __x._M_buf_ptr)
*this = __x;
else
{
_M_current_pos = __x._M_current_pos;
_M_root = __x._M_root;
_M_buf_ptr = 0;
}
}
};
template<class _CharT, class _Alloc>
class _Rope_iterator;
template<class _CharT, class _Alloc>
class _Rope_const_iterator
: public _Rope_iterator_base<_CharT, _Alloc>
{
friend class rope<_CharT, _Alloc>;
protected:
typedef _Rope_RopeRep<_CharT, _Alloc> _RopeRep;
// The one from the base class may not be directly visible.
_Rope_const_iterator(const _RopeRep* __root, size_t __pos)
: _Rope_iterator_base<_CharT, _Alloc>(const_cast<_RopeRep*>(__root),
__pos)
// Only nonconst iterators modify root ref count
{ }
public:
typedef _CharT reference; // Really a value. Returning a reference
// Would be a mess, since it would have
// to be included in refcount.
typedef const _CharT* pointer;
public:
_Rope_const_iterator() { }
_Rope_const_iterator(const _Rope_const_iterator& __x)
: _Rope_iterator_base<_CharT,_Alloc>(__x) { }
_Rope_const_iterator(const _Rope_iterator<_CharT,_Alloc>& __x);
_Rope_const_iterator(const rope<_CharT, _Alloc>& __r, size_t __pos)
: _Rope_iterator_base<_CharT,_Alloc>(__r._M_tree_ptr, __pos) { }
_Rope_const_iterator&
operator=(const _Rope_const_iterator& __x)
{
if (0 != __x._M_buf_ptr)
*(static_cast<_Rope_iterator_base<_CharT, _Alloc>*>(this)) = __x;
else
{
this->_M_current_pos = __x._M_current_pos;
this->_M_root = __x._M_root;
this->_M_buf_ptr = 0;
}
return(*this);
}
reference
operator*()
{
if (0 == this->_M_buf_ptr)
this->_S_setcache(*this);
return *this->_M_buf_ptr;
}
// Without this const version, Rope iterators do not meet the
// requirements of an Input Iterator.
reference
operator*() const
{
return *const_cast<_Rope_const_iterator&>(*this);
}
_Rope_const_iterator&
operator++()
{
__GC_CONST _CharT* __next;
if (0 != this->_M_buf_ptr
&& (__next = this->_M_buf_ptr + 1) < this->_M_buf_end)
{
this->_M_buf_ptr = __next;
++this->_M_current_pos;
}
else
this->_M_incr(1);
return *this;
}
_Rope_const_iterator&
operator+=(ptrdiff_t __n)
{
if (__n >= 0)
this->_M_incr(__n);
else
this->_M_decr(-__n);
return *this;
}
_Rope_const_iterator&
operator--()
{
this->_M_decr(1);
return *this;
}
_Rope_const_iterator&
operator-=(ptrdiff_t __n)
{
if (__n >= 0)
this->_M_decr(__n);
else
this->_M_incr(-__n);
return *this;
}
_Rope_const_iterator
operator++(int)
{
size_t __old_pos = this->_M_current_pos;
this->_M_incr(1);
return _Rope_const_iterator<_CharT,_Alloc>(this->_M_root, __old_pos);
// This makes a subsequent dereference expensive.
// Perhaps we should instead copy the iterator
// if it has a valid cache?
}
_Rope_const_iterator
operator--(int)
{
size_t __old_pos = this->_M_current_pos;
this->_M_decr(1);
return _Rope_const_iterator<_CharT,_Alloc>(this->_M_root, __old_pos);
}
template<class _CharT2, class _Alloc2>
friend _Rope_const_iterator<_CharT2, _Alloc2>
operator-(const _Rope_const_iterator<_CharT2, _Alloc2>& __x,
ptrdiff_t __n);
template<class _CharT2, class _Alloc2>
friend _Rope_const_iterator<_CharT2, _Alloc2>
operator+(const _Rope_const_iterator<_CharT2, _Alloc2>& __x,
ptrdiff_t __n);
template<class _CharT2, class _Alloc2>
friend _Rope_const_iterator<_CharT2, _Alloc2>
operator+(ptrdiff_t __n,
const _Rope_const_iterator<_CharT2, _Alloc2>& __x);
reference
operator[](size_t __n)
{ return rope<_CharT, _Alloc>::_S_fetch(this->_M_root,
this->_M_current_pos + __n); }
template<class _CharT2, class _Alloc2>
friend bool
operator==(const _Rope_const_iterator<_CharT2, _Alloc2>& __x,
const _Rope_const_iterator<_CharT2, _Alloc2>& __y);
template<class _CharT2, class _Alloc2>
friend bool
operator<(const _Rope_const_iterator<_CharT2, _Alloc2>& __x,
const _Rope_const_iterator<_CharT2, _Alloc2>& __y);
template<class _CharT2, class _Alloc2>
friend ptrdiff_t
operator-(const _Rope_const_iterator<_CharT2, _Alloc2>& __x,
const _Rope_const_iterator<_CharT2, _Alloc2>& __y);
};
template<class _CharT, class _Alloc>
class _Rope_iterator
: public _Rope_iterator_base<_CharT, _Alloc>
{
friend class rope<_CharT, _Alloc>;
protected:
typedef typename _Rope_iterator_base<_CharT, _Alloc>::_RopeRep _RopeRep;
rope<_CharT, _Alloc>* _M_root_rope;
// root is treated as a cached version of this, and is used to
// detect changes to the underlying rope.
// Root is included in the reference count. This is necessary
// so that we can detect changes reliably. Unfortunately, it
// requires careful bookkeeping for the nonGC case.
_Rope_iterator(rope<_CharT, _Alloc>* __r, size_t __pos)
: _Rope_iterator_base<_CharT, _Alloc>(__r->_M_tree_ptr, __pos),
_M_root_rope(__r)
{ _RopeRep::_S_ref(this->_M_root);
if (!(__r -> empty()))
this->_S_setcache(*this);
}
void _M_check();
public:
typedef _Rope_char_ref_proxy<_CharT, _Alloc> reference;
typedef _Rope_char_ref_proxy<_CharT, _Alloc>* pointer;
rope<_CharT, _Alloc>&
container()
{ return *_M_root_rope; }
_Rope_iterator()
{
this->_M_root = 0; // Needed for reference counting.
}
_Rope_iterator(const _Rope_iterator& __x)
: _Rope_iterator_base<_CharT, _Alloc>(__x)
{
_M_root_rope = __x._M_root_rope;
_RopeRep::_S_ref(this->_M_root);
}
_Rope_iterator(rope<_CharT, _Alloc>& __r, size_t __pos);
~_Rope_iterator()
{ _RopeRep::_S_unref(this->_M_root); }
_Rope_iterator&
operator=(const _Rope_iterator& __x)
{
_RopeRep* __old = this->_M_root;
_RopeRep::_S_ref(__x._M_root);
if (0 != __x._M_buf_ptr)
{
_M_root_rope = __x._M_root_rope;
*(static_cast<_Rope_iterator_base<_CharT, _Alloc>*>(this)) = __x;
}
else
{
this->_M_current_pos = __x._M_current_pos;
this->_M_root = __x._M_root;
_M_root_rope = __x._M_root_rope;
this->_M_buf_ptr = 0;
}
_RopeRep::_S_unref(__old);
return(*this);
}
reference
operator*()
{
_M_check();
if (0 == this->_M_buf_ptr)
return _Rope_char_ref_proxy<_CharT, _Alloc>(_M_root_rope,
this->_M_current_pos);
else
return _Rope_char_ref_proxy<_CharT, _Alloc>(_M_root_rope,
this->_M_current_pos,
*this->_M_buf_ptr);
}
// See above comment.
reference
operator*() const
{
return *const_cast<_Rope_iterator&>(*this);
}
_Rope_iterator&
operator++()
{
this->_M_incr(1);
return *this;
}
_Rope_iterator&
operator+=(ptrdiff_t __n)
{
if (__n >= 0)
this->_M_incr(__n);
else
this->_M_decr(-__n);
return *this;
}
_Rope_iterator&
operator--()
{
this->_M_decr(1);
return *this;
}
_Rope_iterator&
operator-=(ptrdiff_t __n)
{
if (__n >= 0)
this->_M_decr(__n);
else
this->_M_incr(-__n);
return *this;
}
_Rope_iterator
operator++(int)
{
size_t __old_pos = this->_M_current_pos;
this->_M_incr(1);
return _Rope_iterator<_CharT,_Alloc>(_M_root_rope, __old_pos);
}
_Rope_iterator
operator--(int)
{
size_t __old_pos = this->_M_current_pos;
this->_M_decr(1);
return _Rope_iterator<_CharT,_Alloc>(_M_root_rope, __old_pos);
}
reference
operator[](ptrdiff_t __n)
{ return _Rope_char_ref_proxy<_CharT, _Alloc>(_M_root_rope,
this->_M_current_pos
+ __n); }
template<class _CharT2, class _Alloc2>
friend bool
operator==(const _Rope_iterator<_CharT2, _Alloc2>& __x,
const _Rope_iterator<_CharT2, _Alloc2>& __y);
template<class _CharT2, class _Alloc2>
friend bool
operator<(const _Rope_iterator<_CharT2, _Alloc2>& __x,
const _Rope_iterator<_CharT2, _Alloc2>& __y);
template<class _CharT2, class _Alloc2>
friend ptrdiff_t
operator-(const _Rope_iterator<_CharT2, _Alloc2>& __x,
const _Rope_iterator<_CharT2, _Alloc2>& __y);
template<class _CharT2, class _Alloc2>
friend _Rope_iterator<_CharT2, _Alloc2>
operator-(const _Rope_iterator<_CharT2, _Alloc2>& __x, ptrdiff_t __n);
template<class _CharT2, class _Alloc2>
friend _Rope_iterator<_CharT2, _Alloc2>
operator+(const _Rope_iterator<_CharT2, _Alloc2>& __x, ptrdiff_t __n);
template<class _CharT2, class _Alloc2>
friend _Rope_iterator<_CharT2, _Alloc2>
operator+(ptrdiff_t __n, const _Rope_iterator<_CharT2, _Alloc2>& __x);
};
template <class _CharT, class _Alloc>
struct _Rope_base
: public _Alloc
{
typedef _Alloc allocator_type;
allocator_type
get_allocator() const
{ return *static_cast<const _Alloc*>(this); }
allocator_type&
_M_get_allocator()
{ return *static_cast<_Alloc*>(this); }
const allocator_type&
_M_get_allocator() const
{ return *static_cast<const _Alloc*>(this); }
typedef _Rope_RopeRep<_CharT, _Alloc> _RopeRep;
// The one in _Base may not be visible due to template rules.
_Rope_base(_RopeRep* __t, const allocator_type&)
: _M_tree_ptr(__t) { }
_Rope_base(const allocator_type&) { }
// The only data member of a rope:
_RopeRep *_M_tree_ptr;
#define __ROPE_DEFINE_ALLOC(_Tp, __name) \
typedef typename \
_Alloc::template rebind<_Tp>::other __name##Alloc; \
static _Tp* __name##_allocate(size_t __n) \
{ return __name##Alloc().allocate(__n); } \
static void __name##_deallocate(_Tp *__p, size_t __n) \
{ __name##Alloc().deallocate(__p, __n); }
__ROPE_DEFINE_ALLOCS(_Alloc)
#undef __ROPE_DEFINE_ALLOC
protected:
_Rope_base&
operator=(const _Rope_base&);
_Rope_base(const _Rope_base&);
};
/**
* This is an SGI extension.
* @ingroup SGIextensions
* @doctodo
*/
template <class _CharT, class _Alloc>
class rope : public _Rope_base<_CharT, _Alloc>
{
public:
typedef _CharT value_type;
typedef ptrdiff_t difference_type;
typedef size_t size_type;
typedef _CharT const_reference;
typedef const _CharT* const_pointer;
typedef _Rope_iterator<_CharT, _Alloc> iterator;
typedef _Rope_const_iterator<_CharT, _Alloc> const_iterator;
typedef _Rope_char_ref_proxy<_CharT, _Alloc> reference;
typedef _Rope_char_ptr_proxy<_CharT, _Alloc> pointer;
friend class _Rope_iterator<_CharT, _Alloc>;
friend class _Rope_const_iterator<_CharT, _Alloc>;
friend struct _Rope_RopeRep<_CharT, _Alloc>;
friend class _Rope_iterator_base<_CharT, _Alloc>;
friend class _Rope_char_ptr_proxy<_CharT, _Alloc>;
friend class _Rope_char_ref_proxy<_CharT, _Alloc>;
friend struct _Rope_RopeSubstring<_CharT, _Alloc>;
protected:
typedef _Rope_base<_CharT, _Alloc> _Base;
typedef typename _Base::allocator_type allocator_type;
using _Base::_M_tree_ptr;
using _Base::get_allocator;
using _Base::_M_get_allocator;
typedef __GC_CONST _CharT* _Cstrptr;
static _CharT _S_empty_c_str[1];
static bool
_S_is0(_CharT __c)
{ return __c == _S_eos((_CharT*)0); }
enum { _S_copy_max = 23 };
// For strings shorter than _S_copy_max, we copy to
// concatenate.
typedef _Rope_RopeRep<_CharT, _Alloc> _RopeRep;
typedef _Rope_RopeConcatenation<_CharT, _Alloc> _RopeConcatenation;
typedef _Rope_RopeLeaf<_CharT, _Alloc> _RopeLeaf;
typedef _Rope_RopeFunction<_CharT, _Alloc> _RopeFunction;
typedef _Rope_RopeSubstring<_CharT, _Alloc> _RopeSubstring;
// Retrieve a character at the indicated position.
static _CharT _S_fetch(_RopeRep* __r, size_type __pos);
#ifndef __GC
// Obtain a pointer to the character at the indicated position.
// The pointer can be used to change the character.
// If such a pointer cannot be produced, as is frequently the
// case, 0 is returned instead.
// (Returns nonzero only if all nodes in the path have a refcount
// of 1.)
static _CharT* _S_fetch_ptr(_RopeRep* __r, size_type __pos);
#endif
static bool
_S_apply_to_pieces(// should be template parameter
_Rope_char_consumer<_CharT>& __c,
const _RopeRep* __r,
size_t __begin, size_t __end);
// begin and end are assumed to be in range.
#ifndef __GC
static void
_S_unref(_RopeRep* __t)
{ _RopeRep::_S_unref(__t); }
static void
_S_ref(_RopeRep* __t)
{ _RopeRep::_S_ref(__t); }
#else /* __GC */
static void _S_unref(_RopeRep*) { }
static void _S_ref(_RopeRep*) { }
#endif
#ifdef __GC
typedef _Rope_RopeRep<_CharT, _Alloc>* _Self_destruct_ptr;
#else
typedef _Rope_self_destruct_ptr<_CharT, _Alloc> _Self_destruct_ptr;
#endif
// _Result is counted in refcount.
static _RopeRep* _S_substring(_RopeRep* __base,
size_t __start, size_t __endp1);
static _RopeRep* _S_concat_char_iter(_RopeRep* __r,
const _CharT* __iter, size_t __slen);
// Concatenate rope and char ptr, copying __s.
// Should really take an arbitrary iterator.
// Result is counted in refcount.
static _RopeRep* _S_destr_concat_char_iter(_RopeRep* __r,
const _CharT* __iter,
size_t __slen)
// As above, but one reference to __r is about to be
// destroyed. Thus the pieces may be recycled if all
// relevant reference counts are 1.
#ifdef __GC
// We can't really do anything since refcounts are unavailable.
{ return _S_concat_char_iter(__r, __iter, __slen); }
#else
;
#endif
static _RopeRep* _S_concat(_RopeRep* __left, _RopeRep* __right);
// General concatenation on _RopeRep. _Result
// has refcount of 1. Adjusts argument refcounts.
public:
void
apply_to_pieces(size_t __begin, size_t __end,
_Rope_char_consumer<_CharT>& __c) const
{ _S_apply_to_pieces(__c, this->_M_tree_ptr, __begin, __end); }
protected:
static size_t
_S_rounded_up_size(size_t __n)
{ return _RopeLeaf::_S_rounded_up_size(__n); }
static size_t
_S_allocated_capacity(size_t __n)
{
if (_S_is_basic_char_type((_CharT*)0))
return _S_rounded_up_size(__n) - 1;
else
return _S_rounded_up_size(__n);
}
// Allocate and construct a RopeLeaf using the supplied allocator
// Takes ownership of s instead of copying.
static _RopeLeaf*
_S_new_RopeLeaf(__GC_CONST _CharT *__s,
size_t __size, allocator_type& __a)
{
_RopeLeaf* __space = typename _Base::_LAlloc(__a).allocate(1);
return new(__space) _RopeLeaf(__s, __size, __a);
}
static _RopeConcatenation*
_S_new_RopeConcatenation(_RopeRep* __left, _RopeRep* __right,
allocator_type& __a)
{
_RopeConcatenation* __space = typename _Base::_CAlloc(__a).allocate(1);
return new(__space) _RopeConcatenation(__left, __right, __a);
}
static _RopeFunction*
_S_new_RopeFunction(char_producer<_CharT>* __f,
size_t __size, bool __d, allocator_type& __a)
{
_RopeFunction* __space = typename _Base::_FAlloc(__a).allocate(1);
return new(__space) _RopeFunction(__f, __size, __d, __a);
}
static _RopeSubstring*
_S_new_RopeSubstring(_Rope_RopeRep<_CharT,_Alloc>* __b, size_t __s,
size_t __l, allocator_type& __a)
{
_RopeSubstring* __space = typename _Base::_SAlloc(__a).allocate(1);
return new(__space) _RopeSubstring(__b, __s, __l, __a);
}
static _RopeLeaf*
_S_RopeLeaf_from_unowned_char_ptr(const _CharT *__s,
size_t __size, allocator_type& __a)
#define __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __size, __a) \
_S_RopeLeaf_from_unowned_char_ptr(__s, __size, __a)
{
if (0 == __size)
return 0;
_CharT* __buf = __a.allocate(_S_rounded_up_size(__size));
__uninitialized_copy_n_a(__s, __size, __buf, __a);
_S_cond_store_eos(__buf[__size]);
__try
{ return _S_new_RopeLeaf(__buf, __size, __a); }
__catch(...)
{
_RopeRep::__STL_FREE_STRING(__buf, __size, __a);
__throw_exception_again;
}
}
// Concatenation of nonempty strings.
// Always builds a concatenation node.
// Rebalances if the result is too deep.
// Result has refcount 1.
// Does not increment left and right ref counts even though
// they are referenced.
static _RopeRep*
_S_tree_concat(_RopeRep* __left, _RopeRep* __right);
// Concatenation helper functions
static _RopeLeaf*
_S_leaf_concat_char_iter(_RopeLeaf* __r,
const _CharT* __iter, size_t __slen);
// Concatenate by copying leaf.
// should take an arbitrary iterator
// result has refcount 1.
#ifndef __GC
static _RopeLeaf*
_S_destr_leaf_concat_char_iter(_RopeLeaf* __r,
const _CharT* __iter, size_t __slen);
// A version that potentially clobbers __r if __r->_M_ref_count == 1.
#endif
private:
static size_t _S_char_ptr_len(const _CharT* __s);
// slightly generalized strlen
rope(_RopeRep* __t, const allocator_type& __a = allocator_type())
: _Base(__t, __a) { }
// Copy __r to the _CharT buffer.
// Returns __buffer + __r->_M_size.
// Assumes that buffer is uninitialized.
static _CharT* _S_flatten(_RopeRep* __r, _CharT* __buffer);
// Again, with explicit starting position and length.
// Assumes that buffer is uninitialized.
static _CharT* _S_flatten(_RopeRep* __r,
size_t __start, size_t __len,
_CharT* __buffer);
static const unsigned long
_S_min_len[__detail::_S_max_rope_depth + 1];
static bool
_S_is_balanced(_RopeRep* __r)
{ return (__r->_M_size >= _S_min_len[__r->_M_depth]); }
static bool
_S_is_almost_balanced(_RopeRep* __r)
{ return (__r->_M_depth == 0
|| __r->_M_size >= _S_min_len[__r->_M_depth - 1]); }
static bool
_S_is_roughly_balanced(_RopeRep* __r)
{ return (__r->_M_depth <= 1
|| __r->_M_size >= _S_min_len[__r->_M_depth - 2]); }
// Assumes the result is not empty.
static _RopeRep*
_S_concat_and_set_balanced(_RopeRep* __left, _RopeRep* __right)
{
_RopeRep* __result = _S_concat(__left, __right);
if (_S_is_balanced(__result))
__result->_M_is_balanced = true;
return __result;
}
// The basic rebalancing operation. Logically copies the
// rope. The result has refcount of 1. The client will
// usually decrement the reference count of __r.
// The result is within height 2 of balanced by the above
// definition.
static _RopeRep* _S_balance(_RopeRep* __r);
// Add all unbalanced subtrees to the forest of balanced trees.
// Used only by balance.
static void _S_add_to_forest(_RopeRep*__r, _RopeRep** __forest);
// Add __r to forest, assuming __r is already balanced.
static void _S_add_leaf_to_forest(_RopeRep* __r, _RopeRep** __forest);
// Print to stdout, exposing structure
static void _S_dump(_RopeRep* __r, int __indent = 0);
// Return -1, 0, or 1 if __x < __y, __x == __y, or __x > __y resp.
static int _S_compare(const _RopeRep* __x, const _RopeRep* __y);
public:
bool
empty() const
{ return 0 == this->_M_tree_ptr; }
// Comparison member function. This is public only for those
// clients that need a ternary comparison. Others
// should use the comparison operators below.
int
compare(const rope& __y) const
{ return _S_compare(this->_M_tree_ptr, __y._M_tree_ptr); }
rope(const _CharT* __s, const allocator_type& __a = allocator_type())
: _Base(__a)
{
this->_M_tree_ptr =
__STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, _S_char_ptr_len(__s),
_M_get_allocator());
}
rope(const _CharT* __s, size_t __len,
const allocator_type& __a = allocator_type())
: _Base(__a)
{
this->_M_tree_ptr =
__STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __len, _M_get_allocator());
}
// Should perhaps be templatized with respect to the iterator type
// and use Sequence_buffer. (It should perhaps use sequence_buffer
// even now.)
rope(const _CharT* __s, const _CharT* __e,
const allocator_type& __a = allocator_type())
: _Base(__a)
{
this->_M_tree_ptr =
__STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __e - __s, _M_get_allocator());
}
rope(const const_iterator& __s, const const_iterator& __e,
const allocator_type& __a = allocator_type())
: _Base(_S_substring(__s._M_root, __s._M_current_pos,
__e._M_current_pos), __a)
{ }
rope(const iterator& __s, const iterator& __e,
const allocator_type& __a = allocator_type())
: _Base(_S_substring(__s._M_root, __s._M_current_pos,
__e._M_current_pos), __a)
{ }
rope(_CharT __c, const allocator_type& __a = allocator_type())
: _Base(__a)
{
_CharT* __buf = this->_Data_allocate(_S_rounded_up_size(1));
_M_get_allocator().construct(__buf, __c);
__try
{
this->_M_tree_ptr = _S_new_RopeLeaf(__buf, 1,
_M_get_allocator());
}
__catch(...)
{
_RopeRep::__STL_FREE_STRING(__buf, 1, _M_get_allocator());
__throw_exception_again;
}
}
rope(size_t __n, _CharT __c,
const allocator_type& __a = allocator_type());
rope(const allocator_type& __a = allocator_type())
: _Base(0, __a) { }
// Construct a rope from a function that can compute its members
rope(char_producer<_CharT> *__fn, size_t __len, bool __delete_fn,
const allocator_type& __a = allocator_type())
: _Base(__a)
{
this->_M_tree_ptr = (0 == __len)
? 0
: _S_new_RopeFunction(__fn, __len, __delete_fn, _M_get_allocator());
}
rope(const rope& __x, const allocator_type& __a = allocator_type())
: _Base(__x._M_tree_ptr, __a)
{ _S_ref(this->_M_tree_ptr); }
~rope() throw()
{ _S_unref(this->_M_tree_ptr); }
rope&
operator=(const rope& __x)
{
_RopeRep* __old = this->_M_tree_ptr;
this->_M_tree_ptr = __x._M_tree_ptr;
_S_ref(this->_M_tree_ptr);
_S_unref(__old);
return *this;
}
void
clear()
{
_S_unref(this->_M_tree_ptr);
this->_M_tree_ptr = 0;
}
void
push_back(_CharT __x)
{
_RopeRep* __old = this->_M_tree_ptr;
this->_M_tree_ptr
= _S_destr_concat_char_iter(this->_M_tree_ptr, &__x, 1);
_S_unref(__old);
}
void
pop_back()
{
_RopeRep* __old = this->_M_tree_ptr;
this->_M_tree_ptr = _S_substring(this->_M_tree_ptr,
0, this->_M_tree_ptr->_M_size - 1);
_S_unref(__old);
}
_CharT
back() const
{ return _S_fetch(this->_M_tree_ptr, this->_M_tree_ptr->_M_size - 1); }
void
push_front(_CharT __x)
{
_RopeRep* __old = this->_M_tree_ptr;
_RopeRep* __left =
__STL_ROPE_FROM_UNOWNED_CHAR_PTR(&__x, 1, _M_get_allocator());
__try
{
this->_M_tree_ptr = _S_concat(__left, this->_M_tree_ptr);
_S_unref(__old);
_S_unref(__left);
}
__catch(...)
{
_S_unref(__left);
__throw_exception_again;
}
}
void
pop_front()
{
_RopeRep* __old = this->_M_tree_ptr;
this->_M_tree_ptr
= _S_substring(this->_M_tree_ptr, 1, this->_M_tree_ptr->_M_size);
_S_unref(__old);
}
_CharT
front() const
{ return _S_fetch(this->_M_tree_ptr, 0); }
void
balance()
{
_RopeRep* __old = this->_M_tree_ptr;
this->_M_tree_ptr = _S_balance(this->_M_tree_ptr);
_S_unref(__old);
}
void
copy(_CharT* __buffer) const
{
_Destroy_const(__buffer, __buffer + size(), _M_get_allocator());
_S_flatten(this->_M_tree_ptr, __buffer);
}
// This is the copy function from the standard, but
// with the arguments reordered to make it consistent with the
// rest of the interface.
// Note that this guaranteed not to compile if the draft standard
// order is assumed.
size_type
copy(size_type __pos, size_type __n, _CharT* __buffer) const
{
size_t __size = size();
size_t __len = (__pos + __n > __size? __size - __pos : __n);
_Destroy_const(__buffer, __buffer + __len, _M_get_allocator());
_S_flatten(this->_M_tree_ptr, __pos, __len, __buffer);
return __len;
}
// Print to stdout, exposing structure. May be useful for
// performance debugging.
void
dump()
{ _S_dump(this->_M_tree_ptr); }
// Convert to 0 terminated string in new allocated memory.
// Embedded 0s in the input do not terminate the copy.
const _CharT* c_str() const;
// As above, but also use the flattened representation as
// the new rope representation.
const _CharT* replace_with_c_str();
// Reclaim memory for the c_str generated flattened string.
// Intentionally undocumented, since it's hard to say when this
// is safe for multiple threads.
void
delete_c_str ()
{
if (0 == this->_M_tree_ptr)
return;
if (__detail::_S_leaf == this->_M_tree_ptr->_M_tag &&
((_RopeLeaf*)this->_M_tree_ptr)->_M_data ==
this->_M_tree_ptr->_M_c_string)
{
// Representation shared
return;
}
#ifndef __GC
this->_M_tree_ptr->_M_free_c_string();
#endif
this->_M_tree_ptr->_M_c_string = 0;
}
_CharT
operator[] (size_type __pos) const
{ return _S_fetch(this->_M_tree_ptr, __pos); }
_CharT
at(size_type __pos) const
{
// if (__pos >= size()) throw out_of_range; // XXX
return (*this)[__pos];
}
const_iterator
begin() const
{ return(const_iterator(this->_M_tree_ptr, 0)); }
// An easy way to get a const iterator from a non-const container.
const_iterator
const_begin() const
{ return(const_iterator(this->_M_tree_ptr, 0)); }
const_iterator
end() const
{ return(const_iterator(this->_M_tree_ptr, size())); }
const_iterator
const_end() const
{ return(const_iterator(this->_M_tree_ptr, size())); }
size_type
size() const
{ return(0 == this->_M_tree_ptr? 0 : this->_M_tree_ptr->_M_size); }
size_type
length() const
{ return size(); }
size_type
max_size() const
{
return _S_min_len[int(__detail::_S_max_rope_depth) - 1] - 1;
// Guarantees that the result can be sufficiently
// balanced. Longer ropes will probably still work,
// but it's harder to make guarantees.
}
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
const_reverse_iterator
rbegin() const
{ return const_reverse_iterator(end()); }
const_reverse_iterator
const_rbegin() const
{ return const_reverse_iterator(end()); }
const_reverse_iterator
rend() const
{ return const_reverse_iterator(begin()); }
const_reverse_iterator
const_rend() const
{ return const_reverse_iterator(begin()); }
template<class _CharT2, class _Alloc2>
friend rope<_CharT2, _Alloc2>
operator+(const rope<_CharT2, _Alloc2>& __left,
const rope<_CharT2, _Alloc2>& __right);
template<class _CharT2, class _Alloc2>
friend rope<_CharT2, _Alloc2>
operator+(const rope<_CharT2, _Alloc2>& __left, const _CharT2* __right);
template<class _CharT2, class _Alloc2>
friend rope<_CharT2, _Alloc2>
operator+(const rope<_CharT2, _Alloc2>& __left, _CharT2 __right);
// The symmetric cases are intentionally omitted, since they're
// presumed to be less common, and we don't handle them as well.
// The following should really be templatized. The first
// argument should be an input iterator or forward iterator with
// value_type _CharT.
rope&
append(const _CharT* __iter, size_t __n)
{
_RopeRep* __result =
_S_destr_concat_char_iter(this->_M_tree_ptr, __iter, __n);
_S_unref(this->_M_tree_ptr);
this->_M_tree_ptr = __result;
return *this;
}
rope&
append(const _CharT* __c_string)
{
size_t __len = _S_char_ptr_len(__c_string);
append(__c_string, __len);
return(*this);
}
rope&
append(const _CharT* __s, const _CharT* __e)
{
_RopeRep* __result =
_S_destr_concat_char_iter(this->_M_tree_ptr, __s, __e - __s);
_S_unref(this->_M_tree_ptr);
this->_M_tree_ptr = __result;
return *this;
}
rope&
append(const_iterator __s, const_iterator __e)
{
_Self_destruct_ptr __appendee(_S_substring(__s._M_root,
__s._M_current_pos,
__e._M_current_pos));
_RopeRep* __result = _S_concat(this->_M_tree_ptr,
(_RopeRep*)__appendee);
_S_unref(this->_M_tree_ptr);
this->_M_tree_ptr = __result;
return *this;
}
rope&
append(_CharT __c)
{
_RopeRep* __result =
_S_destr_concat_char_iter(this->_M_tree_ptr, &__c, 1);
_S_unref(this->_M_tree_ptr);
this->_M_tree_ptr = __result;
return *this;
}
rope&
append()
{ return append(_CharT()); } // XXX why?
rope&
append(const rope& __y)
{
_RopeRep* __result = _S_concat(this->_M_tree_ptr, __y._M_tree_ptr);
_S_unref(this->_M_tree_ptr);
this->_M_tree_ptr = __result;
return *this;
}
rope&
append(size_t __n, _CharT __c)
{
rope<_CharT,_Alloc> __last(__n, __c);
return append(__last);
}
void
swap(rope& __b)
{
_RopeRep* __tmp = this->_M_tree_ptr;
this->_M_tree_ptr = __b._M_tree_ptr;
__b._M_tree_ptr = __tmp;
}
protected:
// Result is included in refcount.
static _RopeRep*
replace(_RopeRep* __old, size_t __pos1,
size_t __pos2, _RopeRep* __r)
{
if (0 == __old)
{
_S_ref(__r);
return __r;
}
_Self_destruct_ptr __left(_S_substring(__old, 0, __pos1));
_Self_destruct_ptr __right(_S_substring(__old, __pos2, __old->_M_size));
_RopeRep* __result;
if (0 == __r)
__result = _S_concat(__left, __right);
else
{
_Self_destruct_ptr __left_result(_S_concat(__left, __r));
__result = _S_concat(__left_result, __right);
}
return __result;
}
public:
void
insert(size_t __p, const rope& __r)
{
_RopeRep* __result =
replace(this->_M_tree_ptr, __p, __p, __r._M_tree_ptr);
_S_unref(this->_M_tree_ptr);
this->_M_tree_ptr = __result;
}
void
insert(size_t __p, size_t __n, _CharT __c)
{
rope<_CharT,_Alloc> __r(__n,__c);
insert(__p, __r);
}
void
insert(size_t __p, const _CharT* __i, size_t __n)
{
_Self_destruct_ptr __left(_S_substring(this->_M_tree_ptr, 0, __p));
_Self_destruct_ptr __right(_S_substring(this->_M_tree_ptr,
__p, size()));
_Self_destruct_ptr __left_result(_S_concat_char_iter(__left, __i, __n));
// _S_ destr_concat_char_iter should be safe here.
// But as it stands it's probably not a win, since __left
// is likely to have additional references.
_RopeRep* __result = _S_concat(__left_result, __right);
_S_unref(this->_M_tree_ptr);
this->_M_tree_ptr = __result;
}
void
insert(size_t __p, const _CharT* __c_string)
{ insert(__p, __c_string, _S_char_ptr_len(__c_string)); }
void
insert(size_t __p, _CharT __c)
{ insert(__p, &__c, 1); }
void
insert(size_t __p)
{
_CharT __c = _CharT();
insert(__p, &__c, 1);
}
void
insert(size_t __p, const _CharT* __i, const _CharT* __j)
{
rope __r(__i, __j);
insert(__p, __r);
}
void
insert(size_t __p, const const_iterator& __i,
const const_iterator& __j)
{
rope __r(__i, __j);
insert(__p, __r);
}
void
insert(size_t __p, const iterator& __i,
const iterator& __j)
{
rope __r(__i, __j);
insert(__p, __r);
}
// (position, length) versions of replace operations:
void
replace(size_t __p, size_t __n, const rope& __r)
{
_RopeRep* __result =
replace(this->_M_tree_ptr, __p, __p + __n, __r._M_tree_ptr);
_S_unref(this->_M_tree_ptr);
this->_M_tree_ptr = __result;
}
void
replace(size_t __p, size_t __n,
const _CharT* __i, size_t __i_len)
{
rope __r(__i, __i_len);
replace(__p, __n, __r);
}
void
replace(size_t __p, size_t __n, _CharT __c)
{
rope __r(__c);
replace(__p, __n, __r);
}
void
replace(size_t __p, size_t __n, const _CharT* __c_string)
{
rope __r(__c_string);
replace(__p, __n, __r);
}
void
replace(size_t __p, size_t __n,
const _CharT* __i, const _CharT* __j)
{
rope __r(__i, __j);
replace(__p, __n, __r);
}
void
replace(size_t __p, size_t __n,
const const_iterator& __i, const const_iterator& __j)
{
rope __r(__i, __j);
replace(__p, __n, __r);
}
void
replace(size_t __p, size_t __n,
const iterator& __i, const iterator& __j)
{
rope __r(__i, __j);
replace(__p, __n, __r);
}
// Single character variants:
void
replace(size_t __p, _CharT __c)
{
iterator __i(this, __p);
*__i = __c;
}
void
replace(size_t __p, const rope& __r)
{ replace(__p, 1, __r); }
void
replace(size_t __p, const _CharT* __i, size_t __i_len)
{ replace(__p, 1, __i, __i_len); }
void
replace(size_t __p, const _CharT* __c_string)
{ replace(__p, 1, __c_string); }
void
replace(size_t __p, const _CharT* __i, const _CharT* __j)
{ replace(__p, 1, __i, __j); }
void
replace(size_t __p, const const_iterator& __i,
const const_iterator& __j)
{ replace(__p, 1, __i, __j); }
void
replace(size_t __p, const iterator& __i,
const iterator& __j)
{ replace(__p, 1, __i, __j); }
// Erase, (position, size) variant.
void
erase(size_t __p, size_t __n)
{
_RopeRep* __result = replace(this->_M_tree_ptr, __p,
__p + __n, 0);
_S_unref(this->_M_tree_ptr);
this->_M_tree_ptr = __result;
}
// Erase, single character
void
erase(size_t __p)
{ erase(__p, __p + 1); }
// Insert, iterator variants.
iterator
insert(const iterator& __p, const rope& __r)
{
insert(__p.index(), __r);
return __p;
}
iterator
insert(const iterator& __p, size_t __n, _CharT __c)
{
insert(__p.index(), __n, __c);
return __p;
}
iterator insert(const iterator& __p, _CharT __c)
{
insert(__p.index(), __c);
return __p;
}
iterator
insert(const iterator& __p )
{
insert(__p.index());
return __p;
}
iterator
insert(const iterator& __p, const _CharT* c_string)
{
insert(__p.index(), c_string);
return __p;
}
iterator
insert(const iterator& __p, const _CharT* __i, size_t __n)
{
insert(__p.index(), __i, __n);
return __p;
}
iterator
insert(const iterator& __p, const _CharT* __i,
const _CharT* __j)
{
insert(__p.index(), __i, __j);
return __p;
}
iterator
insert(const iterator& __p,
const const_iterator& __i, const const_iterator& __j)
{
insert(__p.index(), __i, __j);
return __p;
}
iterator
insert(const iterator& __p,
const iterator& __i, const iterator& __j)
{
insert(__p.index(), __i, __j);
return __p;
}
// Replace, range variants.
void
replace(const iterator& __p, const iterator& __q, const rope& __r)
{ replace(__p.index(), __q.index() - __p.index(), __r); }
void
replace(const iterator& __p, const iterator& __q, _CharT __c)
{ replace(__p.index(), __q.index() - __p.index(), __c); }
void
replace(const iterator& __p, const iterator& __q,
const _CharT* __c_string)
{ replace(__p.index(), __q.index() - __p.index(), __c_string); }
void
replace(const iterator& __p, const iterator& __q,
const _CharT* __i, size_t __n)
{ replace(__p.index(), __q.index() - __p.index(), __i, __n); }
void
replace(const iterator& __p, const iterator& __q,
const _CharT* __i, const _CharT* __j)
{ replace(__p.index(), __q.index() - __p.index(), __i, __j); }
void
replace(const iterator& __p, const iterator& __q,
const const_iterator& __i, const const_iterator& __j)
{ replace(__p.index(), __q.index() - __p.index(), __i, __j); }
void
replace(const iterator& __p, const iterator& __q,
const iterator& __i, const iterator& __j)
{ replace(__p.index(), __q.index() - __p.index(), __i, __j); }
// Replace, iterator variants.
void
replace(const iterator& __p, const rope& __r)
{ replace(__p.index(), __r); }
void
replace(const iterator& __p, _CharT __c)
{ replace(__p.index(), __c); }
void
replace(const iterator& __p, const _CharT* __c_string)
{ replace(__p.index(), __c_string); }
void
replace(const iterator& __p, const _CharT* __i, size_t __n)
{ replace(__p.index(), __i, __n); }
void
replace(const iterator& __p, const _CharT* __i, const _CharT* __j)
{ replace(__p.index(), __i, __j); }
void
replace(const iterator& __p, const_iterator __i, const_iterator __j)
{ replace(__p.index(), __i, __j); }
void
replace(const iterator& __p, iterator __i, iterator __j)
{ replace(__p.index(), __i, __j); }
// Iterator and range variants of erase
iterator
erase(const iterator& __p, const iterator& __q)
{
size_t __p_index = __p.index();
erase(__p_index, __q.index() - __p_index);
return iterator(this, __p_index);
}
iterator
erase(const iterator& __p)
{
size_t __p_index = __p.index();
erase(__p_index, 1);
return iterator(this, __p_index);
}
rope
substr(size_t __start, size_t __len = 1) const
{
return rope<_CharT, _Alloc>(_S_substring(this->_M_tree_ptr,
__start,
__start + __len));
}
rope
substr(iterator __start, iterator __end) const
{
return rope<_CharT, _Alloc>(_S_substring(this->_M_tree_ptr,
__start.index(),
__end.index()));
}
rope
substr(iterator __start) const
{
size_t __pos = __start.index();
return rope<_CharT, _Alloc>(_S_substring(this->_M_tree_ptr,
__pos, __pos + 1));
}
rope
substr(const_iterator __start, const_iterator __end) const
{
// This might eventually take advantage of the cache in the
// iterator.
return rope<_CharT, _Alloc>(_S_substring(this->_M_tree_ptr,
__start.index(),
__end.index()));
}
rope<_CharT, _Alloc>
substr(const_iterator __start)
{
size_t __pos = __start.index();
return rope<_CharT, _Alloc>(_S_substring(this->_M_tree_ptr,
__pos, __pos + 1));
}
static const size_type npos;
size_type find(_CharT __c, size_type __pos = 0) const;
size_type
find(const _CharT* __s, size_type __pos = 0) const
{
size_type __result_pos;
const_iterator __result =
std::search(const_begin() + __pos, const_end(),
__s, __s + _S_char_ptr_len(__s));
__result_pos = __result.index();
#ifndef __STL_OLD_ROPE_SEMANTICS
if (__result_pos == size())
__result_pos = npos;
#endif
return __result_pos;
}
iterator
mutable_begin()
{ return(iterator(this, 0)); }
iterator
mutable_end()
{ return(iterator(this, size())); }
typedef std::reverse_iterator<iterator> reverse_iterator;
reverse_iterator
mutable_rbegin()
{ return reverse_iterator(mutable_end()); }
reverse_iterator
mutable_rend()
{ return reverse_iterator(mutable_begin()); }
reference
mutable_reference_at(size_type __pos)
{ return reference(this, __pos); }
#ifdef __STD_STUFF
reference
operator[] (size_type __pos)
{ return _char_ref_proxy(this, __pos); }
reference
at(size_type __pos)
{
// if (__pos >= size()) throw out_of_range; // XXX
return (*this)[__pos];
}
void resize(size_type __n, _CharT __c) { }
void resize(size_type __n) { }
void reserve(size_type __res_arg = 0) { }
size_type
capacity() const
{ return max_size(); }
// Stuff below this line is dangerous because it's error prone.
// I would really like to get rid of it.
// copy function with funny arg ordering.
size_type
copy(_CharT* __buffer, size_type __n,
size_type __pos = 0) const
{ return copy(__pos, __n, __buffer); }
iterator
end()
{ return mutable_end(); }
iterator
begin()
{ return mutable_begin(); }
reverse_iterator
rend()
{ return mutable_rend(); }
reverse_iterator
rbegin()
{ return mutable_rbegin(); }
#else
const_iterator
end()
{ return const_end(); }
const_iterator
begin()
{ return const_begin(); }
const_reverse_iterator
rend()
{ return const_rend(); }
const_reverse_iterator
rbegin()
{ return const_rbegin(); }
#endif
};
template <class _CharT, class _Alloc>
const typename rope<_CharT, _Alloc>::size_type
rope<_CharT, _Alloc>::npos = (size_type)(-1);
template <class _CharT, class _Alloc>
inline bool operator==(const _Rope_const_iterator<_CharT, _Alloc>& __x,
const _Rope_const_iterator<_CharT, _Alloc>& __y)
{ return (__x._M_current_pos == __y._M_current_pos
&& __x._M_root == __y._M_root); }
template <class _CharT, class _Alloc>
inline bool operator<(const _Rope_const_iterator<_CharT, _Alloc>& __x,
const _Rope_const_iterator<_CharT, _Alloc>& __y)
{ return (__x._M_current_pos < __y._M_current_pos); }
template <class _CharT, class _Alloc>
inline bool operator!=(const _Rope_const_iterator<_CharT, _Alloc>& __x,
const _Rope_const_iterator<_CharT, _Alloc>& __y)
{ return !(__x == __y); }
template <class _CharT, class _Alloc>
inline bool operator>(const _Rope_const_iterator<_CharT, _Alloc>& __x,
const _Rope_const_iterator<_CharT, _Alloc>& __y)
{ return __y < __x; }
template <class _CharT, class _Alloc>
inline bool
operator<=(const _Rope_const_iterator<_CharT, _Alloc>& __x,
const _Rope_const_iterator<_CharT, _Alloc>& __y)
{ return !(__y < __x); }
template <class _CharT, class _Alloc>
inline bool
operator>=(const _Rope_const_iterator<_CharT, _Alloc>& __x,
const _Rope_const_iterator<_CharT, _Alloc>& __y)
{ return !(__x < __y); }
template <class _CharT, class _Alloc>
inline ptrdiff_t
operator-(const _Rope_const_iterator<_CharT, _Alloc>& __x,
const _Rope_const_iterator<_CharT, _Alloc>& __y)
{ return (ptrdiff_t)__x._M_current_pos - (ptrdiff_t)__y._M_current_pos; }
template <class _CharT, class _Alloc>
inline _Rope_const_iterator<_CharT, _Alloc>
operator-(const _Rope_const_iterator<_CharT, _Alloc>& __x, ptrdiff_t __n)
{ return _Rope_const_iterator<_CharT, _Alloc>(__x._M_root,
__x._M_current_pos - __n); }
template <class _CharT, class _Alloc>
inline _Rope_const_iterator<_CharT, _Alloc>
operator+(const _Rope_const_iterator<_CharT, _Alloc>& __x, ptrdiff_t __n)
{ return _Rope_const_iterator<_CharT, _Alloc>(__x._M_root,
__x._M_current_pos + __n); }
template <class _CharT, class _Alloc>
inline _Rope_const_iterator<_CharT, _Alloc>
operator+(ptrdiff_t __n, const _Rope_const_iterator<_CharT, _Alloc>& __x)
{ return _Rope_const_iterator<_CharT, _Alloc>(__x._M_root,
__x._M_current_pos + __n); }
template <class _CharT, class _Alloc>
inline bool
operator==(const _Rope_iterator<_CharT, _Alloc>& __x,
const _Rope_iterator<_CharT, _Alloc>& __y)
{return (__x._M_current_pos == __y._M_current_pos
&& __x._M_root_rope == __y._M_root_rope); }
template <class _CharT, class _Alloc>
inline bool
operator<(const _Rope_iterator<_CharT, _Alloc>& __x,
const _Rope_iterator<_CharT, _Alloc>& __y)
{ return (__x._M_current_pos < __y._M_current_pos); }
template <class _CharT, class _Alloc>
inline bool
operator!=(const _Rope_iterator<_CharT, _Alloc>& __x,
const _Rope_iterator<_CharT, _Alloc>& __y)
{ return !(__x == __y); }
template <class _CharT, class _Alloc>
inline bool
operator>(const _Rope_iterator<_CharT, _Alloc>& __x,
const _Rope_iterator<_CharT, _Alloc>& __y)
{ return __y < __x; }
template <class _CharT, class _Alloc>
inline bool
operator<=(const _Rope_iterator<_CharT, _Alloc>& __x,
const _Rope_iterator<_CharT, _Alloc>& __y)
{ return !(__y < __x); }
template <class _CharT, class _Alloc>
inline bool
operator>=(const _Rope_iterator<_CharT, _Alloc>& __x,
const _Rope_iterator<_CharT, _Alloc>& __y)
{ return !(__x < __y); }
template <class _CharT, class _Alloc>
inline ptrdiff_t
operator-(const _Rope_iterator<_CharT, _Alloc>& __x,
const _Rope_iterator<_CharT, _Alloc>& __y)
{ return ((ptrdiff_t)__x._M_current_pos
- (ptrdiff_t)__y._M_current_pos); }
template <class _CharT, class _Alloc>
inline _Rope_iterator<_CharT, _Alloc>
operator-(const _Rope_iterator<_CharT, _Alloc>& __x,
ptrdiff_t __n)
{ return _Rope_iterator<_CharT, _Alloc>(__x._M_root_rope,
__x._M_current_pos - __n); }
template <class _CharT, class _Alloc>
inline _Rope_iterator<_CharT, _Alloc>
operator+(const _Rope_iterator<_CharT, _Alloc>& __x, ptrdiff_t __n)
{ return _Rope_iterator<_CharT, _Alloc>(__x._M_root_rope,
__x._M_current_pos + __n); }
template <class _CharT, class _Alloc>
inline _Rope_iterator<_CharT, _Alloc>
operator+(ptrdiff_t __n, const _Rope_iterator<_CharT, _Alloc>& __x)
{ return _Rope_iterator<_CharT, _Alloc>(__x._M_root_rope,
__x._M_current_pos + __n); }
template <class _CharT, class _Alloc>
inline rope<_CharT, _Alloc>
operator+(const rope<_CharT, _Alloc>& __left,
const rope<_CharT, _Alloc>& __right)
{
// Inlining this should make it possible to keep __left and
// __right in registers.
typedef rope<_CharT, _Alloc> rope_type;
return rope_type(rope_type::_S_concat(__left._M_tree_ptr,
__right._M_tree_ptr));
}
template <class _CharT, class _Alloc>
inline rope<_CharT, _Alloc>&
operator+=(rope<_CharT, _Alloc>& __left,
const rope<_CharT, _Alloc>& __right)
{
__left.append(__right);
return __left;
}
template <class _CharT, class _Alloc>
inline rope<_CharT, _Alloc>
operator+(const rope<_CharT, _Alloc>& __left,
const _CharT* __right)
{
typedef rope<_CharT, _Alloc> rope_type;
size_t __rlen = rope_type::_S_char_ptr_len(__right);
return rope_type(rope_type::_S_concat_char_iter(__left._M_tree_ptr,
__right, __rlen));
}
template <class _CharT, class _Alloc>
inline rope<_CharT, _Alloc>&
operator+=(rope<_CharT, _Alloc>& __left,
const _CharT* __right)
{
__left.append(__right);
return __left;
}
template <class _CharT, class _Alloc>
inline rope<_CharT, _Alloc>
operator+(const rope<_CharT, _Alloc>& __left, _CharT __right)
{
typedef rope<_CharT, _Alloc> rope_type;
return rope_type(rope_type::_S_concat_char_iter(__left._M_tree_ptr,
&__right, 1));
}
template <class _CharT, class _Alloc>
inline rope<_CharT, _Alloc>&
operator+=(rope<_CharT, _Alloc>& __left, _CharT __right)
{
__left.append(__right);
return __left;
}
template <class _CharT, class _Alloc>
bool
operator<(const rope<_CharT, _Alloc>& __left,
const rope<_CharT, _Alloc>& __right)
{ return __left.compare(__right) < 0; }
template <class _CharT, class _Alloc>
bool
operator==(const rope<_CharT, _Alloc>& __left,
const rope<_CharT, _Alloc>& __right)
{ return __left.compare(__right) == 0; }
template <class _CharT, class _Alloc>
inline bool
operator==(const _Rope_char_ptr_proxy<_CharT, _Alloc>& __x,
const _Rope_char_ptr_proxy<_CharT, _Alloc>& __y)
{ return (__x._M_pos == __y._M_pos && __x._M_root == __y._M_root); }
template <class _CharT, class _Alloc>
inline bool
operator!=(const rope<_CharT, _Alloc>& __x,
const rope<_CharT, _Alloc>& __y)
{ return !(__x == __y); }
template <class _CharT, class _Alloc>
inline bool
operator>(const rope<_CharT, _Alloc>& __x,
const rope<_CharT, _Alloc>& __y)
{ return __y < __x; }
template <class _CharT, class _Alloc>
inline bool
operator<=(const rope<_CharT, _Alloc>& __x,
const rope<_CharT, _Alloc>& __y)
{ return !(__y < __x); }
template <class _CharT, class _Alloc>
inline bool
operator>=(const rope<_CharT, _Alloc>& __x,
const rope<_CharT, _Alloc>& __y)
{ return !(__x < __y); }
template <class _CharT, class _Alloc>
inline bool
operator!=(const _Rope_char_ptr_proxy<_CharT, _Alloc>& __x,
const _Rope_char_ptr_proxy<_CharT, _Alloc>& __y)
{ return !(__x == __y); }
template<class _CharT, class _Traits, class _Alloc>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __o,
const rope<_CharT, _Alloc>& __r);
typedef rope<char> crope;
typedef rope<wchar_t> wrope;
inline crope::reference
__mutable_reference_at(crope& __c, size_t __i)
{ return __c.mutable_reference_at(__i); }
inline wrope::reference
__mutable_reference_at(wrope& __c, size_t __i)
{ return __c.mutable_reference_at(__i); }
template <class _CharT, class _Alloc>
inline void
swap(rope<_CharT, _Alloc>& __x, rope<_CharT, _Alloc>& __y)
{ __x.swap(__y); }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
namespace tr1
{
template<>
struct hash<__gnu_cxx::crope>
{
size_t
operator()(const __gnu_cxx::crope& __str) const
{
size_t __size = __str.size();
if (0 == __size)
return 0;
return 13 * __str[0] + 5 * __str[__size - 1] + __size;
}
};
template<>
struct hash<__gnu_cxx::wrope>
{
size_t
operator()(const __gnu_cxx::wrope& __str) const
{
size_t __size = __str.size();
if (0 == __size)
return 0;
return 13 * __str[0] + 5 * __str[__size - 1] + __size;
}
};
} // namespace tr1
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
# include <ext/ropeimpl.h>
#endif
c++/8/ext/pb_ds/trie_policy.hpp 0000644 00000027701 15201526705 0012217 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file trie_policy.hpp
* Contains trie-related policies.
*/
#ifndef PB_DS_TRIE_POLICY_HPP
#define PB_DS_TRIE_POLICY_HPP
#include <bits/c++config.h>
#include <string>
#include <ext/pb_ds/detail/type_utils.hpp>
#include <ext/pb_ds/detail/trie_policy/trie_policy_base.hpp>
namespace __gnu_pbds
{
#define PB_DS_CLASS_T_DEC \
template<typename String, typename String::value_type Min_E_Val, \
typename String::value_type Max_E_Val, bool Reverse, \
typename _Alloc>
#define PB_DS_CLASS_C_DEC \
trie_string_access_traits<String, Min_E_Val,Max_E_Val,Reverse,_Alloc>
/**
* Element access traits for string types.
*
* @tparam String String type.
* @tparam Min_E_Val Minimal element value.
* @tparam Max_E_Val Maximum element value.
* @tparam Reverse Reverse iteration should be used.
* Default: false.
* @tparam _Alloc Allocator type.
*/
template<typename String = std::string,
typename String::value_type Min_E_Val = detail::__numeric_traits<typename String::value_type>::__min,
typename String::value_type Max_E_Val = detail::__numeric_traits<typename String::value_type>::__max,
bool Reverse = false,
typename _Alloc = std::allocator<char> >
struct trie_string_access_traits
{
public:
typedef typename _Alloc::size_type size_type;
typedef String key_type;
typedef typename _Alloc::template rebind<key_type> __rebind_k;
typedef typename __rebind_k::other::const_reference key_const_reference;
enum
{
reverse = Reverse
};
/// Element const iterator type.
typedef typename detail::__conditional_type<Reverse, \
typename String::const_reverse_iterator, \
typename String::const_iterator>::__type const_iterator;
/// Element type.
typedef typename std::iterator_traits<const_iterator>::value_type e_type;
enum
{
min_e_val = Min_E_Val,
max_e_val = Max_E_Val,
max_size = max_e_val - min_e_val + 1
};
PB_DS_STATIC_ASSERT(min_max_size, max_size >= 2);
/// Returns a const_iterator to the first element of
/// key_const_reference agumnet.
inline static const_iterator
begin(key_const_reference);
/// Returns a const_iterator to the after-last element of
/// key_const_reference argument.
inline static const_iterator
end(key_const_reference);
/// Maps an element to a position.
inline static size_type
e_pos(e_type e);
private:
inline static const_iterator
begin_imp(key_const_reference, detail::false_type);
inline static const_iterator
begin_imp(key_const_reference, detail::true_type);
inline static const_iterator
end_imp(key_const_reference, detail::false_type);
inline static const_iterator
end_imp(key_const_reference, detail::true_type);
static detail::integral_constant<int, Reverse> s_rev_ind;
};
#include <ext/pb_ds/detail/trie_policy/trie_string_access_traits_imp.hpp>
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
#define PB_DS_CLASS_T_DEC \
template<typename Node_CItr,typename Node_Itr, \
typename _ATraits, typename _Alloc>
#define PB_DS_CLASS_C_DEC \
trie_prefix_search_node_update<Node_CItr, Node_Itr, \
_ATraits,_Alloc>
#define PB_DS_TRIE_POLICY_BASE \
detail::trie_policy_base<Node_CItr,Node_Itr,_ATraits, _Alloc>
/// A node updator that allows tries to be searched for the range of
/// values that match a certain prefix.
template<typename Node_CItr,
typename Node_Itr,
typename _ATraits,
typename _Alloc>
class trie_prefix_search_node_update : private PB_DS_TRIE_POLICY_BASE
{
private:
typedef PB_DS_TRIE_POLICY_BASE base_type;
public:
typedef typename base_type::key_type key_type;
typedef typename base_type::key_const_reference key_const_reference;
/// Element access traits.
typedef _ATraits access_traits;
/// Const element iterator.
typedef typename access_traits::const_iterator a_const_iterator;
/// _Alloc type.
typedef _Alloc allocator_type;
/// Size type.
typedef typename allocator_type::size_type size_type;
typedef null_type metadata_type;
typedef Node_Itr node_iterator;
typedef Node_CItr node_const_iterator;
typedef typename node_iterator::value_type iterator;
typedef typename node_const_iterator::value_type const_iterator;
/// Finds the const iterator range corresponding to all values
/// whose prefixes match r_key.
std::pair<const_iterator, const_iterator>
prefix_range(key_const_reference) const;
/// Finds the iterator range corresponding to all values whose
/// prefixes match r_key.
std::pair<iterator, iterator>
prefix_range(key_const_reference);
/// Finds the const iterator range corresponding to all values
/// whose prefixes match [b, e).
std::pair<const_iterator, const_iterator>
prefix_range(a_const_iterator, a_const_iterator) const;
/// Finds the iterator range corresponding to all values whose
/// prefixes match [b, e).
std::pair<iterator, iterator>
prefix_range(a_const_iterator, a_const_iterator);
protected:
/// Called to update a node's metadata.
inline void
operator()(node_iterator node_it, node_const_iterator end_nd_it) const;
private:
node_iterator
next_child(node_iterator, a_const_iterator, a_const_iterator,
node_iterator, const access_traits&);
/// Returns the const iterator associated with the just-after last element.
virtual const_iterator
end() const = 0;
/// Returns the iterator associated with the just-after last element.
virtual iterator
end() = 0;
/// Returns the node_const_iterator associated with the trie's root node.
virtual node_const_iterator
node_begin() const = 0;
/// Returns the node_iterator associated with the trie's root node.
virtual node_iterator
node_begin() = 0;
/// Returns the node_const_iterator associated with a just-after leaf node.
virtual node_const_iterator
node_end() const = 0;
/// Returns the node_iterator associated with a just-after leaf node.
virtual node_iterator
node_end() = 0;
/// Access to the cmp_fn object.
virtual const access_traits&
get_access_traits() const = 0;
};
#include <ext/pb_ds/detail/trie_policy/prefix_search_node_update_imp.hpp>
#undef PB_DS_CLASS_C_DEC
#define PB_DS_CLASS_C_DEC \
trie_order_statistics_node_update<Node_CItr, Node_Itr, \
_ATraits, _Alloc>
/// Functor updating ranks of entrees.
template<typename Node_CItr,
typename Node_Itr,
typename _ATraits,
typename _Alloc>
class trie_order_statistics_node_update : private PB_DS_TRIE_POLICY_BASE
{
private:
typedef PB_DS_TRIE_POLICY_BASE base_type;
public:
typedef _ATraits access_traits;
typedef typename access_traits::const_iterator a_const_iterator;
typedef _Alloc allocator_type;
typedef typename allocator_type::size_type size_type;
typedef typename base_type::key_type key_type;
typedef typename base_type::key_const_reference key_const_reference;
typedef size_type metadata_type;
typedef Node_CItr node_const_iterator;
typedef Node_Itr node_iterator;
typedef typename node_const_iterator::value_type const_iterator;
typedef typename node_iterator::value_type iterator;
/// Finds an entry by __order. Returns a const_iterator to the
/// entry with the __order order, or a const_iterator to the
/// container object's end if order is at least the size of the
/// container object.
inline const_iterator
find_by_order(size_type) const;
/// Finds an entry by __order. Returns an iterator to the entry
/// with the __order order, or an iterator to the container
/// object's end if order is at least the size of the container
/// object.
inline iterator
find_by_order(size_type);
/// Returns the order of a key within a sequence. For exapmle, if
/// r_key is the smallest key, this method will return 0; if r_key
/// is a key between the smallest and next key, this method will
/// return 1; if r_key is a key larger than the largest key, this
/// method will return the size of r_c.
inline size_type
order_of_key(key_const_reference) const;
/// Returns the order of a prefix within a sequence. For exapmle,
/// if [b, e] is the smallest prefix, this method will return 0; if
/// r_key is a key between the smallest and next key, this method
/// will return 1; if r_key is a key larger than the largest key,
/// this method will return the size of r_c.
inline size_type
order_of_prefix(a_const_iterator, a_const_iterator) const;
protected:
/// Updates the rank of a node through a node_iterator node_it;
/// end_nd_it is the end node iterator.
inline void
operator()(node_iterator, node_const_iterator) const;
private:
typedef typename base_type::const_reference const_reference;
typedef typename base_type::const_pointer const_pointer;
typedef typename _Alloc::template rebind<metadata_type> __rebind_m;
typedef typename __rebind_m::other __rebind_ma;
typedef typename __rebind_ma::const_reference metadata_const_reference;
typedef typename __rebind_ma::reference metadata_reference;
/// Returns true if the container is empty.
virtual bool
empty() const = 0;
/// Returns the iterator associated with the trie's first element.
virtual iterator
begin() = 0;
/// Returns the iterator associated with the trie's
/// just-after-last element.
virtual iterator
end() = 0;
/// Returns the node_const_iterator associated with the trie's root node.
virtual node_const_iterator
node_begin() const = 0;
/// Returns the node_iterator associated with the trie's root node.
virtual node_iterator
node_begin() = 0;
/// Returns the node_const_iterator associated with a just-after
/// leaf node.
virtual node_const_iterator
node_end() const = 0;
/// Returns the node_iterator associated with a just-after leaf node.
virtual node_iterator
node_end() = 0;
/// Access to the cmp_fn object.
virtual access_traits&
get_access_traits() = 0;
};
#include <ext/pb_ds/detail/trie_policy/order_statistics_imp.hpp>
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_TRIE_POLICY_BASE
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/assoc_container.hpp 0000644 00000072636 15201526705 0013056 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file assoc_container.hpp
* Contains associative containers.
*/
#ifndef PB_DS_ASSOC_CNTNR_HPP
#define PB_DS_ASSOC_CNTNR_HPP
#include <bits/c++config.h>
#include <ext/typelist.h>
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/detail/container_base_dispatch.hpp>
#include <ext/pb_ds/detail/branch_policy/traits.hpp>
namespace __gnu_pbds
{
/**
* @defgroup containers-pbds Containers
* @ingroup pbds
* @{
*/
/**
* @defgroup hash-based Hash-Based
* @ingroup containers-pbds
* @{
*/
#define PB_DS_HASH_BASE \
detail::container_base_dispatch<Key, Mapped, _Alloc, Tag, \
typename __gnu_cxx::typelist::append< \
typename __gnu_cxx::typelist::create4<Hash_Fn, Eq_Fn, Resize_Policy, \
detail::integral_constant<int, Store_Hash> >::type, Policy_Tl>::type>::type
/**
* @defgroup hash-detail Base and Policy Classes
* @ingroup hash-based
*/
/**
* A hashed container abstraction.
*
* @tparam Key Key type.
* @tparam Mapped Map type.
* @tparam Hash_Fn Hashing functor.
* @tparam Eq_Fn Equal functor.
* @tparam Resize_Policy Resizes hash.
* @tparam Store_Hash Indicates whether the hash value
* will be stored along with each key.
* @tparam Tag Instantiating data structure type,
* see container_tag.
* @tparam Policy_TL Policy typelist.
* @tparam _Alloc Allocator type.
*
* Base is dispatched at compile time via Tag, from the following
* choices: cc_hash_tag, gp_hash_tag, and descendants of basic_hash_tag.
*
* Base choices are: detail::cc_ht_map, detail::gp_ht_map
*/
template<typename Key,
typename Mapped,
typename Hash_Fn,
typename Eq_Fn,
typename Resize_Policy,
bool Store_Hash,
typename Tag,
typename Policy_Tl,
typename _Alloc>
class basic_hash_table : public PB_DS_HASH_BASE
{
private:
typedef typename PB_DS_HASH_BASE base_type;
public:
virtual
~basic_hash_table() { }
protected:
basic_hash_table() { }
basic_hash_table(const basic_hash_table& other)
: base_type((const base_type&)other) { }
template<typename T0>
basic_hash_table(T0 t0) : base_type(t0) { }
template<typename T0, typename T1>
basic_hash_table(T0 t0, T1 t1) : base_type(t0, t1) { }
template<typename T0, typename T1, typename T2>
basic_hash_table(T0 t0, T1 t1, T2 t2) : base_type(t0, t1, t2) { }
template<typename T0, typename T1, typename T2, typename T3>
basic_hash_table(T0 t0, T1 t1, T2 t2, T3 t3)
: base_type(t0, t1, t2, t3) { }
template<typename T0, typename T1, typename T2, typename T3, typename T4>
basic_hash_table(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4)
: base_type(t0, t1, t2, t3, t4) { }
template<typename T0, typename T1, typename T2, typename T3, typename T4,
typename T5>
basic_hash_table(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
: base_type(t0, t1, t2, t3, t4, t5) { }
template<typename T0, typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6>
basic_hash_table(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
: base_type(t0, t1, t2, t3, t4, t5, t6) { }
template<typename T0, typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7>
basic_hash_table(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7)
: base_type(t0, t1, t2, t3, t4, t5, t6, t7) { }
template<typename T0, typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8>
basic_hash_table(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6,
T7 t7, T8 t8)
: base_type(t0, t1, t2, t3, t4, t5, t6, t7, t8)
{ }
private:
basic_hash_table&
operator=(const base_type&);
};
#undef PB_DS_HASH_BASE
#define PB_DS_CC_HASH_BASE \
basic_hash_table<Key, Mapped, Hash_Fn, Eq_Fn, Resize_Policy, Store_Hash, \
cc_hash_tag, \
typename __gnu_cxx::typelist::create1<Comb_Hash_Fn>::type, _Alloc>
/**
* A collision-chaining hash-based associative container.
*
* @tparam Key Key type.
* @tparam Mapped Map type.
* @tparam Hash_Fn Hashing functor.
* @tparam Eq_Fn Equal functor.
* @tparam Comb_Hash_Fn Combining hash functor.
* If Hash_Fn is not null_type, then this
* is the ranged-hash functor; otherwise,
* this is the range-hashing functor.
* XXX(See Design::Hash-Based Containers::Hash Policies.)
* @tparam Resize_Policy Resizes hash.
* @tparam Store_Hash Indicates whether the hash value
* will be stored along with each key.
* If Hash_Fn is null_type, then the
* container will not compile if this
* value is true
* @tparam _Alloc Allocator type.
*
* Base tag choices are: cc_hash_tag.
*
* Base is basic_hash_table.
*/
template<typename Key,
typename Mapped,
typename Hash_Fn = typename detail::default_hash_fn<Key>::type,
typename Eq_Fn = typename detail::default_eq_fn<Key>::type,
typename Comb_Hash_Fn = detail::default_comb_hash_fn::type,
typename Resize_Policy = typename detail::default_resize_policy<Comb_Hash_Fn>::type,
bool Store_Hash = detail::default_store_hash,
typename _Alloc = std::allocator<char> >
class cc_hash_table : public PB_DS_CC_HASH_BASE
{
private:
typedef PB_DS_CC_HASH_BASE base_type;
public:
typedef cc_hash_tag container_category;
typedef Hash_Fn hash_fn;
typedef Eq_Fn eq_fn;
typedef Resize_Policy resize_policy;
typedef Comb_Hash_Fn comb_hash_fn;
/// Default constructor.
cc_hash_table() { }
/// Constructor taking some policy objects. r_hash_fn will be
/// copied by the Hash_Fn object of the container object.
cc_hash_table(const hash_fn& h)
: base_type(h) { }
/// Constructor taking some policy objects. r_hash_fn will be
/// copied by the hash_fn object of the container object, and
/// r_eq_fn will be copied by the eq_fn object of the container
/// object.
cc_hash_table(const hash_fn& h, const eq_fn& e)
: base_type(h, e) { }
/// Constructor taking some policy objects. r_hash_fn will be
/// copied by the hash_fn object of the container object, r_eq_fn
/// will be copied by the eq_fn object of the container object,
/// and r_comb_hash_fn will be copied by the comb_hash_fn object
/// of the container object.
cc_hash_table(const hash_fn& h, const eq_fn& e, const comb_hash_fn& ch)
: base_type(h, e, ch) { }
/// Constructor taking some policy objects. r_hash_fn will be
/// copied by the hash_fn object of the container object, r_eq_fn
/// will be copied by the eq_fn object of the container object,
/// r_comb_hash_fn will be copied by the comb_hash_fn object of
/// the container object, and r_resize_policy will be copied by
/// the resize_policy object of the container object.
cc_hash_table(const hash_fn& h, const eq_fn& e, const comb_hash_fn& ch,
const resize_policy& rp)
: base_type(h, e, ch, rp) { }
/// Constructor taking __iterators to a range of value_types. The
/// value_types between first_it and last_it will be inserted into
/// the container object.
template<typename It>
cc_hash_table(It first, It last)
{ base_type::copy_from_range(first, last); }
/// Constructor taking __iterators to a range of value_types and
/// some policy objects. The value_types between first_it and
/// last_it will be inserted into the container object.
template<typename It>
cc_hash_table(It first, It last, const hash_fn& h)
: base_type(h)
{ this->copy_from_range(first, last); }
/// Constructor taking __iterators to a range of value_types and
/// some policy objects The value_types between first_it and
/// last_it will be inserted into the container object. r_hash_fn
/// will be copied by the hash_fn object of the container object,
/// and r_eq_fn will be copied by the eq_fn object of the
/// container object.
template<typename It>
cc_hash_table(It first, It last, const hash_fn& h, const eq_fn& e)
: base_type(h, e)
{ this->copy_from_range(first, last); }
/// Constructor taking __iterators to a range of value_types and
/// some policy objects The value_types between first_it and
/// last_it will be inserted into the container object. r_hash_fn
/// will be copied by the hash_fn object of the container object,
/// r_eq_fn will be copied by the eq_fn object of the container
/// object, and r_comb_hash_fn will be copied by the comb_hash_fn
/// object of the container object.
template<typename It>
cc_hash_table(It first, It last, const hash_fn& h, const eq_fn& e,
const comb_hash_fn& ch)
: base_type(h, e, ch)
{ this->copy_from_range(first, last); }
/// Constructor taking __iterators to a range of value_types and
/// some policy objects The value_types between first_it and
/// last_it will be inserted into the container object. r_hash_fn
/// will be copied by the hash_fn object of the container object,
/// r_eq_fn will be copied by the eq_fn object of the container
/// object, r_comb_hash_fn will be copied by the comb_hash_fn
/// object of the container object, and r_resize_policy will be
/// copied by the resize_policy object of the container object.
template<typename It>
cc_hash_table(It first, It last, const hash_fn& h, const eq_fn& e,
const comb_hash_fn& ch, const resize_policy& rp)
: base_type(h, e, ch, rp)
{ this->copy_from_range(first, last); }
cc_hash_table(const cc_hash_table& other)
: base_type((const base_type&)other)
{ }
virtual
~cc_hash_table() { }
cc_hash_table&
operator=(const cc_hash_table& other)
{
if (this != &other)
{
cc_hash_table tmp(other);
swap(tmp);
}
return *this;
}
void
swap(cc_hash_table& other)
{ base_type::swap(other); }
};
#undef PB_DS_CC_HASH_BASE
#define PB_DS_GP_HASH_BASE \
basic_hash_table<Key, Mapped, Hash_Fn, Eq_Fn, Resize_Policy, Store_Hash, \
gp_hash_tag, \
typename __gnu_cxx::typelist::create2<Comb_Probe_Fn, Probe_Fn>::type, _Alloc>
/**
* A general-probing hash-based associative container.
*
* @tparam Key Key type.
* @tparam Mapped Map type.
* @tparam Hash_Fn Hashing functor.
* @tparam Eq_Fn Equal functor.
* @tparam Comb_Probe_Fn Combining probe functor.
* If Hash_Fn is not null_type, then this
* is the ranged-probe functor; otherwise,
* this is the range-hashing functor.
* XXX See Design::Hash-Based Containers::Hash Policies.
* @tparam Probe_Fn Probe functor.
* @tparam Resize_Policy Resizes hash.
* @tparam Store_Hash Indicates whether the hash value
* will be stored along with each key.
* If Hash_Fn is null_type, then the
* container will not compile if this
* value is true
* @tparam _Alloc Allocator type.
*
* Base tag choices are: gp_hash_tag.
*
* Base is basic_hash_table.
*/
template<typename Key,
typename Mapped,
typename Hash_Fn = typename detail::default_hash_fn<Key>::type,
typename Eq_Fn = typename detail::default_eq_fn<Key>::type,
typename Comb_Probe_Fn = detail::default_comb_hash_fn::type,
typename Probe_Fn = typename detail::default_probe_fn<Comb_Probe_Fn>::type,
typename Resize_Policy = typename detail::default_resize_policy<Comb_Probe_Fn>::type,
bool Store_Hash = detail::default_store_hash,
typename _Alloc = std::allocator<char> >
class gp_hash_table : public PB_DS_GP_HASH_BASE
{
private:
typedef PB_DS_GP_HASH_BASE base_type;
public:
typedef gp_hash_tag container_category;
typedef Hash_Fn hash_fn;
typedef Eq_Fn eq_fn;
typedef Comb_Probe_Fn comb_probe_fn;
typedef Probe_Fn probe_fn;
typedef Resize_Policy resize_policy;
/// Default constructor.
gp_hash_table() { }
/// Constructor taking some policy objects. r_hash_fn will be
/// copied by the hash_fn object of the container object.
gp_hash_table(const hash_fn& h)
: base_type(h) { }
/// Constructor taking some policy objects. r_hash_fn will be
/// copied by the hash_fn object of the container object, and
/// r_eq_fn will be copied by the eq_fn object of the container
/// object.
gp_hash_table(const hash_fn& h, const eq_fn& e)
: base_type(h, e) { }
/// Constructor taking some policy objects. r_hash_fn will be
/// copied by the hash_fn object of the container object, r_eq_fn
/// will be copied by the eq_fn object of the container object,
/// and r_comb_probe_fn will be copied by the comb_probe_fn object
/// of the container object.
gp_hash_table(const hash_fn& h, const eq_fn& e, const comb_probe_fn& cp)
: base_type(h, e, cp) { }
/// Constructor taking some policy objects. r_hash_fn will be
/// copied by the hash_fn object of the container object, r_eq_fn
/// will be copied by the eq_fn object of the container object,
/// r_comb_probe_fn will be copied by the comb_probe_fn object of
/// the container object, and r_probe_fn will be copied by the
/// probe_fn object of the container object.
gp_hash_table(const hash_fn& h, const eq_fn& e, const comb_probe_fn& cp,
const probe_fn& p)
: base_type(h, e, cp, p) { }
/// Constructor taking some policy objects. r_hash_fn will be
/// copied by the hash_fn object of the container object, r_eq_fn
/// will be copied by the eq_fn object of the container object,
/// r_comb_probe_fn will be copied by the comb_probe_fn object of
/// the container object, r_probe_fn will be copied by the
/// probe_fn object of the container object, and r_resize_policy
/// will be copied by the Resize_Policy object of the container
/// object.
gp_hash_table(const hash_fn& h, const eq_fn& e, const comb_probe_fn& cp,
const probe_fn& p, const resize_policy& rp)
: base_type(h, e, cp, p, rp) { }
/// Constructor taking __iterators to a range of value_types. The
/// value_types between first_it and last_it will be inserted into
/// the container object.
template<typename It>
gp_hash_table(It first, It last)
{ base_type::copy_from_range(first, last); }
/// Constructor taking __iterators to a range of value_types and
/// some policy objects. The value_types between first_it and
/// last_it will be inserted into the container object. r_hash_fn
/// will be copied by the hash_fn object of the container object.
template<typename It>
gp_hash_table(It first, It last, const hash_fn& h)
: base_type(h)
{ base_type::copy_from_range(first, last); }
/// Constructor taking __iterators to a range of value_types and
/// some policy objects. The value_types between first_it and
/// last_it will be inserted into the container object. r_hash_fn
/// will be copied by the hash_fn object of the container object,
/// and r_eq_fn will be copied by the eq_fn object of the
/// container object.
template<typename It>
gp_hash_table(It first, It last, const hash_fn& h, const eq_fn& e)
: base_type(h, e)
{ base_type::copy_from_range(first, last); }
/// Constructor taking __iterators to a range of value_types and
/// some policy objects. The value_types between first_it and
/// last_it will be inserted into the container object. r_hash_fn
/// will be copied by the hash_fn object of the container object,
/// r_eq_fn will be copied by the eq_fn object of the container
/// object, and r_comb_probe_fn will be copied by the
/// comb_probe_fn object of the container object.
template<typename It>
gp_hash_table(It first, It last, const hash_fn& h, const eq_fn& e,
const comb_probe_fn& cp)
: base_type(h, e, cp)
{ base_type::copy_from_range(first, last); }
/// Constructor taking __iterators to a range of value_types and
/// some policy objects. The value_types between first_it and
/// last_it will be inserted into the container object. r_hash_fn
/// will be copied by the hash_fn object of the container object,
/// r_eq_fn will be copied by the eq_fn object of the container
/// object, r_comb_probe_fn will be copied by the comb_probe_fn
/// object of the container object, and r_probe_fn will be copied
/// by the probe_fn object of the container object.
template<typename It>
gp_hash_table(It first, It last, const hash_fn& h, const eq_fn& e,
const comb_probe_fn& cp, const probe_fn& p)
: base_type(h, e, cp, p)
{ base_type::copy_from_range(first, last); }
/// Constructor taking __iterators to a range of value_types and
/// some policy objects. The value_types between first_it and
/// last_it will be inserted into the container object. r_hash_fn
/// will be copied by the hash_fn object of the container object,
/// r_eq_fn will be copied by the eq_fn object of the container
/// object, r_comb_probe_fn will be copied by the comb_probe_fn
/// object of the container object, r_probe_fn will be copied by
/// the probe_fn object of the container object, and
/// r_resize_policy will be copied by the resize_policy object of
/// the container object.
template<typename It>
gp_hash_table(It first, It last, const hash_fn& h, const eq_fn& e,
const comb_probe_fn& cp, const probe_fn& p,
const resize_policy& rp)
: base_type(h, e, cp, p, rp)
{ base_type::copy_from_range(first, last); }
gp_hash_table(const gp_hash_table& other)
: base_type((const base_type&)other)
{ }
virtual
~gp_hash_table() { }
gp_hash_table&
operator=(const gp_hash_table& other)
{
if (this != &other)
{
gp_hash_table tmp(other);
swap(tmp);
}
return *this;
}
void
swap(gp_hash_table& other)
{ base_type::swap(other); }
};
//@} hash-based
#undef PB_DS_GP_HASH_BASE
/**
* @defgroup branch-based Branch-Based
* @ingroup containers-pbds
* @{
*/
#define PB_DS_BRANCH_BASE \
detail::container_base_dispatch<Key, Mapped, _Alloc, Tag, Policy_Tl>::type
/**
* @defgroup branch-detail Base and Policy Classes
* @ingroup branch-based
*/
/**
* A branched, tree-like (tree, trie) container abstraction.
*
* @tparam Key Key type.
* @tparam Mapped Map type.
* @tparam Tag Instantiating data structure type,
* see container_tag.
* @tparam Node_Update Updates nodes, restores invariants.
* @tparam Policy_TL Policy typelist.
* @tparam _Alloc Allocator type.
*
* Base is dispatched at compile time via Tag, from the following
* choices: tree_tag, trie_tag, and their descendants.
*
* Base choices are: detail::ov_tree_map, detail::rb_tree_map,
* detail::splay_tree_map, and detail::pat_trie_map.
*/
template<typename Key, typename Mapped, typename Tag,
typename Node_Update, typename Policy_Tl, typename _Alloc>
class basic_branch : public PB_DS_BRANCH_BASE
{
private:
typedef typename PB_DS_BRANCH_BASE base_type;
public:
typedef Node_Update node_update;
virtual
~basic_branch() { }
protected:
basic_branch() { }
basic_branch(const basic_branch& other)
: base_type((const base_type&)other) { }
template<typename T0>
basic_branch(T0 t0) : base_type(t0) { }
template<typename T0, typename T1>
basic_branch(T0 t0, T1 t1) : base_type(t0, t1) { }
template<typename T0, typename T1, typename T2>
basic_branch(T0 t0, T1 t1, T2 t2) : base_type(t0, t1, t2) { }
template<typename T0, typename T1, typename T2, typename T3>
basic_branch(T0 t0, T1 t1, T2 t2, T3 t3)
: base_type(t0, t1, t2, t3) { }
template<typename T0, typename T1, typename T2, typename T3, typename T4>
basic_branch(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4)
: base_type(t0, t1, t2, t3, t4) { }
template<typename T0, typename T1, typename T2, typename T3, typename T4,
typename T5>
basic_branch(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
: base_type(t0, t1, t2, t3, t4, t5) { }
template<typename T0, typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6>
basic_branch(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
: base_type(t0, t1, t2, t3, t4, t5, t6) { }
};
#undef PB_DS_BRANCH_BASE
#define PB_DS_TREE_NODE_AND_IT_TRAITS \
detail::tree_traits<Key, Mapped,Cmp_Fn,Node_Update,Tag,_Alloc>
#define PB_DS_TREE_BASE \
basic_branch<Key,Mapped, Tag, \
typename PB_DS_TREE_NODE_AND_IT_TRAITS::node_update, \
typename __gnu_cxx::typelist::create2<Cmp_Fn, \
PB_DS_TREE_NODE_AND_IT_TRAITS>::type, _Alloc>
/**
* A tree-based container.
*
* @tparam Key Key type.
* @tparam Mapped Map type.
* @tparam Cmp_Fn Comparison functor.
* @tparam Tag Instantiating data structure type,
* see container_tag.
* @tparam Node_Update Updates tree internal-nodes,
* restores invariants when invalidated.
* XXX See design::tree-based-containers::node invariants.
* @tparam _Alloc Allocator type.
*
* Base tag choices are: ov_tree_tag, rb_tree_tag, splay_tree_tag.
*
* Base is basic_branch.
*/
template<typename Key, typename Mapped, typename Cmp_Fn = std::less<Key>,
typename Tag = rb_tree_tag,
template<typename Node_CItr, typename Node_Itr,
typename Cmp_Fn_, typename _Alloc_>
class Node_Update = null_node_update,
typename _Alloc = std::allocator<char> >
class tree : public PB_DS_TREE_BASE
{
private:
typedef PB_DS_TREE_BASE base_type;
public:
/// Comparison functor type.
typedef Cmp_Fn cmp_fn;
tree() { }
/// Constructor taking some policy objects. r_cmp_fn will be
/// copied by the Cmp_Fn object of the container object.
tree(const cmp_fn& c)
: base_type(c) { }
/// Constructor taking __iterators to a range of value_types. The
/// value_types between first_it and last_it will be inserted into
/// the container object.
template<typename It>
tree(It first, It last)
{ base_type::copy_from_range(first, last); }
/// Constructor taking __iterators to a range of value_types and
/// some policy objects The value_types between first_it and
/// last_it will be inserted into the container object. r_cmp_fn
/// will be copied by the cmp_fn object of the container object.
template<typename It>
tree(It first, It last, const cmp_fn& c)
: base_type(c)
{ base_type::copy_from_range(first, last); }
tree(const tree& other)
: base_type((const base_type&)other) { }
virtual
~tree() { }
tree&
operator=(const tree& other)
{
if (this != &other)
{
tree tmp(other);
swap(tmp);
}
return *this;
}
void
swap(tree& other)
{ base_type::swap(other); }
};
#undef PB_DS_TREE_BASE
#undef PB_DS_TREE_NODE_AND_IT_TRAITS
#define PB_DS_TRIE_NODE_AND_IT_TRAITS \
detail::trie_traits<Key,Mapped,_ATraits,Node_Update,Tag,_Alloc>
#define PB_DS_TRIE_BASE \
basic_branch<Key,Mapped,Tag, \
typename PB_DS_TRIE_NODE_AND_IT_TRAITS::node_update, \
typename __gnu_cxx::typelist::create2<_ATraits, \
PB_DS_TRIE_NODE_AND_IT_TRAITS >::type, _Alloc>
/**
* A trie-based container.
*
* @tparam Key Key type.
* @tparam Mapped Map type.
* @tparam _ATraits Element access traits.
* @tparam Tag Instantiating data structure type,
* see container_tag.
* @tparam Node_Update Updates trie internal-nodes,
* restores invariants when invalidated.
* XXX See design::tree-based-containers::node invariants.
* @tparam _Alloc Allocator type.
*
* Base tag choice is pat_trie_tag.
*
* Base is basic_branch.
*/
template<typename Key,
typename Mapped,
typename _ATraits = \
typename detail::default_trie_access_traits<Key>::type,
typename Tag = pat_trie_tag,
template<typename Node_CItr,
typename Node_Itr,
typename _ATraits_,
typename _Alloc_>
class Node_Update = null_node_update,
typename _Alloc = std::allocator<char> >
class trie : public PB_DS_TRIE_BASE
{
private:
typedef PB_DS_TRIE_BASE base_type;
public:
/// Element access traits type.
typedef _ATraits access_traits;
trie() { }
/// Constructor taking some policy objects. r_access_traits will
/// be copied by the _ATraits object of the container object.
trie(const access_traits& t)
: base_type(t) { }
/// Constructor taking __iterators to a range of value_types. The
/// value_types between first_it and last_it will be inserted into
/// the container object.
template<typename It>
trie(It first, It last)
{ base_type::copy_from_range(first, last); }
/// Constructor taking __iterators to a range of value_types and
/// some policy objects. The value_types between first_it and
/// last_it will be inserted into the container object.
template<typename It>
trie(It first, It last, const access_traits& t)
: base_type(t)
{ base_type::copy_from_range(first, last); }
trie(const trie& other)
: base_type((const base_type&)other) { }
virtual
~trie() { }
trie&
operator=(const trie& other)
{
if (this != &other)
{
trie tmp(other);
swap(tmp);
}
return *this;
}
void
swap(trie& other)
{ base_type::swap(other); }
};
//@} branch-based
#undef PB_DS_TRIE_BASE
#undef PB_DS_TRIE_NODE_AND_IT_TRAITS
/**
* @defgroup list-based List-Based
* @ingroup containers-pbds
* @{
*/
#define PB_DS_LU_BASE \
detail::container_base_dispatch<Key, Mapped, _Alloc, list_update_tag, \
typename __gnu_cxx::typelist::create2<Eq_Fn, Update_Policy>::type>::type
/**
* A list-update based associative container.
*
* @tparam Key Key type.
* @tparam Mapped Map type.
* @tparam Eq_Fn Equal functor.
* @tparam Update_Policy Update policy, determines when an element
* will be moved to the front of the list.
* @tparam _Alloc Allocator type.
*
* Base is detail::lu_map.
*/
template<typename Key,
typename Mapped,
class Eq_Fn = typename detail::default_eq_fn<Key>::type,
class Update_Policy = detail::default_update_policy::type,
class _Alloc = std::allocator<char> >
class list_update : public PB_DS_LU_BASE
{
private:
typedef typename PB_DS_LU_BASE base_type;
public:
typedef list_update_tag container_category;
typedef Eq_Fn eq_fn;
typedef Update_Policy update_policy;
list_update() { }
/// Constructor taking __iterators to a range of value_types. The
/// value_types between first_it and last_it will be inserted into
/// the container object.
template<typename It>
list_update(It first, It last)
{ base_type::copy_from_range(first, last); }
list_update(const list_update& other)
: base_type((const base_type&)other) { }
virtual
~list_update() { }
list_update&
operator=(const list_update& other)
{
if (this !=& other)
{
list_update tmp(other);
swap(tmp);
}
return *this;
}
void
swap(list_update& other)
{ base_type::swap(other); }
};
//@} list-based
#undef PB_DS_LU_BASE
// @} group containers-pbds
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/priority_queue.hpp 0000644 00000012576 15201526705 0012766 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file priority_queue.hpp
* Contains priority_queues.
*/
#ifndef PB_DS_PRIORITY_QUEUE_HPP
#define PB_DS_PRIORITY_QUEUE_HPP
#include <bits/c++config.h>
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/pb_ds/detail/priority_queue_base_dispatch.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
namespace __gnu_pbds
{
/**
* @defgroup heap-based Heap-Based
* @ingroup containers-pbds
* @{
*/
/**
* @defgroup heap-detail Base and Policy Classes
* @ingroup heap-based
*/
/**
* A priority queue composed of one specific heap policy.
*
* @tparam _Tv Value type.
* @tparam Cmp_Fn Comparison functor.
* @tparam Tag Instantiating data structure type,
* see container_tag.
* @tparam _Alloc Allocator type.
*
* Base is dispatched at compile time via Tag, from the following
* choices: binary_heap_tag, binomial_heap_tag, pairing_heap_tag,
* rc_binomial_heap_tag, thin_heap_tag
*
* Base choices are: detail::binary_heap, detail::binomial_heap,
* detail::pairing_heap, detail::rc_binomial_heap,
* detail::thin_heap.
*/
template<typename _Tv,
typename Cmp_Fn = std::less<_Tv>,
typename Tag = pairing_heap_tag,
typename _Alloc = std::allocator<char> >
class priority_queue
: public detail::container_base_dispatch<_Tv, Cmp_Fn, _Alloc, Tag>::type
{
public:
typedef _Tv value_type;
typedef Cmp_Fn cmp_fn;
typedef Tag container_category;
typedef _Alloc allocator_type;
typedef typename allocator_type::size_type size_type;
typedef typename allocator_type::difference_type difference_type;
private:
typedef typename detail::container_base_dispatch<_Tv, Cmp_Fn, _Alloc,
Tag>::type
base_type;
typedef typename _Alloc::template rebind<_Tv> __rebind_v;
typedef typename __rebind_v::other __rebind_va;
public:
typedef typename __rebind_va::reference reference;
typedef typename __rebind_va::const_reference const_reference;
typedef typename __rebind_va::pointer pointer;
typedef typename __rebind_va::const_pointer const_pointer;
typedef typename base_type::point_iterator point_iterator;
typedef typename base_type::point_const_iterator point_const_iterator;
typedef typename base_type::iterator iterator;
typedef typename base_type::const_iterator const_iterator;
priority_queue() { }
/// Constructor taking some policy objects. r_cmp_fn will be
/// copied by the Cmp_Fn object of the container object.
priority_queue(const cmp_fn& r_cmp_fn) : base_type(r_cmp_fn) { }
/// Constructor taking __iterators to a range of value_types. The
/// value_types between first_it and last_it will be inserted into
/// the container object.
template<typename It>
priority_queue(It first_it, It last_it)
{ base_type::copy_from_range(first_it, last_it); }
/// Constructor taking __iterators to a range of value_types and
/// some policy objects The value_types between first_it and
/// last_it will be inserted into the container object. r_cmp_fn
/// will be copied by the cmp_fn object of the container object.
template<typename It>
priority_queue(It first_it, It last_it, const cmp_fn& r_cmp_fn)
: base_type(r_cmp_fn)
{ base_type::copy_from_range(first_it, last_it); }
priority_queue(const priority_queue& other)
: base_type((const base_type& )other) { }
virtual
~priority_queue() { }
priority_queue&
operator=(const priority_queue& other)
{
if (this != &other)
{
priority_queue tmp(other);
swap(tmp);
}
return *this;
}
void
swap(priority_queue& other)
{ base_type::swap(other); }
};
} // namespace __gnu_pbds
//@} heap-based
#endif
c++/8/ext/pb_ds/exception.hpp 0000644 00000005654 15201526705 0011676 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file exception.hpp
* Contains exception classes.
*/
#ifndef PB_DS_EXCEPTION_HPP
#define PB_DS_EXCEPTION_HPP
#include <bits/c++config.h>
#include <stdexcept>
#include <cstdlib>
namespace __gnu_pbds
{
/**
* @defgroup exceptions-pbds Exceptions
* @ingroup pbds
* @{
*/
/// Base class for exceptions.
struct container_error : public std::logic_error
{
container_error()
: std::logic_error(__N("__gnu_pbds::container_error")) { }
};
/// An entry cannot be inserted into a container object for logical
/// reasons (not, e.g., if memory is unabvailable, in which case
/// the allocator_type's exception will be thrown).
struct insert_error : public container_error { };
/// A join cannot be performed logical reasons (i.e., the ranges of
/// the two container objects being joined overlaps.
struct join_error : public container_error { };
/// A container cannot be resized.
struct resize_error : public container_error { };
inline void
__throw_container_error()
{ _GLIBCXX_THROW_OR_ABORT(container_error()); }
inline void
__throw_insert_error()
{ _GLIBCXX_THROW_OR_ABORT(insert_error()); }
inline void
__throw_join_error()
{ _GLIBCXX_THROW_OR_ABORT(join_error()); }
inline void
__throw_resize_error()
{ _GLIBCXX_THROW_OR_ABORT(resize_error()); }
//@}
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/tag_and_trait.hpp 0000644 00000027754 15201526705 0012505 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file tag_and_trait.hpp
* Contains tags and traits, e.g., ones describing underlying
* data structures.
*/
#ifndef PB_DS_TAG_AND_TRAIT_HPP
#define PB_DS_TAG_AND_TRAIT_HPP
#include <bits/c++config.h>
#include <ext/pb_ds/detail/type_utils.hpp>
/**
* @namespace __gnu_pbds
* @brief GNU extensions for policy-based data structures for public use.
*/
namespace __gnu_pbds
{
/** @defgroup pbds Policy-Based Data Structures
* @ingroup extensions
*
* This is a library of policy-based elementary data structures:
* associative containers and priority queues. It is designed for
* high-performance, flexibility, semantic safety, and conformance
* to the corresponding containers in std (except for some points
* where it differs by design).
*
* For details, see:
* http://gcc.gnu.org/onlinedocs/libstdc++/ext/pb_ds/index.html
*
* @{
*/
/**
* @defgroup tags Tags
* @{
*/
/// A trivial iterator tag. Signifies that the iterators has none of
/// std::iterators's movement abilities.
struct trivial_iterator_tag
{ };
/// Prohibit moving trivial iterators.
typedef void trivial_iterator_difference_type;
/**
* @defgroup invalidation_tags Invalidation Guarantees
* @ingroup tags
* @{
*/
/**
* Signifies a basic invalidation guarantee that any iterator,
* pointer, or reference to a container object's mapped value type
* is valid as long as the container is not modified.
*/
struct basic_invalidation_guarantee
{ };
/**
* Signifies an invalidation guarantee that includes all those of
* its base, and additionally, that any point-type iterator,
* pointer, or reference to a container object's mapped value type
* is valid as long as its corresponding entry has not be erased,
* regardless of modifications to the container object.
*/
struct point_invalidation_guarantee : public basic_invalidation_guarantee
{ };
/**
* Signifies an invalidation guarantee that includes all those of
* its base, and additionally, that any range-type iterator
* (including the returns of begin() and end()) is in the correct
* relative positions to other range-type iterators as long as its
* corresponding entry has not be erased, regardless of
* modifications to the container object.
*/
struct range_invalidation_guarantee : public point_invalidation_guarantee
{ };
//@}
/**
* @defgroup ds_tags Data Structure Type
* @ingroup tags
* @{
*/
/// Base data structure tag.
struct container_tag
{ };
/// Basic sequence.
struct sequence_tag : public container_tag { };
/// Basic string container, inclusive of strings, ropes, etc.
struct string_tag : public sequence_tag { };
/// Basic associative-container.
struct associative_tag : public container_tag { };
/// Basic hash structure.
struct basic_hash_tag : public associative_tag { };
/// Collision-chaining hash.
struct cc_hash_tag : public basic_hash_tag { };
/// General-probing hash.
struct gp_hash_tag : public basic_hash_tag { };
/// Basic branch structure.
struct basic_branch_tag : public associative_tag { };
/// Basic tree structure.
struct tree_tag : public basic_branch_tag { };
/// Red-black tree.
struct rb_tree_tag : public tree_tag { };
/// Splay tree.
struct splay_tree_tag : public tree_tag { };
/// Ordered-vector tree.
struct ov_tree_tag : public tree_tag { };
/// Basic trie structure.
struct trie_tag : public basic_branch_tag { };
/// PATRICIA trie.
struct pat_trie_tag : public trie_tag { };
/// List-update.
struct list_update_tag : public associative_tag { };
/// Basic priority-queue.
struct priority_queue_tag : public container_tag { };
/// Pairing-heap.
struct pairing_heap_tag : public priority_queue_tag { };
/// Binomial-heap.
struct binomial_heap_tag : public priority_queue_tag { };
/// Redundant-counter binomial-heap.
struct rc_binomial_heap_tag : public priority_queue_tag { };
/// Binary-heap (array-based).
struct binary_heap_tag : public priority_queue_tag { };
/// Thin heap.
struct thin_heap_tag : public priority_queue_tag { };
//@}
//@}
/**
* @defgroup traits Traits
* @{
*/
/**
* @brief Represents no type, or absence of type, for template tricks.
*
* In a mapped-policy, indicates that an associative container is a set.
*
* In a list-update policy, indicates that each link does not need
* metadata.
*
* In a hash policy, indicates that the combining hash function
* is actually a ranged hash function.
*
* In a probe policy, indicates that the combining probe function
* is actually a ranged probe function.
*/
struct null_type { };
/// A null node updator, indicating that no node updates are required.
template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4>
struct null_node_update : public null_type
{ };
/// Primary template, container traits base.
template<typename _Tag>
struct container_traits_base;
/// Specialization, cc hash.
template<>
struct container_traits_base<cc_hash_tag>
{
typedef cc_hash_tag container_category;
typedef point_invalidation_guarantee invalidation_guarantee;
enum
{
order_preserving = false,
erase_can_throw = false,
split_join_can_throw = false,
reverse_iteration = false
};
};
/// Specialization, gp hash.
template<>
struct container_traits_base<gp_hash_tag>
{
typedef gp_hash_tag container_category;
typedef basic_invalidation_guarantee invalidation_guarantee;
enum
{
order_preserving = false,
erase_can_throw = false,
split_join_can_throw = false,
reverse_iteration = false
};
};
/// Specialization, rb tree.
template<>
struct container_traits_base<rb_tree_tag>
{
typedef rb_tree_tag container_category;
typedef range_invalidation_guarantee invalidation_guarantee;
enum
{
order_preserving = true,
erase_can_throw = false,
split_join_can_throw = false,
reverse_iteration = true
};
};
/// Specialization, splay tree.
template<>
struct container_traits_base<splay_tree_tag>
{
typedef splay_tree_tag container_category;
typedef range_invalidation_guarantee invalidation_guarantee;
enum
{
order_preserving = true,
erase_can_throw = false,
split_join_can_throw = false,
reverse_iteration = true
};
};
/// Specialization, ov tree.
template<>
struct container_traits_base<ov_tree_tag>
{
typedef ov_tree_tag container_category;
typedef basic_invalidation_guarantee invalidation_guarantee;
enum
{
order_preserving = true,
erase_can_throw = true,
split_join_can_throw = true,
reverse_iteration = false
};
};
/// Specialization, pat trie.
template<>
struct container_traits_base<pat_trie_tag>
{
typedef pat_trie_tag container_category;
typedef range_invalidation_guarantee invalidation_guarantee;
enum
{
order_preserving = true,
erase_can_throw = false,
split_join_can_throw = true,
reverse_iteration = true
};
};
/// Specialization, list update.
template<>
struct container_traits_base<list_update_tag>
{
typedef list_update_tag container_category;
typedef point_invalidation_guarantee invalidation_guarantee;
enum
{
order_preserving = false,
erase_can_throw = false,
split_join_can_throw = false,
reverse_iteration = false
};
};
/// Specialization, pairing heap.
template<>
struct container_traits_base<pairing_heap_tag>
{
typedef pairing_heap_tag container_category;
typedef point_invalidation_guarantee invalidation_guarantee;
enum
{
order_preserving = false,
erase_can_throw = false,
split_join_can_throw = false,
reverse_iteration = false
};
};
/// Specialization, thin heap.
template<>
struct container_traits_base<thin_heap_tag>
{
typedef thin_heap_tag container_category;
typedef point_invalidation_guarantee invalidation_guarantee;
enum
{
order_preserving = false,
erase_can_throw = false,
split_join_can_throw = false,
reverse_iteration = false
};
};
/// Specialization, binomial heap.
template<>
struct container_traits_base<binomial_heap_tag>
{
typedef binomial_heap_tag container_category;
typedef point_invalidation_guarantee invalidation_guarantee;
enum
{
order_preserving = false,
erase_can_throw = false,
split_join_can_throw = false,
reverse_iteration = false
};
};
/// Specialization, rc binomial heap.
template<>
struct container_traits_base<rc_binomial_heap_tag>
{
typedef rc_binomial_heap_tag container_category;
typedef point_invalidation_guarantee invalidation_guarantee;
enum
{
order_preserving = false,
erase_can_throw = false,
split_join_can_throw = false,
reverse_iteration = false
};
};
/// Specialization, binary heap.
template<>
struct container_traits_base<binary_heap_tag>
{
typedef binary_heap_tag container_category;
typedef basic_invalidation_guarantee invalidation_guarantee;
enum
{
order_preserving = false,
erase_can_throw = false,
split_join_can_throw = true,
reverse_iteration = false
};
};
/// Container traits.
// See Matt Austern for the name, S. Meyers MEFC++ #2, others.
template<typename Cntnr>
struct container_traits
: public container_traits_base<typename Cntnr::container_category>
{
typedef Cntnr container_type;
typedef typename Cntnr::container_category container_category;
typedef container_traits_base<container_category> base_type;
typedef typename base_type::invalidation_guarantee invalidation_guarantee;
enum
{
/// True only if Cntnr objects guarantee storing keys by order.
order_preserving = base_type::order_preserving,
/// True only if erasing a key can throw.
erase_can_throw = base_type::erase_can_throw,
/// True only if split or join operations can throw.
split_join_can_throw = base_type::split_join_can_throw,
/// True only reverse iterators are supported.
reverse_iteration = base_type::reverse_iteration
};
};
//@}
namespace detail
{
/// Dispatch mechanism, primary template for associative types.
template<typename Key, typename Mapped, typename _Alloc, typename Tag,
typename Policy_Tl = null_type>
struct container_base_dispatch;
} // namespace detail
//@}
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/list_update_policy.hpp 0000644 00000010420 15201526705 0013557 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file list_update_policy.hpp
* Contains policies for list update containers.
*/
#ifndef PB_DS_LU_POLICY_HPP
#define PB_DS_LU_POLICY_HPP
#include <bits/c++config.h>
#include <cstdlib>
#include <ext/pb_ds/detail/list_update_policy/lu_counter_metadata.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
namespace __gnu_pbds
{
/**
* A list-update policy that unconditionally moves elements to the
* front of the list. A null type means that each link in a
* list-based container does not actually need metadata.
*/
template<typename _Alloc = std::allocator<char> >
class lu_move_to_front_policy
{
public:
typedef _Alloc allocator_type;
/// Metadata on which this functor operates.
typedef null_type metadata_type;
private:
typedef typename _Alloc::template rebind<metadata_type> __rebind_m;
public:
/// Reference to metadata on which this functor operates.
typedef typename __rebind_m::other::reference metadata_reference;
/// Creates a metadata object.
metadata_type
operator()() const
{ return s_metadata; }
/// Decides whether a metadata object should be moved to the front
/// of the list.
inline bool
operator()(metadata_reference r_metadata) const
{ return true; }
private:
static null_type s_metadata;
};
/**
* A list-update policy that moves elements to the front of the
* list based on the counter algorithm.
*/
template<std::size_t Max_Count = 5, typename _Alloc = std::allocator<char> >
class lu_counter_policy
: private detail::lu_counter_policy_base<typename _Alloc::size_type>
{
public:
typedef _Alloc allocator_type;
typedef typename allocator_type::size_type size_type;
enum
{
/// When some element is accessed this number of times, it
/// will be moved to the front of the list.
max_count = Max_Count
};
/// Metadata on which this functor operates.
typedef detail::lu_counter_metadata<size_type> metadata_type;
private:
typedef detail::lu_counter_policy_base<size_type> base_type;
typedef typename _Alloc::template rebind<metadata_type> __rebind_m;
public:
/// Reference to metadata on which this functor operates.
typedef typename __rebind_m::other::reference metadata_reference;
/// Creates a metadata object.
metadata_type
operator()() const
{ return base_type::operator()(max_count); }
/// Decides whether a metadata object should be moved to the front
/// of the list.
bool
operator()(metadata_reference r_data) const
{ return base_type::operator()(r_data, max_count); }
};
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/hash_policy.hpp 0000644 00000040657 15201526705 0012204 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file hash_policy.hpp
* Contains hash-related policies.
*/
#ifndef PB_DS_HASH_POLICY_HPP
#define PB_DS_HASH_POLICY_HPP
#include <bits/c++config.h>
#include <algorithm>
#include <vector>
#include <cmath>
#include <ext/pb_ds/exception.hpp>
#include <ext/pb_ds/detail/type_utils.hpp>
#include <ext/pb_ds/detail/hash_fn/mask_based_range_hashing.hpp>
#include <ext/pb_ds/detail/hash_fn/mod_based_range_hashing.hpp>
#include <ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_size_base.hpp>
namespace __gnu_pbds
{
#define PB_DS_CLASS_T_DEC template<typename Size_Type>
#define PB_DS_CLASS_C_DEC linear_probe_fn<Size_Type>
/// A probe sequence policy using fixed increments.
template<typename Size_Type = std::size_t>
class linear_probe_fn
{
public:
typedef Size_Type size_type;
void
swap(PB_DS_CLASS_C_DEC& other);
protected:
/// Returns the i-th offset from the hash value.
inline size_type
operator()(size_type i) const;
};
#include <ext/pb_ds/detail/hash_fn/linear_probe_fn_imp.hpp>
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
#define PB_DS_CLASS_T_DEC template<typename Size_Type>
#define PB_DS_CLASS_C_DEC quadratic_probe_fn<Size_Type>
/// A probe sequence policy using square increments.
template<typename Size_Type = std::size_t>
class quadratic_probe_fn
{
public:
typedef Size_Type size_type;
void
swap(PB_DS_CLASS_C_DEC& other);
protected:
/// Returns the i-th offset from the hash value.
inline size_type
operator()(size_type i) const;
};
#include <ext/pb_ds/detail/hash_fn/quadratic_probe_fn_imp.hpp>
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
#define PB_DS_CLASS_T_DEC template<typename Size_Type>
#define PB_DS_CLASS_C_DEC direct_mask_range_hashing<Size_Type>
/// A mask range-hashing class (uses a bitmask).
template<typename Size_Type = std::size_t>
class direct_mask_range_hashing
: public detail::mask_based_range_hashing<Size_Type>
{
private:
typedef detail::mask_based_range_hashing<Size_Type> mask_based_base;
public:
typedef Size_Type size_type;
void
swap(PB_DS_CLASS_C_DEC& other);
protected:
void
notify_resized(size_type size);
/// Transforms the __hash value hash into a ranged-hash value
/// (using a bit-mask).
inline size_type
operator()(size_type hash) const;
};
#include <ext/pb_ds/detail/hash_fn/direct_mask_range_hashing_imp.hpp>
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
#define PB_DS_CLASS_T_DEC template<typename Size_Type>
#define PB_DS_CLASS_C_DEC direct_mod_range_hashing<Size_Type>
/// A mod range-hashing class (uses the modulo function).
template<typename Size_Type = std::size_t>
class direct_mod_range_hashing
: public detail::mod_based_range_hashing<Size_Type>
{
public:
typedef Size_Type size_type;
void
swap(PB_DS_CLASS_C_DEC& other);
protected:
void
notify_resized(size_type size);
/// Transforms the __hash value hash into a ranged-hash value
/// (using a modulo operation).
inline size_type
operator()(size_type hash) const;
private:
typedef detail::mod_based_range_hashing<size_type> mod_based_base;
};
#include <ext/pb_ds/detail/hash_fn/direct_mod_range_hashing_imp.hpp>
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
#define PB_DS_CLASS_T_DEC template<bool External_Load_Access, typename Size_Type>
#define PB_DS_CLASS_C_DEC hash_load_check_resize_trigger<External_Load_Access, Size_Type>
#define PB_DS_SIZE_BASE_C_DEC detail::hash_load_check_resize_trigger_size_base<Size_Type, External_Load_Access>
/// A resize trigger policy based on a load check. It keeps the
/// load factor between some load factors load_min and load_max.
template<bool External_Load_Access = false, typename Size_Type = std::size_t>
class hash_load_check_resize_trigger : private PB_DS_SIZE_BASE_C_DEC
{
public:
typedef Size_Type size_type;
enum
{
/// Specifies whether the load factor can be accessed
/// externally. The two options have different trade-offs in
/// terms of flexibility, genericity, and encapsulation.
external_load_access = External_Load_Access
};
/// Default constructor, or constructor taking load_min and
/// load_max load factors between which this policy will keep the
/// actual load.
hash_load_check_resize_trigger(float load_min = 0.125,
float load_max = 0.5);
void
swap(hash_load_check_resize_trigger& other);
virtual
~hash_load_check_resize_trigger();
/// Returns a pair of the minimal and maximal loads, respectively.
inline std::pair<float, float>
get_loads() const;
/// Sets the loads through a pair of the minimal and maximal
/// loads, respectively.
void
set_loads(std::pair<float, float> load_pair);
protected:
inline void
notify_insert_search_start();
inline void
notify_insert_search_collision();
inline void
notify_insert_search_end();
inline void
notify_find_search_start();
inline void
notify_find_search_collision();
inline void
notify_find_search_end();
inline void
notify_erase_search_start();
inline void
notify_erase_search_collision();
inline void
notify_erase_search_end();
/// Notifies an element was inserted. The total number of entries
/// in the table is num_entries.
inline void
notify_inserted(size_type num_entries);
inline void
notify_erased(size_type num_entries);
/// Notifies the table was cleared.
void
notify_cleared();
/// Notifies the table was resized as a result of this object's
/// signifying that a resize is needed.
void
notify_resized(size_type new_size);
void
notify_externally_resized(size_type new_size);
inline bool
is_resize_needed() const;
inline bool
is_grow_needed(size_type size, size_type num_entries) const;
private:
virtual void
do_resize(size_type new_size);
typedef PB_DS_SIZE_BASE_C_DEC size_base;
#ifdef _GLIBCXX_DEBUG
void
assert_valid(const char* file, int line) const;
#endif
float m_load_min;
float m_load_max;
size_type m_next_shrink_size;
size_type m_next_grow_size;
bool m_resize_needed;
};
#include <ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_imp.hpp>
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_SIZE_BASE_C_DEC
#define PB_DS_CLASS_T_DEC template<bool External_Load_Access, typename Size_Type>
#define PB_DS_CLASS_C_DEC cc_hash_max_collision_check_resize_trigger<External_Load_Access, Size_Type>
/// A resize trigger policy based on collision checks. It keeps the
/// simulated load factor lower than some given load factor.
template<bool External_Load_Access = false, typename Size_Type = std::size_t>
class cc_hash_max_collision_check_resize_trigger
{
public:
typedef Size_Type size_type;
enum
{
/// Specifies whether the load factor can be accessed
/// externally. The two options have different trade-offs in
/// terms of flexibility, genericity, and encapsulation.
external_load_access = External_Load_Access
};
/// Default constructor, or constructor taking load, a __load
/// factor which it will attempt to maintain.
cc_hash_max_collision_check_resize_trigger(float load = 0.5);
void
swap(PB_DS_CLASS_C_DEC& other);
/// Returns the current load.
inline float
get_load() const;
/// Sets the load; does not resize the container.
void
set_load(float load);
protected:
/// Notifies an insert search started.
inline void
notify_insert_search_start();
/// Notifies a search encountered a collision.
inline void
notify_insert_search_collision();
/// Notifies a search ended.
inline void
notify_insert_search_end();
/// Notifies a find search started.
inline void
notify_find_search_start();
/// Notifies a search encountered a collision.
inline void
notify_find_search_collision();
/// Notifies a search ended.
inline void
notify_find_search_end();
/// Notifies an erase search started.
inline void
notify_erase_search_start();
/// Notifies a search encountered a collision.
inline void
notify_erase_search_collision();
/// Notifies a search ended.
inline void
notify_erase_search_end();
/// Notifies an element was inserted.
inline void
notify_inserted(size_type num_entries);
/// Notifies an element was erased.
inline void
notify_erased(size_type num_entries);
/// Notifies the table was cleared.
void
notify_cleared();
/// Notifies the table was resized as a result of this object's
/// signifying that a resize is needed.
void
notify_resized(size_type new_size);
/// Notifies the table was resized externally.
void
notify_externally_resized(size_type new_size);
/// Queries whether a resize is needed.
inline bool
is_resize_needed() const;
/// Queries whether a grow is needed. This method is called only
/// if this object indicated is needed.
inline bool
is_grow_needed(size_type size, size_type num_entries) const;
private:
void
calc_max_num_coll();
inline void
calc_resize_needed();
float m_load;
size_type m_size;
size_type m_num_col;
size_type m_max_col;
bool m_resize_needed;
};
#include <ext/pb_ds/detail/resize_policy/cc_hash_max_collision_check_resize_trigger_imp.hpp>
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
#define PB_DS_CLASS_T_DEC template<typename Size_Type>
#define PB_DS_CLASS_C_DEC hash_exponential_size_policy<Size_Type>
/// A size policy whose sequence of sizes form an exponential
/// sequence (typically powers of 2.
template<typename Size_Type = std::size_t>
class hash_exponential_size_policy
{
public:
typedef Size_Type size_type;
/// Default constructor, or onstructor taking a start_size, or
/// constructor taking a start size and grow_factor. The policy
/// will use the sequence of sizes start_size, start_size*
/// grow_factor, start_size* grow_factor^2, ...
hash_exponential_size_policy(size_type start_size = 8,
size_type grow_factor = 2);
void
swap(PB_DS_CLASS_C_DEC& other);
protected:
size_type
get_nearest_larger_size(size_type size) const;
size_type
get_nearest_smaller_size(size_type size) const;
private:
size_type m_start_size;
size_type m_grow_factor;
};
#include <ext/pb_ds/detail/resize_policy/hash_exponential_size_policy_imp.hpp>
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
#define PB_DS_CLASS_T_DEC
#define PB_DS_CLASS_C_DEC hash_prime_size_policy
/// A size policy whose sequence of sizes form a nearly-exponential
/// sequence of primes.
class hash_prime_size_policy
{
public:
/// Size type.
typedef std::size_t size_type;
/// Default constructor, or onstructor taking a start_size The
/// policy will use the sequence of sizes approximately
/// start_size, start_size* 2, start_size* 2^2, ...
hash_prime_size_policy(size_type start_size = 8);
inline void
swap(PB_DS_CLASS_C_DEC& other);
protected:
size_type
get_nearest_larger_size(size_type size) const;
size_type
get_nearest_smaller_size(size_type size) const;
private:
size_type m_start_size;
};
#include <ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp>
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
#define PB_DS_CLASS_T_DEC template<typename Size_Policy, typename Trigger_Policy, bool External_Size_Access, typename Size_Type>
#define PB_DS_CLASS_C_DEC hash_standard_resize_policy<Size_Policy, Trigger_Policy, External_Size_Access, Size_Type>
/// A resize policy which delegates operations to size and trigger policies.
template<typename Size_Policy = hash_exponential_size_policy<>,
typename Trigger_Policy = hash_load_check_resize_trigger<>,
bool External_Size_Access = false,
typename Size_Type = std::size_t>
class hash_standard_resize_policy
: public Size_Policy, public Trigger_Policy
{
public:
typedef Size_Type size_type;
typedef Trigger_Policy trigger_policy;
typedef Size_Policy size_policy;
enum
{
external_size_access = External_Size_Access
};
/// Default constructor.
hash_standard_resize_policy();
/// constructor taking some policies r_size_policy will be copied
/// by the Size_Policy object of this object.
hash_standard_resize_policy(const Size_Policy& r_size_policy);
/// constructor taking some policies. r_size_policy will be
/// copied by the Size_Policy object of this
/// object. r_trigger_policy will be copied by the Trigger_Policy
/// object of this object.
hash_standard_resize_policy(const Size_Policy& r_size_policy,
const Trigger_Policy& r_trigger_policy);
virtual
~hash_standard_resize_policy();
inline void
swap(PB_DS_CLASS_C_DEC& other);
/// Access to the Size_Policy object used.
Size_Policy&
get_size_policy();
/// Const access to the Size_Policy object used.
const Size_Policy&
get_size_policy() const;
/// Access to the Trigger_Policy object used.
Trigger_Policy&
get_trigger_policy();
/// Access to the Trigger_Policy object used.
const Trigger_Policy&
get_trigger_policy() const;
/// Returns the actual size of the container.
inline size_type
get_actual_size() const;
/// Resizes the container to suggested_new_size, a suggested size
/// (the actual size will be determined by the Size_Policy
/// object).
void
resize(size_type suggested_new_size);
protected:
inline void
notify_insert_search_start();
inline void
notify_insert_search_collision();
inline void
notify_insert_search_end();
inline void
notify_find_search_start();
inline void
notify_find_search_collision();
inline void
notify_find_search_end();
inline void
notify_erase_search_start();
inline void
notify_erase_search_collision();
inline void
notify_erase_search_end();
inline void
notify_inserted(size_type num_e);
inline void
notify_erased(size_type num_e);
void
notify_cleared();
void
notify_resized(size_type new_size);
inline bool
is_resize_needed() const;
/// Queries what the new size should be, when the container is
/// resized naturally. The current __size of the container is
/// size, and the number of used entries within the container is
/// num_used_e.
size_type
get_new_size(size_type size, size_type num_used_e) const;
private:
/// Resizes to new_size.
virtual void
do_resize(size_type new_size);
typedef Trigger_Policy trigger_policy_base;
typedef Size_Policy size_policy_base;
size_type m_size;
};
#include <ext/pb_ds/detail/resize_policy/hash_standard_resize_policy_imp.hpp>
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/detail/resize_policy/hash_exponential_size_policy_imp.hpp 0000644 00000005324 15201526705 0022623 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file hash_exponential_size_policy_imp.hpp
* Contains a resize size policy implementation.
*/
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
hash_exponential_size_policy(size_type start_size, size_type grow_factor) :
m_start_size(start_size),
m_grow_factor(grow_factor)
{ }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
std::swap(m_start_size, other.m_start_size);
std::swap(m_grow_factor, other.m_grow_factor);
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
get_nearest_larger_size(size_type size) const
{
size_type ret = m_start_size;
while (ret <= size)
{
const size_type next_ret = ret* m_grow_factor;
if (next_ret < ret)
__throw_insert_error();
ret = next_ret;
}
return ret;
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
get_nearest_smaller_size(size_type size) const
{
size_type ret = m_start_size;
while (true)
{
const size_type next_ret = ret* m_grow_factor;
if (next_ret < ret)
__throw_resize_error();
if (next_ret >= size)
return (ret);
ret = next_ret;
}
return ret;
}
c++/8/ext/pb_ds/detail/resize_policy/sample_resize_policy.hpp 0000644 00000006772 15201526705 0020245 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file sample_resize_policy.hpp
* Contains a sample resize policy for hash tables.
*/
#ifndef PB_DS_SAMPLE_RESIZE_POLICY_HPP
#define PB_DS_SAMPLE_RESIZE_POLICY_HPP
namespace __gnu_pbds
{
/// A sample resize policy.
class sample_resize_policy
{
public:
/// Size type.
typedef std::size_t size_type;
/// Default constructor.
sample_resize_policy();
/// Copy constructor.
sample_range_hashing(const sample_resize_policy& other);
/// Swaps content.
inline void
swap(sample_resize_policy& other);
protected:
/// Notifies a search started.
inline void
notify_insert_search_start();
/// Notifies a search encountered a collision.
inline void
notify_insert_search_collision();
/// Notifies a search ended.
inline void
notify_insert_search_end();
/// Notifies a search started.
inline void
notify_find_search_start();
/// Notifies a search encountered a collision.
inline void
notify_find_search_collision();
/// Notifies a search ended.
inline void
notify_find_search_end();
/// Notifies a search started.
inline void
notify_erase_search_start();
/// Notifies a search encountered a collision.
inline void
notify_erase_search_collision();
/// Notifies a search ended.
inline void
notify_erase_search_end();
/// Notifies an element was inserted.
inline void
notify_inserted(size_type num_e);
/// Notifies an element was erased.
inline void
notify_erased(size_type num_e);
/// Notifies the table was cleared.
void
notify_cleared();
/// Notifies the table was resized to new_size.
void
notify_resized(size_type new_size);
/// Queries whether a resize is needed.
inline bool
is_resize_needed() const;
/// Queries what the new size should be.
size_type
get_new_size(size_type size, size_type num_used_e) const;
};
}
#endif
c++/8/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_imp.hpp 0000644 00000017110 15201526705 0023040 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file hash_load_check_resize_trigger_imp.hpp
* Contains a resize trigger implementation.
*/
#define PB_DS_ASSERT_VALID(X) \
_GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
hash_load_check_resize_trigger(float load_min, float load_max)
: m_load_min(load_min), m_load_max(load_max), m_next_shrink_size(0),
m_next_grow_size(0), m_resize_needed(false)
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_find_search_start()
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_find_search_collision()
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_find_search_end()
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_insert_search_start()
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_insert_search_collision()
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_insert_search_end()
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_erase_search_start()
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_erase_search_collision()
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_erase_search_end()
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_inserted(size_type num_entries)
{
m_resize_needed = (num_entries >= m_next_grow_size);
size_base::set_size(num_entries);
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_erased(size_type num_entries)
{
size_base::set_size(num_entries);
m_resize_needed = num_entries <= m_next_shrink_size;
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
is_resize_needed() const
{
PB_DS_ASSERT_VALID((*this))
return m_resize_needed;
}
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
is_grow_needed(size_type /*size*/, size_type num_entries) const
{
_GLIBCXX_DEBUG_ASSERT(m_resize_needed);
return num_entries >= m_next_grow_size;
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
~hash_load_check_resize_trigger() { }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
notify_resized(size_type new_size)
{
m_resize_needed = false;
m_next_grow_size = size_type(m_load_max * new_size - 1);
m_next_shrink_size = size_type(m_load_min * new_size);
#ifdef PB_DS_HT_MAP_RESIZE_TRACE_
std::cerr << "hlcrt::notify_resized " << std::endl
<< "1 " << new_size << std::endl
<< "2 " << m_load_min << std::endl
<< "3 " << m_load_max << std::endl
<< "4 " << m_next_shrink_size << std::endl
<< "5 " << m_next_grow_size << std::endl;
#endif
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
notify_externally_resized(size_type new_size)
{
m_resize_needed = false;
size_type new_grow_size = size_type(m_load_max * new_size - 1);
size_type new_shrink_size = size_type(m_load_min * new_size);
#ifdef PB_DS_HT_MAP_RESIZE_TRACE_
std::cerr << "hlcrt::notify_externally_resized " << std::endl
<< "1 " << new_size << std::endl
<< "2 " << m_load_min << std::endl
<< "3 " << m_load_max << std::endl
<< "4 " << m_next_shrink_size << std::endl
<< "5 " << m_next_grow_size << std::endl
<< "6 " << new_shrink_size << std::endl
<< "7 " << new_grow_size << std::endl;
#endif
if (new_grow_size >= m_next_grow_size)
{
_GLIBCXX_DEBUG_ASSERT(new_shrink_size >= m_next_shrink_size);
m_next_grow_size = new_grow_size;
}
else
{
_GLIBCXX_DEBUG_ASSERT(new_shrink_size <= m_next_shrink_size);
m_next_shrink_size = new_shrink_size;
}
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
notify_cleared()
{
PB_DS_ASSERT_VALID((*this))
size_base::set_size(0);
m_resize_needed = (0 < m_next_shrink_size);
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
size_base::swap(other);
std::swap(m_load_min, other.m_load_min);
std::swap(m_load_max, other.m_load_max);
std::swap(m_resize_needed, other.m_resize_needed);
std::swap(m_next_grow_size, other.m_next_grow_size);
std::swap(m_next_shrink_size, other.m_next_shrink_size);
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
PB_DS_CLASS_T_DEC
inline std::pair<float, float>
PB_DS_CLASS_C_DEC::
get_loads() const
{
PB_DS_STATIC_ASSERT(access, external_load_access);
return std::make_pair(m_load_min, m_load_max);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
set_loads(std::pair<float, float> load_pair)
{
PB_DS_STATIC_ASSERT(access, external_load_access);
const float old_load_min = m_load_min;
const float old_load_max = m_load_max;
const size_type old_next_shrink_size = m_next_shrink_size;
const size_type old_next_grow_size = m_next_grow_size;
const bool old_resize_needed = m_resize_needed;
__try
{
m_load_min = load_pair.first;
m_load_max = load_pair.second;
do_resize(static_cast<size_type>(size_base::get_size() / ((m_load_min + m_load_max) / 2)));
}
__catch(...)
{
m_load_min = old_load_min;
m_load_max = old_load_max;
m_next_shrink_size = old_next_shrink_size;
m_next_grow_size = old_next_grow_size;
m_resize_needed = old_resize_needed;
__throw_exception_again;
}
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
do_resize(size_type)
{ std::abort(); }
#ifdef _GLIBCXX_DEBUG
# define PB_DS_DEBUG_VERIFY(_Cond) \
_GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
_M_message(#_Cond" assertion from %1;:%2;") \
._M_string(__FILE__)._M_integer(__LINE__) \
,__file,__line)
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_valid(const char* __file, int __line) const
{
PB_DS_DEBUG_VERIFY(m_load_max > m_load_min);
PB_DS_DEBUG_VERIFY(m_next_grow_size >= m_next_shrink_size);
}
# undef PB_DS_DEBUG_VERIFY
#endif
#undef PB_DS_ASSERT_VALID
c++/8/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp 0000644 00000013773 15201526705 0021420 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file hash_prime_size_policy_imp.hpp
* Contains a resize size policy implementation.
*/
#pragma GCC system_header
namespace detail
{
enum
{
num_distinct_sizes_32_bit = 30,
num_distinct_sizes_64_bit = 62,
num_distinct_sizes = sizeof(std::size_t) != 8 ?
num_distinct_sizes_32_bit : num_distinct_sizes_64_bit,
};
// Originally taken from the SGI implementation; acknowledged in the docs.
// Further modified (for 64 bits) from tr1's hashtable.
static const std::size_t g_a_sizes[num_distinct_sizes_64_bit] =
{
/* 0 */ 5ul,
/* 1 */ 11ul,
/* 2 */ 23ul,
/* 3 */ 47ul,
/* 4 */ 97ul,
/* 5 */ 199ul,
/* 6 */ 409ul,
/* 7 */ 823ul,
/* 8 */ 1741ul,
/* 9 */ 3469ul,
/* 10 */ 6949ul,
/* 11 */ 14033ul,
/* 12 */ 28411ul,
/* 13 */ 57557ul,
/* 14 */ 116731ul,
/* 15 */ 236897ul,
/* 16 */ 480881ul,
/* 17 */ 976369ul,
/* 18 */ 1982627ul,
/* 19 */ 4026031ul,
/* 20 */ 8175383ul,
/* 21 */ 16601593ul,
/* 22 */ 33712729ul,
/* 23 */ 68460391ul,
/* 24 */ 139022417ul,
/* 25 */ 282312799ul,
/* 26 */ 573292817ul,
/* 27 */ 1164186217ul,
/* 28 */ 2364114217ul,
/* 29 */ 4294967291ul,
/* 30 */ (std::size_t)8589934583ull,
/* 31 */ (std::size_t)17179869143ull,
/* 32 */ (std::size_t)34359738337ull,
/* 33 */ (std::size_t)68719476731ull,
/* 34 */ (std::size_t)137438953447ull,
/* 35 */ (std::size_t)274877906899ull,
/* 36 */ (std::size_t)549755813881ull,
/* 37 */ (std::size_t)1099511627689ull,
/* 38 */ (std::size_t)2199023255531ull,
/* 39 */ (std::size_t)4398046511093ull,
/* 40 */ (std::size_t)8796093022151ull,
/* 41 */ (std::size_t)17592186044399ull,
/* 42 */ (std::size_t)35184372088777ull,
/* 43 */ (std::size_t)70368744177643ull,
/* 44 */ (std::size_t)140737488355213ull,
/* 45 */ (std::size_t)281474976710597ull,
/* 46 */ (std::size_t)562949953421231ull,
/* 47 */ (std::size_t)1125899906842597ull,
/* 48 */ (std::size_t)2251799813685119ull,
/* 49 */ (std::size_t)4503599627370449ull,
/* 50 */ (std::size_t)9007199254740881ull,
/* 51 */ (std::size_t)18014398509481951ull,
/* 52 */ (std::size_t)36028797018963913ull,
/* 53 */ (std::size_t)72057594037927931ull,
/* 54 */ (std::size_t)144115188075855859ull,
/* 55 */ (std::size_t)288230376151711717ull,
/* 56 */ (std::size_t)576460752303423433ull,
/* 57 */ (std::size_t)1152921504606846883ull,
/* 58 */ (std::size_t)2305843009213693951ull,
/* 59 */ (std::size_t)4611686018427387847ull,
/* 60 */ (std::size_t)9223372036854775783ull,
/* 61 */ (std::size_t)18446744073709551557ull,
};
} // namespace detail
PB_DS_CLASS_T_DEC
inline
PB_DS_CLASS_C_DEC::
hash_prime_size_policy(size_type n) : m_start_size(n)
{ m_start_size = get_nearest_larger_size(n); }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{ std::swap(m_start_size, other.m_start_size); }
PB_DS_CLASS_T_DEC
inline PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
get_nearest_larger_size(size_type n) const
{
const std::size_t* const p_upper = std::upper_bound(detail::g_a_sizes,
detail::g_a_sizes + detail::num_distinct_sizes, n);
if (p_upper == detail::g_a_sizes + detail::num_distinct_sizes)
__throw_resize_error();
return *p_upper;
}
PB_DS_CLASS_T_DEC
inline PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
get_nearest_smaller_size(size_type n) const
{
const std::size_t* p_lower = std::lower_bound(detail::g_a_sizes,
detail::g_a_sizes + detail::num_distinct_sizes, n);
if (*p_lower >= n && p_lower != detail::g_a_sizes)
--p_lower;
if (*p_lower < m_start_size)
return m_start_size;
return *p_lower;
}
c++/8/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_size_base.hpp 0000644 00000005632 15201526705 0024225 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file hash_load_check_resize_trigger_size_base.hpp
* Contains an base holding size for some resize policies.
*/
#ifndef PB_DS_HASH_LOAD_CHECK_RESIZE_TRIGGER_SIZE_BASE_HPP
#define PB_DS_HASH_LOAD_CHECK_RESIZE_TRIGGER_SIZE_BASE_HPP
namespace __gnu_pbds
{
namespace detail
{
/// Primary template.
template<typename Size_Type, bool Hold_Size>
class hash_load_check_resize_trigger_size_base;
/// Specializations.
template<typename Size_Type>
class hash_load_check_resize_trigger_size_base<Size_Type, true>
{
protected:
typedef Size_Type size_type;
hash_load_check_resize_trigger_size_base(): m_size(0)
{ }
inline void
swap(hash_load_check_resize_trigger_size_base& other)
{ std::swap(m_size, other.m_size); }
inline void
set_size(size_type size)
{ m_size = size; }
inline size_type
get_size() const
{ return m_size; }
private:
size_type m_size;
};
template<typename Size_Type>
class hash_load_check_resize_trigger_size_base<Size_Type, false>
{
protected:
typedef Size_Type size_type;
protected:
inline void
swap(hash_load_check_resize_trigger_size_base& other) { }
inline void
set_size(size_type size) { }
};
} // namespace detail
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/detail/resize_policy/cc_hash_max_collision_check_resize_trigger_imp.hpp 0000644 00000011443 15201526705 0025431 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file cc_hash_max_collision_check_resize_trigger_imp.hpp
* Contains a resize trigger implementation.
*/
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
cc_hash_max_collision_check_resize_trigger(float load) :
m_load(load),
m_size(0),
m_num_col(0),
m_max_col(0),
m_resize_needed(false)
{ }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_find_search_start()
{ }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_find_search_collision()
{ }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_find_search_end()
{ }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_insert_search_start()
{ m_num_col = 0; }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_insert_search_collision()
{ ++m_num_col; }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_insert_search_end()
{ calc_resize_needed(); }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_erase_search_start()
{ }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_erase_search_collision()
{ }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_erase_search_end()
{ }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_inserted(size_type)
{ }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_erased(size_type)
{ m_resize_needed = true; }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
notify_cleared()
{ m_resize_needed = false; }
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
is_resize_needed() const
{ return m_resize_needed; }
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
is_grow_needed(size_type /*size*/, size_type /*num_used_e*/) const
{ return m_num_col >= m_max_col; }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
notify_resized(size_type new_size)
{
m_size = new_size;
#ifdef PB_DS_HT_MAP_RESIZE_TRACE_
std::cerr << "chmccrt::notify_resized "
<< static_cast<unsigned long>(new_size) << std::endl;
#endif
calc_max_num_coll();
calc_resize_needed();
m_num_col = 0;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
calc_max_num_coll()
{
// max_col <-- \sqrt{2 load \ln( 2 m \ln( m ) ) }
const double ln_arg = 2 * m_size * std::log(double(m_size));
m_max_col = size_type(std::ceil(std::sqrt(2 * m_load * std::log(ln_arg))));
#ifdef PB_DS_HT_MAP_RESIZE_TRACE_
std::cerr << "chmccrt::calc_max_num_coll "
<< static_cast<unsigned long>(m_size) << " "
<< static_cast<unsigned long>(m_max_col) << std::endl;
#endif
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
notify_externally_resized(size_type new_size)
{ notify_resized(new_size); }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
std::swap(m_load, other.m_load);
std::swap(m_size, other.m_size);
std::swap(m_num_col, other.m_num_col);
std::swap(m_max_col, other.m_max_col);
std::swap(m_resize_needed, other.m_resize_needed);
}
PB_DS_CLASS_T_DEC
inline float
PB_DS_CLASS_C_DEC::
get_load() const
{
PB_DS_STATIC_ASSERT(access, external_load_access);
return m_load;
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
calc_resize_needed()
{ m_resize_needed = m_resize_needed || m_num_col >= m_max_col; }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
set_load(float load)
{
PB_DS_STATIC_ASSERT(access, external_load_access);
m_load = load;
calc_max_num_coll();
calc_resize_needed();
}
c++/8/ext/pb_ds/detail/resize_policy/hash_standard_resize_policy_imp.hpp 0000644 00000014213 15201526705 0022421 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file hash_standard_resize_policy_imp.hpp
* Contains a resize policy implementation.
*/
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
hash_standard_resize_policy()
: m_size(Size_Policy::get_nearest_larger_size(1))
{ trigger_policy_base::notify_externally_resized(m_size); }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
hash_standard_resize_policy(const Size_Policy& r_size_policy)
: Size_Policy(r_size_policy), m_size(Size_Policy::get_nearest_larger_size(1))
{ trigger_policy_base::notify_externally_resized(m_size); }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
hash_standard_resize_policy(const Size_Policy& r_size_policy,
const Trigger_Policy& r_trigger_policy)
: Size_Policy(r_size_policy), Trigger_Policy(r_trigger_policy),
m_size(Size_Policy::get_nearest_larger_size(1))
{ trigger_policy_base::notify_externally_resized(m_size); }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
~hash_standard_resize_policy()
{ }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
trigger_policy_base::swap(other);
size_policy_base::swap(other);
std::swap(m_size, other.m_size);
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_find_search_start()
{ trigger_policy_base::notify_find_search_start(); }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_find_search_collision()
{ trigger_policy_base::notify_find_search_collision(); }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_find_search_end()
{ trigger_policy_base::notify_find_search_end(); }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_insert_search_start()
{ trigger_policy_base::notify_insert_search_start(); }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_insert_search_collision()
{ trigger_policy_base::notify_insert_search_collision(); }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_insert_search_end()
{ trigger_policy_base::notify_insert_search_end(); }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_erase_search_start()
{ trigger_policy_base::notify_erase_search_start(); }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_erase_search_collision()
{ trigger_policy_base::notify_erase_search_collision(); }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_erase_search_end()
{ trigger_policy_base::notify_erase_search_end(); }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_inserted(size_type num_e)
{ trigger_policy_base::notify_inserted(num_e); }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_erased(size_type num_e)
{ trigger_policy_base::notify_erased(num_e); }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
notify_cleared()
{ trigger_policy_base::notify_cleared(); }
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
is_resize_needed() const
{ return trigger_policy_base::is_resize_needed(); }
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
get_new_size(size_type size, size_type num_used_e) const
{
if (trigger_policy_base::is_grow_needed(size, num_used_e))
return size_policy_base::get_nearest_larger_size(size);
return size_policy_base::get_nearest_smaller_size(size);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
notify_resized(size_type new_size)
{
trigger_policy_base::notify_resized(new_size);
m_size = new_size;
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
get_actual_size() const
{
PB_DS_STATIC_ASSERT(access, external_size_access);
return m_size;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
resize(size_type new_size)
{
PB_DS_STATIC_ASSERT(access, external_size_access);
size_type actual_size = size_policy_base::get_nearest_larger_size(1);
while (actual_size < new_size)
{
const size_type pot = size_policy_base::get_nearest_larger_size(actual_size);
if (pot == actual_size && pot < new_size)
__throw_resize_error();
actual_size = pot;
}
if (actual_size > 0)
--actual_size;
const size_type old_size = m_size;
__try
{
do_resize(actual_size - 1);
}
__catch(insert_error& )
{
m_size = old_size;
__throw_resize_error();
}
__catch(...)
{
m_size = old_size;
__throw_exception_again;
}
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
do_resize(size_type)
{
// Do nothing
}
PB_DS_CLASS_T_DEC
Trigger_Policy&
PB_DS_CLASS_C_DEC::
get_trigger_policy()
{ return *this; }
PB_DS_CLASS_T_DEC
const Trigger_Policy&
PB_DS_CLASS_C_DEC::
get_trigger_policy() const
{ return *this; }
PB_DS_CLASS_T_DEC
Size_Policy&
PB_DS_CLASS_C_DEC::
get_size_policy()
{ return *this; }
PB_DS_CLASS_T_DEC
const Size_Policy&
PB_DS_CLASS_C_DEC::
get_size_policy() const
{ return *this; }
c++/8/ext/pb_ds/detail/resize_policy/sample_size_policy.hpp 0000644 00000004573 15201526705 0017713 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file sample_size_policy.hpp
* Contains a sample size resize-policy.
*/
#ifndef PB_DS_SAMPLE_SIZE_POLICY_HPP
#define PB_DS_SAMPLE_SIZE_POLICY_HPP
namespace __gnu_pbds
{
/// A sample size policy.
class sample_size_policy
{
public:
/// Size type.
typedef std::size_t size_type;
/// Default constructor.
sample_size_policy();
/// Copy constructor.
sample_range_hashing(const sample_size_policy&);
/// Swaps content.
inline void
swap(sample_size_policy& other);
protected:
/// Given a __size size, returns a __size that is larger.
inline size_type
get_nearest_larger_size(size_type size) const;
/// Given a __size size, returns a __size that is smaller.
inline size_type
get_nearest_smaller_size(size_type size) const;
};
}
#endif
c++/8/ext/pb_ds/detail/resize_policy/sample_resize_trigger.hpp 0000644 00000007512 15201526705 0020402 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file sample_resize_trigger.hpp
* Contains a sample resize trigger policy class.
*/
#ifndef PB_DS_SAMPLE_RESIZE_TRIGGER_HPP
#define PB_DS_SAMPLE_RESIZE_TRIGGER_HPP
namespace __gnu_pbds
{
/// A sample resize trigger policy.
class sample_resize_trigger
{
public:
/// Size type.
typedef std::size_t size_type;
/// Default constructor.
sample_resize_trigger();
/// Copy constructor.
sample_range_hashing(const sample_resize_trigger&);
/// Swaps content.
inline void
swap(sample_resize_trigger&);
protected:
/// Notifies a search started.
inline void
notify_insert_search_start();
/// Notifies a search encountered a collision.
inline void
notify_insert_search_collision();
/// Notifies a search ended.
inline void
notify_insert_search_end();
/// Notifies a search started.
inline void
notify_find_search_start();
/// Notifies a search encountered a collision.
inline void
notify_find_search_collision();
/// Notifies a search ended.
inline void
notify_find_search_end();
/// Notifies a search started.
inline void
notify_erase_search_start();
/// Notifies a search encountered a collision.
inline void
notify_erase_search_collision();
/// Notifies a search ended.
inline void
notify_erase_search_end();
/// Notifies an element was inserted. the total number of entries in
/// the table is num_entries.
inline void
notify_inserted(size_type num_entries);
/// Notifies an element was erased.
inline void
notify_erased(size_type num_entries);
/// Notifies the table was cleared.
void
notify_cleared();
/// Notifies the table was resized as a result of this object's
/// signifying that a resize is needed.
void
notify_resized(size_type new_size);
/// Notifies the table was resized externally.
void
notify_externally_resized(size_type new_size);
/// Queries whether a resize is needed.
inline bool
is_resize_needed() const;
/// Queries whether a grow is needed.
inline bool
is_grow_needed(size_type size, size_type num_entries) const;
private:
/// Resizes to new_size.
virtual void
do_resize(size_type);
};
}
#endif
c++/8/ext/pb_ds/detail/tree_policy/order_statistics_imp.hpp 0000644 00000007213 15201526705 0017703 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file tree_policy/order_statistics_imp.hpp
* Contains forward declarations for order_statistics_key
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
find_by_order(size_type order)
{
node_iterator it = node_begin();
node_iterator end_it = node_end();
while (it != end_it)
{
node_iterator l_it = it.get_l_child();
const size_type o = (l_it == end_it)? 0 : l_it.get_metadata();
if (order == o)
return *it;
else if (order < o)
it = l_it;
else
{
order -= o + 1;
it = it.get_r_child();
}
}
return base_type::end_iterator();
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
find_by_order(size_type order) const
{ return const_cast<PB_DS_CLASS_C_DEC*>(this)->find_by_order(order); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
order_of_key(key_const_reference r_key) const
{
node_const_iterator it = node_begin();
node_const_iterator end_it = node_end();
const cmp_fn& r_cmp_fn = const_cast<PB_DS_CLASS_C_DEC*>(this)->get_cmp_fn();
size_type ord = 0;
while (it != end_it)
{
node_const_iterator l_it = it.get_l_child();
if (r_cmp_fn(r_key, this->extract_key(*(*it))))
it = l_it;
else if (r_cmp_fn(this->extract_key(*(*it)), r_key))
{
ord += (l_it == end_it)? 1 : 1 + l_it.get_metadata();
it = it.get_r_child();
}
else
{
ord += (l_it == end_it)? 0 : l_it.get_metadata();
it = end_it;
}
}
return ord;
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
operator()(node_iterator node_it, node_const_iterator end_nd_it) const
{
node_iterator l_it = node_it.get_l_child();
const size_type l_rank = (l_it == end_nd_it) ? 0 : l_it.get_metadata();
node_iterator r_it = node_it.get_r_child();
const size_type r_rank = (r_it == end_nd_it) ? 0 : r_it.get_metadata();
const_cast<metadata_reference>(node_it.get_metadata())= 1 + l_rank + r_rank;
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
~tree_order_statistics_node_update()
{ }
c++/8/ext/pb_ds/detail/tree_policy/node_metadata_selector.hpp 0000644 00000006412 15201526705 0020136 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file tree_policy/node_metadata_selector.hpp
* Contains an implementation class for trees.
*/
#ifndef PB_DS_TREE_NODE_METADATA_DISPATCH_HPP
#define PB_DS_TREE_NODE_METADATA_DISPATCH_HPP
#include <ext/pb_ds/detail/branch_policy/null_node_metadata.hpp>
#include <ext/pb_ds/detail/types_traits.hpp>
namespace __gnu_pbds
{
namespace detail
{
/**
* @addtogroup traits Traits
* @{
*/
/// Tree metadata helper.
template<typename Node_Update, bool _BTp>
struct tree_metadata_helper;
/// Specialization, false.
template<typename Node_Update>
struct tree_metadata_helper<Node_Update, false>
{
typedef typename Node_Update::metadata_type type;
};
/// Specialization, true.
template<typename Node_Update>
struct tree_metadata_helper<Node_Update, true>
{
typedef null_type type;
};
/// Tree node metadata dispatch.
template<typename Key,
typename Data,
typename Cmp_Fn,
template<typename Node_CItr,
typename Const_Iterator,
typename Cmp_Fn_,
typename _Alloc_>
class Node_Update,
typename _Alloc>
struct tree_node_metadata_dispatch
{
private:
typedef dumnode_const_iterator<Key, Data, _Alloc> __it_type;
typedef Node_Update<__it_type, __it_type, Cmp_Fn, _Alloc> __node_u;
typedef null_node_update<__it_type, __it_type, Cmp_Fn, _Alloc> __nnode_u;
enum
{
null_update = is_same<__node_u, __nnode_u>::value
};
public:
typedef typename tree_metadata_helper<__node_u, null_update>::type type;
};
//@}
} // namespace detail
} // namespace __gnu_pbds
#endif // #ifndef PB_DS_TREE_NODE_METADATA_DISPATCH_HPP
c++/8/ext/pb_ds/detail/tree_policy/sample_tree_node_update.hpp 0000644 00000004452 15201526705 0020322 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file tree_policy/sample_tree_node_update.hpp
* Contains a samle node update functor.
*/
#ifndef PB_DS_SAMPLE_TREE_NODE_UPDATOR_HPP
#define PB_DS_SAMPLE_TREE_NODE_UPDATOR_HPP
namespace __gnu_pbds
{
/// A sample node updator.
template<typename Const_Node_Iter, typename Node_Iter, typename Cmp_Fn,
typename _Alloc>
class sample_tree_node_update
{
typedef std::size_t metadata_type;
/// Default constructor.
sample_tree_node_update();
/// Updates the rank of a node through a node_iterator node_it;
/// end_nd_it is the end node iterator.
inline void
operator()(node_iterator node_it, node_const_iterator end_nd_it) const;
};
}
#endif // #ifndef PB_DS_SAMPLE_TREE_NODE_UPDATOR_HPP
c++/8/ext/pb_ds/detail/left_child_next_sibling_heap_/info_fn_imps.hpp 0000644 00000004072 15201526705 0021577 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file left_child_next_sibling_heap_/info_fn_imps.hpp
* Contains an implementation class for left_child_next_sibling_heap_.
*/
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
empty() const
{
return (m_size == 0);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
size() const
{
return (m_size);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
max_size() const
{
return (s_node_allocator.max_size());
}
c++/8/ext/pb_ds/detail/left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp 0000644 00000007727 15201526705 0025704 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp
* Contains an implementation class for left_child_next_sibling_heap_.
*/
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_allocator
PB_DS_CLASS_C_DEC::s_node_allocator;
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::no_throw_copies_t
PB_DS_CLASS_C_DEC::s_no_throw_copies_ind;
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
left_child_next_sibling_heap() :
m_p_root(0),
m_size(0)
{
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
left_child_next_sibling_heap(const Cmp_Fn& r_cmp_fn) :
Cmp_Fn(r_cmp_fn),
m_p_root(0),
m_size(0)
{
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
left_child_next_sibling_heap(const PB_DS_CLASS_C_DEC& other)
: Cmp_Fn(other), m_p_root(0), m_size(0)
{
m_size = other.m_size;
PB_DS_ASSERT_VALID(other)
m_p_root = recursive_copy_node(other.m_p_root);
m_size = other.m_size;
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
value_swap(other);
std::swap((Cmp_Fn& )(*this), (Cmp_Fn& )other);
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
value_swap(PB_DS_CLASS_C_DEC& other)
{
std::swap(m_p_root, other.m_p_root);
std::swap(m_size, other.m_size);
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
~left_child_next_sibling_heap()
{
clear();
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
recursive_copy_node(node_const_pointer p_nd)
{
if (p_nd == 0)
return (0);
node_pointer p_ret = s_node_allocator.allocate(1);
__try
{
new (p_ret) node(*p_nd);
}
__catch(...)
{
s_node_allocator.deallocate(p_ret, 1);
__throw_exception_again;
}
p_ret->m_p_l_child = p_ret->m_p_next_sibling =
p_ret->m_p_prev_or_parent = 0;
__try
{
p_ret->m_p_l_child = recursive_copy_node(p_nd->m_p_l_child);
p_ret->m_p_next_sibling = recursive_copy_node(p_nd->m_p_next_sibling);
}
__catch(...)
{
clear_imp(p_ret);
__throw_exception_again;
}
if (p_ret->m_p_l_child != 0)
p_ret->m_p_l_child->m_p_prev_or_parent = p_ret;
if (p_ret->m_p_next_sibling != 0)
p_ret->m_p_next_sibling->m_p_prev_or_parent =
p_nd->m_p_next_sibling->m_p_prev_or_parent == p_nd ? p_ret : 0;
return p_ret;
}
c++/8/ext/pb_ds/detail/left_child_next_sibling_heap_/iterators_fn_imps.hpp 0000644 00000004773 15201526705 0022670 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file left_child_next_sibling_heap_/iterators_fn_imps.hpp
* Contains an implementation class for left_child_next_sibling_heap_.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
begin()
{
node_pointer p_nd = m_p_root;
if (p_nd == 0)
return (iterator(0));
while (p_nd->m_p_l_child != 0)
p_nd = p_nd->m_p_l_child;
return (iterator(p_nd));
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
begin() const
{
node_pointer p_nd = m_p_root;
if (p_nd == 0)
return (const_iterator(0));
while (p_nd->m_p_l_child != 0)
p_nd = p_nd->m_p_l_child;
return (const_iterator(p_nd));
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
end()
{
return (iterator(0));
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
end() const
{
return (const_iterator(0));
}
c++/8/ext/pb_ds/detail/left_child_next_sibling_heap_/point_const_iterator.hpp 0000644 00000010620 15201526705 0023375 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file left_child_next_sibling_heap_/point_const_iterator.hpp
* Contains an iterator class returned by the table's const find and insert
* methods.
*/
#ifndef PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_CONST_FIND_ITERATOR_HPP
#define PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_CONST_FIND_ITERATOR_HPP
#include <ext/pb_ds/tag_and_trait.hpp>
#include <debug/debug.h>
namespace __gnu_pbds
{
namespace detail
{
#define PB_DS_CLASS_T_DEC \
template<typename Node, typename _Alloc>
#define PB_DS_CLASS_C_DEC \
left_child_next_sibling_heap_node_point_const_iterator_<Node, _Alloc>
/// Const point-type iterator.
template<typename Node, typename _Alloc>
class left_child_next_sibling_heap_node_point_const_iterator_
{
protected:
typedef typename _Alloc::template rebind<Node>::other::pointer node_pointer;
public:
/// Category.
typedef trivial_iterator_tag iterator_category;
/// Difference type.
typedef trivial_iterator_difference_type difference_type;
/// Iterator's value type.
typedef typename Node::value_type value_type;
/// Iterator's pointer type.
typedef
typename _Alloc::template rebind<
value_type>::other::pointer
pointer;
/// Iterator's const pointer type.
typedef
typename _Alloc::template rebind<
value_type>::other::const_pointer
const_pointer;
/// Iterator's reference type.
typedef
typename _Alloc::template rebind<
value_type>::other::reference
reference;
/// Iterator's const reference type.
typedef
typename _Alloc::template rebind<
value_type>::other::const_reference
const_reference;
inline
left_child_next_sibling_heap_node_point_const_iterator_(node_pointer p_nd) : m_p_nd(p_nd)
{ }
/// Default constructor.
inline
left_child_next_sibling_heap_node_point_const_iterator_() : m_p_nd(0)
{ }
/// Copy constructor.
inline
left_child_next_sibling_heap_node_point_const_iterator_(const PB_DS_CLASS_C_DEC& other) : m_p_nd(other.m_p_nd)
{ }
/// Access.
const_pointer
operator->() const
{
_GLIBCXX_DEBUG_ASSERT(m_p_nd != 0);
return &m_p_nd->m_value;
}
/// Access.
const_reference
operator*() const
{
_GLIBCXX_DEBUG_ASSERT(m_p_nd != 0);
return m_p_nd->m_value;
}
/// Compares content to a different iterator object.
bool
operator==(const PB_DS_CLASS_C_DEC& other) const
{ return m_p_nd == other.m_p_nd; }
/// Compares content (negatively) to a different iterator object.
bool
operator!=(const PB_DS_CLASS_C_DEC& other) const
{ return m_p_nd != other.m_p_nd; }
node_pointer m_p_nd;
};
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
} // namespace detail
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/detail/left_child_next_sibling_heap_/debug_fn_imps.hpp 0000644 00000007753 15201526705 0021743 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file left_child_next_sibling_heap_/debug_fn_imps.hpp
* Contains an implementation class for left_child_next_sibling_heap_.
*/
#ifdef _GLIBCXX_DEBUG
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_valid(const char* __file, int __line) const
{
PB_DS_DEBUG_VERIFY(m_p_root == 0 || m_p_root->m_p_prev_or_parent == 0);
if (m_p_root != 0)
assert_node_consistent(m_p_root, Single_Link_Roots, __file, __line);
assert_size(__file, __line);
assert_iterators(__file, __line);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_node_consistent(node_const_pointer p_nd, bool single_link,
const char* __file, int __line) const
{
if (p_nd == 0)
return;
assert_node_consistent(p_nd->m_p_l_child, false, __file, __line);
assert_node_consistent(p_nd->m_p_next_sibling, single_link, __file, __line);
if (single_link)
PB_DS_DEBUG_VERIFY(p_nd->m_p_prev_or_parent == 0);
else if (p_nd->m_p_next_sibling != 0)
PB_DS_DEBUG_VERIFY(p_nd->m_p_next_sibling->m_p_prev_or_parent == p_nd);
if (p_nd->m_p_l_child == 0)
return;
node_const_pointer p_child = p_nd->m_p_l_child;
while (p_child != 0)
{
node_const_pointer p_next_child = p_child->m_p_next_sibling;
PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(p_nd->m_value, p_child->m_value));
p_child = p_next_child;
}
PB_DS_DEBUG_VERIFY(p_nd->m_p_l_child->m_p_prev_or_parent == p_nd);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_iterators(const char* __file, int __line) const
{
PB_DS_DEBUG_VERIFY(std::distance(begin(), end()) == size());
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_size(const char* __file, int __line) const
{
PB_DS_DEBUG_VERIFY(size_from_node(m_p_root) == m_size);
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
size_under_node(node_const_pointer p_nd)
{ return 1 + size_from_node(p_nd->m_p_l_child); }
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
size_from_node(node_const_pointer p_nd)
{
size_type ret = 0;
while (p_nd != 0)
{
ret += 1 + size_from_node(p_nd->m_p_l_child);
p_nd = p_nd->m_p_next_sibling;
}
return ret;
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
degree(node_const_pointer p_nd)
{
size_type ret = 0;
node_const_pointer p_child = p_nd->m_p_l_child;
while (p_child != 0)
{
++ret;
p_child = p_child->m_p_next_sibling;
}
return ret;
}
#endif
c++/8/ext/pb_ds/detail/left_child_next_sibling_heap_/node.hpp 0000644 00000006214 15201526705 0020056 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file left_child_next_sibling_heap_/node.hpp
* Contains an implementation struct for this type of heap's node.
*/
#ifndef PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_NODE_HPP
#define PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_NODE_HPP
namespace __gnu_pbds
{
namespace detail
{
/// Node.
template<typename _Value, typename _Metadata, typename _Alloc>
struct left_child_next_sibling_heap_node_
{
private:
typedef left_child_next_sibling_heap_node_<_Value, _Metadata, _Alloc> this_type;
public:
typedef _Value value_type;
typedef typename _Alloc::size_type size_type;
typedef _Metadata metadata_type;
typedef typename _Alloc::template rebind<this_type>::other::pointer node_pointer;
value_type m_value;
metadata_type m_metadata;
node_pointer m_p_l_child;
node_pointer m_p_next_sibling;
node_pointer m_p_prev_or_parent;
};
template<typename _Value, typename _Alloc>
struct left_child_next_sibling_heap_node_<_Value, null_type, _Alloc>
{
private:
typedef left_child_next_sibling_heap_node_<_Value, null_type, _Alloc> this_type;
public:
typedef _Value value_type;
typedef typename _Alloc::size_type size_type;
typedef typename _Alloc::template rebind<this_type>::other::pointer node_pointer;
value_type m_value;
node_pointer m_p_l_child;
node_pointer m_p_next_sibling;
node_pointer m_p_prev_or_parent;
};
} // namespace detail
} // namespace __gnu_pbds
#endif // #ifndef PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_NODE_HPP
c++/8/ext/pb_ds/detail/left_child_next_sibling_heap_/insert_fn_imps.hpp 0000644 00000012121 15201526705 0022142 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file left_child_next_sibling_heap_/insert_fn_imps.hpp
* Contains an implementation class for left_child_next_sibling_heap_.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
get_new_node_for_insert(const_reference r_val)
{
return get_new_node_for_insert(r_val, s_no_throw_copies_ind);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
get_new_node_for_insert(const_reference r_val, false_type)
{
node_pointer p_new_nd = s_node_allocator.allocate(1);
cond_dealtor_t cond(p_new_nd);
new (const_cast<void* >(
static_cast<const void* >(&p_new_nd->m_value)))
typename node::value_type(r_val);
cond.set_no_action();
++m_size;
return (p_new_nd);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
get_new_node_for_insert(const_reference r_val, true_type)
{
node_pointer p_new_nd = s_node_allocator.allocate(1);
new (const_cast<void* >(
static_cast<const void* >(&p_new_nd->m_value)))
typename node::value_type(r_val);
++m_size;
return (p_new_nd);
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
make_child_of(node_pointer p_nd, node_pointer p_new_parent)
{
_GLIBCXX_DEBUG_ASSERT(p_nd != 0);
_GLIBCXX_DEBUG_ASSERT(p_new_parent != 0);
p_nd->m_p_next_sibling = p_new_parent->m_p_l_child;
if (p_new_parent->m_p_l_child != 0)
p_new_parent->m_p_l_child->m_p_prev_or_parent = p_nd;
p_nd->m_p_prev_or_parent = p_new_parent;
p_new_parent->m_p_l_child = p_nd;
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
parent(node_pointer p_nd)
{
while (true)
{
node_pointer p_pot = p_nd->m_p_prev_or_parent;
if (p_pot == 0 || p_pot->m_p_l_child == p_nd)
return p_pot;
p_nd = p_pot;
}
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
swap_with_parent(node_pointer p_nd, node_pointer p_parent)
{
if (p_parent == m_p_root)
m_p_root = p_nd;
_GLIBCXX_DEBUG_ASSERT(p_nd != 0);
_GLIBCXX_DEBUG_ASSERT(p_parent != 0);
_GLIBCXX_DEBUG_ASSERT(parent(p_nd) == p_parent);
const bool nd_direct_child = p_parent->m_p_l_child == p_nd;
const bool parent_root = p_parent->m_p_prev_or_parent == 0;
const bool parent_direct_child =
!parent_root&& p_parent->m_p_prev_or_parent->m_p_l_child == p_parent;
std::swap(p_parent->m_p_prev_or_parent, p_nd->m_p_prev_or_parent);
std::swap(p_parent->m_p_next_sibling, p_nd->m_p_next_sibling);
std::swap(p_parent->m_p_l_child, p_nd->m_p_l_child);
std::swap(p_parent->m_metadata, p_nd->m_metadata);
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_l_child != 0);
_GLIBCXX_DEBUG_ASSERT(p_parent->m_p_prev_or_parent != 0);
if (p_nd->m_p_next_sibling != 0)
p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd;
if (p_parent->m_p_next_sibling != 0)
p_parent->m_p_next_sibling->m_p_prev_or_parent = p_parent;
if (p_parent->m_p_l_child != 0)
p_parent->m_p_l_child->m_p_prev_or_parent = p_parent;
if (parent_direct_child)
p_nd->m_p_prev_or_parent->m_p_l_child = p_nd;
else if (!parent_root)
p_nd->m_p_prev_or_parent->m_p_next_sibling = p_nd;
if (!nd_direct_child)
{
p_nd->m_p_l_child->m_p_prev_or_parent = p_nd;
p_parent->m_p_prev_or_parent->m_p_next_sibling = p_parent;
}
else
{
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_l_child == p_nd);
_GLIBCXX_DEBUG_ASSERT(p_parent->m_p_prev_or_parent == p_parent);
p_nd->m_p_l_child = p_parent;
p_parent->m_p_prev_or_parent = p_nd;
}
_GLIBCXX_DEBUG_ASSERT(parent(p_parent) == p_nd);
}
c++/8/ext/pb_ds/detail/left_child_next_sibling_heap_/erase_fn_imps.hpp 0000644 00000007567 15201526705 0021757 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file left_child_next_sibling_heap_/erase_fn_imps.hpp
* Contains an implementation class for left_child_next_sibling_heap_.
*/
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
clear()
{
clear_imp(m_p_root);
_GLIBCXX_DEBUG_ASSERT(m_size == 0);
m_p_root = 0;
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
actual_erase_node(node_pointer p_nd)
{
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
--m_size;
p_nd->~node();
s_node_allocator.deallocate(p_nd, 1);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
clear_imp(node_pointer p_nd)
{
while (p_nd != 0)
{
clear_imp(p_nd->m_p_l_child);
node_pointer p_next = p_nd->m_p_next_sibling;
actual_erase_node(p_nd);
p_nd = p_next;
}
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
to_linked_list()
{
PB_DS_ASSERT_VALID((*this))
node_pointer p_cur = m_p_root;
while (p_cur != 0)
if (p_cur->m_p_l_child != 0)
{
node_pointer p_child_next = p_cur->m_p_l_child->m_p_next_sibling;
p_cur->m_p_l_child->m_p_next_sibling = p_cur->m_p_next_sibling;
p_cur->m_p_next_sibling = p_cur->m_p_l_child;
p_cur->m_p_l_child = p_child_next;
}
else
p_cur = p_cur->m_p_next_sibling;
#ifdef _GLIBCXX_DEBUG
node_const_pointer p_counter = m_p_root;
size_type count = 0;
while (p_counter != 0)
{
++count;
_GLIBCXX_DEBUG_ASSERT(p_counter->m_p_l_child == 0);
p_counter = p_counter->m_p_next_sibling;
}
_GLIBCXX_DEBUG_ASSERT(count == m_size);
#endif
}
PB_DS_CLASS_T_DEC
template<typename Pred>
typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
prune(Pred pred)
{
node_pointer p_cur = m_p_root;
m_p_root = 0;
node_pointer p_out = 0;
while (p_cur != 0)
{
node_pointer p_next = p_cur->m_p_next_sibling;
if (pred(p_cur->m_value))
{
p_cur->m_p_next_sibling = p_out;
if (p_out != 0)
p_out->m_p_prev_or_parent = p_cur;
p_out = p_cur;
}
else
{
p_cur->m_p_next_sibling = m_p_root;
if (m_p_root != 0)
m_p_root->m_p_prev_or_parent = p_cur;
m_p_root = p_cur;
}
p_cur = p_next;
}
return p_out;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
bubble_to_top(node_pointer p_nd)
{
node_pointer p_parent = parent(p_nd);
while (p_parent != 0)
{
swap_with_parent(p_nd, p_parent);
p_parent = parent(p_nd);
}
}
c++/8/ext/pb_ds/detail/left_child_next_sibling_heap_/trace_fn_imps.hpp 0000644 00000005377 15201526705 0021753 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file left_child_next_sibling_heap_/trace_fn_imps.hpp
* Contains an implementation class for left_child_next_sibling_heap_.
*/
#ifdef PB_DS_LC_NS_HEAP_TRACE_
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
trace() const
{
std::cerr << std::endl;
trace_node(m_p_root, 0);
std::cerr << std::endl;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
trace_node(node_const_pointer p_nd, size_type level)
{
while (p_nd != 0)
{
for (size_type i = 0; i < level; ++i)
std::cerr << ' ';
std::cerr << p_nd <<
" prev = " << p_nd->m_p_prev_or_parent <<
" next " << p_nd->m_p_next_sibling <<
" left = " << p_nd->m_p_l_child << " ";
trace_node_metadata(p_nd, type_to_type<node_metadata>());
std::cerr << p_nd->m_value << std::endl;
trace_node(p_nd->m_p_l_child, level + 1);
p_nd = p_nd->m_p_next_sibling;
}
}
PB_DS_CLASS_T_DEC
template<typename Metadata_>
void
PB_DS_CLASS_C_DEC::
trace_node_metadata(node_const_pointer p_nd, type_to_type<Metadata_>)
{
std::cerr << "(" << p_nd->m_metadata << ") ";
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
trace_node_metadata(node_const_pointer, type_to_type<null_type>)
{ }
#endif // #ifdef PB_DS_LC_NS_HEAP_TRACE_
c++/8/ext/pb_ds/detail/left_child_next_sibling_heap_/const_iterator.hpp 0000644 00000011474 15201526705 0022174 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file left_child_next_sibling_heap_/const_iterator.hpp
* Contains an iterator class returned by the table's const find and insert
* methods.
*/
#ifndef PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_CONST_ITERATOR_HPP
#define PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_CONST_ITERATOR_HPP
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/point_const_iterator.hpp>
#include <debug/debug.h>
namespace __gnu_pbds
{
namespace detail
{
#define PB_DS_CLASS_C_DEC \
left_child_next_sibling_heap_const_iterator_<Node, _Alloc>
#define PB_DS_BASIC_HEAP_CIT_BASE \
left_child_next_sibling_heap_node_point_const_iterator_<Node, _Alloc>
/// Const point-type iterator.
template<typename Node, typename _Alloc>
class left_child_next_sibling_heap_const_iterator_
: public PB_DS_BASIC_HEAP_CIT_BASE
{
private:
typedef PB_DS_BASIC_HEAP_CIT_BASE base_type;
typedef typename base_type::node_pointer node_pointer;
public:
/// Category.
typedef std::forward_iterator_tag iterator_category;
/// Difference type.
typedef typename _Alloc::difference_type difference_type;
/// Iterator's value type.
typedef typename base_type::value_type value_type;
/// Iterator's pointer type.
typedef typename base_type::pointer pointer;
/// Iterator's const pointer type.
typedef typename base_type::const_pointer const_pointer;
/// Iterator's reference type.
typedef typename base_type::reference reference;
/// Iterator's const reference type.
typedef typename base_type::const_reference const_reference;
inline
left_child_next_sibling_heap_const_iterator_(node_pointer p_nd)
: base_type(p_nd)
{ }
/// Default constructor.
inline
left_child_next_sibling_heap_const_iterator_()
{ }
/// Copy constructor.
inline
left_child_next_sibling_heap_const_iterator_(const PB_DS_CLASS_C_DEC& other) : base_type(other)
{ }
/// Compares content to a different iterator object.
bool
operator==(const PB_DS_CLASS_C_DEC& other) const
{ return (base_type::m_p_nd == other.m_p_nd); }
/// Compares content (negatively) to a different iterator object.
bool
operator!=(const PB_DS_CLASS_C_DEC& other) const
{ return (base_type::m_p_nd != other.m_p_nd); }
PB_DS_CLASS_C_DEC&
operator++()
{
_GLIBCXX_DEBUG_ASSERT(base_type::m_p_nd != 0);
inc();
return (*this);
}
PB_DS_CLASS_C_DEC
operator++(int)
{
PB_DS_CLASS_C_DEC ret_it(base_type::m_p_nd);
operator++();
return (ret_it);
}
private:
void
inc()
{
if (base_type::m_p_nd->m_p_next_sibling != 0)
{
base_type::m_p_nd = base_type::m_p_nd->m_p_next_sibling;
while (base_type::m_p_nd->m_p_l_child != 0)
base_type::m_p_nd = base_type::m_p_nd->m_p_l_child;
return;
}
while (true)
{
node_pointer p_next = base_type::m_p_nd;
base_type::m_p_nd = base_type::m_p_nd->m_p_prev_or_parent;
if (base_type::m_p_nd == 0
|| base_type::m_p_nd->m_p_l_child == p_next)
return;
}
}
};
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_BASIC_HEAP_CIT_BASE
} // namespace detail
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp 0000644 00000017757 15201526705 0025145 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp
* Contains an implementation class for a basic heap.
*/
#ifndef PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_HPP
#define PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_HPP
/*
* Based on CLRS.
*/
#include <iterator>
#include <ext/pb_ds/detail/cond_dealtor.hpp>
#include <ext/pb_ds/detail/type_utils.hpp>
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/node.hpp>
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/point_const_iterator.hpp>
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/const_iterator.hpp>
#ifdef PB_DS_LC_NS_HEAP_TRACE_
#include <iostream>
#endif
#include <debug/debug.h>
namespace __gnu_pbds
{
namespace detail
{
#ifdef _GLIBCXX_DEBUG
#define PB_DS_CLASS_T_DEC \
template<typename Value_Type, typename Cmp_Fn, typename Node_Metadata, \
typename _Alloc, bool Single_Link_Roots>
#define PB_DS_CLASS_C_DEC \
left_child_next_sibling_heap<Value_Type, Cmp_Fn, Node_Metadata, \
_Alloc, Single_Link_Roots>
#else
#define PB_DS_CLASS_T_DEC \
template<typename Value_Type, typename Cmp_Fn, typename Node_Metadata, \
typename _Alloc>
#define PB_DS_CLASS_C_DEC \
left_child_next_sibling_heap<Value_Type, Cmp_Fn, Node_Metadata, _Alloc>
#endif
/// Base class for a basic heap.
template<typename Value_Type,
typename Cmp_Fn,
typename Node_Metadata,
typename _Alloc
#ifdef _GLIBCXX_DEBUG
,bool Single_Link_Roots>
#else
>
#endif
class left_child_next_sibling_heap : public Cmp_Fn
{
protected:
typedef
typename _Alloc::template rebind<
left_child_next_sibling_heap_node_<Value_Type, Node_Metadata,
_Alloc> >::other
node_allocator;
typedef typename node_allocator::value_type node;
typedef typename node_allocator::pointer node_pointer;
typedef typename node_allocator::const_pointer node_const_pointer;
typedef Node_Metadata node_metadata;
typedef std::pair< node_pointer, node_pointer> node_pointer_pair;
private:
typedef cond_dealtor< node, _Alloc> cond_dealtor_t;
enum
{
simple_value = is_simple<Value_Type>::value
};
typedef integral_constant<int, simple_value> no_throw_copies_t;
typedef typename _Alloc::template rebind<Value_Type> __rebind_v;
public:
typedef typename _Alloc::size_type size_type;
typedef typename _Alloc::difference_type difference_type;
typedef Value_Type value_type;
typedef typename __rebind_v::other::pointer pointer;
typedef typename __rebind_v::other::const_pointer const_pointer;
typedef typename __rebind_v::other::reference reference;
typedef typename __rebind_v::other::const_reference const_reference;
typedef left_child_next_sibling_heap_node_point_const_iterator_<node, _Alloc>
point_const_iterator;
typedef point_const_iterator point_iterator;
typedef left_child_next_sibling_heap_const_iterator_<node, _Alloc>
const_iterator;
typedef const_iterator iterator;
typedef Cmp_Fn cmp_fn;
typedef _Alloc allocator_type;
left_child_next_sibling_heap();
left_child_next_sibling_heap(const Cmp_Fn&);
left_child_next_sibling_heap(const left_child_next_sibling_heap&);
void
swap(PB_DS_CLASS_C_DEC&);
~left_child_next_sibling_heap();
inline bool
empty() const;
inline size_type
size() const;
inline size_type
max_size() const;
Cmp_Fn&
get_cmp_fn();
const Cmp_Fn&
get_cmp_fn() const;
inline iterator
begin();
inline const_iterator
begin() const;
inline iterator
end();
inline const_iterator
end() const;
void
clear();
#ifdef PB_DS_LC_NS_HEAP_TRACE_
void
trace() const;
#endif
protected:
inline node_pointer
get_new_node_for_insert(const_reference);
inline static void
make_child_of(node_pointer, node_pointer);
void
value_swap(left_child_next_sibling_heap&);
inline static node_pointer
parent(node_pointer);
inline void
swap_with_parent(node_pointer, node_pointer);
void
bubble_to_top(node_pointer);
inline void
actual_erase_node(node_pointer);
void
clear_imp(node_pointer);
void
to_linked_list();
template<typename Pred>
node_pointer
prune(Pred);
#ifdef _GLIBCXX_DEBUG
void
assert_valid(const char*, int) const;
void
assert_node_consistent(node_const_pointer, bool, const char*, int) const;
static size_type
size_under_node(node_const_pointer);
static size_type
degree(node_const_pointer);
#endif
#ifdef PB_DS_LC_NS_HEAP_TRACE_
static void
trace_node(node_const_pointer, size_type);
#endif
private:
#ifdef _GLIBCXX_DEBUG
void
assert_iterators(const char*, int) const;
void
assert_size(const char*, int) const;
static size_type
size_from_node(node_const_pointer);
#endif
node_pointer
recursive_copy_node(node_const_pointer);
inline node_pointer
get_new_node_for_insert(const_reference, false_type);
inline node_pointer
get_new_node_for_insert(const_reference, true_type);
#ifdef PB_DS_LC_NS_HEAP_TRACE_
template<typename Metadata_>
static void
trace_node_metadata(node_const_pointer, type_to_type<Metadata_>);
static void
trace_node_metadata(node_const_pointer, type_to_type<null_type>);
#endif
static node_allocator s_node_allocator;
static no_throw_copies_t s_no_throw_copies_ind;
protected:
node_pointer m_p_root;
size_type m_size;
};
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/iterators_fn_imps.hpp>
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/debug_fn_imps.hpp>
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/trace_fn_imps.hpp>
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/insert_fn_imps.hpp>
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/erase_fn_imps.hpp>
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/info_fn_imps.hpp>
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/policy_access_fn_imps.hpp>
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC
} // namespace detail
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/detail/left_child_next_sibling_heap_/policy_access_fn_imps.hpp 0000644 00000003607 15201526705 0023467 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file left_child_next_sibling_heap_/policy_access_fn_imps.hpp
* Contains an implementation class for left_child_next_sibling_heap_.
*/
PB_DS_CLASS_T_DEC
Cmp_Fn&
PB_DS_CLASS_C_DEC::
get_cmp_fn()
{ return *this; }
PB_DS_CLASS_T_DEC
const Cmp_Fn&
PB_DS_CLASS_C_DEC::
get_cmp_fn() const
{ return *this; }
c++/8/ext/pb_ds/detail/list_update_map_/info_fn_imps.hpp 0000644 00000004032 15201526705 0017106 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file list_update_map_/info_fn_imps.hpp
* Contains implementations of lu_map_.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
size() const
{ return std::distance(begin(), end()); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
max_size() const
{ return s_entry_allocator.max_size(); }
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
empty() const
{ return (m_p_l == 0); }
c++/8/ext/pb_ds/detail/list_update_map_/iterators_fn_imps.hpp 0000644 00000004722 15201526705 0020175 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file list_update_map_/iterators_fn_imps.hpp
* Contains implementations of lu_map_.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
begin()
{
if (m_p_l == 0)
{
_GLIBCXX_DEBUG_ASSERT(empty());
return end();
}
return iterator(&m_p_l->m_value, m_p_l, this);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
begin() const
{
if (m_p_l == 0)
{
_GLIBCXX_DEBUG_ASSERT(empty());
return end();
}
return iterator(&m_p_l->m_value, m_p_l, const_cast<PB_DS_CLASS_C_DEC* >(this));
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
end()
{ return iterator(0, 0, this); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
end() const
{
return const_iterator(0, 0, const_cast<PB_DS_CLASS_C_DEC*>(this));
}
c++/8/ext/pb_ds/detail/list_update_map_/debug_fn_imps.hpp 0000644 00000004057 15201526705 0017250 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file list_update_map_/debug_fn_imps.hpp
* Contains implementations of cc_ht_map_'s debug-mode functions.
*/
#ifdef _GLIBCXX_DEBUG
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_valid(const char* __file, int __line) const
{
size_type calc_size = 0;
for (const_iterator it = begin(); it != end(); ++it)
{
debug_base::check_key_exists(PB_DS_V2F(*it), __file, __line);
++calc_size;
}
debug_base::check_size(calc_size, __file, __line);
}
#endif
c++/8/ext/pb_ds/detail/list_update_map_/find_fn_imps.hpp 0000644 00000005455 15201526705 0017105 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file list_update_map_/find_fn_imps.hpp
* Contains implementations of lu_map_.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::entry_pointer
PB_DS_CLASS_C_DEC::
find_imp(key_const_reference r_key) const
{
if (m_p_l == 0)
return 0;
if (s_eq_fn(r_key, PB_DS_V2F(m_p_l->m_value)))
{
apply_update(m_p_l, s_metadata_type_indicator);
PB_DS_CHECK_KEY_EXISTS(r_key)
return m_p_l;
}
entry_pointer p_l = m_p_l;
while (p_l->m_p_next != 0)
{
entry_pointer p_next = p_l->m_p_next;
if (s_eq_fn(r_key, PB_DS_V2F(p_next->m_value)))
{
if (apply_update(p_next, s_metadata_type_indicator))
{
p_l->m_p_next = p_next->m_p_next;
p_next->m_p_next = m_p_l;
m_p_l = p_next;
return m_p_l;
}
return p_next;
}
else
p_l = p_next;
}
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return 0;
}
PB_DS_CLASS_T_DEC
template<typename Metadata>
inline bool
PB_DS_CLASS_C_DEC::
apply_update(entry_pointer p_l, type_to_type<Metadata>)
{ return s_update_policy(p_l->m_update_metadata); }
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
apply_update(entry_pointer, type_to_type<null_type>)
{ return s_update_policy(s_null_type); }
c++/8/ext/pb_ds/detail/list_update_map_/entry_metadata_base.hpp 0000644 00000004105 15201526705 0020434 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file list_update_map_/entry_metadata_base.hpp
* Contains an implementation for a list update map.
*/
#ifndef PB_DS_LU_MAP_ENTRY_METADATA_BASE_HPP
#define PB_DS_LU_MAP_ENTRY_METADATA_BASE_HPP
namespace __gnu_pbds
{
namespace detail
{
template<typename Metadata>
struct lu_map_entry_metadata_base
{
Metadata m_update_metadata;
};
template<>
struct lu_map_entry_metadata_base<null_type>
{ };
} // namespace detail
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/detail/list_update_map_/lu_map_.hpp 0000644 00000024231 15201526705 0016057 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file list_update_map_/lu_map_.hpp
* Contains a list update map.
*/
#include <utility>
#include <iterator>
#include <ext/pb_ds/detail/cond_dealtor.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/pb_ds/detail/types_traits.hpp>
#include <ext/pb_ds/detail/list_update_map_/entry_metadata_base.hpp>
#include <ext/pb_ds/exception.hpp>
#ifdef _GLIBCXX_DEBUG
#include <ext/pb_ds/detail/debug_map_base.hpp>
#endif
#ifdef PB_DS_LU_MAP_TRACE_
#include <iostream>
#endif
#include <debug/debug.h>
namespace __gnu_pbds
{
namespace detail
{
#ifdef PB_DS_DATA_TRUE_INDICATOR
#define PB_DS_LU_NAME lu_map
#endif
#ifdef PB_DS_DATA_FALSE_INDICATOR
#define PB_DS_LU_NAME lu_set
#endif
#define PB_DS_CLASS_T_DEC \
template<typename Key, typename Mapped, typename Eq_Fn, \
typename _Alloc, typename Update_Policy>
#define PB_DS_CLASS_C_DEC \
PB_DS_LU_NAME<Key, Mapped, Eq_Fn, _Alloc, Update_Policy>
#define PB_DS_LU_TRAITS_BASE \
types_traits<Key, Mapped, _Alloc, false>
#ifdef _GLIBCXX_DEBUG
#define PB_DS_DEBUG_MAP_BASE_C_DEC \
debug_map_base<Key, Eq_Fn, \
typename _Alloc::template rebind<Key>::other::const_reference>
#endif
/// list-based (with updates) associative container.
/// Skip to the lu, my darling.
template<typename Key,
typename Mapped,
typename Eq_Fn,
typename _Alloc,
typename Update_Policy>
class PB_DS_LU_NAME :
#ifdef _GLIBCXX_DEBUG
protected PB_DS_DEBUG_MAP_BASE_C_DEC,
#endif
public PB_DS_LU_TRAITS_BASE
{
private:
typedef PB_DS_LU_TRAITS_BASE traits_base;
struct entry
: public lu_map_entry_metadata_base<typename Update_Policy::metadata_type>
{
typename traits_base::value_type m_value;
typename _Alloc::template rebind<entry>::other::pointer m_p_next;
};
typedef typename _Alloc::template rebind<entry>::other entry_allocator;
typedef typename entry_allocator::pointer entry_pointer;
typedef typename entry_allocator::const_pointer const_entry_pointer;
typedef typename entry_allocator::reference entry_reference;
typedef typename entry_allocator::const_reference const_entry_reference;
typedef typename _Alloc::template rebind<entry_pointer>::other entry_pointer_allocator;
typedef typename entry_pointer_allocator::pointer entry_pointer_array;
typedef typename traits_base::value_type value_type_;
typedef typename traits_base::pointer pointer_;
typedef typename traits_base::const_pointer const_pointer_;
typedef typename traits_base::reference reference_;
typedef typename traits_base::const_reference const_reference_;
#define PB_DS_GEN_POS entry_pointer
#include <ext/pb_ds/detail/unordered_iterator/point_const_iterator.hpp>
#include <ext/pb_ds/detail/unordered_iterator/point_iterator.hpp>
#include <ext/pb_ds/detail/unordered_iterator/const_iterator.hpp>
#include <ext/pb_ds/detail/unordered_iterator/iterator.hpp>
#undef PB_DS_GEN_POS
#ifdef _GLIBCXX_DEBUG
typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base;
#endif
typedef cond_dealtor<entry, _Alloc> cond_dealtor_t;
public:
typedef _Alloc allocator_type;
typedef typename _Alloc::size_type size_type;
typedef typename _Alloc::difference_type difference_type;
typedef Eq_Fn eq_fn;
typedef Update_Policy update_policy;
typedef typename Update_Policy::metadata_type update_metadata;
typedef typename traits_base::key_type key_type;
typedef typename traits_base::key_pointer key_pointer;
typedef typename traits_base::key_const_pointer key_const_pointer;
typedef typename traits_base::key_reference key_reference;
typedef typename traits_base::key_const_reference key_const_reference;
typedef typename traits_base::mapped_type mapped_type;
typedef typename traits_base::mapped_pointer mapped_pointer;
typedef typename traits_base::mapped_const_pointer mapped_const_pointer;
typedef typename traits_base::mapped_reference mapped_reference;
typedef typename traits_base::mapped_const_reference mapped_const_reference;
typedef typename traits_base::value_type value_type;
typedef typename traits_base::pointer pointer;
typedef typename traits_base::const_pointer const_pointer;
typedef typename traits_base::reference reference;
typedef typename traits_base::const_reference const_reference;
#ifdef PB_DS_DATA_TRUE_INDICATOR
typedef point_iterator_ point_iterator;
#endif
#ifdef PB_DS_DATA_FALSE_INDICATOR
typedef point_const_iterator_ point_iterator;
#endif
typedef point_const_iterator_ point_const_iterator;
#ifdef PB_DS_DATA_TRUE_INDICATOR
typedef iterator_ iterator;
#endif
#ifdef PB_DS_DATA_FALSE_INDICATOR
typedef const_iterator_ iterator;
#endif
typedef const_iterator_ const_iterator;
public:
PB_DS_LU_NAME();
PB_DS_LU_NAME(const PB_DS_CLASS_C_DEC&);
virtual
~PB_DS_LU_NAME();
template<typename It>
PB_DS_LU_NAME(It, It);
void
swap(PB_DS_CLASS_C_DEC&);
inline size_type
size() const;
inline size_type
max_size() const;
inline bool
empty() const;
inline mapped_reference
operator[](key_const_reference r_key)
{
#ifdef PB_DS_DATA_TRUE_INDICATOR
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
return insert(std::make_pair(r_key, mapped_type())).first->second;
#else
insert(r_key);
return traits_base::s_null_type;
#endif
}
inline std::pair<point_iterator, bool>
insert(const_reference);
inline point_iterator
find(key_const_reference r_key)
{
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
entry_pointer p_e = find_imp(r_key);
return point_iterator(p_e == 0 ? 0: &p_e->m_value);
}
inline point_const_iterator
find(key_const_reference r_key) const
{
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
entry_pointer p_e = find_imp(r_key);
return point_const_iterator(p_e == 0 ? 0: &p_e->m_value);
}
inline bool
erase(key_const_reference);
template<typename Pred>
inline size_type
erase_if(Pred);
void
clear();
inline iterator
begin();
inline const_iterator
begin() const;
inline iterator
end();
inline const_iterator
end() const;
#ifdef _GLIBCXX_DEBUG
void
assert_valid(const char* file, int line) const;
#endif
#ifdef PB_DS_LU_MAP_TRACE_
void
trace() const;
#endif
protected:
template<typename It>
void
copy_from_range(It, It);
private:
#ifdef PB_DS_DATA_TRUE_INDICATOR
friend class iterator_;
#endif
friend class const_iterator_;
inline entry_pointer
allocate_new_entry(const_reference, false_type);
inline entry_pointer
allocate_new_entry(const_reference, true_type);
template<typename Metadata>
inline static void
init_entry_metadata(entry_pointer, type_to_type<Metadata>);
inline static void
init_entry_metadata(entry_pointer, type_to_type<null_type>);
void
deallocate_all();
void
erase_next(entry_pointer);
void
actual_erase_entry(entry_pointer);
void
inc_it_state(const_pointer& r_p_value, entry_pointer& r_pos) const
{
r_pos = r_pos->m_p_next;
r_p_value = (r_pos == 0) ? 0 : &r_pos->m_value;
}
template<typename Metadata>
inline static bool
apply_update(entry_pointer, type_to_type<Metadata>);
inline static bool
apply_update(entry_pointer, type_to_type<null_type>);
inline entry_pointer
find_imp(key_const_reference) const;
static entry_allocator s_entry_allocator;
static Eq_Fn s_eq_fn;
static Update_Policy s_update_policy;
static type_to_type<update_metadata> s_metadata_type_indicator;
static null_type s_null_type;
mutable entry_pointer m_p_l;
};
#include <ext/pb_ds/detail/list_update_map_/constructor_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/list_update_map_/info_fn_imps.hpp>
#include <ext/pb_ds/detail/list_update_map_/debug_fn_imps.hpp>
#include <ext/pb_ds/detail/list_update_map_/iterators_fn_imps.hpp>
#include <ext/pb_ds/detail/list_update_map_/erase_fn_imps.hpp>
#include <ext/pb_ds/detail/list_update_map_/find_fn_imps.hpp>
#include <ext/pb_ds/detail/list_update_map_/insert_fn_imps.hpp>
#include <ext/pb_ds/detail/list_update_map_/trace_fn_imps.hpp>
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_LU_TRAITS_BASE
#undef PB_DS_DEBUG_MAP_BASE_C_DEC
#undef PB_DS_LU_NAME
} // namespace detail
} // namespace __gnu_pbds
c++/8/ext/pb_ds/detail/list_update_map_/insert_fn_imps.hpp 0000644 00000006666 15201526705 0017476 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file list_update_map_/insert_fn_imps.hpp
* Contains implementations of lu_map_.
*/
PB_DS_CLASS_T_DEC
inline std::pair<
typename PB_DS_CLASS_C_DEC::point_iterator,
bool>
PB_DS_CLASS_C_DEC::
insert(const_reference r_val)
{
PB_DS_ASSERT_VALID((*this))
entry_pointer p_l = find_imp(PB_DS_V2F(r_val));
if (p_l != 0)
{
PB_DS_CHECK_KEY_EXISTS(PB_DS_V2F(r_val))
return std::make_pair(point_iterator(&p_l->m_value), false);
}
PB_DS_CHECK_KEY_DOES_NOT_EXIST(PB_DS_V2F(r_val))
p_l = allocate_new_entry(r_val, traits_base::m_no_throw_copies_indicator);
p_l->m_p_next = m_p_l;
m_p_l = p_l;
PB_DS_ASSERT_VALID((*this))
return std::make_pair(point_iterator(&p_l->m_value), true);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::entry_pointer
PB_DS_CLASS_C_DEC::
allocate_new_entry(const_reference r_val, false_type)
{
entry_pointer p_l = s_entry_allocator.allocate(1);
cond_dealtor_t cond(p_l);
new (const_cast<void* >(static_cast<const void* >(&p_l->m_value)))
value_type(r_val);
cond.set_no_action();
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_val));)
init_entry_metadata(p_l, s_metadata_type_indicator);
return p_l;
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::entry_pointer
PB_DS_CLASS_C_DEC::
allocate_new_entry(const_reference r_val, true_type)
{
entry_pointer p_l = s_entry_allocator.allocate(1);
new (&p_l->m_value) value_type(r_val);
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_val));)
init_entry_metadata(p_l, s_metadata_type_indicator);
return p_l;
}
PB_DS_CLASS_T_DEC
template<typename Metadata>
inline void
PB_DS_CLASS_C_DEC::
init_entry_metadata(entry_pointer p_l, type_to_type<Metadata>)
{ new (&p_l->m_update_metadata) Metadata(s_update_policy()); }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
init_entry_metadata(entry_pointer, type_to_type<null_type>)
{ }
c++/8/ext/pb_ds/detail/list_update_map_/erase_fn_imps.hpp 0000644 00000006632 15201526705 0017262 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file list_update_map_/erase_fn_imps.hpp
* Contains implementations of lu_map_.
*/
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
erase(key_const_reference r_key)
{
PB_DS_ASSERT_VALID((*this))
if (m_p_l == 0)
return false;
if (s_eq_fn(r_key, PB_DS_V2F(m_p_l->m_value)))
{
entry_pointer p_next = m_p_l->m_p_next;
actual_erase_entry(m_p_l);
m_p_l = p_next;
return true;
}
entry_pointer p_l = m_p_l;
while (p_l->m_p_next != 0)
if (s_eq_fn(r_key, PB_DS_V2F(p_l->m_p_next->m_value)))
{
erase_next(p_l);
return true;
}
else
p_l = p_l->m_p_next;
return false;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
clear()
{
deallocate_all();
}
PB_DS_CLASS_T_DEC
template<typename Pred>
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
erase_if(Pred pred)
{
PB_DS_ASSERT_VALID((*this))
size_type num_ersd = 0;
while (m_p_l != 0 && pred(m_p_l->m_value))
{
entry_pointer p_next = m_p_l->m_p_next;
++num_ersd;
actual_erase_entry(m_p_l);
m_p_l = p_next;
}
if (m_p_l == 0)
return num_ersd;
entry_pointer p_l = m_p_l;
while (p_l->m_p_next != 0)
{
if (pred(p_l->m_p_next->m_value))
{
++num_ersd;
erase_next(p_l);
}
else
p_l = p_l->m_p_next;
}
PB_DS_ASSERT_VALID((*this))
return num_ersd;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
erase_next(entry_pointer p_l)
{
_GLIBCXX_DEBUG_ASSERT(p_l != 0);
_GLIBCXX_DEBUG_ASSERT(p_l->m_p_next != 0);
entry_pointer p_next_l = p_l->m_p_next->m_p_next;
actual_erase_entry(p_l->m_p_next);
p_l->m_p_next = p_next_l;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
actual_erase_entry(entry_pointer p_l)
{
_GLIBCXX_DEBUG_ONLY(debug_base::erase_existing(PB_DS_V2F(p_l->m_value));)
p_l->~entry();
s_entry_allocator.deallocate(p_l, 1);
}
c++/8/ext/pb_ds/detail/list_update_map_/constructor_destructor_fn_imps.hpp 0000644 00000007000 15201526705 0023014 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file list_update_map_/constructor_destructor_fn_imps.hpp
*/
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::entry_allocator
PB_DS_CLASS_C_DEC::s_entry_allocator;
PB_DS_CLASS_T_DEC
Eq_Fn PB_DS_CLASS_C_DEC::s_eq_fn;
PB_DS_CLASS_T_DEC
null_type PB_DS_CLASS_C_DEC::s_null_type;
PB_DS_CLASS_T_DEC
Update_Policy PB_DS_CLASS_C_DEC::s_update_policy;
PB_DS_CLASS_T_DEC
type_to_type<
typename PB_DS_CLASS_C_DEC::update_metadata> PB_DS_CLASS_C_DEC::s_metadata_type_indicator;
PB_DS_CLASS_T_DEC
template<typename It>
void
PB_DS_CLASS_C_DEC::
copy_from_range(It first_it, It last_it)
{
while (first_it != last_it)
insert(*(first_it++));
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_LU_NAME() : m_p_l(0)
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
template<typename It>
PB_DS_CLASS_C_DEC::
PB_DS_LU_NAME(It first_it, It last_it) : m_p_l(0)
{
copy_from_range(first_it, last_it);
PB_DS_ASSERT_VALID((*this));
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_LU_NAME(const PB_DS_CLASS_C_DEC& other) :
m_p_l(0)
{
__try
{
for (const_iterator it = other.begin(); it != other.end(); ++it)
{
entry_pointer p_l = allocate_new_entry(*it,
traits_base::m_no_throw_copies_indicator);
p_l->m_p_next = m_p_l;
m_p_l = p_l;
}
}
__catch(...)
{
deallocate_all();
__throw_exception_again;
}
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
_GLIBCXX_DEBUG_ONLY(debug_base::swap(other);)
std::swap(m_p_l, other.m_p_l);
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
deallocate_all()
{
entry_pointer p_l = m_p_l;
while (p_l != 0)
{
entry_pointer p_next_l = p_l->m_p_next;
actual_erase_entry(p_l);
p_l = p_next_l;
}
m_p_l = 0;
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
~PB_DS_LU_NAME()
{ deallocate_all(); }
c++/8/ext/pb_ds/detail/list_update_map_/trace_fn_imps.hpp 0000644 00000003754 15201526705 0017263 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file list_update_map_/trace_fn_imps.hpp
* Contains implementations of lu_map_.
*/
#ifdef PB_DS_LU_MAP_TRACE_
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
trace() const
{
std::cerr << m_p_l << std::endl << std::endl;
const_entry_pointer p_l = m_p_l;
while (p_l != 0)
{
std::cerr << PB_DS_V2F(p_l->m_value) << std::endl;
p_l = p_l->m_p_next;
}
std::cerr << std::endl;
}
#endif
c++/8/ext/pb_ds/detail/pairing_heap_/constructors_destructor_fn_imps.hpp 0000644 00000004712 15201526705 0022462 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file pairing_heap_/constructors_destructor_fn_imps.hpp
* Contains an implementation class for a pairing heap.
*/
PB_DS_CLASS_T_DEC
template<typename It>
void
PB_DS_CLASS_C_DEC::
copy_from_range(It first_it, It last_it)
{
while (first_it != last_it)
push(*(first_it++));
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
pairing_heap()
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
pairing_heap(const Cmp_Fn& r_cmp_fn)
: base_type(r_cmp_fn)
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
pairing_heap(const PB_DS_CLASS_C_DEC& other)
: base_type(other)
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
base_type::swap(other);
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
~pairing_heap()
{ }
c++/8/ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp 0000644 00000003714 15201526705 0016523 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file pairing_heap_/debug_fn_imps.hpp
* Contains an implementation class for a pairing heap.
*/
#ifdef _GLIBCXX_DEBUG
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_valid(const char* __file, int __line) const
{
PB_DS_DEBUG_VERIFY(base_type::m_p_root == 0
|| base_type::m_p_root->m_p_next_sibling == 0);
base_type::assert_valid(__file, __line);
}
#endif
c++/8/ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp 0000644 00000003621 15201526705 0016352 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file pairing_heap_/find_fn_imps.hpp
* Contains an implementation class for a pairing heap.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_reference
PB_DS_CLASS_C_DEC::
top() const
{
PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
return base_type::m_p_root->m_value;
}
c++/8/ext/pb_ds/detail/pairing_heap_/pairing_heap_.hpp 0000644 00000012615 15201526705 0016507 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file pairing_heap_/pairing_heap_.hpp
* Contains an implementation class for a pairing heap.
*/
/*
* Pairing heap:
* Michael L. Fredman, Robert Sedgewick, Daniel Dominic Sleator,
* and Robert Endre Tarjan, The Pairing Heap:
* A New Form of Self-Adjusting Heap, Algorithmica, 1(1):111-129, 1986.
*/
#include <ext/pb_ds/detail/cond_dealtor.hpp>
#include <ext/pb_ds/detail/type_utils.hpp>
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp>
#include <debug/debug.h>
namespace __gnu_pbds
{
namespace detail
{
#define PB_DS_CLASS_T_DEC \
template<typename Value_Type, typename Cmp_Fn, typename _Alloc>
#define PB_DS_CLASS_C_DEC \
pairing_heap<Value_Type, Cmp_Fn, _Alloc>
#ifdef _GLIBCXX_DEBUG
#define PB_DS_P_HEAP_BASE \
left_child_next_sibling_heap<Value_Type, Cmp_Fn, null_type, _Alloc, false>
#else
#define PB_DS_P_HEAP_BASE \
left_child_next_sibling_heap<Value_Type, Cmp_Fn, null_type, _Alloc>
#endif
/**
* Pairing heap.
*
* @ingroup heap-detail
*/
template<typename Value_Type, typename Cmp_Fn, typename _Alloc>
class pairing_heap : public PB_DS_P_HEAP_BASE
{
private:
typedef PB_DS_P_HEAP_BASE base_type;
typedef typename base_type::node_pointer node_pointer;
typedef typename _Alloc::template rebind<Value_Type>::other __rebind_a;
public:
typedef Value_Type value_type;
typedef Cmp_Fn cmp_fn;
typedef _Alloc allocator_type;
typedef typename _Alloc::size_type size_type;
typedef typename _Alloc::difference_type difference_type;
typedef typename __rebind_a::pointer pointer;
typedef typename __rebind_a::const_pointer const_pointer;
typedef typename __rebind_a::reference reference;
typedef typename __rebind_a::const_reference const_reference;
typedef typename base_type::point_const_iterator point_const_iterator;
typedef typename base_type::point_iterator point_iterator;
typedef typename base_type::const_iterator const_iterator;
typedef typename base_type::iterator iterator;
pairing_heap();
pairing_heap(const Cmp_Fn&);
pairing_heap(const pairing_heap&);
void
swap(pairing_heap&);
~pairing_heap();
inline point_iterator
push(const_reference);
void
modify(point_iterator, const_reference);
inline const_reference
top() const;
void
pop();
void
erase(point_iterator);
template<typename Pred>
size_type
erase_if(Pred);
template<typename Pred>
void
split(Pred, pairing_heap&);
void
join(pairing_heap&);
protected:
template<typename It>
void
copy_from_range(It, It);
#ifdef _GLIBCXX_DEBUG
void
assert_valid(const char*, int) const;
#endif
private:
inline void
push_imp(node_pointer);
node_pointer
join_node_children(node_pointer);
node_pointer
forward_join(node_pointer, node_pointer);
node_pointer
back_join(node_pointer, node_pointer);
void
remove_node(node_pointer);
};
#define PB_DS_ASSERT_NODE_CONSISTENT(_Node, _Bool) \
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(_Node, _Bool, \
__FILE__, __LINE__);)
#include <ext/pb_ds/detail/pairing_heap_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp>
#include <ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp>
#include <ext/pb_ds/detail/pairing_heap_/insert_fn_imps.hpp>
#include <ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp>
#include <ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp>
#undef PB_DS_ASSERT_NODE_CONSISTENT
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_P_HEAP_BASE
} // namespace detail
} // namespace __gnu_pbds
c++/8/ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp 0000644 00000007172 15201526705 0017611 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file pairing_heap_/split_join_fn_imps.hpp
* Contains an implementation class for a pairing heap.
*/
PB_DS_CLASS_T_DEC
template<typename Pred>
void
PB_DS_CLASS_C_DEC::
split(Pred pred, PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
other.clear();
if (base_type::empty())
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
return;
}
base_type::to_linked_list();
node_pointer p_out = base_type::prune(pred);
while (p_out != 0)
{
_GLIBCXX_DEBUG_ASSERT(base_type::m_size > 0);
--base_type::m_size;
++other.m_size;
node_pointer p_next = p_out->m_p_next_sibling;
p_out->m_p_l_child = p_out->m_p_next_sibling = p_out->m_p_prev_or_parent = 0;
other.push_imp(p_out);
p_out = p_next;
}
PB_DS_ASSERT_VALID(other)
node_pointer p_cur = base_type::m_p_root;
base_type::m_p_root = 0;
while (p_cur != 0)
{
node_pointer p_next = p_cur->m_p_next_sibling;
p_cur->m_p_l_child = p_cur->m_p_next_sibling = p_cur->m_p_prev_or_parent = 0;
push_imp(p_cur);
p_cur = p_next;
}
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
join(PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
if (other.m_p_root == 0)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
return;
}
if (base_type::m_p_root == 0)
base_type::m_p_root = other.m_p_root;
else if (Cmp_Fn::operator()(base_type::m_p_root->m_value, other.m_p_root->m_value))
{
base_type::make_child_of(base_type::m_p_root, other.m_p_root);
PB_DS_ASSERT_NODE_CONSISTENT(other.m_p_root, false)
base_type::m_p_root = other.m_p_root;
}
else
{
base_type::make_child_of(other.m_p_root, base_type::m_p_root);
PB_DS_ASSERT_NODE_CONSISTENT(base_type::m_p_root, false)
}
base_type::m_size += other.m_size;
other.m_p_root = 0;
other.m_size = 0;
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
c++/8/ext/pb_ds/detail/pairing_heap_/insert_fn_imps.hpp 0000644 00000005603 15201526705 0016740 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file pairing_heap_/insert_fn_imps.hpp
* Contains an implementation class for a pairing heap.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC::
push(const_reference r_val)
{
PB_DS_ASSERT_VALID((*this))
node_pointer p_new_nd = base_type::get_new_node_for_insert(r_val);
push_imp(p_new_nd);
PB_DS_ASSERT_VALID((*this))
return point_iterator(p_new_nd);
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
push_imp(node_pointer p_nd)
{
p_nd->m_p_l_child = 0;
if (base_type::m_p_root == 0)
{
p_nd->m_p_next_sibling = p_nd->m_p_prev_or_parent = 0;
base_type::m_p_root = p_nd;
}
else if (Cmp_Fn::operator()(base_type::m_p_root->m_value, p_nd->m_value))
{
p_nd->m_p_next_sibling = p_nd->m_p_prev_or_parent = 0;
base_type::make_child_of(base_type::m_p_root, p_nd);
PB_DS_ASSERT_NODE_CONSISTENT(p_nd, false)
base_type::m_p_root = p_nd;
}
else
{
base_type::make_child_of(p_nd, base_type::m_p_root);
PB_DS_ASSERT_NODE_CONSISTENT(base_type::m_p_root, false)
}
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
modify(point_iterator it, const_reference r_new_val)
{
PB_DS_ASSERT_VALID((*this))
remove_node(it.m_p_nd);
it.m_p_nd->m_value = r_new_val;
push_imp(it.m_p_nd);
PB_DS_ASSERT_VALID((*this))
}
c++/8/ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp 0000644 00000016027 15201526705 0016535 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file pairing_heap_/erase_fn_imps.hpp
* Contains an implementation class for a pairing heap.
*/
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
pop()
{
PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
node_pointer p_new_root = join_node_children(base_type::m_p_root);
PB_DS_ASSERT_NODE_CONSISTENT(p_new_root, false)
if (p_new_root != 0)
p_new_root->m_p_prev_or_parent = 0;
base_type::actual_erase_node(base_type::m_p_root);
base_type::m_p_root = p_new_root;
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
erase(point_iterator it)
{
PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
remove_node(it.m_p_nd);
base_type::actual_erase_node(it.m_p_nd);
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
remove_node(node_pointer p_nd)
{
PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
node_pointer p_new_child = join_node_children(p_nd);
PB_DS_ASSERT_NODE_CONSISTENT(p_new_child, false)
if (p_nd == base_type::m_p_root)
{
if (p_new_child != 0)
p_new_child->m_p_prev_or_parent = 0;
base_type::m_p_root = p_new_child;
PB_DS_ASSERT_NODE_CONSISTENT(base_type::m_p_root, false)
return;
}
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_prev_or_parent != 0);
if (p_nd->m_p_prev_or_parent->m_p_l_child == p_nd)
{
if (p_new_child != 0)
{
p_new_child->m_p_prev_or_parent = p_nd->m_p_prev_or_parent;
p_new_child->m_p_next_sibling = p_nd->m_p_next_sibling;
if (p_new_child->m_p_next_sibling != 0)
p_new_child->m_p_next_sibling->m_p_prev_or_parent = p_new_child;
p_nd->m_p_prev_or_parent->m_p_l_child = p_new_child;
PB_DS_ASSERT_NODE_CONSISTENT(p_nd->m_p_prev_or_parent, false)
return;
}
p_nd->m_p_prev_or_parent->m_p_l_child = p_nd->m_p_next_sibling;
if (p_nd->m_p_next_sibling != 0)
p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd->m_p_prev_or_parent;
PB_DS_ASSERT_NODE_CONSISTENT(p_nd->m_p_prev_or_parent, false)
return;
}
if (p_new_child != 0)
{
p_new_child->m_p_prev_or_parent = p_nd->m_p_prev_or_parent;
p_new_child->m_p_next_sibling = p_nd->m_p_next_sibling;
if (p_new_child->m_p_next_sibling != 0)
p_new_child->m_p_next_sibling->m_p_prev_or_parent = p_new_child;
p_new_child->m_p_prev_or_parent->m_p_next_sibling = p_new_child;
PB_DS_ASSERT_NODE_CONSISTENT(p_nd->m_p_prev_or_parent, false)
return;
}
p_nd->m_p_prev_or_parent->m_p_next_sibling = p_nd->m_p_next_sibling;
if (p_nd->m_p_next_sibling != 0)
p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd->m_p_prev_or_parent;
PB_DS_ASSERT_NODE_CONSISTENT(p_nd->m_p_prev_or_parent, false)
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
join_node_children(node_pointer p_nd)
{
_GLIBCXX_DEBUG_ASSERT(p_nd != 0);
node_pointer p_ret = p_nd->m_p_l_child;
if (p_ret == 0)
return 0;
while (p_ret->m_p_next_sibling != 0)
p_ret = forward_join(p_ret, p_ret->m_p_next_sibling);
while (p_ret->m_p_prev_or_parent != p_nd)
p_ret = back_join(p_ret->m_p_prev_or_parent, p_ret);
PB_DS_ASSERT_NODE_CONSISTENT(p_ret, false)
return p_ret;
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
forward_join(node_pointer p_nd, node_pointer p_next)
{
_GLIBCXX_DEBUG_ASSERT(p_nd != 0);
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_next_sibling == p_next);
if (Cmp_Fn::operator()(p_nd->m_value, p_next->m_value))
{
p_next->m_p_prev_or_parent = p_nd->m_p_prev_or_parent;
base_type::make_child_of(p_nd, p_next);
return p_next->m_p_next_sibling == 0
? p_next : p_next->m_p_next_sibling;
}
if (p_next->m_p_next_sibling != 0)
{
p_next->m_p_next_sibling->m_p_prev_or_parent = p_nd;
p_nd->m_p_next_sibling = p_next->m_p_next_sibling;
base_type::make_child_of(p_next, p_nd);
return p_nd->m_p_next_sibling;
}
p_nd->m_p_next_sibling = 0;
base_type::make_child_of(p_next, p_nd);
PB_DS_ASSERT_NODE_CONSISTENT(p_nd, false)
return p_nd;
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
back_join(node_pointer p_nd, node_pointer p_next)
{
_GLIBCXX_DEBUG_ASSERT(p_nd != 0);
_GLIBCXX_DEBUG_ASSERT(p_next->m_p_next_sibling == 0);
if (Cmp_Fn::operator()(p_nd->m_value, p_next->m_value))
{
p_next->m_p_prev_or_parent = p_nd->m_p_prev_or_parent;
base_type::make_child_of(p_nd, p_next);
PB_DS_ASSERT_NODE_CONSISTENT(p_next, false)
return p_next;
}
p_nd->m_p_next_sibling = 0;
base_type::make_child_of(p_next, p_nd);
PB_DS_ASSERT_NODE_CONSISTENT(p_nd, false)
return p_nd;
}
PB_DS_CLASS_T_DEC
template<typename Pred>
typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
erase_if(Pred pred)
{
PB_DS_ASSERT_VALID((*this))
if (base_type::empty())
{
PB_DS_ASSERT_VALID((*this))
return 0;
}
base_type::to_linked_list();
node_pointer p_out = base_type::prune(pred);
size_type ersd = 0;
while (p_out != 0)
{
++ersd;
node_pointer p_next = p_out->m_p_next_sibling;
base_type::actual_erase_node(p_out);
p_out = p_next;
}
node_pointer p_cur = base_type::m_p_root;
base_type::m_p_root = 0;
while (p_cur != 0)
{
node_pointer p_next = p_cur->m_p_next_sibling;
p_cur->m_p_l_child = p_cur->m_p_next_sibling = p_cur->m_p_prev_or_parent = 0;
push_imp(p_cur);
p_cur = p_next;
}
PB_DS_ASSERT_VALID((*this))
return ersd;
}
c++/8/ext/pb_ds/detail/list_update_policy/lu_counter_metadata.hpp 0000644 00000005442 15201526705 0021050 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file lu_counter_metadata.hpp
* Contains implementation of a lu counter policy's metadata.
*/
namespace __gnu_pbds
{
namespace detail
{
template<typename Size_Type>
class lu_counter_policy_base;
/// A list-update metadata type that moves elements to the front of
/// the list based on the counter algorithm.
template<typename Size_Type = std::size_t>
class lu_counter_metadata
{
public:
typedef Size_Type size_type;
private:
lu_counter_metadata(size_type init_count) : m_count(init_count)
{ }
friend class lu_counter_policy_base<size_type>;
mutable size_type m_count;
};
/// Base class for list-update counter policy.
template<typename Size_Type>
class lu_counter_policy_base
{
protected:
typedef Size_Type size_type;
lu_counter_metadata<size_type>
operator()(size_type max_size) const
{ return lu_counter_metadata<Size_Type>(std::rand() % max_size); }
template<typename Metadata_Reference>
bool
operator()(Metadata_Reference r_data, size_type m_max_count) const
{
if (++r_data.m_count != m_max_count)
return false;
r_data.m_count = 0;
return true;
}
};
} // namespace detail
} // namespace __gnu_pbds
c++/8/ext/pb_ds/detail/list_update_policy/sample_update_policy.hpp 0000644 00000005160 15201526705 0021230 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file sample_update_policy.hpp
* Contains a sample policy for list update containers.
*/
#ifndef PB_DS_SAMPLE_UPDATE_POLICY_HPP
#define PB_DS_SAMPLE_UPDATE_POLICY_HPP
namespace __gnu_pbds
{
/// A sample list-update policy.
struct sample_update_policy
{
/// Default constructor.
sample_update_policy();
/// Copy constructor.
sample_update_policy(const sample_update_policy&);
/// Swaps content.
inline void
swap(sample_update_policy& other);
protected:
/// Metadata on which this functor operates.
typedef some_metadata_type metadata_type;
/// Creates a metadata object.
metadata_type
operator()() const;
/// Decides whether a metadata object should be moved to the front
/// of the list. A list-update based containers object will call
/// this method to decide whether to move a node to the front of
/// the list. The method shoule return true if the node should be
/// moved to the front of the list.
bool
operator()(metadata_reference) const;
};
}
#endif
c++/8/ext/pb_ds/detail/debug_map_base.hpp 0000644 00000020771 15201526705 0014054 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file detail/debug_map_base.hpp
* Contains a debug-mode base for all maps.
*/
#ifndef PB_DS_DEBUG_MAP_BASE_HPP
#define PB_DS_DEBUG_MAP_BASE_HPP
#ifdef _GLIBCXX_DEBUG
#include <list>
#include <utility>
#include <cstdlib>
#include <iostream>
#include <ext/throw_allocator.h>
#include <debug/debug.h>
namespace __gnu_pbds
{
namespace detail
{
// Need std::pair ostream extractor.
template<typename _CharT, typename _Traits, typename _Tp1, typename _Tp2>
inline std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __out,
const std::pair<_Tp1, _Tp2>& p)
{ return (__out << '(' << p.first << ',' << p.second << ')'); }
#define PB_DS_CLASS_T_DEC \
template<typename Key, typename Eq_Fn, typename Const_Key_Reference>
#define PB_DS_CLASS_C_DEC \
debug_map_base<Key, Eq_Fn, Const_Key_Reference>
/// Debug base class.
template<typename Key, typename Eq_Fn, typename Const_Key_Reference>
class debug_map_base
{
private:
typedef Const_Key_Reference key_const_reference;
typedef std::_GLIBCXX_STD_C::list<Key> key_repository;
typedef typename key_repository::size_type size_type;
typedef typename key_repository::iterator iterator;
typedef typename key_repository::const_iterator const_iterator;
protected:
debug_map_base();
debug_map_base(const PB_DS_CLASS_C_DEC&);
~debug_map_base();
inline void
insert_new(key_const_reference);
inline void
erase_existing(key_const_reference);
void
clear();
inline void
check_key_exists(key_const_reference, const char*, int) const;
inline void
check_key_does_not_exist(key_const_reference, const char*, int) const;
inline void
check_size(size_type, const char*, int) const;
void
swap(PB_DS_CLASS_C_DEC&);
template<typename Cmp_Fn>
void
split(key_const_reference, Cmp_Fn, PB_DS_CLASS_C_DEC&);
void
join(PB_DS_CLASS_C_DEC&, bool with_cleanup = true);
private:
void
assert_valid(const char*, int) const;
const_iterator
find(key_const_reference) const;
iterator
find(key_const_reference);
key_repository m_keys;
Eq_Fn m_eq;
};
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
debug_map_base()
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
debug_map_base(const PB_DS_CLASS_C_DEC& other)
: m_keys(other.m_keys), m_eq(other.m_eq)
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
~debug_map_base()
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
insert_new(key_const_reference r_key)
{
PB_DS_ASSERT_VALID((*this))
if (find(r_key) != m_keys.end())
{
std::cerr << "insert_new key already present " << r_key << std::endl;
std::abort();
}
__try
{
m_keys.push_back(r_key);
}
__catch(...)
{
std::cerr << "insert_new " << r_key << std::endl;
std::abort();
}
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
erase_existing(key_const_reference r_key)
{
PB_DS_ASSERT_VALID((*this))
iterator it = find(r_key);
if (it == m_keys.end())
{
std::cerr << "erase_existing" << r_key << std::endl;
std::abort();
}
m_keys.erase(it);
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
clear()
{
PB_DS_ASSERT_VALID((*this))
m_keys.clear();
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
check_key_exists(key_const_reference r_key,
const char* __file, int __line) const
{
assert_valid(__file, __line);
if (find(r_key) == m_keys.end())
{
std::cerr << __file << ':' << __line << ": check_key_exists "
<< r_key << std::endl;
std::abort();
}
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
check_key_does_not_exist(key_const_reference r_key,
const char* __file, int __line) const
{
assert_valid(__file, __line);
if (find(r_key) != m_keys.end())
{
using std::cerr;
using std::endl;
cerr << __file << ':' << __line << ": check_key_does_not_exist "
<< r_key << endl;
std::abort();
}
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
check_size(size_type size, const char* __file, int __line) const
{
assert_valid(__file, __line);
const size_type keys_size = m_keys.size();
if (size != keys_size)
{
std::cerr << __file << ':' << __line << ": check_size "
<< size << " != " << keys_size << std::endl;
std::abort();
}
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
m_keys.swap(other.m_keys);
std::swap(m_eq, other.m_eq);
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
find(key_const_reference r_key) const
{
PB_DS_ASSERT_VALID((*this))
typedef const_iterator iterator_type;
for (iterator_type it = m_keys.begin(); it != m_keys.end(); ++it)
if (m_eq(*it, r_key))
return it;
return m_keys.end();
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
find(key_const_reference r_key)
{
PB_DS_ASSERT_VALID((*this))
iterator it = m_keys.begin();
while (it != m_keys.end())
{
if (m_eq(*it, r_key))
return it;
++it;
}
return it;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_valid(const char* __file, int __line) const
{
const_iterator prime_it = m_keys.begin();
while (prime_it != m_keys.end())
{
const_iterator sec_it = prime_it;
++sec_it;
while (sec_it != m_keys.end())
{
PB_DS_DEBUG_VERIFY(!m_eq(*sec_it, *prime_it));
PB_DS_DEBUG_VERIFY(!m_eq(*prime_it, *sec_it));
++sec_it;
}
++prime_it;
}
}
PB_DS_CLASS_T_DEC
template<typename Cmp_Fn>
void
PB_DS_CLASS_C_DEC::
split(key_const_reference r_key, Cmp_Fn cmp_fn, PB_DS_CLASS_C_DEC& other)
{
other.clear();
iterator it = m_keys.begin();
while (it != m_keys.end())
if (cmp_fn(r_key, *it))
{
other.insert_new(*it);
it = m_keys.erase(it);
}
else
++it;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
join(PB_DS_CLASS_C_DEC& other, bool with_cleanup)
{
iterator it = other.m_keys.begin();
while (it != other.m_keys.end())
{
insert_new(*it);
if (with_cleanup)
it = other.m_keys.erase(it);
else
++it;
}
_GLIBCXX_DEBUG_ASSERT(!with_cleanup || other.m_keys.empty());
}
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
} // namespace detail
} // namespace __gnu_pbds
#endif
#endif
c++/8/ext/pb_ds/detail/rb_tree_map_/info_fn_imps.hpp 0000644 00000003461 15201526705 0016220 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file rb_tree_map_/info_fn_imps.hpp
* Contains an implementation for rb_tree_.
*/
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
is_effectively_black(const node_pointer p_nd)
{ return (p_nd == 0 || !p_nd->m_red); }
c++/8/ext/pb_ds/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp 0000644 00000005337 15201526705 0022317 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file rb_tree_map_/constructors_destructor_fn_imps.hpp
* Contains an implementation for rb_tree_.
*/
PB_DS_CLASS_T_DEC
template<typename It>
void
PB_DS_CLASS_C_DEC::
copy_from_range(It first_it, It last_it)
{
while (first_it != last_it)
insert(*(first_it++));
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_RB_TREE_NAME()
{
initialize();
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_RB_TREE_NAME(const Cmp_Fn& r_cmp_fn) :
base_type(r_cmp_fn)
{
initialize();
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_RB_TREE_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_update) :
base_type(r_cmp_fn, r_node_update)
{
initialize();
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_RB_TREE_NAME(const PB_DS_CLASS_C_DEC& other) :
base_type(other)
{
initialize();
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
base_type::swap(other);
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
initialize()
{ base_type::m_p_head->m_red = true; }
c++/8/ext/pb_ds/detail/rb_tree_map_/debug_fn_imps.hpp 0000644 00000005311 15201526705 0016347 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file rb_tree_map_/debug_fn_imps.hpp
* Contains an implementation for rb_tree_.
*/
#ifdef _GLIBCXX_DEBUG
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
assert_node_consistent(const node_pointer p_nd, const char* __file,
int __line) const
{
if (p_nd == 0)
return 1;
const size_type l_height =
assert_node_consistent(p_nd->m_p_left, __file, __line);
const size_type r_height =
assert_node_consistent(p_nd->m_p_right, __file, __line);
if (p_nd->m_red)
{
PB_DS_DEBUG_VERIFY(is_effectively_black(p_nd->m_p_left));
PB_DS_DEBUG_VERIFY(is_effectively_black(p_nd->m_p_right));
}
PB_DS_DEBUG_VERIFY(l_height == r_height);
return (p_nd->m_red ? 0 : 1) + l_height;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_valid(const char* __file, int __line) const
{
base_type::assert_valid(__file, __line);
const node_pointer p_head = base_type::m_p_head;
PB_DS_DEBUG_VERIFY(p_head->m_red);
if (p_head->m_p_parent != 0)
{
PB_DS_DEBUG_VERIFY(!p_head->m_p_parent->m_red);
assert_node_consistent(p_head->m_p_parent, __file, __line);
}
}
#endif
c++/8/ext/pb_ds/detail/rb_tree_map_/find_fn_imps.hpp 0000644 00000003247 15201526705 0016207 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file rb_tree_map_/find_fn_imps.hpp
* Contains an implementation for rb_tree_.
*/
c++/8/ext/pb_ds/detail/rb_tree_map_/node.hpp 0000644 00000007436 15201526705 0014505 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file rb_tree_map_/node.hpp
* Contains an implementation for rb_tree_.
*/
#ifndef PB_DS_RB_TREE_NODE_HPP
#define PB_DS_RB_TREE_NODE_HPP
#include <ext/pb_ds/detail/branch_policy/null_node_metadata.hpp>
namespace __gnu_pbds
{
namespace detail
{
/// Node for Red-Black trees.
template<typename Value_Type, class Metadata, typename _Alloc>
struct rb_tree_node_
{
public:
typedef Value_Type value_type;
typedef Metadata metadata_type;
typedef
typename _Alloc::template rebind<
rb_tree_node_<
Value_Type,
Metadata,
_Alloc> >::other::pointer
node_pointer;
typedef
typename _Alloc::template rebind<
metadata_type>::other::reference
metadata_reference;
typedef
typename _Alloc::template rebind<
metadata_type>::other::const_reference
metadata_const_reference;
bool
special() const
{ return m_red; }
metadata_const_reference
get_metadata() const
{ return m_metadata; }
metadata_reference
get_metadata()
{ return m_metadata; }
#ifdef PB_DS_BIN_SEARCH_TREE_TRACE_
void
trace() const
{
std::cout << PB_DS_V2F(m_value) <<(m_red? " <r> " : " <b> ")
<< "(" << m_metadata << ")";
}
#endif
node_pointer m_p_left;
node_pointer m_p_right;
node_pointer m_p_parent;
value_type m_value;
bool m_red;
metadata_type m_metadata;
};
template<typename Value_Type, typename _Alloc>
struct rb_tree_node_<Value_Type, null_type, _Alloc>
{
public:
typedef Value_Type value_type;
typedef null_type metadata_type;
typedef
typename _Alloc::template rebind<
rb_tree_node_<
Value_Type,
null_type,
_Alloc> >::other::pointer
node_pointer;
bool
special() const
{ return m_red; }
#ifdef PB_DS_BIN_SEARCH_TREE_TRACE_
void
trace() const
{ std::cout << PB_DS_V2F(m_value) <<(m_red? " <r> " : " <b> "); }
#endif
node_pointer m_p_left;
node_pointer m_p_right;
node_pointer m_p_parent;
value_type m_value;
bool m_red;
};
} // namespace detail
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp 0000644 00000017432 15201526705 0015336 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file rb_tree_map_/rb_tree_.hpp
* Contains an implementation for Red Black trees.
*/
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <utility>
#include <vector>
#include <assert.h>
#include <debug/debug.h>
namespace __gnu_pbds
{
namespace detail
{
#define PB_DS_CLASS_T_DEC \
template<typename Key, typename Mapped, typename Cmp_Fn, \
typename Node_And_It_Traits, typename _Alloc>
#ifdef PB_DS_DATA_TRUE_INDICATOR
# define PB_DS_RB_TREE_NAME rb_tree_map
# define PB_DS_RB_TREE_BASE_NAME bin_search_tree_map
#endif
#ifdef PB_DS_DATA_FALSE_INDICATOR
# define PB_DS_RB_TREE_NAME rb_tree_set
# define PB_DS_RB_TREE_BASE_NAME bin_search_tree_set
#endif
#define PB_DS_CLASS_C_DEC \
PB_DS_RB_TREE_NAME<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc>
#define PB_DS_RB_TREE_BASE \
PB_DS_RB_TREE_BASE_NAME<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc>
/**
* @brief Red-Black tree.
* @ingroup branch-detail
*
* This implementation uses an idea from the SGI STL (using a
* @a header node which is needed for efficient iteration).
*/
template<typename Key,
typename Mapped,
typename Cmp_Fn,
typename Node_And_It_Traits,
typename _Alloc>
class PB_DS_RB_TREE_NAME : public PB_DS_RB_TREE_BASE
{
private:
typedef PB_DS_RB_TREE_BASE base_type;
typedef typename base_type::node_pointer node_pointer;
public:
typedef rb_tree_tag container_category;
typedef Cmp_Fn cmp_fn;
typedef _Alloc allocator_type;
typedef typename _Alloc::size_type size_type;
typedef typename _Alloc::difference_type difference_type;
typedef typename base_type::key_type key_type;
typedef typename base_type::key_pointer key_pointer;
typedef typename base_type::key_const_pointer key_const_pointer;
typedef typename base_type::key_reference key_reference;
typedef typename base_type::key_const_reference key_const_reference;
typedef typename base_type::mapped_type mapped_type;
typedef typename base_type::mapped_pointer mapped_pointer;
typedef typename base_type::mapped_const_pointer mapped_const_pointer;
typedef typename base_type::mapped_reference mapped_reference;
typedef typename base_type::mapped_const_reference mapped_const_reference;
typedef typename base_type::value_type value_type;
typedef typename base_type::pointer pointer;
typedef typename base_type::const_pointer const_pointer;
typedef typename base_type::reference reference;
typedef typename base_type::const_reference const_reference;
typedef typename base_type::point_iterator point_iterator;
typedef typename base_type::const_iterator point_const_iterator;
typedef typename base_type::iterator iterator;
typedef typename base_type::const_iterator const_iterator;
typedef typename base_type::reverse_iterator reverse_iterator;
typedef typename base_type::const_reverse_iterator const_reverse_iterator;
typedef typename base_type::node_update node_update;
PB_DS_RB_TREE_NAME();
PB_DS_RB_TREE_NAME(const Cmp_Fn&);
PB_DS_RB_TREE_NAME(const Cmp_Fn&, const node_update&);
PB_DS_RB_TREE_NAME(const PB_DS_CLASS_C_DEC&);
void
swap(PB_DS_CLASS_C_DEC&);
template<typename It>
void
copy_from_range(It, It);
inline std::pair<point_iterator, bool>
insert(const_reference);
inline mapped_reference
operator[](key_const_reference r_key)
{
#ifdef PB_DS_DATA_TRUE_INDICATOR
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
std::pair<point_iterator, bool> ins_pair =
base_type::insert_leaf(value_type(r_key, mapped_type()));
if (ins_pair.second == true)
{
ins_pair.first.m_p_nd->m_red = true;
_GLIBCXX_DEBUG_ONLY(this->structure_only_assert_valid(__FILE__, __LINE__);)
insert_fixup(ins_pair.first.m_p_nd);
}
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
return ins_pair.first.m_p_nd->m_value.second;
#else
insert(r_key);
return base_type::s_null_type;
#endif
}
inline bool
erase(key_const_reference);
inline iterator
erase(iterator);
inline reverse_iterator
erase(reverse_iterator);
template<typename Pred>
inline size_type
erase_if(Pred);
void
join(PB_DS_CLASS_C_DEC&);
void
split(key_const_reference, PB_DS_CLASS_C_DEC&);
private:
#ifdef _GLIBCXX_DEBUG
void
assert_valid(const char*, int) const;
size_type
assert_node_consistent(const node_pointer, const char*, int) const;
#endif
inline static bool
is_effectively_black(const node_pointer);
void
initialize();
void
insert_fixup(node_pointer);
void
erase_node(node_pointer);
void
remove_node(node_pointer);
void
remove_fixup(node_pointer, node_pointer);
void
split_imp(node_pointer, PB_DS_CLASS_C_DEC&);
inline node_pointer
split_min();
std::pair<node_pointer, node_pointer>
split_min_imp();
void
join_imp(node_pointer, node_pointer);
std::pair<node_pointer, node_pointer>
find_join_pos_right(node_pointer, size_type, size_type);
std::pair<node_pointer, node_pointer>
find_join_pos_left(node_pointer, size_type, size_type);
inline size_type
black_height(node_pointer);
void
split_at_node(node_pointer, PB_DS_CLASS_C_DEC&);
};
#define PB_DS_STRUCT_ONLY_ASSERT_VALID(X) \
_GLIBCXX_DEBUG_ONLY(X.structure_only_assert_valid(__FILE__, __LINE__);)
#include <ext/pb_ds/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/rb_tree_map_/insert_fn_imps.hpp>
#include <ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp>
#include <ext/pb_ds/detail/rb_tree_map_/debug_fn_imps.hpp>
#include <ext/pb_ds/detail/rb_tree_map_/split_join_fn_imps.hpp>
#include <ext/pb_ds/detail/rb_tree_map_/info_fn_imps.hpp>
#undef PB_DS_STRUCT_ONLY_ASSERT_VALID
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_RB_TREE_NAME
#undef PB_DS_RB_TREE_BASE_NAME
#undef PB_DS_RB_TREE_BASE
} // namespace detail
} // namespace __gnu_pbds
c++/8/ext/pb_ds/detail/rb_tree_map_/split_join_fn_imps.hpp 0000644 00000017265 15201526705 0017446 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file rb_tree_map_/split_join_fn_imps.hpp
* Contains an implementation for rb_tree_.
*/
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
join(PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
if (base_type::join_prep(other) == false)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
return;
}
const node_pointer p_x = other.split_min();
join_imp(p_x, other.m_p_head->m_p_parent);
base_type::join_finish(other);
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
join_imp(node_pointer p_x, node_pointer p_r)
{
_GLIBCXX_DEBUG_ASSERT(p_x != 0);
if (p_r != 0)
p_r->m_red = false;
const size_type h = black_height(base_type::m_p_head->m_p_parent);
const size_type other_h = black_height(p_r);
node_pointer p_x_l;
node_pointer p_x_r;
std::pair<node_pointer, node_pointer> join_pos;
const bool right_join = h >= other_h;
if (right_join)
{
join_pos = find_join_pos_right(base_type::m_p_head->m_p_parent,
h, other_h);
p_x_l = join_pos.first;
p_x_r = p_r;
}
else
{
p_x_l = base_type::m_p_head->m_p_parent;
base_type::m_p_head->m_p_parent = p_r;
if (p_r != 0)
p_r->m_p_parent = base_type::m_p_head;
join_pos = find_join_pos_left(base_type::m_p_head->m_p_parent,
h, other_h);
p_x_r = join_pos.first;
}
node_pointer p_parent = join_pos.second;
if (p_parent == base_type::m_p_head)
{
base_type::m_p_head->m_p_parent = p_x;
p_x->m_p_parent = base_type::m_p_head;
}
else
{
p_x->m_p_parent = p_parent;
if (right_join)
p_x->m_p_parent->m_p_right = p_x;
else
p_x->m_p_parent->m_p_left = p_x;
}
p_x->m_p_left = p_x_l;
if (p_x_l != 0)
p_x_l->m_p_parent = p_x;
p_x->m_p_right = p_x_r;
if (p_x_r != 0)
p_x_r->m_p_parent = p_x;
p_x->m_red = true;
base_type::initialize_min_max();
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
base_type::update_to_top(p_x, (node_update* )this);
insert_fixup(p_x);
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
split_min()
{
node_pointer p_min = base_type::m_p_head->m_p_left;
#ifdef _GLIBCXX_DEBUG
const node_pointer p_head = base_type::m_p_head;
_GLIBCXX_DEBUG_ASSERT(p_min != p_head);
#endif
remove_node(p_min);
return p_min;
}
PB_DS_CLASS_T_DEC
std::pair<
typename PB_DS_CLASS_C_DEC::node_pointer,
typename PB_DS_CLASS_C_DEC::node_pointer>
PB_DS_CLASS_C_DEC::
find_join_pos_right(node_pointer p_l, size_type h_l, size_type h_r)
{
_GLIBCXX_DEBUG_ASSERT(h_l >= h_r);
if (base_type::m_p_head->m_p_parent == 0)
return (std::make_pair((node_pointer)0, base_type::m_p_head));
node_pointer p_l_parent = base_type::m_p_head;
while (h_l > h_r)
{
if (p_l->m_red == false)
{
_GLIBCXX_DEBUG_ASSERT(h_l > 0);
--h_l;
}
p_l_parent = p_l;
p_l = p_l->m_p_right;
}
if (!is_effectively_black(p_l))
{
p_l_parent = p_l;
p_l = p_l->m_p_right;
}
_GLIBCXX_DEBUG_ASSERT(is_effectively_black(p_l));
_GLIBCXX_DEBUG_ASSERT(black_height(p_l) == h_r);
_GLIBCXX_DEBUG_ASSERT(p_l == 0 || p_l->m_p_parent == p_l_parent);
return std::make_pair(p_l, p_l_parent);
}
PB_DS_CLASS_T_DEC
std::pair<
typename PB_DS_CLASS_C_DEC::node_pointer,
typename PB_DS_CLASS_C_DEC::node_pointer>
PB_DS_CLASS_C_DEC::
find_join_pos_left(node_pointer p_r, size_type h_l, size_type h_r)
{
_GLIBCXX_DEBUG_ASSERT(h_r > h_l);
if (base_type::m_p_head->m_p_parent == 0)
return (std::make_pair((node_pointer)0,
base_type::m_p_head));
node_pointer p_r_parent = base_type::m_p_head;
while (h_r > h_l)
{
if (p_r->m_red == false)
{
_GLIBCXX_DEBUG_ASSERT(h_r > 0);
--h_r;
}
p_r_parent = p_r;
p_r = p_r->m_p_left;
}
if (!is_effectively_black(p_r))
{
p_r_parent = p_r;
p_r = p_r->m_p_left;
}
_GLIBCXX_DEBUG_ASSERT(is_effectively_black(p_r));
_GLIBCXX_DEBUG_ASSERT(black_height(p_r) == h_l);
_GLIBCXX_DEBUG_ASSERT(p_r == 0 || p_r->m_p_parent == p_r_parent);
return std::make_pair(p_r, p_r_parent);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
black_height(node_pointer p_nd)
{
size_type h = 1;
while (p_nd != 0)
{
if (p_nd->m_red == false)
++h;
p_nd = p_nd->m_p_left;
}
return h;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
split(key_const_reference r_key, PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
if (base_type::split_prep(r_key, other) == false)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
return;
}
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
PB_DS_STRUCT_ONLY_ASSERT_VALID(other)
node_pointer p_nd = this->upper_bound(r_key).m_p_nd;
do
{
node_pointer p_next_nd = p_nd->m_p_parent;
if (Cmp_Fn::operator()(r_key, PB_DS_V2F(p_nd->m_value)))
split_at_node(p_nd, other);
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
PB_DS_STRUCT_ONLY_ASSERT_VALID(other)
p_nd = p_next_nd;
}
while (p_nd != base_type::m_p_head);
base_type::split_finish(other);
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
split_at_node(node_pointer p_nd, PB_DS_CLASS_C_DEC& other)
{
_GLIBCXX_DEBUG_ASSERT(p_nd != 0);
node_pointer p_l = p_nd->m_p_left;
node_pointer p_r = p_nd->m_p_right;
node_pointer p_parent = p_nd->m_p_parent;
if (p_parent == base_type::m_p_head)
{
base_type::m_p_head->m_p_parent = p_l;
if (p_l != 0)
{
p_l->m_p_parent = base_type::m_p_head;
p_l->m_red = false;
}
}
else
{
if (p_parent->m_p_left == p_nd)
p_parent->m_p_left = p_l;
else
p_parent->m_p_right = p_l;
if (p_l != 0)
p_l->m_p_parent = p_parent;
this->update_to_top(p_parent, (node_update* )this);
if (!p_nd->m_red)
remove_fixup(p_l, p_parent);
}
base_type::initialize_min_max();
other.join_imp(p_nd, p_r);
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
PB_DS_STRUCT_ONLY_ASSERT_VALID(other)
}
c++/8/ext/pb_ds/detail/rb_tree_map_/insert_fn_imps.hpp 0000644 00000007433 15201526705 0016574 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file rb_tree_map_/insert_fn_imps.hpp
* Contains an implementation for rb_tree_.
*/
PB_DS_CLASS_T_DEC
inline std::pair<typename PB_DS_CLASS_C_DEC::point_iterator, bool>
PB_DS_CLASS_C_DEC::
insert(const_reference r_value)
{
PB_DS_ASSERT_VALID((*this))
std::pair<point_iterator, bool> ins_pair = base_type::insert_leaf(r_value);
if (ins_pair.second == true)
{
ins_pair.first.m_p_nd->m_red = true;
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
insert_fixup(ins_pair.first.m_p_nd);
}
PB_DS_ASSERT_VALID((*this))
return ins_pair;
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
insert_fixup(node_pointer p_nd)
{
_GLIBCXX_DEBUG_ASSERT(p_nd->m_red == true);
while (p_nd != base_type::m_p_head->m_p_parent && p_nd->m_p_parent->m_red)
{
if (p_nd->m_p_parent == p_nd->m_p_parent->m_p_parent->m_p_left)
{
node_pointer p_y = p_nd->m_p_parent->m_p_parent->m_p_right;
if (p_y != 0 && p_y->m_red)
{
p_nd->m_p_parent->m_red = false;
p_y->m_red = false;
p_nd->m_p_parent->m_p_parent->m_red = true;
p_nd = p_nd->m_p_parent->m_p_parent;
}
else
{
if (p_nd == p_nd->m_p_parent->m_p_right)
{
p_nd = p_nd->m_p_parent;
base_type::rotate_left(p_nd);
}
p_nd->m_p_parent->m_red = false;
p_nd->m_p_parent->m_p_parent->m_red = true;
base_type::rotate_right(p_nd->m_p_parent->m_p_parent);
}
}
else
{
node_pointer p_y = p_nd->m_p_parent->m_p_parent->m_p_left;
if (p_y != 0 && p_y->m_red)
{
p_nd->m_p_parent->m_red = false;
p_y->m_red = false;
p_nd->m_p_parent->m_p_parent->m_red = true;
p_nd = p_nd->m_p_parent->m_p_parent;
}
else
{
if (p_nd == p_nd->m_p_parent->m_p_left)
{
p_nd = p_nd->m_p_parent;
base_type::rotate_right(p_nd);
}
p_nd->m_p_parent->m_red = false;
p_nd->m_p_parent->m_p_parent->m_red = true;
base_type::rotate_left(p_nd->m_p_parent->m_p_parent);
}
}
}
base_type::update_to_top(p_nd, (node_update* )this);
base_type::m_p_head->m_p_parent->m_red = false;
}
c++/8/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp 0000644 00000015613 15201526705 0016366 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file rb_tree_map_/erase_fn_imps.hpp
* Contains an implementation for rb_tree_.
*/
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
erase(key_const_reference r_key)
{
point_iterator it = this->find(r_key);
if (it == base_type::end())
return false;
erase(it);
return true;
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
erase(iterator it)
{
PB_DS_ASSERT_VALID((*this))
if (it == base_type::end())
return it;
iterator ret_it = it;
++ret_it;
erase_node(it.m_p_nd);
PB_DS_ASSERT_VALID((*this))
return ret_it;
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::reverse_iterator
PB_DS_CLASS_C_DEC::
erase(reverse_iterator it)
{
PB_DS_ASSERT_VALID((*this))
if (it.m_p_nd == base_type::m_p_head)
return it;
reverse_iterator ret_it = it;
++ret_it;
erase_node(it.m_p_nd);
PB_DS_ASSERT_VALID((*this))
return ret_it;
}
PB_DS_CLASS_T_DEC
template<typename Pred>
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
erase_if(Pred pred)
{
PB_DS_ASSERT_VALID((*this))
size_type num_ersd = 0;
iterator it = base_type::begin();
while (it != base_type::end())
{
if (pred(*it))
{
++num_ersd;
it = erase(it);
}
else
++it;
}
PB_DS_ASSERT_VALID((*this))
return num_ersd;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
erase_node(node_pointer p_nd)
{
remove_node(p_nd);
base_type::actual_erase_node(p_nd);
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
remove_node(node_pointer p_z)
{
this->update_min_max_for_erased_node(p_z);
node_pointer p_y = p_z;
node_pointer p_x = 0;
node_pointer p_new_x_parent = 0;
if (p_y->m_p_left == 0)
p_x = p_y->m_p_right;
else if (p_y->m_p_right == 0)
p_x = p_y->m_p_left;
else
{
p_y = p_y->m_p_right;
while (p_y->m_p_left != 0)
p_y = p_y->m_p_left;
p_x = p_y->m_p_right;
}
if (p_y == p_z)
{
p_new_x_parent = p_y->m_p_parent;
if (p_x != 0)
p_x->m_p_parent = p_y->m_p_parent;
if (base_type::m_p_head->m_p_parent == p_z)
base_type::m_p_head->m_p_parent = p_x;
else if (p_z->m_p_parent->m_p_left == p_z)
{
p_y->m_p_left = p_z->m_p_parent;
p_z->m_p_parent->m_p_left = p_x;
}
else
{
p_y->m_p_left = 0;
p_z->m_p_parent->m_p_right = p_x;
}
}
else
{
p_z->m_p_left->m_p_parent = p_y;
p_y->m_p_left = p_z->m_p_left;
if (p_y != p_z->m_p_right)
{
p_new_x_parent = p_y->m_p_parent;
if (p_x != 0)
p_x->m_p_parent = p_y->m_p_parent;
p_y->m_p_parent->m_p_left = p_x;
p_y->m_p_right = p_z->m_p_right;
p_z->m_p_right->m_p_parent = p_y;
}
else
p_new_x_parent = p_y;
if (base_type::m_p_head->m_p_parent == p_z)
base_type::m_p_head->m_p_parent = p_y;
else if (p_z->m_p_parent->m_p_left == p_z)
p_z->m_p_parent->m_p_left = p_y;
else
p_z->m_p_parent->m_p_right = p_y;
p_y->m_p_parent = p_z->m_p_parent;
std::swap(p_y->m_red, p_z->m_red);
p_y = p_z;
}
this->update_to_top(p_new_x_parent, (node_update* )this);
if (p_y->m_red)
return;
remove_fixup(p_x, p_new_x_parent);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
remove_fixup(node_pointer p_x, node_pointer p_new_x_parent)
{
_GLIBCXX_DEBUG_ASSERT(p_x == 0 || p_x->m_p_parent == p_new_x_parent);
while (p_x != base_type::m_p_head->m_p_parent && is_effectively_black(p_x))
if (p_x == p_new_x_parent->m_p_left)
{
node_pointer p_w = p_new_x_parent->m_p_right;
if (p_w->m_red)
{
p_w->m_red = false;
p_new_x_parent->m_red = true;
base_type::rotate_left(p_new_x_parent);
p_w = p_new_x_parent->m_p_right;
}
if (is_effectively_black(p_w->m_p_left)
&& is_effectively_black(p_w->m_p_right))
{
p_w->m_red = true;
p_x = p_new_x_parent;
p_new_x_parent = p_new_x_parent->m_p_parent;
}
else
{
if (is_effectively_black(p_w->m_p_right))
{
if (p_w->m_p_left != 0)
p_w->m_p_left->m_red = false;
p_w->m_red = true;
base_type::rotate_right(p_w);
p_w = p_new_x_parent->m_p_right;
}
p_w->m_red = p_new_x_parent->m_red;
p_new_x_parent->m_red = false;
if (p_w->m_p_right != 0)
p_w->m_p_right->m_red = false;
base_type::rotate_left(p_new_x_parent);
this->update_to_top(p_new_x_parent, (node_update* )this);
break;
}
}
else
{
node_pointer p_w = p_new_x_parent->m_p_left;
if (p_w->m_red == true)
{
p_w->m_red = false;
p_new_x_parent->m_red = true;
base_type::rotate_right(p_new_x_parent);
p_w = p_new_x_parent->m_p_left;
}
if (is_effectively_black(p_w->m_p_right)
&& is_effectively_black(p_w->m_p_left))
{
p_w->m_red = true;
p_x = p_new_x_parent;
p_new_x_parent = p_new_x_parent->m_p_parent;
}
else
{
if (is_effectively_black(p_w->m_p_left))
{
if (p_w->m_p_right != 0)
p_w->m_p_right->m_red = false;
p_w->m_red = true;
base_type::rotate_left(p_w);
p_w = p_new_x_parent->m_p_left;
}
p_w->m_red = p_new_x_parent->m_red;
p_new_x_parent->m_red = false;
if (p_w->m_p_left != 0)
p_w->m_p_left->m_red = false;
base_type::rotate_right(p_new_x_parent);
this->update_to_top(p_new_x_parent, (node_update* )this);
break;
}
}
if (p_x != 0)
p_x->m_red = false;
}
c++/8/ext/pb_ds/detail/rb_tree_map_/traits.hpp 0000644 00000006323 15201526705 0015060 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file rb_tree_map_/traits.hpp
* Contains an implementation for rb_tree_.
*/
#ifndef PB_DS_RB_TREE_NODE_AND_IT_TRAITS_HPP
#define PB_DS_RB_TREE_NODE_AND_IT_TRAITS_HPP
#include <ext/pb_ds/detail/rb_tree_map_/node.hpp>
namespace __gnu_pbds
{
namespace detail
{
/// Specialization.
/// @ingroup traits
template<typename Key,
typename Mapped,
typename Cmp_Fn,
template<typename Node_CItr,
typename Node_Itr,
typename Cmp_Fn_,
typename _Alloc_>
class Node_Update,
typename _Alloc>
struct tree_traits<Key, Mapped, Cmp_Fn, Node_Update, rb_tree_tag,_Alloc>
: public bin_search_tree_traits<
Key,
Mapped,
Cmp_Fn,
Node_Update,
rb_tree_node_<
typename types_traits<Key, Mapped, _Alloc, false>::value_type,
typename tree_node_metadata_dispatch<Key, Mapped, Cmp_Fn, Node_Update,
_Alloc>::type,
_Alloc>,
_Alloc>
{ };
/// Specialization.
/// @ingroup traits
template<typename Key,
typename Cmp_Fn,
template<typename Node_CItr,
typename Node_Itr,
typename Cmp_Fn_,
typename _Alloc_>
class Node_Update,
typename _Alloc>
struct tree_traits<Key, null_type, Cmp_Fn, Node_Update, rb_tree_tag,_Alloc>
: public bin_search_tree_traits<
Key,
null_type,
Cmp_Fn,
Node_Update,
rb_tree_node_<
typename types_traits<Key, null_type, _Alloc, false>::value_type,
typename tree_node_metadata_dispatch<Key, null_type, Cmp_Fn, Node_Update,
_Alloc>::type,
_Alloc>,
_Alloc>
{ };
} // namespace detail
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/detail/binomial_heap_/binomial_heap_.hpp 0000644 00000007522 15201526705 0017012 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file binomial_heap_.hpp
* Contains an implementation class for a binomial heap.
*/
/*
* Binomial heap.
* Vuillemin J is the mastah.
* Modified from CLRS.
*/
#include <debug/debug.h>
#include <ext/pb_ds/detail/cond_dealtor.hpp>
#include <ext/pb_ds/detail/type_utils.hpp>
#include <ext/pb_ds/detail/binomial_heap_base_/binomial_heap_base_.hpp>
namespace __gnu_pbds
{
namespace detail
{
#define PB_DS_CLASS_T_DEC \
template<typename Value_Type, typename Cmp_Fn, typename _Alloc>
#define PB_DS_CLASS_C_DEC \
binomial_heap<Value_Type, Cmp_Fn, _Alloc>
/**
* Binomial heap.
*
* @ingroup heap-detail
*/
template<typename Value_Type, typename Cmp_Fn, typename _Alloc>
class binomial_heap
: public binomial_heap_base<Value_Type, Cmp_Fn, _Alloc>
{
private:
typedef binomial_heap_base<Value_Type, Cmp_Fn, _Alloc> base_type;
typedef typename base_type::node_pointer node_pointer;
typedef typename base_type::node_const_pointer node_const_pointer;
public:
typedef Value_Type value_type;
typedef typename _Alloc::size_type size_type;
typedef typename _Alloc::difference_type difference_type;
typedef typename base_type::pointer pointer;
typedef typename base_type::const_pointer const_pointer;
typedef typename base_type::reference reference;
typedef typename base_type::const_reference const_reference;
typedef typename base_type::point_const_iterator point_const_iterator;
typedef typename base_type::point_iterator point_iterator;
typedef typename base_type::const_iterator const_iterator;
typedef typename base_type::iterator iterator;
typedef typename base_type::cmp_fn cmp_fn;
typedef typename base_type::allocator_type allocator_type;
binomial_heap();
binomial_heap(const Cmp_Fn&);
binomial_heap(const binomial_heap&);
~binomial_heap();
protected:
#ifdef _GLIBCXX_DEBUG
void
assert_valid(const char*, int) const;
#endif
};
#include <ext/pb_ds/detail/binomial_heap_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/binomial_heap_/debug_fn_imps.hpp>
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC
} // namespace detail
} // namespace __gnu_pbds
c++/8/ext/pb_ds/detail/binomial_heap_/constructors_destructor_fn_imps.hpp 0000644 00000004147 15201526705 0022625 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file detail/binomial_heap_/constructors_destructor_fn_imps.hpp
* Contains an implementation for binomial_heap_.
*/
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
binomial_heap()
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
binomial_heap(const Cmp_Fn& r_cmp_fn)
: base_type(r_cmp_fn)
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
binomial_heap(const PB_DS_CLASS_C_DEC& other)
: base_type(other)
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
~binomial_heap() { }
c++/8/ext/pb_ds/detail/binomial_heap_/debug_fn_imps.hpp 0000644 00000003551 15201526705 0016663 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file detail/binomial_heap_/debug_fn_imps.hpp
* Contains an implementation for binomial_heap_.
*/
#ifdef _GLIBCXX_DEBUG
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_valid(const char* __file, int __line) const
{ base_type::assert_valid(true, __file, __line); }
#endif
c++/8/ext/pb_ds/detail/binomial_heap_base_/constructors_destructor_fn_imps.hpp 0000644 00000005200 15201526705 0023606 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file binomial_heap_base_/constructors_destructor_fn_imps.hpp
* Contains an implementation class for a base of binomial heaps.
*/
PB_DS_CLASS_T_DEC
template<typename It>
void
PB_DS_CLASS_C_DEC::
copy_from_range(It first_it, It last_it)
{
while (first_it != last_it)
push(*(first_it++));
PB_DS_ASSERT_VALID_COND((*this),false)
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
binomial_heap_base() : m_p_max(0)
{
PB_DS_ASSERT_VALID_COND((*this),false)
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
binomial_heap_base(const Cmp_Fn& r_cmp_fn)
: base_type(r_cmp_fn), m_p_max(0)
{ PB_DS_ASSERT_VALID_COND((*this),false) }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
binomial_heap_base(const PB_DS_CLASS_C_DEC& other)
: base_type(other), m_p_max(0)
{ PB_DS_ASSERT_VALID_COND((*this),false) }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID_COND((*this),false)
base_type::swap(other);
std::swap(m_p_max, other.m_p_max);
PB_DS_ASSERT_VALID_COND((*this),false)
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
~binomial_heap_base()
{ }
c++/8/ext/pb_ds/detail/binomial_heap_base_/debug_fn_imps.hpp 0000644 00000006614 15201526705 0017660 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file binomial_heap_base_/debug_fn_imps.hpp
* Contains an implementation class for a base of binomial heaps.
*/
#ifdef _GLIBCXX_DEBUG
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_valid(bool strictly_binomial, const char* __file, int __line) const
{
base_type::assert_valid(__file, __line);
assert_node_consistent(base_type::m_p_root, strictly_binomial, true,
__file, __line);
assert_max(__file, __line);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_max(const char* __file, int __line) const
{
if (m_p_max == 0)
return;
PB_DS_DEBUG_VERIFY(base_type::parent(m_p_max) == 0);
for (const_iterator it = base_type::begin(); it != base_type::end(); ++it)
PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(m_p_max->m_value,
it.m_p_nd->m_value));
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_node_consistent(node_const_pointer p_nd, bool strictly_binomial,
bool increasing, const char* __file, int __line) const
{
PB_DS_DEBUG_VERIFY(increasing || strictly_binomial);
base_type::assert_node_consistent(p_nd, false, __file, __line);
if (p_nd == 0)
return;
PB_DS_DEBUG_VERIFY(p_nd->m_metadata == base_type::degree(p_nd));
PB_DS_DEBUG_VERIFY(base_type::size_under_node(p_nd) ==
static_cast<size_type>(1 << p_nd->m_metadata));
assert_node_consistent(p_nd->m_p_next_sibling, strictly_binomial, increasing,
__file, __line);
assert_node_consistent(p_nd->m_p_l_child, true, false, __file, __line);
if (p_nd->m_p_next_sibling != 0)
{
if (increasing)
{
if (strictly_binomial)
PB_DS_DEBUG_VERIFY(p_nd->m_metadata
< p_nd->m_p_next_sibling->m_metadata);
else
PB_DS_DEBUG_VERIFY(p_nd->m_metadata
<= p_nd->m_p_next_sibling->m_metadata);
}
else
PB_DS_DEBUG_VERIFY(p_nd->m_metadata
> p_nd->m_p_next_sibling->m_metadata);
}
}
#endif
c++/8/ext/pb_ds/detail/binomial_heap_base_/find_fn_imps.hpp 0000644 00000004451 15201526705 0017507 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file binomial_heap_base_/find_fn_imps.hpp
* Contains an implementation class for a base of binomial heaps.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_reference
PB_DS_CLASS_C_DEC::
top() const
{
PB_DS_ASSERT_VALID_COND((*this),false)
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
if (m_p_max == 0)
const_cast<PB_DS_CLASS_C_DEC* >(this)->find_max();
_GLIBCXX_DEBUG_ASSERT(m_p_max != 0);
return m_p_max->m_value;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
find_max()
{
node_pointer p_cur = base_type::m_p_root;
m_p_max = p_cur;
while (p_cur != 0)
{
if (Cmp_Fn::operator()(m_p_max->m_value, p_cur->m_value))
m_p_max = p_cur;
p_cur = p_cur->m_p_next_sibling;
}
}
c++/8/ext/pb_ds/detail/binomial_heap_base_/binomial_heap_base_.hpp 0000644 00000014072 15201526705 0020774 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file binomial_heap_base_/binomial_heap_base_.hpp
* Contains an implementation class for a base of binomial heaps.
*/
#ifndef PB_DS_BINOMIAL_HEAP_BASE_HPP
#define PB_DS_BINOMIAL_HEAP_BASE_HPP
/*
* Binomial heap base.
* Vuillemin J is the mastah.
* Modified from CLRS.
*/
#include <debug/debug.h>
#include <ext/pb_ds/detail/cond_dealtor.hpp>
#include <ext/pb_ds/detail/type_utils.hpp>
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp>
namespace __gnu_pbds
{
namespace detail
{
#define PB_DS_CLASS_T_DEC \
template<typename Value_Type, typename Cmp_Fn, typename _Alloc>
#define PB_DS_CLASS_C_DEC \
binomial_heap_base<Value_Type, Cmp_Fn, _Alloc>
#ifdef _GLIBCXX_DEBUG
#define PB_DS_B_HEAP_BASE \
left_child_next_sibling_heap<Value_Type, Cmp_Fn, \
typename _Alloc::size_type, _Alloc, false>
#else
#define PB_DS_B_HEAP_BASE \
left_child_next_sibling_heap<Value_Type, Cmp_Fn, \
typename _Alloc::size_type, _Alloc>
#endif
/// Base class for binomial heap.
template<typename Value_Type, typename Cmp_Fn, typename _Alloc>
class binomial_heap_base
: public PB_DS_B_HEAP_BASE
{
private:
typedef typename _Alloc::template rebind<Value_Type>::other __rebind_v;
typedef PB_DS_B_HEAP_BASE base_type;
protected:
typedef typename base_type::node node;
typedef typename base_type::node_pointer node_pointer;
typedef typename base_type::node_const_pointer node_const_pointer;
public:
typedef Value_Type value_type;
typedef Cmp_Fn cmp_fn;
typedef _Alloc allocator_type;
typedef typename _Alloc::size_type size_type;
typedef typename _Alloc::difference_type difference_type;
typedef typename __rebind_v::pointer pointer;
typedef typename __rebind_v::const_pointer const_pointer;
typedef typename __rebind_v::reference reference;
typedef typename __rebind_v::const_reference const_reference;
typedef typename base_type::point_const_iterator point_const_iterator;
typedef typename base_type::point_iterator point_iterator;
typedef typename base_type::const_iterator const_iterator;
typedef typename base_type::iterator iterator;
public:
inline point_iterator
push(const_reference);
void
modify(point_iterator, const_reference);
inline const_reference
top() const;
void
pop();
void
erase(point_iterator);
inline void
clear();
template<typename Pred>
size_type
erase_if(Pred);
template<typename Pred>
void
split(Pred, PB_DS_CLASS_C_DEC&);
void
join(PB_DS_CLASS_C_DEC&);
protected:
binomial_heap_base();
binomial_heap_base(const Cmp_Fn&);
binomial_heap_base(const PB_DS_CLASS_C_DEC&);
void
swap(PB_DS_CLASS_C_DEC&);
~binomial_heap_base();
template<typename It>
void
copy_from_range(It, It);
inline void
find_max();
#ifdef _GLIBCXX_DEBUG
void
assert_valid(bool, const char*, int) const;
void
assert_max(const char*, int) const;
#endif
private:
inline node_pointer
fix(node_pointer) const;
inline void
insert_node(node_pointer);
inline void
remove_parentless_node(node_pointer);
inline node_pointer
join(node_pointer, node_pointer) const;
#ifdef _GLIBCXX_DEBUG
void
assert_node_consistent(node_const_pointer, bool, bool,
const char*, int) const;
#endif
protected:
node_pointer m_p_max;
};
#define PB_DS_ASSERT_VALID_COND(X, _StrictlyBinomial) \
_GLIBCXX_DEBUG_ONLY(X.assert_valid(_StrictlyBinomial,__FILE__, __LINE__);)
#define PB_DS_ASSERT_BASE_NODE_CONSISTENT(_Node, _Bool) \
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(_Node, _Bool, \
__FILE__, __LINE__);)
#include <ext/pb_ds/detail/binomial_heap_base_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/binomial_heap_base_/debug_fn_imps.hpp>
#include <ext/pb_ds/detail/binomial_heap_base_/find_fn_imps.hpp>
#include <ext/pb_ds/detail/binomial_heap_base_/insert_fn_imps.hpp>
#include <ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp>
#include <ext/pb_ds/detail/binomial_heap_base_/split_join_fn_imps.hpp>
#undef PB_DS_ASSERT_BASE_NODE_CONSISTENT
#undef PB_DS_ASSERT_VALID_COND
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_B_HEAP_BASE
} // namespace detail
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/detail/binomial_heap_base_/split_join_fn_imps.hpp 0000644 00000012365 15201526705 0020744 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file binomial_heap_base_/split_join_fn_imps.hpp
* Contains an implementation class for a base of binomial heaps.
*/
PB_DS_CLASS_T_DEC
template<typename Pred>
void
PB_DS_CLASS_C_DEC::
split(Pred pred, PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID_COND((*this),true)
PB_DS_ASSERT_VALID_COND(other,true)
other.clear();
if (base_type::empty())
{
PB_DS_ASSERT_VALID_COND((*this),true)
PB_DS_ASSERT_VALID_COND(other,true)
return;
}
base_type::to_linked_list();
node_pointer p_out = base_type::prune(pred);
while (p_out != 0)
{
_GLIBCXX_DEBUG_ASSERT(base_type::m_size > 0);
--base_type::m_size;
++other.m_size;
node_pointer p_next = p_out->m_p_next_sibling;
p_out->m_p_l_child = p_out->m_p_prev_or_parent = 0;
p_out->m_metadata = 0;
p_out->m_p_next_sibling = other.m_p_root;
if (other.m_p_root != 0)
other.m_p_root->m_p_prev_or_parent = p_out;
other.m_p_root = p_out;
other.m_p_root = other.fix(other.m_p_root);
p_out = p_next;
}
PB_DS_ASSERT_VALID_COND(other,true)
node_pointer p_cur = base_type::m_p_root;
base_type::m_p_root = 0;
while (p_cur != 0)
{
node_pointer p_next = p_cur->m_p_next_sibling;
p_cur->m_p_l_child = p_cur->m_p_prev_or_parent = 0;
p_cur->m_metadata = 0;
p_cur->m_p_next_sibling = base_type::m_p_root;
if (base_type::m_p_root != 0)
base_type::m_p_root->m_p_prev_or_parent = p_cur;
base_type::m_p_root = p_cur;
base_type::m_p_root = fix(base_type::m_p_root);
p_cur = p_next;
}
m_p_max = 0;
PB_DS_ASSERT_VALID_COND((*this),true)
PB_DS_ASSERT_VALID_COND(other,true)
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
join(PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID_COND((*this),true)
PB_DS_ASSERT_VALID_COND(other,true)
node_pointer p_other = other.m_p_root;
if (p_other != 0)
do
{
node_pointer p_next = p_other->m_p_next_sibling;
std::swap(p_other->m_p_next_sibling, p_other->m_p_prev_or_parent);
p_other = p_next;
}
while (p_other != 0);
base_type::m_p_root = join(base_type::m_p_root, other.m_p_root);
base_type::m_size += other.m_size;
m_p_max = 0;
other.m_p_root = 0;
other.m_size = 0;
other.m_p_max = 0;
PB_DS_ASSERT_VALID_COND((*this),true)
PB_DS_ASSERT_VALID_COND(other,true)
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
join(node_pointer p_lhs, node_pointer p_rhs) const
{
node_pointer p_ret = 0;
node_pointer p_cur = 0;
while (p_lhs != 0 || p_rhs != 0)
{
if (p_rhs == 0)
{
if (p_cur == 0)
p_ret = p_cur = p_lhs;
else
{
p_cur->m_p_next_sibling = p_lhs;
p_lhs->m_p_prev_or_parent = p_cur;
}
p_cur = p_lhs = 0;
}
else if (p_lhs == 0 || p_rhs->m_metadata < p_lhs->m_metadata)
{
if (p_cur == 0)
{
p_ret = p_cur = p_rhs;
p_rhs = p_rhs->m_p_prev_or_parent;
}
else
{
p_cur->m_p_next_sibling = p_rhs;
p_rhs = p_rhs->m_p_prev_or_parent;
p_cur->m_p_next_sibling->m_p_prev_or_parent = p_cur;
p_cur = p_cur->m_p_next_sibling;
}
}
else if (p_lhs->m_metadata < p_rhs->m_metadata)
{
if (p_cur == 0)
p_ret = p_cur = p_lhs;
else
{
p_cur->m_p_next_sibling = p_lhs;
p_lhs->m_p_prev_or_parent = p_cur;
p_cur = p_cur->m_p_next_sibling;
}
p_lhs = p_cur->m_p_next_sibling;
}
else
{
node_pointer p_next_rhs = p_rhs->m_p_prev_or_parent;
p_rhs->m_p_next_sibling = p_lhs;
p_lhs = fix(p_rhs);
p_rhs = p_next_rhs;
}
}
if (p_cur != 0)
p_cur->m_p_next_sibling = 0;
if (p_ret != 0)
p_ret->m_p_prev_or_parent = 0;
return p_ret;
}
c++/8/ext/pb_ds/detail/binomial_heap_base_/insert_fn_imps.hpp 0000644 00000012227 15201526705 0020073 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file binomial_heap_base_/insert_fn_imps.hpp
* Contains an implementation class for a base of binomial heaps.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC::
push(const_reference r_val)
{
PB_DS_ASSERT_VALID_COND((*this),true)
node_pointer p_nd = base_type::get_new_node_for_insert(r_val);
insert_node(p_nd);
m_p_max = 0;
PB_DS_ASSERT_VALID_COND((*this),true)
return point_iterator(p_nd);
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
insert_node(node_pointer p_nd)
{
if (base_type::m_p_root == 0)
{
p_nd->m_p_next_sibling = 0;
p_nd->m_p_prev_or_parent = 0;
p_nd->m_p_l_child = 0;
p_nd->m_metadata = 0;
base_type::m_p_root = p_nd;
return;
}
if (base_type::m_p_root->m_metadata > 0)
{
p_nd->m_p_prev_or_parent = p_nd->m_p_l_child = 0;
p_nd->m_p_next_sibling = base_type::m_p_root;
base_type::m_p_root->m_p_prev_or_parent = p_nd;
base_type::m_p_root = p_nd;
p_nd->m_metadata = 0;
return;
}
if (Cmp_Fn::operator()(base_type::m_p_root->m_value, p_nd->m_value))
{
p_nd->m_p_next_sibling = base_type::m_p_root->m_p_next_sibling;
p_nd->m_p_prev_or_parent = 0;
p_nd->m_metadata = 1;
p_nd->m_p_l_child = base_type::m_p_root;
base_type::m_p_root->m_p_prev_or_parent = p_nd;
base_type::m_p_root->m_p_next_sibling = 0;
base_type::m_p_root = p_nd;
}
else
{
p_nd->m_p_next_sibling = 0;
p_nd->m_p_l_child = 0;
p_nd->m_p_prev_or_parent = base_type::m_p_root;
p_nd->m_metadata = 0;
_GLIBCXX_DEBUG_ASSERT(base_type::m_p_root->m_p_l_child == 0);
base_type::m_p_root->m_p_l_child = p_nd;
base_type::m_p_root->m_metadata = 1;
}
base_type::m_p_root = fix(base_type::m_p_root);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
fix(node_pointer p_nd) const
{
while (p_nd->m_p_next_sibling != 0 &&
p_nd->m_metadata == p_nd->m_p_next_sibling->m_metadata)
{
node_pointer p_next = p_nd->m_p_next_sibling;
if (Cmp_Fn::operator()(p_nd->m_value, p_next->m_value))
{
p_next->m_p_prev_or_parent = p_nd->m_p_prev_or_parent;
if (p_nd->m_p_prev_or_parent != 0)
p_nd->m_p_prev_or_parent->m_p_next_sibling = p_next;
base_type::make_child_of(p_nd, p_next);
++p_next->m_metadata;
p_nd = p_next;
}
else
{
p_nd->m_p_next_sibling = p_next->m_p_next_sibling;
if (p_nd->m_p_next_sibling != 0)
p_next->m_p_next_sibling = 0;
base_type::make_child_of(p_next, p_nd);
++p_nd->m_metadata;
}
}
if (p_nd->m_p_next_sibling != 0)
p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd;
return p_nd;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
modify(point_iterator it, const_reference r_new_val)
{
PB_DS_ASSERT_VALID_COND((*this),true)
node_pointer p_nd = it.m_p_nd;
_GLIBCXX_DEBUG_ASSERT(p_nd != 0);
PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_nd, false)
const bool bubble_up = Cmp_Fn::operator()(p_nd->m_value, r_new_val);
p_nd->m_value = r_new_val;
if (bubble_up)
{
node_pointer p_parent = base_type::parent(p_nd);
while (p_parent != 0 &&
Cmp_Fn::operator()(p_parent->m_value, p_nd->m_value))
{
base_type::swap_with_parent(p_nd, p_parent);
p_parent = base_type::parent(p_nd);
}
if (p_nd->m_p_prev_or_parent == 0)
base_type::m_p_root = p_nd;
m_p_max = 0;
PB_DS_ASSERT_VALID_COND((*this),true)
return;
}
base_type::bubble_to_top(p_nd);
remove_parentless_node(p_nd);
insert_node(p_nd);
m_p_max = 0;
PB_DS_ASSERT_VALID_COND((*this),true)
}
c++/8/ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp 0000644 00000010602 15201526705 0017661 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file binomial_heap_base_/erase_fn_imps.hpp
* Contains an implementation class for a base of binomial heaps.
*/
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
pop()
{
PB_DS_ASSERT_VALID_COND((*this),true)
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
if (m_p_max == 0)
find_max();
_GLIBCXX_DEBUG_ASSERT(m_p_max != 0);
node_pointer p_nd = m_p_max;
remove_parentless_node(m_p_max);
base_type::actual_erase_node(p_nd);
m_p_max = 0;
PB_DS_ASSERT_VALID_COND((*this),true)
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
remove_parentless_node(node_pointer p_nd)
{
_GLIBCXX_DEBUG_ASSERT(p_nd != 0);
_GLIBCXX_DEBUG_ASSERT(base_type::parent(p_nd) == 0);
node_pointer p_cur_root = p_nd == base_type::m_p_root?
p_nd->m_p_next_sibling : base_type::m_p_root;
if (p_cur_root != 0)
p_cur_root->m_p_prev_or_parent = 0;
if (p_nd->m_p_prev_or_parent != 0)
p_nd->m_p_prev_or_parent->m_p_next_sibling = p_nd->m_p_next_sibling;
if (p_nd->m_p_next_sibling != 0)
p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd->m_p_prev_or_parent;
node_pointer p_child = p_nd->m_p_l_child;
if (p_child != 0)
{
p_child->m_p_prev_or_parent = 0;
while (p_child->m_p_next_sibling != 0)
p_child = p_child->m_p_next_sibling;
}
m_p_max = 0;
base_type::m_p_root = join(p_cur_root, p_child);
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
clear()
{
base_type::clear();
m_p_max = 0;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
erase(point_iterator it)
{
PB_DS_ASSERT_VALID_COND((*this),true)
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
base_type::bubble_to_top(it.m_p_nd);
remove_parentless_node(it.m_p_nd);
base_type::actual_erase_node(it.m_p_nd);
m_p_max = 0;
PB_DS_ASSERT_VALID_COND((*this),true)
}
PB_DS_CLASS_T_DEC
template<typename Pred>
typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
erase_if(Pred pred)
{
PB_DS_ASSERT_VALID_COND((*this),true)
if (base_type::empty())
{
PB_DS_ASSERT_VALID_COND((*this),true)
return 0;
}
base_type::to_linked_list();
node_pointer p_out = base_type::prune(pred);
size_type ersd = 0;
while (p_out != 0)
{
++ersd;
node_pointer p_next = p_out->m_p_next_sibling;
base_type::actual_erase_node(p_out);
p_out = p_next;
}
node_pointer p_cur = base_type::m_p_root;
base_type::m_p_root = 0;
while (p_cur != 0)
{
node_pointer p_next = p_cur->m_p_next_sibling;
p_cur->m_p_l_child = p_cur->m_p_prev_or_parent = 0;
p_cur->m_metadata = 0;
p_cur->m_p_next_sibling = base_type::m_p_root;
if (base_type::m_p_root != 0)
base_type::m_p_root->m_p_prev_or_parent = p_cur;
base_type::m_p_root = p_cur;
base_type::m_p_root = fix(base_type::m_p_root);
p_cur = p_next;
}
m_p_max = 0;
PB_DS_ASSERT_VALID_COND((*this),true)
return ersd;
}
c++/8/ext/pb_ds/detail/unordered_iterator/point_const_iterator.hpp 0000644 00000007336 15201526705 0021311 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file unordered_iterator/point_const_iterator.hpp
* Contains an iterator class returned by the tables' const find and insert
* methods.
*/
class point_iterator_;
/// Const point-type iterator.
class point_const_iterator_
{
public:
/// Category.
typedef trivial_iterator_tag iterator_category;
/// Difference type.
typedef trivial_iterator_difference_type difference_type;
/// Iterator's value type.
typedef value_type_ value_type;
/// Iterator's pointer type.
typedef pointer_ pointer;
/// Iterator's const pointer type.
typedef const_pointer_ const_pointer;
/// Iterator's reference type.
typedef reference_ reference;
/// Iterator's const reference type.
typedef const_reference_ const_reference;
inline
point_const_iterator_(const_pointer p_value) : m_p_value(p_value)
{ }
/// Default constructor.
inline
point_const_iterator_() : m_p_value(0)
{ }
/// Copy constructor.
inline
point_const_iterator_(const point_const_iterator_& other)
: m_p_value(other.m_p_value)
{ }
/// Copy constructor.
inline
point_const_iterator_(const point_iterator_& other)
: m_p_value(other.m_p_value)
{ }
/// Access.
const_pointer
operator->() const
{
_GLIBCXX_DEBUG_ASSERT(m_p_value != 0);
return m_p_value;
}
/// Access.
const_reference
operator*() const
{
_GLIBCXX_DEBUG_ASSERT(m_p_value != 0);
return *m_p_value;
}
/// Compares content to a different iterator object.
bool
operator==(const point_iterator_& other) const
{ return m_p_value == other.m_p_value; }
/// Compares content to a different iterator object.
bool
operator==(const point_const_iterator_& other) const
{ return m_p_value == other.m_p_value; }
/// Compares content (negatively) to a different iterator object.
bool
operator!=(const point_iterator_& other) const
{ return m_p_value != other.m_p_value; }
/// Compares content (negatively) to a different iterator object.
bool
operator!=(const point_const_iterator_& other) const
{ return m_p_value != other.m_p_value; }
protected:
const_pointer m_p_value;
friend class point_iterator_;
friend class PB_DS_CLASS_C_DEC;
};
c++/8/ext/pb_ds/detail/unordered_iterator/const_iterator.hpp 0000644 00000006421 15201526705 0020072 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file unordered_iterator/const_iterator.hpp
* Contains an iterator class used for const ranging over the elements of the
* table.
*/
/// Const range-type iterator.
class const_iterator_
: public point_const_iterator_
{
public:
/// Category.
typedef std::forward_iterator_tag iterator_category;
/// Difference type.
typedef typename _Alloc::difference_type difference_type;
/// Iterator's value type.
typedef value_type_ value_type;
/// Iterator's pointer type.
typedef pointer_ pointer;
/// Iterator's const pointer type.
typedef const_pointer_ const_pointer;
/// Iterator's reference type.
typedef reference_ reference;
/// Iterator's const reference type.
typedef const_reference_ const_reference;
/// Default constructor.
const_iterator_() : m_p_tbl(0)
{ }
/// Increments.
const_iterator_&
operator++()
{
m_p_tbl->inc_it_state(base_type::m_p_value, m_pos);
return *this;
}
/// Increments.
const_iterator_
operator++(int)
{
const_iterator_ ret =* this;
m_p_tbl->inc_it_state(base_type::m_p_value, m_pos);
return ret;
}
protected:
typedef point_const_iterator_ base_type;
/**
* Constructor used by the table to initiate the generalized
* pointer and position (e.g., this is called from within a find()
* of a table.
* */
const_iterator_(const_pointer_ p_value, PB_DS_GEN_POS pos,
const PB_DS_CLASS_C_DEC* p_tbl)
: point_const_iterator_(p_value), m_p_tbl(p_tbl), m_pos(pos)
{ }
/**
* Pointer to the table object which created the iterator (used for
* incrementing its position.
* */
const PB_DS_CLASS_C_DEC* m_p_tbl;
PB_DS_GEN_POS m_pos;
friend class PB_DS_CLASS_C_DEC;
};
c++/8/ext/pb_ds/detail/unordered_iterator/point_iterator.hpp 0000644 00000006766 15201526705 0020111 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file point_iterator.hpp
* Contains an iterator class returned by the tables' find and insert
* methods.
*/
/// Find type iterator.
class point_iterator_
{
public:
/// Category.
typedef trivial_iterator_tag iterator_category;
/// Difference type.
typedef trivial_iterator_difference_type difference_type;
/// Iterator's value type.
typedef value_type_ value_type;
/// Iterator's pointer type.
typedef pointer_ pointer;
/// Iterator's const pointer type.
typedef const_pointer_ const_pointer;
/// Iterator's reference type.
typedef reference_ reference;
/// Iterator's const reference type.
typedef const_reference_ const_reference;
/// Default constructor.
inline
point_iterator_()
: m_p_value(0)
{ }
/// Copy constructor.
inline
point_iterator_(const point_iterator_& other)
: m_p_value(other.m_p_value)
{ }
/// Access.
pointer
operator->() const
{
_GLIBCXX_DEBUG_ASSERT(m_p_value != 0);
return (m_p_value);
}
/// Access.
reference
operator*() const
{
_GLIBCXX_DEBUG_ASSERT(m_p_value != 0);
return (*m_p_value);
}
/// Compares content to a different iterator object.
bool
operator==(const point_iterator_& other) const
{ return m_p_value == other.m_p_value; }
/// Compares content to a different iterator object.
bool
operator==(const point_const_iterator_& other) const
{ return m_p_value == other.m_p_value; }
/// Compares content to a different iterator object.
bool
operator!=(const point_iterator_& other) const
{ return m_p_value != other.m_p_value; }
/// Compares content (negatively) to a different iterator object.
bool
operator!=(const point_const_iterator_& other) const
{ return m_p_value != other.m_p_value; }
inline
point_iterator_(pointer p_value) : m_p_value(p_value)
{ }
protected:
friend class point_const_iterator_;
friend class PB_DS_CLASS_C_DEC;
protected:
pointer m_p_value;
};
c++/8/ext/pb_ds/detail/unordered_iterator/iterator.hpp 0000644 00000007325 15201526705 0016670 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file iterator.hpp
* Contains an iterator_ class used for ranging over the elements of the
* table.
*/
/// Range-type iterator.
class iterator_
: public const_iterator_
{
public:
/// Category.
typedef std::forward_iterator_tag iterator_category;
/// Difference type.
typedef typename _Alloc::difference_type difference_type;
/// Iterator's value type.
typedef value_type_ value_type;
/// Iterator's pointer type.
typedef pointer_ pointer;
/// Iterator's const pointer type.
typedef const_pointer_ const_pointer;
/// Iterator's reference type.
typedef reference_ reference;
/// Iterator's const reference type.
typedef const_reference_ const_reference;
/// Default constructor.
inline
iterator_()
: const_iterator_(0, PB_DS_GEN_POS(), 0) { }
/// Conversion to a point-type iterator.
inline
operator point_iterator_()
{ return point_iterator_(const_cast<pointer>(const_iterator_::m_p_value)); }
/// Conversion to a point-type iterator.
inline
operator const point_iterator_() const
{ return point_iterator_(const_cast<pointer>(const_iterator_::m_p_value)); }
/// Access.
pointer
operator->() const
{
_GLIBCXX_DEBUG_ASSERT(base_type::m_p_value != 0);
return (const_cast<pointer>(base_type::m_p_value));
}
/// Access.
reference
operator*() const
{
_GLIBCXX_DEBUG_ASSERT(base_type::m_p_value != 0);
return (const_cast<reference>(*base_type::m_p_value));
}
/// Increments.
iterator_&
operator++()
{
base_type::m_p_tbl->inc_it_state(base_type::m_p_value, base_type::m_pos);
return *this;
}
/// Increments.
iterator_
operator++(int)
{
iterator_ ret =* this;
base_type::m_p_tbl->inc_it_state(base_type::m_p_value, base_type::m_pos);
return ret;
}
protected:
typedef const_iterator_ base_type;
/**
* Constructor used by the table to initiate the generalized
* pointer and position (e.g., this is called from within a find()
* of a table.
* */
inline
iterator_(pointer p_value, PB_DS_GEN_POS pos, PB_DS_CLASS_C_DEC* p_tbl)
: const_iterator_(p_value, pos, p_tbl)
{ }
friend class PB_DS_CLASS_C_DEC;
};
c++/8/ext/pb_ds/detail/thin_heap_/constructors_destructor_fn_imps.hpp 0000644 00000005602 15201526705 0021772 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file thin_heap_/constructors_destructor_fn_imps.hpp
* Contains an implementation for thin_heap_.
*/
PB_DS_CLASS_T_DEC
template<typename It>
void
PB_DS_CLASS_C_DEC::
copy_from_range(It first_it, It last_it)
{
while (first_it != last_it)
push(*(first_it++));
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
thin_heap() : m_p_max(0)
{
initialize();
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
thin_heap(const Cmp_Fn& r_cmp_fn)
: base_type(r_cmp_fn), m_p_max(0)
{
initialize();
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
thin_heap(const PB_DS_CLASS_C_DEC& other)
: base_type(other)
{
initialize();
m_p_max = base_type::m_p_root;
for (node_pointer p_nd = base_type::m_p_root; p_nd != 0;
p_nd = p_nd->m_p_next_sibling)
if (Cmp_Fn::operator()(m_p_max->m_value, p_nd->m_value))
m_p_max = p_nd;
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
base_type::swap(other);
std::swap(m_p_max, other.m_p_max);
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
~thin_heap()
{ }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
initialize()
{ std::fill(m_a_aux, m_a_aux + max_rank, static_cast<node_pointer>(0)); }
c++/8/ext/pb_ds/detail/thin_heap_/debug_fn_imps.hpp 0000644 00000007432 15201526705 0016035 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file thin_heap_/debug_fn_imps.hpp
* Contains an implementation for thin_heap_.
*/
#ifdef _GLIBCXX_DEBUG
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_valid(const char* __file, int __line) const
{
base_type::assert_valid(__file, __line);
assert_node_consistent(base_type::m_p_root, true, __file, __line);
assert_max(__file, __line);
assert_aux_null(__file, __line);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_aux_null(const char* __file, int __line) const
{
for (size_type i = 0; i < max_rank; ++i)
PB_DS_DEBUG_VERIFY(m_a_aux[i] == 0);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_max(const char* __file, int __line) const
{
if (m_p_max == 0)
{
PB_DS_DEBUG_VERIFY(base_type::empty());
return;
}
PB_DS_DEBUG_VERIFY(!base_type::empty());
PB_DS_DEBUG_VERIFY(base_type::parent(m_p_max) == 0);
PB_DS_DEBUG_VERIFY(m_p_max->m_p_prev_or_parent == 0);
for (const_iterator it = base_type::begin(); it != base_type::end(); ++it)
PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(m_p_max->m_value, it.m_p_nd->m_value));
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_node_consistent(node_const_pointer p_nd, bool root,
const char* __file, int __line) const
{
base_type::assert_node_consistent(p_nd, root, __file, __line);
if (p_nd == 0)
return;
assert_node_consistent(p_nd->m_p_next_sibling, root, __file, __line);
assert_node_consistent(p_nd->m_p_l_child, false, __file, __line);
if (!root)
{
if (p_nd->m_metadata == 0)
PB_DS_DEBUG_VERIFY(p_nd->m_p_next_sibling == 0);
else
PB_DS_DEBUG_VERIFY(p_nd->m_metadata == p_nd->m_p_next_sibling->m_metadata + 1);
}
if (p_nd->m_p_l_child != 0)
PB_DS_DEBUG_VERIFY(p_nd->m_p_l_child->m_metadata + 1 == base_type::degree(p_nd));
const bool unmarked_valid =
(p_nd->m_p_l_child == 0 && p_nd->m_metadata == 0)
|| (p_nd->m_p_l_child != 0
&& p_nd->m_metadata == p_nd->m_p_l_child->m_metadata + 1);
const bool marked_valid =
(p_nd->m_p_l_child == 0 && p_nd->m_metadata == 1)
|| (p_nd->m_p_l_child != 0
&& p_nd->m_metadata == p_nd->m_p_l_child->m_metadata + 2);
PB_DS_DEBUG_VERIFY(unmarked_valid || marked_valid);
if (root)
PB_DS_DEBUG_VERIFY(unmarked_valid);
}
#endif
c++/8/ext/pb_ds/detail/thin_heap_/find_fn_imps.hpp 0000644 00000003640 15201526705 0015664 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file thin_heap_/find_fn_imps.hpp
* Contains an implementation for thin_heap_.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_reference
PB_DS_CLASS_C_DEC::
top() const
{
PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
_GLIBCXX_DEBUG_ASSERT(m_p_max != 0);
return m_p_max->m_value;
}
c++/8/ext/pb_ds/detail/thin_heap_/split_join_fn_imps.hpp 0000644 00000006123 15201526705 0017115 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file thin_heap_/split_join_fn_imps.hpp
* Contains an implementation for thin_heap_.
*/
PB_DS_CLASS_T_DEC
template<typename Pred>
void
PB_DS_CLASS_C_DEC::
split(Pred pred, PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
other.clear();
if (base_type::empty())
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
return;
}
base_type::to_linked_list();
node_pointer p_out = base_type::prune(pred);
while (p_out != 0)
{
_GLIBCXX_DEBUG_ASSERT(base_type::m_size > 0);
--base_type::m_size;
++other.m_size;
node_pointer p_next = p_out->m_p_next_sibling;
other.make_root_and_link(p_out);
p_out = p_next;
}
PB_DS_ASSERT_VALID(other)
node_pointer p_cur = base_type::m_p_root;
m_p_max = 0;
base_type::m_p_root = 0;
while (p_cur != 0)
{
node_pointer p_next = p_cur->m_p_next_sibling;
make_root_and_link(p_cur);
p_cur = p_next;
}
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
join(PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
node_pointer p_other = other.m_p_root;
while (p_other != 0)
{
node_pointer p_next = p_other->m_p_next_sibling;
make_root_and_link(p_other);
p_other = p_next;
}
base_type::m_size += other.m_size;
other.m_p_root = 0;
other.m_size = 0;
other.m_p_max = 0;
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
c++/8/ext/pb_ds/detail/thin_heap_/insert_fn_imps.hpp 0000644 00000016473 15201526705 0016260 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file thin_heap_/insert_fn_imps.hpp
* Contains an implementation for thin_heap_.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC::
push(const_reference r_val)
{
PB_DS_ASSERT_VALID((*this))
node_pointer p_nd = base_type::get_new_node_for_insert(r_val);
p_nd->m_metadata = 0;
p_nd->m_p_prev_or_parent = p_nd->m_p_l_child = 0;
if (base_type::m_p_root == 0)
{
p_nd->m_p_next_sibling = 0;
m_p_max = base_type::m_p_root = p_nd;
PB_DS_ASSERT_VALID((*this))
return point_iterator(p_nd);
}
p_nd->m_p_next_sibling = base_type::m_p_root;
base_type::m_p_root->m_p_prev_or_parent = 0;
base_type::m_p_root = p_nd;
update_max(p_nd);
PB_DS_ASSERT_VALID((*this))
return point_iterator(p_nd);
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
make_root(node_pointer p_nd)
{
p_nd->m_metadata = p_nd->m_p_l_child == 0
? 0 : 1 + p_nd->m_p_l_child->m_metadata;
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
make_root_and_link(node_pointer p_nd)
{
make_root(p_nd);
p_nd->m_p_prev_or_parent = 0;
p_nd->m_p_next_sibling = base_type::m_p_root;
if (base_type::m_p_root != 0)
base_type::m_p_root->m_p_prev_or_parent = 0;
base_type::m_p_root = p_nd;
update_max(p_nd);
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
fix(node_pointer p_y)
{
while (true)
{
if (p_y->m_p_prev_or_parent == 0)
{
fix_root(p_y);
return;
}
else if (p_y->m_metadata == 1&& p_y->m_p_next_sibling == 0)
{
if (p_y->m_p_l_child != 0)
{
fix_sibling_rank_1_unmarked(p_y);
return;
}
fix_sibling_rank_1_marked(p_y);
p_y = p_y->m_p_prev_or_parent;
}
else if (p_y->m_metadata > p_y->m_p_next_sibling->m_metadata + 1)
{
_GLIBCXX_DEBUG_ASSERT(p_y->m_p_l_child != 0);
if (p_y->m_metadata != p_y->m_p_l_child->m_metadata + 2)
{
fix_sibling_general_unmarked(p_y);
return;
}
fix_sibling_general_marked(p_y);
p_y = p_y->m_p_prev_or_parent;
}
else if ((p_y->m_p_l_child == 0&&
p_y->m_metadata == 2) ||(p_y->m_p_l_child != 0&&
p_y->m_metadata == p_y->m_p_l_child->m_metadata + 3))
{
node_pointer p_z = p_y->m_p_prev_or_parent;
fix_child(p_y);
p_y = p_z;
}
else
return;
}
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
fix_root(node_pointer p_y)
{
_GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent == 0);
make_root(p_y);
PB_DS_ASSERT_NODE_CONSISTENT(p_y, true)
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
fix_sibling_rank_1_unmarked(node_pointer p_y)
{
_GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != 0);
_GLIBCXX_DEBUG_ONLY(node_pointer p_w = p_y->m_p_l_child;)
_GLIBCXX_DEBUG_ASSERT(p_w != 0);
_GLIBCXX_DEBUG_ASSERT(p_w->m_p_next_sibling == 0);
_GLIBCXX_DEBUG_ASSERT(p_y->m_p_next_sibling == 0);
p_y->m_p_next_sibling = p_y->m_p_l_child;
p_y->m_p_next_sibling->m_p_prev_or_parent = p_y;
p_y->m_p_l_child = 0;
PB_DS_ASSERT_NODE_CONSISTENT(p_y, false)
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
fix_sibling_rank_1_marked(node_pointer p_y)
{
_GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != 0);
_GLIBCXX_DEBUG_ASSERT(p_y->m_p_l_child == 0);
p_y->m_metadata = 0;
PB_DS_ASSERT_NODE_CONSISTENT(p_y, false)
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
fix_sibling_general_unmarked(node_pointer p_y)
{
_GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != 0);
node_pointer p_w = p_y->m_p_l_child;
_GLIBCXX_DEBUG_ASSERT(p_w != 0);
_GLIBCXX_DEBUG_ASSERT(p_w->m_p_next_sibling != 0);
p_y->m_p_l_child = p_w->m_p_next_sibling;
p_w->m_p_next_sibling->m_p_prev_or_parent = p_y;
p_w->m_p_next_sibling = p_y->m_p_next_sibling;
_GLIBCXX_DEBUG_ASSERT(p_w->m_p_next_sibling != 0);
p_w->m_p_next_sibling->m_p_prev_or_parent = p_w;
p_y->m_p_next_sibling = p_w;
p_w->m_p_prev_or_parent = p_y;
PB_DS_ASSERT_NODE_CONSISTENT(p_y, false)
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
fix_sibling_general_marked(node_pointer p_y)
{
_GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != 0);
--p_y->m_metadata;
PB_DS_ASSERT_NODE_CONSISTENT(p_y, false)
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
fix_child(node_pointer p_y)
{
_GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != 0);
if (p_y->m_p_next_sibling != 0)
p_y->m_p_next_sibling->m_p_prev_or_parent = p_y->m_p_prev_or_parent;
if (p_y->m_p_prev_or_parent->m_p_l_child == p_y)
p_y->m_p_prev_or_parent->m_p_l_child = p_y->m_p_next_sibling;
else
p_y->m_p_prev_or_parent->m_p_next_sibling = p_y->m_p_next_sibling;
make_root_and_link(p_y);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
modify(point_iterator it, const_reference r_new_val)
{
PB_DS_ASSERT_VALID((*this))
node_pointer p_nd = it.m_p_nd;
_GLIBCXX_DEBUG_ASSERT(p_nd != 0);
const bool smaller = Cmp_Fn::operator()(r_new_val, p_nd->m_value);
p_nd->m_value = r_new_val;
if (smaller)
{
remove_node(p_nd);
p_nd->m_p_l_child = 0;
make_root_and_link(p_nd);
PB_DS_ASSERT_VALID((*this))
return;
}
if (p_nd->m_p_prev_or_parent == 0)
{
update_max(p_nd);
PB_DS_ASSERT_VALID((*this))
return;
}
node_pointer p_y = p_nd->m_p_prev_or_parent;
_GLIBCXX_DEBUG_ASSERT(p_y != 0);
if (p_nd->m_p_next_sibling != 0)
p_nd->m_p_next_sibling->m_p_prev_or_parent = p_y;
if (p_y->m_p_l_child == p_nd)
p_y->m_p_l_child = p_nd->m_p_next_sibling;
else
p_y->m_p_next_sibling = p_nd->m_p_next_sibling;
fix(p_y);
make_root_and_link(p_nd);
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
update_max(node_pointer p_nd)
{
if (m_p_max == 0 || Cmp_Fn::operator()(m_p_max->m_value, p_nd->m_value))
m_p_max = p_nd;
}
c++/8/ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp 0000644 00000013647 15201526705 0016053 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file thin_heap_/erase_fn_imps.hpp
* Contains an implementation for thin_heap_.
*/
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
pop()
{
PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
_GLIBCXX_DEBUG_ASSERT(m_p_max != 0);
node_pointer p_nd = m_p_max;
remove_max_node();
base_type::actual_erase_node(p_nd);
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
remove_max_node()
{
to_aux_except_max();
make_from_aux();
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
to_aux_except_max()
{
node_pointer p_add = base_type::m_p_root;
while (p_add != m_p_max)
{
node_pointer p_next_add = p_add->m_p_next_sibling;
add_to_aux(p_add);
p_add = p_next_add;
}
p_add = m_p_max->m_p_l_child;
while (p_add != 0)
{
node_pointer p_next_add = p_add->m_p_next_sibling;
p_add->m_metadata = p_add->m_p_l_child == 0 ?
0 : p_add->m_p_l_child->m_metadata + 1;
add_to_aux(p_add);
p_add = p_next_add;
}
p_add = m_p_max->m_p_next_sibling;
while (p_add != 0)
{
node_pointer p_next_add = p_add->m_p_next_sibling;
add_to_aux(p_add);
p_add = p_next_add;
}
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
add_to_aux(node_pointer p_nd)
{
size_type r = p_nd->m_metadata;
while (m_a_aux[r] != 0)
{
_GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata < rank_bound());
if (Cmp_Fn::operator()(m_a_aux[r]->m_value, p_nd->m_value))
make_child_of(m_a_aux[r], p_nd);
else
{
make_child_of(p_nd, m_a_aux[r]);
p_nd = m_a_aux[r];
}
m_a_aux[r] = 0;
++r;
}
_GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata < rank_bound());
m_a_aux[r] = p_nd;
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
make_child_of(node_pointer p_nd, node_pointer p_new_parent)
{
_GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata == p_new_parent->m_metadata);
_GLIBCXX_DEBUG_ASSERT(m_a_aux[p_nd->m_metadata] == p_nd ||
m_a_aux[p_nd->m_metadata] == p_new_parent);
++p_new_parent->m_metadata;
base_type::make_child_of(p_nd, p_new_parent);
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
make_from_aux()
{
base_type::m_p_root = m_p_max = 0;
const size_type rnk_bnd = rank_bound();
size_type i = 0;
while (i < rnk_bnd)
{
if (m_a_aux[i] != 0)
{
make_root_and_link(m_a_aux[i]);
m_a_aux[i] = 0;
}
++i;
}
PB_DS_ASSERT_AUX_NULL((*this))
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
remove_node(node_pointer p_nd)
{
node_pointer p_parent = p_nd;
while (base_type::parent(p_parent) != 0)
p_parent = base_type::parent(p_parent);
base_type::bubble_to_top(p_nd);
m_p_max = p_nd;
node_pointer p_fix = base_type::m_p_root;
while (p_fix != 0&& p_fix->m_p_next_sibling != p_parent)
p_fix = p_fix->m_p_next_sibling;
if (p_fix != 0)
p_fix->m_p_next_sibling = p_nd;
remove_max_node();
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
clear()
{
base_type::clear();
m_p_max = 0;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
erase(point_iterator it)
{
PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
node_pointer p_nd = it.m_p_nd;
remove_node(p_nd);
base_type::actual_erase_node(p_nd);
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
template<typename Pred>
typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
erase_if(Pred pred)
{
PB_DS_ASSERT_VALID((*this))
if (base_type::empty())
{
PB_DS_ASSERT_VALID((*this))
return 0;
}
base_type::to_linked_list();
node_pointer p_out = base_type::prune(pred);
size_type ersd = 0;
while (p_out != 0)
{
++ersd;
node_pointer p_next = p_out->m_p_next_sibling;
base_type::actual_erase_node(p_out);
p_out = p_next;
}
node_pointer p_cur = base_type::m_p_root;
m_p_max = base_type::m_p_root = 0;
while (p_cur != 0)
{
node_pointer p_next = p_cur->m_p_next_sibling;
make_root_and_link(p_cur);
p_cur = p_next;
}
PB_DS_ASSERT_VALID((*this))
return ersd;
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
rank_bound()
{
using namespace std;
const size_t* const p_upper =
std::upper_bound(g_a_rank_bounds,
g_a_rank_bounds + num_distinct_rank_bounds,
base_type::m_size);
if (p_upper == g_a_rank_bounds + num_distinct_rank_bounds)
return max_rank;
return (p_upper - g_a_rank_bounds);
}
c++/8/ext/pb_ds/detail/thin_heap_/trace_fn_imps.hpp 0000644 00000003652 15201526705 0016045 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file thin_heap_/trace_fn_imps.hpp
* Contains an implementation class for left_child_next_sibling_heap_.
*/
#ifdef PB_DS_THIN_HEAP_TRACE_
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
trace() const
{
std::cerr << std::endl;
std::cerr << "m_p_max " << m_p_max << std::endl;
base_type::trace();
}
#endif // #ifdef PB_DS_THIN_HEAP_TRACE_
c++/8/ext/pb_ds/detail/thin_heap_/thin_heap_.hpp 0000644 00000020324 15201526705 0015325 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file thin_heap_/thin_heap_.hpp
* Contains an implementation class for a thin heap.
*/
#ifndef PB_DS_THIN_HEAP_HPP
#define PB_DS_THIN_HEAP_HPP
#include <algorithm>
#include <ext/pb_ds/detail/cond_dealtor.hpp>
#include <ext/pb_ds/detail/type_utils.hpp>
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp>
#include <debug/debug.h>
namespace __gnu_pbds
{
namespace detail
{
#define PB_DS_CLASS_T_DEC \
template<typename Value_Type, typename Cmp_Fn, typename _Alloc>
#define PB_DS_CLASS_C_DEC \
thin_heap<Value_Type, Cmp_Fn, _Alloc>
#ifdef _GLIBCXX_DEBUG
#define PB_DS_BASE_T_P \
<Value_Type, Cmp_Fn, typename _Alloc::size_type, _Alloc, true>
#else
#define PB_DS_BASE_T_P \
<Value_Type, Cmp_Fn, typename _Alloc::size_type, _Alloc>
#endif
/**
* Thin heap.
*
* @ingroup heap-detail
*
* See Tarjan and Kaplan.
*/
template<typename Value_Type, typename Cmp_Fn, typename _Alloc>
class thin_heap
: public left_child_next_sibling_heap PB_DS_BASE_T_P
{
private:
typedef typename _Alloc::template rebind<Value_Type>::other __rebind_a;
typedef left_child_next_sibling_heap PB_DS_BASE_T_P base_type;
protected:
typedef typename base_type::node node;
typedef typename base_type::node_pointer node_pointer;
typedef typename base_type::node_const_pointer node_const_pointer;
public:
typedef Value_Type value_type;
typedef Cmp_Fn cmp_fn;
typedef _Alloc allocator_type;
typedef typename _Alloc::size_type size_type;
typedef typename _Alloc::difference_type difference_type;
typedef typename __rebind_a::pointer pointer;
typedef typename __rebind_a::const_pointer const_pointer;
typedef typename __rebind_a::reference reference;
typedef typename __rebind_a::const_reference const_reference;
typedef typename base_type::point_iterator point_iterator;
typedef typename base_type::point_const_iterator point_const_iterator;
typedef typename base_type::iterator iterator;
typedef typename base_type::const_iterator const_iterator;
inline point_iterator
push(const_reference);
void
modify(point_iterator, const_reference);
inline const_reference
top() const;
void
pop();
void
erase(point_iterator);
inline void
clear();
template<typename Pred>
size_type
erase_if(Pred);
template<typename Pred>
void
split(Pred, PB_DS_CLASS_C_DEC&);
void
join(PB_DS_CLASS_C_DEC&);
protected:
thin_heap();
thin_heap(const Cmp_Fn&);
thin_heap(const PB_DS_CLASS_C_DEC&);
void
swap(PB_DS_CLASS_C_DEC&);
~thin_heap();
template<typename It>
void
copy_from_range(It, It);
#ifdef _GLIBCXX_DEBUG
void
assert_valid(const char*, int) const;
void
assert_max(const char*, int) const;
#endif
#ifdef PB_DS_THIN_HEAP_TRACE_
void
trace() const;
#endif
private:
enum
{
max_rank = (sizeof(size_type) << 4) + 2
};
void
initialize();
inline void
update_max(node_pointer);
inline void
fix(node_pointer);
inline void
fix_root(node_pointer);
inline void
fix_sibling_rank_1_unmarked(node_pointer);
inline void
fix_sibling_rank_1_marked(node_pointer);
inline void
fix_sibling_general_unmarked(node_pointer);
inline void
fix_sibling_general_marked(node_pointer);
inline void
fix_child(node_pointer);
inline static void
make_root(node_pointer);
inline void
make_root_and_link(node_pointer);
inline void
remove_max_node();
void
to_aux_except_max();
inline void
add_to_aux(node_pointer);
inline void
make_from_aux();
inline size_type
rank_bound();
inline void
make_child_of(node_pointer, node_pointer);
inline void
remove_node(node_pointer);
inline node_pointer
join(node_pointer, node_pointer) const;
#ifdef _GLIBCXX_DEBUG
void
assert_node_consistent(node_const_pointer, bool, const char*, int) const;
void
assert_aux_null(const char*, int) const;
#endif
node_pointer m_p_max;
node_pointer m_a_aux[max_rank];
};
enum
{
num_distinct_rank_bounds = 48
};
// Taken from the SGI implementation; acknowledged in the docs.
static const std::size_t g_a_rank_bounds[num_distinct_rank_bounds] =
{
/* Dealing cards... */
/* 0 */ 0ul,
/* 1 */ 1ul,
/* 2 */ 1ul,
/* 3 */ 2ul,
/* 4 */ 4ul,
/* 5 */ 6ul,
/* 6 */ 11ul,
/* 7 */ 17ul,
/* 8 */ 29ul,
/* 9 */ 46ul,
/* 10 */ 76ul,
/* 11 */ 122ul,
/* 12 */ 199ul,
/* 13 */ 321ul,
/* 14 */ 521ul,
/* 15 */ 842ul,
/* 16 */ 1364ul,
/* 17 */ 2206ul,
/* 18 */ 3571ul,
/* 19 */ 5777ul,
/* 20 */ 9349ul,
/* 21 */ 15126ul,
/* 22 */ 24476ul,
/* 23 */ 39602ul,
/* 24 */ 64079ul
#if __SIZE_MAX__ > 0xfffful
,
/* 25 */ 103681ul,
/* 26 */ 167761ul,
/* 27 */ 271442ul,
/* 28 */ 439204ul,
/* 29 */ 710646ul
#if __SIZE_MAX__ > 0xffffful
,
/* 30 */ 1149851ul,
/* 31 */ 1860497ul,
/* 32 */ 3010349ul,
/* 33 */ 4870846ul,
/* 34 */ 7881196ul,
/* 35 */ 12752042ul
#if __SIZE_MAX__ > 0xfffffful
,
/* 36 */ 20633239ul,
/* 37 */ 33385282ul,
/* 38 */ 54018521ul,
/* 39 */ 87403803ul,
/* 40 */ 141422324ul,
/* 41 */ 228826127ul,
/* 42 */ 370248451ul,
/* 43 */ 599074578ul,
/* 44 */ 969323029ul,
/* 45 */ 1568397607ul,
/* 46 */ 2537720636ul,
/* 47 */ 4106118243ul
#endif
#endif
#endif
/* Pot's good, let's play */
};
#define PB_DS_ASSERT_NODE_CONSISTENT(_Node, _Bool) \
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(_Node, _Bool, \
__FILE__, __LINE__);)
#define PB_DS_ASSERT_AUX_NULL(X) \
_GLIBCXX_DEBUG_ONLY(X.assert_aux_null(__FILE__, __LINE__);)
#include <ext/pb_ds/detail/thin_heap_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/thin_heap_/debug_fn_imps.hpp>
#include <ext/pb_ds/detail/thin_heap_/trace_fn_imps.hpp>
#include <ext/pb_ds/detail/thin_heap_/find_fn_imps.hpp>
#include <ext/pb_ds/detail/thin_heap_/insert_fn_imps.hpp>
#include <ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp>
#include <ext/pb_ds/detail/thin_heap_/split_join_fn_imps.hpp>
#undef PB_DS_ASSERT_AUX_NULL
#undef PB_DS_ASSERT_NODE_CONSISTENT
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_BASE_T_P
} // namespace detail
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/detail/priority_queue_base_dispatch.hpp 0000644 00000010054 15201526705 0017066 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file detail/priority_queue_base_dispatch.hpp
* Contains an pqiative container dispatching base.
*/
#ifndef PB_DS_PRIORITY_QUEUE_BASE_DS_DISPATCHER_HPP
#define PB_DS_PRIORITY_QUEUE_BASE_DS_DISPATCHER_HPP
#define PB_DS_ASSERT_VALID(X) \
_GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
#define PB_DS_DEBUG_VERIFY(_Cond) \
_GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
_M_message(#_Cond" assertion from %1;:%2;") \
._M_string(__FILE__)._M_integer(__LINE__) \
,__file,__line)
#include <ext/pb_ds/detail/pairing_heap_/pairing_heap_.hpp>
#include <ext/pb_ds/detail/binomial_heap_/binomial_heap_.hpp>
#include <ext/pb_ds/detail/rc_binomial_heap_/rc_binomial_heap_.hpp>
#include <ext/pb_ds/detail/binary_heap_/binary_heap_.hpp>
#include <ext/pb_ds/detail/thin_heap_/thin_heap_.hpp>
#undef PB_DS_DEBUG_VERIFY
#undef PB_DS_ASSERT_VALID
namespace __gnu_pbds
{
namespace detail
{
/// Specialization for pairing_heap.
template<typename _VTp, typename Cmp_Fn, typename _Alloc>
struct container_base_dispatch<_VTp, Cmp_Fn, _Alloc, pairing_heap_tag,
null_type>
{
/// Dispatched type.
typedef pairing_heap<_VTp, Cmp_Fn, _Alloc> type;
};
/// Specialization for binomial_heap.
template<typename _VTp, typename Cmp_Fn, typename _Alloc>
struct container_base_dispatch<_VTp, Cmp_Fn, _Alloc, binomial_heap_tag,
null_type>
{
/// Dispatched type.
typedef binomial_heap<_VTp, Cmp_Fn, _Alloc> type;
};
/// Specialization for rc_binary_heap.
template<typename _VTp, typename Cmp_Fn, typename _Alloc>
struct container_base_dispatch<_VTp, Cmp_Fn, _Alloc, rc_binomial_heap_tag,
null_type>
{
/// Dispatched type.
typedef rc_binomial_heap<_VTp, Cmp_Fn, _Alloc> type;
};
/// Specialization for binary_heap.
template<typename _VTp, typename Cmp_Fn, typename _Alloc>
struct container_base_dispatch<_VTp, Cmp_Fn, _Alloc, binary_heap_tag,
null_type>
{
/// Dispatched type.
typedef binary_heap<_VTp, Cmp_Fn, _Alloc> type;
};
/// Specialization for thin_heap.
template<typename _VTp, typename Cmp_Fn, typename _Alloc>
struct container_base_dispatch<_VTp, Cmp_Fn, _Alloc, thin_heap_tag,
null_type>
{
/// Dispatched type.
typedef thin_heap<_VTp, Cmp_Fn, _Alloc> type;
};
//@} group pbds
} // namespace detail
} // namespace __gnu_pbds
#endif // #ifndef PB_DS_PRIORITY_QUEUE_BASE_DS_DISPATCHER_HPP
c++/8/ext/pb_ds/detail/rc_binomial_heap_/constructors_destructor_fn_imps.hpp 0000644 00000004643 15201526705 0023312 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file rc_binomial_heap_/constructors_destructor_fn_imps.hpp
* Contains an implementation for rc_binomial_heap_.
*/
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
rc_binomial_heap()
{
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
rc_binomial_heap(const Cmp_Fn& r_cmp_fn)
: base_type(r_cmp_fn)
{
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
rc_binomial_heap(const PB_DS_CLASS_C_DEC& other)
: base_type(other)
{
make_binomial_heap();
base_type::find_max();
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
~rc_binomial_heap()
{ }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
base_type::swap(other);
m_rc.swap(other.m_rc);
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
c++/8/ext/pb_ds/detail/rc_binomial_heap_/debug_fn_imps.hpp 0000644 00000006722 15201526705 0017352 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file rc_binomial_heap_/debug_fn_imps.hpp
* Contains an implementation for rc_binomial_heap_.
*/
#ifdef _GLIBCXX_DEBUG
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_valid(const char* __file, int __line) const
{
base_type::assert_valid(false, __file, __line);
if (!base_type::empty())
{
PB_DS_DEBUG_VERIFY(base_type::m_p_max != 0);
base_type::assert_max(__file, __line);
}
m_rc.assert_valid(__file, __line);
if (m_rc.empty())
{
base_type::assert_valid(true, __file, __line);
PB_DS_DEBUG_VERIFY(next_2_pointer(base_type::m_p_root) == 0);
return;
}
node_const_pointer p_nd = next_2_pointer(base_type::m_p_root);
typename rc_t::const_iterator it = m_rc.end();
--it;
while (p_nd != 0)
{
PB_DS_DEBUG_VERIFY(*it == p_nd);
node_const_pointer p_next = p_nd->m_p_next_sibling;
PB_DS_DEBUG_VERIFY(p_next != 0);
PB_DS_DEBUG_VERIFY(p_nd->m_metadata == p_next->m_metadata);
PB_DS_DEBUG_VERIFY(p_next->m_p_next_sibling == 0 ||
p_next->m_metadata < p_next->m_p_next_sibling->m_metadata);
--it;
p_nd = next_2_pointer(next_after_0_pointer(p_nd));
}
PB_DS_DEBUG_VERIFY(it + 1 == m_rc.begin());
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_const_pointer
PB_DS_CLASS_C_DEC::
next_2_pointer(node_const_pointer p_nd)
{
if (p_nd == 0)
return 0;
node_pointer p_next = p_nd->m_p_next_sibling;
if (p_next == 0)
return 0;
if (p_nd->m_metadata == p_next->m_metadata)
return p_nd;
return next_2_pointer(p_next);
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_const_pointer
PB_DS_CLASS_C_DEC::
next_after_0_pointer(node_const_pointer p_nd)
{
if (p_nd == 0)
return 0;
node_pointer p_next = p_nd->m_p_next_sibling;
if (p_next == 0)
return 0;
if (p_nd->m_metadata < p_next->m_metadata)
return p_next;
return next_after_0_pointer(p_next);
}
#endif
c++/8/ext/pb_ds/detail/rc_binomial_heap_/rc_binomial_heap_.hpp 0000644 00000012267 15201526705 0020164 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file rc_binomial_heap_/rc_binomial_heap_.hpp
* Contains an implementation for redundant-counter binomial heap.
*/
#include <ext/pb_ds/detail/cond_dealtor.hpp>
#include <ext/pb_ds/detail/type_utils.hpp>
#include <ext/pb_ds/detail/binomial_heap_base_/binomial_heap_base_.hpp>
#include <ext/pb_ds/detail/rc_binomial_heap_/rc.hpp>
#include <debug/debug.h>
namespace __gnu_pbds
{
namespace detail
{
#define PB_DS_CLASS_T_DEC \
template<typename Value_Type, typename Cmp_Fn, typename _Alloc>
#define PB_DS_CLASS_C_DEC \
rc_binomial_heap<Value_Type, Cmp_Fn, _Alloc>
#define PB_DS_RC_C_DEC \
rc<typename binomial_heap_base<Value_Type, Cmp_Fn, _Alloc>::node, _Alloc>
/**
* Redundant-counter binomial heap.
*
* @ingroup heap-detail
*/
template<typename Value_Type, typename Cmp_Fn, typename _Alloc>
class rc_binomial_heap
: public binomial_heap_base<Value_Type, Cmp_Fn, _Alloc>
{
private:
typedef binomial_heap_base<Value_Type, Cmp_Fn, _Alloc>
base_type;
typedef typename base_type::node_pointer node_pointer;
typedef typename base_type::node_const_pointer node_const_pointer;
typedef PB_DS_RC_C_DEC rc_t;
public:
typedef Value_Type value_type;
typedef typename _Alloc::size_type size_type;
typedef typename _Alloc::difference_type difference_type;
typedef typename base_type::pointer pointer;
typedef typename base_type::const_pointer const_pointer;
typedef typename base_type::reference reference;
typedef typename base_type::const_reference const_reference;
typedef typename base_type::point_const_iterator point_const_iterator;
typedef typename base_type::point_iterator point_iterator;
typedef typename base_type::const_iterator const_iterator;
typedef typename base_type::iterator iterator;
typedef typename base_type::cmp_fn cmp_fn;
typedef typename base_type::allocator_type allocator_type;
rc_binomial_heap();
rc_binomial_heap(const Cmp_Fn&);
rc_binomial_heap(const PB_DS_CLASS_C_DEC&);
~rc_binomial_heap();
void
swap(PB_DS_CLASS_C_DEC&);
inline point_iterator
push(const_reference);
void
modify(point_iterator, const_reference);
inline void
pop();
void
erase(point_iterator);
inline void
clear();
template<typename Pred>
size_type
erase_if(Pred);
template<typename Pred>
void
split(Pred, PB_DS_CLASS_C_DEC&);
void
join(PB_DS_CLASS_C_DEC&);
#ifdef _GLIBCXX_DEBUG
void
assert_valid(const char*, int) const;
#endif
#ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_
void
trace() const;
#endif
private:
inline node_pointer
link_with_next_sibling(node_pointer);
void
make_0_exposed();
void
make_binomial_heap();
#ifdef _GLIBCXX_DEBUG
static node_const_pointer
next_2_pointer(node_const_pointer);
static node_const_pointer
next_after_0_pointer(node_const_pointer);
#endif
rc_t m_rc;
};
#include <ext/pb_ds/detail/rc_binomial_heap_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/rc_binomial_heap_/debug_fn_imps.hpp>
#include <ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp>
#include <ext/pb_ds/detail/rc_binomial_heap_/trace_fn_imps.hpp>
#include <ext/pb_ds/detail/rc_binomial_heap_/insert_fn_imps.hpp>
#include <ext/pb_ds/detail/rc_binomial_heap_/split_join_fn_imps.hpp>
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_RC_C_DEC
} // namespace detail
} // namespace __gnu_pbds
c++/8/ext/pb_ds/detail/rc_binomial_heap_/rc.hpp 0000644 00000014171 15201526705 0015152 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file rc_binomial_heap_/rc.hpp
* Contains a redundant (binary counter).
*/
#ifndef PB_DS_RC_HPP
#define PB_DS_RC_HPP
namespace __gnu_pbds
{
namespace detail
{
/// Redundant binary counter.
template<typename _Node, typename _Alloc>
class rc
{
private:
typedef _Alloc allocator_type;
typedef typename allocator_type::size_type size_type;
typedef _Node node;
typedef typename _Alloc::template rebind<node> __rebind_n;
typedef typename __rebind_n::other::pointer node_pointer;
typedef typename _Alloc::template rebind<node_pointer> __rebind_np;
typedef typename __rebind_np::other::pointer entry_pointer;
typedef typename __rebind_np::other::const_pointer entry_const_pointer;
enum
{
max_entries = sizeof(size_type) << 3
};
public:
typedef node_pointer entry;
typedef entry_const_pointer const_iterator;
rc();
rc(const rc&);
inline void
swap(rc&);
inline void
push(entry);
inline node_pointer
top() const;
inline void
pop();
inline bool
empty() const;
inline size_type
size() const;
void
clear();
const const_iterator
begin() const;
const const_iterator
end() const;
#ifdef _GLIBCXX_DEBUG
void
assert_valid(const char*, int) const;
#endif
#ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_
void
trace() const;
#endif
private:
node_pointer m_a_entries[max_entries];
size_type m_over_top;
};
template<typename _Node, typename _Alloc>
rc<_Node, _Alloc>::
rc() : m_over_top(0)
{ PB_DS_ASSERT_VALID((*this)) }
template<typename _Node, typename _Alloc>
rc<_Node, _Alloc>::
rc(const rc<_Node, _Alloc>& other) : m_over_top(0)
{ PB_DS_ASSERT_VALID((*this)) }
template<typename _Node, typename _Alloc>
inline void
rc<_Node, _Alloc>::
swap(rc<_Node, _Alloc>& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
const size_type over_top = std::max(m_over_top, other.m_over_top);
for (size_type i = 0; i < over_top; ++i)
std::swap(m_a_entries[i], other.m_a_entries[i]);
std::swap(m_over_top, other.m_over_top);
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
template<typename _Node, typename _Alloc>
inline void
rc<_Node, _Alloc>::
push(entry p_nd)
{
PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(m_over_top < max_entries);
m_a_entries[m_over_top++] = p_nd;
PB_DS_ASSERT_VALID((*this))
}
template<typename _Node, typename _Alloc>
inline void
rc<_Node, _Alloc>::
pop()
{
PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!empty());
--m_over_top;
PB_DS_ASSERT_VALID((*this))
}
template<typename _Node, typename _Alloc>
inline typename rc<_Node, _Alloc>::node_pointer
rc<_Node, _Alloc>::
top() const
{
PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!empty());
return *(m_a_entries + m_over_top - 1);
}
template<typename _Node, typename _Alloc>
inline bool
rc<_Node, _Alloc>::
empty() const
{
PB_DS_ASSERT_VALID((*this))
return m_over_top == 0;
}
template<typename _Node, typename _Alloc>
inline typename rc<_Node, _Alloc>::size_type
rc<_Node, _Alloc>::
size() const
{ return m_over_top; }
template<typename _Node, typename _Alloc>
void
rc<_Node, _Alloc>::
clear()
{
PB_DS_ASSERT_VALID((*this))
m_over_top = 0;
PB_DS_ASSERT_VALID((*this))
}
template<typename _Node, typename _Alloc>
const typename rc<_Node, _Alloc>::const_iterator
rc<_Node, _Alloc>::
begin() const
{ return& m_a_entries[0]; }
template<typename _Node, typename _Alloc>
const typename rc<_Node, _Alloc>::const_iterator
rc<_Node, _Alloc>::
end() const
{ return& m_a_entries[m_over_top]; }
#ifdef _GLIBCXX_DEBUG
template<typename _Node, typename _Alloc>
void
rc<_Node, _Alloc>::
assert_valid(const char* __file, int __line) const
{ PB_DS_DEBUG_VERIFY(m_over_top < max_entries); }
#endif
#ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_
template<typename _Node, typename _Alloc>
void
rc<_Node, _Alloc>::
trace() const
{
std::cout << "rc" << std::endl;
for (size_type i = 0; i < m_over_top; ++i)
std::cerr << m_a_entries[i] << std::endl;
std::cout << std::endl;
}
#endif
} // namespace detail
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/detail/rc_binomial_heap_/split_join_fn_imps.hpp 0000644 00000004562 15201526705 0020436 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file rc_binomial_heap_/split_join_fn_imps.hpp
* Contains an implementation for rc_binomial_heap_.
*/
PB_DS_CLASS_T_DEC
template<typename Pred>
void
PB_DS_CLASS_C_DEC::
split(Pred pred, PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
make_binomial_heap();
other.make_binomial_heap();
base_type::split(pred, other);
base_type::find_max();
other.find_max();
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
join(PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
make_binomial_heap();
other.make_binomial_heap();
base_type::join(other);
base_type::find_max();
other.find_max();
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
c++/8/ext/pb_ds/detail/rc_binomial_heap_/insert_fn_imps.hpp 0000644 00000010215 15201526705 0017560 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file rc_binomial_heap_/insert_fn_imps.hpp
* Contains an implementation for rc_binomial_heap_.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC::
push(const_reference r_val)
{
PB_DS_ASSERT_VALID((*this))
make_0_exposed();
PB_DS_ASSERT_VALID((*this))
node_pointer p_nd = base_type::get_new_node_for_insert(r_val);
p_nd->m_p_l_child = p_nd->m_p_prev_or_parent = 0;
p_nd->m_metadata = 0;
if (base_type::m_p_max == 0 || Cmp_Fn::operator()(base_type::m_p_max->m_value, r_val))
base_type::m_p_max = p_nd;
p_nd->m_p_next_sibling = base_type::m_p_root;
if (base_type::m_p_root != 0)
base_type::m_p_root->m_p_prev_or_parent = p_nd;
base_type::m_p_root = p_nd;
if (p_nd->m_p_next_sibling != 0&& p_nd->m_p_next_sibling->m_metadata == 0)
m_rc.push(p_nd);
PB_DS_ASSERT_VALID((*this))
return point_iterator(p_nd);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
modify(point_iterator it, const_reference r_new_val)
{
PB_DS_ASSERT_VALID((*this))
make_binomial_heap();
base_type::modify(it, r_new_val);
base_type::find_max();
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
link_with_next_sibling(node_pointer p_nd)
{
node_pointer p_next = p_nd->m_p_next_sibling;
_GLIBCXX_DEBUG_ASSERT(p_next != 0);
_GLIBCXX_DEBUG_ASSERT(p_next->m_p_prev_or_parent == p_nd);
if (Cmp_Fn::operator()(p_nd->m_value, p_next->m_value))
{
p_next->m_p_prev_or_parent = p_nd->m_p_prev_or_parent;
if (p_next->m_p_prev_or_parent == 0)
base_type::m_p_root = p_next;
else
p_next->m_p_prev_or_parent->m_p_next_sibling = p_next;
if (base_type::m_p_max == p_nd)
base_type::m_p_max = p_next;
base_type::make_child_of(p_nd, p_next);
++p_next->m_metadata;
return p_next;
}
p_nd->m_p_next_sibling = p_next->m_p_next_sibling;
if (p_nd->m_p_next_sibling != 0)
p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd;
if (base_type::m_p_max == p_next)
base_type::m_p_max = p_nd;
base_type::make_child_of(p_next, p_nd);
++p_nd->m_metadata;
return p_nd;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
make_0_exposed()
{
if (m_rc.empty())
return;
node_pointer p_nd = m_rc.top();
m_rc.pop();
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_next_sibling != 0);
_GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata == p_nd->m_p_next_sibling->m_metadata);
node_pointer p_res = link_with_next_sibling(p_nd);
if (p_res->m_p_next_sibling != 0&& p_res->m_metadata == p_res->m_p_next_sibling->m_metadata)
m_rc.push(p_res);
}
c++/8/ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp 0000644 00000005511 15201526705 0017356 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file rc_binomial_heap_/erase_fn_imps.hpp
* Contains an implementation for rc_binomial_heap_.
*/
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
pop()
{
make_binomial_heap();
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
base_type::pop();
base_type::find_max();
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
clear()
{
base_type::clear();
m_rc.clear();
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
make_binomial_heap()
{
node_pointer p_nd = base_type::m_p_root;
while (p_nd != 0)
{
node_pointer p_next = p_nd->m_p_next_sibling;
if (p_next == 0)
p_nd = p_next;
else if (p_nd->m_metadata == p_next->m_metadata)
p_nd = link_with_next_sibling(p_nd);
else if (p_nd->m_metadata < p_next->m_metadata)
p_nd = p_next;
#ifdef _GLIBCXX_DEBUG
else
_GLIBCXX_DEBUG_ASSERT(0);
#endif
}
m_rc.clear();
}
PB_DS_CLASS_T_DEC
template<typename Pred>
typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
erase_if(Pred pred)
{
make_binomial_heap();
const size_type ersd = base_type::erase_if(pred);
base_type::find_max();
PB_DS_ASSERT_VALID((*this))
return ersd;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
erase(point_iterator it)
{
make_binomial_heap();
base_type::erase(it);
base_type::find_max();
}
c++/8/ext/pb_ds/detail/rc_binomial_heap_/trace_fn_imps.hpp 0000644 00000003560 15201526705 0017357 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file rc_binomial_heap_/trace_fn_imps.hpp
* Contains an implementation for rc_binomial_heap_.
*/
#ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
trace() const
{
base_type::trace();
m_rc.trace();
}
#endif // #ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_
c++/8/ext/pb_ds/detail/cond_dealtor.hpp 0000644 00000005244 15201526705 0013572 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file detail/cond_dealtor.hpp
* Contains a conditional deallocator.
*/
#ifndef PB_DS_COND_DEALTOR_HPP
#define PB_DS_COND_DEALTOR_HPP
namespace __gnu_pbds
{
namespace detail
{
/// Conditional deallocate constructor argument.
template<typename Entry, typename _Alloc>
class cond_dealtor
{
typedef typename _Alloc::template rebind<Entry> __rebind_e;
public:
typedef typename __rebind_e::other entry_allocator;
typedef typename entry_allocator::pointer entry_pointer;
cond_dealtor(entry_pointer p_e)
: m_p_e(p_e), m_no_action_destructor(false) { }
~cond_dealtor()
{
if (m_no_action_destructor)
return;
s_alloc.deallocate(m_p_e, 1);
}
void
set_no_action()
{ m_no_action_destructor = true; }
private:
entry_pointer m_p_e;
bool m_no_action_destructor;
static entry_allocator s_alloc;
};
template<typename Entry, class _Alloc>
typename cond_dealtor<Entry, _Alloc>::entry_allocator
cond_dealtor<Entry, _Alloc>::s_alloc;
} // namespace detail
} // namespace __gnu_pbds
#endif // #ifndef PB_DS_COND_DEALTOR_HPP
c++/8/ext/pb_ds/detail/pat_trie_/split_fn_imps.hpp 0000644 00000017055 15201526705 0015754 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file pat_trie_/split_fn_imps.hpp
* Contains an implementation class for pat_trie.
*/
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
split(key_const_reference r_key, PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
branch_bag bag;
leaf_pointer p_split_lf = split_prep(r_key, other, bag);
if (p_split_lf == 0)
{
_GLIBCXX_DEBUG_ASSERT(bag.empty());
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
return;
}
_GLIBCXX_DEBUG_ASSERT(!bag.empty());
other.clear();
m_p_head->m_p_parent = rec_split(m_p_head->m_p_parent, pref_begin(p_split_lf),
pref_end(p_split_lf), other, bag);
m_p_head->m_p_parent->m_p_parent = m_p_head;
head_pointer __ohead = other.m_p_head;
__ohead->m_p_max = m_p_head->m_p_max;
m_p_head->m_p_max = rightmost_descendant(m_p_head->m_p_parent);
__ohead->m_p_min = other.leftmost_descendant(__ohead->m_p_parent);
other.m_size = std::distance(other.PB_DS_CLASS_C_DEC::begin(),
other.PB_DS_CLASS_C_DEC::end());
m_size -= other.m_size;
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::leaf_pointer
PB_DS_CLASS_C_DEC::
split_prep(key_const_reference r_key, PB_DS_CLASS_C_DEC& other,
branch_bag& r_bag)
{
_GLIBCXX_DEBUG_ASSERT(r_bag.empty());
if (m_size == 0)
{
other.clear();
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
return 0;
}
if (synth_access_traits::cmp_keys(r_key,
PB_DS_V2F(static_cast<leaf_const_pointer>(m_p_head->m_p_min)->value())))
{
other.clear();
value_swap(other);
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
return 0;
}
if (!synth_access_traits::cmp_keys(r_key,
PB_DS_V2F(static_cast<leaf_const_pointer>(m_p_head->m_p_max)->value())))
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
return 0;
}
iterator it = lower_bound(r_key);
if (!synth_access_traits::equal_keys(PB_DS_V2F(*it), r_key))
--it;
node_pointer p_nd = it.m_p_nd;
_GLIBCXX_DEBUG_ASSERT(p_nd->m_type == leaf_node);
leaf_pointer p_ret_l = static_cast<leaf_pointer>(p_nd);
while (p_nd->m_type != head_node)
{
r_bag.add_branch();
p_nd = p_nd->m_p_parent;
}
_GLIBCXX_DEBUG_ONLY(debug_base::split(r_key,(synth_access_traits&)(*this), other);)
return p_ret_l;
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
rec_split(node_pointer p_nd, a_const_iterator b_it, a_const_iterator e_it,
PB_DS_CLASS_C_DEC& other, branch_bag& r_bag)
{
if (p_nd->m_type == leaf_node)
{
_GLIBCXX_DEBUG_ASSERT(other.m_p_head->m_p_parent == 0);
return p_nd;
}
_GLIBCXX_DEBUG_ASSERT(p_nd->m_type == i_node);
inode_pointer p_ind = static_cast<inode_pointer>(p_nd);
node_pointer pfirst = p_ind->get_child_node(b_it, e_it, this);
node_pointer p_child_ret = rec_split(pfirst, b_it, e_it, other, r_bag);
PB_DS_ASSERT_NODE_VALID(p_child_ret)
p_ind->replace_child(p_child_ret, b_it, e_it, this);
apply_update(p_ind, (node_update*)this);
inode_iterator child_it = p_ind->get_child_it(b_it, e_it, this);
const size_type lhs_dist = std::distance(p_ind->begin(), child_it);
const size_type lhs_num_children = lhs_dist + 1;
_GLIBCXX_DEBUG_ASSERT(lhs_num_children > 0);
const size_type rhs_dist = std::distance(p_ind->begin(), p_ind->end());
size_type rhs_num_children = rhs_dist - lhs_num_children;
if (rhs_num_children == 0)
{
apply_update(p_ind, (node_update*)this);
return p_ind;
}
other.split_insert_branch(p_ind->get_e_ind(), b_it, child_it,
rhs_num_children, r_bag);
child_it = p_ind->get_child_it(b_it, e_it, this);
while (rhs_num_children != 0)
{
++child_it;
p_ind->remove_child(child_it);
--rhs_num_children;
}
apply_update(p_ind, (node_update*)this);
const size_type int_dist = std::distance(p_ind->begin(), p_ind->end());
_GLIBCXX_DEBUG_ASSERT(int_dist >= 1);
if (int_dist > 1)
{
p_ind->update_prefixes(this);
PB_DS_ASSERT_NODE_VALID(p_ind)
apply_update(p_ind, (node_update*)this);
return p_ind;
}
node_pointer p_ret = *p_ind->begin();
p_ind->~inode();
s_inode_allocator.deallocate(p_ind, 1);
apply_update(p_ret, (node_update*)this);
return p_ret;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
split_insert_branch(size_type e_ind, a_const_iterator b_it,
inode_iterator child_b_it,
size_type num_children, branch_bag& r_bag)
{
#ifdef _GLIBCXX_DEBUG
if (m_p_head->m_p_parent != 0)
PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent)
#endif
const size_type start = m_p_head->m_p_parent == 0 ? 0 : 1;
const size_type total_num_children = start + num_children;
if (total_num_children == 0)
{
_GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_parent == 0);
return;
}
if (total_num_children == 1)
{
if (m_p_head->m_p_parent != 0)
{
PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent)
return;
}
_GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_parent == 0);
++child_b_it;
m_p_head->m_p_parent = *child_b_it;
m_p_head->m_p_parent->m_p_parent = m_p_head;
apply_update(m_p_head->m_p_parent, (node_update*)this);
PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent)
return;
}
_GLIBCXX_DEBUG_ASSERT(total_num_children > 1);
inode_pointer p_new_root = r_bag.get_branch();
new (p_new_root) inode(e_ind, b_it);
size_type num_inserted = 0;
while (num_inserted++ < num_children)
{
++child_b_it;
PB_DS_ASSERT_NODE_VALID((*child_b_it))
p_new_root->add_child(*child_b_it, pref_begin(*child_b_it),
pref_end(*child_b_it), this);
}
if (m_p_head->m_p_parent != 0)
p_new_root->add_child(m_p_head->m_p_parent,
pref_begin(m_p_head->m_p_parent),
pref_end(m_p_head->m_p_parent), this);
m_p_head->m_p_parent = p_new_root;
p_new_root->m_p_parent = m_p_head;
apply_update(m_p_head->m_p_parent, (node_update*)this);
PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent)
}
c++/8/ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp 0000644 00000034213 15201526705 0017137 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file pat_trie_/insert_join_fn_imps.hpp
* Contains an implementation class for pat_trie.
*/
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
join(PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
branch_bag bag;
if (!join_prep(other, bag))
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
return;
}
m_p_head->m_p_parent = rec_join(m_p_head->m_p_parent,
other.m_p_head->m_p_parent, 0, bag);
m_p_head->m_p_parent->m_p_parent = m_p_head;
m_size += other.m_size;
other.initialize();
PB_DS_ASSERT_VALID(other)
m_p_head->m_p_min = leftmost_descendant(m_p_head->m_p_parent);
m_p_head->m_p_max = rightmost_descendant(m_p_head->m_p_parent);
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
bool
PB_DS_CLASS_C_DEC::
join_prep(PB_DS_CLASS_C_DEC& other, branch_bag& r_bag)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
if (other.m_size == 0)
return false;
if (m_size == 0)
{
value_swap(other);
return false;
}
const bool greater =
synth_access_traits::cmp_keys(PB_DS_V2F(static_cast<leaf_const_pointer>(m_p_head->m_p_max)->value()),
PB_DS_V2F(static_cast<leaf_const_pointer>(other.m_p_head->m_p_min)->value()));
const bool lesser =
synth_access_traits::cmp_keys(PB_DS_V2F(static_cast<leaf_const_pointer>(other.m_p_head->m_p_max)->value()),
PB_DS_V2F(static_cast<leaf_const_pointer>(m_p_head->m_p_min)->value()));
if (!greater && !lesser)
__throw_join_error();
rec_join_prep(m_p_head->m_p_parent, other.m_p_head->m_p_parent, r_bag);
_GLIBCXX_DEBUG_ONLY(debug_base::join(other, false);)
return true;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
rec_join_prep(node_const_pointer p_l, node_const_pointer p_r,
branch_bag& r_bag)
{
if (p_l->m_type == leaf_node)
{
if (p_r->m_type == leaf_node)
{
rec_join_prep(static_cast<leaf_const_pointer>(p_l),
static_cast<leaf_const_pointer>(p_r), r_bag);
return;
}
_GLIBCXX_DEBUG_ASSERT(p_r->m_type == i_node);
rec_join_prep(static_cast<leaf_const_pointer>(p_l),
static_cast<inode_const_pointer>(p_r), r_bag);
return;
}
_GLIBCXX_DEBUG_ASSERT(p_l->m_type == i_node);
if (p_r->m_type == leaf_node)
{
rec_join_prep(static_cast<inode_const_pointer>(p_l),
static_cast<leaf_const_pointer>(p_r), r_bag);
return;
}
_GLIBCXX_DEBUG_ASSERT(p_r->m_type == i_node);
rec_join_prep(static_cast<inode_const_pointer>(p_l),
static_cast<inode_const_pointer>(p_r), r_bag);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
rec_join_prep(leaf_const_pointer /*p_l*/, leaf_const_pointer /*p_r*/,
branch_bag& r_bag)
{ r_bag.add_branch(); }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
rec_join_prep(leaf_const_pointer /*p_l*/, inode_const_pointer /*p_r*/,
branch_bag& r_bag)
{ r_bag.add_branch(); }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
rec_join_prep(inode_const_pointer /*p_l*/, leaf_const_pointer /*p_r*/,
branch_bag& r_bag)
{ r_bag.add_branch(); }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
rec_join_prep(inode_const_pointer p_l, inode_const_pointer p_r,
branch_bag& r_bag)
{
if (p_l->get_e_ind() == p_r->get_e_ind() &&
synth_access_traits::equal_prefixes(p_l->pref_b_it(), p_l->pref_e_it(),
p_r->pref_b_it(), p_r->pref_e_it()))
{
for (typename inode::const_iterator it = p_r->begin();
it != p_r->end(); ++ it)
{
node_const_pointer p_l_join_child = p_l->get_join_child(*it, this);
if (p_l_join_child != 0)
rec_join_prep(p_l_join_child, * it, r_bag);
}
return;
}
if (p_r->get_e_ind() < p_l->get_e_ind() &&
p_r->should_be_mine(p_l->pref_b_it(), p_l->pref_e_it(), 0, this))
{
node_const_pointer p_r_join_child = p_r->get_join_child(p_l, this);
if (p_r_join_child != 0)
rec_join_prep(p_r_join_child, p_l, r_bag);
return;
}
if (p_r->get_e_ind() < p_l->get_e_ind() &&
p_r->should_be_mine(p_l->pref_b_it(), p_l->pref_e_it(), 0, this))
{
node_const_pointer p_r_join_child = p_r->get_join_child(p_l, this);
if (p_r_join_child != 0)
rec_join_prep(p_r_join_child, p_l, r_bag);
return;
}
r_bag.add_branch();
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
rec_join(node_pointer p_l, node_pointer p_r, size_type checked_ind,
branch_bag& r_bag)
{
_GLIBCXX_DEBUG_ASSERT(p_r != 0);
if (p_l == 0)
{
apply_update(p_r, (node_update*)this);
return (p_r);
}
if (p_l->m_type == leaf_node)
{
if (p_r->m_type == leaf_node)
{
node_pointer p_ret = rec_join(static_cast<leaf_pointer>(p_l),
static_cast<leaf_pointer>(p_r), r_bag);
apply_update(p_ret, (node_update*)this);
return p_ret;
}
_GLIBCXX_DEBUG_ASSERT(p_r->m_type == i_node);
node_pointer p_ret = rec_join(static_cast<leaf_pointer>(p_l),
static_cast<inode_pointer>(p_r),
checked_ind, r_bag);
apply_update(p_ret, (node_update*)this);
return p_ret;
}
_GLIBCXX_DEBUG_ASSERT(p_l->m_type == i_node);
if (p_r->m_type == leaf_node)
{
node_pointer p_ret = rec_join(static_cast<inode_pointer>(p_l),
static_cast<leaf_pointer>(p_r),
checked_ind, r_bag);
apply_update(p_ret, (node_update*)this);
return p_ret;
}
_GLIBCXX_DEBUG_ASSERT(p_r->m_type == i_node);
node_pointer p_ret = rec_join(static_cast<inode_pointer>(p_l),
static_cast<inode_pointer>(p_r),
r_bag);
apply_update(p_ret, (node_update*)this);
return p_ret;
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
rec_join(leaf_pointer p_l, leaf_pointer p_r, branch_bag& r_bag)
{
_GLIBCXX_DEBUG_ASSERT(p_r != 0);
if (p_l == 0)
return (p_r);
node_pointer p_ret = insert_branch(p_l, p_r, r_bag);
_GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_ret) == 2);
return p_ret;
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
rec_join(leaf_pointer p_l, inode_pointer p_r, size_type checked_ind,
branch_bag& r_bag)
{
#ifdef _GLIBCXX_DEBUG
const size_type lhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_l);
const size_type rhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_r);
#endif
_GLIBCXX_DEBUG_ASSERT(p_r != 0);
node_pointer p_ret = rec_join(p_r, p_l, checked_ind, r_bag);
_GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_ret) == lhs_leafs + rhs_leafs);
return p_ret;
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
rec_join(inode_pointer p_l, leaf_pointer p_r, size_type checked_ind, branch_bag& r_bag)
{
_GLIBCXX_DEBUG_ASSERT(p_l != 0);
_GLIBCXX_DEBUG_ASSERT(p_r != 0);
#ifdef _GLIBCXX_DEBUG
const size_type lhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_l);
const size_type rhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_r);
#endif
if (!p_l->should_be_mine(pref_begin(p_r), pref_end(p_r), checked_ind, this))
{
node_pointer p_ret = insert_branch(p_l, p_r, r_bag);
PB_DS_ASSERT_NODE_VALID(p_ret)
_GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_ret) ==
lhs_leafs + rhs_leafs);
return p_ret;
}
node_pointer p_pot_child = p_l->add_child(p_r, pref_begin(p_r),
pref_end(p_r), this);
if (p_pot_child != p_r)
{
node_pointer p_new_child = rec_join(p_pot_child, p_r, p_l->get_e_ind(),
r_bag);
p_l->replace_child(p_new_child, pref_begin(p_new_child),
pref_end(p_new_child), this);
}
PB_DS_ASSERT_NODE_VALID(p_l)
_GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_l) == lhs_leafs + rhs_leafs);
return p_l;
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
rec_join(inode_pointer p_l, inode_pointer p_r,
branch_bag& r_bag)
{
_GLIBCXX_DEBUG_ASSERT(p_l != 0);
_GLIBCXX_DEBUG_ASSERT(p_r != 0);
#ifdef _GLIBCXX_DEBUG
const size_type lhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_l);
const size_type rhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_r);
#endif
if (p_l->get_e_ind() == p_r->get_e_ind() &&
synth_access_traits::equal_prefixes(p_l->pref_b_it(), p_l->pref_e_it(),
p_r->pref_b_it(), p_r->pref_e_it()))
{
for (typename inode::iterator it = p_r->begin();
it != p_r->end(); ++ it)
{
node_pointer p_new_child = rec_join(p_l->get_join_child(*it, this),
* it, 0, r_bag);
p_l->replace_child(p_new_child, pref_begin(p_new_child),
pref_end(p_new_child), this);
}
p_r->~inode();
s_inode_allocator.deallocate(p_r, 1);
PB_DS_ASSERT_NODE_VALID(p_l)
_GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_l) == lhs_leafs + rhs_leafs);
return p_l;
}
if (p_l->get_e_ind() < p_r->get_e_ind() &&
p_l->should_be_mine(p_r->pref_b_it(), p_r->pref_e_it(), 0, this))
{
node_pointer p_new_child = rec_join(p_l->get_join_child(p_r, this),
p_r, 0, r_bag);
p_l->replace_child(p_new_child, pref_begin(p_new_child),
pref_end(p_new_child), this);
PB_DS_ASSERT_NODE_VALID(p_l)
return p_l;
}
if (p_r->get_e_ind() < p_l->get_e_ind() &&
p_r->should_be_mine(p_l->pref_b_it(), p_l->pref_e_it(), 0, this))
{
node_pointer p_new_child = rec_join(p_r->get_join_child(p_l, this), p_l,
0, r_bag);
p_r->replace_child(p_new_child, pref_begin(p_new_child),
pref_end(p_new_child), this);
PB_DS_ASSERT_NODE_VALID(p_r)
_GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_r) == lhs_leafs + rhs_leafs);
return p_r;
}
node_pointer p_ret = insert_branch(p_l, p_r, r_bag);
PB_DS_ASSERT_NODE_VALID(p_ret)
_GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_ret) == lhs_leafs + rhs_leafs);
return p_ret;
}
PB_DS_CLASS_T_DEC
inline std::pair<typename PB_DS_CLASS_C_DEC::iterator, bool>
PB_DS_CLASS_C_DEC::
insert(const_reference r_val)
{
node_pointer p_lf = find_imp(PB_DS_V2F(r_val));
if (p_lf != 0 && p_lf->m_type == leaf_node &&
synth_access_traits::equal_keys(PB_DS_V2F(static_cast<leaf_pointer>(p_lf)->value()), PB_DS_V2F(r_val)))
{
PB_DS_CHECK_KEY_EXISTS(PB_DS_V2F(r_val))
PB_DS_ASSERT_VALID((*this))
return std::make_pair(iterator(p_lf), false);
}
PB_DS_CHECK_KEY_DOES_NOT_EXIST(PB_DS_V2F(r_val))
leaf_pointer p_new_lf = s_leaf_allocator.allocate(1);
cond_dealtor cond(p_new_lf);
new (p_new_lf) leaf(r_val);
apply_update(p_new_lf, (node_update*)this);
cond.set_call_destructor();
branch_bag bag;
bag.add_branch();
m_p_head->m_p_parent = rec_join(m_p_head->m_p_parent, p_new_lf, 0, bag);
m_p_head->m_p_parent->m_p_parent = m_p_head;
cond.set_no_action_dtor();
++m_size;
update_min_max_for_inserted_leaf(p_new_lf);
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_val));)
PB_DS_ASSERT_VALID((*this))
return std::make_pair(point_iterator(p_new_lf), true);
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
keys_diff_ind(typename access_traits::const_iterator b_l,
typename access_traits::const_iterator e_l,
typename access_traits::const_iterator b_r,
typename access_traits::const_iterator e_r)
{
size_type diff_pos = 0;
while (b_l != e_l)
{
if (b_r == e_r)
return (diff_pos);
if (access_traits::e_pos(*b_l) != access_traits::e_pos(*b_r))
return (diff_pos);
++b_l;
++b_r;
++diff_pos;
}
_GLIBCXX_DEBUG_ASSERT(b_r != e_r);
return diff_pos;
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::inode_pointer
PB_DS_CLASS_C_DEC::
insert_branch(node_pointer p_l, node_pointer p_r, branch_bag& r_bag)
{
typename synth_access_traits::const_iterator left_b_it = pref_begin(p_l);
typename synth_access_traits::const_iterator left_e_it = pref_end(p_l);
typename synth_access_traits::const_iterator right_b_it = pref_begin(p_r);
typename synth_access_traits::const_iterator right_e_it = pref_end(p_r);
const size_type diff_ind = keys_diff_ind(left_b_it, left_e_it,
right_b_it, right_e_it);
inode_pointer p_new_nd = r_bag.get_branch();
new (p_new_nd) inode(diff_ind, left_b_it);
p_new_nd->add_child(p_l, left_b_it, left_e_it, this);
p_new_nd->add_child(p_r, right_b_it, right_e_it, this);
p_l->m_p_parent = p_new_nd;
p_r->m_p_parent = p_new_nd;
PB_DS_ASSERT_NODE_VALID(p_new_nd)
return (p_new_nd);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
update_min_max_for_inserted_leaf(leaf_pointer p_new_lf)
{
if (m_p_head->m_p_min == m_p_head ||
synth_access_traits::cmp_keys(PB_DS_V2F(p_new_lf->value()),
PB_DS_V2F(static_cast<leaf_const_pointer>(m_p_head->m_p_min)->value())))
m_p_head->m_p_min = p_new_lf;
if (m_p_head->m_p_max == m_p_head ||
synth_access_traits::cmp_keys(PB_DS_V2F(static_cast<leaf_const_pointer>(m_p_head->m_p_max)->value()), PB_DS_V2F(p_new_lf->value())))
m_p_head->m_p_max = p_new_lf;
}
c++/8/ext/pb_ds/detail/pat_trie_/info_fn_imps.hpp 0000644 00000004010 15201526705 0015537 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file pat_trie_/info_fn_imps.hpp
* Contains an implementation class for pat_trie.
*/
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
empty() const
{ return (m_size == 0); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
size() const
{ return m_size; }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
max_size() const
{ return s_inode_allocator.max_size(); }
c++/8/ext/pb_ds/detail/pat_trie_/constructors_destructor_fn_imps.hpp 0000644 00000013120 15201526705 0021634 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file pat_trie_/constructors_destructor_fn_imps.hpp
* Contains an implementation class for pat_trie.
*/
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::head_allocator
PB_DS_CLASS_C_DEC::s_head_allocator;
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::inode_allocator
PB_DS_CLASS_C_DEC::s_inode_allocator;
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::leaf_allocator
PB_DS_CLASS_C_DEC::s_leaf_allocator;
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_PAT_TRIE_NAME() :
m_p_head(s_head_allocator.allocate(1)),
m_size(0)
{
initialize();
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_PAT_TRIE_NAME(const access_traits& r_access_traits) :
synth_access_traits(r_access_traits),
m_p_head(s_head_allocator.allocate(1)),
m_size(0)
{
initialize();
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_PAT_TRIE_NAME(const PB_DS_CLASS_C_DEC& other) :
#ifdef _GLIBCXX_DEBUG
debug_base(other),
#endif
synth_access_traits(other),
node_update(other),
m_p_head(s_head_allocator.allocate(1)),
m_size(0)
{
initialize();
m_size = other.m_size;
PB_DS_ASSERT_VALID(other)
if (other.m_p_head->m_p_parent == 0)
{
PB_DS_ASSERT_VALID((*this))
return;
}
__try
{
m_p_head->m_p_parent = recursive_copy_node(other.m_p_head->m_p_parent);
}
__catch(...)
{
s_head_allocator.deallocate(m_p_head, 1);
__throw_exception_again;
}
m_p_head->m_p_min = leftmost_descendant(m_p_head->m_p_parent);
m_p_head->m_p_max = rightmost_descendant(m_p_head->m_p_parent);
m_p_head->m_p_parent->m_p_parent = m_p_head;
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
value_swap(other);
std::swap((access_traits& )(*this), (access_traits& )other);
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
value_swap(PB_DS_CLASS_C_DEC& other)
{
_GLIBCXX_DEBUG_ONLY(debug_base::swap(other);)
std::swap(m_p_head, other.m_p_head);
std::swap(m_size, other.m_size);
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
~PB_DS_PAT_TRIE_NAME()
{
clear();
s_head_allocator.deallocate(m_p_head, 1);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
initialize()
{
new (m_p_head) head();
m_p_head->m_p_parent = 0;
m_p_head->m_p_min = m_p_head;
m_p_head->m_p_max = m_p_head;
m_size = 0;
}
PB_DS_CLASS_T_DEC
template<typename It>
void
PB_DS_CLASS_C_DEC::
copy_from_range(It first_it, It last_it)
{
while (first_it != last_it)
insert(*(first_it++));
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
recursive_copy_node(node_const_pointer p_ncp)
{
_GLIBCXX_DEBUG_ASSERT(p_ncp != 0);
if (p_ncp->m_type == leaf_node)
{
leaf_const_pointer p_other_lf = static_cast<leaf_const_pointer>(p_ncp);
leaf_pointer p_new_lf = s_leaf_allocator.allocate(1);
cond_dealtor cond(p_new_lf);
new (p_new_lf) leaf(p_other_lf->value());
apply_update(p_new_lf, (node_update*)this);
cond.set_no_action_dtor();
return (p_new_lf);
}
_GLIBCXX_DEBUG_ASSERT(p_ncp->m_type == i_node);
node_pointer a_p_children[inode::arr_size];
size_type child_i = 0;
inode_const_pointer p_icp = static_cast<inode_const_pointer>(p_ncp);
typename inode::const_iterator child_it = p_icp->begin();
inode_pointer p_ret;
__try
{
while (child_it != p_icp->end())
{
a_p_children[child_i] = recursive_copy_node(*(child_it));
child_i++;
child_it++;
}
p_ret = s_inode_allocator.allocate(1);
}
__catch(...)
{
while (child_i-- > 0)
clear_imp(a_p_children[child_i]);
__throw_exception_again;
}
new (p_ret) inode(p_icp->get_e_ind(), pref_begin(a_p_children[0]));
--child_i;
_GLIBCXX_DEBUG_ASSERT(child_i >= 1);
do
p_ret->add_child(a_p_children[child_i], pref_begin(a_p_children[child_i]),
pref_end(a_p_children[child_i]), this);
while (child_i-- > 0);
apply_update(p_ret, (node_update*)this);
return p_ret;
}
c++/8/ext/pb_ds/detail/pat_trie_/iterators_fn_imps.hpp 0000644 00000006630 15201526705 0016632 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file pat_trie_/iterators_fn_imps.hpp
* Contains an implementation class for pat_trie.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
begin()
{ return iterator(m_p_head->m_p_min); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
begin() const
{ return const_iterator(m_p_head->m_p_min); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
end()
{ return iterator(m_p_head); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
end() const
{ return const_iterator(m_p_head); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_reverse_iterator
PB_DS_CLASS_C_DEC::
rbegin() const
{
if (empty())
return rend();
return --end();
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::reverse_iterator
PB_DS_CLASS_C_DEC::
rbegin()
{
if (empty())
return rend();
return --end();
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::reverse_iterator
PB_DS_CLASS_C_DEC::
rend()
{ return reverse_iterator(m_p_head); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_reverse_iterator
PB_DS_CLASS_C_DEC::
rend() const
{ return const_reverse_iterator(m_p_head); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_const_iterator
PB_DS_CLASS_C_DEC::
node_begin() const
{ return node_const_iterator(m_p_head->m_p_parent, this); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_iterator
PB_DS_CLASS_C_DEC::
node_begin()
{ return node_iterator(m_p_head->m_p_parent, this); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_const_iterator
PB_DS_CLASS_C_DEC::
node_end() const
{ return node_const_iterator(0, this); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_iterator
PB_DS_CLASS_C_DEC::
node_end()
{ return node_iterator(0, this); }
c++/8/ext/pb_ds/detail/pat_trie_/debug_fn_imps.hpp 0000644 00000007317 15201526705 0015707 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file pat_trie_/debug_fn_imps.hpp
* Contains an implementation class for pat_trie_.
*/
#ifdef _GLIBCXX_DEBUG
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_valid(const char* __file, int __line) const
{
if (m_p_head->m_p_parent != 0)
m_p_head->m_p_parent->assert_valid(this, __file, __line);
assert_iterators(__file, __line);
assert_reverse_iterators(__file, __line);
if (m_p_head->m_p_parent == 0)
{
PB_DS_DEBUG_VERIFY(m_p_head->m_p_min == m_p_head);
PB_DS_DEBUG_VERIFY(m_p_head->m_p_max == m_p_head);
PB_DS_DEBUG_VERIFY(empty());
return;
}
PB_DS_DEBUG_VERIFY(m_p_head->m_p_min->m_type == leaf_node);
PB_DS_DEBUG_VERIFY(m_p_head->m_p_max->m_type == leaf_node);
PB_DS_DEBUG_VERIFY(!empty());
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_iterators(const char* __file, int __line) const
{
size_type calc_size = 0;
for (const_iterator it = begin(); it != end(); ++it)
{
++calc_size;
debug_base::check_key_exists(PB_DS_V2F(*it), __file, __line);
PB_DS_DEBUG_VERIFY(lower_bound(PB_DS_V2F(*it)) == it);
PB_DS_DEBUG_VERIFY(--upper_bound(PB_DS_V2F(*it)) == it);
}
PB_DS_DEBUG_VERIFY(calc_size == m_size);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_reverse_iterators(const char* __file, int __line) const
{
size_type calc_size = 0;
for (const_reverse_iterator it = rbegin(); it != rend(); ++it)
{
++calc_size;
node_const_pointer p_nd =
const_cast<PB_DS_CLASS_C_DEC*>(this)->find_imp(PB_DS_V2F(*it));
PB_DS_DEBUG_VERIFY(p_nd == it.m_p_nd);
}
PB_DS_DEBUG_VERIFY(calc_size == m_size);
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
recursive_count_leafs(node_const_pointer p_nd, const char* __file, int __line)
{
if (p_nd == 0)
return (0);
if (p_nd->m_type == leaf_node)
return (1);
PB_DS_DEBUG_VERIFY(p_nd->m_type == i_node);
size_type ret = 0;
for (typename inode::const_iterator it = static_cast<inode_const_pointer>(p_nd)->begin();
it != static_cast<inode_const_pointer>(p_nd)->end();
++it)
ret += recursive_count_leafs(*it, __file, __line);
return ret;
}
#endif
c++/8/ext/pb_ds/detail/pat_trie_/pat_trie_base.hpp 0000644 00000111401 15201526705 0015675 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file pat_trie_/pat_trie_base.hpp
* Contains the base class for a patricia tree.
*/
#ifndef PB_DS_PAT_TRIE_BASE
#define PB_DS_PAT_TRIE_BASE
#include <debug/debug.h>
namespace __gnu_pbds
{
namespace detail
{
/// Base type for PATRICIA trees.
struct pat_trie_base
{
/**
* @brief Three types of nodes.
*
* i_node is used by _Inode, leaf_node by _Leaf, and head_node by _Head.
*/
enum node_type
{
i_node,
leaf_node,
head_node
};
/// Metadata base primary template.
template<typename Metadata, typename _Alloc>
struct _Metadata
{
typedef Metadata metadata_type;
typedef _Alloc allocator_type;
typedef typename _Alloc::template rebind<Metadata> __rebind_m;
typedef typename __rebind_m::other::const_reference const_reference;
const_reference
get_metadata() const
{ return m_metadata; }
metadata_type m_metadata;
};
/// Specialization for null metadata.
template<typename _Alloc>
struct _Metadata<null_type, _Alloc>
{
typedef null_type metadata_type;
typedef _Alloc allocator_type;
};
/// Node base.
template<typename _ATraits, typename Metadata>
struct _Node_base
: public Metadata
{
private:
typedef typename Metadata::allocator_type _Alloc;
public:
typedef _Alloc allocator_type;
typedef _ATraits access_traits;
typedef typename _ATraits::type_traits type_traits;
typedef typename _Alloc::template rebind<_Node_base> __rebind_n;
typedef typename __rebind_n::other::pointer node_pointer;
node_pointer m_p_parent;
const node_type m_type;
_Node_base(node_type type) : m_type(type)
{ }
typedef typename _Alloc::template rebind<_ATraits> __rebind_at;
typedef typename __rebind_at::other::const_pointer a_const_pointer;
typedef typename _ATraits::const_iterator a_const_iterator;
#ifdef _GLIBCXX_DEBUG
typedef std::pair<a_const_iterator, a_const_iterator> node_debug_info;
void
assert_valid(a_const_pointer p_traits,
const char* __file, int __line) const
{ assert_valid_imp(p_traits, __file, __line); }
virtual node_debug_info
assert_valid_imp(a_const_pointer, const char*, int) const = 0;
#endif
};
/// Head node for PATRICIA tree.
template<typename _ATraits, typename Metadata>
struct _Head
: public _Node_base<_ATraits, Metadata>
{
typedef _Node_base<_ATraits, Metadata> base_type;
typedef typename base_type::type_traits type_traits;
typedef typename base_type::node_pointer node_pointer;
node_pointer m_p_min;
node_pointer m_p_max;
_Head() : base_type(head_node) { }
#ifdef _GLIBCXX_DEBUG
typedef typename base_type::node_debug_info node_debug_info;
typedef typename base_type::a_const_pointer a_const_pointer;
virtual node_debug_info
assert_valid_imp(a_const_pointer, const char* __file, int __line) const
{
_GLIBCXX_DEBUG_VERIFY_AT(false,
_M_message("Assertion from %1;:%2;")
._M_string(__FILE__)._M_integer(__LINE__),
__file, __line);
return node_debug_info();
}
#endif
};
/// Leaf node for PATRICIA tree.
template<typename _ATraits, typename Metadata>
struct _Leaf
: public _Node_base<_ATraits, Metadata>
{
typedef _Node_base<_ATraits, Metadata> base_type;
typedef typename base_type::type_traits type_traits;
typedef typename type_traits::value_type value_type;
typedef typename type_traits::reference reference;
typedef typename type_traits::const_reference const_reference;
private:
value_type m_value;
_Leaf(const _Leaf&);
public:
_Leaf(const_reference other)
: base_type(leaf_node), m_value(other) { }
reference
value()
{ return m_value; }
const_reference
value() const
{ return m_value; }
#ifdef _GLIBCXX_DEBUG
typedef typename base_type::node_debug_info node_debug_info;
typedef typename base_type::a_const_pointer a_const_pointer;
virtual node_debug_info
assert_valid_imp(a_const_pointer p_traits,
const char* __file, int __line) const
{
PB_DS_DEBUG_VERIFY(base_type::m_type == leaf_node);
node_debug_info ret;
const_reference r_val = value();
return std::make_pair(p_traits->begin(p_traits->extract_key(r_val)),
p_traits->end(p_traits->extract_key(r_val)));
}
virtual
~_Leaf() { }
#endif
};
/// Internal node type, PATRICIA tree.
template<typename _ATraits, typename Metadata>
struct _Inode
: public _Node_base<_ATraits, Metadata>
{
typedef _Node_base<_ATraits, Metadata> base_type;
typedef typename base_type::type_traits type_traits;
typedef typename base_type::access_traits access_traits;
typedef typename type_traits::value_type value_type;
typedef typename base_type::allocator_type _Alloc;
typedef _Alloc allocator_type;
typedef typename _Alloc::size_type size_type;
private:
typedef typename base_type::a_const_pointer a_const_pointer;
typedef typename base_type::a_const_iterator a_const_iterator;
typedef typename base_type::node_pointer node_pointer;
typedef typename _Alloc::template rebind<base_type> __rebind_n;
typedef typename __rebind_n::other::const_pointer node_const_pointer;
typedef _Leaf<_ATraits, Metadata> leaf;
typedef typename _Alloc::template rebind<leaf>::other __rebind_l;
typedef typename __rebind_l::pointer leaf_pointer;
typedef typename __rebind_l::const_pointer leaf_const_pointer;
typedef typename _Alloc::template rebind<_Inode>::other __rebind_in;
typedef typename __rebind_in::pointer inode_pointer;
typedef typename __rebind_in::const_pointer inode_const_pointer;
inline size_type
get_pref_pos(a_const_iterator, a_const_iterator, a_const_pointer) const;
public:
typedef typename _Alloc::template rebind<node_pointer>::other __rebind_np;
typedef typename __rebind_np::pointer node_pointer_pointer;
typedef typename __rebind_np::reference node_pointer_reference;
enum
{
arr_size = _ATraits::max_size + 1
};
PB_DS_STATIC_ASSERT(min_arr_size, arr_size >= 2);
/// Constant child iterator.
struct const_iterator
{
node_pointer_pointer m_p_p_cur;
node_pointer_pointer m_p_p_end;
typedef std::forward_iterator_tag iterator_category;
typedef typename _Alloc::difference_type difference_type;
typedef node_pointer value_type;
typedef node_pointer_pointer pointer;
typedef node_pointer_reference reference;
const_iterator(node_pointer_pointer p_p_cur = 0,
node_pointer_pointer p_p_end = 0)
: m_p_p_cur(p_p_cur), m_p_p_end(p_p_end)
{ }
bool
operator==(const const_iterator& other) const
{ return m_p_p_cur == other.m_p_p_cur; }
bool
operator!=(const const_iterator& other) const
{ return m_p_p_cur != other.m_p_p_cur; }
const_iterator&
operator++()
{
do
++m_p_p_cur;
while (m_p_p_cur != m_p_p_end && *m_p_p_cur == 0);
return *this;
}
const_iterator
operator++(int)
{
const_iterator ret_it(*this);
operator++();
return ret_it;
}
const node_pointer_pointer
operator->() const
{
_GLIBCXX_DEBUG_ONLY(assert_referencible();)
return m_p_p_cur;
}
node_const_pointer
operator*() const
{
_GLIBCXX_DEBUG_ONLY(assert_referencible();)
return *m_p_p_cur;
}
protected:
#ifdef _GLIBCXX_DEBUG
void
assert_referencible() const
{ _GLIBCXX_DEBUG_ASSERT(m_p_p_cur != m_p_p_end && *m_p_p_cur != 0); }
#endif
};
/// Child iterator.
struct iterator : public const_iterator
{
public:
typedef std::forward_iterator_tag iterator_category;
typedef typename _Alloc::difference_type difference_type;
typedef node_pointer value_type;
typedef node_pointer_pointer pointer;
typedef node_pointer_reference reference;
inline
iterator(node_pointer_pointer p_p_cur = 0,
node_pointer_pointer p_p_end = 0)
: const_iterator(p_p_cur, p_p_end) { }
bool
operator==(const iterator& other) const
{ return const_iterator::m_p_p_cur == other.m_p_p_cur; }
bool
operator!=(const iterator& other) const
{ return const_iterator::m_p_p_cur != other.m_p_p_cur; }
iterator&
operator++()
{
const_iterator::operator++();
return *this;
}
iterator
operator++(int)
{
iterator ret_it(*this);
operator++();
return ret_it;
}
node_pointer_pointer
operator->()
{
_GLIBCXX_DEBUG_ONLY(const_iterator::assert_referencible();)
return const_iterator::m_p_p_cur;
}
node_pointer
operator*()
{
_GLIBCXX_DEBUG_ONLY(const_iterator::assert_referencible();)
return *const_iterator::m_p_p_cur;
}
};
_Inode(size_type, const a_const_iterator);
void
update_prefixes(a_const_pointer);
const_iterator
begin() const;
iterator
begin();
const_iterator
end() const;
iterator
end();
inline node_pointer
get_child_node(a_const_iterator, a_const_iterator, a_const_pointer);
inline node_const_pointer
get_child_node(a_const_iterator, a_const_iterator, a_const_pointer) const;
inline iterator
get_child_it(a_const_iterator, a_const_iterator, a_const_pointer);
inline node_pointer
get_lower_bound_child_node(a_const_iterator, a_const_iterator,
size_type, a_const_pointer);
inline node_pointer
add_child(node_pointer, a_const_iterator, a_const_iterator,
a_const_pointer);
inline node_const_pointer
get_join_child(node_const_pointer, a_const_pointer) const;
inline node_pointer
get_join_child(node_pointer, a_const_pointer);
void
remove_child(node_pointer);
void
remove_child(iterator);
void
replace_child(node_pointer, a_const_iterator, a_const_iterator,
a_const_pointer);
inline a_const_iterator
pref_b_it() const;
inline a_const_iterator
pref_e_it() const;
bool
should_be_mine(a_const_iterator, a_const_iterator, size_type,
a_const_pointer) const;
leaf_pointer
leftmost_descendant();
leaf_const_pointer
leftmost_descendant() const;
leaf_pointer
rightmost_descendant();
leaf_const_pointer
rightmost_descendant() const;
#ifdef _GLIBCXX_DEBUG
typedef typename base_type::node_debug_info node_debug_info;
virtual node_debug_info
assert_valid_imp(a_const_pointer, const char*, int) const;
#endif
size_type
get_e_ind() const
{ return m_e_ind; }
private:
_Inode(const _Inode&);
size_type
get_begin_pos() const;
static __rebind_l s_leaf_alloc;
static __rebind_in s_inode_alloc;
const size_type m_e_ind;
a_const_iterator m_pref_b_it;
a_const_iterator m_pref_e_it;
node_pointer m_a_p_children[arr_size];
};
#define PB_DS_CONST_IT_C_DEC \
_CIter<Node, Leaf, Head, Inode, Is_Forward_Iterator>
#define PB_DS_CONST_ODIR_IT_C_DEC \
_CIter<Node, Leaf, Head, Inode, !Is_Forward_Iterator>
#define PB_DS_IT_C_DEC \
_Iter<Node, Leaf, Head, Inode, Is_Forward_Iterator>
#define PB_DS_ODIR_IT_C_DEC \
_Iter<Node, Leaf, Head, Inode, !Is_Forward_Iterator>
/// Const iterator.
template<typename Node, typename Leaf, typename Head, typename Inode,
bool Is_Forward_Iterator>
class _CIter
{
public:
// These types are all the same for the first four template arguments.
typedef typename Node::allocator_type allocator_type;
typedef typename Node::type_traits type_traits;
typedef std::bidirectional_iterator_tag iterator_category;
typedef typename allocator_type::difference_type difference_type;
typedef typename type_traits::value_type value_type;
typedef typename type_traits::pointer pointer;
typedef typename type_traits::reference reference;
typedef typename type_traits::const_pointer const_pointer;
typedef typename type_traits::const_reference const_reference;
typedef allocator_type _Alloc;
typedef typename _Alloc::template rebind<Node> __rebind_n;
typedef typename __rebind_n::other::pointer node_pointer;
typedef typename _Alloc::template rebind<Leaf> __rebind_l;
typedef typename __rebind_l::other::pointer leaf_pointer;
typedef typename __rebind_l::other::const_pointer leaf_const_pointer;
typedef typename _Alloc::template rebind<Head> __rebind_h;
typedef typename __rebind_h::other::pointer head_pointer;
typedef typename _Alloc::template rebind<Inode> __rebind_in;
typedef typename __rebind_in::other::pointer inode_pointer;
typedef typename Inode::iterator inode_iterator;
node_pointer m_p_nd;
_CIter(node_pointer p_nd = 0) : m_p_nd(p_nd)
{ }
_CIter(const PB_DS_CONST_ODIR_IT_C_DEC& other)
: m_p_nd(other.m_p_nd)
{ }
_CIter&
operator=(const _CIter& other)
{
m_p_nd = other.m_p_nd;
return *this;
}
_CIter&
operator=(const PB_DS_CONST_ODIR_IT_C_DEC& other)
{
m_p_nd = other.m_p_nd;
return *this;
}
const_pointer
operator->() const
{
_GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == leaf_node);
return &static_cast<leaf_pointer>(m_p_nd)->value();
}
const_reference
operator*() const
{
_GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == leaf_node);
return static_cast<leaf_pointer>(m_p_nd)->value();
}
bool
operator==(const _CIter& other) const
{ return m_p_nd == other.m_p_nd; }
bool
operator==(const PB_DS_CONST_ODIR_IT_C_DEC& other) const
{ return m_p_nd == other.m_p_nd; }
bool
operator!=(const _CIter& other) const
{ return m_p_nd != other.m_p_nd; }
bool
operator!=(const PB_DS_CONST_ODIR_IT_C_DEC& other) const
{ return m_p_nd != other.m_p_nd; }
_CIter&
operator++()
{
inc(integral_constant<int, Is_Forward_Iterator>());
return *this;
}
_CIter
operator++(int)
{
_CIter ret_it(m_p_nd);
operator++();
return ret_it;
}
_CIter&
operator--()
{
dec(integral_constant<int, Is_Forward_Iterator>());
return *this;
}
_CIter
operator--(int)
{
_CIter ret_it(m_p_nd);
operator--();
return ret_it;
}
protected:
void
inc(false_type)
{ dec(true_type()); }
void
inc(true_type)
{
if (m_p_nd->m_type == head_node)
{
m_p_nd = static_cast<head_pointer>(m_p_nd)->m_p_min;
return;
}
node_pointer p_y = m_p_nd->m_p_parent;
while (p_y->m_type != head_node && get_larger_sibling(m_p_nd) == 0)
{
m_p_nd = p_y;
p_y = p_y->m_p_parent;
}
if (p_y->m_type == head_node)
{
m_p_nd = p_y;
return;
}
m_p_nd = leftmost_descendant(get_larger_sibling(m_p_nd));
}
void
dec(false_type)
{ inc(true_type()); }
void
dec(true_type)
{
if (m_p_nd->m_type == head_node)
{
m_p_nd = static_cast<head_pointer>(m_p_nd)->m_p_max;
return;
}
node_pointer p_y = m_p_nd->m_p_parent;
while (p_y->m_type != head_node && get_smaller_sibling(m_p_nd) == 0)
{
m_p_nd = p_y;
p_y = p_y->m_p_parent;
}
if (p_y->m_type == head_node)
{
m_p_nd = p_y;
return;
}
m_p_nd = rightmost_descendant(get_smaller_sibling(m_p_nd));
}
static node_pointer
get_larger_sibling(node_pointer p_nd)
{
inode_pointer p_parent = static_cast<inode_pointer>(p_nd->m_p_parent);
inode_iterator it = p_parent->begin();
while (*it != p_nd)
++it;
inode_iterator next_it = it;
++next_it;
return (next_it == p_parent->end())? 0 : *next_it;
}
static node_pointer
get_smaller_sibling(node_pointer p_nd)
{
inode_pointer p_parent = static_cast<inode_pointer>(p_nd->m_p_parent);
inode_iterator it = p_parent->begin();
if (*it == p_nd)
return 0;
inode_iterator prev_it;
do
{
prev_it = it;
++it;
if (*it == p_nd)
return *prev_it;
}
while (true);
_GLIBCXX_DEBUG_ASSERT(false);
return 0;
}
static leaf_pointer
leftmost_descendant(node_pointer p_nd)
{
if (p_nd->m_type == leaf_node)
return static_cast<leaf_pointer>(p_nd);
return static_cast<inode_pointer>(p_nd)->leftmost_descendant();
}
static leaf_pointer
rightmost_descendant(node_pointer p_nd)
{
if (p_nd->m_type == leaf_node)
return static_cast<leaf_pointer>(p_nd);
return static_cast<inode_pointer>(p_nd)->rightmost_descendant();
}
};
/// Iterator.
template<typename Node, typename Leaf, typename Head, typename Inode,
bool Is_Forward_Iterator>
class _Iter
: public _CIter<Node, Leaf, Head, Inode, Is_Forward_Iterator>
{
public:
typedef _CIter<Node, Leaf, Head, Inode, Is_Forward_Iterator>
base_type;
typedef typename base_type::allocator_type allocator_type;
typedef typename base_type::type_traits type_traits;
typedef typename type_traits::value_type value_type;
typedef typename type_traits::pointer pointer;
typedef typename type_traits::reference reference;
typedef typename base_type::node_pointer node_pointer;
typedef typename base_type::leaf_pointer leaf_pointer;
typedef typename base_type::leaf_const_pointer leaf_const_pointer;
typedef typename base_type::head_pointer head_pointer;
typedef typename base_type::inode_pointer inode_pointer;
_Iter(node_pointer p_nd = 0)
: base_type(p_nd) { }
_Iter(const PB_DS_ODIR_IT_C_DEC& other)
: base_type(other.m_p_nd) { }
_Iter&
operator=(const _Iter& other)
{
base_type::m_p_nd = other.m_p_nd;
return *this;
}
_Iter&
operator=(const PB_DS_ODIR_IT_C_DEC& other)
{
base_type::m_p_nd = other.m_p_nd;
return *this;
}
pointer
operator->() const
{
_GLIBCXX_DEBUG_ASSERT(base_type::m_p_nd->m_type == leaf_node);
return &static_cast<leaf_pointer>(base_type::m_p_nd)->value();
}
reference
operator*() const
{
_GLIBCXX_DEBUG_ASSERT(base_type::m_p_nd->m_type == leaf_node);
return static_cast<leaf_pointer>(base_type::m_p_nd)->value();
}
_Iter&
operator++()
{
base_type::operator++();
return *this;
}
_Iter
operator++(int)
{
_Iter ret(base_type::m_p_nd);
operator++();
return ret;
}
_Iter&
operator--()
{
base_type::operator--();
return *this;
}
_Iter
operator--(int)
{
_Iter ret(base_type::m_p_nd);
operator--();
return ret;
}
};
#undef PB_DS_CONST_ODIR_IT_C_DEC
#undef PB_DS_ODIR_IT_C_DEC
#define PB_DS_PAT_TRIE_NODE_CONST_ITERATOR_C_DEC \
_Node_citer<Node, Leaf, Head, Inode, _CIterator, Iterator, _ATraits, _Alloc>
#define PB_DS_PAT_TRIE_NODE_ITERATOR_C_DEC \
_Node_iter<Node, Leaf, Head, Inode, _CIterator, Iterator, _ATraits, _Alloc>
/// Node const iterator.
template<typename Node,
typename Leaf,
typename Head,
typename Inode,
typename _CIterator,
typename Iterator,
typename _Alloc>
class _Node_citer
{
protected:
typedef typename _Alloc::template rebind<Node> __rebind_n;
typedef typename __rebind_n::other::pointer node_pointer;
typedef typename _Alloc::template rebind<Leaf> __rebind_l;
typedef typename __rebind_l::other::pointer leaf_pointer;
typedef typename __rebind_l::other::const_pointer leaf_const_pointer;
typedef typename _Alloc::template rebind<Inode> __rebind_in;
typedef typename __rebind_in::other::pointer inode_pointer;
typedef typename __rebind_in::other::const_pointer inode_const_pointer;
typedef typename Node::a_const_pointer a_const_pointer;
typedef typename Node::a_const_iterator a_const_iterator;
private:
a_const_iterator
pref_begin() const
{
if (m_p_nd->m_type == leaf_node)
{
leaf_const_pointer lcp = static_cast<leaf_const_pointer>(m_p_nd);
return m_p_traits->begin(m_p_traits->extract_key(lcp->value()));
}
_GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == i_node);
return static_cast<inode_const_pointer>(m_p_nd)->pref_b_it();
}
a_const_iterator
pref_end() const
{
if (m_p_nd->m_type == leaf_node)
{
leaf_const_pointer lcp = static_cast<leaf_const_pointer>(m_p_nd);
return m_p_traits->end(m_p_traits->extract_key(lcp->value()));
}
_GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == i_node);
return static_cast<inode_const_pointer>(m_p_nd)->pref_e_it();
}
public:
typedef trivial_iterator_tag iterator_category;
typedef trivial_iterator_difference_type difference_type;
typedef typename _Alloc::size_type size_type;
typedef _CIterator value_type;
typedef value_type reference;
typedef value_type const_reference;
/// Metadata type.
typedef typename Node::metadata_type metadata_type;
/// Const metadata reference type.
typedef typename _Alloc::template rebind<metadata_type> __rebind_m;
typedef typename __rebind_m::other __rebind_ma;
typedef typename __rebind_ma::const_reference metadata_const_reference;
inline
_Node_citer(node_pointer p_nd = 0, a_const_pointer p_traits = 0)
: m_p_nd(const_cast<node_pointer>(p_nd)), m_p_traits(p_traits)
{ }
/// Subtree valid prefix.
std::pair<a_const_iterator, a_const_iterator>
valid_prefix() const
{ return std::make_pair(pref_begin(), pref_end()); }
/// Const access; returns the __const iterator* associated with
/// the current leaf.
const_reference
operator*() const
{
_GLIBCXX_DEBUG_ASSERT(num_children() == 0);
return _CIterator(m_p_nd);
}
/// Metadata access.
metadata_const_reference
get_metadata() const
{ return m_p_nd->get_metadata(); }
/// Returns the number of children in the corresponding node.
size_type
num_children() const
{
if (m_p_nd->m_type == leaf_node)
return 0;
_GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == i_node);
inode_pointer inp = static_cast<inode_pointer>(m_p_nd);
return std::distance(inp->begin(), inp->end());
}
/// Returns a __const node __iterator to the corresponding node's
/// i-th child.
_Node_citer
get_child(size_type i) const
{
_GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == i_node);
inode_pointer inp = static_cast<inode_pointer>(m_p_nd);
typename Inode::iterator it = inp->begin();
std::advance(it, i);
return _Node_citer(*it, m_p_traits);
}
/// Compares content to a different iterator object.
bool
operator==(const _Node_citer& other) const
{ return m_p_nd == other.m_p_nd; }
/// Compares content (negatively) to a different iterator object.
bool
operator!=(const _Node_citer& other) const
{ return m_p_nd != other.m_p_nd; }
node_pointer m_p_nd;
a_const_pointer m_p_traits;
};
/// Node iterator.
template<typename Node,
typename Leaf,
typename Head,
typename Inode,
typename _CIterator,
typename Iterator,
typename _Alloc>
class _Node_iter
: public _Node_citer<Node, Leaf, Head, Inode, _CIterator, Iterator, _Alloc>
{
private:
typedef _Node_citer<Node, Leaf, Head, Inode,
_CIterator, Iterator, _Alloc> base_type;
typedef typename _Alloc::template rebind<Node> __rebind_n;
typedef typename __rebind_n::other::pointer node_pointer;
typedef typename base_type::inode_pointer inode_pointer;
typedef typename base_type::a_const_pointer a_const_pointer;
typedef Iterator iterator;
public:
typedef typename base_type::size_type size_type;
typedef Iterator value_type;
typedef value_type reference;
typedef value_type const_reference;
_Node_iter(node_pointer p_nd = 0, a_const_pointer p_traits = 0)
: base_type(p_nd, p_traits)
{ }
/// Access; returns the iterator* associated with the current leaf.
reference
operator*() const
{
_GLIBCXX_DEBUG_ASSERT(base_type::num_children() == 0);
return iterator(base_type::m_p_nd);
}
/// Returns a node __iterator to the corresponding node's i-th child.
_Node_iter
get_child(size_type i) const
{
_GLIBCXX_DEBUG_ASSERT(base_type::m_p_nd->m_type == i_node);
typename Inode::iterator it =
static_cast<inode_pointer>(base_type::m_p_nd)->begin();
std::advance(it, i);
return _Node_iter(*it, base_type::m_p_traits);
}
};
};
#define PB_DS_CLASS_T_DEC \
template<typename _ATraits, typename Metadata>
#define PB_DS_CLASS_C_DEC \
pat_trie_base::_Inode<_ATraits, Metadata>
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::__rebind_l
PB_DS_CLASS_C_DEC::s_leaf_alloc;
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::__rebind_in
PB_DS_CLASS_C_DEC::s_inode_alloc;
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
get_pref_pos(a_const_iterator b_it, a_const_iterator e_it,
a_const_pointer p_traits) const
{
if (static_cast<std::size_t>(std::distance(b_it, e_it)) <= m_e_ind)
return 0;
std::advance(b_it, m_e_ind);
return 1 + p_traits->e_pos(*b_it);
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
_Inode(size_type len, const a_const_iterator it)
: base_type(i_node), m_e_ind(len), m_pref_b_it(it), m_pref_e_it(it)
{
std::advance(m_pref_e_it, m_e_ind);
std::fill(m_a_p_children, m_a_p_children + arr_size,
static_cast<node_pointer>(0));
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
update_prefixes(a_const_pointer p_traits)
{
node_pointer p_first = *begin();
if (p_first->m_type == leaf_node)
{
leaf_const_pointer p = static_cast<leaf_const_pointer>(p_first);
m_pref_b_it = p_traits->begin(access_traits::extract_key(p->value()));
}
else
{
inode_pointer p = static_cast<inode_pointer>(p_first);
_GLIBCXX_DEBUG_ASSERT(p_first->m_type == i_node);
m_pref_b_it = p->pref_b_it();
}
m_pref_e_it = m_pref_b_it;
std::advance(m_pref_e_it, m_e_ind);
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
begin() const
{
typedef node_pointer_pointer pointer_type;
pointer_type p = const_cast<pointer_type>(m_a_p_children);
return const_iterator(p + get_begin_pos(), p + arr_size);
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
begin()
{
return iterator(m_a_p_children + get_begin_pos(),
m_a_p_children + arr_size);
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
end() const
{
typedef node_pointer_pointer pointer_type;
pointer_type p = const_cast<pointer_type>(m_a_p_children) + arr_size;
return const_iterator(p, p);
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
end()
{ return iterator(m_a_p_children + arr_size, m_a_p_children + arr_size); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
get_child_node(a_const_iterator b_it, a_const_iterator e_it,
a_const_pointer p_traits)
{
const size_type i = get_pref_pos(b_it, e_it, p_traits);
_GLIBCXX_DEBUG_ASSERT(i < arr_size);
return m_a_p_children[i];
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
get_child_it(a_const_iterator b_it, a_const_iterator e_it,
a_const_pointer p_traits)
{
const size_type i = get_pref_pos(b_it, e_it, p_traits);
_GLIBCXX_DEBUG_ASSERT(i < arr_size);
_GLIBCXX_DEBUG_ASSERT(m_a_p_children[i] != 0);
return iterator(m_a_p_children + i, m_a_p_children + i);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_const_pointer
PB_DS_CLASS_C_DEC::
get_child_node(a_const_iterator b_it, a_const_iterator e_it,
a_const_pointer p_traits) const
{ return const_cast<node_pointer>(get_child_node(b_it, e_it, p_traits)); }
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
get_lower_bound_child_node(a_const_iterator b_it, a_const_iterator e_it,
size_type checked_ind,
a_const_pointer p_traits)
{
if (!should_be_mine(b_it, e_it, checked_ind, p_traits))
{
if (p_traits->cmp_prefixes(b_it, e_it, m_pref_b_it,
m_pref_e_it, true))
return leftmost_descendant();
return rightmost_descendant();
}
size_type i = get_pref_pos(b_it, e_it, p_traits);
_GLIBCXX_DEBUG_ASSERT(i < arr_size);
if (m_a_p_children[i] != 0)
return m_a_p_children[i];
while (++i < arr_size)
if (m_a_p_children[i] != 0)
{
const node_type& __nt = m_a_p_children[i]->m_type;
node_pointer ret = m_a_p_children[i];
if (__nt == leaf_node)
return ret;
_GLIBCXX_DEBUG_ASSERT(__nt == i_node);
inode_pointer inp = static_cast<inode_pointer>(ret);
return inp->leftmost_descendant();
}
return rightmost_descendant();
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
add_child(node_pointer p_nd, a_const_iterator b_it, a_const_iterator e_it,
a_const_pointer p_traits)
{
const size_type i = get_pref_pos(b_it, e_it, p_traits);
_GLIBCXX_DEBUG_ASSERT(i < arr_size);
if (m_a_p_children[i] == 0)
{
m_a_p_children[i] = p_nd;
p_nd->m_p_parent = this;
return p_nd;
}
return m_a_p_children[i];
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_const_pointer
PB_DS_CLASS_C_DEC::
get_join_child(node_const_pointer p_nd,
a_const_pointer p_tr) const
{
node_pointer p = const_cast<node_pointer>(p_nd);
return const_cast<inode_pointer>(this)->get_join_child(p, p_tr);
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
get_join_child(node_pointer p_nd, a_const_pointer p_traits)
{
size_type i;
a_const_iterator b_it;
a_const_iterator e_it;
if (p_nd->m_type == leaf_node)
{
leaf_const_pointer p = static_cast<leaf_const_pointer>(p_nd);
typedef typename type_traits::key_const_reference kcr;
kcr r_key = access_traits::extract_key(p->value());
b_it = p_traits->begin(r_key);
e_it = p_traits->end(r_key);
}
else
{
b_it = static_cast<inode_pointer>(p_nd)->pref_b_it();
e_it = static_cast<inode_pointer>(p_nd)->pref_e_it();
}
i = get_pref_pos(b_it, e_it, p_traits);
_GLIBCXX_DEBUG_ASSERT(i < arr_size);
return m_a_p_children[i];
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
remove_child(node_pointer p_nd)
{
size_type i = 0;
for (; i < arr_size; ++i)
if (m_a_p_children[i] == p_nd)
{
m_a_p_children[i] = 0;
return;
}
_GLIBCXX_DEBUG_ASSERT(i != arr_size);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
remove_child(iterator it)
{ *it.m_p_p_cur = 0; }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
replace_child(node_pointer p_nd, a_const_iterator b_it,
a_const_iterator e_it,
a_const_pointer p_traits)
{
const size_type i = get_pref_pos(b_it, e_it, p_traits);
_GLIBCXX_DEBUG_ASSERT(i < arr_size);
m_a_p_children[i] = p_nd;
p_nd->m_p_parent = this;
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::a_const_iterator
PB_DS_CLASS_C_DEC::
pref_b_it() const
{ return m_pref_b_it; }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::a_const_iterator
PB_DS_CLASS_C_DEC::
pref_e_it() const
{ return m_pref_e_it; }
PB_DS_CLASS_T_DEC
bool
PB_DS_CLASS_C_DEC::
should_be_mine(a_const_iterator b_it, a_const_iterator e_it,
size_type checked_ind,
a_const_pointer p_traits) const
{
if (m_e_ind == 0)
return true;
const size_type num_es = std::distance(b_it, e_it);
if (num_es < m_e_ind)
return false;
a_const_iterator key_b_it = b_it;
std::advance(key_b_it, checked_ind);
a_const_iterator key_e_it = b_it;
std::advance(key_e_it, m_e_ind);
a_const_iterator value_b_it = m_pref_b_it;
std::advance(value_b_it, checked_ind);
a_const_iterator value_e_it = m_pref_b_it;
std::advance(value_e_it, m_e_ind);
return p_traits->equal_prefixes(key_b_it, key_e_it, value_b_it,
value_e_it);
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::leaf_pointer
PB_DS_CLASS_C_DEC::
leftmost_descendant()
{
node_pointer p_pot = *begin();
if (p_pot->m_type == leaf_node)
return (static_cast<leaf_pointer>(p_pot));
_GLIBCXX_DEBUG_ASSERT(p_pot->m_type == i_node);
return static_cast<inode_pointer>(p_pot)->leftmost_descendant();
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::leaf_const_pointer
PB_DS_CLASS_C_DEC::
leftmost_descendant() const
{ return const_cast<inode_pointer>(this)->leftmost_descendant(); }
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::leaf_pointer
PB_DS_CLASS_C_DEC::
rightmost_descendant()
{
const size_type num_children = std::distance(begin(), end());
_GLIBCXX_DEBUG_ASSERT(num_children >= 2);
iterator it = begin();
std::advance(it, num_children - 1);
node_pointer p_pot =* it;
if (p_pot->m_type == leaf_node)
return static_cast<leaf_pointer>(p_pot);
_GLIBCXX_DEBUG_ASSERT(p_pot->m_type == i_node);
return static_cast<inode_pointer>(p_pot)->rightmost_descendant();
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::leaf_const_pointer
PB_DS_CLASS_C_DEC::
rightmost_descendant() const
{ return const_cast<inode_pointer>(this)->rightmost_descendant(); }
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
get_begin_pos() const
{
size_type i = 0;
for (; i < arr_size && m_a_p_children[i] == 0; ++i)
;
return i;
}
#ifdef _GLIBCXX_DEBUG
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_debug_info
PB_DS_CLASS_C_DEC::
assert_valid_imp(a_const_pointer p_traits,
const char* __file, int __line) const
{
PB_DS_DEBUG_VERIFY(base_type::m_type == i_node);
PB_DS_DEBUG_VERIFY(static_cast<size_type>(std::distance(pref_b_it(), pref_e_it())) == m_e_ind);
PB_DS_DEBUG_VERIFY(std::distance(begin(), end()) >= 2);
for (typename _Inode::const_iterator it = begin(); it != end(); ++it)
{
node_const_pointer p_nd = *it;
PB_DS_DEBUG_VERIFY(p_nd->m_p_parent == this);
node_debug_info child_ret = p_nd->assert_valid_imp(p_traits,
__file, __line);
PB_DS_DEBUG_VERIFY(static_cast<size_type>(std::distance(child_ret.first, child_ret.second)) >= m_e_ind);
PB_DS_DEBUG_VERIFY(should_be_mine(child_ret.first, child_ret.second, 0, p_traits));
PB_DS_DEBUG_VERIFY(get_pref_pos(child_ret.first, child_ret.second, p_traits) == static_cast<size_type>(it.m_p_p_cur - m_a_p_children));
}
return std::make_pair(pref_b_it(), pref_e_it());
}
#endif
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
} // namespace detail
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp 0000644 00000017303 15201526705 0015535 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file pat_trie_/find_fn_imps.hpp
* Contains an implementation class for pat_trie.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC::
find(key_const_reference r_key)
{
PB_DS_ASSERT_VALID((*this))
node_pointer p_nd = find_imp(r_key);
if (p_nd == 0 || p_nd->m_type != leaf_node)
{
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return end();
}
if (synth_access_traits::equal_keys(PB_DS_V2F(static_cast<leaf_pointer>(p_nd)->value()), r_key))
{
PB_DS_CHECK_KEY_EXISTS(r_key)
return iterator(p_nd);
}
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return end();
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_const_iterator
PB_DS_CLASS_C_DEC::
find(key_const_reference r_key) const
{
PB_DS_ASSERT_VALID((*this))
node_const_pointer p_nd = const_cast<PB_DS_CLASS_C_DEC* >(this)->find_imp(r_key);
if (p_nd == 0 || p_nd->m_type != leaf_node)
{
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return end();
}
if (synth_access_traits::equal_keys(PB_DS_V2F(static_cast<leaf_const_pointer>(p_nd)->value()), r_key))
{
PB_DS_CHECK_KEY_EXISTS(r_key)
return const_iterator(const_cast<node_pointer>(p_nd));
}
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return end();
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
find_imp(key_const_reference r_key)
{
if (empty())
return 0;
typename synth_access_traits::const_iterator b_it =
synth_access_traits::begin(r_key);
typename synth_access_traits::const_iterator e_it =
synth_access_traits::end(r_key);
node_pointer p_nd = m_p_head->m_p_parent;
_GLIBCXX_DEBUG_ASSERT(p_nd != 0);
while (p_nd->m_type != leaf_node)
{
_GLIBCXX_DEBUG_ASSERT(p_nd->m_type == i_node);
node_pointer p_next_nd = static_cast<inode_pointer>(p_nd)->get_child_node(b_it, e_it, this);
if (p_next_nd == 0)
return p_nd;
p_nd = p_next_nd;
}
return p_nd;
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
lower_bound_imp(key_const_reference r_key)
{
if (empty())
return (m_p_head);
node_pointer p_nd = m_p_head->m_p_parent;
_GLIBCXX_DEBUG_ASSERT(p_nd != 0);
typename PB_DS_CLASS_C_DEC::a_const_iterator b_it =
synth_access_traits::begin(r_key);
typename PB_DS_CLASS_C_DEC::a_const_iterator e_it =
synth_access_traits::end(r_key);
size_type checked_ind = 0;
while (true)
{
if (p_nd->m_type == leaf_node)
{
if (!synth_access_traits::cmp_keys(PB_DS_V2F(static_cast<leaf_const_pointer>(p_nd)->value()), r_key))
return p_nd;
iterator it(p_nd);
++it;
return it.m_p_nd;
}
_GLIBCXX_DEBUG_ASSERT(p_nd->m_type == i_node);
const size_type new_checked_ind =
static_cast<inode_pointer>(p_nd)->get_e_ind();
p_nd =
static_cast<inode_pointer>(p_nd)->get_lower_bound_child_node( b_it, e_it, checked_ind, this);
checked_ind = new_checked_ind;
}
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC::
lower_bound(key_const_reference r_key)
{ return point_iterator(lower_bound_imp(r_key)); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_const_iterator
PB_DS_CLASS_C_DEC::
lower_bound(key_const_reference r_key) const
{
return point_const_iterator(const_cast<PB_DS_CLASS_C_DEC* >(this)->lower_bound_imp(r_key));
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC::
upper_bound(key_const_reference r_key)
{
point_iterator l_bound_it = lower_bound(r_key);
_GLIBCXX_DEBUG_ASSERT(l_bound_it == end() ||
!synth_access_traits::cmp_keys(PB_DS_V2F(*l_bound_it),
r_key));
if (l_bound_it == end() ||
synth_access_traits::cmp_keys(r_key, PB_DS_V2F(*l_bound_it)))
return l_bound_it;
return ++l_bound_it;
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_const_iterator
PB_DS_CLASS_C_DEC::
upper_bound(key_const_reference r_key) const
{
point_const_iterator l_bound_it = lower_bound(r_key);
_GLIBCXX_DEBUG_ASSERT(l_bound_it == end() ||
!synth_access_traits::cmp_keys(PB_DS_V2F(*l_bound_it),
r_key));
if (l_bound_it == end() ||
synth_access_traits::cmp_keys(r_key, PB_DS_V2F(*l_bound_it)))
return l_bound_it;
return ++l_bound_it;
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::a_const_iterator
PB_DS_CLASS_C_DEC::
pref_begin(node_const_pointer p_nd)
{
if (p_nd->m_type == leaf_node)
return (synth_access_traits::begin(PB_DS_V2F(static_cast<leaf_const_pointer>(p_nd)->value())));
_GLIBCXX_DEBUG_ASSERT(p_nd->m_type == i_node);
return static_cast<inode_const_pointer>(p_nd)->pref_b_it();
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::a_const_iterator
PB_DS_CLASS_C_DEC::
pref_end(node_const_pointer p_nd)
{
if (p_nd->m_type == leaf_node)
return (synth_access_traits::end(PB_DS_V2F(static_cast<leaf_const_pointer>(p_nd)->value())));
_GLIBCXX_DEBUG_ASSERT(p_nd->m_type == i_node);
return static_cast<inode_const_pointer>(p_nd)->pref_e_it();
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::leaf_const_pointer
PB_DS_CLASS_C_DEC::
leftmost_descendant(node_const_pointer p_nd)
{
if (p_nd->m_type == leaf_node)
return static_cast<leaf_const_pointer>(p_nd);
return static_cast<inode_const_pointer>(p_nd)->leftmost_descendant();
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::leaf_pointer
PB_DS_CLASS_C_DEC::
leftmost_descendant(node_pointer p_nd)
{
if (p_nd->m_type == leaf_node)
return static_cast<leaf_pointer>(p_nd);
return static_cast<inode_pointer>(p_nd)->leftmost_descendant();
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::leaf_const_pointer
PB_DS_CLASS_C_DEC::
rightmost_descendant(node_const_pointer p_nd)
{
if (p_nd->m_type == leaf_node)
return static_cast<leaf_const_pointer>(p_nd);
return static_cast<inode_const_pointer>(p_nd)->rightmost_descendant();
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::leaf_pointer
PB_DS_CLASS_C_DEC::
rightmost_descendant(node_pointer p_nd)
{
if (p_nd->m_type == leaf_node)
return static_cast<leaf_pointer>(p_nd);
return static_cast<inode_pointer>(p_nd)->rightmost_descendant();
}
c++/8/ext/pb_ds/detail/pat_trie_/rotate_fn_imps.hpp 0000644 00000010352 15201526705 0016110 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file pat_trie_/rotate_fn_imps.hpp
* Contains imps for rotating nodes.
*/
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
rotate_left(node_pointer p_x)
{
node_pointer p_y = p_x->m_p_right;
p_x->m_p_right = p_y->m_p_left;
if (p_y->m_p_left != 0)
p_y->m_p_left->m_p_parent = p_x;
p_y->m_p_parent = p_x->m_p_parent;
if (p_x == m_p_head->m_p_parent)
m_p_head->m_p_parent = p_y;
else if (p_x == p_x->m_p_parent->m_p_left)
p_x->m_p_parent->m_p_left = p_y;
else
p_x->m_p_parent->m_p_right = p_y;
p_y->m_p_left = p_x;
p_x->m_p_parent = p_y;
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_x);)
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y);)
apply_update(p_x, (Node_Update*)this);
apply_update(p_x->m_p_parent, (Node_Update*)this);
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
rotate_right(node_pointer p_x)
{
node_pointer p_y = p_x->m_p_left;
p_x->m_p_left = p_y->m_p_right;
if (p_y->m_p_right != 0)
p_y->m_p_right->m_p_parent = p_x;
p_y->m_p_parent = p_x->m_p_parent;
if (p_x == m_p_head->m_p_parent)
m_p_head->m_p_parent = p_y;
else if (p_x == p_x->m_p_parent->m_p_right)
p_x->m_p_parent->m_p_right = p_y;
else
p_x->m_p_parent->m_p_left = p_y;
p_y->m_p_right = p_x;
p_x->m_p_parent = p_y;
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_x);)
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y);)
apply_update(p_x, (Node_Update*)this);
apply_update(p_x->m_p_parent, (Node_Update*)this);
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
rotate_parent(node_pointer p_nd)
{
node_pointer p_parent = p_nd->m_p_parent;
if (p_nd == p_parent->m_p_left)
rotate_right(p_parent);
else
rotate_left(p_parent);
_GLIBCXX_DEBUG_ASSERT(p_parent->m_p_parent = p_nd);
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_left == p_parent || p_nd->m_p_right == p_parent);
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
apply_update(node_pointer /*p_nd*/, __gnu_pbds::null_node_update* /*p_update*/)
{ }
PB_DS_CLASS_T_DEC
template<typename Node_Update_>
inline void
PB_DS_CLASS_C_DEC::
apply_update(node_pointer p_nd, Node_Update_* p_update)
{
p_update->operator()(& PB_DS_V2F(p_nd->m_value),(p_nd->m_p_left == 0) ?
0 :
& PB_DS_V2F(p_nd->m_p_left->m_value),(p_nd->m_p_right == 0) ?
0 :
& PB_DS_V2F(p_nd->m_p_right->m_value));
}
PB_DS_CLASS_T_DEC
template<typename Node_Update_>
inline void
PB_DS_CLASS_C_DEC::
update_to_top(node_pointer p_nd, Node_Update_* p_update)
{
while (p_nd != m_p_head)
{
apply_update(p_nd, p_update);
p_nd = p_nd->m_p_parent;
}
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
update_to_top(node_pointer /*p_nd*/, __gnu_pbds::null_node_update* /*p_update*/)
{ }
c++/8/ext/pb_ds/detail/pat_trie_/erase_fn_imps.hpp 0000644 00000017411 15201526705 0015714 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file pat_trie_/erase_fn_imps.hpp
* Contains an implementation class for pat_trie.
*/
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
erase(key_const_reference r_key)
{
node_pointer p_nd = find_imp(r_key);
if (p_nd == 0 || p_nd->m_type == i_node)
{
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return false;
}
_GLIBCXX_DEBUG_ASSERT(p_nd->m_type == leaf_node);
if (!synth_access_traits::equal_keys(PB_DS_V2F(reinterpret_cast<leaf_pointer>(p_nd)->value()), r_key))
{
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return false;
}
PB_DS_CHECK_KEY_EXISTS(r_key)
erase_leaf(static_cast<leaf_pointer>(p_nd));
PB_DS_ASSERT_VALID((*this))
return true;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
erase_fixup(inode_pointer p_nd)
{
_GLIBCXX_DEBUG_ASSERT(std::distance(p_nd->begin(), p_nd->end()) >= 1);
if (std::distance(p_nd->begin(), p_nd->end()) == 1)
{
node_pointer p_parent = p_nd->m_p_parent;
if (p_parent == m_p_head)
m_p_head->m_p_parent = *p_nd->begin();
else
{
_GLIBCXX_DEBUG_ASSERT(p_parent->m_type == i_node);
node_pointer p_new_child = *p_nd->begin();
typedef inode_pointer inode_ptr;
inode_ptr p_internal = static_cast<inode_ptr>(p_parent);
p_internal->replace_child(p_new_child, pref_begin(p_new_child),
pref_end(p_new_child), this);
}
(*p_nd->begin())->m_p_parent = p_nd->m_p_parent;
p_nd->~inode();
s_inode_allocator.deallocate(p_nd, 1);
if (p_parent == m_p_head)
return;
_GLIBCXX_DEBUG_ASSERT(p_parent->m_type == i_node);
p_nd = static_cast<inode_pointer>(p_parent);
}
while (true)
{
_GLIBCXX_DEBUG_ASSERT(std::distance(p_nd->begin(), p_nd->end()) > 1);
p_nd->update_prefixes(this);
apply_update(p_nd, (node_update*)this);
PB_DS_ASSERT_NODE_VALID(p_nd)
if (p_nd->m_p_parent->m_type == head_node)
return;
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_parent->m_type == i_node);
p_nd = static_cast<inode_pointer>(p_nd->m_p_parent);
}
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
actual_erase_leaf(leaf_pointer p_l)
{
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
--m_size;
_GLIBCXX_DEBUG_ONLY(debug_base::erase_existing(PB_DS_V2F(p_l->value())));
p_l->~leaf();
s_leaf_allocator.deallocate(p_l, 1);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
clear()
{
if (!empty())
{
clear_imp(m_p_head->m_p_parent);
m_size = 0;
initialize();
_GLIBCXX_DEBUG_ONLY(debug_base::clear();)
PB_DS_ASSERT_VALID((*this))
}
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
clear_imp(node_pointer p_nd)
{
if (p_nd->m_type == i_node)
{
_GLIBCXX_DEBUG_ASSERT(p_nd->m_type == i_node);
for (typename inode::iterator it =
static_cast<inode_pointer>(p_nd)->begin();
it != static_cast<inode_pointer>(p_nd)->end();
++it)
{
node_pointer p_child =* it;
clear_imp(p_child);
}
s_inode_allocator.deallocate(static_cast<inode_pointer>(p_nd), 1);
return;
}
_GLIBCXX_DEBUG_ASSERT(p_nd->m_type == leaf_node);
static_cast<leaf_pointer>(p_nd)->~leaf();
s_leaf_allocator.deallocate(static_cast<leaf_pointer>(p_nd), 1);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
erase(const_iterator it)
{
PB_DS_ASSERT_VALID((*this))
if (it == end())
return it;
const_iterator ret_it = it;
++ret_it;
_GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == leaf_node);
erase_leaf(static_cast<leaf_pointer>(it.m_p_nd));
PB_DS_ASSERT_VALID((*this))
return ret_it;
}
#ifdef PB_DS_DATA_TRUE_INDICATOR
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
erase(iterator it)
{
PB_DS_ASSERT_VALID((*this))
if (it == end())
return it;
iterator ret_it = it;
++ret_it;
_GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == leaf_node);
erase_leaf(static_cast<leaf_pointer>(it.m_p_nd));
PB_DS_ASSERT_VALID((*this))
return ret_it;
}
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_reverse_iterator
PB_DS_CLASS_C_DEC::
erase(const_reverse_iterator it)
{
PB_DS_ASSERT_VALID((*this))
if (it.m_p_nd == m_p_head)
return it;
const_reverse_iterator ret_it = it;
++ret_it;
_GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == leaf_node);
erase_leaf(static_cast<leaf_pointer>(it.m_p_nd));
PB_DS_ASSERT_VALID((*this))
return ret_it;
}
#ifdef PB_DS_DATA_TRUE_INDICATOR
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::reverse_iterator
PB_DS_CLASS_C_DEC::
erase(reverse_iterator it)
{
PB_DS_ASSERT_VALID((*this))
if (it.m_p_nd == m_p_head)
return it;
reverse_iterator ret_it = it;
++ret_it;
_GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == leaf_node);
erase_leaf(static_cast<leaf_pointer>(it.m_p_nd));
PB_DS_ASSERT_VALID((*this))
return ret_it;
}
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
PB_DS_CLASS_T_DEC
template<typename Pred>
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
erase_if(Pred pred)
{
size_type num_ersd = 0;
PB_DS_ASSERT_VALID((*this))
iterator it = begin();
while (it != end())
{
PB_DS_ASSERT_VALID((*this))
if (pred(*it))
{
++num_ersd;
it = erase(it);
}
else
++it;
}
PB_DS_ASSERT_VALID((*this))
return num_ersd;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
erase_leaf(leaf_pointer p_l)
{
update_min_max_for_erased_leaf(p_l);
if (p_l->m_p_parent->m_type == head_node)
{
_GLIBCXX_DEBUG_ASSERT(size() == 1);
clear();
return;
}
_GLIBCXX_DEBUG_ASSERT(size() > 1);
_GLIBCXX_DEBUG_ASSERT(p_l->m_p_parent->m_type == i_node);
inode_pointer p_parent = static_cast<inode_pointer>(p_l->m_p_parent);
p_parent->remove_child(p_l);
erase_fixup(p_parent);
actual_erase_leaf(p_l);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
update_min_max_for_erased_leaf(leaf_pointer p_l)
{
if (m_size == 1)
{
m_p_head->m_p_min = m_p_head;
m_p_head->m_p_max = m_p_head;
return;
}
if (p_l == static_cast<leaf_const_pointer>(m_p_head->m_p_min))
{
iterator it(p_l);
++it;
m_p_head->m_p_min = it.m_p_nd;
return;
}
if (p_l == static_cast<leaf_const_pointer>(m_p_head->m_p_max))
{
iterator it(p_l);
--it;
m_p_head->m_p_max = it.m_p_nd;
}
}
c++/8/ext/pb_ds/detail/pat_trie_/r_erase_fn_imps.hpp 0000644 00000005550 15201526705 0016236 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file pat_trie_/r_erase_fn_imps.hpp
* Contains an implementation class for pat_trie.
*/
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
actual_erase_node(node_pointer p_z)
{
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
--m_size;
_GLIBCXX_DEBUG_ONLY(debug_base::erase_existing(PB_DS_V2F(p_z->m_value)));
p_z->~node();
s_node_allocator.deallocate(p_z, 1);
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
update_min_max_for_erased_node(node_pointer p_z)
{
if (m_size == 1)
{
m_p_head->m_p_left = m_p_head->m_p_right = m_p_head;
return;
}
if (m_p_head->m_p_left == p_z)
{
iterator it(p_z);
++it;
m_p_head->m_p_left = it.m_p_nd;
}
else if (m_p_head->m_p_right == p_z)
{
iterator it(p_z);
--it;
m_p_head->m_p_right = it.m_p_nd;
}
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
clear()
{
_GLIBCXX_DEBUG_ONLY(assert_valid(true, true);)
clear_imp(m_p_head->m_p_parent);
m_size = 0;
initialize();
_GLIBCXX_DEBUG_ONLY(debug_base::clear();)
_GLIBCXX_DEBUG_ONLY(assert_valid(true, true);)
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
clear_imp(node_pointer p_nd)
{
if (p_nd == 0)
return;
clear_imp(p_nd->m_p_left);
clear_imp(p_nd->m_p_right);
p_nd->~Node();
s_node_allocator.deallocate(p_nd, 1);
}
c++/8/ext/pb_ds/detail/pat_trie_/pat_trie_.hpp 0000644 00000040745 15201526705 0015056 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file pat_trie_/pat_trie_.hpp
* Contains an implementation class for a patricia tree.
*/
#include <iterator>
#include <utility>
#include <algorithm>
#include <functional>
#include <assert.h>
#include <list>
#include <ext/pb_ds/exception.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/cond_dealtor.hpp>
#include <ext/pb_ds/detail/type_utils.hpp>
#include <ext/pb_ds/detail/types_traits.hpp>
#include <ext/pb_ds/detail/eq_fn/eq_by_less.hpp>
#include <ext/pb_ds/detail/pat_trie_/synth_access_traits.hpp>
#include <ext/pb_ds/detail/pat_trie_/pat_trie_base.hpp>
#ifdef _GLIBCXX_DEBUG
#include <ext/pb_ds/detail/debug_map_base.hpp>
#endif
#include <debug/debug.h>
namespace __gnu_pbds
{
namespace detail
{
#ifdef PB_DS_DATA_TRUE_INDICATOR
#define PB_DS_PAT_TRIE_NAME pat_trie_map
#endif
#ifdef PB_DS_DATA_FALSE_INDICATOR
#define PB_DS_PAT_TRIE_NAME pat_trie_set
#endif
#define PB_DS_CLASS_T_DEC \
template<typename Key, typename Mapped, typename Node_And_It_Traits, \
typename _Alloc>
#define PB_DS_CLASS_C_DEC \
PB_DS_PAT_TRIE_NAME<Key, Mapped, Node_And_It_Traits, _Alloc>
#define PB_DS_PAT_TRIE_TRAITS_BASE \
types_traits<Key, Mapped, _Alloc, false>
#ifdef _GLIBCXX_DEBUG
#define PB_DS_DEBUG_MAP_BASE_C_DEC \
debug_map_base<Key, eq_by_less<Key, std::less<Key> >, \
typename _Alloc::template rebind<Key>::other::const_reference>
#endif
/**
* @brief PATRICIA trie.
* @ingroup branch-detail
*
* This implementation loosely borrows ideas from:
* 1) Fast Mergeable Integer Maps, Okasaki, Gill 1998
* 2) Ptset: Sets of integers implemented as Patricia trees,
* Jean-Christophe Filliatr, 2000
*/
template<typename Key, typename Mapped, typename Node_And_It_Traits,
typename _Alloc>
class PB_DS_PAT_TRIE_NAME :
#ifdef _GLIBCXX_DEBUG
public PB_DS_DEBUG_MAP_BASE_C_DEC,
#endif
public Node_And_It_Traits::synth_access_traits,
public Node_And_It_Traits::node_update,
public PB_DS_PAT_TRIE_TRAITS_BASE,
public pat_trie_base
{
private:
typedef pat_trie_base base_type;
typedef PB_DS_PAT_TRIE_TRAITS_BASE traits_base;
typedef Node_And_It_Traits traits_type;
typedef typename traits_type::synth_access_traits synth_access_traits;
typedef typename synth_access_traits::const_iterator a_const_iterator;
typedef typename traits_type::node node;
typedef typename _Alloc::template rebind<node> __rebind_n;
typedef typename __rebind_n::other::const_pointer node_const_pointer;
typedef typename __rebind_n::other::pointer node_pointer;
typedef typename traits_type::head head;
typedef typename _Alloc::template rebind<head> __rebind_h;
typedef typename __rebind_h::other head_allocator;
typedef typename head_allocator::pointer head_pointer;
typedef typename traits_type::leaf leaf;
typedef typename _Alloc::template rebind<leaf> __rebind_l;
typedef typename __rebind_l::other leaf_allocator;
typedef typename leaf_allocator::pointer leaf_pointer;
typedef typename leaf_allocator::const_pointer leaf_const_pointer;
typedef typename traits_type::inode inode;
typedef typename inode::iterator inode_iterator;
typedef typename _Alloc::template rebind<inode> __rebind_in;
typedef typename __rebind_in::other __rebind_ina;
typedef typename __rebind_in::other inode_allocator;
typedef typename __rebind_ina::pointer inode_pointer;
typedef typename __rebind_ina::const_pointer inode_const_pointer;
/// Conditional deallocator.
class cond_dealtor
{
protected:
leaf_pointer m_p_nd;
bool m_no_action_dtor;
bool m_call_destructor;
public:
cond_dealtor(leaf_pointer p_nd)
: m_p_nd(p_nd), m_no_action_dtor(false), m_call_destructor(false)
{ }
void
set_no_action_dtor()
{ m_no_action_dtor = true; }
void
set_call_destructor()
{ m_call_destructor = true; }
~cond_dealtor()
{
if (m_no_action_dtor)
return;
if (m_call_destructor)
m_p_nd->~leaf();
s_leaf_allocator.deallocate(m_p_nd, 1);
}
};
/// Branch bag, for split-join.
class branch_bag
{
private:
typedef inode_pointer __inp;
typedef typename _Alloc::template rebind<__inp>::other __rebind_inp;
#ifdef _GLIBCXX_DEBUG
typedef std::_GLIBCXX_STD_C::list<__inp, __rebind_inp> bag_type;
#else
typedef std::list<__inp, __rebind_inp> bag_type;
#endif
bag_type m_bag;
public:
void
add_branch()
{
inode_pointer p_nd = s_inode_allocator.allocate(1);
__try
{
m_bag.push_back(p_nd);
}
__catch(...)
{
s_inode_allocator.deallocate(p_nd, 1);
__throw_exception_again;
}
}
inode_pointer
get_branch()
{
_GLIBCXX_DEBUG_ASSERT(!m_bag.empty());
inode_pointer p_nd = *m_bag.begin();
m_bag.pop_front();
return p_nd;
}
~branch_bag()
{
while (!m_bag.empty())
{
inode_pointer p_nd = *m_bag.begin();
s_inode_allocator.deallocate(p_nd, 1);
m_bag.pop_front();
}
}
inline bool
empty() const
{ return m_bag.empty(); }
};
#ifdef _GLIBCXX_DEBUG
typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base;
#endif
typedef typename traits_type::null_node_update_pointer null_node_update_pointer;
public:
typedef pat_trie_tag container_category;
typedef _Alloc allocator_type;
typedef typename _Alloc::size_type size_type;
typedef typename _Alloc::difference_type difference_type;
typedef typename traits_base::key_type key_type;
typedef typename traits_base::key_pointer key_pointer;
typedef typename traits_base::key_const_pointer key_const_pointer;
typedef typename traits_base::key_reference key_reference;
typedef typename traits_base::key_const_reference key_const_reference;
typedef typename traits_base::mapped_type mapped_type;
typedef typename traits_base::mapped_pointer mapped_pointer;
typedef typename traits_base::mapped_const_pointer mapped_const_pointer;
typedef typename traits_base::mapped_reference mapped_reference;
typedef typename traits_base::mapped_const_reference mapped_const_reference;
typedef typename traits_base::value_type value_type;
typedef typename traits_base::pointer pointer;
typedef typename traits_base::const_pointer const_pointer;
typedef typename traits_base::reference reference;
typedef typename traits_base::const_reference const_reference;
typedef typename traits_type::access_traits access_traits;
typedef typename traits_type::const_iterator point_const_iterator;
typedef typename traits_type::iterator point_iterator;
typedef point_const_iterator const_iterator;
typedef point_iterator iterator;
typedef typename traits_type::reverse_iterator reverse_iterator;
typedef typename traits_type::const_reverse_iterator const_reverse_iterator;
typedef typename traits_type::node_const_iterator node_const_iterator;
typedef typename traits_type::node_iterator node_iterator;
typedef typename traits_type::node_update node_update;
PB_DS_PAT_TRIE_NAME();
PB_DS_PAT_TRIE_NAME(const access_traits&);
PB_DS_PAT_TRIE_NAME(const PB_DS_CLASS_C_DEC&);
void
swap(PB_DS_CLASS_C_DEC&);
~PB_DS_PAT_TRIE_NAME();
inline bool
empty() const;
inline size_type
size() const;
inline size_type
max_size() const;
access_traits&
get_access_traits();
const access_traits&
get_access_traits() const;
node_update&
get_node_update();
const node_update&
get_node_update() const;
inline std::pair<point_iterator, bool>
insert(const_reference);
inline mapped_reference
operator[](key_const_reference r_key)
{
#ifdef PB_DS_DATA_TRUE_INDICATOR
return insert(std::make_pair(r_key, mapped_type())).first->second;
#else
insert(r_key);
return traits_base::s_null_type;
#endif
}
inline point_iterator
find(key_const_reference);
inline point_const_iterator
find(key_const_reference) const;
inline point_iterator
lower_bound(key_const_reference);
inline point_const_iterator
lower_bound(key_const_reference) const;
inline point_iterator
upper_bound(key_const_reference);
inline point_const_iterator
upper_bound(key_const_reference) const;
void
clear();
inline bool
erase(key_const_reference);
inline const_iterator
erase(const_iterator);
#ifdef PB_DS_DATA_TRUE_INDICATOR
inline iterator
erase(iterator);
#endif
inline const_reverse_iterator
erase(const_reverse_iterator);
#ifdef PB_DS_DATA_TRUE_INDICATOR
inline reverse_iterator
erase(reverse_iterator);
#endif
template<typename Pred>
inline size_type
erase_if(Pred);
void
join(PB_DS_CLASS_C_DEC&);
void
split(key_const_reference, PB_DS_CLASS_C_DEC&);
inline iterator
begin();
inline const_iterator
begin() const;
inline iterator
end();
inline const_iterator
end() const;
inline reverse_iterator
rbegin();
inline const_reverse_iterator
rbegin() const;
inline reverse_iterator
rend();
inline const_reverse_iterator
rend() const;
/// Returns a const node_iterator corresponding to the node at the
/// root of the tree.
inline node_const_iterator
node_begin() const;
/// Returns a node_iterator corresponding to the node at the
/// root of the tree.
inline node_iterator
node_begin();
/// Returns a const node_iterator corresponding to a node just
/// after a leaf of the tree.
inline node_const_iterator
node_end() const;
/// Returns a node_iterator corresponding to a node just
/// after a leaf of the tree.
inline node_iterator
node_end();
#ifdef PB_DS_PAT_TRIE_TRACE_
void
trace() const;
#endif
protected:
template<typename It>
void
copy_from_range(It, It);
void
value_swap(PB_DS_CLASS_C_DEC&);
node_pointer
recursive_copy_node(node_const_pointer);
private:
void
initialize();
inline void
apply_update(node_pointer, null_node_update_pointer);
template<typename Node_Update_>
inline void
apply_update(node_pointer, Node_Update_*);
bool
join_prep(PB_DS_CLASS_C_DEC&, branch_bag&);
void
rec_join_prep(node_const_pointer, node_const_pointer, branch_bag&);
void
rec_join_prep(leaf_const_pointer, leaf_const_pointer, branch_bag&);
void
rec_join_prep(leaf_const_pointer, inode_const_pointer, branch_bag&);
void
rec_join_prep(inode_const_pointer, leaf_const_pointer, branch_bag&);
void
rec_join_prep(inode_const_pointer, inode_const_pointer, branch_bag&);
node_pointer
rec_join(node_pointer, node_pointer, size_type, branch_bag&);
node_pointer
rec_join(leaf_pointer, leaf_pointer, branch_bag&);
node_pointer
rec_join(leaf_pointer, inode_pointer, size_type, branch_bag&);
node_pointer
rec_join(inode_pointer, leaf_pointer, size_type, branch_bag&);
node_pointer
rec_join(inode_pointer, inode_pointer, branch_bag&);
size_type
keys_diff_ind(typename access_traits::const_iterator,
typename access_traits::const_iterator,
typename access_traits::const_iterator,
typename access_traits::const_iterator);
inode_pointer
insert_branch(node_pointer, node_pointer, branch_bag&);
void
update_min_max_for_inserted_leaf(leaf_pointer);
void
erase_leaf(leaf_pointer);
inline void
actual_erase_leaf(leaf_pointer);
void
clear_imp(node_pointer);
void
erase_fixup(inode_pointer);
void
update_min_max_for_erased_leaf(leaf_pointer);
static inline a_const_iterator
pref_begin(node_const_pointer);
static inline a_const_iterator
pref_end(node_const_pointer);
inline node_pointer
find_imp(key_const_reference);
inline node_pointer
lower_bound_imp(key_const_reference);
inline node_pointer
upper_bound_imp(key_const_reference);
inline static leaf_const_pointer
leftmost_descendant(node_const_pointer);
inline static leaf_pointer
leftmost_descendant(node_pointer);
inline static leaf_const_pointer
rightmost_descendant(node_const_pointer);
inline static leaf_pointer
rightmost_descendant(node_pointer);
#ifdef _GLIBCXX_DEBUG
void
assert_valid(const char*, int) const;
void
assert_iterators(const char*, int) const;
void
assert_reverse_iterators(const char*, int) const;
static size_type
recursive_count_leafs(node_const_pointer, const char*, int);
#endif
#ifdef PB_DS_PAT_TRIE_TRACE_
static void
trace_node(node_const_pointer, size_type);
template<typename Metadata_>
static void
trace_node_metadata(node_const_pointer, type_to_type<Metadata_>);
static void
trace_node_metadata(node_const_pointer, type_to_type<null_type>);
#endif
leaf_pointer
split_prep(key_const_reference, PB_DS_CLASS_C_DEC&, branch_bag&);
node_pointer
rec_split(node_pointer, a_const_iterator, a_const_iterator,
PB_DS_CLASS_C_DEC&, branch_bag&);
void
split_insert_branch(size_type, a_const_iterator, inode_iterator,
size_type, branch_bag&);
static head_allocator s_head_allocator;
static inode_allocator s_inode_allocator;
static leaf_allocator s_leaf_allocator;
head_pointer m_p_head;
size_type m_size;
};
#define PB_DS_ASSERT_NODE_VALID(X) \
_GLIBCXX_DEBUG_ONLY(X->assert_valid(this, __FILE__, __LINE__);)
#define PB_DS_RECURSIVE_COUNT_LEAFS(X) \
recursive_count_leafs(X, __FILE__, __LINE__)
#include <ext/pb_ds/detail/pat_trie_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/pat_trie_/iterators_fn_imps.hpp>
#include <ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp>
#include <ext/pb_ds/detail/pat_trie_/erase_fn_imps.hpp>
#include <ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp>
#include <ext/pb_ds/detail/pat_trie_/info_fn_imps.hpp>
#include <ext/pb_ds/detail/pat_trie_/policy_access_fn_imps.hpp>
#include <ext/pb_ds/detail/pat_trie_/split_fn_imps.hpp>
#include <ext/pb_ds/detail/pat_trie_/debug_fn_imps.hpp>
#include <ext/pb_ds/detail/pat_trie_/trace_fn_imps.hpp>
#include <ext/pb_ds/detail/pat_trie_/update_fn_imps.hpp>
#undef PB_DS_RECURSIVE_COUNT_LEAFS
#undef PB_DS_ASSERT_NODE_VALID
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_PAT_TRIE_NAME
#undef PB_DS_PAT_TRIE_TRAITS_BASE
#undef PB_DS_DEBUG_MAP_BASE_C_DEC
} // namespace detail
} // namespace __gnu_pbds
c++/8/ext/pb_ds/detail/pat_trie_/synth_access_traits.hpp 0000644 00000015076 15201526705 0017163 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file pat_trie_/synth_access_traits.hpp
* Contains an implementation class for a patricia tree.
*/
#ifndef PB_DS_SYNTH_E_ACCESS_TRAITS_HPP
#define PB_DS_SYNTH_E_ACCESS_TRAITS_HPP
#include <ext/pb_ds/detail/type_utils.hpp>
namespace __gnu_pbds
{
namespace detail
{
#define PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC \
template<typename Type_Traits, bool Set, typename _ATraits>
#define PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC \
synth_access_traits<Type_Traits, Set, _ATraits>
/// Synthetic element access traits.
template<typename Type_Traits, bool Set, typename _ATraits>
struct synth_access_traits : public _ATraits
{
typedef _ATraits base_type;
typedef typename base_type::const_iterator const_iterator;
typedef Type_Traits type_traits;
typedef typename type_traits::const_reference const_reference;
typedef typename type_traits::key_const_reference key_const_reference;
synth_access_traits();
synth_access_traits(const base_type&);
inline bool
equal_prefixes(const_iterator, const_iterator, const_iterator,
const_iterator, bool compare_after = true) const;
bool
equal_keys(key_const_reference, key_const_reference) const;
bool
cmp_prefixes(const_iterator, const_iterator, const_iterator,
const_iterator, bool compare_after = false) const;
bool
cmp_keys(key_const_reference, key_const_reference) const;
inline static key_const_reference
extract_key(const_reference);
#ifdef _GLIBCXX_DEBUG
bool
operator()(key_const_reference, key_const_reference);
#endif
private:
inline static key_const_reference
extract_key(const_reference, true_type);
inline static key_const_reference
extract_key(const_reference, false_type);
static integral_constant<int, Set> s_set_ind;
};
PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
integral_constant<int,Set>
PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::s_set_ind;
PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
synth_access_traits()
{ }
PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
synth_access_traits(const _ATraits& r_traits)
: _ATraits(r_traits)
{ }
PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
inline bool
PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
equal_prefixes(const_iterator b_l, const_iterator e_l, const_iterator b_r,
const_iterator e_r, bool compare_after /*= false */) const
{
while (b_l != e_l)
{
if (b_r == e_r)
return false;
if (base_type::e_pos(*b_l) != base_type::e_pos(*b_r))
return false;
++b_l;
++b_r;
}
return (!compare_after || b_r == e_r);
}
PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
bool
PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
equal_keys(key_const_reference r_lhs_key,
key_const_reference r_rhs_key) const
{
return equal_prefixes(base_type::begin(r_lhs_key),
base_type::end(r_lhs_key),
base_type::begin(r_rhs_key),
base_type::end(r_rhs_key),
true);
}
PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
bool
PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
cmp_prefixes(const_iterator b_l, const_iterator e_l, const_iterator b_r,
const_iterator e_r, bool compare_after /* = false*/) const
{
while (b_l != e_l)
{
if (b_r == e_r)
return false;
const typename base_type::size_type l_pos = base_type::e_pos(*b_l);
const typename base_type::size_type r_pos = base_type::e_pos(*b_r);
if (l_pos != r_pos)
return l_pos < r_pos;
++b_l;
++b_r;
}
if (!compare_after)
return false;
return b_r != e_r;
}
PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
bool
PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
cmp_keys(key_const_reference r_lhs_key,
key_const_reference r_rhs_key) const
{
return cmp_prefixes(base_type::begin(r_lhs_key),
base_type::end(r_lhs_key),
base_type::begin(r_rhs_key),
base_type::end(r_rhs_key),
true);
}
PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
inline typename PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::key_const_reference
PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
extract_key(const_reference r_val)
{ return extract_key(r_val, s_set_ind); }
PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
inline typename PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::key_const_reference
PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
extract_key(const_reference r_val, true_type)
{ return r_val; }
PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
inline typename PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::key_const_reference
PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
extract_key(const_reference r_val, false_type)
{ return r_val.first; }
#ifdef _GLIBCXX_DEBUG
PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
bool
PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
operator()(key_const_reference r_lhs, key_const_reference r_rhs)
{ return cmp_keys(r_lhs, r_rhs); }
#endif
#undef PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
#undef PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC
} // namespace detail
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/detail/pat_trie_/trace_fn_imps.hpp 0000644 00000006511 15201526705 0015712 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file pat_trie_/trace_fn_imps.hpp
* Contains an implementation class for pat_trie_.
*/
#ifdef PB_DS_PAT_TRIE_TRACE_
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
trace() const
{
std::cerr << std::endl;
if (m_p_head->m_p_parent == 0)
return;
trace_node(m_p_head->m_p_parent, 0);
std::cerr << std::endl;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
trace_node(node_const_pointer p_nd, size_type level)
{
for (size_type i = 0; i < level; ++i)
std::cerr << ' ';
std::cerr << p_nd << " ";
std::cerr << ((p_nd->m_type == pat_trie_leaf_node_type) ? "l " : "i ");
trace_node_metadata(p_nd, type_to_type<typename node::metadata_type>());
typename access_traits::const_iterator el_it = pref_begin(p_nd);
while (el_it != pref_end(p_nd))
{
std::cerr <<* el_it;
++el_it;
}
if (p_nd->m_type == pat_trie_leaf_node_type)
{
std::cerr << std::endl;
return;
}
inode_const_pointer p_internal = static_cast<inode_const_pointer>(p_nd);
std::cerr << " " <<
static_cast<unsigned long>(p_internal->get_e_ind()) << std::endl;
const size_type num_children = std::distance(p_internal->begin(),
p_internal->end());
for (size_type child_i = 0; child_i < num_children; ++child_i)
{
typename inode::const_iterator child_it = p_internal->begin();
std::advance(child_it, num_children - child_i - 1);
trace_node(*child_it, level + 1);
}
}
PB_DS_CLASS_T_DEC
template<typename Metadata_>
void
PB_DS_CLASS_C_DEC::
trace_node_metadata(node_const_pointer p_nd, type_to_type<Metadata_>)
{
std::cerr << "(" << static_cast<unsigned long>(p_nd->get_metadata()) << ") ";
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
trace_node_metadata(node_const_pointer, type_to_type<null_type>)
{ }
#endif
c++/8/ext/pb_ds/detail/pat_trie_/update_fn_imps.hpp 0000644 00000003772 15201526705 0016104 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file pat_trie_/update_fn_imps.hpp
* Contains an implementation class for pat_trie_.
*/
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
apply_update(node_pointer, null_node_update_pointer)
{ }
PB_DS_CLASS_T_DEC
template<typename Node_Update_>
inline void
PB_DS_CLASS_C_DEC::
apply_update(node_pointer p_nd, Node_Update_*)
{
Node_Update_::operator()(node_iterator(p_nd, this),
node_const_iterator(0, this));
}
c++/8/ext/pb_ds/detail/pat_trie_/traits.hpp 0000644 00000014241 15201526705 0014406 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file pat_trie_/traits.hpp
* Contains an implementation class for pat_trie_.
*/
#ifndef PB_DS_PAT_TRIE_NODE_AND_IT_TRAITS_HPP
#define PB_DS_PAT_TRIE_NODE_AND_IT_TRAITS_HPP
#include <ext/pb_ds/detail/pat_trie_/pat_trie_base.hpp>
#include <ext/pb_ds/detail/pat_trie_/synth_access_traits.hpp>
namespace __gnu_pbds
{
namespace detail
{
/// Specialization.
/// @ingroup traits
template<typename Key,
typename Mapped,
typename _ATraits,
template<typename Node_CItr,
typename Node_Itr,
typename Cmp_Fn_,
typename _Alloc_>
class Node_Update,
typename _Alloc>
struct trie_traits<Key, Mapped, _ATraits, Node_Update, pat_trie_tag, _Alloc>
{
private:
typedef pat_trie_base base_type;
typedef types_traits<Key, Mapped, _Alloc, false> type_traits;
public:
typedef typename trie_node_metadata_dispatch<Key, Mapped, _ATraits, Node_Update, _Alloc>::type metadata_type;
typedef base_type::_Metadata<metadata_type, _Alloc> metadata;
typedef _ATraits access_traits;
/// Type for synthesized traits.
typedef __gnu_pbds::detail::synth_access_traits<type_traits, false, access_traits> synth_access_traits;
typedef base_type::_Node_base<synth_access_traits, metadata> node;
typedef base_type::_Head<synth_access_traits, metadata> head;
typedef base_type::_Leaf<synth_access_traits, metadata> leaf;
typedef base_type::_Inode<synth_access_traits, metadata> inode;
typedef base_type::_Iter<node, leaf, head, inode, true> iterator;
typedef base_type::_CIter<node, leaf, head, inode, true> const_iterator;
typedef base_type::_Iter<node, leaf, head, inode, false> reverse_iterator;
typedef base_type::_CIter<node, leaf, head, inode, false> const_reverse_iterator;
/// This is an iterator to an iterator: it iterates over nodes,
/// and de-referencing it returns one of the tree's iterators.
typedef base_type::_Node_citer<node, leaf, head, inode, const_iterator, iterator, _Alloc> node_const_iterator;
typedef base_type::_Node_iter<node, leaf, head, inode, const_iterator, iterator, _Alloc> node_iterator;
/// Type for node update.
typedef Node_Update<node_const_iterator, node_iterator, _ATraits, _Alloc> node_update;
typedef null_node_update<node_const_iterator, node_iterator, _ATraits, _Alloc>* null_node_update_pointer;
};
/// Specialization.
/// @ingroup traits
template<typename Key,
typename _ATraits,
template<typename Node_CItr,
typename Node_Itr,
typename Cmp_Fn_,
typename _Alloc_>
class Node_Update,
typename _Alloc>
struct trie_traits<Key, null_type, _ATraits, Node_Update, pat_trie_tag, _Alloc>
{
private:
typedef pat_trie_base base_type;
typedef types_traits<Key, null_type, _Alloc, false> type_traits;
public:
typedef typename trie_node_metadata_dispatch<Key, null_type, _ATraits, Node_Update, _Alloc>::type metadata_type;
typedef base_type::_Metadata<metadata_type, _Alloc> metadata;
typedef _ATraits access_traits;
/// Type for synthesized traits.
typedef __gnu_pbds::detail::synth_access_traits<type_traits, true, access_traits> synth_access_traits;
typedef base_type::_Node_base<synth_access_traits, metadata> node;
typedef base_type::_Head<synth_access_traits, metadata> head;
typedef base_type::_Leaf<synth_access_traits, metadata> leaf;
typedef base_type::_Inode<synth_access_traits, metadata> inode;
typedef base_type::_CIter<node, leaf, head, inode, true> const_iterator;
typedef const_iterator iterator;
typedef base_type::_CIter<node, leaf, head, inode, false> const_reverse_iterator;
typedef const_reverse_iterator reverse_iterator;
/// This is an iterator to an iterator: it iterates over nodes,
/// and de-referencing it returns one of the tree's iterators.
typedef base_type::_Node_citer<node, leaf, head, inode, const_iterator, iterator, _Alloc> node_const_iterator;
typedef node_const_iterator node_iterator;
/// Type for node update.
typedef Node_Update<node_const_iterator, node_iterator, _ATraits, _Alloc> node_update;
typedef null_node_update<node_const_iterator, node_const_iterator, _ATraits, _Alloc>* null_node_update_pointer;
};
} // namespace detail
} // namespace __gnu_pbds
#endif // #ifndef PB_DS_PAT_TRIE_NODE_AND_IT_TRAITS_HPP
c++/8/ext/pb_ds/detail/pat_trie_/policy_access_fn_imps.hpp 0000644 00000004247 15201526705 0017440 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file pat_trie_/policy_access_fn_imps.hpp
* Contains an implementation class for pat_trie.
*/
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::access_traits&
PB_DS_CLASS_C_DEC::
get_access_traits()
{ return *this; }
PB_DS_CLASS_T_DEC
const typename PB_DS_CLASS_C_DEC::access_traits&
PB_DS_CLASS_C_DEC::
get_access_traits() const
{ return *this; }
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_update&
PB_DS_CLASS_C_DEC::
get_node_update()
{ return *this; }
PB_DS_CLASS_T_DEC
const typename PB_DS_CLASS_C_DEC::node_update&
PB_DS_CLASS_C_DEC::
get_node_update() const
{ return *this; }
c++/8/ext/pb_ds/detail/cc_hash_table_map_/insert_no_store_hash_fn_imps.hpp 0000644 00000005072 15201526705 0022621 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file cc_hash_table_map_/insert_no_store_hash_fn_imps.hpp
* Contains implementations of cc_ht_map_'s insert related functions,
* when the hash value is not stored.
*/
PB_DS_CLASS_T_DEC
inline std::pair<typename PB_DS_CLASS_C_DEC::point_iterator, bool>
PB_DS_CLASS_C_DEC::
insert_imp(const_reference r_val, false_type)
{
PB_DS_ASSERT_VALID((*this))
key_const_reference r_key = PB_DS_V2F(r_val);
const size_type pos = ranged_hash_fn_base::operator()(r_key);
entry_pointer p_e = m_entries[pos];
resize_base::notify_insert_search_start();
while (p_e != 0 && !hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value),
r_key))
{
resize_base::notify_insert_search_collision();
p_e = p_e->m_p_next;
}
resize_base::notify_insert_search_end();
if (p_e != 0)
{
PB_DS_CHECK_KEY_EXISTS(r_key)
return std::make_pair(&p_e->m_value, false);
}
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return std::make_pair(insert_new_imp(r_val, pos), true);
}
c++/8/ext/pb_ds/detail/cc_hash_table_map_/entry_list_fn_imps.hpp 0000644 00000005612 15201526705 0020576 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file cc_hash_table_map_/entry_list_fn_imps.hpp
* Contains implementations of cc_ht_map_'s entry-list related functions.
*/
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
deallocate_links_in_list(entry_pointer p_e)
{
while (p_e != 0)
{
entry_pointer p_dealloc_e = p_e;
p_e = p_e->m_p_next;
s_entry_allocator.deallocate(p_dealloc_e, 1);
}
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::entry_pointer
PB_DS_CLASS_C_DEC::
get_entry(const_reference r_val, true_type)
{
// Following line might throw an exception.
entry_pointer p_e = s_entry_allocator.allocate(1);
// Following lines* cannot* throw an exception.
new (&p_e->m_value) value_type(r_val);
return p_e;
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::entry_pointer
PB_DS_CLASS_C_DEC::
get_entry(const_reference r_val, false_type)
{
// Following line might throw an exception.
entry_pointer p_e = s_entry_allocator.allocate(1);
cond_dealtor_t cond(p_e);
// Following lines might throw an exception.
new (&p_e->m_value) value_type(r_val);
cond.set_no_action();
return p_e;
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
rels_entry(entry_pointer p_e)
{
// The following lines cannot throw exceptions (unless if key-data dtors do).
p_e->m_value.~value_type();
s_entry_allocator.deallocate(p_e, 1);
}
c++/8/ext/pb_ds/detail/cc_hash_table_map_/info_fn_imps.hpp 0000644 00000006047 15201526705 0017340 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file cc_hash_table_map_/info_fn_imps.hpp
* Contains implementations of cc_ht_map_'s entire container info related
* functions.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
size() const
{ return m_num_used_e; }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
max_size() const
{ return m_entry_allocator.max_size(); }
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
empty() const
{ return (size() == 0); }
PB_DS_CLASS_T_DEC
template<typename Other_HT_Map_Type>
bool
PB_DS_CLASS_C_DEC::
operator==(const Other_HT_Map_Type& other) const
{ return cmp_with_other(other); }
PB_DS_CLASS_T_DEC
template<typename Other_Map_Type>
bool
PB_DS_CLASS_C_DEC::
cmp_with_other(const Other_Map_Type& other) const
{
if (size() != other.size())
return false;
for (typename Other_Map_Type::const_iterator it = other.begin();
it != other.end(); ++it)
{
key_const_reference r_key =(key_const_reference)PB_DS_V2F(*it);
mapped_const_pointer p_mapped_value =
const_cast<PB_DS_CLASS_C_DEC& >(*this).
find_key_pointer(r_key, traits_base::m_store_extra_indicator);
if (p_mapped_value == 0)
return false;
#ifdef PB_DS_DATA_TRUE_INDICATOR
if (p_mapped_value->second != it->second)
return false;
#endif
}
return true;
}
PB_DS_CLASS_T_DEC
template<typename Other_HT_Map_Type>
bool
PB_DS_CLASS_C_DEC::
operator!=(const Other_HT_Map_Type& other) const
{ return !operator==(other); }
c++/8/ext/pb_ds/detail/cc_hash_table_map_/erase_store_hash_fn_imps.hpp 0000644 00000006231 15201526705 0021716 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file cc_hash_table_map_/erase_store_hash_fn_imps.hpp
* Contains implementations of cc_ht_map_'s erase related functions,
* when the hash value is stored.
*/
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
erase_in_pos_imp(key_const_reference r_key, const comp_hash& r_pos_hash_pair)
{
PB_DS_ASSERT_VALID((*this))
entry_pointer p_e = m_entries[r_pos_hash_pair.first];
resize_base::notify_erase_search_start();
if (p_e == 0)
{
resize_base::notify_erase_search_end();
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
PB_DS_ASSERT_VALID((*this))
return false;
}
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), p_e->m_hash,
r_key, r_pos_hash_pair.second))
{
resize_base::notify_erase_search_end();
PB_DS_CHECK_KEY_EXISTS(r_key)
erase_entry_pointer(m_entries[r_pos_hash_pair.first]);
do_resize_if_needed_no_throw();
PB_DS_ASSERT_VALID((*this))
return true;
}
while (true)
{
entry_pointer p_next_e = p_e->m_p_next;
if (p_next_e == 0)
{
resize_base::notify_erase_search_end();
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
PB_DS_ASSERT_VALID((*this))
return false;
}
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_next_e->m_value),
p_next_e->m_hash, r_key,
r_pos_hash_pair.second))
{
resize_base::notify_erase_search_end();
PB_DS_CHECK_KEY_EXISTS(r_key)
erase_entry_pointer(p_e->m_p_next);
do_resize_if_needed_no_throw();
PB_DS_ASSERT_VALID((*this))
return true;
}
resize_base::notify_erase_search_collision();
p_e = p_next_e;
}
}
c++/8/ext/pb_ds/detail/cc_hash_table_map_/iterators_fn_imps.hpp 0000644 00000005150 15201526705 0020413 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file cc_hash_table_map_/iterators_fn_imps.hpp
* Contains implementations of cc_ht_map_'s iterators related functions, e.g.,
* begin().
*/
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::s_end_it;
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::s_const_end_it;
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
begin()
{
pointer p_value;
std::pair<entry_pointer, size_type> pos;
get_start_it_state(p_value, pos);
return iterator(p_value, pos, this);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
end()
{ return s_end_it; }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
begin() const
{
pointer p_value;
std::pair<entry_pointer, size_type> pos;
get_start_it_state(p_value, pos);
return const_iterator(p_value, pos, this);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
end() const
{ return s_const_end_it; }
c++/8/ext/pb_ds/detail/cc_hash_table_map_/debug_fn_imps.hpp 0000644 00000005205 15201526705 0017466 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file cc_hash_table_map_/debug_fn_imps.hpp
* Contains implementations of cc_ht_map_'s debug-mode functions.
*/
#ifdef _GLIBCXX_DEBUG
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_valid(const char* __file, int __line) const
{
debug_base::check_size(m_num_used_e, __file, __line);
assert_entry_pointer_array_valid(m_entries, __file, __line);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_entry_pointer_array_valid(const entry_pointer_array a_p_entries,
const char* __file, int __line) const
{
size_type iterated_num_used_e = 0;
for (size_type pos = 0; pos < m_num_e; ++pos)
{
entry_pointer p_e = a_p_entries[pos];
while (p_e != 0)
{
++iterated_num_used_e;
assert_entry_pointer_valid(p_e, traits_base::m_store_extra_indicator,
__file, __line);
p_e = p_e->m_p_next;
}
}
PB_DS_DEBUG_VERIFY(iterated_num_used_e == m_num_used_e);
}
#include <ext/pb_ds/detail/cc_hash_table_map_/debug_store_hash_fn_imps.hpp>
#include <ext/pb_ds/detail/cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp>
#endif
c++/8/ext/pb_ds/detail/cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp 0000644 00000003720 15201526705 0022401 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp
* Contains implementations of cc_ht_map_'s debug-mode functions.
*/
#ifdef _GLIBCXX_DEBUG
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_entry_pointer_valid(const entry_pointer p, false_type,
const char* __file, int __line) const
{ debug_base::check_key_exists(PB_DS_V2F(p->m_value), __file, __line); }
#endif
c++/8/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp 0000644 00000004402 15201526705 0025460 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file cc_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp
* Contains implementations of cc_ht_map_'s constructors, destructor,
* and related functions.
*/
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
constructor_insert_new_imp(const_reference r_val, size_type pos, true_type)
{
// Following lines might throw an exception.
entry_pointer p = get_entry(r_val, traits_base::s_no_throw_copies_indicator);
// At this point no exceptions can be thrown.
p->m_p_next = m_entries[pos];
p->m_hash = ranged_hash_fn_base::operator()((key_const_reference)(PB_DS_V2F(p->m_value))).second;
m_entries[pos] = p;
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(r_key);)
}
c++/8/ext/pb_ds/detail/cc_hash_table_map_/find_fn_imps.hpp 0000644 00000004665 15201526705 0017331 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file cc_hash_table_map_/find_fn_imps.hpp
* Contains implementations of cc_ht_map_'s find related functions.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC::
find(key_const_reference r_key)
{
PB_DS_ASSERT_VALID((*this))
return find_key_pointer(r_key, traits_base::m_store_extra_indicator);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_const_iterator
PB_DS_CLASS_C_DEC::
find(key_const_reference r_key) const
{
PB_DS_ASSERT_VALID((*this))
return const_cast<PB_DS_CLASS_C_DEC& >(*this).find_key_pointer(r_key,
traits_base::m_store_extra_indicator);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC::
find_end()
{ return 0; }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_const_iterator
PB_DS_CLASS_C_DEC::
find_end() const
{ return 0; }
c++/8/ext/pb_ds/detail/cc_hash_table_map_/resize_store_hash_fn_imps.hpp 0000644 00000004342 15201526705 0022121 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file cc_hash_table_map_/resize_store_hash_fn_imps.hpp
* Contains implementations of cc_ht_map_'s resize related functions, when the
* hash value is stored.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::entry_pointer
PB_DS_CLASS_C_DEC::
resize_imp_no_exceptions_reassign_pointer(entry_pointer p_e, entry_pointer_array a_p_entries_resized, true_type)
{
const comp_hash pos_hash_pair =
ranged_hash_fn_base::operator()(PB_DS_V2F(p_e->m_value), p_e->m_hash);
entry_pointer const p_next_e = p_e->m_p_next;
p_e->m_p_next = a_p_entries_resized[pos_hash_pair.first];
a_p_entries_resized[pos_hash_pair.first] = p_e;
return p_next_e;
}
c++/8/ext/pb_ds/detail/cc_hash_table_map_/cmp_fn_imps.hpp 0000644 00000005315 15201526705 0017161 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file cc_hash_table_map_/cmp_fn_imps.hpp
* Contains implementations of cc_ht_map_'s entire container comparison related
* functions.
*/
PB_DS_CLASS_T_DEC
template<typename Other_HT_Map_Type>
bool
PB_DS_CLASS_C_DEC::
operator==(const Other_HT_Map_Type& other) const
{ return cmp_with_other(other); }
PB_DS_CLASS_T_DEC
template<typename Other_Map_Type>
bool
PB_DS_CLASS_C_DEC::
cmp_with_other(const Other_Map_Type& other) const
{
if (size() != other.size())
return false;
for (typename Other_Map_Type::const_iterator it = other.begin();
it != other.end(); ++it)
{
key_const_reference r_key = key_const_reference(PB_DS_V2F(*it));
mapped_const_pointer p_mapped_value =
const_cast<PB_DS_CLASS_C_DEC& >(*this).
find_key_pointer(r_key, traits_base::m_store_extra_indicator);
if (p_mapped_value == 0)
return false;
#ifdef PB_DS_DATA_TRUE_INDICATOR
if (p_mapped_value->second != it->second)
return false;
#endif
}
return true;
}
PB_DS_CLASS_T_DEC
template<typename Other_HT_Map_Type>
bool
PB_DS_CLASS_C_DEC::
operator!=(const Other_HT_Map_Type& other) const
{ return !operator==(other); }
c++/8/ext/pb_ds/detail/cc_hash_table_map_/debug_store_hash_fn_imps.hpp 0000644 00000004144 15201526705 0021706 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file cc_hash_table_map_/debug_store_hash_fn_imps.hpp
* Contains implementations of cc_ht_map_'s debug-mode functions.
*/
#ifdef _GLIBCXX_DEBUG
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_entry_pointer_valid(const entry_pointer p_e, true_type,
const char* __file, int __line) const
{
debug_base::check_key_exists(PB_DS_V2F(p_e->m_value), __file, __line);
comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(PB_DS_V2F(p_e->m_value));
PB_DS_DEBUG_VERIFY(p_e->m_hash == pos_hash_pair.second);
}
#endif
c++/8/ext/pb_ds/detail/cc_hash_table_map_/resize_fn_imps.hpp 0000644 00000007736 15201526705 0017714 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file cc_hash_table_map_/resize_fn_imps.hpp
* Contains implementations of cc_ht_map_'s resize related functions.
*/
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
do_resize_if_needed()
{
if (!resize_base::is_resize_needed())
return false;
resize_imp(resize_base::get_new_size(m_num_e, m_num_used_e));
return true;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
do_resize(size_type len)
{ resize_imp(resize_base::get_nearest_larger_size(len)); }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
do_resize_if_needed_no_throw()
{
if (!resize_base::is_resize_needed())
return;
__try
{
resize_imp(resize_base::get_new_size(m_num_e, m_num_used_e));
}
__catch(...)
{ }
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
resize_imp(size_type new_size)
{
PB_DS_ASSERT_VALID((*this))
if (new_size == m_num_e)
return;
const size_type old_size = m_num_e;
entry_pointer_array a_p_entries_resized;
// Following line might throw an exception.
ranged_hash_fn_base::notify_resized(new_size);
__try
{
// Following line might throw an exception.
a_p_entries_resized = s_entry_pointer_allocator.allocate(new_size);
m_num_e = new_size;
}
__catch(...)
{
ranged_hash_fn_base::notify_resized(old_size);
__throw_exception_again;
}
// At this point no exceptions can be thrown.
resize_imp_no_exceptions(new_size, a_p_entries_resized, old_size);
Resize_Policy::notify_resized(new_size);
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
resize_imp_no_exceptions(size_type new_size, entry_pointer_array a_p_entries_resized, size_type old_size)
{
std::fill(a_p_entries_resized, a_p_entries_resized + m_num_e,
entry_pointer(0));
for (size_type pos = 0; pos < old_size; ++pos)
{
entry_pointer p_e = m_entries[pos];
while (p_e != 0)
p_e = resize_imp_no_exceptions_reassign_pointer(p_e, a_p_entries_resized, traits_base::m_store_extra_indicator);
}
m_num_e = new_size;
_GLIBCXX_DEBUG_ONLY(assert_entry_pointer_array_valid(a_p_entries_resized,
__FILE__, __LINE__);)
s_entry_pointer_allocator.deallocate(m_entries, old_size);
m_entries = a_p_entries_resized;
PB_DS_ASSERT_VALID((*this))
}
#include <ext/pb_ds/detail/cc_hash_table_map_/resize_no_store_hash_fn_imps.hpp>
#include <ext/pb_ds/detail/cc_hash_table_map_/resize_store_hash_fn_imps.hpp>
c++/8/ext/pb_ds/detail/cc_hash_table_map_/insert_fn_imps.hpp 0000644 00000003550 15201526705 0017705 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file cc_hash_table_map_/insert_fn_imps.hpp
* Contains implementations of cc_ht_map_'s insert related functions.
*/
#include <ext/pb_ds/detail/cc_hash_table_map_/insert_no_store_hash_fn_imps.hpp>
#include <ext/pb_ds/detail/cc_hash_table_map_/insert_store_hash_fn_imps.hpp>
c++/8/ext/pb_ds/detail/cc_hash_table_map_/erase_fn_imps.hpp 0000644 00000006255 15201526705 0017505 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file cc_hash_table_map_/erase_fn_imps.hpp
* Contains implementations of cc_ht_map_'s erase related functions.
*/
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
erase_entry_pointer(entry_pointer& r_p_e)
{
_GLIBCXX_DEBUG_ONLY(debug_base::erase_existing(PB_DS_V2F(r_p_e->m_value)));
entry_pointer p_e = r_p_e;
r_p_e = r_p_e->m_p_next;
rels_entry(p_e);
_GLIBCXX_DEBUG_ASSERT(m_num_used_e > 0);
resize_base::notify_erased(--m_num_used_e);
}
PB_DS_CLASS_T_DEC
template<typename Pred>
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
erase_if(Pred pred)
{
size_type num_ersd = 0;
for (size_type pos = 0; pos < m_num_e; ++pos)
{
while (m_entries[pos] != 0 && pred(m_entries[pos]->m_value))
{
++num_ersd;
entry_pointer p_next_e = m_entries[pos]->m_p_next;
erase_entry_pointer(m_entries[pos]);
m_entries[pos] = p_next_e;
}
entry_pointer p_e = m_entries[pos];
while (p_e != 0 && p_e->m_p_next != 0)
{
if (pred(p_e->m_p_next->m_value))
{
++num_ersd;
erase_entry_pointer(p_e->m_p_next);
}
else
p_e = p_e->m_p_next;
}
}
do_resize_if_needed_no_throw();
return num_ersd;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
clear()
{
for (size_type pos = 0; pos < m_num_e; ++pos)
while (m_entries[pos] != 0)
erase_entry_pointer(m_entries[pos]);
do_resize_if_needed_no_throw();
resize_base::notify_cleared();
}
#include <ext/pb_ds/detail/cc_hash_table_map_/erase_no_store_hash_fn_imps.hpp>
#include <ext/pb_ds/detail/cc_hash_table_map_/erase_store_hash_fn_imps.hpp>
c++/8/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp 0000644 00000046761 15201526705 0016755 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file cc_hash_table_map_/cc_ht_map_.hpp
* Contains an implementation class for cc_ht_map_.
*/
#include <utility>
#include <iterator>
#include <ext/pb_ds/detail/cond_dealtor.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/pb_ds/detail/hash_fn/ranged_hash_fn.hpp>
#include <ext/pb_ds/detail/types_traits.hpp>
#include <ext/pb_ds/exception.hpp>
#include <ext/pb_ds/detail/eq_fn/hash_eq_fn.hpp>
#ifdef _GLIBCXX_DEBUG
#include <ext/pb_ds/detail/debug_map_base.hpp>
#endif
#ifdef PB_DS_HT_MAP_TRACE_
#include <iostream>
#endif
#include <debug/debug.h>
namespace __gnu_pbds
{
namespace detail
{
#ifdef PB_DS_DATA_TRUE_INDICATOR
#define PB_DS_CC_HASH_NAME cc_ht_map
#endif
#ifdef PB_DS_DATA_FALSE_INDICATOR
#define PB_DS_CC_HASH_NAME cc_ht_set
#endif
#define PB_DS_CLASS_T_DEC \
template<typename Key, typename Mapped, typename Hash_Fn, \
typename Eq_Fn, typename _Alloc, bool Store_Hash, \
typename Comb_Hash_Fn, typename Resize_Policy>
#define PB_DS_CLASS_C_DEC \
PB_DS_CC_HASH_NAME<Key, Mapped, Hash_Fn, Eq_Fn, _Alloc, \
Store_Hash, Comb_Hash_Fn, Resize_Policy>
#define PB_DS_HASH_EQ_FN_C_DEC \
hash_eq_fn<Key, Eq_Fn, _Alloc, Store_Hash>
#define PB_DS_RANGED_HASH_FN_C_DEC \
ranged_hash_fn<Key, Hash_Fn, _Alloc, Comb_Hash_Fn, Store_Hash>
#define PB_DS_CC_HASH_TRAITS_BASE \
types_traits<Key, Mapped, _Alloc, Store_Hash>
#ifdef _GLIBCXX_DEBUG
#define PB_DS_DEBUG_MAP_BASE_C_DEC \
debug_map_base<Key, Eq_Fn, \
typename _Alloc::template rebind<Key>::other::const_reference>
#endif
/**
* A collision-chaining hash-based container.
*
*
* @ingroup hash-detail
*
* @tparam Key Key type.
*
* @tparam Mapped Map type.
*
* @tparam Hash_Fn Hashing functor.
* Default is __gnu_cxx::hash.
*
* @tparam Eq_Fn Equal functor.
* Default std::equal_to<Key>
*
* @tparam _Alloc Allocator type.
*
* @tparam Store_Hash If key type stores extra metadata.
* Defaults to false.
*
* @tparam Comb_Hash_Fn Combining hash functor.
* If Hash_Fn is not null_type, then this
* is the ranged-hash functor; otherwise,
* this is the range-hashing functor.
* XXX(See Design::Hash-Based Containers::Hash Policies.)
* Default direct_mask_range_hashing.
*
* @tparam Resize_Policy Resizes hash.
* Defaults to hash_standard_resize_policy,
* using hash_exponential_size_policy and
* hash_load_check_resize_trigger.
*
*
* Bases are: detail::hash_eq_fn, Resize_Policy, detail::ranged_hash_fn,
* detail::types_traits. (Optional: detail::debug_map_base.)
*/
template<typename Key,
typename Mapped,
typename Hash_Fn,
typename Eq_Fn,
typename _Alloc,
bool Store_Hash,
typename Comb_Hash_Fn,
typename Resize_Policy >
class PB_DS_CC_HASH_NAME:
#ifdef _GLIBCXX_DEBUG
protected PB_DS_DEBUG_MAP_BASE_C_DEC,
#endif
public PB_DS_HASH_EQ_FN_C_DEC,
public Resize_Policy,
public PB_DS_RANGED_HASH_FN_C_DEC,
public PB_DS_CC_HASH_TRAITS_BASE
{
private:
typedef PB_DS_CC_HASH_TRAITS_BASE traits_base;
typedef typename traits_base::comp_hash comp_hash;
typedef typename traits_base::value_type value_type_;
typedef typename traits_base::pointer pointer_;
typedef typename traits_base::const_pointer const_pointer_;
typedef typename traits_base::reference reference_;
typedef typename traits_base::const_reference const_reference_;
struct entry : public traits_base::stored_data_type
{
typename _Alloc::template rebind<entry>::other::pointer m_p_next;
};
typedef cond_dealtor<entry, _Alloc> cond_dealtor_t;
typedef typename _Alloc::template rebind<entry>::other entry_allocator;
typedef typename entry_allocator::pointer entry_pointer;
typedef typename entry_allocator::const_pointer const_entry_pointer;
typedef typename entry_allocator::reference entry_reference;
typedef typename entry_allocator::const_reference const_entry_reference;
typedef typename _Alloc::template rebind<entry_pointer>::other entry_pointer_allocator;
typedef typename entry_pointer_allocator::pointer entry_pointer_array;
typedef PB_DS_RANGED_HASH_FN_C_DEC ranged_hash_fn_base;
typedef PB_DS_HASH_EQ_FN_C_DEC hash_eq_fn_base;
typedef Resize_Policy resize_base;
#ifdef _GLIBCXX_DEBUG
typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base;
#endif
#define PB_DS_GEN_POS std::pair<entry_pointer, typename _Alloc::size_type>
#include <ext/pb_ds/detail/unordered_iterator/point_const_iterator.hpp>
#include <ext/pb_ds/detail/unordered_iterator/point_iterator.hpp>
#include <ext/pb_ds/detail/unordered_iterator/const_iterator.hpp>
#include <ext/pb_ds/detail/unordered_iterator/iterator.hpp>
#undef PB_DS_GEN_POS
public:
typedef _Alloc allocator_type;
typedef typename _Alloc::size_type size_type;
typedef typename _Alloc::difference_type difference_type;
typedef Hash_Fn hash_fn;
typedef Eq_Fn eq_fn;
typedef Comb_Hash_Fn comb_hash_fn;
typedef Resize_Policy resize_policy;
/// Value stores hash, true or false.
enum
{
store_hash = Store_Hash
};
typedef typename traits_base::key_type key_type;
typedef typename traits_base::key_pointer key_pointer;
typedef typename traits_base::key_const_pointer key_const_pointer;
typedef typename traits_base::key_reference key_reference;
typedef typename traits_base::key_const_reference key_const_reference;
typedef typename traits_base::mapped_type mapped_type;
typedef typename traits_base::mapped_pointer mapped_pointer;
typedef typename traits_base::mapped_const_pointer mapped_const_pointer;
typedef typename traits_base::mapped_reference mapped_reference;
typedef typename traits_base::mapped_const_reference mapped_const_reference;
typedef typename traits_base::value_type value_type;
typedef typename traits_base::pointer pointer;
typedef typename traits_base::const_pointer const_pointer;
typedef typename traits_base::reference reference;
typedef typename traits_base::const_reference const_reference;
#ifdef PB_DS_DATA_TRUE_INDICATOR
typedef point_iterator_ point_iterator;
#endif
#ifdef PB_DS_DATA_FALSE_INDICATOR
typedef point_const_iterator_ point_iterator;
#endif
typedef point_const_iterator_ point_const_iterator;
#ifdef PB_DS_DATA_TRUE_INDICATOR
typedef iterator_ iterator;
#endif
#ifdef PB_DS_DATA_FALSE_INDICATOR
typedef const_iterator_ iterator;
#endif
typedef const_iterator_ const_iterator;
PB_DS_CC_HASH_NAME();
PB_DS_CC_HASH_NAME(const Hash_Fn&);
PB_DS_CC_HASH_NAME(const Hash_Fn&, const Eq_Fn&);
PB_DS_CC_HASH_NAME(const Hash_Fn&, const Eq_Fn&, const Comb_Hash_Fn&);
PB_DS_CC_HASH_NAME(const Hash_Fn&, const Eq_Fn&, const Comb_Hash_Fn&,
const Resize_Policy&);
PB_DS_CC_HASH_NAME(const PB_DS_CLASS_C_DEC&);
virtual
~PB_DS_CC_HASH_NAME();
void
swap(PB_DS_CLASS_C_DEC&);
template<typename It>
void
copy_from_range(It, It);
void
initialize();
inline size_type
size() const;
inline size_type
max_size() const;
/// True if size() == 0.
inline bool
empty() const;
/// Return current hash_fn.
Hash_Fn&
get_hash_fn();
/// Return current const hash_fn.
const Hash_Fn&
get_hash_fn() const;
/// Return current eq_fn.
Eq_Fn&
get_eq_fn();
/// Return current const eq_fn.
const Eq_Fn&
get_eq_fn() const;
/// Return current comb_hash_fn.
Comb_Hash_Fn&
get_comb_hash_fn();
/// Return current const comb_hash_fn.
const Comb_Hash_Fn&
get_comb_hash_fn() const;
/// Return current resize_policy.
Resize_Policy&
get_resize_policy();
/// Return current const resize_policy.
const Resize_Policy&
get_resize_policy() const;
inline std::pair<point_iterator, bool>
insert(const_reference r_val)
{ return insert_imp(r_val, traits_base::m_store_extra_indicator); }
inline mapped_reference
operator[](key_const_reference r_key)
{
#ifdef PB_DS_DATA_TRUE_INDICATOR
return (subscript_imp(r_key, traits_base::m_store_extra_indicator));
#else
insert(r_key);
return traits_base::s_null_type;
#endif
}
inline point_iterator
find(key_const_reference);
inline point_const_iterator
find(key_const_reference) const;
inline point_iterator
find_end();
inline point_const_iterator
find_end() const;
inline bool
erase(key_const_reference);
template<typename Pred>
inline size_type
erase_if(Pred);
void
clear();
inline iterator
begin();
inline const_iterator
begin() const;
inline iterator
end();
inline const_iterator
end() const;
#ifdef _GLIBCXX_DEBUG
void
assert_valid(const char*, int) const;
#endif
#ifdef PB_DS_HT_MAP_TRACE_
void
trace() const;
#endif
private:
void
deallocate_all();
inline bool
do_resize_if_needed();
inline void
do_resize_if_needed_no_throw();
void
resize_imp(size_type);
void
do_resize(size_type);
void
resize_imp_no_exceptions(size_type, entry_pointer_array, size_type);
inline entry_pointer
resize_imp_no_exceptions_reassign_pointer(entry_pointer,
entry_pointer_array,
false_type);
inline entry_pointer
resize_imp_no_exceptions_reassign_pointer(entry_pointer,
entry_pointer_array,
true_type);
void
deallocate_links_in_list(entry_pointer);
inline entry_pointer
get_entry(const_reference, false_type);
inline entry_pointer
get_entry(const_reference, true_type);
inline void
rels_entry(entry_pointer);
#ifdef PB_DS_DATA_TRUE_INDICATOR
inline mapped_reference
subscript_imp(key_const_reference r_key, false_type)
{
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
const size_type pos = ranged_hash_fn_base::operator()(r_key);
entry_pointer p_e = m_entries[pos];
resize_base::notify_insert_search_start();
while (p_e != 0
&& !hash_eq_fn_base::operator()(p_e->m_value.first, r_key))
{
resize_base::notify_insert_search_collision();
p_e = p_e->m_p_next;
}
resize_base::notify_insert_search_end();
if (p_e != 0)
{
PB_DS_CHECK_KEY_EXISTS(r_key)
return (p_e->m_value.second);
}
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return insert_new_imp(value_type(r_key, mapped_type()), pos)->second;
}
inline mapped_reference
subscript_imp(key_const_reference r_key, true_type)
{
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(r_key);
entry_pointer p_e = m_entries[pos_hash_pair.first];
resize_base::notify_insert_search_start();
while (p_e != 0 &&
!hash_eq_fn_base::operator()(p_e->m_value.first, p_e->m_hash,
r_key, pos_hash_pair.second))
{
resize_base::notify_insert_search_collision();
p_e = p_e->m_p_next;
}
resize_base::notify_insert_search_end();
if (p_e != 0)
{
PB_DS_CHECK_KEY_EXISTS(r_key)
return p_e->m_value.second;
}
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return insert_new_imp(value_type(r_key, mapped_type()),
pos_hash_pair)->second;
}
#endif
inline std::pair<point_iterator, bool>
insert_imp(const_reference, false_type);
inline std::pair<point_iterator, bool>
insert_imp(const_reference, true_type);
inline pointer
insert_new_imp(const_reference r_val, size_type pos)
{
if (do_resize_if_needed())
pos = ranged_hash_fn_base::operator()(PB_DS_V2F(r_val));
// Following lines might throw an exception.
entry_pointer p_e = get_entry(r_val,
traits_base::m_no_throw_copies_indicator);
// At this point no exceptions can be thrown.
p_e->m_p_next = m_entries[pos];
m_entries[pos] = p_e;
resize_base::notify_inserted(++m_num_used_e);
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_val));)
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
return &p_e->m_value;
}
inline pointer
insert_new_imp(const_reference r_val, comp_hash& r_pos_hash_pair)
{
// Following lines might throw an exception.
if (do_resize_if_needed())
r_pos_hash_pair = ranged_hash_fn_base::operator()(PB_DS_V2F(r_val));
entry_pointer p_e = get_entry(r_val,
traits_base::m_no_throw_copies_indicator);
// At this point no exceptions can be thrown.
p_e->m_hash = r_pos_hash_pair.second;
p_e->m_p_next = m_entries[r_pos_hash_pair.first];
m_entries[r_pos_hash_pair.first] = p_e;
resize_base::notify_inserted(++m_num_used_e);
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_val));)
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
return &p_e->m_value;
}
inline pointer
find_key_pointer(key_const_reference r_key, false_type)
{
entry_pointer p_e = m_entries[ranged_hash_fn_base::operator()(r_key)];
resize_base::notify_find_search_start();
while (p_e != 0 &&
!hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), r_key))
{
resize_base::notify_find_search_collision();
p_e = p_e->m_p_next;
}
resize_base::notify_find_search_end();
#ifdef _GLIBCXX_DEBUG
if (p_e == 0)
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
else
PB_DS_CHECK_KEY_EXISTS(r_key)
#endif
return &p_e->m_value;
}
inline pointer
find_key_pointer(key_const_reference r_key, true_type)
{
comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(r_key);
entry_pointer p_e = m_entries[pos_hash_pair.first];
resize_base::notify_find_search_start();
while (p_e != 0 &&
!hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value),
p_e->m_hash,
r_key, pos_hash_pair.second))
{
resize_base::notify_find_search_collision();
p_e = p_e->m_p_next;
}
resize_base::notify_find_search_end();
#ifdef _GLIBCXX_DEBUG
if (p_e == 0)
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
else
PB_DS_CHECK_KEY_EXISTS(r_key)
#endif
return &p_e->m_value;
}
inline bool
erase_in_pos_imp(key_const_reference, size_type);
inline bool
erase_in_pos_imp(key_const_reference, const comp_hash&);
inline void
erase_entry_pointer(entry_pointer&);
#ifdef PB_DS_DATA_TRUE_INDICATOR
void
inc_it_state(pointer& r_p_value,
std::pair<entry_pointer, size_type>& r_pos) const
{
inc_it_state((mapped_const_pointer& )r_p_value, r_pos);
}
#endif
void
inc_it_state(const_pointer& r_p_value,
std::pair<entry_pointer, size_type>& r_pos) const
{
_GLIBCXX_DEBUG_ASSERT(r_p_value != 0);
r_pos.first = r_pos.first->m_p_next;
if (r_pos.first != 0)
{
r_p_value = &r_pos.first->m_value;
return;
}
for (++r_pos.second; r_pos.second < m_num_e; ++r_pos.second)
if (m_entries[r_pos.second] != 0)
{
r_pos.first = m_entries[r_pos.second];
r_p_value = &r_pos.first->m_value;
return;
}
r_p_value = 0;
}
void
get_start_it_state(pointer& r_p_value,
std::pair<entry_pointer, size_type>& r_pos) const
{
for (r_pos.second = 0; r_pos.second < m_num_e; ++r_pos.second)
if (m_entries[r_pos.second] != 0)
{
r_pos.first = m_entries[r_pos.second];
r_p_value = &r_pos.first->m_value;
return;
}
r_p_value = 0;
}
#ifdef _GLIBCXX_DEBUG
void
assert_entry_pointer_array_valid(const entry_pointer_array,
const char*, int) const;
void
assert_entry_pointer_valid(const entry_pointer, true_type,
const char*, int) const;
void
assert_entry_pointer_valid(const entry_pointer, false_type,
const char*, int) const;
#endif
#ifdef PB_DS_HT_MAP_TRACE_
void
trace_list(const_entry_pointer) const;
#endif
private:
#ifdef PB_DS_DATA_TRUE_INDICATOR
friend class iterator_;
#endif
friend class const_iterator_;
static entry_allocator s_entry_allocator;
static entry_pointer_allocator s_entry_pointer_allocator;
static iterator s_end_it;
static const_iterator s_const_end_it;
static point_iterator s_find_end_it;
static point_const_iterator s_const_find_end_it;
size_type m_num_e;
size_type m_num_used_e;
entry_pointer_array m_entries;
enum
{
store_hash_ok = !Store_Hash
|| !is_same<Hash_Fn, __gnu_pbds::null_type>::value
};
PB_DS_STATIC_ASSERT(sth, store_hash_ok);
};
#include <ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/cc_hash_table_map_/entry_list_fn_imps.hpp>
#include <ext/pb_ds/detail/cc_hash_table_map_/find_fn_imps.hpp>
#include <ext/pb_ds/detail/cc_hash_table_map_/resize_fn_imps.hpp>
#include <ext/pb_ds/detail/cc_hash_table_map_/debug_fn_imps.hpp>
#include <ext/pb_ds/detail/cc_hash_table_map_/size_fn_imps.hpp>
#include <ext/pb_ds/detail/cc_hash_table_map_/policy_access_fn_imps.hpp>
#include <ext/pb_ds/detail/cc_hash_table_map_/erase_fn_imps.hpp>
#include <ext/pb_ds/detail/cc_hash_table_map_/iterators_fn_imps.hpp>
#include <ext/pb_ds/detail/cc_hash_table_map_/insert_fn_imps.hpp>
#include <ext/pb_ds/detail/cc_hash_table_map_/trace_fn_imps.hpp>
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_HASH_EQ_FN_C_DEC
#undef PB_DS_RANGED_HASH_FN_C_DEC
#undef PB_DS_CC_HASH_TRAITS_BASE
#undef PB_DS_DEBUG_MAP_BASE_C_DEC
#undef PB_DS_CC_HASH_NAME
} // namespace detail
} // namespace __gnu_pbds
c++/8/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_fn_imps.hpp 0000644 00000013237 15201526705 0023247 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file cc_hash_table_map_/constructor_destructor_fn_imps.hpp
* Contains implementations of cc_ht_map_'s constructors, destructor,
* and related functions.
*/
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::entry_allocator
PB_DS_CLASS_C_DEC::s_entry_allocator;
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::entry_pointer_allocator
PB_DS_CLASS_C_DEC::s_entry_pointer_allocator;
PB_DS_CLASS_T_DEC
template<typename It>
void
PB_DS_CLASS_C_DEC::
copy_from_range(It first_it, It last_it)
{
while (first_it != last_it)
insert(*(first_it++));
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_CC_HASH_NAME() :
ranged_hash_fn_base(resize_base::get_nearest_larger_size(1)),
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
m_entries(s_entry_pointer_allocator.allocate(m_num_e))
{
initialize();
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_CC_HASH_NAME(const Hash_Fn& r_hash_fn) :
ranged_hash_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn),
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
m_entries(s_entry_pointer_allocator.allocate(m_num_e))
{
initialize();
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_CC_HASH_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn) :
PB_DS_HASH_EQ_FN_C_DEC(r_eq_fn),
ranged_hash_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn),
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
m_entries(s_entry_pointer_allocator.allocate(m_num_e))
{
std::fill(m_entries, m_entries + m_num_e, (entry_pointer)0);
Resize_Policy::notify_cleared();
ranged_hash_fn_base::notify_resized(m_num_e);
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_CC_HASH_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn,
const Comb_Hash_Fn& r_comb_hash_fn) :
PB_DS_HASH_EQ_FN_C_DEC(r_eq_fn),
ranged_hash_fn_base(resize_base::get_nearest_larger_size(1),
r_hash_fn, r_comb_hash_fn),
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
m_entries(s_entry_pointer_allocator.allocate(m_num_e))
{
initialize();
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_CC_HASH_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn,
const Comb_Hash_Fn& r_comb_hash_fn,
const Resize_Policy& r_resize_policy) :
PB_DS_HASH_EQ_FN_C_DEC(r_eq_fn),
Resize_Policy(r_resize_policy),
ranged_hash_fn_base(resize_base::get_nearest_larger_size(1),
r_hash_fn, r_comb_hash_fn),
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
m_entries(s_entry_pointer_allocator.allocate(m_num_e))
{
initialize();
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_CC_HASH_NAME(const PB_DS_CLASS_C_DEC& other) :
PB_DS_HASH_EQ_FN_C_DEC(other),
resize_base(other), ranged_hash_fn_base(other),
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
m_entries(s_entry_pointer_allocator.allocate(m_num_e))
{
initialize();
PB_DS_ASSERT_VALID((*this))
__try
{
copy_from_range(other.begin(), other.end());
}
__catch(...)
{
deallocate_all();
__throw_exception_again;
}
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
~PB_DS_CC_HASH_NAME()
{ deallocate_all(); }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
std::swap(m_entries, other.m_entries);
std::swap(m_num_e, other.m_num_e);
std::swap(m_num_used_e, other.m_num_used_e);
ranged_hash_fn_base::swap(other);
hash_eq_fn_base::swap(other);
resize_base::swap(other);
_GLIBCXX_DEBUG_ONLY(debug_base::swap(other));
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
deallocate_all()
{
clear();
s_entry_pointer_allocator.deallocate(m_entries, m_num_e);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
initialize()
{
std::fill(m_entries, m_entries + m_num_e, entry_pointer(0));
Resize_Policy::notify_resized(m_num_e);
Resize_Policy::notify_cleared();
ranged_hash_fn_base::notify_resized(m_num_e);
}
c++/8/ext/pb_ds/detail/cc_hash_table_map_/size_fn_imps.hpp 0000644 00000004075 15201526705 0017356 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file cc_hash_table_map_/size_fn_imps.hpp
* Contains implementations of cc_ht_map_'s entire container size related
* functions.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
size() const
{ return m_num_used_e; }
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
empty() const
{ return (size() == 0); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
max_size() const
{ return s_entry_allocator.max_size(); }
c++/8/ext/pb_ds/detail/cc_hash_table_map_/trace_fn_imps.hpp 0000644 00000004473 15201526705 0017504 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file cc_hash_table_map_/trace_fn_imps.hpp
* Contains implementations of cc_ht_map_'s trace-mode functions.
*/
#ifdef PB_DS_HT_MAP_TRACE_
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
trace() const
{
std::cerr << static_cast<unsigned long>(m_num_e) << " "
<< static_cast<unsigned long>(m_num_used_e) << std::endl;
for (size_type i = 0; i < m_num_e; ++i)
{
std::cerr << static_cast<unsigned long>(i) << " ";
trace_list(m_entries[i]);
std::cerr << std::endl;
}
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
trace_list(const_entry_pointer p_l) const
{
size_type iterated_num_used_e = 0;
while (p_l != 0)
{
std::cerr << PB_DS_V2F(p_l->m_value) << " ";
p_l = p_l->m_p_next;
}
}
#endif
c++/8/ext/pb_ds/detail/cc_hash_table_map_/resize_no_store_hash_fn_imps.hpp 0000644 00000004302 15201526705 0022611 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file cc_hash_table_map_/resize_no_store_hash_fn_imps.hpp
* Contains implementations of cc_ht_map_'s resize related functions, when the
* hash value is not stored.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::entry_pointer
PB_DS_CLASS_C_DEC::
resize_imp_no_exceptions_reassign_pointer(entry_pointer p_e, entry_pointer_array a_p_entries_resized, false_type)
{
const size_type hash_pos =
ranged_hash_fn_base::operator()(PB_DS_V2F(p_e->m_value));
entry_pointer const p_next_e = p_e->m_p_next;
p_e->m_p_next = a_p_entries_resized[hash_pos];
a_p_entries_resized[hash_pos] = p_e;
return p_next_e;
}
c++/8/ext/pb_ds/detail/cc_hash_table_map_/find_store_hash_fn_imps.hpp 0000644 00000003363 15201526705 0021542 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file cc_hash_table_map_/find_store_hash_fn_imps.hpp
* Contains implementations of cc_ht_map_'s find related functions,
* when the hash value is stored.
*/
c++/8/ext/pb_ds/detail/cc_hash_table_map_/insert_store_hash_fn_imps.hpp 0000644 00000005162 15201526705 0022125 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file cc_hash_table_map_/insert_store_hash_fn_imps.hpp
* Contains implementations of cc_ht_map_'s insert related functions,
* when the hash value is stored.
*/
PB_DS_CLASS_T_DEC
inline std::pair<typename PB_DS_CLASS_C_DEC::point_iterator, bool>
PB_DS_CLASS_C_DEC::
insert_imp(const_reference r_val, true_type)
{
PB_DS_ASSERT_VALID((*this))
key_const_reference key = PB_DS_V2F(r_val);
comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(key);
entry_pointer p_e = m_entries[pos_hash_pair.first];
resize_base::notify_insert_search_start();
while (p_e != 0 && !hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value),
p_e->m_hash,
key, pos_hash_pair.second))
{
resize_base::notify_insert_search_collision();
p_e = p_e->m_p_next;
}
resize_base::notify_insert_search_end();
if (p_e != 0)
{
PB_DS_CHECK_KEY_EXISTS(key)
return std::make_pair(&p_e->m_value, false);
}
PB_DS_CHECK_KEY_DOES_NOT_EXIST(key)
return std::make_pair(insert_new_imp(r_val, pos_hash_pair), true);
}
c++/8/ext/pb_ds/detail/cc_hash_table_map_/erase_no_store_hash_fn_imps.hpp 0000644 00000006300 15201526705 0022407 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file cc_hash_table_map_/erase_no_store_hash_fn_imps.hpp
* Contains implementations of cc_ht_map_'s erase related functions,
* when the hash value is not stored.
*/
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
erase(key_const_reference r_key)
{
PB_DS_ASSERT_VALID((*this))
return erase_in_pos_imp(r_key, ranged_hash_fn_base::operator()(r_key));
}
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
erase_in_pos_imp(key_const_reference r_key, size_type pos)
{
PB_DS_ASSERT_VALID((*this))
entry_pointer p_e = m_entries[pos];
resize_base::notify_erase_search_start();
if (p_e == 0)
{
resize_base::notify_erase_search_end();
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
PB_DS_ASSERT_VALID((*this))
return false;
}
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), r_key))
{
resize_base::notify_erase_search_end();
PB_DS_CHECK_KEY_EXISTS(r_key)
erase_entry_pointer(m_entries[pos]);
do_resize_if_needed_no_throw();
PB_DS_ASSERT_VALID((*this))
return true;
}
while (true)
{
entry_pointer p_next_e = p_e->m_p_next;
if (p_next_e == 0)
{
resize_base::notify_erase_search_end();
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
PB_DS_ASSERT_VALID((*this))
return false;
}
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_next_e->m_value), r_key))
{
resize_base::notify_erase_search_end();
PB_DS_CHECK_KEY_EXISTS(r_key)
erase_entry_pointer(p_e->m_p_next);
do_resize_if_needed_no_throw();
PB_DS_ASSERT_VALID((*this))
return true;
}
resize_base::notify_erase_search_collision();
p_e = p_next_e;
}
}
c++/8/ext/pb_ds/detail/cc_hash_table_map_/cond_key_dtor_entry_dealtor.hpp 0000644 00000005472 15201526705 0022451 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file cc_hash_table_map_/cond_key_dtor_entry_dealtor.hpp
* Contains a conditional key destructor, used for exception handling.
*/
namespace __gnu_pbds
{
namespace detail
{
/// Conditional dey destructor, cc_hash.
template<typename HT_Map>
class cond_dealtor
{
public:
typedef typename HT_Map::entry entry;
typedef typename HT_Map::entry_allocator entry_allocator;
typedef typename HT_Map::key_type key_type;
cond_dealtor(entry_allocator* p_a, entry* p_e)
: m_p_a(p_a), m_p_e(p_e), m_key_destruct(false),
m_no_action_destructor(false)
{ }
inline
~cond_dealtor();
void
set_key_destruct()
{ m_key_destruct = true; }
void
set_no_action_destructor()
{ m_no_action_destructor = true; }
protected:
entry_allocator* const m_p_a;
entry* const m_p_e;
bool m_key_destruct;
bool m_no_action_destructor;
};
template<typename HT_Map>
inline
cond_dealtor<HT_Map>::
~cond_dealtor()
{
if (m_no_action_destructor)
return;
if (m_key_destruct)
m_p_e->m_value.first.~key_type();
m_p_a->deallocate(m_p_e, 1);
}
} // namespace detail
} // namespace __gnu_pbds
c++/8/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp 0000644 00000004262 15201526705 0026160 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file cc_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp
* Contains implementations of cc_ht_map_'s constructors, destructor,
* and related functions.
*/
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
constructor_insert_new_imp(mapped_const_reference r_val, size_type pos,
false_type)
{
// Following lines might throw an exception.
entry_pointer p = get_entry(r_val, traits_base::s_no_throw_copies_indicator);
// At this point no exceptions can be thrown.
p->m_p_next = m_entries[pos];
m_entries[pos] = p;
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(r_key);)
}
c++/8/ext/pb_ds/detail/cc_hash_table_map_/policy_access_fn_imps.hpp 0000644 00000004661 15201526705 0021225 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file cc_hash_table_map_/policy_access_fn_imps.hpp
* Contains implementations of cc_ht_map_'s policy access
* functions.
*/
PB_DS_CLASS_T_DEC
Hash_Fn&
PB_DS_CLASS_C_DEC::
get_hash_fn()
{ return *this; }
PB_DS_CLASS_T_DEC
const Hash_Fn&
PB_DS_CLASS_C_DEC::
get_hash_fn() const
{ return *this; }
PB_DS_CLASS_T_DEC
Eq_Fn&
PB_DS_CLASS_C_DEC::
get_eq_fn()
{ return *this; }
PB_DS_CLASS_T_DEC
const Eq_Fn&
PB_DS_CLASS_C_DEC::
get_eq_fn() const
{ return *this; }
PB_DS_CLASS_T_DEC
Comb_Hash_Fn&
PB_DS_CLASS_C_DEC::
get_comb_hash_fn()
{ return *this; }
PB_DS_CLASS_T_DEC
const Comb_Hash_Fn&
PB_DS_CLASS_C_DEC::
get_comb_hash_fn() const
{ return *this; }
PB_DS_CLASS_T_DEC
Resize_Policy&
PB_DS_CLASS_C_DEC::
get_resize_policy()
{ return *this; }
PB_DS_CLASS_T_DEC
const Resize_Policy&
PB_DS_CLASS_C_DEC::
get_resize_policy() const
{ return *this; }
c++/8/ext/pb_ds/detail/types_traits.hpp 0000644 00000023416 15201526705 0013670 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file detail/types_traits.hpp
* Contains a traits class of types used by containers.
*/
#ifndef PB_DS_TYPES_TRAITS_HPP
#define PB_DS_TYPES_TRAITS_HPP
#include <algorithm>
#include <utility>
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/pb_ds/detail/type_utils.hpp>
#include <utility>
namespace __gnu_pbds
{
namespace detail
{
/**
* @addtogroup traits Traits
* @{
*/
/// Primary template.
template<typename Key, typename Mapped>
struct no_throw_copies
{
static const bool __simple = is_simple<Key>::value
&& is_simple<Mapped>::value;
typedef integral_constant<int, __simple> indicator;
};
/// Specialization.
template<typename Key>
struct no_throw_copies<Key, null_type>
{
typedef integral_constant<int, is_simple<Key>::value> indicator;
};
/// Stored value.
template<typename _Tv>
struct stored_value
{
typedef _Tv value_type;
value_type m_value;
};
/// Stored hash.
template<typename _Th>
struct stored_hash
{
typedef _Th hash_type;
hash_type m_hash;
};
/// Primary template for representation of stored data.
/// Two types of data can be stored: value and hash.
template<typename _Tv, typename _Th>
struct stored_data
: public stored_value<_Tv>, public stored_hash<_Th>
{ };
/// Specialization for representation of stored data of just value type.
template<typename _Tv>
struct stored_data<_Tv, null_type>
: public stored_value<_Tv>
{ };
/// Primary template.
template<typename Key, typename Mapped, typename _Alloc, bool Store_Hash>
struct type_base;
/**
* Specialization of type_base for the case where the hash value
* is not stored alongside each value.
*/
template<typename Key, typename Mapped, typename _Alloc>
struct type_base<Key, Mapped, _Alloc, false>
{
public:
typedef typename _Alloc::size_type size_type;
private:
typedef typename _Alloc::template rebind<Mapped> __rebind_m;
typedef typename __rebind_m::other __rebind_ma;
typedef std::pair<const Key, Mapped> __value_type;
typedef typename _Alloc::template rebind<__value_type> __rebind_v;
typedef typename __rebind_v::other __rebind_va;
public:
typedef typename __rebind_ma::value_type mapped_type;
typedef typename __rebind_ma::pointer mapped_pointer;
typedef typename __rebind_ma::const_pointer mapped_const_pointer;
typedef typename __rebind_ma::reference mapped_reference;
typedef typename __rebind_ma::const_reference mapped_const_reference;
typedef typename __rebind_va::value_type value_type;
typedef typename __rebind_va::pointer pointer;
typedef typename __rebind_va::const_pointer const_pointer;
typedef typename __rebind_va::reference reference;
typedef typename __rebind_va::const_reference const_reference;
typedef stored_data<value_type, null_type> stored_data_type;
};
/**
* Specialization of type_base for the case where the hash value
* is stored alongside each value.
*/
template<typename Key, typename Mapped, typename _Alloc>
struct type_base<Key, Mapped, _Alloc, true>
{
public:
typedef typename _Alloc::size_type size_type;
private:
typedef typename _Alloc::template rebind<Mapped> __rebind_m;
typedef typename __rebind_m::other __rebind_ma;
typedef std::pair<const Key, Mapped> __value_type;
typedef typename _Alloc::template rebind<__value_type> __rebind_v;
typedef typename __rebind_v::other __rebind_va;
public:
typedef typename __rebind_ma::value_type mapped_type;
typedef typename __rebind_ma::pointer mapped_pointer;
typedef typename __rebind_ma::const_pointer mapped_const_pointer;
typedef typename __rebind_ma::reference mapped_reference;
typedef typename __rebind_ma::const_reference mapped_const_reference;
typedef typename __rebind_va::value_type value_type;
typedef typename __rebind_va::pointer pointer;
typedef typename __rebind_va::const_pointer const_pointer;
typedef typename __rebind_va::reference reference;
typedef typename __rebind_va::const_reference const_reference;
typedef stored_data<value_type, size_type> stored_data_type;
};
/**
* Specialization of type_base for the case where the hash value
* is not stored alongside each value.
*/
template<typename Key, typename _Alloc>
struct type_base<Key, null_type, _Alloc, false>
{
public:
typedef typename _Alloc::size_type size_type;
typedef Key value_type;
private:
typedef typename _Alloc::template rebind<null_type> __rebind_m;
typedef typename __rebind_m::other __rebind_ma;
typedef typename _Alloc::template rebind<value_type> __rebind_v;
typedef typename __rebind_v::other __rebind_va;
public:
typedef typename __rebind_ma::value_type mapped_type;
typedef typename __rebind_ma::pointer mapped_pointer;
typedef typename __rebind_ma::const_pointer mapped_const_pointer;
typedef typename __rebind_ma::reference mapped_reference;
typedef typename __rebind_ma::const_reference mapped_const_reference;
typedef typename __rebind_va::pointer pointer;
typedef typename __rebind_va::const_pointer const_pointer;
typedef typename __rebind_va::reference reference;
typedef typename __rebind_va::const_reference const_reference;
typedef stored_data<value_type, null_type> stored_data_type;
static null_type s_null_type;
};
template<typename Key, typename _Alloc>
null_type
type_base<Key, null_type, _Alloc, false>::s_null_type;
/**
* Specialization of type_base for the case where the hash value
* is stored alongside each value.
*/
template<typename Key, typename _Alloc>
struct type_base<Key, null_type, _Alloc, true>
{
public:
typedef typename _Alloc::size_type size_type;
typedef Key value_type;
private:
typedef typename _Alloc::template rebind<null_type> __rebind_m;
typedef typename __rebind_m::other __rebind_ma;
typedef typename _Alloc::template rebind<value_type> __rebind_v;
typedef typename __rebind_v::other __rebind_va;
public:
typedef typename __rebind_ma::value_type mapped_type;
typedef typename __rebind_ma::pointer mapped_pointer;
typedef typename __rebind_ma::const_pointer mapped_const_pointer;
typedef typename __rebind_ma::reference mapped_reference;
typedef typename __rebind_ma::const_reference mapped_const_reference;
typedef typename __rebind_va::pointer pointer;
typedef typename __rebind_va::const_pointer const_pointer;
typedef typename __rebind_va::reference reference;
typedef typename __rebind_va::const_reference const_reference;
typedef stored_data<value_type, size_type> stored_data_type;
static null_type s_null_type;
};
template<typename Key, typename _Alloc>
null_type
type_base<Key, null_type, _Alloc, true>::s_null_type;
/// Type base dispatch.
template<typename Key, typename Mapped, typename _Alloc, bool Store_Hash>
struct type_dispatch
{
typedef type_base<Key, Mapped, _Alloc, Store_Hash> type;
};
/// Traits for abstract types.
template<typename Key, typename Mapped, typename _Alloc, bool Store_Hash>
struct types_traits
: public type_dispatch<Key, Mapped, _Alloc, Store_Hash>::type
{
private:
typedef no_throw_copies<Key, Mapped> __nothrowcopy;
typedef typename _Alloc::template rebind<Key>::other __rebind_a;
public:
typedef typename _Alloc::size_type size_type;
typedef typename __rebind_a::value_type key_type;
typedef typename __rebind_a::pointer key_pointer;
typedef typename __rebind_a::const_pointer key_const_pointer;
typedef typename __rebind_a::reference key_reference;
typedef typename __rebind_a::const_reference key_const_reference;
typedef std::pair<size_type, size_type> comp_hash;
typedef integral_constant<int, Store_Hash> store_extra;
typedef typename __nothrowcopy::indicator no_throw_indicator;
store_extra m_store_extra_indicator;
no_throw_indicator m_no_throw_copies_indicator;
};
//@}
} // namespace detail
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/detail/tree_trace_base.hpp 0000644 00000012016 15201526705 0014237 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file detail/tree_trace_base.hpp
* Contains tree-related policies.
*/
#ifndef PB_DS_TREE_TRACE_BASE_HPP
#define PB_DS_TREE_TRACE_BASE_HPP
#ifdef PB_DS_TREE_TRACE
#include <ext/pb_ds/detail/branch_policy/branch_policy.hpp>
#include <ext/pb_ds/detail/branch_policy/null_node_metadata.hpp>
namespace __gnu_pbds
{
namespace detail
{
#ifdef PB_DS_TREE_TRACE
#define PB_DS_CLASS_T_DEC \
template<typename Node_CItr, typename Node_Itr, \
typename Cmp_Fn, bool Node_Based, typename _Alloc>
#define PB_DS_CLASS_C_DEC \
tree_trace_base<Node_CItr, Node_Itr, Cmp_Fn, \
Node_Based, _Alloc>
#define PB_DS_TRACE_BASE \
branch_policy<Node_CItr, Node_Itr, _Alloc>
/// Tracing base class.
template<typename Node_CItr, typename Node_Itr,
typename Cmp_Fn, bool Node_Based, typename _Alloc>
class tree_trace_base : private PB_DS_TRACE_BASE
{
public:
void
trace() const;
private:
typedef PB_DS_TRACE_BASE base_type;
typedef Node_CItr node_const_iterator;
typedef typename _Alloc::size_type size_type;
void
trace_node(node_const_iterator, size_type) const;
virtual bool
empty() const = 0;
virtual node_const_iterator
node_begin() const = 0;
virtual node_const_iterator
node_end() const = 0;
static void
print_node_pointer(Node_CItr, integral_constant<int,true>);
static void
print_node_pointer(Node_CItr, integral_constant<int,false>);
template<typename Metadata_>
static void
trace_it_metadata(Node_CItr, type_to_type<Metadata_>);
static void
trace_it_metadata(Node_CItr, type_to_type<null_type>);
};
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
trace() const
{
if (empty())
return;
trace_node(node_begin(), 0);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
trace_node(node_const_iterator nd_it, size_type level) const
{
if (nd_it.get_r_child() != node_end())
trace_node(nd_it.get_r_child(), level + 1);
for (size_type i = 0; i < level; ++i)
std::cerr << ' ';
print_node_pointer(nd_it, integral_constant<int,Node_Based>());
std::cerr << base_type::extract_key(*(*nd_it));
typedef type_to_type<typename node_const_iterator::metadata_type>
m_type_ind_t;
trace_it_metadata(nd_it, m_type_ind_t());
std::cerr << std::endl;
if (nd_it.get_l_child() != node_end())
trace_node(nd_it.get_l_child(), level + 1);
}
PB_DS_CLASS_T_DEC
template<typename Metadata_>
void
PB_DS_CLASS_C_DEC::
trace_it_metadata(Node_CItr nd_it, type_to_type<Metadata_>)
{
const unsigned long ul = static_cast<unsigned long>(nd_it.get_metadata());
std::cerr << " (" << ul << ") ";
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
trace_it_metadata(Node_CItr, type_to_type<null_type>)
{ }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
print_node_pointer(Node_CItr nd_it, integral_constant<int,true>)
{ std::cerr << nd_it.m_p_nd << " "; }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
print_node_pointer(Node_CItr nd_it, integral_constant<int,false>)
{ std::cerr << *nd_it << " "; }
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_TRACE_BASE
#endif // #ifdef PB_DS_TREE_TRACE
} // namespace detail
} // namespace __gnu_pbds
#endif // #ifdef PB_DS_TREE_TRACE
#endif // #ifndef PB_DS_TREE_TRACE_BASE_HPP
c++/8/ext/pb_ds/detail/gp_hash_table_map_/insert_no_store_hash_fn_imps.hpp 0000644 00000007301 15201526705 0022637 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file gp_hash_table_map_/insert_no_store_hash_fn_imps.hpp
* Contains implementations of gp_ht_map_'s insert related functions,
* when the hash value is not stored.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
find_ins_pos(key_const_reference r_key, false_type)
{
size_type hash = ranged_probe_fn_base::operator()(r_key);
size_type i;
/* The insertion position is initted to a non-legal value to indicate
* that it has not been initted yet.
*/
size_type ins_pos = m_num_e;
resize_base::notify_insert_search_start();
for (i = 0; i < m_num_e; ++i)
{
const size_type pos = ranged_probe_fn_base::operator()(r_key, hash, i);
_GLIBCXX_DEBUG_ASSERT(pos < m_num_e);
entry* const p_e = m_entries + pos;
switch(p_e->m_stat)
{
case empty_entry_status:
{
resize_base::notify_insert_search_end();
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return (ins_pos == m_num_e) ? pos : ins_pos;
}
break;
case erased_entry_status:
if (ins_pos == m_num_e)
ins_pos = pos;
break;
case valid_entry_status:
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), r_key))
{
resize_base::notify_insert_search_end();
PB_DS_CHECK_KEY_EXISTS(r_key)
return pos;
}
break;
default:
_GLIBCXX_DEBUG_ASSERT(0);
};
resize_base::notify_insert_search_collision();
}
resize_base::notify_insert_search_end();
if (ins_pos == m_num_e)
__throw_insert_error();
return ins_pos;
}
PB_DS_CLASS_T_DEC
inline std::pair<typename PB_DS_CLASS_C_DEC::point_iterator, bool>
PB_DS_CLASS_C_DEC::
insert_imp(const_reference r_val, false_type)
{
key_const_reference r_key = PB_DS_V2F(r_val);
const size_type pos = find_ins_pos(r_key,
traits_base::m_store_extra_indicator);
if (m_entries[pos].m_stat == valid_entry_status)
{
PB_DS_CHECK_KEY_EXISTS(r_key)
return std::make_pair(&(m_entries + pos)->m_value, false);
}
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return std::make_pair(insert_new_imp(r_val, pos), true);
}
c++/8/ext/pb_ds/detail/gp_hash_table_map_/info_fn_imps.hpp 0000644 00000004074 15201526705 0017357 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file gp_hash_table_map_/info_fn_imps.hpp
* Contains implementations of gp_ht_map_'s entire container info related
* functions.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
size() const
{ return m_num_used_e; }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
max_size() const
{ return s_entry_allocator.max_size(); }
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
empty() const
{ return (size() == 0); }
c++/8/ext/pb_ds/detail/gp_hash_table_map_/find_no_store_hash_fn_imps.hpp 0000644 00000003604 15201526705 0022255 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file gp_hash_table_map_/find_no_store_hash_fn_imps.hpp
* Contains implementations of gp_ht_map_'s find related functions,
* when the hash value is not stored.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::pointer
PB_DS_CLASS_C_DEC::
find_key_pointer(key_const_reference r_key, false_type)
c++/8/ext/pb_ds/detail/gp_hash_table_map_/erase_store_hash_fn_imps.hpp 0000644 00000005547 15201526705 0021750 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file gp_hash_table_map_/erase_store_hash_fn_imps.hpp
* Contains implementations of gp_ht_map_'s erase related functions,
* when the hash value is stored.
*/
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
erase_imp(key_const_reference r_key, true_type)
{
const comp_hash pos_hash_pair = ranged_probe_fn_base::operator()(r_key);
size_type i;
resize_base::notify_erase_search_start();
for (i = 0; i < m_num_e; ++i)
{
const size_type pos = ranged_probe_fn_base::operator()(r_key, pos_hash_pair.second, i);
entry* const p_e = m_entries + pos;
switch(p_e->m_stat)
{
case empty_entry_status:
{
resize_base::notify_erase_search_end();
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return false;
}
break;
case valid_entry_status:
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), p_e->m_hash,
r_key, pos_hash_pair.second))
{
resize_base::notify_erase_search_end();
erase_entry(p_e);
do_resize_if_needed_no_throw();
return true;
}
break;
case erased_entry_status:
break;
default:
_GLIBCXX_DEBUG_ASSERT(0);
};
resize_base::notify_erase_search_collision();
}
resize_base::notify_erase_search_end();
return false;
}
c++/8/ext/pb_ds/detail/gp_hash_table_map_/debug_fn_imps.hpp 0000644 00000004176 15201526705 0017515 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file gp_hash_table_map_/debug_fn_imps.hpp
* Contains implementations of gp_ht_map_'s debug-mode functions.
*/
#ifdef _GLIBCXX_DEBUG
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_valid(const char* __file, int __line) const
{
debug_base::check_size(m_num_used_e, __file, __line);
assert_entry_array_valid(m_entries, traits_base::m_store_extra_indicator,
__file, __line);
}
#include <ext/pb_ds/detail/gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp>
#include <ext/pb_ds/detail/gp_hash_table_map_/debug_store_hash_fn_imps.hpp>
#endif
c++/8/ext/pb_ds/detail/gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp 0000644 00000004711 15201526705 0022423 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp
* Contains implementations of gp_ht_map_'s debug-mode functions.
*/
#ifdef _GLIBCXX_DEBUG
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_entry_array_valid(const entry_array a_entries, false_type,
const char* __file, int __line) const
{
size_type iterated_num_used_e = 0;
for (size_type pos = 0; pos < m_num_e; ++pos)
{
const_entry_pointer p_e = &a_entries[pos];
switch(p_e->m_stat)
{
case empty_entry_status:
case erased_entry_status:
break;
case valid_entry_status:
{
key_const_reference r_key = PB_DS_V2F(p_e->m_value);
debug_base::check_key_exists(r_key, __file, __line);
++iterated_num_used_e;
break;
}
default:
PB_DS_DEBUG_VERIFY(0);
};
}
PB_DS_DEBUG_VERIFY(iterated_num_used_e == m_num_used_e);
}
#endif
c++/8/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp 0000644 00000004335 15201526705 0025506 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file gp_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp
* Contains implementations of gp_ht_map_'s constructors, destructor,
* and related functions.
*/
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
constructor_insert_new_imp(mapped_const_reference r_val, size_type pos,
true_type)
{
_GLIBCXX_DEBUG_ASSERT(m_entries[pos].m_stat != valid_entry_status);
entry* const p_e = m_entries + pos;
new (&p_e->m_value) mapped_value_type(r_val);
p_e->m_hash = ranged_probe_fn_base::operator()(PB_DS_V2F(r_val)).second;
p_e->m_stat = valid_entry_status;
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(p_e->m_value.first);)
}
c++/8/ext/pb_ds/detail/gp_hash_table_map_/find_fn_imps.hpp 0000644 00000004656 15201526705 0017352 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file gp_hash_table_map_/find_fn_imps.hpp
* Contains implementations of gp_ht_map_'s find related functions.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC::
find(key_const_reference r_key)
{
PB_DS_ASSERT_VALID((*this))
return find_key_pointer(r_key, traits_base::m_store_extra_indicator);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_const_iterator
PB_DS_CLASS_C_DEC::
find(key_const_reference r_key) const
{
PB_DS_ASSERT_VALID((*this))
return const_cast<PB_DS_CLASS_C_DEC&>(*this).find_key_pointer(r_key, traits_base::m_store_extra_indicator);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC::
find_end()
{ return 0; }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_const_iterator
PB_DS_CLASS_C_DEC::
find_end() const
{ return 0; }
c++/8/ext/pb_ds/detail/gp_hash_table_map_/resize_store_hash_fn_imps.hpp 0000644 00000005133 15201526705 0022141 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file gp_hash_table_map_/resize_store_hash_fn_imps.hpp
* Contains implementations of gp_ht_map_'s resize related functions, when the
* hash value is stored.
*/
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
resize_imp_reassign(entry_pointer p_e, entry_array a_entries_resized,
true_type)
{
key_const_reference r_key = PB_DS_V2F(p_e->m_value);
size_type hash = ranged_probe_fn_base::operator()(r_key, p_e->m_hash);
size_type i;
for (i = 0; i < m_num_e; ++i)
{
const size_type pos = ranged_probe_fn_base::operator()(r_key, hash, i);
entry_pointer p_new_e = a_entries_resized + pos;
switch(p_new_e->m_stat)
{
case empty_entry_status:
new (&p_new_e->m_value) value_type(p_e->m_value);
p_new_e->m_hash = hash;
p_new_e->m_stat = valid_entry_status;
return;
case erased_entry_status:
_GLIBCXX_DEBUG_ASSERT(0);
break;
case valid_entry_status:
break;
default:
_GLIBCXX_DEBUG_ASSERT(0);
};
}
__throw_insert_error();
}
c++/8/ext/pb_ds/detail/gp_hash_table_map_/debug_store_hash_fn_imps.hpp 0000644 00000005125 15201526705 0021727 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file gp_hash_table_map_/debug_store_hash_fn_imps.hpp
* Contains implementations of gp_ht_map_'s debug-mode functions.
*/
#ifdef _GLIBCXX_DEBUG
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_entry_array_valid(const entry_array a_entries, true_type,
const char* __file, int __line) const
{
size_type iterated_num_used_e = 0;
for (size_type pos = 0; pos < m_num_e; ++pos)
{
const_entry_pointer p_e =& a_entries[pos];
switch(p_e->m_stat)
{
case empty_entry_status:
case erased_entry_status:
break;
case valid_entry_status:
{
key_const_reference r_key = PB_DS_V2F(p_e->m_value);
debug_base::check_key_exists(r_key, __file, __line);
const comp_hash pos_hash_pair = ranged_probe_fn_base::operator()(r_key);
PB_DS_DEBUG_VERIFY(p_e->m_hash == pos_hash_pair.second);
++iterated_num_used_e;
break;
}
default:
PB_DS_DEBUG_VERIFY(0);
};
}
PB_DS_DEBUG_VERIFY(iterated_num_used_e == m_num_used_e);
}
#endif
c++/8/ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp 0000644 00000010075 15201526705 0017723 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file gp_hash_table_map_/resize_fn_imps.hpp
* Contains implementations of gp_ht_map_'s resize related functions.
*/
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
do_resize_if_needed()
{
if (!resize_base::is_resize_needed())
return false;
resize_imp(resize_base::get_new_size(m_num_e, m_num_used_e));
return true;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
do_resize(size_type n)
{ resize_imp(resize_base::get_nearest_larger_size(n)); }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
do_resize_if_needed_no_throw()
{
if (!resize_base::is_resize_needed())
return;
__try
{
resize_imp(resize_base::get_new_size(m_num_e, m_num_used_e));
}
__catch(...)
{ }
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
resize_imp(size_type new_size)
{
#ifdef PB_DS_REGRESSION
typename _Alloc::group_adjustor adjust(m_num_e);
#endif
if (new_size == m_num_e)
return;
PB_DS_ASSERT_VALID((*this))
const size_type old_size = m_num_e;
entry_array a_entries_resized = 0;
// Following line might throw an exception.
a_entries_resized = s_entry_allocator.allocate(new_size);
ranged_probe_fn_base::notify_resized(new_size);
m_num_e = new_size;
for (size_type i = 0; i < m_num_e; ++i)
a_entries_resized[i].m_stat = empty_entry_status;
__try
{
resize_imp(a_entries_resized, old_size);
}
__catch(...)
{
erase_all_valid_entries(a_entries_resized, new_size);
m_num_e = old_size;
s_entry_allocator.deallocate(a_entries_resized, new_size);
ranged_probe_fn_base::notify_resized(old_size);
__throw_exception_again;
}
// At this point no exceptions can be thrown.
_GLIBCXX_DEBUG_ONLY(assert_entry_array_valid(a_entries_resized,
traits_base::m_store_extra_indicator,
__FILE__, __LINE__);)
Resize_Policy::notify_resized(new_size);
erase_all_valid_entries(m_entries, old_size);
s_entry_allocator.deallocate(m_entries, old_size);
m_entries = a_entries_resized;
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
resize_imp(entry_array a_entries_resized, size_type old_size)
{
for (size_type pos = 0; pos < old_size; ++pos)
if (m_entries[pos].m_stat == valid_entry_status)
resize_imp_reassign(m_entries + pos, a_entries_resized,
traits_base::m_store_extra_indicator);
}
#include <ext/pb_ds/detail/gp_hash_table_map_/resize_no_store_hash_fn_imps.hpp>
#include <ext/pb_ds/detail/gp_hash_table_map_/resize_store_hash_fn_imps.hpp>
c++/8/ext/pb_ds/detail/gp_hash_table_map_/insert_fn_imps.hpp 0000644 00000003550 15201526705 0017726 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file gp_hash_table_map_/insert_fn_imps.hpp
* Contains implementations of gp_ht_map_'s insert related functions.
*/
#include <ext/pb_ds/detail/gp_hash_table_map_/insert_no_store_hash_fn_imps.hpp>
#include <ext/pb_ds/detail/gp_hash_table_map_/insert_store_hash_fn_imps.hpp>
c++/8/ext/pb_ds/detail/gp_hash_table_map_/iterator_fn_imps.hpp 0000644 00000005073 15201526705 0020255 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file gp_hash_table_map_/iterator_fn_imps.hpp
* Contains implementations of gp_ht_map_'s iterators related functions, e.g.,
* begin().
*/
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::s_end_it;
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::s_const_end_it;
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
begin()
{
pointer_ p_value;
size_type pos;
get_start_it_state(p_value, pos);
return iterator(p_value, pos, this);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
end()
{ return s_end_it; }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
begin() const
{
const_pointer_ p_value;
size_type pos;
get_start_it_state(p_value, pos);
return const_iterator(p_value, pos, this);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
end() const
{ return s_const_end_it; }
c++/8/ext/pb_ds/detail/gp_hash_table_map_/erase_fn_imps.hpp 0000644 00000006204 15201526705 0017520 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file gp_hash_table_map_/erase_fn_imps.hpp
* Contains implementations of gp_ht_map_'s erase related functions.
*/
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
erase_entry(entry_pointer p_e)
{
_GLIBCXX_DEBUG_ASSERT(p_e->m_stat = valid_entry_status);
_GLIBCXX_DEBUG_ONLY(debug_base::erase_existing(PB_DS_V2F(p_e->m_value));)
p_e->m_value.~value_type();
p_e->m_stat = erased_entry_status;
_GLIBCXX_DEBUG_ASSERT(m_num_used_e > 0);
resize_base::notify_erased(--m_num_used_e);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
clear()
{
for (size_type pos = 0; pos < m_num_e; ++pos)
{
entry_pointer p_e = &m_entries[pos];
if (p_e->m_stat == valid_entry_status)
erase_entry(p_e);
}
do_resize_if_needed_no_throw();
resize_base::notify_cleared();
}
PB_DS_CLASS_T_DEC
template<typename Pred>
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
erase_if(Pred pred)
{
PB_DS_ASSERT_VALID((*this))
size_type num_ersd = 0;
for (size_type pos = 0; pos < m_num_e; ++pos)
{
entry_pointer p_e = &m_entries[pos];
if (p_e->m_stat == valid_entry_status)
if (pred(p_e->m_value))
{
++num_ersd;
erase_entry(p_e);
}
}
do_resize_if_needed_no_throw();
PB_DS_ASSERT_VALID((*this))
return num_ersd;
}
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
erase(key_const_reference r_key)
{ return erase_imp(r_key, traits_base::m_store_extra_indicator); }
#include <ext/pb_ds/detail/gp_hash_table_map_/erase_no_store_hash_fn_imps.hpp>
#include <ext/pb_ds/detail/gp_hash_table_map_/erase_store_hash_fn_imps.hpp>
c++/8/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_fn_imps.hpp 0000644 00000014716 15201526705 0023273 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file gp_hash_table_map_/constructor_destructor_fn_imps.hpp
* Contains implementations of gp_ht_map_'s constructors, destructor,
* and related functions.
*/
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::entry_allocator
PB_DS_CLASS_C_DEC::s_entry_allocator;
PB_DS_CLASS_T_DEC
template<typename It>
void
PB_DS_CLASS_C_DEC::
copy_from_range(It first_it, It last_it)
{
while (first_it != last_it)
insert(*(first_it++));
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_GP_HASH_NAME()
: ranged_probe_fn_base(resize_base::get_nearest_larger_size(1)),
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
m_entries(s_entry_allocator.allocate(m_num_e))
{
initialize();
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_GP_HASH_NAME(const Hash_Fn& r_hash_fn)
: ranged_probe_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn),
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
m_entries(s_entry_allocator.allocate(m_num_e))
{
initialize();
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_GP_HASH_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn)
: hash_eq_fn_base(r_eq_fn),
ranged_probe_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn),
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
m_entries(s_entry_allocator.allocate(m_num_e))
{
initialize();
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_GP_HASH_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn,
const Comb_Probe_Fn& r_comb_hash_fn)
: hash_eq_fn_base(r_eq_fn),
ranged_probe_fn_base(resize_base::get_nearest_larger_size(1),
r_hash_fn, r_comb_hash_fn),
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
m_entries(s_entry_allocator.allocate(m_num_e))
{
initialize();
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_GP_HASH_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn,
const Comb_Probe_Fn& comb_hash_fn, const Probe_Fn& prober)
: hash_eq_fn_base(r_eq_fn),
ranged_probe_fn_base(resize_base::get_nearest_larger_size(1),
r_hash_fn, comb_hash_fn, prober),
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
m_entries(s_entry_allocator.allocate(m_num_e))
{
initialize();
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_GP_HASH_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn,
const Comb_Probe_Fn& comb_hash_fn, const Probe_Fn& prober,
const Resize_Policy& r_resize_policy)
: hash_eq_fn_base(r_eq_fn), resize_base(r_resize_policy),
ranged_probe_fn_base(resize_base::get_nearest_larger_size(1),
r_hash_fn, comb_hash_fn, prober),
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
m_entries(s_entry_allocator.allocate(m_num_e))
{
initialize();
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_GP_HASH_NAME(const PB_DS_CLASS_C_DEC& other) :
#ifdef _GLIBCXX_DEBUG
debug_base(other),
#endif
hash_eq_fn_base(other),
resize_base(other),
ranged_probe_fn_base(other),
m_num_e(other.m_num_e),
m_num_used_e(other.m_num_used_e),
m_entries(s_entry_allocator.allocate(m_num_e))
{
for (size_type i = 0; i < m_num_e; ++i)
m_entries[i].m_stat = (entry_status)empty_entry_status;
__try
{
for (size_type i = 0; i < m_num_e; ++i)
{
m_entries[i].m_stat = other.m_entries[i].m_stat;
if (m_entries[i].m_stat == valid_entry_status)
new (m_entries + i) entry(other.m_entries[i]);
}
}
__catch(...)
{
deallocate_all();
__throw_exception_again;
}
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
~PB_DS_GP_HASH_NAME()
{ deallocate_all(); }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
std::swap(m_num_e, other.m_num_e);
std::swap(m_num_used_e, other.m_num_used_e);
std::swap(m_entries, other.m_entries);
ranged_probe_fn_base::swap(other);
hash_eq_fn_base::swap(other);
resize_base::swap(other);
_GLIBCXX_DEBUG_ONLY(debug_base::swap(other));
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
deallocate_all()
{
clear();
erase_all_valid_entries(m_entries, m_num_e);
s_entry_allocator.deallocate(m_entries, m_num_e);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
erase_all_valid_entries(entry_array a_entries_resized, size_type len)
{
for (size_type pos = 0; pos < len; ++pos)
{
entry_pointer p_e = &a_entries_resized[pos];
if (p_e->m_stat == valid_entry_status)
p_e->m_value.~value_type();
}
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
initialize()
{
Resize_Policy::notify_resized(m_num_e);
Resize_Policy::notify_cleared();
ranged_probe_fn_base::notify_resized(m_num_e);
for (size_type i = 0; i < m_num_e; ++i)
m_entries[i].m_stat = empty_entry_status;
}
c++/8/ext/pb_ds/detail/gp_hash_table_map_/trace_fn_imps.hpp 0000644 00000004570 15201526705 0017523 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file gp_hash_table_map_/trace_fn_imps.hpp
* Contains implementations of gp_ht_map_'s trace-mode functions.
*/
#ifdef PB_DS_HT_MAP_TRACE_
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
trace() const
{
std::cerr << static_cast<unsigned long>(m_num_e) << " " <<
static_cast<unsigned long>(m_num_used_e) << std::endl;
for (size_type i = 0; i < m_num_e; ++i)
{
std::cerr << static_cast<unsigned long>(i) << " ";
switch(m_entries[i].m_stat)
{
case empty_entry_status:
std::cerr << "<empty>";
break;
case erased_entry_status:
std::cerr << "<erased>";
break;
case valid_entry_status:
std::cerr << PB_DS_V2F(m_entries[i].m_value);
break;
default:
_GLIBCXX_DEBUG_ASSERT(0);
};
std::cerr << std::endl;
}
}
#endif // #ifdef PB_DS_HT_MAP_TRACE_
c++/8/ext/pb_ds/detail/gp_hash_table_map_/resize_no_store_hash_fn_imps.hpp 0000644 00000005072 15201526705 0022637 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file gp_hash_table_map_/resize_no_store_hash_fn_imps.hpp
* Contains implementations of gp_ht_map_'s resize related functions, when the
* hash value is not stored.
*/
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
resize_imp_reassign(entry_pointer p_e, entry_array a_entries_resized,
false_type)
{
key_const_reference r_key = PB_DS_V2F(p_e->m_value);
size_type hash = ranged_probe_fn_base::operator()(r_key);
size_type i;
for (i = 0; i < m_num_e; ++i)
{
const size_type pos = ranged_probe_fn_base::operator()(r_key, hash, i);
entry_pointer p_new_e = a_entries_resized + pos;
switch(p_new_e->m_stat)
{
case empty_entry_status:
new (&p_new_e->m_value) value_type(p_e->m_value);
p_new_e->m_stat = valid_entry_status;
return;
case erased_entry_status:
_GLIBCXX_DEBUG_ASSERT(0);
break;
case valid_entry_status:
break;
default:
_GLIBCXX_DEBUG_ASSERT(0);
};
}
__throw_insert_error();
}
c++/8/ext/pb_ds/detail/gp_hash_table_map_/find_store_hash_fn_imps.hpp 0000644 00000003364 15201526705 0021564 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file gp_hash_table_map_/find_store_hash_fn_imps.hpp
* Contains implementations of gp_ht_map_'s insert related functions,
* when the hash value is stored.
*/
c++/8/ext/pb_ds/detail/gp_hash_table_map_/insert_store_hash_fn_imps.hpp 0000644 00000007765 15201526705 0022161 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file gp_hash_table_map_/insert_store_hash_fn_imps.hpp
* Contains implementations of gp_ht_map_'s find related functions,
* when the hash value is stored.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::comp_hash
PB_DS_CLASS_C_DEC::
find_ins_pos(key_const_reference r_key, true_type)
{
PB_DS_ASSERT_VALID((*this))
comp_hash pos_hash_pair = ranged_probe_fn_base::operator()(r_key);
size_type i;
/* The insertion position is initted to a non-legal value to indicate
* that it has not been initted yet.
*/
size_type ins_pos = m_num_e;
resize_base::notify_insert_search_start();
for (i = 0; i < m_num_e; ++i)
{
const size_type pos = ranged_probe_fn_base::operator()(r_key, pos_hash_pair.second, i);
entry* const p_e = m_entries + pos;
switch(p_e->m_stat)
{
case empty_entry_status:
{
resize_base::notify_insert_search_end();
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return ((ins_pos == m_num_e) ?
std::make_pair(pos, pos_hash_pair.second) :
std::make_pair(ins_pos, pos_hash_pair.second));
}
break;
case erased_entry_status:
if (ins_pos == m_num_e)
ins_pos = pos;
break;
case valid_entry_status:
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), p_e->m_hash,
r_key, pos_hash_pair.second))
{
resize_base::notify_insert_search_end();
PB_DS_CHECK_KEY_EXISTS(r_key)
return std::make_pair(pos, pos_hash_pair.second);
}
break;
default:
_GLIBCXX_DEBUG_ASSERT(0);
};
resize_base::notify_insert_search_collision();
}
resize_base::notify_insert_search_end();
if (ins_pos == m_num_e)
__throw_insert_error();
return std::make_pair(ins_pos, pos_hash_pair.second);
}
PB_DS_CLASS_T_DEC
inline std::pair<typename PB_DS_CLASS_C_DEC::point_iterator, bool>
PB_DS_CLASS_C_DEC::
insert_imp(const_reference r_val, true_type)
{
key_const_reference r_key = PB_DS_V2F(r_val);
comp_hash pos_hash_pair = find_ins_pos(r_key,
traits_base::m_store_extra_indicator);
_GLIBCXX_DEBUG_ASSERT(pos_hash_pair.first < m_num_e);
entry_pointer p_e =& m_entries[pos_hash_pair.first];
if (p_e->m_stat == valid_entry_status)
{
PB_DS_CHECK_KEY_EXISTS(r_key)
return std::make_pair(&p_e->m_value, false);
}
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return std::make_pair(insert_new_imp(r_val, pos_hash_pair), true);
}
c++/8/ext/pb_ds/detail/gp_hash_table_map_/erase_no_store_hash_fn_imps.hpp 0000644 00000005505 15201526705 0022436 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file gp_hash_table_map_/erase_no_store_hash_fn_imps.hpp
* Contains implementations of gp_ht_map_'s erase related functions,
* when the hash value is not stored.
*/
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
erase_imp(key_const_reference r_key, false_type)
{
PB_DS_ASSERT_VALID((*this))
size_type hash = ranged_probe_fn_base::operator()(r_key);
size_type i;
resize_base::notify_erase_search_start();
for (i = 0; i < m_num_e; ++i)
{
const size_type pos = ranged_probe_fn_base::operator()(r_key, hash, i);
entry* const p_e = m_entries + pos;
switch(p_e->m_stat)
{
case empty_entry_status:
{
resize_base::notify_erase_search_end();
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return false;
}
break;
case valid_entry_status:
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), r_key))
{
resize_base::notify_erase_search_end();
erase_entry(p_e);
do_resize_if_needed_no_throw();
return true;
}
break;
case erased_entry_status:
break;
default:
_GLIBCXX_DEBUG_ASSERT(0);
};
resize_base::notify_erase_search_collision();
}
resize_base::notify_erase_search_end();
return false;
}
c++/8/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp 0000644 00000004232 15201526705 0026176 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file gp_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp
* Contains implementations of gp_ht_map_'s constructors, destructor,
* and related functions.
*/
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
constructor_insert_new_imp(mapped_const_reference r_val, size_type pos,
false_type)
{
_GLIBCXX_DEBUG_ASSERT(m_entries[pos].m_stat != valid_entry_status)k;
entry* const p_e = m_entries + pos;
new (&p_e->m_value) mapped_value_type(r_val);
p_e->m_stat = valid_entry_status;
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(p_e->m_value.first);)
}
c++/8/ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp 0000644 00000047656 15201526705 0017023 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file gp_hash_table_map_/gp_ht_map_.hpp
* Contains an implementation class for general probing hash.
*/
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/pb_ds/detail/hash_fn/ranged_probe_fn.hpp>
#include <ext/pb_ds/detail/types_traits.hpp>
#include <ext/pb_ds/exception.hpp>
#include <ext/pb_ds/detail/eq_fn/hash_eq_fn.hpp>
#include <utility>
#ifdef PB_DS_HT_MAP_TRACE_
#include <iostream>
#endif
#ifdef _GLIBCXX_DEBUG
#include <ext/pb_ds/detail/debug_map_base.hpp>
#endif
#include <debug/debug.h>
namespace __gnu_pbds
{
namespace detail
{
#ifdef PB_DS_DATA_TRUE_INDICATOR
#define PB_DS_GP_HASH_NAME gp_ht_map
#endif
#ifdef PB_DS_DATA_FALSE_INDICATOR
#define PB_DS_GP_HASH_NAME gp_ht_set
#endif
#define PB_DS_CLASS_T_DEC \
template<typename Key, typename Mapped, typename Hash_Fn, typename Eq_Fn, \
typename _Alloc, bool Store_Hash, typename Comb_Probe_Fn, \
typename Probe_Fn, typename Resize_Policy>
#define PB_DS_CLASS_C_DEC \
PB_DS_GP_HASH_NAME<Key, Mapped, Hash_Fn, Eq_Fn, _Alloc, \
Store_Hash, Comb_Probe_Fn, Probe_Fn, Resize_Policy>
#define PB_DS_HASH_EQ_FN_C_DEC \
hash_eq_fn<Key, Eq_Fn, _Alloc, Store_Hash>
#define PB_DS_RANGED_PROBE_FN_C_DEC \
ranged_probe_fn<Key, Hash_Fn, _Alloc, Comb_Probe_Fn, Probe_Fn, Store_Hash>
#define PB_DS_GP_HASH_TRAITS_BASE \
types_traits<Key, Mapped, _Alloc, Store_Hash>
#ifdef _GLIBCXX_DEBUG
#define PB_DS_DEBUG_MAP_BASE_C_DEC \
debug_map_base<Key, Eq_Fn, \
typename _Alloc::template rebind<Key>::other::const_reference>
#endif
/**
* A general-probing hash-based container.
*
*
* @ingroup hash-detail
*
* @tparam Key Key type.
*
* @tparam Mapped Map type.
*
* @tparam Hash_Fn Hashing functor.
* Default is __gnu_cxx::hash.
*
* @tparam Eq_Fn Equal functor.
* Default std::equal_to<Key>
*
* @tparam _Alloc Allocator type.
*
* @tparam Store_Hash If key type stores extra metadata.
* Defaults to false.
*
* @tparam Comb_Probe_Fn Combining probe functor.
* If Hash_Fn is not null_type, then this
* is the ranged-probe functor; otherwise,
* this is the range-hashing functor.
* XXX See Design::Hash-Based Containers::Hash Policies.
* Default direct_mask_range_hashing.
*
* @tparam Probe_Fn Probe functor.
* Defaults to linear_probe_fn,
* also quadratic_probe_fn.
*
* @tparam Resize_Policy Resizes hash.
* Defaults to hash_standard_resize_policy,
* using hash_exponential_size_policy and
* hash_load_check_resize_trigger.
*
*
* Bases are: detail::hash_eq_fn, Resize_Policy, detail::ranged_probe_fn,
* detail::types_traits. (Optional: detail::debug_map_base.)
*/
template<typename Key,
typename Mapped,
typename Hash_Fn,
typename Eq_Fn,
typename _Alloc,
bool Store_Hash,
typename Comb_Probe_Fn,
typename Probe_Fn,
typename Resize_Policy>
class PB_DS_GP_HASH_NAME :
#ifdef _GLIBCXX_DEBUG
protected PB_DS_DEBUG_MAP_BASE_C_DEC,
#endif
public PB_DS_HASH_EQ_FN_C_DEC,
public Resize_Policy,
public PB_DS_RANGED_PROBE_FN_C_DEC,
public PB_DS_GP_HASH_TRAITS_BASE
{
private:
typedef PB_DS_GP_HASH_TRAITS_BASE traits_base;
typedef typename traits_base::value_type value_type_;
typedef typename traits_base::pointer pointer_;
typedef typename traits_base::const_pointer const_pointer_;
typedef typename traits_base::reference reference_;
typedef typename traits_base::const_reference const_reference_;
typedef typename traits_base::comp_hash comp_hash;
enum entry_status
{
empty_entry_status,
valid_entry_status,
erased_entry_status
} __attribute__ ((__packed__));
struct entry : public traits_base::stored_data_type
{
entry_status m_stat;
};
typedef typename _Alloc::template rebind<entry>::other entry_allocator;
typedef typename entry_allocator::pointer entry_pointer;
typedef typename entry_allocator::const_pointer const_entry_pointer;
typedef typename entry_allocator::reference entry_reference;
typedef typename entry_allocator::const_reference const_entry_reference;
typedef typename entry_allocator::pointer entry_array;
typedef PB_DS_RANGED_PROBE_FN_C_DEC ranged_probe_fn_base;
#ifdef _GLIBCXX_DEBUG
typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base;
#endif
typedef PB_DS_HASH_EQ_FN_C_DEC hash_eq_fn_base;
typedef Resize_Policy resize_base;
#define PB_DS_GEN_POS typename _Alloc::size_type
#include <ext/pb_ds/detail/unordered_iterator/point_const_iterator.hpp>
#include <ext/pb_ds/detail/unordered_iterator/point_iterator.hpp>
#include <ext/pb_ds/detail/unordered_iterator/const_iterator.hpp>
#include <ext/pb_ds/detail/unordered_iterator/iterator.hpp>
#undef PB_DS_GEN_POS
public:
typedef _Alloc allocator_type;
typedef typename _Alloc::size_type size_type;
typedef typename _Alloc::difference_type difference_type;
typedef Hash_Fn hash_fn;
typedef Eq_Fn eq_fn;
typedef Probe_Fn probe_fn;
typedef Comb_Probe_Fn comb_probe_fn;
typedef Resize_Policy resize_policy;
/// Value stores hash, true or false.
enum
{
store_hash = Store_Hash
};
typedef typename traits_base::key_type key_type;
typedef typename traits_base::key_pointer key_pointer;
typedef typename traits_base::key_const_pointer key_const_pointer;
typedef typename traits_base::key_reference key_reference;
typedef typename traits_base::key_const_reference key_const_reference;
typedef typename traits_base::mapped_type mapped_type;
typedef typename traits_base::mapped_pointer mapped_pointer;
typedef typename traits_base::mapped_const_pointer mapped_const_pointer;
typedef typename traits_base::mapped_reference mapped_reference;
typedef typename traits_base::mapped_const_reference mapped_const_reference;
typedef typename traits_base::value_type value_type;
typedef typename traits_base::pointer pointer;
typedef typename traits_base::const_pointer const_pointer;
typedef typename traits_base::reference reference;
typedef typename traits_base::const_reference const_reference;
#ifdef PB_DS_DATA_TRUE_INDICATOR
typedef point_iterator_ point_iterator;
#endif
#ifdef PB_DS_DATA_FALSE_INDICATOR
typedef point_const_iterator_ point_iterator;
#endif
typedef point_const_iterator_ point_const_iterator;
#ifdef PB_DS_DATA_TRUE_INDICATOR
typedef iterator_ iterator;
#endif
#ifdef PB_DS_DATA_FALSE_INDICATOR
typedef const_iterator_ iterator;
#endif
typedef const_iterator_ const_iterator;
PB_DS_GP_HASH_NAME();
PB_DS_GP_HASH_NAME(const PB_DS_CLASS_C_DEC&);
PB_DS_GP_HASH_NAME(const Hash_Fn&);
PB_DS_GP_HASH_NAME(const Hash_Fn&, const Eq_Fn&);
PB_DS_GP_HASH_NAME(const Hash_Fn&, const Eq_Fn&, const Comb_Probe_Fn&);
PB_DS_GP_HASH_NAME(const Hash_Fn&, const Eq_Fn&, const Comb_Probe_Fn&,
const Probe_Fn&);
PB_DS_GP_HASH_NAME(const Hash_Fn&, const Eq_Fn&, const Comb_Probe_Fn&,
const Probe_Fn&, const Resize_Policy&);
template<typename It>
void
copy_from_range(It, It);
virtual
~PB_DS_GP_HASH_NAME();
void
swap(PB_DS_CLASS_C_DEC&);
inline size_type
size() const;
inline size_type
max_size() const;
/// True if size() == 0.
inline bool
empty() const;
/// Return current hash_fn.
Hash_Fn&
get_hash_fn();
/// Return current const hash_fn.
const Hash_Fn&
get_hash_fn() const;
/// Return current eq_fn.
Eq_Fn&
get_eq_fn();
/// Return current const eq_fn.
const Eq_Fn&
get_eq_fn() const;
/// Return current probe_fn.
Probe_Fn&
get_probe_fn();
/// Return current const probe_fn.
const Probe_Fn&
get_probe_fn() const;
/// Return current comb_probe_fn.
Comb_Probe_Fn&
get_comb_probe_fn();
/// Return current const comb_probe_fn.
const Comb_Probe_Fn&
get_comb_probe_fn() const;
/// Return current resize_policy.
Resize_Policy&
get_resize_policy();
/// Return current const resize_policy.
const Resize_Policy&
get_resize_policy() const;
inline std::pair<point_iterator, bool>
insert(const_reference r_val)
{
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid(__FILE__, __LINE__);)
return insert_imp(r_val, traits_base::m_store_extra_indicator);
}
inline mapped_reference
operator[](key_const_reference r_key)
{
#ifdef PB_DS_DATA_TRUE_INDICATOR
return subscript_imp(r_key, traits_base::m_store_extra_indicator);
#else
insert(r_key);
return traits_base::s_null_type;
#endif
}
inline point_iterator
find(key_const_reference);
inline point_const_iterator
find(key_const_reference) const;
inline point_iterator
find_end();
inline point_const_iterator
find_end() const;
inline bool
erase(key_const_reference);
template<typename Pred>
inline size_type
erase_if(Pred);
void
clear();
inline iterator
begin();
inline const_iterator
begin() const;
inline iterator
end();
inline const_iterator
end() const;
#ifdef _GLIBCXX_DEBUG
void
assert_valid(const char*, int) const;
#endif
#ifdef PB_DS_HT_MAP_TRACE_
void
trace() const;
#endif
private:
#ifdef PB_DS_DATA_TRUE_INDICATOR
friend class iterator_;
#endif
friend class const_iterator_;
void
deallocate_all();
void
initialize();
void
erase_all_valid_entries(entry_array, size_type);
inline bool
do_resize_if_needed();
inline void
do_resize_if_needed_no_throw();
void
resize_imp(size_type);
virtual void
do_resize(size_type);
void
resize_imp(entry_array, size_type);
inline void
resize_imp_reassign(entry_pointer, entry_array, false_type);
inline void
resize_imp_reassign(entry_pointer, entry_array, true_type);
inline size_type
find_ins_pos(key_const_reference, false_type);
inline comp_hash
find_ins_pos(key_const_reference, true_type);
inline std::pair<point_iterator, bool>
insert_imp(const_reference, false_type);
inline std::pair<point_iterator, bool>
insert_imp(const_reference, true_type);
inline pointer
insert_new_imp(const_reference r_val, size_type pos)
{
_GLIBCXX_DEBUG_ASSERT(m_entries[pos].m_stat != valid_entry_status);
if (do_resize_if_needed())
pos = find_ins_pos(PB_DS_V2F(r_val),
traits_base::m_store_extra_indicator);
_GLIBCXX_DEBUG_ASSERT(m_entries[pos].m_stat != valid_entry_status);
entry* const p_e = m_entries + pos;
new (&p_e->m_value) value_type(r_val);
p_e->m_stat = valid_entry_status;
resize_base::notify_inserted(++m_num_used_e);
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(p_e->m_value));)
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
return &p_e->m_value;
}
inline pointer
insert_new_imp(const_reference r_val, comp_hash& r_pos_hash_pair)
{
_GLIBCXX_DEBUG_ASSERT(m_entries[r_pos_hash_pair.first].m_stat !=
valid_entry_status);
if (do_resize_if_needed())
r_pos_hash_pair = find_ins_pos(PB_DS_V2F(r_val),
traits_base::m_store_extra_indicator);
_GLIBCXX_DEBUG_ASSERT(m_entries[r_pos_hash_pair.first].m_stat !=
valid_entry_status);
entry* const p_e = m_entries + r_pos_hash_pair.first;
new (&p_e->m_value) value_type(r_val);
p_e->m_hash = r_pos_hash_pair.second;
p_e->m_stat = valid_entry_status;
resize_base::notify_inserted(++m_num_used_e);
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(p_e->m_value));)
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
return &p_e->m_value;
}
#ifdef PB_DS_DATA_TRUE_INDICATOR
inline mapped_reference
subscript_imp(key_const_reference key, false_type)
{
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
const size_type pos = find_ins_pos(key,
traits_base::m_store_extra_indicator);
entry_pointer p_e = &m_entries[pos];
if (p_e->m_stat != valid_entry_status)
return insert_new_imp(value_type(key, mapped_type()), pos)->second;
PB_DS_CHECK_KEY_EXISTS(key)
return p_e->m_value.second;
}
inline mapped_reference
subscript_imp(key_const_reference key, true_type)
{
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
comp_hash pos_hash_pair = find_ins_pos(key,
traits_base::m_store_extra_indicator);
if (m_entries[pos_hash_pair.first].m_stat != valid_entry_status)
return insert_new_imp(value_type(key, mapped_type()),
pos_hash_pair)->second;
PB_DS_CHECK_KEY_EXISTS(key)
return (m_entries + pos_hash_pair.first)->m_value.second;
}
#endif
inline pointer
find_key_pointer(key_const_reference key, false_type)
{
const size_type hash = ranged_probe_fn_base::operator()(key);
resize_base::notify_find_search_start();
// Loop until entry is found or until all possible entries accessed.
for (size_type i = 0; i < m_num_e; ++i)
{
const size_type pos = ranged_probe_fn_base::operator()(key,
hash, i);
entry* const p_e = m_entries + pos;
switch (p_e->m_stat)
{
case empty_entry_status:
{
resize_base::notify_find_search_end();
PB_DS_CHECK_KEY_DOES_NOT_EXIST(key)
return 0;
}
break;
case valid_entry_status:
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), key))
{
resize_base::notify_find_search_end();
PB_DS_CHECK_KEY_EXISTS(key)
return pointer(&p_e->m_value);
}
break;
case erased_entry_status:
break;
default:
_GLIBCXX_DEBUG_ASSERT(0);
};
resize_base::notify_find_search_collision();
}
PB_DS_CHECK_KEY_DOES_NOT_EXIST(key)
resize_base::notify_find_search_end();
return 0;
}
inline pointer
find_key_pointer(key_const_reference key, true_type)
{
comp_hash pos_hash_pair = ranged_probe_fn_base::operator()(key);
resize_base::notify_find_search_start();
// Loop until entry is found or until all possible entries accessed.
for (size_type i = 0; i < m_num_e; ++i)
{
const size_type pos =
ranged_probe_fn_base::operator()(key, pos_hash_pair.second, i);
entry* const p_e = m_entries + pos;
switch(p_e->m_stat)
{
case empty_entry_status:
{
resize_base::notify_find_search_end();
PB_DS_CHECK_KEY_DOES_NOT_EXIST(key)
return 0;
}
break;
case valid_entry_status:
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value),
p_e->m_hash,
key, pos_hash_pair.second))
{
resize_base::notify_find_search_end();
PB_DS_CHECK_KEY_EXISTS(key)
return pointer(&p_e->m_value);
}
break;
case erased_entry_status:
break;
default:
_GLIBCXX_DEBUG_ASSERT(0);
};
resize_base::notify_find_search_collision();
}
PB_DS_CHECK_KEY_DOES_NOT_EXIST(key)
resize_base::notify_find_search_end();
return 0;
}
inline bool
erase_imp(key_const_reference, true_type);
inline bool
erase_imp(key_const_reference, false_type);
inline void
erase_entry(entry_pointer);
#ifdef PB_DS_DATA_TRUE_INDICATOR
void
inc_it_state(pointer& r_p_value, size_type& r_pos) const
{ inc_it_state((mapped_const_pointer& )r_p_value, r_pos); }
#endif
void
inc_it_state(const_pointer& r_p_value, size_type& r_pos) const
{
_GLIBCXX_DEBUG_ASSERT(r_p_value != 0);
for (++r_pos; r_pos < m_num_e; ++r_pos)
{
const_entry_pointer p_e =& m_entries[r_pos];
if (p_e->m_stat == valid_entry_status)
{
r_p_value =& p_e->m_value;
return;
}
}
r_p_value = 0;
}
void
get_start_it_state(const_pointer& r_p_value, size_type& r_pos) const
{
for (r_pos = 0; r_pos < m_num_e; ++r_pos)
{
const_entry_pointer p_e = &m_entries[r_pos];
if (p_e->m_stat == valid_entry_status)
{
r_p_value = &p_e->m_value;
return;
}
}
r_p_value = 0;
}
void
get_start_it_state(pointer& r_p_value, size_type& r_pos)
{
for (r_pos = 0; r_pos < m_num_e; ++r_pos)
{
entry_pointer p_e = &m_entries[r_pos];
if (p_e->m_stat == valid_entry_status)
{
r_p_value = &p_e->m_value;
return;
}
}
r_p_value = 0;
}
#ifdef _GLIBCXX_DEBUG
void
assert_entry_array_valid(const entry_array, false_type,
const char*, int) const;
void
assert_entry_array_valid(const entry_array, true_type,
const char*, int) const;
#endif
static entry_allocator s_entry_allocator;
static iterator s_end_it;
static const_iterator s_const_end_it;
size_type m_num_e;
size_type m_num_used_e;
entry_pointer m_entries;
enum
{
store_hash_ok = !Store_Hash
|| !is_same<Hash_Fn, __gnu_pbds::null_type>::value
};
PB_DS_STATIC_ASSERT(sth, store_hash_ok);
};
#include <ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/gp_hash_table_map_/find_fn_imps.hpp>
#include <ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp>
#include <ext/pb_ds/detail/gp_hash_table_map_/debug_fn_imps.hpp>
#include <ext/pb_ds/detail/gp_hash_table_map_/info_fn_imps.hpp>
#include <ext/pb_ds/detail/gp_hash_table_map_/policy_access_fn_imps.hpp>
#include <ext/pb_ds/detail/gp_hash_table_map_/erase_fn_imps.hpp>
#include <ext/pb_ds/detail/gp_hash_table_map_/iterator_fn_imps.hpp>
#include <ext/pb_ds/detail/gp_hash_table_map_/insert_fn_imps.hpp>
#include <ext/pb_ds/detail/gp_hash_table_map_/trace_fn_imps.hpp>
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_HASH_EQ_FN_C_DEC
#undef PB_DS_RANGED_PROBE_FN_C_DEC
#undef PB_DS_GP_HASH_TRAITS_BASE
#undef PB_DS_DEBUG_MAP_BASE_C_DEC
#undef PB_DS_GP_HASH_NAME
} // namespace detail
} // namespace __gnu_pbds
c++/8/ext/pb_ds/detail/gp_hash_table_map_/policy_access_fn_imps.hpp 0000644 00000005144 15201526705 0021243 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file gp_hash_table_map_/policy_access_fn_imps.hpp
* Contains implementations of gp_ht_map_'s policy agpess
* functions.
*/
PB_DS_CLASS_T_DEC
Hash_Fn&
PB_DS_CLASS_C_DEC::
get_hash_fn()
{ return *this; }
PB_DS_CLASS_T_DEC
const Hash_Fn&
PB_DS_CLASS_C_DEC::
get_hash_fn() const
{ return *this; }
PB_DS_CLASS_T_DEC
Eq_Fn&
PB_DS_CLASS_C_DEC::
get_eq_fn()
{ return *this; }
PB_DS_CLASS_T_DEC
const Eq_Fn&
PB_DS_CLASS_C_DEC::
get_eq_fn() const
{ return *this; }
PB_DS_CLASS_T_DEC
Probe_Fn&
PB_DS_CLASS_C_DEC::
get_probe_fn()
{ return *this; }
PB_DS_CLASS_T_DEC
const Probe_Fn&
PB_DS_CLASS_C_DEC::
get_probe_fn() const
{ return *this; }
PB_DS_CLASS_T_DEC
Comb_Probe_Fn&
PB_DS_CLASS_C_DEC::
get_comb_probe_fn()
{ return *this; }
PB_DS_CLASS_T_DEC
const Comb_Probe_Fn&
PB_DS_CLASS_C_DEC::
get_comb_probe_fn() const
{ return *this; }
PB_DS_CLASS_T_DEC
Resize_Policy&
PB_DS_CLASS_C_DEC::
get_resize_policy()
{ return *this; }
PB_DS_CLASS_T_DEC
const Resize_Policy&
PB_DS_CLASS_C_DEC::
get_resize_policy() const
{ return *this; }
c++/8/ext/pb_ds/detail/eq_fn/hash_eq_fn.hpp 0000644 00000007355 15201526705 0014325 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file hash_eq_fn.hpp
* Contains 2 eqivalence functions, one employing a hash value,
* and one ignoring it.
*/
#ifndef PB_DS_HASH_EQ_FN_HPP
#define PB_DS_HASH_EQ_FN_HPP
#include <utility>
#include <debug/debug.h>
namespace __gnu_pbds
{
namespace detail
{
/// Primary template.
template<typename Key, typename Eq_Fn, typename _Alloc, bool Store_Hash>
struct hash_eq_fn;
/// Specialization 1 - The client requests that hash values not be stored.
template<typename Key, typename Eq_Fn, typename _Alloc>
struct hash_eq_fn<Key, Eq_Fn, _Alloc, false> : public Eq_Fn
{
typedef Eq_Fn eq_fn_base;
typedef typename _Alloc::template rebind<Key>::other key_allocator;
typedef typename key_allocator::const_reference key_const_reference;
hash_eq_fn() { }
hash_eq_fn(const Eq_Fn& r_eq_fn) : Eq_Fn(r_eq_fn) { }
bool
operator()(key_const_reference r_lhs_key,
key_const_reference r_rhs_key) const
{ return eq_fn_base::operator()(r_lhs_key, r_rhs_key); }
void
swap(const hash_eq_fn& other)
{ std::swap((Eq_Fn&)(*this), (Eq_Fn&)other); }
};
/// Specialization 2 - The client requests that hash values be stored.
template<typename Key, class Eq_Fn, class _Alloc>
struct hash_eq_fn<Key, Eq_Fn, _Alloc, true> : public Eq_Fn
{
typedef typename _Alloc::size_type size_type;
typedef Eq_Fn eq_fn_base;
typedef typename _Alloc::template rebind<Key>::other key_allocator;
typedef typename key_allocator::const_reference key_const_reference;
hash_eq_fn() { }
hash_eq_fn(const Eq_Fn& r_eq_fn) : Eq_Fn(r_eq_fn) { }
bool
operator()(key_const_reference r_lhs_key, size_type lhs_hash,
key_const_reference r_rhs_key, size_type rhs_hash) const
{
_GLIBCXX_DEBUG_ASSERT(!eq_fn_base::operator()(r_lhs_key, r_rhs_key)
|| lhs_hash == rhs_hash);
return (lhs_hash == rhs_hash &&
eq_fn_base::operator()(r_lhs_key, r_rhs_key));
}
void
swap(const hash_eq_fn& other)
{ std::swap((Eq_Fn&)(*this), (Eq_Fn&)(other)); }
};
} // namespace detail
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/detail/eq_fn/eq_by_less.hpp 0000644 00000004432 15201526705 0014350 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file eq_by_less.hpp
* Contains an equivalence function.
*/
#ifndef PB_DS_EQ_BY_LESS_HPP
#define PB_DS_EQ_BY_LESS_HPP
#include <utility>
#include <functional>
#include <vector>
#include <assert.h>
#include <ext/pb_ds/detail/types_traits.hpp>
namespace __gnu_pbds
{
namespace detail
{
/// Equivalence function.
template<typename Key, class Cmp_Fn>
struct eq_by_less : private Cmp_Fn
{
bool
operator()(const Key& r_lhs, const Key& r_rhs) const
{
const bool l = Cmp_Fn::operator()(r_lhs, r_rhs);
const bool g = Cmp_Fn::operator()(r_rhs, r_lhs);
return !(l || g);
}
};
} // namespace detail
} // namespace __gnu_pbds
#endif // #ifndef PB_DS_EQ_BY_LESS_HPP
c++/8/ext/pb_ds/detail/container_base_dispatch.hpp 0000644 00000031500 15201526705 0015762 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file container_base_dispatch.hpp
* Contains associative container dispatching.
*/
#ifndef PB_DS_ASSOC_CNTNR_BASE_DS_DISPATCHER_HPP
#define PB_DS_ASSOC_CNTNR_BASE_DS_DISPATCHER_HPP
#include <ext/typelist.h>
#define PB_DS_ASSERT_VALID(X) \
_GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
#define PB_DS_DEBUG_VERIFY(_Cond) \
_GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
_M_message(#_Cond" assertion from %1;:%2;") \
._M_string(__FILE__)._M_integer(__LINE__) \
,__file,__line)
#define PB_DS_CHECK_KEY_EXISTS(_Key) \
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(_Key, __FILE__, __LINE__);)
#define PB_DS_CHECK_KEY_DOES_NOT_EXIST(_Key) \
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(_Key, \
__FILE__, __LINE__);)
#define PB_DS_DATA_TRUE_INDICATOR
#define PB_DS_V2F(X) (X).first
#define PB_DS_V2S(X) (X).second
#define PB_DS_EP2VP(X)& ((X)->m_value)
#include <ext/pb_ds/detail/list_update_map_/lu_map_.hpp>
#include <ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp>
#include <ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp>
#include <ext/pb_ds/detail/splay_tree_/splay_tree_.hpp>
#include <ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp>
#include <ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp>
#include <ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp>
#include <ext/pb_ds/detail/pat_trie_/pat_trie_.hpp>
#undef PB_DS_DATA_TRUE_INDICATOR
#undef PB_DS_V2F
#undef PB_DS_V2S
#undef PB_DS_EP2VP
#define PB_DS_DATA_FALSE_INDICATOR
#define PB_DS_V2F(X) (X)
#define PB_DS_V2S(X) Mapped_Data()
#define PB_DS_EP2VP(X)& ((X)->m_value.first)
#include <ext/pb_ds/detail/list_update_map_/lu_map_.hpp>
#include <ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp>
#include <ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp>
#include <ext/pb_ds/detail/splay_tree_/splay_tree_.hpp>
#include <ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp>
#include <ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp>
#include <ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp>
#include <ext/pb_ds/detail/pat_trie_/pat_trie_.hpp>
#undef PB_DS_DATA_FALSE_INDICATOR
#undef PB_DS_V2F
#undef PB_DS_V2S
#undef PB_DS_EP2VP
#undef PB_DS_CHECK_KEY_DOES_NOT_EXIST
#undef PB_DS_CHECK_KEY_EXISTS
#undef PB_DS_DEBUG_VERIFY
#undef PB_DS_ASSERT_VALID
namespace __gnu_pbds
{
namespace detail
{
/// Specialization for list-update map.
template<typename Key, typename Mapped, typename _Alloc, typename Policy_Tl>
struct container_base_dispatch<Key, Mapped, _Alloc, list_update_tag,
Policy_Tl>
{
private:
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
typedef typename at0::type at0t;
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> at1;
typedef typename at1::type at1t;
public:
/// Dispatched type.
typedef lu_map<Key, Mapped, at0t, _Alloc, at1t> type;
};
/// Specialization for list-update set.
template<typename Key, typename _Alloc, typename Policy_Tl>
struct container_base_dispatch<Key, null_type, _Alloc, list_update_tag,
Policy_Tl>
{
private:
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
typedef typename at0::type at0t;
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> at1;
typedef typename at1::type at1t;
public:
/// Dispatched type.
typedef lu_set<Key, null_type, at0t, _Alloc, at1t> type;
};
/// Specialization for PATRICIA trie map.
template<typename Key, typename Mapped, typename _Alloc, typename Policy_Tl>
struct container_base_dispatch<Key, Mapped, _Alloc, pat_trie_tag, Policy_Tl>
{
private:
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> at1;
typedef typename at1::type at1t;
public:
typedef pat_trie_map<Key, Mapped, at1t, _Alloc> type;
};
/// Specialization for PATRICIA trie set.
template<typename Key, typename _Alloc, typename Policy_Tl>
struct container_base_dispatch<Key, null_type, _Alloc, pat_trie_tag,
Policy_Tl>
{
private:
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> at1;
typedef typename at1::type at1t;
public:
/// Dispatched type.
typedef pat_trie_set<Key, null_type, at1t, _Alloc> type;
};
/// Specialization for R-B tree map.
template<typename Key, typename Mapped, typename _Alloc, typename Policy_Tl>
struct container_base_dispatch<Key, Mapped, _Alloc, rb_tree_tag, Policy_Tl>
{
private:
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
typedef typename at0::type at0t;
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> at1;
typedef typename at1::type at1t;
public:
/// Dispatched type.
typedef rb_tree_map<Key, Mapped, at0t, at1t, _Alloc> type;
};
/// Specialization for R-B tree set.
template<typename Key, typename _Alloc, typename Policy_Tl>
struct container_base_dispatch<Key, null_type, _Alloc, rb_tree_tag,
Policy_Tl>
{
private:
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
typedef typename at0::type at0t;
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> at1;
typedef typename at1::type at1t;
public:
typedef rb_tree_set<Key, null_type, at0t, at1t, _Alloc> type;
};
/// Specialization splay tree map.
template<typename Key, typename Mapped, typename _Alloc, typename Policy_Tl>
struct container_base_dispatch<Key, Mapped, _Alloc, splay_tree_tag,
Policy_Tl>
{
private:
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
typedef typename at0::type at0t;
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> at1;
typedef typename at1::type at1t;
public:
/// Dispatched type.
typedef splay_tree_map<Key, Mapped, at0t, at1t, _Alloc> type;
};
/// Specialization splay tree set.
template<typename Key, typename _Alloc, typename Policy_Tl>
struct container_base_dispatch<Key, null_type, _Alloc, splay_tree_tag,
Policy_Tl>
{
private:
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
typedef typename at0::type at0t;
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> at1;
typedef typename at1::type at1t;
public:
/// Dispatched type.
typedef splay_tree_set<Key, null_type, at0t, at1t, _Alloc> type;
};
/// Specialization ordered-vector tree map.
template<typename Key, typename Mapped, typename _Alloc, typename Policy_Tl>
struct container_base_dispatch<Key, Mapped, _Alloc, ov_tree_tag, Policy_Tl>
{
private:
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
typedef typename at0::type at0t;
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> at1;
typedef typename at1::type at1t;
public:
/// Dispatched type.
typedef ov_tree_map<Key, Mapped, at0t, at1t, _Alloc> type;
};
/// Specialization ordered-vector tree set.
template<typename Key, typename _Alloc, typename Policy_Tl>
struct container_base_dispatch<Key, null_type, _Alloc, ov_tree_tag,
Policy_Tl>
{
private:
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
typedef typename at0::type at0t;
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> at1;
typedef typename at1::type at1t;
public:
/// Dispatched type.
typedef ov_tree_set<Key, null_type, at0t, at1t, _Alloc> type;
};
/// Specialization colision-chaining hash map.
template<typename Key, typename Mapped, typename _Alloc, typename Policy_Tl>
struct container_base_dispatch<Key, Mapped, _Alloc, cc_hash_tag, Policy_Tl>
{
private:
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
typedef typename at0::type at0t;
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> at1;
typedef typename at1::type at1t;
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 2> at2;
typedef typename at2::type at2t;
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 3> at3;
typedef typename at3::type at3t;
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 4> at4;
typedef typename at4::type at4t;
public:
/// Dispatched type.
typedef cc_ht_map<Key, Mapped, at0t, at1t, _Alloc,
at3t::value, at4t, at2t> type;
};
/// Specialization colision-chaining hash set.
template<typename Key, typename _Alloc, typename Policy_Tl>
struct container_base_dispatch<Key, null_type, _Alloc, cc_hash_tag,
Policy_Tl>
{
private:
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
typedef typename at0::type at0t;
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> at1;
typedef typename at1::type at1t;
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 2> at2;
typedef typename at2::type at2t;
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 3> at3;
typedef typename at3::type at3t;
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 4> at4;
typedef typename at4::type at4t;
public:
/// Dispatched type.
typedef cc_ht_set<Key, null_type, at0t, at1t, _Alloc,
at3t::value, at4t, at2t> type;
};
/// Specialization general-probe hash map.
template<typename Key, typename Mapped, typename _Alloc, typename Policy_Tl>
struct container_base_dispatch<Key, Mapped, _Alloc, gp_hash_tag, Policy_Tl>
{
private:
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
typedef typename at0::type at0t;
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> at1;
typedef typename at1::type at1t;
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 2> at2;
typedef typename at2::type at2t;
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 3> at3;
typedef typename at3::type at3t;
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 4> at4;
typedef typename at4::type at4t;
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 5> at5;
typedef typename at5::type at5t;
public:
/// Dispatched type.
typedef gp_ht_map<Key, Mapped, at0t, at1t, _Alloc,
at3t::value, at4t, at5t, at2t> type;
};
/// Specialization general-probe hash set.
template<typename Key, typename _Alloc, typename Policy_Tl>
struct container_base_dispatch<Key, null_type, _Alloc, gp_hash_tag,
Policy_Tl>
{
private:
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
typedef typename at0::type at0t;
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> at1;
typedef typename at1::type at1t;
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 2> at2;
typedef typename at2::type at2t;
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 3> at3;
typedef typename at3::type at3t;
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 4> at4;
typedef typename at4::type at4t;
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 5> at5;
typedef typename at5::type at5t;
public:
/// Dispatched type.
typedef gp_ht_set<Key, null_type, at0t, at1t, _Alloc,
at3t::value, at4t, at5t, at2t> type;
};
} // namespace detail
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/detail/splay_tree_/splay_tree_.hpp 0000644 00000022133 15201526705 0015745 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file splay_tree_/splay_tree_.hpp
* Contains an implementation class for splay trees.
*/
/*
* This implementation uses an idea from the SGI STL (using a @a header node
* which is needed for efficient iteration). Following is the SGI STL
* copyright.
*
* Copyright (c) 1996,1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
*/
#include <utility>
#include <vector>
#include <assert.h>
#include <debug/debug.h>
namespace __gnu_pbds
{
namespace detail
{
#ifdef PB_DS_DATA_TRUE_INDICATOR
# define PB_DS_S_TREE_NAME splay_tree_map
# define PB_DS_S_TREE_BASE_NAME bin_search_tree_map
#endif
#ifdef PB_DS_DATA_FALSE_INDICATOR
# define PB_DS_S_TREE_NAME splay_tree_set
# define PB_DS_S_TREE_BASE_NAME bin_search_tree_set
#endif
#define PB_DS_CLASS_T_DEC \
template<typename Key, typename Mapped, typename Cmp_Fn, \
typename Node_And_It_Traits, typename _Alloc>
#define PB_DS_CLASS_C_DEC \
PB_DS_S_TREE_NAME<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc>
#define PB_DS_S_TREE_BASE \
PB_DS_S_TREE_BASE_NAME<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc>
/**
* @brief Splay tree.
* @ingroup branch-detail
*/
template<typename Key, typename Mapped, typename Cmp_Fn,
typename Node_And_It_Traits, typename _Alloc>
class PB_DS_S_TREE_NAME : public PB_DS_S_TREE_BASE
{
private:
typedef PB_DS_S_TREE_BASE base_type;
#ifdef _GLIBCXX_DEBUG
typedef base_type debug_base;
#endif
typedef typename base_type::node_pointer node_pointer;
public:
typedef splay_tree_tag container_category;
typedef _Alloc allocator_type;
typedef typename _Alloc::size_type size_type;
typedef typename _Alloc::difference_type difference_type;
typedef Cmp_Fn cmp_fn;
typedef typename base_type::key_type key_type;
typedef typename base_type::key_pointer key_pointer;
typedef typename base_type::key_const_pointer key_const_pointer;
typedef typename base_type::key_reference key_reference;
typedef typename base_type::key_const_reference key_const_reference;
typedef typename base_type::mapped_type mapped_type;
typedef typename base_type::mapped_pointer mapped_pointer;
typedef typename base_type::mapped_const_pointer mapped_const_pointer;
typedef typename base_type::mapped_reference mapped_reference;
typedef typename base_type::mapped_const_reference mapped_const_reference;
typedef typename base_type::value_type value_type;
typedef typename base_type::pointer pointer;
typedef typename base_type::const_pointer const_pointer;
typedef typename base_type::reference reference;
typedef typename base_type::const_reference const_reference;
typedef typename base_type::point_iterator point_iterator;
typedef typename base_type::const_iterator point_const_iterator;
typedef typename base_type::iterator iterator;
typedef typename base_type::const_iterator const_iterator;
typedef typename base_type::reverse_iterator reverse_iterator;
typedef typename base_type::const_reverse_iterator const_reverse_iterator;
typedef typename base_type::node_update node_update;
PB_DS_S_TREE_NAME();
PB_DS_S_TREE_NAME(const Cmp_Fn&);
PB_DS_S_TREE_NAME(const Cmp_Fn&, const node_update&);
PB_DS_S_TREE_NAME(const PB_DS_CLASS_C_DEC&);
void
swap(PB_DS_CLASS_C_DEC&);
template<typename It>
void
copy_from_range(It, It);
void
initialize();
inline std::pair<point_iterator, bool>
insert(const_reference r_value);
inline mapped_reference
operator[](key_const_reference r_key)
{
#ifdef PB_DS_DATA_TRUE_INDICATOR
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
std::pair<point_iterator, bool> ins_pair =
insert_leaf_imp(value_type(r_key, mapped_type()));
ins_pair.first.m_p_nd->m_special = false;
_GLIBCXX_DEBUG_ONLY(base_type::assert_valid(__FILE__, __LINE__));
splay(ins_pair.first.m_p_nd);
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
return ins_pair.first.m_p_nd->m_value.second;
#else
insert(r_key);
return base_type::s_null_type;
#endif
}
inline point_iterator
find(key_const_reference);
inline point_const_iterator
find(key_const_reference) const;
inline bool
erase(key_const_reference);
inline iterator
erase(iterator it);
inline reverse_iterator
erase(reverse_iterator);
template<typename Pred>
inline size_type
erase_if(Pred);
void
join(PB_DS_CLASS_C_DEC&);
void
split(key_const_reference, PB_DS_CLASS_C_DEC&);
private:
inline std::pair<point_iterator, bool>
insert_leaf_imp(const_reference);
inline node_pointer
find_imp(key_const_reference);
inline const node_pointer
find_imp(key_const_reference) const;
#ifdef _GLIBCXX_DEBUG
void
assert_valid(const char* file, int line) const;
void
assert_special_imp(const node_pointer, const char* file, int line) const;
#endif
void
splay(node_pointer);
inline void
splay_zig_zag_left(node_pointer, node_pointer, node_pointer);
inline void
splay_zig_zag_right(node_pointer, node_pointer, node_pointer);
inline void
splay_zig_zig_left(node_pointer, node_pointer, node_pointer);
inline void
splay_zig_zig_right(node_pointer, node_pointer, node_pointer);
inline void
splay_zz_start(node_pointer, node_pointer, node_pointer);
inline void
splay_zz_end(node_pointer, node_pointer, node_pointer);
inline node_pointer
leftmost(node_pointer);
void
erase_node(node_pointer);
};
#define PB_DS_ASSERT_BASE_NODE_CONSISTENT(_Node) \
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(_Node, \
__FILE__, __LINE__);)
#include <ext/pb_ds/detail/splay_tree_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/splay_tree_/insert_fn_imps.hpp>
#include <ext/pb_ds/detail/splay_tree_/splay_fn_imps.hpp>
#include <ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp>
#include <ext/pb_ds/detail/splay_tree_/find_fn_imps.hpp>
#include <ext/pb_ds/detail/splay_tree_/debug_fn_imps.hpp>
#include <ext/pb_ds/detail/splay_tree_/split_join_fn_imps.hpp>
#undef PB_DS_ASSERT_BASE_NODE_CONSISTENT
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_S_TREE_NAME
#undef PB_DS_S_TREE_BASE_NAME
#undef PB_DS_S_TREE_BASE
} // namespace detail
} // namespace __gnu_pbds
c++/8/ext/pb_ds/detail/splay_tree_/splay_fn_imps.hpp 0000644 00000017561 15201526705 0016313 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file splay_tree_/splay_fn_imps.hpp
* Contains an implementation class for splay_tree_.
*/
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
splay(node_pointer p_nd)
{
while (p_nd->m_p_parent != base_type::m_p_head)
{
#ifdef _GLIBCXX_DEBUG
{
node_pointer p_head = base_type::m_p_head;
assert_special_imp(p_head, __FILE__, __LINE__);
}
#endif
PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_nd)
if (p_nd->m_p_parent->m_p_parent == base_type::m_p_head)
{
base_type::rotate_parent(p_nd);
_GLIBCXX_DEBUG_ASSERT(p_nd == this->m_p_head->m_p_parent);
}
else
{
const node_pointer p_parent = p_nd->m_p_parent;
const node_pointer p_grandparent = p_parent->m_p_parent;
#ifdef _GLIBCXX_DEBUG
const size_type total =
base_type::recursive_count(p_grandparent);
_GLIBCXX_DEBUG_ASSERT(total >= 3);
#endif
if (p_parent->m_p_left == p_nd &&
p_grandparent->m_p_right == p_parent)
splay_zig_zag_left(p_nd, p_parent, p_grandparent);
else if (p_parent->m_p_right == p_nd &&
p_grandparent->m_p_left == p_parent)
splay_zig_zag_right(p_nd, p_parent, p_grandparent);
else if (p_parent->m_p_left == p_nd &&
p_grandparent->m_p_left == p_parent)
splay_zig_zig_left(p_nd, p_parent, p_grandparent);
else
splay_zig_zig_right(p_nd, p_parent, p_grandparent);
_GLIBCXX_DEBUG_ASSERT(total ==this->recursive_count(p_nd));
}
PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_nd)
}
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
splay_zig_zag_left(node_pointer p_nd, node_pointer p_parent,
node_pointer p_grandparent)
{
_GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent);
_GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent);
PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_grandparent)
_GLIBCXX_DEBUG_ASSERT(p_parent->m_p_left == p_nd &&
p_grandparent->m_p_right == p_parent);
splay_zz_start(p_nd, p_parent, p_grandparent);
node_pointer p_b = p_nd->m_p_right;
node_pointer p_c = p_nd->m_p_left;
p_nd->m_p_right = p_parent;
p_parent->m_p_parent = p_nd;
p_nd->m_p_left = p_grandparent;
p_grandparent->m_p_parent = p_nd;
p_parent->m_p_left = p_b;
if (p_b != 0)
p_b->m_p_parent = p_parent;
p_grandparent->m_p_right = p_c;
if (p_c != 0)
p_c->m_p_parent = p_grandparent;
splay_zz_end(p_nd, p_parent, p_grandparent);
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
splay_zig_zag_right(node_pointer p_nd, node_pointer p_parent,
node_pointer p_grandparent)
{
_GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent);
_GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent);
PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_grandparent)
_GLIBCXX_DEBUG_ASSERT(p_parent->m_p_right == p_nd &&
p_grandparent->m_p_left == p_parent);
splay_zz_start(p_nd, p_parent, p_grandparent);
node_pointer p_b = p_nd->m_p_left;
node_pointer p_c = p_nd->m_p_right;
p_nd->m_p_left = p_parent;
p_parent->m_p_parent = p_nd;
p_nd->m_p_right = p_grandparent;
p_grandparent->m_p_parent = p_nd;
p_parent->m_p_right = p_b;
if (p_b != 0)
p_b->m_p_parent = p_parent;
p_grandparent->m_p_left = p_c;
if (p_c != 0)
p_c->m_p_parent = p_grandparent;
splay_zz_end(p_nd, p_parent, p_grandparent);
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
splay_zig_zig_left(node_pointer p_nd, node_pointer p_parent,
node_pointer p_grandparent)
{
_GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent);
_GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent);
PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_grandparent)
_GLIBCXX_DEBUG_ASSERT(p_parent->m_p_left == p_nd &&
p_nd->m_p_parent->m_p_parent->m_p_left == p_nd->m_p_parent);
splay_zz_start(p_nd, p_parent, p_grandparent);
node_pointer p_b = p_nd->m_p_right;
node_pointer p_c = p_parent->m_p_right;
p_nd->m_p_right = p_parent;
p_parent->m_p_parent = p_nd;
p_parent->m_p_right = p_grandparent;
p_grandparent->m_p_parent = p_parent;
p_parent->m_p_left = p_b;
if (p_b != 0)
p_b->m_p_parent = p_parent;
p_grandparent->m_p_left = p_c;
if (p_c != 0)
p_c->m_p_parent = p_grandparent;
splay_zz_end(p_nd, p_parent, p_grandparent);
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
splay_zig_zig_right(node_pointer p_nd, node_pointer p_parent,
node_pointer p_grandparent)
{
_GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent);
_GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent);
PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_grandparent)
_GLIBCXX_DEBUG_ASSERT(p_parent->m_p_right == p_nd &&
p_nd->m_p_parent->m_p_parent->m_p_right == p_nd->m_p_parent);
splay_zz_start(p_nd, p_parent, p_grandparent);
node_pointer p_b = p_nd->m_p_left;
node_pointer p_c = p_parent->m_p_left;
p_nd->m_p_left = p_parent;
p_parent->m_p_parent = p_nd;
p_parent->m_p_left = p_grandparent;
p_grandparent->m_p_parent = p_parent;
p_parent->m_p_right = p_b;
if (p_b != 0)
p_b->m_p_parent = p_parent;
p_grandparent->m_p_right = p_c;
if (p_c != 0)
p_c->m_p_parent = p_grandparent;
base_type::update_to_top(p_grandparent, (node_update*)this);
splay_zz_end(p_nd, p_parent, p_grandparent);
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
splay_zz_start(node_pointer p_nd,
#ifdef _GLIBCXX_DEBUG
node_pointer p_parent,
#else
node_pointer /*p_parent*/,
#endif
node_pointer p_grandparent)
{
_GLIBCXX_DEBUG_ASSERT(p_nd != 0);
_GLIBCXX_DEBUG_ASSERT(p_parent != 0);
_GLIBCXX_DEBUG_ASSERT(p_grandparent != 0);
const bool grandparent_head = p_grandparent->m_p_parent == base_type::m_p_head;
if (grandparent_head)
{
base_type::m_p_head->m_p_parent = base_type::m_p_head->m_p_parent;
p_nd->m_p_parent = base_type::m_p_head;
return;
}
node_pointer p_greatgrandparent = p_grandparent->m_p_parent;
p_nd->m_p_parent = p_greatgrandparent;
if (p_grandparent == p_greatgrandparent->m_p_left)
p_greatgrandparent->m_p_left = p_nd;
else
p_greatgrandparent->m_p_right = p_nd;
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
splay_zz_end(node_pointer p_nd, node_pointer p_parent,
node_pointer p_grandparent)
{
if (p_nd->m_p_parent == base_type::m_p_head)
base_type::m_p_head->m_p_parent = p_nd;
this->apply_update(p_grandparent, (node_update*)this);
this->apply_update(p_parent, (node_update*)this);
this->apply_update(p_nd, (node_update*)this);
PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_nd)
}
c++/8/ext/pb_ds/detail/splay_tree_/info_fn_imps.hpp 0000644 00000003231 15201526705 0016103 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file splay_tree_/info_fn_imps.hpp
* Contains an implementation.
*/
c++/8/ext/pb_ds/detail/splay_tree_/constructors_destructor_fn_imps.hpp 0000644 00000005437 15201526705 0022210 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file splay_tree_/constructors_destructor_fn_imps.hpp
* Contains an implementation class for splay_tree_.
*/
PB_DS_CLASS_T_DEC
template<typename It>
void
PB_DS_CLASS_C_DEC::
copy_from_range(It first_it, It last_it)
{
while (first_it != last_it)
insert(*(first_it++));
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_S_TREE_NAME()
{
initialize();
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_S_TREE_NAME(const Cmp_Fn& r_cmp_fn) :
base_type(r_cmp_fn)
{
initialize();
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_S_TREE_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_update) :
base_type(r_cmp_fn, r_node_update)
{
initialize();
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_S_TREE_NAME(const PB_DS_CLASS_C_DEC& other) :
base_type(other)
{
initialize();
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
base_type::swap(other);
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
initialize()
{ base_type::m_p_head->m_special = true; }
c++/8/ext/pb_ds/detail/splay_tree_/debug_fn_imps.hpp 0000644 00000004637 15201526705 0016251 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file splay_tree_/debug_fn_imps.hpp
* Contains an implementation class for splay_tree_.
*/
#ifdef _GLIBCXX_DEBUG
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_valid(const char* __file, int __line) const
{
base_type::assert_valid(__file, __line);
const node_pointer p_head = base_type::m_p_head;
assert_special_imp(p_head, __file, __line);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_special_imp(const node_pointer p_nd,
const char* __file, int __line) const
{
if (p_nd == 0)
return;
if (p_nd == base_type::m_p_head)
{
PB_DS_DEBUG_VERIFY(p_nd->m_special);
assert_special_imp(p_nd->m_p_parent, __file, __line);
return;
}
PB_DS_DEBUG_VERIFY(!p_nd->m_special);
assert_special_imp(p_nd->m_p_left, __file, __line);
assert_special_imp(p_nd->m_p_right, __file, __line);
}
#endif
c++/8/ext/pb_ds/detail/splay_tree_/find_fn_imps.hpp 0000644 00000006367 15201526705 0016105 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file splay_tree_/find_fn_imps.hpp
* Contains an implementation class for splay_tree_.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC::
find(key_const_reference r_key)
{
node_pointer p_found = find_imp(r_key);
if (p_found != base_type::m_p_head)
splay(p_found);
return point_iterator(p_found);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_const_iterator
PB_DS_CLASS_C_DEC::
find(key_const_reference r_key) const
{
const node_pointer p_found = find_imp(r_key);
if (p_found != base_type::m_p_head)
const_cast<PB_DS_CLASS_C_DEC* >(this)->splay(p_found);
return point_iterator(p_found);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
find_imp(key_const_reference r_key)
{
_GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid(__FILE__,
__LINE__);)
node_pointer p_nd = base_type::m_p_head->m_p_parent;
while (p_nd != 0)
if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key))
{
if (!Cmp_Fn::operator()(r_key, PB_DS_V2F(p_nd->m_value)))
return p_nd;
p_nd = p_nd->m_p_left;
}
else
p_nd = p_nd->m_p_right;
return base_type::m_p_head;
}
PB_DS_CLASS_T_DEC
inline const typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
find_imp(key_const_reference r_key) const
{
PB_DS_ASSERT_VALID((*this))
node_pointer p_nd = base_type::m_p_head->m_p_parent;
while (p_nd != 0)
if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key))
{
if (!Cmp_Fn::operator()(r_key, PB_DS_V2F(p_nd->m_value)))
return p_nd;
p_nd = p_nd->m_p_left;
}
else
p_nd = p_nd->m_p_right;
return base_type::m_p_head;
}
c++/8/ext/pb_ds/detail/splay_tree_/node.hpp 0000644 00000007240 15201526705 0014366 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file splay_tree_/node.hpp
* Contains an implementation struct for splay_tree_'s node.
*/
#ifndef PB_DS_SPLAY_TREE_NODE_HPP
#define PB_DS_SPLAY_TREE_NODE_HPP
namespace __gnu_pbds
{
namespace detail
{
/// Node for splay tree.
template<typename Value_Type, class Metadata, typename _Alloc>
struct splay_tree_node_
{
public:
typedef Value_Type value_type;
typedef Metadata metadata_type;
typedef
typename _Alloc::template rebind<
splay_tree_node_<Value_Type, Metadata, _Alloc> >::other::pointer
node_pointer;
typedef
typename _Alloc::template rebind<metadata_type>::other::reference
metadata_reference;
typedef
typename _Alloc::template rebind<metadata_type>::other::const_reference
metadata_const_reference;
#ifdef PB_DS_BIN_SEARCH_TREE_TRACE_
void
trace() const
{ std::cout << PB_DS_V2F(m_value) << "(" << m_metadata << ")"; }
#endif
inline bool
special() const
{ return m_special; }
inline metadata_const_reference
get_metadata() const
{ return m_metadata; }
inline metadata_reference
get_metadata()
{ return m_metadata; }
value_type m_value;
bool m_special;
node_pointer m_p_left;
node_pointer m_p_right;
node_pointer m_p_parent;
metadata_type m_metadata;
};
template<typename Value_Type, typename _Alloc>
struct splay_tree_node_<Value_Type, null_type, _Alloc>
{
public:
typedef Value_Type value_type;
typedef null_type metadata_type;
typedef
typename _Alloc::template rebind<
splay_tree_node_<Value_Type, null_type, _Alloc> >::other::pointer
node_pointer;
inline bool
special() const
{ return m_special; }
#ifdef PB_DS_BIN_SEARCH_TREE_TRACE_
void
trace() const
{ std::cout << PB_DS_V2F(m_value); }
#endif
node_pointer m_p_left;
node_pointer m_p_right;
node_pointer m_p_parent;
value_type m_value;
bool m_special;
};
} // namespace detail
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/detail/splay_tree_/split_join_fn_imps.hpp 0000644 00000007062 15201526705 0017330 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file splay_tree_/split_join_fn_imps.hpp
* Contains an implementation class for splay_tree_.
*/
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
join(PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
if (base_type::join_prep(other) == false)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
return;
}
node_pointer p_target_r = other.leftmost(other.m_p_head);
_GLIBCXX_DEBUG_ASSERT(p_target_r != 0);
other.splay(p_target_r);
_GLIBCXX_DEBUG_ASSERT(p_target_r == other.m_p_head->m_p_parent);
_GLIBCXX_DEBUG_ASSERT(p_target_r->m_p_left == 0);
p_target_r->m_p_left = base_type::m_p_head->m_p_parent;
_GLIBCXX_DEBUG_ASSERT(p_target_r->m_p_left != 0);
p_target_r->m_p_left->m_p_parent = p_target_r;
base_type::m_p_head->m_p_parent = p_target_r;
p_target_r->m_p_parent = base_type::m_p_head;
this->apply_update(p_target_r, (node_update*)this);
base_type::join_finish(other);
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
split(key_const_reference r_key, PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
if (base_type::split_prep(r_key, other) == false)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
return;
}
node_pointer p_upper_bound = this->upper_bound(r_key).m_p_nd;
_GLIBCXX_DEBUG_ASSERT(p_upper_bound != 0);
splay(p_upper_bound);
_GLIBCXX_DEBUG_ASSERT(p_upper_bound->m_p_parent == this->m_p_head);
node_pointer p_new_root = p_upper_bound->m_p_left;
_GLIBCXX_DEBUG_ASSERT(p_new_root != 0);
base_type::m_p_head->m_p_parent = p_new_root;
p_new_root->m_p_parent = base_type::m_p_head;
other.m_p_head->m_p_parent = p_upper_bound;
p_upper_bound->m_p_parent = other.m_p_head;
p_upper_bound->m_p_left = 0;
this->apply_update(p_upper_bound, (node_update*)this);
base_type::split_finish(other);
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
c++/8/ext/pb_ds/detail/splay_tree_/insert_fn_imps.hpp 0000644 00000006431 15201526705 0016461 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file splay_tree_/insert_fn_imps.hpp
* Contains an implementation class for splay_tree_.
*/
PB_DS_CLASS_T_DEC
inline std::pair<typename PB_DS_CLASS_C_DEC::point_iterator, bool>
PB_DS_CLASS_C_DEC::
insert(const_reference r_value)
{
PB_DS_ASSERT_VALID((*this))
std::pair<point_iterator, bool> ins_pair = insert_leaf_imp(r_value);
ins_pair.first.m_p_nd->m_special = false;
PB_DS_ASSERT_VALID((*this))
splay(ins_pair.first.m_p_nd);
PB_DS_ASSERT_VALID((*this))
return ins_pair;
}
PB_DS_CLASS_T_DEC
inline std::pair<typename PB_DS_CLASS_C_DEC::point_iterator, bool>
PB_DS_CLASS_C_DEC::
insert_leaf_imp(const_reference r_value)
{
_GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid(__FILE__,
__LINE__);)
if (base_type::m_size == 0)
return std::make_pair(base_type::insert_imp_empty(r_value), true);
node_pointer p_nd = base_type::m_p_head->m_p_parent;
node_pointer p_pot = base_type::m_p_head;
while (p_nd != 0)
if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), PB_DS_V2F(r_value)))
{
if (!Cmp_Fn::operator()(PB_DS_V2F(r_value), PB_DS_V2F(p_nd->m_value)))
{
return std::make_pair(point_iterator(p_nd), false);
}
p_pot = p_nd;
p_nd = p_nd->m_p_left;
}
else
p_nd = p_nd->m_p_right;
if (p_pot == base_type::m_p_head)
return std::make_pair(base_type::insert_leaf_new(r_value, base_type::m_p_head->m_p_right, false), true);
PB_DS_CHECK_KEY_DOES_NOT_EXIST(PB_DS_V2F(r_value))
p_nd = p_pot->m_p_left;
if (p_nd == 0)
return (std::make_pair(base_type::insert_leaf_new(r_value, p_pot, true), true));
while (p_nd->m_p_right != 0)
p_nd = p_nd->m_p_right;
return std::make_pair(this->insert_leaf_new(r_value, p_nd, false), true);
}
c++/8/ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp 0000644 00000010255 15201526705 0016253 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file splay_tree_/erase_fn_imps.hpp
* Contains an implementation class for splay_tree_.
*/
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
erase(key_const_reference r_key)
{
point_iterator it = find(r_key);
if (it == base_type::end())
return false;
erase(it);
return true;
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
erase(iterator it)
{
PB_DS_ASSERT_VALID((*this))
if (it == base_type::end())
return it;
iterator ret_it = it;
++ret_it;
erase_node(it.m_p_nd);
PB_DS_ASSERT_VALID((*this))
return ret_it;
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::reverse_iterator
PB_DS_CLASS_C_DEC::
erase(reverse_iterator it)
{
PB_DS_ASSERT_VALID((*this))
if (it.m_p_nd == base_type::m_p_head)
return (it);
reverse_iterator ret_it = it;
++ret_it;
erase_node(it.m_p_nd);
PB_DS_ASSERT_VALID((*this))
return ret_it;
}
PB_DS_CLASS_T_DEC
template<typename Pred>
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
erase_if(Pred pred)
{
PB_DS_ASSERT_VALID((*this))
size_type num_ersd = 0;
iterator it = base_type::begin();
while (it != base_type::end())
{
if (pred(*it))
{
++num_ersd;
it = erase(it);
}
else
++it;
}
PB_DS_ASSERT_VALID((*this))
return num_ersd;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
erase_node(node_pointer p_nd)
{
_GLIBCXX_DEBUG_ASSERT(p_nd != 0);
splay(p_nd);
PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(p_nd == this->m_p_head->m_p_parent);
node_pointer p_l = p_nd->m_p_left;
node_pointer p_r = p_nd->m_p_right;
base_type::update_min_max_for_erased_node(p_nd);
base_type::actual_erase_node(p_nd);
if (p_r == 0)
{
base_type::m_p_head->m_p_parent = p_l;
if (p_l != 0)
p_l->m_p_parent = base_type::m_p_head;
PB_DS_ASSERT_VALID((*this))
return;
}
node_pointer p_target_r = leftmost(p_r);
_GLIBCXX_DEBUG_ASSERT(p_target_r != 0);
p_r->m_p_parent = base_type::m_p_head;
base_type::m_p_head->m_p_parent = p_r;
splay(p_target_r);
_GLIBCXX_DEBUG_ONLY(p_target_r->m_p_left = 0);
_GLIBCXX_DEBUG_ASSERT(p_target_r->m_p_parent == this->m_p_head);
_GLIBCXX_DEBUG_ASSERT(this->m_p_head->m_p_parent == p_target_r);
p_target_r->m_p_left = p_l;
if (p_l != 0)
p_l->m_p_parent = p_target_r;
PB_DS_ASSERT_VALID((*this))
this->apply_update(p_target_r, (node_update*)this);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
leftmost(node_pointer p_nd)
{
_GLIBCXX_DEBUG_ASSERT(p_nd != 0);
while (p_nd->m_p_left != 0)
p_nd = p_nd->m_p_left;
return p_nd;
}
c++/8/ext/pb_ds/detail/splay_tree_/traits.hpp 0000644 00000006427 15201526705 0014755 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file splay_tree_/traits.hpp
* Contains an implementation for splay_tree_.
*/
#ifndef PB_DS_SPLAY_TREE_NODE_AND_IT_TRAITS_HPP
#define PB_DS_SPLAY_TREE_NODE_AND_IT_TRAITS_HPP
#include <ext/pb_ds/detail/splay_tree_/node.hpp>
namespace __gnu_pbds
{
namespace detail
{
/// Specialization.
/// @ingroup traits
template<typename Key,
typename Mapped,
typename Cmp_Fn,
template<typename Node_CItr,
typename Node_Itr,
typename Cmp_Fn_,
typename _Alloc_>
class Node_Update,
typename _Alloc>
struct tree_traits<Key, Mapped, Cmp_Fn, Node_Update, splay_tree_tag, _Alloc>
: public bin_search_tree_traits<Key, Mapped, Cmp_Fn, Node_Update,
splay_tree_node_<
typename types_traits<Key, Mapped, _Alloc, false>::value_type,
typename tree_node_metadata_dispatch<Key, Mapped, Cmp_Fn, Node_Update,
_Alloc>::type,
_Alloc>,
_Alloc>
{ };
/// Specialization.
/// @ingroup traits
template<typename Key,
class Cmp_Fn,
template<typename Node_CItr,
class Node_Itr,
class Cmp_Fn_,
typename _Alloc_>
class Node_Update,
typename _Alloc>
struct tree_traits<Key, null_type, Cmp_Fn, Node_Update,
splay_tree_tag, _Alloc>
: public bin_search_tree_traits<Key, null_type, Cmp_Fn, Node_Update,
splay_tree_node_<
typename types_traits<Key, null_type, _Alloc, false>::value_type,
typename tree_node_metadata_dispatch<Key, null_type, Cmp_Fn, Node_Update,
_Alloc>::type,
_Alloc>,
_Alloc>
{ };
} // namespace detail
} // namespace __gnu_pbds
#endif // #ifndef PB_DS_SPLAY_TREE_NODE_AND_IT_TRAITS_HPP
c++/8/ext/pb_ds/detail/hash_fn/ranged_probe_fn.hpp 0000644 00000024304 15201526705 0015653 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file ranged_probe_fn.hpp
* Contains a unified ranged probe functor, allowing the probe tables to deal with
* a single class for ranged probeing.
*/
#ifndef PB_DS_RANGED_PROBE_FN_HPP
#define PB_DS_RANGED_PROBE_FN_HPP
#include <utility>
#include <debug/debug.h>
namespace __gnu_pbds
{
namespace detail
{
/// Primary template.
template<typename Key, typename Hash_Fn, typename _Alloc,
typename Comb_Probe_Fn, typename Probe_Fn, bool Store_Hash>
class ranged_probe_fn;
#define PB_DS_CLASS_T_DEC \
template<typename Key, typename Hash_Fn, typename _Alloc, \
typename Comb_Probe_Fn, typename Probe_Fn>
#define PB_DS_CLASS_C_DEC \
ranged_probe_fn<Key, Hash_Fn, _Alloc, Comb_Probe_Fn, Probe_Fn, false>
/**
* Specialization 1
* The client supplies a probe function and a ranged probe
* function, and requests that hash values not be stored.
**/
template<typename Key, typename Hash_Fn, typename _Alloc,
typename Comb_Probe_Fn, typename Probe_Fn>
class ranged_probe_fn<Key, Hash_Fn, _Alloc, Comb_Probe_Fn,
Probe_Fn, false>
: public Hash_Fn, public Comb_Probe_Fn, public Probe_Fn
{
protected:
typedef typename _Alloc::size_type size_type;
typedef Comb_Probe_Fn comb_probe_fn_base;
typedef Hash_Fn hash_fn_base;
typedef Probe_Fn probe_fn_base;
typedef typename _Alloc::template rebind<Key>::other key_allocator;
typedef typename key_allocator::const_reference key_const_reference;
ranged_probe_fn(size_type);
ranged_probe_fn(size_type, const Hash_Fn&);
ranged_probe_fn(size_type, const Hash_Fn&, const Comb_Probe_Fn&);
ranged_probe_fn(size_type, const Hash_Fn&, const Comb_Probe_Fn&,
const Probe_Fn&);
void
swap(PB_DS_CLASS_C_DEC&);
void
notify_resized(size_type);
inline size_type
operator()(key_const_reference) const;
inline size_type
operator()(key_const_reference, size_type, size_type) const;
};
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
ranged_probe_fn(size_type size)
{ Comb_Probe_Fn::notify_resized(size); }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn)
: Hash_Fn(r_hash_fn)
{ Comb_Probe_Fn::notify_resized(size); }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn,
const Comb_Probe_Fn& r_comb_probe_fn)
: Hash_Fn(r_hash_fn), Comb_Probe_Fn(r_comb_probe_fn)
{ comb_probe_fn_base::notify_resized(size); }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn,
const Comb_Probe_Fn& r_comb_probe_fn,
const Probe_Fn& r_probe_fn)
: Hash_Fn(r_hash_fn), Comb_Probe_Fn(r_comb_probe_fn), Probe_Fn(r_probe_fn)
{ comb_probe_fn_base::notify_resized(size); }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
comb_probe_fn_base::swap(other);
std::swap((Hash_Fn& )(*this), (Hash_Fn&)other);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
notify_resized(size_type size)
{ comb_probe_fn_base::notify_resized(size); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
operator()(key_const_reference r_key) const
{ return comb_probe_fn_base::operator()(hash_fn_base::operator()(r_key)); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
operator()(key_const_reference, size_type hash, size_type i) const
{
return comb_probe_fn_base::operator()(hash + probe_fn_base::operator()(i));
}
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
#define PB_DS_CLASS_T_DEC \
template<typename Key, typename Hash_Fn, typename _Alloc, \
typename Comb_Probe_Fn, typename Probe_Fn>
#define PB_DS_CLASS_C_DEC \
ranged_probe_fn<Key, Hash_Fn, _Alloc, Comb_Probe_Fn, Probe_Fn, true>
/**
* Specialization 2- The client supplies a probe function and a ranged
* probe function, and requests that hash values not be stored.
**/
template<typename Key, typename Hash_Fn, typename _Alloc,
typename Comb_Probe_Fn, typename Probe_Fn>
class ranged_probe_fn<Key, Hash_Fn, _Alloc, Comb_Probe_Fn,
Probe_Fn, true>
: public Hash_Fn, public Comb_Probe_Fn, public Probe_Fn
{
protected:
typedef typename _Alloc::size_type size_type;
typedef std::pair<size_type, size_type> comp_hash;
typedef Comb_Probe_Fn comb_probe_fn_base;
typedef Hash_Fn hash_fn_base;
typedef Probe_Fn probe_fn_base;
typedef typename _Alloc::template rebind<Key>::other key_allocator;
typedef typename key_allocator::const_reference key_const_reference;
ranged_probe_fn(size_type);
ranged_probe_fn(size_type, const Hash_Fn&);
ranged_probe_fn(size_type, const Hash_Fn&,
const Comb_Probe_Fn&);
ranged_probe_fn(size_type, const Hash_Fn&, const Comb_Probe_Fn&,
const Probe_Fn&);
void
swap(PB_DS_CLASS_C_DEC&);
void
notify_resized(size_type);
inline comp_hash
operator()(key_const_reference) const;
inline size_type
operator()(key_const_reference, size_type, size_type) const;
inline size_type
operator()(key_const_reference, size_type) const;
};
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
ranged_probe_fn(size_type size)
{ Comb_Probe_Fn::notify_resized(size); }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn)
: Hash_Fn(r_hash_fn)
{ Comb_Probe_Fn::notify_resized(size); }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn,
const Comb_Probe_Fn& r_comb_probe_fn)
: Hash_Fn(r_hash_fn), Comb_Probe_Fn(r_comb_probe_fn)
{ comb_probe_fn_base::notify_resized(size); }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn,
const Comb_Probe_Fn& r_comb_probe_fn,
const Probe_Fn& r_probe_fn)
: Hash_Fn(r_hash_fn), Comb_Probe_Fn(r_comb_probe_fn), Probe_Fn(r_probe_fn)
{ comb_probe_fn_base::notify_resized(size); }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
comb_probe_fn_base::swap(other);
std::swap((Hash_Fn& )(*this), (Hash_Fn& )other);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
notify_resized(size_type size)
{ comb_probe_fn_base::notify_resized(size); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::comp_hash
PB_DS_CLASS_C_DEC::
operator()(key_const_reference r_key) const
{
const size_type hash = hash_fn_base::operator()(r_key);
return std::make_pair(comb_probe_fn_base::operator()(hash), hash);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
operator()(key_const_reference, size_type hash, size_type i) const
{
return comb_probe_fn_base::operator()(hash + probe_fn_base::operator()(i));
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
operator()
#ifdef _GLIBCXX_DEBUG
(key_const_reference r_key, size_type hash) const
#else
(key_const_reference /*r_key*/, size_type hash) const
#endif
{
_GLIBCXX_DEBUG_ASSERT(hash == hash_fn_base::operator()(r_key));
return hash;
}
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
/**
* Specialization 3 and 4
* The client does not supply a hash function or probe function,
* and requests that hash values not be stored.
**/
template<typename Key, typename _Alloc, typename Comb_Probe_Fn>
class ranged_probe_fn<Key, null_type, _Alloc, Comb_Probe_Fn,
null_type, false>
: public Comb_Probe_Fn
{
protected:
typedef typename _Alloc::size_type size_type;
typedef Comb_Probe_Fn comb_probe_fn_base;
typedef typename _Alloc::template rebind<Key>::other key_allocator;
typedef typename key_allocator::const_reference key_const_reference;
ranged_probe_fn(size_type size)
{ Comb_Probe_Fn::notify_resized(size); }
ranged_probe_fn(size_type, const Comb_Probe_Fn& r_comb_probe_fn)
: Comb_Probe_Fn(r_comb_probe_fn)
{ }
ranged_probe_fn(size_type, const null_type&,
const Comb_Probe_Fn& r_comb_probe_fn,
const null_type&)
: Comb_Probe_Fn(r_comb_probe_fn)
{ }
void
swap(ranged_probe_fn& other)
{ comb_probe_fn_base::swap(other); }
};
} // namespace detail
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/detail/hash_fn/sample_ranged_probe_fn.hpp 0000644 00000005046 15201526705 0017216 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file sample_ranged_probe_fn.hpp
* Contains a ranged probe policy.
*/
#ifndef PB_DS_SAMPLE_RANGED_PROBE_FN_HPP
#define PB_DS_SAMPLE_RANGED_PROBE_FN_HPP
namespace __gnu_pbds
{
/// A sample ranged-probe functor.
class sample_ranged_probe_fn
{
public:
typedef std::size_t size_type;
// Default constructor.
sample_ranged_probe_fn();
// Copy constructor.
sample_ranged_probe_fn(const sample_ranged_probe_fn&);
// Swaps content.
inline void
swap(sample_ranged_probe_fn&);
protected:
// Notifies the policy object that the container's __size has
// changed to size.
void
notify_resized(size_type);
// Transforms the const key reference r_key into the i-th position
// within the table. This method is called for each collision within
// the probe sequence.
inline size_type
operator()(key_const_reference, std::size_t, size_type) const;
};
}
#endif // #ifndef PB_DS_SAMPLE_RANGED_PROBE_FN_HPP
c++/8/ext/pb_ds/detail/hash_fn/direct_mod_range_hashing_imp.hpp 0000644 00000004056 15201526705 0020376 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file direct_mod_range_hashing_imp.hpp
* Contains a range-hashing policy implementation
*/
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{ mod_based_base::swap(other); }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
notify_resized(size_type n)
{ mod_based_base::notify_resized(n); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
operator()(size_type hash) const
{ return mod_based_base::range_hash(hash); }
c++/8/ext/pb_ds/detail/hash_fn/linear_probe_fn_imp.hpp 0000644 00000003571 15201526705 0016535 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file linear_probe_fn_imp.hpp
* Contains a probe policy implementation
*/
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{ }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
operator()(size_type i) const
{
return (i);
}
c++/8/ext/pb_ds/detail/hash_fn/ranged_hash_fn.hpp 0000644 00000024573 15201526705 0015477 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file ranged_hash_fn.hpp
* Contains a unified ranged hash functor, allowing the hash tables
* to deal with a single class for ranged hashing.
*/
#ifndef PB_DS_RANGED_HASH_FN_HPP
#define PB_DS_RANGED_HASH_FN_HPP
#include <utility>
#include <debug/debug.h>
namespace __gnu_pbds
{
namespace detail
{
/// Primary template.
template<typename Key, typename Hash_Fn, typename _Alloc,
typename Comb_Hash_Fn, bool Store_Hash>
class ranged_hash_fn;
#define PB_DS_CLASS_T_DEC \
template<typename Key, typename Hash_Fn, typename _Alloc, \
typename Comb_Hash_Fn>
#define PB_DS_CLASS_C_DEC \
ranged_hash_fn<Key, Hash_Fn, _Alloc, Comb_Hash_Fn, false>
/**
* Specialization 1
* The client supplies a hash function and a ranged hash function,
* and requests that hash values not be stored.
**/
template<typename Key, typename Hash_Fn, typename _Alloc,
typename Comb_Hash_Fn>
class ranged_hash_fn< Key, Hash_Fn, _Alloc, Comb_Hash_Fn, false>
: public Hash_Fn, public Comb_Hash_Fn
{
protected:
typedef typename _Alloc::size_type size_type;
typedef Hash_Fn hash_fn_base;
typedef Comb_Hash_Fn comb_hash_fn_base;
typedef typename _Alloc::template rebind< Key>::other key_allocator;
typedef typename key_allocator::const_reference key_const_reference;
ranged_hash_fn(size_type);
ranged_hash_fn(size_type, const Hash_Fn&);
ranged_hash_fn(size_type, const Hash_Fn&, const Comb_Hash_Fn&);
void
swap(PB_DS_CLASS_C_DEC&);
void
notify_resized(size_type);
inline size_type
operator()(key_const_reference) const;
};
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
ranged_hash_fn(size_type size)
{ Comb_Hash_Fn::notify_resized(size); }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
ranged_hash_fn(size_type size, const Hash_Fn& r_hash_fn)
: Hash_Fn(r_hash_fn)
{ Comb_Hash_Fn::notify_resized(size); }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
ranged_hash_fn(size_type size, const Hash_Fn& r_hash_fn,
const Comb_Hash_Fn& r_comb_hash_fn)
: Hash_Fn(r_hash_fn), Comb_Hash_Fn(r_comb_hash_fn)
{ comb_hash_fn_base::notify_resized(size); }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
comb_hash_fn_base::swap(other);
std::swap((Hash_Fn& )(*this), (Hash_Fn& )other);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
notify_resized(size_type size)
{ comb_hash_fn_base::notify_resized(size); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
operator()(key_const_reference r_key) const
{ return (comb_hash_fn_base::operator()(hash_fn_base::operator()(r_key)));}
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
#define PB_DS_CLASS_T_DEC \
template<typename Key, typename Hash_Fn, typename _Alloc, \
typename Comb_Hash_Fn>
#define PB_DS_CLASS_C_DEC \
ranged_hash_fn<Key,Hash_Fn, _Alloc, Comb_Hash_Fn, true>
/**
* Specialization 2
* The client supplies a hash function and a ranged hash function,
* and requests that hash values be stored.
**/
template<typename Key, typename Hash_Fn, typename _Alloc,
typename Comb_Hash_Fn>
class ranged_hash_fn<Key, Hash_Fn, _Alloc, Comb_Hash_Fn, true>
: public Hash_Fn, public Comb_Hash_Fn
{
protected:
typedef typename _Alloc::size_type size_type;
typedef std::pair<size_type, size_type> comp_hash;
typedef Hash_Fn hash_fn_base;
typedef Comb_Hash_Fn comb_hash_fn_base;
typedef typename _Alloc::template rebind<Key>::other key_allocator;
typedef typename key_allocator::const_reference key_const_reference;
ranged_hash_fn(size_type);
ranged_hash_fn(size_type, const Hash_Fn&);
ranged_hash_fn(size_type, const Hash_Fn&, const Comb_Hash_Fn&);
void
swap(PB_DS_CLASS_C_DEC&);
void
notify_resized(size_type);
inline comp_hash
operator()(key_const_reference) const;
inline comp_hash
operator()(key_const_reference, size_type) const;
};
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
ranged_hash_fn(size_type size)
{ Comb_Hash_Fn::notify_resized(size); }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
ranged_hash_fn(size_type size, const Hash_Fn& r_hash_fn) :
Hash_Fn(r_hash_fn)
{ Comb_Hash_Fn::notify_resized(size); }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
ranged_hash_fn(size_type size, const Hash_Fn& r_hash_fn,
const Comb_Hash_Fn& r_comb_hash_fn)
: Hash_Fn(r_hash_fn), Comb_Hash_Fn(r_comb_hash_fn)
{ comb_hash_fn_base::notify_resized(size); }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
comb_hash_fn_base::swap(other);
std::swap((Hash_Fn& )(*this), (Hash_Fn& )other);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
notify_resized(size_type size)
{ comb_hash_fn_base::notify_resized(size); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::comp_hash
PB_DS_CLASS_C_DEC::
operator()(key_const_reference r_key) const
{
const size_type hash = hash_fn_base::operator()(r_key);
return std::make_pair(comb_hash_fn_base::operator()(hash), hash);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::comp_hash
PB_DS_CLASS_C_DEC::
operator()
#ifdef _GLIBCXX_DEBUG
(key_const_reference r_key, size_type hash) const
#else
(key_const_reference /*r_key*/, size_type hash) const
#endif
{
_GLIBCXX_DEBUG_ASSERT(hash == hash_fn_base::operator()(r_key));
return std::make_pair(comb_hash_fn_base::operator()(hash), hash);
}
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
#define PB_DS_CLASS_T_DEC \
template<typename Key, typename _Alloc, typename Comb_Hash_Fn>
#define PB_DS_CLASS_C_DEC \
ranged_hash_fn<Key, null_type, _Alloc, Comb_Hash_Fn, false>
/**
* Specialization 3
* The client does not supply a hash function (by specifying
* null_type as the Hash_Fn parameter), and requests that hash
* values not be stored.
**/
template<typename Key, typename _Alloc, typename Comb_Hash_Fn>
class ranged_hash_fn<Key, null_type, _Alloc, Comb_Hash_Fn, false>
: public Comb_Hash_Fn
{
protected:
typedef typename _Alloc::size_type size_type;
typedef Comb_Hash_Fn comb_hash_fn_base;
ranged_hash_fn(size_type);
ranged_hash_fn(size_type, const Comb_Hash_Fn&);
ranged_hash_fn(size_type, const null_type&, const Comb_Hash_Fn&);
void
swap(PB_DS_CLASS_C_DEC&);
};
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
ranged_hash_fn(size_type size)
{ Comb_Hash_Fn::notify_resized(size); }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
ranged_hash_fn(size_type size, const Comb_Hash_Fn& r_comb_hash_fn) :
Comb_Hash_Fn(r_comb_hash_fn)
{ }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
ranged_hash_fn(size_type size, const null_type& r_null_type,
const Comb_Hash_Fn& r_comb_hash_fn)
: Comb_Hash_Fn(r_comb_hash_fn)
{ }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{ comb_hash_fn_base::swap(other); }
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
#define PB_DS_CLASS_T_DEC \
template<typename Key, typename _Alloc, typename Comb_Hash_Fn>
#define PB_DS_CLASS_C_DEC \
ranged_hash_fn<Key, null_type, _Alloc, Comb_Hash_Fn, true>
/**
* Specialization 4
* The client does not supply a hash function (by specifying
* null_type as the Hash_Fn parameter), and requests that hash
* values be stored.
**/
template<typename Key, typename _Alloc, typename Comb_Hash_Fn>
class ranged_hash_fn<Key, null_type, _Alloc, Comb_Hash_Fn, true>
: public Comb_Hash_Fn
{
protected:
typedef typename _Alloc::size_type size_type;
typedef Comb_Hash_Fn comb_hash_fn_base;
ranged_hash_fn(size_type);
ranged_hash_fn(size_type, const Comb_Hash_Fn&);
ranged_hash_fn(size_type, const null_type&, const Comb_Hash_Fn&);
void
swap(PB_DS_CLASS_C_DEC&);
};
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
ranged_hash_fn(size_type size)
{ Comb_Hash_Fn::notify_resized(size); }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
ranged_hash_fn(size_type size, const Comb_Hash_Fn& r_comb_hash_fn)
: Comb_Hash_Fn(r_comb_hash_fn)
{ }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
ranged_hash_fn(size_type size, const null_type& r_null_type,
const Comb_Hash_Fn& r_comb_hash_fn)
: Comb_Hash_Fn(r_comb_hash_fn)
{ }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{ comb_hash_fn_base::swap(other); }
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
} // namespace detail
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/detail/hash_fn/sample_ranged_hash_fn.hpp 0000644 00000004645 15201526705 0017036 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file sample_ranged_hash_fn.hpp
* Contains a ranged hash policy.
*/
#ifndef PB_DS_SAMPLE_RANGED_HASH_FN_HPP
#define PB_DS_SAMPLE_RANGED_HASH_FN_HPP
namespace __gnu_pbds
{
/// A sample ranged-hash functor.
class sample_ranged_hash_fn
{
public:
typedef std::size_t size_type;
/// Default constructor.
sample_ranged_hash_fn();
/// Copy constructor.
sample_ranged_hash_fn(const sample_ranged_hash_fn&);
/// Swaps content.
inline void
swap(sample_ranged_hash_fn&);
protected:
/// Notifies the policy object that the container's __size has
/// changed to size.
void
notify_resized(size_type);
/// Transforms key_const_reference into a position within the table.
inline size_type
operator()(key_const_reference) const;
};
}
#endif // #ifndef PB_DS_SAMPLE_RANGED_HASH_FN_HPP
c++/8/ext/pb_ds/detail/hash_fn/direct_mask_range_hashing_imp.hpp 0000644 00000004070 15201526705 0020546 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file direct_mask_range_hashing_imp.hpp
* Contains a range-hashing policy implementation
*/
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{ mask_based_base::swap(other); }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
notify_resized(size_type size)
{ mask_based_base::notify_resized(size); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
operator()(size_type hash) const
{ return mask_based_base::range_hash(hash); }
c++/8/ext/pb_ds/detail/hash_fn/mod_based_range_hashing.hpp 0000644 00000004527 15201526705 0017340 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file mod_based_range_hashing.hpp
* Contains a range hashing policy base.
*/
#ifndef PB_DS_MOD_BASED_RANGE_HASHING_HPP
#define PB_DS_MOD_BASED_RANGE_HASHING_HPP
namespace __gnu_pbds
{
namespace detail
{
/// Mod based range hashing.
template<typename Size_Type>
class mod_based_range_hashing
{
protected:
typedef Size_Type size_type;
void
swap(mod_based_range_hashing& other)
{ std::swap(m_size, other.m_size); }
void
notify_resized(size_type s)
{ m_size = s; }
inline size_type
range_hash(size_type s) const
{ return s % m_size; }
private:
size_type m_size;
};
} // namespace detail
} // namespace __gnu_pbds
#endif // #ifndef PB_DS_MOD_BASED_RANGE_HASHING_HPP
c++/8/ext/pb_ds/detail/hash_fn/sample_range_hashing.hpp 0000644 00000004667 15201526705 0016711 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file sample_range_hashing.hpp
* Contains a range hashing policy.
*/
#ifndef PB_DS_SAMPLE_RANGE_HASHING_HPP
#define PB_DS_SAMPLE_RANGE_HASHING_HPP
namespace __gnu_pbds
{
/// A sample range-hashing functor.
class sample_range_hashing
{
public:
/// Size type.
typedef std::size_t size_type;
/// Default constructor.
sample_range_hashing();
/// Copy constructor.
sample_range_hashing(const sample_range_hashing& other);
/// Swaps content.
inline void
swap(sample_range_hashing& other);
protected:
/// Notifies the policy object that the container's size has
/// changed to argument's size.
void
notify_resized(size_type);
/// Transforms the __hash value hash into a ranged-hash value.
inline size_type
operator()(size_type ) const;
};
}
#endif // #ifndef PB_DS_SAMPLE_RANGE_HASHING_HPP
c++/8/ext/pb_ds/detail/hash_fn/sample_probe_fn.hpp 0000644 00000004363 15201526705 0015677 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file sample_probe_fn.hpp
* Contains a sample probe policy.
*/
#ifndef PB_DS_SAMPLE_PROBE_FN_HPP
#define PB_DS_SAMPLE_PROBE_FN_HPP
namespace __gnu_pbds
{
/// A sample probe policy.
class sample_probe_fn
{
public:
typedef std::size_t size_type;
/// Default constructor.
sample_probe_fn();
/// Copy constructor.
sample_probe_fn(const sample_probe_fn&);
/// Swaps content.
inline void
swap(sample_probe_fn&);
protected:
/// Returns the i-th offset from the hash value of some key r_key.
inline size_type
operator()(key_const_reference r_key, size_type i) const;
};
}
#endif // #ifndef PB_DS_SAMPLE_PROBE_FN_HPP
c++/8/ext/pb_ds/detail/hash_fn/probe_fn_base.hpp 0000644 00000003731 15201526705 0015326 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file probe_fn_base.hpp
* Contains a probe policy base.
*/
#ifndef PB_DS_PROBE_FN_BASE_HPP
#define PB_DS_PROBE_FN_BASE_HPP
#include <functional>
namespace __gnu_pbds
{
namespace detail
{
/// Probe functor base.
template<typename _Alloc>
class probe_fn_base
{
protected:
~probe_fn_base() { }
};
} // namespace detail
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/detail/hash_fn/mask_based_range_hashing.hpp 0000644 00000006332 15201526705 0017510 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file mask_based_range_hashing.hpp
* Contains a range hashing policy base.
*/
#ifndef PB_DS_MASK_BASED_RANGE_HASHING_HPP
#define PB_DS_MASK_BASED_RANGE_HASHING_HPP
namespace __gnu_pbds
{
namespace detail
{
/// Range hashing policy.
template<typename Size_Type>
class mask_based_range_hashing
{
protected:
typedef Size_Type size_type;
void
swap(mask_based_range_hashing& other)
{ std::swap(m_mask, other.m_mask); }
void
notify_resized(size_type size);
inline size_type
range_hash(size_type hash) const
{ return size_type(hash & m_mask); }
private:
size_type m_mask;
const static size_type s_num_bits_in_size_type;
const static size_type s_highest_bit_1;
};
template<typename Size_Type>
const typename mask_based_range_hashing<Size_Type>::size_type
mask_based_range_hashing<Size_Type>::s_num_bits_in_size_type =
sizeof(typename mask_based_range_hashing<Size_Type>::size_type) << 3;
template<typename Size_Type>
const typename mask_based_range_hashing<Size_Type>::size_type mask_based_range_hashing<Size_Type>::s_highest_bit_1 = static_cast<typename mask_based_range_hashing<Size_Type>::size_type>(1) << (s_num_bits_in_size_type - 1);
template<typename Size_Type>
void
mask_based_range_hashing<Size_Type>::
notify_resized(size_type size)
{
size_type i = 0;
while (size ^ s_highest_bit_1)
{
size <<= 1;
++i;
}
m_mask = 1;
i += 2;
while (i++ < s_num_bits_in_size_type)
m_mask = (m_mask << 1) ^ 1;
}
} // namespace detail
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/detail/hash_fn/quadratic_probe_fn_imp.hpp 0000644 00000003600 15201526705 0017231 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file quadratic_probe_fn_imp.hpp
* Contains a probe policy implementation
*/
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{ }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
operator()(size_type i) const
{
return (i* i);
}
c++/8/ext/pb_ds/detail/trie_policy/order_statistics_imp.hpp 0000644 00000011135 15201526705 0017705 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file trie_policy/order_statistics_imp.hpp
* Contains forward declarations for order_statistics_key
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
find_by_order(size_type order)
{
if (empty())
return end();
++order;
node_iterator nd_it = node_begin();
while (true)
{
if (order > nd_it.get_metadata())
return ++base_type::rightmost_it(nd_it);
const size_type num_children = nd_it.num_children();
if (num_children == 0)
return *nd_it;
for (size_type i = 0; i < num_children; ++i)
{
node_iterator child_nd_it = nd_it.get_child(i);
if (order <= child_nd_it.get_metadata())
{
i = num_children;
nd_it = child_nd_it;
}
else
order -= child_nd_it.get_metadata();
}
}
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
find_by_order(size_type order) const
{ return const_cast<PB_DS_CLASS_C_DEC*>(this)->find_by_order(order); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
order_of_key(key_const_reference r_key) const
{
const _ATraits& r_traits =
const_cast<PB_DS_CLASS_C_DEC* >(this)->get_access_traits();
return order_of_prefix(r_traits.begin(r_key), r_traits.end(r_key));
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
order_of_prefix(typename access_traits::const_iterator b,
typename access_traits::const_iterator e) const
{
if (empty())
return 0;
const _ATraits& r_traits =
const_cast<PB_DS_CLASS_C_DEC*>(this)->get_access_traits();
node_const_iterator nd_it = node_begin();
node_const_iterator end_nd_it = node_end();
size_type ord = 0;
while (true)
{
const size_type num_children = nd_it.num_children();
if (num_children == 0)
{
key_const_reference r_key = base_type::extract_key(*(*nd_it));
typename access_traits::const_iterator key_b =
r_traits.begin(r_key);
typename access_traits::const_iterator key_e =
r_traits.end(r_key);
return (base_type::less(key_b, key_e, b, e, r_traits)) ?
ord + 1 : ord;
}
node_const_iterator next_nd_it = end_nd_it;
size_type i = num_children - 1;
do
{
node_const_iterator child_nd_it = nd_it.get_child(i);
if (next_nd_it != end_nd_it)
ord += child_nd_it.get_metadata();
else if (!base_type::less(b, e,
child_nd_it.valid_prefix().first,
child_nd_it.valid_prefix().second,
r_traits))
next_nd_it = child_nd_it;
}
while (i-- > 0);
if (next_nd_it == end_nd_it)
return ord;
nd_it = next_nd_it;
}
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
operator()(node_iterator nd_it, node_const_iterator /*end_nd_it*/) const
{
const size_type num_children = nd_it.num_children();
size_type children_rank = 0;
for (size_type i = 0; i < num_children; ++i)
children_rank += nd_it.get_child(i).get_metadata();
const size_type res = (num_children == 0) ? 1 : children_rank;
const_cast<size_type&>(nd_it.get_metadata()) = res;
}
c++/8/ext/pb_ds/detail/trie_policy/sample_trie_access_traits.hpp 0000644 00000005231 15201526705 0020666 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file trie_policy/sample_trie_access_traits.hpp
* Contains a sample probe policy.
*/
#ifndef PB_DS_SAMPLE_TRIE_E_ACCESS_TRAITS_HPP
#define PB_DS_SAMPLE_TRIE_E_ACCESS_TRAITS_HPP
namespace __gnu_pbds
{
/// A sample trie element access traits.
struct sample_trie_access_traits
{
typedef std::size_t size_type;
typedef std::string key_type;
typedef typename _Alloc::template rebind<key_type> __rebind_k;
typedef typename __rebind_k::other::const_reference key_const_reference;
typedef std::string::const_iterator const_iterator;
/// Element type.
typedef char e_type;
enum
{
max_size = 4
};
/// Returns a const_iterator to the first element of r_key.
inline static const_iterator
begin(key_const_reference);
/// Returns a const_iterator to the after-last element of r_key.
inline static const_iterator
end(key_const_reference);
/// Maps an element to a position.
inline static size_type
e_pos(e_type);
};
}
#endif // #ifndef PB_DS_SAMPLE_TRIE_E_ACCESS_TRAITS_HPP
c++/8/ext/pb_ds/detail/trie_policy/node_metadata_selector.hpp 0000644 00000006412 15201526705 0020142 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file trie_policy/node_metadata_selector.hpp
* Contains an implementation class for tries.
*/
#ifndef PB_DS_TRIE_NODE_METADATA_DISPATCH_HPP
#define PB_DS_TRIE_NODE_METADATA_DISPATCH_HPP
#include <ext/pb_ds/detail/branch_policy/null_node_metadata.hpp>
#include <ext/pb_ds/detail/types_traits.hpp>
namespace __gnu_pbds
{
namespace detail
{
/**
* @addtogroup traits Traits
* @{
*/
/// Trie metadata helper.
template<typename Node_Update, bool _BTp>
struct trie_metadata_helper;
/// Specialization, false.
template<typename Node_Update>
struct trie_metadata_helper<Node_Update, false>
{
typedef typename Node_Update::metadata_type type;
};
/// Specialization, true.
template<typename Node_Update>
struct trie_metadata_helper<Node_Update, true>
{
typedef null_type type;
};
/// Trie node metadata dispatch.
template<typename Key,
typename Data,
typename Cmp_Fn,
template<typename Node_CItr,
typename Const_Iterator,
typename Cmp_Fn_,
typename _Alloc_>
class Node_Update,
typename _Alloc>
struct trie_node_metadata_dispatch
{
private:
typedef dumnode_const_iterator<Key, Data, _Alloc> __it_type;
typedef Node_Update<__it_type, __it_type, Cmp_Fn, _Alloc> __node_u;
typedef null_node_update<__it_type, __it_type, Cmp_Fn, _Alloc> __nnode_u;
enum
{
null_update = is_same<__node_u, __nnode_u>::value
};
public:
typedef typename trie_metadata_helper<__node_u, null_update>::type type;
};
//@}
} // namespace detail
} // namespace __gnu_pbds
#endif // #ifndef PB_DS_TRIE_NODE_METADATA_DISPATCH_HPP
c++/8/ext/pb_ds/detail/trie_policy/prefix_search_node_update_imp.hpp 0000644 00000010637 15201526705 0021517 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file trie_policy/prefix_search_node_update_imp.hpp
* Contains an implementation of prefix_search_node_update.
*/
PB_DS_CLASS_T_DEC
std::pair<
typename PB_DS_CLASS_C_DEC::const_iterator,
typename PB_DS_CLASS_C_DEC::const_iterator>
PB_DS_CLASS_C_DEC::
prefix_range(key_const_reference r_key) const
{
const access_traits& r_traits = get_access_traits();
return (prefix_range(r_traits.begin(r_key), r_traits.end(r_key)));
}
PB_DS_CLASS_T_DEC
std::pair<
typename PB_DS_CLASS_C_DEC::iterator,
typename PB_DS_CLASS_C_DEC::iterator>
PB_DS_CLASS_C_DEC::
prefix_range(key_const_reference r_key)
{
return (prefix_range(get_access_traits().begin(r_key),
get_access_traits().end(r_key)));
}
PB_DS_CLASS_T_DEC
std::pair<
typename PB_DS_CLASS_C_DEC::const_iterator,
typename PB_DS_CLASS_C_DEC::const_iterator>
PB_DS_CLASS_C_DEC::
prefix_range(typename access_traits::const_iterator b,
typename access_traits::const_iterator e) const
{
const std::pair<iterator, iterator> non_const_ret =
const_cast<PB_DS_CLASS_C_DEC* >(this)->prefix_range(b, e);
return (std::make_pair(const_iterator(non_const_ret.first),
const_iterator(non_const_ret.second)));
}
PB_DS_CLASS_T_DEC
std::pair<
typename PB_DS_CLASS_C_DEC::iterator,
typename PB_DS_CLASS_C_DEC::iterator>
PB_DS_CLASS_C_DEC::
prefix_range(typename access_traits::const_iterator b,
typename access_traits::const_iterator e)
{
Node_Itr nd_it = node_begin();
Node_Itr end_nd_it = node_end();
const access_traits& r_traits = get_access_traits();
const size_type given_range_length = std::distance(b, e);
while (true)
{
if (nd_it == end_nd_it)
return (std::make_pair(end(), end()));
const size_type common_range_length =
base_type::common_prefix_len(nd_it, b, e, r_traits);
if (common_range_length >= given_range_length)
{
iterator ret_b = this->leftmost_it(nd_it);
iterator ret_e = this->rightmost_it(nd_it);
return (std::make_pair(ret_b, ++ret_e));
}
nd_it = next_child(nd_it, b, e, end_nd_it, r_traits);
}
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_iterator
PB_DS_CLASS_C_DEC::
next_child(node_iterator nd_it, typename access_traits::const_iterator b,
typename access_traits::const_iterator e, node_iterator end_nd_it,
const access_traits& r_traits)
{
const size_type num_children = nd_it.num_children();
node_iterator ret = end_nd_it;
size_type max_length = 0;
for (size_type i = 0; i < num_children; ++i)
{
node_iterator pot = nd_it.get_child(i);
const size_type common_range_length =
base_type::common_prefix_len(pot, b, e, r_traits);
if (common_range_length > max_length)
{
ret = pot;
max_length = common_range_length;
}
}
return (ret);
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
operator()(node_iterator /*nd_it*/, node_const_iterator /*end_nd_it*/) const
{ }
c++/8/ext/pb_ds/detail/trie_policy/trie_policy_base.hpp 0000644 00000013327 15201526705 0016774 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file trie_policy/trie_policy_base.hpp
* Contains an implementation of trie_policy_base.
*/
#ifndef PB_DS_TRIE_POLICY_BASE_HPP
#define PB_DS_TRIE_POLICY_BASE_HPP
#include <ext/pb_ds/detail/branch_policy/branch_policy.hpp>
namespace __gnu_pbds
{
namespace detail
{
/// Base class for trie policies.
template<typename Node_CItr, typename Node_Itr,
typename _ATraits, typename _Alloc>
class trie_policy_base
: public branch_policy<Node_CItr, Node_Itr, _Alloc>
{
typedef branch_policy<Node_CItr, Node_Itr, _Alloc> base_type;
public:
typedef _ATraits access_traits;
typedef _Alloc allocator_type;
typedef typename allocator_type::size_type size_type;
typedef null_type metadata_type;
typedef Node_CItr node_const_iterator;
typedef Node_Itr node_iterator;
typedef typename node_const_iterator::value_type const_iterator;
typedef typename node_iterator::value_type iterator;
typedef typename base_type::key_type key_type;
typedef typename base_type::key_const_reference key_const_reference;
protected:
virtual const_iterator
end() const = 0;
virtual iterator
end() = 0;
virtual node_const_iterator
node_begin() const = 0;
virtual node_iterator
node_begin() = 0;
virtual node_const_iterator
node_end() const = 0;
virtual node_iterator
node_end() = 0;
virtual const access_traits&
get_access_traits() const = 0;
private:
typedef typename access_traits::const_iterator e_const_iterator;
typedef std::pair<e_const_iterator, e_const_iterator> prefix_range_t;
protected:
static size_type
common_prefix_len(node_iterator, e_const_iterator,
e_const_iterator, const access_traits&);
static iterator
leftmost_it(node_iterator);
static iterator
rightmost_it(node_iterator);
static bool
less(e_const_iterator, e_const_iterator, e_const_iterator,
e_const_iterator, const access_traits&);
};
#define PB_DS_CLASS_T_DEC \
template<typename Node_CItr, typename Node_Itr, \
typename _ATraits, typename _Alloc>
#define PB_DS_CLASS_C_DEC \
trie_policy_base<Node_CItr, Node_Itr, _ATraits, _Alloc>
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
common_prefix_len(node_iterator nd_it, e_const_iterator b_r,
e_const_iterator e_r, const access_traits& r_traits)
{
prefix_range_t pref_range = nd_it.valid_prefix();
e_const_iterator b_l = pref_range.first;
e_const_iterator e_l = pref_range.second;
const size_type range_length_l = std::distance(b_l, e_l);
const size_type range_length_r = std::distance(b_r, e_r);
if (range_length_r < range_length_l)
{
std::swap(b_l, b_r);
std::swap(e_l, e_r);
}
size_type ret = 0;
while (b_l != e_l)
{
if (r_traits.e_pos(*b_l) != r_traits.e_pos(*b_r))
return ret;
++ret;
++b_l;
++b_r;
}
return ret;
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
leftmost_it(node_iterator nd_it)
{
if (nd_it.num_children() == 0)
return *nd_it;
return leftmost_it(nd_it.get_child(0));
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
rightmost_it(node_iterator nd_it)
{
const size_type num_children = nd_it.num_children();
if (num_children == 0)
return *nd_it;
return rightmost_it(nd_it.get_child(num_children - 1));
}
PB_DS_CLASS_T_DEC
bool
PB_DS_CLASS_C_DEC::
less(e_const_iterator b_l, e_const_iterator e_l,
e_const_iterator b_r, e_const_iterator e_r,
const access_traits& r_traits)
{
while (b_l != e_l)
{
if (b_r == e_r)
return false;
size_type l_pos = r_traits.e_pos(*b_l);
size_type r_pos = r_traits.e_pos(*b_r);
if (l_pos != r_pos)
return (l_pos < r_pos);
++b_l;
++b_r;
}
return b_r != e_r;
}
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
} // namespace detail
} // namespace __gnu_pbds
#endif // #ifndef PB_DS_TRIE_POLICY_BASE_HPP
c++/8/ext/pb_ds/detail/trie_policy/trie_string_access_traits_imp.hpp 0000644 00000005753 15201526705 0021571 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file trie_policy/trie_string_access_traits_imp.hpp
* Contains a policy for extracting character positions from
* a string for a vector-based PATRICIA tree
*/
PB_DS_CLASS_T_DEC
detail::integral_constant<int, Reverse> PB_DS_CLASS_C_DEC::s_rev_ind;
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
e_pos(e_type e)
{
return (static_cast<size_type>(e - min_e_val));
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
begin(key_const_reference r_key)
{
return (begin_imp(r_key, s_rev_ind));
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
end(key_const_reference r_key)
{
return (end_imp(r_key, s_rev_ind));
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
begin_imp(key_const_reference r_key, detail::false_type)
{
return (r_key.begin());
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
begin_imp(key_const_reference r_key, detail::true_type)
{
return (r_key.rbegin());
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
end_imp(key_const_reference r_key, detail::false_type)
{
return (r_key.end());
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
end_imp(key_const_reference r_key, detail::true_type)
{
return (r_key.rend());
}
c++/8/ext/pb_ds/detail/trie_policy/sample_trie_node_update.hpp 0000644 00000004454 15201526705 0020334 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file trie_policy/sample_trie_node_update.hpp
* Contains a samle node update functor.
*/
#ifndef PB_DS_SAMPLE_TRIE_NODE_UPDATOR_HPP
#define PB_DS_SAMPLE_TRIE_NODE_UPDATOR_HPP
namespace __gnu_pbds
{
/// A sample node updator.
template<typename Node_CItr, typename Node_Itr,
typename _ATraits, typename _Alloc>
class sample_trie_node_update
{
public:
typedef std::size_t metadata_type;
protected:
/// Default constructor.
sample_trie_node_update();
/// Updates the rank of a node through a node_iterator node_it;
/// end_nd_it is the end node iterator.
inline void
operator()(node_iterator, node_const_iterator) const;
};
}
#endif // #ifndef PB_DS_SAMPLE_TRIE_NODE_UPDATOR_HPP
c++/8/ext/pb_ds/detail/branch_policy/null_node_metadata.hpp 0000644 00000004513 15201526705 0017566 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file branch_policy/null_node_metadata.hpp
* Contains an implementation class for tree-like classes.
*/
#ifndef PB_DS_0_NODE_METADATA_HPP
#define PB_DS_0_NODE_METADATA_HPP
#include <ext/pb_ds/detail/types_traits.hpp>
namespace __gnu_pbds
{
namespace detail
{
/// Constant node iterator.
template<typename Key, typename Data, typename _Alloc>
struct dumnode_const_iterator
{
private:
typedef types_traits<Key, Data, _Alloc, false> __traits_type;
typedef typename __traits_type::pointer const_iterator;
public:
typedef const_iterator value_type;
typedef const_iterator const_reference;
typedef const_reference reference;
};
} // namespace detail
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/detail/branch_policy/branch_policy.hpp 0000644 00000007677 15201526705 0016601 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file branch_policy/branch_policy.hpp
* Contains a base class for branch policies.
*/
#ifndef PB_DS_BRANCH_POLICY_BASE_HPP
#define PB_DS_BRANCH_POLICY_BASE_HPP
#include <ext/pb_ds/tag_and_trait.hpp>
namespace __gnu_pbds
{
namespace detail
{
/// Primary template, base class for branch structure policies.
template<typename Node_CItr, typename Node_Itr, typename _Alloc>
struct branch_policy
{
protected:
typedef typename Node_Itr::value_type it_type;
typedef typename std::iterator_traits<it_type>::value_type value_type;
typedef typename value_type::first_type key_type;
typedef typename remove_const<value_type>::type rcvalue_type;
typedef typename remove_const<key_type>::type rckey_type;
typedef typename _Alloc::template rebind<rcvalue_type>::other rebind_v;
typedef typename _Alloc::template rebind<rckey_type>::other rebind_k;
typedef typename rebind_v::reference reference;
typedef typename rebind_v::const_reference const_reference;
typedef typename rebind_v::const_pointer const_pointer;
typedef typename rebind_k::const_reference key_const_reference;
static inline key_const_reference
extract_key(const_reference r_val)
{ return r_val.first; }
virtual it_type
end() = 0;
it_type
end_iterator() const
{ return const_cast<branch_policy*>(this)->end(); }
virtual
~branch_policy() { }
};
/// Specialization for const iterators.
template<typename Node_CItr, typename _Alloc>
struct branch_policy<Node_CItr, Node_CItr, _Alloc>
{
protected:
typedef typename Node_CItr::value_type it_type;
typedef typename std::iterator_traits<it_type>::value_type value_type;
typedef typename remove_const<value_type>::type rcvalue_type;
typedef typename _Alloc::template rebind<rcvalue_type>::other rebind_v;
typedef typename rebind_v::reference reference;
typedef typename rebind_v::const_reference const_reference;
typedef typename rebind_v::const_pointer const_pointer;
typedef value_type key_type;
typedef typename rebind_v::const_reference key_const_reference;
static inline key_const_reference
extract_key(const_reference r_val)
{ return r_val; }
virtual it_type
end() const = 0;
it_type
end_iterator() const
{ return end(); }
virtual
~branch_policy() { }
};
} // namespace detail
} // namespace __gnu_pbds
#endif // #ifndef PB_DS_BRANCH_POLICY_BASE_HPP
c++/8/ext/pb_ds/detail/branch_policy/traits.hpp 0000644 00000006266 15201526705 0015264 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file branch_policy/traits.hpp
* Contains an implementation class for tree-like classes.
*/
#ifndef PB_DS_NODE_AND_IT_TRAITS_HPP
#define PB_DS_NODE_AND_IT_TRAITS_HPP
#include <ext/pb_ds/detail/types_traits.hpp>
#include <ext/pb_ds/detail/bin_search_tree_/traits.hpp>
#include <ext/pb_ds/detail/tree_policy/node_metadata_selector.hpp>
#include <ext/pb_ds/detail/trie_policy/node_metadata_selector.hpp>
#define PB_DS_DEBUG_VERIFY(_Cond) \
_GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
_M_message(#_Cond" assertion from %1;:%2;") \
._M_string(__FILE__)._M_integer(__LINE__) \
,__file,__line)
namespace __gnu_pbds
{
namespace detail
{
/// Tree traits class, primary template.
template<typename Key,
typename Data,
typename Cmp_Fn,
template<typename Node_CItr,
typename Node_Itr,
typename Cmp_Fn_,
typename _Alloc>
class Node_Update,
typename Tag,
typename _Alloc>
struct tree_traits;
/// Trie traits class, primary template.
template<typename Key,
typename Data,
typename _ATraits,
template<typename Node_CItr,
typename Node_Itr,
typename _ATraits_,
typename _Alloc>
class Node_Update,
typename Tag,
typename _Alloc>
struct trie_traits;
} // namespace detail
} // namespace __gnu_pbds
#include <ext/pb_ds/detail/rb_tree_map_/traits.hpp>
#include <ext/pb_ds/detail/splay_tree_/traits.hpp>
#include <ext/pb_ds/detail/ov_tree_map_/traits.hpp>
#include <ext/pb_ds/detail/pat_trie_/traits.hpp>
#undef PB_DS_DEBUG_VERIFY
#endif // #ifndef PB_DS_NODE_AND_IT_TRAITS_HPP
c++/8/ext/pb_ds/detail/bin_search_tree_/info_fn_imps.hpp 0000644 00000004040 15201526705 0017047 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file bin_search_tree_/info_fn_imps.hpp
* Contains an implementation class for bin_search_tree_.
*/
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
empty() const
{
return (m_size == 0);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
size() const
{
return (m_size);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
max_size() const
{
return (s_node_allocator.max_size());
}
c++/8/ext/pb_ds/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp 0000644 00000012603 15201526705 0023146 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file bin_search_tree_/constructors_destructor_fn_imps.hpp
* Contains an implementation class for bin_search_tree_.
*/
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_allocator
PB_DS_CLASS_C_DEC::s_node_allocator;
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_BIN_TREE_NAME() : m_p_head(s_node_allocator.allocate(1)), m_size(0)
{
initialize();
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_BIN_TREE_NAME(const Cmp_Fn& r_cmp_fn) :
Cmp_Fn(r_cmp_fn), m_p_head(s_node_allocator.allocate(1)), m_size(0)
{
initialize();
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_BIN_TREE_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_update) :
Cmp_Fn(r_cmp_fn),
node_update(r_node_update),
m_p_head(s_node_allocator.allocate(1)),
m_size(0)
{
initialize();
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_BIN_TREE_NAME(const PB_DS_CLASS_C_DEC& other) :
#ifdef _GLIBCXX_DEBUG
debug_base(other),
#endif
#ifdef PB_DS_TREE_TRACE
PB_DS_TREE_TRACE_BASE_C_DEC(other),
#endif
Cmp_Fn(other),
node_update(other),
m_p_head(s_node_allocator.allocate(1)),
m_size(0)
{
initialize();
m_size = other.m_size;
PB_DS_STRUCT_ONLY_ASSERT_VALID(other)
__try
{
m_p_head->m_p_parent = recursive_copy_node(other.m_p_head->m_p_parent);
if (m_p_head->m_p_parent != 0)
m_p_head->m_p_parent->m_p_parent = m_p_head;
m_size = other.m_size;
initialize_min_max();
}
__catch(...)
{
_GLIBCXX_DEBUG_ONLY(debug_base::clear();)
s_node_allocator.deallocate(m_p_head, 1);
__throw_exception_again;
}
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
PB_DS_STRUCT_ONLY_ASSERT_VALID(other)
value_swap(other);
std::swap((Cmp_Fn& )(*this), (Cmp_Fn& )other);
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
PB_DS_STRUCT_ONLY_ASSERT_VALID(other)
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
value_swap(PB_DS_CLASS_C_DEC& other)
{
_GLIBCXX_DEBUG_ONLY(debug_base::swap(other);)
std::swap(m_p_head, other.m_p_head);
std::swap(m_size, other.m_size);
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
~PB_DS_BIN_TREE_NAME()
{
clear();
s_node_allocator.deallocate(m_p_head, 1);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
initialize()
{
m_p_head->m_p_parent = 0;
m_p_head->m_p_left = m_p_head;
m_p_head->m_p_right = m_p_head;
m_size = 0;
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
recursive_copy_node(const node_pointer p_nd)
{
if (p_nd == 0)
return (0);
node_pointer p_ret = s_node_allocator.allocate(1);
__try
{
new (p_ret) node(*p_nd);
}
__catch(...)
{
s_node_allocator.deallocate(p_ret, 1);
__throw_exception_again;
}
p_ret->m_p_left = p_ret->m_p_right = 0;
__try
{
p_ret->m_p_left = recursive_copy_node(p_nd->m_p_left);
p_ret->m_p_right = recursive_copy_node(p_nd->m_p_right);
}
__catch(...)
{
clear_imp(p_ret);
__throw_exception_again;
}
if (p_ret->m_p_left != 0)
p_ret->m_p_left->m_p_parent = p_ret;
if (p_ret->m_p_right != 0)
p_ret->m_p_right->m_p_parent = p_ret;
PB_DS_ASSERT_NODE_CONSISTENT(p_ret)
return p_ret;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
initialize_min_max()
{
if (m_p_head->m_p_parent == 0)
{
m_p_head->m_p_left = m_p_head->m_p_right = m_p_head;
return;
}
{
node_pointer p_min = m_p_head->m_p_parent;
while (p_min->m_p_left != 0)
p_min = p_min->m_p_left;
m_p_head->m_p_left = p_min;
}
{
node_pointer p_max = m_p_head->m_p_parent;
while (p_max->m_p_right != 0)
p_max = p_max->m_p_right;
m_p_head->m_p_right = p_max;
}
}
c++/8/ext/pb_ds/detail/bin_search_tree_/iterators_fn_imps.hpp 0000644 00000006673 15201526705 0020146 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file bin_search_tree_/iterators_fn_imps.hpp
* Contains an implementation class for bin_search_tree_.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
begin()
{
return (iterator(m_p_head->m_p_left));
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
begin() const
{
return (const_iterator(m_p_head->m_p_left));
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
end()
{
return (iterator(m_p_head));
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
end() const
{
return (const_iterator(m_p_head));
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_reverse_iterator
PB_DS_CLASS_C_DEC::
rbegin() const
{
return (const_reverse_iterator(m_p_head->m_p_right));
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::reverse_iterator
PB_DS_CLASS_C_DEC::
rbegin()
{
return (reverse_iterator(m_p_head->m_p_right));
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::reverse_iterator
PB_DS_CLASS_C_DEC::
rend()
{
return (reverse_iterator(m_p_head));
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_reverse_iterator
PB_DS_CLASS_C_DEC::
rend() const
{
return (const_reverse_iterator(m_p_head));
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_const_iterator
PB_DS_CLASS_C_DEC::
node_begin() const
{
return (node_const_iterator(m_p_head->m_p_parent));
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_iterator
PB_DS_CLASS_C_DEC::
node_begin()
{
return (node_iterator(m_p_head->m_p_parent));
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_const_iterator
PB_DS_CLASS_C_DEC::
node_end() const
{
return (node_const_iterator(0));
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_iterator
PB_DS_CLASS_C_DEC::
node_end()
{
return (node_iterator(0));
}
c++/8/ext/pb_ds/detail/bin_search_tree_/debug_fn_imps.hpp 0000644 00000017607 15201526705 0017217 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file bin_search_tree_/debug_fn_imps.hpp
* Contains an implementation class for bin_search_tree_.
*/
#ifdef _GLIBCXX_DEBUG
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_valid(const char* __file, int __line) const
{
structure_only_assert_valid(__file, __line);
assert_consistent_with_debug_base(__file, __line);
assert_size(__file, __line);
assert_iterators(__file, __line);
if (m_p_head->m_p_parent == 0)
{
PB_DS_DEBUG_VERIFY(m_size == 0);
}
else
{
PB_DS_DEBUG_VERIFY(m_size > 0);
}
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
structure_only_assert_valid(const char* __file, int __line) const
{
PB_DS_DEBUG_VERIFY(m_p_head != 0);
if (m_p_head->m_p_parent == 0)
{
PB_DS_DEBUG_VERIFY(m_p_head->m_p_left == m_p_head);
PB_DS_DEBUG_VERIFY(m_p_head->m_p_right == m_p_head);
}
else
{
PB_DS_DEBUG_VERIFY(m_p_head->m_p_parent->m_p_parent == m_p_head);
PB_DS_DEBUG_VERIFY(m_p_head->m_p_left != m_p_head);
PB_DS_DEBUG_VERIFY(m_p_head->m_p_right != m_p_head);
}
if (m_p_head->m_p_parent != 0)
assert_node_consistent(m_p_head->m_p_parent, __file, __line);
assert_min(__file, __line);
assert_max(__file, __line);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_node_consistent(const node_pointer p_nd,
const char* __file, int __line) const
{
assert_node_consistent_(p_nd, __file, __line);
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_consistent_t
PB_DS_CLASS_C_DEC::
assert_node_consistent_(const node_pointer p_nd,
const char* __file, int __line) const
{
if (p_nd == 0)
return (std::make_pair((const_pointer)0,(const_pointer)0));
assert_node_consistent_with_left(p_nd, __file, __line);
assert_node_consistent_with_right(p_nd, __file, __line);
const std::pair<const_pointer, const_pointer>
l_range = assert_node_consistent_(p_nd->m_p_left, __file, __line);
if (l_range.second != 0)
PB_DS_DEBUG_VERIFY(Cmp_Fn::operator()(PB_DS_V2F(*l_range.second),
PB_DS_V2F(p_nd->m_value)));
const std::pair<const_pointer, const_pointer>
r_range = assert_node_consistent_(p_nd->m_p_right, __file, __line);
if (r_range.first != 0)
PB_DS_DEBUG_VERIFY(Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value),
PB_DS_V2F(*r_range.first)));
return std::make_pair((l_range.first != 0) ? l_range.first : &p_nd->m_value,
(r_range.second != 0)? r_range.second : &p_nd->m_value);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_node_consistent_with_left(const node_pointer p_nd,
const char* __file, int __line) const
{
if (p_nd->m_p_left == 0)
return;
PB_DS_DEBUG_VERIFY(p_nd->m_p_left->m_p_parent == p_nd);
PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value),
PB_DS_V2F(p_nd->m_p_left->m_value)));
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_node_consistent_with_right(const node_pointer p_nd,
const char* __file, int __line) const
{
if (p_nd->m_p_right == 0)
return;
PB_DS_DEBUG_VERIFY(p_nd->m_p_right->m_p_parent == p_nd);
PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_p_right->m_value),
PB_DS_V2F(p_nd->m_value)));
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_min(const char* __file, int __line) const
{
assert_min_imp(m_p_head->m_p_parent, __file, __line);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_min_imp(const node_pointer p_nd, const char* __file, int __line) const
{
if (p_nd == 0)
{
PB_DS_DEBUG_VERIFY(m_p_head->m_p_left == m_p_head);
return;
}
if (p_nd->m_p_left == 0)
{
PB_DS_DEBUG_VERIFY(p_nd == m_p_head->m_p_left);
return;
}
assert_min_imp(p_nd->m_p_left, __file, __line);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_max(const char* __file, int __line) const
{
assert_max_imp(m_p_head->m_p_parent, __file, __line);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_max_imp(const node_pointer p_nd,
const char* __file, int __line) const
{
if (p_nd == 0)
{
PB_DS_DEBUG_VERIFY(m_p_head->m_p_right == m_p_head);
return;
}
if (p_nd->m_p_right == 0)
{
PB_DS_DEBUG_VERIFY(p_nd == m_p_head->m_p_right);
return;
}
assert_max_imp(p_nd->m_p_right, __file, __line);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_iterators(const char* __file, int __line) const
{
size_type iterated_num = 0;
const_iterator prev_it = end();
for (const_iterator it = begin(); it != end(); ++it)
{
++iterated_num;
PB_DS_DEBUG_VERIFY(lower_bound(PB_DS_V2F(*it)).m_p_nd == it.m_p_nd);
const_iterator upper_bound_it = upper_bound(PB_DS_V2F(*it));
--upper_bound_it;
PB_DS_DEBUG_VERIFY(upper_bound_it.m_p_nd == it.m_p_nd);
if (prev_it != end())
PB_DS_DEBUG_VERIFY(Cmp_Fn::operator()(PB_DS_V2F(*prev_it),
PB_DS_V2F(*it)));
prev_it = it;
}
PB_DS_DEBUG_VERIFY(iterated_num == m_size);
size_type reverse_iterated_num = 0;
const_reverse_iterator reverse_prev_it = rend();
for (const_reverse_iterator reverse_it = rbegin(); reverse_it != rend();
++reverse_it)
{
++reverse_iterated_num;
PB_DS_DEBUG_VERIFY(lower_bound(
PB_DS_V2F(*reverse_it)).m_p_nd == reverse_it.m_p_nd);
const_iterator upper_bound_it = upper_bound(PB_DS_V2F(*reverse_it));
--upper_bound_it;
PB_DS_DEBUG_VERIFY(upper_bound_it.m_p_nd == reverse_it.m_p_nd);
if (reverse_prev_it != rend())
PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(PB_DS_V2F(*reverse_prev_it),
PB_DS_V2F(*reverse_it)));
reverse_prev_it = reverse_it;
}
PB_DS_DEBUG_VERIFY(reverse_iterated_num == m_size);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_consistent_with_debug_base(const char* __file, int __line) const
{
debug_base::check_size(m_size, __file, __line);
assert_consistent_with_debug_base(m_p_head->m_p_parent, __file, __line);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_consistent_with_debug_base(const node_pointer p_nd,
const char* __file, int __line) const
{
if (p_nd == 0)
return;
debug_base::check_key_exists(PB_DS_V2F(p_nd->m_value), __file, __line);
assert_consistent_with_debug_base(p_nd->m_p_left, __file, __line);
assert_consistent_with_debug_base(p_nd->m_p_right, __file, __line);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_size(const char* __file, int __line) const
{ PB_DS_DEBUG_VERIFY(recursive_count(m_p_head->m_p_parent) == m_size); }
#endif
c++/8/ext/pb_ds/detail/bin_search_tree_/find_fn_imps.hpp 0000644 00000011107 15201526705 0017036 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file bin_search_tree_/find_fn_imps.hpp
* Contains an implementation class for bin_search_tree_.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_const_iterator
PB_DS_CLASS_C_DEC::
lower_bound(key_const_reference r_key) const
{
node_pointer p_pot = m_p_head;
node_pointer p_nd = m_p_head->m_p_parent;
while (p_nd != 0)
if (Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key))
p_nd = p_nd->m_p_right;
else
{
p_pot = p_nd;
p_nd = p_nd->m_p_left;
}
return iterator(p_pot);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC::
lower_bound(key_const_reference r_key)
{
node_pointer p_pot = m_p_head;
node_pointer p_nd = m_p_head->m_p_parent;
while (p_nd != 0)
if (Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key))
p_nd = p_nd->m_p_right;
else
{
p_pot = p_nd;
p_nd = p_nd->m_p_left;
}
return iterator(p_pot);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_const_iterator
PB_DS_CLASS_C_DEC::
upper_bound(key_const_reference r_key) const
{
node_pointer p_pot = m_p_head;
node_pointer p_nd = m_p_head->m_p_parent;
while (p_nd != 0)
if (Cmp_Fn::operator()(r_key, PB_DS_V2F(p_nd->m_value)))
{
p_pot = p_nd;
p_nd = p_nd->m_p_left;
}
else
p_nd = p_nd->m_p_right;
return const_iterator(p_pot);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC::
upper_bound(key_const_reference r_key)
{
node_pointer p_pot = m_p_head;
node_pointer p_nd = m_p_head->m_p_parent;
while (p_nd != 0)
if (Cmp_Fn::operator()(r_key, PB_DS_V2F(p_nd->m_value)))
{
p_pot = p_nd;
p_nd = p_nd->m_p_left;
}
else
p_nd = p_nd->m_p_right;
return point_iterator(p_pot);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC::
find(key_const_reference r_key)
{
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
node_pointer p_pot = m_p_head;
node_pointer p_nd = m_p_head->m_p_parent;
while (p_nd != 0)
if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key))
{
p_pot = p_nd;
p_nd = p_nd->m_p_left;
}
else
p_nd = p_nd->m_p_right;
node_pointer ret = p_pot;
if (p_pot != m_p_head)
{
const bool __cmp = Cmp_Fn::operator()(r_key, PB_DS_V2F(p_pot->m_value));
if (__cmp)
ret = m_p_head;
}
return point_iterator(ret);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_const_iterator
PB_DS_CLASS_C_DEC::
find(key_const_reference r_key) const
{
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
node_pointer p_pot = m_p_head;
node_pointer p_nd = m_p_head->m_p_parent;
while (p_nd != 0)
if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key))
{
p_pot = p_nd;
p_nd = p_nd->m_p_left;
}
else
p_nd = p_nd->m_p_right;
node_pointer ret = p_pot;
if (p_pot != m_p_head)
{
const bool __cmp = Cmp_Fn::operator()(r_key, PB_DS_V2F(p_pot->m_value));
if (__cmp)
ret = m_p_head;
}
return point_const_iterator(ret);
}
c++/8/ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp 0000644 00000030203 15201526705 0017654 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file bin_search_tree_/bin_search_tree_.hpp
* Contains an implementation class for binary search tree.
*/
#include <ext/pb_ds/exception.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/eq_fn/eq_by_less.hpp>
#include <ext/pb_ds/detail/types_traits.hpp>
#include <ext/pb_ds/detail/cond_dealtor.hpp>
#include <ext/pb_ds/detail/type_utils.hpp>
#include <ext/pb_ds/detail/tree_trace_base.hpp>
#ifdef _GLIBCXX_DEBUG
#include <ext/pb_ds/detail/debug_map_base.hpp>
#endif
#include <utility>
#include <functional>
#include <debug/debug.h>
namespace __gnu_pbds
{
namespace detail
{
#ifdef PB_DS_DATA_TRUE_INDICATOR
#define PB_DS_BIN_TREE_NAME bin_search_tree_map
#endif
#ifdef PB_DS_DATA_FALSE_INDICATOR
#define PB_DS_BIN_TREE_NAME bin_search_tree_set
#endif
#define PB_DS_CLASS_T_DEC \
template<typename Key, typename Mapped, typename Cmp_Fn, \
typename Node_And_It_Traits, typename _Alloc>
#define PB_DS_CLASS_C_DEC \
PB_DS_BIN_TREE_NAME<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc>
#define PB_DS_BIN_TREE_TRAITS_BASE \
types_traits<Key, Mapped, _Alloc, false>
#ifdef _GLIBCXX_DEBUG
#define PB_DS_DEBUG_MAP_BASE_C_DEC \
debug_map_base<Key, eq_by_less<Key, Cmp_Fn>, \
typename _Alloc::template rebind<Key>::other::const_reference>
#endif
#ifdef PB_DS_TREE_TRACE
#define PB_DS_TREE_TRACE_BASE_C_DEC \
tree_trace_base<typename Node_And_It_Traits::node_const_iterator, \
typename Node_And_It_Traits::node_iterator, \
Cmp_Fn, true, _Alloc>
#endif
/*
* @brief Binary search tree (BST).
*
* This implementation uses an idea from the SGI STL (using a @a
* header node which is needed for efficient iteration).
*/
template<typename Key, typename Mapped, typename Cmp_Fn,
typename Node_And_It_Traits, typename _Alloc>
class PB_DS_BIN_TREE_NAME :
#ifdef _GLIBCXX_DEBUG
public PB_DS_DEBUG_MAP_BASE_C_DEC,
#endif
#ifdef PB_DS_TREE_TRACE
public PB_DS_TREE_TRACE_BASE_C_DEC,
#endif
public Cmp_Fn,
public PB_DS_BIN_TREE_TRAITS_BASE,
public Node_And_It_Traits::node_update
{
typedef Node_And_It_Traits traits_type;
protected:
typedef PB_DS_BIN_TREE_TRAITS_BASE traits_base;
typedef
typename _Alloc::template rebind<typename traits_type::node>::other
node_allocator;
typedef typename node_allocator::value_type node;
typedef typename node_allocator::pointer node_pointer;
typedef typename traits_type::null_node_update_pointer
null_node_update_pointer;
private:
typedef cond_dealtor<node, _Alloc> cond_dealtor_t;
#ifdef _GLIBCXX_DEBUG
typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base;
#endif
public:
typedef typename _Alloc::size_type size_type;
typedef typename _Alloc::difference_type difference_type;
typedef typename traits_base::key_type key_type;
typedef typename traits_base::key_pointer key_pointer;
typedef typename traits_base::key_const_pointer key_const_pointer;
typedef typename traits_base::key_reference key_reference;
typedef typename traits_base::key_const_reference key_const_reference;
#ifdef PB_DS_DATA_TRUE_INDICATOR
typedef typename traits_base::mapped_type mapped_type;
typedef typename traits_base::mapped_pointer mapped_pointer;
typedef typename traits_base::mapped_const_pointer mapped_const_pointer;
typedef typename traits_base::mapped_reference mapped_reference;
typedef typename traits_base::mapped_const_reference mapped_const_reference;
#endif
typedef typename traits_base::value_type value_type;
typedef typename traits_base::pointer pointer;
typedef typename traits_base::const_pointer const_pointer;
typedef typename traits_base::reference reference;
typedef typename traits_base::const_reference const_reference;
typedef typename traits_type::point_const_iterator point_const_iterator;
typedef point_const_iterator const_iterator;
typedef typename traits_type::point_iterator point_iterator;
typedef point_iterator iterator;
typedef typename traits_type::const_reverse_iterator const_reverse_iterator;
typedef typename traits_type::reverse_iterator reverse_iterator;
typedef typename traits_type::node_const_iterator node_const_iterator;
typedef typename traits_type::node_iterator node_iterator;
typedef typename traits_type::node_update node_update;
typedef Cmp_Fn cmp_fn;
typedef _Alloc allocator_type;
PB_DS_BIN_TREE_NAME();
PB_DS_BIN_TREE_NAME(const Cmp_Fn&);
PB_DS_BIN_TREE_NAME(const Cmp_Fn&, const node_update&);
PB_DS_BIN_TREE_NAME(const PB_DS_CLASS_C_DEC&);
void
swap(PB_DS_CLASS_C_DEC&);
~PB_DS_BIN_TREE_NAME();
inline bool
empty() const;
inline size_type
size() const;
inline size_type
max_size() const;
Cmp_Fn&
get_cmp_fn();
const Cmp_Fn&
get_cmp_fn() const;
inline point_iterator
lower_bound(key_const_reference);
inline point_const_iterator
lower_bound(key_const_reference) const;
inline point_iterator
upper_bound(key_const_reference);
inline point_const_iterator
upper_bound(key_const_reference) const;
inline point_iterator
find(key_const_reference);
inline point_const_iterator
find(key_const_reference) const;
inline iterator
begin();
inline const_iterator
begin() const;
inline iterator
end();
inline const_iterator
end() const;
inline reverse_iterator
rbegin();
inline const_reverse_iterator
rbegin() const;
inline reverse_iterator
rend();
inline const_reverse_iterator
rend() const;
/// Returns a const node_iterator corresponding to the node at the
/// root of the tree.
inline node_const_iterator
node_begin() const;
/// Returns a node_iterator corresponding to the node at the
/// root of the tree.
inline node_iterator
node_begin();
/// Returns a const node_iterator corresponding to a node just
/// after a leaf of the tree.
inline node_const_iterator
node_end() const;
/// Returns a node_iterator corresponding to a node just
/// after a leaf of the tree.
inline node_iterator
node_end();
void
clear();
protected:
void
value_swap(PB_DS_CLASS_C_DEC&);
void
initialize_min_max();
inline iterator
insert_imp_empty(const_reference);
inline iterator
insert_leaf_new(const_reference, node_pointer, bool);
inline node_pointer
get_new_node_for_leaf_insert(const_reference, false_type);
inline node_pointer
get_new_node_for_leaf_insert(const_reference, true_type);
inline void
actual_erase_node(node_pointer);
inline std::pair<node_pointer, bool>
erase(node_pointer);
inline void
update_min_max_for_erased_node(node_pointer);
static void
clear_imp(node_pointer);
inline std::pair<point_iterator, bool>
insert_leaf(const_reference);
inline void
rotate_left(node_pointer);
inline void
rotate_right(node_pointer);
inline void
rotate_parent(node_pointer);
inline void
apply_update(node_pointer, null_node_update_pointer);
template<typename Node_Update_>
inline void
apply_update(node_pointer, Node_Update_*);
inline void
update_to_top(node_pointer, null_node_update_pointer);
template<typename Node_Update_>
inline void
update_to_top(node_pointer, Node_Update_*);
bool
join_prep(PB_DS_CLASS_C_DEC&);
void
join_finish(PB_DS_CLASS_C_DEC&);
bool
split_prep(key_const_reference, PB_DS_CLASS_C_DEC&);
void
split_finish(PB_DS_CLASS_C_DEC&);
size_type
recursive_count(node_pointer) const;
#ifdef _GLIBCXX_DEBUG
void
assert_valid(const char*, int) const;
void
structure_only_assert_valid(const char*, int) const;
void
assert_node_consistent(const node_pointer, const char*, int) const;
#endif
private:
#ifdef _GLIBCXX_DEBUG
void
assert_iterators(const char*, int) const;
void
assert_consistent_with_debug_base(const char*, int) const;
void
assert_node_consistent_with_left(const node_pointer,
const char*, int) const;
void
assert_node_consistent_with_right(const node_pointer,
const char*, int) const;
void
assert_consistent_with_debug_base(const node_pointer,
const char*, int) const;
void
assert_min(const char*, int) const;
void
assert_min_imp(const node_pointer, const char*, int) const;
void
assert_max(const char*, int) const;
void
assert_max_imp(const node_pointer, const char*, int) const;
void
assert_size(const char*, int) const;
typedef std::pair<const_pointer, const_pointer> node_consistent_t;
node_consistent_t
assert_node_consistent_(const node_pointer, const char*, int) const;
#endif
void
initialize();
node_pointer
recursive_copy_node(const node_pointer);
protected:
node_pointer m_p_head;
size_type m_size;
static node_allocator s_node_allocator;
};
#define PB_DS_STRUCT_ONLY_ASSERT_VALID(X) \
_GLIBCXX_DEBUG_ONLY(X.structure_only_assert_valid(__FILE__, __LINE__);)
#define PB_DS_ASSERT_NODE_CONSISTENT(_Node) \
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(_Node, __FILE__, __LINE__);)
#include <ext/pb_ds/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/bin_search_tree_/iterators_fn_imps.hpp>
#include <ext/pb_ds/detail/bin_search_tree_/debug_fn_imps.hpp>
#include <ext/pb_ds/detail/bin_search_tree_/insert_fn_imps.hpp>
#include <ext/pb_ds/detail/bin_search_tree_/erase_fn_imps.hpp>
#include <ext/pb_ds/detail/bin_search_tree_/find_fn_imps.hpp>
#include <ext/pb_ds/detail/bin_search_tree_/info_fn_imps.hpp>
#include <ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp>
#include <ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp>
#include <ext/pb_ds/detail/bin_search_tree_/policy_access_fn_imps.hpp>
#undef PB_DS_ASSERT_NODE_CONSISTENT
#undef PB_DS_STRUCT_ONLY_ASSERT_VALID
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_BIN_TREE_NAME
#undef PB_DS_BIN_TREE_TRAITS_BASE
#undef PB_DS_DEBUG_MAP_BASE_C_DEC
#ifdef PB_DS_TREE_TRACE
#undef PB_DS_TREE_TRACE_BASE_C_DEC
#endif
} // namespace detail
} // namespace __gnu_pbds
c++/8/ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp 0000644 00000010136 15201526705 0017415 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file bin_search_tree_/rotate_fn_imps.hpp
* Contains imps for rotating nodes.
*/
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
rotate_left(node_pointer p_x)
{
node_pointer p_y = p_x->m_p_right;
p_x->m_p_right = p_y->m_p_left;
if (p_y->m_p_left != 0)
p_y->m_p_left->m_p_parent = p_x;
p_y->m_p_parent = p_x->m_p_parent;
if (p_x == m_p_head->m_p_parent)
m_p_head->m_p_parent = p_y;
else if (p_x == p_x->m_p_parent->m_p_left)
p_x->m_p_parent->m_p_left = p_y;
else
p_x->m_p_parent->m_p_right = p_y;
p_y->m_p_left = p_x;
p_x->m_p_parent = p_y;
PB_DS_ASSERT_NODE_CONSISTENT(p_x)
PB_DS_ASSERT_NODE_CONSISTENT(p_y)
apply_update(p_x, (node_update* )this);
apply_update(p_x->m_p_parent, (node_update* )this);
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
rotate_right(node_pointer p_x)
{
node_pointer p_y = p_x->m_p_left;
p_x->m_p_left = p_y->m_p_right;
if (p_y->m_p_right != 0)
p_y->m_p_right->m_p_parent = p_x;
p_y->m_p_parent = p_x->m_p_parent;
if (p_x == m_p_head->m_p_parent)
m_p_head->m_p_parent = p_y;
else if (p_x == p_x->m_p_parent->m_p_right)
p_x->m_p_parent->m_p_right = p_y;
else
p_x->m_p_parent->m_p_left = p_y;
p_y->m_p_right = p_x;
p_x->m_p_parent = p_y;
PB_DS_ASSERT_NODE_CONSISTENT(p_x)
PB_DS_ASSERT_NODE_CONSISTENT(p_y)
apply_update(p_x, (node_update* )this);
apply_update(p_x->m_p_parent, (node_update* )this);
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
rotate_parent(node_pointer p_nd)
{
node_pointer p_parent = p_nd->m_p_parent;
if (p_nd == p_parent->m_p_left)
rotate_right(p_parent);
else
rotate_left(p_parent);
_GLIBCXX_DEBUG_ASSERT(p_parent->m_p_parent = p_nd);
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_left == p_parent ||
p_nd->m_p_right == p_parent);
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
apply_update(node_pointer /*p_nd*/, null_node_update_pointer /*p_update*/)
{ }
PB_DS_CLASS_T_DEC
template<typename Node_Update_>
inline void
PB_DS_CLASS_C_DEC::
apply_update(node_pointer p_nd, Node_Update_* /*p_update*/)
{
node_update::operator()(node_iterator(p_nd),
node_const_iterator(static_cast<node_pointer>(0)));
}
PB_DS_CLASS_T_DEC
template<typename Node_Update_>
inline void
PB_DS_CLASS_C_DEC::
update_to_top(node_pointer p_nd, Node_Update_* p_update)
{
while (p_nd != m_p_head)
{
apply_update(p_nd, p_update);
p_nd = p_nd->m_p_parent;
}
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
update_to_top(node_pointer /*p_nd*/, null_node_update_pointer /*p_update*/)
{ }
c++/8/ext/pb_ds/detail/bin_search_tree_/point_iterators.hpp 0000644 00000021401 15201526705 0017626 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file bin_search_tree_/point_iterators.hpp
* Contains an implementation class for bin_search_tree_.
*/
#ifndef PB_DS_BIN_SEARCH_TREE_FIND_ITERATORS_HPP
#define PB_DS_BIN_SEARCH_TREE_FIND_ITERATORS_HPP
#include <ext/pb_ds/tag_and_trait.hpp>
#include <debug/debug.h>
namespace __gnu_pbds
{
namespace detail
{
#define PB_DS_TREE_CONST_IT_C_DEC \
bin_search_tree_const_it_< \
Node_Pointer, \
Value_Type, \
Pointer, \
Const_Pointer, \
Reference, \
Const_Reference, \
Is_Forward_Iterator, \
_Alloc>
#define PB_DS_TREE_CONST_ODIR_IT_C_DEC \
bin_search_tree_const_it_< \
Node_Pointer, \
Value_Type, \
Pointer, \
Const_Pointer, \
Reference, \
Const_Reference, \
!Is_Forward_Iterator, \
_Alloc>
#define PB_DS_TREE_IT_C_DEC \
bin_search_tree_it_< \
Node_Pointer, \
Value_Type, \
Pointer, \
Const_Pointer, \
Reference, \
Const_Reference, \
Is_Forward_Iterator, \
_Alloc>
#define PB_DS_TREE_ODIR_IT_C_DEC \
bin_search_tree_it_< \
Node_Pointer, \
Value_Type, \
Pointer, \
Const_Pointer, \
Reference, \
Const_Reference, \
!Is_Forward_Iterator, \
_Alloc>
/// Const iterator.
template<typename Node_Pointer,
typename Value_Type,
typename Pointer,
typename Const_Pointer,
typename Reference,
typename Const_Reference,
bool Is_Forward_Iterator,
typename _Alloc>
class bin_search_tree_const_it_
{
public:
typedef std::bidirectional_iterator_tag iterator_category;
typedef typename _Alloc::difference_type difference_type;
typedef Value_Type value_type;
typedef Pointer pointer;
typedef Const_Pointer const_pointer;
typedef Reference reference;
typedef Const_Reference const_reference;
inline
bin_search_tree_const_it_(const Node_Pointer p_nd = 0)
: m_p_nd(const_cast<Node_Pointer>(p_nd))
{ }
inline
bin_search_tree_const_it_(const PB_DS_TREE_CONST_ODIR_IT_C_DEC& other)
: m_p_nd(other.m_p_nd)
{ }
inline
PB_DS_TREE_CONST_IT_C_DEC&
operator=(const PB_DS_TREE_CONST_IT_C_DEC& other)
{
m_p_nd = other.m_p_nd;
return *this;
}
inline
PB_DS_TREE_CONST_IT_C_DEC&
operator=(const PB_DS_TREE_CONST_ODIR_IT_C_DEC& other)
{
m_p_nd = other.m_p_nd;
return *this;
}
inline const_pointer
operator->() const
{
_GLIBCXX_DEBUG_ASSERT(m_p_nd != 0);
return &m_p_nd->m_value;
}
inline const_reference
operator*() const
{
_GLIBCXX_DEBUG_ASSERT(m_p_nd != 0);
return m_p_nd->m_value;
}
inline bool
operator==(const PB_DS_TREE_CONST_IT_C_DEC & other) const
{ return m_p_nd == other.m_p_nd; }
inline bool
operator==(const PB_DS_TREE_CONST_ODIR_IT_C_DEC & other) const
{ return m_p_nd == other.m_p_nd; }
inline bool
operator!=(const PB_DS_TREE_CONST_IT_C_DEC& other) const
{ return m_p_nd != other.m_p_nd; }
inline bool
operator!=(const PB_DS_TREE_CONST_ODIR_IT_C_DEC& other) const
{ return m_p_nd != other.m_p_nd; }
inline PB_DS_TREE_CONST_IT_C_DEC&
operator++()
{
_GLIBCXX_DEBUG_ASSERT(m_p_nd != 0);
inc(integral_constant<int,Is_Forward_Iterator>());
return *this;
}
inline PB_DS_TREE_CONST_IT_C_DEC
operator++(int)
{
PB_DS_TREE_CONST_IT_C_DEC ret_it(m_p_nd);
operator++();
return ret_it;
}
inline PB_DS_TREE_CONST_IT_C_DEC&
operator--()
{
dec(integral_constant<int,Is_Forward_Iterator>());
return *this;
}
inline PB_DS_TREE_CONST_IT_C_DEC
operator--(int)
{
PB_DS_TREE_CONST_IT_C_DEC ret_it(m_p_nd);
operator--();
return ret_it;
}
protected:
inline void
inc(false_type)
{ dec(true_type()); }
void
inc(true_type)
{
if (m_p_nd->special()&&
m_p_nd->m_p_parent->m_p_parent == m_p_nd)
{
m_p_nd = m_p_nd->m_p_left;
return;
}
if (m_p_nd->m_p_right != 0)
{
m_p_nd = m_p_nd->m_p_right;
while (m_p_nd->m_p_left != 0)
m_p_nd = m_p_nd->m_p_left;
return;
}
Node_Pointer p_y = m_p_nd->m_p_parent;
while (m_p_nd == p_y->m_p_right)
{
m_p_nd = p_y;
p_y = p_y->m_p_parent;
}
if (m_p_nd->m_p_right != p_y)
m_p_nd = p_y;
}
inline void
dec(false_type)
{ inc(true_type()); }
void
dec(true_type)
{
if (m_p_nd->special() && m_p_nd->m_p_parent->m_p_parent == m_p_nd)
{
m_p_nd = m_p_nd->m_p_right;
return;
}
if (m_p_nd->m_p_left != 0)
{
Node_Pointer p_y = m_p_nd->m_p_left;
while (p_y->m_p_right != 0)
p_y = p_y->m_p_right;
m_p_nd = p_y;
return;
}
Node_Pointer p_y = m_p_nd->m_p_parent;
while (m_p_nd == p_y->m_p_left)
{
m_p_nd = p_y;
p_y = p_y->m_p_parent;
}
if (m_p_nd->m_p_left != p_y)
m_p_nd = p_y;
}
public:
Node_Pointer m_p_nd;
};
/// Iterator.
template<typename Node_Pointer,
typename Value_Type,
typename Pointer,
typename Const_Pointer,
typename Reference,
typename Const_Reference,
bool Is_Forward_Iterator,
typename _Alloc>
class bin_search_tree_it_ : public PB_DS_TREE_CONST_IT_C_DEC
{
public:
inline
bin_search_tree_it_(const Node_Pointer p_nd = 0)
: PB_DS_TREE_CONST_IT_C_DEC((Node_Pointer)p_nd)
{ }
inline
bin_search_tree_it_(const PB_DS_TREE_ODIR_IT_C_DEC& other)
: PB_DS_TREE_CONST_IT_C_DEC(other.m_p_nd)
{ }
inline
PB_DS_TREE_IT_C_DEC&
operator=(const PB_DS_TREE_IT_C_DEC& other)
{
base_it_type::m_p_nd = other.m_p_nd;
return *this;
}
inline
PB_DS_TREE_IT_C_DEC&
operator=(const PB_DS_TREE_ODIR_IT_C_DEC& other)
{
base_it_type::m_p_nd = other.m_p_nd;
return *this;
}
inline typename PB_DS_TREE_CONST_IT_C_DEC::pointer
operator->() const
{
_GLIBCXX_DEBUG_ASSERT(base_it_type::m_p_nd != 0);
return &base_it_type::m_p_nd->m_value;
}
inline typename PB_DS_TREE_CONST_IT_C_DEC::reference
operator*() const
{
_GLIBCXX_DEBUG_ASSERT(base_it_type::m_p_nd != 0);
return base_it_type::m_p_nd->m_value;
}
inline PB_DS_TREE_IT_C_DEC&
operator++()
{
PB_DS_TREE_CONST_IT_C_DEC:: operator++();
return *this;
}
inline PB_DS_TREE_IT_C_DEC
operator++(int)
{
PB_DS_TREE_IT_C_DEC ret_it(base_it_type::m_p_nd);
operator++();
return ret_it;
}
inline PB_DS_TREE_IT_C_DEC&
operator--()
{
PB_DS_TREE_CONST_IT_C_DEC:: operator--();
return *this;
}
inline PB_DS_TREE_IT_C_DEC
operator--(int)
{
PB_DS_TREE_IT_C_DEC ret_it(base_it_type::m_p_nd);
operator--();
return ret_it;
}
protected:
typedef PB_DS_TREE_CONST_IT_C_DEC base_it_type;
};
#undef PB_DS_TREE_CONST_IT_C_DEC
#undef PB_DS_TREE_CONST_ODIR_IT_C_DEC
#undef PB_DS_TREE_IT_C_DEC
#undef PB_DS_TREE_ODIR_IT_C_DEC
} // namespace detail
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp 0000644 00000007647 15201526705 0020306 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file bin_search_tree_/split_join_fn_imps.hpp
* Contains an implementation class for bin_search_tree_.
*/
PB_DS_CLASS_T_DEC
bool
PB_DS_CLASS_C_DEC::
join_prep(PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
if (other.m_size == 0)
return false;
if (m_size == 0)
{
value_swap(other);
return false;
}
const bool greater =
Cmp_Fn::operator()(PB_DS_V2F(m_p_head->m_p_right->m_value),
PB_DS_V2F(other.m_p_head->m_p_left->m_value));
const bool lesser =
Cmp_Fn::operator()(PB_DS_V2F(other.m_p_head->m_p_right->m_value),
PB_DS_V2F(m_p_head->m_p_left->m_value));
if (!greater && !lesser)
__throw_join_error();
if (lesser)
value_swap(other);
m_size += other.m_size;
_GLIBCXX_DEBUG_ONLY(debug_base::join(other);)
return true;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
join_finish(PB_DS_CLASS_C_DEC& other)
{
initialize_min_max();
other.initialize();
}
PB_DS_CLASS_T_DEC
bool
PB_DS_CLASS_C_DEC::
split_prep(key_const_reference r_key, PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
other.clear();
if (m_size == 0)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
return false;
}
if (Cmp_Fn::operator()(r_key, PB_DS_V2F(m_p_head->m_p_left->m_value)))
{
value_swap(other);
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
return false;
}
if (!Cmp_Fn::operator()(r_key, PB_DS_V2F(m_p_head->m_p_right->m_value)))
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
return false;
}
if (m_size == 1)
{
value_swap(other);
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
return false;
}
_GLIBCXX_DEBUG_ONLY(debug_base::split(r_key,(Cmp_Fn& )(*this), other);)
return true;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
split_finish(PB_DS_CLASS_C_DEC& other)
{
other.initialize_min_max();
other.m_size = std::distance(other.begin(), other.end());
m_size -= other.m_size;
initialize_min_max();
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
recursive_count(node_pointer p) const
{
if (p == 0)
return 0;
return 1 + recursive_count(p->m_p_left) + recursive_count(p->m_p_right);
}
c++/8/ext/pb_ds/detail/bin_search_tree_/insert_fn_imps.hpp 0000644 00000012551 15201526705 0017426 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file bin_search_tree_/insert_fn_imps.hpp
* Contains an implementation class for bin_search_tree_.
*/
PB_DS_CLASS_T_DEC
inline std::pair<typename PB_DS_CLASS_C_DEC::point_iterator, bool>
PB_DS_CLASS_C_DEC::
insert_leaf(const_reference r_value)
{
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
if (m_size == 0)
return std::make_pair(insert_imp_empty(r_value),
true);
node_pointer p_nd = m_p_head->m_p_parent;
node_pointer p_pot = m_p_head;
while (p_nd != 0)
if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value),
PB_DS_V2F(r_value)))
{
p_pot = p_nd;
p_nd = p_nd->m_p_left;
}
else
p_nd = p_nd->m_p_right;
if (p_pot == m_p_head)
return std::make_pair(insert_leaf_new(r_value, m_p_head->m_p_right, false),
true);
if (!Cmp_Fn::operator()(PB_DS_V2F(r_value),
PB_DS_V2F(p_pot->m_value)))
{
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
PB_DS_CHECK_KEY_EXISTS(PB_DS_V2F(r_value))
return std::make_pair(p_pot, false);
}
PB_DS_CHECK_KEY_DOES_NOT_EXIST(PB_DS_V2F(r_value))
p_nd = p_pot->m_p_left;
if (p_nd == 0)
return std::make_pair(insert_leaf_new(r_value, p_pot, true),
true);
while (p_nd->m_p_right != 0)
p_nd = p_nd->m_p_right;
return std::make_pair(insert_leaf_new(r_value, p_nd, false),
true);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
insert_leaf_new(const_reference r_value, node_pointer p_nd, bool left_nd)
{
node_pointer p_new_nd =
get_new_node_for_leaf_insert(r_value,
traits_base::m_no_throw_copies_indicator);
if (left_nd)
{
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_left == 0);
_GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(r_value),
PB_DS_V2F(p_nd->m_value)));
p_nd->m_p_left = p_new_nd;
if (m_p_head->m_p_left == p_nd)
m_p_head->m_p_left = p_new_nd;
}
else
{
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_right == 0);
_GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value),
PB_DS_V2F(r_value)));
p_nd->m_p_right = p_new_nd;
if (m_p_head->m_p_right == p_nd)
m_p_head->m_p_right = p_new_nd;
}
p_new_nd->m_p_parent = p_nd;
p_new_nd->m_p_left = p_new_nd->m_p_right = 0;
PB_DS_ASSERT_NODE_CONSISTENT(p_nd)
update_to_top(p_new_nd, (node_update* )this);
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_value));)
return iterator(p_new_nd);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
insert_imp_empty(const_reference r_value)
{
node_pointer p_new_node =
get_new_node_for_leaf_insert(r_value, traits_base::m_no_throw_copies_indicator);
m_p_head->m_p_left = m_p_head->m_p_right =
m_p_head->m_p_parent = p_new_node;
p_new_node->m_p_parent = m_p_head;
p_new_node->m_p_left = p_new_node->m_p_right = 0;
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_value));)
update_to_top(m_p_head->m_p_parent, (node_update*)this);
return iterator(p_new_node);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
get_new_node_for_leaf_insert(const_reference r_val, false_type)
{
node_pointer p_new_nd = s_node_allocator.allocate(1);
cond_dealtor_t cond(p_new_nd);
new (const_cast<void* >(static_cast<const void* >(&p_new_nd->m_value)))
typename node::value_type(r_val);
cond.set_no_action();
p_new_nd->m_p_left = p_new_nd->m_p_right = 0;
++m_size;
return p_new_nd;
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
get_new_node_for_leaf_insert(const_reference r_val, true_type)
{
node_pointer p_new_nd = s_node_allocator.allocate(1);
new (const_cast<void* >(static_cast<const void* >(&p_new_nd->m_value)))
typename node::value_type(r_val);
p_new_nd->m_p_left = p_new_nd->m_p_right = 0;
++m_size;
return p_new_nd;
}
c++/8/ext/pb_ds/detail/bin_search_tree_/erase_fn_imps.hpp 0000644 00000005547 15201526705 0017230 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file bin_search_tree_/erase_fn_imps.hpp
* Contains an implementation class for bin_search_tree_.
*/
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
actual_erase_node(node_pointer p_z)
{
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
--m_size;
_GLIBCXX_DEBUG_ONLY(debug_base::erase_existing(PB_DS_V2F(p_z->m_value));)
p_z->~node();
s_node_allocator.deallocate(p_z, 1);
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
update_min_max_for_erased_node(node_pointer p_z)
{
if (m_size == 1)
{
m_p_head->m_p_left = m_p_head->m_p_right = m_p_head;
return;
}
if (m_p_head->m_p_left == p_z)
{
iterator it(p_z);
++it;
m_p_head->m_p_left = it.m_p_nd;
}
else if (m_p_head->m_p_right == p_z)
{
iterator it(p_z);
--it;
m_p_head->m_p_right = it.m_p_nd;
}
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
clear()
{
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
clear_imp(m_p_head->m_p_parent);
m_size = 0;
initialize();
_GLIBCXX_DEBUG_ONLY(debug_base::clear();)
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
clear_imp(node_pointer p_nd)
{
if (p_nd == 0)
return;
clear_imp(p_nd->m_p_left);
clear_imp(p_nd->m_p_right);
p_nd->~node();
s_node_allocator.deallocate(p_nd, 1);
}
c++/8/ext/pb_ds/detail/bin_search_tree_/r_erase_fn_imps.hpp 0000644 00000005535 15201526705 0017546 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file bin_search_tree_/r_erase_fn_imps.hpp
* Contains an implementation class for bin_search_tree_.
*/
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
actual_erase_node(node_pointer p_z)
{
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
--m_size;
_GLIBCXX_DEBUG_ONLY(erase_existing(PB_DS_V2F(p_z->m_value));)
p_z->~node();
s_node_allocator.deallocate(p_z, 1);
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
update_min_max_for_erased_node(node_pointer p_z)
{
if (m_size == 1)
{
m_p_head->m_p_left = m_p_head->m_p_right = m_p_head;
return;
}
if (m_p_head->m_p_left == p_z)
{
iterator it(p_z);
++it;
m_p_head->m_p_left = it.m_p_nd;
}
else if (m_p_head->m_p_right == p_z)
{
iterator it(p_z);
--it;
m_p_head->m_p_right = it.m_p_nd;
}
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
clear()
{
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
clear_imp(m_p_head->m_p_parent);
m_size = 0;
initialize();
_GLIBCXX_DEBUG_ONLY(debug_base::clear();)
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
clear_imp(node_pointer p_nd)
{
if (p_nd == 0)
return;
clear_imp(p_nd->m_p_left);
clear_imp(p_nd->m_p_right);
p_nd->~Node();
s_node_allocator.deallocate(p_nd, 1);
}
c++/8/ext/pb_ds/detail/bin_search_tree_/traits.hpp 0000644 00000014352 15201526705 0015716 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file bin_search_tree_/traits.hpp
* Contains an implementation for bin_search_tree_.
*/
#ifndef PB_DS_BIN_SEARCH_TREE_NODE_AND_IT_TRAITS_HPP
#define PB_DS_BIN_SEARCH_TREE_NODE_AND_IT_TRAITS_HPP
#include <ext/pb_ds/detail/bin_search_tree_/point_iterators.hpp>
#include <ext/pb_ds/detail/bin_search_tree_/node_iterators.hpp>
namespace __gnu_pbds
{
namespace detail
{
/// Binary search tree traits, primary template
/// @ingroup traits
template<typename Key,
typename Mapped,
class Cmp_Fn,
template<typename Node_CItr,
class Node_Itr,
class _Cmp_Fn,
typename _Alloc>
class Node_Update,
class Node,
typename _Alloc>
struct bin_search_tree_traits
{
private:
typedef types_traits<Key, Mapped, _Alloc, false> type_traits;
public:
typedef Node node;
typedef
bin_search_tree_const_it_<
typename _Alloc::template rebind<
node>::other::pointer,
typename type_traits::value_type,
typename type_traits::pointer,
typename type_traits::const_pointer,
typename type_traits::reference,
typename type_traits::const_reference,
true,
_Alloc>
point_const_iterator;
typedef
bin_search_tree_it_<
typename _Alloc::template rebind<
node>::other::pointer,
typename type_traits::value_type,
typename type_traits::pointer,
typename type_traits::const_pointer,
typename type_traits::reference,
typename type_traits::const_reference,
true,
_Alloc>
point_iterator;
typedef
bin_search_tree_const_it_<
typename _Alloc::template rebind<
node>::other::pointer,
typename type_traits::value_type,
typename type_traits::pointer,
typename type_traits::const_pointer,
typename type_traits::reference,
typename type_traits::const_reference,
false,
_Alloc>
const_reverse_iterator;
typedef
bin_search_tree_it_<
typename _Alloc::template rebind<
node>::other::pointer,
typename type_traits::value_type,
typename type_traits::pointer,
typename type_traits::const_pointer,
typename type_traits::reference,
typename type_traits::const_reference,
false,
_Alloc>
reverse_iterator;
/// This is an iterator to an iterator: it iterates over nodes,
/// and de-referencing it returns one of the tree's iterators.
typedef
bin_search_tree_const_node_it_<
Node,
point_const_iterator,
point_iterator,
_Alloc>
node_const_iterator;
typedef
bin_search_tree_node_it_<
Node,
point_const_iterator,
point_iterator,
_Alloc>
node_iterator;
typedef
Node_Update<
node_const_iterator,
node_iterator,
Cmp_Fn,
_Alloc>
node_update;
typedef
__gnu_pbds::null_node_update<
node_const_iterator,
node_iterator,
Cmp_Fn,
_Alloc>*
null_node_update_pointer;
};
/// Specialization.
/// @ingroup traits
template<typename Key,
class Cmp_Fn,
template<typename Node_CItr,
class Node_Itr,
class _Cmp_Fn,
typename _Alloc>
class Node_Update,
class Node,
typename _Alloc>
struct
bin_search_tree_traits<Key, null_type, Cmp_Fn, Node_Update, Node, _Alloc>
{
private:
typedef types_traits<Key, null_type, _Alloc, false> type_traits;
public:
typedef Node node;
typedef
bin_search_tree_const_it_<
typename _Alloc::template rebind<
node>::other::pointer,
typename type_traits::value_type,
typename type_traits::pointer,
typename type_traits::const_pointer,
typename type_traits::reference,
typename type_traits::const_reference,
true,
_Alloc>
point_const_iterator;
typedef point_const_iterator point_iterator;
typedef
bin_search_tree_const_it_<
typename _Alloc::template rebind<
node>::other::pointer,
typename type_traits::value_type,
typename type_traits::pointer,
typename type_traits::const_pointer,
typename type_traits::reference,
typename type_traits::const_reference,
false,
_Alloc>
const_reverse_iterator;
typedef const_reverse_iterator reverse_iterator;
/// This is an iterator to an iterator: it iterates over nodes,
/// and de-referencing it returns one of the tree's iterators.
typedef
bin_search_tree_const_node_it_<
Node,
point_const_iterator,
point_iterator,
_Alloc>
node_const_iterator;
typedef node_const_iterator node_iterator;
typedef
Node_Update<node_const_iterator, node_iterator, Cmp_Fn, _Alloc>
node_update;
typedef
__gnu_pbds::null_node_update<
node_const_iterator,
node_iterator,
Cmp_Fn,
_Alloc>*
null_node_update_pointer;
};
} // namespace detail
} // namespace __gnu_pbds
#endif // #ifndef PB_DS_BIN_SEARCH_TREE_NODE_AND_IT_TRAITS_HPP
c++/8/ext/pb_ds/detail/bin_search_tree_/policy_access_fn_imps.hpp 0000644 00000003561 15201526705 0020743 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file bin_search_tree_/policy_access_fn_imps.hpp
* Contains an implementation class for bin_search_tree_.
*/
PB_DS_CLASS_T_DEC
Cmp_Fn&
PB_DS_CLASS_C_DEC::
get_cmp_fn()
{ return (*this); }
PB_DS_CLASS_T_DEC
const Cmp_Fn&
PB_DS_CLASS_C_DEC::
get_cmp_fn() const
{ return (*this); }
c++/8/ext/pb_ds/detail/bin_search_tree_/node_iterators.hpp 0000644 00000013555 15201526705 0017435 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file bin_search_tree_/node_iterators.hpp
* Contains an implementation class for bin_search_tree_.
*/
#ifndef PB_DS_BIN_SEARCH_TREE_NODE_ITERATORS_HPP
#define PB_DS_BIN_SEARCH_TREE_NODE_ITERATORS_HPP
#include <ext/pb_ds/tag_and_trait.hpp>
namespace __gnu_pbds
{
namespace detail
{
#define PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC \
bin_search_tree_const_node_it_<Node, Const_Iterator, Iterator, _Alloc>
/// Const node iterator.
template<typename Node,
class Const_Iterator,
class Iterator,
typename _Alloc>
class bin_search_tree_const_node_it_
{
private:
typedef
typename _Alloc::template rebind<
Node>::other::pointer
node_pointer;
public:
/// Category.
typedef trivial_iterator_tag iterator_category;
/// Difference type.
typedef trivial_iterator_difference_type difference_type;
/// Iterator's value type.
typedef Const_Iterator value_type;
/// Iterator's reference type.
typedef Const_Iterator reference;
/// Iterator's __const reference type.
typedef Const_Iterator const_reference;
/// Metadata type.
typedef typename Node::metadata_type metadata_type;
/// Const metadata reference type.
typedef
typename _Alloc::template rebind<metadata_type>::other::const_reference
metadata_const_reference;
bin_search_tree_const_node_it_(const node_pointer p_nd = 0)
: m_p_nd(const_cast<node_pointer>(p_nd))
{ }
/// Access.
const_reference
operator*() const
{ return Const_Iterator(m_p_nd); }
/// Metadata access.
metadata_const_reference
get_metadata() const
{ return m_p_nd->get_metadata(); }
/// Returns the __const node iterator associated with the left node.
PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC
get_l_child() const
{ return PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC(m_p_nd->m_p_left); }
/// Returns the __const node iterator associated with the right node.
PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC
get_r_child() const
{ return PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC(m_p_nd->m_p_right); }
/// Compares to a different iterator object.
bool
operator==(const PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC& other) const
{ return m_p_nd == other.m_p_nd; }
/// Compares (negatively) to a different iterator object.
bool
operator!=(const PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC& other) const
{ return m_p_nd != other.m_p_nd; }
node_pointer m_p_nd;
};
#define PB_DS_TREE_NODE_ITERATOR_CLASS_C_DEC \
bin_search_tree_node_it_<Node, Const_Iterator, Iterator, _Alloc>
/// Node iterator.
template<typename Node,
class Const_Iterator,
class Iterator,
typename _Alloc>
class bin_search_tree_node_it_
: public PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC
{
private:
typedef
typename _Alloc::template rebind<
Node>::other::pointer
node_pointer;
public:
/// Iterator's value type.
typedef Iterator value_type;
/// Iterator's reference type.
typedef Iterator reference;
/// Iterator's __const reference type.
typedef Iterator const_reference;
inline
bin_search_tree_node_it_(const node_pointer p_nd = 0)
: PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC(const_cast<node_pointer>(p_nd))
{ }
/// Access.
Iterator
operator*() const
{ return Iterator(PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC::m_p_nd); }
/// Returns the node iterator associated with the left node.
PB_DS_TREE_NODE_ITERATOR_CLASS_C_DEC
get_l_child() const
{
return PB_DS_TREE_NODE_ITERATOR_CLASS_C_DEC(
PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC::m_p_nd->m_p_left);
}
/// Returns the node iterator associated with the right node.
PB_DS_TREE_NODE_ITERATOR_CLASS_C_DEC
get_r_child() const
{
return PB_DS_TREE_NODE_ITERATOR_CLASS_C_DEC(
PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC::m_p_nd->m_p_right);
}
};
#undef PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC
#undef PB_DS_TREE_NODE_ITERATOR_CLASS_C_DEC
} // namespace detail
} // namespace __gnu_pbds
#endif // #ifndef PB_DS_BIN_SEARCH_TREE_NODE_ITERATORS_HPP
c++/8/ext/pb_ds/detail/type_utils.hpp 0000644 00000010337 15201526705 0013335 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file detail/type_utils.hpp
* Contains utilities for handnling types. All of these classes are based on
* Modern C++ by Andrei Alxandrescu.
*/
#ifndef PB_DS_TYPE_UTILS_HPP
#define PB_DS_TYPE_UTILS_HPP
#include <cstddef>
#include <utility>
#include <tr1/type_traits>
#include <ext/type_traits.h>
#include <ext/numeric_traits.h>
namespace __gnu_pbds
{
namespace detail
{
using std::tr1::is_same;
using std::tr1::is_const;
using std::tr1::is_pointer;
using std::tr1::is_reference;
using std::tr1::is_fundamental;
using std::tr1::is_member_object_pointer;
using std::tr1::is_member_pointer;
using std::tr1::is_base_of;
using std::tr1::remove_const;
using std::tr1::remove_reference;
// Need integral_const<bool, true> <-> integral_const<int, 1>, so
// because of this use the following typedefs instead of importing
// std::tr1's.
using std::tr1::integral_constant;
typedef std::tr1::integral_constant<int, 1> true_type;
typedef std::tr1::integral_constant<int, 0> false_type;
using __gnu_cxx::__conditional_type;
using __gnu_cxx::__numeric_traits;
template<typename T>
struct is_const_pointer
{
enum
{
value = is_const<T>::value && is_pointer<T>::value
};
};
template<typename T>
struct is_const_reference
{
enum
{
value = is_const<T>::value && is_reference<T>::value
};
};
template<typename T>
struct is_simple
{
enum
{
value = is_fundamental<typename remove_const<T>::type>::value
|| is_pointer<typename remove_const<T>::type>::value
|| is_member_pointer<T>::value
};
};
template<typename T>
class is_pair
{
private:
template<typename U>
struct is_pair_imp
{
enum
{
value = 0
};
};
template<typename U, typename V>
struct is_pair_imp<std::pair<U,V> >
{
enum
{
value = 1
};
};
public:
enum
{
value = is_pair_imp<T>::value
};
};
// Use C++11's static_assert if possible.
#if __cplusplus >= 201103L
#define PB_DS_STATIC_ASSERT(UNIQUE, E) static_assert(E, #UNIQUE)
#else
template<bool>
struct __static_assert;
template<>
struct __static_assert<true>
{ };
template<int>
struct __static_assert_dumclass
{
enum
{
v = 1
};
};
#define PB_DS_STATIC_ASSERT(UNIQUE, E) \
typedef __gnu_pbds::detail::__static_assert_dumclass<sizeof(__gnu_pbds::detail::__static_assert<bool(E)>)> UNIQUE##__static_assert_type
#endif
template<typename Type>
struct type_to_type
{
typedef Type type;
};
} // namespace detail
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/detail/standard_policies.hpp 0000644 00000011647 15201526705 0014630 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file detail/standard_policies.hpp
* Contains standard policies for containers.
*/
#ifndef PB_DS_STANDARD_POLICIES_HPP
#define PB_DS_STANDARD_POLICIES_HPP
#include <memory>
#include <ext/pb_ds/hash_policy.hpp>
#include <ext/pb_ds/list_update_policy.hpp>
#include <ext/pb_ds/detail/branch_policy/null_node_metadata.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
#include <tr1/functional>
namespace __gnu_pbds
{
namespace detail
{
/// Primary template, default_hash_fn.
template<typename Key>
struct default_hash_fn
{
/// Dispatched type.
typedef std::tr1::hash<Key> type;
};
/// Primary template, default_eq_fn.
template<typename Key>
struct default_eq_fn
{
/// Dispatched type.
typedef std::equal_to<Key> type;
};
/// Enumeration for default behavior of stored hash data.
enum
{
default_store_hash = false
};
/// Primary template, default_comb_hash_fn.
struct default_comb_hash_fn
{
/// Dispatched type.
typedef direct_mask_range_hashing<> type;
};
/// Primary template, default_resize_policy.
template<typename Comb_Hash_Fn>
struct default_resize_policy
{
private:
typedef typename Comb_Hash_Fn::size_type size_type;
typedef direct_mask_range_hashing<size_type> default_fn;
typedef is_same<default_fn, Comb_Hash_Fn> same_type;
typedef hash_exponential_size_policy<size_type> iftrue;
typedef hash_prime_size_policy iffalse;
typedef __conditional_type<same_type::value, iftrue, iffalse> cond_type;
typedef typename cond_type::__type size_policy_type;
typedef hash_load_check_resize_trigger<false, size_type> trigger;
public:
/// Dispatched type.
typedef hash_standard_resize_policy<size_policy_type, trigger,
false, size_type> type;
};
/// Default update policy.
struct default_update_policy
{
/// Dispatched type.
typedef lu_move_to_front_policy<> type;
};
/// Primary template, default_probe_fn.
template<typename Comb_Probe_Fn>
struct default_probe_fn
{
private:
typedef typename Comb_Probe_Fn::size_type size_type;
typedef direct_mask_range_hashing<size_type> default_fn;
typedef is_same<default_fn, Comb_Probe_Fn> same_type;
typedef linear_probe_fn<size_type> iftrue;
typedef quadratic_probe_fn<size_type> iffalse;
typedef __conditional_type<same_type::value, iftrue, iffalse> cond_type;
public:
/// Dispatched type.
typedef typename cond_type::__type type;
};
/// Primary template, default_trie_access_traits.
template<typename Key>
struct default_trie_access_traits;
#define __dtrie_alloc std::allocator<char>
#define __dtrie_string std::basic_string<Char, Char_Traits, __dtrie_alloc>
/// Partial specialization, default_trie_access_traits.
template<typename Char, typename Char_Traits>
struct default_trie_access_traits<__dtrie_string>
{
private:
typedef __dtrie_string string_type;
public:
/// Dispatched type.
typedef trie_string_access_traits<string_type> type;
};
#undef __dtrie_alloc
#undef __dtrie_string
} // namespace detail
} // namespace __gnu_pbds
#endif // #ifndef PB_DS_STANDARD_POLICIES_HPP
c++/8/ext/pb_ds/detail/ov_tree_map_/info_fn_imps.hpp 0000644 00000004044 15201526705 0016237 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file ov_tree_map_/info_fn_imps.hpp
* Contains an implementation class for ov_tree_.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
size() const
{
PB_DS_ASSERT_VALID((*this))
return m_size;
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
max_size() const
{ return s_value_alloc.max_size(); }
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
empty() const
{ return size() == 0; }
c++/8/ext/pb_ds/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp 0000644 00000015325 15201526705 0022336 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file ov_tree_map_/constructors_destructor_fn_imps.hpp
* Contains an implementation class for ov_tree_.
*/
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::value_allocator
PB_DS_CLASS_C_DEC::s_value_alloc;
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::metadata_allocator
PB_DS_CLASS_C_DEC::s_metadata_alloc;
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_OV_TREE_NAME() :
m_a_values(0),
m_a_metadata(0),
m_end_it(0),
m_size(0)
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_OV_TREE_NAME(const Cmp_Fn& r_cmp_fn) :
cmp_fn(r_cmp_fn),
m_a_values(0),
m_a_metadata(0),
m_end_it(0),
m_size(0)
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_OV_TREE_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_nodeu) :
cmp_fn(r_cmp_fn),
node_update(r_nodeu),
m_a_values(0),
m_a_metadata(0),
m_end_it(0),
m_size(0)
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_OV_TREE_NAME(const PB_DS_CLASS_C_DEC& other) :
#ifdef PB_DS_TREE_TRACE
trace_base(other),
#endif
cmp_fn(other),
node_update(other),
m_a_values(0),
m_a_metadata(0),
m_end_it(0),
m_size(0)
{
copy_from_ordered_range(other.begin(), other.end());
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
template<typename It>
inline void
PB_DS_CLASS_C_DEC::
copy_from_range(It first_it, It last_it)
{
#ifdef PB_DS_DATA_TRUE_INDICATOR
typedef std::map<key_type, mapped_type, Cmp_Fn,
typename _Alloc::template rebind<value_type>::other>
map_type;
#else
typedef std::set<key_type, Cmp_Fn,
typename _Alloc::template rebind<Key>::other>
map_type;
#endif
map_type m(first_it, last_it);
copy_from_ordered_range(m.begin(), m.end());
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
template<typename It>
void
PB_DS_CLASS_C_DEC::
copy_from_ordered_range(It first_it, It last_it)
{
const size_type len = std::distance(first_it, last_it);
if (len == 0)
return;
value_vector a_values = s_value_alloc.allocate(len);
iterator target_it = a_values;
It source_it = first_it;
It source_end_it = last_it;
cond_dtor<size_type> cd(a_values, target_it, len);
while (source_it != source_end_it)
{
void* __v = const_cast<void*>(static_cast<const void*>(target_it));
new (__v) value_type(*source_it++);
++target_it;
}
reallocate_metadata((node_update*)this, len);
cd.set_no_action();
m_a_values = a_values;
m_size = len;
m_end_it = m_a_values + m_size;
update(PB_DS_node_begin_imp(), (node_update*)this);
#ifdef _GLIBCXX_DEBUG
for (const_iterator dbg_it = m_a_values; dbg_it != m_end_it; ++dbg_it)
debug_base::insert_new(PB_DS_V2F(*dbg_it));
#endif
}
PB_DS_CLASS_T_DEC
template<typename It>
void
PB_DS_CLASS_C_DEC::
copy_from_ordered_range(It first_it, It last_it, It other_first_it,
It other_last_it)
{
clear();
const size_type len = std::distance(first_it, last_it)
+ std::distance(other_first_it, other_last_it);
value_vector a_values = s_value_alloc.allocate(len);
iterator target_it = a_values;
It source_it = first_it;
It source_end_it = last_it;
cond_dtor<size_type> cd(a_values, target_it, len);
while (source_it != source_end_it)
{
new (const_cast<void* >(static_cast<const void* >(target_it)))
value_type(*source_it++);
++target_it;
}
source_it = other_first_it;
source_end_it = other_last_it;
while (source_it != source_end_it)
{
new (const_cast<void* >(static_cast<const void* >(target_it)))
value_type(*source_it++);
++target_it;
}
reallocate_metadata((node_update* )this, len);
cd.set_no_action();
m_a_values = a_values;
m_size = len;
m_end_it = m_a_values + m_size;
update(PB_DS_node_begin_imp(), (node_update* )this);
#ifdef _GLIBCXX_DEBUG
for (const_iterator dbg_it = m_a_values; dbg_it != m_end_it; ++dbg_it)
debug_base::insert_new(PB_DS_V2F(*dbg_it));
#endif
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
value_swap(other);
std::swap(static_cast<cmp_fn&>(*this),
static_cast<cmp_fn&>(other));
std::swap(static_cast<traits_base&>(*this),
static_cast<traits_base&>(other));
PB_DS_ASSERT_VALID(other)
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
value_swap(PB_DS_CLASS_C_DEC& other)
{
_GLIBCXX_DEBUG_ONLY(debug_base::swap(other);)
std::swap(m_a_values, other.m_a_values);
std::swap(m_a_metadata, other.m_a_metadata);
std::swap(m_size, other.m_size);
std::swap(m_end_it, other.m_end_it);
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
~PB_DS_OV_TREE_NAME()
{
PB_DS_ASSERT_VALID((*this))
cond_dtor<size_type> cd(m_a_values, m_end_it, m_size);
reallocate_metadata((node_update*)this, 0);
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
update(node_iterator, null_node_update_pointer)
{ }
PB_DS_CLASS_T_DEC
template<typename Node_Update>
void
PB_DS_CLASS_C_DEC::
update(node_iterator nd_it, Node_Update* p_update)
{
node_const_iterator end_it = PB_DS_node_end_imp();
if (nd_it != end_it)
{
update(nd_it.get_l_child(), p_update);
update(nd_it.get_r_child(), p_update);
node_update::operator()(nd_it, end_it);
}
}
c++/8/ext/pb_ds/detail/ov_tree_map_/iterators_fn_imps.hpp 0000644 00000006441 15201526705 0017323 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file ov_tree_map_/iterators_fn_imps.hpp
* Contains an implementation class for ov_tree_.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_const_iterator
PB_DS_CLASS_C_DEC::
node_begin() const
{ return PB_DS_node_begin_imp(); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_const_iterator
PB_DS_CLASS_C_DEC::
node_end() const
{ return PB_DS_node_end_imp(); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_iterator
PB_DS_CLASS_C_DEC::
node_begin()
{ return PB_DS_node_begin_imp(); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_iterator
PB_DS_CLASS_C_DEC::
node_end()
{ return PB_DS_node_end_imp(); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_const_iterator
PB_DS_CLASS_C_DEC::
PB_DS_node_begin_imp() const
{
return node_const_iterator(const_cast<pointer>(mid_pointer(begin(), end())),
const_cast<pointer>(begin()),
const_cast<pointer>(end()),(m_a_metadata == 0)?
0 :
mid_pointer(m_a_metadata, m_a_metadata + m_size));
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_const_iterator
PB_DS_CLASS_C_DEC::
PB_DS_node_end_imp() const
{
return node_const_iterator(end(), end(), end(),
(m_a_metadata == 0) ? 0 : m_a_metadata + m_size);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_iterator
PB_DS_CLASS_C_DEC::
PB_DS_node_begin_imp()
{
return node_iterator(mid_pointer(begin(), end()), begin(), end(),
(m_a_metadata == 0) ? 0 : mid_pointer(m_a_metadata, m_a_metadata + m_size));
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_iterator
PB_DS_CLASS_C_DEC::
PB_DS_node_end_imp()
{
return node_iterator(end(), end(),
end(),(m_a_metadata == 0) ? 0 : m_a_metadata + m_size);
}
c++/8/ext/pb_ds/detail/ov_tree_map_/debug_fn_imps.hpp 0000644 00000005402 15201526705 0016371 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file ov_tree_map_/debug_fn_imps.hpp
* Contains an implementation class for ov_tree_.
*/
#ifdef _GLIBCXX_DEBUG
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_valid(const char* __file, int __line) const
{
if (m_a_values == 0 || m_end_it == 0 || m_size == 0)
PB_DS_DEBUG_VERIFY(m_a_values == 0 && m_end_it == 0 && m_size == 0);
assert_iterators(__file, __line);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_iterators(const char* __file, int __line) const
{
debug_base::check_size(m_size, __file, __line);
size_type iterated_num = 0;
const_iterator prev_it = end();
PB_DS_DEBUG_VERIFY(m_end_it == m_a_values + m_size);
for (const_iterator it = begin(); it != end(); ++it)
{
++iterated_num;
debug_base::check_key_exists(PB_DS_V2F(*it), __file, __line);
PB_DS_DEBUG_VERIFY(lower_bound(PB_DS_V2F(*it)) == it);
const_iterator upper_bound_it = upper_bound(PB_DS_V2F(*it));
--upper_bound_it;
PB_DS_DEBUG_VERIFY(upper_bound_it == it);
if (prev_it != end())
PB_DS_DEBUG_VERIFY(Cmp_Fn::operator()(PB_DS_V2F(*prev_it),
PB_DS_V2F(*it)));
prev_it = it;
}
PB_DS_DEBUG_VERIFY(iterated_num == m_size);
}
#endif
c++/8/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp 0000644 00000036006 15201526705 0016233 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file ov_tree_map_/ov_tree_map_.hpp
* Contains an implementation class for ov_tree.
*/
#include <map>
#include <set>
#include <ext/pb_ds/exception.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/eq_fn/eq_by_less.hpp>
#include <ext/pb_ds/detail/types_traits.hpp>
#include <ext/pb_ds/detail/type_utils.hpp>
#include <ext/pb_ds/detail/tree_trace_base.hpp>
#ifdef _GLIBCXX_DEBUG
#include <ext/pb_ds/detail/debug_map_base.hpp>
#endif
#include <utility>
#include <functional>
#include <algorithm>
#include <vector>
#include <assert.h>
#include <debug/debug.h>
namespace __gnu_pbds
{
namespace detail
{
#ifdef PB_DS_DATA_TRUE_INDICATOR
#define PB_DS_OV_TREE_NAME ov_tree_map
#define PB_DS_CONST_NODE_ITERATOR_NAME ov_tree_node_const_iterator_map
#endif
#ifdef PB_DS_DATA_FALSE_INDICATOR
#define PB_DS_OV_TREE_NAME ov_tree_set
#define PB_DS_CONST_NODE_ITERATOR_NAME ov_tree_node_const_iterator_set
#endif
#define PB_DS_CLASS_T_DEC \
template<typename Key, typename Mapped, typename Cmp_Fn, \
typename Node_And_It_Traits, typename _Alloc>
#define PB_DS_CLASS_C_DEC \
PB_DS_OV_TREE_NAME<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc>
#define PB_DS_OV_TREE_TRAITS_BASE \
types_traits<Key, Mapped, _Alloc, false>
#ifdef _GLIBCXX_DEBUG
#define PB_DS_DEBUG_MAP_BASE_C_DEC \
debug_map_base<Key, eq_by_less<Key, Cmp_Fn>, \
typename _Alloc::template rebind<Key>::other::const_reference>
#endif
#ifdef PB_DS_TREE_TRACE
#define PB_DS_TREE_TRACE_BASE_C_DEC \
tree_trace_base<typename Node_And_It_Traits::node_const_iterator, \
typename Node_And_It_Traits::node_iterator, \
Cmp_Fn, false, _Alloc>
#endif
#ifndef PB_DS_CHECK_KEY_EXISTS
# error Missing definition
#endif
/**
* @brief Ordered-vector tree associative-container.
* @ingroup branch-detail
*/
template<typename Key, typename Mapped, typename Cmp_Fn,
typename Node_And_It_Traits, typename _Alloc>
class PB_DS_OV_TREE_NAME :
#ifdef _GLIBCXX_DEBUG
protected PB_DS_DEBUG_MAP_BASE_C_DEC,
#endif
#ifdef PB_DS_TREE_TRACE
public PB_DS_TREE_TRACE_BASE_C_DEC,
#endif
public Cmp_Fn,
public Node_And_It_Traits::node_update,
public PB_DS_OV_TREE_TRAITS_BASE
{
private:
typedef PB_DS_OV_TREE_TRAITS_BASE traits_base;
typedef Node_And_It_Traits traits_type;
typedef typename remove_const<typename traits_base::value_type>::type non_const_value_type;
typedef typename _Alloc::template rebind<non_const_value_type>::other value_allocator;
typedef typename value_allocator::pointer value_vector;
#ifdef _GLIBCXX_DEBUG
typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base;
#endif
#ifdef PB_DS_TREE_TRACE
typedef PB_DS_TREE_TRACE_BASE_C_DEC trace_base;
#endif
typedef typename traits_base::pointer mapped_pointer_;
typedef typename traits_base::const_pointer mapped_const_pointer_;
typedef typename traits_type::metadata_type metadata_type;
typedef typename _Alloc::template rebind<metadata_type>::other metadata_allocator;
typedef typename metadata_allocator::pointer metadata_pointer;
typedef typename metadata_allocator::const_reference metadata_const_reference;
typedef typename metadata_allocator::reference metadata_reference;
typedef typename traits_type::null_node_update_pointer
null_node_update_pointer;
public:
typedef ov_tree_tag container_category;
typedef _Alloc allocator_type;
typedef typename _Alloc::size_type size_type;
typedef typename _Alloc::difference_type difference_type;
typedef Cmp_Fn cmp_fn;
typedef typename traits_base::key_type key_type;
typedef typename traits_base::key_pointer key_pointer;
typedef typename traits_base::key_const_pointer key_const_pointer;
typedef typename traits_base::key_reference key_reference;
typedef typename traits_base::key_const_reference key_const_reference;
typedef typename traits_base::mapped_type mapped_type;
typedef typename traits_base::mapped_pointer mapped_pointer;
typedef typename traits_base::mapped_const_pointer mapped_const_pointer;
typedef typename traits_base::mapped_reference mapped_reference;
typedef typename traits_base::mapped_const_reference mapped_const_reference;
typedef typename traits_base::value_type value_type;
typedef typename traits_base::pointer pointer;
typedef typename traits_base::const_pointer const_pointer;
typedef typename traits_base::reference reference;
typedef typename traits_base::const_reference const_reference;
typedef const_pointer point_const_iterator;
#ifdef PB_DS_DATA_TRUE_INDICATOR
typedef pointer point_iterator;
#else
typedef point_const_iterator point_iterator;
#endif
typedef point_iterator iterator;
typedef point_const_iterator const_iterator;
/// Conditional destructor.
template<typename Size_Type>
class cond_dtor
{
public:
cond_dtor(value_vector a_vec, iterator& r_last_it,
Size_Type total_size)
: m_a_vec(a_vec), m_r_last_it(r_last_it), m_max_size(total_size),
m_no_action(false)
{ }
~cond_dtor()
{
if (m_no_action)
return;
iterator it = m_a_vec;
while (it != m_r_last_it)
{
it->~value_type();
++it;
}
if (m_max_size > 0)
value_allocator().deallocate(m_a_vec, m_max_size);
}
inline void
set_no_action()
{ m_no_action = true; }
protected:
value_vector m_a_vec;
iterator& m_r_last_it;
const Size_Type m_max_size;
bool m_no_action;
};
typedef typename traits_type::node_update node_update;
typedef typename traits_type::node_iterator node_iterator;
typedef typename traits_type::node_const_iterator node_const_iterator;
PB_DS_OV_TREE_NAME();
PB_DS_OV_TREE_NAME(const Cmp_Fn&);
PB_DS_OV_TREE_NAME(const Cmp_Fn&, const node_update&);
PB_DS_OV_TREE_NAME(const PB_DS_CLASS_C_DEC&);
~PB_DS_OV_TREE_NAME();
void
swap(PB_DS_CLASS_C_DEC&);
template<typename It>
void
copy_from_range(It, It);
inline size_type
max_size() const;
inline bool
empty() const;
inline size_type
size() const;
Cmp_Fn&
get_cmp_fn();
const Cmp_Fn&
get_cmp_fn() const;
inline mapped_reference
operator[](key_const_reference r_key)
{
#ifdef PB_DS_DATA_TRUE_INDICATOR
PB_DS_ASSERT_VALID((*this))
point_iterator it = lower_bound(r_key);
if (it != end() && !Cmp_Fn::operator()(r_key, PB_DS_V2F(*it)))
{
PB_DS_CHECK_KEY_EXISTS(r_key)
PB_DS_ASSERT_VALID((*this))
return it->second;
}
return insert_new_val(it, std::make_pair(r_key, mapped_type()))->second;
#else
insert(r_key);
return traits_base::s_null_type;
#endif
}
inline std::pair<point_iterator, bool>
insert(const_reference r_value)
{
PB_DS_ASSERT_VALID((*this))
key_const_reference r_key = PB_DS_V2F(r_value);
point_iterator it = lower_bound(r_key);
if (it != end()&& !Cmp_Fn::operator()(r_key, PB_DS_V2F(*it)))
{
PB_DS_ASSERT_VALID((*this))
PB_DS_CHECK_KEY_EXISTS(r_key)
return std::make_pair(it, false);
}
return std::make_pair(insert_new_val(it, r_value), true);
}
inline point_iterator
lower_bound(key_const_reference r_key)
{
pointer it = m_a_values;
pointer e_it = m_a_values + m_size;
while (it != e_it)
{
pointer mid_it = it + ((e_it - it) >> 1);
if (cmp_fn::operator()(PB_DS_V2F(*mid_it), r_key))
it = ++mid_it;
else
e_it = mid_it;
}
return it;
}
inline point_const_iterator
lower_bound(key_const_reference r_key) const
{ return const_cast<PB_DS_CLASS_C_DEC& >(*this).lower_bound(r_key); }
inline point_iterator
upper_bound(key_const_reference r_key)
{
iterator pot_it = lower_bound(r_key);
if (pot_it != end() && !Cmp_Fn::operator()(r_key, PB_DS_V2F(*pot_it)))
{
PB_DS_CHECK_KEY_EXISTS(r_key)
return ++pot_it;
}
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return pot_it;
}
inline point_const_iterator
upper_bound(key_const_reference r_key) const
{ return const_cast<PB_DS_CLASS_C_DEC&>(*this).upper_bound(r_key); }
inline point_iterator
find(key_const_reference r_key)
{
PB_DS_ASSERT_VALID((*this))
iterator pot_it = lower_bound(r_key);
if (pot_it != end() && !Cmp_Fn::operator()(r_key, PB_DS_V2F(*pot_it)))
{
PB_DS_CHECK_KEY_EXISTS(r_key)
return pot_it;
}
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return end();
}
inline point_const_iterator
find(key_const_reference r_key) const
{ return (const_cast<PB_DS_CLASS_C_DEC&>(*this).find(r_key)); }
bool
erase(key_const_reference);
template<typename Pred>
inline size_type
erase_if(Pred);
inline iterator
erase(iterator it)
{ return erase_imp<iterator>(it); }
void
clear();
void
join(PB_DS_CLASS_C_DEC&);
void
split(key_const_reference, PB_DS_CLASS_C_DEC&);
inline iterator
begin()
{ return m_a_values; }
inline const_iterator
begin() const
{ return m_a_values; }
inline iterator
end()
{ return m_end_it; }
inline const_iterator
end() const
{ return m_end_it; }
/// Returns a const node_iterator corresponding to the node at the
/// root of the tree.
inline node_const_iterator
node_begin() const;
/// Returns a node_iterator corresponding to the node at the
/// root of the tree.
inline node_iterator
node_begin();
/// Returns a const node_iterator corresponding to a node just
/// after a leaf of the tree.
inline node_const_iterator
node_end() const;
/// Returns a node_iterator corresponding to a node just
/// after a leaf of the tree.
inline node_iterator
node_end();
private:
inline void
update(node_iterator, null_node_update_pointer);
template<typename Node_Update>
void
update(node_iterator, Node_Update*);
void
reallocate_metadata(null_node_update_pointer, size_type);
template<typename Node_Update_>
void
reallocate_metadata(Node_Update_*, size_type);
template<typename It>
void
copy_from_ordered_range(It, It);
void
value_swap(PB_DS_CLASS_C_DEC&);
template<typename It>
void
copy_from_ordered_range(It, It, It, It);
template<typename Ptr>
inline static Ptr
mid_pointer(Ptr p_begin, Ptr p_end)
{
_GLIBCXX_DEBUG_ASSERT(p_end >= p_begin);
return (p_begin + (p_end - p_begin) / 2);
}
inline iterator
insert_new_val(iterator it, const_reference r_value)
{
#ifdef PB_DS_REGRESSION
typename _Alloc::group_adjustor adjust(m_size);
#endif
PB_DS_CHECK_KEY_DOES_NOT_EXIST(PB_DS_V2F(r_value))
value_vector a_values = s_value_alloc.allocate(m_size + 1);
iterator source_it = begin();
iterator source_end_it = end();
iterator target_it = a_values;
iterator ret_it;
cond_dtor<size_type> cd(a_values, target_it, m_size + 1);
while (source_it != it)
{
new (const_cast<void*>(static_cast<const void*>(target_it)))
value_type(*source_it++);
++target_it;
}
new (const_cast<void*>(static_cast<const void*>(ret_it = target_it)))
value_type(r_value);
++target_it;
while (source_it != source_end_it)
{
new (const_cast<void*>(static_cast<const void*>(target_it)))
value_type(*source_it++);
++target_it;
}
reallocate_metadata((node_update*)this, m_size + 1);
cd.set_no_action();
if (m_size != 0)
{
cond_dtor<size_type> cd1(m_a_values, m_end_it, m_size);
}
++m_size;
m_a_values = a_values;
m_end_it = m_a_values + m_size;
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_value)));
update(node_begin(), (node_update* )this);
PB_DS_ASSERT_VALID((*this))
return ret_it;
}
#ifdef _GLIBCXX_DEBUG
void
assert_valid(const char*, int) const;
void
assert_iterators(const char*, int) const;
#endif
template<typename It>
It
erase_imp(It);
inline node_const_iterator
PB_DS_node_begin_imp() const;
inline node_const_iterator
PB_DS_node_end_imp() const;
inline node_iterator
PB_DS_node_begin_imp();
inline node_iterator
PB_DS_node_end_imp();
private:
static value_allocator s_value_alloc;
static metadata_allocator s_metadata_alloc;
value_vector m_a_values;
metadata_pointer m_a_metadata;
iterator m_end_it;
size_type m_size;
};
#include <ext/pb_ds/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/ov_tree_map_/iterators_fn_imps.hpp>
#include <ext/pb_ds/detail/ov_tree_map_/debug_fn_imps.hpp>
#include <ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp>
#include <ext/pb_ds/detail/ov_tree_map_/insert_fn_imps.hpp>
#include <ext/pb_ds/detail/ov_tree_map_/info_fn_imps.hpp>
#include <ext/pb_ds/detail/ov_tree_map_/split_join_fn_imps.hpp>
#include <ext/pb_ds/detail/bin_search_tree_/policy_access_fn_imps.hpp>
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_OV_TREE_NAME
#undef PB_DS_OV_TREE_TRAITS_BASE
#undef PB_DS_DEBUG_MAP_BASE_C_DEC
#ifdef PB_DS_TREE_TRACE
#undef PB_DS_TREE_TRACE_BASE_C_DEC
#endif
#undef PB_DS_CONST_NODE_ITERATOR_NAME
} // namespace detail
} // namespace __gnu_pbds
c++/8/ext/pb_ds/detail/ov_tree_map_/split_join_fn_imps.hpp 0000644 00000007276 15201526705 0017470 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file ov_tree_map_/split_join_fn_imps.hpp
* Contains an implementation class for ov_tree_.
*/
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
split(key_const_reference r_key, PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
if (m_size == 0)
{
other.clear();
return;
}
if (Cmp_Fn::operator()(r_key, PB_DS_V2F(*begin())))
{
value_swap(other);
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
return;
}
if (!Cmp_Fn::operator()(r_key, PB_DS_V2F(*(end() - 1))))
{
return;
}
if (m_size == 1)
{
value_swap(other);
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
return;
}
iterator it = upper_bound(r_key);
PB_DS_CLASS_C_DEC new_other(other, other);
new_other.copy_from_ordered_range(it, end());
PB_DS_CLASS_C_DEC new_this(*this, *this);
new_this.copy_from_ordered_range(begin(), it);
// No exceptions from this point.
other.update(other.node_begin(), (node_update*)(&other));
update(node_begin(), (node_update*)this);
other.value_swap(new_other);
value_swap(new_this);
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
join(PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
if (other.m_size == 0)
return;
if (m_size == 0)
{
value_swap(other);
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
return;
}
const bool greater = Cmp_Fn::operator()(PB_DS_V2F(*(end() - 1)),
PB_DS_V2F(*other.begin()));
const bool lesser = Cmp_Fn::operator()(PB_DS_V2F(*(other.end() - 1)),
PB_DS_V2F(*begin()));
if (!greater && !lesser)
__throw_join_error();
PB_DS_CLASS_C_DEC new_this(*this, *this);
if (greater)
new_this.copy_from_ordered_range(begin(), end(),
other.begin(), other.end());
else
new_this.copy_from_ordered_range(other.begin(), other.end(),
begin(), end());
// No exceptions from this point.
value_swap(new_this);
other.clear();
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
c++/8/ext/pb_ds/detail/ov_tree_map_/insert_fn_imps.hpp 0000644 00000004341 15201526705 0016610 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file ov_tree_map_/insert_fn_imps.hpp
* Contains an implementation class for ov_tree_.
*/
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
reallocate_metadata(null_node_update_pointer, size_type)
{ }
PB_DS_CLASS_T_DEC
template<typename Node_Update_>
void
PB_DS_CLASS_C_DEC::
reallocate_metadata(Node_Update_* , size_type new_size)
{
metadata_pointer a_new_metadata_vec =(new_size == 0) ? 0 : s_metadata_alloc.allocate(new_size);
if (m_a_metadata != 0)
{
for (size_type i = 0; i < m_size; ++i)
m_a_metadata[i].~metadata_type();
s_metadata_alloc.deallocate(m_a_metadata, m_size);
}
std::swap(m_a_metadata, a_new_metadata_vec);
}
c++/8/ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp 0000644 00000011565 15201526705 0016411 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file ov_tree_map_/erase_fn_imps.hpp
* Contains an implementation class for ov_tree_.
*/
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
clear()
{
PB_DS_ASSERT_VALID((*this))
if (m_size == 0)
{
return;
}
else
{
reallocate_metadata((node_update* )this, 0);
cond_dtor<size_type> cd(m_a_values, m_end_it, m_size);
}
_GLIBCXX_DEBUG_ONLY(debug_base::clear();)
m_a_values = 0;
m_size = 0;
m_end_it = m_a_values;
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
template<typename Pred>
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
erase_if(Pred pred)
{
PB_DS_ASSERT_VALID((*this))
#ifdef PB_DS_REGRESSION
typename _Alloc::group_adjustor adjust(m_size);
#endif
size_type new_size = 0;
size_type num_val_ersd = 0;
for (iterator source_it = begin(); source_it != m_end_it; ++source_it)
if (!pred(*source_it))
++new_size;
else
++num_val_ersd;
if (new_size == 0)
{
clear();
return num_val_ersd;
}
value_vector a_new_values = s_value_alloc.allocate(new_size);
iterator target_it = a_new_values;
cond_dtor<size_type> cd(a_new_values, target_it, new_size);
_GLIBCXX_DEBUG_ONLY(debug_base::clear());
for (iterator source_it = begin(); source_it != m_end_it; ++source_it)
{
if (!pred(*source_it))
{
new (const_cast<void*>(static_cast<const void*>(target_it)))
value_type(*source_it);
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(*source_it)));
++target_it;
}
}
reallocate_metadata((node_update*)this, new_size);
cd.set_no_action();
{
cond_dtor<size_type> cd1(m_a_values, m_end_it, m_size);
}
m_a_values = a_new_values;
m_size = new_size;
m_end_it = target_it;
update(node_begin(), (node_update*)this);
PB_DS_ASSERT_VALID((*this))
return num_val_ersd;
}
PB_DS_CLASS_T_DEC
template<typename It>
It
PB_DS_CLASS_C_DEC::
erase_imp(It it)
{
PB_DS_ASSERT_VALID((*this))
if (it == end())
return end();
PB_DS_CHECK_KEY_EXISTS(PB_DS_V2F(*it))
#ifdef PB_DS_REGRESSION
typename _Alloc::group_adjustor adjust(m_size);
#endif
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
value_vector a_values = s_value_alloc.allocate(m_size - 1);
iterator source_it = begin();
iterator source_end_it = end();
iterator target_it = a_values;
iterator ret_it = end();
cond_dtor<size_type> cd(a_values, target_it, m_size - 1);
_GLIBCXX_DEBUG_ONLY(size_type cnt = 0;)
while (source_it != source_end_it)
{
if (source_it != it)
{
_GLIBCXX_DEBUG_ONLY(++cnt;)
_GLIBCXX_DEBUG_ASSERT(cnt != m_size);
new (const_cast<void*>(static_cast<const void*>(target_it)))
value_type(*source_it);
++target_it;
}
else
ret_it = target_it;
++source_it;
}
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
reallocate_metadata((node_update*)this, m_size - 1);
cd.set_no_action();
_GLIBCXX_DEBUG_ONLY(debug_base::erase_existing(PB_DS_V2F(*it));)
{
cond_dtor<size_type> cd1(m_a_values, m_end_it, m_size);
}
m_a_values = a_values;
--m_size;
m_end_it = m_a_values + m_size;
update(node_begin(), (node_update*)this);
PB_DS_ASSERT_VALID((*this))
return It(ret_it);
}
PB_DS_CLASS_T_DEC
bool
PB_DS_CLASS_C_DEC::
erase(key_const_reference r_key)
{
point_iterator it = find(r_key);
if (it == end())
return false;
erase(it);
return true;
}
c++/8/ext/pb_ds/detail/ov_tree_map_/traits.hpp 0000644 00000010722 15201526705 0015077 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file ov_tree_map_/traits.hpp
* Contains an implementation class for ov_tree_.
*/
#ifndef PB_DS_OV_TREE_NODE_AND_IT_TRAITS_HPP
#define PB_DS_OV_TREE_NODE_AND_IT_TRAITS_HPP
#include <ext/pb_ds/detail/ov_tree_map_/node_iterators.hpp>
namespace __gnu_pbds
{
namespace detail
{
/// Tree traits.
/// @ingroup traits
template<typename Key,
typename Mapped,
class Cmp_Fn,
template<typename Node_CItr,
class Node_Itr,
class Cmp_Fn_,
typename _Alloc_>
class Node_Update,
typename _Alloc>
struct tree_traits<
Key,
Mapped,
Cmp_Fn,
Node_Update,
ov_tree_tag,
_Alloc>
{
private:
typedef
typename types_traits<
Key,
Mapped,
_Alloc,
false>::value_type
value_type;
public:
typedef
typename tree_node_metadata_dispatch<
Key,
Mapped,
Cmp_Fn,
Node_Update,
_Alloc>::type
metadata_type;
/// This is an iterator to an iterator: it iterates over nodes,
/// and de-referencing it returns one of the tree's iterators.
typedef
ov_tree_node_const_it_<
value_type,
metadata_type,
_Alloc>
node_const_iterator;
typedef
ov_tree_node_it_<
value_type,
metadata_type,
_Alloc>
node_iterator;
typedef
Node_Update<
node_const_iterator,
node_iterator,
Cmp_Fn,
_Alloc>
node_update;
typedef
__gnu_pbds::null_node_update<
node_const_iterator,
node_iterator,
Cmp_Fn,
_Alloc>*
null_node_update_pointer;
};
/// Specialization.
/// @ingroup traits
template<typename Key,
class Cmp_Fn,
template<typename Node_CItr,
class Node_Itr,
class Cmp_Fn_,
typename _Alloc_>
class Node_Update,
typename _Alloc>
struct tree_traits<
Key,
null_type,
Cmp_Fn,
Node_Update,
ov_tree_tag,
_Alloc>
{
private:
typedef
typename types_traits<
Key,
null_type,
_Alloc,
false>::value_type
value_type;
public:
typedef
typename tree_node_metadata_dispatch<
Key,
null_type,
Cmp_Fn,
Node_Update,
_Alloc>::type
metadata_type;
/// This is an iterator to an iterator: it iterates over nodes,
/// and de-referencing it returns one of the tree's iterators.
typedef
ov_tree_node_const_it_<
value_type,
metadata_type,
_Alloc>
node_const_iterator;
typedef node_const_iterator node_iterator;
typedef
Node_Update<
node_const_iterator,
node_const_iterator,
Cmp_Fn,
_Alloc>
node_update;
typedef
__gnu_pbds::null_node_update<
node_const_iterator,
node_iterator,
Cmp_Fn,
_Alloc>*
null_node_update_pointer;
};
} // namespace detail
} // namespace __gnu_pbds
#endif // #ifndef PB_DS_OV_TREE_NODE_AND_IT_TRAITS_HPP
c++/8/ext/pb_ds/detail/ov_tree_map_/policy_access_fn_imps.hpp 0000644 00000003537 15201526705 0020132 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file ov_tree_map_/policy_access_fn_imps.hpp
* Contains an implementation class for ov_tree.
*/
PB_DS_CLASS_T_DEC
Cmp_Fn&
PB_DS_CLASS_C_DEC::
get_cmp_fn()
{ return *this; }
PB_DS_CLASS_T_DEC
const Cmp_Fn&
PB_DS_CLASS_C_DEC::
get_cmp_fn() const
{ return *this; }
c++/8/ext/pb_ds/detail/ov_tree_map_/node_iterators.hpp 0000644 00000021153 15201526705 0016612 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file ov_tree_map_/node_iterators.hpp
* Contains an implementation class for ov_tree_.
*/
#ifndef PB_DS_OV_TREE_NODE_ITERATORS_HPP
#define PB_DS_OV_TREE_NODE_ITERATORS_HPP
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/pb_ds/detail/type_utils.hpp>
#include <debug/debug.h>
namespace __gnu_pbds
{
namespace detail
{
#define PB_DS_OV_TREE_CONST_NODE_ITERATOR_C_DEC \
ov_tree_node_const_it_<Value_Type, Metadata_Type, _Alloc>
/// Const node reference.
template<typename Value_Type, typename Metadata_Type, typename _Alloc>
class ov_tree_node_const_it_
{
protected:
typedef
typename _Alloc::template rebind<
Value_Type>::other::pointer
pointer;
typedef
typename _Alloc::template rebind<
Value_Type>::other::const_pointer
const_pointer;
typedef
typename _Alloc::template rebind<
Metadata_Type>::other::const_pointer
const_metadata_pointer;
typedef PB_DS_OV_TREE_CONST_NODE_ITERATOR_C_DEC this_type;
protected:
template<typename Ptr>
inline static Ptr
mid_pointer(Ptr p_begin, Ptr p_end)
{
_GLIBCXX_DEBUG_ASSERT(p_end >= p_begin);
return (p_begin + (p_end - p_begin) / 2);
}
public:
typedef trivial_iterator_tag iterator_category;
typedef trivial_iterator_difference_type difference_type;
typedef
typename _Alloc::template rebind<
Value_Type>::other::const_pointer
value_type;
typedef
typename _Alloc::template rebind<
typename remove_const<
Value_Type>::type>::other::const_pointer
reference;
typedef
typename _Alloc::template rebind<
typename remove_const<
Value_Type>::type>::other::const_pointer
const_reference;
typedef Metadata_Type metadata_type;
typedef
typename _Alloc::template rebind<
metadata_type>::other::const_reference
metadata_const_reference;
public:
inline
ov_tree_node_const_it_(const_pointer p_nd = 0, const_pointer p_begin_nd = 0, const_pointer p_end_nd = 0, const_metadata_pointer p_metadata = 0) : m_p_value(const_cast<pointer>(p_nd)), m_p_begin_value(const_cast<pointer>(p_begin_nd)), m_p_end_value(const_cast<pointer>(p_end_nd)), m_p_metadata(p_metadata)
{ }
inline const_reference
operator*() const
{ return m_p_value; }
inline metadata_const_reference
get_metadata() const
{
enum
{
has_metadata = !is_same<Metadata_Type, null_type>::value
};
PB_DS_STATIC_ASSERT(should_have_metadata, has_metadata);
_GLIBCXX_DEBUG_ASSERT(m_p_metadata != 0);
return *m_p_metadata;
}
/// Returns the node iterator associated with the left node.
inline this_type
get_l_child() const
{
if (m_p_begin_value == m_p_value)
return (this_type(m_p_begin_value, m_p_begin_value, m_p_begin_value));
const_metadata_pointer p_begin_metadata =
m_p_metadata - (m_p_value - m_p_begin_value);
return (this_type(mid_pointer(m_p_begin_value, m_p_value),
m_p_begin_value,
m_p_value,
mid_pointer(p_begin_metadata, m_p_metadata)));
}
/// Returns the node iterator associated with the right node.
inline this_type
get_r_child() const
{
if (m_p_value == m_p_end_value)
return (this_type(m_p_end_value, m_p_end_value, m_p_end_value));
const_metadata_pointer p_end_metadata =
m_p_metadata + (m_p_end_value - m_p_value);
return (this_type(mid_pointer(m_p_value + 1, m_p_end_value),
m_p_value + 1,
m_p_end_value,(m_p_metadata == 0) ?
0 : mid_pointer(m_p_metadata + 1, p_end_metadata)));
}
inline bool
operator==(const this_type& other) const
{
const bool is_end = m_p_begin_value == m_p_end_value;
const bool is_other_end = other.m_p_begin_value == other.m_p_end_value;
if (is_end)
return (is_other_end);
if (is_other_end)
return (is_end);
return m_p_value == other.m_p_value;
}
inline bool
operator!=(const this_type& other) const
{ return !operator==(other); }
public:
pointer m_p_value;
pointer m_p_begin_value;
pointer m_p_end_value;
const_metadata_pointer m_p_metadata;
};
#define PB_DS_OV_TREE_NODE_ITERATOR_C_DEC \
ov_tree_node_it_<Value_Type, Metadata_Type, _Alloc>
/// Node reference.
template<typename Value_Type, typename Metadata_Type, typename _Alloc>
class ov_tree_node_it_ : public PB_DS_OV_TREE_CONST_NODE_ITERATOR_C_DEC
{
private:
typedef PB_DS_OV_TREE_NODE_ITERATOR_C_DEC this_type;
typedef PB_DS_OV_TREE_CONST_NODE_ITERATOR_C_DEC base_type;
typedef typename base_type::pointer pointer;
typedef typename base_type::const_pointer const_pointer;
typedef
typename base_type::const_metadata_pointer
const_metadata_pointer;
public:
typedef trivial_iterator_tag iterator_category;
typedef trivial_iterator_difference_type difference_type;
typedef
typename _Alloc::template rebind<
Value_Type>::other::pointer
value_type;
typedef
typename _Alloc::template rebind<
typename remove_const<
Value_Type>::type>::other::pointer
reference;
typedef
typename _Alloc::template rebind<
typename remove_const<
Value_Type>::type>::other::pointer
const_reference;
inline
ov_tree_node_it_(const_pointer p_nd = 0, const_pointer p_begin_nd = 0, const_pointer p_end_nd = 0, const_metadata_pointer p_metadata = 0) : base_type(p_nd, p_begin_nd, p_end_nd, p_metadata)
{ }
/// Access.
inline reference
operator*() const
{ return reference(base_type::m_p_value); }
/// Returns the node reference associated with the left node.
inline ov_tree_node_it_
get_l_child() const
{
if (base_type::m_p_begin_value == base_type::m_p_value)
return (this_type(base_type::m_p_begin_value, base_type::m_p_begin_value, base_type::m_p_begin_value));
const_metadata_pointer p_begin_metadata =
base_type::m_p_metadata - (base_type::m_p_value - base_type::m_p_begin_value);
return (this_type(base_type::mid_pointer(base_type::m_p_begin_value, base_type::m_p_value),
base_type::m_p_begin_value,
base_type::m_p_value,
base_type::mid_pointer(p_begin_metadata, base_type::m_p_metadata)));
}
/// Returns the node reference associated with the right node.
inline ov_tree_node_it_
get_r_child() const
{
if (base_type::m_p_value == base_type::m_p_end_value)
return this_type(base_type::m_p_end_value, base_type::m_p_end_value,
base_type::m_p_end_value);
const_metadata_pointer p_end_metadata =
base_type::m_p_metadata + (base_type::m_p_end_value - base_type::m_p_value);
return (this_type(base_type::mid_pointer(base_type::m_p_value + 1, base_type::m_p_end_value),
base_type::m_p_value + 1,
base_type::m_p_end_value,(base_type::m_p_metadata == 0)?
0 : base_type::mid_pointer(base_type::m_p_metadata + 1, p_end_metadata)));
}
};
#undef PB_DS_OV_TREE_NODE_ITERATOR_C_DEC
#undef PB_DS_OV_TREE_CONST_NODE_ITERATOR_C_DEC
} // namespace detail
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/detail/binary_heap_/info_fn_imps.hpp 0000644 00000004016 15201526705 0016217 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file binary_heap_/info_fn_imps.hpp
* Contains an implementation class for a binary_heap.
*/
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
empty() const
{ return m_size == 0; }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
size() const
{ return m_size; }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
max_size() const
{ return s_entry_allocator.max_size(); }
c++/8/ext/pb_ds/detail/binary_heap_/constructors_destructor_fn_imps.hpp 0000644 00000010135 15201526705 0022311 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file binary_heap_/constructors_destructor_fn_imps.hpp
* Contains an implementation class for binary_heap_.
*/
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::entry_allocator
PB_DS_CLASS_C_DEC::s_entry_allocator;
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::value_allocator
PB_DS_CLASS_C_DEC::s_value_allocator;
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::no_throw_copies_t
PB_DS_CLASS_C_DEC::s_no_throw_copies_ind;
PB_DS_CLASS_T_DEC
template<typename It>
void
PB_DS_CLASS_C_DEC::
copy_from_range(It first_it, It last_it)
{
while (first_it != last_it)
{
insert_value(*first_it, s_no_throw_copies_ind);
++first_it;
}
make_heap();
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
binary_heap()
: m_size(0), m_actual_size(resize_policy::min_size),
m_a_entries(s_entry_allocator.allocate(m_actual_size))
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
binary_heap(const Cmp_Fn& r_cmp_fn)
: entry_cmp(r_cmp_fn), m_size(0), m_actual_size(resize_policy::min_size),
m_a_entries(s_entry_allocator.allocate(m_actual_size))
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
binary_heap(const PB_DS_CLASS_C_DEC& other)
: entry_cmp(other), resize_policy(other), m_size(0),
m_actual_size(other.m_actual_size),
m_a_entries(s_entry_allocator.allocate(m_actual_size))
{
PB_DS_ASSERT_VALID(other)
_GLIBCXX_DEBUG_ASSERT(m_a_entries != other.m_a_entries);
__try
{
copy_from_range(other.begin(), other.end());
}
__catch(...)
{
for (size_type i = 0; i < m_size; ++i)
erase_at(m_a_entries, i, s_no_throw_copies_ind);
s_entry_allocator.deallocate(m_a_entries, m_actual_size);
__throw_exception_again;
}
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
_GLIBCXX_DEBUG_ASSERT(m_a_entries != other.m_a_entries);
value_swap(other);
std::swap((entry_cmp&)(*this), (entry_cmp&)other);
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
value_swap(PB_DS_CLASS_C_DEC& other)
{
std::swap(m_a_entries, other.m_a_entries);
std::swap(m_size, other.m_size);
std::swap(m_actual_size, other.m_actual_size);
static_cast<resize_policy*>(this)->swap(other);
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
~binary_heap()
{
for (size_type i = 0; i < m_size; ++i)
erase_at(m_a_entries, i, s_no_throw_copies_ind);
s_entry_allocator.deallocate(m_a_entries, m_actual_size);
}
c++/8/ext/pb_ds/detail/binary_heap_/binary_heap_.hpp 0000644 00000021462 15201526705 0016175 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file binary_heap_/binary_heap_.hpp
* Contains an implementation class for a binary heap.
*/
#ifndef PB_DS_BINARY_HEAP_HPP
#define PB_DS_BINARY_HEAP_HPP
#include <queue>
#include <algorithm>
#include <ext/pb_ds/detail/cond_dealtor.hpp>
#include <ext/pb_ds/detail/cond_dealtor.hpp>
#include <ext/pb_ds/detail/type_utils.hpp>
#include <ext/pb_ds/detail/binary_heap_/entry_cmp.hpp>
#include <ext/pb_ds/detail/binary_heap_/entry_pred.hpp>
#include <ext/pb_ds/detail/binary_heap_/resize_policy.hpp>
#include <ext/pb_ds/detail/binary_heap_/point_const_iterator.hpp>
#include <ext/pb_ds/detail/binary_heap_/const_iterator.hpp>
#ifdef PB_DS_BINARY_HEAP_TRACE_
#include <iostream>
#endif
#include <ext/pb_ds/detail/type_utils.hpp>
#include <debug/debug.h>
namespace __gnu_pbds
{
namespace detail
{
#define PB_DS_CLASS_T_DEC \
template<typename Value_Type, typename Cmp_Fn, typename _Alloc>
#define PB_DS_CLASS_C_DEC \
binary_heap<Value_Type, Cmp_Fn, _Alloc>
#define PB_DS_ENTRY_CMP_DEC \
entry_cmp<Value_Type, Cmp_Fn, _Alloc, is_simple<Value_Type>::value>::type
#define PB_DS_RESIZE_POLICY_DEC \
__gnu_pbds::detail::resize_policy<typename _Alloc::size_type>
/**
* Binary heaps composed of resize and compare policies.
*
* @ingroup heap-detail
*
* Based on CLRS.
*/
template<typename Value_Type, typename Cmp_Fn, typename _Alloc>
class binary_heap
: public PB_DS_ENTRY_CMP_DEC, public PB_DS_RESIZE_POLICY_DEC
{
public:
typedef Value_Type value_type;
typedef Cmp_Fn cmp_fn;
typedef _Alloc allocator_type;
typedef typename _Alloc::size_type size_type;
typedef typename _Alloc::difference_type difference_type;
typedef typename PB_DS_ENTRY_CMP_DEC entry_cmp;
typedef PB_DS_RESIZE_POLICY_DEC resize_policy;
typedef cond_dealtor<value_type, _Alloc> cond_dealtor_t;
private:
enum
{
simple_value = is_simple<value_type>::value
};
typedef integral_constant<int, simple_value> no_throw_copies_t;
typedef typename _Alloc::template rebind<value_type> __rebind_v;
typedef typename __rebind_v::other value_allocator;
public:
typedef typename value_allocator::pointer pointer;
typedef typename value_allocator::const_pointer const_pointer;
typedef typename value_allocator::reference reference;
typedef typename value_allocator::const_reference const_reference;
typedef typename __conditional_type<simple_value,
value_type, pointer>::__type
entry;
typedef typename _Alloc::template rebind<entry>::other
entry_allocator;
typedef typename entry_allocator::pointer entry_pointer;
typedef binary_heap_point_const_iterator_<value_type, entry,
simple_value, _Alloc>
point_const_iterator;
typedef point_const_iterator point_iterator;
typedef binary_heap_const_iterator_<value_type, entry,
simple_value, _Alloc>
const_iterator;
typedef const_iterator iterator;
binary_heap();
binary_heap(const cmp_fn&);
binary_heap(const binary_heap&);
void
swap(binary_heap&);
~binary_heap();
inline bool
empty() const;
inline size_type
size() const;
inline size_type
max_size() const;
Cmp_Fn&
get_cmp_fn();
const Cmp_Fn&
get_cmp_fn() const;
inline point_iterator
push(const_reference);
void
modify(point_iterator, const_reference);
inline const_reference
top() const;
inline void
pop();
inline void
erase(point_iterator);
template<typename Pred>
size_type
erase_if(Pred);
inline void
erase_at(entry_pointer, size_type, false_type);
inline void
erase_at(entry_pointer, size_type, true_type);
inline iterator
begin();
inline const_iterator
begin() const;
inline iterator
end();
inline const_iterator
end() const;
void
clear();
template<typename Pred>
void
split(Pred, binary_heap&);
void
join(binary_heap&);
#ifdef PB_DS_BINARY_HEAP_TRACE_
void
trace() const;
#endif
protected:
template<typename It>
void
copy_from_range(It, It);
private:
void
value_swap(binary_heap&);
inline void
insert_value(const_reference, false_type);
inline void
insert_value(value_type, true_type);
inline void
resize_for_insert_if_needed();
inline void
swap_value_imp(entry_pointer, value_type, true_type);
inline void
swap_value_imp(entry_pointer, const_reference, false_type);
void
fix(entry_pointer);
inline const_reference
top_imp(true_type) const;
inline const_reference
top_imp(false_type) const;
inline static size_type
left_child(size_type);
inline static size_type
right_child(size_type);
inline static size_type
parent(size_type);
inline void
resize_for_erase_if_needed();
template<typename Pred>
size_type
partition(Pred);
void
make_heap()
{
const entry_cmp& m_cmp = static_cast<entry_cmp&>(*this);
entry_pointer end = m_a_entries + m_size;
std::make_heap(m_a_entries, end, m_cmp);
}
void
push_heap()
{
const entry_cmp& m_cmp = static_cast<entry_cmp&>(*this);
entry_pointer end = m_a_entries + m_size;
std::push_heap(m_a_entries, end, m_cmp);
}
void
pop_heap()
{
const entry_cmp& m_cmp = static_cast<entry_cmp&>(*this);
entry_pointer end = m_a_entries + m_size;
std::pop_heap(m_a_entries, end, m_cmp);
}
#ifdef _GLIBCXX_DEBUG
void
assert_valid(const char*, int) const;
#endif
#ifdef PB_DS_BINARY_HEAP_TRACE_
void
trace_entry(const entry&, false_type) const;
void
trace_entry(const entry&, true_type) const;
#endif
static entry_allocator s_entry_allocator;
static value_allocator s_value_allocator;
static no_throw_copies_t s_no_throw_copies_ind;
size_type m_size;
size_type m_actual_size;
entry_pointer m_a_entries;
};
#define PB_DS_ASSERT_VALID(X) \
_GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
#define PB_DS_DEBUG_VERIFY(_Cond) \
_GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
_M_message(#_Cond" assertion from %1;:%2;") \
._M_string(__FILE__)._M_integer(__LINE__) \
,__file,__line)
#include <ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp>
#include <ext/pb_ds/detail/binary_heap_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/binary_heap_/iterators_fn_imps.hpp>
#include <ext/pb_ds/detail/binary_heap_/debug_fn_imps.hpp>
#include <ext/pb_ds/detail/binary_heap_/trace_fn_imps.hpp>
#include <ext/pb_ds/detail/binary_heap_/erase_fn_imps.hpp>
#include <ext/pb_ds/detail/binary_heap_/info_fn_imps.hpp>
#include <ext/pb_ds/detail/binary_heap_/find_fn_imps.hpp>
#include <ext/pb_ds/detail/binary_heap_/split_join_fn_imps.hpp>
#include <ext/pb_ds/detail/binary_heap_/policy_access_fn_imps.hpp>
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_ENTRY_CMP_DEC
#undef PB_DS_RESIZE_POLICY_DEC
} // namespace detail
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/detail/binary_heap_/iterators_fn_imps.hpp 0000644 00000004336 15201526705 0017305 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file binary_heap_/iterators_fn_imps.hpp
* Contains an implementation class for a binary_heap.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
begin()
{ return iterator(m_a_entries); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
begin() const
{ return const_iterator(m_a_entries); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
end()
{ return iterator(m_a_entries + m_size); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
end() const
{ return const_iterator(m_a_entries + m_size); }
c++/8/ext/pb_ds/detail/binary_heap_/point_const_iterator.hpp 0000644 00000010537 15201526705 0020026 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file binary_heap_/point_const_iterator.hpp
* Contains an iterator class returned by the table's const find and insert
* methods.
*/
#ifndef PB_DS_BINARY_HEAP_CONST_FIND_ITERATOR_HPP
#define PB_DS_BINARY_HEAP_CONST_FIND_ITERATOR_HPP
#include <ext/pb_ds/tag_and_trait.hpp>
#include <debug/debug.h>
namespace __gnu_pbds
{
namespace detail
{
/// Const point-type iterator.
template<typename Value_Type, typename Entry, bool Simple,
typename _Alloc>
class binary_heap_point_const_iterator_
{
protected:
typedef typename _Alloc::template rebind<Entry>::other::pointer entry_pointer;
public:
/// Category.
typedef trivial_iterator_tag iterator_category;
/// Difference type.
typedef trivial_iterator_difference_type difference_type;
/// Iterator's value type.
typedef Value_Type value_type;
/// Iterator's pointer type.
typedef typename _Alloc::template rebind<value_type>::other::pointer
pointer;
/// Iterator's const pointer type.
typedef
typename _Alloc::template rebind<value_type>::other::const_pointer
const_pointer;
/// Iterator's reference type.
typedef
typename _Alloc::template rebind<value_type>::other::reference
reference;
/// Iterator's const reference type.
typedef
typename _Alloc::template rebind<value_type>::other::const_reference
const_reference;
inline
binary_heap_point_const_iterator_(entry_pointer p_e) : m_p_e(p_e)
{ }
/// Default constructor.
inline
binary_heap_point_const_iterator_() : m_p_e(0) { }
/// Copy constructor.
inline
binary_heap_point_const_iterator_(const binary_heap_point_const_iterator_& other)
: m_p_e(other.m_p_e)
{ }
/// Access.
inline const_pointer
operator->() const
{
_GLIBCXX_DEBUG_ASSERT(m_p_e != 0);
return to_ptr(integral_constant<int, Simple>());
}
/// Access.
inline const_reference
operator*() const
{
_GLIBCXX_DEBUG_ASSERT(m_p_e != 0);
return *to_ptr(integral_constant<int, Simple>());
}
/// Compares content to a different iterator object.
inline bool
operator==(const binary_heap_point_const_iterator_& other) const
{ return m_p_e == other.m_p_e; }
/// Compares content (negatively) to a different iterator object.
inline bool
operator!=(const binary_heap_point_const_iterator_& other) const
{ return m_p_e != other.m_p_e; }
private:
inline const_pointer
to_ptr(true_type) const
{ return m_p_e; }
inline const_pointer
to_ptr(false_type) const
{ return *m_p_e; }
public:
entry_pointer m_p_e;
};
} // namespace detail
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/detail/binary_heap_/debug_fn_imps.hpp 0000644 00000004755 15201526705 0016364 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file binary_heap_/debug_fn_imps.hpp
* Contains an implementation class for a binary_heap.
*/
#ifdef _GLIBCXX_DEBUG
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_valid(const char* __file, int __line) const
{
#ifdef PB_DS_REGRESSION
s_entry_allocator.check_allocated(m_a_entries, m_actual_size);
#endif
resize_policy::assert_valid(__file, __line);
PB_DS_DEBUG_VERIFY(m_size <= m_actual_size);
for (size_type i = 0; i < m_size; ++i)
{
#ifdef PB_DS_REGRESSION
s_value_allocator.check_allocated(m_a_entries[i], 1);
#endif
if (left_child(i) < m_size)
PB_DS_DEBUG_VERIFY(!entry_cmp::operator()(m_a_entries[i], m_a_entries[left_child(i)]));
PB_DS_DEBUG_VERIFY(parent(left_child(i)) == i);
if (right_child(i) < m_size)
PB_DS_DEBUG_VERIFY(!entry_cmp::operator()(m_a_entries[i], m_a_entries[right_child(i)]));
PB_DS_DEBUG_VERIFY(parent(right_child(i)) == i);
}
}
#endif
c++/8/ext/pb_ds/detail/binary_heap_/find_fn_imps.hpp 0000644 00000005045 15201526705 0016207 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file binary_heap_/find_fn_imps.hpp
* Contains an implementation class for a binary_heap.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_reference
PB_DS_CLASS_C_DEC::
top() const
{
PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!empty());
return top_imp(s_no_throw_copies_ind);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_reference
PB_DS_CLASS_C_DEC::
top_imp(true_type) const
{ return *m_a_entries; }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_reference
PB_DS_CLASS_C_DEC::
top_imp(false_type) const
{ return **m_a_entries; }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
left_child(size_type i)
{ return i * 2 + 1; }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
right_child(size_type i)
{ return i * 2 + 2; }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
parent(size_type i)
{ return (i - 1) / 2; }
c++/8/ext/pb_ds/detail/binary_heap_/resize_policy.hpp 0000644 00000013765 15201526705 0016444 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file binary_heap_/resize_policy.hpp
* Contains an implementation class for a binary_heap.
*/
#ifndef PB_DS_BINARY_HEAP_RESIZE_POLICY_HPP
#define PB_DS_BINARY_HEAP_RESIZE_POLICY_HPP
#include <debug/debug.h>
namespace __gnu_pbds
{
namespace detail
{
/// Resize policy for binary heap.
template<typename _Tp>
class resize_policy
{
private:
enum
{
ratio = 8,
factor = 2
};
/// Next shrink size.
_Tp m_shrink_size;
/// Next grow size.
_Tp m_grow_size;
public:
typedef _Tp size_type;
static const _Tp min_size = 16;
resize_policy() : m_shrink_size(0), m_grow_size(min_size)
{ PB_DS_ASSERT_VALID((*this)) }
resize_policy(const resize_policy& other)
: m_shrink_size(other.m_shrink_size), m_grow_size(other.m_grow_size)
{ PB_DS_ASSERT_VALID((*this)) }
inline void
swap(resize_policy<_Tp>&);
inline bool
resize_needed_for_grow(size_type) const;
inline bool
resize_needed_for_shrink(size_type) const;
inline bool
grow_needed(size_type) const;
inline bool
shrink_needed(size_type) const;
inline size_type
get_new_size_for_grow() const;
inline size_type
get_new_size_for_shrink() const;
inline size_type
get_new_size_for_arbitrary(size_type) const;
inline void
notify_grow_resize();
inline void
notify_shrink_resize();
void
notify_arbitrary(size_type);
#ifdef _GLIBCXX_DEBUG
void
assert_valid(const char*, int) const;
#endif
#ifdef PB_DS_BINARY_HEAP_TRACE_
void
trace() const;
#endif
};
template<typename _Tp>
const _Tp resize_policy<_Tp>::min_size;
template<typename _Tp>
inline void
resize_policy<_Tp>::
swap(resize_policy<_Tp>& other)
{
std::swap(m_shrink_size, other.m_shrink_size);
std::swap(m_grow_size, other.m_grow_size);
}
template<typename _Tp>
inline bool
resize_policy<_Tp>::
resize_needed_for_grow(size_type size) const
{
_GLIBCXX_DEBUG_ASSERT(size <= m_grow_size);
return size == m_grow_size;
}
template<typename _Tp>
inline bool
resize_policy<_Tp>::
resize_needed_for_shrink(size_type size) const
{
_GLIBCXX_DEBUG_ASSERT(size <= m_grow_size);
return size == m_shrink_size;
}
template<typename _Tp>
inline typename resize_policy<_Tp>::size_type
resize_policy<_Tp>::
get_new_size_for_grow() const
{ return m_grow_size * factor; }
template<typename _Tp>
inline typename resize_policy<_Tp>::size_type
resize_policy<_Tp>::
get_new_size_for_shrink() const
{
const size_type half_size = m_grow_size / factor;
return std::max(min_size, half_size);
}
template<typename _Tp>
inline typename resize_policy<_Tp>::size_type
resize_policy<_Tp>::
get_new_size_for_arbitrary(size_type size) const
{
size_type ret = min_size;
while (ret < size)
ret *= factor;
return ret;
}
template<typename _Tp>
inline void
resize_policy<_Tp>::
notify_grow_resize()
{
PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(m_grow_size >= min_size);
m_grow_size *= factor;
m_shrink_size = m_grow_size / ratio;
PB_DS_ASSERT_VALID((*this))
}
template<typename _Tp>
inline void
resize_policy<_Tp>::
notify_shrink_resize()
{
PB_DS_ASSERT_VALID((*this))
m_shrink_size /= factor;
if (m_shrink_size == 1)
m_shrink_size = 0;
m_grow_size = std::max(m_grow_size / factor, min_size);
PB_DS_ASSERT_VALID((*this))
}
template<typename _Tp>
inline void
resize_policy<_Tp>::
notify_arbitrary(size_type actual_size)
{
m_grow_size = actual_size;
m_shrink_size = m_grow_size / ratio;
PB_DS_ASSERT_VALID((*this))
}
#ifdef _GLIBCXX_DEBUG
template<typename _Tp>
void
resize_policy<_Tp>::
assert_valid(const char* __file, int __line) const
{
PB_DS_DEBUG_VERIFY(m_shrink_size == 0
|| m_shrink_size * ratio == m_grow_size);
PB_DS_DEBUG_VERIFY(m_grow_size >= min_size);
}
#endif
#ifdef PB_DS_BINARY_HEAP_TRACE_
template<typename _Tp>
void
resize_policy<_Tp>::
trace() const
{
std::cerr << "shrink = " << m_shrink_size
<< " grow = " << m_grow_size << std::endl;
}
#endif
} // namespace detail
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/detail/binary_heap_/entry_cmp.hpp 0000644 00000005404 15201526705 0015553 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file binary_heap_/entry_cmp.hpp
* Contains an implementation class for a binary_heap.
*/
#ifndef PB_DS_BINARY_HEAP_ENTRY_CMP_HPP
#define PB_DS_BINARY_HEAP_ENTRY_CMP_HPP
namespace __gnu_pbds
{
namespace detail
{
/// Entry compare, primary template.
template<typename _VTp, typename Cmp_Fn, typename _Alloc, bool No_Throw>
struct entry_cmp;
/// Specialization, true.
template<typename _VTp, typename Cmp_Fn, typename _Alloc>
struct entry_cmp<_VTp, Cmp_Fn, _Alloc, true>
{
/// Compare.
typedef Cmp_Fn type;
};
/// Specialization, false.
template<typename _VTp, typename Cmp_Fn, typename _Alloc>
struct entry_cmp<_VTp, Cmp_Fn, _Alloc, false>
{
private:
typedef typename _Alloc::template rebind<_VTp> __rebind_v;
public:
typedef typename __rebind_v::other::const_pointer entry;
/// Compare plus entry.
struct type : public Cmp_Fn
{
type() { }
type(const Cmp_Fn& other) : Cmp_Fn(other) { }
bool
operator()(entry lhs, entry rhs) const
{ return Cmp_Fn::operator()(*lhs, *rhs); }
};
};
} // namespace detail
} // namespace __gnu_pbds
#endif // #ifndef PB_DS_BINARY_HEAP_ENTRY_CMP_HPP
c++/8/ext/pb_ds/detail/binary_heap_/split_join_fn_imps.hpp 0000644 00000011473 15201526705 0017443 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file binary_heap_/split_join_fn_imps.hpp
* Contains an implementation class for a binary_heap.
*/
PB_DS_CLASS_T_DEC
template<typename Pred>
void
PB_DS_CLASS_C_DEC::
split(Pred pred, PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
typedef
typename entry_pred<value_type, Pred, _Alloc, simple_value>::type
pred_t;
const size_type left = partition(pred_t(pred));
_GLIBCXX_DEBUG_ASSERT(m_size >= left);
const size_type ersd = m_size - left;
_GLIBCXX_DEBUG_ASSERT(m_size >= ersd);
const size_type new_size = resize_policy::get_new_size_for_arbitrary(left);
const size_type other_actual_size = other.get_new_size_for_arbitrary(ersd);
entry_pointer a_entries = 0;
entry_pointer a_other_entries = 0;
__try
{
a_entries = s_entry_allocator.allocate(new_size);
a_other_entries = s_entry_allocator.allocate(other_actual_size);
}
__catch(...)
{
if (a_entries != 0)
s_entry_allocator.deallocate(a_entries, new_size);
if (a_other_entries != 0)
s_entry_allocator.deallocate(a_other_entries, other_actual_size);
__throw_exception_again;
};
for (size_type i = 0; i < other.m_size; ++i)
erase_at(other.m_a_entries, i, s_no_throw_copies_ind);
_GLIBCXX_DEBUG_ASSERT(new_size >= left);
std::copy(m_a_entries, m_a_entries + left, a_entries);
std::copy(m_a_entries + left, m_a_entries + m_size, a_other_entries);
s_entry_allocator.deallocate(m_a_entries, m_actual_size);
s_entry_allocator.deallocate(other.m_a_entries, other.m_actual_size);
m_actual_size = new_size;
other.m_actual_size = other_actual_size;
m_size = left;
other.m_size = ersd;
m_a_entries = a_entries;
other.m_a_entries = a_other_entries;
make_heap();
other.make_heap();
resize_policy::notify_arbitrary(m_actual_size);
other.notify_arbitrary(other.m_actual_size);
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
join(PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
const size_type len = m_size + other.m_size;
const size_type new_size = resize_policy::get_new_size_for_arbitrary(len);
entry_pointer a_entries = 0;
entry_pointer a_other_entries = 0;
__try
{
a_entries = s_entry_allocator.allocate(new_size);
a_other_entries = s_entry_allocator.allocate(resize_policy::min_size);
}
__catch(...)
{
if (a_entries != 0)
s_entry_allocator.deallocate(a_entries, new_size);
if (a_other_entries != 0)
s_entry_allocator.deallocate(a_other_entries, resize_policy::min_size);
__throw_exception_again;
}
std::copy(m_a_entries, m_a_entries + m_size, a_entries);
std::copy(other.m_a_entries, other.m_a_entries + other.m_size,
a_entries + m_size);
s_entry_allocator.deallocate(m_a_entries, m_actual_size);
m_a_entries = a_entries;
m_size = len;
m_actual_size = new_size;
resize_policy::notify_arbitrary(new_size);
make_heap();
s_entry_allocator.deallocate(other.m_a_entries, other.m_actual_size);
other.m_a_entries = a_other_entries;
other.m_size = 0;
other.m_actual_size = resize_policy::min_size;
other.notify_arbitrary(resize_policy::min_size);
other.make_heap();
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
c++/8/ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp 0000644 00000011562 15201526705 0016574 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file binary_heap_/insert_fn_imps.hpp
* Contains an implementation class for a binary_heap.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC::
push(const_reference r_val)
{
PB_DS_ASSERT_VALID((*this))
insert_value(r_val, s_no_throw_copies_ind);
push_heap();
PB_DS_ASSERT_VALID((*this))
return point_iterator(m_a_entries);
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
insert_value(value_type val, true_type)
{
resize_for_insert_if_needed();
m_a_entries[m_size++] = val;
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
insert_value(const_reference r_val, false_type)
{
resize_for_insert_if_needed();
pointer p_new = s_value_allocator.allocate(1);
cond_dealtor_t cond(p_new);
new (p_new) value_type(r_val);
cond.set_no_action();
m_a_entries[m_size++] = p_new;
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
resize_for_insert_if_needed()
{
if (!resize_policy::resize_needed_for_grow(m_size))
{
_GLIBCXX_DEBUG_ASSERT(m_size < m_actual_size);
return;
}
const size_type new_size = resize_policy::get_new_size_for_grow();
entry_pointer new_entries = s_entry_allocator.allocate(new_size);
resize_policy::notify_grow_resize();
std::copy(m_a_entries, m_a_entries + m_size, new_entries);
s_entry_allocator.deallocate(m_a_entries, m_actual_size);
m_actual_size = new_size;
m_a_entries = new_entries;
make_heap();
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
modify(point_iterator it, const_reference r_new_val)
{
PB_DS_ASSERT_VALID((*this))
swap_value_imp(it.m_p_e, r_new_val, s_no_throw_copies_ind);
fix(it.m_p_e);
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
fix(entry_pointer p_e)
{
size_type i = p_e - m_a_entries;
if (i > 0 && entry_cmp::operator()(m_a_entries[parent(i)], m_a_entries[i]))
{
size_type parent_i = parent(i);
while (i > 0
&& entry_cmp::operator()(m_a_entries[parent_i], m_a_entries[i]))
{
std::swap(m_a_entries[i], m_a_entries[parent_i]);
i = parent_i;
parent_i = parent(i);
}
PB_DS_ASSERT_VALID((*this))
return;
}
while (i < m_size)
{
const size_type lchild_i = left_child(i);
const size_type rchild_i = right_child(i);
_GLIBCXX_DEBUG_ASSERT(rchild_i > lchild_i);
const bool smaller_than_lchild = lchild_i < m_size &&
entry_cmp::operator()(m_a_entries[i], m_a_entries[lchild_i]);
const bool smaller_than_rchild = rchild_i < m_size &&
entry_cmp::operator()(m_a_entries[i], m_a_entries[rchild_i]);
const bool swap_with_rchild = smaller_than_rchild && (!smaller_than_lchild || entry_cmp::operator()(m_a_entries[lchild_i], m_a_entries[rchild_i]));
const bool swap_with_lchild = !swap_with_rchild && smaller_than_lchild;
if (swap_with_lchild)
{
std::swap(m_a_entries[i], m_a_entries[lchild_i]);
i = lchild_i;
}
else if (swap_with_rchild)
{
std::swap(m_a_entries[i], m_a_entries[rchild_i]);
i = rchild_i;
}
else
i = m_size;
}
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
swap_value_imp(entry_pointer p_e, value_type new_val, true_type)
{ *p_e = new_val; }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
swap_value_imp(entry_pointer p_e, const_reference r_new_val, false_type)
{
value_type tmp(r_new_val);
(*p_e)->swap(tmp);
}
c++/8/ext/pb_ds/detail/binary_heap_/erase_fn_imps.hpp 0000644 00000012600 15201526705 0016361 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file binary_heap_/erase_fn_imps.hpp
* Contains an implementation class for a binary_heap.
*/
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
clear()
{
for (size_type i = 0; i < m_size; ++i)
erase_at(m_a_entries, i, s_no_throw_copies_ind);
__try
{
const size_type new_size = resize_policy::get_new_size_for_arbitrary(0);
entry_pointer new_entries = s_entry_allocator.allocate(new_size);
resize_policy::notify_arbitrary(new_size);
s_entry_allocator.deallocate(m_a_entries, m_actual_size);
m_actual_size = new_size;
m_a_entries = new_entries;
}
__catch(...)
{ }
m_size = 0;
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
erase_at(entry_pointer a_entries, size_type i, false_type)
{
a_entries[i]->~value_type();
s_value_allocator.deallocate(a_entries[i], 1);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
erase_at(entry_pointer, size_type, true_type)
{ }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
pop()
{
PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!empty());
pop_heap();
erase_at(m_a_entries, m_size - 1, s_no_throw_copies_ind);
resize_for_erase_if_needed();
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
--m_size;
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
template<typename Pred>
typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
erase_if(Pred pred)
{
PB_DS_ASSERT_VALID((*this))
typedef typename entry_pred<value_type, Pred, _Alloc, simple_value>::type
pred_t;
const size_type left = partition(pred_t(pred));
_GLIBCXX_DEBUG_ASSERT(m_size >= left);
const size_type ersd = m_size - left;
for (size_type i = left; i < m_size; ++i)
erase_at(m_a_entries, i, s_no_throw_copies_ind);
__try
{
const size_type new_size =
resize_policy::get_new_size_for_arbitrary(left);
entry_pointer new_entries = s_entry_allocator.allocate(new_size);
std::copy(m_a_entries, m_a_entries + left, new_entries);
s_entry_allocator.deallocate(m_a_entries, m_actual_size);
m_actual_size = new_size;
resize_policy::notify_arbitrary(m_actual_size);
}
__catch(...)
{ };
m_size = left;
make_heap();
PB_DS_ASSERT_VALID((*this))
return ersd;
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
erase(point_iterator it)
{
PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!empty());
const size_type fix_pos = it.m_p_e - m_a_entries;
std::swap(*it.m_p_e, m_a_entries[m_size - 1]);
erase_at(m_a_entries, m_size - 1, s_no_throw_copies_ind);
resize_for_erase_if_needed();
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
--m_size;
_GLIBCXX_DEBUG_ASSERT(fix_pos <= m_size);
if (fix_pos != m_size)
fix(m_a_entries + fix_pos);
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
resize_for_erase_if_needed()
{
if (!resize_policy::resize_needed_for_shrink(m_size))
return;
__try
{
const size_type new_size = resize_policy::get_new_size_for_shrink();
entry_pointer new_entries = s_entry_allocator.allocate(new_size);
resize_policy::notify_shrink_resize();
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
std::copy(m_a_entries, m_a_entries + m_size - 1, new_entries);
s_entry_allocator.deallocate(m_a_entries, m_actual_size);
m_actual_size = new_size;
m_a_entries = new_entries;
}
__catch(...)
{ }
}
PB_DS_CLASS_T_DEC
template<typename Pred>
typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
partition(Pred pred)
{
size_type left = 0;
size_type right = m_size - 1;
while (right + 1 != left)
{
_GLIBCXX_DEBUG_ASSERT(left <= m_size);
if (!pred(m_a_entries[left]))
++left;
else if (pred(m_a_entries[right]))
--right;
else
{
_GLIBCXX_DEBUG_ASSERT(left < right);
std::swap(m_a_entries[left], m_a_entries[right]);
++left;
--right;
}
}
return left;
}
c++/8/ext/pb_ds/detail/binary_heap_/trace_fn_imps.hpp 0000644 00000004617 15201526705 0016371 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file binary_heap_/trace_fn_imps.hpp
* Contains an implementation class for a binary_heap.
*/
#ifdef PB_DS_BINARY_HEAP_TRACE_
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
trace() const
{
std::cerr << this << std::endl;
std::cerr << m_a_entries << std::endl;
for (size_type i = 0; i < m_size; ++i)
trace_entry(m_a_entries[i], s_no_throw_copies_ind);
std::cerr << std::endl;
std::cerr << "size = " << m_size << " " << "actual_size = " << m_actual_size << std::endl;
resize_policy::trace();
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
trace_entry(const entry& r_e, false_type) const
{
std::cout << r_e << " " <<* r_e << std::endl;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
trace_entry(const entry& r_e, true_type) const
{
std::cout << r_e << std::endl;
}
#endif // #ifdef PB_DS_BINARY_HEAP_TRACE_
c++/8/ext/pb_ds/detail/binary_heap_/const_iterator.hpp 0000644 00000010362 15201526705 0016611 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file binary_heap_/const_iterator.hpp
* Contains an iterator class returned by the table's const find and insert
* methods.
*/
#ifndef PB_DS_BINARY_HEAP_CONST_ITERATOR_HPP
#define PB_DS_BINARY_HEAP_CONST_ITERATOR_HPP
#include <ext/pb_ds/detail/binary_heap_/point_const_iterator.hpp>
#include <debug/debug.h>
namespace __gnu_pbds
{
namespace detail
{
#define PB_DS_BIN_HEAP_CIT_BASE \
binary_heap_point_const_iterator_<Value_Type, Entry, Simple, _Alloc>
/// Const point-type iterator.
template<typename Value_Type,
typename Entry,
bool Simple,
typename _Alloc>
class binary_heap_const_iterator_ : public PB_DS_BIN_HEAP_CIT_BASE
{
private:
typedef PB_DS_BIN_HEAP_CIT_BASE base_type;
typedef typename base_type::entry_pointer entry_pointer;
public:
/// Category.
typedef std::forward_iterator_tag iterator_category;
/// Difference type.
typedef typename _Alloc::difference_type difference_type;
/// Iterator's value type.
typedef typename base_type::value_type value_type;
/// Iterator's pointer type.
typedef typename base_type::pointer pointer;
/// Iterator's const pointer type.
typedef typename base_type::const_pointer const_pointer;
/// Iterator's reference type.
typedef typename base_type::reference reference;
/// Iterator's const reference type.
typedef typename base_type::const_reference const_reference;
inline
binary_heap_const_iterator_(entry_pointer p_e) : base_type(p_e)
{ }
/// Default constructor.
inline
binary_heap_const_iterator_()
{ }
/// Copy constructor.
inline
binary_heap_const_iterator_(const binary_heap_const_iterator_& other)
: base_type(other)
{ }
/// Compares content to a different iterator object.
inline bool
operator==(const binary_heap_const_iterator_& other) const
{ return base_type::m_p_e == other.m_p_e; }
/// Compares content (negatively) to a different iterator object.
inline bool
operator!=(const binary_heap_const_iterator_& other) const
{ return base_type::m_p_e != other.m_p_e; }
inline binary_heap_const_iterator_&
operator++()
{
_GLIBCXX_DEBUG_ASSERT(base_type::m_p_e != 0);
inc();
return *this;
}
inline binary_heap_const_iterator_
operator++(int)
{
binary_heap_const_iterator_ ret_it(base_type::m_p_e);
operator++();
return ret_it;
}
private:
void
inc()
{ ++base_type::m_p_e; }
};
#undef PB_DS_BIN_HEAP_CIT_BASE
} // namespace detail
} // namespace __gnu_pbds
#endif
c++/8/ext/pb_ds/detail/binary_heap_/entry_pred.hpp 0000644 00000005341 15201526705 0015726 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file binary_heap_/entry_pred.hpp
* Contains an implementation class for a binary_heap.
*/
#ifndef PB_DS_BINARY_HEAP_ENTRY_PRED_HPP
#define PB_DS_BINARY_HEAP_ENTRY_PRED_HPP
namespace __gnu_pbds
{
namespace detail
{
/// Entry predicate primary class template.
template<typename _VTp, typename Pred, typename _Alloc, bool No_Throw>
struct entry_pred;
/// Specialization, true.
template<typename _VTp, typename Pred, typename _Alloc>
struct entry_pred<_VTp, Pred, _Alloc, true>
{
typedef Pred type;
};
/// Specialization, false.
template<typename _VTp, typename Pred, typename _Alloc>
struct entry_pred<_VTp, Pred, _Alloc, false>
{
private:
typedef typename _Alloc::template rebind<_VTp> __rebind_v;
public:
typedef typename __rebind_v::other::const_pointer entry;
struct type : public Pred
{
inline
type() { }
inline
type(const Pred& other) : Pred(other) { }
inline bool
operator()(entry p_v) const
{ return Pred::operator()(*p_v); }
};
};
} // namespace detail
} // namespace __gnu_pbds
#endif // #ifndef PB_DS_BINARY_HEAP_ENTRY_PRED_HPP
c++/8/ext/pb_ds/detail/binary_heap_/policy_access_fn_imps.hpp 0000644 00000003556 15201526705 0020114 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file binary_heap_/policy_access_fn_imps.hpp
* Contains an implementation class for a binary_heap.
*/
PB_DS_CLASS_T_DEC
Cmp_Fn&
PB_DS_CLASS_C_DEC::
get_cmp_fn()
{
return (*this);
}
PB_DS_CLASS_T_DEC
const Cmp_Fn&
PB_DS_CLASS_C_DEC::
get_cmp_fn() const
{
return (*this);
}
c++/8/ext/pb_ds/tree_policy.hpp 0000644 00000012711 15201526705 0012206 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file tree_policy.hpp
* Contains tree-related policies.
*/
#ifndef PB_DS_TREE_POLICY_HPP
#define PB_DS_TREE_POLICY_HPP
#include <bits/c++config.h>
#include <iterator>
#include <ext/pb_ds/detail/type_utils.hpp>
#include <ext/pb_ds/detail/branch_policy/branch_policy.hpp>
namespace __gnu_pbds
{
#define PB_DS_CLASS_T_DEC \
template<typename Node_CItr, typename Node_Itr, typename Cmp_Fn, \
typename _Alloc>
#define PB_DS_CLASS_C_DEC \
tree_order_statistics_node_update<Node_CItr, Node_Itr, Cmp_Fn, _Alloc>
#define PB_DS_BRANCH_POLICY_BASE \
detail::branch_policy<Node_CItr, Node_Itr, _Alloc>
/// Functor updating ranks of entrees.
template<typename Node_CItr, typename Node_Itr,
typename Cmp_Fn, typename _Alloc>
class tree_order_statistics_node_update : private PB_DS_BRANCH_POLICY_BASE
{
private:
typedef PB_DS_BRANCH_POLICY_BASE base_type;
public:
typedef Cmp_Fn cmp_fn;
typedef _Alloc allocator_type;
typedef typename allocator_type::size_type size_type;
typedef typename base_type::key_type key_type;
typedef typename base_type::key_const_reference key_const_reference;
typedef size_type metadata_type;
typedef Node_CItr node_const_iterator;
typedef Node_Itr node_iterator;
typedef typename node_const_iterator::value_type const_iterator;
typedef typename node_iterator::value_type iterator;
/// Finds an entry by __order. Returns a const_iterator to the
/// entry with the __order order, or a const_iterator to the
/// container object's end if order is at least the size of the
/// container object.
inline const_iterator
find_by_order(size_type) const;
/// Finds an entry by __order. Returns an iterator to the entry
/// with the __order order, or an iterator to the container
/// object's end if order is at least the size of the container
/// object.
inline iterator
find_by_order(size_type);
/// Returns the order of a key within a sequence. For exapmle, if
/// r_key is the smallest key, this method will return 0; if r_key
/// is a key between the smallest and next key, this method will
/// return 1; if r_key is a key larger than the largest key, this
/// method will return the size of r_c.
inline size_type
order_of_key(key_const_reference) const;
private:
/// Const reference to the container's value-type.
typedef typename base_type::const_reference const_reference;
/// Const pointer to the container's value-type.
typedef typename base_type::const_pointer const_pointer;
typedef typename _Alloc::template rebind<metadata_type>::other __rebind_m;
/// Const metadata reference.
typedef typename __rebind_m::const_reference metadata_const_reference;
/// Metadata reference.
typedef typename __rebind_m::reference metadata_reference;
/// Returns the node_const_iterator associated with the tree's root node.
virtual node_const_iterator
node_begin() const = 0;
/// Returns the node_iterator associated with the tree's root node.
virtual node_iterator
node_begin() = 0;
/// Returns the node_const_iterator associated with a just-after leaf node.
virtual node_const_iterator
node_end() const = 0;
/// Returns the node_iterator associated with a just-after leaf node.
virtual node_iterator
node_end() = 0;
/// Access to the cmp_fn object.
virtual cmp_fn&
get_cmp_fn() = 0;
protected:
/// Updates the rank of a node through a node_iterator node_it;
/// end_nd_it is the end node iterator.
inline void
operator()(node_iterator, node_const_iterator) const;
virtual
~tree_order_statistics_node_update();
};
#include <ext/pb_ds/detail/tree_policy/order_statistics_imp.hpp>
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_BRANCH_POLICY_BASE
} // namespace __gnu_pbds
#endif
c++/8/ext/stdio_sync_filebuf.h 0000644 00000021116 15201526705 0012112 0 ustar 00 // Iostreams wrapper for stdio FILE* -*- C++ -*-
// Copyright (C) 2003-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file ext/stdio_sync_filebuf.h
* This file is a GNU extension to the Standard C++ Library.
*/
#ifndef _STDIO_SYNC_FILEBUF_H
#define _STDIO_SYNC_FILEBUF_H 1
#pragma GCC system_header
#include <streambuf>
#include <unistd.h>
#include <cstdio>
#include <bits/c++io.h> // For __c_file
#include <bits/move.h> // For __exchange
#ifdef _GLIBCXX_USE_WCHAR_T
#include <cwchar>
#endif
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @brief Provides a layer of compatibility for C.
* @ingroup io
*
* This GNU extension provides extensions for working with standard
* C FILE*'s. It must be instantiated by the user with the type of
* character used in the file stream, e.g., stdio_filebuf<char>.
*/
template<typename _CharT, typename _Traits = std::char_traits<_CharT> >
class stdio_sync_filebuf : public std::basic_streambuf<_CharT, _Traits>
{
public:
// Types:
typedef _CharT char_type;
typedef _Traits traits_type;
typedef typename traits_type::int_type int_type;
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
private:
typedef std::basic_streambuf<_CharT, _Traits> __streambuf_type;
// Underlying stdio FILE
std::__c_file* _M_file;
// Last character gotten. This is used when pbackfail is
// called from basic_streambuf::sungetc()
int_type _M_unget_buf;
public:
explicit
stdio_sync_filebuf(std::__c_file* __f)
: _M_file(__f), _M_unget_buf(traits_type::eof())
{ }
#if __cplusplus >= 201103L
stdio_sync_filebuf(stdio_sync_filebuf&& __fb) noexcept
: __streambuf_type(std::move(__fb)),
_M_file(__fb._M_file), _M_unget_buf(__fb._M_unget_buf)
{
__fb._M_file = nullptr;
__fb._M_unget_buf = traits_type::eof();
}
stdio_sync_filebuf&
operator=(stdio_sync_filebuf&& __fb) noexcept
{
__streambuf_type::operator=(__fb);
_M_file = std::__exchange(__fb._M_file, nullptr);
_M_unget_buf = std::__exchange(__fb._M_unget_buf, traits_type::eof());
return *this;
}
void
swap(stdio_sync_filebuf& __fb)
{
__streambuf_type::swap(__fb);
std::swap(_M_file, __fb._M_file);
std::swap(_M_unget_buf, __fb._M_unget_buf);
}
#endif
/**
* @return The underlying FILE*.
*
* This function can be used to access the underlying C file pointer.
* Note that there is no way for the library to track what you do
* with the file, so be careful.
*/
std::__c_file*
file() { return this->_M_file; }
protected:
int_type
syncgetc();
int_type
syncungetc(int_type __c);
int_type
syncputc(int_type __c);
virtual int_type
underflow()
{
int_type __c = this->syncgetc();
return this->syncungetc(__c);
}
virtual int_type
uflow()
{
// Store the gotten character in case we need to unget it.
_M_unget_buf = this->syncgetc();
return _M_unget_buf;
}
virtual int_type
pbackfail(int_type __c = traits_type::eof())
{
int_type __ret;
const int_type __eof = traits_type::eof();
// Check if the unget or putback was requested
if (traits_type::eq_int_type(__c, __eof)) // unget
{
if (!traits_type::eq_int_type(_M_unget_buf, __eof))
__ret = this->syncungetc(_M_unget_buf);
else // buffer invalid, fail.
__ret = __eof;
}
else // putback
__ret = this->syncungetc(__c);
// The buffered character is no longer valid, discard it.
_M_unget_buf = __eof;
return __ret;
}
virtual std::streamsize
xsgetn(char_type* __s, std::streamsize __n);
virtual int_type
overflow(int_type __c = traits_type::eof())
{
int_type __ret;
if (traits_type::eq_int_type(__c, traits_type::eof()))
{
if (std::fflush(_M_file))
__ret = traits_type::eof();
else
__ret = traits_type::not_eof(__c);
}
else
__ret = this->syncputc(__c);
return __ret;
}
virtual std::streamsize
xsputn(const char_type* __s, std::streamsize __n);
virtual int
sync()
{ return std::fflush(_M_file); }
virtual std::streampos
seekoff(std::streamoff __off, std::ios_base::seekdir __dir,
std::ios_base::openmode = std::ios_base::in | std::ios_base::out)
{
std::streampos __ret(std::streamoff(-1));
int __whence;
if (__dir == std::ios_base::beg)
__whence = SEEK_SET;
else if (__dir == std::ios_base::cur)
__whence = SEEK_CUR;
else
__whence = SEEK_END;
#ifdef _GLIBCXX_USE_LFS
if (!fseeko64(_M_file, __off, __whence))
__ret = std::streampos(ftello64(_M_file));
#else
if (!fseek(_M_file, __off, __whence))
__ret = std::streampos(std::ftell(_M_file));
#endif
return __ret;
}
virtual std::streampos
seekpos(std::streampos __pos,
std::ios_base::openmode __mode =
std::ios_base::in | std::ios_base::out)
{ return seekoff(std::streamoff(__pos), std::ios_base::beg, __mode); }
};
template<>
inline stdio_sync_filebuf<char>::int_type
stdio_sync_filebuf<char>::syncgetc()
{ return std::getc(_M_file); }
template<>
inline stdio_sync_filebuf<char>::int_type
stdio_sync_filebuf<char>::syncungetc(int_type __c)
{ return std::ungetc(__c, _M_file); }
template<>
inline stdio_sync_filebuf<char>::int_type
stdio_sync_filebuf<char>::syncputc(int_type __c)
{ return std::putc(__c, _M_file); }
template<>
inline std::streamsize
stdio_sync_filebuf<char>::xsgetn(char* __s, std::streamsize __n)
{
std::streamsize __ret = std::fread(__s, 1, __n, _M_file);
if (__ret > 0)
_M_unget_buf = traits_type::to_int_type(__s[__ret - 1]);
else
_M_unget_buf = traits_type::eof();
return __ret;
}
template<>
inline std::streamsize
stdio_sync_filebuf<char>::xsputn(const char* __s, std::streamsize __n)
{ return std::fwrite(__s, 1, __n, _M_file); }
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
inline stdio_sync_filebuf<wchar_t>::int_type
stdio_sync_filebuf<wchar_t>::syncgetc()
{ return std::getwc(_M_file); }
template<>
inline stdio_sync_filebuf<wchar_t>::int_type
stdio_sync_filebuf<wchar_t>::syncungetc(int_type __c)
{ return std::ungetwc(__c, _M_file); }
template<>
inline stdio_sync_filebuf<wchar_t>::int_type
stdio_sync_filebuf<wchar_t>::syncputc(int_type __c)
{ return std::putwc(__c, _M_file); }
template<>
inline std::streamsize
stdio_sync_filebuf<wchar_t>::xsgetn(wchar_t* __s, std::streamsize __n)
{
std::streamsize __ret = 0;
const int_type __eof = traits_type::eof();
while (__n--)
{
int_type __c = this->syncgetc();
if (traits_type::eq_int_type(__c, __eof))
break;
__s[__ret] = traits_type::to_char_type(__c);
++__ret;
}
if (__ret > 0)
_M_unget_buf = traits_type::to_int_type(__s[__ret - 1]);
else
_M_unget_buf = traits_type::eof();
return __ret;
}
template<>
inline std::streamsize
stdio_sync_filebuf<wchar_t>::xsputn(const wchar_t* __s,
std::streamsize __n)
{
std::streamsize __ret = 0;
const int_type __eof = traits_type::eof();
while (__n--)
{
if (traits_type::eq_int_type(this->syncputc(*__s++), __eof))
break;
++__ret;
}
return __ret;
}
#endif
#if _GLIBCXX_EXTERN_TEMPLATE
extern template class stdio_sync_filebuf<char>;
#ifdef _GLIBCXX_USE_WCHAR_T
extern template class stdio_sync_filebuf<wchar_t>;
#endif
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/ext/numeric 0000644 00000011173 15201526705 0007456 0 ustar 00 // Numeric extensions -*- C++ -*-
// Copyright (C) 2002-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1996
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file ext/numeric
* This file is a GNU extension to the Standard C++ Library (possibly
* containing extensions from the HP/SGI STL subset).
*/
#ifndef _EXT_NUMERIC
#define _EXT_NUMERIC 1
#pragma GCC system_header
#include <bits/concept_check.h>
#include <numeric>
#include <ext/functional> // For identity_element
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Returns __x ** __n, where __n >= 0. _Note that "multiplication"
// is required to be associative, but not necessarily commutative.
template<typename _Tp, typename _Integer, typename _MonoidOperation>
_Tp
__power(_Tp __x, _Integer __n, _MonoidOperation __monoid_op)
{
if (__n == 0)
return identity_element(__monoid_op);
else
{
while ((__n & 1) == 0)
{
__n >>= 1;
__x = __monoid_op(__x, __x);
}
_Tp __result = __x;
__n >>= 1;
while (__n != 0)
{
__x = __monoid_op(__x, __x);
if ((__n & 1) != 0)
__result = __monoid_op(__result, __x);
__n >>= 1;
}
return __result;
}
}
template<typename _Tp, typename _Integer>
inline _Tp
__power(_Tp __x, _Integer __n)
{ return __power(__x, __n, std::multiplies<_Tp>()); }
/**
* This is an SGI extension.
* @ingroup SGIextensions
* @doctodo
*/
// Alias for the internal name __power. Note that power is an extension,
// not part of the C++ standard.
template<typename _Tp, typename _Integer, typename _MonoidOperation>
inline _Tp
power(_Tp __x, _Integer __n, _MonoidOperation __monoid_op)
{ return __power(__x, __n, __monoid_op); }
/**
* This is an SGI extension.
* @ingroup SGIextensions
* @doctodo
*/
template<typename _Tp, typename _Integer>
inline _Tp
power(_Tp __x, _Integer __n)
{ return __power(__x, __n); }
#if __cplusplus >= 201103L
using std::iota;
#else
/**
* This is an SGI extension.
* @ingroup SGIextensions
* @doctodo
*/
// iota is not part of the C++ standard. It is an extension.
template<typename _ForwardIter, typename _Tp>
void
iota(_ForwardIter __first, _ForwardIter __last, _Tp __value)
{
// concept requirements
__glibcxx_function_requires(_Mutable_ForwardIteratorConcept<_ForwardIter>)
__glibcxx_function_requires(_ConvertibleConcept<_Tp,
typename std::iterator_traits<_ForwardIter>::value_type>)
while (__first != __last)
*__first++ = __value++;
}
#endif // C++11
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/ext/codecvt_specializations.h 0000644 00000037741 15201526705 0013163 0 ustar 00 // Locale support (codecvt) -*- C++ -*-
// Copyright (C) 2000-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 22.2.1.5 Template class codecvt
//
// Written by Benjamin Kosnik <bkoz@redhat.com>
/** @file ext/codecvt_specializations.h
* This file is a GNU extension to the Standard C++ Library.
*/
#ifndef _EXT_CODECVT_SPECIALIZATIONS_H
#define _EXT_CODECVT_SPECIALIZATIONS_H 1
#include <bits/c++config.h>
#include <locale>
#include <iconv.h>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_BEGIN_NAMESPACE_CXX11
/// Extension to use iconv for dealing with character encodings.
// This includes conversions and comparisons between various character
// sets. This object encapsulates data that may need to be shared between
// char_traits, codecvt and ctype.
class encoding_state
{
public:
// Types:
// NB: A conversion descriptor subsumes and enhances the
// functionality of a simple state type such as mbstate_t.
typedef iconv_t descriptor_type;
protected:
// Name of internal character set encoding.
std::string _M_int_enc;
// Name of external character set encoding.
std::string _M_ext_enc;
// Conversion descriptor between external encoding to internal encoding.
descriptor_type _M_in_desc;
// Conversion descriptor between internal encoding to external encoding.
descriptor_type _M_out_desc;
// The byte-order marker for the external encoding, if necessary.
int _M_ext_bom;
// The byte-order marker for the internal encoding, if necessary.
int _M_int_bom;
// Number of external bytes needed to construct one complete
// character in the internal encoding.
// NB: -1 indicates variable, or stateful, encodings.
int _M_bytes;
public:
explicit
encoding_state()
: _M_in_desc(0), _M_out_desc(0), _M_ext_bom(0), _M_int_bom(0), _M_bytes(0)
{ }
explicit
encoding_state(const char* __int, const char* __ext,
int __ibom = 0, int __ebom = 0, int __bytes = 1)
: _M_int_enc(__int), _M_ext_enc(__ext), _M_in_desc(0), _M_out_desc(0),
_M_ext_bom(__ebom), _M_int_bom(__ibom), _M_bytes(__bytes)
{ init(); }
// 21.1.2 traits typedefs
// p4
// typedef STATE_T state_type
// requires: state_type shall meet the requirements of
// CopyConstructible types (20.1.3)
// NB: This does not preserve the actual state of the conversion
// descriptor member, but it does duplicate the encoding
// information.
encoding_state(const encoding_state& __obj) : _M_in_desc(0), _M_out_desc(0)
{ construct(__obj); }
// Need assignment operator as well.
encoding_state&
operator=(const encoding_state& __obj)
{
construct(__obj);
return *this;
}
~encoding_state()
{ destroy(); }
bool
good() const throw()
{
const descriptor_type __err = (iconv_t)(-1);
bool __test = _M_in_desc && _M_in_desc != __err;
__test &= _M_out_desc && _M_out_desc != __err;
return __test;
}
int
character_ratio() const
{ return _M_bytes; }
const std::string
internal_encoding() const
{ return _M_int_enc; }
int
internal_bom() const
{ return _M_int_bom; }
const std::string
external_encoding() const
{ return _M_ext_enc; }
int
external_bom() const
{ return _M_ext_bom; }
const descriptor_type&
in_descriptor() const
{ return _M_in_desc; }
const descriptor_type&
out_descriptor() const
{ return _M_out_desc; }
protected:
void
init()
{
const descriptor_type __err = (iconv_t)(-1);
const bool __have_encodings = _M_int_enc.size() && _M_ext_enc.size();
if (!_M_in_desc && __have_encodings)
{
_M_in_desc = iconv_open(_M_int_enc.c_str(), _M_ext_enc.c_str());
if (_M_in_desc == __err)
std::__throw_runtime_error(__N("encoding_state::_M_init "
"creating iconv input descriptor failed"));
}
if (!_M_out_desc && __have_encodings)
{
_M_out_desc = iconv_open(_M_ext_enc.c_str(), _M_int_enc.c_str());
if (_M_out_desc == __err)
std::__throw_runtime_error(__N("encoding_state::_M_init "
"creating iconv output descriptor failed"));
}
}
void
construct(const encoding_state& __obj)
{
destroy();
_M_int_enc = __obj._M_int_enc;
_M_ext_enc = __obj._M_ext_enc;
_M_ext_bom = __obj._M_ext_bom;
_M_int_bom = __obj._M_int_bom;
_M_bytes = __obj._M_bytes;
init();
}
void
destroy() throw()
{
const descriptor_type __err = (iconv_t)(-1);
if (_M_in_desc && _M_in_desc != __err)
{
iconv_close(_M_in_desc);
_M_in_desc = 0;
}
if (_M_out_desc && _M_out_desc != __err)
{
iconv_close(_M_out_desc);
_M_out_desc = 0;
}
}
};
/// encoding_char_traits
// Custom traits type with encoding_state for the state type, and the
// associated fpos<encoding_state> for the position type, all other
// bits equivalent to the required char_traits instantiations.
template<typename _CharT>
struct encoding_char_traits
: public std::char_traits<_CharT>
{
typedef encoding_state state_type;
typedef typename std::fpos<state_type> pos_type;
};
_GLIBCXX_END_NAMESPACE_CXX11
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using __gnu_cxx::encoding_state;
/// codecvt<InternT, _ExternT, encoding_state> specialization.
// This partial specialization takes advantage of iconv to provide
// code conversions between a large number of character encodings.
template<typename _InternT, typename _ExternT>
class codecvt<_InternT, _ExternT, encoding_state>
: public __codecvt_abstract_base<_InternT, _ExternT, encoding_state>
{
public:
// Types:
typedef codecvt_base::result result;
typedef _InternT intern_type;
typedef _ExternT extern_type;
typedef __gnu_cxx::encoding_state state_type;
typedef state_type::descriptor_type descriptor_type;
// Data Members:
static locale::id id;
explicit
codecvt(size_t __refs = 0)
: __codecvt_abstract_base<intern_type, extern_type, state_type>(__refs)
{ }
explicit
codecvt(state_type& __enc, size_t __refs = 0)
: __codecvt_abstract_base<intern_type, extern_type, state_type>(__refs)
{ }
protected:
virtual
~codecvt() { }
virtual result
do_out(state_type& __state, const intern_type* __from,
const intern_type* __from_end, const intern_type*& __from_next,
extern_type* __to, extern_type* __to_end,
extern_type*& __to_next) const;
virtual result
do_unshift(state_type& __state, extern_type* __to,
extern_type* __to_end, extern_type*& __to_next) const;
virtual result
do_in(state_type& __state, const extern_type* __from,
const extern_type* __from_end, const extern_type*& __from_next,
intern_type* __to, intern_type* __to_end,
intern_type*& __to_next) const;
virtual int
do_encoding() const throw();
virtual bool
do_always_noconv() const throw();
virtual int
do_length(state_type&, const extern_type* __from,
const extern_type* __end, size_t __max) const;
virtual int
do_max_length() const throw();
};
template<typename _InternT, typename _ExternT>
locale::id
codecvt<_InternT, _ExternT, encoding_state>::id;
// This adaptor works around the signature problems of the second
// argument to iconv(): SUSv2 and others use 'const char**', but glibc 2.2
// uses 'char**', which matches the POSIX 1003.1-2001 standard.
// Using this adaptor, g++ will do the work for us.
template<typename _Tp>
inline size_t
__iconv_adaptor(size_t(*__func)(iconv_t, _Tp, size_t*, char**, size_t*),
iconv_t __cd, char** __inbuf, size_t* __inbytes,
char** __outbuf, size_t* __outbytes)
{ return __func(__cd, (_Tp)__inbuf, __inbytes, __outbuf, __outbytes); }
template<typename _InternT, typename _ExternT>
codecvt_base::result
codecvt<_InternT, _ExternT, encoding_state>::
do_out(state_type& __state, const intern_type* __from,
const intern_type* __from_end, const intern_type*& __from_next,
extern_type* __to, extern_type* __to_end,
extern_type*& __to_next) const
{
result __ret = codecvt_base::error;
if (__state.good())
{
const descriptor_type& __desc = __state.out_descriptor();
const size_t __fmultiple = sizeof(intern_type);
size_t __fbytes = __fmultiple * (__from_end - __from);
const size_t __tmultiple = sizeof(extern_type);
size_t __tbytes = __tmultiple * (__to_end - __to);
// Argument list for iconv specifies a byte sequence. Thus,
// all to/from arrays must be brutally casted to char*.
char* __cto = reinterpret_cast<char*>(__to);
char* __cfrom;
size_t __conv;
// Some encodings need a byte order marker as the first item
// in the byte stream, to designate endian-ness. The default
// value for the byte order marker is NULL, so if this is
// the case, it's not necessary and we can just go on our
// merry way.
int __int_bom = __state.internal_bom();
if (__int_bom)
{
size_t __size = __from_end - __from;
intern_type* __cfixed = static_cast<intern_type*>
(__builtin_alloca(sizeof(intern_type) * (__size + 1)));
__cfixed[0] = static_cast<intern_type>(__int_bom);
char_traits<intern_type>::copy(__cfixed + 1, __from, __size);
__cfrom = reinterpret_cast<char*>(__cfixed);
__conv = __iconv_adaptor(iconv, __desc, &__cfrom,
&__fbytes, &__cto, &__tbytes);
}
else
{
intern_type* __cfixed = const_cast<intern_type*>(__from);
__cfrom = reinterpret_cast<char*>(__cfixed);
__conv = __iconv_adaptor(iconv, __desc, &__cfrom, &__fbytes,
&__cto, &__tbytes);
}
if (__conv != size_t(-1))
{
__from_next = reinterpret_cast<const intern_type*>(__cfrom);
__to_next = reinterpret_cast<extern_type*>(__cto);
__ret = codecvt_base::ok;
}
else
{
if (__fbytes < __fmultiple * (__from_end - __from))
{
__from_next = reinterpret_cast<const intern_type*>(__cfrom);
__to_next = reinterpret_cast<extern_type*>(__cto);
__ret = codecvt_base::partial;
}
else
__ret = codecvt_base::error;
}
}
return __ret;
}
template<typename _InternT, typename _ExternT>
codecvt_base::result
codecvt<_InternT, _ExternT, encoding_state>::
do_unshift(state_type& __state, extern_type* __to,
extern_type* __to_end, extern_type*& __to_next) const
{
result __ret = codecvt_base::error;
if (__state.good())
{
const descriptor_type& __desc = __state.in_descriptor();
const size_t __tmultiple = sizeof(intern_type);
size_t __tlen = __tmultiple * (__to_end - __to);
// Argument list for iconv specifies a byte sequence. Thus,
// all to/from arrays must be brutally casted to char*.
char* __cto = reinterpret_cast<char*>(__to);
size_t __conv = __iconv_adaptor(iconv,__desc, 0, 0,
&__cto, &__tlen);
if (__conv != size_t(-1))
{
__to_next = reinterpret_cast<extern_type*>(__cto);
if (__tlen == __tmultiple * (__to_end - __to))
__ret = codecvt_base::noconv;
else if (__tlen == 0)
__ret = codecvt_base::ok;
else
__ret = codecvt_base::partial;
}
else
__ret = codecvt_base::error;
}
return __ret;
}
template<typename _InternT, typename _ExternT>
codecvt_base::result
codecvt<_InternT, _ExternT, encoding_state>::
do_in(state_type& __state, const extern_type* __from,
const extern_type* __from_end, const extern_type*& __from_next,
intern_type* __to, intern_type* __to_end,
intern_type*& __to_next) const
{
result __ret = codecvt_base::error;
if (__state.good())
{
const descriptor_type& __desc = __state.in_descriptor();
const size_t __fmultiple = sizeof(extern_type);
size_t __flen = __fmultiple * (__from_end - __from);
const size_t __tmultiple = sizeof(intern_type);
size_t __tlen = __tmultiple * (__to_end - __to);
// Argument list for iconv specifies a byte sequence. Thus,
// all to/from arrays must be brutally casted to char*.
char* __cto = reinterpret_cast<char*>(__to);
char* __cfrom;
size_t __conv;
// Some encodings need a byte order marker as the first item
// in the byte stream, to designate endian-ness. The default
// value for the byte order marker is NULL, so if this is
// the case, it's not necessary and we can just go on our
// merry way.
int __ext_bom = __state.external_bom();
if (__ext_bom)
{
size_t __size = __from_end - __from;
extern_type* __cfixed = static_cast<extern_type*>
(__builtin_alloca(sizeof(extern_type) * (__size + 1)));
__cfixed[0] = static_cast<extern_type>(__ext_bom);
char_traits<extern_type>::copy(__cfixed + 1, __from, __size);
__cfrom = reinterpret_cast<char*>(__cfixed);
__conv = __iconv_adaptor(iconv, __desc, &__cfrom,
&__flen, &__cto, &__tlen);
}
else
{
extern_type* __cfixed = const_cast<extern_type*>(__from);
__cfrom = reinterpret_cast<char*>(__cfixed);
__conv = __iconv_adaptor(iconv, __desc, &__cfrom,
&__flen, &__cto, &__tlen);
}
if (__conv != size_t(-1))
{
__from_next = reinterpret_cast<const extern_type*>(__cfrom);
__to_next = reinterpret_cast<intern_type*>(__cto);
__ret = codecvt_base::ok;
}
else
{
if (__flen < static_cast<size_t>(__from_end - __from))
{
__from_next = reinterpret_cast<const extern_type*>(__cfrom);
__to_next = reinterpret_cast<intern_type*>(__cto);
__ret = codecvt_base::partial;
}
else
__ret = codecvt_base::error;
}
}
return __ret;
}
template<typename _InternT, typename _ExternT>
int
codecvt<_InternT, _ExternT, encoding_state>::
do_encoding() const throw()
{
int __ret = 0;
if (sizeof(_ExternT) <= sizeof(_InternT))
__ret = sizeof(_InternT) / sizeof(_ExternT);
return __ret;
}
template<typename _InternT, typename _ExternT>
bool
codecvt<_InternT, _ExternT, encoding_state>::
do_always_noconv() const throw()
{ return false; }
template<typename _InternT, typename _ExternT>
int
codecvt<_InternT, _ExternT, encoding_state>::
do_length(state_type&, const extern_type* __from,
const extern_type* __end, size_t __max) const
{ return std::min(__max, static_cast<size_t>(__end - __from)); }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 74. Garbled text for codecvt::do_max_length
template<typename _InternT, typename _ExternT>
int
codecvt<_InternT, _ExternT, encoding_state>::
do_max_length() const throw()
{ return 1; }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/ext/aligned_buffer.h 0000644 00000007604 15201526705 0011202 0 ustar 00 // Aligned memory buffer -*- C++ -*-
// Copyright (C) 2013-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file ext/aligned_buffer.h
* This file is a GNU extension to the Standard C++ Library.
*/
#ifndef _ALIGNED_BUFFER_H
#define _ALIGNED_BUFFER_H 1
#pragma GCC system_header
#if __cplusplus >= 201103L
# include <type_traits>
#else
# include <bits/c++0x_warning.h>
#endif
namespace __gnu_cxx
{
// A utility type containing a POD object that can hold an object of type
// _Tp initialized via placement new or allocator_traits::construct.
// Intended for use as a data member subobject, use __aligned_buffer for
// complete objects.
template<typename _Tp>
struct __aligned_membuf
{
// Target macro ADJUST_FIELD_ALIGN can produce different alignment for
// types when used as class members. __aligned_membuf is intended
// for use as a class member, so align the buffer as for a class member.
// Since GCC 8 we could just use alignof(_Tp) instead, but older
// versions of non-GNU compilers might still need this trick.
struct _Tp2 { _Tp _M_t; };
alignas(__alignof__(_Tp2::_M_t)) unsigned char _M_storage[sizeof(_Tp)];
__aligned_membuf() = default;
// Can be used to avoid value-initialization zeroing _M_storage.
__aligned_membuf(std::nullptr_t) { }
void*
_M_addr() noexcept
{ return static_cast<void*>(&_M_storage); }
const void*
_M_addr() const noexcept
{ return static_cast<const void*>(&_M_storage); }
_Tp*
_M_ptr() noexcept
{ return static_cast<_Tp*>(_M_addr()); }
const _Tp*
_M_ptr() const noexcept
{ return static_cast<const _Tp*>(_M_addr()); }
};
#if _GLIBCXX_INLINE_VERSION
template<typename _Tp>
using __aligned_buffer = __aligned_membuf<_Tp>;
#else
// Similar to __aligned_membuf but aligned for complete objects, not members.
// This type is used in <forward_list>, <future>, <bits/shared_ptr_base.h>
// and <bits/hashtable_policy.h>, but ideally they would use __aligned_membuf
// instead, as it has smaller size for some types on some targets.
// This type is still used to avoid an ABI change.
template<typename _Tp>
struct __aligned_buffer
: std::aligned_storage<sizeof(_Tp), __alignof__(_Tp)>
{
typename
std::aligned_storage<sizeof(_Tp), __alignof__(_Tp)>::type _M_storage;
__aligned_buffer() = default;
// Can be used to avoid value-initialization
__aligned_buffer(std::nullptr_t) { }
void*
_M_addr() noexcept
{
return static_cast<void*>(&_M_storage);
}
const void*
_M_addr() const noexcept
{
return static_cast<const void*>(&_M_storage);
}
_Tp*
_M_ptr() noexcept
{ return static_cast<_Tp*>(_M_addr()); }
const _Tp*
_M_ptr() const noexcept
{ return static_cast<const _Tp*>(_M_addr()); }
};
#endif
} // namespace
#endif /* _ALIGNED_BUFFER_H */
c++/8/ext/numeric_traits.h 0000644 00000010737 15201526705 0011277 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file ext/numeric_traits.h
* This file is a GNU extension to the Standard C++ Library.
*/
#ifndef _EXT_NUMERIC_TRAITS
#define _EXT_NUMERIC_TRAITS 1
#pragma GCC system_header
#include <bits/cpp_type_traits.h>
#include <ext/type_traits.h>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Compile time constants for builtin types.
// Sadly std::numeric_limits member functions cannot be used for this.
#define __glibcxx_signed(_Tp) ((_Tp)(-1) < 0)
#define __glibcxx_digits(_Tp) \
(sizeof(_Tp) * __CHAR_BIT__ - __glibcxx_signed(_Tp))
#define __glibcxx_min(_Tp) \
(__glibcxx_signed(_Tp) ? (_Tp)1 << __glibcxx_digits(_Tp) : (_Tp)0)
#define __glibcxx_max(_Tp) \
(__glibcxx_signed(_Tp) ? \
(((((_Tp)1 << (__glibcxx_digits(_Tp) - 1)) - 1) << 1) + 1) : ~(_Tp)0)
template<typename _Value>
struct __numeric_traits_integer
{
// Only integers for initialization of member constant.
static const _Value __min = __glibcxx_min(_Value);
static const _Value __max = __glibcxx_max(_Value);
// NB: these two also available in std::numeric_limits as compile
// time constants, but <limits> is big and we avoid including it.
static const bool __is_signed = __glibcxx_signed(_Value);
static const int __digits = __glibcxx_digits(_Value);
};
template<typename _Value>
const _Value __numeric_traits_integer<_Value>::__min;
template<typename _Value>
const _Value __numeric_traits_integer<_Value>::__max;
template<typename _Value>
const bool __numeric_traits_integer<_Value>::__is_signed;
template<typename _Value>
const int __numeric_traits_integer<_Value>::__digits;
#undef __glibcxx_signed
#undef __glibcxx_digits
#undef __glibcxx_min
#undef __glibcxx_max
#define __glibcxx_floating(_Tp, _Fval, _Dval, _LDval) \
(std::__are_same<_Tp, float>::__value ? _Fval \
: std::__are_same<_Tp, double>::__value ? _Dval : _LDval)
#define __glibcxx_max_digits10(_Tp) \
(2 + __glibcxx_floating(_Tp, __FLT_MANT_DIG__, __DBL_MANT_DIG__, \
__LDBL_MANT_DIG__) * 643L / 2136)
#define __glibcxx_digits10(_Tp) \
__glibcxx_floating(_Tp, __FLT_DIG__, __DBL_DIG__, __LDBL_DIG__)
#define __glibcxx_max_exponent10(_Tp) \
__glibcxx_floating(_Tp, __FLT_MAX_10_EXP__, __DBL_MAX_10_EXP__, \
__LDBL_MAX_10_EXP__)
template<typename _Value>
struct __numeric_traits_floating
{
// Only floating point types. See N1822.
static const int __max_digits10 = __glibcxx_max_digits10(_Value);
// See above comment...
static const bool __is_signed = true;
static const int __digits10 = __glibcxx_digits10(_Value);
static const int __max_exponent10 = __glibcxx_max_exponent10(_Value);
};
template<typename _Value>
const int __numeric_traits_floating<_Value>::__max_digits10;
template<typename _Value>
const bool __numeric_traits_floating<_Value>::__is_signed;
template<typename _Value>
const int __numeric_traits_floating<_Value>::__digits10;
template<typename _Value>
const int __numeric_traits_floating<_Value>::__max_exponent10;
template<typename _Value>
struct __numeric_traits
: public __conditional_type<std::__is_integer<_Value>::__value,
__numeric_traits_integer<_Value>,
__numeric_traits_floating<_Value> >::__type
{ };
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#undef __glibcxx_floating
#undef __glibcxx_max_digits10
#undef __glibcxx_digits10
#undef __glibcxx_max_exponent10
#endif
c++/8/ext/sso_string_base.h 0000644 00000037672 15201526705 0011442 0 ustar 00 // Short-string-optimized versatile string base -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file ext/sso_string_base.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{ext/vstring.h}
*/
#ifndef _SSO_STRING_BASE_H
#define _SSO_STRING_BASE_H 1
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _CharT, typename _Traits, typename _Alloc>
class __sso_string_base
: protected __vstring_utility<_CharT, _Traits, _Alloc>
{
public:
typedef _Traits traits_type;
typedef typename _Traits::char_type value_type;
typedef __vstring_utility<_CharT, _Traits, _Alloc> _Util_Base;
typedef typename _Util_Base::_CharT_alloc_type _CharT_alloc_type;
typedef typename _CharT_alloc_type::size_type size_type;
private:
// Data Members:
typename _Util_Base::template _Alloc_hider<_CharT_alloc_type>
_M_dataplus;
size_type _M_string_length;
enum { _S_local_capacity = 15 };
union
{
_CharT _M_local_data[_S_local_capacity + 1];
size_type _M_allocated_capacity;
};
void
_M_data(_CharT* __p)
{ _M_dataplus._M_p = __p; }
void
_M_length(size_type __length)
{ _M_string_length = __length; }
void
_M_capacity(size_type __capacity)
{ _M_allocated_capacity = __capacity; }
bool
_M_is_local() const
{ return _M_data() == _M_local_data; }
// Create & Destroy
_CharT*
_M_create(size_type&, size_type);
void
_M_dispose()
{
if (!_M_is_local())
_M_destroy(_M_allocated_capacity);
}
void
_M_destroy(size_type __size) throw()
{ _M_get_allocator().deallocate(_M_data(), __size + 1); }
// _M_construct_aux is used to implement the 21.3.1 para 15 which
// requires special behaviour if _InIterator is an integral type
template<typename _InIterator>
void
_M_construct_aux(_InIterator __beg, _InIterator __end,
std::__false_type)
{
typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
_M_construct(__beg, __end, _Tag());
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 438. Ambiguity in the "do the right thing" clause
template<typename _Integer>
void
_M_construct_aux(_Integer __beg, _Integer __end, std::__true_type)
{ _M_construct_aux_2(static_cast<size_type>(__beg), __end); }
void
_M_construct_aux_2(size_type __req, _CharT __c)
{ _M_construct(__req, __c); }
template<typename _InIterator>
void
_M_construct(_InIterator __beg, _InIterator __end)
{
typedef typename std::__is_integer<_InIterator>::__type _Integral;
_M_construct_aux(__beg, __end, _Integral());
}
// For Input Iterators, used in istreambuf_iterators, etc.
template<typename _InIterator>
void
_M_construct(_InIterator __beg, _InIterator __end,
std::input_iterator_tag);
// For forward_iterators up to random_access_iterators, used for
// string::iterator, _CharT*, etc.
template<typename _FwdIterator>
void
_M_construct(_FwdIterator __beg, _FwdIterator __end,
std::forward_iterator_tag);
void
_M_construct(size_type __req, _CharT __c);
public:
size_type
_M_max_size() const
{ return (_M_get_allocator().max_size() - 1) / 2; }
_CharT*
_M_data() const
{ return _M_dataplus._M_p; }
size_type
_M_length() const
{ return _M_string_length; }
size_type
_M_capacity() const
{
return _M_is_local() ? size_type(_S_local_capacity)
: _M_allocated_capacity;
}
bool
_M_is_shared() const
{ return false; }
void
_M_set_leaked() { }
void
_M_leak() { }
void
_M_set_length(size_type __n)
{
_M_length(__n);
traits_type::assign(_M_data()[__n], _CharT());
}
__sso_string_base()
: _M_dataplus(_M_local_data)
{ _M_set_length(0); }
__sso_string_base(const _Alloc& __a);
__sso_string_base(const __sso_string_base& __rcs);
#if __cplusplus >= 201103L
__sso_string_base(__sso_string_base&& __rcs);
#endif
__sso_string_base(size_type __n, _CharT __c, const _Alloc& __a);
template<typename _InputIterator>
__sso_string_base(_InputIterator __beg, _InputIterator __end,
const _Alloc& __a);
~__sso_string_base()
{ _M_dispose(); }
_CharT_alloc_type&
_M_get_allocator()
{ return _M_dataplus; }
const _CharT_alloc_type&
_M_get_allocator() const
{ return _M_dataplus; }
void
_M_swap(__sso_string_base& __rcs);
void
_M_assign(const __sso_string_base& __rcs);
void
_M_reserve(size_type __res);
void
_M_mutate(size_type __pos, size_type __len1, const _CharT* __s,
size_type __len2);
void
_M_erase(size_type __pos, size_type __n);
void
_M_clear()
{ _M_set_length(0); }
bool
_M_compare(const __sso_string_base&) const
{ return false; }
};
template<typename _CharT, typename _Traits, typename _Alloc>
void
__sso_string_base<_CharT, _Traits, _Alloc>::
_M_swap(__sso_string_base& __rcs)
{
if (this == &__rcs)
return;
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 431. Swapping containers with unequal allocators.
std::__alloc_swap<_CharT_alloc_type>::_S_do_it(_M_get_allocator(),
__rcs._M_get_allocator());
if (_M_is_local())
if (__rcs._M_is_local())
{
if (_M_length() && __rcs._M_length())
{
_CharT __tmp_data[_S_local_capacity + 1];
traits_type::copy(__tmp_data, __rcs._M_local_data,
_S_local_capacity + 1);
traits_type::copy(__rcs._M_local_data, _M_local_data,
_S_local_capacity + 1);
traits_type::copy(_M_local_data, __tmp_data,
_S_local_capacity + 1);
}
else if (__rcs._M_length())
{
traits_type::copy(_M_local_data, __rcs._M_local_data,
_S_local_capacity + 1);
_M_length(__rcs._M_length());
__rcs._M_set_length(0);
return;
}
else if (_M_length())
{
traits_type::copy(__rcs._M_local_data, _M_local_data,
_S_local_capacity + 1);
__rcs._M_length(_M_length());
_M_set_length(0);
return;
}
}
else
{
const size_type __tmp_capacity = __rcs._M_allocated_capacity;
traits_type::copy(__rcs._M_local_data, _M_local_data,
_S_local_capacity + 1);
_M_data(__rcs._M_data());
__rcs._M_data(__rcs._M_local_data);
_M_capacity(__tmp_capacity);
}
else
{
const size_type __tmp_capacity = _M_allocated_capacity;
if (__rcs._M_is_local())
{
traits_type::copy(_M_local_data, __rcs._M_local_data,
_S_local_capacity + 1);
__rcs._M_data(_M_data());
_M_data(_M_local_data);
}
else
{
_CharT* __tmp_ptr = _M_data();
_M_data(__rcs._M_data());
__rcs._M_data(__tmp_ptr);
_M_capacity(__rcs._M_allocated_capacity);
}
__rcs._M_capacity(__tmp_capacity);
}
const size_type __tmp_length = _M_length();
_M_length(__rcs._M_length());
__rcs._M_length(__tmp_length);
}
template<typename _CharT, typename _Traits, typename _Alloc>
_CharT*
__sso_string_base<_CharT, _Traits, _Alloc>::
_M_create(size_type& __capacity, size_type __old_capacity)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 83. String::npos vs. string::max_size()
if (__capacity > _M_max_size())
std::__throw_length_error(__N("__sso_string_base::_M_create"));
// The below implements an exponential growth policy, necessary to
// meet amortized linear time requirements of the library: see
// http://gcc.gnu.org/ml/libstdc++/2001-07/msg00085.html.
if (__capacity > __old_capacity && __capacity < 2 * __old_capacity)
{
__capacity = 2 * __old_capacity;
// Never allocate a string bigger than max_size.
if (__capacity > _M_max_size())
__capacity = _M_max_size();
}
// NB: Need an array of char_type[__capacity], plus a terminating
// null char_type() element.
return _M_get_allocator().allocate(__capacity + 1);
}
template<typename _CharT, typename _Traits, typename _Alloc>
__sso_string_base<_CharT, _Traits, _Alloc>::
__sso_string_base(const _Alloc& __a)
: _M_dataplus(__a, _M_local_data)
{ _M_set_length(0); }
template<typename _CharT, typename _Traits, typename _Alloc>
__sso_string_base<_CharT, _Traits, _Alloc>::
__sso_string_base(const __sso_string_base& __rcs)
: _M_dataplus(__rcs._M_get_allocator(), _M_local_data)
{ _M_construct(__rcs._M_data(), __rcs._M_data() + __rcs._M_length()); }
#if __cplusplus >= 201103L
template<typename _CharT, typename _Traits, typename _Alloc>
__sso_string_base<_CharT, _Traits, _Alloc>::
__sso_string_base(__sso_string_base&& __rcs)
: _M_dataplus(__rcs._M_get_allocator(), _M_local_data)
{
if (__rcs._M_is_local())
{
if (__rcs._M_length())
traits_type::copy(_M_local_data, __rcs._M_local_data,
_S_local_capacity + 1);
}
else
{
_M_data(__rcs._M_data());
_M_capacity(__rcs._M_allocated_capacity);
}
_M_set_length(__rcs._M_length());
__rcs._M_data(__rcs._M_local_data);
__rcs._M_set_length(0);
}
#endif
template<typename _CharT, typename _Traits, typename _Alloc>
__sso_string_base<_CharT, _Traits, _Alloc>::
__sso_string_base(size_type __n, _CharT __c, const _Alloc& __a)
: _M_dataplus(__a, _M_local_data)
{ _M_construct(__n, __c); }
template<typename _CharT, typename _Traits, typename _Alloc>
template<typename _InputIterator>
__sso_string_base<_CharT, _Traits, _Alloc>::
__sso_string_base(_InputIterator __beg, _InputIterator __end,
const _Alloc& __a)
: _M_dataplus(__a, _M_local_data)
{ _M_construct(__beg, __end); }
// NB: This is the special case for Input Iterators, used in
// istreambuf_iterators, etc.
// Input Iterators have a cost structure very different from
// pointers, calling for a different coding style.
template<typename _CharT, typename _Traits, typename _Alloc>
template<typename _InIterator>
void
__sso_string_base<_CharT, _Traits, _Alloc>::
_M_construct(_InIterator __beg, _InIterator __end,
std::input_iterator_tag)
{
size_type __len = 0;
size_type __capacity = size_type(_S_local_capacity);
while (__beg != __end && __len < __capacity)
{
_M_data()[__len++] = *__beg;
++__beg;
}
__try
{
while (__beg != __end)
{
if (__len == __capacity)
{
// Allocate more space.
__capacity = __len + 1;
_CharT* __another = _M_create(__capacity, __len);
this->_S_copy(__another, _M_data(), __len);
_M_dispose();
_M_data(__another);
_M_capacity(__capacity);
}
_M_data()[__len++] = *__beg;
++__beg;
}
}
__catch(...)
{
_M_dispose();
__throw_exception_again;
}
_M_set_length(__len);
}
template<typename _CharT, typename _Traits, typename _Alloc>
template<typename _InIterator>
void
__sso_string_base<_CharT, _Traits, _Alloc>::
_M_construct(_InIterator __beg, _InIterator __end,
std::forward_iterator_tag)
{
// NB: Not required, but considered best practice.
if (__is_null_pointer(__beg) && __beg != __end)
std::__throw_logic_error(__N("__sso_string_base::"
"_M_construct null not valid"));
size_type __dnew = static_cast<size_type>(std::distance(__beg, __end));
if (__dnew > size_type(_S_local_capacity))
{
_M_data(_M_create(__dnew, size_type(0)));
_M_capacity(__dnew);
}
// Check for out_of_range and length_error exceptions.
__try
{ this->_S_copy_chars(_M_data(), __beg, __end); }
__catch(...)
{
_M_dispose();
__throw_exception_again;
}
_M_set_length(__dnew);
}
template<typename _CharT, typename _Traits, typename _Alloc>
void
__sso_string_base<_CharT, _Traits, _Alloc>::
_M_construct(size_type __n, _CharT __c)
{
if (__n > size_type(_S_local_capacity))
{
_M_data(_M_create(__n, size_type(0)));
_M_capacity(__n);
}
if (__n)
this->_S_assign(_M_data(), __n, __c);
_M_set_length(__n);
}
template<typename _CharT, typename _Traits, typename _Alloc>
void
__sso_string_base<_CharT, _Traits, _Alloc>::
_M_assign(const __sso_string_base& __rcs)
{
if (this != &__rcs)
{
const size_type __rsize = __rcs._M_length();
const size_type __capacity = _M_capacity();
if (__rsize > __capacity)
{
size_type __new_capacity = __rsize;
_CharT* __tmp = _M_create(__new_capacity, __capacity);
_M_dispose();
_M_data(__tmp);
_M_capacity(__new_capacity);
}
if (__rsize)
this->_S_copy(_M_data(), __rcs._M_data(), __rsize);
_M_set_length(__rsize);
}
}
template<typename _CharT, typename _Traits, typename _Alloc>
void
__sso_string_base<_CharT, _Traits, _Alloc>::
_M_reserve(size_type __res)
{
// Make sure we don't shrink below the current size.
if (__res < _M_length())
__res = _M_length();
const size_type __capacity = _M_capacity();
if (__res != __capacity)
{
if (__res > __capacity
|| __res > size_type(_S_local_capacity))
{
_CharT* __tmp = _M_create(__res, __capacity);
this->_S_copy(__tmp, _M_data(), _M_length() + 1);
_M_dispose();
_M_data(__tmp);
_M_capacity(__res);
}
else if (!_M_is_local())
{
this->_S_copy(_M_local_data, _M_data(), _M_length() + 1);
_M_destroy(__capacity);
_M_data(_M_local_data);
}
}
}
template<typename _CharT, typename _Traits, typename _Alloc>
void
__sso_string_base<_CharT, _Traits, _Alloc>::
_M_mutate(size_type __pos, size_type __len1, const _CharT* __s,
size_type __len2)
{
const size_type __how_much = _M_length() - __pos - __len1;
size_type __new_capacity = _M_length() + __len2 - __len1;
_CharT* __r = _M_create(__new_capacity, _M_capacity());
if (__pos)
this->_S_copy(__r, _M_data(), __pos);
if (__s && __len2)
this->_S_copy(__r + __pos, __s, __len2);
if (__how_much)
this->_S_copy(__r + __pos + __len2,
_M_data() + __pos + __len1, __how_much);
_M_dispose();
_M_data(__r);
_M_capacity(__new_capacity);
}
template<typename _CharT, typename _Traits, typename _Alloc>
void
__sso_string_base<_CharT, _Traits, _Alloc>::
_M_erase(size_type __pos, size_type __n)
{
const size_type __how_much = _M_length() - __pos - __n;
if (__how_much && __n)
this->_S_move(_M_data() + __pos, _M_data() + __pos + __n, __how_much);
_M_set_length(_M_length() - __n);
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif /* _SSO_STRING_BASE_H */
c++/8/ext/typelist.h 0000644 00000040140 15201526705 0010113 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice and
// this permission notice appear in supporting documentation. None of
// the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied warranty.
/**
* @file ext/typelist.h
* This file is a GNU extension to the Standard C++ Library.
*
* Contains typelist_chain definitions.
* Typelists are an idea by Andrei Alexandrescu.
*/
#ifndef _TYPELIST_H
#define _TYPELIST_H 1
#include <ext/type_traits.h>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/** @namespace __gnu_cxx::typelist
* @brief GNU typelist extensions for public compile-time use.
*/
namespace typelist
{
struct null_type { };
template<typename Root>
struct node
{
typedef Root root;
};
// Forward declarations of functors.
template<typename Hd, typename Typelist>
struct chain
{
typedef Hd head;
typedef Typelist tail;
};
// Apply all typelist types to unary functor.
template<typename Fn, typename Typelist>
void
apply(Fn&, Typelist);
/// Apply all typelist types to generator functor.
template<typename Gn, typename Typelist>
void
apply_generator(Gn&, Typelist);
// Apply all typelist types and values to generator functor.
template<typename Gn, typename TypelistT, typename TypelistV>
void
apply_generator(Gn&, TypelistT, TypelistV);
template<typename Typelist0, typename Typelist1>
struct append;
template<typename Typelist_Typelist>
struct append_typelist;
template<typename Typelist, typename T>
struct contains;
template<typename Typelist, template<typename T> class Pred>
struct filter;
template<typename Typelist, int i>
struct at_index;
template<typename Typelist, template<typename T> class Transform>
struct transform;
template<typename Typelist_Typelist>
struct flatten;
template<typename Typelist>
struct from_first;
template<typename T1>
struct create1;
template<typename T1, typename T2>
struct create2;
template<typename T1, typename T2, typename T3>
struct create3;
template<typename T1, typename T2, typename T3, typename T4>
struct create4;
template<typename T1, typename T2, typename T3, typename T4, typename T5>
struct create5;
template<typename T1, typename T2, typename T3,
typename T4, typename T5, typename T6>
struct create6;
namespace detail
{
template<typename Fn, typename Typelist_Chain>
struct apply_;
template<typename Fn, typename Hd, typename Tl>
struct apply_<Fn, chain<Hd, Tl> >
{
void
operator()(Fn& f)
{
f.operator()(Hd());
apply_<Fn, Tl> next;
next(f);
}
};
template<typename Fn>
struct apply_<Fn, null_type>
{
void
operator()(Fn&) { }
};
template<typename Gn, typename Typelist_Chain>
struct apply_generator1_;
template<typename Gn, typename Hd, typename Tl>
struct apply_generator1_<Gn, chain<Hd, Tl> >
{
void
operator()(Gn& g)
{
g.template operator()<Hd>();
apply_generator1_<Gn, Tl> next;
next(g);
}
};
template<typename Gn>
struct apply_generator1_<Gn, null_type>
{
void
operator()(Gn&) { }
};
template<typename Gn, typename TypelistT_Chain, typename TypelistV_Chain>
struct apply_generator2_;
template<typename Gn, typename Hd1, typename TlT, typename Hd2, typename TlV>
struct apply_generator2_<Gn, chain<Hd1, TlT>, chain<Hd2, TlV> >
{
void
operator()(Gn& g)
{
g.template operator()<Hd1, Hd2>();
apply_generator2_<Gn, TlT, TlV> next;
next(g);
}
};
template<typename Gn>
struct apply_generator2_<Gn, null_type, null_type>
{
void
operator()(Gn&) { }
};
template<typename Typelist_Chain0, typename Typelist_Chain1>
struct append_;
template<typename Hd, typename Tl, typename Typelist_Chain>
struct append_<chain<Hd, Tl>, Typelist_Chain>
{
private:
typedef append_<Tl, Typelist_Chain> append_type;
public:
typedef chain<Hd, typename append_type::type> type;
};
template<typename Typelist_Chain>
struct append_<null_type, Typelist_Chain>
{
typedef Typelist_Chain type;
};
template<typename Typelist_Chain>
struct append_<Typelist_Chain, null_type>
{
typedef Typelist_Chain type;
};
template<>
struct append_<null_type, null_type>
{
typedef null_type type;
};
template<typename Typelist_Typelist_Chain>
struct append_typelist_;
template<typename Hd>
struct append_typelist_<chain<Hd, null_type> >
{
typedef chain<Hd, null_type> type;
};
template<typename Hd, typename Tl>
struct append_typelist_<chain< Hd, Tl> >
{
private:
typedef typename append_typelist_<Tl>::type rest_type;
public:
typedef typename append<Hd, node<rest_type> >::type::root type;
};
template<typename Typelist_Chain, typename T>
struct contains_;
template<typename T>
struct contains_<null_type, T>
{
enum
{
value = false
};
};
template<typename Hd, typename Tl, typename T>
struct contains_<chain<Hd, Tl>, T>
{
enum
{
value = contains_<Tl, T>::value
};
};
template<typename Tl, typename T>
struct contains_<chain<T, Tl>, T>
{
enum
{
value = true
};
};
template<typename Typelist_Chain, template<typename T> class Pred>
struct chain_filter_;
template<template<typename T> class Pred>
struct chain_filter_<null_type, Pred>
{
typedef null_type type;
};
template<typename Hd, typename Tl, template<typename T> class Pred>
struct chain_filter_<chain<Hd, Tl>, Pred>
{
private:
enum
{
include_hd = Pred<Hd>::value
};
typedef typename chain_filter_<Tl, Pred>::type rest_type;
typedef chain<Hd, rest_type> chain_type;
public:
typedef typename __conditional_type<include_hd, chain_type, rest_type>::__type type;
};
template<typename Typelist_Chain, int i>
struct chain_at_index_;
template<typename Hd, typename Tl>
struct chain_at_index_<chain<Hd, Tl>, 0>
{
typedef Hd type;
};
template<typename Hd, typename Tl, int i>
struct chain_at_index_<chain<Hd, Tl>, i>
{
typedef typename chain_at_index_<Tl, i - 1>::type type;
};
template<class Typelist_Chain, template<typename T> class Transform>
struct chain_transform_;
template<template<typename T> class Transform>
struct chain_transform_<null_type, Transform>
{
typedef null_type type;
};
template<class Hd, class Tl, template<typename T> class Transform>
struct chain_transform_<chain<Hd, Tl>, Transform>
{
private:
typedef typename chain_transform_<Tl, Transform>::type rest_type;
typedef typename Transform<Hd>::type transform_type;
public:
typedef chain<transform_type, rest_type> type;
};
template<typename Typelist_Typelist_Chain>
struct chain_flatten_;
template<typename Hd_Tl>
struct chain_flatten_<chain<Hd_Tl, null_type> >
{
typedef typename Hd_Tl::root type;
};
template<typename Hd_Typelist, class Tl_Typelist>
struct chain_flatten_<chain<Hd_Typelist, Tl_Typelist> >
{
private:
typedef typename chain_flatten_<Tl_Typelist>::type rest_type;
typedef append<Hd_Typelist, node<rest_type> > append_type;
public:
typedef typename append_type::type::root type;
};
} // namespace detail
#define _GLIBCXX_TYPELIST_CHAIN1(X0) __gnu_cxx::typelist::chain<X0, __gnu_cxx::typelist::null_type>
#define _GLIBCXX_TYPELIST_CHAIN2(X0, X1) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN1(X1) >
#define _GLIBCXX_TYPELIST_CHAIN3(X0, X1, X2) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN2(X1, X2) >
#define _GLIBCXX_TYPELIST_CHAIN4(X0, X1, X2, X3) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN3(X1, X2, X3) >
#define _GLIBCXX_TYPELIST_CHAIN5(X0, X1, X2, X3, X4) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN4(X1, X2, X3, X4) >
#define _GLIBCXX_TYPELIST_CHAIN6(X0, X1, X2, X3, X4, X5) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN5(X1, X2, X3, X4, X5) >
#define _GLIBCXX_TYPELIST_CHAIN7(X0, X1, X2, X3, X4, X5, X6) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN6(X1, X2, X3, X4, X5, X6) >
#define _GLIBCXX_TYPELIST_CHAIN8(X0, X1, X2, X3, X4, X5, X6, X7) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN7(X1, X2, X3, X4, X5, X6, X7) >
#define _GLIBCXX_TYPELIST_CHAIN9(X0, X1, X2, X3, X4, X5, X6, X7, X8) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN8(X1, X2, X3, X4, X5, X6, X7, X8) >
#define _GLIBCXX_TYPELIST_CHAIN10(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN9(X1, X2, X3, X4, X5, X6, X7, X8, X9) >
#define _GLIBCXX_TYPELIST_CHAIN11(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN10(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10) >
#define _GLIBCXX_TYPELIST_CHAIN12(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN11(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11) >
#define _GLIBCXX_TYPELIST_CHAIN13(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN12(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12) >
#define _GLIBCXX_TYPELIST_CHAIN14(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN13(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13) >
#define _GLIBCXX_TYPELIST_CHAIN15(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN14(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14) >
#define _GLIBCXX_TYPELIST_CHAIN16(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN15(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15) >
#define _GLIBCXX_TYPELIST_CHAIN17(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15, X16) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN16(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15, X16) >
#define _GLIBCXX_TYPELIST_CHAIN18(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15, X16, X17) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN17(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15, X16, X17) >
#define _GLIBCXX_TYPELIST_CHAIN19(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15, X16, X17, X18) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN18(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15, X16, X17, X18) >
#define _GLIBCXX_TYPELIST_CHAIN20(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15, X16, X17, X18, X19) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN19(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15, X16, X17, X18, X19) >
template<typename Fn, typename Typelist>
void
apply(Fn& fn, Typelist)
{
detail::apply_<Fn, typename Typelist::root> a;
a(fn);
}
template<typename Fn, typename Typelist>
void
apply_generator(Fn& fn, Typelist)
{
detail::apply_generator1_<Fn, typename Typelist::root> a;
a(fn);
}
template<typename Fn, typename TypelistT, typename TypelistV>
void
apply_generator(Fn& fn, TypelistT, TypelistV)
{
typedef typename TypelistT::root rootT;
typedef typename TypelistV::root rootV;
detail::apply_generator2_<Fn, rootT, rootV> a;
a(fn);
}
template<typename Typelist0, typename Typelist1>
struct append
{
private:
typedef typename Typelist0::root root0_type;
typedef typename Typelist1::root root1_type;
typedef detail::append_<root0_type, root1_type> append_type;
public:
typedef node<typename append_type::type> type;
};
template<typename Typelist_Typelist>
struct append_typelist
{
private:
typedef typename Typelist_Typelist::root root_type;
typedef detail::append_typelist_<root_type> append_type;
public:
typedef node<typename append_type::type> type;
};
template<typename Typelist, typename T>
struct contains
{
private:
typedef typename Typelist::root root_type;
public:
enum
{
value = detail::contains_<root_type, T>::value
};
};
template<typename Typelist, template<typename T> class Pred>
struct filter
{
private:
typedef typename Typelist::root root_type;
typedef detail::chain_filter_<root_type, Pred> filter_type;
public:
typedef node<typename filter_type::type> type;
};
template<typename Typelist, int i>
struct at_index
{
private:
typedef typename Typelist::root root_type;
typedef detail::chain_at_index_<root_type, i> index_type;
public:
typedef typename index_type::type type;
};
template<typename Typelist, template<typename T> class Transform>
struct transform
{
private:
typedef typename Typelist::root root_type;
typedef detail::chain_transform_<root_type, Transform> transform_type;
public:
typedef node<typename transform_type::type> type;
};
template<typename Typelist_Typelist>
struct flatten
{
private:
typedef typename Typelist_Typelist::root root_type;
typedef typename detail::chain_flatten_<root_type>::type flatten_type;
public:
typedef node<flatten_type> type;
};
template<typename Typelist>
struct from_first
{
private:
typedef typename at_index<Typelist, 0>::type first_type;
public:
typedef node<chain<first_type, null_type> > type;
};
template<typename T1>
struct create1
{
typedef node<_GLIBCXX_TYPELIST_CHAIN1(T1)> type;
};
template<typename T1, typename T2>
struct create2
{
typedef node<_GLIBCXX_TYPELIST_CHAIN2(T1,T2)> type;
};
template<typename T1, typename T2, typename T3>
struct create3
{
typedef node<_GLIBCXX_TYPELIST_CHAIN3(T1,T2,T3)> type;
};
template<typename T1, typename T2, typename T3, typename T4>
struct create4
{
typedef node<_GLIBCXX_TYPELIST_CHAIN4(T1,T2,T3,T4)> type;
};
template<typename T1, typename T2, typename T3,
typename T4, typename T5>
struct create5
{
typedef node<_GLIBCXX_TYPELIST_CHAIN5(T1,T2,T3,T4,T5)> type;
};
template<typename T1, typename T2, typename T3,
typename T4, typename T5, typename T6>
struct create6
{
typedef node<_GLIBCXX_TYPELIST_CHAIN6(T1,T2,T3,T4,T5,T6)> type;
};
} // namespace typelist
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/ext/pointer.h 0000644 00000046563 15201526705 0007735 0 ustar 00 // Custom pointer adapter and sample storage policies
// Copyright (C) 2008-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/**
* @file ext/pointer.h
* This file is a GNU extension to the Standard C++ Library.
*
* @author Bob Walters
*
* Provides reusable _Pointer_adapter for assisting in the development of
* custom pointer types that can be used with the standard containers via
* the allocator::pointer and allocator::const_pointer typedefs.
*/
#ifndef _POINTER_H
#define _POINTER_H 1
#pragma GCC system_header
#include <iosfwd>
#include <bits/stl_iterator_base_types.h>
#include <ext/cast.h>
#include <ext/type_traits.h>
#if __cplusplus >= 201103L
# include <bits/move.h>
# include <bits/ptr_traits.h>
#endif
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @brief A storage policy for use with _Pointer_adapter<> which yields a
* standard pointer.
*
* A _Storage_policy is required to provide 4 things:
* 1) A get() API for returning the stored pointer value.
* 2) An set() API for storing a pointer value.
* 3) An element_type typedef to define the type this points to.
* 4) An operator<() to support pointer comparison.
* 5) An operator==() to support pointer comparison.
*/
template<typename _Tp>
class _Std_pointer_impl
{
public:
// the type this pointer points to.
typedef _Tp element_type;
// A method to fetch the pointer value as a standard T* value;
inline _Tp*
get() const
{ return _M_value; }
// A method to set the pointer value, from a standard T* value;
inline void
set(element_type* __arg)
{ _M_value = __arg; }
// Comparison of pointers
inline bool
operator<(const _Std_pointer_impl& __rarg) const
{ return (_M_value < __rarg._M_value); }
inline bool
operator==(const _Std_pointer_impl& __rarg) const
{ return (_M_value == __rarg._M_value); }
private:
element_type* _M_value;
};
/**
* @brief A storage policy for use with _Pointer_adapter<> which stores
* the pointer's address as an offset value which is relative to
* its own address.
*
* This is intended for pointers within shared memory regions which
* might be mapped at different addresses by different processes.
* For null pointers, a value of 1 is used. (0 is legitimate
* sometimes for nodes in circularly linked lists) This value was
* chosen as the least likely to generate an incorrect null, As
* there is no reason why any normal pointer would point 1 byte into
* its own pointer address.
*/
template<typename _Tp>
class _Relative_pointer_impl
{
public:
typedef _Tp element_type;
_Tp*
get() const
{
if (_M_diff == 1)
return 0;
else
return reinterpret_cast<_Tp*>(reinterpret_cast<_UIntPtrType>(this)
+ _M_diff);
}
void
set(_Tp* __arg)
{
if (!__arg)
_M_diff = 1;
else
_M_diff = reinterpret_cast<_UIntPtrType>(__arg)
- reinterpret_cast<_UIntPtrType>(this);
}
// Comparison of pointers
inline bool
operator<(const _Relative_pointer_impl& __rarg) const
{ return (reinterpret_cast<_UIntPtrType>(this->get())
< reinterpret_cast<_UIntPtrType>(__rarg.get())); }
inline bool
operator==(const _Relative_pointer_impl& __rarg) const
{ return (reinterpret_cast<_UIntPtrType>(this->get())
== reinterpret_cast<_UIntPtrType>(__rarg.get())); }
private:
#ifdef _GLIBCXX_USE_LONG_LONG
typedef __gnu_cxx::__conditional_type<
(sizeof(unsigned long) >= sizeof(void*)),
unsigned long, unsigned long long>::__type _UIntPtrType;
#else
typedef unsigned long _UIntPtrType;
#endif
_UIntPtrType _M_diff;
};
/**
* Relative_pointer_impl needs a specialization for const T because of
* the casting done during pointer arithmetic.
*/
template<typename _Tp>
class _Relative_pointer_impl<const _Tp>
{
public:
typedef const _Tp element_type;
const _Tp*
get() const
{
if (_M_diff == 1)
return 0;
else
return reinterpret_cast<const _Tp*>
(reinterpret_cast<_UIntPtrType>(this) + _M_diff);
}
void
set(const _Tp* __arg)
{
if (!__arg)
_M_diff = 1;
else
_M_diff = reinterpret_cast<_UIntPtrType>(__arg)
- reinterpret_cast<_UIntPtrType>(this);
}
// Comparison of pointers
inline bool
operator<(const _Relative_pointer_impl& __rarg) const
{ return (reinterpret_cast<_UIntPtrType>(this->get())
< reinterpret_cast<_UIntPtrType>(__rarg.get())); }
inline bool
operator==(const _Relative_pointer_impl& __rarg) const
{ return (reinterpret_cast<_UIntPtrType>(this->get())
== reinterpret_cast<_UIntPtrType>(__rarg.get())); }
private:
#ifdef _GLIBCXX_USE_LONG_LONG
typedef __gnu_cxx::__conditional_type<
(sizeof(unsigned long) >= sizeof(void*)),
unsigned long, unsigned long long>::__type _UIntPtrType;
#else
typedef unsigned long _UIntPtrType;
#endif
_UIntPtrType _M_diff;
};
/**
* The specialization on this type helps resolve the problem of
* reference to void, and eliminates the need to specialize
* _Pointer_adapter for cases of void*, const void*, and so on.
*/
struct _Invalid_type { };
template<typename _Tp>
struct _Reference_type
{ typedef _Tp& reference; };
template<>
struct _Reference_type<void>
{ typedef _Invalid_type& reference; };
template<>
struct _Reference_type<const void>
{ typedef const _Invalid_type& reference; };
template<>
struct _Reference_type<volatile void>
{ typedef volatile _Invalid_type& reference; };
template<>
struct _Reference_type<volatile const void>
{ typedef const volatile _Invalid_type& reference; };
/**
* This structure accommodates the way in which
* std::iterator_traits<> is normally specialized for const T*, so
* that value_type is still T.
*/
template<typename _Tp>
struct _Unqualified_type
{ typedef _Tp type; };
template<typename _Tp>
struct _Unqualified_type<const _Tp>
{ typedef _Tp type; };
/**
* The following provides an 'alternative pointer' that works with
* the containers when specified as the pointer typedef of the
* allocator.
*
* The pointer type used with the containers doesn't have to be this
* class, but it must support the implicit conversions, pointer
* arithmetic, comparison operators, etc. that are supported by this
* class, and avoid raising compile-time ambiguities. Because
* creating a working pointer can be challenging, this pointer
* template was designed to wrapper an easier storage policy type,
* so that it becomes reusable for creating other pointer types.
*
* A key point of this class is also that it allows container
* writers to 'assume' Allocator::pointer is a typedef for a normal
* pointer. This class supports most of the conventions of a true
* pointer, and can, for instance handle implicit conversion to
* const and base class pointer types. The only impositions on
* container writers to support extended pointers are: 1) use the
* Allocator::pointer typedef appropriately for pointer types. 2)
* if you need pointer casting, use the __pointer_cast<> functions
* from ext/cast.h. This allows pointer cast operations to be
* overloaded as necessary by custom pointers.
*
* Note: The const qualifier works with this pointer adapter as
* follows:
*
* _Tp* == _Pointer_adapter<_Std_pointer_impl<_Tp> >;
* const _Tp* == _Pointer_adapter<_Std_pointer_impl<const _Tp> >;
* _Tp* const == const _Pointer_adapter<_Std_pointer_impl<_Tp> >;
* const _Tp* const == const _Pointer_adapter<_Std_pointer_impl<const _Tp> >;
*/
template<typename _Storage_policy>
class _Pointer_adapter : public _Storage_policy
{
public:
typedef typename _Storage_policy::element_type element_type;
// These are needed for iterator_traits
typedef std::random_access_iterator_tag iterator_category;
typedef typename _Unqualified_type<element_type>::type value_type;
typedef std::ptrdiff_t difference_type;
typedef _Pointer_adapter pointer;
typedef typename _Reference_type<element_type>::reference reference;
// Reminder: 'const' methods mean that the method is valid when the
// pointer is immutable, and has nothing to do with whether the
// 'pointee' is const.
// Default Constructor (Convert from element_type*)
_Pointer_adapter(element_type* __arg = 0)
{ _Storage_policy::set(__arg); }
// Copy constructor from _Pointer_adapter of same type.
_Pointer_adapter(const _Pointer_adapter& __arg)
{ _Storage_policy::set(__arg.get()); }
// Convert from _Up* if conversion to element_type* is valid.
template<typename _Up>
_Pointer_adapter(_Up* __arg)
{ _Storage_policy::set(__arg); }
// Conversion from another _Pointer_adapter if _Up if static cast is
// valid.
template<typename _Up>
_Pointer_adapter(const _Pointer_adapter<_Up>& __arg)
{ _Storage_policy::set(__arg.get()); }
// Destructor
~_Pointer_adapter() { }
// Assignment operator
_Pointer_adapter&
operator=(const _Pointer_adapter& __arg)
{
_Storage_policy::set(__arg.get());
return *this;
}
template<typename _Up>
_Pointer_adapter&
operator=(const _Pointer_adapter<_Up>& __arg)
{
_Storage_policy::set(__arg.get());
return *this;
}
template<typename _Up>
_Pointer_adapter&
operator=(_Up* __arg)
{
_Storage_policy::set(__arg);
return *this;
}
// Operator*, returns element_type&
inline reference
operator*() const
{ return *(_Storage_policy::get()); }
// Operator->, returns element_type*
inline element_type*
operator->() const
{ return _Storage_policy::get(); }
// Operator[], returns a element_type& to the item at that loc.
inline reference
operator[](std::ptrdiff_t __index) const
{ return _Storage_policy::get()[__index]; }
// To allow implicit conversion to "bool", for "if (ptr)..."
private:
typedef element_type*(_Pointer_adapter::*__unspecified_bool_type)() const;
public:
operator __unspecified_bool_type() const
{
return _Storage_policy::get() == 0 ? 0 :
&_Pointer_adapter::operator->;
}
// ! operator (for: if (!ptr)...)
inline bool
operator!() const
{ return (_Storage_policy::get() == 0); }
// Pointer differences
inline friend std::ptrdiff_t
operator-(const _Pointer_adapter& __lhs, element_type* __rhs)
{ return (__lhs.get() - __rhs); }
inline friend std::ptrdiff_t
operator-(element_type* __lhs, const _Pointer_adapter& __rhs)
{ return (__lhs - __rhs.get()); }
template<typename _Up>
inline friend std::ptrdiff_t
operator-(const _Pointer_adapter& __lhs, _Up* __rhs)
{ return (__lhs.get() - __rhs); }
template<typename _Up>
inline friend std::ptrdiff_t
operator-(_Up* __lhs, const _Pointer_adapter& __rhs)
{ return (__lhs - __rhs.get()); }
template<typename _Up>
inline std::ptrdiff_t
operator-(const _Pointer_adapter<_Up>& __rhs) const
{ return (_Storage_policy::get() - __rhs.get()); }
// Pointer math
// Note: There is a reason for all this overloading based on different
// integer types. In some libstdc++-v3 test cases, a templated
// operator+ is declared which can match any types. This operator
// tends to "steal" the recognition of _Pointer_adapter's own operator+
// unless the integer type matches perfectly.
#define _CXX_POINTER_ARITH_OPERATOR_SET(INT_TYPE) \
inline friend _Pointer_adapter \
operator+(const _Pointer_adapter& __lhs, INT_TYPE __offset) \
{ return _Pointer_adapter(__lhs.get() + __offset); } \
\
inline friend _Pointer_adapter \
operator+(INT_TYPE __offset, const _Pointer_adapter& __rhs) \
{ return _Pointer_adapter(__rhs.get() + __offset); } \
\
inline friend _Pointer_adapter \
operator-(const _Pointer_adapter& __lhs, INT_TYPE __offset) \
{ return _Pointer_adapter(__lhs.get() - __offset); } \
\
inline _Pointer_adapter& \
operator+=(INT_TYPE __offset) \
{ \
_Storage_policy::set(_Storage_policy::get() + __offset); \
return *this; \
} \
\
inline _Pointer_adapter& \
operator-=(INT_TYPE __offset) \
{ \
_Storage_policy::set(_Storage_policy::get() - __offset); \
return *this; \
} \
// END of _CXX_POINTER_ARITH_OPERATOR_SET macro
// Expand into the various pointer arithmetic operators needed.
_CXX_POINTER_ARITH_OPERATOR_SET(short);
_CXX_POINTER_ARITH_OPERATOR_SET(unsigned short);
_CXX_POINTER_ARITH_OPERATOR_SET(int);
_CXX_POINTER_ARITH_OPERATOR_SET(unsigned int);
_CXX_POINTER_ARITH_OPERATOR_SET(long);
_CXX_POINTER_ARITH_OPERATOR_SET(unsigned long);
#ifdef _GLIBCXX_USE_LONG_LONG
_CXX_POINTER_ARITH_OPERATOR_SET(long long);
_CXX_POINTER_ARITH_OPERATOR_SET(unsigned long long);
#endif
// Mathematical Manipulators
inline _Pointer_adapter&
operator++()
{
_Storage_policy::set(_Storage_policy::get() + 1);
return *this;
}
inline _Pointer_adapter
operator++(int)
{
_Pointer_adapter __tmp(*this);
_Storage_policy::set(_Storage_policy::get() + 1);
return __tmp;
}
inline _Pointer_adapter&
operator--()
{
_Storage_policy::set(_Storage_policy::get() - 1);
return *this;
}
inline _Pointer_adapter
operator--(int)
{
_Pointer_adapter __tmp(*this);
_Storage_policy::set(_Storage_policy::get() - 1);
return __tmp;
}
}; // class _Pointer_adapter
#define _GCC_CXX_POINTER_COMPARISON_OPERATION_SET(OPERATOR) \
template<typename _Tp1, typename _Tp2> \
inline bool \
operator OPERATOR(const _Pointer_adapter<_Tp1>& __lhs, _Tp2 __rhs) \
{ return __lhs.get() OPERATOR __rhs; } \
\
template<typename _Tp1, typename _Tp2> \
inline bool \
operator OPERATOR(_Tp1 __lhs, const _Pointer_adapter<_Tp2>& __rhs) \
{ return __lhs OPERATOR __rhs.get(); } \
\
template<typename _Tp1, typename _Tp2> \
inline bool \
operator OPERATOR(const _Pointer_adapter<_Tp1>& __lhs, \
const _Pointer_adapter<_Tp2>& __rhs) \
{ return __lhs.get() OPERATOR __rhs.get(); } \
\
// End GCC_CXX_POINTER_COMPARISON_OPERATION_SET Macro
// Expand into the various comparison operators needed.
_GCC_CXX_POINTER_COMPARISON_OPERATION_SET(==)
_GCC_CXX_POINTER_COMPARISON_OPERATION_SET(!=)
_GCC_CXX_POINTER_COMPARISON_OPERATION_SET(<)
_GCC_CXX_POINTER_COMPARISON_OPERATION_SET(<=)
_GCC_CXX_POINTER_COMPARISON_OPERATION_SET(>)
_GCC_CXX_POINTER_COMPARISON_OPERATION_SET(>=)
// These are here for expressions like "ptr == 0", "ptr != 0"
template<typename _Tp>
inline bool
operator==(const _Pointer_adapter<_Tp>& __lhs, int __rhs)
{ return __lhs.get() == reinterpret_cast<void*>(__rhs); }
template<typename _Tp>
inline bool
operator==(int __lhs, const _Pointer_adapter<_Tp>& __rhs)
{ return __rhs.get() == reinterpret_cast<void*>(__lhs); }
template<typename _Tp>
inline bool
operator!=(const _Pointer_adapter<_Tp>& __lhs, int __rhs)
{ return __lhs.get() != reinterpret_cast<void*>(__rhs); }
template<typename _Tp>
inline bool
operator!=(int __lhs, const _Pointer_adapter<_Tp>& __rhs)
{ return __rhs.get() != reinterpret_cast<void*>(__lhs); }
/**
* Comparison operators for _Pointer_adapter defer to the base class'
* comparison operators, when possible.
*/
template<typename _Tp>
inline bool
operator==(const _Pointer_adapter<_Tp>& __lhs,
const _Pointer_adapter<_Tp>& __rhs)
{ return __lhs._Tp::operator==(__rhs); }
template<typename _Tp>
inline bool
operator<=(const _Pointer_adapter<_Tp>& __lhs,
const _Pointer_adapter<_Tp>& __rhs)
{ return __lhs._Tp::operator<(__rhs) || __lhs._Tp::operator==(__rhs); }
template<typename _Tp>
inline bool
operator!=(const _Pointer_adapter<_Tp>& __lhs,
const _Pointer_adapter<_Tp>& __rhs)
{ return !(__lhs._Tp::operator==(__rhs)); }
template<typename _Tp>
inline bool
operator>(const _Pointer_adapter<_Tp>& __lhs,
const _Pointer_adapter<_Tp>& __rhs)
{ return !(__lhs._Tp::operator<(__rhs) || __lhs._Tp::operator==(__rhs)); }
template<typename _Tp>
inline bool
operator>=(const _Pointer_adapter<_Tp>& __lhs,
const _Pointer_adapter<_Tp>& __rhs)
{ return !(__lhs._Tp::operator<(__rhs)); }
template<typename _CharT, typename _Traits, typename _StoreT>
inline std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const _Pointer_adapter<_StoreT>& __p)
{ return (__os << __p.get()); }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#if __cplusplus >= 201103L
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Storage_policy>
struct pointer_traits<__gnu_cxx::_Pointer_adapter<_Storage_policy>>
{
/// The pointer type
typedef __gnu_cxx::_Pointer_adapter<_Storage_policy> pointer;
/// The type pointed to
typedef typename pointer::element_type element_type;
/// Type used to represent the difference between two pointers
typedef typename pointer::difference_type difference_type;
template<typename _Up>
using rebind = typename __gnu_cxx::_Pointer_adapter<
typename pointer_traits<_Storage_policy>::template rebind<_Up>>;
static pointer pointer_to(typename pointer::reference __r) noexcept
{ return pointer(std::addressof(__r)); }
};
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
#endif // _POINTER_H
c++/8/ext/atomicity.h 0000644 00000006665 15201526705 0010256 0 ustar 00 // Support for atomic operations -*- C++ -*-
// Copyright (C) 2004-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file ext/atomicity.h
* This file is a GNU extension to the Standard C++ Library.
*/
#ifndef _GLIBCXX_ATOMICITY_H
#define _GLIBCXX_ATOMICITY_H 1
#pragma GCC system_header
#include <bits/c++config.h>
#include <bits/gthr.h>
#include <bits/atomic_word.h>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Functions for portable atomic access.
// To abstract locking primitives across all thread policies, use:
// __exchange_and_add_dispatch
// __atomic_add_dispatch
#ifdef _GLIBCXX_ATOMIC_BUILTINS
static inline _Atomic_word
__exchange_and_add(volatile _Atomic_word* __mem, int __val)
{ return __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); }
static inline void
__atomic_add(volatile _Atomic_word* __mem, int __val)
{ __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); }
#else
_Atomic_word
__attribute__ ((__unused__))
__exchange_and_add(volatile _Atomic_word*, int) throw ();
void
__attribute__ ((__unused__))
__atomic_add(volatile _Atomic_word*, int) throw ();
#endif
static inline _Atomic_word
__exchange_and_add_single(_Atomic_word* __mem, int __val)
{
_Atomic_word __result = *__mem;
*__mem += __val;
return __result;
}
static inline void
__atomic_add_single(_Atomic_word* __mem, int __val)
{ *__mem += __val; }
static inline _Atomic_word
__attribute__ ((__unused__))
__exchange_and_add_dispatch(_Atomic_word* __mem, int __val)
{
#ifdef __GTHREADS
if (__gthread_active_p())
return __exchange_and_add(__mem, __val);
else
return __exchange_and_add_single(__mem, __val);
#else
return __exchange_and_add_single(__mem, __val);
#endif
}
static inline void
__attribute__ ((__unused__))
__atomic_add_dispatch(_Atomic_word* __mem, int __val)
{
#ifdef __GTHREADS
if (__gthread_active_p())
__atomic_add(__mem, __val);
else
__atomic_add_single(__mem, __val);
#else
__atomic_add_single(__mem, __val);
#endif
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
// Even if the CPU doesn't need a memory barrier, we need to ensure
// that the compiler doesn't reorder memory accesses across the
// barriers.
#ifndef _GLIBCXX_READ_MEM_BARRIER
#define _GLIBCXX_READ_MEM_BARRIER __atomic_thread_fence (__ATOMIC_ACQUIRE)
#endif
#ifndef _GLIBCXX_WRITE_MEM_BARRIER
#define _GLIBCXX_WRITE_MEM_BARRIER __atomic_thread_fence (__ATOMIC_RELEASE)
#endif
#endif
c++/8/ext/bitmap_allocator.h 0000644 00000076116 15201526705 0011566 0 ustar 00 // Bitmap Allocator. -*- C++ -*-
// Copyright (C) 2004-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file ext/bitmap_allocator.h
* This file is a GNU extension to the Standard C++ Library.
*/
#ifndef _BITMAP_ALLOCATOR_H
#define _BITMAP_ALLOCATOR_H 1
#include <utility> // For std::pair.
#include <bits/functexcept.h> // For __throw_bad_alloc().
#include <functional> // For greater_equal, and less_equal.
#include <new> // For operator new.
#include <debug/debug.h> // _GLIBCXX_DEBUG_ASSERT
#include <ext/concurrence.h>
#include <bits/move.h>
/** @brief The constant in the expression below is the alignment
* required in bytes.
*/
#define _BALLOC_ALIGN_BYTES 8
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using std::size_t;
using std::ptrdiff_t;
namespace __detail
{
/** @class __mini_vector bitmap_allocator.h bitmap_allocator.h
*
* @brief __mini_vector<> is a stripped down version of the
* full-fledged std::vector<>.
*
* It is to be used only for built-in types or PODs. Notable
* differences are:
*
* 1. Not all accessor functions are present.
* 2. Used ONLY for PODs.
* 3. No Allocator template argument. Uses ::operator new() to get
* memory, and ::operator delete() to free it.
* Caveat: The dtor does NOT free the memory allocated, so this a
* memory-leaking vector!
*/
template<typename _Tp>
class __mini_vector
{
__mini_vector(const __mini_vector&);
__mini_vector& operator=(const __mini_vector&);
public:
typedef _Tp value_type;
typedef _Tp* pointer;
typedef _Tp& reference;
typedef const _Tp& const_reference;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef pointer iterator;
private:
pointer _M_start;
pointer _M_finish;
pointer _M_end_of_storage;
size_type
_M_space_left() const throw()
{ return _M_end_of_storage - _M_finish; }
pointer
allocate(size_type __n)
{ return static_cast<pointer>(::operator new(__n * sizeof(_Tp))); }
void
deallocate(pointer __p, size_type)
{ ::operator delete(__p); }
public:
// Members used: size(), push_back(), pop_back(),
// insert(iterator, const_reference), erase(iterator),
// begin(), end(), back(), operator[].
__mini_vector()
: _M_start(0), _M_finish(0), _M_end_of_storage(0) { }
size_type
size() const throw()
{ return _M_finish - _M_start; }
iterator
begin() const throw()
{ return this->_M_start; }
iterator
end() const throw()
{ return this->_M_finish; }
reference
back() const throw()
{ return *(this->end() - 1); }
reference
operator[](const size_type __pos) const throw()
{ return this->_M_start[__pos]; }
void
insert(iterator __pos, const_reference __x);
void
push_back(const_reference __x)
{
if (this->_M_space_left())
{
*this->end() = __x;
++this->_M_finish;
}
else
this->insert(this->end(), __x);
}
void
pop_back() throw()
{ --this->_M_finish; }
void
erase(iterator __pos) throw();
void
clear() throw()
{ this->_M_finish = this->_M_start; }
};
// Out of line function definitions.
template<typename _Tp>
void __mini_vector<_Tp>::
insert(iterator __pos, const_reference __x)
{
if (this->_M_space_left())
{
size_type __to_move = this->_M_finish - __pos;
iterator __dest = this->end();
iterator __src = this->end() - 1;
++this->_M_finish;
while (__to_move)
{
*__dest = *__src;
--__dest; --__src; --__to_move;
}
*__pos = __x;
}
else
{
size_type __new_size = this->size() ? this->size() * 2 : 1;
iterator __new_start = this->allocate(__new_size);
iterator __first = this->begin();
iterator __start = __new_start;
while (__first != __pos)
{
*__start = *__first;
++__start; ++__first;
}
*__start = __x;
++__start;
while (__first != this->end())
{
*__start = *__first;
++__start; ++__first;
}
if (this->_M_start)
this->deallocate(this->_M_start, this->size());
this->_M_start = __new_start;
this->_M_finish = __start;
this->_M_end_of_storage = this->_M_start + __new_size;
}
}
template<typename _Tp>
void __mini_vector<_Tp>::
erase(iterator __pos) throw()
{
while (__pos + 1 != this->end())
{
*__pos = __pos[1];
++__pos;
}
--this->_M_finish;
}
template<typename _Tp>
struct __mv_iter_traits
{
typedef typename _Tp::value_type value_type;
typedef typename _Tp::difference_type difference_type;
};
template<typename _Tp>
struct __mv_iter_traits<_Tp*>
{
typedef _Tp value_type;
typedef ptrdiff_t difference_type;
};
enum
{
bits_per_byte = 8,
bits_per_block = sizeof(size_t) * size_t(bits_per_byte)
};
template<typename _ForwardIterator, typename _Tp, typename _Compare>
_ForwardIterator
__lower_bound(_ForwardIterator __first, _ForwardIterator __last,
const _Tp& __val, _Compare __comp)
{
typedef typename __mv_iter_traits<_ForwardIterator>::difference_type
_DistanceType;
_DistanceType __len = __last - __first;
_DistanceType __half;
_ForwardIterator __middle;
while (__len > 0)
{
__half = __len >> 1;
__middle = __first;
__middle += __half;
if (__comp(*__middle, __val))
{
__first = __middle;
++__first;
__len = __len - __half - 1;
}
else
__len = __half;
}
return __first;
}
/** @brief The number of Blocks pointed to by the address pair
* passed to the function.
*/
template<typename _AddrPair>
inline size_t
__num_blocks(_AddrPair __ap)
{ return (__ap.second - __ap.first) + 1; }
/** @brief The number of Bit-maps pointed to by the address pair
* passed to the function.
*/
template<typename _AddrPair>
inline size_t
__num_bitmaps(_AddrPair __ap)
{ return __num_blocks(__ap) / size_t(bits_per_block); }
// _Tp should be a pointer type.
template<typename _Tp>
class _Inclusive_between
: public std::unary_function<typename std::pair<_Tp, _Tp>, bool>
{
typedef _Tp pointer;
pointer _M_ptr_value;
typedef typename std::pair<_Tp, _Tp> _Block_pair;
public:
_Inclusive_between(pointer __ptr) : _M_ptr_value(__ptr)
{ }
bool
operator()(_Block_pair __bp) const throw()
{
if (std::less_equal<pointer>()(_M_ptr_value, __bp.second)
&& std::greater_equal<pointer>()(_M_ptr_value, __bp.first))
return true;
else
return false;
}
};
// Used to pass a Functor to functions by reference.
template<typename _Functor>
class _Functor_Ref
: public std::unary_function<typename _Functor::argument_type,
typename _Functor::result_type>
{
_Functor& _M_fref;
public:
typedef typename _Functor::argument_type argument_type;
typedef typename _Functor::result_type result_type;
_Functor_Ref(_Functor& __fref) : _M_fref(__fref)
{ }
result_type
operator()(argument_type __arg)
{ return _M_fref(__arg); }
};
/** @class _Ffit_finder bitmap_allocator.h bitmap_allocator.h
*
* @brief The class which acts as a predicate for applying the
* first-fit memory allocation policy for the bitmap allocator.
*/
// _Tp should be a pointer type, and _Alloc is the Allocator for
// the vector.
template<typename _Tp>
class _Ffit_finder
: public std::unary_function<typename std::pair<_Tp, _Tp>, bool>
{
typedef typename std::pair<_Tp, _Tp> _Block_pair;
typedef typename __detail::__mini_vector<_Block_pair> _BPVector;
typedef typename _BPVector::difference_type _Counter_type;
size_t* _M_pbitmap;
_Counter_type _M_data_offset;
public:
_Ffit_finder() : _M_pbitmap(0), _M_data_offset(0)
{ }
bool
operator()(_Block_pair __bp) throw()
{
// Set the _rover to the last physical location bitmap,
// which is the bitmap which belongs to the first free
// block. Thus, the bitmaps are in exact reverse order of
// the actual memory layout. So, we count down the bitmaps,
// which is the same as moving up the memory.
// If the used count stored at the start of the Bit Map headers
// is equal to the number of Objects that the current Block can
// store, then there is definitely no space for another single
// object, so just return false.
_Counter_type __diff = __detail::__num_bitmaps(__bp);
if (*(reinterpret_cast<size_t*>
(__bp.first) - (__diff + 1)) == __detail::__num_blocks(__bp))
return false;
size_t* __rover = reinterpret_cast<size_t*>(__bp.first) - 1;
for (_Counter_type __i = 0; __i < __diff; ++__i)
{
_M_data_offset = __i;
if (*__rover)
{
_M_pbitmap = __rover;
return true;
}
--__rover;
}
return false;
}
size_t*
_M_get() const throw()
{ return _M_pbitmap; }
_Counter_type
_M_offset() const throw()
{ return _M_data_offset * size_t(bits_per_block); }
};
/** @class _Bitmap_counter bitmap_allocator.h bitmap_allocator.h
*
* @brief The bitmap counter which acts as the bitmap
* manipulator, and manages the bit-manipulation functions and
* the searching and identification functions on the bit-map.
*/
// _Tp should be a pointer type.
template<typename _Tp>
class _Bitmap_counter
{
typedef typename
__detail::__mini_vector<typename std::pair<_Tp, _Tp> > _BPVector;
typedef typename _BPVector::size_type _Index_type;
typedef _Tp pointer;
_BPVector& _M_vbp;
size_t* _M_curr_bmap;
size_t* _M_last_bmap_in_block;
_Index_type _M_curr_index;
public:
// Use the 2nd parameter with care. Make sure that such an
// entry exists in the vector before passing that particular
// index to this ctor.
_Bitmap_counter(_BPVector& Rvbp, long __index = -1) : _M_vbp(Rvbp)
{ this->_M_reset(__index); }
void
_M_reset(long __index = -1) throw()
{
if (__index == -1)
{
_M_curr_bmap = 0;
_M_curr_index = static_cast<_Index_type>(-1);
return;
}
_M_curr_index = __index;
_M_curr_bmap = reinterpret_cast<size_t*>
(_M_vbp[_M_curr_index].first) - 1;
_GLIBCXX_DEBUG_ASSERT(__index <= (long)_M_vbp.size() - 1);
_M_last_bmap_in_block = _M_curr_bmap
- ((_M_vbp[_M_curr_index].second
- _M_vbp[_M_curr_index].first + 1)
/ size_t(bits_per_block) - 1);
}
// Dangerous Function! Use with extreme care. Pass to this
// function ONLY those values that are known to be correct,
// otherwise this will mess up big time.
void
_M_set_internal_bitmap(size_t* __new_internal_marker) throw()
{ _M_curr_bmap = __new_internal_marker; }
bool
_M_finished() const throw()
{ return(_M_curr_bmap == 0); }
_Bitmap_counter&
operator++() throw()
{
if (_M_curr_bmap == _M_last_bmap_in_block)
{
if (++_M_curr_index == _M_vbp.size())
_M_curr_bmap = 0;
else
this->_M_reset(_M_curr_index);
}
else
--_M_curr_bmap;
return *this;
}
size_t*
_M_get() const throw()
{ return _M_curr_bmap; }
pointer
_M_base() const throw()
{ return _M_vbp[_M_curr_index].first; }
_Index_type
_M_offset() const throw()
{
return size_t(bits_per_block)
* ((reinterpret_cast<size_t*>(this->_M_base())
- _M_curr_bmap) - 1);
}
_Index_type
_M_where() const throw()
{ return _M_curr_index; }
};
/** @brief Mark a memory address as allocated by re-setting the
* corresponding bit in the bit-map.
*/
inline void
__bit_allocate(size_t* __pbmap, size_t __pos) throw()
{
size_t __mask = 1 << __pos;
__mask = ~__mask;
*__pbmap &= __mask;
}
/** @brief Mark a memory address as free by setting the
* corresponding bit in the bit-map.
*/
inline void
__bit_free(size_t* __pbmap, size_t __pos) throw()
{
size_t __mask = 1 << __pos;
*__pbmap |= __mask;
}
} // namespace __detail
/** @brief Generic Version of the bsf instruction.
*/
inline size_t
_Bit_scan_forward(size_t __num)
{ return static_cast<size_t>(__builtin_ctzl(__num)); }
/** @class free_list bitmap_allocator.h bitmap_allocator.h
*
* @brief The free list class for managing chunks of memory to be
* given to and returned by the bitmap_allocator.
*/
class free_list
{
public:
typedef size_t* value_type;
typedef __detail::__mini_vector<value_type> vector_type;
typedef vector_type::iterator iterator;
typedef __mutex __mutex_type;
private:
struct _LT_pointer_compare
{
bool
operator()(const size_t* __pui,
const size_t __cui) const throw()
{ return *__pui < __cui; }
};
#if defined __GTHREADS
__mutex_type&
_M_get_mutex()
{
static __mutex_type _S_mutex;
return _S_mutex;
}
#endif
vector_type&
_M_get_free_list()
{
static vector_type _S_free_list;
return _S_free_list;
}
/** @brief Performs validation of memory based on their size.
*
* @param __addr The pointer to the memory block to be
* validated.
*
* Validates the memory block passed to this function and
* appropriately performs the action of managing the free list of
* blocks by adding this block to the free list or deleting this
* or larger blocks from the free list.
*/
void
_M_validate(size_t* __addr) throw()
{
vector_type& __free_list = _M_get_free_list();
const vector_type::size_type __max_size = 64;
if (__free_list.size() >= __max_size)
{
// Ok, the threshold value has been reached. We determine
// which block to remove from the list of free blocks.
if (*__addr >= *__free_list.back())
{
// Ok, the new block is greater than or equal to the
// last block in the list of free blocks. We just free
// the new block.
::operator delete(static_cast<void*>(__addr));
return;
}
else
{
// Deallocate the last block in the list of free lists,
// and insert the new one in its correct position.
::operator delete(static_cast<void*>(__free_list.back()));
__free_list.pop_back();
}
}
// Just add the block to the list of free lists unconditionally.
iterator __temp = __detail::__lower_bound
(__free_list.begin(), __free_list.end(),
*__addr, _LT_pointer_compare());
// We may insert the new free list before _temp;
__free_list.insert(__temp, __addr);
}
/** @brief Decides whether the wastage of memory is acceptable for
* the current memory request and returns accordingly.
*
* @param __block_size The size of the block available in the free
* list.
*
* @param __required_size The required size of the memory block.
*
* @return true if the wastage incurred is acceptable, else returns
* false.
*/
bool
_M_should_i_give(size_t __block_size,
size_t __required_size) throw()
{
const size_t __max_wastage_percentage = 36;
if (__block_size >= __required_size &&
(((__block_size - __required_size) * 100 / __block_size)
< __max_wastage_percentage))
return true;
else
return false;
}
public:
/** @brief This function returns the block of memory to the
* internal free list.
*
* @param __addr The pointer to the memory block that was given
* by a call to the _M_get function.
*/
inline void
_M_insert(size_t* __addr) throw()
{
#if defined __GTHREADS
__scoped_lock __bfl_lock(_M_get_mutex());
#endif
// Call _M_validate to decide what should be done with
// this particular free list.
this->_M_validate(reinterpret_cast<size_t*>(__addr) - 1);
// See discussion as to why this is 1!
}
/** @brief This function gets a block of memory of the specified
* size from the free list.
*
* @param __sz The size in bytes of the memory required.
*
* @return A pointer to the new memory block of size at least
* equal to that requested.
*/
size_t*
_M_get(size_t __sz) _GLIBCXX_THROW(std::bad_alloc);
/** @brief This function just clears the internal Free List, and
* gives back all the memory to the OS.
*/
void
_M_clear();
};
// Forward declare the class.
template<typename _Tp>
class bitmap_allocator;
// Specialize for void:
template<>
class bitmap_allocator<void>
{
public:
typedef void* pointer;
typedef const void* const_pointer;
// Reference-to-void members are impossible.
typedef void value_type;
template<typename _Tp1>
struct rebind
{
typedef bitmap_allocator<_Tp1> other;
};
};
/**
* @brief Bitmap Allocator, primary template.
* @ingroup allocators
*/
template<typename _Tp>
class bitmap_allocator : private free_list
{
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef _Tp* pointer;
typedef const _Tp* const_pointer;
typedef _Tp& reference;
typedef const _Tp& const_reference;
typedef _Tp value_type;
typedef free_list::__mutex_type __mutex_type;
template<typename _Tp1>
struct rebind
{
typedef bitmap_allocator<_Tp1> other;
};
#if __cplusplus >= 201103L
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2103. propagate_on_container_move_assignment
typedef std::true_type propagate_on_container_move_assignment;
#endif
private:
template<size_t _BSize, size_t _AlignSize>
struct aligned_size
{
enum
{
modulus = _BSize % _AlignSize,
value = _BSize + (modulus ? _AlignSize - (modulus) : 0)
};
};
struct _Alloc_block
{
char __M_unused[aligned_size<sizeof(value_type),
_BALLOC_ALIGN_BYTES>::value];
};
typedef typename std::pair<_Alloc_block*, _Alloc_block*> _Block_pair;
typedef typename __detail::__mini_vector<_Block_pair> _BPVector;
typedef typename _BPVector::iterator _BPiter;
template<typename _Predicate>
static _BPiter
_S_find(_Predicate __p)
{
_BPiter __first = _S_mem_blocks.begin();
while (__first != _S_mem_blocks.end() && !__p(*__first))
++__first;
return __first;
}
#if defined _GLIBCXX_DEBUG
// Complexity: O(lg(N)). Where, N is the number of block of size
// sizeof(value_type).
void
_S_check_for_free_blocks() throw()
{
typedef typename __detail::_Ffit_finder<_Alloc_block*> _FFF;
_BPiter __bpi = _S_find(_FFF());
_GLIBCXX_DEBUG_ASSERT(__bpi == _S_mem_blocks.end());
}
#endif
/** @brief Responsible for exponentially growing the internal
* memory pool.
*
* @throw std::bad_alloc. If memory can not be allocated.
*
* Complexity: O(1), but internally depends upon the
* complexity of the function free_list::_M_get. The part where
* the bitmap headers are written has complexity: O(X),where X
* is the number of blocks of size sizeof(value_type) within
* the newly acquired block. Having a tight bound.
*/
void
_S_refill_pool() _GLIBCXX_THROW(std::bad_alloc)
{
#if defined _GLIBCXX_DEBUG
_S_check_for_free_blocks();
#endif
const size_t __num_bitmaps = (_S_block_size
/ size_t(__detail::bits_per_block));
const size_t __size_to_allocate = sizeof(size_t)
+ _S_block_size * sizeof(_Alloc_block)
+ __num_bitmaps * sizeof(size_t);
size_t* __temp =
reinterpret_cast<size_t*>(this->_M_get(__size_to_allocate));
*__temp = 0;
++__temp;
// The Header information goes at the Beginning of the Block.
_Block_pair __bp =
std::make_pair(reinterpret_cast<_Alloc_block*>
(__temp + __num_bitmaps),
reinterpret_cast<_Alloc_block*>
(__temp + __num_bitmaps)
+ _S_block_size - 1);
// Fill the Vector with this information.
_S_mem_blocks.push_back(__bp);
for (size_t __i = 0; __i < __num_bitmaps; ++__i)
__temp[__i] = ~static_cast<size_t>(0); // 1 Indicates all Free.
_S_block_size *= 2;
}
static _BPVector _S_mem_blocks;
static size_t _S_block_size;
static __detail::_Bitmap_counter<_Alloc_block*> _S_last_request;
static typename _BPVector::size_type _S_last_dealloc_index;
#if defined __GTHREADS
static __mutex_type _S_mut;
#endif
public:
/** @brief Allocates memory for a single object of size
* sizeof(_Tp).
*
* @throw std::bad_alloc. If memory can not be allocated.
*
* Complexity: Worst case complexity is O(N), but that
* is hardly ever hit. If and when this particular case is
* encountered, the next few cases are guaranteed to have a
* worst case complexity of O(1)! That's why this function
* performs very well on average. You can consider this
* function to have a complexity referred to commonly as:
* Amortized Constant time.
*/
pointer
_M_allocate_single_object() _GLIBCXX_THROW(std::bad_alloc)
{
#if defined __GTHREADS
__scoped_lock __bit_lock(_S_mut);
#endif
// The algorithm is something like this: The last_request
// variable points to the last accessed Bit Map. When such a
// condition occurs, we try to find a free block in the
// current bitmap, or succeeding bitmaps until the last bitmap
// is reached. If no free block turns up, we resort to First
// Fit method.
// WARNING: Do not re-order the condition in the while
// statement below, because it relies on C++'s short-circuit
// evaluation. The return from _S_last_request->_M_get() will
// NOT be dereference able if _S_last_request->_M_finished()
// returns true. This would inevitably lead to a NULL pointer
// dereference if tinkered with.
while (_S_last_request._M_finished() == false
&& (*(_S_last_request._M_get()) == 0))
_S_last_request.operator++();
if (__builtin_expect(_S_last_request._M_finished() == true, false))
{
// Fall Back to First Fit algorithm.
typedef typename __detail::_Ffit_finder<_Alloc_block*> _FFF;
_FFF __fff;
_BPiter __bpi = _S_find(__detail::_Functor_Ref<_FFF>(__fff));
if (__bpi != _S_mem_blocks.end())
{
// Search was successful. Ok, now mark the first bit from
// the right as 0, meaning Allocated. This bit is obtained
// by calling _M_get() on __fff.
size_t __nz_bit = _Bit_scan_forward(*__fff._M_get());
__detail::__bit_allocate(__fff._M_get(), __nz_bit);
_S_last_request._M_reset(__bpi - _S_mem_blocks.begin());
// Now, get the address of the bit we marked as allocated.
pointer __ret = reinterpret_cast<pointer>
(__bpi->first + __fff._M_offset() + __nz_bit);
size_t* __puse_count =
reinterpret_cast<size_t*>
(__bpi->first) - (__detail::__num_bitmaps(*__bpi) + 1);
++(*__puse_count);
return __ret;
}
else
{
// Search was unsuccessful. We Add more memory to the
// pool by calling _S_refill_pool().
_S_refill_pool();
// _M_Reset the _S_last_request structure to the first
// free block's bit map.
_S_last_request._M_reset(_S_mem_blocks.size() - 1);
// Now, mark that bit as allocated.
}
}
// _S_last_request holds a pointer to a valid bit map, that
// points to a free block in memory.
size_t __nz_bit = _Bit_scan_forward(*_S_last_request._M_get());
__detail::__bit_allocate(_S_last_request._M_get(), __nz_bit);
pointer __ret = reinterpret_cast<pointer>
(_S_last_request._M_base() + _S_last_request._M_offset() + __nz_bit);
size_t* __puse_count = reinterpret_cast<size_t*>
(_S_mem_blocks[_S_last_request._M_where()].first)
- (__detail::
__num_bitmaps(_S_mem_blocks[_S_last_request._M_where()]) + 1);
++(*__puse_count);
return __ret;
}
/** @brief Deallocates memory that belongs to a single object of
* size sizeof(_Tp).
*
* Complexity: O(lg(N)), but the worst case is not hit
* often! This is because containers usually deallocate memory
* close to each other and this case is handled in O(1) time by
* the deallocate function.
*/
void
_M_deallocate_single_object(pointer __p) throw()
{
#if defined __GTHREADS
__scoped_lock __bit_lock(_S_mut);
#endif
_Alloc_block* __real_p = reinterpret_cast<_Alloc_block*>(__p);
typedef typename _BPVector::iterator _Iterator;
typedef typename _BPVector::difference_type _Difference_type;
_Difference_type __diff;
long __displacement;
_GLIBCXX_DEBUG_ASSERT(_S_last_dealloc_index >= 0);
__detail::_Inclusive_between<_Alloc_block*> __ibt(__real_p);
if (__ibt(_S_mem_blocks[_S_last_dealloc_index]))
{
_GLIBCXX_DEBUG_ASSERT(_S_last_dealloc_index
<= _S_mem_blocks.size() - 1);
// Initial Assumption was correct!
__diff = _S_last_dealloc_index;
__displacement = __real_p - _S_mem_blocks[__diff].first;
}
else
{
_Iterator _iter = _S_find(__ibt);
_GLIBCXX_DEBUG_ASSERT(_iter != _S_mem_blocks.end());
__diff = _iter - _S_mem_blocks.begin();
__displacement = __real_p - _S_mem_blocks[__diff].first;
_S_last_dealloc_index = __diff;
}
// Get the position of the iterator that has been found.
const size_t __rotate = (__displacement
% size_t(__detail::bits_per_block));
size_t* __bitmapC =
reinterpret_cast<size_t*>
(_S_mem_blocks[__diff].first) - 1;
__bitmapC -= (__displacement / size_t(__detail::bits_per_block));
__detail::__bit_free(__bitmapC, __rotate);
size_t* __puse_count = reinterpret_cast<size_t*>
(_S_mem_blocks[__diff].first)
- (__detail::__num_bitmaps(_S_mem_blocks[__diff]) + 1);
_GLIBCXX_DEBUG_ASSERT(*__puse_count != 0);
--(*__puse_count);
if (__builtin_expect(*__puse_count == 0, false))
{
_S_block_size /= 2;
// We can safely remove this block.
// _Block_pair __bp = _S_mem_blocks[__diff];
this->_M_insert(__puse_count);
_S_mem_blocks.erase(_S_mem_blocks.begin() + __diff);
// Reset the _S_last_request variable to reflect the
// erased block. We do this to protect future requests
// after the last block has been removed from a particular
// memory Chunk, which in turn has been returned to the
// free list, and hence had been erased from the vector,
// so the size of the vector gets reduced by 1.
if ((_Difference_type)_S_last_request._M_where() >= __diff--)
_S_last_request._M_reset(__diff);
// If the Index into the vector of the region of memory
// that might hold the next address that will be passed to
// deallocated may have been invalidated due to the above
// erase procedure being called on the vector, hence we
// try to restore this invariant too.
if (_S_last_dealloc_index >= _S_mem_blocks.size())
{
_S_last_dealloc_index =(__diff != -1 ? __diff : 0);
_GLIBCXX_DEBUG_ASSERT(_S_last_dealloc_index >= 0);
}
}
}
public:
bitmap_allocator() _GLIBCXX_USE_NOEXCEPT
{ }
bitmap_allocator(const bitmap_allocator&) _GLIBCXX_USE_NOEXCEPT
{ }
template<typename _Tp1>
bitmap_allocator(const bitmap_allocator<_Tp1>&) _GLIBCXX_USE_NOEXCEPT
{ }
~bitmap_allocator() _GLIBCXX_USE_NOEXCEPT
{ }
pointer
allocate(size_type __n)
{
if (__n > this->max_size())
std::__throw_bad_alloc();
#if __cpp_aligned_new
if (alignof(value_type) > __STDCPP_DEFAULT_NEW_ALIGNMENT__)
{
const size_type __b = __n * sizeof(value_type);
std::align_val_t __al = std::align_val_t(alignof(value_type));
return static_cast<pointer>(::operator new(__b, __al));
}
#endif
if (__builtin_expect(__n == 1, true))
return this->_M_allocate_single_object();
else
{
const size_type __b = __n * sizeof(value_type);
return reinterpret_cast<pointer>(::operator new(__b));
}
}
pointer
allocate(size_type __n, typename bitmap_allocator<void>::const_pointer)
{ return allocate(__n); }
void
deallocate(pointer __p, size_type __n) throw()
{
if (__builtin_expect(__p != 0, true))
{
#if __cpp_aligned_new
// Types with extended alignment are handled by operator delete.
if (alignof(value_type) > __STDCPP_DEFAULT_NEW_ALIGNMENT__)
{
::operator delete(__p, std::align_val_t(alignof(value_type)));
return;
}
#endif
if (__builtin_expect(__n == 1, true))
this->_M_deallocate_single_object(__p);
else
::operator delete(__p);
}
}
pointer
address(reference __r) const _GLIBCXX_NOEXCEPT
{ return std::__addressof(__r); }
const_pointer
address(const_reference __r) const _GLIBCXX_NOEXCEPT
{ return std::__addressof(__r); }
size_type
max_size() const _GLIBCXX_USE_NOEXCEPT
{ return size_type(-1) / sizeof(value_type); }
#if __cplusplus >= 201103L
template<typename _Up, typename... _Args>
void
construct(_Up* __p, _Args&&... __args)
{ ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
template<typename _Up>
void
destroy(_Up* __p)
{ __p->~_Up(); }
#else
void
construct(pointer __p, const_reference __data)
{ ::new((void *)__p) value_type(__data); }
void
destroy(pointer __p)
{ __p->~value_type(); }
#endif
};
template<typename _Tp1, typename _Tp2>
bool
operator==(const bitmap_allocator<_Tp1>&,
const bitmap_allocator<_Tp2>&) throw()
{ return true; }
template<typename _Tp1, typename _Tp2>
bool
operator!=(const bitmap_allocator<_Tp1>&,
const bitmap_allocator<_Tp2>&) throw()
{ return false; }
// Static member definitions.
template<typename _Tp>
typename bitmap_allocator<_Tp>::_BPVector
bitmap_allocator<_Tp>::_S_mem_blocks;
template<typename _Tp>
size_t bitmap_allocator<_Tp>::_S_block_size =
2 * size_t(__detail::bits_per_block);
template<typename _Tp>
typename bitmap_allocator<_Tp>::_BPVector::size_type
bitmap_allocator<_Tp>::_S_last_dealloc_index = 0;
template<typename _Tp>
__detail::_Bitmap_counter
<typename bitmap_allocator<_Tp>::_Alloc_block*>
bitmap_allocator<_Tp>::_S_last_request(_S_mem_blocks);
#if defined __GTHREADS
template<typename _Tp>
typename bitmap_allocator<_Tp>::__mutex_type
bitmap_allocator<_Tp>::_S_mut;
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace __gnu_cxx
#endif
c++/8/ext/cast.h 0000644 00000010537 15201526705 0007177 0 ustar 00 // <cast.h> -*- C++ -*-
// Copyright (C) 2008-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file ext/cast.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{ext/pointer.h}
*/
#ifndef _GLIBCXX_CAST_H
#define _GLIBCXX_CAST_H 1
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* These functions are here to allow containers to support non standard
* pointer types. For normal pointers, these resolve to the use of the
* standard cast operation. For other types the functions will perform
* the appropriate cast to/from the custom pointer class so long as that
* class meets the following conditions:
* 1) has a typedef element_type which names tehe type it points to.
* 2) has a get() const method which returns element_type*.
* 3) has a constructor which can take one element_type* argument.
*/
/**
* This type supports the semantics of the pointer cast operators (below.)
*/
template<typename _ToType>
struct _Caster
{ typedef typename _ToType::element_type* type; };
template<typename _ToType>
struct _Caster<_ToType*>
{ typedef _ToType* type; };
/**
* Casting operations for cases where _FromType is not a standard pointer.
* _ToType can be a standard or non-standard pointer. Given that _FromType
* is not a pointer, it must have a get() method that returns the standard
* pointer equivalent of the address it points to, and must have an
* element_type typedef which names the type it points to.
*/
template<typename _ToType, typename _FromType>
inline _ToType
__static_pointer_cast(const _FromType& __arg)
{ return _ToType(static_cast<typename _Caster<_ToType>::
type>(__arg.get())); }
template<typename _ToType, typename _FromType>
inline _ToType
__dynamic_pointer_cast(const _FromType& __arg)
{ return _ToType(dynamic_cast<typename _Caster<_ToType>::
type>(__arg.get())); }
template<typename _ToType, typename _FromType>
inline _ToType
__const_pointer_cast(const _FromType& __arg)
{ return _ToType(const_cast<typename _Caster<_ToType>::
type>(__arg.get())); }
template<typename _ToType, typename _FromType>
inline _ToType
__reinterpret_pointer_cast(const _FromType& __arg)
{ return _ToType(reinterpret_cast<typename _Caster<_ToType>::
type>(__arg.get())); }
/**
* Casting operations for cases where _FromType is a standard pointer.
* _ToType can be a standard or non-standard pointer.
*/
template<typename _ToType, typename _FromType>
inline _ToType
__static_pointer_cast(_FromType* __arg)
{ return _ToType(static_cast<typename _Caster<_ToType>::
type>(__arg)); }
template<typename _ToType, typename _FromType>
inline _ToType
__dynamic_pointer_cast(_FromType* __arg)
{ return _ToType(dynamic_cast<typename _Caster<_ToType>::
type>(__arg)); }
template<typename _ToType, typename _FromType>
inline _ToType
__const_pointer_cast(_FromType* __arg)
{ return _ToType(const_cast<typename _Caster<_ToType>::
type>(__arg)); }
template<typename _ToType, typename _FromType>
inline _ToType
__reinterpret_pointer_cast(_FromType* __arg)
{ return _ToType(reinterpret_cast<typename _Caster<_ToType>::
type>(__arg)); }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif // _GLIBCXX_CAST_H
c++/8/ext/rc_string_base.h 0000644 00000056267 15201526705 0011243 0 ustar 00 // Reference-counted versatile string base -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file ext/rc_string_base.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{ext/vstring.h}
*/
#ifndef _RC_STRING_BASE_H
#define _RC_STRING_BASE_H 1
#include <ext/atomicity.h>
#include <bits/stl_iterator_base_funcs.h>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* Documentation? What's that?
* Nathan Myers <ncm@cantrip.org>.
*
* A string looks like this:
*
* @code
* [_Rep]
* _M_length
* [__rc_string_base<char_type>] _M_capacity
* _M_dataplus _M_refcount
* _M_p ----------------> unnamed array of char_type
* @endcode
*
* Where the _M_p points to the first character in the string, and
* you cast it to a pointer-to-_Rep and subtract 1 to get a
* pointer to the header.
*
* This approach has the enormous advantage that a string object
* requires only one allocation. All the ugliness is confined
* within a single pair of inline functions, which each compile to
* a single @a add instruction: _Rep::_M_refdata(), and
* __rc_string_base::_M_rep(); and the allocation function which gets a
* block of raw bytes and with room enough and constructs a _Rep
* object at the front.
*
* The reason you want _M_data pointing to the character array and
* not the _Rep is so that the debugger can see the string
* contents. (Probably we should add a non-inline member to get
* the _Rep for the debugger to use, so users can check the actual
* string length.)
*
* Note that the _Rep object is a POD so that you can have a
* static <em>empty string</em> _Rep object already @a constructed before
* static constructors have run. The reference-count encoding is
* chosen so that a 0 indicates one reference, so you never try to
* destroy the empty-string _Rep object.
*
* All but the last paragraph is considered pretty conventional
* for a C++ string implementation.
*/
template<typename _CharT, typename _Traits, typename _Alloc>
class __rc_string_base
: protected __vstring_utility<_CharT, _Traits, _Alloc>
{
public:
typedef _Traits traits_type;
typedef typename _Traits::char_type value_type;
typedef _Alloc allocator_type;
typedef __vstring_utility<_CharT, _Traits, _Alloc> _Util_Base;
typedef typename _Util_Base::_CharT_alloc_type _CharT_alloc_type;
typedef typename _CharT_alloc_type::size_type size_type;
private:
// _Rep: string representation
// Invariants:
// 1. String really contains _M_length + 1 characters: due to 21.3.4
// must be kept null-terminated.
// 2. _M_capacity >= _M_length
// Allocated memory is always (_M_capacity + 1) * sizeof(_CharT).
// 3. _M_refcount has three states:
// -1: leaked, one reference, no ref-copies allowed, non-const.
// 0: one reference, non-const.
// n>0: n + 1 references, operations require a lock, const.
// 4. All fields == 0 is an empty string, given the extra storage
// beyond-the-end for a null terminator; thus, the shared
// empty string representation needs no constructor.
struct _Rep
{
union
{
struct
{
size_type _M_length;
size_type _M_capacity;
_Atomic_word _M_refcount;
} _M_info;
// Only for alignment purposes.
_CharT _M_align;
};
typedef typename _Alloc::template rebind<_Rep>::other _Rep_alloc_type;
_CharT*
_M_refdata() throw()
{ return reinterpret_cast<_CharT*>(this + 1); }
_CharT*
_M_refcopy() throw()
{
__atomic_add_dispatch(&_M_info._M_refcount, 1);
return _M_refdata();
} // XXX MT
void
_M_set_length(size_type __n)
{
_M_info._M_refcount = 0; // One reference.
_M_info._M_length = __n;
// grrr. (per 21.3.4)
// You cannot leave those LWG people alone for a second.
traits_type::assign(_M_refdata()[__n], _CharT());
}
// Create & Destroy
static _Rep*
_S_create(size_type, size_type, const _Alloc&);
void
_M_destroy(const _Alloc&) throw();
_CharT*
_M_clone(const _Alloc&, size_type __res = 0);
};
struct _Rep_empty
: public _Rep
{
_CharT _M_terminal;
};
static _Rep_empty _S_empty_rep;
// The maximum number of individual char_type elements of an
// individual string is determined by _S_max_size. This is the
// value that will be returned by max_size(). (Whereas npos
// is the maximum number of bytes the allocator can allocate.)
// If one was to divvy up the theoretical largest size string,
// with a terminating character and m _CharT elements, it'd
// look like this:
// npos = sizeof(_Rep) + (m * sizeof(_CharT)) + sizeof(_CharT)
// + sizeof(_Rep) - 1
// (NB: last two terms for rounding reasons, see _M_create below)
// Solving for m:
// m = ((npos - 2 * sizeof(_Rep) + 1) / sizeof(_CharT)) - 1
// In addition, this implementation halves this amount.
enum { _S_max_size = (((static_cast<size_type>(-1) - 2 * sizeof(_Rep)
+ 1) / sizeof(_CharT)) - 1) / 2 };
// Data Member (private):
mutable typename _Util_Base::template _Alloc_hider<_Alloc> _M_dataplus;
void
_M_data(_CharT* __p)
{ _M_dataplus._M_p = __p; }
_Rep*
_M_rep() const
{ return &((reinterpret_cast<_Rep*>(_M_data()))[-1]); }
_CharT*
_M_grab(const _Alloc& __alloc) const
{
return (!_M_is_leaked() && _M_get_allocator() == __alloc)
? _M_rep()->_M_refcopy() : _M_rep()->_M_clone(__alloc);
}
void
_M_dispose()
{
// Be race-detector-friendly. For more info see bits/c++config.
_GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_rep()->_M_info.
_M_refcount);
if (__exchange_and_add_dispatch(&_M_rep()->_M_info._M_refcount,
-1) <= 0)
{
_GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_rep()->_M_info.
_M_refcount);
_M_rep()->_M_destroy(_M_get_allocator());
}
} // XXX MT
bool
_M_is_leaked() const
{ return _M_rep()->_M_info._M_refcount < 0; }
void
_M_set_sharable()
{ _M_rep()->_M_info._M_refcount = 0; }
void
_M_leak_hard();
// _S_construct_aux is used to implement the 21.3.1 para 15 which
// requires special behaviour if _InIterator is an integral type
template<typename _InIterator>
static _CharT*
_S_construct_aux(_InIterator __beg, _InIterator __end,
const _Alloc& __a, std::__false_type)
{
typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
return _S_construct(__beg, __end, __a, _Tag());
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 438. Ambiguity in the "do the right thing" clause
template<typename _Integer>
static _CharT*
_S_construct_aux(_Integer __beg, _Integer __end,
const _Alloc& __a, std::__true_type)
{ return _S_construct_aux_2(static_cast<size_type>(__beg),
__end, __a); }
static _CharT*
_S_construct_aux_2(size_type __req, _CharT __c, const _Alloc& __a)
{ return _S_construct(__req, __c, __a); }
template<typename _InIterator>
static _CharT*
_S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a)
{
typedef typename std::__is_integer<_InIterator>::__type _Integral;
return _S_construct_aux(__beg, __end, __a, _Integral());
}
// For Input Iterators, used in istreambuf_iterators, etc.
template<typename _InIterator>
static _CharT*
_S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a,
std::input_iterator_tag);
// For forward_iterators up to random_access_iterators, used for
// string::iterator, _CharT*, etc.
template<typename _FwdIterator>
static _CharT*
_S_construct(_FwdIterator __beg, _FwdIterator __end, const _Alloc& __a,
std::forward_iterator_tag);
static _CharT*
_S_construct(size_type __req, _CharT __c, const _Alloc& __a);
public:
size_type
_M_max_size() const
{ return size_type(_S_max_size); }
_CharT*
_M_data() const
{ return _M_dataplus._M_p; }
size_type
_M_length() const
{ return _M_rep()->_M_info._M_length; }
size_type
_M_capacity() const
{ return _M_rep()->_M_info._M_capacity; }
bool
_M_is_shared() const
{ return _M_rep()->_M_info._M_refcount > 0; }
void
_M_set_leaked()
{ _M_rep()->_M_info._M_refcount = -1; }
void
_M_leak() // for use in begin() & non-const op[]
{
if (!_M_is_leaked())
_M_leak_hard();
}
void
_M_set_length(size_type __n)
{ _M_rep()->_M_set_length(__n); }
__rc_string_base()
: _M_dataplus(_S_empty_rep._M_refcopy()) { }
__rc_string_base(const _Alloc& __a);
__rc_string_base(const __rc_string_base& __rcs);
#if __cplusplus >= 201103L
__rc_string_base(__rc_string_base&& __rcs)
: _M_dataplus(__rcs._M_dataplus)
{ __rcs._M_data(_S_empty_rep._M_refcopy()); }
#endif
__rc_string_base(size_type __n, _CharT __c, const _Alloc& __a);
template<typename _InputIterator>
__rc_string_base(_InputIterator __beg, _InputIterator __end,
const _Alloc& __a);
~__rc_string_base()
{ _M_dispose(); }
allocator_type&
_M_get_allocator()
{ return _M_dataplus; }
const allocator_type&
_M_get_allocator() const
{ return _M_dataplus; }
void
_M_swap(__rc_string_base& __rcs);
void
_M_assign(const __rc_string_base& __rcs);
void
_M_reserve(size_type __res);
void
_M_mutate(size_type __pos, size_type __len1, const _CharT* __s,
size_type __len2);
void
_M_erase(size_type __pos, size_type __n);
void
_M_clear()
{
_M_dispose();
_M_data(_S_empty_rep._M_refcopy());
}
bool
_M_compare(const __rc_string_base&) const
{ return false; }
};
template<typename _CharT, typename _Traits, typename _Alloc>
typename __rc_string_base<_CharT, _Traits, _Alloc>::_Rep_empty
__rc_string_base<_CharT, _Traits, _Alloc>::_S_empty_rep;
template<typename _CharT, typename _Traits, typename _Alloc>
typename __rc_string_base<_CharT, _Traits, _Alloc>::_Rep*
__rc_string_base<_CharT, _Traits, _Alloc>::_Rep::
_S_create(size_type __capacity, size_type __old_capacity,
const _Alloc& __alloc)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 83. String::npos vs. string::max_size()
if (__capacity > size_type(_S_max_size))
std::__throw_length_error(__N("__rc_string_base::_Rep::_S_create"));
// The standard places no restriction on allocating more memory
// than is strictly needed within this layer at the moment or as
// requested by an explicit application call to reserve().
// Many malloc implementations perform quite poorly when an
// application attempts to allocate memory in a stepwise fashion
// growing each allocation size by only 1 char. Additionally,
// it makes little sense to allocate less linear memory than the
// natural blocking size of the malloc implementation.
// Unfortunately, we would need a somewhat low-level calculation
// with tuned parameters to get this perfect for any particular
// malloc implementation. Fortunately, generalizations about
// common features seen among implementations seems to suffice.
// __pagesize need not match the actual VM page size for good
// results in practice, thus we pick a common value on the low
// side. __malloc_header_size is an estimate of the amount of
// overhead per memory allocation (in practice seen N * sizeof
// (void*) where N is 0, 2 or 4). According to folklore,
// picking this value on the high side is better than
// low-balling it (especially when this algorithm is used with
// malloc implementations that allocate memory blocks rounded up
// to a size which is a power of 2).
const size_type __pagesize = 4096;
const size_type __malloc_header_size = 4 * sizeof(void*);
// The below implements an exponential growth policy, necessary to
// meet amortized linear time requirements of the library: see
// http://gcc.gnu.org/ml/libstdc++/2001-07/msg00085.html.
if (__capacity > __old_capacity && __capacity < 2 * __old_capacity)
{
__capacity = 2 * __old_capacity;
// Never allocate a string bigger than _S_max_size.
if (__capacity > size_type(_S_max_size))
__capacity = size_type(_S_max_size);
}
// NB: Need an array of char_type[__capacity], plus a terminating
// null char_type() element, plus enough for the _Rep data structure,
// plus sizeof(_Rep) - 1 to upper round to a size multiple of
// sizeof(_Rep).
// Whew. Seemingly so needy, yet so elemental.
size_type __size = ((__capacity + 1) * sizeof(_CharT)
+ 2 * sizeof(_Rep) - 1);
const size_type __adj_size = __size + __malloc_header_size;
if (__adj_size > __pagesize && __capacity > __old_capacity)
{
const size_type __extra = __pagesize - __adj_size % __pagesize;
__capacity += __extra / sizeof(_CharT);
if (__capacity > size_type(_S_max_size))
__capacity = size_type(_S_max_size);
__size = (__capacity + 1) * sizeof(_CharT) + 2 * sizeof(_Rep) - 1;
}
// NB: Might throw, but no worries about a leak, mate: _Rep()
// does not throw.
_Rep* __place = _Rep_alloc_type(__alloc).allocate(__size / sizeof(_Rep));
_Rep* __p = new (__place) _Rep;
__p->_M_info._M_capacity = __capacity;
return __p;
}
template<typename _CharT, typename _Traits, typename _Alloc>
void
__rc_string_base<_CharT, _Traits, _Alloc>::_Rep::
_M_destroy(const _Alloc& __a) throw ()
{
const size_type __size = ((_M_info._M_capacity + 1) * sizeof(_CharT)
+ 2 * sizeof(_Rep) - 1);
_Rep_alloc_type(__a).deallocate(this, __size / sizeof(_Rep));
}
template<typename _CharT, typename _Traits, typename _Alloc>
_CharT*
__rc_string_base<_CharT, _Traits, _Alloc>::_Rep::
_M_clone(const _Alloc& __alloc, size_type __res)
{
// Requested capacity of the clone.
const size_type __requested_cap = _M_info._M_length + __res;
_Rep* __r = _Rep::_S_create(__requested_cap, _M_info._M_capacity,
__alloc);
if (_M_info._M_length)
__rc_string_base::_S_copy(__r->_M_refdata(), _M_refdata(), _M_info._M_length);
__r->_M_set_length(_M_info._M_length);
return __r->_M_refdata();
}
template<typename _CharT, typename _Traits, typename _Alloc>
__rc_string_base<_CharT, _Traits, _Alloc>::
__rc_string_base(const _Alloc& __a)
: _M_dataplus(__a, _S_construct(size_type(), _CharT(), __a)) { }
template<typename _CharT, typename _Traits, typename _Alloc>
__rc_string_base<_CharT, _Traits, _Alloc>::
__rc_string_base(const __rc_string_base& __rcs)
: _M_dataplus(__rcs._M_get_allocator(),
__rcs._M_grab(__rcs._M_get_allocator())) { }
template<typename _CharT, typename _Traits, typename _Alloc>
__rc_string_base<_CharT, _Traits, _Alloc>::
__rc_string_base(size_type __n, _CharT __c, const _Alloc& __a)
: _M_dataplus(__a, _S_construct(__n, __c, __a)) { }
template<typename _CharT, typename _Traits, typename _Alloc>
template<typename _InputIterator>
__rc_string_base<_CharT, _Traits, _Alloc>::
__rc_string_base(_InputIterator __beg, _InputIterator __end,
const _Alloc& __a)
: _M_dataplus(__a, _S_construct(__beg, __end, __a)) { }
template<typename _CharT, typename _Traits, typename _Alloc>
void
__rc_string_base<_CharT, _Traits, _Alloc>::
_M_leak_hard()
{
if (_M_is_shared())
_M_erase(0, 0);
_M_set_leaked();
}
// NB: This is the special case for Input Iterators, used in
// istreambuf_iterators, etc.
// Input Iterators have a cost structure very different from
// pointers, calling for a different coding style.
template<typename _CharT, typename _Traits, typename _Alloc>
template<typename _InIterator>
_CharT*
__rc_string_base<_CharT, _Traits, _Alloc>::
_S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a,
std::input_iterator_tag)
{
if (__beg == __end && __a == _Alloc())
return _S_empty_rep._M_refcopy();
// Avoid reallocation for common case.
_CharT __buf[128];
size_type __len = 0;
while (__beg != __end && __len < sizeof(__buf) / sizeof(_CharT))
{
__buf[__len++] = *__beg;
++__beg;
}
_Rep* __r = _Rep::_S_create(__len, size_type(0), __a);
_S_copy(__r->_M_refdata(), __buf, __len);
__try
{
while (__beg != __end)
{
if (__len == __r->_M_info._M_capacity)
{
// Allocate more space.
_Rep* __another = _Rep::_S_create(__len + 1, __len, __a);
_S_copy(__another->_M_refdata(), __r->_M_refdata(), __len);
__r->_M_destroy(__a);
__r = __another;
}
__r->_M_refdata()[__len++] = *__beg;
++__beg;
}
}
__catch(...)
{
__r->_M_destroy(__a);
__throw_exception_again;
}
__r->_M_set_length(__len);
return __r->_M_refdata();
}
template<typename _CharT, typename _Traits, typename _Alloc>
template<typename _InIterator>
_CharT*
__rc_string_base<_CharT, _Traits, _Alloc>::
_S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a,
std::forward_iterator_tag)
{
if (__beg == __end && __a == _Alloc())
return _S_empty_rep._M_refcopy();
// NB: Not required, but considered best practice.
if (__is_null_pointer(__beg) && __beg != __end)
std::__throw_logic_error(__N("__rc_string_base::"
"_S_construct null not valid"));
const size_type __dnew = static_cast<size_type>(std::distance(__beg,
__end));
// Check for out_of_range and length_error exceptions.
_Rep* __r = _Rep::_S_create(__dnew, size_type(0), __a);
__try
{ __rc_string_base::_S_copy_chars(__r->_M_refdata(), __beg, __end); }
__catch(...)
{
__r->_M_destroy(__a);
__throw_exception_again;
}
__r->_M_set_length(__dnew);
return __r->_M_refdata();
}
template<typename _CharT, typename _Traits, typename _Alloc>
_CharT*
__rc_string_base<_CharT, _Traits, _Alloc>::
_S_construct(size_type __n, _CharT __c, const _Alloc& __a)
{
if (__n == 0 && __a == _Alloc())
return _S_empty_rep._M_refcopy();
// Check for out_of_range and length_error exceptions.
_Rep* __r = _Rep::_S_create(__n, size_type(0), __a);
if (__n)
__rc_string_base::_S_assign(__r->_M_refdata(), __n, __c);
__r->_M_set_length(__n);
return __r->_M_refdata();
}
template<typename _CharT, typename _Traits, typename _Alloc>
void
__rc_string_base<_CharT, _Traits, _Alloc>::
_M_swap(__rc_string_base& __rcs)
{
if (_M_is_leaked())
_M_set_sharable();
if (__rcs._M_is_leaked())
__rcs._M_set_sharable();
_CharT* __tmp = _M_data();
_M_data(__rcs._M_data());
__rcs._M_data(__tmp);
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 431. Swapping containers with unequal allocators.
std::__alloc_swap<allocator_type>::_S_do_it(_M_get_allocator(),
__rcs._M_get_allocator());
}
template<typename _CharT, typename _Traits, typename _Alloc>
void
__rc_string_base<_CharT, _Traits, _Alloc>::
_M_assign(const __rc_string_base& __rcs)
{
if (_M_rep() != __rcs._M_rep())
{
_CharT* __tmp = __rcs._M_grab(_M_get_allocator());
_M_dispose();
_M_data(__tmp);
}
}
template<typename _CharT, typename _Traits, typename _Alloc>
void
__rc_string_base<_CharT, _Traits, _Alloc>::
_M_reserve(size_type __res)
{
// Make sure we don't shrink below the current size.
if (__res < _M_length())
__res = _M_length();
if (__res != _M_capacity() || _M_is_shared())
{
_CharT* __tmp = _M_rep()->_M_clone(_M_get_allocator(),
__res - _M_length());
_M_dispose();
_M_data(__tmp);
}
}
template<typename _CharT, typename _Traits, typename _Alloc>
void
__rc_string_base<_CharT, _Traits, _Alloc>::
_M_mutate(size_type __pos, size_type __len1, const _CharT* __s,
size_type __len2)
{
const size_type __how_much = _M_length() - __pos - __len1;
_Rep* __r = _Rep::_S_create(_M_length() + __len2 - __len1,
_M_capacity(), _M_get_allocator());
if (__pos)
this->_S_copy(__r->_M_refdata(), _M_data(), __pos);
if (__s && __len2)
this->_S_copy(__r->_M_refdata() + __pos, __s, __len2);
if (__how_much)
this->_S_copy(__r->_M_refdata() + __pos + __len2,
_M_data() + __pos + __len1, __how_much);
_M_dispose();
_M_data(__r->_M_refdata());
}
template<typename _CharT, typename _Traits, typename _Alloc>
void
__rc_string_base<_CharT, _Traits, _Alloc>::
_M_erase(size_type __pos, size_type __n)
{
const size_type __new_size = _M_length() - __n;
const size_type __how_much = _M_length() - __pos - __n;
if (_M_is_shared())
{
// Must reallocate.
_Rep* __r = _Rep::_S_create(__new_size, _M_capacity(),
_M_get_allocator());
if (__pos)
this->_S_copy(__r->_M_refdata(), _M_data(), __pos);
if (__how_much)
this->_S_copy(__r->_M_refdata() + __pos,
_M_data() + __pos + __n, __how_much);
_M_dispose();
_M_data(__r->_M_refdata());
}
else if (__how_much && __n)
{
// Work in-place.
this->_S_move(_M_data() + __pos,
_M_data() + __pos + __n, __how_much);
}
_M_rep()->_M_set_length(__new_size);
}
template<>
inline bool
__rc_string_base<char, std::char_traits<char>,
std::allocator<char> >::
_M_compare(const __rc_string_base& __rcs) const
{
if (_M_rep() == __rcs._M_rep())
return true;
return false;
}
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
inline bool
__rc_string_base<wchar_t, std::char_traits<wchar_t>,
std::allocator<wchar_t> >::
_M_compare(const __rc_string_base& __rcs) const
{
if (_M_rep() == __rcs._M_rep())
return true;
return false;
}
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif /* _RC_STRING_BASE_H */
c++/8/ext/cmath 0000644 00000014652 15201526705 0007115 0 ustar 00 // Math extensions -*- C++ -*-
// Copyright (C) 2013-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file ext/cmath
* This file is a GNU extension to the Standard C++ Library.
*/
#ifndef _EXT_CMATH
#define _EXT_CMATH 1
#pragma GCC system_header
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
#include <cmath>
#include <type_traits>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// A class for math constants.
template<typename _RealType>
struct __math_constants
{
static_assert(std::is_floating_point<_RealType>::value,
"template argument not a floating point type");
// Constant @f$ \pi @f$.
static constexpr _RealType __pi = 3.1415926535897932384626433832795029L;
// Constant @f$ \pi / 2 @f$.
static constexpr _RealType __pi_half = 1.5707963267948966192313216916397514L;
// Constant @f$ \pi / 3 @f$.
static constexpr _RealType __pi_third = 1.0471975511965977461542144610931676L;
// Constant @f$ \pi / 4 @f$.
static constexpr _RealType __pi_quarter = 0.7853981633974483096156608458198757L;
// Constant @f$ \sqrt(\pi / 2) @f$.
static constexpr _RealType __root_pi_div_2 = 1.2533141373155002512078826424055226L;
// Constant @f$ 1 / \pi @f$.
static constexpr _RealType __one_div_pi = 0.3183098861837906715377675267450287L;
// Constant @f$ 2 / \pi @f$.
static constexpr _RealType __two_div_pi = 0.6366197723675813430755350534900574L;
// Constant @f$ 2 / \sqrt(\pi) @f$.
static constexpr _RealType __two_div_root_pi = 1.1283791670955125738961589031215452L;
// Constant Euler's number @f$ e @f$.
static constexpr _RealType __e = 2.7182818284590452353602874713526625L;
// Constant @f$ 1 / e @f$.
static constexpr _RealType __one_div_e = 0.36787944117144232159552377016146087L;
// Constant @f$ \log_2(e) @f$.
static constexpr _RealType __log2_e = 1.4426950408889634073599246810018921L;
// Constant @f$ \log_10(e) @f$.
static constexpr _RealType __log10_e = 0.4342944819032518276511289189166051L;
// Constant @f$ \ln(2) @f$.
static constexpr _RealType __ln_2 = 0.6931471805599453094172321214581766L;
// Constant @f$ \ln(3) @f$.
static constexpr _RealType __ln_3 = 1.0986122886681096913952452369225257L;
// Constant @f$ \ln(10) @f$.
static constexpr _RealType __ln_10 = 2.3025850929940456840179914546843642L;
// Constant Euler-Mascheroni @f$ \gamma_E @f$.
static constexpr _RealType __gamma_e = 0.5772156649015328606065120900824024L;
// Constant Golden Ratio @f$ \phi @f$.
static constexpr _RealType __phi = 1.6180339887498948482045868343656381L;
// Constant @f$ \sqrt(2) @f$.
static constexpr _RealType __root_2 = 1.4142135623730950488016887242096981L;
// Constant @f$ \sqrt(3) @f$.
static constexpr _RealType __root_3 = 1.7320508075688772935274463415058724L;
// Constant @f$ \sqrt(5) @f$.
static constexpr _RealType __root_5 = 2.2360679774997896964091736687312762L;
// Constant @f$ \sqrt(7) @f$.
static constexpr _RealType __root_7 = 2.6457513110645905905016157536392604L;
// Constant @f$ 1 / \sqrt(2) @f$.
static constexpr _RealType __one_div_root_2 = 0.7071067811865475244008443621048490L;
};
// And the template definitions for the constants.
template<typename _RealType>
constexpr _RealType __math_constants<_RealType>::__pi;
template<typename _RealType>
constexpr _RealType __math_constants<_RealType>::__pi_half;
template<typename _RealType>
constexpr _RealType __math_constants<_RealType>::__pi_third;
template<typename _RealType>
constexpr _RealType __math_constants<_RealType>::__pi_quarter;
template<typename _RealType>
constexpr _RealType __math_constants<_RealType>::__root_pi_div_2;
template<typename _RealType>
constexpr _RealType __math_constants<_RealType>::__one_div_pi;
template<typename _RealType>
constexpr _RealType __math_constants<_RealType>::__two_div_pi;
template<typename _RealType>
constexpr _RealType __math_constants<_RealType>::__two_div_root_pi;
template<typename _RealType>
constexpr _RealType __math_constants<_RealType>::__e;
template<typename _RealType>
constexpr _RealType __math_constants<_RealType>::__one_div_e;
template<typename _RealType>
constexpr _RealType __math_constants<_RealType>::__log2_e;
template<typename _RealType>
constexpr _RealType __math_constants<_RealType>::__log10_e;
template<typename _RealType>
constexpr _RealType __math_constants<_RealType>::__ln_2;
template<typename _RealType>
constexpr _RealType __math_constants<_RealType>::__ln_3;
template<typename _RealType>
constexpr _RealType __math_constants<_RealType>::__ln_10;
template<typename _RealType>
constexpr _RealType __math_constants<_RealType>::__gamma_e;
template<typename _RealType>
constexpr _RealType __math_constants<_RealType>::__phi;
template<typename _RealType>
constexpr _RealType __math_constants<_RealType>::__root_2;
template<typename _RealType>
constexpr _RealType __math_constants<_RealType>::__root_3;
template<typename _RealType>
constexpr _RealType __math_constants<_RealType>::__root_5;
template<typename _RealType>
constexpr _RealType __math_constants<_RealType>::__root_7;
template<typename _RealType>
constexpr _RealType __math_constants<_RealType>::__one_div_root_2;
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace __gnu_cxx
#endif // C++11
#endif // _EXT_CMATH
c++/8/ext/mt_allocator.h 0000644 00000055723 15201526705 0010733 0 ustar 00 // MT-optimized allocator -*- C++ -*-
// Copyright (C) 2003-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file ext/mt_allocator.h
* This file is a GNU extension to the Standard C++ Library.
*/
#ifndef _MT_ALLOCATOR_H
#define _MT_ALLOCATOR_H 1
#include <new>
#include <cstdlib>
#include <bits/functexcept.h>
#include <ext/atomicity.h>
#include <bits/move.h>
#if __cplusplus >= 201103L
#include <type_traits>
#endif
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using std::size_t;
using std::ptrdiff_t;
typedef void (*__destroy_handler)(void*);
/// Base class for pool object.
struct __pool_base
{
// Using short int as type for the binmap implies we are never
// caching blocks larger than 32768 with this allocator.
typedef unsigned short int _Binmap_type;
// Variables used to configure the behavior of the allocator,
// assigned and explained in detail below.
struct _Tune
{
// Compile time constants for the default _Tune values.
enum { _S_align = 8 };
enum { _S_max_bytes = 128 };
enum { _S_min_bin = 8 };
enum { _S_chunk_size = 4096 - 4 * sizeof(void*) };
enum { _S_max_threads = 4096 };
enum { _S_freelist_headroom = 10 };
// Alignment needed.
// NB: In any case must be >= sizeof(_Block_record), that
// is 4 on 32 bit machines and 8 on 64 bit machines.
size_t _M_align;
// Allocation requests (after round-up to power of 2) below
// this value will be handled by the allocator. A raw new/
// call will be used for requests larger than this value.
// NB: Must be much smaller than _M_chunk_size and in any
// case <= 32768.
size_t _M_max_bytes;
// Size in bytes of the smallest bin.
// NB: Must be a power of 2 and >= _M_align (and of course
// much smaller than _M_max_bytes).
size_t _M_min_bin;
// In order to avoid fragmenting and minimize the number of
// new() calls we always request new memory using this
// value. Based on previous discussions on the libstdc++
// mailing list we have chosen the value below.
// See http://gcc.gnu.org/ml/libstdc++/2001-07/msg00077.html
// NB: At least one order of magnitude > _M_max_bytes.
size_t _M_chunk_size;
// The maximum number of supported threads. For
// single-threaded operation, use one. Maximum values will
// vary depending on details of the underlying system. (For
// instance, Linux 2.4.18 reports 4070 in
// /proc/sys/kernel/threads-max, while Linux 2.6.6 reports
// 65534)
size_t _M_max_threads;
// Each time a deallocation occurs in a threaded application
// we make sure that there are no more than
// _M_freelist_headroom % of used memory on the freelist. If
// the number of additional records is more than
// _M_freelist_headroom % of the freelist, we move these
// records back to the global pool.
size_t _M_freelist_headroom;
// Set to true forces all allocations to use new().
bool _M_force_new;
explicit
_Tune()
: _M_align(_S_align), _M_max_bytes(_S_max_bytes), _M_min_bin(_S_min_bin),
_M_chunk_size(_S_chunk_size), _M_max_threads(_S_max_threads),
_M_freelist_headroom(_S_freelist_headroom),
_M_force_new(std::getenv("GLIBCXX_FORCE_NEW") ? true : false)
{ }
explicit
_Tune(size_t __align, size_t __maxb, size_t __minbin, size_t __chunk,
size_t __maxthreads, size_t __headroom, bool __force)
: _M_align(__align), _M_max_bytes(__maxb), _M_min_bin(__minbin),
_M_chunk_size(__chunk), _M_max_threads(__maxthreads),
_M_freelist_headroom(__headroom), _M_force_new(__force)
{ }
};
struct _Block_address
{
void* _M_initial;
_Block_address* _M_next;
};
const _Tune&
_M_get_options() const
{ return _M_options; }
void
_M_set_options(_Tune __t)
{
if (!_M_init)
_M_options = __t;
}
bool
_M_check_threshold(size_t __bytes)
{ return __bytes > _M_options._M_max_bytes || _M_options._M_force_new; }
size_t
_M_get_binmap(size_t __bytes)
{ return _M_binmap[__bytes]; }
size_t
_M_get_align()
{ return _M_options._M_align; }
explicit
__pool_base()
: _M_options(_Tune()), _M_binmap(0), _M_init(false) { }
explicit
__pool_base(const _Tune& __options)
: _M_options(__options), _M_binmap(0), _M_init(false) { }
private:
explicit
__pool_base(const __pool_base&);
__pool_base&
operator=(const __pool_base&);
protected:
// Configuration options.
_Tune _M_options;
_Binmap_type* _M_binmap;
// Configuration of the pool object via _M_options can happen
// after construction but before initialization. After
// initialization is complete, this variable is set to true.
bool _M_init;
};
/**
* @brief Data describing the underlying memory pool, parameterized on
* threading support.
*/
template<bool _Thread>
class __pool;
/// Specialization for single thread.
template<>
class __pool<false> : public __pool_base
{
public:
union _Block_record
{
// Points to the block_record of the next free block.
_Block_record* _M_next;
};
struct _Bin_record
{
// An "array" of pointers to the first free block.
_Block_record** _M_first;
// A list of the initial addresses of all allocated blocks.
_Block_address* _M_address;
};
void
_M_initialize_once()
{
if (__builtin_expect(_M_init == false, false))
_M_initialize();
}
void
_M_destroy() throw();
char*
_M_reserve_block(size_t __bytes, const size_t __thread_id);
void
_M_reclaim_block(char* __p, size_t __bytes) throw ();
size_t
_M_get_thread_id() { return 0; }
const _Bin_record&
_M_get_bin(size_t __which)
{ return _M_bin[__which]; }
void
_M_adjust_freelist(const _Bin_record&, _Block_record*, size_t)
{ }
explicit __pool()
: _M_bin(0), _M_bin_size(1) { }
explicit __pool(const __pool_base::_Tune& __tune)
: __pool_base(__tune), _M_bin(0), _M_bin_size(1) { }
private:
// An "array" of bin_records each of which represents a specific
// power of 2 size. Memory to this "array" is allocated in
// _M_initialize().
_Bin_record* _M_bin;
// Actual value calculated in _M_initialize().
size_t _M_bin_size;
void
_M_initialize();
};
#ifdef __GTHREADS
/// Specialization for thread enabled, via gthreads.h.
template<>
class __pool<true> : public __pool_base
{
public:
// Each requesting thread is assigned an id ranging from 1 to
// _S_max_threads. Thread id 0 is used as a global memory pool.
// In order to get constant performance on the thread assignment
// routine, we keep a list of free ids. When a thread first
// requests memory we remove the first record in this list and
// stores the address in a __gthread_key. When initializing the
// __gthread_key we specify a destructor. When this destructor
// (i.e. the thread dies) is called, we return the thread id to
// the front of this list.
struct _Thread_record
{
// Points to next free thread id record. NULL if last record in list.
_Thread_record* _M_next;
// Thread id ranging from 1 to _S_max_threads.
size_t _M_id;
};
union _Block_record
{
// Points to the block_record of the next free block.
_Block_record* _M_next;
// The thread id of the thread which has requested this block.
size_t _M_thread_id;
};
struct _Bin_record
{
// An "array" of pointers to the first free block for each
// thread id. Memory to this "array" is allocated in
// _S_initialize() for _S_max_threads + global pool 0.
_Block_record** _M_first;
// A list of the initial addresses of all allocated blocks.
_Block_address* _M_address;
// An "array" of counters used to keep track of the amount of
// blocks that are on the freelist/used for each thread id.
// - Note that the second part of the allocated _M_used "array"
// actually hosts (atomic) counters of reclaimed blocks: in
// _M_reserve_block and in _M_reclaim_block those numbers are
// subtracted from the first ones to obtain the actual size
// of the "working set" of the given thread.
// - Memory to these "arrays" is allocated in _S_initialize()
// for _S_max_threads + global pool 0.
size_t* _M_free;
size_t* _M_used;
// Each bin has its own mutex which is used to ensure data
// integrity while changing "ownership" on a block. The mutex
// is initialized in _S_initialize().
__gthread_mutex_t* _M_mutex;
};
// XXX GLIBCXX_ABI Deprecated
void
_M_initialize(__destroy_handler);
void
_M_initialize_once()
{
if (__builtin_expect(_M_init == false, false))
_M_initialize();
}
void
_M_destroy() throw();
char*
_M_reserve_block(size_t __bytes, const size_t __thread_id);
void
_M_reclaim_block(char* __p, size_t __bytes) throw ();
const _Bin_record&
_M_get_bin(size_t __which)
{ return _M_bin[__which]; }
void
_M_adjust_freelist(const _Bin_record& __bin, _Block_record* __block,
size_t __thread_id)
{
if (__gthread_active_p())
{
__block->_M_thread_id = __thread_id;
--__bin._M_free[__thread_id];
++__bin._M_used[__thread_id];
}
}
// XXX GLIBCXX_ABI Deprecated
void
_M_destroy_thread_key(void*) throw ();
size_t
_M_get_thread_id();
explicit __pool()
: _M_bin(0), _M_bin_size(1), _M_thread_freelist(0)
{ }
explicit __pool(const __pool_base::_Tune& __tune)
: __pool_base(__tune), _M_bin(0), _M_bin_size(1),
_M_thread_freelist(0)
{ }
private:
// An "array" of bin_records each of which represents a specific
// power of 2 size. Memory to this "array" is allocated in
// _M_initialize().
_Bin_record* _M_bin;
// Actual value calculated in _M_initialize().
size_t _M_bin_size;
_Thread_record* _M_thread_freelist;
void* _M_thread_freelist_initial;
void
_M_initialize();
};
#endif
template<template <bool> class _PoolTp, bool _Thread>
struct __common_pool
{
typedef _PoolTp<_Thread> pool_type;
static pool_type&
_S_get_pool()
{
static pool_type _S_pool;
return _S_pool;
}
};
template<template <bool> class _PoolTp, bool _Thread>
struct __common_pool_base;
template<template <bool> class _PoolTp>
struct __common_pool_base<_PoolTp, false>
: public __common_pool<_PoolTp, false>
{
using __common_pool<_PoolTp, false>::_S_get_pool;
static void
_S_initialize_once()
{
static bool __init;
if (__builtin_expect(__init == false, false))
{
_S_get_pool()._M_initialize_once();
__init = true;
}
}
};
#ifdef __GTHREADS
template<template <bool> class _PoolTp>
struct __common_pool_base<_PoolTp, true>
: public __common_pool<_PoolTp, true>
{
using __common_pool<_PoolTp, true>::_S_get_pool;
static void
_S_initialize()
{ _S_get_pool()._M_initialize_once(); }
static void
_S_initialize_once()
{
static bool __init;
if (__builtin_expect(__init == false, false))
{
if (__gthread_active_p())
{
// On some platforms, __gthread_once_t is an aggregate.
static __gthread_once_t __once = __GTHREAD_ONCE_INIT;
__gthread_once(&__once, _S_initialize);
}
// Double check initialization. May be necessary on some
// systems for proper construction when not compiling with
// thread flags.
_S_get_pool()._M_initialize_once();
__init = true;
}
}
};
#endif
/// Policy for shared __pool objects.
template<template <bool> class _PoolTp, bool _Thread>
struct __common_pool_policy : public __common_pool_base<_PoolTp, _Thread>
{
template<typename _Tp1, template <bool> class _PoolTp1 = _PoolTp,
bool _Thread1 = _Thread>
struct _M_rebind
{ typedef __common_pool_policy<_PoolTp1, _Thread1> other; };
using __common_pool_base<_PoolTp, _Thread>::_S_get_pool;
using __common_pool_base<_PoolTp, _Thread>::_S_initialize_once;
};
template<typename _Tp, template <bool> class _PoolTp, bool _Thread>
struct __per_type_pool
{
typedef _Tp value_type;
typedef _PoolTp<_Thread> pool_type;
static pool_type&
_S_get_pool()
{
// Sane defaults for the _PoolTp.
typedef typename pool_type::_Block_record _Block_record;
const static size_t __a = (__alignof__(_Tp) >= sizeof(_Block_record)
? __alignof__(_Tp) : sizeof(_Block_record));
typedef typename __pool_base::_Tune _Tune;
static _Tune _S_tune(__a, sizeof(_Tp) * 64,
sizeof(_Tp) * 2 >= __a ? sizeof(_Tp) * 2 : __a,
sizeof(_Tp) * size_t(_Tune::_S_chunk_size),
_Tune::_S_max_threads,
_Tune::_S_freelist_headroom,
std::getenv("GLIBCXX_FORCE_NEW") ? true : false);
static pool_type _S_pool(_S_tune);
return _S_pool;
}
};
template<typename _Tp, template <bool> class _PoolTp, bool _Thread>
struct __per_type_pool_base;
template<typename _Tp, template <bool> class _PoolTp>
struct __per_type_pool_base<_Tp, _PoolTp, false>
: public __per_type_pool<_Tp, _PoolTp, false>
{
using __per_type_pool<_Tp, _PoolTp, false>::_S_get_pool;
static void
_S_initialize_once()
{
static bool __init;
if (__builtin_expect(__init == false, false))
{
_S_get_pool()._M_initialize_once();
__init = true;
}
}
};
#ifdef __GTHREADS
template<typename _Tp, template <bool> class _PoolTp>
struct __per_type_pool_base<_Tp, _PoolTp, true>
: public __per_type_pool<_Tp, _PoolTp, true>
{
using __per_type_pool<_Tp, _PoolTp, true>::_S_get_pool;
static void
_S_initialize()
{ _S_get_pool()._M_initialize_once(); }
static void
_S_initialize_once()
{
static bool __init;
if (__builtin_expect(__init == false, false))
{
if (__gthread_active_p())
{
// On some platforms, __gthread_once_t is an aggregate.
static __gthread_once_t __once = __GTHREAD_ONCE_INIT;
__gthread_once(&__once, _S_initialize);
}
// Double check initialization. May be necessary on some
// systems for proper construction when not compiling with
// thread flags.
_S_get_pool()._M_initialize_once();
__init = true;
}
}
};
#endif
/// Policy for individual __pool objects.
template<typename _Tp, template <bool> class _PoolTp, bool _Thread>
struct __per_type_pool_policy
: public __per_type_pool_base<_Tp, _PoolTp, _Thread>
{
template<typename _Tp1, template <bool> class _PoolTp1 = _PoolTp,
bool _Thread1 = _Thread>
struct _M_rebind
{ typedef __per_type_pool_policy<_Tp1, _PoolTp1, _Thread1> other; };
using __per_type_pool_base<_Tp, _PoolTp, _Thread>::_S_get_pool;
using __per_type_pool_base<_Tp, _PoolTp, _Thread>::_S_initialize_once;
};
/// Base class for _Tp dependent member functions.
template<typename _Tp>
class __mt_alloc_base
{
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef _Tp* pointer;
typedef const _Tp* const_pointer;
typedef _Tp& reference;
typedef const _Tp& const_reference;
typedef _Tp value_type;
#if __cplusplus >= 201103L
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2103. propagate_on_container_move_assignment
typedef std::true_type propagate_on_container_move_assignment;
#endif
pointer
address(reference __x) const _GLIBCXX_NOEXCEPT
{ return std::__addressof(__x); }
const_pointer
address(const_reference __x) const _GLIBCXX_NOEXCEPT
{ return std::__addressof(__x); }
size_type
max_size() const _GLIBCXX_USE_NOEXCEPT
{ return size_t(-1) / sizeof(_Tp); }
#if __cplusplus >= 201103L
template<typename _Up, typename... _Args>
void
construct(_Up* __p, _Args&&... __args)
{ ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
template<typename _Up>
void
destroy(_Up* __p) { __p->~_Up(); }
#else
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 402. wrong new expression in [some_] allocator::construct
void
construct(pointer __p, const _Tp& __val)
{ ::new((void *)__p) _Tp(__val); }
void
destroy(pointer __p) { __p->~_Tp(); }
#endif
};
#ifdef __GTHREADS
#define __thread_default true
#else
#define __thread_default false
#endif
/**
* @brief This is a fixed size (power of 2) allocator which - when
* compiled with thread support - will maintain one freelist per
* size per thread plus a @a global one. Steps are taken to limit
* the per thread freelist sizes (by returning excess back to
* the @a global list).
* @ingroup allocators
*
* Further details:
* https://gcc.gnu.org/onlinedocs/libstdc++/manual/mt_allocator.html
*/
template<typename _Tp,
typename _Poolp = __common_pool_policy<__pool, __thread_default> >
class __mt_alloc : public __mt_alloc_base<_Tp>
{
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef _Tp* pointer;
typedef const _Tp* const_pointer;
typedef _Tp& reference;
typedef const _Tp& const_reference;
typedef _Tp value_type;
typedef _Poolp __policy_type;
typedef typename _Poolp::pool_type __pool_type;
template<typename _Tp1, typename _Poolp1 = _Poolp>
struct rebind
{
typedef typename _Poolp1::template _M_rebind<_Tp1>::other pol_type;
typedef __mt_alloc<_Tp1, pol_type> other;
};
__mt_alloc() _GLIBCXX_USE_NOEXCEPT { }
__mt_alloc(const __mt_alloc&) _GLIBCXX_USE_NOEXCEPT { }
template<typename _Tp1, typename _Poolp1>
__mt_alloc(const __mt_alloc<_Tp1, _Poolp1>&) _GLIBCXX_USE_NOEXCEPT { }
~__mt_alloc() _GLIBCXX_USE_NOEXCEPT { }
pointer
allocate(size_type __n, const void* = 0);
void
deallocate(pointer __p, size_type __n);
const __pool_base::_Tune
_M_get_options()
{
// Return a copy, not a reference, for external consumption.
return __policy_type::_S_get_pool()._M_get_options();
}
void
_M_set_options(__pool_base::_Tune __t)
{ __policy_type::_S_get_pool()._M_set_options(__t); }
};
template<typename _Tp, typename _Poolp>
typename __mt_alloc<_Tp, _Poolp>::pointer
__mt_alloc<_Tp, _Poolp>::
allocate(size_type __n, const void*)
{
if (__n > this->max_size())
std::__throw_bad_alloc();
#if __cpp_aligned_new
// Types with extended alignment are handled by operator new/delete.
if (alignof(_Tp) > __STDCPP_DEFAULT_NEW_ALIGNMENT__)
{
std::align_val_t __al = std::align_val_t(alignof(_Tp));
return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp), __al));
}
#endif
__policy_type::_S_initialize_once();
// Requests larger than _M_max_bytes are handled by operator
// new/delete directly.
__pool_type& __pool = __policy_type::_S_get_pool();
const size_t __bytes = __n * sizeof(_Tp);
if (__pool._M_check_threshold(__bytes))
{
void* __ret = ::operator new(__bytes);
return static_cast<_Tp*>(__ret);
}
// Round up to power of 2 and figure out which bin to use.
const size_t __which = __pool._M_get_binmap(__bytes);
const size_t __thread_id = __pool._M_get_thread_id();
// Find out if we have blocks on our freelist. If so, go ahead
// and use them directly without having to lock anything.
char* __c;
typedef typename __pool_type::_Bin_record _Bin_record;
const _Bin_record& __bin = __pool._M_get_bin(__which);
if (__bin._M_first[__thread_id])
{
// Already reserved.
typedef typename __pool_type::_Block_record _Block_record;
_Block_record* __block = __bin._M_first[__thread_id];
__bin._M_first[__thread_id] = __block->_M_next;
__pool._M_adjust_freelist(__bin, __block, __thread_id);
__c = reinterpret_cast<char*>(__block) + __pool._M_get_align();
}
else
{
// Null, reserve.
__c = __pool._M_reserve_block(__bytes, __thread_id);
}
return static_cast<_Tp*>(static_cast<void*>(__c));
}
template<typename _Tp, typename _Poolp>
void
__mt_alloc<_Tp, _Poolp>::
deallocate(pointer __p, size_type __n)
{
if (__builtin_expect(__p != 0, true))
{
#if __cpp_aligned_new
// Types with extended alignment are handled by operator new/delete.
if (alignof(_Tp) > __STDCPP_DEFAULT_NEW_ALIGNMENT__)
{
::operator delete(__p, std::align_val_t(alignof(_Tp)));
return;
}
#endif
// Requests larger than _M_max_bytes are handled by
// operators new/delete directly.
__pool_type& __pool = __policy_type::_S_get_pool();
const size_t __bytes = __n * sizeof(_Tp);
if (__pool._M_check_threshold(__bytes))
::operator delete(__p);
else
__pool._M_reclaim_block(reinterpret_cast<char*>(__p), __bytes);
}
}
template<typename _Tp, typename _Poolp>
inline bool
operator==(const __mt_alloc<_Tp, _Poolp>&, const __mt_alloc<_Tp, _Poolp>&)
{ return true; }
template<typename _Tp, typename _Poolp>
inline bool
operator!=(const __mt_alloc<_Tp, _Poolp>&, const __mt_alloc<_Tp, _Poolp>&)
{ return false; }
#undef __thread_default
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/ext/iterator 0000644 00000007677 15201526705 0007663 0 ustar 00 // HP/SGI iterator extensions -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1996-1998
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file ext/iterator
* This file is a GNU extension to the Standard C++ Library (possibly
* containing extensions from the HP/SGI STL subset).
*/
#ifndef _EXT_ITERATOR
#define _EXT_ITERATOR 1
#pragma GCC system_header
#include <bits/concept_check.h>
#include <iterator>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// There are two signatures for distance. In addition to the one
// taking two iterators and returning a result, there is another
// taking two iterators and a reference-to-result variable, and
// returning nothing. The latter seems to be an SGI extension.
// -- pedwards
template<typename _InputIterator, typename _Distance>
inline void
__distance(_InputIterator __first, _InputIterator __last,
_Distance& __n, std::input_iterator_tag)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
while (__first != __last)
{
++__first;
++__n;
}
}
template<typename _RandomAccessIterator, typename _Distance>
inline void
__distance(_RandomAccessIterator __first, _RandomAccessIterator __last,
_Distance& __n, std::random_access_iterator_tag)
{
// concept requirements
__glibcxx_function_requires(_RandomAccessIteratorConcept<
_RandomAccessIterator>)
__n += __last - __first;
}
/**
* This is an SGI extension.
* @ingroup SGIextensions
* @doctodo
*/
template<typename _InputIterator, typename _Distance>
inline void
distance(_InputIterator __first, _InputIterator __last,
_Distance& __n)
{
// concept requirements -- taken care of in __distance
__distance(__first, __last, __n, std::__iterator_category(__first));
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/ext/random 0000644 00000331443 15201526705 0007301 0 ustar 00 // Random number extensions -*- C++ -*-
// Copyright (C) 2012-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file ext/random
* This file is a GNU extension to the Standard C++ Library.
*/
#ifndef _EXT_RANDOM
#define _EXT_RANDOM 1
#pragma GCC system_header
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
#include <random>
#include <algorithm>
#include <array>
#include <ext/cmath>
#ifdef __SSE2__
# include <emmintrin.h>
#endif
#if defined(_GLIBCXX_USE_C99_STDINT_TR1) && defined(UINT32_C)
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
/* Mersenne twister implementation optimized for vector operations.
*
* Reference: http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/
*/
template<typename _UIntType, size_t __m,
size_t __pos1, size_t __sl1, size_t __sl2,
size_t __sr1, size_t __sr2,
uint32_t __msk1, uint32_t __msk2,
uint32_t __msk3, uint32_t __msk4,
uint32_t __parity1, uint32_t __parity2,
uint32_t __parity3, uint32_t __parity4>
class simd_fast_mersenne_twister_engine
{
static_assert(std::is_unsigned<_UIntType>::value, "template argument "
"substituting _UIntType not an unsigned integral type");
static_assert(__sr1 < 32, "first right shift too large");
static_assert(__sr2 < 16, "second right shift too large");
static_assert(__sl1 < 32, "first left shift too large");
static_assert(__sl2 < 16, "second left shift too large");
public:
typedef _UIntType result_type;
private:
static constexpr size_t m_w = sizeof(result_type) * 8;
static constexpr size_t _M_nstate = __m / 128 + 1;
static constexpr size_t _M_nstate32 = _M_nstate * 4;
static_assert(std::is_unsigned<_UIntType>::value, "template argument "
"substituting _UIntType not an unsigned integral type");
static_assert(__pos1 < _M_nstate, "POS1 not smaller than state size");
static_assert(16 % sizeof(_UIntType) == 0,
"UIntType size must divide 16");
public:
static constexpr size_t state_size = _M_nstate * (16
/ sizeof(result_type));
static constexpr result_type default_seed = 5489u;
// constructors and member function
explicit
simd_fast_mersenne_twister_engine(result_type __sd = default_seed)
{ seed(__sd); }
template<typename _Sseq, typename = typename
std::enable_if<!std::is_same<_Sseq,
simd_fast_mersenne_twister_engine>::value>
::type>
explicit
simd_fast_mersenne_twister_engine(_Sseq& __q)
{ seed(__q); }
void
seed(result_type __sd = default_seed);
template<typename _Sseq>
typename std::enable_if<std::is_class<_Sseq>::value>::type
seed(_Sseq& __q);
static constexpr result_type
min()
{ return 0; }
static constexpr result_type
max()
{ return std::numeric_limits<result_type>::max(); }
void
discard(unsigned long long __z);
result_type
operator()()
{
if (__builtin_expect(_M_pos >= state_size, 0))
_M_gen_rand();
return _M_stateT[_M_pos++];
}
template<typename _UIntType_2, size_t __m_2,
size_t __pos1_2, size_t __sl1_2, size_t __sl2_2,
size_t __sr1_2, size_t __sr2_2,
uint32_t __msk1_2, uint32_t __msk2_2,
uint32_t __msk3_2, uint32_t __msk4_2,
uint32_t __parity1_2, uint32_t __parity2_2,
uint32_t __parity3_2, uint32_t __parity4_2>
friend bool
operator==(const simd_fast_mersenne_twister_engine<_UIntType_2,
__m_2, __pos1_2, __sl1_2, __sl2_2, __sr1_2, __sr2_2,
__msk1_2, __msk2_2, __msk3_2, __msk4_2,
__parity1_2, __parity2_2, __parity3_2, __parity4_2>& __lhs,
const simd_fast_mersenne_twister_engine<_UIntType_2,
__m_2, __pos1_2, __sl1_2, __sl2_2, __sr1_2, __sr2_2,
__msk1_2, __msk2_2, __msk3_2, __msk4_2,
__parity1_2, __parity2_2, __parity3_2, __parity4_2>& __rhs);
template<typename _UIntType_2, size_t __m_2,
size_t __pos1_2, size_t __sl1_2, size_t __sl2_2,
size_t __sr1_2, size_t __sr2_2,
uint32_t __msk1_2, uint32_t __msk2_2,
uint32_t __msk3_2, uint32_t __msk4_2,
uint32_t __parity1_2, uint32_t __parity2_2,
uint32_t __parity3_2, uint32_t __parity4_2,
typename _CharT, typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const __gnu_cxx::simd_fast_mersenne_twister_engine
<_UIntType_2,
__m_2, __pos1_2, __sl1_2, __sl2_2, __sr1_2, __sr2_2,
__msk1_2, __msk2_2, __msk3_2, __msk4_2,
__parity1_2, __parity2_2, __parity3_2, __parity4_2>& __x);
template<typename _UIntType_2, size_t __m_2,
size_t __pos1_2, size_t __sl1_2, size_t __sl2_2,
size_t __sr1_2, size_t __sr2_2,
uint32_t __msk1_2, uint32_t __msk2_2,
uint32_t __msk3_2, uint32_t __msk4_2,
uint32_t __parity1_2, uint32_t __parity2_2,
uint32_t __parity3_2, uint32_t __parity4_2,
typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
__gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType_2,
__m_2, __pos1_2, __sl1_2, __sl2_2, __sr1_2, __sr2_2,
__msk1_2, __msk2_2, __msk3_2, __msk4_2,
__parity1_2, __parity2_2, __parity3_2, __parity4_2>& __x);
private:
union
{
#ifdef __SSE2__
__m128i _M_state[_M_nstate];
#endif
#ifdef __ARM_NEON
#ifdef __aarch64__
__Uint32x4_t _M_state[_M_nstate];
#endif
#endif
uint32_t _M_state32[_M_nstate32];
result_type _M_stateT[state_size];
} __attribute__ ((__aligned__ (16)));
size_t _M_pos;
void _M_gen_rand(void);
void _M_period_certification();
};
template<typename _UIntType, size_t __m,
size_t __pos1, size_t __sl1, size_t __sl2,
size_t __sr1, size_t __sr2,
uint32_t __msk1, uint32_t __msk2,
uint32_t __msk3, uint32_t __msk4,
uint32_t __parity1, uint32_t __parity2,
uint32_t __parity3, uint32_t __parity4>
inline bool
operator!=(const __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType,
__m, __pos1, __sl1, __sl2, __sr1, __sr2, __msk1, __msk2, __msk3,
__msk4, __parity1, __parity2, __parity3, __parity4>& __lhs,
const __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType,
__m, __pos1, __sl1, __sl2, __sr1, __sr2, __msk1, __msk2, __msk3,
__msk4, __parity1, __parity2, __parity3, __parity4>& __rhs)
{ return !(__lhs == __rhs); }
/* Definitions for the SIMD-oriented Fast Mersenne Twister as defined
* in the C implementation by Daito and Matsumoto, as both a 32-bit
* and 64-bit version.
*/
typedef simd_fast_mersenne_twister_engine<uint32_t, 607, 2,
15, 3, 13, 3,
0xfdff37ffU, 0xef7f3f7dU,
0xff777b7dU, 0x7ff7fb2fU,
0x00000001U, 0x00000000U,
0x00000000U, 0x5986f054U>
sfmt607;
typedef simd_fast_mersenne_twister_engine<uint64_t, 607, 2,
15, 3, 13, 3,
0xfdff37ffU, 0xef7f3f7dU,
0xff777b7dU, 0x7ff7fb2fU,
0x00000001U, 0x00000000U,
0x00000000U, 0x5986f054U>
sfmt607_64;
typedef simd_fast_mersenne_twister_engine<uint32_t, 1279, 7,
14, 3, 5, 1,
0xf7fefffdU, 0x7fefcfffU,
0xaff3ef3fU, 0xb5ffff7fU,
0x00000001U, 0x00000000U,
0x00000000U, 0x20000000U>
sfmt1279;
typedef simd_fast_mersenne_twister_engine<uint64_t, 1279, 7,
14, 3, 5, 1,
0xf7fefffdU, 0x7fefcfffU,
0xaff3ef3fU, 0xb5ffff7fU,
0x00000001U, 0x00000000U,
0x00000000U, 0x20000000U>
sfmt1279_64;
typedef simd_fast_mersenne_twister_engine<uint32_t, 2281, 12,
19, 1, 5, 1,
0xbff7ffbfU, 0xfdfffffeU,
0xf7ffef7fU, 0xf2f7cbbfU,
0x00000001U, 0x00000000U,
0x00000000U, 0x41dfa600U>
sfmt2281;
typedef simd_fast_mersenne_twister_engine<uint64_t, 2281, 12,
19, 1, 5, 1,
0xbff7ffbfU, 0xfdfffffeU,
0xf7ffef7fU, 0xf2f7cbbfU,
0x00000001U, 0x00000000U,
0x00000000U, 0x41dfa600U>
sfmt2281_64;
typedef simd_fast_mersenne_twister_engine<uint32_t, 4253, 17,
20, 1, 7, 1,
0x9f7bffffU, 0x9fffff5fU,
0x3efffffbU, 0xfffff7bbU,
0xa8000001U, 0xaf5390a3U,
0xb740b3f8U, 0x6c11486dU>
sfmt4253;
typedef simd_fast_mersenne_twister_engine<uint64_t, 4253, 17,
20, 1, 7, 1,
0x9f7bffffU, 0x9fffff5fU,
0x3efffffbU, 0xfffff7bbU,
0xa8000001U, 0xaf5390a3U,
0xb740b3f8U, 0x6c11486dU>
sfmt4253_64;
typedef simd_fast_mersenne_twister_engine<uint32_t, 11213, 68,
14, 3, 7, 3,
0xeffff7fbU, 0xffffffefU,
0xdfdfbfffU, 0x7fffdbfdU,
0x00000001U, 0x00000000U,
0xe8148000U, 0xd0c7afa3U>
sfmt11213;
typedef simd_fast_mersenne_twister_engine<uint64_t, 11213, 68,
14, 3, 7, 3,
0xeffff7fbU, 0xffffffefU,
0xdfdfbfffU, 0x7fffdbfdU,
0x00000001U, 0x00000000U,
0xe8148000U, 0xd0c7afa3U>
sfmt11213_64;
typedef simd_fast_mersenne_twister_engine<uint32_t, 19937, 122,
18, 1, 11, 1,
0xdfffffefU, 0xddfecb7fU,
0xbffaffffU, 0xbffffff6U,
0x00000001U, 0x00000000U,
0x00000000U, 0x13c9e684U>
sfmt19937;
typedef simd_fast_mersenne_twister_engine<uint64_t, 19937, 122,
18, 1, 11, 1,
0xdfffffefU, 0xddfecb7fU,
0xbffaffffU, 0xbffffff6U,
0x00000001U, 0x00000000U,
0x00000000U, 0x13c9e684U>
sfmt19937_64;
typedef simd_fast_mersenne_twister_engine<uint32_t, 44497, 330,
5, 3, 9, 3,
0xeffffffbU, 0xdfbebfffU,
0xbfbf7befU, 0x9ffd7bffU,
0x00000001U, 0x00000000U,
0xa3ac4000U, 0xecc1327aU>
sfmt44497;
typedef simd_fast_mersenne_twister_engine<uint64_t, 44497, 330,
5, 3, 9, 3,
0xeffffffbU, 0xdfbebfffU,
0xbfbf7befU, 0x9ffd7bffU,
0x00000001U, 0x00000000U,
0xa3ac4000U, 0xecc1327aU>
sfmt44497_64;
typedef simd_fast_mersenne_twister_engine<uint32_t, 86243, 366,
6, 7, 19, 1,
0xfdbffbffU, 0xbff7ff3fU,
0xfd77efffU, 0xbf9ff3ffU,
0x00000001U, 0x00000000U,
0x00000000U, 0xe9528d85U>
sfmt86243;
typedef simd_fast_mersenne_twister_engine<uint64_t, 86243, 366,
6, 7, 19, 1,
0xfdbffbffU, 0xbff7ff3fU,
0xfd77efffU, 0xbf9ff3ffU,
0x00000001U, 0x00000000U,
0x00000000U, 0xe9528d85U>
sfmt86243_64;
typedef simd_fast_mersenne_twister_engine<uint32_t, 132049, 110,
19, 1, 21, 1,
0xffffbb5fU, 0xfb6ebf95U,
0xfffefffaU, 0xcff77fffU,
0x00000001U, 0x00000000U,
0xcb520000U, 0xc7e91c7dU>
sfmt132049;
typedef simd_fast_mersenne_twister_engine<uint64_t, 132049, 110,
19, 1, 21, 1,
0xffffbb5fU, 0xfb6ebf95U,
0xfffefffaU, 0xcff77fffU,
0x00000001U, 0x00000000U,
0xcb520000U, 0xc7e91c7dU>
sfmt132049_64;
typedef simd_fast_mersenne_twister_engine<uint32_t, 216091, 627,
11, 3, 10, 1,
0xbff7bff7U, 0xbfffffffU,
0xbffffa7fU, 0xffddfbfbU,
0xf8000001U, 0x89e80709U,
0x3bd2b64bU, 0x0c64b1e4U>
sfmt216091;
typedef simd_fast_mersenne_twister_engine<uint64_t, 216091, 627,
11, 3, 10, 1,
0xbff7bff7U, 0xbfffffffU,
0xbffffa7fU, 0xffddfbfbU,
0xf8000001U, 0x89e80709U,
0x3bd2b64bU, 0x0c64b1e4U>
sfmt216091_64;
#endif // __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
/**
* @brief A beta continuous distribution for random numbers.
*
* The formula for the beta probability density function is:
* @f[
* p(x|\alpha,\beta) = \frac{1}{B(\alpha,\beta)}
* x^{\alpha - 1} (1 - x)^{\beta - 1}
* @f]
*/
template<typename _RealType = double>
class beta_distribution
{
static_assert(std::is_floating_point<_RealType>::value,
"template argument not a floating point type");
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
/** Parameter type. */
struct param_type
{
typedef beta_distribution<_RealType> distribution_type;
friend class beta_distribution<_RealType>;
explicit
param_type(_RealType __alpha_val = _RealType(1),
_RealType __beta_val = _RealType(1))
: _M_alpha(__alpha_val), _M_beta(__beta_val)
{
__glibcxx_assert(_M_alpha > _RealType(0));
__glibcxx_assert(_M_beta > _RealType(0));
}
_RealType
alpha() const
{ return _M_alpha; }
_RealType
beta() const
{ return _M_beta; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{ return (__p1._M_alpha == __p2._M_alpha
&& __p1._M_beta == __p2._M_beta); }
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
void
_M_initialize();
_RealType _M_alpha;
_RealType _M_beta;
};
public:
/**
* @brief Constructs a beta distribution with parameters
* @f$\alpha@f$ and @f$\beta@f$.
*/
explicit
beta_distribution(_RealType __alpha_val = _RealType(1),
_RealType __beta_val = _RealType(1))
: _M_param(__alpha_val, __beta_val)
{ }
explicit
beta_distribution(const param_type& __p)
: _M_param(__p)
{ }
/**
* @brief Resets the distribution state.
*/
void
reset()
{ }
/**
* @brief Returns the @f$\alpha@f$ of the distribution.
*/
_RealType
alpha() const
{ return _M_param.alpha(); }
/**
* @brief Returns the @f$\beta@f$ of the distribution.
*/
_RealType
beta() const
{ return _M_param.beta(); }
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ _M_param = __param; }
/**
* @brief Returns the greatest lower bound value of the distribution.
*/
result_type
min() const
{ return result_type(0); }
/**
* @brief Returns the least upper bound value of the distribution.
*/
result_type
max() const
{ return result_type(1); }
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
{ return this->operator()(__urng, _M_param); }
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p);
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate(__f, __t, __urng, _M_param); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two beta distributions have the same
* parameters and the sequences that would be generated
* are equal.
*/
friend bool
operator==(const beta_distribution& __d1,
const beta_distribution& __d2)
{ return __d1._M_param == __d2._M_param; }
/**
* @brief Inserts a %beta_distribution random number distribution
* @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %beta_distribution random number distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const __gnu_cxx::beta_distribution<_RealType1>& __x);
/**
* @brief Extracts a %beta_distribution random number distribution
* @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %beta_distribution random number generator engine.
*
* @returns The input stream with @p __x extracted or in an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
__gnu_cxx::beta_distribution<_RealType1>& __x);
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
param_type _M_param;
};
/**
* @brief Return true if two beta distributions are different.
*/
template<typename _RealType>
inline bool
operator!=(const __gnu_cxx::beta_distribution<_RealType>& __d1,
const __gnu_cxx::beta_distribution<_RealType>& __d2)
{ return !(__d1 == __d2); }
/**
* @brief A multi-variate normal continuous distribution for random numbers.
*
* The formula for the normal probability density function is
* @f[
* p(\overrightarrow{x}|\overrightarrow{\mu },\Sigma) =
* \frac{1}{\sqrt{(2\pi )^k\det(\Sigma))}}
* e^{-\frac{1}{2}(\overrightarrow{x}-\overrightarrow{\mu})^\text{T}
* \Sigma ^{-1}(\overrightarrow{x}-\overrightarrow{\mu})}
* @f]
*
* where @f$\overrightarrow{x}@f$ and @f$\overrightarrow{\mu}@f$ are
* vectors of dimension @f$k@f$ and @f$\Sigma@f$ is the covariance
* matrix (which must be positive-definite).
*/
template<std::size_t _Dimen, typename _RealType = double>
class normal_mv_distribution
{
static_assert(std::is_floating_point<_RealType>::value,
"template argument not a floating point type");
static_assert(_Dimen != 0, "dimension is zero");
public:
/** The type of the range of the distribution. */
typedef std::array<_RealType, _Dimen> result_type;
/** Parameter type. */
class param_type
{
static constexpr size_t _M_t_size = _Dimen * (_Dimen + 1) / 2;
public:
typedef normal_mv_distribution<_Dimen, _RealType> distribution_type;
friend class normal_mv_distribution<_Dimen, _RealType>;
param_type()
{
std::fill(_M_mean.begin(), _M_mean.end(), _RealType(0));
auto __it = _M_t.begin();
for (size_t __i = 0; __i < _Dimen; ++__i)
{
std::fill_n(__it, __i, _RealType(0));
__it += __i;
*__it++ = _RealType(1);
}
}
template<typename _ForwardIterator1, typename _ForwardIterator2>
param_type(_ForwardIterator1 __meanbegin,
_ForwardIterator1 __meanend,
_ForwardIterator2 __varcovbegin,
_ForwardIterator2 __varcovend)
{
__glibcxx_function_requires(_ForwardIteratorConcept<
_ForwardIterator1>)
__glibcxx_function_requires(_ForwardIteratorConcept<
_ForwardIterator2>)
_GLIBCXX_DEBUG_ASSERT(std::distance(__meanbegin, __meanend)
<= _Dimen);
const auto __dist = std::distance(__varcovbegin, __varcovend);
_GLIBCXX_DEBUG_ASSERT(__dist == _Dimen * _Dimen
|| __dist == _Dimen * (_Dimen + 1) / 2
|| __dist == _Dimen);
if (__dist == _Dimen * _Dimen)
_M_init_full(__meanbegin, __meanend, __varcovbegin, __varcovend);
else if (__dist == _Dimen * (_Dimen + 1) / 2)
_M_init_lower(__meanbegin, __meanend, __varcovbegin, __varcovend);
else
{
__glibcxx_assert(__dist == _Dimen);
_M_init_diagonal(__meanbegin, __meanend,
__varcovbegin, __varcovend);
}
}
param_type(std::initializer_list<_RealType> __mean,
std::initializer_list<_RealType> __varcov)
{
_GLIBCXX_DEBUG_ASSERT(__mean.size() <= _Dimen);
_GLIBCXX_DEBUG_ASSERT(__varcov.size() == _Dimen * _Dimen
|| __varcov.size() == _Dimen * (_Dimen + 1) / 2
|| __varcov.size() == _Dimen);
if (__varcov.size() == _Dimen * _Dimen)
_M_init_full(__mean.begin(), __mean.end(),
__varcov.begin(), __varcov.end());
else if (__varcov.size() == _Dimen * (_Dimen + 1) / 2)
_M_init_lower(__mean.begin(), __mean.end(),
__varcov.begin(), __varcov.end());
else
{
__glibcxx_assert(__varcov.size() == _Dimen);
_M_init_diagonal(__mean.begin(), __mean.end(),
__varcov.begin(), __varcov.end());
}
}
std::array<_RealType, _Dimen>
mean() const
{ return _M_mean; }
std::array<_RealType, _M_t_size>
varcov() const
{ return _M_t; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{ return __p1._M_mean == __p2._M_mean && __p1._M_t == __p2._M_t; }
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
template <typename _InputIterator1, typename _InputIterator2>
void _M_init_full(_InputIterator1 __meanbegin,
_InputIterator1 __meanend,
_InputIterator2 __varcovbegin,
_InputIterator2 __varcovend);
template <typename _InputIterator1, typename _InputIterator2>
void _M_init_lower(_InputIterator1 __meanbegin,
_InputIterator1 __meanend,
_InputIterator2 __varcovbegin,
_InputIterator2 __varcovend);
template <typename _InputIterator1, typename _InputIterator2>
void _M_init_diagonal(_InputIterator1 __meanbegin,
_InputIterator1 __meanend,
_InputIterator2 __varbegin,
_InputIterator2 __varend);
std::array<_RealType, _Dimen> _M_mean;
std::array<_RealType, _M_t_size> _M_t;
};
public:
normal_mv_distribution()
: _M_param(), _M_nd()
{ }
template<typename _ForwardIterator1, typename _ForwardIterator2>
normal_mv_distribution(_ForwardIterator1 __meanbegin,
_ForwardIterator1 __meanend,
_ForwardIterator2 __varcovbegin,
_ForwardIterator2 __varcovend)
: _M_param(__meanbegin, __meanend, __varcovbegin, __varcovend),
_M_nd()
{ }
normal_mv_distribution(std::initializer_list<_RealType> __mean,
std::initializer_list<_RealType> __varcov)
: _M_param(__mean, __varcov), _M_nd()
{ }
explicit
normal_mv_distribution(const param_type& __p)
: _M_param(__p), _M_nd()
{ }
/**
* @brief Resets the distribution state.
*/
void
reset()
{ _M_nd.reset(); }
/**
* @brief Returns the mean of the distribution.
*/
result_type
mean() const
{ return _M_param.mean(); }
/**
* @brief Returns the compact form of the variance/covariance
* matrix of the distribution.
*/
std::array<_RealType, _Dimen * (_Dimen + 1) / 2>
varcov() const
{ return _M_param.varcov(); }
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ _M_param = __param; }
/**
* @brief Returns the greatest lower bound value of the distribution.
*/
result_type
min() const
{ result_type __res;
__res.fill(std::numeric_limits<_RealType>::lowest());
return __res; }
/**
* @brief Returns the least upper bound value of the distribution.
*/
result_type
max() const
{ result_type __res;
__res.fill(std::numeric_limits<_RealType>::max());
return __res; }
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
{ return this->operator()(__urng, _M_param); }
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p);
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ return this->__generate_impl(__f, __t, __urng, _M_param); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ return this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two multi-variant normal distributions have
* the same parameters and the sequences that would
* be generated are equal.
*/
template<size_t _Dimen1, typename _RealType1>
friend bool
operator==(const
__gnu_cxx::normal_mv_distribution<_Dimen1, _RealType1>&
__d1,
const
__gnu_cxx::normal_mv_distribution<_Dimen1, _RealType1>&
__d2);
/**
* @brief Inserts a %normal_mv_distribution random number distribution
* @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %normal_mv_distribution random number distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<size_t _Dimen1, typename _RealType1,
typename _CharT, typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const
__gnu_cxx::normal_mv_distribution<_Dimen1, _RealType1>&
__x);
/**
* @brief Extracts a %normal_mv_distribution random number distribution
* @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %normal_mv_distribution random number generator engine.
*
* @returns The input stream with @p __x extracted or in an error
* state.
*/
template<size_t _Dimen1, typename _RealType1,
typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
__gnu_cxx::normal_mv_distribution<_Dimen1, _RealType1>&
__x);
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
param_type _M_param;
std::normal_distribution<_RealType> _M_nd;
};
/**
* @brief Return true if two multi-variate normal distributions are
* different.
*/
template<size_t _Dimen, typename _RealType>
inline bool
operator!=(const __gnu_cxx::normal_mv_distribution<_Dimen, _RealType>&
__d1,
const __gnu_cxx::normal_mv_distribution<_Dimen, _RealType>&
__d2)
{ return !(__d1 == __d2); }
/**
* @brief A Rice continuous distribution for random numbers.
*
* The formula for the Rice probability density function is
* @f[
* p(x|\nu,\sigma) = \frac{x}{\sigma^2}
* \exp\left(-\frac{x^2+\nu^2}{2\sigma^2}\right)
* I_0\left(\frac{x \nu}{\sigma^2}\right)
* @f]
* where @f$I_0(z)@f$ is the modified Bessel function of the first kind
* of order 0 and @f$\nu >= 0@f$ and @f$\sigma > 0@f$.
*
* <table border=1 cellpadding=10 cellspacing=0>
* <caption align=top>Distribution Statistics</caption>
* <tr><td>Mean</td><td>@f$\sqrt{\pi/2}L_{1/2}(-\nu^2/2\sigma^2)@f$</td></tr>
* <tr><td>Variance</td><td>@f$2\sigma^2 + \nu^2
* + (\pi\sigma^2/2)L^2_{1/2}(-\nu^2/2\sigma^2)@f$</td></tr>
* <tr><td>Range</td><td>@f$[0, \infty)@f$</td></tr>
* </table>
* where @f$L_{1/2}(x)@f$ is the Laguerre polynomial of order 1/2.
*/
template<typename _RealType = double>
class
rice_distribution
{
static_assert(std::is_floating_point<_RealType>::value,
"template argument not a floating point type");
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
/** Parameter type. */
struct param_type
{
typedef rice_distribution<result_type> distribution_type;
param_type(result_type __nu_val = result_type(0),
result_type __sigma_val = result_type(1))
: _M_nu(__nu_val), _M_sigma(__sigma_val)
{
__glibcxx_assert(_M_nu >= result_type(0));
__glibcxx_assert(_M_sigma > result_type(0));
}
result_type
nu() const
{ return _M_nu; }
result_type
sigma() const
{ return _M_sigma; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{ return __p1._M_nu == __p2._M_nu && __p1._M_sigma == __p2._M_sigma; }
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
void _M_initialize();
result_type _M_nu;
result_type _M_sigma;
};
/**
* @brief Constructors.
*/
explicit
rice_distribution(result_type __nu_val = result_type(0),
result_type __sigma_val = result_type(1))
: _M_param(__nu_val, __sigma_val),
_M_ndx(__nu_val, __sigma_val),
_M_ndy(result_type(0), __sigma_val)
{ }
explicit
rice_distribution(const param_type& __p)
: _M_param(__p),
_M_ndx(__p.nu(), __p.sigma()),
_M_ndy(result_type(0), __p.sigma())
{ }
/**
* @brief Resets the distribution state.
*/
void
reset()
{
_M_ndx.reset();
_M_ndy.reset();
}
/**
* @brief Return the parameters of the distribution.
*/
result_type
nu() const
{ return _M_param.nu(); }
result_type
sigma() const
{ return _M_param.sigma(); }
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ _M_param = __param; }
/**
* @brief Returns the greatest lower bound value of the distribution.
*/
result_type
min() const
{ return result_type(0); }
/**
* @brief Returns the least upper bound value of the distribution.
*/
result_type
max() const
{ return std::numeric_limits<result_type>::max(); }
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
{
result_type __x = this->_M_ndx(__urng);
result_type __y = this->_M_ndy(__urng);
#if _GLIBCXX_USE_C99_MATH_TR1
return std::hypot(__x, __y);
#else
return std::sqrt(__x * __x + __y * __y);
#endif
}
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
typename std::normal_distribution<result_type>::param_type
__px(__p.nu(), __p.sigma()), __py(result_type(0), __p.sigma());
result_type __x = this->_M_ndx(__px, __urng);
result_type __y = this->_M_ndy(__py, __urng);
#if _GLIBCXX_USE_C99_MATH_TR1
return std::hypot(__x, __y);
#else
return std::sqrt(__x * __x + __y * __y);
#endif
}
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate(__f, __t, __urng, _M_param); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two Rice distributions have
* the same parameters and the sequences that would
* be generated are equal.
*/
friend bool
operator==(const rice_distribution& __d1,
const rice_distribution& __d2)
{ return (__d1._M_param == __d2._M_param
&& __d1._M_ndx == __d2._M_ndx
&& __d1._M_ndy == __d2._M_ndy); }
/**
* @brief Inserts a %rice_distribution random number distribution
* @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %rice_distribution random number distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>&,
const rice_distribution<_RealType1>&);
/**
* @brief Extracts a %rice_distribution random number distribution
* @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %rice_distribution random number
* generator engine.
*
* @returns The input stream with @p __x extracted or in an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>&,
rice_distribution<_RealType1>&);
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
param_type _M_param;
std::normal_distribution<result_type> _M_ndx;
std::normal_distribution<result_type> _M_ndy;
};
/**
* @brief Return true if two Rice distributions are not equal.
*/
template<typename _RealType1>
inline bool
operator!=(const rice_distribution<_RealType1>& __d1,
const rice_distribution<_RealType1>& __d2)
{ return !(__d1 == __d2); }
/**
* @brief A Nakagami continuous distribution for random numbers.
*
* The formula for the Nakagami probability density function is
* @f[
* p(x|\mu,\omega) = \frac{2\mu^\mu}{\Gamma(\mu)\omega^\mu}
* x^{2\mu-1}e^{-\mu x / \omega}
* @f]
* where @f$\Gamma(z)@f$ is the gamma function and @f$\mu >= 0.5@f$
* and @f$\omega > 0@f$.
*/
template<typename _RealType = double>
class
nakagami_distribution
{
static_assert(std::is_floating_point<_RealType>::value,
"template argument not a floating point type");
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
/** Parameter type. */
struct param_type
{
typedef nakagami_distribution<result_type> distribution_type;
param_type(result_type __mu_val = result_type(1),
result_type __omega_val = result_type(1))
: _M_mu(__mu_val), _M_omega(__omega_val)
{
__glibcxx_assert(_M_mu >= result_type(0.5L));
__glibcxx_assert(_M_omega > result_type(0));
}
result_type
mu() const
{ return _M_mu; }
result_type
omega() const
{ return _M_omega; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{ return __p1._M_mu == __p2._M_mu && __p1._M_omega == __p2._M_omega; }
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
void _M_initialize();
result_type _M_mu;
result_type _M_omega;
};
/**
* @brief Constructors.
*/
explicit
nakagami_distribution(result_type __mu_val = result_type(1),
result_type __omega_val = result_type(1))
: _M_param(__mu_val, __omega_val),
_M_gd(__mu_val, __omega_val / __mu_val)
{ }
explicit
nakagami_distribution(const param_type& __p)
: _M_param(__p),
_M_gd(__p.mu(), __p.omega() / __p.mu())
{ }
/**
* @brief Resets the distribution state.
*/
void
reset()
{ _M_gd.reset(); }
/**
* @brief Return the parameters of the distribution.
*/
result_type
mu() const
{ return _M_param.mu(); }
result_type
omega() const
{ return _M_param.omega(); }
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ _M_param = __param; }
/**
* @brief Returns the greatest lower bound value of the distribution.
*/
result_type
min() const
{ return result_type(0); }
/**
* @brief Returns the least upper bound value of the distribution.
*/
result_type
max() const
{ return std::numeric_limits<result_type>::max(); }
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
{ return std::sqrt(this->_M_gd(__urng)); }
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
typename std::gamma_distribution<result_type>::param_type
__pg(__p.mu(), __p.omega() / __p.mu());
return std::sqrt(this->_M_gd(__pg, __urng));
}
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate(__f, __t, __urng, _M_param); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two Nakagami distributions have
* the same parameters and the sequences that would
* be generated are equal.
*/
friend bool
operator==(const nakagami_distribution& __d1,
const nakagami_distribution& __d2)
{ return (__d1._M_param == __d2._M_param
&& __d1._M_gd == __d2._M_gd); }
/**
* @brief Inserts a %nakagami_distribution random number distribution
* @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %nakagami_distribution random number distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>&,
const nakagami_distribution<_RealType1>&);
/**
* @brief Extracts a %nakagami_distribution random number distribution
* @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %nakagami_distribution random number
* generator engine.
*
* @returns The input stream with @p __x extracted or in an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>&,
nakagami_distribution<_RealType1>&);
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
param_type _M_param;
std::gamma_distribution<result_type> _M_gd;
};
/**
* @brief Return true if two Nakagami distributions are not equal.
*/
template<typename _RealType>
inline bool
operator!=(const nakagami_distribution<_RealType>& __d1,
const nakagami_distribution<_RealType>& __d2)
{ return !(__d1 == __d2); }
/**
* @brief A Pareto continuous distribution for random numbers.
*
* The formula for the Pareto cumulative probability function is
* @f[
* P(x|\alpha,\mu) = 1 - \left(\frac{\mu}{x}\right)^\alpha
* @f]
* The formula for the Pareto probability density function is
* @f[
* p(x|\alpha,\mu) = \frac{\alpha + 1}{\mu}
* \left(\frac{\mu}{x}\right)^{\alpha + 1}
* @f]
* where @f$x >= \mu@f$ and @f$\mu > 0@f$, @f$\alpha > 0@f$.
*
* <table border=1 cellpadding=10 cellspacing=0>
* <caption align=top>Distribution Statistics</caption>
* <tr><td>Mean</td><td>@f$\alpha \mu / (\alpha - 1)@f$
* for @f$\alpha > 1@f$</td></tr>
* <tr><td>Variance</td><td>@f$\alpha \mu^2 / [(\alpha - 1)^2(\alpha - 2)]@f$
* for @f$\alpha > 2@f$</td></tr>
* <tr><td>Range</td><td>@f$[\mu, \infty)@f$</td></tr>
* </table>
*/
template<typename _RealType = double>
class
pareto_distribution
{
static_assert(std::is_floating_point<_RealType>::value,
"template argument not a floating point type");
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
/** Parameter type. */
struct param_type
{
typedef pareto_distribution<result_type> distribution_type;
param_type(result_type __alpha_val = result_type(1),
result_type __mu_val = result_type(1))
: _M_alpha(__alpha_val), _M_mu(__mu_val)
{
__glibcxx_assert(_M_alpha > result_type(0));
__glibcxx_assert(_M_mu > result_type(0));
}
result_type
alpha() const
{ return _M_alpha; }
result_type
mu() const
{ return _M_mu; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{ return __p1._M_alpha == __p2._M_alpha && __p1._M_mu == __p2._M_mu; }
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
void _M_initialize();
result_type _M_alpha;
result_type _M_mu;
};
/**
* @brief Constructors.
*/
explicit
pareto_distribution(result_type __alpha_val = result_type(1),
result_type __mu_val = result_type(1))
: _M_param(__alpha_val, __mu_val),
_M_ud()
{ }
explicit
pareto_distribution(const param_type& __p)
: _M_param(__p),
_M_ud()
{ }
/**
* @brief Resets the distribution state.
*/
void
reset()
{
_M_ud.reset();
}
/**
* @brief Return the parameters of the distribution.
*/
result_type
alpha() const
{ return _M_param.alpha(); }
result_type
mu() const
{ return _M_param.mu(); }
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ _M_param = __param; }
/**
* @brief Returns the greatest lower bound value of the distribution.
*/
result_type
min() const
{ return this->mu(); }
/**
* @brief Returns the least upper bound value of the distribution.
*/
result_type
max() const
{ return std::numeric_limits<result_type>::max(); }
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
{
return this->mu() * std::pow(this->_M_ud(__urng),
-result_type(1) / this->alpha());
}
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
return __p.mu() * std::pow(this->_M_ud(__urng),
-result_type(1) / __p.alpha());
}
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate(__f, __t, __urng, _M_param); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two Pareto distributions have
* the same parameters and the sequences that would
* be generated are equal.
*/
friend bool
operator==(const pareto_distribution& __d1,
const pareto_distribution& __d2)
{ return (__d1._M_param == __d2._M_param
&& __d1._M_ud == __d2._M_ud); }
/**
* @brief Inserts a %pareto_distribution random number distribution
* @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %pareto_distribution random number distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>&,
const pareto_distribution<_RealType1>&);
/**
* @brief Extracts a %pareto_distribution random number distribution
* @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %pareto_distribution random number
* generator engine.
*
* @returns The input stream with @p __x extracted or in an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>&,
pareto_distribution<_RealType1>&);
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
param_type _M_param;
std::uniform_real_distribution<result_type> _M_ud;
};
/**
* @brief Return true if two Pareto distributions are not equal.
*/
template<typename _RealType>
inline bool
operator!=(const pareto_distribution<_RealType>& __d1,
const pareto_distribution<_RealType>& __d2)
{ return !(__d1 == __d2); }
/**
* @brief A K continuous distribution for random numbers.
*
* The formula for the K probability density function is
* @f[
* p(x|\lambda, \mu, \nu) = \frac{2}{x}
* \left(\frac{\lambda\nu x}{\mu}\right)^{\frac{\lambda + \nu}{2}}
* \frac{1}{\Gamma(\lambda)\Gamma(\nu)}
* K_{\nu - \lambda}\left(2\sqrt{\frac{\lambda\nu x}{\mu}}\right)
* @f]
* where @f$I_0(z)@f$ is the modified Bessel function of the second kind
* of order @f$\nu - \lambda@f$ and @f$\lambda > 0@f$, @f$\mu > 0@f$
* and @f$\nu > 0@f$.
*
* <table border=1 cellpadding=10 cellspacing=0>
* <caption align=top>Distribution Statistics</caption>
* <tr><td>Mean</td><td>@f$\mu@f$</td></tr>
* <tr><td>Variance</td><td>@f$\mu^2\frac{\lambda + \nu + 1}{\lambda\nu}@f$</td></tr>
* <tr><td>Range</td><td>@f$[0, \infty)@f$</td></tr>
* </table>
*/
template<typename _RealType = double>
class
k_distribution
{
static_assert(std::is_floating_point<_RealType>::value,
"template argument not a floating point type");
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
/** Parameter type. */
struct param_type
{
typedef k_distribution<result_type> distribution_type;
param_type(result_type __lambda_val = result_type(1),
result_type __mu_val = result_type(1),
result_type __nu_val = result_type(1))
: _M_lambda(__lambda_val), _M_mu(__mu_val), _M_nu(__nu_val)
{
__glibcxx_assert(_M_lambda > result_type(0));
__glibcxx_assert(_M_mu > result_type(0));
__glibcxx_assert(_M_nu > result_type(0));
}
result_type
lambda() const
{ return _M_lambda; }
result_type
mu() const
{ return _M_mu; }
result_type
nu() const
{ return _M_nu; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{
return __p1._M_lambda == __p2._M_lambda
&& __p1._M_mu == __p2._M_mu
&& __p1._M_nu == __p2._M_nu;
}
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
void _M_initialize();
result_type _M_lambda;
result_type _M_mu;
result_type _M_nu;
};
/**
* @brief Constructors.
*/
explicit
k_distribution(result_type __lambda_val = result_type(1),
result_type __mu_val = result_type(1),
result_type __nu_val = result_type(1))
: _M_param(__lambda_val, __mu_val, __nu_val),
_M_gd1(__lambda_val, result_type(1) / __lambda_val),
_M_gd2(__nu_val, __mu_val / __nu_val)
{ }
explicit
k_distribution(const param_type& __p)
: _M_param(__p),
_M_gd1(__p.lambda(), result_type(1) / __p.lambda()),
_M_gd2(__p.nu(), __p.mu() / __p.nu())
{ }
/**
* @brief Resets the distribution state.
*/
void
reset()
{
_M_gd1.reset();
_M_gd2.reset();
}
/**
* @brief Return the parameters of the distribution.
*/
result_type
lambda() const
{ return _M_param.lambda(); }
result_type
mu() const
{ return _M_param.mu(); }
result_type
nu() const
{ return _M_param.nu(); }
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ _M_param = __param; }
/**
* @brief Returns the greatest lower bound value of the distribution.
*/
result_type
min() const
{ return result_type(0); }
/**
* @brief Returns the least upper bound value of the distribution.
*/
result_type
max() const
{ return std::numeric_limits<result_type>::max(); }
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator&);
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator&, const param_type&);
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate(__f, __t, __urng, _M_param); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two K distributions have
* the same parameters and the sequences that would
* be generated are equal.
*/
friend bool
operator==(const k_distribution& __d1,
const k_distribution& __d2)
{ return (__d1._M_param == __d2._M_param
&& __d1._M_gd1 == __d2._M_gd1
&& __d1._M_gd2 == __d2._M_gd2); }
/**
* @brief Inserts a %k_distribution random number distribution
* @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %k_distribution random number distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>&,
const k_distribution<_RealType1>&);
/**
* @brief Extracts a %k_distribution random number distribution
* @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %k_distribution random number
* generator engine.
*
* @returns The input stream with @p __x extracted or in an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>&,
k_distribution<_RealType1>&);
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
param_type _M_param;
std::gamma_distribution<result_type> _M_gd1;
std::gamma_distribution<result_type> _M_gd2;
};
/**
* @brief Return true if two K distributions are not equal.
*/
template<typename _RealType>
inline bool
operator!=(const k_distribution<_RealType>& __d1,
const k_distribution<_RealType>& __d2)
{ return !(__d1 == __d2); }
/**
* @brief An arcsine continuous distribution for random numbers.
*
* The formula for the arcsine probability density function is
* @f[
* p(x|a,b) = \frac{1}{\pi \sqrt{(x - a)(b - x)}}
* @f]
* where @f$x >= a@f$ and @f$x <= b@f$.
*
* <table border=1 cellpadding=10 cellspacing=0>
* <caption align=top>Distribution Statistics</caption>
* <tr><td>Mean</td><td>@f$ (a + b) / 2 @f$</td></tr>
* <tr><td>Variance</td><td>@f$ (b - a)^2 / 8 @f$</td></tr>
* <tr><td>Range</td><td>@f$[a, b]@f$</td></tr>
* </table>
*/
template<typename _RealType = double>
class
arcsine_distribution
{
static_assert(std::is_floating_point<_RealType>::value,
"template argument not a floating point type");
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
/** Parameter type. */
struct param_type
{
typedef arcsine_distribution<result_type> distribution_type;
param_type(result_type __a = result_type(0),
result_type __b = result_type(1))
: _M_a(__a), _M_b(__b)
{
__glibcxx_assert(_M_a <= _M_b);
}
result_type
a() const
{ return _M_a; }
result_type
b() const
{ return _M_b; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{ return __p1._M_a == __p2._M_a && __p1._M_b == __p2._M_b; }
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
void _M_initialize();
result_type _M_a;
result_type _M_b;
};
/**
* @brief Constructors.
*/
explicit
arcsine_distribution(result_type __a = result_type(0),
result_type __b = result_type(1))
: _M_param(__a, __b),
_M_ud(-1.5707963267948966192313216916397514L,
+1.5707963267948966192313216916397514L)
{ }
explicit
arcsine_distribution(const param_type& __p)
: _M_param(__p),
_M_ud(-1.5707963267948966192313216916397514L,
+1.5707963267948966192313216916397514L)
{ }
/**
* @brief Resets the distribution state.
*/
void
reset()
{ _M_ud.reset(); }
/**
* @brief Return the parameters of the distribution.
*/
result_type
a() const
{ return _M_param.a(); }
result_type
b() const
{ return _M_param.b(); }
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ _M_param = __param; }
/**
* @brief Returns the greatest lower bound value of the distribution.
*/
result_type
min() const
{ return this->a(); }
/**
* @brief Returns the least upper bound value of the distribution.
*/
result_type
max() const
{ return this->b(); }
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
{
result_type __x = std::sin(this->_M_ud(__urng));
return (__x * (this->b() - this->a())
+ this->a() + this->b()) / result_type(2);
}
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
result_type __x = std::sin(this->_M_ud(__urng));
return (__x * (__p.b() - __p.a())
+ __p.a() + __p.b()) / result_type(2);
}
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate(__f, __t, __urng, _M_param); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two arcsine distributions have
* the same parameters and the sequences that would
* be generated are equal.
*/
friend bool
operator==(const arcsine_distribution& __d1,
const arcsine_distribution& __d2)
{ return (__d1._M_param == __d2._M_param
&& __d1._M_ud == __d2._M_ud); }
/**
* @brief Inserts a %arcsine_distribution random number distribution
* @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %arcsine_distribution random number distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>&,
const arcsine_distribution<_RealType1>&);
/**
* @brief Extracts a %arcsine_distribution random number distribution
* @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %arcsine_distribution random number
* generator engine.
*
* @returns The input stream with @p __x extracted or in an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>&,
arcsine_distribution<_RealType1>&);
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
param_type _M_param;
std::uniform_real_distribution<result_type> _M_ud;
};
/**
* @brief Return true if two arcsine distributions are not equal.
*/
template<typename _RealType>
inline bool
operator!=(const arcsine_distribution<_RealType>& __d1,
const arcsine_distribution<_RealType>& __d2)
{ return !(__d1 == __d2); }
/**
* @brief A Hoyt continuous distribution for random numbers.
*
* The formula for the Hoyt probability density function is
* @f[
* p(x|q,\omega) = \frac{(1 + q^2)x}{q\omega}
* \exp\left(-\frac{(1 + q^2)^2 x^2}{4 q^2 \omega}\right)
* I_0\left(\frac{(1 - q^4) x^2}{4 q^2 \omega}\right)
* @f]
* where @f$I_0(z)@f$ is the modified Bessel function of the first kind
* of order 0 and @f$0 < q < 1@f$.
*
* <table border=1 cellpadding=10 cellspacing=0>
* <caption align=top>Distribution Statistics</caption>
* <tr><td>Mean</td><td>@f$ \sqrt{\frac{2}{\pi}} \sqrt{\frac{\omega}{1 + q^2}}
* E(1 - q^2) @f$</td></tr>
* <tr><td>Variance</td><td>@f$ \omega \left(1 - \frac{2E^2(1 - q^2)}
* {\pi (1 + q^2)}\right) @f$</td></tr>
* <tr><td>Range</td><td>@f$[0, \infty)@f$</td></tr>
* </table>
* where @f$E(x)@f$ is the elliptic function of the second kind.
*/
template<typename _RealType = double>
class
hoyt_distribution
{
static_assert(std::is_floating_point<_RealType>::value,
"template argument not a floating point type");
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
/** Parameter type. */
struct param_type
{
typedef hoyt_distribution<result_type> distribution_type;
param_type(result_type __q = result_type(0.5L),
result_type __omega = result_type(1))
: _M_q(__q), _M_omega(__omega)
{
__glibcxx_assert(_M_q > result_type(0));
__glibcxx_assert(_M_q < result_type(1));
}
result_type
q() const
{ return _M_q; }
result_type
omega() const
{ return _M_omega; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{ return __p1._M_q == __p2._M_q && __p1._M_omega == __p2._M_omega; }
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
void _M_initialize();
result_type _M_q;
result_type _M_omega;
};
/**
* @brief Constructors.
*/
explicit
hoyt_distribution(result_type __q = result_type(0.5L),
result_type __omega = result_type(1))
: _M_param(__q, __omega),
_M_ad(result_type(0.5L) * (result_type(1) + __q * __q),
result_type(0.5L) * (result_type(1) + __q * __q)
/ (__q * __q)),
_M_ed(result_type(1))
{ }
explicit
hoyt_distribution(const param_type& __p)
: _M_param(__p),
_M_ad(result_type(0.5L) * (result_type(1) + __p.q() * __p.q()),
result_type(0.5L) * (result_type(1) + __p.q() * __p.q())
/ (__p.q() * __p.q())),
_M_ed(result_type(1))
{ }
/**
* @brief Resets the distribution state.
*/
void
reset()
{
_M_ad.reset();
_M_ed.reset();
}
/**
* @brief Return the parameters of the distribution.
*/
result_type
q() const
{ return _M_param.q(); }
result_type
omega() const
{ return _M_param.omega(); }
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ _M_param = __param; }
/**
* @brief Returns the greatest lower bound value of the distribution.
*/
result_type
min() const
{ return result_type(0); }
/**
* @brief Returns the least upper bound value of the distribution.
*/
result_type
max() const
{ return std::numeric_limits<result_type>::max(); }
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng);
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p);
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate(__f, __t, __urng, _M_param); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two Hoyt distributions have
* the same parameters and the sequences that would
* be generated are equal.
*/
friend bool
operator==(const hoyt_distribution& __d1,
const hoyt_distribution& __d2)
{ return (__d1._M_param == __d2._M_param
&& __d1._M_ad == __d2._M_ad
&& __d1._M_ed == __d2._M_ed); }
/**
* @brief Inserts a %hoyt_distribution random number distribution
* @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %hoyt_distribution random number distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>&,
const hoyt_distribution<_RealType1>&);
/**
* @brief Extracts a %hoyt_distribution random number distribution
* @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %hoyt_distribution random number
* generator engine.
*
* @returns The input stream with @p __x extracted or in an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>&,
hoyt_distribution<_RealType1>&);
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
param_type _M_param;
__gnu_cxx::arcsine_distribution<result_type> _M_ad;
std::exponential_distribution<result_type> _M_ed;
};
/**
* @brief Return true if two Hoyt distributions are not equal.
*/
template<typename _RealType>
inline bool
operator!=(const hoyt_distribution<_RealType>& __d1,
const hoyt_distribution<_RealType>& __d2)
{ return !(__d1 == __d2); }
/**
* @brief A triangular distribution for random numbers.
*
* The formula for the triangular probability density function is
* @f[
* / 0 for x < a
* p(x|a,b,c) = | \frac{2(x-a)}{(c-a)(b-a)} for a <= x <= b
* | \frac{2(c-x)}{(c-a)(c-b)} for b < x <= c
* \ 0 for c < x
* @f]
*
* <table border=1 cellpadding=10 cellspacing=0>
* <caption align=top>Distribution Statistics</caption>
* <tr><td>Mean</td><td>@f$ \frac{a+b+c}{2} @f$</td></tr>
* <tr><td>Variance</td><td>@f$ \frac{a^2+b^2+c^2-ab-ac-bc}
* {18}@f$</td></tr>
* <tr><td>Range</td><td>@f$[a, c]@f$</td></tr>
* </table>
*/
template<typename _RealType = double>
class triangular_distribution
{
static_assert(std::is_floating_point<_RealType>::value,
"template argument not a floating point type");
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
/** Parameter type. */
struct param_type
{
friend class triangular_distribution<_RealType>;
explicit
param_type(_RealType __a = _RealType(0),
_RealType __b = _RealType(0.5),
_RealType __c = _RealType(1))
: _M_a(__a), _M_b(__b), _M_c(__c)
{
__glibcxx_assert(_M_a <= _M_b);
__glibcxx_assert(_M_b <= _M_c);
__glibcxx_assert(_M_a < _M_c);
_M_r_ab = (_M_b - _M_a) / (_M_c - _M_a);
_M_f_ab_ac = (_M_b - _M_a) * (_M_c - _M_a);
_M_f_bc_ac = (_M_c - _M_b) * (_M_c - _M_a);
}
_RealType
a() const
{ return _M_a; }
_RealType
b() const
{ return _M_b; }
_RealType
c() const
{ return _M_c; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{
return (__p1._M_a == __p2._M_a && __p1._M_b == __p2._M_b
&& __p1._M_c == __p2._M_c);
}
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
_RealType _M_a;
_RealType _M_b;
_RealType _M_c;
_RealType _M_r_ab;
_RealType _M_f_ab_ac;
_RealType _M_f_bc_ac;
};
/**
* @brief Constructs a triangle distribution with parameters
* @f$ a @f$, @f$ b @f$ and @f$ c @f$.
*/
explicit
triangular_distribution(result_type __a = result_type(0),
result_type __b = result_type(0.5),
result_type __c = result_type(1))
: _M_param(__a, __b, __c)
{ }
explicit
triangular_distribution(const param_type& __p)
: _M_param(__p)
{ }
/**
* @brief Resets the distribution state.
*/
void
reset()
{ }
/**
* @brief Returns the @f$ a @f$ of the distribution.
*/
result_type
a() const
{ return _M_param.a(); }
/**
* @brief Returns the @f$ b @f$ of the distribution.
*/
result_type
b() const
{ return _M_param.b(); }
/**
* @brief Returns the @f$ c @f$ of the distribution.
*/
result_type
c() const
{ return _M_param.c(); }
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ _M_param = __param; }
/**
* @brief Returns the greatest lower bound value of the distribution.
*/
result_type
min() const
{ return _M_param._M_a; }
/**
* @brief Returns the least upper bound value of the distribution.
*/
result_type
max() const
{ return _M_param._M_c; }
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
{ return this->operator()(__urng, _M_param); }
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
std::__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
__aurng(__urng);
result_type __rnd = __aurng();
if (__rnd <= __p._M_r_ab)
return __p.a() + std::sqrt(__rnd * __p._M_f_ab_ac);
else
return __p.c() - std::sqrt((result_type(1) - __rnd)
* __p._M_f_bc_ac);
}
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate(__f, __t, __urng, _M_param); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two triangle distributions have the same
* parameters and the sequences that would be generated
* are equal.
*/
friend bool
operator==(const triangular_distribution& __d1,
const triangular_distribution& __d2)
{ return __d1._M_param == __d2._M_param; }
/**
* @brief Inserts a %triangular_distribution random number distribution
* @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %triangular_distribution random number distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const __gnu_cxx::triangular_distribution<_RealType1>& __x);
/**
* @brief Extracts a %triangular_distribution random number distribution
* @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %triangular_distribution random number generator engine.
*
* @returns The input stream with @p __x extracted or in an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
__gnu_cxx::triangular_distribution<_RealType1>& __x);
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
param_type _M_param;
};
/**
* @brief Return true if two triangle distributions are different.
*/
template<typename _RealType>
inline bool
operator!=(const __gnu_cxx::triangular_distribution<_RealType>& __d1,
const __gnu_cxx::triangular_distribution<_RealType>& __d2)
{ return !(__d1 == __d2); }
/**
* @brief A von Mises distribution for random numbers.
*
* The formula for the von Mises probability density function is
* @f[
* p(x|\mu,\kappa) = \frac{e^{\kappa \cos(x-\mu)}}
* {2\pi I_0(\kappa)}
* @f]
*
* The generating functions use the method according to:
*
* D. J. Best and N. I. Fisher, 1979. "Efficient Simulation of the
* von Mises Distribution", Journal of the Royal Statistical Society.
* Series C (Applied Statistics), Vol. 28, No. 2, pp. 152-157.
*
* <table border=1 cellpadding=10 cellspacing=0>
* <caption align=top>Distribution Statistics</caption>
* <tr><td>Mean</td><td>@f$ \mu @f$</td></tr>
* <tr><td>Variance</td><td>@f$ 1-I_1(\kappa)/I_0(\kappa) @f$</td></tr>
* <tr><td>Range</td><td>@f$[-\pi, \pi]@f$</td></tr>
* </table>
*/
template<typename _RealType = double>
class von_mises_distribution
{
static_assert(std::is_floating_point<_RealType>::value,
"template argument not a floating point type");
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
/** Parameter type. */
struct param_type
{
friend class von_mises_distribution<_RealType>;
explicit
param_type(_RealType __mu = _RealType(0),
_RealType __kappa = _RealType(1))
: _M_mu(__mu), _M_kappa(__kappa)
{
const _RealType __pi = __gnu_cxx::__math_constants<_RealType>::__pi;
__glibcxx_assert(_M_mu >= -__pi && _M_mu <= __pi);
__glibcxx_assert(_M_kappa >= _RealType(0));
auto __tau = std::sqrt(_RealType(4) * _M_kappa * _M_kappa
+ _RealType(1)) + _RealType(1);
auto __rho = ((__tau - std::sqrt(_RealType(2) * __tau))
/ (_RealType(2) * _M_kappa));
_M_r = (_RealType(1) + __rho * __rho) / (_RealType(2) * __rho);
}
_RealType
mu() const
{ return _M_mu; }
_RealType
kappa() const
{ return _M_kappa; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{ return __p1._M_mu == __p2._M_mu && __p1._M_kappa == __p2._M_kappa; }
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
_RealType _M_mu;
_RealType _M_kappa;
_RealType _M_r;
};
/**
* @brief Constructs a von Mises distribution with parameters
* @f$\mu@f$ and @f$\kappa@f$.
*/
explicit
von_mises_distribution(result_type __mu = result_type(0),
result_type __kappa = result_type(1))
: _M_param(__mu, __kappa)
{ }
explicit
von_mises_distribution(const param_type& __p)
: _M_param(__p)
{ }
/**
* @brief Resets the distribution state.
*/
void
reset()
{ }
/**
* @brief Returns the @f$ \mu @f$ of the distribution.
*/
result_type
mu() const
{ return _M_param.mu(); }
/**
* @brief Returns the @f$ \kappa @f$ of the distribution.
*/
result_type
kappa() const
{ return _M_param.kappa(); }
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ _M_param = __param; }
/**
* @brief Returns the greatest lower bound value of the distribution.
*/
result_type
min() const
{
return -__gnu_cxx::__math_constants<result_type>::__pi;
}
/**
* @brief Returns the least upper bound value of the distribution.
*/
result_type
max() const
{
return __gnu_cxx::__math_constants<result_type>::__pi;
}
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
{ return this->operator()(__urng, _M_param); }
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p);
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate(__f, __t, __urng, _M_param); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two von Mises distributions have the same
* parameters and the sequences that would be generated
* are equal.
*/
friend bool
operator==(const von_mises_distribution& __d1,
const von_mises_distribution& __d2)
{ return __d1._M_param == __d2._M_param; }
/**
* @brief Inserts a %von_mises_distribution random number distribution
* @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %von_mises_distribution random number distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const __gnu_cxx::von_mises_distribution<_RealType1>& __x);
/**
* @brief Extracts a %von_mises_distribution random number distribution
* @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %von_mises_distribution random number generator engine.
*
* @returns The input stream with @p __x extracted or in an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
__gnu_cxx::von_mises_distribution<_RealType1>& __x);
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
param_type _M_param;
};
/**
* @brief Return true if two von Mises distributions are different.
*/
template<typename _RealType>
inline bool
operator!=(const __gnu_cxx::von_mises_distribution<_RealType>& __d1,
const __gnu_cxx::von_mises_distribution<_RealType>& __d2)
{ return !(__d1 == __d2); }
/**
* @brief A discrete hypergeometric random number distribution.
*
* The hypergeometric distribution is a discrete probability distribution
* that describes the probability of @p k successes in @p n draws @a without
* replacement from a finite population of size @p N containing exactly @p K
* successes.
*
* The formula for the hypergeometric probability density function is
* @f[
* p(k|N,K,n) = \frac{\binom{K}{k} \binom{N-K}{n-k}}{\binom{N}{n}}
* @f]
* where @f$N@f$ is the total population of the distribution,
* @f$K@f$ is the total population of the distribution.
*
* <table border=1 cellpadding=10 cellspacing=0>
* <caption align=top>Distribution Statistics</caption>
* <tr><td>Mean</td><td>@f$ n\frac{K}{N} @f$</td></tr>
* <tr><td>Variance</td><td>@f$ n\frac{K}{N}\frac{N-K}{N}\frac{N-n}{N-1}
* @f$</td></tr>
* <tr><td>Range</td><td>@f$[max(0, n+K-N), min(K, n)]@f$</td></tr>
* </table>
*/
template<typename _UIntType = unsigned int>
class hypergeometric_distribution
{
static_assert(std::is_unsigned<_UIntType>::value, "template argument "
"substituting _UIntType not an unsigned integral type");
public:
/** The type of the range of the distribution. */
typedef _UIntType result_type;
/** Parameter type. */
struct param_type
{
typedef hypergeometric_distribution<_UIntType> distribution_type;
friend class hypergeometric_distribution<_UIntType>;
explicit
param_type(result_type __N = 10, result_type __K = 5,
result_type __n = 1)
: _M_N{__N}, _M_K{__K}, _M_n{__n}
{
__glibcxx_assert(_M_N >= _M_K);
__glibcxx_assert(_M_N >= _M_n);
}
result_type
total_size() const
{ return _M_N; }
result_type
successful_size() const
{ return _M_K; }
result_type
unsuccessful_size() const
{ return _M_N - _M_K; }
result_type
total_draws() const
{ return _M_n; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{ return (__p1._M_N == __p2._M_N)
&& (__p1._M_K == __p2._M_K)
&& (__p1._M_n == __p2._M_n); }
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
result_type _M_N;
result_type _M_K;
result_type _M_n;
};
// constructors and member function
explicit
hypergeometric_distribution(result_type __N = 10, result_type __K = 5,
result_type __n = 1)
: _M_param{__N, __K, __n}
{ }
explicit
hypergeometric_distribution(const param_type& __p)
: _M_param{__p}
{ }
/**
* @brief Resets the distribution state.
*/
void
reset()
{ }
/**
* @brief Returns the distribution parameter @p N,
* the total number of items.
*/
result_type
total_size() const
{ return this->_M_param.total_size(); }
/**
* @brief Returns the distribution parameter @p K,
* the total number of successful items.
*/
result_type
successful_size() const
{ return this->_M_param.successful_size(); }
/**
* @brief Returns the total number of unsuccessful items @f$ N - K @f$.
*/
result_type
unsuccessful_size() const
{ return this->_M_param.unsuccessful_size(); }
/**
* @brief Returns the distribution parameter @p n,
* the total number of draws.
*/
result_type
total_draws() const
{ return this->_M_param.total_draws(); }
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return this->_M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ this->_M_param = __param; }
/**
* @brief Returns the greatest lower bound value of the distribution.
*/
result_type
min() const
{
using _IntType = typename std::make_signed<result_type>::type;
return static_cast<result_type>(std::max(static_cast<_IntType>(0),
static_cast<_IntType>(this->total_draws()
- this->unsuccessful_size())));
}
/**
* @brief Returns the least upper bound value of the distribution.
*/
result_type
max() const
{ return std::min(this->successful_size(), this->total_draws()); }
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
{ return this->operator()(__urng, this->_M_param); }
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p);
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate(__f, __t, __urng, this->_M_param); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two hypergeometric distributions have the same
* parameters and the sequences that would be generated
* are equal.
*/
friend bool
operator==(const hypergeometric_distribution& __d1,
const hypergeometric_distribution& __d2)
{ return __d1._M_param == __d2._M_param; }
/**
* @brief Inserts a %hypergeometric_distribution random number
* distribution @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %hypergeometric_distribution random number
* distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _UIntType1, typename _CharT, typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const __gnu_cxx::hypergeometric_distribution<_UIntType1>&
__x);
/**
* @brief Extracts a %hypergeometric_distribution random number
* distribution @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %hypergeometric_distribution random number generator
* distribution.
*
* @returns The input stream with @p __x extracted or in an error
* state.
*/
template<typename _UIntType1, typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
__gnu_cxx::hypergeometric_distribution<_UIntType1>& __x);
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
param_type _M_param;
};
/**
* @brief Return true if two hypergeometric distributions are different.
*/
template<typename _UIntType>
inline bool
operator!=(const __gnu_cxx::hypergeometric_distribution<_UIntType>& __d1,
const __gnu_cxx::hypergeometric_distribution<_UIntType>& __d2)
{ return !(__d1 == __d2); }
/**
* @brief A logistic continuous distribution for random numbers.
*
* The formula for the logistic probability density function is
* @f[
* p(x|\a,\b) = \frac{e^{(x - a)/b}}{b[1 + e^{(x - a)/b}]^2}
* @f]
* where @f$b > 0@f$.
*
* The formula for the logistic probability function is
* @f[
* cdf(x|\a,\b) = \frac{e^{(x - a)/b}}{1 + e^{(x - a)/b}}
* @f]
* where @f$b > 0@f$.
*
* <table border=1 cellpadding=10 cellspacing=0>
* <caption align=top>Distribution Statistics</caption>
* <tr><td>Mean</td><td>@f$a@f$</td></tr>
* <tr><td>Variance</td><td>@f$b^2\pi^2/3@f$</td></tr>
* <tr><td>Range</td><td>@f$[0, \infty)@f$</td></tr>
* </table>
*/
template<typename _RealType = double>
class
logistic_distribution
{
static_assert(std::is_floating_point<_RealType>::value,
"template argument not a floating point type");
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
/** Parameter type. */
struct param_type
{
typedef logistic_distribution<result_type> distribution_type;
param_type(result_type __a = result_type(0),
result_type __b = result_type(1))
: _M_a(__a), _M_b(__b)
{
__glibcxx_assert(_M_b > result_type(0));
}
result_type
a() const
{ return _M_a; }
result_type
b() const
{ return _M_b; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{ return __p1._M_a == __p2._M_a && __p1._M_b == __p2._M_b; }
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
void _M_initialize();
result_type _M_a;
result_type _M_b;
};
/**
* @brief Constructors.
*/
explicit
logistic_distribution(result_type __a = result_type(0),
result_type __b = result_type(1))
: _M_param(__a, __b)
{ }
explicit
logistic_distribution(const param_type& __p)
: _M_param(__p)
{ }
/**
* @brief Resets the distribution state.
*/
void
reset()
{ }
/**
* @brief Return the parameters of the distribution.
*/
result_type
a() const
{ return _M_param.a(); }
result_type
b() const
{ return _M_param.b(); }
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ _M_param = __param; }
/**
* @brief Returns the greatest lower bound value of the distribution.
*/
result_type
min() const
{ return -std::numeric_limits<result_type>::max(); }
/**
* @brief Returns the least upper bound value of the distribution.
*/
result_type
max() const
{ return std::numeric_limits<result_type>::max(); }
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
{ return this->operator()(__urng, this->_M_param); }
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator&,
const param_type&);
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate(__f, __t, __urng, this->param()); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two logistic distributions have
* the same parameters and the sequences that would
* be generated are equal.
*/
template<typename _RealType1>
friend bool
operator==(const logistic_distribution<_RealType1>& __d1,
const logistic_distribution<_RealType1>& __d2)
{ return __d1.param() == __d2.param(); }
/**
* @brief Inserts a %logistic_distribution random number distribution
* @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %logistic_distribution random number distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>&,
const logistic_distribution<_RealType1>&);
/**
* @brief Extracts a %logistic_distribution random number distribution
* @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %logistic_distribution random number
* generator engine.
*
* @returns The input stream with @p __x extracted or in an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>&,
logistic_distribution<_RealType1>&);
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
param_type _M_param;
};
/**
* @brief Return true if two logistic distributions are not equal.
*/
template<typename _RealType1>
inline bool
operator!=(const logistic_distribution<_RealType1>& __d1,
const logistic_distribution<_RealType1>& __d2)
{ return !(__d1 == __d2); }
/**
* @brief A distribution for random coordinates on a unit sphere.
*
* The method used in the generation function is attributed by Donald Knuth
* to G. W. Brown, Modern Mathematics for the Engineer (1956).
*/
template<std::size_t _Dimen, typename _RealType = double>
class uniform_on_sphere_distribution
{
static_assert(std::is_floating_point<_RealType>::value,
"template argument not a floating point type");
static_assert(_Dimen != 0, "dimension is zero");
public:
/** The type of the range of the distribution. */
typedef std::array<_RealType, _Dimen> result_type;
/** Parameter type. */
struct param_type
{
explicit
param_type()
{ }
friend bool
operator==(const param_type&, const param_type&)
{ return true; }
friend bool
operator!=(const param_type&, const param_type&)
{ return false; }
};
/**
* @brief Constructs a uniform on sphere distribution.
*/
explicit
uniform_on_sphere_distribution()
: _M_param(), _M_nd()
{ }
explicit
uniform_on_sphere_distribution(const param_type& __p)
: _M_param(__p), _M_nd()
{ }
/**
* @brief Resets the distribution state.
*/
void
reset()
{ _M_nd.reset(); }
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ _M_param = __param; }
/**
* @brief Returns the greatest lower bound value of the distribution.
* This function makes no sense for this distribution.
*/
result_type
min() const
{
result_type __res;
__res.fill(0);
return __res;
}
/**
* @brief Returns the least upper bound value of the distribution.
* This function makes no sense for this distribution.
*/
result_type
max() const
{
result_type __res;
__res.fill(0);
return __res;
}
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
{ return this->operator()(__urng, _M_param); }
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p);
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate(__f, __t, __urng, this->param()); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two uniform on sphere distributions have
* the same parameters and the sequences that would be
* generated are equal.
*/
friend bool
operator==(const uniform_on_sphere_distribution& __d1,
const uniform_on_sphere_distribution& __d2)
{ return __d1._M_nd == __d2._M_nd; }
/**
* @brief Inserts a %uniform_on_sphere_distribution random number
* distribution @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %uniform_on_sphere_distribution random number
* distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<size_t _Dimen1, typename _RealType1, typename _CharT,
typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const __gnu_cxx::uniform_on_sphere_distribution<_Dimen1,
_RealType1>&
__x);
/**
* @brief Extracts a %uniform_on_sphere_distribution random number
* distribution
* @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %uniform_on_sphere_distribution random number
* generator engine.
*
* @returns The input stream with @p __x extracted or in an error state.
*/
template<std::size_t _Dimen1, typename _RealType1, typename _CharT,
typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
__gnu_cxx::uniform_on_sphere_distribution<_Dimen1,
_RealType1>& __x);
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
param_type _M_param;
std::normal_distribution<_RealType> _M_nd;
};
/**
* @brief Return true if two uniform on sphere distributions are different.
*/
template<std::size_t _Dimen, typename _RealType>
inline bool
operator!=(const __gnu_cxx::uniform_on_sphere_distribution<_Dimen,
_RealType>& __d1,
const __gnu_cxx::uniform_on_sphere_distribution<_Dimen,
_RealType>& __d2)
{ return !(__d1 == __d2); }
/**
* @brief A distribution for random coordinates inside a unit sphere.
*/
template<std::size_t _Dimen, typename _RealType = double>
class uniform_inside_sphere_distribution
{
static_assert(std::is_floating_point<_RealType>::value,
"template argument not a floating point type");
static_assert(_Dimen != 0, "dimension is zero");
public:
/** The type of the range of the distribution. */
using result_type = std::array<_RealType, _Dimen>;
/** Parameter type. */
struct param_type
{
using distribution_type
= uniform_inside_sphere_distribution<_Dimen, _RealType>;
friend class uniform_inside_sphere_distribution<_Dimen, _RealType>;
explicit
param_type(_RealType __radius = _RealType(1))
: _M_radius(__radius)
{
__glibcxx_assert(_M_radius > _RealType(0));
}
_RealType
radius() const
{ return _M_radius; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{ return __p1._M_radius == __p2._M_radius; }
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
_RealType _M_radius;
};
/**
* @brief Constructors.
*/
explicit
uniform_inside_sphere_distribution(_RealType __radius = _RealType(1))
: _M_param(__radius), _M_uosd()
{ }
explicit
uniform_inside_sphere_distribution(const param_type& __p)
: _M_param(__p), _M_uosd()
{ }
/**
* @brief Resets the distribution state.
*/
void
reset()
{ _M_uosd.reset(); }
/**
* @brief Returns the @f$radius@f$ of the distribution.
*/
_RealType
radius() const
{ return _M_param.radius(); }
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ _M_param = __param; }
/**
* @brief Returns the greatest lower bound value of the distribution.
* This function makes no sense for this distribution.
*/
result_type
min() const
{
result_type __res;
__res.fill(0);
return __res;
}
/**
* @brief Returns the least upper bound value of the distribution.
* This function makes no sense for this distribution.
*/
result_type
max() const
{
result_type __res;
__res.fill(0);
return __res;
}
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
{ return this->operator()(__urng, _M_param); }
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p);
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate(__f, __t, __urng, this->param()); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two uniform on sphere distributions have
* the same parameters and the sequences that would be
* generated are equal.
*/
friend bool
operator==(const uniform_inside_sphere_distribution& __d1,
const uniform_inside_sphere_distribution& __d2)
{ return __d1._M_param == __d2._M_param && __d1._M_uosd == __d2._M_uosd; }
/**
* @brief Inserts a %uniform_inside_sphere_distribution random number
* distribution @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %uniform_inside_sphere_distribution random number
* distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<size_t _Dimen1, typename _RealType1, typename _CharT,
typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const __gnu_cxx::uniform_inside_sphere_distribution<_Dimen1,
_RealType1>&
);
/**
* @brief Extracts a %uniform_inside_sphere_distribution random number
* distribution
* @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %uniform_inside_sphere_distribution random number
* generator engine.
*
* @returns The input stream with @p __x extracted or in an error state.
*/
template<std::size_t _Dimen1, typename _RealType1, typename _CharT,
typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
__gnu_cxx::uniform_inside_sphere_distribution<_Dimen1,
_RealType1>&);
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
param_type _M_param;
uniform_on_sphere_distribution<_Dimen, _RealType> _M_uosd;
};
/**
* @brief Return true if two uniform on sphere distributions are different.
*/
template<std::size_t _Dimen, typename _RealType>
inline bool
operator!=(const __gnu_cxx::uniform_inside_sphere_distribution<_Dimen,
_RealType>& __d1,
const __gnu_cxx::uniform_inside_sphere_distribution<_Dimen,
_RealType>& __d2)
{ return !(__d1 == __d2); }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace __gnu_cxx
#include <ext/opt_random.h>
#include <ext/random.tcc>
#endif // _GLIBCXX_USE_C99_STDINT_TR1 && UINT32_C
#endif // C++11
#endif // _EXT_RANDOM
c++/8/ext/algorithm 0000644 00000045532 15201526705 0010010 0 ustar 00 // Algorithm extensions -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1996
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file ext/algorithm
* This file is a GNU extension to the Standard C++ Library (possibly
* containing extensions from the HP/SGI STL subset).
*/
#ifndef _EXT_ALGORITHM
#define _EXT_ALGORITHM 1
#pragma GCC system_header
#include <algorithm>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using std::ptrdiff_t;
using std::min;
using std::pair;
using std::input_iterator_tag;
using std::random_access_iterator_tag;
using std::iterator_traits;
//--------------------------------------------------
// copy_n (not part of the C++ standard)
template<typename _InputIterator, typename _Size, typename _OutputIterator>
pair<_InputIterator, _OutputIterator>
__copy_n(_InputIterator __first, _Size __count,
_OutputIterator __result,
input_iterator_tag)
{
for ( ; __count > 0; --__count)
{
*__result = *__first;
++__first;
++__result;
}
return pair<_InputIterator, _OutputIterator>(__first, __result);
}
template<typename _RAIterator, typename _Size, typename _OutputIterator>
inline pair<_RAIterator, _OutputIterator>
__copy_n(_RAIterator __first, _Size __count,
_OutputIterator __result,
random_access_iterator_tag)
{
_RAIterator __last = __first + __count;
return pair<_RAIterator, _OutputIterator>(__last, std::copy(__first,
__last,
__result));
}
/**
* @brief Copies the range [first,first+count) into [result,result+count).
* @param __first An input iterator.
* @param __count The number of elements to copy.
* @param __result An output iterator.
* @return A std::pair composed of first+count and result+count.
*
* This is an SGI extension.
* This inline function will boil down to a call to @c memmove whenever
* possible. Failing that, if random access iterators are passed, then the
* loop count will be known (and therefore a candidate for compiler
* optimizations such as unrolling).
* @ingroup SGIextensions
*/
template<typename _InputIterator, typename _Size, typename _OutputIterator>
inline pair<_InputIterator, _OutputIterator>
copy_n(_InputIterator __first, _Size __count, _OutputIterator __result)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_InputIterator>::value_type>)
return __gnu_cxx::__copy_n(__first, __count, __result,
std::__iterator_category(__first));
}
template<typename _InputIterator1, typename _InputIterator2>
int
__lexicographical_compare_3way(_InputIterator1 __first1,
_InputIterator1 __last1,
_InputIterator2 __first2,
_InputIterator2 __last2)
{
while (__first1 != __last1 && __first2 != __last2)
{
if (*__first1 < *__first2)
return -1;
if (*__first2 < *__first1)
return 1;
++__first1;
++__first2;
}
if (__first2 == __last2)
return !(__first1 == __last1);
else
return -1;
}
inline int
__lexicographical_compare_3way(const unsigned char* __first1,
const unsigned char* __last1,
const unsigned char* __first2,
const unsigned char* __last2)
{
const ptrdiff_t __len1 = __last1 - __first1;
const ptrdiff_t __len2 = __last2 - __first2;
const int __result = __builtin_memcmp(__first1, __first2,
min(__len1, __len2));
return __result != 0 ? __result
: (__len1 == __len2 ? 0 : (__len1 < __len2 ? -1 : 1));
}
inline int
__lexicographical_compare_3way(const char* __first1, const char* __last1,
const char* __first2, const char* __last2)
{
#if CHAR_MAX == SCHAR_MAX
return __lexicographical_compare_3way((const signed char*) __first1,
(const signed char*) __last1,
(const signed char*) __first2,
(const signed char*) __last2);
#else
return __lexicographical_compare_3way((const unsigned char*) __first1,
(const unsigned char*) __last1,
(const unsigned char*) __first2,
(const unsigned char*) __last2);
#endif
}
/**
* @brief @c memcmp on steroids.
* @param __first1 An input iterator.
* @param __last1 An input iterator.
* @param __first2 An input iterator.
* @param __last2 An input iterator.
* @return An int, as with @c memcmp.
*
* The return value will be less than zero if the first range is
* <em>lexigraphically less than</em> the second, greater than zero
* if the second range is <em>lexigraphically less than</em> the
* first, and zero otherwise.
* This is an SGI extension.
* @ingroup SGIextensions
*/
template<typename _InputIterator1, typename _InputIterator2>
int
lexicographical_compare_3way(_InputIterator1 __first1,
_InputIterator1 __last1,
_InputIterator2 __first2,
_InputIterator2 __last2)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
__glibcxx_function_requires(_LessThanComparableConcept<
typename iterator_traits<_InputIterator1>::value_type>)
__glibcxx_function_requires(_LessThanComparableConcept<
typename iterator_traits<_InputIterator2>::value_type>)
__glibcxx_requires_valid_range(__first1, __last1);
__glibcxx_requires_valid_range(__first2, __last2);
return __lexicographical_compare_3way(__first1, __last1, __first2,
__last2);
}
// count and count_if: this version, whose return type is void, was present
// in the HP STL, and is retained as an extension for backward compatibility.
template<typename _InputIterator, typename _Tp, typename _Size>
void
count(_InputIterator __first, _InputIterator __last,
const _Tp& __value,
_Size& __n)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_EqualityComparableConcept<
typename iterator_traits<_InputIterator>::value_type >)
__glibcxx_function_requires(_EqualityComparableConcept<_Tp>)
__glibcxx_requires_valid_range(__first, __last);
for ( ; __first != __last; ++__first)
if (*__first == __value)
++__n;
}
template<typename _InputIterator, typename _Predicate, typename _Size>
void
count_if(_InputIterator __first, _InputIterator __last,
_Predicate __pred,
_Size& __n)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
typename iterator_traits<_InputIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
for ( ; __first != __last; ++__first)
if (__pred(*__first))
++__n;
}
// random_sample and random_sample_n (extensions, not part of the standard).
/**
* This is an SGI extension.
* @ingroup SGIextensions
* @doctodo
*/
template<typename _ForwardIterator, typename _OutputIterator,
typename _Distance>
_OutputIterator
random_sample_n(_ForwardIterator __first, _ForwardIterator __last,
_OutputIterator __out, const _Distance __n)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
_Distance __remaining = std::distance(__first, __last);
_Distance __m = min(__n, __remaining);
while (__m > 0)
{
if ((std::rand() % __remaining) < __m)
{
*__out = *__first;
++__out;
--__m;
}
--__remaining;
++__first;
}
return __out;
}
/**
* This is an SGI extension.
* @ingroup SGIextensions
* @doctodo
*/
template<typename _ForwardIterator, typename _OutputIterator,
typename _Distance, typename _RandomNumberGenerator>
_OutputIterator
random_sample_n(_ForwardIterator __first, _ForwardIterator __last,
_OutputIterator __out, const _Distance __n,
_RandomNumberGenerator& __rand)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_function_requires(_UnaryFunctionConcept<
_RandomNumberGenerator, _Distance, _Distance>)
__glibcxx_requires_valid_range(__first, __last);
_Distance __remaining = std::distance(__first, __last);
_Distance __m = min(__n, __remaining);
while (__m > 0)
{
if (__rand(__remaining) < __m)
{
*__out = *__first;
++__out;
--__m;
}
--__remaining;
++__first;
}
return __out;
}
template<typename _InputIterator, typename _RandomAccessIterator,
typename _Distance>
_RandomAccessIterator
__random_sample(_InputIterator __first, _InputIterator __last,
_RandomAccessIterator __out,
const _Distance __n)
{
_Distance __m = 0;
_Distance __t = __n;
for ( ; __first != __last && __m < __n; ++__m, ++__first)
__out[__m] = *__first;
while (__first != __last)
{
++__t;
_Distance __M = std::rand() % (__t);
if (__M < __n)
__out[__M] = *__first;
++__first;
}
return __out + __m;
}
template<typename _InputIterator, typename _RandomAccessIterator,
typename _RandomNumberGenerator, typename _Distance>
_RandomAccessIterator
__random_sample(_InputIterator __first, _InputIterator __last,
_RandomAccessIterator __out,
_RandomNumberGenerator& __rand,
const _Distance __n)
{
// concept requirements
__glibcxx_function_requires(_UnaryFunctionConcept<
_RandomNumberGenerator, _Distance, _Distance>)
_Distance __m = 0;
_Distance __t = __n;
for ( ; __first != __last && __m < __n; ++__m, ++__first)
__out[__m] = *__first;
while (__first != __last)
{
++__t;
_Distance __M = __rand(__t);
if (__M < __n)
__out[__M] = *__first;
++__first;
}
return __out + __m;
}
/**
* This is an SGI extension.
* @ingroup SGIextensions
* @doctodo
*/
template<typename _InputIterator, typename _RandomAccessIterator>
inline _RandomAccessIterator
random_sample(_InputIterator __first, _InputIterator __last,
_RandomAccessIterator __out_first,
_RandomAccessIterator __out_last)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_valid_range(__out_first, __out_last);
return __random_sample(__first, __last,
__out_first, __out_last - __out_first);
}
/**
* This is an SGI extension.
* @ingroup SGIextensions
* @doctodo
*/
template<typename _InputIterator, typename _RandomAccessIterator,
typename _RandomNumberGenerator>
inline _RandomAccessIterator
random_sample(_InputIterator __first, _InputIterator __last,
_RandomAccessIterator __out_first,
_RandomAccessIterator __out_last,
_RandomNumberGenerator& __rand)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_valid_range(__out_first, __out_last);
return __random_sample(__first, __last,
__out_first, __rand,
__out_last - __out_first);
}
#if __cplusplus >= 201103L
using std::is_heap;
#else
/**
* This is an SGI extension.
* @ingroup SGIextensions
* @doctodo
*/
template<typename _RandomAccessIterator>
inline bool
is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
{
// concept requirements
__glibcxx_function_requires(_RandomAccessIteratorConcept<
_RandomAccessIterator>)
__glibcxx_function_requires(_LessThanComparableConcept<
typename iterator_traits<_RandomAccessIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
return std::__is_heap(__first, __last - __first);
}
/**
* This is an SGI extension.
* @ingroup SGIextensions
* @doctodo
*/
template<typename _RandomAccessIterator, typename _StrictWeakOrdering>
inline bool
is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
_StrictWeakOrdering __comp)
{
// concept requirements
__glibcxx_function_requires(_RandomAccessIteratorConcept<
_RandomAccessIterator>)
__glibcxx_function_requires(_BinaryPredicateConcept<_StrictWeakOrdering,
typename iterator_traits<_RandomAccessIterator>::value_type,
typename iterator_traits<_RandomAccessIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
return std::__is_heap(__first, __comp, __last - __first);
}
#endif
#if __cplusplus >= 201103L
using std::is_sorted;
#else
// is_sorted, a predicated testing whether a range is sorted in
// nondescending order. This is an extension, not part of the C++
// standard.
/**
* This is an SGI extension.
* @ingroup SGIextensions
* @doctodo
*/
template<typename _ForwardIterator>
bool
is_sorted(_ForwardIterator __first, _ForwardIterator __last)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_LessThanComparableConcept<
typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
if (__first == __last)
return true;
_ForwardIterator __next = __first;
for (++__next; __next != __last; __first = __next, ++__next)
if (*__next < *__first)
return false;
return true;
}
/**
* This is an SGI extension.
* @ingroup SGIextensions
* @doctodo
*/
template<typename _ForwardIterator, typename _StrictWeakOrdering>
bool
is_sorted(_ForwardIterator __first, _ForwardIterator __last,
_StrictWeakOrdering __comp)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_BinaryPredicateConcept<_StrictWeakOrdering,
typename iterator_traits<_ForwardIterator>::value_type,
typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
if (__first == __last)
return true;
_ForwardIterator __next = __first;
for (++__next; __next != __last; __first = __next, ++__next)
if (__comp(*__next, *__first))
return false;
return true;
}
#endif // C++11
/**
* @brief Find the median of three values.
* @param __a A value.
* @param __b A value.
* @param __c A value.
* @return One of @p a, @p b or @p c.
*
* If @c {l,m,n} is some convolution of @p {a,b,c} such that @c l<=m<=n
* then the value returned will be @c m.
* This is an SGI extension.
* @ingroup SGIextensions
*/
template<typename _Tp>
const _Tp&
__median(const _Tp& __a, const _Tp& __b, const _Tp& __c)
{
// concept requirements
__glibcxx_function_requires(_LessThanComparableConcept<_Tp>)
if (__a < __b)
if (__b < __c)
return __b;
else if (__a < __c)
return __c;
else
return __a;
else if (__a < __c)
return __a;
else if (__b < __c)
return __c;
else
return __b;
}
/**
* @brief Find the median of three values using a predicate for comparison.
* @param __a A value.
* @param __b A value.
* @param __c A value.
* @param __comp A binary predicate.
* @return One of @p a, @p b or @p c.
*
* If @c {l,m,n} is some convolution of @p {a,b,c} such that @p comp(l,m)
* and @p comp(m,n) are both true then the value returned will be @c m.
* This is an SGI extension.
* @ingroup SGIextensions
*/
template<typename _Tp, typename _Compare>
const _Tp&
__median(const _Tp& __a, const _Tp& __b, const _Tp& __c, _Compare __comp)
{
// concept requirements
__glibcxx_function_requires(_BinaryFunctionConcept<_Compare, bool,
_Tp, _Tp>)
if (__comp(__a, __b))
if (__comp(__b, __c))
return __b;
else if (__comp(__a, __c))
return __c;
else
return __a;
else if (__comp(__a, __c))
return __a;
else if (__comp(__b, __c))
return __c;
else
return __b;
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif /* _EXT_ALGORITHM */
c++/8/ext/vstring.tcc 0000644 00000056076 15201526705 0010273 0 ustar 00 // Versatile string -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file ext/vstring.tcc
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{ext/vstring.h}
*/
#ifndef _VSTRING_TCC
#define _VSTRING_TCC 1
#pragma GCC system_header
#include <bits/cxxabi_forced.h>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
const typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type
__versa_string<_CharT, _Traits, _Alloc, _Base>::npos;
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
void
__versa_string<_CharT, _Traits, _Alloc, _Base>::
resize(size_type __n, _CharT __c)
{
const size_type __size = this->size();
if (__size < __n)
this->append(__n - __size, __c);
else if (__n < __size)
this->_M_erase(__n, __size - __n);
}
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
__versa_string<_CharT, _Traits, _Alloc, _Base>&
__versa_string<_CharT, _Traits, _Alloc, _Base>::
_M_append(const _CharT* __s, size_type __n)
{
const size_type __len = __n + this->size();
if (__len <= this->capacity() && !this->_M_is_shared())
{
if (__n)
this->_S_copy(this->_M_data() + this->size(), __s, __n);
}
else
this->_M_mutate(this->size(), size_type(0), __s, __n);
this->_M_set_length(__len);
return *this;
}
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
template<typename _InputIterator>
__versa_string<_CharT, _Traits, _Alloc, _Base>&
__versa_string<_CharT, _Traits, _Alloc, _Base>::
_M_replace_dispatch(const_iterator __i1, const_iterator __i2,
_InputIterator __k1, _InputIterator __k2,
std::__false_type)
{
const __versa_string __s(__k1, __k2);
const size_type __n1 = __i2 - __i1;
return _M_replace(__i1 - _M_ibegin(), __n1, __s._M_data(),
__s.size());
}
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
__versa_string<_CharT, _Traits, _Alloc, _Base>&
__versa_string<_CharT, _Traits, _Alloc, _Base>::
_M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
_CharT __c)
{
_M_check_length(__n1, __n2, "__versa_string::_M_replace_aux");
const size_type __old_size = this->size();
const size_type __new_size = __old_size + __n2 - __n1;
if (__new_size <= this->capacity() && !this->_M_is_shared())
{
_CharT* __p = this->_M_data() + __pos1;
const size_type __how_much = __old_size - __pos1 - __n1;
if (__how_much && __n1 != __n2)
this->_S_move(__p + __n2, __p + __n1, __how_much);
}
else
this->_M_mutate(__pos1, __n1, 0, __n2);
if (__n2)
this->_S_assign(this->_M_data() + __pos1, __n2, __c);
this->_M_set_length(__new_size);
return *this;
}
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
__versa_string<_CharT, _Traits, _Alloc, _Base>&
__versa_string<_CharT, _Traits, _Alloc, _Base>::
_M_replace(size_type __pos, size_type __len1, const _CharT* __s,
const size_type __len2)
{
_M_check_length(__len1, __len2, "__versa_string::_M_replace");
const size_type __old_size = this->size();
const size_type __new_size = __old_size + __len2 - __len1;
if (__new_size <= this->capacity() && !this->_M_is_shared())
{
_CharT* __p = this->_M_data() + __pos;
const size_type __how_much = __old_size - __pos - __len1;
if (_M_disjunct(__s))
{
if (__how_much && __len1 != __len2)
this->_S_move(__p + __len2, __p + __len1, __how_much);
if (__len2)
this->_S_copy(__p, __s, __len2);
}
else
{
// Work in-place.
if (__len2 && __len2 <= __len1)
this->_S_move(__p, __s, __len2);
if (__how_much && __len1 != __len2)
this->_S_move(__p + __len2, __p + __len1, __how_much);
if (__len2 > __len1)
{
if (__s + __len2 <= __p + __len1)
this->_S_move(__p, __s, __len2);
else if (__s >= __p + __len1)
this->_S_copy(__p, __s + __len2 - __len1, __len2);
else
{
const size_type __nleft = (__p + __len1) - __s;
this->_S_move(__p, __s, __nleft);
this->_S_copy(__p + __nleft, __p + __len2,
__len2 - __nleft);
}
}
}
}
else
this->_M_mutate(__pos, __len1, __s, __len2);
this->_M_set_length(__new_size);
return *this;
}
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
__versa_string<_CharT, _Traits, _Alloc, _Base>
operator+(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
{
__versa_string<_CharT, _Traits, _Alloc, _Base> __str;
__str.reserve(__lhs.size() + __rhs.size());
__str.append(__lhs);
__str.append(__rhs);
return __str;
}
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
__versa_string<_CharT, _Traits, _Alloc, _Base>
operator+(const _CharT* __lhs,
const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
{
__glibcxx_requires_string(__lhs);
typedef __versa_string<_CharT, _Traits, _Alloc, _Base> __string_type;
typedef typename __string_type::size_type __size_type;
const __size_type __len = _Traits::length(__lhs);
__string_type __str;
__str.reserve(__len + __rhs.size());
__str.append(__lhs, __len);
__str.append(__rhs);
return __str;
}
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
__versa_string<_CharT, _Traits, _Alloc, _Base>
operator+(_CharT __lhs,
const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
{
__versa_string<_CharT, _Traits, _Alloc, _Base> __str;
__str.reserve(__rhs.size() + 1);
__str.push_back(__lhs);
__str.append(__rhs);
return __str;
}
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
__versa_string<_CharT, _Traits, _Alloc, _Base>
operator+(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
const _CharT* __rhs)
{
__glibcxx_requires_string(__rhs);
typedef __versa_string<_CharT, _Traits, _Alloc, _Base> __string_type;
typedef typename __string_type::size_type __size_type;
const __size_type __len = _Traits::length(__rhs);
__string_type __str;
__str.reserve(__lhs.size() + __len);
__str.append(__lhs);
__str.append(__rhs, __len);
return __str;
}
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
__versa_string<_CharT, _Traits, _Alloc, _Base>
operator+(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
_CharT __rhs)
{
__versa_string<_CharT, _Traits, _Alloc, _Base> __str;
__str.reserve(__lhs.size() + 1);
__str.append(__lhs);
__str.push_back(__rhs);
return __str;
}
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type
__versa_string<_CharT, _Traits, _Alloc, _Base>::
copy(_CharT* __s, size_type __n, size_type __pos) const
{
_M_check(__pos, "__versa_string::copy");
__n = _M_limit(__pos, __n);
__glibcxx_requires_string_len(__s, __n);
if (__n)
this->_S_copy(__s, this->_M_data() + __pos, __n);
// 21.3.5.7 par 3: do not append null. (good.)
return __n;
}
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type
__versa_string<_CharT, _Traits, _Alloc, _Base>::
find(const _CharT* __s, size_type __pos, size_type __n) const
{
__glibcxx_requires_string_len(__s, __n);
const size_type __size = this->size();
const _CharT* __data = this->_M_data();
if (__n == 0)
return __pos <= __size ? __pos : npos;
if (__n <= __size)
{
for (; __pos <= __size - __n; ++__pos)
if (traits_type::eq(__data[__pos], __s[0])
&& traits_type::compare(__data + __pos + 1,
__s + 1, __n - 1) == 0)
return __pos;
}
return npos;
}
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type
__versa_string<_CharT, _Traits, _Alloc, _Base>::
find(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT
{
size_type __ret = npos;
const size_type __size = this->size();
if (__pos < __size)
{
const _CharT* __data = this->_M_data();
const size_type __n = __size - __pos;
const _CharT* __p = traits_type::find(__data + __pos, __n, __c);
if (__p)
__ret = __p - __data;
}
return __ret;
}
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type
__versa_string<_CharT, _Traits, _Alloc, _Base>::
rfind(const _CharT* __s, size_type __pos, size_type __n) const
{
__glibcxx_requires_string_len(__s, __n);
const size_type __size = this->size();
if (__n <= __size)
{
__pos = std::min(size_type(__size - __n), __pos);
const _CharT* __data = this->_M_data();
do
{
if (traits_type::compare(__data + __pos, __s, __n) == 0)
return __pos;
}
while (__pos-- > 0);
}
return npos;
}
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type
__versa_string<_CharT, _Traits, _Alloc, _Base>::
rfind(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT
{
size_type __size = this->size();
if (__size)
{
if (--__size > __pos)
__size = __pos;
for (++__size; __size-- > 0; )
if (traits_type::eq(this->_M_data()[__size], __c))
return __size;
}
return npos;
}
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type
__versa_string<_CharT, _Traits, _Alloc, _Base>::
find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
{
__glibcxx_requires_string_len(__s, __n);
for (; __n && __pos < this->size(); ++__pos)
{
const _CharT* __p = traits_type::find(__s, __n,
this->_M_data()[__pos]);
if (__p)
return __pos;
}
return npos;
}
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type
__versa_string<_CharT, _Traits, _Alloc, _Base>::
find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
{
__glibcxx_requires_string_len(__s, __n);
size_type __size = this->size();
if (__size && __n)
{
if (--__size > __pos)
__size = __pos;
do
{
if (traits_type::find(__s, __n, this->_M_data()[__size]))
return __size;
}
while (__size-- != 0);
}
return npos;
}
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type
__versa_string<_CharT, _Traits, _Alloc, _Base>::
find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
{
__glibcxx_requires_string_len(__s, __n);
for (; __pos < this->size(); ++__pos)
if (!traits_type::find(__s, __n, this->_M_data()[__pos]))
return __pos;
return npos;
}
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type
__versa_string<_CharT, _Traits, _Alloc, _Base>::
find_first_not_of(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT
{
for (; __pos < this->size(); ++__pos)
if (!traits_type::eq(this->_M_data()[__pos], __c))
return __pos;
return npos;
}
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type
__versa_string<_CharT, _Traits, _Alloc, _Base>::
find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
{
__glibcxx_requires_string_len(__s, __n);
size_type __size = this->size();
if (__size)
{
if (--__size > __pos)
__size = __pos;
do
{
if (!traits_type::find(__s, __n, this->_M_data()[__size]))
return __size;
}
while (__size--);
}
return npos;
}
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type
__versa_string<_CharT, _Traits, _Alloc, _Base>::
find_last_not_of(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT
{
size_type __size = this->size();
if (__size)
{
if (--__size > __pos)
__size = __pos;
do
{
if (!traits_type::eq(this->_M_data()[__size], __c))
return __size;
}
while (__size--);
}
return npos;
}
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
int
__versa_string<_CharT, _Traits, _Alloc, _Base>::
compare(size_type __pos, size_type __n, const __versa_string& __str) const
{
_M_check(__pos, "__versa_string::compare");
__n = _M_limit(__pos, __n);
const size_type __osize = __str.size();
const size_type __len = std::min(__n, __osize);
int __r = traits_type::compare(this->_M_data() + __pos,
__str.data(), __len);
if (!__r)
__r = this->_S_compare(__n, __osize);
return __r;
}
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
int
__versa_string<_CharT, _Traits, _Alloc, _Base>::
compare(size_type __pos1, size_type __n1, const __versa_string& __str,
size_type __pos2, size_type __n2) const
{
_M_check(__pos1, "__versa_string::compare");
__str._M_check(__pos2, "__versa_string::compare");
__n1 = _M_limit(__pos1, __n1);
__n2 = __str._M_limit(__pos2, __n2);
const size_type __len = std::min(__n1, __n2);
int __r = traits_type::compare(this->_M_data() + __pos1,
__str.data() + __pos2, __len);
if (!__r)
__r = this->_S_compare(__n1, __n2);
return __r;
}
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
int
__versa_string<_CharT, _Traits, _Alloc, _Base>::
compare(const _CharT* __s) const
{
__glibcxx_requires_string(__s);
const size_type __size = this->size();
const size_type __osize = traits_type::length(__s);
const size_type __len = std::min(__size, __osize);
int __r = traits_type::compare(this->_M_data(), __s, __len);
if (!__r)
__r = this->_S_compare(__size, __osize);
return __r;
}
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
int
__versa_string <_CharT, _Traits, _Alloc, _Base>::
compare(size_type __pos, size_type __n1, const _CharT* __s) const
{
__glibcxx_requires_string(__s);
_M_check(__pos, "__versa_string::compare");
__n1 = _M_limit(__pos, __n1);
const size_type __osize = traits_type::length(__s);
const size_type __len = std::min(__n1, __osize);
int __r = traits_type::compare(this->_M_data() + __pos, __s, __len);
if (!__r)
__r = this->_S_compare(__n1, __osize);
return __r;
}
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
int
__versa_string <_CharT, _Traits, _Alloc, _Base>::
compare(size_type __pos, size_type __n1, const _CharT* __s,
size_type __n2) const
{
__glibcxx_requires_string_len(__s, __n2);
_M_check(__pos, "__versa_string::compare");
__n1 = _M_limit(__pos, __n1);
const size_type __len = std::min(__n1, __n2);
int __r = traits_type::compare(this->_M_data() + __pos, __s, __len);
if (!__r)
__r = this->_S_compare(__n1, __n2);
return __r;
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __in,
__gnu_cxx::__versa_string<_CharT, _Traits,
_Alloc, _Base>& __str)
{
typedef basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
typedef __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc, _Base>
__string_type;
typedef typename __istream_type::int_type __int_type;
typedef typename __string_type::size_type __size_type;
typedef ctype<_CharT> __ctype_type;
typedef typename __ctype_type::ctype_base __ctype_base;
__size_type __extracted = 0;
typename __ios_base::iostate __err = __ios_base::goodbit;
typename __istream_type::sentry __cerb(__in, false);
if (__cerb)
{
__try
{
// Avoid reallocation for common case.
__str.erase();
_CharT __buf[128];
__size_type __len = 0;
const streamsize __w = __in.width();
const __size_type __n = __w > 0 ? static_cast<__size_type>(__w)
: __str.max_size();
const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc());
const __int_type __eof = _Traits::eof();
__int_type __c = __in.rdbuf()->sgetc();
while (__extracted < __n
&& !_Traits::eq_int_type(__c, __eof)
&& !__ct.is(__ctype_base::space,
_Traits::to_char_type(__c)))
{
if (__len == sizeof(__buf) / sizeof(_CharT))
{
__str.append(__buf, sizeof(__buf) / sizeof(_CharT));
__len = 0;
}
__buf[__len++] = _Traits::to_char_type(__c);
++__extracted;
__c = __in.rdbuf()->snextc();
}
__str.append(__buf, __len);
if (_Traits::eq_int_type(__c, __eof))
__err |= __ios_base::eofbit;
__in.width(0);
}
__catch(__cxxabiv1::__forced_unwind&)
{
__in._M_setstate(__ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 91. Description of operator>> and getline() for string<>
// might cause endless loop
__in._M_setstate(__ios_base::badbit);
}
}
// 211. operator>>(istream&, string&) doesn't set failbit
if (!__extracted)
__err |= __ios_base::failbit;
if (__err)
__in.setstate(__err);
return __in;
}
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
basic_istream<_CharT, _Traits>&
getline(basic_istream<_CharT, _Traits>& __in,
__gnu_cxx::__versa_string<_CharT, _Traits, _Alloc, _Base>& __str,
_CharT __delim)
{
typedef basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
typedef __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc, _Base>
__string_type;
typedef typename __istream_type::int_type __int_type;
typedef typename __string_type::size_type __size_type;
__size_type __extracted = 0;
const __size_type __n = __str.max_size();
typename __ios_base::iostate __err = __ios_base::goodbit;
typename __istream_type::sentry __cerb(__in, true);
if (__cerb)
{
__try
{
// Avoid reallocation for common case.
__str.erase();
_CharT __buf[128];
__size_type __len = 0;
const __int_type __idelim = _Traits::to_int_type(__delim);
const __int_type __eof = _Traits::eof();
__int_type __c = __in.rdbuf()->sgetc();
while (__extracted < __n
&& !_Traits::eq_int_type(__c, __eof)
&& !_Traits::eq_int_type(__c, __idelim))
{
if (__len == sizeof(__buf) / sizeof(_CharT))
{
__str.append(__buf, sizeof(__buf) / sizeof(_CharT));
__len = 0;
}
__buf[__len++] = _Traits::to_char_type(__c);
++__extracted;
__c = __in.rdbuf()->snextc();
}
__str.append(__buf, __len);
if (_Traits::eq_int_type(__c, __eof))
__err |= __ios_base::eofbit;
else if (_Traits::eq_int_type(__c, __idelim))
{
++__extracted;
__in.rdbuf()->sbumpc();
}
else
__err |= __ios_base::failbit;
}
__catch(__cxxabiv1::__forced_unwind&)
{
__in._M_setstate(__ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 91. Description of operator>> and getline() for string<>
// might cause endless loop
__in._M_setstate(__ios_base::badbit);
}
}
if (!__extracted)
__err |= __ios_base::failbit;
if (__err)
__in.setstate(__err);
return __in;
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif // _VSTRING_TCC
c++/8/ext/enc_filebuf.h 0000644 00000004307 15201526705 0010504 0 ustar 00 // filebuf with encoding state type -*- C++ -*-
// Copyright (C) 2002-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file ext/enc_filebuf.h
* This file is a GNU extension to the Standard C++ Library.
*/
#ifndef _EXT_ENC_FILEBUF_H
#define _EXT_ENC_FILEBUF_H 1
#include <fstream>
#include <locale>
#include <ext/codecvt_specializations.h>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/// class enc_filebuf.
template<typename _CharT>
class enc_filebuf
: public std::basic_filebuf<_CharT, encoding_char_traits<_CharT> >
{
public:
typedef encoding_char_traits<_CharT> traits_type;
typedef typename traits_type::state_type state_type;
typedef typename traits_type::pos_type pos_type;
enc_filebuf(state_type& __state)
: std::basic_filebuf<_CharT, encoding_char_traits<_CharT> >()
{ this->_M_state_beg = __state; }
private:
// concept requirements:
// Set state type to something useful.
// Something more than copyconstructible is needed here, so
// require default and copy constructible + assignment operator.
__glibcxx_class_requires(state_type, _SGIAssignableConcept)
};
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/iostream 0000644 00000005207 15201526705 0007040 0 ustar 00 // Standard iostream objects -*- C++ -*-
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/iostream
* This is a Standard C++ Library header.
*/
//
// ISO C++ 14882: 27.3 Standard iostream objects
//
#ifndef _GLIBCXX_IOSTREAM
#define _GLIBCXX_IOSTREAM 1
#pragma GCC system_header
#include <bits/c++config.h>
#include <ostream>
#include <istream>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @name Standard Stream Objects
*
* The <iostream> header declares the eight <em>standard stream
* objects</em>. For other declarations, see
* http://gcc.gnu.org/onlinedocs/libstdc++/manual/io.html
* and the @link iosfwd I/O forward declarations @endlink
*
* They are required by default to cooperate with the global C
* library's @c FILE streams, and to be available during program
* startup and termination. For more information, see the section of the
* manual linked to above.
*/
//@{
extern istream cin; /// Linked to standard input
extern ostream cout; /// Linked to standard output
extern ostream cerr; /// Linked to standard error (unbuffered)
extern ostream clog; /// Linked to standard error (buffered)
#ifdef _GLIBCXX_USE_WCHAR_T
extern wistream wcin; /// Linked to standard input
extern wostream wcout; /// Linked to standard output
extern wostream wcerr; /// Linked to standard error (unbuffered)
extern wostream wclog; /// Linked to standard error (buffered)
#endif
//@}
// For construction of filebuffers for cout, cin, cerr, clog et. al.
static ios_base::Init __ioinit;
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif /* _GLIBCXX_IOSTREAM */
c++/8/x86_64-redhat-linux/ext/opt_random.h 0000644 00000011224 15201526705 0013741 0 ustar 00 // Optimizations for random number extensions, x86 version -*- C++ -*-
// Copyright (C) 2012-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file ext/random.tcc
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{ext/random}
*/
#ifndef _EXT_OPT_RANDOM_H
#define _EXT_OPT_RANDOM_H 1
#pragma GCC system_header
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#ifdef __SSE2__
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
namespace {
template<size_t __sl1, size_t __sl2, size_t __sr1, size_t __sr2,
uint32_t __msk1, uint32_t __msk2, uint32_t __msk3, uint32_t __msk4>
inline __m128i __sse2_recursion(__m128i __a, __m128i __b,
__m128i __c, __m128i __d)
{
__m128i __y = _mm_srli_epi32(__b, __sr1);
__m128i __z = _mm_srli_si128(__c, __sr2);
__m128i __v = _mm_slli_epi32(__d, __sl1);
__z = _mm_xor_si128(__z, __a);
__z = _mm_xor_si128(__z, __v);
__m128i __x = _mm_slli_si128(__a, __sl2);
__y = _mm_and_si128(__y, _mm_set_epi32(__msk4, __msk3, __msk2, __msk1));
__z = _mm_xor_si128(__z, __x);
return _mm_xor_si128(__z, __y);
}
}
#define _GLIBCXX_OPT_HAVE_RANDOM_SFMT_GEN_READ 1
template<typename _UIntType, size_t __m,
size_t __pos1, size_t __sl1, size_t __sl2,
size_t __sr1, size_t __sr2,
uint32_t __msk1, uint32_t __msk2,
uint32_t __msk3, uint32_t __msk4,
uint32_t __parity1, uint32_t __parity2,
uint32_t __parity3, uint32_t __parity4>
void simd_fast_mersenne_twister_engine<_UIntType, __m,
__pos1, __sl1, __sl2, __sr1, __sr2,
__msk1, __msk2, __msk3, __msk4,
__parity1, __parity2, __parity3,
__parity4>::
_M_gen_rand(void)
{
__m128i __r1 = _mm_load_si128(&_M_state[_M_nstate - 2]);
__m128i __r2 = _mm_load_si128(&_M_state[_M_nstate - 1]);
size_t __i;
for (__i = 0; __i < _M_nstate - __pos1; ++__i)
{
__m128i __r = __sse2_recursion<__sl1, __sl2, __sr1, __sr2,
__msk1, __msk2, __msk3, __msk4>
(_M_state[__i], _M_state[__i + __pos1], __r1, __r2);
_mm_store_si128(&_M_state[__i], __r);
__r1 = __r2;
__r2 = __r;
}
for (; __i < _M_nstate; ++__i)
{
__m128i __r = __sse2_recursion<__sl1, __sl2, __sr1, __sr2,
__msk1, __msk2, __msk3, __msk4>
(_M_state[__i], _M_state[__i + __pos1 - _M_nstate], __r1, __r2);
_mm_store_si128(&_M_state[__i], __r);
__r1 = __r2;
__r2 = __r;
}
_M_pos = 0;
}
#define _GLIBCXX_OPT_HAVE_RANDOM_SFMT_OPERATOREQUAL 1
template<typename _UIntType, size_t __m,
size_t __pos1, size_t __sl1, size_t __sl2,
size_t __sr1, size_t __sr2,
uint32_t __msk1, uint32_t __msk2,
uint32_t __msk3, uint32_t __msk4,
uint32_t __parity1, uint32_t __parity2,
uint32_t __parity3, uint32_t __parity4>
bool
operator==(const __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType,
__m, __pos1, __sl1, __sl2, __sr1, __sr2,
__msk1, __msk2, __msk3, __msk4,
__parity1, __parity2, __parity3, __parity4>& __lhs,
const __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType,
__m, __pos1, __sl1, __sl2, __sr1, __sr2,
__msk1, __msk2, __msk3, __msk4,
__parity1, __parity2, __parity3, __parity4>& __rhs)
{
__m128i __res = _mm_cmpeq_epi8(__lhs._M_state[0], __rhs._M_state[0]);
for (size_t __i = 1; __i < __lhs._M_nstate; ++__i)
__res = _mm_and_si128(__res, _mm_cmpeq_epi8(__lhs._M_state[__i],
__rhs._M_state[__i]));
return (_mm_movemask_epi8(__res) == 0xffff
&& __lhs._M_pos == __rhs._M_pos);
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif // __SSE2__
#endif // __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#endif // _EXT_OPT_RANDOM_H
c++/8/x86_64-redhat-linux/bits/gthr-default.h 0000644 00000057255 15201526705 0014344 0 ustar 00 /* Threads compatibility routines for libgcc2 and libobjc. */
/* Compile this one with gcc. */
/* Copyright (C) 1997-2018 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _GLIBCXX_GCC_GTHR_POSIX_H
#define _GLIBCXX_GCC_GTHR_POSIX_H
/* POSIX threads specific definitions.
Easy, since the interface is just one-to-one mapping. */
#define __GTHREADS 1
#define __GTHREADS_CXX0X 1
#include <pthread.h>
#if ((defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)) \
|| !defined(_GTHREAD_USE_MUTEX_TIMEDLOCK))
# include <unistd.h>
# if defined(_POSIX_TIMEOUTS) && _POSIX_TIMEOUTS >= 0
# define _GTHREAD_USE_MUTEX_TIMEDLOCK 1
# else
# define _GTHREAD_USE_MUTEX_TIMEDLOCK 0
# endif
#endif
typedef pthread_t __gthread_t;
typedef pthread_key_t __gthread_key_t;
typedef pthread_once_t __gthread_once_t;
typedef pthread_mutex_t __gthread_mutex_t;
typedef pthread_mutex_t __gthread_recursive_mutex_t;
typedef pthread_cond_t __gthread_cond_t;
typedef struct timespec __gthread_time_t;
/* POSIX like conditional variables are supported. Please look at comments
in gthr.h for details. */
#define __GTHREAD_HAS_COND 1
#define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
#define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function
#define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT
#if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER)
#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER
#elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
#else
#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
#endif
#define __GTHREAD_COND_INIT PTHREAD_COND_INITIALIZER
#define __GTHREAD_TIME_INIT {0,0}
#ifdef _GTHREAD_USE_MUTEX_INIT_FUNC
# undef __GTHREAD_MUTEX_INIT
#endif
#ifdef _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC
# undef __GTHREAD_RECURSIVE_MUTEX_INIT
# undef __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
# define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
#endif
#ifdef _GTHREAD_USE_COND_INIT_FUNC
# undef __GTHREAD_COND_INIT
# define __GTHREAD_COND_INIT_FUNCTION __gthread_cond_init_function
#endif
#if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK
# ifndef __gthrw_pragma
# define __gthrw_pragma(pragma)
# endif
# define __gthrw2(name,name2,type) \
static __typeof(type) name __attribute__ ((__weakref__(#name2))); \
__gthrw_pragma(weak type)
# define __gthrw_(name) __gthrw_ ## name
#else
# define __gthrw2(name,name2,type)
# define __gthrw_(name) name
#endif
/* Typically, __gthrw_foo is a weak reference to symbol foo. */
#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
__gthrw(pthread_once)
__gthrw(pthread_getspecific)
__gthrw(pthread_setspecific)
__gthrw(pthread_create)
__gthrw(pthread_join)
__gthrw(pthread_equal)
__gthrw(pthread_self)
__gthrw(pthread_detach)
#ifndef __BIONIC__
__gthrw(pthread_cancel)
#endif
__gthrw(sched_yield)
__gthrw(pthread_mutex_lock)
__gthrw(pthread_mutex_trylock)
#if _GTHREAD_USE_MUTEX_TIMEDLOCK
__gthrw(pthread_mutex_timedlock)
#endif
__gthrw(pthread_mutex_unlock)
__gthrw(pthread_mutex_init)
__gthrw(pthread_mutex_destroy)
__gthrw(pthread_cond_init)
__gthrw(pthread_cond_broadcast)
__gthrw(pthread_cond_signal)
__gthrw(pthread_cond_wait)
__gthrw(pthread_cond_timedwait)
__gthrw(pthread_cond_destroy)
__gthrw(pthread_key_create)
__gthrw(pthread_key_delete)
__gthrw(pthread_mutexattr_init)
__gthrw(pthread_mutexattr_settype)
__gthrw(pthread_mutexattr_destroy)
#if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)
/* Objective-C. */
__gthrw(pthread_exit)
#ifdef _POSIX_PRIORITY_SCHEDULING
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
__gthrw(sched_get_priority_max)
__gthrw(sched_get_priority_min)
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
#endif /* _POSIX_PRIORITY_SCHEDULING */
__gthrw(pthread_attr_destroy)
__gthrw(pthread_attr_init)
__gthrw(pthread_attr_setdetachstate)
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
__gthrw(pthread_getschedparam)
__gthrw(pthread_setschedparam)
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
#endif /* _LIBOBJC || _LIBOBJC_WEAK */
#if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK
/* On Solaris 2.6 up to 9, the libc exposes a POSIX threads interface even if
-pthreads is not specified. The functions are dummies and most return an
error value. However pthread_once returns 0 without invoking the routine
it is passed so we cannot pretend that the interface is active if -pthreads
is not specified. On Solaris 2.5.1, the interface is not exposed at all so
we need to play the usual game with weak symbols. On Solaris 10 and up, a
working interface is always exposed. On FreeBSD 6 and later, libc also
exposes a dummy POSIX threads interface, similar to what Solaris 2.6 up
to 9 does. FreeBSD >= 700014 even provides a pthread_cancel stub in libc,
which means the alternate __gthread_active_p below cannot be used there. */
#if defined(__FreeBSD__) || (defined(__sun) && defined(__svr4__))
static volatile int __gthread_active = -1;
static void
__gthread_trigger (void)
{
__gthread_active = 1;
}
static inline int
__gthread_active_p (void)
{
static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_once_t __gthread_active_once = PTHREAD_ONCE_INIT;
/* Avoid reading __gthread_active twice on the main code path. */
int __gthread_active_latest_value = __gthread_active;
/* This test is not protected to avoid taking a lock on the main code
path so every update of __gthread_active in a threaded program must
be atomic with regard to the result of the test. */
if (__builtin_expect (__gthread_active_latest_value < 0, 0))
{
if (__gthrw_(pthread_once))
{
/* If this really is a threaded program, then we must ensure that
__gthread_active has been set to 1 before exiting this block. */
__gthrw_(pthread_mutex_lock) (&__gthread_active_mutex);
__gthrw_(pthread_once) (&__gthread_active_once, __gthread_trigger);
__gthrw_(pthread_mutex_unlock) (&__gthread_active_mutex);
}
/* Make sure we'll never enter this block again. */
if (__gthread_active < 0)
__gthread_active = 0;
__gthread_active_latest_value = __gthread_active;
}
return __gthread_active_latest_value != 0;
}
#else /* neither FreeBSD nor Solaris */
/* For a program to be multi-threaded the only thing that it certainly must
be using is pthread_create. However, there may be other libraries that
intercept pthread_create with their own definitions to wrap pthreads
functionality for some purpose. In those cases, pthread_create being
defined might not necessarily mean that libpthread is actually linked
in.
For the GNU C library, we can use a known internal name. This is always
available in the ABI, but no other library would define it. That is
ideal, since any public pthread function might be intercepted just as
pthread_create might be. __pthread_key_create is an "internal"
implementation symbol, but it is part of the public exported ABI. Also,
it's among the symbols that the static libpthread.a always links in
whenever pthread_create is used, so there is no danger of a false
negative result in any statically-linked, multi-threaded program.
For others, we choose pthread_cancel as a function that seems unlikely
to be redefined by an interceptor library. The bionic (Android) C
library does not provide pthread_cancel, so we do use pthread_create
there (and interceptor libraries lose). */
#ifdef __GLIBC__
__gthrw2(__gthrw_(__pthread_key_create),
__pthread_key_create,
pthread_key_create)
# define GTHR_ACTIVE_PROXY __gthrw_(__pthread_key_create)
#elif defined (__BIONIC__)
# define GTHR_ACTIVE_PROXY __gthrw_(pthread_create)
#else
# define GTHR_ACTIVE_PROXY __gthrw_(pthread_cancel)
#endif
static inline int
__gthread_active_p (void)
{
static void *const __gthread_active_ptr
= __extension__ (void *) >HR_ACTIVE_PROXY;
return __gthread_active_ptr != 0;
}
#endif /* FreeBSD or Solaris */
#else /* not __GXX_WEAK__ */
/* Similar to Solaris, HP-UX 11 for PA-RISC provides stubs for pthread
calls in shared flavors of the HP-UX C library. Most of the stubs
have no functionality. The details are described in the "libc cumulative
patch" for each subversion of HP-UX 11. There are two special interfaces
provided for checking whether an application is linked to a shared pthread
library or not. However, these interfaces aren't available in early
libpthread libraries. We also need a test that works for archive
libraries. We can't use pthread_once as some libc versions call the
init function. We also can't use pthread_create or pthread_attr_init
as these create a thread and thereby prevent changing the default stack
size. The function pthread_default_stacksize_np is available in both
the archive and shared versions of libpthread. It can be used to
determine the default pthread stack size. There is a stub in some
shared libc versions which returns a zero size if pthreads are not
active. We provide an equivalent stub to handle cases where libc
doesn't provide one. */
#if defined(__hppa__) && defined(__hpux__)
static volatile int __gthread_active = -1;
static inline int
__gthread_active_p (void)
{
/* Avoid reading __gthread_active twice on the main code path. */
int __gthread_active_latest_value = __gthread_active;
size_t __s;
if (__builtin_expect (__gthread_active_latest_value < 0, 0))
{
pthread_default_stacksize_np (0, &__s);
__gthread_active = __s ? 1 : 0;
__gthread_active_latest_value = __gthread_active;
}
return __gthread_active_latest_value != 0;
}
#else /* not hppa-hpux */
static inline int
__gthread_active_p (void)
{
return 1;
}
#endif /* hppa-hpux */
#endif /* __GXX_WEAK__ */
#ifdef _LIBOBJC
/* This is the config.h file in libobjc/ */
#include <config.h>
#ifdef HAVE_SCHED_H
# include <sched.h>
#endif
/* Key structure for maintaining thread specific storage */
static pthread_key_t _objc_thread_storage;
static pthread_attr_t _objc_thread_attribs;
/* Thread local storage for a single thread */
static void *thread_local_storage = NULL;
/* Backend initialization functions */
/* Initialize the threads subsystem. */
static inline int
__gthread_objc_init_thread_system (void)
{
if (__gthread_active_p ())
{
/* Initialize the thread storage key. */
if (__gthrw_(pthread_key_create) (&_objc_thread_storage, NULL) == 0)
{
/* The normal default detach state for threads is
* PTHREAD_CREATE_JOINABLE which causes threads to not die
* when you think they should. */
if (__gthrw_(pthread_attr_init) (&_objc_thread_attribs) == 0
&& __gthrw_(pthread_attr_setdetachstate) (&_objc_thread_attribs,
PTHREAD_CREATE_DETACHED) == 0)
return 0;
}
}
return -1;
}
/* Close the threads subsystem. */
static inline int
__gthread_objc_close_thread_system (void)
{
if (__gthread_active_p ()
&& __gthrw_(pthread_key_delete) (_objc_thread_storage) == 0
&& __gthrw_(pthread_attr_destroy) (&_objc_thread_attribs) == 0)
return 0;
return -1;
}
/* Backend thread functions */
/* Create a new thread of execution. */
static inline objc_thread_t
__gthread_objc_thread_detach (void (*func)(void *), void *arg)
{
objc_thread_t thread_id;
pthread_t new_thread_handle;
if (!__gthread_active_p ())
return NULL;
if (!(__gthrw_(pthread_create) (&new_thread_handle, &_objc_thread_attribs,
(void *) func, arg)))
thread_id = (objc_thread_t) new_thread_handle;
else
thread_id = NULL;
return thread_id;
}
/* Set the current thread's priority. */
static inline int
__gthread_objc_thread_set_priority (int priority)
{
if (!__gthread_active_p ())
return -1;
else
{
#ifdef _POSIX_PRIORITY_SCHEDULING
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
pthread_t thread_id = __gthrw_(pthread_self) ();
int policy;
struct sched_param params;
int priority_min, priority_max;
if (__gthrw_(pthread_getschedparam) (thread_id, &policy, ¶ms) == 0)
{
if ((priority_max = __gthrw_(sched_get_priority_max) (policy)) == -1)
return -1;
if ((priority_min = __gthrw_(sched_get_priority_min) (policy)) == -1)
return -1;
if (priority > priority_max)
priority = priority_max;
else if (priority < priority_min)
priority = priority_min;
params.sched_priority = priority;
/*
* The solaris 7 and several other man pages incorrectly state that
* this should be a pointer to policy but pthread.h is universally
* at odds with this.
*/
if (__gthrw_(pthread_setschedparam) (thread_id, policy, ¶ms) == 0)
return 0;
}
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
#endif /* _POSIX_PRIORITY_SCHEDULING */
return -1;
}
}
/* Return the current thread's priority. */
static inline int
__gthread_objc_thread_get_priority (void)
{
#ifdef _POSIX_PRIORITY_SCHEDULING
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
if (__gthread_active_p ())
{
int policy;
struct sched_param params;
if (__gthrw_(pthread_getschedparam) (__gthrw_(pthread_self) (), &policy, ¶ms) == 0)
return params.sched_priority;
else
return -1;
}
else
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
#endif /* _POSIX_PRIORITY_SCHEDULING */
return OBJC_THREAD_INTERACTIVE_PRIORITY;
}
/* Yield our process time to another thread. */
static inline void
__gthread_objc_thread_yield (void)
{
if (__gthread_active_p ())
__gthrw_(sched_yield) ();
}
/* Terminate the current thread. */
static inline int
__gthread_objc_thread_exit (void)
{
if (__gthread_active_p ())
/* exit the thread */
__gthrw_(pthread_exit) (&__objc_thread_exit_status);
/* Failed if we reached here */
return -1;
}
/* Returns an integer value which uniquely describes a thread. */
static inline objc_thread_t
__gthread_objc_thread_id (void)
{
if (__gthread_active_p ())
return (objc_thread_t) __gthrw_(pthread_self) ();
else
return (objc_thread_t) 1;
}
/* Sets the thread's local storage pointer. */
static inline int
__gthread_objc_thread_set_data (void *value)
{
if (__gthread_active_p ())
return __gthrw_(pthread_setspecific) (_objc_thread_storage, value);
else
{
thread_local_storage = value;
return 0;
}
}
/* Returns the thread's local storage pointer. */
static inline void *
__gthread_objc_thread_get_data (void)
{
if (__gthread_active_p ())
return __gthrw_(pthread_getspecific) (_objc_thread_storage);
else
return thread_local_storage;
}
/* Backend mutex functions */
/* Allocate a mutex. */
static inline int
__gthread_objc_mutex_allocate (objc_mutex_t mutex)
{
if (__gthread_active_p ())
{
mutex->backend = objc_malloc (sizeof (pthread_mutex_t));
if (__gthrw_(pthread_mutex_init) ((pthread_mutex_t *) mutex->backend, NULL))
{
objc_free (mutex->backend);
mutex->backend = NULL;
return -1;
}
}
return 0;
}
/* Deallocate a mutex. */
static inline int
__gthread_objc_mutex_deallocate (objc_mutex_t mutex)
{
if (__gthread_active_p ())
{
int count;
/*
* Posix Threads specifically require that the thread be unlocked
* for __gthrw_(pthread_mutex_destroy) to work.
*/
do
{
count = __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend);
if (count < 0)
return -1;
}
while (count);
if (__gthrw_(pthread_mutex_destroy) ((pthread_mutex_t *) mutex->backend))
return -1;
objc_free (mutex->backend);
mutex->backend = NULL;
}
return 0;
}
/* Grab a lock on a mutex. */
static inline int
__gthread_objc_mutex_lock (objc_mutex_t mutex)
{
if (__gthread_active_p ()
&& __gthrw_(pthread_mutex_lock) ((pthread_mutex_t *) mutex->backend) != 0)
{
return -1;
}
return 0;
}
/* Try to grab a lock on a mutex. */
static inline int
__gthread_objc_mutex_trylock (objc_mutex_t mutex)
{
if (__gthread_active_p ()
&& __gthrw_(pthread_mutex_trylock) ((pthread_mutex_t *) mutex->backend) != 0)
{
return -1;
}
return 0;
}
/* Unlock the mutex */
static inline int
__gthread_objc_mutex_unlock (objc_mutex_t mutex)
{
if (__gthread_active_p ()
&& __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend) != 0)
{
return -1;
}
return 0;
}
/* Backend condition mutex functions */
/* Allocate a condition. */
static inline int
__gthread_objc_condition_allocate (objc_condition_t condition)
{
if (__gthread_active_p ())
{
condition->backend = objc_malloc (sizeof (pthread_cond_t));
if (__gthrw_(pthread_cond_init) ((pthread_cond_t *) condition->backend, NULL))
{
objc_free (condition->backend);
condition->backend = NULL;
return -1;
}
}
return 0;
}
/* Deallocate a condition. */
static inline int
__gthread_objc_condition_deallocate (objc_condition_t condition)
{
if (__gthread_active_p ())
{
if (__gthrw_(pthread_cond_destroy) ((pthread_cond_t *) condition->backend))
return -1;
objc_free (condition->backend);
condition->backend = NULL;
}
return 0;
}
/* Wait on the condition */
static inline int
__gthread_objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex)
{
if (__gthread_active_p ())
return __gthrw_(pthread_cond_wait) ((pthread_cond_t *) condition->backend,
(pthread_mutex_t *) mutex->backend);
else
return 0;
}
/* Wake up all threads waiting on this condition. */
static inline int
__gthread_objc_condition_broadcast (objc_condition_t condition)
{
if (__gthread_active_p ())
return __gthrw_(pthread_cond_broadcast) ((pthread_cond_t *) condition->backend);
else
return 0;
}
/* Wake up one thread waiting on this condition. */
static inline int
__gthread_objc_condition_signal (objc_condition_t condition)
{
if (__gthread_active_p ())
return __gthrw_(pthread_cond_signal) ((pthread_cond_t *) condition->backend);
else
return 0;
}
#else /* _LIBOBJC */
static inline int
__gthread_create (__gthread_t *__threadid, void *(*__func) (void*),
void *__args)
{
return __gthrw_(pthread_create) (__threadid, NULL, __func, __args);
}
static inline int
__gthread_join (__gthread_t __threadid, void **__value_ptr)
{
return __gthrw_(pthread_join) (__threadid, __value_ptr);
}
static inline int
__gthread_detach (__gthread_t __threadid)
{
return __gthrw_(pthread_detach) (__threadid);
}
static inline int
__gthread_equal (__gthread_t __t1, __gthread_t __t2)
{
return __gthrw_(pthread_equal) (__t1, __t2);
}
static inline __gthread_t
__gthread_self (void)
{
return __gthrw_(pthread_self) ();
}
static inline int
__gthread_yield (void)
{
return __gthrw_(sched_yield) ();
}
static inline int
__gthread_once (__gthread_once_t *__once, void (*__func) (void))
{
if (__gthread_active_p ())
return __gthrw_(pthread_once) (__once, __func);
else
return -1;
}
static inline int
__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *))
{
return __gthrw_(pthread_key_create) (__key, __dtor);
}
static inline int
__gthread_key_delete (__gthread_key_t __key)
{
return __gthrw_(pthread_key_delete) (__key);
}
static inline void *
__gthread_getspecific (__gthread_key_t __key)
{
return __gthrw_(pthread_getspecific) (__key);
}
static inline int
__gthread_setspecific (__gthread_key_t __key, const void *__ptr)
{
return __gthrw_(pthread_setspecific) (__key, __ptr);
}
static inline void
__gthread_mutex_init_function (__gthread_mutex_t *__mutex)
{
if (__gthread_active_p ())
__gthrw_(pthread_mutex_init) (__mutex, NULL);
}
static inline int
__gthread_mutex_destroy (__gthread_mutex_t *__mutex)
{
if (__gthread_active_p ())
return __gthrw_(pthread_mutex_destroy) (__mutex);
else
return 0;
}
static inline int
__gthread_mutex_lock (__gthread_mutex_t *__mutex)
{
if (__gthread_active_p ())
return __gthrw_(pthread_mutex_lock) (__mutex);
else
return 0;
}
static inline int
__gthread_mutex_trylock (__gthread_mutex_t *__mutex)
{
if (__gthread_active_p ())
return __gthrw_(pthread_mutex_trylock) (__mutex);
else
return 0;
}
#if _GTHREAD_USE_MUTEX_TIMEDLOCK
static inline int
__gthread_mutex_timedlock (__gthread_mutex_t *__mutex,
const __gthread_time_t *__abs_timeout)
{
if (__gthread_active_p ())
return __gthrw_(pthread_mutex_timedlock) (__mutex, __abs_timeout);
else
return 0;
}
#endif
static inline int
__gthread_mutex_unlock (__gthread_mutex_t *__mutex)
{
if (__gthread_active_p ())
return __gthrw_(pthread_mutex_unlock) (__mutex);
else
return 0;
}
#if !defined( PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) \
|| defined(_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC)
static inline int
__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex)
{
if (__gthread_active_p ())
{
pthread_mutexattr_t __attr;
int __r;
__r = __gthrw_(pthread_mutexattr_init) (&__attr);
if (!__r)
__r = __gthrw_(pthread_mutexattr_settype) (&__attr,
PTHREAD_MUTEX_RECURSIVE);
if (!__r)
__r = __gthrw_(pthread_mutex_init) (__mutex, &__attr);
if (!__r)
__r = __gthrw_(pthread_mutexattr_destroy) (&__attr);
return __r;
}
return 0;
}
#endif
static inline int
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_lock (__mutex);
}
static inline int
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_trylock (__mutex);
}
#if _GTHREAD_USE_MUTEX_TIMEDLOCK
static inline int
__gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *__mutex,
const __gthread_time_t *__abs_timeout)
{
return __gthread_mutex_timedlock (__mutex, __abs_timeout);
}
#endif
static inline int
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_unlock (__mutex);
}
static inline int
__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_destroy (__mutex);
}
#ifdef _GTHREAD_USE_COND_INIT_FUNC
static inline void
__gthread_cond_init_function (__gthread_cond_t *__cond)
{
if (__gthread_active_p ())
__gthrw_(pthread_cond_init) (__cond, NULL);
}
#endif
static inline int
__gthread_cond_broadcast (__gthread_cond_t *__cond)
{
return __gthrw_(pthread_cond_broadcast) (__cond);
}
static inline int
__gthread_cond_signal (__gthread_cond_t *__cond)
{
return __gthrw_(pthread_cond_signal) (__cond);
}
static inline int
__gthread_cond_wait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex)
{
return __gthrw_(pthread_cond_wait) (__cond, __mutex);
}
static inline int
__gthread_cond_timedwait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex,
const __gthread_time_t *__abs_timeout)
{
return __gthrw_(pthread_cond_timedwait) (__cond, __mutex, __abs_timeout);
}
static inline int
__gthread_cond_wait_recursive (__gthread_cond_t *__cond,
__gthread_recursive_mutex_t *__mutex)
{
return __gthread_cond_wait (__cond, __mutex);
}
static inline int
__gthread_cond_destroy (__gthread_cond_t* __cond)
{
return __gthrw_(pthread_cond_destroy) (__cond);
}
#endif /* _LIBOBJC */
#endif /* ! _GLIBCXX_GCC_GTHR_POSIX_H */
c++/8/x86_64-redhat-linux/bits/gthr-posix.h 0000644 00000057255 15201526705 0014062 0 ustar 00 /* Threads compatibility routines for libgcc2 and libobjc. */
/* Compile this one with gcc. */
/* Copyright (C) 1997-2018 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _GLIBCXX_GCC_GTHR_POSIX_H
#define _GLIBCXX_GCC_GTHR_POSIX_H
/* POSIX threads specific definitions.
Easy, since the interface is just one-to-one mapping. */
#define __GTHREADS 1
#define __GTHREADS_CXX0X 1
#include <pthread.h>
#if ((defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)) \
|| !defined(_GTHREAD_USE_MUTEX_TIMEDLOCK))
# include <unistd.h>
# if defined(_POSIX_TIMEOUTS) && _POSIX_TIMEOUTS >= 0
# define _GTHREAD_USE_MUTEX_TIMEDLOCK 1
# else
# define _GTHREAD_USE_MUTEX_TIMEDLOCK 0
# endif
#endif
typedef pthread_t __gthread_t;
typedef pthread_key_t __gthread_key_t;
typedef pthread_once_t __gthread_once_t;
typedef pthread_mutex_t __gthread_mutex_t;
typedef pthread_mutex_t __gthread_recursive_mutex_t;
typedef pthread_cond_t __gthread_cond_t;
typedef struct timespec __gthread_time_t;
/* POSIX like conditional variables are supported. Please look at comments
in gthr.h for details. */
#define __GTHREAD_HAS_COND 1
#define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
#define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function
#define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT
#if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER)
#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER
#elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
#else
#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
#endif
#define __GTHREAD_COND_INIT PTHREAD_COND_INITIALIZER
#define __GTHREAD_TIME_INIT {0,0}
#ifdef _GTHREAD_USE_MUTEX_INIT_FUNC
# undef __GTHREAD_MUTEX_INIT
#endif
#ifdef _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC
# undef __GTHREAD_RECURSIVE_MUTEX_INIT
# undef __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
# define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
#endif
#ifdef _GTHREAD_USE_COND_INIT_FUNC
# undef __GTHREAD_COND_INIT
# define __GTHREAD_COND_INIT_FUNCTION __gthread_cond_init_function
#endif
#if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK
# ifndef __gthrw_pragma
# define __gthrw_pragma(pragma)
# endif
# define __gthrw2(name,name2,type) \
static __typeof(type) name __attribute__ ((__weakref__(#name2))); \
__gthrw_pragma(weak type)
# define __gthrw_(name) __gthrw_ ## name
#else
# define __gthrw2(name,name2,type)
# define __gthrw_(name) name
#endif
/* Typically, __gthrw_foo is a weak reference to symbol foo. */
#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
__gthrw(pthread_once)
__gthrw(pthread_getspecific)
__gthrw(pthread_setspecific)
__gthrw(pthread_create)
__gthrw(pthread_join)
__gthrw(pthread_equal)
__gthrw(pthread_self)
__gthrw(pthread_detach)
#ifndef __BIONIC__
__gthrw(pthread_cancel)
#endif
__gthrw(sched_yield)
__gthrw(pthread_mutex_lock)
__gthrw(pthread_mutex_trylock)
#if _GTHREAD_USE_MUTEX_TIMEDLOCK
__gthrw(pthread_mutex_timedlock)
#endif
__gthrw(pthread_mutex_unlock)
__gthrw(pthread_mutex_init)
__gthrw(pthread_mutex_destroy)
__gthrw(pthread_cond_init)
__gthrw(pthread_cond_broadcast)
__gthrw(pthread_cond_signal)
__gthrw(pthread_cond_wait)
__gthrw(pthread_cond_timedwait)
__gthrw(pthread_cond_destroy)
__gthrw(pthread_key_create)
__gthrw(pthread_key_delete)
__gthrw(pthread_mutexattr_init)
__gthrw(pthread_mutexattr_settype)
__gthrw(pthread_mutexattr_destroy)
#if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)
/* Objective-C. */
__gthrw(pthread_exit)
#ifdef _POSIX_PRIORITY_SCHEDULING
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
__gthrw(sched_get_priority_max)
__gthrw(sched_get_priority_min)
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
#endif /* _POSIX_PRIORITY_SCHEDULING */
__gthrw(pthread_attr_destroy)
__gthrw(pthread_attr_init)
__gthrw(pthread_attr_setdetachstate)
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
__gthrw(pthread_getschedparam)
__gthrw(pthread_setschedparam)
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
#endif /* _LIBOBJC || _LIBOBJC_WEAK */
#if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK
/* On Solaris 2.6 up to 9, the libc exposes a POSIX threads interface even if
-pthreads is not specified. The functions are dummies and most return an
error value. However pthread_once returns 0 without invoking the routine
it is passed so we cannot pretend that the interface is active if -pthreads
is not specified. On Solaris 2.5.1, the interface is not exposed at all so
we need to play the usual game with weak symbols. On Solaris 10 and up, a
working interface is always exposed. On FreeBSD 6 and later, libc also
exposes a dummy POSIX threads interface, similar to what Solaris 2.6 up
to 9 does. FreeBSD >= 700014 even provides a pthread_cancel stub in libc,
which means the alternate __gthread_active_p below cannot be used there. */
#if defined(__FreeBSD__) || (defined(__sun) && defined(__svr4__))
static volatile int __gthread_active = -1;
static void
__gthread_trigger (void)
{
__gthread_active = 1;
}
static inline int
__gthread_active_p (void)
{
static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_once_t __gthread_active_once = PTHREAD_ONCE_INIT;
/* Avoid reading __gthread_active twice on the main code path. */
int __gthread_active_latest_value = __gthread_active;
/* This test is not protected to avoid taking a lock on the main code
path so every update of __gthread_active in a threaded program must
be atomic with regard to the result of the test. */
if (__builtin_expect (__gthread_active_latest_value < 0, 0))
{
if (__gthrw_(pthread_once))
{
/* If this really is a threaded program, then we must ensure that
__gthread_active has been set to 1 before exiting this block. */
__gthrw_(pthread_mutex_lock) (&__gthread_active_mutex);
__gthrw_(pthread_once) (&__gthread_active_once, __gthread_trigger);
__gthrw_(pthread_mutex_unlock) (&__gthread_active_mutex);
}
/* Make sure we'll never enter this block again. */
if (__gthread_active < 0)
__gthread_active = 0;
__gthread_active_latest_value = __gthread_active;
}
return __gthread_active_latest_value != 0;
}
#else /* neither FreeBSD nor Solaris */
/* For a program to be multi-threaded the only thing that it certainly must
be using is pthread_create. However, there may be other libraries that
intercept pthread_create with their own definitions to wrap pthreads
functionality for some purpose. In those cases, pthread_create being
defined might not necessarily mean that libpthread is actually linked
in.
For the GNU C library, we can use a known internal name. This is always
available in the ABI, but no other library would define it. That is
ideal, since any public pthread function might be intercepted just as
pthread_create might be. __pthread_key_create is an "internal"
implementation symbol, but it is part of the public exported ABI. Also,
it's among the symbols that the static libpthread.a always links in
whenever pthread_create is used, so there is no danger of a false
negative result in any statically-linked, multi-threaded program.
For others, we choose pthread_cancel as a function that seems unlikely
to be redefined by an interceptor library. The bionic (Android) C
library does not provide pthread_cancel, so we do use pthread_create
there (and interceptor libraries lose). */
#ifdef __GLIBC__
__gthrw2(__gthrw_(__pthread_key_create),
__pthread_key_create,
pthread_key_create)
# define GTHR_ACTIVE_PROXY __gthrw_(__pthread_key_create)
#elif defined (__BIONIC__)
# define GTHR_ACTIVE_PROXY __gthrw_(pthread_create)
#else
# define GTHR_ACTIVE_PROXY __gthrw_(pthread_cancel)
#endif
static inline int
__gthread_active_p (void)
{
static void *const __gthread_active_ptr
= __extension__ (void *) >HR_ACTIVE_PROXY;
return __gthread_active_ptr != 0;
}
#endif /* FreeBSD or Solaris */
#else /* not __GXX_WEAK__ */
/* Similar to Solaris, HP-UX 11 for PA-RISC provides stubs for pthread
calls in shared flavors of the HP-UX C library. Most of the stubs
have no functionality. The details are described in the "libc cumulative
patch" for each subversion of HP-UX 11. There are two special interfaces
provided for checking whether an application is linked to a shared pthread
library or not. However, these interfaces aren't available in early
libpthread libraries. We also need a test that works for archive
libraries. We can't use pthread_once as some libc versions call the
init function. We also can't use pthread_create or pthread_attr_init
as these create a thread and thereby prevent changing the default stack
size. The function pthread_default_stacksize_np is available in both
the archive and shared versions of libpthread. It can be used to
determine the default pthread stack size. There is a stub in some
shared libc versions which returns a zero size if pthreads are not
active. We provide an equivalent stub to handle cases where libc
doesn't provide one. */
#if defined(__hppa__) && defined(__hpux__)
static volatile int __gthread_active = -1;
static inline int
__gthread_active_p (void)
{
/* Avoid reading __gthread_active twice on the main code path. */
int __gthread_active_latest_value = __gthread_active;
size_t __s;
if (__builtin_expect (__gthread_active_latest_value < 0, 0))
{
pthread_default_stacksize_np (0, &__s);
__gthread_active = __s ? 1 : 0;
__gthread_active_latest_value = __gthread_active;
}
return __gthread_active_latest_value != 0;
}
#else /* not hppa-hpux */
static inline int
__gthread_active_p (void)
{
return 1;
}
#endif /* hppa-hpux */
#endif /* __GXX_WEAK__ */
#ifdef _LIBOBJC
/* This is the config.h file in libobjc/ */
#include <config.h>
#ifdef HAVE_SCHED_H
# include <sched.h>
#endif
/* Key structure for maintaining thread specific storage */
static pthread_key_t _objc_thread_storage;
static pthread_attr_t _objc_thread_attribs;
/* Thread local storage for a single thread */
static void *thread_local_storage = NULL;
/* Backend initialization functions */
/* Initialize the threads subsystem. */
static inline int
__gthread_objc_init_thread_system (void)
{
if (__gthread_active_p ())
{
/* Initialize the thread storage key. */
if (__gthrw_(pthread_key_create) (&_objc_thread_storage, NULL) == 0)
{
/* The normal default detach state for threads is
* PTHREAD_CREATE_JOINABLE which causes threads to not die
* when you think they should. */
if (__gthrw_(pthread_attr_init) (&_objc_thread_attribs) == 0
&& __gthrw_(pthread_attr_setdetachstate) (&_objc_thread_attribs,
PTHREAD_CREATE_DETACHED) == 0)
return 0;
}
}
return -1;
}
/* Close the threads subsystem. */
static inline int
__gthread_objc_close_thread_system (void)
{
if (__gthread_active_p ()
&& __gthrw_(pthread_key_delete) (_objc_thread_storage) == 0
&& __gthrw_(pthread_attr_destroy) (&_objc_thread_attribs) == 0)
return 0;
return -1;
}
/* Backend thread functions */
/* Create a new thread of execution. */
static inline objc_thread_t
__gthread_objc_thread_detach (void (*func)(void *), void *arg)
{
objc_thread_t thread_id;
pthread_t new_thread_handle;
if (!__gthread_active_p ())
return NULL;
if (!(__gthrw_(pthread_create) (&new_thread_handle, &_objc_thread_attribs,
(void *) func, arg)))
thread_id = (objc_thread_t) new_thread_handle;
else
thread_id = NULL;
return thread_id;
}
/* Set the current thread's priority. */
static inline int
__gthread_objc_thread_set_priority (int priority)
{
if (!__gthread_active_p ())
return -1;
else
{
#ifdef _POSIX_PRIORITY_SCHEDULING
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
pthread_t thread_id = __gthrw_(pthread_self) ();
int policy;
struct sched_param params;
int priority_min, priority_max;
if (__gthrw_(pthread_getschedparam) (thread_id, &policy, ¶ms) == 0)
{
if ((priority_max = __gthrw_(sched_get_priority_max) (policy)) == -1)
return -1;
if ((priority_min = __gthrw_(sched_get_priority_min) (policy)) == -1)
return -1;
if (priority > priority_max)
priority = priority_max;
else if (priority < priority_min)
priority = priority_min;
params.sched_priority = priority;
/*
* The solaris 7 and several other man pages incorrectly state that
* this should be a pointer to policy but pthread.h is universally
* at odds with this.
*/
if (__gthrw_(pthread_setschedparam) (thread_id, policy, ¶ms) == 0)
return 0;
}
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
#endif /* _POSIX_PRIORITY_SCHEDULING */
return -1;
}
}
/* Return the current thread's priority. */
static inline int
__gthread_objc_thread_get_priority (void)
{
#ifdef _POSIX_PRIORITY_SCHEDULING
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
if (__gthread_active_p ())
{
int policy;
struct sched_param params;
if (__gthrw_(pthread_getschedparam) (__gthrw_(pthread_self) (), &policy, ¶ms) == 0)
return params.sched_priority;
else
return -1;
}
else
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
#endif /* _POSIX_PRIORITY_SCHEDULING */
return OBJC_THREAD_INTERACTIVE_PRIORITY;
}
/* Yield our process time to another thread. */
static inline void
__gthread_objc_thread_yield (void)
{
if (__gthread_active_p ())
__gthrw_(sched_yield) ();
}
/* Terminate the current thread. */
static inline int
__gthread_objc_thread_exit (void)
{
if (__gthread_active_p ())
/* exit the thread */
__gthrw_(pthread_exit) (&__objc_thread_exit_status);
/* Failed if we reached here */
return -1;
}
/* Returns an integer value which uniquely describes a thread. */
static inline objc_thread_t
__gthread_objc_thread_id (void)
{
if (__gthread_active_p ())
return (objc_thread_t) __gthrw_(pthread_self) ();
else
return (objc_thread_t) 1;
}
/* Sets the thread's local storage pointer. */
static inline int
__gthread_objc_thread_set_data (void *value)
{
if (__gthread_active_p ())
return __gthrw_(pthread_setspecific) (_objc_thread_storage, value);
else
{
thread_local_storage = value;
return 0;
}
}
/* Returns the thread's local storage pointer. */
static inline void *
__gthread_objc_thread_get_data (void)
{
if (__gthread_active_p ())
return __gthrw_(pthread_getspecific) (_objc_thread_storage);
else
return thread_local_storage;
}
/* Backend mutex functions */
/* Allocate a mutex. */
static inline int
__gthread_objc_mutex_allocate (objc_mutex_t mutex)
{
if (__gthread_active_p ())
{
mutex->backend = objc_malloc (sizeof (pthread_mutex_t));
if (__gthrw_(pthread_mutex_init) ((pthread_mutex_t *) mutex->backend, NULL))
{
objc_free (mutex->backend);
mutex->backend = NULL;
return -1;
}
}
return 0;
}
/* Deallocate a mutex. */
static inline int
__gthread_objc_mutex_deallocate (objc_mutex_t mutex)
{
if (__gthread_active_p ())
{
int count;
/*
* Posix Threads specifically require that the thread be unlocked
* for __gthrw_(pthread_mutex_destroy) to work.
*/
do
{
count = __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend);
if (count < 0)
return -1;
}
while (count);
if (__gthrw_(pthread_mutex_destroy) ((pthread_mutex_t *) mutex->backend))
return -1;
objc_free (mutex->backend);
mutex->backend = NULL;
}
return 0;
}
/* Grab a lock on a mutex. */
static inline int
__gthread_objc_mutex_lock (objc_mutex_t mutex)
{
if (__gthread_active_p ()
&& __gthrw_(pthread_mutex_lock) ((pthread_mutex_t *) mutex->backend) != 0)
{
return -1;
}
return 0;
}
/* Try to grab a lock on a mutex. */
static inline int
__gthread_objc_mutex_trylock (objc_mutex_t mutex)
{
if (__gthread_active_p ()
&& __gthrw_(pthread_mutex_trylock) ((pthread_mutex_t *) mutex->backend) != 0)
{
return -1;
}
return 0;
}
/* Unlock the mutex */
static inline int
__gthread_objc_mutex_unlock (objc_mutex_t mutex)
{
if (__gthread_active_p ()
&& __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend) != 0)
{
return -1;
}
return 0;
}
/* Backend condition mutex functions */
/* Allocate a condition. */
static inline int
__gthread_objc_condition_allocate (objc_condition_t condition)
{
if (__gthread_active_p ())
{
condition->backend = objc_malloc (sizeof (pthread_cond_t));
if (__gthrw_(pthread_cond_init) ((pthread_cond_t *) condition->backend, NULL))
{
objc_free (condition->backend);
condition->backend = NULL;
return -1;
}
}
return 0;
}
/* Deallocate a condition. */
static inline int
__gthread_objc_condition_deallocate (objc_condition_t condition)
{
if (__gthread_active_p ())
{
if (__gthrw_(pthread_cond_destroy) ((pthread_cond_t *) condition->backend))
return -1;
objc_free (condition->backend);
condition->backend = NULL;
}
return 0;
}
/* Wait on the condition */
static inline int
__gthread_objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex)
{
if (__gthread_active_p ())
return __gthrw_(pthread_cond_wait) ((pthread_cond_t *) condition->backend,
(pthread_mutex_t *) mutex->backend);
else
return 0;
}
/* Wake up all threads waiting on this condition. */
static inline int
__gthread_objc_condition_broadcast (objc_condition_t condition)
{
if (__gthread_active_p ())
return __gthrw_(pthread_cond_broadcast) ((pthread_cond_t *) condition->backend);
else
return 0;
}
/* Wake up one thread waiting on this condition. */
static inline int
__gthread_objc_condition_signal (objc_condition_t condition)
{
if (__gthread_active_p ())
return __gthrw_(pthread_cond_signal) ((pthread_cond_t *) condition->backend);
else
return 0;
}
#else /* _LIBOBJC */
static inline int
__gthread_create (__gthread_t *__threadid, void *(*__func) (void*),
void *__args)
{
return __gthrw_(pthread_create) (__threadid, NULL, __func, __args);
}
static inline int
__gthread_join (__gthread_t __threadid, void **__value_ptr)
{
return __gthrw_(pthread_join) (__threadid, __value_ptr);
}
static inline int
__gthread_detach (__gthread_t __threadid)
{
return __gthrw_(pthread_detach) (__threadid);
}
static inline int
__gthread_equal (__gthread_t __t1, __gthread_t __t2)
{
return __gthrw_(pthread_equal) (__t1, __t2);
}
static inline __gthread_t
__gthread_self (void)
{
return __gthrw_(pthread_self) ();
}
static inline int
__gthread_yield (void)
{
return __gthrw_(sched_yield) ();
}
static inline int
__gthread_once (__gthread_once_t *__once, void (*__func) (void))
{
if (__gthread_active_p ())
return __gthrw_(pthread_once) (__once, __func);
else
return -1;
}
static inline int
__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *))
{
return __gthrw_(pthread_key_create) (__key, __dtor);
}
static inline int
__gthread_key_delete (__gthread_key_t __key)
{
return __gthrw_(pthread_key_delete) (__key);
}
static inline void *
__gthread_getspecific (__gthread_key_t __key)
{
return __gthrw_(pthread_getspecific) (__key);
}
static inline int
__gthread_setspecific (__gthread_key_t __key, const void *__ptr)
{
return __gthrw_(pthread_setspecific) (__key, __ptr);
}
static inline void
__gthread_mutex_init_function (__gthread_mutex_t *__mutex)
{
if (__gthread_active_p ())
__gthrw_(pthread_mutex_init) (__mutex, NULL);
}
static inline int
__gthread_mutex_destroy (__gthread_mutex_t *__mutex)
{
if (__gthread_active_p ())
return __gthrw_(pthread_mutex_destroy) (__mutex);
else
return 0;
}
static inline int
__gthread_mutex_lock (__gthread_mutex_t *__mutex)
{
if (__gthread_active_p ())
return __gthrw_(pthread_mutex_lock) (__mutex);
else
return 0;
}
static inline int
__gthread_mutex_trylock (__gthread_mutex_t *__mutex)
{
if (__gthread_active_p ())
return __gthrw_(pthread_mutex_trylock) (__mutex);
else
return 0;
}
#if _GTHREAD_USE_MUTEX_TIMEDLOCK
static inline int
__gthread_mutex_timedlock (__gthread_mutex_t *__mutex,
const __gthread_time_t *__abs_timeout)
{
if (__gthread_active_p ())
return __gthrw_(pthread_mutex_timedlock) (__mutex, __abs_timeout);
else
return 0;
}
#endif
static inline int
__gthread_mutex_unlock (__gthread_mutex_t *__mutex)
{
if (__gthread_active_p ())
return __gthrw_(pthread_mutex_unlock) (__mutex);
else
return 0;
}
#if !defined( PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) \
|| defined(_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC)
static inline int
__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex)
{
if (__gthread_active_p ())
{
pthread_mutexattr_t __attr;
int __r;
__r = __gthrw_(pthread_mutexattr_init) (&__attr);
if (!__r)
__r = __gthrw_(pthread_mutexattr_settype) (&__attr,
PTHREAD_MUTEX_RECURSIVE);
if (!__r)
__r = __gthrw_(pthread_mutex_init) (__mutex, &__attr);
if (!__r)
__r = __gthrw_(pthread_mutexattr_destroy) (&__attr);
return __r;
}
return 0;
}
#endif
static inline int
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_lock (__mutex);
}
static inline int
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_trylock (__mutex);
}
#if _GTHREAD_USE_MUTEX_TIMEDLOCK
static inline int
__gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *__mutex,
const __gthread_time_t *__abs_timeout)
{
return __gthread_mutex_timedlock (__mutex, __abs_timeout);
}
#endif
static inline int
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_unlock (__mutex);
}
static inline int
__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_destroy (__mutex);
}
#ifdef _GTHREAD_USE_COND_INIT_FUNC
static inline void
__gthread_cond_init_function (__gthread_cond_t *__cond)
{
if (__gthread_active_p ())
__gthrw_(pthread_cond_init) (__cond, NULL);
}
#endif
static inline int
__gthread_cond_broadcast (__gthread_cond_t *__cond)
{
return __gthrw_(pthread_cond_broadcast) (__cond);
}
static inline int
__gthread_cond_signal (__gthread_cond_t *__cond)
{
return __gthrw_(pthread_cond_signal) (__cond);
}
static inline int
__gthread_cond_wait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex)
{
return __gthrw_(pthread_cond_wait) (__cond, __mutex);
}
static inline int
__gthread_cond_timedwait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex,
const __gthread_time_t *__abs_timeout)
{
return __gthrw_(pthread_cond_timedwait) (__cond, __mutex, __abs_timeout);
}
static inline int
__gthread_cond_wait_recursive (__gthread_cond_t *__cond,
__gthread_recursive_mutex_t *__mutex)
{
return __gthread_cond_wait (__cond, __mutex);
}
static inline int
__gthread_cond_destroy (__gthread_cond_t* __cond)
{
return __gthrw_(pthread_cond_destroy) (__cond);
}
#endif /* _LIBOBJC */
#endif /* ! _GLIBCXX_GCC_GTHR_POSIX_H */
c++/8/x86_64-redhat-linux/bits/time_members.h 0000644 00000005554 15201526705 0014421 0 ustar 00 // std::time_get, std::time_put implementation, GNU version -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/time_members.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{locale}
*/
//
// ISO C++ 14882: 22.2.5.1.2 - time_get functions
// ISO C++ 14882: 22.2.5.3.2 - time_put functions
//
// Written by Benjamin Kosnik <bkoz@redhat.com>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _CharT>
__timepunct<_CharT>::__timepunct(size_t __refs)
: facet(__refs), _M_data(0), _M_c_locale_timepunct(0),
_M_name_timepunct(_S_get_c_name())
{ _M_initialize_timepunct(); }
template<typename _CharT>
__timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs)
: facet(__refs), _M_data(__cache), _M_c_locale_timepunct(0),
_M_name_timepunct(_S_get_c_name())
{ _M_initialize_timepunct(); }
template<typename _CharT>
__timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
size_t __refs)
: facet(__refs), _M_data(0), _M_c_locale_timepunct(0),
_M_name_timepunct(0)
{
if (__builtin_strcmp(__s, _S_get_c_name()) != 0)
{
const size_t __len = __builtin_strlen(__s) + 1;
char* __tmp = new char[__len];
__builtin_memcpy(__tmp, __s, __len);
_M_name_timepunct = __tmp;
}
else
_M_name_timepunct = _S_get_c_name();
__try
{ _M_initialize_timepunct(__cloc); }
__catch(...)
{
if (_M_name_timepunct != _S_get_c_name())
delete [] _M_name_timepunct;
__throw_exception_again;
}
}
template<typename _CharT>
__timepunct<_CharT>::~__timepunct()
{
if (_M_name_timepunct != _S_get_c_name())
delete [] _M_name_timepunct;
delete _M_data;
_S_destroy_c_locale(_M_c_locale_timepunct);
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
c++/8/x86_64-redhat-linux/bits/ctype_inline.h 0000644 00000004354 15201526705 0014430 0 ustar 00 // Locale support -*- C++ -*-
// Copyright (C) 2000-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/ctype_inline.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{locale}
*/
//
// ISO C++ 14882: 22.1 Locales
//
// ctype bits to be inlined go here. Non-inlinable (ie virtual do_*)
// functions go in ctype.cc
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
bool
ctype<char>::
is(mask __m, char __c) const
{ return _M_table[static_cast<unsigned char>(__c)] & __m; }
const char*
ctype<char>::
is(const char* __low, const char* __high, mask* __vec) const
{
while (__low < __high)
*__vec++ = _M_table[static_cast<unsigned char>(*__low++)];
return __high;
}
const char*
ctype<char>::
scan_is(mask __m, const char* __low, const char* __high) const
{
while (__low < __high
&& !(_M_table[static_cast<unsigned char>(*__low)] & __m))
++__low;
return __low;
}
const char*
ctype<char>::
scan_not(mask __m, const char* __low, const char* __high) const
{
while (__low < __high
&& (_M_table[static_cast<unsigned char>(*__low)] & __m) != 0)
++__low;
return __low;
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
c++/8/x86_64-redhat-linux/bits/gthr-single.h 0000644 00000015230 15201526705 0014164 0 ustar 00 /* Threads compatibility routines for libgcc2 and libobjc. */
/* Compile this one with gcc. */
/* Copyright (C) 1997-2018 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _GLIBCXX_GCC_GTHR_SINGLE_H
#define _GLIBCXX_GCC_GTHR_SINGLE_H
/* Just provide compatibility for mutex handling. */
typedef int __gthread_key_t;
typedef int __gthread_once_t;
typedef int __gthread_mutex_t;
typedef int __gthread_recursive_mutex_t;
#define __GTHREAD_ONCE_INIT 0
#define __GTHREAD_MUTEX_INIT 0
#define __GTHREAD_MUTEX_INIT_FUNCTION(mx) do {} while (0)
#define __GTHREAD_RECURSIVE_MUTEX_INIT 0
#define _GLIBCXX_UNUSED __attribute__((__unused__))
#ifdef _LIBOBJC
/* Thread local storage for a single thread */
static void *thread_local_storage = NULL;
/* Backend initialization functions */
/* Initialize the threads subsystem. */
static inline int
__gthread_objc_init_thread_system (void)
{
/* No thread support available */
return -1;
}
/* Close the threads subsystem. */
static inline int
__gthread_objc_close_thread_system (void)
{
/* No thread support available */
return -1;
}
/* Backend thread functions */
/* Create a new thread of execution. */
static inline objc_thread_t
__gthread_objc_thread_detach (void (* func)(void *), void * arg _GLIBCXX_UNUSED)
{
/* No thread support available */
return NULL;
}
/* Set the current thread's priority. */
static inline int
__gthread_objc_thread_set_priority (int priority _GLIBCXX_UNUSED)
{
/* No thread support available */
return -1;
}
/* Return the current thread's priority. */
static inline int
__gthread_objc_thread_get_priority (void)
{
return OBJC_THREAD_INTERACTIVE_PRIORITY;
}
/* Yield our process time to another thread. */
static inline void
__gthread_objc_thread_yield (void)
{
return;
}
/* Terminate the current thread. */
static inline int
__gthread_objc_thread_exit (void)
{
/* No thread support available */
/* Should we really exit the program */
/* exit (&__objc_thread_exit_status); */
return -1;
}
/* Returns an integer value which uniquely describes a thread. */
static inline objc_thread_t
__gthread_objc_thread_id (void)
{
/* No thread support, use 1. */
return (objc_thread_t) 1;
}
/* Sets the thread's local storage pointer. */
static inline int
__gthread_objc_thread_set_data (void *value)
{
thread_local_storage = value;
return 0;
}
/* Returns the thread's local storage pointer. */
static inline void *
__gthread_objc_thread_get_data (void)
{
return thread_local_storage;
}
/* Backend mutex functions */
/* Allocate a mutex. */
static inline int
__gthread_objc_mutex_allocate (objc_mutex_t mutex _GLIBCXX_UNUSED)
{
return 0;
}
/* Deallocate a mutex. */
static inline int
__gthread_objc_mutex_deallocate (objc_mutex_t mutex _GLIBCXX_UNUSED)
{
return 0;
}
/* Grab a lock on a mutex. */
static inline int
__gthread_objc_mutex_lock (objc_mutex_t mutex _GLIBCXX_UNUSED)
{
/* There can only be one thread, so we always get the lock */
return 0;
}
/* Try to grab a lock on a mutex. */
static inline int
__gthread_objc_mutex_trylock (objc_mutex_t mutex _GLIBCXX_UNUSED)
{
/* There can only be one thread, so we always get the lock */
return 0;
}
/* Unlock the mutex */
static inline int
__gthread_objc_mutex_unlock (objc_mutex_t mutex _GLIBCXX_UNUSED)
{
return 0;
}
/* Backend condition mutex functions */
/* Allocate a condition. */
static inline int
__gthread_objc_condition_allocate (objc_condition_t condition _GLIBCXX_UNUSED)
{
return 0;
}
/* Deallocate a condition. */
static inline int
__gthread_objc_condition_deallocate (objc_condition_t condition _GLIBCXX_UNUSED)
{
return 0;
}
/* Wait on the condition */
static inline int
__gthread_objc_condition_wait (objc_condition_t condition _GLIBCXX_UNUSED,
objc_mutex_t mutex _GLIBCXX_UNUSED)
{
return 0;
}
/* Wake up all threads waiting on this condition. */
static inline int
__gthread_objc_condition_broadcast (objc_condition_t condition _GLIBCXX_UNUSED)
{
return 0;
}
/* Wake up one thread waiting on this condition. */
static inline int
__gthread_objc_condition_signal (objc_condition_t condition _GLIBCXX_UNUSED)
{
return 0;
}
#else /* _LIBOBJC */
static inline int
__gthread_active_p (void)
{
return 0;
}
static inline int
__gthread_once (__gthread_once_t *__once _GLIBCXX_UNUSED, void (*__func) (void) _GLIBCXX_UNUSED)
{
return 0;
}
static inline int _GLIBCXX_UNUSED
__gthread_key_create (__gthread_key_t *__key _GLIBCXX_UNUSED, void (*__func) (void *) _GLIBCXX_UNUSED)
{
return 0;
}
static int _GLIBCXX_UNUSED
__gthread_key_delete (__gthread_key_t __key _GLIBCXX_UNUSED)
{
return 0;
}
static inline void *
__gthread_getspecific (__gthread_key_t __key _GLIBCXX_UNUSED)
{
return 0;
}
static inline int
__gthread_setspecific (__gthread_key_t __key _GLIBCXX_UNUSED, const void *__v _GLIBCXX_UNUSED)
{
return 0;
}
static inline int
__gthread_mutex_destroy (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
{
return 0;
}
static inline int
__gthread_mutex_lock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
{
return 0;
}
static inline int
__gthread_mutex_trylock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
{
return 0;
}
static inline int
__gthread_mutex_unlock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
{
return 0;
}
static inline int
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_lock (__mutex);
}
static inline int
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_trylock (__mutex);
}
static inline int
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_unlock (__mutex);
}
static inline int
__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_destroy (__mutex);
}
#endif /* _LIBOBJC */
#undef _GLIBCXX_UNUSED
#endif /* ! _GLIBCXX_GCC_GTHR_SINGLE_H */
c++/8/x86_64-redhat-linux/bits/c++allocator.h 0000644 00000003673 15201526705 0014222 0 ustar 00 // Base to std::allocator -*- C++ -*-
// Copyright (C) 2004-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/c++allocator.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{memory}
*/
#ifndef _GLIBCXX_CXX_ALLOCATOR_H
#define _GLIBCXX_CXX_ALLOCATOR_H 1
#include <ext/new_allocator.h>
#if __cplusplus >= 201103L
namespace std
{
/**
* @brief An alias to the base class for std::allocator.
* @ingroup allocators
*
* Used to set the std::allocator base class to
* __gnu_cxx::new_allocator.
*
* @tparam _Tp Type of allocated object.
*/
template<typename _Tp>
using __allocator_base = __gnu_cxx::new_allocator<_Tp>;
}
#else
// Define new_allocator as the base class to std::allocator.
# define __allocator_base __gnu_cxx::new_allocator
#endif
#if defined(__SANITIZE_ADDRESS__) && !defined(_GLIBCXX_SANITIZE_STD_ALLOCATOR)
# define _GLIBCXX_SANITIZE_STD_ALLOCATOR 1
#endif
#endif
c++/8/x86_64-redhat-linux/bits/ctype_base.h 0000644 00000004414 15201526705 0014061 0 ustar 00 // Locale support -*- C++ -*-
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/ctype_base.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{locale}
*/
//
// ISO C++ 14882: 22.1 Locales
//
// Information as gleaned from /usr/include/ctype.h
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/// @brief Base class for ctype.
struct ctype_base
{
// Non-standard typedefs.
typedef const int* __to_type;
// NB: Offsets into ctype<char>::_M_table force a particular size
// on the mask type. Because of this, we don't use an enum.
typedef unsigned short mask;
static const mask upper = _ISupper;
static const mask lower = _ISlower;
static const mask alpha = _ISalpha;
static const mask digit = _ISdigit;
static const mask xdigit = _ISxdigit;
static const mask space = _ISspace;
static const mask print = _ISprint;
static const mask graph = _ISalpha | _ISdigit | _ISpunct;
static const mask cntrl = _IScntrl;
static const mask punct = _ISpunct;
static const mask alnum = _ISalpha | _ISdigit;
#if __cplusplus >= 201103L
static const mask blank = _ISblank;
#endif
};
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
c++/8/x86_64-redhat-linux/bits/cxxabi_tweaks.h 0000644 00000004060 15201526705 0014574 0 ustar 00 // Control various target specific ABI tweaks. Generic version.
// Copyright (C) 2004-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/cxxabi_tweaks.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{cxxabi.h}
*/
#ifndef _CXXABI_TWEAKS_H
#define _CXXABI_TWEAKS_H 1
#ifdef __cplusplus
namespace __cxxabiv1
{
extern "C"
{
#endif
// The generic ABI uses the first byte of a 64-bit guard variable.
#define _GLIBCXX_GUARD_TEST(x) (*(char *) (x) != 0)
#define _GLIBCXX_GUARD_SET(x) *(char *) (x) = 1
#define _GLIBCXX_GUARD_BIT __guard_test_bit (0, 1)
#define _GLIBCXX_GUARD_PENDING_BIT __guard_test_bit (1, 1)
#define _GLIBCXX_GUARD_WAITING_BIT __guard_test_bit (2, 1)
__extension__ typedef int __guard __attribute__((mode (__DI__)));
// __cxa_vec_ctor has void return type.
typedef void __cxa_vec_ctor_return_type;
#define _GLIBCXX_CXA_VEC_CTOR_RETURN(x) return
// Constructors and destructors do not return a value.
typedef void __cxa_cdtor_return_type;
#ifdef __cplusplus
}
} // namespace __cxxabiv1
#endif
#endif
c++/8/x86_64-redhat-linux/bits/basic_file.h 0000644 00000006553 15201526705 0014031 0 ustar 00 // Wrapper of C-language FILE struct -*- C++ -*-
// Copyright (C) 2000-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 27.8 File-based streams
//
/** @file bits/basic_file.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{ios}
*/
#ifndef _GLIBCXX_BASIC_FILE_STDIO_H
#define _GLIBCXX_BASIC_FILE_STDIO_H 1
#pragma GCC system_header
#include <bits/c++config.h>
#include <bits/c++io.h> // for __c_lock and __c_file
#include <bits/move.h> // for swap
#include <ios>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Generic declaration.
template<typename _CharT>
class __basic_file;
// Specialization.
template<>
class __basic_file<char>
{
// Underlying data source/sink.
__c_file* _M_cfile;
// True iff we opened _M_cfile, and thus must close it ourselves.
bool _M_cfile_created;
public:
__basic_file(__c_lock* __lock = 0) throw ();
#if __cplusplus >= 201103L
__basic_file(__basic_file&& __rv, __c_lock* = 0) noexcept
: _M_cfile(__rv._M_cfile), _M_cfile_created(__rv._M_cfile_created)
{
__rv._M_cfile = nullptr;
__rv._M_cfile_created = false;
}
__basic_file& operator=(const __basic_file&) = delete;
__basic_file& operator=(__basic_file&&) = delete;
void
swap(__basic_file& __f) noexcept
{
std::swap(_M_cfile, __f._M_cfile);
std::swap(_M_cfile_created, __f._M_cfile_created);
}
#endif
__basic_file*
open(const char* __name, ios_base::openmode __mode, int __prot = 0664);
__basic_file*
sys_open(__c_file* __file, ios_base::openmode);
__basic_file*
sys_open(int __fd, ios_base::openmode __mode) throw ();
__basic_file*
close();
_GLIBCXX_PURE bool
is_open() const throw ();
_GLIBCXX_PURE int
fd() throw ();
_GLIBCXX_PURE __c_file*
file() throw ();
~__basic_file();
streamsize
xsputn(const char* __s, streamsize __n);
streamsize
xsputn_2(const char* __s1, streamsize __n1,
const char* __s2, streamsize __n2);
streamsize
xsgetn(char* __s, streamsize __n);
streamoff
seekoff(streamoff __off, ios_base::seekdir __way) throw ();
int
sync();
streamsize
showmanyc();
};
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/x86_64-redhat-linux/bits/os_defines.h 0000644 00000003727 15201526705 0014067 0 ustar 00 // Specific definitions for GNU/Linux -*- C++ -*-
// Copyright (C) 2000-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/os_defines.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{iosfwd}
*/
#ifndef _GLIBCXX_OS_DEFINES
#define _GLIBCXX_OS_DEFINES 1
// System-specific #define, typedefs, corrections, etc, go here. This
// file will come before all others.
// This keeps isanum, et al from being propagated as macros.
#define __NO_CTYPE 1
#include <features.h>
// Provide a declaration for the possibly deprecated gets function, as
// glibc 2.15 and later does not declare gets for ISO C11 when
// __GNU_SOURCE is defined.
#if __GLIBC_PREREQ(2,15) && defined(_GNU_SOURCE)
# undef _GLIBCXX_HAVE_GETS
#endif
// Glibc 2.23 removed the obsolete isinf and isnan declarations. Check the
// version dynamically in case it has changed since libstdc++ was configured.
#define _GLIBCXX_NO_OBSOLETE_ISINF_ISNAN_DYNAMIC __GLIBC_PREREQ(2,23)
#endif
c++/8/x86_64-redhat-linux/bits/stdtr1c++.h 0000644 00000003315 15201526705 0013454 0 ustar 00 // C++ includes used for precompiling TR1 -*- C++ -*-
// Copyright (C) 2006-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file stdtr1c++.h
* This is an implementation file for a precompiled header.
*/
#include <bits/stdc++.h>
#include <tr1/array>
#include <tr1/cctype>
#include <tr1/cfenv>
#include <tr1/cfloat>
#include <tr1/cinttypes>
#include <tr1/climits>
#include <tr1/cmath>
#include <tr1/complex>
#include <tr1/cstdarg>
#include <tr1/cstdbool>
#include <tr1/cstdint>
#include <tr1/cstdio>
#include <tr1/cstdlib>
#include <tr1/ctgmath>
#include <tr1/ctime>
#include <tr1/cwchar>
#include <tr1/cwctype>
#include <tr1/functional>
#include <tr1/random>
#include <tr1/tuple>
#include <tr1/unordered_map>
#include <tr1/unordered_set>
#include <tr1/utility>
c++/8/x86_64-redhat-linux/bits/extc++.h 0000644 00000005145 15201526705 0013036 0 ustar 00 // C++ includes used for precompiling extensions -*- C++ -*-
// Copyright (C) 2006-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file extc++.h
* This is an implementation file for a precompiled header.
*/
#if __cplusplus < 201103L
#include <bits/stdtr1c++.h>
#else
#include <bits/stdc++.h>
#endif
#include <ext/algorithm>
#if __cplusplus >= 201103L
# include <ext/aligned_buffer.h>
#endif
#include <ext/alloc_traits.h>
#include <ext/array_allocator.h>
#include <ext/atomicity.h>
#include <ext/bitmap_allocator.h>
#include <ext/cast.h>
#if __cplusplus >= 201103L
# include <ext/cmath>
#endif
#include <ext/concurrence.h>
#include <ext/debug_allocator.h>
#include <ext/extptr_allocator.h>
#include <ext/functional>
#include <ext/iterator>
#include <ext/malloc_allocator.h>
#include <ext/memory>
#include <ext/mt_allocator.h>
#include <ext/new_allocator.h>
#include <ext/numeric>
#include <ext/numeric_traits.h>
#include <ext/pod_char_traits.h>
#include <ext/pointer.h>
#include <ext/pool_allocator.h>
#if __cplusplus >= 201103L
# include <ext/random>
#endif
#include <ext/rb_tree>
#include <ext/rope>
#include <ext/slist>
#include <ext/stdio_filebuf.h>
#include <ext/stdio_sync_filebuf.h>
#include <ext/throw_allocator.h>
#include <ext/typelist.h>
#include <ext/type_traits.h>
#include <ext/vstring.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include <ext/pb_ds/exception.hpp>
#include <ext/pb_ds/hash_policy.hpp>
#include <ext/pb_ds/list_update_policy.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#ifdef _GLIBCXX_HAVE_ICONV
#include <ext/codecvt_specializations.h>
#include <ext/enc_filebuf.h>
#endif
c++/8/x86_64-redhat-linux/bits/c++config.h 0000644 00000341407 15201526705 0013507 0 ustar 00 #ifndef _CPP_CPPCONFIG_WRAPPER
#define _CPP_CPPCONFIG_WRAPPER 1
#include <bits/wordsize.h>
#if __WORDSIZE == 32
// Predefined symbols and macros -*- C++ -*-
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/c++config.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{iosfwd}
*/
#ifndef _GLIBCXX_CXX_CONFIG_H
#define _GLIBCXX_CXX_CONFIG_H 1
// The major release number for the GCC release the C++ library belongs to.
#define _GLIBCXX_RELEASE 8
// The datestamp of the C++ library in compressed ISO date format.
#define __GLIBCXX__ 20210514
// Macros for various attributes.
// _GLIBCXX_PURE
// _GLIBCXX_CONST
// _GLIBCXX_NORETURN
// _GLIBCXX_NOTHROW
// _GLIBCXX_VISIBILITY
#ifndef _GLIBCXX_PURE
# define _GLIBCXX_PURE __attribute__ ((__pure__))
#endif
#ifndef _GLIBCXX_CONST
# define _GLIBCXX_CONST __attribute__ ((__const__))
#endif
#ifndef _GLIBCXX_NORETURN
# define _GLIBCXX_NORETURN __attribute__ ((__noreturn__))
#endif
// See below for C++
#ifndef _GLIBCXX_NOTHROW
# ifndef __cplusplus
# define _GLIBCXX_NOTHROW __attribute__((__nothrow__))
# endif
#endif
// Macros for visibility attributes.
// _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY
// _GLIBCXX_VISIBILITY
# define _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY 1
#if _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY
# define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ (#V)))
#else
// If this is not supplied by the OS-specific or CPU-specific
// headers included below, it will be defined to an empty default.
# define _GLIBCXX_VISIBILITY(V) _GLIBCXX_PSEUDO_VISIBILITY(V)
#endif
// Macros for deprecated attributes.
// _GLIBCXX_USE_DEPRECATED
// _GLIBCXX_DEPRECATED
// _GLIBCXX17_DEPRECATED
#ifndef _GLIBCXX_USE_DEPRECATED
# define _GLIBCXX_USE_DEPRECATED 1
#endif
#if defined(__DEPRECATED) && (__cplusplus >= 201103L)
# define _GLIBCXX_DEPRECATED __attribute__ ((__deprecated__))
#else
# define _GLIBCXX_DEPRECATED
#endif
#if defined(__DEPRECATED) && (__cplusplus >= 201703L)
# define _GLIBCXX17_DEPRECATED [[__deprecated__]]
#else
# define _GLIBCXX17_DEPRECATED
#endif
// Macros for ABI tag attributes.
#ifndef _GLIBCXX_ABI_TAG_CXX11
# define _GLIBCXX_ABI_TAG_CXX11 __attribute ((__abi_tag__ ("cxx11")))
#endif
// Macro to warn about unused results.
#if __cplusplus >= 201703L
# define _GLIBCXX_NODISCARD [[__nodiscard__]]
#else
# define _GLIBCXX_NODISCARD
#endif
#if __cplusplus
// Macro for constexpr, to support in mixed 03/0x mode.
#ifndef _GLIBCXX_CONSTEXPR
# if __cplusplus >= 201103L
# define _GLIBCXX_CONSTEXPR constexpr
# define _GLIBCXX_USE_CONSTEXPR constexpr
# else
# define _GLIBCXX_CONSTEXPR
# define _GLIBCXX_USE_CONSTEXPR const
# endif
#endif
#ifndef _GLIBCXX14_CONSTEXPR
# if __cplusplus >= 201402L
# define _GLIBCXX14_CONSTEXPR constexpr
# else
# define _GLIBCXX14_CONSTEXPR
# endif
#endif
#ifndef _GLIBCXX17_CONSTEXPR
# if __cplusplus > 201402L
# define _GLIBCXX17_CONSTEXPR constexpr
# else
# define _GLIBCXX17_CONSTEXPR
# endif
#endif
#ifndef _GLIBCXX17_INLINE
# if __cplusplus > 201402L
# define _GLIBCXX17_INLINE inline
# else
# define _GLIBCXX17_INLINE
# endif
#endif
// Macro for noexcept, to support in mixed 03/0x mode.
#ifndef _GLIBCXX_NOEXCEPT
# if __cplusplus >= 201103L
# define _GLIBCXX_NOEXCEPT noexcept
# define _GLIBCXX_NOEXCEPT_IF(_COND) noexcept(_COND)
# define _GLIBCXX_USE_NOEXCEPT noexcept
# define _GLIBCXX_THROW(_EXC)
# else
# define _GLIBCXX_NOEXCEPT
# define _GLIBCXX_NOEXCEPT_IF(_COND)
# define _GLIBCXX_USE_NOEXCEPT throw()
# define _GLIBCXX_THROW(_EXC) throw(_EXC)
# endif
#endif
#ifndef _GLIBCXX_NOTHROW
# define _GLIBCXX_NOTHROW _GLIBCXX_USE_NOEXCEPT
#endif
#ifndef _GLIBCXX_THROW_OR_ABORT
# if __cpp_exceptions
# define _GLIBCXX_THROW_OR_ABORT(_EXC) (throw (_EXC))
# else
# define _GLIBCXX_THROW_OR_ABORT(_EXC) (__builtin_abort())
# endif
#endif
#if __cpp_noexcept_function_type
#define _GLIBCXX_NOEXCEPT_PARM , bool _NE
#define _GLIBCXX_NOEXCEPT_QUAL noexcept (_NE)
#else
#define _GLIBCXX_NOEXCEPT_PARM
#define _GLIBCXX_NOEXCEPT_QUAL
#endif
// Macro for extern template, ie controlling template linkage via use
// of extern keyword on template declaration. As documented in the g++
// manual, it inhibits all implicit instantiations and is used
// throughout the library to avoid multiple weak definitions for
// required types that are already explicitly instantiated in the
// library binary. This substantially reduces the binary size of
// resulting executables.
// Special case: _GLIBCXX_EXTERN_TEMPLATE == -1 disallows extern
// templates only in basic_string, thus activating its debug-mode
// checks even at -O0.
# define _GLIBCXX_EXTERN_TEMPLATE 1
/*
Outline of libstdc++ namespaces.
namespace std
{
namespace __debug { }
namespace __parallel { }
namespace __profile { }
namespace __cxx1998 { }
namespace __detail {
namespace __variant { } // C++17
}
namespace rel_ops { }
namespace tr1
{
namespace placeholders { }
namespace regex_constants { }
namespace __detail { }
}
namespace tr2 { }
namespace decimal { }
namespace chrono { } // C++11
namespace placeholders { } // C++11
namespace regex_constants { } // C++11
namespace this_thread { } // C++11
inline namespace literals { // C++14
inline namespace chrono_literals { } // C++14
inline namespace complex_literals { } // C++14
inline namespace string_literals { } // C++14
inline namespace string_view_literals { } // C++17
}
}
namespace abi { }
namespace __gnu_cxx
{
namespace __detail { }
}
For full details see:
http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/namespaces.html
*/
namespace std
{
typedef __SIZE_TYPE__ size_t;
typedef __PTRDIFF_TYPE__ ptrdiff_t;
#if __cplusplus >= 201103L
typedef decltype(nullptr) nullptr_t;
#endif
}
# define _GLIBCXX_USE_DUAL_ABI 1
#if ! _GLIBCXX_USE_DUAL_ABI
// Ignore any pre-defined value of _GLIBCXX_USE_CXX11_ABI
# undef _GLIBCXX_USE_CXX11_ABI
#endif
#ifndef _GLIBCXX_USE_CXX11_ABI
# define _GLIBCXX_USE_CXX11_ABI 1
#endif
#if _GLIBCXX_USE_CXX11_ABI
namespace std
{
inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
}
namespace __gnu_cxx
{
inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
}
# define _GLIBCXX_NAMESPACE_CXX11 __cxx11::
# define _GLIBCXX_BEGIN_NAMESPACE_CXX11 namespace __cxx11 {
# define _GLIBCXX_END_NAMESPACE_CXX11 }
# define _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_ABI_TAG_CXX11
#else
# define _GLIBCXX_NAMESPACE_CXX11
# define _GLIBCXX_BEGIN_NAMESPACE_CXX11
# define _GLIBCXX_END_NAMESPACE_CXX11
# define _GLIBCXX_DEFAULT_ABI_TAG
#endif
// Defined if inline namespaces are used for versioning.
# define _GLIBCXX_INLINE_VERSION 0
// Inline namespace for symbol versioning.
#if _GLIBCXX_INLINE_VERSION
# define _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace __8 {
# define _GLIBCXX_END_NAMESPACE_VERSION }
namespace std
{
inline _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __cplusplus >= 201402L
inline namespace literals {
inline namespace chrono_literals { }
inline namespace complex_literals { }
inline namespace string_literals { }
#if __cplusplus > 201402L
inline namespace string_view_literals { }
#endif // C++17
}
#endif // C++14
_GLIBCXX_END_NAMESPACE_VERSION
}
namespace __gnu_cxx
{
inline _GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_END_NAMESPACE_VERSION
}
#else
# define _GLIBCXX_BEGIN_NAMESPACE_VERSION
# define _GLIBCXX_END_NAMESPACE_VERSION
#endif
// Inline namespaces for special modes: debug, parallel, profile.
#if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PARALLEL) \
|| defined(_GLIBCXX_PROFILE)
namespace std
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Non-inline namespace for components replaced by alternates in active mode.
namespace __cxx1998
{
# if _GLIBCXX_USE_CXX11_ABI
inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
# endif
}
_GLIBCXX_END_NAMESPACE_VERSION
// Inline namespace for debug mode.
# ifdef _GLIBCXX_DEBUG
inline namespace __debug { }
# endif
// Inline namespaces for parallel mode.
# ifdef _GLIBCXX_PARALLEL
inline namespace __parallel { }
# endif
// Inline namespaces for profile mode
# ifdef _GLIBCXX_PROFILE
inline namespace __profile { }
# endif
}
// Check for invalid usage and unsupported mixed-mode use.
# if defined(_GLIBCXX_DEBUG) && defined(_GLIBCXX_PARALLEL)
# error illegal use of multiple inlined namespaces
# endif
# if defined(_GLIBCXX_PROFILE) && defined(_GLIBCXX_DEBUG)
# error illegal use of multiple inlined namespaces
# endif
# if defined(_GLIBCXX_PROFILE) && defined(_GLIBCXX_PARALLEL)
# error illegal use of multiple inlined namespaces
# endif
// Check for invalid use due to lack for weak symbols.
# if __NO_INLINE__ && !__GXX_WEAK__
# warning currently using inlined namespace mode which may fail \
without inlining due to lack of weak symbols
# endif
#endif
// Macros for namespace scope. Either namespace std:: or the name
// of some nested namespace within it corresponding to the active mode.
// _GLIBCXX_STD_A
// _GLIBCXX_STD_C
//
// Macros for opening/closing conditional namespaces.
// _GLIBCXX_BEGIN_NAMESPACE_ALGO
// _GLIBCXX_END_NAMESPACE_ALGO
// _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// _GLIBCXX_END_NAMESPACE_CONTAINER
#if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PROFILE)
# define _GLIBCXX_STD_C __cxx1998
# define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER \
namespace _GLIBCXX_STD_C {
# define _GLIBCXX_END_NAMESPACE_CONTAINER }
#else
# define _GLIBCXX_STD_C std
# define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
# define _GLIBCXX_END_NAMESPACE_CONTAINER
#endif
#ifdef _GLIBCXX_PARALLEL
# define _GLIBCXX_STD_A __cxx1998
# define _GLIBCXX_BEGIN_NAMESPACE_ALGO \
namespace _GLIBCXX_STD_A {
# define _GLIBCXX_END_NAMESPACE_ALGO }
#else
# define _GLIBCXX_STD_A std
# define _GLIBCXX_BEGIN_NAMESPACE_ALGO
# define _GLIBCXX_END_NAMESPACE_ALGO
#endif
// GLIBCXX_ABI Deprecated
// Define if compatibility should be provided for -mlong-double-64.
#undef _GLIBCXX_LONG_DOUBLE_COMPAT
// Inline namespace for long double 128 mode.
#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
namespace std
{
inline namespace __gnu_cxx_ldbl128 { }
}
# define _GLIBCXX_NAMESPACE_LDBL __gnu_cxx_ldbl128::
# define _GLIBCXX_BEGIN_NAMESPACE_LDBL namespace __gnu_cxx_ldbl128 {
# define _GLIBCXX_END_NAMESPACE_LDBL }
#else
# define _GLIBCXX_NAMESPACE_LDBL
# define _GLIBCXX_BEGIN_NAMESPACE_LDBL
# define _GLIBCXX_END_NAMESPACE_LDBL
#endif
#if _GLIBCXX_USE_CXX11_ABI
# define _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_NAMESPACE_CXX11
# define _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_BEGIN_NAMESPACE_CXX11
# define _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_END_NAMESPACE_CXX11
#else
# define _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_NAMESPACE_LDBL
# define _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_BEGIN_NAMESPACE_LDBL
# define _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_END_NAMESPACE_LDBL
#endif
// Debug Mode implies checking assertions.
#if defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_ASSERTIONS)
# define _GLIBCXX_ASSERTIONS 1
#endif
// Disable std::string explicit instantiation declarations in order to assert.
#ifdef _GLIBCXX_ASSERTIONS
# undef _GLIBCXX_EXTERN_TEMPLATE
# define _GLIBCXX_EXTERN_TEMPLATE -1
#endif
// Assert.
#if defined(_GLIBCXX_ASSERTIONS) \
|| defined(_GLIBCXX_PARALLEL) || defined(_GLIBCXX_PARALLEL_ASSERTIONS)
namespace std
{
// Avoid the use of assert, because we're trying to keep the <cassert>
// include out of the mix.
inline void
__replacement_assert(const char* __file, int __line,
const char* __function, const char* __condition)
{
__builtin_printf("%s:%d: %s: Assertion '%s' failed.\n", __file, __line,
__function, __condition);
__builtin_abort();
}
}
#define __glibcxx_assert_impl(_Condition) \
do \
{ \
if (! (_Condition)) \
std::__replacement_assert(__FILE__, __LINE__, __PRETTY_FUNCTION__, \
#_Condition); \
} while (false)
#endif
#if defined(_GLIBCXX_ASSERTIONS)
# define __glibcxx_assert(_Condition) __glibcxx_assert_impl(_Condition)
#else
# define __glibcxx_assert(_Condition)
#endif
// Macros for race detectors.
// _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) and
// _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) should be used to explain
// atomic (lock-free) synchronization to race detectors:
// the race detector will infer a happens-before arc from the former to the
// latter when they share the same argument pointer.
//
// The most frequent use case for these macros (and the only case in the
// current implementation of the library) is atomic reference counting:
// void _M_remove_reference()
// {
// _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
// if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount, -1) <= 0)
// {
// _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
// _M_destroy(__a);
// }
// }
// The annotations in this example tell the race detector that all memory
// accesses occurred when the refcount was positive do not race with
// memory accesses which occurred after the refcount became zero.
#ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE
# define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A)
#endif
#ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER
# define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A)
#endif
// Macros for C linkage: define extern "C" linkage only when using C++.
# define _GLIBCXX_BEGIN_EXTERN_C extern "C" {
# define _GLIBCXX_END_EXTERN_C }
# define _GLIBCXX_USE_ALLOCATOR_NEW 1
#else // !__cplusplus
# define _GLIBCXX_BEGIN_EXTERN_C
# define _GLIBCXX_END_EXTERN_C
#endif
// First includes.
// Pick up any OS-specific definitions.
#include <bits/os_defines.h>
// Pick up any CPU-specific definitions.
#include <bits/cpu_defines.h>
// If platform uses neither visibility nor psuedo-visibility,
// specify empty default for namespace annotation macros.
#ifndef _GLIBCXX_PSEUDO_VISIBILITY
# define _GLIBCXX_PSEUDO_VISIBILITY(V)
#endif
// Certain function definitions that are meant to be overridable from
// user code are decorated with this macro. For some targets, this
// macro causes these definitions to be weak.
#ifndef _GLIBCXX_WEAK_DEFINITION
# define _GLIBCXX_WEAK_DEFINITION
#endif
// By default, we assume that __GXX_WEAK__ also means that there is support
// for declaring functions as weak while not defining such functions. This
// allows for referring to functions provided by other libraries (e.g.,
// libitm) without depending on them if the respective features are not used.
#ifndef _GLIBCXX_USE_WEAK_REF
# define _GLIBCXX_USE_WEAK_REF __GXX_WEAK__
#endif
// Conditionally enable annotations for the Transactional Memory TS on C++11.
// Most of the following conditions are due to limitations in the current
// implementation.
#if __cplusplus >= 201103L && _GLIBCXX_USE_CXX11_ABI \
&& _GLIBCXX_USE_DUAL_ABI && __cpp_transactional_memory >= 201505L \
&& !_GLIBCXX_FULLY_DYNAMIC_STRING && _GLIBCXX_USE_WEAK_REF \
&& _GLIBCXX_USE_ALLOCATOR_NEW
#define _GLIBCXX_TXN_SAFE transaction_safe
#define _GLIBCXX_TXN_SAFE_DYN transaction_safe_dynamic
#else
#define _GLIBCXX_TXN_SAFE
#define _GLIBCXX_TXN_SAFE_DYN
#endif
#if __cplusplus > 201402L
// In C++17 mathematical special functions are in namespace std.
# define _GLIBCXX_USE_STD_SPEC_FUNCS 1
#elif __cplusplus >= 201103L && __STDCPP_WANT_MATH_SPEC_FUNCS__ != 0
// For C++11 and C++14 they are in namespace std when requested.
# define _GLIBCXX_USE_STD_SPEC_FUNCS 1
#endif
// The remainder of the prewritten config is automatic; all the
// user hooks are listed above.
// Create a boolean flag to be used to determine if --fast-math is set.
#ifdef __FAST_MATH__
# define _GLIBCXX_FAST_MATH 1
#else
# define _GLIBCXX_FAST_MATH 0
#endif
// This marks string literals in header files to be extracted for eventual
// translation. It is primarily used for messages in thrown exceptions; see
// src/functexcept.cc. We use __N because the more traditional _N is used
// for something else under certain OSes (see BADNAMES).
#define __N(msgid) (msgid)
// For example, <windows.h> is known to #define min and max as macros...
#undef min
#undef max
// N.B. these _GLIBCXX_USE_C99_XXX macros are defined unconditionally
// so they should be tested with #if not with #ifdef.
#if __cplusplus >= 201103L
# ifndef _GLIBCXX_USE_C99_MATH
# define _GLIBCXX_USE_C99_MATH _GLIBCXX11_USE_C99_MATH
# endif
# ifndef _GLIBCXX_USE_C99_COMPLEX
# define _GLIBCXX_USE_C99_COMPLEX _GLIBCXX11_USE_C99_COMPLEX
# endif
# ifndef _GLIBCXX_USE_C99_STDIO
# define _GLIBCXX_USE_C99_STDIO _GLIBCXX11_USE_C99_STDIO
# endif
# ifndef _GLIBCXX_USE_C99_STDLIB
# define _GLIBCXX_USE_C99_STDLIB _GLIBCXX11_USE_C99_STDLIB
# endif
# ifndef _GLIBCXX_USE_C99_WCHAR
# define _GLIBCXX_USE_C99_WCHAR _GLIBCXX11_USE_C99_WCHAR
# endif
#else
# ifndef _GLIBCXX_USE_C99_MATH
# define _GLIBCXX_USE_C99_MATH _GLIBCXX98_USE_C99_MATH
# endif
# ifndef _GLIBCXX_USE_C99_COMPLEX
# define _GLIBCXX_USE_C99_COMPLEX _GLIBCXX98_USE_C99_COMPLEX
# endif
# ifndef _GLIBCXX_USE_C99_STDIO
# define _GLIBCXX_USE_C99_STDIO _GLIBCXX98_USE_C99_STDIO
# endif
# ifndef _GLIBCXX_USE_C99_STDLIB
# define _GLIBCXX_USE_C99_STDLIB _GLIBCXX98_USE_C99_STDLIB
# endif
# ifndef _GLIBCXX_USE_C99_WCHAR
# define _GLIBCXX_USE_C99_WCHAR _GLIBCXX98_USE_C99_WCHAR
# endif
#endif
/* Define if __float128 is supported on this host. */
#if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
#define _GLIBCXX_USE_FLOAT128 1
#endif
// End of prewritten config; the settings discovered at configure time follow.
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the `acosf' function. */
#define _GLIBCXX_HAVE_ACOSF 1
/* Define to 1 if you have the `acosl' function. */
#define _GLIBCXX_HAVE_ACOSL 1
/* Define to 1 if you have the `aligned_alloc' function. */
#define _GLIBCXX_HAVE_ALIGNED_ALLOC 1
/* Define to 1 if you have the `asinf' function. */
#define _GLIBCXX_HAVE_ASINF 1
/* Define to 1 if you have the `asinl' function. */
#define _GLIBCXX_HAVE_ASINL 1
/* Define to 1 if the target assembler supports .symver directive. */
#define _GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE 1
/* Define to 1 if you have the `atan2f' function. */
#define _GLIBCXX_HAVE_ATAN2F 1
/* Define to 1 if you have the `atan2l' function. */
#define _GLIBCXX_HAVE_ATAN2L 1
/* Define to 1 if you have the `atanf' function. */
#define _GLIBCXX_HAVE_ATANF 1
/* Define to 1 if you have the `atanl' function. */
#define _GLIBCXX_HAVE_ATANL 1
/* Define to 1 if you have the `at_quick_exit' function. */
#define _GLIBCXX_HAVE_AT_QUICK_EXIT 1
/* Define to 1 if the target assembler supports thread-local storage. */
/* #undef _GLIBCXX_HAVE_CC_TLS */
/* Define to 1 if you have the `ceilf' function. */
#define _GLIBCXX_HAVE_CEILF 1
/* Define to 1 if you have the `ceill' function. */
#define _GLIBCXX_HAVE_CEILL 1
/* Define to 1 if you have the <complex.h> header file. */
#define _GLIBCXX_HAVE_COMPLEX_H 1
/* Define to 1 if you have the `cosf' function. */
#define _GLIBCXX_HAVE_COSF 1
/* Define to 1 if you have the `coshf' function. */
#define _GLIBCXX_HAVE_COSHF 1
/* Define to 1 if you have the `coshl' function. */
#define _GLIBCXX_HAVE_COSHL 1
/* Define to 1 if you have the `cosl' function. */
#define _GLIBCXX_HAVE_COSL 1
/* Define to 1 if you have the <dirent.h> header file. */
#define _GLIBCXX_HAVE_DIRENT_H 1
/* Define to 1 if you have the <dlfcn.h> header file. */
#define _GLIBCXX_HAVE_DLFCN_H 1
/* Define if EBADMSG exists. */
#define _GLIBCXX_HAVE_EBADMSG 1
/* Define if ECANCELED exists. */
#define _GLIBCXX_HAVE_ECANCELED 1
/* Define if ECHILD exists. */
#define _GLIBCXX_HAVE_ECHILD 1
/* Define if EIDRM exists. */
#define _GLIBCXX_HAVE_EIDRM 1
/* Define to 1 if you have the <endian.h> header file. */
#define _GLIBCXX_HAVE_ENDIAN_H 1
/* Define if ENODATA exists. */
#define _GLIBCXX_HAVE_ENODATA 1
/* Define if ENOLINK exists. */
#define _GLIBCXX_HAVE_ENOLINK 1
/* Define if ENOSPC exists. */
#define _GLIBCXX_HAVE_ENOSPC 1
/* Define if ENOSR exists. */
#define _GLIBCXX_HAVE_ENOSR 1
/* Define if ENOSTR exists. */
#define _GLIBCXX_HAVE_ENOSTR 1
/* Define if ENOTRECOVERABLE exists. */
#define _GLIBCXX_HAVE_ENOTRECOVERABLE 1
/* Define if ENOTSUP exists. */
#define _GLIBCXX_HAVE_ENOTSUP 1
/* Define if EOVERFLOW exists. */
#define _GLIBCXX_HAVE_EOVERFLOW 1
/* Define if EOWNERDEAD exists. */
#define _GLIBCXX_HAVE_EOWNERDEAD 1
/* Define if EPERM exists. */
#define _GLIBCXX_HAVE_EPERM 1
/* Define if EPROTO exists. */
#define _GLIBCXX_HAVE_EPROTO 1
/* Define if ETIME exists. */
#define _GLIBCXX_HAVE_ETIME 1
/* Define if ETIMEDOUT exists. */
#define _GLIBCXX_HAVE_ETIMEDOUT 1
/* Define if ETXTBSY exists. */
#define _GLIBCXX_HAVE_ETXTBSY 1
/* Define if EWOULDBLOCK exists. */
#define _GLIBCXX_HAVE_EWOULDBLOCK 1
/* Define to 1 if GCC 4.6 supported std::exception_ptr for the target */
#define _GLIBCXX_HAVE_EXCEPTION_PTR_SINCE_GCC46 1
/* Define to 1 if you have the <execinfo.h> header file. */
#define _GLIBCXX_HAVE_EXECINFO_H 1
/* Define to 1 if you have the `expf' function. */
#define _GLIBCXX_HAVE_EXPF 1
/* Define to 1 if you have the `expl' function. */
#define _GLIBCXX_HAVE_EXPL 1
/* Define to 1 if you have the `fabsf' function. */
#define _GLIBCXX_HAVE_FABSF 1
/* Define to 1 if you have the `fabsl' function. */
#define _GLIBCXX_HAVE_FABSL 1
/* Define to 1 if you have the <fcntl.h> header file. */
#define _GLIBCXX_HAVE_FCNTL_H 1
/* Define to 1 if you have the <fenv.h> header file. */
#define _GLIBCXX_HAVE_FENV_H 1
/* Define to 1 if you have the `finite' function. */
#define _GLIBCXX_HAVE_FINITE 1
/* Define to 1 if you have the `finitef' function. */
#define _GLIBCXX_HAVE_FINITEF 1
/* Define to 1 if you have the `finitel' function. */
#define _GLIBCXX_HAVE_FINITEL 1
/* Define to 1 if you have the <float.h> header file. */
#define _GLIBCXX_HAVE_FLOAT_H 1
/* Define to 1 if you have the `floorf' function. */
#define _GLIBCXX_HAVE_FLOORF 1
/* Define to 1 if you have the `floorl' function. */
#define _GLIBCXX_HAVE_FLOORL 1
/* Define to 1 if you have the `fmodf' function. */
#define _GLIBCXX_HAVE_FMODF 1
/* Define to 1 if you have the `fmodl' function. */
#define _GLIBCXX_HAVE_FMODL 1
/* Define to 1 if you have the `fpclass' function. */
/* #undef _GLIBCXX_HAVE_FPCLASS */
/* Define to 1 if you have the <fp.h> header file. */
/* #undef _GLIBCXX_HAVE_FP_H */
/* Define to 1 if you have the `frexpf' function. */
#define _GLIBCXX_HAVE_FREXPF 1
/* Define to 1 if you have the `frexpl' function. */
#define _GLIBCXX_HAVE_FREXPL 1
/* Define if _Unwind_GetIPInfo is available. */
#define _GLIBCXX_HAVE_GETIPINFO 1
/* Define if gets is available in <stdio.h> before C++14. */
#define _GLIBCXX_HAVE_GETS 1
/* Define to 1 if you have the `hypot' function. */
#define _GLIBCXX_HAVE_HYPOT 1
/* Define to 1 if you have the `hypotf' function. */
#define _GLIBCXX_HAVE_HYPOTF 1
/* Define to 1 if you have the `hypotl' function. */
#define _GLIBCXX_HAVE_HYPOTL 1
/* Define if you have the iconv() function. */
#define _GLIBCXX_HAVE_ICONV 1
/* Define to 1 if you have the <ieeefp.h> header file. */
/* #undef _GLIBCXX_HAVE_IEEEFP_H */
/* Define if int64_t is available in <stdint.h>. */
#define _GLIBCXX_HAVE_INT64_T 1
/* Define if int64_t is a long. */
/* #undef _GLIBCXX_HAVE_INT64_T_LONG */
/* Define if int64_t is a long long. */
#define _GLIBCXX_HAVE_INT64_T_LONG_LONG 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define _GLIBCXX_HAVE_INTTYPES_H 1
/* Define to 1 if you have the `isinf' function. */
/* #undef _GLIBCXX_HAVE_ISINF */
/* Define to 1 if you have the `isinff' function. */
#define _GLIBCXX_HAVE_ISINFF 1
/* Define to 1 if you have the `isinfl' function. */
#define _GLIBCXX_HAVE_ISINFL 1
/* Define to 1 if you have the `isnan' function. */
/* #undef _GLIBCXX_HAVE_ISNAN */
/* Define to 1 if you have the `isnanf' function. */
#define _GLIBCXX_HAVE_ISNANF 1
/* Define to 1 if you have the `isnanl' function. */
#define _GLIBCXX_HAVE_ISNANL 1
/* Defined if iswblank exists. */
#define _GLIBCXX_HAVE_ISWBLANK 1
/* Define if LC_MESSAGES is available in <locale.h>. */
#define _GLIBCXX_HAVE_LC_MESSAGES 1
/* Define to 1 if you have the `ldexpf' function. */
#define _GLIBCXX_HAVE_LDEXPF 1
/* Define to 1 if you have the `ldexpl' function. */
#define _GLIBCXX_HAVE_LDEXPL 1
/* Define to 1 if you have the <libintl.h> header file. */
#define _GLIBCXX_HAVE_LIBINTL_H 1
/* Only used in build directory testsuite_hooks.h. */
#define _GLIBCXX_HAVE_LIMIT_AS 1
/* Only used in build directory testsuite_hooks.h. */
#define _GLIBCXX_HAVE_LIMIT_DATA 1
/* Only used in build directory testsuite_hooks.h. */
#define _GLIBCXX_HAVE_LIMIT_FSIZE 1
/* Only used in build directory testsuite_hooks.h. */
#define _GLIBCXX_HAVE_LIMIT_RSS 1
/* Only used in build directory testsuite_hooks.h. */
#define _GLIBCXX_HAVE_LIMIT_VMEM 0
/* Define if futex syscall is available. */
#define _GLIBCXX_HAVE_LINUX_FUTEX 1
/* Define to 1 if you have the <linux/random.h> header file. */
#define _GLIBCXX_HAVE_LINUX_RANDOM_H 1
/* Define to 1 if you have the <linux/types.h> header file. */
#define _GLIBCXX_HAVE_LINUX_TYPES_H 1
/* Define to 1 if you have the <locale.h> header file. */
#define _GLIBCXX_HAVE_LOCALE_H 1
/* Define to 1 if you have the `log10f' function. */
#define _GLIBCXX_HAVE_LOG10F 1
/* Define to 1 if you have the `log10l' function. */
#define _GLIBCXX_HAVE_LOG10L 1
/* Define to 1 if you have the `logf' function. */
#define _GLIBCXX_HAVE_LOGF 1
/* Define to 1 if you have the `logl' function. */
#define _GLIBCXX_HAVE_LOGL 1
/* Define to 1 if you have the <machine/endian.h> header file. */
/* #undef _GLIBCXX_HAVE_MACHINE_ENDIAN_H */
/* Define to 1 if you have the <machine/param.h> header file. */
/* #undef _GLIBCXX_HAVE_MACHINE_PARAM_H */
/* Define if mbstate_t exists in wchar.h. */
#define _GLIBCXX_HAVE_MBSTATE_T 1
/* Define to 1 if you have the `memalign' function. */
#define _GLIBCXX_HAVE_MEMALIGN 1
/* Define to 1 if you have the <memory.h> header file. */
#define _GLIBCXX_HAVE_MEMORY_H 1
/* Define to 1 if you have the `modf' function. */
#define _GLIBCXX_HAVE_MODF 1
/* Define to 1 if you have the `modff' function. */
#define _GLIBCXX_HAVE_MODFF 1
/* Define to 1 if you have the `modfl' function. */
#define _GLIBCXX_HAVE_MODFL 1
/* Define to 1 if you have the <nan.h> header file. */
/* #undef _GLIBCXX_HAVE_NAN_H */
/* Define if <math.h> defines obsolete isinf function. */
/* #undef _GLIBCXX_HAVE_OBSOLETE_ISINF */
/* Define if <math.h> defines obsolete isnan function. */
/* #undef _GLIBCXX_HAVE_OBSOLETE_ISNAN */
/* Define if poll is available in <poll.h>. */
#define _GLIBCXX_HAVE_POLL 1
/* Define to 1 if you have the `posix_memalign' function. */
#define _GLIBCXX_HAVE_POSIX_MEMALIGN 1
/* Define to 1 if you have the `powf' function. */
#define _GLIBCXX_HAVE_POWF 1
/* Define to 1 if you have the `powl' function. */
#define _GLIBCXX_HAVE_POWL 1
/* Define to 1 if you have the `qfpclass' function. */
/* #undef _GLIBCXX_HAVE_QFPCLASS */
/* Define to 1 if you have the `quick_exit' function. */
#define _GLIBCXX_HAVE_QUICK_EXIT 1
/* Define to 1 if you have the `setenv' function. */
#define _GLIBCXX_HAVE_SETENV 1
/* Define to 1 if you have the `sincos' function. */
#define _GLIBCXX_HAVE_SINCOS 1
/* Define to 1 if you have the `sincosf' function. */
#define _GLIBCXX_HAVE_SINCOSF 1
/* Define to 1 if you have the `sincosl' function. */
#define _GLIBCXX_HAVE_SINCOSL 1
/* Define to 1 if you have the `sinf' function. */
#define _GLIBCXX_HAVE_SINF 1
/* Define to 1 if you have the `sinhf' function. */
#define _GLIBCXX_HAVE_SINHF 1
/* Define to 1 if you have the `sinhl' function. */
#define _GLIBCXX_HAVE_SINHL 1
/* Define to 1 if you have the `sinl' function. */
#define _GLIBCXX_HAVE_SINL 1
/* Defined if sleep exists. */
/* #undef _GLIBCXX_HAVE_SLEEP */
/* Define to 1 if you have the `sqrtf' function. */
#define _GLIBCXX_HAVE_SQRTF 1
/* Define to 1 if you have the `sqrtl' function. */
#define _GLIBCXX_HAVE_SQRTL 1
/* Define to 1 if you have the <stdalign.h> header file. */
#define _GLIBCXX_HAVE_STDALIGN_H 1
/* Define to 1 if you have the <stdbool.h> header file. */
#define _GLIBCXX_HAVE_STDBOOL_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#define _GLIBCXX_HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define _GLIBCXX_HAVE_STDLIB_H 1
/* Define if strerror_l is available in <string.h>. */
#define _GLIBCXX_HAVE_STRERROR_L 1
/* Define if strerror_r is available in <string.h>. */
#define _GLIBCXX_HAVE_STRERROR_R 1
/* Define to 1 if you have the <strings.h> header file. */
#define _GLIBCXX_HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define _GLIBCXX_HAVE_STRING_H 1
/* Define to 1 if you have the `strtof' function. */
#define _GLIBCXX_HAVE_STRTOF 1
/* Define to 1 if you have the `strtold' function. */
#define _GLIBCXX_HAVE_STRTOLD 1
/* Define to 1 if `d_type' is a member of `struct dirent'. */
#define _GLIBCXX_HAVE_STRUCT_DIRENT_D_TYPE 1
/* Define if strxfrm_l is available in <string.h>. */
#define _GLIBCXX_HAVE_STRXFRM_L 1
/* Define to 1 if the target runtime linker supports binding the same symbol
to different versions. */
#define _GLIBCXX_HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT 1
/* Define to 1 if you have the <sys/filio.h> header file. */
/* #undef _GLIBCXX_HAVE_SYS_FILIO_H */
/* Define to 1 if you have the <sys/ioctl.h> header file. */
#define _GLIBCXX_HAVE_SYS_IOCTL_H 1
/* Define to 1 if you have the <sys/ipc.h> header file. */
#define _GLIBCXX_HAVE_SYS_IPC_H 1
/* Define to 1 if you have the <sys/isa_defs.h> header file. */
/* #undef _GLIBCXX_HAVE_SYS_ISA_DEFS_H */
/* Define to 1 if you have the <sys/machine.h> header file. */
/* #undef _GLIBCXX_HAVE_SYS_MACHINE_H */
/* Define to 1 if you have the <sys/param.h> header file. */
#define _GLIBCXX_HAVE_SYS_PARAM_H 1
/* Define to 1 if you have the <sys/resource.h> header file. */
#define _GLIBCXX_HAVE_SYS_RESOURCE_H 1
/* Define to 1 if you have a suitable <sys/sdt.h> header file */
#define _GLIBCXX_HAVE_SYS_SDT_H 1
/* Define to 1 if you have the <sys/sem.h> header file. */
#define _GLIBCXX_HAVE_SYS_SEM_H 1
/* Define to 1 if you have the <sys/statvfs.h> header file. */
#define _GLIBCXX_HAVE_SYS_STATVFS_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define _GLIBCXX_HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/sysinfo.h> header file. */
#define _GLIBCXX_HAVE_SYS_SYSINFO_H 1
/* Define to 1 if you have the <sys/time.h> header file. */
#define _GLIBCXX_HAVE_SYS_TIME_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define _GLIBCXX_HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <sys/uio.h> header file. */
#define _GLIBCXX_HAVE_SYS_UIO_H 1
/* Define if S_IFREG is available in <sys/stat.h>. */
/* #undef _GLIBCXX_HAVE_S_IFREG */
/* Define if S_ISREG is available in <sys/stat.h>. */
#define _GLIBCXX_HAVE_S_ISREG 1
/* Define to 1 if you have the `tanf' function. */
#define _GLIBCXX_HAVE_TANF 1
/* Define to 1 if you have the `tanhf' function. */
#define _GLIBCXX_HAVE_TANHF 1
/* Define to 1 if you have the `tanhl' function. */
#define _GLIBCXX_HAVE_TANHL 1
/* Define to 1 if you have the `tanl' function. */
#define _GLIBCXX_HAVE_TANL 1
/* Define to 1 if you have the <tgmath.h> header file. */
#define _GLIBCXX_HAVE_TGMATH_H 1
/* Define to 1 if the target supports thread-local storage. */
#define _GLIBCXX_HAVE_TLS 1
/* Define to 1 if you have the <uchar.h> header file. */
#define _GLIBCXX_HAVE_UCHAR_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define _GLIBCXX_HAVE_UNISTD_H 1
/* Defined if usleep exists. */
/* #undef _GLIBCXX_HAVE_USLEEP */
/* Define to 1 if you have the <utime.h> header file. */
#define _GLIBCXX_HAVE_UTIME_H 1
/* Defined if vfwscanf exists. */
#define _GLIBCXX_HAVE_VFWSCANF 1
/* Defined if vswscanf exists. */
#define _GLIBCXX_HAVE_VSWSCANF 1
/* Defined if vwscanf exists. */
#define _GLIBCXX_HAVE_VWSCANF 1
/* Define to 1 if you have the <wchar.h> header file. */
#define _GLIBCXX_HAVE_WCHAR_H 1
/* Defined if wcstof exists. */
#define _GLIBCXX_HAVE_WCSTOF 1
/* Define to 1 if you have the <wctype.h> header file. */
#define _GLIBCXX_HAVE_WCTYPE_H 1
/* Defined if Sleep exists. */
/* #undef _GLIBCXX_HAVE_WIN32_SLEEP */
/* Define if writev is available in <sys/uio.h>. */
#define _GLIBCXX_HAVE_WRITEV 1
/* Define to 1 if you have the `_acosf' function. */
/* #undef _GLIBCXX_HAVE__ACOSF */
/* Define to 1 if you have the `_acosl' function. */
/* #undef _GLIBCXX_HAVE__ACOSL */
/* Define to 1 if you have the `_aligned_malloc' function. */
/* #undef _GLIBCXX_HAVE__ALIGNED_MALLOC */
/* Define to 1 if you have the `_asinf' function. */
/* #undef _GLIBCXX_HAVE__ASINF */
/* Define to 1 if you have the `_asinl' function. */
/* #undef _GLIBCXX_HAVE__ASINL */
/* Define to 1 if you have the `_atan2f' function. */
/* #undef _GLIBCXX_HAVE__ATAN2F */
/* Define to 1 if you have the `_atan2l' function. */
/* #undef _GLIBCXX_HAVE__ATAN2L */
/* Define to 1 if you have the `_atanf' function. */
/* #undef _GLIBCXX_HAVE__ATANF */
/* Define to 1 if you have the `_atanl' function. */
/* #undef _GLIBCXX_HAVE__ATANL */
/* Define to 1 if you have the `_ceilf' function. */
/* #undef _GLIBCXX_HAVE__CEILF */
/* Define to 1 if you have the `_ceill' function. */
/* #undef _GLIBCXX_HAVE__CEILL */
/* Define to 1 if you have the `_cosf' function. */
/* #undef _GLIBCXX_HAVE__COSF */
/* Define to 1 if you have the `_coshf' function. */
/* #undef _GLIBCXX_HAVE__COSHF */
/* Define to 1 if you have the `_coshl' function. */
/* #undef _GLIBCXX_HAVE__COSHL */
/* Define to 1 if you have the `_cosl' function. */
/* #undef _GLIBCXX_HAVE__COSL */
/* Define to 1 if you have the `_expf' function. */
/* #undef _GLIBCXX_HAVE__EXPF */
/* Define to 1 if you have the `_expl' function. */
/* #undef _GLIBCXX_HAVE__EXPL */
/* Define to 1 if you have the `_fabsf' function. */
/* #undef _GLIBCXX_HAVE__FABSF */
/* Define to 1 if you have the `_fabsl' function. */
/* #undef _GLIBCXX_HAVE__FABSL */
/* Define to 1 if you have the `_finite' function. */
/* #undef _GLIBCXX_HAVE__FINITE */
/* Define to 1 if you have the `_finitef' function. */
/* #undef _GLIBCXX_HAVE__FINITEF */
/* Define to 1 if you have the `_finitel' function. */
/* #undef _GLIBCXX_HAVE__FINITEL */
/* Define to 1 if you have the `_floorf' function. */
/* #undef _GLIBCXX_HAVE__FLOORF */
/* Define to 1 if you have the `_floorl' function. */
/* #undef _GLIBCXX_HAVE__FLOORL */
/* Define to 1 if you have the `_fmodf' function. */
/* #undef _GLIBCXX_HAVE__FMODF */
/* Define to 1 if you have the `_fmodl' function. */
/* #undef _GLIBCXX_HAVE__FMODL */
/* Define to 1 if you have the `_fpclass' function. */
/* #undef _GLIBCXX_HAVE__FPCLASS */
/* Define to 1 if you have the `_frexpf' function. */
/* #undef _GLIBCXX_HAVE__FREXPF */
/* Define to 1 if you have the `_frexpl' function. */
/* #undef _GLIBCXX_HAVE__FREXPL */
/* Define to 1 if you have the `_hypot' function. */
/* #undef _GLIBCXX_HAVE__HYPOT */
/* Define to 1 if you have the `_hypotf' function. */
/* #undef _GLIBCXX_HAVE__HYPOTF */
/* Define to 1 if you have the `_hypotl' function. */
/* #undef _GLIBCXX_HAVE__HYPOTL */
/* Define to 1 if you have the `_isinf' function. */
/* #undef _GLIBCXX_HAVE__ISINF */
/* Define to 1 if you have the `_isinff' function. */
/* #undef _GLIBCXX_HAVE__ISINFF */
/* Define to 1 if you have the `_isinfl' function. */
/* #undef _GLIBCXX_HAVE__ISINFL */
/* Define to 1 if you have the `_isnan' function. */
/* #undef _GLIBCXX_HAVE__ISNAN */
/* Define to 1 if you have the `_isnanf' function. */
/* #undef _GLIBCXX_HAVE__ISNANF */
/* Define to 1 if you have the `_isnanl' function. */
/* #undef _GLIBCXX_HAVE__ISNANL */
/* Define to 1 if you have the `_ldexpf' function. */
/* #undef _GLIBCXX_HAVE__LDEXPF */
/* Define to 1 if you have the `_ldexpl' function. */
/* #undef _GLIBCXX_HAVE__LDEXPL */
/* Define to 1 if you have the `_log10f' function. */
/* #undef _GLIBCXX_HAVE__LOG10F */
/* Define to 1 if you have the `_log10l' function. */
/* #undef _GLIBCXX_HAVE__LOG10L */
/* Define to 1 if you have the `_logf' function. */
/* #undef _GLIBCXX_HAVE__LOGF */
/* Define to 1 if you have the `_logl' function. */
/* #undef _GLIBCXX_HAVE__LOGL */
/* Define to 1 if you have the `_modf' function. */
/* #undef _GLIBCXX_HAVE__MODF */
/* Define to 1 if you have the `_modff' function. */
/* #undef _GLIBCXX_HAVE__MODFF */
/* Define to 1 if you have the `_modfl' function. */
/* #undef _GLIBCXX_HAVE__MODFL */
/* Define to 1 if you have the `_powf' function. */
/* #undef _GLIBCXX_HAVE__POWF */
/* Define to 1 if you have the `_powl' function. */
/* #undef _GLIBCXX_HAVE__POWL */
/* Define to 1 if you have the `_qfpclass' function. */
/* #undef _GLIBCXX_HAVE__QFPCLASS */
/* Define to 1 if you have the `_sincos' function. */
/* #undef _GLIBCXX_HAVE__SINCOS */
/* Define to 1 if you have the `_sincosf' function. */
/* #undef _GLIBCXX_HAVE__SINCOSF */
/* Define to 1 if you have the `_sincosl' function. */
/* #undef _GLIBCXX_HAVE__SINCOSL */
/* Define to 1 if you have the `_sinf' function. */
/* #undef _GLIBCXX_HAVE__SINF */
/* Define to 1 if you have the `_sinhf' function. */
/* #undef _GLIBCXX_HAVE__SINHF */
/* Define to 1 if you have the `_sinhl' function. */
/* #undef _GLIBCXX_HAVE__SINHL */
/* Define to 1 if you have the `_sinl' function. */
/* #undef _GLIBCXX_HAVE__SINL */
/* Define to 1 if you have the `_sqrtf' function. */
/* #undef _GLIBCXX_HAVE__SQRTF */
/* Define to 1 if you have the `_sqrtl' function. */
/* #undef _GLIBCXX_HAVE__SQRTL */
/* Define to 1 if you have the `_tanf' function. */
/* #undef _GLIBCXX_HAVE__TANF */
/* Define to 1 if you have the `_tanhf' function. */
/* #undef _GLIBCXX_HAVE__TANHF */
/* Define to 1 if you have the `_tanhl' function. */
/* #undef _GLIBCXX_HAVE__TANHL */
/* Define to 1 if you have the `_tanl' function. */
/* #undef _GLIBCXX_HAVE__TANL */
/* Define to 1 if you have the `__cxa_thread_atexit' function. */
/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT */
/* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
/* Define as const if the declaration of iconv() needs const. */
#define _GLIBCXX_ICONV_CONST
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#define LT_OBJDIR ".libs/"
/* Name of package */
/* #undef _GLIBCXX_PACKAGE */
/* Define to the address where bug reports for this package should be sent. */
#define _GLIBCXX_PACKAGE_BUGREPORT ""
/* Define to the full name of this package. */
#define _GLIBCXX_PACKAGE_NAME "package-unused"
/* Define to the full name and version of this package. */
#define _GLIBCXX_PACKAGE_STRING "package-unused version-unused"
/* Define to the one symbol short name of this package. */
#define _GLIBCXX_PACKAGE_TARNAME "libstdc++"
/* Define to the home page for this package. */
#define _GLIBCXX_PACKAGE_URL ""
/* Define to the version of this package. */
#define _GLIBCXX_PACKAGE__GLIBCXX_VERSION "version-unused"
/* The size of `char', as computed by sizeof. */
/* #undef SIZEOF_CHAR */
/* The size of `int', as computed by sizeof. */
/* #undef SIZEOF_INT */
/* The size of `long', as computed by sizeof. */
/* #undef SIZEOF_LONG */
/* The size of `short', as computed by sizeof. */
/* #undef SIZEOF_SHORT */
/* The size of `void *', as computed by sizeof. */
/* #undef SIZEOF_VOID_P */
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Version number of package */
/* #undef _GLIBCXX_VERSION */
/* Number of bits in a file offset, on hosts where this is settable. */
#define _GLIBCXX_FILE_OFFSET_BITS 64
/* Define if C99 functions in <complex.h> should be used in <complex> for
C++11. Using compiler builtins for these functions requires corresponding
C99 library functions to be present. */
#define _GLIBCXX11_USE_C99_COMPLEX 1
/* Define if C99 functions or macros in <math.h> should be imported in <cmath>
in namespace std for C++11. */
#define _GLIBCXX11_USE_C99_MATH 1
/* Define if C99 functions or macros in <stdio.h> should be imported in
<cstdio> in namespace std for C++11. */
#define _GLIBCXX11_USE_C99_STDIO 1
/* Define if C99 functions or macros in <stdlib.h> should be imported in
<cstdlib> in namespace std for C++11. */
#define _GLIBCXX11_USE_C99_STDLIB 1
/* Define if C99 functions or macros in <wchar.h> should be imported in
<cwchar> in namespace std for C++11. */
#define _GLIBCXX11_USE_C99_WCHAR 1
/* Define if C99 functions in <complex.h> should be used in <complex> for
C++98. Using compiler builtins for these functions requires corresponding
C99 library functions to be present. */
#define _GLIBCXX98_USE_C99_COMPLEX 1
/* Define if C99 functions or macros in <math.h> should be imported in <cmath>
in namespace std for C++98. */
#define _GLIBCXX98_USE_C99_MATH 1
/* Define if C99 functions or macros in <stdio.h> should be imported in
<cstdio> in namespace std for C++98. */
#define _GLIBCXX98_USE_C99_STDIO 1
/* Define if C99 functions or macros in <stdlib.h> should be imported in
<cstdlib> in namespace std for C++98. */
#define _GLIBCXX98_USE_C99_STDLIB 1
/* Define if C99 functions or macros in <wchar.h> should be imported in
<cwchar> in namespace std for C++98. */
#define _GLIBCXX98_USE_C99_WCHAR 1
/* Define if the compiler supports C++11 atomics. */
#define _GLIBCXX_ATOMIC_BUILTINS 1
/* Define to use concept checking code from the boost libraries. */
/* #undef _GLIBCXX_CONCEPT_CHECKS */
/* Define to 1 if a fully dynamic basic_string is wanted, 0 to disable,
undefined for platform defaults */
#define _GLIBCXX_FULLY_DYNAMIC_STRING 0
/* Define if gthreads library is available. */
#define _GLIBCXX_HAS_GTHREADS 1
/* Define to 1 if a full hosted library is built, or 0 if freestanding. */
#define _GLIBCXX_HOSTED 1
/* Define if compatibility should be provided for -mlong-double-64. */
/* Define to the letter to which size_t is mangled. */
#define _GLIBCXX_MANGLE_SIZE_T j
/* Define if C99 llrint and llround functions are missing from <math.h>. */
/* #undef _GLIBCXX_NO_C99_ROUNDING_FUNCS */
/* Define if ptrdiff_t is int. */
#define _GLIBCXX_PTRDIFF_T_IS_INT 1
/* Define if using setrlimit to set resource limits during "make check" */
#define _GLIBCXX_RES_LIMITS 1
/* Define if size_t is unsigned int. */
#define _GLIBCXX_SIZE_T_IS_UINT 1
/* Define to the value of the EOF integer constant. */
#define _GLIBCXX_STDIO_EOF -1
/* Define to the value of the SEEK_CUR integer constant. */
#define _GLIBCXX_STDIO_SEEK_CUR 1
/* Define to the value of the SEEK_END integer constant. */
#define _GLIBCXX_STDIO_SEEK_END 2
/* Define to use symbol versioning in the shared library. */
#define _GLIBCXX_SYMVER 1
/* Define to use darwin versioning in the shared library. */
/* #undef _GLIBCXX_SYMVER_DARWIN */
/* Define to use GNU versioning in the shared library. */
#define _GLIBCXX_SYMVER_GNU 1
/* Define to use GNU namespace versioning in the shared library. */
/* #undef _GLIBCXX_SYMVER_GNU_NAMESPACE */
/* Define to use Sun versioning in the shared library. */
/* #undef _GLIBCXX_SYMVER_SUN */
/* Define if C11 functions in <uchar.h> should be imported into namespace std
in <cuchar>. */
#define _GLIBCXX_USE_C11_UCHAR_CXX11 1
/* Define if C99 functions or macros from <wchar.h>, <math.h>, <complex.h>,
<stdio.h>, and <stdlib.h> can be used or exposed. */
#define _GLIBCXX_USE_C99 1
/* Define if C99 functions in <complex.h> should be used in <tr1/complex>.
Using compiler builtins for these functions requires corresponding C99
library functions to be present. */
#define _GLIBCXX_USE_C99_COMPLEX_TR1 1
/* Define if C99 functions in <ctype.h> should be imported in <tr1/cctype> in
namespace std::tr1. */
#define _GLIBCXX_USE_C99_CTYPE_TR1 1
/* Define if C99 functions in <fenv.h> should be imported in <tr1/cfenv> in
namespace std::tr1. */
#define _GLIBCXX_USE_C99_FENV_TR1 1
/* Define if C99 functions in <inttypes.h> should be imported in
<tr1/cinttypes> in namespace std::tr1. */
#define _GLIBCXX_USE_C99_INTTYPES_TR1 1
/* Define if wchar_t C99 functions in <inttypes.h> should be imported in
<tr1/cinttypes> in namespace std::tr1. */
#define _GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1 1
/* Define if C99 functions or macros in <math.h> should be imported in
<tr1/cmath> in namespace std::tr1. */
#define _GLIBCXX_USE_C99_MATH_TR1 1
/* Define if C99 types in <stdint.h> should be imported in <tr1/cstdint> in
namespace std::tr1. */
#define _GLIBCXX_USE_C99_STDINT_TR1 1
/* Defined if clock_gettime syscall has monotonic and realtime clock support.
*/
/* #undef _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL */
/* Defined if clock_gettime has monotonic clock support. */
#define _GLIBCXX_USE_CLOCK_MONOTONIC 1
/* Defined if clock_gettime has realtime clock support. */
#define _GLIBCXX_USE_CLOCK_REALTIME 1
/* Define if ISO/IEC TR 24733 decimal floating point types are supported on
this host. */
#define _GLIBCXX_USE_DECIMAL_FLOAT 1
/* Define if fchmod is available in <sys/stat.h>. */
#define _GLIBCXX_USE_FCHMOD 1
/* Define if fchmodat is available in <sys/stat.h>. */
#define _GLIBCXX_USE_FCHMODAT 1
/* Defined if gettimeofday is available. */
#define _GLIBCXX_USE_GETTIMEOFDAY 1
/* Define if get_nprocs is available in <sys/sysinfo.h>. */
#define _GLIBCXX_USE_GET_NPROCS 1
/* Define if __int128 is supported on this host. */
/* #undef _GLIBCXX_USE_INT128 */
/* Define if LFS support is available. */
#define _GLIBCXX_USE_LFS 1
/* Define if code specialized for long long should be used. */
#define _GLIBCXX_USE_LONG_LONG 1
/* Defined if nanosleep is available. */
#define _GLIBCXX_USE_NANOSLEEP 1
/* Define if NLS translations are to be used. */
#define _GLIBCXX_USE_NLS 1
/* Define if pthreads_num_processors_np is available in <pthread.h>. */
/* #undef _GLIBCXX_USE_PTHREADS_NUM_PROCESSORS_NP */
/* Define if POSIX read/write locks are available in <gthr.h>. */
#define _GLIBCXX_USE_PTHREAD_RWLOCK_T 1
/* Define if /dev/random and /dev/urandom are available for the random_device
of TR1 (Chapter 5.1). */
#define _GLIBCXX_USE_RANDOM_TR1 1
/* Define if usable realpath is available in <stdlib.h>. */
#define _GLIBCXX_USE_REALPATH 1
/* Defined if sched_yield is available. */
#define _GLIBCXX_USE_SCHED_YIELD 1
/* Define if _SC_NPROCESSORS_ONLN is available in <unistd.h>. */
#define _GLIBCXX_USE_SC_NPROCESSORS_ONLN 1
/* Define if _SC_NPROC_ONLN is available in <unistd.h>. */
/* #undef _GLIBCXX_USE_SC_NPROC_ONLN */
/* Define if sendfile is available in <sys/sendfile.h>. */
#define _GLIBCXX_USE_SENDFILE 1
/* Define if struct stat has timespec members. */
#define _GLIBCXX_USE_ST_MTIM 1
/* Define if sysctl(), CTL_HW and HW_NCPU are available in <sys/sysctl.h>. */
/* #undef _GLIBCXX_USE_SYSCTL_HW_NCPU */
/* Define if obsolescent tmpnam is available in <stdio.h>. */
#define _GLIBCXX_USE_TMPNAM 1
/* Define if utimensat and UTIME_OMIT are available in <sys/stat.h> and
AT_FDCWD in <fcntl.h>. */
#define _GLIBCXX_USE_UTIMENSAT 1
/* Define if code specialized for wchar_t should be used. */
#define _GLIBCXX_USE_WCHAR_T 1
/* Define to 1 if a verbose library is built, or 0 otherwise. */
#define _GLIBCXX_VERBOSE 1
/* Defined if as can handle rdrand. */
#define _GLIBCXX_X86_RDRAND 1
/* Define to 1 if mutex_timedlock is available. */
#define _GTHREAD_USE_MUTEX_TIMEDLOCK 1
/* Define for large files, on AIX-style hosts. */
/* #undef _GLIBCXX_LARGE_FILES */
/* Define if all C++11 floating point overloads are available in <math.h>. */
#if __cplusplus >= 201103L
/* #undef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP */
#endif
/* Define if all C++11 integral type overloads are available in <math.h>. */
#if __cplusplus >= 201103L
/* #undef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT */
#endif
#if defined (_GLIBCXX_HAVE__ACOSF) && ! defined (_GLIBCXX_HAVE_ACOSF)
# define _GLIBCXX_HAVE_ACOSF 1
# define acosf _acosf
#endif
#if defined (_GLIBCXX_HAVE__ACOSL) && ! defined (_GLIBCXX_HAVE_ACOSL)
# define _GLIBCXX_HAVE_ACOSL 1
# define acosl _acosl
#endif
#if defined (_GLIBCXX_HAVE__ASINF) && ! defined (_GLIBCXX_HAVE_ASINF)
# define _GLIBCXX_HAVE_ASINF 1
# define asinf _asinf
#endif
#if defined (_GLIBCXX_HAVE__ASINL) && ! defined (_GLIBCXX_HAVE_ASINL)
# define _GLIBCXX_HAVE_ASINL 1
# define asinl _asinl
#endif
#if defined (_GLIBCXX_HAVE__ATAN2F) && ! defined (_GLIBCXX_HAVE_ATAN2F)
# define _GLIBCXX_HAVE_ATAN2F 1
# define atan2f _atan2f
#endif
#if defined (_GLIBCXX_HAVE__ATAN2L) && ! defined (_GLIBCXX_HAVE_ATAN2L)
# define _GLIBCXX_HAVE_ATAN2L 1
# define atan2l _atan2l
#endif
#if defined (_GLIBCXX_HAVE__ATANF) && ! defined (_GLIBCXX_HAVE_ATANF)
# define _GLIBCXX_HAVE_ATANF 1
# define atanf _atanf
#endif
#if defined (_GLIBCXX_HAVE__ATANL) && ! defined (_GLIBCXX_HAVE_ATANL)
# define _GLIBCXX_HAVE_ATANL 1
# define atanl _atanl
#endif
#if defined (_GLIBCXX_HAVE__CEILF) && ! defined (_GLIBCXX_HAVE_CEILF)
# define _GLIBCXX_HAVE_CEILF 1
# define ceilf _ceilf
#endif
#if defined (_GLIBCXX_HAVE__CEILL) && ! defined (_GLIBCXX_HAVE_CEILL)
# define _GLIBCXX_HAVE_CEILL 1
# define ceill _ceill
#endif
#if defined (_GLIBCXX_HAVE__COSF) && ! defined (_GLIBCXX_HAVE_COSF)
# define _GLIBCXX_HAVE_COSF 1
# define cosf _cosf
#endif
#if defined (_GLIBCXX_HAVE__COSHF) && ! defined (_GLIBCXX_HAVE_COSHF)
# define _GLIBCXX_HAVE_COSHF 1
# define coshf _coshf
#endif
#if defined (_GLIBCXX_HAVE__COSHL) && ! defined (_GLIBCXX_HAVE_COSHL)
# define _GLIBCXX_HAVE_COSHL 1
# define coshl _coshl
#endif
#if defined (_GLIBCXX_HAVE__COSL) && ! defined (_GLIBCXX_HAVE_COSL)
# define _GLIBCXX_HAVE_COSL 1
# define cosl _cosl
#endif
#if defined (_GLIBCXX_HAVE__EXPF) && ! defined (_GLIBCXX_HAVE_EXPF)
# define _GLIBCXX_HAVE_EXPF 1
# define expf _expf
#endif
#if defined (_GLIBCXX_HAVE__EXPL) && ! defined (_GLIBCXX_HAVE_EXPL)
# define _GLIBCXX_HAVE_EXPL 1
# define expl _expl
#endif
#if defined (_GLIBCXX_HAVE__FABSF) && ! defined (_GLIBCXX_HAVE_FABSF)
# define _GLIBCXX_HAVE_FABSF 1
# define fabsf _fabsf
#endif
#if defined (_GLIBCXX_HAVE__FABSL) && ! defined (_GLIBCXX_HAVE_FABSL)
# define _GLIBCXX_HAVE_FABSL 1
# define fabsl _fabsl
#endif
#if defined (_GLIBCXX_HAVE__FINITE) && ! defined (_GLIBCXX_HAVE_FINITE)
# define _GLIBCXX_HAVE_FINITE 1
# define finite _finite
#endif
#if defined (_GLIBCXX_HAVE__FINITEF) && ! defined (_GLIBCXX_HAVE_FINITEF)
# define _GLIBCXX_HAVE_FINITEF 1
# define finitef _finitef
#endif
#if defined (_GLIBCXX_HAVE__FINITEL) && ! defined (_GLIBCXX_HAVE_FINITEL)
# define _GLIBCXX_HAVE_FINITEL 1
# define finitel _finitel
#endif
#if defined (_GLIBCXX_HAVE__FLOORF) && ! defined (_GLIBCXX_HAVE_FLOORF)
# define _GLIBCXX_HAVE_FLOORF 1
# define floorf _floorf
#endif
#if defined (_GLIBCXX_HAVE__FLOORL) && ! defined (_GLIBCXX_HAVE_FLOORL)
# define _GLIBCXX_HAVE_FLOORL 1
# define floorl _floorl
#endif
#if defined (_GLIBCXX_HAVE__FMODF) && ! defined (_GLIBCXX_HAVE_FMODF)
# define _GLIBCXX_HAVE_FMODF 1
# define fmodf _fmodf
#endif
#if defined (_GLIBCXX_HAVE__FMODL) && ! defined (_GLIBCXX_HAVE_FMODL)
# define _GLIBCXX_HAVE_FMODL 1
# define fmodl _fmodl
#endif
#if defined (_GLIBCXX_HAVE__FPCLASS) && ! defined (_GLIBCXX_HAVE_FPCLASS)
# define _GLIBCXX_HAVE_FPCLASS 1
# define fpclass _fpclass
#endif
#if defined (_GLIBCXX_HAVE__FREXPF) && ! defined (_GLIBCXX_HAVE_FREXPF)
# define _GLIBCXX_HAVE_FREXPF 1
# define frexpf _frexpf
#endif
#if defined (_GLIBCXX_HAVE__FREXPL) && ! defined (_GLIBCXX_HAVE_FREXPL)
# define _GLIBCXX_HAVE_FREXPL 1
# define frexpl _frexpl
#endif
#if defined (_GLIBCXX_HAVE__HYPOT) && ! defined (_GLIBCXX_HAVE_HYPOT)
# define _GLIBCXX_HAVE_HYPOT 1
# define hypot _hypot
#endif
#if defined (_GLIBCXX_HAVE__HYPOTF) && ! defined (_GLIBCXX_HAVE_HYPOTF)
# define _GLIBCXX_HAVE_HYPOTF 1
# define hypotf _hypotf
#endif
#if defined (_GLIBCXX_HAVE__HYPOTL) && ! defined (_GLIBCXX_HAVE_HYPOTL)
# define _GLIBCXX_HAVE_HYPOTL 1
# define hypotl _hypotl
#endif
#if defined (_GLIBCXX_HAVE__ISINF) && ! defined (_GLIBCXX_HAVE_ISINF)
# define _GLIBCXX_HAVE_ISINF 1
# define isinf _isinf
#endif
#if defined (_GLIBCXX_HAVE__ISINFF) && ! defined (_GLIBCXX_HAVE_ISINFF)
# define _GLIBCXX_HAVE_ISINFF 1
# define isinff _isinff
#endif
#if defined (_GLIBCXX_HAVE__ISINFL) && ! defined (_GLIBCXX_HAVE_ISINFL)
# define _GLIBCXX_HAVE_ISINFL 1
# define isinfl _isinfl
#endif
#if defined (_GLIBCXX_HAVE__ISNAN) && ! defined (_GLIBCXX_HAVE_ISNAN)
# define _GLIBCXX_HAVE_ISNAN 1
# define isnan _isnan
#endif
#if defined (_GLIBCXX_HAVE__ISNANF) && ! defined (_GLIBCXX_HAVE_ISNANF)
# define _GLIBCXX_HAVE_ISNANF 1
# define isnanf _isnanf
#endif
#if defined (_GLIBCXX_HAVE__ISNANL) && ! defined (_GLIBCXX_HAVE_ISNANL)
# define _GLIBCXX_HAVE_ISNANL 1
# define isnanl _isnanl
#endif
#if defined (_GLIBCXX_HAVE__LDEXPF) && ! defined (_GLIBCXX_HAVE_LDEXPF)
# define _GLIBCXX_HAVE_LDEXPF 1
# define ldexpf _ldexpf
#endif
#if defined (_GLIBCXX_HAVE__LDEXPL) && ! defined (_GLIBCXX_HAVE_LDEXPL)
# define _GLIBCXX_HAVE_LDEXPL 1
# define ldexpl _ldexpl
#endif
#if defined (_GLIBCXX_HAVE__LOG10F) && ! defined (_GLIBCXX_HAVE_LOG10F)
# define _GLIBCXX_HAVE_LOG10F 1
# define log10f _log10f
#endif
#if defined (_GLIBCXX_HAVE__LOG10L) && ! defined (_GLIBCXX_HAVE_LOG10L)
# define _GLIBCXX_HAVE_LOG10L 1
# define log10l _log10l
#endif
#if defined (_GLIBCXX_HAVE__LOGF) && ! defined (_GLIBCXX_HAVE_LOGF)
# define _GLIBCXX_HAVE_LOGF 1
# define logf _logf
#endif
#if defined (_GLIBCXX_HAVE__LOGL) && ! defined (_GLIBCXX_HAVE_LOGL)
# define _GLIBCXX_HAVE_LOGL 1
# define logl _logl
#endif
#if defined (_GLIBCXX_HAVE__MODF) && ! defined (_GLIBCXX_HAVE_MODF)
# define _GLIBCXX_HAVE_MODF 1
# define modf _modf
#endif
#if defined (_GLIBCXX_HAVE__MODFF) && ! defined (_GLIBCXX_HAVE_MODFF)
# define _GLIBCXX_HAVE_MODFF 1
# define modff _modff
#endif
#if defined (_GLIBCXX_HAVE__MODFL) && ! defined (_GLIBCXX_HAVE_MODFL)
# define _GLIBCXX_HAVE_MODFL 1
# define modfl _modfl
#endif
#if defined (_GLIBCXX_HAVE__POWF) && ! defined (_GLIBCXX_HAVE_POWF)
# define _GLIBCXX_HAVE_POWF 1
# define powf _powf
#endif
#if defined (_GLIBCXX_HAVE__POWL) && ! defined (_GLIBCXX_HAVE_POWL)
# define _GLIBCXX_HAVE_POWL 1
# define powl _powl
#endif
#if defined (_GLIBCXX_HAVE__QFPCLASS) && ! defined (_GLIBCXX_HAVE_QFPCLASS)
# define _GLIBCXX_HAVE_QFPCLASS 1
# define qfpclass _qfpclass
#endif
#if defined (_GLIBCXX_HAVE__SINCOS) && ! defined (_GLIBCXX_HAVE_SINCOS)
# define _GLIBCXX_HAVE_SINCOS 1
# define sincos _sincos
#endif
#if defined (_GLIBCXX_HAVE__SINCOSF) && ! defined (_GLIBCXX_HAVE_SINCOSF)
# define _GLIBCXX_HAVE_SINCOSF 1
# define sincosf _sincosf
#endif
#if defined (_GLIBCXX_HAVE__SINCOSL) && ! defined (_GLIBCXX_HAVE_SINCOSL)
# define _GLIBCXX_HAVE_SINCOSL 1
# define sincosl _sincosl
#endif
#if defined (_GLIBCXX_HAVE__SINF) && ! defined (_GLIBCXX_HAVE_SINF)
# define _GLIBCXX_HAVE_SINF 1
# define sinf _sinf
#endif
#if defined (_GLIBCXX_HAVE__SINHF) && ! defined (_GLIBCXX_HAVE_SINHF)
# define _GLIBCXX_HAVE_SINHF 1
# define sinhf _sinhf
#endif
#if defined (_GLIBCXX_HAVE__SINHL) && ! defined (_GLIBCXX_HAVE_SINHL)
# define _GLIBCXX_HAVE_SINHL 1
# define sinhl _sinhl
#endif
#if defined (_GLIBCXX_HAVE__SINL) && ! defined (_GLIBCXX_HAVE_SINL)
# define _GLIBCXX_HAVE_SINL 1
# define sinl _sinl
#endif
#if defined (_GLIBCXX_HAVE__SQRTF) && ! defined (_GLIBCXX_HAVE_SQRTF)
# define _GLIBCXX_HAVE_SQRTF 1
# define sqrtf _sqrtf
#endif
#if defined (_GLIBCXX_HAVE__SQRTL) && ! defined (_GLIBCXX_HAVE_SQRTL)
# define _GLIBCXX_HAVE_SQRTL 1
# define sqrtl _sqrtl
#endif
#if defined (_GLIBCXX_HAVE__STRTOF) && ! defined (_GLIBCXX_HAVE_STRTOF)
# define _GLIBCXX_HAVE_STRTOF 1
# define strtof _strtof
#endif
#if defined (_GLIBCXX_HAVE__STRTOLD) && ! defined (_GLIBCXX_HAVE_STRTOLD)
# define _GLIBCXX_HAVE_STRTOLD 1
# define strtold _strtold
#endif
#if defined (_GLIBCXX_HAVE__TANF) && ! defined (_GLIBCXX_HAVE_TANF)
# define _GLIBCXX_HAVE_TANF 1
# define tanf _tanf
#endif
#if defined (_GLIBCXX_HAVE__TANHF) && ! defined (_GLIBCXX_HAVE_TANHF)
# define _GLIBCXX_HAVE_TANHF 1
# define tanhf _tanhf
#endif
#if defined (_GLIBCXX_HAVE__TANHL) && ! defined (_GLIBCXX_HAVE_TANHL)
# define _GLIBCXX_HAVE_TANHL 1
# define tanhl _tanhl
#endif
#if defined (_GLIBCXX_HAVE__TANL) && ! defined (_GLIBCXX_HAVE_TANL)
# define _GLIBCXX_HAVE_TANL 1
# define tanl _tanl
#endif
#endif // _GLIBCXX_CXX_CONFIG_H
#else
// Predefined symbols and macros -*- C++ -*-
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/c++config.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{iosfwd}
*/
#ifndef _GLIBCXX_CXX_CONFIG_H
#define _GLIBCXX_CXX_CONFIG_H 1
// The major release number for the GCC release the C++ library belongs to.
#define _GLIBCXX_RELEASE 8
// The datestamp of the C++ library in compressed ISO date format.
#define __GLIBCXX__ 20210514
// Macros for various attributes.
// _GLIBCXX_PURE
// _GLIBCXX_CONST
// _GLIBCXX_NORETURN
// _GLIBCXX_NOTHROW
// _GLIBCXX_VISIBILITY
#ifndef _GLIBCXX_PURE
# define _GLIBCXX_PURE __attribute__ ((__pure__))
#endif
#ifndef _GLIBCXX_CONST
# define _GLIBCXX_CONST __attribute__ ((__const__))
#endif
#ifndef _GLIBCXX_NORETURN
# define _GLIBCXX_NORETURN __attribute__ ((__noreturn__))
#endif
// See below for C++
#ifndef _GLIBCXX_NOTHROW
# ifndef __cplusplus
# define _GLIBCXX_NOTHROW __attribute__((__nothrow__))
# endif
#endif
// Macros for visibility attributes.
// _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY
// _GLIBCXX_VISIBILITY
# define _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY 1
#if _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY
# define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ (#V)))
#else
// If this is not supplied by the OS-specific or CPU-specific
// headers included below, it will be defined to an empty default.
# define _GLIBCXX_VISIBILITY(V) _GLIBCXX_PSEUDO_VISIBILITY(V)
#endif
// Macros for deprecated attributes.
// _GLIBCXX_USE_DEPRECATED
// _GLIBCXX_DEPRECATED
// _GLIBCXX17_DEPRECATED
#ifndef _GLIBCXX_USE_DEPRECATED
# define _GLIBCXX_USE_DEPRECATED 1
#endif
#if defined(__DEPRECATED) && (__cplusplus >= 201103L)
# define _GLIBCXX_DEPRECATED __attribute__ ((__deprecated__))
#else
# define _GLIBCXX_DEPRECATED
#endif
#if defined(__DEPRECATED) && (__cplusplus >= 201703L)
# define _GLIBCXX17_DEPRECATED [[__deprecated__]]
#else
# define _GLIBCXX17_DEPRECATED
#endif
// Macros for ABI tag attributes.
#ifndef _GLIBCXX_ABI_TAG_CXX11
# define _GLIBCXX_ABI_TAG_CXX11 __attribute ((__abi_tag__ ("cxx11")))
#endif
// Macro to warn about unused results.
#if __cplusplus >= 201703L
# define _GLIBCXX_NODISCARD [[__nodiscard__]]
#else
# define _GLIBCXX_NODISCARD
#endif
#if __cplusplus
// Macro for constexpr, to support in mixed 03/0x mode.
#ifndef _GLIBCXX_CONSTEXPR
# if __cplusplus >= 201103L
# define _GLIBCXX_CONSTEXPR constexpr
# define _GLIBCXX_USE_CONSTEXPR constexpr
# else
# define _GLIBCXX_CONSTEXPR
# define _GLIBCXX_USE_CONSTEXPR const
# endif
#endif
#ifndef _GLIBCXX14_CONSTEXPR
# if __cplusplus >= 201402L
# define _GLIBCXX14_CONSTEXPR constexpr
# else
# define _GLIBCXX14_CONSTEXPR
# endif
#endif
#ifndef _GLIBCXX17_CONSTEXPR
# if __cplusplus > 201402L
# define _GLIBCXX17_CONSTEXPR constexpr
# else
# define _GLIBCXX17_CONSTEXPR
# endif
#endif
#ifndef _GLIBCXX17_INLINE
# if __cplusplus > 201402L
# define _GLIBCXX17_INLINE inline
# else
# define _GLIBCXX17_INLINE
# endif
#endif
// Macro for noexcept, to support in mixed 03/0x mode.
#ifndef _GLIBCXX_NOEXCEPT
# if __cplusplus >= 201103L
# define _GLIBCXX_NOEXCEPT noexcept
# define _GLIBCXX_NOEXCEPT_IF(_COND) noexcept(_COND)
# define _GLIBCXX_USE_NOEXCEPT noexcept
# define _GLIBCXX_THROW(_EXC)
# else
# define _GLIBCXX_NOEXCEPT
# define _GLIBCXX_NOEXCEPT_IF(_COND)
# define _GLIBCXX_USE_NOEXCEPT throw()
# define _GLIBCXX_THROW(_EXC) throw(_EXC)
# endif
#endif
#ifndef _GLIBCXX_NOTHROW
# define _GLIBCXX_NOTHROW _GLIBCXX_USE_NOEXCEPT
#endif
#ifndef _GLIBCXX_THROW_OR_ABORT
# if __cpp_exceptions
# define _GLIBCXX_THROW_OR_ABORT(_EXC) (throw (_EXC))
# else
# define _GLIBCXX_THROW_OR_ABORT(_EXC) (__builtin_abort())
# endif
#endif
#if __cpp_noexcept_function_type
#define _GLIBCXX_NOEXCEPT_PARM , bool _NE
#define _GLIBCXX_NOEXCEPT_QUAL noexcept (_NE)
#else
#define _GLIBCXX_NOEXCEPT_PARM
#define _GLIBCXX_NOEXCEPT_QUAL
#endif
// Macro for extern template, ie controlling template linkage via use
// of extern keyword on template declaration. As documented in the g++
// manual, it inhibits all implicit instantiations and is used
// throughout the library to avoid multiple weak definitions for
// required types that are already explicitly instantiated in the
// library binary. This substantially reduces the binary size of
// resulting executables.
// Special case: _GLIBCXX_EXTERN_TEMPLATE == -1 disallows extern
// templates only in basic_string, thus activating its debug-mode
// checks even at -O0.
# define _GLIBCXX_EXTERN_TEMPLATE 1
/*
Outline of libstdc++ namespaces.
namespace std
{
namespace __debug { }
namespace __parallel { }
namespace __profile { }
namespace __cxx1998 { }
namespace __detail {
namespace __variant { } // C++17
}
namespace rel_ops { }
namespace tr1
{
namespace placeholders { }
namespace regex_constants { }
namespace __detail { }
}
namespace tr2 { }
namespace decimal { }
namespace chrono { } // C++11
namespace placeholders { } // C++11
namespace regex_constants { } // C++11
namespace this_thread { } // C++11
inline namespace literals { // C++14
inline namespace chrono_literals { } // C++14
inline namespace complex_literals { } // C++14
inline namespace string_literals { } // C++14
inline namespace string_view_literals { } // C++17
}
}
namespace abi { }
namespace __gnu_cxx
{
namespace __detail { }
}
For full details see:
http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/namespaces.html
*/
namespace std
{
typedef __SIZE_TYPE__ size_t;
typedef __PTRDIFF_TYPE__ ptrdiff_t;
#if __cplusplus >= 201103L
typedef decltype(nullptr) nullptr_t;
#endif
}
# define _GLIBCXX_USE_DUAL_ABI 1
#if ! _GLIBCXX_USE_DUAL_ABI
// Ignore any pre-defined value of _GLIBCXX_USE_CXX11_ABI
# undef _GLIBCXX_USE_CXX11_ABI
#endif
#ifndef _GLIBCXX_USE_CXX11_ABI
# define _GLIBCXX_USE_CXX11_ABI 1
#endif
#if _GLIBCXX_USE_CXX11_ABI
namespace std
{
inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
}
namespace __gnu_cxx
{
inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
}
# define _GLIBCXX_NAMESPACE_CXX11 __cxx11::
# define _GLIBCXX_BEGIN_NAMESPACE_CXX11 namespace __cxx11 {
# define _GLIBCXX_END_NAMESPACE_CXX11 }
# define _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_ABI_TAG_CXX11
#else
# define _GLIBCXX_NAMESPACE_CXX11
# define _GLIBCXX_BEGIN_NAMESPACE_CXX11
# define _GLIBCXX_END_NAMESPACE_CXX11
# define _GLIBCXX_DEFAULT_ABI_TAG
#endif
// Defined if inline namespaces are used for versioning.
# define _GLIBCXX_INLINE_VERSION 0
// Inline namespace for symbol versioning.
#if _GLIBCXX_INLINE_VERSION
# define _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace __8 {
# define _GLIBCXX_END_NAMESPACE_VERSION }
namespace std
{
inline _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __cplusplus >= 201402L
inline namespace literals {
inline namespace chrono_literals { }
inline namespace complex_literals { }
inline namespace string_literals { }
#if __cplusplus > 201402L
inline namespace string_view_literals { }
#endif // C++17
}
#endif // C++14
_GLIBCXX_END_NAMESPACE_VERSION
}
namespace __gnu_cxx
{
inline _GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_END_NAMESPACE_VERSION
}
#else
# define _GLIBCXX_BEGIN_NAMESPACE_VERSION
# define _GLIBCXX_END_NAMESPACE_VERSION
#endif
// Inline namespaces for special modes: debug, parallel, profile.
#if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PARALLEL) \
|| defined(_GLIBCXX_PROFILE)
namespace std
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Non-inline namespace for components replaced by alternates in active mode.
namespace __cxx1998
{
# if _GLIBCXX_USE_CXX11_ABI
inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
# endif
}
_GLIBCXX_END_NAMESPACE_VERSION
// Inline namespace for debug mode.
# ifdef _GLIBCXX_DEBUG
inline namespace __debug { }
# endif
// Inline namespaces for parallel mode.
# ifdef _GLIBCXX_PARALLEL
inline namespace __parallel { }
# endif
// Inline namespaces for profile mode
# ifdef _GLIBCXX_PROFILE
inline namespace __profile { }
# endif
}
// Check for invalid usage and unsupported mixed-mode use.
# if defined(_GLIBCXX_DEBUG) && defined(_GLIBCXX_PARALLEL)
# error illegal use of multiple inlined namespaces
# endif
# if defined(_GLIBCXX_PROFILE) && defined(_GLIBCXX_DEBUG)
# error illegal use of multiple inlined namespaces
# endif
# if defined(_GLIBCXX_PROFILE) && defined(_GLIBCXX_PARALLEL)
# error illegal use of multiple inlined namespaces
# endif
// Check for invalid use due to lack for weak symbols.
# if __NO_INLINE__ && !__GXX_WEAK__
# warning currently using inlined namespace mode which may fail \
without inlining due to lack of weak symbols
# endif
#endif
// Macros for namespace scope. Either namespace std:: or the name
// of some nested namespace within it corresponding to the active mode.
// _GLIBCXX_STD_A
// _GLIBCXX_STD_C
//
// Macros for opening/closing conditional namespaces.
// _GLIBCXX_BEGIN_NAMESPACE_ALGO
// _GLIBCXX_END_NAMESPACE_ALGO
// _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// _GLIBCXX_END_NAMESPACE_CONTAINER
#if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PROFILE)
# define _GLIBCXX_STD_C __cxx1998
# define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER \
namespace _GLIBCXX_STD_C {
# define _GLIBCXX_END_NAMESPACE_CONTAINER }
#else
# define _GLIBCXX_STD_C std
# define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
# define _GLIBCXX_END_NAMESPACE_CONTAINER
#endif
#ifdef _GLIBCXX_PARALLEL
# define _GLIBCXX_STD_A __cxx1998
# define _GLIBCXX_BEGIN_NAMESPACE_ALGO \
namespace _GLIBCXX_STD_A {
# define _GLIBCXX_END_NAMESPACE_ALGO }
#else
# define _GLIBCXX_STD_A std
# define _GLIBCXX_BEGIN_NAMESPACE_ALGO
# define _GLIBCXX_END_NAMESPACE_ALGO
#endif
// GLIBCXX_ABI Deprecated
// Define if compatibility should be provided for -mlong-double-64.
#undef _GLIBCXX_LONG_DOUBLE_COMPAT
// Inline namespace for long double 128 mode.
#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
namespace std
{
inline namespace __gnu_cxx_ldbl128 { }
}
# define _GLIBCXX_NAMESPACE_LDBL __gnu_cxx_ldbl128::
# define _GLIBCXX_BEGIN_NAMESPACE_LDBL namespace __gnu_cxx_ldbl128 {
# define _GLIBCXX_END_NAMESPACE_LDBL }
#else
# define _GLIBCXX_NAMESPACE_LDBL
# define _GLIBCXX_BEGIN_NAMESPACE_LDBL
# define _GLIBCXX_END_NAMESPACE_LDBL
#endif
#if _GLIBCXX_USE_CXX11_ABI
# define _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_NAMESPACE_CXX11
# define _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_BEGIN_NAMESPACE_CXX11
# define _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_END_NAMESPACE_CXX11
#else
# define _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_NAMESPACE_LDBL
# define _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_BEGIN_NAMESPACE_LDBL
# define _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_END_NAMESPACE_LDBL
#endif
// Debug Mode implies checking assertions.
#if defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_ASSERTIONS)
# define _GLIBCXX_ASSERTIONS 1
#endif
// Disable std::string explicit instantiation declarations in order to assert.
#ifdef _GLIBCXX_ASSERTIONS
# undef _GLIBCXX_EXTERN_TEMPLATE
# define _GLIBCXX_EXTERN_TEMPLATE -1
#endif
// Assert.
#if defined(_GLIBCXX_ASSERTIONS) \
|| defined(_GLIBCXX_PARALLEL) || defined(_GLIBCXX_PARALLEL_ASSERTIONS)
namespace std
{
// Avoid the use of assert, because we're trying to keep the <cassert>
// include out of the mix.
inline void
__replacement_assert(const char* __file, int __line,
const char* __function, const char* __condition)
{
__builtin_printf("%s:%d: %s: Assertion '%s' failed.\n", __file, __line,
__function, __condition);
__builtin_abort();
}
}
#define __glibcxx_assert_impl(_Condition) \
do \
{ \
if (! (_Condition)) \
std::__replacement_assert(__FILE__, __LINE__, __PRETTY_FUNCTION__, \
#_Condition); \
} while (false)
#endif
#if defined(_GLIBCXX_ASSERTIONS)
# define __glibcxx_assert(_Condition) __glibcxx_assert_impl(_Condition)
#else
# define __glibcxx_assert(_Condition)
#endif
// Macros for race detectors.
// _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) and
// _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) should be used to explain
// atomic (lock-free) synchronization to race detectors:
// the race detector will infer a happens-before arc from the former to the
// latter when they share the same argument pointer.
//
// The most frequent use case for these macros (and the only case in the
// current implementation of the library) is atomic reference counting:
// void _M_remove_reference()
// {
// _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
// if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount, -1) <= 0)
// {
// _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
// _M_destroy(__a);
// }
// }
// The annotations in this example tell the race detector that all memory
// accesses occurred when the refcount was positive do not race with
// memory accesses which occurred after the refcount became zero.
#ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE
# define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A)
#endif
#ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER
# define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A)
#endif
// Macros for C linkage: define extern "C" linkage only when using C++.
# define _GLIBCXX_BEGIN_EXTERN_C extern "C" {
# define _GLIBCXX_END_EXTERN_C }
# define _GLIBCXX_USE_ALLOCATOR_NEW 1
#else // !__cplusplus
# define _GLIBCXX_BEGIN_EXTERN_C
# define _GLIBCXX_END_EXTERN_C
#endif
// First includes.
// Pick up any OS-specific definitions.
#include <bits/os_defines.h>
// Pick up any CPU-specific definitions.
#include <bits/cpu_defines.h>
// If platform uses neither visibility nor psuedo-visibility,
// specify empty default for namespace annotation macros.
#ifndef _GLIBCXX_PSEUDO_VISIBILITY
# define _GLIBCXX_PSEUDO_VISIBILITY(V)
#endif
// Certain function definitions that are meant to be overridable from
// user code are decorated with this macro. For some targets, this
// macro causes these definitions to be weak.
#ifndef _GLIBCXX_WEAK_DEFINITION
# define _GLIBCXX_WEAK_DEFINITION
#endif
// By default, we assume that __GXX_WEAK__ also means that there is support
// for declaring functions as weak while not defining such functions. This
// allows for referring to functions provided by other libraries (e.g.,
// libitm) without depending on them if the respective features are not used.
#ifndef _GLIBCXX_USE_WEAK_REF
# define _GLIBCXX_USE_WEAK_REF __GXX_WEAK__
#endif
// Conditionally enable annotations for the Transactional Memory TS on C++11.
// Most of the following conditions are due to limitations in the current
// implementation.
#if __cplusplus >= 201103L && _GLIBCXX_USE_CXX11_ABI \
&& _GLIBCXX_USE_DUAL_ABI && __cpp_transactional_memory >= 201505L \
&& !_GLIBCXX_FULLY_DYNAMIC_STRING && _GLIBCXX_USE_WEAK_REF \
&& _GLIBCXX_USE_ALLOCATOR_NEW
#define _GLIBCXX_TXN_SAFE transaction_safe
#define _GLIBCXX_TXN_SAFE_DYN transaction_safe_dynamic
#else
#define _GLIBCXX_TXN_SAFE
#define _GLIBCXX_TXN_SAFE_DYN
#endif
#if __cplusplus > 201402L
// In C++17 mathematical special functions are in namespace std.
# define _GLIBCXX_USE_STD_SPEC_FUNCS 1
#elif __cplusplus >= 201103L && __STDCPP_WANT_MATH_SPEC_FUNCS__ != 0
// For C++11 and C++14 they are in namespace std when requested.
# define _GLIBCXX_USE_STD_SPEC_FUNCS 1
#endif
// The remainder of the prewritten config is automatic; all the
// user hooks are listed above.
// Create a boolean flag to be used to determine if --fast-math is set.
#ifdef __FAST_MATH__
# define _GLIBCXX_FAST_MATH 1
#else
# define _GLIBCXX_FAST_MATH 0
#endif
// This marks string literals in header files to be extracted for eventual
// translation. It is primarily used for messages in thrown exceptions; see
// src/functexcept.cc. We use __N because the more traditional _N is used
// for something else under certain OSes (see BADNAMES).
#define __N(msgid) (msgid)
// For example, <windows.h> is known to #define min and max as macros...
#undef min
#undef max
// N.B. these _GLIBCXX_USE_C99_XXX macros are defined unconditionally
// so they should be tested with #if not with #ifdef.
#if __cplusplus >= 201103L
# ifndef _GLIBCXX_USE_C99_MATH
# define _GLIBCXX_USE_C99_MATH _GLIBCXX11_USE_C99_MATH
# endif
# ifndef _GLIBCXX_USE_C99_COMPLEX
# define _GLIBCXX_USE_C99_COMPLEX _GLIBCXX11_USE_C99_COMPLEX
# endif
# ifndef _GLIBCXX_USE_C99_STDIO
# define _GLIBCXX_USE_C99_STDIO _GLIBCXX11_USE_C99_STDIO
# endif
# ifndef _GLIBCXX_USE_C99_STDLIB
# define _GLIBCXX_USE_C99_STDLIB _GLIBCXX11_USE_C99_STDLIB
# endif
# ifndef _GLIBCXX_USE_C99_WCHAR
# define _GLIBCXX_USE_C99_WCHAR _GLIBCXX11_USE_C99_WCHAR
# endif
#else
# ifndef _GLIBCXX_USE_C99_MATH
# define _GLIBCXX_USE_C99_MATH _GLIBCXX98_USE_C99_MATH
# endif
# ifndef _GLIBCXX_USE_C99_COMPLEX
# define _GLIBCXX_USE_C99_COMPLEX _GLIBCXX98_USE_C99_COMPLEX
# endif
# ifndef _GLIBCXX_USE_C99_STDIO
# define _GLIBCXX_USE_C99_STDIO _GLIBCXX98_USE_C99_STDIO
# endif
# ifndef _GLIBCXX_USE_C99_STDLIB
# define _GLIBCXX_USE_C99_STDLIB _GLIBCXX98_USE_C99_STDLIB
# endif
# ifndef _GLIBCXX_USE_C99_WCHAR
# define _GLIBCXX_USE_C99_WCHAR _GLIBCXX98_USE_C99_WCHAR
# endif
#endif
/* Define if __float128 is supported on this host. */
#if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
#define _GLIBCXX_USE_FLOAT128 1
#endif
// End of prewritten config; the settings discovered at configure time follow.
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the `acosf' function. */
#define _GLIBCXX_HAVE_ACOSF 1
/* Define to 1 if you have the `acosl' function. */
#define _GLIBCXX_HAVE_ACOSL 1
/* Define to 1 if you have the `aligned_alloc' function. */
#define _GLIBCXX_HAVE_ALIGNED_ALLOC 1
/* Define to 1 if you have the `asinf' function. */
#define _GLIBCXX_HAVE_ASINF 1
/* Define to 1 if you have the `asinl' function. */
#define _GLIBCXX_HAVE_ASINL 1
/* Define to 1 if the target assembler supports .symver directive. */
#define _GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE 1
/* Define to 1 if you have the `atan2f' function. */
#define _GLIBCXX_HAVE_ATAN2F 1
/* Define to 1 if you have the `atan2l' function. */
#define _GLIBCXX_HAVE_ATAN2L 1
/* Define to 1 if you have the `atanf' function. */
#define _GLIBCXX_HAVE_ATANF 1
/* Define to 1 if you have the `atanl' function. */
#define _GLIBCXX_HAVE_ATANL 1
/* Define to 1 if you have the `at_quick_exit' function. */
#define _GLIBCXX_HAVE_AT_QUICK_EXIT 1
/* Define to 1 if the target assembler supports thread-local storage. */
/* #undef _GLIBCXX_HAVE_CC_TLS */
/* Define to 1 if you have the `ceilf' function. */
#define _GLIBCXX_HAVE_CEILF 1
/* Define to 1 if you have the `ceill' function. */
#define _GLIBCXX_HAVE_CEILL 1
/* Define to 1 if you have the <complex.h> header file. */
#define _GLIBCXX_HAVE_COMPLEX_H 1
/* Define to 1 if you have the `cosf' function. */
#define _GLIBCXX_HAVE_COSF 1
/* Define to 1 if you have the `coshf' function. */
#define _GLIBCXX_HAVE_COSHF 1
/* Define to 1 if you have the `coshl' function. */
#define _GLIBCXX_HAVE_COSHL 1
/* Define to 1 if you have the `cosl' function. */
#define _GLIBCXX_HAVE_COSL 1
/* Define to 1 if you have the <dirent.h> header file. */
#define _GLIBCXX_HAVE_DIRENT_H 1
/* Define to 1 if you have the <dlfcn.h> header file. */
#define _GLIBCXX_HAVE_DLFCN_H 1
/* Define if EBADMSG exists. */
#define _GLIBCXX_HAVE_EBADMSG 1
/* Define if ECANCELED exists. */
#define _GLIBCXX_HAVE_ECANCELED 1
/* Define if ECHILD exists. */
#define _GLIBCXX_HAVE_ECHILD 1
/* Define if EIDRM exists. */
#define _GLIBCXX_HAVE_EIDRM 1
/* Define to 1 if you have the <endian.h> header file. */
#define _GLIBCXX_HAVE_ENDIAN_H 1
/* Define if ENODATA exists. */
#define _GLIBCXX_HAVE_ENODATA 1
/* Define if ENOLINK exists. */
#define _GLIBCXX_HAVE_ENOLINK 1
/* Define if ENOSPC exists. */
#define _GLIBCXX_HAVE_ENOSPC 1
/* Define if ENOSR exists. */
#define _GLIBCXX_HAVE_ENOSR 1
/* Define if ENOSTR exists. */
#define _GLIBCXX_HAVE_ENOSTR 1
/* Define if ENOTRECOVERABLE exists. */
#define _GLIBCXX_HAVE_ENOTRECOVERABLE 1
/* Define if ENOTSUP exists. */
#define _GLIBCXX_HAVE_ENOTSUP 1
/* Define if EOVERFLOW exists. */
#define _GLIBCXX_HAVE_EOVERFLOW 1
/* Define if EOWNERDEAD exists. */
#define _GLIBCXX_HAVE_EOWNERDEAD 1
/* Define if EPERM exists. */
#define _GLIBCXX_HAVE_EPERM 1
/* Define if EPROTO exists. */
#define _GLIBCXX_HAVE_EPROTO 1
/* Define if ETIME exists. */
#define _GLIBCXX_HAVE_ETIME 1
/* Define if ETIMEDOUT exists. */
#define _GLIBCXX_HAVE_ETIMEDOUT 1
/* Define if ETXTBSY exists. */
#define _GLIBCXX_HAVE_ETXTBSY 1
/* Define if EWOULDBLOCK exists. */
#define _GLIBCXX_HAVE_EWOULDBLOCK 1
/* Define to 1 if GCC 4.6 supported std::exception_ptr for the target */
#define _GLIBCXX_HAVE_EXCEPTION_PTR_SINCE_GCC46 1
/* Define to 1 if you have the <execinfo.h> header file. */
#define _GLIBCXX_HAVE_EXECINFO_H 1
/* Define to 1 if you have the `expf' function. */
#define _GLIBCXX_HAVE_EXPF 1
/* Define to 1 if you have the `expl' function. */
#define _GLIBCXX_HAVE_EXPL 1
/* Define to 1 if you have the `fabsf' function. */
#define _GLIBCXX_HAVE_FABSF 1
/* Define to 1 if you have the `fabsl' function. */
#define _GLIBCXX_HAVE_FABSL 1
/* Define to 1 if you have the <fcntl.h> header file. */
#define _GLIBCXX_HAVE_FCNTL_H 1
/* Define to 1 if you have the <fenv.h> header file. */
#define _GLIBCXX_HAVE_FENV_H 1
/* Define to 1 if you have the `finite' function. */
#define _GLIBCXX_HAVE_FINITE 1
/* Define to 1 if you have the `finitef' function. */
#define _GLIBCXX_HAVE_FINITEF 1
/* Define to 1 if you have the `finitel' function. */
#define _GLIBCXX_HAVE_FINITEL 1
/* Define to 1 if you have the <float.h> header file. */
#define _GLIBCXX_HAVE_FLOAT_H 1
/* Define to 1 if you have the `floorf' function. */
#define _GLIBCXX_HAVE_FLOORF 1
/* Define to 1 if you have the `floorl' function. */
#define _GLIBCXX_HAVE_FLOORL 1
/* Define to 1 if you have the `fmodf' function. */
#define _GLIBCXX_HAVE_FMODF 1
/* Define to 1 if you have the `fmodl' function. */
#define _GLIBCXX_HAVE_FMODL 1
/* Define to 1 if you have the `fpclass' function. */
/* #undef _GLIBCXX_HAVE_FPCLASS */
/* Define to 1 if you have the <fp.h> header file. */
/* #undef _GLIBCXX_HAVE_FP_H */
/* Define to 1 if you have the `frexpf' function. */
#define _GLIBCXX_HAVE_FREXPF 1
/* Define to 1 if you have the `frexpl' function. */
#define _GLIBCXX_HAVE_FREXPL 1
/* Define if _Unwind_GetIPInfo is available. */
#define _GLIBCXX_HAVE_GETIPINFO 1
/* Define if gets is available in <stdio.h> before C++14. */
#define _GLIBCXX_HAVE_GETS 1
/* Define to 1 if you have the `hypot' function. */
#define _GLIBCXX_HAVE_HYPOT 1
/* Define to 1 if you have the `hypotf' function. */
#define _GLIBCXX_HAVE_HYPOTF 1
/* Define to 1 if you have the `hypotl' function. */
#define _GLIBCXX_HAVE_HYPOTL 1
/* Define if you have the iconv() function. */
#define _GLIBCXX_HAVE_ICONV 1
/* Define to 1 if you have the <ieeefp.h> header file. */
/* #undef _GLIBCXX_HAVE_IEEEFP_H */
/* Define if int64_t is available in <stdint.h>. */
#define _GLIBCXX_HAVE_INT64_T 1
/* Define if int64_t is a long. */
#define _GLIBCXX_HAVE_INT64_T_LONG 1
/* Define if int64_t is a long long. */
/* #undef _GLIBCXX_HAVE_INT64_T_LONG_LONG */
/* Define to 1 if you have the <inttypes.h> header file. */
#define _GLIBCXX_HAVE_INTTYPES_H 1
/* Define to 1 if you have the `isinf' function. */
/* #undef _GLIBCXX_HAVE_ISINF */
/* Define to 1 if you have the `isinff' function. */
#define _GLIBCXX_HAVE_ISINFF 1
/* Define to 1 if you have the `isinfl' function. */
#define _GLIBCXX_HAVE_ISINFL 1
/* Define to 1 if you have the `isnan' function. */
/* #undef _GLIBCXX_HAVE_ISNAN */
/* Define to 1 if you have the `isnanf' function. */
#define _GLIBCXX_HAVE_ISNANF 1
/* Define to 1 if you have the `isnanl' function. */
#define _GLIBCXX_HAVE_ISNANL 1
/* Defined if iswblank exists. */
#define _GLIBCXX_HAVE_ISWBLANK 1
/* Define if LC_MESSAGES is available in <locale.h>. */
#define _GLIBCXX_HAVE_LC_MESSAGES 1
/* Define to 1 if you have the `ldexpf' function. */
#define _GLIBCXX_HAVE_LDEXPF 1
/* Define to 1 if you have the `ldexpl' function. */
#define _GLIBCXX_HAVE_LDEXPL 1
/* Define to 1 if you have the <libintl.h> header file. */
#define _GLIBCXX_HAVE_LIBINTL_H 1
/* Only used in build directory testsuite_hooks.h. */
#define _GLIBCXX_HAVE_LIMIT_AS 1
/* Only used in build directory testsuite_hooks.h. */
#define _GLIBCXX_HAVE_LIMIT_DATA 1
/* Only used in build directory testsuite_hooks.h. */
#define _GLIBCXX_HAVE_LIMIT_FSIZE 1
/* Only used in build directory testsuite_hooks.h. */
#define _GLIBCXX_HAVE_LIMIT_RSS 1
/* Only used in build directory testsuite_hooks.h. */
#define _GLIBCXX_HAVE_LIMIT_VMEM 0
/* Define if futex syscall is available. */
#define _GLIBCXX_HAVE_LINUX_FUTEX 1
/* Define to 1 if you have the <linux/random.h> header file. */
#define _GLIBCXX_HAVE_LINUX_RANDOM_H 1
/* Define to 1 if you have the <linux/types.h> header file. */
#define _GLIBCXX_HAVE_LINUX_TYPES_H 1
/* Define to 1 if you have the <locale.h> header file. */
#define _GLIBCXX_HAVE_LOCALE_H 1
/* Define to 1 if you have the `log10f' function. */
#define _GLIBCXX_HAVE_LOG10F 1
/* Define to 1 if you have the `log10l' function. */
#define _GLIBCXX_HAVE_LOG10L 1
/* Define to 1 if you have the `logf' function. */
#define _GLIBCXX_HAVE_LOGF 1
/* Define to 1 if you have the `logl' function. */
#define _GLIBCXX_HAVE_LOGL 1
/* Define to 1 if you have the <machine/endian.h> header file. */
/* #undef _GLIBCXX_HAVE_MACHINE_ENDIAN_H */
/* Define to 1 if you have the <machine/param.h> header file. */
/* #undef _GLIBCXX_HAVE_MACHINE_PARAM_H */
/* Define if mbstate_t exists in wchar.h. */
#define _GLIBCXX_HAVE_MBSTATE_T 1
/* Define to 1 if you have the `memalign' function. */
#define _GLIBCXX_HAVE_MEMALIGN 1
/* Define to 1 if you have the <memory.h> header file. */
#define _GLIBCXX_HAVE_MEMORY_H 1
/* Define to 1 if you have the `modf' function. */
#define _GLIBCXX_HAVE_MODF 1
/* Define to 1 if you have the `modff' function. */
#define _GLIBCXX_HAVE_MODFF 1
/* Define to 1 if you have the `modfl' function. */
#define _GLIBCXX_HAVE_MODFL 1
/* Define to 1 if you have the <nan.h> header file. */
/* #undef _GLIBCXX_HAVE_NAN_H */
/* Define if <math.h> defines obsolete isinf function. */
/* #undef _GLIBCXX_HAVE_OBSOLETE_ISINF */
/* Define if <math.h> defines obsolete isnan function. */
/* #undef _GLIBCXX_HAVE_OBSOLETE_ISNAN */
/* Define if poll is available in <poll.h>. */
#define _GLIBCXX_HAVE_POLL 1
/* Define to 1 if you have the `posix_memalign' function. */
#define _GLIBCXX_HAVE_POSIX_MEMALIGN 1
/* Define to 1 if you have the `powf' function. */
#define _GLIBCXX_HAVE_POWF 1
/* Define to 1 if you have the `powl' function. */
#define _GLIBCXX_HAVE_POWL 1
/* Define to 1 if you have the `qfpclass' function. */
/* #undef _GLIBCXX_HAVE_QFPCLASS */
/* Define to 1 if you have the `quick_exit' function. */
#define _GLIBCXX_HAVE_QUICK_EXIT 1
/* Define to 1 if you have the `setenv' function. */
#define _GLIBCXX_HAVE_SETENV 1
/* Define to 1 if you have the `sincos' function. */
#define _GLIBCXX_HAVE_SINCOS 1
/* Define to 1 if you have the `sincosf' function. */
#define _GLIBCXX_HAVE_SINCOSF 1
/* Define to 1 if you have the `sincosl' function. */
#define _GLIBCXX_HAVE_SINCOSL 1
/* Define to 1 if you have the `sinf' function. */
#define _GLIBCXX_HAVE_SINF 1
/* Define to 1 if you have the `sinhf' function. */
#define _GLIBCXX_HAVE_SINHF 1
/* Define to 1 if you have the `sinhl' function. */
#define _GLIBCXX_HAVE_SINHL 1
/* Define to 1 if you have the `sinl' function. */
#define _GLIBCXX_HAVE_SINL 1
/* Defined if sleep exists. */
/* #undef _GLIBCXX_HAVE_SLEEP */
/* Define to 1 if you have the `sqrtf' function. */
#define _GLIBCXX_HAVE_SQRTF 1
/* Define to 1 if you have the `sqrtl' function. */
#define _GLIBCXX_HAVE_SQRTL 1
/* Define to 1 if you have the <stdalign.h> header file. */
#define _GLIBCXX_HAVE_STDALIGN_H 1
/* Define to 1 if you have the <stdbool.h> header file. */
#define _GLIBCXX_HAVE_STDBOOL_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#define _GLIBCXX_HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define _GLIBCXX_HAVE_STDLIB_H 1
/* Define if strerror_l is available in <string.h>. */
#define _GLIBCXX_HAVE_STRERROR_L 1
/* Define if strerror_r is available in <string.h>. */
#define _GLIBCXX_HAVE_STRERROR_R 1
/* Define to 1 if you have the <strings.h> header file. */
#define _GLIBCXX_HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define _GLIBCXX_HAVE_STRING_H 1
/* Define to 1 if you have the `strtof' function. */
#define _GLIBCXX_HAVE_STRTOF 1
/* Define to 1 if you have the `strtold' function. */
#define _GLIBCXX_HAVE_STRTOLD 1
/* Define to 1 if `d_type' is a member of `struct dirent'. */
#define _GLIBCXX_HAVE_STRUCT_DIRENT_D_TYPE 1
/* Define if strxfrm_l is available in <string.h>. */
#define _GLIBCXX_HAVE_STRXFRM_L 1
/* Define to 1 if the target runtime linker supports binding the same symbol
to different versions. */
#define _GLIBCXX_HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT 1
/* Define to 1 if you have the <sys/filio.h> header file. */
/* #undef _GLIBCXX_HAVE_SYS_FILIO_H */
/* Define to 1 if you have the <sys/ioctl.h> header file. */
#define _GLIBCXX_HAVE_SYS_IOCTL_H 1
/* Define to 1 if you have the <sys/ipc.h> header file. */
#define _GLIBCXX_HAVE_SYS_IPC_H 1
/* Define to 1 if you have the <sys/isa_defs.h> header file. */
/* #undef _GLIBCXX_HAVE_SYS_ISA_DEFS_H */
/* Define to 1 if you have the <sys/machine.h> header file. */
/* #undef _GLIBCXX_HAVE_SYS_MACHINE_H */
/* Define to 1 if you have the <sys/param.h> header file. */
#define _GLIBCXX_HAVE_SYS_PARAM_H 1
/* Define to 1 if you have the <sys/resource.h> header file. */
#define _GLIBCXX_HAVE_SYS_RESOURCE_H 1
/* Define to 1 if you have a suitable <sys/sdt.h> header file */
#define _GLIBCXX_HAVE_SYS_SDT_H 1
/* Define to 1 if you have the <sys/sem.h> header file. */
#define _GLIBCXX_HAVE_SYS_SEM_H 1
/* Define to 1 if you have the <sys/statvfs.h> header file. */
#define _GLIBCXX_HAVE_SYS_STATVFS_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define _GLIBCXX_HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/sysinfo.h> header file. */
#define _GLIBCXX_HAVE_SYS_SYSINFO_H 1
/* Define to 1 if you have the <sys/time.h> header file. */
#define _GLIBCXX_HAVE_SYS_TIME_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define _GLIBCXX_HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <sys/uio.h> header file. */
#define _GLIBCXX_HAVE_SYS_UIO_H 1
/* Define if S_IFREG is available in <sys/stat.h>. */
/* #undef _GLIBCXX_HAVE_S_IFREG */
/* Define if S_ISREG is available in <sys/stat.h>. */
#define _GLIBCXX_HAVE_S_ISREG 1
/* Define to 1 if you have the `tanf' function. */
#define _GLIBCXX_HAVE_TANF 1
/* Define to 1 if you have the `tanhf' function. */
#define _GLIBCXX_HAVE_TANHF 1
/* Define to 1 if you have the `tanhl' function. */
#define _GLIBCXX_HAVE_TANHL 1
/* Define to 1 if you have the `tanl' function. */
#define _GLIBCXX_HAVE_TANL 1
/* Define to 1 if you have the <tgmath.h> header file. */
#define _GLIBCXX_HAVE_TGMATH_H 1
/* Define to 1 if the target supports thread-local storage. */
#define _GLIBCXX_HAVE_TLS 1
/* Define to 1 if you have the <uchar.h> header file. */
#define _GLIBCXX_HAVE_UCHAR_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define _GLIBCXX_HAVE_UNISTD_H 1
/* Defined if usleep exists. */
/* #undef _GLIBCXX_HAVE_USLEEP */
/* Define to 1 if you have the <utime.h> header file. */
#define _GLIBCXX_HAVE_UTIME_H 1
/* Defined if vfwscanf exists. */
#define _GLIBCXX_HAVE_VFWSCANF 1
/* Defined if vswscanf exists. */
#define _GLIBCXX_HAVE_VSWSCANF 1
/* Defined if vwscanf exists. */
#define _GLIBCXX_HAVE_VWSCANF 1
/* Define to 1 if you have the <wchar.h> header file. */
#define _GLIBCXX_HAVE_WCHAR_H 1
/* Defined if wcstof exists. */
#define _GLIBCXX_HAVE_WCSTOF 1
/* Define to 1 if you have the <wctype.h> header file. */
#define _GLIBCXX_HAVE_WCTYPE_H 1
/* Defined if Sleep exists. */
/* #undef _GLIBCXX_HAVE_WIN32_SLEEP */
/* Define if writev is available in <sys/uio.h>. */
#define _GLIBCXX_HAVE_WRITEV 1
/* Define to 1 if you have the `_acosf' function. */
/* #undef _GLIBCXX_HAVE__ACOSF */
/* Define to 1 if you have the `_acosl' function. */
/* #undef _GLIBCXX_HAVE__ACOSL */
/* Define to 1 if you have the `_aligned_malloc' function. */
/* #undef _GLIBCXX_HAVE__ALIGNED_MALLOC */
/* Define to 1 if you have the `_asinf' function. */
/* #undef _GLIBCXX_HAVE__ASINF */
/* Define to 1 if you have the `_asinl' function. */
/* #undef _GLIBCXX_HAVE__ASINL */
/* Define to 1 if you have the `_atan2f' function. */
/* #undef _GLIBCXX_HAVE__ATAN2F */
/* Define to 1 if you have the `_atan2l' function. */
/* #undef _GLIBCXX_HAVE__ATAN2L */
/* Define to 1 if you have the `_atanf' function. */
/* #undef _GLIBCXX_HAVE__ATANF */
/* Define to 1 if you have the `_atanl' function. */
/* #undef _GLIBCXX_HAVE__ATANL */
/* Define to 1 if you have the `_ceilf' function. */
/* #undef _GLIBCXX_HAVE__CEILF */
/* Define to 1 if you have the `_ceill' function. */
/* #undef _GLIBCXX_HAVE__CEILL */
/* Define to 1 if you have the `_cosf' function. */
/* #undef _GLIBCXX_HAVE__COSF */
/* Define to 1 if you have the `_coshf' function. */
/* #undef _GLIBCXX_HAVE__COSHF */
/* Define to 1 if you have the `_coshl' function. */
/* #undef _GLIBCXX_HAVE__COSHL */
/* Define to 1 if you have the `_cosl' function. */
/* #undef _GLIBCXX_HAVE__COSL */
/* Define to 1 if you have the `_expf' function. */
/* #undef _GLIBCXX_HAVE__EXPF */
/* Define to 1 if you have the `_expl' function. */
/* #undef _GLIBCXX_HAVE__EXPL */
/* Define to 1 if you have the `_fabsf' function. */
/* #undef _GLIBCXX_HAVE__FABSF */
/* Define to 1 if you have the `_fabsl' function. */
/* #undef _GLIBCXX_HAVE__FABSL */
/* Define to 1 if you have the `_finite' function. */
/* #undef _GLIBCXX_HAVE__FINITE */
/* Define to 1 if you have the `_finitef' function. */
/* #undef _GLIBCXX_HAVE__FINITEF */
/* Define to 1 if you have the `_finitel' function. */
/* #undef _GLIBCXX_HAVE__FINITEL */
/* Define to 1 if you have the `_floorf' function. */
/* #undef _GLIBCXX_HAVE__FLOORF */
/* Define to 1 if you have the `_floorl' function. */
/* #undef _GLIBCXX_HAVE__FLOORL */
/* Define to 1 if you have the `_fmodf' function. */
/* #undef _GLIBCXX_HAVE__FMODF */
/* Define to 1 if you have the `_fmodl' function. */
/* #undef _GLIBCXX_HAVE__FMODL */
/* Define to 1 if you have the `_fpclass' function. */
/* #undef _GLIBCXX_HAVE__FPCLASS */
/* Define to 1 if you have the `_frexpf' function. */
/* #undef _GLIBCXX_HAVE__FREXPF */
/* Define to 1 if you have the `_frexpl' function. */
/* #undef _GLIBCXX_HAVE__FREXPL */
/* Define to 1 if you have the `_hypot' function. */
/* #undef _GLIBCXX_HAVE__HYPOT */
/* Define to 1 if you have the `_hypotf' function. */
/* #undef _GLIBCXX_HAVE__HYPOTF */
/* Define to 1 if you have the `_hypotl' function. */
/* #undef _GLIBCXX_HAVE__HYPOTL */
/* Define to 1 if you have the `_isinf' function. */
/* #undef _GLIBCXX_HAVE__ISINF */
/* Define to 1 if you have the `_isinff' function. */
/* #undef _GLIBCXX_HAVE__ISINFF */
/* Define to 1 if you have the `_isinfl' function. */
/* #undef _GLIBCXX_HAVE__ISINFL */
/* Define to 1 if you have the `_isnan' function. */
/* #undef _GLIBCXX_HAVE__ISNAN */
/* Define to 1 if you have the `_isnanf' function. */
/* #undef _GLIBCXX_HAVE__ISNANF */
/* Define to 1 if you have the `_isnanl' function. */
/* #undef _GLIBCXX_HAVE__ISNANL */
/* Define to 1 if you have the `_ldexpf' function. */
/* #undef _GLIBCXX_HAVE__LDEXPF */
/* Define to 1 if you have the `_ldexpl' function. */
/* #undef _GLIBCXX_HAVE__LDEXPL */
/* Define to 1 if you have the `_log10f' function. */
/* #undef _GLIBCXX_HAVE__LOG10F */
/* Define to 1 if you have the `_log10l' function. */
/* #undef _GLIBCXX_HAVE__LOG10L */
/* Define to 1 if you have the `_logf' function. */
/* #undef _GLIBCXX_HAVE__LOGF */
/* Define to 1 if you have the `_logl' function. */
/* #undef _GLIBCXX_HAVE__LOGL */
/* Define to 1 if you have the `_modf' function. */
/* #undef _GLIBCXX_HAVE__MODF */
/* Define to 1 if you have the `_modff' function. */
/* #undef _GLIBCXX_HAVE__MODFF */
/* Define to 1 if you have the `_modfl' function. */
/* #undef _GLIBCXX_HAVE__MODFL */
/* Define to 1 if you have the `_powf' function. */
/* #undef _GLIBCXX_HAVE__POWF */
/* Define to 1 if you have the `_powl' function. */
/* #undef _GLIBCXX_HAVE__POWL */
/* Define to 1 if you have the `_qfpclass' function. */
/* #undef _GLIBCXX_HAVE__QFPCLASS */
/* Define to 1 if you have the `_sincos' function. */
/* #undef _GLIBCXX_HAVE__SINCOS */
/* Define to 1 if you have the `_sincosf' function. */
/* #undef _GLIBCXX_HAVE__SINCOSF */
/* Define to 1 if you have the `_sincosl' function. */
/* #undef _GLIBCXX_HAVE__SINCOSL */
/* Define to 1 if you have the `_sinf' function. */
/* #undef _GLIBCXX_HAVE__SINF */
/* Define to 1 if you have the `_sinhf' function. */
/* #undef _GLIBCXX_HAVE__SINHF */
/* Define to 1 if you have the `_sinhl' function. */
/* #undef _GLIBCXX_HAVE__SINHL */
/* Define to 1 if you have the `_sinl' function. */
/* #undef _GLIBCXX_HAVE__SINL */
/* Define to 1 if you have the `_sqrtf' function. */
/* #undef _GLIBCXX_HAVE__SQRTF */
/* Define to 1 if you have the `_sqrtl' function. */
/* #undef _GLIBCXX_HAVE__SQRTL */
/* Define to 1 if you have the `_tanf' function. */
/* #undef _GLIBCXX_HAVE__TANF */
/* Define to 1 if you have the `_tanhf' function. */
/* #undef _GLIBCXX_HAVE__TANHF */
/* Define to 1 if you have the `_tanhl' function. */
/* #undef _GLIBCXX_HAVE__TANHL */
/* Define to 1 if you have the `_tanl' function. */
/* #undef _GLIBCXX_HAVE__TANL */
/* Define to 1 if you have the `__cxa_thread_atexit' function. */
/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT */
/* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
/* Define as const if the declaration of iconv() needs const. */
#define _GLIBCXX_ICONV_CONST
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#define LT_OBJDIR ".libs/"
/* Name of package */
/* #undef _GLIBCXX_PACKAGE */
/* Define to the address where bug reports for this package should be sent. */
#define _GLIBCXX_PACKAGE_BUGREPORT ""
/* Define to the full name of this package. */
#define _GLIBCXX_PACKAGE_NAME "package-unused"
/* Define to the full name and version of this package. */
#define _GLIBCXX_PACKAGE_STRING "package-unused version-unused"
/* Define to the one symbol short name of this package. */
#define _GLIBCXX_PACKAGE_TARNAME "libstdc++"
/* Define to the home page for this package. */
#define _GLIBCXX_PACKAGE_URL ""
/* Define to the version of this package. */
#define _GLIBCXX_PACKAGE__GLIBCXX_VERSION "version-unused"
/* The size of `char', as computed by sizeof. */
/* #undef SIZEOF_CHAR */
/* The size of `int', as computed by sizeof. */
/* #undef SIZEOF_INT */
/* The size of `long', as computed by sizeof. */
/* #undef SIZEOF_LONG */
/* The size of `short', as computed by sizeof. */
/* #undef SIZEOF_SHORT */
/* The size of `void *', as computed by sizeof. */
/* #undef SIZEOF_VOID_P */
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Version number of package */
/* #undef _GLIBCXX_VERSION */
/* Number of bits in a file offset, on hosts where this is settable. */
/* #undef _GLIBCXX_FILE_OFFSET_BITS */
/* Define if C99 functions in <complex.h> should be used in <complex> for
C++11. Using compiler builtins for these functions requires corresponding
C99 library functions to be present. */
#define _GLIBCXX11_USE_C99_COMPLEX 1
/* Define if C99 functions or macros in <math.h> should be imported in <cmath>
in namespace std for C++11. */
#define _GLIBCXX11_USE_C99_MATH 1
/* Define if C99 functions or macros in <stdio.h> should be imported in
<cstdio> in namespace std for C++11. */
#define _GLIBCXX11_USE_C99_STDIO 1
/* Define if C99 functions or macros in <stdlib.h> should be imported in
<cstdlib> in namespace std for C++11. */
#define _GLIBCXX11_USE_C99_STDLIB 1
/* Define if C99 functions or macros in <wchar.h> should be imported in
<cwchar> in namespace std for C++11. */
#define _GLIBCXX11_USE_C99_WCHAR 1
/* Define if C99 functions in <complex.h> should be used in <complex> for
C++98. Using compiler builtins for these functions requires corresponding
C99 library functions to be present. */
#define _GLIBCXX98_USE_C99_COMPLEX 1
/* Define if C99 functions or macros in <math.h> should be imported in <cmath>
in namespace std for C++98. */
#define _GLIBCXX98_USE_C99_MATH 1
/* Define if C99 functions or macros in <stdio.h> should be imported in
<cstdio> in namespace std for C++98. */
#define _GLIBCXX98_USE_C99_STDIO 1
/* Define if C99 functions or macros in <stdlib.h> should be imported in
<cstdlib> in namespace std for C++98. */
#define _GLIBCXX98_USE_C99_STDLIB 1
/* Define if C99 functions or macros in <wchar.h> should be imported in
<cwchar> in namespace std for C++98. */
#define _GLIBCXX98_USE_C99_WCHAR 1
/* Define if the compiler supports C++11 atomics. */
#define _GLIBCXX_ATOMIC_BUILTINS 1
/* Define to use concept checking code from the boost libraries. */
/* #undef _GLIBCXX_CONCEPT_CHECKS */
/* Define to 1 if a fully dynamic basic_string is wanted, 0 to disable,
undefined for platform defaults */
#define _GLIBCXX_FULLY_DYNAMIC_STRING 0
/* Define if gthreads library is available. */
#define _GLIBCXX_HAS_GTHREADS 1
/* Define to 1 if a full hosted library is built, or 0 if freestanding. */
#define _GLIBCXX_HOSTED 1
/* Define if compatibility should be provided for -mlong-double-64. */
/* Define to the letter to which size_t is mangled. */
#define _GLIBCXX_MANGLE_SIZE_T m
/* Define if C99 llrint and llround functions are missing from <math.h>. */
/* #undef _GLIBCXX_NO_C99_ROUNDING_FUNCS */
/* Define if ptrdiff_t is int. */
/* #undef _GLIBCXX_PTRDIFF_T_IS_INT */
/* Define if using setrlimit to set resource limits during "make check" */
#define _GLIBCXX_RES_LIMITS 1
/* Define if size_t is unsigned int. */
/* #undef _GLIBCXX_SIZE_T_IS_UINT */
/* Define to the value of the EOF integer constant. */
#define _GLIBCXX_STDIO_EOF -1
/* Define to the value of the SEEK_CUR integer constant. */
#define _GLIBCXX_STDIO_SEEK_CUR 1
/* Define to the value of the SEEK_END integer constant. */
#define _GLIBCXX_STDIO_SEEK_END 2
/* Define to use symbol versioning in the shared library. */
#define _GLIBCXX_SYMVER 1
/* Define to use darwin versioning in the shared library. */
/* #undef _GLIBCXX_SYMVER_DARWIN */
/* Define to use GNU versioning in the shared library. */
#define _GLIBCXX_SYMVER_GNU 1
/* Define to use GNU namespace versioning in the shared library. */
/* #undef _GLIBCXX_SYMVER_GNU_NAMESPACE */
/* Define to use Sun versioning in the shared library. */
/* #undef _GLIBCXX_SYMVER_SUN */
/* Define if C11 functions in <uchar.h> should be imported into namespace std
in <cuchar>. */
#define _GLIBCXX_USE_C11_UCHAR_CXX11 1
/* Define if C99 functions or macros from <wchar.h>, <math.h>, <complex.h>,
<stdio.h>, and <stdlib.h> can be used or exposed. */
#define _GLIBCXX_USE_C99 1
/* Define if C99 functions in <complex.h> should be used in <tr1/complex>.
Using compiler builtins for these functions requires corresponding C99
library functions to be present. */
#define _GLIBCXX_USE_C99_COMPLEX_TR1 1
/* Define if C99 functions in <ctype.h> should be imported in <tr1/cctype> in
namespace std::tr1. */
#define _GLIBCXX_USE_C99_CTYPE_TR1 1
/* Define if C99 functions in <fenv.h> should be imported in <tr1/cfenv> in
namespace std::tr1. */
#define _GLIBCXX_USE_C99_FENV_TR1 1
/* Define if C99 functions in <inttypes.h> should be imported in
<tr1/cinttypes> in namespace std::tr1. */
#define _GLIBCXX_USE_C99_INTTYPES_TR1 1
/* Define if wchar_t C99 functions in <inttypes.h> should be imported in
<tr1/cinttypes> in namespace std::tr1. */
#define _GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1 1
/* Define if C99 functions or macros in <math.h> should be imported in
<tr1/cmath> in namespace std::tr1. */
#define _GLIBCXX_USE_C99_MATH_TR1 1
/* Define if C99 types in <stdint.h> should be imported in <tr1/cstdint> in
namespace std::tr1. */
#define _GLIBCXX_USE_C99_STDINT_TR1 1
/* Defined if clock_gettime syscall has monotonic and realtime clock support.
*/
/* #undef _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL */
/* Defined if clock_gettime has monotonic clock support. */
#define _GLIBCXX_USE_CLOCK_MONOTONIC 1
/* Defined if clock_gettime has realtime clock support. */
#define _GLIBCXX_USE_CLOCK_REALTIME 1
/* Define if ISO/IEC TR 24733 decimal floating point types are supported on
this host. */
#define _GLIBCXX_USE_DECIMAL_FLOAT 1
/* Define if fchmod is available in <sys/stat.h>. */
#define _GLIBCXX_USE_FCHMOD 1
/* Define if fchmodat is available in <sys/stat.h>. */
#define _GLIBCXX_USE_FCHMODAT 1
/* Defined if gettimeofday is available. */
#define _GLIBCXX_USE_GETTIMEOFDAY 1
/* Define if get_nprocs is available in <sys/sysinfo.h>. */
#define _GLIBCXX_USE_GET_NPROCS 1
/* Define if __int128 is supported on this host. */
#define _GLIBCXX_USE_INT128 1
/* Define if LFS support is available. */
#define _GLIBCXX_USE_LFS 1
/* Define if code specialized for long long should be used. */
#define _GLIBCXX_USE_LONG_LONG 1
/* Defined if nanosleep is available. */
#define _GLIBCXX_USE_NANOSLEEP 1
/* Define if NLS translations are to be used. */
#define _GLIBCXX_USE_NLS 1
/* Define if pthreads_num_processors_np is available in <pthread.h>. */
/* #undef _GLIBCXX_USE_PTHREADS_NUM_PROCESSORS_NP */
/* Define if POSIX read/write locks are available in <gthr.h>. */
#define _GLIBCXX_USE_PTHREAD_RWLOCK_T 1
/* Define if /dev/random and /dev/urandom are available for the random_device
of TR1 (Chapter 5.1). */
#define _GLIBCXX_USE_RANDOM_TR1 1
/* Define if usable realpath is available in <stdlib.h>. */
#define _GLIBCXX_USE_REALPATH 1
/* Defined if sched_yield is available. */
#define _GLIBCXX_USE_SCHED_YIELD 1
/* Define if _SC_NPROCESSORS_ONLN is available in <unistd.h>. */
#define _GLIBCXX_USE_SC_NPROCESSORS_ONLN 1
/* Define if _SC_NPROC_ONLN is available in <unistd.h>. */
/* #undef _GLIBCXX_USE_SC_NPROC_ONLN */
/* Define if sendfile is available in <sys/sendfile.h>. */
#define _GLIBCXX_USE_SENDFILE 1
/* Define if struct stat has timespec members. */
#define _GLIBCXX_USE_ST_MTIM 1
/* Define if sysctl(), CTL_HW and HW_NCPU are available in <sys/sysctl.h>. */
/* #undef _GLIBCXX_USE_SYSCTL_HW_NCPU */
/* Define if obsolescent tmpnam is available in <stdio.h>. */
#define _GLIBCXX_USE_TMPNAM 1
/* Define if utimensat and UTIME_OMIT are available in <sys/stat.h> and
AT_FDCWD in <fcntl.h>. */
#define _GLIBCXX_USE_UTIMENSAT 1
/* Define if code specialized for wchar_t should be used. */
#define _GLIBCXX_USE_WCHAR_T 1
/* Define to 1 if a verbose library is built, or 0 otherwise. */
#define _GLIBCXX_VERBOSE 1
/* Defined if as can handle rdrand. */
#define _GLIBCXX_X86_RDRAND 1
/* Define to 1 if mutex_timedlock is available. */
#define _GTHREAD_USE_MUTEX_TIMEDLOCK 1
/* Define for large files, on AIX-style hosts. */
/* #undef _GLIBCXX_LARGE_FILES */
/* Define if all C++11 floating point overloads are available in <math.h>. */
#if __cplusplus >= 201103L
/* #undef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP */
#endif
/* Define if all C++11 integral type overloads are available in <math.h>. */
#if __cplusplus >= 201103L
/* #undef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT */
#endif
#if defined (_GLIBCXX_HAVE__ACOSF) && ! defined (_GLIBCXX_HAVE_ACOSF)
# define _GLIBCXX_HAVE_ACOSF 1
# define acosf _acosf
#endif
#if defined (_GLIBCXX_HAVE__ACOSL) && ! defined (_GLIBCXX_HAVE_ACOSL)
# define _GLIBCXX_HAVE_ACOSL 1
# define acosl _acosl
#endif
#if defined (_GLIBCXX_HAVE__ASINF) && ! defined (_GLIBCXX_HAVE_ASINF)
# define _GLIBCXX_HAVE_ASINF 1
# define asinf _asinf
#endif
#if defined (_GLIBCXX_HAVE__ASINL) && ! defined (_GLIBCXX_HAVE_ASINL)
# define _GLIBCXX_HAVE_ASINL 1
# define asinl _asinl
#endif
#if defined (_GLIBCXX_HAVE__ATAN2F) && ! defined (_GLIBCXX_HAVE_ATAN2F)
# define _GLIBCXX_HAVE_ATAN2F 1
# define atan2f _atan2f
#endif
#if defined (_GLIBCXX_HAVE__ATAN2L) && ! defined (_GLIBCXX_HAVE_ATAN2L)
# define _GLIBCXX_HAVE_ATAN2L 1
# define atan2l _atan2l
#endif
#if defined (_GLIBCXX_HAVE__ATANF) && ! defined (_GLIBCXX_HAVE_ATANF)
# define _GLIBCXX_HAVE_ATANF 1
# define atanf _atanf
#endif
#if defined (_GLIBCXX_HAVE__ATANL) && ! defined (_GLIBCXX_HAVE_ATANL)
# define _GLIBCXX_HAVE_ATANL 1
# define atanl _atanl
#endif
#if defined (_GLIBCXX_HAVE__CEILF) && ! defined (_GLIBCXX_HAVE_CEILF)
# define _GLIBCXX_HAVE_CEILF 1
# define ceilf _ceilf
#endif
#if defined (_GLIBCXX_HAVE__CEILL) && ! defined (_GLIBCXX_HAVE_CEILL)
# define _GLIBCXX_HAVE_CEILL 1
# define ceill _ceill
#endif
#if defined (_GLIBCXX_HAVE__COSF) && ! defined (_GLIBCXX_HAVE_COSF)
# define _GLIBCXX_HAVE_COSF 1
# define cosf _cosf
#endif
#if defined (_GLIBCXX_HAVE__COSHF) && ! defined (_GLIBCXX_HAVE_COSHF)
# define _GLIBCXX_HAVE_COSHF 1
# define coshf _coshf
#endif
#if defined (_GLIBCXX_HAVE__COSHL) && ! defined (_GLIBCXX_HAVE_COSHL)
# define _GLIBCXX_HAVE_COSHL 1
# define coshl _coshl
#endif
#if defined (_GLIBCXX_HAVE__COSL) && ! defined (_GLIBCXX_HAVE_COSL)
# define _GLIBCXX_HAVE_COSL 1
# define cosl _cosl
#endif
#if defined (_GLIBCXX_HAVE__EXPF) && ! defined (_GLIBCXX_HAVE_EXPF)
# define _GLIBCXX_HAVE_EXPF 1
# define expf _expf
#endif
#if defined (_GLIBCXX_HAVE__EXPL) && ! defined (_GLIBCXX_HAVE_EXPL)
# define _GLIBCXX_HAVE_EXPL 1
# define expl _expl
#endif
#if defined (_GLIBCXX_HAVE__FABSF) && ! defined (_GLIBCXX_HAVE_FABSF)
# define _GLIBCXX_HAVE_FABSF 1
# define fabsf _fabsf
#endif
#if defined (_GLIBCXX_HAVE__FABSL) && ! defined (_GLIBCXX_HAVE_FABSL)
# define _GLIBCXX_HAVE_FABSL 1
# define fabsl _fabsl
#endif
#if defined (_GLIBCXX_HAVE__FINITE) && ! defined (_GLIBCXX_HAVE_FINITE)
# define _GLIBCXX_HAVE_FINITE 1
# define finite _finite
#endif
#if defined (_GLIBCXX_HAVE__FINITEF) && ! defined (_GLIBCXX_HAVE_FINITEF)
# define _GLIBCXX_HAVE_FINITEF 1
# define finitef _finitef
#endif
#if defined (_GLIBCXX_HAVE__FINITEL) && ! defined (_GLIBCXX_HAVE_FINITEL)
# define _GLIBCXX_HAVE_FINITEL 1
# define finitel _finitel
#endif
#if defined (_GLIBCXX_HAVE__FLOORF) && ! defined (_GLIBCXX_HAVE_FLOORF)
# define _GLIBCXX_HAVE_FLOORF 1
# define floorf _floorf
#endif
#if defined (_GLIBCXX_HAVE__FLOORL) && ! defined (_GLIBCXX_HAVE_FLOORL)
# define _GLIBCXX_HAVE_FLOORL 1
# define floorl _floorl
#endif
#if defined (_GLIBCXX_HAVE__FMODF) && ! defined (_GLIBCXX_HAVE_FMODF)
# define _GLIBCXX_HAVE_FMODF 1
# define fmodf _fmodf
#endif
#if defined (_GLIBCXX_HAVE__FMODL) && ! defined (_GLIBCXX_HAVE_FMODL)
# define _GLIBCXX_HAVE_FMODL 1
# define fmodl _fmodl
#endif
#if defined (_GLIBCXX_HAVE__FPCLASS) && ! defined (_GLIBCXX_HAVE_FPCLASS)
# define _GLIBCXX_HAVE_FPCLASS 1
# define fpclass _fpclass
#endif
#if defined (_GLIBCXX_HAVE__FREXPF) && ! defined (_GLIBCXX_HAVE_FREXPF)
# define _GLIBCXX_HAVE_FREXPF 1
# define frexpf _frexpf
#endif
#if defined (_GLIBCXX_HAVE__FREXPL) && ! defined (_GLIBCXX_HAVE_FREXPL)
# define _GLIBCXX_HAVE_FREXPL 1
# define frexpl _frexpl
#endif
#if defined (_GLIBCXX_HAVE__HYPOT) && ! defined (_GLIBCXX_HAVE_HYPOT)
# define _GLIBCXX_HAVE_HYPOT 1
# define hypot _hypot
#endif
#if defined (_GLIBCXX_HAVE__HYPOTF) && ! defined (_GLIBCXX_HAVE_HYPOTF)
# define _GLIBCXX_HAVE_HYPOTF 1
# define hypotf _hypotf
#endif
#if defined (_GLIBCXX_HAVE__HYPOTL) && ! defined (_GLIBCXX_HAVE_HYPOTL)
# define _GLIBCXX_HAVE_HYPOTL 1
# define hypotl _hypotl
#endif
#if defined (_GLIBCXX_HAVE__ISINF) && ! defined (_GLIBCXX_HAVE_ISINF)
# define _GLIBCXX_HAVE_ISINF 1
# define isinf _isinf
#endif
#if defined (_GLIBCXX_HAVE__ISINFF) && ! defined (_GLIBCXX_HAVE_ISINFF)
# define _GLIBCXX_HAVE_ISINFF 1
# define isinff _isinff
#endif
#if defined (_GLIBCXX_HAVE__ISINFL) && ! defined (_GLIBCXX_HAVE_ISINFL)
# define _GLIBCXX_HAVE_ISINFL 1
# define isinfl _isinfl
#endif
#if defined (_GLIBCXX_HAVE__ISNAN) && ! defined (_GLIBCXX_HAVE_ISNAN)
# define _GLIBCXX_HAVE_ISNAN 1
# define isnan _isnan
#endif
#if defined (_GLIBCXX_HAVE__ISNANF) && ! defined (_GLIBCXX_HAVE_ISNANF)
# define _GLIBCXX_HAVE_ISNANF 1
# define isnanf _isnanf
#endif
#if defined (_GLIBCXX_HAVE__ISNANL) && ! defined (_GLIBCXX_HAVE_ISNANL)
# define _GLIBCXX_HAVE_ISNANL 1
# define isnanl _isnanl
#endif
#if defined (_GLIBCXX_HAVE__LDEXPF) && ! defined (_GLIBCXX_HAVE_LDEXPF)
# define _GLIBCXX_HAVE_LDEXPF 1
# define ldexpf _ldexpf
#endif
#if defined (_GLIBCXX_HAVE__LDEXPL) && ! defined (_GLIBCXX_HAVE_LDEXPL)
# define _GLIBCXX_HAVE_LDEXPL 1
# define ldexpl _ldexpl
#endif
#if defined (_GLIBCXX_HAVE__LOG10F) && ! defined (_GLIBCXX_HAVE_LOG10F)
# define _GLIBCXX_HAVE_LOG10F 1
# define log10f _log10f
#endif
#if defined (_GLIBCXX_HAVE__LOG10L) && ! defined (_GLIBCXX_HAVE_LOG10L)
# define _GLIBCXX_HAVE_LOG10L 1
# define log10l _log10l
#endif
#if defined (_GLIBCXX_HAVE__LOGF) && ! defined (_GLIBCXX_HAVE_LOGF)
# define _GLIBCXX_HAVE_LOGF 1
# define logf _logf
#endif
#if defined (_GLIBCXX_HAVE__LOGL) && ! defined (_GLIBCXX_HAVE_LOGL)
# define _GLIBCXX_HAVE_LOGL 1
# define logl _logl
#endif
#if defined (_GLIBCXX_HAVE__MODF) && ! defined (_GLIBCXX_HAVE_MODF)
# define _GLIBCXX_HAVE_MODF 1
# define modf _modf
#endif
#if defined (_GLIBCXX_HAVE__MODFF) && ! defined (_GLIBCXX_HAVE_MODFF)
# define _GLIBCXX_HAVE_MODFF 1
# define modff _modff
#endif
#if defined (_GLIBCXX_HAVE__MODFL) && ! defined (_GLIBCXX_HAVE_MODFL)
# define _GLIBCXX_HAVE_MODFL 1
# define modfl _modfl
#endif
#if defined (_GLIBCXX_HAVE__POWF) && ! defined (_GLIBCXX_HAVE_POWF)
# define _GLIBCXX_HAVE_POWF 1
# define powf _powf
#endif
#if defined (_GLIBCXX_HAVE__POWL) && ! defined (_GLIBCXX_HAVE_POWL)
# define _GLIBCXX_HAVE_POWL 1
# define powl _powl
#endif
#if defined (_GLIBCXX_HAVE__QFPCLASS) && ! defined (_GLIBCXX_HAVE_QFPCLASS)
# define _GLIBCXX_HAVE_QFPCLASS 1
# define qfpclass _qfpclass
#endif
#if defined (_GLIBCXX_HAVE__SINCOS) && ! defined (_GLIBCXX_HAVE_SINCOS)
# define _GLIBCXX_HAVE_SINCOS 1
# define sincos _sincos
#endif
#if defined (_GLIBCXX_HAVE__SINCOSF) && ! defined (_GLIBCXX_HAVE_SINCOSF)
# define _GLIBCXX_HAVE_SINCOSF 1
# define sincosf _sincosf
#endif
#if defined (_GLIBCXX_HAVE__SINCOSL) && ! defined (_GLIBCXX_HAVE_SINCOSL)
# define _GLIBCXX_HAVE_SINCOSL 1
# define sincosl _sincosl
#endif
#if defined (_GLIBCXX_HAVE__SINF) && ! defined (_GLIBCXX_HAVE_SINF)
# define _GLIBCXX_HAVE_SINF 1
# define sinf _sinf
#endif
#if defined (_GLIBCXX_HAVE__SINHF) && ! defined (_GLIBCXX_HAVE_SINHF)
# define _GLIBCXX_HAVE_SINHF 1
# define sinhf _sinhf
#endif
#if defined (_GLIBCXX_HAVE__SINHL) && ! defined (_GLIBCXX_HAVE_SINHL)
# define _GLIBCXX_HAVE_SINHL 1
# define sinhl _sinhl
#endif
#if defined (_GLIBCXX_HAVE__SINL) && ! defined (_GLIBCXX_HAVE_SINL)
# define _GLIBCXX_HAVE_SINL 1
# define sinl _sinl
#endif
#if defined (_GLIBCXX_HAVE__SQRTF) && ! defined (_GLIBCXX_HAVE_SQRTF)
# define _GLIBCXX_HAVE_SQRTF 1
# define sqrtf _sqrtf
#endif
#if defined (_GLIBCXX_HAVE__SQRTL) && ! defined (_GLIBCXX_HAVE_SQRTL)
# define _GLIBCXX_HAVE_SQRTL 1
# define sqrtl _sqrtl
#endif
#if defined (_GLIBCXX_HAVE__STRTOF) && ! defined (_GLIBCXX_HAVE_STRTOF)
# define _GLIBCXX_HAVE_STRTOF 1
# define strtof _strtof
#endif
#if defined (_GLIBCXX_HAVE__STRTOLD) && ! defined (_GLIBCXX_HAVE_STRTOLD)
# define _GLIBCXX_HAVE_STRTOLD 1
# define strtold _strtold
#endif
#if defined (_GLIBCXX_HAVE__TANF) && ! defined (_GLIBCXX_HAVE_TANF)
# define _GLIBCXX_HAVE_TANF 1
# define tanf _tanf
#endif
#if defined (_GLIBCXX_HAVE__TANHF) && ! defined (_GLIBCXX_HAVE_TANHF)
# define _GLIBCXX_HAVE_TANHF 1
# define tanhf _tanhf
#endif
#if defined (_GLIBCXX_HAVE__TANHL) && ! defined (_GLIBCXX_HAVE_TANHL)
# define _GLIBCXX_HAVE_TANHL 1
# define tanhl _tanhl
#endif
#if defined (_GLIBCXX_HAVE__TANL) && ! defined (_GLIBCXX_HAVE_TANL)
# define _GLIBCXX_HAVE_TANL 1
# define tanl _tanl
#endif
#endif // _GLIBCXX_CXX_CONFIG_H
#endif
#endif
c++/8/x86_64-redhat-linux/bits/c++locale.h 0000644 00000006353 15201526705 0013477 0 ustar 00 // Wrapper for underlying C-language localization -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/c++locale.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{locale}
*/
//
// ISO C++ 14882: 22.8 Standard locale categories.
//
// Written by Benjamin Kosnik <bkoz@redhat.com>
#ifndef _GLIBCXX_CXX_LOCALE_H
#define _GLIBCXX_CXX_LOCALE_H 1
#pragma GCC system_header
#include <clocale>
#define _GLIBCXX_C_LOCALE_GNU 1
#define _GLIBCXX_NUM_CATEGORIES 6
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
extern "C" __typeof(uselocale) __uselocale;
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef __locale_t __c_locale;
// Convert numeric value of type double and long double to string and
// return length of string. If vsnprintf is available use it, otherwise
// fall back to the unsafe vsprintf which, in general, can be dangerous
// and should be avoided.
inline int
__convert_from_v(const __c_locale& __cloc __attribute__ ((__unused__)),
char* __out,
const int __size __attribute__ ((__unused__)),
const char* __fmt, ...)
{
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__c_locale __old = __gnu_cxx::__uselocale(__cloc);
#else
char* __old = std::setlocale(LC_NUMERIC, 0);
char* __sav = 0;
if (__builtin_strcmp(__old, "C"))
{
const size_t __len = __builtin_strlen(__old) + 1;
__sav = new char[__len];
__builtin_memcpy(__sav, __old, __len);
std::setlocale(LC_NUMERIC, "C");
}
#endif
__builtin_va_list __args;
__builtin_va_start(__args, __fmt);
#if _GLIBCXX_USE_C99_STDIO
const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
#else
const int __ret = __builtin_vsprintf(__out, __fmt, __args);
#endif
__builtin_va_end(__args);
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__gnu_cxx::__uselocale(__old);
#else
if (__sav)
{
std::setlocale(LC_NUMERIC, __sav);
delete [] __sav;
}
#endif
return __ret;
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/x86_64-redhat-linux/bits/c++io.h 0000644 00000003110 15201526705 0012633 0 ustar 00 // Underlying io library details -*- C++ -*-
// Copyright (C) 2000-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/c++io.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{ios}
*/
// c_io_stdio.h - Defines for using "C" stdio.h
#ifndef _GLIBCXX_CXX_IO_H
#define _GLIBCXX_CXX_IO_H 1
#include <cstdio>
#include <bits/gthr.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef __gthread_mutex_t __c_lock;
// for basic_file.h
typedef FILE __c_file;
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/x86_64-redhat-linux/bits/atomic_word.h 0000644 00000002756 15201526705 0014261 0 ustar 00 // Low-level type for atomic operations -*- C++ -*-
// Copyright (C) 2004-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file atomic_word.h
* This file is a GNU extension to the Standard C++ Library.
*/
#ifndef _GLIBCXX_ATOMIC_WORD_H
#define _GLIBCXX_ATOMIC_WORD_H 1
typedef int _Atomic_word;
// This is a memory order acquire fence.
#define _GLIBCXX_READ_MEM_BARRIER __atomic_thread_fence (__ATOMIC_ACQUIRE)
// This is a memory order release fence.
#define _GLIBCXX_WRITE_MEM_BARRIER __atomic_thread_fence (__ATOMIC_RELEASE)
#endif
c++/8/x86_64-redhat-linux/bits/error_constants.h 0000644 00000012067 15201526705 0015173 0 ustar 00 // Specific definitions for generic platforms -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/error_constants.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{system_error}
*/
#ifndef _GLIBCXX_ERROR_CONSTANTS
#define _GLIBCXX_ERROR_CONSTANTS 1
#include <bits/c++config.h>
#include <cerrno>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
enum class errc
{
address_family_not_supported = EAFNOSUPPORT,
address_in_use = EADDRINUSE,
address_not_available = EADDRNOTAVAIL,
already_connected = EISCONN,
argument_list_too_long = E2BIG,
argument_out_of_domain = EDOM,
bad_address = EFAULT,
bad_file_descriptor = EBADF,
#ifdef _GLIBCXX_HAVE_EBADMSG
bad_message = EBADMSG,
#endif
broken_pipe = EPIPE,
connection_aborted = ECONNABORTED,
connection_already_in_progress = EALREADY,
connection_refused = ECONNREFUSED,
connection_reset = ECONNRESET,
cross_device_link = EXDEV,
destination_address_required = EDESTADDRREQ,
device_or_resource_busy = EBUSY,
directory_not_empty = ENOTEMPTY,
executable_format_error = ENOEXEC,
file_exists = EEXIST,
file_too_large = EFBIG,
filename_too_long = ENAMETOOLONG,
function_not_supported = ENOSYS,
host_unreachable = EHOSTUNREACH,
#ifdef _GLIBCXX_HAVE_EIDRM
identifier_removed = EIDRM,
#endif
illegal_byte_sequence = EILSEQ,
inappropriate_io_control_operation = ENOTTY,
interrupted = EINTR,
invalid_argument = EINVAL,
invalid_seek = ESPIPE,
io_error = EIO,
is_a_directory = EISDIR,
message_size = EMSGSIZE,
network_down = ENETDOWN,
network_reset = ENETRESET,
network_unreachable = ENETUNREACH,
no_buffer_space = ENOBUFS,
no_child_process = ECHILD,
#ifdef _GLIBCXX_HAVE_ENOLINK
no_link = ENOLINK,
#endif
no_lock_available = ENOLCK,
#ifdef _GLIBCXX_HAVE_ENODATA
no_message_available = ENODATA,
#endif
no_message = ENOMSG,
no_protocol_option = ENOPROTOOPT,
no_space_on_device = ENOSPC,
#ifdef _GLIBCXX_HAVE_ENOSR
no_stream_resources = ENOSR,
#endif
no_such_device_or_address = ENXIO,
no_such_device = ENODEV,
no_such_file_or_directory = ENOENT,
no_such_process = ESRCH,
not_a_directory = ENOTDIR,
not_a_socket = ENOTSOCK,
#ifdef _GLIBCXX_HAVE_ENOSTR
not_a_stream = ENOSTR,
#endif
not_connected = ENOTCONN,
not_enough_memory = ENOMEM,
#ifdef _GLIBCXX_HAVE_ENOTSUP
not_supported = ENOTSUP,
#endif
#ifdef _GLIBCXX_HAVE_ECANCELED
operation_canceled = ECANCELED,
#endif
operation_in_progress = EINPROGRESS,
operation_not_permitted = EPERM,
operation_not_supported = EOPNOTSUPP,
operation_would_block = EWOULDBLOCK,
#ifdef _GLIBCXX_HAVE_EOWNERDEAD
owner_dead = EOWNERDEAD,
#endif
permission_denied = EACCES,
#ifdef _GLIBCXX_HAVE_EPROTO
protocol_error = EPROTO,
#endif
protocol_not_supported = EPROTONOSUPPORT,
read_only_file_system = EROFS,
resource_deadlock_would_occur = EDEADLK,
resource_unavailable_try_again = EAGAIN,
result_out_of_range = ERANGE,
#ifdef _GLIBCXX_HAVE_ENOTRECOVERABLE
state_not_recoverable = ENOTRECOVERABLE,
#endif
#ifdef _GLIBCXX_HAVE_ETIME
stream_timeout = ETIME,
#endif
#ifdef _GLIBCXX_HAVE_ETXTBSY
text_file_busy = ETXTBSY,
#endif
timed_out = ETIMEDOUT,
too_many_files_open_in_system = ENFILE,
too_many_files_open = EMFILE,
too_many_links = EMLINK,
too_many_symbolic_link_levels = ELOOP,
#ifdef _GLIBCXX_HAVE_EOVERFLOW
value_too_large = EOVERFLOW,
#endif
wrong_protocol_type = EPROTOTYPE
};
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/x86_64-redhat-linux/bits/opt_random.h 0000644 00000014062 15201526705 0014105 0 ustar 00 // Optimizations for random number functions, x86 version -*- C++ -*-
// Copyright (C) 2012-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/opt_random.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{random}
*/
#ifndef _BITS_OPT_RANDOM_H
#define _BITS_OPT_RANDOM_H 1
#ifdef __SSE3__
#include <pmmintrin.h>
#endif
#pragma GCC system_header
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
#ifdef __SSE3__
template<>
template<typename _UniformRandomNumberGenerator>
void
normal_distribution<double>::
__generate(typename normal_distribution<double>::result_type* __f,
typename normal_distribution<double>::result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
typedef uint64_t __uctype;
if (__f == __t)
return;
if (_M_saved_available)
{
_M_saved_available = false;
*__f++ = _M_saved * __param.stddev() + __param.mean();
if (__f == __t)
return;
}
constexpr uint64_t __maskval = 0xfffffffffffffull;
static const __m128i __mask = _mm_set1_epi64x(__maskval);
static const __m128i __two = _mm_set1_epi64x(0x4000000000000000ull);
static const __m128d __three = _mm_set1_pd(3.0);
const __m128d __av = _mm_set1_pd(__param.mean());
const __uctype __urngmin = __urng.min();
const __uctype __urngmax = __urng.max();
const __uctype __urngrange = __urngmax - __urngmin;
const __uctype __uerngrange = __urngrange + 1;
while (__f + 1 < __t)
{
double __le;
__m128d __x;
do
{
union
{
__m128i __i;
__m128d __d;
} __v;
if (__urngrange > __maskval)
{
if (__detail::_Power_of_2(__uerngrange))
__v.__i = _mm_and_si128(_mm_set_epi64x(__urng(),
__urng()),
__mask);
else
{
const __uctype __uerange = __maskval + 1;
const __uctype __scaling = __urngrange / __uerange;
const __uctype __past = __uerange * __scaling;
uint64_t __v1;
do
__v1 = __uctype(__urng()) - __urngmin;
while (__v1 >= __past);
__v1 /= __scaling;
uint64_t __v2;
do
__v2 = __uctype(__urng()) - __urngmin;
while (__v2 >= __past);
__v2 /= __scaling;
__v.__i = _mm_set_epi64x(__v1, __v2);
}
}
else if (__urngrange == __maskval)
__v.__i = _mm_set_epi64x(__urng(), __urng());
else if ((__urngrange + 2) * __urngrange >= __maskval
&& __detail::_Power_of_2(__uerngrange))
{
uint64_t __v1 = __urng() * __uerngrange + __urng();
uint64_t __v2 = __urng() * __uerngrange + __urng();
__v.__i = _mm_and_si128(_mm_set_epi64x(__v1, __v2),
__mask);
}
else
{
size_t __nrng = 2;
__uctype __high = __maskval / __uerngrange / __uerngrange;
while (__high > __uerngrange)
{
++__nrng;
__high /= __uerngrange;
}
const __uctype __highrange = __high + 1;
const __uctype __scaling = __urngrange / __highrange;
const __uctype __past = __highrange * __scaling;
__uctype __tmp;
uint64_t __v1;
do
{
do
__tmp = __uctype(__urng()) - __urngmin;
while (__tmp >= __past);
__v1 = __tmp / __scaling;
for (size_t __cnt = 0; __cnt < __nrng; ++__cnt)
{
__tmp = __v1;
__v1 *= __uerngrange;
__v1 += __uctype(__urng()) - __urngmin;
}
}
while (__v1 > __maskval || __v1 < __tmp);
uint64_t __v2;
do
{
do
__tmp = __uctype(__urng()) - __urngmin;
while (__tmp >= __past);
__v2 = __tmp / __scaling;
for (size_t __cnt = 0; __cnt < __nrng; ++__cnt)
{
__tmp = __v2;
__v2 *= __uerngrange;
__v2 += __uctype(__urng()) - __urngmin;
}
}
while (__v2 > __maskval || __v2 < __tmp);
__v.__i = _mm_set_epi64x(__v1, __v2);
}
__v.__i = _mm_or_si128(__v.__i, __two);
__x = _mm_sub_pd(__v.__d, __three);
__m128d __m = _mm_mul_pd(__x, __x);
__le = _mm_cvtsd_f64(_mm_hadd_pd (__m, __m));
}
while (__le == 0.0 || __le >= 1.0);
double __mult = (std::sqrt(-2.0 * std::log(__le) / __le)
* __param.stddev());
__x = _mm_add_pd(_mm_mul_pd(__x, _mm_set1_pd(__mult)), __av);
_mm_storeu_pd(__f, __x);
__f += 2;
}
if (__f != __t)
{
result_type __x, __y, __r2;
__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
__aurng(__urng);
do
{
__x = result_type(2.0) * __aurng() - 1.0;
__y = result_type(2.0) * __aurng() - 1.0;
__r2 = __x * __x + __y * __y;
}
while (__r2 > 1.0 || __r2 == 0.0);
const result_type __mult = std::sqrt(-2 * std::log(__r2) / __r2);
_M_saved = __x * __mult;
_M_saved_available = true;
*__f = __y * __mult * __param.stddev() + __param.mean();
}
}
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif // _BITS_OPT_RANDOM_H
c++/8/x86_64-redhat-linux/bits/stdc++.h 0000644 00000005607 15201526705 0013033 0 ustar 00 // C++ includes used for precompiling -*- C++ -*-
// Copyright (C) 2003-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file stdc++.h
* This is an implementation file for a precompiled header.
*/
// 17.4.1.2 Headers
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cuchar>
#include <cwchar>
#include <cwctype>
#endif
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#if __cplusplus >= 201402L
#include <shared_mutex>
#endif
#if __cplusplus >= 201703L
#include <charconv>
#include <filesystem>
#endif
c++/8/x86_64-redhat-linux/bits/gthr.h 0000644 00000012750 15201526705 0012711 0 ustar 00 /* Threads compatibility routines for libgcc2. */
/* Compile this one with gcc. */
/* Copyright (C) 1997-2018 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _GLIBCXX_GCC_GTHR_H
#define _GLIBCXX_GCC_GTHR_H
#ifndef _GLIBCXX_HIDE_EXPORTS
#pragma GCC visibility push(default)
#endif
/* If this file is compiled with threads support, it must
#define __GTHREADS 1
to indicate that threads support is present. Also it has define
function
int __gthread_active_p ()
that returns 1 if thread system is active, 0 if not.
The threads interface must define the following types:
__gthread_key_t
__gthread_once_t
__gthread_mutex_t
__gthread_recursive_mutex_t
The threads interface must define the following macros:
__GTHREAD_ONCE_INIT
to initialize __gthread_once_t
__GTHREAD_MUTEX_INIT
to initialize __gthread_mutex_t to get a fast
non-recursive mutex.
__GTHREAD_MUTEX_INIT_FUNCTION
to initialize __gthread_mutex_t to get a fast
non-recursive mutex.
Define this to a function which looks like this:
void __GTHREAD_MUTEX_INIT_FUNCTION (__gthread_mutex_t *)
Some systems can't initialize a mutex without a
function call. Don't define __GTHREAD_MUTEX_INIT in this case.
__GTHREAD_RECURSIVE_MUTEX_INIT
__GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
as above, but for a recursive mutex.
The threads interface must define the following static functions:
int __gthread_once (__gthread_once_t *once, void (*func) ())
int __gthread_key_create (__gthread_key_t *keyp, void (*dtor) (void *))
int __gthread_key_delete (__gthread_key_t key)
void *__gthread_getspecific (__gthread_key_t key)
int __gthread_setspecific (__gthread_key_t key, const void *ptr)
int __gthread_mutex_destroy (__gthread_mutex_t *mutex);
int __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *mutex);
int __gthread_mutex_lock (__gthread_mutex_t *mutex);
int __gthread_mutex_trylock (__gthread_mutex_t *mutex);
int __gthread_mutex_unlock (__gthread_mutex_t *mutex);
int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex);
int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex);
int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex);
The following are supported in POSIX threads only. They are required to
fix a deadlock in static initialization inside libsupc++. The header file
gthr-posix.h defines a symbol __GTHREAD_HAS_COND to signify that these extra
features are supported.
Types:
__gthread_cond_t
Macros:
__GTHREAD_COND_INIT
__GTHREAD_COND_INIT_FUNCTION
Interface:
int __gthread_cond_broadcast (__gthread_cond_t *cond);
int __gthread_cond_wait (__gthread_cond_t *cond, __gthread_mutex_t *mutex);
int __gthread_cond_wait_recursive (__gthread_cond_t *cond,
__gthread_recursive_mutex_t *mutex);
All functions returning int should return zero on success or the error
number. If the operation is not supported, -1 is returned.
If the following are also defined, you should
#define __GTHREADS_CXX0X 1
to enable the c++0x thread library.
Types:
__gthread_t
__gthread_time_t
Interface:
int __gthread_create (__gthread_t *thread, void *(*func) (void*),
void *args);
int __gthread_join (__gthread_t thread, void **value_ptr);
int __gthread_detach (__gthread_t thread);
int __gthread_equal (__gthread_t t1, __gthread_t t2);
__gthread_t __gthread_self (void);
int __gthread_yield (void);
int __gthread_mutex_timedlock (__gthread_mutex_t *m,
const __gthread_time_t *abs_timeout);
int __gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *m,
const __gthread_time_t *abs_time);
int __gthread_cond_signal (__gthread_cond_t *cond);
int __gthread_cond_timedwait (__gthread_cond_t *cond,
__gthread_mutex_t *mutex,
const __gthread_time_t *abs_timeout);
*/
#if __GXX_WEAK__
/* The pe-coff weak support isn't fully compatible to ELF's weak.
For static libraries it might would work, but as we need to deal
with shared versions too, we disable it for mingw-targets. */
#ifdef __MINGW32__
#undef _GLIBCXX_GTHREAD_USE_WEAK
#define _GLIBCXX_GTHREAD_USE_WEAK 0
#endif
#ifndef _GLIBCXX_GTHREAD_USE_WEAK
#define _GLIBCXX_GTHREAD_USE_WEAK 1
#endif
#endif
#include <bits/gthr-default.h>
#ifndef _GLIBCXX_HIDE_EXPORTS
#pragma GCC visibility pop
#endif
#endif /* ! _GLIBCXX_GCC_GTHR_H */
c++/8/x86_64-redhat-linux/bits/messages_members.h 0000644 00000010644 15201526705 0015266 0 ustar 00 // std::messages implementation details, GNU version -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/messages_members.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{locale}
*/
//
// ISO C++ 14882: 22.2.7.1.2 messages functions
//
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <libintl.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Non-virtual member functions.
template<typename _CharT>
messages<_CharT>::messages(size_t __refs)
: facet(__refs), _M_c_locale_messages(_S_get_c_locale()),
_M_name_messages(_S_get_c_name())
{ }
template<typename _CharT>
messages<_CharT>::messages(__c_locale __cloc, const char* __s,
size_t __refs)
: facet(__refs), _M_c_locale_messages(0), _M_name_messages(0)
{
if (__builtin_strcmp(__s, _S_get_c_name()) != 0)
{
const size_t __len = __builtin_strlen(__s) + 1;
char* __tmp = new char[__len];
__builtin_memcpy(__tmp, __s, __len);
_M_name_messages = __tmp;
}
else
_M_name_messages = _S_get_c_name();
// Last to avoid leaking memory if new throws.
_M_c_locale_messages = _S_clone_c_locale(__cloc);
}
template<typename _CharT>
typename messages<_CharT>::catalog
messages<_CharT>::open(const basic_string<char>& __s, const locale& __loc,
const char* __dir) const
{
bindtextdomain(__s.c_str(), __dir);
return this->do_open(__s, __loc);
}
// Virtual member functions.
template<typename _CharT>
messages<_CharT>::~messages()
{
if (_M_name_messages != _S_get_c_name())
delete [] _M_name_messages;
_S_destroy_c_locale(_M_c_locale_messages);
}
template<typename _CharT>
typename messages<_CharT>::catalog
messages<_CharT>::do_open(const basic_string<char>& __s,
const locale&) const
{
// No error checking is done, assume the catalog exists and can
// be used.
textdomain(__s.c_str());
return 0;
}
template<typename _CharT>
void
messages<_CharT>::do_close(catalog) const
{ }
// messages_byname
template<typename _CharT>
messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs)
: messages<_CharT>(__refs)
{
if (this->_M_name_messages != locale::facet::_S_get_c_name())
{
delete [] this->_M_name_messages;
if (__builtin_strcmp(__s, locale::facet::_S_get_c_name()) != 0)
{
const size_t __len = __builtin_strlen(__s) + 1;
char* __tmp = new char[__len];
__builtin_memcpy(__tmp, __s, __len);
this->_M_name_messages = __tmp;
}
else
this->_M_name_messages = locale::facet::_S_get_c_name();
}
if (__builtin_strcmp(__s, "C") != 0
&& __builtin_strcmp(__s, "POSIX") != 0)
{
this->_S_destroy_c_locale(this->_M_c_locale_messages);
this->_S_create_c_locale(this->_M_c_locale_messages, __s);
}
}
//Specializations.
template<>
typename messages<char>::catalog
messages<char>::do_open(const basic_string<char>&,
const locale&) const;
template<>
void
messages<char>::do_close(catalog) const;
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
typename messages<wchar_t>::catalog
messages<wchar_t>::do_open(const basic_string<char>&,
const locale&) const;
template<>
void
messages<wchar_t>::do_close(catalog) const;
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
c++/8/x86_64-redhat-linux/bits/cpu_defines.h 0000644 00000002465 15201526705 0014233 0 ustar 00 // Specific definitions for generic platforms -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/cpu_defines.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{iosfwd}
*/
#ifndef _GLIBCXX_CPU_DEFINES
#define _GLIBCXX_CPU_DEFINES 1
#endif
c++/8/x86_64-redhat-linux/32/ext/opt_random.h 0000644 00000011224 15201526705 0014165 0 ustar 00 // Optimizations for random number extensions, x86 version -*- C++ -*-
// Copyright (C) 2012-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file ext/random.tcc
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{ext/random}
*/
#ifndef _EXT_OPT_RANDOM_H
#define _EXT_OPT_RANDOM_H 1
#pragma GCC system_header
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#ifdef __SSE2__
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
namespace {
template<size_t __sl1, size_t __sl2, size_t __sr1, size_t __sr2,
uint32_t __msk1, uint32_t __msk2, uint32_t __msk3, uint32_t __msk4>
inline __m128i __sse2_recursion(__m128i __a, __m128i __b,
__m128i __c, __m128i __d)
{
__m128i __y = _mm_srli_epi32(__b, __sr1);
__m128i __z = _mm_srli_si128(__c, __sr2);
__m128i __v = _mm_slli_epi32(__d, __sl1);
__z = _mm_xor_si128(__z, __a);
__z = _mm_xor_si128(__z, __v);
__m128i __x = _mm_slli_si128(__a, __sl2);
__y = _mm_and_si128(__y, _mm_set_epi32(__msk4, __msk3, __msk2, __msk1));
__z = _mm_xor_si128(__z, __x);
return _mm_xor_si128(__z, __y);
}
}
#define _GLIBCXX_OPT_HAVE_RANDOM_SFMT_GEN_READ 1
template<typename _UIntType, size_t __m,
size_t __pos1, size_t __sl1, size_t __sl2,
size_t __sr1, size_t __sr2,
uint32_t __msk1, uint32_t __msk2,
uint32_t __msk3, uint32_t __msk4,
uint32_t __parity1, uint32_t __parity2,
uint32_t __parity3, uint32_t __parity4>
void simd_fast_mersenne_twister_engine<_UIntType, __m,
__pos1, __sl1, __sl2, __sr1, __sr2,
__msk1, __msk2, __msk3, __msk4,
__parity1, __parity2, __parity3,
__parity4>::
_M_gen_rand(void)
{
__m128i __r1 = _mm_load_si128(&_M_state[_M_nstate - 2]);
__m128i __r2 = _mm_load_si128(&_M_state[_M_nstate - 1]);
size_t __i;
for (__i = 0; __i < _M_nstate - __pos1; ++__i)
{
__m128i __r = __sse2_recursion<__sl1, __sl2, __sr1, __sr2,
__msk1, __msk2, __msk3, __msk4>
(_M_state[__i], _M_state[__i + __pos1], __r1, __r2);
_mm_store_si128(&_M_state[__i], __r);
__r1 = __r2;
__r2 = __r;
}
for (; __i < _M_nstate; ++__i)
{
__m128i __r = __sse2_recursion<__sl1, __sl2, __sr1, __sr2,
__msk1, __msk2, __msk3, __msk4>
(_M_state[__i], _M_state[__i + __pos1 - _M_nstate], __r1, __r2);
_mm_store_si128(&_M_state[__i], __r);
__r1 = __r2;
__r2 = __r;
}
_M_pos = 0;
}
#define _GLIBCXX_OPT_HAVE_RANDOM_SFMT_OPERATOREQUAL 1
template<typename _UIntType, size_t __m,
size_t __pos1, size_t __sl1, size_t __sl2,
size_t __sr1, size_t __sr2,
uint32_t __msk1, uint32_t __msk2,
uint32_t __msk3, uint32_t __msk4,
uint32_t __parity1, uint32_t __parity2,
uint32_t __parity3, uint32_t __parity4>
bool
operator==(const __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType,
__m, __pos1, __sl1, __sl2, __sr1, __sr2,
__msk1, __msk2, __msk3, __msk4,
__parity1, __parity2, __parity3, __parity4>& __lhs,
const __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType,
__m, __pos1, __sl1, __sl2, __sr1, __sr2,
__msk1, __msk2, __msk3, __msk4,
__parity1, __parity2, __parity3, __parity4>& __rhs)
{
__m128i __res = _mm_cmpeq_epi8(__lhs._M_state[0], __rhs._M_state[0]);
for (size_t __i = 1; __i < __lhs._M_nstate; ++__i)
__res = _mm_and_si128(__res, _mm_cmpeq_epi8(__lhs._M_state[__i],
__rhs._M_state[__i]));
return (_mm_movemask_epi8(__res) == 0xffff
&& __lhs._M_pos == __rhs._M_pos);
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif // __SSE2__
#endif // __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#endif // _EXT_OPT_RANDOM_H
c++/8/x86_64-redhat-linux/32/bits/gthr-default.h 0000644 00000057255 15201526705 0014570 0 ustar 00 /* Threads compatibility routines for libgcc2 and libobjc. */
/* Compile this one with gcc. */
/* Copyright (C) 1997-2018 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _GLIBCXX_GCC_GTHR_POSIX_H
#define _GLIBCXX_GCC_GTHR_POSIX_H
/* POSIX threads specific definitions.
Easy, since the interface is just one-to-one mapping. */
#define __GTHREADS 1
#define __GTHREADS_CXX0X 1
#include <pthread.h>
#if ((defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)) \
|| !defined(_GTHREAD_USE_MUTEX_TIMEDLOCK))
# include <unistd.h>
# if defined(_POSIX_TIMEOUTS) && _POSIX_TIMEOUTS >= 0
# define _GTHREAD_USE_MUTEX_TIMEDLOCK 1
# else
# define _GTHREAD_USE_MUTEX_TIMEDLOCK 0
# endif
#endif
typedef pthread_t __gthread_t;
typedef pthread_key_t __gthread_key_t;
typedef pthread_once_t __gthread_once_t;
typedef pthread_mutex_t __gthread_mutex_t;
typedef pthread_mutex_t __gthread_recursive_mutex_t;
typedef pthread_cond_t __gthread_cond_t;
typedef struct timespec __gthread_time_t;
/* POSIX like conditional variables are supported. Please look at comments
in gthr.h for details. */
#define __GTHREAD_HAS_COND 1
#define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
#define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function
#define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT
#if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER)
#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER
#elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
#else
#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
#endif
#define __GTHREAD_COND_INIT PTHREAD_COND_INITIALIZER
#define __GTHREAD_TIME_INIT {0,0}
#ifdef _GTHREAD_USE_MUTEX_INIT_FUNC
# undef __GTHREAD_MUTEX_INIT
#endif
#ifdef _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC
# undef __GTHREAD_RECURSIVE_MUTEX_INIT
# undef __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
# define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
#endif
#ifdef _GTHREAD_USE_COND_INIT_FUNC
# undef __GTHREAD_COND_INIT
# define __GTHREAD_COND_INIT_FUNCTION __gthread_cond_init_function
#endif
#if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK
# ifndef __gthrw_pragma
# define __gthrw_pragma(pragma)
# endif
# define __gthrw2(name,name2,type) \
static __typeof(type) name __attribute__ ((__weakref__(#name2))); \
__gthrw_pragma(weak type)
# define __gthrw_(name) __gthrw_ ## name
#else
# define __gthrw2(name,name2,type)
# define __gthrw_(name) name
#endif
/* Typically, __gthrw_foo is a weak reference to symbol foo. */
#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
__gthrw(pthread_once)
__gthrw(pthread_getspecific)
__gthrw(pthread_setspecific)
__gthrw(pthread_create)
__gthrw(pthread_join)
__gthrw(pthread_equal)
__gthrw(pthread_self)
__gthrw(pthread_detach)
#ifndef __BIONIC__
__gthrw(pthread_cancel)
#endif
__gthrw(sched_yield)
__gthrw(pthread_mutex_lock)
__gthrw(pthread_mutex_trylock)
#if _GTHREAD_USE_MUTEX_TIMEDLOCK
__gthrw(pthread_mutex_timedlock)
#endif
__gthrw(pthread_mutex_unlock)
__gthrw(pthread_mutex_init)
__gthrw(pthread_mutex_destroy)
__gthrw(pthread_cond_init)
__gthrw(pthread_cond_broadcast)
__gthrw(pthread_cond_signal)
__gthrw(pthread_cond_wait)
__gthrw(pthread_cond_timedwait)
__gthrw(pthread_cond_destroy)
__gthrw(pthread_key_create)
__gthrw(pthread_key_delete)
__gthrw(pthread_mutexattr_init)
__gthrw(pthread_mutexattr_settype)
__gthrw(pthread_mutexattr_destroy)
#if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)
/* Objective-C. */
__gthrw(pthread_exit)
#ifdef _POSIX_PRIORITY_SCHEDULING
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
__gthrw(sched_get_priority_max)
__gthrw(sched_get_priority_min)
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
#endif /* _POSIX_PRIORITY_SCHEDULING */
__gthrw(pthread_attr_destroy)
__gthrw(pthread_attr_init)
__gthrw(pthread_attr_setdetachstate)
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
__gthrw(pthread_getschedparam)
__gthrw(pthread_setschedparam)
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
#endif /* _LIBOBJC || _LIBOBJC_WEAK */
#if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK
/* On Solaris 2.6 up to 9, the libc exposes a POSIX threads interface even if
-pthreads is not specified. The functions are dummies and most return an
error value. However pthread_once returns 0 without invoking the routine
it is passed so we cannot pretend that the interface is active if -pthreads
is not specified. On Solaris 2.5.1, the interface is not exposed at all so
we need to play the usual game with weak symbols. On Solaris 10 and up, a
working interface is always exposed. On FreeBSD 6 and later, libc also
exposes a dummy POSIX threads interface, similar to what Solaris 2.6 up
to 9 does. FreeBSD >= 700014 even provides a pthread_cancel stub in libc,
which means the alternate __gthread_active_p below cannot be used there. */
#if defined(__FreeBSD__) || (defined(__sun) && defined(__svr4__))
static volatile int __gthread_active = -1;
static void
__gthread_trigger (void)
{
__gthread_active = 1;
}
static inline int
__gthread_active_p (void)
{
static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_once_t __gthread_active_once = PTHREAD_ONCE_INIT;
/* Avoid reading __gthread_active twice on the main code path. */
int __gthread_active_latest_value = __gthread_active;
/* This test is not protected to avoid taking a lock on the main code
path so every update of __gthread_active in a threaded program must
be atomic with regard to the result of the test. */
if (__builtin_expect (__gthread_active_latest_value < 0, 0))
{
if (__gthrw_(pthread_once))
{
/* If this really is a threaded program, then we must ensure that
__gthread_active has been set to 1 before exiting this block. */
__gthrw_(pthread_mutex_lock) (&__gthread_active_mutex);
__gthrw_(pthread_once) (&__gthread_active_once, __gthread_trigger);
__gthrw_(pthread_mutex_unlock) (&__gthread_active_mutex);
}
/* Make sure we'll never enter this block again. */
if (__gthread_active < 0)
__gthread_active = 0;
__gthread_active_latest_value = __gthread_active;
}
return __gthread_active_latest_value != 0;
}
#else /* neither FreeBSD nor Solaris */
/* For a program to be multi-threaded the only thing that it certainly must
be using is pthread_create. However, there may be other libraries that
intercept pthread_create with their own definitions to wrap pthreads
functionality for some purpose. In those cases, pthread_create being
defined might not necessarily mean that libpthread is actually linked
in.
For the GNU C library, we can use a known internal name. This is always
available in the ABI, but no other library would define it. That is
ideal, since any public pthread function might be intercepted just as
pthread_create might be. __pthread_key_create is an "internal"
implementation symbol, but it is part of the public exported ABI. Also,
it's among the symbols that the static libpthread.a always links in
whenever pthread_create is used, so there is no danger of a false
negative result in any statically-linked, multi-threaded program.
For others, we choose pthread_cancel as a function that seems unlikely
to be redefined by an interceptor library. The bionic (Android) C
library does not provide pthread_cancel, so we do use pthread_create
there (and interceptor libraries lose). */
#ifdef __GLIBC__
__gthrw2(__gthrw_(__pthread_key_create),
__pthread_key_create,
pthread_key_create)
# define GTHR_ACTIVE_PROXY __gthrw_(__pthread_key_create)
#elif defined (__BIONIC__)
# define GTHR_ACTIVE_PROXY __gthrw_(pthread_create)
#else
# define GTHR_ACTIVE_PROXY __gthrw_(pthread_cancel)
#endif
static inline int
__gthread_active_p (void)
{
static void *const __gthread_active_ptr
= __extension__ (void *) >HR_ACTIVE_PROXY;
return __gthread_active_ptr != 0;
}
#endif /* FreeBSD or Solaris */
#else /* not __GXX_WEAK__ */
/* Similar to Solaris, HP-UX 11 for PA-RISC provides stubs for pthread
calls in shared flavors of the HP-UX C library. Most of the stubs
have no functionality. The details are described in the "libc cumulative
patch" for each subversion of HP-UX 11. There are two special interfaces
provided for checking whether an application is linked to a shared pthread
library or not. However, these interfaces aren't available in early
libpthread libraries. We also need a test that works for archive
libraries. We can't use pthread_once as some libc versions call the
init function. We also can't use pthread_create or pthread_attr_init
as these create a thread and thereby prevent changing the default stack
size. The function pthread_default_stacksize_np is available in both
the archive and shared versions of libpthread. It can be used to
determine the default pthread stack size. There is a stub in some
shared libc versions which returns a zero size if pthreads are not
active. We provide an equivalent stub to handle cases where libc
doesn't provide one. */
#if defined(__hppa__) && defined(__hpux__)
static volatile int __gthread_active = -1;
static inline int
__gthread_active_p (void)
{
/* Avoid reading __gthread_active twice on the main code path. */
int __gthread_active_latest_value = __gthread_active;
size_t __s;
if (__builtin_expect (__gthread_active_latest_value < 0, 0))
{
pthread_default_stacksize_np (0, &__s);
__gthread_active = __s ? 1 : 0;
__gthread_active_latest_value = __gthread_active;
}
return __gthread_active_latest_value != 0;
}
#else /* not hppa-hpux */
static inline int
__gthread_active_p (void)
{
return 1;
}
#endif /* hppa-hpux */
#endif /* __GXX_WEAK__ */
#ifdef _LIBOBJC
/* This is the config.h file in libobjc/ */
#include <config.h>
#ifdef HAVE_SCHED_H
# include <sched.h>
#endif
/* Key structure for maintaining thread specific storage */
static pthread_key_t _objc_thread_storage;
static pthread_attr_t _objc_thread_attribs;
/* Thread local storage for a single thread */
static void *thread_local_storage = NULL;
/* Backend initialization functions */
/* Initialize the threads subsystem. */
static inline int
__gthread_objc_init_thread_system (void)
{
if (__gthread_active_p ())
{
/* Initialize the thread storage key. */
if (__gthrw_(pthread_key_create) (&_objc_thread_storage, NULL) == 0)
{
/* The normal default detach state for threads is
* PTHREAD_CREATE_JOINABLE which causes threads to not die
* when you think they should. */
if (__gthrw_(pthread_attr_init) (&_objc_thread_attribs) == 0
&& __gthrw_(pthread_attr_setdetachstate) (&_objc_thread_attribs,
PTHREAD_CREATE_DETACHED) == 0)
return 0;
}
}
return -1;
}
/* Close the threads subsystem. */
static inline int
__gthread_objc_close_thread_system (void)
{
if (__gthread_active_p ()
&& __gthrw_(pthread_key_delete) (_objc_thread_storage) == 0
&& __gthrw_(pthread_attr_destroy) (&_objc_thread_attribs) == 0)
return 0;
return -1;
}
/* Backend thread functions */
/* Create a new thread of execution. */
static inline objc_thread_t
__gthread_objc_thread_detach (void (*func)(void *), void *arg)
{
objc_thread_t thread_id;
pthread_t new_thread_handle;
if (!__gthread_active_p ())
return NULL;
if (!(__gthrw_(pthread_create) (&new_thread_handle, &_objc_thread_attribs,
(void *) func, arg)))
thread_id = (objc_thread_t) new_thread_handle;
else
thread_id = NULL;
return thread_id;
}
/* Set the current thread's priority. */
static inline int
__gthread_objc_thread_set_priority (int priority)
{
if (!__gthread_active_p ())
return -1;
else
{
#ifdef _POSIX_PRIORITY_SCHEDULING
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
pthread_t thread_id = __gthrw_(pthread_self) ();
int policy;
struct sched_param params;
int priority_min, priority_max;
if (__gthrw_(pthread_getschedparam) (thread_id, &policy, ¶ms) == 0)
{
if ((priority_max = __gthrw_(sched_get_priority_max) (policy)) == -1)
return -1;
if ((priority_min = __gthrw_(sched_get_priority_min) (policy)) == -1)
return -1;
if (priority > priority_max)
priority = priority_max;
else if (priority < priority_min)
priority = priority_min;
params.sched_priority = priority;
/*
* The solaris 7 and several other man pages incorrectly state that
* this should be a pointer to policy but pthread.h is universally
* at odds with this.
*/
if (__gthrw_(pthread_setschedparam) (thread_id, policy, ¶ms) == 0)
return 0;
}
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
#endif /* _POSIX_PRIORITY_SCHEDULING */
return -1;
}
}
/* Return the current thread's priority. */
static inline int
__gthread_objc_thread_get_priority (void)
{
#ifdef _POSIX_PRIORITY_SCHEDULING
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
if (__gthread_active_p ())
{
int policy;
struct sched_param params;
if (__gthrw_(pthread_getschedparam) (__gthrw_(pthread_self) (), &policy, ¶ms) == 0)
return params.sched_priority;
else
return -1;
}
else
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
#endif /* _POSIX_PRIORITY_SCHEDULING */
return OBJC_THREAD_INTERACTIVE_PRIORITY;
}
/* Yield our process time to another thread. */
static inline void
__gthread_objc_thread_yield (void)
{
if (__gthread_active_p ())
__gthrw_(sched_yield) ();
}
/* Terminate the current thread. */
static inline int
__gthread_objc_thread_exit (void)
{
if (__gthread_active_p ())
/* exit the thread */
__gthrw_(pthread_exit) (&__objc_thread_exit_status);
/* Failed if we reached here */
return -1;
}
/* Returns an integer value which uniquely describes a thread. */
static inline objc_thread_t
__gthread_objc_thread_id (void)
{
if (__gthread_active_p ())
return (objc_thread_t) __gthrw_(pthread_self) ();
else
return (objc_thread_t) 1;
}
/* Sets the thread's local storage pointer. */
static inline int
__gthread_objc_thread_set_data (void *value)
{
if (__gthread_active_p ())
return __gthrw_(pthread_setspecific) (_objc_thread_storage, value);
else
{
thread_local_storage = value;
return 0;
}
}
/* Returns the thread's local storage pointer. */
static inline void *
__gthread_objc_thread_get_data (void)
{
if (__gthread_active_p ())
return __gthrw_(pthread_getspecific) (_objc_thread_storage);
else
return thread_local_storage;
}
/* Backend mutex functions */
/* Allocate a mutex. */
static inline int
__gthread_objc_mutex_allocate (objc_mutex_t mutex)
{
if (__gthread_active_p ())
{
mutex->backend = objc_malloc (sizeof (pthread_mutex_t));
if (__gthrw_(pthread_mutex_init) ((pthread_mutex_t *) mutex->backend, NULL))
{
objc_free (mutex->backend);
mutex->backend = NULL;
return -1;
}
}
return 0;
}
/* Deallocate a mutex. */
static inline int
__gthread_objc_mutex_deallocate (objc_mutex_t mutex)
{
if (__gthread_active_p ())
{
int count;
/*
* Posix Threads specifically require that the thread be unlocked
* for __gthrw_(pthread_mutex_destroy) to work.
*/
do
{
count = __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend);
if (count < 0)
return -1;
}
while (count);
if (__gthrw_(pthread_mutex_destroy) ((pthread_mutex_t *) mutex->backend))
return -1;
objc_free (mutex->backend);
mutex->backend = NULL;
}
return 0;
}
/* Grab a lock on a mutex. */
static inline int
__gthread_objc_mutex_lock (objc_mutex_t mutex)
{
if (__gthread_active_p ()
&& __gthrw_(pthread_mutex_lock) ((pthread_mutex_t *) mutex->backend) != 0)
{
return -1;
}
return 0;
}
/* Try to grab a lock on a mutex. */
static inline int
__gthread_objc_mutex_trylock (objc_mutex_t mutex)
{
if (__gthread_active_p ()
&& __gthrw_(pthread_mutex_trylock) ((pthread_mutex_t *) mutex->backend) != 0)
{
return -1;
}
return 0;
}
/* Unlock the mutex */
static inline int
__gthread_objc_mutex_unlock (objc_mutex_t mutex)
{
if (__gthread_active_p ()
&& __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend) != 0)
{
return -1;
}
return 0;
}
/* Backend condition mutex functions */
/* Allocate a condition. */
static inline int
__gthread_objc_condition_allocate (objc_condition_t condition)
{
if (__gthread_active_p ())
{
condition->backend = objc_malloc (sizeof (pthread_cond_t));
if (__gthrw_(pthread_cond_init) ((pthread_cond_t *) condition->backend, NULL))
{
objc_free (condition->backend);
condition->backend = NULL;
return -1;
}
}
return 0;
}
/* Deallocate a condition. */
static inline int
__gthread_objc_condition_deallocate (objc_condition_t condition)
{
if (__gthread_active_p ())
{
if (__gthrw_(pthread_cond_destroy) ((pthread_cond_t *) condition->backend))
return -1;
objc_free (condition->backend);
condition->backend = NULL;
}
return 0;
}
/* Wait on the condition */
static inline int
__gthread_objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex)
{
if (__gthread_active_p ())
return __gthrw_(pthread_cond_wait) ((pthread_cond_t *) condition->backend,
(pthread_mutex_t *) mutex->backend);
else
return 0;
}
/* Wake up all threads waiting on this condition. */
static inline int
__gthread_objc_condition_broadcast (objc_condition_t condition)
{
if (__gthread_active_p ())
return __gthrw_(pthread_cond_broadcast) ((pthread_cond_t *) condition->backend);
else
return 0;
}
/* Wake up one thread waiting on this condition. */
static inline int
__gthread_objc_condition_signal (objc_condition_t condition)
{
if (__gthread_active_p ())
return __gthrw_(pthread_cond_signal) ((pthread_cond_t *) condition->backend);
else
return 0;
}
#else /* _LIBOBJC */
static inline int
__gthread_create (__gthread_t *__threadid, void *(*__func) (void*),
void *__args)
{
return __gthrw_(pthread_create) (__threadid, NULL, __func, __args);
}
static inline int
__gthread_join (__gthread_t __threadid, void **__value_ptr)
{
return __gthrw_(pthread_join) (__threadid, __value_ptr);
}
static inline int
__gthread_detach (__gthread_t __threadid)
{
return __gthrw_(pthread_detach) (__threadid);
}
static inline int
__gthread_equal (__gthread_t __t1, __gthread_t __t2)
{
return __gthrw_(pthread_equal) (__t1, __t2);
}
static inline __gthread_t
__gthread_self (void)
{
return __gthrw_(pthread_self) ();
}
static inline int
__gthread_yield (void)
{
return __gthrw_(sched_yield) ();
}
static inline int
__gthread_once (__gthread_once_t *__once, void (*__func) (void))
{
if (__gthread_active_p ())
return __gthrw_(pthread_once) (__once, __func);
else
return -1;
}
static inline int
__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *))
{
return __gthrw_(pthread_key_create) (__key, __dtor);
}
static inline int
__gthread_key_delete (__gthread_key_t __key)
{
return __gthrw_(pthread_key_delete) (__key);
}
static inline void *
__gthread_getspecific (__gthread_key_t __key)
{
return __gthrw_(pthread_getspecific) (__key);
}
static inline int
__gthread_setspecific (__gthread_key_t __key, const void *__ptr)
{
return __gthrw_(pthread_setspecific) (__key, __ptr);
}
static inline void
__gthread_mutex_init_function (__gthread_mutex_t *__mutex)
{
if (__gthread_active_p ())
__gthrw_(pthread_mutex_init) (__mutex, NULL);
}
static inline int
__gthread_mutex_destroy (__gthread_mutex_t *__mutex)
{
if (__gthread_active_p ())
return __gthrw_(pthread_mutex_destroy) (__mutex);
else
return 0;
}
static inline int
__gthread_mutex_lock (__gthread_mutex_t *__mutex)
{
if (__gthread_active_p ())
return __gthrw_(pthread_mutex_lock) (__mutex);
else
return 0;
}
static inline int
__gthread_mutex_trylock (__gthread_mutex_t *__mutex)
{
if (__gthread_active_p ())
return __gthrw_(pthread_mutex_trylock) (__mutex);
else
return 0;
}
#if _GTHREAD_USE_MUTEX_TIMEDLOCK
static inline int
__gthread_mutex_timedlock (__gthread_mutex_t *__mutex,
const __gthread_time_t *__abs_timeout)
{
if (__gthread_active_p ())
return __gthrw_(pthread_mutex_timedlock) (__mutex, __abs_timeout);
else
return 0;
}
#endif
static inline int
__gthread_mutex_unlock (__gthread_mutex_t *__mutex)
{
if (__gthread_active_p ())
return __gthrw_(pthread_mutex_unlock) (__mutex);
else
return 0;
}
#if !defined( PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) \
|| defined(_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC)
static inline int
__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex)
{
if (__gthread_active_p ())
{
pthread_mutexattr_t __attr;
int __r;
__r = __gthrw_(pthread_mutexattr_init) (&__attr);
if (!__r)
__r = __gthrw_(pthread_mutexattr_settype) (&__attr,
PTHREAD_MUTEX_RECURSIVE);
if (!__r)
__r = __gthrw_(pthread_mutex_init) (__mutex, &__attr);
if (!__r)
__r = __gthrw_(pthread_mutexattr_destroy) (&__attr);
return __r;
}
return 0;
}
#endif
static inline int
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_lock (__mutex);
}
static inline int
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_trylock (__mutex);
}
#if _GTHREAD_USE_MUTEX_TIMEDLOCK
static inline int
__gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *__mutex,
const __gthread_time_t *__abs_timeout)
{
return __gthread_mutex_timedlock (__mutex, __abs_timeout);
}
#endif
static inline int
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_unlock (__mutex);
}
static inline int
__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_destroy (__mutex);
}
#ifdef _GTHREAD_USE_COND_INIT_FUNC
static inline void
__gthread_cond_init_function (__gthread_cond_t *__cond)
{
if (__gthread_active_p ())
__gthrw_(pthread_cond_init) (__cond, NULL);
}
#endif
static inline int
__gthread_cond_broadcast (__gthread_cond_t *__cond)
{
return __gthrw_(pthread_cond_broadcast) (__cond);
}
static inline int
__gthread_cond_signal (__gthread_cond_t *__cond)
{
return __gthrw_(pthread_cond_signal) (__cond);
}
static inline int
__gthread_cond_wait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex)
{
return __gthrw_(pthread_cond_wait) (__cond, __mutex);
}
static inline int
__gthread_cond_timedwait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex,
const __gthread_time_t *__abs_timeout)
{
return __gthrw_(pthread_cond_timedwait) (__cond, __mutex, __abs_timeout);
}
static inline int
__gthread_cond_wait_recursive (__gthread_cond_t *__cond,
__gthread_recursive_mutex_t *__mutex)
{
return __gthread_cond_wait (__cond, __mutex);
}
static inline int
__gthread_cond_destroy (__gthread_cond_t* __cond)
{
return __gthrw_(pthread_cond_destroy) (__cond);
}
#endif /* _LIBOBJC */
#endif /* ! _GLIBCXX_GCC_GTHR_POSIX_H */
c++/8/x86_64-redhat-linux/32/bits/gthr-posix.h 0000644 00000057255 15201526705 0014306 0 ustar 00 /* Threads compatibility routines for libgcc2 and libobjc. */
/* Compile this one with gcc. */
/* Copyright (C) 1997-2018 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _GLIBCXX_GCC_GTHR_POSIX_H
#define _GLIBCXX_GCC_GTHR_POSIX_H
/* POSIX threads specific definitions.
Easy, since the interface is just one-to-one mapping. */
#define __GTHREADS 1
#define __GTHREADS_CXX0X 1
#include <pthread.h>
#if ((defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)) \
|| !defined(_GTHREAD_USE_MUTEX_TIMEDLOCK))
# include <unistd.h>
# if defined(_POSIX_TIMEOUTS) && _POSIX_TIMEOUTS >= 0
# define _GTHREAD_USE_MUTEX_TIMEDLOCK 1
# else
# define _GTHREAD_USE_MUTEX_TIMEDLOCK 0
# endif
#endif
typedef pthread_t __gthread_t;
typedef pthread_key_t __gthread_key_t;
typedef pthread_once_t __gthread_once_t;
typedef pthread_mutex_t __gthread_mutex_t;
typedef pthread_mutex_t __gthread_recursive_mutex_t;
typedef pthread_cond_t __gthread_cond_t;
typedef struct timespec __gthread_time_t;
/* POSIX like conditional variables are supported. Please look at comments
in gthr.h for details. */
#define __GTHREAD_HAS_COND 1
#define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
#define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function
#define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT
#if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER)
#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER
#elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
#else
#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
#endif
#define __GTHREAD_COND_INIT PTHREAD_COND_INITIALIZER
#define __GTHREAD_TIME_INIT {0,0}
#ifdef _GTHREAD_USE_MUTEX_INIT_FUNC
# undef __GTHREAD_MUTEX_INIT
#endif
#ifdef _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC
# undef __GTHREAD_RECURSIVE_MUTEX_INIT
# undef __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
# define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
#endif
#ifdef _GTHREAD_USE_COND_INIT_FUNC
# undef __GTHREAD_COND_INIT
# define __GTHREAD_COND_INIT_FUNCTION __gthread_cond_init_function
#endif
#if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK
# ifndef __gthrw_pragma
# define __gthrw_pragma(pragma)
# endif
# define __gthrw2(name,name2,type) \
static __typeof(type) name __attribute__ ((__weakref__(#name2))); \
__gthrw_pragma(weak type)
# define __gthrw_(name) __gthrw_ ## name
#else
# define __gthrw2(name,name2,type)
# define __gthrw_(name) name
#endif
/* Typically, __gthrw_foo is a weak reference to symbol foo. */
#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
__gthrw(pthread_once)
__gthrw(pthread_getspecific)
__gthrw(pthread_setspecific)
__gthrw(pthread_create)
__gthrw(pthread_join)
__gthrw(pthread_equal)
__gthrw(pthread_self)
__gthrw(pthread_detach)
#ifndef __BIONIC__
__gthrw(pthread_cancel)
#endif
__gthrw(sched_yield)
__gthrw(pthread_mutex_lock)
__gthrw(pthread_mutex_trylock)
#if _GTHREAD_USE_MUTEX_TIMEDLOCK
__gthrw(pthread_mutex_timedlock)
#endif
__gthrw(pthread_mutex_unlock)
__gthrw(pthread_mutex_init)
__gthrw(pthread_mutex_destroy)
__gthrw(pthread_cond_init)
__gthrw(pthread_cond_broadcast)
__gthrw(pthread_cond_signal)
__gthrw(pthread_cond_wait)
__gthrw(pthread_cond_timedwait)
__gthrw(pthread_cond_destroy)
__gthrw(pthread_key_create)
__gthrw(pthread_key_delete)
__gthrw(pthread_mutexattr_init)
__gthrw(pthread_mutexattr_settype)
__gthrw(pthread_mutexattr_destroy)
#if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)
/* Objective-C. */
__gthrw(pthread_exit)
#ifdef _POSIX_PRIORITY_SCHEDULING
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
__gthrw(sched_get_priority_max)
__gthrw(sched_get_priority_min)
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
#endif /* _POSIX_PRIORITY_SCHEDULING */
__gthrw(pthread_attr_destroy)
__gthrw(pthread_attr_init)
__gthrw(pthread_attr_setdetachstate)
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
__gthrw(pthread_getschedparam)
__gthrw(pthread_setschedparam)
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
#endif /* _LIBOBJC || _LIBOBJC_WEAK */
#if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK
/* On Solaris 2.6 up to 9, the libc exposes a POSIX threads interface even if
-pthreads is not specified. The functions are dummies and most return an
error value. However pthread_once returns 0 without invoking the routine
it is passed so we cannot pretend that the interface is active if -pthreads
is not specified. On Solaris 2.5.1, the interface is not exposed at all so
we need to play the usual game with weak symbols. On Solaris 10 and up, a
working interface is always exposed. On FreeBSD 6 and later, libc also
exposes a dummy POSIX threads interface, similar to what Solaris 2.6 up
to 9 does. FreeBSD >= 700014 even provides a pthread_cancel stub in libc,
which means the alternate __gthread_active_p below cannot be used there. */
#if defined(__FreeBSD__) || (defined(__sun) && defined(__svr4__))
static volatile int __gthread_active = -1;
static void
__gthread_trigger (void)
{
__gthread_active = 1;
}
static inline int
__gthread_active_p (void)
{
static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_once_t __gthread_active_once = PTHREAD_ONCE_INIT;
/* Avoid reading __gthread_active twice on the main code path. */
int __gthread_active_latest_value = __gthread_active;
/* This test is not protected to avoid taking a lock on the main code
path so every update of __gthread_active in a threaded program must
be atomic with regard to the result of the test. */
if (__builtin_expect (__gthread_active_latest_value < 0, 0))
{
if (__gthrw_(pthread_once))
{
/* If this really is a threaded program, then we must ensure that
__gthread_active has been set to 1 before exiting this block. */
__gthrw_(pthread_mutex_lock) (&__gthread_active_mutex);
__gthrw_(pthread_once) (&__gthread_active_once, __gthread_trigger);
__gthrw_(pthread_mutex_unlock) (&__gthread_active_mutex);
}
/* Make sure we'll never enter this block again. */
if (__gthread_active < 0)
__gthread_active = 0;
__gthread_active_latest_value = __gthread_active;
}
return __gthread_active_latest_value != 0;
}
#else /* neither FreeBSD nor Solaris */
/* For a program to be multi-threaded the only thing that it certainly must
be using is pthread_create. However, there may be other libraries that
intercept pthread_create with their own definitions to wrap pthreads
functionality for some purpose. In those cases, pthread_create being
defined might not necessarily mean that libpthread is actually linked
in.
For the GNU C library, we can use a known internal name. This is always
available in the ABI, but no other library would define it. That is
ideal, since any public pthread function might be intercepted just as
pthread_create might be. __pthread_key_create is an "internal"
implementation symbol, but it is part of the public exported ABI. Also,
it's among the symbols that the static libpthread.a always links in
whenever pthread_create is used, so there is no danger of a false
negative result in any statically-linked, multi-threaded program.
For others, we choose pthread_cancel as a function that seems unlikely
to be redefined by an interceptor library. The bionic (Android) C
library does not provide pthread_cancel, so we do use pthread_create
there (and interceptor libraries lose). */
#ifdef __GLIBC__
__gthrw2(__gthrw_(__pthread_key_create),
__pthread_key_create,
pthread_key_create)
# define GTHR_ACTIVE_PROXY __gthrw_(__pthread_key_create)
#elif defined (__BIONIC__)
# define GTHR_ACTIVE_PROXY __gthrw_(pthread_create)
#else
# define GTHR_ACTIVE_PROXY __gthrw_(pthread_cancel)
#endif
static inline int
__gthread_active_p (void)
{
static void *const __gthread_active_ptr
= __extension__ (void *) >HR_ACTIVE_PROXY;
return __gthread_active_ptr != 0;
}
#endif /* FreeBSD or Solaris */
#else /* not __GXX_WEAK__ */
/* Similar to Solaris, HP-UX 11 for PA-RISC provides stubs for pthread
calls in shared flavors of the HP-UX C library. Most of the stubs
have no functionality. The details are described in the "libc cumulative
patch" for each subversion of HP-UX 11. There are two special interfaces
provided for checking whether an application is linked to a shared pthread
library or not. However, these interfaces aren't available in early
libpthread libraries. We also need a test that works for archive
libraries. We can't use pthread_once as some libc versions call the
init function. We also can't use pthread_create or pthread_attr_init
as these create a thread and thereby prevent changing the default stack
size. The function pthread_default_stacksize_np is available in both
the archive and shared versions of libpthread. It can be used to
determine the default pthread stack size. There is a stub in some
shared libc versions which returns a zero size if pthreads are not
active. We provide an equivalent stub to handle cases where libc
doesn't provide one. */
#if defined(__hppa__) && defined(__hpux__)
static volatile int __gthread_active = -1;
static inline int
__gthread_active_p (void)
{
/* Avoid reading __gthread_active twice on the main code path. */
int __gthread_active_latest_value = __gthread_active;
size_t __s;
if (__builtin_expect (__gthread_active_latest_value < 0, 0))
{
pthread_default_stacksize_np (0, &__s);
__gthread_active = __s ? 1 : 0;
__gthread_active_latest_value = __gthread_active;
}
return __gthread_active_latest_value != 0;
}
#else /* not hppa-hpux */
static inline int
__gthread_active_p (void)
{
return 1;
}
#endif /* hppa-hpux */
#endif /* __GXX_WEAK__ */
#ifdef _LIBOBJC
/* This is the config.h file in libobjc/ */
#include <config.h>
#ifdef HAVE_SCHED_H
# include <sched.h>
#endif
/* Key structure for maintaining thread specific storage */
static pthread_key_t _objc_thread_storage;
static pthread_attr_t _objc_thread_attribs;
/* Thread local storage for a single thread */
static void *thread_local_storage = NULL;
/* Backend initialization functions */
/* Initialize the threads subsystem. */
static inline int
__gthread_objc_init_thread_system (void)
{
if (__gthread_active_p ())
{
/* Initialize the thread storage key. */
if (__gthrw_(pthread_key_create) (&_objc_thread_storage, NULL) == 0)
{
/* The normal default detach state for threads is
* PTHREAD_CREATE_JOINABLE which causes threads to not die
* when you think they should. */
if (__gthrw_(pthread_attr_init) (&_objc_thread_attribs) == 0
&& __gthrw_(pthread_attr_setdetachstate) (&_objc_thread_attribs,
PTHREAD_CREATE_DETACHED) == 0)
return 0;
}
}
return -1;
}
/* Close the threads subsystem. */
static inline int
__gthread_objc_close_thread_system (void)
{
if (__gthread_active_p ()
&& __gthrw_(pthread_key_delete) (_objc_thread_storage) == 0
&& __gthrw_(pthread_attr_destroy) (&_objc_thread_attribs) == 0)
return 0;
return -1;
}
/* Backend thread functions */
/* Create a new thread of execution. */
static inline objc_thread_t
__gthread_objc_thread_detach (void (*func)(void *), void *arg)
{
objc_thread_t thread_id;
pthread_t new_thread_handle;
if (!__gthread_active_p ())
return NULL;
if (!(__gthrw_(pthread_create) (&new_thread_handle, &_objc_thread_attribs,
(void *) func, arg)))
thread_id = (objc_thread_t) new_thread_handle;
else
thread_id = NULL;
return thread_id;
}
/* Set the current thread's priority. */
static inline int
__gthread_objc_thread_set_priority (int priority)
{
if (!__gthread_active_p ())
return -1;
else
{
#ifdef _POSIX_PRIORITY_SCHEDULING
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
pthread_t thread_id = __gthrw_(pthread_self) ();
int policy;
struct sched_param params;
int priority_min, priority_max;
if (__gthrw_(pthread_getschedparam) (thread_id, &policy, ¶ms) == 0)
{
if ((priority_max = __gthrw_(sched_get_priority_max) (policy)) == -1)
return -1;
if ((priority_min = __gthrw_(sched_get_priority_min) (policy)) == -1)
return -1;
if (priority > priority_max)
priority = priority_max;
else if (priority < priority_min)
priority = priority_min;
params.sched_priority = priority;
/*
* The solaris 7 and several other man pages incorrectly state that
* this should be a pointer to policy but pthread.h is universally
* at odds with this.
*/
if (__gthrw_(pthread_setschedparam) (thread_id, policy, ¶ms) == 0)
return 0;
}
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
#endif /* _POSIX_PRIORITY_SCHEDULING */
return -1;
}
}
/* Return the current thread's priority. */
static inline int
__gthread_objc_thread_get_priority (void)
{
#ifdef _POSIX_PRIORITY_SCHEDULING
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
if (__gthread_active_p ())
{
int policy;
struct sched_param params;
if (__gthrw_(pthread_getschedparam) (__gthrw_(pthread_self) (), &policy, ¶ms) == 0)
return params.sched_priority;
else
return -1;
}
else
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
#endif /* _POSIX_PRIORITY_SCHEDULING */
return OBJC_THREAD_INTERACTIVE_PRIORITY;
}
/* Yield our process time to another thread. */
static inline void
__gthread_objc_thread_yield (void)
{
if (__gthread_active_p ())
__gthrw_(sched_yield) ();
}
/* Terminate the current thread. */
static inline int
__gthread_objc_thread_exit (void)
{
if (__gthread_active_p ())
/* exit the thread */
__gthrw_(pthread_exit) (&__objc_thread_exit_status);
/* Failed if we reached here */
return -1;
}
/* Returns an integer value which uniquely describes a thread. */
static inline objc_thread_t
__gthread_objc_thread_id (void)
{
if (__gthread_active_p ())
return (objc_thread_t) __gthrw_(pthread_self) ();
else
return (objc_thread_t) 1;
}
/* Sets the thread's local storage pointer. */
static inline int
__gthread_objc_thread_set_data (void *value)
{
if (__gthread_active_p ())
return __gthrw_(pthread_setspecific) (_objc_thread_storage, value);
else
{
thread_local_storage = value;
return 0;
}
}
/* Returns the thread's local storage pointer. */
static inline void *
__gthread_objc_thread_get_data (void)
{
if (__gthread_active_p ())
return __gthrw_(pthread_getspecific) (_objc_thread_storage);
else
return thread_local_storage;
}
/* Backend mutex functions */
/* Allocate a mutex. */
static inline int
__gthread_objc_mutex_allocate (objc_mutex_t mutex)
{
if (__gthread_active_p ())
{
mutex->backend = objc_malloc (sizeof (pthread_mutex_t));
if (__gthrw_(pthread_mutex_init) ((pthread_mutex_t *) mutex->backend, NULL))
{
objc_free (mutex->backend);
mutex->backend = NULL;
return -1;
}
}
return 0;
}
/* Deallocate a mutex. */
static inline int
__gthread_objc_mutex_deallocate (objc_mutex_t mutex)
{
if (__gthread_active_p ())
{
int count;
/*
* Posix Threads specifically require that the thread be unlocked
* for __gthrw_(pthread_mutex_destroy) to work.
*/
do
{
count = __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend);
if (count < 0)
return -1;
}
while (count);
if (__gthrw_(pthread_mutex_destroy) ((pthread_mutex_t *) mutex->backend))
return -1;
objc_free (mutex->backend);
mutex->backend = NULL;
}
return 0;
}
/* Grab a lock on a mutex. */
static inline int
__gthread_objc_mutex_lock (objc_mutex_t mutex)
{
if (__gthread_active_p ()
&& __gthrw_(pthread_mutex_lock) ((pthread_mutex_t *) mutex->backend) != 0)
{
return -1;
}
return 0;
}
/* Try to grab a lock on a mutex. */
static inline int
__gthread_objc_mutex_trylock (objc_mutex_t mutex)
{
if (__gthread_active_p ()
&& __gthrw_(pthread_mutex_trylock) ((pthread_mutex_t *) mutex->backend) != 0)
{
return -1;
}
return 0;
}
/* Unlock the mutex */
static inline int
__gthread_objc_mutex_unlock (objc_mutex_t mutex)
{
if (__gthread_active_p ()
&& __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend) != 0)
{
return -1;
}
return 0;
}
/* Backend condition mutex functions */
/* Allocate a condition. */
static inline int
__gthread_objc_condition_allocate (objc_condition_t condition)
{
if (__gthread_active_p ())
{
condition->backend = objc_malloc (sizeof (pthread_cond_t));
if (__gthrw_(pthread_cond_init) ((pthread_cond_t *) condition->backend, NULL))
{
objc_free (condition->backend);
condition->backend = NULL;
return -1;
}
}
return 0;
}
/* Deallocate a condition. */
static inline int
__gthread_objc_condition_deallocate (objc_condition_t condition)
{
if (__gthread_active_p ())
{
if (__gthrw_(pthread_cond_destroy) ((pthread_cond_t *) condition->backend))
return -1;
objc_free (condition->backend);
condition->backend = NULL;
}
return 0;
}
/* Wait on the condition */
static inline int
__gthread_objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex)
{
if (__gthread_active_p ())
return __gthrw_(pthread_cond_wait) ((pthread_cond_t *) condition->backend,
(pthread_mutex_t *) mutex->backend);
else
return 0;
}
/* Wake up all threads waiting on this condition. */
static inline int
__gthread_objc_condition_broadcast (objc_condition_t condition)
{
if (__gthread_active_p ())
return __gthrw_(pthread_cond_broadcast) ((pthread_cond_t *) condition->backend);
else
return 0;
}
/* Wake up one thread waiting on this condition. */
static inline int
__gthread_objc_condition_signal (objc_condition_t condition)
{
if (__gthread_active_p ())
return __gthrw_(pthread_cond_signal) ((pthread_cond_t *) condition->backend);
else
return 0;
}
#else /* _LIBOBJC */
static inline int
__gthread_create (__gthread_t *__threadid, void *(*__func) (void*),
void *__args)
{
return __gthrw_(pthread_create) (__threadid, NULL, __func, __args);
}
static inline int
__gthread_join (__gthread_t __threadid, void **__value_ptr)
{
return __gthrw_(pthread_join) (__threadid, __value_ptr);
}
static inline int
__gthread_detach (__gthread_t __threadid)
{
return __gthrw_(pthread_detach) (__threadid);
}
static inline int
__gthread_equal (__gthread_t __t1, __gthread_t __t2)
{
return __gthrw_(pthread_equal) (__t1, __t2);
}
static inline __gthread_t
__gthread_self (void)
{
return __gthrw_(pthread_self) ();
}
static inline int
__gthread_yield (void)
{
return __gthrw_(sched_yield) ();
}
static inline int
__gthread_once (__gthread_once_t *__once, void (*__func) (void))
{
if (__gthread_active_p ())
return __gthrw_(pthread_once) (__once, __func);
else
return -1;
}
static inline int
__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *))
{
return __gthrw_(pthread_key_create) (__key, __dtor);
}
static inline int
__gthread_key_delete (__gthread_key_t __key)
{
return __gthrw_(pthread_key_delete) (__key);
}
static inline void *
__gthread_getspecific (__gthread_key_t __key)
{
return __gthrw_(pthread_getspecific) (__key);
}
static inline int
__gthread_setspecific (__gthread_key_t __key, const void *__ptr)
{
return __gthrw_(pthread_setspecific) (__key, __ptr);
}
static inline void
__gthread_mutex_init_function (__gthread_mutex_t *__mutex)
{
if (__gthread_active_p ())
__gthrw_(pthread_mutex_init) (__mutex, NULL);
}
static inline int
__gthread_mutex_destroy (__gthread_mutex_t *__mutex)
{
if (__gthread_active_p ())
return __gthrw_(pthread_mutex_destroy) (__mutex);
else
return 0;
}
static inline int
__gthread_mutex_lock (__gthread_mutex_t *__mutex)
{
if (__gthread_active_p ())
return __gthrw_(pthread_mutex_lock) (__mutex);
else
return 0;
}
static inline int
__gthread_mutex_trylock (__gthread_mutex_t *__mutex)
{
if (__gthread_active_p ())
return __gthrw_(pthread_mutex_trylock) (__mutex);
else
return 0;
}
#if _GTHREAD_USE_MUTEX_TIMEDLOCK
static inline int
__gthread_mutex_timedlock (__gthread_mutex_t *__mutex,
const __gthread_time_t *__abs_timeout)
{
if (__gthread_active_p ())
return __gthrw_(pthread_mutex_timedlock) (__mutex, __abs_timeout);
else
return 0;
}
#endif
static inline int
__gthread_mutex_unlock (__gthread_mutex_t *__mutex)
{
if (__gthread_active_p ())
return __gthrw_(pthread_mutex_unlock) (__mutex);
else
return 0;
}
#if !defined( PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) \
|| defined(_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC)
static inline int
__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex)
{
if (__gthread_active_p ())
{
pthread_mutexattr_t __attr;
int __r;
__r = __gthrw_(pthread_mutexattr_init) (&__attr);
if (!__r)
__r = __gthrw_(pthread_mutexattr_settype) (&__attr,
PTHREAD_MUTEX_RECURSIVE);
if (!__r)
__r = __gthrw_(pthread_mutex_init) (__mutex, &__attr);
if (!__r)
__r = __gthrw_(pthread_mutexattr_destroy) (&__attr);
return __r;
}
return 0;
}
#endif
static inline int
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_lock (__mutex);
}
static inline int
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_trylock (__mutex);
}
#if _GTHREAD_USE_MUTEX_TIMEDLOCK
static inline int
__gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *__mutex,
const __gthread_time_t *__abs_timeout)
{
return __gthread_mutex_timedlock (__mutex, __abs_timeout);
}
#endif
static inline int
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_unlock (__mutex);
}
static inline int
__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_destroy (__mutex);
}
#ifdef _GTHREAD_USE_COND_INIT_FUNC
static inline void
__gthread_cond_init_function (__gthread_cond_t *__cond)
{
if (__gthread_active_p ())
__gthrw_(pthread_cond_init) (__cond, NULL);
}
#endif
static inline int
__gthread_cond_broadcast (__gthread_cond_t *__cond)
{
return __gthrw_(pthread_cond_broadcast) (__cond);
}
static inline int
__gthread_cond_signal (__gthread_cond_t *__cond)
{
return __gthrw_(pthread_cond_signal) (__cond);
}
static inline int
__gthread_cond_wait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex)
{
return __gthrw_(pthread_cond_wait) (__cond, __mutex);
}
static inline int
__gthread_cond_timedwait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex,
const __gthread_time_t *__abs_timeout)
{
return __gthrw_(pthread_cond_timedwait) (__cond, __mutex, __abs_timeout);
}
static inline int
__gthread_cond_wait_recursive (__gthread_cond_t *__cond,
__gthread_recursive_mutex_t *__mutex)
{
return __gthread_cond_wait (__cond, __mutex);
}
static inline int
__gthread_cond_destroy (__gthread_cond_t* __cond)
{
return __gthrw_(pthread_cond_destroy) (__cond);
}
#endif /* _LIBOBJC */
#endif /* ! _GLIBCXX_GCC_GTHR_POSIX_H */
c++/8/x86_64-redhat-linux/32/bits/time_members.h 0000644 00000005554 15201526705 0014645 0 ustar 00 // std::time_get, std::time_put implementation, GNU version -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/time_members.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{locale}
*/
//
// ISO C++ 14882: 22.2.5.1.2 - time_get functions
// ISO C++ 14882: 22.2.5.3.2 - time_put functions
//
// Written by Benjamin Kosnik <bkoz@redhat.com>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _CharT>
__timepunct<_CharT>::__timepunct(size_t __refs)
: facet(__refs), _M_data(0), _M_c_locale_timepunct(0),
_M_name_timepunct(_S_get_c_name())
{ _M_initialize_timepunct(); }
template<typename _CharT>
__timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs)
: facet(__refs), _M_data(__cache), _M_c_locale_timepunct(0),
_M_name_timepunct(_S_get_c_name())
{ _M_initialize_timepunct(); }
template<typename _CharT>
__timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
size_t __refs)
: facet(__refs), _M_data(0), _M_c_locale_timepunct(0),
_M_name_timepunct(0)
{
if (__builtin_strcmp(__s, _S_get_c_name()) != 0)
{
const size_t __len = __builtin_strlen(__s) + 1;
char* __tmp = new char[__len];
__builtin_memcpy(__tmp, __s, __len);
_M_name_timepunct = __tmp;
}
else
_M_name_timepunct = _S_get_c_name();
__try
{ _M_initialize_timepunct(__cloc); }
__catch(...)
{
if (_M_name_timepunct != _S_get_c_name())
delete [] _M_name_timepunct;
__throw_exception_again;
}
}
template<typename _CharT>
__timepunct<_CharT>::~__timepunct()
{
if (_M_name_timepunct != _S_get_c_name())
delete [] _M_name_timepunct;
delete _M_data;
_S_destroy_c_locale(_M_c_locale_timepunct);
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
c++/8/x86_64-redhat-linux/32/bits/ctype_inline.h 0000644 00000004354 15201526705 0014654 0 ustar 00 // Locale support -*- C++ -*-
// Copyright (C) 2000-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/ctype_inline.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{locale}
*/
//
// ISO C++ 14882: 22.1 Locales
//
// ctype bits to be inlined go here. Non-inlinable (ie virtual do_*)
// functions go in ctype.cc
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
bool
ctype<char>::
is(mask __m, char __c) const
{ return _M_table[static_cast<unsigned char>(__c)] & __m; }
const char*
ctype<char>::
is(const char* __low, const char* __high, mask* __vec) const
{
while (__low < __high)
*__vec++ = _M_table[static_cast<unsigned char>(*__low++)];
return __high;
}
const char*
ctype<char>::
scan_is(mask __m, const char* __low, const char* __high) const
{
while (__low < __high
&& !(_M_table[static_cast<unsigned char>(*__low)] & __m))
++__low;
return __low;
}
const char*
ctype<char>::
scan_not(mask __m, const char* __low, const char* __high) const
{
while (__low < __high
&& (_M_table[static_cast<unsigned char>(*__low)] & __m) != 0)
++__low;
return __low;
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
c++/8/x86_64-redhat-linux/32/bits/gthr-single.h 0000644 00000015230 15201526705 0014410 0 ustar 00 /* Threads compatibility routines for libgcc2 and libobjc. */
/* Compile this one with gcc. */
/* Copyright (C) 1997-2018 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _GLIBCXX_GCC_GTHR_SINGLE_H
#define _GLIBCXX_GCC_GTHR_SINGLE_H
/* Just provide compatibility for mutex handling. */
typedef int __gthread_key_t;
typedef int __gthread_once_t;
typedef int __gthread_mutex_t;
typedef int __gthread_recursive_mutex_t;
#define __GTHREAD_ONCE_INIT 0
#define __GTHREAD_MUTEX_INIT 0
#define __GTHREAD_MUTEX_INIT_FUNCTION(mx) do {} while (0)
#define __GTHREAD_RECURSIVE_MUTEX_INIT 0
#define _GLIBCXX_UNUSED __attribute__((__unused__))
#ifdef _LIBOBJC
/* Thread local storage for a single thread */
static void *thread_local_storage = NULL;
/* Backend initialization functions */
/* Initialize the threads subsystem. */
static inline int
__gthread_objc_init_thread_system (void)
{
/* No thread support available */
return -1;
}
/* Close the threads subsystem. */
static inline int
__gthread_objc_close_thread_system (void)
{
/* No thread support available */
return -1;
}
/* Backend thread functions */
/* Create a new thread of execution. */
static inline objc_thread_t
__gthread_objc_thread_detach (void (* func)(void *), void * arg _GLIBCXX_UNUSED)
{
/* No thread support available */
return NULL;
}
/* Set the current thread's priority. */
static inline int
__gthread_objc_thread_set_priority (int priority _GLIBCXX_UNUSED)
{
/* No thread support available */
return -1;
}
/* Return the current thread's priority. */
static inline int
__gthread_objc_thread_get_priority (void)
{
return OBJC_THREAD_INTERACTIVE_PRIORITY;
}
/* Yield our process time to another thread. */
static inline void
__gthread_objc_thread_yield (void)
{
return;
}
/* Terminate the current thread. */
static inline int
__gthread_objc_thread_exit (void)
{
/* No thread support available */
/* Should we really exit the program */
/* exit (&__objc_thread_exit_status); */
return -1;
}
/* Returns an integer value which uniquely describes a thread. */
static inline objc_thread_t
__gthread_objc_thread_id (void)
{
/* No thread support, use 1. */
return (objc_thread_t) 1;
}
/* Sets the thread's local storage pointer. */
static inline int
__gthread_objc_thread_set_data (void *value)
{
thread_local_storage = value;
return 0;
}
/* Returns the thread's local storage pointer. */
static inline void *
__gthread_objc_thread_get_data (void)
{
return thread_local_storage;
}
/* Backend mutex functions */
/* Allocate a mutex. */
static inline int
__gthread_objc_mutex_allocate (objc_mutex_t mutex _GLIBCXX_UNUSED)
{
return 0;
}
/* Deallocate a mutex. */
static inline int
__gthread_objc_mutex_deallocate (objc_mutex_t mutex _GLIBCXX_UNUSED)
{
return 0;
}
/* Grab a lock on a mutex. */
static inline int
__gthread_objc_mutex_lock (objc_mutex_t mutex _GLIBCXX_UNUSED)
{
/* There can only be one thread, so we always get the lock */
return 0;
}
/* Try to grab a lock on a mutex. */
static inline int
__gthread_objc_mutex_trylock (objc_mutex_t mutex _GLIBCXX_UNUSED)
{
/* There can only be one thread, so we always get the lock */
return 0;
}
/* Unlock the mutex */
static inline int
__gthread_objc_mutex_unlock (objc_mutex_t mutex _GLIBCXX_UNUSED)
{
return 0;
}
/* Backend condition mutex functions */
/* Allocate a condition. */
static inline int
__gthread_objc_condition_allocate (objc_condition_t condition _GLIBCXX_UNUSED)
{
return 0;
}
/* Deallocate a condition. */
static inline int
__gthread_objc_condition_deallocate (objc_condition_t condition _GLIBCXX_UNUSED)
{
return 0;
}
/* Wait on the condition */
static inline int
__gthread_objc_condition_wait (objc_condition_t condition _GLIBCXX_UNUSED,
objc_mutex_t mutex _GLIBCXX_UNUSED)
{
return 0;
}
/* Wake up all threads waiting on this condition. */
static inline int
__gthread_objc_condition_broadcast (objc_condition_t condition _GLIBCXX_UNUSED)
{
return 0;
}
/* Wake up one thread waiting on this condition. */
static inline int
__gthread_objc_condition_signal (objc_condition_t condition _GLIBCXX_UNUSED)
{
return 0;
}
#else /* _LIBOBJC */
static inline int
__gthread_active_p (void)
{
return 0;
}
static inline int
__gthread_once (__gthread_once_t *__once _GLIBCXX_UNUSED, void (*__func) (void) _GLIBCXX_UNUSED)
{
return 0;
}
static inline int _GLIBCXX_UNUSED
__gthread_key_create (__gthread_key_t *__key _GLIBCXX_UNUSED, void (*__func) (void *) _GLIBCXX_UNUSED)
{
return 0;
}
static int _GLIBCXX_UNUSED
__gthread_key_delete (__gthread_key_t __key _GLIBCXX_UNUSED)
{
return 0;
}
static inline void *
__gthread_getspecific (__gthread_key_t __key _GLIBCXX_UNUSED)
{
return 0;
}
static inline int
__gthread_setspecific (__gthread_key_t __key _GLIBCXX_UNUSED, const void *__v _GLIBCXX_UNUSED)
{
return 0;
}
static inline int
__gthread_mutex_destroy (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
{
return 0;
}
static inline int
__gthread_mutex_lock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
{
return 0;
}
static inline int
__gthread_mutex_trylock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
{
return 0;
}
static inline int
__gthread_mutex_unlock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
{
return 0;
}
static inline int
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_lock (__mutex);
}
static inline int
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_trylock (__mutex);
}
static inline int
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_unlock (__mutex);
}
static inline int
__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_destroy (__mutex);
}
#endif /* _LIBOBJC */
#undef _GLIBCXX_UNUSED
#endif /* ! _GLIBCXX_GCC_GTHR_SINGLE_H */
c++/8/x86_64-redhat-linux/32/bits/c++allocator.h 0000644 00000003673 15201526705 0014446 0 ustar 00 // Base to std::allocator -*- C++ -*-
// Copyright (C) 2004-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/c++allocator.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{memory}
*/
#ifndef _GLIBCXX_CXX_ALLOCATOR_H
#define _GLIBCXX_CXX_ALLOCATOR_H 1
#include <ext/new_allocator.h>
#if __cplusplus >= 201103L
namespace std
{
/**
* @brief An alias to the base class for std::allocator.
* @ingroup allocators
*
* Used to set the std::allocator base class to
* __gnu_cxx::new_allocator.
*
* @tparam _Tp Type of allocated object.
*/
template<typename _Tp>
using __allocator_base = __gnu_cxx::new_allocator<_Tp>;
}
#else
// Define new_allocator as the base class to std::allocator.
# define __allocator_base __gnu_cxx::new_allocator
#endif
#if defined(__SANITIZE_ADDRESS__) && !defined(_GLIBCXX_SANITIZE_STD_ALLOCATOR)
# define _GLIBCXX_SANITIZE_STD_ALLOCATOR 1
#endif
#endif
c++/8/x86_64-redhat-linux/32/bits/ctype_base.h 0000644 00000004414 15201526705 0014305 0 ustar 00 // Locale support -*- C++ -*-
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/ctype_base.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{locale}
*/
//
// ISO C++ 14882: 22.1 Locales
//
// Information as gleaned from /usr/include/ctype.h
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/// @brief Base class for ctype.
struct ctype_base
{
// Non-standard typedefs.
typedef const int* __to_type;
// NB: Offsets into ctype<char>::_M_table force a particular size
// on the mask type. Because of this, we don't use an enum.
typedef unsigned short mask;
static const mask upper = _ISupper;
static const mask lower = _ISlower;
static const mask alpha = _ISalpha;
static const mask digit = _ISdigit;
static const mask xdigit = _ISxdigit;
static const mask space = _ISspace;
static const mask print = _ISprint;
static const mask graph = _ISalpha | _ISdigit | _ISpunct;
static const mask cntrl = _IScntrl;
static const mask punct = _ISpunct;
static const mask alnum = _ISalpha | _ISdigit;
#if __cplusplus >= 201103L
static const mask blank = _ISblank;
#endif
};
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
c++/8/x86_64-redhat-linux/32/bits/cxxabi_tweaks.h 0000644 00000004060 15201526705 0015020 0 ustar 00 // Control various target specific ABI tweaks. Generic version.
// Copyright (C) 2004-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/cxxabi_tweaks.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{cxxabi.h}
*/
#ifndef _CXXABI_TWEAKS_H
#define _CXXABI_TWEAKS_H 1
#ifdef __cplusplus
namespace __cxxabiv1
{
extern "C"
{
#endif
// The generic ABI uses the first byte of a 64-bit guard variable.
#define _GLIBCXX_GUARD_TEST(x) (*(char *) (x) != 0)
#define _GLIBCXX_GUARD_SET(x) *(char *) (x) = 1
#define _GLIBCXX_GUARD_BIT __guard_test_bit (0, 1)
#define _GLIBCXX_GUARD_PENDING_BIT __guard_test_bit (1, 1)
#define _GLIBCXX_GUARD_WAITING_BIT __guard_test_bit (2, 1)
__extension__ typedef int __guard __attribute__((mode (__DI__)));
// __cxa_vec_ctor has void return type.
typedef void __cxa_vec_ctor_return_type;
#define _GLIBCXX_CXA_VEC_CTOR_RETURN(x) return
// Constructors and destructors do not return a value.
typedef void __cxa_cdtor_return_type;
#ifdef __cplusplus
}
} // namespace __cxxabiv1
#endif
#endif
c++/8/x86_64-redhat-linux/32/bits/basic_file.h 0000644 00000006553 15201526705 0014255 0 ustar 00 // Wrapper of C-language FILE struct -*- C++ -*-
// Copyright (C) 2000-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 27.8 File-based streams
//
/** @file bits/basic_file.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{ios}
*/
#ifndef _GLIBCXX_BASIC_FILE_STDIO_H
#define _GLIBCXX_BASIC_FILE_STDIO_H 1
#pragma GCC system_header
#include <bits/c++config.h>
#include <bits/c++io.h> // for __c_lock and __c_file
#include <bits/move.h> // for swap
#include <ios>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Generic declaration.
template<typename _CharT>
class __basic_file;
// Specialization.
template<>
class __basic_file<char>
{
// Underlying data source/sink.
__c_file* _M_cfile;
// True iff we opened _M_cfile, and thus must close it ourselves.
bool _M_cfile_created;
public:
__basic_file(__c_lock* __lock = 0) throw ();
#if __cplusplus >= 201103L
__basic_file(__basic_file&& __rv, __c_lock* = 0) noexcept
: _M_cfile(__rv._M_cfile), _M_cfile_created(__rv._M_cfile_created)
{
__rv._M_cfile = nullptr;
__rv._M_cfile_created = false;
}
__basic_file& operator=(const __basic_file&) = delete;
__basic_file& operator=(__basic_file&&) = delete;
void
swap(__basic_file& __f) noexcept
{
std::swap(_M_cfile, __f._M_cfile);
std::swap(_M_cfile_created, __f._M_cfile_created);
}
#endif
__basic_file*
open(const char* __name, ios_base::openmode __mode, int __prot = 0664);
__basic_file*
sys_open(__c_file* __file, ios_base::openmode);
__basic_file*
sys_open(int __fd, ios_base::openmode __mode) throw ();
__basic_file*
close();
_GLIBCXX_PURE bool
is_open() const throw ();
_GLIBCXX_PURE int
fd() throw ();
_GLIBCXX_PURE __c_file*
file() throw ();
~__basic_file();
streamsize
xsputn(const char* __s, streamsize __n);
streamsize
xsputn_2(const char* __s1, streamsize __n1,
const char* __s2, streamsize __n2);
streamsize
xsgetn(char* __s, streamsize __n);
streamoff
seekoff(streamoff __off, ios_base::seekdir __way) throw ();
int
sync();
streamsize
showmanyc();
};
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/x86_64-redhat-linux/32/bits/os_defines.h 0000644 00000003727 15201526705 0014313 0 ustar 00 // Specific definitions for GNU/Linux -*- C++ -*-
// Copyright (C) 2000-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/os_defines.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{iosfwd}
*/
#ifndef _GLIBCXX_OS_DEFINES
#define _GLIBCXX_OS_DEFINES 1
// System-specific #define, typedefs, corrections, etc, go here. This
// file will come before all others.
// This keeps isanum, et al from being propagated as macros.
#define __NO_CTYPE 1
#include <features.h>
// Provide a declaration for the possibly deprecated gets function, as
// glibc 2.15 and later does not declare gets for ISO C11 when
// __GNU_SOURCE is defined.
#if __GLIBC_PREREQ(2,15) && defined(_GNU_SOURCE)
# undef _GLIBCXX_HAVE_GETS
#endif
// Glibc 2.23 removed the obsolete isinf and isnan declarations. Check the
// version dynamically in case it has changed since libstdc++ was configured.
#define _GLIBCXX_NO_OBSOLETE_ISINF_ISNAN_DYNAMIC __GLIBC_PREREQ(2,23)
#endif
c++/8/x86_64-redhat-linux/32/bits/stdtr1c++.h 0000644 00000003315 15201526705 0013700 0 ustar 00 // C++ includes used for precompiling TR1 -*- C++ -*-
// Copyright (C) 2006-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file stdtr1c++.h
* This is an implementation file for a precompiled header.
*/
#include <bits/stdc++.h>
#include <tr1/array>
#include <tr1/cctype>
#include <tr1/cfenv>
#include <tr1/cfloat>
#include <tr1/cinttypes>
#include <tr1/climits>
#include <tr1/cmath>
#include <tr1/complex>
#include <tr1/cstdarg>
#include <tr1/cstdbool>
#include <tr1/cstdint>
#include <tr1/cstdio>
#include <tr1/cstdlib>
#include <tr1/ctgmath>
#include <tr1/ctime>
#include <tr1/cwchar>
#include <tr1/cwctype>
#include <tr1/functional>
#include <tr1/random>
#include <tr1/tuple>
#include <tr1/unordered_map>
#include <tr1/unordered_set>
#include <tr1/utility>
c++/8/x86_64-redhat-linux/32/bits/extc++.h 0000644 00000005145 15201526705 0013262 0 ustar 00 // C++ includes used for precompiling extensions -*- C++ -*-
// Copyright (C) 2006-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file extc++.h
* This is an implementation file for a precompiled header.
*/
#if __cplusplus < 201103L
#include <bits/stdtr1c++.h>
#else
#include <bits/stdc++.h>
#endif
#include <ext/algorithm>
#if __cplusplus >= 201103L
# include <ext/aligned_buffer.h>
#endif
#include <ext/alloc_traits.h>
#include <ext/array_allocator.h>
#include <ext/atomicity.h>
#include <ext/bitmap_allocator.h>
#include <ext/cast.h>
#if __cplusplus >= 201103L
# include <ext/cmath>
#endif
#include <ext/concurrence.h>
#include <ext/debug_allocator.h>
#include <ext/extptr_allocator.h>
#include <ext/functional>
#include <ext/iterator>
#include <ext/malloc_allocator.h>
#include <ext/memory>
#include <ext/mt_allocator.h>
#include <ext/new_allocator.h>
#include <ext/numeric>
#include <ext/numeric_traits.h>
#include <ext/pod_char_traits.h>
#include <ext/pointer.h>
#include <ext/pool_allocator.h>
#if __cplusplus >= 201103L
# include <ext/random>
#endif
#include <ext/rb_tree>
#include <ext/rope>
#include <ext/slist>
#include <ext/stdio_filebuf.h>
#include <ext/stdio_sync_filebuf.h>
#include <ext/throw_allocator.h>
#include <ext/typelist.h>
#include <ext/type_traits.h>
#include <ext/vstring.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include <ext/pb_ds/exception.hpp>
#include <ext/pb_ds/hash_policy.hpp>
#include <ext/pb_ds/list_update_policy.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#ifdef _GLIBCXX_HAVE_ICONV
#include <ext/codecvt_specializations.h>
#include <ext/enc_filebuf.h>
#endif
c++/8/x86_64-redhat-linux/32/bits/c++config.h 0000644 00000160477 15201526705 0013741 0 ustar 00 // Predefined symbols and macros -*- C++ -*-
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/c++config.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{iosfwd}
*/
#ifndef _GLIBCXX_CXX_CONFIG_H
#define _GLIBCXX_CXX_CONFIG_H 1
// The major release number for the GCC release the C++ library belongs to.
#define _GLIBCXX_RELEASE 8
// The datestamp of the C++ library in compressed ISO date format.
#define __GLIBCXX__ 20210514
// Macros for various attributes.
// _GLIBCXX_PURE
// _GLIBCXX_CONST
// _GLIBCXX_NORETURN
// _GLIBCXX_NOTHROW
// _GLIBCXX_VISIBILITY
#ifndef _GLIBCXX_PURE
# define _GLIBCXX_PURE __attribute__ ((__pure__))
#endif
#ifndef _GLIBCXX_CONST
# define _GLIBCXX_CONST __attribute__ ((__const__))
#endif
#ifndef _GLIBCXX_NORETURN
# define _GLIBCXX_NORETURN __attribute__ ((__noreturn__))
#endif
// See below for C++
#ifndef _GLIBCXX_NOTHROW
# ifndef __cplusplus
# define _GLIBCXX_NOTHROW __attribute__((__nothrow__))
# endif
#endif
// Macros for visibility attributes.
// _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY
// _GLIBCXX_VISIBILITY
# define _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY 1
#if _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY
# define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ (#V)))
#else
// If this is not supplied by the OS-specific or CPU-specific
// headers included below, it will be defined to an empty default.
# define _GLIBCXX_VISIBILITY(V) _GLIBCXX_PSEUDO_VISIBILITY(V)
#endif
// Macros for deprecated attributes.
// _GLIBCXX_USE_DEPRECATED
// _GLIBCXX_DEPRECATED
// _GLIBCXX17_DEPRECATED
#ifndef _GLIBCXX_USE_DEPRECATED
# define _GLIBCXX_USE_DEPRECATED 1
#endif
#if defined(__DEPRECATED) && (__cplusplus >= 201103L)
# define _GLIBCXX_DEPRECATED __attribute__ ((__deprecated__))
#else
# define _GLIBCXX_DEPRECATED
#endif
#if defined(__DEPRECATED) && (__cplusplus >= 201703L)
# define _GLIBCXX17_DEPRECATED [[__deprecated__]]
#else
# define _GLIBCXX17_DEPRECATED
#endif
// Macros for ABI tag attributes.
#ifndef _GLIBCXX_ABI_TAG_CXX11
# define _GLIBCXX_ABI_TAG_CXX11 __attribute ((__abi_tag__ ("cxx11")))
#endif
// Macro to warn about unused results.
#if __cplusplus >= 201703L
# define _GLIBCXX_NODISCARD [[__nodiscard__]]
#else
# define _GLIBCXX_NODISCARD
#endif
#if __cplusplus
// Macro for constexpr, to support in mixed 03/0x mode.
#ifndef _GLIBCXX_CONSTEXPR
# if __cplusplus >= 201103L
# define _GLIBCXX_CONSTEXPR constexpr
# define _GLIBCXX_USE_CONSTEXPR constexpr
# else
# define _GLIBCXX_CONSTEXPR
# define _GLIBCXX_USE_CONSTEXPR const
# endif
#endif
#ifndef _GLIBCXX14_CONSTEXPR
# if __cplusplus >= 201402L
# define _GLIBCXX14_CONSTEXPR constexpr
# else
# define _GLIBCXX14_CONSTEXPR
# endif
#endif
#ifndef _GLIBCXX17_CONSTEXPR
# if __cplusplus > 201402L
# define _GLIBCXX17_CONSTEXPR constexpr
# else
# define _GLIBCXX17_CONSTEXPR
# endif
#endif
#ifndef _GLIBCXX17_INLINE
# if __cplusplus > 201402L
# define _GLIBCXX17_INLINE inline
# else
# define _GLIBCXX17_INLINE
# endif
#endif
// Macro for noexcept, to support in mixed 03/0x mode.
#ifndef _GLIBCXX_NOEXCEPT
# if __cplusplus >= 201103L
# define _GLIBCXX_NOEXCEPT noexcept
# define _GLIBCXX_NOEXCEPT_IF(_COND) noexcept(_COND)
# define _GLIBCXX_USE_NOEXCEPT noexcept
# define _GLIBCXX_THROW(_EXC)
# else
# define _GLIBCXX_NOEXCEPT
# define _GLIBCXX_NOEXCEPT_IF(_COND)
# define _GLIBCXX_USE_NOEXCEPT throw()
# define _GLIBCXX_THROW(_EXC) throw(_EXC)
# endif
#endif
#ifndef _GLIBCXX_NOTHROW
# define _GLIBCXX_NOTHROW _GLIBCXX_USE_NOEXCEPT
#endif
#ifndef _GLIBCXX_THROW_OR_ABORT
# if __cpp_exceptions
# define _GLIBCXX_THROW_OR_ABORT(_EXC) (throw (_EXC))
# else
# define _GLIBCXX_THROW_OR_ABORT(_EXC) (__builtin_abort())
# endif
#endif
#if __cpp_noexcept_function_type
#define _GLIBCXX_NOEXCEPT_PARM , bool _NE
#define _GLIBCXX_NOEXCEPT_QUAL noexcept (_NE)
#else
#define _GLIBCXX_NOEXCEPT_PARM
#define _GLIBCXX_NOEXCEPT_QUAL
#endif
// Macro for extern template, ie controlling template linkage via use
// of extern keyword on template declaration. As documented in the g++
// manual, it inhibits all implicit instantiations and is used
// throughout the library to avoid multiple weak definitions for
// required types that are already explicitly instantiated in the
// library binary. This substantially reduces the binary size of
// resulting executables.
// Special case: _GLIBCXX_EXTERN_TEMPLATE == -1 disallows extern
// templates only in basic_string, thus activating its debug-mode
// checks even at -O0.
# define _GLIBCXX_EXTERN_TEMPLATE 1
/*
Outline of libstdc++ namespaces.
namespace std
{
namespace __debug { }
namespace __parallel { }
namespace __profile { }
namespace __cxx1998 { }
namespace __detail {
namespace __variant { } // C++17
}
namespace rel_ops { }
namespace tr1
{
namespace placeholders { }
namespace regex_constants { }
namespace __detail { }
}
namespace tr2 { }
namespace decimal { }
namespace chrono { } // C++11
namespace placeholders { } // C++11
namespace regex_constants { } // C++11
namespace this_thread { } // C++11
inline namespace literals { // C++14
inline namespace chrono_literals { } // C++14
inline namespace complex_literals { } // C++14
inline namespace string_literals { } // C++14
inline namespace string_view_literals { } // C++17
}
}
namespace abi { }
namespace __gnu_cxx
{
namespace __detail { }
}
For full details see:
http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/namespaces.html
*/
namespace std
{
typedef __SIZE_TYPE__ size_t;
typedef __PTRDIFF_TYPE__ ptrdiff_t;
#if __cplusplus >= 201103L
typedef decltype(nullptr) nullptr_t;
#endif
}
# define _GLIBCXX_USE_DUAL_ABI 1
#if ! _GLIBCXX_USE_DUAL_ABI
// Ignore any pre-defined value of _GLIBCXX_USE_CXX11_ABI
# undef _GLIBCXX_USE_CXX11_ABI
#endif
#ifndef _GLIBCXX_USE_CXX11_ABI
# define _GLIBCXX_USE_CXX11_ABI 1
#endif
#if _GLIBCXX_USE_CXX11_ABI
namespace std
{
inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
}
namespace __gnu_cxx
{
inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
}
# define _GLIBCXX_NAMESPACE_CXX11 __cxx11::
# define _GLIBCXX_BEGIN_NAMESPACE_CXX11 namespace __cxx11 {
# define _GLIBCXX_END_NAMESPACE_CXX11 }
# define _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_ABI_TAG_CXX11
#else
# define _GLIBCXX_NAMESPACE_CXX11
# define _GLIBCXX_BEGIN_NAMESPACE_CXX11
# define _GLIBCXX_END_NAMESPACE_CXX11
# define _GLIBCXX_DEFAULT_ABI_TAG
#endif
// Defined if inline namespaces are used for versioning.
# define _GLIBCXX_INLINE_VERSION 0
// Inline namespace for symbol versioning.
#if _GLIBCXX_INLINE_VERSION
# define _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace __8 {
# define _GLIBCXX_END_NAMESPACE_VERSION }
namespace std
{
inline _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __cplusplus >= 201402L
inline namespace literals {
inline namespace chrono_literals { }
inline namespace complex_literals { }
inline namespace string_literals { }
#if __cplusplus > 201402L
inline namespace string_view_literals { }
#endif // C++17
}
#endif // C++14
_GLIBCXX_END_NAMESPACE_VERSION
}
namespace __gnu_cxx
{
inline _GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_END_NAMESPACE_VERSION
}
#else
# define _GLIBCXX_BEGIN_NAMESPACE_VERSION
# define _GLIBCXX_END_NAMESPACE_VERSION
#endif
// Inline namespaces for special modes: debug, parallel, profile.
#if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PARALLEL) \
|| defined(_GLIBCXX_PROFILE)
namespace std
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Non-inline namespace for components replaced by alternates in active mode.
namespace __cxx1998
{
# if _GLIBCXX_USE_CXX11_ABI
inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
# endif
}
_GLIBCXX_END_NAMESPACE_VERSION
// Inline namespace for debug mode.
# ifdef _GLIBCXX_DEBUG
inline namespace __debug { }
# endif
// Inline namespaces for parallel mode.
# ifdef _GLIBCXX_PARALLEL
inline namespace __parallel { }
# endif
// Inline namespaces for profile mode
# ifdef _GLIBCXX_PROFILE
inline namespace __profile { }
# endif
}
// Check for invalid usage and unsupported mixed-mode use.
# if defined(_GLIBCXX_DEBUG) && defined(_GLIBCXX_PARALLEL)
# error illegal use of multiple inlined namespaces
# endif
# if defined(_GLIBCXX_PROFILE) && defined(_GLIBCXX_DEBUG)
# error illegal use of multiple inlined namespaces
# endif
# if defined(_GLIBCXX_PROFILE) && defined(_GLIBCXX_PARALLEL)
# error illegal use of multiple inlined namespaces
# endif
// Check for invalid use due to lack for weak symbols.
# if __NO_INLINE__ && !__GXX_WEAK__
# warning currently using inlined namespace mode which may fail \
without inlining due to lack of weak symbols
# endif
#endif
// Macros for namespace scope. Either namespace std:: or the name
// of some nested namespace within it corresponding to the active mode.
// _GLIBCXX_STD_A
// _GLIBCXX_STD_C
//
// Macros for opening/closing conditional namespaces.
// _GLIBCXX_BEGIN_NAMESPACE_ALGO
// _GLIBCXX_END_NAMESPACE_ALGO
// _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// _GLIBCXX_END_NAMESPACE_CONTAINER
#if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PROFILE)
# define _GLIBCXX_STD_C __cxx1998
# define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER \
namespace _GLIBCXX_STD_C {
# define _GLIBCXX_END_NAMESPACE_CONTAINER }
#else
# define _GLIBCXX_STD_C std
# define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
# define _GLIBCXX_END_NAMESPACE_CONTAINER
#endif
#ifdef _GLIBCXX_PARALLEL
# define _GLIBCXX_STD_A __cxx1998
# define _GLIBCXX_BEGIN_NAMESPACE_ALGO \
namespace _GLIBCXX_STD_A {
# define _GLIBCXX_END_NAMESPACE_ALGO }
#else
# define _GLIBCXX_STD_A std
# define _GLIBCXX_BEGIN_NAMESPACE_ALGO
# define _GLIBCXX_END_NAMESPACE_ALGO
#endif
// GLIBCXX_ABI Deprecated
// Define if compatibility should be provided for -mlong-double-64.
#undef _GLIBCXX_LONG_DOUBLE_COMPAT
// Inline namespace for long double 128 mode.
#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
namespace std
{
inline namespace __gnu_cxx_ldbl128 { }
}
# define _GLIBCXX_NAMESPACE_LDBL __gnu_cxx_ldbl128::
# define _GLIBCXX_BEGIN_NAMESPACE_LDBL namespace __gnu_cxx_ldbl128 {
# define _GLIBCXX_END_NAMESPACE_LDBL }
#else
# define _GLIBCXX_NAMESPACE_LDBL
# define _GLIBCXX_BEGIN_NAMESPACE_LDBL
# define _GLIBCXX_END_NAMESPACE_LDBL
#endif
#if _GLIBCXX_USE_CXX11_ABI
# define _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_NAMESPACE_CXX11
# define _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_BEGIN_NAMESPACE_CXX11
# define _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_END_NAMESPACE_CXX11
#else
# define _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_NAMESPACE_LDBL
# define _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_BEGIN_NAMESPACE_LDBL
# define _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_END_NAMESPACE_LDBL
#endif
// Debug Mode implies checking assertions.
#if defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_ASSERTIONS)
# define _GLIBCXX_ASSERTIONS 1
#endif
// Disable std::string explicit instantiation declarations in order to assert.
#ifdef _GLIBCXX_ASSERTIONS
# undef _GLIBCXX_EXTERN_TEMPLATE
# define _GLIBCXX_EXTERN_TEMPLATE -1
#endif
// Assert.
#if defined(_GLIBCXX_ASSERTIONS) \
|| defined(_GLIBCXX_PARALLEL) || defined(_GLIBCXX_PARALLEL_ASSERTIONS)
namespace std
{
// Avoid the use of assert, because we're trying to keep the <cassert>
// include out of the mix.
inline void
__replacement_assert(const char* __file, int __line,
const char* __function, const char* __condition)
{
__builtin_printf("%s:%d: %s: Assertion '%s' failed.\n", __file, __line,
__function, __condition);
__builtin_abort();
}
}
#define __glibcxx_assert_impl(_Condition) \
do \
{ \
if (! (_Condition)) \
std::__replacement_assert(__FILE__, __LINE__, __PRETTY_FUNCTION__, \
#_Condition); \
} while (false)
#endif
#if defined(_GLIBCXX_ASSERTIONS)
# define __glibcxx_assert(_Condition) __glibcxx_assert_impl(_Condition)
#else
# define __glibcxx_assert(_Condition)
#endif
// Macros for race detectors.
// _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) and
// _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) should be used to explain
// atomic (lock-free) synchronization to race detectors:
// the race detector will infer a happens-before arc from the former to the
// latter when they share the same argument pointer.
//
// The most frequent use case for these macros (and the only case in the
// current implementation of the library) is atomic reference counting:
// void _M_remove_reference()
// {
// _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
// if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount, -1) <= 0)
// {
// _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
// _M_destroy(__a);
// }
// }
// The annotations in this example tell the race detector that all memory
// accesses occurred when the refcount was positive do not race with
// memory accesses which occurred after the refcount became zero.
#ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE
# define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A)
#endif
#ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER
# define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A)
#endif
// Macros for C linkage: define extern "C" linkage only when using C++.
# define _GLIBCXX_BEGIN_EXTERN_C extern "C" {
# define _GLIBCXX_END_EXTERN_C }
# define _GLIBCXX_USE_ALLOCATOR_NEW 1
#else // !__cplusplus
# define _GLIBCXX_BEGIN_EXTERN_C
# define _GLIBCXX_END_EXTERN_C
#endif
// First includes.
// Pick up any OS-specific definitions.
#include <bits/os_defines.h>
// Pick up any CPU-specific definitions.
#include <bits/cpu_defines.h>
// If platform uses neither visibility nor psuedo-visibility,
// specify empty default for namespace annotation macros.
#ifndef _GLIBCXX_PSEUDO_VISIBILITY
# define _GLIBCXX_PSEUDO_VISIBILITY(V)
#endif
// Certain function definitions that are meant to be overridable from
// user code are decorated with this macro. For some targets, this
// macro causes these definitions to be weak.
#ifndef _GLIBCXX_WEAK_DEFINITION
# define _GLIBCXX_WEAK_DEFINITION
#endif
// By default, we assume that __GXX_WEAK__ also means that there is support
// for declaring functions as weak while not defining such functions. This
// allows for referring to functions provided by other libraries (e.g.,
// libitm) without depending on them if the respective features are not used.
#ifndef _GLIBCXX_USE_WEAK_REF
# define _GLIBCXX_USE_WEAK_REF __GXX_WEAK__
#endif
// Conditionally enable annotations for the Transactional Memory TS on C++11.
// Most of the following conditions are due to limitations in the current
// implementation.
#if __cplusplus >= 201103L && _GLIBCXX_USE_CXX11_ABI \
&& _GLIBCXX_USE_DUAL_ABI && __cpp_transactional_memory >= 201505L \
&& !_GLIBCXX_FULLY_DYNAMIC_STRING && _GLIBCXX_USE_WEAK_REF \
&& _GLIBCXX_USE_ALLOCATOR_NEW
#define _GLIBCXX_TXN_SAFE transaction_safe
#define _GLIBCXX_TXN_SAFE_DYN transaction_safe_dynamic
#else
#define _GLIBCXX_TXN_SAFE
#define _GLIBCXX_TXN_SAFE_DYN
#endif
#if __cplusplus > 201402L
// In C++17 mathematical special functions are in namespace std.
# define _GLIBCXX_USE_STD_SPEC_FUNCS 1
#elif __cplusplus >= 201103L && __STDCPP_WANT_MATH_SPEC_FUNCS__ != 0
// For C++11 and C++14 they are in namespace std when requested.
# define _GLIBCXX_USE_STD_SPEC_FUNCS 1
#endif
// The remainder of the prewritten config is automatic; all the
// user hooks are listed above.
// Create a boolean flag to be used to determine if --fast-math is set.
#ifdef __FAST_MATH__
# define _GLIBCXX_FAST_MATH 1
#else
# define _GLIBCXX_FAST_MATH 0
#endif
// This marks string literals in header files to be extracted for eventual
// translation. It is primarily used for messages in thrown exceptions; see
// src/functexcept.cc. We use __N because the more traditional _N is used
// for something else under certain OSes (see BADNAMES).
#define __N(msgid) (msgid)
// For example, <windows.h> is known to #define min and max as macros...
#undef min
#undef max
// N.B. these _GLIBCXX_USE_C99_XXX macros are defined unconditionally
// so they should be tested with #if not with #ifdef.
#if __cplusplus >= 201103L
# ifndef _GLIBCXX_USE_C99_MATH
# define _GLIBCXX_USE_C99_MATH _GLIBCXX11_USE_C99_MATH
# endif
# ifndef _GLIBCXX_USE_C99_COMPLEX
# define _GLIBCXX_USE_C99_COMPLEX _GLIBCXX11_USE_C99_COMPLEX
# endif
# ifndef _GLIBCXX_USE_C99_STDIO
# define _GLIBCXX_USE_C99_STDIO _GLIBCXX11_USE_C99_STDIO
# endif
# ifndef _GLIBCXX_USE_C99_STDLIB
# define _GLIBCXX_USE_C99_STDLIB _GLIBCXX11_USE_C99_STDLIB
# endif
# ifndef _GLIBCXX_USE_C99_WCHAR
# define _GLIBCXX_USE_C99_WCHAR _GLIBCXX11_USE_C99_WCHAR
# endif
#else
# ifndef _GLIBCXX_USE_C99_MATH
# define _GLIBCXX_USE_C99_MATH _GLIBCXX98_USE_C99_MATH
# endif
# ifndef _GLIBCXX_USE_C99_COMPLEX
# define _GLIBCXX_USE_C99_COMPLEX _GLIBCXX98_USE_C99_COMPLEX
# endif
# ifndef _GLIBCXX_USE_C99_STDIO
# define _GLIBCXX_USE_C99_STDIO _GLIBCXX98_USE_C99_STDIO
# endif
# ifndef _GLIBCXX_USE_C99_STDLIB
# define _GLIBCXX_USE_C99_STDLIB _GLIBCXX98_USE_C99_STDLIB
# endif
# ifndef _GLIBCXX_USE_C99_WCHAR
# define _GLIBCXX_USE_C99_WCHAR _GLIBCXX98_USE_C99_WCHAR
# endif
#endif
/* Define if __float128 is supported on this host. */
#if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
#define _GLIBCXX_USE_FLOAT128 1
#endif
// End of prewritten config; the settings discovered at configure time follow.
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the `acosf' function. */
#define _GLIBCXX_HAVE_ACOSF 1
/* Define to 1 if you have the `acosl' function. */
#define _GLIBCXX_HAVE_ACOSL 1
/* Define to 1 if you have the `aligned_alloc' function. */
#define _GLIBCXX_HAVE_ALIGNED_ALLOC 1
/* Define to 1 if you have the `asinf' function. */
#define _GLIBCXX_HAVE_ASINF 1
/* Define to 1 if you have the `asinl' function. */
#define _GLIBCXX_HAVE_ASINL 1
/* Define to 1 if the target assembler supports .symver directive. */
#define _GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE 1
/* Define to 1 if you have the `atan2f' function. */
#define _GLIBCXX_HAVE_ATAN2F 1
/* Define to 1 if you have the `atan2l' function. */
#define _GLIBCXX_HAVE_ATAN2L 1
/* Define to 1 if you have the `atanf' function. */
#define _GLIBCXX_HAVE_ATANF 1
/* Define to 1 if you have the `atanl' function. */
#define _GLIBCXX_HAVE_ATANL 1
/* Define to 1 if you have the `at_quick_exit' function. */
#define _GLIBCXX_HAVE_AT_QUICK_EXIT 1
/* Define to 1 if the target assembler supports thread-local storage. */
/* #undef _GLIBCXX_HAVE_CC_TLS */
/* Define to 1 if you have the `ceilf' function. */
#define _GLIBCXX_HAVE_CEILF 1
/* Define to 1 if you have the `ceill' function. */
#define _GLIBCXX_HAVE_CEILL 1
/* Define to 1 if you have the <complex.h> header file. */
#define _GLIBCXX_HAVE_COMPLEX_H 1
/* Define to 1 if you have the `cosf' function. */
#define _GLIBCXX_HAVE_COSF 1
/* Define to 1 if you have the `coshf' function. */
#define _GLIBCXX_HAVE_COSHF 1
/* Define to 1 if you have the `coshl' function. */
#define _GLIBCXX_HAVE_COSHL 1
/* Define to 1 if you have the `cosl' function. */
#define _GLIBCXX_HAVE_COSL 1
/* Define to 1 if you have the <dirent.h> header file. */
#define _GLIBCXX_HAVE_DIRENT_H 1
/* Define to 1 if you have the <dlfcn.h> header file. */
#define _GLIBCXX_HAVE_DLFCN_H 1
/* Define if EBADMSG exists. */
#define _GLIBCXX_HAVE_EBADMSG 1
/* Define if ECANCELED exists. */
#define _GLIBCXX_HAVE_ECANCELED 1
/* Define if ECHILD exists. */
#define _GLIBCXX_HAVE_ECHILD 1
/* Define if EIDRM exists. */
#define _GLIBCXX_HAVE_EIDRM 1
/* Define to 1 if you have the <endian.h> header file. */
#define _GLIBCXX_HAVE_ENDIAN_H 1
/* Define if ENODATA exists. */
#define _GLIBCXX_HAVE_ENODATA 1
/* Define if ENOLINK exists. */
#define _GLIBCXX_HAVE_ENOLINK 1
/* Define if ENOSPC exists. */
#define _GLIBCXX_HAVE_ENOSPC 1
/* Define if ENOSR exists. */
#define _GLIBCXX_HAVE_ENOSR 1
/* Define if ENOSTR exists. */
#define _GLIBCXX_HAVE_ENOSTR 1
/* Define if ENOTRECOVERABLE exists. */
#define _GLIBCXX_HAVE_ENOTRECOVERABLE 1
/* Define if ENOTSUP exists. */
#define _GLIBCXX_HAVE_ENOTSUP 1
/* Define if EOVERFLOW exists. */
#define _GLIBCXX_HAVE_EOVERFLOW 1
/* Define if EOWNERDEAD exists. */
#define _GLIBCXX_HAVE_EOWNERDEAD 1
/* Define if EPERM exists. */
#define _GLIBCXX_HAVE_EPERM 1
/* Define if EPROTO exists. */
#define _GLIBCXX_HAVE_EPROTO 1
/* Define if ETIME exists. */
#define _GLIBCXX_HAVE_ETIME 1
/* Define if ETIMEDOUT exists. */
#define _GLIBCXX_HAVE_ETIMEDOUT 1
/* Define if ETXTBSY exists. */
#define _GLIBCXX_HAVE_ETXTBSY 1
/* Define if EWOULDBLOCK exists. */
#define _GLIBCXX_HAVE_EWOULDBLOCK 1
/* Define to 1 if GCC 4.6 supported std::exception_ptr for the target */
#define _GLIBCXX_HAVE_EXCEPTION_PTR_SINCE_GCC46 1
/* Define to 1 if you have the <execinfo.h> header file. */
#define _GLIBCXX_HAVE_EXECINFO_H 1
/* Define to 1 if you have the `expf' function. */
#define _GLIBCXX_HAVE_EXPF 1
/* Define to 1 if you have the `expl' function. */
#define _GLIBCXX_HAVE_EXPL 1
/* Define to 1 if you have the `fabsf' function. */
#define _GLIBCXX_HAVE_FABSF 1
/* Define to 1 if you have the `fabsl' function. */
#define _GLIBCXX_HAVE_FABSL 1
/* Define to 1 if you have the <fcntl.h> header file. */
#define _GLIBCXX_HAVE_FCNTL_H 1
/* Define to 1 if you have the <fenv.h> header file. */
#define _GLIBCXX_HAVE_FENV_H 1
/* Define to 1 if you have the `finite' function. */
#define _GLIBCXX_HAVE_FINITE 1
/* Define to 1 if you have the `finitef' function. */
#define _GLIBCXX_HAVE_FINITEF 1
/* Define to 1 if you have the `finitel' function. */
#define _GLIBCXX_HAVE_FINITEL 1
/* Define to 1 if you have the <float.h> header file. */
#define _GLIBCXX_HAVE_FLOAT_H 1
/* Define to 1 if you have the `floorf' function. */
#define _GLIBCXX_HAVE_FLOORF 1
/* Define to 1 if you have the `floorl' function. */
#define _GLIBCXX_HAVE_FLOORL 1
/* Define to 1 if you have the `fmodf' function. */
#define _GLIBCXX_HAVE_FMODF 1
/* Define to 1 if you have the `fmodl' function. */
#define _GLIBCXX_HAVE_FMODL 1
/* Define to 1 if you have the `fpclass' function. */
/* #undef _GLIBCXX_HAVE_FPCLASS */
/* Define to 1 if you have the <fp.h> header file. */
/* #undef _GLIBCXX_HAVE_FP_H */
/* Define to 1 if you have the `frexpf' function. */
#define _GLIBCXX_HAVE_FREXPF 1
/* Define to 1 if you have the `frexpl' function. */
#define _GLIBCXX_HAVE_FREXPL 1
/* Define if _Unwind_GetIPInfo is available. */
#define _GLIBCXX_HAVE_GETIPINFO 1
/* Define if gets is available in <stdio.h> before C++14. */
#define _GLIBCXX_HAVE_GETS 1
/* Define to 1 if you have the `hypot' function. */
#define _GLIBCXX_HAVE_HYPOT 1
/* Define to 1 if you have the `hypotf' function. */
#define _GLIBCXX_HAVE_HYPOTF 1
/* Define to 1 if you have the `hypotl' function. */
#define _GLIBCXX_HAVE_HYPOTL 1
/* Define if you have the iconv() function. */
#define _GLIBCXX_HAVE_ICONV 1
/* Define to 1 if you have the <ieeefp.h> header file. */
/* #undef _GLIBCXX_HAVE_IEEEFP_H */
/* Define if int64_t is available in <stdint.h>. */
#define _GLIBCXX_HAVE_INT64_T 1
/* Define if int64_t is a long. */
/* #undef _GLIBCXX_HAVE_INT64_T_LONG */
/* Define if int64_t is a long long. */
#define _GLIBCXX_HAVE_INT64_T_LONG_LONG 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define _GLIBCXX_HAVE_INTTYPES_H 1
/* Define to 1 if you have the `isinf' function. */
/* #undef _GLIBCXX_HAVE_ISINF */
/* Define to 1 if you have the `isinff' function. */
#define _GLIBCXX_HAVE_ISINFF 1
/* Define to 1 if you have the `isinfl' function. */
#define _GLIBCXX_HAVE_ISINFL 1
/* Define to 1 if you have the `isnan' function. */
/* #undef _GLIBCXX_HAVE_ISNAN */
/* Define to 1 if you have the `isnanf' function. */
#define _GLIBCXX_HAVE_ISNANF 1
/* Define to 1 if you have the `isnanl' function. */
#define _GLIBCXX_HAVE_ISNANL 1
/* Defined if iswblank exists. */
#define _GLIBCXX_HAVE_ISWBLANK 1
/* Define if LC_MESSAGES is available in <locale.h>. */
#define _GLIBCXX_HAVE_LC_MESSAGES 1
/* Define to 1 if you have the `ldexpf' function. */
#define _GLIBCXX_HAVE_LDEXPF 1
/* Define to 1 if you have the `ldexpl' function. */
#define _GLIBCXX_HAVE_LDEXPL 1
/* Define to 1 if you have the <libintl.h> header file. */
#define _GLIBCXX_HAVE_LIBINTL_H 1
/* Only used in build directory testsuite_hooks.h. */
#define _GLIBCXX_HAVE_LIMIT_AS 1
/* Only used in build directory testsuite_hooks.h. */
#define _GLIBCXX_HAVE_LIMIT_DATA 1
/* Only used in build directory testsuite_hooks.h. */
#define _GLIBCXX_HAVE_LIMIT_FSIZE 1
/* Only used in build directory testsuite_hooks.h. */
#define _GLIBCXX_HAVE_LIMIT_RSS 1
/* Only used in build directory testsuite_hooks.h. */
#define _GLIBCXX_HAVE_LIMIT_VMEM 0
/* Define if futex syscall is available. */
#define _GLIBCXX_HAVE_LINUX_FUTEX 1
/* Define to 1 if you have the <linux/random.h> header file. */
#define _GLIBCXX_HAVE_LINUX_RANDOM_H 1
/* Define to 1 if you have the <linux/types.h> header file. */
#define _GLIBCXX_HAVE_LINUX_TYPES_H 1
/* Define to 1 if you have the <locale.h> header file. */
#define _GLIBCXX_HAVE_LOCALE_H 1
/* Define to 1 if you have the `log10f' function. */
#define _GLIBCXX_HAVE_LOG10F 1
/* Define to 1 if you have the `log10l' function. */
#define _GLIBCXX_HAVE_LOG10L 1
/* Define to 1 if you have the `logf' function. */
#define _GLIBCXX_HAVE_LOGF 1
/* Define to 1 if you have the `logl' function. */
#define _GLIBCXX_HAVE_LOGL 1
/* Define to 1 if you have the <machine/endian.h> header file. */
/* #undef _GLIBCXX_HAVE_MACHINE_ENDIAN_H */
/* Define to 1 if you have the <machine/param.h> header file. */
/* #undef _GLIBCXX_HAVE_MACHINE_PARAM_H */
/* Define if mbstate_t exists in wchar.h. */
#define _GLIBCXX_HAVE_MBSTATE_T 1
/* Define to 1 if you have the `memalign' function. */
#define _GLIBCXX_HAVE_MEMALIGN 1
/* Define to 1 if you have the <memory.h> header file. */
#define _GLIBCXX_HAVE_MEMORY_H 1
/* Define to 1 if you have the `modf' function. */
#define _GLIBCXX_HAVE_MODF 1
/* Define to 1 if you have the `modff' function. */
#define _GLIBCXX_HAVE_MODFF 1
/* Define to 1 if you have the `modfl' function. */
#define _GLIBCXX_HAVE_MODFL 1
/* Define to 1 if you have the <nan.h> header file. */
/* #undef _GLIBCXX_HAVE_NAN_H */
/* Define if <math.h> defines obsolete isinf function. */
/* #undef _GLIBCXX_HAVE_OBSOLETE_ISINF */
/* Define if <math.h> defines obsolete isnan function. */
/* #undef _GLIBCXX_HAVE_OBSOLETE_ISNAN */
/* Define if poll is available in <poll.h>. */
#define _GLIBCXX_HAVE_POLL 1
/* Define to 1 if you have the `posix_memalign' function. */
#define _GLIBCXX_HAVE_POSIX_MEMALIGN 1
/* Define to 1 if you have the `powf' function. */
#define _GLIBCXX_HAVE_POWF 1
/* Define to 1 if you have the `powl' function. */
#define _GLIBCXX_HAVE_POWL 1
/* Define to 1 if you have the `qfpclass' function. */
/* #undef _GLIBCXX_HAVE_QFPCLASS */
/* Define to 1 if you have the `quick_exit' function. */
#define _GLIBCXX_HAVE_QUICK_EXIT 1
/* Define to 1 if you have the `setenv' function. */
#define _GLIBCXX_HAVE_SETENV 1
/* Define to 1 if you have the `sincos' function. */
#define _GLIBCXX_HAVE_SINCOS 1
/* Define to 1 if you have the `sincosf' function. */
#define _GLIBCXX_HAVE_SINCOSF 1
/* Define to 1 if you have the `sincosl' function. */
#define _GLIBCXX_HAVE_SINCOSL 1
/* Define to 1 if you have the `sinf' function. */
#define _GLIBCXX_HAVE_SINF 1
/* Define to 1 if you have the `sinhf' function. */
#define _GLIBCXX_HAVE_SINHF 1
/* Define to 1 if you have the `sinhl' function. */
#define _GLIBCXX_HAVE_SINHL 1
/* Define to 1 if you have the `sinl' function. */
#define _GLIBCXX_HAVE_SINL 1
/* Defined if sleep exists. */
/* #undef _GLIBCXX_HAVE_SLEEP */
/* Define to 1 if you have the `sqrtf' function. */
#define _GLIBCXX_HAVE_SQRTF 1
/* Define to 1 if you have the `sqrtl' function. */
#define _GLIBCXX_HAVE_SQRTL 1
/* Define to 1 if you have the <stdalign.h> header file. */
#define _GLIBCXX_HAVE_STDALIGN_H 1
/* Define to 1 if you have the <stdbool.h> header file. */
#define _GLIBCXX_HAVE_STDBOOL_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#define _GLIBCXX_HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define _GLIBCXX_HAVE_STDLIB_H 1
/* Define if strerror_l is available in <string.h>. */
#define _GLIBCXX_HAVE_STRERROR_L 1
/* Define if strerror_r is available in <string.h>. */
#define _GLIBCXX_HAVE_STRERROR_R 1
/* Define to 1 if you have the <strings.h> header file. */
#define _GLIBCXX_HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define _GLIBCXX_HAVE_STRING_H 1
/* Define to 1 if you have the `strtof' function. */
#define _GLIBCXX_HAVE_STRTOF 1
/* Define to 1 if you have the `strtold' function. */
#define _GLIBCXX_HAVE_STRTOLD 1
/* Define to 1 if `d_type' is a member of `struct dirent'. */
#define _GLIBCXX_HAVE_STRUCT_DIRENT_D_TYPE 1
/* Define if strxfrm_l is available in <string.h>. */
#define _GLIBCXX_HAVE_STRXFRM_L 1
/* Define to 1 if the target runtime linker supports binding the same symbol
to different versions. */
#define _GLIBCXX_HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT 1
/* Define to 1 if you have the <sys/filio.h> header file. */
/* #undef _GLIBCXX_HAVE_SYS_FILIO_H */
/* Define to 1 if you have the <sys/ioctl.h> header file. */
#define _GLIBCXX_HAVE_SYS_IOCTL_H 1
/* Define to 1 if you have the <sys/ipc.h> header file. */
#define _GLIBCXX_HAVE_SYS_IPC_H 1
/* Define to 1 if you have the <sys/isa_defs.h> header file. */
/* #undef _GLIBCXX_HAVE_SYS_ISA_DEFS_H */
/* Define to 1 if you have the <sys/machine.h> header file. */
/* #undef _GLIBCXX_HAVE_SYS_MACHINE_H */
/* Define to 1 if you have the <sys/param.h> header file. */
#define _GLIBCXX_HAVE_SYS_PARAM_H 1
/* Define to 1 if you have the <sys/resource.h> header file. */
#define _GLIBCXX_HAVE_SYS_RESOURCE_H 1
/* Define to 1 if you have a suitable <sys/sdt.h> header file */
#define _GLIBCXX_HAVE_SYS_SDT_H 1
/* Define to 1 if you have the <sys/sem.h> header file. */
#define _GLIBCXX_HAVE_SYS_SEM_H 1
/* Define to 1 if you have the <sys/statvfs.h> header file. */
#define _GLIBCXX_HAVE_SYS_STATVFS_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define _GLIBCXX_HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/sysinfo.h> header file. */
#define _GLIBCXX_HAVE_SYS_SYSINFO_H 1
/* Define to 1 if you have the <sys/time.h> header file. */
#define _GLIBCXX_HAVE_SYS_TIME_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define _GLIBCXX_HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <sys/uio.h> header file. */
#define _GLIBCXX_HAVE_SYS_UIO_H 1
/* Define if S_IFREG is available in <sys/stat.h>. */
/* #undef _GLIBCXX_HAVE_S_IFREG */
/* Define if S_ISREG is available in <sys/stat.h>. */
#define _GLIBCXX_HAVE_S_ISREG 1
/* Define to 1 if you have the `tanf' function. */
#define _GLIBCXX_HAVE_TANF 1
/* Define to 1 if you have the `tanhf' function. */
#define _GLIBCXX_HAVE_TANHF 1
/* Define to 1 if you have the `tanhl' function. */
#define _GLIBCXX_HAVE_TANHL 1
/* Define to 1 if you have the `tanl' function. */
#define _GLIBCXX_HAVE_TANL 1
/* Define to 1 if you have the <tgmath.h> header file. */
#define _GLIBCXX_HAVE_TGMATH_H 1
/* Define to 1 if the target supports thread-local storage. */
#define _GLIBCXX_HAVE_TLS 1
/* Define to 1 if you have the <uchar.h> header file. */
#define _GLIBCXX_HAVE_UCHAR_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define _GLIBCXX_HAVE_UNISTD_H 1
/* Defined if usleep exists. */
/* #undef _GLIBCXX_HAVE_USLEEP */
/* Define to 1 if you have the <utime.h> header file. */
#define _GLIBCXX_HAVE_UTIME_H 1
/* Defined if vfwscanf exists. */
#define _GLIBCXX_HAVE_VFWSCANF 1
/* Defined if vswscanf exists. */
#define _GLIBCXX_HAVE_VSWSCANF 1
/* Defined if vwscanf exists. */
#define _GLIBCXX_HAVE_VWSCANF 1
/* Define to 1 if you have the <wchar.h> header file. */
#define _GLIBCXX_HAVE_WCHAR_H 1
/* Defined if wcstof exists. */
#define _GLIBCXX_HAVE_WCSTOF 1
/* Define to 1 if you have the <wctype.h> header file. */
#define _GLIBCXX_HAVE_WCTYPE_H 1
/* Defined if Sleep exists. */
/* #undef _GLIBCXX_HAVE_WIN32_SLEEP */
/* Define if writev is available in <sys/uio.h>. */
#define _GLIBCXX_HAVE_WRITEV 1
/* Define to 1 if you have the `_acosf' function. */
/* #undef _GLIBCXX_HAVE__ACOSF */
/* Define to 1 if you have the `_acosl' function. */
/* #undef _GLIBCXX_HAVE__ACOSL */
/* Define to 1 if you have the `_aligned_malloc' function. */
/* #undef _GLIBCXX_HAVE__ALIGNED_MALLOC */
/* Define to 1 if you have the `_asinf' function. */
/* #undef _GLIBCXX_HAVE__ASINF */
/* Define to 1 if you have the `_asinl' function. */
/* #undef _GLIBCXX_HAVE__ASINL */
/* Define to 1 if you have the `_atan2f' function. */
/* #undef _GLIBCXX_HAVE__ATAN2F */
/* Define to 1 if you have the `_atan2l' function. */
/* #undef _GLIBCXX_HAVE__ATAN2L */
/* Define to 1 if you have the `_atanf' function. */
/* #undef _GLIBCXX_HAVE__ATANF */
/* Define to 1 if you have the `_atanl' function. */
/* #undef _GLIBCXX_HAVE__ATANL */
/* Define to 1 if you have the `_ceilf' function. */
/* #undef _GLIBCXX_HAVE__CEILF */
/* Define to 1 if you have the `_ceill' function. */
/* #undef _GLIBCXX_HAVE__CEILL */
/* Define to 1 if you have the `_cosf' function. */
/* #undef _GLIBCXX_HAVE__COSF */
/* Define to 1 if you have the `_coshf' function. */
/* #undef _GLIBCXX_HAVE__COSHF */
/* Define to 1 if you have the `_coshl' function. */
/* #undef _GLIBCXX_HAVE__COSHL */
/* Define to 1 if you have the `_cosl' function. */
/* #undef _GLIBCXX_HAVE__COSL */
/* Define to 1 if you have the `_expf' function. */
/* #undef _GLIBCXX_HAVE__EXPF */
/* Define to 1 if you have the `_expl' function. */
/* #undef _GLIBCXX_HAVE__EXPL */
/* Define to 1 if you have the `_fabsf' function. */
/* #undef _GLIBCXX_HAVE__FABSF */
/* Define to 1 if you have the `_fabsl' function. */
/* #undef _GLIBCXX_HAVE__FABSL */
/* Define to 1 if you have the `_finite' function. */
/* #undef _GLIBCXX_HAVE__FINITE */
/* Define to 1 if you have the `_finitef' function. */
/* #undef _GLIBCXX_HAVE__FINITEF */
/* Define to 1 if you have the `_finitel' function. */
/* #undef _GLIBCXX_HAVE__FINITEL */
/* Define to 1 if you have the `_floorf' function. */
/* #undef _GLIBCXX_HAVE__FLOORF */
/* Define to 1 if you have the `_floorl' function. */
/* #undef _GLIBCXX_HAVE__FLOORL */
/* Define to 1 if you have the `_fmodf' function. */
/* #undef _GLIBCXX_HAVE__FMODF */
/* Define to 1 if you have the `_fmodl' function. */
/* #undef _GLIBCXX_HAVE__FMODL */
/* Define to 1 if you have the `_fpclass' function. */
/* #undef _GLIBCXX_HAVE__FPCLASS */
/* Define to 1 if you have the `_frexpf' function. */
/* #undef _GLIBCXX_HAVE__FREXPF */
/* Define to 1 if you have the `_frexpl' function. */
/* #undef _GLIBCXX_HAVE__FREXPL */
/* Define to 1 if you have the `_hypot' function. */
/* #undef _GLIBCXX_HAVE__HYPOT */
/* Define to 1 if you have the `_hypotf' function. */
/* #undef _GLIBCXX_HAVE__HYPOTF */
/* Define to 1 if you have the `_hypotl' function. */
/* #undef _GLIBCXX_HAVE__HYPOTL */
/* Define to 1 if you have the `_isinf' function. */
/* #undef _GLIBCXX_HAVE__ISINF */
/* Define to 1 if you have the `_isinff' function. */
/* #undef _GLIBCXX_HAVE__ISINFF */
/* Define to 1 if you have the `_isinfl' function. */
/* #undef _GLIBCXX_HAVE__ISINFL */
/* Define to 1 if you have the `_isnan' function. */
/* #undef _GLIBCXX_HAVE__ISNAN */
/* Define to 1 if you have the `_isnanf' function. */
/* #undef _GLIBCXX_HAVE__ISNANF */
/* Define to 1 if you have the `_isnanl' function. */
/* #undef _GLIBCXX_HAVE__ISNANL */
/* Define to 1 if you have the `_ldexpf' function. */
/* #undef _GLIBCXX_HAVE__LDEXPF */
/* Define to 1 if you have the `_ldexpl' function. */
/* #undef _GLIBCXX_HAVE__LDEXPL */
/* Define to 1 if you have the `_log10f' function. */
/* #undef _GLIBCXX_HAVE__LOG10F */
/* Define to 1 if you have the `_log10l' function. */
/* #undef _GLIBCXX_HAVE__LOG10L */
/* Define to 1 if you have the `_logf' function. */
/* #undef _GLIBCXX_HAVE__LOGF */
/* Define to 1 if you have the `_logl' function. */
/* #undef _GLIBCXX_HAVE__LOGL */
/* Define to 1 if you have the `_modf' function. */
/* #undef _GLIBCXX_HAVE__MODF */
/* Define to 1 if you have the `_modff' function. */
/* #undef _GLIBCXX_HAVE__MODFF */
/* Define to 1 if you have the `_modfl' function. */
/* #undef _GLIBCXX_HAVE__MODFL */
/* Define to 1 if you have the `_powf' function. */
/* #undef _GLIBCXX_HAVE__POWF */
/* Define to 1 if you have the `_powl' function. */
/* #undef _GLIBCXX_HAVE__POWL */
/* Define to 1 if you have the `_qfpclass' function. */
/* #undef _GLIBCXX_HAVE__QFPCLASS */
/* Define to 1 if you have the `_sincos' function. */
/* #undef _GLIBCXX_HAVE__SINCOS */
/* Define to 1 if you have the `_sincosf' function. */
/* #undef _GLIBCXX_HAVE__SINCOSF */
/* Define to 1 if you have the `_sincosl' function. */
/* #undef _GLIBCXX_HAVE__SINCOSL */
/* Define to 1 if you have the `_sinf' function. */
/* #undef _GLIBCXX_HAVE__SINF */
/* Define to 1 if you have the `_sinhf' function. */
/* #undef _GLIBCXX_HAVE__SINHF */
/* Define to 1 if you have the `_sinhl' function. */
/* #undef _GLIBCXX_HAVE__SINHL */
/* Define to 1 if you have the `_sinl' function. */
/* #undef _GLIBCXX_HAVE__SINL */
/* Define to 1 if you have the `_sqrtf' function. */
/* #undef _GLIBCXX_HAVE__SQRTF */
/* Define to 1 if you have the `_sqrtl' function. */
/* #undef _GLIBCXX_HAVE__SQRTL */
/* Define to 1 if you have the `_tanf' function. */
/* #undef _GLIBCXX_HAVE__TANF */
/* Define to 1 if you have the `_tanhf' function. */
/* #undef _GLIBCXX_HAVE__TANHF */
/* Define to 1 if you have the `_tanhl' function. */
/* #undef _GLIBCXX_HAVE__TANHL */
/* Define to 1 if you have the `_tanl' function. */
/* #undef _GLIBCXX_HAVE__TANL */
/* Define to 1 if you have the `__cxa_thread_atexit' function. */
/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT */
/* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
/* Define as const if the declaration of iconv() needs const. */
#define _GLIBCXX_ICONV_CONST
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#define LT_OBJDIR ".libs/"
/* Name of package */
/* #undef _GLIBCXX_PACKAGE */
/* Define to the address where bug reports for this package should be sent. */
#define _GLIBCXX_PACKAGE_BUGREPORT ""
/* Define to the full name of this package. */
#define _GLIBCXX_PACKAGE_NAME "package-unused"
/* Define to the full name and version of this package. */
#define _GLIBCXX_PACKAGE_STRING "package-unused version-unused"
/* Define to the one symbol short name of this package. */
#define _GLIBCXX_PACKAGE_TARNAME "libstdc++"
/* Define to the home page for this package. */
#define _GLIBCXX_PACKAGE_URL ""
/* Define to the version of this package. */
#define _GLIBCXX_PACKAGE__GLIBCXX_VERSION "version-unused"
/* The size of `char', as computed by sizeof. */
/* #undef SIZEOF_CHAR */
/* The size of `int', as computed by sizeof. */
/* #undef SIZEOF_INT */
/* The size of `long', as computed by sizeof. */
/* #undef SIZEOF_LONG */
/* The size of `short', as computed by sizeof. */
/* #undef SIZEOF_SHORT */
/* The size of `void *', as computed by sizeof. */
/* #undef SIZEOF_VOID_P */
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Version number of package */
/* #undef _GLIBCXX_VERSION */
/* Number of bits in a file offset, on hosts where this is settable. */
#define _GLIBCXX_FILE_OFFSET_BITS 64
/* Define if C99 functions in <complex.h> should be used in <complex> for
C++11. Using compiler builtins for these functions requires corresponding
C99 library functions to be present. */
#define _GLIBCXX11_USE_C99_COMPLEX 1
/* Define if C99 functions or macros in <math.h> should be imported in <cmath>
in namespace std for C++11. */
#define _GLIBCXX11_USE_C99_MATH 1
/* Define if C99 functions or macros in <stdio.h> should be imported in
<cstdio> in namespace std for C++11. */
#define _GLIBCXX11_USE_C99_STDIO 1
/* Define if C99 functions or macros in <stdlib.h> should be imported in
<cstdlib> in namespace std for C++11. */
#define _GLIBCXX11_USE_C99_STDLIB 1
/* Define if C99 functions or macros in <wchar.h> should be imported in
<cwchar> in namespace std for C++11. */
#define _GLIBCXX11_USE_C99_WCHAR 1
/* Define if C99 functions in <complex.h> should be used in <complex> for
C++98. Using compiler builtins for these functions requires corresponding
C99 library functions to be present. */
#define _GLIBCXX98_USE_C99_COMPLEX 1
/* Define if C99 functions or macros in <math.h> should be imported in <cmath>
in namespace std for C++98. */
#define _GLIBCXX98_USE_C99_MATH 1
/* Define if C99 functions or macros in <stdio.h> should be imported in
<cstdio> in namespace std for C++98. */
#define _GLIBCXX98_USE_C99_STDIO 1
/* Define if C99 functions or macros in <stdlib.h> should be imported in
<cstdlib> in namespace std for C++98. */
#define _GLIBCXX98_USE_C99_STDLIB 1
/* Define if C99 functions or macros in <wchar.h> should be imported in
<cwchar> in namespace std for C++98. */
#define _GLIBCXX98_USE_C99_WCHAR 1
/* Define if the compiler supports C++11 atomics. */
#define _GLIBCXX_ATOMIC_BUILTINS 1
/* Define to use concept checking code from the boost libraries. */
/* #undef _GLIBCXX_CONCEPT_CHECKS */
/* Define to 1 if a fully dynamic basic_string is wanted, 0 to disable,
undefined for platform defaults */
#define _GLIBCXX_FULLY_DYNAMIC_STRING 0
/* Define if gthreads library is available. */
#define _GLIBCXX_HAS_GTHREADS 1
/* Define to 1 if a full hosted library is built, or 0 if freestanding. */
#define _GLIBCXX_HOSTED 1
/* Define if compatibility should be provided for -mlong-double-64. */
/* Define to the letter to which size_t is mangled. */
#define _GLIBCXX_MANGLE_SIZE_T j
/* Define if C99 llrint and llround functions are missing from <math.h>. */
/* #undef _GLIBCXX_NO_C99_ROUNDING_FUNCS */
/* Define if ptrdiff_t is int. */
#define _GLIBCXX_PTRDIFF_T_IS_INT 1
/* Define if using setrlimit to set resource limits during "make check" */
#define _GLIBCXX_RES_LIMITS 1
/* Define if size_t is unsigned int. */
#define _GLIBCXX_SIZE_T_IS_UINT 1
/* Define to the value of the EOF integer constant. */
#define _GLIBCXX_STDIO_EOF -1
/* Define to the value of the SEEK_CUR integer constant. */
#define _GLIBCXX_STDIO_SEEK_CUR 1
/* Define to the value of the SEEK_END integer constant. */
#define _GLIBCXX_STDIO_SEEK_END 2
/* Define to use symbol versioning in the shared library. */
#define _GLIBCXX_SYMVER 1
/* Define to use darwin versioning in the shared library. */
/* #undef _GLIBCXX_SYMVER_DARWIN */
/* Define to use GNU versioning in the shared library. */
#define _GLIBCXX_SYMVER_GNU 1
/* Define to use GNU namespace versioning in the shared library. */
/* #undef _GLIBCXX_SYMVER_GNU_NAMESPACE */
/* Define to use Sun versioning in the shared library. */
/* #undef _GLIBCXX_SYMVER_SUN */
/* Define if C11 functions in <uchar.h> should be imported into namespace std
in <cuchar>. */
#define _GLIBCXX_USE_C11_UCHAR_CXX11 1
/* Define if C99 functions or macros from <wchar.h>, <math.h>, <complex.h>,
<stdio.h>, and <stdlib.h> can be used or exposed. */
#define _GLIBCXX_USE_C99 1
/* Define if C99 functions in <complex.h> should be used in <tr1/complex>.
Using compiler builtins for these functions requires corresponding C99
library functions to be present. */
#define _GLIBCXX_USE_C99_COMPLEX_TR1 1
/* Define if C99 functions in <ctype.h> should be imported in <tr1/cctype> in
namespace std::tr1. */
#define _GLIBCXX_USE_C99_CTYPE_TR1 1
/* Define if C99 functions in <fenv.h> should be imported in <tr1/cfenv> in
namespace std::tr1. */
#define _GLIBCXX_USE_C99_FENV_TR1 1
/* Define if C99 functions in <inttypes.h> should be imported in
<tr1/cinttypes> in namespace std::tr1. */
#define _GLIBCXX_USE_C99_INTTYPES_TR1 1
/* Define if wchar_t C99 functions in <inttypes.h> should be imported in
<tr1/cinttypes> in namespace std::tr1. */
#define _GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1 1
/* Define if C99 functions or macros in <math.h> should be imported in
<tr1/cmath> in namespace std::tr1. */
#define _GLIBCXX_USE_C99_MATH_TR1 1
/* Define if C99 types in <stdint.h> should be imported in <tr1/cstdint> in
namespace std::tr1. */
#define _GLIBCXX_USE_C99_STDINT_TR1 1
/* Defined if clock_gettime syscall has monotonic and realtime clock support.
*/
/* #undef _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL */
/* Defined if clock_gettime has monotonic clock support. */
#define _GLIBCXX_USE_CLOCK_MONOTONIC 1
/* Defined if clock_gettime has realtime clock support. */
#define _GLIBCXX_USE_CLOCK_REALTIME 1
/* Define if ISO/IEC TR 24733 decimal floating point types are supported on
this host. */
#define _GLIBCXX_USE_DECIMAL_FLOAT 1
/* Define if fchmod is available in <sys/stat.h>. */
#define _GLIBCXX_USE_FCHMOD 1
/* Define if fchmodat is available in <sys/stat.h>. */
#define _GLIBCXX_USE_FCHMODAT 1
/* Defined if gettimeofday is available. */
#define _GLIBCXX_USE_GETTIMEOFDAY 1
/* Define if get_nprocs is available in <sys/sysinfo.h>. */
#define _GLIBCXX_USE_GET_NPROCS 1
/* Define if __int128 is supported on this host. */
/* #undef _GLIBCXX_USE_INT128 */
/* Define if LFS support is available. */
#define _GLIBCXX_USE_LFS 1
/* Define if code specialized for long long should be used. */
#define _GLIBCXX_USE_LONG_LONG 1
/* Defined if nanosleep is available. */
#define _GLIBCXX_USE_NANOSLEEP 1
/* Define if NLS translations are to be used. */
#define _GLIBCXX_USE_NLS 1
/* Define if pthreads_num_processors_np is available in <pthread.h>. */
/* #undef _GLIBCXX_USE_PTHREADS_NUM_PROCESSORS_NP */
/* Define if POSIX read/write locks are available in <gthr.h>. */
#define _GLIBCXX_USE_PTHREAD_RWLOCK_T 1
/* Define if /dev/random and /dev/urandom are available for the random_device
of TR1 (Chapter 5.1). */
#define _GLIBCXX_USE_RANDOM_TR1 1
/* Define if usable realpath is available in <stdlib.h>. */
#define _GLIBCXX_USE_REALPATH 1
/* Defined if sched_yield is available. */
#define _GLIBCXX_USE_SCHED_YIELD 1
/* Define if _SC_NPROCESSORS_ONLN is available in <unistd.h>. */
#define _GLIBCXX_USE_SC_NPROCESSORS_ONLN 1
/* Define if _SC_NPROC_ONLN is available in <unistd.h>. */
/* #undef _GLIBCXX_USE_SC_NPROC_ONLN */
/* Define if sendfile is available in <sys/sendfile.h>. */
#define _GLIBCXX_USE_SENDFILE 1
/* Define if struct stat has timespec members. */
#define _GLIBCXX_USE_ST_MTIM 1
/* Define if sysctl(), CTL_HW and HW_NCPU are available in <sys/sysctl.h>. */
/* #undef _GLIBCXX_USE_SYSCTL_HW_NCPU */
/* Define if obsolescent tmpnam is available in <stdio.h>. */
#define _GLIBCXX_USE_TMPNAM 1
/* Define if utimensat and UTIME_OMIT are available in <sys/stat.h> and
AT_FDCWD in <fcntl.h>. */
#define _GLIBCXX_USE_UTIMENSAT 1
/* Define if code specialized for wchar_t should be used. */
#define _GLIBCXX_USE_WCHAR_T 1
/* Define to 1 if a verbose library is built, or 0 otherwise. */
#define _GLIBCXX_VERBOSE 1
/* Defined if as can handle rdrand. */
#define _GLIBCXX_X86_RDRAND 1
/* Define to 1 if mutex_timedlock is available. */
#define _GTHREAD_USE_MUTEX_TIMEDLOCK 1
/* Define for large files, on AIX-style hosts. */
/* #undef _GLIBCXX_LARGE_FILES */
/* Define if all C++11 floating point overloads are available in <math.h>. */
#if __cplusplus >= 201103L
/* #undef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP */
#endif
/* Define if all C++11 integral type overloads are available in <math.h>. */
#if __cplusplus >= 201103L
/* #undef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT */
#endif
#if defined (_GLIBCXX_HAVE__ACOSF) && ! defined (_GLIBCXX_HAVE_ACOSF)
# define _GLIBCXX_HAVE_ACOSF 1
# define acosf _acosf
#endif
#if defined (_GLIBCXX_HAVE__ACOSL) && ! defined (_GLIBCXX_HAVE_ACOSL)
# define _GLIBCXX_HAVE_ACOSL 1
# define acosl _acosl
#endif
#if defined (_GLIBCXX_HAVE__ASINF) && ! defined (_GLIBCXX_HAVE_ASINF)
# define _GLIBCXX_HAVE_ASINF 1
# define asinf _asinf
#endif
#if defined (_GLIBCXX_HAVE__ASINL) && ! defined (_GLIBCXX_HAVE_ASINL)
# define _GLIBCXX_HAVE_ASINL 1
# define asinl _asinl
#endif
#if defined (_GLIBCXX_HAVE__ATAN2F) && ! defined (_GLIBCXX_HAVE_ATAN2F)
# define _GLIBCXX_HAVE_ATAN2F 1
# define atan2f _atan2f
#endif
#if defined (_GLIBCXX_HAVE__ATAN2L) && ! defined (_GLIBCXX_HAVE_ATAN2L)
# define _GLIBCXX_HAVE_ATAN2L 1
# define atan2l _atan2l
#endif
#if defined (_GLIBCXX_HAVE__ATANF) && ! defined (_GLIBCXX_HAVE_ATANF)
# define _GLIBCXX_HAVE_ATANF 1
# define atanf _atanf
#endif
#if defined (_GLIBCXX_HAVE__ATANL) && ! defined (_GLIBCXX_HAVE_ATANL)
# define _GLIBCXX_HAVE_ATANL 1
# define atanl _atanl
#endif
#if defined (_GLIBCXX_HAVE__CEILF) && ! defined (_GLIBCXX_HAVE_CEILF)
# define _GLIBCXX_HAVE_CEILF 1
# define ceilf _ceilf
#endif
#if defined (_GLIBCXX_HAVE__CEILL) && ! defined (_GLIBCXX_HAVE_CEILL)
# define _GLIBCXX_HAVE_CEILL 1
# define ceill _ceill
#endif
#if defined (_GLIBCXX_HAVE__COSF) && ! defined (_GLIBCXX_HAVE_COSF)
# define _GLIBCXX_HAVE_COSF 1
# define cosf _cosf
#endif
#if defined (_GLIBCXX_HAVE__COSHF) && ! defined (_GLIBCXX_HAVE_COSHF)
# define _GLIBCXX_HAVE_COSHF 1
# define coshf _coshf
#endif
#if defined (_GLIBCXX_HAVE__COSHL) && ! defined (_GLIBCXX_HAVE_COSHL)
# define _GLIBCXX_HAVE_COSHL 1
# define coshl _coshl
#endif
#if defined (_GLIBCXX_HAVE__COSL) && ! defined (_GLIBCXX_HAVE_COSL)
# define _GLIBCXX_HAVE_COSL 1
# define cosl _cosl
#endif
#if defined (_GLIBCXX_HAVE__EXPF) && ! defined (_GLIBCXX_HAVE_EXPF)
# define _GLIBCXX_HAVE_EXPF 1
# define expf _expf
#endif
#if defined (_GLIBCXX_HAVE__EXPL) && ! defined (_GLIBCXX_HAVE_EXPL)
# define _GLIBCXX_HAVE_EXPL 1
# define expl _expl
#endif
#if defined (_GLIBCXX_HAVE__FABSF) && ! defined (_GLIBCXX_HAVE_FABSF)
# define _GLIBCXX_HAVE_FABSF 1
# define fabsf _fabsf
#endif
#if defined (_GLIBCXX_HAVE__FABSL) && ! defined (_GLIBCXX_HAVE_FABSL)
# define _GLIBCXX_HAVE_FABSL 1
# define fabsl _fabsl
#endif
#if defined (_GLIBCXX_HAVE__FINITE) && ! defined (_GLIBCXX_HAVE_FINITE)
# define _GLIBCXX_HAVE_FINITE 1
# define finite _finite
#endif
#if defined (_GLIBCXX_HAVE__FINITEF) && ! defined (_GLIBCXX_HAVE_FINITEF)
# define _GLIBCXX_HAVE_FINITEF 1
# define finitef _finitef
#endif
#if defined (_GLIBCXX_HAVE__FINITEL) && ! defined (_GLIBCXX_HAVE_FINITEL)
# define _GLIBCXX_HAVE_FINITEL 1
# define finitel _finitel
#endif
#if defined (_GLIBCXX_HAVE__FLOORF) && ! defined (_GLIBCXX_HAVE_FLOORF)
# define _GLIBCXX_HAVE_FLOORF 1
# define floorf _floorf
#endif
#if defined (_GLIBCXX_HAVE__FLOORL) && ! defined (_GLIBCXX_HAVE_FLOORL)
# define _GLIBCXX_HAVE_FLOORL 1
# define floorl _floorl
#endif
#if defined (_GLIBCXX_HAVE__FMODF) && ! defined (_GLIBCXX_HAVE_FMODF)
# define _GLIBCXX_HAVE_FMODF 1
# define fmodf _fmodf
#endif
#if defined (_GLIBCXX_HAVE__FMODL) && ! defined (_GLIBCXX_HAVE_FMODL)
# define _GLIBCXX_HAVE_FMODL 1
# define fmodl _fmodl
#endif
#if defined (_GLIBCXX_HAVE__FPCLASS) && ! defined (_GLIBCXX_HAVE_FPCLASS)
# define _GLIBCXX_HAVE_FPCLASS 1
# define fpclass _fpclass
#endif
#if defined (_GLIBCXX_HAVE__FREXPF) && ! defined (_GLIBCXX_HAVE_FREXPF)
# define _GLIBCXX_HAVE_FREXPF 1
# define frexpf _frexpf
#endif
#if defined (_GLIBCXX_HAVE__FREXPL) && ! defined (_GLIBCXX_HAVE_FREXPL)
# define _GLIBCXX_HAVE_FREXPL 1
# define frexpl _frexpl
#endif
#if defined (_GLIBCXX_HAVE__HYPOT) && ! defined (_GLIBCXX_HAVE_HYPOT)
# define _GLIBCXX_HAVE_HYPOT 1
# define hypot _hypot
#endif
#if defined (_GLIBCXX_HAVE__HYPOTF) && ! defined (_GLIBCXX_HAVE_HYPOTF)
# define _GLIBCXX_HAVE_HYPOTF 1
# define hypotf _hypotf
#endif
#if defined (_GLIBCXX_HAVE__HYPOTL) && ! defined (_GLIBCXX_HAVE_HYPOTL)
# define _GLIBCXX_HAVE_HYPOTL 1
# define hypotl _hypotl
#endif
#if defined (_GLIBCXX_HAVE__ISINF) && ! defined (_GLIBCXX_HAVE_ISINF)
# define _GLIBCXX_HAVE_ISINF 1
# define isinf _isinf
#endif
#if defined (_GLIBCXX_HAVE__ISINFF) && ! defined (_GLIBCXX_HAVE_ISINFF)
# define _GLIBCXX_HAVE_ISINFF 1
# define isinff _isinff
#endif
#if defined (_GLIBCXX_HAVE__ISINFL) && ! defined (_GLIBCXX_HAVE_ISINFL)
# define _GLIBCXX_HAVE_ISINFL 1
# define isinfl _isinfl
#endif
#if defined (_GLIBCXX_HAVE__ISNAN) && ! defined (_GLIBCXX_HAVE_ISNAN)
# define _GLIBCXX_HAVE_ISNAN 1
# define isnan _isnan
#endif
#if defined (_GLIBCXX_HAVE__ISNANF) && ! defined (_GLIBCXX_HAVE_ISNANF)
# define _GLIBCXX_HAVE_ISNANF 1
# define isnanf _isnanf
#endif
#if defined (_GLIBCXX_HAVE__ISNANL) && ! defined (_GLIBCXX_HAVE_ISNANL)
# define _GLIBCXX_HAVE_ISNANL 1
# define isnanl _isnanl
#endif
#if defined (_GLIBCXX_HAVE__LDEXPF) && ! defined (_GLIBCXX_HAVE_LDEXPF)
# define _GLIBCXX_HAVE_LDEXPF 1
# define ldexpf _ldexpf
#endif
#if defined (_GLIBCXX_HAVE__LDEXPL) && ! defined (_GLIBCXX_HAVE_LDEXPL)
# define _GLIBCXX_HAVE_LDEXPL 1
# define ldexpl _ldexpl
#endif
#if defined (_GLIBCXX_HAVE__LOG10F) && ! defined (_GLIBCXX_HAVE_LOG10F)
# define _GLIBCXX_HAVE_LOG10F 1
# define log10f _log10f
#endif
#if defined (_GLIBCXX_HAVE__LOG10L) && ! defined (_GLIBCXX_HAVE_LOG10L)
# define _GLIBCXX_HAVE_LOG10L 1
# define log10l _log10l
#endif
#if defined (_GLIBCXX_HAVE__LOGF) && ! defined (_GLIBCXX_HAVE_LOGF)
# define _GLIBCXX_HAVE_LOGF 1
# define logf _logf
#endif
#if defined (_GLIBCXX_HAVE__LOGL) && ! defined (_GLIBCXX_HAVE_LOGL)
# define _GLIBCXX_HAVE_LOGL 1
# define logl _logl
#endif
#if defined (_GLIBCXX_HAVE__MODF) && ! defined (_GLIBCXX_HAVE_MODF)
# define _GLIBCXX_HAVE_MODF 1
# define modf _modf
#endif
#if defined (_GLIBCXX_HAVE__MODFF) && ! defined (_GLIBCXX_HAVE_MODFF)
# define _GLIBCXX_HAVE_MODFF 1
# define modff _modff
#endif
#if defined (_GLIBCXX_HAVE__MODFL) && ! defined (_GLIBCXX_HAVE_MODFL)
# define _GLIBCXX_HAVE_MODFL 1
# define modfl _modfl
#endif
#if defined (_GLIBCXX_HAVE__POWF) && ! defined (_GLIBCXX_HAVE_POWF)
# define _GLIBCXX_HAVE_POWF 1
# define powf _powf
#endif
#if defined (_GLIBCXX_HAVE__POWL) && ! defined (_GLIBCXX_HAVE_POWL)
# define _GLIBCXX_HAVE_POWL 1
# define powl _powl
#endif
#if defined (_GLIBCXX_HAVE__QFPCLASS) && ! defined (_GLIBCXX_HAVE_QFPCLASS)
# define _GLIBCXX_HAVE_QFPCLASS 1
# define qfpclass _qfpclass
#endif
#if defined (_GLIBCXX_HAVE__SINCOS) && ! defined (_GLIBCXX_HAVE_SINCOS)
# define _GLIBCXX_HAVE_SINCOS 1
# define sincos _sincos
#endif
#if defined (_GLIBCXX_HAVE__SINCOSF) && ! defined (_GLIBCXX_HAVE_SINCOSF)
# define _GLIBCXX_HAVE_SINCOSF 1
# define sincosf _sincosf
#endif
#if defined (_GLIBCXX_HAVE__SINCOSL) && ! defined (_GLIBCXX_HAVE_SINCOSL)
# define _GLIBCXX_HAVE_SINCOSL 1
# define sincosl _sincosl
#endif
#if defined (_GLIBCXX_HAVE__SINF) && ! defined (_GLIBCXX_HAVE_SINF)
# define _GLIBCXX_HAVE_SINF 1
# define sinf _sinf
#endif
#if defined (_GLIBCXX_HAVE__SINHF) && ! defined (_GLIBCXX_HAVE_SINHF)
# define _GLIBCXX_HAVE_SINHF 1
# define sinhf _sinhf
#endif
#if defined (_GLIBCXX_HAVE__SINHL) && ! defined (_GLIBCXX_HAVE_SINHL)
# define _GLIBCXX_HAVE_SINHL 1
# define sinhl _sinhl
#endif
#if defined (_GLIBCXX_HAVE__SINL) && ! defined (_GLIBCXX_HAVE_SINL)
# define _GLIBCXX_HAVE_SINL 1
# define sinl _sinl
#endif
#if defined (_GLIBCXX_HAVE__SQRTF) && ! defined (_GLIBCXX_HAVE_SQRTF)
# define _GLIBCXX_HAVE_SQRTF 1
# define sqrtf _sqrtf
#endif
#if defined (_GLIBCXX_HAVE__SQRTL) && ! defined (_GLIBCXX_HAVE_SQRTL)
# define _GLIBCXX_HAVE_SQRTL 1
# define sqrtl _sqrtl
#endif
#if defined (_GLIBCXX_HAVE__STRTOF) && ! defined (_GLIBCXX_HAVE_STRTOF)
# define _GLIBCXX_HAVE_STRTOF 1
# define strtof _strtof
#endif
#if defined (_GLIBCXX_HAVE__STRTOLD) && ! defined (_GLIBCXX_HAVE_STRTOLD)
# define _GLIBCXX_HAVE_STRTOLD 1
# define strtold _strtold
#endif
#if defined (_GLIBCXX_HAVE__TANF) && ! defined (_GLIBCXX_HAVE_TANF)
# define _GLIBCXX_HAVE_TANF 1
# define tanf _tanf
#endif
#if defined (_GLIBCXX_HAVE__TANHF) && ! defined (_GLIBCXX_HAVE_TANHF)
# define _GLIBCXX_HAVE_TANHF 1
# define tanhf _tanhf
#endif
#if defined (_GLIBCXX_HAVE__TANHL) && ! defined (_GLIBCXX_HAVE_TANHL)
# define _GLIBCXX_HAVE_TANHL 1
# define tanhl _tanhl
#endif
#if defined (_GLIBCXX_HAVE__TANL) && ! defined (_GLIBCXX_HAVE_TANL)
# define _GLIBCXX_HAVE_TANL 1
# define tanl _tanl
#endif
#endif // _GLIBCXX_CXX_CONFIG_H
c++/8/x86_64-redhat-linux/32/bits/c++locale.h 0000644 00000006353 15201526705 0013723 0 ustar 00 // Wrapper for underlying C-language localization -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/c++locale.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{locale}
*/
//
// ISO C++ 14882: 22.8 Standard locale categories.
//
// Written by Benjamin Kosnik <bkoz@redhat.com>
#ifndef _GLIBCXX_CXX_LOCALE_H
#define _GLIBCXX_CXX_LOCALE_H 1
#pragma GCC system_header
#include <clocale>
#define _GLIBCXX_C_LOCALE_GNU 1
#define _GLIBCXX_NUM_CATEGORIES 6
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
extern "C" __typeof(uselocale) __uselocale;
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef __locale_t __c_locale;
// Convert numeric value of type double and long double to string and
// return length of string. If vsnprintf is available use it, otherwise
// fall back to the unsafe vsprintf which, in general, can be dangerous
// and should be avoided.
inline int
__convert_from_v(const __c_locale& __cloc __attribute__ ((__unused__)),
char* __out,
const int __size __attribute__ ((__unused__)),
const char* __fmt, ...)
{
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__c_locale __old = __gnu_cxx::__uselocale(__cloc);
#else
char* __old = std::setlocale(LC_NUMERIC, 0);
char* __sav = 0;
if (__builtin_strcmp(__old, "C"))
{
const size_t __len = __builtin_strlen(__old) + 1;
__sav = new char[__len];
__builtin_memcpy(__sav, __old, __len);
std::setlocale(LC_NUMERIC, "C");
}
#endif
__builtin_va_list __args;
__builtin_va_start(__args, __fmt);
#if _GLIBCXX_USE_C99_STDIO
const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
#else
const int __ret = __builtin_vsprintf(__out, __fmt, __args);
#endif
__builtin_va_end(__args);
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__gnu_cxx::__uselocale(__old);
#else
if (__sav)
{
std::setlocale(LC_NUMERIC, __sav);
delete [] __sav;
}
#endif
return __ret;
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/x86_64-redhat-linux/32/bits/c++io.h 0000644 00000003110 15201526705 0013057 0 ustar 00 // Underlying io library details -*- C++ -*-
// Copyright (C) 2000-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/c++io.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{ios}
*/
// c_io_stdio.h - Defines for using "C" stdio.h
#ifndef _GLIBCXX_CXX_IO_H
#define _GLIBCXX_CXX_IO_H 1
#include <cstdio>
#include <bits/gthr.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef __gthread_mutex_t __c_lock;
// for basic_file.h
typedef FILE __c_file;
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/x86_64-redhat-linux/32/bits/atomic_word.h 0000644 00000002756 15201526705 0014505 0 ustar 00 // Low-level type for atomic operations -*- C++ -*-
// Copyright (C) 2004-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file atomic_word.h
* This file is a GNU extension to the Standard C++ Library.
*/
#ifndef _GLIBCXX_ATOMIC_WORD_H
#define _GLIBCXX_ATOMIC_WORD_H 1
typedef int _Atomic_word;
// This is a memory order acquire fence.
#define _GLIBCXX_READ_MEM_BARRIER __atomic_thread_fence (__ATOMIC_ACQUIRE)
// This is a memory order release fence.
#define _GLIBCXX_WRITE_MEM_BARRIER __atomic_thread_fence (__ATOMIC_RELEASE)
#endif
c++/8/x86_64-redhat-linux/32/bits/error_constants.h 0000644 00000012067 15201526705 0015417 0 ustar 00 // Specific definitions for generic platforms -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/error_constants.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{system_error}
*/
#ifndef _GLIBCXX_ERROR_CONSTANTS
#define _GLIBCXX_ERROR_CONSTANTS 1
#include <bits/c++config.h>
#include <cerrno>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
enum class errc
{
address_family_not_supported = EAFNOSUPPORT,
address_in_use = EADDRINUSE,
address_not_available = EADDRNOTAVAIL,
already_connected = EISCONN,
argument_list_too_long = E2BIG,
argument_out_of_domain = EDOM,
bad_address = EFAULT,
bad_file_descriptor = EBADF,
#ifdef _GLIBCXX_HAVE_EBADMSG
bad_message = EBADMSG,
#endif
broken_pipe = EPIPE,
connection_aborted = ECONNABORTED,
connection_already_in_progress = EALREADY,
connection_refused = ECONNREFUSED,
connection_reset = ECONNRESET,
cross_device_link = EXDEV,
destination_address_required = EDESTADDRREQ,
device_or_resource_busy = EBUSY,
directory_not_empty = ENOTEMPTY,
executable_format_error = ENOEXEC,
file_exists = EEXIST,
file_too_large = EFBIG,
filename_too_long = ENAMETOOLONG,
function_not_supported = ENOSYS,
host_unreachable = EHOSTUNREACH,
#ifdef _GLIBCXX_HAVE_EIDRM
identifier_removed = EIDRM,
#endif
illegal_byte_sequence = EILSEQ,
inappropriate_io_control_operation = ENOTTY,
interrupted = EINTR,
invalid_argument = EINVAL,
invalid_seek = ESPIPE,
io_error = EIO,
is_a_directory = EISDIR,
message_size = EMSGSIZE,
network_down = ENETDOWN,
network_reset = ENETRESET,
network_unreachable = ENETUNREACH,
no_buffer_space = ENOBUFS,
no_child_process = ECHILD,
#ifdef _GLIBCXX_HAVE_ENOLINK
no_link = ENOLINK,
#endif
no_lock_available = ENOLCK,
#ifdef _GLIBCXX_HAVE_ENODATA
no_message_available = ENODATA,
#endif
no_message = ENOMSG,
no_protocol_option = ENOPROTOOPT,
no_space_on_device = ENOSPC,
#ifdef _GLIBCXX_HAVE_ENOSR
no_stream_resources = ENOSR,
#endif
no_such_device_or_address = ENXIO,
no_such_device = ENODEV,
no_such_file_or_directory = ENOENT,
no_such_process = ESRCH,
not_a_directory = ENOTDIR,
not_a_socket = ENOTSOCK,
#ifdef _GLIBCXX_HAVE_ENOSTR
not_a_stream = ENOSTR,
#endif
not_connected = ENOTCONN,
not_enough_memory = ENOMEM,
#ifdef _GLIBCXX_HAVE_ENOTSUP
not_supported = ENOTSUP,
#endif
#ifdef _GLIBCXX_HAVE_ECANCELED
operation_canceled = ECANCELED,
#endif
operation_in_progress = EINPROGRESS,
operation_not_permitted = EPERM,
operation_not_supported = EOPNOTSUPP,
operation_would_block = EWOULDBLOCK,
#ifdef _GLIBCXX_HAVE_EOWNERDEAD
owner_dead = EOWNERDEAD,
#endif
permission_denied = EACCES,
#ifdef _GLIBCXX_HAVE_EPROTO
protocol_error = EPROTO,
#endif
protocol_not_supported = EPROTONOSUPPORT,
read_only_file_system = EROFS,
resource_deadlock_would_occur = EDEADLK,
resource_unavailable_try_again = EAGAIN,
result_out_of_range = ERANGE,
#ifdef _GLIBCXX_HAVE_ENOTRECOVERABLE
state_not_recoverable = ENOTRECOVERABLE,
#endif
#ifdef _GLIBCXX_HAVE_ETIME
stream_timeout = ETIME,
#endif
#ifdef _GLIBCXX_HAVE_ETXTBSY
text_file_busy = ETXTBSY,
#endif
timed_out = ETIMEDOUT,
too_many_files_open_in_system = ENFILE,
too_many_files_open = EMFILE,
too_many_links = EMLINK,
too_many_symbolic_link_levels = ELOOP,
#ifdef _GLIBCXX_HAVE_EOVERFLOW
value_too_large = EOVERFLOW,
#endif
wrong_protocol_type = EPROTOTYPE
};
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/x86_64-redhat-linux/32/bits/opt_random.h 0000644 00000014062 15201526705 0014331 0 ustar 00 // Optimizations for random number functions, x86 version -*- C++ -*-
// Copyright (C) 2012-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/opt_random.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{random}
*/
#ifndef _BITS_OPT_RANDOM_H
#define _BITS_OPT_RANDOM_H 1
#ifdef __SSE3__
#include <pmmintrin.h>
#endif
#pragma GCC system_header
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
#ifdef __SSE3__
template<>
template<typename _UniformRandomNumberGenerator>
void
normal_distribution<double>::
__generate(typename normal_distribution<double>::result_type* __f,
typename normal_distribution<double>::result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
typedef uint64_t __uctype;
if (__f == __t)
return;
if (_M_saved_available)
{
_M_saved_available = false;
*__f++ = _M_saved * __param.stddev() + __param.mean();
if (__f == __t)
return;
}
constexpr uint64_t __maskval = 0xfffffffffffffull;
static const __m128i __mask = _mm_set1_epi64x(__maskval);
static const __m128i __two = _mm_set1_epi64x(0x4000000000000000ull);
static const __m128d __three = _mm_set1_pd(3.0);
const __m128d __av = _mm_set1_pd(__param.mean());
const __uctype __urngmin = __urng.min();
const __uctype __urngmax = __urng.max();
const __uctype __urngrange = __urngmax - __urngmin;
const __uctype __uerngrange = __urngrange + 1;
while (__f + 1 < __t)
{
double __le;
__m128d __x;
do
{
union
{
__m128i __i;
__m128d __d;
} __v;
if (__urngrange > __maskval)
{
if (__detail::_Power_of_2(__uerngrange))
__v.__i = _mm_and_si128(_mm_set_epi64x(__urng(),
__urng()),
__mask);
else
{
const __uctype __uerange = __maskval + 1;
const __uctype __scaling = __urngrange / __uerange;
const __uctype __past = __uerange * __scaling;
uint64_t __v1;
do
__v1 = __uctype(__urng()) - __urngmin;
while (__v1 >= __past);
__v1 /= __scaling;
uint64_t __v2;
do
__v2 = __uctype(__urng()) - __urngmin;
while (__v2 >= __past);
__v2 /= __scaling;
__v.__i = _mm_set_epi64x(__v1, __v2);
}
}
else if (__urngrange == __maskval)
__v.__i = _mm_set_epi64x(__urng(), __urng());
else if ((__urngrange + 2) * __urngrange >= __maskval
&& __detail::_Power_of_2(__uerngrange))
{
uint64_t __v1 = __urng() * __uerngrange + __urng();
uint64_t __v2 = __urng() * __uerngrange + __urng();
__v.__i = _mm_and_si128(_mm_set_epi64x(__v1, __v2),
__mask);
}
else
{
size_t __nrng = 2;
__uctype __high = __maskval / __uerngrange / __uerngrange;
while (__high > __uerngrange)
{
++__nrng;
__high /= __uerngrange;
}
const __uctype __highrange = __high + 1;
const __uctype __scaling = __urngrange / __highrange;
const __uctype __past = __highrange * __scaling;
__uctype __tmp;
uint64_t __v1;
do
{
do
__tmp = __uctype(__urng()) - __urngmin;
while (__tmp >= __past);
__v1 = __tmp / __scaling;
for (size_t __cnt = 0; __cnt < __nrng; ++__cnt)
{
__tmp = __v1;
__v1 *= __uerngrange;
__v1 += __uctype(__urng()) - __urngmin;
}
}
while (__v1 > __maskval || __v1 < __tmp);
uint64_t __v2;
do
{
do
__tmp = __uctype(__urng()) - __urngmin;
while (__tmp >= __past);
__v2 = __tmp / __scaling;
for (size_t __cnt = 0; __cnt < __nrng; ++__cnt)
{
__tmp = __v2;
__v2 *= __uerngrange;
__v2 += __uctype(__urng()) - __urngmin;
}
}
while (__v2 > __maskval || __v2 < __tmp);
__v.__i = _mm_set_epi64x(__v1, __v2);
}
__v.__i = _mm_or_si128(__v.__i, __two);
__x = _mm_sub_pd(__v.__d, __three);
__m128d __m = _mm_mul_pd(__x, __x);
__le = _mm_cvtsd_f64(_mm_hadd_pd (__m, __m));
}
while (__le == 0.0 || __le >= 1.0);
double __mult = (std::sqrt(-2.0 * std::log(__le) / __le)
* __param.stddev());
__x = _mm_add_pd(_mm_mul_pd(__x, _mm_set1_pd(__mult)), __av);
_mm_storeu_pd(__f, __x);
__f += 2;
}
if (__f != __t)
{
result_type __x, __y, __r2;
__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
__aurng(__urng);
do
{
__x = result_type(2.0) * __aurng() - 1.0;
__y = result_type(2.0) * __aurng() - 1.0;
__r2 = __x * __x + __y * __y;
}
while (__r2 > 1.0 || __r2 == 0.0);
const result_type __mult = std::sqrt(-2 * std::log(__r2) / __r2);
_M_saved = __x * __mult;
_M_saved_available = true;
*__f = __y * __mult * __param.stddev() + __param.mean();
}
}
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif // _BITS_OPT_RANDOM_H
c++/8/x86_64-redhat-linux/32/bits/stdc++.h 0000644 00000005607 15201526705 0013257 0 ustar 00 // C++ includes used for precompiling -*- C++ -*-
// Copyright (C) 2003-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file stdc++.h
* This is an implementation file for a precompiled header.
*/
// 17.4.1.2 Headers
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cuchar>
#include <cwchar>
#include <cwctype>
#endif
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#if __cplusplus >= 201402L
#include <shared_mutex>
#endif
#if __cplusplus >= 201703L
#include <charconv>
#include <filesystem>
#endif
c++/8/x86_64-redhat-linux/32/bits/gthr.h 0000644 00000012750 15201526705 0013135 0 ustar 00 /* Threads compatibility routines for libgcc2. */
/* Compile this one with gcc. */
/* Copyright (C) 1997-2018 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _GLIBCXX_GCC_GTHR_H
#define _GLIBCXX_GCC_GTHR_H
#ifndef _GLIBCXX_HIDE_EXPORTS
#pragma GCC visibility push(default)
#endif
/* If this file is compiled with threads support, it must
#define __GTHREADS 1
to indicate that threads support is present. Also it has define
function
int __gthread_active_p ()
that returns 1 if thread system is active, 0 if not.
The threads interface must define the following types:
__gthread_key_t
__gthread_once_t
__gthread_mutex_t
__gthread_recursive_mutex_t
The threads interface must define the following macros:
__GTHREAD_ONCE_INIT
to initialize __gthread_once_t
__GTHREAD_MUTEX_INIT
to initialize __gthread_mutex_t to get a fast
non-recursive mutex.
__GTHREAD_MUTEX_INIT_FUNCTION
to initialize __gthread_mutex_t to get a fast
non-recursive mutex.
Define this to a function which looks like this:
void __GTHREAD_MUTEX_INIT_FUNCTION (__gthread_mutex_t *)
Some systems can't initialize a mutex without a
function call. Don't define __GTHREAD_MUTEX_INIT in this case.
__GTHREAD_RECURSIVE_MUTEX_INIT
__GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
as above, but for a recursive mutex.
The threads interface must define the following static functions:
int __gthread_once (__gthread_once_t *once, void (*func) ())
int __gthread_key_create (__gthread_key_t *keyp, void (*dtor) (void *))
int __gthread_key_delete (__gthread_key_t key)
void *__gthread_getspecific (__gthread_key_t key)
int __gthread_setspecific (__gthread_key_t key, const void *ptr)
int __gthread_mutex_destroy (__gthread_mutex_t *mutex);
int __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *mutex);
int __gthread_mutex_lock (__gthread_mutex_t *mutex);
int __gthread_mutex_trylock (__gthread_mutex_t *mutex);
int __gthread_mutex_unlock (__gthread_mutex_t *mutex);
int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex);
int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex);
int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex);
The following are supported in POSIX threads only. They are required to
fix a deadlock in static initialization inside libsupc++. The header file
gthr-posix.h defines a symbol __GTHREAD_HAS_COND to signify that these extra
features are supported.
Types:
__gthread_cond_t
Macros:
__GTHREAD_COND_INIT
__GTHREAD_COND_INIT_FUNCTION
Interface:
int __gthread_cond_broadcast (__gthread_cond_t *cond);
int __gthread_cond_wait (__gthread_cond_t *cond, __gthread_mutex_t *mutex);
int __gthread_cond_wait_recursive (__gthread_cond_t *cond,
__gthread_recursive_mutex_t *mutex);
All functions returning int should return zero on success or the error
number. If the operation is not supported, -1 is returned.
If the following are also defined, you should
#define __GTHREADS_CXX0X 1
to enable the c++0x thread library.
Types:
__gthread_t
__gthread_time_t
Interface:
int __gthread_create (__gthread_t *thread, void *(*func) (void*),
void *args);
int __gthread_join (__gthread_t thread, void **value_ptr);
int __gthread_detach (__gthread_t thread);
int __gthread_equal (__gthread_t t1, __gthread_t t2);
__gthread_t __gthread_self (void);
int __gthread_yield (void);
int __gthread_mutex_timedlock (__gthread_mutex_t *m,
const __gthread_time_t *abs_timeout);
int __gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *m,
const __gthread_time_t *abs_time);
int __gthread_cond_signal (__gthread_cond_t *cond);
int __gthread_cond_timedwait (__gthread_cond_t *cond,
__gthread_mutex_t *mutex,
const __gthread_time_t *abs_timeout);
*/
#if __GXX_WEAK__
/* The pe-coff weak support isn't fully compatible to ELF's weak.
For static libraries it might would work, but as we need to deal
with shared versions too, we disable it for mingw-targets. */
#ifdef __MINGW32__
#undef _GLIBCXX_GTHREAD_USE_WEAK
#define _GLIBCXX_GTHREAD_USE_WEAK 0
#endif
#ifndef _GLIBCXX_GTHREAD_USE_WEAK
#define _GLIBCXX_GTHREAD_USE_WEAK 1
#endif
#endif
#include <bits/gthr-default.h>
#ifndef _GLIBCXX_HIDE_EXPORTS
#pragma GCC visibility pop
#endif
#endif /* ! _GLIBCXX_GCC_GTHR_H */
c++/8/x86_64-redhat-linux/32/bits/messages_members.h 0000644 00000010644 15201526705 0015512 0 ustar 00 // std::messages implementation details, GNU version -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/messages_members.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{locale}
*/
//
// ISO C++ 14882: 22.2.7.1.2 messages functions
//
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <libintl.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Non-virtual member functions.
template<typename _CharT>
messages<_CharT>::messages(size_t __refs)
: facet(__refs), _M_c_locale_messages(_S_get_c_locale()),
_M_name_messages(_S_get_c_name())
{ }
template<typename _CharT>
messages<_CharT>::messages(__c_locale __cloc, const char* __s,
size_t __refs)
: facet(__refs), _M_c_locale_messages(0), _M_name_messages(0)
{
if (__builtin_strcmp(__s, _S_get_c_name()) != 0)
{
const size_t __len = __builtin_strlen(__s) + 1;
char* __tmp = new char[__len];
__builtin_memcpy(__tmp, __s, __len);
_M_name_messages = __tmp;
}
else
_M_name_messages = _S_get_c_name();
// Last to avoid leaking memory if new throws.
_M_c_locale_messages = _S_clone_c_locale(__cloc);
}
template<typename _CharT>
typename messages<_CharT>::catalog
messages<_CharT>::open(const basic_string<char>& __s, const locale& __loc,
const char* __dir) const
{
bindtextdomain(__s.c_str(), __dir);
return this->do_open(__s, __loc);
}
// Virtual member functions.
template<typename _CharT>
messages<_CharT>::~messages()
{
if (_M_name_messages != _S_get_c_name())
delete [] _M_name_messages;
_S_destroy_c_locale(_M_c_locale_messages);
}
template<typename _CharT>
typename messages<_CharT>::catalog
messages<_CharT>::do_open(const basic_string<char>& __s,
const locale&) const
{
// No error checking is done, assume the catalog exists and can
// be used.
textdomain(__s.c_str());
return 0;
}
template<typename _CharT>
void
messages<_CharT>::do_close(catalog) const
{ }
// messages_byname
template<typename _CharT>
messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs)
: messages<_CharT>(__refs)
{
if (this->_M_name_messages != locale::facet::_S_get_c_name())
{
delete [] this->_M_name_messages;
if (__builtin_strcmp(__s, locale::facet::_S_get_c_name()) != 0)
{
const size_t __len = __builtin_strlen(__s) + 1;
char* __tmp = new char[__len];
__builtin_memcpy(__tmp, __s, __len);
this->_M_name_messages = __tmp;
}
else
this->_M_name_messages = locale::facet::_S_get_c_name();
}
if (__builtin_strcmp(__s, "C") != 0
&& __builtin_strcmp(__s, "POSIX") != 0)
{
this->_S_destroy_c_locale(this->_M_c_locale_messages);
this->_S_create_c_locale(this->_M_c_locale_messages, __s);
}
}
//Specializations.
template<>
typename messages<char>::catalog
messages<char>::do_open(const basic_string<char>&,
const locale&) const;
template<>
void
messages<char>::do_close(catalog) const;
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
typename messages<wchar_t>::catalog
messages<wchar_t>::do_open(const basic_string<char>&,
const locale&) const;
template<>
void
messages<wchar_t>::do_close(catalog) const;
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
c++/8/x86_64-redhat-linux/32/bits/cpu_defines.h 0000644 00000002465 15201526705 0014457 0 ustar 00 // Specific definitions for generic platforms -*- C++ -*-
// Copyright (C) 2005-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/cpu_defines.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{iosfwd}
*/
#ifndef _GLIBCXX_CPU_DEFINES
#define _GLIBCXX_CPU_DEFINES 1
#endif
c++/8/cassert 0000644 00000003160 15201526705 0006655 0 ustar 00 // -*- C++ -*- forwarding header.
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file cassert
* This is a Standard C++ Library file. You should @c \#include this file
* in your programs, rather than any of the @a *.h implementation files.
*
* This is the C++ version of the Standard C Library header @c assert.h,
* and its contents are (mostly) the same as that header, but are all
* contained in the namespace @c std (except for names which are defined
* as macros in C).
*/
//
// ISO C++ 14882: 19.2 Assertions
//
// No include guards on this header...
#pragma GCC system_header
#include <bits/c++config.h>
#include <assert.h>
c++/8/scoped_allocator 0000644 00000037535 15201526705 0010543 0 ustar 00 // <scoped_allocator> -*- C++ -*-
// Copyright (C) 2011-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/scoped_allocator
* This is a Standard C++ Library header.
*/
#ifndef _SCOPED_ALLOCATOR
#define _SCOPED_ALLOCATOR 1
#pragma GCC system_header
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
#include <utility>
#include <tuple>
#include <bits/alloc_traits.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @addtogroup allocators
* @{
*/
template<typename _Alloc>
using __outer_allocator_t
= decltype(std::declval<_Alloc>().outer_allocator());
template<typename _Alloc, typename = void>
struct __outermost_type
{
using type = _Alloc;
static type& _S_outermost(_Alloc& __a) { return __a; }
};
template<typename _Alloc>
struct __outermost_type<_Alloc, __void_t<__outer_allocator_t<_Alloc>>>
: __outermost_type<
typename remove_reference<__outer_allocator_t<_Alloc>>::type
>
{
using __base = __outermost_type<
typename remove_reference<__outer_allocator_t<_Alloc>>::type
>;
static typename __base::type&
_S_outermost(_Alloc& __a)
{ return __base::_S_outermost(__a.outer_allocator()); }
};
template<typename _Alloc>
inline typename __outermost_type<_Alloc>::type&
__outermost(_Alloc& __a)
{ return __outermost_type<_Alloc>::_S_outermost(__a); }
template<typename _OuterAlloc, typename... _InnerAllocs>
class scoped_allocator_adaptor;
template<typename...>
struct __inner_type_impl;
template<typename _Outer>
struct __inner_type_impl<_Outer>
{
typedef scoped_allocator_adaptor<_Outer> __type;
__inner_type_impl() = default;
__inner_type_impl(const __inner_type_impl&) = default;
__inner_type_impl(__inner_type_impl&&) = default;
__inner_type_impl& operator=(const __inner_type_impl&) = default;
__inner_type_impl& operator=(__inner_type_impl&&) = default;
template<typename _Alloc>
__inner_type_impl(const __inner_type_impl<_Alloc>& __other)
{ }
template<typename _Alloc>
__inner_type_impl(__inner_type_impl<_Alloc>&& __other)
{ }
__type&
_M_get(__type* __p) noexcept { return *__p; }
const __type&
_M_get(const __type* __p) const noexcept { return *__p; }
tuple<>
_M_tie() const noexcept { return tuple<>(); }
bool
operator==(const __inner_type_impl&) const noexcept
{ return true; }
};
template<typename _Outer, typename _InnerHead, typename... _InnerTail>
struct __inner_type_impl<_Outer, _InnerHead, _InnerTail...>
{
typedef scoped_allocator_adaptor<_InnerHead, _InnerTail...> __type;
__inner_type_impl() = default;
__inner_type_impl(const __inner_type_impl&) = default;
__inner_type_impl(__inner_type_impl&&) = default;
__inner_type_impl& operator=(const __inner_type_impl&) = default;
__inner_type_impl& operator=(__inner_type_impl&&) = default;
template<typename... _Allocs>
__inner_type_impl(const __inner_type_impl<_Allocs...>& __other)
: _M_inner(__other._M_inner) { }
template<typename... _Allocs>
__inner_type_impl(__inner_type_impl<_Allocs...>&& __other)
: _M_inner(std::move(__other._M_inner)) { }
template<typename... _Args>
explicit
__inner_type_impl(_Args&&... __args)
: _M_inner(std::forward<_Args>(__args)...) { }
__type&
_M_get(void*) noexcept { return _M_inner; }
const __type&
_M_get(const void*) const noexcept { return _M_inner; }
tuple<const _InnerHead&, const _InnerTail&...>
_M_tie() const noexcept
{ return _M_inner._M_tie(); }
bool
operator==(const __inner_type_impl& __other) const noexcept
{ return _M_inner == __other._M_inner; }
private:
template<typename...> friend class __inner_type_impl;
template<typename, typename...> friend class scoped_allocator_adaptor;
__type _M_inner;
};
/// Primary class template.
template<typename _OuterAlloc, typename... _InnerAllocs>
class scoped_allocator_adaptor
: public _OuterAlloc
{
typedef allocator_traits<_OuterAlloc> __traits;
typedef __inner_type_impl<_OuterAlloc, _InnerAllocs...> __inner_type;
__inner_type _M_inner;
template<typename _Outer, typename... _Inner>
friend class scoped_allocator_adaptor;
template<typename...>
friend class __inner_type_impl;
tuple<const _OuterAlloc&, const _InnerAllocs&...>
_M_tie() const noexcept
{ return std::tuple_cat(std::tie(outer_allocator()), _M_inner._M_tie()); }
template<typename _Alloc>
using __outermost_alloc_traits
= allocator_traits<typename __outermost_type<_Alloc>::type>;
template<typename _Tp, typename... _Args>
void
_M_construct(__uses_alloc0, _Tp* __p, _Args&&... __args)
{
typedef __outermost_alloc_traits<scoped_allocator_adaptor> _O_traits;
_O_traits::construct(__outermost(*this), __p,
std::forward<_Args>(__args)...);
}
typedef __uses_alloc1<typename __inner_type::__type> __uses_alloc1_;
typedef __uses_alloc2<typename __inner_type::__type> __uses_alloc2_;
template<typename _Tp, typename... _Args>
void
_M_construct(__uses_alloc1_, _Tp* __p, _Args&&... __args)
{
typedef __outermost_alloc_traits<scoped_allocator_adaptor> _O_traits;
_O_traits::construct(__outermost(*this), __p,
allocator_arg, inner_allocator(),
std::forward<_Args>(__args)...);
}
template<typename _Tp, typename... _Args>
void
_M_construct(__uses_alloc2_, _Tp* __p, _Args&&... __args)
{
typedef __outermost_alloc_traits<scoped_allocator_adaptor> _O_traits;
_O_traits::construct(__outermost(*this), __p,
std::forward<_Args>(__args)...,
inner_allocator());
}
template<typename _Alloc>
static _Alloc
_S_select_on_copy(const _Alloc& __a)
{
typedef allocator_traits<_Alloc> __a_traits;
return __a_traits::select_on_container_copy_construction(__a);
}
template<std::size_t... _Indices>
scoped_allocator_adaptor(tuple<const _OuterAlloc&,
const _InnerAllocs&...> __refs,
_Index_tuple<_Indices...>)
: _OuterAlloc(_S_select_on_copy(std::get<0>(__refs))),
_M_inner(_S_select_on_copy(std::get<_Indices+1>(__refs))...)
{ }
// Used to constrain constructors to disallow invalid conversions.
template<typename _Alloc>
using _Constructible = typename enable_if<
is_constructible<_OuterAlloc, _Alloc>::value
>::type;
public:
typedef _OuterAlloc outer_allocator_type;
typedef typename __inner_type::__type inner_allocator_type;
typedef typename __traits::value_type value_type;
typedef typename __traits::size_type size_type;
typedef typename __traits::difference_type difference_type;
typedef typename __traits::pointer pointer;
typedef typename __traits::const_pointer const_pointer;
typedef typename __traits::void_pointer void_pointer;
typedef typename __traits::const_void_pointer const_void_pointer;
typedef typename __or_<
typename __traits::propagate_on_container_copy_assignment,
typename allocator_traits<_InnerAllocs>::
propagate_on_container_copy_assignment...>::type
propagate_on_container_copy_assignment;
typedef typename __or_<
typename __traits::propagate_on_container_move_assignment,
typename allocator_traits<_InnerAllocs>::
propagate_on_container_move_assignment...>::type
propagate_on_container_move_assignment;
typedef typename __or_<
typename __traits::propagate_on_container_swap,
typename allocator_traits<_InnerAllocs>::
propagate_on_container_swap...>::type
propagate_on_container_swap;
typedef typename __and_<
typename __traits::is_always_equal,
typename allocator_traits<_InnerAllocs>::is_always_equal...>::type
is_always_equal;
template <class _Tp>
struct rebind
{
typedef scoped_allocator_adaptor<
typename __traits::template rebind_alloc<_Tp>,
_InnerAllocs...> other;
};
scoped_allocator_adaptor() : _OuterAlloc(), _M_inner() { }
template<typename _Outer2, typename = _Constructible<_Outer2>>
scoped_allocator_adaptor(_Outer2&& __outer,
const _InnerAllocs&... __inner)
: _OuterAlloc(std::forward<_Outer2>(__outer)),
_M_inner(__inner...)
{ }
scoped_allocator_adaptor(const scoped_allocator_adaptor& __other)
: _OuterAlloc(__other.outer_allocator()),
_M_inner(__other._M_inner)
{ }
scoped_allocator_adaptor(scoped_allocator_adaptor&& __other)
: _OuterAlloc(std::move(__other.outer_allocator())),
_M_inner(std::move(__other._M_inner))
{ }
template<typename _Outer2, typename = _Constructible<const _Outer2&>>
scoped_allocator_adaptor(
const scoped_allocator_adaptor<_Outer2, _InnerAllocs...>& __other)
: _OuterAlloc(__other.outer_allocator()),
_M_inner(__other._M_inner)
{ }
template<typename _Outer2, typename = _Constructible<_Outer2>>
scoped_allocator_adaptor(
scoped_allocator_adaptor<_Outer2, _InnerAllocs...>&& __other)
: _OuterAlloc(std::move(__other.outer_allocator())),
_M_inner(std::move(__other._M_inner))
{ }
scoped_allocator_adaptor&
operator=(const scoped_allocator_adaptor&) = default;
scoped_allocator_adaptor&
operator=(scoped_allocator_adaptor&&) = default;
inner_allocator_type& inner_allocator() noexcept
{ return _M_inner._M_get(this); }
const inner_allocator_type& inner_allocator() const noexcept
{ return _M_inner._M_get(this); }
outer_allocator_type& outer_allocator() noexcept
{ return static_cast<_OuterAlloc&>(*this); }
const outer_allocator_type& outer_allocator() const noexcept
{ return static_cast<const _OuterAlloc&>(*this); }
pointer allocate(size_type __n)
{ return __traits::allocate(outer_allocator(), __n); }
pointer allocate(size_type __n, const_void_pointer __hint)
{ return __traits::allocate(outer_allocator(), __n, __hint); }
void deallocate(pointer __p, size_type __n)
{ return __traits::deallocate(outer_allocator(), __p, __n); }
size_type max_size() const
{ return __traits::max_size(outer_allocator()); }
template<typename _Tp, typename... _Args>
void construct(_Tp* __p, _Args&&... __args)
{
auto& __inner = inner_allocator();
auto __use_tag
= __use_alloc<_Tp, inner_allocator_type, _Args...>(__inner);
_M_construct(__use_tag, __p, std::forward<_Args>(__args)...);
}
template<typename _T1, typename _T2, typename... _Args1,
typename... _Args2>
void
construct(pair<_T1, _T2>* __p, piecewise_construct_t,
tuple<_Args1...> __x, tuple<_Args2...> __y)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2203. wrong argument types for piecewise construction
auto& __inner = inner_allocator();
auto __x_use_tag
= __use_alloc<_T1, inner_allocator_type, _Args1...>(__inner);
auto __y_use_tag
= __use_alloc<_T2, inner_allocator_type, _Args2...>(__inner);
typename _Build_index_tuple<sizeof...(_Args1)>::__type __x_indices;
typename _Build_index_tuple<sizeof...(_Args2)>::__type __y_indices;
typedef __outermost_alloc_traits<scoped_allocator_adaptor> _O_traits;
_O_traits::construct(__outermost(*this), __p, piecewise_construct,
_M_construct_p(__x_use_tag, __x_indices, __x),
_M_construct_p(__y_use_tag, __y_indices, __y));
}
template<typename _T1, typename _T2>
void
construct(pair<_T1, _T2>* __p)
{ construct(__p, piecewise_construct, tuple<>(), tuple<>()); }
template<typename _T1, typename _T2, typename _Up, typename _Vp>
void
construct(pair<_T1, _T2>* __p, _Up&& __u, _Vp&& __v)
{
construct(__p, piecewise_construct,
std::forward_as_tuple(std::forward<_Up>(__u)),
std::forward_as_tuple(std::forward<_Vp>(__v)));
}
template<typename _T1, typename _T2, typename _Up, typename _Vp>
void
construct(pair<_T1, _T2>* __p, const pair<_Up, _Vp>& __x)
{
construct(__p, piecewise_construct,
std::forward_as_tuple(__x.first),
std::forward_as_tuple(__x.second));
}
template<typename _T1, typename _T2, typename _Up, typename _Vp>
void
construct(pair<_T1, _T2>* __p, pair<_Up, _Vp>&& __x)
{
construct(__p, piecewise_construct,
std::forward_as_tuple(std::forward<_Up>(__x.first)),
std::forward_as_tuple(std::forward<_Vp>(__x.second)));
}
template<typename _Tp>
void destroy(_Tp* __p)
{
typedef __outermost_alloc_traits<scoped_allocator_adaptor> _O_traits;
_O_traits::destroy(__outermost(*this), __p);
}
scoped_allocator_adaptor
select_on_container_copy_construction() const
{
typedef typename _Build_index_tuple<sizeof...(_InnerAllocs)>::__type
_Indices;
return scoped_allocator_adaptor(_M_tie(), _Indices());
}
template <typename _OutA1, typename _OutA2, typename... _InA>
friend bool
operator==(const scoped_allocator_adaptor<_OutA1, _InA...>& __a,
const scoped_allocator_adaptor<_OutA2, _InA...>& __b) noexcept;
private:
template<typename _Ind, typename... _Args>
tuple<_Args&&...>
_M_construct_p(__uses_alloc0, _Ind, tuple<_Args...>& __t)
{ return std::move(__t); }
template<size_t... _Ind, typename... _Args>
tuple<allocator_arg_t, inner_allocator_type&, _Args&&...>
_M_construct_p(__uses_alloc1_, _Index_tuple<_Ind...>,
tuple<_Args...>& __t)
{
return { allocator_arg, inner_allocator(),
std::get<_Ind>(std::move(__t))...
};
}
template<size_t... _Ind, typename... _Args>
tuple<_Args&&..., inner_allocator_type&>
_M_construct_p(__uses_alloc2_, _Index_tuple<_Ind...>,
tuple<_Args...>& __t)
{
return { std::get<_Ind>(std::move(__t))..., inner_allocator() };
}
};
template <typename _OutA1, typename _OutA2, typename... _InA>
inline bool
operator==(const scoped_allocator_adaptor<_OutA1, _InA...>& __a,
const scoped_allocator_adaptor<_OutA2, _InA...>& __b) noexcept
{
return __a.outer_allocator() == __b.outer_allocator()
&& __a._M_inner == __b._M_inner;
}
template <typename _OutA1, typename _OutA2, typename... _InA>
inline bool
operator!=(const scoped_allocator_adaptor<_OutA1, _InA...>& __a,
const scoped_allocator_adaptor<_OutA2, _InA...>& __b) noexcept
{ return !(__a == __b); }
/// @}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif // C++11
#endif // _SCOPED_ALLOCATOR
c++/8/string_view 0000644 00000050467 15201526705 0007565 0 ustar 00 // Components for manipulating non-owning sequences of characters -*- C++ -*-
// Copyright (C) 2013-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file string_view
* This is a Standard C++ Library header.
*/
//
// N3762 basic_string_view library
//
#ifndef _GLIBCXX_STRING_VIEW
#define _GLIBCXX_STRING_VIEW 1
#pragma GCC system_header
#if __cplusplus >= 201703L
#include <limits>
#include <iosfwd>
#include <bits/char_traits.h>
#include <bits/functional_hash.h>
#include <bits/range_access.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
#define __cpp_lib_string_view 201603
/**
* @class basic_string_view <string_view>
* @brief A non-owning reference to a string.
*
* @ingroup strings
* @ingroup sequences
*
* @tparam _CharT Type of character
* @tparam _Traits Traits for character type, defaults to
* char_traits<_CharT>.
*
* A basic_string_view looks like this:
*
* @code
* _CharT* _M_str
* size_t _M_len
* @endcode
*/
template<typename _CharT, typename _Traits = std::char_traits<_CharT>>
class basic_string_view
{
public:
// types
using traits_type = _Traits;
using value_type = _CharT;
using pointer = const _CharT*;
using const_pointer = const _CharT*;
using reference = const _CharT&;
using const_reference = const _CharT&;
using const_iterator = const _CharT*;
using iterator = const_iterator;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
using reverse_iterator = const_reverse_iterator;
using size_type = size_t;
using difference_type = ptrdiff_t;
static constexpr size_type npos = size_type(-1);
// [string.view.cons], construct/copy
constexpr
basic_string_view() noexcept
: _M_len{0}, _M_str{nullptr}
{ }
constexpr basic_string_view(const basic_string_view&) noexcept = default;
constexpr basic_string_view(const _CharT* __str) noexcept
: _M_len{__str == nullptr ? 0 : traits_type::length(__str)},
_M_str{__str}
{ }
constexpr
basic_string_view(const _CharT* __str, size_type __len) noexcept
: _M_len{__len}, _M_str{__str}
{ }
constexpr basic_string_view&
operator=(const basic_string_view&) noexcept = default;
// [string.view.iterators], iterators
constexpr const_iterator
begin() const noexcept
{ return this->_M_str; }
constexpr const_iterator
end() const noexcept
{ return this->_M_str + this->_M_len; }
constexpr const_iterator
cbegin() const noexcept
{ return this->_M_str; }
constexpr const_iterator
cend() const noexcept
{ return this->_M_str + this->_M_len; }
constexpr const_reverse_iterator
rbegin() const noexcept
{ return const_reverse_iterator(this->end()); }
constexpr const_reverse_iterator
rend() const noexcept
{ return const_reverse_iterator(this->begin()); }
constexpr const_reverse_iterator
crbegin() const noexcept
{ return const_reverse_iterator(this->end()); }
constexpr const_reverse_iterator
crend() const noexcept
{ return const_reverse_iterator(this->begin()); }
// [string.view.capacity], capacity
constexpr size_type
size() const noexcept
{ return this->_M_len; }
constexpr size_type
length() const noexcept
{ return _M_len; }
constexpr size_type
max_size() const noexcept
{
return (npos - sizeof(size_type) - sizeof(void*))
/ sizeof(value_type) / 4;
}
[[nodiscard]] constexpr bool
empty() const noexcept
{ return this->_M_len == 0; }
// [string.view.access], element access
constexpr const _CharT&
operator[](size_type __pos) const noexcept
{
__glibcxx_assert(__pos < this->_M_len);
return *(this->_M_str + __pos);
}
constexpr const _CharT&
at(size_type __pos) const
{
if (__pos >= _M_len)
__throw_out_of_range_fmt(__N("basic_string_view::at: __pos "
"(which is %zu) >= this->size() "
"(which is %zu)"), __pos, this->size());
return *(this->_M_str + __pos);
}
constexpr const _CharT&
front() const noexcept
{
__glibcxx_assert(this->_M_len > 0);
return *this->_M_str;
}
constexpr const _CharT&
back() const noexcept
{
__glibcxx_assert(this->_M_len > 0);
return *(this->_M_str + this->_M_len - 1);
}
constexpr const _CharT*
data() const noexcept
{ return this->_M_str; }
// [string.view.modifiers], modifiers:
constexpr void
remove_prefix(size_type __n) noexcept
{
__glibcxx_assert(this->_M_len >= __n);
this->_M_str += __n;
this->_M_len -= __n;
}
constexpr void
remove_suffix(size_type __n) noexcept
{ this->_M_len -= __n; }
constexpr void
swap(basic_string_view& __sv) noexcept
{
auto __tmp = *this;
*this = __sv;
__sv = __tmp;
}
// [string.view.ops], string operations:
size_type
copy(_CharT* __str, size_type __n, size_type __pos = 0) const
{
__glibcxx_requires_string_len(__str, __n);
__pos = _M_check(__pos, "basic_string_view::copy");
const size_type __rlen = std::min(__n, _M_len - __pos);
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2777. basic_string_view::copy should use char_traits::copy
traits_type::copy(__str, data() + __pos, __rlen);
return __rlen;
}
constexpr basic_string_view
substr(size_type __pos = 0, size_type __n = npos) const noexcept(false)
{
__pos = _M_check(__pos, "basic_string_view::substr");
const size_type __rlen = std::min(__n, _M_len - __pos);
return basic_string_view{_M_str + __pos, __rlen};
}
constexpr int
compare(basic_string_view __str) const noexcept
{
const size_type __rlen = std::min(this->_M_len, __str._M_len);
int __ret = traits_type::compare(this->_M_str, __str._M_str, __rlen);
if (__ret == 0)
__ret = _S_compare(this->_M_len, __str._M_len);
return __ret;
}
constexpr int
compare(size_type __pos1, size_type __n1, basic_string_view __str) const
{ return this->substr(__pos1, __n1).compare(__str); }
constexpr int
compare(size_type __pos1, size_type __n1,
basic_string_view __str, size_type __pos2, size_type __n2) const
{
return this->substr(__pos1, __n1).compare(__str.substr(__pos2, __n2));
}
constexpr int
compare(const _CharT* __str) const noexcept
{ return this->compare(basic_string_view{__str}); }
constexpr int
compare(size_type __pos1, size_type __n1, const _CharT* __str) const
{ return this->substr(__pos1, __n1).compare(basic_string_view{__str}); }
constexpr int
compare(size_type __pos1, size_type __n1,
const _CharT* __str, size_type __n2) const noexcept(false)
{
return this->substr(__pos1, __n1)
.compare(basic_string_view(__str, __n2));
}
constexpr size_type
find(basic_string_view __str, size_type __pos = 0) const noexcept
{ return this->find(__str._M_str, __pos, __str._M_len); }
constexpr size_type
find(_CharT __c, size_type __pos = 0) const noexcept;
constexpr size_type
find(const _CharT* __str, size_type __pos, size_type __n) const noexcept;
constexpr size_type
find(const _CharT* __str, size_type __pos = 0) const noexcept
{ return this->find(__str, __pos, traits_type::length(__str)); }
constexpr size_type
rfind(basic_string_view __str, size_type __pos = npos) const noexcept
{ return this->rfind(__str._M_str, __pos, __str._M_len); }
constexpr size_type
rfind(_CharT __c, size_type __pos = npos) const noexcept;
constexpr size_type
rfind(const _CharT* __str, size_type __pos, size_type __n) const noexcept;
constexpr size_type
rfind(const _CharT* __str, size_type __pos = npos) const noexcept
{ return this->rfind(__str, __pos, traits_type::length(__str)); }
constexpr size_type
find_first_of(basic_string_view __str, size_type __pos = 0) const noexcept
{ return this->find_first_of(__str._M_str, __pos, __str._M_len); }
constexpr size_type
find_first_of(_CharT __c, size_type __pos = 0) const noexcept
{ return this->find(__c, __pos); }
constexpr size_type
find_first_of(const _CharT* __str, size_type __pos, size_type __n) const noexcept;
constexpr size_type
find_first_of(const _CharT* __str, size_type __pos = 0) const noexcept
{ return this->find_first_of(__str, __pos, traits_type::length(__str)); }
constexpr size_type
find_last_of(basic_string_view __str,
size_type __pos = npos) const noexcept
{ return this->find_last_of(__str._M_str, __pos, __str._M_len); }
constexpr size_type
find_last_of(_CharT __c, size_type __pos=npos) const noexcept
{ return this->rfind(__c, __pos); }
constexpr size_type
find_last_of(const _CharT* __str, size_type __pos,
size_type __n) const noexcept;
constexpr size_type
find_last_of(const _CharT* __str, size_type __pos = npos) const noexcept
{ return this->find_last_of(__str, __pos, traits_type::length(__str)); }
constexpr size_type
find_first_not_of(basic_string_view __str,
size_type __pos = 0) const noexcept
{ return this->find_first_not_of(__str._M_str, __pos, __str._M_len); }
constexpr size_type
find_first_not_of(_CharT __c, size_type __pos = 0) const noexcept;
constexpr size_type
find_first_not_of(const _CharT* __str,
size_type __pos, size_type __n) const noexcept;
constexpr size_type
find_first_not_of(const _CharT* __str, size_type __pos = 0) const noexcept
{
return this->find_first_not_of(__str, __pos,
traits_type::length(__str));
}
constexpr size_type
find_last_not_of(basic_string_view __str,
size_type __pos = npos) const noexcept
{ return this->find_last_not_of(__str._M_str, __pos, __str._M_len); }
constexpr size_type
find_last_not_of(_CharT __c, size_type __pos = npos) const noexcept;
constexpr size_type
find_last_not_of(const _CharT* __str,
size_type __pos, size_type __n) const noexcept;
constexpr size_type
find_last_not_of(const _CharT* __str,
size_type __pos = npos) const noexcept
{
return this->find_last_not_of(__str, __pos,
traits_type::length(__str));
}
constexpr size_type
_M_check(size_type __pos, const char* __s) const noexcept(false)
{
if (__pos > this->size())
__throw_out_of_range_fmt(__N("%s: __pos (which is %zu) > "
"this->size() (which is %zu)"),
__s, __pos, this->size());
return __pos;
}
// NB: _M_limit doesn't check for a bad __pos value.
constexpr size_type
_M_limit(size_type __pos, size_type __off) const noexcept
{
const bool __testoff = __off < this->size() - __pos;
return __testoff ? __off : this->size() - __pos;
}
private:
static constexpr int
_S_compare(size_type __n1, size_type __n2) noexcept
{
const difference_type __diff = __n1 - __n2;
if (__diff > std::numeric_limits<int>::max())
return std::numeric_limits<int>::max();
if (__diff < std::numeric_limits<int>::min())
return std::numeric_limits<int>::min();
return static_cast<int>(__diff);
}
size_t _M_len;
const _CharT* _M_str;
};
// [string.view.comparison], non-member basic_string_view comparison function
namespace __detail
{
// Identity transform to create a non-deduced context, so that only one
// argument participates in template argument deduction and the other
// argument gets implicitly converted to the deduced type. See n3766.html.
template<typename _Tp>
using __idt = common_type_t<_Tp>;
}
template<typename _CharT, typename _Traits>
constexpr bool
operator==(basic_string_view<_CharT, _Traits> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.size() == __y.size() && __x.compare(__y) == 0; }
template<typename _CharT, typename _Traits>
constexpr bool
operator==(basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
{ return __x.size() == __y.size() && __x.compare(__y) == 0; }
template<typename _CharT, typename _Traits>
constexpr bool
operator==(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.size() == __y.size() && __x.compare(__y) == 0; }
template<typename _CharT, typename _Traits>
constexpr bool
operator!=(basic_string_view<_CharT, _Traits> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return !(__x == __y); }
template<typename _CharT, typename _Traits>
constexpr bool
operator!=(basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
{ return !(__x == __y); }
template<typename _CharT, typename _Traits>
constexpr bool
operator!=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return !(__x == __y); }
template<typename _CharT, typename _Traits>
constexpr bool
operator< (basic_string_view<_CharT, _Traits> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) < 0; }
template<typename _CharT, typename _Traits>
constexpr bool
operator< (basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
{ return __x.compare(__y) < 0; }
template<typename _CharT, typename _Traits>
constexpr bool
operator< (__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) < 0; }
template<typename _CharT, typename _Traits>
constexpr bool
operator> (basic_string_view<_CharT, _Traits> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) > 0; }
template<typename _CharT, typename _Traits>
constexpr bool
operator> (basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
{ return __x.compare(__y) > 0; }
template<typename _CharT, typename _Traits>
constexpr bool
operator> (__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) > 0; }
template<typename _CharT, typename _Traits>
constexpr bool
operator<=(basic_string_view<_CharT, _Traits> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) <= 0; }
template<typename _CharT, typename _Traits>
constexpr bool
operator<=(basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
{ return __x.compare(__y) <= 0; }
template<typename _CharT, typename _Traits>
constexpr bool
operator<=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) <= 0; }
template<typename _CharT, typename _Traits>
constexpr bool
operator>=(basic_string_view<_CharT, _Traits> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) >= 0; }
template<typename _CharT, typename _Traits>
constexpr bool
operator>=(basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
{ return __x.compare(__y) >= 0; }
template<typename _CharT, typename _Traits>
constexpr bool
operator>=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) >= 0; }
// [string.view.io], Inserters and extractors
template<typename _CharT, typename _Traits>
inline basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
basic_string_view<_CharT,_Traits> __str)
{ return __ostream_insert(__os, __str.data(), __str.size()); }
// basic_string_view typedef names
using string_view = basic_string_view<char>;
#ifdef _GLIBCXX_USE_WCHAR_T
using wstring_view = basic_string_view<wchar_t>;
#endif
#ifdef _GLIBCXX_USE_C99_STDINT_TR1
using u16string_view = basic_string_view<char16_t>;
using u32string_view = basic_string_view<char32_t>;
#endif
// [string.view.hash], hash support:
template<typename _Tp>
struct hash;
template<>
struct hash<string_view>
: public __hash_base<size_t, string_view>
{
size_t
operator()(const string_view& __str) const noexcept
{ return std::_Hash_impl::hash(__str.data(), __str.length()); }
};
template<>
struct __is_fast_hash<hash<string_view>> : std::false_type
{ };
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
struct hash<wstring_view>
: public __hash_base<size_t, wstring>
{
size_t
operator()(const wstring_view& __s) const noexcept
{ return std::_Hash_impl::hash(__s.data(),
__s.length() * sizeof(wchar_t)); }
};
template<>
struct __is_fast_hash<hash<wstring_view>> : std::false_type
{ };
#endif
#ifdef _GLIBCXX_USE_C99_STDINT_TR1
template<>
struct hash<u16string_view>
: public __hash_base<size_t, u16string_view>
{
size_t
operator()(const u16string_view& __s) const noexcept
{ return std::_Hash_impl::hash(__s.data(),
__s.length() * sizeof(char16_t)); }
};
template<>
struct __is_fast_hash<hash<u16string_view>> : std::false_type
{ };
template<>
struct hash<u32string_view>
: public __hash_base<size_t, u32string_view>
{
size_t
operator()(const u32string_view& __s) const noexcept
{ return std::_Hash_impl::hash(__s.data(),
__s.length() * sizeof(char32_t)); }
};
template<>
struct __is_fast_hash<hash<u32string_view>> : std::false_type
{ };
#endif
inline namespace literals
{
inline namespace string_view_literals
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wliteral-suffix"
inline constexpr basic_string_view<char>
operator""sv(const char* __str, size_t __len) noexcept
{ return basic_string_view<char>{__str, __len}; }
#ifdef _GLIBCXX_USE_WCHAR_T
inline constexpr basic_string_view<wchar_t>
operator""sv(const wchar_t* __str, size_t __len) noexcept
{ return basic_string_view<wchar_t>{__str, __len}; }
#endif
#ifdef _GLIBCXX_USE_C99_STDINT_TR1
inline constexpr basic_string_view<char16_t>
operator""sv(const char16_t* __str, size_t __len) noexcept
{ return basic_string_view<char16_t>{__str, __len}; }
inline constexpr basic_string_view<char32_t>
operator""sv(const char32_t* __str, size_t __len) noexcept
{ return basic_string_view<char32_t>{__str, __len}; }
#endif
#pragma GCC diagnostic pop
} // namespace string_literals
} // namespace literals
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#include <bits/string_view.tcc>
#endif // __cplusplus <= 201402L
#endif // _GLIBCXX_EXPERIMENTAL_STRING_VIEW
c++/8/profile/map.h 0000644 00000047204 15201526705 0007663 0 ustar 00 // Profiling map implementation -*- C++ -*-
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
/** @file profile/map.h
* This file is a GNU profile extension to the Standard C++ Library.
*/
#ifndef _GLIBCXX_PROFILE_MAP_H
#define _GLIBCXX_PROFILE_MAP_H 1
#include <profile/base.h>
#include <profile/ordered_base.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __profile
{
/// Class std::map wrapper with performance instrumentation.
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Allocator = std::allocator<std::pair<const _Key, _Tp> > >
class map
: public _GLIBCXX_STD_C::map<_Key, _Tp, _Compare, _Allocator>,
public _Ordered_profile<map<_Key, _Tp, _Compare, _Allocator> >
{
typedef _GLIBCXX_STD_C::map<_Key, _Tp, _Compare, _Allocator> _Base;
typedef typename _Base::iterator _Base_iterator;
typedef typename _Base::const_iterator _Base_const_iterator;
public:
// types:
typedef _Key key_type;
typedef _Tp mapped_type;
typedef typename _Base::value_type value_type;
typedef _Compare key_compare;
typedef typename _Base::reference reference;
typedef typename _Base::const_reference const_reference;
typedef __iterator_tracker<_Base_iterator, map> iterator;
typedef __iterator_tracker<_Base_const_iterator,
map> const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
typedef typename _Base::size_type size_type;
typedef typename _Base::difference_type difference_type;
// 23.3.1.1 construct/copy/destroy:
#if __cplusplus < 201103L
map()
: _Base() { }
map(const map& __x)
: _Base(__x) { }
~map()
{ }
#else
map() = default;
map(const map&) = default;
map(map&&) = default;
~map() = default;
#endif
explicit
map(const _Compare& __comp,
const _Allocator& __a = _Allocator())
: _Base(__comp, __a) { }
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
#else
template<typename _InputIterator>
#endif
map(_InputIterator __first, _InputIterator __last,
const _Compare& __comp = _Compare(),
const _Allocator& __a = _Allocator())
: _Base(__first, __last, __comp, __a) { }
map(const _Base& __x)
: _Base(__x) { }
#if __cplusplus >= 201103L
map(initializer_list<value_type> __l,
const _Compare& __c = _Compare(),
const _Allocator& __a = _Allocator())
: _Base(__l, __c, __a) { }
explicit
map(const _Allocator& __a)
: _Base(__a) { }
map(const map& __x, const _Allocator& __a)
: _Base(__x, __a) { }
map(map&& __x, const _Allocator& __a)
noexcept( noexcept(_Base(std::move(__x), __a)) )
: _Base(std::move(__x), __a) { }
map(initializer_list<value_type> __l, const _Allocator& __a)
: _Base(__l, __a) { }
template<typename _InputIterator>
map(_InputIterator __first, _InputIterator __last,
const _Allocator& __a)
: _Base(__first, __last, __a) { }
#endif
#if __cplusplus < 201103L
map&
operator=(const map& __x)
{
this->_M_profile_destruct();
_M_base() = __x;
this->_M_profile_construct();
return *this;
}
#else
map&
operator=(const map&) = default;
map&
operator=(map&&) = default;
map&
operator=(initializer_list<value_type> __l)
{
this->_M_profile_destruct();
_M_base() = __l;
this->_M_profile_construct();
return *this;
}
#endif
// iterators
iterator
begin() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::begin(), this); }
const_iterator
begin() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::begin(), this); }
iterator
end() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::end(), this); }
const_iterator
end() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::end(), this); }
#if __cplusplus >= 201103L
const_iterator
cbegin() const noexcept
{ return const_iterator(_Base::cbegin(), this); }
const_iterator
cend() const noexcept
{ return const_iterator(_Base::cend(), this); }
#endif
reverse_iterator
rbegin() _GLIBCXX_NOEXCEPT
{
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return reverse_iterator(end());
}
const_reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT
{
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(end());
}
reverse_iterator
rend() _GLIBCXX_NOEXCEPT
{
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return reverse_iterator(begin());
}
const_reverse_iterator
rend() const _GLIBCXX_NOEXCEPT
{
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(begin());
}
#if __cplusplus >= 201103L
const_reverse_iterator
crbegin() const noexcept
{
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(cend());
}
const_reverse_iterator
crend() const noexcept
{
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(cbegin());
}
#endif
// 23.3.1.2 element access:
mapped_type&
operator[](const key_type& __k)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return _Base::operator[](__k);
}
#if __cplusplus >= 201103L
mapped_type&
operator[](key_type&& __k)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return _Base::operator[](std::move(__k));
}
#endif
mapped_type&
at(const key_type& __k)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return _Base::at(__k);
}
const mapped_type&
at(const key_type& __k) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return _Base::at(__k);
}
// modifiers:
#if __cplusplus >= 201103L
template<typename... _Args>
std::pair<iterator, bool>
emplace(_Args&&... __args)
{
// The cost is the same whether or not the element is inserted so we
// always report insertion of 1 element.
__profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
auto __base_ret = _Base::emplace(std::forward<_Args>(__args)...);
return std::make_pair(iterator(__base_ret.first, this),
__base_ret.second);
}
template<typename... _Args>
iterator
emplace_hint(const_iterator __pos, _Args&&... __args)
{
auto size_before = this->size();
auto __res
= _Base::emplace_hint(__pos.base(), std::forward<_Args>(__args)...);
__profcxx_map2umap_insert(this->_M_map2umap_info,
size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
return iterator(__res, this);
}
#endif
std::pair<iterator, bool>
insert(const value_type& __x)
{
__profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
std::pair<_Base_iterator, bool> __base_ret = _Base::insert(__x);
return std::make_pair(iterator(__base_ret.first, this),
__base_ret.second);
}
#if __cplusplus >= 201103L
template<typename _Pair, typename = typename
std::enable_if<std::is_constructible<value_type,
_Pair&&>::value>::type>
std::pair<iterator, bool>
insert(_Pair&& __x)
{
__profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
auto __base_ret= _Base::insert(std::forward<_Pair>(__x));
return std::make_pair(iterator(__base_ret.first, this),
__base_ret.second);
}
#endif
#if __cplusplus >= 201103L
void
insert(std::initializer_list<value_type> __list)
{ insert(__list.begin(), __list.end()); }
#endif
iterator
#if __cplusplus >= 201103L
insert(const_iterator __pos, const value_type& __x)
#else
insert(iterator __pos, const value_type& __x)
#endif
{
size_type size_before = this->size();
_Base_iterator __res = _Base::insert(__pos.base(), __x);
__profcxx_map2umap_insert(this->_M_map2umap_info,
size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
return iterator(__res, this);
}
#if __cplusplus >= 201103L
template<typename _Pair, typename = typename
std::enable_if<std::is_constructible<value_type,
_Pair&&>::value>::type>
iterator
insert(const_iterator __pos, _Pair&& __x)
{
size_type size_before = this->size();
auto __res = _Base::insert(__pos.base(), std::forward<_Pair>(__x));
__profcxx_map2umap_insert(this->_M_map2umap_info,
size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
return iterator(__res, this);
}
#endif
template<typename _InputIterator>
void
insert(_InputIterator __first, _InputIterator __last)
{
for (; __first != __last; ++__first)
insert(*__first);
}
#if __cplusplus >= 201103L
iterator
erase(const_iterator __pos)
{
__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
return iterator(_Base::erase(__pos.base()), this);
}
iterator
erase(iterator __pos)
{
__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
return iterator(_Base::erase(__pos.base()), this);
}
#else
void
erase(iterator __pos)
{
__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
_Base::erase(__pos.base());
}
#endif
size_type
erase(const key_type& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
return _Base::erase(__x);
}
#if __cplusplus >= 201103L
iterator
erase(const_iterator __first, const_iterator __last)
{
if (__first != __last)
{
iterator __ret;
for (; __first != __last;)
__ret = erase(__first++);
return __ret;
}
else
return iterator(_Base::erase(__first.base(), __last.base()), this);
}
#else
void
erase(iterator __first, iterator __last)
{
for (; __first != __last;)
erase(__first++);
}
#endif
void
swap(map& __x)
_GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
{
_Base::swap(__x);
this->_M_swap(__x);
}
void
clear() _GLIBCXX_NOEXCEPT
{
this->_M_profile_destruct();
_Base::clear();
this->_M_profile_construct();
}
// 23.3.1.3 map operations:
iterator
find(const key_type& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return iterator(_Base::find(__x), this);
}
#if __cplusplus > 201103L
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
iterator
find(const _Kt& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return { _Base::find(__x), this };
}
#endif
const_iterator
find(const key_type& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return const_iterator(_Base::find(__x), this);
}
#if __cplusplus > 201103L
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
const_iterator
find(const _Kt& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return { _Base::find(__x), this };
}
#endif
size_type
count(const key_type& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return _Base::count(__x);
}
#if __cplusplus > 201103L
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
size_type
count(const _Kt& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return _Base::count(__x);
}
#endif
iterator
lower_bound(const key_type& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return iterator(_Base::lower_bound(__x), this);
}
#if __cplusplus > 201103L
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
iterator
lower_bound(const _Kt& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return { _Base::lower_bound(__x), this };
}
#endif
const_iterator
lower_bound(const key_type& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_iterator(_Base::lower_bound(__x), this);
}
#if __cplusplus > 201103L
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
const_iterator
lower_bound(const _Kt& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return { _Base::lower_bound(__x), this };
}
#endif
iterator
upper_bound(const key_type& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return iterator(_Base::upper_bound(__x), this);
}
#if __cplusplus > 201103L
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
iterator
upper_bound(const _Kt& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return { _Base::upper_bound(__x), this };
}
#endif
const_iterator
upper_bound(const key_type& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_iterator(_Base::upper_bound(__x), this);
}
#if __cplusplus > 201103L
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
const_iterator
upper_bound(const _Kt& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return { _Base::upper_bound(__x), this };
}
#endif
std::pair<iterator,iterator>
equal_range(const key_type& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
std::pair<_Base_iterator, _Base_iterator> __base_ret
= _Base::equal_range(__x);
return std::make_pair(iterator(__base_ret.first, this),
iterator(__base_ret.second, this));
}
#if __cplusplus > 201103L
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
std::pair<iterator, iterator>
equal_range(const _Kt& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
auto __res = _Base::equal_range(__x);
return { { __res.first, this }, { __res.second, this } };
}
#endif
std::pair<const_iterator,const_iterator>
equal_range(const key_type& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
std::pair<_Base_const_iterator, _Base_const_iterator> __base_ret
= _Base::equal_range(__x);
return std::make_pair(const_iterator(__base_ret.first, this),
const_iterator(__base_ret.second, this));
}
#if __cplusplus > 201103L
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
std::pair<const_iterator, const_iterator>
equal_range(const _Kt& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
auto __res = _Base::equal_range(__x);
return { { __res.first, this }, { __res.second, this } };
}
#endif
_Base&
_M_base() _GLIBCXX_NOEXCEPT { return *this; }
const _Base&
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
private:
/** If hint is used we consider that the map and unordered_map
* operations have equivalent insertion cost so we do not update metrics
* about it.
* Note that to find out if hint has been used is libstdc++
* implementation dependent.
*/
bool
_M_hint_used(_Base_const_iterator __hint, _Base_iterator __res)
{
return (__hint == __res
|| (__hint == _M_base().end() && ++__res == _M_base().end())
|| (__hint != _M_base().end() && (++__hint == __res
|| ++__res == --__hint)));
}
template<typename _K1, typename _T1, typename _C1, typename _A1>
friend bool
operator==(const map<_K1, _T1, _C1, _A1>&,
const map<_K1, _T1, _C1, _A1>&);
template<typename _K1, typename _T1, typename _C1, typename _A1>
friend bool
operator<(const map<_K1, _T1, _C1, _A1>&,
const map<_K1, _T1, _C1, _A1>&);
};
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>
inline bool
operator==(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
{
__profcxx_map2umap_invalidate(__lhs._M_map2umap_info);
__profcxx_map2umap_invalidate(__rhs._M_map2umap_info);
return __lhs._M_base() == __rhs._M_base();
}
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>
inline bool
operator<(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
{
__profcxx_map2umap_invalidate(__lhs._M_map2umap_info);
__profcxx_map2umap_invalidate(__rhs._M_map2umap_info);
return __lhs._M_base() < __rhs._M_base();
}
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>
inline bool
operator!=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
{ return !(__lhs == __rhs); }
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>
inline bool
operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
{ return !(__rhs < __lhs); }
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>
inline bool
operator>=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
{ return !(__lhs < __rhs); }
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>
inline bool
operator>(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
{ return __rhs < __lhs; }
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>
inline void
swap(map<_Key, _Tp, _Compare, _Allocator>& __lhs,
map<_Key, _Tp, _Compare, _Allocator>& __rhs)
_GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
{ __lhs.swap(__rhs); }
} // namespace __profile
} // namespace std
#endif
c++/8/profile/vector 0000644 00000037012 15201526705 0010156 0 ustar 00 // Profiling vector implementation -*- C++ -*-
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
/** @file profile/vector
* This file is a GNU profile extension to the Standard C++ Library.
*/
#ifndef _GLIBCXX_PROFILE_VECTOR
#define _GLIBCXX_PROFILE_VECTOR 1
#include <vector>
#include <utility>
#include <profile/base.h>
#include <profile/iterator_tracker.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __profile
{
template<typename _Vector>
class _Vector_profile_pre
{
_Vector&
_M_conjure()
{ return *static_cast<_Vector*>(this); }
public:
#if __cplusplus >= 201103L
_Vector_profile_pre() = default;
_Vector_profile_pre(const _Vector_profile_pre&) = default;
_Vector_profile_pre(_Vector_profile_pre&&) = default;
_Vector_profile_pre&
operator=(const _Vector_profile_pre&)
{ _M_conjure()._M_profile_destruct(); }
_Vector_profile_pre&
operator=(_Vector_profile_pre&&) noexcept
{ _M_conjure()._M_profile_destruct(); }
#endif
};
template<typename _Vector>
class _Vector_profile_post
{
_Vector&
_M_conjure()
{ return *static_cast<_Vector*>(this); }
protected:
__gnu_profile::__container_size_info* _M_size_info;
__gnu_profile::__vector2list_info* _M_vect2list_info;
_Vector_profile_post() _GLIBCXX_NOEXCEPT
{ _M_profile_construct(); }
#if __cplusplus >= 201103L
_Vector_profile_post(const _Vector_profile_post&) noexcept
: _Vector_profile_post() { }
_Vector_profile_post(_Vector_profile_post&& __other) noexcept
: _Vector_profile_post()
{ _M_swap(__other); }
_Vector_profile_post&
operator=(const _Vector_profile_post&) noexcept
{ _M_profile_construct(); }
_Vector_profile_post&
operator=(_Vector_profile_post&& __other) noexcept
{
_M_swap(__other);
__other._M_profile_construct();
}
#endif
~_Vector_profile_post()
{ _M_conjure()._M_profile_destruct(); }
public:
void
_M_profile_construct() _GLIBCXX_NOEXCEPT
{
_M_size_info =
__profcxx_vector_size_construct(_M_conjure().capacity());
_M_vect2list_info = __profcxx_vector2list_construct();
}
void
_M_profile_destruct() _GLIBCXX_NOEXCEPT
{
__profcxx_vector2list_destruct(_M_vect2list_info);
_M_vect2list_info = 0;
__profcxx_vector_size_destruct(_M_size_info,
_M_conjure().capacity(),
_M_conjure().size());
_M_size_info = 0;
}
void
_M_swap(_Vector_profile_post& __other) _GLIBCXX_NOEXCEPT
{
std::swap(_M_size_info, __other._M_size_info);
std::swap(_M_vect2list_info, __other._M_vect2list_info);
}
};
template<typename _Tp,
typename _Allocator = std::allocator<_Tp> >
class vector
: public _Vector_profile_pre<vector<_Tp, _Allocator> >,
public _GLIBCXX_STD_C::vector<_Tp, _Allocator>,
public _Vector_profile_post<vector<_Tp, _Allocator> >
{
typedef _GLIBCXX_STD_C::vector<_Tp, _Allocator> _Base;
typedef typename _Base::iterator _Base_iterator;
typedef typename _Base::const_iterator _Base_const_iterator;
public:
typedef typename _Base::reference reference;
typedef typename _Base::const_reference const_reference;
typedef __iterator_tracker<_Base_iterator, vector>
iterator;
typedef __iterator_tracker<_Base_const_iterator, vector>
const_iterator;
typedef typename _Base::size_type size_type;
typedef typename _Base::difference_type difference_type;
typedef _Tp value_type;
typedef _Allocator allocator_type;
typedef typename _Base::pointer pointer;
typedef typename _Base::const_pointer const_pointer;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
_Base&
_M_base() _GLIBCXX_NOEXCEPT { return *this; }
const _Base&
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
// 23.2.4.1 construct/copy/destroy:
#if __cplusplus < 201103L
vector()
{ }
vector(const vector& __x)
: _Base(__x) { }
#else
vector() = default;
vector(const vector&) = default;
vector(vector&&) = default;
#endif
explicit
vector(const _Allocator& __a) _GLIBCXX_NOEXCEPT
: _Base(__a) { }
#if __cplusplus >= 201103L
explicit
vector(size_type __n, const _Allocator& __a = _Allocator())
: _Base(__n, __a) { }
vector(size_type __n, const _Tp& __value,
const _Allocator& __a = _Allocator())
: _Base(__n, __value, __a) { }
#else
explicit
vector(size_type __n, const _Tp& __value = _Tp(),
const _Allocator& __a = _Allocator())
: _Base(__n, __value, __a) { }
#endif
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
#else
template<typename _InputIterator>
#endif
vector(_InputIterator __first, _InputIterator __last,
const _Allocator& __a = _Allocator())
: _Base(__first, __last, __a) { }
/// Construction from a normal-mode vector
vector(const _Base& __x)
: _Base(__x) { }
#if __cplusplus >= 201103L
vector(const _Base& __x, const _Allocator& __a)
: _Base(__x, __a) { }
vector(vector&& __x, const _Allocator& __a)
: _Base(std::move(__x), __a) { }
vector(initializer_list<value_type> __l,
const allocator_type& __a = allocator_type())
: _Base(__l, __a) { }
#endif
#if __cplusplus < 201103L
vector&
operator=(const vector& __x)
{
this->_M_profile_destruct();
_M_base() = __x;
this->_M_profile_construct();
return *this;
}
#else
vector&
operator=(const vector&) = default;
vector&
operator=(vector&&) = default;
vector&
operator=(initializer_list<value_type> __l)
{
this->_M_profile_destruct();
_M_base() = __l;
this->_M_profile_construct();
return *this;
}
#endif
// iterators:
iterator
begin() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::begin(), this); }
const_iterator
begin() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::begin(), this); }
iterator
end() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::end(), this); }
const_iterator
end() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::end(), this); }
reverse_iterator
rbegin() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(end()); }
const_reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(end()); }
reverse_iterator
rend() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(begin()); }
const_reverse_iterator
rend() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(begin()); }
#if __cplusplus >= 201103L
const_iterator
cbegin() const noexcept
{ return const_iterator(_Base::begin(), this); }
const_iterator
cend() const noexcept
{ return const_iterator(_Base::end(), this); }
const_reverse_iterator
crbegin() const noexcept
{ return const_reverse_iterator(end()); }
const_reverse_iterator
crend() const noexcept
{ return const_reverse_iterator(begin()); }
#endif
// 23.2.4.2 capacity:
#if __cplusplus >= 201103L
void
resize(size_type __sz)
{
__profcxx_vector2list_invalid_operator(this->_M_vect2list_info);
_M_profile_resize(this->capacity(), __sz);
_Base::resize(__sz);
}
void
resize(size_type __sz, const _Tp& __c)
{
__profcxx_vector2list_invalid_operator(this->_M_vect2list_info);
_M_profile_resize(this->capacity(), __sz);
_Base::resize(__sz, __c);
}
#else
void
resize(size_type __sz, _Tp __c = _Tp())
{
__profcxx_vector2list_invalid_operator(this->_M_vect2list_info);
_M_profile_resize(this->capacity(), __sz);
_Base::resize(__sz, __c);
}
#endif
// element access:
reference
operator[](size_type __n) _GLIBCXX_NOEXCEPT
{
__profcxx_vector2list_invalid_operator(this->_M_vect2list_info);
return _M_base()[__n];
}
const_reference
operator[](size_type __n) const _GLIBCXX_NOEXCEPT
{
__profcxx_vector2list_invalid_operator(this->_M_vect2list_info);
return _M_base()[__n];
}
// 23.2.4.3 modifiers:
void
push_back(const _Tp& __x)
{
size_type __old_size = this->capacity();
_Base::push_back(__x);
_M_profile_resize(__old_size, this->capacity());
}
#if __cplusplus >= 201103L
void
push_back(_Tp&& __x)
{
size_type __old_size = this->capacity();
_Base::push_back(std::move(__x));
_M_profile_resize(__old_size, this->capacity());
}
#endif
iterator
#if __cplusplus >= 201103L
insert(const_iterator __pos, const _Tp& __x)
#else
insert(iterator __pos, const _Tp& __x)
#endif
{
__profcxx_vector2list_insert(this->_M_vect2list_info,
__pos.base() - _Base::begin(),
this->size());
size_type __old_size = this->capacity();
_Base_iterator __res = _Base::insert(__pos.base(), __x);
_M_profile_resize(__old_size, this->capacity());
return iterator(__res, this);
}
#if __cplusplus >= 201103L
iterator
insert(const_iterator __pos, _Tp&& __x)
{
__profcxx_vector2list_insert(this->_M_vect2list_info,
__pos.base() - _Base::cbegin(),
this->size());
size_type __old_size = this->capacity();
_Base_iterator __res = _Base::insert(__pos.base(), __x);
_M_profile_resize(__old_size, this->capacity());
return iterator(__res, this);
}
template<typename... _Args>
iterator
emplace(const_iterator __pos, _Args&&... __args)
{
_Base_iterator __res = _Base::emplace(__pos.base(),
std::forward<_Args>(__args)...);
return iterator(__res, this);
}
iterator
insert(const_iterator __pos, initializer_list<value_type> __l)
{ return this->insert(__pos, __l.begin(), __l.end()); }
#endif
void
swap(vector& __x)
#if __cplusplus >= 201103L
noexcept( noexcept(declval<_Base>().swap(__x)) )
#endif
{
_Base::swap(__x);
this->_M_swap(__x);
}
#if __cplusplus >= 201103L
iterator
insert(const_iterator __pos, size_type __n, const _Tp& __x)
{
__profcxx_vector2list_insert(this->_M_vect2list_info,
__pos.base() - _Base::cbegin(),
this->size());
size_type __old_size = this->capacity();
_Base_iterator __res = _Base::insert(__pos, __n, __x);
_M_profile_resize(__old_size, this->capacity());
return iterator(__res, this);
}
#else
void
insert(iterator __pos, size_type __n, const _Tp& __x)
{
__profcxx_vector2list_insert(this->_M_vect2list_info,
__pos.base() - _Base::begin(),
this->size());
size_type __old_size = this->capacity();
_Base::insert(__pos, __n, __x);
_M_profile_resize(__old_size, this->capacity());
}
#endif
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
iterator
insert(const_iterator __pos,
_InputIterator __first, _InputIterator __last)
{
__profcxx_vector2list_insert(this->_M_vect2list_info,
__pos.base() - _Base::cbegin(),
this->size());
size_type __old_size = this->capacity();
_Base_iterator __res = _Base::insert(__pos, __first, __last);
_M_profile_resize(__old_size, this->capacity());
return iterator(__res, this);
}
#else
template<typename _InputIterator>
void
insert(iterator __pos,
_InputIterator __first, _InputIterator __last)
{
__profcxx_vector2list_insert(this->_M_vect2list_info,
__pos.base() - _Base::begin(),
this->size());
size_type __old_size = this->capacity();
_Base::insert(__pos, __first, __last);
_M_profile_resize(__old_size, this->capacity());
}
#endif
iterator
#if __cplusplus >= 201103L
erase(const_iterator __pos)
#else
erase(iterator __pos)
#endif
{ return iterator(_Base::erase(__pos.base()), this); }
iterator
#if __cplusplus >= 201103L
erase(const_iterator __first, const_iterator __last)
#else
erase(iterator __first, iterator __last)
#endif
{ return iterator(_Base::erase(__first.base(), __last.base()), this); }
void
clear() _GLIBCXX_NOEXCEPT
{
this->_M_profile_destruct();
_Base::clear();
this->_M_profile_construct();
}
inline void
_M_profile_iterate(int __rewind = 0) const
{ __profcxx_vector2list_iterate(this->_M_vect2list_info, __rewind); }
private:
void _M_profile_resize(size_type __old_size, size_type __new_size)
{
if (__old_size < __new_size)
{
__profcxx_vector_size_resize(this->_M_size_info,
this->size(), __new_size);
__profcxx_vector2list_resize(this->_M_vect2list_info,
this->size(), __new_size);
}
}
};
template<typename _Tp, typename _Alloc>
inline bool
operator==(const vector<_Tp, _Alloc>& __lhs,
const vector<_Tp, _Alloc>& __rhs)
{ return __lhs._M_base() == __rhs._M_base(); }
template<typename _Tp, typename _Alloc>
inline bool
operator!=(const vector<_Tp, _Alloc>& __lhs,
const vector<_Tp, _Alloc>& __rhs)
{ return __lhs._M_base() != __rhs._M_base(); }
template<typename _Tp, typename _Alloc>
inline bool
operator<(const vector<_Tp, _Alloc>& __lhs,
const vector<_Tp, _Alloc>& __rhs)
{ return __lhs._M_base() < __rhs._M_base(); }
template<typename _Tp, typename _Alloc>
inline bool
operator<=(const vector<_Tp, _Alloc>& __lhs,
const vector<_Tp, _Alloc>& __rhs)
{ return __lhs._M_base() <= __rhs._M_base(); }
template<typename _Tp, typename _Alloc>
inline bool
operator>=(const vector<_Tp, _Alloc>& __lhs,
const vector<_Tp, _Alloc>& __rhs)
{ return __lhs._M_base() >= __rhs._M_base(); }
template<typename _Tp, typename _Alloc>
inline bool
operator>(const vector<_Tp, _Alloc>& __lhs,
const vector<_Tp, _Alloc>& __rhs)
{ return __lhs._M_base() > __rhs._M_base(); }
template<typename _Tp, typename _Alloc>
inline void
swap(vector<_Tp, _Alloc>& __lhs, vector<_Tp, _Alloc>& __rhs)
_GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
{ __lhs.swap(__rhs); }
} // namespace __profile
#if __cplusplus >= 201103L
// DR 1182.
/// std::hash specialization for vector<bool>.
template<typename _Alloc>
struct hash<__profile::vector<bool, _Alloc>>
: public __hash_base<size_t, __profile::vector<bool, _Alloc>>
{
size_t
operator()(const __profile::vector<bool, _Alloc>& __b) const noexcept
{
return std::hash<_GLIBCXX_STD_C::vector<bool, _Alloc>>()(__b._M_base());
}
};
#endif
} // namespace std
#endif
c++/8/profile/impl/profiler_list_to_slist.h 0000644 00000010526 15201526705 0014641 0 ustar 00 // -*- C++ -*-
//
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
/** @file profile/impl/profiler_list_to_slist.h
* @brief Diagnostics for list to slist.
*/
// Written by Changhee Jung.
#ifndef _GLIBCXX_PROFILE_PROFILER_LIST_TO_SLIST_H
#define _GLIBCXX_PROFILE_PROFILER_LIST_TO_SLIST_H 1
#include "profile/impl/profiler.h"
#include "profile/impl/profiler_node.h"
#include "profile/impl/profiler_trace.h"
namespace __gnu_profile
{
class __list2slist_info
: public __object_info_base
{
public:
__list2slist_info(__stack_t __stack)
: __object_info_base(__stack), _M_rewind(false), _M_operations(0) { }
// XXX: the magnitude should be multiplied with a constant factor F,
// where F is 1 when the malloc size class of list nodes is different
// from the malloc size class of slist nodes. When they fall into the same
// class, the only slist benefit is from having to set fewer links, so
// the factor F should be much smaller, closer to 0 than to 1.
// This could be implemented by passing the size classes in the config
// file. For now, we always assume F to be 1.
float
__magnitude() const
{
if (!_M_rewind)
return _M_operations;
else
return 0;
}
void
__write(FILE* __f) const
{ std::fprintf(__f, "%s\n", _M_rewind ? "invalid" : "valid"); }
std::string
__advice() const
{ return "change std::list to std::forward_list"; }
void
__opr_rewind()
{
_M_rewind = true;
__set_invalid();
}
void
__record_operation()
{ ++_M_operations; }
bool
__has_rewind()
{ return _M_rewind; }
private:
bool _M_rewind;
std::size_t _M_operations;
};
class __list2slist_stack_info
: public __list2slist_info
{
public:
__list2slist_stack_info(const __list2slist_info& __o)
: __list2slist_info(__o) { }
};
class __trace_list_to_slist
: public __trace_base<__list2slist_info, __list2slist_stack_info>
{
public:
~__trace_list_to_slist() { }
__trace_list_to_slist()
: __trace_base<__list2slist_info, __list2slist_stack_info>()
{ __id = "list-to-slist"; }
void
__destruct(__list2slist_info* __obj_info)
{ __retire_object(__obj_info); }
};
inline void
__trace_list_to_slist_init()
{ _GLIBCXX_PROFILE_DATA(_S_list_to_slist) = new __trace_list_to_slist(); }
inline void
__trace_list_to_slist_free()
{ delete _GLIBCXX_PROFILE_DATA(_S_list_to_slist); }
inline void
__trace_list_to_slist_report(FILE* __f, __warning_vector_t& __warnings)
{ __trace_report(_GLIBCXX_PROFILE_DATA(_S_list_to_slist), __f, __warnings); }
inline __list2slist_info*
__trace_list_to_slist_construct()
{
if (!__profcxx_init())
return 0;
if (!__reentrance_guard::__get_in())
return 0;
__reentrance_guard __get_out;
return _GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__add_object(__get_stack());
}
inline void
__trace_list_to_slist_rewind(__list2slist_info* __obj_info)
{
if (!__obj_info)
return;
__obj_info->__opr_rewind();
}
inline void
__trace_list_to_slist_operation(__list2slist_info* __obj_info)
{
if (!__obj_info)
return;
__obj_info->__record_operation();
}
inline void
__trace_list_to_slist_destruct(__list2slist_info* __obj_info)
{
if (!__obj_info)
return;
_GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__destruct(__obj_info);
}
} // namespace __gnu_profile
#endif /* _GLIBCXX_PROFILE_PROFILER_LIST_TO_SLIST_H */
c++/8/profile/impl/profiler_list_to_vector.h 0000644 00000015273 15201526705 0015011 0 ustar 00 // -*- C++ -*-
//
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
/** @file profile/impl/profiler_list_to_vector.h
* @brief diagnostics for list to vector.
*/
// Written by Changhee Jung.
#ifndef _GLIBCXX_PROFILE_PROFILER_LIST_TO_VECTOR_H
#define _GLIBCXX_PROFILE_PROFILER_LIST_TO_VECTOR_H 1
#include <sstream>
#include "profile/impl/profiler.h"
#include "profile/impl/profiler_node.h"
#include "profile/impl/profiler_trace.h"
namespace __gnu_profile
{
/** @brief A list-to-vector instrumentation line in the object table. */
class __list2vector_info
: public __object_info_base
{
public:
__list2vector_info(__stack_t __stack)
: __object_info_base(__stack), _M_shift_count(0), _M_iterate(0),
_M_resize(0), _M_list_cost(0), _M_vector_cost(0),
_M_max_size(0) { }
void
__merge(const __list2vector_info& __o)
{
__object_info_base::__merge(__o);
_M_shift_count += __o._M_shift_count;
_M_iterate += __o._M_iterate;
_M_vector_cost += __o._M_vector_cost;
_M_list_cost += __o._M_list_cost;
_M_resize += __o._M_resize;
_M_max_size = std::max( _M_max_size, __o._M_max_size);
}
void
__write(FILE* __f) const
{
std::fprintf(__f, "%Zu %Zu %Zu %.0f %.0f\n", _M_shift_count,
_M_resize, _M_iterate, _M_vector_cost, _M_list_cost);
}
float
__magnitude() const
{ return _M_list_cost - _M_vector_cost; }
std::string
__advice() const
{
std::stringstream __sstream;
__sstream
<< "change std::list to std::vector and its initial size from 0 to "
<< _M_max_size;
return __sstream.str();
}
std::size_t
__shift_count()
{ return _M_shift_count; }
std::size_t
__iterate()
{ return _M_iterate; }
float
__list_cost()
{ return _M_list_cost; }
std::size_t
__resize()
{ return _M_resize; }
void
__set_list_cost(float __lc)
{ _M_list_cost = __lc; }
void
__set_vector_cost(float __vc)
{ _M_vector_cost = __vc; }
void
__opr_insert(std::size_t __shift, std::size_t __size)
{
_M_shift_count += __shift;
_M_max_size = std::max(_M_max_size, __size);
}
void
__opr_iterate(int __num)
{ __gnu_cxx::__atomic_add(&_M_iterate, __num); }
void
__resize(std::size_t __from, std::size_t)
{ _M_resize += __from; }
private:
std::size_t _M_shift_count;
mutable _Atomic_word _M_iterate;
std::size_t _M_resize;
float _M_list_cost;
float _M_vector_cost;
std::size_t _M_max_size;
};
class __list2vector_stack_info
: public __list2vector_info
{
public:
__list2vector_stack_info(const __list2vector_info& __o)
: __list2vector_info(__o) {}
};
class __trace_list_to_vector
: public __trace_base<__list2vector_info, __list2vector_stack_info>
{
public:
__trace_list_to_vector()
: __trace_base<__list2vector_info, __list2vector_stack_info>()
{ __id = "list-to-vector"; }
~__trace_list_to_vector() { }
// Call at destruction/clean to set container final size.
void
__destruct(__list2vector_info* __obj_info)
{
float __vc = __vector_cost(__obj_info->__shift_count(),
__obj_info->__iterate());
float __lc = __list_cost(__obj_info->__shift_count(),
__obj_info->__iterate());
__obj_info->__set_vector_cost(__vc);
__obj_info->__set_list_cost(__lc);
__retire_object(__obj_info);
}
// Collect cost of operations.
float
__vector_cost(std::size_t __shift, std::size_t __iterate)
{
// The resulting vector will use a 'reserve' method.
return (__shift
* _GLIBCXX_PROFILE_DATA(__vector_shift_cost_factor).__value
+ __iterate
* _GLIBCXX_PROFILE_DATA(__vector_iterate_cost_factor).__value);
}
float
__list_cost(std::size_t __shift, std::size_t __iterate)
{
return (__shift
* _GLIBCXX_PROFILE_DATA(__list_shift_cost_factor).__value
+ __iterate
* _GLIBCXX_PROFILE_DATA(__list_iterate_cost_factor).__value);
}
};
inline void
__trace_list_to_vector_init()
{ _GLIBCXX_PROFILE_DATA(_S_list_to_vector) = new __trace_list_to_vector(); }
inline void
__trace_list_to_vector_free()
{ delete _GLIBCXX_PROFILE_DATA(_S_list_to_vector); }
inline void
__trace_list_to_vector_report(FILE* __f, __warning_vector_t& __warnings)
{ __trace_report(_GLIBCXX_PROFILE_DATA(_S_list_to_vector), __f, __warnings); }
inline __list2vector_info*
__trace_list_to_vector_construct()
{
if (!__profcxx_init())
return 0;
if (!__reentrance_guard::__get_in())
return 0;
__reentrance_guard __get_out;
return _GLIBCXX_PROFILE_DATA(_S_list_to_vector)
->__add_object(__get_stack());
}
inline void
__trace_list_to_vector_insert(__list2vector_info* __obj_info,
std::size_t __shift, std::size_t __size)
{
if (!__obj_info)
return;
__obj_info->__opr_insert(__shift, __size);
}
inline void
__trace_list_to_vector_iterate(__list2vector_info* __obj_info,
int)
{
if (!__obj_info)
return;
// We only collect if an iteration took place no matter in what side.
__obj_info->__opr_iterate(1);
}
inline void
__trace_list_to_vector_invalid_operator(__list2vector_info* __obj_info)
{
if (!__obj_info)
return;
__obj_info->__set_invalid();
}
inline void
__trace_list_to_vector_resize(__list2vector_info* __obj_info,
std::size_t __from, std::size_t __to)
{
if (!__obj_info)
return;
__obj_info->__resize(__from, __to);
}
inline void
__trace_list_to_vector_destruct(__list2vector_info* __obj_info)
{
if (!__obj_info)
return;
_GLIBCXX_PROFILE_DATA(_S_list_to_vector)->__destruct(__obj_info);
}
} // namespace __gnu_profile
#endif /* _GLIBCXX_PROFILE_PROFILER_LIST_TO_VECTOR_H__ */
c++/8/profile/impl/profiler_hash_func.h 0000644 00000010474 15201526705 0013706 0 ustar 00 // -*- C++ -*-
//
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
/** @file profile/impl/profiler_hash_func.h
* @brief Data structures to represent profiling traces.
*/
// Written by Lixia Liu and Silvius Rus.
#ifndef _GLIBCXX_PROFILE_PROFILER_HASH_FUNC_H
#define _GLIBCXX_PROFILE_PROFILER_HASH_FUNC_H 1
#include "profile/impl/profiler.h"
#include "profile/impl/profiler_node.h"
#include "profile/impl/profiler_trace.h"
namespace __gnu_profile
{
/** @brief A hash performance instrumentation line in the object table. */
class __hashfunc_info
: public __object_info_base
{
public:
__hashfunc_info(__stack_t __stack)
: __object_info_base(__stack), _M_longest_chain(0),
_M_accesses(0), _M_hops(0) { }
void
__merge(const __hashfunc_info& __o)
{
__object_info_base::__merge(__o);
_M_longest_chain = std::max(_M_longest_chain, __o._M_longest_chain);
_M_accesses += __o._M_accesses;
_M_hops += __o._M_hops;
}
void
__destruct(std::size_t __chain, std::size_t __accesses,
std::size_t __hops)
{
_M_longest_chain = std::max(_M_longest_chain, __chain);
_M_accesses += __accesses;
_M_hops += __hops;
}
void
__write(FILE* __f) const
{ std::fprintf(__f, "%Zu %Zu %Zu\n", _M_hops,
_M_accesses, _M_longest_chain); }
float
__magnitude() const
{ return static_cast<float>(_M_hops); }
std::string
__advice() const
{ return "change hash function"; }
private:
std::size_t _M_longest_chain;
std::size_t _M_accesses;
std::size_t _M_hops;
};
/** @brief A hash performance instrumentation line in the stack table. */
class __hashfunc_stack_info
: public __hashfunc_info
{
public:
__hashfunc_stack_info(const __hashfunc_info& __o)
: __hashfunc_info(__o) { }
};
/** @brief Hash performance instrumentation producer. */
class __trace_hash_func
: public __trace_base<__hashfunc_info, __hashfunc_stack_info>
{
public:
__trace_hash_func()
: __trace_base<__hashfunc_info, __hashfunc_stack_info>()
{ __id = "hash-distr"; }
~__trace_hash_func() {}
// Call at destruction/clean to set container final size.
void
__destruct(__hashfunc_info* __obj_info,
std::size_t __chain, std::size_t __accesses, std::size_t __hops)
{
if (!__obj_info)
return;
__obj_info->__destruct(__chain, __accesses, __hops);
__retire_object(__obj_info);
}
};
inline void
__trace_hash_func_init()
{ _GLIBCXX_PROFILE_DATA(_S_hash_func) = new __trace_hash_func(); }
inline void
__trace_hash_func_free()
{ delete _GLIBCXX_PROFILE_DATA(_S_hash_func); }
inline void
__trace_hash_func_report(FILE* __f, __warning_vector_t& __warnings)
{ __trace_report(_GLIBCXX_PROFILE_DATA(_S_hash_func), __f, __warnings); }
inline __hashfunc_info*
__trace_hash_func_construct()
{
if (!__profcxx_init())
return 0;
if (!__reentrance_guard::__get_in())
return 0;
__reentrance_guard __get_out;
return _GLIBCXX_PROFILE_DATA(_S_hash_func)->__add_object(__get_stack());
}
inline void
__trace_hash_func_destruct(__hashfunc_info* __obj_info,
std::size_t __chain, std::size_t __accesses,
std::size_t __hops)
{
_GLIBCXX_PROFILE_DATA(_S_hash_func)->__destruct(__obj_info, __chain,
__accesses, __hops);
}
} // namespace __gnu_profile
#endif /* _GLIBCXX_PROFILE_PROFILER_HASH_FUNC_H */
c++/8/profile/impl/profiler.h 0000644 00000033144 15201526705 0011667 0 ustar 00 // -*- C++ -*-
//
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
/** @file profile/impl/profiler.h
* @brief Interface of the profiling runtime library.
*/
// Written by Lixia Liu and Silvius Rus.
#ifndef _GLIBCXX_PROFILE_PROFILER_H
#define _GLIBCXX_PROFILE_PROFILER_H 1
#include <bits/c++config.h>
// Mechanism to define data with inline linkage.
#define _GLIBCXX_PROFILE_DEFINE_UNINIT_DATA(__type, __name) \
inline __type& \
__get_##__name() \
{ \
static __type __name; \
return __name; \
}
#define _GLIBCXX_PROFILE_DEFINE_DATA(__type, __name, __initial_value...) \
inline __type& __get_##__name() { \
static __type __name(__initial_value); \
return __name; \
}
#define _GLIBCXX_PROFILE_DATA(__name) \
__get_##__name()
namespace __gnu_profile
{
/** @brief Reentrance guard.
*
* Mechanism to protect all __gnu_profile operations against recursion,
* multithreaded and exception reentrance.
*/
struct __reentrance_guard
{
static bool
__get_in()
{
if (__inside() == true)
return false;
else
{
__inside() = true;
return true;
}
}
static bool&
__inside()
{
static __thread bool _S_inside(false);
return _S_inside;
}
__reentrance_guard() { }
~__reentrance_guard() { __inside() = false; }
};
// Forward declarations of implementation functions.
// Don't use any __gnu_profile:: in user code.
// Instead, use the __profcxx... macros, which offer guarded access.
class __container_size_info;
class __hashfunc_info;
class __map2umap_info;
class __vector2list_info;
class __list2slist_info;
class __list2vector_info;
bool __turn_on();
bool __turn_off();
bool __is_invalid();
bool __is_on();
bool __is_off();
void __report();
__container_size_info*
__trace_hashtable_size_construct(std::size_t);
void __trace_hashtable_size_resize(__container_size_info*,
std::size_t, std::size_t);
void __trace_hashtable_size_destruct(__container_size_info*,
std::size_t, std::size_t);
__hashfunc_info*
__trace_hash_func_construct();
void __trace_hash_func_destruct(__hashfunc_info*,
std::size_t, std::size_t, std::size_t);
__container_size_info*
__trace_vector_size_construct(std::size_t);
void __trace_vector_size_resize(__container_size_info*,
std::size_t, std::size_t);
void __trace_vector_size_destruct(__container_size_info*,
std::size_t, std::size_t);
__vector2list_info*
__trace_vector_to_list_construct();
void __trace_vector_to_list_insert(__vector2list_info*,
std::size_t, std::size_t);
void __trace_vector_to_list_iterate(__vector2list_info*, int);
void __trace_vector_to_list_invalid_operator(__vector2list_info*);
void __trace_vector_to_list_resize(__vector2list_info*,
std::size_t, std::size_t);
void __trace_vector_to_list_destruct(__vector2list_info*);
__list2slist_info*
__trace_list_to_slist_construct();
void __trace_list_to_slist_rewind(__list2slist_info*);
void __trace_list_to_slist_operation(__list2slist_info*);
void __trace_list_to_slist_destruct(__list2slist_info*);
__list2vector_info*
__trace_list_to_vector_construct();
void __trace_list_to_vector_insert(__list2vector_info*,
std::size_t, std::size_t);
void __trace_list_to_vector_iterate(__list2vector_info*, int);
void __trace_list_to_vector_invalid_operator(__list2vector_info*);
void __trace_list_to_vector_resize(__list2vector_info*,
std::size_t, std::size_t);
void __trace_list_to_vector_destruct(__list2vector_info*);
__map2umap_info*
__trace_map_to_unordered_map_construct();
void __trace_map_to_unordered_map_invalidate(__map2umap_info*);
void __trace_map_to_unordered_map_insert(__map2umap_info*, std::size_t,
std::size_t);
void __trace_map_to_unordered_map_erase(__map2umap_info*, std::size_t,
std::size_t);
void __trace_map_to_unordered_map_iterate(__map2umap_info*, std::size_t);
void __trace_map_to_unordered_map_find(__map2umap_info*, std::size_t);
void __trace_map_to_unordered_map_destruct(__map2umap_info*);
} // namespace __gnu_profile
// Master switch turns on all diagnostics that are not explicitly turned off.
#ifdef _GLIBCXX_PROFILE
#ifndef _GLIBCXX_PROFILE_NO_HASHTABLE_TOO_SMALL
#define _GLIBCXX_PROFILE_HASHTABLE_TOO_SMALL
#endif
#ifndef _GLIBCXX_PROFILE_NO_HASHTABLE_TOO_LARGE
#define _GLIBCXX_PROFILE_HASHTABLE_TOO_LARGE
#endif
#ifndef _GLIBCXX_PROFILE_NO_VECTOR_TOO_SMALL
#define _GLIBCXX_PROFILE_VECTOR_TOO_SMALL
#endif
#ifndef _GLIBCXX_PROFILE_NO_VECTOR_TOO_LARGE
#define _GLIBCXX_PROFILE_VECTOR_TOO_LARGE
#endif
#ifndef _GLIBCXX_PROFILE_NO_INEFFICIENT_HASH
#define _GLIBCXX_PROFILE_INEFFICIENT_HASH
#endif
#ifndef _GLIBCXX_PROFILE_NO_VECTOR_TO_LIST
#define _GLIBCXX_PROFILE_VECTOR_TO_LIST
#endif
#ifndef _GLIBCXX_PROFILE_NO_LIST_TO_SLIST
#define _GLIBCXX_PROFILE_LIST_TO_SLIST
#endif
#ifndef _GLIBCXX_PROFILE_NO_LIST_TO_VECTOR
#define _GLIBCXX_PROFILE_LIST_TO_VECTOR
#endif
#ifndef _GLIBCXX_PROFILE_NO_MAP_TO_UNORDERED_MAP
#define _GLIBCXX_PROFILE_MAP_TO_UNORDERED_MAP
#endif
#endif
// Expose global management routines to user code.
#ifdef _GLIBCXX_PROFILE
#define __profcxx_report() __gnu_profile::__report()
#define __profcxx_turn_on() __gnu_profile::__turn_on()
#define __profcxx_turn_off() __gnu_profile::__turn_off()
#define __profcxx_is_invalid() __gnu_profile::__is_invalid()
#define __profcxx_is_on() __gnu_profile::__is_on()
#define __profcxx_is_off() __gnu_profile::__is_off()
#else
#define __profcxx_report()
#define __profcxx_turn_on()
#define __profcxx_turn_off()
#define __profcxx_is_invalid()
#define __profcxx_is_on()
#define __profcxx_is_off()
#endif
// Turn on/off instrumentation for HASHTABLE_TOO_SMALL and HASHTABLE_TOO_LARGE.
#if (defined(_GLIBCXX_PROFILE_HASHTABLE_TOO_SMALL) \
|| defined(_GLIBCXX_PROFILE_HASHTABLE_TOO_LARGE))
#define __profcxx_hashtable_size_construct(__x...) \
__gnu_profile::__trace_hashtable_size_construct(__x)
#define __profcxx_hashtable_size_resize(__x...) \
__gnu_profile::__trace_hashtable_size_resize(__x)
#define __profcxx_hashtable_size_destruct(__x...) \
__gnu_profile::__trace_hashtable_size_destruct(__x)
#else
#define __profcxx_hashtable_size_construct(__x...) 0
#define __profcxx_hashtable_size_resize(__x...)
#define __profcxx_hashtable_size_destruct(__x...)
#endif
// Turn on/off instrumentation for VECTOR_TOO_SMALL and VECTOR_TOO_LARGE.
#if (defined(_GLIBCXX_PROFILE_VECTOR_TOO_SMALL) \
|| defined(_GLIBCXX_PROFILE_VECTOR_TOO_LARGE))
#define __profcxx_vector_size_construct(__x...) \
__gnu_profile::__trace_vector_size_construct(__x)
#define __profcxx_vector_size_resize(__x...) \
__gnu_profile::__trace_vector_size_resize(__x)
#define __profcxx_vector_size_destruct(__x...) \
__gnu_profile::__trace_vector_size_destruct(__x)
#else
#define __profcxx_vector_size_construct(__x...) 0
#define __profcxx_vector_size_resize(__x...)
#define __profcxx_vector_size_destruct(__x...)
#endif
// Turn on/off instrumentation for INEFFICIENT_HASH.
#if defined(_GLIBCXX_PROFILE_INEFFICIENT_HASH)
#define __profcxx_hash_func_construct(__x...) \
__gnu_profile::__trace_hash_func_construct(__x)
#define __profcxx_hash_func_destruct(__x...) \
__gnu_profile::__trace_hash_func_destruct(__x)
#else
#define __profcxx_hash_func_construct(__x...) 0
#define __profcxx_hash_func_destruct(__x...)
#endif
// Turn on/off instrumentation for VECTOR_TO_LIST.
#if defined(_GLIBCXX_PROFILE_VECTOR_TO_LIST)
#define __profcxx_vector2list_construct(__x...) \
__gnu_profile::__trace_vector_to_list_construct(__x)
#define __profcxx_vector2list_insert(__x...) \
__gnu_profile::__trace_vector_to_list_insert(__x)
#define __profcxx_vector2list_iterate(__x...) \
__gnu_profile::__trace_vector_to_list_iterate(__x)
#define __profcxx_vector2list_invalid_operator(__x...) \
__gnu_profile::__trace_vector_to_list_invalid_operator(__x)
#define __profcxx_vector2list_resize(__x...) \
__gnu_profile::__trace_vector_to_list_resize(__x)
#define __profcxx_vector2list_destruct(__x...) \
__gnu_profile::__trace_vector_to_list_destruct(__x)
#else
#define __profcxx_vector2list_construct(__x...) 0
#define __profcxx_vector2list_insert(__x...)
#define __profcxx_vector2list_iterate(__x...)
#define __profcxx_vector2list_invalid_operator(__x...)
#define __profcxx_vector2list_resize(__x...)
#define __profcxx_vector2list_destruct(__x...)
#endif
// Turn on/off instrumentation for LIST_TO_VECTOR.
#if defined(_GLIBCXX_PROFILE_LIST_TO_VECTOR)
#define __profcxx_list2vector_construct(__x...) \
__gnu_profile::__trace_list_to_vector_construct(__x)
#define __profcxx_list2vector_insert(__x...) \
__gnu_profile::__trace_list_to_vector_insert(__x)
#define __profcxx_list2vector_iterate(__x...) \
__gnu_profile::__trace_list_to_vector_iterate(__x)
#define __profcxx_list2vector_invalid_operator(__x...) \
__gnu_profile::__trace_list_to_vector_invalid_operator(__x)
#define __profcxx_list2vector_destruct(__x...) \
__gnu_profile::__trace_list_to_vector_destruct(__x)
#else
#define __profcxx_list2vector_construct(__x...) 0
#define __profcxx_list2vector_insert(__x...)
#define __profcxx_list2vector_iterate(__x...)
#define __profcxx_list2vector_invalid_operator(__x...)
#define __profcxx_list2vector_destruct(__x...)
#endif
// Turn on/off instrumentation for LIST_TO_SLIST.
#if defined(_GLIBCXX_PROFILE_LIST_TO_SLIST)
#define __profcxx_list2slist_construct(__x...) \
__gnu_profile::__trace_list_to_slist_construct(__x)
#define __profcxx_list2slist_rewind(__x...) \
__gnu_profile::__trace_list_to_slist_rewind(__x)
#define __profcxx_list2slist_operation(__x...) \
__gnu_profile::__trace_list_to_slist_operation(__x)
#define __profcxx_list2slist_destruct(__x...) \
__gnu_profile::__trace_list_to_slist_destruct(__x)
#else
#define __profcxx_list2slist_construct(__x...) 0
#define __profcxx_list2slist_rewind(__x...)
#define __profcxx_list2slist_operation(__x...)
#define __profcxx_list2slist_destruct(__x...)
#endif
// Turn on/off instrumentation for MAP_TO_UNORDERED_MAP.
#if defined(_GLIBCXX_PROFILE_MAP_TO_UNORDERED_MAP)
#define __profcxx_map2umap_construct(__x...) \
__gnu_profile::__trace_map_to_unordered_map_construct(__x)
#define __profcxx_map2umap_insert(__x...) \
__gnu_profile::__trace_map_to_unordered_map_insert(__x)
#define __profcxx_map2umap_erase(__x...) \
__gnu_profile::__trace_map_to_unordered_map_erase(__x)
#define __profcxx_map2umap_iterate(__x...) \
__gnu_profile::__trace_map_to_unordered_map_iterate(__x)
#define __profcxx_map2umap_invalidate(__x...) \
__gnu_profile::__trace_map_to_unordered_map_invalidate(__x)
#define __profcxx_map2umap_find(__x...) \
__gnu_profile::__trace_map_to_unordered_map_find(__x)
#define __profcxx_map2umap_destruct(__x...) \
__gnu_profile::__trace_map_to_unordered_map_destruct(__x)
#else
#define __profcxx_map2umap_construct(__x...) 0
#define __profcxx_map2umap_insert(__x...)
#define __profcxx_map2umap_erase(__x...)
#define __profcxx_map2umap_iterate(__x...)
#define __profcxx_map2umap_invalidate(__x...)
#define __profcxx_map2umap_find(__x...)
#define __profcxx_map2umap_destruct(__x...)
#endif
// Set default values for compile-time customizable variables.
#ifndef _GLIBCXX_PROFILE_TRACE_PATH_ROOT
#define _GLIBCXX_PROFILE_TRACE_PATH_ROOT "libstdcxx-profile"
#endif
#ifndef _GLIBCXX_PROFILE_TRACE_ENV_VAR
#define _GLIBCXX_PROFILE_TRACE_ENV_VAR "_GLIBCXX_PROFILE_TRACE_PATH_ROOT"
#endif
#ifndef _GLIBCXX_PROFILE_MAX_WARN_COUNT_ENV_VAR
#define _GLIBCXX_PROFILE_MAX_WARN_COUNT_ENV_VAR \
"_GLIBCXX_PROFILE_MAX_WARN_COUNT"
#endif
#ifndef _GLIBCXX_PROFILE_MAX_WARN_COUNT
#define _GLIBCXX_PROFILE_MAX_WARN_COUNT 10
#endif
#ifndef _GLIBCXX_PROFILE_MAX_STACK_DEPTH
#define _GLIBCXX_PROFILE_MAX_STACK_DEPTH 32
#endif
#ifndef _GLIBCXX_PROFILE_MAX_STACK_DEPTH_ENV_VAR
#define _GLIBCXX_PROFILE_MAX_STACK_DEPTH_ENV_VAR \
"_GLIBCXX_PROFILE_MAX_STACK_DEPTH"
#endif
#ifndef _GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC
#define _GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC (1 << 28)
#endif
#ifndef _GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC_ENV_VAR
#define _GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC_ENV_VAR \
"_GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC"
#endif
// Instrumentation hook implementations.
#include "profile/impl/profiler_hash_func.h"
#include "profile/impl/profiler_hashtable_size.h"
#include "profile/impl/profiler_map_to_unordered_map.h"
#include "profile/impl/profiler_vector_size.h"
#include "profile/impl/profiler_vector_to_list.h"
#include "profile/impl/profiler_list_to_slist.h"
#include "profile/impl/profiler_list_to_vector.h"
#endif // _GLIBCXX_PROFILE_PROFILER_H
c++/8/profile/impl/profiler_vector_to_list.h 0000644 00000015335 15201526705 0015010 0 ustar 00 // -*- C++ -*-
//
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
/** @file profile/impl/profiler_vector_to_list.h
* @brief diagnostics for vector to list.
*/
// Written by Lixia Liu and Silvius Rus.
#ifndef _GLIBCXX_PROFILE_PROFILER_VECTOR_TO_LIST_H
#define _GLIBCXX_PROFILE_PROFILER_VECTOR_TO_LIST_H 1
#include "profile/impl/profiler.h"
#include "profile/impl/profiler_node.h"
#include "profile/impl/profiler_trace.h"
namespace __gnu_profile
{
/** @brief A vector-to-list instrumentation line in the object table. */
class __vector2list_info
: public __object_info_base
{
public:
__vector2list_info(__stack_t __stack)
: __object_info_base(__stack), _M_shift_count(0), _M_iterate(0),
_M_resize(0), _M_list_cost(0), _M_vector_cost(0)
{ }
void
__merge(const __vector2list_info& __o)
{
__object_info_base::__merge(__o);
_M_shift_count += __o._M_shift_count;
_M_iterate += __o._M_iterate;
_M_vector_cost += __o._M_vector_cost;
_M_list_cost += __o._M_list_cost;
_M_resize += __o._M_resize;
}
void
__write(FILE* __f) const
{
std::fprintf(__f, "%Zu %Zu %Zu %.0f %.0f\n", _M_shift_count,
_M_resize, _M_iterate, _M_vector_cost, _M_list_cost);
}
float
__magnitude() const
{ return _M_vector_cost - _M_list_cost; }
std::string
__advice() const
{ return "change std::vector to std::list"; }
std::size_t
__shift_count()
{ return _M_shift_count; }
std::size_t
__iterate()
{ return _M_iterate; }
float
__list_cost()
{ return _M_list_cost; }
std::size_t
__resize()
{ return _M_resize; }
void
__set_list_cost(float __lc)
{ _M_list_cost = __lc; }
void
__set_vector_cost(float __vc)
{ _M_vector_cost = __vc; }
void
__opr_insert(std::size_t __pos, std::size_t __num)
{ _M_shift_count += __num - __pos; }
void
__opr_iterate(int __num)
{ __gnu_cxx::__atomic_add(&_M_iterate, __num); }
void
__resize(std::size_t __from, std::size_t)
{ _M_resize += __from; }
private:
std::size_t _M_shift_count;
mutable _Atomic_word _M_iterate;
std::size_t _M_resize;
float _M_list_cost;
float _M_vector_cost;
};
/** @brief A vector-to-list instrumentation line in the stack table. */
class __vector2list_stack_info
: public __vector2list_info
{
public:
__vector2list_stack_info(const __vector2list_info& __o)
: __vector2list_info(__o) { }
};
/** @brief Vector-to-list instrumentation producer. */
class __trace_vector_to_list
: public __trace_base<__vector2list_info, __vector2list_stack_info>
{
public:
__trace_vector_to_list()
: __trace_base<__vector2list_info, __vector2list_stack_info>()
{ __id = "vector-to-list"; }
~__trace_vector_to_list() { }
// Call at destruction/clean to set container final size.
void
__destruct(__vector2list_info* __obj_info)
{
float __vc = __vector_cost(__obj_info->__shift_count(),
__obj_info->__iterate(),
__obj_info->__resize());
float __lc = __list_cost(__obj_info->__shift_count(),
__obj_info->__iterate(),
__obj_info->__resize());
__obj_info->__set_vector_cost(__vc);
__obj_info->__set_list_cost(__lc);
__retire_object(__obj_info);
}
// Collect cost of operations.
float
__vector_cost(std::size_t __shift, std::size_t __iterate,
std::size_t __resize)
{
return (__shift
* _GLIBCXX_PROFILE_DATA(__vector_shift_cost_factor).__value
+ __iterate
* _GLIBCXX_PROFILE_DATA(__vector_iterate_cost_factor).__value
+ __resize
* _GLIBCXX_PROFILE_DATA(__vector_resize_cost_factor).__value);
}
float
__list_cost(std::size_t __shift, std::size_t __iterate,
std::size_t __resize)
{
return (__shift
* _GLIBCXX_PROFILE_DATA(__list_shift_cost_factor).__value
+ __iterate
* _GLIBCXX_PROFILE_DATA(__list_iterate_cost_factor).__value
+ __resize
* _GLIBCXX_PROFILE_DATA(__list_resize_cost_factor).__value);
}
};
inline void
__trace_vector_to_list_init()
{ _GLIBCXX_PROFILE_DATA(_S_vector_to_list) = new __trace_vector_to_list(); }
inline void
__trace_vector_to_list_free()
{ delete _GLIBCXX_PROFILE_DATA(_S_vector_to_list); }
inline void
__trace_vector_to_list_report(FILE* __f, __warning_vector_t& __warnings)
{ __trace_report(_GLIBCXX_PROFILE_DATA(_S_vector_to_list), __f, __warnings); }
inline __vector2list_info*
__trace_vector_to_list_construct()
{
if (!__profcxx_init())
return 0;
if (!__reentrance_guard::__get_in())
return 0;
__reentrance_guard __get_out;
return _GLIBCXX_PROFILE_DATA(_S_vector_to_list)
->__add_object(__get_stack());
}
inline void
__trace_vector_to_list_insert(__vector2list_info* __obj_info,
std::size_t __pos,
std::size_t __num)
{
if (!__obj_info)
return;
__obj_info->__opr_insert(__pos, __num);
}
inline void
__trace_vector_to_list_iterate(__vector2list_info* __obj_info, int)
{
if (!__obj_info)
return;
// We only collect if an iteration took place no matter in what side.
__obj_info->__opr_iterate(1);
}
inline void
__trace_vector_to_list_invalid_operator(__vector2list_info* __obj_info)
{
if (!__obj_info)
return;
__obj_info->__set_invalid();
}
inline void
__trace_vector_to_list_resize(__vector2list_info* __obj_info,
std::size_t __from,
std::size_t __to)
{
if (!__obj_info)
return;
__obj_info->__resize(__from, __to);
}
inline void
__trace_vector_to_list_destruct(__vector2list_info* __obj_info)
{
if (!__obj_info)
return;
_GLIBCXX_PROFILE_DATA(_S_vector_to_list)->__destruct(__obj_info);
}
} // namespace __gnu_profile
#endif /* _GLIBCXX_PROFILE_PROFILER_VECTOR_TO_LIST_H */
c++/8/profile/impl/profiler_map_to_unordered_map.h 0000644 00000015651 15201526705 0016135 0 ustar 00 // -*- C++ -*-
//
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
/** @file profile/impl/profiler_map_to_unordered_map.h
* @brief Diagnostics for map to unordered_map.
*/
// Written by Silvius Rus.
#ifndef _GLIBCXX_PROFILE_PROFILER_MAP_TO_UNORDERED_MAP_H
#define _GLIBCXX_PROFILE_PROFILER_MAP_TO_UNORDERED_MAP_H 1
#include "profile/impl/profiler.h"
#include "profile/impl/profiler_node.h"
#include "profile/impl/profiler_trace.h"
namespace __gnu_profile
{
inline int
__log2(std::size_t __size)
{
for (int __bit_count = sizeof(std::size_t) - 1; __bit_count >= 0;
-- __bit_count)
if ((2 << __bit_count) & __size)
return __bit_count;
return 0;
}
inline float
__map_insert_cost(std::size_t __size)
{ return (_GLIBCXX_PROFILE_DATA(__map_insert_cost_factor).__value
* static_cast<float>(__log2(__size))); }
inline float
__map_erase_cost(std::size_t __size)
{ return (_GLIBCXX_PROFILE_DATA(__map_erase_cost_factor).__value
* static_cast<float>(__log2(__size))); }
inline float
__map_find_cost(std::size_t __size)
{ return (_GLIBCXX_PROFILE_DATA(__map_find_cost_factor).__value
* static_cast<float>(__log2(__size))); }
/** @brief A map-to-unordered_map instrumentation line in the
object table. */
class __map2umap_info
: public __object_info_base
{
public:
__map2umap_info(__stack_t __stack)
: __object_info_base(__stack), _M_insert(0), _M_erase(0), _M_find(0),
_M_iterate(0), _M_umap_cost(0.0), _M_map_cost(0.0)
{ }
void
__merge(const __map2umap_info& __o)
{
__object_info_base::__merge(__o);
_M_insert += __o._M_insert;
_M_erase += __o._M_erase;
_M_find += __o._M_find;
_M_iterate += __o._M_iterate;
_M_umap_cost += __o._M_umap_cost;
_M_map_cost += __o._M_map_cost;
}
void
__write(FILE* __f) const
{
std::fprintf(__f, "%Zu %Zu %Zu %Zu %.0f %.0f\n",
_M_insert, _M_erase, _M_find, _M_iterate, _M_map_cost,
_M_umap_cost);
}
float
__magnitude() const
{ return _M_map_cost - _M_umap_cost; }
std::string
__advice() const
{ return "prefer an unordered container"; }
void
__record_insert(std::size_t __size, std::size_t __count)
{
++_M_insert;
if (__count)
{
_M_map_cost += __count * __map_insert_cost(__size);
_M_umap_cost
+= (__count
* _GLIBCXX_PROFILE_DATA(__umap_insert_cost_factor).__value);
}
}
void
__record_erase(std::size_t __size, std::size_t __count)
{
++_M_erase;
if (__count)
{
_M_map_cost += __count * __map_erase_cost(__size);
_M_umap_cost
+= (__count
* _GLIBCXX_PROFILE_DATA(__umap_erase_cost_factor).__value);
}
}
void
__record_find(std::size_t __size)
{
++_M_find;
_M_map_cost += __map_find_cost(__size);
_M_umap_cost += _GLIBCXX_PROFILE_DATA(__umap_find_cost_factor).__value;
}
void
__record_iterate(int __count)
{ __gnu_cxx::__atomic_add(&_M_iterate, __count); }
void
__set_iterate_costs()
{
_M_umap_cost
+= (_M_iterate
* _GLIBCXX_PROFILE_DATA(__umap_iterate_cost_factor).__value);
_M_map_cost
+= (_M_iterate
* _GLIBCXX_PROFILE_DATA(__map_iterate_cost_factor).__value);
}
private:
std::size_t _M_insert;
std::size_t _M_erase;
std::size_t _M_find;
mutable _Atomic_word _M_iterate;
float _M_umap_cost;
float _M_map_cost;
};
/** @brief A map-to-unordered_map instrumentation line in the
stack table. */
class __map2umap_stack_info
: public __map2umap_info
{
public:
__map2umap_stack_info(const __map2umap_info& __o)
: __map2umap_info(__o) { }
};
/** @brief Map-to-unordered_map instrumentation producer. */
class __trace_map2umap
: public __trace_base<__map2umap_info, __map2umap_stack_info>
{
public:
__trace_map2umap()
: __trace_base<__map2umap_info, __map2umap_stack_info>()
{ __id = "ordered-to-unordered"; }
// Call at destruction/clean to set container final size.
void
__destruct(__map2umap_info* __obj_info)
{
__obj_info->__set_iterate_costs();
__retire_object(__obj_info);
}
};
inline void
__trace_map_to_unordered_map_init()
{ _GLIBCXX_PROFILE_DATA(_S_map2umap) = new __trace_map2umap(); }
inline void
__trace_map_to_unordered_map_free()
{ delete _GLIBCXX_PROFILE_DATA(_S_map2umap); }
inline void
__trace_map_to_unordered_map_report(FILE* __f,
__warning_vector_t& __warnings)
{ __trace_report(_GLIBCXX_PROFILE_DATA(_S_map2umap), __f, __warnings); }
inline __map2umap_info*
__trace_map_to_unordered_map_construct()
{
if (!__profcxx_init())
return 0;
if (!__reentrance_guard::__get_in())
return 0;
__reentrance_guard __get_out;
return _GLIBCXX_PROFILE_DATA(_S_map2umap)->__add_object(__get_stack());
}
inline void
__trace_map_to_unordered_map_insert(__map2umap_info* __info,
std::size_t __size, std::size_t __count)
{
if (!__info)
return;
__info->__record_insert(__size, __count);
}
inline void
__trace_map_to_unordered_map_erase(__map2umap_info* __info,
std::size_t __size, std::size_t __count)
{
if (!__info)
return;
__info->__record_erase(__size, __count);
}
inline void
__trace_map_to_unordered_map_find(__map2umap_info* __info,
std::size_t __size)
{
if (!__info)
return;
__info->__record_find(__size);
}
inline void
__trace_map_to_unordered_map_iterate(__map2umap_info* __info,
int)
{
if (!__info)
return;
// We only collect if an iteration took place no matter in what side.
__info->__record_iterate(1);
}
inline void
__trace_map_to_unordered_map_invalidate(__map2umap_info* __info)
{
if (!__info)
return;
__info->__set_invalid();
}
inline void
__trace_map_to_unordered_map_destruct(__map2umap_info* __info)
{
if (!__info)
return;
_GLIBCXX_PROFILE_DATA(_S_map2umap)->__destruct(__info);
}
} // namespace __gnu_profile
#endif /* _GLIBCXX_PROFILE_PROFILER_MAP_TO_UNORDERED_MAP_H */
c++/8/profile/impl/profiler_state.h 0000644 00000003724 15201526705 0013070 0 ustar 00 // -*- C++ -*-
//
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
/** @file profile/impl/profiler_state.h
* @brief Global profiler state.
*/
// Written by Lixia Liu and Silvius Rus.
#ifndef _GLIBCXX_PROFILE_PROFILER_STATE_H
#define _GLIBCXX_PROFILE_PROFILER_STATE_H 1
namespace __gnu_profile
{
enum __state_type { __ON, __OFF, __INVALID };
_GLIBCXX_PROFILE_DEFINE_DATA(__state_type, __state, __INVALID);
inline bool
__turn(__state_type __s)
{
__state_type inv(__INVALID);
return __atomic_compare_exchange_n(&_GLIBCXX_PROFILE_DATA(__state),
&inv, __s, false, __ATOMIC_ACQ_REL,
__ATOMIC_RELAXED);
}
inline bool
__turn_on()
{ return __turn(__ON); }
inline bool
__turn_off()
{ return __turn(__OFF); }
inline bool
__is_on()
{ return _GLIBCXX_PROFILE_DATA(__state) == __ON; }
inline bool
__is_off()
{ return _GLIBCXX_PROFILE_DATA(__state) == __OFF; }
inline bool
__is_invalid()
{ return _GLIBCXX_PROFILE_DATA(__state) == __INVALID; }
} // end namespace __gnu_profile
#endif /* _GLIBCXX_PROFILE_PROFILER_STATE_H */
c++/8/profile/impl/profiler_container_size.h 0000644 00000012433 15201526705 0014761 0 ustar 00 // -*- C++ -*-
//
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
/** @file profile/impl/profiler_container_size.h
* @brief Diagnostics for container sizes.
*/
// Written by Lixia Liu and Silvius Rus.
#ifndef _GLIBCXX_PROFILE_PROFILER_CONTAINER_SIZE_H
#define _GLIBCXX_PROFILE_PROFILER_CONTAINER_SIZE_H 1
#include <sstream>
#include "profile/impl/profiler.h"
#include "profile/impl/profiler_node.h"
#include "profile/impl/profiler_trace.h"
namespace __gnu_profile
{
/** @brief A container size instrumentation line in the object table. */
class __container_size_info
: public __object_info_base
{
public:
__container_size_info(__stack_t __stack)
: __object_info_base(__stack), _M_init(0), _M_max(0),
_M_min(0), _M_total(0), _M_item_min(0), _M_item_max(0),
_M_item_total(0), _M_count(0), _M_resize(0), _M_cost(0)
{ }
void
__write(FILE* __f) const
{
std::fprintf(__f, "%Zu %Zu %Zu %Zu %Zu %Zu %Zu %Zu %Zu %Zu\n",
_M_init, _M_count, _M_cost, _M_resize, _M_min, _M_max,
_M_total, _M_item_min, _M_item_max, _M_item_total);
}
float
__magnitude() const
{ return static_cast<float>(_M_cost); }
std::string
__advice() const
{
std::stringstream __message;
if (_M_init < _M_item_max)
__message << "change initial container size from " << _M_init
<< " to " << _M_item_max;
return __message.str();
}
void
__init(std::size_t __num)
{
_M_init = __num;
_M_max = __num;
}
void
__merge(const __container_size_info& __o)
{
__object_info_base::__merge(__o);
_M_init = std::max(_M_init, __o._M_init);
_M_max = std::max(_M_max, __o._M_max);
_M_item_max = std::max(_M_item_max, __o._M_item_max);
_M_min = std::min(_M_min, __o._M_min);
_M_item_min = std::min(_M_item_min, __o._M_item_min);
_M_total += __o._M_total;
_M_item_total += __o._M_item_total;
_M_count += __o._M_count;
_M_cost += __o._M_cost;
_M_resize += __o._M_resize;
}
// Call if a container is destructed or cleaned.
void
__destruct(std::size_t __num, std::size_t __inum)
{
_M_max = std::max(_M_max, __num);
_M_item_max = std::max(_M_item_max, __inum);
if (_M_min == 0)
{
_M_min = __num;
_M_item_min = __inum;
}
else
{
_M_min = std::min(_M_min, __num);
_M_item_min = std::min(_M_item_min, __inum);
}
_M_total += __num;
_M_item_total += __inum;
_M_count += 1;
}
// Estimate the cost of resize/rehash.
float
__resize_cost(std::size_t __from, std::size_t)
{ return __from; }
// Call if container is resized.
void
__resize(std::size_t __from, std::size_t __to)
{
_M_cost += this->__resize_cost(__from, __to);
_M_resize += 1;
_M_max = std::max(_M_max, __to);
}
private:
std::size_t _M_init;
std::size_t _M_max; // range of # buckets
std::size_t _M_min;
std::size_t _M_total;
std::size_t _M_item_min; // range of # items
std::size_t _M_item_max;
std::size_t _M_item_total;
std::size_t _M_count;
std::size_t _M_resize;
std::size_t _M_cost;
};
/** @brief A container size instrumentation line in the stack table. */
class __container_size_stack_info
: public __container_size_info
{
public:
__container_size_stack_info(const __container_size_info& __o)
: __container_size_info(__o) { }
};
/** @brief Container size instrumentation trace producer. */
class __trace_container_size
: public __trace_base<__container_size_info, __container_size_stack_info>
{
public:
~__trace_container_size() { }
__trace_container_size()
: __trace_base<__container_size_info, __container_size_stack_info>() { };
// Insert a new node at construct with object, callstack and initial size.
__container_size_info*
__insert(__stack_t __stack, std::size_t __num)
{
__container_size_info* __ret = __add_object(__stack);
if (__ret)
__ret->__init(__num);
return __ret;
}
// Call at destruction/clean to set container final size.
void
__destruct(__container_size_info* __obj_info,
std::size_t __num, std::size_t __inum)
{
__obj_info->__destruct(__num, __inum);
__retire_object(__obj_info);
}
};
} // namespace __gnu_profile
#endif /* _GLIBCXX_PROFILE_PROFILER_CONTAINER_SIZE_H */
c++/8/profile/impl/profiler_trace.h 0000644 00000050613 15201526705 0013045 0 ustar 00 // -*- C++ -*-
//
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
/** @file profile/impl/profiler_trace.h
* @brief Data structures to represent profiling traces.
*/
// Written by Lixia Liu and Silvius Rus.
#ifndef _GLIBCXX_PROFILE_PROFILER_TRACE_H
#define _GLIBCXX_PROFILE_PROFILER_TRACE_H 1
#include <cstdio> // fopen, fclose, fprintf, FILE
#include <cerrno>
#include <cstdlib> // atof, atoi, strtol, getenv, atexit, abort
#if __cplusplus >= 201103L
#include <unordered_map>
#define _GLIBCXX_IMPL_UNORDERED_MAP std::_GLIBCXX_STD_C::unordered_map
#else
#include <tr1/unordered_map>
#define _GLIBCXX_IMPL_UNORDERED_MAP std::tr1::unordered_map
#endif
#include <ext/concurrence.h>
#include <fstream>
#include <string>
#include <utility>
#include <vector>
#include "profile/impl/profiler_algos.h"
#include "profile/impl/profiler_state.h"
#include "profile/impl/profiler_node.h"
namespace __gnu_profile
{
/** @brief Internal environment. Values can be set one of two ways:
1. In config file "var = value". The default config file path is
libstdcxx-profile.conf.
2. By setting process environment variables. For instance, in a Bash
shell you can set the unit cost of iterating through a map like this:
export __map_iterate_cost_factor=5.0.
If a value is set both in the input file and through an environment
variable, the environment value takes precedence. */
typedef _GLIBCXX_IMPL_UNORDERED_MAP<std::string, std::string> __env_t;
_GLIBCXX_PROFILE_DEFINE_UNINIT_DATA(__env_t, __env);
/** @brief Master lock. */
_GLIBCXX_PROFILE_DEFINE_UNINIT_DATA(__gnu_cxx::__mutex, __global_mutex);
/** @brief Representation of a warning. */
struct __warning_data
{
float __magnitude;
__stack_t __context;
const char* __warning_id;
std::string __warning_message;
__warning_data()
: __magnitude(0.0), __context(0), __warning_id(0) { }
__warning_data(float __m, __stack_t __c, const char* __id,
const std::string& __msg)
: __magnitude(__m), __context(__c), __warning_id(__id),
__warning_message(__msg) { }
bool
operator<(const __warning_data& __other) const
{ return __magnitude < __other.__magnitude; }
};
typedef std::_GLIBCXX_STD_C::vector<__warning_data> __warning_vector_t;
// Defined in profiler_<diagnostic name>.h.
class __trace_hash_func;
class __trace_hashtable_size;
class __trace_map2umap;
class __trace_vector_size;
class __trace_vector_to_list;
class __trace_list_to_slist;
class __trace_list_to_vector;
void __trace_vector_size_init();
void __trace_hashtable_size_init();
void __trace_hash_func_init();
void __trace_vector_to_list_init();
void __trace_list_to_slist_init();
void __trace_list_to_vector_init();
void __trace_map_to_unordered_map_init();
void __trace_vector_size_report(FILE*, __warning_vector_t&);
void __trace_hashtable_size_report(FILE*, __warning_vector_t&);
void __trace_hash_func_report(FILE*, __warning_vector_t&);
void __trace_vector_to_list_report(FILE*, __warning_vector_t&);
void __trace_list_to_slist_report(FILE*, __warning_vector_t&);
void __trace_list_to_vector_report(FILE*, __warning_vector_t&);
void __trace_map_to_unordered_map_report(FILE*, __warning_vector_t&);
void __trace_vector_size_free();
void __trace_hashtable_size_free();
void __trace_hash_func_free();
void __trace_vector_to_list_free();
void __trace_list_to_slist_free();
void __trace_list_to_vector_free();
void __trace_map_to_unordered_map_free();
struct __cost_factor
{
const char* __env_var;
float __value;
};
typedef std::_GLIBCXX_STD_C::vector<__cost_factor*> __cost_factor_vector;
_GLIBCXX_PROFILE_DEFINE_DATA(__trace_hash_func*, _S_hash_func, 0);
_GLIBCXX_PROFILE_DEFINE_DATA(__trace_hashtable_size*, _S_hashtable_size, 0);
_GLIBCXX_PROFILE_DEFINE_DATA(__trace_map2umap*, _S_map2umap, 0);
_GLIBCXX_PROFILE_DEFINE_DATA(__trace_vector_size*, _S_vector_size, 0);
_GLIBCXX_PROFILE_DEFINE_DATA(__trace_vector_to_list*, _S_vector_to_list, 0);
_GLIBCXX_PROFILE_DEFINE_DATA(__trace_list_to_slist*, _S_list_to_slist, 0);
_GLIBCXX_PROFILE_DEFINE_DATA(__trace_list_to_vector*, _S_list_to_vector, 0);
_GLIBCXX_PROFILE_DEFINE_DATA(__cost_factor, __vector_shift_cost_factor,
{"__vector_shift_cost_factor", 1.0});
_GLIBCXX_PROFILE_DEFINE_DATA(__cost_factor, __vector_iterate_cost_factor,
{"__vector_iterate_cost_factor", 1.0});
_GLIBCXX_PROFILE_DEFINE_DATA(__cost_factor, __vector_resize_cost_factor,
{"__vector_resize_cost_factor", 1.0});
_GLIBCXX_PROFILE_DEFINE_DATA(__cost_factor, __list_shift_cost_factor,
{"__list_shift_cost_factor", 0.0});
_GLIBCXX_PROFILE_DEFINE_DATA(__cost_factor, __list_iterate_cost_factor,
{"__list_iterate_cost_factor", 10.0});
_GLIBCXX_PROFILE_DEFINE_DATA(__cost_factor, __list_resize_cost_factor,
{"__list_resize_cost_factor", 0.0});
_GLIBCXX_PROFILE_DEFINE_DATA(__cost_factor, __map_insert_cost_factor,
{"__map_insert_cost_factor", 1.5});
_GLIBCXX_PROFILE_DEFINE_DATA(__cost_factor, __map_erase_cost_factor,
{"__map_erase_cost_factor", 1.5});
_GLIBCXX_PROFILE_DEFINE_DATA(__cost_factor, __map_find_cost_factor,
{"__map_find_cost_factor", 1});
_GLIBCXX_PROFILE_DEFINE_DATA(__cost_factor, __map_iterate_cost_factor,
{"__map_iterate_cost_factor", 2.3});
_GLIBCXX_PROFILE_DEFINE_DATA(__cost_factor, __umap_insert_cost_factor,
{"__umap_insert_cost_factor", 12.0});
_GLIBCXX_PROFILE_DEFINE_DATA(__cost_factor, __umap_erase_cost_factor,
{"__umap_erase_cost_factor", 12.0});
_GLIBCXX_PROFILE_DEFINE_DATA(__cost_factor, __umap_find_cost_factor,
{"__umap_find_cost_factor", 10.0});
_GLIBCXX_PROFILE_DEFINE_DATA(__cost_factor, __umap_iterate_cost_factor,
{"__umap_iterate_cost_factor", 1.7});
_GLIBCXX_PROFILE_DEFINE_DATA(__cost_factor_vector*, __cost_factors, 0);
_GLIBCXX_PROFILE_DEFINE_DATA(const char*, _S_trace_file_name,
_GLIBCXX_PROFILE_TRACE_PATH_ROOT);
_GLIBCXX_PROFILE_DEFINE_DATA(std::size_t, _S_max_warn_count,
_GLIBCXX_PROFILE_MAX_WARN_COUNT);
_GLIBCXX_PROFILE_DEFINE_DATA(std::size_t, _S_max_stack_depth,
_GLIBCXX_PROFILE_MAX_STACK_DEPTH);
_GLIBCXX_PROFILE_DEFINE_DATA(std::size_t, _S_max_mem,
_GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC);
inline std::size_t
__stack_max_depth()
{ return _GLIBCXX_PROFILE_DATA(_S_max_stack_depth); }
inline std::size_t
__max_mem()
{ return _GLIBCXX_PROFILE_DATA(_S_max_mem); }
/** @brief Base class for all trace producers. */
template<typename __object_info, typename __stack_info>
class __trace_base
{
public:
// Do not pick the initial size too large, as we don't know which
// diagnostics are more active.
__trace_base()
: __objects_byte_size(0), __stack_table(10000),
__stack_table_byte_size(0), __id(0) { }
~__trace_base()
{
for (typename __stack_table_t::iterator __it
= __stack_table.begin(); __it != __stack_table.end(); ++__it)
delete __it->first;
}
__object_info* __add_object(__stack_t __stack);
void __retire_object(__object_info* __info);
void __write(FILE* __f);
void __collect_warnings(__warning_vector_t& __warnings);
void __free();
private:
__gnu_cxx::__mutex __trace_mutex;
typedef _GLIBCXX_IMPL_UNORDERED_MAP<__stack_t, __stack_info,
__stack_hash,
__stack_hash> __stack_table_t;
std::size_t __objects_byte_size;
__stack_table_t __stack_table;
std::size_t __stack_table_byte_size;
protected:
const char* __id;
};
template<typename __object_info, typename __stack_info>
__object_info*
__trace_base<__object_info, __stack_info>::
__add_object(__stack_t __stack)
{
// If we have no backtrace information no need to collect data.
if (!__stack)
return 0;
__gnu_cxx::__scoped_lock __lock(this->__trace_mutex);
if (__max_mem() != 0 && __objects_byte_size >= __max_mem())
{
delete __stack;
return 0;
}
__object_info* __ret = new(std::nothrow) __object_info(__stack);
if (!__ret)
{
delete __stack;
return 0;
}
__objects_byte_size += sizeof(__object_info);
return __ret;
}
template<typename __object_info, typename __stack_info>
void
__trace_base<__object_info, __stack_info>::
__retire_object(__object_info* __obj_info)
{
if (!__obj_info)
return;
__gnu_cxx::__scoped_lock __lock(this->__trace_mutex);
const __object_info& __info = *__obj_info;
__stack_t __stack = __info.__stack();
typename __stack_table_t::iterator __stack_it
= __stack_table.find(__stack);
if (__stack_it == __stack_table.end())
{
// First occurrence of this call context.
if (__max_mem() == 0 || __stack_table_byte_size < __max_mem())
{
__stack_table_byte_size
+= (sizeof(__instruction_address_t) * __size(__stack)
+ sizeof(__stack) + sizeof(__stack_info));
__stack_table.insert(make_pair(__stack,
__stack_info(__info)));
}
else
delete __stack;
}
else
{
// Merge object info into info summary for this call context.
__stack_it->second.__merge(__info);
delete __stack;
}
delete __obj_info;
__objects_byte_size -= sizeof(__object_info);
}
template<typename __object_info, typename __stack_info>
void
__trace_base<__object_info, __stack_info>::
__write(FILE* __f)
{
for (typename __stack_table_t::iterator __it
= __stack_table.begin(); __it != __stack_table.end(); ++__it)
if (__it->second.__is_valid())
{
std::fprintf(__f, __id);
std::fprintf(__f, "|");
__gnu_profile::__write(__f, __it->first);
std::fprintf(__f, "|");
__it->second.__write(__f);
}
}
template<typename __object_info, typename __stack_info>
void
__trace_base<__object_info, __stack_info>::
__collect_warnings(__warning_vector_t& __warnings)
{
for (typename __stack_table_t::iterator __it
= __stack_table.begin(); __it != __stack_table.end(); ++__it)
__warnings.push_back(__warning_data(__it->second.__magnitude(),
__it->first, __id,
__it->second.__advice()));
}
template<typename __object_info, typename __stack_info>
inline void
__trace_report(__trace_base<__object_info, __stack_info>* __cont,
FILE* __f, __warning_vector_t& __warnings)
{
if (__cont)
{
__cont->__collect_warnings(__warnings);
__cont->__write(__f);
}
}
inline std::size_t
__env_to_size_t(const char* __env_var, std::size_t __default_value)
{
char* __env_value = std::getenv(__env_var);
if (__env_value)
{
errno = 0;
long __converted_value = std::strtol(__env_value, 0, 10);
if (errno || __converted_value < 0)
{
std::fprintf(stderr,
"Bad value for environment variable '%s'.\n",
__env_var);
std::abort();
}
else
return static_cast<std::size_t>(__converted_value);
}
else
return __default_value;
}
inline void
__set_max_stack_trace_depth()
{
_GLIBCXX_PROFILE_DATA(_S_max_stack_depth)
= __env_to_size_t(_GLIBCXX_PROFILE_MAX_STACK_DEPTH_ENV_VAR,
_GLIBCXX_PROFILE_DATA(_S_max_stack_depth));
}
inline void
__set_max_mem()
{
_GLIBCXX_PROFILE_DATA(_S_max_mem)
= __env_to_size_t(_GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC_ENV_VAR,
_GLIBCXX_PROFILE_DATA(_S_max_mem));
}
inline int
__log_magnitude(float __f)
{
const float __log_base = 10.0;
int __result = 0;
int __sign = 1;
if (__f < 0)
{
__f = -__f;
__sign = -1;
}
while (__f > __log_base)
{
++__result;
__f /= 10.0;
}
return __sign * __result;
}
inline FILE*
__open_output_file(const char* __extension)
{
// The path is made of _S_trace_file_name + "." + extension.
std::size_t __root_len
= __builtin_strlen(_GLIBCXX_PROFILE_DATA(_S_trace_file_name));
std::size_t __ext_len = __builtin_strlen(__extension);
char* __file_name = new char[__root_len + 1 + __ext_len + 1];
__builtin_memcpy(__file_name,
_GLIBCXX_PROFILE_DATA(_S_trace_file_name),
__root_len);
*(__file_name + __root_len) = '.';
__builtin_memcpy(__file_name + __root_len + 1,
__extension, __ext_len + 1);
FILE* __out_file = std::fopen(__file_name, "w");
if (!__out_file)
{
std::fprintf(stderr, "Could not open trace file '%s'.\n",
__file_name);
std::abort();
}
delete[] __file_name;
return __out_file;
}
struct __warn
{
FILE* __file;
__warn(FILE* __f)
{ __file = __f; }
void
operator()(const __warning_data& __info)
{
std::fprintf(__file, __info.__warning_id);
std::fprintf(__file, ": improvement = %d",
__log_magnitude(__info.__magnitude));
std::fprintf(__file, ": call stack = ");
__gnu_profile::__write(__file, __info.__context);
std::fprintf(__file, ": advice = %s\n",
__info.__warning_message.c_str());
}
};
/** @brief Final report method, registered with @b atexit.
*
* This can also be called directly by user code, including signal handlers.
* It is protected against deadlocks by the reentrance guard in profiler.h.
* However, when called from a signal handler that triggers while within
* __gnu_profile (under the guarded zone), no output will be produced.
*/
inline void
__report()
{
__gnu_cxx::__scoped_lock __lock(_GLIBCXX_PROFILE_DATA(__global_mutex));
__warning_vector_t __warnings, __top_warnings;
FILE* __raw_file = __open_output_file("raw");
__trace_vector_size_report(__raw_file, __warnings);
__trace_hashtable_size_report(__raw_file, __warnings);
__trace_hash_func_report(__raw_file, __warnings);
__trace_vector_to_list_report(__raw_file, __warnings);
__trace_list_to_slist_report(__raw_file, __warnings);
__trace_list_to_vector_report(__raw_file, __warnings);
__trace_map_to_unordered_map_report(__raw_file, __warnings);
std::fclose(__raw_file);
// Sort data by magnitude, keeping just top N.
std::size_t __cutoff = std::min(_GLIBCXX_PROFILE_DATA(_S_max_warn_count),
__warnings.size());
__top_n(__warnings, __top_warnings, __cutoff);
FILE* __warn_file = __open_output_file("txt");
__for_each(__top_warnings.begin(), __top_warnings.end(),
__warn(__warn_file));
std::fclose(__warn_file);
}
inline void
__report_and_free()
{
__report();
__trace_map_to_unordered_map_free();
__trace_list_to_vector_free();
__trace_list_to_slist_free();
__trace_vector_to_list_free();
__trace_hash_func_free();
__trace_hashtable_size_free();
__trace_vector_size_free();
delete _GLIBCXX_PROFILE_DATA(__cost_factors);
}
inline void
__set_trace_path()
{
char* __env_trace_file_name = std::getenv(_GLIBCXX_PROFILE_TRACE_ENV_VAR);
if (__env_trace_file_name)
_GLIBCXX_PROFILE_DATA(_S_trace_file_name) = __env_trace_file_name;
// Make sure early that we can create the trace file.
std::fclose(__open_output_file("txt"));
}
inline void
__set_max_warn_count()
{
char* __env_max_warn_count_str
= std::getenv(_GLIBCXX_PROFILE_MAX_WARN_COUNT_ENV_VAR);
if (__env_max_warn_count_str)
_GLIBCXX_PROFILE_DATA(_S_max_warn_count)
= static_cast<std::size_t>(std::atoi(__env_max_warn_count_str));
}
inline void
__read_cost_factors()
{
std::string __conf_file_name(_GLIBCXX_PROFILE_DATA(_S_trace_file_name));
__conf_file_name += ".conf";
std::ifstream __conf_file(__conf_file_name.c_str());
if (__conf_file.is_open())
{
std::string __line;
while (std::getline(__conf_file, __line))
{
std::string::size_type __i = __line.find_first_not_of(" \t\n\v");
if (__line.length() <= 0 || __line[__i] == '#')
// Skip empty lines or comments.
continue;
}
// Trim.
__line.erase(__remove(__line.begin(), __line.end(), ' '),
__line.end());
std::string::size_type __pos = __line.find("=");
std::string __factor_name = __line.substr(0, __pos);
std::string::size_type __end = __line.find_first_of(";\n");
std::string __factor_value = __line.substr(__pos + 1, __end - __pos);
_GLIBCXX_PROFILE_DATA(__env)[__factor_name] = __factor_value;
}
}
struct __cost_factor_writer
{
FILE* __file;
__cost_factor_writer(FILE* __f)
: __file(__f) { }
void
operator() (const __cost_factor* __factor)
{ std::fprintf(__file, "%s = %f\n", __factor->__env_var,
__factor->__value); }
};
inline void
__write_cost_factors()
{
FILE* __file = __open_output_file("conf.out");
__for_each(_GLIBCXX_PROFILE_DATA(__cost_factors)->begin(),
_GLIBCXX_PROFILE_DATA(__cost_factors)->end(),
__cost_factor_writer(__file));
std::fclose(__file);
}
struct __cost_factor_setter
{
void
operator()(__cost_factor* __factor)
{
// Look it up in the process environment first.
const char* __env_value = std::getenv(__factor->__env_var);
if (!__env_value)
{
// Look it up in the config file.
__env_t::iterator __it
= _GLIBCXX_PROFILE_DATA(__env).find(__factor->__env_var);
if (__it != _GLIBCXX_PROFILE_DATA(__env).end())
__env_value = __it->second.c_str();
}
if (__env_value)
__factor->__value = std::atof(__env_value);
}
};
inline void
__set_cost_factors()
{
__cost_factor_vector* __factors = new __cost_factor_vector;
_GLIBCXX_PROFILE_DATA(__cost_factors) = __factors;
__factors->push_back(&_GLIBCXX_PROFILE_DATA(__vector_shift_cost_factor));
__factors->push_back(&_GLIBCXX_PROFILE_DATA(__vector_iterate_cost_factor));
__factors->push_back(&_GLIBCXX_PROFILE_DATA(__vector_resize_cost_factor));
__factors->push_back(&_GLIBCXX_PROFILE_DATA(__list_shift_cost_factor));
__factors->push_back(&_GLIBCXX_PROFILE_DATA(__list_iterate_cost_factor));
__factors->push_back(&_GLIBCXX_PROFILE_DATA(__list_resize_cost_factor));
__factors->push_back(&_GLIBCXX_PROFILE_DATA(__map_insert_cost_factor));
__factors->push_back(&_GLIBCXX_PROFILE_DATA(__map_erase_cost_factor));
__factors->push_back(&_GLIBCXX_PROFILE_DATA(__map_find_cost_factor));
__factors->push_back(&_GLIBCXX_PROFILE_DATA(__map_iterate_cost_factor));
__factors->push_back(&_GLIBCXX_PROFILE_DATA(__umap_insert_cost_factor));
__factors->push_back(&_GLIBCXX_PROFILE_DATA(__umap_erase_cost_factor));
__factors->push_back(&_GLIBCXX_PROFILE_DATA(__umap_find_cost_factor));
__factors->push_back(&_GLIBCXX_PROFILE_DATA(__umap_iterate_cost_factor));
__for_each(__factors->begin(), __factors->end(), __cost_factor_setter());
}
inline void
__profcxx_init_unconditional()
{
__gnu_cxx::__scoped_lock __lock(_GLIBCXX_PROFILE_DATA(__global_mutex));
if (__is_invalid())
{
__set_max_warn_count();
if (_GLIBCXX_PROFILE_DATA(_S_max_warn_count) == 0)
__turn_off();
else
{
__set_max_stack_trace_depth();
__set_max_mem();
__set_trace_path();
__read_cost_factors();
__set_cost_factors();
__write_cost_factors();
__trace_vector_size_init();
__trace_hashtable_size_init();
__trace_hash_func_init();
__trace_vector_to_list_init();
__trace_list_to_slist_init();
__trace_list_to_vector_init();
__trace_map_to_unordered_map_init();
std::atexit(__report_and_free);
__turn_on();
}
}
}
/** @brief This function must be called by each instrumentation point.
*
* The common path is inlined fully.
*/
inline bool
__profcxx_init()
{
if (__is_invalid())
__profcxx_init_unconditional();
return __is_on();
}
} // namespace __gnu_profile
#endif /* _GLIBCXX_PROFILE_PROFILER_TRACE_H */
c++/8/profile/impl/profiler_vector_size.h 0000644 00000005560 15201526705 0014304 0 ustar 00 // -*- C++ -*-
//
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
/** @file profile/impl/profiler_vector_size.h
* @brief Collection of vector size traces.
*/
// Written by Lixia Liu and Silvius Rus.
#ifndef _GLIBCXX_PROFILE_PROFILER_VECTOR_SIZE_H
#define _GLIBCXX_PROFILE_PROFILER_VECTOR_SIZE_H 1
#include "profile/impl/profiler.h"
#include "profile/impl/profiler_node.h"
#include "profile/impl/profiler_trace.h"
#include "profile/impl/profiler_state.h"
#include "profile/impl/profiler_container_size.h"
namespace __gnu_profile
{
/** @brief Hashtable size instrumentation trace producer. */
class __trace_vector_size
: public __trace_container_size
{
public:
__trace_vector_size()
: __trace_container_size()
{ __id = "vector-size"; }
};
inline void
__trace_vector_size_init()
{ _GLIBCXX_PROFILE_DATA(_S_vector_size) = new __trace_vector_size(); }
inline void
__trace_vector_size_free()
{ delete _GLIBCXX_PROFILE_DATA(_S_vector_size); }
inline void
__trace_vector_size_report(FILE* __f, __warning_vector_t& __warnings)
{ __trace_report(_GLIBCXX_PROFILE_DATA(_S_vector_size), __f, __warnings); }
inline __container_size_info*
__trace_vector_size_construct(std::size_t __num)
{
if (!__profcxx_init())
return 0;
if (!__reentrance_guard::__get_in())
return 0;
__reentrance_guard __get_out;
return _GLIBCXX_PROFILE_DATA(_S_vector_size)->
__insert(__get_stack(), __num);
}
inline void
__trace_vector_size_resize(__container_size_info* __obj_info,
std::size_t __from, std::size_t __to)
{
if (!__obj_info)
return;
__obj_info->__resize(__from, __to);
}
inline void
__trace_vector_size_destruct(__container_size_info* __obj_info,
std::size_t __num, std::size_t __inum)
{
if (!__obj_info)
return;
_GLIBCXX_PROFILE_DATA(_S_vector_size)->
__destruct(__obj_info, __num, __inum);
}
} // namespace __gnu_profile
#endif /* _GLIBCXX_PROFILE_PROFILER_VECTOR_SIZE_H */
c++/8/profile/impl/profiler_node.h 0000644 00000007331 15201526705 0012673 0 ustar 00 // -*- C++ -*-
//
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
/** @file profile/impl/profiler_node.h
* @brief Data structures to represent a single profiling event.
*/
// Written by Lixia Liu and Silvius Rus.
#ifndef _GLIBCXX_PROFILE_PROFILER_NODE_H
#define _GLIBCXX_PROFILE_PROFILER_NODE_H 1
#include <cstdio> // FILE, fprintf
#include <vector>
#if defined _GLIBCXX_HAVE_EXECINFO_H
#include <execinfo.h>
#endif
namespace __gnu_profile
{
typedef void* __instruction_address_t;
typedef std::_GLIBCXX_STD_C::vector<__instruction_address_t> __stack_npt;
typedef __stack_npt* __stack_t;
std::size_t __stack_max_depth();
inline __stack_t
__get_stack()
{
#if defined _GLIBCXX_HAVE_EXECINFO_H
__try
{
std::size_t __max_depth = __stack_max_depth();
if (__max_depth == 0)
return 0;
__stack_npt __buffer(__max_depth);
int __depth = backtrace(&__buffer[0], __max_depth);
return new(std::nothrow) __stack_npt(__buffer.begin(),
__buffer.begin() + __depth);
}
__catch(...)
{
return 0;
}
#else
return 0;
#endif
}
inline std::size_t
__size(__stack_t __stack)
{
if (!__stack)
return 0;
else
return __stack->size();
}
// XXX
inline void
__write(FILE* __f, __stack_t __stack)
{
if (!__stack)
return;
__stack_npt::const_iterator __it;
for (__it = __stack->begin(); __it != __stack->end(); ++__it)
std::fprintf(__f, "%p ", *__it);
}
/** @brief Hash function for summary trace using call stack as index. */
class __stack_hash
{
public:
std::size_t
operator()(__stack_t __s) const
{
if (!__s)
return 0;
std::size_t __index = 0;
__stack_npt::const_iterator __it;
for (__it = __s->begin(); __it != __s->end(); ++__it)
__index += reinterpret_cast<std::size_t>(*__it);
return __index;
}
bool operator() (__stack_t __stack1, __stack_t __stack2) const
{
if (!__stack1 && !__stack2)
return true;
if (!__stack1 || !__stack2)
return false;
if (__stack1->size() != __stack2->size())
return false;
std::size_t __byte_size
= __stack1->size() * sizeof(__stack_npt::value_type);
return __builtin_memcmp(&(*__stack1)[0], &(*__stack2)[0],
__byte_size) == 0;
}
};
/** @brief Base class for a line in the object table. */
class __object_info_base
{
public:
__object_info_base(__stack_t __stack)
: _M_stack(__stack), _M_valid(true) { }
bool
__is_valid() const
{ return _M_valid; }
void
__set_invalid()
{ _M_valid = false; }
void
__merge(const __object_info_base& __o)
{ _M_valid &= __o._M_valid; }
__stack_t
__stack() const
{ return _M_stack; }
protected:
__stack_t _M_stack;
bool _M_valid;
};
} // namespace __gnu_profile
#endif /* _GLIBCXX_PROFILE_PROFILER_NODE_H */
c++/8/profile/impl/profiler_hashtable_size.h 0000644 00000005646 15201526705 0014742 0 ustar 00 // -*- C++ -*-
//
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
/** @file profile/impl/profiler_hashtable_size.h
* @brief Collection of hashtable size traces.
*/
// Written by Lixia Liu and Silvius Rus.
#ifndef _GLIBCXX_PROFILE_PROFILER_HASHTABLE_SIZE_H
#define _GLIBCXX_PROFILE_PROFILER_HASHTABLE_SIZE_H 1
#include "profile/impl/profiler.h"
#include "profile/impl/profiler_node.h"
#include "profile/impl/profiler_trace.h"
#include "profile/impl/profiler_state.h"
#include "profile/impl/profiler_container_size.h"
namespace __gnu_profile
{
/** @brief Hashtable size instrumentation trace producer. */
class __trace_hashtable_size
: public __trace_container_size
{
public:
__trace_hashtable_size()
: __trace_container_size()
{ __id = "hashtable-size"; }
};
inline void
__trace_hashtable_size_init()
{ _GLIBCXX_PROFILE_DATA(_S_hashtable_size) = new __trace_hashtable_size(); }
inline void
__trace_hashtable_size_free()
{ delete _GLIBCXX_PROFILE_DATA(_S_hashtable_size); }
inline void
__trace_hashtable_size_report(FILE* __f, __warning_vector_t& __warnings)
{ __trace_report(_GLIBCXX_PROFILE_DATA(_S_hashtable_size), __f, __warnings); }
inline __container_size_info*
__trace_hashtable_size_construct(std::size_t __num)
{
if (!__profcxx_init())
return 0;
if (!__reentrance_guard::__get_in())
return 0;
__reentrance_guard __get_out;
return _GLIBCXX_PROFILE_DATA(_S_hashtable_size)->
__insert(__get_stack(), __num);
}
inline void
__trace_hashtable_size_resize(__container_size_info* __obj_info,
std::size_t __from, std::size_t __to)
{
if (!__obj_info)
return;
__obj_info->__resize(__from, __to);
}
inline void
__trace_hashtable_size_destruct(__container_size_info* __obj_info,
std::size_t __num, std::size_t __inum)
{
if (!__obj_info)
return;
_GLIBCXX_PROFILE_DATA(_S_hashtable_size)->
__destruct(__obj_info, __num, __inum);
}
} // namespace __gnu_profile
#endif /* _GLIBCXX_PROFILE_PROFILER_HASHTABLE_SIZE_H */
c++/8/profile/impl/profiler_algos.h 0000644 00000006545 15201526705 0013061 0 ustar 00 // -*- C++ -*-
//
// Copyright (C) 2010-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
/** @file profile/impl/profiler_algos.h
* @brief Algorithms used by the profile extension.
*
* This file is needed to avoid including \<algorithm\> or \<bits/stl_algo.h\>.
* Including those files would result in recursive includes.
* These implementations are oversimplified. In general, efficiency may be
* sacrificed to minimize maintenance overhead.
*/
#ifndef _GLIBCXX_PROFILE_PROFILER_ALGOS_H
#define _GLIBCXX_PROFILE_PROFILER_ALGOS_H 1
namespace __gnu_profile
{
/* Helper for __top_n. Insert in sorted vector, but not beyond Nth elem. */
template<typename _Container>
void
__insert_top_n(_Container& __output,
const typename _Container::value_type& __value,
typename _Container::size_type __n)
{
typename _Container::iterator __it = __output.begin();
typename _Container::size_type __count = 0;
// Skip up to N - 1 elements larger than VALUE.
// XXX: Could do binary search for random iterators.
while (true)
{
if (__count >= __n)
// VALUE is not in top N.
return;
if (__it == __output.end())
break;
if (*__it < __value)
break;
++__it;
++__count;
}
__output.insert(__it, __value);
}
/* Copy the top N elements in INPUT, sorted in reverse order, to OUTPUT. */
template<typename _Container>
void
__top_n(const _Container& __input, _Container& __output,
typename _Container::size_type __n)
{
__output.clear();
typename _Container::const_iterator __it;
for (__it = __input.begin(); __it != __input.end(); ++__it)
__insert_top_n(__output, *__it, __n);
}
/* Simplified clone of std::for_each. */
template<typename _InputIterator, typename _Function>
_Function
__for_each(_InputIterator __first, _InputIterator __last, _Function __f)
{
for (; __first != __last; ++__first)
__f(*__first);
return __f;
}
/* Simplified clone of std::remove. */
template<typename _ForwardIterator, typename _Tp>
_ForwardIterator
__remove(_ForwardIterator __first, _ForwardIterator __last,
const _Tp& __value)
{
if(__first == __last)
return __first;
_ForwardIterator __result = __first;
++__first;
for(; __first != __last; ++__first)
if(!(*__first == __value))
{
*__result = *__first;
++__result;
}
return __result;
}
} // namespace __gnu_profile
#endif /* _GLIBCXX_PROFILE_PROFILER_ALGOS_H */
c++/8/profile/set.h 0000644 00000043311 15201526705 0007674 0 ustar 00 // Profiling set implementation -*- C++ -*-
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file profile/set.h
* This file is a GNU profile extension to the Standard C++ Library.
*/
#ifndef _GLIBCXX_PROFILE_SET_H
#define _GLIBCXX_PROFILE_SET_H 1
#include <profile/base.h>
#include <profile/ordered_base.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __profile
{
/// Class std::set wrapper with performance instrumentation.
template<typename _Key, typename _Compare = std::less<_Key>,
typename _Allocator = std::allocator<_Key> >
class set
: public _GLIBCXX_STD_C::set<_Key,_Compare,_Allocator>,
public _Ordered_profile<set<_Key, _Compare, _Allocator> >
{
typedef _GLIBCXX_STD_C::set<_Key, _Compare, _Allocator> _Base;
typedef typename _Base::iterator _Base_iterator;
typedef typename _Base::const_iterator _Base_const_iterator;
public:
// types:
typedef _Key key_type;
typedef _Key value_type;
typedef _Compare key_compare;
typedef _Compare value_compare;
typedef typename _Base::reference reference;
typedef typename _Base::const_reference const_reference;
typedef __iterator_tracker<_Base_iterator, set> iterator;
typedef __iterator_tracker<_Base_const_iterator,
set> const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
typedef typename _Base::size_type size_type;
typedef typename _Base::difference_type difference_type;
// 23.3.3.1 construct/copy/destroy:
#if __cplusplus < 201103L
set()
: _Base() { }
set(const set& __x)
: _Base(__x) { }
~set() { }
#else
set() = default;
set(const set&) = default;
set(set&&) = default;
~set() = default;
#endif
explicit set(const _Compare& __comp,
const _Allocator& __a = _Allocator())
: _Base(__comp, __a) { }
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
#else
template<typename _InputIterator>
#endif
set(_InputIterator __first, _InputIterator __last,
const _Compare& __comp = _Compare(),
const _Allocator& __a = _Allocator())
: _Base(__first, __last, __comp, __a) { }
#if __cplusplus >= 201103L
set(initializer_list<value_type> __l,
const _Compare& __comp = _Compare(),
const _Allocator& __a = _Allocator())
: _Base(__l, __comp, __a) { }
explicit
set(const _Allocator& __a)
: _Base(__a) { }
set(const set& __x, const _Allocator& __a)
: _Base(__x, __a) { }
set(set&& __x, const _Allocator& __a)
noexcept( noexcept(_Base(std::move(__x), __a)) )
: _Base(std::move(__x), __a) { }
set(initializer_list<value_type> __l, const _Allocator& __a)
: _Base(__l, __a) { }
template<typename _InputIterator>
set(_InputIterator __first, _InputIterator __last,
const _Allocator& __a)
: _Base(__first, __last, __a) { }
#endif
set(const _Base& __x)
: _Base(__x) { }
#if __cplusplus < 201103L
set&
operator=(const set& __x)
{
this->_M_profile_destruct();
_M_base() = __x;
this->_M_profile_construct();
return *this;
}
#else
set&
operator=(const set&) = default;
set&
operator=(set&&) = default;
set&
operator=(initializer_list<value_type> __l)
{
this->_M_profile_destruct();
_M_base() = __l;
this->_M_profile_construct();
return *this;
}
#endif
// iterators
iterator
begin() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::begin(), this); }
const_iterator
begin() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::begin(), this); }
iterator
end() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::end(), this); }
const_iterator
end() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::end(), this); }
#if __cplusplus >= 201103L
const_iterator
cbegin() const noexcept
{ return const_iterator(_Base::cbegin(), this); }
const_iterator
cend() const noexcept
{ return const_iterator(_Base::cend(), this); }
#endif
reverse_iterator
rbegin() _GLIBCXX_NOEXCEPT
{
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return reverse_iterator(end());
}
const_reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT
{
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(end());
}
reverse_iterator
rend() _GLIBCXX_NOEXCEPT
{
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return reverse_iterator(begin());
}
const_reverse_iterator
rend() const _GLIBCXX_NOEXCEPT
{
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(begin());
}
#if __cplusplus >= 201103L
const_reverse_iterator
crbegin() const noexcept
{
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(cend());
}
const_reverse_iterator
crend() const noexcept
{
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(cbegin());
}
#endif
void
swap(set& __x)
_GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
{
_Base::swap(__x);
this->_M_swap(__x);
}
// modifiers:
#if __cplusplus >= 201103L
template<typename... _Args>
std::pair<iterator, bool>
emplace(_Args&&... __args)
{
__profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
auto __base_ret = _Base::emplace(std::forward<_Args>(__args)...);
return std::make_pair(iterator(__base_ret.first, this),
__base_ret.second);
}
template<typename... _Args>
iterator
emplace_hint(const_iterator __pos, _Args&&... __args)
{
auto size_before = this->size();
auto __res
= _Base::emplace_hint(__pos.base(), std::forward<_Args>(__args)...);
__profcxx_map2umap_insert(this->_M_map2umap_info,
size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
return iterator(__res, this);
}
#endif
std::pair<iterator, bool>
insert(const value_type& __x)
{
__profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
std::pair<_Base_iterator, bool> __base_ret = _Base::insert(__x);
return std::make_pair(iterator(__base_ret.first, this),
__base_ret.second);
}
#if __cplusplus >= 201103L
std::pair<iterator, bool>
insert(value_type&& __x)
{
__profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
std::pair<_Base_iterator, bool> __base_ret
= _Base::insert(std::move(__x));
return std::make_pair(iterator(__base_ret.first, this),
__base_ret.second);
}
#endif
iterator
insert(const_iterator __pos, const value_type& __x)
{
size_type size_before = this->size();
_Base_iterator __res = _Base::insert(__pos.base(), __x);
__profcxx_map2umap_insert(this->_M_map2umap_info,
size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
return iterator(__res, this);
}
#if __cplusplus >= 201103L
iterator
insert(const_iterator __pos, value_type&& __x)
{ return iterator(_Base::insert(__pos.base(), std::move(__x)), this); }
#endif
template<typename _InputIterator>
void
insert(_InputIterator __first, _InputIterator __last)
{
for (; __first != __last; ++__first)
insert(*__first);
}
#if __cplusplus >= 201103L
void
insert(initializer_list<value_type> __l)
{ insert(__l.begin(), __l.end()); }
#endif
#if __cplusplus >= 201103L
iterator
erase(const_iterator __pos)
{
__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
return iterator(_Base::erase(__pos.base()), this);
}
#else
void
erase(iterator __pos)
{
__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
_Base::erase(__pos.base());
}
#endif
size_type
erase(const key_type& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
return _Base::erase(__x);
}
#if __cplusplus >= 201103L
iterator
erase(const_iterator __first, const_iterator __last)
{
if (__first != __last)
{
iterator __ret;
for (; __first != __last;)
__ret = erase(__first++);
return __ret;
}
return iterator(_Base::erase(__first.base(), __last.base()), this);
}
#else
void
erase(iterator __first, iterator __last)
{
for (; __first != __last;)
erase(__first++);
}
#endif
void
clear() _GLIBCXX_NOEXCEPT
{
this->_M_profile_destruct();
_Base::clear();
this->_M_profile_construct();
}
size_type
count(const key_type& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return _Base::count(__x);
}
#if __cplusplus > 201103L
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
size_type
count(const _Kt& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return _Base::count(__x);
}
#endif
// set operations:
iterator
find(const key_type& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return iterator(_Base::find(__x), this);
}
const_iterator
find(const key_type& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return const_iterator(_Base::find(__x), this);
}
#if __cplusplus > 201103L
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
iterator
find(const _Kt& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return { _Base::find(__x), this };
}
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
const_iterator
find(const _Kt& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return { _Base::find(__x), this };
}
#endif
iterator
lower_bound(const key_type& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return iterator(_Base::lower_bound(__x), this);
}
const_iterator
lower_bound(const key_type& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_iterator(_Base::lower_bound(__x), this);
}
#if __cplusplus > 201103L
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
iterator
lower_bound(const _Kt& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return { _Base::lower_bound(__x), this };
}
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
const_iterator
lower_bound(const _Kt& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return { _Base::lower_bound(__x), this };
}
#endif
iterator
upper_bound(const key_type& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return iterator(_Base::upper_bound(__x), this);
}
const_iterator
upper_bound(const key_type& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_iterator(_Base::upper_bound(__x), this);
}
#if __cplusplus > 201103L
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
iterator
upper_bound(const _Kt& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return { _Base::upper_bound(__x), this };
}
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
const_iterator
upper_bound(const _Kt& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return { _Base::upper_bound(__x), this };
}
#endif
std::pair<iterator, iterator>
equal_range(const key_type& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
std::pair<_Base_iterator, _Base_iterator> __base_ret
= _Base::equal_range(__x);
return std::make_pair(iterator(__base_ret.first, this),
iterator(__base_ret.second, this));
}
std::pair<const_iterator, const_iterator>
equal_range(const key_type& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
std::pair<_Base_const_iterator, _Base_const_iterator> __base_ret
= _Base::equal_range(__x);
return std::make_pair(const_iterator(__base_ret.first, this),
const_iterator(__base_ret.second, this));
}
#if __cplusplus > 201103L
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
std::pair<iterator, iterator>
equal_range(const _Kt& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
auto __res = _Base::equal_range(__x);
return { { __res.first, this }, { __res.second, this } };
}
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
std::pair<const_iterator, const_iterator>
equal_range(const _Kt& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
auto __res = _Base::equal_range(__x);
return { { __res.first, this }, { __res.second, this } };
}
#endif
_Base&
_M_base() _GLIBCXX_NOEXCEPT { return *this; }
const _Base&
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
private:
/** If hint is used we consider that the map and unordered_map
* operations have equivalent insertion cost so we do not update metrics
* about it.
* Note that to find out if hint has been used is libstdc++
* implementation dependent.
*/
bool
_M_hint_used(_Base_const_iterator __hint, _Base_iterator __res)
{
return (__hint == __res
|| (__hint == _M_base().end() && ++__res == _M_base().end())
|| (__hint != _M_base().end() && (++__hint == __res
|| ++__res == --__hint)));
}
template<typename _K1, typename _C1, typename _A1>
friend bool
operator==(const set<_K1, _C1, _A1>&, const set<_K1, _C1, _A1>&);
template<typename _K1, typename _C1, typename _A1>
friend bool
operator<(const set<_K1, _C1, _A1>&, const set<_K1, _C1, _A1>&);
};
template<typename _Key, typename _Compare, typename _Allocator>
inline bool
operator==(const set<_Key, _Compare, _Allocator>& __lhs,
const set<_Key, _Compare, _Allocator>& __rhs)
{
__profcxx_map2umap_invalidate(__lhs._M_map2umap_info);
__profcxx_map2umap_invalidate(__rhs._M_map2umap_info);
return __lhs._M_base() == __rhs._M_base();
}
template<typename _Key, typename _Compare, typename _Allocator>
inline bool
operator<(const set<_Key, _Compare, _Allocator>& __lhs,
const set<_Key, _Compare, _Allocator>& __rhs)
{
__profcxx_map2umap_invalidate(__lhs._M_map2umap_info);
__profcxx_map2umap_invalidate(__rhs._M_map2umap_info);
return __lhs._M_base() < __rhs._M_base();
}
template<typename _Key, typename _Compare, typename _Allocator>
inline bool
operator!=(const set<_Key, _Compare, _Allocator>& __lhs,
const set<_Key, _Compare, _Allocator>& __rhs)
{ return !(__lhs == __rhs); }
template<typename _Key, typename _Compare, typename _Allocator>
inline bool
operator<=(const set<_Key, _Compare, _Allocator>& __lhs,
const set<_Key, _Compare, _Allocator>& __rhs)
{ return !(__rhs < __lhs); }
template<typename _Key, typename _Compare, typename _Allocator>
inline bool
operator>=(const set<_Key, _Compare, _Allocator>& __lhs,
const set<_Key, _Compare, _Allocator>& __rhs)
{ return !(__lhs < __rhs); }
template<typename _Key, typename _Compare, typename _Allocator>
inline bool
operator>(const set<_Key, _Compare, _Allocator>& __lhs,
const set<_Key, _Compare, _Allocator>& __rhs)
{ return __rhs < __lhs; }
template<typename _Key, typename _Compare, typename _Allocator>
void
swap(set<_Key, _Compare, _Allocator>& __x,
set<_Key, _Compare, _Allocator>& __y)
_GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
{ return __x.swap(__y); }
} // namespace __profile
} // namespace std
#endif
c++/8/profile/bitset 0000644 00000014717 15201526705 0010155 0 ustar 00 // Profiling bitset implementation -*- C++ -*-
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file profile/bitset
* This file is a GNU profile extension to the Standard C++ Library.
*/
#ifndef _GLIBCXX_PROFILE_BITSET
#define _GLIBCXX_PROFILE_BITSET
#include <bitset>
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __profile
{
/// Class std::bitset wrapper with performance instrumentation, none at the
/// moment.
template<size_t _Nb>
class bitset
: public _GLIBCXX_STD_C::bitset<_Nb>
{
typedef _GLIBCXX_STD_C::bitset<_Nb> _Base;
public:
// 23.3.5.1 constructors:
#if __cplusplus < 201103L
bitset()
: _Base() { }
#else
constexpr bitset() = default;
#endif
#if __cplusplus >= 201103L
constexpr bitset(unsigned long long __val) noexcept
#else
bitset(unsigned long __val)
#endif
: _Base(__val) { }
template<typename _CharT, typename _Traits, typename _Alloc>
explicit
bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __str,
typename std::basic_string<_CharT, _Traits, _Alloc>::size_type
__pos = 0,
typename std::basic_string<_CharT, _Traits, _Alloc>::size_type
__n = (std::basic_string<_CharT, _Traits, _Alloc>::npos))
: _Base(__str, __pos, __n) { }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 396. what are characters zero and one.
template<class _CharT, class _Traits, class _Alloc>
bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __str,
typename std::basic_string<_CharT, _Traits, _Alloc>::size_type
__pos,
typename std::basic_string<_CharT, _Traits, _Alloc>::size_type
__n,
_CharT __zero, _CharT __one = _CharT('1'))
: _Base(__str, __pos, __n, __zero, __one) { }
bitset(const _Base& __x) : _Base(__x) { }
#if __cplusplus >= 201103L
template<typename _CharT>
explicit
bitset(const _CharT* __str,
typename std::basic_string<_CharT>::size_type __n
= std::basic_string<_CharT>::npos,
_CharT __zero = _CharT('0'), _CharT __one = _CharT('1'))
: _Base(__str, __n, __zero, __one) { }
#endif
// 23.3.5.2 bitset operations:
bitset<_Nb>&
operator&=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT
{
_M_base() &= __rhs;
return *this;
}
bitset<_Nb>&
operator|=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT
{
_M_base() |= __rhs;
return *this;
}
bitset<_Nb>&
operator^=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT
{
_M_base() ^= __rhs;
return *this;
}
bitset<_Nb>&
operator<<=(size_t __pos) _GLIBCXX_NOEXCEPT
{
_M_base() <<= __pos;
return *this;
}
bitset<_Nb>&
operator>>=(size_t __pos) _GLIBCXX_NOEXCEPT
{
_M_base() >>= __pos;
return *this;
}
bitset<_Nb>&
set() _GLIBCXX_NOEXCEPT
{
_Base::set();
return *this;
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 186. bitset::set() second parameter should be bool
bitset<_Nb>&
set(size_t __pos, bool __val = true)
{
_Base::set(__pos, __val);
return *this;
}
bitset<_Nb>&
reset() _GLIBCXX_NOEXCEPT
{
_Base::reset();
return *this;
}
bitset<_Nb>&
reset(size_t __pos)
{
_Base::reset(__pos);
return *this;
}
bitset<_Nb>
operator~() const _GLIBCXX_NOEXCEPT
{ return bitset(~_M_base()); }
bitset<_Nb>&
flip() _GLIBCXX_NOEXCEPT
{
_Base::flip();
return *this;
}
bitset<_Nb>&
flip(size_t __pos)
{
_Base::flip(__pos);
return *this;
}
bool
operator==(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT
{ return _M_base() == __rhs; }
bool
operator!=(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT
{ return _M_base() != __rhs; }
bitset<_Nb>
operator<<(size_t __pos) const _GLIBCXX_NOEXCEPT
{ return bitset<_Nb>(_M_base() << __pos); }
bitset<_Nb>
operator>>(size_t __pos) const _GLIBCXX_NOEXCEPT
{ return bitset<_Nb>(_M_base() >> __pos); }
_Base&
_M_base() _GLIBCXX_NOEXCEPT
{ return *this; }
const _Base&
_M_base() const _GLIBCXX_NOEXCEPT
{ return *this; }
};
template<size_t _Nb>
bitset<_Nb>
operator&(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT
{ return bitset<_Nb>(__x) &= __y; }
template<size_t _Nb>
bitset<_Nb>
operator|(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT
{ return bitset<_Nb>(__x) |= __y; }
template<size_t _Nb>
bitset<_Nb>
operator^(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT
{ return bitset<_Nb>(__x) ^= __y; }
template<typename _CharT, typename _Traits, size_t _Nb>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is, bitset<_Nb>& __x)
{ return __is >> __x._M_base(); }
template<typename _CharT, typename _Traits, size_t _Nb>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const bitset<_Nb>& __x)
{ return __os << __x._M_base(); }
} // namespace __profile
#if __cplusplus >= 201103L
// DR 1182.
/// std::hash specialization for bitset.
template<size_t _Nb>
struct hash<__profile::bitset<_Nb>>
: public __hash_base<size_t, __profile::bitset<_Nb>>
{
size_t
operator()(const __profile::bitset<_Nb>& __b) const noexcept
{ return std::hash<_GLIBCXX_STD_C::bitset<_Nb>>()(__b._M_base()); }
};
#endif
} // namespace std
#endif
c++/8/profile/list 0000644 00000040736 15201526705 0007636 0 ustar 00 // Profiling list implementation -*- C++ -*-
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file profile/list
* This file is a GNU profile extension to the Standard C++ Library.
*/
#ifndef _GLIBCXX_PROFILE_LIST
#define _GLIBCXX_PROFILE_LIST 1
#include <list>
#include <profile/base.h>
#include <profile/iterator_tracker.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __profile
{
template<typename _List>
class _List_profile
{
_List&
_M_conjure()
{ return *static_cast<_List*>(this); }
public:
__gnu_profile::__list2slist_info* _M_list2slist_info;
__gnu_profile::__list2vector_info* _M_list2vector_info;
_List_profile() _GLIBCXX_NOEXCEPT
{ _M_profile_construct(); }
void
_M_profile_construct() _GLIBCXX_NOEXCEPT
{
_M_list2slist_info = __profcxx_list2slist_construct();
_M_list2vector_info = __profcxx_list2vector_construct();
}
void
_M_profile_destruct() _GLIBCXX_NOEXCEPT
{
__profcxx_list2vector_destruct(_M_list2vector_info);
_M_list2vector_info = 0;
__profcxx_list2slist_destruct(_M_list2slist_info);
_M_list2slist_info = 0;
}
void
_M_swap(_List_profile& __other)
{
std::swap(_M_list2slist_info, __other._M_list2slist_info);
std::swap(_M_list2vector_info, __other._M_list2vector_info);
}
#if __cplusplus >= 201103L
_List_profile(const _List_profile&) noexcept
: _List_profile() { }
_List_profile(_List_profile&& __other) noexcept
: _List_profile()
{ _M_swap(__other); }
_List_profile&
operator=(const _List_profile&) noexcept
{
_M_profile_destruct();
_M_profile_construct();
}
_List_profile&
operator=(_List_profile&& __other) noexcept
{
_M_swap(__other);
__other._M_profile_destruct();
__other._M_profile_construct();
}
#endif
~_List_profile()
{ _M_profile_destruct(); }
};
/** @brief List wrapper with performance instrumentation. */
template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
class list
: public _GLIBCXX_STD_C::list<_Tp, _Allocator>,
public _List_profile<list<_Tp, _Allocator> >
{
typedef _GLIBCXX_STD_C::list<_Tp, _Allocator> _Base;
public:
typedef typename _Base::reference reference;
typedef typename _Base::const_reference const_reference;
typedef __iterator_tracker<typename _Base::iterator, list>
iterator;
typedef __iterator_tracker<typename _Base::const_iterator, list>
const_iterator;
typedef typename _Base::size_type size_type;
typedef typename _Base::difference_type difference_type;
typedef _Tp value_type;
typedef _Allocator allocator_type;
typedef typename _Base::pointer pointer;
typedef typename _Base::const_pointer const_pointer;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
// 23.2.2.1 construct/copy/destroy:
#if __cplusplus < 201103L
list() { }
list(const list& __x)
: _Base(__x) { }
~list() { }
#else
list() = default;
list(const list&) = default;
list(list&&) = default;
~list() = default;
list(initializer_list<value_type> __l,
const allocator_type& __a = allocator_type())
: _Base(__l, __a) { }
list(const list& __x, const allocator_type& __a)
: _Base(__x, __a) { }
list(list&& __x, const allocator_type& __a)
: _Base(std::move(__x), __a) { }
#endif
explicit
list(const _Allocator& __a) _GLIBCXX_NOEXCEPT
: _Base(__a) { }
#if __cplusplus >= 201103L
explicit
list(size_type __n, const allocator_type& __a = allocator_type())
: _Base(__n, __a) { }
list(size_type __n, const _Tp& __value,
const _Allocator& __a = _Allocator())
: _Base(__n, __value, __a) { }
#else
explicit
list(size_type __n, const _Tp& __value = _Tp(),
const _Allocator& __a = _Allocator())
: _Base(__n, __value, __a) { }
#endif
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
#else
template<class _InputIterator>
#endif
list(_InputIterator __first, _InputIterator __last,
const _Allocator& __a = _Allocator())
: _Base(__first, __last, __a) { }
list(const _Base& __x)
: _Base(__x) { }
#if __cplusplus < 201103L
list&
operator=(const list& __x)
{
this->_M_profile_destruct();
_M_base() = __x;
this->_M_profile_construct();
return *this;
}
#else
list&
operator=(const list&) = default;
list&
operator=(list&&) = default;
list&
operator=(initializer_list<value_type> __l)
{
this->_M_profile_destruct();
_M_base() = __l;
this->_M_profile_construct();
return *this;
}
#endif
// iterators:
iterator
begin() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::begin(), this); }
const_iterator
begin() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::begin(), this); }
iterator
end() _GLIBCXX_NOEXCEPT
{
__profcxx_list2slist_rewind(this->_M_list2slist_info);
return iterator(_Base::end(), this);
}
const_iterator
end() const _GLIBCXX_NOEXCEPT
{
__profcxx_list2slist_rewind(this->_M_list2slist_info);
return const_iterator(_Base::end(), this);
}
reverse_iterator
rbegin() _GLIBCXX_NOEXCEPT
{
__profcxx_list2slist_rewind(this->_M_list2slist_info);
return reverse_iterator(end());
}
const_reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT
{
__profcxx_list2slist_rewind(this->_M_list2slist_info);
return const_reverse_iterator(end());
}
reverse_iterator
rend() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(begin()); }
const_reverse_iterator
rend() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(begin()); }
#if __cplusplus >= 201103L
const_iterator
cbegin() const noexcept
{ return const_iterator(_Base::cbegin(), this); }
const_iterator
cend() const noexcept
{ return const_iterator(_Base::cend(), this); }
const_reverse_iterator
crbegin() const noexcept
{ return const_reverse_iterator(end()); }
const_reverse_iterator
crend() const noexcept
{ return const_reverse_iterator(begin()); }
#endif
// 23.2.2.2 capacity:
reference
back() _GLIBCXX_NOEXCEPT
{
__profcxx_list2slist_rewind(this->_M_list2slist_info);
return _Base::back();
}
const_reference
back() const _GLIBCXX_NOEXCEPT
{
__profcxx_list2slist_rewind(this->_M_list2slist_info);
return _Base::back();
}
// 23.2.2.3 modifiers:
void
push_front(const value_type& __x)
{
__profcxx_list2vector_invalid_operator(this->_M_list2vector_info);
__profcxx_list2slist_operation(this->_M_list2slist_info);
_Base::push_front(__x);
}
void
pop_front() _GLIBCXX_NOEXCEPT
{
__profcxx_list2slist_operation(this->_M_list2slist_info);
_Base::pop_front();
}
void
pop_back() _GLIBCXX_NOEXCEPT
{
_Base::pop_back();
__profcxx_list2slist_rewind(this->_M_list2slist_info);
}
#if __cplusplus >= 201103L
template<typename... _Args>
iterator
emplace(const_iterator __position, _Args&&... __args)
{
return iterator(_Base::emplace(__position.base(),
std::forward<_Args>(__args)...),
this);
}
#endif
iterator
#if __cplusplus >= 201103L
insert(const_iterator __pos, const _Tp& __x)
#else
insert(iterator __pos, const _Tp& __x)
#endif
{
_M_profile_insert(__pos, this->size());
return iterator(_Base::insert(__pos.base(), __x), this);
}
#if __cplusplus >= 201103L
iterator
insert(const_iterator __pos, _Tp&& __x)
{
_M_profile_insert(__pos, this->size());
return iterator(_Base::emplace(__pos.base(), std::move(__x)),
this);
}
iterator
insert(const_iterator __pos, initializer_list<value_type> __l)
{
_M_profile_insert(__pos, this->size());
return iterator(_Base::insert(__pos.base(), __l), this);
}
#endif
#if __cplusplus >= 201103L
iterator
insert(const_iterator __pos, size_type __n, const _Tp& __x)
{
_M_profile_insert(__pos, this->size());
return iterator(_Base::insert(__pos.base(), __n, __x), this);
}
#else
void
insert(iterator __pos, size_type __n, const _Tp& __x)
{
_M_profile_insert(__pos, this->size());
_Base::insert(__pos.base(), __n, __x);
}
#endif
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
iterator
insert(const_iterator __pos, _InputIterator __first,
_InputIterator __last)
{
_M_profile_insert(__pos, this->size());
return iterator(_Base::insert(__pos.base(), __first, __last),
this);
}
#else
template<class _InputIterator>
void
insert(iterator __pos, _InputIterator __first,
_InputIterator __last)
{
_M_profile_insert(__pos, this->size());
_Base::insert(__pos.base(), __first, __last);
}
#endif
iterator
#if __cplusplus >= 201103L
erase(const_iterator __pos) noexcept
#else
erase(iterator __pos)
#endif
{ return iterator(_Base::erase(__pos.base()), this); }
iterator
#if __cplusplus >= 201103L
erase(const_iterator __pos, const_iterator __last) noexcept
#else
erase(iterator __pos, iterator __last)
#endif
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 151. can't currently clear() empty container
return iterator(_Base::erase(__pos.base(), __last.base()), this);
}
void
swap(list& __x)
_GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
{
_Base::swap(__x);
this->_M_swap(__x);
}
void
clear() _GLIBCXX_NOEXCEPT
{
this->_M_profile_destruct();
_Base::clear();
this->_M_profile_construct();
}
// 23.2.2.4 list operations:
void
#if __cplusplus >= 201103L
splice(const_iterator __pos, list&& __x) noexcept
#else
splice(iterator __pos, list& __x)
#endif
{ this->splice(__pos, _GLIBCXX_MOVE(__x), __x.begin(), __x.end()); }
#if __cplusplus >= 201103L
void
splice(const_iterator __pos, list& __x) noexcept
{ this->splice(__pos, std::move(__x)); }
void
splice(const_iterator __pos, list& __x, const_iterator __i)
{ this->splice(__pos, std::move(__x), __i); }
#endif
void
#if __cplusplus >= 201103L
splice(const_iterator __pos, list&& __x, const_iterator __i) noexcept
#else
splice(iterator __pos, list& __x, iterator __i)
#endif
{
// We used to perform the splice_alloc check: not anymore, redundant
// after implementing the relevant bits of N1599.
// _GLIBCXX_RESOLVE_LIB_DEFECTS
_Base::splice(__pos.base(), _GLIBCXX_MOVE(__x._M_base()),
__i.base());
}
void
#if __cplusplus >= 201103L
splice(const_iterator __pos, list&& __x, const_iterator __first,
const_iterator __last) noexcept
#else
splice(iterator __pos, list& __x, iterator __first,
iterator __last)
#endif
{
_Base::splice(__pos.base(), _GLIBCXX_MOVE(__x._M_base()),
__first.base(), __last.base());
}
#if __cplusplus >= 201103L
void
splice(const_iterator __pos, list& __x,
const_iterator __first, const_iterator __last) noexcept
{ this->splice(__pos, std::move(__x), __first, __last); }
#endif
void
remove(const _Tp& __value)
{
for (iterator __x = begin(); __x != end(); )
{
if (*__x == __value)
__x = erase(__x);
else
++__x;
}
}
template<class _Predicate>
void
remove_if(_Predicate __pred)
{
for (iterator __x = begin(); __x != end(); )
{
__profcxx_list2slist_operation(this->_M_list2slist_info);
if (__pred(*__x))
__x = erase(__x);
else
++__x;
}
}
void
unique()
{
iterator __first = begin();
iterator __last = end();
if (__first == __last)
return;
iterator __next = __first;
while (++__next != __last)
{
__profcxx_list2slist_operation(this->_M_list2slist_info);
if (*__first == *__next)
erase(__next);
else
__first = __next;
__next = __first;
}
}
template<class _BinaryPredicate>
void
unique(_BinaryPredicate __binary_pred)
{
iterator __first = begin();
iterator __last = end();
if (__first == __last)
return;
iterator __next = __first;
while (++__next != __last)
{
__profcxx_list2slist_operation(this->_M_list2slist_info);
if (__binary_pred(*__first, *__next))
erase(__next);
else
__first = __next;
__next = __first;
}
}
void
#if __cplusplus >= 201103L
merge(list&& __x)
#else
merge(list& __x)
#endif
{ _Base::merge(_GLIBCXX_MOVE(__x._M_base())); }
#if __cplusplus >= 201103L
void
merge(list& __x)
{ this->merge(std::move(__x)); }
#endif
template<class _Compare>
void
#if __cplusplus >= 201103L
merge(list&& __x, _Compare __comp)
#else
merge(list& __x, _Compare __comp)
#endif
{ _Base::merge(_GLIBCXX_MOVE(__x._M_base()), __comp); }
#if __cplusplus >= 201103L
template<typename _Compare>
void
merge(list& __x, _Compare __comp)
{ this->merge(std::move(__x), __comp); }
#endif
_Base&
_M_base() _GLIBCXX_NOEXCEPT { return *this; }
const _Base&
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
void _M_profile_iterate(int __rewind = 0) const
{
__profcxx_list2slist_operation(this->_M_list2slist_info);
__profcxx_list2vector_iterate(this->_M_list2vector_info, __rewind);
if (__rewind)
__profcxx_list2slist_rewind(this->_M_list2slist_info);
}
private:
size_type
_M_profile_insert(const_iterator __pos, size_type __size)
{
size_type __shift = 0;
typename _Base::const_iterator __it = __pos.base();
for (; __it != _Base::end(); ++__it)
__shift++;
__profcxx_list2slist_rewind(this->_M_list2slist_info);
__profcxx_list2slist_operation(this->_M_list2slist_info);
__profcxx_list2vector_insert(this->_M_list2vector_info, __shift, __size);
}
};
template<typename _Tp, typename _Alloc>
inline bool
operator==(const list<_Tp, _Alloc>& __lhs,
const list<_Tp, _Alloc>& __rhs)
{ return __lhs._M_base() == __rhs._M_base(); }
template<typename _Tp, typename _Alloc>
inline bool
operator!=(const list<_Tp, _Alloc>& __lhs,
const list<_Tp, _Alloc>& __rhs)
{ return __lhs._M_base() != __rhs._M_base(); }
template<typename _Tp, typename _Alloc>
inline bool
operator<(const list<_Tp, _Alloc>& __lhs,
const list<_Tp, _Alloc>& __rhs)
{ return __lhs._M_base() < __rhs._M_base(); }
template<typename _Tp, typename _Alloc>
inline bool
operator<=(const list<_Tp, _Alloc>& __lhs,
const list<_Tp, _Alloc>& __rhs)
{ return __lhs._M_base() <= __rhs._M_base(); }
template<typename _Tp, typename _Alloc>
inline bool
operator>=(const list<_Tp, _Alloc>& __lhs,
const list<_Tp, _Alloc>& __rhs)
{ return __lhs._M_base() >= __rhs._M_base(); }
template<typename _Tp, typename _Alloc>
inline bool
operator>(const list<_Tp, _Alloc>& __lhs,
const list<_Tp, _Alloc>& __rhs)
{ return __lhs._M_base() > __rhs._M_base(); }
template<typename _Tp, typename _Alloc>
inline void
swap(list<_Tp, _Alloc>& __lhs, list<_Tp, _Alloc>& __rhs)
_GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
{ __lhs.swap(__rhs); }
} // namespace __profile
} // namespace std
#endif
c++/8/profile/array 0000644 00000021134 15201526705 0007770 0 ustar 00 // Profile array implementation -*- C++ -*-
// Copyright (C) 2012-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file profile/array
* This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_PROFILE_ARRAY
#define _GLIBCXX_PROFILE_ARRAY 1
#pragma GCC system_header
#include <array>
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __profile
{
template<typename _Tp, std::size_t _Nm>
struct array
{
typedef _Tp value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef value_type* iterator;
typedef const value_type* const_iterator;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
// Support for zero-sized arrays mandatory.
typedef _GLIBCXX_STD_C::__array_traits<_Tp, _Nm> _AT_Type;
typename _AT_Type::_Type _M_elems;
// No explicit construct/copy/destroy for aggregate type.
// DR 776.
void
fill(const value_type& __u)
{ std::fill_n(begin(), size(), __u); }
void
swap(array& __other)
noexcept(_AT_Type::_Is_nothrow_swappable::value)
{ std::swap_ranges(begin(), end(), __other.begin()); }
// Iterators.
_GLIBCXX17_CONSTEXPR iterator
begin() noexcept
{ return iterator(data()); }
_GLIBCXX17_CONSTEXPR const_iterator
begin() const noexcept
{ return const_iterator(data()); }
_GLIBCXX17_CONSTEXPR iterator
end() noexcept
{ return iterator(data() + _Nm); }
_GLIBCXX17_CONSTEXPR const_iterator
end() const noexcept
{ return const_iterator(data() + _Nm); }
_GLIBCXX17_CONSTEXPR reverse_iterator
rbegin() noexcept
{ return reverse_iterator(end()); }
_GLIBCXX17_CONSTEXPR const_reverse_iterator
rbegin() const noexcept
{ return const_reverse_iterator(end()); }
_GLIBCXX17_CONSTEXPR reverse_iterator
rend() noexcept
{ return reverse_iterator(begin()); }
_GLIBCXX17_CONSTEXPR const_reverse_iterator
rend() const noexcept
{ return const_reverse_iterator(begin()); }
_GLIBCXX17_CONSTEXPR const_iterator
cbegin() const noexcept
{ return const_iterator(data()); }
_GLIBCXX17_CONSTEXPR const_iterator
cend() const noexcept
{ return const_iterator(data() + _Nm); }
_GLIBCXX17_CONSTEXPR const_reverse_iterator
crbegin() const noexcept
{ return const_reverse_iterator(end()); }
_GLIBCXX17_CONSTEXPR const_reverse_iterator
crend() const noexcept
{ return const_reverse_iterator(begin()); }
// Capacity.
constexpr size_type
size() const noexcept { return _Nm; }
constexpr size_type
max_size() const noexcept { return _Nm; }
constexpr bool
empty() const noexcept { return size() == 0; }
// Element access.
reference
operator[](size_type __n) noexcept
{ return _AT_Type::_S_ref(_M_elems, __n); }
constexpr const_reference
operator[](size_type __n) const noexcept
{ return _AT_Type::_S_ref(_M_elems, __n); }
_GLIBCXX17_CONSTEXPR reference
at(size_type __n)
{
if (__n >= _Nm)
std::__throw_out_of_range_fmt(__N("array::at: __n "
"(which is %zu) >= _Nm "
"(which is %zu)"),
__n, _Nm);
return _AT_Type::_S_ref(_M_elems, __n);
}
constexpr const_reference
at(size_type __n) const
{
// Result of conditional expression must be an lvalue so use
// boolean ? lvalue : (throw-expr, lvalue)
return __n < _Nm ? _AT_Type::_S_ref(_M_elems, __n)
: (std::__throw_out_of_range_fmt(__N("array::at: __n (which is %zu) "
">= _Nm (which is %zu)"),
__n, _Nm),
_AT_Type::_S_ref(_M_elems, 0));
}
_GLIBCXX17_CONSTEXPR reference
front() noexcept
{ return *begin(); }
constexpr const_reference
front() const noexcept
{ return _AT_Type::_S_ref(_M_elems, 0); }
_GLIBCXX17_CONSTEXPR reference
back() noexcept
{ return _Nm ? *(end() - 1) : *end(); }
constexpr const_reference
back() const noexcept
{
return _Nm ? _AT_Type::_S_ref(_M_elems, _Nm - 1)
: _AT_Type::_S_ref(_M_elems, 0);
}
_GLIBCXX17_CONSTEXPR pointer
data() noexcept
{ return _AT_Type::_S_ptr(_M_elems); }
_GLIBCXX17_CONSTEXPR const_pointer
data() const noexcept
{ return _AT_Type::_S_ptr(_M_elems); }
};
// Array comparisons.
template<typename _Tp, std::size_t _Nm>
inline bool
operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
{ return std::equal(__one.begin(), __one.end(), __two.begin()); }
template<typename _Tp, std::size_t _Nm>
inline bool
operator!=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
{ return !(__one == __two); }
template<typename _Tp, std::size_t _Nm>
inline bool
operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b)
{
return std::lexicographical_compare(__a.begin(), __a.end(),
__b.begin(), __b.end());
}
template<typename _Tp, std::size_t _Nm>
inline bool
operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
{ return __two < __one; }
template<typename _Tp, std::size_t _Nm>
inline bool
operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
{ return !(__one > __two); }
template<typename _Tp, std::size_t _Nm>
inline bool
operator>=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
{ return !(__one < __two); }
// Specialized algorithms.
template<typename _Tp, std::size_t _Nm>
inline void
swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
noexcept(noexcept(__one.swap(__two)))
{ __one.swap(__two); }
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
constexpr _Tp&
get(array<_Tp, _Nm>& __arr) noexcept
{
static_assert(_Int < _Nm, "index is out of bounds");
return _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::
_S_ref(__arr._M_elems, _Int);
}
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
constexpr _Tp&&
get(array<_Tp, _Nm>&& __arr) noexcept
{
static_assert(_Int < _Nm, "index is out of bounds");
return std::move(__profile::get<_Int>(__arr));
}
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
constexpr const _Tp&
get(const array<_Tp, _Nm>& __arr) noexcept
{
static_assert(_Int < _Nm, "index is out of bounds");
return _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::
_S_ref(__arr._M_elems, _Int);
}
} // namespace __profile
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Tuple interface to class template array.
/// tuple_size
template<typename _Tp, std::size_t _Nm>
struct tuple_size<std::__profile::array<_Tp, _Nm>>
: public integral_constant<std::size_t, _Nm> { };
/// tuple_element
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
struct tuple_element<_Int, std::__profile::array<_Tp, _Nm>>
{
static_assert(_Int < _Nm, "index is out of bounds");
typedef _Tp type;
};
template<typename _Tp, std::size_t _Nm>
struct __is_tuple_like_impl<std::__profile::array<_Tp, _Nm>> : true_type
{ };
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // _GLIBCXX_PROFILE_ARRAY
c++/8/profile/ordered_base.h 0000644 00000005330 15201526705 0011516 0 ustar 00 // Profiling unordered containers implementation details -*- C++ -*-
// Copyright (C) 2014-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
/** @file profile/ordered_base.h
* This file is a GNU profile extension to the Standard C++ Library.
*/
#ifndef _GLIBCXX_PROFILE_ORDERED
#define _GLIBCXX_PROFILE_ORDERED 1
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __profile
{
template<typename _Cont>
class _Ordered_profile
{
public:
void
_M_profile_iterate(int __rewind = 0) const
{ __profcxx_map2umap_iterate(this->_M_map2umap_info, __rewind); }
protected:
_Ordered_profile() _GLIBCXX_NOEXCEPT
{ _M_profile_construct(); }
#if __cplusplus >= 201103L
_Ordered_profile(const _Ordered_profile&) noexcept
: _Ordered_profile() { }
_Ordered_profile(_Ordered_profile&& __other) noexcept
: _Ordered_profile()
{ _M_swap(__other); }
_Ordered_profile&
operator=(const _Ordered_profile&) noexcept
{
_M_profile_destruct();
_M_profile_construct();
}
_Ordered_profile&
operator=(_Ordered_profile&& __other) noexcept
{
_M_swap(__other);
__other._M_profile_destruct();
__other._M_profile_construct();
}
#endif
~_Ordered_profile()
{ _M_profile_destruct(); }
void
_M_profile_construct() _GLIBCXX_NOEXCEPT
{ _M_map2umap_info = __profcxx_map2umap_construct(); }
void
_M_profile_destruct() _GLIBCXX_NOEXCEPT
{
__profcxx_map2umap_destruct(_M_map2umap_info);
_M_map2umap_info = 0;
}
void
_M_swap(_Ordered_profile& __other)
{ std::swap(_M_map2umap_info, __other._M_map2umap_info); }
__gnu_profile::__map2umap_info* _M_map2umap_info;
private:
_Cont&
_M_conjure()
{ return *static_cast<_Cont*>(this); }
};
} // namespace __profile
} // namespace std
#endif
c++/8/profile/forward_list 0000644 00000014366 15201526705 0011362 0 ustar 00 // <forward_list> -*- C++ -*-
// Copyright (C) 2010-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file profile/forward_list
* This file is a GNU debug extension to the Standard C++ Library.
*/
#ifndef _GLIBCXX_PROFILE_FORWARD_LIST
#define _GLIBCXX_PROFILE_FORWARD_LIST 1
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
#include <forward_list>
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __profile
{
/// Class std::forward_list wrapper with performance instrumentation.
template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
class forward_list
: public _GLIBCXX_STD_C::forward_list<_Tp, _Alloc>
{
typedef _GLIBCXX_STD_C::forward_list<_Tp, _Alloc> _Base;
public:
typedef typename _Base::size_type size_type;
typedef typename _Base::const_iterator const_iterator;
// 23.2.3.1 construct/copy/destroy:
forward_list() = default;
explicit
forward_list(const _Alloc& __al) noexcept
: _Base(__al) { }
forward_list(const forward_list& __list, const _Alloc& __al)
: _Base(__list, __al)
{ }
forward_list(forward_list&& __list, const _Alloc& __al)
: _Base(std::move(__list), __al)
{ }
explicit
forward_list(size_type __n, const _Alloc& __al = _Alloc())
: _Base(__n, __al)
{ }
forward_list(size_type __n, const _Tp& __value,
const _Alloc& __al = _Alloc())
: _Base(__n, __value, __al)
{ }
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
forward_list(_InputIterator __first, _InputIterator __last,
const _Alloc& __al = _Alloc())
: _Base(__first, __last, __al)
{ }
forward_list(const forward_list&) = default;
forward_list(forward_list&&) = default;
forward_list(std::initializer_list<_Tp> __il,
const _Alloc& __al = _Alloc())
: _Base(__il, __al)
{ }
~forward_list() = default;
forward_list&
operator=(const forward_list&) = default;
forward_list&
operator=(forward_list&&) = default;
forward_list&
operator=(std::initializer_list<_Tp> __il)
{
_M_base() = __il;
return *this;
}
void
swap(forward_list& __fl)
noexcept( noexcept(declval<_Base&>().swap(__fl)) )
{ _Base::swap(__fl); }
void
splice_after(const_iterator __pos, forward_list&& __fl)
{ _Base::splice_after(__pos, std::move(__fl)); }
void
splice_after(const_iterator __pos, forward_list& __list)
{ _Base::splice_after(__pos, __list); }
void
splice_after(const_iterator __pos, forward_list&& __list,
const_iterator __i)
{ _Base::splice_after(__pos, std::move(__list), __i); }
void
splice_after(const_iterator __pos, forward_list& __list,
const_iterator __i)
{ _Base::splice_after(__pos, __list, __i); }
void
splice_after(const_iterator __pos, forward_list&& __list,
const_iterator __before, const_iterator __last)
{ _Base::splice_after(__pos, std::move(__list), __before, __last); }
void
splice_after(const_iterator __pos, forward_list& __list,
const_iterator __before, const_iterator __last)
{ _Base::splice_after(__pos, __list, __before, __last); }
void
merge(forward_list&& __list)
{ _Base::merge(std::move(__list)); }
void
merge(forward_list& __list)
{ _Base::merge(__list); }
template<typename _Comp>
void
merge(forward_list&& __list, _Comp __comp)
{ _Base::merge(std::move(__list), __comp); }
template<typename _Comp>
void
merge(forward_list& __list, _Comp __comp)
{ _Base::merge(__list, __comp); }
_Base&
_M_base() noexcept { return *this; }
const _Base&
_M_base() const noexcept { return *this; }
};
template<typename _Tp, typename _Alloc>
inline bool
operator==(const forward_list<_Tp, _Alloc>& __lx,
const forward_list<_Tp, _Alloc>& __ly)
{ return __lx._M_base() == __ly._M_base(); }
template<typename _Tp, typename _Alloc>
inline bool
operator<(const forward_list<_Tp, _Alloc>& __lx,
const forward_list<_Tp, _Alloc>& __ly)
{ return __lx._M_base() < __ly._M_base(); }
template<typename _Tp, typename _Alloc>
inline bool
operator!=(const forward_list<_Tp, _Alloc>& __lx,
const forward_list<_Tp, _Alloc>& __ly)
{ return !(__lx == __ly); }
/// Based on operator<
template<typename _Tp, typename _Alloc>
inline bool
operator>(const forward_list<_Tp, _Alloc>& __lx,
const forward_list<_Tp, _Alloc>& __ly)
{ return (__ly < __lx); }
/// Based on operator<
template<typename _Tp, typename _Alloc>
inline bool
operator>=(const forward_list<_Tp, _Alloc>& __lx,
const forward_list<_Tp, _Alloc>& __ly)
{ return !(__lx < __ly); }
/// Based on operator<
template<typename _Tp, typename _Alloc>
inline bool
operator<=(const forward_list<_Tp, _Alloc>& __lx,
const forward_list<_Tp, _Alloc>& __ly)
{ return !(__ly < __lx); }
/// See std::forward_list::swap().
template<typename _Tp, typename _Alloc>
inline void
swap(forward_list<_Tp, _Alloc>& __lx,
forward_list<_Tp, _Alloc>& __ly)
noexcept(noexcept(__lx.swap(__ly)))
{ __lx.swap(__ly); }
} // namespace __profile
} // namespace std
#endif // C++11
#endif
c++/8/profile/multimap.h 0000644 00000045606 15201526705 0010742 0 ustar 00 // Profiling multimap implementation -*- C++ -*-
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file profile/multimap.h
* This file is a GNU profile extension to the Standard C++ Library.
*/
#ifndef _GLIBCXX_PROFILE_MULTIMAP_H
#define _GLIBCXX_PROFILE_MULTIMAP_H 1
#include <profile/base.h>
#include <profile/ordered_base.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __profile
{
/// Class std::multimap wrapper with performance instrumentation.
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Allocator = std::allocator<std::pair<const _Key, _Tp> > >
class multimap
: public _GLIBCXX_STD_C::multimap<_Key, _Tp, _Compare, _Allocator>,
public _Ordered_profile<map<_Key, _Tp, _Compare, _Allocator> >
{
typedef _GLIBCXX_STD_C::multimap<_Key, _Tp, _Compare, _Allocator> _Base;
typedef typename _Base::iterator _Base_iterator;
typedef typename _Base::const_iterator _Base_const_iterator;
public:
// types:
typedef _Key key_type;
typedef _Tp mapped_type;
typedef std::pair<const _Key, _Tp> value_type;
typedef _Compare key_compare;
typedef typename _Base::reference reference;
typedef typename _Base::const_reference const_reference;
typedef __iterator_tracker<_Base_iterator,
multimap> iterator;
typedef __iterator_tracker<_Base_const_iterator,
multimap> const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
typedef typename _Base::size_type size_type;
typedef typename _Base::difference_type difference_type;
// 23.3.1.1 construct/copy/destroy:
#if __cplusplus < 201103L
multimap()
: _Base() { }
multimap(const multimap& __x)
: _Base(__x) { }
~multimap() { }
#else
multimap() = default;
multimap(const multimap&) = default;
multimap(multimap&&) = default;
~multimap() = default;
#endif
explicit multimap(const _Compare& __comp,
const _Allocator& __a = _Allocator())
: _Base(__comp, __a) { }
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
#else
template<typename _InputIterator>
#endif
multimap(_InputIterator __first, _InputIterator __last,
const _Compare& __comp = _Compare(),
const _Allocator& __a = _Allocator())
: _Base(__first, __last, __comp, __a) { }
#if __cplusplus >= 201103L
multimap(initializer_list<value_type> __l,
const _Compare& __c = _Compare(),
const _Allocator& __a = _Allocator())
: _Base(__l, __c, __a) { }
explicit
multimap(const _Allocator& __a)
: _Base(__a) { }
multimap(const multimap& __x, const _Allocator& __a)
: _Base(__x, __a) { }
multimap(multimap&& __x, const _Allocator& __a)
noexcept( noexcept(_Base(std::move(__x), __a)) )
: _Base(std::move(__x), __a) { }
multimap(initializer_list<value_type> __l, const _Allocator& __a)
: _Base(__l, __a) { }
template<typename _InputIterator>
multimap(_InputIterator __first, _InputIterator __last,
const _Allocator& __a)
: _Base(__first, __last, __a) { }
#endif
multimap(const _Base& __x)
: _Base(__x) { }
#if __cplusplus < 201103L
multimap&
operator=(const multimap& __x)
{
this->_M_profile_destruct();
_M_base() = __x;
this->_M_profile_construct();
return *this;
}
#else
multimap&
operator=(const multimap&) = default;
multimap&
operator=(multimap&&) = default;
multimap&
operator=(initializer_list<value_type> __l)
{
this->_M_profile_destruct();
_M_base() = __l;
this->_M_profile_construct();
return *this;
}
#endif
// iterators
iterator
begin() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::begin(), this); }
const_iterator
begin() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::begin(), this); }
iterator
end() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::end(), this); }
const_iterator
end() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::end(), this); }
#if __cplusplus >= 201103L
const_iterator
cbegin() const noexcept
{ return const_iterator(_Base::cbegin(), this); }
const_iterator
cend() const noexcept
{ return const_iterator(_Base::cend(), this); }
#endif
reverse_iterator
rbegin() _GLIBCXX_NOEXCEPT
{
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return reverse_iterator(end());
}
const_reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT
{
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(end());
}
reverse_iterator
rend() _GLIBCXX_NOEXCEPT
{
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return reverse_iterator(begin());
}
const_reverse_iterator
rend() const _GLIBCXX_NOEXCEPT
{
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(begin());
}
#if __cplusplus >= 201103L
const_reverse_iterator
crbegin() const noexcept
{
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(cend());
}
const_reverse_iterator
crend() const noexcept
{
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(cbegin());
}
#endif
// modifiers:
#if __cplusplus >= 201103L
template<typename... _Args>
iterator
emplace(_Args&&... __args)
{
__profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
return iterator(_Base::emplace(std::forward<_Args>(__args)...), this);
}
template<typename... _Args>
iterator
emplace_hint(const_iterator __pos, _Args&&... __args)
{
auto size_before = this->size();
auto __res
= _Base::emplace_hint(__pos.base(), std::forward<_Args>(__args)...);
__profcxx_map2umap_insert(this->_M_map2umap_info,
size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
return iterator(__res, this);
}
#endif
iterator
insert(const value_type& __x)
{
__profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
return iterator(_Base::insert(__x), this);
}
#if __cplusplus >= 201103L
template<typename _Pair, typename = typename
std::enable_if<std::is_constructible<value_type,
_Pair&&>::value>::type>
iterator
insert(_Pair&& __x)
{
__profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
return iterator(_Base::insert(std::forward<_Pair>(__x)), this);
}
#endif
#if __cplusplus >= 201103L
void
insert(std::initializer_list<value_type> __list)
{ insert(__list.begin(), __list.end()); }
#endif
iterator
#if __cplusplus >= 201103L
insert(const_iterator __pos, const value_type& __x)
#else
insert(iterator __pos, const value_type& __x)
#endif
{
size_type size_before = this->size();
_Base_iterator __res = _Base::insert(__pos.base(), __x);
__profcxx_map2umap_insert(this->_M_map2umap_info,
size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
return iterator(__res, this);
}
#if __cplusplus >= 201103L
template<typename _Pair, typename = typename
std::enable_if<std::is_constructible<value_type,
_Pair&&>::value>::type>
iterator
insert(const_iterator __pos, _Pair&& __x)
{
size_type size_before = this->size();
auto __res = _Base::insert(__pos.base(), std::forward<_Pair>(__x));
__profcxx_map2umap_insert(this->_M_map2umap_info,
size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
return iterator(__res, this);
}
#endif
template<typename _InputIterator>
void
insert(_InputIterator __first, _InputIterator __last)
{
for (; __first != __last; ++__first)
insert(*__first);
}
#if __cplusplus >= 201103L
iterator
erase(const_iterator __pos)
{
__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
return iterator(_Base::erase(__pos.base()), this);
}
iterator
erase(iterator __pos)
{
__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
return iterator(_Base::erase(__pos.base()), this);
}
#else
void
erase(iterator __pos)
{
__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
_Base::erase(__pos.base());
}
#endif
size_type
erase(const key_type& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
return _Base::erase(__x);
}
#if __cplusplus >= 201103L
iterator
erase(const_iterator __first, const_iterator __last)
{
if (__first != __last)
{
iterator __ret;
for (; __first != __last;)
__ret = erase(__first++);
return __ret;
}
else
return iterator(_Base::erase(__first.base(), __last.base()), this);
}
#else
void
erase(iterator __first, iterator __last)
{
for (; __first != __last;)
erase(__first++);
}
#endif
void
swap(multimap& __x)
_GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
{
std::swap(this->_M_map2umap_info, __x._M_map2umap_info);
_Base::swap(__x);
}
void
clear() _GLIBCXX_NOEXCEPT
{
this->_M_profile_destruct();
_Base::clear();
this->_M_profile_construct();
}
// 23.3.1.3 multimap operations:
iterator
find(const key_type& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return iterator(_Base::find(__x), this);
}
#if __cplusplus > 201103L
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
iterator
find(const _Kt& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return { _Base::find(__x), this };
}
#endif
const_iterator
find(const key_type& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return const_iterator(_Base::find(__x), this);
}
#if __cplusplus > 201103L
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
const_iterator
find(const _Kt& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return { _Base::find(__x), this };
}
#endif
size_type
count(const key_type& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return _Base::count(__x);
}
#if __cplusplus > 201103L
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
size_type
count(const _Kt& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return _Base::count(__x);
}
#endif
iterator
lower_bound(const key_type& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return iterator(_Base::lower_bound(__x), this);
}
#if __cplusplus > 201103L
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
iterator
lower_bound(const _Kt& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return { _Base::lower_bound(__x), this };
}
#endif
const_iterator
lower_bound(const key_type& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_iterator(_Base::lower_bound(__x), this);
}
#if __cplusplus > 201103L
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
const_iterator
lower_bound(const _Kt& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return { _Base::lower_bound(__x), this };
}
#endif
iterator
upper_bound(const key_type& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return iterator(_Base::upper_bound(__x), this);
}
#if __cplusplus > 201103L
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
iterator
upper_bound(const _Kt& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return { _Base::upper_bound(__x), this };
}
#endif
const_iterator
upper_bound(const key_type& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_iterator(_Base::upper_bound(__x), this);
}
#if __cplusplus > 201103L
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
const_iterator
upper_bound(const _Kt& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return { _Base::upper_bound(__x), this };
}
#endif
std::pair<iterator,iterator>
equal_range(const key_type& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
std::pair<_Base_iterator, _Base_iterator> __base_ret
= _Base::equal_range(__x);
return std::make_pair(iterator(__base_ret.first, this),
iterator(__base_ret.second, this));
}
#if __cplusplus > 201103L
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
std::pair<iterator, iterator>
equal_range(const _Kt& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
auto __res = _Base::equal_range(__x);
return { { __res.first, this }, { __res.second, this } };
}
#endif
std::pair<const_iterator,const_iterator>
equal_range(const key_type& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
std::pair<_Base_const_iterator, _Base_const_iterator> __base_ret
= _Base::equal_range(__x);
return std::make_pair(const_iterator(__base_ret.first, this),
const_iterator(__base_ret.second, this));
}
#if __cplusplus > 201103L
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
std::pair<const_iterator, const_iterator>
equal_range(const _Kt& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
auto __res = _Base::equal_range(__x);
return { { __res.first, this }, { __res.second, this } };
}
#endif
_Base&
_M_base() _GLIBCXX_NOEXCEPT { return *this; }
const _Base&
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
private:
/** If hint is used we consider that the map and unordered_map
* operations have equivalent insertion cost so we do not update metrics
* about it.
* Note that to find out if hint has been used is libstdc++
* implementation dependent.
*/
bool
_M_hint_used(_Base_const_iterator __hint, _Base_iterator __res)
{
return (__hint == __res
|| (__hint == _M_base().end() && ++__res == _M_base().end())
|| (__hint != _M_base().end() && (++__hint == __res
|| ++__res == --__hint)));
}
template<typename _K1, typename _T1, typename _C1, typename _A1>
friend bool
operator==(const multimap<_K1, _T1, _C1, _A1>&,
const multimap<_K1, _T1, _C1, _A1>&);
template<typename _K1, typename _T1, typename _C1, typename _A1>
friend bool
operator<(const multimap<_K1, _T1, _C1, _A1>&,
const multimap<_K1, _T1, _C1, _A1>&);
};
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>
inline bool
operator==(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
{
__profcxx_map2umap_invalidate(__lhs._M_map2umap_info);
__profcxx_map2umap_invalidate(__rhs._M_map2umap_info);
return __lhs._M_base() == __rhs._M_base();
}
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>
inline bool
operator<(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
{
__profcxx_map2umap_invalidate(__lhs._M_map2umap_info);
__profcxx_map2umap_invalidate(__rhs._M_map2umap_info);
return __lhs._M_base() < __rhs._M_base();
}
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>
inline bool
operator!=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
{ return !(__lhs == __rhs); }
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>
inline bool
operator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
{ return !(__rhs < __lhs); }
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>
inline bool
operator>=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
{ return !(__lhs < __rhs); }
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>
inline bool
operator>(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
{ return __rhs < __lhs; }
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>
inline void
swap(multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
_GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
{ __lhs.swap(__rhs); }
} // namespace __profile
} // namespace std
#endif
c++/8/profile/map 0000644 00000002336 15201526705 0007432 0 ustar 00 // Profiling map/multimap implementation -*- C++ -*-
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
/** @file profile/map
* This file is a GNU profile extension to the Standard C++ Library.
*/
#ifndef _GLIBCXX_PROFILE_MAP
#define _GLIBCXX_PROFILE_MAP 1
#include <map>
#include <profile/map.h>
#include <profile/multimap.h>
#endif
c++/8/profile/unordered_base.h 0000644 00000021634 15201526705 0012066 0 ustar 00 // Profiling unordered containers implementation details -*- C++ -*-
// Copyright (C) 2013-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
/** @file profile/unordered_base.h
* This file is a GNU profile extension to the Standard C++ Library.
*/
#ifndef _GLIBCXX_PROFILE_UNORDERED
#define _GLIBCXX_PROFILE_UNORDERED 1
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __profile
{
template<typename _UnorderedCont,
typename _Value, bool _Cache_hash_code>
struct _Bucket_index_helper;
template<typename _UnorderedCont, typename _Value>
struct _Bucket_index_helper<_UnorderedCont, _Value, true>
{
static std::size_t
bucket(const _UnorderedCont& __uc,
const __detail::_Hash_node<_Value, true>* __node)
{ return __node->_M_hash_code % __uc.bucket_count(); }
};
template<typename _UnorderedCont, typename _Value>
struct _Bucket_index_helper<_UnorderedCont, _Value, false>
{
static std::size_t
bucket(const _UnorderedCont& __uc,
const __detail::_Hash_node<_Value, false>* __node)
{ return __uc.bucket(__node->_M_v()); }
};
template<typename _UnorderedCont, typename _Key, typename _Mapped>
struct _Bucket_index_helper<_UnorderedCont,
std::pair<const _Key, _Mapped>, false>
{
typedef std::pair<const _Key, _Mapped> _Value;
static std::size_t
bucket(const _UnorderedCont& __uc,
const __detail::_Hash_node<_Value, false>* __node)
{ return __uc.bucket(__node->_M_v().first); }
};
template<typename _UnorderedCont, typename _Value, bool _Cache_hash_code>
std::size_t
__get_bucket_index(const _UnorderedCont& __uc,
const __detail::_Hash_node<_Value, _Cache_hash_code>* __node)
{
using __bucket_index_helper
= _Bucket_index_helper<_UnorderedCont, _Value, _Cache_hash_code>;
return __bucket_index_helper::bucket(__uc, __node);
}
template<typename _UnorderedCont,
typename _Value, bool _Cache_hash_code>
struct _Equal_helper;
template<typename _UnorderedCont, typename _Value>
struct _Equal_helper<_UnorderedCont, _Value, true>
{
static std::size_t
are_equal(const _UnorderedCont& __uc,
const __detail::_Hash_node<_Value, true>* __lhs,
const __detail::_Hash_node<_Value, true>* __rhs)
{
return __lhs->_M_hash_code == __rhs->_M_hash_code
&& __uc.key_eq()(__lhs->_M_v(), __rhs->_M_v());
}
};
template<typename _UnorderedCont,
typename _Value>
struct _Equal_helper<_UnorderedCont, _Value, false>
{
static std::size_t
are_equal(const _UnorderedCont& __uc,
const __detail::_Hash_node<_Value, false>* __lhs,
const __detail::_Hash_node<_Value, false>* __rhs)
{ return __uc.key_eq()(__lhs->_M_v(), __rhs->_M_v()); }
};
template<typename _UnorderedCont,
typename _Key, typename _Mapped>
struct _Equal_helper<_UnorderedCont, std::pair<const _Key, _Mapped>, true>
{
typedef std::pair<const _Key, _Mapped> _Value;
static std::size_t
are_equal(const _UnorderedCont& __uc,
const __detail::_Hash_node<_Value, true>* __lhs,
const __detail::_Hash_node<_Value, true>* __rhs)
{
return __lhs->_M_hash_code == __rhs->_M_hash_code
&& __uc.key_eq()(__lhs->_M_v().first, __rhs->_M_v().first);
}
};
template<typename _UnorderedCont,
typename _Key, typename _Mapped>
struct _Equal_helper<_UnorderedCont, std::pair<const _Key, _Mapped>, false>
{
typedef std::pair<const _Key, _Mapped> _Value;
static std::size_t
are_equal(const _UnorderedCont& __uc,
const __detail::_Hash_node<_Value, false>* __lhs,
const __detail::_Hash_node<_Value, false>* __rhs)
{ return __uc.key_eq()(__lhs->_M_v().first, __rhs->_M_v().first); }
};
template<typename _UnorderedCont, typename _Value, bool _Cache_hash_code>
bool
__are_equal(const _UnorderedCont& __uc,
const __detail::_Hash_node<_Value, _Cache_hash_code>* __lhs,
const __detail::_Hash_node<_Value, _Cache_hash_code>* __rhs)
{
using __equal_helper
= _Equal_helper<_UnorderedCont, _Value, _Cache_hash_code>;
return __equal_helper::are_equal(__uc, __lhs, __rhs);
}
template<typename _UnorderedCont, bool _Unique_keys>
class _Unordered_profile
{
_UnorderedCont&
_M_conjure()
{ return *(static_cast<_UnorderedCont*>(this)); }
using __unique_keys = std::integral_constant<bool, _Unique_keys>;
protected:
_Unordered_profile() noexcept
{ _M_profile_construct(); }
_Unordered_profile(const _Unordered_profile&) noexcept
: _Unordered_profile() { }
_Unordered_profile(_Unordered_profile&& __other) noexcept
: _Unordered_profile()
{ _M_swap(__other); }
~_Unordered_profile()
{ _M_profile_destruct(); }
_Unordered_profile&
operator=(const _Unordered_profile&) noexcept
{
// Assignment just reset profiling.
_M_profile_destruct();
_M_profile_construct();
}
_Unordered_profile&
operator=(_Unordered_profile&& __other) noexcept
{
// Take profiling of the moved instance...
_M_swap(__other);
// ...and then reset other instance profiling.
__other._M_profile_destruct();
__other._M_profile_construct();
}
void
_M_profile_construct() noexcept
{
auto& __uc = _M_conjure();
_M_size_info = __profcxx_hashtable_size_construct(__uc.bucket_count());
_M_hashfunc_info = __profcxx_hash_func_construct();
}
void
_M_profile_destruct() noexcept
{
auto& __uc = _M_conjure();
__profcxx_hashtable_size_destruct(_M_size_info,
__uc.bucket_count(), __uc.size());
_M_size_info = 0;
if (!_M_hashfunc_info)
return;
_M_profile_destruct(__unique_keys());
_M_hashfunc_info = 0;
}
void
_M_swap(_Unordered_profile& __other) noexcept
{
std::swap(_M_size_info, __other._M_size_info);
std::swap(_M_hashfunc_info, __other._M_hashfunc_info);
}
void
_M_profile_resize(std::size_t __old_size)
{
auto __new_size = _M_conjure().bucket_count();
if (__old_size != __new_size)
__profcxx_hashtable_size_resize(_M_size_info, __old_size, __new_size);
}
__gnu_profile::__container_size_info* _M_size_info;
__gnu_profile::__hashfunc_info* _M_hashfunc_info;
private:
void
_M_profile_destruct(std::true_type);
void
_M_profile_destruct(std::false_type);
};
template<typename _UnorderedCont, bool _Unique_keys>
void
_Unordered_profile<_UnorderedCont, _Unique_keys>::
_M_profile_destruct(std::true_type)
{
auto& __uc = _M_conjure();
std::size_t __hops = 0, __lc = 0, __chain = 0;
auto __it = __uc.begin();
while (__it != __uc.end())
{
auto __bkt = __get_bucket_index(__uc, __it._M_cur);
auto __lit = __uc.begin(__bkt);
auto __lend = __uc.end(__bkt);
for (++__it, ++__lit; __lit != __lend; ++__it, ++__lit)
++__chain;
if (__chain)
{
++__chain;
__lc = __lc > __chain ? __lc : __chain;
__hops += __chain * (__chain - 1) / 2;
__chain = 0;
}
}
__profcxx_hash_func_destruct(_M_hashfunc_info,
__lc, __uc.size(), __hops);
}
template<typename _UnorderedCont, bool _Unique_keys>
void
_Unordered_profile<_UnorderedCont, _Unique_keys>::
_M_profile_destruct(std::false_type)
{
auto& __uc = _M_conjure();
std::size_t __hops = 0, __lc = 0, __chain = 0, __unique_size = 0;
auto __it = __uc.begin();
while (__it != __uc.end())
{
auto __bkt = __get_bucket_index(__uc, __it._M_cur);
auto __lit = __uc.begin(__bkt);
auto __lend = __uc.end(__bkt);
auto __pit = __it;
++__unique_size;
for (++__it, ++__lit; __lit != __lend; ++__it, ++__lit)
{
if (!__are_equal(__uc, __pit._M_cur, __it._M_cur))
{
++__chain;
++__unique_size;
__pit = __it;
}
}
if (__chain)
{
++__chain;
__lc = __lc > __chain ? __lc : __chain;
__hops += __chain * (__chain - 1) / 2;
__chain = 0;
}
}
__profcxx_hash_func_destruct(_M_hashfunc_info,
__lc, __unique_size, __hops);
}
} // namespace __profile
} // namespace std
#endif
c++/8/profile/set 0000644 00000002336 15201526705 0007450 0 ustar 00 // Profiling set/multiset implementation -*- C++ -*-
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
/** @file profile/set
* This file is a GNU profile extension to the Standard C++ Library.
*/
#ifndef _GLIBCXX_PROFILE_SET
#define _GLIBCXX_PROFILE_SET 1
#include <set>
#include <profile/set.h>
#include <profile/multiset.h>
#endif
c++/8/profile/iterator_tracker.h 0000644 00000022522 15201526705 0012446 0 ustar 00 // Profiling iterator implementation -*- C++ -*-
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file profile/iterator_tracker.h
* This file is a GNU profile extension to the Standard C++ Library.
*/
#ifndef _GLIBCXX_PROFILE_ITERATOR_TRACKER
#define _GLIBCXX_PROFILE_ITERATOR_TRACKER 1
#include <ext/type_traits.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __profile
{
template<typename _Iterator, typename _Sequence>
class __iterator_tracker
{
typedef __iterator_tracker _Self;
// The underlying iterator
_Iterator _M_current;
// The underlying data structure
const _Sequence* _M_ds;
typedef std::iterator_traits<_Iterator> _Traits;
public:
typedef _Iterator _Base_iterator;
typedef typename _Traits::iterator_category iterator_category;
typedef typename _Traits::value_type value_type;
typedef typename _Traits::difference_type difference_type;
typedef typename _Traits::reference reference;
typedef typename _Traits::pointer pointer;
__iterator_tracker() _GLIBCXX_NOEXCEPT
: _M_current(), _M_ds(0) { }
__iterator_tracker(const _Iterator& __i, const _Sequence* __seq)
_GLIBCXX_NOEXCEPT
: _M_current(__i), _M_ds(__seq) { }
__iterator_tracker(const __iterator_tracker& __x) _GLIBCXX_NOEXCEPT
: _M_current(__x._M_current), _M_ds(__x._M_ds) { }
template<typename _MutableIterator>
__iterator_tracker(const __iterator_tracker<_MutableIterator,
typename __gnu_cxx::__enable_if
<(std::__are_same<_MutableIterator, typename
_Sequence::iterator::_Base_iterator>::__value),
_Sequence>::__type>& __x) _GLIBCXX_NOEXCEPT
: _M_current(__x.base()), _M_ds(__x._M_get_sequence()) { }
_Iterator
base() const _GLIBCXX_NOEXCEPT { return _M_current; }
/**
* @brief Conversion to underlying non-debug iterator to allow
* better interaction with non-profile containers.
*/
operator _Iterator() const _GLIBCXX_NOEXCEPT { return _M_current; }
pointer
operator->() const _GLIBCXX_NOEXCEPT { return &*_M_current; }
__iterator_tracker&
operator++() _GLIBCXX_NOEXCEPT
{
_M_ds->_M_profile_iterate();
++_M_current;
return *this;
}
__iterator_tracker
operator++(int) _GLIBCXX_NOEXCEPT
{
_M_ds->_M_profile_iterate();
__iterator_tracker __tmp(*this);
++_M_current;
return __tmp;
}
__iterator_tracker&
operator--() _GLIBCXX_NOEXCEPT
{
_M_ds->_M_profile_iterate(1);
--_M_current;
return *this;
}
__iterator_tracker
operator--(int) _GLIBCXX_NOEXCEPT
{
_M_ds->_M_profile_iterate(1);
__iterator_tracker __tmp(*this);
--_M_current;
return __tmp;
}
__iterator_tracker&
operator=(const __iterator_tracker& __x) _GLIBCXX_NOEXCEPT
{
_M_current = __x._M_current;
_M_ds = __x._M_ds;
return *this;
}
reference
operator*() const _GLIBCXX_NOEXCEPT
{ return *_M_current; }
// ------ Random access iterator requirements ------
reference
operator[](const difference_type& __n) const _GLIBCXX_NOEXCEPT
{ return _M_current[__n]; }
__iterator_tracker&
operator+=(const difference_type& __n) _GLIBCXX_NOEXCEPT
{
_M_current += __n;
return *this;
}
__iterator_tracker
operator+(const difference_type& __n) const _GLIBCXX_NOEXCEPT
{
__iterator_tracker __tmp(*this);
__tmp += __n;
return __tmp;
}
__iterator_tracker&
operator-=(const difference_type& __n) _GLIBCXX_NOEXCEPT
{
_M_current += -__n;
return *this;
}
__iterator_tracker
operator-(const difference_type& __n) const _GLIBCXX_NOEXCEPT
{
__iterator_tracker __tmp(*this);
__tmp -= __n;
return __tmp;
}
const _Sequence*
_M_get_sequence() const
{ return static_cast<const _Sequence*>(_M_ds); }
};
template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline bool
operator==(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
_GLIBCXX_NOEXCEPT
{ return __lhs.base() == __rhs.base(); }
template<typename _Iterator, typename _Sequence>
inline bool
operator==(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
const __iterator_tracker<_Iterator, _Sequence>& __rhs)
_GLIBCXX_NOEXCEPT
{ return __lhs.base() == __rhs.base(); }
template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline bool
operator!=(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
_GLIBCXX_NOEXCEPT
{ return __lhs.base() != __rhs.base(); }
template<typename _Iterator, typename _Sequence>
inline bool
operator!=(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
const __iterator_tracker<_Iterator, _Sequence>& __rhs)
_GLIBCXX_NOEXCEPT
{ return __lhs.base() != __rhs.base(); }
template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline bool
operator<(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
_GLIBCXX_NOEXCEPT
{ return __lhs.base() < __rhs.base(); }
template<typename _Iterator, typename _Sequence>
inline bool
operator<(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
const __iterator_tracker<_Iterator, _Sequence>& __rhs)
_GLIBCXX_NOEXCEPT
{ return __lhs.base() < __rhs.base(); }
template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline bool
operator<=(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
_GLIBCXX_NOEXCEPT
{ return __lhs.base() <= __rhs.base(); }
template<typename _Iterator, typename _Sequence>
inline bool
operator<=(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
const __iterator_tracker<_Iterator, _Sequence>& __rhs)
_GLIBCXX_NOEXCEPT
{ return __lhs.base() <= __rhs.base(); }
template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline bool
operator>(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
_GLIBCXX_NOEXCEPT
{ return __lhs.base() > __rhs.base(); }
template<typename _Iterator, typename _Sequence>
inline bool
operator>(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
const __iterator_tracker<_Iterator, _Sequence>& __rhs)
_GLIBCXX_NOEXCEPT
{ return __lhs.base() > __rhs.base(); }
template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline bool
operator>=(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
_GLIBCXX_NOEXCEPT
{ return __lhs.base() >= __rhs.base(); }
template<typename _Iterator, typename _Sequence>
inline bool
operator>=(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
const __iterator_tracker<_Iterator, _Sequence>& __rhs)
_GLIBCXX_NOEXCEPT
{ return __lhs.base() >= __rhs.base(); }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// According to the resolution of DR179 not only the various comparison
// operators but also operator- must accept mixed iterator/const_iterator
// parameters.
template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline typename __iterator_tracker<_IteratorL, _Sequence>::difference_type
operator-(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
_GLIBCXX_NOEXCEPT
{ return __lhs.base() - __rhs.base(); }
template<typename _Iterator, typename _Sequence>
inline typename __iterator_tracker<_Iterator, _Sequence>::difference_type
operator-(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
const __iterator_tracker<_Iterator, _Sequence>& __rhs)
_GLIBCXX_NOEXCEPT
{ return __lhs.base() - __rhs.base(); }
template<typename _Iterator, typename _Sequence>
inline __iterator_tracker<_Iterator, _Sequence>
operator+(typename __iterator_tracker<_Iterator,_Sequence>::difference_type
__n,
const __iterator_tracker<_Iterator, _Sequence>& __i)
_GLIBCXX_NOEXCEPT
{ return __i + __n; }
} // namespace __profile
} // namespace std
#endif
c++/8/profile/multiset.h 0000644 00000044741 15201526705 0010757 0 ustar 00 // Profiling multiset implementation -*- C++ -*-
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file profile/multiset.h
* This file is a GNU profile extension to the Standard C++ Library.
*/
#ifndef _GLIBCXX_PROFILE_MULTISET_H
#define _GLIBCXX_PROFILE_MULTISET_H 1
#include <profile/base.h>
#include <profile/ordered_base.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __profile
{
/// Class std::multiset wrapper with performance instrumentation.
template<typename _Key, typename _Compare = std::less<_Key>,
typename _Allocator = std::allocator<_Key> >
class multiset
: public _GLIBCXX_STD_C::multiset<_Key, _Compare, _Allocator>,
public _Ordered_profile<multiset<_Key, _Compare, _Allocator> >
{
typedef _GLIBCXX_STD_C::multiset<_Key, _Compare, _Allocator> _Base;
typedef typename _Base::iterator _Base_iterator;
typedef typename _Base::const_iterator _Base_const_iterator;
public:
// types:
typedef _Key key_type;
typedef _Key value_type;
typedef _Compare key_compare;
typedef _Compare value_compare;
typedef _Allocator allocator_type;
typedef typename _Base::reference reference;
typedef typename _Base::const_reference const_reference;
typedef __iterator_tracker<_Base_iterator,
multiset> iterator;
typedef __iterator_tracker<_Base_const_iterator,
multiset> const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
typedef typename _Base::size_type size_type;
typedef typename _Base::difference_type difference_type;
// 23.3.3.1 construct/copy/destroy:
#if __cplusplus < 201103L
multiset()
: _Base() { }
multiset(const multiset& __x)
: _Base(__x) { }
~multiset() { }
#else
multiset() = default;
multiset(const multiset&) = default;
multiset(multiset&&) = default;
~multiset() = default;
#endif
explicit multiset(const _Compare& __comp,
const _Allocator& __a = _Allocator())
: _Base(__comp, __a) { }
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
#else
template<typename _InputIterator>
#endif
multiset(_InputIterator __first, _InputIterator __last,
const _Compare& __comp = _Compare(),
const _Allocator& __a = _Allocator())
: _Base(__first, __last, __comp, __a) { }
#if __cplusplus >= 201103L
multiset(initializer_list<value_type> __l,
const _Compare& __comp = _Compare(),
const allocator_type& __a = allocator_type())
: _Base(__l, __comp, __a) { }
explicit
multiset(const allocator_type& __a)
: _Base(__a) { }
multiset(const multiset& __x, const allocator_type& __a)
: _Base(__x, __a) { }
multiset(multiset&& __x, const allocator_type& __a)
noexcept( noexcept(_Base(std::move(__x), __a)) )
: _Base(std::move(__x), __a) { }
multiset(initializer_list<value_type> __l, const allocator_type& __a)
: _Base(__l, __a) { }
template<typename _InputIterator>
multiset(_InputIterator __first, _InputIterator __last,
const allocator_type& __a)
: _Base(__first, __last, __a) { }
#endif
multiset(const _Base& __x)
: _Base(__x) { }
#if __cplusplus < 201103L
multiset&
operator=(const multiset& __x)
{
this->_M_profile_destruct();
_M_base() = __x;
this->_M_profile_construct();
return *this;
}
#else
multiset&
operator=(const multiset&) = default;
multiset&
operator=(multiset&&) = default;
multiset&
operator=(initializer_list<value_type> __l)
{
this->_M_profile_destruct();
_M_base() = __l;
this->_M_profile_construct();
return *this;
}
#endif
// iterators
iterator
begin() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::begin(), this); }
const_iterator
begin() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::begin(), this); }
iterator
end() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::end(), this); }
const_iterator
end() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::end(), this); }
#if __cplusplus >= 201103L
const_iterator
cbegin() const noexcept
{ return const_iterator(_Base::cbegin(), this); }
const_iterator
cend() const noexcept
{ return const_iterator(_Base::cend(), this); }
#endif
reverse_iterator
rbegin() _GLIBCXX_NOEXCEPT
{
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return reverse_iterator(end());
}
const_reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT
{
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(end());
}
reverse_iterator
rend() _GLIBCXX_NOEXCEPT
{
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return reverse_iterator(begin());
}
const_reverse_iterator
rend() const _GLIBCXX_NOEXCEPT
{
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(begin());
}
#if __cplusplus >= 201103L
const_reverse_iterator
crbegin() const noexcept
{
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(cend());
}
const_reverse_iterator
crend() const noexcept
{
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(cbegin());
}
#endif
void
swap(multiset& __x)
_GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
{
_Base::swap(__x);
this->_M_swap(__x);
}
// modifiers:
#if __cplusplus >= 201103L
template<typename... _Args>
iterator
emplace(_Args&&... __args)
{
// The cost is the same whether or not the element is inserted so we
// always report insertion of 1 element.
__profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
return iterator(_Base::emplace(std::forward<_Args>(__args)...), this);
}
template<typename... _Args>
iterator
emplace_hint(const_iterator __pos, _Args&&... __args)
{
auto size_before = this->size();
auto __res
= _Base::emplace_hint(__pos.base(), std::forward<_Args>(__args)...);
__profcxx_map2umap_insert(this->_M_map2umap_info,
size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
return iterator(__res, this);
}
#endif
iterator
insert(const value_type& __x)
{
__profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
return iterator(_Base::insert(__x), this);
}
#if __cplusplus >= 201103L
iterator
insert(value_type&& __x)
{
__profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
return iterator(_Base::insert(std::move(__x)), this);
}
#endif
iterator
insert(const_iterator __pos, const value_type& __x)
{
size_type size_before = this->size();
_Base_iterator __res = _Base::insert(__pos.base(), __x);
__profcxx_map2umap_insert(this->_M_map2umap_info,
size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
return iterator(__res, this);
}
#if __cplusplus >= 201103L
iterator
insert(const_iterator __pos, value_type&& __x)
{
auto size_before = this->size();
auto __res = _Base::insert(__pos.base(), std::move(__x));
__profcxx_map2umap_insert(this->_M_map2umap_info,
size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
return iterator(__res, this);
}
#endif
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
#else
template<typename _InputIterator>
#endif
void
insert(_InputIterator __first, _InputIterator __last)
{
for (; __first != __last; ++__first)
insert(*__first);
}
#if __cplusplus >= 201103L
void
insert(initializer_list<value_type> __l)
{ insert(__l.begin(), __l.end()); }
#endif
#if __cplusplus >= 201103L
iterator
erase(const_iterator __pos)
{
__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
return iterator(_Base::erase(__pos.base()), this);
}
#else
void
erase(iterator __pos)
{
__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
_Base::erase(__pos.base());
}
#endif
size_type
erase(const key_type& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
return _Base::erase(__x);
}
#if __cplusplus >= 201103L
iterator
erase(const_iterator __first, const_iterator __last)
{
if (__first != __last)
{
iterator __ret;
for (; __first != __last;)
__ret = erase(__first++);
return __ret;
}
else
return iterator(_Base::erase(__first.base(), __last.base()), this);
}
#else
void
erase(iterator __first, iterator __last)
{
for (; __first != __last;)
erase(__first++);
}
#endif
void
clear() _GLIBCXX_NOEXCEPT
{
this->_M_profile_destruct();
_Base::clear();
this->_M_profile_construct();
}
size_type
count(const key_type& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return _Base::count(__x);
}
#if __cplusplus > 201103L
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
size_type
count(const _Kt& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return _Base::count(__x);
}
#endif
// multiset operations:
iterator
find(const key_type& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return iterator(_Base::find(__x), this);
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 214. set::find() missing const overload
const_iterator
find(const key_type& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return const_iterator(_Base::find(__x), this);
}
#if __cplusplus > 201103L
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
iterator
find(const _Kt& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return { _Base::find(__x), this };
}
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
const_iterator
find(const _Kt& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return { _Base::find(__x), this };
}
#endif
iterator
lower_bound(const key_type& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return iterator(_Base::lower_bound(__x), this);
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 214. set::find() missing const overload
const_iterator
lower_bound(const key_type& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_iterator(_Base::lower_bound(__x), this);
}
#if __cplusplus > 201103L
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
iterator
lower_bound(const _Kt& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return { _Base::lower_bound(__x), this };
}
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
const_iterator
lower_bound(const _Kt& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return { _Base::lower_bound(__x), this };
}
#endif
iterator
upper_bound(const key_type& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return iterator(_Base::upper_bound(__x), this);
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 214. set::find() missing const overload
const_iterator
upper_bound(const key_type& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_iterator(_Base::upper_bound(__x), this);
}
#if __cplusplus > 201103L
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
iterator
upper_bound(const _Kt& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return { _Base::upper_bound(__x), this };
}
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
const_iterator
upper_bound(const _Kt& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return { _Base::upper_bound(__x), this };
}
#endif
std::pair<iterator,iterator>
equal_range(const key_type& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
std::pair<_Base_iterator, _Base_iterator> __base_ret
= _Base::equal_range(__x);
return std::make_pair(iterator(__base_ret.first, this),
iterator(__base_ret.second, this));
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 214. set::find() missing const overload
std::pair<const_iterator,const_iterator>
equal_range(const key_type& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
std::pair<_Base_const_iterator, _Base_const_iterator> __base_ret
= _Base::equal_range(__x);
return std::make_pair(const_iterator(__base_ret.first, this),
const_iterator(__base_ret.second, this));
}
#if __cplusplus > 201103L
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
std::pair<iterator, iterator>
equal_range(const _Kt& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
auto __res = _Base::equal_range(__x);
return { { __res.first, this }, { __res.second, this } };
}
template<typename _Kt,
typename _Req =
typename __has_is_transparent<_Compare, _Kt>::type>
std::pair<const_iterator, const_iterator>
equal_range(const _Kt& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
auto __res = _Base::equal_range(__x);
return { { __res.first, this }, { __res.second, this } };
}
#endif
_Base&
_M_base() _GLIBCXX_NOEXCEPT { return *this; }
const _Base&
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
private:
/** If hint is used we consider that the map and unordered_map
* operations have equivalent insertion cost so we do not update metrics
* about it.
* Note that to find out if hint has been used is libstdc++
* implementation dependent.
*/
bool
_M_hint_used(_Base_const_iterator __hint, _Base_iterator __res)
{
return (__hint == __res
|| (__hint == _M_base().end() && ++__res == _M_base().end())
|| (__hint != _M_base().end() && (++__hint == __res
|| ++__res == --__hint)));
}
template<typename _K1, typename _C1, typename _A1>
friend bool
operator==(const multiset<_K1, _C1, _A1>&,
const multiset<_K1, _C1, _A1>&);
template<typename _K1, typename _C1, typename _A1>
friend bool
operator< (const multiset<_K1, _C1, _A1>&,
const multiset<_K1, _C1, _A1>&);
};
template<typename _Key, typename _Compare, typename _Allocator>
inline bool
operator==(const multiset<_Key, _Compare, _Allocator>& __lhs,
const multiset<_Key, _Compare, _Allocator>& __rhs)
{
__profcxx_map2umap_invalidate(__lhs._M_map2umap_info);
__profcxx_map2umap_invalidate(__rhs._M_map2umap_info);
return __lhs._M_base() == __rhs._M_base();
}
template<typename _Key, typename _Compare, typename _Allocator>
inline bool
operator<(const multiset<_Key, _Compare, _Allocator>& __lhs,
const multiset<_Key, _Compare, _Allocator>& __rhs)
{
__profcxx_map2umap_invalidate(__lhs._M_map2umap_info);
__profcxx_map2umap_invalidate(__rhs._M_map2umap_info);
return __lhs._M_base() < __rhs._M_base();
}
template<typename _Key, typename _Compare, typename _Allocator>
inline bool
operator!=(const multiset<_Key, _Compare, _Allocator>& __lhs,
const multiset<_Key, _Compare, _Allocator>& __rhs)
{ return !(__lhs == __rhs); }
template<typename _Key, typename _Compare, typename _Allocator>
inline bool
operator<=(const multiset<_Key, _Compare, _Allocator>& __lhs,
const multiset<_Key, _Compare, _Allocator>& __rhs)
{ return !(__rhs < __lhs); }
template<typename _Key, typename _Compare, typename _Allocator>
inline bool
operator>=(const multiset<_Key, _Compare, _Allocator>& __lhs,
const multiset<_Key, _Compare, _Allocator>& __rhs)
{ return !(__lhs < __rhs); }
template<typename _Key, typename _Compare, typename _Allocator>
inline bool
operator>(const multiset<_Key, _Compare, _Allocator>& __lhs,
const multiset<_Key, _Compare, _Allocator>& __rhs)
{ return __rhs < __lhs; }
template<typename _Key, typename _Compare, typename _Allocator>
void
swap(multiset<_Key, _Compare, _Allocator>& __x,
multiset<_Key, _Compare, _Allocator>& __y)
_GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
{ return __x.swap(__y); }
} // namespace __profile
} // namespace std
#endif
c++/8/profile/base.h 0000644 00000003255 15201526705 0010016 0 ustar 00 // -*- C++ -*-
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
/** @file profile/base.h
* @brief Sequential helper functions.
* This file is a GNU profile extension to the Standard C++ Library.
*/
// Written by Lixia Liu
#ifndef _GLIBCXX_PROFILE_BASE_H
#define _GLIBCXX_PROFILE_BASE_H 1
#include <profile/impl/profiler.h>
// Profiling mode namespaces.
/**
* @namespace std::__profile
* @brief GNU profile code, replaces standard behavior with profile behavior.
*/
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __profile { }
}
/**
* @namespace __gnu_profile
* @brief GNU profile code for public use.
*/
namespace __gnu_profile
{
// Import all the profile versions of components in namespace std.
using namespace std::__profile;
}
#endif /* _GLIBCXX_PROFILE_BASE_H */
c++/8/profile/deque 0000644 00000012231 15201526705 0007753 0 ustar 00 // Profiling deque implementation -*- C++ -*-
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file profile/deque
* This file is a GNU profile extension to the Standard C++ Library.
*/
#ifndef _GLIBCXX_PROFILE_DEQUE
#define _GLIBCXX_PROFILE_DEQUE 1
#include <deque>
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __profile
{
/// Class std::deque wrapper with performance instrumentation.
template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
class deque
: public _GLIBCXX_STD_C::deque<_Tp, _Allocator>
{
typedef _GLIBCXX_STD_C::deque<_Tp, _Allocator> _Base;
public:
typedef typename _Base::size_type size_type;
typedef typename _Base::value_type value_type;
// 23.2.1.1 construct/copy/destroy:
#if __cplusplus < 201103L
deque()
: _Base() { }
deque(const deque& __x)
: _Base(__x) { }
~deque() { }
#else
deque() = default;
deque(const deque&) = default;
deque(deque&&) = default;
deque(const deque& __d, const _Allocator& __a)
: _Base(__d, __a) { }
deque(deque&& __d, const _Allocator& __a)
: _Base(std::move(__d), __a) { }
~deque() = default;
deque(initializer_list<value_type> __l,
const _Allocator& __a = _Allocator())
: _Base(__l, __a) { }
#endif
explicit
deque(const _Allocator& __a)
: _Base(__a) { }
#if __cplusplus >= 201103L
explicit
deque(size_type __n, const _Allocator& __a = _Allocator())
: _Base(__n, __a) { }
deque(size_type __n, const _Tp& __value,
const _Allocator& __a = _Allocator())
: _Base(__n, __value, __a) { }
#else
explicit
deque(size_type __n, const _Tp& __value = _Tp(),
const _Allocator& __a = _Allocator())
: _Base(__n, __value, __a) { }
#endif
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
#else
template<typename _InputIterator>
#endif
deque(_InputIterator __first, _InputIterator __last,
const _Allocator& __a = _Allocator())
: _Base(__first, __last, __a)
{ }
deque(const _Base& __x)
: _Base(__x) { }
#if __cplusplus < 201103L
deque&
operator=(const deque& __x)
{
_M_base() = __x;
return *this;
}
#else
deque&
operator=(const deque&) = default;
deque&
operator=(deque&&) = default;
deque&
operator=(initializer_list<value_type> __l)
{
_M_base() = __l;
return *this;
}
#endif
void
swap(deque& __x)
_GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
{ _Base::swap(__x); }
_Base&
_M_base() _GLIBCXX_NOEXCEPT { return *this; }
const _Base&
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
};
template<typename _Tp, typename _Alloc>
inline bool
operator==(const deque<_Tp, _Alloc>& __lhs,
const deque<_Tp, _Alloc>& __rhs)
{ return __lhs._M_base() == __rhs._M_base(); }
template<typename _Tp, typename _Alloc>
inline bool
operator!=(const deque<_Tp, _Alloc>& __lhs,
const deque<_Tp, _Alloc>& __rhs)
{ return __lhs._M_base() != __rhs._M_base(); }
template<typename _Tp, typename _Alloc>
inline bool
operator<(const deque<_Tp, _Alloc>& __lhs,
const deque<_Tp, _Alloc>& __rhs)
{ return __lhs._M_base() < __rhs._M_base(); }
template<typename _Tp, typename _Alloc>
inline bool
operator<=(const deque<_Tp, _Alloc>& __lhs,
const deque<_Tp, _Alloc>& __rhs)
{ return __lhs._M_base() <= __rhs._M_base(); }
template<typename _Tp, typename _Alloc>
inline bool
operator>=(const deque<_Tp, _Alloc>& __lhs,
const deque<_Tp, _Alloc>& __rhs)
{ return __lhs._M_base() >= __rhs._M_base(); }
template<typename _Tp, typename _Alloc>
inline bool
operator>(const deque<_Tp, _Alloc>& __lhs,
const deque<_Tp, _Alloc>& __rhs)
{ return __lhs._M_base() > __rhs._M_base(); }
template<typename _Tp, typename _Alloc>
inline void
swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>& __rhs)
_GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
{ __lhs.swap(__rhs); }
} // namespace __profile
} // namespace std
#endif
c++/8/profile/unordered_map 0000644 00000042210 15201526705 0011474 0 ustar 00 // Profiling unordered_map/unordered_multimap implementation -*- C++ -*-
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
/** @file profile/unordered_map
* This file is a GNU profile extension to the Standard C++ Library.
*/
#ifndef _GLIBCXX_PROFILE_UNORDERED_MAP
#define _GLIBCXX_PROFILE_UNORDERED_MAP 1
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
# include <unordered_map>
#include <profile/base.h>
#include <profile/unordered_base.h>
#define _GLIBCXX_BASE unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>
#define _GLIBCXX_STD_BASE _GLIBCXX_STD_C::_GLIBCXX_BASE
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __profile
{
/// Class std::unordered_map wrapper with performance instrumentation.
template<typename _Key, typename _Tp,
typename _Hash = std::hash<_Key>,
typename _Pred = std::equal_to<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
class unordered_map
: public _GLIBCXX_STD_BASE,
public _Unordered_profile<unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>,
true>
{
typedef typename _GLIBCXX_STD_BASE _Base;
_Base&
_M_base() noexcept { return *this; }
const _Base&
_M_base() const noexcept { return *this; }
public:
typedef typename _Base::size_type size_type;
typedef typename _Base::hasher hasher;
typedef typename _Base::key_equal key_equal;
typedef typename _Base::allocator_type allocator_type;
typedef typename _Base::key_type key_type;
typedef typename _Base::value_type value_type;
typedef typename _Base::difference_type difference_type;
typedef typename _Base::reference reference;
typedef typename _Base::const_reference const_reference;
typedef typename _Base::mapped_type mapped_type;
typedef typename _Base::iterator iterator;
typedef typename _Base::const_iterator const_iterator;
unordered_map() = default;
explicit
unordered_map(size_type __n,
const hasher& __hf = hasher(),
const key_equal& __eql = key_equal(),
const allocator_type& __a = allocator_type())
: _Base(__n, __hf, __eql, __a) { }
template<typename _InputIterator>
unordered_map(_InputIterator __f, _InputIterator __l,
size_type __n = 0,
const hasher& __hf = hasher(),
const key_equal& __eql = key_equal(),
const allocator_type& __a = allocator_type())
: _Base(__f, __l, __n, __hf, __eql, __a) { }
unordered_map(const unordered_map&) = default;
unordered_map(const _Base& __x)
: _Base(__x) { }
unordered_map(unordered_map&&) = default;
explicit
unordered_map(const allocator_type& __a)
: _Base(__a) { }
unordered_map(const unordered_map& __umap,
const allocator_type& __a)
: _Base(__umap, __a) { }
unordered_map(unordered_map&& __umap,
const allocator_type& __a)
: _Base(std::move(__umap._M_base()), __a) { }
unordered_map(initializer_list<value_type> __l,
size_type __n = 0,
const hasher& __hf = hasher(),
const key_equal& __eql = key_equal(),
const allocator_type& __a = allocator_type())
: _Base(__l, __n, __hf, __eql, __a) { }
unordered_map(size_type __n, const allocator_type& __a)
: unordered_map(__n, hasher(), key_equal(), __a)
{ }
unordered_map(size_type __n, const hasher& __hf,
const allocator_type& __a)
: unordered_map(__n, __hf, key_equal(), __a)
{ }
template<typename _InputIterator>
unordered_map(_InputIterator __first, _InputIterator __last,
size_type __n,
const allocator_type& __a)
: unordered_map(__first, __last, __n, hasher(), key_equal(), __a)
{ }
template<typename _InputIterator>
unordered_map(_InputIterator __first, _InputIterator __last,
size_type __n, const hasher& __hf,
const allocator_type& __a)
: unordered_map(__first, __last, __n, __hf, key_equal(), __a)
{ }
unordered_map(initializer_list<value_type> __l,
size_type __n,
const allocator_type& __a)
: unordered_map(__l, __n, hasher(), key_equal(), __a)
{ }
unordered_map(initializer_list<value_type> __l,
size_type __n, const hasher& __hf,
const allocator_type& __a)
: unordered_map(__l, __n, __hf, key_equal(), __a)
{ }
unordered_map&
operator=(const unordered_map&) = default;
unordered_map&
operator=(unordered_map&&) = default;
unordered_map&
operator=(initializer_list<value_type> __l)
{
this->_M_profile_destruct();
_M_base() = __l;
this->_M_profile_construct();
return *this;
}
void
clear() noexcept
{
this->_M_profile_destruct();
_Base::clear();
this->_M_profile_construct();
}
template<typename... _Args>
std::pair<iterator, bool>
emplace(_Args&&... __args)
{
size_type __old_size = _Base::bucket_count();
std::pair<iterator, bool> __res
= _Base::emplace(std::forward<_Args>(__args)...);
this->_M_profile_resize(__old_size);
return __res;
}
template<typename... _Args>
iterator
emplace_hint(const_iterator __it, _Args&&... __args)
{
size_type __old_size = _Base::bucket_count();
iterator __res
= _Base::emplace_hint(__it, std::forward<_Args>(__args)...);
this->_M_profile_resize(__old_size);
return __res;
}
void
insert(std::initializer_list<value_type> __l)
{
size_type __old_size = _Base::bucket_count();
_Base::insert(__l);
this->_M_profile_resize(__old_size);
}
std::pair<iterator, bool>
insert(const value_type& __obj)
{
size_type __old_size = _Base::bucket_count();
std::pair<iterator, bool> __res = _Base::insert(__obj);
this->_M_profile_resize(__old_size);
return __res;
}
iterator
insert(const_iterator __iter, const value_type& __v)
{
size_type __old_size = _Base::bucket_count();
iterator __res = _Base::insert(__iter, __v);
this->_M_profile_resize(__old_size);
return __res;
}
template<typename _Pair, typename = typename
std::enable_if<std::is_constructible<value_type,
_Pair&&>::value>::type>
std::pair<iterator, bool>
insert(_Pair&& __obj)
{
size_type __old_size = _Base::bucket_count();
std::pair<iterator, bool> __res
= _Base::insert(std::forward<_Pair>(__obj));
this->_M_profile_resize(__old_size);
return __res;
}
template<typename _Pair, typename = typename
std::enable_if<std::is_constructible<value_type,
_Pair&&>::value>::type>
iterator
insert(const_iterator __iter, _Pair&& __v)
{
size_type __old_size = _Base::bucket_count();
iterator __res = _Base::insert(__iter, std::forward<_Pair>(__v));
this->_M_profile_resize(__old_size);
return __res;
}
template<typename _InputIter>
void
insert(_InputIter __first, _InputIter __last)
{
size_type __old_size = _Base::bucket_count();
_Base::insert(__first, __last);
this->_M_profile_resize(__old_size);
}
// operator[]
mapped_type&
operator[](const _Key& __k)
{
size_type __old_size = _Base::bucket_count();
mapped_type& __res = _M_base()[__k];
this->_M_profile_resize(__old_size);
return __res;
}
mapped_type&
operator[](_Key&& __k)
{
size_type __old_size = _Base::bucket_count();
mapped_type& __res = _M_base()[std::move(__k)];
this->_M_profile_resize(__old_size);
return __res;
}
void
swap(unordered_map& __x)
noexcept( noexcept(__x._M_base().swap(__x)) )
{
_Base::swap(__x._M_base());
this->_M_swap(__x);
}
void rehash(size_type __n)
{
size_type __old_size = _Base::bucket_count();
_Base::rehash(__n);
this->_M_profile_resize(__old_size);
}
};
template<typename _Key, typename _Tp, typename _Hash,
typename _Pred, typename _Alloc>
inline void
swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
noexcept(noexcept(__x.swap(__y)))
{ __x.swap(__y); }
template<typename _Key, typename _Tp, typename _Hash,
typename _Pred, typename _Alloc>
inline bool
operator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
{ return static_cast<const _GLIBCXX_STD_BASE&>(__x) == __y; }
template<typename _Key, typename _Tp, typename _Hash,
typename _Pred, typename _Alloc>
inline bool
operator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
{ return !(__x == __y); }
#undef _GLIBCXX_BASE
#undef _GLIBCXX_STD_BASE
#define _GLIBCXX_BASE unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>
#define _GLIBCXX_STD_BASE _GLIBCXX_STD_C::_GLIBCXX_BASE
/// Class std::unordered_multimap wrapper with performance instrumentation.
template<typename _Key, typename _Tp,
typename _Hash = std::hash<_Key>,
typename _Pred = std::equal_to<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
class unordered_multimap
: public _GLIBCXX_STD_BASE,
public _Unordered_profile<unordered_multimap<_Key, _Tp,
_Hash, _Pred, _Alloc>,
false>
{
typedef typename _GLIBCXX_STD_BASE _Base;
_Base&
_M_base() noexcept { return *this; }
const _Base&
_M_base() const noexcept { return *this; }
public:
typedef typename _Base::size_type size_type;
typedef typename _Base::hasher hasher;
typedef typename _Base::key_equal key_equal;
typedef typename _Base::allocator_type allocator_type;
typedef typename _Base::key_type key_type;
typedef typename _Base::value_type value_type;
typedef typename _Base::difference_type difference_type;
typedef typename _Base::reference reference;
typedef typename _Base::const_reference const_reference;
typedef typename _Base::iterator iterator;
typedef typename _Base::const_iterator const_iterator;
unordered_multimap() = default;
explicit
unordered_multimap(size_type __n,
const hasher& __hf = hasher(),
const key_equal& __eql = key_equal(),
const allocator_type& __a = allocator_type())
: _Base(__n, __hf, __eql, __a) { }
template<typename _InputIterator>
unordered_multimap(_InputIterator __f, _InputIterator __l,
size_type __n = 0,
const hasher& __hf = hasher(),
const key_equal& __eql = key_equal(),
const allocator_type& __a = allocator_type())
: _Base(__f, __l, __n, __hf, __eql, __a) { }
unordered_multimap(const unordered_multimap&) = default;
unordered_multimap(const _Base& __x)
: _Base(__x) { }
unordered_multimap(unordered_multimap&&) = default;
explicit
unordered_multimap(const allocator_type& __a)
: _Base(__a) { }
unordered_multimap(const unordered_multimap& __ummap,
const allocator_type& __a)
: _Base(__ummap._M_base(), __a) { }
unordered_multimap(unordered_multimap&& __ummap,
const allocator_type& __a)
: _Base(std::move(__ummap._M_base()), __a) { }
unordered_multimap(initializer_list<value_type> __l,
size_type __n = 0,
const hasher& __hf = hasher(),
const key_equal& __eql = key_equal(),
const allocator_type& __a = allocator_type())
: _Base(__l, __n, __hf, __eql, __a) { }
unordered_multimap(size_type __n, const allocator_type& __a)
: unordered_multimap(__n, hasher(), key_equal(), __a)
{ }
unordered_multimap(size_type __n, const hasher& __hf,
const allocator_type& __a)
: unordered_multimap(__n, __hf, key_equal(), __a)
{ }
template<typename _InputIterator>
unordered_multimap(_InputIterator __first, _InputIterator __last,
size_type __n,
const allocator_type& __a)
: unordered_multimap(__first, __last, __n, hasher(), key_equal(), __a)
{ }
template<typename _InputIterator>
unordered_multimap(_InputIterator __first, _InputIterator __last,
size_type __n, const hasher& __hf,
const allocator_type& __a)
: unordered_multimap(__first, __last, __n, __hf, key_equal(), __a)
{ }
unordered_multimap(initializer_list<value_type> __l,
size_type __n,
const allocator_type& __a)
: unordered_multimap(__l, __n, hasher(), key_equal(), __a)
{ }
unordered_multimap(initializer_list<value_type> __l,
size_type __n, const hasher& __hf,
const allocator_type& __a)
: unordered_multimap(__l, __n, __hf, key_equal(), __a)
{ }
unordered_multimap&
operator=(const unordered_multimap&) = default;
unordered_multimap&
operator=(unordered_multimap&&) = default;
unordered_multimap&
operator=(initializer_list<value_type> __l)
{
this->_M_profile_destruct();
_M_base() = __l;
this->_M_profile_construct();
return *this;
}
void
clear() noexcept
{
this->_M_profile_destruct();
_Base::clear();
this->_M_profile_construct();
}
template<typename... _Args>
iterator
emplace(_Args&&... __args)
{
size_type __old_size = _Base::bucket_count();
iterator __res
= _Base::emplace(std::forward<_Args>(__args)...);
this->_M_profile_resize(__old_size);
return __res;
}
template<typename... _Args>
iterator
emplace_hint(const_iterator __it, _Args&&... __args)
{
size_type __old_size = _Base::bucket_count();
iterator __res
= _Base::emplace_hint(__it, std::forward<_Args>(__args)...);
this->_M_profile_resize(__old_size);
return __res;
}
void
insert(std::initializer_list<value_type> __l)
{
size_type __old_size = _Base::bucket_count();
_Base::insert(__l);
this->_M_profile_resize(__old_size);
}
iterator
insert(const value_type& __obj)
{
size_type __old_size = _Base::bucket_count();
iterator __res = _Base::insert(__obj);
this->_M_profile_resize(__old_size);
return __res;
}
iterator
insert(const_iterator __iter, const value_type& __v)
{
size_type __old_size = _Base::bucket_count();
iterator __res = _Base::insert(__iter, __v);
this->_M_profile_resize(__old_size);
return __res;
}
template<typename _Pair, typename = typename
std::enable_if<std::is_constructible<value_type,
_Pair&&>::value>::type>
iterator
insert(_Pair&& __obj)
{
size_type __old_size = _Base::bucket_count();
iterator __res = _Base::insert(std::forward<_Pair>(__obj));
this->_M_profile_resize(__old_size);
return __res;
}
template<typename _Pair, typename = typename
std::enable_if<std::is_constructible<value_type,
_Pair&&>::value>::type>
iterator
insert(const_iterator __iter, _Pair&& __v)
{
size_type __old_size = _Base::bucket_count();
iterator __res = _Base::insert(__iter, std::forward<_Pair>(__v));
this->_M_profile_resize(__old_size);
return __res;
}
template<typename _InputIter>
void
insert(_InputIter __first, _InputIter __last)
{
size_type __old_size = _Base::bucket_count();
_Base::insert(__first, __last);
this->_M_profile_resize(__old_size);
}
void
swap(unordered_multimap& __x)
noexcept( noexcept(__x._M_base().swap(__x)) )
{
_Base::swap(__x._M_base());
this->_M_swap(__x);
}
void
rehash(size_type __n)
{
size_type __old_size = _Base::bucket_count();
_Base::rehash(__n);
this->_M_profile_resize(__old_size);
}
};
template<typename _Key, typename _Tp, typename _Hash,
typename _Pred, typename _Alloc>
inline void
swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
noexcept(noexcept(__x.swap(__y)))
{ __x.swap(__y); }
template<typename _Key, typename _Tp, typename _Hash,
typename _Pred, typename _Alloc>
inline bool
operator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
{ return static_cast<const _GLIBCXX_STD_BASE&>(__x) == __y; }
template<typename _Key, typename _Tp, typename _Hash,
typename _Pred, typename _Alloc>
inline bool
operator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
{ return !(__x == __y); }
} // namespace __profile
} // namespace std
#undef _GLIBCXX_BASE
#undef _GLIBCXX_STD_BASE
#endif // C++11
#endif
c++/8/profile/unordered_set 0000644 00000037643 15201526705 0011530 0 ustar 00 // Profiling unordered_set/unordered_multiset implementation -*- C++ -*-
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
/** @file profile/unordered_set
* This file is a GNU profile extension to the Standard C++ Library.
*/
#ifndef _GLIBCXX_PROFILE_UNORDERED_SET
#define _GLIBCXX_PROFILE_UNORDERED_SET 1
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
# include <unordered_set>
#include <profile/base.h>
#include <profile/unordered_base.h>
#define _GLIBCXX_BASE unordered_set<_Key, _Hash, _Pred, _Alloc>
#define _GLIBCXX_STD_BASE _GLIBCXX_STD_C::_GLIBCXX_BASE
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __profile
{
/** @brief Unordered_set wrapper with performance instrumentation. */
template<typename _Key,
typename _Hash = std::hash<_Key>,
typename _Pred = std::equal_to<_Key>,
typename _Alloc = std::allocator<_Key> >
class unordered_set
: public _GLIBCXX_STD_BASE,
public _Unordered_profile<unordered_set<_Key, _Hash, _Pred, _Alloc>,
true>
{
typedef _GLIBCXX_STD_BASE _Base;
_Base&
_M_base() noexcept { return *this; }
const _Base&
_M_base() const noexcept { return *this; }
public:
typedef typename _Base::size_type size_type;
typedef typename _Base::hasher hasher;
typedef typename _Base::key_equal key_equal;
typedef typename _Base::allocator_type allocator_type;
typedef typename _Base::key_type key_type;
typedef typename _Base::value_type value_type;
typedef typename _Base::difference_type difference_type;
typedef typename _Base::reference reference;
typedef typename _Base::const_reference const_reference;
typedef typename _Base::iterator iterator;
typedef typename _Base::const_iterator const_iterator;
unordered_set() = default;
explicit
unordered_set(size_type __n,
const hasher& __hf = hasher(),
const key_equal& __eql = key_equal(),
const allocator_type& __a = allocator_type())
: _Base(__n, __hf, __eql, __a)
{ }
template<typename _InputIterator>
unordered_set(_InputIterator __f, _InputIterator __l,
size_type __n = 0,
const hasher& __hf = hasher(),
const key_equal& __eql = key_equal(),
const allocator_type& __a = allocator_type())
: _Base(__f, __l, __n, __hf, __eql, __a)
{ }
unordered_set(const unordered_set&) = default;
unordered_set(const _Base& __x)
: _Base(__x)
{ }
unordered_set(unordered_set&&) = default;
explicit
unordered_set(const allocator_type& __a)
: _Base(__a)
{ }
unordered_set(const unordered_set& __uset,
const allocator_type& __a)
: _Base(__uset._M_base(), __a)
{ }
unordered_set(unordered_set&& __uset,
const allocator_type& __a)
: _Base(std::move(__uset._M_base()), __a)
{ }
unordered_set(initializer_list<value_type> __l,
size_type __n = 0,
const hasher& __hf = hasher(),
const key_equal& __eql = key_equal(),
const allocator_type& __a = allocator_type())
: _Base(__l, __n, __hf, __eql, __a)
{ }
unordered_set(size_type __n, const allocator_type& __a)
: unordered_set(__n, hasher(), key_equal(), __a)
{ }
unordered_set(size_type __n, const hasher& __hf,
const allocator_type& __a)
: unordered_set(__n, __hf, key_equal(), __a)
{ }
template<typename _InputIterator>
unordered_set(_InputIterator __first, _InputIterator __last,
size_type __n,
const allocator_type& __a)
: unordered_set(__first, __last, __n, hasher(), key_equal(), __a)
{ }
template<typename _InputIterator>
unordered_set(_InputIterator __first, _InputIterator __last,
size_type __n, const hasher& __hf,
const allocator_type& __a)
: unordered_set(__first, __last, __n, __hf, key_equal(), __a)
{ }
unordered_set(initializer_list<value_type> __l,
size_type __n,
const allocator_type& __a)
: unordered_set(__l, __n, hasher(), key_equal(), __a)
{ }
unordered_set(initializer_list<value_type> __l,
size_type __n, const hasher& __hf,
const allocator_type& __a)
: unordered_set(__l, __n, __hf, key_equal(), __a)
{ }
unordered_set&
operator=(const unordered_set&) = default;
unordered_set&
operator=(unordered_set&&) = default;
unordered_set&
operator=(initializer_list<value_type> __l)
{
this->_M_profile_destruct();
_M_base() = __l;
this->_M_profile_construct();
return *this;
}
void
swap(unordered_set& __x)
noexcept( noexcept(__x._M_base().swap(__x)) )
{
_Base::swap(__x);
this->_M_swap(__x);
}
void
clear() noexcept
{
this->_M_profile_destruct();
_Base::clear();
this->_M_profile_construct();
}
template<typename... _Args>
std::pair<iterator, bool>
emplace(_Args&&... __args)
{
size_type __old_size = _Base::bucket_count();
std::pair<iterator, bool> __res
= _Base::emplace(std::forward<_Args>(__args)...);
this->_M_profile_resize(__old_size);
return __res;
}
template<typename... _Args>
iterator
emplace_hint(const_iterator __it, _Args&&... __args)
{
size_type __old_size = _Base::bucket_count();
iterator __res
= _Base::emplace_hint(__it, std::forward<_Args>(__args)...);
this->_M_profile_resize(__old_size);
return __res;
}
void
insert(std::initializer_list<value_type> __l)
{
size_type __old_size = _Base::bucket_count();
_Base::insert(__l);
this->_M_profile_resize(__old_size);
}
std::pair<iterator, bool>
insert(const value_type& __obj)
{
size_type __old_size = _Base::bucket_count();
std::pair<iterator, bool> __res = _Base::insert(__obj);
this->_M_profile_resize(__old_size);
return __res;
}
iterator
insert(const_iterator __iter, const value_type& __v)
{
size_type __old_size = _Base::bucket_count();
iterator __res = _Base::insert(__iter, __v);
this->_M_profile_resize(__old_size);
return __res;
}
std::pair<iterator, bool>
insert(value_type&& __obj)
{
size_type __old_size = _Base::bucket_count();
std::pair<iterator, bool> __res = _Base::insert(std::move(__obj));
this->_M_profile_resize(__old_size);
return __res;
}
iterator
insert(const_iterator __iter, value_type&& __v)
{
size_type __old_size = _Base::bucket_count();
iterator __res = _Base::insert(__iter, std::move(__v));
this->_M_profile_resize(__old_size);
return __res;
}
template<typename _InputIter>
void
insert(_InputIter __first, _InputIter __last)
{
size_type __old_size = _Base::bucket_count();
_Base::insert(__first, __last);
this->_M_profile_resize(__old_size);
}
void
rehash(size_type __n)
{
size_type __old_size = _Base::bucket_count();
_Base::rehash(__n);
this->_M_profile_resize(__old_size);
}
};
template<typename _Key, typename _Hash, typename _Pred, typename _Alloc>
inline void
swap(unordered_set<_Key, _Hash, _Pred, _Alloc>& __x,
unordered_set<_Key, _Hash, _Pred, _Alloc>& __y)
noexcept(noexcept(__x.swap(__y)))
{ __x.swap(__y); }
template<typename _Key, typename _Hash, typename _Pred, typename _Alloc>
inline bool
operator==(const unordered_set<_Key, _Hash, _Pred, _Alloc>& __x,
const unordered_set<_Key, _Hash, _Pred, _Alloc>& __y)
{ return static_cast<const _GLIBCXX_STD_BASE&>(__x) == __y; }
template<typename _Key, typename _Hash, typename _Pred, typename _Alloc>
inline bool
operator!=(const unordered_set<_Key, _Hash, _Pred, _Alloc>& __x,
const unordered_set<_Key, _Hash, _Pred, _Alloc>& __y)
{ return !(__x == __y); }
#undef _GLIBCXX_BASE
#undef _GLIBCXX_STD_BASE
#define _GLIBCXX_STD_BASE _GLIBCXX_STD_C::_GLIBCXX_BASE
#define _GLIBCXX_BASE unordered_multiset<_Value, _Hash, _Pred, _Alloc>
/** @brief Unordered_multiset wrapper with performance instrumentation. */
template<typename _Value,
typename _Hash = std::hash<_Value>,
typename _Pred = std::equal_to<_Value>,
typename _Alloc = std::allocator<_Value> >
class unordered_multiset
: public _GLIBCXX_STD_BASE,
public _Unordered_profile<unordered_multiset<_Value,
_Hash, _Pred, _Alloc>,
false>
{
typedef _GLIBCXX_STD_BASE _Base;
_Base&
_M_base() noexcept { return *this; }
const _Base&
_M_base() const noexcept { return *this; }
public:
typedef typename _Base::size_type size_type;
typedef typename _Base::hasher hasher;
typedef typename _Base::key_equal key_equal;
typedef typename _Base::allocator_type allocator_type;
typedef typename _Base::key_type key_type;
typedef typename _Base::value_type value_type;
typedef typename _Base::difference_type difference_type;
typedef typename _Base::reference reference;
typedef typename _Base::const_reference const_reference;
typedef typename _Base::iterator iterator;
typedef typename _Base::const_iterator const_iterator;
unordered_multiset() = default;
explicit
unordered_multiset(size_type __n,
const hasher& __hf = hasher(),
const key_equal& __eql = key_equal(),
const allocator_type& __a = allocator_type())
: _Base(__n, __hf, __eql, __a)
{ }
template<typename _InputIterator>
unordered_multiset(_InputIterator __f, _InputIterator __l,
size_type __n = 0,
const hasher& __hf = hasher(),
const key_equal& __eql = key_equal(),
const allocator_type& __a = allocator_type())
: _Base(__f, __l, __n, __hf, __eql, __a)
{ }
unordered_multiset(const unordered_multiset&) = default;
unordered_multiset(const _Base& __x)
: _Base(__x)
{ }
unordered_multiset(unordered_multiset&&) = default;
explicit
unordered_multiset(const allocator_type& __a)
: _Base(__a)
{ }
unordered_multiset(const unordered_multiset& __umset,
const allocator_type& __a)
: _Base(__umset._M_base(), __a)
{ }
unordered_multiset(unordered_multiset&& __umset,
const allocator_type& __a)
: _Base(std::move(__umset._M_base()), __a)
{ }
unordered_multiset(initializer_list<value_type> __l,
size_type __n = 0,
const hasher& __hf = hasher(),
const key_equal& __eql = key_equal(),
const allocator_type& __a = allocator_type())
: _Base(__l, __n, __hf, __eql, __a)
{ }
unordered_multiset(size_type __n, const allocator_type& __a)
: unordered_multiset(__n, hasher(), key_equal(), __a)
{ }
unordered_multiset(size_type __n, const hasher& __hf,
const allocator_type& __a)
: unordered_multiset(__n, __hf, key_equal(), __a)
{ }
template<typename _InputIterator>
unordered_multiset(_InputIterator __first, _InputIterator __last,
size_type __n,
const allocator_type& __a)
: unordered_multiset(__first, __last, __n, hasher(), key_equal(), __a)
{ }
template<typename _InputIterator>
unordered_multiset(_InputIterator __first, _InputIterator __last,
size_type __n, const hasher& __hf,
const allocator_type& __a)
: unordered_multiset(__first, __last, __n, __hf, key_equal(), __a)
{ }
unordered_multiset(initializer_list<value_type> __l,
size_type __n,
const allocator_type& __a)
: unordered_multiset(__l, __n, hasher(), key_equal(), __a)
{ }
unordered_multiset(initializer_list<value_type> __l,
size_type __n, const hasher& __hf,
const allocator_type& __a)
: unordered_multiset(__l, __n, __hf, key_equal(), __a)
{ }
unordered_multiset&
operator=(const unordered_multiset&) = default;
unordered_multiset&
operator=(unordered_multiset&&) = default;
unordered_multiset&
operator=(initializer_list<value_type> __l)
{
this->_M_profile_destruct();
_M_base() = __l;
this->_M_profile_construct();
return *this;
}
void
swap(unordered_multiset& __x)
noexcept( noexcept(__x._M_base().swap(__x)) )
{
_Base::swap(__x);
this->_M_swap(__x);
}
void
clear() noexcept
{
this->_M_profile_destruct();
_Base::clear();
this->_M_profile_construct();
}
template<typename... _Args>
iterator
emplace(_Args&&... __args)
{
size_type __old_size = _Base::bucket_count();
iterator __res = _Base::emplace(std::forward<_Args>(__args)...);
this->_M_profile_resize(__old_size);
return __res;
}
template<typename... _Args>
iterator
emplace_hint(const_iterator __it, _Args&&... __args)
{
size_type __old_size = _Base::bucket_count();
iterator __res
= _Base::emplace_hint(__it, std::forward<_Args>(__args)...);
this->_M_profile_resize(__old_size);
return __res;
}
void
insert(std::initializer_list<value_type> __l)
{
size_type __old_size = _Base::bucket_count();
_Base::insert(__l);
this->_M_profile_resize(__old_size);
}
iterator
insert(const value_type& __obj)
{
size_type __old_size = _Base::bucket_count();
iterator __res = _Base::insert(__obj);
this->_M_profile_resize(__old_size);
return __res;
}
iterator
insert(const_iterator __iter, const value_type& __v)
{
size_type __old_size = _Base::bucket_count();
iterator __res = _Base::insert(__iter, __v);
this->_M_profile_resize(__old_size);
return __res;
}
iterator
insert(value_type&& __obj)
{
size_type __old_size = _Base::bucket_count();
iterator __res = _Base::insert(std::move(__obj));
this->_M_profile_resize(__old_size);
return __res;
}
iterator
insert(const_iterator __iter, value_type&& __v)
{
size_type __old_size = _Base::bucket_count();
iterator __res = _Base::insert(__iter, std::move(__v));
this->_M_profile_resize(__old_size);
return __res;
}
template<typename _InputIter>
void
insert(_InputIter __first, _InputIter __last)
{
size_type __old_size = _Base::bucket_count();
_Base::insert(__first, __last);
this->_M_profile_resize(__old_size);
}
void
rehash(size_type __n)
{
size_type __old_size = _Base::bucket_count();
_Base::rehash(__n);
this->_M_profile_resize(__old_size);
}
};
template<typename _Value, typename _Hash, typename _Pred, typename _Alloc>
inline void
swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
noexcept(noexcept(__x.swap(__y)))
{ __x.swap(__y); }
template<typename _Value, typename _Hash, typename _Pred, typename _Alloc>
inline bool
operator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
{ return static_cast<const _GLIBCXX_STD_BASE&>(__x) == __y; }
template<typename _Value, typename _Hash, typename _Pred, typename _Alloc>
inline bool
operator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
{ return !(__x == __y); }
} // namespace __profile
} // namespace std
#undef _GLIBCXX_BASE
#undef _GLIBCXX_STD_BASE
#endif // C++11
#endif
c++/8/fenv.h 0000644 00000003744 15201526705 0006405 0 ustar 00 // -*- C++ -*- compatibility header.
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file fenv.h
* This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_FENV_H
#define _GLIBCXX_FENV_H 1
#pragma GCC system_header
#include <bits/c++config.h>
#if _GLIBCXX_HAVE_FENV_H
# include_next <fenv.h>
#endif
#if __cplusplus >= 201103L
#if _GLIBCXX_USE_C99_FENV_TR1
#undef feclearexcept
#undef fegetexceptflag
#undef feraiseexcept
#undef fesetexceptflag
#undef fetestexcept
#undef fegetround
#undef fesetround
#undef fegetenv
#undef feholdexcept
#undef fesetenv
#undef feupdateenv
namespace std
{
// types
using ::fenv_t;
using ::fexcept_t;
// functions
using ::feclearexcept;
using ::fegetexceptflag;
using ::feraiseexcept;
using ::fesetexceptflag;
using ::fetestexcept;
using ::fegetround;
using ::fesetround;
using ::fegetenv;
using ::feholdexcept;
using ::fesetenv;
using ::feupdateenv;
} // namespace
#endif // _GLIBCXX_USE_C99_FENV_TR1
#endif // C++11
#endif // _GLIBCXX_FENV_H
c++/8/array 0000644 00000026611 15201526705 0006335 0 ustar 00 // <array> -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/array
* This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_ARRAY
#define _GLIBCXX_ARRAY 1
#pragma GCC system_header
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
#include <utility>
#include <stdexcept>
#include <bits/stl_algobase.h>
#include <bits/range_access.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Tp, std::size_t _Nm>
struct __array_traits
{
typedef _Tp _Type[_Nm];
typedef __is_swappable<_Tp> _Is_swappable;
typedef __is_nothrow_swappable<_Tp> _Is_nothrow_swappable;
static constexpr _Tp&
_S_ref(const _Type& __t, std::size_t __n) noexcept
{ return const_cast<_Tp&>(__t[__n]); }
static constexpr _Tp*
_S_ptr(const _Type& __t) noexcept
{ return const_cast<_Tp*>(__t); }
};
template<typename _Tp>
struct __array_traits<_Tp, 0>
{
struct _Type { };
typedef true_type _Is_swappable;
typedef true_type _Is_nothrow_swappable;
static constexpr _Tp&
_S_ref(const _Type&, std::size_t) noexcept
{ return *static_cast<_Tp*>(nullptr); }
static constexpr _Tp*
_S_ptr(const _Type&) noexcept
{ return nullptr; }
};
/**
* @brief A standard container for storing a fixed size sequence of elements.
*
* @ingroup sequences
*
* Meets the requirements of a <a href="tables.html#65">container</a>, a
* <a href="tables.html#66">reversible container</a>, and a
* <a href="tables.html#67">sequence</a>.
*
* Sets support random access iterators.
*
* @tparam Tp Type of element. Required to be a complete type.
* @tparam N Number of elements.
*/
template<typename _Tp, std::size_t _Nm>
struct array
{
typedef _Tp value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef value_type* iterator;
typedef const value_type* const_iterator;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
// Support for zero-sized arrays mandatory.
typedef _GLIBCXX_STD_C::__array_traits<_Tp, _Nm> _AT_Type;
typename _AT_Type::_Type _M_elems;
// No explicit construct/copy/destroy for aggregate type.
// DR 776.
void
fill(const value_type& __u)
{ std::fill_n(begin(), size(), __u); }
void
swap(array& __other)
noexcept(_AT_Type::_Is_nothrow_swappable::value)
{ std::swap_ranges(begin(), end(), __other.begin()); }
// Iterators.
_GLIBCXX17_CONSTEXPR iterator
begin() noexcept
{ return iterator(data()); }
_GLIBCXX17_CONSTEXPR const_iterator
begin() const noexcept
{ return const_iterator(data()); }
_GLIBCXX17_CONSTEXPR iterator
end() noexcept
{ return iterator(data() + _Nm); }
_GLIBCXX17_CONSTEXPR const_iterator
end() const noexcept
{ return const_iterator(data() + _Nm); }
_GLIBCXX17_CONSTEXPR reverse_iterator
rbegin() noexcept
{ return reverse_iterator(end()); }
_GLIBCXX17_CONSTEXPR const_reverse_iterator
rbegin() const noexcept
{ return const_reverse_iterator(end()); }
_GLIBCXX17_CONSTEXPR reverse_iterator
rend() noexcept
{ return reverse_iterator(begin()); }
_GLIBCXX17_CONSTEXPR const_reverse_iterator
rend() const noexcept
{ return const_reverse_iterator(begin()); }
_GLIBCXX17_CONSTEXPR const_iterator
cbegin() const noexcept
{ return const_iterator(data()); }
_GLIBCXX17_CONSTEXPR const_iterator
cend() const noexcept
{ return const_iterator(data() + _Nm); }
_GLIBCXX17_CONSTEXPR const_reverse_iterator
crbegin() const noexcept
{ return const_reverse_iterator(end()); }
_GLIBCXX17_CONSTEXPR const_reverse_iterator
crend() const noexcept
{ return const_reverse_iterator(begin()); }
// Capacity.
constexpr size_type
size() const noexcept { return _Nm; }
constexpr size_type
max_size() const noexcept { return _Nm; }
constexpr bool
empty() const noexcept { return size() == 0; }
// Element access.
_GLIBCXX17_CONSTEXPR reference
operator[](size_type __n) noexcept
{ return _AT_Type::_S_ref(_M_elems, __n); }
constexpr const_reference
operator[](size_type __n) const noexcept
{ return _AT_Type::_S_ref(_M_elems, __n); }
_GLIBCXX17_CONSTEXPR reference
at(size_type __n)
{
if (__n >= _Nm)
std::__throw_out_of_range_fmt(__N("array::at: __n (which is %zu) "
">= _Nm (which is %zu)"),
__n, _Nm);
return _AT_Type::_S_ref(_M_elems, __n);
}
constexpr const_reference
at(size_type __n) const
{
// Result of conditional expression must be an lvalue so use
// boolean ? lvalue : (throw-expr, lvalue)
return __n < _Nm ? _AT_Type::_S_ref(_M_elems, __n)
: (std::__throw_out_of_range_fmt(__N("array::at: __n (which is %zu) "
">= _Nm (which is %zu)"),
__n, _Nm),
_AT_Type::_S_ref(_M_elems, 0));
}
_GLIBCXX17_CONSTEXPR reference
front() noexcept
{ return *begin(); }
constexpr const_reference
front() const noexcept
{ return _AT_Type::_S_ref(_M_elems, 0); }
_GLIBCXX17_CONSTEXPR reference
back() noexcept
{ return _Nm ? *(end() - 1) : *end(); }
constexpr const_reference
back() const noexcept
{
return _Nm ? _AT_Type::_S_ref(_M_elems, _Nm - 1)
: _AT_Type::_S_ref(_M_elems, 0);
}
_GLIBCXX17_CONSTEXPR pointer
data() noexcept
{ return _AT_Type::_S_ptr(_M_elems); }
_GLIBCXX17_CONSTEXPR const_pointer
data() const noexcept
{ return _AT_Type::_S_ptr(_M_elems); }
};
#if __cpp_deduction_guides >= 201606
template<typename _Tp, typename... _Up>
array(_Tp, _Up...)
-> array<enable_if_t<(is_same_v<_Tp, _Up> && ...), _Tp>,
1 + sizeof...(_Up)>;
#endif
// Array comparisons.
template<typename _Tp, std::size_t _Nm>
inline bool
operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
{ return std::equal(__one.begin(), __one.end(), __two.begin()); }
template<typename _Tp, std::size_t _Nm>
inline bool
operator!=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
{ return !(__one == __two); }
template<typename _Tp, std::size_t _Nm>
inline bool
operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b)
{
return std::lexicographical_compare(__a.begin(), __a.end(),
__b.begin(), __b.end());
}
template<typename _Tp, std::size_t _Nm>
inline bool
operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
{ return __two < __one; }
template<typename _Tp, std::size_t _Nm>
inline bool
operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
{ return !(__one > __two); }
template<typename _Tp, std::size_t _Nm>
inline bool
operator>=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
{ return !(__one < __two); }
// Specialized algorithms.
template<typename _Tp, std::size_t _Nm>
inline
#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
// Constrained free swap overload, see p0185r1
typename enable_if<
_GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::_Is_swappable::value
>::type
#else
void
#endif
swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
noexcept(noexcept(__one.swap(__two)))
{ __one.swap(__two); }
#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
template<typename _Tp, std::size_t _Nm>
typename enable_if<
!_GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::_Is_swappable::value>::type
swap(array<_Tp, _Nm>&, array<_Tp, _Nm>&) = delete;
#endif
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
constexpr _Tp&
get(array<_Tp, _Nm>& __arr) noexcept
{
static_assert(_Int < _Nm, "array index is within bounds");
return _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::
_S_ref(__arr._M_elems, _Int);
}
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
constexpr _Tp&&
get(array<_Tp, _Nm>&& __arr) noexcept
{
static_assert(_Int < _Nm, "array index is within bounds");
return std::move(_GLIBCXX_STD_C::get<_Int>(__arr));
}
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
constexpr const _Tp&
get(const array<_Tp, _Nm>& __arr) noexcept
{
static_assert(_Int < _Nm, "array index is within bounds");
return _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::
_S_ref(__arr._M_elems, _Int);
}
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
constexpr const _Tp&&
get(const array<_Tp, _Nm>&& __arr) noexcept
{
static_assert(_Int < _Nm, "array index is within bounds");
return std::move(_GLIBCXX_STD_C::get<_Int>(__arr));
}
_GLIBCXX_END_NAMESPACE_CONTAINER
} // namespace std
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Tuple interface to class template array.
/// tuple_size
template<typename _Tp>
struct tuple_size;
/// Partial specialization for std::array
template<typename _Tp, std::size_t _Nm>
struct tuple_size<_GLIBCXX_STD_C::array<_Tp, _Nm>>
: public integral_constant<std::size_t, _Nm> { };
/// tuple_element
template<std::size_t _Int, typename _Tp>
struct tuple_element;
/// Partial specialization for std::array
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
struct tuple_element<_Int, _GLIBCXX_STD_C::array<_Tp, _Nm>>
{
static_assert(_Int < _Nm, "index is out of bounds");
typedef _Tp type;
};
template<typename _Tp, std::size_t _Nm>
struct __is_tuple_like_impl<_GLIBCXX_STD_C::array<_Tp, _Nm>> : true_type
{ };
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#ifdef _GLIBCXX_DEBUG
# include <debug/array>
#endif
#ifdef _GLIBCXX_PROFILE
# include <profile/array>
#endif
#endif // C++11
#endif // _GLIBCXX_ARRAY
c++/8/ccomplex 0000644 00000002467 15201526705 0007034 0 ustar 00 // <ccomplex> -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/ccomplex
* This is a Standard C++ Library header.
*/
#pragma GCC system_header
#ifndef _GLIBCXX_CCOMPLEX
#define _GLIBCXX_CCOMPLEX 1
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#endif
extern "C++" {
#include <complex>
}
#endif
c++/8/queue 0000644 00000004643 15201526705 0006344 0 ustar 00 // <queue> -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1996,1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file include/queue
* This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_QUEUE
#define _GLIBCXX_QUEUE 1
#pragma GCC system_header
#include <deque>
#include <vector>
#include <bits/stl_heap.h>
#include <bits/stl_function.h>
#include <bits/stl_queue.h>
#endif /* _GLIBCXX_QUEUE */
c++/8/stack 0000644 00000004527 15201526705 0006326 0 ustar 00 // <stack> -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1996,1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file include/stack
* This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_STACK
#define _GLIBCXX_STACK 1
#pragma GCC system_header
#include <deque>
#include <bits/stl_stack.h>
#endif /* _GLIBCXX_STACK */
c++/8/regex 0000644 00000003546 15201526705 0006333 0 ustar 00 // <regex> -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/regex
* This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_REGEX
#define _GLIBCXX_REGEX 1
#pragma GCC system_header
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
#include <algorithm>
#include <bitset>
#ifdef _GLIBCXX_DEBUG
# include <iosfwd>
#endif
#include <iterator>
#include <locale>
#include <memory>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <cstring>
#include <ext/aligned_buffer.h>
#include <bits/std_function.h>
#include <bits/regex_constants.h>
#include <bits/regex_error.h>
#include <bits/regex_automaton.h>
#include <bits/regex_scanner.h>
#include <bits/regex_compiler.h>
#include <bits/regex.h>
#include <bits/regex_executor.h>
#endif // C++11
#endif // _GLIBCXX_REGEX
c++/8/ctime 0000644 00000004115 15201526705 0006313 0 ustar 00 // -*- C++ -*- forwarding header.
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/ctime
* This is a Standard C++ Library file. You should @c \#include this file
* in your programs, rather than any of the @a *.h implementation files.
*
* This is the C++ version of the Standard C Library header @c time.h,
* and its contents are (mostly) the same as that header, but are all
* contained in the namespace @c std (except for names which are defined
* as macros in C).
*/
//
// ISO C++ 14882: 20.5 Date and time
//
#pragma GCC system_header
#include <bits/c++config.h>
#include <time.h>
#ifndef _GLIBCXX_CTIME
#define _GLIBCXX_CTIME 1
// Get rid of those macros defined in <time.h> in lieu of real functions.
#undef clock
#undef difftime
#undef mktime
#undef time
#undef asctime
#undef ctime
#undef gmtime
#undef localtime
#undef strftime
namespace std
{
using ::clock_t;
using ::time_t;
using ::tm;
using ::clock;
using ::difftime;
using ::mktime;
using ::time;
using ::asctime;
using ::ctime;
using ::gmtime;
using ::localtime;
using ::strftime;
} // namespace
#endif
c++/8/csetjmp 0000644 00000003635 15201526705 0006665 0 ustar 00 // -*- C++ -*- forwarding header.
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file csetjmp
* This is a Standard C++ Library file. You should @c \#include this file
* in your programs, rather than any of the @a *.h implementation files.
*
* This is the C++ version of the Standard C Library header @c setjmp.h,
* and its contents are (mostly) the same as that header, but are all
* contained in the namespace @c std (except for names which are defined
* as macros in C).
*/
//
// ISO C++ 14882: 20.4.6 C library
//
#pragma GCC system_header
#include <bits/c++config.h>
#include <setjmp.h>
#ifndef _GLIBCXX_CSETJMP
#define _GLIBCXX_CSETJMP 1
// Get rid of those macros defined in <setjmp.h> in lieu of real functions.
#undef longjmp
// Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998
#ifndef setjmp
#define setjmp(env) setjmp (env)
#endif
namespace std
{
using ::jmp_buf;
using ::longjmp;
} // namespace std
#endif
c++/8/cstddef 0000644 00000014450 15201526705 0006631 0 ustar 00 // -*- C++ -*- forwarding header.
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file cstddef
* This is a Standard C++ Library file. You should @c \#include this file
* in your programs, rather than any of the @a *.h implementation files.
*
* This is the C++ version of the Standard C Library header @c stddef.h,
* and its contents are (mostly) the same as that header, but are all
* contained in the namespace @c std (except for names which are defined
* as macros in C).
*/
//
// ISO C++ 14882: 18.1 Types
//
#ifndef _GLIBCXX_CSTDDEF
#define _GLIBCXX_CSTDDEF 1
#pragma GCC system_header
#undef __need_wchar_t
#undef __need_ptrdiff_t
#undef __need_size_t
#undef __need_NULL
#undef __need_wint_t
#include <bits/c++config.h>
#include <stddef.h>
#if __cplusplus >= 201103L
namespace std
{
// We handle size_t, ptrdiff_t, and nullptr_t in c++config.h.
using ::max_align_t;
}
#endif
#if __cplusplus >= 201703L
namespace std
{
#define __cpp_lib_byte 201603
/// std::byte
enum class byte : unsigned char {};
template<typename _IntegerType> struct __byte_operand { };
template<> struct __byte_operand<bool> { using __type = byte; };
template<> struct __byte_operand<char> { using __type = byte; };
template<> struct __byte_operand<signed char> { using __type = byte; };
template<> struct __byte_operand<unsigned char> { using __type = byte; };
#ifdef _GLIBCXX_USE_WCHAR_T
template<> struct __byte_operand<wchar_t> { using __type = byte; };
#endif
template<> struct __byte_operand<char16_t> { using __type = byte; };
template<> struct __byte_operand<char32_t> { using __type = byte; };
template<> struct __byte_operand<short> { using __type = byte; };
template<> struct __byte_operand<unsigned short> { using __type = byte; };
template<> struct __byte_operand<int> { using __type = byte; };
template<> struct __byte_operand<unsigned int> { using __type = byte; };
template<> struct __byte_operand<long> { using __type = byte; };
template<> struct __byte_operand<unsigned long> { using __type = byte; };
template<> struct __byte_operand<long long> { using __type = byte; };
template<> struct __byte_operand<unsigned long long> { using __type = byte; };
#if defined(__GLIBCXX_TYPE_INT_N_0)
template<> struct __byte_operand<__GLIBCXX_TYPE_INT_N_0>
{ using __type = byte; };
template<> struct __byte_operand<unsigned __GLIBCXX_TYPE_INT_N_0>
{ using __type = byte; };
#endif
#if defined(__GLIBCXX_TYPE_INT_N_1)
template<> struct __byte_operand<__GLIBCXX_TYPE_INT_N_1>
{ using __type = byte; };
template<> struct __byte_operand<unsigned __GLIBCXX_TYPE_INT_N_1>
{ using __type = byte; };
#endif
#if defined(__GLIBCXX_TYPE_INT_N_2)
template<> struct __byte_operand<__GLIBCXX_TYPE_INT_N_2>
{ using __type = byte; };
template<> struct __byte_operand<unsigned __GLIBCXX_TYPE_INT_N_2>
{ using __type = byte; };
#endif
template<typename _IntegerType>
struct __byte_operand<const _IntegerType>
: __byte_operand<_IntegerType> { };
template<typename _IntegerType>
struct __byte_operand<volatile _IntegerType>
: __byte_operand<_IntegerType> { };
template<typename _IntegerType>
struct __byte_operand<const volatile _IntegerType>
: __byte_operand<_IntegerType> { };
template<typename _IntegerType>
using __byte_op_t = typename __byte_operand<_IntegerType>::__type;
template<typename _IntegerType>
constexpr __byte_op_t<_IntegerType>&
operator<<=(byte& __b, _IntegerType __shift) noexcept
{ return __b = byte(static_cast<unsigned char>(__b) << __shift); }
template<typename _IntegerType>
constexpr __byte_op_t<_IntegerType>
operator<<(byte __b, _IntegerType __shift) noexcept
{ return byte(static_cast<unsigned char>(__b) << __shift); }
template<typename _IntegerType>
constexpr __byte_op_t<_IntegerType>&
operator>>=(byte& __b, _IntegerType __shift) noexcept
{ return __b = byte(static_cast<unsigned char>(__b) >> __shift); }
template<typename _IntegerType>
constexpr __byte_op_t<_IntegerType>
operator>>(byte __b, _IntegerType __shift) noexcept
{ return byte(static_cast<unsigned char>(__b) >> __shift); }
constexpr byte&
operator|=(byte& __l, byte __r) noexcept
{
return __l =
byte(static_cast<unsigned char>(__l) | static_cast<unsigned char>(__r));
}
constexpr byte
operator|(byte __l, byte __r) noexcept
{
return
byte(static_cast<unsigned char>(__l) | static_cast<unsigned char>(__r));
}
constexpr byte&
operator&=(byte& __l, byte __r) noexcept
{
return __l =
byte(static_cast<unsigned char>(__l) & static_cast<unsigned char>(__r));
}
constexpr byte
operator&(byte __l, byte __r) noexcept
{
return
byte(static_cast<unsigned char>(__l) & static_cast<unsigned char>(__r));
}
constexpr byte&
operator^=(byte& __l, byte __r) noexcept
{
return __l =
byte(static_cast<unsigned char>(__l) ^ static_cast<unsigned char>(__r));
}
constexpr byte
operator^(byte __l, byte __r) noexcept
{
return
byte(static_cast<unsigned char>(__l) ^ static_cast<unsigned char>(__r));
}
constexpr byte
operator~(byte __b) noexcept
{ return byte(~static_cast<unsigned char>(__b)); }
template<typename _IntegerType>
constexpr _IntegerType
to_integer(__byte_op_t<_IntegerType> __b) noexcept
{ return _IntegerType(__b); }
} // namespace std
#endif
#endif // _GLIBCXX_CSTDDEF
c++/8/decimal/decimal.h 0000644 00000041147 15201526705 0010442 0 ustar 00 // decimal classes -*- C++ -*-
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file decimal/decimal.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{decimal}
*/
// ISO/IEC TR 24733
// Written by Janis Johnson <janis187@us.ibm.com>
#ifndef _GLIBCXX_DECIMAL_IMPL
#define _GLIBCXX_DECIMAL_IMPL 1
#pragma GCC system_header
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
namespace decimal
{
// ISO/IEC TR 24733 3.2.[234].1 Construct/copy/destroy.
inline decimal32::decimal32(decimal64 __r) : __val(__r.__getval()) {}
inline decimal32::decimal32(decimal128 __r) : __val(__r.__getval()) {}
inline decimal64::decimal64(decimal32 __r) : __val(__r.__getval()) {}
inline decimal64::decimal64(decimal128 __r) : __val(__r.__getval()) {}
inline decimal128::decimal128(decimal32 __r) : __val(__r.__getval()) {}
inline decimal128::decimal128(decimal64 __r) : __val(__r.__getval()) {}
// ISO/IEC TR 24733 3.2.[234].6 Compound assignment.
#define _DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_DEC(_Op1, _Op2, _T1, _T2) \
inline _T1& _T1::operator _Op1(_T2 __rhs) \
{ \
__setval(__getval() _Op2 __rhs.__getval()); \
return *this; \
}
#define _DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_INT(_Op1, _Op2, _T1, _T2) \
inline _T1& _T1::operator _Op1(_T2 __rhs) \
{ \
__setval(__getval() _Op2 __rhs); \
return *this; \
}
#define _DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(_Op1, _Op2, _T1) \
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_DEC(_Op1, _Op2, _T1, decimal32) \
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_DEC(_Op1, _Op2, _T1, decimal64) \
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_DEC(_Op1, _Op2, _T1, decimal128) \
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_INT(_Op1, _Op2, _T1, int) \
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_INT(_Op1, _Op2, _T1, unsigned int) \
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_INT(_Op1, _Op2, _T1, long) \
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_INT(_Op1, _Op2, _T1, unsigned long)\
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_INT(_Op1, _Op2, _T1, long long) \
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_INT(_Op1, _Op2, _T1, unsigned long long)
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(+=, +, decimal32)
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(-=, -, decimal32)
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(*=, *, decimal32)
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(/=, /, decimal32)
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(+=, +, decimal64)
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(-=, -, decimal64)
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(*=, *, decimal64)
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(/=, /, decimal64)
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(+=, +, decimal128)
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(-=, -, decimal128)
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(*=, *, decimal128)
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(/=, /, decimal128)
#undef _DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_DEC
#undef _DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_INT
#undef _DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS
// Extension: Conversion to integral type.
inline long long decimal32_to_long_long(decimal32 __d)
{ return (long long)__d.__getval(); }
inline long long decimal64_to_long_long(decimal64 __d)
{ return (long long)__d.__getval(); }
inline long long decimal128_to_long_long(decimal128 __d)
{ return (long long)__d.__getval(); }
inline long long decimal_to_long_long(decimal32 __d)
{ return (long long)__d.__getval(); }
inline long long decimal_to_long_long(decimal64 __d)
{ return (long long)__d.__getval(); }
inline long long decimal_to_long_long(decimal128 __d)
{ return (long long)__d.__getval(); }
// ISO/IEC TR 24733 3.2.5 Initialization from coefficient and exponent.
static decimal32 make_decimal32(long long __coeff, int __exponent)
{
decimal32 __decexp = 1, __multiplier;
if (__exponent < 0)
{
__multiplier = 1.E-1DF;
__exponent = -__exponent;
}
else
__multiplier = 1.E1DF;
for (int __i = 0; __i < __exponent; ++__i)
__decexp *= __multiplier;
return __coeff * __decexp;
}
static decimal32 make_decimal32(unsigned long long __coeff, int __exponent)
{
decimal32 __decexp = 1, __multiplier;
if (__exponent < 0)
{
__multiplier = 1.E-1DF;
__exponent = -__exponent;
}
else
__multiplier = 1.E1DF;
for (int __i = 0; __i < __exponent; ++__i)
__decexp *= __multiplier;
return __coeff * __decexp;
}
static decimal64 make_decimal64(long long __coeff, int __exponent)
{
decimal64 __decexp = 1, __multiplier;
if (__exponent < 0)
{
__multiplier = 1.E-1DD;
__exponent = -__exponent;
}
else
__multiplier = 1.E1DD;
for (int __i = 0; __i < __exponent; ++__i)
__decexp *= __multiplier;
return __coeff * __decexp;
}
static decimal64 make_decimal64(unsigned long long __coeff, int __exponent)
{
decimal64 __decexp = 1, __multiplier;
if (__exponent < 0)
{
__multiplier = 1.E-1DD;
__exponent = -__exponent;
}
else
__multiplier = 1.E1DD;
for (int __i = 0; __i < __exponent; ++__i)
__decexp *= __multiplier;
return __coeff * __decexp;
}
static decimal128 make_decimal128(long long __coeff, int __exponent)
{
decimal128 __decexp = 1, __multiplier;
if (__exponent < 0)
{
__multiplier = 1.E-1DL;
__exponent = -__exponent;
}
else
__multiplier = 1.E1DL;
for (int __i = 0; __i < __exponent; ++__i)
__decexp *= __multiplier;
return __coeff * __decexp;
}
static decimal128 make_decimal128(unsigned long long __coeff, int __exponent)
{
decimal128 __decexp = 1, __multiplier;
if (__exponent < 0)
{
__multiplier = 1.E-1DL;
__exponent = -__exponent;
}
else
__multiplier = 1.E1DL;
for (int __i = 0; __i < __exponent; ++__i)
__decexp *= __multiplier;
return __coeff * __decexp;
}
// ISO/IEC TR 24733 3.2.6 Conversion to generic floating-point type.
inline float decimal32_to_float(decimal32 __d)
{ return (float)__d.__getval(); }
inline float decimal64_to_float(decimal64 __d)
{ return (float)__d.__getval(); }
inline float decimal128_to_float(decimal128 __d)
{ return (float)__d.__getval(); }
inline float decimal_to_float(decimal32 __d)
{ return (float)__d.__getval(); }
inline float decimal_to_float(decimal64 __d)
{ return (float)__d.__getval(); }
inline float decimal_to_float(decimal128 __d)
{ return (float)__d.__getval(); }
inline double decimal32_to_double(decimal32 __d)
{ return (double)__d.__getval(); }
inline double decimal64_to_double(decimal64 __d)
{ return (double)__d.__getval(); }
inline double decimal128_to_double(decimal128 __d)
{ return (double)__d.__getval(); }
inline double decimal_to_double(decimal32 __d)
{ return (double)__d.__getval(); }
inline double decimal_to_double(decimal64 __d)
{ return (double)__d.__getval(); }
inline double decimal_to_double(decimal128 __d)
{ return (double)__d.__getval(); }
inline long double decimal32_to_long_double(decimal32 __d)
{ return (long double)__d.__getval(); }
inline long double decimal64_to_long_double(decimal64 __d)
{ return (long double)__d.__getval(); }
inline long double decimal128_to_long_double(decimal128 __d)
{ return (long double)__d.__getval(); }
inline long double decimal_to_long_double(decimal32 __d)
{ return (long double)__d.__getval(); }
inline long double decimal_to_long_double(decimal64 __d)
{ return (long double)__d.__getval(); }
inline long double decimal_to_long_double(decimal128 __d)
{ return (long double)__d.__getval(); }
// ISO/IEC TR 24733 3.2.7 Unary arithmetic operators.
#define _DEFINE_DECIMAL_UNARY_OP(_Op, _Tp) \
inline _Tp operator _Op(_Tp __rhs) \
{ \
_Tp __tmp; \
__tmp.__setval(_Op __rhs.__getval()); \
return __tmp; \
}
_DEFINE_DECIMAL_UNARY_OP(+, decimal32)
_DEFINE_DECIMAL_UNARY_OP(+, decimal64)
_DEFINE_DECIMAL_UNARY_OP(+, decimal128)
_DEFINE_DECIMAL_UNARY_OP(-, decimal32)
_DEFINE_DECIMAL_UNARY_OP(-, decimal64)
_DEFINE_DECIMAL_UNARY_OP(-, decimal128)
#undef _DEFINE_DECIMAL_UNARY_OP
// ISO/IEC TR 24733 3.2.8 Binary arithmetic operators.
#define _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(_Op, _T1, _T2, _T3) \
inline _T1 operator _Op(_T2 __lhs, _T3 __rhs) \
{ \
_T1 __retval; \
__retval.__setval(__lhs.__getval() _Op __rhs.__getval()); \
return __retval; \
}
#define _DEFINE_DECIMAL_BINARY_OP_BOTH(_Op, _T1, _T2, _T3) \
inline _T1 operator _Op(_T2 __lhs, _T3 __rhs) \
{ \
_T1 __retval; \
__retval.__setval(__lhs.__getval() _Op __rhs.__getval()); \
return __retval; \
}
#define _DEFINE_DECIMAL_BINARY_OP_LHS(_Op, _T1, _T2) \
inline _T1 operator _Op(_T1 __lhs, _T2 __rhs) \
{ \
_T1 __retval; \
__retval.__setval(__lhs.__getval() _Op __rhs); \
return __retval; \
}
#define _DEFINE_DECIMAL_BINARY_OP_RHS(_Op, _T1, _T2) \
inline _T1 operator _Op(_T2 __lhs, _T1 __rhs) \
{ \
_T1 __retval; \
__retval.__setval(__lhs _Op __rhs.__getval()); \
return __retval; \
}
#define _DEFINE_DECIMAL_BINARY_OP_WITH_INT(_Op, _T1) \
_DEFINE_DECIMAL_BINARY_OP_LHS(_Op, _T1, int); \
_DEFINE_DECIMAL_BINARY_OP_LHS(_Op, _T1, unsigned int); \
_DEFINE_DECIMAL_BINARY_OP_LHS(_Op, _T1, long); \
_DEFINE_DECIMAL_BINARY_OP_LHS(_Op, _T1, unsigned long); \
_DEFINE_DECIMAL_BINARY_OP_LHS(_Op, _T1, long long); \
_DEFINE_DECIMAL_BINARY_OP_LHS(_Op, _T1, unsigned long long); \
_DEFINE_DECIMAL_BINARY_OP_RHS(_Op, _T1, int); \
_DEFINE_DECIMAL_BINARY_OP_RHS(_Op, _T1, unsigned int); \
_DEFINE_DECIMAL_BINARY_OP_RHS(_Op, _T1, long); \
_DEFINE_DECIMAL_BINARY_OP_RHS(_Op, _T1, unsigned long); \
_DEFINE_DECIMAL_BINARY_OP_RHS(_Op, _T1, long long); \
_DEFINE_DECIMAL_BINARY_OP_RHS(_Op, _T1, unsigned long long); \
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal32, decimal32, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_INT(+, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal64, decimal32, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal64, decimal64, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal64, decimal64, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_INT(+, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal32, decimal128)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal64, decimal128)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal128, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal128, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal128, decimal128)
_DEFINE_DECIMAL_BINARY_OP_WITH_INT(+, decimal128)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal32, decimal32, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_INT(-, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal64, decimal32, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal64, decimal64, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal64, decimal64, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_INT(-, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal32, decimal128)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal64, decimal128)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal128, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal128, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal128, decimal128)
_DEFINE_DECIMAL_BINARY_OP_WITH_INT(-, decimal128)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal32, decimal32, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_INT(*, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal64, decimal32, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal64, decimal64, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal64, decimal64, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_INT(*, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal32, decimal128)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal64, decimal128)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal128, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal128, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal128, decimal128)
_DEFINE_DECIMAL_BINARY_OP_WITH_INT(*, decimal128)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal32, decimal32, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_INT(/, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal64, decimal32, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal64, decimal64, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal64, decimal64, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_INT(/, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal32, decimal128)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal64, decimal128)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal128, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal128, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal128, decimal128)
_DEFINE_DECIMAL_BINARY_OP_WITH_INT(/, decimal128)
#undef _DEFINE_DECIMAL_BINARY_OP_WITH_DEC
#undef _DEFINE_DECIMAL_BINARY_OP_BOTH
#undef _DEFINE_DECIMAL_BINARY_OP_LHS
#undef _DEFINE_DECIMAL_BINARY_OP_RHS
#undef _DEFINE_DECIMAL_BINARY_OP_WITH_INT
// ISO/IEC TR 24733 3.2.9 Comparison operators.
#define _DEFINE_DECIMAL_COMPARISON_BOTH(_Op, _T1, _T2) \
inline bool operator _Op(_T1 __lhs, _T2 __rhs) \
{ return __lhs.__getval() _Op __rhs.__getval(); }
#define _DEFINE_DECIMAL_COMPARISON_LHS(_Op, _T1, _T2) \
inline bool operator _Op(_T1 __lhs, _T2 __rhs) \
{ return __lhs.__getval() _Op __rhs; }
#define _DEFINE_DECIMAL_COMPARISON_RHS(_Op, _T1, _T2) \
inline bool operator _Op(_T1 __lhs, _T2 __rhs) \
{ return __lhs _Op __rhs.__getval(); }
#define _DEFINE_DECIMAL_COMPARISONS(_Op, _Tp) \
_DEFINE_DECIMAL_COMPARISON_BOTH(_Op, _Tp, decimal32) \
_DEFINE_DECIMAL_COMPARISON_BOTH(_Op, _Tp, decimal64) \
_DEFINE_DECIMAL_COMPARISON_BOTH(_Op, _Tp, decimal128) \
_DEFINE_DECIMAL_COMPARISON_LHS(_Op, _Tp, int) \
_DEFINE_DECIMAL_COMPARISON_LHS(_Op, _Tp, unsigned int) \
_DEFINE_DECIMAL_COMPARISON_LHS(_Op, _Tp, long) \
_DEFINE_DECIMAL_COMPARISON_LHS(_Op, _Tp, unsigned long) \
_DEFINE_DECIMAL_COMPARISON_LHS(_Op, _Tp, long long) \
_DEFINE_DECIMAL_COMPARISON_LHS(_Op, _Tp, unsigned long long) \
_DEFINE_DECIMAL_COMPARISON_RHS(_Op, int, _Tp) \
_DEFINE_DECIMAL_COMPARISON_RHS(_Op, unsigned int, _Tp) \
_DEFINE_DECIMAL_COMPARISON_RHS(_Op, long, _Tp) \
_DEFINE_DECIMAL_COMPARISON_RHS(_Op, unsigned long, _Tp) \
_DEFINE_DECIMAL_COMPARISON_RHS(_Op, long long, _Tp) \
_DEFINE_DECIMAL_COMPARISON_RHS(_Op, unsigned long long, _Tp)
_DEFINE_DECIMAL_COMPARISONS(==, decimal32)
_DEFINE_DECIMAL_COMPARISONS(==, decimal64)
_DEFINE_DECIMAL_COMPARISONS(==, decimal128)
_DEFINE_DECIMAL_COMPARISONS(!=, decimal32)
_DEFINE_DECIMAL_COMPARISONS(!=, decimal64)
_DEFINE_DECIMAL_COMPARISONS(!=, decimal128)
_DEFINE_DECIMAL_COMPARISONS(<, decimal32)
_DEFINE_DECIMAL_COMPARISONS(<, decimal64)
_DEFINE_DECIMAL_COMPARISONS(<, decimal128)
_DEFINE_DECIMAL_COMPARISONS(<=, decimal32)
_DEFINE_DECIMAL_COMPARISONS(<=, decimal64)
_DEFINE_DECIMAL_COMPARISONS(<=, decimal128)
_DEFINE_DECIMAL_COMPARISONS(>, decimal32)
_DEFINE_DECIMAL_COMPARISONS(>, decimal64)
_DEFINE_DECIMAL_COMPARISONS(>, decimal128)
_DEFINE_DECIMAL_COMPARISONS(>=, decimal32)
_DEFINE_DECIMAL_COMPARISONS(>=, decimal64)
_DEFINE_DECIMAL_COMPARISONS(>=, decimal128)
#undef _DEFINE_DECIMAL_COMPARISON_BOTH
#undef _DEFINE_DECIMAL_COMPARISON_LHS
#undef _DEFINE_DECIMAL_COMPARISON_RHS
#undef _DEFINE_DECIMAL_COMPARISONS
} // namespace decimal
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif /* _GLIBCXX_DECIMAL_IMPL */
c++/8/decimal/decimal 0000644 00000042344 15201526705 0010214 0 ustar 00 // <decimal> -*- C++ -*-
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file decimal/decimal
* This is a Standard C++ Library header.
*/
// ISO/IEC TR 24733
// Written by Janis Johnson <janis187@us.ibm.com>
#ifndef _GLIBCXX_DECIMAL
#define _GLIBCXX_DECIMAL 1
#pragma GCC system_header
#include <bits/c++config.h>
#ifndef _GLIBCXX_USE_DECIMAL_FLOAT
#error This file requires compiler and library support for ISO/IEC TR 24733 \
that is currently not available.
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @defgroup decimal Decimal Floating-Point Arithmetic
* @ingroup numerics
*
* Classes and functions for decimal floating-point arithmetic.
* @{
*/
/** @namespace std::decimal
* @brief ISO/IEC TR 24733 Decimal floating-point arithmetic.
*/
namespace decimal
{
class decimal32;
class decimal64;
class decimal128;
// 3.2.5 Initialization from coefficient and exponent.
static decimal32 make_decimal32(long long __coeff, int __exp);
static decimal32 make_decimal32(unsigned long long __coeff, int __exp);
static decimal64 make_decimal64(long long __coeff, int __exp);
static decimal64 make_decimal64(unsigned long long __coeff, int __exp);
static decimal128 make_decimal128(long long __coeff, int __exp);
static decimal128 make_decimal128(unsigned long long __coeff, int __exp);
/// Non-conforming extension: Conversion to integral type.
long long decimal32_to_long_long(decimal32 __d);
long long decimal64_to_long_long(decimal64 __d);
long long decimal128_to_long_long(decimal128 __d);
long long decimal_to_long_long(decimal32 __d);
long long decimal_to_long_long(decimal64 __d);
long long decimal_to_long_long(decimal128 __d);
// 3.2.6 Conversion to generic floating-point type.
float decimal32_to_float(decimal32 __d);
float decimal64_to_float(decimal64 __d);
float decimal128_to_float(decimal128 __d);
float decimal_to_float(decimal32 __d);
float decimal_to_float(decimal64 __d);
float decimal_to_float(decimal128 __d);
double decimal32_to_double(decimal32 __d);
double decimal64_to_double(decimal64 __d);
double decimal128_to_double(decimal128 __d);
double decimal_to_double(decimal32 __d);
double decimal_to_double(decimal64 __d);
double decimal_to_double(decimal128 __d);
long double decimal32_to_long_double(decimal32 __d);
long double decimal64_to_long_double(decimal64 __d);
long double decimal128_to_long_double(decimal128 __d);
long double decimal_to_long_double(decimal32 __d);
long double decimal_to_long_double(decimal64 __d);
long double decimal_to_long_double(decimal128 __d);
// 3.2.7 Unary arithmetic operators.
decimal32 operator+(decimal32 __rhs);
decimal64 operator+(decimal64 __rhs);
decimal128 operator+(decimal128 __rhs);
decimal32 operator-(decimal32 __rhs);
decimal64 operator-(decimal64 __rhs);
decimal128 operator-(decimal128 __rhs);
// 3.2.8 Binary arithmetic operators.
#define _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(_Op, _T1, _T2, _T3) \
_T1 operator _Op(_T2 __lhs, _T3 __rhs);
#define _DECLARE_DECIMAL_BINARY_OP_WITH_INT(_Op, _Tp) \
_Tp operator _Op(_Tp __lhs, int __rhs); \
_Tp operator _Op(_Tp __lhs, unsigned int __rhs); \
_Tp operator _Op(_Tp __lhs, long __rhs); \
_Tp operator _Op(_Tp __lhs, unsigned long __rhs); \
_Tp operator _Op(_Tp __lhs, long long __rhs); \
_Tp operator _Op(_Tp __lhs, unsigned long long __rhs); \
_Tp operator _Op(int __lhs, _Tp __rhs); \
_Tp operator _Op(unsigned int __lhs, _Tp __rhs); \
_Tp operator _Op(long __lhs, _Tp __rhs); \
_Tp operator _Op(unsigned long __lhs, _Tp __rhs); \
_Tp operator _Op(long long __lhs, _Tp __rhs); \
_Tp operator _Op(unsigned long long __lhs, _Tp __rhs);
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal32, decimal32, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_INT(+, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal64, decimal32, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal64, decimal64, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal64, decimal64, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_INT(+, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal32, decimal128)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal64, decimal128)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal128, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal128, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal128, decimal128)
_DECLARE_DECIMAL_BINARY_OP_WITH_INT(+, decimal128)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal32, decimal32, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_INT(-, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal64, decimal32, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal64, decimal64, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal64, decimal64, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_INT(-, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal32, decimal128)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal64, decimal128)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal128, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal128, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal128, decimal128)
_DECLARE_DECIMAL_BINARY_OP_WITH_INT(-, decimal128)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal32, decimal32, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_INT(*, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal64, decimal32, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal64, decimal64, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal64, decimal64, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_INT(*, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal32, decimal128)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal64, decimal128)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal128, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal128, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal128, decimal128)
_DECLARE_DECIMAL_BINARY_OP_WITH_INT(*, decimal128)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal32, decimal32, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_INT(/, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal64, decimal32, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal64, decimal64, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal64, decimal64, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_INT(/, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal32, decimal128)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal64, decimal128)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal128, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal128, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal128, decimal128)
_DECLARE_DECIMAL_BINARY_OP_WITH_INT(/, decimal128)
#undef _DECLARE_DECIMAL_BINARY_OP_WITH_DEC
#undef _DECLARE_DECIMAL_BINARY_OP_WITH_INT
// 3.2.9 Comparison operators.
#define _DECLARE_DECIMAL_COMPARISON(_Op, _Tp) \
bool operator _Op(_Tp __lhs, decimal32 __rhs); \
bool operator _Op(_Tp __lhs, decimal64 __rhs); \
bool operator _Op(_Tp __lhs, decimal128 __rhs); \
bool operator _Op(_Tp __lhs, int __rhs); \
bool operator _Op(_Tp __lhs, unsigned int __rhs); \
bool operator _Op(_Tp __lhs, long __rhs); \
bool operator _Op(_Tp __lhs, unsigned long __rhs); \
bool operator _Op(_Tp __lhs, long long __rhs); \
bool operator _Op(_Tp __lhs, unsigned long long __rhs); \
bool operator _Op(int __lhs, _Tp __rhs); \
bool operator _Op(unsigned int __lhs, _Tp __rhs); \
bool operator _Op(long __lhs, _Tp __rhs); \
bool operator _Op(unsigned long __lhs, _Tp __rhs); \
bool operator _Op(long long __lhs, _Tp __rhs); \
bool operator _Op(unsigned long long __lhs, _Tp __rhs);
_DECLARE_DECIMAL_COMPARISON(==, decimal32)
_DECLARE_DECIMAL_COMPARISON(==, decimal64)
_DECLARE_DECIMAL_COMPARISON(==, decimal128)
_DECLARE_DECIMAL_COMPARISON(!=, decimal32)
_DECLARE_DECIMAL_COMPARISON(!=, decimal64)
_DECLARE_DECIMAL_COMPARISON(!=, decimal128)
_DECLARE_DECIMAL_COMPARISON(<, decimal32)
_DECLARE_DECIMAL_COMPARISON(<, decimal64)
_DECLARE_DECIMAL_COMPARISON(<, decimal128)
_DECLARE_DECIMAL_COMPARISON(>=, decimal32)
_DECLARE_DECIMAL_COMPARISON(>=, decimal64)
_DECLARE_DECIMAL_COMPARISON(>=, decimal128)
_DECLARE_DECIMAL_COMPARISON(>, decimal32)
_DECLARE_DECIMAL_COMPARISON(>, decimal64)
_DECLARE_DECIMAL_COMPARISON(>, decimal128)
_DECLARE_DECIMAL_COMPARISON(>=, decimal32)
_DECLARE_DECIMAL_COMPARISON(>=, decimal64)
_DECLARE_DECIMAL_COMPARISON(>=, decimal128)
#undef _DECLARE_DECIMAL_COMPARISON
/// 3.2.2 Class decimal32.
class decimal32
{
public:
typedef float __decfloat32 __attribute__((mode(SD)));
// 3.2.2.2 Construct/copy/destroy.
decimal32() : __val(0.e-101DF) {}
// 3.2.2.3 Conversion from floating-point type.
explicit decimal32(decimal64 __d64);
explicit decimal32(decimal128 __d128);
explicit decimal32(float __r) : __val(__r) {}
explicit decimal32(double __r) : __val(__r) {}
explicit decimal32(long double __r) : __val(__r) {}
// 3.2.2.4 Conversion from integral type.
decimal32(int __z) : __val(__z) {}
decimal32(unsigned int __z) : __val(__z) {}
decimal32(long __z) : __val(__z) {}
decimal32(unsigned long __z) : __val(__z) {}
decimal32(long long __z) : __val(__z) {}
decimal32(unsigned long long __z) : __val(__z) {}
/// Conforming extension: Conversion from scalar decimal type.
decimal32(__decfloat32 __z) : __val(__z) {}
#if __cplusplus >= 201103L
// 3.2.2.5 Conversion to integral type.
// Note: explicit per n3407.
explicit operator long long() const { return (long long)__val; }
#endif
// 3.2.2.6 Increment and decrement operators.
decimal32& operator++()
{
__val += 1;
return *this;
}
decimal32 operator++(int)
{
decimal32 __tmp = *this;
__val += 1;
return __tmp;
}
decimal32& operator--()
{
__val -= 1;
return *this;
}
decimal32 operator--(int)
{
decimal32 __tmp = *this;
__val -= 1;
return __tmp;
}
// 3.2.2.7 Compound assignment.
#define _DECLARE_DECIMAL32_COMPOUND_ASSIGNMENT(_Op) \
decimal32& operator _Op(decimal32 __rhs); \
decimal32& operator _Op(decimal64 __rhs); \
decimal32& operator _Op(decimal128 __rhs); \
decimal32& operator _Op(int __rhs); \
decimal32& operator _Op(unsigned int __rhs); \
decimal32& operator _Op(long __rhs); \
decimal32& operator _Op(unsigned long __rhs); \
decimal32& operator _Op(long long __rhs); \
decimal32& operator _Op(unsigned long long __rhs);
_DECLARE_DECIMAL32_COMPOUND_ASSIGNMENT(+=)
_DECLARE_DECIMAL32_COMPOUND_ASSIGNMENT(-=)
_DECLARE_DECIMAL32_COMPOUND_ASSIGNMENT(*=)
_DECLARE_DECIMAL32_COMPOUND_ASSIGNMENT(/=)
#undef _DECLARE_DECIMAL32_COMPOUND_ASSIGNMENT
private:
__decfloat32 __val;
public:
__decfloat32 __getval(void) { return __val; }
void __setval(__decfloat32 __x) { __val = __x; }
};
/// 3.2.3 Class decimal64.
class decimal64
{
public:
typedef float __decfloat64 __attribute__((mode(DD)));
// 3.2.3.2 Construct/copy/destroy.
decimal64() : __val(0.e-398dd) {}
// 3.2.3.3 Conversion from floating-point type.
decimal64(decimal32 d32);
explicit decimal64(decimal128 d128);
explicit decimal64(float __r) : __val(__r) {}
explicit decimal64(double __r) : __val(__r) {}
explicit decimal64(long double __r) : __val(__r) {}
// 3.2.3.4 Conversion from integral type.
decimal64(int __z) : __val(__z) {}
decimal64(unsigned int __z) : __val(__z) {}
decimal64(long __z) : __val(__z) {}
decimal64(unsigned long __z) : __val(__z) {}
decimal64(long long __z) : __val(__z) {}
decimal64(unsigned long long __z) : __val(__z) {}
/// Conforming extension: Conversion from scalar decimal type.
decimal64(__decfloat64 __z) : __val(__z) {}
#if __cplusplus >= 201103L
// 3.2.3.5 Conversion to integral type.
// Note: explicit per n3407.
explicit operator long long() const { return (long long)__val; }
#endif
// 3.2.3.6 Increment and decrement operators.
decimal64& operator++()
{
__val += 1;
return *this;
}
decimal64 operator++(int)
{
decimal64 __tmp = *this;
__val += 1;
return __tmp;
}
decimal64& operator--()
{
__val -= 1;
return *this;
}
decimal64 operator--(int)
{
decimal64 __tmp = *this;
__val -= 1;
return __tmp;
}
// 3.2.3.7 Compound assignment.
#define _DECLARE_DECIMAL64_COMPOUND_ASSIGNMENT(_Op) \
decimal64& operator _Op(decimal32 __rhs); \
decimal64& operator _Op(decimal64 __rhs); \
decimal64& operator _Op(decimal128 __rhs); \
decimal64& operator _Op(int __rhs); \
decimal64& operator _Op(unsigned int __rhs); \
decimal64& operator _Op(long __rhs); \
decimal64& operator _Op(unsigned long __rhs); \
decimal64& operator _Op(long long __rhs); \
decimal64& operator _Op(unsigned long long __rhs);
_DECLARE_DECIMAL64_COMPOUND_ASSIGNMENT(+=)
_DECLARE_DECIMAL64_COMPOUND_ASSIGNMENT(-=)
_DECLARE_DECIMAL64_COMPOUND_ASSIGNMENT(*=)
_DECLARE_DECIMAL64_COMPOUND_ASSIGNMENT(/=)
#undef _DECLARE_DECIMAL64_COMPOUND_ASSIGNMENT
private:
__decfloat64 __val;
public:
__decfloat64 __getval(void) { return __val; }
void __setval(__decfloat64 __x) { __val = __x; }
};
/// 3.2.4 Class decimal128.
class decimal128
{
public:
typedef float __decfloat128 __attribute__((mode(TD)));
// 3.2.4.2 Construct/copy/destroy.
decimal128() : __val(0.e-6176DL) {}
// 3.2.4.3 Conversion from floating-point type.
decimal128(decimal32 d32);
decimal128(decimal64 d64);
explicit decimal128(float __r) : __val(__r) {}
explicit decimal128(double __r) : __val(__r) {}
explicit decimal128(long double __r) : __val(__r) {}
// 3.2.4.4 Conversion from integral type.
decimal128(int __z) : __val(__z) {}
decimal128(unsigned int __z) : __val(__z) {}
decimal128(long __z) : __val(__z) {}
decimal128(unsigned long __z) : __val(__z) {}
decimal128(long long __z) : __val(__z) {}
decimal128(unsigned long long __z) : __val(__z) {}
/// Conforming extension: Conversion from scalar decimal type.
decimal128(__decfloat128 __z) : __val(__z) {}
#if __cplusplus >= 201103L
// 3.2.4.5 Conversion to integral type.
// Note: explicit per n3407.
explicit operator long long() const { return (long long)__val; }
#endif
// 3.2.4.6 Increment and decrement operators.
decimal128& operator++()
{
__val += 1;
return *this;
}
decimal128 operator++(int)
{
decimal128 __tmp = *this;
__val += 1;
return __tmp;
}
decimal128& operator--()
{
__val -= 1;
return *this;
}
decimal128 operator--(int)
{
decimal128 __tmp = *this;
__val -= 1;
return __tmp;
}
// 3.2.4.7 Compound assignment.
#define _DECLARE_DECIMAL128_COMPOUND_ASSIGNMENT(_Op) \
decimal128& operator _Op(decimal32 __rhs); \
decimal128& operator _Op(decimal64 __rhs); \
decimal128& operator _Op(decimal128 __rhs); \
decimal128& operator _Op(int __rhs); \
decimal128& operator _Op(unsigned int __rhs); \
decimal128& operator _Op(long __rhs); \
decimal128& operator _Op(unsigned long __rhs); \
decimal128& operator _Op(long long __rhs); \
decimal128& operator _Op(unsigned long long __rhs);
_DECLARE_DECIMAL128_COMPOUND_ASSIGNMENT(+=)
_DECLARE_DECIMAL128_COMPOUND_ASSIGNMENT(-=)
_DECLARE_DECIMAL128_COMPOUND_ASSIGNMENT(*=)
_DECLARE_DECIMAL128_COMPOUND_ASSIGNMENT(/=)
#undef _DECLARE_DECIMAL128_COMPOUND_ASSIGNMENT
private:
__decfloat128 __val;
public:
__decfloat128 __getval(void) { return __val; }
void __setval(__decfloat128 __x) { __val = __x; }
};
#define _GLIBCXX_USE_DECIMAL_ 1
} // namespace decimal
// @} group decimal
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#include <decimal/decimal.h>
#endif /* _GLIBCXX_DECIMAL */
c++/8/forward_list 0000644 00000003051 15201526705 0007707 0 ustar 00 // <forward_list> -*- C++ -*-
// Copyright (C) 2008-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/forward_list
* This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_FORWARD_LIST
#define _GLIBCXX_FORWARD_LIST 1
#pragma GCC system_header
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
#include <bits/forward_list.h>
#include <bits/range_access.h>
#include <bits/forward_list.tcc>
#ifdef _GLIBCXX_DEBUG
# include <debug/forward_list>
#endif
#ifdef _GLIBCXX_PROFILE
# include <profile/forward_list>
#endif
#endif // C++11
#endif // _GLIBCXX_FORWARD_LIST
c++/8/variant 0000644 00000136162 15201526705 0006666 0 ustar 00 // <variant> -*- C++ -*-
// Copyright (C) 2016-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file variant
* This is the <variant> C++ Library header.
*/
#ifndef _GLIBCXX_VARIANT
#define _GLIBCXX_VARIANT 1
#pragma GCC system_header
#if __cplusplus >= 201703L
#include <type_traits>
#include <utility>
#include <bits/enable_special_members.h>
#include <bits/functexcept.h>
#include <bits/move.h>
#include <bits/functional_hash.h>
#include <bits/invoke.h>
#include <ext/aligned_buffer.h>
#include <bits/parse_numbers.h>
#include <bits/stl_iterator_base_types.h>
#include <bits/stl_iterator_base_funcs.h>
#include <bits/stl_construct.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
namespace __detail
{
namespace __variant
{
template<size_t _Np, typename... _Types>
struct _Nth_type;
template<size_t _Np, typename _First, typename... _Rest>
struct _Nth_type<_Np, _First, _Rest...>
: _Nth_type<_Np-1, _Rest...> { };
template<typename _First, typename... _Rest>
struct _Nth_type<0, _First, _Rest...>
{ using type = _First; };
} // namespace __variant
} // namespace __detail
#define __cpp_lib_variant 201606L
template<typename... _Types> class tuple;
template<typename... _Types> class variant;
template <typename> struct hash;
template<typename _Variant>
struct variant_size;
template<typename _Variant>
struct variant_size<const _Variant> : variant_size<_Variant> {};
template<typename _Variant>
struct variant_size<volatile _Variant> : variant_size<_Variant> {};
template<typename _Variant>
struct variant_size<const volatile _Variant> : variant_size<_Variant> {};
template<typename... _Types>
struct variant_size<variant<_Types...>>
: std::integral_constant<size_t, sizeof...(_Types)> {};
template<typename _Variant>
inline constexpr size_t variant_size_v = variant_size<_Variant>::value;
template<size_t _Np, typename _Variant>
struct variant_alternative;
template<size_t _Np, typename _First, typename... _Rest>
struct variant_alternative<_Np, variant<_First, _Rest...>>
: variant_alternative<_Np-1, variant<_Rest...>> {};
template<typename _First, typename... _Rest>
struct variant_alternative<0, variant<_First, _Rest...>>
{ using type = _First; };
template<size_t _Np, typename _Variant>
using variant_alternative_t =
typename variant_alternative<_Np, _Variant>::type;
template<size_t _Np, typename _Variant>
struct variant_alternative<_Np, const _Variant>
{ using type = add_const_t<variant_alternative_t<_Np, _Variant>>; };
template<size_t _Np, typename _Variant>
struct variant_alternative<_Np, volatile _Variant>
{ using type = add_volatile_t<variant_alternative_t<_Np, _Variant>>; };
template<size_t _Np, typename _Variant>
struct variant_alternative<_Np, const volatile _Variant>
{ using type = add_cv_t<variant_alternative_t<_Np, _Variant>>; };
inline constexpr size_t variant_npos = -1;
template<size_t _Np, typename... _Types>
constexpr variant_alternative_t<_Np, variant<_Types...>>&
get(variant<_Types...>&);
template<size_t _Np, typename... _Types>
constexpr variant_alternative_t<_Np, variant<_Types...>>&&
get(variant<_Types...>&&);
template<size_t _Np, typename... _Types>
constexpr variant_alternative_t<_Np, variant<_Types...>> const&
get(const variant<_Types...>&);
template<size_t _Np, typename... _Types>
constexpr variant_alternative_t<_Np, variant<_Types...>> const&&
get(const variant<_Types...>&&);
namespace __detail
{
namespace __variant
{
// Returns the first apparence of _Tp in _Types.
// Returns sizeof...(_Types) if _Tp is not in _Types.
template<typename _Tp, typename... _Types>
struct __index_of : std::integral_constant<size_t, 0> {};
template<typename _Tp, typename... _Types>
inline constexpr size_t __index_of_v = __index_of<_Tp, _Types...>::value;
template<typename _Tp, typename _First, typename... _Rest>
struct __index_of<_Tp, _First, _Rest...> :
std::integral_constant<size_t, is_same_v<_Tp, _First>
? 0 : __index_of_v<_Tp, _Rest...> + 1> {};
// _Uninitialized<T> is guaranteed to be a literal type, even if T is not.
// We have to do this, because [basic.types]p10.5.3 (n4606) is not implemented
// yet. When it's implemented, _Uninitialized<T> can be changed to the alias
// to T, therefore equivalent to being removed entirely.
//
// Another reason we may not want to remove _Uninitialzied<T> may be that, we
// want _Uninitialized<T> to be trivially destructible, no matter whether T
// is; but we will see.
template<typename _Type, bool = std::is_literal_type_v<_Type>>
struct _Uninitialized;
template<typename _Type>
struct _Uninitialized<_Type, true>
{
template<typename... _Args>
constexpr _Uninitialized(in_place_index_t<0>, _Args&&... __args)
: _M_storage(std::forward<_Args>(__args)...)
{ }
constexpr const _Type& _M_get() const &
{ return _M_storage; }
constexpr _Type& _M_get() &
{ return _M_storage; }
constexpr const _Type&& _M_get() const &&
{ return std::move(_M_storage); }
constexpr _Type&& _M_get() &&
{ return std::move(_M_storage); }
_Type _M_storage;
};
template<typename _Type>
struct _Uninitialized<_Type, false>
{
template<typename... _Args>
constexpr _Uninitialized(in_place_index_t<0>, _Args&&... __args)
{ ::new (&_M_storage) _Type(std::forward<_Args>(__args)...); }
const _Type& _M_get() const &
{ return *_M_storage._M_ptr(); }
_Type& _M_get() &
{ return *_M_storage._M_ptr(); }
const _Type&& _M_get() const &&
{ return std::move(*_M_storage._M_ptr()); }
_Type&& _M_get() &&
{ return std::move(*_M_storage._M_ptr()); }
__gnu_cxx::__aligned_membuf<_Type> _M_storage;
};
template<typename _Ref>
_Ref __ref_cast(void* __ptr)
{
return static_cast<_Ref>(*static_cast<remove_reference_t<_Ref>*>(__ptr));
}
template<typename _Union>
constexpr decltype(auto) __get(in_place_index_t<0>, _Union&& __u)
{ return std::forward<_Union>(__u)._M_first._M_get(); }
template<size_t _Np, typename _Union>
constexpr decltype(auto) __get(in_place_index_t<_Np>, _Union&& __u)
{
return __variant::__get(in_place_index<_Np-1>,
std::forward<_Union>(__u)._M_rest);
}
// Returns the typed storage for __v.
template<size_t _Np, typename _Variant>
constexpr decltype(auto) __get(_Variant&& __v)
{
return __variant::__get(std::in_place_index<_Np>,
std::forward<_Variant>(__v)._M_u);
}
// Various functions as "vtable" entries, where those vtables are used by
// polymorphic operations.
template<typename _Lhs, typename _Rhs>
void
__erased_ctor(void* __lhs, void* __rhs)
{
using _Type = remove_reference_t<_Lhs>;
::new (__lhs) _Type(__variant::__ref_cast<_Rhs>(__rhs));
}
template<typename _Variant, size_t _Np>
void
__erased_dtor(_Variant&& __v)
{ std::_Destroy(std::__addressof(__variant::__get<_Np>(__v))); }
template<typename _Lhs, typename _Rhs>
void
__erased_assign(void* __lhs, void* __rhs)
{
__variant::__ref_cast<_Lhs>(__lhs) = __variant::__ref_cast<_Rhs>(__rhs);
}
template<typename _Lhs, typename _Rhs>
void
__erased_swap(void* __lhs, void* __rhs)
{
using std::swap;
swap(__variant::__ref_cast<_Lhs>(__lhs),
__variant::__ref_cast<_Rhs>(__rhs));
}
#define _VARIANT_RELATION_FUNCTION_TEMPLATE(__OP, __NAME) \
template<typename _Variant, size_t _Np> \
constexpr bool \
__erased_##__NAME(const _Variant& __lhs, const _Variant& __rhs) \
{ \
return __variant::__get<_Np>(std::forward<_Variant>(__lhs)) \
__OP __variant::__get<_Np>(std::forward<_Variant>(__rhs)); \
}
_VARIANT_RELATION_FUNCTION_TEMPLATE(<, less)
_VARIANT_RELATION_FUNCTION_TEMPLATE(<=, less_equal)
_VARIANT_RELATION_FUNCTION_TEMPLATE(==, equal)
_VARIANT_RELATION_FUNCTION_TEMPLATE(!=, not_equal)
_VARIANT_RELATION_FUNCTION_TEMPLATE(>=, greater_equal)
_VARIANT_RELATION_FUNCTION_TEMPLATE(>, greater)
#undef _VARIANT_RELATION_FUNCTION_TEMPLATE
template<typename _Tp>
size_t
__erased_hash(void* __t)
{
return std::hash<remove_cv_t<remove_reference_t<_Tp>>>{}(
__variant::__ref_cast<_Tp>(__t));
}
template<typename... _Types>
struct _Traits
{
static constexpr bool _S_default_ctor =
is_default_constructible_v<typename _Nth_type<0, _Types...>::type>;
static constexpr bool _S_copy_ctor =
(is_copy_constructible_v<_Types> && ...);
static constexpr bool _S_move_ctor =
(is_move_constructible_v<_Types> && ...);
static constexpr bool _S_copy_assign =
_S_copy_ctor && _S_move_ctor
&& (is_copy_assignable_v<_Types> && ...);
static constexpr bool _S_move_assign =
_S_move_ctor
&& (is_move_assignable_v<_Types> && ...);
static constexpr bool _S_trivial_dtor =
(is_trivially_destructible_v<_Types> && ...);
static constexpr bool _S_trivial_copy_ctor =
(is_trivially_copy_constructible_v<_Types> && ...);
static constexpr bool _S_trivial_move_ctor =
(is_trivially_move_constructible_v<_Types> && ...);
static constexpr bool _S_trivial_copy_assign =
_S_trivial_dtor && (is_trivially_copy_assignable_v<_Types> && ...);
static constexpr bool _S_trivial_move_assign =
_S_trivial_dtor && (is_trivially_move_assignable_v<_Types> && ...);
// The following nothrow traits are for non-trivial SMFs. Trivial SMFs
// are always nothrow.
static constexpr bool _S_nothrow_default_ctor =
is_nothrow_default_constructible_v<
typename _Nth_type<0, _Types...>::type>;
static constexpr bool _S_nothrow_copy_ctor = false;
static constexpr bool _S_nothrow_move_ctor =
(is_nothrow_move_constructible_v<_Types> && ...);
static constexpr bool _S_nothrow_copy_assign = false;
static constexpr bool _S_nothrow_move_assign =
_S_nothrow_move_ctor && (is_nothrow_move_assignable_v<_Types> && ...);
};
// Defines members and ctors.
template<typename... _Types>
union _Variadic_union { };
template<typename _First, typename... _Rest>
union _Variadic_union<_First, _Rest...>
{
constexpr _Variadic_union() : _M_rest() { }
template<typename... _Args>
constexpr _Variadic_union(in_place_index_t<0>, _Args&&... __args)
: _M_first(in_place_index<0>, std::forward<_Args>(__args)...)
{ }
template<size_t _Np, typename... _Args>
constexpr _Variadic_union(in_place_index_t<_Np>, _Args&&... __args)
: _M_rest(in_place_index<_Np-1>, std::forward<_Args>(__args)...)
{ }
_Uninitialized<_First> _M_first;
_Variadic_union<_Rest...> _M_rest;
};
// Defines index and the dtor, possibly trivial.
template<bool __trivially_destructible, typename... _Types>
struct _Variant_storage;
template <typename... _Types>
using __select_index =
typename __select_int::_Select_int_base<sizeof...(_Types) + 1,
unsigned char,
unsigned short>::type::value_type;
template<typename... _Types>
struct _Variant_storage<false, _Types...>
{
template<size_t... __indices>
static constexpr void (*_S_vtable[])(const _Variant_storage&) =
{ &__erased_dtor<const _Variant_storage&, __indices>... };
constexpr _Variant_storage() : _M_index(variant_npos) { }
template<size_t _Np, typename... _Args>
constexpr _Variant_storage(in_place_index_t<_Np>, _Args&&... __args)
: _M_u(in_place_index<_Np>, std::forward<_Args>(__args)...),
_M_index(_Np)
{ }
template<size_t... __indices>
constexpr void _M_reset_impl(std::index_sequence<__indices...>)
{
if (_M_index != __index_type(variant_npos))
_S_vtable<__indices...>[_M_index](*this);
}
void _M_reset()
{
_M_reset_impl(std::index_sequence_for<_Types...>{});
_M_index = variant_npos;
}
~_Variant_storage()
{ _M_reset(); }
void*
_M_storage() const
{
return const_cast<void*>(static_cast<const void*>(
std::addressof(_M_u)));
}
constexpr bool
_M_valid() const noexcept
{
return this->_M_index != __index_type(variant_npos);
}
_Variadic_union<_Types...> _M_u;
using __index_type = __select_index<_Types...>;
__index_type _M_index;
};
template<typename... _Types>
struct _Variant_storage<true, _Types...>
{
constexpr _Variant_storage() : _M_index(variant_npos) { }
template<size_t _Np, typename... _Args>
constexpr _Variant_storage(in_place_index_t<_Np>, _Args&&... __args)
: _M_u(in_place_index<_Np>, std::forward<_Args>(__args)...),
_M_index(_Np)
{ }
void _M_reset()
{ _M_index = variant_npos; }
void*
_M_storage() const
{
return const_cast<void*>(static_cast<const void*>(
std::addressof(_M_u)));
}
constexpr bool
_M_valid() const noexcept
{
return this->_M_index != __index_type(variant_npos);
}
_Variadic_union<_Types...> _M_u;
using __index_type = __select_index<_Types...>;
__index_type _M_index;
};
template<typename... _Types>
using _Variant_storage_alias =
_Variant_storage<_Traits<_Types...>::_S_trivial_dtor, _Types...>;
// The following are (Copy|Move) (ctor|assign) layers for forwarding
// triviality and handling non-trivial SMF behaviors.
template<bool, typename... _Types>
struct _Copy_ctor_base : _Variant_storage_alias<_Types...>
{
using _Base = _Variant_storage_alias<_Types...>;
using _Base::_Base;
_Copy_ctor_base(const _Copy_ctor_base& __rhs)
noexcept(_Traits<_Types...>::_S_nothrow_copy_ctor)
{
if (__rhs._M_valid())
{
static constexpr void (*_S_vtable[])(void*, void*) =
{ &__erased_ctor<_Types&, const _Types&>... };
_S_vtable[__rhs._M_index](this->_M_storage(), __rhs._M_storage());
this->_M_index = __rhs._M_index;
}
}
_Copy_ctor_base(_Copy_ctor_base&&) = default;
_Copy_ctor_base& operator=(const _Copy_ctor_base&) = default;
_Copy_ctor_base& operator=(_Copy_ctor_base&&) = default;
};
template<typename... _Types>
struct _Copy_ctor_base<true, _Types...> : _Variant_storage_alias<_Types...>
{
using _Base = _Variant_storage_alias<_Types...>;
using _Base::_Base;
};
template<typename... _Types>
using _Copy_ctor_alias =
_Copy_ctor_base<_Traits<_Types...>::_S_trivial_copy_ctor, _Types...>;
template<bool, typename... _Types>
struct _Move_ctor_base : _Copy_ctor_alias<_Types...>
{
using _Base = _Copy_ctor_alias<_Types...>;
using _Base::_Base;
_Move_ctor_base(_Move_ctor_base&& __rhs)
noexcept(_Traits<_Types...>::_S_nothrow_move_ctor)
{
if (__rhs._M_valid())
{
static constexpr void (*_S_vtable[])(void*, void*) =
{ &__erased_ctor<_Types&, _Types&&>... };
_S_vtable[__rhs._M_index](this->_M_storage(), __rhs._M_storage());
this->_M_index = __rhs._M_index;
}
}
void _M_destructive_move(_Move_ctor_base&& __rhs)
{
this->~_Move_ctor_base();
__try
{
::new (this) _Move_ctor_base(std::move(__rhs));
}
__catch (...)
{
this->_M_index = variant_npos;
__throw_exception_again;
}
}
_Move_ctor_base(const _Move_ctor_base&) = default;
_Move_ctor_base& operator=(const _Move_ctor_base&) = default;
_Move_ctor_base& operator=(_Move_ctor_base&&) = default;
};
template<typename... _Types>
struct _Move_ctor_base<true, _Types...> : _Copy_ctor_alias<_Types...>
{
using _Base = _Copy_ctor_alias<_Types...>;
using _Base::_Base;
void _M_destructive_move(_Move_ctor_base&& __rhs)
{
this->~_Move_ctor_base();
::new (this) _Move_ctor_base(std::move(__rhs));
}
};
template<typename... _Types>
using _Move_ctor_alias =
_Move_ctor_base<_Traits<_Types...>::_S_trivial_move_ctor, _Types...>;
template<bool, typename... _Types>
struct _Copy_assign_base : _Move_ctor_alias<_Types...>
{
using _Base = _Move_ctor_alias<_Types...>;
using _Base::_Base;
_Copy_assign_base&
operator=(const _Copy_assign_base& __rhs)
noexcept(_Traits<_Types...>::_S_nothrow_copy_assign)
{
if (this->_M_index == __rhs._M_index)
{
if (__rhs._M_valid())
{
static constexpr void (*_S_vtable[])(void*, void*) =
{ &__erased_assign<_Types&, const _Types&>... };
_S_vtable[__rhs._M_index](this->_M_storage(),
__rhs._M_storage());
}
}
else
{
_Copy_assign_base __tmp(__rhs);
this->_M_destructive_move(std::move(__tmp));
}
__glibcxx_assert(this->_M_index == __rhs._M_index);
return *this;
}
_Copy_assign_base(const _Copy_assign_base&) = default;
_Copy_assign_base(_Copy_assign_base&&) = default;
_Copy_assign_base& operator=(_Copy_assign_base&&) = default;
};
template<typename... _Types>
struct _Copy_assign_base<true, _Types...> : _Move_ctor_alias<_Types...>
{
using _Base = _Move_ctor_alias<_Types...>;
using _Base::_Base;
};
template<typename... _Types>
using _Copy_assign_alias =
_Copy_assign_base<_Traits<_Types...>::_S_trivial_copy_assign,
_Types...>;
template<bool, typename... _Types>
struct _Move_assign_base : _Copy_assign_alias<_Types...>
{
using _Base = _Copy_assign_alias<_Types...>;
using _Base::_Base;
_Move_assign_base&
operator=(_Move_assign_base&& __rhs)
noexcept(_Traits<_Types...>::_S_nothrow_move_assign)
{
if (this->_M_index == __rhs._M_index)
{
if (__rhs._M_valid())
{
static constexpr void (*_S_vtable[])(void*, void*) =
{ &__erased_assign<_Types&, _Types&&>... };
_S_vtable[__rhs._M_index]
(this->_M_storage(), __rhs._M_storage());
}
}
else
{
_Move_assign_base __tmp(std::move(__rhs));
this->_M_destructive_move(std::move(__tmp));
}
__glibcxx_assert(this->_M_index == __rhs._M_index);
return *this;
}
_Move_assign_base(const _Move_assign_base&) = default;
_Move_assign_base(_Move_assign_base&&) = default;
_Move_assign_base& operator=(const _Move_assign_base&) = default;
};
template<typename... _Types>
struct _Move_assign_base<true, _Types...> : _Copy_assign_alias<_Types...>
{
using _Base = _Copy_assign_alias<_Types...>;
using _Base::_Base;
};
template<typename... _Types>
using _Move_assign_alias =
_Move_assign_base<_Traits<_Types...>::_S_trivial_move_assign,
_Types...>;
template<typename... _Types>
struct _Variant_base : _Move_assign_alias<_Types...>
{
using _Base = _Move_assign_alias<_Types...>;
constexpr
_Variant_base()
noexcept(_Traits<_Types...>::_S_nothrow_default_ctor)
: _Variant_base(in_place_index<0>) { }
template<size_t _Np, typename... _Args>
constexpr explicit
_Variant_base(in_place_index_t<_Np> __i, _Args&&... __args)
: _Base(__i, std::forward<_Args>(__args)...)
{ }
_Variant_base(const _Variant_base&) = default;
_Variant_base(_Variant_base&&) = default;
_Variant_base& operator=(const _Variant_base&) = default;
_Variant_base& operator=(_Variant_base&&) = default;
};
// For how many times does _Tp appear in _Tuple?
template<typename _Tp, typename _Tuple>
struct __tuple_count;
template<typename _Tp, typename _Tuple>
inline constexpr size_t __tuple_count_v =
__tuple_count<_Tp, _Tuple>::value;
template<typename _Tp, typename... _Types>
struct __tuple_count<_Tp, tuple<_Types...>>
: integral_constant<size_t, 0> { };
template<typename _Tp, typename _First, typename... _Rest>
struct __tuple_count<_Tp, tuple<_First, _Rest...>>
: integral_constant<
size_t,
__tuple_count_v<_Tp, tuple<_Rest...>> + is_same_v<_Tp, _First>> { };
// TODO: Reuse this in <tuple> ?
template<typename _Tp, typename... _Types>
inline constexpr bool __exactly_once =
__tuple_count_v<_Tp, tuple<_Types...>> == 1;
// Takes _Types and create an overloaded _S_fun for each type.
// If a type appears more than once in _Types, create only one overload.
template<typename... _Types>
struct __overload_set
{ static void _S_fun(); };
template<typename _First, typename... _Rest>
struct __overload_set<_First, _Rest...> : __overload_set<_Rest...>
{
using __overload_set<_Rest...>::_S_fun;
static integral_constant<size_t, sizeof...(_Rest)> _S_fun(_First);
};
template<typename... _Rest>
struct __overload_set<void, _Rest...> : __overload_set<_Rest...>
{
using __overload_set<_Rest...>::_S_fun;
};
// Helper for variant(_Tp&&) and variant::operator=(_Tp&&).
// __accepted_index maps the arbitrary _Tp to an alternative type in _Variant.
template<typename _Tp, typename _Variant, typename = void>
struct __accepted_index
{ static constexpr size_t value = variant_npos; };
template<typename _Tp, typename... _Types>
struct __accepted_index<
_Tp, variant<_Types...>,
decltype(__overload_set<_Types...>::_S_fun(std::declval<_Tp>()),
std::declval<void>())>
{
static constexpr size_t value = sizeof...(_Types) - 1
- decltype(__overload_set<_Types...>::
_S_fun(std::declval<_Tp>()))::value;
};
// Returns the raw storage for __v.
template<typename _Variant>
void* __get_storage(_Variant&& __v)
{ return __v._M_storage(); }
// Used for storing multi-dimensional vtable.
template<typename _Tp, size_t... _Dimensions>
struct _Multi_array
{
constexpr const _Tp&
_M_access() const
{ return _M_data; }
_Tp _M_data;
};
template<typename _Tp, size_t __first, size_t... __rest>
struct _Multi_array<_Tp, __first, __rest...>
{
template<typename... _Args>
constexpr const _Tp&
_M_access(size_t __first_index, _Args... __rest_indices) const
{ return _M_arr[__first_index]._M_access(__rest_indices...); }
_Multi_array<_Tp, __rest...> _M_arr[__first];
};
// Creates a multi-dimensional vtable recursively.
//
// For example,
// visit([](auto, auto){},
// variant<int, char>(), // typedef'ed as V1
// variant<float, double, long double>()) // typedef'ed as V2
// will trigger instantiations of:
// __gen_vtable_impl<_Multi_array<void(*)(V1&&, V2&&), 2, 3>,
// tuple<V1&&, V2&&>, std::index_sequence<>>
// __gen_vtable_impl<_Multi_array<void(*)(V1&&, V2&&), 3>,
// tuple<V1&&, V2&&>, std::index_sequence<0>>
// __gen_vtable_impl<_Multi_array<void(*)(V1&&, V2&&)>,
// tuple<V1&&, V2&&>, std::index_sequence<0, 0>>
// __gen_vtable_impl<_Multi_array<void(*)(V1&&, V2&&)>,
// tuple<V1&&, V2&&>, std::index_sequence<0, 1>>
// __gen_vtable_impl<_Multi_array<void(*)(V1&&, V2&&)>,
// tuple<V1&&, V2&&>, std::index_sequence<0, 2>>
// __gen_vtable_impl<_Multi_array<void(*)(V1&&, V2&&), 3>,
// tuple<V1&&, V2&&>, std::index_sequence<1>>
// __gen_vtable_impl<_Multi_array<void(*)(V1&&, V2&&)>,
// tuple<V1&&, V2&&>, std::index_sequence<1, 0>>
// __gen_vtable_impl<_Multi_array<void(*)(V1&&, V2&&)>,
// tuple<V1&&, V2&&>, std::index_sequence<1, 1>>
// __gen_vtable_impl<_Multi_array<void(*)(V1&&, V2&&)>,
// tuple<V1&&, V2&&>, std::index_sequence<1, 2>>
// The returned multi-dimensional vtable can be fast accessed by the visitor
// using index calculation.
template<typename _Array_type, typename _Variant_tuple, typename _Index_seq>
struct __gen_vtable_impl;
template<typename _Result_type, typename _Visitor, size_t... __dimensions,
typename... _Variants, size_t... __indices>
struct __gen_vtable_impl<
_Multi_array<_Result_type (*)(_Visitor, _Variants...), __dimensions...>,
tuple<_Variants...>, std::index_sequence<__indices...>>
{
using _Next =
remove_reference_t<typename _Nth_type<sizeof...(__indices),
_Variants...>::type>;
using _Array_type =
_Multi_array<_Result_type (*)(_Visitor, _Variants...),
__dimensions...>;
static constexpr _Array_type
_S_apply()
{
_Array_type __vtable{};
_S_apply_all_alts(
__vtable, make_index_sequence<variant_size_v<_Next>>());
return __vtable;
}
template<size_t... __var_indices>
static constexpr void
_S_apply_all_alts(_Array_type& __vtable,
std::index_sequence<__var_indices...>)
{
(_S_apply_single_alt<__var_indices>(
__vtable._M_arr[__var_indices]), ...);
}
template<size_t __index, typename _Tp>
static constexpr void
_S_apply_single_alt(_Tp& __element)
{
using _Alternative = variant_alternative_t<__index, _Next>;
__element = __gen_vtable_impl<
remove_reference_t<decltype(__element)>, tuple<_Variants...>,
std::index_sequence<__indices..., __index>>::_S_apply();
}
};
template<typename _Result_type, typename _Visitor, typename... _Variants,
size_t... __indices>
struct __gen_vtable_impl<
_Multi_array<_Result_type (*)(_Visitor, _Variants...)>,
tuple<_Variants...>, std::index_sequence<__indices...>>
{
using _Array_type =
_Multi_array<_Result_type (*)(_Visitor&&, _Variants...)>;
static constexpr decltype(auto)
__visit_invoke(_Visitor&& __visitor, _Variants... __vars)
{
return std::__invoke(std::forward<_Visitor>(__visitor),
__variant::__get<__indices>(std::forward<_Variants>(__vars))...);
}
static constexpr auto
_S_apply()
{ return _Array_type{&__visit_invoke}; }
};
template<typename _Result_type, typename _Visitor, typename... _Variants>
struct __gen_vtable
{
using _Func_ptr = _Result_type (*)(_Visitor&&, _Variants...);
using _Array_type =
_Multi_array<_Func_ptr,
variant_size_v<remove_reference_t<_Variants>>...>;
static constexpr _Array_type
_S_apply()
{
return __gen_vtable_impl<_Array_type, tuple<_Variants...>,
std::index_sequence<>>::_S_apply();
}
static constexpr auto _S_vtable = _S_apply();
};
template<size_t _Np, typename _Tp>
struct _Base_dedup : public _Tp { };
template<typename _Variant, typename __indices>
struct _Variant_hash_base;
template<typename... _Types, size_t... __indices>
struct _Variant_hash_base<variant<_Types...>,
std::index_sequence<__indices...>>
: _Base_dedup<__indices, __poison_hash<remove_const_t<_Types>>>... { };
} // namespace __variant
} // namespace __detail
template<typename _Tp, typename... _Types>
constexpr bool
holds_alternative(const variant<_Types...>& __v) noexcept
{
static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>,
"T should occur for exactly once in alternatives");
return __v.index() == __detail::__variant::__index_of_v<_Tp, _Types...>;
}
template<typename _Tp, typename... _Types>
constexpr _Tp& get(variant<_Types...>& __v)
{
static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>,
"T should occur for exactly once in alternatives");
static_assert(!is_void_v<_Tp>, "_Tp should not be void");
return std::get<__detail::__variant::__index_of_v<_Tp, _Types...>>(__v);
}
template<typename _Tp, typename... _Types>
constexpr _Tp&& get(variant<_Types...>&& __v)
{
static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>,
"T should occur for exactly once in alternatives");
static_assert(!is_void_v<_Tp>, "_Tp should not be void");
return std::get<__detail::__variant::__index_of_v<_Tp, _Types...>>(
std::move(__v));
}
template<typename _Tp, typename... _Types>
constexpr const _Tp& get(const variant<_Types...>& __v)
{
static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>,
"T should occur for exactly once in alternatives");
static_assert(!is_void_v<_Tp>, "_Tp should not be void");
return std::get<__detail::__variant::__index_of_v<_Tp, _Types...>>(__v);
}
template<typename _Tp, typename... _Types>
constexpr const _Tp&& get(const variant<_Types...>&& __v)
{
static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>,
"T should occur for exactly once in alternatives");
static_assert(!is_void_v<_Tp>, "_Tp should not be void");
return std::get<__detail::__variant::__index_of_v<_Tp, _Types...>>(
std::move(__v));
}
template<size_t _Np, typename... _Types>
constexpr add_pointer_t<variant_alternative_t<_Np, variant<_Types...>>>
get_if(variant<_Types...>* __ptr) noexcept
{
using _Alternative_type = variant_alternative_t<_Np, variant<_Types...>>;
static_assert(_Np < sizeof...(_Types),
"The index should be in [0, number of alternatives)");
static_assert(!is_void_v<_Alternative_type>, "_Tp should not be void");
if (__ptr && __ptr->index() == _Np)
return &__detail::__variant::__get<_Np>(*__ptr);
return nullptr;
}
template<size_t _Np, typename... _Types>
constexpr
add_pointer_t<const variant_alternative_t<_Np, variant<_Types...>>>
get_if(const variant<_Types...>* __ptr) noexcept
{
using _Alternative_type = variant_alternative_t<_Np, variant<_Types...>>;
static_assert(_Np < sizeof...(_Types),
"The index should be in [0, number of alternatives)");
static_assert(!is_void_v<_Alternative_type>, "_Tp should not be void");
if (__ptr && __ptr->index() == _Np)
return &__detail::__variant::__get<_Np>(*__ptr);
return nullptr;
}
template<typename _Tp, typename... _Types>
constexpr add_pointer_t<_Tp>
get_if(variant<_Types...>* __ptr) noexcept
{
static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>,
"T should occur for exactly once in alternatives");
static_assert(!is_void_v<_Tp>, "_Tp should not be void");
return std::get_if<__detail::__variant::__index_of_v<_Tp, _Types...>>(
__ptr);
}
template<typename _Tp, typename... _Types>
constexpr add_pointer_t<const _Tp>
get_if(const variant<_Types...>* __ptr)
noexcept
{
static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>,
"T should occur for exactly once in alternatives");
static_assert(!is_void_v<_Tp>, "_Tp should not be void");
return std::get_if<__detail::__variant::__index_of_v<_Tp, _Types...>>(
__ptr);
}
struct monostate { };
#define _VARIANT_RELATION_FUNCTION_TEMPLATE(__OP, __NAME) \
template<typename... _Types> \
constexpr bool operator __OP(const variant<_Types...>& __lhs, \
const variant<_Types...>& __rhs) \
{ \
return __lhs._M_##__NAME(__rhs, std::index_sequence_for<_Types...>{}); \
} \
\
constexpr bool operator __OP(monostate, monostate) noexcept \
{ return 0 __OP 0; }
_VARIANT_RELATION_FUNCTION_TEMPLATE(<, less)
_VARIANT_RELATION_FUNCTION_TEMPLATE(<=, less_equal)
_VARIANT_RELATION_FUNCTION_TEMPLATE(==, equal)
_VARIANT_RELATION_FUNCTION_TEMPLATE(!=, not_equal)
_VARIANT_RELATION_FUNCTION_TEMPLATE(>=, greater_equal)
_VARIANT_RELATION_FUNCTION_TEMPLATE(>, greater)
#undef _VARIANT_RELATION_FUNCTION_TEMPLATE
template<typename _Visitor, typename... _Variants>
constexpr decltype(auto) visit(_Visitor&&, _Variants&&...);
template<typename... _Types>
inline enable_if_t<(is_move_constructible_v<_Types> && ...)
&& (is_swappable_v<_Types> && ...)>
swap(variant<_Types...>& __lhs, variant<_Types...>& __rhs)
noexcept(noexcept(__lhs.swap(__rhs)))
{ __lhs.swap(__rhs); }
template<typename... _Types>
enable_if_t<!((is_move_constructible_v<_Types> && ...)
&& (is_swappable_v<_Types> && ...))>
swap(variant<_Types...>&, variant<_Types...>&) = delete;
class bad_variant_access : public exception
{
public:
bad_variant_access() noexcept : _M_reason("Unknown reason") { }
const char* what() const noexcept override
{ return _M_reason; }
private:
bad_variant_access(const char* __reason) : _M_reason(__reason) { }
const char* _M_reason;
friend void __throw_bad_variant_access(const char* __what);
};
inline void
__throw_bad_variant_access(const char* __what)
{ _GLIBCXX_THROW_OR_ABORT(bad_variant_access(__what)); }
template<typename... _Types>
class variant
: private __detail::__variant::_Variant_base<_Types...>,
private _Enable_default_constructor<
__detail::__variant::_Traits<_Types...>::_S_default_ctor,
variant<_Types...>>,
private _Enable_copy_move<
__detail::__variant::_Traits<_Types...>::_S_copy_ctor,
__detail::__variant::_Traits<_Types...>::_S_copy_assign,
__detail::__variant::_Traits<_Types...>::_S_move_ctor,
__detail::__variant::_Traits<_Types...>::_S_move_assign,
variant<_Types...>>
{
private:
static_assert(sizeof...(_Types) > 0,
"variant must have at least one alternative");
static_assert(!(std::is_reference_v<_Types> || ...),
"variant must have no reference alternative");
static_assert(!(std::is_void_v<_Types> || ...),
"variant must have no void alternative");
using _Base = __detail::__variant::_Variant_base<_Types...>;
using _Default_ctor_enabler =
_Enable_default_constructor<
__detail::__variant::_Traits<_Types...>::_S_default_ctor,
variant<_Types...>>;
template<typename _Tp>
static constexpr bool
__exactly_once = __detail::__variant::__exactly_once<_Tp, _Types...>;
template<typename _Tp>
static constexpr size_t __accepted_index =
__detail::__variant::__accepted_index<_Tp&&, variant>::value;
template<size_t _Np, bool = _Np < sizeof...(_Types)>
struct __to_type_impl;
template<size_t _Np>
struct __to_type_impl<_Np, true>
{ using type = variant_alternative_t<_Np, variant>; };
template<size_t _Np>
using __to_type = typename __to_type_impl<_Np>::type;
template<typename _Tp>
using __accepted_type = __to_type<__accepted_index<_Tp>>;
template<typename _Tp>
static constexpr size_t __index_of =
__detail::__variant::__index_of_v<_Tp, _Types...>;
using _Traits = __detail::__variant::_Traits<_Types...>;
template<typename _Tp>
struct __is_in_place_tag : false_type { };
template<typename _Tp>
struct __is_in_place_tag<in_place_type_t<_Tp>> : true_type { };
template<size_t _Np>
struct __is_in_place_tag<in_place_index_t<_Np>> : true_type { };
template<typename _Tp>
static constexpr bool __not_in_place_tag
= !__is_in_place_tag<decay_t<_Tp>>::value;
public:
variant() = default;
variant(const variant& __rhs) = default;
variant(variant&&) = default;
variant& operator=(const variant&) = default;
variant& operator=(variant&&) = default;
~variant() = default;
template<typename _Tp,
typename = enable_if_t<!is_same_v<decay_t<_Tp>, variant>>,
typename = enable_if_t<(sizeof...(_Types)>0)>,
typename = enable_if_t<__not_in_place_tag<_Tp>>,
typename = enable_if_t<__exactly_once<__accepted_type<_Tp&&>>
&& is_constructible_v<__accepted_type<_Tp&&>, _Tp&&>>>
constexpr
variant(_Tp&& __t)
noexcept(is_nothrow_constructible_v<__accepted_type<_Tp&&>, _Tp&&>)
: variant(in_place_index<__accepted_index<_Tp&&>>,
std::forward<_Tp>(__t))
{ __glibcxx_assert(holds_alternative<__accepted_type<_Tp&&>>(*this)); }
template<typename _Tp, typename... _Args,
typename = enable_if_t<__exactly_once<_Tp>
&& is_constructible_v<_Tp, _Args&&...>>>
constexpr explicit
variant(in_place_type_t<_Tp>, _Args&&... __args)
: variant(in_place_index<__index_of<_Tp>>,
std::forward<_Args>(__args)...)
{ __glibcxx_assert(holds_alternative<_Tp>(*this)); }
template<typename _Tp, typename _Up, typename... _Args,
typename = enable_if_t<__exactly_once<_Tp>
&& is_constructible_v<
_Tp, initializer_list<_Up>&, _Args&&...>>>
constexpr explicit
variant(in_place_type_t<_Tp>, initializer_list<_Up> __il,
_Args&&... __args)
: variant(in_place_index<__index_of<_Tp>>, __il,
std::forward<_Args>(__args)...)
{ __glibcxx_assert(holds_alternative<_Tp>(*this)); }
template<size_t _Np, typename... _Args,
typename = enable_if_t<
is_constructible_v<__to_type<_Np>, _Args&&...>>>
constexpr explicit
variant(in_place_index_t<_Np>, _Args&&... __args)
: _Base(in_place_index<_Np>, std::forward<_Args>(__args)...),
_Default_ctor_enabler(_Enable_default_constructor_tag{})
{ __glibcxx_assert(index() == _Np); }
template<size_t _Np, typename _Up, typename... _Args,
typename = enable_if_t<is_constructible_v<__to_type<_Np>,
initializer_list<_Up>&, _Args&&...>>>
constexpr explicit
variant(in_place_index_t<_Np>, initializer_list<_Up> __il,
_Args&&... __args)
: _Base(in_place_index<_Np>, __il, std::forward<_Args>(__args)...),
_Default_ctor_enabler(_Enable_default_constructor_tag{})
{ __glibcxx_assert(index() == _Np); }
template<typename _Tp>
enable_if_t<__exactly_once<__accepted_type<_Tp&&>>
&& is_constructible_v<__accepted_type<_Tp&&>, _Tp&&>
&& is_assignable_v<__accepted_type<_Tp&&>&, _Tp&&>
&& !is_same_v<decay_t<_Tp>, variant>, variant&>
operator=(_Tp&& __rhs)
noexcept(is_nothrow_assignable_v<__accepted_type<_Tp&&>&, _Tp&&>
&& is_nothrow_constructible_v<__accepted_type<_Tp&&>, _Tp&&>)
{
constexpr auto __index = __accepted_index<_Tp&&>;
if (index() == __index)
std::get<__index>(*this) = std::forward<_Tp>(__rhs);
else
this->emplace<__index>(std::forward<_Tp>(__rhs));
__glibcxx_assert(holds_alternative<__accepted_type<_Tp&&>>(*this));
return *this;
}
template<typename _Tp, typename... _Args>
enable_if_t<is_constructible_v<_Tp, _Args...> && __exactly_once<_Tp>,
_Tp&>
emplace(_Args&&... __args)
{
auto& ret =
this->emplace<__index_of<_Tp>>(std::forward<_Args>(__args)...);
__glibcxx_assert(holds_alternative<_Tp>(*this));
return ret;
}
template<typename _Tp, typename _Up, typename... _Args>
enable_if_t<is_constructible_v<_Tp, initializer_list<_Up>&, _Args...>
&& __exactly_once<_Tp>,
_Tp&>
emplace(initializer_list<_Up> __il, _Args&&... __args)
{
auto& ret =
this->emplace<__index_of<_Tp>>(__il,
std::forward<_Args>(__args)...);
__glibcxx_assert(holds_alternative<_Tp>(*this));
return ret;
}
template<size_t _Np, typename... _Args>
enable_if_t<is_constructible_v<variant_alternative_t<_Np, variant>,
_Args...>,
variant_alternative_t<_Np, variant>&>
emplace(_Args&&... __args)
{
static_assert(_Np < sizeof...(_Types),
"The index should be in [0, number of alternatives)");
this->~variant();
__try
{
::new (this) variant(in_place_index<_Np>,
std::forward<_Args>(__args)...);
}
__catch (...)
{
this->_M_index = variant_npos;
__throw_exception_again;
}
__glibcxx_assert(index() == _Np);
return std::get<_Np>(*this);
}
template<size_t _Np, typename _Up, typename... _Args>
enable_if_t<is_constructible_v<variant_alternative_t<_Np, variant>,
initializer_list<_Up>&, _Args...>,
variant_alternative_t<_Np, variant>&>
emplace(initializer_list<_Up> __il, _Args&&... __args)
{
static_assert(_Np < sizeof...(_Types),
"The index should be in [0, number of alternatives)");
this->~variant();
__try
{
::new (this) variant(in_place_index<_Np>, __il,
std::forward<_Args>(__args)...);
}
__catch (...)
{
this->_M_index = variant_npos;
__throw_exception_again;
}
__glibcxx_assert(index() == _Np);
return std::get<_Np>(*this);
}
constexpr bool valueless_by_exception() const noexcept
{ return !this->_M_valid(); }
constexpr size_t index() const noexcept
{
if (this->_M_index ==
typename _Base::__index_type(variant_npos))
return variant_npos;
return this->_M_index;
}
void
swap(variant& __rhs)
noexcept((__is_nothrow_swappable<_Types>::value && ...)
&& is_nothrow_move_constructible_v<variant>)
{
if (this->index() == __rhs.index())
{
if (this->_M_valid())
{
static constexpr void (*_S_vtable[])(void*, void*) =
{ &__detail::__variant::__erased_swap<_Types&, _Types&>... };
_S_vtable[__rhs._M_index](this->_M_storage(),
__rhs._M_storage());
}
}
else if (!this->_M_valid())
{
this->_M_destructive_move(std::move(__rhs));
__rhs._M_reset();
}
else if (!__rhs._M_valid())
{
__rhs._M_destructive_move(std::move(*this));
this->_M_reset();
}
else
{
auto __tmp = std::move(__rhs);
__rhs._M_destructive_move(std::move(*this));
this->_M_destructive_move(std::move(__tmp));
}
}
private:
#define _VARIANT_RELATION_FUNCTION_TEMPLATE(__OP, __NAME) \
template<size_t... __indices> \
static constexpr bool \
(*_S_erased_##__NAME[])(const variant&, const variant&) = \
{ &__detail::__variant::__erased_##__NAME< \
const variant&, __indices>... }; \
template<size_t... __indices> \
constexpr bool \
_M_##__NAME(const variant& __rhs, \
std::index_sequence<__indices...>) const \
{ \
auto __lhs_index = this->index(); \
auto __rhs_index = __rhs.index(); \
if (__lhs_index != __rhs_index || valueless_by_exception()) \
/* Modulo addition. */ \
return __lhs_index + 1 __OP __rhs_index + 1; \
return _S_erased_##__NAME<__indices...>[__lhs_index](*this, __rhs); \
}
_VARIANT_RELATION_FUNCTION_TEMPLATE(<, less)
_VARIANT_RELATION_FUNCTION_TEMPLATE(<=, less_equal)
_VARIANT_RELATION_FUNCTION_TEMPLATE(==, equal)
_VARIANT_RELATION_FUNCTION_TEMPLATE(!=, not_equal)
_VARIANT_RELATION_FUNCTION_TEMPLATE(>=, greater_equal)
_VARIANT_RELATION_FUNCTION_TEMPLATE(>, greater)
#undef _VARIANT_RELATION_FUNCTION_TEMPLATE
#ifdef __clang__
public:
using _Base::_M_u; // See https://bugs.llvm.org/show_bug.cgi?id=31852
private:
#endif
template<size_t _Np, typename _Vp>
friend constexpr decltype(auto) __detail::__variant::__get(_Vp&& __v);
template<typename _Vp>
friend void* __detail::__variant::__get_storage(_Vp&& __v);
#define _VARIANT_RELATION_FUNCTION_TEMPLATE(__OP) \
template<typename... _Tp> \
friend constexpr bool \
operator __OP(const variant<_Tp...>& __lhs, \
const variant<_Tp...>& __rhs);
_VARIANT_RELATION_FUNCTION_TEMPLATE(<)
_VARIANT_RELATION_FUNCTION_TEMPLATE(<=)
_VARIANT_RELATION_FUNCTION_TEMPLATE(==)
_VARIANT_RELATION_FUNCTION_TEMPLATE(!=)
_VARIANT_RELATION_FUNCTION_TEMPLATE(>=)
_VARIANT_RELATION_FUNCTION_TEMPLATE(>)
#undef _VARIANT_RELATION_FUNCTION_TEMPLATE
};
template<size_t _Np, typename... _Types>
constexpr variant_alternative_t<_Np, variant<_Types...>>&
get(variant<_Types...>& __v)
{
static_assert(_Np < sizeof...(_Types),
"The index should be in [0, number of alternatives)");
if (__v.index() != _Np)
__throw_bad_variant_access("Unexpected index");
return __detail::__variant::__get<_Np>(__v);
}
template<size_t _Np, typename... _Types>
constexpr variant_alternative_t<_Np, variant<_Types...>>&&
get(variant<_Types...>&& __v)
{
static_assert(_Np < sizeof...(_Types),
"The index should be in [0, number of alternatives)");
if (__v.index() != _Np)
__throw_bad_variant_access("Unexpected index");
return __detail::__variant::__get<_Np>(std::move(__v));
}
template<size_t _Np, typename... _Types>
constexpr const variant_alternative_t<_Np, variant<_Types...>>&
get(const variant<_Types...>& __v)
{
static_assert(_Np < sizeof...(_Types),
"The index should be in [0, number of alternatives)");
if (__v.index() != _Np)
__throw_bad_variant_access("Unexpected index");
return __detail::__variant::__get<_Np>(__v);
}
template<size_t _Np, typename... _Types>
constexpr const variant_alternative_t<_Np, variant<_Types...>>&&
get(const variant<_Types...>&& __v)
{
static_assert(_Np < sizeof...(_Types),
"The index should be in [0, number of alternatives)");
if (__v.index() != _Np)
__throw_bad_variant_access("Unexpected index");
return __detail::__variant::__get<_Np>(std::move(__v));
}
template<typename _Visitor, typename... _Variants>
constexpr decltype(auto)
visit(_Visitor&& __visitor, _Variants&&... __variants)
{
if ((__variants.valueless_by_exception() || ...))
__throw_bad_variant_access("Unexpected index");
using _Result_type =
decltype(std::forward<_Visitor>(__visitor)(
std::get<0>(std::forward<_Variants>(__variants))...));
constexpr auto& __vtable = __detail::__variant::__gen_vtable<
_Result_type, _Visitor&&, _Variants&&...>::_S_vtable;
auto __func_ptr = __vtable._M_access(__variants.index()...);
return (*__func_ptr)(std::forward<_Visitor>(__visitor),
std::forward<_Variants>(__variants)...);
}
template<bool, typename... _Types>
struct __variant_hash_call_base_impl
{
size_t
operator()(const variant<_Types...>& __t) const
noexcept((is_nothrow_invocable_v<hash<decay_t<_Types>>, _Types> && ...))
{
if (!__t.valueless_by_exception())
{
namespace __edv = __detail::__variant;
static constexpr size_t (*_S_vtable[])(void*) =
{ &__edv::__erased_hash<const _Types&>... };
return hash<size_t>{}(__t.index())
+ _S_vtable[__t.index()](__edv::__get_storage(__t));
}
return hash<size_t>{}(__t.index());
}
};
template<typename... _Types>
struct __variant_hash_call_base_impl<false, _Types...> {};
template<typename... _Types>
using __variant_hash_call_base =
__variant_hash_call_base_impl<(__poison_hash<remove_const_t<_Types>>::
__enable_hash_call &&...), _Types...>;
template<typename... _Types>
struct hash<variant<_Types...>>
: private __detail::__variant::_Variant_hash_base<
variant<_Types...>, std::index_sequence_for<_Types...>>,
public __variant_hash_call_base<_Types...>
{
using result_type [[__deprecated__]] = size_t;
using argument_type [[__deprecated__]] = variant<_Types...>;
};
template<>
struct hash<monostate>
{
using result_type [[__deprecated__]] = size_t;
using argument_type [[__deprecated__]] = monostate;
size_t
operator()(const monostate& __t) const noexcept
{
constexpr size_t __magic_monostate_hash = -7777;
return __magic_monostate_hash;
}
};
template<typename... _Types>
struct __is_fast_hash<hash<variant<_Types...>>>
: bool_constant<(__is_fast_hash<_Types>::value && ...)>
{ };
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // C++17
#endif // _GLIBCXX_VARIANT
c++/8/cfloat 0000644 00000003541 15201526705 0006464 0 ustar 00 // -*- C++ -*- forwarding header.
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/cfloat
* This is a Standard C++ Library file. You should @c \#include this file
* in your programs, rather than any of the @a *.h implementation files.
*
* This is the C++ version of the Standard C Library header @c float.h,
* and its contents are (mostly) the same as that header, but are all
* contained in the namespace @c std (except for names which are defined
* as macros in C).
*/
//
// ISO C++ 14882: 18.2.2 Implementation properties: C library
//
#pragma GCC system_header
#include <bits/c++config.h>
#include <float.h>
#ifndef _GLIBCXX_CFLOAT
#define _GLIBCXX_CFLOAT 1
#if __cplusplus >= 201103L
# ifndef DECIMAL_DIG
# define DECIMAL_DIG __DECIMAL_DIG__
# endif
# ifndef FLT_EVAL_METHOD
# define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
# endif
#endif
#endif
c++/8/codecvt 0000644 00000012335 15201526705 0006644 0 ustar 00 // <codecvt> -*- C++ -*-
// Copyright (C) 2015-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// ISO C++ 14882: 22.5 Standard code conversion facets
/** @file include/codecvt
* This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_CODECVT
#define _GLIBCXX_CODECVT 1
#pragma GCC system_header
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
#include <bits/locale_classes.h>
#include <bits/codecvt.h>
#ifdef _GLIBCXX_USE_C99_STDINT_TR1
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
enum codecvt_mode
{
consume_header = 4,
generate_header = 2,
little_endian = 1
};
template<typename _Elem, unsigned long _Maxcode = 0x10ffff,
codecvt_mode _Mode = (codecvt_mode)0>
class codecvt_utf8 : public codecvt<_Elem, char, mbstate_t>
{
public:
explicit
codecvt_utf8(size_t __refs = 0);
~codecvt_utf8();
};
template<typename _Elem, unsigned long _Maxcode = 0x10ffff,
codecvt_mode _Mode = (codecvt_mode)0>
class codecvt_utf16 : public codecvt<_Elem, char, mbstate_t>
{
public:
explicit
codecvt_utf16(size_t __refs = 0);
~codecvt_utf16();
};
template<typename _Elem, unsigned long _Maxcode = 0x10ffff,
codecvt_mode _Mode = (codecvt_mode)0>
class codecvt_utf8_utf16 : public codecvt<_Elem, char, mbstate_t>
{
public:
explicit
codecvt_utf8_utf16(size_t __refs = 0);
~codecvt_utf8_utf16();
};
#define _GLIBCXX_CODECVT_SPECIALIZATION2(_NAME, _ELEM) \
template<> \
class _NAME<_ELEM> \
: public codecvt<_ELEM, char, mbstate_t> \
{ \
public: \
typedef _ELEM intern_type; \
typedef char extern_type; \
typedef mbstate_t state_type; \
\
protected: \
_NAME(unsigned long __maxcode, codecvt_mode __mode, size_t __refs) \
: codecvt(__refs), _M_maxcode(__maxcode), _M_mode(__mode) { } \
\
virtual \
~_NAME(); \
\
virtual result \
do_out(state_type& __state, const intern_type* __from, \
const intern_type* __from_end, const intern_type*& __from_next, \
extern_type* __to, extern_type* __to_end, \
extern_type*& __to_next) const; \
\
virtual result \
do_unshift(state_type& __state, \
extern_type* __to, extern_type* __to_end, \
extern_type*& __to_next) const; \
\
virtual result \
do_in(state_type& __state, \
const extern_type* __from, const extern_type* __from_end, \
const extern_type*& __from_next, \
intern_type* __to, intern_type* __to_end, \
intern_type*& __to_next) const; \
\
virtual \
int do_encoding() const throw(); \
\
virtual \
bool do_always_noconv() const throw(); \
\
virtual \
int do_length(state_type&, const extern_type* __from, \
const extern_type* __end, size_t __max) const; \
\
virtual int \
do_max_length() const throw(); \
\
private: \
unsigned long _M_maxcode; \
codecvt_mode _M_mode; \
}
#define _GLIBCXX_CODECVT_SPECIALIZATION(_NAME, _ELEM) \
_GLIBCXX_CODECVT_SPECIALIZATION2(__ ## _NAME ## _base, _ELEM); \
template<unsigned long _Maxcode, codecvt_mode _Mode> \
class _NAME<_ELEM, _Maxcode, _Mode> \
: public __ ## _NAME ## _base<_ELEM> \
{ \
public: \
explicit \
_NAME(size_t __refs = 0) \
: __ ## _NAME ## _base<_ELEM>(std::min(_Maxcode, 0x10fffful), \
_Mode, __refs) \
{ } \
}
template<typename _Elem> class __codecvt_utf8_base;
template<typename _Elem> class __codecvt_utf16_base;
template<typename _Elem> class __codecvt_utf8_utf16_base;
_GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf8, char16_t);
_GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf16, char16_t);
_GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf8_utf16, char16_t);
_GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf8, char32_t);
_GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf16, char32_t);
_GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf8_utf16, char32_t);
#ifdef _GLIBCXX_USE_WCHAR_T
_GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf8, wchar_t);
_GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf16, wchar_t);
_GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf8_utf16, wchar_t);
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif // _GLIBCXX_USE_C99_STDINT_TR1
#endif
#endif /* _GLIBCXX_CODECVT */
c++/8/bits/shared_ptr.h 0000644 00000055611 15201526705 0010543 0 ustar 00 // shared_ptr and weak_ptr implementation -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// GCC Note: Based on files from version 1.32.0 of the Boost library.
// shared_count.hpp
// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
// shared_ptr.hpp
// Copyright (C) 1998, 1999 Greg Colvin and Beman Dawes.
// Copyright (C) 2001, 2002, 2003 Peter Dimov
// weak_ptr.hpp
// Copyright (C) 2001, 2002, 2003 Peter Dimov
// enable_shared_from_this.hpp
// Copyright (C) 2002 Peter Dimov
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/** @file
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{memory}
*/
#ifndef _SHARED_PTR_H
#define _SHARED_PTR_H 1
#include <bits/shared_ptr_base.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @addtogroup pointer_abstractions
* @{
*/
/// 20.7.2.2.11 shared_ptr I/O
template<typename _Ch, typename _Tr, typename _Tp, _Lock_policy _Lp>
inline std::basic_ostream<_Ch, _Tr>&
operator<<(std::basic_ostream<_Ch, _Tr>& __os,
const __shared_ptr<_Tp, _Lp>& __p)
{
__os << __p.get();
return __os;
}
template<typename _Del, typename _Tp, _Lock_policy _Lp>
inline _Del*
get_deleter(const __shared_ptr<_Tp, _Lp>& __p) noexcept
{
#if __cpp_rtti
return static_cast<_Del*>(__p._M_get_deleter(typeid(_Del)));
#else
return 0;
#endif
}
/// 20.7.2.2.10 shared_ptr get_deleter
template<typename _Del, typename _Tp>
inline _Del*
get_deleter(const shared_ptr<_Tp>& __p) noexcept
{
#if __cpp_rtti
return static_cast<_Del*>(__p._M_get_deleter(typeid(_Del)));
#else
return 0;
#endif
}
/**
* @brief A smart pointer with reference-counted copy semantics.
*
* The object pointed to is deleted when the last shared_ptr pointing to
* it is destroyed or reset.
*/
template<typename _Tp>
class shared_ptr : public __shared_ptr<_Tp>
{
template<typename... _Args>
using _Constructible = typename enable_if<
is_constructible<__shared_ptr<_Tp>, _Args...>::value
>::type;
template<typename _Arg>
using _Assignable = typename enable_if<
is_assignable<__shared_ptr<_Tp>&, _Arg>::value, shared_ptr&
>::type;
public:
using element_type = typename __shared_ptr<_Tp>::element_type;
#if __cplusplus > 201402L
# define __cpp_lib_shared_ptr_weak_type 201606
using weak_type = weak_ptr<_Tp>;
#endif
/**
* @brief Construct an empty %shared_ptr.
* @post use_count()==0 && get()==0
*/
constexpr shared_ptr() noexcept : __shared_ptr<_Tp>() { }
shared_ptr(const shared_ptr&) noexcept = default;
/**
* @brief Construct a %shared_ptr that owns the pointer @a __p.
* @param __p A pointer that is convertible to element_type*.
* @post use_count() == 1 && get() == __p
* @throw std::bad_alloc, in which case @c delete @a __p is called.
*/
template<typename _Yp, typename = _Constructible<_Yp*>>
explicit
shared_ptr(_Yp* __p) : __shared_ptr<_Tp>(__p) { }
/**
* @brief Construct a %shared_ptr that owns the pointer @a __p
* and the deleter @a __d.
* @param __p A pointer.
* @param __d A deleter.
* @post use_count() == 1 && get() == __p
* @throw std::bad_alloc, in which case @a __d(__p) is called.
*
* Requirements: _Deleter's copy constructor and destructor must
* not throw
*
* __shared_ptr will release __p by calling __d(__p)
*/
template<typename _Yp, typename _Deleter,
typename = _Constructible<_Yp*, _Deleter>>
shared_ptr(_Yp* __p, _Deleter __d)
: __shared_ptr<_Tp>(__p, std::move(__d)) { }
/**
* @brief Construct a %shared_ptr that owns a null pointer
* and the deleter @a __d.
* @param __p A null pointer constant.
* @param __d A deleter.
* @post use_count() == 1 && get() == __p
* @throw std::bad_alloc, in which case @a __d(__p) is called.
*
* Requirements: _Deleter's copy constructor and destructor must
* not throw
*
* The last owner will call __d(__p)
*/
template<typename _Deleter>
shared_ptr(nullptr_t __p, _Deleter __d)
: __shared_ptr<_Tp>(__p, std::move(__d)) { }
/**
* @brief Construct a %shared_ptr that owns the pointer @a __p
* and the deleter @a __d.
* @param __p A pointer.
* @param __d A deleter.
* @param __a An allocator.
* @post use_count() == 1 && get() == __p
* @throw std::bad_alloc, in which case @a __d(__p) is called.
*
* Requirements: _Deleter's copy constructor and destructor must
* not throw _Alloc's copy constructor and destructor must not
* throw.
*
* __shared_ptr will release __p by calling __d(__p)
*/
template<typename _Yp, typename _Deleter, typename _Alloc,
typename = _Constructible<_Yp*, _Deleter, _Alloc>>
shared_ptr(_Yp* __p, _Deleter __d, _Alloc __a)
: __shared_ptr<_Tp>(__p, std::move(__d), std::move(__a)) { }
/**
* @brief Construct a %shared_ptr that owns a null pointer
* and the deleter @a __d.
* @param __p A null pointer constant.
* @param __d A deleter.
* @param __a An allocator.
* @post use_count() == 1 && get() == __p
* @throw std::bad_alloc, in which case @a __d(__p) is called.
*
* Requirements: _Deleter's copy constructor and destructor must
* not throw _Alloc's copy constructor and destructor must not
* throw.
*
* The last owner will call __d(__p)
*/
template<typename _Deleter, typename _Alloc>
shared_ptr(nullptr_t __p, _Deleter __d, _Alloc __a)
: __shared_ptr<_Tp>(__p, std::move(__d), std::move(__a)) { }
// Aliasing constructor
/**
* @brief Constructs a %shared_ptr instance that stores @a __p
* and shares ownership with @a __r.
* @param __r A %shared_ptr.
* @param __p A pointer that will remain valid while @a *__r is valid.
* @post get() == __p && use_count() == __r.use_count()
*
* This can be used to construct a @c shared_ptr to a sub-object
* of an object managed by an existing @c shared_ptr.
*
* @code
* shared_ptr< pair<int,int> > pii(new pair<int,int>());
* shared_ptr<int> pi(pii, &pii->first);
* assert(pii.use_count() == 2);
* @endcode
*/
template<typename _Yp>
shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) noexcept
: __shared_ptr<_Tp>(__r, __p) { }
/**
* @brief If @a __r is empty, constructs an empty %shared_ptr;
* otherwise construct a %shared_ptr that shares ownership
* with @a __r.
* @param __r A %shared_ptr.
* @post get() == __r.get() && use_count() == __r.use_count()
*/
template<typename _Yp,
typename = _Constructible<const shared_ptr<_Yp>&>>
shared_ptr(const shared_ptr<_Yp>& __r) noexcept
: __shared_ptr<_Tp>(__r) { }
/**
* @brief Move-constructs a %shared_ptr instance from @a __r.
* @param __r A %shared_ptr rvalue.
* @post *this contains the old value of @a __r, @a __r is empty.
*/
shared_ptr(shared_ptr&& __r) noexcept
: __shared_ptr<_Tp>(std::move(__r)) { }
/**
* @brief Move-constructs a %shared_ptr instance from @a __r.
* @param __r A %shared_ptr rvalue.
* @post *this contains the old value of @a __r, @a __r is empty.
*/
template<typename _Yp, typename = _Constructible<shared_ptr<_Yp>>>
shared_ptr(shared_ptr<_Yp>&& __r) noexcept
: __shared_ptr<_Tp>(std::move(__r)) { }
/**
* @brief Constructs a %shared_ptr that shares ownership with @a __r
* and stores a copy of the pointer stored in @a __r.
* @param __r A weak_ptr.
* @post use_count() == __r.use_count()
* @throw bad_weak_ptr when __r.expired(),
* in which case the constructor has no effect.
*/
template<typename _Yp, typename = _Constructible<const weak_ptr<_Yp>&>>
explicit shared_ptr(const weak_ptr<_Yp>& __r)
: __shared_ptr<_Tp>(__r) { }
#if _GLIBCXX_USE_DEPRECATED
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
template<typename _Yp, typename = _Constructible<auto_ptr<_Yp>>>
shared_ptr(auto_ptr<_Yp>&& __r);
#pragma GCC diagnostic pop
#endif
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2399. shared_ptr's constructor from unique_ptr should be constrained
template<typename _Yp, typename _Del,
typename = _Constructible<unique_ptr<_Yp, _Del>>>
shared_ptr(unique_ptr<_Yp, _Del>&& __r)
: __shared_ptr<_Tp>(std::move(__r)) { }
#if __cplusplus <= 201402L && _GLIBCXX_USE_DEPRECATED
// This non-standard constructor exists to support conversions that
// were possible in C++11 and C++14 but are ill-formed in C++17.
// If an exception is thrown this constructor has no effect.
template<typename _Yp, typename _Del,
_Constructible<unique_ptr<_Yp, _Del>, __sp_array_delete>* = 0>
shared_ptr(unique_ptr<_Yp, _Del>&& __r)
: __shared_ptr<_Tp>(std::move(__r), __sp_array_delete()) { }
#endif
/**
* @brief Construct an empty %shared_ptr.
* @post use_count() == 0 && get() == nullptr
*/
constexpr shared_ptr(nullptr_t) noexcept : shared_ptr() { }
shared_ptr& operator=(const shared_ptr&) noexcept = default;
template<typename _Yp>
_Assignable<const shared_ptr<_Yp>&>
operator=(const shared_ptr<_Yp>& __r) noexcept
{
this->__shared_ptr<_Tp>::operator=(__r);
return *this;
}
#if _GLIBCXX_USE_DEPRECATED
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
template<typename _Yp>
_Assignable<auto_ptr<_Yp>>
operator=(auto_ptr<_Yp>&& __r)
{
this->__shared_ptr<_Tp>::operator=(std::move(__r));
return *this;
}
#pragma GCC diagnostic pop
#endif
shared_ptr&
operator=(shared_ptr&& __r) noexcept
{
this->__shared_ptr<_Tp>::operator=(std::move(__r));
return *this;
}
template<class _Yp>
_Assignable<shared_ptr<_Yp>>
operator=(shared_ptr<_Yp>&& __r) noexcept
{
this->__shared_ptr<_Tp>::operator=(std::move(__r));
return *this;
}
template<typename _Yp, typename _Del>
_Assignable<unique_ptr<_Yp, _Del>>
operator=(unique_ptr<_Yp, _Del>&& __r)
{
this->__shared_ptr<_Tp>::operator=(std::move(__r));
return *this;
}
private:
// This constructor is non-standard, it is used by allocate_shared.
template<typename _Alloc, typename... _Args>
shared_ptr(_Sp_alloc_shared_tag<_Alloc> __tag, _Args&&... __args)
: __shared_ptr<_Tp>(__tag, std::forward<_Args>(__args)...)
{ }
template<typename _Yp, typename _Alloc, typename... _Args>
friend shared_ptr<_Yp>
allocate_shared(const _Alloc& __a, _Args&&... __args);
// This constructor is non-standard, it is used by weak_ptr::lock().
shared_ptr(const weak_ptr<_Tp>& __r, std::nothrow_t)
: __shared_ptr<_Tp>(__r, std::nothrow) { }
friend class weak_ptr<_Tp>;
};
#if __cpp_deduction_guides >= 201606
template<typename _Tp>
shared_ptr(weak_ptr<_Tp>) -> shared_ptr<_Tp>;
template<typename _Tp, typename _Del>
shared_ptr(unique_ptr<_Tp, _Del>) -> shared_ptr<_Tp>;
#endif
// 20.7.2.2.7 shared_ptr comparisons
template<typename _Tp, typename _Up>
inline bool
operator==(const shared_ptr<_Tp>& __a, const shared_ptr<_Up>& __b) noexcept
{ return __a.get() == __b.get(); }
template<typename _Tp>
inline bool
operator==(const shared_ptr<_Tp>& __a, nullptr_t) noexcept
{ return !__a; }
template<typename _Tp>
inline bool
operator==(nullptr_t, const shared_ptr<_Tp>& __a) noexcept
{ return !__a; }
template<typename _Tp, typename _Up>
inline bool
operator!=(const shared_ptr<_Tp>& __a, const shared_ptr<_Up>& __b) noexcept
{ return __a.get() != __b.get(); }
template<typename _Tp>
inline bool
operator!=(const shared_ptr<_Tp>& __a, nullptr_t) noexcept
{ return (bool)__a; }
template<typename _Tp>
inline bool
operator!=(nullptr_t, const shared_ptr<_Tp>& __a) noexcept
{ return (bool)__a; }
template<typename _Tp, typename _Up>
inline bool
operator<(const shared_ptr<_Tp>& __a, const shared_ptr<_Up>& __b) noexcept
{
using _Tp_elt = typename shared_ptr<_Tp>::element_type;
using _Up_elt = typename shared_ptr<_Up>::element_type;
using _Vp = typename common_type<_Tp_elt*, _Up_elt*>::type;
return less<_Vp>()(__a.get(), __b.get());
}
template<typename _Tp>
inline bool
operator<(const shared_ptr<_Tp>& __a, nullptr_t) noexcept
{
using _Tp_elt = typename shared_ptr<_Tp>::element_type;
return less<_Tp_elt*>()(__a.get(), nullptr);
}
template<typename _Tp>
inline bool
operator<(nullptr_t, const shared_ptr<_Tp>& __a) noexcept
{
using _Tp_elt = typename shared_ptr<_Tp>::element_type;
return less<_Tp_elt*>()(nullptr, __a.get());
}
template<typename _Tp, typename _Up>
inline bool
operator<=(const shared_ptr<_Tp>& __a, const shared_ptr<_Up>& __b) noexcept
{ return !(__b < __a); }
template<typename _Tp>
inline bool
operator<=(const shared_ptr<_Tp>& __a, nullptr_t) noexcept
{ return !(nullptr < __a); }
template<typename _Tp>
inline bool
operator<=(nullptr_t, const shared_ptr<_Tp>& __a) noexcept
{ return !(__a < nullptr); }
template<typename _Tp, typename _Up>
inline bool
operator>(const shared_ptr<_Tp>& __a, const shared_ptr<_Up>& __b) noexcept
{ return (__b < __a); }
template<typename _Tp>
inline bool
operator>(const shared_ptr<_Tp>& __a, nullptr_t) noexcept
{ return nullptr < __a; }
template<typename _Tp>
inline bool
operator>(nullptr_t, const shared_ptr<_Tp>& __a) noexcept
{ return __a < nullptr; }
template<typename _Tp, typename _Up>
inline bool
operator>=(const shared_ptr<_Tp>& __a, const shared_ptr<_Up>& __b) noexcept
{ return !(__a < __b); }
template<typename _Tp>
inline bool
operator>=(const shared_ptr<_Tp>& __a, nullptr_t) noexcept
{ return !(__a < nullptr); }
template<typename _Tp>
inline bool
operator>=(nullptr_t, const shared_ptr<_Tp>& __a) noexcept
{ return !(nullptr < __a); }
template<typename _Tp>
struct less<shared_ptr<_Tp>> : public _Sp_less<shared_ptr<_Tp>>
{ };
// 20.7.2.2.8 shared_ptr specialized algorithms.
template<typename _Tp>
inline void
swap(shared_ptr<_Tp>& __a, shared_ptr<_Tp>& __b) noexcept
{ __a.swap(__b); }
// 20.7.2.2.9 shared_ptr casts.
template<typename _Tp, typename _Up>
inline shared_ptr<_Tp>
static_pointer_cast(const shared_ptr<_Up>& __r) noexcept
{
using _Sp = shared_ptr<_Tp>;
return _Sp(__r, static_cast<typename _Sp::element_type*>(__r.get()));
}
template<typename _Tp, typename _Up>
inline shared_ptr<_Tp>
const_pointer_cast(const shared_ptr<_Up>& __r) noexcept
{
using _Sp = shared_ptr<_Tp>;
return _Sp(__r, const_cast<typename _Sp::element_type*>(__r.get()));
}
template<typename _Tp, typename _Up>
inline shared_ptr<_Tp>
dynamic_pointer_cast(const shared_ptr<_Up>& __r) noexcept
{
using _Sp = shared_ptr<_Tp>;
if (auto* __p = dynamic_cast<typename _Sp::element_type*>(__r.get()))
return _Sp(__r, __p);
return _Sp();
}
#if __cplusplus > 201402L
template<typename _Tp, typename _Up>
inline shared_ptr<_Tp>
reinterpret_pointer_cast(const shared_ptr<_Up>& __r) noexcept
{
using _Sp = shared_ptr<_Tp>;
return _Sp(__r, reinterpret_cast<typename _Sp::element_type*>(__r.get()));
}
#endif
/**
* @brief A smart pointer with weak semantics.
*
* With forwarding constructors and assignment operators.
*/
template<typename _Tp>
class weak_ptr : public __weak_ptr<_Tp>
{
template<typename _Arg>
using _Constructible = typename enable_if<
is_constructible<__weak_ptr<_Tp>, _Arg>::value
>::type;
template<typename _Arg>
using _Assignable = typename enable_if<
is_assignable<__weak_ptr<_Tp>&, _Arg>::value, weak_ptr&
>::type;
public:
constexpr weak_ptr() noexcept = default;
template<typename _Yp,
typename = _Constructible<const shared_ptr<_Yp>&>>
weak_ptr(const shared_ptr<_Yp>& __r) noexcept
: __weak_ptr<_Tp>(__r) { }
weak_ptr(const weak_ptr&) noexcept = default;
template<typename _Yp, typename = _Constructible<const weak_ptr<_Yp>&>>
weak_ptr(const weak_ptr<_Yp>& __r) noexcept
: __weak_ptr<_Tp>(__r) { }
weak_ptr(weak_ptr&&) noexcept = default;
template<typename _Yp, typename = _Constructible<weak_ptr<_Yp>>>
weak_ptr(weak_ptr<_Yp>&& __r) noexcept
: __weak_ptr<_Tp>(std::move(__r)) { }
weak_ptr&
operator=(const weak_ptr& __r) noexcept = default;
template<typename _Yp>
_Assignable<const weak_ptr<_Yp>&>
operator=(const weak_ptr<_Yp>& __r) noexcept
{
this->__weak_ptr<_Tp>::operator=(__r);
return *this;
}
template<typename _Yp>
_Assignable<const shared_ptr<_Yp>&>
operator=(const shared_ptr<_Yp>& __r) noexcept
{
this->__weak_ptr<_Tp>::operator=(__r);
return *this;
}
weak_ptr&
operator=(weak_ptr&& __r) noexcept = default;
template<typename _Yp>
_Assignable<weak_ptr<_Yp>>
operator=(weak_ptr<_Yp>&& __r) noexcept
{
this->__weak_ptr<_Tp>::operator=(std::move(__r));
return *this;
}
shared_ptr<_Tp>
lock() const noexcept
{ return shared_ptr<_Tp>(*this, std::nothrow); }
};
#if __cpp_deduction_guides >= 201606
template<typename _Tp>
weak_ptr(shared_ptr<_Tp>) -> weak_ptr<_Tp>;
#endif
// 20.7.2.3.6 weak_ptr specialized algorithms.
template<typename _Tp>
inline void
swap(weak_ptr<_Tp>& __a, weak_ptr<_Tp>& __b) noexcept
{ __a.swap(__b); }
/// Primary template owner_less
template<typename _Tp = void>
struct owner_less;
/// Void specialization of owner_less
template<>
struct owner_less<void> : _Sp_owner_less<void, void>
{ };
/// Partial specialization of owner_less for shared_ptr.
template<typename _Tp>
struct owner_less<shared_ptr<_Tp>>
: public _Sp_owner_less<shared_ptr<_Tp>, weak_ptr<_Tp>>
{ };
/// Partial specialization of owner_less for weak_ptr.
template<typename _Tp>
struct owner_less<weak_ptr<_Tp>>
: public _Sp_owner_less<weak_ptr<_Tp>, shared_ptr<_Tp>>
{ };
/**
* @brief Base class allowing use of member function shared_from_this.
*/
template<typename _Tp>
class enable_shared_from_this
{
protected:
constexpr enable_shared_from_this() noexcept { }
enable_shared_from_this(const enable_shared_from_this&) noexcept { }
enable_shared_from_this&
operator=(const enable_shared_from_this&) noexcept
{ return *this; }
~enable_shared_from_this() { }
public:
shared_ptr<_Tp>
shared_from_this()
{ return shared_ptr<_Tp>(this->_M_weak_this); }
shared_ptr<const _Tp>
shared_from_this() const
{ return shared_ptr<const _Tp>(this->_M_weak_this); }
#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
#define __cpp_lib_enable_shared_from_this 201603
weak_ptr<_Tp>
weak_from_this() noexcept
{ return this->_M_weak_this; }
weak_ptr<const _Tp>
weak_from_this() const noexcept
{ return this->_M_weak_this; }
#endif
private:
template<typename _Tp1>
void
_M_weak_assign(_Tp1* __p, const __shared_count<>& __n) const noexcept
{ _M_weak_this._M_assign(__p, __n); }
// Found by ADL when this is an associated class.
friend const enable_shared_from_this*
__enable_shared_from_this_base(const __shared_count<>&,
const enable_shared_from_this* __p)
{ return __p; }
template<typename, _Lock_policy>
friend class __shared_ptr;
mutable weak_ptr<_Tp> _M_weak_this;
};
/**
* @brief Create an object that is owned by a shared_ptr.
* @param __a An allocator.
* @param __args Arguments for the @a _Tp object's constructor.
* @return A shared_ptr that owns the newly created object.
* @throw An exception thrown from @a _Alloc::allocate or from the
* constructor of @a _Tp.
*
* A copy of @a __a will be used to allocate memory for the shared_ptr
* and the new object.
*/
template<typename _Tp, typename _Alloc, typename... _Args>
inline shared_ptr<_Tp>
allocate_shared(const _Alloc& __a, _Args&&... __args)
{
static_assert(!is_array<_Tp>::value, "make_shared<T[]> not supported");
return shared_ptr<_Tp>(_Sp_alloc_shared_tag<_Alloc>{__a},
std::forward<_Args>(__args)...);
}
/**
* @brief Create an object that is owned by a shared_ptr.
* @param __args Arguments for the @a _Tp object's constructor.
* @return A shared_ptr that owns the newly created object.
* @throw std::bad_alloc, or an exception thrown from the
* constructor of @a _Tp.
*/
template<typename _Tp, typename... _Args>
inline shared_ptr<_Tp>
make_shared(_Args&&... __args)
{
typedef typename std::remove_cv<_Tp>::type _Tp_nc;
return std::allocate_shared<_Tp>(std::allocator<_Tp_nc>(),
std::forward<_Args>(__args)...);
}
/// std::hash specialization for shared_ptr.
template<typename _Tp>
struct hash<shared_ptr<_Tp>>
: public __hash_base<size_t, shared_ptr<_Tp>>
{
size_t
operator()(const shared_ptr<_Tp>& __s) const noexcept
{
return std::hash<typename shared_ptr<_Tp>::element_type*>()(__s.get());
}
};
// @} group pointer_abstractions
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif // _SHARED_PTR_H
c++/8/bits/parse_numbers.h 0000644 00000017410 15201526705 0011250 0 ustar 00 // Components for compile-time parsing of numbers -*- C++ -*-
// Copyright (C) 2013-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/parse_numbers.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{chrono}
*/
#ifndef _GLIBCXX_PARSE_NUMBERS_H
#define _GLIBCXX_PARSE_NUMBERS_H 1
#pragma GCC system_header
// From n3642.pdf except I added binary literals and digit separator '\''.
#if __cplusplus > 201103L
#include <limits>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
namespace __parse_int
{
template<unsigned _Base, char _Dig>
struct _Digit;
template<unsigned _Base>
struct _Digit<_Base, '0'> : integral_constant<unsigned, 0>
{
using __valid = true_type;
};
template<unsigned _Base>
struct _Digit<_Base, '1'> : integral_constant<unsigned, 1>
{
using __valid = true_type;
};
template<unsigned _Base, unsigned _Val>
struct _Digit_impl : integral_constant<unsigned, _Val>
{
static_assert(_Base > _Val, "invalid digit");
using __valid = true_type;
};
template<unsigned _Base>
struct _Digit<_Base, '2'> : _Digit_impl<_Base, 2>
{ };
template<unsigned _Base>
struct _Digit<_Base, '3'> : _Digit_impl<_Base, 3>
{ };
template<unsigned _Base>
struct _Digit<_Base, '4'> : _Digit_impl<_Base, 4>
{ };
template<unsigned _Base>
struct _Digit<_Base, '5'> : _Digit_impl<_Base, 5>
{ };
template<unsigned _Base>
struct _Digit<_Base, '6'> : _Digit_impl<_Base, 6>
{ };
template<unsigned _Base>
struct _Digit<_Base, '7'> : _Digit_impl<_Base, 7>
{ };
template<unsigned _Base>
struct _Digit<_Base, '8'> : _Digit_impl<_Base, 8>
{ };
template<unsigned _Base>
struct _Digit<_Base, '9'> : _Digit_impl<_Base, 9>
{ };
template<unsigned _Base>
struct _Digit<_Base, 'a'> : _Digit_impl<_Base, 0xa>
{ };
template<unsigned _Base>
struct _Digit<_Base, 'A'> : _Digit_impl<_Base, 0xa>
{ };
template<unsigned _Base>
struct _Digit<_Base, 'b'> : _Digit_impl<_Base, 0xb>
{ };
template<unsigned _Base>
struct _Digit<_Base, 'B'> : _Digit_impl<_Base, 0xb>
{ };
template<unsigned _Base>
struct _Digit<_Base, 'c'> : _Digit_impl<_Base, 0xc>
{ };
template<unsigned _Base>
struct _Digit<_Base, 'C'> : _Digit_impl<_Base, 0xc>
{ };
template<unsigned _Base>
struct _Digit<_Base, 'd'> : _Digit_impl<_Base, 0xd>
{ };
template<unsigned _Base>
struct _Digit<_Base, 'D'> : _Digit_impl<_Base, 0xd>
{ };
template<unsigned _Base>
struct _Digit<_Base, 'e'> : _Digit_impl<_Base, 0xe>
{ };
template<unsigned _Base>
struct _Digit<_Base, 'E'> : _Digit_impl<_Base, 0xe>
{ };
template<unsigned _Base>
struct _Digit<_Base, 'f'> : _Digit_impl<_Base, 0xf>
{ };
template<unsigned _Base>
struct _Digit<_Base, 'F'> : _Digit_impl<_Base, 0xf>
{ };
// Digit separator
template<unsigned _Base>
struct _Digit<_Base, '\''> : integral_constant<unsigned, 0>
{
using __valid = false_type;
};
//------------------------------------------------------------------------------
template<unsigned long long _Val>
using __ull_constant = integral_constant<unsigned long long, _Val>;
template<unsigned _Base, char _Dig, char... _Digs>
struct _Power_help
{
using __next = typename _Power_help<_Base, _Digs...>::type;
using __valid_digit = typename _Digit<_Base, _Dig>::__valid;
using type
= __ull_constant<__next::value * (__valid_digit{} ? _Base : 1ULL)>;
};
template<unsigned _Base, char _Dig>
struct _Power_help<_Base, _Dig>
{
using __valid_digit = typename _Digit<_Base, _Dig>::__valid;
using type = __ull_constant<__valid_digit::value>;
};
template<unsigned _Base, char... _Digs>
struct _Power : _Power_help<_Base, _Digs...>::type
{ };
template<unsigned _Base>
struct _Power<_Base> : __ull_constant<0>
{ };
//------------------------------------------------------------------------------
template<unsigned _Base, unsigned long long _Pow, char _Dig, char... _Digs>
struct _Number_help
{
using __digit = _Digit<_Base, _Dig>;
using __valid_digit = typename __digit::__valid;
using __next = _Number_help<_Base,
__valid_digit::value ? _Pow / _Base : _Pow,
_Digs...>;
using type = __ull_constant<_Pow * __digit::value + __next::type::value>;
static_assert((type::value / _Pow) == __digit::value,
"integer literal does not fit in unsigned long long");
};
// Skip past digit separators:
template<unsigned _Base, unsigned long long _Pow, char _Dig, char..._Digs>
struct _Number_help<_Base, _Pow, '\'', _Dig, _Digs...>
: _Number_help<_Base, _Pow, _Dig, _Digs...>
{ };
// Terminating case for recursion:
template<unsigned _Base, char _Dig>
struct _Number_help<_Base, 1ULL, _Dig>
{
using type = __ull_constant<_Digit<_Base, _Dig>::value>;
};
template<unsigned _Base, char... _Digs>
struct _Number
: _Number_help<_Base, _Power<_Base, _Digs...>::value, _Digs...>::type
{ };
template<unsigned _Base>
struct _Number<_Base>
: __ull_constant<0>
{ };
//------------------------------------------------------------------------------
template<char... _Digs>
struct _Parse_int;
template<char... _Digs>
struct _Parse_int<'0', 'b', _Digs...>
: _Number<2U, _Digs...>::type
{ };
template<char... _Digs>
struct _Parse_int<'0', 'B', _Digs...>
: _Number<2U, _Digs...>::type
{ };
template<char... _Digs>
struct _Parse_int<'0', 'x', _Digs...>
: _Number<16U, _Digs...>::type
{ };
template<char... _Digs>
struct _Parse_int<'0', 'X', _Digs...>
: _Number<16U, _Digs...>::type
{ };
template<char... _Digs>
struct _Parse_int<'0', _Digs...>
: _Number<8U, _Digs...>::type
{ };
template<char... _Digs>
struct _Parse_int
: _Number<10U, _Digs...>::type
{ };
} // namespace __parse_int
namespace __select_int
{
template<unsigned long long _Val, typename... _Ints>
struct _Select_int_base;
template<unsigned long long _Val, typename _IntType, typename... _Ints>
struct _Select_int_base<_Val, _IntType, _Ints...>
: conditional_t<(_Val <= std::numeric_limits<_IntType>::max()),
integral_constant<_IntType, _Val>,
_Select_int_base<_Val, _Ints...>>
{ };
template<unsigned long long _Val>
struct _Select_int_base<_Val>
{ };
template<char... _Digs>
using _Select_int = typename _Select_int_base<
__parse_int::_Parse_int<_Digs...>::value,
unsigned char,
unsigned short,
unsigned int,
unsigned long,
unsigned long long
>::type;
} // namespace __select_int
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // __cplusplus > 201103L
#endif // _GLIBCXX_PARSE_NUMBERS_H
c++/8/bits/unordered_map.h 0000644 00000223115 15201526705 0011230 0 ustar 00 // unordered_map implementation -*- C++ -*-
// Copyright (C) 2010-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/unordered_map.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{unordered_map}
*/
#ifndef _UNORDERED_MAP_H
#define _UNORDERED_MAP_H
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
/// Base types for unordered_map.
template<bool _Cache>
using __umap_traits = __detail::_Hashtable_traits<_Cache, false, true>;
template<typename _Key,
typename _Tp,
typename _Hash = hash<_Key>,
typename _Pred = std::equal_to<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >,
typename _Tr = __umap_traits<__cache_default<_Key, _Hash>::value>>
using __umap_hashtable = _Hashtable<_Key, std::pair<const _Key, _Tp>,
_Alloc, __detail::_Select1st,
_Pred, _Hash,
__detail::_Mod_range_hashing,
__detail::_Default_ranged_hash,
__detail::_Prime_rehash_policy, _Tr>;
/// Base types for unordered_multimap.
template<bool _Cache>
using __ummap_traits = __detail::_Hashtable_traits<_Cache, false, false>;
template<typename _Key,
typename _Tp,
typename _Hash = hash<_Key>,
typename _Pred = std::equal_to<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >,
typename _Tr = __ummap_traits<__cache_default<_Key, _Hash>::value>>
using __ummap_hashtable = _Hashtable<_Key, std::pair<const _Key, _Tp>,
_Alloc, __detail::_Select1st,
_Pred, _Hash,
__detail::_Mod_range_hashing,
__detail::_Default_ranged_hash,
__detail::_Prime_rehash_policy, _Tr>;
template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
class unordered_multimap;
/**
* @brief A standard container composed of unique keys (containing
* at most one of each key value) that associates values of another type
* with the keys.
*
* @ingroup unordered_associative_containers
*
* @tparam _Key Type of key objects.
* @tparam _Tp Type of mapped objects.
* @tparam _Hash Hashing function object type, defaults to hash<_Value>.
* @tparam _Pred Predicate function object type, defaults
* to equal_to<_Value>.
* @tparam _Alloc Allocator type, defaults to
* std::allocator<std::pair<const _Key, _Tp>>.
*
* Meets the requirements of a <a href="tables.html#65">container</a>, and
* <a href="tables.html#xx">unordered associative container</a>
*
* The resulting value type of the container is std::pair<const _Key, _Tp>.
*
* Base is _Hashtable, dispatched at compile time via template
* alias __umap_hashtable.
*/
template<typename _Key, typename _Tp,
typename _Hash = hash<_Key>,
typename _Pred = equal_to<_Key>,
typename _Alloc = allocator<std::pair<const _Key, _Tp>>>
class unordered_map
{
typedef __umap_hashtable<_Key, _Tp, _Hash, _Pred, _Alloc> _Hashtable;
_Hashtable _M_h;
public:
// typedefs:
//@{
/// Public typedefs.
typedef typename _Hashtable::key_type key_type;
typedef typename _Hashtable::value_type value_type;
typedef typename _Hashtable::mapped_type mapped_type;
typedef typename _Hashtable::hasher hasher;
typedef typename _Hashtable::key_equal key_equal;
typedef typename _Hashtable::allocator_type allocator_type;
//@}
//@{
/// Iterator-related typedefs.
typedef typename _Hashtable::pointer pointer;
typedef typename _Hashtable::const_pointer const_pointer;
typedef typename _Hashtable::reference reference;
typedef typename _Hashtable::const_reference const_reference;
typedef typename _Hashtable::iterator iterator;
typedef typename _Hashtable::const_iterator const_iterator;
typedef typename _Hashtable::local_iterator local_iterator;
typedef typename _Hashtable::const_local_iterator const_local_iterator;
typedef typename _Hashtable::size_type size_type;
typedef typename _Hashtable::difference_type difference_type;
//@}
#if __cplusplus > 201402L
using node_type = typename _Hashtable::node_type;
using insert_return_type = typename _Hashtable::insert_return_type;
#endif
//construct/destroy/copy
/// Default constructor.
unordered_map() = default;
/**
* @brief Default constructor creates no elements.
* @param __n Minimal initial number of buckets.
* @param __hf A hash functor.
* @param __eql A key equality functor.
* @param __a An allocator object.
*/
explicit
unordered_map(size_type __n,
const hasher& __hf = hasher(),
const key_equal& __eql = key_equal(),
const allocator_type& __a = allocator_type())
: _M_h(__n, __hf, __eql, __a)
{ }
/**
* @brief Builds an %unordered_map from a range.
* @param __first An input iterator.
* @param __last An input iterator.
* @param __n Minimal initial number of buckets.
* @param __hf A hash functor.
* @param __eql A key equality functor.
* @param __a An allocator object.
*
* Create an %unordered_map consisting of copies of the elements from
* [__first,__last). This is linear in N (where N is
* distance(__first,__last)).
*/
template<typename _InputIterator>
unordered_map(_InputIterator __first, _InputIterator __last,
size_type __n = 0,
const hasher& __hf = hasher(),
const key_equal& __eql = key_equal(),
const allocator_type& __a = allocator_type())
: _M_h(__first, __last, __n, __hf, __eql, __a)
{ }
/// Copy constructor.
unordered_map(const unordered_map&) = default;
/// Move constructor.
unordered_map(unordered_map&&) = default;
/**
* @brief Creates an %unordered_map with no elements.
* @param __a An allocator object.
*/
explicit
unordered_map(const allocator_type& __a)
: _M_h(__a)
{ }
/*
* @brief Copy constructor with allocator argument.
* @param __uset Input %unordered_map to copy.
* @param __a An allocator object.
*/
unordered_map(const unordered_map& __umap,
const allocator_type& __a)
: _M_h(__umap._M_h, __a)
{ }
/*
* @brief Move constructor with allocator argument.
* @param __uset Input %unordered_map to move.
* @param __a An allocator object.
*/
unordered_map(unordered_map&& __umap,
const allocator_type& __a)
: _M_h(std::move(__umap._M_h), __a)
{ }
/**
* @brief Builds an %unordered_map from an initializer_list.
* @param __l An initializer_list.
* @param __n Minimal initial number of buckets.
* @param __hf A hash functor.
* @param __eql A key equality functor.
* @param __a An allocator object.
*
* Create an %unordered_map consisting of copies of the elements in the
* list. This is linear in N (where N is @a __l.size()).
*/
unordered_map(initializer_list<value_type> __l,
size_type __n = 0,
const hasher& __hf = hasher(),
const key_equal& __eql = key_equal(),
const allocator_type& __a = allocator_type())
: _M_h(__l, __n, __hf, __eql, __a)
{ }
unordered_map(size_type __n, const allocator_type& __a)
: unordered_map(__n, hasher(), key_equal(), __a)
{ }
unordered_map(size_type __n, const hasher& __hf,
const allocator_type& __a)
: unordered_map(__n, __hf, key_equal(), __a)
{ }
template<typename _InputIterator>
unordered_map(_InputIterator __first, _InputIterator __last,
size_type __n,
const allocator_type& __a)
: unordered_map(__first, __last, __n, hasher(), key_equal(), __a)
{ }
template<typename _InputIterator>
unordered_map(_InputIterator __first, _InputIterator __last,
size_type __n, const hasher& __hf,
const allocator_type& __a)
: unordered_map(__first, __last, __n, __hf, key_equal(), __a)
{ }
unordered_map(initializer_list<value_type> __l,
size_type __n,
const allocator_type& __a)
: unordered_map(__l, __n, hasher(), key_equal(), __a)
{ }
unordered_map(initializer_list<value_type> __l,
size_type __n, const hasher& __hf,
const allocator_type& __a)
: unordered_map(__l, __n, __hf, key_equal(), __a)
{ }
/// Copy assignment operator.
unordered_map&
operator=(const unordered_map&) = default;
/// Move assignment operator.
unordered_map&
operator=(unordered_map&&) = default;
/**
* @brief %Unordered_map list assignment operator.
* @param __l An initializer_list.
*
* This function fills an %unordered_map with copies of the elements in
* the initializer list @a __l.
*
* Note that the assignment completely changes the %unordered_map and
* that the resulting %unordered_map's size is the same as the number
* of elements assigned.
*/
unordered_map&
operator=(initializer_list<value_type> __l)
{
_M_h = __l;
return *this;
}
/// Returns the allocator object used by the %unordered_map.
allocator_type
get_allocator() const noexcept
{ return _M_h.get_allocator(); }
// size and capacity:
/// Returns true if the %unordered_map is empty.
bool
empty() const noexcept
{ return _M_h.empty(); }
/// Returns the size of the %unordered_map.
size_type
size() const noexcept
{ return _M_h.size(); }
/// Returns the maximum size of the %unordered_map.
size_type
max_size() const noexcept
{ return _M_h.max_size(); }
// iterators.
/**
* Returns a read/write iterator that points to the first element in the
* %unordered_map.
*/
iterator
begin() noexcept
{ return _M_h.begin(); }
//@{
/**
* Returns a read-only (constant) iterator that points to the first
* element in the %unordered_map.
*/
const_iterator
begin() const noexcept
{ return _M_h.begin(); }
const_iterator
cbegin() const noexcept
{ return _M_h.begin(); }
//@}
/**
* Returns a read/write iterator that points one past the last element in
* the %unordered_map.
*/
iterator
end() noexcept
{ return _M_h.end(); }
//@{
/**
* Returns a read-only (constant) iterator that points one past the last
* element in the %unordered_map.
*/
const_iterator
end() const noexcept
{ return _M_h.end(); }
const_iterator
cend() const noexcept
{ return _M_h.end(); }
//@}
// modifiers.
/**
* @brief Attempts to build and insert a std::pair into the
* %unordered_map.
*
* @param __args Arguments used to generate a new pair instance (see
* std::piecewise_contruct for passing arguments to each
* part of the pair constructor).
*
* @return A pair, of which the first element is an iterator that points
* to the possibly inserted pair, and the second is a bool that
* is true if the pair was actually inserted.
*
* This function attempts to build and insert a (key, value) %pair into
* the %unordered_map.
* An %unordered_map relies on unique keys and thus a %pair is only
* inserted if its first element (the key) is not already present in the
* %unordered_map.
*
* Insertion requires amortized constant time.
*/
template<typename... _Args>
std::pair<iterator, bool>
emplace(_Args&&... __args)
{ return _M_h.emplace(std::forward<_Args>(__args)...); }
/**
* @brief Attempts to build and insert a std::pair into the
* %unordered_map.
*
* @param __pos An iterator that serves as a hint as to where the pair
* should be inserted.
* @param __args Arguments used to generate a new pair instance (see
* std::piecewise_contruct for passing arguments to each
* part of the pair constructor).
* @return An iterator that points to the element with key of the
* std::pair built from @a __args (may or may not be that
* std::pair).
*
* This function is not concerned about whether the insertion took place,
* and thus does not return a boolean like the single-argument emplace()
* does.
* Note that the first parameter is only a hint and can potentially
* improve the performance of the insertion process. A bad hint would
* cause no gains in efficiency.
*
* See
* https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints
* for more on @a hinting.
*
* Insertion requires amortized constant time.
*/
template<typename... _Args>
iterator
emplace_hint(const_iterator __pos, _Args&&... __args)
{ return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); }
#if __cplusplus > 201402L
/// Extract a node.
node_type
extract(const_iterator __pos)
{
__glibcxx_assert(__pos != end());
return _M_h.extract(__pos);
}
/// Extract a node.
node_type
extract(const key_type& __key)
{ return _M_h.extract(__key); }
/// Re-insert an extracted node.
insert_return_type
insert(node_type&& __nh)
{ return _M_h._M_reinsert_node(std::move(__nh)); }
/// Re-insert an extracted node.
iterator
insert(const_iterator, node_type&& __nh)
{ return _M_h._M_reinsert_node(std::move(__nh)).position; }
#define __cpp_lib_unordered_map_try_emplace 201411
/**
* @brief Attempts to build and insert a std::pair into the
* %unordered_map.
*
* @param __k Key to use for finding a possibly existing pair in
* the unordered_map.
* @param __args Arguments used to generate the .second for a
* new pair instance.
*
* @return A pair, of which the first element is an iterator that points
* to the possibly inserted pair, and the second is a bool that
* is true if the pair was actually inserted.
*
* This function attempts to build and insert a (key, value) %pair into
* the %unordered_map.
* An %unordered_map relies on unique keys and thus a %pair is only
* inserted if its first element (the key) is not already present in the
* %unordered_map.
* If a %pair is not inserted, this function has no effect.
*
* Insertion requires amortized constant time.
*/
template <typename... _Args>
pair<iterator, bool>
try_emplace(const key_type& __k, _Args&&... __args)
{
iterator __i = find(__k);
if (__i == end())
{
__i = emplace(std::piecewise_construct,
std::forward_as_tuple(__k),
std::forward_as_tuple(
std::forward<_Args>(__args)...))
.first;
return {__i, true};
}
return {__i, false};
}
// move-capable overload
template <typename... _Args>
pair<iterator, bool>
try_emplace(key_type&& __k, _Args&&... __args)
{
iterator __i = find(__k);
if (__i == end())
{
__i = emplace(std::piecewise_construct,
std::forward_as_tuple(std::move(__k)),
std::forward_as_tuple(
std::forward<_Args>(__args)...))
.first;
return {__i, true};
}
return {__i, false};
}
/**
* @brief Attempts to build and insert a std::pair into the
* %unordered_map.
*
* @param __hint An iterator that serves as a hint as to where the pair
* should be inserted.
* @param __k Key to use for finding a possibly existing pair in
* the unordered_map.
* @param __args Arguments used to generate the .second for a
* new pair instance.
* @return An iterator that points to the element with key of the
* std::pair built from @a __args (may or may not be that
* std::pair).
*
* This function is not concerned about whether the insertion took place,
* and thus does not return a boolean like the single-argument emplace()
* does. However, if insertion did not take place,
* this function has no effect.
* Note that the first parameter is only a hint and can potentially
* improve the performance of the insertion process. A bad hint would
* cause no gains in efficiency.
*
* See
* https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints
* for more on @a hinting.
*
* Insertion requires amortized constant time.
*/
template <typename... _Args>
iterator
try_emplace(const_iterator __hint, const key_type& __k,
_Args&&... __args)
{
iterator __i = find(__k);
if (__i == end())
__i = emplace_hint(__hint, std::piecewise_construct,
std::forward_as_tuple(__k),
std::forward_as_tuple(
std::forward<_Args>(__args)...));
return __i;
}
// move-capable overload
template <typename... _Args>
iterator
try_emplace(const_iterator __hint, key_type&& __k, _Args&&... __args)
{
iterator __i = find(__k);
if (__i == end())
__i = emplace_hint(__hint, std::piecewise_construct,
std::forward_as_tuple(std::move(__k)),
std::forward_as_tuple(
std::forward<_Args>(__args)...));
return __i;
}
#endif // C++17
//@{
/**
* @brief Attempts to insert a std::pair into the %unordered_map.
* @param __x Pair to be inserted (see std::make_pair for easy
* creation of pairs).
*
* @return A pair, of which the first element is an iterator that
* points to the possibly inserted pair, and the second is
* a bool that is true if the pair was actually inserted.
*
* This function attempts to insert a (key, value) %pair into the
* %unordered_map. An %unordered_map relies on unique keys and thus a
* %pair is only inserted if its first element (the key) is not already
* present in the %unordered_map.
*
* Insertion requires amortized constant time.
*/
std::pair<iterator, bool>
insert(const value_type& __x)
{ return _M_h.insert(__x); }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2354. Unnecessary copying when inserting into maps with braced-init
std::pair<iterator, bool>
insert(value_type&& __x)
{ return _M_h.insert(std::move(__x)); }
template<typename _Pair>
__enable_if_t<is_constructible<value_type, _Pair&&>::value,
pair<iterator, bool>>
insert(_Pair&& __x)
{ return _M_h.emplace(std::forward<_Pair>(__x)); }
//@}
//@{
/**
* @brief Attempts to insert a std::pair into the %unordered_map.
* @param __hint An iterator that serves as a hint as to where the
* pair should be inserted.
* @param __x Pair to be inserted (see std::make_pair for easy creation
* of pairs).
* @return An iterator that points to the element with key of
* @a __x (may or may not be the %pair passed in).
*
* This function is not concerned about whether the insertion took place,
* and thus does not return a boolean like the single-argument insert()
* does. Note that the first parameter is only a hint and can
* potentially improve the performance of the insertion process. A bad
* hint would cause no gains in efficiency.
*
* See
* https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints
* for more on @a hinting.
*
* Insertion requires amortized constant time.
*/
iterator
insert(const_iterator __hint, const value_type& __x)
{ return _M_h.insert(__hint, __x); }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2354. Unnecessary copying when inserting into maps with braced-init
iterator
insert(const_iterator __hint, value_type&& __x)
{ return _M_h.insert(__hint, std::move(__x)); }
template<typename _Pair>
__enable_if_t<is_constructible<value_type, _Pair&&>::value, iterator>
insert(const_iterator __hint, _Pair&& __x)
{ return _M_h.emplace_hint(__hint, std::forward<_Pair>(__x)); }
//@}
/**
* @brief A template function that attempts to insert a range of
* elements.
* @param __first Iterator pointing to the start of the range to be
* inserted.
* @param __last Iterator pointing to the end of the range.
*
* Complexity similar to that of the range constructor.
*/
template<typename _InputIterator>
void
insert(_InputIterator __first, _InputIterator __last)
{ _M_h.insert(__first, __last); }
/**
* @brief Attempts to insert a list of elements into the %unordered_map.
* @param __l A std::initializer_list<value_type> of elements
* to be inserted.
*
* Complexity similar to that of the range constructor.
*/
void
insert(initializer_list<value_type> __l)
{ _M_h.insert(__l); }
#if __cplusplus > 201402L
#define __cpp_lib_unordered_map_insertion 201411
/**
* @brief Attempts to insert a std::pair into the %unordered_map.
* @param __k Key to use for finding a possibly existing pair in
* the map.
* @param __obj Argument used to generate the .second for a pair
* instance.
*
* @return A pair, of which the first element is an iterator that
* points to the possibly inserted pair, and the second is
* a bool that is true if the pair was actually inserted.
*
* This function attempts to insert a (key, value) %pair into the
* %unordered_map. An %unordered_map relies on unique keys and thus a
* %pair is only inserted if its first element (the key) is not already
* present in the %unordered_map.
* If the %pair was already in the %unordered_map, the .second of
* the %pair is assigned from __obj.
*
* Insertion requires amortized constant time.
*/
template <typename _Obj>
pair<iterator, bool>
insert_or_assign(const key_type& __k, _Obj&& __obj)
{
iterator __i = find(__k);
if (__i == end())
{
__i = emplace(std::piecewise_construct,
std::forward_as_tuple(__k),
std::forward_as_tuple(std::forward<_Obj>(__obj)))
.first;
return {__i, true};
}
(*__i).second = std::forward<_Obj>(__obj);
return {__i, false};
}
// move-capable overload
template <typename _Obj>
pair<iterator, bool>
insert_or_assign(key_type&& __k, _Obj&& __obj)
{
iterator __i = find(__k);
if (__i == end())
{
__i = emplace(std::piecewise_construct,
std::forward_as_tuple(std::move(__k)),
std::forward_as_tuple(std::forward<_Obj>(__obj)))
.first;
return {__i, true};
}
(*__i).second = std::forward<_Obj>(__obj);
return {__i, false};
}
/**
* @brief Attempts to insert a std::pair into the %unordered_map.
* @param __hint An iterator that serves as a hint as to where the
* pair should be inserted.
* @param __k Key to use for finding a possibly existing pair in
* the unordered_map.
* @param __obj Argument used to generate the .second for a pair
* instance.
* @return An iterator that points to the element with key of
* @a __x (may or may not be the %pair passed in).
*
* This function is not concerned about whether the insertion took place,
* and thus does not return a boolean like the single-argument insert()
* does.
* If the %pair was already in the %unordered map, the .second of
* the %pair is assigned from __obj.
* Note that the first parameter is only a hint and can
* potentially improve the performance of the insertion process. A bad
* hint would cause no gains in efficiency.
*
* See
* https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints
* for more on @a hinting.
*
* Insertion requires amortized constant time.
*/
template <typename _Obj>
iterator
insert_or_assign(const_iterator __hint, const key_type& __k,
_Obj&& __obj)
{
iterator __i = find(__k);
if (__i == end())
{
return emplace_hint(__hint, std::piecewise_construct,
std::forward_as_tuple(__k),
std::forward_as_tuple(
std::forward<_Obj>(__obj)));
}
(*__i).second = std::forward<_Obj>(__obj);
return __i;
}
// move-capable overload
template <typename _Obj>
iterator
insert_or_assign(const_iterator __hint, key_type&& __k, _Obj&& __obj)
{
iterator __i = find(__k);
if (__i == end())
{
return emplace_hint(__hint, std::piecewise_construct,
std::forward_as_tuple(std::move(__k)),
std::forward_as_tuple(
std::forward<_Obj>(__obj)));
}
(*__i).second = std::forward<_Obj>(__obj);
return __i;
}
#endif
//@{
/**
* @brief Erases an element from an %unordered_map.
* @param __position An iterator pointing to the element to be erased.
* @return An iterator pointing to the element immediately following
* @a __position prior to the element being erased. If no such
* element exists, end() is returned.
*
* This function erases an element, pointed to by the given iterator,
* from an %unordered_map.
* Note that this function only erases the element, and that if the
* element is itself a pointer, the pointed-to memory is not touched in
* any way. Managing the pointer is the user's responsibility.
*/
iterator
erase(const_iterator __position)
{ return _M_h.erase(__position); }
// LWG 2059.
iterator
erase(iterator __position)
{ return _M_h.erase(__position); }
//@}
/**
* @brief Erases elements according to the provided key.
* @param __x Key of element to be erased.
* @return The number of elements erased.
*
* This function erases all the elements located by the given key from
* an %unordered_map. For an %unordered_map the result of this function
* can only be 0 (not present) or 1 (present).
* Note that this function only erases the element, and that if the
* element is itself a pointer, the pointed-to memory is not touched in
* any way. Managing the pointer is the user's responsibility.
*/
size_type
erase(const key_type& __x)
{ return _M_h.erase(__x); }
/**
* @brief Erases a [__first,__last) range of elements from an
* %unordered_map.
* @param __first Iterator pointing to the start of the range to be
* erased.
* @param __last Iterator pointing to the end of the range to
* be erased.
* @return The iterator @a __last.
*
* This function erases a sequence of elements from an %unordered_map.
* Note that this function only erases the elements, and that if
* the element is itself a pointer, the pointed-to memory is not touched
* in any way. Managing the pointer is the user's responsibility.
*/
iterator
erase(const_iterator __first, const_iterator __last)
{ return _M_h.erase(__first, __last); }
/**
* Erases all elements in an %unordered_map.
* Note that this function only erases the elements, and that if the
* elements themselves are pointers, the pointed-to memory is not touched
* in any way. Managing the pointer is the user's responsibility.
*/
void
clear() noexcept
{ _M_h.clear(); }
/**
* @brief Swaps data with another %unordered_map.
* @param __x An %unordered_map of the same element and allocator
* types.
*
* This exchanges the elements between two %unordered_map in constant
* time.
* Note that the global std::swap() function is specialized such that
* std::swap(m1,m2) will feed to this function.
*/
void
swap(unordered_map& __x)
noexcept( noexcept(_M_h.swap(__x._M_h)) )
{ _M_h.swap(__x._M_h); }
#if __cplusplus > 201402L
template<typename, typename, typename>
friend class std::_Hash_merge_helper;
template<typename _H2, typename _P2>
void
merge(unordered_map<_Key, _Tp, _H2, _P2, _Alloc>& __source)
{
using _Merge_helper = _Hash_merge_helper<unordered_map, _H2, _P2>;
_M_h._M_merge_unique(_Merge_helper::_S_get_table(__source));
}
template<typename _H2, typename _P2>
void
merge(unordered_map<_Key, _Tp, _H2, _P2, _Alloc>&& __source)
{ merge(__source); }
template<typename _H2, typename _P2>
void
merge(unordered_multimap<_Key, _Tp, _H2, _P2, _Alloc>& __source)
{
using _Merge_helper = _Hash_merge_helper<unordered_map, _H2, _P2>;
_M_h._M_merge_unique(_Merge_helper::_S_get_table(__source));
}
template<typename _H2, typename _P2>
void
merge(unordered_multimap<_Key, _Tp, _H2, _P2, _Alloc>&& __source)
{ merge(__source); }
#endif // C++17
// observers.
/// Returns the hash functor object with which the %unordered_map was
/// constructed.
hasher
hash_function() const
{ return _M_h.hash_function(); }
/// Returns the key comparison object with which the %unordered_map was
/// constructed.
key_equal
key_eq() const
{ return _M_h.key_eq(); }
// lookup.
//@{
/**
* @brief Tries to locate an element in an %unordered_map.
* @param __x Key to be located.
* @return Iterator pointing to sought-after element, or end() if not
* found.
*
* This function takes a key and tries to locate the element with which
* the key matches. If successful the function returns an iterator
* pointing to the sought after element. If unsuccessful it returns the
* past-the-end ( @c end() ) iterator.
*/
iterator
find(const key_type& __x)
{ return _M_h.find(__x); }
const_iterator
find(const key_type& __x) const
{ return _M_h.find(__x); }
//@}
/**
* @brief Finds the number of elements.
* @param __x Key to count.
* @return Number of elements with specified key.
*
* This function only makes sense for %unordered_multimap; for
* %unordered_map the result will either be 0 (not present) or 1
* (present).
*/
size_type
count(const key_type& __x) const
{ return _M_h.count(__x); }
//@{
/**
* @brief Finds a subsequence matching given key.
* @param __x Key to be located.
* @return Pair of iterators that possibly points to the subsequence
* matching given key.
*
* This function probably only makes sense for %unordered_multimap.
*/
std::pair<iterator, iterator>
equal_range(const key_type& __x)
{ return _M_h.equal_range(__x); }
std::pair<const_iterator, const_iterator>
equal_range(const key_type& __x) const
{ return _M_h.equal_range(__x); }
//@}
//@{
/**
* @brief Subscript ( @c [] ) access to %unordered_map data.
* @param __k The key for which data should be retrieved.
* @return A reference to the data of the (key,data) %pair.
*
* Allows for easy lookup with the subscript ( @c [] )operator. Returns
* data associated with the key specified in subscript. If the key does
* not exist, a pair with that key is created using default values, which
* is then returned.
*
* Lookup requires constant time.
*/
mapped_type&
operator[](const key_type& __k)
{ return _M_h[__k]; }
mapped_type&
operator[](key_type&& __k)
{ return _M_h[std::move(__k)]; }
//@}
//@{
/**
* @brief Access to %unordered_map data.
* @param __k The key for which data should be retrieved.
* @return A reference to the data whose key is equal to @a __k, if
* such a data is present in the %unordered_map.
* @throw std::out_of_range If no such data is present.
*/
mapped_type&
at(const key_type& __k)
{ return _M_h.at(__k); }
const mapped_type&
at(const key_type& __k) const
{ return _M_h.at(__k); }
//@}
// bucket interface.
/// Returns the number of buckets of the %unordered_map.
size_type
bucket_count() const noexcept
{ return _M_h.bucket_count(); }
/// Returns the maximum number of buckets of the %unordered_map.
size_type
max_bucket_count() const noexcept
{ return _M_h.max_bucket_count(); }
/*
* @brief Returns the number of elements in a given bucket.
* @param __n A bucket index.
* @return The number of elements in the bucket.
*/
size_type
bucket_size(size_type __n) const
{ return _M_h.bucket_size(__n); }
/*
* @brief Returns the bucket index of a given element.
* @param __key A key instance.
* @return The key bucket index.
*/
size_type
bucket(const key_type& __key) const
{ return _M_h.bucket(__key); }
/**
* @brief Returns a read/write iterator pointing to the first bucket
* element.
* @param __n The bucket index.
* @return A read/write local iterator.
*/
local_iterator
begin(size_type __n)
{ return _M_h.begin(__n); }
//@{
/**
* @brief Returns a read-only (constant) iterator pointing to the first
* bucket element.
* @param __n The bucket index.
* @return A read-only local iterator.
*/
const_local_iterator
begin(size_type __n) const
{ return _M_h.begin(__n); }
const_local_iterator
cbegin(size_type __n) const
{ return _M_h.cbegin(__n); }
//@}
/**
* @brief Returns a read/write iterator pointing to one past the last
* bucket elements.
* @param __n The bucket index.
* @return A read/write local iterator.
*/
local_iterator
end(size_type __n)
{ return _M_h.end(__n); }
//@{
/**
* @brief Returns a read-only (constant) iterator pointing to one past
* the last bucket elements.
* @param __n The bucket index.
* @return A read-only local iterator.
*/
const_local_iterator
end(size_type __n) const
{ return _M_h.end(__n); }
const_local_iterator
cend(size_type __n) const
{ return _M_h.cend(__n); }
//@}
// hash policy.
/// Returns the average number of elements per bucket.
float
load_factor() const noexcept
{ return _M_h.load_factor(); }
/// Returns a positive number that the %unordered_map tries to keep the
/// load factor less than or equal to.
float
max_load_factor() const noexcept
{ return _M_h.max_load_factor(); }
/**
* @brief Change the %unordered_map maximum load factor.
* @param __z The new maximum load factor.
*/
void
max_load_factor(float __z)
{ _M_h.max_load_factor(__z); }
/**
* @brief May rehash the %unordered_map.
* @param __n The new number of buckets.
*
* Rehash will occur only if the new number of buckets respect the
* %unordered_map maximum load factor.
*/
void
rehash(size_type __n)
{ _M_h.rehash(__n); }
/**
* @brief Prepare the %unordered_map for a specified number of
* elements.
* @param __n Number of elements required.
*
* Same as rehash(ceil(n / max_load_factor())).
*/
void
reserve(size_type __n)
{ _M_h.reserve(__n); }
template<typename _Key1, typename _Tp1, typename _Hash1, typename _Pred1,
typename _Alloc1>
friend bool
operator==(const unordered_map<_Key1, _Tp1, _Hash1, _Pred1, _Alloc1>&,
const unordered_map<_Key1, _Tp1, _Hash1, _Pred1, _Alloc1>&);
};
#if __cpp_deduction_guides >= 201606
template<typename _InputIterator,
typename _Hash = hash<__iter_key_t<_InputIterator>>,
typename _Pred = equal_to<__iter_key_t<_InputIterator>>,
typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>,
typename = _RequireInputIter<_InputIterator>,
typename = _RequireAllocator<_Allocator>>
unordered_map(_InputIterator, _InputIterator,
typename unordered_map<int, int>::size_type = {},
_Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
-> unordered_map<__iter_key_t<_InputIterator>,
__iter_val_t<_InputIterator>,
_Hash, _Pred, _Allocator>;
template<typename _Key, typename _Tp, typename _Hash = hash<_Key>,
typename _Pred = equal_to<_Key>,
typename _Allocator = allocator<pair<const _Key, _Tp>>,
typename = _RequireAllocator<_Allocator>>
unordered_map(initializer_list<pair<_Key, _Tp>>,
typename unordered_map<int, int>::size_type = {},
_Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
-> unordered_map<_Key, _Tp, _Hash, _Pred, _Allocator>;
template<typename _InputIterator, typename _Allocator,
typename = _RequireInputIter<_InputIterator>,
typename = _RequireAllocator<_Allocator>>
unordered_map(_InputIterator, _InputIterator,
typename unordered_map<int, int>::size_type, _Allocator)
-> unordered_map<__iter_key_t<_InputIterator>,
__iter_val_t<_InputIterator>,
hash<__iter_key_t<_InputIterator>>,
equal_to<__iter_key_t<_InputIterator>>,
_Allocator>;
template<typename _InputIterator, typename _Allocator,
typename = _RequireInputIter<_InputIterator>,
typename = _RequireAllocator<_Allocator>>
unordered_map(_InputIterator, _InputIterator, _Allocator)
-> unordered_map<__iter_key_t<_InputIterator>,
__iter_val_t<_InputIterator>,
hash<__iter_key_t<_InputIterator>>,
equal_to<__iter_key_t<_InputIterator>>,
_Allocator>;
template<typename _InputIterator, typename _Hash, typename _Allocator,
typename = _RequireInputIter<_InputIterator>,
typename = _RequireAllocator<_Allocator>>
unordered_map(_InputIterator, _InputIterator,
typename unordered_map<int, int>::size_type,
_Hash, _Allocator)
-> unordered_map<__iter_key_t<_InputIterator>,
__iter_val_t<_InputIterator>, _Hash,
equal_to<__iter_key_t<_InputIterator>>, _Allocator>;
template<typename _Key, typename _Tp, typename _Allocator,
typename = _RequireAllocator<_Allocator>>
unordered_map(initializer_list<pair<_Key, _Tp>>,
typename unordered_map<int, int>::size_type,
_Allocator)
-> unordered_map<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>;
template<typename _Key, typename _Tp, typename _Allocator,
typename = _RequireAllocator<_Allocator>>
unordered_map(initializer_list<pair<_Key, _Tp>>, _Allocator)
-> unordered_map<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>;
template<typename _Key, typename _Tp, typename _Hash, typename _Allocator,
typename = _RequireAllocator<_Allocator>>
unordered_map(initializer_list<pair<_Key, _Tp>>,
typename unordered_map<int, int>::size_type,
_Hash, _Allocator)
-> unordered_map<_Key, _Tp, _Hash, equal_to<_Key>, _Allocator>;
#endif
/**
* @brief A standard container composed of equivalent keys
* (possibly containing multiple of each key value) that associates
* values of another type with the keys.
*
* @ingroup unordered_associative_containers
*
* @tparam _Key Type of key objects.
* @tparam _Tp Type of mapped objects.
* @tparam _Hash Hashing function object type, defaults to hash<_Value>.
* @tparam _Pred Predicate function object type, defaults
* to equal_to<_Value>.
* @tparam _Alloc Allocator type, defaults to
* std::allocator<std::pair<const _Key, _Tp>>.
*
* Meets the requirements of a <a href="tables.html#65">container</a>, and
* <a href="tables.html#xx">unordered associative container</a>
*
* The resulting value type of the container is std::pair<const _Key, _Tp>.
*
* Base is _Hashtable, dispatched at compile time via template
* alias __ummap_hashtable.
*/
template<typename _Key, typename _Tp,
typename _Hash = hash<_Key>,
typename _Pred = equal_to<_Key>,
typename _Alloc = allocator<std::pair<const _Key, _Tp>>>
class unordered_multimap
{
typedef __ummap_hashtable<_Key, _Tp, _Hash, _Pred, _Alloc> _Hashtable;
_Hashtable _M_h;
public:
// typedefs:
//@{
/// Public typedefs.
typedef typename _Hashtable::key_type key_type;
typedef typename _Hashtable::value_type value_type;
typedef typename _Hashtable::mapped_type mapped_type;
typedef typename _Hashtable::hasher hasher;
typedef typename _Hashtable::key_equal key_equal;
typedef typename _Hashtable::allocator_type allocator_type;
//@}
//@{
/// Iterator-related typedefs.
typedef typename _Hashtable::pointer pointer;
typedef typename _Hashtable::const_pointer const_pointer;
typedef typename _Hashtable::reference reference;
typedef typename _Hashtable::const_reference const_reference;
typedef typename _Hashtable::iterator iterator;
typedef typename _Hashtable::const_iterator const_iterator;
typedef typename _Hashtable::local_iterator local_iterator;
typedef typename _Hashtable::const_local_iterator const_local_iterator;
typedef typename _Hashtable::size_type size_type;
typedef typename _Hashtable::difference_type difference_type;
//@}
#if __cplusplus > 201402L
using node_type = typename _Hashtable::node_type;
#endif
//construct/destroy/copy
/// Default constructor.
unordered_multimap() = default;
/**
* @brief Default constructor creates no elements.
* @param __n Mnimal initial number of buckets.
* @param __hf A hash functor.
* @param __eql A key equality functor.
* @param __a An allocator object.
*/
explicit
unordered_multimap(size_type __n,
const hasher& __hf = hasher(),
const key_equal& __eql = key_equal(),
const allocator_type& __a = allocator_type())
: _M_h(__n, __hf, __eql, __a)
{ }
/**
* @brief Builds an %unordered_multimap from a range.
* @param __first An input iterator.
* @param __last An input iterator.
* @param __n Minimal initial number of buckets.
* @param __hf A hash functor.
* @param __eql A key equality functor.
* @param __a An allocator object.
*
* Create an %unordered_multimap consisting of copies of the elements
* from [__first,__last). This is linear in N (where N is
* distance(__first,__last)).
*/
template<typename _InputIterator>
unordered_multimap(_InputIterator __first, _InputIterator __last,
size_type __n = 0,
const hasher& __hf = hasher(),
const key_equal& __eql = key_equal(),
const allocator_type& __a = allocator_type())
: _M_h(__first, __last, __n, __hf, __eql, __a)
{ }
/// Copy constructor.
unordered_multimap(const unordered_multimap&) = default;
/// Move constructor.
unordered_multimap(unordered_multimap&&) = default;
/**
* @brief Creates an %unordered_multimap with no elements.
* @param __a An allocator object.
*/
explicit
unordered_multimap(const allocator_type& __a)
: _M_h(__a)
{ }
/*
* @brief Copy constructor with allocator argument.
* @param __uset Input %unordered_multimap to copy.
* @param __a An allocator object.
*/
unordered_multimap(const unordered_multimap& __ummap,
const allocator_type& __a)
: _M_h(__ummap._M_h, __a)
{ }
/*
* @brief Move constructor with allocator argument.
* @param __uset Input %unordered_multimap to move.
* @param __a An allocator object.
*/
unordered_multimap(unordered_multimap&& __ummap,
const allocator_type& __a)
: _M_h(std::move(__ummap._M_h), __a)
{ }
/**
* @brief Builds an %unordered_multimap from an initializer_list.
* @param __l An initializer_list.
* @param __n Minimal initial number of buckets.
* @param __hf A hash functor.
* @param __eql A key equality functor.
* @param __a An allocator object.
*
* Create an %unordered_multimap consisting of copies of the elements in
* the list. This is linear in N (where N is @a __l.size()).
*/
unordered_multimap(initializer_list<value_type> __l,
size_type __n = 0,
const hasher& __hf = hasher(),
const key_equal& __eql = key_equal(),
const allocator_type& __a = allocator_type())
: _M_h(__l, __n, __hf, __eql, __a)
{ }
unordered_multimap(size_type __n, const allocator_type& __a)
: unordered_multimap(__n, hasher(), key_equal(), __a)
{ }
unordered_multimap(size_type __n, const hasher& __hf,
const allocator_type& __a)
: unordered_multimap(__n, __hf, key_equal(), __a)
{ }
template<typename _InputIterator>
unordered_multimap(_InputIterator __first, _InputIterator __last,
size_type __n,
const allocator_type& __a)
: unordered_multimap(__first, __last, __n, hasher(), key_equal(), __a)
{ }
template<typename _InputIterator>
unordered_multimap(_InputIterator __first, _InputIterator __last,
size_type __n, const hasher& __hf,
const allocator_type& __a)
: unordered_multimap(__first, __last, __n, __hf, key_equal(), __a)
{ }
unordered_multimap(initializer_list<value_type> __l,
size_type __n,
const allocator_type& __a)
: unordered_multimap(__l, __n, hasher(), key_equal(), __a)
{ }
unordered_multimap(initializer_list<value_type> __l,
size_type __n, const hasher& __hf,
const allocator_type& __a)
: unordered_multimap(__l, __n, __hf, key_equal(), __a)
{ }
/// Copy assignment operator.
unordered_multimap&
operator=(const unordered_multimap&) = default;
/// Move assignment operator.
unordered_multimap&
operator=(unordered_multimap&&) = default;
/**
* @brief %Unordered_multimap list assignment operator.
* @param __l An initializer_list.
*
* This function fills an %unordered_multimap with copies of the
* elements in the initializer list @a __l.
*
* Note that the assignment completely changes the %unordered_multimap
* and that the resulting %unordered_multimap's size is the same as the
* number of elements assigned.
*/
unordered_multimap&
operator=(initializer_list<value_type> __l)
{
_M_h = __l;
return *this;
}
/// Returns the allocator object used by the %unordered_multimap.
allocator_type
get_allocator() const noexcept
{ return _M_h.get_allocator(); }
// size and capacity:
/// Returns true if the %unordered_multimap is empty.
bool
empty() const noexcept
{ return _M_h.empty(); }
/// Returns the size of the %unordered_multimap.
size_type
size() const noexcept
{ return _M_h.size(); }
/// Returns the maximum size of the %unordered_multimap.
size_type
max_size() const noexcept
{ return _M_h.max_size(); }
// iterators.
/**
* Returns a read/write iterator that points to the first element in the
* %unordered_multimap.
*/
iterator
begin() noexcept
{ return _M_h.begin(); }
//@{
/**
* Returns a read-only (constant) iterator that points to the first
* element in the %unordered_multimap.
*/
const_iterator
begin() const noexcept
{ return _M_h.begin(); }
const_iterator
cbegin() const noexcept
{ return _M_h.begin(); }
//@}
/**
* Returns a read/write iterator that points one past the last element in
* the %unordered_multimap.
*/
iterator
end() noexcept
{ return _M_h.end(); }
//@{
/**
* Returns a read-only (constant) iterator that points one past the last
* element in the %unordered_multimap.
*/
const_iterator
end() const noexcept
{ return _M_h.end(); }
const_iterator
cend() const noexcept
{ return _M_h.end(); }
//@}
// modifiers.
/**
* @brief Attempts to build and insert a std::pair into the
* %unordered_multimap.
*
* @param __args Arguments used to generate a new pair instance (see
* std::piecewise_contruct for passing arguments to each
* part of the pair constructor).
*
* @return An iterator that points to the inserted pair.
*
* This function attempts to build and insert a (key, value) %pair into
* the %unordered_multimap.
*
* Insertion requires amortized constant time.
*/
template<typename... _Args>
iterator
emplace(_Args&&... __args)
{ return _M_h.emplace(std::forward<_Args>(__args)...); }
/**
* @brief Attempts to build and insert a std::pair into the
* %unordered_multimap.
*
* @param __pos An iterator that serves as a hint as to where the pair
* should be inserted.
* @param __args Arguments used to generate a new pair instance (see
* std::piecewise_contruct for passing arguments to each
* part of the pair constructor).
* @return An iterator that points to the element with key of the
* std::pair built from @a __args.
*
* Note that the first parameter is only a hint and can potentially
* improve the performance of the insertion process. A bad hint would
* cause no gains in efficiency.
*
* See
* https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints
* for more on @a hinting.
*
* Insertion requires amortized constant time.
*/
template<typename... _Args>
iterator
emplace_hint(const_iterator __pos, _Args&&... __args)
{ return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); }
//@{
/**
* @brief Inserts a std::pair into the %unordered_multimap.
* @param __x Pair to be inserted (see std::make_pair for easy
* creation of pairs).
*
* @return An iterator that points to the inserted pair.
*
* Insertion requires amortized constant time.
*/
iterator
insert(const value_type& __x)
{ return _M_h.insert(__x); }
iterator
insert(value_type&& __x)
{ return _M_h.insert(std::move(__x)); }
template<typename _Pair>
__enable_if_t<is_constructible<value_type, _Pair&&>::value, iterator>
insert(_Pair&& __x)
{ return _M_h.emplace(std::forward<_Pair>(__x)); }
//@}
//@{
/**
* @brief Inserts a std::pair into the %unordered_multimap.
* @param __hint An iterator that serves as a hint as to where the
* pair should be inserted.
* @param __x Pair to be inserted (see std::make_pair for easy creation
* of pairs).
* @return An iterator that points to the element with key of
* @a __x (may or may not be the %pair passed in).
*
* Note that the first parameter is only a hint and can potentially
* improve the performance of the insertion process. A bad hint would
* cause no gains in efficiency.
*
* See
* https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints
* for more on @a hinting.
*
* Insertion requires amortized constant time.
*/
iterator
insert(const_iterator __hint, const value_type& __x)
{ return _M_h.insert(__hint, __x); }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2354. Unnecessary copying when inserting into maps with braced-init
iterator
insert(const_iterator __hint, value_type&& __x)
{ return _M_h.insert(__hint, std::move(__x)); }
template<typename _Pair>
__enable_if_t<is_constructible<value_type, _Pair&&>::value, iterator>
insert(const_iterator __hint, _Pair&& __x)
{ return _M_h.emplace_hint(__hint, std::forward<_Pair>(__x)); }
//@}
/**
* @brief A template function that attempts to insert a range of
* elements.
* @param __first Iterator pointing to the start of the range to be
* inserted.
* @param __last Iterator pointing to the end of the range.
*
* Complexity similar to that of the range constructor.
*/
template<typename _InputIterator>
void
insert(_InputIterator __first, _InputIterator __last)
{ _M_h.insert(__first, __last); }
/**
* @brief Attempts to insert a list of elements into the
* %unordered_multimap.
* @param __l A std::initializer_list<value_type> of elements
* to be inserted.
*
* Complexity similar to that of the range constructor.
*/
void
insert(initializer_list<value_type> __l)
{ _M_h.insert(__l); }
#if __cplusplus > 201402L
/// Extract a node.
node_type
extract(const_iterator __pos)
{
__glibcxx_assert(__pos != end());
return _M_h.extract(__pos);
}
/// Extract a node.
node_type
extract(const key_type& __key)
{ return _M_h.extract(__key); }
/// Re-insert an extracted node.
iterator
insert(node_type&& __nh)
{ return _M_h._M_reinsert_node_multi(cend(), std::move(__nh)); }
/// Re-insert an extracted node.
iterator
insert(const_iterator __hint, node_type&& __nh)
{ return _M_h._M_reinsert_node_multi(__hint, std::move(__nh)); }
#endif // C++17
//@{
/**
* @brief Erases an element from an %unordered_multimap.
* @param __position An iterator pointing to the element to be erased.
* @return An iterator pointing to the element immediately following
* @a __position prior to the element being erased. If no such
* element exists, end() is returned.
*
* This function erases an element, pointed to by the given iterator,
* from an %unordered_multimap.
* Note that this function only erases the element, and that if the
* element is itself a pointer, the pointed-to memory is not touched in
* any way. Managing the pointer is the user's responsibility.
*/
iterator
erase(const_iterator __position)
{ return _M_h.erase(__position); }
// LWG 2059.
iterator
erase(iterator __position)
{ return _M_h.erase(__position); }
//@}
/**
* @brief Erases elements according to the provided key.
* @param __x Key of elements to be erased.
* @return The number of elements erased.
*
* This function erases all the elements located by the given key from
* an %unordered_multimap.
* Note that this function only erases the element, and that if the
* element is itself a pointer, the pointed-to memory is not touched in
* any way. Managing the pointer is the user's responsibility.
*/
size_type
erase(const key_type& __x)
{ return _M_h.erase(__x); }
/**
* @brief Erases a [__first,__last) range of elements from an
* %unordered_multimap.
* @param __first Iterator pointing to the start of the range to be
* erased.
* @param __last Iterator pointing to the end of the range to
* be erased.
* @return The iterator @a __last.
*
* This function erases a sequence of elements from an
* %unordered_multimap.
* Note that this function only erases the elements, and that if
* the element is itself a pointer, the pointed-to memory is not touched
* in any way. Managing the pointer is the user's responsibility.
*/
iterator
erase(const_iterator __first, const_iterator __last)
{ return _M_h.erase(__first, __last); }
/**
* Erases all elements in an %unordered_multimap.
* Note that this function only erases the elements, and that if the
* elements themselves are pointers, the pointed-to memory is not touched
* in any way. Managing the pointer is the user's responsibility.
*/
void
clear() noexcept
{ _M_h.clear(); }
/**
* @brief Swaps data with another %unordered_multimap.
* @param __x An %unordered_multimap of the same element and allocator
* types.
*
* This exchanges the elements between two %unordered_multimap in
* constant time.
* Note that the global std::swap() function is specialized such that
* std::swap(m1,m2) will feed to this function.
*/
void
swap(unordered_multimap& __x)
noexcept( noexcept(_M_h.swap(__x._M_h)) )
{ _M_h.swap(__x._M_h); }
#if __cplusplus > 201402L
template<typename, typename, typename>
friend class std::_Hash_merge_helper;
template<typename _H2, typename _P2>
void
merge(unordered_multimap<_Key, _Tp, _H2, _P2, _Alloc>& __source)
{
using _Merge_helper
= _Hash_merge_helper<unordered_multimap, _H2, _P2>;
_M_h._M_merge_multi(_Merge_helper::_S_get_table(__source));
}
template<typename _H2, typename _P2>
void
merge(unordered_multimap<_Key, _Tp, _H2, _P2, _Alloc>&& __source)
{ merge(__source); }
template<typename _H2, typename _P2>
void
merge(unordered_map<_Key, _Tp, _H2, _P2, _Alloc>& __source)
{
using _Merge_helper
= _Hash_merge_helper<unordered_multimap, _H2, _P2>;
_M_h._M_merge_multi(_Merge_helper::_S_get_table(__source));
}
template<typename _H2, typename _P2>
void
merge(unordered_map<_Key, _Tp, _H2, _P2, _Alloc>&& __source)
{ merge(__source); }
#endif // C++17
// observers.
/// Returns the hash functor object with which the %unordered_multimap
/// was constructed.
hasher
hash_function() const
{ return _M_h.hash_function(); }
/// Returns the key comparison object with which the %unordered_multimap
/// was constructed.
key_equal
key_eq() const
{ return _M_h.key_eq(); }
// lookup.
//@{
/**
* @brief Tries to locate an element in an %unordered_multimap.
* @param __x Key to be located.
* @return Iterator pointing to sought-after element, or end() if not
* found.
*
* This function takes a key and tries to locate the element with which
* the key matches. If successful the function returns an iterator
* pointing to the sought after element. If unsuccessful it returns the
* past-the-end ( @c end() ) iterator.
*/
iterator
find(const key_type& __x)
{ return _M_h.find(__x); }
const_iterator
find(const key_type& __x) const
{ return _M_h.find(__x); }
//@}
/**
* @brief Finds the number of elements.
* @param __x Key to count.
* @return Number of elements with specified key.
*/
size_type
count(const key_type& __x) const
{ return _M_h.count(__x); }
//@{
/**
* @brief Finds a subsequence matching given key.
* @param __x Key to be located.
* @return Pair of iterators that possibly points to the subsequence
* matching given key.
*/
std::pair<iterator, iterator>
equal_range(const key_type& __x)
{ return _M_h.equal_range(__x); }
std::pair<const_iterator, const_iterator>
equal_range(const key_type& __x) const
{ return _M_h.equal_range(__x); }
//@}
// bucket interface.
/// Returns the number of buckets of the %unordered_multimap.
size_type
bucket_count() const noexcept
{ return _M_h.bucket_count(); }
/// Returns the maximum number of buckets of the %unordered_multimap.
size_type
max_bucket_count() const noexcept
{ return _M_h.max_bucket_count(); }
/*
* @brief Returns the number of elements in a given bucket.
* @param __n A bucket index.
* @return The number of elements in the bucket.
*/
size_type
bucket_size(size_type __n) const
{ return _M_h.bucket_size(__n); }
/*
* @brief Returns the bucket index of a given element.
* @param __key A key instance.
* @return The key bucket index.
*/
size_type
bucket(const key_type& __key) const
{ return _M_h.bucket(__key); }
/**
* @brief Returns a read/write iterator pointing to the first bucket
* element.
* @param __n The bucket index.
* @return A read/write local iterator.
*/
local_iterator
begin(size_type __n)
{ return _M_h.begin(__n); }
//@{
/**
* @brief Returns a read-only (constant) iterator pointing to the first
* bucket element.
* @param __n The bucket index.
* @return A read-only local iterator.
*/
const_local_iterator
begin(size_type __n) const
{ return _M_h.begin(__n); }
const_local_iterator
cbegin(size_type __n) const
{ return _M_h.cbegin(__n); }
//@}
/**
* @brief Returns a read/write iterator pointing to one past the last
* bucket elements.
* @param __n The bucket index.
* @return A read/write local iterator.
*/
local_iterator
end(size_type __n)
{ return _M_h.end(__n); }
//@{
/**
* @brief Returns a read-only (constant) iterator pointing to one past
* the last bucket elements.
* @param __n The bucket index.
* @return A read-only local iterator.
*/
const_local_iterator
end(size_type __n) const
{ return _M_h.end(__n); }
const_local_iterator
cend(size_type __n) const
{ return _M_h.cend(__n); }
//@}
// hash policy.
/// Returns the average number of elements per bucket.
float
load_factor() const noexcept
{ return _M_h.load_factor(); }
/// Returns a positive number that the %unordered_multimap tries to keep
/// the load factor less than or equal to.
float
max_load_factor() const noexcept
{ return _M_h.max_load_factor(); }
/**
* @brief Change the %unordered_multimap maximum load factor.
* @param __z The new maximum load factor.
*/
void
max_load_factor(float __z)
{ _M_h.max_load_factor(__z); }
/**
* @brief May rehash the %unordered_multimap.
* @param __n The new number of buckets.
*
* Rehash will occur only if the new number of buckets respect the
* %unordered_multimap maximum load factor.
*/
void
rehash(size_type __n)
{ _M_h.rehash(__n); }
/**
* @brief Prepare the %unordered_multimap for a specified number of
* elements.
* @param __n Number of elements required.
*
* Same as rehash(ceil(n / max_load_factor())).
*/
void
reserve(size_type __n)
{ _M_h.reserve(__n); }
template<typename _Key1, typename _Tp1, typename _Hash1, typename _Pred1,
typename _Alloc1>
friend bool
operator==(const unordered_multimap<_Key1, _Tp1,
_Hash1, _Pred1, _Alloc1>&,
const unordered_multimap<_Key1, _Tp1,
_Hash1, _Pred1, _Alloc1>&);
};
#if __cpp_deduction_guides >= 201606
template<typename _InputIterator,
typename _Hash = hash<__iter_key_t<_InputIterator>>,
typename _Pred = equal_to<__iter_key_t<_InputIterator>>,
typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>,
typename = _RequireInputIter<_InputIterator>,
typename = _RequireAllocator<_Allocator>>
unordered_multimap(_InputIterator, _InputIterator,
unordered_multimap<int, int>::size_type = {},
_Hash = _Hash(), _Pred = _Pred(),
_Allocator = _Allocator())
-> unordered_multimap<__iter_key_t<_InputIterator>,
__iter_val_t<_InputIterator>, _Hash, _Pred,
_Allocator>;
template<typename _Key, typename _Tp, typename _Hash = hash<_Key>,
typename _Pred = equal_to<_Key>,
typename _Allocator = allocator<pair<const _Key, _Tp>>,
typename = _RequireAllocator<_Allocator>>
unordered_multimap(initializer_list<pair<_Key, _Tp>>,
unordered_multimap<int, int>::size_type = {},
_Hash = _Hash(), _Pred = _Pred(),
_Allocator = _Allocator())
-> unordered_multimap<_Key, _Tp, _Hash, _Pred, _Allocator>;
template<typename _InputIterator, typename _Allocator,
typename = _RequireInputIter<_InputIterator>,
typename = _RequireAllocator<_Allocator>>
unordered_multimap(_InputIterator, _InputIterator,
unordered_multimap<int, int>::size_type, _Allocator)
-> unordered_multimap<__iter_key_t<_InputIterator>,
__iter_val_t<_InputIterator>,
hash<__iter_key_t<_InputIterator>>,
equal_to<__iter_key_t<_InputIterator>>, _Allocator>;
template<typename _InputIterator, typename _Allocator,
typename = _RequireInputIter<_InputIterator>,
typename = _RequireAllocator<_Allocator>>
unordered_multimap(_InputIterator, _InputIterator, _Allocator)
-> unordered_multimap<__iter_key_t<_InputIterator>,
__iter_val_t<_InputIterator>,
hash<__iter_key_t<_InputIterator>>,
equal_to<__iter_key_t<_InputIterator>>, _Allocator>;
template<typename _InputIterator, typename _Hash, typename _Allocator,
typename = _RequireInputIter<_InputIterator>,
typename = _RequireAllocator<_Allocator>>
unordered_multimap(_InputIterator, _InputIterator,
unordered_multimap<int, int>::size_type, _Hash,
_Allocator)
-> unordered_multimap<__iter_key_t<_InputIterator>,
__iter_val_t<_InputIterator>, _Hash,
equal_to<__iter_key_t<_InputIterator>>, _Allocator>;
template<typename _Key, typename _Tp, typename _Allocator,
typename = _RequireAllocator<_Allocator>>
unordered_multimap(initializer_list<pair<_Key, _Tp>>,
unordered_multimap<int, int>::size_type,
_Allocator)
-> unordered_multimap<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>;
template<typename _Key, typename _Tp, typename _Allocator,
typename = _RequireAllocator<_Allocator>>
unordered_multimap(initializer_list<pair<_Key, _Tp>>, _Allocator)
-> unordered_multimap<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>;
template<typename _Key, typename _Tp, typename _Hash, typename _Allocator,
typename = _RequireAllocator<_Allocator>>
unordered_multimap(initializer_list<pair<_Key, _Tp>>,
unordered_multimap<int, int>::size_type,
_Hash, _Allocator)
-> unordered_multimap<_Key, _Tp, _Hash, equal_to<_Key>, _Allocator>;
#endif
template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
inline void
swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
noexcept(noexcept(__x.swap(__y)))
{ __x.swap(__y); }
template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
inline void
swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
noexcept(noexcept(__x.swap(__y)))
{ __x.swap(__y); }
template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
inline bool
operator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
{ return __x._M_h._M_equal(__y._M_h); }
template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
inline bool
operator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
{ return !(__x == __y); }
template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
inline bool
operator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
{ return __x._M_h._M_equal(__y._M_h); }
template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
inline bool
operator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
{ return !(__x == __y); }
_GLIBCXX_END_NAMESPACE_CONTAINER
#if __cplusplus > 201402L
// Allow std::unordered_map access to internals of compatible maps.
template<typename _Key, typename _Val, typename _Hash1, typename _Eq1,
typename _Alloc, typename _Hash2, typename _Eq2>
struct _Hash_merge_helper<
_GLIBCXX_STD_C::unordered_map<_Key, _Val, _Hash1, _Eq1, _Alloc>,
_Hash2, _Eq2>
{
private:
template<typename... _Tp>
using unordered_map = _GLIBCXX_STD_C::unordered_map<_Tp...>;
template<typename... _Tp>
using unordered_multimap = _GLIBCXX_STD_C::unordered_multimap<_Tp...>;
friend unordered_map<_Key, _Val, _Hash1, _Eq1, _Alloc>;
static auto&
_S_get_table(unordered_map<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map)
{ return __map._M_h; }
static auto&
_S_get_table(unordered_multimap<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map)
{ return __map._M_h; }
};
// Allow std::unordered_multimap access to internals of compatible maps.
template<typename _Key, typename _Val, typename _Hash1, typename _Eq1,
typename _Alloc, typename _Hash2, typename _Eq2>
struct _Hash_merge_helper<
_GLIBCXX_STD_C::unordered_multimap<_Key, _Val, _Hash1, _Eq1, _Alloc>,
_Hash2, _Eq2>
{
private:
template<typename... _Tp>
using unordered_map = _GLIBCXX_STD_C::unordered_map<_Tp...>;
template<typename... _Tp>
using unordered_multimap = _GLIBCXX_STD_C::unordered_multimap<_Tp...>;
friend unordered_multimap<_Key, _Val, _Hash1, _Eq1, _Alloc>;
static auto&
_S_get_table(unordered_map<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map)
{ return __map._M_h; }
static auto&
_S_get_table(unordered_multimap<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map)
{ return __map._M_h; }
};
#endif // C++17
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif /* _UNORDERED_MAP_H */
c++/8/bits/regex_compiler.tcc 0000644 00000045530 15201526705 0011735 0 ustar 00 // class template regex -*- C++ -*-
// Copyright (C) 2013-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/**
* @file bits/regex_compiler.tcc
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{regex}
*/
// FIXME make comments doxygen format.
/*
// This compiler refers to "Regular Expression Matching Can Be Simple And Fast"
// (http://swtch.com/~rsc/regexp/regexp1.html),
// but doesn't strictly follow it.
//
// When compiling, states are *chained* instead of tree- or graph-constructed.
// It's more like structured programs: there's if statement and loop statement.
//
// For alternative structure (say "a|b"), aka "if statement", two branches
// should be constructed. However, these two shall merge to an "end_tag" at
// the end of this operator:
//
// branch1
// / \
// => begin_tag end_tag =>
// \ /
// branch2
//
// This is the difference between this implementation and that in Russ's
// article.
//
// That's why we introduced dummy node here ------ "end_tag" is a dummy node.
// All dummy nodes will be eliminated at the end of compilation.
*/
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
namespace __detail
{
template<typename _TraitsT>
_Compiler<_TraitsT>::
_Compiler(_IterT __b, _IterT __e,
const typename _TraitsT::locale_type& __loc, _FlagT __flags)
: _M_flags((__flags
& (regex_constants::ECMAScript
| regex_constants::basic
| regex_constants::extended
| regex_constants::grep
| regex_constants::egrep
| regex_constants::awk))
? __flags
: __flags | regex_constants::ECMAScript),
_M_scanner(__b, __e, _M_flags, __loc),
_M_nfa(make_shared<_RegexT>(__loc, _M_flags)),
_M_traits(_M_nfa->_M_traits),
_M_ctype(std::use_facet<_CtypeT>(__loc))
{
_StateSeqT __r(*_M_nfa, _M_nfa->_M_start());
__r._M_append(_M_nfa->_M_insert_subexpr_begin());
this->_M_disjunction();
if (!_M_match_token(_ScannerT::_S_token_eof))
__throw_regex_error(regex_constants::error_paren);
__r._M_append(_M_pop());
__glibcxx_assert(_M_stack.empty());
__r._M_append(_M_nfa->_M_insert_subexpr_end());
__r._M_append(_M_nfa->_M_insert_accept());
_M_nfa->_M_eliminate_dummy();
}
template<typename _TraitsT>
void
_Compiler<_TraitsT>::
_M_disjunction()
{
this->_M_alternative();
while (_M_match_token(_ScannerT::_S_token_or))
{
_StateSeqT __alt1 = _M_pop();
this->_M_alternative();
_StateSeqT __alt2 = _M_pop();
auto __end = _M_nfa->_M_insert_dummy();
__alt1._M_append(__end);
__alt2._M_append(__end);
// __alt2 is state._M_next, __alt1 is state._M_alt. The executor
// executes _M_alt before _M_next, as well as executing left
// alternative before right one.
_M_stack.push(_StateSeqT(*_M_nfa,
_M_nfa->_M_insert_alt(
__alt2._M_start, __alt1._M_start, false),
__end));
}
}
template<typename _TraitsT>
void
_Compiler<_TraitsT>::
_M_alternative()
{
if (this->_M_term())
{
_StateSeqT __re = _M_pop();
this->_M_alternative();
__re._M_append(_M_pop());
_M_stack.push(__re);
}
else
_M_stack.push(_StateSeqT(*_M_nfa, _M_nfa->_M_insert_dummy()));
}
template<typename _TraitsT>
bool
_Compiler<_TraitsT>::
_M_term()
{
if (this->_M_assertion())
return true;
if (this->_M_atom())
{
while (this->_M_quantifier())
;
return true;
}
return false;
}
template<typename _TraitsT>
bool
_Compiler<_TraitsT>::
_M_assertion()
{
if (_M_match_token(_ScannerT::_S_token_line_begin))
_M_stack.push(_StateSeqT(*_M_nfa, _M_nfa->_M_insert_line_begin()));
else if (_M_match_token(_ScannerT::_S_token_line_end))
_M_stack.push(_StateSeqT(*_M_nfa, _M_nfa->_M_insert_line_end()));
else if (_M_match_token(_ScannerT::_S_token_word_bound))
// _M_value[0] == 'n' means it's negative, say "not word boundary".
_M_stack.push(_StateSeqT(*_M_nfa, _M_nfa->
_M_insert_word_bound(_M_value[0] == 'n')));
else if (_M_match_token(_ScannerT::_S_token_subexpr_lookahead_begin))
{
auto __neg = _M_value[0] == 'n';
this->_M_disjunction();
if (!_M_match_token(_ScannerT::_S_token_subexpr_end))
__throw_regex_error(regex_constants::error_paren,
"Parenthesis is not closed.");
auto __tmp = _M_pop();
__tmp._M_append(_M_nfa->_M_insert_accept());
_M_stack.push(
_StateSeqT(
*_M_nfa,
_M_nfa->_M_insert_lookahead(__tmp._M_start, __neg)));
}
else
return false;
return true;
}
template<typename _TraitsT>
bool
_Compiler<_TraitsT>::
_M_quantifier()
{
bool __neg = (_M_flags & regex_constants::ECMAScript);
auto __init = [this, &__neg]()
{
if (_M_stack.empty())
__throw_regex_error(regex_constants::error_badrepeat,
"Nothing to repeat before a quantifier.");
__neg = __neg && _M_match_token(_ScannerT::_S_token_opt);
};
if (_M_match_token(_ScannerT::_S_token_closure0))
{
__init();
auto __e = _M_pop();
_StateSeqT __r(*_M_nfa,
_M_nfa->_M_insert_repeat(_S_invalid_state_id,
__e._M_start, __neg));
__e._M_append(__r);
_M_stack.push(__r);
}
else if (_M_match_token(_ScannerT::_S_token_closure1))
{
__init();
auto __e = _M_pop();
__e._M_append(_M_nfa->_M_insert_repeat(_S_invalid_state_id,
__e._M_start, __neg));
_M_stack.push(__e);
}
else if (_M_match_token(_ScannerT::_S_token_opt))
{
__init();
auto __e = _M_pop();
auto __end = _M_nfa->_M_insert_dummy();
_StateSeqT __r(*_M_nfa,
_M_nfa->_M_insert_repeat(_S_invalid_state_id,
__e._M_start, __neg));
__e._M_append(__end);
__r._M_append(__end);
_M_stack.push(__r);
}
else if (_M_match_token(_ScannerT::_S_token_interval_begin))
{
if (_M_stack.empty())
__throw_regex_error(regex_constants::error_badrepeat,
"Nothing to repeat before a quantifier.");
if (!_M_match_token(_ScannerT::_S_token_dup_count))
__throw_regex_error(regex_constants::error_badbrace,
"Unexpected token in brace expression.");
_StateSeqT __r(_M_pop());
_StateSeqT __e(*_M_nfa, _M_nfa->_M_insert_dummy());
long __min_rep = _M_cur_int_value(10);
bool __infi = false;
long __n;
// {3
if (_M_match_token(_ScannerT::_S_token_comma))
if (_M_match_token(_ScannerT::_S_token_dup_count)) // {3,7}
__n = _M_cur_int_value(10) - __min_rep;
else
__infi = true;
else
__n = 0;
if (!_M_match_token(_ScannerT::_S_token_interval_end))
__throw_regex_error(regex_constants::error_brace,
"Unexpected end of brace expression.");
__neg = __neg && _M_match_token(_ScannerT::_S_token_opt);
for (long __i = 0; __i < __min_rep; ++__i)
__e._M_append(__r._M_clone());
if (__infi)
{
auto __tmp = __r._M_clone();
_StateSeqT __s(*_M_nfa,
_M_nfa->_M_insert_repeat(_S_invalid_state_id,
__tmp._M_start, __neg));
__tmp._M_append(__s);
__e._M_append(__s);
}
else
{
if (__n < 0)
__throw_regex_error(regex_constants::error_badbrace,
"Invalid range in brace expression.");
auto __end = _M_nfa->_M_insert_dummy();
// _M_alt is the "match more" branch, and _M_next is the
// "match less" one. Switch _M_alt and _M_next of all created
// nodes. This is a hack but IMO works well.
std::stack<_StateIdT> __stack;
for (long __i = 0; __i < __n; ++__i)
{
auto __tmp = __r._M_clone();
auto __alt = _M_nfa->_M_insert_repeat(__tmp._M_start,
__end, __neg);
__stack.push(__alt);
__e._M_append(_StateSeqT(*_M_nfa, __alt, __tmp._M_end));
}
__e._M_append(__end);
while (!__stack.empty())
{
auto& __tmp = (*_M_nfa)[__stack.top()];
__stack.pop();
std::swap(__tmp._M_next, __tmp._M_alt);
}
}
_M_stack.push(__e);
}
else
return false;
return true;
}
#define __INSERT_REGEX_MATCHER(__func, ...)\
do {\
if (!(_M_flags & regex_constants::icase))\
if (!(_M_flags & regex_constants::collate))\
__func<false, false>(__VA_ARGS__);\
else\
__func<false, true>(__VA_ARGS__);\
else\
if (!(_M_flags & regex_constants::collate))\
__func<true, false>(__VA_ARGS__);\
else\
__func<true, true>(__VA_ARGS__);\
} while (false)
template<typename _TraitsT>
bool
_Compiler<_TraitsT>::
_M_atom()
{
if (_M_match_token(_ScannerT::_S_token_anychar))
{
if (!(_M_flags & regex_constants::ECMAScript))
__INSERT_REGEX_MATCHER(_M_insert_any_matcher_posix);
else
__INSERT_REGEX_MATCHER(_M_insert_any_matcher_ecma);
}
else if (_M_try_char())
__INSERT_REGEX_MATCHER(_M_insert_char_matcher);
else if (_M_match_token(_ScannerT::_S_token_backref))
_M_stack.push(_StateSeqT(*_M_nfa, _M_nfa->
_M_insert_backref(_M_cur_int_value(10))));
else if (_M_match_token(_ScannerT::_S_token_quoted_class))
__INSERT_REGEX_MATCHER(_M_insert_character_class_matcher);
else if (_M_match_token(_ScannerT::_S_token_subexpr_no_group_begin))
{
_StateSeqT __r(*_M_nfa, _M_nfa->_M_insert_dummy());
this->_M_disjunction();
if (!_M_match_token(_ScannerT::_S_token_subexpr_end))
__throw_regex_error(regex_constants::error_paren,
"Parenthesis is not closed.");
__r._M_append(_M_pop());
_M_stack.push(__r);
}
else if (_M_match_token(_ScannerT::_S_token_subexpr_begin))
{
_StateSeqT __r(*_M_nfa, _M_nfa->_M_insert_subexpr_begin());
this->_M_disjunction();
if (!_M_match_token(_ScannerT::_S_token_subexpr_end))
__throw_regex_error(regex_constants::error_paren,
"Parenthesis is not closed.");
__r._M_append(_M_pop());
__r._M_append(_M_nfa->_M_insert_subexpr_end());
_M_stack.push(__r);
}
else if (!_M_bracket_expression())
return false;
return true;
}
template<typename _TraitsT>
bool
_Compiler<_TraitsT>::
_M_bracket_expression()
{
bool __neg =
_M_match_token(_ScannerT::_S_token_bracket_neg_begin);
if (!(__neg || _M_match_token(_ScannerT::_S_token_bracket_begin)))
return false;
__INSERT_REGEX_MATCHER(_M_insert_bracket_matcher, __neg);
return true;
}
#undef __INSERT_REGEX_MATCHER
template<typename _TraitsT>
template<bool __icase, bool __collate>
void
_Compiler<_TraitsT>::
_M_insert_any_matcher_ecma()
{
_M_stack.push(_StateSeqT(*_M_nfa,
_M_nfa->_M_insert_matcher
(_AnyMatcher<_TraitsT, true, __icase, __collate>
(_M_traits))));
}
template<typename _TraitsT>
template<bool __icase, bool __collate>
void
_Compiler<_TraitsT>::
_M_insert_any_matcher_posix()
{
_M_stack.push(_StateSeqT(*_M_nfa,
_M_nfa->_M_insert_matcher
(_AnyMatcher<_TraitsT, false, __icase, __collate>
(_M_traits))));
}
template<typename _TraitsT>
template<bool __icase, bool __collate>
void
_Compiler<_TraitsT>::
_M_insert_char_matcher()
{
_M_stack.push(_StateSeqT(*_M_nfa,
_M_nfa->_M_insert_matcher
(_CharMatcher<_TraitsT, __icase, __collate>
(_M_value[0], _M_traits))));
}
template<typename _TraitsT>
template<bool __icase, bool __collate>
void
_Compiler<_TraitsT>::
_M_insert_character_class_matcher()
{
__glibcxx_assert(_M_value.size() == 1);
_BracketMatcher<__icase, __collate> __matcher
(_M_ctype.is(_CtypeT::upper, _M_value[0]), _M_traits);
__matcher._M_add_character_class(_M_value, false);
__matcher._M_ready();
_M_stack.push(_StateSeqT(*_M_nfa,
_M_nfa->_M_insert_matcher(std::move(__matcher))));
}
template<typename _TraitsT>
template<bool __icase, bool __collate>
void
_Compiler<_TraitsT>::
_M_insert_bracket_matcher(bool __neg)
{
_BracketMatcher<__icase, __collate> __matcher(__neg, _M_traits);
_BracketState __last_char;
if (_M_try_char())
__last_char.set(_M_value[0]);
else if (_M_match_token(_ScannerT::_S_token_bracket_dash))
// Dash as first character is a normal character.
__last_char.set('-');
while (_M_expression_term(__last_char, __matcher))
;
if (__last_char._M_is_char())
__matcher._M_add_char(__last_char.get());
__matcher._M_ready();
_M_stack.push(_StateSeqT(
*_M_nfa,
_M_nfa->_M_insert_matcher(std::move(__matcher))));
}
template<typename _TraitsT>
template<bool __icase, bool __collate>
bool
_Compiler<_TraitsT>::
_M_expression_term(_BracketState& __last_char,
_BracketMatcher<__icase, __collate>& __matcher)
{
if (_M_match_token(_ScannerT::_S_token_bracket_end))
return false;
// Add any previously cached char into the matcher and update cache.
const auto __push_char = [&](_CharT __ch)
{
if (__last_char._M_is_char())
__matcher._M_add_char(__last_char.get());
__last_char.set(__ch);
};
// Add any previously cached char into the matcher and update cache.
const auto __push_class = [&]
{
if (__last_char._M_is_char())
__matcher._M_add_char(__last_char.get());
// We don't cache anything here, just record that the last thing
// processed was a character class (or similar).
__last_char.reset(_BracketState::_Type::_Class);
};
if (_M_match_token(_ScannerT::_S_token_collsymbol))
{
auto __symbol = __matcher._M_add_collate_element(_M_value);
if (__symbol.size() == 1)
__push_char(__symbol[0]);
else
__push_class();
}
else if (_M_match_token(_ScannerT::_S_token_equiv_class_name))
{
__push_class();
__matcher._M_add_equivalence_class(_M_value);
}
else if (_M_match_token(_ScannerT::_S_token_char_class_name))
{
__push_class();
__matcher._M_add_character_class(_M_value, false);
}
else if (_M_try_char())
__push_char(_M_value[0]);
// POSIX doesn't allow '-' as a start-range char (say [a-z--0]),
// except when the '-' is the first or last character in the bracket
// expression ([--0]). ECMAScript treats all '-' after a range as a
// normal character. Also see above, where _M_expression_term gets called.
//
// As a result, POSIX rejects [-----], but ECMAScript doesn't.
// Boost (1.57.0) always uses POSIX style even in its ECMAScript syntax.
// Clang (3.5) always uses ECMAScript style even in its POSIX syntax.
//
// It turns out that no one reads BNFs ;)
else if (_M_match_token(_ScannerT::_S_token_bracket_dash))
{
if (_M_match_token(_ScannerT::_S_token_bracket_end))
{
// For "-]" the dash is a literal character.
__push_char('-');
return false;
}
else if (__last_char._M_is_class())
{
// "\\w-" is invalid, start of range must be a single char.
__throw_regex_error(regex_constants::error_range,
"Invalid start of range in bracket expression.");
}
else if (__last_char._M_is_char())
{
if (_M_try_char())
{
// "x-y"
__matcher._M_make_range(__last_char.get(), _M_value[0]);
__last_char.reset();
}
else if (_M_match_token(_ScannerT::_S_token_bracket_dash))
{
// "x--"
__matcher._M_make_range(__last_char.get(), '-');
__last_char.reset();
}
else
__throw_regex_error(regex_constants::error_range,
"Invalid end of range in bracket expression.");
}
else if (_M_flags & regex_constants::ECMAScript)
{
// A dash that is not part of an existing range. Might be the
// start of a new range, or might just be a literal '-' char.
// Only ECMAScript allows that in the middle of a bracket expr.
__push_char('-');
}
else
__throw_regex_error(regex_constants::error_range,
"Invalid dash in bracket expression.");
}
else if (_M_match_token(_ScannerT::_S_token_quoted_class))
{
__push_class();
__matcher._M_add_character_class(_M_value,
_M_ctype.is(_CtypeT::upper,
_M_value[0]));
}
else
__throw_regex_error(regex_constants::error_brack,
"Unexpected character in bracket expression.");
return true;
}
template<typename _TraitsT>
bool
_Compiler<_TraitsT>::
_M_try_char()
{
bool __is_char = false;
if (_M_match_token(_ScannerT::_S_token_oct_num))
{
__is_char = true;
_M_value.assign(1, _M_cur_int_value(8));
}
else if (_M_match_token(_ScannerT::_S_token_hex_num))
{
__is_char = true;
_M_value.assign(1, _M_cur_int_value(16));
}
else if (_M_match_token(_ScannerT::_S_token_ord_char))
__is_char = true;
return __is_char;
}
template<typename _TraitsT>
bool
_Compiler<_TraitsT>::
_M_match_token(_TokenT __token)
{
if (__token == _M_scanner._M_get_token())
{
_M_value = _M_scanner._M_get_value();
_M_scanner._M_advance();
return true;
}
return false;
}
template<typename _TraitsT>
int
_Compiler<_TraitsT>::
_M_cur_int_value(int __radix)
{
long __v = 0;
for (typename _StringT::size_type __i = 0;
__i < _M_value.length(); ++__i)
__v =__v * __radix + _M_traits.value(_M_value[__i], __radix);
return __v;
}
template<typename _TraitsT, bool __icase, bool __collate>
bool
_BracketMatcher<_TraitsT, __icase, __collate>::
_M_apply(_CharT __ch, false_type) const
{
return [this, __ch]
{
if (std::binary_search(_M_char_set.begin(), _M_char_set.end(),
_M_translator._M_translate(__ch)))
return true;
auto __s = _M_translator._M_transform(__ch);
for (auto& __it : _M_range_set)
if (_M_translator._M_match_range(__it.first, __it.second, __s))
return true;
if (_M_traits.isctype(__ch, _M_class_set))
return true;
if (std::find(_M_equiv_set.begin(), _M_equiv_set.end(),
_M_traits.transform_primary(&__ch, &__ch+1))
!= _M_equiv_set.end())
return true;
for (auto& __it : _M_neg_class_set)
if (!_M_traits.isctype(__ch, __it))
return true;
return false;
}() ^ _M_is_non_matching;
}
} // namespace __detail
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
c++/8/bits/predefined_ops.h 0000644 00000021573 15201526705 0011376 0 ustar 00 // Default predicates for internal use -*- C++ -*-
// Copyright (C) 2013-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file predefined_ops.h
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly. @headername{algorithm}
*/
#ifndef _GLIBCXX_PREDEFINED_OPS_H
#define _GLIBCXX_PREDEFINED_OPS_H 1
namespace __gnu_cxx
{
namespace __ops
{
struct _Iter_less_iter
{
template<typename _Iterator1, typename _Iterator2>
_GLIBCXX14_CONSTEXPR
bool
operator()(_Iterator1 __it1, _Iterator2 __it2) const
{ return *__it1 < *__it2; }
};
_GLIBCXX14_CONSTEXPR
inline _Iter_less_iter
__iter_less_iter()
{ return _Iter_less_iter(); }
struct _Iter_less_val
{
#if __cplusplus >= 201103L
constexpr _Iter_less_val() = default;
#else
_Iter_less_val() { }
#endif
explicit
_Iter_less_val(_Iter_less_iter) { }
template<typename _Iterator, typename _Value>
bool
operator()(_Iterator __it, _Value& __val) const
{ return *__it < __val; }
};
inline _Iter_less_val
__iter_less_val()
{ return _Iter_less_val(); }
inline _Iter_less_val
__iter_comp_val(_Iter_less_iter)
{ return _Iter_less_val(); }
struct _Val_less_iter
{
#if __cplusplus >= 201103L
constexpr _Val_less_iter() = default;
#else
_Val_less_iter() { }
#endif
explicit
_Val_less_iter(_Iter_less_iter) { }
template<typename _Value, typename _Iterator>
bool
operator()(_Value& __val, _Iterator __it) const
{ return __val < *__it; }
};
inline _Val_less_iter
__val_less_iter()
{ return _Val_less_iter(); }
inline _Val_less_iter
__val_comp_iter(_Iter_less_iter)
{ return _Val_less_iter(); }
struct _Iter_equal_to_iter
{
template<typename _Iterator1, typename _Iterator2>
bool
operator()(_Iterator1 __it1, _Iterator2 __it2) const
{ return *__it1 == *__it2; }
};
inline _Iter_equal_to_iter
__iter_equal_to_iter()
{ return _Iter_equal_to_iter(); }
struct _Iter_equal_to_val
{
template<typename _Iterator, typename _Value>
bool
operator()(_Iterator __it, _Value& __val) const
{ return *__it == __val; }
};
inline _Iter_equal_to_val
__iter_equal_to_val()
{ return _Iter_equal_to_val(); }
inline _Iter_equal_to_val
__iter_comp_val(_Iter_equal_to_iter)
{ return _Iter_equal_to_val(); }
template<typename _Compare>
struct _Iter_comp_iter
{
_Compare _M_comp;
explicit _GLIBCXX14_CONSTEXPR
_Iter_comp_iter(_Compare __comp)
: _M_comp(_GLIBCXX_MOVE(__comp))
{ }
template<typename _Iterator1, typename _Iterator2>
_GLIBCXX14_CONSTEXPR
bool
operator()(_Iterator1 __it1, _Iterator2 __it2)
{ return bool(_M_comp(*__it1, *__it2)); }
};
template<typename _Compare>
_GLIBCXX14_CONSTEXPR
inline _Iter_comp_iter<_Compare>
__iter_comp_iter(_Compare __comp)
{ return _Iter_comp_iter<_Compare>(_GLIBCXX_MOVE(__comp)); }
template<typename _Compare>
struct _Iter_comp_val
{
_Compare _M_comp;
explicit
_Iter_comp_val(_Compare __comp)
: _M_comp(_GLIBCXX_MOVE(__comp))
{ }
explicit
_Iter_comp_val(const _Iter_comp_iter<_Compare>& __comp)
: _M_comp(__comp._M_comp)
{ }
#if __cplusplus >= 201103L
explicit
_Iter_comp_val(_Iter_comp_iter<_Compare>&& __comp)
: _M_comp(std::move(__comp._M_comp))
{ }
#endif
template<typename _Iterator, typename _Value>
bool
operator()(_Iterator __it, _Value& __val)
{ return bool(_M_comp(*__it, __val)); }
};
template<typename _Compare>
inline _Iter_comp_val<_Compare>
__iter_comp_val(_Compare __comp)
{ return _Iter_comp_val<_Compare>(_GLIBCXX_MOVE(__comp)); }
template<typename _Compare>
inline _Iter_comp_val<_Compare>
__iter_comp_val(_Iter_comp_iter<_Compare> __comp)
{ return _Iter_comp_val<_Compare>(_GLIBCXX_MOVE(__comp)); }
template<typename _Compare>
struct _Val_comp_iter
{
_Compare _M_comp;
explicit
_Val_comp_iter(_Compare __comp)
: _M_comp(_GLIBCXX_MOVE(__comp))
{ }
explicit
_Val_comp_iter(const _Iter_comp_iter<_Compare>& __comp)
: _M_comp(__comp._M_comp)
{ }
#if __cplusplus >= 201103L
explicit
_Val_comp_iter(_Iter_comp_iter<_Compare>&& __comp)
: _M_comp(std::move(__comp._M_comp))
{ }
#endif
template<typename _Value, typename _Iterator>
bool
operator()(_Value& __val, _Iterator __it)
{ return bool(_M_comp(__val, *__it)); }
};
template<typename _Compare>
inline _Val_comp_iter<_Compare>
__val_comp_iter(_Compare __comp)
{ return _Val_comp_iter<_Compare>(_GLIBCXX_MOVE(__comp)); }
template<typename _Compare>
inline _Val_comp_iter<_Compare>
__val_comp_iter(_Iter_comp_iter<_Compare> __comp)
{ return _Val_comp_iter<_Compare>(_GLIBCXX_MOVE(__comp)); }
template<typename _Value>
struct _Iter_equals_val
{
_Value& _M_value;
explicit
_Iter_equals_val(_Value& __value)
: _M_value(__value)
{ }
template<typename _Iterator>
bool
operator()(_Iterator __it)
{ return *__it == _M_value; }
};
template<typename _Value>
inline _Iter_equals_val<_Value>
__iter_equals_val(_Value& __val)
{ return _Iter_equals_val<_Value>(__val); }
template<typename _Iterator1>
struct _Iter_equals_iter
{
_Iterator1 _M_it1;
explicit
_Iter_equals_iter(_Iterator1 __it1)
: _M_it1(__it1)
{ }
template<typename _Iterator2>
bool
operator()(_Iterator2 __it2)
{ return *__it2 == *_M_it1; }
};
template<typename _Iterator>
inline _Iter_equals_iter<_Iterator>
__iter_comp_iter(_Iter_equal_to_iter, _Iterator __it)
{ return _Iter_equals_iter<_Iterator>(__it); }
template<typename _Predicate>
struct _Iter_pred
{
_Predicate _M_pred;
explicit
_Iter_pred(_Predicate __pred)
: _M_pred(_GLIBCXX_MOVE(__pred))
{ }
template<typename _Iterator>
bool
operator()(_Iterator __it)
{ return bool(_M_pred(*__it)); }
};
template<typename _Predicate>
inline _Iter_pred<_Predicate>
__pred_iter(_Predicate __pred)
{ return _Iter_pred<_Predicate>(_GLIBCXX_MOVE(__pred)); }
template<typename _Compare, typename _Value>
struct _Iter_comp_to_val
{
_Compare _M_comp;
_Value& _M_value;
_Iter_comp_to_val(_Compare __comp, _Value& __value)
: _M_comp(_GLIBCXX_MOVE(__comp)), _M_value(__value)
{ }
template<typename _Iterator>
bool
operator()(_Iterator __it)
{ return bool(_M_comp(*__it, _M_value)); }
};
template<typename _Compare, typename _Value>
_Iter_comp_to_val<_Compare, _Value>
__iter_comp_val(_Compare __comp, _Value &__val)
{
return _Iter_comp_to_val<_Compare, _Value>(_GLIBCXX_MOVE(__comp), __val);
}
template<typename _Compare, typename _Iterator1>
struct _Iter_comp_to_iter
{
_Compare _M_comp;
_Iterator1 _M_it1;
_Iter_comp_to_iter(_Compare __comp, _Iterator1 __it1)
: _M_comp(_GLIBCXX_MOVE(__comp)), _M_it1(__it1)
{ }
template<typename _Iterator2>
bool
operator()(_Iterator2 __it2)
{ return bool(_M_comp(*__it2, *_M_it1)); }
};
template<typename _Compare, typename _Iterator>
inline _Iter_comp_to_iter<_Compare, _Iterator>
__iter_comp_iter(_Iter_comp_iter<_Compare> __comp, _Iterator __it)
{
return _Iter_comp_to_iter<_Compare, _Iterator>(
_GLIBCXX_MOVE(__comp._M_comp), __it);
}
template<typename _Predicate>
struct _Iter_negate
{
_Predicate _M_pred;
explicit
_Iter_negate(_Predicate __pred)
: _M_pred(_GLIBCXX_MOVE(__pred))
{ }
template<typename _Iterator>
bool
operator()(_Iterator __it)
{ return !bool(_M_pred(*__it)); }
};
template<typename _Predicate>
inline _Iter_negate<_Predicate>
__negate(_Iter_pred<_Predicate> __pred)
{ return _Iter_negate<_Predicate>(_GLIBCXX_MOVE(__pred._M_pred)); }
} // namespace __ops
} // namespace __gnu_cxx
#endif
c++/8/bits/basic_string.tcc 0000644 00000150773 15201526705 0011406 0 ustar 00 // Components for manipulating sequences of characters -*- C++ -*-
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/basic_string.tcc
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{string}
*/
//
// ISO C++ 14882: 21 Strings library
//
// Written by Jason Merrill based upon the specification by Takanori Adachi
// in ANSI X3J16/94-0013R2. Rewritten by Nathan Myers to ISO-14882.
// Non-reference-counted implementation written by Paolo Carlini and
// updated by Jonathan Wakely for ISO-14882-2011.
#ifndef _BASIC_STRING_TCC
#define _BASIC_STRING_TCC 1
#pragma GCC system_header
#include <bits/cxxabi_forced.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
#if _GLIBCXX_USE_CXX11_ABI
template<typename _CharT, typename _Traits, typename _Alloc>
const typename basic_string<_CharT, _Traits, _Alloc>::size_type
basic_string<_CharT, _Traits, _Alloc>::npos;
template<typename _CharT, typename _Traits, typename _Alloc>
void
basic_string<_CharT, _Traits, _Alloc>::
swap(basic_string& __s) _GLIBCXX_NOEXCEPT
{
if (this == &__s)
return;
_Alloc_traits::_S_on_swap(_M_get_allocator(), __s._M_get_allocator());
if (_M_is_local())
if (__s._M_is_local())
{
if (length() && __s.length())
{
_CharT __tmp_data[_S_local_capacity + 1];
traits_type::copy(__tmp_data, __s._M_local_buf,
_S_local_capacity + 1);
traits_type::copy(__s._M_local_buf, _M_local_buf,
_S_local_capacity + 1);
traits_type::copy(_M_local_buf, __tmp_data,
_S_local_capacity + 1);
}
else if (__s.length())
{
traits_type::copy(_M_local_buf, __s._M_local_buf,
_S_local_capacity + 1);
_M_length(__s.length());
__s._M_set_length(0);
return;
}
else if (length())
{
traits_type::copy(__s._M_local_buf, _M_local_buf,
_S_local_capacity + 1);
__s._M_length(length());
_M_set_length(0);
return;
}
}
else
{
const size_type __tmp_capacity = __s._M_allocated_capacity;
traits_type::copy(__s._M_local_buf, _M_local_buf,
_S_local_capacity + 1);
_M_data(__s._M_data());
__s._M_data(__s._M_local_buf);
_M_capacity(__tmp_capacity);
}
else
{
const size_type __tmp_capacity = _M_allocated_capacity;
if (__s._M_is_local())
{
traits_type::copy(_M_local_buf, __s._M_local_buf,
_S_local_capacity + 1);
__s._M_data(_M_data());
_M_data(_M_local_buf);
}
else
{
pointer __tmp_ptr = _M_data();
_M_data(__s._M_data());
__s._M_data(__tmp_ptr);
_M_capacity(__s._M_allocated_capacity);
}
__s._M_capacity(__tmp_capacity);
}
const size_type __tmp_length = length();
_M_length(__s.length());
__s._M_length(__tmp_length);
}
template<typename _CharT, typename _Traits, typename _Alloc>
typename basic_string<_CharT, _Traits, _Alloc>::pointer
basic_string<_CharT, _Traits, _Alloc>::
_M_create(size_type& __capacity, size_type __old_capacity)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 83. String::npos vs. string::max_size()
if (__capacity > max_size())
std::__throw_length_error(__N("basic_string::_M_create"));
// The below implements an exponential growth policy, necessary to
// meet amortized linear time requirements of the library: see
// http://gcc.gnu.org/ml/libstdc++/2001-07/msg00085.html.
if (__capacity > __old_capacity && __capacity < 2 * __old_capacity)
{
__capacity = 2 * __old_capacity;
// Never allocate a string bigger than max_size.
if (__capacity > max_size())
__capacity = max_size();
}
// NB: Need an array of char_type[__capacity], plus a terminating
// null char_type() element.
return _Alloc_traits::allocate(_M_get_allocator(), __capacity + 1);
}
// NB: This is the special case for Input Iterators, used in
// istreambuf_iterators, etc.
// Input Iterators have a cost structure very different from
// pointers, calling for a different coding style.
template<typename _CharT, typename _Traits, typename _Alloc>
template<typename _InIterator>
void
basic_string<_CharT, _Traits, _Alloc>::
_M_construct(_InIterator __beg, _InIterator __end,
std::input_iterator_tag)
{
size_type __len = 0;
size_type __capacity = size_type(_S_local_capacity);
while (__beg != __end && __len < __capacity)
{
_M_data()[__len++] = *__beg;
++__beg;
}
__try
{
while (__beg != __end)
{
if (__len == __capacity)
{
// Allocate more space.
__capacity = __len + 1;
pointer __another = _M_create(__capacity, __len);
this->_S_copy(__another, _M_data(), __len);
_M_dispose();
_M_data(__another);
_M_capacity(__capacity);
}
_M_data()[__len++] = *__beg;
++__beg;
}
}
__catch(...)
{
_M_dispose();
__throw_exception_again;
}
_M_set_length(__len);
}
template<typename _CharT, typename _Traits, typename _Alloc>
template<typename _InIterator>
void
basic_string<_CharT, _Traits, _Alloc>::
_M_construct(_InIterator __beg, _InIterator __end,
std::forward_iterator_tag)
{
// NB: Not required, but considered best practice.
if (__gnu_cxx::__is_null_pointer(__beg) && __beg != __end)
std::__throw_logic_error(__N("basic_string::"
"_M_construct null not valid"));
size_type __dnew = static_cast<size_type>(std::distance(__beg, __end));
if (__dnew > size_type(_S_local_capacity))
{
_M_data(_M_create(__dnew, size_type(0)));
_M_capacity(__dnew);
}
// Check for out_of_range and length_error exceptions.
__try
{ this->_S_copy_chars(_M_data(), __beg, __end); }
__catch(...)
{
_M_dispose();
__throw_exception_again;
}
_M_set_length(__dnew);
}
template<typename _CharT, typename _Traits, typename _Alloc>
void
basic_string<_CharT, _Traits, _Alloc>::
_M_construct(size_type __n, _CharT __c)
{
if (__n > size_type(_S_local_capacity))
{
_M_data(_M_create(__n, size_type(0)));
_M_capacity(__n);
}
if (__n)
this->_S_assign(_M_data(), __n, __c);
_M_set_length(__n);
}
template<typename _CharT, typename _Traits, typename _Alloc>
void
basic_string<_CharT, _Traits, _Alloc>::
_M_assign(const basic_string& __str)
{
if (this != &__str)
{
const size_type __rsize = __str.length();
const size_type __capacity = capacity();
if (__rsize > __capacity)
{
size_type __new_capacity = __rsize;
pointer __tmp = _M_create(__new_capacity, __capacity);
_M_dispose();
_M_data(__tmp);
_M_capacity(__new_capacity);
}
if (__rsize)
this->_S_copy(_M_data(), __str._M_data(), __rsize);
_M_set_length(__rsize);
}
}
template<typename _CharT, typename _Traits, typename _Alloc>
void
basic_string<_CharT, _Traits, _Alloc>::
reserve(size_type __res)
{
// Make sure we don't shrink below the current size.
if (__res < length())
__res = length();
const size_type __capacity = capacity();
if (__res != __capacity)
{
if (__res > __capacity
|| __res > size_type(_S_local_capacity))
{
pointer __tmp = _M_create(__res, __capacity);
this->_S_copy(__tmp, _M_data(), length() + 1);
_M_dispose();
_M_data(__tmp);
_M_capacity(__res);
}
else if (!_M_is_local())
{
this->_S_copy(_M_local_data(), _M_data(), length() + 1);
_M_destroy(__capacity);
_M_data(_M_local_data());
}
}
}
template<typename _CharT, typename _Traits, typename _Alloc>
void
basic_string<_CharT, _Traits, _Alloc>::
_M_mutate(size_type __pos, size_type __len1, const _CharT* __s,
size_type __len2)
{
const size_type __how_much = length() - __pos - __len1;
size_type __new_capacity = length() + __len2 - __len1;
pointer __r = _M_create(__new_capacity, capacity());
if (__pos)
this->_S_copy(__r, _M_data(), __pos);
if (__s && __len2)
this->_S_copy(__r + __pos, __s, __len2);
if (__how_much)
this->_S_copy(__r + __pos + __len2,
_M_data() + __pos + __len1, __how_much);
_M_dispose();
_M_data(__r);
_M_capacity(__new_capacity);
}
template<typename _CharT, typename _Traits, typename _Alloc>
void
basic_string<_CharT, _Traits, _Alloc>::
_M_erase(size_type __pos, size_type __n)
{
const size_type __how_much = length() - __pos - __n;
if (__how_much && __n)
this->_S_move(_M_data() + __pos, _M_data() + __pos + __n, __how_much);
_M_set_length(length() - __n);
}
template<typename _CharT, typename _Traits, typename _Alloc>
void
basic_string<_CharT, _Traits, _Alloc>::
resize(size_type __n, _CharT __c)
{
const size_type __size = this->size();
if (__size < __n)
this->append(__n - __size, __c);
else if (__n < __size)
this->_M_set_length(__n);
}
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>&
basic_string<_CharT, _Traits, _Alloc>::
_M_append(const _CharT* __s, size_type __n)
{
const size_type __len = __n + this->size();
if (__len <= this->capacity())
{
if (__n)
this->_S_copy(this->_M_data() + this->size(), __s, __n);
}
else
this->_M_mutate(this->size(), size_type(0), __s, __n);
this->_M_set_length(__len);
return *this;
}
template<typename _CharT, typename _Traits, typename _Alloc>
template<typename _InputIterator>
basic_string<_CharT, _Traits, _Alloc>&
basic_string<_CharT, _Traits, _Alloc>::
_M_replace_dispatch(const_iterator __i1, const_iterator __i2,
_InputIterator __k1, _InputIterator __k2,
std::__false_type)
{
const basic_string __s(__k1, __k2);
const size_type __n1 = __i2 - __i1;
return _M_replace(__i1 - begin(), __n1, __s._M_data(),
__s.size());
}
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>&
basic_string<_CharT, _Traits, _Alloc>::
_M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
_CharT __c)
{
_M_check_length(__n1, __n2, "basic_string::_M_replace_aux");
const size_type __old_size = this->size();
const size_type __new_size = __old_size + __n2 - __n1;
if (__new_size <= this->capacity())
{
pointer __p = this->_M_data() + __pos1;
const size_type __how_much = __old_size - __pos1 - __n1;
if (__how_much && __n1 != __n2)
this->_S_move(__p + __n2, __p + __n1, __how_much);
}
else
this->_M_mutate(__pos1, __n1, 0, __n2);
if (__n2)
this->_S_assign(this->_M_data() + __pos1, __n2, __c);
this->_M_set_length(__new_size);
return *this;
}
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>&
basic_string<_CharT, _Traits, _Alloc>::
_M_replace(size_type __pos, size_type __len1, const _CharT* __s,
const size_type __len2)
{
_M_check_length(__len1, __len2, "basic_string::_M_replace");
const size_type __old_size = this->size();
const size_type __new_size = __old_size + __len2 - __len1;
if (__new_size <= this->capacity())
{
pointer __p = this->_M_data() + __pos;
const size_type __how_much = __old_size - __pos - __len1;
if (_M_disjunct(__s))
{
if (__how_much && __len1 != __len2)
this->_S_move(__p + __len2, __p + __len1, __how_much);
if (__len2)
this->_S_copy(__p, __s, __len2);
}
else
{
// Work in-place.
if (__len2 && __len2 <= __len1)
this->_S_move(__p, __s, __len2);
if (__how_much && __len1 != __len2)
this->_S_move(__p + __len2, __p + __len1, __how_much);
if (__len2 > __len1)
{
if (__s + __len2 <= __p + __len1)
this->_S_move(__p, __s, __len2);
else if (__s >= __p + __len1)
this->_S_copy(__p, __s + __len2 - __len1, __len2);
else
{
const size_type __nleft = (__p + __len1) - __s;
this->_S_move(__p, __s, __nleft);
this->_S_copy(__p + __nleft, __p + __len2,
__len2 - __nleft);
}
}
}
}
else
this->_M_mutate(__pos, __len1, __s, __len2);
this->_M_set_length(__new_size);
return *this;
}
template<typename _CharT, typename _Traits, typename _Alloc>
typename basic_string<_CharT, _Traits, _Alloc>::size_type
basic_string<_CharT, _Traits, _Alloc>::
copy(_CharT* __s, size_type __n, size_type __pos) const
{
_M_check(__pos, "basic_string::copy");
__n = _M_limit(__pos, __n);
__glibcxx_requires_string_len(__s, __n);
if (__n)
_S_copy(__s, _M_data() + __pos, __n);
// 21.3.5.7 par 3: do not append null. (good.)
return __n;
}
#else // !_GLIBCXX_USE_CXX11_ABI
template<typename _CharT, typename _Traits, typename _Alloc>
const typename basic_string<_CharT, _Traits, _Alloc>::size_type
basic_string<_CharT, _Traits, _Alloc>::
_Rep::_S_max_size = (((npos - sizeof(_Rep_base))/sizeof(_CharT)) - 1) / 4;
template<typename _CharT, typename _Traits, typename _Alloc>
const _CharT
basic_string<_CharT, _Traits, _Alloc>::
_Rep::_S_terminal = _CharT();
template<typename _CharT, typename _Traits, typename _Alloc>
const typename basic_string<_CharT, _Traits, _Alloc>::size_type
basic_string<_CharT, _Traits, _Alloc>::npos;
// Linker sets _S_empty_rep_storage to all 0s (one reference, empty string)
// at static init time (before static ctors are run).
template<typename _CharT, typename _Traits, typename _Alloc>
typename basic_string<_CharT, _Traits, _Alloc>::size_type
basic_string<_CharT, _Traits, _Alloc>::_Rep::_S_empty_rep_storage[
(sizeof(_Rep_base) + sizeof(_CharT) + sizeof(size_type) - 1) /
sizeof(size_type)];
// NB: This is the special case for Input Iterators, used in
// istreambuf_iterators, etc.
// Input Iterators have a cost structure very different from
// pointers, calling for a different coding style.
template<typename _CharT, typename _Traits, typename _Alloc>
template<typename _InIterator>
_CharT*
basic_string<_CharT, _Traits, _Alloc>::
_S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a,
input_iterator_tag)
{
#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
if (__beg == __end && __a == _Alloc())
return _S_empty_rep()._M_refdata();
#endif
// Avoid reallocation for common case.
_CharT __buf[128];
size_type __len = 0;
while (__beg != __end && __len < sizeof(__buf) / sizeof(_CharT))
{
__buf[__len++] = *__beg;
++__beg;
}
_Rep* __r = _Rep::_S_create(__len, size_type(0), __a);
_M_copy(__r->_M_refdata(), __buf, __len);
__try
{
while (__beg != __end)
{
if (__len == __r->_M_capacity)
{
// Allocate more space.
_Rep* __another = _Rep::_S_create(__len + 1, __len, __a);
_M_copy(__another->_M_refdata(), __r->_M_refdata(), __len);
__r->_M_destroy(__a);
__r = __another;
}
__r->_M_refdata()[__len++] = *__beg;
++__beg;
}
}
__catch(...)
{
__r->_M_destroy(__a);
__throw_exception_again;
}
__r->_M_set_length_and_sharable(__len);
return __r->_M_refdata();
}
template<typename _CharT, typename _Traits, typename _Alloc>
template <typename _InIterator>
_CharT*
basic_string<_CharT, _Traits, _Alloc>::
_S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a,
forward_iterator_tag)
{
#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
if (__beg == __end && __a == _Alloc())
return _S_empty_rep()._M_refdata();
#endif
// NB: Not required, but considered best practice.
if (__gnu_cxx::__is_null_pointer(__beg) && __beg != __end)
__throw_logic_error(__N("basic_string::_S_construct null not valid"));
const size_type __dnew = static_cast<size_type>(std::distance(__beg,
__end));
// Check for out_of_range and length_error exceptions.
_Rep* __r = _Rep::_S_create(__dnew, size_type(0), __a);
__try
{ _S_copy_chars(__r->_M_refdata(), __beg, __end); }
__catch(...)
{
__r->_M_destroy(__a);
__throw_exception_again;
}
__r->_M_set_length_and_sharable(__dnew);
return __r->_M_refdata();
}
template<typename _CharT, typename _Traits, typename _Alloc>
_CharT*
basic_string<_CharT, _Traits, _Alloc>::
_S_construct(size_type __n, _CharT __c, const _Alloc& __a)
{
#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
if (__n == 0 && __a == _Alloc())
return _S_empty_rep()._M_refdata();
#endif
// Check for out_of_range and length_error exceptions.
_Rep* __r = _Rep::_S_create(__n, size_type(0), __a);
if (__n)
_M_assign(__r->_M_refdata(), __n, __c);
__r->_M_set_length_and_sharable(__n);
return __r->_M_refdata();
}
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>::
basic_string(const basic_string& __str)
: _M_dataplus(__str._M_rep()->_M_grab(_Alloc(__str.get_allocator()),
__str.get_allocator()),
__str.get_allocator())
{ }
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>::
basic_string(const _Alloc& __a)
: _M_dataplus(_S_construct(size_type(), _CharT(), __a), __a)
{ }
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>::
basic_string(const basic_string& __str, size_type __pos, const _Alloc& __a)
: _M_dataplus(_S_construct(__str._M_data()
+ __str._M_check(__pos,
"basic_string::basic_string"),
__str._M_data() + __str._M_limit(__pos, npos)
+ __pos, __a), __a)
{ }
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>::
basic_string(const basic_string& __str, size_type __pos, size_type __n)
: _M_dataplus(_S_construct(__str._M_data()
+ __str._M_check(__pos,
"basic_string::basic_string"),
__str._M_data() + __str._M_limit(__pos, __n)
+ __pos, _Alloc()), _Alloc())
{ }
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>::
basic_string(const basic_string& __str, size_type __pos,
size_type __n, const _Alloc& __a)
: _M_dataplus(_S_construct(__str._M_data()
+ __str._M_check(__pos,
"basic_string::basic_string"),
__str._M_data() + __str._M_limit(__pos, __n)
+ __pos, __a), __a)
{ }
// TBD: DPG annotate
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>::
basic_string(const _CharT* __s, size_type __n, const _Alloc& __a)
: _M_dataplus(_S_construct(__s, __s + __n, __a), __a)
{ }
// TBD: DPG annotate
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>::
basic_string(const _CharT* __s, const _Alloc& __a)
: _M_dataplus(_S_construct(__s, __s ? __s + traits_type::length(__s) :
__s + npos, __a), __a)
{ }
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>::
basic_string(size_type __n, _CharT __c, const _Alloc& __a)
: _M_dataplus(_S_construct(__n, __c, __a), __a)
{ }
// TBD: DPG annotate
template<typename _CharT, typename _Traits, typename _Alloc>
template<typename _InputIterator>
basic_string<_CharT, _Traits, _Alloc>::
basic_string(_InputIterator __beg, _InputIterator __end, const _Alloc& __a)
: _M_dataplus(_S_construct(__beg, __end, __a), __a)
{ }
#if __cplusplus >= 201103L
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>::
basic_string(initializer_list<_CharT> __l, const _Alloc& __a)
: _M_dataplus(_S_construct(__l.begin(), __l.end(), __a), __a)
{ }
#endif
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>&
basic_string<_CharT, _Traits, _Alloc>::
assign(const basic_string& __str)
{
if (_M_rep() != __str._M_rep())
{
// XXX MT
const allocator_type __a = this->get_allocator();
_CharT* __tmp = __str._M_rep()->_M_grab(__a, __str.get_allocator());
_M_rep()->_M_dispose(__a);
_M_data(__tmp);
}
return *this;
}
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>&
basic_string<_CharT, _Traits, _Alloc>::
assign(const _CharT* __s, size_type __n)
{
__glibcxx_requires_string_len(__s, __n);
_M_check_length(this->size(), __n, "basic_string::assign");
if (_M_disjunct(__s) || _M_rep()->_M_is_shared())
return _M_replace_safe(size_type(0), this->size(), __s, __n);
else
{
// Work in-place.
const size_type __pos = __s - _M_data();
if (__pos >= __n)
_M_copy(_M_data(), __s, __n);
else if (__pos)
_M_move(_M_data(), __s, __n);
_M_rep()->_M_set_length_and_sharable(__n);
return *this;
}
}
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>&
basic_string<_CharT, _Traits, _Alloc>::
append(size_type __n, _CharT __c)
{
if (__n)
{
_M_check_length(size_type(0), __n, "basic_string::append");
const size_type __len = __n + this->size();
if (__len > this->capacity() || _M_rep()->_M_is_shared())
this->reserve(__len);
_M_assign(_M_data() + this->size(), __n, __c);
_M_rep()->_M_set_length_and_sharable(__len);
}
return *this;
}
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>&
basic_string<_CharT, _Traits, _Alloc>::
append(const _CharT* __s, size_type __n)
{
__glibcxx_requires_string_len(__s, __n);
if (__n)
{
_M_check_length(size_type(0), __n, "basic_string::append");
const size_type __len = __n + this->size();
if (__len > this->capacity() || _M_rep()->_M_is_shared())
{
if (_M_disjunct(__s))
this->reserve(__len);
else
{
const size_type __off = __s - _M_data();
this->reserve(__len);
__s = _M_data() + __off;
}
}
_M_copy(_M_data() + this->size(), __s, __n);
_M_rep()->_M_set_length_and_sharable(__len);
}
return *this;
}
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>&
basic_string<_CharT, _Traits, _Alloc>::
append(const basic_string& __str)
{
const size_type __size = __str.size();
if (__size)
{
const size_type __len = __size + this->size();
if (__len > this->capacity() || _M_rep()->_M_is_shared())
this->reserve(__len);
_M_copy(_M_data() + this->size(), __str._M_data(), __size);
_M_rep()->_M_set_length_and_sharable(__len);
}
return *this;
}
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>&
basic_string<_CharT, _Traits, _Alloc>::
append(const basic_string& __str, size_type __pos, size_type __n)
{
__str._M_check(__pos, "basic_string::append");
__n = __str._M_limit(__pos, __n);
if (__n)
{
const size_type __len = __n + this->size();
if (__len > this->capacity() || _M_rep()->_M_is_shared())
this->reserve(__len);
_M_copy(_M_data() + this->size(), __str._M_data() + __pos, __n);
_M_rep()->_M_set_length_and_sharable(__len);
}
return *this;
}
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>&
basic_string<_CharT, _Traits, _Alloc>::
insert(size_type __pos, const _CharT* __s, size_type __n)
{
__glibcxx_requires_string_len(__s, __n);
_M_check(__pos, "basic_string::insert");
_M_check_length(size_type(0), __n, "basic_string::insert");
if (_M_disjunct(__s) || _M_rep()->_M_is_shared())
return _M_replace_safe(__pos, size_type(0), __s, __n);
else
{
// Work in-place.
const size_type __off = __s - _M_data();
_M_mutate(__pos, 0, __n);
__s = _M_data() + __off;
_CharT* __p = _M_data() + __pos;
if (__s + __n <= __p)
_M_copy(__p, __s, __n);
else if (__s >= __p)
_M_copy(__p, __s + __n, __n);
else
{
const size_type __nleft = __p - __s;
_M_copy(__p, __s, __nleft);
_M_copy(__p + __nleft, __p + __n, __n - __nleft);
}
return *this;
}
}
template<typename _CharT, typename _Traits, typename _Alloc>
typename basic_string<_CharT, _Traits, _Alloc>::iterator
basic_string<_CharT, _Traits, _Alloc>::
erase(iterator __first, iterator __last)
{
_GLIBCXX_DEBUG_PEDASSERT(__first >= _M_ibegin() && __first <= __last
&& __last <= _M_iend());
// NB: This isn't just an optimization (bail out early when
// there is nothing to do, really), it's also a correctness
// issue vs MT, see libstdc++/40518.
const size_type __size = __last - __first;
if (__size)
{
const size_type __pos = __first - _M_ibegin();
_M_mutate(__pos, __size, size_type(0));
_M_rep()->_M_set_leaked();
return iterator(_M_data() + __pos);
}
else
return __first;
}
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>&
basic_string<_CharT, _Traits, _Alloc>::
replace(size_type __pos, size_type __n1, const _CharT* __s,
size_type __n2)
{
__glibcxx_requires_string_len(__s, __n2);
_M_check(__pos, "basic_string::replace");
__n1 = _M_limit(__pos, __n1);
_M_check_length(__n1, __n2, "basic_string::replace");
bool __left;
if (_M_disjunct(__s) || _M_rep()->_M_is_shared())
return _M_replace_safe(__pos, __n1, __s, __n2);
else if ((__left = __s + __n2 <= _M_data() + __pos)
|| _M_data() + __pos + __n1 <= __s)
{
// Work in-place: non-overlapping case.
size_type __off = __s - _M_data();
__left ? __off : (__off += __n2 - __n1);
_M_mutate(__pos, __n1, __n2);
_M_copy(_M_data() + __pos, _M_data() + __off, __n2);
return *this;
}
else
{
// Todo: overlapping case.
const basic_string __tmp(__s, __n2);
return _M_replace_safe(__pos, __n1, __tmp._M_data(), __n2);
}
}
template<typename _CharT, typename _Traits, typename _Alloc>
void
basic_string<_CharT, _Traits, _Alloc>::_Rep::
_M_destroy(const _Alloc& __a) throw ()
{
const size_type __size = sizeof(_Rep_base) +
(this->_M_capacity + 1) * sizeof(_CharT);
_Raw_bytes_alloc(__a).deallocate(reinterpret_cast<char*>(this), __size);
}
template<typename _CharT, typename _Traits, typename _Alloc>
void
basic_string<_CharT, _Traits, _Alloc>::
_M_leak_hard()
{
#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
if (_M_rep() == &_S_empty_rep())
return;
#endif
if (_M_rep()->_M_is_shared())
_M_mutate(0, 0, 0);
_M_rep()->_M_set_leaked();
}
template<typename _CharT, typename _Traits, typename _Alloc>
void
basic_string<_CharT, _Traits, _Alloc>::
_M_mutate(size_type __pos, size_type __len1, size_type __len2)
{
const size_type __old_size = this->size();
const size_type __new_size = __old_size + __len2 - __len1;
const size_type __how_much = __old_size - __pos - __len1;
if (__new_size > this->capacity() || _M_rep()->_M_is_shared())
{
// Must reallocate.
const allocator_type __a = get_allocator();
_Rep* __r = _Rep::_S_create(__new_size, this->capacity(), __a);
if (__pos)
_M_copy(__r->_M_refdata(), _M_data(), __pos);
if (__how_much)
_M_copy(__r->_M_refdata() + __pos + __len2,
_M_data() + __pos + __len1, __how_much);
_M_rep()->_M_dispose(__a);
_M_data(__r->_M_refdata());
}
else if (__how_much && __len1 != __len2)
{
// Work in-place.
_M_move(_M_data() + __pos + __len2,
_M_data() + __pos + __len1, __how_much);
}
_M_rep()->_M_set_length_and_sharable(__new_size);
}
template<typename _CharT, typename _Traits, typename _Alloc>
void
basic_string<_CharT, _Traits, _Alloc>::
reserve(size_type __res)
{
if (__res != this->capacity() || _M_rep()->_M_is_shared())
{
// Make sure we don't shrink below the current size
if (__res < this->size())
__res = this->size();
const allocator_type __a = get_allocator();
_CharT* __tmp = _M_rep()->_M_clone(__a, __res - this->size());
_M_rep()->_M_dispose(__a);
_M_data(__tmp);
}
}
template<typename _CharT, typename _Traits, typename _Alloc>
void
basic_string<_CharT, _Traits, _Alloc>::
swap(basic_string& __s)
{
if (_M_rep()->_M_is_leaked())
_M_rep()->_M_set_sharable();
if (__s._M_rep()->_M_is_leaked())
__s._M_rep()->_M_set_sharable();
if (this->get_allocator() == __s.get_allocator())
{
_CharT* __tmp = _M_data();
_M_data(__s._M_data());
__s._M_data(__tmp);
}
// The code below can usually be optimized away.
else
{
const basic_string __tmp1(_M_ibegin(), _M_iend(),
__s.get_allocator());
const basic_string __tmp2(__s._M_ibegin(), __s._M_iend(),
this->get_allocator());
*this = __tmp2;
__s = __tmp1;
}
}
template<typename _CharT, typename _Traits, typename _Alloc>
typename basic_string<_CharT, _Traits, _Alloc>::_Rep*
basic_string<_CharT, _Traits, _Alloc>::_Rep::
_S_create(size_type __capacity, size_type __old_capacity,
const _Alloc& __alloc)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 83. String::npos vs. string::max_size()
if (__capacity > _S_max_size)
__throw_length_error(__N("basic_string::_S_create"));
// The standard places no restriction on allocating more memory
// than is strictly needed within this layer at the moment or as
// requested by an explicit application call to reserve().
// Many malloc implementations perform quite poorly when an
// application attempts to allocate memory in a stepwise fashion
// growing each allocation size by only 1 char. Additionally,
// it makes little sense to allocate less linear memory than the
// natural blocking size of the malloc implementation.
// Unfortunately, we would need a somewhat low-level calculation
// with tuned parameters to get this perfect for any particular
// malloc implementation. Fortunately, generalizations about
// common features seen among implementations seems to suffice.
// __pagesize need not match the actual VM page size for good
// results in practice, thus we pick a common value on the low
// side. __malloc_header_size is an estimate of the amount of
// overhead per memory allocation (in practice seen N * sizeof
// (void*) where N is 0, 2 or 4). According to folklore,
// picking this value on the high side is better than
// low-balling it (especially when this algorithm is used with
// malloc implementations that allocate memory blocks rounded up
// to a size which is a power of 2).
const size_type __pagesize = 4096;
const size_type __malloc_header_size = 4 * sizeof(void*);
// The below implements an exponential growth policy, necessary to
// meet amortized linear time requirements of the library: see
// http://gcc.gnu.org/ml/libstdc++/2001-07/msg00085.html.
// It's active for allocations requiring an amount of memory above
// system pagesize. This is consistent with the requirements of the
// standard: http://gcc.gnu.org/ml/libstdc++/2001-07/msg00130.html
if (__capacity > __old_capacity && __capacity < 2 * __old_capacity)
__capacity = 2 * __old_capacity;
// NB: Need an array of char_type[__capacity], plus a terminating
// null char_type() element, plus enough for the _Rep data structure.
// Whew. Seemingly so needy, yet so elemental.
size_type __size = (__capacity + 1) * sizeof(_CharT) + sizeof(_Rep);
const size_type __adj_size = __size + __malloc_header_size;
if (__adj_size > __pagesize && __capacity > __old_capacity)
{
const size_type __extra = __pagesize - __adj_size % __pagesize;
__capacity += __extra / sizeof(_CharT);
// Never allocate a string bigger than _S_max_size.
if (__capacity > _S_max_size)
__capacity = _S_max_size;
__size = (__capacity + 1) * sizeof(_CharT) + sizeof(_Rep);
}
// NB: Might throw, but no worries about a leak, mate: _Rep()
// does not throw.
void* __place = _Raw_bytes_alloc(__alloc).allocate(__size);
_Rep *__p = new (__place) _Rep;
__p->_M_capacity = __capacity;
// ABI compatibility - 3.4.x set in _S_create both
// _M_refcount and _M_length. All callers of _S_create
// in basic_string.tcc then set just _M_length.
// In 4.0.x and later both _M_refcount and _M_length
// are initialized in the callers, unfortunately we can
// have 3.4.x compiled code with _S_create callers inlined
// calling 4.0.x+ _S_create.
__p->_M_set_sharable();
return __p;
}
template<typename _CharT, typename _Traits, typename _Alloc>
_CharT*
basic_string<_CharT, _Traits, _Alloc>::_Rep::
_M_clone(const _Alloc& __alloc, size_type __res)
{
// Requested capacity of the clone.
const size_type __requested_cap = this->_M_length + __res;
_Rep* __r = _Rep::_S_create(__requested_cap, this->_M_capacity,
__alloc);
if (this->_M_length)
_M_copy(__r->_M_refdata(), _M_refdata(), this->_M_length);
__r->_M_set_length_and_sharable(this->_M_length);
return __r->_M_refdata();
}
template<typename _CharT, typename _Traits, typename _Alloc>
void
basic_string<_CharT, _Traits, _Alloc>::
resize(size_type __n, _CharT __c)
{
const size_type __size = this->size();
_M_check_length(__size, __n, "basic_string::resize");
if (__size < __n)
this->append(__n - __size, __c);
else if (__n < __size)
this->erase(__n);
// else nothing (in particular, avoid calling _M_mutate() unnecessarily.)
}
template<typename _CharT, typename _Traits, typename _Alloc>
template<typename _InputIterator>
basic_string<_CharT, _Traits, _Alloc>&
basic_string<_CharT, _Traits, _Alloc>::
_M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
_InputIterator __k2, __false_type)
{
const basic_string __s(__k1, __k2);
const size_type __n1 = __i2 - __i1;
_M_check_length(__n1, __s.size(), "basic_string::_M_replace_dispatch");
return _M_replace_safe(__i1 - _M_ibegin(), __n1, __s._M_data(),
__s.size());
}
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>&
basic_string<_CharT, _Traits, _Alloc>::
_M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
_CharT __c)
{
_M_check_length(__n1, __n2, "basic_string::_M_replace_aux");
_M_mutate(__pos1, __n1, __n2);
if (__n2)
_M_assign(_M_data() + __pos1, __n2, __c);
return *this;
}
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>&
basic_string<_CharT, _Traits, _Alloc>::
_M_replace_safe(size_type __pos1, size_type __n1, const _CharT* __s,
size_type __n2)
{
_M_mutate(__pos1, __n1, __n2);
if (__n2)
_M_copy(_M_data() + __pos1, __s, __n2);
return *this;
}
template<typename _CharT, typename _Traits, typename _Alloc>
typename basic_string<_CharT, _Traits, _Alloc>::size_type
basic_string<_CharT, _Traits, _Alloc>::
copy(_CharT* __s, size_type __n, size_type __pos) const
{
_M_check(__pos, "basic_string::copy");
__n = _M_limit(__pos, __n);
__glibcxx_requires_string_len(__s, __n);
if (__n)
_M_copy(__s, _M_data() + __pos, __n);
// 21.3.5.7 par 3: do not append null. (good.)
return __n;
}
#endif // !_GLIBCXX_USE_CXX11_ABI
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>
operator+(const _CharT* __lhs,
const basic_string<_CharT, _Traits, _Alloc>& __rhs)
{
__glibcxx_requires_string(__lhs);
typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
typedef typename __string_type::size_type __size_type;
const __size_type __len = _Traits::length(__lhs);
__string_type __str;
__str.reserve(__len + __rhs.size());
__str.append(__lhs, __len);
__str.append(__rhs);
return __str;
}
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>
operator+(_CharT __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs)
{
typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
typedef typename __string_type::size_type __size_type;
__string_type __str;
const __size_type __len = __rhs.size();
__str.reserve(__len + 1);
__str.append(__size_type(1), __lhs);
__str.append(__rhs);
return __str;
}
template<typename _CharT, typename _Traits, typename _Alloc>
typename basic_string<_CharT, _Traits, _Alloc>::size_type
basic_string<_CharT, _Traits, _Alloc>::
find(const _CharT* __s, size_type __pos, size_type __n) const
_GLIBCXX_NOEXCEPT
{
__glibcxx_requires_string_len(__s, __n);
const size_type __size = this->size();
if (__n == 0)
return __pos <= __size ? __pos : npos;
if (__pos >= __size)
return npos;
const _CharT __elem0 = __s[0];
const _CharT* const __data = data();
const _CharT* __first = __data + __pos;
const _CharT* const __last = __data + __size;
size_type __len = __size - __pos;
while (__len >= __n)
{
// Find the first occurrence of __elem0:
__first = traits_type::find(__first, __len - __n + 1, __elem0);
if (!__first)
return npos;
// Compare the full strings from the first occurrence of __elem0.
// We already know that __first[0] == __s[0] but compare them again
// anyway because __s is probably aligned, which helps memcmp.
if (traits_type::compare(__first, __s, __n) == 0)
return __first - __data;
__len = __last - ++__first;
}
return npos;
}
template<typename _CharT, typename _Traits, typename _Alloc>
typename basic_string<_CharT, _Traits, _Alloc>::size_type
basic_string<_CharT, _Traits, _Alloc>::
find(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT
{
size_type __ret = npos;
const size_type __size = this->size();
if (__pos < __size)
{
const _CharT* __data = _M_data();
const size_type __n = __size - __pos;
const _CharT* __p = traits_type::find(__data + __pos, __n, __c);
if (__p)
__ret = __p - __data;
}
return __ret;
}
template<typename _CharT, typename _Traits, typename _Alloc>
typename basic_string<_CharT, _Traits, _Alloc>::size_type
basic_string<_CharT, _Traits, _Alloc>::
rfind(const _CharT* __s, size_type __pos, size_type __n) const
_GLIBCXX_NOEXCEPT
{
__glibcxx_requires_string_len(__s, __n);
const size_type __size = this->size();
if (__n <= __size)
{
__pos = std::min(size_type(__size - __n), __pos);
const _CharT* __data = _M_data();
do
{
if (traits_type::compare(__data + __pos, __s, __n) == 0)
return __pos;
}
while (__pos-- > 0);
}
return npos;
}
template<typename _CharT, typename _Traits, typename _Alloc>
typename basic_string<_CharT, _Traits, _Alloc>::size_type
basic_string<_CharT, _Traits, _Alloc>::
rfind(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT
{
size_type __size = this->size();
if (__size)
{
if (--__size > __pos)
__size = __pos;
for (++__size; __size-- > 0; )
if (traits_type::eq(_M_data()[__size], __c))
return __size;
}
return npos;
}
template<typename _CharT, typename _Traits, typename _Alloc>
typename basic_string<_CharT, _Traits, _Alloc>::size_type
basic_string<_CharT, _Traits, _Alloc>::
find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
_GLIBCXX_NOEXCEPT
{
__glibcxx_requires_string_len(__s, __n);
for (; __n && __pos < this->size(); ++__pos)
{
const _CharT* __p = traits_type::find(__s, __n, _M_data()[__pos]);
if (__p)
return __pos;
}
return npos;
}
template<typename _CharT, typename _Traits, typename _Alloc>
typename basic_string<_CharT, _Traits, _Alloc>::size_type
basic_string<_CharT, _Traits, _Alloc>::
find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
_GLIBCXX_NOEXCEPT
{
__glibcxx_requires_string_len(__s, __n);
size_type __size = this->size();
if (__size && __n)
{
if (--__size > __pos)
__size = __pos;
do
{
if (traits_type::find(__s, __n, _M_data()[__size]))
return __size;
}
while (__size-- != 0);
}
return npos;
}
template<typename _CharT, typename _Traits, typename _Alloc>
typename basic_string<_CharT, _Traits, _Alloc>::size_type
basic_string<_CharT, _Traits, _Alloc>::
find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
_GLIBCXX_NOEXCEPT
{
__glibcxx_requires_string_len(__s, __n);
for (; __pos < this->size(); ++__pos)
if (!traits_type::find(__s, __n, _M_data()[__pos]))
return __pos;
return npos;
}
template<typename _CharT, typename _Traits, typename _Alloc>
typename basic_string<_CharT, _Traits, _Alloc>::size_type
basic_string<_CharT, _Traits, _Alloc>::
find_first_not_of(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT
{
for (; __pos < this->size(); ++__pos)
if (!traits_type::eq(_M_data()[__pos], __c))
return __pos;
return npos;
}
template<typename _CharT, typename _Traits, typename _Alloc>
typename basic_string<_CharT, _Traits, _Alloc>::size_type
basic_string<_CharT, _Traits, _Alloc>::
find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
_GLIBCXX_NOEXCEPT
{
__glibcxx_requires_string_len(__s, __n);
size_type __size = this->size();
if (__size)
{
if (--__size > __pos)
__size = __pos;
do
{
if (!traits_type::find(__s, __n, _M_data()[__size]))
return __size;
}
while (__size--);
}
return npos;
}
template<typename _CharT, typename _Traits, typename _Alloc>
typename basic_string<_CharT, _Traits, _Alloc>::size_type
basic_string<_CharT, _Traits, _Alloc>::
find_last_not_of(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT
{
size_type __size = this->size();
if (__size)
{
if (--__size > __pos)
__size = __pos;
do
{
if (!traits_type::eq(_M_data()[__size], __c))
return __size;
}
while (__size--);
}
return npos;
}
template<typename _CharT, typename _Traits, typename _Alloc>
int
basic_string<_CharT, _Traits, _Alloc>::
compare(size_type __pos, size_type __n, const basic_string& __str) const
{
_M_check(__pos, "basic_string::compare");
__n = _M_limit(__pos, __n);
const size_type __osize = __str.size();
const size_type __len = std::min(__n, __osize);
int __r = traits_type::compare(_M_data() + __pos, __str.data(), __len);
if (!__r)
__r = _S_compare(__n, __osize);
return __r;
}
template<typename _CharT, typename _Traits, typename _Alloc>
int
basic_string<_CharT, _Traits, _Alloc>::
compare(size_type __pos1, size_type __n1, const basic_string& __str,
size_type __pos2, size_type __n2) const
{
_M_check(__pos1, "basic_string::compare");
__str._M_check(__pos2, "basic_string::compare");
__n1 = _M_limit(__pos1, __n1);
__n2 = __str._M_limit(__pos2, __n2);
const size_type __len = std::min(__n1, __n2);
int __r = traits_type::compare(_M_data() + __pos1,
__str.data() + __pos2, __len);
if (!__r)
__r = _S_compare(__n1, __n2);
return __r;
}
template<typename _CharT, typename _Traits, typename _Alloc>
int
basic_string<_CharT, _Traits, _Alloc>::
compare(const _CharT* __s) const _GLIBCXX_NOEXCEPT
{
__glibcxx_requires_string(__s);
const size_type __size = this->size();
const size_type __osize = traits_type::length(__s);
const size_type __len = std::min(__size, __osize);
int __r = traits_type::compare(_M_data(), __s, __len);
if (!__r)
__r = _S_compare(__size, __osize);
return __r;
}
template<typename _CharT, typename _Traits, typename _Alloc>
int
basic_string <_CharT, _Traits, _Alloc>::
compare(size_type __pos, size_type __n1, const _CharT* __s) const
{
__glibcxx_requires_string(__s);
_M_check(__pos, "basic_string::compare");
__n1 = _M_limit(__pos, __n1);
const size_type __osize = traits_type::length(__s);
const size_type __len = std::min(__n1, __osize);
int __r = traits_type::compare(_M_data() + __pos, __s, __len);
if (!__r)
__r = _S_compare(__n1, __osize);
return __r;
}
template<typename _CharT, typename _Traits, typename _Alloc>
int
basic_string <_CharT, _Traits, _Alloc>::
compare(size_type __pos, size_type __n1, const _CharT* __s,
size_type __n2) const
{
__glibcxx_requires_string_len(__s, __n2);
_M_check(__pos, "basic_string::compare");
__n1 = _M_limit(__pos, __n1);
const size_type __len = std::min(__n1, __n2);
int __r = traits_type::compare(_M_data() + __pos, __s, __len);
if (!__r)
__r = _S_compare(__n1, __n2);
return __r;
}
// 21.3.7.9 basic_string::getline and operators
template<typename _CharT, typename _Traits, typename _Alloc>
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __in,
basic_string<_CharT, _Traits, _Alloc>& __str)
{
typedef basic_istream<_CharT, _Traits> __istream_type;
typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
typedef typename __istream_type::ios_base __ios_base;
typedef typename __istream_type::int_type __int_type;
typedef typename __string_type::size_type __size_type;
typedef ctype<_CharT> __ctype_type;
typedef typename __ctype_type::ctype_base __ctype_base;
__size_type __extracted = 0;
typename __ios_base::iostate __err = __ios_base::goodbit;
typename __istream_type::sentry __cerb(__in, false);
if (__cerb)
{
__try
{
// Avoid reallocation for common case.
__str.erase();
_CharT __buf[128];
__size_type __len = 0;
const streamsize __w = __in.width();
const __size_type __n = __w > 0 ? static_cast<__size_type>(__w)
: __str.max_size();
const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc());
const __int_type __eof = _Traits::eof();
__int_type __c = __in.rdbuf()->sgetc();
while (__extracted < __n
&& !_Traits::eq_int_type(__c, __eof)
&& !__ct.is(__ctype_base::space,
_Traits::to_char_type(__c)))
{
if (__len == sizeof(__buf) / sizeof(_CharT))
{
__str.append(__buf, sizeof(__buf) / sizeof(_CharT));
__len = 0;
}
__buf[__len++] = _Traits::to_char_type(__c);
++__extracted;
__c = __in.rdbuf()->snextc();
}
__str.append(__buf, __len);
if (_Traits::eq_int_type(__c, __eof))
__err |= __ios_base::eofbit;
__in.width(0);
}
__catch(__cxxabiv1::__forced_unwind&)
{
__in._M_setstate(__ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 91. Description of operator>> and getline() for string<>
// might cause endless loop
__in._M_setstate(__ios_base::badbit);
}
}
// 211. operator>>(istream&, string&) doesn't set failbit
if (!__extracted)
__err |= __ios_base::failbit;
if (__err)
__in.setstate(__err);
return __in;
}
template<typename _CharT, typename _Traits, typename _Alloc>
basic_istream<_CharT, _Traits>&
getline(basic_istream<_CharT, _Traits>& __in,
basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim)
{
typedef basic_istream<_CharT, _Traits> __istream_type;
typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
typedef typename __istream_type::ios_base __ios_base;
typedef typename __istream_type::int_type __int_type;
typedef typename __string_type::size_type __size_type;
__size_type __extracted = 0;
const __size_type __n = __str.max_size();
typename __ios_base::iostate __err = __ios_base::goodbit;
typename __istream_type::sentry __cerb(__in, true);
if (__cerb)
{
__try
{
__str.erase();
const __int_type __idelim = _Traits::to_int_type(__delim);
const __int_type __eof = _Traits::eof();
__int_type __c = __in.rdbuf()->sgetc();
while (__extracted < __n
&& !_Traits::eq_int_type(__c, __eof)
&& !_Traits::eq_int_type(__c, __idelim))
{
__str += _Traits::to_char_type(__c);
++__extracted;
__c = __in.rdbuf()->snextc();
}
if (_Traits::eq_int_type(__c, __eof))
__err |= __ios_base::eofbit;
else if (_Traits::eq_int_type(__c, __idelim))
{
++__extracted;
__in.rdbuf()->sbumpc();
}
else
__err |= __ios_base::failbit;
}
__catch(__cxxabiv1::__forced_unwind&)
{
__in._M_setstate(__ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 91. Description of operator>> and getline() for string<>
// might cause endless loop
__in._M_setstate(__ios_base::badbit);
}
}
if (!__extracted)
__err |= __ios_base::failbit;
if (__err)
__in.setstate(__err);
return __in;
}
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
#if _GLIBCXX_EXTERN_TEMPLATE
// The explicit instantiations definitions in src/c++11/string-inst.cc
// are compiled as C++14, so the new C++17 members aren't instantiated.
// Until those definitions are compiled as C++17 suppress the declaration,
// so C++17 code will implicitly instantiate std::string and std::wstring
// as needed.
# if __cplusplus <= 201402L && _GLIBCXX_EXTERN_TEMPLATE > 0
extern template class basic_string<char>;
# elif ! _GLIBCXX_USE_CXX11_ABI
// Still need to prevent implicit instantiation of the COW empty rep,
// to ensure the definition in libstdc++.so is unique (PR 86138).
extern template basic_string<char>::size_type
basic_string<char>::_Rep::_S_empty_rep_storage[];
# endif
extern template
basic_istream<char>&
operator>>(basic_istream<char>&, string&);
extern template
basic_ostream<char>&
operator<<(basic_ostream<char>&, const string&);
extern template
basic_istream<char>&
getline(basic_istream<char>&, string&, char);
extern template
basic_istream<char>&
getline(basic_istream<char>&, string&);
#ifdef _GLIBCXX_USE_WCHAR_T
# if __cplusplus <= 201402L && _GLIBCXX_EXTERN_TEMPLATE > 0
extern template class basic_string<wchar_t>;
# elif ! _GLIBCXX_USE_CXX11_ABI
extern template basic_string<wchar_t>::size_type
basic_string<wchar_t>::_Rep::_S_empty_rep_storage[];
# endif
extern template
basic_istream<wchar_t>&
operator>>(basic_istream<wchar_t>&, wstring&);
extern template
basic_ostream<wchar_t>&
operator<<(basic_ostream<wchar_t>&, const wstring&);
extern template
basic_istream<wchar_t>&
getline(basic_istream<wchar_t>&, wstring&, wchar_t);
extern template
basic_istream<wchar_t>&
getline(basic_istream<wchar_t>&, wstring&);
#endif // _GLIBCXX_USE_WCHAR_T
#endif // _GLIBCXX_EXTERN_TEMPLATE
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif
c++/8/bits/string_view.tcc 0000644 00000015052 15201526705 0011265 0 ustar 00 // Components for manipulating non-owning sequences of characters -*- C++ -*-
// Copyright (C) 2013-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/bits/string_view.tcc
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{string_view}
*/
//
// N3762 basic_string_view library
//
#ifndef _GLIBCXX_STRING_VIEW_TCC
#define _GLIBCXX_STRING_VIEW_TCC 1
#pragma GCC system_header
#if __cplusplus >= 201703L
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _CharT, typename _Traits>
constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find(const _CharT* __str, size_type __pos, size_type __n) const noexcept
{
__glibcxx_requires_string_len(__str, __n);
if (__n == 0)
return __pos <= this->_M_len ? __pos : npos;
if (__n <= this->_M_len)
{
for (; __pos <= this->_M_len - __n; ++__pos)
if (traits_type::eq(this->_M_str[__pos], __str[0])
&& traits_type::compare(this->_M_str + __pos + 1,
__str + 1, __n - 1) == 0)
return __pos;
}
return npos;
}
template<typename _CharT, typename _Traits>
constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find(_CharT __c, size_type __pos) const noexcept
{
size_type __ret = npos;
if (__pos < this->_M_len)
{
const size_type __n = this->_M_len - __pos;
const _CharT* __p = traits_type::find(this->_M_str + __pos, __n, __c);
if (__p)
__ret = __p - this->_M_str;
}
return __ret;
}
template<typename _CharT, typename _Traits>
constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
rfind(const _CharT* __str, size_type __pos, size_type __n) const noexcept
{
__glibcxx_requires_string_len(__str, __n);
if (__n <= this->_M_len)
{
__pos = std::min(size_type(this->_M_len - __n), __pos);
do
{
if (traits_type::compare(this->_M_str + __pos, __str, __n) == 0)
return __pos;
}
while (__pos-- > 0);
}
return npos;
}
template<typename _CharT, typename _Traits>
constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
rfind(_CharT __c, size_type __pos) const noexcept
{
size_type __size = this->_M_len;
if (__size > 0)
{
if (--__size > __pos)
__size = __pos;
for (++__size; __size-- > 0; )
if (traits_type::eq(this->_M_str[__size], __c))
return __size;
}
return npos;
}
template<typename _CharT, typename _Traits>
constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find_first_of(const _CharT* __str, size_type __pos,
size_type __n) const noexcept
{
__glibcxx_requires_string_len(__str, __n);
for (; __n && __pos < this->_M_len; ++__pos)
{
const _CharT* __p = traits_type::find(__str, __n,
this->_M_str[__pos]);
if (__p)
return __pos;
}
return npos;
}
template<typename _CharT, typename _Traits>
constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find_last_of(const _CharT* __str, size_type __pos,
size_type __n) const noexcept
{
__glibcxx_requires_string_len(__str, __n);
size_type __size = this->size();
if (__size && __n)
{
if (--__size > __pos)
__size = __pos;
do
{
if (traits_type::find(__str, __n, this->_M_str[__size]))
return __size;
}
while (__size-- != 0);
}
return npos;
}
template<typename _CharT, typename _Traits>
constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find_first_not_of(const _CharT* __str, size_type __pos,
size_type __n) const noexcept
{
__glibcxx_requires_string_len(__str, __n);
for (; __pos < this->_M_len; ++__pos)
if (!traits_type::find(__str, __n, this->_M_str[__pos]))
return __pos;
return npos;
}
template<typename _CharT, typename _Traits>
constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find_first_not_of(_CharT __c, size_type __pos) const noexcept
{
for (; __pos < this->_M_len; ++__pos)
if (!traits_type::eq(this->_M_str[__pos], __c))
return __pos;
return npos;
}
template<typename _CharT, typename _Traits>
constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find_last_not_of(const _CharT* __str, size_type __pos,
size_type __n) const noexcept
{
__glibcxx_requires_string_len(__str, __n);
size_type __size = this->_M_len;
if (__size)
{
if (--__size > __pos)
__size = __pos;
do
{
if (!traits_type::find(__str, __n, this->_M_str[__size]))
return __size;
}
while (__size--);
}
return npos;
}
template<typename _CharT, typename _Traits>
constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find_last_not_of(_CharT __c, size_type __pos) const noexcept
{
size_type __size = this->_M_len;
if (__size)
{
if (--__size > __pos)
__size = __pos;
do
{
if (!traits_type::eq(this->_M_str[__size], __c))
return __size;
}
while (__size--);
}
return npos;
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // __cplusplus <= 201402L
#endif // _GLIBCXX_STRING_VIEW_TCC
c++/8/bits/gslice_array.h 0000644 00000017131 15201526705 0011047 0 ustar 00 // The template and inlines for the -*- C++ -*- gslice_array class.
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/gslice_array.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{valarray}
*/
// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
#ifndef _GSLICE_ARRAY_H
#define _GSLICE_ARRAY_H 1
#pragma GCC system_header
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @addtogroup numeric_arrays
* @{
*/
/**
* @brief Reference to multi-dimensional subset of an array.
*
* A gslice_array is a reference to the actual elements of an array
* specified by a gslice. The way to get a gslice_array is to call
* operator[](gslice) on a valarray. The returned gslice_array then
* permits carrying operations out on the referenced subset of elements in
* the original valarray. For example, operator+=(valarray) will add
* values to the subset of elements in the underlying valarray this
* gslice_array refers to.
*
* @param Tp Element type.
*/
template<typename _Tp>
class gslice_array
{
public:
typedef _Tp value_type;
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 253. valarray helper functions are almost entirely useless
/// Copy constructor. Both slices refer to the same underlying array.
gslice_array(const gslice_array&);
/// Assignment operator. Assigns slice elements to corresponding
/// elements of @a a.
gslice_array& operator=(const gslice_array&);
/// Assign slice elements to corresponding elements of @a v.
void operator=(const valarray<_Tp>&) const;
/// Multiply slice elements by corresponding elements of @a v.
void operator*=(const valarray<_Tp>&) const;
/// Divide slice elements by corresponding elements of @a v.
void operator/=(const valarray<_Tp>&) const;
/// Modulo slice elements by corresponding elements of @a v.
void operator%=(const valarray<_Tp>&) const;
/// Add corresponding elements of @a v to slice elements.
void operator+=(const valarray<_Tp>&) const;
/// Subtract corresponding elements of @a v from slice elements.
void operator-=(const valarray<_Tp>&) const;
/// Logical xor slice elements with corresponding elements of @a v.
void operator^=(const valarray<_Tp>&) const;
/// Logical and slice elements with corresponding elements of @a v.
void operator&=(const valarray<_Tp>&) const;
/// Logical or slice elements with corresponding elements of @a v.
void operator|=(const valarray<_Tp>&) const;
/// Left shift slice elements by corresponding elements of @a v.
void operator<<=(const valarray<_Tp>&) const;
/// Right shift slice elements by corresponding elements of @a v.
void operator>>=(const valarray<_Tp>&) const;
/// Assign all slice elements to @a t.
void operator=(const _Tp&) const;
template<class _Dom>
void operator=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom>
void operator*=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom>
void operator/=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom>
void operator%=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom>
void operator+=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom>
void operator-=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom>
void operator^=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom>
void operator&=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom>
void operator|=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom>
void operator<<=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom>
void operator>>=(const _Expr<_Dom, _Tp>&) const;
private:
_Array<_Tp> _M_array;
const valarray<size_t>& _M_index;
friend class valarray<_Tp>;
gslice_array(_Array<_Tp>, const valarray<size_t>&);
// not implemented
gslice_array();
};
template<typename _Tp>
inline
gslice_array<_Tp>::gslice_array(_Array<_Tp> __a,
const valarray<size_t>& __i)
: _M_array(__a), _M_index(__i) {}
template<typename _Tp>
inline
gslice_array<_Tp>::gslice_array(const gslice_array<_Tp>& __a)
: _M_array(__a._M_array), _M_index(__a._M_index) {}
template<typename _Tp>
inline gslice_array<_Tp>&
gslice_array<_Tp>::operator=(const gslice_array<_Tp>& __a)
{
std::__valarray_copy(_Array<_Tp>(__a._M_array),
_Array<size_t>(__a._M_index), _M_index.size(),
_M_array, _Array<size_t>(_M_index));
return *this;
}
template<typename _Tp>
inline void
gslice_array<_Tp>::operator=(const _Tp& __t) const
{
std::__valarray_fill(_M_array, _Array<size_t>(_M_index),
_M_index.size(), __t);
}
template<typename _Tp>
inline void
gslice_array<_Tp>::operator=(const valarray<_Tp>& __v) const
{
std::__valarray_copy(_Array<_Tp>(__v), __v.size(),
_M_array, _Array<size_t>(_M_index));
}
template<typename _Tp>
template<class _Dom>
inline void
gslice_array<_Tp>::operator=(const _Expr<_Dom, _Tp>& __e) const
{
std::__valarray_copy (__e, _M_index.size(), _M_array,
_Array<size_t>(_M_index));
}
#undef _DEFINE_VALARRAY_OPERATOR
#define _DEFINE_VALARRAY_OPERATOR(_Op, _Name) \
template<typename _Tp> \
inline void \
gslice_array<_Tp>::operator _Op##=(const valarray<_Tp>& __v) const \
{ \
_Array_augmented_##_Name(_M_array, _Array<size_t>(_M_index), \
_Array<_Tp>(__v), __v.size()); \
} \
\
template<typename _Tp> \
template<class _Dom> \
inline void \
gslice_array<_Tp>::operator _Op##= (const _Expr<_Dom, _Tp>& __e) const\
{ \
_Array_augmented_##_Name(_M_array, _Array<size_t>(_M_index), __e,\
_M_index.size()); \
}
_DEFINE_VALARRAY_OPERATOR(*, __multiplies)
_DEFINE_VALARRAY_OPERATOR(/, __divides)
_DEFINE_VALARRAY_OPERATOR(%, __modulus)
_DEFINE_VALARRAY_OPERATOR(+, __plus)
_DEFINE_VALARRAY_OPERATOR(-, __minus)
_DEFINE_VALARRAY_OPERATOR(^, __bitwise_xor)
_DEFINE_VALARRAY_OPERATOR(&, __bitwise_and)
_DEFINE_VALARRAY_OPERATOR(|, __bitwise_or)
_DEFINE_VALARRAY_OPERATOR(<<, __shift_left)
_DEFINE_VALARRAY_OPERATOR(>>, __shift_right)
#undef _DEFINE_VALARRAY_OPERATOR
// @} group numeric_arrays
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif /* _GSLICE_ARRAY_H */
c++/8/bits/allocated_ptr.h 0000644 00000006335 15201526705 0011224 0 ustar 00 // Guarded Allocation -*- C++ -*-
// Copyright (C) 2014-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/allocated_ptr.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{memory}
*/
#ifndef _ALLOCATED_PTR_H
#define _ALLOCATED_PTR_H 1
#if __cplusplus < 201103L
# include <bits/c++0xwarning.h>
#else
# include <type_traits>
# include <bits/ptr_traits.h>
# include <bits/alloc_traits.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/// Non-standard RAII type for managing pointers obtained from allocators.
template<typename _Alloc>
struct __allocated_ptr
{
using pointer = typename allocator_traits<_Alloc>::pointer;
using value_type = typename allocator_traits<_Alloc>::value_type;
/// Take ownership of __ptr
__allocated_ptr(_Alloc& __a, pointer __ptr) noexcept
: _M_alloc(std::__addressof(__a)), _M_ptr(__ptr)
{ }
/// Convert __ptr to allocator's pointer type and take ownership of it
template<typename _Ptr,
typename _Req = _Require<is_same<_Ptr, value_type*>>>
__allocated_ptr(_Alloc& __a, _Ptr __ptr)
: _M_alloc(std::__addressof(__a)),
_M_ptr(pointer_traits<pointer>::pointer_to(*__ptr))
{ }
/// Transfer ownership of the owned pointer
__allocated_ptr(__allocated_ptr&& __gd) noexcept
: _M_alloc(__gd._M_alloc), _M_ptr(__gd._M_ptr)
{ __gd._M_ptr = nullptr; }
/// Deallocate the owned pointer
~__allocated_ptr()
{
if (_M_ptr != nullptr)
std::allocator_traits<_Alloc>::deallocate(*_M_alloc, _M_ptr, 1);
}
/// Release ownership of the owned pointer
__allocated_ptr&
operator=(std::nullptr_t) noexcept
{
_M_ptr = nullptr;
return *this;
}
/// Get the address that the owned pointer refers to.
value_type* get() { return std::__to_address(_M_ptr); }
private:
_Alloc* _M_alloc;
pointer _M_ptr;
};
/// Allocate space for a single object using __a
template<typename _Alloc>
__allocated_ptr<_Alloc>
__allocate_guarded(_Alloc& __a)
{
return { __a, std::allocator_traits<_Alloc>::allocate(__a, 1) };
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif
#endif
c++/8/bits/cxxabi_init_exception.h 0000644 00000004254 15201526705 0012764 0 ustar 00 // ABI Support -*- C++ -*-
// Copyright (C) 2016-2018 Free Software Foundation, Inc.
//
// This file is part of GCC.
//
// GCC is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// GCC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/cxxabi_init_exception.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly.
*/
#ifndef _CXXABI_INIT_EXCEPTION_H
#define _CXXABI_INIT_EXCEPTION_H 1
#pragma GCC system_header
#pragma GCC visibility push(default)
#include <stddef.h>
#include <bits/c++config.h>
#ifndef _GLIBCXX_CDTOR_CALLABI
#define _GLIBCXX_CDTOR_CALLABI
#define _GLIBCXX_HAVE_CDTOR_CALLABI 0
#else
#define _GLIBCXX_HAVE_CDTOR_CALLABI 1
#endif
#ifdef __cplusplus
namespace std
{
class type_info;
}
namespace __cxxabiv1
{
struct __cxa_refcounted_exception;
extern "C"
{
// Allocate memory for the primary exception plus the thrown object.
void*
__cxa_allocate_exception(size_t) _GLIBCXX_NOTHROW;
void
__cxa_free_exception(void*) _GLIBCXX_NOTHROW;
// Initialize exception (this is a GNU extension)
__cxa_refcounted_exception*
__cxa_init_primary_exception(void *object, std::type_info *tinfo,
void (_GLIBCXX_CDTOR_CALLABI *dest) (void *)) _GLIBCXX_NOTHROW;
}
} // namespace __cxxabiv1
#endif
#pragma GCC visibility pop
#endif // _CXXABI_INIT_EXCEPTION_H
c++/8/bits/stl_bvector.h 0000644 00000101700 15201526705 0010725 0 ustar 00 // vector<bool> specialization -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1996-1999
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file bits/stl_bvector.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{vector}
*/
#ifndef _STL_BVECTOR_H
#define _STL_BVECTOR_H 1
#if __cplusplus >= 201103L
#include <initializer_list>
#include <bits/functional_hash.h>
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
typedef unsigned long _Bit_type;
enum { _S_word_bit = int(__CHAR_BIT__ * sizeof(_Bit_type)) };
struct _Bit_reference
{
_Bit_type * _M_p;
_Bit_type _M_mask;
_Bit_reference(_Bit_type * __x, _Bit_type __y)
: _M_p(__x), _M_mask(__y) { }
_Bit_reference() _GLIBCXX_NOEXCEPT : _M_p(0), _M_mask(0) { }
operator bool() const _GLIBCXX_NOEXCEPT
{ return !!(*_M_p & _M_mask); }
_Bit_reference&
operator=(bool __x) _GLIBCXX_NOEXCEPT
{
if (__x)
*_M_p |= _M_mask;
else
*_M_p &= ~_M_mask;
return *this;
}
_Bit_reference&
operator=(const _Bit_reference& __x) _GLIBCXX_NOEXCEPT
{ return *this = bool(__x); }
bool
operator==(const _Bit_reference& __x) const
{ return bool(*this) == bool(__x); }
bool
operator<(const _Bit_reference& __x) const
{ return !bool(*this) && bool(__x); }
void
flip() _GLIBCXX_NOEXCEPT
{ *_M_p ^= _M_mask; }
};
#if __cplusplus >= 201103L
inline void
swap(_Bit_reference __x, _Bit_reference __y) noexcept
{
bool __tmp = __x;
__x = __y;
__y = __tmp;
}
inline void
swap(_Bit_reference __x, bool& __y) noexcept
{
bool __tmp = __x;
__x = __y;
__y = __tmp;
}
inline void
swap(bool& __x, _Bit_reference __y) noexcept
{
bool __tmp = __x;
__x = __y;
__y = __tmp;
}
#endif
struct _Bit_iterator_base
: public std::iterator<std::random_access_iterator_tag, bool>
{
_Bit_type * _M_p;
unsigned int _M_offset;
_Bit_iterator_base(_Bit_type * __x, unsigned int __y)
: _M_p(__x), _M_offset(__y) { }
void
_M_bump_up()
{
if (_M_offset++ == int(_S_word_bit) - 1)
{
_M_offset = 0;
++_M_p;
}
}
void
_M_bump_down()
{
if (_M_offset-- == 0)
{
_M_offset = int(_S_word_bit) - 1;
--_M_p;
}
}
void
_M_incr(ptrdiff_t __i)
{
difference_type __n = __i + _M_offset;
_M_p += __n / int(_S_word_bit);
__n = __n % int(_S_word_bit);
if (__n < 0)
{
__n += int(_S_word_bit);
--_M_p;
}
_M_offset = static_cast<unsigned int>(__n);
}
bool
operator==(const _Bit_iterator_base& __i) const
{ return _M_p == __i._M_p && _M_offset == __i._M_offset; }
bool
operator<(const _Bit_iterator_base& __i) const
{
return _M_p < __i._M_p
|| (_M_p == __i._M_p && _M_offset < __i._M_offset);
}
bool
operator!=(const _Bit_iterator_base& __i) const
{ return !(*this == __i); }
bool
operator>(const _Bit_iterator_base& __i) const
{ return __i < *this; }
bool
operator<=(const _Bit_iterator_base& __i) const
{ return !(__i < *this); }
bool
operator>=(const _Bit_iterator_base& __i) const
{ return !(*this < __i); }
};
inline ptrdiff_t
operator-(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y)
{
return (int(_S_word_bit) * (__x._M_p - __y._M_p)
+ __x._M_offset - __y._M_offset);
}
struct _Bit_iterator : public _Bit_iterator_base
{
typedef _Bit_reference reference;
typedef _Bit_reference* pointer;
typedef _Bit_iterator iterator;
_Bit_iterator() : _Bit_iterator_base(0, 0) { }
_Bit_iterator(_Bit_type * __x, unsigned int __y)
: _Bit_iterator_base(__x, __y) { }
iterator
_M_const_cast() const
{ return *this; }
reference
operator*() const
{ return reference(_M_p, 1UL << _M_offset); }
iterator&
operator++()
{
_M_bump_up();
return *this;
}
iterator
operator++(int)
{
iterator __tmp = *this;
_M_bump_up();
return __tmp;
}
iterator&
operator--()
{
_M_bump_down();
return *this;
}
iterator
operator--(int)
{
iterator __tmp = *this;
_M_bump_down();
return __tmp;
}
iterator&
operator+=(difference_type __i)
{
_M_incr(__i);
return *this;
}
iterator&
operator-=(difference_type __i)
{
*this += -__i;
return *this;
}
iterator
operator+(difference_type __i) const
{
iterator __tmp = *this;
return __tmp += __i;
}
iterator
operator-(difference_type __i) const
{
iterator __tmp = *this;
return __tmp -= __i;
}
reference
operator[](difference_type __i) const
{ return *(*this + __i); }
};
inline _Bit_iterator
operator+(ptrdiff_t __n, const _Bit_iterator& __x)
{ return __x + __n; }
struct _Bit_const_iterator : public _Bit_iterator_base
{
typedef bool reference;
typedef bool const_reference;
typedef const bool* pointer;
typedef _Bit_const_iterator const_iterator;
_Bit_const_iterator() : _Bit_iterator_base(0, 0) { }
_Bit_const_iterator(_Bit_type * __x, unsigned int __y)
: _Bit_iterator_base(__x, __y) { }
_Bit_const_iterator(const _Bit_iterator& __x)
: _Bit_iterator_base(__x._M_p, __x._M_offset) { }
_Bit_iterator
_M_const_cast() const
{ return _Bit_iterator(_M_p, _M_offset); }
const_reference
operator*() const
{ return _Bit_reference(_M_p, 1UL << _M_offset); }
const_iterator&
operator++()
{
_M_bump_up();
return *this;
}
const_iterator
operator++(int)
{
const_iterator __tmp = *this;
_M_bump_up();
return __tmp;
}
const_iterator&
operator--()
{
_M_bump_down();
return *this;
}
const_iterator
operator--(int)
{
const_iterator __tmp = *this;
_M_bump_down();
return __tmp;
}
const_iterator&
operator+=(difference_type __i)
{
_M_incr(__i);
return *this;
}
const_iterator&
operator-=(difference_type __i)
{
*this += -__i;
return *this;
}
const_iterator
operator+(difference_type __i) const
{
const_iterator __tmp = *this;
return __tmp += __i;
}
const_iterator
operator-(difference_type __i) const
{
const_iterator __tmp = *this;
return __tmp -= __i;
}
const_reference
operator[](difference_type __i) const
{ return *(*this + __i); }
};
inline _Bit_const_iterator
operator+(ptrdiff_t __n, const _Bit_const_iterator& __x)
{ return __x + __n; }
inline void
__fill_bvector(_Bit_type * __v,
unsigned int __first, unsigned int __last, bool __x)
{
const _Bit_type __fmask = ~0ul << __first;
const _Bit_type __lmask = ~0ul >> (_S_word_bit - __last);
const _Bit_type __mask = __fmask & __lmask;
if (__x)
*__v |= __mask;
else
*__v &= ~__mask;
}
inline void
fill(_Bit_iterator __first, _Bit_iterator __last, const bool& __x)
{
if (__first._M_p != __last._M_p)
{
_Bit_type* __first_p = __first._M_p;
if (__first._M_offset != 0)
__fill_bvector(__first_p++, __first._M_offset, _S_word_bit, __x);
__builtin_memset(__first_p, __x ? ~0 : 0,
(__last._M_p - __first_p) * sizeof(_Bit_type));
if (__last._M_offset != 0)
__fill_bvector(__last._M_p, 0, __last._M_offset, __x);
}
else if (__first._M_offset != __last._M_offset)
__fill_bvector(__first._M_p, __first._M_offset, __last._M_offset, __x);
}
template<typename _Alloc>
struct _Bvector_base
{
typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template
rebind<_Bit_type>::other _Bit_alloc_type;
typedef typename __gnu_cxx::__alloc_traits<_Bit_alloc_type>
_Bit_alloc_traits;
typedef typename _Bit_alloc_traits::pointer _Bit_pointer;
struct _Bvector_impl_data
{
_Bit_iterator _M_start;
_Bit_iterator _M_finish;
_Bit_pointer _M_end_of_storage;
_Bvector_impl_data() _GLIBCXX_NOEXCEPT
: _M_start(), _M_finish(), _M_end_of_storage()
{ }
#if __cplusplus >= 201103L
_Bvector_impl_data(_Bvector_impl_data&& __x) noexcept
: _M_start(__x._M_start), _M_finish(__x._M_finish)
, _M_end_of_storage(__x._M_end_of_storage)
{ __x._M_reset(); }
void
_M_move_data(_Bvector_impl_data&& __x) noexcept
{
this->_M_start = __x._M_start;
this->_M_finish = __x._M_finish;
this->_M_end_of_storage = __x._M_end_of_storage;
__x._M_reset();
}
#endif
void
_M_reset() _GLIBCXX_NOEXCEPT
{
_M_start = _M_finish = _Bit_iterator();
_M_end_of_storage = _Bit_pointer();
}
};
struct _Bvector_impl
: public _Bit_alloc_type, public _Bvector_impl_data
{
public:
_Bvector_impl() _GLIBCXX_NOEXCEPT_IF(
is_nothrow_default_constructible<_Bit_alloc_type>::value)
: _Bit_alloc_type()
{ }
_Bvector_impl(const _Bit_alloc_type& __a) _GLIBCXX_NOEXCEPT
: _Bit_alloc_type(__a)
{ }
#if __cplusplus >= 201103L
_Bvector_impl(_Bvector_impl&&) = default;
#endif
_Bit_type*
_M_end_addr() const _GLIBCXX_NOEXCEPT
{
if (this->_M_end_of_storage)
return std::__addressof(this->_M_end_of_storage[-1]) + 1;
return 0;
}
};
public:
typedef _Alloc allocator_type;
_Bit_alloc_type&
_M_get_Bit_allocator() _GLIBCXX_NOEXCEPT
{ return this->_M_impl; }
const _Bit_alloc_type&
_M_get_Bit_allocator() const _GLIBCXX_NOEXCEPT
{ return this->_M_impl; }
allocator_type
get_allocator() const _GLIBCXX_NOEXCEPT
{ return allocator_type(_M_get_Bit_allocator()); }
#if __cplusplus >= 201103L
_Bvector_base() = default;
#else
_Bvector_base() { }
#endif
_Bvector_base(const allocator_type& __a)
: _M_impl(__a) { }
#if __cplusplus >= 201103L
_Bvector_base(_Bvector_base&&) = default;
#endif
~_Bvector_base()
{ this->_M_deallocate(); }
protected:
_Bvector_impl _M_impl;
_Bit_pointer
_M_allocate(size_t __n)
{ return _Bit_alloc_traits::allocate(_M_impl, _S_nword(__n)); }
void
_M_deallocate()
{
if (_M_impl._M_start._M_p)
{
const size_t __n = _M_impl._M_end_addr() - _M_impl._M_start._M_p;
_Bit_alloc_traits::deallocate(_M_impl,
_M_impl._M_end_of_storage - __n,
__n);
_M_impl._M_reset();
}
}
#if __cplusplus >= 201103L
void
_M_move_data(_Bvector_base&& __x) noexcept
{ _M_impl._M_move_data(std::move(__x._M_impl)); }
#endif
static size_t
_S_nword(size_t __n)
{ return (__n + int(_S_word_bit) - 1) / int(_S_word_bit); }
};
_GLIBCXX_END_NAMESPACE_CONTAINER
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
// Declare a partial specialization of vector<T, Alloc>.
#include <bits/stl_vector.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
/**
* @brief A specialization of vector for booleans which offers fixed time
* access to individual elements in any order.
*
* @ingroup sequences
*
* @tparam _Alloc Allocator type.
*
* Note that vector<bool> does not actually meet the requirements for being
* a container. This is because the reference and pointer types are not
* really references and pointers to bool. See DR96 for details. @see
* vector for function documentation.
*
* In some terminology a %vector can be described as a dynamic
* C-style array, it offers fast and efficient access to individual
* elements in any order and saves the user from worrying about
* memory and size allocation. Subscripting ( @c [] ) access is
* also provided as with C-style arrays.
*/
template<typename _Alloc>
class vector<bool, _Alloc> : protected _Bvector_base<_Alloc>
{
typedef _Bvector_base<_Alloc> _Base;
typedef typename _Base::_Bit_pointer _Bit_pointer;
typedef typename _Base::_Bit_alloc_traits _Bit_alloc_traits;
#if __cplusplus >= 201103L
friend struct std::hash<vector>;
#endif
public:
typedef bool value_type;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef _Bit_reference reference;
typedef bool const_reference;
typedef _Bit_reference* pointer;
typedef const bool* const_pointer;
typedef _Bit_iterator iterator;
typedef _Bit_const_iterator const_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef _Alloc allocator_type;
allocator_type
get_allocator() const
{ return _Base::get_allocator(); }
protected:
using _Base::_M_allocate;
using _Base::_M_deallocate;
using _Base::_S_nword;
using _Base::_M_get_Bit_allocator;
public:
#if __cplusplus >= 201103L
vector() = default;
#else
vector() { }
#endif
explicit
vector(const allocator_type& __a)
: _Base(__a) { }
#if __cplusplus >= 201103L
explicit
vector(size_type __n, const allocator_type& __a = allocator_type())
: vector(__n, false, __a)
{ }
vector(size_type __n, const bool& __value,
const allocator_type& __a = allocator_type())
#else
explicit
vector(size_type __n, const bool& __value = bool(),
const allocator_type& __a = allocator_type())
#endif
: _Base(__a)
{
_M_initialize(__n);
_M_initialize_value(__value);
}
vector(const vector& __x)
: _Base(_Bit_alloc_traits::_S_select_on_copy(__x._M_get_Bit_allocator()))
{
_M_initialize(__x.size());
_M_copy_aligned(__x.begin(), __x.end(), this->_M_impl._M_start);
}
#if __cplusplus >= 201103L
vector(vector&&) = default;
vector(vector&& __x, const allocator_type& __a)
noexcept(_Bit_alloc_traits::_S_always_equal())
: _Base(__a)
{
if (__x.get_allocator() == __a)
this->_M_move_data(std::move(__x));
else
{
_M_initialize(__x.size());
_M_copy_aligned(__x.begin(), __x.end(), begin());
__x.clear();
}
}
vector(const vector& __x, const allocator_type& __a)
: _Base(__a)
{
_M_initialize(__x.size());
_M_copy_aligned(__x.begin(), __x.end(), this->_M_impl._M_start);
}
vector(initializer_list<bool> __l,
const allocator_type& __a = allocator_type())
: _Base(__a)
{
_M_initialize_range(__l.begin(), __l.end(),
random_access_iterator_tag());
}
#endif
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
vector(_InputIterator __first, _InputIterator __last,
const allocator_type& __a = allocator_type())
: _Base(__a)
{ _M_initialize_dispatch(__first, __last, __false_type()); }
#else
template<typename _InputIterator>
vector(_InputIterator __first, _InputIterator __last,
const allocator_type& __a = allocator_type())
: _Base(__a)
{
typedef typename std::__is_integer<_InputIterator>::__type _Integral;
_M_initialize_dispatch(__first, __last, _Integral());
}
#endif
~vector() _GLIBCXX_NOEXCEPT { }
vector&
operator=(const vector& __x)
{
if (&__x == this)
return *this;
#if __cplusplus >= 201103L
if (_Bit_alloc_traits::_S_propagate_on_copy_assign())
{
if (this->_M_get_Bit_allocator() != __x._M_get_Bit_allocator())
{
this->_M_deallocate();
std::__alloc_on_copy(_M_get_Bit_allocator(),
__x._M_get_Bit_allocator());
_M_initialize(__x.size());
}
else
std::__alloc_on_copy(_M_get_Bit_allocator(),
__x._M_get_Bit_allocator());
}
#endif
if (__x.size() > capacity())
{
this->_M_deallocate();
_M_initialize(__x.size());
}
this->_M_impl._M_finish = _M_copy_aligned(__x.begin(), __x.end(),
begin());
return *this;
}
#if __cplusplus >= 201103L
vector&
operator=(vector&& __x) noexcept(_Bit_alloc_traits::_S_nothrow_move())
{
if (_Bit_alloc_traits::_S_propagate_on_move_assign()
|| this->_M_get_Bit_allocator() == __x._M_get_Bit_allocator())
{
this->_M_deallocate();
this->_M_move_data(std::move(__x));
std::__alloc_on_move(_M_get_Bit_allocator(),
__x._M_get_Bit_allocator());
}
else
{
if (__x.size() > capacity())
{
this->_M_deallocate();
_M_initialize(__x.size());
}
this->_M_impl._M_finish = _M_copy_aligned(__x.begin(), __x.end(),
begin());
__x.clear();
}
return *this;
}
vector&
operator=(initializer_list<bool> __l)
{
this->assign (__l.begin(), __l.end());
return *this;
}
#endif
// assign(), a generalized assignment member function. Two
// versions: one that takes a count, and one that takes a range.
// The range version is a member template, so we dispatch on whether
// or not the type is an integer.
void
assign(size_type __n, const bool& __x)
{ _M_fill_assign(__n, __x); }
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
void
assign(_InputIterator __first, _InputIterator __last)
{ _M_assign_aux(__first, __last, std::__iterator_category(__first)); }
#else
template<typename _InputIterator>
void
assign(_InputIterator __first, _InputIterator __last)
{
typedef typename std::__is_integer<_InputIterator>::__type _Integral;
_M_assign_dispatch(__first, __last, _Integral());
}
#endif
#if __cplusplus >= 201103L
void
assign(initializer_list<bool> __l)
{ _M_assign_aux(__l.begin(), __l.end(), random_access_iterator_tag()); }
#endif
iterator
begin() _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_start; }
const_iterator
begin() const _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_start; }
iterator
end() _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_finish; }
const_iterator
end() const _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_finish; }
reverse_iterator
rbegin() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(end()); }
const_reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(end()); }
reverse_iterator
rend() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(begin()); }
const_reverse_iterator
rend() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(begin()); }
#if __cplusplus >= 201103L
const_iterator
cbegin() const noexcept
{ return this->_M_impl._M_start; }
const_iterator
cend() const noexcept
{ return this->_M_impl._M_finish; }
const_reverse_iterator
crbegin() const noexcept
{ return const_reverse_iterator(end()); }
const_reverse_iterator
crend() const noexcept
{ return const_reverse_iterator(begin()); }
#endif
size_type
size() const _GLIBCXX_NOEXCEPT
{ return size_type(end() - begin()); }
size_type
max_size() const _GLIBCXX_NOEXCEPT
{
const size_type __isize =
__gnu_cxx::__numeric_traits<difference_type>::__max
- int(_S_word_bit) + 1;
const size_type __asize
= _Bit_alloc_traits::max_size(_M_get_Bit_allocator());
return (__asize <= __isize / int(_S_word_bit)
? __asize * int(_S_word_bit) : __isize);
}
size_type
capacity() const _GLIBCXX_NOEXCEPT
{ return size_type(const_iterator(this->_M_impl._M_end_addr(), 0)
- begin()); }
bool
empty() const _GLIBCXX_NOEXCEPT
{ return begin() == end(); }
reference
operator[](size_type __n)
{
return *iterator(this->_M_impl._M_start._M_p
+ __n / int(_S_word_bit), __n % int(_S_word_bit));
}
const_reference
operator[](size_type __n) const
{
return *const_iterator(this->_M_impl._M_start._M_p
+ __n / int(_S_word_bit), __n % int(_S_word_bit));
}
protected:
void
_M_range_check(size_type __n) const
{
if (__n >= this->size())
__throw_out_of_range_fmt(__N("vector<bool>::_M_range_check: __n "
"(which is %zu) >= this->size() "
"(which is %zu)"),
__n, this->size());
}
public:
reference
at(size_type __n)
{ _M_range_check(__n); return (*this)[__n]; }
const_reference
at(size_type __n) const
{ _M_range_check(__n); return (*this)[__n]; }
void
reserve(size_type __n)
{
if (__n > max_size())
__throw_length_error(__N("vector::reserve"));
if (capacity() < __n)
_M_reallocate(__n);
}
reference
front()
{ return *begin(); }
const_reference
front() const
{ return *begin(); }
reference
back()
{ return *(end() - 1); }
const_reference
back() const
{ return *(end() - 1); }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 464. Suggestion for new member functions in standard containers.
// N.B. DR 464 says nothing about vector<bool> but we need something
// here due to the way we are implementing DR 464 in the debug-mode
// vector class.
void
data() _GLIBCXX_NOEXCEPT { }
void
push_back(bool __x)
{
if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr())
*this->_M_impl._M_finish++ = __x;
else
_M_insert_aux(end(), __x);
}
void
swap(vector& __x) _GLIBCXX_NOEXCEPT
{
std::swap(this->_M_impl._M_start, __x._M_impl._M_start);
std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish);
std::swap(this->_M_impl._M_end_of_storage,
__x._M_impl._M_end_of_storage);
_Bit_alloc_traits::_S_on_swap(_M_get_Bit_allocator(),
__x._M_get_Bit_allocator());
}
// [23.2.5]/1, third-to-last entry in synopsis listing
static void
swap(reference __x, reference __y) _GLIBCXX_NOEXCEPT
{
bool __tmp = __x;
__x = __y;
__y = __tmp;
}
iterator
#if __cplusplus >= 201103L
insert(const_iterator __position, const bool& __x = bool())
#else
insert(iterator __position, const bool& __x = bool())
#endif
{
const difference_type __n = __position - begin();
if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr()
&& __position == end())
*this->_M_impl._M_finish++ = __x;
else
_M_insert_aux(__position._M_const_cast(), __x);
return begin() + __n;
}
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
iterator
insert(const_iterator __position,
_InputIterator __first, _InputIterator __last)
{
difference_type __offset = __position - cbegin();
_M_insert_dispatch(__position._M_const_cast(),
__first, __last, __false_type());
return begin() + __offset;
}
#else
template<typename _InputIterator>
void
insert(iterator __position,
_InputIterator __first, _InputIterator __last)
{
typedef typename std::__is_integer<_InputIterator>::__type _Integral;
_M_insert_dispatch(__position, __first, __last, _Integral());
}
#endif
#if __cplusplus >= 201103L
iterator
insert(const_iterator __position, size_type __n, const bool& __x)
{
difference_type __offset = __position - cbegin();
_M_fill_insert(__position._M_const_cast(), __n, __x);
return begin() + __offset;
}
#else
void
insert(iterator __position, size_type __n, const bool& __x)
{ _M_fill_insert(__position, __n, __x); }
#endif
#if __cplusplus >= 201103L
iterator
insert(const_iterator __p, initializer_list<bool> __l)
{ return this->insert(__p, __l.begin(), __l.end()); }
#endif
void
pop_back()
{ --this->_M_impl._M_finish; }
iterator
#if __cplusplus >= 201103L
erase(const_iterator __position)
#else
erase(iterator __position)
#endif
{ return _M_erase(__position._M_const_cast()); }
iterator
#if __cplusplus >= 201103L
erase(const_iterator __first, const_iterator __last)
#else
erase(iterator __first, iterator __last)
#endif
{ return _M_erase(__first._M_const_cast(), __last._M_const_cast()); }
void
resize(size_type __new_size, bool __x = bool())
{
if (__new_size < size())
_M_erase_at_end(begin() + difference_type(__new_size));
else
insert(end(), __new_size - size(), __x);
}
#if __cplusplus >= 201103L
void
shrink_to_fit()
{ _M_shrink_to_fit(); }
#endif
void
flip() _GLIBCXX_NOEXCEPT
{
_Bit_type * const __end = this->_M_impl._M_end_addr();
for (_Bit_type * __p = this->_M_impl._M_start._M_p; __p != __end; ++__p)
*__p = ~*__p;
}
void
clear() _GLIBCXX_NOEXCEPT
{ _M_erase_at_end(begin()); }
#if __cplusplus >= 201103L
template<typename... _Args>
#if __cplusplus > 201402L
reference
#else
void
#endif
emplace_back(_Args&&... __args)
{
push_back(bool(__args...));
#if __cplusplus > 201402L
return back();
#endif
}
template<typename... _Args>
iterator
emplace(const_iterator __pos, _Args&&... __args)
{ return insert(__pos, bool(__args...)); }
#endif
protected:
// Precondition: __first._M_offset == 0 && __result._M_offset == 0.
iterator
_M_copy_aligned(const_iterator __first, const_iterator __last,
iterator __result)
{
_Bit_type* __q = std::copy(__first._M_p, __last._M_p, __result._M_p);
return std::copy(const_iterator(__last._M_p, 0), __last,
iterator(__q, 0));
}
void
_M_initialize(size_type __n)
{
if (__n)
{
_Bit_pointer __q = this->_M_allocate(__n);
this->_M_impl._M_end_of_storage = __q + _S_nword(__n);
this->_M_impl._M_start = iterator(std::__addressof(*__q), 0);
}
else
{
this->_M_impl._M_end_of_storage = _Bit_pointer();
this->_M_impl._M_start = iterator(0, 0);
}
this->_M_impl._M_finish = this->_M_impl._M_start + difference_type(__n);
}
void
_M_initialize_value(bool __x)
{
if (_Bit_type* __p = this->_M_impl._M_start._M_p)
__builtin_memset(__p, __x ? ~0 : 0,
(this->_M_impl._M_end_addr() - __p)
* sizeof(_Bit_type));
}
void
_M_reallocate(size_type __n);
#if __cplusplus >= 201103L
bool
_M_shrink_to_fit();
#endif
// Check whether it's an integral type. If so, it's not an iterator.
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 438. Ambiguity in the "do the right thing" clause
template<typename _Integer>
void
_M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
{
_M_initialize(static_cast<size_type>(__n));
_M_initialize_value(__x);
}
template<typename _InputIterator>
void
_M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
__false_type)
{ _M_initialize_range(__first, __last,
std::__iterator_category(__first)); }
template<typename _InputIterator>
void
_M_initialize_range(_InputIterator __first, _InputIterator __last,
std::input_iterator_tag)
{
for (; __first != __last; ++__first)
push_back(*__first);
}
template<typename _ForwardIterator>
void
_M_initialize_range(_ForwardIterator __first, _ForwardIterator __last,
std::forward_iterator_tag)
{
const size_type __n = std::distance(__first, __last);
_M_initialize(__n);
std::copy(__first, __last, this->_M_impl._M_start);
}
#if __cplusplus < 201103L
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 438. Ambiguity in the "do the right thing" clause
template<typename _Integer>
void
_M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
{ _M_fill_assign(__n, __val); }
template<class _InputIterator>
void
_M_assign_dispatch(_InputIterator __first, _InputIterator __last,
__false_type)
{ _M_assign_aux(__first, __last, std::__iterator_category(__first)); }
#endif
void
_M_fill_assign(size_t __n, bool __x)
{
if (__n > size())
{
_M_initialize_value(__x);
insert(end(), __n - size(), __x);
}
else
{
_M_erase_at_end(begin() + __n);
_M_initialize_value(__x);
}
}
template<typename _InputIterator>
void
_M_assign_aux(_InputIterator __first, _InputIterator __last,
std::input_iterator_tag)
{
iterator __cur = begin();
for (; __first != __last && __cur != end(); ++__cur, ++__first)
*__cur = *__first;
if (__first == __last)
_M_erase_at_end(__cur);
else
insert(end(), __first, __last);
}
template<typename _ForwardIterator>
void
_M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
std::forward_iterator_tag)
{
const size_type __len = std::distance(__first, __last);
if (__len < size())
_M_erase_at_end(std::copy(__first, __last, begin()));
else
{
_ForwardIterator __mid = __first;
std::advance(__mid, size());
std::copy(__first, __mid, begin());
insert(end(), __mid, __last);
}
}
// Check whether it's an integral type. If so, it's not an iterator.
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 438. Ambiguity in the "do the right thing" clause
template<typename _Integer>
void
_M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x,
__true_type)
{ _M_fill_insert(__pos, __n, __x); }
template<typename _InputIterator>
void
_M_insert_dispatch(iterator __pos,
_InputIterator __first, _InputIterator __last,
__false_type)
{ _M_insert_range(__pos, __first, __last,
std::__iterator_category(__first)); }
void
_M_fill_insert(iterator __position, size_type __n, bool __x);
template<typename _InputIterator>
void
_M_insert_range(iterator __pos, _InputIterator __first,
_InputIterator __last, std::input_iterator_tag)
{
for (; __first != __last; ++__first)
{
__pos = insert(__pos, *__first);
++__pos;
}
}
template<typename _ForwardIterator>
void
_M_insert_range(iterator __position, _ForwardIterator __first,
_ForwardIterator __last, std::forward_iterator_tag);
void
_M_insert_aux(iterator __position, bool __x);
size_type
_M_check_len(size_type __n, const char* __s) const
{
if (max_size() - size() < __n)
__throw_length_error(__N(__s));
const size_type __len = size() + std::max(size(), __n);
return (__len < size() || __len > max_size()) ? max_size() : __len;
}
void
_M_erase_at_end(iterator __pos)
{ this->_M_impl._M_finish = __pos; }
iterator
_M_erase(iterator __pos);
iterator
_M_erase(iterator __first, iterator __last);
};
_GLIBCXX_END_NAMESPACE_CONTAINER
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#if __cplusplus >= 201103L
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// DR 1182.
/// std::hash specialization for vector<bool>.
template<typename _Alloc>
struct hash<_GLIBCXX_STD_C::vector<bool, _Alloc>>
: public __hash_base<size_t, _GLIBCXX_STD_C::vector<bool, _Alloc>>
{
size_t
operator()(const _GLIBCXX_STD_C::vector<bool, _Alloc>&) const noexcept;
};
_GLIBCXX_END_NAMESPACE_VERSION
}// namespace std
#endif // C++11
#endif
c++/8/bits/regex_scanner.h 0000644 00000015660 15201526705 0011233 0 ustar 00 // class template regex -*- C++ -*-
// Copyright (C) 2013-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/**
* @file bits/regex_scanner.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{regex}
*/
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
namespace __detail
{
/**
* @addtogroup regex-detail
* @{
*/
struct _ScannerBase
{
public:
/// Token types returned from the scanner.
enum _TokenT : unsigned
{
_S_token_anychar,
_S_token_ord_char,
_S_token_oct_num,
_S_token_hex_num,
_S_token_backref,
_S_token_subexpr_begin,
_S_token_subexpr_no_group_begin,
_S_token_subexpr_lookahead_begin, // neg if _M_value[0] == 'n'
_S_token_subexpr_end,
_S_token_bracket_begin,
_S_token_bracket_neg_begin,
_S_token_bracket_end,
_S_token_interval_begin,
_S_token_interval_end,
_S_token_quoted_class,
_S_token_char_class_name,
_S_token_collsymbol,
_S_token_equiv_class_name,
_S_token_opt,
_S_token_or,
_S_token_closure0,
_S_token_closure1,
_S_token_line_begin,
_S_token_line_end,
_S_token_word_bound, // neg if _M_value[0] == 'n'
_S_token_comma,
_S_token_dup_count,
_S_token_eof,
_S_token_bracket_dash,
_S_token_unknown = -1u
};
protected:
typedef regex_constants::syntax_option_type _FlagT;
enum _StateT
{
_S_state_normal,
_S_state_in_brace,
_S_state_in_bracket,
};
protected:
_ScannerBase(_FlagT __flags)
: _M_state(_S_state_normal),
_M_flags(__flags),
_M_escape_tbl(_M_is_ecma()
? _M_ecma_escape_tbl
: _M_awk_escape_tbl),
_M_spec_char(_M_is_ecma()
? _M_ecma_spec_char
: _M_flags & regex_constants::basic
? _M_basic_spec_char
: _M_flags & regex_constants::extended
? _M_extended_spec_char
: _M_flags & regex_constants::grep
? ".[\\*^$\n"
: _M_flags & regex_constants::egrep
? ".[\\()*+?{|^$\n"
: _M_flags & regex_constants::awk
? _M_extended_spec_char
: nullptr),
_M_at_bracket_start(false)
{ __glibcxx_assert(_M_spec_char); }
protected:
const char*
_M_find_escape(char __c)
{
auto __it = _M_escape_tbl;
for (; __it->first != '\0'; ++__it)
if (__it->first == __c)
return &__it->second;
return nullptr;
}
bool
_M_is_ecma() const
{ return _M_flags & regex_constants::ECMAScript; }
bool
_M_is_basic() const
{ return _M_flags & (regex_constants::basic | regex_constants::grep); }
bool
_M_is_extended() const
{
return _M_flags & (regex_constants::extended
| regex_constants::egrep
| regex_constants::awk);
}
bool
_M_is_grep() const
{ return _M_flags & (regex_constants::grep | regex_constants::egrep); }
bool
_M_is_awk() const
{ return _M_flags & regex_constants::awk; }
protected:
// TODO: Make them static in the next abi change.
const std::pair<char, _TokenT> _M_token_tbl[9] =
{
{'^', _S_token_line_begin},
{'$', _S_token_line_end},
{'.', _S_token_anychar},
{'*', _S_token_closure0},
{'+', _S_token_closure1},
{'?', _S_token_opt},
{'|', _S_token_or},
{'\n', _S_token_or}, // grep and egrep
{'\0', _S_token_or},
};
const std::pair<char, char> _M_ecma_escape_tbl[8] =
{
{'0', '\0'},
{'b', '\b'},
{'f', '\f'},
{'n', '\n'},
{'r', '\r'},
{'t', '\t'},
{'v', '\v'},
{'\0', '\0'},
};
const std::pair<char, char> _M_awk_escape_tbl[11] =
{
{'"', '"'},
{'/', '/'},
{'\\', '\\'},
{'a', '\a'},
{'b', '\b'},
{'f', '\f'},
{'n', '\n'},
{'r', '\r'},
{'t', '\t'},
{'v', '\v'},
{'\0', '\0'},
};
const char* _M_ecma_spec_char = "^$\\.*+?()[]{}|";
const char* _M_basic_spec_char = ".[\\*^$";
const char* _M_extended_spec_char = ".[\\()*+?{|^$";
_StateT _M_state;
_FlagT _M_flags;
_TokenT _M_token;
const std::pair<char, char>* _M_escape_tbl;
const char* _M_spec_char;
bool _M_at_bracket_start;
};
/**
* @brief Scans an input range for regex tokens.
*
* The %_Scanner class interprets the regular expression pattern in
* the input range passed to its constructor as a sequence of parse
* tokens passed to the regular expression compiler. The sequence
* of tokens provided depends on the flag settings passed to the
* constructor: different regular expression grammars will interpret
* the same input pattern in syntactically different ways.
*/
template<typename _CharT>
class _Scanner
: public _ScannerBase
{
public:
typedef const _CharT* _IterT;
typedef std::basic_string<_CharT> _StringT;
typedef regex_constants::syntax_option_type _FlagT;
typedef const std::ctype<_CharT> _CtypeT;
_Scanner(_IterT __begin, _IterT __end,
_FlagT __flags, std::locale __loc);
void
_M_advance();
_TokenT
_M_get_token() const
{ return _M_token; }
const _StringT&
_M_get_value() const
{ return _M_value; }
#ifdef _GLIBCXX_DEBUG
std::ostream&
_M_print(std::ostream&);
#endif
private:
void
_M_scan_normal();
void
_M_scan_in_bracket();
void
_M_scan_in_brace();
void
_M_eat_escape_ecma();
void
_M_eat_escape_posix();
void
_M_eat_escape_awk();
void
_M_eat_class(char);
_IterT _M_current;
_IterT _M_end;
_CtypeT& _M_ctype;
_StringT _M_value;
void (_Scanner::* _M_eat_escape)();
};
//@} regex-detail
} // namespace __detail
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#include <bits/regex_scanner.tcc>
c++/8/bits/regex_error.h 0000644 00000011450 15201526705 0010724 0 ustar 00 // class template regex -*- C++ -*-
// Copyright (C) 2010-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/**
* @file bits/regex_error.h
* @brief Error and exception objects for the std regex library.
*
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{regex}
*/
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @addtogroup regex
* @{
*/
namespace regex_constants
{
/**
* @name 5.3 Error Types
*/
//@{
enum error_type
{
_S_error_collate,
_S_error_ctype,
_S_error_escape,
_S_error_backref,
_S_error_brack,
_S_error_paren,
_S_error_brace,
_S_error_badbrace,
_S_error_range,
_S_error_space,
_S_error_badrepeat,
_S_error_complexity,
_S_error_stack,
};
/** The expression contained an invalid collating element name. */
constexpr error_type error_collate(_S_error_collate);
/** The expression contained an invalid character class name. */
constexpr error_type error_ctype(_S_error_ctype);
/**
* The expression contained an invalid escaped character, or a trailing
* escape.
*/
constexpr error_type error_escape(_S_error_escape);
/** The expression contained an invalid back reference. */
constexpr error_type error_backref(_S_error_backref);
/** The expression contained mismatched [ and ]. */
constexpr error_type error_brack(_S_error_brack);
/** The expression contained mismatched ( and ). */
constexpr error_type error_paren(_S_error_paren);
/** The expression contained mismatched { and } */
constexpr error_type error_brace(_S_error_brace);
/** The expression contained an invalid range in a {} expression. */
constexpr error_type error_badbrace(_S_error_badbrace);
/**
* The expression contained an invalid character range,
* such as [b-a] in most encodings.
*/
constexpr error_type error_range(_S_error_range);
/**
* There was insufficient memory to convert the expression into a
* finite state machine.
*/
constexpr error_type error_space(_S_error_space);
/**
* One of <em>*?+{</em> was not preceded by a valid regular expression.
*/
constexpr error_type error_badrepeat(_S_error_badrepeat);
/**
* The complexity of an attempted match against a regular expression
* exceeded a pre-set level.
*/
constexpr error_type error_complexity(_S_error_complexity);
/**
* There was insufficient memory to determine whether the
* regular expression could match the specified character sequence.
*/
constexpr error_type error_stack(_S_error_stack);
//@}
} // namespace regex_constants
// [7.8] Class regex_error
/**
* @brief A regular expression exception class.
* @ingroup exceptions
*
* The regular expression library throws objects of this class on error.
*/
class regex_error : public std::runtime_error
{
regex_constants::error_type _M_code;
public:
/**
* @brief Constructs a regex_error object.
*
* @param __ecode the regex error code.
*/
explicit
regex_error(regex_constants::error_type __ecode);
virtual ~regex_error() throw();
/**
* @brief Gets the regex error code.
*
* @returns the regex error code.
*/
regex_constants::error_type
code() const
{ return _M_code; }
private:
regex_error(regex_constants::error_type __ecode, const char* __what)
: std::runtime_error(__what), _M_code(__ecode)
{ }
friend void __throw_regex_error(regex_constants::error_type, const char*);
};
//@} // group regex
void
__throw_regex_error(regex_constants::error_type __ecode);
inline void
__throw_regex_error(regex_constants::error_type __ecode, const char* __what)
{ _GLIBCXX_THROW_OR_ABORT(regex_error(__ecode, __what)); }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
c++/8/bits/specfun.h 0000644 00000133713 15201526705 0010053 0 ustar 00 // Mathematical Special Functions for -*- C++ -*-
// Copyright (C) 2006-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/specfun.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{cmath}
*/
#ifndef _GLIBCXX_BITS_SPECFUN_H
#define _GLIBCXX_BITS_SPECFUN_H 1
#pragma GCC visibility push(default)
#include <bits/c++config.h>
#define __STDCPP_MATH_SPEC_FUNCS__ 201003L
#define __cpp_lib_math_special_functions 201603L
#if __cplusplus <= 201403L && __STDCPP_WANT_MATH_SPEC_FUNCS__ == 0
# error include <cmath> and define __STDCPP_WANT_MATH_SPEC_FUNCS__
#endif
#include <bits/stl_algobase.h>
#include <limits>
#include <type_traits>
#include <tr1/gamma.tcc>
#include <tr1/bessel_function.tcc>
#include <tr1/beta_function.tcc>
#include <tr1/ell_integral.tcc>
#include <tr1/exp_integral.tcc>
#include <tr1/hypergeometric.tcc>
#include <tr1/legendre_function.tcc>
#include <tr1/modified_bessel_func.tcc>
#include <tr1/poly_hermite.tcc>
#include <tr1/poly_laguerre.tcc>
#include <tr1/riemann_zeta.tcc>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @defgroup mathsf Mathematical Special Functions
* @ingroup numerics
*
* A collection of advanced mathematical special functions,
* defined by ISO/IEC IS 29124.
* @{
*/
/**
* @mainpage Mathematical Special Functions
*
* @section intro Introduction and History
* The first significant library upgrade on the road to C++2011,
* <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1836.pdf">
* TR1</a>, included a set of 23 mathematical functions that significantly
* extended the standard transcendental functions inherited from C and declared
* in @<cmath@>.
*
* Although most components from TR1 were eventually adopted for C++11 these
* math functions were left behind out of concern for implementability.
* The math functions were published as a separate international standard
* <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2010/n3060.pdf">
* IS 29124 - Extensions to the C++ Library to Support Mathematical Special
* Functions</a>.
*
* For C++17 these functions were incorporated into the main standard.
*
* @section contents Contents
* The following functions are implemented in namespace @c std:
* - @ref assoc_laguerre "assoc_laguerre - Associated Laguerre functions"
* - @ref assoc_legendre "assoc_legendre - Associated Legendre functions"
* - @ref beta "beta - Beta functions"
* - @ref comp_ellint_1 "comp_ellint_1 - Complete elliptic functions of the first kind"
* - @ref comp_ellint_2 "comp_ellint_2 - Complete elliptic functions of the second kind"
* - @ref comp_ellint_3 "comp_ellint_3 - Complete elliptic functions of the third kind"
* - @ref cyl_bessel_i "cyl_bessel_i - Regular modified cylindrical Bessel functions"
* - @ref cyl_bessel_j "cyl_bessel_j - Cylindrical Bessel functions of the first kind"
* - @ref cyl_bessel_k "cyl_bessel_k - Irregular modified cylindrical Bessel functions"
* - @ref cyl_neumann "cyl_neumann - Cylindrical Neumann functions or Cylindrical Bessel functions of the second kind"
* - @ref ellint_1 "ellint_1 - Incomplete elliptic functions of the first kind"
* - @ref ellint_2 "ellint_2 - Incomplete elliptic functions of the second kind"
* - @ref ellint_3 "ellint_3 - Incomplete elliptic functions of the third kind"
* - @ref expint "expint - The exponential integral"
* - @ref hermite "hermite - Hermite polynomials"
* - @ref laguerre "laguerre - Laguerre functions"
* - @ref legendre "legendre - Legendre polynomials"
* - @ref riemann_zeta "riemann_zeta - The Riemann zeta function"
* - @ref sph_bessel "sph_bessel - Spherical Bessel functions"
* - @ref sph_legendre "sph_legendre - Spherical Legendre functions"
* - @ref sph_neumann "sph_neumann - Spherical Neumann functions"
*
* The hypergeometric functions were stricken from the TR29124 and C++17
* versions of this math library because of implementation concerns.
* However, since they were in the TR1 version and since they are popular
* we kept them as an extension in namespace @c __gnu_cxx:
* - @ref __gnu_cxx::conf_hyperg "conf_hyperg - Confluent hypergeometric functions"
* - @ref __gnu_cxx::hyperg "hyperg - Hypergeometric functions"
*
* @section general General Features
*
* @subsection promotion Argument Promotion
* The arguments suppled to the non-suffixed functions will be promoted
* according to the following rules:
* 1. If any argument intended to be floating point is given an integral value
* That integral value is promoted to double.
* 2. All floating point arguments are promoted up to the largest floating
* point precision among them.
*
* @subsection NaN NaN Arguments
* If any of the floating point arguments supplied to these functions is
* invalid or NaN (std::numeric_limits<Tp>::quiet_NaN),
* the value NaN is returned.
*
* @section impl Implementation
*
* We strive to implement the underlying math with type generic algorithms
* to the greatest extent possible. In practice, the functions are thin
* wrappers that dispatch to function templates. Type dependence is
* controlled with std::numeric_limits and functions thereof.
*
* We don't promote @c float to @c double or @c double to <tt>long double</tt>
* reflexively. The goal is for @c float functions to operate more quickly,
* at the cost of @c float accuracy and possibly a smaller domain of validity.
* Similaryly, <tt>long double</tt> should give you more dynamic range
* and slightly more pecision than @c double on many systems.
*
* @section testing Testing
*
* These functions have been tested against equivalent implementations
* from the <a href="http://www.gnu.org/software/gsl">
* Gnu Scientific Library, GSL</a> and
* <a href="http://www.boost.org/doc/libs/1_60_0/libs/math/doc/html/index.html>Boost</a>
* and the ratio
* @f[
* \frac{|f - f_{test}|}{|f_{test}|}
* @f]
* is generally found to be within 10^-15 for 64-bit double on linux-x86_64 systems
* over most of the ranges of validity.
*
* @todo Provide accuracy comparisons on a per-function basis for a small
* number of targets.
*
* @section bibliography General Bibliography
*
* @see Abramowitz and Stegun: Handbook of Mathematical Functions,
* with Formulas, Graphs, and Mathematical Tables
* Edited by Milton Abramowitz and Irene A. Stegun,
* National Bureau of Standards Applied Mathematics Series - 55
* Issued June 1964, Tenth Printing, December 1972, with corrections
* Electronic versions of A&S abound including both pdf and navigable html.
* @see for example http://people.math.sfu.ca/~cbm/aands/
*
* @see The old A&S has been redone as the
* NIST Digital Library of Mathematical Functions: http://dlmf.nist.gov/
* This version is far more navigable and includes more recent work.
*
* @see An Atlas of Functions: with Equator, the Atlas Function Calculator
* 2nd Edition, by Oldham, Keith B., Myland, Jan, Spanier, Jerome
*
* @see Asymptotics and Special Functions by Frank W. J. Olver,
* Academic Press, 1974
*
* @see Numerical Recipes in C, The Art of Scientific Computing,
* by William H. Press, Second Ed., Saul A. Teukolsky,
* William T. Vetterling, and Brian P. Flannery,
* Cambridge University Press, 1992
*
* @see The Special Functions and Their Approximations: Volumes 1 and 2,
* by Yudell L. Luke, Academic Press, 1969
*/
// Associated Laguerre polynomials
/**
* Return the associated Laguerre polynomial of order @c n,
* degree @c m: @f$ L_n^m(x) @f$ for @c float argument.
*
* @see assoc_laguerre for more details.
*/
inline float
assoc_laguerref(unsigned int __n, unsigned int __m, float __x)
{ return __detail::__assoc_laguerre<float>(__n, __m, __x); }
/**
* Return the associated Laguerre polynomial of order @c n,
* degree @c m: @f$ L_n^m(x) @f$.
*
* @see assoc_laguerre for more details.
*/
inline long double
assoc_laguerrel(unsigned int __n, unsigned int __m, long double __x)
{ return __detail::__assoc_laguerre<long double>(__n, __m, __x); }
/**
* Return the associated Laguerre polynomial of nonnegative order @c n,
* nonnegative degree @c m and real argument @c x: @f$ L_n^m(x) @f$.
*
* The associated Laguerre function of real degree @f$ \alpha @f$,
* @f$ L_n^\alpha(x) @f$, is defined by
* @f[
* L_n^\alpha(x) = \frac{(\alpha + 1)_n}{n!}
* {}_1F_1(-n; \alpha + 1; x)
* @f]
* where @f$ (\alpha)_n @f$ is the Pochhammer symbol and
* @f$ {}_1F_1(a; c; x) @f$ is the confluent hypergeometric function.
*
* The associated Laguerre polynomial is defined for integral
* degree @f$ \alpha = m @f$ by:
* @f[
* L_n^m(x) = (-1)^m \frac{d^m}{dx^m} L_{n + m}(x)
* @f]
* where the Laguerre polynomial is defined by:
* @f[
* L_n(x) = \frac{e^x}{n!} \frac{d^n}{dx^n} (x^ne^{-x})
* @f]
* and @f$ x >= 0 @f$.
* @see laguerre for details of the Laguerre function of degree @c n
*
* @tparam _Tp The floating-point type of the argument @c __x.
* @param __n The order of the Laguerre function, <tt>__n >= 0</tt>.
* @param __m The degree of the Laguerre function, <tt>__m >= 0</tt>.
* @param __x The argument of the Laguerre function, <tt>__x >= 0</tt>.
* @throw std::domain_error if <tt>__x < 0</tt>.
*/
template<typename _Tp>
inline typename __gnu_cxx::__promote<_Tp>::__type
assoc_laguerre(unsigned int __n, unsigned int __m, _Tp __x)
{
typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
return __detail::__assoc_laguerre<__type>(__n, __m, __x);
}
// Associated Legendre functions
/**
* Return the associated Legendre function of degree @c l and order @c m
* for @c float argument.
*
* @see assoc_legendre for more details.
*/
inline float
assoc_legendref(unsigned int __l, unsigned int __m, float __x)
{ return __detail::__assoc_legendre_p<float>(__l, __m, __x); }
/**
* Return the associated Legendre function of degree @c l and order @c m.
*
* @see assoc_legendre for more details.
*/
inline long double
assoc_legendrel(unsigned int __l, unsigned int __m, long double __x)
{ return __detail::__assoc_legendre_p<long double>(__l, __m, __x); }
/**
* Return the associated Legendre function of degree @c l and order @c m.
*
* The associated Legendre function is derived from the Legendre function
* @f$ P_l(x) @f$ by the Rodrigues formula:
* @f[
* P_l^m(x) = (1 - x^2)^{m/2}\frac{d^m}{dx^m}P_l(x)
* @f]
* @see legendre for details of the Legendre function of degree @c l
*
* @tparam _Tp The floating-point type of the argument @c __x.
* @param __l The degree <tt>__l >= 0</tt>.
* @param __m The order <tt>__m <= l</tt>.
* @param __x The argument, <tt>abs(__x) <= 1</tt>.
* @throw std::domain_error if <tt>abs(__x) > 1</tt>.
*/
template<typename _Tp>
inline typename __gnu_cxx::__promote<_Tp>::__type
assoc_legendre(unsigned int __l, unsigned int __m, _Tp __x)
{
typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
return __detail::__assoc_legendre_p<__type>(__l, __m, __x);
}
// Beta functions
/**
* Return the beta function, @f$ B(a,b) @f$, for @c float parameters @c a, @c b.
*
* @see beta for more details.
*/
inline float
betaf(float __a, float __b)
{ return __detail::__beta<float>(__a, __b); }
/**
* Return the beta function, @f$B(a,b)@f$, for long double
* parameters @c a, @c b.
*
* @see beta for more details.
*/
inline long double
betal(long double __a, long double __b)
{ return __detail::__beta<long double>(__a, __b); }
/**
* Return the beta function, @f$B(a,b)@f$, for real parameters @c a, @c b.
*
* The beta function is defined by
* @f[
* B(a,b) = \int_0^1 t^{a - 1} (1 - t)^{b - 1} dt
* = \frac{\Gamma(a)\Gamma(b)}{\Gamma(a+b)}
* @f]
* where @f$ a > 0 @f$ and @f$ b > 0 @f$
*
* @tparam _Tpa The floating-point type of the parameter @c __a.
* @tparam _Tpb The floating-point type of the parameter @c __b.
* @param __a The first argument of the beta function, <tt> __a > 0 </tt>.
* @param __b The second argument of the beta function, <tt> __b > 0 </tt>.
* @throw std::domain_error if <tt> __a < 0 </tt> or <tt> __b < 0 </tt>.
*/
template<typename _Tpa, typename _Tpb>
inline typename __gnu_cxx::__promote_2<_Tpa, _Tpb>::__type
beta(_Tpa __a, _Tpb __b)
{
typedef typename __gnu_cxx::__promote_2<_Tpa, _Tpb>::__type __type;
return __detail::__beta<__type>(__a, __b);
}
// Complete elliptic integrals of the first kind
/**
* Return the complete elliptic integral of the first kind @f$ E(k) @f$
* for @c float modulus @c k.
*
* @see comp_ellint_1 for details.
*/
inline float
comp_ellint_1f(float __k)
{ return __detail::__comp_ellint_1<float>(__k); }
/**
* Return the complete elliptic integral of the first kind @f$ E(k) @f$
* for long double modulus @c k.
*
* @see comp_ellint_1 for details.
*/
inline long double
comp_ellint_1l(long double __k)
{ return __detail::__comp_ellint_1<long double>(__k); }
/**
* Return the complete elliptic integral of the first kind
* @f$ K(k) @f$ for real modulus @c k.
*
* The complete elliptic integral of the first kind is defined as
* @f[
* K(k) = F(k,\pi/2) = \int_0^{\pi/2}\frac{d\theta}
* {\sqrt{1 - k^2 sin^2\theta}}
* @f]
* where @f$ F(k,\phi) @f$ is the incomplete elliptic integral of the
* first kind and the modulus @f$ |k| <= 1 @f$.
* @see ellint_1 for details of the incomplete elliptic function
* of the first kind.
*
* @tparam _Tp The floating-point type of the modulus @c __k.
* @param __k The modulus, <tt> abs(__k) <= 1 </tt>
* @throw std::domain_error if <tt> abs(__k) > 1 </tt>.
*/
template<typename _Tp>
inline typename __gnu_cxx::__promote<_Tp>::__type
comp_ellint_1(_Tp __k)
{
typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
return __detail::__comp_ellint_1<__type>(__k);
}
// Complete elliptic integrals of the second kind
/**
* Return the complete elliptic integral of the second kind @f$ E(k) @f$
* for @c float modulus @c k.
*
* @see comp_ellint_2 for details.
*/
inline float
comp_ellint_2f(float __k)
{ return __detail::__comp_ellint_2<float>(__k); }
/**
* Return the complete elliptic integral of the second kind @f$ E(k) @f$
* for long double modulus @c k.
*
* @see comp_ellint_2 for details.
*/
inline long double
comp_ellint_2l(long double __k)
{ return __detail::__comp_ellint_2<long double>(__k); }
/**
* Return the complete elliptic integral of the second kind @f$ E(k) @f$
* for real modulus @c k.
*
* The complete elliptic integral of the second kind is defined as
* @f[
* E(k) = E(k,\pi/2) = \int_0^{\pi/2}\sqrt{1 - k^2 sin^2\theta}
* @f]
* where @f$ E(k,\phi) @f$ is the incomplete elliptic integral of the
* second kind and the modulus @f$ |k| <= 1 @f$.
* @see ellint_2 for details of the incomplete elliptic function
* of the second kind.
*
* @tparam _Tp The floating-point type of the modulus @c __k.
* @param __k The modulus, @c abs(__k) <= 1
* @throw std::domain_error if @c abs(__k) > 1.
*/
template<typename _Tp>
inline typename __gnu_cxx::__promote<_Tp>::__type
comp_ellint_2(_Tp __k)
{
typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
return __detail::__comp_ellint_2<__type>(__k);
}
// Complete elliptic integrals of the third kind
/**
* @brief Return the complete elliptic integral of the third kind
* @f$ \Pi(k,\nu) @f$ for @c float modulus @c k.
*
* @see comp_ellint_3 for details.
*/
inline float
comp_ellint_3f(float __k, float __nu)
{ return __detail::__comp_ellint_3<float>(__k, __nu); }
/**
* @brief Return the complete elliptic integral of the third kind
* @f$ \Pi(k,\nu) @f$ for <tt>long double</tt> modulus @c k.
*
* @see comp_ellint_3 for details.
*/
inline long double
comp_ellint_3l(long double __k, long double __nu)
{ return __detail::__comp_ellint_3<long double>(__k, __nu); }
/**
* Return the complete elliptic integral of the third kind
* @f$ \Pi(k,\nu) = \Pi(k,\nu,\pi/2) @f$ for real modulus @c k.
*
* The complete elliptic integral of the third kind is defined as
* @f[
* \Pi(k,\nu) = \Pi(k,\nu,\pi/2) = \int_0^{\pi/2}
* \frac{d\theta}
* {(1 - \nu \sin^2\theta)\sqrt{1 - k^2 \sin^2\theta}}
* @f]
* where @f$ \Pi(k,\nu,\phi) @f$ is the incomplete elliptic integral of the
* second kind and the modulus @f$ |k| <= 1 @f$.
* @see ellint_3 for details of the incomplete elliptic function
* of the third kind.
*
* @tparam _Tp The floating-point type of the modulus @c __k.
* @tparam _Tpn The floating-point type of the argument @c __nu.
* @param __k The modulus, @c abs(__k) <= 1
* @param __nu The argument
* @throw std::domain_error if @c abs(__k) > 1.
*/
template<typename _Tp, typename _Tpn>
inline typename __gnu_cxx::__promote_2<_Tp, _Tpn>::__type
comp_ellint_3(_Tp __k, _Tpn __nu)
{
typedef typename __gnu_cxx::__promote_2<_Tp, _Tpn>::__type __type;
return __detail::__comp_ellint_3<__type>(__k, __nu);
}
// Regular modified cylindrical Bessel functions
/**
* Return the regular modified Bessel function @f$ I_{\nu}(x) @f$
* for @c float order @f$ \nu @f$ and argument @f$ x >= 0 @f$.
*
* @see cyl_bessel_i for setails.
*/
inline float
cyl_bessel_if(float __nu, float __x)
{ return __detail::__cyl_bessel_i<float>(__nu, __x); }
/**
* Return the regular modified Bessel function @f$ I_{\nu}(x) @f$
* for <tt>long double</tt> order @f$ \nu @f$ and argument @f$ x >= 0 @f$.
*
* @see cyl_bessel_i for setails.
*/
inline long double
cyl_bessel_il(long double __nu, long double __x)
{ return __detail::__cyl_bessel_i<long double>(__nu, __x); }
/**
* Return the regular modified Bessel function @f$ I_{\nu}(x) @f$
* for real order @f$ \nu @f$ and argument @f$ x >= 0 @f$.
*
* The regular modified cylindrical Bessel function is:
* @f[
* I_{\nu}(x) = i^{-\nu}J_\nu(ix) = \sum_{k=0}^{\infty}
* \frac{(x/2)^{\nu + 2k}}{k!\Gamma(\nu+k+1)}
* @f]
*
* @tparam _Tpnu The floating-point type of the order @c __nu.
* @tparam _Tp The floating-point type of the argument @c __x.
* @param __nu The order
* @param __x The argument, <tt> __x >= 0 </tt>
* @throw std::domain_error if <tt> __x < 0 </tt>.
*/
template<typename _Tpnu, typename _Tp>
inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
cyl_bessel_i(_Tpnu __nu, _Tp __x)
{
typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
return __detail::__cyl_bessel_i<__type>(__nu, __x);
}
// Cylindrical Bessel functions (of the first kind)
/**
* Return the Bessel function of the first kind @f$ J_{\nu}(x) @f$
* for @c float order @f$ \nu @f$ and argument @f$ x >= 0 @f$.
*
* @see cyl_bessel_j for setails.
*/
inline float
cyl_bessel_jf(float __nu, float __x)
{ return __detail::__cyl_bessel_j<float>(__nu, __x); }
/**
* Return the Bessel function of the first kind @f$ J_{\nu}(x) @f$
* for <tt>long double</tt> order @f$ \nu @f$ and argument @f$ x >= 0 @f$.
*
* @see cyl_bessel_j for setails.
*/
inline long double
cyl_bessel_jl(long double __nu, long double __x)
{ return __detail::__cyl_bessel_j<long double>(__nu, __x); }
/**
* Return the Bessel function @f$ J_{\nu}(x) @f$ of real order @f$ \nu @f$
* and argument @f$ x >= 0 @f$.
*
* The cylindrical Bessel function is:
* @f[
* J_{\nu}(x) = \sum_{k=0}^{\infty}
* \frac{(-1)^k (x/2)^{\nu + 2k}}{k!\Gamma(\nu+k+1)}
* @f]
*
* @tparam _Tpnu The floating-point type of the order @c __nu.
* @tparam _Tp The floating-point type of the argument @c __x.
* @param __nu The order
* @param __x The argument, <tt> __x >= 0 </tt>
* @throw std::domain_error if <tt> __x < 0 </tt>.
*/
template<typename _Tpnu, typename _Tp>
inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
cyl_bessel_j(_Tpnu __nu, _Tp __x)
{
typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
return __detail::__cyl_bessel_j<__type>(__nu, __x);
}
// Irregular modified cylindrical Bessel functions
/**
* Return the irregular modified Bessel function @f$ K_{\nu}(x) @f$
* for @c float order @f$ \nu @f$ and argument @f$ x >= 0 @f$.
*
* @see cyl_bessel_k for setails.
*/
inline float
cyl_bessel_kf(float __nu, float __x)
{ return __detail::__cyl_bessel_k<float>(__nu, __x); }
/**
* Return the irregular modified Bessel function @f$ K_{\nu}(x) @f$
* for <tt>long double</tt> order @f$ \nu @f$ and argument @f$ x >= 0 @f$.
*
* @see cyl_bessel_k for setails.
*/
inline long double
cyl_bessel_kl(long double __nu, long double __x)
{ return __detail::__cyl_bessel_k<long double>(__nu, __x); }
/**
* Return the irregular modified Bessel function @f$ K_{\nu}(x) @f$
* of real order @f$ \nu @f$ and argument @f$ x @f$.
*
* The irregular modified Bessel function is defined by:
* @f[
* K_{\nu}(x) = \frac{\pi}{2}
* \frac{I_{-\nu}(x) - I_{\nu}(x)}{\sin \nu\pi}
* @f]
* where for integral @f$ \nu = n @f$ a limit is taken:
* @f$ lim_{\nu \to n} @f$.
* For negative argument we have simply:
* @f[
* K_{-\nu}(x) = K_{\nu}(x)
* @f]
*
* @tparam _Tpnu The floating-point type of the order @c __nu.
* @tparam _Tp The floating-point type of the argument @c __x.
* @param __nu The order
* @param __x The argument, <tt> __x >= 0 </tt>
* @throw std::domain_error if <tt> __x < 0 </tt>.
*/
template<typename _Tpnu, typename _Tp>
inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
cyl_bessel_k(_Tpnu __nu, _Tp __x)
{
typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
return __detail::__cyl_bessel_k<__type>(__nu, __x);
}
// Cylindrical Neumann functions
/**
* Return the Neumann function @f$ N_{\nu}(x) @f$
* of @c float order @f$ \nu @f$ and argument @f$ x @f$.
*
* @see cyl_neumann for setails.
*/
inline float
cyl_neumannf(float __nu, float __x)
{ return __detail::__cyl_neumann_n<float>(__nu, __x); }
/**
* Return the Neumann function @f$ N_{\nu}(x) @f$
* of <tt>long double</tt> order @f$ \nu @f$ and argument @f$ x @f$.
*
* @see cyl_neumann for setails.
*/
inline long double
cyl_neumannl(long double __nu, long double __x)
{ return __detail::__cyl_neumann_n<long double>(__nu, __x); }
/**
* Return the Neumann function @f$ N_{\nu}(x) @f$
* of real order @f$ \nu @f$ and argument @f$ x >= 0 @f$.
*
* The Neumann function is defined by:
* @f[
* N_{\nu}(x) = \frac{J_{\nu}(x) \cos \nu\pi - J_{-\nu}(x)}
* {\sin \nu\pi}
* @f]
* where @f$ x >= 0 @f$ and for integral order @f$ \nu = n @f$
* a limit is taken: @f$ lim_{\nu \to n} @f$.
*
* @tparam _Tpnu The floating-point type of the order @c __nu.
* @tparam _Tp The floating-point type of the argument @c __x.
* @param __nu The order
* @param __x The argument, <tt> __x >= 0 </tt>
* @throw std::domain_error if <tt> __x < 0 </tt>.
*/
template<typename _Tpnu, typename _Tp>
inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
cyl_neumann(_Tpnu __nu, _Tp __x)
{
typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
return __detail::__cyl_neumann_n<__type>(__nu, __x);
}
// Incomplete elliptic integrals of the first kind
/**
* Return the incomplete elliptic integral of the first kind @f$ E(k,\phi) @f$
* for @c float modulus @f$ k @f$ and angle @f$ \phi @f$.
*
* @see ellint_1 for details.
*/
inline float
ellint_1f(float __k, float __phi)
{ return __detail::__ellint_1<float>(__k, __phi); }
/**
* Return the incomplete elliptic integral of the first kind @f$ E(k,\phi) @f$
* for <tt>long double</tt> modulus @f$ k @f$ and angle @f$ \phi @f$.
*
* @see ellint_1 for details.
*/
inline long double
ellint_1l(long double __k, long double __phi)
{ return __detail::__ellint_1<long double>(__k, __phi); }
/**
* Return the incomplete elliptic integral of the first kind @f$ F(k,\phi) @f$
* for @c real modulus @f$ k @f$ and angle @f$ \phi @f$.
*
* The incomplete elliptic integral of the first kind is defined as
* @f[
* F(k,\phi) = \int_0^{\phi}\frac{d\theta}
* {\sqrt{1 - k^2 sin^2\theta}}
* @f]
* For @f$ \phi= \pi/2 @f$ this becomes the complete elliptic integral of
* the first kind, @f$ K(k) @f$. @see comp_ellint_1.
*
* @tparam _Tp The floating-point type of the modulus @c __k.
* @tparam _Tpp The floating-point type of the angle @c __phi.
* @param __k The modulus, <tt> abs(__k) <= 1 </tt>
* @param __phi The integral limit argument in radians
* @throw std::domain_error if <tt> abs(__k) > 1 </tt>.
*/
template<typename _Tp, typename _Tpp>
inline typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type
ellint_1(_Tp __k, _Tpp __phi)
{
typedef typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type __type;
return __detail::__ellint_1<__type>(__k, __phi);
}
// Incomplete elliptic integrals of the second kind
/**
* @brief Return the incomplete elliptic integral of the second kind
* @f$ E(k,\phi) @f$ for @c float argument.
*
* @see ellint_2 for details.
*/
inline float
ellint_2f(float __k, float __phi)
{ return __detail::__ellint_2<float>(__k, __phi); }
/**
* @brief Return the incomplete elliptic integral of the second kind
* @f$ E(k,\phi) @f$.
*
* @see ellint_2 for details.
*/
inline long double
ellint_2l(long double __k, long double __phi)
{ return __detail::__ellint_2<long double>(__k, __phi); }
/**
* Return the incomplete elliptic integral of the second kind
* @f$ E(k,\phi) @f$.
*
* The incomplete elliptic integral of the second kind is defined as
* @f[
* E(k,\phi) = \int_0^{\phi} \sqrt{1 - k^2 sin^2\theta}
* @f]
* For @f$ \phi= \pi/2 @f$ this becomes the complete elliptic integral of
* the second kind, @f$ E(k) @f$. @see comp_ellint_2.
*
* @tparam _Tp The floating-point type of the modulus @c __k.
* @tparam _Tpp The floating-point type of the angle @c __phi.
* @param __k The modulus, <tt> abs(__k) <= 1 </tt>
* @param __phi The integral limit argument in radians
* @return The elliptic function of the second kind.
* @throw std::domain_error if <tt> abs(__k) > 1 </tt>.
*/
template<typename _Tp, typename _Tpp>
inline typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type
ellint_2(_Tp __k, _Tpp __phi)
{
typedef typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type __type;
return __detail::__ellint_2<__type>(__k, __phi);
}
// Incomplete elliptic integrals of the third kind
/**
* @brief Return the incomplete elliptic integral of the third kind
* @f$ \Pi(k,\nu,\phi) @f$ for @c float argument.
*
* @see ellint_3 for details.
*/
inline float
ellint_3f(float __k, float __nu, float __phi)
{ return __detail::__ellint_3<float>(__k, __nu, __phi); }
/**
* @brief Return the incomplete elliptic integral of the third kind
* @f$ \Pi(k,\nu,\phi) @f$.
*
* @see ellint_3 for details.
*/
inline long double
ellint_3l(long double __k, long double __nu, long double __phi)
{ return __detail::__ellint_3<long double>(__k, __nu, __phi); }
/**
* @brief Return the incomplete elliptic integral of the third kind
* @f$ \Pi(k,\nu,\phi) @f$.
*
* The incomplete elliptic integral of the third kind is defined by:
* @f[
* \Pi(k,\nu,\phi) = \int_0^{\phi}
* \frac{d\theta}
* {(1 - \nu \sin^2\theta)
* \sqrt{1 - k^2 \sin^2\theta}}
* @f]
* For @f$ \phi= \pi/2 @f$ this becomes the complete elliptic integral of
* the third kind, @f$ \Pi(k,\nu) @f$. @see comp_ellint_3.
*
* @tparam _Tp The floating-point type of the modulus @c __k.
* @tparam _Tpn The floating-point type of the argument @c __nu.
* @tparam _Tpp The floating-point type of the angle @c __phi.
* @param __k The modulus, <tt> abs(__k) <= 1 </tt>
* @param __nu The second argument
* @param __phi The integral limit argument in radians
* @return The elliptic function of the third kind.
* @throw std::domain_error if <tt> abs(__k) > 1 </tt>.
*/
template<typename _Tp, typename _Tpn, typename _Tpp>
inline typename __gnu_cxx::__promote_3<_Tp, _Tpn, _Tpp>::__type
ellint_3(_Tp __k, _Tpn __nu, _Tpp __phi)
{
typedef typename __gnu_cxx::__promote_3<_Tp, _Tpn, _Tpp>::__type __type;
return __detail::__ellint_3<__type>(__k, __nu, __phi);
}
// Exponential integrals
/**
* Return the exponential integral @f$ Ei(x) @f$ for @c float argument @c x.
*
* @see expint for details.
*/
inline float
expintf(float __x)
{ return __detail::__expint<float>(__x); }
/**
* Return the exponential integral @f$ Ei(x) @f$
* for <tt>long double</tt> argument @c x.
*
* @see expint for details.
*/
inline long double
expintl(long double __x)
{ return __detail::__expint<long double>(__x); }
/**
* Return the exponential integral @f$ Ei(x) @f$ for @c real argument @c x.
*
* The exponential integral is given by
* \f[
* Ei(x) = -\int_{-x}^\infty \frac{e^t}{t} dt
* \f]
*
* @tparam _Tp The floating-point type of the argument @c __x.
* @param __x The argument of the exponential integral function.
*/
template<typename _Tp>
inline typename __gnu_cxx::__promote<_Tp>::__type
expint(_Tp __x)
{
typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
return __detail::__expint<__type>(__x);
}
// Hermite polynomials
/**
* Return the Hermite polynomial @f$ H_n(x) @f$ of nonnegative order n
* and float argument @c x.
*
* @see hermite for details.
*/
inline float
hermitef(unsigned int __n, float __x)
{ return __detail::__poly_hermite<float>(__n, __x); }
/**
* Return the Hermite polynomial @f$ H_n(x) @f$ of nonnegative order n
* and <tt>long double</tt> argument @c x.
*
* @see hermite for details.
*/
inline long double
hermitel(unsigned int __n, long double __x)
{ return __detail::__poly_hermite<long double>(__n, __x); }
/**
* Return the Hermite polynomial @f$ H_n(x) @f$ of order n
* and @c real argument @c x.
*
* The Hermite polynomial is defined by:
* @f[
* H_n(x) = (-1)^n e^{x^2} \frac{d^n}{dx^n} e^{-x^2}
* @f]
*
* The Hermite polynomial obeys a reflection formula:
* @f[
* H_n(-x) = (-1)^n H_n(x)
* @f]
*
* @tparam _Tp The floating-point type of the argument @c __x.
* @param __n The order
* @param __x The argument
*/
template<typename _Tp>
inline typename __gnu_cxx::__promote<_Tp>::__type
hermite(unsigned int __n, _Tp __x)
{
typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
return __detail::__poly_hermite<__type>(__n, __x);
}
// Laguerre polynomials
/**
* Returns the Laguerre polynomial @f$ L_n(x) @f$ of nonnegative degree @c n
* and @c float argument @f$ x >= 0 @f$.
*
* @see laguerre for more details.
*/
inline float
laguerref(unsigned int __n, float __x)
{ return __detail::__laguerre<float>(__n, __x); }
/**
* Returns the Laguerre polynomial @f$ L_n(x) @f$ of nonnegative degree @c n
* and <tt>long double</tt> argument @f$ x >= 0 @f$.
*
* @see laguerre for more details.
*/
inline long double
laguerrel(unsigned int __n, long double __x)
{ return __detail::__laguerre<long double>(__n, __x); }
/**
* Returns the Laguerre polynomial @f$ L_n(x) @f$
* of nonnegative degree @c n and real argument @f$ x >= 0 @f$.
*
* The Laguerre polynomial is defined by:
* @f[
* L_n(x) = \frac{e^x}{n!} \frac{d^n}{dx^n} (x^ne^{-x})
* @f]
*
* @tparam _Tp The floating-point type of the argument @c __x.
* @param __n The nonnegative order
* @param __x The argument <tt> __x >= 0 </tt>
* @throw std::domain_error if <tt> __x < 0 </tt>.
*/
template<typename _Tp>
inline typename __gnu_cxx::__promote<_Tp>::__type
laguerre(unsigned int __n, _Tp __x)
{
typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
return __detail::__laguerre<__type>(__n, __x);
}
// Legendre polynomials
/**
* Return the Legendre polynomial @f$ P_l(x) @f$ of nonnegative
* degree @f$ l @f$ and @c float argument @f$ |x| <= 0 @f$.
*
* @see legendre for more details.
*/
inline float
legendref(unsigned int __l, float __x)
{ return __detail::__poly_legendre_p<float>(__l, __x); }
/**
* Return the Legendre polynomial @f$ P_l(x) @f$ of nonnegative
* degree @f$ l @f$ and <tt>long double</tt> argument @f$ |x| <= 0 @f$.
*
* @see legendre for more details.
*/
inline long double
legendrel(unsigned int __l, long double __x)
{ return __detail::__poly_legendre_p<long double>(__l, __x); }
/**
* Return the Legendre polynomial @f$ P_l(x) @f$ of nonnegative
* degree @f$ l @f$ and real argument @f$ |x| <= 0 @f$.
*
* The Legendre function of order @f$ l @f$ and argument @f$ x @f$,
* @f$ P_l(x) @f$, is defined by:
* @f[
* P_l(x) = \frac{1}{2^l l!}\frac{d^l}{dx^l}(x^2 - 1)^{l}
* @f]
*
* @tparam _Tp The floating-point type of the argument @c __x.
* @param __l The degree @f$ l >= 0 @f$
* @param __x The argument @c abs(__x) <= 1
* @throw std::domain_error if @c abs(__x) > 1
*/
template<typename _Tp>
inline typename __gnu_cxx::__promote<_Tp>::__type
legendre(unsigned int __l, _Tp __x)
{
typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
return __detail::__poly_legendre_p<__type>(__l, __x);
}
// Riemann zeta functions
/**
* Return the Riemann zeta function @f$ \zeta(s) @f$
* for @c float argument @f$ s @f$.
*
* @see riemann_zeta for more details.
*/
inline float
riemann_zetaf(float __s)
{ return __detail::__riemann_zeta<float>(__s); }
/**
* Return the Riemann zeta function @f$ \zeta(s) @f$
* for <tt>long double</tt> argument @f$ s @f$.
*
* @see riemann_zeta for more details.
*/
inline long double
riemann_zetal(long double __s)
{ return __detail::__riemann_zeta<long double>(__s); }
/**
* Return the Riemann zeta function @f$ \zeta(s) @f$
* for real argument @f$ s @f$.
*
* The Riemann zeta function is defined by:
* @f[
* \zeta(s) = \sum_{k=1}^{\infty} k^{-s} \hbox{ for } s > 1
* @f]
* and
* @f[
* \zeta(s) = \frac{1}{1-2^{1-s}}\sum_{k=1}^{\infty}(-1)^{k-1}k^{-s}
* \hbox{ for } 0 <= s <= 1
* @f]
* For s < 1 use the reflection formula:
* @f[
* \zeta(s) = 2^s \pi^{s-1} \sin(\frac{\pi s}{2}) \Gamma(1-s) \zeta(1-s)
* @f]
*
* @tparam _Tp The floating-point type of the argument @c __s.
* @param __s The argument <tt> s != 1 </tt>
*/
template<typename _Tp>
inline typename __gnu_cxx::__promote<_Tp>::__type
riemann_zeta(_Tp __s)
{
typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
return __detail::__riemann_zeta<__type>(__s);
}
// Spherical Bessel functions
/**
* Return the spherical Bessel function @f$ j_n(x) @f$ of nonnegative order n
* and @c float argument @f$ x >= 0 @f$.
*
* @see sph_bessel for more details.
*/
inline float
sph_besself(unsigned int __n, float __x)
{ return __detail::__sph_bessel<float>(__n, __x); }
/**
* Return the spherical Bessel function @f$ j_n(x) @f$ of nonnegative order n
* and <tt>long double</tt> argument @f$ x >= 0 @f$.
*
* @see sph_bessel for more details.
*/
inline long double
sph_bessell(unsigned int __n, long double __x)
{ return __detail::__sph_bessel<long double>(__n, __x); }
/**
* Return the spherical Bessel function @f$ j_n(x) @f$ of nonnegative order n
* and real argument @f$ x >= 0 @f$.
*
* The spherical Bessel function is defined by:
* @f[
* j_n(x) = \left(\frac{\pi}{2x} \right) ^{1/2} J_{n+1/2}(x)
* @f]
*
* @tparam _Tp The floating-point type of the argument @c __x.
* @param __n The integral order <tt> n >= 0 </tt>
* @param __x The real argument <tt> x >= 0 </tt>
* @throw std::domain_error if <tt> __x < 0 </tt>.
*/
template<typename _Tp>
inline typename __gnu_cxx::__promote<_Tp>::__type
sph_bessel(unsigned int __n, _Tp __x)
{
typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
return __detail::__sph_bessel<__type>(__n, __x);
}
// Spherical associated Legendre functions
/**
* Return the spherical Legendre function of nonnegative integral
* degree @c l and order @c m and float angle @f$ \theta @f$ in radians.
*
* @see sph_legendre for details.
*/
inline float
sph_legendref(unsigned int __l, unsigned int __m, float __theta)
{ return __detail::__sph_legendre<float>(__l, __m, __theta); }
/**
* Return the spherical Legendre function of nonnegative integral
* degree @c l and order @c m and <tt>long double</tt> angle @f$ \theta @f$
* in radians.
*
* @see sph_legendre for details.
*/
inline long double
sph_legendrel(unsigned int __l, unsigned int __m, long double __theta)
{ return __detail::__sph_legendre<long double>(__l, __m, __theta); }
/**
* Return the spherical Legendre function of nonnegative integral
* degree @c l and order @c m and real angle @f$ \theta @f$ in radians.
*
* The spherical Legendre function is defined by
* @f[
* Y_l^m(\theta,\phi) = (-1)^m[\frac{(2l+1)}{4\pi}
* \frac{(l-m)!}{(l+m)!}]
* P_l^m(\cos\theta) \exp^{im\phi}
* @f]
*
* @tparam _Tp The floating-point type of the angle @c __theta.
* @param __l The order <tt> __l >= 0 </tt>
* @param __m The degree <tt> __m >= 0 </tt> and <tt> __m <= __l </tt>
* @param __theta The radian polar angle argument
*/
template<typename _Tp>
inline typename __gnu_cxx::__promote<_Tp>::__type
sph_legendre(unsigned int __l, unsigned int __m, _Tp __theta)
{
typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
return __detail::__sph_legendre<__type>(__l, __m, __theta);
}
// Spherical Neumann functions
/**
* Return the spherical Neumann function of integral order @f$ n >= 0 @f$
* and @c float argument @f$ x >= 0 @f$.
*
* @see sph_neumann for details.
*/
inline float
sph_neumannf(unsigned int __n, float __x)
{ return __detail::__sph_neumann<float>(__n, __x); }
/**
* Return the spherical Neumann function of integral order @f$ n >= 0 @f$
* and <tt>long double</tt> @f$ x >= 0 @f$.
*
* @see sph_neumann for details.
*/
inline long double
sph_neumannl(unsigned int __n, long double __x)
{ return __detail::__sph_neumann<long double>(__n, __x); }
/**
* Return the spherical Neumann function of integral order @f$ n >= 0 @f$
* and real argument @f$ x >= 0 @f$.
*
* The spherical Neumann function is defined by
* @f[
* n_n(x) = \left(\frac{\pi}{2x} \right) ^{1/2} N_{n+1/2}(x)
* @f]
*
* @tparam _Tp The floating-point type of the argument @c __x.
* @param __n The integral order <tt> n >= 0 </tt>
* @param __x The real argument <tt> __x >= 0 </tt>
* @throw std::domain_error if <tt> __x < 0 </tt>.
*/
template<typename _Tp>
inline typename __gnu_cxx::__promote<_Tp>::__type
sph_neumann(unsigned int __n, _Tp __x)
{
typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
return __detail::__sph_neumann<__type>(__n, __x);
}
// @} group mathsf
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#ifndef __STRICT_ANSI__
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Airy functions
/**
* Return the Airy function @f$ Ai(x) @f$ of @c float argument x.
*/
inline float
airy_aif(float __x)
{
float __Ai, __Bi, __Aip, __Bip;
std::__detail::__airy<float>(__x, __Ai, __Bi, __Aip, __Bip);
return __Ai;
}
/**
* Return the Airy function @f$ Ai(x) @f$ of <tt>long double</tt> argument x.
*/
inline long double
airy_ail(long double __x)
{
long double __Ai, __Bi, __Aip, __Bip;
std::__detail::__airy<long double>(__x, __Ai, __Bi, __Aip, __Bip);
return __Ai;
}
/**
* Return the Airy function @f$ Ai(x) @f$ of real argument x.
*/
template<typename _Tp>
inline typename __gnu_cxx::__promote<_Tp>::__type
airy_ai(_Tp __x)
{
typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
__type __Ai, __Bi, __Aip, __Bip;
std::__detail::__airy<__type>(__x, __Ai, __Bi, __Aip, __Bip);
return __Ai;
}
/**
* Return the Airy function @f$ Bi(x) @f$ of @c float argument x.
*/
inline float
airy_bif(float __x)
{
float __Ai, __Bi, __Aip, __Bip;
std::__detail::__airy<float>(__x, __Ai, __Bi, __Aip, __Bip);
return __Bi;
}
/**
* Return the Airy function @f$ Bi(x) @f$ of <tt>long double</tt> argument x.
*/
inline long double
airy_bil(long double __x)
{
long double __Ai, __Bi, __Aip, __Bip;
std::__detail::__airy<long double>(__x, __Ai, __Bi, __Aip, __Bip);
return __Bi;
}
/**
* Return the Airy function @f$ Bi(x) @f$ of real argument x.
*/
template<typename _Tp>
inline typename __gnu_cxx::__promote<_Tp>::__type
airy_bi(_Tp __x)
{
typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
__type __Ai, __Bi, __Aip, __Bip;
std::__detail::__airy<__type>(__x, __Ai, __Bi, __Aip, __Bip);
return __Bi;
}
// Confluent hypergeometric functions
/**
* Return the confluent hypergeometric function @f$ {}_1F_1(a;c;x) @f$
* of @c float numeratorial parameter @c a, denominatorial parameter @c c,
* and argument @c x.
*
* @see conf_hyperg for details.
*/
inline float
conf_hypergf(float __a, float __c, float __x)
{ return std::__detail::__conf_hyperg<float>(__a, __c, __x); }
/**
* Return the confluent hypergeometric function @f$ {}_1F_1(a;c;x) @f$
* of <tt>long double</tt> numeratorial parameter @c a,
* denominatorial parameter @c c, and argument @c x.
*
* @see conf_hyperg for details.
*/
inline long double
conf_hypergl(long double __a, long double __c, long double __x)
{ return std::__detail::__conf_hyperg<long double>(__a, __c, __x); }
/**
* Return the confluent hypergeometric function @f$ {}_1F_1(a;c;x) @f$
* of real numeratorial parameter @c a, denominatorial parameter @c c,
* and argument @c x.
*
* The confluent hypergeometric function is defined by
* @f[
* {}_1F_1(a;c;x) = \sum_{n=0}^{\infty} \frac{(a)_n x^n}{(c)_n n!}
* @f]
* where the Pochhammer symbol is @f$ (x)_k = (x)(x+1)...(x+k-1) @f$,
* @f$ (x)_0 = 1 @f$
*
* @param __a The numeratorial parameter
* @param __c The denominatorial parameter
* @param __x The argument
*/
template<typename _Tpa, typename _Tpc, typename _Tp>
inline typename __gnu_cxx::__promote_3<_Tpa, _Tpc, _Tp>::__type
conf_hyperg(_Tpa __a, _Tpc __c, _Tp __x)
{
typedef typename __gnu_cxx::__promote_3<_Tpa, _Tpc, _Tp>::__type __type;
return std::__detail::__conf_hyperg<__type>(__a, __c, __x);
}
// Hypergeometric functions
/**
* Return the hypergeometric function @f$ {}_2F_1(a,b;c;x) @f$
* of @ float numeratorial parameters @c a and @c b,
* denominatorial parameter @c c, and argument @c x.
*
* @see hyperg for details.
*/
inline float
hypergf(float __a, float __b, float __c, float __x)
{ return std::__detail::__hyperg<float>(__a, __b, __c, __x); }
/**
* Return the hypergeometric function @f$ {}_2F_1(a,b;c;x) @f$
* of <tt>long double</tt> numeratorial parameters @c a and @c b,
* denominatorial parameter @c c, and argument @c x.
*
* @see hyperg for details.
*/
inline long double
hypergl(long double __a, long double __b, long double __c, long double __x)
{ return std::__detail::__hyperg<long double>(__a, __b, __c, __x); }
/**
* Return the hypergeometric function @f$ {}_2F_1(a,b;c;x) @f$
* of real numeratorial parameters @c a and @c b,
* denominatorial parameter @c c, and argument @c x.
*
* The hypergeometric function is defined by
* @f[
* {}_2F_1(a;c;x) = \sum_{n=0}^{\infty} \frac{(a)_n (b)_n x^n}{(c)_n n!}
* @f]
* where the Pochhammer symbol is @f$ (x)_k = (x)(x+1)...(x+k-1) @f$,
* @f$ (x)_0 = 1 @f$
*
* @param __a The first numeratorial parameter
* @param __b The second numeratorial parameter
* @param __c The denominatorial parameter
* @param __x The argument
*/
template<typename _Tpa, typename _Tpb, typename _Tpc, typename _Tp>
inline typename __gnu_cxx::__promote_4<_Tpa, _Tpb, _Tpc, _Tp>::__type
hyperg(_Tpa __a, _Tpb __b, _Tpc __c, _Tp __x)
{
typedef typename __gnu_cxx::__promote_4<_Tpa, _Tpb, _Tpc, _Tp>
::__type __type;
return std::__detail::__hyperg<__type>(__a, __b, __c, __x);
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace __gnu_cxx
#endif // __STRICT_ANSI__
#pragma GCC visibility pop
#endif // _GLIBCXX_BITS_SPECFUN_H
c++/8/bits/locale_facets_nonio.tcc 0000644 00000130340 15201526705 0012711 0 ustar 00 // Locale support -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/locale_facets_nonio.tcc
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{locale}
*/
#ifndef _LOCALE_FACETS_NONIO_TCC
#define _LOCALE_FACETS_NONIO_TCC 1
#pragma GCC system_header
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _CharT, bool _Intl>
struct __use_cache<__moneypunct_cache<_CharT, _Intl> >
{
const __moneypunct_cache<_CharT, _Intl>*
operator() (const locale& __loc) const
{
const size_t __i = moneypunct<_CharT, _Intl>::id._M_id();
const locale::facet** __caches = __loc._M_impl->_M_caches;
if (!__caches[__i])
{
__moneypunct_cache<_CharT, _Intl>* __tmp = 0;
__try
{
__tmp = new __moneypunct_cache<_CharT, _Intl>;
__tmp->_M_cache(__loc);
}
__catch(...)
{
delete __tmp;
__throw_exception_again;
}
__loc._M_impl->_M_install_cache(__tmp, __i);
}
return static_cast<
const __moneypunct_cache<_CharT, _Intl>*>(__caches[__i]);
}
};
template<typename _CharT, bool _Intl>
void
__moneypunct_cache<_CharT, _Intl>::_M_cache(const locale& __loc)
{
const moneypunct<_CharT, _Intl>& __mp =
use_facet<moneypunct<_CharT, _Intl> >(__loc);
_M_decimal_point = __mp.decimal_point();
_M_thousands_sep = __mp.thousands_sep();
_M_frac_digits = __mp.frac_digits();
char* __grouping = 0;
_CharT* __curr_symbol = 0;
_CharT* __positive_sign = 0;
_CharT* __negative_sign = 0;
__try
{
const string& __g = __mp.grouping();
_M_grouping_size = __g.size();
__grouping = new char[_M_grouping_size];
__g.copy(__grouping, _M_grouping_size);
_M_use_grouping = (_M_grouping_size
&& static_cast<signed char>(__grouping[0]) > 0
&& (__grouping[0]
!= __gnu_cxx::__numeric_traits<char>::__max));
const basic_string<_CharT>& __cs = __mp.curr_symbol();
_M_curr_symbol_size = __cs.size();
__curr_symbol = new _CharT[_M_curr_symbol_size];
__cs.copy(__curr_symbol, _M_curr_symbol_size);
const basic_string<_CharT>& __ps = __mp.positive_sign();
_M_positive_sign_size = __ps.size();
__positive_sign = new _CharT[_M_positive_sign_size];
__ps.copy(__positive_sign, _M_positive_sign_size);
const basic_string<_CharT>& __ns = __mp.negative_sign();
_M_negative_sign_size = __ns.size();
__negative_sign = new _CharT[_M_negative_sign_size];
__ns.copy(__negative_sign, _M_negative_sign_size);
_M_pos_format = __mp.pos_format();
_M_neg_format = __mp.neg_format();
const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__loc);
__ct.widen(money_base::_S_atoms,
money_base::_S_atoms + money_base::_S_end, _M_atoms);
_M_grouping = __grouping;
_M_curr_symbol = __curr_symbol;
_M_positive_sign = __positive_sign;
_M_negative_sign = __negative_sign;
_M_allocated = true;
}
__catch(...)
{
delete [] __grouping;
delete [] __curr_symbol;
delete [] __positive_sign;
delete [] __negative_sign;
__throw_exception_again;
}
}
_GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11
template<typename _CharT, typename _InIter>
template<bool _Intl>
_InIter
money_get<_CharT, _InIter>::
_M_extract(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, string& __units) const
{
typedef char_traits<_CharT> __traits_type;
typedef typename string_type::size_type size_type;
typedef money_base::part part;
typedef __moneypunct_cache<_CharT, _Intl> __cache_type;
const locale& __loc = __io._M_getloc();
const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
__use_cache<__cache_type> __uc;
const __cache_type* __lc = __uc(__loc);
const char_type* __lit = __lc->_M_atoms;
// Deduced sign.
bool __negative = false;
// Sign size.
size_type __sign_size = 0;
// True if sign is mandatory.
const bool __mandatory_sign = (__lc->_M_positive_sign_size
&& __lc->_M_negative_sign_size);
// String of grouping info from thousands_sep plucked from __units.
string __grouping_tmp;
if (__lc->_M_use_grouping)
__grouping_tmp.reserve(32);
// Last position before the decimal point.
int __last_pos = 0;
// Separator positions, then, possibly, fractional digits.
int __n = 0;
// If input iterator is in a valid state.
bool __testvalid = true;
// Flag marking when a decimal point is found.
bool __testdecfound = false;
// The tentative returned string is stored here.
string __res;
__res.reserve(32);
const char_type* __lit_zero = __lit + money_base::_S_zero;
const money_base::pattern __p = __lc->_M_neg_format;
for (int __i = 0; __i < 4 && __testvalid; ++__i)
{
const part __which = static_cast<part>(__p.field[__i]);
switch (__which)
{
case money_base::symbol:
// According to 22.2.6.1.2, p2, symbol is required
// if (__io.flags() & ios_base::showbase), otherwise
// is optional and consumed only if other characters
// are needed to complete the format.
if (__io.flags() & ios_base::showbase || __sign_size > 1
|| __i == 0
|| (__i == 1 && (__mandatory_sign
|| (static_cast<part>(__p.field[0])
== money_base::sign)
|| (static_cast<part>(__p.field[2])
== money_base::space)))
|| (__i == 2 && ((static_cast<part>(__p.field[3])
== money_base::value)
|| (__mandatory_sign
&& (static_cast<part>(__p.field[3])
== money_base::sign)))))
{
const size_type __len = __lc->_M_curr_symbol_size;
size_type __j = 0;
for (; __beg != __end && __j < __len
&& *__beg == __lc->_M_curr_symbol[__j];
++__beg, (void)++__j);
if (__j != __len
&& (__j || __io.flags() & ios_base::showbase))
__testvalid = false;
}
break;
case money_base::sign:
// Sign might not exist, or be more than one character long.
if (__lc->_M_positive_sign_size && __beg != __end
&& *__beg == __lc->_M_positive_sign[0])
{
__sign_size = __lc->_M_positive_sign_size;
++__beg;
}
else if (__lc->_M_negative_sign_size && __beg != __end
&& *__beg == __lc->_M_negative_sign[0])
{
__negative = true;
__sign_size = __lc->_M_negative_sign_size;
++__beg;
}
else if (__lc->_M_positive_sign_size
&& !__lc->_M_negative_sign_size)
// "... if no sign is detected, the result is given the sign
// that corresponds to the source of the empty string"
__negative = true;
else if (__mandatory_sign)
__testvalid = false;
break;
case money_base::value:
// Extract digits, remove and stash away the
// grouping of found thousands separators.
for (; __beg != __end; ++__beg)
{
const char_type __c = *__beg;
const char_type* __q = __traits_type::find(__lit_zero,
10, __c);
if (__q != 0)
{
__res += money_base::_S_atoms[__q - __lit];
++__n;
}
else if (__c == __lc->_M_decimal_point
&& !__testdecfound)
{
if (__lc->_M_frac_digits <= 0)
break;
__last_pos = __n;
__n = 0;
__testdecfound = true;
}
else if (__lc->_M_use_grouping
&& __c == __lc->_M_thousands_sep
&& !__testdecfound)
{
if (__n)
{
// Mark position for later analysis.
__grouping_tmp += static_cast<char>(__n);
__n = 0;
}
else
{
__testvalid = false;
break;
}
}
else
break;
}
if (__res.empty())
__testvalid = false;
break;
case money_base::space:
// At least one space is required.
if (__beg != __end && __ctype.is(ctype_base::space, *__beg))
++__beg;
else
__testvalid = false;
// fallthrough
case money_base::none:
// Only if not at the end of the pattern.
if (__i != 3)
for (; __beg != __end
&& __ctype.is(ctype_base::space, *__beg); ++__beg);
break;
}
}
// Need to get the rest of the sign characters, if they exist.
if (__sign_size > 1 && __testvalid)
{
const char_type* __sign = __negative ? __lc->_M_negative_sign
: __lc->_M_positive_sign;
size_type __i = 1;
for (; __beg != __end && __i < __sign_size
&& *__beg == __sign[__i]; ++__beg, (void)++__i);
if (__i != __sign_size)
__testvalid = false;
}
if (__testvalid)
{
// Strip leading zeros.
if (__res.size() > 1)
{
const size_type __first = __res.find_first_not_of('0');
const bool __only_zeros = __first == string::npos;
if (__first)
__res.erase(0, __only_zeros ? __res.size() - 1 : __first);
}
// 22.2.6.1.2, p4
if (__negative && __res[0] != '0')
__res.insert(__res.begin(), '-');
// Test for grouping fidelity.
if (__grouping_tmp.size())
{
// Add the ending grouping.
__grouping_tmp += static_cast<char>(__testdecfound ? __last_pos
: __n);
if (!std::__verify_grouping(__lc->_M_grouping,
__lc->_M_grouping_size,
__grouping_tmp))
__err |= ios_base::failbit;
}
// Iff not enough digits were supplied after the decimal-point.
if (__testdecfound && __n != __lc->_M_frac_digits)
__testvalid = false;
}
// Iff valid sequence is not recognized.
if (!__testvalid)
__err |= ios_base::failbit;
else
__units.swap(__res);
// Iff no more characters are available.
if (__beg == __end)
__err |= ios_base::eofbit;
return __beg;
}
#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ \
&& _GLIBCXX_USE_CXX11_ABI == 0
template<typename _CharT, typename _InIter>
_InIter
money_get<_CharT, _InIter>::
__do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io,
ios_base::iostate& __err, double& __units) const
{
string __str;
__beg = __intl ? _M_extract<true>(__beg, __end, __io, __err, __str)
: _M_extract<false>(__beg, __end, __io, __err, __str);
std::__convert_to_v(__str.c_str(), __units, __err, _S_get_c_locale());
return __beg;
}
#endif
template<typename _CharT, typename _InIter>
_InIter
money_get<_CharT, _InIter>::
do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io,
ios_base::iostate& __err, long double& __units) const
{
string __str;
__beg = __intl ? _M_extract<true>(__beg, __end, __io, __err, __str)
: _M_extract<false>(__beg, __end, __io, __err, __str);
std::__convert_to_v(__str.c_str(), __units, __err, _S_get_c_locale());
return __beg;
}
template<typename _CharT, typename _InIter>
_InIter
money_get<_CharT, _InIter>::
do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io,
ios_base::iostate& __err, string_type& __digits) const
{
typedef typename string::size_type size_type;
const locale& __loc = __io._M_getloc();
const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
string __str;
__beg = __intl ? _M_extract<true>(__beg, __end, __io, __err, __str)
: _M_extract<false>(__beg, __end, __io, __err, __str);
const size_type __len = __str.size();
if (__len)
{
__digits.resize(__len);
__ctype.widen(__str.data(), __str.data() + __len, &__digits[0]);
}
return __beg;
}
template<typename _CharT, typename _OutIter>
template<bool _Intl>
_OutIter
money_put<_CharT, _OutIter>::
_M_insert(iter_type __s, ios_base& __io, char_type __fill,
const string_type& __digits) const
{
typedef typename string_type::size_type size_type;
typedef money_base::part part;
typedef __moneypunct_cache<_CharT, _Intl> __cache_type;
const locale& __loc = __io._M_getloc();
const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
__use_cache<__cache_type> __uc;
const __cache_type* __lc = __uc(__loc);
const char_type* __lit = __lc->_M_atoms;
// Determine if negative or positive formats are to be used, and
// discard leading negative_sign if it is present.
const char_type* __beg = __digits.data();
money_base::pattern __p;
const char_type* __sign;
size_type __sign_size;
if (!(*__beg == __lit[money_base::_S_minus]))
{
__p = __lc->_M_pos_format;
__sign = __lc->_M_positive_sign;
__sign_size = __lc->_M_positive_sign_size;
}
else
{
__p = __lc->_M_neg_format;
__sign = __lc->_M_negative_sign;
__sign_size = __lc->_M_negative_sign_size;
if (__digits.size())
++__beg;
}
// Look for valid numbers in the ctype facet within input digits.
size_type __len = __ctype.scan_not(ctype_base::digit, __beg,
__beg + __digits.size()) - __beg;
if (__len)
{
// Assume valid input, and attempt to format.
// Break down input numbers into base components, as follows:
// final_value = grouped units + (decimal point) + (digits)
string_type __value;
__value.reserve(2 * __len);
// Add thousands separators to non-decimal digits, per
// grouping rules.
long __paddec = __len - __lc->_M_frac_digits;
if (__paddec > 0)
{
if (__lc->_M_frac_digits < 0)
__paddec = __len;
if (__lc->_M_grouping_size)
{
__value.assign(2 * __paddec, char_type());
_CharT* __vend =
std::__add_grouping(&__value[0], __lc->_M_thousands_sep,
__lc->_M_grouping,
__lc->_M_grouping_size,
__beg, __beg + __paddec);
__value.erase(__vend - &__value[0]);
}
else
__value.assign(__beg, __paddec);
}
// Deal with decimal point, decimal digits.
if (__lc->_M_frac_digits > 0)
{
__value += __lc->_M_decimal_point;
if (__paddec >= 0)
__value.append(__beg + __paddec, __lc->_M_frac_digits);
else
{
// Have to pad zeros in the decimal position.
__value.append(-__paddec, __lit[money_base::_S_zero]);
__value.append(__beg, __len);
}
}
// Calculate length of resulting string.
const ios_base::fmtflags __f = __io.flags()
& ios_base::adjustfield;
__len = __value.size() + __sign_size;
__len += ((__io.flags() & ios_base::showbase)
? __lc->_M_curr_symbol_size : 0);
string_type __res;
__res.reserve(2 * __len);
const size_type __width = static_cast<size_type>(__io.width());
const bool __testipad = (__f == ios_base::internal
&& __len < __width);
// Fit formatted digits into the required pattern.
for (int __i = 0; __i < 4; ++__i)
{
const part __which = static_cast<part>(__p.field[__i]);
switch (__which)
{
case money_base::symbol:
if (__io.flags() & ios_base::showbase)
__res.append(__lc->_M_curr_symbol,
__lc->_M_curr_symbol_size);
break;
case money_base::sign:
// Sign might not exist, or be more than one
// character long. In that case, add in the rest
// below.
if (__sign_size)
__res += __sign[0];
break;
case money_base::value:
__res += __value;
break;
case money_base::space:
// At least one space is required, but if internal
// formatting is required, an arbitrary number of
// fill spaces will be necessary.
if (__testipad)
__res.append(__width - __len, __fill);
else
__res += __fill;
break;
case money_base::none:
if (__testipad)
__res.append(__width - __len, __fill);
break;
}
}
// Special case of multi-part sign parts.
if (__sign_size > 1)
__res.append(__sign + 1, __sign_size - 1);
// Pad, if still necessary.
__len = __res.size();
if (__width > __len)
{
if (__f == ios_base::left)
// After.
__res.append(__width - __len, __fill);
else
// Before.
__res.insert(0, __width - __len, __fill);
__len = __width;
}
// Write resulting, fully-formatted string to output iterator.
__s = std::__write(__s, __res.data(), __len);
}
__io.width(0);
return __s;
}
#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ \
&& _GLIBCXX_USE_CXX11_ABI == 0
template<typename _CharT, typename _OutIter>
_OutIter
money_put<_CharT, _OutIter>::
__do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
double __units) const
{ return this->do_put(__s, __intl, __io, __fill, (long double) __units); }
#endif
template<typename _CharT, typename _OutIter>
_OutIter
money_put<_CharT, _OutIter>::
do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
long double __units) const
{
const locale __loc = __io.getloc();
const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
#if _GLIBCXX_USE_C99_STDIO
// First try a buffer perhaps big enough.
int __cs_size = 64;
char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 328. Bad sprintf format modifier in money_put<>::do_put()
int __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size,
"%.*Lf", 0, __units);
// If the buffer was not large enough, try again with the correct size.
if (__len >= __cs_size)
{
__cs_size = __len + 1;
__cs = static_cast<char*>(__builtin_alloca(__cs_size));
__len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size,
"%.*Lf", 0, __units);
}
#else
// max_exponent10 + 1 for the integer part, + 2 for sign and '\0'.
const int __cs_size =
__gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 3;
char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
int __len = std::__convert_from_v(_S_get_c_locale(), __cs, 0, "%.*Lf",
0, __units);
#endif
string_type __digits(__len, char_type());
__ctype.widen(__cs, __cs + __len, &__digits[0]);
return __intl ? _M_insert<true>(__s, __io, __fill, __digits)
: _M_insert<false>(__s, __io, __fill, __digits);
}
template<typename _CharT, typename _OutIter>
_OutIter
money_put<_CharT, _OutIter>::
do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
const string_type& __digits) const
{ return __intl ? _M_insert<true>(__s, __io, __fill, __digits)
: _M_insert<false>(__s, __io, __fill, __digits); }
_GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
// NB: Not especially useful. Without an ios_base object or some
// kind of locale reference, we are left clawing at the air where
// the side of the mountain used to be...
template<typename _CharT, typename _InIter>
time_base::dateorder
time_get<_CharT, _InIter>::do_date_order() const
{ return time_base::no_order; }
// Expand a strftime format string and parse it. E.g., do_get_date() may
// pass %m/%d/%Y => extracted characters.
template<typename _CharT, typename _InIter>
_InIter
time_get<_CharT, _InIter>::
_M_extract_via_format(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, tm* __tm,
const _CharT* __format) const
{
const locale& __loc = __io._M_getloc();
const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
const size_t __len = char_traits<_CharT>::length(__format);
ios_base::iostate __tmperr = ios_base::goodbit;
size_t __i = 0;
for (; __beg != __end && __i < __len && !__tmperr; ++__i)
{
if (__ctype.narrow(__format[__i], 0) == '%')
{
// Verify valid formatting code, attempt to extract.
char __c = __ctype.narrow(__format[++__i], 0);
int __mem = 0;
if (__c == 'E' || __c == 'O')
__c = __ctype.narrow(__format[++__i], 0);
switch (__c)
{
const char* __cs;
_CharT __wcs[10];
case 'a':
// Abbreviated weekday name [tm_wday]
const char_type* __days1[7];
__tp._M_days_abbreviated(__days1);
__beg = _M_extract_name(__beg, __end, __mem, __days1,
7, __io, __tmperr);
if (!__tmperr)
__tm->tm_wday = __mem;
break;
case 'A':
// Weekday name [tm_wday].
const char_type* __days2[7];
__tp._M_days(__days2);
__beg = _M_extract_name(__beg, __end, __mem, __days2,
7, __io, __tmperr);
if (!__tmperr)
__tm->tm_wday = __mem;
break;
case 'h':
case 'b':
// Abbreviated month name [tm_mon]
const char_type* __months1[12];
__tp._M_months_abbreviated(__months1);
__beg = _M_extract_name(__beg, __end, __mem,
__months1, 12, __io, __tmperr);
if (!__tmperr)
__tm->tm_mon = __mem;
break;
case 'B':
// Month name [tm_mon].
const char_type* __months2[12];
__tp._M_months(__months2);
__beg = _M_extract_name(__beg, __end, __mem,
__months2, 12, __io, __tmperr);
if (!__tmperr)
__tm->tm_mon = __mem;
break;
case 'c':
// Default time and date representation.
const char_type* __dt[2];
__tp._M_date_time_formats(__dt);
__beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
__tm, __dt[0]);
break;
case 'd':
// Day [01, 31]. [tm_mday]
__beg = _M_extract_num(__beg, __end, __mem, 1, 31, 2,
__io, __tmperr);
if (!__tmperr)
__tm->tm_mday = __mem;
break;
case 'e':
// Day [1, 31], with single digits preceded by
// space. [tm_mday]
if (__ctype.is(ctype_base::space, *__beg))
__beg = _M_extract_num(++__beg, __end, __mem, 1, 9,
1, __io, __tmperr);
else
__beg = _M_extract_num(__beg, __end, __mem, 10, 31,
2, __io, __tmperr);
if (!__tmperr)
__tm->tm_mday = __mem;
break;
case 'D':
// Equivalent to %m/%d/%y.[tm_mon, tm_mday, tm_year]
__cs = "%m/%d/%y";
__ctype.widen(__cs, __cs + 9, __wcs);
__beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
__tm, __wcs);
break;
case 'H':
// Hour [00, 23]. [tm_hour]
__beg = _M_extract_num(__beg, __end, __mem, 0, 23, 2,
__io, __tmperr);
if (!__tmperr)
__tm->tm_hour = __mem;
break;
case 'I':
// Hour [01, 12]. [tm_hour]
__beg = _M_extract_num(__beg, __end, __mem, 1, 12, 2,
__io, __tmperr);
if (!__tmperr)
__tm->tm_hour = __mem;
break;
case 'm':
// Month [01, 12]. [tm_mon]
__beg = _M_extract_num(__beg, __end, __mem, 1, 12, 2,
__io, __tmperr);
if (!__tmperr)
__tm->tm_mon = __mem - 1;
break;
case 'M':
// Minute [00, 59]. [tm_min]
__beg = _M_extract_num(__beg, __end, __mem, 0, 59, 2,
__io, __tmperr);
if (!__tmperr)
__tm->tm_min = __mem;
break;
case 'n':
if (__ctype.narrow(*__beg, 0) == '\n')
++__beg;
else
__tmperr |= ios_base::failbit;
break;
case 'R':
// Equivalent to (%H:%M).
__cs = "%H:%M";
__ctype.widen(__cs, __cs + 6, __wcs);
__beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
__tm, __wcs);
break;
case 'S':
// Seconds. [tm_sec]
// [00, 60] in C99 (one leap-second), [00, 61] in C89.
#if _GLIBCXX_USE_C99
__beg = _M_extract_num(__beg, __end, __mem, 0, 60, 2,
#else
__beg = _M_extract_num(__beg, __end, __mem, 0, 61, 2,
#endif
__io, __tmperr);
if (!__tmperr)
__tm->tm_sec = __mem;
break;
case 't':
if (__ctype.narrow(*__beg, 0) == '\t')
++__beg;
else
__tmperr |= ios_base::failbit;
break;
case 'T':
// Equivalent to (%H:%M:%S).
__cs = "%H:%M:%S";
__ctype.widen(__cs, __cs + 9, __wcs);
__beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
__tm, __wcs);
break;
case 'x':
// Locale's date.
const char_type* __dates[2];
__tp._M_date_formats(__dates);
__beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
__tm, __dates[0]);
break;
case 'X':
// Locale's time.
const char_type* __times[2];
__tp._M_time_formats(__times);
__beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
__tm, __times[0]);
break;
case 'y':
case 'C': // C99
// Two digit year.
case 'Y':
// Year [1900).
// NB: We parse either two digits, implicitly years since
// 1900, or 4 digits, full year. In both cases we can
// reconstruct [tm_year]. See also libstdc++/26701.
__beg = _M_extract_num(__beg, __end, __mem, 0, 9999, 4,
__io, __tmperr);
if (!__tmperr)
__tm->tm_year = __mem < 0 ? __mem + 100 : __mem - 1900;
break;
case 'Z':
// Timezone info.
if (__ctype.is(ctype_base::upper, *__beg))
{
int __tmp;
__beg = _M_extract_name(__beg, __end, __tmp,
__timepunct_cache<_CharT>::_S_timezones,
14, __io, __tmperr);
// GMT requires special effort.
if (__beg != __end && !__tmperr && __tmp == 0
&& (*__beg == __ctype.widen('-')
|| *__beg == __ctype.widen('+')))
{
__beg = _M_extract_num(__beg, __end, __tmp, 0, 23, 2,
__io, __tmperr);
__beg = _M_extract_num(__beg, __end, __tmp, 0, 59, 2,
__io, __tmperr);
}
}
else
__tmperr |= ios_base::failbit;
break;
default:
// Not recognized.
__tmperr |= ios_base::failbit;
}
}
else
{
// Verify format and input match, extract and discard.
if (__format[__i] == *__beg)
++__beg;
else
__tmperr |= ios_base::failbit;
}
}
if (__tmperr || __i != __len)
__err |= ios_base::failbit;
return __beg;
}
template<typename _CharT, typename _InIter>
_InIter
time_get<_CharT, _InIter>::
_M_extract_num(iter_type __beg, iter_type __end, int& __member,
int __min, int __max, size_t __len,
ios_base& __io, ios_base::iostate& __err) const
{
const locale& __loc = __io._M_getloc();
const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
// As-is works for __len = 1, 2, 4, the values actually used.
int __mult = __len == 2 ? 10 : (__len == 4 ? 1000 : 1);
++__min;
size_t __i = 0;
int __value = 0;
for (; __beg != __end && __i < __len; ++__beg, (void)++__i)
{
const char __c = __ctype.narrow(*__beg, '*');
if (__c >= '0' && __c <= '9')
{
__value = __value * 10 + (__c - '0');
const int __valuec = __value * __mult;
if (__valuec > __max || __valuec + __mult < __min)
break;
__mult /= 10;
}
else
break;
}
if (__i == __len)
__member = __value;
// Special encoding for do_get_year, 'y', and 'Y' above.
else if (__len == 4 && __i == 2)
__member = __value - 100;
else
__err |= ios_base::failbit;
return __beg;
}
// Assumptions:
// All elements in __names are unique.
template<typename _CharT, typename _InIter>
_InIter
time_get<_CharT, _InIter>::
_M_extract_name(iter_type __beg, iter_type __end, int& __member,
const _CharT** __names, size_t __indexlen,
ios_base& __io, ios_base::iostate& __err) const
{
typedef char_traits<_CharT> __traits_type;
const locale& __loc = __io._M_getloc();
const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
int* __matches = static_cast<int*>(__builtin_alloca(sizeof(int)
* __indexlen));
size_t __nmatches = 0;
size_t __pos = 0;
bool __testvalid = true;
const char_type* __name;
// Look for initial matches.
// NB: Some of the locale data is in the form of all lowercase
// names, and some is in the form of initially-capitalized
// names. Look for both.
if (__beg != __end)
{
const char_type __c = *__beg;
for (size_t __i1 = 0; __i1 < __indexlen; ++__i1)
if (__c == __names[__i1][0]
|| __c == __ctype.toupper(__names[__i1][0]))
__matches[__nmatches++] = __i1;
}
while (__nmatches > 1)
{
// Find smallest matching string.
size_t __minlen = __traits_type::length(__names[__matches[0]]);
for (size_t __i2 = 1; __i2 < __nmatches; ++__i2)
__minlen = std::min(__minlen,
__traits_type::length(__names[__matches[__i2]]));
++__beg;
++__pos;
if (__pos < __minlen && __beg != __end)
for (size_t __i3 = 0; __i3 < __nmatches;)
{
__name = __names[__matches[__i3]];
if (!(__name[__pos] == *__beg))
__matches[__i3] = __matches[--__nmatches];
else
++__i3;
}
else
break;
}
if (__nmatches == 1)
{
// Make sure found name is completely extracted.
++__beg;
++__pos;
__name = __names[__matches[0]];
const size_t __len = __traits_type::length(__name);
while (__pos < __len && __beg != __end && __name[__pos] == *__beg)
++__beg, (void)++__pos;
if (__len == __pos)
__member = __matches[0];
else
__testvalid = false;
}
else
__testvalid = false;
if (!__testvalid)
__err |= ios_base::failbit;
return __beg;
}
template<typename _CharT, typename _InIter>
_InIter
time_get<_CharT, _InIter>::
_M_extract_wday_or_month(iter_type __beg, iter_type __end, int& __member,
const _CharT** __names, size_t __indexlen,
ios_base& __io, ios_base::iostate& __err) const
{
typedef char_traits<_CharT> __traits_type;
const locale& __loc = __io._M_getloc();
const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
int* __matches = static_cast<int*>(__builtin_alloca(2 * sizeof(int)
* __indexlen));
size_t __nmatches = 0;
size_t* __matches_lengths = 0;
size_t __pos = 0;
if (__beg != __end)
{
const char_type __c = *__beg;
for (size_t __i = 0; __i < 2 * __indexlen; ++__i)
if (__c == __names[__i][0]
|| __c == __ctype.toupper(__names[__i][0]))
__matches[__nmatches++] = __i;
}
if (__nmatches)
{
++__beg;
++__pos;
__matches_lengths
= static_cast<size_t*>(__builtin_alloca(sizeof(size_t)
* __nmatches));
for (size_t __i = 0; __i < __nmatches; ++__i)
__matches_lengths[__i]
= __traits_type::length(__names[__matches[__i]]);
}
for (; __beg != __end; ++__beg, (void)++__pos)
{
size_t __nskipped = 0;
const char_type __c = *__beg;
for (size_t __i = 0; __i < __nmatches;)
{
const char_type* __name = __names[__matches[__i]];
if (__pos >= __matches_lengths[__i])
++__nskipped, ++__i;
else if (!(__name[__pos] == __c))
{
--__nmatches;
__matches[__i] = __matches[__nmatches];
__matches_lengths[__i] = __matches_lengths[__nmatches];
}
else
++__i;
}
if (__nskipped == __nmatches)
break;
}
if ((__nmatches == 1 && __matches_lengths[0] == __pos)
|| (__nmatches == 2 && (__matches_lengths[0] == __pos
|| __matches_lengths[1] == __pos)))
__member = (__matches[0] >= __indexlen
? __matches[0] - __indexlen : __matches[0]);
else
__err |= ios_base::failbit;
return __beg;
}
template<typename _CharT, typename _InIter>
_InIter
time_get<_CharT, _InIter>::
do_get_time(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, tm* __tm) const
{
const locale& __loc = __io._M_getloc();
const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
const char_type* __times[2];
__tp._M_time_formats(__times);
__beg = _M_extract_via_format(__beg, __end, __io, __err,
__tm, __times[0]);
if (__beg == __end)
__err |= ios_base::eofbit;
return __beg;
}
template<typename _CharT, typename _InIter>
_InIter
time_get<_CharT, _InIter>::
do_get_date(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, tm* __tm) const
{
const locale& __loc = __io._M_getloc();
const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
const char_type* __dates[2];
__tp._M_date_formats(__dates);
__beg = _M_extract_via_format(__beg, __end, __io, __err,
__tm, __dates[0]);
if (__beg == __end)
__err |= ios_base::eofbit;
return __beg;
}
template<typename _CharT, typename _InIter>
_InIter
time_get<_CharT, _InIter>::
do_get_weekday(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, tm* __tm) const
{
const locale& __loc = __io._M_getloc();
const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
const char_type* __days[14];
__tp._M_days_abbreviated(__days);
__tp._M_days(__days + 7);
int __tmpwday;
ios_base::iostate __tmperr = ios_base::goodbit;
__beg = _M_extract_wday_or_month(__beg, __end, __tmpwday, __days, 7,
__io, __tmperr);
if (!__tmperr)
__tm->tm_wday = __tmpwday;
else
__err |= ios_base::failbit;
if (__beg == __end)
__err |= ios_base::eofbit;
return __beg;
}
template<typename _CharT, typename _InIter>
_InIter
time_get<_CharT, _InIter>::
do_get_monthname(iter_type __beg, iter_type __end,
ios_base& __io, ios_base::iostate& __err, tm* __tm) const
{
const locale& __loc = __io._M_getloc();
const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
const char_type* __months[24];
__tp._M_months_abbreviated(__months);
__tp._M_months(__months + 12);
int __tmpmon;
ios_base::iostate __tmperr = ios_base::goodbit;
__beg = _M_extract_wday_or_month(__beg, __end, __tmpmon, __months, 12,
__io, __tmperr);
if (!__tmperr)
__tm->tm_mon = __tmpmon;
else
__err |= ios_base::failbit;
if (__beg == __end)
__err |= ios_base::eofbit;
return __beg;
}
template<typename _CharT, typename _InIter>
_InIter
time_get<_CharT, _InIter>::
do_get_year(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, tm* __tm) const
{
int __tmpyear;
ios_base::iostate __tmperr = ios_base::goodbit;
__beg = _M_extract_num(__beg, __end, __tmpyear, 0, 9999, 4,
__io, __tmperr);
if (!__tmperr)
__tm->tm_year = __tmpyear < 0 ? __tmpyear + 100 : __tmpyear - 1900;
else
__err |= ios_base::failbit;
if (__beg == __end)
__err |= ios_base::eofbit;
return __beg;
}
#if __cplusplus >= 201103L
template<typename _CharT, typename _InIter>
inline
_InIter
time_get<_CharT, _InIter>::
get(iter_type __s, iter_type __end, ios_base& __io,
ios_base::iostate& __err, tm* __tm, const char_type* __fmt,
const char_type* __fmtend) const
{
const locale& __loc = __io._M_getloc();
ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
__err = ios_base::goodbit;
while (__fmt != __fmtend &&
__err == ios_base::goodbit)
{
if (__s == __end)
{
__err = ios_base::eofbit | ios_base::failbit;
break;
}
else if (__ctype.narrow(*__fmt, 0) == '%')
{
char __format;
char __mod = 0;
if (++__fmt == __fmtend)
{
__err = ios_base::failbit;
break;
}
const char __c = __ctype.narrow(*__fmt, 0);
if (__c != 'E' && __c != 'O')
__format = __c;
else if (++__fmt != __fmtend)
{
__mod = __c;
__format = __ctype.narrow(*__fmt, 0);
}
else
{
__err = ios_base::failbit;
break;
}
__s = this->do_get(__s, __end, __io, __err, __tm, __format,
__mod);
++__fmt;
}
else if (__ctype.is(ctype_base::space, *__fmt))
{
++__fmt;
while (__fmt != __fmtend &&
__ctype.is(ctype_base::space, *__fmt))
++__fmt;
while (__s != __end &&
__ctype.is(ctype_base::space, *__s))
++__s;
}
// TODO real case-insensitive comparison
else if (__ctype.tolower(*__s) == __ctype.tolower(*__fmt) ||
__ctype.toupper(*__s) == __ctype.toupper(*__fmt))
{
++__s;
++__fmt;
}
else
{
__err = ios_base::failbit;
break;
}
}
return __s;
}
template<typename _CharT, typename _InIter>
inline
_InIter
time_get<_CharT, _InIter>::
do_get(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, tm* __tm,
char __format, char __mod) const
{
const locale& __loc = __io._M_getloc();
ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
__err = ios_base::goodbit;
char_type __fmt[4];
__fmt[0] = __ctype.widen('%');
if (!__mod)
{
__fmt[1] = __format;
__fmt[2] = char_type();
}
else
{
__fmt[1] = __mod;
__fmt[2] = __format;
__fmt[3] = char_type();
}
__beg = _M_extract_via_format(__beg, __end, __io, __err, __tm, __fmt);
if (__beg == __end)
__err |= ios_base::eofbit;
return __beg;
}
#endif // __cplusplus >= 201103L
template<typename _CharT, typename _OutIter>
_OutIter
time_put<_CharT, _OutIter>::
put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm,
const _CharT* __beg, const _CharT* __end) const
{
const locale& __loc = __io._M_getloc();
ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
for (; __beg != __end; ++__beg)
if (__ctype.narrow(*__beg, 0) != '%')
{
*__s = *__beg;
++__s;
}
else if (++__beg != __end)
{
char __format;
char __mod = 0;
const char __c = __ctype.narrow(*__beg, 0);
if (__c != 'E' && __c != 'O')
__format = __c;
else if (++__beg != __end)
{
__mod = __c;
__format = __ctype.narrow(*__beg, 0);
}
else
break;
__s = this->do_put(__s, __io, __fill, __tm, __format, __mod);
}
else
break;
return __s;
}
template<typename _CharT, typename _OutIter>
_OutIter
time_put<_CharT, _OutIter>::
do_put(iter_type __s, ios_base& __io, char_type, const tm* __tm,
char __format, char __mod) const
{
const locale& __loc = __io._M_getloc();
ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
__timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);
// NB: This size is arbitrary. Should this be a data member,
// initialized at construction?
const size_t __maxlen = 128;
char_type __res[__maxlen];
// NB: In IEE 1003.1-200x, and perhaps other locale models, it
// is possible that the format character will be longer than one
// character. Possibilities include 'E' or 'O' followed by a
// format character: if __mod is not the default argument, assume
// it's a valid modifier.
char_type __fmt[4];
__fmt[0] = __ctype.widen('%');
if (!__mod)
{
__fmt[1] = __format;
__fmt[2] = char_type();
}
else
{
__fmt[1] = __mod;
__fmt[2] = __format;
__fmt[3] = char_type();
}
__tp._M_put(__res, __maxlen, __fmt, __tm);
// Write resulting, fully-formatted string to output iterator.
return std::__write(__s, __res, char_traits<char_type>::length(__res));
}
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
#if _GLIBCXX_EXTERN_TEMPLATE
extern template class moneypunct<char, false>;
extern template class moneypunct<char, true>;
extern template class moneypunct_byname<char, false>;
extern template class moneypunct_byname<char, true>;
extern template class _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 money_get<char>;
extern template class _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 money_put<char>;
extern template class __timepunct<char>;
extern template class time_put<char>;
extern template class time_put_byname<char>;
extern template class time_get<char>;
extern template class time_get_byname<char>;
extern template class messages<char>;
extern template class messages_byname<char>;
extern template
const moneypunct<char, true>&
use_facet<moneypunct<char, true> >(const locale&);
extern template
const moneypunct<char, false>&
use_facet<moneypunct<char, false> >(const locale&);
extern template
const money_put<char>&
use_facet<money_put<char> >(const locale&);
extern template
const money_get<char>&
use_facet<money_get<char> >(const locale&);
extern template
const __timepunct<char>&
use_facet<__timepunct<char> >(const locale&);
extern template
const time_put<char>&
use_facet<time_put<char> >(const locale&);
extern template
const time_get<char>&
use_facet<time_get<char> >(const locale&);
extern template
const messages<char>&
use_facet<messages<char> >(const locale&);
extern template
bool
has_facet<moneypunct<char> >(const locale&);
extern template
bool
has_facet<money_put<char> >(const locale&);
extern template
bool
has_facet<money_get<char> >(const locale&);
extern template
bool
has_facet<__timepunct<char> >(const locale&);
extern template
bool
has_facet<time_put<char> >(const locale&);
extern template
bool
has_facet<time_get<char> >(const locale&);
extern template
bool
has_facet<messages<char> >(const locale&);
#ifdef _GLIBCXX_USE_WCHAR_T
extern template class moneypunct<wchar_t, false>;
extern template class moneypunct<wchar_t, true>;
extern template class moneypunct_byname<wchar_t, false>;
extern template class moneypunct_byname<wchar_t, true>;
extern template class _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 money_get<wchar_t>;
extern template class _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 money_put<wchar_t>;
extern template class __timepunct<wchar_t>;
extern template class time_put<wchar_t>;
extern template class time_put_byname<wchar_t>;
extern template class time_get<wchar_t>;
extern template class time_get_byname<wchar_t>;
extern template class messages<wchar_t>;
extern template class messages_byname<wchar_t>;
extern template
const moneypunct<wchar_t, true>&
use_facet<moneypunct<wchar_t, true> >(const locale&);
extern template
const moneypunct<wchar_t, false>&
use_facet<moneypunct<wchar_t, false> >(const locale&);
extern template
const money_put<wchar_t>&
use_facet<money_put<wchar_t> >(const locale&);
extern template
const money_get<wchar_t>&
use_facet<money_get<wchar_t> >(const locale&);
extern template
const __timepunct<wchar_t>&
use_facet<__timepunct<wchar_t> >(const locale&);
extern template
const time_put<wchar_t>&
use_facet<time_put<wchar_t> >(const locale&);
extern template
const time_get<wchar_t>&
use_facet<time_get<wchar_t> >(const locale&);
extern template
const messages<wchar_t>&
use_facet<messages<wchar_t> >(const locale&);
extern template
bool
has_facet<moneypunct<wchar_t> >(const locale&);
extern template
bool
has_facet<money_put<wchar_t> >(const locale&);
extern template
bool
has_facet<money_get<wchar_t> >(const locale&);
extern template
bool
has_facet<__timepunct<wchar_t> >(const locale&);
extern template
bool
has_facet<time_put<wchar_t> >(const locale&);
extern template
bool
has_facet<time_get<wchar_t> >(const locale&);
extern template
bool
has_facet<messages<wchar_t> >(const locale&);
#endif
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif
c++/8/bits/stl_list.h 0000644 00000203746 15201526705 0010251 0 ustar 00 // List implementation -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1996,1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file bits/stl_list.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{list}
*/
#ifndef _STL_LIST_H
#define _STL_LIST_H 1
#include <bits/concept_check.h>
#include <ext/alloc_traits.h>
#if __cplusplus >= 201103L
#include <initializer_list>
#include <bits/allocated_ptr.h>
#include <ext/aligned_buffer.h>
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
namespace __detail
{
// Supporting structures are split into common and templated
// types; the latter publicly inherits from the former in an
// effort to reduce code duplication. This results in some
// "needless" static_cast'ing later on, but it's all safe
// downcasting.
/// Common part of a node in the %list.
struct _List_node_base
{
_List_node_base* _M_next;
_List_node_base* _M_prev;
static void
swap(_List_node_base& __x, _List_node_base& __y) _GLIBCXX_USE_NOEXCEPT;
void
_M_transfer(_List_node_base* const __first,
_List_node_base* const __last) _GLIBCXX_USE_NOEXCEPT;
void
_M_reverse() _GLIBCXX_USE_NOEXCEPT;
void
_M_hook(_List_node_base* const __position) _GLIBCXX_USE_NOEXCEPT;
void
_M_unhook() _GLIBCXX_USE_NOEXCEPT;
};
/// The %list node header.
struct _List_node_header : public _List_node_base
{
#if _GLIBCXX_USE_CXX11_ABI
std::size_t _M_size;
#endif
_List_node_header() _GLIBCXX_NOEXCEPT
{ _M_init(); }
#if __cplusplus >= 201103L
_List_node_header(_List_node_header&& __x) noexcept
: _List_node_base{ __x._M_next, __x._M_prev }
# if _GLIBCXX_USE_CXX11_ABI
, _M_size(__x._M_size)
# endif
{
if (__x._M_base()->_M_next == __x._M_base())
this->_M_next = this->_M_prev = this;
else
{
this->_M_next->_M_prev = this->_M_prev->_M_next = this->_M_base();
__x._M_init();
}
}
void
_M_move_nodes(_List_node_header&& __x)
{
_List_node_base* const __xnode = __x._M_base();
if (__xnode->_M_next == __xnode)
_M_init();
else
{
_List_node_base* const __node = this->_M_base();
__node->_M_next = __xnode->_M_next;
__node->_M_prev = __xnode->_M_prev;
__node->_M_next->_M_prev = __node->_M_prev->_M_next = __node;
# if _GLIBCXX_USE_CXX11_ABI
_M_size = __x._M_size;
# endif
__x._M_init();
}
}
#endif
void
_M_init() _GLIBCXX_NOEXCEPT
{
this->_M_next = this->_M_prev = this;
#if _GLIBCXX_USE_CXX11_ABI
this->_M_size = 0;
#endif
}
private:
_List_node_base* _M_base() { return this; }
};
} // namespace detail
_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
/// An actual node in the %list.
template<typename _Tp>
struct _List_node : public __detail::_List_node_base
{
#if __cplusplus >= 201103L
__gnu_cxx::__aligned_membuf<_Tp> _M_storage;
_Tp* _M_valptr() { return _M_storage._M_ptr(); }
_Tp const* _M_valptr() const { return _M_storage._M_ptr(); }
#else
_Tp _M_data;
_Tp* _M_valptr() { return std::__addressof(_M_data); }
_Tp const* _M_valptr() const { return std::__addressof(_M_data); }
#endif
};
/**
* @brief A list::iterator.
*
* All the functions are op overloads.
*/
template<typename _Tp>
struct _List_iterator
{
typedef _List_iterator<_Tp> _Self;
typedef _List_node<_Tp> _Node;
typedef ptrdiff_t difference_type;
typedef std::bidirectional_iterator_tag iterator_category;
typedef _Tp value_type;
typedef _Tp* pointer;
typedef _Tp& reference;
_List_iterator() _GLIBCXX_NOEXCEPT
: _M_node() { }
explicit
_List_iterator(__detail::_List_node_base* __x) _GLIBCXX_NOEXCEPT
: _M_node(__x) { }
_Self
_M_const_cast() const _GLIBCXX_NOEXCEPT
{ return *this; }
// Must downcast from _List_node_base to _List_node to get to value.
reference
operator*() const _GLIBCXX_NOEXCEPT
{ return *static_cast<_Node*>(_M_node)->_M_valptr(); }
pointer
operator->() const _GLIBCXX_NOEXCEPT
{ return static_cast<_Node*>(_M_node)->_M_valptr(); }
_Self&
operator++() _GLIBCXX_NOEXCEPT
{
_M_node = _M_node->_M_next;
return *this;
}
_Self
operator++(int) _GLIBCXX_NOEXCEPT
{
_Self __tmp = *this;
_M_node = _M_node->_M_next;
return __tmp;
}
_Self&
operator--() _GLIBCXX_NOEXCEPT
{
_M_node = _M_node->_M_prev;
return *this;
}
_Self
operator--(int) _GLIBCXX_NOEXCEPT
{
_Self __tmp = *this;
_M_node = _M_node->_M_prev;
return __tmp;
}
bool
operator==(const _Self& __x) const _GLIBCXX_NOEXCEPT
{ return _M_node == __x._M_node; }
bool
operator!=(const _Self& __x) const _GLIBCXX_NOEXCEPT
{ return _M_node != __x._M_node; }
// The only member points to the %list element.
__detail::_List_node_base* _M_node;
};
/**
* @brief A list::const_iterator.
*
* All the functions are op overloads.
*/
template<typename _Tp>
struct _List_const_iterator
{
typedef _List_const_iterator<_Tp> _Self;
typedef const _List_node<_Tp> _Node;
typedef _List_iterator<_Tp> iterator;
typedef ptrdiff_t difference_type;
typedef std::bidirectional_iterator_tag iterator_category;
typedef _Tp value_type;
typedef const _Tp* pointer;
typedef const _Tp& reference;
_List_const_iterator() _GLIBCXX_NOEXCEPT
: _M_node() { }
explicit
_List_const_iterator(const __detail::_List_node_base* __x)
_GLIBCXX_NOEXCEPT
: _M_node(__x) { }
_List_const_iterator(const iterator& __x) _GLIBCXX_NOEXCEPT
: _M_node(__x._M_node) { }
iterator
_M_const_cast() const _GLIBCXX_NOEXCEPT
{ return iterator(const_cast<__detail::_List_node_base*>(_M_node)); }
// Must downcast from List_node_base to _List_node to get to value.
reference
operator*() const _GLIBCXX_NOEXCEPT
{ return *static_cast<_Node*>(_M_node)->_M_valptr(); }
pointer
operator->() const _GLIBCXX_NOEXCEPT
{ return static_cast<_Node*>(_M_node)->_M_valptr(); }
_Self&
operator++() _GLIBCXX_NOEXCEPT
{
_M_node = _M_node->_M_next;
return *this;
}
_Self
operator++(int) _GLIBCXX_NOEXCEPT
{
_Self __tmp = *this;
_M_node = _M_node->_M_next;
return __tmp;
}
_Self&
operator--() _GLIBCXX_NOEXCEPT
{
_M_node = _M_node->_M_prev;
return *this;
}
_Self
operator--(int) _GLIBCXX_NOEXCEPT
{
_Self __tmp = *this;
_M_node = _M_node->_M_prev;
return __tmp;
}
bool
operator==(const _Self& __x) const _GLIBCXX_NOEXCEPT
{ return _M_node == __x._M_node; }
bool
operator!=(const _Self& __x) const _GLIBCXX_NOEXCEPT
{ return _M_node != __x._M_node; }
// The only member points to the %list element.
const __detail::_List_node_base* _M_node;
};
template<typename _Val>
inline bool
operator==(const _List_iterator<_Val>& __x,
const _List_const_iterator<_Val>& __y) _GLIBCXX_NOEXCEPT
{ return __x._M_node == __y._M_node; }
template<typename _Val>
inline bool
operator!=(const _List_iterator<_Val>& __x,
const _List_const_iterator<_Val>& __y) _GLIBCXX_NOEXCEPT
{ return __x._M_node != __y._M_node; }
_GLIBCXX_BEGIN_NAMESPACE_CXX11
/// See bits/stl_deque.h's _Deque_base for an explanation.
template<typename _Tp, typename _Alloc>
class _List_base
{
protected:
typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template
rebind<_Tp>::other _Tp_alloc_type;
typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Tp_alloc_traits;
typedef typename _Tp_alloc_traits::template
rebind<_List_node<_Tp> >::other _Node_alloc_type;
typedef __gnu_cxx::__alloc_traits<_Node_alloc_type> _Node_alloc_traits;
#if !_GLIBCXX_INLINE_VERSION
static size_t
_S_distance(const __detail::_List_node_base* __first,
const __detail::_List_node_base* __last)
{
size_t __n = 0;
while (__first != __last)
{
__first = __first->_M_next;
++__n;
}
return __n;
}
#endif
struct _List_impl
: public _Node_alloc_type
{
__detail::_List_node_header _M_node;
_List_impl() _GLIBCXX_NOEXCEPT_IF(
is_nothrow_default_constructible<_Node_alloc_type>::value)
: _Node_alloc_type()
{ }
_List_impl(const _Node_alloc_type& __a) _GLIBCXX_NOEXCEPT
: _Node_alloc_type(__a)
{ }
#if __cplusplus >= 201103L
_List_impl(_List_impl&&) = default;
_List_impl(_Node_alloc_type&& __a, _List_impl&& __x)
: _Node_alloc_type(std::move(__a)), _M_node(std::move(__x._M_node))
{ }
_List_impl(_Node_alloc_type&& __a) noexcept
: _Node_alloc_type(std::move(__a))
{ }
#endif
};
_List_impl _M_impl;
#if _GLIBCXX_USE_CXX11_ABI
size_t _M_get_size() const { return _M_impl._M_node._M_size; }
void _M_set_size(size_t __n) { _M_impl._M_node._M_size = __n; }
void _M_inc_size(size_t __n) { _M_impl._M_node._M_size += __n; }
void _M_dec_size(size_t __n) { _M_impl._M_node._M_size -= __n; }
# if !_GLIBCXX_INLINE_VERSION
size_t
_M_distance(const __detail::_List_node_base* __first,
const __detail::_List_node_base* __last) const
{ return _S_distance(__first, __last); }
// return the stored size
size_t _M_node_count() const { return _M_get_size(); }
# endif
#else
// dummy implementations used when the size is not stored
size_t _M_get_size() const { return 0; }
void _M_set_size(size_t) { }
void _M_inc_size(size_t) { }
void _M_dec_size(size_t) { }
# if !_GLIBCXX_INLINE_VERSION
size_t _M_distance(const void*, const void*) const { return 0; }
// count the number of nodes
size_t _M_node_count() const
{
return _S_distance(_M_impl._M_node._M_next,
std::__addressof(_M_impl._M_node));
}
# endif
#endif
typename _Node_alloc_traits::pointer
_M_get_node()
{ return _Node_alloc_traits::allocate(_M_impl, 1); }
void
_M_put_node(typename _Node_alloc_traits::pointer __p) _GLIBCXX_NOEXCEPT
{ _Node_alloc_traits::deallocate(_M_impl, __p, 1); }
public:
typedef _Alloc allocator_type;
_Node_alloc_type&
_M_get_Node_allocator() _GLIBCXX_NOEXCEPT
{ return _M_impl; }
const _Node_alloc_type&
_M_get_Node_allocator() const _GLIBCXX_NOEXCEPT
{ return _M_impl; }
#if __cplusplus >= 201103L
_List_base() = default;
#else
_List_base() { }
#endif
_List_base(const _Node_alloc_type& __a) _GLIBCXX_NOEXCEPT
: _M_impl(__a)
{ }
#if __cplusplus >= 201103L
_List_base(_List_base&&) = default;
# if !_GLIBCXX_INLINE_VERSION
_List_base(_List_base&& __x, _Node_alloc_type&& __a)
: _M_impl(std::move(__a))
{
if (__x._M_get_Node_allocator() == _M_get_Node_allocator())
_M_move_nodes(std::move(__x));
// else caller must move individual elements.
}
# endif
// Used when allocator is_always_equal.
_List_base(_Node_alloc_type&& __a, _List_base&& __x)
: _M_impl(std::move(__a), std::move(__x._M_impl))
{ }
// Used when allocator !is_always_equal.
_List_base(_Node_alloc_type&& __a)
: _M_impl(std::move(__a))
{ }
void
_M_move_nodes(_List_base&& __x)
{ _M_impl._M_node._M_move_nodes(std::move(__x._M_impl._M_node)); }
#endif
// This is what actually destroys the list.
~_List_base() _GLIBCXX_NOEXCEPT
{ _M_clear(); }
void
_M_clear() _GLIBCXX_NOEXCEPT;
void
_M_init() _GLIBCXX_NOEXCEPT
{ this->_M_impl._M_node._M_init(); }
};
/**
* @brief A standard container with linear time access to elements,
* and fixed time insertion/deletion at any point in the sequence.
*
* @ingroup sequences
*
* @tparam _Tp Type of element.
* @tparam _Alloc Allocator type, defaults to allocator<_Tp>.
*
* Meets the requirements of a <a href="tables.html#65">container</a>, a
* <a href="tables.html#66">reversible container</a>, and a
* <a href="tables.html#67">sequence</a>, including the
* <a href="tables.html#68">optional sequence requirements</a> with the
* %exception of @c at and @c operator[].
*
* This is a @e doubly @e linked %list. Traversal up and down the
* %list requires linear time, but adding and removing elements (or
* @e nodes) is done in constant time, regardless of where the
* change takes place. Unlike std::vector and std::deque,
* random-access iterators are not provided, so subscripting ( @c
* [] ) access is not allowed. For algorithms which only need
* sequential access, this lack makes no difference.
*
* Also unlike the other standard containers, std::list provides
* specialized algorithms %unique to linked lists, such as
* splicing, sorting, and in-place reversal.
*
* A couple points on memory allocation for list<Tp>:
*
* First, we never actually allocate a Tp, we allocate
* List_node<Tp>'s and trust [20.1.5]/4 to DTRT. This is to ensure
* that after elements from %list<X,Alloc1> are spliced into
* %list<X,Alloc2>, destroying the memory of the second %list is a
* valid operation, i.e., Alloc1 giveth and Alloc2 taketh away.
*
* Second, a %list conceptually represented as
* @code
* A <---> B <---> C <---> D
* @endcode
* is actually circular; a link exists between A and D. The %list
* class holds (as its only data member) a private list::iterator
* pointing to @e D, not to @e A! To get to the head of the %list,
* we start at the tail and move forward by one. When this member
* iterator's next/previous pointers refer to itself, the %list is
* %empty.
*/
template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
class list : protected _List_base<_Tp, _Alloc>
{
#ifdef _GLIBCXX_CONCEPT_CHECKS
// concept requirements
typedef typename _Alloc::value_type _Alloc_value_type;
# if __cplusplus < 201103L
__glibcxx_class_requires(_Tp, _SGIAssignableConcept)
# endif
__glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept)
#endif
#if __cplusplus >= 201103L
static_assert(is_same<typename remove_cv<_Tp>::type, _Tp>::value,
"std::list must have a non-const, non-volatile value_type");
# ifdef __STRICT_ANSI__
static_assert(is_same<typename _Alloc::value_type, _Tp>::value,
"std::list must have the same value_type as its allocator");
# endif
#endif
typedef _List_base<_Tp, _Alloc> _Base;
typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
typedef typename _Base::_Tp_alloc_traits _Tp_alloc_traits;
typedef typename _Base::_Node_alloc_type _Node_alloc_type;
typedef typename _Base::_Node_alloc_traits _Node_alloc_traits;
public:
typedef _Tp value_type;
typedef typename _Tp_alloc_traits::pointer pointer;
typedef typename _Tp_alloc_traits::const_pointer const_pointer;
typedef typename _Tp_alloc_traits::reference reference;
typedef typename _Tp_alloc_traits::const_reference const_reference;
typedef _List_iterator<_Tp> iterator;
typedef _List_const_iterator<_Tp> const_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef _Alloc allocator_type;
protected:
// Note that pointers-to-_Node's can be ctor-converted to
// iterator types.
typedef _List_node<_Tp> _Node;
using _Base::_M_impl;
using _Base::_M_put_node;
using _Base::_M_get_node;
using _Base::_M_get_Node_allocator;
/**
* @param __args An instance of user data.
*
* Allocates space for a new node and constructs a copy of
* @a __args in it.
*/
#if __cplusplus < 201103L
_Node*
_M_create_node(const value_type& __x)
{
_Node* __p = this->_M_get_node();
__try
{
_Tp_alloc_type __alloc(_M_get_Node_allocator());
__alloc.construct(__p->_M_valptr(), __x);
}
__catch(...)
{
_M_put_node(__p);
__throw_exception_again;
}
return __p;
}
#else
template<typename... _Args>
_Node*
_M_create_node(_Args&&... __args)
{
auto __p = this->_M_get_node();
auto& __alloc = _M_get_Node_allocator();
__allocated_ptr<_Node_alloc_type> __guard{__alloc, __p};
_Node_alloc_traits::construct(__alloc, __p->_M_valptr(),
std::forward<_Args>(__args)...);
__guard = nullptr;
return __p;
}
#endif
#if _GLIBCXX_USE_CXX11_ABI
static size_t
_S_distance(const_iterator __first, const_iterator __last)
{ return std::distance(__first, __last); }
// return the stored size
size_t
_M_node_count() const
{ return this->_M_get_size(); }
#else
// dummy implementations used when the size is not stored
static size_t
_S_distance(const_iterator, const_iterator)
{ return 0; }
// count the number of nodes
size_t
_M_node_count() const
{ return std::distance(begin(), end()); }
#endif
public:
// [23.2.2.1] construct/copy/destroy
// (assign() and get_allocator() are also listed in this section)
/**
* @brief Creates a %list with no elements.
*/
#if __cplusplus >= 201103L
list() = default;
#else
list() { }
#endif
/**
* @brief Creates a %list with no elements.
* @param __a An allocator object.
*/
explicit
list(const allocator_type& __a) _GLIBCXX_NOEXCEPT
: _Base(_Node_alloc_type(__a)) { }
#if __cplusplus >= 201103L
/**
* @brief Creates a %list with default constructed elements.
* @param __n The number of elements to initially create.
* @param __a An allocator object.
*
* This constructor fills the %list with @a __n default
* constructed elements.
*/
explicit
list(size_type __n, const allocator_type& __a = allocator_type())
: _Base(_Node_alloc_type(__a))
{ _M_default_initialize(__n); }
/**
* @brief Creates a %list with copies of an exemplar element.
* @param __n The number of elements to initially create.
* @param __value An element to copy.
* @param __a An allocator object.
*
* This constructor fills the %list with @a __n copies of @a __value.
*/
list(size_type __n, const value_type& __value,
const allocator_type& __a = allocator_type())
: _Base(_Node_alloc_type(__a))
{ _M_fill_initialize(__n, __value); }
#else
/**
* @brief Creates a %list with copies of an exemplar element.
* @param __n The number of elements to initially create.
* @param __value An element to copy.
* @param __a An allocator object.
*
* This constructor fills the %list with @a __n copies of @a __value.
*/
explicit
list(size_type __n, const value_type& __value = value_type(),
const allocator_type& __a = allocator_type())
: _Base(_Node_alloc_type(__a))
{ _M_fill_initialize(__n, __value); }
#endif
/**
* @brief %List copy constructor.
* @param __x A %list of identical element and allocator types.
*
* The newly-created %list uses a copy of the allocation object used
* by @a __x (unless the allocator traits dictate a different object).
*/
list(const list& __x)
: _Base(_Node_alloc_traits::
_S_select_on_copy(__x._M_get_Node_allocator()))
{ _M_initialize_dispatch(__x.begin(), __x.end(), __false_type()); }
#if __cplusplus >= 201103L
/**
* @brief %List move constructor.
*
* The newly-created %list contains the exact contents of the moved
* instance. The contents of the moved instance are a valid, but
* unspecified %list.
*/
list(list&&) = default;
/**
* @brief Builds a %list from an initializer_list
* @param __l An initializer_list of value_type.
* @param __a An allocator object.
*
* Create a %list consisting of copies of the elements in the
* initializer_list @a __l. This is linear in __l.size().
*/
list(initializer_list<value_type> __l,
const allocator_type& __a = allocator_type())
: _Base(_Node_alloc_type(__a))
{ _M_initialize_dispatch(__l.begin(), __l.end(), __false_type()); }
list(const list& __x, const allocator_type& __a)
: _Base(_Node_alloc_type(__a))
{ _M_initialize_dispatch(__x.begin(), __x.end(), __false_type()); }
private:
list(list&& __x, const allocator_type& __a, true_type) noexcept
: _Base(_Node_alloc_type(__a), std::move(__x))
{ }
list(list&& __x, const allocator_type& __a, false_type)
: _Base(_Node_alloc_type(__a))
{
if (__x._M_get_Node_allocator() == this->_M_get_Node_allocator())
this->_M_move_nodes(std::move(__x));
else
insert(begin(), std::__make_move_if_noexcept_iterator(__x.begin()),
std::__make_move_if_noexcept_iterator(__x.end()));
}
public:
list(list&& __x, const allocator_type& __a)
noexcept(_Node_alloc_traits::_S_always_equal())
: list(std::move(__x), __a,
typename _Node_alloc_traits::is_always_equal{})
{ }
#endif
/**
* @brief Builds a %list from a range.
* @param __first An input iterator.
* @param __last An input iterator.
* @param __a An allocator object.
*
* Create a %list consisting of copies of the elements from
* [@a __first,@a __last). This is linear in N (where N is
* distance(@a __first,@a __last)).
*/
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
list(_InputIterator __first, _InputIterator __last,
const allocator_type& __a = allocator_type())
: _Base(_Node_alloc_type(__a))
{ _M_initialize_dispatch(__first, __last, __false_type()); }
#else
template<typename _InputIterator>
list(_InputIterator __first, _InputIterator __last,
const allocator_type& __a = allocator_type())
: _Base(_Node_alloc_type(__a))
{
// Check whether it's an integral type. If so, it's not an iterator.
typedef typename std::__is_integer<_InputIterator>::__type _Integral;
_M_initialize_dispatch(__first, __last, _Integral());
}
#endif
#if __cplusplus >= 201103L
/**
* No explicit dtor needed as the _Base dtor takes care of
* things. The _Base dtor only erases the elements, and note
* that if the elements themselves are pointers, the pointed-to
* memory is not touched in any way. Managing the pointer is
* the user's responsibility.
*/
~list() = default;
#endif
/**
* @brief %List assignment operator.
* @param __x A %list of identical element and allocator types.
*
* All the elements of @a __x are copied.
*
* Whether the allocator is copied depends on the allocator traits.
*/
list&
operator=(const list& __x);
#if __cplusplus >= 201103L
/**
* @brief %List move assignment operator.
* @param __x A %list of identical element and allocator types.
*
* The contents of @a __x are moved into this %list (without copying).
*
* Afterwards @a __x is a valid, but unspecified %list
*
* Whether the allocator is moved depends on the allocator traits.
*/
list&
operator=(list&& __x)
noexcept(_Node_alloc_traits::_S_nothrow_move())
{
constexpr bool __move_storage =
_Node_alloc_traits::_S_propagate_on_move_assign()
|| _Node_alloc_traits::_S_always_equal();
_M_move_assign(std::move(__x), __bool_constant<__move_storage>());
return *this;
}
/**
* @brief %List initializer list assignment operator.
* @param __l An initializer_list of value_type.
*
* Replace the contents of the %list with copies of the elements
* in the initializer_list @a __l. This is linear in l.size().
*/
list&
operator=(initializer_list<value_type> __l)
{
this->assign(__l.begin(), __l.end());
return *this;
}
#endif
/**
* @brief Assigns a given value to a %list.
* @param __n Number of elements to be assigned.
* @param __val Value to be assigned.
*
* This function fills a %list with @a __n copies of the given
* value. Note that the assignment completely changes the %list
* and that the resulting %list's size is the same as the number
* of elements assigned.
*/
void
assign(size_type __n, const value_type& __val)
{ _M_fill_assign(__n, __val); }
/**
* @brief Assigns a range to a %list.
* @param __first An input iterator.
* @param __last An input iterator.
*
* This function fills a %list with copies of the elements in the
* range [@a __first,@a __last).
*
* Note that the assignment completely changes the %list and
* that the resulting %list's size is the same as the number of
* elements assigned.
*/
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
void
assign(_InputIterator __first, _InputIterator __last)
{ _M_assign_dispatch(__first, __last, __false_type()); }
#else
template<typename _InputIterator>
void
assign(_InputIterator __first, _InputIterator __last)
{
// Check whether it's an integral type. If so, it's not an iterator.
typedef typename std::__is_integer<_InputIterator>::__type _Integral;
_M_assign_dispatch(__first, __last, _Integral());
}
#endif
#if __cplusplus >= 201103L
/**
* @brief Assigns an initializer_list to a %list.
* @param __l An initializer_list of value_type.
*
* Replace the contents of the %list with copies of the elements
* in the initializer_list @a __l. This is linear in __l.size().
*/
void
assign(initializer_list<value_type> __l)
{ this->_M_assign_dispatch(__l.begin(), __l.end(), __false_type()); }
#endif
/// Get a copy of the memory allocation object.
allocator_type
get_allocator() const _GLIBCXX_NOEXCEPT
{ return allocator_type(_Base::_M_get_Node_allocator()); }
// iterators
/**
* Returns a read/write iterator that points to the first element in the
* %list. Iteration is done in ordinary element order.
*/
iterator
begin() _GLIBCXX_NOEXCEPT
{ return iterator(this->_M_impl._M_node._M_next); }
/**
* Returns a read-only (constant) iterator that points to the
* first element in the %list. Iteration is done in ordinary
* element order.
*/
const_iterator
begin() const _GLIBCXX_NOEXCEPT
{ return const_iterator(this->_M_impl._M_node._M_next); }
/**
* Returns a read/write iterator that points one past the last
* element in the %list. Iteration is done in ordinary element
* order.
*/
iterator
end() _GLIBCXX_NOEXCEPT
{ return iterator(&this->_M_impl._M_node); }
/**
* Returns a read-only (constant) iterator that points one past
* the last element in the %list. Iteration is done in ordinary
* element order.
*/
const_iterator
end() const _GLIBCXX_NOEXCEPT
{ return const_iterator(&this->_M_impl._M_node); }
/**
* Returns a read/write reverse iterator that points to the last
* element in the %list. Iteration is done in reverse element
* order.
*/
reverse_iterator
rbegin() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(end()); }
/**
* Returns a read-only (constant) reverse iterator that points to
* the last element in the %list. Iteration is done in reverse
* element order.
*/
const_reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(end()); }
/**
* Returns a read/write reverse iterator that points to one
* before the first element in the %list. Iteration is done in
* reverse element order.
*/
reverse_iterator
rend() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(begin()); }
/**
* Returns a read-only (constant) reverse iterator that points to one
* before the first element in the %list. Iteration is done in reverse
* element order.
*/
const_reverse_iterator
rend() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(begin()); }
#if __cplusplus >= 201103L
/**
* Returns a read-only (constant) iterator that points to the
* first element in the %list. Iteration is done in ordinary
* element order.
*/
const_iterator
cbegin() const noexcept
{ return const_iterator(this->_M_impl._M_node._M_next); }
/**
* Returns a read-only (constant) iterator that points one past
* the last element in the %list. Iteration is done in ordinary
* element order.
*/
const_iterator
cend() const noexcept
{ return const_iterator(&this->_M_impl._M_node); }
/**
* Returns a read-only (constant) reverse iterator that points to
* the last element in the %list. Iteration is done in reverse
* element order.
*/
const_reverse_iterator
crbegin() const noexcept
{ return const_reverse_iterator(end()); }
/**
* Returns a read-only (constant) reverse iterator that points to one
* before the first element in the %list. Iteration is done in reverse
* element order.
*/
const_reverse_iterator
crend() const noexcept
{ return const_reverse_iterator(begin()); }
#endif
// [23.2.2.2] capacity
/**
* Returns true if the %list is empty. (Thus begin() would equal
* end().)
*/
bool
empty() const _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_node._M_next == &this->_M_impl._M_node; }
/** Returns the number of elements in the %list. */
size_type
size() const _GLIBCXX_NOEXCEPT
{ return _M_node_count(); }
/** Returns the size() of the largest possible %list. */
size_type
max_size() const _GLIBCXX_NOEXCEPT
{ return _Node_alloc_traits::max_size(_M_get_Node_allocator()); }
#if __cplusplus >= 201103L
/**
* @brief Resizes the %list to the specified number of elements.
* @param __new_size Number of elements the %list should contain.
*
* This function will %resize the %list to the specified number
* of elements. If the number is smaller than the %list's
* current size the %list is truncated, otherwise default
* constructed elements are appended.
*/
void
resize(size_type __new_size);
/**
* @brief Resizes the %list to the specified number of elements.
* @param __new_size Number of elements the %list should contain.
* @param __x Data with which new elements should be populated.
*
* This function will %resize the %list to the specified number
* of elements. If the number is smaller than the %list's
* current size the %list is truncated, otherwise the %list is
* extended and new elements are populated with given data.
*/
void
resize(size_type __new_size, const value_type& __x);
#else
/**
* @brief Resizes the %list to the specified number of elements.
* @param __new_size Number of elements the %list should contain.
* @param __x Data with which new elements should be populated.
*
* This function will %resize the %list to the specified number
* of elements. If the number is smaller than the %list's
* current size the %list is truncated, otherwise the %list is
* extended and new elements are populated with given data.
*/
void
resize(size_type __new_size, value_type __x = value_type());
#endif
// element access
/**
* Returns a read/write reference to the data at the first
* element of the %list.
*/
reference
front() _GLIBCXX_NOEXCEPT
{ return *begin(); }
/**
* Returns a read-only (constant) reference to the data at the first
* element of the %list.
*/
const_reference
front() const _GLIBCXX_NOEXCEPT
{ return *begin(); }
/**
* Returns a read/write reference to the data at the last element
* of the %list.
*/
reference
back() _GLIBCXX_NOEXCEPT
{
iterator __tmp = end();
--__tmp;
return *__tmp;
}
/**
* Returns a read-only (constant) reference to the data at the last
* element of the %list.
*/
const_reference
back() const _GLIBCXX_NOEXCEPT
{
const_iterator __tmp = end();
--__tmp;
return *__tmp;
}
// [23.2.2.3] modifiers
/**
* @brief Add data to the front of the %list.
* @param __x Data to be added.
*
* This is a typical stack operation. The function creates an
* element at the front of the %list and assigns the given data
* to it. Due to the nature of a %list this operation can be
* done in constant time, and does not invalidate iterators and
* references.
*/
void
push_front(const value_type& __x)
{ this->_M_insert(begin(), __x); }
#if __cplusplus >= 201103L
void
push_front(value_type&& __x)
{ this->_M_insert(begin(), std::move(__x)); }
template<typename... _Args>
#if __cplusplus > 201402L
reference
#else
void
#endif
emplace_front(_Args&&... __args)
{
this->_M_insert(begin(), std::forward<_Args>(__args)...);
#if __cplusplus > 201402L
return front();
#endif
}
#endif
/**
* @brief Removes first element.
*
* This is a typical stack operation. It shrinks the %list by
* one. Due to the nature of a %list this operation can be done
* in constant time, and only invalidates iterators/references to
* the element being removed.
*
* Note that no data is returned, and if the first element's data
* is needed, it should be retrieved before pop_front() is
* called.
*/
void
pop_front() _GLIBCXX_NOEXCEPT
{ this->_M_erase(begin()); }
/**
* @brief Add data to the end of the %list.
* @param __x Data to be added.
*
* This is a typical stack operation. The function creates an
* element at the end of the %list and assigns the given data to
* it. Due to the nature of a %list this operation can be done
* in constant time, and does not invalidate iterators and
* references.
*/
void
push_back(const value_type& __x)
{ this->_M_insert(end(), __x); }
#if __cplusplus >= 201103L
void
push_back(value_type&& __x)
{ this->_M_insert(end(), std::move(__x)); }
template<typename... _Args>
#if __cplusplus > 201402L
reference
#else
void
#endif
emplace_back(_Args&&... __args)
{
this->_M_insert(end(), std::forward<_Args>(__args)...);
#if __cplusplus > 201402L
return back();
#endif
}
#endif
/**
* @brief Removes last element.
*
* This is a typical stack operation. It shrinks the %list by
* one. Due to the nature of a %list this operation can be done
* in constant time, and only invalidates iterators/references to
* the element being removed.
*
* Note that no data is returned, and if the last element's data
* is needed, it should be retrieved before pop_back() is called.
*/
void
pop_back() _GLIBCXX_NOEXCEPT
{ this->_M_erase(iterator(this->_M_impl._M_node._M_prev)); }
#if __cplusplus >= 201103L
/**
* @brief Constructs object in %list before specified iterator.
* @param __position A const_iterator into the %list.
* @param __args Arguments.
* @return An iterator that points to the inserted data.
*
* This function will insert an object of type T constructed
* with T(std::forward<Args>(args)...) before the specified
* location. Due to the nature of a %list this operation can
* be done in constant time, and does not invalidate iterators
* and references.
*/
template<typename... _Args>
iterator
emplace(const_iterator __position, _Args&&... __args);
/**
* @brief Inserts given value into %list before specified iterator.
* @param __position A const_iterator into the %list.
* @param __x Data to be inserted.
* @return An iterator that points to the inserted data.
*
* This function will insert a copy of the given value before
* the specified location. Due to the nature of a %list this
* operation can be done in constant time, and does not
* invalidate iterators and references.
*/
iterator
insert(const_iterator __position, const value_type& __x);
#else
/**
* @brief Inserts given value into %list before specified iterator.
* @param __position An iterator into the %list.
* @param __x Data to be inserted.
* @return An iterator that points to the inserted data.
*
* This function will insert a copy of the given value before
* the specified location. Due to the nature of a %list this
* operation can be done in constant time, and does not
* invalidate iterators and references.
*/
iterator
insert(iterator __position, const value_type& __x);
#endif
#if __cplusplus >= 201103L
/**
* @brief Inserts given rvalue into %list before specified iterator.
* @param __position A const_iterator into the %list.
* @param __x Data to be inserted.
* @return An iterator that points to the inserted data.
*
* This function will insert a copy of the given rvalue before
* the specified location. Due to the nature of a %list this
* operation can be done in constant time, and does not
* invalidate iterators and references.
*/
iterator
insert(const_iterator __position, value_type&& __x)
{ return emplace(__position, std::move(__x)); }
/**
* @brief Inserts the contents of an initializer_list into %list
* before specified const_iterator.
* @param __p A const_iterator into the %list.
* @param __l An initializer_list of value_type.
* @return An iterator pointing to the first element inserted
* (or __position).
*
* This function will insert copies of the data in the
* initializer_list @a l into the %list before the location
* specified by @a p.
*
* This operation is linear in the number of elements inserted and
* does not invalidate iterators and references.
*/
iterator
insert(const_iterator __p, initializer_list<value_type> __l)
{ return this->insert(__p, __l.begin(), __l.end()); }
#endif
#if __cplusplus >= 201103L
/**
* @brief Inserts a number of copies of given data into the %list.
* @param __position A const_iterator into the %list.
* @param __n Number of elements to be inserted.
* @param __x Data to be inserted.
* @return An iterator pointing to the first element inserted
* (or __position).
*
* This function will insert a specified number of copies of the
* given data before the location specified by @a position.
*
* This operation is linear in the number of elements inserted and
* does not invalidate iterators and references.
*/
iterator
insert(const_iterator __position, size_type __n, const value_type& __x);
#else
/**
* @brief Inserts a number of copies of given data into the %list.
* @param __position An iterator into the %list.
* @param __n Number of elements to be inserted.
* @param __x Data to be inserted.
*
* This function will insert a specified number of copies of the
* given data before the location specified by @a position.
*
* This operation is linear in the number of elements inserted and
* does not invalidate iterators and references.
*/
void
insert(iterator __position, size_type __n, const value_type& __x)
{
list __tmp(__n, __x, get_allocator());
splice(__position, __tmp);
}
#endif
#if __cplusplus >= 201103L
/**
* @brief Inserts a range into the %list.
* @param __position A const_iterator into the %list.
* @param __first An input iterator.
* @param __last An input iterator.
* @return An iterator pointing to the first element inserted
* (or __position).
*
* This function will insert copies of the data in the range [@a
* first,@a last) into the %list before the location specified by
* @a position.
*
* This operation is linear in the number of elements inserted and
* does not invalidate iterators and references.
*/
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
iterator
insert(const_iterator __position, _InputIterator __first,
_InputIterator __last);
#else
/**
* @brief Inserts a range into the %list.
* @param __position An iterator into the %list.
* @param __first An input iterator.
* @param __last An input iterator.
*
* This function will insert copies of the data in the range [@a
* first,@a last) into the %list before the location specified by
* @a position.
*
* This operation is linear in the number of elements inserted and
* does not invalidate iterators and references.
*/
template<typename _InputIterator>
void
insert(iterator __position, _InputIterator __first,
_InputIterator __last)
{
list __tmp(__first, __last, get_allocator());
splice(__position, __tmp);
}
#endif
/**
* @brief Remove element at given position.
* @param __position Iterator pointing to element to be erased.
* @return An iterator pointing to the next element (or end()).
*
* This function will erase the element at the given position and thus
* shorten the %list by one.
*
* Due to the nature of a %list this operation can be done in
* constant time, and only invalidates iterators/references to
* the element being removed. The user is also cautioned that
* this function only erases the element, and that if the element
* is itself a pointer, the pointed-to memory is not touched in
* any way. Managing the pointer is the user's responsibility.
*/
iterator
#if __cplusplus >= 201103L
erase(const_iterator __position) noexcept;
#else
erase(iterator __position);
#endif
/**
* @brief Remove a range of elements.
* @param __first Iterator pointing to the first element to be erased.
* @param __last Iterator pointing to one past the last element to be
* erased.
* @return An iterator pointing to the element pointed to by @a last
* prior to erasing (or end()).
*
* This function will erase the elements in the range @a
* [first,last) and shorten the %list accordingly.
*
* This operation is linear time in the size of the range and only
* invalidates iterators/references to the element being removed.
* The user is also cautioned that this function only erases the
* elements, and that if the elements themselves are pointers, the
* pointed-to memory is not touched in any way. Managing the pointer
* is the user's responsibility.
*/
iterator
#if __cplusplus >= 201103L
erase(const_iterator __first, const_iterator __last) noexcept
#else
erase(iterator __first, iterator __last)
#endif
{
while (__first != __last)
__first = erase(__first);
return __last._M_const_cast();
}
/**
* @brief Swaps data with another %list.
* @param __x A %list of the same element and allocator types.
*
* This exchanges the elements between two lists in constant
* time. Note that the global std::swap() function is
* specialized such that std::swap(l1,l2) will feed to this
* function.
*
* Whether the allocators are swapped depends on the allocator traits.
*/
void
swap(list& __x) _GLIBCXX_NOEXCEPT
{
__detail::_List_node_base::swap(this->_M_impl._M_node,
__x._M_impl._M_node);
size_t __xsize = __x._M_get_size();
__x._M_set_size(this->_M_get_size());
this->_M_set_size(__xsize);
_Node_alloc_traits::_S_on_swap(this->_M_get_Node_allocator(),
__x._M_get_Node_allocator());
}
/**
* Erases all the elements. Note that this function only erases
* the elements, and that if the elements themselves are
* pointers, the pointed-to memory is not touched in any way.
* Managing the pointer is the user's responsibility.
*/
void
clear() _GLIBCXX_NOEXCEPT
{
_Base::_M_clear();
_Base::_M_init();
}
// [23.2.2.4] list operations
/**
* @brief Insert contents of another %list.
* @param __position Iterator referencing the element to insert before.
* @param __x Source list.
*
* The elements of @a __x are inserted in constant time in front of
* the element referenced by @a __position. @a __x becomes an empty
* list.
*
* Requires this != @a __x.
*/
void
#if __cplusplus >= 201103L
splice(const_iterator __position, list&& __x) noexcept
#else
splice(iterator __position, list& __x)
#endif
{
if (!__x.empty())
{
_M_check_equal_allocators(__x);
this->_M_transfer(__position._M_const_cast(),
__x.begin(), __x.end());
this->_M_inc_size(__x._M_get_size());
__x._M_set_size(0);
}
}
#if __cplusplus >= 201103L
void
splice(const_iterator __position, list& __x) noexcept
{ splice(__position, std::move(__x)); }
#endif
#if __cplusplus >= 201103L
/**
* @brief Insert element from another %list.
* @param __position Const_iterator referencing the element to
* insert before.
* @param __x Source list.
* @param __i Const_iterator referencing the element to move.
*
* Removes the element in list @a __x referenced by @a __i and
* inserts it into the current list before @a __position.
*/
void
splice(const_iterator __position, list&& __x, const_iterator __i) noexcept
#else
/**
* @brief Insert element from another %list.
* @param __position Iterator referencing the element to insert before.
* @param __x Source list.
* @param __i Iterator referencing the element to move.
*
* Removes the element in list @a __x referenced by @a __i and
* inserts it into the current list before @a __position.
*/
void
splice(iterator __position, list& __x, iterator __i)
#endif
{
iterator __j = __i._M_const_cast();
++__j;
if (__position == __i || __position == __j)
return;
if (this != std::__addressof(__x))
_M_check_equal_allocators(__x);
this->_M_transfer(__position._M_const_cast(),
__i._M_const_cast(), __j);
this->_M_inc_size(1);
__x._M_dec_size(1);
}
#if __cplusplus >= 201103L
/**
* @brief Insert element from another %list.
* @param __position Const_iterator referencing the element to
* insert before.
* @param __x Source list.
* @param __i Const_iterator referencing the element to move.
*
* Removes the element in list @a __x referenced by @a __i and
* inserts it into the current list before @a __position.
*/
void
splice(const_iterator __position, list& __x, const_iterator __i) noexcept
{ splice(__position, std::move(__x), __i); }
#endif
#if __cplusplus >= 201103L
/**
* @brief Insert range from another %list.
* @param __position Const_iterator referencing the element to
* insert before.
* @param __x Source list.
* @param __first Const_iterator referencing the start of range in x.
* @param __last Const_iterator referencing the end of range in x.
*
* Removes elements in the range [__first,__last) and inserts them
* before @a __position in constant time.
*
* Undefined if @a __position is in [__first,__last).
*/
void
splice(const_iterator __position, list&& __x, const_iterator __first,
const_iterator __last) noexcept
#else
/**
* @brief Insert range from another %list.
* @param __position Iterator referencing the element to insert before.
* @param __x Source list.
* @param __first Iterator referencing the start of range in x.
* @param __last Iterator referencing the end of range in x.
*
* Removes elements in the range [__first,__last) and inserts them
* before @a __position in constant time.
*
* Undefined if @a __position is in [__first,__last).
*/
void
splice(iterator __position, list& __x, iterator __first,
iterator __last)
#endif
{
if (__first != __last)
{
if (this != std::__addressof(__x))
_M_check_equal_allocators(__x);
size_t __n = _S_distance(__first, __last);
this->_M_inc_size(__n);
__x._M_dec_size(__n);
this->_M_transfer(__position._M_const_cast(),
__first._M_const_cast(),
__last._M_const_cast());
}
}
#if __cplusplus >= 201103L
/**
* @brief Insert range from another %list.
* @param __position Const_iterator referencing the element to
* insert before.
* @param __x Source list.
* @param __first Const_iterator referencing the start of range in x.
* @param __last Const_iterator referencing the end of range in x.
*
* Removes elements in the range [__first,__last) and inserts them
* before @a __position in constant time.
*
* Undefined if @a __position is in [__first,__last).
*/
void
splice(const_iterator __position, list& __x, const_iterator __first,
const_iterator __last) noexcept
{ splice(__position, std::move(__x), __first, __last); }
#endif
/**
* @brief Remove all elements equal to value.
* @param __value The value to remove.
*
* Removes every element in the list equal to @a value.
* Remaining elements stay in list order. Note that this
* function only erases the elements, and that if the elements
* themselves are pointers, the pointed-to memory is not
* touched in any way. Managing the pointer is the user's
* responsibility.
*/
void
remove(const _Tp& __value);
/**
* @brief Remove all elements satisfying a predicate.
* @tparam _Predicate Unary predicate function or object.
*
* Removes every element in the list for which the predicate
* returns true. Remaining elements stay in list order. Note
* that this function only erases the elements, and that if the
* elements themselves are pointers, the pointed-to memory is
* not touched in any way. Managing the pointer is the user's
* responsibility.
*/
template<typename _Predicate>
void
remove_if(_Predicate);
/**
* @brief Remove consecutive duplicate elements.
*
* For each consecutive set of elements with the same value,
* remove all but the first one. Remaining elements stay in
* list order. Note that this function only erases the
* elements, and that if the elements themselves are pointers,
* the pointed-to memory is not touched in any way. Managing
* the pointer is the user's responsibility.
*/
void
unique();
/**
* @brief Remove consecutive elements satisfying a predicate.
* @tparam _BinaryPredicate Binary predicate function or object.
*
* For each consecutive set of elements [first,last) that
* satisfy predicate(first,i) where i is an iterator in
* [first,last), remove all but the first one. Remaining
* elements stay in list order. Note that this function only
* erases the elements, and that if the elements themselves are
* pointers, the pointed-to memory is not touched in any way.
* Managing the pointer is the user's responsibility.
*/
template<typename _BinaryPredicate>
void
unique(_BinaryPredicate);
/**
* @brief Merge sorted lists.
* @param __x Sorted list to merge.
*
* Assumes that both @a __x and this list are sorted according to
* operator<(). Merges elements of @a __x into this list in
* sorted order, leaving @a __x empty when complete. Elements in
* this list precede elements in @a __x that are equal.
*/
#if __cplusplus >= 201103L
void
merge(list&& __x);
void
merge(list& __x)
{ merge(std::move(__x)); }
#else
void
merge(list& __x);
#endif
/**
* @brief Merge sorted lists according to comparison function.
* @tparam _StrictWeakOrdering Comparison function defining
* sort order.
* @param __x Sorted list to merge.
* @param __comp Comparison functor.
*
* Assumes that both @a __x and this list are sorted according to
* StrictWeakOrdering. Merges elements of @a __x into this list
* in sorted order, leaving @a __x empty when complete. Elements
* in this list precede elements in @a __x that are equivalent
* according to StrictWeakOrdering().
*/
#if __cplusplus >= 201103L
template<typename _StrictWeakOrdering>
void
merge(list&& __x, _StrictWeakOrdering __comp);
template<typename _StrictWeakOrdering>
void
merge(list& __x, _StrictWeakOrdering __comp)
{ merge(std::move(__x), __comp); }
#else
template<typename _StrictWeakOrdering>
void
merge(list& __x, _StrictWeakOrdering __comp);
#endif
/**
* @brief Reverse the elements in list.
*
* Reverse the order of elements in the list in linear time.
*/
void
reverse() _GLIBCXX_NOEXCEPT
{ this->_M_impl._M_node._M_reverse(); }
/**
* @brief Sort the elements.
*
* Sorts the elements of this list in NlogN time. Equivalent
* elements remain in list order.
*/
void
sort();
/**
* @brief Sort the elements according to comparison function.
*
* Sorts the elements of this list in NlogN time. Equivalent
* elements remain in list order.
*/
template<typename _StrictWeakOrdering>
void
sort(_StrictWeakOrdering);
protected:
// Internal constructor functions follow.
// Called by the range constructor to implement [23.1.1]/9
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 438. Ambiguity in the "do the right thing" clause
template<typename _Integer>
void
_M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
{ _M_fill_initialize(static_cast<size_type>(__n), __x); }
// Called by the range constructor to implement [23.1.1]/9
template<typename _InputIterator>
void
_M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
__false_type)
{
for (; __first != __last; ++__first)
#if __cplusplus >= 201103L
emplace_back(*__first);
#else
push_back(*__first);
#endif
}
// Called by list(n,v,a), and the range constructor when it turns out
// to be the same thing.
void
_M_fill_initialize(size_type __n, const value_type& __x)
{
for (; __n; --__n)
push_back(__x);
}
#if __cplusplus >= 201103L
// Called by list(n).
void
_M_default_initialize(size_type __n)
{
for (; __n; --__n)
emplace_back();
}
// Called by resize(sz).
void
_M_default_append(size_type __n);
#endif
// Internal assign functions follow.
// Called by the range assign to implement [23.1.1]/9
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 438. Ambiguity in the "do the right thing" clause
template<typename _Integer>
void
_M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
{ _M_fill_assign(__n, __val); }
// Called by the range assign to implement [23.1.1]/9
template<typename _InputIterator>
void
_M_assign_dispatch(_InputIterator __first, _InputIterator __last,
__false_type);
// Called by assign(n,t), and the range assign when it turns out
// to be the same thing.
void
_M_fill_assign(size_type __n, const value_type& __val);
// Moves the elements from [first,last) before position.
void
_M_transfer(iterator __position, iterator __first, iterator __last)
{ __position._M_node->_M_transfer(__first._M_node, __last._M_node); }
// Inserts new element at position given and with value given.
#if __cplusplus < 201103L
void
_M_insert(iterator __position, const value_type& __x)
{
_Node* __tmp = _M_create_node(__x);
__tmp->_M_hook(__position._M_node);
this->_M_inc_size(1);
}
#else
template<typename... _Args>
void
_M_insert(iterator __position, _Args&&... __args)
{
_Node* __tmp = _M_create_node(std::forward<_Args>(__args)...);
__tmp->_M_hook(__position._M_node);
this->_M_inc_size(1);
}
#endif
// Erases element at position given.
void
_M_erase(iterator __position) _GLIBCXX_NOEXCEPT
{
this->_M_dec_size(1);
__position._M_node->_M_unhook();
_Node* __n = static_cast<_Node*>(__position._M_node);
#if __cplusplus >= 201103L
_Node_alloc_traits::destroy(_M_get_Node_allocator(), __n->_M_valptr());
#else
_Tp_alloc_type(_M_get_Node_allocator()).destroy(__n->_M_valptr());
#endif
_M_put_node(__n);
}
// To implement the splice (and merge) bits of N1599.
void
_M_check_equal_allocators(list& __x) _GLIBCXX_NOEXCEPT
{
if (std::__alloc_neq<typename _Base::_Node_alloc_type>::
_S_do_it(_M_get_Node_allocator(), __x._M_get_Node_allocator()))
__builtin_abort();
}
// Used to implement resize.
const_iterator
_M_resize_pos(size_type& __new_size) const;
#if __cplusplus >= 201103L
void
_M_move_assign(list&& __x, true_type) noexcept
{
this->_M_clear();
this->_M_move_nodes(std::move(__x));
std::__alloc_on_move(this->_M_get_Node_allocator(),
__x._M_get_Node_allocator());
}
void
_M_move_assign(list&& __x, false_type)
{
if (__x._M_get_Node_allocator() == this->_M_get_Node_allocator())
_M_move_assign(std::move(__x), true_type{});
else
// The rvalue's allocator cannot be moved, or is not equal,
// so we need to individually move each element.
_M_assign_dispatch(std::__make_move_if_noexcept_iterator(__x.begin()),
std::__make_move_if_noexcept_iterator(__x.end()),
__false_type{});
}
#endif
};
#if __cpp_deduction_guides >= 201606
template<typename _InputIterator, typename _ValT
= typename iterator_traits<_InputIterator>::value_type,
typename _Allocator = allocator<_ValT>,
typename = _RequireInputIter<_InputIterator>,
typename = _RequireAllocator<_Allocator>>
list(_InputIterator, _InputIterator, _Allocator = _Allocator())
-> list<_ValT, _Allocator>;
#endif
_GLIBCXX_END_NAMESPACE_CXX11
/**
* @brief List equality comparison.
* @param __x A %list.
* @param __y A %list of the same type as @a __x.
* @return True iff the size and elements of the lists are equal.
*
* This is an equivalence relation. It is linear in the size of
* the lists. Lists are considered equivalent if their sizes are
* equal, and if corresponding elements compare equal.
*/
template<typename _Tp, typename _Alloc>
inline bool
operator==(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
{
#if _GLIBCXX_USE_CXX11_ABI
if (__x.size() != __y.size())
return false;
#endif
typedef typename list<_Tp, _Alloc>::const_iterator const_iterator;
const_iterator __end1 = __x.end();
const_iterator __end2 = __y.end();
const_iterator __i1 = __x.begin();
const_iterator __i2 = __y.begin();
while (__i1 != __end1 && __i2 != __end2 && *__i1 == *__i2)
{
++__i1;
++__i2;
}
return __i1 == __end1 && __i2 == __end2;
}
/**
* @brief List ordering relation.
* @param __x A %list.
* @param __y A %list of the same type as @a __x.
* @return True iff @a __x is lexicographically less than @a __y.
*
* This is a total ordering relation. It is linear in the size of the
* lists. The elements must be comparable with @c <.
*
* See std::lexicographical_compare() for how the determination is made.
*/
template<typename _Tp, typename _Alloc>
inline bool
operator<(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
{ return std::lexicographical_compare(__x.begin(), __x.end(),
__y.begin(), __y.end()); }
/// Based on operator==
template<typename _Tp, typename _Alloc>
inline bool
operator!=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
{ return !(__x == __y); }
/// Based on operator<
template<typename _Tp, typename _Alloc>
inline bool
operator>(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
{ return __y < __x; }
/// Based on operator<
template<typename _Tp, typename _Alloc>
inline bool
operator<=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
{ return !(__y < __x); }
/// Based on operator<
template<typename _Tp, typename _Alloc>
inline bool
operator>=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
{ return !(__x < __y); }
/// See std::list::swap().
template<typename _Tp, typename _Alloc>
inline void
swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y)
_GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
{ __x.swap(__y); }
_GLIBCXX_END_NAMESPACE_CONTAINER
#if _GLIBCXX_USE_CXX11_ABI
// Detect when distance is used to compute the size of the whole list.
template<typename _Tp>
inline ptrdiff_t
__distance(_GLIBCXX_STD_C::_List_iterator<_Tp> __first,
_GLIBCXX_STD_C::_List_iterator<_Tp> __last,
input_iterator_tag __tag)
{
typedef _GLIBCXX_STD_C::_List_const_iterator<_Tp> _CIter;
return std::__distance(_CIter(__first), _CIter(__last), __tag);
}
template<typename _Tp>
inline ptrdiff_t
__distance(_GLIBCXX_STD_C::_List_const_iterator<_Tp> __first,
_GLIBCXX_STD_C::_List_const_iterator<_Tp> __last,
input_iterator_tag)
{
typedef __detail::_List_node_header _Sentinel;
_GLIBCXX_STD_C::_List_const_iterator<_Tp> __beyond = __last;
++__beyond;
const bool __whole = __first == __beyond;
if (__builtin_constant_p (__whole) && __whole)
return static_cast<const _Sentinel*>(__last._M_node)->_M_size;
ptrdiff_t __n = 0;
while (__first != __last)
{
++__first;
++__n;
}
return __n;
}
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif /* _STL_LIST_H */
c++/8/bits/stl_function.h 0000644 00000121421 15201526705 0011110 0 ustar 00 // Functor implementations -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1996-1998
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file bits/stl_function.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{functional}
*/
#ifndef _STL_FUNCTION_H
#define _STL_FUNCTION_H 1
#if __cplusplus > 201103L
#include <bits/move.h>
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// 20.3.1 base classes
/** @defgroup functors Function Objects
* @ingroup utilities
*
* Function objects, or @e functors, are objects with an @c operator()
* defined and accessible. They can be passed as arguments to algorithm
* templates and used in place of a function pointer. Not only is the
* resulting expressiveness of the library increased, but the generated
* code can be more efficient than what you might write by hand. When we
* refer to @a functors, then, generally we include function pointers in
* the description as well.
*
* Often, functors are only created as temporaries passed to algorithm
* calls, rather than being created as named variables.
*
* Two examples taken from the standard itself follow. To perform a
* by-element addition of two vectors @c a and @c b containing @c double,
* and put the result in @c a, use
* \code
* transform (a.begin(), a.end(), b.begin(), a.begin(), plus<double>());
* \endcode
* To negate every element in @c a, use
* \code
* transform(a.begin(), a.end(), a.begin(), negate<double>());
* \endcode
* The addition and negation functions will be inlined directly.
*
* The standard functors are derived from structs named @c unary_function
* and @c binary_function. These two classes contain nothing but typedefs,
* to aid in generic (template) programming. If you write your own
* functors, you might consider doing the same.
*
* @{
*/
/**
* This is one of the @link functors functor base classes@endlink.
*/
template<typename _Arg, typename _Result>
struct unary_function
{
/// @c argument_type is the type of the argument
typedef _Arg argument_type;
/// @c result_type is the return type
typedef _Result result_type;
};
/**
* This is one of the @link functors functor base classes@endlink.
*/
template<typename _Arg1, typename _Arg2, typename _Result>
struct binary_function
{
/// @c first_argument_type is the type of the first argument
typedef _Arg1 first_argument_type;
/// @c second_argument_type is the type of the second argument
typedef _Arg2 second_argument_type;
/// @c result_type is the return type
typedef _Result result_type;
};
/** @} */
// 20.3.2 arithmetic
/** @defgroup arithmetic_functors Arithmetic Classes
* @ingroup functors
*
* Because basic math often needs to be done during an algorithm,
* the library provides functors for those operations. See the
* documentation for @link functors the base classes@endlink
* for examples of their use.
*
* @{
*/
#if __cplusplus > 201103L
struct __is_transparent; // undefined
template<typename _Tp = void>
struct plus;
template<typename _Tp = void>
struct minus;
template<typename _Tp = void>
struct multiplies;
template<typename _Tp = void>
struct divides;
template<typename _Tp = void>
struct modulus;
template<typename _Tp = void>
struct negate;
#endif
/// One of the @link arithmetic_functors math functors@endlink.
template<typename _Tp>
struct plus : public binary_function<_Tp, _Tp, _Tp>
{
_GLIBCXX14_CONSTEXPR
_Tp
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x + __y; }
};
/// One of the @link arithmetic_functors math functors@endlink.
template<typename _Tp>
struct minus : public binary_function<_Tp, _Tp, _Tp>
{
_GLIBCXX14_CONSTEXPR
_Tp
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x - __y; }
};
/// One of the @link arithmetic_functors math functors@endlink.
template<typename _Tp>
struct multiplies : public binary_function<_Tp, _Tp, _Tp>
{
_GLIBCXX14_CONSTEXPR
_Tp
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x * __y; }
};
/// One of the @link arithmetic_functors math functors@endlink.
template<typename _Tp>
struct divides : public binary_function<_Tp, _Tp, _Tp>
{
_GLIBCXX14_CONSTEXPR
_Tp
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x / __y; }
};
/// One of the @link arithmetic_functors math functors@endlink.
template<typename _Tp>
struct modulus : public binary_function<_Tp, _Tp, _Tp>
{
_GLIBCXX14_CONSTEXPR
_Tp
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x % __y; }
};
/// One of the @link arithmetic_functors math functors@endlink.
template<typename _Tp>
struct negate : public unary_function<_Tp, _Tp>
{
_GLIBCXX14_CONSTEXPR
_Tp
operator()(const _Tp& __x) const
{ return -__x; }
};
#if __cplusplus > 201103L
#define __cpp_lib_transparent_operators 201510
template<>
struct plus<void>
{
template <typename _Tp, typename _Up>
_GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) + std::forward<_Up>(__u)))
-> decltype(std::forward<_Tp>(__t) + std::forward<_Up>(__u))
{ return std::forward<_Tp>(__t) + std::forward<_Up>(__u); }
typedef __is_transparent is_transparent;
};
/// One of the @link arithmetic_functors math functors@endlink.
template<>
struct minus<void>
{
template <typename _Tp, typename _Up>
_GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) - std::forward<_Up>(__u)))
-> decltype(std::forward<_Tp>(__t) - std::forward<_Up>(__u))
{ return std::forward<_Tp>(__t) - std::forward<_Up>(__u); }
typedef __is_transparent is_transparent;
};
/// One of the @link arithmetic_functors math functors@endlink.
template<>
struct multiplies<void>
{
template <typename _Tp, typename _Up>
_GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) * std::forward<_Up>(__u)))
-> decltype(std::forward<_Tp>(__t) * std::forward<_Up>(__u))
{ return std::forward<_Tp>(__t) * std::forward<_Up>(__u); }
typedef __is_transparent is_transparent;
};
/// One of the @link arithmetic_functors math functors@endlink.
template<>
struct divides<void>
{
template <typename _Tp, typename _Up>
_GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) / std::forward<_Up>(__u)))
-> decltype(std::forward<_Tp>(__t) / std::forward<_Up>(__u))
{ return std::forward<_Tp>(__t) / std::forward<_Up>(__u); }
typedef __is_transparent is_transparent;
};
/// One of the @link arithmetic_functors math functors@endlink.
template<>
struct modulus<void>
{
template <typename _Tp, typename _Up>
_GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) % std::forward<_Up>(__u)))
-> decltype(std::forward<_Tp>(__t) % std::forward<_Up>(__u))
{ return std::forward<_Tp>(__t) % std::forward<_Up>(__u); }
typedef __is_transparent is_transparent;
};
/// One of the @link arithmetic_functors math functors@endlink.
template<>
struct negate<void>
{
template <typename _Tp>
_GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t) const
noexcept(noexcept(-std::forward<_Tp>(__t)))
-> decltype(-std::forward<_Tp>(__t))
{ return -std::forward<_Tp>(__t); }
typedef __is_transparent is_transparent;
};
#endif
/** @} */
// 20.3.3 comparisons
/** @defgroup comparison_functors Comparison Classes
* @ingroup functors
*
* The library provides six wrapper functors for all the basic comparisons
* in C++, like @c <.
*
* @{
*/
#if __cplusplus > 201103L
template<typename _Tp = void>
struct equal_to;
template<typename _Tp = void>
struct not_equal_to;
template<typename _Tp = void>
struct greater;
template<typename _Tp = void>
struct less;
template<typename _Tp = void>
struct greater_equal;
template<typename _Tp = void>
struct less_equal;
#endif
/// One of the @link comparison_functors comparison functors@endlink.
template<typename _Tp>
struct equal_to : public binary_function<_Tp, _Tp, bool>
{
_GLIBCXX14_CONSTEXPR
bool
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x == __y; }
};
/// One of the @link comparison_functors comparison functors@endlink.
template<typename _Tp>
struct not_equal_to : public binary_function<_Tp, _Tp, bool>
{
_GLIBCXX14_CONSTEXPR
bool
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x != __y; }
};
/// One of the @link comparison_functors comparison functors@endlink.
template<typename _Tp>
struct greater : public binary_function<_Tp, _Tp, bool>
{
_GLIBCXX14_CONSTEXPR
bool
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x > __y; }
};
/// One of the @link comparison_functors comparison functors@endlink.
template<typename _Tp>
struct less : public binary_function<_Tp, _Tp, bool>
{
_GLIBCXX14_CONSTEXPR
bool
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x < __y; }
};
/// One of the @link comparison_functors comparison functors@endlink.
template<typename _Tp>
struct greater_equal : public binary_function<_Tp, _Tp, bool>
{
_GLIBCXX14_CONSTEXPR
bool
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x >= __y; }
};
/// One of the @link comparison_functors comparison functors@endlink.
template<typename _Tp>
struct less_equal : public binary_function<_Tp, _Tp, bool>
{
_GLIBCXX14_CONSTEXPR
bool
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x <= __y; }
};
// Partial specialization of std::greater for pointers.
template<typename _Tp>
struct greater<_Tp*> : public binary_function<_Tp*, _Tp*, bool>
{
_GLIBCXX14_CONSTEXPR bool
operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW
{
if (__builtin_constant_p (__x > __y))
return __x > __y;
return (__UINTPTR_TYPE__)__x > (__UINTPTR_TYPE__)__y;
}
};
// Partial specialization of std::less for pointers.
template<typename _Tp>
struct less<_Tp*> : public binary_function<_Tp*, _Tp*, bool>
{
_GLIBCXX14_CONSTEXPR bool
operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW
{
if (__builtin_constant_p (__x < __y))
return __x < __y;
return (__UINTPTR_TYPE__)__x < (__UINTPTR_TYPE__)__y;
}
};
// Partial specialization of std::greater_equal for pointers.
template<typename _Tp>
struct greater_equal<_Tp*> : public binary_function<_Tp*, _Tp*, bool>
{
_GLIBCXX14_CONSTEXPR bool
operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW
{
if (__builtin_constant_p (__x >= __y))
return __x >= __y;
return (__UINTPTR_TYPE__)__x >= (__UINTPTR_TYPE__)__y;
}
};
// Partial specialization of std::less_equal for pointers.
template<typename _Tp>
struct less_equal<_Tp*> : public binary_function<_Tp*, _Tp*, bool>
{
_GLIBCXX14_CONSTEXPR bool
operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW
{
if (__builtin_constant_p (__x <= __y))
return __x <= __y;
return (__UINTPTR_TYPE__)__x <= (__UINTPTR_TYPE__)__y;
}
};
#if __cplusplus >= 201402L
/// One of the @link comparison_functors comparison functors@endlink.
template<>
struct equal_to<void>
{
template <typename _Tp, typename _Up>
constexpr auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) == std::forward<_Up>(__u)))
-> decltype(std::forward<_Tp>(__t) == std::forward<_Up>(__u))
{ return std::forward<_Tp>(__t) == std::forward<_Up>(__u); }
typedef __is_transparent is_transparent;
};
/// One of the @link comparison_functors comparison functors@endlink.
template<>
struct not_equal_to<void>
{
template <typename _Tp, typename _Up>
constexpr auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) != std::forward<_Up>(__u)))
-> decltype(std::forward<_Tp>(__t) != std::forward<_Up>(__u))
{ return std::forward<_Tp>(__t) != std::forward<_Up>(__u); }
typedef __is_transparent is_transparent;
};
/// One of the @link comparison_functors comparison functors@endlink.
template<>
struct greater<void>
{
template <typename _Tp, typename _Up>
constexpr auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) > std::forward<_Up>(__u)))
-> decltype(std::forward<_Tp>(__t) > std::forward<_Up>(__u))
{
return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u),
__ptr_cmp<_Tp, _Up>{});
}
template<typename _Tp, typename _Up>
constexpr bool
operator()(_Tp* __t, _Up* __u) const noexcept
{ return greater<common_type_t<_Tp*, _Up*>>{}(__t, __u); }
typedef __is_transparent is_transparent;
private:
template <typename _Tp, typename _Up>
static constexpr decltype(auto)
_S_cmp(_Tp&& __t, _Up&& __u, false_type)
{ return std::forward<_Tp>(__t) > std::forward<_Up>(__u); }
template <typename _Tp, typename _Up>
static constexpr bool
_S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept
{
return greater<const volatile void*>{}(
static_cast<const volatile void*>(std::forward<_Tp>(__t)),
static_cast<const volatile void*>(std::forward<_Up>(__u)));
}
// True if there is no viable operator> member function.
template<typename _Tp, typename _Up, typename = void>
struct __not_overloaded2 : true_type { };
// False if we can call T.operator>(U)
template<typename _Tp, typename _Up>
struct __not_overloaded2<_Tp, _Up, __void_t<
decltype(std::declval<_Tp>().operator>(std::declval<_Up>()))>>
: false_type { };
// True if there is no overloaded operator> for these operands.
template<typename _Tp, typename _Up, typename = void>
struct __not_overloaded : __not_overloaded2<_Tp, _Up> { };
// False if we can call operator>(T,U)
template<typename _Tp, typename _Up>
struct __not_overloaded<_Tp, _Up, __void_t<
decltype(operator>(std::declval<_Tp>(), std::declval<_Up>()))>>
: false_type { };
template<typename _Tp, typename _Up>
using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>,
is_convertible<_Tp, const volatile void*>,
is_convertible<_Up, const volatile void*>>;
};
/// One of the @link comparison_functors comparison functors@endlink.
template<>
struct less<void>
{
template <typename _Tp, typename _Up>
constexpr auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) < std::forward<_Up>(__u)))
-> decltype(std::forward<_Tp>(__t) < std::forward<_Up>(__u))
{
return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u),
__ptr_cmp<_Tp, _Up>{});
}
template<typename _Tp, typename _Up>
constexpr bool
operator()(_Tp* __t, _Up* __u) const noexcept
{ return less<common_type_t<_Tp*, _Up*>>{}(__t, __u); }
typedef __is_transparent is_transparent;
private:
template <typename _Tp, typename _Up>
static constexpr decltype(auto)
_S_cmp(_Tp&& __t, _Up&& __u, false_type)
{ return std::forward<_Tp>(__t) < std::forward<_Up>(__u); }
template <typename _Tp, typename _Up>
static constexpr bool
_S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept
{
return less<const volatile void*>{}(
static_cast<const volatile void*>(std::forward<_Tp>(__t)),
static_cast<const volatile void*>(std::forward<_Up>(__u)));
}
// True if there is no viable operator< member function.
template<typename _Tp, typename _Up, typename = void>
struct __not_overloaded2 : true_type { };
// False if we can call T.operator<(U)
template<typename _Tp, typename _Up>
struct __not_overloaded2<_Tp, _Up, __void_t<
decltype(std::declval<_Tp>().operator<(std::declval<_Up>()))>>
: false_type { };
// True if there is no overloaded operator< for these operands.
template<typename _Tp, typename _Up, typename = void>
struct __not_overloaded : __not_overloaded2<_Tp, _Up> { };
// False if we can call operator<(T,U)
template<typename _Tp, typename _Up>
struct __not_overloaded<_Tp, _Up, __void_t<
decltype(operator<(std::declval<_Tp>(), std::declval<_Up>()))>>
: false_type { };
template<typename _Tp, typename _Up>
using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>,
is_convertible<_Tp, const volatile void*>,
is_convertible<_Up, const volatile void*>>;
};
/// One of the @link comparison_functors comparison functors@endlink.
template<>
struct greater_equal<void>
{
template <typename _Tp, typename _Up>
constexpr auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) >= std::forward<_Up>(__u)))
-> decltype(std::forward<_Tp>(__t) >= std::forward<_Up>(__u))
{
return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u),
__ptr_cmp<_Tp, _Up>{});
}
template<typename _Tp, typename _Up>
constexpr bool
operator()(_Tp* __t, _Up* __u) const noexcept
{ return greater_equal<common_type_t<_Tp*, _Up*>>{}(__t, __u); }
typedef __is_transparent is_transparent;
private:
template <typename _Tp, typename _Up>
static constexpr decltype(auto)
_S_cmp(_Tp&& __t, _Up&& __u, false_type)
{ return std::forward<_Tp>(__t) >= std::forward<_Up>(__u); }
template <typename _Tp, typename _Up>
static constexpr bool
_S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept
{
return greater_equal<const volatile void*>{}(
static_cast<const volatile void*>(std::forward<_Tp>(__t)),
static_cast<const volatile void*>(std::forward<_Up>(__u)));
}
// True if there is no viable operator>= member function.
template<typename _Tp, typename _Up, typename = void>
struct __not_overloaded2 : true_type { };
// False if we can call T.operator>=(U)
template<typename _Tp, typename _Up>
struct __not_overloaded2<_Tp, _Up, __void_t<
decltype(std::declval<_Tp>().operator>=(std::declval<_Up>()))>>
: false_type { };
// True if there is no overloaded operator>= for these operands.
template<typename _Tp, typename _Up, typename = void>
struct __not_overloaded : __not_overloaded2<_Tp, _Up> { };
// False if we can call operator>=(T,U)
template<typename _Tp, typename _Up>
struct __not_overloaded<_Tp, _Up, __void_t<
decltype(operator>=(std::declval<_Tp>(), std::declval<_Up>()))>>
: false_type { };
template<typename _Tp, typename _Up>
using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>,
is_convertible<_Tp, const volatile void*>,
is_convertible<_Up, const volatile void*>>;
};
/// One of the @link comparison_functors comparison functors@endlink.
template<>
struct less_equal<void>
{
template <typename _Tp, typename _Up>
constexpr auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) <= std::forward<_Up>(__u)))
-> decltype(std::forward<_Tp>(__t) <= std::forward<_Up>(__u))
{
return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u),
__ptr_cmp<_Tp, _Up>{});
}
template<typename _Tp, typename _Up>
constexpr bool
operator()(_Tp* __t, _Up* __u) const noexcept
{ return less_equal<common_type_t<_Tp*, _Up*>>{}(__t, __u); }
typedef __is_transparent is_transparent;
private:
template <typename _Tp, typename _Up>
static constexpr decltype(auto)
_S_cmp(_Tp&& __t, _Up&& __u, false_type)
{ return std::forward<_Tp>(__t) <= std::forward<_Up>(__u); }
template <typename _Tp, typename _Up>
static constexpr bool
_S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept
{
return less_equal<const volatile void*>{}(
static_cast<const volatile void*>(std::forward<_Tp>(__t)),
static_cast<const volatile void*>(std::forward<_Up>(__u)));
}
// True if there is no viable operator<= member function.
template<typename _Tp, typename _Up, typename = void>
struct __not_overloaded2 : true_type { };
// False if we can call T.operator<=(U)
template<typename _Tp, typename _Up>
struct __not_overloaded2<_Tp, _Up, __void_t<
decltype(std::declval<_Tp>().operator<=(std::declval<_Up>()))>>
: false_type { };
// True if there is no overloaded operator<= for these operands.
template<typename _Tp, typename _Up, typename = void>
struct __not_overloaded : __not_overloaded2<_Tp, _Up> { };
// False if we can call operator<=(T,U)
template<typename _Tp, typename _Up>
struct __not_overloaded<_Tp, _Up, __void_t<
decltype(operator<=(std::declval<_Tp>(), std::declval<_Up>()))>>
: false_type { };
template<typename _Tp, typename _Up>
using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>,
is_convertible<_Tp, const volatile void*>,
is_convertible<_Up, const volatile void*>>;
};
#endif // C++14
/** @} */
// 20.3.4 logical operations
/** @defgroup logical_functors Boolean Operations Classes
* @ingroup functors
*
* Here are wrapper functors for Boolean operations: @c &&, @c ||,
* and @c !.
*
* @{
*/
#if __cplusplus > 201103L
template<typename _Tp = void>
struct logical_and;
template<typename _Tp = void>
struct logical_or;
template<typename _Tp = void>
struct logical_not;
#endif
/// One of the @link logical_functors Boolean operations functors@endlink.
template<typename _Tp>
struct logical_and : public binary_function<_Tp, _Tp, bool>
{
_GLIBCXX14_CONSTEXPR
bool
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x && __y; }
};
/// One of the @link logical_functors Boolean operations functors@endlink.
template<typename _Tp>
struct logical_or : public binary_function<_Tp, _Tp, bool>
{
_GLIBCXX14_CONSTEXPR
bool
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x || __y; }
};
/// One of the @link logical_functors Boolean operations functors@endlink.
template<typename _Tp>
struct logical_not : public unary_function<_Tp, bool>
{
_GLIBCXX14_CONSTEXPR
bool
operator()(const _Tp& __x) const
{ return !__x; }
};
#if __cplusplus > 201103L
/// One of the @link logical_functors Boolean operations functors@endlink.
template<>
struct logical_and<void>
{
template <typename _Tp, typename _Up>
_GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) && std::forward<_Up>(__u)))
-> decltype(std::forward<_Tp>(__t) && std::forward<_Up>(__u))
{ return std::forward<_Tp>(__t) && std::forward<_Up>(__u); }
typedef __is_transparent is_transparent;
};
/// One of the @link logical_functors Boolean operations functors@endlink.
template<>
struct logical_or<void>
{
template <typename _Tp, typename _Up>
_GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) || std::forward<_Up>(__u)))
-> decltype(std::forward<_Tp>(__t) || std::forward<_Up>(__u))
{ return std::forward<_Tp>(__t) || std::forward<_Up>(__u); }
typedef __is_transparent is_transparent;
};
/// One of the @link logical_functors Boolean operations functors@endlink.
template<>
struct logical_not<void>
{
template <typename _Tp>
_GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t) const
noexcept(noexcept(!std::forward<_Tp>(__t)))
-> decltype(!std::forward<_Tp>(__t))
{ return !std::forward<_Tp>(__t); }
typedef __is_transparent is_transparent;
};
#endif
/** @} */
#if __cplusplus > 201103L
template<typename _Tp = void>
struct bit_and;
template<typename _Tp = void>
struct bit_or;
template<typename _Tp = void>
struct bit_xor;
template<typename _Tp = void>
struct bit_not;
#endif
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 660. Missing Bitwise Operations.
template<typename _Tp>
struct bit_and : public binary_function<_Tp, _Tp, _Tp>
{
_GLIBCXX14_CONSTEXPR
_Tp
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x & __y; }
};
template<typename _Tp>
struct bit_or : public binary_function<_Tp, _Tp, _Tp>
{
_GLIBCXX14_CONSTEXPR
_Tp
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x | __y; }
};
template<typename _Tp>
struct bit_xor : public binary_function<_Tp, _Tp, _Tp>
{
_GLIBCXX14_CONSTEXPR
_Tp
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x ^ __y; }
};
template<typename _Tp>
struct bit_not : public unary_function<_Tp, _Tp>
{
_GLIBCXX14_CONSTEXPR
_Tp
operator()(const _Tp& __x) const
{ return ~__x; }
};
#if __cplusplus > 201103L
template <>
struct bit_and<void>
{
template <typename _Tp, typename _Up>
_GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) & std::forward<_Up>(__u)))
-> decltype(std::forward<_Tp>(__t) & std::forward<_Up>(__u))
{ return std::forward<_Tp>(__t) & std::forward<_Up>(__u); }
typedef __is_transparent is_transparent;
};
template <>
struct bit_or<void>
{
template <typename _Tp, typename _Up>
_GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) | std::forward<_Up>(__u)))
-> decltype(std::forward<_Tp>(__t) | std::forward<_Up>(__u))
{ return std::forward<_Tp>(__t) | std::forward<_Up>(__u); }
typedef __is_transparent is_transparent;
};
template <>
struct bit_xor<void>
{
template <typename _Tp, typename _Up>
_GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) ^ std::forward<_Up>(__u)))
-> decltype(std::forward<_Tp>(__t) ^ std::forward<_Up>(__u))
{ return std::forward<_Tp>(__t) ^ std::forward<_Up>(__u); }
typedef __is_transparent is_transparent;
};
template <>
struct bit_not<void>
{
template <typename _Tp>
_GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t) const
noexcept(noexcept(~std::forward<_Tp>(__t)))
-> decltype(~std::forward<_Tp>(__t))
{ return ~std::forward<_Tp>(__t); }
typedef __is_transparent is_transparent;
};
#endif
// 20.3.5 negators
/** @defgroup negators Negators
* @ingroup functors
*
* The functions @c not1 and @c not2 each take a predicate functor
* and return an instance of @c unary_negate or
* @c binary_negate, respectively. These classes are functors whose
* @c operator() performs the stored predicate function and then returns
* the negation of the result.
*
* For example, given a vector of integers and a trivial predicate,
* \code
* struct IntGreaterThanThree
* : public std::unary_function<int, bool>
* {
* bool operator() (int x) { return x > 3; }
* };
*
* std::find_if (v.begin(), v.end(), not1(IntGreaterThanThree()));
* \endcode
* The call to @c find_if will locate the first index (i) of @c v for which
* <code>!(v[i] > 3)</code> is true.
*
* The not1/unary_negate combination works on predicates taking a single
* argument. The not2/binary_negate combination works on predicates which
* take two arguments.
*
* @{
*/
/// One of the @link negators negation functors@endlink.
template<typename _Predicate>
class unary_negate
: public unary_function<typename _Predicate::argument_type, bool>
{
protected:
_Predicate _M_pred;
public:
_GLIBCXX14_CONSTEXPR
explicit
unary_negate(const _Predicate& __x) : _M_pred(__x) { }
_GLIBCXX14_CONSTEXPR
bool
operator()(const typename _Predicate::argument_type& __x) const
{ return !_M_pred(__x); }
};
/// One of the @link negators negation functors@endlink.
template<typename _Predicate>
_GLIBCXX14_CONSTEXPR
inline unary_negate<_Predicate>
not1(const _Predicate& __pred)
{ return unary_negate<_Predicate>(__pred); }
/// One of the @link negators negation functors@endlink.
template<typename _Predicate>
class binary_negate
: public binary_function<typename _Predicate::first_argument_type,
typename _Predicate::second_argument_type, bool>
{
protected:
_Predicate _M_pred;
public:
_GLIBCXX14_CONSTEXPR
explicit
binary_negate(const _Predicate& __x) : _M_pred(__x) { }
_GLIBCXX14_CONSTEXPR
bool
operator()(const typename _Predicate::first_argument_type& __x,
const typename _Predicate::second_argument_type& __y) const
{ return !_M_pred(__x, __y); }
};
/// One of the @link negators negation functors@endlink.
template<typename _Predicate>
_GLIBCXX14_CONSTEXPR
inline binary_negate<_Predicate>
not2(const _Predicate& __pred)
{ return binary_negate<_Predicate>(__pred); }
/** @} */
// 20.3.7 adaptors pointers functions
/** @defgroup pointer_adaptors Adaptors for pointers to functions
* @ingroup functors
*
* The advantage of function objects over pointers to functions is that
* the objects in the standard library declare nested typedefs describing
* their argument and result types with uniform names (e.g., @c result_type
* from the base classes @c unary_function and @c binary_function).
* Sometimes those typedefs are required, not just optional.
*
* Adaptors are provided to turn pointers to unary (single-argument) and
* binary (double-argument) functions into function objects. The
* long-winded functor @c pointer_to_unary_function is constructed with a
* function pointer @c f, and its @c operator() called with argument @c x
* returns @c f(x). The functor @c pointer_to_binary_function does the same
* thing, but with a double-argument @c f and @c operator().
*
* The function @c ptr_fun takes a pointer-to-function @c f and constructs
* an instance of the appropriate functor.
*
* @{
*/
/// One of the @link pointer_adaptors adaptors for function pointers@endlink.
template<typename _Arg, typename _Result>
class pointer_to_unary_function : public unary_function<_Arg, _Result>
{
protected:
_Result (*_M_ptr)(_Arg);
public:
pointer_to_unary_function() { }
explicit
pointer_to_unary_function(_Result (*__x)(_Arg))
: _M_ptr(__x) { }
_Result
operator()(_Arg __x) const
{ return _M_ptr(__x); }
};
/// One of the @link pointer_adaptors adaptors for function pointers@endlink.
template<typename _Arg, typename _Result>
inline pointer_to_unary_function<_Arg, _Result>
ptr_fun(_Result (*__x)(_Arg))
{ return pointer_to_unary_function<_Arg, _Result>(__x); }
/// One of the @link pointer_adaptors adaptors for function pointers@endlink.
template<typename _Arg1, typename _Arg2, typename _Result>
class pointer_to_binary_function
: public binary_function<_Arg1, _Arg2, _Result>
{
protected:
_Result (*_M_ptr)(_Arg1, _Arg2);
public:
pointer_to_binary_function() { }
explicit
pointer_to_binary_function(_Result (*__x)(_Arg1, _Arg2))
: _M_ptr(__x) { }
_Result
operator()(_Arg1 __x, _Arg2 __y) const
{ return _M_ptr(__x, __y); }
};
/// One of the @link pointer_adaptors adaptors for function pointers@endlink.
template<typename _Arg1, typename _Arg2, typename _Result>
inline pointer_to_binary_function<_Arg1, _Arg2, _Result>
ptr_fun(_Result (*__x)(_Arg1, _Arg2))
{ return pointer_to_binary_function<_Arg1, _Arg2, _Result>(__x); }
/** @} */
template<typename _Tp>
struct _Identity
: public unary_function<_Tp, _Tp>
{
_Tp&
operator()(_Tp& __x) const
{ return __x; }
const _Tp&
operator()(const _Tp& __x) const
{ return __x; }
};
// Partial specialization, avoids confusing errors in e.g. std::set<const T>.
template<typename _Tp> struct _Identity<const _Tp> : _Identity<_Tp> { };
template<typename _Pair>
struct _Select1st
: public unary_function<_Pair, typename _Pair::first_type>
{
typename _Pair::first_type&
operator()(_Pair& __x) const
{ return __x.first; }
const typename _Pair::first_type&
operator()(const _Pair& __x) const
{ return __x.first; }
#if __cplusplus >= 201103L
template<typename _Pair2>
typename _Pair2::first_type&
operator()(_Pair2& __x) const
{ return __x.first; }
template<typename _Pair2>
const typename _Pair2::first_type&
operator()(const _Pair2& __x) const
{ return __x.first; }
#endif
};
template<typename _Pair>
struct _Select2nd
: public unary_function<_Pair, typename _Pair::second_type>
{
typename _Pair::second_type&
operator()(_Pair& __x) const
{ return __x.second; }
const typename _Pair::second_type&
operator()(const _Pair& __x) const
{ return __x.second; }
};
// 20.3.8 adaptors pointers members
/** @defgroup memory_adaptors Adaptors for pointers to members
* @ingroup functors
*
* There are a total of 8 = 2^3 function objects in this family.
* (1) Member functions taking no arguments vs member functions taking
* one argument.
* (2) Call through pointer vs call through reference.
* (3) Const vs non-const member function.
*
* All of this complexity is in the function objects themselves. You can
* ignore it by using the helper function mem_fun and mem_fun_ref,
* which create whichever type of adaptor is appropriate.
*
* @{
*/
/// One of the @link memory_adaptors adaptors for member
/// pointers@endlink.
template<typename _Ret, typename _Tp>
class mem_fun_t : public unary_function<_Tp*, _Ret>
{
public:
explicit
mem_fun_t(_Ret (_Tp::*__pf)())
: _M_f(__pf) { }
_Ret
operator()(_Tp* __p) const
{ return (__p->*_M_f)(); }
private:
_Ret (_Tp::*_M_f)();
};
/// One of the @link memory_adaptors adaptors for member
/// pointers@endlink.
template<typename _Ret, typename _Tp>
class const_mem_fun_t : public unary_function<const _Tp*, _Ret>
{
public:
explicit
const_mem_fun_t(_Ret (_Tp::*__pf)() const)
: _M_f(__pf) { }
_Ret
operator()(const _Tp* __p) const
{ return (__p->*_M_f)(); }
private:
_Ret (_Tp::*_M_f)() const;
};
/// One of the @link memory_adaptors adaptors for member
/// pointers@endlink.
template<typename _Ret, typename _Tp>
class mem_fun_ref_t : public unary_function<_Tp, _Ret>
{
public:
explicit
mem_fun_ref_t(_Ret (_Tp::*__pf)())
: _M_f(__pf) { }
_Ret
operator()(_Tp& __r) const
{ return (__r.*_M_f)(); }
private:
_Ret (_Tp::*_M_f)();
};
/// One of the @link memory_adaptors adaptors for member
/// pointers@endlink.
template<typename _Ret, typename _Tp>
class const_mem_fun_ref_t : public unary_function<_Tp, _Ret>
{
public:
explicit
const_mem_fun_ref_t(_Ret (_Tp::*__pf)() const)
: _M_f(__pf) { }
_Ret
operator()(const _Tp& __r) const
{ return (__r.*_M_f)(); }
private:
_Ret (_Tp::*_M_f)() const;
};
/// One of the @link memory_adaptors adaptors for member
/// pointers@endlink.
template<typename _Ret, typename _Tp, typename _Arg>
class mem_fun1_t : public binary_function<_Tp*, _Arg, _Ret>
{
public:
explicit
mem_fun1_t(_Ret (_Tp::*__pf)(_Arg))
: _M_f(__pf) { }
_Ret
operator()(_Tp* __p, _Arg __x) const
{ return (__p->*_M_f)(__x); }
private:
_Ret (_Tp::*_M_f)(_Arg);
};
/// One of the @link memory_adaptors adaptors for member
/// pointers@endlink.
template<typename _Ret, typename _Tp, typename _Arg>
class const_mem_fun1_t : public binary_function<const _Tp*, _Arg, _Ret>
{
public:
explicit
const_mem_fun1_t(_Ret (_Tp::*__pf)(_Arg) const)
: _M_f(__pf) { }
_Ret
operator()(const _Tp* __p, _Arg __x) const
{ return (__p->*_M_f)(__x); }
private:
_Ret (_Tp::*_M_f)(_Arg) const;
};
/// One of the @link memory_adaptors adaptors for member
/// pointers@endlink.
template<typename _Ret, typename _Tp, typename _Arg>
class mem_fun1_ref_t : public binary_function<_Tp, _Arg, _Ret>
{
public:
explicit
mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg))
: _M_f(__pf) { }
_Ret
operator()(_Tp& __r, _Arg __x) const
{ return (__r.*_M_f)(__x); }
private:
_Ret (_Tp::*_M_f)(_Arg);
};
/// One of the @link memory_adaptors adaptors for member
/// pointers@endlink.
template<typename _Ret, typename _Tp, typename _Arg>
class const_mem_fun1_ref_t : public binary_function<_Tp, _Arg, _Ret>
{
public:
explicit
const_mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg) const)
: _M_f(__pf) { }
_Ret
operator()(const _Tp& __r, _Arg __x) const
{ return (__r.*_M_f)(__x); }
private:
_Ret (_Tp::*_M_f)(_Arg) const;
};
// Mem_fun adaptor helper functions. There are only two:
// mem_fun and mem_fun_ref.
template<typename _Ret, typename _Tp>
inline mem_fun_t<_Ret, _Tp>
mem_fun(_Ret (_Tp::*__f)())
{ return mem_fun_t<_Ret, _Tp>(__f); }
template<typename _Ret, typename _Tp>
inline const_mem_fun_t<_Ret, _Tp>
mem_fun(_Ret (_Tp::*__f)() const)
{ return const_mem_fun_t<_Ret, _Tp>(__f); }
template<typename _Ret, typename _Tp>
inline mem_fun_ref_t<_Ret, _Tp>
mem_fun_ref(_Ret (_Tp::*__f)())
{ return mem_fun_ref_t<_Ret, _Tp>(__f); }
template<typename _Ret, typename _Tp>
inline const_mem_fun_ref_t<_Ret, _Tp>
mem_fun_ref(_Ret (_Tp::*__f)() const)
{ return const_mem_fun_ref_t<_Ret, _Tp>(__f); }
template<typename _Ret, typename _Tp, typename _Arg>
inline mem_fun1_t<_Ret, _Tp, _Arg>
mem_fun(_Ret (_Tp::*__f)(_Arg))
{ return mem_fun1_t<_Ret, _Tp, _Arg>(__f); }
template<typename _Ret, typename _Tp, typename _Arg>
inline const_mem_fun1_t<_Ret, _Tp, _Arg>
mem_fun(_Ret (_Tp::*__f)(_Arg) const)
{ return const_mem_fun1_t<_Ret, _Tp, _Arg>(__f); }
template<typename _Ret, typename _Tp, typename _Arg>
inline mem_fun1_ref_t<_Ret, _Tp, _Arg>
mem_fun_ref(_Ret (_Tp::*__f)(_Arg))
{ return mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); }
template<typename _Ret, typename _Tp, typename _Arg>
inline const_mem_fun1_ref_t<_Ret, _Tp, _Arg>
mem_fun_ref(_Ret (_Tp::*__f)(_Arg) const)
{ return const_mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); }
/** @} */
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#if (__cplusplus < 201103L) || _GLIBCXX_USE_DEPRECATED
# include <backward/binders.h>
#endif
#endif /* _STL_FUNCTION_H */
c++/8/bits/atomic_lockfree_defines.h 0000644 00000004315 15201526705 0013226 0 ustar 00 // -*- C++ -*- header.
// Copyright (C) 2008-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/atomic_lockfree_defines.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{atomic}
*/
#ifndef _GLIBCXX_ATOMIC_LOCK_FREE_H
#define _GLIBCXX_ATOMIC_LOCK_FREE_H 1
#pragma GCC system_header
/**
* @addtogroup atomics
* @{
*/
/**
* Lock-free property.
*
* 0 indicates that the types are never lock-free.
* 1 indicates that the types are sometimes lock-free.
* 2 indicates that the types are always lock-free.
*/
#if __cplusplus >= 201103L
#define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE
#define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE
#define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE
#define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE
#define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE
#define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE
#define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE
#define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE
#define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE
#define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE
#endif
// @} group atomics
#endif
c++/8/bits/localefwd.h 0000644 00000013016 15201526705 0010341 0 ustar 00 // <locale> Forward declarations -*- C++ -*-
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/localefwd.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{locale}
*/
//
// ISO C++ 14882: 22.1 Locales
//
#ifndef _LOCALE_FWD_H
#define _LOCALE_FWD_H 1
#pragma GCC system_header
#include <bits/c++config.h>
#include <bits/c++locale.h> // Defines __c_locale, config-specific include
#include <iosfwd> // For ostreambuf_iterator, istreambuf_iterator
#include <cctype>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @defgroup locales Locales
*
* Classes and functions for internationalization and localization.
*/
// 22.1.1 Locale
class locale;
template<typename _Facet>
bool
has_facet(const locale&) throw();
template<typename _Facet>
const _Facet&
use_facet(const locale&);
// 22.1.3 Convenience interfaces
template<typename _CharT>
bool
isspace(_CharT, const locale&);
template<typename _CharT>
bool
isprint(_CharT, const locale&);
template<typename _CharT>
bool
iscntrl(_CharT, const locale&);
template<typename _CharT>
bool
isupper(_CharT, const locale&);
template<typename _CharT>
bool
islower(_CharT, const locale&);
template<typename _CharT>
bool
isalpha(_CharT, const locale&);
template<typename _CharT>
bool
isdigit(_CharT, const locale&);
template<typename _CharT>
bool
ispunct(_CharT, const locale&);
template<typename _CharT>
bool
isxdigit(_CharT, const locale&);
template<typename _CharT>
bool
isalnum(_CharT, const locale&);
template<typename _CharT>
bool
isgraph(_CharT, const locale&);
#if __cplusplus >= 201103L
template<typename _CharT>
bool
isblank(_CharT, const locale&);
#endif
template<typename _CharT>
_CharT
toupper(_CharT, const locale&);
template<typename _CharT>
_CharT
tolower(_CharT, const locale&);
// 22.2.1 and 22.2.1.3 ctype
class ctype_base;
template<typename _CharT>
class ctype;
template<> class ctype<char>;
#ifdef _GLIBCXX_USE_WCHAR_T
template<> class ctype<wchar_t>;
#endif
template<typename _CharT>
class ctype_byname;
// NB: Specialized for char and wchar_t in locale_facets.h.
class codecvt_base;
template<typename _InternT, typename _ExternT, typename _StateT>
class codecvt;
template<> class codecvt<char, char, mbstate_t>;
#ifdef _GLIBCXX_USE_WCHAR_T
template<> class codecvt<wchar_t, char, mbstate_t>;
#endif
template<typename _InternT, typename _ExternT, typename _StateT>
class codecvt_byname;
// 22.2.2 and 22.2.3 numeric
_GLIBCXX_BEGIN_NAMESPACE_LDBL
template<typename _CharT, typename _InIter = istreambuf_iterator<_CharT> >
class num_get;
template<typename _CharT, typename _OutIter = ostreambuf_iterator<_CharT> >
class num_put;
_GLIBCXX_END_NAMESPACE_LDBL
_GLIBCXX_BEGIN_NAMESPACE_CXX11
template<typename _CharT> class numpunct;
template<typename _CharT> class numpunct_byname;
_GLIBCXX_END_NAMESPACE_CXX11
_GLIBCXX_BEGIN_NAMESPACE_CXX11
// 22.2.4 collation
template<typename _CharT>
class collate;
template<typename _CharT>
class collate_byname;
_GLIBCXX_END_NAMESPACE_CXX11
// 22.2.5 date and time
class time_base;
_GLIBCXX_BEGIN_NAMESPACE_CXX11
template<typename _CharT, typename _InIter = istreambuf_iterator<_CharT> >
class time_get;
template<typename _CharT, typename _InIter = istreambuf_iterator<_CharT> >
class time_get_byname;
_GLIBCXX_END_NAMESPACE_CXX11
template<typename _CharT, typename _OutIter = ostreambuf_iterator<_CharT> >
class time_put;
template<typename _CharT, typename _OutIter = ostreambuf_iterator<_CharT> >
class time_put_byname;
// 22.2.6 money
class money_base;
_GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11
template<typename _CharT, typename _InIter = istreambuf_iterator<_CharT> >
class money_get;
template<typename _CharT, typename _OutIter = ostreambuf_iterator<_CharT> >
class money_put;
_GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
_GLIBCXX_BEGIN_NAMESPACE_CXX11
template<typename _CharT, bool _Intl = false>
class moneypunct;
template<typename _CharT, bool _Intl = false>
class moneypunct_byname;
_GLIBCXX_END_NAMESPACE_CXX11
// 22.2.7 message retrieval
class messages_base;
_GLIBCXX_BEGIN_NAMESPACE_CXX11
template<typename _CharT>
class messages;
template<typename _CharT>
class messages_byname;
_GLIBCXX_END_NAMESPACE_CXX11
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif
c++/8/bits/memoryfwd.h 0000644 00000004625 15201526705 0010420 0 ustar 00 // <memory> Forward declarations -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
* Copyright (c) 1996-1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file bits/memoryfwd.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{memory}
*/
#ifndef _MEMORYFWD_H
#define _MEMORYFWD_H 1
#pragma GCC system_header
#include <bits/c++config.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @defgroup allocators Allocators
* @ingroup memory
*
* Classes encapsulating memory operations.
*
* @{
*/
template<typename>
class allocator;
template<>
class allocator<void>;
#if __cplusplus >= 201103L
/// Declare uses_allocator so it can be specialized in \<queue\> etc.
template<typename, typename>
struct uses_allocator;
#endif
/// @} group memory
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif
c++/8/bits/valarray_before.h 0000644 00000044121 15201526705 0011545 0 ustar 00 // The template and inlines for the -*- C++ -*- internal _Meta class.
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/valarray_before.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{valarray}
*/
// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@cmla.ens-cachan.fr>
#ifndef _VALARRAY_BEFORE_H
#define _VALARRAY_BEFORE_H 1
#pragma GCC system_header
#include <bits/slice_array.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
//
// Implementing a loosened valarray return value is tricky.
// First we need to meet 26.3.1/3: we should not add more than
// two levels of template nesting. Therefore we resort to template
// template to "flatten" loosened return value types.
// At some point we use partial specialization to remove one level
// template nesting due to _Expr<>
//
// This class is NOT defined. It doesn't need to.
template<typename _Tp1, typename _Tp2> class _Constant;
// Implementations of unary functions applied to valarray<>s.
// I use hard-coded object functions here instead of a generic
// approach like pointers to function:
// 1) correctness: some functions take references, others values.
// we can't deduce the correct type afterwards.
// 2) efficiency -- object functions can be easily inlined
// 3) be Koenig-lookup-friendly
struct _Abs
{
template<typename _Tp>
_Tp operator()(const _Tp& __t) const
{ return abs(__t); }
};
struct _Cos
{
template<typename _Tp>
_Tp operator()(const _Tp& __t) const
{ return cos(__t); }
};
struct _Acos
{
template<typename _Tp>
_Tp operator()(const _Tp& __t) const
{ return acos(__t); }
};
struct _Cosh
{
template<typename _Tp>
_Tp operator()(const _Tp& __t) const
{ return cosh(__t); }
};
struct _Sin
{
template<typename _Tp>
_Tp operator()(const _Tp& __t) const
{ return sin(__t); }
};
struct _Asin
{
template<typename _Tp>
_Tp operator()(const _Tp& __t) const
{ return asin(__t); }
};
struct _Sinh
{
template<typename _Tp>
_Tp operator()(const _Tp& __t) const
{ return sinh(__t); }
};
struct _Tan
{
template<typename _Tp>
_Tp operator()(const _Tp& __t) const
{ return tan(__t); }
};
struct _Atan
{
template<typename _Tp>
_Tp operator()(const _Tp& __t) const
{ return atan(__t); }
};
struct _Tanh
{
template<typename _Tp>
_Tp operator()(const _Tp& __t) const
{ return tanh(__t); }
};
struct _Exp
{
template<typename _Tp>
_Tp operator()(const _Tp& __t) const
{ return exp(__t); }
};
struct _Log
{
template<typename _Tp>
_Tp operator()(const _Tp& __t) const
{ return log(__t); }
};
struct _Log10
{
template<typename _Tp>
_Tp operator()(const _Tp& __t) const
{ return log10(__t); }
};
struct _Sqrt
{
template<typename _Tp>
_Tp operator()(const _Tp& __t) const
{ return sqrt(__t); }
};
// In the past, we used to tailor operator applications semantics
// to the specialization of standard function objects (i.e. plus<>, etc.)
// That is incorrect. Therefore we provide our own surrogates.
struct __unary_plus
{
template<typename _Tp>
_Tp operator()(const _Tp& __t) const
{ return +__t; }
};
struct __negate
{
template<typename _Tp>
_Tp operator()(const _Tp& __t) const
{ return -__t; }
};
struct __bitwise_not
{
template<typename _Tp>
_Tp operator()(const _Tp& __t) const
{ return ~__t; }
};
struct __plus
{
template<typename _Tp>
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{ return __x + __y; }
};
struct __minus
{
template<typename _Tp>
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{ return __x - __y; }
};
struct __multiplies
{
template<typename _Tp>
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{ return __x * __y; }
};
struct __divides
{
template<typename _Tp>
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{ return __x / __y; }
};
struct __modulus
{
template<typename _Tp>
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{ return __x % __y; }
};
struct __bitwise_xor
{
template<typename _Tp>
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{ return __x ^ __y; }
};
struct __bitwise_and
{
template<typename _Tp>
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{ return __x & __y; }
};
struct __bitwise_or
{
template<typename _Tp>
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{ return __x | __y; }
};
struct __shift_left
{
template<typename _Tp>
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{ return __x << __y; }
};
struct __shift_right
{
template<typename _Tp>
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{ return __x >> __y; }
};
struct __logical_and
{
template<typename _Tp>
bool operator()(const _Tp& __x, const _Tp& __y) const
{ return __x && __y; }
};
struct __logical_or
{
template<typename _Tp>
bool operator()(const _Tp& __x, const _Tp& __y) const
{ return __x || __y; }
};
struct __logical_not
{
template<typename _Tp>
bool operator()(const _Tp& __x) const
{ return !__x; }
};
struct __equal_to
{
template<typename _Tp>
bool operator()(const _Tp& __x, const _Tp& __y) const
{ return __x == __y; }
};
struct __not_equal_to
{
template<typename _Tp>
bool operator()(const _Tp& __x, const _Tp& __y) const
{ return __x != __y; }
};
struct __less
{
template<typename _Tp>
bool operator()(const _Tp& __x, const _Tp& __y) const
{ return __x < __y; }
};
struct __greater
{
template<typename _Tp>
bool operator()(const _Tp& __x, const _Tp& __y) const
{ return __x > __y; }
};
struct __less_equal
{
template<typename _Tp>
bool operator()(const _Tp& __x, const _Tp& __y) const
{ return __x <= __y; }
};
struct __greater_equal
{
template<typename _Tp>
bool operator()(const _Tp& __x, const _Tp& __y) const
{ return __x >= __y; }
};
// The few binary functions we miss.
struct _Atan2
{
template<typename _Tp>
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{ return atan2(__x, __y); }
};
struct _Pow
{
template<typename _Tp>
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{ return pow(__x, __y); }
};
template<typename _Tp, bool _IsValidValarrayValue = !__is_abstract(_Tp)>
struct __fun_with_valarray
{
typedef _Tp result_type;
};
template<typename _Tp>
struct __fun_with_valarray<_Tp, false>
{
// No result type defined for invalid value types.
};
// We need these bits in order to recover the return type of
// some functions/operators now that we're no longer using
// function templates.
template<typename, typename _Tp>
struct __fun : __fun_with_valarray<_Tp>
{
};
// several specializations for relational operators.
template<typename _Tp>
struct __fun<__logical_not, _Tp>
{
typedef bool result_type;
};
template<typename _Tp>
struct __fun<__logical_and, _Tp>
{
typedef bool result_type;
};
template<typename _Tp>
struct __fun<__logical_or, _Tp>
{
typedef bool result_type;
};
template<typename _Tp>
struct __fun<__less, _Tp>
{
typedef bool result_type;
};
template<typename _Tp>
struct __fun<__greater, _Tp>
{
typedef bool result_type;
};
template<typename _Tp>
struct __fun<__less_equal, _Tp>
{
typedef bool result_type;
};
template<typename _Tp>
struct __fun<__greater_equal, _Tp>
{
typedef bool result_type;
};
template<typename _Tp>
struct __fun<__equal_to, _Tp>
{
typedef bool result_type;
};
template<typename _Tp>
struct __fun<__not_equal_to, _Tp>
{
typedef bool result_type;
};
//
// Apply function taking a value/const reference closure
//
template<typename _Dom, typename _Arg>
class _FunBase
{
public:
typedef typename _Dom::value_type value_type;
_FunBase(const _Dom& __e, value_type __f(_Arg))
: _M_expr(__e), _M_func(__f) {}
value_type operator[](size_t __i) const
{ return _M_func (_M_expr[__i]); }
size_t size() const { return _M_expr.size ();}
private:
const _Dom& _M_expr;
value_type (*_M_func)(_Arg);
};
template<class _Dom>
struct _ValFunClos<_Expr,_Dom> : _FunBase<_Dom, typename _Dom::value_type>
{
typedef _FunBase<_Dom, typename _Dom::value_type> _Base;
typedef typename _Base::value_type value_type;
typedef value_type _Tp;
_ValFunClos(const _Dom& __e, _Tp __f(_Tp)) : _Base(__e, __f) {}
};
template<typename _Tp>
struct _ValFunClos<_ValArray,_Tp> : _FunBase<valarray<_Tp>, _Tp>
{
typedef _FunBase<valarray<_Tp>, _Tp> _Base;
typedef _Tp value_type;
_ValFunClos(const valarray<_Tp>& __v, _Tp __f(_Tp)) : _Base(__v, __f) {}
};
template<class _Dom>
struct _RefFunClos<_Expr, _Dom>
: _FunBase<_Dom, const typename _Dom::value_type&>
{
typedef _FunBase<_Dom, const typename _Dom::value_type&> _Base;
typedef typename _Base::value_type value_type;
typedef value_type _Tp;
_RefFunClos(const _Dom& __e, _Tp __f(const _Tp&))
: _Base(__e, __f) {}
};
template<typename _Tp>
struct _RefFunClos<_ValArray, _Tp>
: _FunBase<valarray<_Tp>, const _Tp&>
{
typedef _FunBase<valarray<_Tp>, const _Tp&> _Base;
typedef _Tp value_type;
_RefFunClos(const valarray<_Tp>& __v, _Tp __f(const _Tp&))
: _Base(__v, __f) {}
};
//
// Unary expression closure.
//
template<class _Oper, class _Arg>
class _UnBase
{
public:
typedef typename _Arg::value_type _Vt;
typedef typename __fun<_Oper, _Vt>::result_type value_type;
_UnBase(const _Arg& __e) : _M_expr(__e) {}
value_type operator[](size_t __i) const
{ return _Oper()(_M_expr[__i]); }
size_t size() const { return _M_expr.size(); }
private:
const _Arg& _M_expr;
};
template<class _Oper, class _Dom>
struct _UnClos<_Oper, _Expr, _Dom>
: _UnBase<_Oper, _Dom>
{
typedef _Dom _Arg;
typedef _UnBase<_Oper, _Dom> _Base;
typedef typename _Base::value_type value_type;
_UnClos(const _Arg& __e) : _Base(__e) {}
};
template<class _Oper, typename _Tp>
struct _UnClos<_Oper, _ValArray, _Tp>
: _UnBase<_Oper, valarray<_Tp> >
{
typedef valarray<_Tp> _Arg;
typedef _UnBase<_Oper, valarray<_Tp> > _Base;
typedef typename _Base::value_type value_type;
_UnClos(const _Arg& __e) : _Base(__e) {}
};
//
// Binary expression closure.
//
template<class _Oper, class _FirstArg, class _SecondArg>
class _BinBase
{
public:
typedef typename _FirstArg::value_type _Vt;
typedef typename __fun<_Oper, _Vt>::result_type value_type;
_BinBase(const _FirstArg& __e1, const _SecondArg& __e2)
: _M_expr1(__e1), _M_expr2(__e2) {}
value_type operator[](size_t __i) const
{ return _Oper()(_M_expr1[__i], _M_expr2[__i]); }
size_t size() const { return _M_expr1.size(); }
private:
const _FirstArg& _M_expr1;
const _SecondArg& _M_expr2;
};
template<class _Oper, class _Clos>
class _BinBase2
{
public:
typedef typename _Clos::value_type _Vt;
typedef typename __fun<_Oper, _Vt>::result_type value_type;
_BinBase2(const _Clos& __e, const _Vt& __t)
: _M_expr1(__e), _M_expr2(__t) {}
value_type operator[](size_t __i) const
{ return _Oper()(_M_expr1[__i], _M_expr2); }
size_t size() const { return _M_expr1.size(); }
private:
const _Clos& _M_expr1;
const _Vt& _M_expr2;
};
template<class _Oper, class _Clos>
class _BinBase1
{
public:
typedef typename _Clos::value_type _Vt;
typedef typename __fun<_Oper, _Vt>::result_type value_type;
_BinBase1(const _Vt& __t, const _Clos& __e)
: _M_expr1(__t), _M_expr2(__e) {}
value_type operator[](size_t __i) const
{ return _Oper()(_M_expr1, _M_expr2[__i]); }
size_t size() const { return _M_expr2.size(); }
private:
const _Vt& _M_expr1;
const _Clos& _M_expr2;
};
template<class _Oper, class _Dom1, class _Dom2>
struct _BinClos<_Oper, _Expr, _Expr, _Dom1, _Dom2>
: _BinBase<_Oper, _Dom1, _Dom2>
{
typedef _BinBase<_Oper, _Dom1, _Dom2> _Base;
typedef typename _Base::value_type value_type;
_BinClos(const _Dom1& __e1, const _Dom2& __e2) : _Base(__e1, __e2) {}
};
template<class _Oper, typename _Tp>
struct _BinClos<_Oper,_ValArray, _ValArray, _Tp, _Tp>
: _BinBase<_Oper, valarray<_Tp>, valarray<_Tp> >
{
typedef _BinBase<_Oper, valarray<_Tp>, valarray<_Tp> > _Base;
typedef typename _Base::value_type value_type;
_BinClos(const valarray<_Tp>& __v, const valarray<_Tp>& __w)
: _Base(__v, __w) {}
};
template<class _Oper, class _Dom>
struct _BinClos<_Oper, _Expr, _ValArray, _Dom, typename _Dom::value_type>
: _BinBase<_Oper, _Dom, valarray<typename _Dom::value_type> >
{
typedef typename _Dom::value_type _Tp;
typedef _BinBase<_Oper,_Dom,valarray<_Tp> > _Base;
typedef typename _Base::value_type value_type;
_BinClos(const _Dom& __e1, const valarray<_Tp>& __e2)
: _Base(__e1, __e2) {}
};
template<class _Oper, class _Dom>
struct _BinClos<_Oper, _ValArray, _Expr, typename _Dom::value_type, _Dom>
: _BinBase<_Oper, valarray<typename _Dom::value_type>,_Dom>
{
typedef typename _Dom::value_type _Tp;
typedef _BinBase<_Oper, valarray<_Tp>, _Dom> _Base;
typedef typename _Base::value_type value_type;
_BinClos(const valarray<_Tp>& __e1, const _Dom& __e2)
: _Base(__e1, __e2) {}
};
template<class _Oper, class _Dom>
struct _BinClos<_Oper, _Expr, _Constant, _Dom, typename _Dom::value_type>
: _BinBase2<_Oper, _Dom>
{
typedef typename _Dom::value_type _Tp;
typedef _BinBase2<_Oper,_Dom> _Base;
typedef typename _Base::value_type value_type;
_BinClos(const _Dom& __e1, const _Tp& __e2) : _Base(__e1, __e2) {}
};
template<class _Oper, class _Dom>
struct _BinClos<_Oper, _Constant, _Expr, typename _Dom::value_type, _Dom>
: _BinBase1<_Oper, _Dom>
{
typedef typename _Dom::value_type _Tp;
typedef _BinBase1<_Oper, _Dom> _Base;
typedef typename _Base::value_type value_type;
_BinClos(const _Tp& __e1, const _Dom& __e2) : _Base(__e1, __e2) {}
};
template<class _Oper, typename _Tp>
struct _BinClos<_Oper, _ValArray, _Constant, _Tp, _Tp>
: _BinBase2<_Oper, valarray<_Tp> >
{
typedef _BinBase2<_Oper,valarray<_Tp> > _Base;
typedef typename _Base::value_type value_type;
_BinClos(const valarray<_Tp>& __v, const _Tp& __t) : _Base(__v, __t) {}
};
template<class _Oper, typename _Tp>
struct _BinClos<_Oper, _Constant, _ValArray, _Tp, _Tp>
: _BinBase1<_Oper, valarray<_Tp> >
{
typedef _BinBase1<_Oper, valarray<_Tp> > _Base;
typedef typename _Base::value_type value_type;
_BinClos(const _Tp& __t, const valarray<_Tp>& __v) : _Base(__t, __v) {}
};
//
// slice_array closure.
//
template<typename _Dom>
class _SBase
{
public:
typedef typename _Dom::value_type value_type;
_SBase (const _Dom& __e, const slice& __s)
: _M_expr (__e), _M_slice (__s) {}
value_type
operator[] (size_t __i) const
{ return _M_expr[_M_slice.start () + __i * _M_slice.stride ()]; }
size_t
size() const
{ return _M_slice.size (); }
private:
const _Dom& _M_expr;
const slice& _M_slice;
};
template<typename _Tp>
class _SBase<_Array<_Tp> >
{
public:
typedef _Tp value_type;
_SBase (_Array<_Tp> __a, const slice& __s)
: _M_array (__a._M_data+__s.start()), _M_size (__s.size()),
_M_stride (__s.stride()) {}
value_type
operator[] (size_t __i) const
{ return _M_array._M_data[__i * _M_stride]; }
size_t
size() const
{ return _M_size; }
private:
const _Array<_Tp> _M_array;
const size_t _M_size;
const size_t _M_stride;
};
template<class _Dom>
struct _SClos<_Expr, _Dom>
: _SBase<_Dom>
{
typedef _SBase<_Dom> _Base;
typedef typename _Base::value_type value_type;
_SClos (const _Dom& __e, const slice& __s) : _Base (__e, __s) {}
};
template<typename _Tp>
struct _SClos<_ValArray, _Tp>
: _SBase<_Array<_Tp> >
{
typedef _SBase<_Array<_Tp> > _Base;
typedef _Tp value_type;
_SClos (_Array<_Tp> __a, const slice& __s) : _Base (__a, __s) {}
};
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif /* _CPP_VALARRAY_BEFORE_H */
c++/8/bits/random.tcc 0000644 00000316166 15201526705 0010217 0 ustar 00 // random number generation (out of line) -*- C++ -*-
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/random.tcc
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{random}
*/
#ifndef _RANDOM_TCC
#define _RANDOM_TCC 1
#include <numeric> // std::accumulate and std::partial_sum
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/*
* (Further) implementation-space details.
*/
namespace __detail
{
// General case for x = (ax + c) mod m -- use Schrage's algorithm
// to avoid integer overflow.
//
// Preconditions: a > 0, m > 0.
//
// Note: only works correctly for __m % __a < __m / __a.
template<typename _Tp, _Tp __m, _Tp __a, _Tp __c>
_Tp
_Mod<_Tp, __m, __a, __c, false, true>::
__calc(_Tp __x)
{
if (__a == 1)
__x %= __m;
else
{
static const _Tp __q = __m / __a;
static const _Tp __r = __m % __a;
_Tp __t1 = __a * (__x % __q);
_Tp __t2 = __r * (__x / __q);
if (__t1 >= __t2)
__x = __t1 - __t2;
else
__x = __m - __t2 + __t1;
}
if (__c != 0)
{
const _Tp __d = __m - __x;
if (__d > __c)
__x += __c;
else
__x = __c - __d;
}
return __x;
}
template<typename _InputIterator, typename _OutputIterator,
typename _Tp>
_OutputIterator
__normalize(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, const _Tp& __factor)
{
for (; __first != __last; ++__first, ++__result)
*__result = *__first / __factor;
return __result;
}
} // namespace __detail
template<typename _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
constexpr _UIntType
linear_congruential_engine<_UIntType, __a, __c, __m>::multiplier;
template<typename _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
constexpr _UIntType
linear_congruential_engine<_UIntType, __a, __c, __m>::increment;
template<typename _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
constexpr _UIntType
linear_congruential_engine<_UIntType, __a, __c, __m>::modulus;
template<typename _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
constexpr _UIntType
linear_congruential_engine<_UIntType, __a, __c, __m>::default_seed;
/**
* Seeds the LCR with integral value @p __s, adjusted so that the
* ring identity is never a member of the convergence set.
*/
template<typename _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
void
linear_congruential_engine<_UIntType, __a, __c, __m>::
seed(result_type __s)
{
if ((__detail::__mod<_UIntType, __m>(__c) == 0)
&& (__detail::__mod<_UIntType, __m>(__s) == 0))
_M_x = 1;
else
_M_x = __detail::__mod<_UIntType, __m>(__s);
}
/**
* Seeds the LCR engine with a value generated by @p __q.
*/
template<typename _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
template<typename _Sseq>
typename std::enable_if<std::is_class<_Sseq>::value>::type
linear_congruential_engine<_UIntType, __a, __c, __m>::
seed(_Sseq& __q)
{
const _UIntType __k0 = __m == 0 ? std::numeric_limits<_UIntType>::digits
: std::__lg(__m);
const _UIntType __k = (__k0 + 31) / 32;
uint_least32_t __arr[__k + 3];
__q.generate(__arr + 0, __arr + __k + 3);
_UIntType __factor = 1u;
_UIntType __sum = 0u;
for (size_t __j = 0; __j < __k; ++__j)
{
__sum += __arr[__j + 3] * __factor;
__factor *= __detail::_Shift<_UIntType, 32>::__value;
}
seed(__sum);
}
template<typename _UIntType, _UIntType __a, _UIntType __c, _UIntType __m,
typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const linear_congruential_engine<_UIntType,
__a, __c, __m>& __lcr)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
__os.flags(__ios_base::dec | __ios_base::fixed | __ios_base::left);
__os.fill(__os.widen(' '));
__os << __lcr._M_x;
__os.flags(__flags);
__os.fill(__fill);
return __os;
}
template<typename _UIntType, _UIntType __a, _UIntType __c, _UIntType __m,
typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
linear_congruential_engine<_UIntType, __a, __c, __m>& __lcr)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec);
__is >> __lcr._M_x;
__is.flags(__flags);
return __is;
}
template<typename _UIntType,
size_t __w, size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s,
_UIntType __b, size_t __t, _UIntType __c, size_t __l,
_UIntType __f>
constexpr size_t
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
__s, __b, __t, __c, __l, __f>::word_size;
template<typename _UIntType,
size_t __w, size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s,
_UIntType __b, size_t __t, _UIntType __c, size_t __l,
_UIntType __f>
constexpr size_t
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
__s, __b, __t, __c, __l, __f>::state_size;
template<typename _UIntType,
size_t __w, size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s,
_UIntType __b, size_t __t, _UIntType __c, size_t __l,
_UIntType __f>
constexpr size_t
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
__s, __b, __t, __c, __l, __f>::shift_size;
template<typename _UIntType,
size_t __w, size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s,
_UIntType __b, size_t __t, _UIntType __c, size_t __l,
_UIntType __f>
constexpr size_t
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
__s, __b, __t, __c, __l, __f>::mask_bits;
template<typename _UIntType,
size_t __w, size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s,
_UIntType __b, size_t __t, _UIntType __c, size_t __l,
_UIntType __f>
constexpr _UIntType
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
__s, __b, __t, __c, __l, __f>::xor_mask;
template<typename _UIntType,
size_t __w, size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s,
_UIntType __b, size_t __t, _UIntType __c, size_t __l,
_UIntType __f>
constexpr size_t
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
__s, __b, __t, __c, __l, __f>::tempering_u;
template<typename _UIntType,
size_t __w, size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s,
_UIntType __b, size_t __t, _UIntType __c, size_t __l,
_UIntType __f>
constexpr _UIntType
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
__s, __b, __t, __c, __l, __f>::tempering_d;
template<typename _UIntType,
size_t __w, size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s,
_UIntType __b, size_t __t, _UIntType __c, size_t __l,
_UIntType __f>
constexpr size_t
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
__s, __b, __t, __c, __l, __f>::tempering_s;
template<typename _UIntType,
size_t __w, size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s,
_UIntType __b, size_t __t, _UIntType __c, size_t __l,
_UIntType __f>
constexpr _UIntType
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
__s, __b, __t, __c, __l, __f>::tempering_b;
template<typename _UIntType,
size_t __w, size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s,
_UIntType __b, size_t __t, _UIntType __c, size_t __l,
_UIntType __f>
constexpr size_t
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
__s, __b, __t, __c, __l, __f>::tempering_t;
template<typename _UIntType,
size_t __w, size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s,
_UIntType __b, size_t __t, _UIntType __c, size_t __l,
_UIntType __f>
constexpr _UIntType
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
__s, __b, __t, __c, __l, __f>::tempering_c;
template<typename _UIntType,
size_t __w, size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s,
_UIntType __b, size_t __t, _UIntType __c, size_t __l,
_UIntType __f>
constexpr size_t
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
__s, __b, __t, __c, __l, __f>::tempering_l;
template<typename _UIntType,
size_t __w, size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s,
_UIntType __b, size_t __t, _UIntType __c, size_t __l,
_UIntType __f>
constexpr _UIntType
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
__s, __b, __t, __c, __l, __f>::
initialization_multiplier;
template<typename _UIntType,
size_t __w, size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s,
_UIntType __b, size_t __t, _UIntType __c, size_t __l,
_UIntType __f>
constexpr _UIntType
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
__s, __b, __t, __c, __l, __f>::default_seed;
template<typename _UIntType,
size_t __w, size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s,
_UIntType __b, size_t __t, _UIntType __c, size_t __l,
_UIntType __f>
void
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
__s, __b, __t, __c, __l, __f>::
seed(result_type __sd)
{
_M_x[0] = __detail::__mod<_UIntType,
__detail::_Shift<_UIntType, __w>::__value>(__sd);
for (size_t __i = 1; __i < state_size; ++__i)
{
_UIntType __x = _M_x[__i - 1];
__x ^= __x >> (__w - 2);
__x *= __f;
__x += __detail::__mod<_UIntType, __n>(__i);
_M_x[__i] = __detail::__mod<_UIntType,
__detail::_Shift<_UIntType, __w>::__value>(__x);
}
_M_p = state_size;
}
template<typename _UIntType,
size_t __w, size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s,
_UIntType __b, size_t __t, _UIntType __c, size_t __l,
_UIntType __f>
template<typename _Sseq>
typename std::enable_if<std::is_class<_Sseq>::value>::type
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
__s, __b, __t, __c, __l, __f>::
seed(_Sseq& __q)
{
const _UIntType __upper_mask = (~_UIntType()) << __r;
const size_t __k = (__w + 31) / 32;
uint_least32_t __arr[__n * __k];
__q.generate(__arr + 0, __arr + __n * __k);
bool __zero = true;
for (size_t __i = 0; __i < state_size; ++__i)
{
_UIntType __factor = 1u;
_UIntType __sum = 0u;
for (size_t __j = 0; __j < __k; ++__j)
{
__sum += __arr[__k * __i + __j] * __factor;
__factor *= __detail::_Shift<_UIntType, 32>::__value;
}
_M_x[__i] = __detail::__mod<_UIntType,
__detail::_Shift<_UIntType, __w>::__value>(__sum);
if (__zero)
{
if (__i == 0)
{
if ((_M_x[0] & __upper_mask) != 0u)
__zero = false;
}
else if (_M_x[__i] != 0u)
__zero = false;
}
}
if (__zero)
_M_x[0] = __detail::_Shift<_UIntType, __w - 1>::__value;
_M_p = state_size;
}
template<typename _UIntType, size_t __w,
size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s,
_UIntType __b, size_t __t, _UIntType __c, size_t __l,
_UIntType __f>
void
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
__s, __b, __t, __c, __l, __f>::
_M_gen_rand(void)
{
const _UIntType __upper_mask = (~_UIntType()) << __r;
const _UIntType __lower_mask = ~__upper_mask;
for (size_t __k = 0; __k < (__n - __m); ++__k)
{
_UIntType __y = ((_M_x[__k] & __upper_mask)
| (_M_x[__k + 1] & __lower_mask));
_M_x[__k] = (_M_x[__k + __m] ^ (__y >> 1)
^ ((__y & 0x01) ? __a : 0));
}
for (size_t __k = (__n - __m); __k < (__n - 1); ++__k)
{
_UIntType __y = ((_M_x[__k] & __upper_mask)
| (_M_x[__k + 1] & __lower_mask));
_M_x[__k] = (_M_x[__k + (__m - __n)] ^ (__y >> 1)
^ ((__y & 0x01) ? __a : 0));
}
_UIntType __y = ((_M_x[__n - 1] & __upper_mask)
| (_M_x[0] & __lower_mask));
_M_x[__n - 1] = (_M_x[__m - 1] ^ (__y >> 1)
^ ((__y & 0x01) ? __a : 0));
_M_p = 0;
}
template<typename _UIntType, size_t __w,
size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s,
_UIntType __b, size_t __t, _UIntType __c, size_t __l,
_UIntType __f>
void
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
__s, __b, __t, __c, __l, __f>::
discard(unsigned long long __z)
{
while (__z > state_size - _M_p)
{
__z -= state_size - _M_p;
_M_gen_rand();
}
_M_p += __z;
}
template<typename _UIntType, size_t __w,
size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s,
_UIntType __b, size_t __t, _UIntType __c, size_t __l,
_UIntType __f>
typename
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
__s, __b, __t, __c, __l, __f>::result_type
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
__s, __b, __t, __c, __l, __f>::
operator()()
{
// Reload the vector - cost is O(n) amortized over n calls.
if (_M_p >= state_size)
_M_gen_rand();
// Calculate o(x(i)).
result_type __z = _M_x[_M_p++];
__z ^= (__z >> __u) & __d;
__z ^= (__z << __s) & __b;
__z ^= (__z << __t) & __c;
__z ^= (__z >> __l);
return __z;
}
template<typename _UIntType, size_t __w,
size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s,
_UIntType __b, size_t __t, _UIntType __c, size_t __l,
_UIntType __f, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const mersenne_twister_engine<_UIntType, __w, __n, __m,
__r, __a, __u, __d, __s, __b, __t, __c, __l, __f>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::dec | __ios_base::fixed | __ios_base::left);
__os.fill(__space);
for (size_t __i = 0; __i < __n; ++__i)
__os << __x._M_x[__i] << __space;
__os << __x._M_p;
__os.flags(__flags);
__os.fill(__fill);
return __os;
}
template<typename _UIntType, size_t __w,
size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s,
_UIntType __b, size_t __t, _UIntType __c, size_t __l,
_UIntType __f, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
mersenne_twister_engine<_UIntType, __w, __n, __m,
__r, __a, __u, __d, __s, __b, __t, __c, __l, __f>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
for (size_t __i = 0; __i < __n; ++__i)
__is >> __x._M_x[__i];
__is >> __x._M_p;
__is.flags(__flags);
return __is;
}
template<typename _UIntType, size_t __w, size_t __s, size_t __r>
constexpr size_t
subtract_with_carry_engine<_UIntType, __w, __s, __r>::word_size;
template<typename _UIntType, size_t __w, size_t __s, size_t __r>
constexpr size_t
subtract_with_carry_engine<_UIntType, __w, __s, __r>::short_lag;
template<typename _UIntType, size_t __w, size_t __s, size_t __r>
constexpr size_t
subtract_with_carry_engine<_UIntType, __w, __s, __r>::long_lag;
template<typename _UIntType, size_t __w, size_t __s, size_t __r>
constexpr _UIntType
subtract_with_carry_engine<_UIntType, __w, __s, __r>::default_seed;
template<typename _UIntType, size_t __w, size_t __s, size_t __r>
void
subtract_with_carry_engine<_UIntType, __w, __s, __r>::
seed(result_type __value)
{
std::linear_congruential_engine<result_type, 40014u, 0u, 2147483563u>
__lcg(__value == 0u ? default_seed : __value);
const size_t __n = (__w + 31) / 32;
for (size_t __i = 0; __i < long_lag; ++__i)
{
_UIntType __sum = 0u;
_UIntType __factor = 1u;
for (size_t __j = 0; __j < __n; ++__j)
{
__sum += __detail::__mod<uint_least32_t,
__detail::_Shift<uint_least32_t, 32>::__value>
(__lcg()) * __factor;
__factor *= __detail::_Shift<_UIntType, 32>::__value;
}
_M_x[__i] = __detail::__mod<_UIntType,
__detail::_Shift<_UIntType, __w>::__value>(__sum);
}
_M_carry = (_M_x[long_lag - 1] == 0) ? 1 : 0;
_M_p = 0;
}
template<typename _UIntType, size_t __w, size_t __s, size_t __r>
template<typename _Sseq>
typename std::enable_if<std::is_class<_Sseq>::value>::type
subtract_with_carry_engine<_UIntType, __w, __s, __r>::
seed(_Sseq& __q)
{
const size_t __k = (__w + 31) / 32;
uint_least32_t __arr[__r * __k];
__q.generate(__arr + 0, __arr + __r * __k);
for (size_t __i = 0; __i < long_lag; ++__i)
{
_UIntType __sum = 0u;
_UIntType __factor = 1u;
for (size_t __j = 0; __j < __k; ++__j)
{
__sum += __arr[__k * __i + __j] * __factor;
__factor *= __detail::_Shift<_UIntType, 32>::__value;
}
_M_x[__i] = __detail::__mod<_UIntType,
__detail::_Shift<_UIntType, __w>::__value>(__sum);
}
_M_carry = (_M_x[long_lag - 1] == 0) ? 1 : 0;
_M_p = 0;
}
template<typename _UIntType, size_t __w, size_t __s, size_t __r>
typename subtract_with_carry_engine<_UIntType, __w, __s, __r>::
result_type
subtract_with_carry_engine<_UIntType, __w, __s, __r>::
operator()()
{
// Derive short lag index from current index.
long __ps = _M_p - short_lag;
if (__ps < 0)
__ps += long_lag;
// Calculate new x(i) without overflow or division.
// NB: Thanks to the requirements for _UIntType, _M_x[_M_p] + _M_carry
// cannot overflow.
_UIntType __xi;
if (_M_x[__ps] >= _M_x[_M_p] + _M_carry)
{
__xi = _M_x[__ps] - _M_x[_M_p] - _M_carry;
_M_carry = 0;
}
else
{
__xi = (__detail::_Shift<_UIntType, __w>::__value
- _M_x[_M_p] - _M_carry + _M_x[__ps]);
_M_carry = 1;
}
_M_x[_M_p] = __xi;
// Adjust current index to loop around in ring buffer.
if (++_M_p >= long_lag)
_M_p = 0;
return __xi;
}
template<typename _UIntType, size_t __w, size_t __s, size_t __r,
typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const subtract_with_carry_engine<_UIntType,
__w, __s, __r>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::dec | __ios_base::fixed | __ios_base::left);
__os.fill(__space);
for (size_t __i = 0; __i < __r; ++__i)
__os << __x._M_x[__i] << __space;
__os << __x._M_carry << __space << __x._M_p;
__os.flags(__flags);
__os.fill(__fill);
return __os;
}
template<typename _UIntType, size_t __w, size_t __s, size_t __r,
typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
subtract_with_carry_engine<_UIntType, __w, __s, __r>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
for (size_t __i = 0; __i < __r; ++__i)
__is >> __x._M_x[__i];
__is >> __x._M_carry;
__is >> __x._M_p;
__is.flags(__flags);
return __is;
}
template<typename _RandomNumberEngine, size_t __p, size_t __r>
constexpr size_t
discard_block_engine<_RandomNumberEngine, __p, __r>::block_size;
template<typename _RandomNumberEngine, size_t __p, size_t __r>
constexpr size_t
discard_block_engine<_RandomNumberEngine, __p, __r>::used_block;
template<typename _RandomNumberEngine, size_t __p, size_t __r>
typename discard_block_engine<_RandomNumberEngine,
__p, __r>::result_type
discard_block_engine<_RandomNumberEngine, __p, __r>::
operator()()
{
if (_M_n >= used_block)
{
_M_b.discard(block_size - _M_n);
_M_n = 0;
}
++_M_n;
return _M_b();
}
template<typename _RandomNumberEngine, size_t __p, size_t __r,
typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const discard_block_engine<_RandomNumberEngine,
__p, __r>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::dec | __ios_base::fixed | __ios_base::left);
__os.fill(__space);
__os << __x.base() << __space << __x._M_n;
__os.flags(__flags);
__os.fill(__fill);
return __os;
}
template<typename _RandomNumberEngine, size_t __p, size_t __r,
typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
discard_block_engine<_RandomNumberEngine, __p, __r>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
__is >> __x._M_b >> __x._M_n;
__is.flags(__flags);
return __is;
}
template<typename _RandomNumberEngine, size_t __w, typename _UIntType>
typename independent_bits_engine<_RandomNumberEngine, __w, _UIntType>::
result_type
independent_bits_engine<_RandomNumberEngine, __w, _UIntType>::
operator()()
{
typedef typename _RandomNumberEngine::result_type _Eresult_type;
const _Eresult_type __r
= (_M_b.max() - _M_b.min() < std::numeric_limits<_Eresult_type>::max()
? _M_b.max() - _M_b.min() + 1 : 0);
const unsigned __edig = std::numeric_limits<_Eresult_type>::digits;
const unsigned __m = __r ? std::__lg(__r) : __edig;
typedef typename std::common_type<_Eresult_type, result_type>::type
__ctype;
const unsigned __cdig = std::numeric_limits<__ctype>::digits;
unsigned __n, __n0;
__ctype __s0, __s1, __y0, __y1;
for (size_t __i = 0; __i < 2; ++__i)
{
__n = (__w + __m - 1) / __m + __i;
__n0 = __n - __w % __n;
const unsigned __w0 = __w / __n; // __w0 <= __m
__s0 = 0;
__s1 = 0;
if (__w0 < __cdig)
{
__s0 = __ctype(1) << __w0;
__s1 = __s0 << 1;
}
__y0 = 0;
__y1 = 0;
if (__r)
{
__y0 = __s0 * (__r / __s0);
if (__s1)
__y1 = __s1 * (__r / __s1);
if (__r - __y0 <= __y0 / __n)
break;
}
else
break;
}
result_type __sum = 0;
for (size_t __k = 0; __k < __n0; ++__k)
{
__ctype __u;
do
__u = _M_b() - _M_b.min();
while (__y0 && __u >= __y0);
__sum = __s0 * __sum + (__s0 ? __u % __s0 : __u);
}
for (size_t __k = __n0; __k < __n; ++__k)
{
__ctype __u;
do
__u = _M_b() - _M_b.min();
while (__y1 && __u >= __y1);
__sum = __s1 * __sum + (__s1 ? __u % __s1 : __u);
}
return __sum;
}
template<typename _RandomNumberEngine, size_t __k>
constexpr size_t
shuffle_order_engine<_RandomNumberEngine, __k>::table_size;
template<typename _RandomNumberEngine, size_t __k>
typename shuffle_order_engine<_RandomNumberEngine, __k>::result_type
shuffle_order_engine<_RandomNumberEngine, __k>::
operator()()
{
size_t __j = __k * ((_M_y - _M_b.min())
/ (_M_b.max() - _M_b.min() + 1.0L));
_M_y = _M_v[__j];
_M_v[__j] = _M_b();
return _M_y;
}
template<typename _RandomNumberEngine, size_t __k,
typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const shuffle_order_engine<_RandomNumberEngine, __k>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::dec | __ios_base::fixed | __ios_base::left);
__os.fill(__space);
__os << __x.base();
for (size_t __i = 0; __i < __k; ++__i)
__os << __space << __x._M_v[__i];
__os << __space << __x._M_y;
__os.flags(__flags);
__os.fill(__fill);
return __os;
}
template<typename _RandomNumberEngine, size_t __k,
typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
shuffle_order_engine<_RandomNumberEngine, __k>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
__is >> __x._M_b;
for (size_t __i = 0; __i < __k; ++__i)
__is >> __x._M_v[__i];
__is >> __x._M_y;
__is.flags(__flags);
return __is;
}
template<typename _IntType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const uniform_int_distribution<_IntType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__space);
__os << __x.a() << __space << __x.b();
__os.flags(__flags);
__os.fill(__fill);
return __os;
}
template<typename _IntType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
uniform_int_distribution<_IntType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
_IntType __a, __b;
if (__is >> __a >> __b)
__x.param(typename uniform_int_distribution<_IntType>::
param_type(__a, __b));
__is.flags(__flags);
return __is;
}
template<typename _RealType>
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
uniform_real_distribution<_RealType>::
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
__aurng(__urng);
auto __range = __p.b() - __p.a();
while (__f != __t)
*__f++ = __aurng() * __range + __p.a();
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const uniform_real_distribution<_RealType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__space);
__os.precision(std::numeric_limits<_RealType>::max_digits10);
__os << __x.a() << __space << __x.b();
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
uniform_real_distribution<_RealType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::skipws);
_RealType __a, __b;
if (__is >> __a >> __b)
__x.param(typename uniform_real_distribution<_RealType>::
param_type(__a, __b));
__is.flags(__flags);
return __is;
}
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
std::bernoulli_distribution::
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__detail::_Adaptor<_UniformRandomNumberGenerator, double>
__aurng(__urng);
auto __limit = __p.p() * (__aurng.max() - __aurng.min());
while (__f != __t)
*__f++ = (__aurng() - __aurng.min()) < __limit;
}
template<typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const bernoulli_distribution& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__os.widen(' '));
__os.precision(std::numeric_limits<double>::max_digits10);
__os << __x.p();
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
template<typename _IntType>
template<typename _UniformRandomNumberGenerator>
typename geometric_distribution<_IntType>::result_type
geometric_distribution<_IntType>::
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
// About the epsilon thing see this thread:
// http://gcc.gnu.org/ml/gcc-patches/2006-10/msg00971.html
const double __naf =
(1 - std::numeric_limits<double>::epsilon()) / 2;
// The largest _RealType convertible to _IntType.
const double __thr =
std::numeric_limits<_IntType>::max() + __naf;
__detail::_Adaptor<_UniformRandomNumberGenerator, double>
__aurng(__urng);
double __cand;
do
__cand = std::floor(std::log(1.0 - __aurng()) / __param._M_log_1_p);
while (__cand >= __thr);
return result_type(__cand + __naf);
}
template<typename _IntType>
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
geometric_distribution<_IntType>::
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
// About the epsilon thing see this thread:
// http://gcc.gnu.org/ml/gcc-patches/2006-10/msg00971.html
const double __naf =
(1 - std::numeric_limits<double>::epsilon()) / 2;
// The largest _RealType convertible to _IntType.
const double __thr =
std::numeric_limits<_IntType>::max() + __naf;
__detail::_Adaptor<_UniformRandomNumberGenerator, double>
__aurng(__urng);
while (__f != __t)
{
double __cand;
do
__cand = std::floor(std::log(1.0 - __aurng())
/ __param._M_log_1_p);
while (__cand >= __thr);
*__f++ = __cand + __naf;
}
}
template<typename _IntType,
typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const geometric_distribution<_IntType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__os.widen(' '));
__os.precision(std::numeric_limits<double>::max_digits10);
__os << __x.p();
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
template<typename _IntType,
typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
geometric_distribution<_IntType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::skipws);
double __p;
if (__is >> __p)
__x.param(typename geometric_distribution<_IntType>::param_type(__p));
__is.flags(__flags);
return __is;
}
// This is Leger's algorithm, also in Devroye, Ch. X, Example 1.5.
template<typename _IntType>
template<typename _UniformRandomNumberGenerator>
typename negative_binomial_distribution<_IntType>::result_type
negative_binomial_distribution<_IntType>::
operator()(_UniformRandomNumberGenerator& __urng)
{
const double __y = _M_gd(__urng);
// XXX Is the constructor too slow?
std::poisson_distribution<result_type> __poisson(__y);
return __poisson(__urng);
}
template<typename _IntType>
template<typename _UniformRandomNumberGenerator>
typename negative_binomial_distribution<_IntType>::result_type
negative_binomial_distribution<_IntType>::
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
typedef typename std::gamma_distribution<double>::param_type
param_type;
const double __y =
_M_gd(__urng, param_type(__p.k(), (1.0 - __p.p()) / __p.p()));
std::poisson_distribution<result_type> __poisson(__y);
return __poisson(__urng);
}
template<typename _IntType>
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
negative_binomial_distribution<_IntType>::
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
while (__f != __t)
{
const double __y = _M_gd(__urng);
// XXX Is the constructor too slow?
std::poisson_distribution<result_type> __poisson(__y);
*__f++ = __poisson(__urng);
}
}
template<typename _IntType>
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
negative_binomial_distribution<_IntType>::
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
typename std::gamma_distribution<result_type>::param_type
__p2(__p.k(), (1.0 - __p.p()) / __p.p());
while (__f != __t)
{
const double __y = _M_gd(__urng, __p2);
std::poisson_distribution<result_type> __poisson(__y);
*__f++ = __poisson(__urng);
}
}
template<typename _IntType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const negative_binomial_distribution<_IntType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__os.widen(' '));
__os.precision(std::numeric_limits<double>::max_digits10);
__os << __x.k() << __space << __x.p()
<< __space << __x._M_gd;
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
template<typename _IntType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
negative_binomial_distribution<_IntType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::skipws);
_IntType __k;
double __p;
if (__is >> __k >> __p >> __x._M_gd)
__x.param(typename negative_binomial_distribution<_IntType>::
param_type(__k, __p));
__is.flags(__flags);
return __is;
}
template<typename _IntType>
void
poisson_distribution<_IntType>::param_type::
_M_initialize()
{
#if _GLIBCXX_USE_C99_MATH_TR1
if (_M_mean >= 12)
{
const double __m = std::floor(_M_mean);
_M_lm_thr = std::log(_M_mean);
_M_lfm = std::lgamma(__m + 1);
_M_sm = std::sqrt(__m);
const double __pi_4 = 0.7853981633974483096156608458198757L;
const double __dx = std::sqrt(2 * __m * std::log(32 * __m
/ __pi_4));
_M_d = std::round(std::max<double>(6.0, std::min(__m, __dx)));
const double __cx = 2 * __m + _M_d;
_M_scx = std::sqrt(__cx / 2);
_M_1cx = 1 / __cx;
_M_c2b = std::sqrt(__pi_4 * __cx) * std::exp(_M_1cx);
_M_cb = 2 * __cx * std::exp(-_M_d * _M_1cx * (1 + _M_d / 2))
/ _M_d;
}
else
#endif
_M_lm_thr = std::exp(-_M_mean);
}
/**
* A rejection algorithm when mean >= 12 and a simple method based
* upon the multiplication of uniform random variates otherwise.
* NB: The former is available only if _GLIBCXX_USE_C99_MATH_TR1
* is defined.
*
* Reference:
* Devroye, L. Non-Uniform Random Variates Generation. Springer-Verlag,
* New York, 1986, Ch. X, Sects. 3.3 & 3.4 (+ Errata!).
*/
template<typename _IntType>
template<typename _UniformRandomNumberGenerator>
typename poisson_distribution<_IntType>::result_type
poisson_distribution<_IntType>::
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
__detail::_Adaptor<_UniformRandomNumberGenerator, double>
__aurng(__urng);
#if _GLIBCXX_USE_C99_MATH_TR1
if (__param.mean() >= 12)
{
double __x;
// See comments above...
const double __naf =
(1 - std::numeric_limits<double>::epsilon()) / 2;
const double __thr =
std::numeric_limits<_IntType>::max() + __naf;
const double __m = std::floor(__param.mean());
// sqrt(pi / 2)
const double __spi_2 = 1.2533141373155002512078826424055226L;
const double __c1 = __param._M_sm * __spi_2;
const double __c2 = __param._M_c2b + __c1;
const double __c3 = __c2 + 1;
const double __c4 = __c3 + 1;
// 1 / 78
const double __178 = 0.0128205128205128205128205128205128L;
// e^(1 / 78)
const double __e178 = 1.0129030479320018583185514777512983L;
const double __c5 = __c4 + __e178;
const double __c = __param._M_cb + __c5;
const double __2cx = 2 * (2 * __m + __param._M_d);
bool __reject = true;
do
{
const double __u = __c * __aurng();
const double __e = -std::log(1.0 - __aurng());
double __w = 0.0;
if (__u <= __c1)
{
const double __n = _M_nd(__urng);
const double __y = -std::abs(__n) * __param._M_sm - 1;
__x = std::floor(__y);
__w = -__n * __n / 2;
if (__x < -__m)
continue;
}
else if (__u <= __c2)
{
const double __n = _M_nd(__urng);
const double __y = 1 + std::abs(__n) * __param._M_scx;
__x = std::ceil(__y);
__w = __y * (2 - __y) * __param._M_1cx;
if (__x > __param._M_d)
continue;
}
else if (__u <= __c3)
// NB: This case not in the book, nor in the Errata,
// but should be ok...
__x = -1;
else if (__u <= __c4)
__x = 0;
else if (__u <= __c5)
{
__x = 1;
// Only in the Errata, see libstdc++/83237.
__w = __178;
}
else
{
const double __v = -std::log(1.0 - __aurng());
const double __y = __param._M_d
+ __v * __2cx / __param._M_d;
__x = std::ceil(__y);
__w = -__param._M_d * __param._M_1cx * (1 + __y / 2);
}
__reject = (__w - __e - __x * __param._M_lm_thr
> __param._M_lfm - std::lgamma(__x + __m + 1));
__reject |= __x + __m >= __thr;
} while (__reject);
return result_type(__x + __m + __naf);
}
else
#endif
{
_IntType __x = 0;
double __prod = 1.0;
do
{
__prod *= __aurng();
__x += 1;
}
while (__prod > __param._M_lm_thr);
return __x - 1;
}
}
template<typename _IntType>
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
poisson_distribution<_IntType>::
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
// We could duplicate everything from operator()...
while (__f != __t)
*__f++ = this->operator()(__urng, __param);
}
template<typename _IntType,
typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const poisson_distribution<_IntType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__space);
__os.precision(std::numeric_limits<double>::max_digits10);
__os << __x.mean() << __space << __x._M_nd;
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
template<typename _IntType,
typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
poisson_distribution<_IntType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::skipws);
double __mean;
if (__is >> __mean >> __x._M_nd)
__x.param(typename poisson_distribution<_IntType>::param_type(__mean));
__is.flags(__flags);
return __is;
}
template<typename _IntType>
void
binomial_distribution<_IntType>::param_type::
_M_initialize()
{
const double __p12 = _M_p <= 0.5 ? _M_p : 1.0 - _M_p;
_M_easy = true;
#if _GLIBCXX_USE_C99_MATH_TR1
if (_M_t * __p12 >= 8)
{
_M_easy = false;
const double __np = std::floor(_M_t * __p12);
const double __pa = __np / _M_t;
const double __1p = 1 - __pa;
const double __pi_4 = 0.7853981633974483096156608458198757L;
const double __d1x =
std::sqrt(__np * __1p * std::log(32 * __np
/ (81 * __pi_4 * __1p)));
_M_d1 = std::round(std::max<double>(1.0, __d1x));
const double __d2x =
std::sqrt(__np * __1p * std::log(32 * _M_t * __1p
/ (__pi_4 * __pa)));
_M_d2 = std::round(std::max<double>(1.0, __d2x));
// sqrt(pi / 2)
const double __spi_2 = 1.2533141373155002512078826424055226L;
_M_s1 = std::sqrt(__np * __1p) * (1 + _M_d1 / (4 * __np));
_M_s2 = std::sqrt(__np * __1p) * (1 + _M_d2 / (4 * _M_t * __1p));
_M_c = 2 * _M_d1 / __np;
_M_a1 = std::exp(_M_c) * _M_s1 * __spi_2;
const double __a12 = _M_a1 + _M_s2 * __spi_2;
const double __s1s = _M_s1 * _M_s1;
_M_a123 = __a12 + (std::exp(_M_d1 / (_M_t * __1p))
* 2 * __s1s / _M_d1
* std::exp(-_M_d1 * _M_d1 / (2 * __s1s)));
const double __s2s = _M_s2 * _M_s2;
_M_s = (_M_a123 + 2 * __s2s / _M_d2
* std::exp(-_M_d2 * _M_d2 / (2 * __s2s)));
_M_lf = (std::lgamma(__np + 1)
+ std::lgamma(_M_t - __np + 1));
_M_lp1p = std::log(__pa / __1p);
_M_q = -std::log(1 - (__p12 - __pa) / __1p);
}
else
#endif
_M_q = -std::log(1 - __p12);
}
template<typename _IntType>
template<typename _UniformRandomNumberGenerator>
typename binomial_distribution<_IntType>::result_type
binomial_distribution<_IntType>::
_M_waiting(_UniformRandomNumberGenerator& __urng,
_IntType __t, double __q)
{
_IntType __x = 0;
double __sum = 0.0;
__detail::_Adaptor<_UniformRandomNumberGenerator, double>
__aurng(__urng);
do
{
if (__t == __x)
return __x;
const double __e = -std::log(1.0 - __aurng());
__sum += __e / (__t - __x);
__x += 1;
}
while (__sum <= __q);
return __x - 1;
}
/**
* A rejection algorithm when t * p >= 8 and a simple waiting time
* method - the second in the referenced book - otherwise.
* NB: The former is available only if _GLIBCXX_USE_C99_MATH_TR1
* is defined.
*
* Reference:
* Devroye, L. Non-Uniform Random Variates Generation. Springer-Verlag,
* New York, 1986, Ch. X, Sect. 4 (+ Errata!).
*/
template<typename _IntType>
template<typename _UniformRandomNumberGenerator>
typename binomial_distribution<_IntType>::result_type
binomial_distribution<_IntType>::
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
result_type __ret;
const _IntType __t = __param.t();
const double __p = __param.p();
const double __p12 = __p <= 0.5 ? __p : 1.0 - __p;
__detail::_Adaptor<_UniformRandomNumberGenerator, double>
__aurng(__urng);
#if _GLIBCXX_USE_C99_MATH_TR1
if (!__param._M_easy)
{
double __x;
// See comments above...
const double __naf =
(1 - std::numeric_limits<double>::epsilon()) / 2;
const double __thr =
std::numeric_limits<_IntType>::max() + __naf;
const double __np = std::floor(__t * __p12);
// sqrt(pi / 2)
const double __spi_2 = 1.2533141373155002512078826424055226L;
const double __a1 = __param._M_a1;
const double __a12 = __a1 + __param._M_s2 * __spi_2;
const double __a123 = __param._M_a123;
const double __s1s = __param._M_s1 * __param._M_s1;
const double __s2s = __param._M_s2 * __param._M_s2;
bool __reject;
do
{
const double __u = __param._M_s * __aurng();
double __v;
if (__u <= __a1)
{
const double __n = _M_nd(__urng);
const double __y = __param._M_s1 * std::abs(__n);
__reject = __y >= __param._M_d1;
if (!__reject)
{
const double __e = -std::log(1.0 - __aurng());
__x = std::floor(__y);
__v = -__e - __n * __n / 2 + __param._M_c;
}
}
else if (__u <= __a12)
{
const double __n = _M_nd(__urng);
const double __y = __param._M_s2 * std::abs(__n);
__reject = __y >= __param._M_d2;
if (!__reject)
{
const double __e = -std::log(1.0 - __aurng());
__x = std::floor(-__y);
__v = -__e - __n * __n / 2;
}
}
else if (__u <= __a123)
{
const double __e1 = -std::log(1.0 - __aurng());
const double __e2 = -std::log(1.0 - __aurng());
const double __y = __param._M_d1
+ 2 * __s1s * __e1 / __param._M_d1;
__x = std::floor(__y);
__v = (-__e2 + __param._M_d1 * (1 / (__t - __np)
-__y / (2 * __s1s)));
__reject = false;
}
else
{
const double __e1 = -std::log(1.0 - __aurng());
const double __e2 = -std::log(1.0 - __aurng());
const double __y = __param._M_d2
+ 2 * __s2s * __e1 / __param._M_d2;
__x = std::floor(-__y);
__v = -__e2 - __param._M_d2 * __y / (2 * __s2s);
__reject = false;
}
__reject = __reject || __x < -__np || __x > __t - __np;
if (!__reject)
{
const double __lfx =
std::lgamma(__np + __x + 1)
+ std::lgamma(__t - (__np + __x) + 1);
__reject = __v > __param._M_lf - __lfx
+ __x * __param._M_lp1p;
}
__reject |= __x + __np >= __thr;
}
while (__reject);
__x += __np + __naf;
const _IntType __z = _M_waiting(__urng, __t - _IntType(__x),
__param._M_q);
__ret = _IntType(__x) + __z;
}
else
#endif
__ret = _M_waiting(__urng, __t, __param._M_q);
if (__p12 != __p)
__ret = __t - __ret;
return __ret;
}
template<typename _IntType>
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
binomial_distribution<_IntType>::
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
// We could duplicate everything from operator()...
while (__f != __t)
*__f++ = this->operator()(__urng, __param);
}
template<typename _IntType,
typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const binomial_distribution<_IntType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__space);
__os.precision(std::numeric_limits<double>::max_digits10);
__os << __x.t() << __space << __x.p()
<< __space << __x._M_nd;
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
template<typename _IntType,
typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
binomial_distribution<_IntType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
_IntType __t;
double __p;
if (__is >> __t >> __p >> __x._M_nd)
__x.param(typename binomial_distribution<_IntType>::
param_type(__t, __p));
__is.flags(__flags);
return __is;
}
template<typename _RealType>
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
std::exponential_distribution<_RealType>::
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
__aurng(__urng);
while (__f != __t)
*__f++ = -std::log(result_type(1) - __aurng()) / __p.lambda();
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const exponential_distribution<_RealType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__os.widen(' '));
__os.precision(std::numeric_limits<_RealType>::max_digits10);
__os << __x.lambda();
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
exponential_distribution<_RealType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __lambda;
if (__is >> __lambda)
__x.param(typename exponential_distribution<_RealType>::
param_type(__lambda));
__is.flags(__flags);
return __is;
}
/**
* Polar method due to Marsaglia.
*
* Devroye, L. Non-Uniform Random Variates Generation. Springer-Verlag,
* New York, 1986, Ch. V, Sect. 4.4.
*/
template<typename _RealType>
template<typename _UniformRandomNumberGenerator>
typename normal_distribution<_RealType>::result_type
normal_distribution<_RealType>::
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
result_type __ret;
__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
__aurng(__urng);
if (_M_saved_available)
{
_M_saved_available = false;
__ret = _M_saved;
}
else
{
result_type __x, __y, __r2;
do
{
__x = result_type(2.0) * __aurng() - 1.0;
__y = result_type(2.0) * __aurng() - 1.0;
__r2 = __x * __x + __y * __y;
}
while (__r2 > 1.0 || __r2 == 0.0);
const result_type __mult = std::sqrt(-2 * std::log(__r2) / __r2);
_M_saved = __x * __mult;
_M_saved_available = true;
__ret = __y * __mult;
}
__ret = __ret * __param.stddev() + __param.mean();
return __ret;
}
template<typename _RealType>
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
normal_distribution<_RealType>::
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
if (__f == __t)
return;
if (_M_saved_available)
{
_M_saved_available = false;
*__f++ = _M_saved * __param.stddev() + __param.mean();
if (__f == __t)
return;
}
__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
__aurng(__urng);
while (__f + 1 < __t)
{
result_type __x, __y, __r2;
do
{
__x = result_type(2.0) * __aurng() - 1.0;
__y = result_type(2.0) * __aurng() - 1.0;
__r2 = __x * __x + __y * __y;
}
while (__r2 > 1.0 || __r2 == 0.0);
const result_type __mult = std::sqrt(-2 * std::log(__r2) / __r2);
*__f++ = __y * __mult * __param.stddev() + __param.mean();
*__f++ = __x * __mult * __param.stddev() + __param.mean();
}
if (__f != __t)
{
result_type __x, __y, __r2;
do
{
__x = result_type(2.0) * __aurng() - 1.0;
__y = result_type(2.0) * __aurng() - 1.0;
__r2 = __x * __x + __y * __y;
}
while (__r2 > 1.0 || __r2 == 0.0);
const result_type __mult = std::sqrt(-2 * std::log(__r2) / __r2);
_M_saved = __x * __mult;
_M_saved_available = true;
*__f = __y * __mult * __param.stddev() + __param.mean();
}
}
template<typename _RealType>
bool
operator==(const std::normal_distribution<_RealType>& __d1,
const std::normal_distribution<_RealType>& __d2)
{
if (__d1._M_param == __d2._M_param
&& __d1._M_saved_available == __d2._M_saved_available)
{
if (__d1._M_saved_available
&& __d1._M_saved == __d2._M_saved)
return true;
else if(!__d1._M_saved_available)
return true;
else
return false;
}
else
return false;
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const normal_distribution<_RealType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__space);
__os.precision(std::numeric_limits<_RealType>::max_digits10);
__os << __x.mean() << __space << __x.stddev()
<< __space << __x._M_saved_available;
if (__x._M_saved_available)
__os << __space << __x._M_saved;
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
normal_distribution<_RealType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
double __mean, __stddev;
bool __saved_avail;
if (__is >> __mean >> __stddev >> __saved_avail)
{
if (!__saved_avail || (__is >> __x._M_saved))
{
__x._M_saved_available = __saved_avail;
__x.param(typename normal_distribution<_RealType>::
param_type(__mean, __stddev));
}
}
__is.flags(__flags);
return __is;
}
template<typename _RealType>
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
lognormal_distribution<_RealType>::
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
while (__f != __t)
*__f++ = std::exp(__p.s() * _M_nd(__urng) + __p.m());
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const lognormal_distribution<_RealType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__space);
__os.precision(std::numeric_limits<_RealType>::max_digits10);
__os << __x.m() << __space << __x.s()
<< __space << __x._M_nd;
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
lognormal_distribution<_RealType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __m, __s;
if (__is >> __m >> __s >> __x._M_nd)
__x.param(typename lognormal_distribution<_RealType>::
param_type(__m, __s));
__is.flags(__flags);
return __is;
}
template<typename _RealType>
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
std::chi_squared_distribution<_RealType>::
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
while (__f != __t)
*__f++ = 2 * _M_gd(__urng);
}
template<typename _RealType>
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
std::chi_squared_distribution<_RealType>::
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const typename
std::gamma_distribution<result_type>::param_type& __p)
{
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
while (__f != __t)
*__f++ = 2 * _M_gd(__urng, __p);
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const chi_squared_distribution<_RealType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__space);
__os.precision(std::numeric_limits<_RealType>::max_digits10);
__os << __x.n() << __space << __x._M_gd;
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
chi_squared_distribution<_RealType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __n;
if (__is >> __n >> __x._M_gd)
__x.param(typename chi_squared_distribution<_RealType>::
param_type(__n));
__is.flags(__flags);
return __is;
}
template<typename _RealType>
template<typename _UniformRandomNumberGenerator>
typename cauchy_distribution<_RealType>::result_type
cauchy_distribution<_RealType>::
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
__aurng(__urng);
_RealType __u;
do
__u = __aurng();
while (__u == 0.5);
const _RealType __pi = 3.1415926535897932384626433832795029L;
return __p.a() + __p.b() * std::tan(__pi * __u);
}
template<typename _RealType>
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
cauchy_distribution<_RealType>::
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
const _RealType __pi = 3.1415926535897932384626433832795029L;
__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
__aurng(__urng);
while (__f != __t)
{
_RealType __u;
do
__u = __aurng();
while (__u == 0.5);
*__f++ = __p.a() + __p.b() * std::tan(__pi * __u);
}
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const cauchy_distribution<_RealType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__space);
__os.precision(std::numeric_limits<_RealType>::max_digits10);
__os << __x.a() << __space << __x.b();
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
cauchy_distribution<_RealType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __a, __b;
if (__is >> __a >> __b)
__x.param(typename cauchy_distribution<_RealType>::
param_type(__a, __b));
__is.flags(__flags);
return __is;
}
template<typename _RealType>
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
std::fisher_f_distribution<_RealType>::
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
while (__f != __t)
*__f++ = ((_M_gd_x(__urng) * n()) / (_M_gd_y(__urng) * m()));
}
template<typename _RealType>
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
std::fisher_f_distribution<_RealType>::
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
typedef typename std::gamma_distribution<result_type>::param_type
param_type;
param_type __p1(__p.m() / 2);
param_type __p2(__p.n() / 2);
while (__f != __t)
*__f++ = ((_M_gd_x(__urng, __p1) * n())
/ (_M_gd_y(__urng, __p2) * m()));
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const fisher_f_distribution<_RealType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__space);
__os.precision(std::numeric_limits<_RealType>::max_digits10);
__os << __x.m() << __space << __x.n()
<< __space << __x._M_gd_x << __space << __x._M_gd_y;
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
fisher_f_distribution<_RealType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __m, __n;
if (__is >> __m >> __n >> __x._M_gd_x >> __x._M_gd_y)
__x.param(typename fisher_f_distribution<_RealType>::
param_type(__m, __n));
__is.flags(__flags);
return __is;
}
template<typename _RealType>
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
std::student_t_distribution<_RealType>::
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
while (__f != __t)
*__f++ = _M_nd(__urng) * std::sqrt(n() / _M_gd(__urng));
}
template<typename _RealType>
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
std::student_t_distribution<_RealType>::
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
typename std::gamma_distribution<result_type>::param_type
__p2(__p.n() / 2, 2);
while (__f != __t)
*__f++ = _M_nd(__urng) * std::sqrt(__p.n() / _M_gd(__urng, __p2));
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const student_t_distribution<_RealType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__space);
__os.precision(std::numeric_limits<_RealType>::max_digits10);
__os << __x.n() << __space << __x._M_nd << __space << __x._M_gd;
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
student_t_distribution<_RealType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __n;
if (__is >> __n >> __x._M_nd >> __x._M_gd)
__x.param(typename student_t_distribution<_RealType>::param_type(__n));
__is.flags(__flags);
return __is;
}
template<typename _RealType>
void
gamma_distribution<_RealType>::param_type::
_M_initialize()
{
_M_malpha = _M_alpha < 1.0 ? _M_alpha + _RealType(1.0) : _M_alpha;
const _RealType __a1 = _M_malpha - _RealType(1.0) / _RealType(3.0);
_M_a2 = _RealType(1.0) / std::sqrt(_RealType(9.0) * __a1);
}
/**
* Marsaglia, G. and Tsang, W. W.
* "A Simple Method for Generating Gamma Variables"
* ACM Transactions on Mathematical Software, 26, 3, 363-372, 2000.
*/
template<typename _RealType>
template<typename _UniformRandomNumberGenerator>
typename gamma_distribution<_RealType>::result_type
gamma_distribution<_RealType>::
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
__aurng(__urng);
result_type __u, __v, __n;
const result_type __a1 = (__param._M_malpha
- _RealType(1.0) / _RealType(3.0));
do
{
do
{
__n = _M_nd(__urng);
__v = result_type(1.0) + __param._M_a2 * __n;
}
while (__v <= 0.0);
__v = __v * __v * __v;
__u = __aurng();
}
while (__u > result_type(1.0) - 0.0331 * __n * __n * __n * __n
&& (std::log(__u) > (0.5 * __n * __n + __a1
* (1.0 - __v + std::log(__v)))));
if (__param.alpha() == __param._M_malpha)
return __a1 * __v * __param.beta();
else
{
do
__u = __aurng();
while (__u == 0.0);
return (std::pow(__u, result_type(1.0) / __param.alpha())
* __a1 * __v * __param.beta());
}
}
template<typename _RealType>
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
gamma_distribution<_RealType>::
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
__aurng(__urng);
result_type __u, __v, __n;
const result_type __a1 = (__param._M_malpha
- _RealType(1.0) / _RealType(3.0));
if (__param.alpha() == __param._M_malpha)
while (__f != __t)
{
do
{
do
{
__n = _M_nd(__urng);
__v = result_type(1.0) + __param._M_a2 * __n;
}
while (__v <= 0.0);
__v = __v * __v * __v;
__u = __aurng();
}
while (__u > result_type(1.0) - 0.0331 * __n * __n * __n * __n
&& (std::log(__u) > (0.5 * __n * __n + __a1
* (1.0 - __v + std::log(__v)))));
*__f++ = __a1 * __v * __param.beta();
}
else
while (__f != __t)
{
do
{
do
{
__n = _M_nd(__urng);
__v = result_type(1.0) + __param._M_a2 * __n;
}
while (__v <= 0.0);
__v = __v * __v * __v;
__u = __aurng();
}
while (__u > result_type(1.0) - 0.0331 * __n * __n * __n * __n
&& (std::log(__u) > (0.5 * __n * __n + __a1
* (1.0 - __v + std::log(__v)))));
do
__u = __aurng();
while (__u == 0.0);
*__f++ = (std::pow(__u, result_type(1.0) / __param.alpha())
* __a1 * __v * __param.beta());
}
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const gamma_distribution<_RealType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__space);
__os.precision(std::numeric_limits<_RealType>::max_digits10);
__os << __x.alpha() << __space << __x.beta()
<< __space << __x._M_nd;
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
gamma_distribution<_RealType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __alpha_val, __beta_val;
if (__is >> __alpha_val >> __beta_val >> __x._M_nd)
__x.param(typename gamma_distribution<_RealType>::
param_type(__alpha_val, __beta_val));
__is.flags(__flags);
return __is;
}
template<typename _RealType>
template<typename _UniformRandomNumberGenerator>
typename weibull_distribution<_RealType>::result_type
weibull_distribution<_RealType>::
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
__aurng(__urng);
return __p.b() * std::pow(-std::log(result_type(1) - __aurng()),
result_type(1) / __p.a());
}
template<typename _RealType>
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
weibull_distribution<_RealType>::
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
__aurng(__urng);
auto __inv_a = result_type(1) / __p.a();
while (__f != __t)
*__f++ = __p.b() * std::pow(-std::log(result_type(1) - __aurng()),
__inv_a);
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const weibull_distribution<_RealType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__space);
__os.precision(std::numeric_limits<_RealType>::max_digits10);
__os << __x.a() << __space << __x.b();
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
weibull_distribution<_RealType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __a, __b;
if (__is >> __a >> __b)
__x.param(typename weibull_distribution<_RealType>::
param_type(__a, __b));
__is.flags(__flags);
return __is;
}
template<typename _RealType>
template<typename _UniformRandomNumberGenerator>
typename extreme_value_distribution<_RealType>::result_type
extreme_value_distribution<_RealType>::
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
__aurng(__urng);
return __p.a() - __p.b() * std::log(-std::log(result_type(1)
- __aurng()));
}
template<typename _RealType>
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
extreme_value_distribution<_RealType>::
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
__aurng(__urng);
while (__f != __t)
*__f++ = __p.a() - __p.b() * std::log(-std::log(result_type(1)
- __aurng()));
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const extreme_value_distribution<_RealType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__space);
__os.precision(std::numeric_limits<_RealType>::max_digits10);
__os << __x.a() << __space << __x.b();
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
extreme_value_distribution<_RealType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __a, __b;
if (__is >> __a >> __b)
__x.param(typename extreme_value_distribution<_RealType>::
param_type(__a, __b));
__is.flags(__flags);
return __is;
}
template<typename _IntType>
void
discrete_distribution<_IntType>::param_type::
_M_initialize()
{
if (_M_prob.size() < 2)
{
_M_prob.clear();
return;
}
const double __sum = std::accumulate(_M_prob.begin(),
_M_prob.end(), 0.0);
// Now normalize the probabilites.
__detail::__normalize(_M_prob.begin(), _M_prob.end(), _M_prob.begin(),
__sum);
// Accumulate partial sums.
_M_cp.reserve(_M_prob.size());
std::partial_sum(_M_prob.begin(), _M_prob.end(),
std::back_inserter(_M_cp));
// Make sure the last cumulative probability is one.
_M_cp[_M_cp.size() - 1] = 1.0;
}
template<typename _IntType>
template<typename _Func>
discrete_distribution<_IntType>::param_type::
param_type(size_t __nw, double __xmin, double __xmax, _Func __fw)
: _M_prob(), _M_cp()
{
const size_t __n = __nw == 0 ? 1 : __nw;
const double __delta = (__xmax - __xmin) / __n;
_M_prob.reserve(__n);
for (size_t __k = 0; __k < __nw; ++__k)
_M_prob.push_back(__fw(__xmin + __k * __delta + 0.5 * __delta));
_M_initialize();
}
template<typename _IntType>
template<typename _UniformRandomNumberGenerator>
typename discrete_distribution<_IntType>::result_type
discrete_distribution<_IntType>::
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
if (__param._M_cp.empty())
return result_type(0);
__detail::_Adaptor<_UniformRandomNumberGenerator, double>
__aurng(__urng);
const double __p = __aurng();
auto __pos = std::lower_bound(__param._M_cp.begin(),
__param._M_cp.end(), __p);
return __pos - __param._M_cp.begin();
}
template<typename _IntType>
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
discrete_distribution<_IntType>::
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
if (__param._M_cp.empty())
{
while (__f != __t)
*__f++ = result_type(0);
return;
}
__detail::_Adaptor<_UniformRandomNumberGenerator, double>
__aurng(__urng);
while (__f != __t)
{
const double __p = __aurng();
auto __pos = std::lower_bound(__param._M_cp.begin(),
__param._M_cp.end(), __p);
*__f++ = __pos - __param._M_cp.begin();
}
}
template<typename _IntType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const discrete_distribution<_IntType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__space);
__os.precision(std::numeric_limits<double>::max_digits10);
std::vector<double> __prob = __x.probabilities();
__os << __prob.size();
for (auto __dit = __prob.begin(); __dit != __prob.end(); ++__dit)
__os << __space << *__dit;
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
namespace __detail
{
template<typename _ValT, typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>&
__extract_params(basic_istream<_CharT, _Traits>& __is,
vector<_ValT>& __vals, size_t __n)
{
__vals.reserve(__n);
while (__n--)
{
_ValT __val;
if (__is >> __val)
__vals.push_back(__val);
else
break;
}
return __is;
}
} // namespace __detail
template<typename _IntType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
discrete_distribution<_IntType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
size_t __n;
if (__is >> __n)
{
std::vector<double> __prob_vec;
if (__detail::__extract_params(__is, __prob_vec, __n))
__x.param({__prob_vec.begin(), __prob_vec.end()});
}
__is.flags(__flags);
return __is;
}
template<typename _RealType>
void
piecewise_constant_distribution<_RealType>::param_type::
_M_initialize()
{
if (_M_int.size() < 2
|| (_M_int.size() == 2
&& _M_int[0] == _RealType(0)
&& _M_int[1] == _RealType(1)))
{
_M_int.clear();
_M_den.clear();
return;
}
const double __sum = std::accumulate(_M_den.begin(),
_M_den.end(), 0.0);
__detail::__normalize(_M_den.begin(), _M_den.end(), _M_den.begin(),
__sum);
_M_cp.reserve(_M_den.size());
std::partial_sum(_M_den.begin(), _M_den.end(),
std::back_inserter(_M_cp));
// Make sure the last cumulative probability is one.
_M_cp[_M_cp.size() - 1] = 1.0;
for (size_t __k = 0; __k < _M_den.size(); ++__k)
_M_den[__k] /= _M_int[__k + 1] - _M_int[__k];
}
template<typename _RealType>
template<typename _InputIteratorB, typename _InputIteratorW>
piecewise_constant_distribution<_RealType>::param_type::
param_type(_InputIteratorB __bbegin,
_InputIteratorB __bend,
_InputIteratorW __wbegin)
: _M_int(), _M_den(), _M_cp()
{
if (__bbegin != __bend)
{
for (;;)
{
_M_int.push_back(*__bbegin);
++__bbegin;
if (__bbegin == __bend)
break;
_M_den.push_back(*__wbegin);
++__wbegin;
}
}
_M_initialize();
}
template<typename _RealType>
template<typename _Func>
piecewise_constant_distribution<_RealType>::param_type::
param_type(initializer_list<_RealType> __bl, _Func __fw)
: _M_int(), _M_den(), _M_cp()
{
_M_int.reserve(__bl.size());
for (auto __biter = __bl.begin(); __biter != __bl.end(); ++__biter)
_M_int.push_back(*__biter);
_M_den.reserve(_M_int.size() - 1);
for (size_t __k = 0; __k < _M_int.size() - 1; ++__k)
_M_den.push_back(__fw(0.5 * (_M_int[__k + 1] + _M_int[__k])));
_M_initialize();
}
template<typename _RealType>
template<typename _Func>
piecewise_constant_distribution<_RealType>::param_type::
param_type(size_t __nw, _RealType __xmin, _RealType __xmax, _Func __fw)
: _M_int(), _M_den(), _M_cp()
{
const size_t __n = __nw == 0 ? 1 : __nw;
const _RealType __delta = (__xmax - __xmin) / __n;
_M_int.reserve(__n + 1);
for (size_t __k = 0; __k <= __nw; ++__k)
_M_int.push_back(__xmin + __k * __delta);
_M_den.reserve(__n);
for (size_t __k = 0; __k < __nw; ++__k)
_M_den.push_back(__fw(_M_int[__k] + 0.5 * __delta));
_M_initialize();
}
template<typename _RealType>
template<typename _UniformRandomNumberGenerator>
typename piecewise_constant_distribution<_RealType>::result_type
piecewise_constant_distribution<_RealType>::
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
__detail::_Adaptor<_UniformRandomNumberGenerator, double>
__aurng(__urng);
const double __p = __aurng();
if (__param._M_cp.empty())
return __p;
auto __pos = std::lower_bound(__param._M_cp.begin(),
__param._M_cp.end(), __p);
const size_t __i = __pos - __param._M_cp.begin();
const double __pref = __i > 0 ? __param._M_cp[__i - 1] : 0.0;
return __param._M_int[__i] + (__p - __pref) / __param._M_den[__i];
}
template<typename _RealType>
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
piecewise_constant_distribution<_RealType>::
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__detail::_Adaptor<_UniformRandomNumberGenerator, double>
__aurng(__urng);
if (__param._M_cp.empty())
{
while (__f != __t)
*__f++ = __aurng();
return;
}
while (__f != __t)
{
const double __p = __aurng();
auto __pos = std::lower_bound(__param._M_cp.begin(),
__param._M_cp.end(), __p);
const size_t __i = __pos - __param._M_cp.begin();
const double __pref = __i > 0 ? __param._M_cp[__i - 1] : 0.0;
*__f++ = (__param._M_int[__i]
+ (__p - __pref) / __param._M_den[__i]);
}
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const piecewise_constant_distribution<_RealType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__space);
__os.precision(std::numeric_limits<_RealType>::max_digits10);
std::vector<_RealType> __int = __x.intervals();
__os << __int.size() - 1;
for (auto __xit = __int.begin(); __xit != __int.end(); ++__xit)
__os << __space << *__xit;
std::vector<double> __den = __x.densities();
for (auto __dit = __den.begin(); __dit != __den.end(); ++__dit)
__os << __space << *__dit;
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
piecewise_constant_distribution<_RealType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
size_t __n;
if (__is >> __n)
{
std::vector<_RealType> __int_vec;
if (__detail::__extract_params(__is, __int_vec, __n + 1))
{
std::vector<double> __den_vec;
if (__detail::__extract_params(__is, __den_vec, __n))
{
__x.param({ __int_vec.begin(), __int_vec.end(),
__den_vec.begin() });
}
}
}
__is.flags(__flags);
return __is;
}
template<typename _RealType>
void
piecewise_linear_distribution<_RealType>::param_type::
_M_initialize()
{
if (_M_int.size() < 2
|| (_M_int.size() == 2
&& _M_int[0] == _RealType(0)
&& _M_int[1] == _RealType(1)
&& _M_den[0] == _M_den[1]))
{
_M_int.clear();
_M_den.clear();
return;
}
double __sum = 0.0;
_M_cp.reserve(_M_int.size() - 1);
_M_m.reserve(_M_int.size() - 1);
for (size_t __k = 0; __k < _M_int.size() - 1; ++__k)
{
const _RealType __delta = _M_int[__k + 1] - _M_int[__k];
__sum += 0.5 * (_M_den[__k + 1] + _M_den[__k]) * __delta;
_M_cp.push_back(__sum);
_M_m.push_back((_M_den[__k + 1] - _M_den[__k]) / __delta);
}
// Now normalize the densities...
__detail::__normalize(_M_den.begin(), _M_den.end(), _M_den.begin(),
__sum);
// ... and partial sums...
__detail::__normalize(_M_cp.begin(), _M_cp.end(), _M_cp.begin(), __sum);
// ... and slopes.
__detail::__normalize(_M_m.begin(), _M_m.end(), _M_m.begin(), __sum);
// Make sure the last cumulative probablility is one.
_M_cp[_M_cp.size() - 1] = 1.0;
}
template<typename _RealType>
template<typename _InputIteratorB, typename _InputIteratorW>
piecewise_linear_distribution<_RealType>::param_type::
param_type(_InputIteratorB __bbegin,
_InputIteratorB __bend,
_InputIteratorW __wbegin)
: _M_int(), _M_den(), _M_cp(), _M_m()
{
for (; __bbegin != __bend; ++__bbegin, ++__wbegin)
{
_M_int.push_back(*__bbegin);
_M_den.push_back(*__wbegin);
}
_M_initialize();
}
template<typename _RealType>
template<typename _Func>
piecewise_linear_distribution<_RealType>::param_type::
param_type(initializer_list<_RealType> __bl, _Func __fw)
: _M_int(), _M_den(), _M_cp(), _M_m()
{
_M_int.reserve(__bl.size());
_M_den.reserve(__bl.size());
for (auto __biter = __bl.begin(); __biter != __bl.end(); ++__biter)
{
_M_int.push_back(*__biter);
_M_den.push_back(__fw(*__biter));
}
_M_initialize();
}
template<typename _RealType>
template<typename _Func>
piecewise_linear_distribution<_RealType>::param_type::
param_type(size_t __nw, _RealType __xmin, _RealType __xmax, _Func __fw)
: _M_int(), _M_den(), _M_cp(), _M_m()
{
const size_t __n = __nw == 0 ? 1 : __nw;
const _RealType __delta = (__xmax - __xmin) / __n;
_M_int.reserve(__n + 1);
_M_den.reserve(__n + 1);
for (size_t __k = 0; __k <= __nw; ++__k)
{
_M_int.push_back(__xmin + __k * __delta);
_M_den.push_back(__fw(_M_int[__k] + __delta));
}
_M_initialize();
}
template<typename _RealType>
template<typename _UniformRandomNumberGenerator>
typename piecewise_linear_distribution<_RealType>::result_type
piecewise_linear_distribution<_RealType>::
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
__detail::_Adaptor<_UniformRandomNumberGenerator, double>
__aurng(__urng);
const double __p = __aurng();
if (__param._M_cp.empty())
return __p;
auto __pos = std::lower_bound(__param._M_cp.begin(),
__param._M_cp.end(), __p);
const size_t __i = __pos - __param._M_cp.begin();
const double __pref = __i > 0 ? __param._M_cp[__i - 1] : 0.0;
const double __a = 0.5 * __param._M_m[__i];
const double __b = __param._M_den[__i];
const double __cm = __p - __pref;
_RealType __x = __param._M_int[__i];
if (__a == 0)
__x += __cm / __b;
else
{
const double __d = __b * __b + 4.0 * __a * __cm;
__x += 0.5 * (std::sqrt(__d) - __b) / __a;
}
return __x;
}
template<typename _RealType>
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
piecewise_linear_distribution<_RealType>::
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
// We could duplicate everything from operator()...
while (__f != __t)
*__f++ = this->operator()(__urng, __param);
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const piecewise_linear_distribution<_RealType>& __x)
{
typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill();
const std::streamsize __precision = __os.precision();
const _CharT __space = __os.widen(' ');
__os.flags(__ios_base::scientific | __ios_base::left);
__os.fill(__space);
__os.precision(std::numeric_limits<_RealType>::max_digits10);
std::vector<_RealType> __int = __x.intervals();
__os << __int.size() - 1;
for (auto __xit = __int.begin(); __xit != __int.end(); ++__xit)
__os << __space << *__xit;
std::vector<double> __den = __x.densities();
for (auto __dit = __den.begin(); __dit != __den.end(); ++__dit)
__os << __space << *__dit;
__os.flags(__flags);
__os.fill(__fill);
__os.precision(__precision);
return __os;
}
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
piecewise_linear_distribution<_RealType>& __x)
{
typedef std::basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws);
size_t __n;
if (__is >> __n)
{
vector<_RealType> __int_vec;
if (__detail::__extract_params(__is, __int_vec, __n + 1))
{
vector<double> __den_vec;
if (__detail::__extract_params(__is, __den_vec, __n + 1))
{
__x.param({ __int_vec.begin(), __int_vec.end(),
__den_vec.begin() });
}
}
}
__is.flags(__flags);
return __is;
}
template<typename _IntType>
seed_seq::seed_seq(std::initializer_list<_IntType> __il)
{
for (auto __iter = __il.begin(); __iter != __il.end(); ++__iter)
_M_v.push_back(__detail::__mod<result_type,
__detail::_Shift<result_type, 32>::__value>(*__iter));
}
template<typename _InputIterator>
seed_seq::seed_seq(_InputIterator __begin, _InputIterator __end)
{
for (_InputIterator __iter = __begin; __iter != __end; ++__iter)
_M_v.push_back(__detail::__mod<result_type,
__detail::_Shift<result_type, 32>::__value>(*__iter));
}
template<typename _RandomAccessIterator>
void
seed_seq::generate(_RandomAccessIterator __begin,
_RandomAccessIterator __end)
{
typedef typename iterator_traits<_RandomAccessIterator>::value_type
_Type;
if (__begin == __end)
return;
std::fill(__begin, __end, _Type(0x8b8b8b8bu));
const size_t __n = __end - __begin;
const size_t __s = _M_v.size();
const size_t __t = (__n >= 623) ? 11
: (__n >= 68) ? 7
: (__n >= 39) ? 5
: (__n >= 7) ? 3
: (__n - 1) / 2;
const size_t __p = (__n - __t) / 2;
const size_t __q = __p + __t;
const size_t __m = std::max(size_t(__s + 1), __n);
for (size_t __k = 0; __k < __m; ++__k)
{
_Type __arg = (__begin[__k % __n]
^ __begin[(__k + __p) % __n]
^ __begin[(__k - 1) % __n]);
_Type __r1 = __arg ^ (__arg >> 27);
__r1 = __detail::__mod<_Type,
__detail::_Shift<_Type, 32>::__value>(1664525u * __r1);
_Type __r2 = __r1;
if (__k == 0)
__r2 += __s;
else if (__k <= __s)
__r2 += __k % __n + _M_v[__k - 1];
else
__r2 += __k % __n;
__r2 = __detail::__mod<_Type,
__detail::_Shift<_Type, 32>::__value>(__r2);
__begin[(__k + __p) % __n] += __r1;
__begin[(__k + __q) % __n] += __r2;
__begin[__k % __n] = __r2;
}
for (size_t __k = __m; __k < __m + __n; ++__k)
{
_Type __arg = (__begin[__k % __n]
+ __begin[(__k + __p) % __n]
+ __begin[(__k - 1) % __n]);
_Type __r3 = __arg ^ (__arg >> 27);
__r3 = __detail::__mod<_Type,
__detail::_Shift<_Type, 32>::__value>(1566083941u * __r3);
_Type __r4 = __r3 - __k % __n;
__r4 = __detail::__mod<_Type,
__detail::_Shift<_Type, 32>::__value>(__r4);
__begin[(__k + __p) % __n] ^= __r3;
__begin[(__k + __q) % __n] ^= __r4;
__begin[__k % __n] = __r4;
}
}
template<typename _RealType, size_t __bits,
typename _UniformRandomNumberGenerator>
_RealType
generate_canonical(_UniformRandomNumberGenerator& __urng)
{
static_assert(std::is_floating_point<_RealType>::value,
"template argument must be a floating point type");
const size_t __b
= std::min(static_cast<size_t>(std::numeric_limits<_RealType>::digits),
__bits);
const long double __r = static_cast<long double>(__urng.max())
- static_cast<long double>(__urng.min()) + 1.0L;
const size_t __log2r = std::log(__r) / std::log(2.0L);
const size_t __m = std::max<size_t>(1UL,
(__b + __log2r - 1UL) / __log2r);
_RealType __ret;
_RealType __sum = _RealType(0);
_RealType __tmp = _RealType(1);
for (size_t __k = __m; __k != 0; --__k)
{
__sum += _RealType(__urng() - __urng.min()) * __tmp;
__tmp *= __r;
}
__ret = __sum / __tmp;
if (__builtin_expect(__ret >= _RealType(1), 0))
{
#if _GLIBCXX_USE_C99_MATH_TR1
__ret = std::nextafter(_RealType(1), _RealType(0));
#else
__ret = _RealType(1)
- std::numeric_limits<_RealType>::epsilon() / _RealType(2);
#endif
}
return __ret;
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/bits/stl_multimap.h 0000644 00000121125 15201526705 0011114 0 ustar 00 // Multimap implementation -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1996,1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file bits/stl_multimap.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{map}
*/
#ifndef _STL_MULTIMAP_H
#define _STL_MULTIMAP_H 1
#include <bits/concept_check.h>
#if __cplusplus >= 201103L
#include <initializer_list>
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
class map;
/**
* @brief A standard container made up of (key,value) pairs, which can be
* retrieved based on a key, in logarithmic time.
*
* @ingroup associative_containers
*
* @tparam _Key Type of key objects.
* @tparam _Tp Type of mapped objects.
* @tparam _Compare Comparison function object type, defaults to less<_Key>.
* @tparam _Alloc Allocator type, defaults to
* allocator<pair<const _Key, _Tp>.
*
* Meets the requirements of a <a href="tables.html#65">container</a>, a
* <a href="tables.html#66">reversible container</a>, and an
* <a href="tables.html#69">associative container</a> (using equivalent
* keys). For a @c multimap<Key,T> the key_type is Key, the mapped_type
* is T, and the value_type is std::pair<const Key,T>.
*
* Multimaps support bidirectional iterators.
*
* The private tree data is declared exactly the same way for map and
* multimap; the distinction is made entirely in how the tree functions are
* called (*_unique versus *_equal, same as the standard).
*/
template <typename _Key, typename _Tp,
typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
class multimap
{
public:
typedef _Key key_type;
typedef _Tp mapped_type;
typedef std::pair<const _Key, _Tp> value_type;
typedef _Compare key_compare;
typedef _Alloc allocator_type;
private:
#ifdef _GLIBCXX_CONCEPT_CHECKS
// concept requirements
typedef typename _Alloc::value_type _Alloc_value_type;
# if __cplusplus < 201103L
__glibcxx_class_requires(_Tp, _SGIAssignableConcept)
# endif
__glibcxx_class_requires4(_Compare, bool, _Key, _Key,
_BinaryFunctionConcept)
__glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept)
#endif
#if __cplusplus >= 201103L && defined(__STRICT_ANSI__)
static_assert(is_same<typename _Alloc::value_type, value_type>::value,
"std::multimap must have the same value_type as its allocator");
#endif
public:
class value_compare
: public std::binary_function<value_type, value_type, bool>
{
friend class multimap<_Key, _Tp, _Compare, _Alloc>;
protected:
_Compare comp;
value_compare(_Compare __c)
: comp(__c) { }
public:
bool operator()(const value_type& __x, const value_type& __y) const
{ return comp(__x.first, __y.first); }
};
private:
/// This turns a red-black tree into a [multi]map.
typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template
rebind<value_type>::other _Pair_alloc_type;
typedef _Rb_tree<key_type, value_type, _Select1st<value_type>,
key_compare, _Pair_alloc_type> _Rep_type;
/// The actual tree structure.
_Rep_type _M_t;
typedef __gnu_cxx::__alloc_traits<_Pair_alloc_type> _Alloc_traits;
public:
// many of these are specified differently in ISO, but the following are
// "functionally equivalent"
typedef typename _Alloc_traits::pointer pointer;
typedef typename _Alloc_traits::const_pointer const_pointer;
typedef typename _Alloc_traits::reference reference;
typedef typename _Alloc_traits::const_reference const_reference;
typedef typename _Rep_type::iterator iterator;
typedef typename _Rep_type::const_iterator const_iterator;
typedef typename _Rep_type::size_type size_type;
typedef typename _Rep_type::difference_type difference_type;
typedef typename _Rep_type::reverse_iterator reverse_iterator;
typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
#if __cplusplus > 201402L
using node_type = typename _Rep_type::node_type;
#endif
// [23.3.2] construct/copy/destroy
// (get_allocator() is also listed in this section)
/**
* @brief Default constructor creates no elements.
*/
#if __cplusplus < 201103L
multimap() : _M_t() { }
#else
multimap() = default;
#endif
/**
* @brief Creates a %multimap with no elements.
* @param __comp A comparison object.
* @param __a An allocator object.
*/
explicit
multimap(const _Compare& __comp,
const allocator_type& __a = allocator_type())
: _M_t(__comp, _Pair_alloc_type(__a)) { }
/**
* @brief %Multimap copy constructor.
*
* Whether the allocator is copied depends on the allocator traits.
*/
#if __cplusplus < 201103L
multimap(const multimap& __x)
: _M_t(__x._M_t) { }
#else
multimap(const multimap&) = default;
/**
* @brief %Multimap move constructor.
*
* The newly-created %multimap contains the exact contents of the
* moved instance. The moved instance is a valid, but unspecified
* %multimap.
*/
multimap(multimap&&) = default;
/**
* @brief Builds a %multimap from an initializer_list.
* @param __l An initializer_list.
* @param __comp A comparison functor.
* @param __a An allocator object.
*
* Create a %multimap consisting of copies of the elements from
* the initializer_list. This is linear in N if the list is already
* sorted, and NlogN otherwise (where N is @a __l.size()).
*/
multimap(initializer_list<value_type> __l,
const _Compare& __comp = _Compare(),
const allocator_type& __a = allocator_type())
: _M_t(__comp, _Pair_alloc_type(__a))
{ _M_t._M_insert_equal(__l.begin(), __l.end()); }
/// Allocator-extended default constructor.
explicit
multimap(const allocator_type& __a)
: _M_t(_Compare(), _Pair_alloc_type(__a)) { }
/// Allocator-extended copy constructor.
multimap(const multimap& __m, const allocator_type& __a)
: _M_t(__m._M_t, _Pair_alloc_type(__a)) { }
/// Allocator-extended move constructor.
multimap(multimap&& __m, const allocator_type& __a)
noexcept(is_nothrow_copy_constructible<_Compare>::value
&& _Alloc_traits::_S_always_equal())
: _M_t(std::move(__m._M_t), _Pair_alloc_type(__a)) { }
/// Allocator-extended initialier-list constructor.
multimap(initializer_list<value_type> __l, const allocator_type& __a)
: _M_t(_Compare(), _Pair_alloc_type(__a))
{ _M_t._M_insert_equal(__l.begin(), __l.end()); }
/// Allocator-extended range constructor.
template<typename _InputIterator>
multimap(_InputIterator __first, _InputIterator __last,
const allocator_type& __a)
: _M_t(_Compare(), _Pair_alloc_type(__a))
{ _M_t._M_insert_equal(__first, __last); }
#endif
/**
* @brief Builds a %multimap from a range.
* @param __first An input iterator.
* @param __last An input iterator.
*
* Create a %multimap consisting of copies of the elements from
* [__first,__last). This is linear in N if the range is already sorted,
* and NlogN otherwise (where N is distance(__first,__last)).
*/
template<typename _InputIterator>
multimap(_InputIterator __first, _InputIterator __last)
: _M_t()
{ _M_t._M_insert_equal(__first, __last); }
/**
* @brief Builds a %multimap from a range.
* @param __first An input iterator.
* @param __last An input iterator.
* @param __comp A comparison functor.
* @param __a An allocator object.
*
* Create a %multimap consisting of copies of the elements from
* [__first,__last). This is linear in N if the range is already sorted,
* and NlogN otherwise (where N is distance(__first,__last)).
*/
template<typename _InputIterator>
multimap(_InputIterator __first, _InputIterator __last,
const _Compare& __comp,
const allocator_type& __a = allocator_type())
: _M_t(__comp, _Pair_alloc_type(__a))
{ _M_t._M_insert_equal(__first, __last); }
#if __cplusplus >= 201103L
/**
* The dtor only erases the elements, and note that if the elements
* themselves are pointers, the pointed-to memory is not touched in any
* way. Managing the pointer is the user's responsibility.
*/
~multimap() = default;
#endif
/**
* @brief %Multimap assignment operator.
*
* Whether the allocator is copied depends on the allocator traits.
*/
#if __cplusplus < 201103L
multimap&
operator=(const multimap& __x)
{
_M_t = __x._M_t;
return *this;
}
#else
multimap&
operator=(const multimap&) = default;
/// Move assignment operator.
multimap&
operator=(multimap&&) = default;
/**
* @brief %Multimap list assignment operator.
* @param __l An initializer_list.
*
* This function fills a %multimap with copies of the elements
* in the initializer list @a __l.
*
* Note that the assignment completely changes the %multimap and
* that the resulting %multimap's size is the same as the number
* of elements assigned.
*/
multimap&
operator=(initializer_list<value_type> __l)
{
_M_t._M_assign_equal(__l.begin(), __l.end());
return *this;
}
#endif
/// Get a copy of the memory allocation object.
allocator_type
get_allocator() const _GLIBCXX_NOEXCEPT
{ return allocator_type(_M_t.get_allocator()); }
// iterators
/**
* Returns a read/write iterator that points to the first pair in the
* %multimap. Iteration is done in ascending order according to the
* keys.
*/
iterator
begin() _GLIBCXX_NOEXCEPT
{ return _M_t.begin(); }
/**
* Returns a read-only (constant) iterator that points to the first pair
* in the %multimap. Iteration is done in ascending order according to
* the keys.
*/
const_iterator
begin() const _GLIBCXX_NOEXCEPT
{ return _M_t.begin(); }
/**
* Returns a read/write iterator that points one past the last pair in
* the %multimap. Iteration is done in ascending order according to the
* keys.
*/
iterator
end() _GLIBCXX_NOEXCEPT
{ return _M_t.end(); }
/**
* Returns a read-only (constant) iterator that points one past the last
* pair in the %multimap. Iteration is done in ascending order according
* to the keys.
*/
const_iterator
end() const _GLIBCXX_NOEXCEPT
{ return _M_t.end(); }
/**
* Returns a read/write reverse iterator that points to the last pair in
* the %multimap. Iteration is done in descending order according to the
* keys.
*/
reverse_iterator
rbegin() _GLIBCXX_NOEXCEPT
{ return _M_t.rbegin(); }
/**
* Returns a read-only (constant) reverse iterator that points to the
* last pair in the %multimap. Iteration is done in descending order
* according to the keys.
*/
const_reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT
{ return _M_t.rbegin(); }
/**
* Returns a read/write reverse iterator that points to one before the
* first pair in the %multimap. Iteration is done in descending order
* according to the keys.
*/
reverse_iterator
rend() _GLIBCXX_NOEXCEPT
{ return _M_t.rend(); }
/**
* Returns a read-only (constant) reverse iterator that points to one
* before the first pair in the %multimap. Iteration is done in
* descending order according to the keys.
*/
const_reverse_iterator
rend() const _GLIBCXX_NOEXCEPT
{ return _M_t.rend(); }
#if __cplusplus >= 201103L
/**
* Returns a read-only (constant) iterator that points to the first pair
* in the %multimap. Iteration is done in ascending order according to
* the keys.
*/
const_iterator
cbegin() const noexcept
{ return _M_t.begin(); }
/**
* Returns a read-only (constant) iterator that points one past the last
* pair in the %multimap. Iteration is done in ascending order according
* to the keys.
*/
const_iterator
cend() const noexcept
{ return _M_t.end(); }
/**
* Returns a read-only (constant) reverse iterator that points to the
* last pair in the %multimap. Iteration is done in descending order
* according to the keys.
*/
const_reverse_iterator
crbegin() const noexcept
{ return _M_t.rbegin(); }
/**
* Returns a read-only (constant) reverse iterator that points to one
* before the first pair in the %multimap. Iteration is done in
* descending order according to the keys.
*/
const_reverse_iterator
crend() const noexcept
{ return _M_t.rend(); }
#endif
// capacity
/** Returns true if the %multimap is empty. */
bool
empty() const _GLIBCXX_NOEXCEPT
{ return _M_t.empty(); }
/** Returns the size of the %multimap. */
size_type
size() const _GLIBCXX_NOEXCEPT
{ return _M_t.size(); }
/** Returns the maximum size of the %multimap. */
size_type
max_size() const _GLIBCXX_NOEXCEPT
{ return _M_t.max_size(); }
// modifiers
#if __cplusplus >= 201103L
/**
* @brief Build and insert a std::pair into the %multimap.
*
* @param __args Arguments used to generate a new pair instance (see
* std::piecewise_contruct for passing arguments to each
* part of the pair constructor).
*
* @return An iterator that points to the inserted (key,value) pair.
*
* This function builds and inserts a (key, value) %pair into the
* %multimap.
* Contrary to a std::map the %multimap does not rely on unique keys and
* thus multiple pairs with the same key can be inserted.
*
* Insertion requires logarithmic time.
*/
template<typename... _Args>
iterator
emplace(_Args&&... __args)
{ return _M_t._M_emplace_equal(std::forward<_Args>(__args)...); }
/**
* @brief Builds and inserts a std::pair into the %multimap.
*
* @param __pos An iterator that serves as a hint as to where the pair
* should be inserted.
* @param __args Arguments used to generate a new pair instance (see
* std::piecewise_contruct for passing arguments to each
* part of the pair constructor).
* @return An iterator that points to the inserted (key,value) pair.
*
* This function inserts a (key, value) pair into the %multimap.
* Contrary to a std::map the %multimap does not rely on unique keys and
* thus multiple pairs with the same key can be inserted.
* Note that the first parameter is only a hint and can potentially
* improve the performance of the insertion process. A bad hint would
* cause no gains in efficiency.
*
* For more on @a hinting, see:
* https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints
*
* Insertion requires logarithmic time (if the hint is not taken).
*/
template<typename... _Args>
iterator
emplace_hint(const_iterator __pos, _Args&&... __args)
{
return _M_t._M_emplace_hint_equal(__pos,
std::forward<_Args>(__args)...);
}
#endif
/**
* @brief Inserts a std::pair into the %multimap.
* @param __x Pair to be inserted (see std::make_pair for easy creation
* of pairs).
* @return An iterator that points to the inserted (key,value) pair.
*
* This function inserts a (key, value) pair into the %multimap.
* Contrary to a std::map the %multimap does not rely on unique keys and
* thus multiple pairs with the same key can be inserted.
*
* Insertion requires logarithmic time.
* @{
*/
iterator
insert(const value_type& __x)
{ return _M_t._M_insert_equal(__x); }
#if __cplusplus >= 201103L
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2354. Unnecessary copying when inserting into maps with braced-init
iterator
insert(value_type&& __x)
{ return _M_t._M_insert_equal(std::move(__x)); }
template<typename _Pair>
__enable_if_t<is_constructible<value_type, _Pair>::value, iterator>
insert(_Pair&& __x)
{ return _M_t._M_emplace_equal(std::forward<_Pair>(__x)); }
#endif
// @}
/**
* @brief Inserts a std::pair into the %multimap.
* @param __position An iterator that serves as a hint as to where the
* pair should be inserted.
* @param __x Pair to be inserted (see std::make_pair for easy creation
* of pairs).
* @return An iterator that points to the inserted (key,value) pair.
*
* This function inserts a (key, value) pair into the %multimap.
* Contrary to a std::map the %multimap does not rely on unique keys and
* thus multiple pairs with the same key can be inserted.
* Note that the first parameter is only a hint and can potentially
* improve the performance of the insertion process. A bad hint would
* cause no gains in efficiency.
*
* For more on @a hinting, see:
* https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints
*
* Insertion requires logarithmic time (if the hint is not taken).
* @{
*/
iterator
#if __cplusplus >= 201103L
insert(const_iterator __position, const value_type& __x)
#else
insert(iterator __position, const value_type& __x)
#endif
{ return _M_t._M_insert_equal_(__position, __x); }
#if __cplusplus >= 201103L
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2354. Unnecessary copying when inserting into maps with braced-init
iterator
insert(const_iterator __position, value_type&& __x)
{ return _M_t._M_insert_equal_(__position, std::move(__x)); }
template<typename _Pair>
__enable_if_t<is_constructible<value_type, _Pair&&>::value, iterator>
insert(const_iterator __position, _Pair&& __x)
{
return _M_t._M_emplace_hint_equal(__position,
std::forward<_Pair>(__x));
}
#endif
// @}
/**
* @brief A template function that attempts to insert a range
* of elements.
* @param __first Iterator pointing to the start of the range to be
* inserted.
* @param __last Iterator pointing to the end of the range.
*
* Complexity similar to that of the range constructor.
*/
template<typename _InputIterator>
void
insert(_InputIterator __first, _InputIterator __last)
{ _M_t._M_insert_equal(__first, __last); }
#if __cplusplus >= 201103L
/**
* @brief Attempts to insert a list of std::pairs into the %multimap.
* @param __l A std::initializer_list<value_type> of pairs to be
* inserted.
*
* Complexity similar to that of the range constructor.
*/
void
insert(initializer_list<value_type> __l)
{ this->insert(__l.begin(), __l.end()); }
#endif
#if __cplusplus > 201402L
/// Extract a node.
node_type
extract(const_iterator __pos)
{
__glibcxx_assert(__pos != end());
return _M_t.extract(__pos);
}
/// Extract a node.
node_type
extract(const key_type& __x)
{ return _M_t.extract(__x); }
/// Re-insert an extracted node.
iterator
insert(node_type&& __nh)
{ return _M_t._M_reinsert_node_equal(std::move(__nh)); }
/// Re-insert an extracted node.
iterator
insert(const_iterator __hint, node_type&& __nh)
{ return _M_t._M_reinsert_node_hint_equal(__hint, std::move(__nh)); }
template<typename, typename>
friend class std::_Rb_tree_merge_helper;
template<typename _C2>
void
merge(multimap<_Key, _Tp, _C2, _Alloc>& __source)
{
using _Merge_helper = _Rb_tree_merge_helper<multimap, _C2>;
_M_t._M_merge_equal(_Merge_helper::_S_get_tree(__source));
}
template<typename _C2>
void
merge(multimap<_Key, _Tp, _C2, _Alloc>&& __source)
{ merge(__source); }
template<typename _C2>
void
merge(map<_Key, _Tp, _C2, _Alloc>& __source)
{
using _Merge_helper = _Rb_tree_merge_helper<multimap, _C2>;
_M_t._M_merge_equal(_Merge_helper::_S_get_tree(__source));
}
template<typename _C2>
void
merge(map<_Key, _Tp, _C2, _Alloc>&& __source)
{ merge(__source); }
#endif // C++17
#if __cplusplus >= 201103L
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 130. Associative erase should return an iterator.
/**
* @brief Erases an element from a %multimap.
* @param __position An iterator pointing to the element to be erased.
* @return An iterator pointing to the element immediately following
* @a position prior to the element being erased. If no such
* element exists, end() is returned.
*
* This function erases an element, pointed to by the given iterator,
* from a %multimap. Note that this function only erases the element,
* and that if the element is itself a pointer, the pointed-to memory is
* not touched in any way. Managing the pointer is the user's
* responsibility.
*
* @{
*/
iterator
erase(const_iterator __position)
{ return _M_t.erase(__position); }
// LWG 2059.
_GLIBCXX_ABI_TAG_CXX11
iterator
erase(iterator __position)
{ return _M_t.erase(__position); }
// @}
#else
/**
* @brief Erases an element from a %multimap.
* @param __position An iterator pointing to the element to be erased.
*
* This function erases an element, pointed to by the given iterator,
* from a %multimap. Note that this function only erases the element,
* and that if the element is itself a pointer, the pointed-to memory is
* not touched in any way. Managing the pointer is the user's
* responsibility.
*/
void
erase(iterator __position)
{ _M_t.erase(__position); }
#endif
/**
* @brief Erases elements according to the provided key.
* @param __x Key of element to be erased.
* @return The number of elements erased.
*
* This function erases all elements located by the given key from a
* %multimap.
* Note that this function only erases the element, and that if
* the element is itself a pointer, the pointed-to memory is not touched
* in any way. Managing the pointer is the user's responsibility.
*/
size_type
erase(const key_type& __x)
{ return _M_t.erase(__x); }
#if __cplusplus >= 201103L
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 130. Associative erase should return an iterator.
/**
* @brief Erases a [first,last) range of elements from a %multimap.
* @param __first Iterator pointing to the start of the range to be
* erased.
* @param __last Iterator pointing to the end of the range to be
* erased .
* @return The iterator @a __last.
*
* This function erases a sequence of elements from a %multimap.
* Note that this function only erases the elements, and that if
* the elements themselves are pointers, the pointed-to memory is not
* touched in any way. Managing the pointer is the user's
* responsibility.
*/
iterator
erase(const_iterator __first, const_iterator __last)
{ return _M_t.erase(__first, __last); }
#else
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 130. Associative erase should return an iterator.
/**
* @brief Erases a [first,last) range of elements from a %multimap.
* @param __first Iterator pointing to the start of the range to be
* erased.
* @param __last Iterator pointing to the end of the range to
* be erased.
*
* This function erases a sequence of elements from a %multimap.
* Note that this function only erases the elements, and that if
* the elements themselves are pointers, the pointed-to memory is not
* touched in any way. Managing the pointer is the user's
* responsibility.
*/
void
erase(iterator __first, iterator __last)
{ _M_t.erase(__first, __last); }
#endif
/**
* @brief Swaps data with another %multimap.
* @param __x A %multimap of the same element and allocator types.
*
* This exchanges the elements between two multimaps in constant time.
* (It is only swapping a pointer, an integer, and an instance of
* the @c Compare type (which itself is often stateless and empty), so it
* should be quite fast.)
* Note that the global std::swap() function is specialized such that
* std::swap(m1,m2) will feed to this function.
*
* Whether the allocators are swapped depends on the allocator traits.
*/
void
swap(multimap& __x)
_GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value)
{ _M_t.swap(__x._M_t); }
/**
* Erases all elements in a %multimap. Note that this function only
* erases the elements, and that if the elements themselves are pointers,
* the pointed-to memory is not touched in any way. Managing the pointer
* is the user's responsibility.
*/
void
clear() _GLIBCXX_NOEXCEPT
{ _M_t.clear(); }
// observers
/**
* Returns the key comparison object out of which the %multimap
* was constructed.
*/
key_compare
key_comp() const
{ return _M_t.key_comp(); }
/**
* Returns a value comparison object, built from the key comparison
* object out of which the %multimap was constructed.
*/
value_compare
value_comp() const
{ return value_compare(_M_t.key_comp()); }
// multimap operations
//@{
/**
* @brief Tries to locate an element in a %multimap.
* @param __x Key of (key, value) pair to be located.
* @return Iterator pointing to sought-after element,
* or end() if not found.
*
* This function takes a key and tries to locate the element with which
* the key matches. If successful the function returns an iterator
* pointing to the sought after %pair. If unsuccessful it returns the
* past-the-end ( @c end() ) iterator.
*/
iterator
find(const key_type& __x)
{ return _M_t.find(__x); }
#if __cplusplus > 201103L
template<typename _Kt>
auto
find(const _Kt& __x) -> decltype(_M_t._M_find_tr(__x))
{ return _M_t._M_find_tr(__x); }
#endif
//@}
//@{
/**
* @brief Tries to locate an element in a %multimap.
* @param __x Key of (key, value) pair to be located.
* @return Read-only (constant) iterator pointing to sought-after
* element, or end() if not found.
*
* This function takes a key and tries to locate the element with which
* the key matches. If successful the function returns a constant
* iterator pointing to the sought after %pair. If unsuccessful it
* returns the past-the-end ( @c end() ) iterator.
*/
const_iterator
find(const key_type& __x) const
{ return _M_t.find(__x); }
#if __cplusplus > 201103L
template<typename _Kt>
auto
find(const _Kt& __x) const -> decltype(_M_t._M_find_tr(__x))
{ return _M_t._M_find_tr(__x); }
#endif
//@}
//@{
/**
* @brief Finds the number of elements with given key.
* @param __x Key of (key, value) pairs to be located.
* @return Number of elements with specified key.
*/
size_type
count(const key_type& __x) const
{ return _M_t.count(__x); }
#if __cplusplus > 201103L
template<typename _Kt>
auto
count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x))
{ return _M_t._M_count_tr(__x); }
#endif
//@}
//@{
/**
* @brief Finds the beginning of a subsequence matching given key.
* @param __x Key of (key, value) pair to be located.
* @return Iterator pointing to first element equal to or greater
* than key, or end().
*
* This function returns the first element of a subsequence of elements
* that matches the given key. If unsuccessful it returns an iterator
* pointing to the first element that has a greater value than given key
* or end() if no such element exists.
*/
iterator
lower_bound(const key_type& __x)
{ return _M_t.lower_bound(__x); }
#if __cplusplus > 201103L
template<typename _Kt>
auto
lower_bound(const _Kt& __x)
-> decltype(iterator(_M_t._M_lower_bound_tr(__x)))
{ return iterator(_M_t._M_lower_bound_tr(__x)); }
#endif
//@}
//@{
/**
* @brief Finds the beginning of a subsequence matching given key.
* @param __x Key of (key, value) pair to be located.
* @return Read-only (constant) iterator pointing to first element
* equal to or greater than key, or end().
*
* This function returns the first element of a subsequence of
* elements that matches the given key. If unsuccessful the
* iterator will point to the next greatest element or, if no
* such greater element exists, to end().
*/
const_iterator
lower_bound(const key_type& __x) const
{ return _M_t.lower_bound(__x); }
#if __cplusplus > 201103L
template<typename _Kt>
auto
lower_bound(const _Kt& __x) const
-> decltype(const_iterator(_M_t._M_lower_bound_tr(__x)))
{ return const_iterator(_M_t._M_lower_bound_tr(__x)); }
#endif
//@}
//@{
/**
* @brief Finds the end of a subsequence matching given key.
* @param __x Key of (key, value) pair to be located.
* @return Iterator pointing to the first element
* greater than key, or end().
*/
iterator
upper_bound(const key_type& __x)
{ return _M_t.upper_bound(__x); }
#if __cplusplus > 201103L
template<typename _Kt>
auto
upper_bound(const _Kt& __x)
-> decltype(iterator(_M_t._M_upper_bound_tr(__x)))
{ return iterator(_M_t._M_upper_bound_tr(__x)); }
#endif
//@}
//@{
/**
* @brief Finds the end of a subsequence matching given key.
* @param __x Key of (key, value) pair to be located.
* @return Read-only (constant) iterator pointing to first iterator
* greater than key, or end().
*/
const_iterator
upper_bound(const key_type& __x) const
{ return _M_t.upper_bound(__x); }
#if __cplusplus > 201103L
template<typename _Kt>
auto
upper_bound(const _Kt& __x) const
-> decltype(const_iterator(_M_t._M_upper_bound_tr(__x)))
{ return const_iterator(_M_t._M_upper_bound_tr(__x)); }
#endif
//@}
//@{
/**
* @brief Finds a subsequence matching given key.
* @param __x Key of (key, value) pairs to be located.
* @return Pair of iterators that possibly points to the subsequence
* matching given key.
*
* This function is equivalent to
* @code
* std::make_pair(c.lower_bound(val),
* c.upper_bound(val))
* @endcode
* (but is faster than making the calls separately).
*/
std::pair<iterator, iterator>
equal_range(const key_type& __x)
{ return _M_t.equal_range(__x); }
#if __cplusplus > 201103L
template<typename _Kt>
auto
equal_range(const _Kt& __x)
-> decltype(pair<iterator, iterator>(_M_t._M_equal_range_tr(__x)))
{ return pair<iterator, iterator>(_M_t._M_equal_range_tr(__x)); }
#endif
//@}
//@{
/**
* @brief Finds a subsequence matching given key.
* @param __x Key of (key, value) pairs to be located.
* @return Pair of read-only (constant) iterators that possibly points
* to the subsequence matching given key.
*
* This function is equivalent to
* @code
* std::make_pair(c.lower_bound(val),
* c.upper_bound(val))
* @endcode
* (but is faster than making the calls separately).
*/
std::pair<const_iterator, const_iterator>
equal_range(const key_type& __x) const
{ return _M_t.equal_range(__x); }
#if __cplusplus > 201103L
template<typename _Kt>
auto
equal_range(const _Kt& __x) const
-> decltype(pair<const_iterator, const_iterator>(
_M_t._M_equal_range_tr(__x)))
{
return pair<const_iterator, const_iterator>(
_M_t._M_equal_range_tr(__x));
}
#endif
//@}
template<typename _K1, typename _T1, typename _C1, typename _A1>
friend bool
operator==(const multimap<_K1, _T1, _C1, _A1>&,
const multimap<_K1, _T1, _C1, _A1>&);
template<typename _K1, typename _T1, typename _C1, typename _A1>
friend bool
operator<(const multimap<_K1, _T1, _C1, _A1>&,
const multimap<_K1, _T1, _C1, _A1>&);
};
#if __cpp_deduction_guides >= 201606
template<typename _InputIterator,
typename _Compare = less<__iter_key_t<_InputIterator>>,
typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>,
typename = _RequireInputIter<_InputIterator>,
typename = _RequireAllocator<_Allocator>>
multimap(_InputIterator, _InputIterator,
_Compare = _Compare(), _Allocator = _Allocator())
-> multimap<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>,
_Compare, _Allocator>;
template<typename _Key, typename _Tp, typename _Compare = less<_Key>,
typename _Allocator = allocator<pair<const _Key, _Tp>>,
typename = _RequireAllocator<_Allocator>>
multimap(initializer_list<pair<_Key, _Tp>>,
_Compare = _Compare(), _Allocator = _Allocator())
-> multimap<_Key, _Tp, _Compare, _Allocator>;
template<typename _InputIterator, typename _Allocator,
typename = _RequireInputIter<_InputIterator>,
typename = _RequireAllocator<_Allocator>>
multimap(_InputIterator, _InputIterator, _Allocator)
-> multimap<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>,
less<__iter_key_t<_InputIterator>>, _Allocator>;
template<typename _Key, typename _Tp, typename _Allocator,
typename = _RequireAllocator<_Allocator>>
multimap(initializer_list<pair<_Key, _Tp>>, _Allocator)
-> multimap<_Key, _Tp, less<_Key>, _Allocator>;
#endif
/**
* @brief Multimap equality comparison.
* @param __x A %multimap.
* @param __y A %multimap of the same type as @a __x.
* @return True iff the size and elements of the maps are equal.
*
* This is an equivalence relation. It is linear in the size of the
* multimaps. Multimaps are considered equivalent if their sizes are equal,
* and if corresponding elements compare equal.
*/
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline bool
operator==(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
{ return __x._M_t == __y._M_t; }
/**
* @brief Multimap ordering relation.
* @param __x A %multimap.
* @param __y A %multimap of the same type as @a __x.
* @return True iff @a x is lexicographically less than @a y.
*
* This is a total ordering relation. It is linear in the size of the
* multimaps. The elements must be comparable with @c <.
*
* See std::lexicographical_compare() for how the determination is made.
*/
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline bool
operator<(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
{ return __x._M_t < __y._M_t; }
/// Based on operator==
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline bool
operator!=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
{ return !(__x == __y); }
/// Based on operator<
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline bool
operator>(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
{ return __y < __x; }
/// Based on operator<
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline bool
operator<=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
{ return !(__y < __x); }
/// Based on operator<
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline bool
operator>=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
{ return !(__x < __y); }
/// See std::multimap::swap().
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline void
swap(multimap<_Key, _Tp, _Compare, _Alloc>& __x,
multimap<_Key, _Tp, _Compare, _Alloc>& __y)
_GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
{ __x.swap(__y); }
_GLIBCXX_END_NAMESPACE_CONTAINER
#if __cplusplus > 201402L
// Allow std::multimap access to internals of compatible maps.
template<typename _Key, typename _Val, typename _Cmp1, typename _Alloc,
typename _Cmp2>
struct
_Rb_tree_merge_helper<_GLIBCXX_STD_C::multimap<_Key, _Val, _Cmp1, _Alloc>,
_Cmp2>
{
private:
friend class _GLIBCXX_STD_C::multimap<_Key, _Val, _Cmp1, _Alloc>;
static auto&
_S_get_tree(_GLIBCXX_STD_C::map<_Key, _Val, _Cmp2, _Alloc>& __map)
{ return __map._M_t; }
static auto&
_S_get_tree(_GLIBCXX_STD_C::multimap<_Key, _Val, _Cmp2, _Alloc>& __map)
{ return __map._M_t; }
};
#endif // C++17
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif /* _STL_MULTIMAP_H */
c++/8/bits/mask_array.h 0000644 00000016653 15201526705 0010544 0 ustar 00 // The template and inlines for the -*- C++ -*- mask_array class.
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/mask_array.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{valarray}
*/
// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
#ifndef _MASK_ARRAY_H
#define _MASK_ARRAY_H 1
#pragma GCC system_header
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @addtogroup numeric_arrays
* @{
*/
/**
* @brief Reference to selected subset of an array.
*
* A mask_array is a reference to the actual elements of an array specified
* by a bitmask in the form of an array of bool. The way to get a
* mask_array is to call operator[](valarray<bool>) on a valarray. The
* returned mask_array then permits carrying operations out on the
* referenced subset of elements in the original valarray.
*
* For example, if a mask_array is obtained using the array (false, true,
* false, true) as an argument, the mask array has two elements referring
* to array[1] and array[3] in the underlying array.
*
* @param Tp Element type.
*/
template <class _Tp>
class mask_array
{
public:
typedef _Tp value_type;
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 253. valarray helper functions are almost entirely useless
/// Copy constructor. Both slices refer to the same underlying array.
mask_array (const mask_array&);
/// Assignment operator. Assigns elements to corresponding elements
/// of @a a.
mask_array& operator=(const mask_array&);
void operator=(const valarray<_Tp>&) const;
/// Multiply slice elements by corresponding elements of @a v.
void operator*=(const valarray<_Tp>&) const;
/// Divide slice elements by corresponding elements of @a v.
void operator/=(const valarray<_Tp>&) const;
/// Modulo slice elements by corresponding elements of @a v.
void operator%=(const valarray<_Tp>&) const;
/// Add corresponding elements of @a v to slice elements.
void operator+=(const valarray<_Tp>&) const;
/// Subtract corresponding elements of @a v from slice elements.
void operator-=(const valarray<_Tp>&) const;
/// Logical xor slice elements with corresponding elements of @a v.
void operator^=(const valarray<_Tp>&) const;
/// Logical and slice elements with corresponding elements of @a v.
void operator&=(const valarray<_Tp>&) const;
/// Logical or slice elements with corresponding elements of @a v.
void operator|=(const valarray<_Tp>&) const;
/// Left shift slice elements by corresponding elements of @a v.
void operator<<=(const valarray<_Tp>&) const;
/// Right shift slice elements by corresponding elements of @a v.
void operator>>=(const valarray<_Tp>&) const;
/// Assign all slice elements to @a t.
void operator=(const _Tp&) const;
// ~mask_array ();
template<class _Dom>
void operator=(const _Expr<_Dom,_Tp>&) const;
template<class _Dom>
void operator*=(const _Expr<_Dom,_Tp>&) const;
template<class _Dom>
void operator/=(const _Expr<_Dom,_Tp>&) const;
template<class _Dom>
void operator%=(const _Expr<_Dom,_Tp>&) const;
template<class _Dom>
void operator+=(const _Expr<_Dom,_Tp>&) const;
template<class _Dom>
void operator-=(const _Expr<_Dom,_Tp>&) const;
template<class _Dom>
void operator^=(const _Expr<_Dom,_Tp>&) const;
template<class _Dom>
void operator&=(const _Expr<_Dom,_Tp>&) const;
template<class _Dom>
void operator|=(const _Expr<_Dom,_Tp>&) const;
template<class _Dom>
void operator<<=(const _Expr<_Dom,_Tp>&) const;
template<class _Dom>
void operator>>=(const _Expr<_Dom,_Tp>&) const;
private:
mask_array(_Array<_Tp>, size_t, _Array<bool>);
friend class valarray<_Tp>;
const size_t _M_sz;
const _Array<bool> _M_mask;
const _Array<_Tp> _M_array;
// not implemented
mask_array();
};
template<typename _Tp>
inline mask_array<_Tp>::mask_array(const mask_array<_Tp>& __a)
: _M_sz(__a._M_sz), _M_mask(__a._M_mask), _M_array(__a._M_array) {}
template<typename _Tp>
inline
mask_array<_Tp>::mask_array(_Array<_Tp> __a, size_t __s, _Array<bool> __m)
: _M_sz(__s), _M_mask(__m), _M_array(__a) {}
template<typename _Tp>
inline mask_array<_Tp>&
mask_array<_Tp>::operator=(const mask_array<_Tp>& __a)
{
std::__valarray_copy(__a._M_array, __a._M_mask,
_M_sz, _M_array, _M_mask);
return *this;
}
template<typename _Tp>
inline void
mask_array<_Tp>::operator=(const _Tp& __t) const
{ std::__valarray_fill(_M_array, _M_sz, _M_mask, __t); }
template<typename _Tp>
inline void
mask_array<_Tp>::operator=(const valarray<_Tp>& __v) const
{ std::__valarray_copy(_Array<_Tp>(__v), __v.size(), _M_array, _M_mask); }
template<typename _Tp>
template<class _Ex>
inline void
mask_array<_Tp>::operator=(const _Expr<_Ex, _Tp>& __e) const
{ std::__valarray_copy(__e, __e.size(), _M_array, _M_mask); }
#undef _DEFINE_VALARRAY_OPERATOR
#define _DEFINE_VALARRAY_OPERATOR(_Op, _Name) \
template<typename _Tp> \
inline void \
mask_array<_Tp>::operator _Op##=(const valarray<_Tp>& __v) const \
{ \
_Array_augmented_##_Name(_M_array, _M_mask, \
_Array<_Tp>(__v), __v.size()); \
} \
\
template<typename _Tp> \
template<class _Dom> \
inline void \
mask_array<_Tp>::operator _Op##=(const _Expr<_Dom, _Tp>& __e) const\
{ \
_Array_augmented_##_Name(_M_array, _M_mask, __e, __e.size()); \
}
_DEFINE_VALARRAY_OPERATOR(*, __multiplies)
_DEFINE_VALARRAY_OPERATOR(/, __divides)
_DEFINE_VALARRAY_OPERATOR(%, __modulus)
_DEFINE_VALARRAY_OPERATOR(+, __plus)
_DEFINE_VALARRAY_OPERATOR(-, __minus)
_DEFINE_VALARRAY_OPERATOR(^, __bitwise_xor)
_DEFINE_VALARRAY_OPERATOR(&, __bitwise_and)
_DEFINE_VALARRAY_OPERATOR(|, __bitwise_or)
_DEFINE_VALARRAY_OPERATOR(<<, __shift_left)
_DEFINE_VALARRAY_OPERATOR(>>, __shift_right)
#undef _DEFINE_VALARRAY_OPERATOR
// @} group numeric_arrays
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif /* _MASK_ARRAY_H */
c++/8/bits/stream_iterator.h 0000644 00000014776 15201526705 0011623 0 ustar 00 // Stream iterators
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/stream_iterator.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{iterator}
*/
#ifndef _STREAM_ITERATOR_H
#define _STREAM_ITERATOR_H 1
#pragma GCC system_header
#include <debug/debug.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @addtogroup iterators
* @{
*/
/// Provides input iterator semantics for streams.
template<typename _Tp, typename _CharT = char,
typename _Traits = char_traits<_CharT>, typename _Dist = ptrdiff_t>
class istream_iterator
: public iterator<input_iterator_tag, _Tp, _Dist, const _Tp*, const _Tp&>
{
public:
typedef _CharT char_type;
typedef _Traits traits_type;
typedef basic_istream<_CharT, _Traits> istream_type;
private:
istream_type* _M_stream;
_Tp _M_value;
bool _M_ok;
public:
/// Construct end of input stream iterator.
_GLIBCXX_CONSTEXPR istream_iterator()
: _M_stream(0), _M_value(), _M_ok(false) {}
/// Construct start of input stream iterator.
istream_iterator(istream_type& __s)
: _M_stream(std::__addressof(__s))
{ _M_read(); }
istream_iterator(const istream_iterator& __obj)
: _M_stream(__obj._M_stream), _M_value(__obj._M_value),
_M_ok(__obj._M_ok)
{ }
const _Tp&
operator*() const
{
__glibcxx_requires_cond(_M_ok,
_M_message(__gnu_debug::__msg_deref_istream)
._M_iterator(*this));
return _M_value;
}
const _Tp*
operator->() const { return std::__addressof((operator*())); }
istream_iterator&
operator++()
{
__glibcxx_requires_cond(_M_ok,
_M_message(__gnu_debug::__msg_inc_istream)
._M_iterator(*this));
_M_read();
return *this;
}
istream_iterator
operator++(int)
{
__glibcxx_requires_cond(_M_ok,
_M_message(__gnu_debug::__msg_inc_istream)
._M_iterator(*this));
istream_iterator __tmp = *this;
_M_read();
return __tmp;
}
bool
_M_equal(const istream_iterator& __x) const
{ return (_M_ok == __x._M_ok) && (!_M_ok || _M_stream == __x._M_stream); }
private:
void
_M_read()
{
_M_ok = (_M_stream && *_M_stream) ? true : false;
if (_M_ok)
{
*_M_stream >> _M_value;
_M_ok = *_M_stream ? true : false;
}
}
};
/// Return true if x and y are both end or not end, or x and y are the same.
template<typename _Tp, typename _CharT, typename _Traits, typename _Dist>
inline bool
operator==(const istream_iterator<_Tp, _CharT, _Traits, _Dist>& __x,
const istream_iterator<_Tp, _CharT, _Traits, _Dist>& __y)
{ return __x._M_equal(__y); }
/// Return false if x and y are both end or not end, or x and y are the same.
template <class _Tp, class _CharT, class _Traits, class _Dist>
inline bool
operator!=(const istream_iterator<_Tp, _CharT, _Traits, _Dist>& __x,
const istream_iterator<_Tp, _CharT, _Traits, _Dist>& __y)
{ return !__x._M_equal(__y); }
/**
* @brief Provides output iterator semantics for streams.
*
* This class provides an iterator to write to an ostream. The type Tp is
* the only type written by this iterator and there must be an
* operator<<(Tp) defined.
*
* @tparam _Tp The type to write to the ostream.
* @tparam _CharT The ostream char_type.
* @tparam _Traits The ostream char_traits.
*/
template<typename _Tp, typename _CharT = char,
typename _Traits = char_traits<_CharT> >
class ostream_iterator
: public iterator<output_iterator_tag, void, void, void, void>
{
public:
//@{
/// Public typedef
typedef _CharT char_type;
typedef _Traits traits_type;
typedef basic_ostream<_CharT, _Traits> ostream_type;
//@}
private:
ostream_type* _M_stream;
const _CharT* _M_string;
public:
/// Construct from an ostream.
ostream_iterator(ostream_type& __s)
: _M_stream(std::__addressof(__s)), _M_string(0) {}
/**
* Construct from an ostream.
*
* The delimiter string @a c is written to the stream after every Tp
* written to the stream. The delimiter is not copied, and thus must
* not be destroyed while this iterator is in use.
*
* @param __s Underlying ostream to write to.
* @param __c CharT delimiter string to insert.
*/
ostream_iterator(ostream_type& __s, const _CharT* __c)
: _M_stream(&__s), _M_string(__c) { }
/// Copy constructor.
ostream_iterator(const ostream_iterator& __obj)
: _M_stream(__obj._M_stream), _M_string(__obj._M_string) { }
/// Writes @a value to underlying ostream using operator<<. If
/// constructed with delimiter string, writes delimiter to ostream.
ostream_iterator&
operator=(const _Tp& __value)
{
__glibcxx_requires_cond(_M_stream != 0,
_M_message(__gnu_debug::__msg_output_ostream)
._M_iterator(*this));
*_M_stream << __value;
if (_M_string) *_M_stream << _M_string;
return *this;
}
ostream_iterator&
operator*()
{ return *this; }
ostream_iterator&
operator++()
{ return *this; }
ostream_iterator&
operator++(int)
{ return *this; }
};
// @} group iterators
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/bits/uses_allocator.h 0000644 00000014575 15201526705 0011433 0 ustar 00 // Uses-allocator Construction -*- C++ -*-
// Copyright (C) 2010-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#ifndef _USES_ALLOCATOR_H
#define _USES_ALLOCATOR_H 1
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
#include <type_traits>
#include <bits/move.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
struct __erased_type { };
template<typename _Alloc, typename _Tp>
using __is_erased_or_convertible
= __or_<is_same<_Tp, __erased_type>, is_convertible<_Alloc, _Tp>>;
/// [allocator.tag]
struct allocator_arg_t { explicit allocator_arg_t() = default; };
_GLIBCXX17_INLINE constexpr allocator_arg_t allocator_arg =
allocator_arg_t();
template<typename _Tp, typename _Alloc, typename = __void_t<>>
struct __uses_allocator_helper
: false_type { };
template<typename _Tp, typename _Alloc>
struct __uses_allocator_helper<_Tp, _Alloc,
__void_t<typename _Tp::allocator_type>>
: __is_erased_or_convertible<_Alloc, typename _Tp::allocator_type>::type
{ };
/// [allocator.uses.trait]
template<typename _Tp, typename _Alloc>
struct uses_allocator
: __uses_allocator_helper<_Tp, _Alloc>::type
{ };
struct __uses_alloc_base { };
struct __uses_alloc0 : __uses_alloc_base
{
struct _Sink { void operator=(const void*) { } } _M_a;
};
template<typename _Alloc>
struct __uses_alloc1 : __uses_alloc_base { const _Alloc* _M_a; };
template<typename _Alloc>
struct __uses_alloc2 : __uses_alloc_base { const _Alloc* _M_a; };
template<bool, typename _Tp, typename _Alloc, typename... _Args>
struct __uses_alloc;
template<typename _Tp, typename _Alloc, typename... _Args>
struct __uses_alloc<true, _Tp, _Alloc, _Args...>
: conditional<
is_constructible<_Tp, allocator_arg_t, const _Alloc&, _Args...>::value,
__uses_alloc1<_Alloc>,
__uses_alloc2<_Alloc>>::type
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2586. Wrong value category used in scoped_allocator_adaptor::construct
static_assert(__or_<
is_constructible<_Tp, allocator_arg_t, const _Alloc&, _Args...>,
is_constructible<_Tp, _Args..., const _Alloc&>>::value,
"construction with an allocator must be possible"
" if uses_allocator is true");
};
template<typename _Tp, typename _Alloc, typename... _Args>
struct __uses_alloc<false, _Tp, _Alloc, _Args...>
: __uses_alloc0 { };
template<typename _Tp, typename _Alloc, typename... _Args>
using __uses_alloc_t =
__uses_alloc<uses_allocator<_Tp, _Alloc>::value, _Tp, _Alloc, _Args...>;
template<typename _Tp, typename _Alloc, typename... _Args>
inline __uses_alloc_t<_Tp, _Alloc, _Args...>
__use_alloc(const _Alloc& __a)
{
__uses_alloc_t<_Tp, _Alloc, _Args...> __ret;
__ret._M_a = std::__addressof(__a);
return __ret;
}
template<typename _Tp, typename _Alloc, typename... _Args>
void
__use_alloc(const _Alloc&&) = delete;
#if __cplusplus > 201402L
template <typename _Tp, typename _Alloc>
inline constexpr bool uses_allocator_v =
uses_allocator<_Tp, _Alloc>::value;
#endif // C++17
template<template<typename...> class _Predicate,
typename _Tp, typename _Alloc, typename... _Args>
struct __is_uses_allocator_predicate
: conditional<uses_allocator<_Tp, _Alloc>::value,
__or_<_Predicate<_Tp, allocator_arg_t, _Alloc, _Args...>,
_Predicate<_Tp, _Args..., _Alloc>>,
_Predicate<_Tp, _Args...>>::type { };
template<typename _Tp, typename _Alloc, typename... _Args>
struct __is_uses_allocator_constructible
: __is_uses_allocator_predicate<is_constructible, _Tp, _Alloc, _Args...>
{ };
#if __cplusplus >= 201402L
template<typename _Tp, typename _Alloc, typename... _Args>
_GLIBCXX17_INLINE constexpr bool __is_uses_allocator_constructible_v =
__is_uses_allocator_constructible<_Tp, _Alloc, _Args...>::value;
#endif // C++14
template<typename _Tp, typename _Alloc, typename... _Args>
struct __is_nothrow_uses_allocator_constructible
: __is_uses_allocator_predicate<is_nothrow_constructible,
_Tp, _Alloc, _Args...>
{ };
#if __cplusplus >= 201402L
template<typename _Tp, typename _Alloc, typename... _Args>
_GLIBCXX17_INLINE constexpr bool
__is_nothrow_uses_allocator_constructible_v =
__is_nothrow_uses_allocator_constructible<_Tp, _Alloc, _Args...>::value;
#endif // C++14
template<typename _Tp, typename... _Args>
void __uses_allocator_construct_impl(__uses_alloc0 __a, _Tp* __ptr,
_Args&&... __args)
{ ::new ((void*)__ptr) _Tp(std::forward<_Args>(__args)...); }
template<typename _Tp, typename _Alloc, typename... _Args>
void __uses_allocator_construct_impl(__uses_alloc1<_Alloc> __a, _Tp* __ptr,
_Args&&... __args)
{
::new ((void*)__ptr) _Tp(allocator_arg, *__a._M_a,
std::forward<_Args>(__args)...);
}
template<typename _Tp, typename _Alloc, typename... _Args>
void __uses_allocator_construct_impl(__uses_alloc2<_Alloc> __a, _Tp* __ptr,
_Args&&... __args)
{ ::new ((void*)__ptr) _Tp(std::forward<_Args>(__args)..., *__a._M_a); }
template<typename _Tp, typename _Alloc, typename... _Args>
void __uses_allocator_construct(const _Alloc& __a, _Tp* __ptr,
_Args&&... __args)
{
__uses_allocator_construct_impl(__use_alloc<_Tp, _Alloc, _Args...>(__a),
__ptr, std::forward<_Args>(__args)...);
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif
#endif
c++/8/bits/regex_compiler.h 0000644 00000043202 15201526705 0011405 0 ustar 00 // class template regex -*- C++ -*-
// Copyright (C) 2010-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/**
* @file bits/regex_compiler.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{regex}
*/
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_BEGIN_NAMESPACE_CXX11
template<typename>
class regex_traits;
_GLIBCXX_END_NAMESPACE_CXX11
namespace __detail
{
/**
* @addtogroup regex-detail
* @{
*/
template<typename, bool, bool>
struct _BracketMatcher;
/**
* @brief Builds an NFA from an input iterator range.
*
* The %_TraitsT type should fulfill requirements [28.3].
*/
template<typename _TraitsT>
class _Compiler
{
public:
typedef typename _TraitsT::char_type _CharT;
typedef const _CharT* _IterT;
typedef _NFA<_TraitsT> _RegexT;
typedef regex_constants::syntax_option_type _FlagT;
_Compiler(_IterT __b, _IterT __e,
const typename _TraitsT::locale_type& __traits, _FlagT __flags);
shared_ptr<const _RegexT>
_M_get_nfa()
{ return std::move(_M_nfa); }
private:
typedef _Scanner<_CharT> _ScannerT;
typedef typename _TraitsT::string_type _StringT;
typedef typename _ScannerT::_TokenT _TokenT;
typedef _StateSeq<_TraitsT> _StateSeqT;
typedef std::stack<_StateSeqT> _StackT;
typedef std::ctype<_CharT> _CtypeT;
// accepts a specific token or returns false.
bool
_M_match_token(_TokenT __token);
void
_M_disjunction();
void
_M_alternative();
bool
_M_term();
bool
_M_assertion();
bool
_M_quantifier();
bool
_M_atom();
bool
_M_bracket_expression();
template<bool __icase, bool __collate>
void
_M_insert_any_matcher_ecma();
template<bool __icase, bool __collate>
void
_M_insert_any_matcher_posix();
template<bool __icase, bool __collate>
void
_M_insert_char_matcher();
template<bool __icase, bool __collate>
void
_M_insert_character_class_matcher();
template<bool __icase, bool __collate>
void
_M_insert_bracket_matcher(bool __neg);
// Cache of the last atom seen in a bracketed range expression.
struct _BracketState
{
enum class _Type : char { _None, _Char, _Class } _M_type = _Type::_None;
_CharT _M_char;
void
set(_CharT __c) noexcept { _M_type = _Type::_Char; _M_char = __c; }
_GLIBCXX_NODISCARD _CharT
get() const noexcept { return _M_char; }
void
reset(_Type __t = _Type::_None) noexcept { _M_type = __t; }
explicit operator bool() const noexcept
{ return _M_type != _Type::_None; }
// Previous token was a single character.
_GLIBCXX_NODISCARD bool
_M_is_char() const noexcept { return _M_type == _Type::_Char; }
// Previous token was a character class, equivalent class,
// collating symbol etc.
_GLIBCXX_NODISCARD bool
_M_is_class() const noexcept { return _M_type == _Type::_Class; }
};
template<bool __icase, bool __collate>
using _BracketMatcher
= std::__detail::_BracketMatcher<_TraitsT, __icase, __collate>;
// Returns true if successfully parsed one term and should continue
// compiling a bracket expression.
// Returns false if the compiler should move on.
template<bool __icase, bool __collate>
bool
_M_expression_term(_BracketState& __last_char,
_BracketMatcher<__icase, __collate>& __matcher);
int
_M_cur_int_value(int __radix);
bool
_M_try_char();
_StateSeqT
_M_pop()
{
auto ret = _M_stack.top();
_M_stack.pop();
return ret;
}
_FlagT _M_flags;
_ScannerT _M_scanner;
shared_ptr<_RegexT> _M_nfa;
_StringT _M_value;
_StackT _M_stack;
const _TraitsT& _M_traits;
const _CtypeT& _M_ctype;
};
template<typename _Tp>
struct __has_contiguous_iter : std::false_type { };
template<typename _Ch, typename _Tr, typename _Alloc>
struct __has_contiguous_iter<std::basic_string<_Ch, _Tr, _Alloc>>
: std::true_type
{ };
template<typename _Tp, typename _Alloc>
struct __has_contiguous_iter<std::vector<_Tp, _Alloc>>
: std::true_type
{ };
template<typename _Tp>
struct __is_contiguous_normal_iter : std::false_type { };
template<typename _CharT>
struct __is_contiguous_normal_iter<_CharT*> : std::true_type { };
template<typename _Tp, typename _Cont>
struct
__is_contiguous_normal_iter<__gnu_cxx::__normal_iterator<_Tp, _Cont>>
: __has_contiguous_iter<_Cont>::type
{ };
template<typename _Iter, typename _TraitsT>
using __enable_if_contiguous_normal_iter
= typename enable_if< __is_contiguous_normal_iter<_Iter>::value,
std::shared_ptr<const _NFA<_TraitsT>> >::type;
template<typename _Iter, typename _TraitsT>
using __disable_if_contiguous_normal_iter
= typename enable_if< !__is_contiguous_normal_iter<_Iter>::value,
std::shared_ptr<const _NFA<_TraitsT>> >::type;
template<typename _TraitsT, typename _FwdIter>
inline __enable_if_contiguous_normal_iter<_FwdIter, _TraitsT>
__compile_nfa(_FwdIter __first, _FwdIter __last,
const typename _TraitsT::locale_type& __loc,
regex_constants::syntax_option_type __flags)
{
size_t __len = __last - __first;
const auto* __cfirst = __len ? std::__addressof(*__first) : nullptr;
using _Cmplr = _Compiler<_TraitsT>;
return _Cmplr(__cfirst, __cfirst + __len, __loc, __flags)._M_get_nfa();
}
template<typename _TraitsT, typename _FwdIter>
inline __disable_if_contiguous_normal_iter<_FwdIter, _TraitsT>
__compile_nfa(_FwdIter __first, _FwdIter __last,
const typename _TraitsT::locale_type& __loc,
regex_constants::syntax_option_type __flags)
{
const basic_string<typename _TraitsT::char_type> __str(__first, __last);
return __compile_nfa<_TraitsT>(__str.data(), __str.data() + __str.size(),
__loc, __flags);
}
// [28.13.14]
template<typename _TraitsT, bool __icase, bool __collate>
class _RegexTranslatorBase
{
public:
typedef typename _TraitsT::char_type _CharT;
typedef typename _TraitsT::string_type _StringT;
typedef _StringT _StrTransT;
explicit
_RegexTranslatorBase(const _TraitsT& __traits)
: _M_traits(__traits)
{ }
_CharT
_M_translate(_CharT __ch) const
{
if (__icase)
return _M_traits.translate_nocase(__ch);
else if (__collate)
return _M_traits.translate(__ch);
else
return __ch;
}
_StrTransT
_M_transform(_CharT __ch) const
{
_StrTransT __str(1, __ch);
return _M_traits.transform(__str.begin(), __str.end());
}
// See LWG 523. It's not efficiently implementable when _TraitsT is not
// std::regex_traits<>, and __collate is true. See specializations for
// implementations of other cases.
bool
_M_match_range(const _StrTransT& __first, const _StrTransT& __last,
const _StrTransT& __s) const
{ return __first <= __s && __s <= __last; }
protected:
bool _M_in_range_icase(_CharT __first, _CharT __last, _CharT __ch) const
{
typedef std::ctype<_CharT> __ctype_type;
const auto& __fctyp = use_facet<__ctype_type>(this->_M_traits.getloc());
auto __lower = __fctyp.tolower(__ch);
auto __upper = __fctyp.toupper(__ch);
return (__first <= __lower && __lower <= __last)
|| (__first <= __upper && __upper <= __last);
}
const _TraitsT& _M_traits;
};
template<typename _TraitsT, bool __icase, bool __collate>
class _RegexTranslator
: public _RegexTranslatorBase<_TraitsT, __icase, __collate>
{
public:
typedef _RegexTranslatorBase<_TraitsT, __icase, __collate> _Base;
using _Base::_Base;
};
template<typename _TraitsT, bool __icase>
class _RegexTranslator<_TraitsT, __icase, false>
: public _RegexTranslatorBase<_TraitsT, __icase, false>
{
public:
typedef _RegexTranslatorBase<_TraitsT, __icase, false> _Base;
typedef typename _Base::_CharT _CharT;
typedef _CharT _StrTransT;
using _Base::_Base;
_StrTransT
_M_transform(_CharT __ch) const
{ return __ch; }
bool
_M_match_range(_CharT __first, _CharT __last, _CharT __ch) const
{
if (!__icase)
return __first <= __ch && __ch <= __last;
return this->_M_in_range_icase(__first, __last, __ch);
}
};
template<typename _CharType>
class _RegexTranslator<std::regex_traits<_CharType>, true, true>
: public _RegexTranslatorBase<std::regex_traits<_CharType>, true, true>
{
public:
typedef _RegexTranslatorBase<std::regex_traits<_CharType>, true, true>
_Base;
typedef typename _Base::_CharT _CharT;
typedef typename _Base::_StrTransT _StrTransT;
using _Base::_Base;
bool
_M_match_range(const _StrTransT& __first, const _StrTransT& __last,
const _StrTransT& __str) const
{
__glibcxx_assert(__first.size() == 1);
__glibcxx_assert(__last.size() == 1);
__glibcxx_assert(__str.size() == 1);
return this->_M_in_range_icase(__first[0], __last[0], __str[0]);
}
};
template<typename _TraitsT>
class _RegexTranslator<_TraitsT, false, false>
{
public:
typedef typename _TraitsT::char_type _CharT;
typedef _CharT _StrTransT;
explicit
_RegexTranslator(const _TraitsT&)
{ }
_CharT
_M_translate(_CharT __ch) const
{ return __ch; }
_StrTransT
_M_transform(_CharT __ch) const
{ return __ch; }
bool
_M_match_range(_CharT __first, _CharT __last, _CharT __ch) const
{ return __first <= __ch && __ch <= __last; }
};
template<typename _TraitsT, bool __is_ecma, bool __icase, bool __collate>
struct _AnyMatcher;
template<typename _TraitsT, bool __icase, bool __collate>
struct _AnyMatcher<_TraitsT, false, __icase, __collate>
{
typedef _RegexTranslator<_TraitsT, __icase, __collate> _TransT;
typedef typename _TransT::_CharT _CharT;
explicit
_AnyMatcher(const _TraitsT& __traits)
: _M_translator(__traits)
{ }
bool
operator()(_CharT __ch) const
{
static auto __nul = _M_translator._M_translate('\0');
return _M_translator._M_translate(__ch) != __nul;
}
_TransT _M_translator;
};
template<typename _TraitsT, bool __icase, bool __collate>
struct _AnyMatcher<_TraitsT, true, __icase, __collate>
{
typedef _RegexTranslator<_TraitsT, __icase, __collate> _TransT;
typedef typename _TransT::_CharT _CharT;
explicit
_AnyMatcher(const _TraitsT& __traits)
: _M_translator(__traits)
{ }
bool
operator()(_CharT __ch) const
{ return _M_apply(__ch, typename is_same<_CharT, char>::type()); }
bool
_M_apply(_CharT __ch, true_type) const
{
auto __c = _M_translator._M_translate(__ch);
auto __n = _M_translator._M_translate('\n');
auto __r = _M_translator._M_translate('\r');
return __c != __n && __c != __r;
}
bool
_M_apply(_CharT __ch, false_type) const
{
auto __c = _M_translator._M_translate(__ch);
auto __n = _M_translator._M_translate('\n');
auto __r = _M_translator._M_translate('\r');
auto __u2028 = _M_translator._M_translate(u'\u2028');
auto __u2029 = _M_translator._M_translate(u'\u2029');
return __c != __n && __c != __r && __c != __u2028 && __c != __u2029;
}
_TransT _M_translator;
};
template<typename _TraitsT, bool __icase, bool __collate>
struct _CharMatcher
{
typedef _RegexTranslator<_TraitsT, __icase, __collate> _TransT;
typedef typename _TransT::_CharT _CharT;
_CharMatcher(_CharT __ch, const _TraitsT& __traits)
: _M_translator(__traits), _M_ch(_M_translator._M_translate(__ch))
{ }
bool
operator()(_CharT __ch) const
{ return _M_ch == _M_translator._M_translate(__ch); }
_TransT _M_translator;
_CharT _M_ch;
};
/// Matches a character range (bracket expression)
template<typename _TraitsT, bool __icase, bool __collate>
struct _BracketMatcher
{
public:
typedef _RegexTranslator<_TraitsT, __icase, __collate> _TransT;
typedef typename _TransT::_CharT _CharT;
typedef typename _TransT::_StrTransT _StrTransT;
typedef typename _TraitsT::string_type _StringT;
typedef typename _TraitsT::char_class_type _CharClassT;
public:
_BracketMatcher(bool __is_non_matching,
const _TraitsT& __traits)
: _M_class_set(0), _M_translator(__traits), _M_traits(__traits),
_M_is_non_matching(__is_non_matching)
{ }
bool
operator()(_CharT __ch) const
{
_GLIBCXX_DEBUG_ASSERT(_M_is_ready);
return _M_apply(__ch, _UseCache());
}
void
_M_add_char(_CharT __c)
{
_M_char_set.push_back(_M_translator._M_translate(__c));
_GLIBCXX_DEBUG_ONLY(_M_is_ready = false);
}
_StringT
_M_add_collate_element(const _StringT& __s)
{
auto __st = _M_traits.lookup_collatename(__s.data(),
__s.data() + __s.size());
if (__st.empty())
__throw_regex_error(regex_constants::error_collate,
"Invalid collate element.");
_M_char_set.push_back(_M_translator._M_translate(__st[0]));
_GLIBCXX_DEBUG_ONLY(_M_is_ready = false);
return __st;
}
void
_M_add_equivalence_class(const _StringT& __s)
{
auto __st = _M_traits.lookup_collatename(__s.data(),
__s.data() + __s.size());
if (__st.empty())
__throw_regex_error(regex_constants::error_collate,
"Invalid equivalence class.");
__st = _M_traits.transform_primary(__st.data(),
__st.data() + __st.size());
_M_equiv_set.push_back(__st);
_GLIBCXX_DEBUG_ONLY(_M_is_ready = false);
}
// __neg should be true for \D, \S and \W only.
void
_M_add_character_class(const _StringT& __s, bool __neg)
{
auto __mask = _M_traits.lookup_classname(__s.data(),
__s.data() + __s.size(),
__icase);
if (__mask == 0)
__throw_regex_error(regex_constants::error_collate,
"Invalid character class.");
if (!__neg)
_M_class_set |= __mask;
else
_M_neg_class_set.push_back(__mask);
_GLIBCXX_DEBUG_ONLY(_M_is_ready = false);
}
void
_M_make_range(_CharT __l, _CharT __r)
{
if (__l > __r)
__throw_regex_error(regex_constants::error_range,
"Invalid range in bracket expression.");
_M_range_set.push_back(make_pair(_M_translator._M_transform(__l),
_M_translator._M_transform(__r)));
_GLIBCXX_DEBUG_ONLY(_M_is_ready = false);
}
void
_M_ready()
{
std::sort(_M_char_set.begin(), _M_char_set.end());
auto __end = std::unique(_M_char_set.begin(), _M_char_set.end());
_M_char_set.erase(__end, _M_char_set.end());
_M_make_cache(_UseCache());
_GLIBCXX_DEBUG_ONLY(_M_is_ready = true);
}
private:
// Currently we only use the cache for char
typedef typename std::is_same<_CharT, char>::type _UseCache;
static constexpr size_t
_S_cache_size()
{
return 1ul << (sizeof(_CharT) * __CHAR_BIT__ * int(_UseCache::value));
}
struct _Dummy { };
typedef typename std::conditional<_UseCache::value,
std::bitset<_S_cache_size()>,
_Dummy>::type _CacheT;
typedef typename std::make_unsigned<_CharT>::type _UnsignedCharT;
bool
_M_apply(_CharT __ch, false_type) const;
bool
_M_apply(_CharT __ch, true_type) const
{ return _M_cache[static_cast<_UnsignedCharT>(__ch)]; }
void
_M_make_cache(true_type)
{
for (unsigned __i = 0; __i < _M_cache.size(); __i++)
_M_cache[__i] = _M_apply(static_cast<_CharT>(__i), false_type());
}
void
_M_make_cache(false_type)
{ }
private:
std::vector<_CharT> _M_char_set;
std::vector<_StringT> _M_equiv_set;
std::vector<pair<_StrTransT, _StrTransT>> _M_range_set;
std::vector<_CharClassT> _M_neg_class_set;
_CharClassT _M_class_set;
_TransT _M_translator;
const _TraitsT& _M_traits;
bool _M_is_non_matching;
_CacheT _M_cache;
#ifdef _GLIBCXX_DEBUG
bool _M_is_ready = false;
#endif
};
//@} regex-detail
} // namespace __detail
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#include <bits/regex_compiler.tcc>
c++/8/bits/regex_automaton.tcc 0000644 00000017236 15201526705 0012134 0 ustar 00 // class template regex -*- C++ -*-
// Copyright (C) 2013-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/**
* @file bits/regex_automaton.tcc
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{regex}
*/
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
namespace __detail
{
#ifdef _GLIBCXX_DEBUG
inline std::ostream&
_State_base::_M_print(std::ostream& ostr) const
{
switch (_M_opcode)
{
case _S_opcode_alternative:
case _S_opcode_repeat:
ostr << "alt next=" << _M_next << " alt=" << _M_alt;
break;
case _S_opcode_subexpr_begin:
ostr << "subexpr begin next=" << _M_next << " index=" << _M_subexpr;
break;
case _S_opcode_subexpr_end:
ostr << "subexpr end next=" << _M_next << " index=" << _M_subexpr;
break;
case _S_opcode_backref:
ostr << "backref next=" << _M_next << " index=" << _M_backref_index;
break;
case _S_opcode_match:
ostr << "match next=" << _M_next;
break;
case _S_opcode_accept:
ostr << "accept next=" << _M_next;
break;
default:
ostr << "unknown next=" << _M_next;
break;
}
return ostr;
}
// Prints graphviz dot commands for state.
inline std::ostream&
_State_base::_M_dot(std::ostream& __ostr, _StateIdT __id) const
{
switch (_M_opcode)
{
case _S_opcode_alternative:
case _S_opcode_repeat:
__ostr << __id << " [label=\"" << __id << "\\nALT\"];\n"
<< __id << " -> " << _M_next
<< " [label=\"next\", tailport=\"s\"];\n"
<< __id << " -> " << _M_alt
<< " [label=\"alt\", tailport=\"n\"];\n";
break;
case _S_opcode_backref:
__ostr << __id << " [label=\"" << __id << "\\nBACKREF "
<< _M_subexpr << "\"];\n"
<< __id << " -> " << _M_next << " [label=\"<match>\"];\n";
break;
case _S_opcode_line_begin_assertion:
__ostr << __id << " [label=\"" << __id << "\\nLINE_BEGIN \"];\n"
<< __id << " -> " << _M_next << " [label=\"epsilon\"];\n";
break;
case _S_opcode_line_end_assertion:
__ostr << __id << " [label=\"" << __id << "\\nLINE_END \"];\n"
<< __id << " -> " << _M_next << " [label=\"epsilon\"];\n";
break;
case _S_opcode_word_boundary:
__ostr << __id << " [label=\"" << __id << "\\nWORD_BOUNDRY "
<< _M_neg << "\"];\n"
<< __id << " -> " << _M_next << " [label=\"epsilon\"];\n";
break;
case _S_opcode_subexpr_lookahead:
__ostr << __id << " [label=\"" << __id << "\\nLOOK_AHEAD\"];\n"
<< __id << " -> " << _M_next
<< " [label=\"epsilon\", tailport=\"s\"];\n"
<< __id << " -> " << _M_alt
<< " [label=\"<assert>\", tailport=\"n\"];\n";
break;
case _S_opcode_subexpr_begin:
__ostr << __id << " [label=\"" << __id << "\\nSBEGIN "
<< _M_subexpr << "\"];\n"
<< __id << " -> " << _M_next << " [label=\"epsilon\"];\n";
break;
case _S_opcode_subexpr_end:
__ostr << __id << " [label=\"" << __id << "\\nSEND "
<< _M_subexpr << "\"];\n"
<< __id << " -> " << _M_next << " [label=\"epsilon\"];\n";
break;
case _S_opcode_dummy:
break;
case _S_opcode_match:
__ostr << __id << " [label=\"" << __id << "\\nMATCH\"];\n"
<< __id << " -> " << _M_next << " [label=\"<match>\"];\n";
break;
case _S_opcode_accept:
__ostr << __id << " [label=\"" << __id << "\\nACC\"];\n" ;
break;
default:
_GLIBCXX_DEBUG_ASSERT(false);
break;
}
return __ostr;
}
template<typename _TraitsT>
std::ostream&
_NFA<_TraitsT>::_M_dot(std::ostream& __ostr) const
{
__ostr << "digraph _Nfa {\n"
" rankdir=LR;\n";
for (size_t __i = 0; __i < this->size(); ++__i)
(*this)[__i]._M_dot(__ostr, __i);
__ostr << "}\n";
return __ostr;
}
#endif
template<typename _TraitsT>
_StateIdT
_NFA<_TraitsT>::_M_insert_backref(size_t __index)
{
if (this->_M_flags & regex_constants::__polynomial)
__throw_regex_error(regex_constants::error_complexity,
"Unexpected back-reference in polynomial mode.");
// To figure out whether a backref is valid, a stack is used to store
// unfinished sub-expressions. For example, when parsing
// "(a(b)(c\\1(d)))" at '\\1', _M_subexpr_count is 3, indicating that 3
// sub expressions are parsed or partially parsed(in the stack), aka,
// "(a..", "(b)" and "(c..").
// _M_paren_stack is {1, 3}, for incomplete "(a.." and "(c..". At this
// time, "\\2" is valid, but "\\1" and "\\3" are not.
if (__index >= _M_subexpr_count)
__throw_regex_error(
regex_constants::error_backref,
"Back-reference index exceeds current sub-expression count.");
for (auto __it : this->_M_paren_stack)
if (__index == __it)
__throw_regex_error(
regex_constants::error_backref,
"Back-reference referred to an opened sub-expression.");
this->_M_has_backref = true;
_StateT __tmp(_S_opcode_backref);
__tmp._M_backref_index = __index;
return _M_insert_state(std::move(__tmp));
}
template<typename _TraitsT>
void
_NFA<_TraitsT>::_M_eliminate_dummy()
{
for (auto& __it : *this)
{
while (__it._M_next >= 0 && (*this)[__it._M_next]._M_opcode()
== _S_opcode_dummy)
__it._M_next = (*this)[__it._M_next]._M_next;
if (__it._M_has_alt())
while (__it._M_alt >= 0 && (*this)[__it._M_alt]._M_opcode()
== _S_opcode_dummy)
__it._M_alt = (*this)[__it._M_alt]._M_next;
}
}
// Just apply DFS on the sequence and re-link their links.
template<typename _TraitsT>
_StateSeq<_TraitsT>
_StateSeq<_TraitsT>::_M_clone()
{
std::map<_StateIdT, _StateIdT> __m;
std::stack<_StateIdT> __stack;
__stack.push(_M_start);
while (!__stack.empty())
{
auto __u = __stack.top();
__stack.pop();
auto __dup = _M_nfa[__u];
// _M_insert_state() never return -1
auto __id = _M_nfa._M_insert_state(std::move(__dup));
__m[__u] = __id;
if (__dup._M_has_alt())
if (__dup._M_alt != _S_invalid_state_id
&& __m.count(__dup._M_alt) == 0)
__stack.push(__dup._M_alt);
if (__u == _M_end)
continue;
if (__dup._M_next != _S_invalid_state_id
&& __m.count(__dup._M_next) == 0)
__stack.push(__dup._M_next);
}
for (auto __it : __m)
{
auto __v = __it.second;
auto& __ref = _M_nfa[__v];
if (__ref._M_next != _S_invalid_state_id)
{
__glibcxx_assert(__m.count(__ref._M_next) > 0);
__ref._M_next = __m[__ref._M_next];
}
if (__ref._M_has_alt())
if (__ref._M_alt != _S_invalid_state_id)
{
__glibcxx_assert(__m.count(__ref._M_alt) > 0);
__ref._M_alt = __m[__ref._M_alt];
}
}
return _StateSeq(_M_nfa, __m[_M_start], __m[_M_end]);
}
} // namespace __detail
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
c++/8/bits/hashtable_policy.h 0000644 00000204603 15201526705 0011717 0 ustar 00 // Internal policy header for unordered_set and unordered_map -*- C++ -*-
// Copyright (C) 2010-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/hashtable_policy.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly.
* @headername{unordered_map,unordered_set}
*/
#ifndef _HASHTABLE_POLICY_H
#define _HASHTABLE_POLICY_H 1
#include <tuple> // for std::tuple, std::forward_as_tuple
#include <cstdint> // for std::uint_fast64_t
#include <bits/stl_algobase.h> // for std::min.
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Key, typename _Value, typename _Alloc,
typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash,
typename _RehashPolicy, typename _Traits>
class _Hashtable;
namespace __detail
{
/**
* @defgroup hashtable-detail Base and Implementation Classes
* @ingroup unordered_associative_containers
* @{
*/
template<typename _Key, typename _Value,
typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _Traits>
struct _Hashtable_base;
// Helper function: return distance(first, last) for forward
// iterators, or 0/1 for input iterators.
template<class _Iterator>
inline typename std::iterator_traits<_Iterator>::difference_type
__distance_fw(_Iterator __first, _Iterator __last,
std::input_iterator_tag)
{ return __first != __last ? 1 : 0; }
template<class _Iterator>
inline typename std::iterator_traits<_Iterator>::difference_type
__distance_fw(_Iterator __first, _Iterator __last,
std::forward_iterator_tag)
{ return std::distance(__first, __last); }
template<class _Iterator>
inline typename std::iterator_traits<_Iterator>::difference_type
__distance_fw(_Iterator __first, _Iterator __last)
{ return __distance_fw(__first, __last,
std::__iterator_category(__first)); }
struct _Identity
{
template<typename _Tp>
_Tp&&
operator()(_Tp&& __x) const
{ return std::forward<_Tp>(__x); }
};
struct _Select1st
{
template<typename _Tp>
auto
operator()(_Tp&& __x) const
-> decltype(std::get<0>(std::forward<_Tp>(__x)))
{ return std::get<0>(std::forward<_Tp>(__x)); }
};
template<typename _NodeAlloc>
struct _Hashtable_alloc;
// Functor recycling a pool of nodes and using allocation once the pool is
// empty.
template<typename _NodeAlloc>
struct _ReuseOrAllocNode
{
private:
using __node_alloc_type = _NodeAlloc;
using __hashtable_alloc = _Hashtable_alloc<__node_alloc_type>;
using __node_alloc_traits =
typename __hashtable_alloc::__node_alloc_traits;
using __node_type = typename __hashtable_alloc::__node_type;
public:
_ReuseOrAllocNode(__node_type* __nodes, __hashtable_alloc& __h)
: _M_nodes(__nodes), _M_h(__h) { }
_ReuseOrAllocNode(const _ReuseOrAllocNode&) = delete;
~_ReuseOrAllocNode()
{ _M_h._M_deallocate_nodes(_M_nodes); }
template<typename _Arg>
__node_type*
operator()(_Arg&& __arg) const
{
if (_M_nodes)
{
__node_type* __node = _M_nodes;
_M_nodes = _M_nodes->_M_next();
__node->_M_nxt = nullptr;
auto& __a = _M_h._M_node_allocator();
__node_alloc_traits::destroy(__a, __node->_M_valptr());
__try
{
__node_alloc_traits::construct(__a, __node->_M_valptr(),
std::forward<_Arg>(__arg));
}
__catch(...)
{
__node->~__node_type();
__node_alloc_traits::deallocate(__a, __node, 1);
__throw_exception_again;
}
return __node;
}
return _M_h._M_allocate_node(std::forward<_Arg>(__arg));
}
private:
mutable __node_type* _M_nodes;
__hashtable_alloc& _M_h;
};
// Functor similar to the previous one but without any pool of nodes to
// recycle.
template<typename _NodeAlloc>
struct _AllocNode
{
private:
using __hashtable_alloc = _Hashtable_alloc<_NodeAlloc>;
using __node_type = typename __hashtable_alloc::__node_type;
public:
_AllocNode(__hashtable_alloc& __h)
: _M_h(__h) { }
template<typename _Arg>
__node_type*
operator()(_Arg&& __arg) const
{ return _M_h._M_allocate_node(std::forward<_Arg>(__arg)); }
private:
__hashtable_alloc& _M_h;
};
// Auxiliary types used for all instantiations of _Hashtable nodes
// and iterators.
/**
* struct _Hashtable_traits
*
* Important traits for hash tables.
*
* @tparam _Cache_hash_code Boolean value. True if the value of
* the hash function is stored along with the value. This is a
* time-space tradeoff. Storing it may improve lookup speed by
* reducing the number of times we need to call the _Equal
* function.
*
* @tparam _Constant_iterators Boolean value. True if iterator and
* const_iterator are both constant iterator types. This is true
* for unordered_set and unordered_multiset, false for
* unordered_map and unordered_multimap.
*
* @tparam _Unique_keys Boolean value. True if the return value
* of _Hashtable::count(k) is always at most one, false if it may
* be an arbitrary number. This is true for unordered_set and
* unordered_map, false for unordered_multiset and
* unordered_multimap.
*/
template<bool _Cache_hash_code, bool _Constant_iterators, bool _Unique_keys>
struct _Hashtable_traits
{
using __hash_cached = __bool_constant<_Cache_hash_code>;
using __constant_iterators = __bool_constant<_Constant_iterators>;
using __unique_keys = __bool_constant<_Unique_keys>;
};
/**
* struct _Hash_node_base
*
* Nodes, used to wrap elements stored in the hash table. A policy
* template parameter of class template _Hashtable controls whether
* nodes also store a hash code. In some cases (e.g. strings) this
* may be a performance win.
*/
struct _Hash_node_base
{
_Hash_node_base* _M_nxt;
_Hash_node_base() noexcept : _M_nxt() { }
_Hash_node_base(_Hash_node_base* __next) noexcept : _M_nxt(__next) { }
};
/**
* struct _Hash_node_value_base
*
* Node type with the value to store.
*/
template<typename _Value>
struct _Hash_node_value_base : _Hash_node_base
{
typedef _Value value_type;
__gnu_cxx::__aligned_buffer<_Value> _M_storage;
_Value*
_M_valptr() noexcept
{ return _M_storage._M_ptr(); }
const _Value*
_M_valptr() const noexcept
{ return _M_storage._M_ptr(); }
_Value&
_M_v() noexcept
{ return *_M_valptr(); }
const _Value&
_M_v() const noexcept
{ return *_M_valptr(); }
};
/**
* Primary template struct _Hash_node.
*/
template<typename _Value, bool _Cache_hash_code>
struct _Hash_node;
/**
* Specialization for nodes with caches, struct _Hash_node.
*
* Base class is __detail::_Hash_node_value_base.
*/
template<typename _Value>
struct _Hash_node<_Value, true> : _Hash_node_value_base<_Value>
{
std::size_t _M_hash_code;
_Hash_node*
_M_next() const noexcept
{ return static_cast<_Hash_node*>(this->_M_nxt); }
};
/**
* Specialization for nodes without caches, struct _Hash_node.
*
* Base class is __detail::_Hash_node_value_base.
*/
template<typename _Value>
struct _Hash_node<_Value, false> : _Hash_node_value_base<_Value>
{
_Hash_node*
_M_next() const noexcept
{ return static_cast<_Hash_node*>(this->_M_nxt); }
};
/// Base class for node iterators.
template<typename _Value, bool _Cache_hash_code>
struct _Node_iterator_base
{
using __node_type = _Hash_node<_Value, _Cache_hash_code>;
__node_type* _M_cur;
_Node_iterator_base(__node_type* __p) noexcept
: _M_cur(__p) { }
void
_M_incr() noexcept
{ _M_cur = _M_cur->_M_next(); }
};
template<typename _Value, bool _Cache_hash_code>
inline bool
operator==(const _Node_iterator_base<_Value, _Cache_hash_code>& __x,
const _Node_iterator_base<_Value, _Cache_hash_code >& __y)
noexcept
{ return __x._M_cur == __y._M_cur; }
template<typename _Value, bool _Cache_hash_code>
inline bool
operator!=(const _Node_iterator_base<_Value, _Cache_hash_code>& __x,
const _Node_iterator_base<_Value, _Cache_hash_code>& __y)
noexcept
{ return __x._M_cur != __y._M_cur; }
/// Node iterators, used to iterate through all the hashtable.
template<typename _Value, bool __constant_iterators, bool __cache>
struct _Node_iterator
: public _Node_iterator_base<_Value, __cache>
{
private:
using __base_type = _Node_iterator_base<_Value, __cache>;
using __node_type = typename __base_type::__node_type;
public:
typedef _Value value_type;
typedef std::ptrdiff_t difference_type;
typedef std::forward_iterator_tag iterator_category;
using pointer = typename std::conditional<__constant_iterators,
const _Value*, _Value*>::type;
using reference = typename std::conditional<__constant_iterators,
const _Value&, _Value&>::type;
_Node_iterator() noexcept
: __base_type(0) { }
explicit
_Node_iterator(__node_type* __p) noexcept
: __base_type(__p) { }
reference
operator*() const noexcept
{ return this->_M_cur->_M_v(); }
pointer
operator->() const noexcept
{ return this->_M_cur->_M_valptr(); }
_Node_iterator&
operator++() noexcept
{
this->_M_incr();
return *this;
}
_Node_iterator
operator++(int) noexcept
{
_Node_iterator __tmp(*this);
this->_M_incr();
return __tmp;
}
};
/// Node const_iterators, used to iterate through all the hashtable.
template<typename _Value, bool __constant_iterators, bool __cache>
struct _Node_const_iterator
: public _Node_iterator_base<_Value, __cache>
{
private:
using __base_type = _Node_iterator_base<_Value, __cache>;
using __node_type = typename __base_type::__node_type;
public:
typedef _Value value_type;
typedef std::ptrdiff_t difference_type;
typedef std::forward_iterator_tag iterator_category;
typedef const _Value* pointer;
typedef const _Value& reference;
_Node_const_iterator() noexcept
: __base_type(0) { }
explicit
_Node_const_iterator(__node_type* __p) noexcept
: __base_type(__p) { }
_Node_const_iterator(const _Node_iterator<_Value, __constant_iterators,
__cache>& __x) noexcept
: __base_type(__x._M_cur) { }
reference
operator*() const noexcept
{ return this->_M_cur->_M_v(); }
pointer
operator->() const noexcept
{ return this->_M_cur->_M_valptr(); }
_Node_const_iterator&
operator++() noexcept
{
this->_M_incr();
return *this;
}
_Node_const_iterator
operator++(int) noexcept
{
_Node_const_iterator __tmp(*this);
this->_M_incr();
return __tmp;
}
};
// Many of class template _Hashtable's template parameters are policy
// classes. These are defaults for the policies.
/// Default range hashing function: use division to fold a large number
/// into the range [0, N).
struct _Mod_range_hashing
{
typedef std::size_t first_argument_type;
typedef std::size_t second_argument_type;
typedef std::size_t result_type;
result_type
operator()(first_argument_type __num,
second_argument_type __den) const noexcept
{ return __num % __den; }
};
/// Default ranged hash function H. In principle it should be a
/// function object composed from objects of type H1 and H2 such that
/// h(k, N) = h2(h1(k), N), but that would mean making extra copies of
/// h1 and h2. So instead we'll just use a tag to tell class template
/// hashtable to do that composition.
struct _Default_ranged_hash { };
/// Default value for rehash policy. Bucket size is (usually) the
/// smallest prime that keeps the load factor small enough.
struct _Prime_rehash_policy
{
using __has_load_factor = std::true_type;
_Prime_rehash_policy(float __z = 1.0) noexcept
: _M_max_load_factor(__z), _M_next_resize(0) { }
float
max_load_factor() const noexcept
{ return _M_max_load_factor; }
// Return a bucket size no smaller than n.
std::size_t
_M_next_bkt(std::size_t __n) const;
// Return a bucket count appropriate for n elements
std::size_t
_M_bkt_for_elements(std::size_t __n) const
{ return __builtin_ceil(__n / (long double)_M_max_load_factor); }
// __n_bkt is current bucket count, __n_elt is current element count,
// and __n_ins is number of elements to be inserted. Do we need to
// increase bucket count? If so, return make_pair(true, n), where n
// is the new bucket count. If not, return make_pair(false, 0).
std::pair<bool, std::size_t>
_M_need_rehash(std::size_t __n_bkt, std::size_t __n_elt,
std::size_t __n_ins) const;
typedef std::size_t _State;
_State
_M_state() const
{ return _M_next_resize; }
void
_M_reset() noexcept
{ _M_next_resize = 0; }
void
_M_reset(_State __state)
{ _M_next_resize = __state; }
static const std::size_t _S_growth_factor = 2;
float _M_max_load_factor;
mutable std::size_t _M_next_resize;
};
/// Range hashing function assuming that second arg is a power of 2.
struct _Mask_range_hashing
{
typedef std::size_t first_argument_type;
typedef std::size_t second_argument_type;
typedef std::size_t result_type;
result_type
operator()(first_argument_type __num,
second_argument_type __den) const noexcept
{ return __num & (__den - 1); }
};
/// Compute closest power of 2.
_GLIBCXX14_CONSTEXPR
inline std::size_t
__clp2(std::size_t __n) noexcept
{
#if __SIZEOF_SIZE_T__ >= 8
std::uint_fast64_t __x = __n;
#else
std::uint_fast32_t __x = __n;
#endif
// Algorithm from Hacker's Delight, Figure 3-3.
__x = __x - 1;
__x = __x | (__x >> 1);
__x = __x | (__x >> 2);
__x = __x | (__x >> 4);
__x = __x | (__x >> 8);
__x = __x | (__x >>16);
#if __SIZEOF_SIZE_T__ >= 8
__x = __x | (__x >>32);
#endif
return __x + 1;
}
/// Rehash policy providing power of 2 bucket numbers. Avoids modulo
/// operations.
struct _Power2_rehash_policy
{
using __has_load_factor = std::true_type;
_Power2_rehash_policy(float __z = 1.0) noexcept
: _M_max_load_factor(__z), _M_next_resize(0) { }
float
max_load_factor() const noexcept
{ return _M_max_load_factor; }
// Return a bucket size no smaller than n (as long as n is not above the
// highest power of 2).
std::size_t
_M_next_bkt(std::size_t __n) noexcept
{
const auto __max_width = std::min<size_t>(sizeof(size_t), 8);
const auto __max_bkt = size_t(1) << (__max_width * __CHAR_BIT__ - 1);
std::size_t __res = __clp2(__n);
if (__res == __n)
__res <<= 1;
if (__res == 0)
__res = __max_bkt;
if (__res == __max_bkt)
// Set next resize to the max value so that we never try to rehash again
// as we already reach the biggest possible bucket number.
// Note that it might result in max_load_factor not being respected.
_M_next_resize = std::size_t(-1);
else
_M_next_resize
= __builtin_ceil(__res * (long double)_M_max_load_factor);
return __res;
}
// Return a bucket count appropriate for n elements
std::size_t
_M_bkt_for_elements(std::size_t __n) const noexcept
{ return __builtin_ceil(__n / (long double)_M_max_load_factor); }
// __n_bkt is current bucket count, __n_elt is current element count,
// and __n_ins is number of elements to be inserted. Do we need to
// increase bucket count? If so, return make_pair(true, n), where n
// is the new bucket count. If not, return make_pair(false, 0).
std::pair<bool, std::size_t>
_M_need_rehash(std::size_t __n_bkt, std::size_t __n_elt,
std::size_t __n_ins) noexcept
{
if (__n_elt + __n_ins >= _M_next_resize)
{
long double __min_bkts = (__n_elt + __n_ins)
/ (long double)_M_max_load_factor;
if (__min_bkts >= __n_bkt)
return std::make_pair(true,
_M_next_bkt(std::max<std::size_t>(__builtin_floor(__min_bkts) + 1,
__n_bkt * _S_growth_factor)));
_M_next_resize
= __builtin_floor(__n_bkt * (long double)_M_max_load_factor);
return std::make_pair(false, 0);
}
else
return std::make_pair(false, 0);
}
typedef std::size_t _State;
_State
_M_state() const noexcept
{ return _M_next_resize; }
void
_M_reset() noexcept
{ _M_next_resize = 0; }
void
_M_reset(_State __state) noexcept
{ _M_next_resize = __state; }
static const std::size_t _S_growth_factor = 2;
float _M_max_load_factor;
std::size_t _M_next_resize;
};
// Base classes for std::_Hashtable. We define these base classes
// because in some cases we want to do different things depending on
// the value of a policy class. In some cases the policy class
// affects which member functions and nested typedefs are defined;
// we handle that by specializing base class templates. Several of
// the base class templates need to access other members of class
// template _Hashtable, so we use a variant of the "Curiously
// Recurring Template Pattern" (CRTP) technique.
/**
* Primary class template _Map_base.
*
* If the hashtable has a value type of the form pair<T1, T2> and a
* key extraction policy (_ExtractKey) that returns the first part
* of the pair, the hashtable gets a mapped_type typedef. If it
* satisfies those criteria and also has unique keys, then it also
* gets an operator[].
*/
template<typename _Key, typename _Value, typename _Alloc,
typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash,
typename _RehashPolicy, typename _Traits,
bool _Unique_keys = _Traits::__unique_keys::value>
struct _Map_base { };
/// Partial specialization, __unique_keys set to false.
template<typename _Key, typename _Pair, typename _Alloc, typename _Equal,
typename _H1, typename _H2, typename _Hash,
typename _RehashPolicy, typename _Traits>
struct _Map_base<_Key, _Pair, _Alloc, _Select1st, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits, false>
{
using mapped_type = typename std::tuple_element<1, _Pair>::type;
};
/// Partial specialization, __unique_keys set to true.
template<typename _Key, typename _Pair, typename _Alloc, typename _Equal,
typename _H1, typename _H2, typename _Hash,
typename _RehashPolicy, typename _Traits>
struct _Map_base<_Key, _Pair, _Alloc, _Select1st, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits, true>
{
private:
using __hashtable_base = __detail::_Hashtable_base<_Key, _Pair,
_Select1st,
_Equal, _H1, _H2, _Hash,
_Traits>;
using __hashtable = _Hashtable<_Key, _Pair, _Alloc,
_Select1st, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>;
using __hash_code = typename __hashtable_base::__hash_code;
using __node_type = typename __hashtable_base::__node_type;
public:
using key_type = typename __hashtable_base::key_type;
using iterator = typename __hashtable_base::iterator;
using mapped_type = typename std::tuple_element<1, _Pair>::type;
mapped_type&
operator[](const key_type& __k);
mapped_type&
operator[](key_type&& __k);
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 761. unordered_map needs an at() member function.
mapped_type&
at(const key_type& __k);
const mapped_type&
at(const key_type& __k) const;
};
template<typename _Key, typename _Pair, typename _Alloc, typename _Equal,
typename _H1, typename _H2, typename _Hash,
typename _RehashPolicy, typename _Traits>
auto
_Map_base<_Key, _Pair, _Alloc, _Select1st, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits, true>::
operator[](const key_type& __k)
-> mapped_type&
{
__hashtable* __h = static_cast<__hashtable*>(this);
__hash_code __code = __h->_M_hash_code(__k);
std::size_t __n = __h->_M_bucket_index(__k, __code);
__node_type* __p = __h->_M_find_node(__n, __k, __code);
if (!__p)
{
__p = __h->_M_allocate_node(std::piecewise_construct,
std::tuple<const key_type&>(__k),
std::tuple<>());
return __h->_M_insert_unique_node(__n, __code, __p)->second;
}
return __p->_M_v().second;
}
template<typename _Key, typename _Pair, typename _Alloc, typename _Equal,
typename _H1, typename _H2, typename _Hash,
typename _RehashPolicy, typename _Traits>
auto
_Map_base<_Key, _Pair, _Alloc, _Select1st, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits, true>::
operator[](key_type&& __k)
-> mapped_type&
{
__hashtable* __h = static_cast<__hashtable*>(this);
__hash_code __code = __h->_M_hash_code(__k);
std::size_t __n = __h->_M_bucket_index(__k, __code);
__node_type* __p = __h->_M_find_node(__n, __k, __code);
if (!__p)
{
__p = __h->_M_allocate_node(std::piecewise_construct,
std::forward_as_tuple(std::move(__k)),
std::tuple<>());
return __h->_M_insert_unique_node(__n, __code, __p)->second;
}
return __p->_M_v().second;
}
template<typename _Key, typename _Pair, typename _Alloc, typename _Equal,
typename _H1, typename _H2, typename _Hash,
typename _RehashPolicy, typename _Traits>
auto
_Map_base<_Key, _Pair, _Alloc, _Select1st, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits, true>::
at(const key_type& __k)
-> mapped_type&
{
__hashtable* __h = static_cast<__hashtable*>(this);
__hash_code __code = __h->_M_hash_code(__k);
std::size_t __n = __h->_M_bucket_index(__k, __code);
__node_type* __p = __h->_M_find_node(__n, __k, __code);
if (!__p)
__throw_out_of_range(__N("_Map_base::at"));
return __p->_M_v().second;
}
template<typename _Key, typename _Pair, typename _Alloc, typename _Equal,
typename _H1, typename _H2, typename _Hash,
typename _RehashPolicy, typename _Traits>
auto
_Map_base<_Key, _Pair, _Alloc, _Select1st, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits, true>::
at(const key_type& __k) const
-> const mapped_type&
{
const __hashtable* __h = static_cast<const __hashtable*>(this);
__hash_code __code = __h->_M_hash_code(__k);
std::size_t __n = __h->_M_bucket_index(__k, __code);
__node_type* __p = __h->_M_find_node(__n, __k, __code);
if (!__p)
__throw_out_of_range(__N("_Map_base::at"));
return __p->_M_v().second;
}
/**
* Primary class template _Insert_base.
*
* Defines @c insert member functions appropriate to all _Hashtables.
*/
template<typename _Key, typename _Value, typename _Alloc,
typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash,
typename _RehashPolicy, typename _Traits>
struct _Insert_base
{
protected:
using __hashtable = _Hashtable<_Key, _Value, _Alloc, _ExtractKey,
_Equal, _H1, _H2, _Hash,
_RehashPolicy, _Traits>;
using __hashtable_base = _Hashtable_base<_Key, _Value, _ExtractKey,
_Equal, _H1, _H2, _Hash,
_Traits>;
using value_type = typename __hashtable_base::value_type;
using iterator = typename __hashtable_base::iterator;
using const_iterator = typename __hashtable_base::const_iterator;
using size_type = typename __hashtable_base::size_type;
using __unique_keys = typename __hashtable_base::__unique_keys;
using __ireturn_type = typename __hashtable_base::__ireturn_type;
using __node_type = _Hash_node<_Value, _Traits::__hash_cached::value>;
using __node_alloc_type = __alloc_rebind<_Alloc, __node_type>;
using __node_gen_type = _AllocNode<__node_alloc_type>;
__hashtable&
_M_conjure_hashtable()
{ return *(static_cast<__hashtable*>(this)); }
template<typename _InputIterator, typename _NodeGetter>
void
_M_insert_range(_InputIterator __first, _InputIterator __last,
const _NodeGetter&, true_type);
template<typename _InputIterator, typename _NodeGetter>
void
_M_insert_range(_InputIterator __first, _InputIterator __last,
const _NodeGetter&, false_type);
public:
__ireturn_type
insert(const value_type& __v)
{
__hashtable& __h = _M_conjure_hashtable();
__node_gen_type __node_gen(__h);
return __h._M_insert(__v, __node_gen, __unique_keys());
}
iterator
insert(const_iterator __hint, const value_type& __v)
{
__hashtable& __h = _M_conjure_hashtable();
__node_gen_type __node_gen(__h);
return __h._M_insert(__hint, __v, __node_gen, __unique_keys());
}
void
insert(initializer_list<value_type> __l)
{ this->insert(__l.begin(), __l.end()); }
template<typename _InputIterator>
void
insert(_InputIterator __first, _InputIterator __last)
{
__hashtable& __h = _M_conjure_hashtable();
__node_gen_type __node_gen(__h);
return _M_insert_range(__first, __last, __node_gen, __unique_keys());
}
};
template<typename _Key, typename _Value, typename _Alloc,
typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash,
typename _RehashPolicy, typename _Traits>
template<typename _InputIterator, typename _NodeGetter>
void
_Insert_base<_Key, _Value, _Alloc, _ExtractKey, _Equal, _H1, _H2, _Hash,
_RehashPolicy, _Traits>::
_M_insert_range(_InputIterator __first, _InputIterator __last,
const _NodeGetter& __node_gen, true_type)
{
size_type __n_elt = __detail::__distance_fw(__first, __last);
if (__n_elt == 0)
return;
__hashtable& __h = _M_conjure_hashtable();
for (; __first != __last; ++__first)
{
if (__h._M_insert(*__first, __node_gen, __unique_keys(),
__n_elt).second)
__n_elt = 1;
else if (__n_elt != 1)
--__n_elt;
}
}
template<typename _Key, typename _Value, typename _Alloc,
typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash,
typename _RehashPolicy, typename _Traits>
template<typename _InputIterator, typename _NodeGetter>
void
_Insert_base<_Key, _Value, _Alloc, _ExtractKey, _Equal, _H1, _H2, _Hash,
_RehashPolicy, _Traits>::
_M_insert_range(_InputIterator __first, _InputIterator __last,
const _NodeGetter& __node_gen, false_type)
{
using __rehash_type = typename __hashtable::__rehash_type;
using __rehash_state = typename __hashtable::__rehash_state;
using pair_type = std::pair<bool, std::size_t>;
size_type __n_elt = __detail::__distance_fw(__first, __last);
if (__n_elt == 0)
return;
__hashtable& __h = _M_conjure_hashtable();
__rehash_type& __rehash = __h._M_rehash_policy;
const __rehash_state& __saved_state = __rehash._M_state();
pair_type __do_rehash = __rehash._M_need_rehash(__h._M_bucket_count,
__h._M_element_count,
__n_elt);
if (__do_rehash.first)
__h._M_rehash(__do_rehash.second, __saved_state);
for (; __first != __last; ++__first)
__h._M_insert(*__first, __node_gen, __unique_keys());
}
/**
* Primary class template _Insert.
*
* Defines @c insert member functions that depend on _Hashtable policies,
* via partial specializations.
*/
template<typename _Key, typename _Value, typename _Alloc,
typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash,
typename _RehashPolicy, typename _Traits,
bool _Constant_iterators = _Traits::__constant_iterators::value>
struct _Insert;
/// Specialization.
template<typename _Key, typename _Value, typename _Alloc,
typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash,
typename _RehashPolicy, typename _Traits>
struct _Insert<_Key, _Value, _Alloc, _ExtractKey, _Equal, _H1, _H2, _Hash,
_RehashPolicy, _Traits, true>
: public _Insert_base<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>
{
using __base_type = _Insert_base<_Key, _Value, _Alloc, _ExtractKey,
_Equal, _H1, _H2, _Hash,
_RehashPolicy, _Traits>;
using __hashtable_base = _Hashtable_base<_Key, _Value, _ExtractKey,
_Equal, _H1, _H2, _Hash,
_Traits>;
using value_type = typename __base_type::value_type;
using iterator = typename __base_type::iterator;
using const_iterator = typename __base_type::const_iterator;
using __unique_keys = typename __base_type::__unique_keys;
using __ireturn_type = typename __hashtable_base::__ireturn_type;
using __hashtable = typename __base_type::__hashtable;
using __node_gen_type = typename __base_type::__node_gen_type;
using __base_type::insert;
__ireturn_type
insert(value_type&& __v)
{
__hashtable& __h = this->_M_conjure_hashtable();
__node_gen_type __node_gen(__h);
return __h._M_insert(std::move(__v), __node_gen, __unique_keys());
}
iterator
insert(const_iterator __hint, value_type&& __v)
{
__hashtable& __h = this->_M_conjure_hashtable();
__node_gen_type __node_gen(__h);
return __h._M_insert(__hint, std::move(__v), __node_gen,
__unique_keys());
}
};
/// Specialization.
template<typename _Key, typename _Value, typename _Alloc,
typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash,
typename _RehashPolicy, typename _Traits>
struct _Insert<_Key, _Value, _Alloc, _ExtractKey, _Equal, _H1, _H2, _Hash,
_RehashPolicy, _Traits, false>
: public _Insert_base<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>
{
using __base_type = _Insert_base<_Key, _Value, _Alloc, _ExtractKey,
_Equal, _H1, _H2, _Hash,
_RehashPolicy, _Traits>;
using value_type = typename __base_type::value_type;
using iterator = typename __base_type::iterator;
using const_iterator = typename __base_type::const_iterator;
using __unique_keys = typename __base_type::__unique_keys;
using __hashtable = typename __base_type::__hashtable;
using __ireturn_type = typename __base_type::__ireturn_type;
using __base_type::insert;
template<typename _Pair>
using __is_cons = std::is_constructible<value_type, _Pair&&>;
template<typename _Pair>
using _IFcons = std::enable_if<__is_cons<_Pair>::value>;
template<typename _Pair>
using _IFconsp = typename _IFcons<_Pair>::type;
template<typename _Pair, typename = _IFconsp<_Pair>>
__ireturn_type
insert(_Pair&& __v)
{
__hashtable& __h = this->_M_conjure_hashtable();
return __h._M_emplace(__unique_keys(), std::forward<_Pair>(__v));
}
template<typename _Pair, typename = _IFconsp<_Pair>>
iterator
insert(const_iterator __hint, _Pair&& __v)
{
__hashtable& __h = this->_M_conjure_hashtable();
return __h._M_emplace(__hint, __unique_keys(),
std::forward<_Pair>(__v));
}
};
template<typename _Policy>
using __has_load_factor = typename _Policy::__has_load_factor;
/**
* Primary class template _Rehash_base.
*
* Give hashtable the max_load_factor functions and reserve iff the
* rehash policy supports it.
*/
template<typename _Key, typename _Value, typename _Alloc,
typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash,
typename _RehashPolicy, typename _Traits,
typename =
__detected_or_t<std::false_type, __has_load_factor, _RehashPolicy>>
struct _Rehash_base;
/// Specialization when rehash policy doesn't provide load factor management.
template<typename _Key, typename _Value, typename _Alloc,
typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash,
typename _RehashPolicy, typename _Traits>
struct _Rehash_base<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits,
std::false_type>
{
};
/// Specialization when rehash policy provide load factor management.
template<typename _Key, typename _Value, typename _Alloc,
typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash,
typename _RehashPolicy, typename _Traits>
struct _Rehash_base<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits,
std::true_type>
{
using __hashtable = _Hashtable<_Key, _Value, _Alloc, _ExtractKey,
_Equal, _H1, _H2, _Hash,
_RehashPolicy, _Traits>;
float
max_load_factor() const noexcept
{
const __hashtable* __this = static_cast<const __hashtable*>(this);
return __this->__rehash_policy().max_load_factor();
}
void
max_load_factor(float __z)
{
__hashtable* __this = static_cast<__hashtable*>(this);
__this->__rehash_policy(_RehashPolicy(__z));
}
void
reserve(std::size_t __n)
{
__hashtable* __this = static_cast<__hashtable*>(this);
__this->rehash(__builtin_ceil(__n / max_load_factor()));
}
};
/**
* Primary class template _Hashtable_ebo_helper.
*
* Helper class using EBO when it is not forbidden (the type is not
* final) and when it is worth it (the type is empty.)
*/
template<int _Nm, typename _Tp,
bool __use_ebo = !__is_final(_Tp) && __is_empty(_Tp)>
struct _Hashtable_ebo_helper;
/// Specialization using EBO.
template<int _Nm, typename _Tp>
struct _Hashtable_ebo_helper<_Nm, _Tp, true>
: private _Tp
{
_Hashtable_ebo_helper() = default;
template<typename _OtherTp>
_Hashtable_ebo_helper(_OtherTp&& __tp)
: _Tp(std::forward<_OtherTp>(__tp))
{ }
static const _Tp&
_S_cget(const _Hashtable_ebo_helper& __eboh)
{ return static_cast<const _Tp&>(__eboh); }
static _Tp&
_S_get(_Hashtable_ebo_helper& __eboh)
{ return static_cast<_Tp&>(__eboh); }
};
/// Specialization not using EBO.
template<int _Nm, typename _Tp>
struct _Hashtable_ebo_helper<_Nm, _Tp, false>
{
_Hashtable_ebo_helper() = default;
template<typename _OtherTp>
_Hashtable_ebo_helper(_OtherTp&& __tp)
: _M_tp(std::forward<_OtherTp>(__tp))
{ }
static const _Tp&
_S_cget(const _Hashtable_ebo_helper& __eboh)
{ return __eboh._M_tp; }
static _Tp&
_S_get(_Hashtable_ebo_helper& __eboh)
{ return __eboh._M_tp; }
private:
_Tp _M_tp;
};
/**
* Primary class template _Local_iterator_base.
*
* Base class for local iterators, used to iterate within a bucket
* but not between buckets.
*/
template<typename _Key, typename _Value, typename _ExtractKey,
typename _H1, typename _H2, typename _Hash,
bool __cache_hash_code>
struct _Local_iterator_base;
/**
* Primary class template _Hash_code_base.
*
* Encapsulates two policy issues that aren't quite orthogonal.
* (1) the difference between using a ranged hash function and using
* the combination of a hash function and a range-hashing function.
* In the former case we don't have such things as hash codes, so
* we have a dummy type as placeholder.
* (2) Whether or not we cache hash codes. Caching hash codes is
* meaningless if we have a ranged hash function.
*
* We also put the key extraction objects here, for convenience.
* Each specialization derives from one or more of the template
* parameters to benefit from Ebo. This is important as this type
* is inherited in some cases by the _Local_iterator_base type used
* to implement local_iterator and const_local_iterator. As with
* any iterator type we prefer to make it as small as possible.
*
* Primary template is unused except as a hook for specializations.
*/
template<typename _Key, typename _Value, typename _ExtractKey,
typename _H1, typename _H2, typename _Hash,
bool __cache_hash_code>
struct _Hash_code_base;
/// Specialization: ranged hash function, no caching hash codes. H1
/// and H2 are provided but ignored. We define a dummy hash code type.
template<typename _Key, typename _Value, typename _ExtractKey,
typename _H1, typename _H2, typename _Hash>
struct _Hash_code_base<_Key, _Value, _ExtractKey, _H1, _H2, _Hash, false>
: private _Hashtable_ebo_helper<0, _ExtractKey>,
private _Hashtable_ebo_helper<1, _Hash>
{
private:
using __ebo_extract_key = _Hashtable_ebo_helper<0, _ExtractKey>;
using __ebo_hash = _Hashtable_ebo_helper<1, _Hash>;
protected:
typedef void* __hash_code;
typedef _Hash_node<_Value, false> __node_type;
// We need the default constructor for the local iterators and _Hashtable
// default constructor.
_Hash_code_base() = default;
_Hash_code_base(const _ExtractKey& __ex, const _H1&, const _H2&,
const _Hash& __h)
: __ebo_extract_key(__ex), __ebo_hash(__h) { }
__hash_code
_M_hash_code(const _Key& __key) const
{ return 0; }
std::size_t
_M_bucket_index(const _Key& __k, __hash_code, std::size_t __n) const
{ return _M_ranged_hash()(__k, __n); }
std::size_t
_M_bucket_index(const __node_type* __p, std::size_t __n) const
noexcept( noexcept(declval<const _Hash&>()(declval<const _Key&>(),
(std::size_t)0)) )
{ return _M_ranged_hash()(_M_extract()(__p->_M_v()), __n); }
void
_M_store_code(__node_type*, __hash_code) const
{ }
void
_M_copy_code(__node_type*, const __node_type*) const
{ }
void
_M_swap(_Hash_code_base& __x)
{
std::swap(_M_extract(), __x._M_extract());
std::swap(_M_ranged_hash(), __x._M_ranged_hash());
}
const _ExtractKey&
_M_extract() const { return __ebo_extract_key::_S_cget(*this); }
_ExtractKey&
_M_extract() { return __ebo_extract_key::_S_get(*this); }
const _Hash&
_M_ranged_hash() const { return __ebo_hash::_S_cget(*this); }
_Hash&
_M_ranged_hash() { return __ebo_hash::_S_get(*this); }
};
// No specialization for ranged hash function while caching hash codes.
// That combination is meaningless, and trying to do it is an error.
/// Specialization: ranged hash function, cache hash codes. This
/// combination is meaningless, so we provide only a declaration
/// and no definition.
template<typename _Key, typename _Value, typename _ExtractKey,
typename _H1, typename _H2, typename _Hash>
struct _Hash_code_base<_Key, _Value, _ExtractKey, _H1, _H2, _Hash, true>;
/// Specialization: hash function and range-hashing function, no
/// caching of hash codes.
/// Provides typedef and accessor required by C++ 11.
template<typename _Key, typename _Value, typename _ExtractKey,
typename _H1, typename _H2>
struct _Hash_code_base<_Key, _Value, _ExtractKey, _H1, _H2,
_Default_ranged_hash, false>
: private _Hashtable_ebo_helper<0, _ExtractKey>,
private _Hashtable_ebo_helper<1, _H1>,
private _Hashtable_ebo_helper<2, _H2>
{
private:
using __ebo_extract_key = _Hashtable_ebo_helper<0, _ExtractKey>;
using __ebo_h1 = _Hashtable_ebo_helper<1, _H1>;
using __ebo_h2 = _Hashtable_ebo_helper<2, _H2>;
// Gives the local iterator implementation access to _M_bucket_index().
friend struct _Local_iterator_base<_Key, _Value, _ExtractKey, _H1, _H2,
_Default_ranged_hash, false>;
public:
typedef _H1 hasher;
hasher
hash_function() const
{ return _M_h1(); }
protected:
typedef std::size_t __hash_code;
typedef _Hash_node<_Value, false> __node_type;
// We need the default constructor for the local iterators and _Hashtable
// default constructor.
_Hash_code_base() = default;
_Hash_code_base(const _ExtractKey& __ex,
const _H1& __h1, const _H2& __h2,
const _Default_ranged_hash&)
: __ebo_extract_key(__ex), __ebo_h1(__h1), __ebo_h2(__h2) { }
__hash_code
_M_hash_code(const _Key& __k) const
{
static_assert(__is_invocable<const _H1&, const _Key&>{},
"hash function must be invocable with an argument of key type");
return _M_h1()(__k);
}
std::size_t
_M_bucket_index(const _Key&, __hash_code __c, std::size_t __n) const
{ return _M_h2()(__c, __n); }
std::size_t
_M_bucket_index(const __node_type* __p, std::size_t __n) const
noexcept( noexcept(declval<const _H1&>()(declval<const _Key&>()))
&& noexcept(declval<const _H2&>()((__hash_code)0,
(std::size_t)0)) )
{ return _M_h2()(_M_h1()(_M_extract()(__p->_M_v())), __n); }
void
_M_store_code(__node_type*, __hash_code) const
{ }
void
_M_copy_code(__node_type*, const __node_type*) const
{ }
void
_M_swap(_Hash_code_base& __x)
{
std::swap(_M_extract(), __x._M_extract());
std::swap(_M_h1(), __x._M_h1());
std::swap(_M_h2(), __x._M_h2());
}
const _ExtractKey&
_M_extract() const { return __ebo_extract_key::_S_cget(*this); }
_ExtractKey&
_M_extract() { return __ebo_extract_key::_S_get(*this); }
const _H1&
_M_h1() const { return __ebo_h1::_S_cget(*this); }
_H1&
_M_h1() { return __ebo_h1::_S_get(*this); }
const _H2&
_M_h2() const { return __ebo_h2::_S_cget(*this); }
_H2&
_M_h2() { return __ebo_h2::_S_get(*this); }
};
/// Specialization: hash function and range-hashing function,
/// caching hash codes. H is provided but ignored. Provides
/// typedef and accessor required by C++ 11.
template<typename _Key, typename _Value, typename _ExtractKey,
typename _H1, typename _H2>
struct _Hash_code_base<_Key, _Value, _ExtractKey, _H1, _H2,
_Default_ranged_hash, true>
: private _Hashtable_ebo_helper<0, _ExtractKey>,
private _Hashtable_ebo_helper<1, _H1>,
private _Hashtable_ebo_helper<2, _H2>
{
private:
// Gives the local iterator implementation access to _M_h2().
friend struct _Local_iterator_base<_Key, _Value, _ExtractKey, _H1, _H2,
_Default_ranged_hash, true>;
using __ebo_extract_key = _Hashtable_ebo_helper<0, _ExtractKey>;
using __ebo_h1 = _Hashtable_ebo_helper<1, _H1>;
using __ebo_h2 = _Hashtable_ebo_helper<2, _H2>;
public:
typedef _H1 hasher;
hasher
hash_function() const
{ return _M_h1(); }
protected:
typedef std::size_t __hash_code;
typedef _Hash_node<_Value, true> __node_type;
// We need the default constructor for _Hashtable default constructor.
_Hash_code_base() = default;
_Hash_code_base(const _ExtractKey& __ex,
const _H1& __h1, const _H2& __h2,
const _Default_ranged_hash&)
: __ebo_extract_key(__ex), __ebo_h1(__h1), __ebo_h2(__h2) { }
__hash_code
_M_hash_code(const _Key& __k) const
{
static_assert(__is_invocable<const _H1&, const _Key&>{},
"hash function must be invocable with an argument of key type");
return _M_h1()(__k);
}
std::size_t
_M_bucket_index(const _Key&, __hash_code __c,
std::size_t __n) const
{ return _M_h2()(__c, __n); }
std::size_t
_M_bucket_index(const __node_type* __p, std::size_t __n) const
noexcept( noexcept(declval<const _H2&>()((__hash_code)0,
(std::size_t)0)) )
{ return _M_h2()(__p->_M_hash_code, __n); }
void
_M_store_code(__node_type* __n, __hash_code __c) const
{ __n->_M_hash_code = __c; }
void
_M_copy_code(__node_type* __to, const __node_type* __from) const
{ __to->_M_hash_code = __from->_M_hash_code; }
void
_M_swap(_Hash_code_base& __x)
{
std::swap(_M_extract(), __x._M_extract());
std::swap(_M_h1(), __x._M_h1());
std::swap(_M_h2(), __x._M_h2());
}
const _ExtractKey&
_M_extract() const { return __ebo_extract_key::_S_cget(*this); }
_ExtractKey&
_M_extract() { return __ebo_extract_key::_S_get(*this); }
const _H1&
_M_h1() const { return __ebo_h1::_S_cget(*this); }
_H1&
_M_h1() { return __ebo_h1::_S_get(*this); }
const _H2&
_M_h2() const { return __ebo_h2::_S_cget(*this); }
_H2&
_M_h2() { return __ebo_h2::_S_get(*this); }
};
/**
* Primary class template _Equal_helper.
*
*/
template <typename _Key, typename _Value, typename _ExtractKey,
typename _Equal, typename _HashCodeType,
bool __cache_hash_code>
struct _Equal_helper;
/// Specialization.
template<typename _Key, typename _Value, typename _ExtractKey,
typename _Equal, typename _HashCodeType>
struct _Equal_helper<_Key, _Value, _ExtractKey, _Equal, _HashCodeType, true>
{
static bool
_S_equals(const _Equal& __eq, const _ExtractKey& __extract,
const _Key& __k, _HashCodeType __c, _Hash_node<_Value, true>* __n)
{ return __c == __n->_M_hash_code && __eq(__k, __extract(__n->_M_v())); }
};
/// Specialization.
template<typename _Key, typename _Value, typename _ExtractKey,
typename _Equal, typename _HashCodeType>
struct _Equal_helper<_Key, _Value, _ExtractKey, _Equal, _HashCodeType, false>
{
static bool
_S_equals(const _Equal& __eq, const _ExtractKey& __extract,
const _Key& __k, _HashCodeType, _Hash_node<_Value, false>* __n)
{ return __eq(__k, __extract(__n->_M_v())); }
};
/// Partial specialization used when nodes contain a cached hash code.
template<typename _Key, typename _Value, typename _ExtractKey,
typename _H1, typename _H2, typename _Hash>
struct _Local_iterator_base<_Key, _Value, _ExtractKey,
_H1, _H2, _Hash, true>
: private _Hashtable_ebo_helper<0, _H2>
{
protected:
using __base_type = _Hashtable_ebo_helper<0, _H2>;
using __hash_code_base = _Hash_code_base<_Key, _Value, _ExtractKey,
_H1, _H2, _Hash, true>;
_Local_iterator_base() = default;
_Local_iterator_base(const __hash_code_base& __base,
_Hash_node<_Value, true>* __p,
std::size_t __bkt, std::size_t __bkt_count)
: __base_type(__base._M_h2()),
_M_cur(__p), _M_bucket(__bkt), _M_bucket_count(__bkt_count) { }
void
_M_incr()
{
_M_cur = _M_cur->_M_next();
if (_M_cur)
{
std::size_t __bkt
= __base_type::_S_get(*this)(_M_cur->_M_hash_code,
_M_bucket_count);
if (__bkt != _M_bucket)
_M_cur = nullptr;
}
}
_Hash_node<_Value, true>* _M_cur;
std::size_t _M_bucket;
std::size_t _M_bucket_count;
public:
const void*
_M_curr() const { return _M_cur; } // for equality ops
std::size_t
_M_get_bucket() const { return _M_bucket; } // for debug mode
};
// Uninitialized storage for a _Hash_code_base.
// This type is DefaultConstructible and Assignable even if the
// _Hash_code_base type isn't, so that _Local_iterator_base<..., false>
// can be DefaultConstructible and Assignable.
template<typename _Tp, bool _IsEmpty = std::is_empty<_Tp>::value>
struct _Hash_code_storage
{
__gnu_cxx::__aligned_buffer<_Tp> _M_storage;
_Tp*
_M_h() { return _M_storage._M_ptr(); }
const _Tp*
_M_h() const { return _M_storage._M_ptr(); }
};
// Empty partial specialization for empty _Hash_code_base types.
template<typename _Tp>
struct _Hash_code_storage<_Tp, true>
{
static_assert( std::is_empty<_Tp>::value, "Type must be empty" );
// As _Tp is an empty type there will be no bytes written/read through
// the cast pointer, so no strict-aliasing violation.
_Tp*
_M_h() { return reinterpret_cast<_Tp*>(this); }
const _Tp*
_M_h() const { return reinterpret_cast<const _Tp*>(this); }
};
template<typename _Key, typename _Value, typename _ExtractKey,
typename _H1, typename _H2, typename _Hash>
using __hash_code_for_local_iter
= _Hash_code_storage<_Hash_code_base<_Key, _Value, _ExtractKey,
_H1, _H2, _Hash, false>>;
// Partial specialization used when hash codes are not cached
template<typename _Key, typename _Value, typename _ExtractKey,
typename _H1, typename _H2, typename _Hash>
struct _Local_iterator_base<_Key, _Value, _ExtractKey,
_H1, _H2, _Hash, false>
: __hash_code_for_local_iter<_Key, _Value, _ExtractKey, _H1, _H2, _Hash>
{
protected:
using __hash_code_base = _Hash_code_base<_Key, _Value, _ExtractKey,
_H1, _H2, _Hash, false>;
_Local_iterator_base() : _M_bucket_count(-1) { }
_Local_iterator_base(const __hash_code_base& __base,
_Hash_node<_Value, false>* __p,
std::size_t __bkt, std::size_t __bkt_count)
: _M_cur(__p), _M_bucket(__bkt), _M_bucket_count(__bkt_count)
{ _M_init(__base); }
~_Local_iterator_base()
{
if (_M_bucket_count != -1)
_M_destroy();
}
_Local_iterator_base(const _Local_iterator_base& __iter)
: _M_cur(__iter._M_cur), _M_bucket(__iter._M_bucket),
_M_bucket_count(__iter._M_bucket_count)
{
if (_M_bucket_count != -1)
_M_init(*__iter._M_h());
}
_Local_iterator_base&
operator=(const _Local_iterator_base& __iter)
{
if (_M_bucket_count != -1)
_M_destroy();
_M_cur = __iter._M_cur;
_M_bucket = __iter._M_bucket;
_M_bucket_count = __iter._M_bucket_count;
if (_M_bucket_count != -1)
_M_init(*__iter._M_h());
return *this;
}
void
_M_incr()
{
_M_cur = _M_cur->_M_next();
if (_M_cur)
{
std::size_t __bkt = this->_M_h()->_M_bucket_index(_M_cur,
_M_bucket_count);
if (__bkt != _M_bucket)
_M_cur = nullptr;
}
}
_Hash_node<_Value, false>* _M_cur;
std::size_t _M_bucket;
std::size_t _M_bucket_count;
void
_M_init(const __hash_code_base& __base)
{ ::new(this->_M_h()) __hash_code_base(__base); }
void
_M_destroy() { this->_M_h()->~__hash_code_base(); }
public:
const void*
_M_curr() const { return _M_cur; } // for equality ops and debug mode
std::size_t
_M_get_bucket() const { return _M_bucket; } // for debug mode
};
template<typename _Key, typename _Value, typename _ExtractKey,
typename _H1, typename _H2, typename _Hash, bool __cache>
inline bool
operator==(const _Local_iterator_base<_Key, _Value, _ExtractKey,
_H1, _H2, _Hash, __cache>& __x,
const _Local_iterator_base<_Key, _Value, _ExtractKey,
_H1, _H2, _Hash, __cache>& __y)
{ return __x._M_curr() == __y._M_curr(); }
template<typename _Key, typename _Value, typename _ExtractKey,
typename _H1, typename _H2, typename _Hash, bool __cache>
inline bool
operator!=(const _Local_iterator_base<_Key, _Value, _ExtractKey,
_H1, _H2, _Hash, __cache>& __x,
const _Local_iterator_base<_Key, _Value, _ExtractKey,
_H1, _H2, _Hash, __cache>& __y)
{ return __x._M_curr() != __y._M_curr(); }
/// local iterators
template<typename _Key, typename _Value, typename _ExtractKey,
typename _H1, typename _H2, typename _Hash,
bool __constant_iterators, bool __cache>
struct _Local_iterator
: public _Local_iterator_base<_Key, _Value, _ExtractKey,
_H1, _H2, _Hash, __cache>
{
private:
using __base_type = _Local_iterator_base<_Key, _Value, _ExtractKey,
_H1, _H2, _Hash, __cache>;
using __hash_code_base = typename __base_type::__hash_code_base;
public:
typedef _Value value_type;
typedef typename std::conditional<__constant_iterators,
const _Value*, _Value*>::type
pointer;
typedef typename std::conditional<__constant_iterators,
const _Value&, _Value&>::type
reference;
typedef std::ptrdiff_t difference_type;
typedef std::forward_iterator_tag iterator_category;
_Local_iterator() = default;
_Local_iterator(const __hash_code_base& __base,
_Hash_node<_Value, __cache>* __p,
std::size_t __bkt, std::size_t __bkt_count)
: __base_type(__base, __p, __bkt, __bkt_count)
{ }
reference
operator*() const
{ return this->_M_cur->_M_v(); }
pointer
operator->() const
{ return this->_M_cur->_M_valptr(); }
_Local_iterator&
operator++()
{
this->_M_incr();
return *this;
}
_Local_iterator
operator++(int)
{
_Local_iterator __tmp(*this);
this->_M_incr();
return __tmp;
}
};
/// local const_iterators
template<typename _Key, typename _Value, typename _ExtractKey,
typename _H1, typename _H2, typename _Hash,
bool __constant_iterators, bool __cache>
struct _Local_const_iterator
: public _Local_iterator_base<_Key, _Value, _ExtractKey,
_H1, _H2, _Hash, __cache>
{
private:
using __base_type = _Local_iterator_base<_Key, _Value, _ExtractKey,
_H1, _H2, _Hash, __cache>;
using __hash_code_base = typename __base_type::__hash_code_base;
public:
typedef _Value value_type;
typedef const _Value* pointer;
typedef const _Value& reference;
typedef std::ptrdiff_t difference_type;
typedef std::forward_iterator_tag iterator_category;
_Local_const_iterator() = default;
_Local_const_iterator(const __hash_code_base& __base,
_Hash_node<_Value, __cache>* __p,
std::size_t __bkt, std::size_t __bkt_count)
: __base_type(__base, __p, __bkt, __bkt_count)
{ }
_Local_const_iterator(const _Local_iterator<_Key, _Value, _ExtractKey,
_H1, _H2, _Hash,
__constant_iterators,
__cache>& __x)
: __base_type(__x)
{ }
reference
operator*() const
{ return this->_M_cur->_M_v(); }
pointer
operator->() const
{ return this->_M_cur->_M_valptr(); }
_Local_const_iterator&
operator++()
{
this->_M_incr();
return *this;
}
_Local_const_iterator
operator++(int)
{
_Local_const_iterator __tmp(*this);
this->_M_incr();
return __tmp;
}
};
/**
* Primary class template _Hashtable_base.
*
* Helper class adding management of _Equal functor to
* _Hash_code_base type.
*
* Base class templates are:
* - __detail::_Hash_code_base
* - __detail::_Hashtable_ebo_helper
*/
template<typename _Key, typename _Value,
typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _Traits>
struct _Hashtable_base
: public _Hash_code_base<_Key, _Value, _ExtractKey, _H1, _H2, _Hash,
_Traits::__hash_cached::value>,
private _Hashtable_ebo_helper<0, _Equal>
{
public:
typedef _Key key_type;
typedef _Value value_type;
typedef _Equal key_equal;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
using __traits_type = _Traits;
using __hash_cached = typename __traits_type::__hash_cached;
using __constant_iterators = typename __traits_type::__constant_iterators;
using __unique_keys = typename __traits_type::__unique_keys;
using __hash_code_base = _Hash_code_base<_Key, _Value, _ExtractKey,
_H1, _H2, _Hash,
__hash_cached::value>;
using __hash_code = typename __hash_code_base::__hash_code;
using __node_type = typename __hash_code_base::__node_type;
using iterator = __detail::_Node_iterator<value_type,
__constant_iterators::value,
__hash_cached::value>;
using const_iterator = __detail::_Node_const_iterator<value_type,
__constant_iterators::value,
__hash_cached::value>;
using local_iterator = __detail::_Local_iterator<key_type, value_type,
_ExtractKey, _H1, _H2, _Hash,
__constant_iterators::value,
__hash_cached::value>;
using const_local_iterator = __detail::_Local_const_iterator<key_type,
value_type,
_ExtractKey, _H1, _H2, _Hash,
__constant_iterators::value,
__hash_cached::value>;
using __ireturn_type = typename std::conditional<__unique_keys::value,
std::pair<iterator, bool>,
iterator>::type;
private:
using _EqualEBO = _Hashtable_ebo_helper<0, _Equal>;
using _EqualHelper = _Equal_helper<_Key, _Value, _ExtractKey, _Equal,
__hash_code, __hash_cached::value>;
protected:
_Hashtable_base() = default;
_Hashtable_base(const _ExtractKey& __ex, const _H1& __h1, const _H2& __h2,
const _Hash& __hash, const _Equal& __eq)
: __hash_code_base(__ex, __h1, __h2, __hash), _EqualEBO(__eq)
{ }
bool
_M_equals(const _Key& __k, __hash_code __c, __node_type* __n) const
{
static_assert(__is_invocable<const _Equal&, const _Key&, const _Key&>{},
"key equality predicate must be invocable with two arguments of "
"key type");
return _EqualHelper::_S_equals(_M_eq(), this->_M_extract(),
__k, __c, __n);
}
void
_M_swap(_Hashtable_base& __x)
{
__hash_code_base::_M_swap(__x);
std::swap(_M_eq(), __x._M_eq());
}
const _Equal&
_M_eq() const { return _EqualEBO::_S_cget(*this); }
_Equal&
_M_eq() { return _EqualEBO::_S_get(*this); }
};
/**
* struct _Equality_base.
*
* Common types and functions for class _Equality.
*/
struct _Equality_base
{
protected:
template<typename _Uiterator>
static bool
_S_is_permutation(_Uiterator, _Uiterator, _Uiterator);
};
// See std::is_permutation in N3068.
template<typename _Uiterator>
bool
_Equality_base::
_S_is_permutation(_Uiterator __first1, _Uiterator __last1,
_Uiterator __first2)
{
for (; __first1 != __last1; ++__first1, ++__first2)
if (!(*__first1 == *__first2))
break;
if (__first1 == __last1)
return true;
_Uiterator __last2 = __first2;
std::advance(__last2, std::distance(__first1, __last1));
for (_Uiterator __it1 = __first1; __it1 != __last1; ++__it1)
{
_Uiterator __tmp = __first1;
while (__tmp != __it1 && !bool(*__tmp == *__it1))
++__tmp;
// We've seen this one before.
if (__tmp != __it1)
continue;
std::ptrdiff_t __n2 = 0;
for (__tmp = __first2; __tmp != __last2; ++__tmp)
if (*__tmp == *__it1)
++__n2;
if (!__n2)
return false;
std::ptrdiff_t __n1 = 0;
for (__tmp = __it1; __tmp != __last1; ++__tmp)
if (*__tmp == *__it1)
++__n1;
if (__n1 != __n2)
return false;
}
return true;
}
/**
* Primary class template _Equality.
*
* This is for implementing equality comparison for unordered
* containers, per N3068, by John Lakos and Pablo Halpern.
* Algorithmically, we follow closely the reference implementations
* therein.
*/
template<typename _Key, typename _Value, typename _Alloc,
typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash,
typename _RehashPolicy, typename _Traits,
bool _Unique_keys = _Traits::__unique_keys::value>
struct _Equality;
/// Specialization.
template<typename _Key, typename _Value, typename _Alloc,
typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash,
typename _RehashPolicy, typename _Traits>
struct _Equality<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits, true>
{
using __hashtable = _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>;
bool
_M_equal(const __hashtable&) const;
};
template<typename _Key, typename _Value, typename _Alloc,
typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash,
typename _RehashPolicy, typename _Traits>
bool
_Equality<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits, true>::
_M_equal(const __hashtable& __other) const
{
const __hashtable* __this = static_cast<const __hashtable*>(this);
if (__this->size() != __other.size())
return false;
for (auto __itx = __this->begin(); __itx != __this->end(); ++__itx)
{
const auto __ity = __other.find(_ExtractKey()(*__itx));
if (__ity == __other.end() || !bool(*__ity == *__itx))
return false;
}
return true;
}
/// Specialization.
template<typename _Key, typename _Value, typename _Alloc,
typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash,
typename _RehashPolicy, typename _Traits>
struct _Equality<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits, false>
: public _Equality_base
{
using __hashtable = _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>;
bool
_M_equal(const __hashtable&) const;
};
template<typename _Key, typename _Value, typename _Alloc,
typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash,
typename _RehashPolicy, typename _Traits>
bool
_Equality<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits, false>::
_M_equal(const __hashtable& __other) const
{
const __hashtable* __this = static_cast<const __hashtable*>(this);
if (__this->size() != __other.size())
return false;
for (auto __itx = __this->begin(); __itx != __this->end();)
{
const auto __xrange = __this->equal_range(_ExtractKey()(*__itx));
const auto __yrange = __other.equal_range(_ExtractKey()(*__itx));
if (std::distance(__xrange.first, __xrange.second)
!= std::distance(__yrange.first, __yrange.second))
return false;
if (!_S_is_permutation(__xrange.first, __xrange.second,
__yrange.first))
return false;
__itx = __xrange.second;
}
return true;
}
/**
* This type deals with all allocation and keeps an allocator instance through
* inheritance to benefit from EBO when possible.
*/
template<typename _NodeAlloc>
struct _Hashtable_alloc : private _Hashtable_ebo_helper<0, _NodeAlloc>
{
private:
using __ebo_node_alloc = _Hashtable_ebo_helper<0, _NodeAlloc>;
public:
using __node_type = typename _NodeAlloc::value_type;
using __node_alloc_type = _NodeAlloc;
// Use __gnu_cxx to benefit from _S_always_equal and al.
using __node_alloc_traits = __gnu_cxx::__alloc_traits<__node_alloc_type>;
using __value_alloc_traits = typename __node_alloc_traits::template
rebind_traits<typename __node_type::value_type>;
using __node_base = __detail::_Hash_node_base;
using __bucket_type = __node_base*;
using __bucket_alloc_type =
__alloc_rebind<__node_alloc_type, __bucket_type>;
using __bucket_alloc_traits = std::allocator_traits<__bucket_alloc_type>;
_Hashtable_alloc() = default;
_Hashtable_alloc(const _Hashtable_alloc&) = default;
_Hashtable_alloc(_Hashtable_alloc&&) = default;
template<typename _Alloc>
_Hashtable_alloc(_Alloc&& __a)
: __ebo_node_alloc(std::forward<_Alloc>(__a))
{ }
__node_alloc_type&
_M_node_allocator()
{ return __ebo_node_alloc::_S_get(*this); }
const __node_alloc_type&
_M_node_allocator() const
{ return __ebo_node_alloc::_S_cget(*this); }
template<typename... _Args>
__node_type*
_M_allocate_node(_Args&&... __args);
void
_M_deallocate_node(__node_type* __n);
// Deallocate the linked list of nodes pointed to by __n
void
_M_deallocate_nodes(__node_type* __n);
__bucket_type*
_M_allocate_buckets(std::size_t __n);
void
_M_deallocate_buckets(__bucket_type*, std::size_t __n);
};
// Definitions of class template _Hashtable_alloc's out-of-line member
// functions.
template<typename _NodeAlloc>
template<typename... _Args>
typename _Hashtable_alloc<_NodeAlloc>::__node_type*
_Hashtable_alloc<_NodeAlloc>::_M_allocate_node(_Args&&... __args)
{
auto __nptr = __node_alloc_traits::allocate(_M_node_allocator(), 1);
__node_type* __n = std::__to_address(__nptr);
__try
{
::new ((void*)__n) __node_type;
__node_alloc_traits::construct(_M_node_allocator(),
__n->_M_valptr(),
std::forward<_Args>(__args)...);
return __n;
}
__catch(...)
{
__node_alloc_traits::deallocate(_M_node_allocator(), __nptr, 1);
__throw_exception_again;
}
}
template<typename _NodeAlloc>
void
_Hashtable_alloc<_NodeAlloc>::_M_deallocate_node(__node_type* __n)
{
typedef typename __node_alloc_traits::pointer _Ptr;
auto __ptr = std::pointer_traits<_Ptr>::pointer_to(*__n);
__node_alloc_traits::destroy(_M_node_allocator(), __n->_M_valptr());
__n->~__node_type();
__node_alloc_traits::deallocate(_M_node_allocator(), __ptr, 1);
}
template<typename _NodeAlloc>
void
_Hashtable_alloc<_NodeAlloc>::_M_deallocate_nodes(__node_type* __n)
{
while (__n)
{
__node_type* __tmp = __n;
__n = __n->_M_next();
_M_deallocate_node(__tmp);
}
}
template<typename _NodeAlloc>
typename _Hashtable_alloc<_NodeAlloc>::__bucket_type*
_Hashtable_alloc<_NodeAlloc>::_M_allocate_buckets(std::size_t __n)
{
__bucket_alloc_type __alloc(_M_node_allocator());
auto __ptr = __bucket_alloc_traits::allocate(__alloc, __n);
__bucket_type* __p = std::__to_address(__ptr);
__builtin_memset(__p, 0, __n * sizeof(__bucket_type));
return __p;
}
template<typename _NodeAlloc>
void
_Hashtable_alloc<_NodeAlloc>::_M_deallocate_buckets(__bucket_type* __bkts,
std::size_t __n)
{
typedef typename __bucket_alloc_traits::pointer _Ptr;
auto __ptr = std::pointer_traits<_Ptr>::pointer_to(*__bkts);
__bucket_alloc_type __alloc(_M_node_allocator());
__bucket_alloc_traits::deallocate(__alloc, __ptr, __n);
}
//@} hashtable-detail
} // namespace __detail
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // _HASHTABLE_POLICY_H
c++/8/bits/invoke.h 0000644 00000007111 15201526705 0007673 0 ustar 00 // Implementation of INVOKE -*- C++ -*-
// Copyright (C) 2016-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/bits/invoke.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{functional}
*/
#ifndef _GLIBCXX_INVOKE_H
#define _GLIBCXX_INVOKE_H 1
#pragma GCC system_header
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
#include <type_traits>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @addtogroup utilities
* @{
*/
// Used by __invoke_impl instead of std::forward<_Tp> so that a
// reference_wrapper is converted to an lvalue-reference.
template<typename _Tp, typename _Up = typename __inv_unwrap<_Tp>::type>
constexpr _Up&&
__invfwd(typename remove_reference<_Tp>::type& __t) noexcept
{ return static_cast<_Up&&>(__t); }
template<typename _Res, typename _Fn, typename... _Args>
constexpr _Res
__invoke_impl(__invoke_other, _Fn&& __f, _Args&&... __args)
{ return std::forward<_Fn>(__f)(std::forward<_Args>(__args)...); }
template<typename _Res, typename _MemFun, typename _Tp, typename... _Args>
constexpr _Res
__invoke_impl(__invoke_memfun_ref, _MemFun&& __f, _Tp&& __t,
_Args&&... __args)
{ return (__invfwd<_Tp>(__t).*__f)(std::forward<_Args>(__args)...); }
template<typename _Res, typename _MemFun, typename _Tp, typename... _Args>
constexpr _Res
__invoke_impl(__invoke_memfun_deref, _MemFun&& __f, _Tp&& __t,
_Args&&... __args)
{
return ((*std::forward<_Tp>(__t)).*__f)(std::forward<_Args>(__args)...);
}
template<typename _Res, typename _MemPtr, typename _Tp>
constexpr _Res
__invoke_impl(__invoke_memobj_ref, _MemPtr&& __f, _Tp&& __t)
{ return __invfwd<_Tp>(__t).*__f; }
template<typename _Res, typename _MemPtr, typename _Tp>
constexpr _Res
__invoke_impl(__invoke_memobj_deref, _MemPtr&& __f, _Tp&& __t)
{ return (*std::forward<_Tp>(__t)).*__f; }
/// Invoke a callable object.
template<typename _Callable, typename... _Args>
constexpr typename __invoke_result<_Callable, _Args...>::type
__invoke(_Callable&& __fn, _Args&&... __args)
noexcept(__is_nothrow_invocable<_Callable, _Args...>::value)
{
using __result = __invoke_result<_Callable, _Args...>;
using __type = typename __result::type;
using __tag = typename __result::__invoke_type;
return std::__invoke_impl<__type>(__tag{}, std::forward<_Callable>(__fn),
std::forward<_Args>(__args)...);
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // C++11
#endif // _GLIBCXX_INVOKE_H
c++/8/bits/range_access.h 0000644 00000023456 15201526705 0011027 0 ustar 00 // <range_access.h> -*- C++ -*-
// Copyright (C) 2010-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/range_access.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{iterator}
*/
#ifndef _GLIBCXX_RANGE_ACCESS_H
#define _GLIBCXX_RANGE_ACCESS_H 1
#pragma GCC system_header
#if __cplusplus >= 201103L
#include <initializer_list>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @brief Return an iterator pointing to the first element of
* the container.
* @param __cont Container.
*/
template<typename _Container>
inline _GLIBCXX17_CONSTEXPR auto
begin(_Container& __cont) -> decltype(__cont.begin())
{ return __cont.begin(); }
/**
* @brief Return an iterator pointing to the first element of
* the const container.
* @param __cont Container.
*/
template<typename _Container>
inline _GLIBCXX17_CONSTEXPR auto
begin(const _Container& __cont) -> decltype(__cont.begin())
{ return __cont.begin(); }
/**
* @brief Return an iterator pointing to one past the last element of
* the container.
* @param __cont Container.
*/
template<typename _Container>
inline _GLIBCXX17_CONSTEXPR auto
end(_Container& __cont) -> decltype(__cont.end())
{ return __cont.end(); }
/**
* @brief Return an iterator pointing to one past the last element of
* the const container.
* @param __cont Container.
*/
template<typename _Container>
inline _GLIBCXX17_CONSTEXPR auto
end(const _Container& __cont) -> decltype(__cont.end())
{ return __cont.end(); }
/**
* @brief Return an iterator pointing to the first element of the array.
* @param __arr Array.
*/
template<typename _Tp, size_t _Nm>
inline _GLIBCXX14_CONSTEXPR _Tp*
begin(_Tp (&__arr)[_Nm])
{ return __arr; }
/**
* @brief Return an iterator pointing to one past the last element
* of the array.
* @param __arr Array.
*/
template<typename _Tp, size_t _Nm>
inline _GLIBCXX14_CONSTEXPR _Tp*
end(_Tp (&__arr)[_Nm])
{ return __arr + _Nm; }
#if __cplusplus >= 201402L
template<typename _Tp> class valarray;
// These overloads must be declared for cbegin and cend to use them.
template<typename _Tp> _Tp* begin(valarray<_Tp>&);
template<typename _Tp> const _Tp* begin(const valarray<_Tp>&);
template<typename _Tp> _Tp* end(valarray<_Tp>&);
template<typename _Tp> const _Tp* end(const valarray<_Tp>&);
/**
* @brief Return an iterator pointing to the first element of
* the const container.
* @param __cont Container.
*/
template<typename _Container>
inline constexpr auto
cbegin(const _Container& __cont) noexcept(noexcept(std::begin(__cont)))
-> decltype(std::begin(__cont))
{ return std::begin(__cont); }
/**
* @brief Return an iterator pointing to one past the last element of
* the const container.
* @param __cont Container.
*/
template<typename _Container>
inline constexpr auto
cend(const _Container& __cont) noexcept(noexcept(std::end(__cont)))
-> decltype(std::end(__cont))
{ return std::end(__cont); }
/**
* @brief Return a reverse iterator pointing to the last element of
* the container.
* @param __cont Container.
*/
template<typename _Container>
inline _GLIBCXX17_CONSTEXPR auto
rbegin(_Container& __cont) -> decltype(__cont.rbegin())
{ return __cont.rbegin(); }
/**
* @brief Return a reverse iterator pointing to the last element of
* the const container.
* @param __cont Container.
*/
template<typename _Container>
inline _GLIBCXX17_CONSTEXPR auto
rbegin(const _Container& __cont) -> decltype(__cont.rbegin())
{ return __cont.rbegin(); }
/**
* @brief Return a reverse iterator pointing one past the first element of
* the container.
* @param __cont Container.
*/
template<typename _Container>
inline _GLIBCXX17_CONSTEXPR auto
rend(_Container& __cont) -> decltype(__cont.rend())
{ return __cont.rend(); }
/**
* @brief Return a reverse iterator pointing one past the first element of
* the const container.
* @param __cont Container.
*/
template<typename _Container>
inline _GLIBCXX17_CONSTEXPR auto
rend(const _Container& __cont) -> decltype(__cont.rend())
{ return __cont.rend(); }
/**
* @brief Return a reverse iterator pointing to the last element of
* the array.
* @param __arr Array.
*/
template<typename _Tp, size_t _Nm>
inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Tp*>
rbegin(_Tp (&__arr)[_Nm])
{ return reverse_iterator<_Tp*>(__arr + _Nm); }
/**
* @brief Return a reverse iterator pointing one past the first element of
* the array.
* @param __arr Array.
*/
template<typename _Tp, size_t _Nm>
inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Tp*>
rend(_Tp (&__arr)[_Nm])
{ return reverse_iterator<_Tp*>(__arr); }
/**
* @brief Return a reverse iterator pointing to the last element of
* the initializer_list.
* @param __il initializer_list.
*/
template<typename _Tp>
inline _GLIBCXX17_CONSTEXPR reverse_iterator<const _Tp*>
rbegin(initializer_list<_Tp> __il)
{ return reverse_iterator<const _Tp*>(__il.end()); }
/**
* @brief Return a reverse iterator pointing one past the first element of
* the initializer_list.
* @param __il initializer_list.
*/
template<typename _Tp>
inline _GLIBCXX17_CONSTEXPR reverse_iterator<const _Tp*>
rend(initializer_list<_Tp> __il)
{ return reverse_iterator<const _Tp*>(__il.begin()); }
/**
* @brief Return a reverse iterator pointing to the last element of
* the const container.
* @param __cont Container.
*/
template<typename _Container>
inline _GLIBCXX17_CONSTEXPR auto
crbegin(const _Container& __cont) -> decltype(std::rbegin(__cont))
{ return std::rbegin(__cont); }
/**
* @brief Return a reverse iterator pointing one past the first element of
* the const container.
* @param __cont Container.
*/
template<typename _Container>
inline _GLIBCXX17_CONSTEXPR auto
crend(const _Container& __cont) -> decltype(std::rend(__cont))
{ return std::rend(__cont); }
#endif // C++14
#if __cplusplus >= 201703L
#define __cpp_lib_nonmember_container_access 201411
/**
* @brief Return the size of a container.
* @param __cont Container.
*/
template <typename _Container>
constexpr auto
size(const _Container& __cont) noexcept(noexcept(__cont.size()))
-> decltype(__cont.size())
{ return __cont.size(); }
/**
* @brief Return the size of an array.
* @param __array Array.
*/
template <typename _Tp, size_t _Nm>
constexpr size_t
size(const _Tp (&/*__array*/)[_Nm]) noexcept
{ return _Nm; }
/**
* @brief Return whether a container is empty.
* @param __cont Container.
*/
template <typename _Container>
[[nodiscard]] constexpr auto
empty(const _Container& __cont) noexcept(noexcept(__cont.empty()))
-> decltype(__cont.empty())
{ return __cont.empty(); }
/**
* @brief Return whether an array is empty (always false).
* @param __array Container.
*/
template <typename _Tp, size_t _Nm>
[[nodiscard]] constexpr bool
empty(const _Tp (&/*__array*/)[_Nm]) noexcept
{ return false; }
/**
* @brief Return whether an initializer_list is empty.
* @param __il Initializer list.
*/
template <typename _Tp>
[[nodiscard]] constexpr bool
empty(initializer_list<_Tp> __il) noexcept
{ return __il.size() == 0;}
/**
* @brief Return the data pointer of a container.
* @param __cont Container.
*/
template <typename _Container>
constexpr auto
data(_Container& __cont) noexcept(noexcept(__cont.data()))
-> decltype(__cont.data())
{ return __cont.data(); }
/**
* @brief Return the data pointer of a const container.
* @param __cont Container.
*/
template <typename _Container>
constexpr auto
data(const _Container& __cont) noexcept(noexcept(__cont.data()))
-> decltype(__cont.data())
{ return __cont.data(); }
/**
* @brief Return the data pointer of an array.
* @param __array Array.
*/
template <typename _Tp, size_t _Nm>
constexpr _Tp*
data(_Tp (&__array)[_Nm]) noexcept
{ return __array; }
/**
* @brief Return the data pointer of an initializer list.
* @param __il Initializer list.
*/
template <typename _Tp>
constexpr const _Tp*
data(initializer_list<_Tp> __il) noexcept
{ return __il.begin(); }
#endif // C++17
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif // C++11
#endif // _GLIBCXX_RANGE_ACCESS_H
c++/8/bits/ostream_insert.h 0000644 00000007642 15201526705 0011447 0 ustar 00 // Helpers for ostream inserters -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/ostream_insert.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{ostream}
*/
#ifndef _OSTREAM_INSERT_H
#define _OSTREAM_INSERT_H 1
#pragma GCC system_header
#include <iosfwd>
#include <bits/cxxabi_forced.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _CharT, typename _Traits>
inline void
__ostream_write(basic_ostream<_CharT, _Traits>& __out,
const _CharT* __s, streamsize __n)
{
typedef basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const streamsize __put = __out.rdbuf()->sputn(__s, __n);
if (__put != __n)
__out.setstate(__ios_base::badbit);
}
template<typename _CharT, typename _Traits>
inline void
__ostream_fill(basic_ostream<_CharT, _Traits>& __out, streamsize __n)
{
typedef basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
const _CharT __c = __out.fill();
for (; __n > 0; --__n)
{
const typename _Traits::int_type __put = __out.rdbuf()->sputc(__c);
if (_Traits::eq_int_type(__put, _Traits::eof()))
{
__out.setstate(__ios_base::badbit);
break;
}
}
}
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
__ostream_insert(basic_ostream<_CharT, _Traits>& __out,
const _CharT* __s, streamsize __n)
{
typedef basic_ostream<_CharT, _Traits> __ostream_type;
typedef typename __ostream_type::ios_base __ios_base;
typename __ostream_type::sentry __cerb(__out);
if (__cerb)
{
__try
{
const streamsize __w = __out.width();
if (__w > __n)
{
const bool __left = ((__out.flags()
& __ios_base::adjustfield)
== __ios_base::left);
if (!__left)
__ostream_fill(__out, __w - __n);
if (__out.good())
__ostream_write(__out, __s, __n);
if (__left && __out.good())
__ostream_fill(__out, __w - __n);
}
else
__ostream_write(__out, __s, __n);
__out.width(0);
}
__catch(__cxxabiv1::__forced_unwind&)
{
__out._M_setstate(__ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ __out._M_setstate(__ios_base::badbit); }
}
return __out;
}
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
#if _GLIBCXX_EXTERN_TEMPLATE
extern template ostream& __ostream_insert(ostream&, const char*, streamsize);
#ifdef _GLIBCXX_USE_WCHAR_T
extern template wostream& __ostream_insert(wostream&, const wchar_t*,
streamsize);
#endif
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif /* _OSTREAM_INSERT_H */
c++/8/bits/move.h 0000644 00000014601 15201526705 0007350 0 ustar 00 // Move, forward and identity for C++11 + swap -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/move.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{utility}
*/
#ifndef _MOVE_H
#define _MOVE_H 1
#include <bits/c++config.h>
#include <bits/concept_check.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Used, in C++03 mode too, by allocators, etc.
/**
* @brief Same as C++11 std::addressof
* @ingroup utilities
*/
template<typename _Tp>
inline _GLIBCXX_CONSTEXPR _Tp*
__addressof(_Tp& __r) _GLIBCXX_NOEXCEPT
{ return __builtin_addressof(__r); }
#if __cplusplus >= 201103L
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#include <type_traits> // Brings in std::declval too.
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @addtogroup utilities
* @{
*/
/**
* @brief Forward an lvalue.
* @return The parameter cast to the specified type.
*
* This function is used to implement "perfect forwarding".
*/
template<typename _Tp>
constexpr _Tp&&
forward(typename std::remove_reference<_Tp>::type& __t) noexcept
{ return static_cast<_Tp&&>(__t); }
/**
* @brief Forward an rvalue.
* @return The parameter cast to the specified type.
*
* This function is used to implement "perfect forwarding".
*/
template<typename _Tp>
constexpr _Tp&&
forward(typename std::remove_reference<_Tp>::type&& __t) noexcept
{
static_assert(!std::is_lvalue_reference<_Tp>::value, "template argument"
" substituting _Tp is an lvalue reference type");
return static_cast<_Tp&&>(__t);
}
/**
* @brief Convert a value to an rvalue.
* @param __t A thing of arbitrary type.
* @return The parameter cast to an rvalue-reference to allow moving it.
*/
template<typename _Tp>
constexpr typename std::remove_reference<_Tp>::type&&
move(_Tp&& __t) noexcept
{ return static_cast<typename std::remove_reference<_Tp>::type&&>(__t); }
template<typename _Tp>
struct __move_if_noexcept_cond
: public __and_<__not_<is_nothrow_move_constructible<_Tp>>,
is_copy_constructible<_Tp>>::type { };
/**
* @brief Conditionally convert a value to an rvalue.
* @param __x A thing of arbitrary type.
* @return The parameter, possibly cast to an rvalue-reference.
*
* Same as std::move unless the type's move constructor could throw and the
* type is copyable, in which case an lvalue-reference is returned instead.
*/
template<typename _Tp>
constexpr typename
conditional<__move_if_noexcept_cond<_Tp>::value, const _Tp&, _Tp&&>::type
move_if_noexcept(_Tp& __x) noexcept
{ return std::move(__x); }
// declval, from type_traits.
#if __cplusplus > 201402L
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2296. std::addressof should be constexpr
# define __cpp_lib_addressof_constexpr 201603
#endif
/**
* @brief Returns the actual address of the object or function
* referenced by r, even in the presence of an overloaded
* operator&.
* @param __r Reference to an object or function.
* @return The actual address.
*/
template<typename _Tp>
inline _GLIBCXX17_CONSTEXPR _Tp*
addressof(_Tp& __r) noexcept
{ return std::__addressof(__r); }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2598. addressof works on temporaries
template<typename _Tp>
const _Tp* addressof(const _Tp&&) = delete;
// C++11 version of std::exchange for internal use.
template <typename _Tp, typename _Up = _Tp>
inline _Tp
__exchange(_Tp& __obj, _Up&& __new_val)
{
_Tp __old_val = std::move(__obj);
__obj = std::forward<_Up>(__new_val);
return __old_val;
}
/// @} group utilities
#define _GLIBCXX_MOVE(__val) std::move(__val)
#define _GLIBCXX_FORWARD(_Tp, __val) std::forward<_Tp>(__val)
#else
#define _GLIBCXX_MOVE(__val) (__val)
#define _GLIBCXX_FORWARD(_Tp, __val) (__val)
#endif
/**
* @addtogroup utilities
* @{
*/
/**
* @brief Swaps two values.
* @param __a A thing of arbitrary type.
* @param __b Another thing of arbitrary type.
* @return Nothing.
*/
template<typename _Tp>
inline
#if __cplusplus >= 201103L
typename enable_if<__and_<__not_<__is_tuple_like<_Tp>>,
is_move_constructible<_Tp>,
is_move_assignable<_Tp>>::value>::type
swap(_Tp& __a, _Tp& __b)
noexcept(__and_<is_nothrow_move_constructible<_Tp>,
is_nothrow_move_assignable<_Tp>>::value)
#else
void
swap(_Tp& __a, _Tp& __b)
#endif
{
// concept requirements
__glibcxx_function_requires(_SGIAssignableConcept<_Tp>)
_Tp __tmp = _GLIBCXX_MOVE(__a);
__a = _GLIBCXX_MOVE(__b);
__b = _GLIBCXX_MOVE(__tmp);
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 809. std::swap should be overloaded for array types.
/// Swap the contents of two arrays.
template<typename _Tp, size_t _Nm>
inline
#if __cplusplus >= 201103L
typename enable_if<__is_swappable<_Tp>::value>::type
swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
noexcept(__is_nothrow_swappable<_Tp>::value)
#else
void
swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
#endif
{
for (size_t __n = 0; __n < _Nm; ++__n)
swap(__a[__n], __b[__n]);
}
/// @} group utilities
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif /* _MOVE_H */
c++/8/bits/hashtable.h 0000644 00000220071 15201526705 0010335 0 ustar 00 // hashtable.h header -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/hashtable.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{unordered_map, unordered_set}
*/
#ifndef _HASHTABLE_H
#define _HASHTABLE_H 1
#pragma GCC system_header
#include <bits/hashtable_policy.h>
#if __cplusplus > 201402L
# include <bits/node_handle.h>
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp, typename _Hash>
using __cache_default
= __not_<__and_<// Do not cache for fast hasher.
__is_fast_hash<_Hash>,
// Mandatory to have erase not throwing.
__is_nothrow_invocable<const _Hash&, const _Tp&>>>;
/**
* Primary class template _Hashtable.
*
* @ingroup hashtable-detail
*
* @tparam _Value CopyConstructible type.
*
* @tparam _Key CopyConstructible type.
*
* @tparam _Alloc An allocator type
* ([lib.allocator.requirements]) whose _Alloc::value_type is
* _Value. As a conforming extension, we allow for
* _Alloc::value_type != _Value.
*
* @tparam _ExtractKey Function object that takes an object of type
* _Value and returns a value of type _Key.
*
* @tparam _Equal Function object that takes two objects of type k
* and returns a bool-like value that is true if the two objects
* are considered equal.
*
* @tparam _H1 The hash function. A unary function object with
* argument type _Key and result type size_t. Return values should
* be distributed over the entire range [0, numeric_limits<size_t>:::max()].
*
* @tparam _H2 The range-hashing function (in the terminology of
* Tavori and Dreizin). A binary function object whose argument
* types and result type are all size_t. Given arguments r and N,
* the return value is in the range [0, N).
*
* @tparam _Hash The ranged hash function (Tavori and Dreizin). A
* binary function whose argument types are _Key and size_t and
* whose result type is size_t. Given arguments k and N, the
* return value is in the range [0, N). Default: hash(k, N) =
* h2(h1(k), N). If _Hash is anything other than the default, _H1
* and _H2 are ignored.
*
* @tparam _RehashPolicy Policy class with three members, all of
* which govern the bucket count. _M_next_bkt(n) returns a bucket
* count no smaller than n. _M_bkt_for_elements(n) returns a
* bucket count appropriate for an element count of n.
* _M_need_rehash(n_bkt, n_elt, n_ins) determines whether, if the
* current bucket count is n_bkt and the current element count is
* n_elt, we need to increase the bucket count. If so, returns
* make_pair(true, n), where n is the new bucket count. If not,
* returns make_pair(false, <anything>)
*
* @tparam _Traits Compile-time class with three boolean
* std::integral_constant members: __cache_hash_code, __constant_iterators,
* __unique_keys.
*
* Each _Hashtable data structure has:
*
* - _Bucket[] _M_buckets
* - _Hash_node_base _M_before_begin
* - size_type _M_bucket_count
* - size_type _M_element_count
*
* with _Bucket being _Hash_node* and _Hash_node containing:
*
* - _Hash_node* _M_next
* - Tp _M_value
* - size_t _M_hash_code if cache_hash_code is true
*
* In terms of Standard containers the hashtable is like the aggregation of:
*
* - std::forward_list<_Node> containing the elements
* - std::vector<std::forward_list<_Node>::iterator> representing the buckets
*
* The non-empty buckets contain the node before the first node in the
* bucket. This design makes it possible to implement something like a
* std::forward_list::insert_after on container insertion and
* std::forward_list::erase_after on container erase
* calls. _M_before_begin is equivalent to
* std::forward_list::before_begin. Empty buckets contain
* nullptr. Note that one of the non-empty buckets contains
* &_M_before_begin which is not a dereferenceable node so the
* node pointer in a bucket shall never be dereferenced, only its
* next node can be.
*
* Walking through a bucket's nodes requires a check on the hash code to
* see if each node is still in the bucket. Such a design assumes a
* quite efficient hash functor and is one of the reasons it is
* highly advisable to set __cache_hash_code to true.
*
* The container iterators are simply built from nodes. This way
* incrementing the iterator is perfectly efficient independent of
* how many empty buckets there are in the container.
*
* On insert we compute the element's hash code and use it to find the
* bucket index. If the element must be inserted in an empty bucket
* we add it at the beginning of the singly linked list and make the
* bucket point to _M_before_begin. The bucket that used to point to
* _M_before_begin, if any, is updated to point to its new before
* begin node.
*
* On erase, the simple iterator design requires using the hash
* functor to get the index of the bucket to update. For this
* reason, when __cache_hash_code is set to false the hash functor must
* not throw and this is enforced by a static assertion.
*
* Functionality is implemented by decomposition into base classes,
* where the derived _Hashtable class is used in _Map_base,
* _Insert, _Rehash_base, and _Equality base classes to access the
* "this" pointer. _Hashtable_base is used in the base classes as a
* non-recursive, fully-completed-type so that detailed nested type
* information, such as iterator type and node type, can be
* used. This is similar to the "Curiously Recurring Template
* Pattern" (CRTP) technique, but uses a reconstructed, not
* explicitly passed, template pattern.
*
* Base class templates are:
* - __detail::_Hashtable_base
* - __detail::_Map_base
* - __detail::_Insert
* - __detail::_Rehash_base
* - __detail::_Equality
*/
template<typename _Key, typename _Value, typename _Alloc,
typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash,
typename _RehashPolicy, typename _Traits>
class _Hashtable
: public __detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal,
_H1, _H2, _Hash, _Traits>,
public __detail::_Map_base<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>,
public __detail::_Insert<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>,
public __detail::_Rehash_base<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>,
public __detail::_Equality<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>,
private __detail::_Hashtable_alloc<
__alloc_rebind<_Alloc,
__detail::_Hash_node<_Value,
_Traits::__hash_cached::value>>>
{
static_assert(is_same<typename remove_cv<_Value>::type, _Value>::value,
"unordered container must have a non-const, non-volatile value_type");
#ifdef __STRICT_ANSI__
static_assert(is_same<typename _Alloc::value_type, _Value>{},
"unordered container must have the same value_type as its allocator");
#endif
using __traits_type = _Traits;
using __hash_cached = typename __traits_type::__hash_cached;
using __node_type = __detail::_Hash_node<_Value, __hash_cached::value>;
using __node_alloc_type = __alloc_rebind<_Alloc, __node_type>;
using __hashtable_alloc = __detail::_Hashtable_alloc<__node_alloc_type>;
using __value_alloc_traits =
typename __hashtable_alloc::__value_alloc_traits;
using __node_alloc_traits =
typename __hashtable_alloc::__node_alloc_traits;
using __node_base = typename __hashtable_alloc::__node_base;
using __bucket_type = typename __hashtable_alloc::__bucket_type;
public:
typedef _Key key_type;
typedef _Value value_type;
typedef _Alloc allocator_type;
typedef _Equal key_equal;
// mapped_type, if present, comes from _Map_base.
// hasher, if present, comes from _Hash_code_base/_Hashtable_base.
typedef typename __value_alloc_traits::pointer pointer;
typedef typename __value_alloc_traits::const_pointer const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
private:
using __rehash_type = _RehashPolicy;
using __rehash_state = typename __rehash_type::_State;
using __constant_iterators = typename __traits_type::__constant_iterators;
using __unique_keys = typename __traits_type::__unique_keys;
using __key_extract = typename std::conditional<
__constant_iterators::value,
__detail::_Identity,
__detail::_Select1st>::type;
using __hashtable_base = __detail::
_Hashtable_base<_Key, _Value, _ExtractKey,
_Equal, _H1, _H2, _Hash, _Traits>;
using __hash_code_base = typename __hashtable_base::__hash_code_base;
using __hash_code = typename __hashtable_base::__hash_code;
using __ireturn_type = typename __hashtable_base::__ireturn_type;
using __map_base = __detail::_Map_base<_Key, _Value, _Alloc, _ExtractKey,
_Equal, _H1, _H2, _Hash,
_RehashPolicy, _Traits>;
using __rehash_base = __detail::_Rehash_base<_Key, _Value, _Alloc,
_ExtractKey, _Equal,
_H1, _H2, _Hash,
_RehashPolicy, _Traits>;
using __eq_base = __detail::_Equality<_Key, _Value, _Alloc, _ExtractKey,
_Equal, _H1, _H2, _Hash,
_RehashPolicy, _Traits>;
using __reuse_or_alloc_node_type =
__detail::_ReuseOrAllocNode<__node_alloc_type>;
// Metaprogramming for picking apart hash caching.
template<typename _Cond>
using __if_hash_cached = __or_<__not_<__hash_cached>, _Cond>;
template<typename _Cond>
using __if_hash_not_cached = __or_<__hash_cached, _Cond>;
// Compile-time diagnostics.
// _Hash_code_base has everything protected, so use this derived type to
// access it.
struct __hash_code_base_access : __hash_code_base
{ using __hash_code_base::_M_bucket_index; };
// Getting a bucket index from a node shall not throw because it is used
// in methods (erase, swap...) that shall not throw.
static_assert(noexcept(declval<const __hash_code_base_access&>()
._M_bucket_index((const __node_type*)nullptr,
(std::size_t)0)),
"Cache the hash code or qualify your functors involved"
" in hash code and bucket index computation with noexcept");
// Following two static assertions are necessary to guarantee
// that local_iterator will be default constructible.
// When hash codes are cached local iterator inherits from H2 functor
// which must then be default constructible.
static_assert(__if_hash_cached<is_default_constructible<_H2>>::value,
"Functor used to map hash code to bucket index"
" must be default constructible");
template<typename _Keya, typename _Valuea, typename _Alloca,
typename _ExtractKeya, typename _Equala,
typename _H1a, typename _H2a, typename _Hasha,
typename _RehashPolicya, typename _Traitsa,
bool _Unique_keysa>
friend struct __detail::_Map_base;
template<typename _Keya, typename _Valuea, typename _Alloca,
typename _ExtractKeya, typename _Equala,
typename _H1a, typename _H2a, typename _Hasha,
typename _RehashPolicya, typename _Traitsa>
friend struct __detail::_Insert_base;
template<typename _Keya, typename _Valuea, typename _Alloca,
typename _ExtractKeya, typename _Equala,
typename _H1a, typename _H2a, typename _Hasha,
typename _RehashPolicya, typename _Traitsa,
bool _Constant_iteratorsa>
friend struct __detail::_Insert;
public:
using size_type = typename __hashtable_base::size_type;
using difference_type = typename __hashtable_base::difference_type;
using iterator = typename __hashtable_base::iterator;
using const_iterator = typename __hashtable_base::const_iterator;
using local_iterator = typename __hashtable_base::local_iterator;
using const_local_iterator = typename __hashtable_base::
const_local_iterator;
#if __cplusplus > 201402L
using node_type = _Node_handle<_Key, _Value, __node_alloc_type>;
using insert_return_type = _Node_insert_return<iterator, node_type>;
#endif
private:
__bucket_type* _M_buckets = &_M_single_bucket;
size_type _M_bucket_count = 1;
__node_base _M_before_begin;
size_type _M_element_count = 0;
_RehashPolicy _M_rehash_policy;
// A single bucket used when only need for 1 bucket. Especially
// interesting in move semantic to leave hashtable with only 1 buckets
// which is not allocated so that we can have those operations noexcept
// qualified.
// Note that we can't leave hashtable with 0 bucket without adding
// numerous checks in the code to avoid 0 modulus.
__bucket_type _M_single_bucket = nullptr;
bool
_M_uses_single_bucket(__bucket_type* __bkts) const
{ return __builtin_expect(__bkts == &_M_single_bucket, false); }
bool
_M_uses_single_bucket() const
{ return _M_uses_single_bucket(_M_buckets); }
__hashtable_alloc&
_M_base_alloc() { return *this; }
__bucket_type*
_M_allocate_buckets(size_type __n)
{
if (__builtin_expect(__n == 1, false))
{
_M_single_bucket = nullptr;
return &_M_single_bucket;
}
return __hashtable_alloc::_M_allocate_buckets(__n);
}
void
_M_deallocate_buckets(__bucket_type* __bkts, size_type __n)
{
if (_M_uses_single_bucket(__bkts))
return;
__hashtable_alloc::_M_deallocate_buckets(__bkts, __n);
}
void
_M_deallocate_buckets()
{ _M_deallocate_buckets(_M_buckets, _M_bucket_count); }
// Gets bucket begin, deals with the fact that non-empty buckets contain
// their before begin node.
__node_type*
_M_bucket_begin(size_type __bkt) const;
__node_type*
_M_begin() const
{ return static_cast<__node_type*>(_M_before_begin._M_nxt); }
template<typename _NodeGenerator>
void
_M_assign(const _Hashtable&, const _NodeGenerator&);
void
_M_move_assign(_Hashtable&&, std::true_type);
void
_M_move_assign(_Hashtable&&, std::false_type);
void
_M_reset() noexcept;
_Hashtable(const _H1& __h1, const _H2& __h2, const _Hash& __h,
const _Equal& __eq, const _ExtractKey& __exk,
const allocator_type& __a)
: __hashtable_base(__exk, __h1, __h2, __h, __eq),
__hashtable_alloc(__node_alloc_type(__a))
{ }
public:
// Constructor, destructor, assignment, swap
_Hashtable() = default;
_Hashtable(size_type __bucket_hint,
const _H1&, const _H2&, const _Hash&,
const _Equal&, const _ExtractKey&,
const allocator_type&);
template<typename _InputIterator>
_Hashtable(_InputIterator __first, _InputIterator __last,
size_type __bucket_hint,
const _H1&, const _H2&, const _Hash&,
const _Equal&, const _ExtractKey&,
const allocator_type&);
_Hashtable(const _Hashtable&);
_Hashtable(_Hashtable&&) noexcept;
_Hashtable(const _Hashtable&, const allocator_type&);
_Hashtable(_Hashtable&&, const allocator_type&);
// Use delegating constructors.
explicit
_Hashtable(const allocator_type& __a)
: __hashtable_alloc(__node_alloc_type(__a))
{ }
explicit
_Hashtable(size_type __n,
const _H1& __hf = _H1(),
const key_equal& __eql = key_equal(),
const allocator_type& __a = allocator_type())
: _Hashtable(__n, __hf, _H2(), _Hash(), __eql,
__key_extract(), __a)
{ }
template<typename _InputIterator>
_Hashtable(_InputIterator __f, _InputIterator __l,
size_type __n = 0,
const _H1& __hf = _H1(),
const key_equal& __eql = key_equal(),
const allocator_type& __a = allocator_type())
: _Hashtable(__f, __l, __n, __hf, _H2(), _Hash(), __eql,
__key_extract(), __a)
{ }
_Hashtable(initializer_list<value_type> __l,
size_type __n = 0,
const _H1& __hf = _H1(),
const key_equal& __eql = key_equal(),
const allocator_type& __a = allocator_type())
: _Hashtable(__l.begin(), __l.end(), __n, __hf, _H2(), _Hash(), __eql,
__key_extract(), __a)
{ }
_Hashtable&
operator=(const _Hashtable& __ht);
_Hashtable&
operator=(_Hashtable&& __ht)
noexcept(__node_alloc_traits::_S_nothrow_move()
&& is_nothrow_move_assignable<_H1>::value
&& is_nothrow_move_assignable<_Equal>::value)
{
constexpr bool __move_storage =
__node_alloc_traits::_S_propagate_on_move_assign()
|| __node_alloc_traits::_S_always_equal();
_M_move_assign(std::move(__ht), __bool_constant<__move_storage>());
return *this;
}
_Hashtable&
operator=(initializer_list<value_type> __l)
{
__reuse_or_alloc_node_type __roan(_M_begin(), *this);
_M_before_begin._M_nxt = nullptr;
clear();
this->_M_insert_range(__l.begin(), __l.end(), __roan, __unique_keys());
return *this;
}
~_Hashtable() noexcept;
void
swap(_Hashtable&)
noexcept(__and_<__is_nothrow_swappable<_H1>,
__is_nothrow_swappable<_Equal>>::value);
// Basic container operations
iterator
begin() noexcept
{ return iterator(_M_begin()); }
const_iterator
begin() const noexcept
{ return const_iterator(_M_begin()); }
iterator
end() noexcept
{ return iterator(nullptr); }
const_iterator
end() const noexcept
{ return const_iterator(nullptr); }
const_iterator
cbegin() const noexcept
{ return const_iterator(_M_begin()); }
const_iterator
cend() const noexcept
{ return const_iterator(nullptr); }
size_type
size() const noexcept
{ return _M_element_count; }
bool
empty() const noexcept
{ return size() == 0; }
allocator_type
get_allocator() const noexcept
{ return allocator_type(this->_M_node_allocator()); }
size_type
max_size() const noexcept
{ return __node_alloc_traits::max_size(this->_M_node_allocator()); }
// Observers
key_equal
key_eq() const
{ return this->_M_eq(); }
// hash_function, if present, comes from _Hash_code_base.
// Bucket operations
size_type
bucket_count() const noexcept
{ return _M_bucket_count; }
size_type
max_bucket_count() const noexcept
{ return max_size(); }
size_type
bucket_size(size_type __n) const
{ return std::distance(begin(__n), end(__n)); }
size_type
bucket(const key_type& __k) const
{ return _M_bucket_index(__k, this->_M_hash_code(__k)); }
local_iterator
begin(size_type __n)
{
return local_iterator(*this, _M_bucket_begin(__n),
__n, _M_bucket_count);
}
local_iterator
end(size_type __n)
{ return local_iterator(*this, nullptr, __n, _M_bucket_count); }
const_local_iterator
begin(size_type __n) const
{
return const_local_iterator(*this, _M_bucket_begin(__n),
__n, _M_bucket_count);
}
const_local_iterator
end(size_type __n) const
{ return const_local_iterator(*this, nullptr, __n, _M_bucket_count); }
// DR 691.
const_local_iterator
cbegin(size_type __n) const
{
return const_local_iterator(*this, _M_bucket_begin(__n),
__n, _M_bucket_count);
}
const_local_iterator
cend(size_type __n) const
{ return const_local_iterator(*this, nullptr, __n, _M_bucket_count); }
float
load_factor() const noexcept
{
return static_cast<float>(size()) / static_cast<float>(bucket_count());
}
// max_load_factor, if present, comes from _Rehash_base.
// Generalization of max_load_factor. Extension, not found in
// TR1. Only useful if _RehashPolicy is something other than
// the default.
const _RehashPolicy&
__rehash_policy() const
{ return _M_rehash_policy; }
void
__rehash_policy(const _RehashPolicy& __pol)
{ _M_rehash_policy = __pol; }
// Lookup.
iterator
find(const key_type& __k);
const_iterator
find(const key_type& __k) const;
size_type
count(const key_type& __k) const;
std::pair<iterator, iterator>
equal_range(const key_type& __k);
std::pair<const_iterator, const_iterator>
equal_range(const key_type& __k) const;
protected:
// Bucket index computation helpers.
size_type
_M_bucket_index(__node_type* __n) const noexcept
{ return __hash_code_base::_M_bucket_index(__n, _M_bucket_count); }
size_type
_M_bucket_index(const key_type& __k, __hash_code __c) const
{ return __hash_code_base::_M_bucket_index(__k, __c, _M_bucket_count); }
// Find and insert helper functions and types
// Find the node before the one matching the criteria.
__node_base*
_M_find_before_node(size_type, const key_type&, __hash_code) const;
__node_type*
_M_find_node(size_type __bkt, const key_type& __key,
__hash_code __c) const
{
__node_base* __before_n = _M_find_before_node(__bkt, __key, __c);
if (__before_n)
return static_cast<__node_type*>(__before_n->_M_nxt);
return nullptr;
}
// Insert a node at the beginning of a bucket.
void
_M_insert_bucket_begin(size_type, __node_type*);
// Remove the bucket first node
void
_M_remove_bucket_begin(size_type __bkt, __node_type* __next_n,
size_type __next_bkt);
// Get the node before __n in the bucket __bkt
__node_base*
_M_get_previous_node(size_type __bkt, __node_base* __n);
// Insert node with hash code __code, in bucket bkt if no rehash (assumes
// no element with its key already present). Take ownership of the node,
// deallocate it on exception.
iterator
_M_insert_unique_node(size_type __bkt, __hash_code __code,
__node_type* __n, size_type __n_elt = 1);
// Insert node with hash code __code. Take ownership of the node,
// deallocate it on exception.
iterator
_M_insert_multi_node(__node_type* __hint,
__hash_code __code, __node_type* __n);
template<typename... _Args>
std::pair<iterator, bool>
_M_emplace(std::true_type, _Args&&... __args);
template<typename... _Args>
iterator
_M_emplace(std::false_type __uk, _Args&&... __args)
{ return _M_emplace(cend(), __uk, std::forward<_Args>(__args)...); }
// Emplace with hint, useless when keys are unique.
template<typename... _Args>
iterator
_M_emplace(const_iterator, std::true_type __uk, _Args&&... __args)
{ return _M_emplace(__uk, std::forward<_Args>(__args)...).first; }
template<typename... _Args>
iterator
_M_emplace(const_iterator, std::false_type, _Args&&... __args);
template<typename _Arg, typename _NodeGenerator>
std::pair<iterator, bool>
_M_insert(_Arg&&, const _NodeGenerator&, true_type, size_type = 1);
template<typename _Arg, typename _NodeGenerator>
iterator
_M_insert(_Arg&& __arg, const _NodeGenerator& __node_gen,
false_type __uk)
{
return _M_insert(cend(), std::forward<_Arg>(__arg), __node_gen,
__uk);
}
// Insert with hint, not used when keys are unique.
template<typename _Arg, typename _NodeGenerator>
iterator
_M_insert(const_iterator, _Arg&& __arg,
const _NodeGenerator& __node_gen, true_type __uk)
{
return
_M_insert(std::forward<_Arg>(__arg), __node_gen, __uk).first;
}
// Insert with hint when keys are not unique.
template<typename _Arg, typename _NodeGenerator>
iterator
_M_insert(const_iterator, _Arg&&,
const _NodeGenerator&, false_type);
size_type
_M_erase(std::true_type, const key_type&);
size_type
_M_erase(std::false_type, const key_type&);
iterator
_M_erase(size_type __bkt, __node_base* __prev_n, __node_type* __n);
public:
// Emplace
template<typename... _Args>
__ireturn_type
emplace(_Args&&... __args)
{ return _M_emplace(__unique_keys(), std::forward<_Args>(__args)...); }
template<typename... _Args>
iterator
emplace_hint(const_iterator __hint, _Args&&... __args)
{
return _M_emplace(__hint, __unique_keys(),
std::forward<_Args>(__args)...);
}
// Insert member functions via inheritance.
// Erase
iterator
erase(const_iterator);
// LWG 2059.
iterator
erase(iterator __it)
{ return erase(const_iterator(__it)); }
size_type
erase(const key_type& __k)
{ return _M_erase(__unique_keys(), __k); }
iterator
erase(const_iterator, const_iterator);
void
clear() noexcept;
// Set number of buckets to be appropriate for container of n element.
void rehash(size_type __n);
// DR 1189.
// reserve, if present, comes from _Rehash_base.
#if __cplusplus > 201402L
/// Re-insert an extracted node into a container with unique keys.
insert_return_type
_M_reinsert_node(node_type&& __nh)
{
insert_return_type __ret;
if (__nh.empty())
__ret.position = end();
else
{
__glibcxx_assert(get_allocator() == __nh.get_allocator());
const key_type& __k = __nh._M_key();
__hash_code __code = this->_M_hash_code(__k);
size_type __bkt = _M_bucket_index(__k, __code);
if (__node_type* __n = _M_find_node(__bkt, __k, __code))
{
__ret.node = std::move(__nh);
__ret.position = iterator(__n);
__ret.inserted = false;
}
else
{
__ret.position
= _M_insert_unique_node(__bkt, __code, __nh._M_ptr);
__nh._M_ptr = nullptr;
__ret.inserted = true;
}
}
return __ret;
}
/// Re-insert an extracted node into a container with equivalent keys.
iterator
_M_reinsert_node_multi(const_iterator __hint, node_type&& __nh)
{
iterator __ret;
if (__nh.empty())
__ret = end();
else
{
__glibcxx_assert(get_allocator() == __nh.get_allocator());
auto __code = this->_M_hash_code(__nh._M_key());
auto __node = std::exchange(__nh._M_ptr, nullptr);
// FIXME: this deallocates the node on exception.
__ret = _M_insert_multi_node(__hint._M_cur, __code, __node);
}
return __ret;
}
/// Extract a node.
node_type
extract(const_iterator __pos)
{
__node_type* __n = __pos._M_cur;
size_t __bkt = _M_bucket_index(__n);
// Look for previous node to unlink it from the erased one, this
// is why we need buckets to contain the before begin to make
// this search fast.
__node_base* __prev_n = _M_get_previous_node(__bkt, __n);
if (__prev_n == _M_buckets[__bkt])
_M_remove_bucket_begin(__bkt, __n->_M_next(),
__n->_M_nxt ? _M_bucket_index(__n->_M_next()) : 0);
else if (__n->_M_nxt)
{
size_type __next_bkt = _M_bucket_index(__n->_M_next());
if (__next_bkt != __bkt)
_M_buckets[__next_bkt] = __prev_n;
}
__prev_n->_M_nxt = __n->_M_nxt;
__n->_M_nxt = nullptr;
--_M_element_count;
return { __n, this->_M_node_allocator() };
}
/// Extract a node.
node_type
extract(const _Key& __k)
{
node_type __nh;
auto __pos = find(__k);
if (__pos != end())
__nh = extract(const_iterator(__pos));
return __nh;
}
/// Merge from a compatible container into one with unique keys.
template<typename _Compatible_Hashtable>
void
_M_merge_unique(_Compatible_Hashtable& __src) noexcept
{
static_assert(is_same_v<typename _Compatible_Hashtable::node_type,
node_type>, "Node types are compatible");
__glibcxx_assert(get_allocator() == __src.get_allocator());
auto __n_elt = __src.size();
for (auto __i = __src.begin(), __end = __src.end(); __i != __end;)
{
auto __pos = __i++;
const key_type& __k = this->_M_extract()(__pos._M_cur->_M_v());
__hash_code __code = this->_M_hash_code(__k);
size_type __bkt = _M_bucket_index(__k, __code);
if (_M_find_node(__bkt, __k, __code) == nullptr)
{
auto __nh = __src.extract(__pos);
_M_insert_unique_node(__bkt, __code, __nh._M_ptr, __n_elt);
__nh._M_ptr = nullptr;
__n_elt = 1;
}
else if (__n_elt != 1)
--__n_elt;
}
}
/// Merge from a compatible container into one with equivalent keys.
template<typename _Compatible_Hashtable>
void
_M_merge_multi(_Compatible_Hashtable& __src) noexcept
{
static_assert(is_same_v<typename _Compatible_Hashtable::node_type,
node_type>, "Node types are compatible");
__glibcxx_assert(get_allocator() == __src.get_allocator());
this->reserve(size() + __src.size());
for (auto __i = __src.begin(), __end = __src.end(); __i != __end;)
_M_reinsert_node_multi(cend(), __src.extract(__i++));
}
#endif // C++17
private:
// Helper rehash method used when keys are unique.
void _M_rehash_aux(size_type __n, std::true_type);
// Helper rehash method used when keys can be non-unique.
void _M_rehash_aux(size_type __n, std::false_type);
// Unconditionally change size of bucket array to n, restore
// hash policy state to __state on exception.
void _M_rehash(size_type __n, const __rehash_state& __state);
};
// Definitions of class template _Hashtable's out-of-line member functions.
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
auto
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
_M_bucket_begin(size_type __bkt) const
-> __node_type*
{
__node_base* __n = _M_buckets[__bkt];
return __n ? static_cast<__node_type*>(__n->_M_nxt) : nullptr;
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
_Hashtable(size_type __bucket_hint,
const _H1& __h1, const _H2& __h2, const _Hash& __h,
const _Equal& __eq, const _ExtractKey& __exk,
const allocator_type& __a)
: _Hashtable(__h1, __h2, __h, __eq, __exk, __a)
{
auto __bkt = _M_rehash_policy._M_next_bkt(__bucket_hint);
if (__bkt > _M_bucket_count)
{
_M_buckets = _M_allocate_buckets(__bkt);
_M_bucket_count = __bkt;
}
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
template<typename _InputIterator>
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
_Hashtable(_InputIterator __f, _InputIterator __l,
size_type __bucket_hint,
const _H1& __h1, const _H2& __h2, const _Hash& __h,
const _Equal& __eq, const _ExtractKey& __exk,
const allocator_type& __a)
: _Hashtable(__h1, __h2, __h, __eq, __exk, __a)
{
auto __nb_elems = __detail::__distance_fw(__f, __l);
auto __bkt_count =
_M_rehash_policy._M_next_bkt(
std::max(_M_rehash_policy._M_bkt_for_elements(__nb_elems),
__bucket_hint));
if (__bkt_count > _M_bucket_count)
{
_M_buckets = _M_allocate_buckets(__bkt_count);
_M_bucket_count = __bkt_count;
}
for (; __f != __l; ++__f)
this->insert(*__f);
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
auto
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
operator=(const _Hashtable& __ht)
-> _Hashtable&
{
if (&__ht == this)
return *this;
if (__node_alloc_traits::_S_propagate_on_copy_assign())
{
auto& __this_alloc = this->_M_node_allocator();
auto& __that_alloc = __ht._M_node_allocator();
if (!__node_alloc_traits::_S_always_equal()
&& __this_alloc != __that_alloc)
{
// Replacement allocator cannot free existing storage.
this->_M_deallocate_nodes(_M_begin());
_M_before_begin._M_nxt = nullptr;
_M_deallocate_buckets();
_M_buckets = nullptr;
std::__alloc_on_copy(__this_alloc, __that_alloc);
__hashtable_base::operator=(__ht);
_M_bucket_count = __ht._M_bucket_count;
_M_element_count = __ht._M_element_count;
_M_rehash_policy = __ht._M_rehash_policy;
__try
{
_M_assign(__ht,
[this](const __node_type* __n)
{ return this->_M_allocate_node(__n->_M_v()); });
}
__catch(...)
{
// _M_assign took care of deallocating all memory. Now we
// must make sure this instance remains in a usable state.
_M_reset();
__throw_exception_again;
}
return *this;
}
std::__alloc_on_copy(__this_alloc, __that_alloc);
}
// Reuse allocated buckets and nodes.
__bucket_type* __former_buckets = nullptr;
std::size_t __former_bucket_count = _M_bucket_count;
const __rehash_state& __former_state = _M_rehash_policy._M_state();
if (_M_bucket_count != __ht._M_bucket_count)
{
__former_buckets = _M_buckets;
_M_buckets = _M_allocate_buckets(__ht._M_bucket_count);
_M_bucket_count = __ht._M_bucket_count;
}
else
__builtin_memset(_M_buckets, 0,
_M_bucket_count * sizeof(__bucket_type));
__try
{
__hashtable_base::operator=(__ht);
_M_element_count = __ht._M_element_count;
_M_rehash_policy = __ht._M_rehash_policy;
__reuse_or_alloc_node_type __roan(_M_begin(), *this);
_M_before_begin._M_nxt = nullptr;
_M_assign(__ht,
[&__roan](const __node_type* __n)
{ return __roan(__n->_M_v()); });
if (__former_buckets)
_M_deallocate_buckets(__former_buckets, __former_bucket_count);
}
__catch(...)
{
if (__former_buckets)
{
// Restore previous buckets.
_M_deallocate_buckets();
_M_rehash_policy._M_reset(__former_state);
_M_buckets = __former_buckets;
_M_bucket_count = __former_bucket_count;
}
__builtin_memset(_M_buckets, 0,
_M_bucket_count * sizeof(__bucket_type));
__throw_exception_again;
}
return *this;
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
template<typename _NodeGenerator>
void
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
_M_assign(const _Hashtable& __ht, const _NodeGenerator& __node_gen)
{
__bucket_type* __buckets = nullptr;
if (!_M_buckets)
_M_buckets = __buckets = _M_allocate_buckets(_M_bucket_count);
__try
{
if (!__ht._M_before_begin._M_nxt)
return;
// First deal with the special first node pointed to by
// _M_before_begin.
__node_type* __ht_n = __ht._M_begin();
__node_type* __this_n = __node_gen(__ht_n);
this->_M_copy_code(__this_n, __ht_n);
_M_before_begin._M_nxt = __this_n;
_M_buckets[_M_bucket_index(__this_n)] = &_M_before_begin;
// Then deal with other nodes.
__node_base* __prev_n = __this_n;
for (__ht_n = __ht_n->_M_next(); __ht_n; __ht_n = __ht_n->_M_next())
{
__this_n = __node_gen(__ht_n);
__prev_n->_M_nxt = __this_n;
this->_M_copy_code(__this_n, __ht_n);
size_type __bkt = _M_bucket_index(__this_n);
if (!_M_buckets[__bkt])
_M_buckets[__bkt] = __prev_n;
__prev_n = __this_n;
}
}
__catch(...)
{
clear();
if (__buckets)
_M_deallocate_buckets();
__throw_exception_again;
}
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
void
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
_M_reset() noexcept
{
_M_rehash_policy._M_reset();
_M_bucket_count = 1;
_M_single_bucket = nullptr;
_M_buckets = &_M_single_bucket;
_M_before_begin._M_nxt = nullptr;
_M_element_count = 0;
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
void
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
_M_move_assign(_Hashtable&& __ht, std::true_type)
{
this->_M_deallocate_nodes(_M_begin());
_M_deallocate_buckets();
__hashtable_base::operator=(std::move(__ht));
_M_rehash_policy = __ht._M_rehash_policy;
if (!__ht._M_uses_single_bucket())
_M_buckets = __ht._M_buckets;
else
{
_M_buckets = &_M_single_bucket;
_M_single_bucket = __ht._M_single_bucket;
}
_M_bucket_count = __ht._M_bucket_count;
_M_before_begin._M_nxt = __ht._M_before_begin._M_nxt;
_M_element_count = __ht._M_element_count;
std::__alloc_on_move(this->_M_node_allocator(), __ht._M_node_allocator());
// Fix buckets containing the _M_before_begin pointers that can't be
// moved.
if (_M_begin())
_M_buckets[_M_bucket_index(_M_begin())] = &_M_before_begin;
__ht._M_reset();
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
void
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
_M_move_assign(_Hashtable&& __ht, std::false_type)
{
if (__ht._M_node_allocator() == this->_M_node_allocator())
_M_move_assign(std::move(__ht), std::true_type());
else
{
// Can't move memory, move elements then.
__bucket_type* __former_buckets = nullptr;
size_type __former_bucket_count = _M_bucket_count;
const __rehash_state& __former_state = _M_rehash_policy._M_state();
if (_M_bucket_count != __ht._M_bucket_count)
{
__former_buckets = _M_buckets;
_M_buckets = _M_allocate_buckets(__ht._M_bucket_count);
_M_bucket_count = __ht._M_bucket_count;
}
else
__builtin_memset(_M_buckets, 0,
_M_bucket_count * sizeof(__bucket_type));
__try
{
__hashtable_base::operator=(std::move(__ht));
_M_element_count = __ht._M_element_count;
_M_rehash_policy = __ht._M_rehash_policy;
__reuse_or_alloc_node_type __roan(_M_begin(), *this);
_M_before_begin._M_nxt = nullptr;
_M_assign(__ht,
[&__roan](__node_type* __n)
{ return __roan(std::move_if_noexcept(__n->_M_v())); });
if (__former_buckets)
_M_deallocate_buckets(__former_buckets, __former_bucket_count);
__ht.clear();
}
__catch(...)
{
if (__former_buckets)
{
_M_deallocate_buckets();
_M_rehash_policy._M_reset(__former_state);
_M_buckets = __former_buckets;
_M_bucket_count = __former_bucket_count;
}
__builtin_memset(_M_buckets, 0,
_M_bucket_count * sizeof(__bucket_type));
__throw_exception_again;
}
}
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
_Hashtable(const _Hashtable& __ht)
: __hashtable_base(__ht),
__map_base(__ht),
__rehash_base(__ht),
__hashtable_alloc(
__node_alloc_traits::_S_select_on_copy(__ht._M_node_allocator())),
_M_buckets(nullptr),
_M_bucket_count(__ht._M_bucket_count),
_M_element_count(__ht._M_element_count),
_M_rehash_policy(__ht._M_rehash_policy)
{
_M_assign(__ht,
[this](const __node_type* __n)
{ return this->_M_allocate_node(__n->_M_v()); });
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
_Hashtable(_Hashtable&& __ht) noexcept
: __hashtable_base(__ht),
__map_base(__ht),
__rehash_base(__ht),
__hashtable_alloc(std::move(__ht._M_base_alloc())),
_M_buckets(__ht._M_buckets),
_M_bucket_count(__ht._M_bucket_count),
_M_before_begin(__ht._M_before_begin._M_nxt),
_M_element_count(__ht._M_element_count),
_M_rehash_policy(__ht._M_rehash_policy)
{
// Update, if necessary, buckets if __ht is using its single bucket.
if (__ht._M_uses_single_bucket())
{
_M_buckets = &_M_single_bucket;
_M_single_bucket = __ht._M_single_bucket;
}
// Update, if necessary, bucket pointing to before begin that hasn't
// moved.
if (_M_begin())
_M_buckets[_M_bucket_index(_M_begin())] = &_M_before_begin;
__ht._M_reset();
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
_Hashtable(const _Hashtable& __ht, const allocator_type& __a)
: __hashtable_base(__ht),
__map_base(__ht),
__rehash_base(__ht),
__hashtable_alloc(__node_alloc_type(__a)),
_M_buckets(),
_M_bucket_count(__ht._M_bucket_count),
_M_element_count(__ht._M_element_count),
_M_rehash_policy(__ht._M_rehash_policy)
{
_M_assign(__ht,
[this](const __node_type* __n)
{ return this->_M_allocate_node(__n->_M_v()); });
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
_Hashtable(_Hashtable&& __ht, const allocator_type& __a)
: __hashtable_base(__ht),
__map_base(__ht),
__rehash_base(__ht),
__hashtable_alloc(__node_alloc_type(__a)),
_M_buckets(nullptr),
_M_bucket_count(__ht._M_bucket_count),
_M_element_count(__ht._M_element_count),
_M_rehash_policy(__ht._M_rehash_policy)
{
if (__ht._M_node_allocator() == this->_M_node_allocator())
{
if (__ht._M_uses_single_bucket())
{
_M_buckets = &_M_single_bucket;
_M_single_bucket = __ht._M_single_bucket;
}
else
_M_buckets = __ht._M_buckets;
_M_before_begin._M_nxt = __ht._M_before_begin._M_nxt;
// Update, if necessary, bucket pointing to before begin that hasn't
// moved.
if (_M_begin())
_M_buckets[_M_bucket_index(_M_begin())] = &_M_before_begin;
__ht._M_reset();
}
else
{
_M_assign(__ht,
[this](__node_type* __n)
{
return this->_M_allocate_node(
std::move_if_noexcept(__n->_M_v()));
});
__ht.clear();
}
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
~_Hashtable() noexcept
{
clear();
_M_deallocate_buckets();
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
void
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
swap(_Hashtable& __x)
noexcept(__and_<__is_nothrow_swappable<_H1>,
__is_nothrow_swappable<_Equal>>::value)
{
// The only base class with member variables is hash_code_base.
// We define _Hash_code_base::_M_swap because different
// specializations have different members.
this->_M_swap(__x);
std::__alloc_on_swap(this->_M_node_allocator(), __x._M_node_allocator());
std::swap(_M_rehash_policy, __x._M_rehash_policy);
// Deal properly with potentially moved instances.
if (this->_M_uses_single_bucket())
{
if (!__x._M_uses_single_bucket())
{
_M_buckets = __x._M_buckets;
__x._M_buckets = &__x._M_single_bucket;
}
}
else if (__x._M_uses_single_bucket())
{
__x._M_buckets = _M_buckets;
_M_buckets = &_M_single_bucket;
}
else
std::swap(_M_buckets, __x._M_buckets);
std::swap(_M_bucket_count, __x._M_bucket_count);
std::swap(_M_before_begin._M_nxt, __x._M_before_begin._M_nxt);
std::swap(_M_element_count, __x._M_element_count);
std::swap(_M_single_bucket, __x._M_single_bucket);
// Fix buckets containing the _M_before_begin pointers that can't be
// swapped.
if (_M_begin())
_M_buckets[_M_bucket_index(_M_begin())] = &_M_before_begin;
if (__x._M_begin())
__x._M_buckets[__x._M_bucket_index(__x._M_begin())]
= &__x._M_before_begin;
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
auto
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
find(const key_type& __k)
-> iterator
{
__hash_code __code = this->_M_hash_code(__k);
std::size_t __n = _M_bucket_index(__k, __code);
__node_type* __p = _M_find_node(__n, __k, __code);
return __p ? iterator(__p) : end();
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
auto
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
find(const key_type& __k) const
-> const_iterator
{
__hash_code __code = this->_M_hash_code(__k);
std::size_t __n = _M_bucket_index(__k, __code);
__node_type* __p = _M_find_node(__n, __k, __code);
return __p ? const_iterator(__p) : end();
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
auto
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
count(const key_type& __k) const
-> size_type
{
__hash_code __code = this->_M_hash_code(__k);
std::size_t __n = _M_bucket_index(__k, __code);
__node_type* __p = _M_bucket_begin(__n);
if (!__p)
return 0;
std::size_t __result = 0;
for (;; __p = __p->_M_next())
{
if (this->_M_equals(__k, __code, __p))
++__result;
else if (__result)
// All equivalent values are next to each other, if we
// found a non-equivalent value after an equivalent one it
// means that we won't find any new equivalent value.
break;
if (!__p->_M_nxt || _M_bucket_index(__p->_M_next()) != __n)
break;
}
return __result;
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
auto
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
equal_range(const key_type& __k)
-> pair<iterator, iterator>
{
__hash_code __code = this->_M_hash_code(__k);
std::size_t __n = _M_bucket_index(__k, __code);
__node_type* __p = _M_find_node(__n, __k, __code);
if (__p)
{
__node_type* __p1 = __p->_M_next();
while (__p1 && _M_bucket_index(__p1) == __n
&& this->_M_equals(__k, __code, __p1))
__p1 = __p1->_M_next();
return std::make_pair(iterator(__p), iterator(__p1));
}
else
return std::make_pair(end(), end());
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
auto
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
equal_range(const key_type& __k) const
-> pair<const_iterator, const_iterator>
{
__hash_code __code = this->_M_hash_code(__k);
std::size_t __n = _M_bucket_index(__k, __code);
__node_type* __p = _M_find_node(__n, __k, __code);
if (__p)
{
__node_type* __p1 = __p->_M_next();
while (__p1 && _M_bucket_index(__p1) == __n
&& this->_M_equals(__k, __code, __p1))
__p1 = __p1->_M_next();
return std::make_pair(const_iterator(__p), const_iterator(__p1));
}
else
return std::make_pair(end(), end());
}
// Find the node whose key compares equal to k in the bucket n.
// Return nullptr if no node is found.
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
auto
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
_M_find_before_node(size_type __n, const key_type& __k,
__hash_code __code) const
-> __node_base*
{
__node_base* __prev_p = _M_buckets[__n];
if (!__prev_p)
return nullptr;
for (__node_type* __p = static_cast<__node_type*>(__prev_p->_M_nxt);;
__p = __p->_M_next())
{
if (this->_M_equals(__k, __code, __p))
return __prev_p;
if (!__p->_M_nxt || _M_bucket_index(__p->_M_next()) != __n)
break;
__prev_p = __p;
}
return nullptr;
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
void
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
_M_insert_bucket_begin(size_type __bkt, __node_type* __node)
{
if (_M_buckets[__bkt])
{
// Bucket is not empty, we just need to insert the new node
// after the bucket before begin.
__node->_M_nxt = _M_buckets[__bkt]->_M_nxt;
_M_buckets[__bkt]->_M_nxt = __node;
}
else
{
// The bucket is empty, the new node is inserted at the
// beginning of the singly-linked list and the bucket will
// contain _M_before_begin pointer.
__node->_M_nxt = _M_before_begin._M_nxt;
_M_before_begin._M_nxt = __node;
if (__node->_M_nxt)
// We must update former begin bucket that is pointing to
// _M_before_begin.
_M_buckets[_M_bucket_index(__node->_M_next())] = __node;
_M_buckets[__bkt] = &_M_before_begin;
}
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
void
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
_M_remove_bucket_begin(size_type __bkt, __node_type* __next,
size_type __next_bkt)
{
if (!__next || __next_bkt != __bkt)
{
// Bucket is now empty
// First update next bucket if any
if (__next)
_M_buckets[__next_bkt] = _M_buckets[__bkt];
// Second update before begin node if necessary
if (&_M_before_begin == _M_buckets[__bkt])
_M_before_begin._M_nxt = __next;
_M_buckets[__bkt] = nullptr;
}
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
auto
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
_M_get_previous_node(size_type __bkt, __node_base* __n)
-> __node_base*
{
__node_base* __prev_n = _M_buckets[__bkt];
while (__prev_n->_M_nxt != __n)
__prev_n = __prev_n->_M_nxt;
return __prev_n;
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
template<typename... _Args>
auto
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
_M_emplace(std::true_type, _Args&&... __args)
-> pair<iterator, bool>
{
// First build the node to get access to the hash code
__node_type* __node = this->_M_allocate_node(std::forward<_Args>(__args)...);
const key_type& __k = this->_M_extract()(__node->_M_v());
__hash_code __code;
__try
{
__code = this->_M_hash_code(__k);
}
__catch(...)
{
this->_M_deallocate_node(__node);
__throw_exception_again;
}
size_type __bkt = _M_bucket_index(__k, __code);
if (__node_type* __p = _M_find_node(__bkt, __k, __code))
{
// There is already an equivalent node, no insertion
this->_M_deallocate_node(__node);
return std::make_pair(iterator(__p), false);
}
// Insert the node
return std::make_pair(_M_insert_unique_node(__bkt, __code, __node),
true);
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
template<typename... _Args>
auto
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
_M_emplace(const_iterator __hint, std::false_type, _Args&&... __args)
-> iterator
{
// First build the node to get its hash code.
__node_type* __node =
this->_M_allocate_node(std::forward<_Args>(__args)...);
__hash_code __code;
__try
{
__code = this->_M_hash_code(this->_M_extract()(__node->_M_v()));
}
__catch(...)
{
this->_M_deallocate_node(__node);
__throw_exception_again;
}
return _M_insert_multi_node(__hint._M_cur, __code, __node);
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
auto
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
_M_insert_unique_node(size_type __bkt, __hash_code __code,
__node_type* __node, size_type __n_elt)
-> iterator
{
const __rehash_state& __saved_state = _M_rehash_policy._M_state();
std::pair<bool, std::size_t> __do_rehash
= _M_rehash_policy._M_need_rehash(_M_bucket_count, _M_element_count,
__n_elt);
__try
{
if (__do_rehash.first)
{
_M_rehash(__do_rehash.second, __saved_state);
__bkt = _M_bucket_index(this->_M_extract()(__node->_M_v()), __code);
}
this->_M_store_code(__node, __code);
// Always insert at the beginning of the bucket.
_M_insert_bucket_begin(__bkt, __node);
++_M_element_count;
return iterator(__node);
}
__catch(...)
{
this->_M_deallocate_node(__node);
__throw_exception_again;
}
}
// Insert node, in bucket bkt if no rehash (assumes no element with its key
// already present). Take ownership of the node, deallocate it on exception.
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
auto
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
_M_insert_multi_node(__node_type* __hint, __hash_code __code,
__node_type* __node)
-> iterator
{
const __rehash_state& __saved_state = _M_rehash_policy._M_state();
std::pair<bool, std::size_t> __do_rehash
= _M_rehash_policy._M_need_rehash(_M_bucket_count, _M_element_count, 1);
__try
{
if (__do_rehash.first)
_M_rehash(__do_rehash.second, __saved_state);
this->_M_store_code(__node, __code);
const key_type& __k = this->_M_extract()(__node->_M_v());
size_type __bkt = _M_bucket_index(__k, __code);
// Find the node before an equivalent one or use hint if it exists and
// if it is equivalent.
__node_base* __prev
= __builtin_expect(__hint != nullptr, false)
&& this->_M_equals(__k, __code, __hint)
? __hint
: _M_find_before_node(__bkt, __k, __code);
if (__prev)
{
// Insert after the node before the equivalent one.
__node->_M_nxt = __prev->_M_nxt;
__prev->_M_nxt = __node;
if (__builtin_expect(__prev == __hint, false))
// hint might be the last bucket node, in this case we need to
// update next bucket.
if (__node->_M_nxt
&& !this->_M_equals(__k, __code, __node->_M_next()))
{
size_type __next_bkt = _M_bucket_index(__node->_M_next());
if (__next_bkt != __bkt)
_M_buckets[__next_bkt] = __node;
}
}
else
// The inserted node has no equivalent in the
// hashtable. We must insert the new node at the
// beginning of the bucket to preserve equivalent
// elements' relative positions.
_M_insert_bucket_begin(__bkt, __node);
++_M_element_count;
return iterator(__node);
}
__catch(...)
{
this->_M_deallocate_node(__node);
__throw_exception_again;
}
}
// Insert v if no element with its key is already present.
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
template<typename _Arg, typename _NodeGenerator>
auto
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
_M_insert(_Arg&& __v, const _NodeGenerator& __node_gen, true_type,
size_type __n_elt)
-> pair<iterator, bool>
{
const key_type& __k = this->_M_extract()(__v);
__hash_code __code = this->_M_hash_code(__k);
size_type __bkt = _M_bucket_index(__k, __code);
__node_type* __n = _M_find_node(__bkt, __k, __code);
if (__n)
return std::make_pair(iterator(__n), false);
__n = __node_gen(std::forward<_Arg>(__v));
return { _M_insert_unique_node(__bkt, __code, __n, __n_elt), true };
}
// Insert v unconditionally.
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
template<typename _Arg, typename _NodeGenerator>
auto
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
_M_insert(const_iterator __hint, _Arg&& __v,
const _NodeGenerator& __node_gen, false_type)
-> iterator
{
// First compute the hash code so that we don't do anything if it
// throws.
__hash_code __code = this->_M_hash_code(this->_M_extract()(__v));
// Second allocate new node so that we don't rehash if it throws.
__node_type* __node = __node_gen(std::forward<_Arg>(__v));
return _M_insert_multi_node(__hint._M_cur, __code, __node);
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
auto
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
erase(const_iterator __it)
-> iterator
{
__node_type* __n = __it._M_cur;
std::size_t __bkt = _M_bucket_index(__n);
// Look for previous node to unlink it from the erased one, this
// is why we need buckets to contain the before begin to make
// this search fast.
__node_base* __prev_n = _M_get_previous_node(__bkt, __n);
return _M_erase(__bkt, __prev_n, __n);
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
auto
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
_M_erase(size_type __bkt, __node_base* __prev_n, __node_type* __n)
-> iterator
{
if (__prev_n == _M_buckets[__bkt])
_M_remove_bucket_begin(__bkt, __n->_M_next(),
__n->_M_nxt ? _M_bucket_index(__n->_M_next()) : 0);
else if (__n->_M_nxt)
{
size_type __next_bkt = _M_bucket_index(__n->_M_next());
if (__next_bkt != __bkt)
_M_buckets[__next_bkt] = __prev_n;
}
__prev_n->_M_nxt = __n->_M_nxt;
iterator __result(__n->_M_next());
this->_M_deallocate_node(__n);
--_M_element_count;
return __result;
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
auto
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
_M_erase(std::true_type, const key_type& __k)
-> size_type
{
__hash_code __code = this->_M_hash_code(__k);
std::size_t __bkt = _M_bucket_index(__k, __code);
// Look for the node before the first matching node.
__node_base* __prev_n = _M_find_before_node(__bkt, __k, __code);
if (!__prev_n)
return 0;
// We found a matching node, erase it.
__node_type* __n = static_cast<__node_type*>(__prev_n->_M_nxt);
_M_erase(__bkt, __prev_n, __n);
return 1;
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
auto
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
_M_erase(std::false_type, const key_type& __k)
-> size_type
{
__hash_code __code = this->_M_hash_code(__k);
std::size_t __bkt = _M_bucket_index(__k, __code);
// Look for the node before the first matching node.
__node_base* __prev_n = _M_find_before_node(__bkt, __k, __code);
if (!__prev_n)
return 0;
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 526. Is it undefined if a function in the standard changes
// in parameters?
// We use one loop to find all matching nodes and another to deallocate
// them so that the key stays valid during the first loop. It might be
// invalidated indirectly when destroying nodes.
__node_type* __n = static_cast<__node_type*>(__prev_n->_M_nxt);
__node_type* __n_last = __n;
std::size_t __n_last_bkt = __bkt;
do
{
__n_last = __n_last->_M_next();
if (!__n_last)
break;
__n_last_bkt = _M_bucket_index(__n_last);
}
while (__n_last_bkt == __bkt && this->_M_equals(__k, __code, __n_last));
// Deallocate nodes.
size_type __result = 0;
do
{
__node_type* __p = __n->_M_next();
this->_M_deallocate_node(__n);
__n = __p;
++__result;
--_M_element_count;
}
while (__n != __n_last);
if (__prev_n == _M_buckets[__bkt])
_M_remove_bucket_begin(__bkt, __n_last, __n_last_bkt);
else if (__n_last && __n_last_bkt != __bkt)
_M_buckets[__n_last_bkt] = __prev_n;
__prev_n->_M_nxt = __n_last;
return __result;
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
auto
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
erase(const_iterator __first, const_iterator __last)
-> iterator
{
__node_type* __n = __first._M_cur;
__node_type* __last_n = __last._M_cur;
if (__n == __last_n)
return iterator(__n);
std::size_t __bkt = _M_bucket_index(__n);
__node_base* __prev_n = _M_get_previous_node(__bkt, __n);
bool __is_bucket_begin = __n == _M_bucket_begin(__bkt);
std::size_t __n_bkt = __bkt;
for (;;)
{
do
{
__node_type* __tmp = __n;
__n = __n->_M_next();
this->_M_deallocate_node(__tmp);
--_M_element_count;
if (!__n)
break;
__n_bkt = _M_bucket_index(__n);
}
while (__n != __last_n && __n_bkt == __bkt);
if (__is_bucket_begin)
_M_remove_bucket_begin(__bkt, __n, __n_bkt);
if (__n == __last_n)
break;
__is_bucket_begin = true;
__bkt = __n_bkt;
}
if (__n && (__n_bkt != __bkt || __is_bucket_begin))
_M_buckets[__n_bkt] = __prev_n;
__prev_n->_M_nxt = __n;
return iterator(__n);
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
void
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
clear() noexcept
{
this->_M_deallocate_nodes(_M_begin());
__builtin_memset(_M_buckets, 0, _M_bucket_count * sizeof(__bucket_type));
_M_element_count = 0;
_M_before_begin._M_nxt = nullptr;
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
void
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
rehash(size_type __n)
{
const __rehash_state& __saved_state = _M_rehash_policy._M_state();
std::size_t __buckets
= std::max(_M_rehash_policy._M_bkt_for_elements(_M_element_count + 1),
__n);
__buckets = _M_rehash_policy._M_next_bkt(__buckets);
if (__buckets != _M_bucket_count)
_M_rehash(__buckets, __saved_state);
else
// No rehash, restore previous state to keep a consistent state.
_M_rehash_policy._M_reset(__saved_state);
}
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
void
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
_M_rehash(size_type __n, const __rehash_state& __state)
{
__try
{
_M_rehash_aux(__n, __unique_keys());
}
__catch(...)
{
// A failure here means that buckets allocation failed. We only
// have to restore hash policy previous state.
_M_rehash_policy._M_reset(__state);
__throw_exception_again;
}
}
// Rehash when there is no equivalent elements.
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
void
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
_M_rehash_aux(size_type __n, std::true_type)
{
__bucket_type* __new_buckets = _M_allocate_buckets(__n);
__node_type* __p = _M_begin();
_M_before_begin._M_nxt = nullptr;
std::size_t __bbegin_bkt = 0;
while (__p)
{
__node_type* __next = __p->_M_next();
std::size_t __bkt = __hash_code_base::_M_bucket_index(__p, __n);
if (!__new_buckets[__bkt])
{
__p->_M_nxt = _M_before_begin._M_nxt;
_M_before_begin._M_nxt = __p;
__new_buckets[__bkt] = &_M_before_begin;
if (__p->_M_nxt)
__new_buckets[__bbegin_bkt] = __p;
__bbegin_bkt = __bkt;
}
else
{
__p->_M_nxt = __new_buckets[__bkt]->_M_nxt;
__new_buckets[__bkt]->_M_nxt = __p;
}
__p = __next;
}
_M_deallocate_buckets();
_M_bucket_count = __n;
_M_buckets = __new_buckets;
}
// Rehash when there can be equivalent elements, preserve their relative
// order.
template<typename _Key, typename _Value,
typename _Alloc, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
typename _Traits>
void
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
_M_rehash_aux(size_type __n, std::false_type)
{
__bucket_type* __new_buckets = _M_allocate_buckets(__n);
__node_type* __p = _M_begin();
_M_before_begin._M_nxt = nullptr;
std::size_t __bbegin_bkt = 0;
std::size_t __prev_bkt = 0;
__node_type* __prev_p = nullptr;
bool __check_bucket = false;
while (__p)
{
__node_type* __next = __p->_M_next();
std::size_t __bkt = __hash_code_base::_M_bucket_index(__p, __n);
if (__prev_p && __prev_bkt == __bkt)
{
// Previous insert was already in this bucket, we insert after
// the previously inserted one to preserve equivalent elements
// relative order.
__p->_M_nxt = __prev_p->_M_nxt;
__prev_p->_M_nxt = __p;
// Inserting after a node in a bucket require to check that we
// haven't change the bucket last node, in this case next
// bucket containing its before begin node must be updated. We
// schedule a check as soon as we move out of the sequence of
// equivalent nodes to limit the number of checks.
__check_bucket = true;
}
else
{
if (__check_bucket)
{
// Check if we shall update the next bucket because of
// insertions into __prev_bkt bucket.
if (__prev_p->_M_nxt)
{
std::size_t __next_bkt
= __hash_code_base::_M_bucket_index(__prev_p->_M_next(),
__n);
if (__next_bkt != __prev_bkt)
__new_buckets[__next_bkt] = __prev_p;
}
__check_bucket = false;
}
if (!__new_buckets[__bkt])
{
__p->_M_nxt = _M_before_begin._M_nxt;
_M_before_begin._M_nxt = __p;
__new_buckets[__bkt] = &_M_before_begin;
if (__p->_M_nxt)
__new_buckets[__bbegin_bkt] = __p;
__bbegin_bkt = __bkt;
}
else
{
__p->_M_nxt = __new_buckets[__bkt]->_M_nxt;
__new_buckets[__bkt]->_M_nxt = __p;
}
}
__prev_p = __p;
__prev_bkt = __bkt;
__p = __next;
}
if (__check_bucket && __prev_p->_M_nxt)
{
std::size_t __next_bkt
= __hash_code_base::_M_bucket_index(__prev_p->_M_next(), __n);
if (__next_bkt != __prev_bkt)
__new_buckets[__next_bkt] = __prev_p;
}
_M_deallocate_buckets();
_M_bucket_count = __n;
_M_buckets = __new_buckets;
}
#if __cplusplus > 201402L
template<typename, typename, typename> class _Hash_merge_helper { };
#endif // C++17
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // _HASHTABLE_H
c++/8/bits/list.tcc 0000644 00000037150 15201526705 0007703 0 ustar 00 // List implementation (out of line) -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1996,1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file bits/list.tcc
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{list}
*/
#ifndef _LIST_TCC
#define _LIST_TCC 1
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Tp, typename _Alloc>
void
_List_base<_Tp, _Alloc>::
_M_clear() _GLIBCXX_NOEXCEPT
{
typedef _List_node<_Tp> _Node;
__detail::_List_node_base* __cur = _M_impl._M_node._M_next;
while (__cur != &_M_impl._M_node)
{
_Node* __tmp = static_cast<_Node*>(__cur);
__cur = __tmp->_M_next;
_Tp* __val = __tmp->_M_valptr();
#if __cplusplus >= 201103L
_Node_alloc_traits::destroy(_M_get_Node_allocator(), __val);
#else
_Tp_alloc_type(_M_get_Node_allocator()).destroy(__val);
#endif
_M_put_node(__tmp);
}
}
#if __cplusplus >= 201103L
template<typename _Tp, typename _Alloc>
template<typename... _Args>
typename list<_Tp, _Alloc>::iterator
list<_Tp, _Alloc>::
emplace(const_iterator __position, _Args&&... __args)
{
_Node* __tmp = _M_create_node(std::forward<_Args>(__args)...);
__tmp->_M_hook(__position._M_const_cast()._M_node);
this->_M_inc_size(1);
return iterator(__tmp);
}
#endif
template<typename _Tp, typename _Alloc>
typename list<_Tp, _Alloc>::iterator
list<_Tp, _Alloc>::
#if __cplusplus >= 201103L
insert(const_iterator __position, const value_type& __x)
#else
insert(iterator __position, const value_type& __x)
#endif
{
_Node* __tmp = _M_create_node(__x);
__tmp->_M_hook(__position._M_const_cast()._M_node);
this->_M_inc_size(1);
return iterator(__tmp);
}
#if __cplusplus >= 201103L
template<typename _Tp, typename _Alloc>
typename list<_Tp, _Alloc>::iterator
list<_Tp, _Alloc>::
insert(const_iterator __position, size_type __n, const value_type& __x)
{
if (__n)
{
list __tmp(__n, __x, get_allocator());
iterator __it = __tmp.begin();
splice(__position, __tmp);
return __it;
}
return __position._M_const_cast();
}
template<typename _Tp, typename _Alloc>
template<typename _InputIterator, typename>
typename list<_Tp, _Alloc>::iterator
list<_Tp, _Alloc>::
insert(const_iterator __position, _InputIterator __first,
_InputIterator __last)
{
list __tmp(__first, __last, get_allocator());
if (!__tmp.empty())
{
iterator __it = __tmp.begin();
splice(__position, __tmp);
return __it;
}
return __position._M_const_cast();
}
#endif
template<typename _Tp, typename _Alloc>
typename list<_Tp, _Alloc>::iterator
list<_Tp, _Alloc>::
#if __cplusplus >= 201103L
erase(const_iterator __position) noexcept
#else
erase(iterator __position)
#endif
{
iterator __ret = iterator(__position._M_node->_M_next);
_M_erase(__position._M_const_cast());
return __ret;
}
// Return a const_iterator indicating the position to start inserting or
// erasing elements (depending whether the list is growing or shrinking),
// and set __new_size to the number of new elements that must be appended.
// Equivalent to the following, but performed optimally:
// if (__new_size < size()) {
// __new_size = 0;
// return std::next(begin(), __new_size);
// } else {
// __newsize -= size();
// return end();
// }
template<typename _Tp, typename _Alloc>
typename list<_Tp, _Alloc>::const_iterator
list<_Tp, _Alloc>::
_M_resize_pos(size_type& __new_size) const
{
const_iterator __i;
#if _GLIBCXX_USE_CXX11_ABI
const size_type __len = size();
if (__new_size < __len)
{
if (__new_size <= __len / 2)
{
__i = begin();
std::advance(__i, __new_size);
}
else
{
__i = end();
ptrdiff_t __num_erase = __len - __new_size;
std::advance(__i, -__num_erase);
}
__new_size = 0;
return __i;
}
else
__i = end();
#else
size_type __len = 0;
for (__i = begin(); __i != end() && __len < __new_size; ++__i, ++__len)
;
#endif
__new_size -= __len;
return __i;
}
#if __cplusplus >= 201103L
template<typename _Tp, typename _Alloc>
void
list<_Tp, _Alloc>::
_M_default_append(size_type __n)
{
size_type __i = 0;
__try
{
for (; __i < __n; ++__i)
emplace_back();
}
__catch(...)
{
for (; __i; --__i)
pop_back();
__throw_exception_again;
}
}
template<typename _Tp, typename _Alloc>
void
list<_Tp, _Alloc>::
resize(size_type __new_size)
{
const_iterator __i = _M_resize_pos(__new_size);
if (__new_size)
_M_default_append(__new_size);
else
erase(__i, end());
}
template<typename _Tp, typename _Alloc>
void
list<_Tp, _Alloc>::
resize(size_type __new_size, const value_type& __x)
{
const_iterator __i = _M_resize_pos(__new_size);
if (__new_size)
insert(end(), __new_size, __x);
else
erase(__i, end());
}
#else
template<typename _Tp, typename _Alloc>
void
list<_Tp, _Alloc>::
resize(size_type __new_size, value_type __x)
{
const_iterator __i = _M_resize_pos(__new_size);
if (__new_size)
insert(end(), __new_size, __x);
else
erase(__i._M_const_cast(), end());
}
#endif
template<typename _Tp, typename _Alloc>
list<_Tp, _Alloc>&
list<_Tp, _Alloc>::
operator=(const list& __x)
{
if (this != std::__addressof(__x))
{
#if __cplusplus >= 201103L
if (_Node_alloc_traits::_S_propagate_on_copy_assign())
{
auto& __this_alloc = this->_M_get_Node_allocator();
auto& __that_alloc = __x._M_get_Node_allocator();
if (!_Node_alloc_traits::_S_always_equal()
&& __this_alloc != __that_alloc)
{
// replacement allocator cannot free existing storage
clear();
}
std::__alloc_on_copy(__this_alloc, __that_alloc);
}
#endif
_M_assign_dispatch(__x.begin(), __x.end(), __false_type());
}
return *this;
}
template<typename _Tp, typename _Alloc>
void
list<_Tp, _Alloc>::
_M_fill_assign(size_type __n, const value_type& __val)
{
iterator __i = begin();
for (; __i != end() && __n > 0; ++__i, --__n)
*__i = __val;
if (__n > 0)
insert(end(), __n, __val);
else
erase(__i, end());
}
template<typename _Tp, typename _Alloc>
template <typename _InputIterator>
void
list<_Tp, _Alloc>::
_M_assign_dispatch(_InputIterator __first2, _InputIterator __last2,
__false_type)
{
iterator __first1 = begin();
iterator __last1 = end();
for (; __first1 != __last1 && __first2 != __last2;
++__first1, ++__first2)
*__first1 = *__first2;
if (__first2 == __last2)
erase(__first1, __last1);
else
insert(__last1, __first2, __last2);
}
template<typename _Tp, typename _Alloc>
void
list<_Tp, _Alloc>::
remove(const value_type& __value)
{
iterator __first = begin();
iterator __last = end();
iterator __extra = __last;
while (__first != __last)
{
iterator __next = __first;
++__next;
if (*__first == __value)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 526. Is it undefined if a function in the standard changes
// in parameters?
if (std::__addressof(*__first) != std::__addressof(__value))
_M_erase(__first);
else
__extra = __first;
}
__first = __next;
}
if (__extra != __last)
_M_erase(__extra);
}
template<typename _Tp, typename _Alloc>
void
list<_Tp, _Alloc>::
unique()
{
iterator __first = begin();
iterator __last = end();
if (__first == __last)
return;
iterator __next = __first;
while (++__next != __last)
{
if (*__first == *__next)
_M_erase(__next);
else
__first = __next;
__next = __first;
}
}
template<typename _Tp, typename _Alloc>
void
list<_Tp, _Alloc>::
#if __cplusplus >= 201103L
merge(list&& __x)
#else
merge(list& __x)
#endif
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 300. list::merge() specification incomplete
if (this != std::__addressof(__x))
{
_M_check_equal_allocators(__x);
iterator __first1 = begin();
iterator __last1 = end();
iterator __first2 = __x.begin();
iterator __last2 = __x.end();
const size_t __orig_size = __x.size();
__try {
while (__first1 != __last1 && __first2 != __last2)
if (*__first2 < *__first1)
{
iterator __next = __first2;
_M_transfer(__first1, __first2, ++__next);
__first2 = __next;
}
else
++__first1;
if (__first2 != __last2)
_M_transfer(__last1, __first2, __last2);
this->_M_inc_size(__x._M_get_size());
__x._M_set_size(0);
}
__catch(...)
{
const size_t __dist = std::distance(__first2, __last2);
this->_M_inc_size(__orig_size - __dist);
__x._M_set_size(__dist);
__throw_exception_again;
}
}
}
template<typename _Tp, typename _Alloc>
template <typename _StrictWeakOrdering>
void
list<_Tp, _Alloc>::
#if __cplusplus >= 201103L
merge(list&& __x, _StrictWeakOrdering __comp)
#else
merge(list& __x, _StrictWeakOrdering __comp)
#endif
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 300. list::merge() specification incomplete
if (this != std::__addressof(__x))
{
_M_check_equal_allocators(__x);
iterator __first1 = begin();
iterator __last1 = end();
iterator __first2 = __x.begin();
iterator __last2 = __x.end();
const size_t __orig_size = __x.size();
__try
{
while (__first1 != __last1 && __first2 != __last2)
if (__comp(*__first2, *__first1))
{
iterator __next = __first2;
_M_transfer(__first1, __first2, ++__next);
__first2 = __next;
}
else
++__first1;
if (__first2 != __last2)
_M_transfer(__last1, __first2, __last2);
this->_M_inc_size(__x._M_get_size());
__x._M_set_size(0);
}
__catch(...)
{
const size_t __dist = std::distance(__first2, __last2);
this->_M_inc_size(__orig_size - __dist);
__x._M_set_size(__dist);
__throw_exception_again;
}
}
}
template<typename _Tp, typename _Alloc>
void
list<_Tp, _Alloc>::
sort()
{
// Do nothing if the list has length 0 or 1.
if (this->_M_impl._M_node._M_next != &this->_M_impl._M_node
&& this->_M_impl._M_node._M_next->_M_next != &this->_M_impl._M_node)
{
list __carry;
list __tmp[64];
list * __fill = __tmp;
list * __counter;
__try
{
do
{
__carry.splice(__carry.begin(), *this, begin());
for(__counter = __tmp;
__counter != __fill && !__counter->empty();
++__counter)
{
__counter->merge(__carry);
__carry.swap(*__counter);
}
__carry.swap(*__counter);
if (__counter == __fill)
++__fill;
}
while ( !empty() );
for (__counter = __tmp + 1; __counter != __fill; ++__counter)
__counter->merge(*(__counter - 1));
swap( *(__fill - 1) );
}
__catch(...)
{
this->splice(this->end(), __carry);
for (int __i = 0; __i < sizeof(__tmp)/sizeof(__tmp[0]); ++__i)
this->splice(this->end(), __tmp[__i]);
__throw_exception_again;
}
}
}
template<typename _Tp, typename _Alloc>
template <typename _Predicate>
void
list<_Tp, _Alloc>::
remove_if(_Predicate __pred)
{
iterator __first = begin();
iterator __last = end();
while (__first != __last)
{
iterator __next = __first;
++__next;
if (__pred(*__first))
_M_erase(__first);
__first = __next;
}
}
template<typename _Tp, typename _Alloc>
template <typename _BinaryPredicate>
void
list<_Tp, _Alloc>::
unique(_BinaryPredicate __binary_pred)
{
iterator __first = begin();
iterator __last = end();
if (__first == __last)
return;
iterator __next = __first;
while (++__next != __last)
{
if (__binary_pred(*__first, *__next))
_M_erase(__next);
else
__first = __next;
__next = __first;
}
}
template<typename _Tp, typename _Alloc>
template <typename _StrictWeakOrdering>
void
list<_Tp, _Alloc>::
sort(_StrictWeakOrdering __comp)
{
// Do nothing if the list has length 0 or 1.
if (this->_M_impl._M_node._M_next != &this->_M_impl._M_node
&& this->_M_impl._M_node._M_next->_M_next != &this->_M_impl._M_node)
{
list __carry;
list __tmp[64];
list * __fill = __tmp;
list * __counter;
__try
{
do
{
__carry.splice(__carry.begin(), *this, begin());
for(__counter = __tmp;
__counter != __fill && !__counter->empty();
++__counter)
{
__counter->merge(__carry, __comp);
__carry.swap(*__counter);
}
__carry.swap(*__counter);
if (__counter == __fill)
++__fill;
}
while ( !empty() );
for (__counter = __tmp + 1; __counter != __fill; ++__counter)
__counter->merge(*(__counter - 1), __comp);
swap(*(__fill - 1));
}
__catch(...)
{
this->splice(this->end(), __carry);
for (int __i = 0; __i < sizeof(__tmp)/sizeof(__tmp[0]); ++__i)
this->splice(this->end(), __tmp[__i]);
__throw_exception_again;
}
}
}
_GLIBCXX_END_NAMESPACE_CONTAINER
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif /* _LIST_TCC */
c++/8/bits/istream.tcc 0000644 00000074565 15201526705 0010407 0 ustar 00 // istream classes -*- C++ -*-
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/istream.tcc
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{istream}
*/
//
// ISO C++ 14882: 27.6.1 Input streams
//
#ifndef _ISTREAM_TCC
#define _ISTREAM_TCC 1
#pragma GCC system_header
#include <bits/cxxabi_forced.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>::sentry::
sentry(basic_istream<_CharT, _Traits>& __in, bool __noskip) : _M_ok(false)
{
ios_base::iostate __err = ios_base::goodbit;
if (__in.good())
__try
{
if (__in.tie())
__in.tie()->flush();
if (!__noskip && bool(__in.flags() & ios_base::skipws))
{
const __int_type __eof = traits_type::eof();
__streambuf_type* __sb = __in.rdbuf();
__int_type __c = __sb->sgetc();
const __ctype_type& __ct = __check_facet(__in._M_ctype);
while (!traits_type::eq_int_type(__c, __eof)
&& __ct.is(ctype_base::space,
traits_type::to_char_type(__c)))
__c = __sb->snextc();
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 195. Should basic_istream::sentry's constructor ever
// set eofbit?
if (traits_type::eq_int_type(__c, __eof))
__err |= ios_base::eofbit;
}
}
__catch(__cxxabiv1::__forced_unwind&)
{
__in._M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ __in._M_setstate(ios_base::badbit); }
if (__in.good() && __err == ios_base::goodbit)
_M_ok = true;
else
{
__err |= ios_base::failbit;
__in.setstate(__err);
}
}
template<typename _CharT, typename _Traits>
template<typename _ValueT>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::
_M_extract(_ValueT& __v)
{
sentry __cerb(*this, false);
if (__cerb)
{
ios_base::iostate __err = ios_base::goodbit;
__try
{
const __num_get_type& __ng = __check_facet(this->_M_num_get);
__ng.get(*this, 0, *this, __err, __v);
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
}
return *this;
}
template<typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::
operator>>(short& __n)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 118. basic_istream uses nonexistent num_get member functions.
sentry __cerb(*this, false);
if (__cerb)
{
ios_base::iostate __err = ios_base::goodbit;
__try
{
long __l;
const __num_get_type& __ng = __check_facet(this->_M_num_get);
__ng.get(*this, 0, *this, __err, __l);
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 696. istream::operator>>(int&) broken.
if (__l < __gnu_cxx::__numeric_traits<short>::__min)
{
__err |= ios_base::failbit;
__n = __gnu_cxx::__numeric_traits<short>::__min;
}
else if (__l > __gnu_cxx::__numeric_traits<short>::__max)
{
__err |= ios_base::failbit;
__n = __gnu_cxx::__numeric_traits<short>::__max;
}
else
__n = short(__l);
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
}
return *this;
}
template<typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::
operator>>(int& __n)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 118. basic_istream uses nonexistent num_get member functions.
sentry __cerb(*this, false);
if (__cerb)
{
ios_base::iostate __err = ios_base::goodbit;
__try
{
long __l;
const __num_get_type& __ng = __check_facet(this->_M_num_get);
__ng.get(*this, 0, *this, __err, __l);
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 696. istream::operator>>(int&) broken.
if (__l < __gnu_cxx::__numeric_traits<int>::__min)
{
__err |= ios_base::failbit;
__n = __gnu_cxx::__numeric_traits<int>::__min;
}
else if (__l > __gnu_cxx::__numeric_traits<int>::__max)
{
__err |= ios_base::failbit;
__n = __gnu_cxx::__numeric_traits<int>::__max;
}
else
__n = int(__l);
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
}
return *this;
}
template<typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::
operator>>(__streambuf_type* __sbout)
{
ios_base::iostate __err = ios_base::goodbit;
sentry __cerb(*this, false);
if (__cerb && __sbout)
{
__try
{
bool __ineof;
if (!__copy_streambufs_eof(this->rdbuf(), __sbout, __ineof))
__err |= ios_base::failbit;
if (__ineof)
__err |= ios_base::eofbit;
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::failbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::failbit); }
}
else if (!__sbout)
__err |= ios_base::failbit;
if (__err)
this->setstate(__err);
return *this;
}
template<typename _CharT, typename _Traits>
typename basic_istream<_CharT, _Traits>::int_type
basic_istream<_CharT, _Traits>::
get(void)
{
const int_type __eof = traits_type::eof();
int_type __c = __eof;
_M_gcount = 0;
ios_base::iostate __err = ios_base::goodbit;
sentry __cerb(*this, true);
if (__cerb)
{
__try
{
__c = this->rdbuf()->sbumpc();
// 27.6.1.1 paragraph 3
if (!traits_type::eq_int_type(__c, __eof))
_M_gcount = 1;
else
__err |= ios_base::eofbit;
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
}
if (!_M_gcount)
__err |= ios_base::failbit;
if (__err)
this->setstate(__err);
return __c;
}
template<typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::
get(char_type& __c)
{
_M_gcount = 0;
ios_base::iostate __err = ios_base::goodbit;
sentry __cerb(*this, true);
if (__cerb)
{
__try
{
const int_type __cb = this->rdbuf()->sbumpc();
// 27.6.1.1 paragraph 3
if (!traits_type::eq_int_type(__cb, traits_type::eof()))
{
_M_gcount = 1;
__c = traits_type::to_char_type(__cb);
}
else
__err |= ios_base::eofbit;
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
}
if (!_M_gcount)
__err |= ios_base::failbit;
if (__err)
this->setstate(__err);
return *this;
}
template<typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::
get(char_type* __s, streamsize __n, char_type __delim)
{
_M_gcount = 0;
ios_base::iostate __err = ios_base::goodbit;
sentry __cerb(*this, true);
if (__cerb)
{
__try
{
const int_type __idelim = traits_type::to_int_type(__delim);
const int_type __eof = traits_type::eof();
__streambuf_type* __sb = this->rdbuf();
int_type __c = __sb->sgetc();
while (_M_gcount + 1 < __n
&& !traits_type::eq_int_type(__c, __eof)
&& !traits_type::eq_int_type(__c, __idelim))
{
*__s++ = traits_type::to_char_type(__c);
++_M_gcount;
__c = __sb->snextc();
}
if (traits_type::eq_int_type(__c, __eof))
__err |= ios_base::eofbit;
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 243. get and getline when sentry reports failure.
if (__n > 0)
*__s = char_type();
if (!_M_gcount)
__err |= ios_base::failbit;
if (__err)
this->setstate(__err);
return *this;
}
template<typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::
get(__streambuf_type& __sb, char_type __delim)
{
_M_gcount = 0;
ios_base::iostate __err = ios_base::goodbit;
sentry __cerb(*this, true);
if (__cerb)
{
__try
{
const int_type __idelim = traits_type::to_int_type(__delim);
const int_type __eof = traits_type::eof();
__streambuf_type* __this_sb = this->rdbuf();
int_type __c = __this_sb->sgetc();
char_type __c2 = traits_type::to_char_type(__c);
while (!traits_type::eq_int_type(__c, __eof)
&& !traits_type::eq_int_type(__c, __idelim)
&& !traits_type::eq_int_type(__sb.sputc(__c2), __eof))
{
++_M_gcount;
__c = __this_sb->snextc();
__c2 = traits_type::to_char_type(__c);
}
if (traits_type::eq_int_type(__c, __eof))
__err |= ios_base::eofbit;
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
}
if (!_M_gcount)
__err |= ios_base::failbit;
if (__err)
this->setstate(__err);
return *this;
}
template<typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::
getline(char_type* __s, streamsize __n, char_type __delim)
{
_M_gcount = 0;
ios_base::iostate __err = ios_base::goodbit;
sentry __cerb(*this, true);
if (__cerb)
{
__try
{
const int_type __idelim = traits_type::to_int_type(__delim);
const int_type __eof = traits_type::eof();
__streambuf_type* __sb = this->rdbuf();
int_type __c = __sb->sgetc();
while (_M_gcount + 1 < __n
&& !traits_type::eq_int_type(__c, __eof)
&& !traits_type::eq_int_type(__c, __idelim))
{
*__s++ = traits_type::to_char_type(__c);
__c = __sb->snextc();
++_M_gcount;
}
if (traits_type::eq_int_type(__c, __eof))
__err |= ios_base::eofbit;
else
{
if (traits_type::eq_int_type(__c, __idelim))
{
__sb->sbumpc();
++_M_gcount;
}
else
__err |= ios_base::failbit;
}
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 243. get and getline when sentry reports failure.
if (__n > 0)
*__s = char_type();
if (!_M_gcount)
__err |= ios_base::failbit;
if (__err)
this->setstate(__err);
return *this;
}
// We provide three overloads, since the first two are much simpler
// than the general case. Also, the latter two can thus adopt the
// same "batchy" strategy used by getline above.
template<typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::
ignore(void)
{
_M_gcount = 0;
sentry __cerb(*this, true);
if (__cerb)
{
ios_base::iostate __err = ios_base::goodbit;
__try
{
const int_type __eof = traits_type::eof();
__streambuf_type* __sb = this->rdbuf();
if (traits_type::eq_int_type(__sb->sbumpc(), __eof))
__err |= ios_base::eofbit;
else
_M_gcount = 1;
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
}
return *this;
}
template<typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::
ignore(streamsize __n)
{
_M_gcount = 0;
sentry __cerb(*this, true);
if (__cerb && __n > 0)
{
ios_base::iostate __err = ios_base::goodbit;
__try
{
const int_type __eof = traits_type::eof();
__streambuf_type* __sb = this->rdbuf();
int_type __c = __sb->sgetc();
// N.B. On LFS-enabled platforms streamsize is still 32 bits
// wide: if we want to implement the standard mandated behavior
// for n == max() (see 27.6.1.3/24) we are at risk of signed
// integer overflow: thus these contortions. Also note that,
// by definition, when more than 2G chars are actually ignored,
// _M_gcount (the return value of gcount, that is) cannot be
// really correct, being unavoidably too small.
bool __large_ignore = false;
while (true)
{
while (_M_gcount < __n
&& !traits_type::eq_int_type(__c, __eof))
{
++_M_gcount;
__c = __sb->snextc();
}
if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
&& !traits_type::eq_int_type(__c, __eof))
{
_M_gcount =
__gnu_cxx::__numeric_traits<streamsize>::__min;
__large_ignore = true;
}
else
break;
}
if (__large_ignore)
_M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
if (traits_type::eq_int_type(__c, __eof))
__err |= ios_base::eofbit;
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
}
return *this;
}
template<typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::
ignore(streamsize __n, int_type __delim)
{
_M_gcount = 0;
sentry __cerb(*this, true);
if (__cerb && __n > 0)
{
ios_base::iostate __err = ios_base::goodbit;
__try
{
const int_type __eof = traits_type::eof();
__streambuf_type* __sb = this->rdbuf();
int_type __c = __sb->sgetc();
// See comment above.
bool __large_ignore = false;
while (true)
{
while (_M_gcount < __n
&& !traits_type::eq_int_type(__c, __eof)
&& !traits_type::eq_int_type(__c, __delim))
{
++_M_gcount;
__c = __sb->snextc();
}
if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
&& !traits_type::eq_int_type(__c, __eof)
&& !traits_type::eq_int_type(__c, __delim))
{
_M_gcount =
__gnu_cxx::__numeric_traits<streamsize>::__min;
__large_ignore = true;
}
else
break;
}
if (__large_ignore)
_M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
if (traits_type::eq_int_type(__c, __eof))
__err |= ios_base::eofbit;
else if (traits_type::eq_int_type(__c, __delim))
{
if (_M_gcount
< __gnu_cxx::__numeric_traits<streamsize>::__max)
++_M_gcount;
__sb->sbumpc();
}
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
}
return *this;
}
template<typename _CharT, typename _Traits>
typename basic_istream<_CharT, _Traits>::int_type
basic_istream<_CharT, _Traits>::
peek(void)
{
int_type __c = traits_type::eof();
_M_gcount = 0;
sentry __cerb(*this, true);
if (__cerb)
{
ios_base::iostate __err = ios_base::goodbit;
__try
{
__c = this->rdbuf()->sgetc();
if (traits_type::eq_int_type(__c, traits_type::eof()))
__err |= ios_base::eofbit;
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
}
return __c;
}
template<typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::
read(char_type* __s, streamsize __n)
{
_M_gcount = 0;
sentry __cerb(*this, true);
if (__cerb)
{
ios_base::iostate __err = ios_base::goodbit;
__try
{
_M_gcount = this->rdbuf()->sgetn(__s, __n);
if (_M_gcount != __n)
__err |= (ios_base::eofbit | ios_base::failbit);
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
}
return *this;
}
template<typename _CharT, typename _Traits>
streamsize
basic_istream<_CharT, _Traits>::
readsome(char_type* __s, streamsize __n)
{
_M_gcount = 0;
sentry __cerb(*this, true);
if (__cerb)
{
ios_base::iostate __err = ios_base::goodbit;
__try
{
// Cannot compare int_type with streamsize generically.
const streamsize __num = this->rdbuf()->in_avail();
if (__num > 0)
_M_gcount = this->rdbuf()->sgetn(__s, std::min(__num, __n));
else if (__num == -1)
__err |= ios_base::eofbit;
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
}
return _M_gcount;
}
template<typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::
putback(char_type __c)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 60. What is a formatted input function?
_M_gcount = 0;
// Clear eofbit per N3168.
this->clear(this->rdstate() & ~ios_base::eofbit);
sentry __cerb(*this, true);
if (__cerb)
{
ios_base::iostate __err = ios_base::goodbit;
__try
{
const int_type __eof = traits_type::eof();
__streambuf_type* __sb = this->rdbuf();
if (!__sb
|| traits_type::eq_int_type(__sb->sputbackc(__c), __eof))
__err |= ios_base::badbit;
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
}
return *this;
}
template<typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::
unget(void)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 60. What is a formatted input function?
_M_gcount = 0;
// Clear eofbit per N3168.
this->clear(this->rdstate() & ~ios_base::eofbit);
sentry __cerb(*this, true);
if (__cerb)
{
ios_base::iostate __err = ios_base::goodbit;
__try
{
const int_type __eof = traits_type::eof();
__streambuf_type* __sb = this->rdbuf();
if (!__sb
|| traits_type::eq_int_type(__sb->sungetc(), __eof))
__err |= ios_base::badbit;
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
}
return *this;
}
template<typename _CharT, typename _Traits>
int
basic_istream<_CharT, _Traits>::
sync(void)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR60. Do not change _M_gcount.
int __ret = -1;
sentry __cerb(*this, true);
if (__cerb)
{
ios_base::iostate __err = ios_base::goodbit;
__try
{
__streambuf_type* __sb = this->rdbuf();
if (__sb)
{
if (__sb->pubsync() == -1)
__err |= ios_base::badbit;
else
__ret = 0;
}
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
}
return __ret;
}
template<typename _CharT, typename _Traits>
typename basic_istream<_CharT, _Traits>::pos_type
basic_istream<_CharT, _Traits>::
tellg(void)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR60. Do not change _M_gcount.
pos_type __ret = pos_type(-1);
sentry __cerb(*this, true);
if (__cerb)
{
__try
{
if (!this->fail())
__ret = this->rdbuf()->pubseekoff(0, ios_base::cur,
ios_base::in);
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
}
return __ret;
}
template<typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::
seekg(pos_type __pos)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR60. Do not change _M_gcount.
// Clear eofbit per N3168.
this->clear(this->rdstate() & ~ios_base::eofbit);
sentry __cerb(*this, true);
if (__cerb)
{
ios_base::iostate __err = ios_base::goodbit;
__try
{
if (!this->fail())
{
// 136. seekp, seekg setting wrong streams?
const pos_type __p = this->rdbuf()->pubseekpos(__pos,
ios_base::in);
// 129. Need error indication from seekp() and seekg()
if (__p == pos_type(off_type(-1)))
__err |= ios_base::failbit;
}
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
}
return *this;
}
template<typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::
seekg(off_type __off, ios_base::seekdir __dir)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR60. Do not change _M_gcount.
// Clear eofbit per N3168.
this->clear(this->rdstate() & ~ios_base::eofbit);
sentry __cerb(*this, true);
if (__cerb)
{
ios_base::iostate __err = ios_base::goodbit;
__try
{
if (!this->fail())
{
// 136. seekp, seekg setting wrong streams?
const pos_type __p = this->rdbuf()->pubseekoff(__off, __dir,
ios_base::in);
// 129. Need error indication from seekp() and seekg()
if (__p == pos_type(off_type(-1)))
__err |= ios_base::failbit;
}
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
}
return *this;
}
// 27.6.1.2.3 Character extraction templates
template<typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c)
{
typedef basic_istream<_CharT, _Traits> __istream_type;
typedef typename __istream_type::int_type __int_type;
typename __istream_type::sentry __cerb(__in, false);
if (__cerb)
{
ios_base::iostate __err = ios_base::goodbit;
__try
{
const __int_type __cb = __in.rdbuf()->sbumpc();
if (!_Traits::eq_int_type(__cb, _Traits::eof()))
__c = _Traits::to_char_type(__cb);
else
__err |= (ios_base::eofbit | ios_base::failbit);
}
__catch(__cxxabiv1::__forced_unwind&)
{
__in._M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ __in._M_setstate(ios_base::badbit); }
if (__err)
__in.setstate(__err);
}
return __in;
}
template<typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s)
{
typedef basic_istream<_CharT, _Traits> __istream_type;
typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
typedef typename _Traits::int_type int_type;
typedef _CharT char_type;
typedef ctype<_CharT> __ctype_type;
streamsize __extracted = 0;
ios_base::iostate __err = ios_base::goodbit;
typename __istream_type::sentry __cerb(__in, false);
if (__cerb)
{
__try
{
// Figure out how many characters to extract.
streamsize __num = __in.width();
if (__num <= 0)
__num = __gnu_cxx::__numeric_traits<streamsize>::__max;
const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc());
const int_type __eof = _Traits::eof();
__streambuf_type* __sb = __in.rdbuf();
int_type __c = __sb->sgetc();
while (__extracted < __num - 1
&& !_Traits::eq_int_type(__c, __eof)
&& !__ct.is(ctype_base::space,
_Traits::to_char_type(__c)))
{
*__s++ = _Traits::to_char_type(__c);
++__extracted;
__c = __sb->snextc();
}
if (_Traits::eq_int_type(__c, __eof))
__err |= ios_base::eofbit;
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 68. Extractors for char* should store null at end
*__s = char_type();
__in.width(0);
}
__catch(__cxxabiv1::__forced_unwind&)
{
__in._M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ __in._M_setstate(ios_base::badbit); }
}
if (!__extracted)
__err |= ios_base::failbit;
if (__err)
__in.setstate(__err);
return __in;
}
// 27.6.1.4 Standard basic_istream manipulators
template<typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>&
ws(basic_istream<_CharT, _Traits>& __in)
{
typedef basic_istream<_CharT, _Traits> __istream_type;
typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
typedef typename __istream_type::int_type __int_type;
typedef ctype<_CharT> __ctype_type;
const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc());
const __int_type __eof = _Traits::eof();
__streambuf_type* __sb = __in.rdbuf();
__int_type __c = __sb->sgetc();
while (!_Traits::eq_int_type(__c, __eof)
&& __ct.is(ctype_base::space, _Traits::to_char_type(__c)))
__c = __sb->snextc();
if (_Traits::eq_int_type(__c, __eof))
__in.setstate(ios_base::eofbit);
return __in;
}
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
#if _GLIBCXX_EXTERN_TEMPLATE
extern template class basic_istream<char>;
extern template istream& ws(istream&);
extern template istream& operator>>(istream&, char&);
extern template istream& operator>>(istream&, char*);
extern template istream& operator>>(istream&, unsigned char&);
extern template istream& operator>>(istream&, signed char&);
extern template istream& operator>>(istream&, unsigned char*);
extern template istream& operator>>(istream&, signed char*);
extern template istream& istream::_M_extract(unsigned short&);
extern template istream& istream::_M_extract(unsigned int&);
extern template istream& istream::_M_extract(long&);
extern template istream& istream::_M_extract(unsigned long&);
extern template istream& istream::_M_extract(bool&);
#ifdef _GLIBCXX_USE_LONG_LONG
extern template istream& istream::_M_extract(long long&);
extern template istream& istream::_M_extract(unsigned long long&);
#endif
extern template istream& istream::_M_extract(float&);
extern template istream& istream::_M_extract(double&);
extern template istream& istream::_M_extract(long double&);
extern template istream& istream::_M_extract(void*&);
extern template class basic_iostream<char>;
#ifdef _GLIBCXX_USE_WCHAR_T
extern template class basic_istream<wchar_t>;
extern template wistream& ws(wistream&);
extern template wistream& operator>>(wistream&, wchar_t&);
extern template wistream& operator>>(wistream&, wchar_t*);
extern template wistream& wistream::_M_extract(unsigned short&);
extern template wistream& wistream::_M_extract(unsigned int&);
extern template wistream& wistream::_M_extract(long&);
extern template wistream& wistream::_M_extract(unsigned long&);
extern template wistream& wistream::_M_extract(bool&);
#ifdef _GLIBCXX_USE_LONG_LONG
extern template wistream& wistream::_M_extract(long long&);
extern template wistream& wistream::_M_extract(unsigned long long&);
#endif
extern template wistream& wistream::_M_extract(float&);
extern template wistream& wistream::_M_extract(double&);
extern template wistream& wistream::_M_extract(long double&);
extern template wistream& wistream::_M_extract(void*&);
extern template class basic_iostream<wchar_t>;
#endif
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif
c++/8/bits/node_handle.h 0000644 00000020030 15201526705 0010633 0 ustar 00 // Node handles for containers -*- C++ -*-
// Copyright (C) 2016-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/node_handle.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly.
* @headername{map,set,unordered_map,unordered_set}
*/
#ifndef _NODE_HANDLE
#define _NODE_HANDLE 1
#pragma GCC system_header
#if __cplusplus > 201402L
# define __cpp_lib_node_extract 201606
#include <optional>
#include <bits/alloc_traits.h>
#include <bits/ptr_traits.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/// Base class for node handle types of maps and sets.
template<typename _Val, typename _NodeAlloc>
class _Node_handle_common
{
using _AllocTraits = allocator_traits<_NodeAlloc>;
public:
using allocator_type = __alloc_rebind<_NodeAlloc, _Val>;
allocator_type
get_allocator() const noexcept
{
__glibcxx_assert(!this->empty());
return allocator_type(*_M_alloc);
}
explicit operator bool() const noexcept { return _M_ptr != nullptr; }
[[nodiscard]] bool empty() const noexcept { return _M_ptr == nullptr; }
protected:
constexpr _Node_handle_common() noexcept : _M_ptr(), _M_alloc() {}
~_Node_handle_common() { _M_destroy(); }
_Node_handle_common(_Node_handle_common&& __nh) noexcept
: _M_ptr(__nh._M_ptr), _M_alloc(std::move(__nh._M_alloc))
{
__nh._M_ptr = nullptr;
__nh._M_alloc = nullopt;
}
_Node_handle_common&
operator=(_Node_handle_common&& __nh) noexcept
{
_M_destroy();
_M_ptr = __nh._M_ptr;
if constexpr (is_move_assignable_v<_NodeAlloc>)
{
if (_AllocTraits::propagate_on_container_move_assignment::value
|| !this->_M_alloc)
this->_M_alloc = std::move(__nh._M_alloc);
else
{
__glibcxx_assert(this->_M_alloc == __nh._M_alloc);
}
}
else
{
__glibcxx_assert(_M_alloc);
}
__nh._M_ptr = nullptr;
__nh._M_alloc = nullopt;
return *this;
}
_Node_handle_common(typename _AllocTraits::pointer __ptr,
const _NodeAlloc& __alloc)
: _M_ptr(__ptr), _M_alloc(__alloc) { }
void
_M_swap(_Node_handle_common& __nh) noexcept
{
using std::swap;
swap(_M_ptr, __nh._M_ptr);
if (_AllocTraits::propagate_on_container_swap::value
|| !_M_alloc || !__nh._M_alloc)
_M_alloc.swap(__nh._M_alloc);
else
{
__glibcxx_assert(_M_alloc == __nh._M_alloc);
}
}
private:
void
_M_destroy() noexcept
{
if (_M_ptr != nullptr)
{
allocator_type __alloc(*_M_alloc);
allocator_traits<allocator_type>::destroy(__alloc,
_M_ptr->_M_valptr());
_AllocTraits::deallocate(*_M_alloc, _M_ptr, 1);
}
}
protected:
typename _AllocTraits::pointer _M_ptr;
private:
optional<_NodeAlloc> _M_alloc;
template<typename _Key2, typename _Value2, typename _KeyOfValue,
typename _Compare, typename _ValueAlloc>
friend class _Rb_tree;
};
/// Node handle type for maps.
template<typename _Key, typename _Value, typename _NodeAlloc>
class _Node_handle : public _Node_handle_common<_Value, _NodeAlloc>
{
public:
constexpr _Node_handle() noexcept = default;
~_Node_handle() = default;
_Node_handle(_Node_handle&&) noexcept = default;
_Node_handle&
operator=(_Node_handle&&) noexcept = default;
using key_type = _Key;
using mapped_type = typename _Value::second_type;
key_type&
key() const noexcept
{
__glibcxx_assert(!this->empty());
return *_M_pkey;
}
mapped_type&
mapped() const noexcept
{
__glibcxx_assert(!this->empty());
return *_M_pmapped;
}
void
swap(_Node_handle& __nh) noexcept
{
this->_M_swap(__nh);
using std::swap;
swap(_M_pkey, __nh._M_pkey);
swap(_M_pmapped, __nh._M_pmapped);
}
friend void
swap(_Node_handle& __x, _Node_handle& __y)
noexcept(noexcept(__x.swap(__y)))
{ __x.swap(__y); }
private:
using _AllocTraits = allocator_traits<_NodeAlloc>;
_Node_handle(typename _AllocTraits::pointer __ptr,
const _NodeAlloc& __alloc)
: _Node_handle_common<_Value, _NodeAlloc>(__ptr, __alloc)
{
if (__ptr)
{
auto& __key = const_cast<_Key&>(__ptr->_M_valptr()->first);
_M_pkey = _S_pointer_to(__key);
_M_pmapped = _S_pointer_to(__ptr->_M_valptr()->second);
}
else
{
_M_pkey = nullptr;
_M_pmapped = nullptr;
}
}
template<typename _Tp>
using __pointer
= __ptr_rebind<typename _AllocTraits::pointer,
remove_reference_t<_Tp>>;
__pointer<_Key> _M_pkey = nullptr;
__pointer<typename _Value::second_type> _M_pmapped = nullptr;
template<typename _Tp>
__pointer<_Tp>
_S_pointer_to(_Tp& __obj)
{ return pointer_traits<__pointer<_Tp>>::pointer_to(__obj); }
const key_type&
_M_key() const noexcept { return key(); }
template<typename _Key2, typename _Value2, typename _KeyOfValue,
typename _Compare, typename _ValueAlloc>
friend class _Rb_tree;
template<typename _Key2, typename _Value2, typename _ValueAlloc,
typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash,
typename _RehashPolicy, typename _Traits>
friend class _Hashtable;
};
/// Node handle type for sets.
template<typename _Value, typename _NodeAlloc>
class _Node_handle<_Value, _Value, _NodeAlloc>
: public _Node_handle_common<_Value, _NodeAlloc>
{
public:
constexpr _Node_handle() noexcept = default;
~_Node_handle() = default;
_Node_handle(_Node_handle&&) noexcept = default;
_Node_handle&
operator=(_Node_handle&&) noexcept = default;
using value_type = _Value;
value_type&
value() const noexcept
{
__glibcxx_assert(!this->empty());
return *this->_M_ptr->_M_valptr();
}
void
swap(_Node_handle& __nh) noexcept
{ this->_M_swap(__nh); }
friend void
swap(_Node_handle& __x, _Node_handle& __y)
noexcept(noexcept(__x.swap(__y)))
{ __x.swap(__y); }
private:
using _AllocTraits = allocator_traits<_NodeAlloc>;
_Node_handle(typename _AllocTraits::pointer __ptr,
const _NodeAlloc& __alloc)
: _Node_handle_common<_Value, _NodeAlloc>(__ptr, __alloc) { }
const value_type&
_M_key() const noexcept { return value(); }
template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc>
friend class _Rb_tree;
template<typename _Key2, typename _Value2, typename _ValueAlloc,
typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash,
typename _RehashPolicy, typename _Traits>
friend class _Hashtable;
};
/// Return type of insert(node_handle&&) on unique maps/sets.
template<typename _Iterator, typename _NodeHandle>
struct _Node_insert_return
{
_Iterator position = _Iterator();
bool inserted = false;
_NodeHandle node;
};
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // C++17
#endif
c++/8/bits/locale_facets.h 0000644 00000264250 15201526705 0011175 0 ustar 00 // Locale support -*- C++ -*-
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/locale_facets.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{locale}
*/
//
// ISO C++ 14882: 22.1 Locales
//
#ifndef _LOCALE_FACETS_H
#define _LOCALE_FACETS_H 1
#pragma GCC system_header
#include <cwctype> // For wctype_t
#include <cctype>
#include <bits/ctype_base.h>
#include <iosfwd>
#include <bits/ios_base.h> // For ios_base, ios_base::iostate
#include <streambuf>
#include <bits/cpp_type_traits.h>
#include <ext/type_traits.h>
#include <ext/numeric_traits.h>
#include <bits/streambuf_iterator.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// NB: Don't instantiate required wchar_t facets if no wchar_t support.
#ifdef _GLIBCXX_USE_WCHAR_T
# define _GLIBCXX_NUM_FACETS 28
# define _GLIBCXX_NUM_CXX11_FACETS 16
#else
# define _GLIBCXX_NUM_FACETS 14
# define _GLIBCXX_NUM_CXX11_FACETS 8
#endif
#ifdef _GLIBCXX_USE_C99_STDINT_TR1
# define _GLIBCXX_NUM_UNICODE_FACETS 2
#else
# define _GLIBCXX_NUM_UNICODE_FACETS 0
#endif
// Convert string to numeric value of type _Tp and store results.
// NB: This is specialized for all required types, there is no
// generic definition.
template<typename _Tp>
void
__convert_to_v(const char*, _Tp&, ios_base::iostate&,
const __c_locale&) throw();
// Explicit specializations for required types.
template<>
void
__convert_to_v(const char*, float&, ios_base::iostate&,
const __c_locale&) throw();
template<>
void
__convert_to_v(const char*, double&, ios_base::iostate&,
const __c_locale&) throw();
template<>
void
__convert_to_v(const char*, long double&, ios_base::iostate&,
const __c_locale&) throw();
// NB: __pad is a struct, rather than a function, so it can be
// partially-specialized.
template<typename _CharT, typename _Traits>
struct __pad
{
static void
_S_pad(ios_base& __io, _CharT __fill, _CharT* __news,
const _CharT* __olds, streamsize __newlen, streamsize __oldlen);
};
// Used by both numeric and monetary facets.
// Inserts "group separator" characters into an array of characters.
// It's recursive, one iteration per group. It moves the characters
// in the buffer this way: "xxxx12345" -> "12,345xxx". Call this
// only with __gsize != 0.
template<typename _CharT>
_CharT*
__add_grouping(_CharT* __s, _CharT __sep,
const char* __gbeg, size_t __gsize,
const _CharT* __first, const _CharT* __last);
// This template permits specializing facet output code for
// ostreambuf_iterator. For ostreambuf_iterator, sputn is
// significantly more efficient than incrementing iterators.
template<typename _CharT>
inline
ostreambuf_iterator<_CharT>
__write(ostreambuf_iterator<_CharT> __s, const _CharT* __ws, int __len)
{
__s._M_put(__ws, __len);
return __s;
}
// This is the unspecialized form of the template.
template<typename _CharT, typename _OutIter>
inline
_OutIter
__write(_OutIter __s, const _CharT* __ws, int __len)
{
for (int __j = 0; __j < __len; __j++, ++__s)
*__s = __ws[__j];
return __s;
}
// 22.2.1.1 Template class ctype
// Include host and configuration specific ctype enums for ctype_base.
/**
* @brief Common base for ctype facet
*
* This template class provides implementations of the public functions
* that forward to the protected virtual functions.
*
* This template also provides abstract stubs for the protected virtual
* functions.
*/
template<typename _CharT>
class __ctype_abstract_base : public locale::facet, public ctype_base
{
public:
// Types:
/// Typedef for the template parameter
typedef _CharT char_type;
/**
* @brief Test char_type classification.
*
* This function finds a mask M for @a __c and compares it to
* mask @a __m. It does so by returning the value of
* ctype<char_type>::do_is().
*
* @param __c The char_type to compare the mask of.
* @param __m The mask to compare against.
* @return (M & __m) != 0.
*/
bool
is(mask __m, char_type __c) const
{ return this->do_is(__m, __c); }
/**
* @brief Return a mask array.
*
* This function finds the mask for each char_type in the range [lo,hi)
* and successively writes it to vec. vec must have as many elements
* as the char array. It does so by returning the value of
* ctype<char_type>::do_is().
*
* @param __lo Pointer to start of range.
* @param __hi Pointer to end of range.
* @param __vec Pointer to an array of mask storage.
* @return @a __hi.
*/
const char_type*
is(const char_type *__lo, const char_type *__hi, mask *__vec) const
{ return this->do_is(__lo, __hi, __vec); }
/**
* @brief Find char_type matching a mask
*
* This function searches for and returns the first char_type c in
* [lo,hi) for which is(m,c) is true. It does so by returning
* ctype<char_type>::do_scan_is().
*
* @param __m The mask to compare against.
* @param __lo Pointer to start of range.
* @param __hi Pointer to end of range.
* @return Pointer to matching char_type if found, else @a __hi.
*/
const char_type*
scan_is(mask __m, const char_type* __lo, const char_type* __hi) const
{ return this->do_scan_is(__m, __lo, __hi); }
/**
* @brief Find char_type not matching a mask
*
* This function searches for and returns the first char_type c in
* [lo,hi) for which is(m,c) is false. It does so by returning
* ctype<char_type>::do_scan_not().
*
* @param __m The mask to compare against.
* @param __lo Pointer to first char in range.
* @param __hi Pointer to end of range.
* @return Pointer to non-matching char if found, else @a __hi.
*/
const char_type*
scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
{ return this->do_scan_not(__m, __lo, __hi); }
/**
* @brief Convert to uppercase.
*
* This function converts the argument to uppercase if possible.
* If not possible (for example, '2'), returns the argument. It does
* so by returning ctype<char_type>::do_toupper().
*
* @param __c The char_type to convert.
* @return The uppercase char_type if convertible, else @a __c.
*/
char_type
toupper(char_type __c) const
{ return this->do_toupper(__c); }
/**
* @brief Convert array to uppercase.
*
* This function converts each char_type in the range [lo,hi) to
* uppercase if possible. Other elements remain untouched. It does so
* by returning ctype<char_type>:: do_toupper(lo, hi).
*
* @param __lo Pointer to start of range.
* @param __hi Pointer to end of range.
* @return @a __hi.
*/
const char_type*
toupper(char_type *__lo, const char_type* __hi) const
{ return this->do_toupper(__lo, __hi); }
/**
* @brief Convert to lowercase.
*
* This function converts the argument to lowercase if possible. If
* not possible (for example, '2'), returns the argument. It does so
* by returning ctype<char_type>::do_tolower(c).
*
* @param __c The char_type to convert.
* @return The lowercase char_type if convertible, else @a __c.
*/
char_type
tolower(char_type __c) const
{ return this->do_tolower(__c); }
/**
* @brief Convert array to lowercase.
*
* This function converts each char_type in the range [__lo,__hi) to
* lowercase if possible. Other elements remain untouched. It does so
* by returning ctype<char_type>:: do_tolower(__lo, __hi).
*
* @param __lo Pointer to start of range.
* @param __hi Pointer to end of range.
* @return @a __hi.
*/
const char_type*
tolower(char_type* __lo, const char_type* __hi) const
{ return this->do_tolower(__lo, __hi); }
/**
* @brief Widen char to char_type
*
* This function converts the char argument to char_type using the
* simplest reasonable transformation. It does so by returning
* ctype<char_type>::do_widen(c).
*
* Note: this is not what you want for codepage conversions. See
* codecvt for that.
*
* @param __c The char to convert.
* @return The converted char_type.
*/
char_type
widen(char __c) const
{ return this->do_widen(__c); }
/**
* @brief Widen array to char_type
*
* This function converts each char in the input to char_type using the
* simplest reasonable transformation. It does so by returning
* ctype<char_type>::do_widen(c).
*
* Note: this is not what you want for codepage conversions. See
* codecvt for that.
*
* @param __lo Pointer to start of range.
* @param __hi Pointer to end of range.
* @param __to Pointer to the destination array.
* @return @a __hi.
*/
const char*
widen(const char* __lo, const char* __hi, char_type* __to) const
{ return this->do_widen(__lo, __hi, __to); }
/**
* @brief Narrow char_type to char
*
* This function converts the char_type to char using the simplest
* reasonable transformation. If the conversion fails, dfault is
* returned instead. It does so by returning
* ctype<char_type>::do_narrow(__c).
*
* Note: this is not what you want for codepage conversions. See
* codecvt for that.
*
* @param __c The char_type to convert.
* @param __dfault Char to return if conversion fails.
* @return The converted char.
*/
char
narrow(char_type __c, char __dfault) const
{ return this->do_narrow(__c, __dfault); }
/**
* @brief Narrow array to char array
*
* This function converts each char_type in the input to char using the
* simplest reasonable transformation and writes the results to the
* destination array. For any char_type in the input that cannot be
* converted, @a dfault is used instead. It does so by returning
* ctype<char_type>::do_narrow(__lo, __hi, __dfault, __to).
*
* Note: this is not what you want for codepage conversions. See
* codecvt for that.
*
* @param __lo Pointer to start of range.
* @param __hi Pointer to end of range.
* @param __dfault Char to use if conversion fails.
* @param __to Pointer to the destination array.
* @return @a __hi.
*/
const char_type*
narrow(const char_type* __lo, const char_type* __hi,
char __dfault, char* __to) const
{ return this->do_narrow(__lo, __hi, __dfault, __to); }
protected:
explicit
__ctype_abstract_base(size_t __refs = 0): facet(__refs) { }
virtual
~__ctype_abstract_base() { }
/**
* @brief Test char_type classification.
*
* This function finds a mask M for @a c and compares it to mask @a m.
*
* do_is() is a hook for a derived facet to change the behavior of
* classifying. do_is() must always return the same result for the
* same input.
*
* @param __c The char_type to find the mask of.
* @param __m The mask to compare against.
* @return (M & __m) != 0.
*/
virtual bool
do_is(mask __m, char_type __c) const = 0;
/**
* @brief Return a mask array.
*
* This function finds the mask for each char_type in the range [lo,hi)
* and successively writes it to vec. vec must have as many elements
* as the input.
*
* do_is() is a hook for a derived facet to change the behavior of
* classifying. do_is() must always return the same result for the
* same input.
*
* @param __lo Pointer to start of range.
* @param __hi Pointer to end of range.
* @param __vec Pointer to an array of mask storage.
* @return @a __hi.
*/
virtual const char_type*
do_is(const char_type* __lo, const char_type* __hi,
mask* __vec) const = 0;
/**
* @brief Find char_type matching mask
*
* This function searches for and returns the first char_type c in
* [__lo,__hi) for which is(__m,c) is true.
*
* do_scan_is() is a hook for a derived facet to change the behavior of
* match searching. do_is() must always return the same result for the
* same input.
*
* @param __m The mask to compare against.
* @param __lo Pointer to start of range.
* @param __hi Pointer to end of range.
* @return Pointer to a matching char_type if found, else @a __hi.
*/
virtual const char_type*
do_scan_is(mask __m, const char_type* __lo,
const char_type* __hi) const = 0;
/**
* @brief Find char_type not matching mask
*
* This function searches for and returns a pointer to the first
* char_type c of [lo,hi) for which is(m,c) is false.
*
* do_scan_is() is a hook for a derived facet to change the behavior of
* match searching. do_is() must always return the same result for the
* same input.
*
* @param __m The mask to compare against.
* @param __lo Pointer to start of range.
* @param __hi Pointer to end of range.
* @return Pointer to a non-matching char_type if found, else @a __hi.
*/
virtual const char_type*
do_scan_not(mask __m, const char_type* __lo,
const char_type* __hi) const = 0;
/**
* @brief Convert to uppercase.
*
* This virtual function converts the char_type argument to uppercase
* if possible. If not possible (for example, '2'), returns the
* argument.
*
* do_toupper() is a hook for a derived facet to change the behavior of
* uppercasing. do_toupper() must always return the same result for
* the same input.
*
* @param __c The char_type to convert.
* @return The uppercase char_type if convertible, else @a __c.
*/
virtual char_type
do_toupper(char_type __c) const = 0;
/**
* @brief Convert array to uppercase.
*
* This virtual function converts each char_type in the range [__lo,__hi)
* to uppercase if possible. Other elements remain untouched.
*
* do_toupper() is a hook for a derived facet to change the behavior of
* uppercasing. do_toupper() must always return the same result for
* the same input.
*
* @param __lo Pointer to start of range.
* @param __hi Pointer to end of range.
* @return @a __hi.
*/
virtual const char_type*
do_toupper(char_type* __lo, const char_type* __hi) const = 0;
/**
* @brief Convert to lowercase.
*
* This virtual function converts the argument to lowercase if
* possible. If not possible (for example, '2'), returns the argument.
*
* do_tolower() is a hook for a derived facet to change the behavior of
* lowercasing. do_tolower() must always return the same result for
* the same input.
*
* @param __c The char_type to convert.
* @return The lowercase char_type if convertible, else @a __c.
*/
virtual char_type
do_tolower(char_type __c) const = 0;
/**
* @brief Convert array to lowercase.
*
* This virtual function converts each char_type in the range [__lo,__hi)
* to lowercase if possible. Other elements remain untouched.
*
* do_tolower() is a hook for a derived facet to change the behavior of
* lowercasing. do_tolower() must always return the same result for
* the same input.
*
* @param __lo Pointer to start of range.
* @param __hi Pointer to end of range.
* @return @a __hi.
*/
virtual const char_type*
do_tolower(char_type* __lo, const char_type* __hi) const = 0;
/**
* @brief Widen char
*
* This virtual function converts the char to char_type using the
* simplest reasonable transformation.
*
* do_widen() is a hook for a derived facet to change the behavior of
* widening. do_widen() must always return the same result for the
* same input.
*
* Note: this is not what you want for codepage conversions. See
* codecvt for that.
*
* @param __c The char to convert.
* @return The converted char_type
*/
virtual char_type
do_widen(char __c) const = 0;
/**
* @brief Widen char array
*
* This function converts each char in the input to char_type using the
* simplest reasonable transformation.
*
* do_widen() is a hook for a derived facet to change the behavior of
* widening. do_widen() must always return the same result for the
* same input.
*
* Note: this is not what you want for codepage conversions. See
* codecvt for that.
*
* @param __lo Pointer to start range.
* @param __hi Pointer to end of range.
* @param __to Pointer to the destination array.
* @return @a __hi.
*/
virtual const char*
do_widen(const char* __lo, const char* __hi, char_type* __to) const = 0;
/**
* @brief Narrow char_type to char
*
* This virtual function converts the argument to char using the
* simplest reasonable transformation. If the conversion fails, dfault
* is returned instead.
*
* do_narrow() is a hook for a derived facet to change the behavior of
* narrowing. do_narrow() must always return the same result for the
* same input.
*
* Note: this is not what you want for codepage conversions. See
* codecvt for that.
*
* @param __c The char_type to convert.
* @param __dfault Char to return if conversion fails.
* @return The converted char.
*/
virtual char
do_narrow(char_type __c, char __dfault) const = 0;
/**
* @brief Narrow char_type array to char
*
* This virtual function converts each char_type in the range
* [__lo,__hi) to char using the simplest reasonable
* transformation and writes the results to the destination
* array. For any element in the input that cannot be
* converted, @a __dfault is used instead.
*
* do_narrow() is a hook for a derived facet to change the behavior of
* narrowing. do_narrow() must always return the same result for the
* same input.
*
* Note: this is not what you want for codepage conversions. See
* codecvt for that.
*
* @param __lo Pointer to start of range.
* @param __hi Pointer to end of range.
* @param __dfault Char to use if conversion fails.
* @param __to Pointer to the destination array.
* @return @a __hi.
*/
virtual const char_type*
do_narrow(const char_type* __lo, const char_type* __hi,
char __dfault, char* __to) const = 0;
};
/**
* @brief Primary class template ctype facet.
* @ingroup locales
*
* This template class defines classification and conversion functions for
* character sets. It wraps cctype functionality. Ctype gets used by
* streams for many I/O operations.
*
* This template provides the protected virtual functions the developer
* will have to replace in a derived class or specialization to make a
* working facet. The public functions that access them are defined in
* __ctype_abstract_base, to allow for implementation flexibility. See
* ctype<wchar_t> for an example. The functions are documented in
* __ctype_abstract_base.
*
* Note: implementations are provided for all the protected virtual
* functions, but will likely not be useful.
*/
template<typename _CharT>
class ctype : public __ctype_abstract_base<_CharT>
{
public:
// Types:
typedef _CharT char_type;
typedef typename __ctype_abstract_base<_CharT>::mask mask;
/// The facet id for ctype<char_type>
static locale::id id;
explicit
ctype(size_t __refs = 0) : __ctype_abstract_base<_CharT>(__refs) { }
protected:
virtual
~ctype();
virtual bool
do_is(mask __m, char_type __c) const;
virtual const char_type*
do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const;
virtual const char_type*
do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const;
virtual const char_type*
do_scan_not(mask __m, const char_type* __lo,
const char_type* __hi) const;
virtual char_type
do_toupper(char_type __c) const;
virtual const char_type*
do_toupper(char_type* __lo, const char_type* __hi) const;
virtual char_type
do_tolower(char_type __c) const;
virtual const char_type*
do_tolower(char_type* __lo, const char_type* __hi) const;
virtual char_type
do_widen(char __c) const;
virtual const char*
do_widen(const char* __lo, const char* __hi, char_type* __dest) const;
virtual char
do_narrow(char_type, char __dfault) const;
virtual const char_type*
do_narrow(const char_type* __lo, const char_type* __hi,
char __dfault, char* __to) const;
};
template<typename _CharT>
locale::id ctype<_CharT>::id;
/**
* @brief The ctype<char> specialization.
* @ingroup locales
*
* This class defines classification and conversion functions for
* the char type. It gets used by char streams for many I/O
* operations. The char specialization provides a number of
* optimizations as well.
*/
template<>
class ctype<char> : public locale::facet, public ctype_base
{
public:
// Types:
/// Typedef for the template parameter char.
typedef char char_type;
protected:
// Data Members:
__c_locale _M_c_locale_ctype;
bool _M_del;
__to_type _M_toupper;
__to_type _M_tolower;
const mask* _M_table;
mutable char _M_widen_ok;
mutable char _M_widen[1 + static_cast<unsigned char>(-1)];
mutable char _M_narrow[1 + static_cast<unsigned char>(-1)];
mutable char _M_narrow_ok; // 0 uninitialized, 1 init,
// 2 memcpy can't be used
public:
/// The facet id for ctype<char>
static locale::id id;
/// The size of the mask table. It is SCHAR_MAX + 1.
static const size_t table_size = 1 + static_cast<unsigned char>(-1);
/**
* @brief Constructor performs initialization.
*
* This is the constructor provided by the standard.
*
* @param __table If non-zero, table is used as the per-char mask.
* Else classic_table() is used.
* @param __del If true, passes ownership of table to this facet.
* @param __refs Passed to the base facet class.
*/
explicit
ctype(const mask* __table = 0, bool __del = false, size_t __refs = 0);
/**
* @brief Constructor performs static initialization.
*
* This constructor is used to construct the initial C locale facet.
*
* @param __cloc Handle to C locale data.
* @param __table If non-zero, table is used as the per-char mask.
* @param __del If true, passes ownership of table to this facet.
* @param __refs Passed to the base facet class.
*/
explicit
ctype(__c_locale __cloc, const mask* __table = 0, bool __del = false,
size_t __refs = 0);
/**
* @brief Test char classification.
*
* This function compares the mask table[c] to @a __m.
*
* @param __c The char to compare the mask of.
* @param __m The mask to compare against.
* @return True if __m & table[__c] is true, false otherwise.
*/
inline bool
is(mask __m, char __c) const;
/**
* @brief Return a mask array.
*
* This function finds the mask for each char in the range [lo, hi) and
* successively writes it to vec. vec must have as many elements as
* the char array.
*
* @param __lo Pointer to start of range.
* @param __hi Pointer to end of range.
* @param __vec Pointer to an array of mask storage.
* @return @a __hi.
*/
inline const char*
is(const char* __lo, const char* __hi, mask* __vec) const;
/**
* @brief Find char matching a mask
*
* This function searches for and returns the first char in [lo,hi) for
* which is(m,char) is true.
*
* @param __m The mask to compare against.
* @param __lo Pointer to start of range.
* @param __hi Pointer to end of range.
* @return Pointer to a matching char if found, else @a __hi.
*/
inline const char*
scan_is(mask __m, const char* __lo, const char* __hi) const;
/**
* @brief Find char not matching a mask
*
* This function searches for and returns a pointer to the first char
* in [__lo,__hi) for which is(m,char) is false.
*
* @param __m The mask to compare against.
* @param __lo Pointer to start of range.
* @param __hi Pointer to end of range.
* @return Pointer to a non-matching char if found, else @a __hi.
*/
inline const char*
scan_not(mask __m, const char* __lo, const char* __hi) const;
/**
* @brief Convert to uppercase.
*
* This function converts the char argument to uppercase if possible.
* If not possible (for example, '2'), returns the argument.
*
* toupper() acts as if it returns ctype<char>::do_toupper(c).
* do_toupper() must always return the same result for the same input.
*
* @param __c The char to convert.
* @return The uppercase char if convertible, else @a __c.
*/
char_type
toupper(char_type __c) const
{ return this->do_toupper(__c); }
/**
* @brief Convert array to uppercase.
*
* This function converts each char in the range [__lo,__hi) to uppercase
* if possible. Other chars remain untouched.
*
* toupper() acts as if it returns ctype<char>:: do_toupper(__lo, __hi).
* do_toupper() must always return the same result for the same input.
*
* @param __lo Pointer to first char in range.
* @param __hi Pointer to end of range.
* @return @a __hi.
*/
const char_type*
toupper(char_type *__lo, const char_type* __hi) const
{ return this->do_toupper(__lo, __hi); }
/**
* @brief Convert to lowercase.
*
* This function converts the char argument to lowercase if possible.
* If not possible (for example, '2'), returns the argument.
*
* tolower() acts as if it returns ctype<char>::do_tolower(__c).
* do_tolower() must always return the same result for the same input.
*
* @param __c The char to convert.
* @return The lowercase char if convertible, else @a __c.
*/
char_type
tolower(char_type __c) const
{ return this->do_tolower(__c); }
/**
* @brief Convert array to lowercase.
*
* This function converts each char in the range [lo,hi) to lowercase
* if possible. Other chars remain untouched.
*
* tolower() acts as if it returns ctype<char>:: do_tolower(__lo, __hi).
* do_tolower() must always return the same result for the same input.
*
* @param __lo Pointer to first char in range.
* @param __hi Pointer to end of range.
* @return @a __hi.
*/
const char_type*
tolower(char_type* __lo, const char_type* __hi) const
{ return this->do_tolower(__lo, __hi); }
/**
* @brief Widen char
*
* This function converts the char to char_type using the simplest
* reasonable transformation. For an underived ctype<char> facet, the
* argument will be returned unchanged.
*
* This function works as if it returns ctype<char>::do_widen(c).
* do_widen() must always return the same result for the same input.
*
* Note: this is not what you want for codepage conversions. See
* codecvt for that.
*
* @param __c The char to convert.
* @return The converted character.
*/
char_type
widen(char __c) const
{
if (_M_widen_ok)
return _M_widen[static_cast<unsigned char>(__c)];
this->_M_widen_init();
return this->do_widen(__c);
}
/**
* @brief Widen char array
*
* This function converts each char in the input to char using the
* simplest reasonable transformation. For an underived ctype<char>
* facet, the argument will be copied unchanged.
*
* This function works as if it returns ctype<char>::do_widen(c).
* do_widen() must always return the same result for the same input.
*
* Note: this is not what you want for codepage conversions. See
* codecvt for that.
*
* @param __lo Pointer to first char in range.
* @param __hi Pointer to end of range.
* @param __to Pointer to the destination array.
* @return @a __hi.
*/
const char*
widen(const char* __lo, const char* __hi, char_type* __to) const
{
if (_M_widen_ok == 1)
{
if (__builtin_expect(__hi != __lo, true))
__builtin_memcpy(__to, __lo, __hi - __lo);
return __hi;
}
if (!_M_widen_ok)
_M_widen_init();
return this->do_widen(__lo, __hi, __to);
}
/**
* @brief Narrow char
*
* This function converts the char to char using the simplest
* reasonable transformation. If the conversion fails, dfault is
* returned instead. For an underived ctype<char> facet, @a c
* will be returned unchanged.
*
* This function works as if it returns ctype<char>::do_narrow(c).
* do_narrow() must always return the same result for the same input.
*
* Note: this is not what you want for codepage conversions. See
* codecvt for that.
*
* @param __c The char to convert.
* @param __dfault Char to return if conversion fails.
* @return The converted character.
*/
char
narrow(char_type __c, char __dfault) const
{
if (_M_narrow[static_cast<unsigned char>(__c)])
return _M_narrow[static_cast<unsigned char>(__c)];
const char __t = do_narrow(__c, __dfault);
if (__t != __dfault)
_M_narrow[static_cast<unsigned char>(__c)] = __t;
return __t;
}
/**
* @brief Narrow char array
*
* This function converts each char in the input to char using the
* simplest reasonable transformation and writes the results to the
* destination array. For any char in the input that cannot be
* converted, @a dfault is used instead. For an underived ctype<char>
* facet, the argument will be copied unchanged.
*
* This function works as if it returns ctype<char>::do_narrow(lo, hi,
* dfault, to). do_narrow() must always return the same result for the
* same input.
*
* Note: this is not what you want for codepage conversions. See
* codecvt for that.
*
* @param __lo Pointer to start of range.
* @param __hi Pointer to end of range.
* @param __dfault Char to use if conversion fails.
* @param __to Pointer to the destination array.
* @return @a __hi.
*/
const char_type*
narrow(const char_type* __lo, const char_type* __hi,
char __dfault, char* __to) const
{
if (__builtin_expect(_M_narrow_ok == 1, true))
{
if (__builtin_expect(__hi != __lo, true))
__builtin_memcpy(__to, __lo, __hi - __lo);
return __hi;
}
if (!_M_narrow_ok)
_M_narrow_init();
return this->do_narrow(__lo, __hi, __dfault, __to);
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 695. ctype<char>::classic_table() not accessible.
/// Returns a pointer to the mask table provided to the constructor, or
/// the default from classic_table() if none was provided.
const mask*
table() const throw()
{ return _M_table; }
/// Returns a pointer to the C locale mask table.
static const mask*
classic_table() throw();
protected:
/**
* @brief Destructor.
*
* This function deletes table() if @a del was true in the
* constructor.
*/
virtual
~ctype();
/**
* @brief Convert to uppercase.
*
* This virtual function converts the char argument to uppercase if
* possible. If not possible (for example, '2'), returns the argument.
*
* do_toupper() is a hook for a derived facet to change the behavior of
* uppercasing. do_toupper() must always return the same result for
* the same input.
*
* @param __c The char to convert.
* @return The uppercase char if convertible, else @a __c.
*/
virtual char_type
do_toupper(char_type __c) const;
/**
* @brief Convert array to uppercase.
*
* This virtual function converts each char in the range [lo,hi) to
* uppercase if possible. Other chars remain untouched.
*
* do_toupper() is a hook for a derived facet to change the behavior of
* uppercasing. do_toupper() must always return the same result for
* the same input.
*
* @param __lo Pointer to start of range.
* @param __hi Pointer to end of range.
* @return @a __hi.
*/
virtual const char_type*
do_toupper(char_type* __lo, const char_type* __hi) const;
/**
* @brief Convert to lowercase.
*
* This virtual function converts the char argument to lowercase if
* possible. If not possible (for example, '2'), returns the argument.
*
* do_tolower() is a hook for a derived facet to change the behavior of
* lowercasing. do_tolower() must always return the same result for
* the same input.
*
* @param __c The char to convert.
* @return The lowercase char if convertible, else @a __c.
*/
virtual char_type
do_tolower(char_type __c) const;
/**
* @brief Convert array to lowercase.
*
* This virtual function converts each char in the range [lo,hi) to
* lowercase if possible. Other chars remain untouched.
*
* do_tolower() is a hook for a derived facet to change the behavior of
* lowercasing. do_tolower() must always return the same result for
* the same input.
*
* @param __lo Pointer to first char in range.
* @param __hi Pointer to end of range.
* @return @a __hi.
*/
virtual const char_type*
do_tolower(char_type* __lo, const char_type* __hi) const;
/**
* @brief Widen char
*
* This virtual function converts the char to char using the simplest
* reasonable transformation. For an underived ctype<char> facet, the
* argument will be returned unchanged.
*
* do_widen() is a hook for a derived facet to change the behavior of
* widening. do_widen() must always return the same result for the
* same input.
*
* Note: this is not what you want for codepage conversions. See
* codecvt for that.
*
* @param __c The char to convert.
* @return The converted character.
*/
virtual char_type
do_widen(char __c) const
{ return __c; }
/**
* @brief Widen char array
*
* This function converts each char in the range [lo,hi) to char using
* the simplest reasonable transformation. For an underived
* ctype<char> facet, the argument will be copied unchanged.
*
* do_widen() is a hook for a derived facet to change the behavior of
* widening. do_widen() must always return the same result for the
* same input.
*
* Note: this is not what you want for codepage conversions. See
* codecvt for that.
*
* @param __lo Pointer to start of range.
* @param __hi Pointer to end of range.
* @param __to Pointer to the destination array.
* @return @a __hi.
*/
virtual const char*
do_widen(const char* __lo, const char* __hi, char_type* __to) const
{
if (__builtin_expect(__hi != __lo, true))
__builtin_memcpy(__to, __lo, __hi - __lo);
return __hi;
}
/**
* @brief Narrow char
*
* This virtual function converts the char to char using the simplest
* reasonable transformation. If the conversion fails, dfault is
* returned instead. For an underived ctype<char> facet, @a c will be
* returned unchanged.
*
* do_narrow() is a hook for a derived facet to change the behavior of
* narrowing. do_narrow() must always return the same result for the
* same input.
*
* Note: this is not what you want for codepage conversions. See
* codecvt for that.
*
* @param __c The char to convert.
* @param __dfault Char to return if conversion fails.
* @return The converted char.
*/
virtual char
do_narrow(char_type __c, char __dfault __attribute__((__unused__))) const
{ return __c; }
/**
* @brief Narrow char array to char array
*
* This virtual function converts each char in the range [lo,hi) to
* char using the simplest reasonable transformation and writes the
* results to the destination array. For any char in the input that
* cannot be converted, @a dfault is used instead. For an underived
* ctype<char> facet, the argument will be copied unchanged.
*
* do_narrow() is a hook for a derived facet to change the behavior of
* narrowing. do_narrow() must always return the same result for the
* same input.
*
* Note: this is not what you want for codepage conversions. See
* codecvt for that.
*
* @param __lo Pointer to start of range.
* @param __hi Pointer to end of range.
* @param __dfault Char to use if conversion fails.
* @param __to Pointer to the destination array.
* @return @a __hi.
*/
virtual const char_type*
do_narrow(const char_type* __lo, const char_type* __hi,
char __dfault __attribute__((__unused__)), char* __to) const
{
if (__builtin_expect(__hi != __lo, true))
__builtin_memcpy(__to, __lo, __hi - __lo);
return __hi;
}
private:
void _M_narrow_init() const;
void _M_widen_init() const;
};
#ifdef _GLIBCXX_USE_WCHAR_T
/**
* @brief The ctype<wchar_t> specialization.
* @ingroup locales
*
* This class defines classification and conversion functions for the
* wchar_t type. It gets used by wchar_t streams for many I/O operations.
* The wchar_t specialization provides a number of optimizations as well.
*
* ctype<wchar_t> inherits its public methods from
* __ctype_abstract_base<wchar_t>.
*/
template<>
class ctype<wchar_t> : public __ctype_abstract_base<wchar_t>
{
public:
// Types:
/// Typedef for the template parameter wchar_t.
typedef wchar_t char_type;
typedef wctype_t __wmask_type;
protected:
__c_locale _M_c_locale_ctype;
// Pre-computed narrowed and widened chars.
bool _M_narrow_ok;
char _M_narrow[128];
wint_t _M_widen[1 + static_cast<unsigned char>(-1)];
// Pre-computed elements for do_is.
mask _M_bit[16];
__wmask_type _M_wmask[16];
public:
// Data Members:
/// The facet id for ctype<wchar_t>
static locale::id id;
/**
* @brief Constructor performs initialization.
*
* This is the constructor provided by the standard.
*
* @param __refs Passed to the base facet class.
*/
explicit
ctype(size_t __refs = 0);
/**
* @brief Constructor performs static initialization.
*
* This constructor is used to construct the initial C locale facet.
*
* @param __cloc Handle to C locale data.
* @param __refs Passed to the base facet class.
*/
explicit
ctype(__c_locale __cloc, size_t __refs = 0);
protected:
__wmask_type
_M_convert_to_wmask(const mask __m) const throw();
/// Destructor
virtual
~ctype();
/**
* @brief Test wchar_t classification.
*
* This function finds a mask M for @a c and compares it to mask @a m.
*
* do_is() is a hook for a derived facet to change the behavior of
* classifying. do_is() must always return the same result for the
* same input.
*
* @param __c The wchar_t to find the mask of.
* @param __m The mask to compare against.
* @return (M & __m) != 0.
*/
virtual bool
do_is(mask __m, char_type __c) const;
/**
* @brief Return a mask array.
*
* This function finds the mask for each wchar_t in the range [lo,hi)
* and successively writes it to vec. vec must have as many elements
* as the input.
*
* do_is() is a hook for a derived facet to change the behavior of
* classifying. do_is() must always return the same result for the
* same input.
*
* @param __lo Pointer to start of range.
* @param __hi Pointer to end of range.
* @param __vec Pointer to an array of mask storage.
* @return @a __hi.
*/
virtual const char_type*
do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const;
/**
* @brief Find wchar_t matching mask
*
* This function searches for and returns the first wchar_t c in
* [__lo,__hi) for which is(__m,c) is true.
*
* do_scan_is() is a hook for a derived facet to change the behavior of
* match searching. do_is() must always return the same result for the
* same input.
*
* @param __m The mask to compare against.
* @param __lo Pointer to start of range.
* @param __hi Pointer to end of range.
* @return Pointer to a matching wchar_t if found, else @a __hi.
*/
virtual const char_type*
do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const;
/**
* @brief Find wchar_t not matching mask
*
* This function searches for and returns a pointer to the first
* wchar_t c of [__lo,__hi) for which is(__m,c) is false.
*
* do_scan_is() is a hook for a derived facet to change the behavior of
* match searching. do_is() must always return the same result for the
* same input.
*
* @param __m The mask to compare against.
* @param __lo Pointer to start of range.
* @param __hi Pointer to end of range.
* @return Pointer to a non-matching wchar_t if found, else @a __hi.
*/
virtual const char_type*
do_scan_not(mask __m, const char_type* __lo,
const char_type* __hi) const;
/**
* @brief Convert to uppercase.
*
* This virtual function converts the wchar_t argument to uppercase if
* possible. If not possible (for example, '2'), returns the argument.
*
* do_toupper() is a hook for a derived facet to change the behavior of
* uppercasing. do_toupper() must always return the same result for
* the same input.
*
* @param __c The wchar_t to convert.
* @return The uppercase wchar_t if convertible, else @a __c.
*/
virtual char_type
do_toupper(char_type __c) const;
/**
* @brief Convert array to uppercase.
*
* This virtual function converts each wchar_t in the range [lo,hi) to
* uppercase if possible. Other elements remain untouched.
*
* do_toupper() is a hook for a derived facet to change the behavior of
* uppercasing. do_toupper() must always return the same result for
* the same input.
*
* @param __lo Pointer to start of range.
* @param __hi Pointer to end of range.
* @return @a __hi.
*/
virtual const char_type*
do_toupper(char_type* __lo, const char_type* __hi) const;
/**
* @brief Convert to lowercase.
*
* This virtual function converts the argument to lowercase if
* possible. If not possible (for example, '2'), returns the argument.
*
* do_tolower() is a hook for a derived facet to change the behavior of
* lowercasing. do_tolower() must always return the same result for
* the same input.
*
* @param __c The wchar_t to convert.
* @return The lowercase wchar_t if convertible, else @a __c.
*/
virtual char_type
do_tolower(char_type __c) const;
/**
* @brief Convert array to lowercase.
*
* This virtual function converts each wchar_t in the range [lo,hi) to
* lowercase if possible. Other elements remain untouched.
*
* do_tolower() is a hook for a derived facet to change the behavior of
* lowercasing. do_tolower() must always return the same result for
* the same input.
*
* @param __lo Pointer to start of range.
* @param __hi Pointer to end of range.
* @return @a __hi.
*/
virtual const char_type*
do_tolower(char_type* __lo, const char_type* __hi) const;
/**
* @brief Widen char to wchar_t
*
* This virtual function converts the char to wchar_t using the
* simplest reasonable transformation. For an underived ctype<wchar_t>
* facet, the argument will be cast to wchar_t.
*
* do_widen() is a hook for a derived facet to change the behavior of
* widening. do_widen() must always return the same result for the
* same input.
*
* Note: this is not what you want for codepage conversions. See
* codecvt for that.
*
* @param __c The char to convert.
* @return The converted wchar_t.
*/
virtual char_type
do_widen(char __c) const;
/**
* @brief Widen char array to wchar_t array
*
* This function converts each char in the input to wchar_t using the
* simplest reasonable transformation. For an underived ctype<wchar_t>
* facet, the argument will be copied, casting each element to wchar_t.
*
* do_widen() is a hook for a derived facet to change the behavior of
* widening. do_widen() must always return the same result for the
* same input.
*
* Note: this is not what you want for codepage conversions. See
* codecvt for that.
*
* @param __lo Pointer to start range.
* @param __hi Pointer to end of range.
* @param __to Pointer to the destination array.
* @return @a __hi.
*/
virtual const char*
do_widen(const char* __lo, const char* __hi, char_type* __to) const;
/**
* @brief Narrow wchar_t to char
*
* This virtual function converts the argument to char using
* the simplest reasonable transformation. If the conversion
* fails, dfault is returned instead. For an underived
* ctype<wchar_t> facet, @a c will be cast to char and
* returned.
*
* do_narrow() is a hook for a derived facet to change the
* behavior of narrowing. do_narrow() must always return the
* same result for the same input.
*
* Note: this is not what you want for codepage conversions. See
* codecvt for that.
*
* @param __c The wchar_t to convert.
* @param __dfault Char to return if conversion fails.
* @return The converted char.
*/
virtual char
do_narrow(char_type __c, char __dfault) const;
/**
* @brief Narrow wchar_t array to char array
*
* This virtual function converts each wchar_t in the range [lo,hi) to
* char using the simplest reasonable transformation and writes the
* results to the destination array. For any wchar_t in the input that
* cannot be converted, @a dfault is used instead. For an underived
* ctype<wchar_t> facet, the argument will be copied, casting each
* element to char.
*
* do_narrow() is a hook for a derived facet to change the behavior of
* narrowing. do_narrow() must always return the same result for the
* same input.
*
* Note: this is not what you want for codepage conversions. See
* codecvt for that.
*
* @param __lo Pointer to start of range.
* @param __hi Pointer to end of range.
* @param __dfault Char to use if conversion fails.
* @param __to Pointer to the destination array.
* @return @a __hi.
*/
virtual const char_type*
do_narrow(const char_type* __lo, const char_type* __hi,
char __dfault, char* __to) const;
// For use at construction time only.
void
_M_initialize_ctype() throw();
};
#endif //_GLIBCXX_USE_WCHAR_T
/// class ctype_byname [22.2.1.2].
template<typename _CharT>
class ctype_byname : public ctype<_CharT>
{
public:
typedef typename ctype<_CharT>::mask mask;
explicit
ctype_byname(const char* __s, size_t __refs = 0);
#if __cplusplus >= 201103L
explicit
ctype_byname(const string& __s, size_t __refs = 0)
: ctype_byname(__s.c_str(), __refs) { }
#endif
protected:
virtual
~ctype_byname() { }
};
/// 22.2.1.4 Class ctype_byname specializations.
template<>
class ctype_byname<char> : public ctype<char>
{
public:
explicit
ctype_byname(const char* __s, size_t __refs = 0);
#if __cplusplus >= 201103L
explicit
ctype_byname(const string& __s, size_t __refs = 0);
#endif
protected:
virtual
~ctype_byname();
};
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
class ctype_byname<wchar_t> : public ctype<wchar_t>
{
public:
explicit
ctype_byname(const char* __s, size_t __refs = 0);
#if __cplusplus >= 201103L
explicit
ctype_byname(const string& __s, size_t __refs = 0);
#endif
protected:
virtual
~ctype_byname();
};
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
// Include host and configuration specific ctype inlines.
#include <bits/ctype_inline.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// 22.2.2 The numeric category.
class __num_base
{
public:
// NB: Code depends on the order of _S_atoms_out elements.
// Below are the indices into _S_atoms_out.
enum
{
_S_ominus,
_S_oplus,
_S_ox,
_S_oX,
_S_odigits,
_S_odigits_end = _S_odigits + 16,
_S_oudigits = _S_odigits_end,
_S_oudigits_end = _S_oudigits + 16,
_S_oe = _S_odigits + 14, // For scientific notation, 'e'
_S_oE = _S_oudigits + 14, // For scientific notation, 'E'
_S_oend = _S_oudigits_end
};
// A list of valid numeric literals for output. This array
// contains chars that will be passed through the current locale's
// ctype<_CharT>.widen() and then used to render numbers.
// For the standard "C" locale, this is
// "-+xX0123456789abcdef0123456789ABCDEF".
static const char* _S_atoms_out;
// String literal of acceptable (narrow) input, for num_get.
// "-+xX0123456789abcdefABCDEF"
static const char* _S_atoms_in;
enum
{
_S_iminus,
_S_iplus,
_S_ix,
_S_iX,
_S_izero,
_S_ie = _S_izero + 14,
_S_iE = _S_izero + 20,
_S_iend = 26
};
// num_put
// Construct and return valid scanf format for floating point types.
static void
_S_format_float(const ios_base& __io, char* __fptr, char __mod) throw();
};
template<typename _CharT>
struct __numpunct_cache : public locale::facet
{
const char* _M_grouping;
size_t _M_grouping_size;
bool _M_use_grouping;
const _CharT* _M_truename;
size_t _M_truename_size;
const _CharT* _M_falsename;
size_t _M_falsename_size;
_CharT _M_decimal_point;
_CharT _M_thousands_sep;
// A list of valid numeric literals for output: in the standard
// "C" locale, this is "-+xX0123456789abcdef0123456789ABCDEF".
// This array contains the chars after having been passed
// through the current locale's ctype<_CharT>.widen().
_CharT _M_atoms_out[__num_base::_S_oend];
// A list of valid numeric literals for input: in the standard
// "C" locale, this is "-+xX0123456789abcdefABCDEF"
// This array contains the chars after having been passed
// through the current locale's ctype<_CharT>.widen().
_CharT _M_atoms_in[__num_base::_S_iend];
bool _M_allocated;
__numpunct_cache(size_t __refs = 0)
: facet(__refs), _M_grouping(0), _M_grouping_size(0),
_M_use_grouping(false),
_M_truename(0), _M_truename_size(0), _M_falsename(0),
_M_falsename_size(0), _M_decimal_point(_CharT()),
_M_thousands_sep(_CharT()), _M_allocated(false)
{ }
~__numpunct_cache();
void
_M_cache(const locale& __loc);
private:
__numpunct_cache&
operator=(const __numpunct_cache&);
explicit
__numpunct_cache(const __numpunct_cache&);
};
template<typename _CharT>
__numpunct_cache<_CharT>::~__numpunct_cache()
{
if (_M_allocated)
{
delete [] _M_grouping;
delete [] _M_truename;
delete [] _M_falsename;
}
}
_GLIBCXX_BEGIN_NAMESPACE_CXX11
/**
* @brief Primary class template numpunct.
* @ingroup locales
*
* This facet stores several pieces of information related to printing and
* scanning numbers, such as the decimal point character. It takes a
* template parameter specifying the char type. The numpunct facet is
* used by streams for many I/O operations involving numbers.
*
* The numpunct template uses protected virtual functions to provide the
* actual results. The public accessors forward the call to the virtual
* functions. These virtual functions are hooks for developers to
* implement the behavior they require from a numpunct facet.
*/
template<typename _CharT>
class numpunct : public locale::facet
{
public:
// Types:
//@{
/// Public typedefs
typedef _CharT char_type;
typedef basic_string<_CharT> string_type;
//@}
typedef __numpunct_cache<_CharT> __cache_type;
protected:
__cache_type* _M_data;
public:
/// Numpunct facet id.
static locale::id id;
/**
* @brief Numpunct constructor.
*
* @param __refs Refcount to pass to the base class.
*/
explicit
numpunct(size_t __refs = 0)
: facet(__refs), _M_data(0)
{ _M_initialize_numpunct(); }
/**
* @brief Internal constructor. Not for general use.
*
* This is a constructor for use by the library itself to set up the
* predefined locale facets.
*
* @param __cache __numpunct_cache object.
* @param __refs Refcount to pass to the base class.
*/
explicit
numpunct(__cache_type* __cache, size_t __refs = 0)
: facet(__refs), _M_data(__cache)
{ _M_initialize_numpunct(); }
/**
* @brief Internal constructor. Not for general use.
*
* This is a constructor for use by the library itself to set up new
* locales.
*
* @param __cloc The C locale.
* @param __refs Refcount to pass to the base class.
*/
explicit
numpunct(__c_locale __cloc, size_t __refs = 0)
: facet(__refs), _M_data(0)
{ _M_initialize_numpunct(__cloc); }
/**
* @brief Return decimal point character.
*
* This function returns a char_type to use as a decimal point. It
* does so by returning returning
* numpunct<char_type>::do_decimal_point().
*
* @return @a char_type representing a decimal point.
*/
char_type
decimal_point() const
{ return this->do_decimal_point(); }
/**
* @brief Return thousands separator character.
*
* This function returns a char_type to use as a thousands
* separator. It does so by returning returning
* numpunct<char_type>::do_thousands_sep().
*
* @return char_type representing a thousands separator.
*/
char_type
thousands_sep() const
{ return this->do_thousands_sep(); }
/**
* @brief Return grouping specification.
*
* This function returns a string representing groupings for the
* integer part of a number. Groupings indicate where thousands
* separators should be inserted in the integer part of a number.
*
* Each char in the return string is interpret as an integer
* rather than a character. These numbers represent the number
* of digits in a group. The first char in the string
* represents the number of digits in the least significant
* group. If a char is negative, it indicates an unlimited
* number of digits for the group. If more chars from the
* string are required to group a number, the last char is used
* repeatedly.
*
* For example, if the grouping() returns "\003\002" and is
* applied to the number 123456789, this corresponds to
* 12,34,56,789. Note that if the string was "32", this would
* put more than 50 digits into the least significant group if
* the character set is ASCII.
*
* The string is returned by calling
* numpunct<char_type>::do_grouping().
*
* @return string representing grouping specification.
*/
string
grouping() const
{ return this->do_grouping(); }
/**
* @brief Return string representation of bool true.
*
* This function returns a string_type containing the text
* representation for true bool variables. It does so by calling
* numpunct<char_type>::do_truename().
*
* @return string_type representing printed form of true.
*/
string_type
truename() const
{ return this->do_truename(); }
/**
* @brief Return string representation of bool false.
*
* This function returns a string_type containing the text
* representation for false bool variables. It does so by calling
* numpunct<char_type>::do_falsename().
*
* @return string_type representing printed form of false.
*/
string_type
falsename() const
{ return this->do_falsename(); }
protected:
/// Destructor.
virtual
~numpunct();
/**
* @brief Return decimal point character.
*
* Returns a char_type to use as a decimal point. This function is a
* hook for derived classes to change the value returned.
*
* @return @a char_type representing a decimal point.
*/
virtual char_type
do_decimal_point() const
{ return _M_data->_M_decimal_point; }
/**
* @brief Return thousands separator character.
*
* Returns a char_type to use as a thousands separator. This function
* is a hook for derived classes to change the value returned.
*
* @return @a char_type representing a thousands separator.
*/
virtual char_type
do_thousands_sep() const
{ return _M_data->_M_thousands_sep; }
/**
* @brief Return grouping specification.
*
* Returns a string representing groupings for the integer part of a
* number. This function is a hook for derived classes to change the
* value returned. @see grouping() for details.
*
* @return String representing grouping specification.
*/
virtual string
do_grouping() const
{ return _M_data->_M_grouping; }
/**
* @brief Return string representation of bool true.
*
* Returns a string_type containing the text representation for true
* bool variables. This function is a hook for derived classes to
* change the value returned.
*
* @return string_type representing printed form of true.
*/
virtual string_type
do_truename() const
{ return _M_data->_M_truename; }
/**
* @brief Return string representation of bool false.
*
* Returns a string_type containing the text representation for false
* bool variables. This function is a hook for derived classes to
* change the value returned.
*
* @return string_type representing printed form of false.
*/
virtual string_type
do_falsename() const
{ return _M_data->_M_falsename; }
// For use at construction time only.
void
_M_initialize_numpunct(__c_locale __cloc = 0);
};
template<typename _CharT>
locale::id numpunct<_CharT>::id;
template<>
numpunct<char>::~numpunct();
template<>
void
numpunct<char>::_M_initialize_numpunct(__c_locale __cloc);
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
numpunct<wchar_t>::~numpunct();
template<>
void
numpunct<wchar_t>::_M_initialize_numpunct(__c_locale __cloc);
#endif
/// class numpunct_byname [22.2.3.2].
template<typename _CharT>
class numpunct_byname : public numpunct<_CharT>
{
public:
typedef _CharT char_type;
typedef basic_string<_CharT> string_type;
explicit
numpunct_byname(const char* __s, size_t __refs = 0)
: numpunct<_CharT>(__refs)
{
if (__builtin_strcmp(__s, "C") != 0
&& __builtin_strcmp(__s, "POSIX") != 0)
{
__c_locale __tmp;
this->_S_create_c_locale(__tmp, __s);
this->_M_initialize_numpunct(__tmp);
this->_S_destroy_c_locale(__tmp);
}
}
#if __cplusplus >= 201103L
explicit
numpunct_byname(const string& __s, size_t __refs = 0)
: numpunct_byname(__s.c_str(), __refs) { }
#endif
protected:
virtual
~numpunct_byname() { }
};
_GLIBCXX_END_NAMESPACE_CXX11
_GLIBCXX_BEGIN_NAMESPACE_LDBL
/**
* @brief Primary class template num_get.
* @ingroup locales
*
* This facet encapsulates the code to parse and return a number
* from a string. It is used by the istream numeric extraction
* operators.
*
* The num_get template uses protected virtual functions to provide the
* actual results. The public accessors forward the call to the virtual
* functions. These virtual functions are hooks for developers to
* implement the behavior they require from the num_get facet.
*/
template<typename _CharT, typename _InIter>
class num_get : public locale::facet
{
public:
// Types:
//@{
/// Public typedefs
typedef _CharT char_type;
typedef _InIter iter_type;
//@}
/// Numpunct facet id.
static locale::id id;
/**
* @brief Constructor performs initialization.
*
* This is the constructor provided by the standard.
*
* @param __refs Passed to the base facet class.
*/
explicit
num_get(size_t __refs = 0) : facet(__refs) { }
/**
* @brief Numeric parsing.
*
* Parses the input stream into the bool @a v. It does so by calling
* num_get::do_get().
*
* If ios_base::boolalpha is set, attempts to read
* ctype<CharT>::truename() or ctype<CharT>::falsename(). Sets
* @a v to true or false if successful. Sets err to
* ios_base::failbit if reading the string fails. Sets err to
* ios_base::eofbit if the stream is emptied.
*
* If ios_base::boolalpha is not set, proceeds as with reading a long,
* except if the value is 1, sets @a v to true, if the value is 0, sets
* @a v to false, and otherwise set err to ios_base::failbit.
*
* @param __in Start of input stream.
* @param __end End of input stream.
* @param __io Source of locale and flags.
* @param __err Error flags to set.
* @param __v Value to format and insert.
* @return Iterator after reading.
*/
iter_type
get(iter_type __in, iter_type __end, ios_base& __io,
ios_base::iostate& __err, bool& __v) const
{ return this->do_get(__in, __end, __io, __err, __v); }
//@{
/**
* @brief Numeric parsing.
*
* Parses the input stream into the integral variable @a v. It does so
* by calling num_get::do_get().
*
* Parsing is affected by the flag settings in @a io.
*
* The basic parse is affected by the value of io.flags() &
* ios_base::basefield. If equal to ios_base::oct, parses like the
* scanf %o specifier. Else if equal to ios_base::hex, parses like %X
* specifier. Else if basefield equal to 0, parses like the %i
* specifier. Otherwise, parses like %d for signed and %u for unsigned
* types. The matching type length modifier is also used.
*
* Digit grouping is interpreted according to
* numpunct::grouping() and numpunct::thousands_sep(). If the
* pattern of digit groups isn't consistent, sets err to
* ios_base::failbit.
*
* If parsing the string yields a valid value for @a v, @a v is set.
* Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
* Sets err to ios_base::eofbit if the stream is emptied.
*
* @param __in Start of input stream.
* @param __end End of input stream.
* @param __io Source of locale and flags.
* @param __err Error flags to set.
* @param __v Value to format and insert.
* @return Iterator after reading.
*/
iter_type
get(iter_type __in, iter_type __end, ios_base& __io,
ios_base::iostate& __err, long& __v) const
{ return this->do_get(__in, __end, __io, __err, __v); }
iter_type
get(iter_type __in, iter_type __end, ios_base& __io,
ios_base::iostate& __err, unsigned short& __v) const
{ return this->do_get(__in, __end, __io, __err, __v); }
iter_type
get(iter_type __in, iter_type __end, ios_base& __io,
ios_base::iostate& __err, unsigned int& __v) const
{ return this->do_get(__in, __end, __io, __err, __v); }
iter_type
get(iter_type __in, iter_type __end, ios_base& __io,
ios_base::iostate& __err, unsigned long& __v) const
{ return this->do_get(__in, __end, __io, __err, __v); }
#ifdef _GLIBCXX_USE_LONG_LONG
iter_type
get(iter_type __in, iter_type __end, ios_base& __io,
ios_base::iostate& __err, long long& __v) const
{ return this->do_get(__in, __end, __io, __err, __v); }
iter_type
get(iter_type __in, iter_type __end, ios_base& __io,
ios_base::iostate& __err, unsigned long long& __v) const
{ return this->do_get(__in, __end, __io, __err, __v); }
#endif
//@}
//@{
/**
* @brief Numeric parsing.
*
* Parses the input stream into the integral variable @a v. It does so
* by calling num_get::do_get().
*
* The input characters are parsed like the scanf %g specifier. The
* matching type length modifier is also used.
*
* The decimal point character used is numpunct::decimal_point().
* Digit grouping is interpreted according to
* numpunct::grouping() and numpunct::thousands_sep(). If the
* pattern of digit groups isn't consistent, sets err to
* ios_base::failbit.
*
* If parsing the string yields a valid value for @a v, @a v is set.
* Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
* Sets err to ios_base::eofbit if the stream is emptied.
*
* @param __in Start of input stream.
* @param __end End of input stream.
* @param __io Source of locale and flags.
* @param __err Error flags to set.
* @param __v Value to format and insert.
* @return Iterator after reading.
*/
iter_type
get(iter_type __in, iter_type __end, ios_base& __io,
ios_base::iostate& __err, float& __v) const
{ return this->do_get(__in, __end, __io, __err, __v); }
iter_type
get(iter_type __in, iter_type __end, ios_base& __io,
ios_base::iostate& __err, double& __v) const
{ return this->do_get(__in, __end, __io, __err, __v); }
iter_type
get(iter_type __in, iter_type __end, ios_base& __io,
ios_base::iostate& __err, long double& __v) const
{ return this->do_get(__in, __end, __io, __err, __v); }
//@}
/**
* @brief Numeric parsing.
*
* Parses the input stream into the pointer variable @a v. It does so
* by calling num_get::do_get().
*
* The input characters are parsed like the scanf %p specifier.
*
* Digit grouping is interpreted according to
* numpunct::grouping() and numpunct::thousands_sep(). If the
* pattern of digit groups isn't consistent, sets err to
* ios_base::failbit.
*
* Note that the digit grouping effect for pointers is a bit ambiguous
* in the standard and shouldn't be relied on. See DR 344.
*
* If parsing the string yields a valid value for @a v, @a v is set.
* Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
* Sets err to ios_base::eofbit if the stream is emptied.
*
* @param __in Start of input stream.
* @param __end End of input stream.
* @param __io Source of locale and flags.
* @param __err Error flags to set.
* @param __v Value to format and insert.
* @return Iterator after reading.
*/
iter_type
get(iter_type __in, iter_type __end, ios_base& __io,
ios_base::iostate& __err, void*& __v) const
{ return this->do_get(__in, __end, __io, __err, __v); }
protected:
/// Destructor.
virtual ~num_get() { }
_GLIBCXX_DEFAULT_ABI_TAG
iter_type
_M_extract_float(iter_type, iter_type, ios_base&, ios_base::iostate&,
string&) const;
template<typename _ValueT>
_GLIBCXX_DEFAULT_ABI_TAG
iter_type
_M_extract_int(iter_type, iter_type, ios_base&, ios_base::iostate&,
_ValueT&) const;
template<typename _CharT2>
typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, int>::__type
_M_find(const _CharT2*, size_t __len, _CharT2 __c) const
{
int __ret = -1;
if (__len <= 10)
{
if (__c >= _CharT2('0') && __c < _CharT2(_CharT2('0') + __len))
__ret = __c - _CharT2('0');
}
else
{
if (__c >= _CharT2('0') && __c <= _CharT2('9'))
__ret = __c - _CharT2('0');
else if (__c >= _CharT2('a') && __c <= _CharT2('f'))
__ret = 10 + (__c - _CharT2('a'));
else if (__c >= _CharT2('A') && __c <= _CharT2('F'))
__ret = 10 + (__c - _CharT2('A'));
}
return __ret;
}
template<typename _CharT2>
typename __gnu_cxx::__enable_if<!__is_char<_CharT2>::__value,
int>::__type
_M_find(const _CharT2* __zero, size_t __len, _CharT2 __c) const
{
int __ret = -1;
const char_type* __q = char_traits<_CharT2>::find(__zero, __len, __c);
if (__q)
{
__ret = __q - __zero;
if (__ret > 15)
__ret -= 6;
}
return __ret;
}
//@{
/**
* @brief Numeric parsing.
*
* Parses the input stream into the variable @a v. This function is a
* hook for derived classes to change the value returned. @see get()
* for more details.
*
* @param __beg Start of input stream.
* @param __end End of input stream.
* @param __io Source of locale and flags.
* @param __err Error flags to set.
* @param __v Value to format and insert.
* @return Iterator after reading.
*/
virtual iter_type
do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, bool&) const;
virtual iter_type
do_get(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, long& __v) const
{ return _M_extract_int(__beg, __end, __io, __err, __v); }
virtual iter_type
do_get(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, unsigned short& __v) const
{ return _M_extract_int(__beg, __end, __io, __err, __v); }
virtual iter_type
do_get(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, unsigned int& __v) const
{ return _M_extract_int(__beg, __end, __io, __err, __v); }
virtual iter_type
do_get(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, unsigned long& __v) const
{ return _M_extract_int(__beg, __end, __io, __err, __v); }
#ifdef _GLIBCXX_USE_LONG_LONG
virtual iter_type
do_get(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, long long& __v) const
{ return _M_extract_int(__beg, __end, __io, __err, __v); }
virtual iter_type
do_get(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, unsigned long long& __v) const
{ return _M_extract_int(__beg, __end, __io, __err, __v); }
#endif
virtual iter_type
do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, float&) const;
virtual iter_type
do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
double&) const;
// XXX GLIBCXX_ABI Deprecated
#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
virtual iter_type
__do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
double&) const;
#else
virtual iter_type
do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
long double&) const;
#endif
virtual iter_type
do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, void*&) const;
// XXX GLIBCXX_ABI Deprecated
#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
virtual iter_type
do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
long double&) const;
#endif
//@}
};
template<typename _CharT, typename _InIter>
locale::id num_get<_CharT, _InIter>::id;
/**
* @brief Primary class template num_put.
* @ingroup locales
*
* This facet encapsulates the code to convert a number to a string. It is
* used by the ostream numeric insertion operators.
*
* The num_put template uses protected virtual functions to provide the
* actual results. The public accessors forward the call to the virtual
* functions. These virtual functions are hooks for developers to
* implement the behavior they require from the num_put facet.
*/
template<typename _CharT, typename _OutIter>
class num_put : public locale::facet
{
public:
// Types:
//@{
/// Public typedefs
typedef _CharT char_type;
typedef _OutIter iter_type;
//@}
/// Numpunct facet id.
static locale::id id;
/**
* @brief Constructor performs initialization.
*
* This is the constructor provided by the standard.
*
* @param __refs Passed to the base facet class.
*/
explicit
num_put(size_t __refs = 0) : facet(__refs) { }
/**
* @brief Numeric formatting.
*
* Formats the boolean @a v and inserts it into a stream. It does so
* by calling num_put::do_put().
*
* If ios_base::boolalpha is set, writes ctype<CharT>::truename() or
* ctype<CharT>::falsename(). Otherwise formats @a v as an int.
*
* @param __s Stream to write to.
* @param __io Source of locale and flags.
* @param __fill Char_type to use for filling.
* @param __v Value to format and insert.
* @return Iterator after writing.
*/
iter_type
put(iter_type __s, ios_base& __io, char_type __fill, bool __v) const
{ return this->do_put(__s, __io, __fill, __v); }
//@{
/**
* @brief Numeric formatting.
*
* Formats the integral value @a v and inserts it into a
* stream. It does so by calling num_put::do_put().
*
* Formatting is affected by the flag settings in @a io.
*
* The basic format is affected by the value of io.flags() &
* ios_base::basefield. If equal to ios_base::oct, formats like the
* printf %o specifier. Else if equal to ios_base::hex, formats like
* %x or %X with ios_base::uppercase unset or set respectively.
* Otherwise, formats like %d, %ld, %lld for signed and %u, %lu, %llu
* for unsigned values. Note that if both oct and hex are set, neither
* will take effect.
*
* If ios_base::showpos is set, '+' is output before positive values.
* If ios_base::showbase is set, '0' precedes octal values (except 0)
* and '0[xX]' precedes hex values.
*
* The decimal point character used is numpunct::decimal_point().
* Thousands separators are inserted according to
* numpunct::grouping() and numpunct::thousands_sep().
*
* If io.width() is non-zero, enough @a fill characters are inserted to
* make the result at least that wide. If
* (io.flags() & ios_base::adjustfield) == ios_base::left, result is
* padded at the end. If ios_base::internal, then padding occurs
* immediately after either a '+' or '-' or after '0x' or '0X'.
* Otherwise, padding occurs at the beginning.
*
* @param __s Stream to write to.
* @param __io Source of locale and flags.
* @param __fill Char_type to use for filling.
* @param __v Value to format and insert.
* @return Iterator after writing.
*/
iter_type
put(iter_type __s, ios_base& __io, char_type __fill, long __v) const
{ return this->do_put(__s, __io, __fill, __v); }
iter_type
put(iter_type __s, ios_base& __io, char_type __fill,
unsigned long __v) const
{ return this->do_put(__s, __io, __fill, __v); }
#ifdef _GLIBCXX_USE_LONG_LONG
iter_type
put(iter_type __s, ios_base& __io, char_type __fill, long long __v) const
{ return this->do_put(__s, __io, __fill, __v); }
iter_type
put(iter_type __s, ios_base& __io, char_type __fill,
unsigned long long __v) const
{ return this->do_put(__s, __io, __fill, __v); }
#endif
//@}
//@{
/**
* @brief Numeric formatting.
*
* Formats the floating point value @a v and inserts it into a stream.
* It does so by calling num_put::do_put().
*
* Formatting is affected by the flag settings in @a io.
*
* The basic format is affected by the value of io.flags() &
* ios_base::floatfield. If equal to ios_base::fixed, formats like the
* printf %f specifier. Else if equal to ios_base::scientific, formats
* like %e or %E with ios_base::uppercase unset or set respectively.
* Otherwise, formats like %g or %G depending on uppercase. Note that
* if both fixed and scientific are set, the effect will also be like
* %g or %G.
*
* The output precision is given by io.precision(). This precision is
* capped at numeric_limits::digits10 + 2 (different for double and
* long double). The default precision is 6.
*
* If ios_base::showpos is set, '+' is output before positive values.
* If ios_base::showpoint is set, a decimal point will always be
* output.
*
* The decimal point character used is numpunct::decimal_point().
* Thousands separators are inserted according to
* numpunct::grouping() and numpunct::thousands_sep().
*
* If io.width() is non-zero, enough @a fill characters are inserted to
* make the result at least that wide. If
* (io.flags() & ios_base::adjustfield) == ios_base::left, result is
* padded at the end. If ios_base::internal, then padding occurs
* immediately after either a '+' or '-' or after '0x' or '0X'.
* Otherwise, padding occurs at the beginning.
*
* @param __s Stream to write to.
* @param __io Source of locale and flags.
* @param __fill Char_type to use for filling.
* @param __v Value to format and insert.
* @return Iterator after writing.
*/
iter_type
put(iter_type __s, ios_base& __io, char_type __fill, double __v) const
{ return this->do_put(__s, __io, __fill, __v); }
iter_type
put(iter_type __s, ios_base& __io, char_type __fill,
long double __v) const
{ return this->do_put(__s, __io, __fill, __v); }
//@}
/**
* @brief Numeric formatting.
*
* Formats the pointer value @a v and inserts it into a stream. It
* does so by calling num_put::do_put().
*
* This function formats @a v as an unsigned long with ios_base::hex
* and ios_base::showbase set.
*
* @param __s Stream to write to.
* @param __io Source of locale and flags.
* @param __fill Char_type to use for filling.
* @param __v Value to format and insert.
* @return Iterator after writing.
*/
iter_type
put(iter_type __s, ios_base& __io, char_type __fill,
const void* __v) const
{ return this->do_put(__s, __io, __fill, __v); }
protected:
template<typename _ValueT>
iter_type
_M_insert_float(iter_type, ios_base& __io, char_type __fill,
char __mod, _ValueT __v) const;
void
_M_group_float(const char* __grouping, size_t __grouping_size,
char_type __sep, const char_type* __p, char_type* __new,
char_type* __cs, int& __len) const;
template<typename _ValueT>
iter_type
_M_insert_int(iter_type, ios_base& __io, char_type __fill,
_ValueT __v) const;
void
_M_group_int(const char* __grouping, size_t __grouping_size,
char_type __sep, ios_base& __io, char_type* __new,
char_type* __cs, int& __len) const;
void
_M_pad(char_type __fill, streamsize __w, ios_base& __io,
char_type* __new, const char_type* __cs, int& __len) const;
/// Destructor.
virtual
~num_put() { }
//@{
/**
* @brief Numeric formatting.
*
* These functions do the work of formatting numeric values and
* inserting them into a stream. This function is a hook for derived
* classes to change the value returned.
*
* @param __s Stream to write to.
* @param __io Source of locale and flags.
* @param __fill Char_type to use for filling.
* @param __v Value to format and insert.
* @return Iterator after writing.
*/
virtual iter_type
do_put(iter_type __s, ios_base& __io, char_type __fill, bool __v) const;
virtual iter_type
do_put(iter_type __s, ios_base& __io, char_type __fill, long __v) const
{ return _M_insert_int(__s, __io, __fill, __v); }
virtual iter_type
do_put(iter_type __s, ios_base& __io, char_type __fill,
unsigned long __v) const
{ return _M_insert_int(__s, __io, __fill, __v); }
#ifdef _GLIBCXX_USE_LONG_LONG
virtual iter_type
do_put(iter_type __s, ios_base& __io, char_type __fill,
long long __v) const
{ return _M_insert_int(__s, __io, __fill, __v); }
virtual iter_type
do_put(iter_type __s, ios_base& __io, char_type __fill,
unsigned long long __v) const
{ return _M_insert_int(__s, __io, __fill, __v); }
#endif
virtual iter_type
do_put(iter_type, ios_base&, char_type, double) const;
// XXX GLIBCXX_ABI Deprecated
#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
virtual iter_type
__do_put(iter_type, ios_base&, char_type, double) const;
#else
virtual iter_type
do_put(iter_type, ios_base&, char_type, long double) const;
#endif
virtual iter_type
do_put(iter_type, ios_base&, char_type, const void*) const;
// XXX GLIBCXX_ABI Deprecated
#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
virtual iter_type
do_put(iter_type, ios_base&, char_type, long double) const;
#endif
//@}
};
template <typename _CharT, typename _OutIter>
locale::id num_put<_CharT, _OutIter>::id;
_GLIBCXX_END_NAMESPACE_LDBL
// Subclause convenience interfaces, inlines.
// NB: These are inline because, when used in a loop, some compilers
// can hoist the body out of the loop; then it's just as fast as the
// C is*() function.
/// Convenience interface to ctype.is(ctype_base::space, __c).
template<typename _CharT>
inline bool
isspace(_CharT __c, const locale& __loc)
{ return use_facet<ctype<_CharT> >(__loc).is(ctype_base::space, __c); }
/// Convenience interface to ctype.is(ctype_base::print, __c).
template<typename _CharT>
inline bool
isprint(_CharT __c, const locale& __loc)
{ return use_facet<ctype<_CharT> >(__loc).is(ctype_base::print, __c); }
/// Convenience interface to ctype.is(ctype_base::cntrl, __c).
template<typename _CharT>
inline bool
iscntrl(_CharT __c, const locale& __loc)
{ return use_facet<ctype<_CharT> >(__loc).is(ctype_base::cntrl, __c); }
/// Convenience interface to ctype.is(ctype_base::upper, __c).
template<typename _CharT>
inline bool
isupper(_CharT __c, const locale& __loc)
{ return use_facet<ctype<_CharT> >(__loc).is(ctype_base::upper, __c); }
/// Convenience interface to ctype.is(ctype_base::lower, __c).
template<typename _CharT>
inline bool
islower(_CharT __c, const locale& __loc)
{ return use_facet<ctype<_CharT> >(__loc).is(ctype_base::lower, __c); }
/// Convenience interface to ctype.is(ctype_base::alpha, __c).
template<typename _CharT>
inline bool
isalpha(_CharT __c, const locale& __loc)
{ return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alpha, __c); }
/// Convenience interface to ctype.is(ctype_base::digit, __c).
template<typename _CharT>
inline bool
isdigit(_CharT __c, const locale& __loc)
{ return use_facet<ctype<_CharT> >(__loc).is(ctype_base::digit, __c); }
/// Convenience interface to ctype.is(ctype_base::punct, __c).
template<typename _CharT>
inline bool
ispunct(_CharT __c, const locale& __loc)
{ return use_facet<ctype<_CharT> >(__loc).is(ctype_base::punct, __c); }
/// Convenience interface to ctype.is(ctype_base::xdigit, __c).
template<typename _CharT>
inline bool
isxdigit(_CharT __c, const locale& __loc)
{ return use_facet<ctype<_CharT> >(__loc).is(ctype_base::xdigit, __c); }
/// Convenience interface to ctype.is(ctype_base::alnum, __c).
template<typename _CharT>
inline bool
isalnum(_CharT __c, const locale& __loc)
{ return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alnum, __c); }
/// Convenience interface to ctype.is(ctype_base::graph, __c).
template<typename _CharT>
inline bool
isgraph(_CharT __c, const locale& __loc)
{ return use_facet<ctype<_CharT> >(__loc).is(ctype_base::graph, __c); }
#if __cplusplus >= 201103L
/// Convenience interface to ctype.is(ctype_base::blank, __c).
template<typename _CharT>
inline bool
isblank(_CharT __c, const locale& __loc)
{ return use_facet<ctype<_CharT> >(__loc).is(ctype_base::blank, __c); }
#endif
/// Convenience interface to ctype.toupper(__c).
template<typename _CharT>
inline _CharT
toupper(_CharT __c, const locale& __loc)
{ return use_facet<ctype<_CharT> >(__loc).toupper(__c); }
/// Convenience interface to ctype.tolower(__c).
template<typename _CharT>
inline _CharT
tolower(_CharT __c, const locale& __loc)
{ return use_facet<ctype<_CharT> >(__loc).tolower(__c); }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
# include <bits/locale_facets.tcc>
#endif
c++/8/bits/ios_base.h 0000644 00000074457 15201526705 0010205 0 ustar 00 // Iostreams base classes -*- C++ -*-
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/ios_base.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{ios}
*/
//
// ISO C++ 14882: 27.4 Iostreams base classes
//
#ifndef _IOS_BASE_H
#define _IOS_BASE_H 1
#pragma GCC system_header
#include <ext/atomicity.h>
#include <bits/localefwd.h>
#include <bits/locale_classes.h>
#if __cplusplus < 201103L
# include <stdexcept>
#else
# include <system_error>
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// The following definitions of bitmask types are enums, not ints,
// as permitted (but not required) in the standard, in order to provide
// better type safety in iostream calls. A side effect is that in C++98
// expressions involving them are not compile-time constants.
enum _Ios_Fmtflags
{
_S_boolalpha = 1L << 0,
_S_dec = 1L << 1,
_S_fixed = 1L << 2,
_S_hex = 1L << 3,
_S_internal = 1L << 4,
_S_left = 1L << 5,
_S_oct = 1L << 6,
_S_right = 1L << 7,
_S_scientific = 1L << 8,
_S_showbase = 1L << 9,
_S_showpoint = 1L << 10,
_S_showpos = 1L << 11,
_S_skipws = 1L << 12,
_S_unitbuf = 1L << 13,
_S_uppercase = 1L << 14,
_S_adjustfield = _S_left | _S_right | _S_internal,
_S_basefield = _S_dec | _S_oct | _S_hex,
_S_floatfield = _S_scientific | _S_fixed,
_S_ios_fmtflags_end = 1L << 16,
_S_ios_fmtflags_max = __INT_MAX__,
_S_ios_fmtflags_min = ~__INT_MAX__
};
inline _GLIBCXX_CONSTEXPR _Ios_Fmtflags
operator&(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
{ return _Ios_Fmtflags(static_cast<int>(__a) & static_cast<int>(__b)); }
inline _GLIBCXX_CONSTEXPR _Ios_Fmtflags
operator|(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
{ return _Ios_Fmtflags(static_cast<int>(__a) | static_cast<int>(__b)); }
inline _GLIBCXX_CONSTEXPR _Ios_Fmtflags
operator^(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
{ return _Ios_Fmtflags(static_cast<int>(__a) ^ static_cast<int>(__b)); }
inline _GLIBCXX_CONSTEXPR _Ios_Fmtflags
operator~(_Ios_Fmtflags __a)
{ return _Ios_Fmtflags(~static_cast<int>(__a)); }
inline const _Ios_Fmtflags&
operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
{ return __a = __a | __b; }
inline const _Ios_Fmtflags&
operator&=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
{ return __a = __a & __b; }
inline const _Ios_Fmtflags&
operator^=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
{ return __a = __a ^ __b; }
enum _Ios_Openmode
{
_S_app = 1L << 0,
_S_ate = 1L << 1,
_S_bin = 1L << 2,
_S_in = 1L << 3,
_S_out = 1L << 4,
_S_trunc = 1L << 5,
_S_ios_openmode_end = 1L << 16,
_S_ios_openmode_max = __INT_MAX__,
_S_ios_openmode_min = ~__INT_MAX__
};
inline _GLIBCXX_CONSTEXPR _Ios_Openmode
operator&(_Ios_Openmode __a, _Ios_Openmode __b)
{ return _Ios_Openmode(static_cast<int>(__a) & static_cast<int>(__b)); }
inline _GLIBCXX_CONSTEXPR _Ios_Openmode
operator|(_Ios_Openmode __a, _Ios_Openmode __b)
{ return _Ios_Openmode(static_cast<int>(__a) | static_cast<int>(__b)); }
inline _GLIBCXX_CONSTEXPR _Ios_Openmode
operator^(_Ios_Openmode __a, _Ios_Openmode __b)
{ return _Ios_Openmode(static_cast<int>(__a) ^ static_cast<int>(__b)); }
inline _GLIBCXX_CONSTEXPR _Ios_Openmode
operator~(_Ios_Openmode __a)
{ return _Ios_Openmode(~static_cast<int>(__a)); }
inline const _Ios_Openmode&
operator|=(_Ios_Openmode& __a, _Ios_Openmode __b)
{ return __a = __a | __b; }
inline const _Ios_Openmode&
operator&=(_Ios_Openmode& __a, _Ios_Openmode __b)
{ return __a = __a & __b; }
inline const _Ios_Openmode&
operator^=(_Ios_Openmode& __a, _Ios_Openmode __b)
{ return __a = __a ^ __b; }
enum _Ios_Iostate
{
_S_goodbit = 0,
_S_badbit = 1L << 0,
_S_eofbit = 1L << 1,
_S_failbit = 1L << 2,
_S_ios_iostate_end = 1L << 16,
_S_ios_iostate_max = __INT_MAX__,
_S_ios_iostate_min = ~__INT_MAX__
};
inline _GLIBCXX_CONSTEXPR _Ios_Iostate
operator&(_Ios_Iostate __a, _Ios_Iostate __b)
{ return _Ios_Iostate(static_cast<int>(__a) & static_cast<int>(__b)); }
inline _GLIBCXX_CONSTEXPR _Ios_Iostate
operator|(_Ios_Iostate __a, _Ios_Iostate __b)
{ return _Ios_Iostate(static_cast<int>(__a) | static_cast<int>(__b)); }
inline _GLIBCXX_CONSTEXPR _Ios_Iostate
operator^(_Ios_Iostate __a, _Ios_Iostate __b)
{ return _Ios_Iostate(static_cast<int>(__a) ^ static_cast<int>(__b)); }
inline _GLIBCXX_CONSTEXPR _Ios_Iostate
operator~(_Ios_Iostate __a)
{ return _Ios_Iostate(~static_cast<int>(__a)); }
inline const _Ios_Iostate&
operator|=(_Ios_Iostate& __a, _Ios_Iostate __b)
{ return __a = __a | __b; }
inline const _Ios_Iostate&
operator&=(_Ios_Iostate& __a, _Ios_Iostate __b)
{ return __a = __a & __b; }
inline const _Ios_Iostate&
operator^=(_Ios_Iostate& __a, _Ios_Iostate __b)
{ return __a = __a ^ __b; }
enum _Ios_Seekdir
{
_S_beg = 0,
_S_cur = _GLIBCXX_STDIO_SEEK_CUR,
_S_end = _GLIBCXX_STDIO_SEEK_END,
_S_ios_seekdir_end = 1L << 16
};
#if __cplusplus >= 201103L
/// I/O error code
enum class io_errc { stream = 1 };
template <> struct is_error_code_enum<io_errc> : public true_type { };
const error_category& iostream_category() noexcept;
inline error_code
make_error_code(io_errc __e) noexcept
{ return error_code(static_cast<int>(__e), iostream_category()); }
inline error_condition
make_error_condition(io_errc __e) noexcept
{ return error_condition(static_cast<int>(__e), iostream_category()); }
#endif
// 27.4.2 Class ios_base
/**
* @brief The base of the I/O class hierarchy.
* @ingroup io
*
* This class defines everything that can be defined about I/O that does
* not depend on the type of characters being input or output. Most
* people will only see @c ios_base when they need to specify the full
* name of the various I/O flags (e.g., the openmodes).
*/
class ios_base
{
#if _GLIBCXX_USE_CXX11_ABI
#if __cplusplus < 201103L
// Type that is layout-compatible with std::system_error
struct system_error : std::runtime_error
{
// Type that is layout-compatible with std::error_code
struct error_code
{
error_code() { }
private:
int _M_value;
const void* _M_cat;
} _M_code;
};
#endif
#endif
public:
/**
* @brief These are thrown to indicate problems with io.
* @ingroup exceptions
*
* 27.4.2.1.1 Class ios_base::failure
*/
#if _GLIBCXX_USE_CXX11_ABI
class _GLIBCXX_ABI_TAG_CXX11 failure : public system_error
{
public:
explicit
failure(const string& __str);
#if __cplusplus >= 201103L
explicit
failure(const string&, const error_code&);
explicit
failure(const char*, const error_code& = io_errc::stream);
#endif
virtual
~failure() throw();
virtual const char*
what() const throw();
};
#else
class failure : public exception
{
public:
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 48. Use of non-existent exception constructor
explicit
failure(const string& __str) throw();
// This declaration is not useless:
// http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gcc/Vague-Linkage.html
virtual
~failure() throw();
virtual const char*
what() const throw();
private:
string _M_msg;
};
#endif
// 27.4.2.1.2 Type ios_base::fmtflags
/**
* @brief This is a bitmask type.
*
* @c @a _Ios_Fmtflags is implementation-defined, but it is valid to
* perform bitwise operations on these values and expect the Right
* Thing to happen. Defined objects of type fmtflags are:
* - boolalpha
* - dec
* - fixed
* - hex
* - internal
* - left
* - oct
* - right
* - scientific
* - showbase
* - showpoint
* - showpos
* - skipws
* - unitbuf
* - uppercase
* - adjustfield
* - basefield
* - floatfield
*/
typedef _Ios_Fmtflags fmtflags;
/// Insert/extract @c bool in alphabetic rather than numeric format.
static const fmtflags boolalpha = _S_boolalpha;
/// Converts integer input or generates integer output in decimal base.
static const fmtflags dec = _S_dec;
/// Generate floating-point output in fixed-point notation.
static const fmtflags fixed = _S_fixed;
/// Converts integer input or generates integer output in hexadecimal base.
static const fmtflags hex = _S_hex;
/// Adds fill characters at a designated internal point in certain
/// generated output, or identical to @c right if no such point is
/// designated.
static const fmtflags internal = _S_internal;
/// Adds fill characters on the right (final positions) of certain
/// generated output. (I.e., the thing you print is flush left.)
static const fmtflags left = _S_left;
/// Converts integer input or generates integer output in octal base.
static const fmtflags oct = _S_oct;
/// Adds fill characters on the left (initial positions) of certain
/// generated output. (I.e., the thing you print is flush right.)
static const fmtflags right = _S_right;
/// Generates floating-point output in scientific notation.
static const fmtflags scientific = _S_scientific;
/// Generates a prefix indicating the numeric base of generated integer
/// output.
static const fmtflags showbase = _S_showbase;
/// Generates a decimal-point character unconditionally in generated
/// floating-point output.
static const fmtflags showpoint = _S_showpoint;
/// Generates a + sign in non-negative generated numeric output.
static const fmtflags showpos = _S_showpos;
/// Skips leading white space before certain input operations.
static const fmtflags skipws = _S_skipws;
/// Flushes output after each output operation.
static const fmtflags unitbuf = _S_unitbuf;
/// Replaces certain lowercase letters with their uppercase equivalents
/// in generated output.
static const fmtflags uppercase = _S_uppercase;
/// A mask of left|right|internal. Useful for the 2-arg form of @c setf.
static const fmtflags adjustfield = _S_adjustfield;
/// A mask of dec|oct|hex. Useful for the 2-arg form of @c setf.
static const fmtflags basefield = _S_basefield;
/// A mask of scientific|fixed. Useful for the 2-arg form of @c setf.
static const fmtflags floatfield = _S_floatfield;
// 27.4.2.1.3 Type ios_base::iostate
/**
* @brief This is a bitmask type.
*
* @c @a _Ios_Iostate is implementation-defined, but it is valid to
* perform bitwise operations on these values and expect the Right
* Thing to happen. Defined objects of type iostate are:
* - badbit
* - eofbit
* - failbit
* - goodbit
*/
typedef _Ios_Iostate iostate;
/// Indicates a loss of integrity in an input or output sequence (such
/// as an irrecoverable read error from a file).
static const iostate badbit = _S_badbit;
/// Indicates that an input operation reached the end of an input sequence.
static const iostate eofbit = _S_eofbit;
/// Indicates that an input operation failed to read the expected
/// characters, or that an output operation failed to generate the
/// desired characters.
static const iostate failbit = _S_failbit;
/// Indicates all is well.
static const iostate goodbit = _S_goodbit;
// 27.4.2.1.4 Type ios_base::openmode
/**
* @brief This is a bitmask type.
*
* @c @a _Ios_Openmode is implementation-defined, but it is valid to
* perform bitwise operations on these values and expect the Right
* Thing to happen. Defined objects of type openmode are:
* - app
* - ate
* - binary
* - in
* - out
* - trunc
*/
typedef _Ios_Openmode openmode;
/// Seek to end before each write.
static const openmode app = _S_app;
/// Open and seek to end immediately after opening.
static const openmode ate = _S_ate;
/// Perform input and output in binary mode (as opposed to text mode).
/// This is probably not what you think it is; see
/// https://gcc.gnu.org/onlinedocs/libstdc++/manual/fstreams.html#std.io.filestreams.binary
static const openmode binary = _S_bin;
/// Open for input. Default for @c ifstream and fstream.
static const openmode in = _S_in;
/// Open for output. Default for @c ofstream and fstream.
static const openmode out = _S_out;
/// Truncate an existing stream when opening. Default for @c ofstream.
static const openmode trunc = _S_trunc;
// 27.4.2.1.5 Type ios_base::seekdir
/**
* @brief This is an enumerated type.
*
* @c @a _Ios_Seekdir is implementation-defined. Defined values
* of type seekdir are:
* - beg
* - cur, equivalent to @c SEEK_CUR in the C standard library.
* - end, equivalent to @c SEEK_END in the C standard library.
*/
typedef _Ios_Seekdir seekdir;
/// Request a seek relative to the beginning of the stream.
static const seekdir beg = _S_beg;
/// Request a seek relative to the current position within the sequence.
static const seekdir cur = _S_cur;
/// Request a seek relative to the current end of the sequence.
static const seekdir end = _S_end;
#if __cplusplus <= 201402L
// Annex D.6 (removed in C++17)
typedef int io_state;
typedef int open_mode;
typedef int seek_dir;
typedef std::streampos streampos;
typedef std::streamoff streamoff;
#endif
// Callbacks;
/**
* @brief The set of events that may be passed to an event callback.
*
* erase_event is used during ~ios() and copyfmt(). imbue_event is used
* during imbue(). copyfmt_event is used during copyfmt().
*/
enum event
{
erase_event,
imbue_event,
copyfmt_event
};
/**
* @brief The type of an event callback function.
* @param __e One of the members of the event enum.
* @param __b Reference to the ios_base object.
* @param __i The integer provided when the callback was registered.
*
* Event callbacks are user defined functions that get called during
* several ios_base and basic_ios functions, specifically imbue(),
* copyfmt(), and ~ios().
*/
typedef void (*event_callback) (event __e, ios_base& __b, int __i);
/**
* @brief Add the callback __fn with parameter __index.
* @param __fn The function to add.
* @param __index The integer to pass to the function when invoked.
*
* Registers a function as an event callback with an integer parameter to
* be passed to the function when invoked. Multiple copies of the
* function are allowed. If there are multiple callbacks, they are
* invoked in the order they were registered.
*/
void
register_callback(event_callback __fn, int __index);
protected:
streamsize _M_precision;
streamsize _M_width;
fmtflags _M_flags;
iostate _M_exception;
iostate _M_streambuf_state;
// 27.4.2.6 Members for callbacks
// 27.4.2.6 ios_base callbacks
struct _Callback_list
{
// Data Members
_Callback_list* _M_next;
ios_base::event_callback _M_fn;
int _M_index;
_Atomic_word _M_refcount; // 0 means one reference.
_Callback_list(ios_base::event_callback __fn, int __index,
_Callback_list* __cb)
: _M_next(__cb), _M_fn(__fn), _M_index(__index), _M_refcount(0) { }
void
_M_add_reference() { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); }
// 0 => OK to delete.
int
_M_remove_reference()
{
// Be race-detector-friendly. For more info see bits/c++config.
_GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_refcount);
int __res = __gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1);
if (__res == 0)
{
_GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_refcount);
}
return __res;
}
};
_Callback_list* _M_callbacks;
void
_M_call_callbacks(event __ev) throw();
void
_M_dispose_callbacks(void) throw();
// 27.4.2.5 Members for iword/pword storage
struct _Words
{
void* _M_pword;
long _M_iword;
_Words() : _M_pword(0), _M_iword(0) { }
};
// Only for failed iword/pword calls.
_Words _M_word_zero;
// Guaranteed storage.
// The first 5 iword and pword slots are reserved for internal use.
enum { _S_local_word_size = 8 };
_Words _M_local_word[_S_local_word_size];
// Allocated storage.
int _M_word_size;
_Words* _M_word;
_Words&
_M_grow_words(int __index, bool __iword);
// Members for locale and locale caching.
locale _M_ios_locale;
void
_M_init() throw();
public:
// 27.4.2.1.6 Class ios_base::Init
// Used to initialize standard streams. In theory, g++ could use
// -finit-priority to order this stuff correctly without going
// through these machinations.
class Init
{
friend class ios_base;
public:
Init();
~Init();
private:
static _Atomic_word _S_refcount;
static bool _S_synced_with_stdio;
};
// [27.4.2.2] fmtflags state functions
/**
* @brief Access to format flags.
* @return The format control flags for both input and output.
*/
fmtflags
flags() const
{ return _M_flags; }
/**
* @brief Setting new format flags all at once.
* @param __fmtfl The new flags to set.
* @return The previous format control flags.
*
* This function overwrites all the format flags with @a __fmtfl.
*/
fmtflags
flags(fmtflags __fmtfl)
{
fmtflags __old = _M_flags;
_M_flags = __fmtfl;
return __old;
}
/**
* @brief Setting new format flags.
* @param __fmtfl Additional flags to set.
* @return The previous format control flags.
*
* This function sets additional flags in format control. Flags that
* were previously set remain set.
*/
fmtflags
setf(fmtflags __fmtfl)
{
fmtflags __old = _M_flags;
_M_flags |= __fmtfl;
return __old;
}
/**
* @brief Setting new format flags.
* @param __fmtfl Additional flags to set.
* @param __mask The flags mask for @a fmtfl.
* @return The previous format control flags.
*
* This function clears @a mask in the format flags, then sets
* @a fmtfl @c & @a mask. An example mask is @c ios_base::adjustfield.
*/
fmtflags
setf(fmtflags __fmtfl, fmtflags __mask)
{
fmtflags __old = _M_flags;
_M_flags &= ~__mask;
_M_flags |= (__fmtfl & __mask);
return __old;
}
/**
* @brief Clearing format flags.
* @param __mask The flags to unset.
*
* This function clears @a __mask in the format flags.
*/
void
unsetf(fmtflags __mask)
{ _M_flags &= ~__mask; }
/**
* @brief Flags access.
* @return The precision to generate on certain output operations.
*
* Be careful if you try to give a definition of @a precision here; see
* DR 189.
*/
streamsize
precision() const
{ return _M_precision; }
/**
* @brief Changing flags.
* @param __prec The new precision value.
* @return The previous value of precision().
*/
streamsize
precision(streamsize __prec)
{
streamsize __old = _M_precision;
_M_precision = __prec;
return __old;
}
/**
* @brief Flags access.
* @return The minimum field width to generate on output operations.
*
* <em>Minimum field width</em> refers to the number of characters.
*/
streamsize
width() const
{ return _M_width; }
/**
* @brief Changing flags.
* @param __wide The new width value.
* @return The previous value of width().
*/
streamsize
width(streamsize __wide)
{
streamsize __old = _M_width;
_M_width = __wide;
return __old;
}
// [27.4.2.4] ios_base static members
/**
* @brief Interaction with the standard C I/O objects.
* @param __sync Whether to synchronize or not.
* @return True if the standard streams were previously synchronized.
*
* The synchronization referred to is @e only that between the standard
* C facilities (e.g., stdout) and the standard C++ objects (e.g.,
* cout). User-declared streams are unaffected. See
* https://gcc.gnu.org/onlinedocs/libstdc++/manual/fstreams.html#std.io.filestreams.binary
*/
static bool
sync_with_stdio(bool __sync = true);
// [27.4.2.3] ios_base locale functions
/**
* @brief Setting a new locale.
* @param __loc The new locale.
* @return The previous locale.
*
* Sets the new locale for this stream, and then invokes each callback
* with imbue_event.
*/
locale
imbue(const locale& __loc) throw();
/**
* @brief Locale access
* @return A copy of the current locale.
*
* If @c imbue(loc) has previously been called, then this function
* returns @c loc. Otherwise, it returns a copy of @c std::locale(),
* the global C++ locale.
*/
locale
getloc() const
{ return _M_ios_locale; }
/**
* @brief Locale access
* @return A reference to the current locale.
*
* Like getloc above, but returns a reference instead of
* generating a copy.
*/
const locale&
_M_getloc() const
{ return _M_ios_locale; }
// [27.4.2.5] ios_base storage functions
/**
* @brief Access to unique indices.
* @return An integer different from all previous calls.
*
* This function returns a unique integer every time it is called. It
* can be used for any purpose, but is primarily intended to be a unique
* index for the iword and pword functions. The expectation is that an
* application calls xalloc in order to obtain an index in the iword and
* pword arrays that can be used without fear of conflict.
*
* The implementation maintains a static variable that is incremented and
* returned on each invocation. xalloc is guaranteed to return an index
* that is safe to use in the iword and pword arrays.
*/
static int
xalloc() throw();
/**
* @brief Access to integer array.
* @param __ix Index into the array.
* @return A reference to an integer associated with the index.
*
* The iword function provides access to an array of integers that can be
* used for any purpose. The array grows as required to hold the
* supplied index. All integers in the array are initialized to 0.
*
* The implementation reserves several indices. You should use xalloc to
* obtain an index that is safe to use. Also note that since the array
* can grow dynamically, it is not safe to hold onto the reference.
*/
long&
iword(int __ix)
{
_Words& __word = (__ix < _M_word_size)
? _M_word[__ix] : _M_grow_words(__ix, true);
return __word._M_iword;
}
/**
* @brief Access to void pointer array.
* @param __ix Index into the array.
* @return A reference to a void* associated with the index.
*
* The pword function provides access to an array of pointers that can be
* used for any purpose. The array grows as required to hold the
* supplied index. All pointers in the array are initialized to 0.
*
* The implementation reserves several indices. You should use xalloc to
* obtain an index that is safe to use. Also note that since the array
* can grow dynamically, it is not safe to hold onto the reference.
*/
void*&
pword(int __ix)
{
_Words& __word = (__ix < _M_word_size)
? _M_word[__ix] : _M_grow_words(__ix, false);
return __word._M_pword;
}
// Destructor
/**
* Invokes each callback with erase_event. Destroys local storage.
*
* Note that the ios_base object for the standard streams never gets
* destroyed. As a result, any callbacks registered with the standard
* streams will not get invoked with erase_event (unless copyfmt is
* used).
*/
virtual ~ios_base();
protected:
ios_base() throw ();
#if __cplusplus < 201103L
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 50. Copy constructor and assignment operator of ios_base
private:
ios_base(const ios_base&);
ios_base&
operator=(const ios_base&);
#else
public:
ios_base(const ios_base&) = delete;
ios_base&
operator=(const ios_base&) = delete;
protected:
void
_M_move(ios_base&) noexcept;
void
_M_swap(ios_base& __rhs) noexcept;
#endif
};
// [27.4.5.1] fmtflags manipulators
/// Calls base.setf(ios_base::boolalpha).
inline ios_base&
boolalpha(ios_base& __base)
{
__base.setf(ios_base::boolalpha);
return __base;
}
/// Calls base.unsetf(ios_base::boolalpha).
inline ios_base&
noboolalpha(ios_base& __base)
{
__base.unsetf(ios_base::boolalpha);
return __base;
}
/// Calls base.setf(ios_base::showbase).
inline ios_base&
showbase(ios_base& __base)
{
__base.setf(ios_base::showbase);
return __base;
}
/// Calls base.unsetf(ios_base::showbase).
inline ios_base&
noshowbase(ios_base& __base)
{
__base.unsetf(ios_base::showbase);
return __base;
}
/// Calls base.setf(ios_base::showpoint).
inline ios_base&
showpoint(ios_base& __base)
{
__base.setf(ios_base::showpoint);
return __base;
}
/// Calls base.unsetf(ios_base::showpoint).
inline ios_base&
noshowpoint(ios_base& __base)
{
__base.unsetf(ios_base::showpoint);
return __base;
}
/// Calls base.setf(ios_base::showpos).
inline ios_base&
showpos(ios_base& __base)
{
__base.setf(ios_base::showpos);
return __base;
}
/// Calls base.unsetf(ios_base::showpos).
inline ios_base&
noshowpos(ios_base& __base)
{
__base.unsetf(ios_base::showpos);
return __base;
}
/// Calls base.setf(ios_base::skipws).
inline ios_base&
skipws(ios_base& __base)
{
__base.setf(ios_base::skipws);
return __base;
}
/// Calls base.unsetf(ios_base::skipws).
inline ios_base&
noskipws(ios_base& __base)
{
__base.unsetf(ios_base::skipws);
return __base;
}
/// Calls base.setf(ios_base::uppercase).
inline ios_base&
uppercase(ios_base& __base)
{
__base.setf(ios_base::uppercase);
return __base;
}
/// Calls base.unsetf(ios_base::uppercase).
inline ios_base&
nouppercase(ios_base& __base)
{
__base.unsetf(ios_base::uppercase);
return __base;
}
/// Calls base.setf(ios_base::unitbuf).
inline ios_base&
unitbuf(ios_base& __base)
{
__base.setf(ios_base::unitbuf);
return __base;
}
/// Calls base.unsetf(ios_base::unitbuf).
inline ios_base&
nounitbuf(ios_base& __base)
{
__base.unsetf(ios_base::unitbuf);
return __base;
}
// [27.4.5.2] adjustfield manipulators
/// Calls base.setf(ios_base::internal, ios_base::adjustfield).
inline ios_base&
internal(ios_base& __base)
{
__base.setf(ios_base::internal, ios_base::adjustfield);
return __base;
}
/// Calls base.setf(ios_base::left, ios_base::adjustfield).
inline ios_base&
left(ios_base& __base)
{
__base.setf(ios_base::left, ios_base::adjustfield);
return __base;
}
/// Calls base.setf(ios_base::right, ios_base::adjustfield).
inline ios_base&
right(ios_base& __base)
{
__base.setf(ios_base::right, ios_base::adjustfield);
return __base;
}
// [27.4.5.3] basefield manipulators
/// Calls base.setf(ios_base::dec, ios_base::basefield).
inline ios_base&
dec(ios_base& __base)
{
__base.setf(ios_base::dec, ios_base::basefield);
return __base;
}
/// Calls base.setf(ios_base::hex, ios_base::basefield).
inline ios_base&
hex(ios_base& __base)
{
__base.setf(ios_base::hex, ios_base::basefield);
return __base;
}
/// Calls base.setf(ios_base::oct, ios_base::basefield).
inline ios_base&
oct(ios_base& __base)
{
__base.setf(ios_base::oct, ios_base::basefield);
return __base;
}
// [27.4.5.4] floatfield manipulators
/// Calls base.setf(ios_base::fixed, ios_base::floatfield).
inline ios_base&
fixed(ios_base& __base)
{
__base.setf(ios_base::fixed, ios_base::floatfield);
return __base;
}
/// Calls base.setf(ios_base::scientific, ios_base::floatfield).
inline ios_base&
scientific(ios_base& __base)
{
__base.setf(ios_base::scientific, ios_base::floatfield);
return __base;
}
#if __cplusplus >= 201103L
// New C++11 floatfield manipulators
/// Calls
/// base.setf(ios_base::fixed|ios_base::scientific, ios_base::floatfield)
inline ios_base&
hexfloat(ios_base& __base)
{
__base.setf(ios_base::fixed | ios_base::scientific, ios_base::floatfield);
return __base;
}
/// Calls @c base.unsetf(ios_base::floatfield)
inline ios_base&
defaultfloat(ios_base& __base)
{
__base.unsetf(ios_base::floatfield);
return __base;
}
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif /* _IOS_BASE_H */
c++/8/bits/nested_exception.h 0000644 00000011302 15201526705 0011735 0 ustar 00 // Nested Exception support header (nested_exception class) for -*- C++ -*-
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/nested_exception.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{exception}
*/
#ifndef _GLIBCXX_NESTED_EXCEPTION_H
#define _GLIBCXX_NESTED_EXCEPTION_H 1
#pragma GCC visibility push(default)
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
#include <bits/c++config.h>
#include <bits/move.h>
extern "C++" {
namespace std
{
/**
* @addtogroup exceptions
* @{
*/
/// Exception class with exception_ptr data member.
class nested_exception
{
exception_ptr _M_ptr;
public:
nested_exception() noexcept : _M_ptr(current_exception()) { }
nested_exception(const nested_exception&) noexcept = default;
nested_exception& operator=(const nested_exception&) noexcept = default;
virtual ~nested_exception() noexcept;
[[noreturn]]
void
rethrow_nested() const
{
if (_M_ptr)
rethrow_exception(_M_ptr);
std::terminate();
}
exception_ptr
nested_ptr() const noexcept
{ return _M_ptr; }
};
template<typename _Except>
struct _Nested_exception : public _Except, public nested_exception
{
explicit _Nested_exception(const _Except& __ex)
: _Except(__ex)
{ }
explicit _Nested_exception(_Except&& __ex)
: _Except(static_cast<_Except&&>(__ex))
{ }
};
// [except.nested]/8
// Throw an exception of unspecified type that is publicly derived from
// both remove_reference_t<_Tp> and nested_exception.
template<typename _Tp>
[[noreturn]]
inline void
__throw_with_nested_impl(_Tp&& __t, true_type)
{
using _Up = typename remove_reference<_Tp>::type;
throw _Nested_exception<_Up>{std::forward<_Tp>(__t)};
}
template<typename _Tp>
[[noreturn]]
inline void
__throw_with_nested_impl(_Tp&& __t, false_type)
{ throw std::forward<_Tp>(__t); }
/// If @p __t is derived from nested_exception, throws @p __t.
/// Else, throws an implementation-defined object derived from both.
template<typename _Tp>
[[noreturn]]
inline void
throw_with_nested(_Tp&& __t)
{
using _Up = typename decay<_Tp>::type;
using _CopyConstructible
= __and_<is_copy_constructible<_Up>, is_move_constructible<_Up>>;
static_assert(_CopyConstructible::value,
"throw_with_nested argument must be CopyConstructible");
using __nest = __and_<is_class<_Up>, __bool_constant<!__is_final(_Up)>,
__not_<is_base_of<nested_exception, _Up>>>;
std::__throw_with_nested_impl(std::forward<_Tp>(__t), __nest{});
}
// Determine if dynamic_cast<const nested_exception&> would be well-formed.
template<typename _Tp>
using __rethrow_if_nested_cond = typename enable_if<
__and_<is_polymorphic<_Tp>,
__or_<__not_<is_base_of<nested_exception, _Tp>>,
is_convertible<_Tp*, nested_exception*>>>::value
>::type;
// Attempt dynamic_cast to nested_exception and call rethrow_nested().
template<typename _Ex>
inline __rethrow_if_nested_cond<_Ex>
__rethrow_if_nested_impl(const _Ex* __ptr)
{
if (auto __ne_ptr = dynamic_cast<const nested_exception*>(__ptr))
__ne_ptr->rethrow_nested();
}
// Otherwise, no effects.
inline void
__rethrow_if_nested_impl(const void*)
{ }
/// If @p __ex is derived from nested_exception, @p __ex.rethrow_nested().
template<typename _Ex>
inline void
rethrow_if_nested(const _Ex& __ex)
{ std::__rethrow_if_nested_impl(std::__addressof(__ex)); }
// @} group exceptions
} // namespace std
} // extern "C++"
#endif // C++11
#pragma GCC visibility pop
#endif // _GLIBCXX_NESTED_EXCEPTION_H
c++/8/bits/exception_ptr.h 0000644 00000013535 15201526705 0011272 0 ustar 00 // Exception Handling support header (exception_ptr class) for -*- C++ -*-
// Copyright (C) 2008-2018 Free Software Foundation, Inc.
//
// This file is part of GCC.
//
// GCC is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// GCC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/exception_ptr.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{exception}
*/
#ifndef _EXCEPTION_PTR_H
#define _EXCEPTION_PTR_H
#pragma GCC visibility push(default)
#include <bits/c++config.h>
#include <bits/exception_defines.h>
#include <bits/cxxabi_init_exception.h>
#include <typeinfo>
#include <new>
extern "C++" {
namespace std
{
class type_info;
/**
* @addtogroup exceptions
* @{
*/
namespace __exception_ptr
{
class exception_ptr;
}
using __exception_ptr::exception_ptr;
/** Obtain an exception_ptr to the currently handled exception. If there
* is none, or the currently handled exception is foreign, return the null
* value.
*/
exception_ptr current_exception() _GLIBCXX_USE_NOEXCEPT;
template<typename _Ex>
exception_ptr make_exception_ptr(_Ex) _GLIBCXX_USE_NOEXCEPT;
/// Throw the object pointed to by the exception_ptr.
void rethrow_exception(exception_ptr) __attribute__ ((__noreturn__));
namespace __exception_ptr
{
using std::rethrow_exception;
/**
* @brief An opaque pointer to an arbitrary exception.
* @ingroup exceptions
*/
class exception_ptr
{
void* _M_exception_object;
explicit exception_ptr(void* __e) _GLIBCXX_USE_NOEXCEPT;
void _M_addref() _GLIBCXX_USE_NOEXCEPT;
void _M_release() _GLIBCXX_USE_NOEXCEPT;
void *_M_get() const _GLIBCXX_NOEXCEPT __attribute__ ((__pure__));
friend exception_ptr std::current_exception() _GLIBCXX_USE_NOEXCEPT;
friend void std::rethrow_exception(exception_ptr);
template<typename _Ex>
friend exception_ptr std::make_exception_ptr(_Ex) _GLIBCXX_USE_NOEXCEPT;
public:
exception_ptr() _GLIBCXX_USE_NOEXCEPT;
exception_ptr(const exception_ptr&) _GLIBCXX_USE_NOEXCEPT;
#if __cplusplus >= 201103L
exception_ptr(nullptr_t) noexcept
: _M_exception_object(0)
{ }
exception_ptr(exception_ptr&& __o) noexcept
: _M_exception_object(__o._M_exception_object)
{ __o._M_exception_object = 0; }
#endif
#if (__cplusplus < 201103L) || defined (_GLIBCXX_EH_PTR_COMPAT)
typedef void (exception_ptr::*__safe_bool)();
// For construction from nullptr or 0.
exception_ptr(__safe_bool) _GLIBCXX_USE_NOEXCEPT;
#endif
exception_ptr&
operator=(const exception_ptr&) _GLIBCXX_USE_NOEXCEPT;
#if __cplusplus >= 201103L
exception_ptr&
operator=(exception_ptr&& __o) noexcept
{
exception_ptr(static_cast<exception_ptr&&>(__o)).swap(*this);
return *this;
}
#endif
~exception_ptr() _GLIBCXX_USE_NOEXCEPT;
void
swap(exception_ptr&) _GLIBCXX_USE_NOEXCEPT;
#ifdef _GLIBCXX_EH_PTR_COMPAT
// Retained for compatibility with CXXABI_1.3.
void _M_safe_bool_dummy() _GLIBCXX_USE_NOEXCEPT
__attribute__ ((__const__));
bool operator!() const _GLIBCXX_USE_NOEXCEPT
__attribute__ ((__pure__));
operator __safe_bool() const _GLIBCXX_USE_NOEXCEPT;
#endif
#if __cplusplus >= 201103L
explicit operator bool() const
{ return _M_exception_object; }
#endif
friend bool
operator==(const exception_ptr&, const exception_ptr&)
_GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__));
const class std::type_info*
__cxa_exception_type() const _GLIBCXX_USE_NOEXCEPT
__attribute__ ((__pure__));
};
bool
operator==(const exception_ptr&, const exception_ptr&)
_GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__));
bool
operator!=(const exception_ptr&, const exception_ptr&)
_GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__));
inline void
swap(exception_ptr& __lhs, exception_ptr& __rhs)
{ __lhs.swap(__rhs); }
template<typename _Ex>
inline void
__dest_thunk(void* __x)
{ static_cast<_Ex*>(__x)->~_Ex(); }
} // namespace __exception_ptr
/// Obtain an exception_ptr pointing to a copy of the supplied object.
template<typename _Ex>
exception_ptr
make_exception_ptr(_Ex __ex) _GLIBCXX_USE_NOEXCEPT
{
#if __cpp_exceptions && __cpp_rtti && !_GLIBCXX_HAVE_CDTOR_CALLABI
void* __e = __cxxabiv1::__cxa_allocate_exception(sizeof(_Ex));
(void) __cxxabiv1::__cxa_init_primary_exception(
__e, const_cast<std::type_info*>(&typeid(__ex)),
__exception_ptr::__dest_thunk<_Ex>);
try
{
::new (__e) _Ex(__ex);
return exception_ptr(__e);
}
catch(...)
{
__cxxabiv1::__cxa_free_exception(__e);
return current_exception();
}
#elif __cpp_exceptions
try
{
throw __ex;
}
catch(...)
{
return current_exception();
}
#else // no RTTI and no exceptions
return exception_ptr();
#endif
}
// @} group exceptions
} // namespace std
} // extern "C++"
#pragma GCC visibility pop
#endif
c++/8/bits/locale_facets.tcc 0000644 00000115174 15201526705 0011517 0 ustar 00 // Locale support -*- C++ -*-
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/locale_facets.tcc
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{locale}
*/
#ifndef _LOCALE_FACETS_TCC
#define _LOCALE_FACETS_TCC 1
#pragma GCC system_header
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Routine to access a cache for the facet. If the cache didn't
// exist before, it gets constructed on the fly.
template<typename _Facet>
struct __use_cache
{
const _Facet*
operator() (const locale& __loc) const;
};
// Specializations.
template<typename _CharT>
struct __use_cache<__numpunct_cache<_CharT> >
{
const __numpunct_cache<_CharT>*
operator() (const locale& __loc) const
{
const size_t __i = numpunct<_CharT>::id._M_id();
const locale::facet** __caches = __loc._M_impl->_M_caches;
if (!__caches[__i])
{
__numpunct_cache<_CharT>* __tmp = 0;
__try
{
__tmp = new __numpunct_cache<_CharT>;
__tmp->_M_cache(__loc);
}
__catch(...)
{
delete __tmp;
__throw_exception_again;
}
__loc._M_impl->_M_install_cache(__tmp, __i);
}
return static_cast<const __numpunct_cache<_CharT>*>(__caches[__i]);
}
};
template<typename _CharT>
void
__numpunct_cache<_CharT>::_M_cache(const locale& __loc)
{
const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
char* __grouping = 0;
_CharT* __truename = 0;
_CharT* __falsename = 0;
__try
{
const string& __g = __np.grouping();
_M_grouping_size = __g.size();
__grouping = new char[_M_grouping_size];
__g.copy(__grouping, _M_grouping_size);
_M_use_grouping = (_M_grouping_size
&& static_cast<signed char>(__grouping[0]) > 0
&& (__grouping[0]
!= __gnu_cxx::__numeric_traits<char>::__max));
const basic_string<_CharT>& __tn = __np.truename();
_M_truename_size = __tn.size();
__truename = new _CharT[_M_truename_size];
__tn.copy(__truename, _M_truename_size);
const basic_string<_CharT>& __fn = __np.falsename();
_M_falsename_size = __fn.size();
__falsename = new _CharT[_M_falsename_size];
__fn.copy(__falsename, _M_falsename_size);
_M_decimal_point = __np.decimal_point();
_M_thousands_sep = __np.thousands_sep();
const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__loc);
__ct.widen(__num_base::_S_atoms_out,
__num_base::_S_atoms_out
+ __num_base::_S_oend, _M_atoms_out);
__ct.widen(__num_base::_S_atoms_in,
__num_base::_S_atoms_in
+ __num_base::_S_iend, _M_atoms_in);
_M_grouping = __grouping;
_M_truename = __truename;
_M_falsename = __falsename;
_M_allocated = true;
}
__catch(...)
{
delete [] __grouping;
delete [] __truename;
delete [] __falsename;
__throw_exception_again;
}
}
// Used by both numeric and monetary facets.
// Check to make sure that the __grouping_tmp string constructed in
// money_get or num_get matches the canonical grouping for a given
// locale.
// __grouping_tmp is parsed L to R
// 1,222,444 == __grouping_tmp of "\1\3\3"
// __grouping is parsed R to L
// 1,222,444 == __grouping of "\3" == "\3\3\3"
_GLIBCXX_PURE bool
__verify_grouping(const char* __grouping, size_t __grouping_size,
const string& __grouping_tmp) throw ();
_GLIBCXX_BEGIN_NAMESPACE_LDBL
template<typename _CharT, typename _InIter>
_GLIBCXX_DEFAULT_ABI_TAG
_InIter
num_get<_CharT, _InIter>::
_M_extract_float(_InIter __beg, _InIter __end, ios_base& __io,
ios_base::iostate& __err, string& __xtrc) const
{
typedef char_traits<_CharT> __traits_type;
typedef __numpunct_cache<_CharT> __cache_type;
__use_cache<__cache_type> __uc;
const locale& __loc = __io._M_getloc();
const __cache_type* __lc = __uc(__loc);
const _CharT* __lit = __lc->_M_atoms_in;
char_type __c = char_type();
// True if __beg becomes equal to __end.
bool __testeof = __beg == __end;
// First check for sign.
if (!__testeof)
{
__c = *__beg;
const bool __plus = __c == __lit[__num_base::_S_iplus];
if ((__plus || __c == __lit[__num_base::_S_iminus])
&& !(__lc->_M_use_grouping && __c == __lc->_M_thousands_sep)
&& !(__c == __lc->_M_decimal_point))
{
__xtrc += __plus ? '+' : '-';
if (++__beg != __end)
__c = *__beg;
else
__testeof = true;
}
}
// Next, look for leading zeros.
bool __found_mantissa = false;
int __sep_pos = 0;
while (!__testeof)
{
if ((__lc->_M_use_grouping && __c == __lc->_M_thousands_sep)
|| __c == __lc->_M_decimal_point)
break;
else if (__c == __lit[__num_base::_S_izero])
{
if (!__found_mantissa)
{
__xtrc += '0';
__found_mantissa = true;
}
++__sep_pos;
if (++__beg != __end)
__c = *__beg;
else
__testeof = true;
}
else
break;
}
// Only need acceptable digits for floating point numbers.
bool __found_dec = false;
bool __found_sci = false;
string __found_grouping;
if (__lc->_M_use_grouping)
__found_grouping.reserve(32);
const char_type* __lit_zero = __lit + __num_base::_S_izero;
if (!__lc->_M_allocated)
// "C" locale
while (!__testeof)
{
const int __digit = _M_find(__lit_zero, 10, __c);
if (__digit != -1)
{
__xtrc += '0' + __digit;
__found_mantissa = true;
}
else if (__c == __lc->_M_decimal_point
&& !__found_dec && !__found_sci)
{
__xtrc += '.';
__found_dec = true;
}
else if ((__c == __lit[__num_base::_S_ie]
|| __c == __lit[__num_base::_S_iE])
&& !__found_sci && __found_mantissa)
{
// Scientific notation.
__xtrc += 'e';
__found_sci = true;
// Remove optional plus or minus sign, if they exist.
if (++__beg != __end)
{
__c = *__beg;
const bool __plus = __c == __lit[__num_base::_S_iplus];
if (__plus || __c == __lit[__num_base::_S_iminus])
__xtrc += __plus ? '+' : '-';
else
continue;
}
else
{
__testeof = true;
break;
}
}
else
break;
if (++__beg != __end)
__c = *__beg;
else
__testeof = true;
}
else
while (!__testeof)
{
// According to 22.2.2.1.2, p8-9, first look for thousands_sep
// and decimal_point.
if (__lc->_M_use_grouping && __c == __lc->_M_thousands_sep)
{
if (!__found_dec && !__found_sci)
{
// NB: Thousands separator at the beginning of a string
// is a no-no, as is two consecutive thousands separators.
if (__sep_pos)
{
__found_grouping += static_cast<char>(__sep_pos);
__sep_pos = 0;
}
else
{
// NB: __convert_to_v will not assign __v and will
// set the failbit.
__xtrc.clear();
break;
}
}
else
break;
}
else if (__c == __lc->_M_decimal_point)
{
if (!__found_dec && !__found_sci)
{
// If no grouping chars are seen, no grouping check
// is applied. Therefore __found_grouping is adjusted
// only if decimal_point comes after some thousands_sep.
if (__found_grouping.size())
__found_grouping += static_cast<char>(__sep_pos);
__xtrc += '.';
__found_dec = true;
}
else
break;
}
else
{
const char_type* __q =
__traits_type::find(__lit_zero, 10, __c);
if (__q)
{
__xtrc += '0' + (__q - __lit_zero);
__found_mantissa = true;
++__sep_pos;
}
else if ((__c == __lit[__num_base::_S_ie]
|| __c == __lit[__num_base::_S_iE])
&& !__found_sci && __found_mantissa)
{
// Scientific notation.
if (__found_grouping.size() && !__found_dec)
__found_grouping += static_cast<char>(__sep_pos);
__xtrc += 'e';
__found_sci = true;
// Remove optional plus or minus sign, if they exist.
if (++__beg != __end)
{
__c = *__beg;
const bool __plus = __c == __lit[__num_base::_S_iplus];
if ((__plus || __c == __lit[__num_base::_S_iminus])
&& !(__lc->_M_use_grouping
&& __c == __lc->_M_thousands_sep)
&& !(__c == __lc->_M_decimal_point))
__xtrc += __plus ? '+' : '-';
else
continue;
}
else
{
__testeof = true;
break;
}
}
else
break;
}
if (++__beg != __end)
__c = *__beg;
else
__testeof = true;
}
// Digit grouping is checked. If grouping and found_grouping don't
// match, then get very very upset, and set failbit.
if (__found_grouping.size())
{
// Add the ending grouping if a decimal or 'e'/'E' wasn't found.
if (!__found_dec && !__found_sci)
__found_grouping += static_cast<char>(__sep_pos);
if (!std::__verify_grouping(__lc->_M_grouping,
__lc->_M_grouping_size,
__found_grouping))
__err = ios_base::failbit;
}
return __beg;
}
template<typename _CharT, typename _InIter>
template<typename _ValueT>
_GLIBCXX_DEFAULT_ABI_TAG
_InIter
num_get<_CharT, _InIter>::
_M_extract_int(_InIter __beg, _InIter __end, ios_base& __io,
ios_base::iostate& __err, _ValueT& __v) const
{
typedef char_traits<_CharT> __traits_type;
using __gnu_cxx::__add_unsigned;
typedef typename __add_unsigned<_ValueT>::__type __unsigned_type;
typedef __numpunct_cache<_CharT> __cache_type;
__use_cache<__cache_type> __uc;
const locale& __loc = __io._M_getloc();
const __cache_type* __lc = __uc(__loc);
const _CharT* __lit = __lc->_M_atoms_in;
char_type __c = char_type();
// NB: Iff __basefield == 0, __base can change based on contents.
const ios_base::fmtflags __basefield = __io.flags()
& ios_base::basefield;
const bool __oct = __basefield == ios_base::oct;
int __base = __oct ? 8 : (__basefield == ios_base::hex ? 16 : 10);
// True if __beg becomes equal to __end.
bool __testeof = __beg == __end;
// First check for sign.
bool __negative = false;
if (!__testeof)
{
__c = *__beg;
__negative = __c == __lit[__num_base::_S_iminus];
if ((__negative || __c == __lit[__num_base::_S_iplus])
&& !(__lc->_M_use_grouping && __c == __lc->_M_thousands_sep)
&& !(__c == __lc->_M_decimal_point))
{
if (++__beg != __end)
__c = *__beg;
else
__testeof = true;
}
}
// Next, look for leading zeros and check required digits
// for base formats.
bool __found_zero = false;
int __sep_pos = 0;
while (!__testeof)
{
if ((__lc->_M_use_grouping && __c == __lc->_M_thousands_sep)
|| __c == __lc->_M_decimal_point)
break;
else if (__c == __lit[__num_base::_S_izero]
&& (!__found_zero || __base == 10))
{
__found_zero = true;
++__sep_pos;
if (__basefield == 0)
__base = 8;
if (__base == 8)
__sep_pos = 0;
}
else if (__found_zero
&& (__c == __lit[__num_base::_S_ix]
|| __c == __lit[__num_base::_S_iX]))
{
if (__basefield == 0)
__base = 16;
if (__base == 16)
{
__found_zero = false;
__sep_pos = 0;
}
else
break;
}
else
break;
if (++__beg != __end)
{
__c = *__beg;
if (!__found_zero)
break;
}
else
__testeof = true;
}
// At this point, base is determined. If not hex, only allow
// base digits as valid input.
const size_t __len = (__base == 16 ? __num_base::_S_iend
- __num_base::_S_izero : __base);
// Extract.
typedef __gnu_cxx::__numeric_traits<_ValueT> __num_traits;
string __found_grouping;
if (__lc->_M_use_grouping)
__found_grouping.reserve(32);
bool __testfail = false;
bool __testoverflow = false;
const __unsigned_type __max =
(__negative && __num_traits::__is_signed)
? -static_cast<__unsigned_type>(__num_traits::__min)
: __num_traits::__max;
const __unsigned_type __smax = __max / __base;
__unsigned_type __result = 0;
int __digit = 0;
const char_type* __lit_zero = __lit + __num_base::_S_izero;
if (!__lc->_M_allocated)
// "C" locale
while (!__testeof)
{
__digit = _M_find(__lit_zero, __len, __c);
if (__digit == -1)
break;
if (__result > __smax)
__testoverflow = true;
else
{
__result *= __base;
__testoverflow |= __result > __max - __digit;
__result += __digit;
++__sep_pos;
}
if (++__beg != __end)
__c = *__beg;
else
__testeof = true;
}
else
while (!__testeof)
{
// According to 22.2.2.1.2, p8-9, first look for thousands_sep
// and decimal_point.
if (__lc->_M_use_grouping && __c == __lc->_M_thousands_sep)
{
// NB: Thousands separator at the beginning of a string
// is a no-no, as is two consecutive thousands separators.
if (__sep_pos)
{
__found_grouping += static_cast<char>(__sep_pos);
__sep_pos = 0;
}
else
{
__testfail = true;
break;
}
}
else if (__c == __lc->_M_decimal_point)
break;
else
{
const char_type* __q =
__traits_type::find(__lit_zero, __len, __c);
if (!__q)
break;
__digit = __q - __lit_zero;
if (__digit > 15)
__digit -= 6;
if (__result > __smax)
__testoverflow = true;
else
{
__result *= __base;
__testoverflow |= __result > __max - __digit;
__result += __digit;
++__sep_pos;
}
}
if (++__beg != __end)
__c = *__beg;
else
__testeof = true;
}
// Digit grouping is checked. If grouping and found_grouping don't
// match, then get very very upset, and set failbit.
if (__found_grouping.size())
{
// Add the ending grouping.
__found_grouping += static_cast<char>(__sep_pos);
if (!std::__verify_grouping(__lc->_M_grouping,
__lc->_M_grouping_size,
__found_grouping))
__err = ios_base::failbit;
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 23. Num_get overflow result.
if ((!__sep_pos && !__found_zero && !__found_grouping.size())
|| __testfail)
{
__v = 0;
__err = ios_base::failbit;
}
else if (__testoverflow)
{
if (__negative && __num_traits::__is_signed)
__v = __num_traits::__min;
else
__v = __num_traits::__max;
__err = ios_base::failbit;
}
else
__v = __negative ? -__result : __result;
if (__testeof)
__err |= ios_base::eofbit;
return __beg;
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 17. Bad bool parsing
template<typename _CharT, typename _InIter>
_InIter
num_get<_CharT, _InIter>::
do_get(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, bool& __v) const
{
if (!(__io.flags() & ios_base::boolalpha))
{
// Parse bool values as long.
// NB: We can't just call do_get(long) here, as it might
// refer to a derived class.
long __l = -1;
__beg = _M_extract_int(__beg, __end, __io, __err, __l);
if (__l == 0 || __l == 1)
__v = bool(__l);
else
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 23. Num_get overflow result.
__v = true;
__err = ios_base::failbit;
if (__beg == __end)
__err |= ios_base::eofbit;
}
}
else
{
// Parse bool values as alphanumeric.
typedef __numpunct_cache<_CharT> __cache_type;
__use_cache<__cache_type> __uc;
const locale& __loc = __io._M_getloc();
const __cache_type* __lc = __uc(__loc);
bool __testf = true;
bool __testt = true;
bool __donef = __lc->_M_falsename_size == 0;
bool __donet = __lc->_M_truename_size == 0;
bool __testeof = false;
size_t __n = 0;
while (!__donef || !__donet)
{
if (__beg == __end)
{
__testeof = true;
break;
}
const char_type __c = *__beg;
if (!__donef)
__testf = __c == __lc->_M_falsename[__n];
if (!__testf && __donet)
break;
if (!__donet)
__testt = __c == __lc->_M_truename[__n];
if (!__testt && __donef)
break;
if (!__testt && !__testf)
break;
++__n;
++__beg;
__donef = !__testf || __n >= __lc->_M_falsename_size;
__donet = !__testt || __n >= __lc->_M_truename_size;
}
if (__testf && __n == __lc->_M_falsename_size && __n)
{
__v = false;
if (__testt && __n == __lc->_M_truename_size)
__err = ios_base::failbit;
else
__err = __testeof ? ios_base::eofbit : ios_base::goodbit;
}
else if (__testt && __n == __lc->_M_truename_size && __n)
{
__v = true;
__err = __testeof ? ios_base::eofbit : ios_base::goodbit;
}
else
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 23. Num_get overflow result.
__v = false;
__err = ios_base::failbit;
if (__testeof)
__err |= ios_base::eofbit;
}
}
return __beg;
}
template<typename _CharT, typename _InIter>
_InIter
num_get<_CharT, _InIter>::
do_get(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, float& __v) const
{
string __xtrc;
__xtrc.reserve(32);
__beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());
if (__beg == __end)
__err |= ios_base::eofbit;
return __beg;
}
template<typename _CharT, typename _InIter>
_InIter
num_get<_CharT, _InIter>::
do_get(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, double& __v) const
{
string __xtrc;
__xtrc.reserve(32);
__beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());
if (__beg == __end)
__err |= ios_base::eofbit;
return __beg;
}
#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
template<typename _CharT, typename _InIter>
_InIter
num_get<_CharT, _InIter>::
__do_get(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, double& __v) const
{
string __xtrc;
__xtrc.reserve(32);
__beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());
if (__beg == __end)
__err |= ios_base::eofbit;
return __beg;
}
#endif
template<typename _CharT, typename _InIter>
_InIter
num_get<_CharT, _InIter>::
do_get(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, long double& __v) const
{
string __xtrc;
__xtrc.reserve(32);
__beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());
if (__beg == __end)
__err |= ios_base::eofbit;
return __beg;
}
template<typename _CharT, typename _InIter>
_InIter
num_get<_CharT, _InIter>::
do_get(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, void*& __v) const
{
// Prepare for hex formatted input.
typedef ios_base::fmtflags fmtflags;
const fmtflags __fmt = __io.flags();
__io.flags((__fmt & ~ios_base::basefield) | ios_base::hex);
typedef __gnu_cxx::__conditional_type<(sizeof(void*)
<= sizeof(unsigned long)),
unsigned long, unsigned long long>::__type _UIntPtrType;
_UIntPtrType __ul;
__beg = _M_extract_int(__beg, __end, __io, __err, __ul);
// Reset from hex formatted input.
__io.flags(__fmt);
__v = reinterpret_cast<void*>(__ul);
return __beg;
}
// For use by integer and floating-point types after they have been
// converted into a char_type string.
template<typename _CharT, typename _OutIter>
void
num_put<_CharT, _OutIter>::
_M_pad(_CharT __fill, streamsize __w, ios_base& __io,
_CharT* __new, const _CharT* __cs, int& __len) const
{
// [22.2.2.2.2] Stage 3.
// If necessary, pad.
__pad<_CharT, char_traits<_CharT> >::_S_pad(__io, __fill, __new,
__cs, __w, __len);
__len = static_cast<int>(__w);
}
_GLIBCXX_END_NAMESPACE_LDBL
template<typename _CharT, typename _ValueT>
int
__int_to_char(_CharT* __bufend, _ValueT __v, const _CharT* __lit,
ios_base::fmtflags __flags, bool __dec)
{
_CharT* __buf = __bufend;
if (__builtin_expect(__dec, true))
{
// Decimal.
do
{
*--__buf = __lit[(__v % 10) + __num_base::_S_odigits];
__v /= 10;
}
while (__v != 0);
}
else if ((__flags & ios_base::basefield) == ios_base::oct)
{
// Octal.
do
{
*--__buf = __lit[(__v & 0x7) + __num_base::_S_odigits];
__v >>= 3;
}
while (__v != 0);
}
else
{
// Hex.
const bool __uppercase = __flags & ios_base::uppercase;
const int __case_offset = __uppercase ? __num_base::_S_oudigits
: __num_base::_S_odigits;
do
{
*--__buf = __lit[(__v & 0xf) + __case_offset];
__v >>= 4;
}
while (__v != 0);
}
return __bufend - __buf;
}
_GLIBCXX_BEGIN_NAMESPACE_LDBL
template<typename _CharT, typename _OutIter>
void
num_put<_CharT, _OutIter>::
_M_group_int(const char* __grouping, size_t __grouping_size, _CharT __sep,
ios_base&, _CharT* __new, _CharT* __cs, int& __len) const
{
_CharT* __p = std::__add_grouping(__new, __sep, __grouping,
__grouping_size, __cs, __cs + __len);
__len = __p - __new;
}
template<typename _CharT, typename _OutIter>
template<typename _ValueT>
_OutIter
num_put<_CharT, _OutIter>::
_M_insert_int(_OutIter __s, ios_base& __io, _CharT __fill,
_ValueT __v) const
{
using __gnu_cxx::__add_unsigned;
typedef typename __add_unsigned<_ValueT>::__type __unsigned_type;
typedef __numpunct_cache<_CharT> __cache_type;
__use_cache<__cache_type> __uc;
const locale& __loc = __io._M_getloc();
const __cache_type* __lc = __uc(__loc);
const _CharT* __lit = __lc->_M_atoms_out;
const ios_base::fmtflags __flags = __io.flags();
// Long enough to hold hex, dec, and octal representations.
const int __ilen = 5 * sizeof(_ValueT);
_CharT* __cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
* __ilen));
// [22.2.2.2.2] Stage 1, numeric conversion to character.
// Result is returned right-justified in the buffer.
const ios_base::fmtflags __basefield = __flags & ios_base::basefield;
const bool __dec = (__basefield != ios_base::oct
&& __basefield != ios_base::hex);
const __unsigned_type __u = ((__v > 0 || !__dec)
? __unsigned_type(__v)
: -__unsigned_type(__v));
int __len = __int_to_char(__cs + __ilen, __u, __lit, __flags, __dec);
__cs += __ilen - __len;
// Add grouping, if necessary.
if (__lc->_M_use_grouping)
{
// Grouping can add (almost) as many separators as the number
// of digits + space is reserved for numeric base or sign.
_CharT* __cs2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
* (__len + 1)
* 2));
_M_group_int(__lc->_M_grouping, __lc->_M_grouping_size,
__lc->_M_thousands_sep, __io, __cs2 + 2, __cs, __len);
__cs = __cs2 + 2;
}
// Complete Stage 1, prepend numeric base or sign.
if (__builtin_expect(__dec, true))
{
// Decimal.
if (__v >= 0)
{
if (bool(__flags & ios_base::showpos)
&& __gnu_cxx::__numeric_traits<_ValueT>::__is_signed)
*--__cs = __lit[__num_base::_S_oplus], ++__len;
}
else
*--__cs = __lit[__num_base::_S_ominus], ++__len;
}
else if (bool(__flags & ios_base::showbase) && __v)
{
if (__basefield == ios_base::oct)
*--__cs = __lit[__num_base::_S_odigits], ++__len;
else
{
// 'x' or 'X'
const bool __uppercase = __flags & ios_base::uppercase;
*--__cs = __lit[__num_base::_S_ox + __uppercase];
// '0'
*--__cs = __lit[__num_base::_S_odigits];
__len += 2;
}
}
// Pad.
const streamsize __w = __io.width();
if (__w > static_cast<streamsize>(__len))
{
_CharT* __cs3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
* __w));
_M_pad(__fill, __w, __io, __cs3, __cs, __len);
__cs = __cs3;
}
__io.width(0);
// [22.2.2.2.2] Stage 4.
// Write resulting, fully-formatted string to output iterator.
return std::__write(__s, __cs, __len);
}
template<typename _CharT, typename _OutIter>
void
num_put<_CharT, _OutIter>::
_M_group_float(const char* __grouping, size_t __grouping_size,
_CharT __sep, const _CharT* __p, _CharT* __new,
_CharT* __cs, int& __len) const
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 282. What types does numpunct grouping refer to?
// Add grouping, if necessary.
const int __declen = __p ? __p - __cs : __len;
_CharT* __p2 = std::__add_grouping(__new, __sep, __grouping,
__grouping_size,
__cs, __cs + __declen);
// Tack on decimal part.
int __newlen = __p2 - __new;
if (__p)
{
char_traits<_CharT>::copy(__p2, __p, __len - __declen);
__newlen += __len - __declen;
}
__len = __newlen;
}
// The following code uses vsnprintf (or vsprintf(), when
// _GLIBCXX_USE_C99_STDIO is not defined) to convert floating point
// values for insertion into a stream. An optimization would be to
// replace them with code that works directly on a wide buffer and
// then use __pad to do the padding. It would be good to replace
// them anyway to gain back the efficiency that C++ provides by
// knowing up front the type of the values to insert. Also, sprintf
// is dangerous since may lead to accidental buffer overruns. This
// implementation follows the C++ standard fairly directly as
// outlined in 22.2.2.2 [lib.locale.num.put]
template<typename _CharT, typename _OutIter>
template<typename _ValueT>
_OutIter
num_put<_CharT, _OutIter>::
_M_insert_float(_OutIter __s, ios_base& __io, _CharT __fill, char __mod,
_ValueT __v) const
{
typedef __numpunct_cache<_CharT> __cache_type;
__use_cache<__cache_type> __uc;
const locale& __loc = __io._M_getloc();
const __cache_type* __lc = __uc(__loc);
// Use default precision if out of range.
const streamsize __prec = __io.precision() < 0 ? 6 : __io.precision();
const int __max_digits =
__gnu_cxx::__numeric_traits<_ValueT>::__digits10;
// [22.2.2.2.2] Stage 1, numeric conversion to character.
int __len;
// Long enough for the max format spec.
char __fbuf[16];
__num_base::_S_format_float(__io, __fbuf, __mod);
#if _GLIBCXX_USE_C99_STDIO && !_GLIBCXX_HAVE_BROKEN_VSNPRINTF
// Precision is always used except for hexfloat format.
const bool __use_prec =
(__io.flags() & ios_base::floatfield) != ios_base::floatfield;
// First try a buffer perhaps big enough (most probably sufficient
// for non-ios_base::fixed outputs)
int __cs_size = __max_digits * 3;
char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
if (__use_prec)
__len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size,
__fbuf, __prec, __v);
else
__len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size,
__fbuf, __v);
// If the buffer was not large enough, try again with the correct size.
if (__len >= __cs_size)
{
__cs_size = __len + 1;
__cs = static_cast<char*>(__builtin_alloca(__cs_size));
if (__use_prec)
__len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size,
__fbuf, __prec, __v);
else
__len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size,
__fbuf, __v);
}
#else
// Consider the possibility of long ios_base::fixed outputs
const bool __fixed = __io.flags() & ios_base::fixed;
const int __max_exp =
__gnu_cxx::__numeric_traits<_ValueT>::__max_exponent10;
// The size of the output string is computed as follows.
// ios_base::fixed outputs may need up to __max_exp + 1 chars
// for the integer part + __prec chars for the fractional part
// + 3 chars for sign, decimal point, '\0'. On the other hand,
// for non-fixed outputs __max_digits * 2 + __prec chars are
// largely sufficient.
const int __cs_size = __fixed ? __max_exp + __prec + 4
: __max_digits * 2 + __prec;
char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
__len = std::__convert_from_v(_S_get_c_locale(), __cs, 0, __fbuf,
__prec, __v);
#endif
// [22.2.2.2.2] Stage 2, convert to char_type, using correct
// numpunct.decimal_point() values for '.' and adding grouping.
const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
_CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
* __len));
__ctype.widen(__cs, __cs + __len, __ws);
// Replace decimal point.
_CharT* __wp = 0;
const char* __p = char_traits<char>::find(__cs, __len, '.');
if (__p)
{
__wp = __ws + (__p - __cs);
*__wp = __lc->_M_decimal_point;
}
// Add grouping, if necessary.
// N.B. Make sure to not group things like 2e20, i.e., no decimal
// point, scientific notation.
if (__lc->_M_use_grouping
&& (__wp || __len < 3 || (__cs[1] <= '9' && __cs[2] <= '9'
&& __cs[1] >= '0' && __cs[2] >= '0')))
{
// Grouping can add (almost) as many separators as the
// number of digits, but no more.
_CharT* __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
* __len * 2));
streamsize __off = 0;
if (__cs[0] == '-' || __cs[0] == '+')
{
__off = 1;
__ws2[0] = __ws[0];
__len -= 1;
}
_M_group_float(__lc->_M_grouping, __lc->_M_grouping_size,
__lc->_M_thousands_sep, __wp, __ws2 + __off,
__ws + __off, __len);
__len += __off;
__ws = __ws2;
}
// Pad.
const streamsize __w = __io.width();
if (__w > static_cast<streamsize>(__len))
{
_CharT* __ws3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
* __w));
_M_pad(__fill, __w, __io, __ws3, __ws, __len);
__ws = __ws3;
}
__io.width(0);
// [22.2.2.2.2] Stage 4.
// Write resulting, fully-formatted string to output iterator.
return std::__write(__s, __ws, __len);
}
template<typename _CharT, typename _OutIter>
_OutIter
num_put<_CharT, _OutIter>::
do_put(iter_type __s, ios_base& __io, char_type __fill, bool __v) const
{
const ios_base::fmtflags __flags = __io.flags();
if ((__flags & ios_base::boolalpha) == 0)
{
const long __l = __v;
__s = _M_insert_int(__s, __io, __fill, __l);
}
else
{
typedef __numpunct_cache<_CharT> __cache_type;
__use_cache<__cache_type> __uc;
const locale& __loc = __io._M_getloc();
const __cache_type* __lc = __uc(__loc);
const _CharT* __name = __v ? __lc->_M_truename
: __lc->_M_falsename;
int __len = __v ? __lc->_M_truename_size
: __lc->_M_falsename_size;
const streamsize __w = __io.width();
if (__w > static_cast<streamsize>(__len))
{
const streamsize __plen = __w - __len;
_CharT* __ps
= static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
* __plen));
char_traits<_CharT>::assign(__ps, __plen, __fill);
__io.width(0);
if ((__flags & ios_base::adjustfield) == ios_base::left)
{
__s = std::__write(__s, __name, __len);
__s = std::__write(__s, __ps, __plen);
}
else
{
__s = std::__write(__s, __ps, __plen);
__s = std::__write(__s, __name, __len);
}
return __s;
}
__io.width(0);
__s = std::__write(__s, __name, __len);
}
return __s;
}
template<typename _CharT, typename _OutIter>
_OutIter
num_put<_CharT, _OutIter>::
do_put(iter_type __s, ios_base& __io, char_type __fill, double __v) const
{ return _M_insert_float(__s, __io, __fill, char(), __v); }
#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
template<typename _CharT, typename _OutIter>
_OutIter
num_put<_CharT, _OutIter>::
__do_put(iter_type __s, ios_base& __io, char_type __fill, double __v) const
{ return _M_insert_float(__s, __io, __fill, char(), __v); }
#endif
template<typename _CharT, typename _OutIter>
_OutIter
num_put<_CharT, _OutIter>::
do_put(iter_type __s, ios_base& __io, char_type __fill,
long double __v) const
{ return _M_insert_float(__s, __io, __fill, 'L', __v); }
template<typename _CharT, typename _OutIter>
_OutIter
num_put<_CharT, _OutIter>::
do_put(iter_type __s, ios_base& __io, char_type __fill,
const void* __v) const
{
const ios_base::fmtflags __flags = __io.flags();
const ios_base::fmtflags __fmt = ~(ios_base::basefield
| ios_base::uppercase);
__io.flags((__flags & __fmt) | (ios_base::hex | ios_base::showbase));
typedef __gnu_cxx::__conditional_type<(sizeof(const void*)
<= sizeof(unsigned long)),
unsigned long, unsigned long long>::__type _UIntPtrType;
__s = _M_insert_int(__s, __io, __fill,
reinterpret_cast<_UIntPtrType>(__v));
__io.flags(__flags);
return __s;
}
_GLIBCXX_END_NAMESPACE_LDBL
// Construct correctly padded string, as per 22.2.2.2.2
// Assumes
// __newlen > __oldlen
// __news is allocated for __newlen size
// NB: Of the two parameters, _CharT can be deduced from the
// function arguments. The other (_Traits) has to be explicitly specified.
template<typename _CharT, typename _Traits>
void
__pad<_CharT, _Traits>::_S_pad(ios_base& __io, _CharT __fill,
_CharT* __news, const _CharT* __olds,
streamsize __newlen, streamsize __oldlen)
{
const size_t __plen = static_cast<size_t>(__newlen - __oldlen);
const ios_base::fmtflags __adjust = __io.flags() & ios_base::adjustfield;
// Padding last.
if (__adjust == ios_base::left)
{
_Traits::copy(__news, __olds, __oldlen);
_Traits::assign(__news + __oldlen, __plen, __fill);
return;
}
size_t __mod = 0;
if (__adjust == ios_base::internal)
{
// Pad after the sign, if there is one.
// Pad after 0[xX], if there is one.
// Who came up with these rules, anyway? Jeeze.
const locale& __loc = __io._M_getloc();
const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
if (__ctype.widen('-') == __olds[0]
|| __ctype.widen('+') == __olds[0])
{
__news[0] = __olds[0];
__mod = 1;
++__news;
}
else if (__ctype.widen('0') == __olds[0]
&& __oldlen > 1
&& (__ctype.widen('x') == __olds[1]
|| __ctype.widen('X') == __olds[1]))
{
__news[0] = __olds[0];
__news[1] = __olds[1];
__mod = 2;
__news += 2;
}
// else Padding first.
}
_Traits::assign(__news, __plen, __fill);
_Traits::copy(__news + __plen, __olds + __mod, __oldlen - __mod);
}
template<typename _CharT>
_CharT*
__add_grouping(_CharT* __s, _CharT __sep,
const char* __gbeg, size_t __gsize,
const _CharT* __first, const _CharT* __last)
{
size_t __idx = 0;
size_t __ctr = 0;
while (__last - __first > __gbeg[__idx]
&& static_cast<signed char>(__gbeg[__idx]) > 0
&& __gbeg[__idx] != __gnu_cxx::__numeric_traits<char>::__max)
{
__last -= __gbeg[__idx];
__idx < __gsize - 1 ? ++__idx : ++__ctr;
}
while (__first != __last)
*__s++ = *__first++;
while (__ctr--)
{
*__s++ = __sep;
for (char __i = __gbeg[__idx]; __i > 0; --__i)
*__s++ = *__first++;
}
while (__idx--)
{
*__s++ = __sep;
for (char __i = __gbeg[__idx]; __i > 0; --__i)
*__s++ = *__first++;
}
return __s;
}
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
#if _GLIBCXX_EXTERN_TEMPLATE
extern template class _GLIBCXX_NAMESPACE_CXX11 numpunct<char>;
extern template class _GLIBCXX_NAMESPACE_CXX11 numpunct_byname<char>;
extern template class _GLIBCXX_NAMESPACE_LDBL num_get<char>;
extern template class _GLIBCXX_NAMESPACE_LDBL num_put<char>;
extern template class ctype_byname<char>;
extern template
const ctype<char>&
use_facet<ctype<char> >(const locale&);
extern template
const numpunct<char>&
use_facet<numpunct<char> >(const locale&);
extern template
const num_put<char>&
use_facet<num_put<char> >(const locale&);
extern template
const num_get<char>&
use_facet<num_get<char> >(const locale&);
extern template
bool
has_facet<ctype<char> >(const locale&);
extern template
bool
has_facet<numpunct<char> >(const locale&);
extern template
bool
has_facet<num_put<char> >(const locale&);
extern template
bool
has_facet<num_get<char> >(const locale&);
#ifdef _GLIBCXX_USE_WCHAR_T
extern template class _GLIBCXX_NAMESPACE_CXX11 numpunct<wchar_t>;
extern template class _GLIBCXX_NAMESPACE_CXX11 numpunct_byname<wchar_t>;
extern template class _GLIBCXX_NAMESPACE_LDBL num_get<wchar_t>;
extern template class _GLIBCXX_NAMESPACE_LDBL num_put<wchar_t>;
extern template class ctype_byname<wchar_t>;
extern template
const ctype<wchar_t>&
use_facet<ctype<wchar_t> >(const locale&);
extern template
const numpunct<wchar_t>&
use_facet<numpunct<wchar_t> >(const locale&);
extern template
const num_put<wchar_t>&
use_facet<num_put<wchar_t> >(const locale&);
extern template
const num_get<wchar_t>&
use_facet<num_get<wchar_t> >(const locale&);
extern template
bool
has_facet<ctype<wchar_t> >(const locale&);
extern template
bool
has_facet<numpunct<wchar_t> >(const locale&);
extern template
bool
has_facet<num_put<wchar_t> >(const locale&);
extern template
bool
has_facet<num_get<wchar_t> >(const locale&);
#endif
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/bits/stl_iterator_base_funcs.h 0000644 00000017762 15201526705 0013320 0 ustar 00 // Functions used by iterators -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1996-1998
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file bits/stl_iterator_base_funcs.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{iterator}
*
* This file contains all of the general iterator-related utility
* functions, such as distance() and advance().
*/
#ifndef _STL_ITERATOR_BASE_FUNCS_H
#define _STL_ITERATOR_BASE_FUNCS_H 1
#pragma GCC system_header
#include <bits/concept_check.h>
#include <debug/assertions.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// Forward declaration for the overloads of __distance.
template <typename> struct _List_iterator;
template <typename> struct _List_const_iterator;
_GLIBCXX_END_NAMESPACE_CONTAINER
template<typename _InputIterator>
inline _GLIBCXX14_CONSTEXPR
typename iterator_traits<_InputIterator>::difference_type
__distance(_InputIterator __first, _InputIterator __last,
input_iterator_tag)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
typename iterator_traits<_InputIterator>::difference_type __n = 0;
while (__first != __last)
{
++__first;
++__n;
}
return __n;
}
template<typename _RandomAccessIterator>
inline _GLIBCXX14_CONSTEXPR
typename iterator_traits<_RandomAccessIterator>::difference_type
__distance(_RandomAccessIterator __first, _RandomAccessIterator __last,
random_access_iterator_tag)
{
// concept requirements
__glibcxx_function_requires(_RandomAccessIteratorConcept<
_RandomAccessIterator>)
return __last - __first;
}
#if _GLIBCXX_USE_CXX11_ABI
// Forward declaration because of the qualified call in distance.
template<typename _Tp>
ptrdiff_t
__distance(_GLIBCXX_STD_C::_List_iterator<_Tp>,
_GLIBCXX_STD_C::_List_iterator<_Tp>,
input_iterator_tag);
template<typename _Tp>
ptrdiff_t
__distance(_GLIBCXX_STD_C::_List_const_iterator<_Tp>,
_GLIBCXX_STD_C::_List_const_iterator<_Tp>,
input_iterator_tag);
#endif
/**
* @brief A generalization of pointer arithmetic.
* @param __first An input iterator.
* @param __last An input iterator.
* @return The distance between them.
*
* Returns @c n such that __first + n == __last. This requires
* that @p __last must be reachable from @p __first. Note that @c
* n may be negative.
*
* For random access iterators, this uses their @c + and @c - operations
* and are constant time. For other %iterator classes they are linear time.
*/
template<typename _InputIterator>
inline _GLIBCXX17_CONSTEXPR
typename iterator_traits<_InputIterator>::difference_type
distance(_InputIterator __first, _InputIterator __last)
{
// concept requirements -- taken care of in __distance
return std::__distance(__first, __last,
std::__iterator_category(__first));
}
template<typename _InputIterator, typename _Distance>
inline _GLIBCXX14_CONSTEXPR void
__advance(_InputIterator& __i, _Distance __n, input_iterator_tag)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_assert(__n >= 0);
while (__n--)
++__i;
}
template<typename _BidirectionalIterator, typename _Distance>
inline _GLIBCXX14_CONSTEXPR void
__advance(_BidirectionalIterator& __i, _Distance __n,
bidirectional_iterator_tag)
{
// concept requirements
__glibcxx_function_requires(_BidirectionalIteratorConcept<
_BidirectionalIterator>)
if (__n > 0)
while (__n--)
++__i;
else
while (__n++)
--__i;
}
template<typename _RandomAccessIterator, typename _Distance>
inline _GLIBCXX14_CONSTEXPR void
__advance(_RandomAccessIterator& __i, _Distance __n,
random_access_iterator_tag)
{
// concept requirements
__glibcxx_function_requires(_RandomAccessIteratorConcept<
_RandomAccessIterator>)
if (__builtin_constant_p(__n) && __n == 1)
++__i;
else if (__builtin_constant_p(__n) && __n == -1)
--__i;
else
__i += __n;
}
/**
* @brief A generalization of pointer arithmetic.
* @param __i An input iterator.
* @param __n The @a delta by which to change @p __i.
* @return Nothing.
*
* This increments @p i by @p n. For bidirectional and random access
* iterators, @p __n may be negative, in which case @p __i is decremented.
*
* For random access iterators, this uses their @c + and @c - operations
* and are constant time. For other %iterator classes they are linear time.
*/
template<typename _InputIterator, typename _Distance>
inline _GLIBCXX17_CONSTEXPR void
advance(_InputIterator& __i, _Distance __n)
{
// concept requirements -- taken care of in __advance
typename iterator_traits<_InputIterator>::difference_type __d = __n;
std::__advance(__i, __d, std::__iterator_category(__i));
}
#if __cplusplus >= 201103L
template<typename _InputIterator>
inline _GLIBCXX17_CONSTEXPR _InputIterator
next(_InputIterator __x, typename
iterator_traits<_InputIterator>::difference_type __n = 1)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
std::advance(__x, __n);
return __x;
}
template<typename _BidirectionalIterator>
inline _GLIBCXX17_CONSTEXPR _BidirectionalIterator
prev(_BidirectionalIterator __x, typename
iterator_traits<_BidirectionalIterator>::difference_type __n = 1)
{
// concept requirements
__glibcxx_function_requires(_BidirectionalIteratorConcept<
_BidirectionalIterator>)
std::advance(__x, -__n);
return __x;
}
#endif // C++11
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif /* _STL_ITERATOR_BASE_FUNCS_H */
c++/8/bits/sstream.tcc 0000644 00000023636 15201526705 0010412 0 ustar 00 // String based streams -*- C++ -*-
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/sstream.tcc
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{sstream}
*/
//
// ISO C++ 14882: 27.7 String-based streams
//
#ifndef _SSTREAM_TCC
#define _SSTREAM_TCC 1
#pragma GCC system_header
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template <class _CharT, class _Traits, class _Alloc>
typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
basic_stringbuf<_CharT, _Traits, _Alloc>::
pbackfail(int_type __c)
{
int_type __ret = traits_type::eof();
if (this->eback() < this->gptr())
{
// Try to put back __c into input sequence in one of three ways.
// Order these tests done in is unspecified by the standard.
const bool __testeof = traits_type::eq_int_type(__c, __ret);
if (!__testeof)
{
const bool __testeq = traits_type::eq(traits_type::
to_char_type(__c),
this->gptr()[-1]);
const bool __testout = this->_M_mode & ios_base::out;
if (__testeq || __testout)
{
this->gbump(-1);
if (!__testeq)
*this->gptr() = traits_type::to_char_type(__c);
__ret = __c;
}
}
else
{
this->gbump(-1);
__ret = traits_type::not_eof(__c);
}
}
return __ret;
}
template <class _CharT, class _Traits, class _Alloc>
typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
basic_stringbuf<_CharT, _Traits, _Alloc>::
overflow(int_type __c)
{
const bool __testout = this->_M_mode & ios_base::out;
if (__builtin_expect(!__testout, false))
return traits_type::eof();
const bool __testeof = traits_type::eq_int_type(__c, traits_type::eof());
if (__builtin_expect(__testeof, false))
return traits_type::not_eof(__c);
const __size_type __capacity = _M_string.capacity();
#if _GLIBCXX_USE_CXX11_ABI
if ((this->epptr() - this->pbase()) < __capacity)
{
// There is additional capacity in _M_string that can be used.
char_type* __base = const_cast<char_type*>(_M_string.data());
_M_pbump(__base, __base + __capacity, this->pptr() - this->pbase());
if (_M_mode & ios_base::in)
{
const __size_type __nget = this->gptr() - this->eback();
const __size_type __eget = this->egptr() - this->eback();
this->setg(__base, __base + __nget, __base + __eget + 1);
}
*this->pptr() = traits_type::to_char_type(__c);
this->pbump(1);
return __c;
}
#endif
const __size_type __max_size = _M_string.max_size();
const bool __testput = this->pptr() < this->epptr();
if (__builtin_expect(!__testput && __capacity == __max_size, false))
return traits_type::eof();
// Try to append __c into output sequence in one of two ways.
// Order these tests done in is unspecified by the standard.
const char_type __conv = traits_type::to_char_type(__c);
if (!__testput)
{
// NB: Start ostringstream buffers at 512 chars. This is an
// experimental value (pronounced "arbitrary" in some of the
// hipper English-speaking countries), and can be changed to
// suit particular needs.
//
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 169. Bad efficiency of overflow() mandated
// 432. stringbuf::overflow() makes only one write position
// available
const __size_type __opt_len = std::max(__size_type(2 * __capacity),
__size_type(512));
const __size_type __len = std::min(__opt_len, __max_size);
__string_type __tmp(_M_string.get_allocator());
__tmp.reserve(__len);
if (this->pbase())
__tmp.assign(this->pbase(), this->epptr() - this->pbase());
__tmp.push_back(__conv);
_M_string.swap(__tmp);
_M_sync(const_cast<char_type*>(_M_string.data()),
this->gptr() - this->eback(), this->pptr() - this->pbase());
}
else
*this->pptr() = __conv;
this->pbump(1);
return __c;
}
template <class _CharT, class _Traits, class _Alloc>
typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
basic_stringbuf<_CharT, _Traits, _Alloc>::
underflow()
{
int_type __ret = traits_type::eof();
const bool __testin = this->_M_mode & ios_base::in;
if (__testin)
{
// Update egptr() to match the actual string end.
_M_update_egptr();
if (this->gptr() < this->egptr())
__ret = traits_type::to_int_type(*this->gptr());
}
return __ret;
}
template <class _CharT, class _Traits, class _Alloc>
typename basic_stringbuf<_CharT, _Traits, _Alloc>::pos_type
basic_stringbuf<_CharT, _Traits, _Alloc>::
seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __mode)
{
pos_type __ret = pos_type(off_type(-1));
bool __testin = (ios_base::in & this->_M_mode & __mode) != 0;
bool __testout = (ios_base::out & this->_M_mode & __mode) != 0;
const bool __testboth = __testin && __testout && __way != ios_base::cur;
__testin &= !(__mode & ios_base::out);
__testout &= !(__mode & ios_base::in);
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 453. basic_stringbuf::seekoff need not always fail for an empty stream.
const char_type* __beg = __testin ? this->eback() : this->pbase();
if ((__beg || !__off) && (__testin || __testout || __testboth))
{
_M_update_egptr();
off_type __newoffi = __off;
off_type __newoffo = __newoffi;
if (__way == ios_base::cur)
{
__newoffi += this->gptr() - __beg;
__newoffo += this->pptr() - __beg;
}
else if (__way == ios_base::end)
__newoffo = __newoffi += this->egptr() - __beg;
if ((__testin || __testboth)
&& __newoffi >= 0
&& this->egptr() - __beg >= __newoffi)
{
this->setg(this->eback(), this->eback() + __newoffi,
this->egptr());
__ret = pos_type(__newoffi);
}
if ((__testout || __testboth)
&& __newoffo >= 0
&& this->egptr() - __beg >= __newoffo)
{
_M_pbump(this->pbase(), this->epptr(), __newoffo);
__ret = pos_type(__newoffo);
}
}
return __ret;
}
template <class _CharT, class _Traits, class _Alloc>
typename basic_stringbuf<_CharT, _Traits, _Alloc>::pos_type
basic_stringbuf<_CharT, _Traits, _Alloc>::
seekpos(pos_type __sp, ios_base::openmode __mode)
{
pos_type __ret = pos_type(off_type(-1));
const bool __testin = (ios_base::in & this->_M_mode & __mode) != 0;
const bool __testout = (ios_base::out & this->_M_mode & __mode) != 0;
const char_type* __beg = __testin ? this->eback() : this->pbase();
if ((__beg || !off_type(__sp)) && (__testin || __testout))
{
_M_update_egptr();
const off_type __pos(__sp);
const bool __testpos = (0 <= __pos
&& __pos <= this->egptr() - __beg);
if (__testpos)
{
if (__testin)
this->setg(this->eback(), this->eback() + __pos,
this->egptr());
if (__testout)
_M_pbump(this->pbase(), this->epptr(), __pos);
__ret = __sp;
}
}
return __ret;
}
template <class _CharT, class _Traits, class _Alloc>
void
basic_stringbuf<_CharT, _Traits, _Alloc>::
_M_sync(char_type* __base, __size_type __i, __size_type __o)
{
const bool __testin = _M_mode & ios_base::in;
const bool __testout = _M_mode & ios_base::out;
char_type* __endg = __base + _M_string.size();
char_type* __endp = __base + _M_string.capacity();
if (__base != _M_string.data())
{
// setbuf: __i == size of buffer area (_M_string.size() == 0).
__endg += __i;
__i = 0;
__endp = __endg;
}
if (__testin)
this->setg(__base, __base + __i, __endg);
if (__testout)
{
_M_pbump(__base, __endp, __o);
// egptr() always tracks the string end. When !__testin,
// for the correct functioning of the streambuf inlines
// the other get area pointers are identical.
if (!__testin)
this->setg(__endg, __endg, __endg);
}
}
template <class _CharT, class _Traits, class _Alloc>
void
basic_stringbuf<_CharT, _Traits, _Alloc>::
_M_pbump(char_type* __pbeg, char_type* __pend, off_type __off)
{
this->setp(__pbeg, __pend);
while (__off > __gnu_cxx::__numeric_traits<int>::__max)
{
this->pbump(__gnu_cxx::__numeric_traits<int>::__max);
__off -= __gnu_cxx::__numeric_traits<int>::__max;
}
this->pbump(__off);
}
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
#if _GLIBCXX_EXTERN_TEMPLATE
extern template class basic_stringbuf<char>;
extern template class basic_istringstream<char>;
extern template class basic_ostringstream<char>;
extern template class basic_stringstream<char>;
#ifdef _GLIBCXX_USE_WCHAR_T
extern template class basic_stringbuf<wchar_t>;
extern template class basic_istringstream<wchar_t>;
extern template class basic_ostringstream<wchar_t>;
extern template class basic_stringstream<wchar_t>;
#endif
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif
c++/8/bits/stl_algobase.h 0000644 00000142476 15201526705 0011055 0 ustar 00 // Core algorithmic facilities -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1996-1998
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file bits/stl_algobase.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{algorithm}
*/
#ifndef _STL_ALGOBASE_H
#define _STL_ALGOBASE_H 1
#include <bits/c++config.h>
#include <bits/functexcept.h>
#include <bits/cpp_type_traits.h>
#include <ext/type_traits.h>
#include <ext/numeric_traits.h>
#include <bits/stl_pair.h>
#include <bits/stl_iterator_base_types.h>
#include <bits/stl_iterator_base_funcs.h>
#include <bits/stl_iterator.h>
#include <bits/concept_check.h>
#include <debug/debug.h>
#include <bits/move.h> // For std::swap
#include <bits/predefined_ops.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __cplusplus < 201103L
// See http://gcc.gnu.org/ml/libstdc++/2004-08/msg00167.html: in a
// nutshell, we are partially implementing the resolution of DR 187,
// when it's safe, i.e., the value_types are equal.
template<bool _BoolType>
struct __iter_swap
{
template<typename _ForwardIterator1, typename _ForwardIterator2>
static void
iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
{
typedef typename iterator_traits<_ForwardIterator1>::value_type
_ValueType1;
_ValueType1 __tmp = *__a;
*__a = *__b;
*__b = __tmp;
}
};
template<>
struct __iter_swap<true>
{
template<typename _ForwardIterator1, typename _ForwardIterator2>
static void
iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
{
swap(*__a, *__b);
}
};
#endif
/**
* @brief Swaps the contents of two iterators.
* @ingroup mutating_algorithms
* @param __a An iterator.
* @param __b Another iterator.
* @return Nothing.
*
* This function swaps the values pointed to by two iterators, not the
* iterators themselves.
*/
template<typename _ForwardIterator1, typename _ForwardIterator2>
inline void
iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
{
// concept requirements
__glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
_ForwardIterator1>)
__glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
_ForwardIterator2>)
#if __cplusplus < 201103L
typedef typename iterator_traits<_ForwardIterator1>::value_type
_ValueType1;
typedef typename iterator_traits<_ForwardIterator2>::value_type
_ValueType2;
__glibcxx_function_requires(_ConvertibleConcept<_ValueType1,
_ValueType2>)
__glibcxx_function_requires(_ConvertibleConcept<_ValueType2,
_ValueType1>)
typedef typename iterator_traits<_ForwardIterator1>::reference
_ReferenceType1;
typedef typename iterator_traits<_ForwardIterator2>::reference
_ReferenceType2;
std::__iter_swap<__are_same<_ValueType1, _ValueType2>::__value
&& __are_same<_ValueType1&, _ReferenceType1>::__value
&& __are_same<_ValueType2&, _ReferenceType2>::__value>::
iter_swap(__a, __b);
#else
swap(*__a, *__b);
#endif
}
/**
* @brief Swap the elements of two sequences.
* @ingroup mutating_algorithms
* @param __first1 A forward iterator.
* @param __last1 A forward iterator.
* @param __first2 A forward iterator.
* @return An iterator equal to @p first2+(last1-first1).
*
* Swaps each element in the range @p [first1,last1) with the
* corresponding element in the range @p [first2,(last1-first1)).
* The ranges must not overlap.
*/
template<typename _ForwardIterator1, typename _ForwardIterator2>
_ForwardIterator2
swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2)
{
// concept requirements
__glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
_ForwardIterator1>)
__glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
_ForwardIterator2>)
__glibcxx_requires_valid_range(__first1, __last1);
for (; __first1 != __last1; ++__first1, (void)++__first2)
std::iter_swap(__first1, __first2);
return __first2;
}
/**
* @brief This does what you think it does.
* @ingroup sorting_algorithms
* @param __a A thing of arbitrary type.
* @param __b Another thing of arbitrary type.
* @return The lesser of the parameters.
*
* This is the simple classic generic implementation. It will work on
* temporary expressions, since they are only evaluated once, unlike a
* preprocessor macro.
*/
template<typename _Tp>
_GLIBCXX14_CONSTEXPR
inline const _Tp&
min(const _Tp& __a, const _Tp& __b)
{
// concept requirements
__glibcxx_function_requires(_LessThanComparableConcept<_Tp>)
//return __b < __a ? __b : __a;
if (__b < __a)
return __b;
return __a;
}
/**
* @brief This does what you think it does.
* @ingroup sorting_algorithms
* @param __a A thing of arbitrary type.
* @param __b Another thing of arbitrary type.
* @return The greater of the parameters.
*
* This is the simple classic generic implementation. It will work on
* temporary expressions, since they are only evaluated once, unlike a
* preprocessor macro.
*/
template<typename _Tp>
_GLIBCXX14_CONSTEXPR
inline const _Tp&
max(const _Tp& __a, const _Tp& __b)
{
// concept requirements
__glibcxx_function_requires(_LessThanComparableConcept<_Tp>)
//return __a < __b ? __b : __a;
if (__a < __b)
return __b;
return __a;
}
/**
* @brief This does what you think it does.
* @ingroup sorting_algorithms
* @param __a A thing of arbitrary type.
* @param __b Another thing of arbitrary type.
* @param __comp A @link comparison_functors comparison functor@endlink.
* @return The lesser of the parameters.
*
* This will work on temporary expressions, since they are only evaluated
* once, unlike a preprocessor macro.
*/
template<typename _Tp, typename _Compare>
_GLIBCXX14_CONSTEXPR
inline const _Tp&
min(const _Tp& __a, const _Tp& __b, _Compare __comp)
{
//return __comp(__b, __a) ? __b : __a;
if (__comp(__b, __a))
return __b;
return __a;
}
/**
* @brief This does what you think it does.
* @ingroup sorting_algorithms
* @param __a A thing of arbitrary type.
* @param __b Another thing of arbitrary type.
* @param __comp A @link comparison_functors comparison functor@endlink.
* @return The greater of the parameters.
*
* This will work on temporary expressions, since they are only evaluated
* once, unlike a preprocessor macro.
*/
template<typename _Tp, typename _Compare>
_GLIBCXX14_CONSTEXPR
inline const _Tp&
max(const _Tp& __a, const _Tp& __b, _Compare __comp)
{
//return __comp(__a, __b) ? __b : __a;
if (__comp(__a, __b))
return __b;
return __a;
}
// Fallback implementation of the function in bits/stl_iterator.h used to
// remove the __normal_iterator wrapper. See copy, fill, ...
template<typename _Iterator>
inline _Iterator
__niter_base(_Iterator __it)
{ return __it; }
// All of these auxiliary structs serve two purposes. (1) Replace
// calls to copy with memmove whenever possible. (Memmove, not memcpy,
// because the input and output ranges are permitted to overlap.)
// (2) If we're using random access iterators, then write the loop as
// a for loop with an explicit count.
template<bool, bool, typename>
struct __copy_move
{
template<typename _II, typename _OI>
static _OI
__copy_m(_II __first, _II __last, _OI __result)
{
for (; __first != __last; ++__result, (void)++__first)
*__result = *__first;
return __result;
}
};
#if __cplusplus >= 201103L
template<typename _Category>
struct __copy_move<true, false, _Category>
{
template<typename _II, typename _OI>
static _OI
__copy_m(_II __first, _II __last, _OI __result)
{
for (; __first != __last; ++__result, (void)++__first)
*__result = std::move(*__first);
return __result;
}
};
#endif
template<>
struct __copy_move<false, false, random_access_iterator_tag>
{
template<typename _II, typename _OI>
static _OI
__copy_m(_II __first, _II __last, _OI __result)
{
typedef typename iterator_traits<_II>::difference_type _Distance;
for(_Distance __n = __last - __first; __n > 0; --__n)
{
*__result = *__first;
++__first;
++__result;
}
return __result;
}
};
#if __cplusplus >= 201103L
template<>
struct __copy_move<true, false, random_access_iterator_tag>
{
template<typename _II, typename _OI>
static _OI
__copy_m(_II __first, _II __last, _OI __result)
{
typedef typename iterator_traits<_II>::difference_type _Distance;
for(_Distance __n = __last - __first; __n > 0; --__n)
{
*__result = std::move(*__first);
++__first;
++__result;
}
return __result;
}
};
#endif
template<bool _IsMove>
struct __copy_move<_IsMove, true, random_access_iterator_tag>
{
template<typename _Tp>
static _Tp*
__copy_m(const _Tp* __first, const _Tp* __last, _Tp* __result)
{
#if __cplusplus >= 201103L
using __assignable = conditional<_IsMove,
is_move_assignable<_Tp>,
is_copy_assignable<_Tp>>;
// trivial types can have deleted assignment
static_assert( __assignable::type::value, "type is not assignable" );
#endif
const ptrdiff_t _Num = __last - __first;
if (_Num)
__builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
return __result + _Num;
}
};
template<bool _IsMove, typename _II, typename _OI>
inline _OI
__copy_move_a(_II __first, _II __last, _OI __result)
{
typedef typename iterator_traits<_II>::value_type _ValueTypeI;
typedef typename iterator_traits<_OI>::value_type _ValueTypeO;
typedef typename iterator_traits<_II>::iterator_category _Category;
const bool __simple = (__is_trivial(_ValueTypeI)
&& __is_pointer<_II>::__value
&& __is_pointer<_OI>::__value
&& __are_same<_ValueTypeI, _ValueTypeO>::__value);
return std::__copy_move<_IsMove, __simple,
_Category>::__copy_m(__first, __last, __result);
}
// Helpers for streambuf iterators (either istream or ostream).
// NB: avoid including <iosfwd>, relatively large.
template<typename _CharT>
struct char_traits;
template<typename _CharT, typename _Traits>
class istreambuf_iterator;
template<typename _CharT, typename _Traits>
class ostreambuf_iterator;
template<bool _IsMove, typename _CharT>
typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
ostreambuf_iterator<_CharT, char_traits<_CharT> > >::__type
__copy_move_a2(_CharT*, _CharT*,
ostreambuf_iterator<_CharT, char_traits<_CharT> >);
template<bool _IsMove, typename _CharT>
typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
ostreambuf_iterator<_CharT, char_traits<_CharT> > >::__type
__copy_move_a2(const _CharT*, const _CharT*,
ostreambuf_iterator<_CharT, char_traits<_CharT> >);
template<bool _IsMove, typename _CharT>
typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
_CharT*>::__type
__copy_move_a2(istreambuf_iterator<_CharT, char_traits<_CharT> >,
istreambuf_iterator<_CharT, char_traits<_CharT> >, _CharT*);
template<bool _IsMove, typename _II, typename _OI>
inline _OI
__copy_move_a2(_II __first, _II __last, _OI __result)
{
return _OI(std::__copy_move_a<_IsMove>(std::__niter_base(__first),
std::__niter_base(__last),
std::__niter_base(__result)));
}
/**
* @brief Copies the range [first,last) into result.
* @ingroup mutating_algorithms
* @param __first An input iterator.
* @param __last An input iterator.
* @param __result An output iterator.
* @return result + (first - last)
*
* This inline function will boil down to a call to @c memmove whenever
* possible. Failing that, if random access iterators are passed, then the
* loop count will be known (and therefore a candidate for compiler
* optimizations such as unrolling). Result may not be contained within
* [first,last); the copy_backward function should be used instead.
*
* Note that the end of the output range is permitted to be contained
* within [first,last).
*/
template<typename _II, typename _OI>
inline _OI
copy(_II __first, _II __last, _OI __result)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_II>)
__glibcxx_function_requires(_OutputIteratorConcept<_OI,
typename iterator_traits<_II>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
return (std::__copy_move_a2<__is_move_iterator<_II>::__value>
(std::__miter_base(__first), std::__miter_base(__last),
__result));
}
#if __cplusplus >= 201103L
/**
* @brief Moves the range [first,last) into result.
* @ingroup mutating_algorithms
* @param __first An input iterator.
* @param __last An input iterator.
* @param __result An output iterator.
* @return result + (first - last)
*
* This inline function will boil down to a call to @c memmove whenever
* possible. Failing that, if random access iterators are passed, then the
* loop count will be known (and therefore a candidate for compiler
* optimizations such as unrolling). Result may not be contained within
* [first,last); the move_backward function should be used instead.
*
* Note that the end of the output range is permitted to be contained
* within [first,last).
*/
template<typename _II, typename _OI>
inline _OI
move(_II __first, _II __last, _OI __result)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_II>)
__glibcxx_function_requires(_OutputIteratorConcept<_OI,
typename iterator_traits<_II>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
return std::__copy_move_a2<true>(std::__miter_base(__first),
std::__miter_base(__last), __result);
}
#define _GLIBCXX_MOVE3(_Tp, _Up, _Vp) std::move(_Tp, _Up, _Vp)
#else
#define _GLIBCXX_MOVE3(_Tp, _Up, _Vp) std::copy(_Tp, _Up, _Vp)
#endif
template<bool, bool, typename>
struct __copy_move_backward
{
template<typename _BI1, typename _BI2>
static _BI2
__copy_move_b(_BI1 __first, _BI1 __last, _BI2 __result)
{
while (__first != __last)
*--__result = *--__last;
return __result;
}
};
#if __cplusplus >= 201103L
template<typename _Category>
struct __copy_move_backward<true, false, _Category>
{
template<typename _BI1, typename _BI2>
static _BI2
__copy_move_b(_BI1 __first, _BI1 __last, _BI2 __result)
{
while (__first != __last)
*--__result = std::move(*--__last);
return __result;
}
};
#endif
template<>
struct __copy_move_backward<false, false, random_access_iterator_tag>
{
template<typename _BI1, typename _BI2>
static _BI2
__copy_move_b(_BI1 __first, _BI1 __last, _BI2 __result)
{
typename iterator_traits<_BI1>::difference_type __n;
for (__n = __last - __first; __n > 0; --__n)
*--__result = *--__last;
return __result;
}
};
#if __cplusplus >= 201103L
template<>
struct __copy_move_backward<true, false, random_access_iterator_tag>
{
template<typename _BI1, typename _BI2>
static _BI2
__copy_move_b(_BI1 __first, _BI1 __last, _BI2 __result)
{
typename iterator_traits<_BI1>::difference_type __n;
for (__n = __last - __first; __n > 0; --__n)
*--__result = std::move(*--__last);
return __result;
}
};
#endif
template<bool _IsMove>
struct __copy_move_backward<_IsMove, true, random_access_iterator_tag>
{
template<typename _Tp>
static _Tp*
__copy_move_b(const _Tp* __first, const _Tp* __last, _Tp* __result)
{
#if __cplusplus >= 201103L
using __assignable = conditional<_IsMove,
is_move_assignable<_Tp>,
is_copy_assignable<_Tp>>;
// trivial types can have deleted assignment
static_assert( __assignable::type::value, "type is not assignable" );
#endif
const ptrdiff_t _Num = __last - __first;
if (_Num)
__builtin_memmove(__result - _Num, __first, sizeof(_Tp) * _Num);
return __result - _Num;
}
};
template<bool _IsMove, typename _BI1, typename _BI2>
inline _BI2
__copy_move_backward_a(_BI1 __first, _BI1 __last, _BI2 __result)
{
typedef typename iterator_traits<_BI1>::value_type _ValueType1;
typedef typename iterator_traits<_BI2>::value_type _ValueType2;
typedef typename iterator_traits<_BI1>::iterator_category _Category;
const bool __simple = (__is_trivial(_ValueType1)
&& __is_pointer<_BI1>::__value
&& __is_pointer<_BI2>::__value
&& __are_same<_ValueType1, _ValueType2>::__value);
return std::__copy_move_backward<_IsMove, __simple,
_Category>::__copy_move_b(__first,
__last,
__result);
}
template<bool _IsMove, typename _BI1, typename _BI2>
inline _BI2
__copy_move_backward_a2(_BI1 __first, _BI1 __last, _BI2 __result)
{
return _BI2(std::__copy_move_backward_a<_IsMove>
(std::__niter_base(__first), std::__niter_base(__last),
std::__niter_base(__result)));
}
/**
* @brief Copies the range [first,last) into result.
* @ingroup mutating_algorithms
* @param __first A bidirectional iterator.
* @param __last A bidirectional iterator.
* @param __result A bidirectional iterator.
* @return result - (first - last)
*
* The function has the same effect as copy, but starts at the end of the
* range and works its way to the start, returning the start of the result.
* This inline function will boil down to a call to @c memmove whenever
* possible. Failing that, if random access iterators are passed, then the
* loop count will be known (and therefore a candidate for compiler
* optimizations such as unrolling).
*
* Result may not be in the range (first,last]. Use copy instead. Note
* that the start of the output range may overlap [first,last).
*/
template<typename _BI1, typename _BI2>
inline _BI2
copy_backward(_BI1 __first, _BI1 __last, _BI2 __result)
{
// concept requirements
__glibcxx_function_requires(_BidirectionalIteratorConcept<_BI1>)
__glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept<_BI2>)
__glibcxx_function_requires(_ConvertibleConcept<
typename iterator_traits<_BI1>::value_type,
typename iterator_traits<_BI2>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
return (std::__copy_move_backward_a2<__is_move_iterator<_BI1>::__value>
(std::__miter_base(__first), std::__miter_base(__last),
__result));
}
#if __cplusplus >= 201103L
/**
* @brief Moves the range [first,last) into result.
* @ingroup mutating_algorithms
* @param __first A bidirectional iterator.
* @param __last A bidirectional iterator.
* @param __result A bidirectional iterator.
* @return result - (first - last)
*
* The function has the same effect as move, but starts at the end of the
* range and works its way to the start, returning the start of the result.
* This inline function will boil down to a call to @c memmove whenever
* possible. Failing that, if random access iterators are passed, then the
* loop count will be known (and therefore a candidate for compiler
* optimizations such as unrolling).
*
* Result may not be in the range (first,last]. Use move instead. Note
* that the start of the output range may overlap [first,last).
*/
template<typename _BI1, typename _BI2>
inline _BI2
move_backward(_BI1 __first, _BI1 __last, _BI2 __result)
{
// concept requirements
__glibcxx_function_requires(_BidirectionalIteratorConcept<_BI1>)
__glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept<_BI2>)
__glibcxx_function_requires(_ConvertibleConcept<
typename iterator_traits<_BI1>::value_type,
typename iterator_traits<_BI2>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
return std::__copy_move_backward_a2<true>(std::__miter_base(__first),
std::__miter_base(__last),
__result);
}
#define _GLIBCXX_MOVE_BACKWARD3(_Tp, _Up, _Vp) std::move_backward(_Tp, _Up, _Vp)
#else
#define _GLIBCXX_MOVE_BACKWARD3(_Tp, _Up, _Vp) std::copy_backward(_Tp, _Up, _Vp)
#endif
template<typename _ForwardIterator, typename _Tp>
inline typename
__gnu_cxx::__enable_if<!__is_scalar<_Tp>::__value, void>::__type
__fill_a(_ForwardIterator __first, _ForwardIterator __last,
const _Tp& __value)
{
for (; __first != __last; ++__first)
*__first = __value;
}
template<typename _ForwardIterator, typename _Tp>
inline typename
__gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, void>::__type
__fill_a(_ForwardIterator __first, _ForwardIterator __last,
const _Tp& __value)
{
const _Tp __tmp = __value;
for (; __first != __last; ++__first)
*__first = __tmp;
}
// Specialization: for char types we can use memset.
template<typename _Tp>
inline typename
__gnu_cxx::__enable_if<__is_byte<_Tp>::__value, void>::__type
__fill_a(_Tp* __first, _Tp* __last, const _Tp& __c)
{
const _Tp __tmp = __c;
if (const size_t __len = __last - __first)
__builtin_memset(__first, static_cast<unsigned char>(__tmp), __len);
}
/**
* @brief Fills the range [first,last) with copies of value.
* @ingroup mutating_algorithms
* @param __first A forward iterator.
* @param __last A forward iterator.
* @param __value A reference-to-const of arbitrary type.
* @return Nothing.
*
* This function fills a range with copies of the same value. For char
* types filling contiguous areas of memory, this becomes an inline call
* to @c memset or @c wmemset.
*/
template<typename _ForwardIterator, typename _Tp>
inline void
fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
{
// concept requirements
__glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
_ForwardIterator>)
__glibcxx_requires_valid_range(__first, __last);
std::__fill_a(std::__niter_base(__first), std::__niter_base(__last),
__value);
}
template<typename _OutputIterator, typename _Size, typename _Tp>
inline typename
__gnu_cxx::__enable_if<!__is_scalar<_Tp>::__value, _OutputIterator>::__type
__fill_n_a(_OutputIterator __first, _Size __n, const _Tp& __value)
{
for (__decltype(__n + 0) __niter = __n;
__niter > 0; --__niter, (void) ++__first)
*__first = __value;
return __first;
}
template<typename _OutputIterator, typename _Size, typename _Tp>
inline typename
__gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, _OutputIterator>::__type
__fill_n_a(_OutputIterator __first, _Size __n, const _Tp& __value)
{
const _Tp __tmp = __value;
for (__decltype(__n + 0) __niter = __n;
__niter > 0; --__niter, (void) ++__first)
*__first = __tmp;
return __first;
}
template<typename _Size, typename _Tp>
inline typename
__gnu_cxx::__enable_if<__is_byte<_Tp>::__value, _Tp*>::__type
__fill_n_a(_Tp* __first, _Size __n, const _Tp& __c)
{
std::__fill_a(__first, __first + __n, __c);
return __first + __n;
}
/**
* @brief Fills the range [first,first+n) with copies of value.
* @ingroup mutating_algorithms
* @param __first An output iterator.
* @param __n The count of copies to perform.
* @param __value A reference-to-const of arbitrary type.
* @return The iterator at first+n.
*
* This function fills a range with copies of the same value. For char
* types filling contiguous areas of memory, this becomes an inline call
* to @c memset or @ wmemset.
*
* _GLIBCXX_RESOLVE_LIB_DEFECTS
* DR 865. More algorithms that throw away information
*/
template<typename _OI, typename _Size, typename _Tp>
inline _OI
fill_n(_OI __first, _Size __n, const _Tp& __value)
{
// concept requirements
__glibcxx_function_requires(_OutputIteratorConcept<_OI, _Tp>)
return _OI(std::__fill_n_a(std::__niter_base(__first), __n, __value));
}
template<bool _BoolType>
struct __equal
{
template<typename _II1, typename _II2>
static bool
equal(_II1 __first1, _II1 __last1, _II2 __first2)
{
for (; __first1 != __last1; ++__first1, (void) ++__first2)
if (!(*__first1 == *__first2))
return false;
return true;
}
};
template<>
struct __equal<true>
{
template<typename _Tp>
static bool
equal(const _Tp* __first1, const _Tp* __last1, const _Tp* __first2)
{
if (const size_t __len = (__last1 - __first1))
return !__builtin_memcmp(__first1, __first2, sizeof(_Tp) * __len);
return true;
}
};
template<typename _II1, typename _II2>
inline bool
__equal_aux(_II1 __first1, _II1 __last1, _II2 __first2)
{
typedef typename iterator_traits<_II1>::value_type _ValueType1;
typedef typename iterator_traits<_II2>::value_type _ValueType2;
const bool __simple = ((__is_integer<_ValueType1>::__value
|| __is_pointer<_ValueType1>::__value)
&& __is_pointer<_II1>::__value
&& __is_pointer<_II2>::__value
&& __are_same<_ValueType1, _ValueType2>::__value);
return std::__equal<__simple>::equal(__first1, __last1, __first2);
}
template<typename, typename>
struct __lc_rai
{
template<typename _II1, typename _II2>
static _II1
__newlast1(_II1, _II1 __last1, _II2, _II2)
{ return __last1; }
template<typename _II>
static bool
__cnd2(_II __first, _II __last)
{ return __first != __last; }
};
template<>
struct __lc_rai<random_access_iterator_tag, random_access_iterator_tag>
{
template<typename _RAI1, typename _RAI2>
static _RAI1
__newlast1(_RAI1 __first1, _RAI1 __last1,
_RAI2 __first2, _RAI2 __last2)
{
const typename iterator_traits<_RAI1>::difference_type
__diff1 = __last1 - __first1;
const typename iterator_traits<_RAI2>::difference_type
__diff2 = __last2 - __first2;
return __diff2 < __diff1 ? __first1 + __diff2 : __last1;
}
template<typename _RAI>
static bool
__cnd2(_RAI, _RAI)
{ return true; }
};
template<typename _II1, typename _II2, typename _Compare>
bool
__lexicographical_compare_impl(_II1 __first1, _II1 __last1,
_II2 __first2, _II2 __last2,
_Compare __comp)
{
typedef typename iterator_traits<_II1>::iterator_category _Category1;
typedef typename iterator_traits<_II2>::iterator_category _Category2;
typedef std::__lc_rai<_Category1, _Category2> __rai_type;
__last1 = __rai_type::__newlast1(__first1, __last1, __first2, __last2);
for (; __first1 != __last1 && __rai_type::__cnd2(__first2, __last2);
++__first1, (void)++__first2)
{
if (__comp(__first1, __first2))
return true;
if (__comp(__first2, __first1))
return false;
}
return __first1 == __last1 && __first2 != __last2;
}
template<bool _BoolType>
struct __lexicographical_compare
{
template<typename _II1, typename _II2>
static bool __lc(_II1, _II1, _II2, _II2);
};
template<bool _BoolType>
template<typename _II1, typename _II2>
bool
__lexicographical_compare<_BoolType>::
__lc(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2)
{
return std::__lexicographical_compare_impl(__first1, __last1,
__first2, __last2,
__gnu_cxx::__ops::__iter_less_iter());
}
template<>
struct __lexicographical_compare<true>
{
template<typename _Tp, typename _Up>
static bool
__lc(const _Tp* __first1, const _Tp* __last1,
const _Up* __first2, const _Up* __last2)
{
const size_t __len1 = __last1 - __first1;
const size_t __len2 = __last2 - __first2;
if (const size_t __len = std::min(__len1, __len2))
if (int __result = __builtin_memcmp(__first1, __first2, __len))
return __result < 0;
return __len1 < __len2;
}
};
template<typename _II1, typename _II2>
inline bool
__lexicographical_compare_aux(_II1 __first1, _II1 __last1,
_II2 __first2, _II2 __last2)
{
typedef typename iterator_traits<_II1>::value_type _ValueType1;
typedef typename iterator_traits<_II2>::value_type _ValueType2;
const bool __simple =
(__is_byte<_ValueType1>::__value && __is_byte<_ValueType2>::__value
&& !__gnu_cxx::__numeric_traits<_ValueType1>::__is_signed
&& !__gnu_cxx::__numeric_traits<_ValueType2>::__is_signed
&& __is_pointer<_II1>::__value
&& __is_pointer<_II2>::__value);
return std::__lexicographical_compare<__simple>::__lc(__first1, __last1,
__first2, __last2);
}
template<typename _ForwardIterator, typename _Tp, typename _Compare>
_ForwardIterator
__lower_bound(_ForwardIterator __first, _ForwardIterator __last,
const _Tp& __val, _Compare __comp)
{
typedef typename iterator_traits<_ForwardIterator>::difference_type
_DistanceType;
_DistanceType __len = std::distance(__first, __last);
while (__len > 0)
{
_DistanceType __half = __len >> 1;
_ForwardIterator __middle = __first;
std::advance(__middle, __half);
if (__comp(__middle, __val))
{
__first = __middle;
++__first;
__len = __len - __half - 1;
}
else
__len = __half;
}
return __first;
}
/**
* @brief Finds the first position in which @a val could be inserted
* without changing the ordering.
* @param __first An iterator.
* @param __last Another iterator.
* @param __val The search term.
* @return An iterator pointing to the first element <em>not less
* than</em> @a val, or end() if every element is less than
* @a val.
* @ingroup binary_search_algorithms
*/
template<typename _ForwardIterator, typename _Tp>
inline _ForwardIterator
lower_bound(_ForwardIterator __first, _ForwardIterator __last,
const _Tp& __val)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_LessThanOpConcept<
typename iterator_traits<_ForwardIterator>::value_type, _Tp>)
__glibcxx_requires_partitioned_lower(__first, __last, __val);
return std::__lower_bound(__first, __last, __val,
__gnu_cxx::__ops::__iter_less_val());
}
/// This is a helper function for the sort routines and for random.tcc.
// Precondition: __n > 0.
inline _GLIBCXX_CONSTEXPR int
__lg(int __n)
{ return (int)sizeof(int) * __CHAR_BIT__ - 1 - __builtin_clz(__n); }
inline _GLIBCXX_CONSTEXPR unsigned
__lg(unsigned __n)
{ return (int)sizeof(int) * __CHAR_BIT__ - 1 - __builtin_clz(__n); }
inline _GLIBCXX_CONSTEXPR long
__lg(long __n)
{ return (int)sizeof(long) * __CHAR_BIT__ - 1 - __builtin_clzl(__n); }
inline _GLIBCXX_CONSTEXPR unsigned long
__lg(unsigned long __n)
{ return (int)sizeof(long) * __CHAR_BIT__ - 1 - __builtin_clzl(__n); }
inline _GLIBCXX_CONSTEXPR long long
__lg(long long __n)
{ return (int)sizeof(long long) * __CHAR_BIT__ - 1 - __builtin_clzll(__n); }
inline _GLIBCXX_CONSTEXPR unsigned long long
__lg(unsigned long long __n)
{ return (int)sizeof(long long) * __CHAR_BIT__ - 1 - __builtin_clzll(__n); }
_GLIBCXX_BEGIN_NAMESPACE_ALGO
/**
* @brief Tests a range for element-wise equality.
* @ingroup non_mutating_algorithms
* @param __first1 An input iterator.
* @param __last1 An input iterator.
* @param __first2 An input iterator.
* @return A boolean true or false.
*
* This compares the elements of two ranges using @c == and returns true or
* false depending on whether all of the corresponding elements of the
* ranges are equal.
*/
template<typename _II1, typename _II2>
inline bool
equal(_II1 __first1, _II1 __last1, _II2 __first2)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_II1>)
__glibcxx_function_requires(_InputIteratorConcept<_II2>)
__glibcxx_function_requires(_EqualOpConcept<
typename iterator_traits<_II1>::value_type,
typename iterator_traits<_II2>::value_type>)
__glibcxx_requires_valid_range(__first1, __last1);
return std::__equal_aux(std::__niter_base(__first1),
std::__niter_base(__last1),
std::__niter_base(__first2));
}
/**
* @brief Tests a range for element-wise equality.
* @ingroup non_mutating_algorithms
* @param __first1 An input iterator.
* @param __last1 An input iterator.
* @param __first2 An input iterator.
* @param __binary_pred A binary predicate @link functors
* functor@endlink.
* @return A boolean true or false.
*
* This compares the elements of two ranges using the binary_pred
* parameter, and returns true or
* false depending on whether all of the corresponding elements of the
* ranges are equal.
*/
template<typename _IIter1, typename _IIter2, typename _BinaryPredicate>
inline bool
equal(_IIter1 __first1, _IIter1 __last1,
_IIter2 __first2, _BinaryPredicate __binary_pred)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_IIter1>)
__glibcxx_function_requires(_InputIteratorConcept<_IIter2>)
__glibcxx_requires_valid_range(__first1, __last1);
for (; __first1 != __last1; ++__first1, (void)++__first2)
if (!bool(__binary_pred(*__first1, *__first2)))
return false;
return true;
}
#if __cplusplus >= 201103L
// 4-iterator version of std::equal<It1, It2> for use in C++11.
template<typename _II1, typename _II2>
inline bool
__equal4(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2)
{
using _RATag = random_access_iterator_tag;
using _Cat1 = typename iterator_traits<_II1>::iterator_category;
using _Cat2 = typename iterator_traits<_II2>::iterator_category;
using _RAIters = __and_<is_same<_Cat1, _RATag>, is_same<_Cat2, _RATag>>;
if (_RAIters())
{
auto __d1 = std::distance(__first1, __last1);
auto __d2 = std::distance(__first2, __last2);
if (__d1 != __d2)
return false;
return _GLIBCXX_STD_A::equal(__first1, __last1, __first2);
}
for (; __first1 != __last1 && __first2 != __last2;
++__first1, (void)++__first2)
if (!(*__first1 == *__first2))
return false;
return __first1 == __last1 && __first2 == __last2;
}
// 4-iterator version of std::equal<It1, It2, BinaryPred> for use in C++11.
template<typename _II1, typename _II2, typename _BinaryPredicate>
inline bool
__equal4(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2,
_BinaryPredicate __binary_pred)
{
using _RATag = random_access_iterator_tag;
using _Cat1 = typename iterator_traits<_II1>::iterator_category;
using _Cat2 = typename iterator_traits<_II2>::iterator_category;
using _RAIters = __and_<is_same<_Cat1, _RATag>, is_same<_Cat2, _RATag>>;
if (_RAIters())
{
auto __d1 = std::distance(__first1, __last1);
auto __d2 = std::distance(__first2, __last2);
if (__d1 != __d2)
return false;
return _GLIBCXX_STD_A::equal(__first1, __last1, __first2,
__binary_pred);
}
for (; __first1 != __last1 && __first2 != __last2;
++__first1, (void)++__first2)
if (!bool(__binary_pred(*__first1, *__first2)))
return false;
return __first1 == __last1 && __first2 == __last2;
}
#endif // C++11
#if __cplusplus > 201103L
#define __cpp_lib_robust_nonmodifying_seq_ops 201304
/**
* @brief Tests a range for element-wise equality.
* @ingroup non_mutating_algorithms
* @param __first1 An input iterator.
* @param __last1 An input iterator.
* @param __first2 An input iterator.
* @param __last2 An input iterator.
* @return A boolean true or false.
*
* This compares the elements of two ranges using @c == and returns true or
* false depending on whether all of the corresponding elements of the
* ranges are equal.
*/
template<typename _II1, typename _II2>
inline bool
equal(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_II1>)
__glibcxx_function_requires(_InputIteratorConcept<_II2>)
__glibcxx_function_requires(_EqualOpConcept<
typename iterator_traits<_II1>::value_type,
typename iterator_traits<_II2>::value_type>)
__glibcxx_requires_valid_range(__first1, __last1);
__glibcxx_requires_valid_range(__first2, __last2);
return _GLIBCXX_STD_A::__equal4(__first1, __last1, __first2, __last2);
}
/**
* @brief Tests a range for element-wise equality.
* @ingroup non_mutating_algorithms
* @param __first1 An input iterator.
* @param __last1 An input iterator.
* @param __first2 An input iterator.
* @param __last2 An input iterator.
* @param __binary_pred A binary predicate @link functors
* functor@endlink.
* @return A boolean true or false.
*
* This compares the elements of two ranges using the binary_pred
* parameter, and returns true or
* false depending on whether all of the corresponding elements of the
* ranges are equal.
*/
template<typename _IIter1, typename _IIter2, typename _BinaryPredicate>
inline bool
equal(_IIter1 __first1, _IIter1 __last1,
_IIter2 __first2, _IIter2 __last2, _BinaryPredicate __binary_pred)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_IIter1>)
__glibcxx_function_requires(_InputIteratorConcept<_IIter2>)
__glibcxx_requires_valid_range(__first1, __last1);
__glibcxx_requires_valid_range(__first2, __last2);
return _GLIBCXX_STD_A::__equal4(__first1, __last1, __first2, __last2,
__binary_pred);
}
#endif // C++14
/**
* @brief Performs @b dictionary comparison on ranges.
* @ingroup sorting_algorithms
* @param __first1 An input iterator.
* @param __last1 An input iterator.
* @param __first2 An input iterator.
* @param __last2 An input iterator.
* @return A boolean true or false.
*
* <em>Returns true if the sequence of elements defined by the range
* [first1,last1) is lexicographically less than the sequence of elements
* defined by the range [first2,last2). Returns false otherwise.</em>
* (Quoted from [25.3.8]/1.) If the iterators are all character pointers,
* then this is an inline call to @c memcmp.
*/
template<typename _II1, typename _II2>
inline bool
lexicographical_compare(_II1 __first1, _II1 __last1,
_II2 __first2, _II2 __last2)
{
#ifdef _GLIBCXX_CONCEPT_CHECKS
// concept requirements
typedef typename iterator_traits<_II1>::value_type _ValueType1;
typedef typename iterator_traits<_II2>::value_type _ValueType2;
#endif
__glibcxx_function_requires(_InputIteratorConcept<_II1>)
__glibcxx_function_requires(_InputIteratorConcept<_II2>)
__glibcxx_function_requires(_LessThanOpConcept<_ValueType1, _ValueType2>)
__glibcxx_function_requires(_LessThanOpConcept<_ValueType2, _ValueType1>)
__glibcxx_requires_valid_range(__first1, __last1);
__glibcxx_requires_valid_range(__first2, __last2);
return std::__lexicographical_compare_aux(std::__niter_base(__first1),
std::__niter_base(__last1),
std::__niter_base(__first2),
std::__niter_base(__last2));
}
/**
* @brief Performs @b dictionary comparison on ranges.
* @ingroup sorting_algorithms
* @param __first1 An input iterator.
* @param __last1 An input iterator.
* @param __first2 An input iterator.
* @param __last2 An input iterator.
* @param __comp A @link comparison_functors comparison functor@endlink.
* @return A boolean true or false.
*
* The same as the four-parameter @c lexicographical_compare, but uses the
* comp parameter instead of @c <.
*/
template<typename _II1, typename _II2, typename _Compare>
inline bool
lexicographical_compare(_II1 __first1, _II1 __last1,
_II2 __first2, _II2 __last2, _Compare __comp)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_II1>)
__glibcxx_function_requires(_InputIteratorConcept<_II2>)
__glibcxx_requires_valid_range(__first1, __last1);
__glibcxx_requires_valid_range(__first2, __last2);
return std::__lexicographical_compare_impl
(__first1, __last1, __first2, __last2,
__gnu_cxx::__ops::__iter_comp_iter(__comp));
}
template<typename _InputIterator1, typename _InputIterator2,
typename _BinaryPredicate>
pair<_InputIterator1, _InputIterator2>
__mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _BinaryPredicate __binary_pred)
{
while (__first1 != __last1 && __binary_pred(__first1, __first2))
{
++__first1;
++__first2;
}
return pair<_InputIterator1, _InputIterator2>(__first1, __first2);
}
/**
* @brief Finds the places in ranges which don't match.
* @ingroup non_mutating_algorithms
* @param __first1 An input iterator.
* @param __last1 An input iterator.
* @param __first2 An input iterator.
* @return A pair of iterators pointing to the first mismatch.
*
* This compares the elements of two ranges using @c == and returns a pair
* of iterators. The first iterator points into the first range, the
* second iterator points into the second range, and the elements pointed
* to by the iterators are not equal.
*/
template<typename _InputIterator1, typename _InputIterator2>
inline pair<_InputIterator1, _InputIterator2>
mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
__glibcxx_function_requires(_EqualOpConcept<
typename iterator_traits<_InputIterator1>::value_type,
typename iterator_traits<_InputIterator2>::value_type>)
__glibcxx_requires_valid_range(__first1, __last1);
return _GLIBCXX_STD_A::__mismatch(__first1, __last1, __first2,
__gnu_cxx::__ops::__iter_equal_to_iter());
}
/**
* @brief Finds the places in ranges which don't match.
* @ingroup non_mutating_algorithms
* @param __first1 An input iterator.
* @param __last1 An input iterator.
* @param __first2 An input iterator.
* @param __binary_pred A binary predicate @link functors
* functor@endlink.
* @return A pair of iterators pointing to the first mismatch.
*
* This compares the elements of two ranges using the binary_pred
* parameter, and returns a pair
* of iterators. The first iterator points into the first range, the
* second iterator points into the second range, and the elements pointed
* to by the iterators are not equal.
*/
template<typename _InputIterator1, typename _InputIterator2,
typename _BinaryPredicate>
inline pair<_InputIterator1, _InputIterator2>
mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _BinaryPredicate __binary_pred)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
__glibcxx_requires_valid_range(__first1, __last1);
return _GLIBCXX_STD_A::__mismatch(__first1, __last1, __first2,
__gnu_cxx::__ops::__iter_comp_iter(__binary_pred));
}
#if __cplusplus > 201103L
template<typename _InputIterator1, typename _InputIterator2,
typename _BinaryPredicate>
pair<_InputIterator1, _InputIterator2>
__mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2,
_BinaryPredicate __binary_pred)
{
while (__first1 != __last1 && __first2 != __last2
&& __binary_pred(__first1, __first2))
{
++__first1;
++__first2;
}
return pair<_InputIterator1, _InputIterator2>(__first1, __first2);
}
/**
* @brief Finds the places in ranges which don't match.
* @ingroup non_mutating_algorithms
* @param __first1 An input iterator.
* @param __last1 An input iterator.
* @param __first2 An input iterator.
* @param __last2 An input iterator.
* @return A pair of iterators pointing to the first mismatch.
*
* This compares the elements of two ranges using @c == and returns a pair
* of iterators. The first iterator points into the first range, the
* second iterator points into the second range, and the elements pointed
* to by the iterators are not equal.
*/
template<typename _InputIterator1, typename _InputIterator2>
inline pair<_InputIterator1, _InputIterator2>
mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
__glibcxx_function_requires(_EqualOpConcept<
typename iterator_traits<_InputIterator1>::value_type,
typename iterator_traits<_InputIterator2>::value_type>)
__glibcxx_requires_valid_range(__first1, __last1);
__glibcxx_requires_valid_range(__first2, __last2);
return _GLIBCXX_STD_A::__mismatch(__first1, __last1, __first2, __last2,
__gnu_cxx::__ops::__iter_equal_to_iter());
}
/**
* @brief Finds the places in ranges which don't match.
* @ingroup non_mutating_algorithms
* @param __first1 An input iterator.
* @param __last1 An input iterator.
* @param __first2 An input iterator.
* @param __last2 An input iterator.
* @param __binary_pred A binary predicate @link functors
* functor@endlink.
* @return A pair of iterators pointing to the first mismatch.
*
* This compares the elements of two ranges using the binary_pred
* parameter, and returns a pair
* of iterators. The first iterator points into the first range, the
* second iterator points into the second range, and the elements pointed
* to by the iterators are not equal.
*/
template<typename _InputIterator1, typename _InputIterator2,
typename _BinaryPredicate>
inline pair<_InputIterator1, _InputIterator2>
mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2,
_BinaryPredicate __binary_pred)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
__glibcxx_requires_valid_range(__first1, __last1);
__glibcxx_requires_valid_range(__first2, __last2);
return _GLIBCXX_STD_A::__mismatch(__first1, __last1, __first2, __last2,
__gnu_cxx::__ops::__iter_comp_iter(__binary_pred));
}
#endif
_GLIBCXX_END_NAMESPACE_ALGO
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
// NB: This file is included within many other C++ includes, as a way
// of getting the base algorithms. So, make sure that parallel bits
// come in too if requested.
#ifdef _GLIBCXX_PARALLEL
# include <parallel/algobase.h>
#endif
#endif
c++/8/bits/valarray_array.h 0000644 00000052457 15201526705 0011434 0 ustar 00 // The template and inlines for the -*- C++ -*- internal _Array helper class.
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/valarray_array.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{valarray}
*/
// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
#ifndef _VALARRAY_ARRAY_H
#define _VALARRAY_ARRAY_H 1
#pragma GCC system_header
#include <bits/c++config.h>
#include <bits/cpp_type_traits.h>
#include <cstdlib>
#include <new>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
//
// Helper functions on raw pointers
//
// We get memory by the old fashion way
inline void*
__valarray_get_memory(size_t __n)
{ return operator new(__n); }
template<typename _Tp>
inline _Tp*__restrict__
__valarray_get_storage(size_t __n)
{
return static_cast<_Tp*__restrict__>
(std::__valarray_get_memory(__n * sizeof(_Tp)));
}
// Return memory to the system
inline void
__valarray_release_memory(void* __p)
{ operator delete(__p); }
// Turn a raw-memory into an array of _Tp filled with _Tp()
// This is required in 'valarray<T> v(n);'
template<typename _Tp, bool>
struct _Array_default_ctor
{
// Please note that this isn't exception safe. But
// valarrays aren't required to be exception safe.
inline static void
_S_do_it(_Tp* __b, _Tp* __e)
{
while (__b != __e)
new(__b++) _Tp();
}
};
template<typename _Tp>
struct _Array_default_ctor<_Tp, true>
{
// For fundamental types, it suffices to say 'memset()'
inline static void
_S_do_it(_Tp* __b, _Tp* __e)
{ __builtin_memset(__b, 0, (__e - __b) * sizeof(_Tp)); }
};
template<typename _Tp>
inline void
__valarray_default_construct(_Tp* __b, _Tp* __e)
{
_Array_default_ctor<_Tp, __is_scalar<_Tp>::__value>::_S_do_it(__b, __e);
}
// Turn a raw-memory into an array of _Tp filled with __t
// This is the required in valarray<T> v(n, t). Also
// used in valarray<>::resize().
template<typename _Tp, bool>
struct _Array_init_ctor
{
// Please note that this isn't exception safe. But
// valarrays aren't required to be exception safe.
inline static void
_S_do_it(_Tp* __b, _Tp* __e, const _Tp __t)
{
while (__b != __e)
new(__b++) _Tp(__t);
}
};
template<typename _Tp>
struct _Array_init_ctor<_Tp, true>
{
inline static void
_S_do_it(_Tp* __b, _Tp* __e, const _Tp __t)
{
while (__b != __e)
*__b++ = __t;
}
};
template<typename _Tp>
inline void
__valarray_fill_construct(_Tp* __b, _Tp* __e, const _Tp __t)
{
_Array_init_ctor<_Tp, __is_trivial(_Tp)>::_S_do_it(__b, __e, __t);
}
//
// copy-construct raw array [__o, *) from plain array [__b, __e)
// We can't just say 'memcpy()'
//
template<typename _Tp, bool>
struct _Array_copy_ctor
{
// Please note that this isn't exception safe. But
// valarrays aren't required to be exception safe.
inline static void
_S_do_it(const _Tp* __b, const _Tp* __e, _Tp* __restrict__ __o)
{
while (__b != __e)
new(__o++) _Tp(*__b++);
}
};
template<typename _Tp>
struct _Array_copy_ctor<_Tp, true>
{
inline static void
_S_do_it(const _Tp* __b, const _Tp* __e, _Tp* __restrict__ __o)
{
if (__b)
__builtin_memcpy(__o, __b, (__e - __b) * sizeof(_Tp));
}
};
template<typename _Tp>
inline void
__valarray_copy_construct(const _Tp* __b, const _Tp* __e,
_Tp* __restrict__ __o)
{
_Array_copy_ctor<_Tp, __is_trivial(_Tp)>::_S_do_it(__b, __e, __o);
}
// copy-construct raw array [__o, *) from strided array __a[<__n : __s>]
template<typename _Tp>
inline void
__valarray_copy_construct (const _Tp* __restrict__ __a, size_t __n,
size_t __s, _Tp* __restrict__ __o)
{
if (__is_trivial(_Tp))
while (__n--)
{
*__o++ = *__a;
__a += __s;
}
else
while (__n--)
{
new(__o++) _Tp(*__a);
__a += __s;
}
}
// copy-construct raw array [__o, *) from indexed array __a[__i[<__n>]]
template<typename _Tp>
inline void
__valarray_copy_construct (const _Tp* __restrict__ __a,
const size_t* __restrict__ __i,
_Tp* __restrict__ __o, size_t __n)
{
if (__is_trivial(_Tp))
while (__n--)
*__o++ = __a[*__i++];
else
while (__n--)
new (__o++) _Tp(__a[*__i++]);
}
// Do the necessary cleanup when we're done with arrays.
template<typename _Tp>
inline void
__valarray_destroy_elements(_Tp* __b, _Tp* __e)
{
if (!__is_trivial(_Tp))
while (__b != __e)
{
__b->~_Tp();
++__b;
}
}
// Fill a plain array __a[<__n>] with __t
template<typename _Tp>
inline void
__valarray_fill(_Tp* __restrict__ __a, size_t __n, const _Tp& __t)
{
while (__n--)
*__a++ = __t;
}
// fill strided array __a[<__n-1 : __s>] with __t
template<typename _Tp>
inline void
__valarray_fill(_Tp* __restrict__ __a, size_t __n,
size_t __s, const _Tp& __t)
{
for (size_t __i = 0; __i < __n; ++__i, __a += __s)
*__a = __t;
}
// fill indirect array __a[__i[<__n>]] with __i
template<typename _Tp>
inline void
__valarray_fill(_Tp* __restrict__ __a, const size_t* __restrict__ __i,
size_t __n, const _Tp& __t)
{
for (size_t __j = 0; __j < __n; ++__j, ++__i)
__a[*__i] = __t;
}
// copy plain array __a[<__n>] in __b[<__n>]
// For non-fundamental types, it is wrong to say 'memcpy()'
template<typename _Tp, bool>
struct _Array_copier
{
inline static void
_S_do_it(const _Tp* __restrict__ __a, size_t __n, _Tp* __restrict__ __b)
{
while(__n--)
*__b++ = *__a++;
}
};
template<typename _Tp>
struct _Array_copier<_Tp, true>
{
inline static void
_S_do_it(const _Tp* __restrict__ __a, size_t __n, _Tp* __restrict__ __b)
{
if (__n != 0)
__builtin_memcpy(__b, __a, __n * sizeof (_Tp));
}
};
// Copy a plain array __a[<__n>] into a play array __b[<>]
template<typename _Tp>
inline void
__valarray_copy(const _Tp* __restrict__ __a, size_t __n,
_Tp* __restrict__ __b)
{
_Array_copier<_Tp, __is_trivial(_Tp)>::_S_do_it(__a, __n, __b);
}
// Copy strided array __a[<__n : __s>] in plain __b[<__n>]
template<typename _Tp>
inline void
__valarray_copy(const _Tp* __restrict__ __a, size_t __n, size_t __s,
_Tp* __restrict__ __b)
{
for (size_t __i = 0; __i < __n; ++__i, ++__b, __a += __s)
*__b = *__a;
}
// Copy a plain array __a[<__n>] into a strided array __b[<__n : __s>]
template<typename _Tp>
inline void
__valarray_copy(const _Tp* __restrict__ __a, _Tp* __restrict__ __b,
size_t __n, size_t __s)
{
for (size_t __i = 0; __i < __n; ++__i, ++__a, __b += __s)
*__b = *__a;
}
// Copy strided array __src[<__n : __s1>] into another
// strided array __dst[< : __s2>]. Their sizes must match.
template<typename _Tp>
inline void
__valarray_copy(const _Tp* __restrict__ __src, size_t __n, size_t __s1,
_Tp* __restrict__ __dst, size_t __s2)
{
for (size_t __i = 0; __i < __n; ++__i)
__dst[__i * __s2] = __src[__i * __s1];
}
// Copy an indexed array __a[__i[<__n>]] in plain array __b[<__n>]
template<typename _Tp>
inline void
__valarray_copy(const _Tp* __restrict__ __a,
const size_t* __restrict__ __i,
_Tp* __restrict__ __b, size_t __n)
{
for (size_t __j = 0; __j < __n; ++__j, ++__b, ++__i)
*__b = __a[*__i];
}
// Copy a plain array __a[<__n>] in an indexed array __b[__i[<__n>]]
template<typename _Tp>
inline void
__valarray_copy(const _Tp* __restrict__ __a, size_t __n,
_Tp* __restrict__ __b, const size_t* __restrict__ __i)
{
for (size_t __j = 0; __j < __n; ++__j, ++__a, ++__i)
__b[*__i] = *__a;
}
// Copy the __n first elements of an indexed array __src[<__i>] into
// another indexed array __dst[<__j>].
template<typename _Tp>
inline void
__valarray_copy(const _Tp* __restrict__ __src, size_t __n,
const size_t* __restrict__ __i,
_Tp* __restrict__ __dst, const size_t* __restrict__ __j)
{
for (size_t __k = 0; __k < __n; ++__k)
__dst[*__j++] = __src[*__i++];
}
//
// Compute the sum of elements in range [__f, __l) which must not be empty.
// This is a naive algorithm. It suffers from cancelling.
// In the future try to specialize for _Tp = float, double, long double
// using a more accurate algorithm.
//
template<typename _Tp>
inline _Tp
__valarray_sum(const _Tp* __f, const _Tp* __l)
{
_Tp __r = *__f++;
while (__f != __l)
__r += *__f++;
return __r;
}
// Compute the product of all elements in range [__f, __l)
template<typename _Tp>
inline _Tp
__valarray_product(const _Tp* __f, const _Tp* __l)
{
_Tp __r = _Tp(1);
while (__f != __l)
__r = __r * *__f++;
return __r;
}
// Compute the min/max of an array-expression
template<typename _Ta>
inline typename _Ta::value_type
__valarray_min(const _Ta& __a)
{
size_t __s = __a.size();
typedef typename _Ta::value_type _Value_type;
_Value_type __r = __s == 0 ? _Value_type() : __a[0];
for (size_t __i = 1; __i < __s; ++__i)
{
_Value_type __t = __a[__i];
if (__t < __r)
__r = __t;
}
return __r;
}
template<typename _Ta>
inline typename _Ta::value_type
__valarray_max(const _Ta& __a)
{
size_t __s = __a.size();
typedef typename _Ta::value_type _Value_type;
_Value_type __r = __s == 0 ? _Value_type() : __a[0];
for (size_t __i = 1; __i < __s; ++__i)
{
_Value_type __t = __a[__i];
if (__t > __r)
__r = __t;
}
return __r;
}
//
// Helper class _Array, first layer of valarray abstraction.
// All operations on valarray should be forwarded to this class
// whenever possible. -- gdr
//
template<typename _Tp>
struct _Array
{
explicit _Array(size_t);
explicit _Array(_Tp* const __restrict__);
explicit _Array(const valarray<_Tp>&);
_Array(const _Tp* __restrict__, size_t);
_Tp* begin() const;
_Tp* const __restrict__ _M_data;
};
// Copy-construct plain array __b[<__n>] from indexed array __a[__i[<__n>]]
template<typename _Tp>
inline void
__valarray_copy_construct(_Array<_Tp> __a, _Array<size_t> __i,
_Array<_Tp> __b, size_t __n)
{ std::__valarray_copy_construct(__a._M_data, __i._M_data,
__b._M_data, __n); }
// Copy-construct plain array __b[<__n>] from strided array __a[<__n : __s>]
template<typename _Tp>
inline void
__valarray_copy_construct(_Array<_Tp> __a, size_t __n, size_t __s,
_Array<_Tp> __b)
{ std::__valarray_copy_construct(__a._M_data, __n, __s, __b._M_data); }
template<typename _Tp>
inline void
__valarray_fill (_Array<_Tp> __a, size_t __n, const _Tp& __t)
{ std::__valarray_fill(__a._M_data, __n, __t); }
template<typename _Tp>
inline void
__valarray_fill(_Array<_Tp> __a, size_t __n, size_t __s, const _Tp& __t)
{ std::__valarray_fill(__a._M_data, __n, __s, __t); }
template<typename _Tp>
inline void
__valarray_fill(_Array<_Tp> __a, _Array<size_t> __i,
size_t __n, const _Tp& __t)
{ std::__valarray_fill(__a._M_data, __i._M_data, __n, __t); }
// Copy a plain array __a[<__n>] into a play array __b[<>]
template<typename _Tp>
inline void
__valarray_copy(_Array<_Tp> __a, size_t __n, _Array<_Tp> __b)
{ std::__valarray_copy(__a._M_data, __n, __b._M_data); }
// Copy strided array __a[<__n : __s>] in plain __b[<__n>]
template<typename _Tp>
inline void
__valarray_copy(_Array<_Tp> __a, size_t __n, size_t __s, _Array<_Tp> __b)
{ std::__valarray_copy(__a._M_data, __n, __s, __b._M_data); }
// Copy a plain array __a[<__n>] into a strided array __b[<__n : __s>]
template<typename _Tp>
inline void
__valarray_copy(_Array<_Tp> __a, _Array<_Tp> __b, size_t __n, size_t __s)
{ __valarray_copy(__a._M_data, __b._M_data, __n, __s); }
// Copy strided array __src[<__n : __s1>] into another
// strided array __dst[< : __s2>]. Their sizes must match.
template<typename _Tp>
inline void
__valarray_copy(_Array<_Tp> __a, size_t __n, size_t __s1,
_Array<_Tp> __b, size_t __s2)
{ std::__valarray_copy(__a._M_data, __n, __s1, __b._M_data, __s2); }
// Copy an indexed array __a[__i[<__n>]] in plain array __b[<__n>]
template<typename _Tp>
inline void
__valarray_copy(_Array<_Tp> __a, _Array<size_t> __i,
_Array<_Tp> __b, size_t __n)
{ std::__valarray_copy(__a._M_data, __i._M_data, __b._M_data, __n); }
// Copy a plain array __a[<__n>] in an indexed array __b[__i[<__n>]]
template<typename _Tp>
inline void
__valarray_copy(_Array<_Tp> __a, size_t __n, _Array<_Tp> __b,
_Array<size_t> __i)
{ std::__valarray_copy(__a._M_data, __n, __b._M_data, __i._M_data); }
// Copy the __n first elements of an indexed array __src[<__i>] into
// another indexed array __dst[<__j>].
template<typename _Tp>
inline void
__valarray_copy(_Array<_Tp> __src, size_t __n, _Array<size_t> __i,
_Array<_Tp> __dst, _Array<size_t> __j)
{
std::__valarray_copy(__src._M_data, __n, __i._M_data,
__dst._M_data, __j._M_data);
}
template<typename _Tp>
inline
_Array<_Tp>::_Array(size_t __n)
: _M_data(__valarray_get_storage<_Tp>(__n))
{ std::__valarray_default_construct(_M_data, _M_data + __n); }
template<typename _Tp>
inline
_Array<_Tp>::_Array(_Tp* const __restrict__ __p)
: _M_data (__p) {}
template<typename _Tp>
inline
_Array<_Tp>::_Array(const valarray<_Tp>& __v)
: _M_data (__v._M_data) {}
template<typename _Tp>
inline
_Array<_Tp>::_Array(const _Tp* __restrict__ __b, size_t __s)
: _M_data(__valarray_get_storage<_Tp>(__s))
{ std::__valarray_copy_construct(__b, __s, _M_data); }
template<typename _Tp>
inline _Tp*
_Array<_Tp>::begin () const
{ return _M_data; }
#define _DEFINE_ARRAY_FUNCTION(_Op, _Name) \
template<typename _Tp> \
inline void \
_Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, const _Tp& __t) \
{ \
for (_Tp* __p = __a._M_data; __p < __a._M_data + __n; ++__p) \
*__p _Op##= __t; \
} \
\
template<typename _Tp> \
inline void \
_Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, _Array<_Tp> __b) \
{ \
_Tp* __p = __a._M_data; \
for (_Tp* __q = __b._M_data; __q < __b._M_data + __n; ++__p, ++__q) \
*__p _Op##= *__q; \
} \
\
template<typename _Tp, class _Dom> \
void \
_Array_augmented_##_Name(_Array<_Tp> __a, \
const _Expr<_Dom, _Tp>& __e, size_t __n) \
{ \
_Tp* __p(__a._M_data); \
for (size_t __i = 0; __i < __n; ++__i, ++__p) \
*__p _Op##= __e[__i]; \
} \
\
template<typename _Tp> \
inline void \
_Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, size_t __s, \
_Array<_Tp> __b) \
{ \
_Tp* __q(__b._M_data); \
for (_Tp* __p = __a._M_data; __p < __a._M_data + __s * __n; \
__p += __s, ++__q) \
*__p _Op##= *__q; \
} \
\
template<typename _Tp> \
inline void \
_Array_augmented_##_Name(_Array<_Tp> __a, _Array<_Tp> __b, \
size_t __n, size_t __s) \
{ \
_Tp* __q(__b._M_data); \
for (_Tp* __p = __a._M_data; __p < __a._M_data + __n; \
++__p, __q += __s) \
*__p _Op##= *__q; \
} \
\
template<typename _Tp, class _Dom> \
void \
_Array_augmented_##_Name(_Array<_Tp> __a, size_t __s, \
const _Expr<_Dom, _Tp>& __e, size_t __n) \
{ \
_Tp* __p(__a._M_data); \
for (size_t __i = 0; __i < __n; ++__i, __p += __s) \
*__p _Op##= __e[__i]; \
} \
\
template<typename _Tp> \
inline void \
_Array_augmented_##_Name(_Array<_Tp> __a, _Array<size_t> __i, \
_Array<_Tp> __b, size_t __n) \
{ \
_Tp* __q(__b._M_data); \
for (size_t* __j = __i._M_data; __j < __i._M_data + __n; \
++__j, ++__q) \
__a._M_data[*__j] _Op##= *__q; \
} \
\
template<typename _Tp> \
inline void \
_Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, \
_Array<_Tp> __b, _Array<size_t> __i) \
{ \
_Tp* __p(__a._M_data); \
for (size_t* __j = __i._M_data; __j<__i._M_data + __n; \
++__j, ++__p) \
*__p _Op##= __b._M_data[*__j]; \
} \
\
template<typename _Tp, class _Dom> \
void \
_Array_augmented_##_Name(_Array<_Tp> __a, _Array<size_t> __i, \
const _Expr<_Dom, _Tp>& __e, size_t __n) \
{ \
size_t* __j(__i._M_data); \
for (size_t __k = 0; __k<__n; ++__k, ++__j) \
__a._M_data[*__j] _Op##= __e[__k]; \
} \
\
template<typename _Tp> \
void \
_Array_augmented_##_Name(_Array<_Tp> __a, _Array<bool> __m, \
_Array<_Tp> __b, size_t __n) \
{ \
bool* __ok(__m._M_data); \
_Tp* __p(__a._M_data); \
for (_Tp* __q = __b._M_data; __q < __b._M_data + __n; \
++__q, ++__ok, ++__p) \
{ \
while (! *__ok) \
{ \
++__ok; \
++__p; \
} \
*__p _Op##= *__q; \
} \
} \
\
template<typename _Tp> \
void \
_Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, \
_Array<_Tp> __b, _Array<bool> __m) \
{ \
bool* __ok(__m._M_data); \
_Tp* __q(__b._M_data); \
for (_Tp* __p = __a._M_data; __p < __a._M_data + __n; \
++__p, ++__ok, ++__q) \
{ \
while (! *__ok) \
{ \
++__ok; \
++__q; \
} \
*__p _Op##= *__q; \
} \
} \
\
template<typename _Tp, class _Dom> \
void \
_Array_augmented_##_Name(_Array<_Tp> __a, _Array<bool> __m, \
const _Expr<_Dom, _Tp>& __e, size_t __n) \
{ \
bool* __ok(__m._M_data); \
_Tp* __p(__a._M_data); \
for (size_t __i = 0; __i < __n; ++__i, ++__ok, ++__p) \
{ \
while (! *__ok) \
{ \
++__ok; \
++__p; \
} \
*__p _Op##= __e[__i]; \
} \
}
_DEFINE_ARRAY_FUNCTION(+, __plus)
_DEFINE_ARRAY_FUNCTION(-, __minus)
_DEFINE_ARRAY_FUNCTION(*, __multiplies)
_DEFINE_ARRAY_FUNCTION(/, __divides)
_DEFINE_ARRAY_FUNCTION(%, __modulus)
_DEFINE_ARRAY_FUNCTION(^, __bitwise_xor)
_DEFINE_ARRAY_FUNCTION(|, __bitwise_or)
_DEFINE_ARRAY_FUNCTION(&, __bitwise_and)
_DEFINE_ARRAY_FUNCTION(<<, __shift_left)
_DEFINE_ARRAY_FUNCTION(>>, __shift_right)
#undef _DEFINE_ARRAY_FUNCTION
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
# include <bits/valarray_array.tcc>
#endif /* _ARRAY_H */
c++/8/bits/stl_queue.h 0000644 00000057011 15201526705 0010412 0 ustar 00 // Queue implementation -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1996,1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file bits/stl_queue.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{queue}
*/
#ifndef _STL_QUEUE_H
#define _STL_QUEUE_H 1
#include <bits/concept_check.h>
#include <debug/debug.h>
#if __cplusplus >= 201103L
# include <bits/uses_allocator.h>
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @brief A standard container giving FIFO behavior.
*
* @ingroup sequences
*
* @tparam _Tp Type of element.
* @tparam _Sequence Type of underlying sequence, defaults to deque<_Tp>.
*
* Meets many of the requirements of a
* <a href="tables.html#65">container</a>,
* but does not define anything to do with iterators. Very few of the
* other standard container interfaces are defined.
*
* This is not a true container, but an @e adaptor. It holds another
* container, and provides a wrapper interface to that container. The
* wrapper is what enforces strict first-in-first-out %queue behavior.
*
* The second template parameter defines the type of the underlying
* sequence/container. It defaults to std::deque, but it can be any type
* that supports @c front, @c back, @c push_back, and @c pop_front,
* such as std::list or an appropriate user-defined type.
*
* Members not found in @a normal containers are @c container_type,
* which is a typedef for the second Sequence parameter, and @c push and
* @c pop, which are standard %queue/FIFO operations.
*/
template<typename _Tp, typename _Sequence = deque<_Tp> >
class queue
{
#ifdef _GLIBCXX_CONCEPT_CHECKS
// concept requirements
typedef typename _Sequence::value_type _Sequence_value_type;
# if __cplusplus < 201103L
__glibcxx_class_requires(_Tp, _SGIAssignableConcept)
# endif
__glibcxx_class_requires(_Sequence, _FrontInsertionSequenceConcept)
__glibcxx_class_requires(_Sequence, _BackInsertionSequenceConcept)
__glibcxx_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept)
#endif
template<typename _Tp1, typename _Seq1>
friend bool
operator==(const queue<_Tp1, _Seq1>&, const queue<_Tp1, _Seq1>&);
template<typename _Tp1, typename _Seq1>
friend bool
operator<(const queue<_Tp1, _Seq1>&, const queue<_Tp1, _Seq1>&);
#if __cplusplus >= 201103L
template<typename _Alloc>
using _Uses = typename
enable_if<uses_allocator<_Sequence, _Alloc>::value>::type;
#endif
public:
typedef typename _Sequence::value_type value_type;
typedef typename _Sequence::reference reference;
typedef typename _Sequence::const_reference const_reference;
typedef typename _Sequence::size_type size_type;
typedef _Sequence container_type;
protected:
/* Maintainers wondering why this isn't uglified as per style
* guidelines should note that this name is specified in the standard,
* C++98 [23.2.3.1].
* (Why? Presumably for the same reason that it's protected instead
* of private: to allow derivation. But none of the other
* containers allow for derivation. Odd.)
*/
/// @c c is the underlying container.
_Sequence c;
public:
/**
* @brief Default constructor creates no elements.
*/
#if __cplusplus < 201103L
explicit
queue(const _Sequence& __c = _Sequence())
: c(__c) { }
#else
template<typename _Seq = _Sequence, typename _Requires = typename
enable_if<is_default_constructible<_Seq>::value>::type>
queue()
: c() { }
explicit
queue(const _Sequence& __c)
: c(__c) { }
explicit
queue(_Sequence&& __c)
: c(std::move(__c)) { }
template<typename _Alloc, typename _Requires = _Uses<_Alloc>>
explicit
queue(const _Alloc& __a)
: c(__a) { }
template<typename _Alloc, typename _Requires = _Uses<_Alloc>>
queue(const _Sequence& __c, const _Alloc& __a)
: c(__c, __a) { }
template<typename _Alloc, typename _Requires = _Uses<_Alloc>>
queue(_Sequence&& __c, const _Alloc& __a)
: c(std::move(__c), __a) { }
template<typename _Alloc, typename _Requires = _Uses<_Alloc>>
queue(const queue& __q, const _Alloc& __a)
: c(__q.c, __a) { }
template<typename _Alloc, typename _Requires = _Uses<_Alloc>>
queue(queue&& __q, const _Alloc& __a)
: c(std::move(__q.c), __a) { }
#endif
/**
* Returns true if the %queue is empty.
*/
bool
empty() const
{ return c.empty(); }
/** Returns the number of elements in the %queue. */
size_type
size() const
{ return c.size(); }
/**
* Returns a read/write reference to the data at the first
* element of the %queue.
*/
reference
front()
{
__glibcxx_requires_nonempty();
return c.front();
}
/**
* Returns a read-only (constant) reference to the data at the first
* element of the %queue.
*/
const_reference
front() const
{
__glibcxx_requires_nonempty();
return c.front();
}
/**
* Returns a read/write reference to the data at the last
* element of the %queue.
*/
reference
back()
{
__glibcxx_requires_nonempty();
return c.back();
}
/**
* Returns a read-only (constant) reference to the data at the last
* element of the %queue.
*/
const_reference
back() const
{
__glibcxx_requires_nonempty();
return c.back();
}
/**
* @brief Add data to the end of the %queue.
* @param __x Data to be added.
*
* This is a typical %queue operation. The function creates an
* element at the end of the %queue and assigns the given data
* to it. The time complexity of the operation depends on the
* underlying sequence.
*/
void
push(const value_type& __x)
{ c.push_back(__x); }
#if __cplusplus >= 201103L
void
push(value_type&& __x)
{ c.push_back(std::move(__x)); }
#if __cplusplus > 201402L
template<typename... _Args>
decltype(auto)
emplace(_Args&&... __args)
{ return c.emplace_back(std::forward<_Args>(__args)...); }
#else
template<typename... _Args>
void
emplace(_Args&&... __args)
{ c.emplace_back(std::forward<_Args>(__args)...); }
#endif
#endif
/**
* @brief Removes first element.
*
* This is a typical %queue operation. It shrinks the %queue by one.
* The time complexity of the operation depends on the underlying
* sequence.
*
* Note that no data is returned, and if the first element's
* data is needed, it should be retrieved before pop() is
* called.
*/
void
pop()
{
__glibcxx_requires_nonempty();
c.pop_front();
}
#if __cplusplus >= 201103L
void
swap(queue& __q)
#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
noexcept(__is_nothrow_swappable<_Sequence>::value)
#else
noexcept(__is_nothrow_swappable<_Tp>::value)
#endif
{
using std::swap;
swap(c, __q.c);
}
#endif // __cplusplus >= 201103L
};
#if __cpp_deduction_guides >= 201606
template<typename _Container,
typename = enable_if_t<!__is_allocator<_Container>::value>>
queue(_Container) -> queue<typename _Container::value_type, _Container>;
template<typename _Container, typename _Allocator,
typename = enable_if_t<!__is_allocator<_Container>::value>,
typename = enable_if_t<__is_allocator<_Allocator>::value>>
queue(_Container, _Allocator)
-> queue<typename _Container::value_type, _Container>;
#endif
/**
* @brief Queue equality comparison.
* @param __x A %queue.
* @param __y A %queue of the same type as @a __x.
* @return True iff the size and elements of the queues are equal.
*
* This is an equivalence relation. Complexity and semantics depend on the
* underlying sequence type, but the expected rules are: this relation is
* linear in the size of the sequences, and queues are considered equivalent
* if their sequences compare equal.
*/
template<typename _Tp, typename _Seq>
inline bool
operator==(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
{ return __x.c == __y.c; }
/**
* @brief Queue ordering relation.
* @param __x A %queue.
* @param __y A %queue of the same type as @a x.
* @return True iff @a __x is lexicographically less than @a __y.
*
* This is an total ordering relation. Complexity and semantics
* depend on the underlying sequence type, but the expected rules
* are: this relation is linear in the size of the sequences, the
* elements must be comparable with @c <, and
* std::lexicographical_compare() is usually used to make the
* determination.
*/
template<typename _Tp, typename _Seq>
inline bool
operator<(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
{ return __x.c < __y.c; }
/// Based on operator==
template<typename _Tp, typename _Seq>
inline bool
operator!=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
{ return !(__x == __y); }
/// Based on operator<
template<typename _Tp, typename _Seq>
inline bool
operator>(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
{ return __y < __x; }
/// Based on operator<
template<typename _Tp, typename _Seq>
inline bool
operator<=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
{ return !(__y < __x); }
/// Based on operator<
template<typename _Tp, typename _Seq>
inline bool
operator>=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
{ return !(__x < __y); }
#if __cplusplus >= 201103L
template<typename _Tp, typename _Seq>
inline
#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
// Constrained free swap overload, see p0185r1
typename enable_if<__is_swappable<_Seq>::value>::type
#else
void
#endif
swap(queue<_Tp, _Seq>& __x, queue<_Tp, _Seq>& __y)
noexcept(noexcept(__x.swap(__y)))
{ __x.swap(__y); }
template<typename _Tp, typename _Seq, typename _Alloc>
struct uses_allocator<queue<_Tp, _Seq>, _Alloc>
: public uses_allocator<_Seq, _Alloc>::type { };
#endif // __cplusplus >= 201103L
/**
* @brief A standard container automatically sorting its contents.
*
* @ingroup sequences
*
* @tparam _Tp Type of element.
* @tparam _Sequence Type of underlying sequence, defaults to vector<_Tp>.
* @tparam _Compare Comparison function object type, defaults to
* less<_Sequence::value_type>.
*
* This is not a true container, but an @e adaptor. It holds
* another container, and provides a wrapper interface to that
* container. The wrapper is what enforces priority-based sorting
* and %queue behavior. Very few of the standard container/sequence
* interface requirements are met (e.g., iterators).
*
* The second template parameter defines the type of the underlying
* sequence/container. It defaults to std::vector, but it can be
* any type that supports @c front(), @c push_back, @c pop_back,
* and random-access iterators, such as std::deque or an
* appropriate user-defined type.
*
* The third template parameter supplies the means of making
* priority comparisons. It defaults to @c less<value_type> but
* can be anything defining a strict weak ordering.
*
* Members not found in @a normal containers are @c container_type,
* which is a typedef for the second Sequence parameter, and @c
* push, @c pop, and @c top, which are standard %queue operations.
*
* @note No equality/comparison operators are provided for
* %priority_queue.
*
* @note Sorting of the elements takes place as they are added to,
* and removed from, the %priority_queue using the
* %priority_queue's member functions. If you access the elements
* by other means, and change their data such that the sorting
* order would be different, the %priority_queue will not re-sort
* the elements for you. (How could it know to do so?)
*/
template<typename _Tp, typename _Sequence = vector<_Tp>,
typename _Compare = less<typename _Sequence::value_type> >
class priority_queue
{
#ifdef _GLIBCXX_CONCEPT_CHECKS
// concept requirements
typedef typename _Sequence::value_type _Sequence_value_type;
# if __cplusplus < 201103L
__glibcxx_class_requires(_Tp, _SGIAssignableConcept)
# endif
__glibcxx_class_requires(_Sequence, _SequenceConcept)
__glibcxx_class_requires(_Sequence, _RandomAccessContainerConcept)
__glibcxx_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept)
__glibcxx_class_requires4(_Compare, bool, _Tp, _Tp,
_BinaryFunctionConcept)
#endif
#if __cplusplus >= 201103L
template<typename _Alloc>
using _Uses = typename
enable_if<uses_allocator<_Sequence, _Alloc>::value>::type;
#endif
public:
typedef typename _Sequence::value_type value_type;
typedef typename _Sequence::reference reference;
typedef typename _Sequence::const_reference const_reference;
typedef typename _Sequence::size_type size_type;
typedef _Sequence container_type;
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 2684. priority_queue lacking comparator typedef
typedef _Compare value_compare;
protected:
// See queue::c for notes on these names.
_Sequence c;
_Compare comp;
public:
/**
* @brief Default constructor creates no elements.
*/
#if __cplusplus < 201103L
explicit
priority_queue(const _Compare& __x = _Compare(),
const _Sequence& __s = _Sequence())
: c(__s), comp(__x)
{ std::make_heap(c.begin(), c.end(), comp); }
#else
template<typename _Seq = _Sequence, typename _Requires = typename
enable_if<__and_<is_default_constructible<_Compare>,
is_default_constructible<_Seq>>::value>::type>
priority_queue()
: c(), comp() { }
explicit
priority_queue(const _Compare& __x, const _Sequence& __s)
: c(__s), comp(__x)
{ std::make_heap(c.begin(), c.end(), comp); }
explicit
priority_queue(const _Compare& __x, _Sequence&& __s = _Sequence())
: c(std::move(__s)), comp(__x)
{ std::make_heap(c.begin(), c.end(), comp); }
template<typename _Alloc, typename _Requires = _Uses<_Alloc>>
explicit
priority_queue(const _Alloc& __a)
: c(__a), comp() { }
template<typename _Alloc, typename _Requires = _Uses<_Alloc>>
priority_queue(const _Compare& __x, const _Alloc& __a)
: c(__a), comp(__x) { }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2537. Constructors [...] taking allocators should call make_heap
template<typename _Alloc, typename _Requires = _Uses<_Alloc>>
priority_queue(const _Compare& __x, const _Sequence& __c,
const _Alloc& __a)
: c(__c, __a), comp(__x)
{ std::make_heap(c.begin(), c.end(), comp); }
template<typename _Alloc, typename _Requires = _Uses<_Alloc>>
priority_queue(const _Compare& __x, _Sequence&& __c, const _Alloc& __a)
: c(std::move(__c), __a), comp(__x)
{ std::make_heap(c.begin(), c.end(), comp); }
template<typename _Alloc, typename _Requires = _Uses<_Alloc>>
priority_queue(const priority_queue& __q, const _Alloc& __a)
: c(__q.c, __a), comp(__q.comp) { }
template<typename _Alloc, typename _Requires = _Uses<_Alloc>>
priority_queue(priority_queue&& __q, const _Alloc& __a)
: c(std::move(__q.c), __a), comp(std::move(__q.comp)) { }
#endif
/**
* @brief Builds a %queue from a range.
* @param __first An input iterator.
* @param __last An input iterator.
* @param __x A comparison functor describing a strict weak ordering.
* @param __s An initial sequence with which to start.
*
* Begins by copying @a __s, inserting a copy of the elements
* from @a [first,last) into the copy of @a __s, then ordering
* the copy according to @a __x.
*
* For more information on function objects, see the
* documentation on @link functors functor base
* classes@endlink.
*/
#if __cplusplus < 201103L
template<typename _InputIterator>
priority_queue(_InputIterator __first, _InputIterator __last,
const _Compare& __x = _Compare(),
const _Sequence& __s = _Sequence())
: c(__s), comp(__x)
{
__glibcxx_requires_valid_range(__first, __last);
c.insert(c.end(), __first, __last);
std::make_heap(c.begin(), c.end(), comp);
}
#else
template<typename _InputIterator>
priority_queue(_InputIterator __first, _InputIterator __last,
const _Compare& __x,
const _Sequence& __s)
: c(__s), comp(__x)
{
__glibcxx_requires_valid_range(__first, __last);
c.insert(c.end(), __first, __last);
std::make_heap(c.begin(), c.end(), comp);
}
template<typename _InputIterator>
priority_queue(_InputIterator __first, _InputIterator __last,
const _Compare& __x = _Compare(),
_Sequence&& __s = _Sequence())
: c(std::move(__s)), comp(__x)
{
__glibcxx_requires_valid_range(__first, __last);
c.insert(c.end(), __first, __last);
std::make_heap(c.begin(), c.end(), comp);
}
#endif
/**
* Returns true if the %queue is empty.
*/
bool
empty() const
{ return c.empty(); }
/** Returns the number of elements in the %queue. */
size_type
size() const
{ return c.size(); }
/**
* Returns a read-only (constant) reference to the data at the first
* element of the %queue.
*/
const_reference
top() const
{
__glibcxx_requires_nonempty();
return c.front();
}
/**
* @brief Add data to the %queue.
* @param __x Data to be added.
*
* This is a typical %queue operation.
* The time complexity of the operation depends on the underlying
* sequence.
*/
void
push(const value_type& __x)
{
c.push_back(__x);
std::push_heap(c.begin(), c.end(), comp);
}
#if __cplusplus >= 201103L
void
push(value_type&& __x)
{
c.push_back(std::move(__x));
std::push_heap(c.begin(), c.end(), comp);
}
template<typename... _Args>
void
emplace(_Args&&... __args)
{
c.emplace_back(std::forward<_Args>(__args)...);
std::push_heap(c.begin(), c.end(), comp);
}
#endif
/**
* @brief Removes first element.
*
* This is a typical %queue operation. It shrinks the %queue
* by one. The time complexity of the operation depends on the
* underlying sequence.
*
* Note that no data is returned, and if the first element's
* data is needed, it should be retrieved before pop() is
* called.
*/
void
pop()
{
__glibcxx_requires_nonempty();
std::pop_heap(c.begin(), c.end(), comp);
c.pop_back();
}
#if __cplusplus >= 201103L
void
swap(priority_queue& __pq)
noexcept(__and_<
#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
__is_nothrow_swappable<_Sequence>,
#else
__is_nothrow_swappable<_Tp>,
#endif
__is_nothrow_swappable<_Compare>
>::value)
{
using std::swap;
swap(c, __pq.c);
swap(comp, __pq.comp);
}
#endif // __cplusplus >= 201103L
};
#if __cpp_deduction_guides >= 201606
template<typename _Compare, typename _Container,
typename = enable_if_t<!__is_allocator<_Compare>::value>,
typename = enable_if_t<!__is_allocator<_Container>::value>>
priority_queue(_Compare, _Container)
-> priority_queue<typename _Container::value_type, _Container, _Compare>;
template<typename _InputIterator, typename _ValT
= typename iterator_traits<_InputIterator>::value_type,
typename _Compare = less<_ValT>,
typename _Container = vector<_ValT>,
typename = _RequireInputIter<_InputIterator>,
typename = enable_if_t<!__is_allocator<_Compare>::value>,
typename = enable_if_t<!__is_allocator<_Container>::value>>
priority_queue(_InputIterator, _InputIterator, _Compare = _Compare(),
_Container = _Container())
-> priority_queue<_ValT, _Container, _Compare>;
template<typename _Compare, typename _Container, typename _Allocator,
typename = enable_if_t<!__is_allocator<_Compare>::value>,
typename = enable_if_t<!__is_allocator<_Container>::value>,
typename = enable_if_t<__is_allocator<_Allocator>::value>>
priority_queue(_Compare, _Container, _Allocator)
-> priority_queue<typename _Container::value_type, _Container, _Compare>;
#endif
// No equality/comparison operators are provided for priority_queue.
#if __cplusplus >= 201103L
template<typename _Tp, typename _Sequence, typename _Compare>
inline
#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
// Constrained free swap overload, see p0185r1
typename enable_if<__and_<__is_swappable<_Sequence>,
__is_swappable<_Compare>>::value>::type
#else
void
#endif
swap(priority_queue<_Tp, _Sequence, _Compare>& __x,
priority_queue<_Tp, _Sequence, _Compare>& __y)
noexcept(noexcept(__x.swap(__y)))
{ __x.swap(__y); }
template<typename _Tp, typename _Sequence, typename _Compare,
typename _Alloc>
struct uses_allocator<priority_queue<_Tp, _Sequence, _Compare>, _Alloc>
: public uses_allocator<_Sequence, _Alloc>::type { };
#endif // __cplusplus >= 201103L
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif /* _STL_QUEUE_H */
c++/8/bits/fstream.tcc 0000644 00000100037 15201526705 0010364 0 ustar 00 // File based streams -*- C++ -*-
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/fstream.tcc
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{fstream}
*/
//
// ISO C++ 14882: 27.8 File-based streams
//
#ifndef _FSTREAM_TCC
#define _FSTREAM_TCC 1
#pragma GCC system_header
#include <bits/cxxabi_forced.h>
#include <bits/move.h> // for swap
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _CharT, typename _Traits>
void
basic_filebuf<_CharT, _Traits>::
_M_allocate_internal_buffer()
{
// Allocate internal buffer only if one doesn't already exist
// (either allocated or provided by the user via setbuf).
if (!_M_buf_allocated && !_M_buf)
{
_M_buf = new char_type[_M_buf_size];
_M_buf_allocated = true;
}
}
template<typename _CharT, typename _Traits>
void
basic_filebuf<_CharT, _Traits>::
_M_destroy_internal_buffer() throw()
{
if (_M_buf_allocated)
{
delete [] _M_buf;
_M_buf = 0;
_M_buf_allocated = false;
}
delete [] _M_ext_buf;
_M_ext_buf = 0;
_M_ext_buf_size = 0;
_M_ext_next = 0;
_M_ext_end = 0;
}
template<typename _CharT, typename _Traits>
basic_filebuf<_CharT, _Traits>::
basic_filebuf() : __streambuf_type(), _M_lock(), _M_file(&_M_lock),
_M_mode(ios_base::openmode(0)), _M_state_beg(), _M_state_cur(),
_M_state_last(), _M_buf(0), _M_buf_size(BUFSIZ),
_M_buf_allocated(false), _M_reading(false), _M_writing(false), _M_pback(),
_M_pback_cur_save(0), _M_pback_end_save(0), _M_pback_init(false),
_M_codecvt(0), _M_ext_buf(0), _M_ext_buf_size(0), _M_ext_next(0),
_M_ext_end(0)
{
if (has_facet<__codecvt_type>(this->_M_buf_locale))
_M_codecvt = &use_facet<__codecvt_type>(this->_M_buf_locale);
}
#if __cplusplus >= 201103L
template<typename _CharT, typename _Traits>
basic_filebuf<_CharT, _Traits>::
basic_filebuf(basic_filebuf&& __rhs)
: __streambuf_type(__rhs),
_M_lock(), _M_file(std::move(__rhs._M_file), &_M_lock),
_M_mode(std::__exchange(__rhs._M_mode, ios_base::openmode(0))),
_M_state_beg(std::move(__rhs._M_state_beg)),
_M_state_cur(std::move(__rhs._M_state_cur)),
_M_state_last(std::move(__rhs._M_state_last)),
_M_buf(std::__exchange(__rhs._M_buf, nullptr)),
_M_buf_size(std::__exchange(__rhs._M_buf_size, 1)),
_M_buf_allocated(std::__exchange(__rhs._M_buf_allocated, false)),
_M_reading(std::__exchange(__rhs._M_reading, false)),
_M_writing(std::__exchange(__rhs._M_writing, false)),
_M_pback(__rhs._M_pback),
_M_pback_cur_save(std::__exchange(__rhs._M_pback_cur_save, nullptr)),
_M_pback_end_save(std::__exchange(__rhs._M_pback_end_save, nullptr)),
_M_pback_init(std::__exchange(__rhs._M_pback_init, false)),
_M_codecvt(__rhs._M_codecvt),
_M_ext_buf(std::__exchange(__rhs._M_ext_buf, nullptr)),
_M_ext_buf_size(std::__exchange(__rhs._M_ext_buf_size, 0)),
_M_ext_next(std::__exchange(__rhs._M_ext_next, nullptr)),
_M_ext_end(std::__exchange(__rhs._M_ext_end, nullptr))
{
__rhs._M_set_buffer(-1);
__rhs._M_state_last = __rhs._M_state_cur = __rhs._M_state_beg;
}
template<typename _CharT, typename _Traits>
basic_filebuf<_CharT, _Traits>&
basic_filebuf<_CharT, _Traits>::
operator=(basic_filebuf&& __rhs)
{
this->close();
__streambuf_type::operator=(__rhs);
_M_file.swap(__rhs._M_file);
_M_mode = std::__exchange(__rhs._M_mode, ios_base::openmode(0));
_M_state_beg = std::move(__rhs._M_state_beg);
_M_state_cur = std::move(__rhs._M_state_cur);
_M_state_last = std::move(__rhs._M_state_last);
_M_buf = std::__exchange(__rhs._M_buf, nullptr);
_M_buf_size = std::__exchange(__rhs._M_buf_size, 1);
_M_buf_allocated = std::__exchange(__rhs._M_buf_allocated, false);
_M_ext_buf = std::__exchange(__rhs._M_ext_buf, nullptr);
_M_ext_buf_size = std::__exchange(__rhs._M_ext_buf_size, 0);
_M_ext_next = std::__exchange(__rhs._M_ext_next, nullptr);
_M_ext_end = std::__exchange(__rhs._M_ext_end, nullptr);
_M_reading = std::__exchange(__rhs._M_reading, false);
_M_writing = std::__exchange(__rhs._M_writing, false);
_M_pback_cur_save = std::__exchange(__rhs._M_pback_cur_save, nullptr);
_M_pback_end_save = std::__exchange(__rhs._M_pback_end_save, nullptr);
_M_pback_init = std::__exchange(__rhs._M_pback_init, false);
__rhs._M_set_buffer(-1);
__rhs._M_state_last = __rhs._M_state_cur = __rhs._M_state_beg;
return *this;
}
template<typename _CharT, typename _Traits>
void
basic_filebuf<_CharT, _Traits>::
swap(basic_filebuf& __rhs)
{
__streambuf_type::swap(__rhs);
_M_file.swap(__rhs._M_file);
std::swap(_M_mode, __rhs._M_mode);
std::swap(_M_state_beg, __rhs._M_state_beg);
std::swap(_M_state_cur, __rhs._M_state_cur);
std::swap(_M_state_last, __rhs._M_state_last);
std::swap(_M_buf, __rhs._M_buf);
std::swap(_M_buf_size, __rhs._M_buf_size);
std::swap(_M_buf_allocated, __rhs._M_buf_allocated);
std::swap(_M_ext_buf, __rhs._M_ext_buf);
std::swap(_M_ext_buf_size, __rhs._M_ext_buf_size);
std::swap(_M_ext_next, __rhs._M_ext_next);
std::swap(_M_ext_end, __rhs._M_ext_end);
std::swap(_M_reading, __rhs._M_reading);
std::swap(_M_writing, __rhs._M_writing);
std::swap(_M_pback_cur_save, __rhs._M_pback_cur_save);
std::swap(_M_pback_end_save, __rhs._M_pback_end_save);
std::swap(_M_pback_init, __rhs._M_pback_init);
}
#endif
template<typename _CharT, typename _Traits>
typename basic_filebuf<_CharT, _Traits>::__filebuf_type*
basic_filebuf<_CharT, _Traits>::
open(const char* __s, ios_base::openmode __mode)
{
__filebuf_type *__ret = 0;
if (!this->is_open())
{
_M_file.open(__s, __mode);
if (this->is_open())
{
_M_allocate_internal_buffer();
_M_mode = __mode;
// Setup initial buffer to 'uncommitted' mode.
_M_reading = false;
_M_writing = false;
_M_set_buffer(-1);
// Reset to initial state.
_M_state_last = _M_state_cur = _M_state_beg;
// 27.8.1.3,4
if ((__mode & ios_base::ate)
&& this->seekoff(0, ios_base::end, __mode)
== pos_type(off_type(-1)))
this->close();
else
__ret = this;
}
}
return __ret;
}
template<typename _CharT, typename _Traits>
typename basic_filebuf<_CharT, _Traits>::__filebuf_type*
basic_filebuf<_CharT, _Traits>::
close()
{
if (!this->is_open())
return 0;
bool __testfail = false;
{
// NB: Do this here so that re-opened filebufs will be cool...
struct __close_sentry
{
basic_filebuf *__fb;
__close_sentry (basic_filebuf *__fbi): __fb(__fbi) { }
~__close_sentry ()
{
__fb->_M_mode = ios_base::openmode(0);
__fb->_M_pback_init = false;
__fb->_M_destroy_internal_buffer();
__fb->_M_reading = false;
__fb->_M_writing = false;
__fb->_M_set_buffer(-1);
__fb->_M_state_last = __fb->_M_state_cur = __fb->_M_state_beg;
}
} __cs (this);
__try
{
if (!_M_terminate_output())
__testfail = true;
}
__catch(__cxxabiv1::__forced_unwind&)
{
_M_file.close();
__throw_exception_again;
}
__catch(...)
{ __testfail = true; }
}
if (!_M_file.close())
__testfail = true;
if (__testfail)
return 0;
else
return this;
}
template<typename _CharT, typename _Traits>
streamsize
basic_filebuf<_CharT, _Traits>::
showmanyc()
{
streamsize __ret = -1;
const bool __testin = _M_mode & ios_base::in;
if (__testin && this->is_open())
{
// For a stateful encoding (-1) the pending sequence might be just
// shift and unshift prefixes with no actual character.
__ret = this->egptr() - this->gptr();
#if _GLIBCXX_HAVE_DOS_BASED_FILESYSTEM
// About this workaround, see libstdc++/20806.
const bool __testbinary = _M_mode & ios_base::binary;
if (__check_facet(_M_codecvt).encoding() >= 0
&& __testbinary)
#else
if (__check_facet(_M_codecvt).encoding() >= 0)
#endif
__ret += _M_file.showmanyc() / _M_codecvt->max_length();
}
return __ret;
}
template<typename _CharT, typename _Traits>
typename basic_filebuf<_CharT, _Traits>::int_type
basic_filebuf<_CharT, _Traits>::
underflow()
{
int_type __ret = traits_type::eof();
const bool __testin = _M_mode & ios_base::in;
if (__testin)
{
if (_M_writing)
{
if (overflow() == traits_type::eof())
return __ret;
_M_set_buffer(-1);
_M_writing = false;
}
// Check for pback madness, and if so switch back to the
// normal buffers and jet outta here before expensive
// fileops happen...
_M_destroy_pback();
if (this->gptr() < this->egptr())
return traits_type::to_int_type(*this->gptr());
// Get and convert input sequence.
const size_t __buflen = _M_buf_size > 1 ? _M_buf_size - 1 : 1;
// Will be set to true if ::read() returns 0 indicating EOF.
bool __got_eof = false;
// Number of internal characters produced.
streamsize __ilen = 0;
codecvt_base::result __r = codecvt_base::ok;
if (__check_facet(_M_codecvt).always_noconv())
{
__ilen = _M_file.xsgetn(reinterpret_cast<char*>(this->eback()),
__buflen);
if (__ilen == 0)
__got_eof = true;
}
else
{
// Worst-case number of external bytes.
// XXX Not done encoding() == -1.
const int __enc = _M_codecvt->encoding();
streamsize __blen; // Minimum buffer size.
streamsize __rlen; // Number of chars to read.
if (__enc > 0)
__blen = __rlen = __buflen * __enc;
else
{
__blen = __buflen + _M_codecvt->max_length() - 1;
__rlen = __buflen;
}
const streamsize __remainder = _M_ext_end - _M_ext_next;
__rlen = __rlen > __remainder ? __rlen - __remainder : 0;
// An imbue in 'read' mode implies first converting the external
// chars already present.
if (_M_reading && this->egptr() == this->eback() && __remainder)
__rlen = 0;
// Allocate buffer if necessary and move unconverted
// bytes to front.
if (_M_ext_buf_size < __blen)
{
char* __buf = new char[__blen];
if (__remainder)
__builtin_memcpy(__buf, _M_ext_next, __remainder);
delete [] _M_ext_buf;
_M_ext_buf = __buf;
_M_ext_buf_size = __blen;
}
else if (__remainder)
__builtin_memmove(_M_ext_buf, _M_ext_next, __remainder);
_M_ext_next = _M_ext_buf;
_M_ext_end = _M_ext_buf + __remainder;
_M_state_last = _M_state_cur;
do
{
if (__rlen > 0)
{
// Sanity check!
// This may fail if the return value of
// codecvt::max_length() is bogus.
if (_M_ext_end - _M_ext_buf + __rlen > _M_ext_buf_size)
{
__throw_ios_failure(__N("basic_filebuf::underflow "
"codecvt::max_length() "
"is not valid"));
}
streamsize __elen = _M_file.xsgetn(_M_ext_end, __rlen);
if (__elen == 0)
__got_eof = true;
else if (__elen == -1)
break;
_M_ext_end += __elen;
}
char_type* __iend = this->eback();
if (_M_ext_next < _M_ext_end)
__r = _M_codecvt->in(_M_state_cur, _M_ext_next,
_M_ext_end, _M_ext_next,
this->eback(),
this->eback() + __buflen, __iend);
if (__r == codecvt_base::noconv)
{
size_t __avail = _M_ext_end - _M_ext_buf;
__ilen = std::min(__avail, __buflen);
traits_type::copy(this->eback(),
reinterpret_cast<char_type*>
(_M_ext_buf), __ilen);
_M_ext_next = _M_ext_buf + __ilen;
}
else
__ilen = __iend - this->eback();
// _M_codecvt->in may return error while __ilen > 0: this is
// ok, and actually occurs in case of mixed encodings (e.g.,
// XML files).
if (__r == codecvt_base::error)
break;
__rlen = 1;
}
while (__ilen == 0 && !__got_eof);
}
if (__ilen > 0)
{
_M_set_buffer(__ilen);
_M_reading = true;
__ret = traits_type::to_int_type(*this->gptr());
}
else if (__got_eof)
{
// If the actual end of file is reached, set 'uncommitted'
// mode, thus allowing an immediate write without an
// intervening seek.
_M_set_buffer(-1);
_M_reading = false;
// However, reaching it while looping on partial means that
// the file has got an incomplete character.
if (__r == codecvt_base::partial)
__throw_ios_failure(__N("basic_filebuf::underflow "
"incomplete character in file"));
}
else if (__r == codecvt_base::error)
__throw_ios_failure(__N("basic_filebuf::underflow "
"invalid byte sequence in file"));
else
__throw_ios_failure(__N("basic_filebuf::underflow "
"error reading the file"));
}
return __ret;
}
template<typename _CharT, typename _Traits>
typename basic_filebuf<_CharT, _Traits>::int_type
basic_filebuf<_CharT, _Traits>::
pbackfail(int_type __i)
{
int_type __ret = traits_type::eof();
const bool __testin = _M_mode & ios_base::in;
if (__testin)
{
if (_M_writing)
{
if (overflow() == traits_type::eof())
return __ret;
_M_set_buffer(-1);
_M_writing = false;
}
// Remember whether the pback buffer is active, otherwise below
// we may try to store in it a second char (libstdc++/9761).
const bool __testpb = _M_pback_init;
const bool __testeof = traits_type::eq_int_type(__i, __ret);
int_type __tmp;
if (this->eback() < this->gptr())
{
this->gbump(-1);
__tmp = traits_type::to_int_type(*this->gptr());
}
else if (this->seekoff(-1, ios_base::cur) != pos_type(off_type(-1)))
{
__tmp = this->underflow();
if (traits_type::eq_int_type(__tmp, __ret))
return __ret;
}
else
{
// At the beginning of the buffer, need to make a
// putback position available. But the seek may fail
// (f.i., at the beginning of a file, see
// libstdc++/9439) and in that case we return
// traits_type::eof().
return __ret;
}
// Try to put back __i into input sequence in one of three ways.
// Order these tests done in is unspecified by the standard.
if (!__testeof && traits_type::eq_int_type(__i, __tmp))
__ret = __i;
else if (__testeof)
__ret = traits_type::not_eof(__i);
else if (!__testpb)
{
_M_create_pback();
_M_reading = true;
*this->gptr() = traits_type::to_char_type(__i);
__ret = __i;
}
}
return __ret;
}
template<typename _CharT, typename _Traits>
typename basic_filebuf<_CharT, _Traits>::int_type
basic_filebuf<_CharT, _Traits>::
overflow(int_type __c)
{
int_type __ret = traits_type::eof();
const bool __testeof = traits_type::eq_int_type(__c, __ret);
const bool __testout = (_M_mode & ios_base::out
|| _M_mode & ios_base::app);
if (__testout)
{
if (_M_reading)
{
_M_destroy_pback();
const int __gptr_off = _M_get_ext_pos(_M_state_last);
if (_M_seek(__gptr_off, ios_base::cur, _M_state_last)
== pos_type(off_type(-1)))
return __ret;
}
if (this->pbase() < this->pptr())
{
// If appropriate, append the overflow char.
if (!__testeof)
{
*this->pptr() = traits_type::to_char_type(__c);
this->pbump(1);
}
// Convert pending sequence to external representation,
// and output.
if (_M_convert_to_external(this->pbase(),
this->pptr() - this->pbase()))
{
_M_set_buffer(0);
__ret = traits_type::not_eof(__c);
}
}
else if (_M_buf_size > 1)
{
// Overflow in 'uncommitted' mode: set _M_writing, set
// the buffer to the initial 'write' mode, and put __c
// into the buffer.
_M_set_buffer(0);
_M_writing = true;
if (!__testeof)
{
*this->pptr() = traits_type::to_char_type(__c);
this->pbump(1);
}
__ret = traits_type::not_eof(__c);
}
else
{
// Unbuffered.
char_type __conv = traits_type::to_char_type(__c);
if (__testeof || _M_convert_to_external(&__conv, 1))
{
_M_writing = true;
__ret = traits_type::not_eof(__c);
}
}
}
return __ret;
}
template<typename _CharT, typename _Traits>
bool
basic_filebuf<_CharT, _Traits>::
_M_convert_to_external(_CharT* __ibuf, streamsize __ilen)
{
// Sizes of external and pending output.
streamsize __elen;
streamsize __plen;
if (__check_facet(_M_codecvt).always_noconv())
{
__elen = _M_file.xsputn(reinterpret_cast<char*>(__ibuf), __ilen);
__plen = __ilen;
}
else
{
// Worst-case number of external bytes needed.
// XXX Not done encoding() == -1.
streamsize __blen = __ilen * _M_codecvt->max_length();
char* __buf = static_cast<char*>(__builtin_alloca(__blen));
char* __bend;
const char_type* __iend;
codecvt_base::result __r;
__r = _M_codecvt->out(_M_state_cur, __ibuf, __ibuf + __ilen,
__iend, __buf, __buf + __blen, __bend);
if (__r == codecvt_base::ok || __r == codecvt_base::partial)
__blen = __bend - __buf;
else if (__r == codecvt_base::noconv)
{
// Same as the always_noconv case above.
__buf = reinterpret_cast<char*>(__ibuf);
__blen = __ilen;
}
else
__throw_ios_failure(__N("basic_filebuf::_M_convert_to_external "
"conversion error"));
__elen = _M_file.xsputn(__buf, __blen);
__plen = __blen;
// Try once more for partial conversions.
if (__r == codecvt_base::partial && __elen == __plen)
{
const char_type* __iresume = __iend;
streamsize __rlen = this->pptr() - __iend;
__r = _M_codecvt->out(_M_state_cur, __iresume,
__iresume + __rlen, __iend, __buf,
__buf + __blen, __bend);
if (__r != codecvt_base::error)
{
__rlen = __bend - __buf;
__elen = _M_file.xsputn(__buf, __rlen);
__plen = __rlen;
}
else
__throw_ios_failure(__N("basic_filebuf::_M_convert_to_external "
"conversion error"));
}
}
return __elen == __plen;
}
template<typename _CharT, typename _Traits>
streamsize
basic_filebuf<_CharT, _Traits>::
xsgetn(_CharT* __s, streamsize __n)
{
// Clear out pback buffer before going on to the real deal...
streamsize __ret = 0;
if (_M_pback_init)
{
if (__n > 0 && this->gptr() == this->eback())
{
*__s++ = *this->gptr(); // emulate non-underflowing sbumpc
this->gbump(1);
__ret = 1;
--__n;
}
_M_destroy_pback();
}
else if (_M_writing)
{
if (overflow() == traits_type::eof())
return __ret;
_M_set_buffer(-1);
_M_writing = false;
}
// Optimization in the always_noconv() case, to be generalized in the
// future: when __n > __buflen we read directly instead of using the
// buffer repeatedly.
const bool __testin = _M_mode & ios_base::in;
const streamsize __buflen = _M_buf_size > 1 ? _M_buf_size - 1 : 1;
if (__n > __buflen && __check_facet(_M_codecvt).always_noconv()
&& __testin)
{
// First, copy the chars already present in the buffer.
const streamsize __avail = this->egptr() - this->gptr();
if (__avail != 0)
{
traits_type::copy(__s, this->gptr(), __avail);
__s += __avail;
this->setg(this->eback(), this->gptr() + __avail, this->egptr());
__ret += __avail;
__n -= __avail;
}
// Need to loop in case of short reads (relatively common
// with pipes).
streamsize __len;
for (;;)
{
__len = _M_file.xsgetn(reinterpret_cast<char*>(__s), __n);
if (__len == -1)
__throw_ios_failure(__N("basic_filebuf::xsgetn "
"error reading the file"));
if (__len == 0)
break;
__n -= __len;
__ret += __len;
if (__n == 0)
break;
__s += __len;
}
if (__n == 0)
{
// Set _M_reading. Buffer is already in initial 'read' mode.
_M_reading = true;
}
else if (__len == 0)
{
// If end of file is reached, set 'uncommitted'
// mode, thus allowing an immediate write without
// an intervening seek.
_M_set_buffer(-1);
_M_reading = false;
}
}
else
__ret += __streambuf_type::xsgetn(__s, __n);
return __ret;
}
template<typename _CharT, typename _Traits>
streamsize
basic_filebuf<_CharT, _Traits>::
xsputn(const _CharT* __s, streamsize __n)
{
streamsize __ret = 0;
// Optimization in the always_noconv() case, to be generalized in the
// future: when __n is sufficiently large we write directly instead of
// using the buffer.
const bool __testout = (_M_mode & ios_base::out
|| _M_mode & ios_base::app);
if (__check_facet(_M_codecvt).always_noconv()
&& __testout && !_M_reading)
{
// Measurement would reveal the best choice.
const streamsize __chunk = 1ul << 10;
streamsize __bufavail = this->epptr() - this->pptr();
// Don't mistake 'uncommitted' mode buffered with unbuffered.
if (!_M_writing && _M_buf_size > 1)
__bufavail = _M_buf_size - 1;
const streamsize __limit = std::min(__chunk, __bufavail);
if (__n >= __limit)
{
const streamsize __buffill = this->pptr() - this->pbase();
const char* __buf = reinterpret_cast<const char*>(this->pbase());
__ret = _M_file.xsputn_2(__buf, __buffill,
reinterpret_cast<const char*>(__s),
__n);
if (__ret == __buffill + __n)
{
_M_set_buffer(0);
_M_writing = true;
}
if (__ret > __buffill)
__ret -= __buffill;
else
__ret = 0;
}
else
__ret = __streambuf_type::xsputn(__s, __n);
}
else
__ret = __streambuf_type::xsputn(__s, __n);
return __ret;
}
template<typename _CharT, typename _Traits>
typename basic_filebuf<_CharT, _Traits>::__streambuf_type*
basic_filebuf<_CharT, _Traits>::
setbuf(char_type* __s, streamsize __n)
{
if (!this->is_open())
{
if (__s == 0 && __n == 0)
_M_buf_size = 1;
else if (__s && __n > 0)
{
// This is implementation-defined behavior, and assumes that
// an external char_type array of length __n exists and has
// been pre-allocated. If this is not the case, things will
// quickly blow up. When __n > 1, __n - 1 positions will be
// used for the get area, __n - 1 for the put area and 1
// position to host the overflow char of a full put area.
// When __n == 1, 1 position will be used for the get area
// and 0 for the put area, as in the unbuffered case above.
_M_buf = __s;
_M_buf_size = __n;
}
}
return this;
}
// According to 27.8.1.4 p11 - 13, seekoff should ignore the last
// argument (of type openmode).
template<typename _CharT, typename _Traits>
typename basic_filebuf<_CharT, _Traits>::pos_type
basic_filebuf<_CharT, _Traits>::
seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode)
{
int __width = 0;
if (_M_codecvt)
__width = _M_codecvt->encoding();
if (__width < 0)
__width = 0;
pos_type __ret = pos_type(off_type(-1));
const bool __testfail = __off != 0 && __width <= 0;
if (this->is_open() && !__testfail)
{
// tellg and tellp queries do not affect any state, unless
// ! always_noconv and the put sequence is not empty.
// In that case, determining the position requires converting the
// put sequence. That doesn't use ext_buf, so requires a flush.
bool __no_movement = __way == ios_base::cur && __off == 0
&& (!_M_writing || _M_codecvt->always_noconv());
// Ditch any pback buffers to avoid confusion.
if (!__no_movement)
_M_destroy_pback();
// Correct state at destination. Note that this is the correct
// state for the current position during output, because
// codecvt::unshift() returns the state to the initial state.
// This is also the correct state at the end of the file because
// an unshift sequence should have been written at the end.
__state_type __state = _M_state_beg;
off_type __computed_off = __off * __width;
if (_M_reading && __way == ios_base::cur)
{
__state = _M_state_last;
__computed_off += _M_get_ext_pos(__state);
}
if (!__no_movement)
__ret = _M_seek(__computed_off, __way, __state);
else
{
if (_M_writing)
__computed_off = this->pptr() - this->pbase();
off_type __file_off = _M_file.seekoff(0, ios_base::cur);
if (__file_off != off_type(-1))
{
__ret = __file_off + __computed_off;
__ret.state(__state);
}
}
}
return __ret;
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 171. Strange seekpos() semantics due to joint position
// According to the resolution of DR 171, seekpos should ignore the last
// argument (of type openmode).
template<typename _CharT, typename _Traits>
typename basic_filebuf<_CharT, _Traits>::pos_type
basic_filebuf<_CharT, _Traits>::
seekpos(pos_type __pos, ios_base::openmode)
{
pos_type __ret = pos_type(off_type(-1));
if (this->is_open())
{
// Ditch any pback buffers to avoid confusion.
_M_destroy_pback();
__ret = _M_seek(off_type(__pos), ios_base::beg, __pos.state());
}
return __ret;
}
template<typename _CharT, typename _Traits>
typename basic_filebuf<_CharT, _Traits>::pos_type
basic_filebuf<_CharT, _Traits>::
_M_seek(off_type __off, ios_base::seekdir __way, __state_type __state)
{
pos_type __ret = pos_type(off_type(-1));
if (_M_terminate_output())
{
off_type __file_off = _M_file.seekoff(__off, __way);
if (__file_off != off_type(-1))
{
_M_reading = false;
_M_writing = false;
_M_ext_next = _M_ext_end = _M_ext_buf;
_M_set_buffer(-1);
_M_state_cur = __state;
__ret = __file_off;
__ret.state(_M_state_cur);
}
}
return __ret;
}
// Returns the distance from the end of the ext buffer to the point
// corresponding to gptr(). This is a negative value. Updates __state
// from eback() correspondence to gptr().
template<typename _CharT, typename _Traits>
int basic_filebuf<_CharT, _Traits>::
_M_get_ext_pos(__state_type& __state)
{
if (_M_codecvt->always_noconv())
return this->gptr() - this->egptr();
else
{
// Calculate offset from _M_ext_buf that corresponds to
// gptr(). Precondition: __state == _M_state_last, which
// corresponds to eback().
const int __gptr_off =
_M_codecvt->length(__state, _M_ext_buf, _M_ext_next,
this->gptr() - this->eback());
return _M_ext_buf + __gptr_off - _M_ext_end;
}
}
template<typename _CharT, typename _Traits>
bool
basic_filebuf<_CharT, _Traits>::
_M_terminate_output()
{
// Part one: update the output sequence.
bool __testvalid = true;
if (this->pbase() < this->pptr())
{
const int_type __tmp = this->overflow();
if (traits_type::eq_int_type(__tmp, traits_type::eof()))
__testvalid = false;
}
// Part two: output unshift sequence.
if (_M_writing && !__check_facet(_M_codecvt).always_noconv()
&& __testvalid)
{
// Note: this value is arbitrary, since there is no way to
// get the length of the unshift sequence from codecvt,
// without calling unshift.
const size_t __blen = 128;
char __buf[__blen];
codecvt_base::result __r;
streamsize __ilen = 0;
do
{
char* __next;
__r = _M_codecvt->unshift(_M_state_cur, __buf,
__buf + __blen, __next);
if (__r == codecvt_base::error)
__testvalid = false;
else if (__r == codecvt_base::ok ||
__r == codecvt_base::partial)
{
__ilen = __next - __buf;
if (__ilen > 0)
{
const streamsize __elen = _M_file.xsputn(__buf, __ilen);
if (__elen != __ilen)
__testvalid = false;
}
}
}
while (__r == codecvt_base::partial && __ilen > 0 && __testvalid);
if (__testvalid)
{
// This second call to overflow() is required by the standard,
// but it's not clear why it's needed, since the output buffer
// should be empty by this point (it should have been emptied
// in the first call to overflow()).
const int_type __tmp = this->overflow();
if (traits_type::eq_int_type(__tmp, traits_type::eof()))
__testvalid = false;
}
}
return __testvalid;
}
template<typename _CharT, typename _Traits>
int
basic_filebuf<_CharT, _Traits>::
sync()
{
// Make sure that the internal buffer resyncs its idea of
// the file position with the external file.
int __ret = 0;
if (this->pbase() < this->pptr())
{
const int_type __tmp = this->overflow();
if (traits_type::eq_int_type(__tmp, traits_type::eof()))
__ret = -1;
}
return __ret;
}
template<typename _CharT, typename _Traits>
void
basic_filebuf<_CharT, _Traits>::
imbue(const locale& __loc)
{
bool __testvalid = true;
const __codecvt_type* _M_codecvt_tmp = 0;
if (__builtin_expect(has_facet<__codecvt_type>(__loc), true))
_M_codecvt_tmp = &use_facet<__codecvt_type>(__loc);
if (this->is_open())
{
// encoding() == -1 is ok only at the beginning.
if ((_M_reading || _M_writing)
&& __check_facet(_M_codecvt).encoding() == -1)
__testvalid = false;
else
{
if (_M_reading)
{
if (__check_facet(_M_codecvt).always_noconv())
{
if (_M_codecvt_tmp
&& !__check_facet(_M_codecvt_tmp).always_noconv())
__testvalid = this->seekoff(0, ios_base::cur, _M_mode)
!= pos_type(off_type(-1));
}
else
{
// External position corresponding to gptr().
_M_ext_next = _M_ext_buf
+ _M_codecvt->length(_M_state_last, _M_ext_buf,
_M_ext_next,
this->gptr() - this->eback());
const streamsize __remainder = _M_ext_end - _M_ext_next;
if (__remainder)
__builtin_memmove(_M_ext_buf, _M_ext_next, __remainder);
_M_ext_next = _M_ext_buf;
_M_ext_end = _M_ext_buf + __remainder;
_M_set_buffer(-1);
_M_state_last = _M_state_cur = _M_state_beg;
}
}
else if (_M_writing && (__testvalid = _M_terminate_output()))
_M_set_buffer(-1);
}
}
if (__testvalid)
_M_codecvt = _M_codecvt_tmp;
else
_M_codecvt = 0;
}
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
#if _GLIBCXX_EXTERN_TEMPLATE
extern template class basic_filebuf<char>;
extern template class basic_ifstream<char>;
extern template class basic_ofstream<char>;
extern template class basic_fstream<char>;
#ifdef _GLIBCXX_USE_WCHAR_T
extern template class basic_filebuf<wchar_t>;
extern template class basic_ifstream<wchar_t>;
extern template class basic_ofstream<wchar_t>;
extern template class basic_fstream<wchar_t>;
#endif
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif
c++/8/bits/stl_algo.h 0000644 00000642426 15201526705 0010222 0 ustar 00 // Algorithm implementation -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1996
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file bits/stl_algo.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{algorithm}
*/
#ifndef _STL_ALGO_H
#define _STL_ALGO_H 1
#include <cstdlib> // for rand
#include <bits/algorithmfwd.h>
#include <bits/stl_heap.h>
#include <bits/stl_tempbuf.h> // for _Temporary_buffer
#include <bits/predefined_ops.h>
#if __cplusplus >= 201103L
#include <bits/uniform_int_dist.h>
#endif
// See concept_check.h for the __glibcxx_*_requires macros.
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/// Swaps the median value of *__a, *__b and *__c under __comp to *__result
template<typename _Iterator, typename _Compare>
void
__move_median_to_first(_Iterator __result,_Iterator __a, _Iterator __b,
_Iterator __c, _Compare __comp)
{
if (__comp(__a, __b))
{
if (__comp(__b, __c))
std::iter_swap(__result, __b);
else if (__comp(__a, __c))
std::iter_swap(__result, __c);
else
std::iter_swap(__result, __a);
}
else if (__comp(__a, __c))
std::iter_swap(__result, __a);
else if (__comp(__b, __c))
std::iter_swap(__result, __c);
else
std::iter_swap(__result, __b);
}
/// This is an overload used by find algos for the Input Iterator case.
template<typename _InputIterator, typename _Predicate>
inline _InputIterator
__find_if(_InputIterator __first, _InputIterator __last,
_Predicate __pred, input_iterator_tag)
{
while (__first != __last && !__pred(__first))
++__first;
return __first;
}
/// This is an overload used by find algos for the RAI case.
template<typename _RandomAccessIterator, typename _Predicate>
_RandomAccessIterator
__find_if(_RandomAccessIterator __first, _RandomAccessIterator __last,
_Predicate __pred, random_access_iterator_tag)
{
typename iterator_traits<_RandomAccessIterator>::difference_type
__trip_count = (__last - __first) >> 2;
for (; __trip_count > 0; --__trip_count)
{
if (__pred(__first))
return __first;
++__first;
if (__pred(__first))
return __first;
++__first;
if (__pred(__first))
return __first;
++__first;
if (__pred(__first))
return __first;
++__first;
}
switch (__last - __first)
{
case 3:
if (__pred(__first))
return __first;
++__first;
case 2:
if (__pred(__first))
return __first;
++__first;
case 1:
if (__pred(__first))
return __first;
++__first;
case 0:
default:
return __last;
}
}
template<typename _Iterator, typename _Predicate>
inline _Iterator
__find_if(_Iterator __first, _Iterator __last, _Predicate __pred)
{
return __find_if(__first, __last, __pred,
std::__iterator_category(__first));
}
/// Provided for stable_partition to use.
template<typename _InputIterator, typename _Predicate>
inline _InputIterator
__find_if_not(_InputIterator __first, _InputIterator __last,
_Predicate __pred)
{
return std::__find_if(__first, __last,
__gnu_cxx::__ops::__negate(__pred),
std::__iterator_category(__first));
}
/// Like find_if_not(), but uses and updates a count of the
/// remaining range length instead of comparing against an end
/// iterator.
template<typename _InputIterator, typename _Predicate, typename _Distance>
_InputIterator
__find_if_not_n(_InputIterator __first, _Distance& __len, _Predicate __pred)
{
for (; __len; --__len, (void) ++__first)
if (!__pred(__first))
break;
return __first;
}
// set_difference
// set_intersection
// set_symmetric_difference
// set_union
// for_each
// find
// find_if
// find_first_of
// adjacent_find
// count
// count_if
// search
template<typename _ForwardIterator1, typename _ForwardIterator2,
typename _BinaryPredicate>
_ForwardIterator1
__search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2, _ForwardIterator2 __last2,
_BinaryPredicate __predicate)
{
// Test for empty ranges
if (__first1 == __last1 || __first2 == __last2)
return __first1;
// Test for a pattern of length 1.
_ForwardIterator2 __p1(__first2);
if (++__p1 == __last2)
return std::__find_if(__first1, __last1,
__gnu_cxx::__ops::__iter_comp_iter(__predicate, __first2));
// General case.
_ForwardIterator2 __p;
_ForwardIterator1 __current = __first1;
for (;;)
{
__first1 =
std::__find_if(__first1, __last1,
__gnu_cxx::__ops::__iter_comp_iter(__predicate, __first2));
if (__first1 == __last1)
return __last1;
__p = __p1;
__current = __first1;
if (++__current == __last1)
return __last1;
while (__predicate(__current, __p))
{
if (++__p == __last2)
return __first1;
if (++__current == __last1)
return __last1;
}
++__first1;
}
return __first1;
}
// search_n
/**
* This is an helper function for search_n overloaded for forward iterators.
*/
template<typename _ForwardIterator, typename _Integer,
typename _UnaryPredicate>
_ForwardIterator
__search_n_aux(_ForwardIterator __first, _ForwardIterator __last,
_Integer __count, _UnaryPredicate __unary_pred,
std::forward_iterator_tag)
{
__first = std::__find_if(__first, __last, __unary_pred);
while (__first != __last)
{
typename iterator_traits<_ForwardIterator>::difference_type
__n = __count;
_ForwardIterator __i = __first;
++__i;
while (__i != __last && __n != 1 && __unary_pred(__i))
{
++__i;
--__n;
}
if (__n == 1)
return __first;
if (__i == __last)
return __last;
__first = std::__find_if(++__i, __last, __unary_pred);
}
return __last;
}
/**
* This is an helper function for search_n overloaded for random access
* iterators.
*/
template<typename _RandomAccessIter, typename _Integer,
typename _UnaryPredicate>
_RandomAccessIter
__search_n_aux(_RandomAccessIter __first, _RandomAccessIter __last,
_Integer __count, _UnaryPredicate __unary_pred,
std::random_access_iterator_tag)
{
typedef typename std::iterator_traits<_RandomAccessIter>::difference_type
_DistanceType;
_DistanceType __tailSize = __last - __first;
_DistanceType __remainder = __count;
while (__remainder <= __tailSize) // the main loop...
{
__first += __remainder;
__tailSize -= __remainder;
// __first here is always pointing to one past the last element of
// next possible match.
_RandomAccessIter __backTrack = __first;
while (__unary_pred(--__backTrack))
{
if (--__remainder == 0)
return (__first - __count); // Success
}
__remainder = __count + 1 - (__first - __backTrack);
}
return __last; // Failure
}
template<typename _ForwardIterator, typename _Integer,
typename _UnaryPredicate>
_ForwardIterator
__search_n(_ForwardIterator __first, _ForwardIterator __last,
_Integer __count,
_UnaryPredicate __unary_pred)
{
if (__count <= 0)
return __first;
if (__count == 1)
return std::__find_if(__first, __last, __unary_pred);
return std::__search_n_aux(__first, __last, __count, __unary_pred,
std::__iterator_category(__first));
}
// find_end for forward iterators.
template<typename _ForwardIterator1, typename _ForwardIterator2,
typename _BinaryPredicate>
_ForwardIterator1
__find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2, _ForwardIterator2 __last2,
forward_iterator_tag, forward_iterator_tag,
_BinaryPredicate __comp)
{
if (__first2 == __last2)
return __last1;
_ForwardIterator1 __result = __last1;
while (1)
{
_ForwardIterator1 __new_result
= std::__search(__first1, __last1, __first2, __last2, __comp);
if (__new_result == __last1)
return __result;
else
{
__result = __new_result;
__first1 = __new_result;
++__first1;
}
}
}
// find_end for bidirectional iterators (much faster).
template<typename _BidirectionalIterator1, typename _BidirectionalIterator2,
typename _BinaryPredicate>
_BidirectionalIterator1
__find_end(_BidirectionalIterator1 __first1,
_BidirectionalIterator1 __last1,
_BidirectionalIterator2 __first2,
_BidirectionalIterator2 __last2,
bidirectional_iterator_tag, bidirectional_iterator_tag,
_BinaryPredicate __comp)
{
// concept requirements
__glibcxx_function_requires(_BidirectionalIteratorConcept<
_BidirectionalIterator1>)
__glibcxx_function_requires(_BidirectionalIteratorConcept<
_BidirectionalIterator2>)
typedef reverse_iterator<_BidirectionalIterator1> _RevIterator1;
typedef reverse_iterator<_BidirectionalIterator2> _RevIterator2;
_RevIterator1 __rlast1(__first1);
_RevIterator2 __rlast2(__first2);
_RevIterator1 __rresult = std::__search(_RevIterator1(__last1), __rlast1,
_RevIterator2(__last2), __rlast2,
__comp);
if (__rresult == __rlast1)
return __last1;
else
{
_BidirectionalIterator1 __result = __rresult.base();
std::advance(__result, -std::distance(__first2, __last2));
return __result;
}
}
/**
* @brief Find last matching subsequence in a sequence.
* @ingroup non_mutating_algorithms
* @param __first1 Start of range to search.
* @param __last1 End of range to search.
* @param __first2 Start of sequence to match.
* @param __last2 End of sequence to match.
* @return The last iterator @c i in the range
* @p [__first1,__last1-(__last2-__first2)) such that @c *(i+N) ==
* @p *(__first2+N) for each @c N in the range @p
* [0,__last2-__first2), or @p __last1 if no such iterator exists.
*
* Searches the range @p [__first1,__last1) for a sub-sequence that
* compares equal value-by-value with the sequence given by @p
* [__first2,__last2) and returns an iterator to the __first
* element of the sub-sequence, or @p __last1 if the sub-sequence
* is not found. The sub-sequence will be the last such
* subsequence contained in [__first1,__last1).
*
* Because the sub-sequence must lie completely within the range @p
* [__first1,__last1) it must start at a position less than @p
* __last1-(__last2-__first2) where @p __last2-__first2 is the
* length of the sub-sequence. This means that the returned
* iterator @c i will be in the range @p
* [__first1,__last1-(__last2-__first2))
*/
template<typename _ForwardIterator1, typename _ForwardIterator2>
inline _ForwardIterator1
find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2, _ForwardIterator2 __last2)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator1>)
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator2>)
__glibcxx_function_requires(_EqualOpConcept<
typename iterator_traits<_ForwardIterator1>::value_type,
typename iterator_traits<_ForwardIterator2>::value_type>)
__glibcxx_requires_valid_range(__first1, __last1);
__glibcxx_requires_valid_range(__first2, __last2);
return std::__find_end(__first1, __last1, __first2, __last2,
std::__iterator_category(__first1),
std::__iterator_category(__first2),
__gnu_cxx::__ops::__iter_equal_to_iter());
}
/**
* @brief Find last matching subsequence in a sequence using a predicate.
* @ingroup non_mutating_algorithms
* @param __first1 Start of range to search.
* @param __last1 End of range to search.
* @param __first2 Start of sequence to match.
* @param __last2 End of sequence to match.
* @param __comp The predicate to use.
* @return The last iterator @c i in the range @p
* [__first1,__last1-(__last2-__first2)) such that @c
* predicate(*(i+N), @p (__first2+N)) is true for each @c N in the
* range @p [0,__last2-__first2), or @p __last1 if no such iterator
* exists.
*
* Searches the range @p [__first1,__last1) for a sub-sequence that
* compares equal value-by-value with the sequence given by @p
* [__first2,__last2) using comp as a predicate and returns an
* iterator to the first element of the sub-sequence, or @p __last1
* if the sub-sequence is not found. The sub-sequence will be the
* last such subsequence contained in [__first,__last1).
*
* Because the sub-sequence must lie completely within the range @p
* [__first1,__last1) it must start at a position less than @p
* __last1-(__last2-__first2) where @p __last2-__first2 is the
* length of the sub-sequence. This means that the returned
* iterator @c i will be in the range @p
* [__first1,__last1-(__last2-__first2))
*/
template<typename _ForwardIterator1, typename _ForwardIterator2,
typename _BinaryPredicate>
inline _ForwardIterator1
find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2, _ForwardIterator2 __last2,
_BinaryPredicate __comp)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator1>)
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator2>)
__glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate,
typename iterator_traits<_ForwardIterator1>::value_type,
typename iterator_traits<_ForwardIterator2>::value_type>)
__glibcxx_requires_valid_range(__first1, __last1);
__glibcxx_requires_valid_range(__first2, __last2);
return std::__find_end(__first1, __last1, __first2, __last2,
std::__iterator_category(__first1),
std::__iterator_category(__first2),
__gnu_cxx::__ops::__iter_comp_iter(__comp));
}
#if __cplusplus >= 201103L
/**
* @brief Checks that a predicate is true for all the elements
* of a sequence.
* @ingroup non_mutating_algorithms
* @param __first An input iterator.
* @param __last An input iterator.
* @param __pred A predicate.
* @return True if the check is true, false otherwise.
*
* Returns true if @p __pred is true for each element in the range
* @p [__first,__last), and false otherwise.
*/
template<typename _InputIterator, typename _Predicate>
inline bool
all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
{ return __last == std::find_if_not(__first, __last, __pred); }
/**
* @brief Checks that a predicate is false for all the elements
* of a sequence.
* @ingroup non_mutating_algorithms
* @param __first An input iterator.
* @param __last An input iterator.
* @param __pred A predicate.
* @return True if the check is true, false otherwise.
*
* Returns true if @p __pred is false for each element in the range
* @p [__first,__last), and false otherwise.
*/
template<typename _InputIterator, typename _Predicate>
inline bool
none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
{ return __last == _GLIBCXX_STD_A::find_if(__first, __last, __pred); }
/**
* @brief Checks that a predicate is false for at least an element
* of a sequence.
* @ingroup non_mutating_algorithms
* @param __first An input iterator.
* @param __last An input iterator.
* @param __pred A predicate.
* @return True if the check is true, false otherwise.
*
* Returns true if an element exists in the range @p
* [__first,__last) such that @p __pred is true, and false
* otherwise.
*/
template<typename _InputIterator, typename _Predicate>
inline bool
any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
{ return !std::none_of(__first, __last, __pred); }
/**
* @brief Find the first element in a sequence for which a
* predicate is false.
* @ingroup non_mutating_algorithms
* @param __first An input iterator.
* @param __last An input iterator.
* @param __pred A predicate.
* @return The first iterator @c i in the range @p [__first,__last)
* such that @p __pred(*i) is false, or @p __last if no such iterator exists.
*/
template<typename _InputIterator, typename _Predicate>
inline _InputIterator
find_if_not(_InputIterator __first, _InputIterator __last,
_Predicate __pred)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
typename iterator_traits<_InputIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
return std::__find_if_not(__first, __last,
__gnu_cxx::__ops::__pred_iter(__pred));
}
/**
* @brief Checks whether the sequence is partitioned.
* @ingroup mutating_algorithms
* @param __first An input iterator.
* @param __last An input iterator.
* @param __pred A predicate.
* @return True if the range @p [__first,__last) is partioned by @p __pred,
* i.e. if all elements that satisfy @p __pred appear before those that
* do not.
*/
template<typename _InputIterator, typename _Predicate>
inline bool
is_partitioned(_InputIterator __first, _InputIterator __last,
_Predicate __pred)
{
__first = std::find_if_not(__first, __last, __pred);
if (__first == __last)
return true;
++__first;
return std::none_of(__first, __last, __pred);
}
/**
* @brief Find the partition point of a partitioned range.
* @ingroup mutating_algorithms
* @param __first An iterator.
* @param __last Another iterator.
* @param __pred A predicate.
* @return An iterator @p mid such that @p all_of(__first, mid, __pred)
* and @p none_of(mid, __last, __pred) are both true.
*/
template<typename _ForwardIterator, typename _Predicate>
_ForwardIterator
partition_point(_ForwardIterator __first, _ForwardIterator __last,
_Predicate __pred)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
typename iterator_traits<_ForwardIterator>::value_type>)
// A specific debug-mode test will be necessary...
__glibcxx_requires_valid_range(__first, __last);
typedef typename iterator_traits<_ForwardIterator>::difference_type
_DistanceType;
_DistanceType __len = std::distance(__first, __last);
_DistanceType __half;
_ForwardIterator __middle;
while (__len > 0)
{
__half = __len >> 1;
__middle = __first;
std::advance(__middle, __half);
if (__pred(*__middle))
{
__first = __middle;
++__first;
__len = __len - __half - 1;
}
else
__len = __half;
}
return __first;
}
#endif
template<typename _InputIterator, typename _OutputIterator,
typename _Predicate>
_OutputIterator
__remove_copy_if(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _Predicate __pred)
{
for (; __first != __last; ++__first)
if (!__pred(__first))
{
*__result = *__first;
++__result;
}
return __result;
}
/**
* @brief Copy a sequence, removing elements of a given value.
* @ingroup mutating_algorithms
* @param __first An input iterator.
* @param __last An input iterator.
* @param __result An output iterator.
* @param __value The value to be removed.
* @return An iterator designating the end of the resulting sequence.
*
* Copies each element in the range @p [__first,__last) not equal
* to @p __value to the range beginning at @p __result.
* remove_copy() is stable, so the relative order of elements that
* are copied is unchanged.
*/
template<typename _InputIterator, typename _OutputIterator, typename _Tp>
inline _OutputIterator
remove_copy(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, const _Tp& __value)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_InputIterator>::value_type>)
__glibcxx_function_requires(_EqualOpConcept<
typename iterator_traits<_InputIterator>::value_type, _Tp>)
__glibcxx_requires_valid_range(__first, __last);
return std::__remove_copy_if(__first, __last, __result,
__gnu_cxx::__ops::__iter_equals_val(__value));
}
/**
* @brief Copy a sequence, removing elements for which a predicate is true.
* @ingroup mutating_algorithms
* @param __first An input iterator.
* @param __last An input iterator.
* @param __result An output iterator.
* @param __pred A predicate.
* @return An iterator designating the end of the resulting sequence.
*
* Copies each element in the range @p [__first,__last) for which
* @p __pred returns false to the range beginning at @p __result.
*
* remove_copy_if() is stable, so the relative order of elements that are
* copied is unchanged.
*/
template<typename _InputIterator, typename _OutputIterator,
typename _Predicate>
inline _OutputIterator
remove_copy_if(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _Predicate __pred)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_InputIterator>::value_type>)
__glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
typename iterator_traits<_InputIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
return std::__remove_copy_if(__first, __last, __result,
__gnu_cxx::__ops::__pred_iter(__pred));
}
#if __cplusplus >= 201103L
/**
* @brief Copy the elements of a sequence for which a predicate is true.
* @ingroup mutating_algorithms
* @param __first An input iterator.
* @param __last An input iterator.
* @param __result An output iterator.
* @param __pred A predicate.
* @return An iterator designating the end of the resulting sequence.
*
* Copies each element in the range @p [__first,__last) for which
* @p __pred returns true to the range beginning at @p __result.
*
* copy_if() is stable, so the relative order of elements that are
* copied is unchanged.
*/
template<typename _InputIterator, typename _OutputIterator,
typename _Predicate>
_OutputIterator
copy_if(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _Predicate __pred)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_InputIterator>::value_type>)
__glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
typename iterator_traits<_InputIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
for (; __first != __last; ++__first)
if (__pred(*__first))
{
*__result = *__first;
++__result;
}
return __result;
}
template<typename _InputIterator, typename _Size, typename _OutputIterator>
_OutputIterator
__copy_n(_InputIterator __first, _Size __n,
_OutputIterator __result, input_iterator_tag)
{
if (__n > 0)
{
while (true)
{
*__result = *__first;
++__result;
if (--__n > 0)
++__first;
else
break;
}
}
return __result;
}
template<typename _RandomAccessIterator, typename _Size,
typename _OutputIterator>
inline _OutputIterator
__copy_n(_RandomAccessIterator __first, _Size __n,
_OutputIterator __result, random_access_iterator_tag)
{ return std::copy(__first, __first + __n, __result); }
/**
* @brief Copies the range [first,first+n) into [result,result+n).
* @ingroup mutating_algorithms
* @param __first An input iterator.
* @param __n The number of elements to copy.
* @param __result An output iterator.
* @return result+n.
*
* This inline function will boil down to a call to @c memmove whenever
* possible. Failing that, if random access iterators are passed, then the
* loop count will be known (and therefore a candidate for compiler
* optimizations such as unrolling).
*/
template<typename _InputIterator, typename _Size, typename _OutputIterator>
inline _OutputIterator
copy_n(_InputIterator __first, _Size __n, _OutputIterator __result)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_InputIterator>::value_type>)
return std::__copy_n(__first, __n, __result,
std::__iterator_category(__first));
}
/**
* @brief Copy the elements of a sequence to separate output sequences
* depending on the truth value of a predicate.
* @ingroup mutating_algorithms
* @param __first An input iterator.
* @param __last An input iterator.
* @param __out_true An output iterator.
* @param __out_false An output iterator.
* @param __pred A predicate.
* @return A pair designating the ends of the resulting sequences.
*
* Copies each element in the range @p [__first,__last) for which
* @p __pred returns true to the range beginning at @p out_true
* and each element for which @p __pred returns false to @p __out_false.
*/
template<typename _InputIterator, typename _OutputIterator1,
typename _OutputIterator2, typename _Predicate>
pair<_OutputIterator1, _OutputIterator2>
partition_copy(_InputIterator __first, _InputIterator __last,
_OutputIterator1 __out_true, _OutputIterator2 __out_false,
_Predicate __pred)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator1,
typename iterator_traits<_InputIterator>::value_type>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator2,
typename iterator_traits<_InputIterator>::value_type>)
__glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
typename iterator_traits<_InputIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
for (; __first != __last; ++__first)
if (__pred(*__first))
{
*__out_true = *__first;
++__out_true;
}
else
{
*__out_false = *__first;
++__out_false;
}
return pair<_OutputIterator1, _OutputIterator2>(__out_true, __out_false);
}
#endif
template<typename _ForwardIterator, typename _Predicate>
_ForwardIterator
__remove_if(_ForwardIterator __first, _ForwardIterator __last,
_Predicate __pred)
{
__first = std::__find_if(__first, __last, __pred);
if (__first == __last)
return __first;
_ForwardIterator __result = __first;
++__first;
for (; __first != __last; ++__first)
if (!__pred(__first))
{
*__result = _GLIBCXX_MOVE(*__first);
++__result;
}
return __result;
}
/**
* @brief Remove elements from a sequence.
* @ingroup mutating_algorithms
* @param __first An input iterator.
* @param __last An input iterator.
* @param __value The value to be removed.
* @return An iterator designating the end of the resulting sequence.
*
* All elements equal to @p __value are removed from the range
* @p [__first,__last).
*
* remove() is stable, so the relative order of elements that are
* not removed is unchanged.
*
* Elements between the end of the resulting sequence and @p __last
* are still present, but their value is unspecified.
*/
template<typename _ForwardIterator, typename _Tp>
inline _ForwardIterator
remove(_ForwardIterator __first, _ForwardIterator __last,
const _Tp& __value)
{
// concept requirements
__glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
_ForwardIterator>)
__glibcxx_function_requires(_EqualOpConcept<
typename iterator_traits<_ForwardIterator>::value_type, _Tp>)
__glibcxx_requires_valid_range(__first, __last);
return std::__remove_if(__first, __last,
__gnu_cxx::__ops::__iter_equals_val(__value));
}
/**
* @brief Remove elements from a sequence using a predicate.
* @ingroup mutating_algorithms
* @param __first A forward iterator.
* @param __last A forward iterator.
* @param __pred A predicate.
* @return An iterator designating the end of the resulting sequence.
*
* All elements for which @p __pred returns true are removed from the range
* @p [__first,__last).
*
* remove_if() is stable, so the relative order of elements that are
* not removed is unchanged.
*
* Elements between the end of the resulting sequence and @p __last
* are still present, but their value is unspecified.
*/
template<typename _ForwardIterator, typename _Predicate>
inline _ForwardIterator
remove_if(_ForwardIterator __first, _ForwardIterator __last,
_Predicate __pred)
{
// concept requirements
__glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
_ForwardIterator>)
__glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
return std::__remove_if(__first, __last,
__gnu_cxx::__ops::__pred_iter(__pred));
}
template<typename _ForwardIterator, typename _BinaryPredicate>
_ForwardIterator
__adjacent_find(_ForwardIterator __first, _ForwardIterator __last,
_BinaryPredicate __binary_pred)
{
if (__first == __last)
return __last;
_ForwardIterator __next = __first;
while (++__next != __last)
{
if (__binary_pred(__first, __next))
return __first;
__first = __next;
}
return __last;
}
template<typename _ForwardIterator, typename _BinaryPredicate>
_ForwardIterator
__unique(_ForwardIterator __first, _ForwardIterator __last,
_BinaryPredicate __binary_pred)
{
// Skip the beginning, if already unique.
__first = std::__adjacent_find(__first, __last, __binary_pred);
if (__first == __last)
return __last;
// Do the real copy work.
_ForwardIterator __dest = __first;
++__first;
while (++__first != __last)
if (!__binary_pred(__dest, __first))
*++__dest = _GLIBCXX_MOVE(*__first);
return ++__dest;
}
/**
* @brief Remove consecutive duplicate values from a sequence.
* @ingroup mutating_algorithms
* @param __first A forward iterator.
* @param __last A forward iterator.
* @return An iterator designating the end of the resulting sequence.
*
* Removes all but the first element from each group of consecutive
* values that compare equal.
* unique() is stable, so the relative order of elements that are
* not removed is unchanged.
* Elements between the end of the resulting sequence and @p __last
* are still present, but their value is unspecified.
*/
template<typename _ForwardIterator>
inline _ForwardIterator
unique(_ForwardIterator __first, _ForwardIterator __last)
{
// concept requirements
__glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
_ForwardIterator>)
__glibcxx_function_requires(_EqualityComparableConcept<
typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
return std::__unique(__first, __last,
__gnu_cxx::__ops::__iter_equal_to_iter());
}
/**
* @brief Remove consecutive values from a sequence using a predicate.
* @ingroup mutating_algorithms
* @param __first A forward iterator.
* @param __last A forward iterator.
* @param __binary_pred A binary predicate.
* @return An iterator designating the end of the resulting sequence.
*
* Removes all but the first element from each group of consecutive
* values for which @p __binary_pred returns true.
* unique() is stable, so the relative order of elements that are
* not removed is unchanged.
* Elements between the end of the resulting sequence and @p __last
* are still present, but their value is unspecified.
*/
template<typename _ForwardIterator, typename _BinaryPredicate>
inline _ForwardIterator
unique(_ForwardIterator __first, _ForwardIterator __last,
_BinaryPredicate __binary_pred)
{
// concept requirements
__glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
_ForwardIterator>)
__glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate,
typename iterator_traits<_ForwardIterator>::value_type,
typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
return std::__unique(__first, __last,
__gnu_cxx::__ops::__iter_comp_iter(__binary_pred));
}
/**
* This is an uglified
* unique_copy(_InputIterator, _InputIterator, _OutputIterator,
* _BinaryPredicate)
* overloaded for forward iterators and output iterator as result.
*/
template<typename _ForwardIterator, typename _OutputIterator,
typename _BinaryPredicate>
_OutputIterator
__unique_copy(_ForwardIterator __first, _ForwardIterator __last,
_OutputIterator __result, _BinaryPredicate __binary_pred,
forward_iterator_tag, output_iterator_tag)
{
// concept requirements -- iterators already checked
__glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate,
typename iterator_traits<_ForwardIterator>::value_type,
typename iterator_traits<_ForwardIterator>::value_type>)
_ForwardIterator __next = __first;
*__result = *__first;
while (++__next != __last)
if (!__binary_pred(__first, __next))
{
__first = __next;
*++__result = *__first;
}
return ++__result;
}
/**
* This is an uglified
* unique_copy(_InputIterator, _InputIterator, _OutputIterator,
* _BinaryPredicate)
* overloaded for input iterators and output iterator as result.
*/
template<typename _InputIterator, typename _OutputIterator,
typename _BinaryPredicate>
_OutputIterator
__unique_copy(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _BinaryPredicate __binary_pred,
input_iterator_tag, output_iterator_tag)
{
// concept requirements -- iterators already checked
__glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate,
typename iterator_traits<_InputIterator>::value_type,
typename iterator_traits<_InputIterator>::value_type>)
typename iterator_traits<_InputIterator>::value_type __value = *__first;
__decltype(__gnu_cxx::__ops::__iter_comp_val(__binary_pred))
__rebound_pred
= __gnu_cxx::__ops::__iter_comp_val(__binary_pred);
*__result = __value;
while (++__first != __last)
if (!__rebound_pred(__first, __value))
{
__value = *__first;
*++__result = __value;
}
return ++__result;
}
/**
* This is an uglified
* unique_copy(_InputIterator, _InputIterator, _OutputIterator,
* _BinaryPredicate)
* overloaded for input iterators and forward iterator as result.
*/
template<typename _InputIterator, typename _ForwardIterator,
typename _BinaryPredicate>
_ForwardIterator
__unique_copy(_InputIterator __first, _InputIterator __last,
_ForwardIterator __result, _BinaryPredicate __binary_pred,
input_iterator_tag, forward_iterator_tag)
{
// concept requirements -- iterators already checked
__glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate,
typename iterator_traits<_ForwardIterator>::value_type,
typename iterator_traits<_InputIterator>::value_type>)
*__result = *__first;
while (++__first != __last)
if (!__binary_pred(__result, __first))
*++__result = *__first;
return ++__result;
}
/**
* This is an uglified reverse(_BidirectionalIterator,
* _BidirectionalIterator)
* overloaded for bidirectional iterators.
*/
template<typename _BidirectionalIterator>
void
__reverse(_BidirectionalIterator __first, _BidirectionalIterator __last,
bidirectional_iterator_tag)
{
while (true)
if (__first == __last || __first == --__last)
return;
else
{
std::iter_swap(__first, __last);
++__first;
}
}
/**
* This is an uglified reverse(_BidirectionalIterator,
* _BidirectionalIterator)
* overloaded for random access iterators.
*/
template<typename _RandomAccessIterator>
void
__reverse(_RandomAccessIterator __first, _RandomAccessIterator __last,
random_access_iterator_tag)
{
if (__first == __last)
return;
--__last;
while (__first < __last)
{
std::iter_swap(__first, __last);
++__first;
--__last;
}
}
/**
* @brief Reverse a sequence.
* @ingroup mutating_algorithms
* @param __first A bidirectional iterator.
* @param __last A bidirectional iterator.
* @return reverse() returns no value.
*
* Reverses the order of the elements in the range @p [__first,__last),
* so that the first element becomes the last etc.
* For every @c i such that @p 0<=i<=(__last-__first)/2), @p reverse()
* swaps @p *(__first+i) and @p *(__last-(i+1))
*/
template<typename _BidirectionalIterator>
inline void
reverse(_BidirectionalIterator __first, _BidirectionalIterator __last)
{
// concept requirements
__glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept<
_BidirectionalIterator>)
__glibcxx_requires_valid_range(__first, __last);
std::__reverse(__first, __last, std::__iterator_category(__first));
}
/**
* @brief Copy a sequence, reversing its elements.
* @ingroup mutating_algorithms
* @param __first A bidirectional iterator.
* @param __last A bidirectional iterator.
* @param __result An output iterator.
* @return An iterator designating the end of the resulting sequence.
*
* Copies the elements in the range @p [__first,__last) to the
* range @p [__result,__result+(__last-__first)) such that the
* order of the elements is reversed. For every @c i such that @p
* 0<=i<=(__last-__first), @p reverse_copy() performs the
* assignment @p *(__result+(__last-__first)-1-i) = *(__first+i).
* The ranges @p [__first,__last) and @p
* [__result,__result+(__last-__first)) must not overlap.
*/
template<typename _BidirectionalIterator, typename _OutputIterator>
_OutputIterator
reverse_copy(_BidirectionalIterator __first, _BidirectionalIterator __last,
_OutputIterator __result)
{
// concept requirements
__glibcxx_function_requires(_BidirectionalIteratorConcept<
_BidirectionalIterator>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_BidirectionalIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
while (__first != __last)
{
--__last;
*__result = *__last;
++__result;
}
return __result;
}
/**
* This is a helper function for the rotate algorithm specialized on RAIs.
* It returns the greatest common divisor of two integer values.
*/
template<typename _EuclideanRingElement>
_EuclideanRingElement
__gcd(_EuclideanRingElement __m, _EuclideanRingElement __n)
{
while (__n != 0)
{
_EuclideanRingElement __t = __m % __n;
__m = __n;
__n = __t;
}
return __m;
}
inline namespace _V2
{
/// This is a helper function for the rotate algorithm.
template<typename _ForwardIterator>
_ForwardIterator
__rotate(_ForwardIterator __first,
_ForwardIterator __middle,
_ForwardIterator __last,
forward_iterator_tag)
{
if (__first == __middle)
return __last;
else if (__last == __middle)
return __first;
_ForwardIterator __first2 = __middle;
do
{
std::iter_swap(__first, __first2);
++__first;
++__first2;
if (__first == __middle)
__middle = __first2;
}
while (__first2 != __last);
_ForwardIterator __ret = __first;
__first2 = __middle;
while (__first2 != __last)
{
std::iter_swap(__first, __first2);
++__first;
++__first2;
if (__first == __middle)
__middle = __first2;
else if (__first2 == __last)
__first2 = __middle;
}
return __ret;
}
/// This is a helper function for the rotate algorithm.
template<typename _BidirectionalIterator>
_BidirectionalIterator
__rotate(_BidirectionalIterator __first,
_BidirectionalIterator __middle,
_BidirectionalIterator __last,
bidirectional_iterator_tag)
{
// concept requirements
__glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept<
_BidirectionalIterator>)
if (__first == __middle)
return __last;
else if (__last == __middle)
return __first;
std::__reverse(__first, __middle, bidirectional_iterator_tag());
std::__reverse(__middle, __last, bidirectional_iterator_tag());
while (__first != __middle && __middle != __last)
{
std::iter_swap(__first, --__last);
++__first;
}
if (__first == __middle)
{
std::__reverse(__middle, __last, bidirectional_iterator_tag());
return __last;
}
else
{
std::__reverse(__first, __middle, bidirectional_iterator_tag());
return __first;
}
}
/// This is a helper function for the rotate algorithm.
template<typename _RandomAccessIterator>
_RandomAccessIterator
__rotate(_RandomAccessIterator __first,
_RandomAccessIterator __middle,
_RandomAccessIterator __last,
random_access_iterator_tag)
{
// concept requirements
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>)
if (__first == __middle)
return __last;
else if (__last == __middle)
return __first;
typedef typename iterator_traits<_RandomAccessIterator>::difference_type
_Distance;
typedef typename iterator_traits<_RandomAccessIterator>::value_type
_ValueType;
_Distance __n = __last - __first;
_Distance __k = __middle - __first;
if (__k == __n - __k)
{
std::swap_ranges(__first, __middle, __middle);
return __middle;
}
_RandomAccessIterator __p = __first;
_RandomAccessIterator __ret = __first + (__last - __middle);
for (;;)
{
if (__k < __n - __k)
{
if (__is_pod(_ValueType) && __k == 1)
{
_ValueType __t = _GLIBCXX_MOVE(*__p);
_GLIBCXX_MOVE3(__p + 1, __p + __n, __p);
*(__p + __n - 1) = _GLIBCXX_MOVE(__t);
return __ret;
}
_RandomAccessIterator __q = __p + __k;
for (_Distance __i = 0; __i < __n - __k; ++ __i)
{
std::iter_swap(__p, __q);
++__p;
++__q;
}
__n %= __k;
if (__n == 0)
return __ret;
std::swap(__n, __k);
__k = __n - __k;
}
else
{
__k = __n - __k;
if (__is_pod(_ValueType) && __k == 1)
{
_ValueType __t = _GLIBCXX_MOVE(*(__p + __n - 1));
_GLIBCXX_MOVE_BACKWARD3(__p, __p + __n - 1, __p + __n);
*__p = _GLIBCXX_MOVE(__t);
return __ret;
}
_RandomAccessIterator __q = __p + __n;
__p = __q - __k;
for (_Distance __i = 0; __i < __n - __k; ++ __i)
{
--__p;
--__q;
std::iter_swap(__p, __q);
}
__n %= __k;
if (__n == 0)
return __ret;
std::swap(__n, __k);
}
}
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 488. rotate throws away useful information
/**
* @brief Rotate the elements of a sequence.
* @ingroup mutating_algorithms
* @param __first A forward iterator.
* @param __middle A forward iterator.
* @param __last A forward iterator.
* @return first + (last - middle).
*
* Rotates the elements of the range @p [__first,__last) by
* @p (__middle - __first) positions so that the element at @p __middle
* is moved to @p __first, the element at @p __middle+1 is moved to
* @p __first+1 and so on for each element in the range
* @p [__first,__last).
*
* This effectively swaps the ranges @p [__first,__middle) and
* @p [__middle,__last).
*
* Performs
* @p *(__first+(n+(__last-__middle))%(__last-__first))=*(__first+n)
* for each @p n in the range @p [0,__last-__first).
*/
template<typename _ForwardIterator>
inline _ForwardIterator
rotate(_ForwardIterator __first, _ForwardIterator __middle,
_ForwardIterator __last)
{
// concept requirements
__glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
_ForwardIterator>)
__glibcxx_requires_valid_range(__first, __middle);
__glibcxx_requires_valid_range(__middle, __last);
return std::__rotate(__first, __middle, __last,
std::__iterator_category(__first));
}
} // namespace _V2
/**
* @brief Copy a sequence, rotating its elements.
* @ingroup mutating_algorithms
* @param __first A forward iterator.
* @param __middle A forward iterator.
* @param __last A forward iterator.
* @param __result An output iterator.
* @return An iterator designating the end of the resulting sequence.
*
* Copies the elements of the range @p [__first,__last) to the
* range beginning at @result, rotating the copied elements by
* @p (__middle-__first) positions so that the element at @p __middle
* is moved to @p __result, the element at @p __middle+1 is moved
* to @p __result+1 and so on for each element in the range @p
* [__first,__last).
*
* Performs
* @p *(__result+(n+(__last-__middle))%(__last-__first))=*(__first+n)
* for each @p n in the range @p [0,__last-__first).
*/
template<typename _ForwardIterator, typename _OutputIterator>
inline _OutputIterator
rotate_copy(_ForwardIterator __first, _ForwardIterator __middle,
_ForwardIterator __last, _OutputIterator __result)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __middle);
__glibcxx_requires_valid_range(__middle, __last);
return std::copy(__first, __middle,
std::copy(__middle, __last, __result));
}
/// This is a helper function...
template<typename _ForwardIterator, typename _Predicate>
_ForwardIterator
__partition(_ForwardIterator __first, _ForwardIterator __last,
_Predicate __pred, forward_iterator_tag)
{
if (__first == __last)
return __first;
while (__pred(*__first))
if (++__first == __last)
return __first;
_ForwardIterator __next = __first;
while (++__next != __last)
if (__pred(*__next))
{
std::iter_swap(__first, __next);
++__first;
}
return __first;
}
/// This is a helper function...
template<typename _BidirectionalIterator, typename _Predicate>
_BidirectionalIterator
__partition(_BidirectionalIterator __first, _BidirectionalIterator __last,
_Predicate __pred, bidirectional_iterator_tag)
{
while (true)
{
while (true)
if (__first == __last)
return __first;
else if (__pred(*__first))
++__first;
else
break;
--__last;
while (true)
if (__first == __last)
return __first;
else if (!bool(__pred(*__last)))
--__last;
else
break;
std::iter_swap(__first, __last);
++__first;
}
}
// partition
/// This is a helper function...
/// Requires __first != __last and !__pred(__first)
/// and __len == distance(__first, __last).
///
/// !__pred(__first) allows us to guarantee that we don't
/// move-assign an element onto itself.
template<typename _ForwardIterator, typename _Pointer, typename _Predicate,
typename _Distance>
_ForwardIterator
__stable_partition_adaptive(_ForwardIterator __first,
_ForwardIterator __last,
_Predicate __pred, _Distance __len,
_Pointer __buffer,
_Distance __buffer_size)
{
if (__len == 1)
return __first;
if (__len <= __buffer_size)
{
_ForwardIterator __result1 = __first;
_Pointer __result2 = __buffer;
// The precondition guarantees that !__pred(__first), so
// move that element to the buffer before starting the loop.
// This ensures that we only call __pred once per element.
*__result2 = _GLIBCXX_MOVE(*__first);
++__result2;
++__first;
for (; __first != __last; ++__first)
if (__pred(__first))
{
*__result1 = _GLIBCXX_MOVE(*__first);
++__result1;
}
else
{
*__result2 = _GLIBCXX_MOVE(*__first);
++__result2;
}
_GLIBCXX_MOVE3(__buffer, __result2, __result1);
return __result1;
}
_ForwardIterator __middle = __first;
std::advance(__middle, __len / 2);
_ForwardIterator __left_split =
std::__stable_partition_adaptive(__first, __middle, __pred,
__len / 2, __buffer,
__buffer_size);
// Advance past true-predicate values to satisfy this
// function's preconditions.
_Distance __right_len = __len - __len / 2;
_ForwardIterator __right_split =
std::__find_if_not_n(__middle, __right_len, __pred);
if (__right_len)
__right_split =
std::__stable_partition_adaptive(__right_split, __last, __pred,
__right_len,
__buffer, __buffer_size);
std::rotate(__left_split, __middle, __right_split);
std::advance(__left_split, std::distance(__middle, __right_split));
return __left_split;
}
template<typename _ForwardIterator, typename _Predicate>
_ForwardIterator
__stable_partition(_ForwardIterator __first, _ForwardIterator __last,
_Predicate __pred)
{
__first = std::__find_if_not(__first, __last, __pred);
if (__first == __last)
return __first;
typedef typename iterator_traits<_ForwardIterator>::value_type
_ValueType;
typedef typename iterator_traits<_ForwardIterator>::difference_type
_DistanceType;
_Temporary_buffer<_ForwardIterator, _ValueType> __buf(__first, __last);
return
std::__stable_partition_adaptive(__first, __last, __pred,
_DistanceType(__buf.requested_size()),
__buf.begin(),
_DistanceType(__buf.size()));
}
/**
* @brief Move elements for which a predicate is true to the beginning
* of a sequence, preserving relative ordering.
* @ingroup mutating_algorithms
* @param __first A forward iterator.
* @param __last A forward iterator.
* @param __pred A predicate functor.
* @return An iterator @p middle such that @p __pred(i) is true for each
* iterator @p i in the range @p [first,middle) and false for each @p i
* in the range @p [middle,last).
*
* Performs the same function as @p partition() with the additional
* guarantee that the relative ordering of elements in each group is
* preserved, so any two elements @p x and @p y in the range
* @p [__first,__last) such that @p __pred(x)==__pred(y) will have the same
* relative ordering after calling @p stable_partition().
*/
template<typename _ForwardIterator, typename _Predicate>
inline _ForwardIterator
stable_partition(_ForwardIterator __first, _ForwardIterator __last,
_Predicate __pred)
{
// concept requirements
__glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
_ForwardIterator>)
__glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
return std::__stable_partition(__first, __last,
__gnu_cxx::__ops::__pred_iter(__pred));
}
/// This is a helper function for the sort routines.
template<typename _RandomAccessIterator, typename _Compare>
void
__heap_select(_RandomAccessIterator __first,
_RandomAccessIterator __middle,
_RandomAccessIterator __last, _Compare __comp)
{
std::__make_heap(__first, __middle, __comp);
for (_RandomAccessIterator __i = __middle; __i < __last; ++__i)
if (__comp(__i, __first))
std::__pop_heap(__first, __middle, __i, __comp);
}
// partial_sort
template<typename _InputIterator, typename _RandomAccessIterator,
typename _Compare>
_RandomAccessIterator
__partial_sort_copy(_InputIterator __first, _InputIterator __last,
_RandomAccessIterator __result_first,
_RandomAccessIterator __result_last,
_Compare __comp)
{
typedef typename iterator_traits<_InputIterator>::value_type
_InputValueType;
typedef iterator_traits<_RandomAccessIterator> _RItTraits;
typedef typename _RItTraits::difference_type _DistanceType;
if (__result_first == __result_last)
return __result_last;
_RandomAccessIterator __result_real_last = __result_first;
while (__first != __last && __result_real_last != __result_last)
{
*__result_real_last = *__first;
++__result_real_last;
++__first;
}
std::__make_heap(__result_first, __result_real_last, __comp);
while (__first != __last)
{
if (__comp(__first, __result_first))
std::__adjust_heap(__result_first, _DistanceType(0),
_DistanceType(__result_real_last
- __result_first),
_InputValueType(*__first), __comp);
++__first;
}
std::__sort_heap(__result_first, __result_real_last, __comp);
return __result_real_last;
}
/**
* @brief Copy the smallest elements of a sequence.
* @ingroup sorting_algorithms
* @param __first An iterator.
* @param __last Another iterator.
* @param __result_first A random-access iterator.
* @param __result_last Another random-access iterator.
* @return An iterator indicating the end of the resulting sequence.
*
* Copies and sorts the smallest N values from the range @p [__first,__last)
* to the range beginning at @p __result_first, where the number of
* elements to be copied, @p N, is the smaller of @p (__last-__first) and
* @p (__result_last-__result_first).
* After the sort if @e i and @e j are iterators in the range
* @p [__result_first,__result_first+N) such that i precedes j then
* *j<*i is false.
* The value returned is @p __result_first+N.
*/
template<typename _InputIterator, typename _RandomAccessIterator>
inline _RandomAccessIterator
partial_sort_copy(_InputIterator __first, _InputIterator __last,
_RandomAccessIterator __result_first,
_RandomAccessIterator __result_last)
{
#ifdef _GLIBCXX_CONCEPT_CHECKS
typedef typename iterator_traits<_InputIterator>::value_type
_InputValueType;
typedef typename iterator_traits<_RandomAccessIterator>::value_type
_OutputValueType;
#endif
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_ConvertibleConcept<_InputValueType,
_OutputValueType>)
__glibcxx_function_requires(_LessThanOpConcept<_InputValueType,
_OutputValueType>)
__glibcxx_function_requires(_LessThanComparableConcept<_OutputValueType>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_irreflexive(__first, __last);
__glibcxx_requires_valid_range(__result_first, __result_last);
return std::__partial_sort_copy(__first, __last,
__result_first, __result_last,
__gnu_cxx::__ops::__iter_less_iter());
}
/**
* @brief Copy the smallest elements of a sequence using a predicate for
* comparison.
* @ingroup sorting_algorithms
* @param __first An input iterator.
* @param __last Another input iterator.
* @param __result_first A random-access iterator.
* @param __result_last Another random-access iterator.
* @param __comp A comparison functor.
* @return An iterator indicating the end of the resulting sequence.
*
* Copies and sorts the smallest N values from the range @p [__first,__last)
* to the range beginning at @p result_first, where the number of
* elements to be copied, @p N, is the smaller of @p (__last-__first) and
* @p (__result_last-__result_first).
* After the sort if @e i and @e j are iterators in the range
* @p [__result_first,__result_first+N) such that i precedes j then
* @p __comp(*j,*i) is false.
* The value returned is @p __result_first+N.
*/
template<typename _InputIterator, typename _RandomAccessIterator,
typename _Compare>
inline _RandomAccessIterator
partial_sort_copy(_InputIterator __first, _InputIterator __last,
_RandomAccessIterator __result_first,
_RandomAccessIterator __result_last,
_Compare __comp)
{
#ifdef _GLIBCXX_CONCEPT_CHECKS
typedef typename iterator_traits<_InputIterator>::value_type
_InputValueType;
typedef typename iterator_traits<_RandomAccessIterator>::value_type
_OutputValueType;
#endif
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>)
__glibcxx_function_requires(_ConvertibleConcept<_InputValueType,
_OutputValueType>)
__glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
_InputValueType, _OutputValueType>)
__glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
_OutputValueType, _OutputValueType>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_irreflexive_pred(__first, __last, __comp);
__glibcxx_requires_valid_range(__result_first, __result_last);
return std::__partial_sort_copy(__first, __last,
__result_first, __result_last,
__gnu_cxx::__ops::__iter_comp_iter(__comp));
}
/// This is a helper function for the sort routine.
template<typename _RandomAccessIterator, typename _Compare>
void
__unguarded_linear_insert(_RandomAccessIterator __last,
_Compare __comp)
{
typename iterator_traits<_RandomAccessIterator>::value_type
__val = _GLIBCXX_MOVE(*__last);
_RandomAccessIterator __next = __last;
--__next;
while (__comp(__val, __next))
{
*__last = _GLIBCXX_MOVE(*__next);
__last = __next;
--__next;
}
*__last = _GLIBCXX_MOVE(__val);
}
/// This is a helper function for the sort routine.
template<typename _RandomAccessIterator, typename _Compare>
void
__insertion_sort(_RandomAccessIterator __first,
_RandomAccessIterator __last, _Compare __comp)
{
if (__first == __last) return;
for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i)
{
if (__comp(__i, __first))
{
typename iterator_traits<_RandomAccessIterator>::value_type
__val = _GLIBCXX_MOVE(*__i);
_GLIBCXX_MOVE_BACKWARD3(__first, __i, __i + 1);
*__first = _GLIBCXX_MOVE(__val);
}
else
std::__unguarded_linear_insert(__i,
__gnu_cxx::__ops::__val_comp_iter(__comp));
}
}
/// This is a helper function for the sort routine.
template<typename _RandomAccessIterator, typename _Compare>
inline void
__unguarded_insertion_sort(_RandomAccessIterator __first,
_RandomAccessIterator __last, _Compare __comp)
{
for (_RandomAccessIterator __i = __first; __i != __last; ++__i)
std::__unguarded_linear_insert(__i,
__gnu_cxx::__ops::__val_comp_iter(__comp));
}
/**
* @doctodo
* This controls some aspect of the sort routines.
*/
enum { _S_threshold = 16 };
/// This is a helper function for the sort routine.
template<typename _RandomAccessIterator, typename _Compare>
void
__final_insertion_sort(_RandomAccessIterator __first,
_RandomAccessIterator __last, _Compare __comp)
{
if (__last - __first > int(_S_threshold))
{
std::__insertion_sort(__first, __first + int(_S_threshold), __comp);
std::__unguarded_insertion_sort(__first + int(_S_threshold), __last,
__comp);
}
else
std::__insertion_sort(__first, __last, __comp);
}
/// This is a helper function...
template<typename _RandomAccessIterator, typename _Compare>
_RandomAccessIterator
__unguarded_partition(_RandomAccessIterator __first,
_RandomAccessIterator __last,
_RandomAccessIterator __pivot, _Compare __comp)
{
while (true)
{
while (__comp(__first, __pivot))
++__first;
--__last;
while (__comp(__pivot, __last))
--__last;
if (!(__first < __last))
return __first;
std::iter_swap(__first, __last);
++__first;
}
}
/// This is a helper function...
template<typename _RandomAccessIterator, typename _Compare>
inline _RandomAccessIterator
__unguarded_partition_pivot(_RandomAccessIterator __first,
_RandomAccessIterator __last, _Compare __comp)
{
_RandomAccessIterator __mid = __first + (__last - __first) / 2;
std::__move_median_to_first(__first, __first + 1, __mid, __last - 1,
__comp);
return std::__unguarded_partition(__first + 1, __last, __first, __comp);
}
template<typename _RandomAccessIterator, typename _Compare>
inline void
__partial_sort(_RandomAccessIterator __first,
_RandomAccessIterator __middle,
_RandomAccessIterator __last,
_Compare __comp)
{
std::__heap_select(__first, __middle, __last, __comp);
std::__sort_heap(__first, __middle, __comp);
}
/// This is a helper function for the sort routine.
template<typename _RandomAccessIterator, typename _Size, typename _Compare>
void
__introsort_loop(_RandomAccessIterator __first,
_RandomAccessIterator __last,
_Size __depth_limit, _Compare __comp)
{
while (__last - __first > int(_S_threshold))
{
if (__depth_limit == 0)
{
std::__partial_sort(__first, __last, __last, __comp);
return;
}
--__depth_limit;
_RandomAccessIterator __cut =
std::__unguarded_partition_pivot(__first, __last, __comp);
std::__introsort_loop(__cut, __last, __depth_limit, __comp);
__last = __cut;
}
}
// sort
template<typename _RandomAccessIterator, typename _Compare>
inline void
__sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
_Compare __comp)
{
if (__first != __last)
{
std::__introsort_loop(__first, __last,
std::__lg(__last - __first) * 2,
__comp);
std::__final_insertion_sort(__first, __last, __comp);
}
}
template<typename _RandomAccessIterator, typename _Size, typename _Compare>
void
__introselect(_RandomAccessIterator __first, _RandomAccessIterator __nth,
_RandomAccessIterator __last, _Size __depth_limit,
_Compare __comp)
{
while (__last - __first > 3)
{
if (__depth_limit == 0)
{
std::__heap_select(__first, __nth + 1, __last, __comp);
// Place the nth largest element in its final position.
std::iter_swap(__first, __nth);
return;
}
--__depth_limit;
_RandomAccessIterator __cut =
std::__unguarded_partition_pivot(__first, __last, __comp);
if (__cut <= __nth)
__first = __cut;
else
__last = __cut;
}
std::__insertion_sort(__first, __last, __comp);
}
// nth_element
// lower_bound moved to stl_algobase.h
/**
* @brief Finds the first position in which @p __val could be inserted
* without changing the ordering.
* @ingroup binary_search_algorithms
* @param __first An iterator.
* @param __last Another iterator.
* @param __val The search term.
* @param __comp A functor to use for comparisons.
* @return An iterator pointing to the first element <em>not less
* than</em> @p __val, or end() if every element is less
* than @p __val.
* @ingroup binary_search_algorithms
*
* The comparison function should have the same effects on ordering as
* the function used for the initial sort.
*/
template<typename _ForwardIterator, typename _Tp, typename _Compare>
inline _ForwardIterator
lower_bound(_ForwardIterator __first, _ForwardIterator __last,
const _Tp& __val, _Compare __comp)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
typename iterator_traits<_ForwardIterator>::value_type, _Tp>)
__glibcxx_requires_partitioned_lower_pred(__first, __last,
__val, __comp);
return std::__lower_bound(__first, __last, __val,
__gnu_cxx::__ops::__iter_comp_val(__comp));
}
template<typename _ForwardIterator, typename _Tp, typename _Compare>
_ForwardIterator
__upper_bound(_ForwardIterator __first, _ForwardIterator __last,
const _Tp& __val, _Compare __comp)
{
typedef typename iterator_traits<_ForwardIterator>::difference_type
_DistanceType;
_DistanceType __len = std::distance(__first, __last);
while (__len > 0)
{
_DistanceType __half = __len >> 1;
_ForwardIterator __middle = __first;
std::advance(__middle, __half);
if (__comp(__val, __middle))
__len = __half;
else
{
__first = __middle;
++__first;
__len = __len - __half - 1;
}
}
return __first;
}
/**
* @brief Finds the last position in which @p __val could be inserted
* without changing the ordering.
* @ingroup binary_search_algorithms
* @param __first An iterator.
* @param __last Another iterator.
* @param __val The search term.
* @return An iterator pointing to the first element greater than @p __val,
* or end() if no elements are greater than @p __val.
* @ingroup binary_search_algorithms
*/
template<typename _ForwardIterator, typename _Tp>
inline _ForwardIterator
upper_bound(_ForwardIterator __first, _ForwardIterator __last,
const _Tp& __val)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_LessThanOpConcept<
_Tp, typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_partitioned_upper(__first, __last, __val);
return std::__upper_bound(__first, __last, __val,
__gnu_cxx::__ops::__val_less_iter());
}
/**
* @brief Finds the last position in which @p __val could be inserted
* without changing the ordering.
* @ingroup binary_search_algorithms
* @param __first An iterator.
* @param __last Another iterator.
* @param __val The search term.
* @param __comp A functor to use for comparisons.
* @return An iterator pointing to the first element greater than @p __val,
* or end() if no elements are greater than @p __val.
* @ingroup binary_search_algorithms
*
* The comparison function should have the same effects on ordering as
* the function used for the initial sort.
*/
template<typename _ForwardIterator, typename _Tp, typename _Compare>
inline _ForwardIterator
upper_bound(_ForwardIterator __first, _ForwardIterator __last,
const _Tp& __val, _Compare __comp)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
_Tp, typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_partitioned_upper_pred(__first, __last,
__val, __comp);
return std::__upper_bound(__first, __last, __val,
__gnu_cxx::__ops::__val_comp_iter(__comp));
}
template<typename _ForwardIterator, typename _Tp,
typename _CompareItTp, typename _CompareTpIt>
pair<_ForwardIterator, _ForwardIterator>
__equal_range(_ForwardIterator __first, _ForwardIterator __last,
const _Tp& __val,
_CompareItTp __comp_it_val, _CompareTpIt __comp_val_it)
{
typedef typename iterator_traits<_ForwardIterator>::difference_type
_DistanceType;
_DistanceType __len = std::distance(__first, __last);
while (__len > 0)
{
_DistanceType __half = __len >> 1;
_ForwardIterator __middle = __first;
std::advance(__middle, __half);
if (__comp_it_val(__middle, __val))
{
__first = __middle;
++__first;
__len = __len - __half - 1;
}
else if (__comp_val_it(__val, __middle))
__len = __half;
else
{
_ForwardIterator __left
= std::__lower_bound(__first, __middle, __val, __comp_it_val);
std::advance(__first, __len);
_ForwardIterator __right
= std::__upper_bound(++__middle, __first, __val, __comp_val_it);
return pair<_ForwardIterator, _ForwardIterator>(__left, __right);
}
}
return pair<_ForwardIterator, _ForwardIterator>(__first, __first);
}
/**
* @brief Finds the largest subrange in which @p __val could be inserted
* at any place in it without changing the ordering.
* @ingroup binary_search_algorithms
* @param __first An iterator.
* @param __last Another iterator.
* @param __val The search term.
* @return An pair of iterators defining the subrange.
* @ingroup binary_search_algorithms
*
* This is equivalent to
* @code
* std::make_pair(lower_bound(__first, __last, __val),
* upper_bound(__first, __last, __val))
* @endcode
* but does not actually call those functions.
*/
template<typename _ForwardIterator, typename _Tp>
inline pair<_ForwardIterator, _ForwardIterator>
equal_range(_ForwardIterator __first, _ForwardIterator __last,
const _Tp& __val)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_LessThanOpConcept<
typename iterator_traits<_ForwardIterator>::value_type, _Tp>)
__glibcxx_function_requires(_LessThanOpConcept<
_Tp, typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_partitioned_lower(__first, __last, __val);
__glibcxx_requires_partitioned_upper(__first, __last, __val);
return std::__equal_range(__first, __last, __val,
__gnu_cxx::__ops::__iter_less_val(),
__gnu_cxx::__ops::__val_less_iter());
}
/**
* @brief Finds the largest subrange in which @p __val could be inserted
* at any place in it without changing the ordering.
* @param __first An iterator.
* @param __last Another iterator.
* @param __val The search term.
* @param __comp A functor to use for comparisons.
* @return An pair of iterators defining the subrange.
* @ingroup binary_search_algorithms
*
* This is equivalent to
* @code
* std::make_pair(lower_bound(__first, __last, __val, __comp),
* upper_bound(__first, __last, __val, __comp))
* @endcode
* but does not actually call those functions.
*/
template<typename _ForwardIterator, typename _Tp, typename _Compare>
inline pair<_ForwardIterator, _ForwardIterator>
equal_range(_ForwardIterator __first, _ForwardIterator __last,
const _Tp& __val, _Compare __comp)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
typename iterator_traits<_ForwardIterator>::value_type, _Tp>)
__glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
_Tp, typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_partitioned_lower_pred(__first, __last,
__val, __comp);
__glibcxx_requires_partitioned_upper_pred(__first, __last,
__val, __comp);
return std::__equal_range(__first, __last, __val,
__gnu_cxx::__ops::__iter_comp_val(__comp),
__gnu_cxx::__ops::__val_comp_iter(__comp));
}
/**
* @brief Determines whether an element exists in a range.
* @ingroup binary_search_algorithms
* @param __first An iterator.
* @param __last Another iterator.
* @param __val The search term.
* @return True if @p __val (or its equivalent) is in [@p
* __first,@p __last ].
*
* Note that this does not actually return an iterator to @p __val. For
* that, use std::find or a container's specialized find member functions.
*/
template<typename _ForwardIterator, typename _Tp>
bool
binary_search(_ForwardIterator __first, _ForwardIterator __last,
const _Tp& __val)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_LessThanOpConcept<
_Tp, typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_partitioned_lower(__first, __last, __val);
__glibcxx_requires_partitioned_upper(__first, __last, __val);
_ForwardIterator __i
= std::__lower_bound(__first, __last, __val,
__gnu_cxx::__ops::__iter_less_val());
return __i != __last && !(__val < *__i);
}
/**
* @brief Determines whether an element exists in a range.
* @ingroup binary_search_algorithms
* @param __first An iterator.
* @param __last Another iterator.
* @param __val The search term.
* @param __comp A functor to use for comparisons.
* @return True if @p __val (or its equivalent) is in @p [__first,__last].
*
* Note that this does not actually return an iterator to @p __val. For
* that, use std::find or a container's specialized find member functions.
*
* The comparison function should have the same effects on ordering as
* the function used for the initial sort.
*/
template<typename _ForwardIterator, typename _Tp, typename _Compare>
bool
binary_search(_ForwardIterator __first, _ForwardIterator __last,
const _Tp& __val, _Compare __comp)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
_Tp, typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_partitioned_lower_pred(__first, __last,
__val, __comp);
__glibcxx_requires_partitioned_upper_pred(__first, __last,
__val, __comp);
_ForwardIterator __i
= std::__lower_bound(__first, __last, __val,
__gnu_cxx::__ops::__iter_comp_val(__comp));
return __i != __last && !bool(__comp(__val, *__i));
}
// merge
/// This is a helper function for the __merge_adaptive routines.
template<typename _InputIterator1, typename _InputIterator2,
typename _OutputIterator, typename _Compare>
void
__move_merge_adaptive(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2,
_OutputIterator __result, _Compare __comp)
{
while (__first1 != __last1 && __first2 != __last2)
{
if (__comp(__first2, __first1))
{
*__result = _GLIBCXX_MOVE(*__first2);
++__first2;
}
else
{
*__result = _GLIBCXX_MOVE(*__first1);
++__first1;
}
++__result;
}
if (__first1 != __last1)
_GLIBCXX_MOVE3(__first1, __last1, __result);
}
/// This is a helper function for the __merge_adaptive routines.
template<typename _BidirectionalIterator1, typename _BidirectionalIterator2,
typename _BidirectionalIterator3, typename _Compare>
void
__move_merge_adaptive_backward(_BidirectionalIterator1 __first1,
_BidirectionalIterator1 __last1,
_BidirectionalIterator2 __first2,
_BidirectionalIterator2 __last2,
_BidirectionalIterator3 __result,
_Compare __comp)
{
if (__first1 == __last1)
{
_GLIBCXX_MOVE_BACKWARD3(__first2, __last2, __result);
return;
}
else if (__first2 == __last2)
return;
--__last1;
--__last2;
while (true)
{
if (__comp(__last2, __last1))
{
*--__result = _GLIBCXX_MOVE(*__last1);
if (__first1 == __last1)
{
_GLIBCXX_MOVE_BACKWARD3(__first2, ++__last2, __result);
return;
}
--__last1;
}
else
{
*--__result = _GLIBCXX_MOVE(*__last2);
if (__first2 == __last2)
return;
--__last2;
}
}
}
/// This is a helper function for the merge routines.
template<typename _BidirectionalIterator1, typename _BidirectionalIterator2,
typename _Distance>
_BidirectionalIterator1
__rotate_adaptive(_BidirectionalIterator1 __first,
_BidirectionalIterator1 __middle,
_BidirectionalIterator1 __last,
_Distance __len1, _Distance __len2,
_BidirectionalIterator2 __buffer,
_Distance __buffer_size)
{
_BidirectionalIterator2 __buffer_end;
if (__len1 > __len2 && __len2 <= __buffer_size)
{
if (__len2)
{
__buffer_end = _GLIBCXX_MOVE3(__middle, __last, __buffer);
_GLIBCXX_MOVE_BACKWARD3(__first, __middle, __last);
return _GLIBCXX_MOVE3(__buffer, __buffer_end, __first);
}
else
return __first;
}
else if (__len1 <= __buffer_size)
{
if (__len1)
{
__buffer_end = _GLIBCXX_MOVE3(__first, __middle, __buffer);
_GLIBCXX_MOVE3(__middle, __last, __first);
return _GLIBCXX_MOVE_BACKWARD3(__buffer, __buffer_end, __last);
}
else
return __last;
}
else
{
std::rotate(__first, __middle, __last);
std::advance(__first, std::distance(__middle, __last));
return __first;
}
}
/// This is a helper function for the merge routines.
template<typename _BidirectionalIterator, typename _Distance,
typename _Pointer, typename _Compare>
void
__merge_adaptive(_BidirectionalIterator __first,
_BidirectionalIterator __middle,
_BidirectionalIterator __last,
_Distance __len1, _Distance __len2,
_Pointer __buffer, _Distance __buffer_size,
_Compare __comp)
{
if (__len1 <= __len2 && __len1 <= __buffer_size)
{
_Pointer __buffer_end = _GLIBCXX_MOVE3(__first, __middle, __buffer);
std::__move_merge_adaptive(__buffer, __buffer_end, __middle, __last,
__first, __comp);
}
else if (__len2 <= __buffer_size)
{
_Pointer __buffer_end = _GLIBCXX_MOVE3(__middle, __last, __buffer);
std::__move_merge_adaptive_backward(__first, __middle, __buffer,
__buffer_end, __last, __comp);
}
else
{
_BidirectionalIterator __first_cut = __first;
_BidirectionalIterator __second_cut = __middle;
_Distance __len11 = 0;
_Distance __len22 = 0;
if (__len1 > __len2)
{
__len11 = __len1 / 2;
std::advance(__first_cut, __len11);
__second_cut
= std::__lower_bound(__middle, __last, *__first_cut,
__gnu_cxx::__ops::__iter_comp_val(__comp));
__len22 = std::distance(__middle, __second_cut);
}
else
{
__len22 = __len2 / 2;
std::advance(__second_cut, __len22);
__first_cut
= std::__upper_bound(__first, __middle, *__second_cut,
__gnu_cxx::__ops::__val_comp_iter(__comp));
__len11 = std::distance(__first, __first_cut);
}
_BidirectionalIterator __new_middle
= std::__rotate_adaptive(__first_cut, __middle, __second_cut,
__len1 - __len11, __len22, __buffer,
__buffer_size);
std::__merge_adaptive(__first, __first_cut, __new_middle, __len11,
__len22, __buffer, __buffer_size, __comp);
std::__merge_adaptive(__new_middle, __second_cut, __last,
__len1 - __len11,
__len2 - __len22, __buffer,
__buffer_size, __comp);
}
}
/// This is a helper function for the merge routines.
template<typename _BidirectionalIterator, typename _Distance,
typename _Compare>
void
__merge_without_buffer(_BidirectionalIterator __first,
_BidirectionalIterator __middle,
_BidirectionalIterator __last,
_Distance __len1, _Distance __len2,
_Compare __comp)
{
if (__len1 == 0 || __len2 == 0)
return;
if (__len1 + __len2 == 2)
{
if (__comp(__middle, __first))
std::iter_swap(__first, __middle);
return;
}
_BidirectionalIterator __first_cut = __first;
_BidirectionalIterator __second_cut = __middle;
_Distance __len11 = 0;
_Distance __len22 = 0;
if (__len1 > __len2)
{
__len11 = __len1 / 2;
std::advance(__first_cut, __len11);
__second_cut
= std::__lower_bound(__middle, __last, *__first_cut,
__gnu_cxx::__ops::__iter_comp_val(__comp));
__len22 = std::distance(__middle, __second_cut);
}
else
{
__len22 = __len2 / 2;
std::advance(__second_cut, __len22);
__first_cut
= std::__upper_bound(__first, __middle, *__second_cut,
__gnu_cxx::__ops::__val_comp_iter(__comp));
__len11 = std::distance(__first, __first_cut);
}
std::rotate(__first_cut, __middle, __second_cut);
_BidirectionalIterator __new_middle = __first_cut;
std::advance(__new_middle, std::distance(__middle, __second_cut));
std::__merge_without_buffer(__first, __first_cut, __new_middle,
__len11, __len22, __comp);
std::__merge_without_buffer(__new_middle, __second_cut, __last,
__len1 - __len11, __len2 - __len22, __comp);
}
template<typename _BidirectionalIterator, typename _Compare>
void
__inplace_merge(_BidirectionalIterator __first,
_BidirectionalIterator __middle,
_BidirectionalIterator __last,
_Compare __comp)
{
typedef typename iterator_traits<_BidirectionalIterator>::value_type
_ValueType;
typedef typename iterator_traits<_BidirectionalIterator>::difference_type
_DistanceType;
if (__first == __middle || __middle == __last)
return;
const _DistanceType __len1 = std::distance(__first, __middle);
const _DistanceType __len2 = std::distance(__middle, __last);
typedef _Temporary_buffer<_BidirectionalIterator, _ValueType> _TmpBuf;
_TmpBuf __buf(__first, __last);
if (__buf.begin() == 0)
std::__merge_without_buffer
(__first, __middle, __last, __len1, __len2, __comp);
else
std::__merge_adaptive
(__first, __middle, __last, __len1, __len2, __buf.begin(),
_DistanceType(__buf.size()), __comp);
}
/**
* @brief Merges two sorted ranges in place.
* @ingroup sorting_algorithms
* @param __first An iterator.
* @param __middle Another iterator.
* @param __last Another iterator.
* @return Nothing.
*
* Merges two sorted and consecutive ranges, [__first,__middle) and
* [__middle,__last), and puts the result in [__first,__last). The
* output will be sorted. The sort is @e stable, that is, for
* equivalent elements in the two ranges, elements from the first
* range will always come before elements from the second.
*
* If enough additional memory is available, this takes (__last-__first)-1
* comparisons. Otherwise an NlogN algorithm is used, where N is
* distance(__first,__last).
*/
template<typename _BidirectionalIterator>
inline void
inplace_merge(_BidirectionalIterator __first,
_BidirectionalIterator __middle,
_BidirectionalIterator __last)
{
// concept requirements
__glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept<
_BidirectionalIterator>)
__glibcxx_function_requires(_LessThanComparableConcept<
typename iterator_traits<_BidirectionalIterator>::value_type>)
__glibcxx_requires_sorted(__first, __middle);
__glibcxx_requires_sorted(__middle, __last);
__glibcxx_requires_irreflexive(__first, __last);
std::__inplace_merge(__first, __middle, __last,
__gnu_cxx::__ops::__iter_less_iter());
}
/**
* @brief Merges two sorted ranges in place.
* @ingroup sorting_algorithms
* @param __first An iterator.
* @param __middle Another iterator.
* @param __last Another iterator.
* @param __comp A functor to use for comparisons.
* @return Nothing.
*
* Merges two sorted and consecutive ranges, [__first,__middle) and
* [middle,last), and puts the result in [__first,__last). The output will
* be sorted. The sort is @e stable, that is, for equivalent
* elements in the two ranges, elements from the first range will always
* come before elements from the second.
*
* If enough additional memory is available, this takes (__last-__first)-1
* comparisons. Otherwise an NlogN algorithm is used, where N is
* distance(__first,__last).
*
* The comparison function should have the same effects on ordering as
* the function used for the initial sort.
*/
template<typename _BidirectionalIterator, typename _Compare>
inline void
inplace_merge(_BidirectionalIterator __first,
_BidirectionalIterator __middle,
_BidirectionalIterator __last,
_Compare __comp)
{
// concept requirements
__glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept<
_BidirectionalIterator>)
__glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
typename iterator_traits<_BidirectionalIterator>::value_type,
typename iterator_traits<_BidirectionalIterator>::value_type>)
__glibcxx_requires_sorted_pred(__first, __middle, __comp);
__glibcxx_requires_sorted_pred(__middle, __last, __comp);
__glibcxx_requires_irreflexive_pred(__first, __last, __comp);
std::__inplace_merge(__first, __middle, __last,
__gnu_cxx::__ops::__iter_comp_iter(__comp));
}
/// This is a helper function for the __merge_sort_loop routines.
template<typename _InputIterator, typename _OutputIterator,
typename _Compare>
_OutputIterator
__move_merge(_InputIterator __first1, _InputIterator __last1,
_InputIterator __first2, _InputIterator __last2,
_OutputIterator __result, _Compare __comp)
{
while (__first1 != __last1 && __first2 != __last2)
{
if (__comp(__first2, __first1))
{
*__result = _GLIBCXX_MOVE(*__first2);
++__first2;
}
else
{
*__result = _GLIBCXX_MOVE(*__first1);
++__first1;
}
++__result;
}
return _GLIBCXX_MOVE3(__first2, __last2,
_GLIBCXX_MOVE3(__first1, __last1,
__result));
}
template<typename _RandomAccessIterator1, typename _RandomAccessIterator2,
typename _Distance, typename _Compare>
void
__merge_sort_loop(_RandomAccessIterator1 __first,
_RandomAccessIterator1 __last,
_RandomAccessIterator2 __result, _Distance __step_size,
_Compare __comp)
{
const _Distance __two_step = 2 * __step_size;
while (__last - __first >= __two_step)
{
__result = std::__move_merge(__first, __first + __step_size,
__first + __step_size,
__first + __two_step,
__result, __comp);
__first += __two_step;
}
__step_size = std::min(_Distance(__last - __first), __step_size);
std::__move_merge(__first, __first + __step_size,
__first + __step_size, __last, __result, __comp);
}
template<typename _RandomAccessIterator, typename _Distance,
typename _Compare>
void
__chunk_insertion_sort(_RandomAccessIterator __first,
_RandomAccessIterator __last,
_Distance __chunk_size, _Compare __comp)
{
while (__last - __first >= __chunk_size)
{
std::__insertion_sort(__first, __first + __chunk_size, __comp);
__first += __chunk_size;
}
std::__insertion_sort(__first, __last, __comp);
}
enum { _S_chunk_size = 7 };
template<typename _RandomAccessIterator, typename _Pointer, typename _Compare>
void
__merge_sort_with_buffer(_RandomAccessIterator __first,
_RandomAccessIterator __last,
_Pointer __buffer, _Compare __comp)
{
typedef typename iterator_traits<_RandomAccessIterator>::difference_type
_Distance;
const _Distance __len = __last - __first;
const _Pointer __buffer_last = __buffer + __len;
_Distance __step_size = _S_chunk_size;
std::__chunk_insertion_sort(__first, __last, __step_size, __comp);
while (__step_size < __len)
{
std::__merge_sort_loop(__first, __last, __buffer,
__step_size, __comp);
__step_size *= 2;
std::__merge_sort_loop(__buffer, __buffer_last, __first,
__step_size, __comp);
__step_size *= 2;
}
}
template<typename _RandomAccessIterator, typename _Pointer,
typename _Distance, typename _Compare>
void
__stable_sort_adaptive(_RandomAccessIterator __first,
_RandomAccessIterator __last,
_Pointer __buffer, _Distance __buffer_size,
_Compare __comp)
{
const _Distance __len = (__last - __first + 1) / 2;
const _RandomAccessIterator __middle = __first + __len;
if (__len > __buffer_size)
{
std::__stable_sort_adaptive(__first, __middle, __buffer,
__buffer_size, __comp);
std::__stable_sort_adaptive(__middle, __last, __buffer,
__buffer_size, __comp);
}
else
{
std::__merge_sort_with_buffer(__first, __middle, __buffer, __comp);
std::__merge_sort_with_buffer(__middle, __last, __buffer, __comp);
}
std::__merge_adaptive(__first, __middle, __last,
_Distance(__middle - __first),
_Distance(__last - __middle),
__buffer, __buffer_size,
__comp);
}
/// This is a helper function for the stable sorting routines.
template<typename _RandomAccessIterator, typename _Compare>
void
__inplace_stable_sort(_RandomAccessIterator __first,
_RandomAccessIterator __last, _Compare __comp)
{
if (__last - __first < 15)
{
std::__insertion_sort(__first, __last, __comp);
return;
}
_RandomAccessIterator __middle = __first + (__last - __first) / 2;
std::__inplace_stable_sort(__first, __middle, __comp);
std::__inplace_stable_sort(__middle, __last, __comp);
std::__merge_without_buffer(__first, __middle, __last,
__middle - __first,
__last - __middle,
__comp);
}
// stable_sort
// Set algorithms: includes, set_union, set_intersection, set_difference,
// set_symmetric_difference. All of these algorithms have the precondition
// that their input ranges are sorted and the postcondition that their output
// ranges are sorted.
template<typename _InputIterator1, typename _InputIterator2,
typename _Compare>
bool
__includes(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2,
_Compare __comp)
{
while (__first1 != __last1 && __first2 != __last2)
if (__comp(__first2, __first1))
return false;
else if (__comp(__first1, __first2))
++__first1;
else
{
++__first1;
++__first2;
}
return __first2 == __last2;
}
/**
* @brief Determines whether all elements of a sequence exists in a range.
* @param __first1 Start of search range.
* @param __last1 End of search range.
* @param __first2 Start of sequence
* @param __last2 End of sequence.
* @return True if each element in [__first2,__last2) is contained in order
* within [__first1,__last1). False otherwise.
* @ingroup set_algorithms
*
* This operation expects both [__first1,__last1) and
* [__first2,__last2) to be sorted. Searches for the presence of
* each element in [__first2,__last2) within [__first1,__last1).
* The iterators over each range only move forward, so this is a
* linear algorithm. If an element in [__first2,__last2) is not
* found before the search iterator reaches @p __last2, false is
* returned.
*/
template<typename _InputIterator1, typename _InputIterator2>
inline bool
includes(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
__glibcxx_function_requires(_LessThanOpConcept<
typename iterator_traits<_InputIterator1>::value_type,
typename iterator_traits<_InputIterator2>::value_type>)
__glibcxx_function_requires(_LessThanOpConcept<
typename iterator_traits<_InputIterator2>::value_type,
typename iterator_traits<_InputIterator1>::value_type>)
__glibcxx_requires_sorted_set(__first1, __last1, __first2);
__glibcxx_requires_sorted_set(__first2, __last2, __first1);
__glibcxx_requires_irreflexive2(__first1, __last1);
__glibcxx_requires_irreflexive2(__first2, __last2);
return std::__includes(__first1, __last1, __first2, __last2,
__gnu_cxx::__ops::__iter_less_iter());
}
/**
* @brief Determines whether all elements of a sequence exists in a range
* using comparison.
* @ingroup set_algorithms
* @param __first1 Start of search range.
* @param __last1 End of search range.
* @param __first2 Start of sequence
* @param __last2 End of sequence.
* @param __comp Comparison function to use.
* @return True if each element in [__first2,__last2) is contained
* in order within [__first1,__last1) according to comp. False
* otherwise. @ingroup set_algorithms
*
* This operation expects both [__first1,__last1) and
* [__first2,__last2) to be sorted. Searches for the presence of
* each element in [__first2,__last2) within [__first1,__last1),
* using comp to decide. The iterators over each range only move
* forward, so this is a linear algorithm. If an element in
* [__first2,__last2) is not found before the search iterator
* reaches @p __last2, false is returned.
*/
template<typename _InputIterator1, typename _InputIterator2,
typename _Compare>
inline bool
includes(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2,
_Compare __comp)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
__glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
typename iterator_traits<_InputIterator1>::value_type,
typename iterator_traits<_InputIterator2>::value_type>)
__glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
typename iterator_traits<_InputIterator2>::value_type,
typename iterator_traits<_InputIterator1>::value_type>)
__glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp);
__glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp);
__glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp);
__glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp);
return std::__includes(__first1, __last1, __first2, __last2,
__gnu_cxx::__ops::__iter_comp_iter(__comp));
}
// nth_element
// merge
// set_difference
// set_intersection
// set_union
// stable_sort
// set_symmetric_difference
// min_element
// max_element
template<typename _BidirectionalIterator, typename _Compare>
bool
__next_permutation(_BidirectionalIterator __first,
_BidirectionalIterator __last, _Compare __comp)
{
if (__first == __last)
return false;
_BidirectionalIterator __i = __first;
++__i;
if (__i == __last)
return false;
__i = __last;
--__i;
for(;;)
{
_BidirectionalIterator __ii = __i;
--__i;
if (__comp(__i, __ii))
{
_BidirectionalIterator __j = __last;
while (!__comp(__i, --__j))
{}
std::iter_swap(__i, __j);
std::__reverse(__ii, __last,
std::__iterator_category(__first));
return true;
}
if (__i == __first)
{
std::__reverse(__first, __last,
std::__iterator_category(__first));
return false;
}
}
}
/**
* @brief Permute range into the next @e dictionary ordering.
* @ingroup sorting_algorithms
* @param __first Start of range.
* @param __last End of range.
* @return False if wrapped to first permutation, true otherwise.
*
* Treats all permutations of the range as a set of @e dictionary sorted
* sequences. Permutes the current sequence into the next one of this set.
* Returns true if there are more sequences to generate. If the sequence
* is the largest of the set, the smallest is generated and false returned.
*/
template<typename _BidirectionalIterator>
inline bool
next_permutation(_BidirectionalIterator __first,
_BidirectionalIterator __last)
{
// concept requirements
__glibcxx_function_requires(_BidirectionalIteratorConcept<
_BidirectionalIterator>)
__glibcxx_function_requires(_LessThanComparableConcept<
typename iterator_traits<_BidirectionalIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_irreflexive(__first, __last);
return std::__next_permutation
(__first, __last, __gnu_cxx::__ops::__iter_less_iter());
}
/**
* @brief Permute range into the next @e dictionary ordering using
* comparison functor.
* @ingroup sorting_algorithms
* @param __first Start of range.
* @param __last End of range.
* @param __comp A comparison functor.
* @return False if wrapped to first permutation, true otherwise.
*
* Treats all permutations of the range [__first,__last) as a set of
* @e dictionary sorted sequences ordered by @p __comp. Permutes the current
* sequence into the next one of this set. Returns true if there are more
* sequences to generate. If the sequence is the largest of the set, the
* smallest is generated and false returned.
*/
template<typename _BidirectionalIterator, typename _Compare>
inline bool
next_permutation(_BidirectionalIterator __first,
_BidirectionalIterator __last, _Compare __comp)
{
// concept requirements
__glibcxx_function_requires(_BidirectionalIteratorConcept<
_BidirectionalIterator>)
__glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
typename iterator_traits<_BidirectionalIterator>::value_type,
typename iterator_traits<_BidirectionalIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_irreflexive_pred(__first, __last, __comp);
return std::__next_permutation
(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp));
}
template<typename _BidirectionalIterator, typename _Compare>
bool
__prev_permutation(_BidirectionalIterator __first,
_BidirectionalIterator __last, _Compare __comp)
{
if (__first == __last)
return false;
_BidirectionalIterator __i = __first;
++__i;
if (__i == __last)
return false;
__i = __last;
--__i;
for(;;)
{
_BidirectionalIterator __ii = __i;
--__i;
if (__comp(__ii, __i))
{
_BidirectionalIterator __j = __last;
while (!__comp(--__j, __i))
{}
std::iter_swap(__i, __j);
std::__reverse(__ii, __last,
std::__iterator_category(__first));
return true;
}
if (__i == __first)
{
std::__reverse(__first, __last,
std::__iterator_category(__first));
return false;
}
}
}
/**
* @brief Permute range into the previous @e dictionary ordering.
* @ingroup sorting_algorithms
* @param __first Start of range.
* @param __last End of range.
* @return False if wrapped to last permutation, true otherwise.
*
* Treats all permutations of the range as a set of @e dictionary sorted
* sequences. Permutes the current sequence into the previous one of this
* set. Returns true if there are more sequences to generate. If the
* sequence is the smallest of the set, the largest is generated and false
* returned.
*/
template<typename _BidirectionalIterator>
inline bool
prev_permutation(_BidirectionalIterator __first,
_BidirectionalIterator __last)
{
// concept requirements
__glibcxx_function_requires(_BidirectionalIteratorConcept<
_BidirectionalIterator>)
__glibcxx_function_requires(_LessThanComparableConcept<
typename iterator_traits<_BidirectionalIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_irreflexive(__first, __last);
return std::__prev_permutation(__first, __last,
__gnu_cxx::__ops::__iter_less_iter());
}
/**
* @brief Permute range into the previous @e dictionary ordering using
* comparison functor.
* @ingroup sorting_algorithms
* @param __first Start of range.
* @param __last End of range.
* @param __comp A comparison functor.
* @return False if wrapped to last permutation, true otherwise.
*
* Treats all permutations of the range [__first,__last) as a set of
* @e dictionary sorted sequences ordered by @p __comp. Permutes the current
* sequence into the previous one of this set. Returns true if there are
* more sequences to generate. If the sequence is the smallest of the set,
* the largest is generated and false returned.
*/
template<typename _BidirectionalIterator, typename _Compare>
inline bool
prev_permutation(_BidirectionalIterator __first,
_BidirectionalIterator __last, _Compare __comp)
{
// concept requirements
__glibcxx_function_requires(_BidirectionalIteratorConcept<
_BidirectionalIterator>)
__glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
typename iterator_traits<_BidirectionalIterator>::value_type,
typename iterator_traits<_BidirectionalIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_irreflexive_pred(__first, __last, __comp);
return std::__prev_permutation(__first, __last,
__gnu_cxx::__ops::__iter_comp_iter(__comp));
}
// replace
// replace_if
template<typename _InputIterator, typename _OutputIterator,
typename _Predicate, typename _Tp>
_OutputIterator
__replace_copy_if(_InputIterator __first, _InputIterator __last,
_OutputIterator __result,
_Predicate __pred, const _Tp& __new_value)
{
for (; __first != __last; ++__first, (void)++__result)
if (__pred(__first))
*__result = __new_value;
else
*__result = *__first;
return __result;
}
/**
* @brief Copy a sequence, replacing each element of one value with another
* value.
* @param __first An input iterator.
* @param __last An input iterator.
* @param __result An output iterator.
* @param __old_value The value to be replaced.
* @param __new_value The replacement value.
* @return The end of the output sequence, @p result+(last-first).
*
* Copies each element in the input range @p [__first,__last) to the
* output range @p [__result,__result+(__last-__first)) replacing elements
* equal to @p __old_value with @p __new_value.
*/
template<typename _InputIterator, typename _OutputIterator, typename _Tp>
inline _OutputIterator
replace_copy(_InputIterator __first, _InputIterator __last,
_OutputIterator __result,
const _Tp& __old_value, const _Tp& __new_value)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_InputIterator>::value_type>)
__glibcxx_function_requires(_EqualOpConcept<
typename iterator_traits<_InputIterator>::value_type, _Tp>)
__glibcxx_requires_valid_range(__first, __last);
return std::__replace_copy_if(__first, __last, __result,
__gnu_cxx::__ops::__iter_equals_val(__old_value),
__new_value);
}
/**
* @brief Copy a sequence, replacing each value for which a predicate
* returns true with another value.
* @ingroup mutating_algorithms
* @param __first An input iterator.
* @param __last An input iterator.
* @param __result An output iterator.
* @param __pred A predicate.
* @param __new_value The replacement value.
* @return The end of the output sequence, @p __result+(__last-__first).
*
* Copies each element in the range @p [__first,__last) to the range
* @p [__result,__result+(__last-__first)) replacing elements for which
* @p __pred returns true with @p __new_value.
*/
template<typename _InputIterator, typename _OutputIterator,
typename _Predicate, typename _Tp>
inline _OutputIterator
replace_copy_if(_InputIterator __first, _InputIterator __last,
_OutputIterator __result,
_Predicate __pred, const _Tp& __new_value)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_InputIterator>::value_type>)
__glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
typename iterator_traits<_InputIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
return std::__replace_copy_if(__first, __last, __result,
__gnu_cxx::__ops::__pred_iter(__pred),
__new_value);
}
template<typename _InputIterator, typename _Predicate>
typename iterator_traits<_InputIterator>::difference_type
__count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
{
typename iterator_traits<_InputIterator>::difference_type __n = 0;
for (; __first != __last; ++__first)
if (__pred(__first))
++__n;
return __n;
}
#if __cplusplus >= 201103L
/**
* @brief Determines whether the elements of a sequence are sorted.
* @ingroup sorting_algorithms
* @param __first An iterator.
* @param __last Another iterator.
* @return True if the elements are sorted, false otherwise.
*/
template<typename _ForwardIterator>
inline bool
is_sorted(_ForwardIterator __first, _ForwardIterator __last)
{ return std::is_sorted_until(__first, __last) == __last; }
/**
* @brief Determines whether the elements of a sequence are sorted
* according to a comparison functor.
* @ingroup sorting_algorithms
* @param __first An iterator.
* @param __last Another iterator.
* @param __comp A comparison functor.
* @return True if the elements are sorted, false otherwise.
*/
template<typename _ForwardIterator, typename _Compare>
inline bool
is_sorted(_ForwardIterator __first, _ForwardIterator __last,
_Compare __comp)
{ return std::is_sorted_until(__first, __last, __comp) == __last; }
template<typename _ForwardIterator, typename _Compare>
_ForwardIterator
__is_sorted_until(_ForwardIterator __first, _ForwardIterator __last,
_Compare __comp)
{
if (__first == __last)
return __last;
_ForwardIterator __next = __first;
for (++__next; __next != __last; __first = __next, (void)++__next)
if (__comp(__next, __first))
return __next;
return __next;
}
/**
* @brief Determines the end of a sorted sequence.
* @ingroup sorting_algorithms
* @param __first An iterator.
* @param __last Another iterator.
* @return An iterator pointing to the last iterator i in [__first, __last)
* for which the range [__first, i) is sorted.
*/
template<typename _ForwardIterator>
inline _ForwardIterator
is_sorted_until(_ForwardIterator __first, _ForwardIterator __last)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_LessThanComparableConcept<
typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_irreflexive(__first, __last);
return std::__is_sorted_until(__first, __last,
__gnu_cxx::__ops::__iter_less_iter());
}
/**
* @brief Determines the end of a sorted sequence using comparison functor.
* @ingroup sorting_algorithms
* @param __first An iterator.
* @param __last Another iterator.
* @param __comp A comparison functor.
* @return An iterator pointing to the last iterator i in [__first, __last)
* for which the range [__first, i) is sorted.
*/
template<typename _ForwardIterator, typename _Compare>
inline _ForwardIterator
is_sorted_until(_ForwardIterator __first, _ForwardIterator __last,
_Compare __comp)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
typename iterator_traits<_ForwardIterator>::value_type,
typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_irreflexive_pred(__first, __last, __comp);
return std::__is_sorted_until(__first, __last,
__gnu_cxx::__ops::__iter_comp_iter(__comp));
}
/**
* @brief Determines min and max at once as an ordered pair.
* @ingroup sorting_algorithms
* @param __a A thing of arbitrary type.
* @param __b Another thing of arbitrary type.
* @return A pair(__b, __a) if __b is smaller than __a, pair(__a,
* __b) otherwise.
*/
template<typename _Tp>
_GLIBCXX14_CONSTEXPR
inline pair<const _Tp&, const _Tp&>
minmax(const _Tp& __a, const _Tp& __b)
{
// concept requirements
__glibcxx_function_requires(_LessThanComparableConcept<_Tp>)
return __b < __a ? pair<const _Tp&, const _Tp&>(__b, __a)
: pair<const _Tp&, const _Tp&>(__a, __b);
}
/**
* @brief Determines min and max at once as an ordered pair.
* @ingroup sorting_algorithms
* @param __a A thing of arbitrary type.
* @param __b Another thing of arbitrary type.
* @param __comp A @link comparison_functors comparison functor @endlink.
* @return A pair(__b, __a) if __b is smaller than __a, pair(__a,
* __b) otherwise.
*/
template<typename _Tp, typename _Compare>
_GLIBCXX14_CONSTEXPR
inline pair<const _Tp&, const _Tp&>
minmax(const _Tp& __a, const _Tp& __b, _Compare __comp)
{
return __comp(__b, __a) ? pair<const _Tp&, const _Tp&>(__b, __a)
: pair<const _Tp&, const _Tp&>(__a, __b);
}
template<typename _ForwardIterator, typename _Compare>
_GLIBCXX14_CONSTEXPR
pair<_ForwardIterator, _ForwardIterator>
__minmax_element(_ForwardIterator __first, _ForwardIterator __last,
_Compare __comp)
{
_ForwardIterator __next = __first;
if (__first == __last
|| ++__next == __last)
return std::make_pair(__first, __first);
_ForwardIterator __min{}, __max{};
if (__comp(__next, __first))
{
__min = __next;
__max = __first;
}
else
{
__min = __first;
__max = __next;
}
__first = __next;
++__first;
while (__first != __last)
{
__next = __first;
if (++__next == __last)
{
if (__comp(__first, __min))
__min = __first;
else if (!__comp(__first, __max))
__max = __first;
break;
}
if (__comp(__next, __first))
{
if (__comp(__next, __min))
__min = __next;
if (!__comp(__first, __max))
__max = __first;
}
else
{
if (__comp(__first, __min))
__min = __first;
if (!__comp(__next, __max))
__max = __next;
}
__first = __next;
++__first;
}
return std::make_pair(__min, __max);
}
/**
* @brief Return a pair of iterators pointing to the minimum and maximum
* elements in a range.
* @ingroup sorting_algorithms
* @param __first Start of range.
* @param __last End of range.
* @return make_pair(m, M), where m is the first iterator i in
* [__first, __last) such that no other element in the range is
* smaller, and where M is the last iterator i in [__first, __last)
* such that no other element in the range is larger.
*/
template<typename _ForwardIterator>
_GLIBCXX14_CONSTEXPR
inline pair<_ForwardIterator, _ForwardIterator>
minmax_element(_ForwardIterator __first, _ForwardIterator __last)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_LessThanComparableConcept<
typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_irreflexive(__first, __last);
return std::__minmax_element(__first, __last,
__gnu_cxx::__ops::__iter_less_iter());
}
/**
* @brief Return a pair of iterators pointing to the minimum and maximum
* elements in a range.
* @ingroup sorting_algorithms
* @param __first Start of range.
* @param __last End of range.
* @param __comp Comparison functor.
* @return make_pair(m, M), where m is the first iterator i in
* [__first, __last) such that no other element in the range is
* smaller, and where M is the last iterator i in [__first, __last)
* such that no other element in the range is larger.
*/
template<typename _ForwardIterator, typename _Compare>
_GLIBCXX14_CONSTEXPR
inline pair<_ForwardIterator, _ForwardIterator>
minmax_element(_ForwardIterator __first, _ForwardIterator __last,
_Compare __comp)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
typename iterator_traits<_ForwardIterator>::value_type,
typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_irreflexive_pred(__first, __last, __comp);
return std::__minmax_element(__first, __last,
__gnu_cxx::__ops::__iter_comp_iter(__comp));
}
// N2722 + DR 915.
template<typename _Tp>
_GLIBCXX14_CONSTEXPR
inline _Tp
min(initializer_list<_Tp> __l)
{ return *std::min_element(__l.begin(), __l.end()); }
template<typename _Tp, typename _Compare>
_GLIBCXX14_CONSTEXPR
inline _Tp
min(initializer_list<_Tp> __l, _Compare __comp)
{ return *std::min_element(__l.begin(), __l.end(), __comp); }
template<typename _Tp>
_GLIBCXX14_CONSTEXPR
inline _Tp
max(initializer_list<_Tp> __l)
{ return *std::max_element(__l.begin(), __l.end()); }
template<typename _Tp, typename _Compare>
_GLIBCXX14_CONSTEXPR
inline _Tp
max(initializer_list<_Tp> __l, _Compare __comp)
{ return *std::max_element(__l.begin(), __l.end(), __comp); }
template<typename _Tp>
_GLIBCXX14_CONSTEXPR
inline pair<_Tp, _Tp>
minmax(initializer_list<_Tp> __l)
{
pair<const _Tp*, const _Tp*> __p =
std::minmax_element(__l.begin(), __l.end());
return std::make_pair(*__p.first, *__p.second);
}
template<typename _Tp, typename _Compare>
_GLIBCXX14_CONSTEXPR
inline pair<_Tp, _Tp>
minmax(initializer_list<_Tp> __l, _Compare __comp)
{
pair<const _Tp*, const _Tp*> __p =
std::minmax_element(__l.begin(), __l.end(), __comp);
return std::make_pair(*__p.first, *__p.second);
}
template<typename _ForwardIterator1, typename _ForwardIterator2,
typename _BinaryPredicate>
bool
__is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2, _BinaryPredicate __pred)
{
// Efficiently compare identical prefixes: O(N) if sequences
// have the same elements in the same order.
for (; __first1 != __last1; ++__first1, (void)++__first2)
if (!__pred(__first1, __first2))
break;
if (__first1 == __last1)
return true;
// Establish __last2 assuming equal ranges by iterating over the
// rest of the list.
_ForwardIterator2 __last2 = __first2;
std::advance(__last2, std::distance(__first1, __last1));
for (_ForwardIterator1 __scan = __first1; __scan != __last1; ++__scan)
{
if (__scan != std::__find_if(__first1, __scan,
__gnu_cxx::__ops::__iter_comp_iter(__pred, __scan)))
continue; // We've seen this one before.
auto __matches
= std::__count_if(__first2, __last2,
__gnu_cxx::__ops::__iter_comp_iter(__pred, __scan));
if (0 == __matches ||
std::__count_if(__scan, __last1,
__gnu_cxx::__ops::__iter_comp_iter(__pred, __scan))
!= __matches)
return false;
}
return true;
}
/**
* @brief Checks whether a permutation of the second sequence is equal
* to the first sequence.
* @ingroup non_mutating_algorithms
* @param __first1 Start of first range.
* @param __last1 End of first range.
* @param __first2 Start of second range.
* @return true if there exists a permutation of the elements in the range
* [__first2, __first2 + (__last1 - __first1)), beginning with
* ForwardIterator2 begin, such that equal(__first1, __last1, begin)
* returns true; otherwise, returns false.
*/
template<typename _ForwardIterator1, typename _ForwardIterator2>
inline bool
is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator1>)
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator2>)
__glibcxx_function_requires(_EqualOpConcept<
typename iterator_traits<_ForwardIterator1>::value_type,
typename iterator_traits<_ForwardIterator2>::value_type>)
__glibcxx_requires_valid_range(__first1, __last1);
return std::__is_permutation(__first1, __last1, __first2,
__gnu_cxx::__ops::__iter_equal_to_iter());
}
/**
* @brief Checks whether a permutation of the second sequence is equal
* to the first sequence.
* @ingroup non_mutating_algorithms
* @param __first1 Start of first range.
* @param __last1 End of first range.
* @param __first2 Start of second range.
* @param __pred A binary predicate.
* @return true if there exists a permutation of the elements in
* the range [__first2, __first2 + (__last1 - __first1)),
* beginning with ForwardIterator2 begin, such that
* equal(__first1, __last1, __begin, __pred) returns true;
* otherwise, returns false.
*/
template<typename _ForwardIterator1, typename _ForwardIterator2,
typename _BinaryPredicate>
inline bool
is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2, _BinaryPredicate __pred)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator1>)
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator2>)
__glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate,
typename iterator_traits<_ForwardIterator1>::value_type,
typename iterator_traits<_ForwardIterator2>::value_type>)
__glibcxx_requires_valid_range(__first1, __last1);
return std::__is_permutation(__first1, __last1, __first2,
__gnu_cxx::__ops::__iter_comp_iter(__pred));
}
#if __cplusplus > 201103L
template<typename _ForwardIterator1, typename _ForwardIterator2,
typename _BinaryPredicate>
bool
__is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2, _ForwardIterator2 __last2,
_BinaryPredicate __pred)
{
using _Cat1
= typename iterator_traits<_ForwardIterator1>::iterator_category;
using _Cat2
= typename iterator_traits<_ForwardIterator2>::iterator_category;
using _It1_is_RA = is_same<_Cat1, random_access_iterator_tag>;
using _It2_is_RA = is_same<_Cat2, random_access_iterator_tag>;
constexpr bool __ra_iters = _It1_is_RA() && _It2_is_RA();
if (__ra_iters)
{
auto __d1 = std::distance(__first1, __last1);
auto __d2 = std::distance(__first2, __last2);
if (__d1 != __d2)
return false;
}
// Efficiently compare identical prefixes: O(N) if sequences
// have the same elements in the same order.
for (; __first1 != __last1 && __first2 != __last2;
++__first1, (void)++__first2)
if (!__pred(__first1, __first2))
break;
if (__ra_iters)
{
if (__first1 == __last1)
return true;
}
else
{
auto __d1 = std::distance(__first1, __last1);
auto __d2 = std::distance(__first2, __last2);
if (__d1 == 0 && __d2 == 0)
return true;
if (__d1 != __d2)
return false;
}
for (_ForwardIterator1 __scan = __first1; __scan != __last1; ++__scan)
{
if (__scan != std::__find_if(__first1, __scan,
__gnu_cxx::__ops::__iter_comp_iter(__pred, __scan)))
continue; // We've seen this one before.
auto __matches = std::__count_if(__first2, __last2,
__gnu_cxx::__ops::__iter_comp_iter(__pred, __scan));
if (0 == __matches
|| std::__count_if(__scan, __last1,
__gnu_cxx::__ops::__iter_comp_iter(__pred, __scan))
!= __matches)
return false;
}
return true;
}
/**
* @brief Checks whether a permutaion of the second sequence is equal
* to the first sequence.
* @ingroup non_mutating_algorithms
* @param __first1 Start of first range.
* @param __last1 End of first range.
* @param __first2 Start of second range.
* @param __last2 End of first range.
* @return true if there exists a permutation of the elements in the range
* [__first2, __last2), beginning with ForwardIterator2 begin,
* such that equal(__first1, __last1, begin) returns true;
* otherwise, returns false.
*/
template<typename _ForwardIterator1, typename _ForwardIterator2>
inline bool
is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2, _ForwardIterator2 __last2)
{
__glibcxx_requires_valid_range(__first1, __last1);
__glibcxx_requires_valid_range(__first2, __last2);
return
std::__is_permutation(__first1, __last1, __first2, __last2,
__gnu_cxx::__ops::__iter_equal_to_iter());
}
/**
* @brief Checks whether a permutation of the second sequence is equal
* to the first sequence.
* @ingroup non_mutating_algorithms
* @param __first1 Start of first range.
* @param __last1 End of first range.
* @param __first2 Start of second range.
* @param __last2 End of first range.
* @param __pred A binary predicate.
* @return true if there exists a permutation of the elements in the range
* [__first2, __last2), beginning with ForwardIterator2 begin,
* such that equal(__first1, __last1, __begin, __pred) returns true;
* otherwise, returns false.
*/
template<typename _ForwardIterator1, typename _ForwardIterator2,
typename _BinaryPredicate>
inline bool
is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2, _ForwardIterator2 __last2,
_BinaryPredicate __pred)
{
__glibcxx_requires_valid_range(__first1, __last1);
__glibcxx_requires_valid_range(__first2, __last2);
return std::__is_permutation(__first1, __last1, __first2, __last2,
__gnu_cxx::__ops::__iter_comp_iter(__pred));
}
#if __cplusplus > 201402L
#define __cpp_lib_clamp 201603
/**
* @brief Returns the value clamped between lo and hi.
* @ingroup sorting_algorithms
* @param __val A value of arbitrary type.
* @param __lo A lower limit of arbitrary type.
* @param __hi An upper limit of arbitrary type.
* @return max(__val, __lo) if __val < __hi or min(__val, __hi) otherwise.
*/
template<typename _Tp>
constexpr const _Tp&
clamp(const _Tp& __val, const _Tp& __lo, const _Tp& __hi)
{
__glibcxx_assert(!(__hi < __lo));
return (__val < __lo) ? __lo : (__hi < __val) ? __hi : __val;
}
/**
* @brief Returns the value clamped between lo and hi.
* @ingroup sorting_algorithms
* @param __val A value of arbitrary type.
* @param __lo A lower limit of arbitrary type.
* @param __hi An upper limit of arbitrary type.
* @param __comp A comparison functor.
* @return max(__val, __lo, __comp) if __comp(__val, __hi)
* or min(__val, __hi, __comp) otherwise.
*/
template<typename _Tp, typename _Compare>
constexpr const _Tp&
clamp(const _Tp& __val, const _Tp& __lo, const _Tp& __hi, _Compare __comp)
{
__glibcxx_assert(!__comp(__hi, __lo));
return __comp(__val, __lo) ? __lo : __comp(__hi, __val) ? __hi : __val;
}
#endif // C++17
#endif // C++14
#ifdef _GLIBCXX_USE_C99_STDINT_TR1
/**
* @brief Generate two uniformly distributed integers using a
* single distribution invocation.
* @param __b0 The upper bound for the first integer.
* @param __b1 The upper bound for the second integer.
* @param __g A UniformRandomBitGenerator.
* @return A pair (i, j) with i and j uniformly distributed
* over [0, __b0) and [0, __b1), respectively.
*
* Requires: __b0 * __b1 <= __g.max() - __g.min().
*
* Using uniform_int_distribution with a range that is very
* small relative to the range of the generator ends up wasting
* potentially expensively generated randomness, since
* uniform_int_distribution does not store leftover randomness
* between invocations.
*
* If we know we want two integers in ranges that are sufficiently
* small, we can compose the ranges, use a single distribution
* invocation, and significantly reduce the waste.
*/
template<typename _IntType, typename _UniformRandomBitGenerator>
pair<_IntType, _IntType>
__gen_two_uniform_ints(_IntType __b0, _IntType __b1,
_UniformRandomBitGenerator&& __g)
{
_IntType __x
= uniform_int_distribution<_IntType>{0, (__b0 * __b1) - 1}(__g);
return std::make_pair(__x / __b1, __x % __b1);
}
/**
* @brief Shuffle the elements of a sequence using a uniform random
* number generator.
* @ingroup mutating_algorithms
* @param __first A forward iterator.
* @param __last A forward iterator.
* @param __g A UniformRandomNumberGenerator (26.5.1.3).
* @return Nothing.
*
* Reorders the elements in the range @p [__first,__last) using @p __g to
* provide random numbers.
*/
template<typename _RandomAccessIterator,
typename _UniformRandomNumberGenerator>
void
shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
_UniformRandomNumberGenerator&& __g)
{
// concept requirements
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>)
__glibcxx_requires_valid_range(__first, __last);
if (__first == __last)
return;
typedef typename iterator_traits<_RandomAccessIterator>::difference_type
_DistanceType;
typedef typename std::make_unsigned<_DistanceType>::type __ud_type;
typedef typename std::uniform_int_distribution<__ud_type> __distr_type;
typedef typename __distr_type::param_type __p_type;
typedef typename remove_reference<_UniformRandomNumberGenerator>::type
_Gen;
typedef typename common_type<typename _Gen::result_type, __ud_type>::type
__uc_type;
const __uc_type __urngrange = __g.max() - __g.min();
const __uc_type __urange = __uc_type(__last - __first);
if (__urngrange / __urange >= __urange)
// I.e. (__urngrange >= __urange * __urange) but without wrap issues.
{
_RandomAccessIterator __i = __first + 1;
// Since we know the range isn't empty, an even number of elements
// means an uneven number of elements /to swap/, in which case we
// do the first one up front:
if ((__urange % 2) == 0)
{
__distr_type __d{0, 1};
std::iter_swap(__i++, __first + __d(__g));
}
// Now we know that __last - __i is even, so we do the rest in pairs,
// using a single distribution invocation to produce swap positions
// for two successive elements at a time:
while (__i != __last)
{
const __uc_type __swap_range = __uc_type(__i - __first) + 1;
const pair<__uc_type, __uc_type> __pospos =
__gen_two_uniform_ints(__swap_range, __swap_range + 1, __g);
std::iter_swap(__i++, __first + __pospos.first);
std::iter_swap(__i++, __first + __pospos.second);
}
return;
}
__distr_type __d;
for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i)
std::iter_swap(__i, __first + __d(__g, __p_type(0, __i - __first)));
}
#endif
#endif // C++11
_GLIBCXX_BEGIN_NAMESPACE_ALGO
/**
* @brief Apply a function to every element of a sequence.
* @ingroup non_mutating_algorithms
* @param __first An input iterator.
* @param __last An input iterator.
* @param __f A unary function object.
* @return @p __f
*
* Applies the function object @p __f to each element in the range
* @p [first,last). @p __f must not modify the order of the sequence.
* If @p __f has a return value it is ignored.
*/
template<typename _InputIterator, typename _Function>
_Function
for_each(_InputIterator __first, _InputIterator __last, _Function __f)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_requires_valid_range(__first, __last);
for (; __first != __last; ++__first)
__f(*__first);
return __f; // N.B. [alg.foreach] says std::move(f) but it's redundant.
}
/**
* @brief Find the first occurrence of a value in a sequence.
* @ingroup non_mutating_algorithms
* @param __first An input iterator.
* @param __last An input iterator.
* @param __val The value to find.
* @return The first iterator @c i in the range @p [__first,__last)
* such that @c *i == @p __val, or @p __last if no such iterator exists.
*/
template<typename _InputIterator, typename _Tp>
inline _InputIterator
find(_InputIterator __first, _InputIterator __last,
const _Tp& __val)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_EqualOpConcept<
typename iterator_traits<_InputIterator>::value_type, _Tp>)
__glibcxx_requires_valid_range(__first, __last);
return std::__find_if(__first, __last,
__gnu_cxx::__ops::__iter_equals_val(__val));
}
/**
* @brief Find the first element in a sequence for which a
* predicate is true.
* @ingroup non_mutating_algorithms
* @param __first An input iterator.
* @param __last An input iterator.
* @param __pred A predicate.
* @return The first iterator @c i in the range @p [__first,__last)
* such that @p __pred(*i) is true, or @p __last if no such iterator exists.
*/
template<typename _InputIterator, typename _Predicate>
inline _InputIterator
find_if(_InputIterator __first, _InputIterator __last,
_Predicate __pred)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
typename iterator_traits<_InputIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
return std::__find_if(__first, __last,
__gnu_cxx::__ops::__pred_iter(__pred));
}
/**
* @brief Find element from a set in a sequence.
* @ingroup non_mutating_algorithms
* @param __first1 Start of range to search.
* @param __last1 End of range to search.
* @param __first2 Start of match candidates.
* @param __last2 End of match candidates.
* @return The first iterator @c i in the range
* @p [__first1,__last1) such that @c *i == @p *(i2) such that i2 is an
* iterator in [__first2,__last2), or @p __last1 if no such iterator exists.
*
* Searches the range @p [__first1,__last1) for an element that is
* equal to some element in the range [__first2,__last2). If
* found, returns an iterator in the range [__first1,__last1),
* otherwise returns @p __last1.
*/
template<typename _InputIterator, typename _ForwardIterator>
_InputIterator
find_first_of(_InputIterator __first1, _InputIterator __last1,
_ForwardIterator __first2, _ForwardIterator __last2)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_EqualOpConcept<
typename iterator_traits<_InputIterator>::value_type,
typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_valid_range(__first1, __last1);
__glibcxx_requires_valid_range(__first2, __last2);
for (; __first1 != __last1; ++__first1)
for (_ForwardIterator __iter = __first2; __iter != __last2; ++__iter)
if (*__first1 == *__iter)
return __first1;
return __last1;
}
/**
* @brief Find element from a set in a sequence using a predicate.
* @ingroup non_mutating_algorithms
* @param __first1 Start of range to search.
* @param __last1 End of range to search.
* @param __first2 Start of match candidates.
* @param __last2 End of match candidates.
* @param __comp Predicate to use.
* @return The first iterator @c i in the range
* @p [__first1,__last1) such that @c comp(*i, @p *(i2)) is true
* and i2 is an iterator in [__first2,__last2), or @p __last1 if no
* such iterator exists.
*
* Searches the range @p [__first1,__last1) for an element that is
* equal to some element in the range [__first2,__last2). If
* found, returns an iterator in the range [__first1,__last1),
* otherwise returns @p __last1.
*/
template<typename _InputIterator, typename _ForwardIterator,
typename _BinaryPredicate>
_InputIterator
find_first_of(_InputIterator __first1, _InputIterator __last1,
_ForwardIterator __first2, _ForwardIterator __last2,
_BinaryPredicate __comp)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate,
typename iterator_traits<_InputIterator>::value_type,
typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_valid_range(__first1, __last1);
__glibcxx_requires_valid_range(__first2, __last2);
for (; __first1 != __last1; ++__first1)
for (_ForwardIterator __iter = __first2; __iter != __last2; ++__iter)
if (__comp(*__first1, *__iter))
return __first1;
return __last1;
}
/**
* @brief Find two adjacent values in a sequence that are equal.
* @ingroup non_mutating_algorithms
* @param __first A forward iterator.
* @param __last A forward iterator.
* @return The first iterator @c i such that @c i and @c i+1 are both
* valid iterators in @p [__first,__last) and such that @c *i == @c *(i+1),
* or @p __last if no such iterator exists.
*/
template<typename _ForwardIterator>
inline _ForwardIterator
adjacent_find(_ForwardIterator __first, _ForwardIterator __last)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_EqualityComparableConcept<
typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
return std::__adjacent_find(__first, __last,
__gnu_cxx::__ops::__iter_equal_to_iter());
}
/**
* @brief Find two adjacent values in a sequence using a predicate.
* @ingroup non_mutating_algorithms
* @param __first A forward iterator.
* @param __last A forward iterator.
* @param __binary_pred A binary predicate.
* @return The first iterator @c i such that @c i and @c i+1 are both
* valid iterators in @p [__first,__last) and such that
* @p __binary_pred(*i,*(i+1)) is true, or @p __last if no such iterator
* exists.
*/
template<typename _ForwardIterator, typename _BinaryPredicate>
inline _ForwardIterator
adjacent_find(_ForwardIterator __first, _ForwardIterator __last,
_BinaryPredicate __binary_pred)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate,
typename iterator_traits<_ForwardIterator>::value_type,
typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
return std::__adjacent_find(__first, __last,
__gnu_cxx::__ops::__iter_comp_iter(__binary_pred));
}
/**
* @brief Count the number of copies of a value in a sequence.
* @ingroup non_mutating_algorithms
* @param __first An input iterator.
* @param __last An input iterator.
* @param __value The value to be counted.
* @return The number of iterators @c i in the range @p [__first,__last)
* for which @c *i == @p __value
*/
template<typename _InputIterator, typename _Tp>
inline typename iterator_traits<_InputIterator>::difference_type
count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_EqualOpConcept<
typename iterator_traits<_InputIterator>::value_type, _Tp>)
__glibcxx_requires_valid_range(__first, __last);
return std::__count_if(__first, __last,
__gnu_cxx::__ops::__iter_equals_val(__value));
}
/**
* @brief Count the elements of a sequence for which a predicate is true.
* @ingroup non_mutating_algorithms
* @param __first An input iterator.
* @param __last An input iterator.
* @param __pred A predicate.
* @return The number of iterators @c i in the range @p [__first,__last)
* for which @p __pred(*i) is true.
*/
template<typename _InputIterator, typename _Predicate>
inline typename iterator_traits<_InputIterator>::difference_type
count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
typename iterator_traits<_InputIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
return std::__count_if(__first, __last,
__gnu_cxx::__ops::__pred_iter(__pred));
}
/**
* @brief Search a sequence for a matching sub-sequence.
* @ingroup non_mutating_algorithms
* @param __first1 A forward iterator.
* @param __last1 A forward iterator.
* @param __first2 A forward iterator.
* @param __last2 A forward iterator.
* @return The first iterator @c i in the range @p
* [__first1,__last1-(__last2-__first2)) such that @c *(i+N) == @p
* *(__first2+N) for each @c N in the range @p
* [0,__last2-__first2), or @p __last1 if no such iterator exists.
*
* Searches the range @p [__first1,__last1) for a sub-sequence that
* compares equal value-by-value with the sequence given by @p
* [__first2,__last2) and returns an iterator to the first element
* of the sub-sequence, or @p __last1 if the sub-sequence is not
* found.
*
* Because the sub-sequence must lie completely within the range @p
* [__first1,__last1) it must start at a position less than @p
* __last1-(__last2-__first2) where @p __last2-__first2 is the
* length of the sub-sequence.
*
* This means that the returned iterator @c i will be in the range
* @p [__first1,__last1-(__last2-__first2))
*/
template<typename _ForwardIterator1, typename _ForwardIterator2>
inline _ForwardIterator1
search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2, _ForwardIterator2 __last2)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator1>)
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator2>)
__glibcxx_function_requires(_EqualOpConcept<
typename iterator_traits<_ForwardIterator1>::value_type,
typename iterator_traits<_ForwardIterator2>::value_type>)
__glibcxx_requires_valid_range(__first1, __last1);
__glibcxx_requires_valid_range(__first2, __last2);
return std::__search(__first1, __last1, __first2, __last2,
__gnu_cxx::__ops::__iter_equal_to_iter());
}
/**
* @brief Search a sequence for a matching sub-sequence using a predicate.
* @ingroup non_mutating_algorithms
* @param __first1 A forward iterator.
* @param __last1 A forward iterator.
* @param __first2 A forward iterator.
* @param __last2 A forward iterator.
* @param __predicate A binary predicate.
* @return The first iterator @c i in the range
* @p [__first1,__last1-(__last2-__first2)) such that
* @p __predicate(*(i+N),*(__first2+N)) is true for each @c N in the range
* @p [0,__last2-__first2), or @p __last1 if no such iterator exists.
*
* Searches the range @p [__first1,__last1) for a sub-sequence that
* compares equal value-by-value with the sequence given by @p
* [__first2,__last2), using @p __predicate to determine equality,
* and returns an iterator to the first element of the
* sub-sequence, or @p __last1 if no such iterator exists.
*
* @see search(_ForwardIter1, _ForwardIter1, _ForwardIter2, _ForwardIter2)
*/
template<typename _ForwardIterator1, typename _ForwardIterator2,
typename _BinaryPredicate>
inline _ForwardIterator1
search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2, _ForwardIterator2 __last2,
_BinaryPredicate __predicate)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator1>)
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator2>)
__glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate,
typename iterator_traits<_ForwardIterator1>::value_type,
typename iterator_traits<_ForwardIterator2>::value_type>)
__glibcxx_requires_valid_range(__first1, __last1);
__glibcxx_requires_valid_range(__first2, __last2);
return std::__search(__first1, __last1, __first2, __last2,
__gnu_cxx::__ops::__iter_comp_iter(__predicate));
}
/**
* @brief Search a sequence for a number of consecutive values.
* @ingroup non_mutating_algorithms
* @param __first A forward iterator.
* @param __last A forward iterator.
* @param __count The number of consecutive values.
* @param __val The value to find.
* @return The first iterator @c i in the range @p
* [__first,__last-__count) such that @c *(i+N) == @p __val for
* each @c N in the range @p [0,__count), or @p __last if no such
* iterator exists.
*
* Searches the range @p [__first,__last) for @p count consecutive elements
* equal to @p __val.
*/
template<typename _ForwardIterator, typename _Integer, typename _Tp>
inline _ForwardIterator
search_n(_ForwardIterator __first, _ForwardIterator __last,
_Integer __count, const _Tp& __val)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_EqualOpConcept<
typename iterator_traits<_ForwardIterator>::value_type, _Tp>)
__glibcxx_requires_valid_range(__first, __last);
return std::__search_n(__first, __last, __count,
__gnu_cxx::__ops::__iter_equals_val(__val));
}
/**
* @brief Search a sequence for a number of consecutive values using a
* predicate.
* @ingroup non_mutating_algorithms
* @param __first A forward iterator.
* @param __last A forward iterator.
* @param __count The number of consecutive values.
* @param __val The value to find.
* @param __binary_pred A binary predicate.
* @return The first iterator @c i in the range @p
* [__first,__last-__count) such that @p
* __binary_pred(*(i+N),__val) is true for each @c N in the range
* @p [0,__count), or @p __last if no such iterator exists.
*
* Searches the range @p [__first,__last) for @p __count
* consecutive elements for which the predicate returns true.
*/
template<typename _ForwardIterator, typename _Integer, typename _Tp,
typename _BinaryPredicate>
inline _ForwardIterator
search_n(_ForwardIterator __first, _ForwardIterator __last,
_Integer __count, const _Tp& __val,
_BinaryPredicate __binary_pred)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate,
typename iterator_traits<_ForwardIterator>::value_type, _Tp>)
__glibcxx_requires_valid_range(__first, __last);
return std::__search_n(__first, __last, __count,
__gnu_cxx::__ops::__iter_comp_val(__binary_pred, __val));
}
#if __cplusplus > 201402L
/** @brief Search a sequence using a Searcher object.
*
* @param __first A forward iterator.
* @param __last A forward iterator.
* @param __searcher A callable object.
* @return @p __searcher(__first,__last).first
*/
template<typename _ForwardIterator, typename _Searcher>
inline _ForwardIterator
search(_ForwardIterator __first, _ForwardIterator __last,
const _Searcher& __searcher)
{ return __searcher(__first, __last).first; }
#endif
/**
* @brief Perform an operation on a sequence.
* @ingroup mutating_algorithms
* @param __first An input iterator.
* @param __last An input iterator.
* @param __result An output iterator.
* @param __unary_op A unary operator.
* @return An output iterator equal to @p __result+(__last-__first).
*
* Applies the operator to each element in the input range and assigns
* the results to successive elements of the output sequence.
* Evaluates @p *(__result+N)=unary_op(*(__first+N)) for each @c N in the
* range @p [0,__last-__first).
*
* @p unary_op must not alter its argument.
*/
template<typename _InputIterator, typename _OutputIterator,
typename _UnaryOperation>
_OutputIterator
transform(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _UnaryOperation __unary_op)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
// "the type returned by a _UnaryOperation"
__typeof__(__unary_op(*__first))>)
__glibcxx_requires_valid_range(__first, __last);
for (; __first != __last; ++__first, (void)++__result)
*__result = __unary_op(*__first);
return __result;
}
/**
* @brief Perform an operation on corresponding elements of two sequences.
* @ingroup mutating_algorithms
* @param __first1 An input iterator.
* @param __last1 An input iterator.
* @param __first2 An input iterator.
* @param __result An output iterator.
* @param __binary_op A binary operator.
* @return An output iterator equal to @p result+(last-first).
*
* Applies the operator to the corresponding elements in the two
* input ranges and assigns the results to successive elements of the
* output sequence.
* Evaluates @p
* *(__result+N)=__binary_op(*(__first1+N),*(__first2+N)) for each
* @c N in the range @p [0,__last1-__first1).
*
* @p binary_op must not alter either of its arguments.
*/
template<typename _InputIterator1, typename _InputIterator2,
typename _OutputIterator, typename _BinaryOperation>
_OutputIterator
transform(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _OutputIterator __result,
_BinaryOperation __binary_op)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
// "the type returned by a _BinaryOperation"
__typeof__(__binary_op(*__first1,*__first2))>)
__glibcxx_requires_valid_range(__first1, __last1);
for (; __first1 != __last1; ++__first1, (void)++__first2, ++__result)
*__result = __binary_op(*__first1, *__first2);
return __result;
}
/**
* @brief Replace each occurrence of one value in a sequence with another
* value.
* @ingroup mutating_algorithms
* @param __first A forward iterator.
* @param __last A forward iterator.
* @param __old_value The value to be replaced.
* @param __new_value The replacement value.
* @return replace() returns no value.
*
* For each iterator @c i in the range @p [__first,__last) if @c *i ==
* @p __old_value then the assignment @c *i = @p __new_value is performed.
*/
template<typename _ForwardIterator, typename _Tp>
void
replace(_ForwardIterator __first, _ForwardIterator __last,
const _Tp& __old_value, const _Tp& __new_value)
{
// concept requirements
__glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
_ForwardIterator>)
__glibcxx_function_requires(_EqualOpConcept<
typename iterator_traits<_ForwardIterator>::value_type, _Tp>)
__glibcxx_function_requires(_ConvertibleConcept<_Tp,
typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
for (; __first != __last; ++__first)
if (*__first == __old_value)
*__first = __new_value;
}
/**
* @brief Replace each value in a sequence for which a predicate returns
* true with another value.
* @ingroup mutating_algorithms
* @param __first A forward iterator.
* @param __last A forward iterator.
* @param __pred A predicate.
* @param __new_value The replacement value.
* @return replace_if() returns no value.
*
* For each iterator @c i in the range @p [__first,__last) if @p __pred(*i)
* is true then the assignment @c *i = @p __new_value is performed.
*/
template<typename _ForwardIterator, typename _Predicate, typename _Tp>
void
replace_if(_ForwardIterator __first, _ForwardIterator __last,
_Predicate __pred, const _Tp& __new_value)
{
// concept requirements
__glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
_ForwardIterator>)
__glibcxx_function_requires(_ConvertibleConcept<_Tp,
typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
for (; __first != __last; ++__first)
if (__pred(*__first))
*__first = __new_value;
}
/**
* @brief Assign the result of a function object to each value in a
* sequence.
* @ingroup mutating_algorithms
* @param __first A forward iterator.
* @param __last A forward iterator.
* @param __gen A function object taking no arguments and returning
* std::iterator_traits<_ForwardIterator>::value_type
* @return generate() returns no value.
*
* Performs the assignment @c *i = @p __gen() for each @c i in the range
* @p [__first,__last).
*/
template<typename _ForwardIterator, typename _Generator>
void
generate(_ForwardIterator __first, _ForwardIterator __last,
_Generator __gen)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_GeneratorConcept<_Generator,
typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
for (; __first != __last; ++__first)
*__first = __gen();
}
/**
* @brief Assign the result of a function object to each value in a
* sequence.
* @ingroup mutating_algorithms
* @param __first A forward iterator.
* @param __n The length of the sequence.
* @param __gen A function object taking no arguments and returning
* std::iterator_traits<_ForwardIterator>::value_type
* @return The end of the sequence, @p __first+__n
*
* Performs the assignment @c *i = @p __gen() for each @c i in the range
* @p [__first,__first+__n).
*
* _GLIBCXX_RESOLVE_LIB_DEFECTS
* DR 865. More algorithms that throw away information
*/
template<typename _OutputIterator, typename _Size, typename _Generator>
_OutputIterator
generate_n(_OutputIterator __first, _Size __n, _Generator __gen)
{
// concept requirements
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
// "the type returned by a _Generator"
__typeof__(__gen())>)
for (__decltype(__n + 0) __niter = __n;
__niter > 0; --__niter, (void) ++__first)
*__first = __gen();
return __first;
}
/**
* @brief Copy a sequence, removing consecutive duplicate values.
* @ingroup mutating_algorithms
* @param __first An input iterator.
* @param __last An input iterator.
* @param __result An output iterator.
* @return An iterator designating the end of the resulting sequence.
*
* Copies each element in the range @p [__first,__last) to the range
* beginning at @p __result, except that only the first element is copied
* from groups of consecutive elements that compare equal.
* unique_copy() is stable, so the relative order of elements that are
* copied is unchanged.
*
* _GLIBCXX_RESOLVE_LIB_DEFECTS
* DR 241. Does unique_copy() require CopyConstructible and Assignable?
*
* _GLIBCXX_RESOLVE_LIB_DEFECTS
* DR 538. 241 again: Does unique_copy() require CopyConstructible and
* Assignable?
*/
template<typename _InputIterator, typename _OutputIterator>
inline _OutputIterator
unique_copy(_InputIterator __first, _InputIterator __last,
_OutputIterator __result)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_InputIterator>::value_type>)
__glibcxx_function_requires(_EqualityComparableConcept<
typename iterator_traits<_InputIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
if (__first == __last)
return __result;
return std::__unique_copy(__first, __last, __result,
__gnu_cxx::__ops::__iter_equal_to_iter(),
std::__iterator_category(__first),
std::__iterator_category(__result));
}
/**
* @brief Copy a sequence, removing consecutive values using a predicate.
* @ingroup mutating_algorithms
* @param __first An input iterator.
* @param __last An input iterator.
* @param __result An output iterator.
* @param __binary_pred A binary predicate.
* @return An iterator designating the end of the resulting sequence.
*
* Copies each element in the range @p [__first,__last) to the range
* beginning at @p __result, except that only the first element is copied
* from groups of consecutive elements for which @p __binary_pred returns
* true.
* unique_copy() is stable, so the relative order of elements that are
* copied is unchanged.
*
* _GLIBCXX_RESOLVE_LIB_DEFECTS
* DR 241. Does unique_copy() require CopyConstructible and Assignable?
*/
template<typename _InputIterator, typename _OutputIterator,
typename _BinaryPredicate>
inline _OutputIterator
unique_copy(_InputIterator __first, _InputIterator __last,
_OutputIterator __result,
_BinaryPredicate __binary_pred)
{
// concept requirements -- predicates checked later
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_InputIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
if (__first == __last)
return __result;
return std::__unique_copy(__first, __last, __result,
__gnu_cxx::__ops::__iter_comp_iter(__binary_pred),
std::__iterator_category(__first),
std::__iterator_category(__result));
}
#if _GLIBCXX_HOSTED
/**
* @brief Randomly shuffle the elements of a sequence.
* @ingroup mutating_algorithms
* @param __first A forward iterator.
* @param __last A forward iterator.
* @return Nothing.
*
* Reorder the elements in the range @p [__first,__last) using a random
* distribution, so that every possible ordering of the sequence is
* equally likely.
*/
template<typename _RandomAccessIterator>
inline void
random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
{
// concept requirements
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>)
__glibcxx_requires_valid_range(__first, __last);
if (__first != __last)
for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i)
{
// XXX rand() % N is not uniformly distributed
_RandomAccessIterator __j = __first
+ std::rand() % ((__i - __first) + 1);
if (__i != __j)
std::iter_swap(__i, __j);
}
}
#endif
/**
* @brief Shuffle the elements of a sequence using a random number
* generator.
* @ingroup mutating_algorithms
* @param __first A forward iterator.
* @param __last A forward iterator.
* @param __rand The RNG functor or function.
* @return Nothing.
*
* Reorders the elements in the range @p [__first,__last) using @p __rand to
* provide a random distribution. Calling @p __rand(N) for a positive
* integer @p N should return a randomly chosen integer from the
* range [0,N).
*/
template<typename _RandomAccessIterator, typename _RandomNumberGenerator>
void
random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
#if __cplusplus >= 201103L
_RandomNumberGenerator&& __rand)
#else
_RandomNumberGenerator& __rand)
#endif
{
// concept requirements
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>)
__glibcxx_requires_valid_range(__first, __last);
if (__first == __last)
return;
for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i)
{
_RandomAccessIterator __j = __first + __rand((__i - __first) + 1);
if (__i != __j)
std::iter_swap(__i, __j);
}
}
/**
* @brief Move elements for which a predicate is true to the beginning
* of a sequence.
* @ingroup mutating_algorithms
* @param __first A forward iterator.
* @param __last A forward iterator.
* @param __pred A predicate functor.
* @return An iterator @p middle such that @p __pred(i) is true for each
* iterator @p i in the range @p [__first,middle) and false for each @p i
* in the range @p [middle,__last).
*
* @p __pred must not modify its operand. @p partition() does not preserve
* the relative ordering of elements in each group, use
* @p stable_partition() if this is needed.
*/
template<typename _ForwardIterator, typename _Predicate>
inline _ForwardIterator
partition(_ForwardIterator __first, _ForwardIterator __last,
_Predicate __pred)
{
// concept requirements
__glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
_ForwardIterator>)
__glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
return std::__partition(__first, __last, __pred,
std::__iterator_category(__first));
}
/**
* @brief Sort the smallest elements of a sequence.
* @ingroup sorting_algorithms
* @param __first An iterator.
* @param __middle Another iterator.
* @param __last Another iterator.
* @return Nothing.
*
* Sorts the smallest @p (__middle-__first) elements in the range
* @p [first,last) and moves them to the range @p [__first,__middle). The
* order of the remaining elements in the range @p [__middle,__last) is
* undefined.
* After the sort if @e i and @e j are iterators in the range
* @p [__first,__middle) such that i precedes j and @e k is an iterator in
* the range @p [__middle,__last) then *j<*i and *k<*i are both false.
*/
template<typename _RandomAccessIterator>
inline void
partial_sort(_RandomAccessIterator __first,
_RandomAccessIterator __middle,
_RandomAccessIterator __last)
{
// concept requirements
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>)
__glibcxx_function_requires(_LessThanComparableConcept<
typename iterator_traits<_RandomAccessIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __middle);
__glibcxx_requires_valid_range(__middle, __last);
__glibcxx_requires_irreflexive(__first, __last);
std::__partial_sort(__first, __middle, __last,
__gnu_cxx::__ops::__iter_less_iter());
}
/**
* @brief Sort the smallest elements of a sequence using a predicate
* for comparison.
* @ingroup sorting_algorithms
* @param __first An iterator.
* @param __middle Another iterator.
* @param __last Another iterator.
* @param __comp A comparison functor.
* @return Nothing.
*
* Sorts the smallest @p (__middle-__first) elements in the range
* @p [__first,__last) and moves them to the range @p [__first,__middle). The
* order of the remaining elements in the range @p [__middle,__last) is
* undefined.
* After the sort if @e i and @e j are iterators in the range
* @p [__first,__middle) such that i precedes j and @e k is an iterator in
* the range @p [__middle,__last) then @p *__comp(j,*i) and @p __comp(*k,*i)
* are both false.
*/
template<typename _RandomAccessIterator, typename _Compare>
inline void
partial_sort(_RandomAccessIterator __first,
_RandomAccessIterator __middle,
_RandomAccessIterator __last,
_Compare __comp)
{
// concept requirements
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>)
__glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
typename iterator_traits<_RandomAccessIterator>::value_type,
typename iterator_traits<_RandomAccessIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __middle);
__glibcxx_requires_valid_range(__middle, __last);
__glibcxx_requires_irreflexive_pred(__first, __last, __comp);
std::__partial_sort(__first, __middle, __last,
__gnu_cxx::__ops::__iter_comp_iter(__comp));
}
/**
* @brief Sort a sequence just enough to find a particular position.
* @ingroup sorting_algorithms
* @param __first An iterator.
* @param __nth Another iterator.
* @param __last Another iterator.
* @return Nothing.
*
* Rearranges the elements in the range @p [__first,__last) so that @p *__nth
* is the same element that would have been in that position had the
* whole sequence been sorted. The elements either side of @p *__nth are
* not completely sorted, but for any iterator @e i in the range
* @p [__first,__nth) and any iterator @e j in the range @p [__nth,__last) it
* holds that *j < *i is false.
*/
template<typename _RandomAccessIterator>
inline void
nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth,
_RandomAccessIterator __last)
{
// concept requirements
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>)
__glibcxx_function_requires(_LessThanComparableConcept<
typename iterator_traits<_RandomAccessIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __nth);
__glibcxx_requires_valid_range(__nth, __last);
__glibcxx_requires_irreflexive(__first, __last);
if (__first == __last || __nth == __last)
return;
std::__introselect(__first, __nth, __last,
std::__lg(__last - __first) * 2,
__gnu_cxx::__ops::__iter_less_iter());
}
/**
* @brief Sort a sequence just enough to find a particular position
* using a predicate for comparison.
* @ingroup sorting_algorithms
* @param __first An iterator.
* @param __nth Another iterator.
* @param __last Another iterator.
* @param __comp A comparison functor.
* @return Nothing.
*
* Rearranges the elements in the range @p [__first,__last) so that @p *__nth
* is the same element that would have been in that position had the
* whole sequence been sorted. The elements either side of @p *__nth are
* not completely sorted, but for any iterator @e i in the range
* @p [__first,__nth) and any iterator @e j in the range @p [__nth,__last) it
* holds that @p __comp(*j,*i) is false.
*/
template<typename _RandomAccessIterator, typename _Compare>
inline void
nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth,
_RandomAccessIterator __last, _Compare __comp)
{
// concept requirements
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>)
__glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
typename iterator_traits<_RandomAccessIterator>::value_type,
typename iterator_traits<_RandomAccessIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __nth);
__glibcxx_requires_valid_range(__nth, __last);
__glibcxx_requires_irreflexive_pred(__first, __last, __comp);
if (__first == __last || __nth == __last)
return;
std::__introselect(__first, __nth, __last,
std::__lg(__last - __first) * 2,
__gnu_cxx::__ops::__iter_comp_iter(__comp));
}
/**
* @brief Sort the elements of a sequence.
* @ingroup sorting_algorithms
* @param __first An iterator.
* @param __last Another iterator.
* @return Nothing.
*
* Sorts the elements in the range @p [__first,__last) in ascending order,
* such that for each iterator @e i in the range @p [__first,__last-1),
* *(i+1)<*i is false.
*
* The relative ordering of equivalent elements is not preserved, use
* @p stable_sort() if this is needed.
*/
template<typename _RandomAccessIterator>
inline void
sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
{
// concept requirements
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>)
__glibcxx_function_requires(_LessThanComparableConcept<
typename iterator_traits<_RandomAccessIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_irreflexive(__first, __last);
std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter());
}
/**
* @brief Sort the elements of a sequence using a predicate for comparison.
* @ingroup sorting_algorithms
* @param __first An iterator.
* @param __last Another iterator.
* @param __comp A comparison functor.
* @return Nothing.
*
* Sorts the elements in the range @p [__first,__last) in ascending order,
* such that @p __comp(*(i+1),*i) is false for every iterator @e i in the
* range @p [__first,__last-1).
*
* The relative ordering of equivalent elements is not preserved, use
* @p stable_sort() if this is needed.
*/
template<typename _RandomAccessIterator, typename _Compare>
inline void
sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
_Compare __comp)
{
// concept requirements
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>)
__glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
typename iterator_traits<_RandomAccessIterator>::value_type,
typename iterator_traits<_RandomAccessIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_irreflexive_pred(__first, __last, __comp);
std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp));
}
template<typename _InputIterator1, typename _InputIterator2,
typename _OutputIterator, typename _Compare>
_OutputIterator
__merge(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2,
_OutputIterator __result, _Compare __comp)
{
while (__first1 != __last1 && __first2 != __last2)
{
if (__comp(__first2, __first1))
{
*__result = *__first2;
++__first2;
}
else
{
*__result = *__first1;
++__first1;
}
++__result;
}
return std::copy(__first2, __last2,
std::copy(__first1, __last1, __result));
}
/**
* @brief Merges two sorted ranges.
* @ingroup sorting_algorithms
* @param __first1 An iterator.
* @param __first2 Another iterator.
* @param __last1 Another iterator.
* @param __last2 Another iterator.
* @param __result An iterator pointing to the end of the merged range.
* @return An iterator pointing to the first element <em>not less
* than</em> @e val.
*
* Merges the ranges @p [__first1,__last1) and @p [__first2,__last2) into
* the sorted range @p [__result, __result + (__last1-__first1) +
* (__last2-__first2)). Both input ranges must be sorted, and the
* output range must not overlap with either of the input ranges.
* The sort is @e stable, that is, for equivalent elements in the
* two ranges, elements from the first range will always come
* before elements from the second.
*/
template<typename _InputIterator1, typename _InputIterator2,
typename _OutputIterator>
inline _OutputIterator
merge(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2,
_OutputIterator __result)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_InputIterator1>::value_type>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_InputIterator2>::value_type>)
__glibcxx_function_requires(_LessThanOpConcept<
typename iterator_traits<_InputIterator2>::value_type,
typename iterator_traits<_InputIterator1>::value_type>)
__glibcxx_requires_sorted_set(__first1, __last1, __first2);
__glibcxx_requires_sorted_set(__first2, __last2, __first1);
__glibcxx_requires_irreflexive2(__first1, __last1);
__glibcxx_requires_irreflexive2(__first2, __last2);
return _GLIBCXX_STD_A::__merge(__first1, __last1,
__first2, __last2, __result,
__gnu_cxx::__ops::__iter_less_iter());
}
/**
* @brief Merges two sorted ranges.
* @ingroup sorting_algorithms
* @param __first1 An iterator.
* @param __first2 Another iterator.
* @param __last1 Another iterator.
* @param __last2 Another iterator.
* @param __result An iterator pointing to the end of the merged range.
* @param __comp A functor to use for comparisons.
* @return An iterator pointing to the first element "not less
* than" @e val.
*
* Merges the ranges @p [__first1,__last1) and @p [__first2,__last2) into
* the sorted range @p [__result, __result + (__last1-__first1) +
* (__last2-__first2)). Both input ranges must be sorted, and the
* output range must not overlap with either of the input ranges.
* The sort is @e stable, that is, for equivalent elements in the
* two ranges, elements from the first range will always come
* before elements from the second.
*
* The comparison function should have the same effects on ordering as
* the function used for the initial sort.
*/
template<typename _InputIterator1, typename _InputIterator2,
typename _OutputIterator, typename _Compare>
inline _OutputIterator
merge(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2,
_OutputIterator __result, _Compare __comp)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_InputIterator1>::value_type>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_InputIterator2>::value_type>)
__glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
typename iterator_traits<_InputIterator2>::value_type,
typename iterator_traits<_InputIterator1>::value_type>)
__glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp);
__glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp);
__glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp);
__glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp);
return _GLIBCXX_STD_A::__merge(__first1, __last1,
__first2, __last2, __result,
__gnu_cxx::__ops::__iter_comp_iter(__comp));
}
template<typename _RandomAccessIterator, typename _Compare>
inline void
__stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
_Compare __comp)
{
typedef typename iterator_traits<_RandomAccessIterator>::value_type
_ValueType;
typedef typename iterator_traits<_RandomAccessIterator>::difference_type
_DistanceType;
typedef _Temporary_buffer<_RandomAccessIterator, _ValueType> _TmpBuf;
_TmpBuf __buf(__first, __last);
if (__buf.begin() == 0)
std::__inplace_stable_sort(__first, __last, __comp);
else
std::__stable_sort_adaptive(__first, __last, __buf.begin(),
_DistanceType(__buf.size()), __comp);
}
/**
* @brief Sort the elements of a sequence, preserving the relative order
* of equivalent elements.
* @ingroup sorting_algorithms
* @param __first An iterator.
* @param __last Another iterator.
* @return Nothing.
*
* Sorts the elements in the range @p [__first,__last) in ascending order,
* such that for each iterator @p i in the range @p [__first,__last-1),
* @p *(i+1)<*i is false.
*
* The relative ordering of equivalent elements is preserved, so any two
* elements @p x and @p y in the range @p [__first,__last) such that
* @p x<y is false and @p y<x is false will have the same relative
* ordering after calling @p stable_sort().
*/
template<typename _RandomAccessIterator>
inline void
stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
{
// concept requirements
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>)
__glibcxx_function_requires(_LessThanComparableConcept<
typename iterator_traits<_RandomAccessIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_irreflexive(__first, __last);
_GLIBCXX_STD_A::__stable_sort(__first, __last,
__gnu_cxx::__ops::__iter_less_iter());
}
/**
* @brief Sort the elements of a sequence using a predicate for comparison,
* preserving the relative order of equivalent elements.
* @ingroup sorting_algorithms
* @param __first An iterator.
* @param __last Another iterator.
* @param __comp A comparison functor.
* @return Nothing.
*
* Sorts the elements in the range @p [__first,__last) in ascending order,
* such that for each iterator @p i in the range @p [__first,__last-1),
* @p __comp(*(i+1),*i) is false.
*
* The relative ordering of equivalent elements is preserved, so any two
* elements @p x and @p y in the range @p [__first,__last) such that
* @p __comp(x,y) is false and @p __comp(y,x) is false will have the same
* relative ordering after calling @p stable_sort().
*/
template<typename _RandomAccessIterator, typename _Compare>
inline void
stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
_Compare __comp)
{
// concept requirements
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>)
__glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
typename iterator_traits<_RandomAccessIterator>::value_type,
typename iterator_traits<_RandomAccessIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_irreflexive_pred(__first, __last, __comp);
_GLIBCXX_STD_A::__stable_sort(__first, __last,
__gnu_cxx::__ops::__iter_comp_iter(__comp));
}
template<typename _InputIterator1, typename _InputIterator2,
typename _OutputIterator,
typename _Compare>
_OutputIterator
__set_union(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2,
_OutputIterator __result, _Compare __comp)
{
while (__first1 != __last1 && __first2 != __last2)
{
if (__comp(__first1, __first2))
{
*__result = *__first1;
++__first1;
}
else if (__comp(__first2, __first1))
{
*__result = *__first2;
++__first2;
}
else
{
*__result = *__first1;
++__first1;
++__first2;
}
++__result;
}
return std::copy(__first2, __last2,
std::copy(__first1, __last1, __result));
}
/**
* @brief Return the union of two sorted ranges.
* @ingroup set_algorithms
* @param __first1 Start of first range.
* @param __last1 End of first range.
* @param __first2 Start of second range.
* @param __last2 End of second range.
* @param __result Start of output range.
* @return End of the output range.
* @ingroup set_algorithms
*
* This operation iterates over both ranges, copying elements present in
* each range in order to the output range. Iterators increment for each
* range. When the current element of one range is less than the other,
* that element is copied and the iterator advanced. If an element is
* contained in both ranges, the element from the first range is copied and
* both ranges advance. The output range may not overlap either input
* range.
*/
template<typename _InputIterator1, typename _InputIterator2,
typename _OutputIterator>
inline _OutputIterator
set_union(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2,
_OutputIterator __result)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_InputIterator1>::value_type>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_InputIterator2>::value_type>)
__glibcxx_function_requires(_LessThanOpConcept<
typename iterator_traits<_InputIterator1>::value_type,
typename iterator_traits<_InputIterator2>::value_type>)
__glibcxx_function_requires(_LessThanOpConcept<
typename iterator_traits<_InputIterator2>::value_type,
typename iterator_traits<_InputIterator1>::value_type>)
__glibcxx_requires_sorted_set(__first1, __last1, __first2);
__glibcxx_requires_sorted_set(__first2, __last2, __first1);
__glibcxx_requires_irreflexive2(__first1, __last1);
__glibcxx_requires_irreflexive2(__first2, __last2);
return _GLIBCXX_STD_A::__set_union(__first1, __last1,
__first2, __last2, __result,
__gnu_cxx::__ops::__iter_less_iter());
}
/**
* @brief Return the union of two sorted ranges using a comparison functor.
* @ingroup set_algorithms
* @param __first1 Start of first range.
* @param __last1 End of first range.
* @param __first2 Start of second range.
* @param __last2 End of second range.
* @param __result Start of output range.
* @param __comp The comparison functor.
* @return End of the output range.
* @ingroup set_algorithms
*
* This operation iterates over both ranges, copying elements present in
* each range in order to the output range. Iterators increment for each
* range. When the current element of one range is less than the other
* according to @p __comp, that element is copied and the iterator advanced.
* If an equivalent element according to @p __comp is contained in both
* ranges, the element from the first range is copied and both ranges
* advance. The output range may not overlap either input range.
*/
template<typename _InputIterator1, typename _InputIterator2,
typename _OutputIterator, typename _Compare>
inline _OutputIterator
set_union(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2,
_OutputIterator __result, _Compare __comp)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_InputIterator1>::value_type>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_InputIterator2>::value_type>)
__glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
typename iterator_traits<_InputIterator1>::value_type,
typename iterator_traits<_InputIterator2>::value_type>)
__glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
typename iterator_traits<_InputIterator2>::value_type,
typename iterator_traits<_InputIterator1>::value_type>)
__glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp);
__glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp);
__glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp);
__glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp);
return _GLIBCXX_STD_A::__set_union(__first1, __last1,
__first2, __last2, __result,
__gnu_cxx::__ops::__iter_comp_iter(__comp));
}
template<typename _InputIterator1, typename _InputIterator2,
typename _OutputIterator,
typename _Compare>
_OutputIterator
__set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2,
_OutputIterator __result, _Compare __comp)
{
while (__first1 != __last1 && __first2 != __last2)
if (__comp(__first1, __first2))
++__first1;
else if (__comp(__first2, __first1))
++__first2;
else
{
*__result = *__first1;
++__first1;
++__first2;
++__result;
}
return __result;
}
/**
* @brief Return the intersection of two sorted ranges.
* @ingroup set_algorithms
* @param __first1 Start of first range.
* @param __last1 End of first range.
* @param __first2 Start of second range.
* @param __last2 End of second range.
* @param __result Start of output range.
* @return End of the output range.
* @ingroup set_algorithms
*
* This operation iterates over both ranges, copying elements present in
* both ranges in order to the output range. Iterators increment for each
* range. When the current element of one range is less than the other,
* that iterator advances. If an element is contained in both ranges, the
* element from the first range is copied and both ranges advance. The
* output range may not overlap either input range.
*/
template<typename _InputIterator1, typename _InputIterator2,
typename _OutputIterator>
inline _OutputIterator
set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2,
_OutputIterator __result)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_InputIterator1>::value_type>)
__glibcxx_function_requires(_LessThanOpConcept<
typename iterator_traits<_InputIterator1>::value_type,
typename iterator_traits<_InputIterator2>::value_type>)
__glibcxx_function_requires(_LessThanOpConcept<
typename iterator_traits<_InputIterator2>::value_type,
typename iterator_traits<_InputIterator1>::value_type>)
__glibcxx_requires_sorted_set(__first1, __last1, __first2);
__glibcxx_requires_sorted_set(__first2, __last2, __first1);
__glibcxx_requires_irreflexive2(__first1, __last1);
__glibcxx_requires_irreflexive2(__first2, __last2);
return _GLIBCXX_STD_A::__set_intersection(__first1, __last1,
__first2, __last2, __result,
__gnu_cxx::__ops::__iter_less_iter());
}
/**
* @brief Return the intersection of two sorted ranges using comparison
* functor.
* @ingroup set_algorithms
* @param __first1 Start of first range.
* @param __last1 End of first range.
* @param __first2 Start of second range.
* @param __last2 End of second range.
* @param __result Start of output range.
* @param __comp The comparison functor.
* @return End of the output range.
* @ingroup set_algorithms
*
* This operation iterates over both ranges, copying elements present in
* both ranges in order to the output range. Iterators increment for each
* range. When the current element of one range is less than the other
* according to @p __comp, that iterator advances. If an element is
* contained in both ranges according to @p __comp, the element from the
* first range is copied and both ranges advance. The output range may not
* overlap either input range.
*/
template<typename _InputIterator1, typename _InputIterator2,
typename _OutputIterator, typename _Compare>
inline _OutputIterator
set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2,
_OutputIterator __result, _Compare __comp)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_InputIterator1>::value_type>)
__glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
typename iterator_traits<_InputIterator1>::value_type,
typename iterator_traits<_InputIterator2>::value_type>)
__glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
typename iterator_traits<_InputIterator2>::value_type,
typename iterator_traits<_InputIterator1>::value_type>)
__glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp);
__glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp);
__glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp);
__glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp);
return _GLIBCXX_STD_A::__set_intersection(__first1, __last1,
__first2, __last2, __result,
__gnu_cxx::__ops::__iter_comp_iter(__comp));
}
template<typename _InputIterator1, typename _InputIterator2,
typename _OutputIterator,
typename _Compare>
_OutputIterator
__set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2,
_OutputIterator __result, _Compare __comp)
{
while (__first1 != __last1 && __first2 != __last2)
if (__comp(__first1, __first2))
{
*__result = *__first1;
++__first1;
++__result;
}
else if (__comp(__first2, __first1))
++__first2;
else
{
++__first1;
++__first2;
}
return std::copy(__first1, __last1, __result);
}
/**
* @brief Return the difference of two sorted ranges.
* @ingroup set_algorithms
* @param __first1 Start of first range.
* @param __last1 End of first range.
* @param __first2 Start of second range.
* @param __last2 End of second range.
* @param __result Start of output range.
* @return End of the output range.
* @ingroup set_algorithms
*
* This operation iterates over both ranges, copying elements present in
* the first range but not the second in order to the output range.
* Iterators increment for each range. When the current element of the
* first range is less than the second, that element is copied and the
* iterator advances. If the current element of the second range is less,
* the iterator advances, but no element is copied. If an element is
* contained in both ranges, no elements are copied and both ranges
* advance. The output range may not overlap either input range.
*/
template<typename _InputIterator1, typename _InputIterator2,
typename _OutputIterator>
inline _OutputIterator
set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2,
_OutputIterator __result)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_InputIterator1>::value_type>)
__glibcxx_function_requires(_LessThanOpConcept<
typename iterator_traits<_InputIterator1>::value_type,
typename iterator_traits<_InputIterator2>::value_type>)
__glibcxx_function_requires(_LessThanOpConcept<
typename iterator_traits<_InputIterator2>::value_type,
typename iterator_traits<_InputIterator1>::value_type>)
__glibcxx_requires_sorted_set(__first1, __last1, __first2);
__glibcxx_requires_sorted_set(__first2, __last2, __first1);
__glibcxx_requires_irreflexive2(__first1, __last1);
__glibcxx_requires_irreflexive2(__first2, __last2);
return _GLIBCXX_STD_A::__set_difference(__first1, __last1,
__first2, __last2, __result,
__gnu_cxx::__ops::__iter_less_iter());
}
/**
* @brief Return the difference of two sorted ranges using comparison
* functor.
* @ingroup set_algorithms
* @param __first1 Start of first range.
* @param __last1 End of first range.
* @param __first2 Start of second range.
* @param __last2 End of second range.
* @param __result Start of output range.
* @param __comp The comparison functor.
* @return End of the output range.
* @ingroup set_algorithms
*
* This operation iterates over both ranges, copying elements present in
* the first range but not the second in order to the output range.
* Iterators increment for each range. When the current element of the
* first range is less than the second according to @p __comp, that element
* is copied and the iterator advances. If the current element of the
* second range is less, no element is copied and the iterator advances.
* If an element is contained in both ranges according to @p __comp, no
* elements are copied and both ranges advance. The output range may not
* overlap either input range.
*/
template<typename _InputIterator1, typename _InputIterator2,
typename _OutputIterator, typename _Compare>
inline _OutputIterator
set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2,
_OutputIterator __result, _Compare __comp)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_InputIterator1>::value_type>)
__glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
typename iterator_traits<_InputIterator1>::value_type,
typename iterator_traits<_InputIterator2>::value_type>)
__glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
typename iterator_traits<_InputIterator2>::value_type,
typename iterator_traits<_InputIterator1>::value_type>)
__glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp);
__glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp);
__glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp);
__glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp);
return _GLIBCXX_STD_A::__set_difference(__first1, __last1,
__first2, __last2, __result,
__gnu_cxx::__ops::__iter_comp_iter(__comp));
}
template<typename _InputIterator1, typename _InputIterator2,
typename _OutputIterator,
typename _Compare>
_OutputIterator
__set_symmetric_difference(_InputIterator1 __first1,
_InputIterator1 __last1,
_InputIterator2 __first2,
_InputIterator2 __last2,
_OutputIterator __result,
_Compare __comp)
{
while (__first1 != __last1 && __first2 != __last2)
if (__comp(__first1, __first2))
{
*__result = *__first1;
++__first1;
++__result;
}
else if (__comp(__first2, __first1))
{
*__result = *__first2;
++__first2;
++__result;
}
else
{
++__first1;
++__first2;
}
return std::copy(__first2, __last2,
std::copy(__first1, __last1, __result));
}
/**
* @brief Return the symmetric difference of two sorted ranges.
* @ingroup set_algorithms
* @param __first1 Start of first range.
* @param __last1 End of first range.
* @param __first2 Start of second range.
* @param __last2 End of second range.
* @param __result Start of output range.
* @return End of the output range.
* @ingroup set_algorithms
*
* This operation iterates over both ranges, copying elements present in
* one range but not the other in order to the output range. Iterators
* increment for each range. When the current element of one range is less
* than the other, that element is copied and the iterator advances. If an
* element is contained in both ranges, no elements are copied and both
* ranges advance. The output range may not overlap either input range.
*/
template<typename _InputIterator1, typename _InputIterator2,
typename _OutputIterator>
inline _OutputIterator
set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2,
_OutputIterator __result)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_InputIterator1>::value_type>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_InputIterator2>::value_type>)
__glibcxx_function_requires(_LessThanOpConcept<
typename iterator_traits<_InputIterator1>::value_type,
typename iterator_traits<_InputIterator2>::value_type>)
__glibcxx_function_requires(_LessThanOpConcept<
typename iterator_traits<_InputIterator2>::value_type,
typename iterator_traits<_InputIterator1>::value_type>)
__glibcxx_requires_sorted_set(__first1, __last1, __first2);
__glibcxx_requires_sorted_set(__first2, __last2, __first1);
__glibcxx_requires_irreflexive2(__first1, __last1);
__glibcxx_requires_irreflexive2(__first2, __last2);
return _GLIBCXX_STD_A::__set_symmetric_difference(__first1, __last1,
__first2, __last2, __result,
__gnu_cxx::__ops::__iter_less_iter());
}
/**
* @brief Return the symmetric difference of two sorted ranges using
* comparison functor.
* @ingroup set_algorithms
* @param __first1 Start of first range.
* @param __last1 End of first range.
* @param __first2 Start of second range.
* @param __last2 End of second range.
* @param __result Start of output range.
* @param __comp The comparison functor.
* @return End of the output range.
* @ingroup set_algorithms
*
* This operation iterates over both ranges, copying elements present in
* one range but not the other in order to the output range. Iterators
* increment for each range. When the current element of one range is less
* than the other according to @p comp, that element is copied and the
* iterator advances. If an element is contained in both ranges according
* to @p __comp, no elements are copied and both ranges advance. The output
* range may not overlap either input range.
*/
template<typename _InputIterator1, typename _InputIterator2,
typename _OutputIterator, typename _Compare>
inline _OutputIterator
set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2,
_OutputIterator __result,
_Compare __comp)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_InputIterator1>::value_type>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_InputIterator2>::value_type>)
__glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
typename iterator_traits<_InputIterator1>::value_type,
typename iterator_traits<_InputIterator2>::value_type>)
__glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
typename iterator_traits<_InputIterator2>::value_type,
typename iterator_traits<_InputIterator1>::value_type>)
__glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp);
__glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp);
__glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp);
__glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp);
return _GLIBCXX_STD_A::__set_symmetric_difference(__first1, __last1,
__first2, __last2, __result,
__gnu_cxx::__ops::__iter_comp_iter(__comp));
}
template<typename _ForwardIterator, typename _Compare>
_GLIBCXX14_CONSTEXPR
_ForwardIterator
__min_element(_ForwardIterator __first, _ForwardIterator __last,
_Compare __comp)
{
if (__first == __last)
return __first;
_ForwardIterator __result = __first;
while (++__first != __last)
if (__comp(__first, __result))
__result = __first;
return __result;
}
/**
* @brief Return the minimum element in a range.
* @ingroup sorting_algorithms
* @param __first Start of range.
* @param __last End of range.
* @return Iterator referencing the first instance of the smallest value.
*/
template<typename _ForwardIterator>
_GLIBCXX14_CONSTEXPR
_ForwardIterator
inline min_element(_ForwardIterator __first, _ForwardIterator __last)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_LessThanComparableConcept<
typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_irreflexive(__first, __last);
return _GLIBCXX_STD_A::__min_element(__first, __last,
__gnu_cxx::__ops::__iter_less_iter());
}
/**
* @brief Return the minimum element in a range using comparison functor.
* @ingroup sorting_algorithms
* @param __first Start of range.
* @param __last End of range.
* @param __comp Comparison functor.
* @return Iterator referencing the first instance of the smallest value
* according to __comp.
*/
template<typename _ForwardIterator, typename _Compare>
_GLIBCXX14_CONSTEXPR
inline _ForwardIterator
min_element(_ForwardIterator __first, _ForwardIterator __last,
_Compare __comp)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
typename iterator_traits<_ForwardIterator>::value_type,
typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_irreflexive_pred(__first, __last, __comp);
return _GLIBCXX_STD_A::__min_element(__first, __last,
__gnu_cxx::__ops::__iter_comp_iter(__comp));
}
template<typename _ForwardIterator, typename _Compare>
_GLIBCXX14_CONSTEXPR
_ForwardIterator
__max_element(_ForwardIterator __first, _ForwardIterator __last,
_Compare __comp)
{
if (__first == __last) return __first;
_ForwardIterator __result = __first;
while (++__first != __last)
if (__comp(__result, __first))
__result = __first;
return __result;
}
/**
* @brief Return the maximum element in a range.
* @ingroup sorting_algorithms
* @param __first Start of range.
* @param __last End of range.
* @return Iterator referencing the first instance of the largest value.
*/
template<typename _ForwardIterator>
_GLIBCXX14_CONSTEXPR
inline _ForwardIterator
max_element(_ForwardIterator __first, _ForwardIterator __last)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_LessThanComparableConcept<
typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_irreflexive(__first, __last);
return _GLIBCXX_STD_A::__max_element(__first, __last,
__gnu_cxx::__ops::__iter_less_iter());
}
/**
* @brief Return the maximum element in a range using comparison functor.
* @ingroup sorting_algorithms
* @param __first Start of range.
* @param __last End of range.
* @param __comp Comparison functor.
* @return Iterator referencing the first instance of the largest value
* according to __comp.
*/
template<typename _ForwardIterator, typename _Compare>
_GLIBCXX14_CONSTEXPR
inline _ForwardIterator
max_element(_ForwardIterator __first, _ForwardIterator __last,
_Compare __comp)
{
// concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
typename iterator_traits<_ForwardIterator>::value_type,
typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_irreflexive_pred(__first, __last, __comp);
return _GLIBCXX_STD_A::__max_element(__first, __last,
__gnu_cxx::__ops::__iter_comp_iter(__comp));
}
#if __cplusplus >= 201402L
/// Reservoir sampling algorithm.
template<typename _InputIterator, typename _RandomAccessIterator,
typename _Size, typename _UniformRandomBitGenerator>
_RandomAccessIterator
__sample(_InputIterator __first, _InputIterator __last, input_iterator_tag,
_RandomAccessIterator __out, random_access_iterator_tag,
_Size __n, _UniformRandomBitGenerator&& __g)
{
using __distrib_type = uniform_int_distribution<_Size>;
using __param_type = typename __distrib_type::param_type;
__distrib_type __d{};
_Size __sample_sz = 0;
while (__first != __last && __sample_sz != __n)
{
__out[__sample_sz++] = *__first;
++__first;
}
for (auto __pop_sz = __sample_sz; __first != __last;
++__first, (void) ++__pop_sz)
{
const auto __k = __d(__g, __param_type{0, __pop_sz});
if (__k < __n)
__out[__k] = *__first;
}
return __out + __sample_sz;
}
/// Selection sampling algorithm.
template<typename _ForwardIterator, typename _OutputIterator, typename _Cat,
typename _Size, typename _UniformRandomBitGenerator>
_OutputIterator
__sample(_ForwardIterator __first, _ForwardIterator __last,
forward_iterator_tag,
_OutputIterator __out, _Cat,
_Size __n, _UniformRandomBitGenerator&& __g)
{
using __distrib_type = uniform_int_distribution<_Size>;
using __param_type = typename __distrib_type::param_type;
using _USize = make_unsigned_t<_Size>;
using _Gen = remove_reference_t<_UniformRandomBitGenerator>;
using __uc_type = common_type_t<typename _Gen::result_type, _USize>;
if (__first == __last)
return __out;
__distrib_type __d{};
_Size __unsampled_sz = std::distance(__first, __last);
__n = std::min(__n, __unsampled_sz);
// If possible, we use __gen_two_uniform_ints to efficiently produce
// two random numbers using a single distribution invocation:
const __uc_type __urngrange = __g.max() - __g.min();
if (__urngrange / __uc_type(__unsampled_sz) >= __uc_type(__unsampled_sz))
// I.e. (__urngrange >= __unsampled_sz * __unsampled_sz) but without
// wrapping issues.
{
while (__n != 0 && __unsampled_sz >= 2)
{
const pair<_Size, _Size> __p =
__gen_two_uniform_ints(__unsampled_sz, __unsampled_sz - 1, __g);
--__unsampled_sz;
if (__p.first < __n)
{
*__out++ = *__first;
--__n;
}
++__first;
if (__n == 0) break;
--__unsampled_sz;
if (__p.second < __n)
{
*__out++ = *__first;
--__n;
}
++__first;
}
}
// The loop above is otherwise equivalent to this one-at-a-time version:
for (; __n != 0; ++__first)
if (__d(__g, __param_type{0, --__unsampled_sz}) < __n)
{
*__out++ = *__first;
--__n;
}
return __out;
}
#if __cplusplus > 201402L
#define __cpp_lib_sample 201603
/// Take a random sample from a population.
template<typename _PopulationIterator, typename _SampleIterator,
typename _Distance, typename _UniformRandomBitGenerator>
_SampleIterator
sample(_PopulationIterator __first, _PopulationIterator __last,
_SampleIterator __out, _Distance __n,
_UniformRandomBitGenerator&& __g)
{
using __pop_cat = typename
std::iterator_traits<_PopulationIterator>::iterator_category;
using __samp_cat = typename
std::iterator_traits<_SampleIterator>::iterator_category;
static_assert(
__or_<is_convertible<__pop_cat, forward_iterator_tag>,
is_convertible<__samp_cat, random_access_iterator_tag>>::value,
"output range must use a RandomAccessIterator when input range"
" does not meet the ForwardIterator requirements");
static_assert(is_integral<_Distance>::value,
"sample size must be an integer type");
typename iterator_traits<_PopulationIterator>::difference_type __d = __n;
return _GLIBCXX_STD_A::
__sample(__first, __last, __pop_cat{}, __out, __samp_cat{}, __d,
std::forward<_UniformRandomBitGenerator>(__g));
}
#endif // C++17
#endif // C++14
_GLIBCXX_END_NAMESPACE_ALGO
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif /* _STL_ALGO_H */
c++/8/bits/fs_fwd.h 0000644 00000024047 15201526705 0007657 0 ustar 00 // Filesystem declarations -*- C++ -*-
// Copyright (C) 2014-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/bits/fs_fwd.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{filesystem}
*/
#ifndef _GLIBCXX_FS_FWD_H
#define _GLIBCXX_FS_FWD_H 1
#if __cplusplus >= 201703L
#include <system_error>
#include <cstdint>
#include <chrono>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
namespace filesystem
{
#if _GLIBCXX_USE_CXX11_ABI
inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
#endif
/**
* @defgroup filesystem Filesystem
*
* Utilities for performing operations on file systems and their components,
* such as paths, regular files, and directories.
*
* @{
*/
class file_status;
_GLIBCXX_BEGIN_NAMESPACE_CXX11
class path;
class filesystem_error;
class directory_entry;
class directory_iterator;
class recursive_directory_iterator;
_GLIBCXX_END_NAMESPACE_CXX11
struct space_info
{
uintmax_t capacity;
uintmax_t free;
uintmax_t available;
};
enum class file_type : signed char {
none = 0, not_found = -1, regular = 1, directory = 2, symlink = 3,
block = 4, character = 5, fifo = 6, socket = 7, unknown = 8
};
/// Bitmask type
enum class copy_options : unsigned short {
none = 0,
skip_existing = 1, overwrite_existing = 2, update_existing = 4,
recursive = 8,
copy_symlinks = 16, skip_symlinks = 32,
directories_only = 64, create_symlinks = 128, create_hard_links = 256
};
constexpr copy_options
operator&(copy_options __x, copy_options __y) noexcept
{
using __utype = typename std::underlying_type<copy_options>::type;
return static_cast<copy_options>(
static_cast<__utype>(__x) & static_cast<__utype>(__y));
}
constexpr copy_options
operator|(copy_options __x, copy_options __y) noexcept
{
using __utype = typename std::underlying_type<copy_options>::type;
return static_cast<copy_options>(
static_cast<__utype>(__x) | static_cast<__utype>(__y));
}
constexpr copy_options
operator^(copy_options __x, copy_options __y) noexcept
{
using __utype = typename std::underlying_type<copy_options>::type;
return static_cast<copy_options>(
static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
}
constexpr copy_options
operator~(copy_options __x) noexcept
{
using __utype = typename std::underlying_type<copy_options>::type;
return static_cast<copy_options>(~static_cast<__utype>(__x));
}
inline copy_options&
operator&=(copy_options& __x, copy_options __y) noexcept
{ return __x = __x & __y; }
inline copy_options&
operator|=(copy_options& __x, copy_options __y) noexcept
{ return __x = __x | __y; }
inline copy_options&
operator^=(copy_options& __x, copy_options __y) noexcept
{ return __x = __x ^ __y; }
/// Bitmask type
enum class perms : unsigned {
none = 0,
owner_read = 0400,
owner_write = 0200,
owner_exec = 0100,
owner_all = 0700,
group_read = 040,
group_write = 020,
group_exec = 010,
group_all = 070,
others_read = 04,
others_write = 02,
others_exec = 01,
others_all = 07,
all = 0777,
set_uid = 04000,
set_gid = 02000,
sticky_bit = 01000,
mask = 07777,
unknown = 0xFFFF,
};
constexpr perms
operator&(perms __x, perms __y) noexcept
{
using __utype = typename std::underlying_type<perms>::type;
return static_cast<perms>(
static_cast<__utype>(__x) & static_cast<__utype>(__y));
}
constexpr perms
operator|(perms __x, perms __y) noexcept
{
using __utype = typename std::underlying_type<perms>::type;
return static_cast<perms>(
static_cast<__utype>(__x) | static_cast<__utype>(__y));
}
constexpr perms
operator^(perms __x, perms __y) noexcept
{
using __utype = typename std::underlying_type<perms>::type;
return static_cast<perms>(
static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
}
constexpr perms
operator~(perms __x) noexcept
{
using __utype = typename std::underlying_type<perms>::type;
return static_cast<perms>(~static_cast<__utype>(__x));
}
inline perms&
operator&=(perms& __x, perms __y) noexcept
{ return __x = __x & __y; }
inline perms&
operator|=(perms& __x, perms __y) noexcept
{ return __x = __x | __y; }
inline perms&
operator^=(perms& __x, perms __y) noexcept
{ return __x = __x ^ __y; }
/// Bitmask type
enum class perm_options : unsigned {
replace = 0x1,
add = 0x2,
remove = 0x4,
nofollow = 0x8
};
constexpr perm_options
operator&(perm_options __x, perm_options __y) noexcept
{
using __utype = typename std::underlying_type<perm_options>::type;
return static_cast<perm_options>(
static_cast<__utype>(__x) & static_cast<__utype>(__y));
}
constexpr perm_options
operator|(perm_options __x, perm_options __y) noexcept
{
using __utype = typename std::underlying_type<perm_options>::type;
return static_cast<perm_options>(
static_cast<__utype>(__x) | static_cast<__utype>(__y));
}
constexpr perm_options
operator^(perm_options __x, perm_options __y) noexcept
{
using __utype = typename std::underlying_type<perm_options>::type;
return static_cast<perm_options>(
static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
}
constexpr perm_options
operator~(perm_options __x) noexcept
{
using __utype = typename std::underlying_type<perm_options>::type;
return static_cast<perm_options>(~static_cast<__utype>(__x));
}
inline perm_options&
operator&=(perm_options& __x, perm_options __y) noexcept
{ return __x = __x & __y; }
inline perm_options&
operator|=(perm_options& __x, perm_options __y) noexcept
{ return __x = __x | __y; }
inline perm_options&
operator^=(perm_options& __x, perm_options __y) noexcept
{ return __x = __x ^ __y; }
// Bitmask type
enum class directory_options : unsigned char {
none = 0, follow_directory_symlink = 1, skip_permission_denied = 2
};
constexpr directory_options
operator&(directory_options __x, directory_options __y) noexcept
{
using __utype = typename std::underlying_type<directory_options>::type;
return static_cast<directory_options>(
static_cast<__utype>(__x) & static_cast<__utype>(__y));
}
constexpr directory_options
operator|(directory_options __x, directory_options __y) noexcept
{
using __utype = typename std::underlying_type<directory_options>::type;
return static_cast<directory_options>(
static_cast<__utype>(__x) | static_cast<__utype>(__y));
}
constexpr directory_options
operator^(directory_options __x, directory_options __y) noexcept
{
using __utype = typename std::underlying_type<directory_options>::type;
return static_cast<directory_options>(
static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
}
constexpr directory_options
operator~(directory_options __x) noexcept
{
using __utype = typename std::underlying_type<directory_options>::type;
return static_cast<directory_options>(~static_cast<__utype>(__x));
}
inline directory_options&
operator&=(directory_options& __x, directory_options __y) noexcept
{ return __x = __x & __y; }
inline directory_options&
operator|=(directory_options& __x, directory_options __y) noexcept
{ return __x = __x | __y; }
inline directory_options&
operator^=(directory_options& __x, directory_options __y) noexcept
{ return __x = __x ^ __y; }
using file_time_type = std::chrono::system_clock::time_point;
// operational functions
void copy(const path& __from, const path& __to, copy_options __options);
void copy(const path& __from, const path& __to, copy_options __options,
error_code&);
bool copy_file(const path& __from, const path& __to, copy_options __option);
bool copy_file(const path& __from, const path& __to, copy_options __option,
error_code&);
path current_path();
bool exists(file_status) noexcept;
bool is_other(file_status) noexcept;
uintmax_t file_size(const path&);
uintmax_t file_size(const path&, error_code&) noexcept;
uintmax_t hard_link_count(const path&);
uintmax_t hard_link_count(const path&, error_code&) noexcept;
file_time_type last_write_time(const path&);
file_time_type last_write_time(const path&, error_code&) noexcept;
void permissions(const path&, perms, perm_options, error_code&) noexcept;
path proximate(const path& __p, const path& __base, error_code& __ec);
path proximate(const path& __p, const path& __base, error_code& __ec);
path relative(const path& __p, const path& __base, error_code& __ec);
file_status status(const path&);
file_status status(const path&, error_code&) noexcept;
bool status_known(file_status) noexcept;
file_status symlink_status(const path&);
file_status symlink_status(const path&, error_code&) noexcept;
bool is_regular_file(file_status) noexcept;
bool is_symlink(file_status) noexcept;
// @} group filesystem
} // namespace filesystem
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // C++17
#endif // _GLIBCXX_FS_FWD_H
c++/8/bits/stl_uninitialized.h 0000644 00000066075 15201526705 0012150 0 ustar 00 // Raw memory manipulators -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1996,1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file bits/stl_uninitialized.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{memory}
*/
#ifndef _STL_UNINITIALIZED_H
#define _STL_UNINITIALIZED_H 1
#if __cplusplus > 201402L
#include <utility>
#endif
#if __cplusplus >= 201103L
#include <type_traits>
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<bool _TrivialValueTypes>
struct __uninitialized_copy
{
template<typename _InputIterator, typename _ForwardIterator>
static _ForwardIterator
__uninit_copy(_InputIterator __first, _InputIterator __last,
_ForwardIterator __result)
{
_ForwardIterator __cur = __result;
__try
{
for (; __first != __last; ++__first, (void)++__cur)
std::_Construct(std::__addressof(*__cur), *__first);
return __cur;
}
__catch(...)
{
std::_Destroy(__result, __cur);
__throw_exception_again;
}
}
};
template<>
struct __uninitialized_copy<true>
{
template<typename _InputIterator, typename _ForwardIterator>
static _ForwardIterator
__uninit_copy(_InputIterator __first, _InputIterator __last,
_ForwardIterator __result)
{ return std::copy(__first, __last, __result); }
};
/**
* @brief Copies the range [first,last) into result.
* @param __first An input iterator.
* @param __last An input iterator.
* @param __result An output iterator.
* @return __result + (__first - __last)
*
* Like copy(), but does not require an initialized output range.
*/
template<typename _InputIterator, typename _ForwardIterator>
inline _ForwardIterator
uninitialized_copy(_InputIterator __first, _InputIterator __last,
_ForwardIterator __result)
{
typedef typename iterator_traits<_InputIterator>::value_type
_ValueType1;
typedef typename iterator_traits<_ForwardIterator>::value_type
_ValueType2;
#if __cplusplus < 201103L
const bool __assignable = true;
#else
// trivial types can have deleted assignment
typedef typename iterator_traits<_InputIterator>::reference _RefType1;
typedef typename iterator_traits<_ForwardIterator>::reference _RefType2;
const bool __assignable = is_assignable<_RefType2, _RefType1>::value;
#endif
return std::__uninitialized_copy<__is_trivial(_ValueType1)
&& __is_trivial(_ValueType2)
&& __assignable>::
__uninit_copy(__first, __last, __result);
}
template<bool _TrivialValueType>
struct __uninitialized_fill
{
template<typename _ForwardIterator, typename _Tp>
static void
__uninit_fill(_ForwardIterator __first, _ForwardIterator __last,
const _Tp& __x)
{
_ForwardIterator __cur = __first;
__try
{
for (; __cur != __last; ++__cur)
std::_Construct(std::__addressof(*__cur), __x);
}
__catch(...)
{
std::_Destroy(__first, __cur);
__throw_exception_again;
}
}
};
template<>
struct __uninitialized_fill<true>
{
template<typename _ForwardIterator, typename _Tp>
static void
__uninit_fill(_ForwardIterator __first, _ForwardIterator __last,
const _Tp& __x)
{ std::fill(__first, __last, __x); }
};
/**
* @brief Copies the value x into the range [first,last).
* @param __first An input iterator.
* @param __last An input iterator.
* @param __x The source value.
* @return Nothing.
*
* Like fill(), but does not require an initialized output range.
*/
template<typename _ForwardIterator, typename _Tp>
inline void
uninitialized_fill(_ForwardIterator __first, _ForwardIterator __last,
const _Tp& __x)
{
typedef typename iterator_traits<_ForwardIterator>::value_type
_ValueType;
#if __cplusplus < 201103L
const bool __assignable = true;
#else
// trivial types can have deleted assignment
const bool __assignable = is_copy_assignable<_ValueType>::value;
#endif
std::__uninitialized_fill<__is_trivial(_ValueType) && __assignable>::
__uninit_fill(__first, __last, __x);
}
template<bool _TrivialValueType>
struct __uninitialized_fill_n
{
template<typename _ForwardIterator, typename _Size, typename _Tp>
static _ForwardIterator
__uninit_fill_n(_ForwardIterator __first, _Size __n,
const _Tp& __x)
{
_ForwardIterator __cur = __first;
__try
{
for (; __n > 0; --__n, (void) ++__cur)
std::_Construct(std::__addressof(*__cur), __x);
return __cur;
}
__catch(...)
{
std::_Destroy(__first, __cur);
__throw_exception_again;
}
}
};
template<>
struct __uninitialized_fill_n<true>
{
template<typename _ForwardIterator, typename _Size, typename _Tp>
static _ForwardIterator
__uninit_fill_n(_ForwardIterator __first, _Size __n,
const _Tp& __x)
{ return std::fill_n(__first, __n, __x); }
};
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 1339. uninitialized_fill_n should return the end of its range
/**
* @brief Copies the value x into the range [first,first+n).
* @param __first An input iterator.
* @param __n The number of copies to make.
* @param __x The source value.
* @return Nothing.
*
* Like fill_n(), but does not require an initialized output range.
*/
template<typename _ForwardIterator, typename _Size, typename _Tp>
inline _ForwardIterator
uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x)
{
typedef typename iterator_traits<_ForwardIterator>::value_type
_ValueType;
#if __cplusplus < 201103L
const bool __assignable = true;
#else
// trivial types can have deleted assignment
const bool __assignable = is_copy_assignable<_ValueType>::value;
#endif
return __uninitialized_fill_n<__is_trivial(_ValueType) && __assignable>::
__uninit_fill_n(__first, __n, __x);
}
// Extensions: versions of uninitialized_copy, uninitialized_fill,
// and uninitialized_fill_n that take an allocator parameter.
// We dispatch back to the standard versions when we're given the
// default allocator. For nondefault allocators we do not use
// any of the POD optimizations.
template<typename _InputIterator, typename _ForwardIterator,
typename _Allocator>
_ForwardIterator
__uninitialized_copy_a(_InputIterator __first, _InputIterator __last,
_ForwardIterator __result, _Allocator& __alloc)
{
_ForwardIterator __cur = __result;
__try
{
typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
for (; __first != __last; ++__first, (void)++__cur)
__traits::construct(__alloc, std::__addressof(*__cur), *__first);
return __cur;
}
__catch(...)
{
std::_Destroy(__result, __cur, __alloc);
__throw_exception_again;
}
}
template<typename _InputIterator, typename _ForwardIterator, typename _Tp>
inline _ForwardIterator
__uninitialized_copy_a(_InputIterator __first, _InputIterator __last,
_ForwardIterator __result, allocator<_Tp>&)
{ return std::uninitialized_copy(__first, __last, __result); }
template<typename _InputIterator, typename _ForwardIterator,
typename _Allocator>
inline _ForwardIterator
__uninitialized_move_a(_InputIterator __first, _InputIterator __last,
_ForwardIterator __result, _Allocator& __alloc)
{
return std::__uninitialized_copy_a(_GLIBCXX_MAKE_MOVE_ITERATOR(__first),
_GLIBCXX_MAKE_MOVE_ITERATOR(__last),
__result, __alloc);
}
template<typename _InputIterator, typename _ForwardIterator,
typename _Allocator>
inline _ForwardIterator
__uninitialized_move_if_noexcept_a(_InputIterator __first,
_InputIterator __last,
_ForwardIterator __result,
_Allocator& __alloc)
{
return std::__uninitialized_copy_a
(_GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__first),
_GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__last), __result, __alloc);
}
template<typename _ForwardIterator, typename _Tp, typename _Allocator>
void
__uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
const _Tp& __x, _Allocator& __alloc)
{
_ForwardIterator __cur = __first;
__try
{
typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
for (; __cur != __last; ++__cur)
__traits::construct(__alloc, std::__addressof(*__cur), __x);
}
__catch(...)
{
std::_Destroy(__first, __cur, __alloc);
__throw_exception_again;
}
}
template<typename _ForwardIterator, typename _Tp, typename _Tp2>
inline void
__uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
const _Tp& __x, allocator<_Tp2>&)
{ std::uninitialized_fill(__first, __last, __x); }
template<typename _ForwardIterator, typename _Size, typename _Tp,
typename _Allocator>
_ForwardIterator
__uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
const _Tp& __x, _Allocator& __alloc)
{
_ForwardIterator __cur = __first;
__try
{
typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
for (; __n > 0; --__n, (void) ++__cur)
__traits::construct(__alloc, std::__addressof(*__cur), __x);
return __cur;
}
__catch(...)
{
std::_Destroy(__first, __cur, __alloc);
__throw_exception_again;
}
}
template<typename _ForwardIterator, typename _Size, typename _Tp,
typename _Tp2>
inline _ForwardIterator
__uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
const _Tp& __x, allocator<_Tp2>&)
{ return std::uninitialized_fill_n(__first, __n, __x); }
// Extensions: __uninitialized_copy_move, __uninitialized_move_copy,
// __uninitialized_fill_move, __uninitialized_move_fill.
// All of these algorithms take a user-supplied allocator, which is used
// for construction and destruction.
// __uninitialized_copy_move
// Copies [first1, last1) into [result, result + (last1 - first1)), and
// move [first2, last2) into
// [result, result + (last1 - first1) + (last2 - first2)).
template<typename _InputIterator1, typename _InputIterator2,
typename _ForwardIterator, typename _Allocator>
inline _ForwardIterator
__uninitialized_copy_move(_InputIterator1 __first1,
_InputIterator1 __last1,
_InputIterator2 __first2,
_InputIterator2 __last2,
_ForwardIterator __result,
_Allocator& __alloc)
{
_ForwardIterator __mid = std::__uninitialized_copy_a(__first1, __last1,
__result,
__alloc);
__try
{
return std::__uninitialized_move_a(__first2, __last2, __mid, __alloc);
}
__catch(...)
{
std::_Destroy(__result, __mid, __alloc);
__throw_exception_again;
}
}
// __uninitialized_move_copy
// Moves [first1, last1) into [result, result + (last1 - first1)), and
// copies [first2, last2) into
// [result, result + (last1 - first1) + (last2 - first2)).
template<typename _InputIterator1, typename _InputIterator2,
typename _ForwardIterator, typename _Allocator>
inline _ForwardIterator
__uninitialized_move_copy(_InputIterator1 __first1,
_InputIterator1 __last1,
_InputIterator2 __first2,
_InputIterator2 __last2,
_ForwardIterator __result,
_Allocator& __alloc)
{
_ForwardIterator __mid = std::__uninitialized_move_a(__first1, __last1,
__result,
__alloc);
__try
{
return std::__uninitialized_copy_a(__first2, __last2, __mid, __alloc);
}
__catch(...)
{
std::_Destroy(__result, __mid, __alloc);
__throw_exception_again;
}
}
// __uninitialized_fill_move
// Fills [result, mid) with x, and moves [first, last) into
// [mid, mid + (last - first)).
template<typename _ForwardIterator, typename _Tp, typename _InputIterator,
typename _Allocator>
inline _ForwardIterator
__uninitialized_fill_move(_ForwardIterator __result, _ForwardIterator __mid,
const _Tp& __x, _InputIterator __first,
_InputIterator __last, _Allocator& __alloc)
{
std::__uninitialized_fill_a(__result, __mid, __x, __alloc);
__try
{
return std::__uninitialized_move_a(__first, __last, __mid, __alloc);
}
__catch(...)
{
std::_Destroy(__result, __mid, __alloc);
__throw_exception_again;
}
}
// __uninitialized_move_fill
// Moves [first1, last1) into [first2, first2 + (last1 - first1)), and
// fills [first2 + (last1 - first1), last2) with x.
template<typename _InputIterator, typename _ForwardIterator, typename _Tp,
typename _Allocator>
inline void
__uninitialized_move_fill(_InputIterator __first1, _InputIterator __last1,
_ForwardIterator __first2,
_ForwardIterator __last2, const _Tp& __x,
_Allocator& __alloc)
{
_ForwardIterator __mid2 = std::__uninitialized_move_a(__first1, __last1,
__first2,
__alloc);
__try
{
std::__uninitialized_fill_a(__mid2, __last2, __x, __alloc);
}
__catch(...)
{
std::_Destroy(__first2, __mid2, __alloc);
__throw_exception_again;
}
}
#if __cplusplus >= 201103L
// Extensions: __uninitialized_default, __uninitialized_default_n,
// __uninitialized_default_a, __uninitialized_default_n_a.
template<bool _TrivialValueType>
struct __uninitialized_default_1
{
template<typename _ForwardIterator>
static void
__uninit_default(_ForwardIterator __first, _ForwardIterator __last)
{
_ForwardIterator __cur = __first;
__try
{
for (; __cur != __last; ++__cur)
std::_Construct(std::__addressof(*__cur));
}
__catch(...)
{
std::_Destroy(__first, __cur);
__throw_exception_again;
}
}
};
template<>
struct __uninitialized_default_1<true>
{
template<typename _ForwardIterator>
static void
__uninit_default(_ForwardIterator __first, _ForwardIterator __last)
{
typedef typename iterator_traits<_ForwardIterator>::value_type
_ValueType;
std::fill(__first, __last, _ValueType());
}
};
template<bool _TrivialValueType>
struct __uninitialized_default_n_1
{
template<typename _ForwardIterator, typename _Size>
static _ForwardIterator
__uninit_default_n(_ForwardIterator __first, _Size __n)
{
_ForwardIterator __cur = __first;
__try
{
for (; __n > 0; --__n, (void) ++__cur)
std::_Construct(std::__addressof(*__cur));
return __cur;
}
__catch(...)
{
std::_Destroy(__first, __cur);
__throw_exception_again;
}
}
};
template<>
struct __uninitialized_default_n_1<true>
{
template<typename _ForwardIterator, typename _Size>
static _ForwardIterator
__uninit_default_n(_ForwardIterator __first, _Size __n)
{
typedef typename iterator_traits<_ForwardIterator>::value_type
_ValueType;
return std::fill_n(__first, __n, _ValueType());
}
};
// __uninitialized_default
// Fills [first, last) with std::distance(first, last) default
// constructed value_types(s).
template<typename _ForwardIterator>
inline void
__uninitialized_default(_ForwardIterator __first,
_ForwardIterator __last)
{
typedef typename iterator_traits<_ForwardIterator>::value_type
_ValueType;
// trivial types can have deleted assignment
const bool __assignable = is_copy_assignable<_ValueType>::value;
std::__uninitialized_default_1<__is_trivial(_ValueType)
&& __assignable>::
__uninit_default(__first, __last);
}
// __uninitialized_default_n
// Fills [first, first + n) with n default constructed value_type(s).
template<typename _ForwardIterator, typename _Size>
inline _ForwardIterator
__uninitialized_default_n(_ForwardIterator __first, _Size __n)
{
typedef typename iterator_traits<_ForwardIterator>::value_type
_ValueType;
// trivial types can have deleted assignment
const bool __assignable = is_copy_assignable<_ValueType>::value;
return __uninitialized_default_n_1<__is_trivial(_ValueType)
&& __assignable>::
__uninit_default_n(__first, __n);
}
// __uninitialized_default_a
// Fills [first, last) with std::distance(first, last) default
// constructed value_types(s), constructed with the allocator alloc.
template<typename _ForwardIterator, typename _Allocator>
void
__uninitialized_default_a(_ForwardIterator __first,
_ForwardIterator __last,
_Allocator& __alloc)
{
_ForwardIterator __cur = __first;
__try
{
typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
for (; __cur != __last; ++__cur)
__traits::construct(__alloc, std::__addressof(*__cur));
}
__catch(...)
{
std::_Destroy(__first, __cur, __alloc);
__throw_exception_again;
}
}
template<typename _ForwardIterator, typename _Tp>
inline void
__uninitialized_default_a(_ForwardIterator __first,
_ForwardIterator __last,
allocator<_Tp>&)
{ std::__uninitialized_default(__first, __last); }
// __uninitialized_default_n_a
// Fills [first, first + n) with n default constructed value_types(s),
// constructed with the allocator alloc.
template<typename _ForwardIterator, typename _Size, typename _Allocator>
_ForwardIterator
__uninitialized_default_n_a(_ForwardIterator __first, _Size __n,
_Allocator& __alloc)
{
_ForwardIterator __cur = __first;
__try
{
typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
for (; __n > 0; --__n, (void) ++__cur)
__traits::construct(__alloc, std::__addressof(*__cur));
return __cur;
}
__catch(...)
{
std::_Destroy(__first, __cur, __alloc);
__throw_exception_again;
}
}
template<typename _ForwardIterator, typename _Size, typename _Tp>
inline _ForwardIterator
__uninitialized_default_n_a(_ForwardIterator __first, _Size __n,
allocator<_Tp>&)
{ return std::__uninitialized_default_n(__first, __n); }
template<bool _TrivialValueType>
struct __uninitialized_default_novalue_1
{
template<typename _ForwardIterator>
static void
__uninit_default_novalue(_ForwardIterator __first,
_ForwardIterator __last)
{
_ForwardIterator __cur = __first;
__try
{
for (; __cur != __last; ++__cur)
std::_Construct_novalue(std::__addressof(*__cur));
}
__catch(...)
{
std::_Destroy(__first, __cur);
__throw_exception_again;
}
}
};
template<>
struct __uninitialized_default_novalue_1<true>
{
template<typename _ForwardIterator>
static void
__uninit_default_novalue(_ForwardIterator __first,
_ForwardIterator __last)
{
}
};
template<bool _TrivialValueType>
struct __uninitialized_default_novalue_n_1
{
template<typename _ForwardIterator, typename _Size>
static _ForwardIterator
__uninit_default_novalue_n(_ForwardIterator __first, _Size __n)
{
_ForwardIterator __cur = __first;
__try
{
for (; __n > 0; --__n, (void) ++__cur)
std::_Construct_novalue(std::__addressof(*__cur));
return __cur;
}
__catch(...)
{
std::_Destroy(__first, __cur);
__throw_exception_again;
}
}
};
template<>
struct __uninitialized_default_novalue_n_1<true>
{
template<typename _ForwardIterator, typename _Size>
static _ForwardIterator
__uninit_default_novalue_n(_ForwardIterator __first, _Size __n)
{ return std::next(__first, __n); }
};
// __uninitialized_default_novalue
// Fills [first, last) with std::distance(first, last) default-initialized
// value_types(s).
template<typename _ForwardIterator>
inline void
__uninitialized_default_novalue(_ForwardIterator __first,
_ForwardIterator __last)
{
typedef typename iterator_traits<_ForwardIterator>::value_type
_ValueType;
std::__uninitialized_default_novalue_1<
is_trivially_default_constructible<_ValueType>::value>::
__uninit_default_novalue(__first, __last);
}
// __uninitialized_default_n
// Fills [first, first + n) with n default-initialized value_type(s).
template<typename _ForwardIterator, typename _Size>
inline _ForwardIterator
__uninitialized_default_novalue_n(_ForwardIterator __first, _Size __n)
{
typedef typename iterator_traits<_ForwardIterator>::value_type
_ValueType;
return __uninitialized_default_novalue_n_1<
is_trivially_default_constructible<_ValueType>::value>::
__uninit_default_novalue_n(__first, __n);
}
template<typename _InputIterator, typename _Size,
typename _ForwardIterator>
_ForwardIterator
__uninitialized_copy_n(_InputIterator __first, _Size __n,
_ForwardIterator __result, input_iterator_tag)
{
_ForwardIterator __cur = __result;
__try
{
for (; __n > 0; --__n, (void) ++__first, ++__cur)
std::_Construct(std::__addressof(*__cur), *__first);
return __cur;
}
__catch(...)
{
std::_Destroy(__result, __cur);
__throw_exception_again;
}
}
template<typename _RandomAccessIterator, typename _Size,
typename _ForwardIterator>
inline _ForwardIterator
__uninitialized_copy_n(_RandomAccessIterator __first, _Size __n,
_ForwardIterator __result,
random_access_iterator_tag)
{ return std::uninitialized_copy(__first, __first + __n, __result); }
template<typename _InputIterator, typename _Size,
typename _ForwardIterator>
pair<_InputIterator, _ForwardIterator>
__uninitialized_copy_n_pair(_InputIterator __first, _Size __n,
_ForwardIterator __result, input_iterator_tag)
{
_ForwardIterator __cur = __result;
__try
{
for (; __n > 0; --__n, (void) ++__first, ++__cur)
std::_Construct(std::__addressof(*__cur), *__first);
return {__first, __cur};
}
__catch(...)
{
std::_Destroy(__result, __cur);
__throw_exception_again;
}
}
template<typename _RandomAccessIterator, typename _Size,
typename _ForwardIterator>
inline pair<_RandomAccessIterator, _ForwardIterator>
__uninitialized_copy_n_pair(_RandomAccessIterator __first, _Size __n,
_ForwardIterator __result,
random_access_iterator_tag)
{
auto __second_res = uninitialized_copy(__first, __first + __n, __result);
auto __first_res = std::next(__first, __n);
return {__first_res, __second_res};
}
/**
* @brief Copies the range [first,first+n) into result.
* @param __first An input iterator.
* @param __n The number of elements to copy.
* @param __result An output iterator.
* @return __result + __n
*
* Like copy_n(), but does not require an initialized output range.
*/
template<typename _InputIterator, typename _Size, typename _ForwardIterator>
inline _ForwardIterator
uninitialized_copy_n(_InputIterator __first, _Size __n,
_ForwardIterator __result)
{ return std::__uninitialized_copy_n(__first, __n, __result,
std::__iterator_category(__first)); }
template<typename _InputIterator, typename _Size, typename _ForwardIterator>
inline pair<_InputIterator, _ForwardIterator>
__uninitialized_copy_n_pair(_InputIterator __first, _Size __n,
_ForwardIterator __result)
{
return
std::__uninitialized_copy_n_pair(__first, __n, __result,
std::__iterator_category(__first));
}
#endif
#if __cplusplus >= 201703L
# define __cpp_lib_raw_memory_algorithms 201606L
template <typename _ForwardIterator>
inline void
uninitialized_default_construct(_ForwardIterator __first,
_ForwardIterator __last)
{
__uninitialized_default_novalue(__first, __last);
}
template <typename _ForwardIterator, typename _Size>
inline _ForwardIterator
uninitialized_default_construct_n(_ForwardIterator __first, _Size __count)
{
return __uninitialized_default_novalue_n(__first, __count);
}
template <typename _ForwardIterator>
inline void
uninitialized_value_construct(_ForwardIterator __first,
_ForwardIterator __last)
{
return __uninitialized_default(__first, __last);
}
template <typename _ForwardIterator, typename _Size>
inline _ForwardIterator
uninitialized_value_construct_n(_ForwardIterator __first, _Size __count)
{
return __uninitialized_default_n(__first, __count);
}
template <typename _InputIterator, typename _ForwardIterator>
inline _ForwardIterator
uninitialized_move(_InputIterator __first, _InputIterator __last,
_ForwardIterator __result)
{
return std::uninitialized_copy
(_GLIBCXX_MAKE_MOVE_ITERATOR(__first),
_GLIBCXX_MAKE_MOVE_ITERATOR(__last), __result);
}
template <typename _InputIterator, typename _Size, typename _ForwardIterator>
inline pair<_InputIterator, _ForwardIterator>
uninitialized_move_n(_InputIterator __first, _Size __count,
_ForwardIterator __result)
{
auto __res = std::__uninitialized_copy_n_pair
(_GLIBCXX_MAKE_MOVE_ITERATOR(__first),
__count, __result);
return {__res.first.base(), __res.second};
}
#endif // C++17
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif /* _STL_UNINITIALIZED_H */
c++/8/bits/random.h 0000644 00000526222 15201526705 0007671 0 ustar 00 // random number generation -*- C++ -*-
// Copyright (C) 2009-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/**
* @file bits/random.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{random}
*/
#ifndef _RANDOM_H
#define _RANDOM_H 1
#include <vector>
#include <bits/uniform_int_dist.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// [26.4] Random number generation
/**
* @defgroup random Random Number Generation
* @ingroup numerics
*
* A facility for generating random numbers on selected distributions.
* @{
*/
/**
* @brief A function template for converting the output of a (integral)
* uniform random number generator to a floatng point result in the range
* [0-1).
*/
template<typename _RealType, size_t __bits,
typename _UniformRandomNumberGenerator>
_RealType
generate_canonical(_UniformRandomNumberGenerator& __g);
/*
* Implementation-space details.
*/
namespace __detail
{
template<typename _UIntType, size_t __w,
bool = __w < static_cast<size_t>
(std::numeric_limits<_UIntType>::digits)>
struct _Shift
{ static const _UIntType __value = 0; };
template<typename _UIntType, size_t __w>
struct _Shift<_UIntType, __w, true>
{ static const _UIntType __value = _UIntType(1) << __w; };
template<int __s,
int __which = ((__s <= __CHAR_BIT__ * sizeof (int))
+ (__s <= __CHAR_BIT__ * sizeof (long))
+ (__s <= __CHAR_BIT__ * sizeof (long long))
/* assume long long no bigger than __int128 */
+ (__s <= 128))>
struct _Select_uint_least_t
{
static_assert(__which < 0, /* needs to be dependent */
"sorry, would be too much trouble for a slow result");
};
template<int __s>
struct _Select_uint_least_t<__s, 4>
{ typedef unsigned int type; };
template<int __s>
struct _Select_uint_least_t<__s, 3>
{ typedef unsigned long type; };
template<int __s>
struct _Select_uint_least_t<__s, 2>
{ typedef unsigned long long type; };
#ifdef _GLIBCXX_USE_INT128
template<int __s>
struct _Select_uint_least_t<__s, 1>
{ typedef unsigned __int128 type; };
#endif
// Assume a != 0, a < m, c < m, x < m.
template<typename _Tp, _Tp __m, _Tp __a, _Tp __c,
bool __big_enough = (!(__m & (__m - 1))
|| (_Tp(-1) - __c) / __a >= __m - 1),
bool __schrage_ok = __m % __a < __m / __a>
struct _Mod
{
typedef typename _Select_uint_least_t<std::__lg(__a)
+ std::__lg(__m) + 2>::type _Tp2;
static _Tp
__calc(_Tp __x)
{ return static_cast<_Tp>((_Tp2(__a) * __x + __c) % __m); }
};
// Schrage.
template<typename _Tp, _Tp __m, _Tp __a, _Tp __c>
struct _Mod<_Tp, __m, __a, __c, false, true>
{
static _Tp
__calc(_Tp __x);
};
// Special cases:
// - for m == 2^n or m == 0, unsigned integer overflow is safe.
// - a * (m - 1) + c fits in _Tp, there is no overflow.
template<typename _Tp, _Tp __m, _Tp __a, _Tp __c, bool __s>
struct _Mod<_Tp, __m, __a, __c, true, __s>
{
static _Tp
__calc(_Tp __x)
{
_Tp __res = __a * __x + __c;
if (__m)
__res %= __m;
return __res;
}
};
template<typename _Tp, _Tp __m, _Tp __a = 1, _Tp __c = 0>
inline _Tp
__mod(_Tp __x)
{ return _Mod<_Tp, __m, __a, __c>::__calc(__x); }
/*
* An adaptor class for converting the output of any Generator into
* the input for a specific Distribution.
*/
template<typename _Engine, typename _DInputType>
struct _Adaptor
{
static_assert(std::is_floating_point<_DInputType>::value,
"template argument must be a floating point type");
public:
_Adaptor(_Engine& __g)
: _M_g(__g) { }
_DInputType
min() const
{ return _DInputType(0); }
_DInputType
max() const
{ return _DInputType(1); }
/*
* Converts a value generated by the adapted random number generator
* into a value in the input domain for the dependent random number
* distribution.
*/
_DInputType
operator()()
{
return std::generate_canonical<_DInputType,
std::numeric_limits<_DInputType>::digits,
_Engine>(_M_g);
}
private:
_Engine& _M_g;
};
} // namespace __detail
/**
* @addtogroup random_generators Random Number Generators
* @ingroup random
*
* These classes define objects which provide random or pseudorandom
* numbers, either from a discrete or a continuous interval. The
* random number generator supplied as a part of this library are
* all uniform random number generators which provide a sequence of
* random number uniformly distributed over their range.
*
* A number generator is a function object with an operator() that
* takes zero arguments and returns a number.
*
* A compliant random number generator must satisfy the following
* requirements. <table border=1 cellpadding=10 cellspacing=0>
* <caption align=top>Random Number Generator Requirements</caption>
* <tr><td>To be documented.</td></tr> </table>
*
* @{
*/
/**
* @brief A model of a linear congruential random number generator.
*
* A random number generator that produces pseudorandom numbers via
* linear function:
* @f[
* x_{i+1}\leftarrow(ax_{i} + c) \bmod m
* @f]
*
* The template parameter @p _UIntType must be an unsigned integral type
* large enough to store values up to (__m-1). If the template parameter
* @p __m is 0, the modulus @p __m used is
* std::numeric_limits<_UIntType>::max() plus 1. Otherwise, the template
* parameters @p __a and @p __c must be less than @p __m.
*
* The size of the state is @f$1@f$.
*/
template<typename _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
class linear_congruential_engine
{
static_assert(std::is_unsigned<_UIntType>::value,
"result_type must be an unsigned integral type");
static_assert(__m == 0u || (__a < __m && __c < __m),
"template argument substituting __m out of bounds");
public:
/** The type of the generated random value. */
typedef _UIntType result_type;
/** The multiplier. */
static constexpr result_type multiplier = __a;
/** An increment. */
static constexpr result_type increment = __c;
/** The modulus. */
static constexpr result_type modulus = __m;
static constexpr result_type default_seed = 1u;
/**
* @brief Constructs a %linear_congruential_engine random number
* generator engine with seed @p __s. The default seed value
* is 1.
*
* @param __s The initial seed value.
*/
explicit
linear_congruential_engine(result_type __s = default_seed)
{ seed(__s); }
/**
* @brief Constructs a %linear_congruential_engine random number
* generator engine seeded from the seed sequence @p __q.
*
* @param __q the seed sequence.
*/
template<typename _Sseq, typename = typename
std::enable_if<!std::is_same<_Sseq, linear_congruential_engine>::value>
::type>
explicit
linear_congruential_engine(_Sseq& __q)
{ seed(__q); }
/**
* @brief Reseeds the %linear_congruential_engine random number generator
* engine sequence to the seed @p __s.
*
* @param __s The new seed.
*/
void
seed(result_type __s = default_seed);
/**
* @brief Reseeds the %linear_congruential_engine random number generator
* engine
* sequence using values from the seed sequence @p __q.
*
* @param __q the seed sequence.
*/
template<typename _Sseq>
typename std::enable_if<std::is_class<_Sseq>::value>::type
seed(_Sseq& __q);
/**
* @brief Gets the smallest possible value in the output range.
*
* The minimum depends on the @p __c parameter: if it is zero, the
* minimum generated must be > 0, otherwise 0 is allowed.
*/
static constexpr result_type
min()
{ return __c == 0u ? 1u : 0u; }
/**
* @brief Gets the largest possible value in the output range.
*/
static constexpr result_type
max()
{ return __m - 1u; }
/**
* @brief Discard a sequence of random numbers.
*/
void
discard(unsigned long long __z)
{
for (; __z != 0ULL; --__z)
(*this)();
}
/**
* @brief Gets the next random number in the sequence.
*/
result_type
operator()()
{
_M_x = __detail::__mod<_UIntType, __m, __a, __c>(_M_x);
return _M_x;
}
/**
* @brief Compares two linear congruential random number generator
* objects of the same type for equality.
*
* @param __lhs A linear congruential random number generator object.
* @param __rhs Another linear congruential random number generator
* object.
*
* @returns true if the infinite sequences of generated values
* would be equal, false otherwise.
*/
friend bool
operator==(const linear_congruential_engine& __lhs,
const linear_congruential_engine& __rhs)
{ return __lhs._M_x == __rhs._M_x; }
/**
* @brief Writes the textual representation of the state x(i) of x to
* @p __os.
*
* @param __os The output stream.
* @param __lcr A % linear_congruential_engine random number generator.
* @returns __os.
*/
template<typename _UIntType1, _UIntType1 __a1, _UIntType1 __c1,
_UIntType1 __m1, typename _CharT, typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const std::linear_congruential_engine<_UIntType1,
__a1, __c1, __m1>& __lcr);
/**
* @brief Sets the state of the engine by reading its textual
* representation from @p __is.
*
* The textual representation must have been previously written using
* an output stream whose imbued locale and whose type's template
* specialization arguments _CharT and _Traits were the same as those
* of @p __is.
*
* @param __is The input stream.
* @param __lcr A % linear_congruential_engine random number generator.
* @returns __is.
*/
template<typename _UIntType1, _UIntType1 __a1, _UIntType1 __c1,
_UIntType1 __m1, typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
std::linear_congruential_engine<_UIntType1, __a1,
__c1, __m1>& __lcr);
private:
_UIntType _M_x;
};
/**
* @brief Compares two linear congruential random number generator
* objects of the same type for inequality.
*
* @param __lhs A linear congruential random number generator object.
* @param __rhs Another linear congruential random number generator
* object.
*
* @returns true if the infinite sequences of generated values
* would be different, false otherwise.
*/
template<typename _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
inline bool
operator!=(const std::linear_congruential_engine<_UIntType, __a,
__c, __m>& __lhs,
const std::linear_congruential_engine<_UIntType, __a,
__c, __m>& __rhs)
{ return !(__lhs == __rhs); }
/**
* A generalized feedback shift register discrete random number generator.
*
* This algorithm avoids multiplication and division and is designed to be
* friendly to a pipelined architecture. If the parameters are chosen
* correctly, this generator will produce numbers with a very long period and
* fairly good apparent entropy, although still not cryptographically strong.
*
* The best way to use this generator is with the predefined mt19937 class.
*
* This algorithm was originally invented by Makoto Matsumoto and
* Takuji Nishimura.
*
* @tparam __w Word size, the number of bits in each element of
* the state vector.
* @tparam __n The degree of recursion.
* @tparam __m The period parameter.
* @tparam __r The separation point bit index.
* @tparam __a The last row of the twist matrix.
* @tparam __u The first right-shift tempering matrix parameter.
* @tparam __d The first right-shift tempering matrix mask.
* @tparam __s The first left-shift tempering matrix parameter.
* @tparam __b The first left-shift tempering matrix mask.
* @tparam __t The second left-shift tempering matrix parameter.
* @tparam __c The second left-shift tempering matrix mask.
* @tparam __l The second right-shift tempering matrix parameter.
* @tparam __f Initialization multiplier.
*/
template<typename _UIntType, size_t __w,
size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s,
_UIntType __b, size_t __t,
_UIntType __c, size_t __l, _UIntType __f>
class mersenne_twister_engine
{
static_assert(std::is_unsigned<_UIntType>::value,
"result_type must be an unsigned integral type");
static_assert(1u <= __m && __m <= __n,
"template argument substituting __m out of bounds");
static_assert(__r <= __w, "template argument substituting "
"__r out of bound");
static_assert(__u <= __w, "template argument substituting "
"__u out of bound");
static_assert(__s <= __w, "template argument substituting "
"__s out of bound");
static_assert(__t <= __w, "template argument substituting "
"__t out of bound");
static_assert(__l <= __w, "template argument substituting "
"__l out of bound");
static_assert(__w <= std::numeric_limits<_UIntType>::digits,
"template argument substituting __w out of bound");
static_assert(__a <= (__detail::_Shift<_UIntType, __w>::__value - 1),
"template argument substituting __a out of bound");
static_assert(__b <= (__detail::_Shift<_UIntType, __w>::__value - 1),
"template argument substituting __b out of bound");
static_assert(__c <= (__detail::_Shift<_UIntType, __w>::__value - 1),
"template argument substituting __c out of bound");
static_assert(__d <= (__detail::_Shift<_UIntType, __w>::__value - 1),
"template argument substituting __d out of bound");
static_assert(__f <= (__detail::_Shift<_UIntType, __w>::__value - 1),
"template argument substituting __f out of bound");
public:
/** The type of the generated random value. */
typedef _UIntType result_type;
// parameter values
static constexpr size_t word_size = __w;
static constexpr size_t state_size = __n;
static constexpr size_t shift_size = __m;
static constexpr size_t mask_bits = __r;
static constexpr result_type xor_mask = __a;
static constexpr size_t tempering_u = __u;
static constexpr result_type tempering_d = __d;
static constexpr size_t tempering_s = __s;
static constexpr result_type tempering_b = __b;
static constexpr size_t tempering_t = __t;
static constexpr result_type tempering_c = __c;
static constexpr size_t tempering_l = __l;
static constexpr result_type initialization_multiplier = __f;
static constexpr result_type default_seed = 5489u;
// constructors and member function
explicit
mersenne_twister_engine(result_type __sd = default_seed)
{ seed(__sd); }
/**
* @brief Constructs a %mersenne_twister_engine random number generator
* engine seeded from the seed sequence @p __q.
*
* @param __q the seed sequence.
*/
template<typename _Sseq, typename = typename
std::enable_if<!std::is_same<_Sseq, mersenne_twister_engine>::value>
::type>
explicit
mersenne_twister_engine(_Sseq& __q)
{ seed(__q); }
void
seed(result_type __sd = default_seed);
template<typename _Sseq>
typename std::enable_if<std::is_class<_Sseq>::value>::type
seed(_Sseq& __q);
/**
* @brief Gets the smallest possible value in the output range.
*/
static constexpr result_type
min()
{ return 0; }
/**
* @brief Gets the largest possible value in the output range.
*/
static constexpr result_type
max()
{ return __detail::_Shift<_UIntType, __w>::__value - 1; }
/**
* @brief Discard a sequence of random numbers.
*/
void
discard(unsigned long long __z);
result_type
operator()();
/**
* @brief Compares two % mersenne_twister_engine random number generator
* objects of the same type for equality.
*
* @param __lhs A % mersenne_twister_engine random number generator
* object.
* @param __rhs Another % mersenne_twister_engine random number
* generator object.
*
* @returns true if the infinite sequences of generated values
* would be equal, false otherwise.
*/
friend bool
operator==(const mersenne_twister_engine& __lhs,
const mersenne_twister_engine& __rhs)
{ return (std::equal(__lhs._M_x, __lhs._M_x + state_size, __rhs._M_x)
&& __lhs._M_p == __rhs._M_p); }
/**
* @brief Inserts the current state of a % mersenne_twister_engine
* random number generator engine @p __x into the output stream
* @p __os.
*
* @param __os An output stream.
* @param __x A % mersenne_twister_engine random number generator
* engine.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _UIntType1,
size_t __w1, size_t __n1,
size_t __m1, size_t __r1,
_UIntType1 __a1, size_t __u1,
_UIntType1 __d1, size_t __s1,
_UIntType1 __b1, size_t __t1,
_UIntType1 __c1, size_t __l1, _UIntType1 __f1,
typename _CharT, typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const std::mersenne_twister_engine<_UIntType1, __w1, __n1,
__m1, __r1, __a1, __u1, __d1, __s1, __b1, __t1, __c1,
__l1, __f1>& __x);
/**
* @brief Extracts the current state of a % mersenne_twister_engine
* random number generator engine @p __x from the input stream
* @p __is.
*
* @param __is An input stream.
* @param __x A % mersenne_twister_engine random number generator
* engine.
*
* @returns The input stream with the state of @p __x extracted or in
* an error state.
*/
template<typename _UIntType1,
size_t __w1, size_t __n1,
size_t __m1, size_t __r1,
_UIntType1 __a1, size_t __u1,
_UIntType1 __d1, size_t __s1,
_UIntType1 __b1, size_t __t1,
_UIntType1 __c1, size_t __l1, _UIntType1 __f1,
typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
std::mersenne_twister_engine<_UIntType1, __w1, __n1, __m1,
__r1, __a1, __u1, __d1, __s1, __b1, __t1, __c1,
__l1, __f1>& __x);
private:
void _M_gen_rand();
_UIntType _M_x[state_size];
size_t _M_p;
};
/**
* @brief Compares two % mersenne_twister_engine random number generator
* objects of the same type for inequality.
*
* @param __lhs A % mersenne_twister_engine random number generator
* object.
* @param __rhs Another % mersenne_twister_engine random number
* generator object.
*
* @returns true if the infinite sequences of generated values
* would be different, false otherwise.
*/
template<typename _UIntType, size_t __w,
size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s,
_UIntType __b, size_t __t,
_UIntType __c, size_t __l, _UIntType __f>
inline bool
operator!=(const std::mersenne_twister_engine<_UIntType, __w, __n, __m,
__r, __a, __u, __d, __s, __b, __t, __c, __l, __f>& __lhs,
const std::mersenne_twister_engine<_UIntType, __w, __n, __m,
__r, __a, __u, __d, __s, __b, __t, __c, __l, __f>& __rhs)
{ return !(__lhs == __rhs); }
/**
* @brief The Marsaglia-Zaman generator.
*
* This is a model of a Generalized Fibonacci discrete random number
* generator, sometimes referred to as the SWC generator.
*
* A discrete random number generator that produces pseudorandom
* numbers using:
* @f[
* x_{i}\leftarrow(x_{i - s} - x_{i - r} - carry_{i-1}) \bmod m
* @f]
*
* The size of the state is @f$r@f$
* and the maximum period of the generator is @f$(m^r - m^s - 1)@f$.
*/
template<typename _UIntType, size_t __w, size_t __s, size_t __r>
class subtract_with_carry_engine
{
static_assert(std::is_unsigned<_UIntType>::value,
"result_type must be an unsigned integral type");
static_assert(0u < __s && __s < __r,
"0 < s < r");
static_assert(0u < __w && __w <= std::numeric_limits<_UIntType>::digits,
"template argument substituting __w out of bounds");
public:
/** The type of the generated random value. */
typedef _UIntType result_type;
// parameter values
static constexpr size_t word_size = __w;
static constexpr size_t short_lag = __s;
static constexpr size_t long_lag = __r;
static constexpr result_type default_seed = 19780503u;
/**
* @brief Constructs an explicitly seeded % subtract_with_carry_engine
* random number generator.
*/
explicit
subtract_with_carry_engine(result_type __sd = default_seed)
{ seed(__sd); }
/**
* @brief Constructs a %subtract_with_carry_engine random number engine
* seeded from the seed sequence @p __q.
*
* @param __q the seed sequence.
*/
template<typename _Sseq, typename = typename
std::enable_if<!std::is_same<_Sseq, subtract_with_carry_engine>::value>
::type>
explicit
subtract_with_carry_engine(_Sseq& __q)
{ seed(__q); }
/**
* @brief Seeds the initial state @f$x_0@f$ of the random number
* generator.
*
* N1688[4.19] modifies this as follows. If @p __value == 0,
* sets value to 19780503. In any case, with a linear
* congruential generator lcg(i) having parameters @f$ m_{lcg} =
* 2147483563, a_{lcg} = 40014, c_{lcg} = 0, and lcg(0) = value
* @f$, sets @f$ x_{-r} \dots x_{-1} @f$ to @f$ lcg(1) \bmod m
* \dots lcg(r) \bmod m @f$ respectively. If @f$ x_{-1} = 0 @f$
* set carry to 1, otherwise sets carry to 0.
*/
void
seed(result_type __sd = default_seed);
/**
* @brief Seeds the initial state @f$x_0@f$ of the
* % subtract_with_carry_engine random number generator.
*/
template<typename _Sseq>
typename std::enable_if<std::is_class<_Sseq>::value>::type
seed(_Sseq& __q);
/**
* @brief Gets the inclusive minimum value of the range of random
* integers returned by this generator.
*/
static constexpr result_type
min()
{ return 0; }
/**
* @brief Gets the inclusive maximum value of the range of random
* integers returned by this generator.
*/
static constexpr result_type
max()
{ return __detail::_Shift<_UIntType, __w>::__value - 1; }
/**
* @brief Discard a sequence of random numbers.
*/
void
discard(unsigned long long __z)
{
for (; __z != 0ULL; --__z)
(*this)();
}
/**
* @brief Gets the next random number in the sequence.
*/
result_type
operator()();
/**
* @brief Compares two % subtract_with_carry_engine random number
* generator objects of the same type for equality.
*
* @param __lhs A % subtract_with_carry_engine random number generator
* object.
* @param __rhs Another % subtract_with_carry_engine random number
* generator object.
*
* @returns true if the infinite sequences of generated values
* would be equal, false otherwise.
*/
friend bool
operator==(const subtract_with_carry_engine& __lhs,
const subtract_with_carry_engine& __rhs)
{ return (std::equal(__lhs._M_x, __lhs._M_x + long_lag, __rhs._M_x)
&& __lhs._M_carry == __rhs._M_carry
&& __lhs._M_p == __rhs._M_p); }
/**
* @brief Inserts the current state of a % subtract_with_carry_engine
* random number generator engine @p __x into the output stream
* @p __os.
*
* @param __os An output stream.
* @param __x A % subtract_with_carry_engine random number generator
* engine.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _UIntType1, size_t __w1, size_t __s1, size_t __r1,
typename _CharT, typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const std::subtract_with_carry_engine<_UIntType1, __w1,
__s1, __r1>& __x);
/**
* @brief Extracts the current state of a % subtract_with_carry_engine
* random number generator engine @p __x from the input stream
* @p __is.
*
* @param __is An input stream.
* @param __x A % subtract_with_carry_engine random number generator
* engine.
*
* @returns The input stream with the state of @p __x extracted or in
* an error state.
*/
template<typename _UIntType1, size_t __w1, size_t __s1, size_t __r1,
typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
std::subtract_with_carry_engine<_UIntType1, __w1,
__s1, __r1>& __x);
private:
/// The state of the generator. This is a ring buffer.
_UIntType _M_x[long_lag];
_UIntType _M_carry; ///< The carry
size_t _M_p; ///< Current index of x(i - r).
};
/**
* @brief Compares two % subtract_with_carry_engine random number
* generator objects of the same type for inequality.
*
* @param __lhs A % subtract_with_carry_engine random number generator
* object.
* @param __rhs Another % subtract_with_carry_engine random number
* generator object.
*
* @returns true if the infinite sequences of generated values
* would be different, false otherwise.
*/
template<typename _UIntType, size_t __w, size_t __s, size_t __r>
inline bool
operator!=(const std::subtract_with_carry_engine<_UIntType, __w,
__s, __r>& __lhs,
const std::subtract_with_carry_engine<_UIntType, __w,
__s, __r>& __rhs)
{ return !(__lhs == __rhs); }
/**
* Produces random numbers from some base engine by discarding blocks of
* data.
*
* 0 <= @p __r <= @p __p
*/
template<typename _RandomNumberEngine, size_t __p, size_t __r>
class discard_block_engine
{
static_assert(1 <= __r && __r <= __p,
"template argument substituting __r out of bounds");
public:
/** The type of the generated random value. */
typedef typename _RandomNumberEngine::result_type result_type;
// parameter values
static constexpr size_t block_size = __p;
static constexpr size_t used_block = __r;
/**
* @brief Constructs a default %discard_block_engine engine.
*
* The underlying engine is default constructed as well.
*/
discard_block_engine()
: _M_b(), _M_n(0) { }
/**
* @brief Copy constructs a %discard_block_engine engine.
*
* Copies an existing base class random number generator.
* @param __rng An existing (base class) engine object.
*/
explicit
discard_block_engine(const _RandomNumberEngine& __rng)
: _M_b(__rng), _M_n(0) { }
/**
* @brief Move constructs a %discard_block_engine engine.
*
* Copies an existing base class random number generator.
* @param __rng An existing (base class) engine object.
*/
explicit
discard_block_engine(_RandomNumberEngine&& __rng)
: _M_b(std::move(__rng)), _M_n(0) { }
/**
* @brief Seed constructs a %discard_block_engine engine.
*
* Constructs the underlying generator engine seeded with @p __s.
* @param __s A seed value for the base class engine.
*/
explicit
discard_block_engine(result_type __s)
: _M_b(__s), _M_n(0) { }
/**
* @brief Generator construct a %discard_block_engine engine.
*
* @param __q A seed sequence.
*/
template<typename _Sseq, typename = typename
std::enable_if<!std::is_same<_Sseq, discard_block_engine>::value
&& !std::is_same<_Sseq, _RandomNumberEngine>::value>
::type>
explicit
discard_block_engine(_Sseq& __q)
: _M_b(__q), _M_n(0)
{ }
/**
* @brief Reseeds the %discard_block_engine object with the default
* seed for the underlying base class generator engine.
*/
void
seed()
{
_M_b.seed();
_M_n = 0;
}
/**
* @brief Reseeds the %discard_block_engine object with the default
* seed for the underlying base class generator engine.
*/
void
seed(result_type __s)
{
_M_b.seed(__s);
_M_n = 0;
}
/**
* @brief Reseeds the %discard_block_engine object with the given seed
* sequence.
* @param __q A seed generator function.
*/
template<typename _Sseq>
void
seed(_Sseq& __q)
{
_M_b.seed(__q);
_M_n = 0;
}
/**
* @brief Gets a const reference to the underlying generator engine
* object.
*/
const _RandomNumberEngine&
base() const noexcept
{ return _M_b; }
/**
* @brief Gets the minimum value in the generated random number range.
*/
static constexpr result_type
min()
{ return _RandomNumberEngine::min(); }
/**
* @brief Gets the maximum value in the generated random number range.
*/
static constexpr result_type
max()
{ return _RandomNumberEngine::max(); }
/**
* @brief Discard a sequence of random numbers.
*/
void
discard(unsigned long long __z)
{
for (; __z != 0ULL; --__z)
(*this)();
}
/**
* @brief Gets the next value in the generated random number sequence.
*/
result_type
operator()();
/**
* @brief Compares two %discard_block_engine random number generator
* objects of the same type for equality.
*
* @param __lhs A %discard_block_engine random number generator object.
* @param __rhs Another %discard_block_engine random number generator
* object.
*
* @returns true if the infinite sequences of generated values
* would be equal, false otherwise.
*/
friend bool
operator==(const discard_block_engine& __lhs,
const discard_block_engine& __rhs)
{ return __lhs._M_b == __rhs._M_b && __lhs._M_n == __rhs._M_n; }
/**
* @brief Inserts the current state of a %discard_block_engine random
* number generator engine @p __x into the output stream
* @p __os.
*
* @param __os An output stream.
* @param __x A %discard_block_engine random number generator engine.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _RandomNumberEngine1, size_t __p1, size_t __r1,
typename _CharT, typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const std::discard_block_engine<_RandomNumberEngine1,
__p1, __r1>& __x);
/**
* @brief Extracts the current state of a % subtract_with_carry_engine
* random number generator engine @p __x from the input stream
* @p __is.
*
* @param __is An input stream.
* @param __x A %discard_block_engine random number generator engine.
*
* @returns The input stream with the state of @p __x extracted or in
* an error state.
*/
template<typename _RandomNumberEngine1, size_t __p1, size_t __r1,
typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
std::discard_block_engine<_RandomNumberEngine1,
__p1, __r1>& __x);
private:
_RandomNumberEngine _M_b;
size_t _M_n;
};
/**
* @brief Compares two %discard_block_engine random number generator
* objects of the same type for inequality.
*
* @param __lhs A %discard_block_engine random number generator object.
* @param __rhs Another %discard_block_engine random number generator
* object.
*
* @returns true if the infinite sequences of generated values
* would be different, false otherwise.
*/
template<typename _RandomNumberEngine, size_t __p, size_t __r>
inline bool
operator!=(const std::discard_block_engine<_RandomNumberEngine, __p,
__r>& __lhs,
const std::discard_block_engine<_RandomNumberEngine, __p,
__r>& __rhs)
{ return !(__lhs == __rhs); }
/**
* Produces random numbers by combining random numbers from some base
* engine to produce random numbers with a specifies number of bits @p __w.
*/
template<typename _RandomNumberEngine, size_t __w, typename _UIntType>
class independent_bits_engine
{
static_assert(std::is_unsigned<_UIntType>::value,
"result_type must be an unsigned integral type");
static_assert(0u < __w && __w <= std::numeric_limits<_UIntType>::digits,
"template argument substituting __w out of bounds");
public:
/** The type of the generated random value. */
typedef _UIntType result_type;
/**
* @brief Constructs a default %independent_bits_engine engine.
*
* The underlying engine is default constructed as well.
*/
independent_bits_engine()
: _M_b() { }
/**
* @brief Copy constructs a %independent_bits_engine engine.
*
* Copies an existing base class random number generator.
* @param __rng An existing (base class) engine object.
*/
explicit
independent_bits_engine(const _RandomNumberEngine& __rng)
: _M_b(__rng) { }
/**
* @brief Move constructs a %independent_bits_engine engine.
*
* Copies an existing base class random number generator.
* @param __rng An existing (base class) engine object.
*/
explicit
independent_bits_engine(_RandomNumberEngine&& __rng)
: _M_b(std::move(__rng)) { }
/**
* @brief Seed constructs a %independent_bits_engine engine.
*
* Constructs the underlying generator engine seeded with @p __s.
* @param __s A seed value for the base class engine.
*/
explicit
independent_bits_engine(result_type __s)
: _M_b(__s) { }
/**
* @brief Generator construct a %independent_bits_engine engine.
*
* @param __q A seed sequence.
*/
template<typename _Sseq, typename = typename
std::enable_if<!std::is_same<_Sseq, independent_bits_engine>::value
&& !std::is_same<_Sseq, _RandomNumberEngine>::value>
::type>
explicit
independent_bits_engine(_Sseq& __q)
: _M_b(__q)
{ }
/**
* @brief Reseeds the %independent_bits_engine object with the default
* seed for the underlying base class generator engine.
*/
void
seed()
{ _M_b.seed(); }
/**
* @brief Reseeds the %independent_bits_engine object with the default
* seed for the underlying base class generator engine.
*/
void
seed(result_type __s)
{ _M_b.seed(__s); }
/**
* @brief Reseeds the %independent_bits_engine object with the given
* seed sequence.
* @param __q A seed generator function.
*/
template<typename _Sseq>
void
seed(_Sseq& __q)
{ _M_b.seed(__q); }
/**
* @brief Gets a const reference to the underlying generator engine
* object.
*/
const _RandomNumberEngine&
base() const noexcept
{ return _M_b; }
/**
* @brief Gets the minimum value in the generated random number range.
*/
static constexpr result_type
min()
{ return 0U; }
/**
* @brief Gets the maximum value in the generated random number range.
*/
static constexpr result_type
max()
{ return __detail::_Shift<_UIntType, __w>::__value - 1; }
/**
* @brief Discard a sequence of random numbers.
*/
void
discard(unsigned long long __z)
{
for (; __z != 0ULL; --__z)
(*this)();
}
/**
* @brief Gets the next value in the generated random number sequence.
*/
result_type
operator()();
/**
* @brief Compares two %independent_bits_engine random number generator
* objects of the same type for equality.
*
* @param __lhs A %independent_bits_engine random number generator
* object.
* @param __rhs Another %independent_bits_engine random number generator
* object.
*
* @returns true if the infinite sequences of generated values
* would be equal, false otherwise.
*/
friend bool
operator==(const independent_bits_engine& __lhs,
const independent_bits_engine& __rhs)
{ return __lhs._M_b == __rhs._M_b; }
/**
* @brief Extracts the current state of a % subtract_with_carry_engine
* random number generator engine @p __x from the input stream
* @p __is.
*
* @param __is An input stream.
* @param __x A %independent_bits_engine random number generator
* engine.
*
* @returns The input stream with the state of @p __x extracted or in
* an error state.
*/
template<typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
std::independent_bits_engine<_RandomNumberEngine,
__w, _UIntType>& __x)
{
__is >> __x._M_b;
return __is;
}
private:
_RandomNumberEngine _M_b;
};
/**
* @brief Compares two %independent_bits_engine random number generator
* objects of the same type for inequality.
*
* @param __lhs A %independent_bits_engine random number generator
* object.
* @param __rhs Another %independent_bits_engine random number generator
* object.
*
* @returns true if the infinite sequences of generated values
* would be different, false otherwise.
*/
template<typename _RandomNumberEngine, size_t __w, typename _UIntType>
inline bool
operator!=(const std::independent_bits_engine<_RandomNumberEngine, __w,
_UIntType>& __lhs,
const std::independent_bits_engine<_RandomNumberEngine, __w,
_UIntType>& __rhs)
{ return !(__lhs == __rhs); }
/**
* @brief Inserts the current state of a %independent_bits_engine random
* number generator engine @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %independent_bits_engine random number generator engine.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _RandomNumberEngine, size_t __w, typename _UIntType,
typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const std::independent_bits_engine<_RandomNumberEngine,
__w, _UIntType>& __x)
{
__os << __x.base();
return __os;
}
/**
* @brief Produces random numbers by combining random numbers from some
* base engine to produce random numbers with a specifies number of bits
* @p __k.
*/
template<typename _RandomNumberEngine, size_t __k>
class shuffle_order_engine
{
static_assert(1u <= __k, "template argument substituting "
"__k out of bound");
public:
/** The type of the generated random value. */
typedef typename _RandomNumberEngine::result_type result_type;
static constexpr size_t table_size = __k;
/**
* @brief Constructs a default %shuffle_order_engine engine.
*
* The underlying engine is default constructed as well.
*/
shuffle_order_engine()
: _M_b()
{ _M_initialize(); }
/**
* @brief Copy constructs a %shuffle_order_engine engine.
*
* Copies an existing base class random number generator.
* @param __rng An existing (base class) engine object.
*/
explicit
shuffle_order_engine(const _RandomNumberEngine& __rng)
: _M_b(__rng)
{ _M_initialize(); }
/**
* @brief Move constructs a %shuffle_order_engine engine.
*
* Copies an existing base class random number generator.
* @param __rng An existing (base class) engine object.
*/
explicit
shuffle_order_engine(_RandomNumberEngine&& __rng)
: _M_b(std::move(__rng))
{ _M_initialize(); }
/**
* @brief Seed constructs a %shuffle_order_engine engine.
*
* Constructs the underlying generator engine seeded with @p __s.
* @param __s A seed value for the base class engine.
*/
explicit
shuffle_order_engine(result_type __s)
: _M_b(__s)
{ _M_initialize(); }
/**
* @brief Generator construct a %shuffle_order_engine engine.
*
* @param __q A seed sequence.
*/
template<typename _Sseq, typename = typename
std::enable_if<!std::is_same<_Sseq, shuffle_order_engine>::value
&& !std::is_same<_Sseq, _RandomNumberEngine>::value>
::type>
explicit
shuffle_order_engine(_Sseq& __q)
: _M_b(__q)
{ _M_initialize(); }
/**
* @brief Reseeds the %shuffle_order_engine object with the default seed
for the underlying base class generator engine.
*/
void
seed()
{
_M_b.seed();
_M_initialize();
}
/**
* @brief Reseeds the %shuffle_order_engine object with the default seed
* for the underlying base class generator engine.
*/
void
seed(result_type __s)
{
_M_b.seed(__s);
_M_initialize();
}
/**
* @brief Reseeds the %shuffle_order_engine object with the given seed
* sequence.
* @param __q A seed generator function.
*/
template<typename _Sseq>
void
seed(_Sseq& __q)
{
_M_b.seed(__q);
_M_initialize();
}
/**
* Gets a const reference to the underlying generator engine object.
*/
const _RandomNumberEngine&
base() const noexcept
{ return _M_b; }
/**
* Gets the minimum value in the generated random number range.
*/
static constexpr result_type
min()
{ return _RandomNumberEngine::min(); }
/**
* Gets the maximum value in the generated random number range.
*/
static constexpr result_type
max()
{ return _RandomNumberEngine::max(); }
/**
* Discard a sequence of random numbers.
*/
void
discard(unsigned long long __z)
{
for (; __z != 0ULL; --__z)
(*this)();
}
/**
* Gets the next value in the generated random number sequence.
*/
result_type
operator()();
/**
* Compares two %shuffle_order_engine random number generator objects
* of the same type for equality.
*
* @param __lhs A %shuffle_order_engine random number generator object.
* @param __rhs Another %shuffle_order_engine random number generator
* object.
*
* @returns true if the infinite sequences of generated values
* would be equal, false otherwise.
*/
friend bool
operator==(const shuffle_order_engine& __lhs,
const shuffle_order_engine& __rhs)
{ return (__lhs._M_b == __rhs._M_b
&& std::equal(__lhs._M_v, __lhs._M_v + __k, __rhs._M_v)
&& __lhs._M_y == __rhs._M_y); }
/**
* @brief Inserts the current state of a %shuffle_order_engine random
* number generator engine @p __x into the output stream
@p __os.
*
* @param __os An output stream.
* @param __x A %shuffle_order_engine random number generator engine.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _RandomNumberEngine1, size_t __k1,
typename _CharT, typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const std::shuffle_order_engine<_RandomNumberEngine1,
__k1>& __x);
/**
* @brief Extracts the current state of a % subtract_with_carry_engine
* random number generator engine @p __x from the input stream
* @p __is.
*
* @param __is An input stream.
* @param __x A %shuffle_order_engine random number generator engine.
*
* @returns The input stream with the state of @p __x extracted or in
* an error state.
*/
template<typename _RandomNumberEngine1, size_t __k1,
typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
std::shuffle_order_engine<_RandomNumberEngine1, __k1>& __x);
private:
void _M_initialize()
{
for (size_t __i = 0; __i < __k; ++__i)
_M_v[__i] = _M_b();
_M_y = _M_b();
}
_RandomNumberEngine _M_b;
result_type _M_v[__k];
result_type _M_y;
};
/**
* Compares two %shuffle_order_engine random number generator objects
* of the same type for inequality.
*
* @param __lhs A %shuffle_order_engine random number generator object.
* @param __rhs Another %shuffle_order_engine random number generator
* object.
*
* @returns true if the infinite sequences of generated values
* would be different, false otherwise.
*/
template<typename _RandomNumberEngine, size_t __k>
inline bool
operator!=(const std::shuffle_order_engine<_RandomNumberEngine,
__k>& __lhs,
const std::shuffle_order_engine<_RandomNumberEngine,
__k>& __rhs)
{ return !(__lhs == __rhs); }
/**
* The classic Minimum Standard rand0 of Lewis, Goodman, and Miller.
*/
typedef linear_congruential_engine<uint_fast32_t, 16807UL, 0UL, 2147483647UL>
minstd_rand0;
/**
* An alternative LCR (Lehmer Generator function).
*/
typedef linear_congruential_engine<uint_fast32_t, 48271UL, 0UL, 2147483647UL>
minstd_rand;
/**
* The classic Mersenne Twister.
*
* Reference:
* M. Matsumoto and T. Nishimura, Mersenne Twister: A 623-Dimensionally
* Equidistributed Uniform Pseudo-Random Number Generator, ACM Transactions
* on Modeling and Computer Simulation, Vol. 8, No. 1, January 1998, pp 3-30.
*/
typedef mersenne_twister_engine<
uint_fast32_t,
32, 624, 397, 31,
0x9908b0dfUL, 11,
0xffffffffUL, 7,
0x9d2c5680UL, 15,
0xefc60000UL, 18, 1812433253UL> mt19937;
/**
* An alternative Mersenne Twister.
*/
typedef mersenne_twister_engine<
uint_fast64_t,
64, 312, 156, 31,
0xb5026f5aa96619e9ULL, 29,
0x5555555555555555ULL, 17,
0x71d67fffeda60000ULL, 37,
0xfff7eee000000000ULL, 43,
6364136223846793005ULL> mt19937_64;
typedef subtract_with_carry_engine<uint_fast32_t, 24, 10, 24>
ranlux24_base;
typedef subtract_with_carry_engine<uint_fast64_t, 48, 5, 12>
ranlux48_base;
typedef discard_block_engine<ranlux24_base, 223, 23> ranlux24;
typedef discard_block_engine<ranlux48_base, 389, 11> ranlux48;
typedef shuffle_order_engine<minstd_rand0, 256> knuth_b;
typedef minstd_rand0 default_random_engine;
/**
* A standard interface to a platform-specific non-deterministic
* random number generator (if any are available).
*/
class random_device
{
public:
/** The type of the generated random value. */
typedef unsigned int result_type;
// constructors, destructors and member functions
#ifdef _GLIBCXX_USE_RANDOM_TR1
explicit
random_device(const std::string& __token = "default")
{
_M_init(__token);
}
~random_device()
{ _M_fini(); }
#else
explicit
random_device(const std::string& __token = "mt19937")
{ _M_init_pretr1(__token); }
public:
#endif
static constexpr result_type
min()
{ return std::numeric_limits<result_type>::min(); }
static constexpr result_type
max()
{ return std::numeric_limits<result_type>::max(); }
double
entropy() const noexcept
{
#ifdef _GLIBCXX_USE_RANDOM_TR1
return this->_M_getentropy();
#else
return 0.0;
#endif
}
result_type
operator()()
{
#ifdef _GLIBCXX_USE_RANDOM_TR1
return this->_M_getval();
#else
return this->_M_getval_pretr1();
#endif
}
// No copy functions.
random_device(const random_device&) = delete;
void operator=(const random_device&) = delete;
private:
void _M_init(const std::string& __token);
void _M_init_pretr1(const std::string& __token);
void _M_fini();
result_type _M_getval();
result_type _M_getval_pretr1();
double _M_getentropy() const noexcept;
union
{
void* _M_file;
mt19937 _M_mt;
};
};
/* @} */ // group random_generators
/**
* @addtogroup random_distributions Random Number Distributions
* @ingroup random
* @{
*/
/**
* @addtogroup random_distributions_uniform Uniform Distributions
* @ingroup random_distributions
* @{
*/
// std::uniform_int_distribution is defined in <bits/uniform_int_dist.h>
/**
* @brief Return true if two uniform integer distributions have
* different parameters.
*/
template<typename _IntType>
inline bool
operator!=(const std::uniform_int_distribution<_IntType>& __d1,
const std::uniform_int_distribution<_IntType>& __d2)
{ return !(__d1 == __d2); }
/**
* @brief Inserts a %uniform_int_distribution random number
* distribution @p __x into the output stream @p os.
*
* @param __os An output stream.
* @param __x A %uniform_int_distribution random number distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _IntType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>&,
const std::uniform_int_distribution<_IntType>&);
/**
* @brief Extracts a %uniform_int_distribution random number distribution
* @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %uniform_int_distribution random number generator engine.
*
* @returns The input stream with @p __x extracted or in an error state.
*/
template<typename _IntType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>&,
std::uniform_int_distribution<_IntType>&);
/**
* @brief Uniform continuous distribution for random numbers.
*
* A continuous random distribution on the range [min, max) with equal
* probability throughout the range. The URNG should be real-valued and
* deliver number in the range [0, 1).
*/
template<typename _RealType = double>
class uniform_real_distribution
{
static_assert(std::is_floating_point<_RealType>::value,
"result_type must be a floating point type");
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
/** Parameter type. */
struct param_type
{
typedef uniform_real_distribution<_RealType> distribution_type;
explicit
param_type(_RealType __a = _RealType(0),
_RealType __b = _RealType(1))
: _M_a(__a), _M_b(__b)
{
__glibcxx_assert(_M_a <= _M_b);
}
result_type
a() const
{ return _M_a; }
result_type
b() const
{ return _M_b; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{ return __p1._M_a == __p2._M_a && __p1._M_b == __p2._M_b; }
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
_RealType _M_a;
_RealType _M_b;
};
public:
/**
* @brief Constructs a uniform_real_distribution object.
*
* @param __a [IN] The lower bound of the distribution.
* @param __b [IN] The upper bound of the distribution.
*/
explicit
uniform_real_distribution(_RealType __a = _RealType(0),
_RealType __b = _RealType(1))
: _M_param(__a, __b)
{ }
explicit
uniform_real_distribution(const param_type& __p)
: _M_param(__p)
{ }
/**
* @brief Resets the distribution state.
*
* Does nothing for the uniform real distribution.
*/
void
reset() { }
result_type
a() const
{ return _M_param.a(); }
result_type
b() const
{ return _M_param.b(); }
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ _M_param = __param; }
/**
* @brief Returns the inclusive lower bound of the distribution range.
*/
result_type
min() const
{ return this->a(); }
/**
* @brief Returns the inclusive upper bound of the distribution range.
*/
result_type
max() const
{ return this->b(); }
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
{ return this->operator()(__urng, _M_param); }
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
__aurng(__urng);
return (__aurng() * (__p.b() - __p.a())) + __p.a();
}
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate(__f, __t, __urng, _M_param); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two uniform real distributions have
* the same parameters.
*/
friend bool
operator==(const uniform_real_distribution& __d1,
const uniform_real_distribution& __d2)
{ return __d1._M_param == __d2._M_param; }
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
param_type _M_param;
};
/**
* @brief Return true if two uniform real distributions have
* different parameters.
*/
template<typename _IntType>
inline bool
operator!=(const std::uniform_real_distribution<_IntType>& __d1,
const std::uniform_real_distribution<_IntType>& __d2)
{ return !(__d1 == __d2); }
/**
* @brief Inserts a %uniform_real_distribution random number
* distribution @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %uniform_real_distribution random number distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>&,
const std::uniform_real_distribution<_RealType>&);
/**
* @brief Extracts a %uniform_real_distribution random number distribution
* @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %uniform_real_distribution random number generator engine.
*
* @returns The input stream with @p __x extracted or in an error state.
*/
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>&,
std::uniform_real_distribution<_RealType>&);
/* @} */ // group random_distributions_uniform
/**
* @addtogroup random_distributions_normal Normal Distributions
* @ingroup random_distributions
* @{
*/
/**
* @brief A normal continuous distribution for random numbers.
*
* The formula for the normal probability density function is
* @f[
* p(x|\mu,\sigma) = \frac{1}{\sigma \sqrt{2 \pi}}
* e^{- \frac{{x - \mu}^ {2}}{2 \sigma ^ {2}} }
* @f]
*/
template<typename _RealType = double>
class normal_distribution
{
static_assert(std::is_floating_point<_RealType>::value,
"result_type must be a floating point type");
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
/** Parameter type. */
struct param_type
{
typedef normal_distribution<_RealType> distribution_type;
explicit
param_type(_RealType __mean = _RealType(0),
_RealType __stddev = _RealType(1))
: _M_mean(__mean), _M_stddev(__stddev)
{
__glibcxx_assert(_M_stddev > _RealType(0));
}
_RealType
mean() const
{ return _M_mean; }
_RealType
stddev() const
{ return _M_stddev; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{ return (__p1._M_mean == __p2._M_mean
&& __p1._M_stddev == __p2._M_stddev); }
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
_RealType _M_mean;
_RealType _M_stddev;
};
public:
/**
* Constructs a normal distribution with parameters @f$mean@f$ and
* standard deviation.
*/
explicit
normal_distribution(result_type __mean = result_type(0),
result_type __stddev = result_type(1))
: _M_param(__mean, __stddev)
{ }
explicit
normal_distribution(const param_type& __p)
: _M_param(__p)
{ }
/**
* @brief Resets the distribution state.
*/
void
reset()
{ _M_saved_available = false; }
/**
* @brief Returns the mean of the distribution.
*/
_RealType
mean() const
{ return _M_param.mean(); }
/**
* @brief Returns the standard deviation of the distribution.
*/
_RealType
stddev() const
{ return _M_param.stddev(); }
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ _M_param = __param; }
/**
* @brief Returns the greatest lower bound value of the distribution.
*/
result_type
min() const
{ return std::numeric_limits<result_type>::lowest(); }
/**
* @brief Returns the least upper bound value of the distribution.
*/
result_type
max() const
{ return std::numeric_limits<result_type>::max(); }
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
{ return this->operator()(__urng, _M_param); }
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p);
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate(__f, __t, __urng, _M_param); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two normal distributions have
* the same parameters and the sequences that would
* be generated are equal.
*/
template<typename _RealType1>
friend bool
operator==(const std::normal_distribution<_RealType1>& __d1,
const std::normal_distribution<_RealType1>& __d2);
/**
* @brief Inserts a %normal_distribution random number distribution
* @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %normal_distribution random number distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const std::normal_distribution<_RealType1>& __x);
/**
* @brief Extracts a %normal_distribution random number distribution
* @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %normal_distribution random number generator engine.
*
* @returns The input stream with @p __x extracted or in an error
* state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
std::normal_distribution<_RealType1>& __x);
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
param_type _M_param;
result_type _M_saved = 0;
bool _M_saved_available = false;
};
/**
* @brief Return true if two normal distributions are different.
*/
template<typename _RealType>
inline bool
operator!=(const std::normal_distribution<_RealType>& __d1,
const std::normal_distribution<_RealType>& __d2)
{ return !(__d1 == __d2); }
/**
* @brief A lognormal_distribution random number distribution.
*
* The formula for the normal probability mass function is
* @f[
* p(x|m,s) = \frac{1}{sx\sqrt{2\pi}}
* \exp{-\frac{(\ln{x} - m)^2}{2s^2}}
* @f]
*/
template<typename _RealType = double>
class lognormal_distribution
{
static_assert(std::is_floating_point<_RealType>::value,
"result_type must be a floating point type");
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
/** Parameter type. */
struct param_type
{
typedef lognormal_distribution<_RealType> distribution_type;
explicit
param_type(_RealType __m = _RealType(0),
_RealType __s = _RealType(1))
: _M_m(__m), _M_s(__s)
{ }
_RealType
m() const
{ return _M_m; }
_RealType
s() const
{ return _M_s; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{ return __p1._M_m == __p2._M_m && __p1._M_s == __p2._M_s; }
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
_RealType _M_m;
_RealType _M_s;
};
explicit
lognormal_distribution(_RealType __m = _RealType(0),
_RealType __s = _RealType(1))
: _M_param(__m, __s), _M_nd()
{ }
explicit
lognormal_distribution(const param_type& __p)
: _M_param(__p), _M_nd()
{ }
/**
* Resets the distribution state.
*/
void
reset()
{ _M_nd.reset(); }
/**
*
*/
_RealType
m() const
{ return _M_param.m(); }
_RealType
s() const
{ return _M_param.s(); }
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ _M_param = __param; }
/**
* @brief Returns the greatest lower bound value of the distribution.
*/
result_type
min() const
{ return result_type(0); }
/**
* @brief Returns the least upper bound value of the distribution.
*/
result_type
max() const
{ return std::numeric_limits<result_type>::max(); }
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
{ return this->operator()(__urng, _M_param); }
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ return std::exp(__p.s() * _M_nd(__urng) + __p.m()); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate(__f, __t, __urng, _M_param); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two lognormal distributions have
* the same parameters and the sequences that would
* be generated are equal.
*/
friend bool
operator==(const lognormal_distribution& __d1,
const lognormal_distribution& __d2)
{ return (__d1._M_param == __d2._M_param
&& __d1._M_nd == __d2._M_nd); }
/**
* @brief Inserts a %lognormal_distribution random number distribution
* @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %lognormal_distribution random number distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const std::lognormal_distribution<_RealType1>& __x);
/**
* @brief Extracts a %lognormal_distribution random number distribution
* @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %lognormal_distribution random number
* generator engine.
*
* @returns The input stream with @p __x extracted or in an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
std::lognormal_distribution<_RealType1>& __x);
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
param_type _M_param;
std::normal_distribution<result_type> _M_nd;
};
/**
* @brief Return true if two lognormal distributions are different.
*/
template<typename _RealType>
inline bool
operator!=(const std::lognormal_distribution<_RealType>& __d1,
const std::lognormal_distribution<_RealType>& __d2)
{ return !(__d1 == __d2); }
/**
* @brief A gamma continuous distribution for random numbers.
*
* The formula for the gamma probability density function is:
* @f[
* p(x|\alpha,\beta) = \frac{1}{\beta\Gamma(\alpha)}
* (x/\beta)^{\alpha - 1} e^{-x/\beta}
* @f]
*/
template<typename _RealType = double>
class gamma_distribution
{
static_assert(std::is_floating_point<_RealType>::value,
"result_type must be a floating point type");
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
/** Parameter type. */
struct param_type
{
typedef gamma_distribution<_RealType> distribution_type;
friend class gamma_distribution<_RealType>;
explicit
param_type(_RealType __alpha_val = _RealType(1),
_RealType __beta_val = _RealType(1))
: _M_alpha(__alpha_val), _M_beta(__beta_val)
{
__glibcxx_assert(_M_alpha > _RealType(0));
_M_initialize();
}
_RealType
alpha() const
{ return _M_alpha; }
_RealType
beta() const
{ return _M_beta; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{ return (__p1._M_alpha == __p2._M_alpha
&& __p1._M_beta == __p2._M_beta); }
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
void
_M_initialize();
_RealType _M_alpha;
_RealType _M_beta;
_RealType _M_malpha, _M_a2;
};
public:
/**
* @brief Constructs a gamma distribution with parameters
* @f$\alpha@f$ and @f$\beta@f$.
*/
explicit
gamma_distribution(_RealType __alpha_val = _RealType(1),
_RealType __beta_val = _RealType(1))
: _M_param(__alpha_val, __beta_val), _M_nd()
{ }
explicit
gamma_distribution(const param_type& __p)
: _M_param(__p), _M_nd()
{ }
/**
* @brief Resets the distribution state.
*/
void
reset()
{ _M_nd.reset(); }
/**
* @brief Returns the @f$\alpha@f$ of the distribution.
*/
_RealType
alpha() const
{ return _M_param.alpha(); }
/**
* @brief Returns the @f$\beta@f$ of the distribution.
*/
_RealType
beta() const
{ return _M_param.beta(); }
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ _M_param = __param; }
/**
* @brief Returns the greatest lower bound value of the distribution.
*/
result_type
min() const
{ return result_type(0); }
/**
* @brief Returns the least upper bound value of the distribution.
*/
result_type
max() const
{ return std::numeric_limits<result_type>::max(); }
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
{ return this->operator()(__urng, _M_param); }
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p);
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate(__f, __t, __urng, _M_param); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two gamma distributions have the same
* parameters and the sequences that would be generated
* are equal.
*/
friend bool
operator==(const gamma_distribution& __d1,
const gamma_distribution& __d2)
{ return (__d1._M_param == __d2._M_param
&& __d1._M_nd == __d2._M_nd); }
/**
* @brief Inserts a %gamma_distribution random number distribution
* @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %gamma_distribution random number distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const std::gamma_distribution<_RealType1>& __x);
/**
* @brief Extracts a %gamma_distribution random number distribution
* @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %gamma_distribution random number generator engine.
*
* @returns The input stream with @p __x extracted or in an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
std::gamma_distribution<_RealType1>& __x);
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
param_type _M_param;
std::normal_distribution<result_type> _M_nd;
};
/**
* @brief Return true if two gamma distributions are different.
*/
template<typename _RealType>
inline bool
operator!=(const std::gamma_distribution<_RealType>& __d1,
const std::gamma_distribution<_RealType>& __d2)
{ return !(__d1 == __d2); }
/**
* @brief A chi_squared_distribution random number distribution.
*
* The formula for the normal probability mass function is
* @f$p(x|n) = \frac{x^{(n/2) - 1}e^{-x/2}}{\Gamma(n/2) 2^{n/2}}@f$
*/
template<typename _RealType = double>
class chi_squared_distribution
{
static_assert(std::is_floating_point<_RealType>::value,
"result_type must be a floating point type");
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
/** Parameter type. */
struct param_type
{
typedef chi_squared_distribution<_RealType> distribution_type;
explicit
param_type(_RealType __n = _RealType(1))
: _M_n(__n)
{ }
_RealType
n() const
{ return _M_n; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{ return __p1._M_n == __p2._M_n; }
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
_RealType _M_n;
};
explicit
chi_squared_distribution(_RealType __n = _RealType(1))
: _M_param(__n), _M_gd(__n / 2)
{ }
explicit
chi_squared_distribution(const param_type& __p)
: _M_param(__p), _M_gd(__p.n() / 2)
{ }
/**
* @brief Resets the distribution state.
*/
void
reset()
{ _M_gd.reset(); }
/**
*
*/
_RealType
n() const
{ return _M_param.n(); }
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{
_M_param = __param;
typedef typename std::gamma_distribution<result_type>::param_type
param_type;
_M_gd.param(param_type{__param.n() / 2});
}
/**
* @brief Returns the greatest lower bound value of the distribution.
*/
result_type
min() const
{ return result_type(0); }
/**
* @brief Returns the least upper bound value of the distribution.
*/
result_type
max() const
{ return std::numeric_limits<result_type>::max(); }
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
{ return 2 * _M_gd(__urng); }
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
typedef typename std::gamma_distribution<result_type>::param_type
param_type;
return 2 * _M_gd(__urng, param_type(__p.n() / 2));
}
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate_impl(__f, __t, __urng); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ typename std::gamma_distribution<result_type>::param_type
__p2(__p.n() / 2);
this->__generate_impl(__f, __t, __urng, __p2); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate_impl(__f, __t, __urng); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ typename std::gamma_distribution<result_type>::param_type
__p2(__p.n() / 2);
this->__generate_impl(__f, __t, __urng, __p2); }
/**
* @brief Return true if two Chi-squared distributions have
* the same parameters and the sequences that would be
* generated are equal.
*/
friend bool
operator==(const chi_squared_distribution& __d1,
const chi_squared_distribution& __d2)
{ return __d1._M_param == __d2._M_param && __d1._M_gd == __d2._M_gd; }
/**
* @brief Inserts a %chi_squared_distribution random number distribution
* @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %chi_squared_distribution random number distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const std::chi_squared_distribution<_RealType1>& __x);
/**
* @brief Extracts a %chi_squared_distribution random number distribution
* @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %chi_squared_distribution random number
* generator engine.
*
* @returns The input stream with @p __x extracted or in an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
std::chi_squared_distribution<_RealType1>& __x);
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng);
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const typename
std::gamma_distribution<result_type>::param_type& __p);
param_type _M_param;
std::gamma_distribution<result_type> _M_gd;
};
/**
* @brief Return true if two Chi-squared distributions are different.
*/
template<typename _RealType>
inline bool
operator!=(const std::chi_squared_distribution<_RealType>& __d1,
const std::chi_squared_distribution<_RealType>& __d2)
{ return !(__d1 == __d2); }
/**
* @brief A cauchy_distribution random number distribution.
*
* The formula for the normal probability mass function is
* @f$p(x|a,b) = (\pi b (1 + (\frac{x-a}{b})^2))^{-1}@f$
*/
template<typename _RealType = double>
class cauchy_distribution
{
static_assert(std::is_floating_point<_RealType>::value,
"result_type must be a floating point type");
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
/** Parameter type. */
struct param_type
{
typedef cauchy_distribution<_RealType> distribution_type;
explicit
param_type(_RealType __a = _RealType(0),
_RealType __b = _RealType(1))
: _M_a(__a), _M_b(__b)
{ }
_RealType
a() const
{ return _M_a; }
_RealType
b() const
{ return _M_b; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{ return __p1._M_a == __p2._M_a && __p1._M_b == __p2._M_b; }
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
_RealType _M_a;
_RealType _M_b;
};
explicit
cauchy_distribution(_RealType __a = _RealType(0),
_RealType __b = _RealType(1))
: _M_param(__a, __b)
{ }
explicit
cauchy_distribution(const param_type& __p)
: _M_param(__p)
{ }
/**
* @brief Resets the distribution state.
*/
void
reset()
{ }
/**
*
*/
_RealType
a() const
{ return _M_param.a(); }
_RealType
b() const
{ return _M_param.b(); }
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ _M_param = __param; }
/**
* @brief Returns the greatest lower bound value of the distribution.
*/
result_type
min() const
{ return std::numeric_limits<result_type>::lowest(); }
/**
* @brief Returns the least upper bound value of the distribution.
*/
result_type
max() const
{ return std::numeric_limits<result_type>::max(); }
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
{ return this->operator()(__urng, _M_param); }
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p);
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate(__f, __t, __urng, _M_param); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two Cauchy distributions have
* the same parameters.
*/
friend bool
operator==(const cauchy_distribution& __d1,
const cauchy_distribution& __d2)
{ return __d1._M_param == __d2._M_param; }
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
param_type _M_param;
};
/**
* @brief Return true if two Cauchy distributions have
* different parameters.
*/
template<typename _RealType>
inline bool
operator!=(const std::cauchy_distribution<_RealType>& __d1,
const std::cauchy_distribution<_RealType>& __d2)
{ return !(__d1 == __d2); }
/**
* @brief Inserts a %cauchy_distribution random number distribution
* @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %cauchy_distribution random number distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const std::cauchy_distribution<_RealType>& __x);
/**
* @brief Extracts a %cauchy_distribution random number distribution
* @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %cauchy_distribution random number
* generator engine.
*
* @returns The input stream with @p __x extracted or in an error state.
*/
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
std::cauchy_distribution<_RealType>& __x);
/**
* @brief A fisher_f_distribution random number distribution.
*
* The formula for the normal probability mass function is
* @f[
* p(x|m,n) = \frac{\Gamma((m+n)/2)}{\Gamma(m/2)\Gamma(n/2)}
* (\frac{m}{n})^{m/2} x^{(m/2)-1}
* (1 + \frac{mx}{n})^{-(m+n)/2}
* @f]
*/
template<typename _RealType = double>
class fisher_f_distribution
{
static_assert(std::is_floating_point<_RealType>::value,
"result_type must be a floating point type");
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
/** Parameter type. */
struct param_type
{
typedef fisher_f_distribution<_RealType> distribution_type;
explicit
param_type(_RealType __m = _RealType(1),
_RealType __n = _RealType(1))
: _M_m(__m), _M_n(__n)
{ }
_RealType
m() const
{ return _M_m; }
_RealType
n() const
{ return _M_n; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{ return __p1._M_m == __p2._M_m && __p1._M_n == __p2._M_n; }
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
_RealType _M_m;
_RealType _M_n;
};
explicit
fisher_f_distribution(_RealType __m = _RealType(1),
_RealType __n = _RealType(1))
: _M_param(__m, __n), _M_gd_x(__m / 2), _M_gd_y(__n / 2)
{ }
explicit
fisher_f_distribution(const param_type& __p)
: _M_param(__p), _M_gd_x(__p.m() / 2), _M_gd_y(__p.n() / 2)
{ }
/**
* @brief Resets the distribution state.
*/
void
reset()
{
_M_gd_x.reset();
_M_gd_y.reset();
}
/**
*
*/
_RealType
m() const
{ return _M_param.m(); }
_RealType
n() const
{ return _M_param.n(); }
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ _M_param = __param; }
/**
* @brief Returns the greatest lower bound value of the distribution.
*/
result_type
min() const
{ return result_type(0); }
/**
* @brief Returns the least upper bound value of the distribution.
*/
result_type
max() const
{ return std::numeric_limits<result_type>::max(); }
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
{ return (_M_gd_x(__urng) * n()) / (_M_gd_y(__urng) * m()); }
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
typedef typename std::gamma_distribution<result_type>::param_type
param_type;
return ((_M_gd_x(__urng, param_type(__p.m() / 2)) * n())
/ (_M_gd_y(__urng, param_type(__p.n() / 2)) * m()));
}
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate_impl(__f, __t, __urng); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate_impl(__f, __t, __urng); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two Fisher f distributions have
* the same parameters and the sequences that would
* be generated are equal.
*/
friend bool
operator==(const fisher_f_distribution& __d1,
const fisher_f_distribution& __d2)
{ return (__d1._M_param == __d2._M_param
&& __d1._M_gd_x == __d2._M_gd_x
&& __d1._M_gd_y == __d2._M_gd_y); }
/**
* @brief Inserts a %fisher_f_distribution random number distribution
* @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %fisher_f_distribution random number distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const std::fisher_f_distribution<_RealType1>& __x);
/**
* @brief Extracts a %fisher_f_distribution random number distribution
* @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %fisher_f_distribution random number
* generator engine.
*
* @returns The input stream with @p __x extracted or in an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
std::fisher_f_distribution<_RealType1>& __x);
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng);
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
param_type _M_param;
std::gamma_distribution<result_type> _M_gd_x, _M_gd_y;
};
/**
* @brief Return true if two Fisher f distributions are different.
*/
template<typename _RealType>
inline bool
operator!=(const std::fisher_f_distribution<_RealType>& __d1,
const std::fisher_f_distribution<_RealType>& __d2)
{ return !(__d1 == __d2); }
/**
* @brief A student_t_distribution random number distribution.
*
* The formula for the normal probability mass function is:
* @f[
* p(x|n) = \frac{1}{\sqrt(n\pi)} \frac{\Gamma((n+1)/2)}{\Gamma(n/2)}
* (1 + \frac{x^2}{n}) ^{-(n+1)/2}
* @f]
*/
template<typename _RealType = double>
class student_t_distribution
{
static_assert(std::is_floating_point<_RealType>::value,
"result_type must be a floating point type");
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
/** Parameter type. */
struct param_type
{
typedef student_t_distribution<_RealType> distribution_type;
explicit
param_type(_RealType __n = _RealType(1))
: _M_n(__n)
{ }
_RealType
n() const
{ return _M_n; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{ return __p1._M_n == __p2._M_n; }
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
_RealType _M_n;
};
explicit
student_t_distribution(_RealType __n = _RealType(1))
: _M_param(__n), _M_nd(), _M_gd(__n / 2, 2)
{ }
explicit
student_t_distribution(const param_type& __p)
: _M_param(__p), _M_nd(), _M_gd(__p.n() / 2, 2)
{ }
/**
* @brief Resets the distribution state.
*/
void
reset()
{
_M_nd.reset();
_M_gd.reset();
}
/**
*
*/
_RealType
n() const
{ return _M_param.n(); }
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ _M_param = __param; }
/**
* @brief Returns the greatest lower bound value of the distribution.
*/
result_type
min() const
{ return std::numeric_limits<result_type>::lowest(); }
/**
* @brief Returns the least upper bound value of the distribution.
*/
result_type
max() const
{ return std::numeric_limits<result_type>::max(); }
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
{ return _M_nd(__urng) * std::sqrt(n() / _M_gd(__urng)); }
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
typedef typename std::gamma_distribution<result_type>::param_type
param_type;
const result_type __g = _M_gd(__urng, param_type(__p.n() / 2, 2));
return _M_nd(__urng) * std::sqrt(__p.n() / __g);
}
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate_impl(__f, __t, __urng); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate_impl(__f, __t, __urng); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two Student t distributions have
* the same parameters and the sequences that would
* be generated are equal.
*/
friend bool
operator==(const student_t_distribution& __d1,
const student_t_distribution& __d2)
{ return (__d1._M_param == __d2._M_param
&& __d1._M_nd == __d2._M_nd && __d1._M_gd == __d2._M_gd); }
/**
* @brief Inserts a %student_t_distribution random number distribution
* @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %student_t_distribution random number distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const std::student_t_distribution<_RealType1>& __x);
/**
* @brief Extracts a %student_t_distribution random number distribution
* @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %student_t_distribution random number
* generator engine.
*
* @returns The input stream with @p __x extracted or in an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
std::student_t_distribution<_RealType1>& __x);
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng);
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
param_type _M_param;
std::normal_distribution<result_type> _M_nd;
std::gamma_distribution<result_type> _M_gd;
};
/**
* @brief Return true if two Student t distributions are different.
*/
template<typename _RealType>
inline bool
operator!=(const std::student_t_distribution<_RealType>& __d1,
const std::student_t_distribution<_RealType>& __d2)
{ return !(__d1 == __d2); }
/* @} */ // group random_distributions_normal
/**
* @addtogroup random_distributions_bernoulli Bernoulli Distributions
* @ingroup random_distributions
* @{
*/
/**
* @brief A Bernoulli random number distribution.
*
* Generates a sequence of true and false values with likelihood @f$p@f$
* that true will come up and @f$(1 - p)@f$ that false will appear.
*/
class bernoulli_distribution
{
public:
/** The type of the range of the distribution. */
typedef bool result_type;
/** Parameter type. */
struct param_type
{
typedef bernoulli_distribution distribution_type;
explicit
param_type(double __p = 0.5)
: _M_p(__p)
{
__glibcxx_assert((_M_p >= 0.0) && (_M_p <= 1.0));
}
double
p() const
{ return _M_p; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{ return __p1._M_p == __p2._M_p; }
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
double _M_p;
};
public:
/**
* @brief Constructs a Bernoulli distribution with likelihood @p p.
*
* @param __p [IN] The likelihood of a true result being returned.
* Must be in the interval @f$[0, 1]@f$.
*/
explicit
bernoulli_distribution(double __p = 0.5)
: _M_param(__p)
{ }
explicit
bernoulli_distribution(const param_type& __p)
: _M_param(__p)
{ }
/**
* @brief Resets the distribution state.
*
* Does nothing for a Bernoulli distribution.
*/
void
reset() { }
/**
* @brief Returns the @p p parameter of the distribution.
*/
double
p() const
{ return _M_param.p(); }
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ _M_param = __param; }
/**
* @brief Returns the greatest lower bound value of the distribution.
*/
result_type
min() const
{ return std::numeric_limits<result_type>::min(); }
/**
* @brief Returns the least upper bound value of the distribution.
*/
result_type
max() const
{ return std::numeric_limits<result_type>::max(); }
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
{ return this->operator()(__urng, _M_param); }
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
__detail::_Adaptor<_UniformRandomNumberGenerator, double>
__aurng(__urng);
if ((__aurng() - __aurng.min())
< __p.p() * (__aurng.max() - __aurng.min()))
return true;
return false;
}
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate(__f, __t, __urng, _M_param); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng, const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two Bernoulli distributions have
* the same parameters.
*/
friend bool
operator==(const bernoulli_distribution& __d1,
const bernoulli_distribution& __d2)
{ return __d1._M_param == __d2._M_param; }
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
param_type _M_param;
};
/**
* @brief Return true if two Bernoulli distributions have
* different parameters.
*/
inline bool
operator!=(const std::bernoulli_distribution& __d1,
const std::bernoulli_distribution& __d2)
{ return !(__d1 == __d2); }
/**
* @brief Inserts a %bernoulli_distribution random number distribution
* @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %bernoulli_distribution random number distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const std::bernoulli_distribution& __x);
/**
* @brief Extracts a %bernoulli_distribution random number distribution
* @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %bernoulli_distribution random number generator engine.
*
* @returns The input stream with @p __x extracted or in an error state.
*/
template<typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
std::bernoulli_distribution& __x)
{
double __p;
if (__is >> __p)
__x.param(bernoulli_distribution::param_type(__p));
return __is;
}
/**
* @brief A discrete binomial random number distribution.
*
* The formula for the binomial probability density function is
* @f$p(i|t,p) = \binom{t}{i} p^i (1 - p)^{t - i}@f$ where @f$t@f$
* and @f$p@f$ are the parameters of the distribution.
*/
template<typename _IntType = int>
class binomial_distribution
{
static_assert(std::is_integral<_IntType>::value,
"result_type must be an integral type");
public:
/** The type of the range of the distribution. */
typedef _IntType result_type;
/** Parameter type. */
struct param_type
{
typedef binomial_distribution<_IntType> distribution_type;
friend class binomial_distribution<_IntType>;
explicit
param_type(_IntType __t = _IntType(1), double __p = 0.5)
: _M_t(__t), _M_p(__p)
{
__glibcxx_assert((_M_t >= _IntType(0))
&& (_M_p >= 0.0)
&& (_M_p <= 1.0));
_M_initialize();
}
_IntType
t() const
{ return _M_t; }
double
p() const
{ return _M_p; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{ return __p1._M_t == __p2._M_t && __p1._M_p == __p2._M_p; }
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
void
_M_initialize();
_IntType _M_t;
double _M_p;
double _M_q;
#if _GLIBCXX_USE_C99_MATH_TR1
double _M_d1, _M_d2, _M_s1, _M_s2, _M_c,
_M_a1, _M_a123, _M_s, _M_lf, _M_lp1p;
#endif
bool _M_easy;
};
// constructors and member function
explicit
binomial_distribution(_IntType __t = _IntType(1),
double __p = 0.5)
: _M_param(__t, __p), _M_nd()
{ }
explicit
binomial_distribution(const param_type& __p)
: _M_param(__p), _M_nd()
{ }
/**
* @brief Resets the distribution state.
*/
void
reset()
{ _M_nd.reset(); }
/**
* @brief Returns the distribution @p t parameter.
*/
_IntType
t() const
{ return _M_param.t(); }
/**
* @brief Returns the distribution @p p parameter.
*/
double
p() const
{ return _M_param.p(); }
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ _M_param = __param; }
/**
* @brief Returns the greatest lower bound value of the distribution.
*/
result_type
min() const
{ return 0; }
/**
* @brief Returns the least upper bound value of the distribution.
*/
result_type
max() const
{ return _M_param.t(); }
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
{ return this->operator()(__urng, _M_param); }
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p);
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate(__f, __t, __urng, _M_param); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two binomial distributions have
* the same parameters and the sequences that would
* be generated are equal.
*/
friend bool
operator==(const binomial_distribution& __d1,
const binomial_distribution& __d2)
#ifdef _GLIBCXX_USE_C99_MATH_TR1
{ return __d1._M_param == __d2._M_param && __d1._M_nd == __d2._M_nd; }
#else
{ return __d1._M_param == __d2._M_param; }
#endif
/**
* @brief Inserts a %binomial_distribution random number distribution
* @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %binomial_distribution random number distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _IntType1,
typename _CharT, typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const std::binomial_distribution<_IntType1>& __x);
/**
* @brief Extracts a %binomial_distribution random number distribution
* @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %binomial_distribution random number generator engine.
*
* @returns The input stream with @p __x extracted or in an error
* state.
*/
template<typename _IntType1,
typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
std::binomial_distribution<_IntType1>& __x);
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
template<typename _UniformRandomNumberGenerator>
result_type
_M_waiting(_UniformRandomNumberGenerator& __urng,
_IntType __t, double __q);
param_type _M_param;
// NB: Unused when _GLIBCXX_USE_C99_MATH_TR1 is undefined.
std::normal_distribution<double> _M_nd;
};
/**
* @brief Return true if two binomial distributions are different.
*/
template<typename _IntType>
inline bool
operator!=(const std::binomial_distribution<_IntType>& __d1,
const std::binomial_distribution<_IntType>& __d2)
{ return !(__d1 == __d2); }
/**
* @brief A discrete geometric random number distribution.
*
* The formula for the geometric probability density function is
* @f$p(i|p) = p(1 - p)^{i}@f$ where @f$p@f$ is the parameter of the
* distribution.
*/
template<typename _IntType = int>
class geometric_distribution
{
static_assert(std::is_integral<_IntType>::value,
"result_type must be an integral type");
public:
/** The type of the range of the distribution. */
typedef _IntType result_type;
/** Parameter type. */
struct param_type
{
typedef geometric_distribution<_IntType> distribution_type;
friend class geometric_distribution<_IntType>;
explicit
param_type(double __p = 0.5)
: _M_p(__p)
{
__glibcxx_assert((_M_p > 0.0) && (_M_p < 1.0));
_M_initialize();
}
double
p() const
{ return _M_p; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{ return __p1._M_p == __p2._M_p; }
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
void
_M_initialize()
{ _M_log_1_p = std::log(1.0 - _M_p); }
double _M_p;
double _M_log_1_p;
};
// constructors and member function
explicit
geometric_distribution(double __p = 0.5)
: _M_param(__p)
{ }
explicit
geometric_distribution(const param_type& __p)
: _M_param(__p)
{ }
/**
* @brief Resets the distribution state.
*
* Does nothing for the geometric distribution.
*/
void
reset() { }
/**
* @brief Returns the distribution parameter @p p.
*/
double
p() const
{ return _M_param.p(); }
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ _M_param = __param; }
/**
* @brief Returns the greatest lower bound value of the distribution.
*/
result_type
min() const
{ return 0; }
/**
* @brief Returns the least upper bound value of the distribution.
*/
result_type
max() const
{ return std::numeric_limits<result_type>::max(); }
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
{ return this->operator()(__urng, _M_param); }
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p);
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate(__f, __t, __urng, _M_param); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two geometric distributions have
* the same parameters.
*/
friend bool
operator==(const geometric_distribution& __d1,
const geometric_distribution& __d2)
{ return __d1._M_param == __d2._M_param; }
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
param_type _M_param;
};
/**
* @brief Return true if two geometric distributions have
* different parameters.
*/
template<typename _IntType>
inline bool
operator!=(const std::geometric_distribution<_IntType>& __d1,
const std::geometric_distribution<_IntType>& __d2)
{ return !(__d1 == __d2); }
/**
* @brief Inserts a %geometric_distribution random number distribution
* @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %geometric_distribution random number distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _IntType,
typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const std::geometric_distribution<_IntType>& __x);
/**
* @brief Extracts a %geometric_distribution random number distribution
* @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %geometric_distribution random number generator engine.
*
* @returns The input stream with @p __x extracted or in an error state.
*/
template<typename _IntType,
typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
std::geometric_distribution<_IntType>& __x);
/**
* @brief A negative_binomial_distribution random number distribution.
*
* The formula for the negative binomial probability mass function is
* @f$p(i) = \binom{n}{i} p^i (1 - p)^{t - i}@f$ where @f$t@f$
* and @f$p@f$ are the parameters of the distribution.
*/
template<typename _IntType = int>
class negative_binomial_distribution
{
static_assert(std::is_integral<_IntType>::value,
"result_type must be an integral type");
public:
/** The type of the range of the distribution. */
typedef _IntType result_type;
/** Parameter type. */
struct param_type
{
typedef negative_binomial_distribution<_IntType> distribution_type;
explicit
param_type(_IntType __k = 1, double __p = 0.5)
: _M_k(__k), _M_p(__p)
{
__glibcxx_assert((_M_k > 0) && (_M_p > 0.0) && (_M_p <= 1.0));
}
_IntType
k() const
{ return _M_k; }
double
p() const
{ return _M_p; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{ return __p1._M_k == __p2._M_k && __p1._M_p == __p2._M_p; }
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
_IntType _M_k;
double _M_p;
};
explicit
negative_binomial_distribution(_IntType __k = 1, double __p = 0.5)
: _M_param(__k, __p), _M_gd(__k, (1.0 - __p) / __p)
{ }
explicit
negative_binomial_distribution(const param_type& __p)
: _M_param(__p), _M_gd(__p.k(), (1.0 - __p.p()) / __p.p())
{ }
/**
* @brief Resets the distribution state.
*/
void
reset()
{ _M_gd.reset(); }
/**
* @brief Return the @f$k@f$ parameter of the distribution.
*/
_IntType
k() const
{ return _M_param.k(); }
/**
* @brief Return the @f$p@f$ parameter of the distribution.
*/
double
p() const
{ return _M_param.p(); }
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ _M_param = __param; }
/**
* @brief Returns the greatest lower bound value of the distribution.
*/
result_type
min() const
{ return result_type(0); }
/**
* @brief Returns the least upper bound value of the distribution.
*/
result_type
max() const
{ return std::numeric_limits<result_type>::max(); }
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng);
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p);
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate_impl(__f, __t, __urng); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate_impl(__f, __t, __urng); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two negative binomial distributions have
* the same parameters and the sequences that would be
* generated are equal.
*/
friend bool
operator==(const negative_binomial_distribution& __d1,
const negative_binomial_distribution& __d2)
{ return __d1._M_param == __d2._M_param && __d1._M_gd == __d2._M_gd; }
/**
* @brief Inserts a %negative_binomial_distribution random
* number distribution @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %negative_binomial_distribution random number
* distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _IntType1, typename _CharT, typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const std::negative_binomial_distribution<_IntType1>& __x);
/**
* @brief Extracts a %negative_binomial_distribution random number
* distribution @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %negative_binomial_distribution random number
* generator engine.
*
* @returns The input stream with @p __x extracted or in an error state.
*/
template<typename _IntType1, typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
std::negative_binomial_distribution<_IntType1>& __x);
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng);
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
param_type _M_param;
std::gamma_distribution<double> _M_gd;
};
/**
* @brief Return true if two negative binomial distributions are different.
*/
template<typename _IntType>
inline bool
operator!=(const std::negative_binomial_distribution<_IntType>& __d1,
const std::negative_binomial_distribution<_IntType>& __d2)
{ return !(__d1 == __d2); }
/* @} */ // group random_distributions_bernoulli
/**
* @addtogroup random_distributions_poisson Poisson Distributions
* @ingroup random_distributions
* @{
*/
/**
* @brief A discrete Poisson random number distribution.
*
* The formula for the Poisson probability density function is
* @f$p(i|\mu) = \frac{\mu^i}{i!} e^{-\mu}@f$ where @f$\mu@f$ is the
* parameter of the distribution.
*/
template<typename _IntType = int>
class poisson_distribution
{
static_assert(std::is_integral<_IntType>::value,
"result_type must be an integral type");
public:
/** The type of the range of the distribution. */
typedef _IntType result_type;
/** Parameter type. */
struct param_type
{
typedef poisson_distribution<_IntType> distribution_type;
friend class poisson_distribution<_IntType>;
explicit
param_type(double __mean = 1.0)
: _M_mean(__mean)
{
__glibcxx_assert(_M_mean > 0.0);
_M_initialize();
}
double
mean() const
{ return _M_mean; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{ return __p1._M_mean == __p2._M_mean; }
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
// Hosts either log(mean) or the threshold of the simple method.
void
_M_initialize();
double _M_mean;
double _M_lm_thr;
#if _GLIBCXX_USE_C99_MATH_TR1
double _M_lfm, _M_sm, _M_d, _M_scx, _M_1cx, _M_c2b, _M_cb;
#endif
};
// constructors and member function
explicit
poisson_distribution(double __mean = 1.0)
: _M_param(__mean), _M_nd()
{ }
explicit
poisson_distribution(const param_type& __p)
: _M_param(__p), _M_nd()
{ }
/**
* @brief Resets the distribution state.
*/
void
reset()
{ _M_nd.reset(); }
/**
* @brief Returns the distribution parameter @p mean.
*/
double
mean() const
{ return _M_param.mean(); }
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ _M_param = __param; }
/**
* @brief Returns the greatest lower bound value of the distribution.
*/
result_type
min() const
{ return 0; }
/**
* @brief Returns the least upper bound value of the distribution.
*/
result_type
max() const
{ return std::numeric_limits<result_type>::max(); }
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
{ return this->operator()(__urng, _M_param); }
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p);
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate(__f, __t, __urng, _M_param); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two Poisson distributions have the same
* parameters and the sequences that would be generated
* are equal.
*/
friend bool
operator==(const poisson_distribution& __d1,
const poisson_distribution& __d2)
#ifdef _GLIBCXX_USE_C99_MATH_TR1
{ return __d1._M_param == __d2._M_param && __d1._M_nd == __d2._M_nd; }
#else
{ return __d1._M_param == __d2._M_param; }
#endif
/**
* @brief Inserts a %poisson_distribution random number distribution
* @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %poisson_distribution random number distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _IntType1, typename _CharT, typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const std::poisson_distribution<_IntType1>& __x);
/**
* @brief Extracts a %poisson_distribution random number distribution
* @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %poisson_distribution random number generator engine.
*
* @returns The input stream with @p __x extracted or in an error
* state.
*/
template<typename _IntType1, typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
std::poisson_distribution<_IntType1>& __x);
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
param_type _M_param;
// NB: Unused when _GLIBCXX_USE_C99_MATH_TR1 is undefined.
std::normal_distribution<double> _M_nd;
};
/**
* @brief Return true if two Poisson distributions are different.
*/
template<typename _IntType>
inline bool
operator!=(const std::poisson_distribution<_IntType>& __d1,
const std::poisson_distribution<_IntType>& __d2)
{ return !(__d1 == __d2); }
/**
* @brief An exponential continuous distribution for random numbers.
*
* The formula for the exponential probability density function is
* @f$p(x|\lambda) = \lambda e^{-\lambda x}@f$.
*
* <table border=1 cellpadding=10 cellspacing=0>
* <caption align=top>Distribution Statistics</caption>
* <tr><td>Mean</td><td>@f$\frac{1}{\lambda}@f$</td></tr>
* <tr><td>Median</td><td>@f$\frac{\ln 2}{\lambda}@f$</td></tr>
* <tr><td>Mode</td><td>@f$zero@f$</td></tr>
* <tr><td>Range</td><td>@f$[0, \infty]@f$</td></tr>
* <tr><td>Standard Deviation</td><td>@f$\frac{1}{\lambda}@f$</td></tr>
* </table>
*/
template<typename _RealType = double>
class exponential_distribution
{
static_assert(std::is_floating_point<_RealType>::value,
"result_type must be a floating point type");
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
/** Parameter type. */
struct param_type
{
typedef exponential_distribution<_RealType> distribution_type;
explicit
param_type(_RealType __lambda = _RealType(1))
: _M_lambda(__lambda)
{
__glibcxx_assert(_M_lambda > _RealType(0));
}
_RealType
lambda() const
{ return _M_lambda; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{ return __p1._M_lambda == __p2._M_lambda; }
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
_RealType _M_lambda;
};
public:
/**
* @brief Constructs an exponential distribution with inverse scale
* parameter @f$\lambda@f$.
*/
explicit
exponential_distribution(const result_type& __lambda = result_type(1))
: _M_param(__lambda)
{ }
explicit
exponential_distribution(const param_type& __p)
: _M_param(__p)
{ }
/**
* @brief Resets the distribution state.
*
* Has no effect on exponential distributions.
*/
void
reset() { }
/**
* @brief Returns the inverse scale parameter of the distribution.
*/
_RealType
lambda() const
{ return _M_param.lambda(); }
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ _M_param = __param; }
/**
* @brief Returns the greatest lower bound value of the distribution.
*/
result_type
min() const
{ return result_type(0); }
/**
* @brief Returns the least upper bound value of the distribution.
*/
result_type
max() const
{ return std::numeric_limits<result_type>::max(); }
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
{ return this->operator()(__urng, _M_param); }
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
__aurng(__urng);
return -std::log(result_type(1) - __aurng()) / __p.lambda();
}
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate(__f, __t, __urng, _M_param); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two exponential distributions have the same
* parameters.
*/
friend bool
operator==(const exponential_distribution& __d1,
const exponential_distribution& __d2)
{ return __d1._M_param == __d2._M_param; }
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
param_type _M_param;
};
/**
* @brief Return true if two exponential distributions have different
* parameters.
*/
template<typename _RealType>
inline bool
operator!=(const std::exponential_distribution<_RealType>& __d1,
const std::exponential_distribution<_RealType>& __d2)
{ return !(__d1 == __d2); }
/**
* @brief Inserts a %exponential_distribution random number distribution
* @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %exponential_distribution random number distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const std::exponential_distribution<_RealType>& __x);
/**
* @brief Extracts a %exponential_distribution random number distribution
* @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %exponential_distribution random number
* generator engine.
*
* @returns The input stream with @p __x extracted or in an error state.
*/
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
std::exponential_distribution<_RealType>& __x);
/**
* @brief A weibull_distribution random number distribution.
*
* The formula for the normal probability density function is:
* @f[
* p(x|\alpha,\beta) = \frac{\alpha}{\beta} (\frac{x}{\beta})^{\alpha-1}
* \exp{(-(\frac{x}{\beta})^\alpha)}
* @f]
*/
template<typename _RealType = double>
class weibull_distribution
{
static_assert(std::is_floating_point<_RealType>::value,
"result_type must be a floating point type");
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
/** Parameter type. */
struct param_type
{
typedef weibull_distribution<_RealType> distribution_type;
explicit
param_type(_RealType __a = _RealType(1),
_RealType __b = _RealType(1))
: _M_a(__a), _M_b(__b)
{ }
_RealType
a() const
{ return _M_a; }
_RealType
b() const
{ return _M_b; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{ return __p1._M_a == __p2._M_a && __p1._M_b == __p2._M_b; }
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
_RealType _M_a;
_RealType _M_b;
};
explicit
weibull_distribution(_RealType __a = _RealType(1),
_RealType __b = _RealType(1))
: _M_param(__a, __b)
{ }
explicit
weibull_distribution(const param_type& __p)
: _M_param(__p)
{ }
/**
* @brief Resets the distribution state.
*/
void
reset()
{ }
/**
* @brief Return the @f$a@f$ parameter of the distribution.
*/
_RealType
a() const
{ return _M_param.a(); }
/**
* @brief Return the @f$b@f$ parameter of the distribution.
*/
_RealType
b() const
{ return _M_param.b(); }
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ _M_param = __param; }
/**
* @brief Returns the greatest lower bound value of the distribution.
*/
result_type
min() const
{ return result_type(0); }
/**
* @brief Returns the least upper bound value of the distribution.
*/
result_type
max() const
{ return std::numeric_limits<result_type>::max(); }
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
{ return this->operator()(__urng, _M_param); }
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p);
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate(__f, __t, __urng, _M_param); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two Weibull distributions have the same
* parameters.
*/
friend bool
operator==(const weibull_distribution& __d1,
const weibull_distribution& __d2)
{ return __d1._M_param == __d2._M_param; }
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
param_type _M_param;
};
/**
* @brief Return true if two Weibull distributions have different
* parameters.
*/
template<typename _RealType>
inline bool
operator!=(const std::weibull_distribution<_RealType>& __d1,
const std::weibull_distribution<_RealType>& __d2)
{ return !(__d1 == __d2); }
/**
* @brief Inserts a %weibull_distribution random number distribution
* @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %weibull_distribution random number distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const std::weibull_distribution<_RealType>& __x);
/**
* @brief Extracts a %weibull_distribution random number distribution
* @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %weibull_distribution random number
* generator engine.
*
* @returns The input stream with @p __x extracted or in an error state.
*/
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
std::weibull_distribution<_RealType>& __x);
/**
* @brief A extreme_value_distribution random number distribution.
*
* The formula for the normal probability mass function is
* @f[
* p(x|a,b) = \frac{1}{b}
* \exp( \frac{a-x}{b} - \exp(\frac{a-x}{b}))
* @f]
*/
template<typename _RealType = double>
class extreme_value_distribution
{
static_assert(std::is_floating_point<_RealType>::value,
"result_type must be a floating point type");
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
/** Parameter type. */
struct param_type
{
typedef extreme_value_distribution<_RealType> distribution_type;
explicit
param_type(_RealType __a = _RealType(0),
_RealType __b = _RealType(1))
: _M_a(__a), _M_b(__b)
{ }
_RealType
a() const
{ return _M_a; }
_RealType
b() const
{ return _M_b; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{ return __p1._M_a == __p2._M_a && __p1._M_b == __p2._M_b; }
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
_RealType _M_a;
_RealType _M_b;
};
explicit
extreme_value_distribution(_RealType __a = _RealType(0),
_RealType __b = _RealType(1))
: _M_param(__a, __b)
{ }
explicit
extreme_value_distribution(const param_type& __p)
: _M_param(__p)
{ }
/**
* @brief Resets the distribution state.
*/
void
reset()
{ }
/**
* @brief Return the @f$a@f$ parameter of the distribution.
*/
_RealType
a() const
{ return _M_param.a(); }
/**
* @brief Return the @f$b@f$ parameter of the distribution.
*/
_RealType
b() const
{ return _M_param.b(); }
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ _M_param = __param; }
/**
* @brief Returns the greatest lower bound value of the distribution.
*/
result_type
min() const
{ return std::numeric_limits<result_type>::lowest(); }
/**
* @brief Returns the least upper bound value of the distribution.
*/
result_type
max() const
{ return std::numeric_limits<result_type>::max(); }
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
{ return this->operator()(__urng, _M_param); }
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p);
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate(__f, __t, __urng, _M_param); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two extreme value distributions have the same
* parameters.
*/
friend bool
operator==(const extreme_value_distribution& __d1,
const extreme_value_distribution& __d2)
{ return __d1._M_param == __d2._M_param; }
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
param_type _M_param;
};
/**
* @brief Return true if two extreme value distributions have different
* parameters.
*/
template<typename _RealType>
inline bool
operator!=(const std::extreme_value_distribution<_RealType>& __d1,
const std::extreme_value_distribution<_RealType>& __d2)
{ return !(__d1 == __d2); }
/**
* @brief Inserts a %extreme_value_distribution random number distribution
* @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %extreme_value_distribution random number distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const std::extreme_value_distribution<_RealType>& __x);
/**
* @brief Extracts a %extreme_value_distribution random number
* distribution @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %extreme_value_distribution random number
* generator engine.
*
* @returns The input stream with @p __x extracted or in an error state.
*/
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
std::extreme_value_distribution<_RealType>& __x);
/**
* @brief A discrete_distribution random number distribution.
*
* The formula for the discrete probability mass function is
*
*/
template<typename _IntType = int>
class discrete_distribution
{
static_assert(std::is_integral<_IntType>::value,
"result_type must be an integral type");
public:
/** The type of the range of the distribution. */
typedef _IntType result_type;
/** Parameter type. */
struct param_type
{
typedef discrete_distribution<_IntType> distribution_type;
friend class discrete_distribution<_IntType>;
param_type()
: _M_prob(), _M_cp()
{ }
template<typename _InputIterator>
param_type(_InputIterator __wbegin,
_InputIterator __wend)
: _M_prob(__wbegin, __wend), _M_cp()
{ _M_initialize(); }
param_type(initializer_list<double> __wil)
: _M_prob(__wil.begin(), __wil.end()), _M_cp()
{ _M_initialize(); }
template<typename _Func>
param_type(size_t __nw, double __xmin, double __xmax,
_Func __fw);
// See: http://cpp-next.com/archive/2010/10/implicit-move-must-go/
param_type(const param_type&) = default;
param_type& operator=(const param_type&) = default;
std::vector<double>
probabilities() const
{ return _M_prob.empty() ? std::vector<double>(1, 1.0) : _M_prob; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{ return __p1._M_prob == __p2._M_prob; }
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
void
_M_initialize();
std::vector<double> _M_prob;
std::vector<double> _M_cp;
};
discrete_distribution()
: _M_param()
{ }
template<typename _InputIterator>
discrete_distribution(_InputIterator __wbegin,
_InputIterator __wend)
: _M_param(__wbegin, __wend)
{ }
discrete_distribution(initializer_list<double> __wl)
: _M_param(__wl)
{ }
template<typename _Func>
discrete_distribution(size_t __nw, double __xmin, double __xmax,
_Func __fw)
: _M_param(__nw, __xmin, __xmax, __fw)
{ }
explicit
discrete_distribution(const param_type& __p)
: _M_param(__p)
{ }
/**
* @brief Resets the distribution state.
*/
void
reset()
{ }
/**
* @brief Returns the probabilities of the distribution.
*/
std::vector<double>
probabilities() const
{
return _M_param._M_prob.empty()
? std::vector<double>(1, 1.0) : _M_param._M_prob;
}
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ _M_param = __param; }
/**
* @brief Returns the greatest lower bound value of the distribution.
*/
result_type
min() const
{ return result_type(0); }
/**
* @brief Returns the least upper bound value of the distribution.
*/
result_type
max() const
{
return _M_param._M_prob.empty()
? result_type(0) : result_type(_M_param._M_prob.size() - 1);
}
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
{ return this->operator()(__urng, _M_param); }
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p);
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate(__f, __t, __urng, _M_param); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two discrete distributions have the same
* parameters.
*/
friend bool
operator==(const discrete_distribution& __d1,
const discrete_distribution& __d2)
{ return __d1._M_param == __d2._M_param; }
/**
* @brief Inserts a %discrete_distribution random number distribution
* @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %discrete_distribution random number distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _IntType1, typename _CharT, typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const std::discrete_distribution<_IntType1>& __x);
/**
* @brief Extracts a %discrete_distribution random number distribution
* @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %discrete_distribution random number
* generator engine.
*
* @returns The input stream with @p __x extracted or in an error
* state.
*/
template<typename _IntType1, typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
std::discrete_distribution<_IntType1>& __x);
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
param_type _M_param;
};
/**
* @brief Return true if two discrete distributions have different
* parameters.
*/
template<typename _IntType>
inline bool
operator!=(const std::discrete_distribution<_IntType>& __d1,
const std::discrete_distribution<_IntType>& __d2)
{ return !(__d1 == __d2); }
/**
* @brief A piecewise_constant_distribution random number distribution.
*
* The formula for the piecewise constant probability mass function is
*
*/
template<typename _RealType = double>
class piecewise_constant_distribution
{
static_assert(std::is_floating_point<_RealType>::value,
"result_type must be a floating point type");
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
/** Parameter type. */
struct param_type
{
typedef piecewise_constant_distribution<_RealType> distribution_type;
friend class piecewise_constant_distribution<_RealType>;
param_type()
: _M_int(), _M_den(), _M_cp()
{ }
template<typename _InputIteratorB, typename _InputIteratorW>
param_type(_InputIteratorB __bfirst,
_InputIteratorB __bend,
_InputIteratorW __wbegin);
template<typename _Func>
param_type(initializer_list<_RealType> __bi, _Func __fw);
template<typename _Func>
param_type(size_t __nw, _RealType __xmin, _RealType __xmax,
_Func __fw);
// See: http://cpp-next.com/archive/2010/10/implicit-move-must-go/
param_type(const param_type&) = default;
param_type& operator=(const param_type&) = default;
std::vector<_RealType>
intervals() const
{
if (_M_int.empty())
{
std::vector<_RealType> __tmp(2);
__tmp[1] = _RealType(1);
return __tmp;
}
else
return _M_int;
}
std::vector<double>
densities() const
{ return _M_den.empty() ? std::vector<double>(1, 1.0) : _M_den; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{ return __p1._M_int == __p2._M_int && __p1._M_den == __p2._M_den; }
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
void
_M_initialize();
std::vector<_RealType> _M_int;
std::vector<double> _M_den;
std::vector<double> _M_cp;
};
explicit
piecewise_constant_distribution()
: _M_param()
{ }
template<typename _InputIteratorB, typename _InputIteratorW>
piecewise_constant_distribution(_InputIteratorB __bfirst,
_InputIteratorB __bend,
_InputIteratorW __wbegin)
: _M_param(__bfirst, __bend, __wbegin)
{ }
template<typename _Func>
piecewise_constant_distribution(initializer_list<_RealType> __bl,
_Func __fw)
: _M_param(__bl, __fw)
{ }
template<typename _Func>
piecewise_constant_distribution(size_t __nw,
_RealType __xmin, _RealType __xmax,
_Func __fw)
: _M_param(__nw, __xmin, __xmax, __fw)
{ }
explicit
piecewise_constant_distribution(const param_type& __p)
: _M_param(__p)
{ }
/**
* @brief Resets the distribution state.
*/
void
reset()
{ }
/**
* @brief Returns a vector of the intervals.
*/
std::vector<_RealType>
intervals() const
{
if (_M_param._M_int.empty())
{
std::vector<_RealType> __tmp(2);
__tmp[1] = _RealType(1);
return __tmp;
}
else
return _M_param._M_int;
}
/**
* @brief Returns a vector of the probability densities.
*/
std::vector<double>
densities() const
{
return _M_param._M_den.empty()
? std::vector<double>(1, 1.0) : _M_param._M_den;
}
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ _M_param = __param; }
/**
* @brief Returns the greatest lower bound value of the distribution.
*/
result_type
min() const
{
return _M_param._M_int.empty()
? result_type(0) : _M_param._M_int.front();
}
/**
* @brief Returns the least upper bound value of the distribution.
*/
result_type
max() const
{
return _M_param._M_int.empty()
? result_type(1) : _M_param._M_int.back();
}
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
{ return this->operator()(__urng, _M_param); }
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p);
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate(__f, __t, __urng, _M_param); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two piecewise constant distributions have the
* same parameters.
*/
friend bool
operator==(const piecewise_constant_distribution& __d1,
const piecewise_constant_distribution& __d2)
{ return __d1._M_param == __d2._M_param; }
/**
* @brief Inserts a %piecewise_constant_distribution random
* number distribution @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %piecewise_constant_distribution random number
* distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const std::piecewise_constant_distribution<_RealType1>& __x);
/**
* @brief Extracts a %piecewise_constant_distribution random
* number distribution @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %piecewise_constant_distribution random number
* generator engine.
*
* @returns The input stream with @p __x extracted or in an error
* state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
std::piecewise_constant_distribution<_RealType1>& __x);
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
param_type _M_param;
};
/**
* @brief Return true if two piecewise constant distributions have
* different parameters.
*/
template<typename _RealType>
inline bool
operator!=(const std::piecewise_constant_distribution<_RealType>& __d1,
const std::piecewise_constant_distribution<_RealType>& __d2)
{ return !(__d1 == __d2); }
/**
* @brief A piecewise_linear_distribution random number distribution.
*
* The formula for the piecewise linear probability mass function is
*
*/
template<typename _RealType = double>
class piecewise_linear_distribution
{
static_assert(std::is_floating_point<_RealType>::value,
"result_type must be a floating point type");
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
/** Parameter type. */
struct param_type
{
typedef piecewise_linear_distribution<_RealType> distribution_type;
friend class piecewise_linear_distribution<_RealType>;
param_type()
: _M_int(), _M_den(), _M_cp(), _M_m()
{ }
template<typename _InputIteratorB, typename _InputIteratorW>
param_type(_InputIteratorB __bfirst,
_InputIteratorB __bend,
_InputIteratorW __wbegin);
template<typename _Func>
param_type(initializer_list<_RealType> __bl, _Func __fw);
template<typename _Func>
param_type(size_t __nw, _RealType __xmin, _RealType __xmax,
_Func __fw);
// See: http://cpp-next.com/archive/2010/10/implicit-move-must-go/
param_type(const param_type&) = default;
param_type& operator=(const param_type&) = default;
std::vector<_RealType>
intervals() const
{
if (_M_int.empty())
{
std::vector<_RealType> __tmp(2);
__tmp[1] = _RealType(1);
return __tmp;
}
else
return _M_int;
}
std::vector<double>
densities() const
{ return _M_den.empty() ? std::vector<double>(2, 1.0) : _M_den; }
friend bool
operator==(const param_type& __p1, const param_type& __p2)
{ return __p1._M_int == __p2._M_int && __p1._M_den == __p2._M_den; }
friend bool
operator!=(const param_type& __p1, const param_type& __p2)
{ return !(__p1 == __p2); }
private:
void
_M_initialize();
std::vector<_RealType> _M_int;
std::vector<double> _M_den;
std::vector<double> _M_cp;
std::vector<double> _M_m;
};
explicit
piecewise_linear_distribution()
: _M_param()
{ }
template<typename _InputIteratorB, typename _InputIteratorW>
piecewise_linear_distribution(_InputIteratorB __bfirst,
_InputIteratorB __bend,
_InputIteratorW __wbegin)
: _M_param(__bfirst, __bend, __wbegin)
{ }
template<typename _Func>
piecewise_linear_distribution(initializer_list<_RealType> __bl,
_Func __fw)
: _M_param(__bl, __fw)
{ }
template<typename _Func>
piecewise_linear_distribution(size_t __nw,
_RealType __xmin, _RealType __xmax,
_Func __fw)
: _M_param(__nw, __xmin, __xmax, __fw)
{ }
explicit
piecewise_linear_distribution(const param_type& __p)
: _M_param(__p)
{ }
/**
* Resets the distribution state.
*/
void
reset()
{ }
/**
* @brief Return the intervals of the distribution.
*/
std::vector<_RealType>
intervals() const
{
if (_M_param._M_int.empty())
{
std::vector<_RealType> __tmp(2);
__tmp[1] = _RealType(1);
return __tmp;
}
else
return _M_param._M_int;
}
/**
* @brief Return a vector of the probability densities of the
* distribution.
*/
std::vector<double>
densities() const
{
return _M_param._M_den.empty()
? std::vector<double>(2, 1.0) : _M_param._M_den;
}
/**
* @brief Returns the parameter set of the distribution.
*/
param_type
param() const
{ return _M_param; }
/**
* @brief Sets the parameter set of the distribution.
* @param __param The new parameter set of the distribution.
*/
void
param(const param_type& __param)
{ _M_param = __param; }
/**
* @brief Returns the greatest lower bound value of the distribution.
*/
result_type
min() const
{
return _M_param._M_int.empty()
? result_type(0) : _M_param._M_int.front();
}
/**
* @brief Returns the least upper bound value of the distribution.
*/
result_type
max() const
{
return _M_param._M_int.empty()
? result_type(1) : _M_param._M_int.back();
}
/**
* @brief Generating functions.
*/
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
{ return this->operator()(__urng, _M_param); }
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p);
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng)
{ this->__generate(__f, __t, __urng, _M_param); }
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
template<typename _UniformRandomNumberGenerator>
void
__generate(result_type* __f, result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{ this->__generate_impl(__f, __t, __urng, __p); }
/**
* @brief Return true if two piecewise linear distributions have the
* same parameters.
*/
friend bool
operator==(const piecewise_linear_distribution& __d1,
const piecewise_linear_distribution& __d2)
{ return __d1._M_param == __d2._M_param; }
/**
* @brief Inserts a %piecewise_linear_distribution random number
* distribution @p __x into the output stream @p __os.
*
* @param __os An output stream.
* @param __x A %piecewise_linear_distribution random number
* distribution.
*
* @returns The output stream with the state of @p __x inserted or in
* an error state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const std::piecewise_linear_distribution<_RealType1>& __x);
/**
* @brief Extracts a %piecewise_linear_distribution random number
* distribution @p __x from the input stream @p __is.
*
* @param __is An input stream.
* @param __x A %piecewise_linear_distribution random number
* generator engine.
*
* @returns The input stream with @p __x extracted or in an error
* state.
*/
template<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
std::piecewise_linear_distribution<_RealType1>& __x);
private:
template<typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
void
__generate_impl(_ForwardIterator __f, _ForwardIterator __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __p);
param_type _M_param;
};
/**
* @brief Return true if two piecewise linear distributions have
* different parameters.
*/
template<typename _RealType>
inline bool
operator!=(const std::piecewise_linear_distribution<_RealType>& __d1,
const std::piecewise_linear_distribution<_RealType>& __d2)
{ return !(__d1 == __d2); }
/* @} */ // group random_distributions_poisson
/* @} */ // group random_distributions
/**
* @addtogroup random_utilities Random Number Utilities
* @ingroup random
* @{
*/
/**
* @brief The seed_seq class generates sequences of seeds for random
* number generators.
*/
class seed_seq
{
public:
/** The type of the seed vales. */
typedef uint_least32_t result_type;
/** Default constructor. */
seed_seq() noexcept
: _M_v()
{ }
template<typename _IntType>
seed_seq(std::initializer_list<_IntType> __il);
template<typename _InputIterator>
seed_seq(_InputIterator __begin, _InputIterator __end);
// generating functions
template<typename _RandomAccessIterator>
void
generate(_RandomAccessIterator __begin, _RandomAccessIterator __end);
// property functions
size_t size() const noexcept
{ return _M_v.size(); }
template<typename _OutputIterator>
void
param(_OutputIterator __dest) const
{ std::copy(_M_v.begin(), _M_v.end(), __dest); }
// no copy functions
seed_seq(const seed_seq&) = delete;
seed_seq& operator=(const seed_seq&) = delete;
private:
std::vector<result_type> _M_v;
};
/* @} */ // group random_utilities
/* @} */ // group random
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif
c++/8/bits/stl_multiset.h 0000644 00000105741 15201526705 0011140 0 ustar 00 // Multiset implementation -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1996
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file bits/stl_multiset.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{set}
*/
#ifndef _STL_MULTISET_H
#define _STL_MULTISET_H 1
#include <bits/concept_check.h>
#if __cplusplus >= 201103L
#include <initializer_list>
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Key, typename _Compare, typename _Alloc>
class set;
/**
* @brief A standard container made up of elements, which can be retrieved
* in logarithmic time.
*
* @ingroup associative_containers
*
*
* @tparam _Key Type of key objects.
* @tparam _Compare Comparison function object type, defaults to less<_Key>.
* @tparam _Alloc Allocator type, defaults to allocator<_Key>.
*
* Meets the requirements of a <a href="tables.html#65">container</a>, a
* <a href="tables.html#66">reversible container</a>, and an
* <a href="tables.html#69">associative container</a> (using equivalent
* keys). For a @c multiset<Key> the key_type and value_type are Key.
*
* Multisets support bidirectional iterators.
*
* The private tree data is declared exactly the same way for set and
* multiset; the distinction is made entirely in how the tree functions are
* called (*_unique versus *_equal, same as the standard).
*/
template <typename _Key, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<_Key> >
class multiset
{
#ifdef _GLIBCXX_CONCEPT_CHECKS
// concept requirements
typedef typename _Alloc::value_type _Alloc_value_type;
# if __cplusplus < 201103L
__glibcxx_class_requires(_Key, _SGIAssignableConcept)
# endif
__glibcxx_class_requires4(_Compare, bool, _Key, _Key,
_BinaryFunctionConcept)
__glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept)
#endif
#if __cplusplus >= 201103L
static_assert(is_same<typename remove_cv<_Key>::type, _Key>::value,
"std::multiset must have a non-const, non-volatile value_type");
# ifdef __STRICT_ANSI__
static_assert(is_same<typename _Alloc::value_type, _Key>::value,
"std::multiset must have the same value_type as its allocator");
# endif
#endif
public:
// typedefs:
typedef _Key key_type;
typedef _Key value_type;
typedef _Compare key_compare;
typedef _Compare value_compare;
typedef _Alloc allocator_type;
private:
/// This turns a red-black tree into a [multi]set.
typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template
rebind<_Key>::other _Key_alloc_type;
typedef _Rb_tree<key_type, value_type, _Identity<value_type>,
key_compare, _Key_alloc_type> _Rep_type;
/// The actual tree structure.
_Rep_type _M_t;
typedef __gnu_cxx::__alloc_traits<_Key_alloc_type> _Alloc_traits;
public:
typedef typename _Alloc_traits::pointer pointer;
typedef typename _Alloc_traits::const_pointer const_pointer;
typedef typename _Alloc_traits::reference reference;
typedef typename _Alloc_traits::const_reference const_reference;
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 103. set::iterator is required to be modifiable,
// but this allows modification of keys.
typedef typename _Rep_type::const_iterator iterator;
typedef typename _Rep_type::const_iterator const_iterator;
typedef typename _Rep_type::const_reverse_iterator reverse_iterator;
typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
typedef typename _Rep_type::size_type size_type;
typedef typename _Rep_type::difference_type difference_type;
#if __cplusplus > 201402L
using node_type = typename _Rep_type::node_type;
#endif
// allocation/deallocation
/**
* @brief Default constructor creates no elements.
*/
#if __cplusplus < 201103L
multiset() : _M_t() { }
#else
multiset() = default;
#endif
/**
* @brief Creates a %multiset with no elements.
* @param __comp Comparator to use.
* @param __a An allocator object.
*/
explicit
multiset(const _Compare& __comp,
const allocator_type& __a = allocator_type())
: _M_t(__comp, _Key_alloc_type(__a)) { }
/**
* @brief Builds a %multiset from a range.
* @param __first An input iterator.
* @param __last An input iterator.
*
* Create a %multiset consisting of copies of the elements from
* [first,last). This is linear in N if the range is already sorted,
* and NlogN otherwise (where N is distance(__first,__last)).
*/
template<typename _InputIterator>
multiset(_InputIterator __first, _InputIterator __last)
: _M_t()
{ _M_t._M_insert_equal(__first, __last); }
/**
* @brief Builds a %multiset from a range.
* @param __first An input iterator.
* @param __last An input iterator.
* @param __comp A comparison functor.
* @param __a An allocator object.
*
* Create a %multiset consisting of copies of the elements from
* [__first,__last). This is linear in N if the range is already sorted,
* and NlogN otherwise (where N is distance(__first,__last)).
*/
template<typename _InputIterator>
multiset(_InputIterator __first, _InputIterator __last,
const _Compare& __comp,
const allocator_type& __a = allocator_type())
: _M_t(__comp, _Key_alloc_type(__a))
{ _M_t._M_insert_equal(__first, __last); }
/**
* @brief %Multiset copy constructor.
*
* Whether the allocator is copied depends on the allocator traits.
*/
#if __cplusplus < 201103L
multiset(const multiset& __x)
: _M_t(__x._M_t) { }
#else
multiset(const multiset&) = default;
/**
* @brief %Multiset move constructor.
*
* The newly-created %multiset contains the exact contents of the
* moved instance. The moved instance is a valid, but unspecified
* %multiset.
*/
multiset(multiset&&) = default;
/**
* @brief Builds a %multiset from an initializer_list.
* @param __l An initializer_list.
* @param __comp A comparison functor.
* @param __a An allocator object.
*
* Create a %multiset consisting of copies of the elements from
* the list. This is linear in N if the list is already sorted,
* and NlogN otherwise (where N is @a __l.size()).
*/
multiset(initializer_list<value_type> __l,
const _Compare& __comp = _Compare(),
const allocator_type& __a = allocator_type())
: _M_t(__comp, _Key_alloc_type(__a))
{ _M_t._M_insert_equal(__l.begin(), __l.end()); }
/// Allocator-extended default constructor.
explicit
multiset(const allocator_type& __a)
: _M_t(_Compare(), _Key_alloc_type(__a)) { }
/// Allocator-extended copy constructor.
multiset(const multiset& __m, const allocator_type& __a)
: _M_t(__m._M_t, _Key_alloc_type(__a)) { }
/// Allocator-extended move constructor.
multiset(multiset&& __m, const allocator_type& __a)
noexcept(is_nothrow_copy_constructible<_Compare>::value
&& _Alloc_traits::_S_always_equal())
: _M_t(std::move(__m._M_t), _Key_alloc_type(__a)) { }
/// Allocator-extended initialier-list constructor.
multiset(initializer_list<value_type> __l, const allocator_type& __a)
: _M_t(_Compare(), _Key_alloc_type(__a))
{ _M_t._M_insert_equal(__l.begin(), __l.end()); }
/// Allocator-extended range constructor.
template<typename _InputIterator>
multiset(_InputIterator __first, _InputIterator __last,
const allocator_type& __a)
: _M_t(_Compare(), _Key_alloc_type(__a))
{ _M_t._M_insert_equal(__first, __last); }
/**
* The dtor only erases the elements, and note that if the elements
* themselves are pointers, the pointed-to memory is not touched in any
* way. Managing the pointer is the user's responsibility.
*/
~multiset() = default;
#endif
/**
* @brief %Multiset assignment operator.
*
* Whether the allocator is copied depends on the allocator traits.
*/
#if __cplusplus < 201103L
multiset&
operator=(const multiset& __x)
{
_M_t = __x._M_t;
return *this;
}
#else
multiset&
operator=(const multiset&) = default;
/// Move assignment operator.
multiset&
operator=(multiset&&) = default;
/**
* @brief %Multiset list assignment operator.
* @param __l An initializer_list.
*
* This function fills a %multiset with copies of the elements in the
* initializer list @a __l.
*
* Note that the assignment completely changes the %multiset and
* that the resulting %multiset's size is the same as the number
* of elements assigned.
*/
multiset&
operator=(initializer_list<value_type> __l)
{
_M_t._M_assign_equal(__l.begin(), __l.end());
return *this;
}
#endif
// accessors:
/// Returns the comparison object.
key_compare
key_comp() const
{ return _M_t.key_comp(); }
/// Returns the comparison object.
value_compare
value_comp() const
{ return _M_t.key_comp(); }
/// Returns the memory allocation object.
allocator_type
get_allocator() const _GLIBCXX_NOEXCEPT
{ return allocator_type(_M_t.get_allocator()); }
/**
* Returns a read-only (constant) iterator that points to the first
* element in the %multiset. Iteration is done in ascending order
* according to the keys.
*/
iterator
begin() const _GLIBCXX_NOEXCEPT
{ return _M_t.begin(); }
/**
* Returns a read-only (constant) iterator that points one past the last
* element in the %multiset. Iteration is done in ascending order
* according to the keys.
*/
iterator
end() const _GLIBCXX_NOEXCEPT
{ return _M_t.end(); }
/**
* Returns a read-only (constant) reverse iterator that points to the
* last element in the %multiset. Iteration is done in descending order
* according to the keys.
*/
reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT
{ return _M_t.rbegin(); }
/**
* Returns a read-only (constant) reverse iterator that points to the
* last element in the %multiset. Iteration is done in descending order
* according to the keys.
*/
reverse_iterator
rend() const _GLIBCXX_NOEXCEPT
{ return _M_t.rend(); }
#if __cplusplus >= 201103L
/**
* Returns a read-only (constant) iterator that points to the first
* element in the %multiset. Iteration is done in ascending order
* according to the keys.
*/
iterator
cbegin() const noexcept
{ return _M_t.begin(); }
/**
* Returns a read-only (constant) iterator that points one past the last
* element in the %multiset. Iteration is done in ascending order
* according to the keys.
*/
iterator
cend() const noexcept
{ return _M_t.end(); }
/**
* Returns a read-only (constant) reverse iterator that points to the
* last element in the %multiset. Iteration is done in descending order
* according to the keys.
*/
reverse_iterator
crbegin() const noexcept
{ return _M_t.rbegin(); }
/**
* Returns a read-only (constant) reverse iterator that points to the
* last element in the %multiset. Iteration is done in descending order
* according to the keys.
*/
reverse_iterator
crend() const noexcept
{ return _M_t.rend(); }
#endif
/// Returns true if the %set is empty.
bool
empty() const _GLIBCXX_NOEXCEPT
{ return _M_t.empty(); }
/// Returns the size of the %set.
size_type
size() const _GLIBCXX_NOEXCEPT
{ return _M_t.size(); }
/// Returns the maximum size of the %set.
size_type
max_size() const _GLIBCXX_NOEXCEPT
{ return _M_t.max_size(); }
/**
* @brief Swaps data with another %multiset.
* @param __x A %multiset of the same element and allocator types.
*
* This exchanges the elements between two multisets in constant time.
* (It is only swapping a pointer, an integer, and an instance of the @c
* Compare type (which itself is often stateless and empty), so it should
* be quite fast.)
* Note that the global std::swap() function is specialized such that
* std::swap(s1,s2) will feed to this function.
*
* Whether the allocators are swapped depends on the allocator traits.
*/
void
swap(multiset& __x)
_GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value)
{ _M_t.swap(__x._M_t); }
// insert/erase
#if __cplusplus >= 201103L
/**
* @brief Builds and inserts an element into the %multiset.
* @param __args Arguments used to generate the element instance to be
* inserted.
* @return An iterator that points to the inserted element.
*
* This function inserts an element into the %multiset. Contrary
* to a std::set the %multiset does not rely on unique keys and thus
* multiple copies of the same element can be inserted.
*
* Insertion requires logarithmic time.
*/
template<typename... _Args>
iterator
emplace(_Args&&... __args)
{ return _M_t._M_emplace_equal(std::forward<_Args>(__args)...); }
/**
* @brief Builds and inserts an element into the %multiset.
* @param __pos An iterator that serves as a hint as to where the
* element should be inserted.
* @param __args Arguments used to generate the element instance to be
* inserted.
* @return An iterator that points to the inserted element.
*
* This function inserts an element into the %multiset. Contrary
* to a std::set the %multiset does not rely on unique keys and thus
* multiple copies of the same element can be inserted.
*
* Note that the first parameter is only a hint and can potentially
* improve the performance of the insertion process. A bad hint would
* cause no gains in efficiency.
*
* See https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints
* for more on @a hinting.
*
* Insertion requires logarithmic time (if the hint is not taken).
*/
template<typename... _Args>
iterator
emplace_hint(const_iterator __pos, _Args&&... __args)
{
return _M_t._M_emplace_hint_equal(__pos,
std::forward<_Args>(__args)...);
}
#endif
/**
* @brief Inserts an element into the %multiset.
* @param __x Element to be inserted.
* @return An iterator that points to the inserted element.
*
* This function inserts an element into the %multiset. Contrary
* to a std::set the %multiset does not rely on unique keys and thus
* multiple copies of the same element can be inserted.
*
* Insertion requires logarithmic time.
*/
iterator
insert(const value_type& __x)
{ return _M_t._M_insert_equal(__x); }
#if __cplusplus >= 201103L
iterator
insert(value_type&& __x)
{ return _M_t._M_insert_equal(std::move(__x)); }
#endif
/**
* @brief Inserts an element into the %multiset.
* @param __position An iterator that serves as a hint as to where the
* element should be inserted.
* @param __x Element to be inserted.
* @return An iterator that points to the inserted element.
*
* This function inserts an element into the %multiset. Contrary
* to a std::set the %multiset does not rely on unique keys and thus
* multiple copies of the same element can be inserted.
*
* Note that the first parameter is only a hint and can potentially
* improve the performance of the insertion process. A bad hint would
* cause no gains in efficiency.
*
* See https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints
* for more on @a hinting.
*
* Insertion requires logarithmic time (if the hint is not taken).
*/
iterator
insert(const_iterator __position, const value_type& __x)
{ return _M_t._M_insert_equal_(__position, __x); }
#if __cplusplus >= 201103L
iterator
insert(const_iterator __position, value_type&& __x)
{ return _M_t._M_insert_equal_(__position, std::move(__x)); }
#endif
/**
* @brief A template function that tries to insert a range of elements.
* @param __first Iterator pointing to the start of the range to be
* inserted.
* @param __last Iterator pointing to the end of the range.
*
* Complexity similar to that of the range constructor.
*/
template<typename _InputIterator>
void
insert(_InputIterator __first, _InputIterator __last)
{ _M_t._M_insert_equal(__first, __last); }
#if __cplusplus >= 201103L
/**
* @brief Attempts to insert a list of elements into the %multiset.
* @param __l A std::initializer_list<value_type> of elements
* to be inserted.
*
* Complexity similar to that of the range constructor.
*/
void
insert(initializer_list<value_type> __l)
{ this->insert(__l.begin(), __l.end()); }
#endif
#if __cplusplus > 201402L
/// Extract a node.
node_type
extract(const_iterator __pos)
{
__glibcxx_assert(__pos != end());
return _M_t.extract(__pos);
}
/// Extract a node.
node_type
extract(const key_type& __x)
{ return _M_t.extract(__x); }
/// Re-insert an extracted node.
iterator
insert(node_type&& __nh)
{ return _M_t._M_reinsert_node_equal(std::move(__nh)); }
/// Re-insert an extracted node.
iterator
insert(const_iterator __hint, node_type&& __nh)
{ return _M_t._M_reinsert_node_hint_equal(__hint, std::move(__nh)); }
template<typename, typename>
friend class std::_Rb_tree_merge_helper;
template<typename _Compare1>
void
merge(multiset<_Key, _Compare1, _Alloc>& __source)
{
using _Merge_helper = _Rb_tree_merge_helper<multiset, _Compare1>;
_M_t._M_merge_equal(_Merge_helper::_S_get_tree(__source));
}
template<typename _Compare1>
void
merge(multiset<_Key, _Compare1, _Alloc>&& __source)
{ merge(__source); }
template<typename _Compare1>
void
merge(set<_Key, _Compare1, _Alloc>& __source)
{
using _Merge_helper = _Rb_tree_merge_helper<multiset, _Compare1>;
_M_t._M_merge_equal(_Merge_helper::_S_get_tree(__source));
}
template<typename _Compare1>
void
merge(set<_Key, _Compare1, _Alloc>&& __source)
{ merge(__source); }
#endif // C++17
#if __cplusplus >= 201103L
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 130. Associative erase should return an iterator.
/**
* @brief Erases an element from a %multiset.
* @param __position An iterator pointing to the element to be erased.
* @return An iterator pointing to the element immediately following
* @a position prior to the element being erased. If no such
* element exists, end() is returned.
*
* This function erases an element, pointed to by the given iterator,
* from a %multiset. Note that this function only erases the element,
* and that if the element is itself a pointer, the pointed-to memory is
* not touched in any way. Managing the pointer is the user's
* responsibility.
*/
_GLIBCXX_ABI_TAG_CXX11
iterator
erase(const_iterator __position)
{ return _M_t.erase(__position); }
#else
/**
* @brief Erases an element from a %multiset.
* @param __position An iterator pointing to the element to be erased.
*
* This function erases an element, pointed to by the given iterator,
* from a %multiset. Note that this function only erases the element,
* and that if the element is itself a pointer, the pointed-to memory is
* not touched in any way. Managing the pointer is the user's
* responsibility.
*/
void
erase(iterator __position)
{ _M_t.erase(__position); }
#endif
/**
* @brief Erases elements according to the provided key.
* @param __x Key of element to be erased.
* @return The number of elements erased.
*
* This function erases all elements located by the given key from a
* %multiset.
* Note that this function only erases the element, and that if
* the element is itself a pointer, the pointed-to memory is not touched
* in any way. Managing the pointer is the user's responsibility.
*/
size_type
erase(const key_type& __x)
{ return _M_t.erase(__x); }
#if __cplusplus >= 201103L
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 130. Associative erase should return an iterator.
/**
* @brief Erases a [first,last) range of elements from a %multiset.
* @param __first Iterator pointing to the start of the range to be
* erased.
* @param __last Iterator pointing to the end of the range to
* be erased.
* @return The iterator @a last.
*
* This function erases a sequence of elements from a %multiset.
* Note that this function only erases the elements, and that if
* the elements themselves are pointers, the pointed-to memory is not
* touched in any way. Managing the pointer is the user's
* responsibility.
*/
_GLIBCXX_ABI_TAG_CXX11
iterator
erase(const_iterator __first, const_iterator __last)
{ return _M_t.erase(__first, __last); }
#else
/**
* @brief Erases a [first,last) range of elements from a %multiset.
* @param first Iterator pointing to the start of the range to be
* erased.
* @param last Iterator pointing to the end of the range to be erased.
*
* This function erases a sequence of elements from a %multiset.
* Note that this function only erases the elements, and that if
* the elements themselves are pointers, the pointed-to memory is not
* touched in any way. Managing the pointer is the user's
* responsibility.
*/
void
erase(iterator __first, iterator __last)
{ _M_t.erase(__first, __last); }
#endif
/**
* Erases all elements in a %multiset. Note that this function only
* erases the elements, and that if the elements themselves are pointers,
* the pointed-to memory is not touched in any way. Managing the pointer
* is the user's responsibility.
*/
void
clear() _GLIBCXX_NOEXCEPT
{ _M_t.clear(); }
// multiset operations:
//@{
/**
* @brief Finds the number of elements with given key.
* @param __x Key of elements to be located.
* @return Number of elements with specified key.
*/
size_type
count(const key_type& __x) const
{ return _M_t.count(__x); }
#if __cplusplus > 201103L
template<typename _Kt>
auto
count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x))
{ return _M_t._M_count_tr(__x); }
#endif
//@}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 214. set::find() missing const overload
//@{
/**
* @brief Tries to locate an element in a %set.
* @param __x Element to be located.
* @return Iterator pointing to sought-after element, or end() if not
* found.
*
* This function takes a key and tries to locate the element with which
* the key matches. If successful the function returns an iterator
* pointing to the sought after element. If unsuccessful it returns the
* past-the-end ( @c end() ) iterator.
*/
iterator
find(const key_type& __x)
{ return _M_t.find(__x); }
const_iterator
find(const key_type& __x) const
{ return _M_t.find(__x); }
#if __cplusplus > 201103L
template<typename _Kt>
auto
find(const _Kt& __x)
-> decltype(iterator{_M_t._M_find_tr(__x)})
{ return iterator{_M_t._M_find_tr(__x)}; }
template<typename _Kt>
auto
find(const _Kt& __x) const
-> decltype(const_iterator{_M_t._M_find_tr(__x)})
{ return const_iterator{_M_t._M_find_tr(__x)}; }
#endif
//@}
//@{
/**
* @brief Finds the beginning of a subsequence matching given key.
* @param __x Key to be located.
* @return Iterator pointing to first element equal to or greater
* than key, or end().
*
* This function returns the first element of a subsequence of elements
* that matches the given key. If unsuccessful it returns an iterator
* pointing to the first element that has a greater value than given key
* or end() if no such element exists.
*/
iterator
lower_bound(const key_type& __x)
{ return _M_t.lower_bound(__x); }
const_iterator
lower_bound(const key_type& __x) const
{ return _M_t.lower_bound(__x); }
#if __cplusplus > 201103L
template<typename _Kt>
auto
lower_bound(const _Kt& __x)
-> decltype(iterator(_M_t._M_lower_bound_tr(__x)))
{ return iterator(_M_t._M_lower_bound_tr(__x)); }
template<typename _Kt>
auto
lower_bound(const _Kt& __x) const
-> decltype(iterator(_M_t._M_lower_bound_tr(__x)))
{ return iterator(_M_t._M_lower_bound_tr(__x)); }
#endif
//@}
//@{
/**
* @brief Finds the end of a subsequence matching given key.
* @param __x Key to be located.
* @return Iterator pointing to the first element
* greater than key, or end().
*/
iterator
upper_bound(const key_type& __x)
{ return _M_t.upper_bound(__x); }
const_iterator
upper_bound(const key_type& __x) const
{ return _M_t.upper_bound(__x); }
#if __cplusplus > 201103L
template<typename _Kt>
auto
upper_bound(const _Kt& __x)
-> decltype(iterator(_M_t._M_upper_bound_tr(__x)))
{ return iterator(_M_t._M_upper_bound_tr(__x)); }
template<typename _Kt>
auto
upper_bound(const _Kt& __x) const
-> decltype(iterator(_M_t._M_upper_bound_tr(__x)))
{ return iterator(_M_t._M_upper_bound_tr(__x)); }
#endif
//@}
//@{
/**
* @brief Finds a subsequence matching given key.
* @param __x Key to be located.
* @return Pair of iterators that possibly points to the subsequence
* matching given key.
*
* This function is equivalent to
* @code
* std::make_pair(c.lower_bound(val),
* c.upper_bound(val))
* @endcode
* (but is faster than making the calls separately).
*
* This function probably only makes sense for multisets.
*/
std::pair<iterator, iterator>
equal_range(const key_type& __x)
{ return _M_t.equal_range(__x); }
std::pair<const_iterator, const_iterator>
equal_range(const key_type& __x) const
{ return _M_t.equal_range(__x); }
#if __cplusplus > 201103L
template<typename _Kt>
auto
equal_range(const _Kt& __x)
-> decltype(pair<iterator, iterator>(_M_t._M_equal_range_tr(__x)))
{ return pair<iterator, iterator>(_M_t._M_equal_range_tr(__x)); }
template<typename _Kt>
auto
equal_range(const _Kt& __x) const
-> decltype(pair<iterator, iterator>(_M_t._M_equal_range_tr(__x)))
{ return pair<iterator, iterator>(_M_t._M_equal_range_tr(__x)); }
#endif
//@}
template<typename _K1, typename _C1, typename _A1>
friend bool
operator==(const multiset<_K1, _C1, _A1>&,
const multiset<_K1, _C1, _A1>&);
template<typename _K1, typename _C1, typename _A1>
friend bool
operator< (const multiset<_K1, _C1, _A1>&,
const multiset<_K1, _C1, _A1>&);
};
#if __cpp_deduction_guides >= 201606
template<typename _InputIterator,
typename _Compare =
less<typename iterator_traits<_InputIterator>::value_type>,
typename _Allocator =
allocator<typename iterator_traits<_InputIterator>::value_type>,
typename = _RequireInputIter<_InputIterator>,
typename = _RequireAllocator<_Allocator>>
multiset(_InputIterator, _InputIterator,
_Compare = _Compare(), _Allocator = _Allocator())
-> multiset<typename iterator_traits<_InputIterator>::value_type,
_Compare, _Allocator>;
template<typename _Key,
typename _Compare = less<_Key>,
typename _Allocator = allocator<_Key>,
typename = _RequireAllocator<_Allocator>>
multiset(initializer_list<_Key>,
_Compare = _Compare(), _Allocator = _Allocator())
-> multiset<_Key, _Compare, _Allocator>;
template<typename _InputIterator, typename _Allocator,
typename = _RequireInputIter<_InputIterator>,
typename = _RequireAllocator<_Allocator>>
multiset(_InputIterator, _InputIterator, _Allocator)
-> multiset<typename iterator_traits<_InputIterator>::value_type,
less<typename iterator_traits<_InputIterator>::value_type>,
_Allocator>;
template<typename _Key, typename _Allocator,
typename = _RequireAllocator<_Allocator>>
multiset(initializer_list<_Key>, _Allocator)
-> multiset<_Key, less<_Key>, _Allocator>;
#endif
/**
* @brief Multiset equality comparison.
* @param __x A %multiset.
* @param __y A %multiset of the same type as @a __x.
* @return True iff the size and elements of the multisets are equal.
*
* This is an equivalence relation. It is linear in the size of the
* multisets.
* Multisets are considered equivalent if their sizes are equal, and if
* corresponding elements compare equal.
*/
template<typename _Key, typename _Compare, typename _Alloc>
inline bool
operator==(const multiset<_Key, _Compare, _Alloc>& __x,
const multiset<_Key, _Compare, _Alloc>& __y)
{ return __x._M_t == __y._M_t; }
/**
* @brief Multiset ordering relation.
* @param __x A %multiset.
* @param __y A %multiset of the same type as @a __x.
* @return True iff @a __x is lexicographically less than @a __y.
*
* This is a total ordering relation. It is linear in the size of the
* sets. The elements must be comparable with @c <.
*
* See std::lexicographical_compare() for how the determination is made.
*/
template<typename _Key, typename _Compare, typename _Alloc>
inline bool
operator<(const multiset<_Key, _Compare, _Alloc>& __x,
const multiset<_Key, _Compare, _Alloc>& __y)
{ return __x._M_t < __y._M_t; }
/// Returns !(x == y).
template<typename _Key, typename _Compare, typename _Alloc>
inline bool
operator!=(const multiset<_Key, _Compare, _Alloc>& __x,
const multiset<_Key, _Compare, _Alloc>& __y)
{ return !(__x == __y); }
/// Returns y < x.
template<typename _Key, typename _Compare, typename _Alloc>
inline bool
operator>(const multiset<_Key,_Compare,_Alloc>& __x,
const multiset<_Key,_Compare,_Alloc>& __y)
{ return __y < __x; }
/// Returns !(y < x)
template<typename _Key, typename _Compare, typename _Alloc>
inline bool
operator<=(const multiset<_Key, _Compare, _Alloc>& __x,
const multiset<_Key, _Compare, _Alloc>& __y)
{ return !(__y < __x); }
/// Returns !(x < y)
template<typename _Key, typename _Compare, typename _Alloc>
inline bool
operator>=(const multiset<_Key, _Compare, _Alloc>& __x,
const multiset<_Key, _Compare, _Alloc>& __y)
{ return !(__x < __y); }
/// See std::multiset::swap().
template<typename _Key, typename _Compare, typename _Alloc>
inline void
swap(multiset<_Key, _Compare, _Alloc>& __x,
multiset<_Key, _Compare, _Alloc>& __y)
_GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
{ __x.swap(__y); }
_GLIBCXX_END_NAMESPACE_CONTAINER
#if __cplusplus > 201402L
// Allow std::multiset access to internals of compatible sets.
template<typename _Val, typename _Cmp1, typename _Alloc, typename _Cmp2>
struct
_Rb_tree_merge_helper<_GLIBCXX_STD_C::multiset<_Val, _Cmp1, _Alloc>,
_Cmp2>
{
private:
friend class _GLIBCXX_STD_C::multiset<_Val, _Cmp1, _Alloc>;
static auto&
_S_get_tree(_GLIBCXX_STD_C::set<_Val, _Cmp2, _Alloc>& __set)
{ return __set._M_t; }
static auto&
_S_get_tree(_GLIBCXX_STD_C::multiset<_Val, _Cmp2, _Alloc>& __set)
{ return __set._M_t; }
};
#endif // C++17
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif /* _STL_MULTISET_H */
c++/8/bits/std_abs.h 0000644 00000006302 15201526705 0010020 0 ustar 00 // -*- C++ -*- C library enhancements header.
// Copyright (C) 2016-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/bits/std_abs.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{cmath, cstdlib}
*/
#ifndef _GLIBCXX_BITS_STD_ABS_H
#define _GLIBCXX_BITS_STD_ABS_H
#pragma GCC system_header
#include <bits/c++config.h>
#define _GLIBCXX_INCLUDE_NEXT_C_HEADERS
#include_next <stdlib.h>
#ifdef __CORRECT_ISO_CPP_MATH_H_PROTO
# include_next <math.h>
#endif
#undef _GLIBCXX_INCLUDE_NEXT_C_HEADERS
#undef abs
extern "C++"
{
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using ::abs;
#ifndef __CORRECT_ISO_CPP_STDLIB_H_PROTO
inline long
abs(long __i) { return __builtin_labs(__i); }
#endif
#ifdef _GLIBCXX_USE_LONG_LONG
inline long long
abs(long long __x) { return __builtin_llabs (__x); }
#endif
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2192. Validity and return type of std::abs(0u) is unclear
// 2294. <cstdlib> should declare abs(double)
#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
inline _GLIBCXX_CONSTEXPR double
abs(double __x)
{ return __builtin_fabs(__x); }
inline _GLIBCXX_CONSTEXPR float
abs(float __x)
{ return __builtin_fabsf(__x); }
inline _GLIBCXX_CONSTEXPR long double
abs(long double __x)
{ return __builtin_fabsl(__x); }
#endif
#if defined(__GLIBCXX_TYPE_INT_N_0)
inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_0
abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
#endif
#if defined(__GLIBCXX_TYPE_INT_N_1)
inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_1
abs(__GLIBCXX_TYPE_INT_N_1 __x) { return __x >= 0 ? __x : -__x; }
#endif
#if defined(__GLIBCXX_TYPE_INT_N_2)
inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_2
abs(__GLIBCXX_TYPE_INT_N_2 __x) { return __x >= 0 ? __x : -__x; }
#endif
#if defined(__GLIBCXX_TYPE_INT_N_3)
inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_3
abs(__GLIBCXX_TYPE_INT_N_3 __x) { return __x >= 0 ? __x : -__x; }
#endif
#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128)
inline _GLIBCXX_CONSTEXPR
__float128
abs(__float128 __x)
{ return __x < 0 ? -__x : __x; }
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
}
#endif // _GLIBCXX_BITS_STD_ABS_H
c++/8/bits/shared_ptr_atomic.h 0000644 00000023051 15201526705 0012070 0 ustar 00 // shared_ptr atomic access -*- C++ -*-
// Copyright (C) 2014-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/shared_ptr_atomic.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{memory}
*/
#ifndef _SHARED_PTR_ATOMIC_H
#define _SHARED_PTR_ATOMIC_H 1
#include <bits/atomic_base.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @addtogroup pointer_abstractions
* @{
*/
struct _Sp_locker
{
_Sp_locker(const _Sp_locker&) = delete;
_Sp_locker& operator=(const _Sp_locker&) = delete;
#ifdef __GTHREADS
explicit
_Sp_locker(const void*) noexcept;
_Sp_locker(const void*, const void*) noexcept;
~_Sp_locker();
private:
unsigned char _M_key1;
unsigned char _M_key2;
#else
explicit _Sp_locker(const void*, const void* = nullptr) { }
#endif
};
/**
* @brief Report whether shared_ptr atomic operations are lock-free.
* @param __p A non-null pointer to a shared_ptr object.
* @return True if atomic access to @c *__p is lock-free, false otherwise.
* @{
*/
template<typename _Tp, _Lock_policy _Lp>
inline bool
atomic_is_lock_free(const __shared_ptr<_Tp, _Lp>* __p)
{
#ifdef __GTHREADS
return __gthread_active_p() == 0;
#else
return true;
#endif
}
template<typename _Tp>
inline bool
atomic_is_lock_free(const shared_ptr<_Tp>* __p)
{ return std::atomic_is_lock_free<_Tp, __default_lock_policy>(__p); }
// @}
/**
* @brief Atomic load for shared_ptr objects.
* @param __p A non-null pointer to a shared_ptr object.
* @return @c *__p
*
* The memory order shall not be @c memory_order_release or
* @c memory_order_acq_rel.
* @{
*/
template<typename _Tp>
inline shared_ptr<_Tp>
atomic_load_explicit(const shared_ptr<_Tp>* __p, memory_order)
{
_Sp_locker __lock{__p};
return *__p;
}
template<typename _Tp>
inline shared_ptr<_Tp>
atomic_load(const shared_ptr<_Tp>* __p)
{ return std::atomic_load_explicit(__p, memory_order_seq_cst); }
template<typename _Tp, _Lock_policy _Lp>
inline __shared_ptr<_Tp, _Lp>
atomic_load_explicit(const __shared_ptr<_Tp, _Lp>* __p, memory_order)
{
_Sp_locker __lock{__p};
return *__p;
}
template<typename _Tp, _Lock_policy _Lp>
inline __shared_ptr<_Tp, _Lp>
atomic_load(const __shared_ptr<_Tp, _Lp>* __p)
{ return std::atomic_load_explicit(__p, memory_order_seq_cst); }
// @}
/**
* @brief Atomic store for shared_ptr objects.
* @param __p A non-null pointer to a shared_ptr object.
* @param __r The value to store.
*
* The memory order shall not be @c memory_order_acquire or
* @c memory_order_acq_rel.
* @{
*/
template<typename _Tp>
inline void
atomic_store_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r,
memory_order)
{
_Sp_locker __lock{__p};
__p->swap(__r); // use swap so that **__p not destroyed while lock held
}
template<typename _Tp>
inline void
atomic_store(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r)
{ std::atomic_store_explicit(__p, std::move(__r), memory_order_seq_cst); }
template<typename _Tp, _Lock_policy _Lp>
inline void
atomic_store_explicit(__shared_ptr<_Tp, _Lp>* __p,
__shared_ptr<_Tp, _Lp> __r,
memory_order)
{
_Sp_locker __lock{__p};
__p->swap(__r); // use swap so that **__p not destroyed while lock held
}
template<typename _Tp, _Lock_policy _Lp>
inline void
atomic_store(__shared_ptr<_Tp, _Lp>* __p, __shared_ptr<_Tp, _Lp> __r)
{ std::atomic_store_explicit(__p, std::move(__r), memory_order_seq_cst); }
// @}
/**
* @brief Atomic exchange for shared_ptr objects.
* @param __p A non-null pointer to a shared_ptr object.
* @param __r New value to store in @c *__p.
* @return The original value of @c *__p
* @{
*/
template<typename _Tp>
inline shared_ptr<_Tp>
atomic_exchange_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r,
memory_order)
{
_Sp_locker __lock{__p};
__p->swap(__r);
return __r;
}
template<typename _Tp>
inline shared_ptr<_Tp>
atomic_exchange(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r)
{
return std::atomic_exchange_explicit(__p, std::move(__r),
memory_order_seq_cst);
}
template<typename _Tp, _Lock_policy _Lp>
inline __shared_ptr<_Tp, _Lp>
atomic_exchange_explicit(__shared_ptr<_Tp, _Lp>* __p,
__shared_ptr<_Tp, _Lp> __r,
memory_order)
{
_Sp_locker __lock{__p};
__p->swap(__r);
return __r;
}
template<typename _Tp, _Lock_policy _Lp>
inline __shared_ptr<_Tp, _Lp>
atomic_exchange(__shared_ptr<_Tp, _Lp>* __p, __shared_ptr<_Tp, _Lp> __r)
{
return std::atomic_exchange_explicit(__p, std::move(__r),
memory_order_seq_cst);
}
// @}
/**
* @brief Atomic compare-and-swap for shared_ptr objects.
* @param __p A non-null pointer to a shared_ptr object.
* @param __v A non-null pointer to a shared_ptr object.
* @param __w A non-null pointer to a shared_ptr object.
* @return True if @c *__p was equivalent to @c *__v, false otherwise.
*
* The memory order for failure shall not be @c memory_order_release or
* @c memory_order_acq_rel, or stronger than the memory order for success.
* @{
*/
template<typename _Tp>
bool
atomic_compare_exchange_strong_explicit(shared_ptr<_Tp>* __p,
shared_ptr<_Tp>* __v,
shared_ptr<_Tp> __w,
memory_order,
memory_order)
{
shared_ptr<_Tp> __x; // goes out of scope after __lock
_Sp_locker __lock{__p, __v};
owner_less<shared_ptr<_Tp>> __less;
if (*__p == *__v && !__less(*__p, *__v) && !__less(*__v, *__p))
{
__x = std::move(*__p);
*__p = std::move(__w);
return true;
}
__x = std::move(*__v);
*__v = *__p;
return false;
}
template<typename _Tp>
inline bool
atomic_compare_exchange_strong(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v,
shared_ptr<_Tp> __w)
{
return std::atomic_compare_exchange_strong_explicit(__p, __v,
std::move(__w), memory_order_seq_cst, memory_order_seq_cst);
}
template<typename _Tp>
inline bool
atomic_compare_exchange_weak_explicit(shared_ptr<_Tp>* __p,
shared_ptr<_Tp>* __v,
shared_ptr<_Tp> __w,
memory_order __success,
memory_order __failure)
{
return std::atomic_compare_exchange_strong_explicit(__p, __v,
std::move(__w), __success, __failure);
}
template<typename _Tp>
inline bool
atomic_compare_exchange_weak(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v,
shared_ptr<_Tp> __w)
{
return std::atomic_compare_exchange_weak_explicit(__p, __v,
std::move(__w), memory_order_seq_cst, memory_order_seq_cst);
}
template<typename _Tp, _Lock_policy _Lp>
bool
atomic_compare_exchange_strong_explicit(__shared_ptr<_Tp, _Lp>* __p,
__shared_ptr<_Tp, _Lp>* __v,
__shared_ptr<_Tp, _Lp> __w,
memory_order,
memory_order)
{
__shared_ptr<_Tp, _Lp> __x; // goes out of scope after __lock
_Sp_locker __lock{__p, __v};
owner_less<__shared_ptr<_Tp, _Lp>> __less;
if (*__p == *__v && !__less(*__p, *__v) && !__less(*__v, *__p))
{
__x = std::move(*__p);
*__p = std::move(__w);
return true;
}
__x = std::move(*__v);
*__v = *__p;
return false;
}
template<typename _Tp, _Lock_policy _Lp>
inline bool
atomic_compare_exchange_strong(__shared_ptr<_Tp, _Lp>* __p,
__shared_ptr<_Tp, _Lp>* __v,
__shared_ptr<_Tp, _Lp> __w)
{
return std::atomic_compare_exchange_strong_explicit(__p, __v,
std::move(__w), memory_order_seq_cst, memory_order_seq_cst);
}
template<typename _Tp, _Lock_policy _Lp>
inline bool
atomic_compare_exchange_weak_explicit(__shared_ptr<_Tp, _Lp>* __p,
__shared_ptr<_Tp, _Lp>* __v,
__shared_ptr<_Tp, _Lp> __w,
memory_order __success,
memory_order __failure)
{
return std::atomic_compare_exchange_strong_explicit(__p, __v,
std::move(__w), __success, __failure);
}
template<typename _Tp, _Lock_policy _Lp>
inline bool
atomic_compare_exchange_weak(__shared_ptr<_Tp, _Lp>* __p,
__shared_ptr<_Tp, _Lp>* __v,
__shared_ptr<_Tp, _Lp> __w)
{
return std::atomic_compare_exchange_weak_explicit(__p, __v,
std::move(__w), memory_order_seq_cst, memory_order_seq_cst);
}
// @}
// @} group pointer_abstractions
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif // _SHARED_PTR_ATOMIC_H
c++/8/bits/slice_array.h 0000644 00000022204 15201526705 0010675 0 ustar 00 // The template and inlines for the -*- C++ -*- slice_array class.
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/slice_array.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{valarray}
*/
// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
#ifndef _SLICE_ARRAY_H
#define _SLICE_ARRAY_H 1
#pragma GCC system_header
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @addtogroup numeric_arrays
* @{
*/
/**
* @brief Class defining one-dimensional subset of an array.
*
* The slice class represents a one-dimensional subset of an array,
* specified by three parameters: start offset, size, and stride. The
* start offset is the index of the first element of the array that is part
* of the subset. The size is the total number of elements in the subset.
* Stride is the distance between each successive array element to include
* in the subset.
*
* For example, with an array of size 10, and a slice with offset 1, size 3
* and stride 2, the subset consists of array elements 1, 3, and 5.
*/
class slice
{
public:
/// Construct an empty slice.
slice();
/**
* @brief Construct a slice.
*
* @param __o Offset in array of first element.
* @param __d Number of elements in slice.
* @param __s Stride between array elements.
*/
slice(size_t __o, size_t __d, size_t __s);
/// Return array offset of first slice element.
size_t start() const;
/// Return size of slice.
size_t size() const;
/// Return array stride of slice.
size_t stride() const;
private:
size_t _M_off; // offset
size_t _M_sz; // size
size_t _M_st; // stride unit
};
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 543. valarray slice default constructor
inline
slice::slice()
: _M_off(0), _M_sz(0), _M_st(0) {}
inline
slice::slice(size_t __o, size_t __d, size_t __s)
: _M_off(__o), _M_sz(__d), _M_st(__s) {}
inline size_t
slice::start() const
{ return _M_off; }
inline size_t
slice::size() const
{ return _M_sz; }
inline size_t
slice::stride() const
{ return _M_st; }
/**
* @brief Reference to one-dimensional subset of an array.
*
* A slice_array is a reference to the actual elements of an array
* specified by a slice. The way to get a slice_array is to call
* operator[](slice) on a valarray. The returned slice_array then permits
* carrying operations out on the referenced subset of elements in the
* original valarray. For example, operator+=(valarray) will add values
* to the subset of elements in the underlying valarray this slice_array
* refers to.
*
* @param Tp Element type.
*/
template<typename _Tp>
class slice_array
{
public:
typedef _Tp value_type;
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 253. valarray helper functions are almost entirely useless
/// Copy constructor. Both slices refer to the same underlying array.
slice_array(const slice_array&);
/// Assignment operator. Assigns slice elements to corresponding
/// elements of @a a.
slice_array& operator=(const slice_array&);
/// Assign slice elements to corresponding elements of @a v.
void operator=(const valarray<_Tp>&) const;
/// Multiply slice elements by corresponding elements of @a v.
void operator*=(const valarray<_Tp>&) const;
/// Divide slice elements by corresponding elements of @a v.
void operator/=(const valarray<_Tp>&) const;
/// Modulo slice elements by corresponding elements of @a v.
void operator%=(const valarray<_Tp>&) const;
/// Add corresponding elements of @a v to slice elements.
void operator+=(const valarray<_Tp>&) const;
/// Subtract corresponding elements of @a v from slice elements.
void operator-=(const valarray<_Tp>&) const;
/// Logical xor slice elements with corresponding elements of @a v.
void operator^=(const valarray<_Tp>&) const;
/// Logical and slice elements with corresponding elements of @a v.
void operator&=(const valarray<_Tp>&) const;
/// Logical or slice elements with corresponding elements of @a v.
void operator|=(const valarray<_Tp>&) const;
/// Left shift slice elements by corresponding elements of @a v.
void operator<<=(const valarray<_Tp>&) const;
/// Right shift slice elements by corresponding elements of @a v.
void operator>>=(const valarray<_Tp>&) const;
/// Assign all slice elements to @a t.
void operator=(const _Tp &) const;
// ~slice_array ();
template<class _Dom>
void operator=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom>
void operator*=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom>
void operator/=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom>
void operator%=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom>
void operator+=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom>
void operator-=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom>
void operator^=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom>
void operator&=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom>
void operator|=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom>
void operator<<=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom>
void operator>>=(const _Expr<_Dom, _Tp>&) const;
private:
friend class valarray<_Tp>;
slice_array(_Array<_Tp>, const slice&);
const size_t _M_sz;
const size_t _M_stride;
const _Array<_Tp> _M_array;
// not implemented
slice_array();
};
template<typename _Tp>
inline
slice_array<_Tp>::slice_array(_Array<_Tp> __a, const slice& __s)
: _M_sz(__s.size()), _M_stride(__s.stride()),
_M_array(__a.begin() + __s.start()) {}
template<typename _Tp>
inline
slice_array<_Tp>::slice_array(const slice_array<_Tp>& __a)
: _M_sz(__a._M_sz), _M_stride(__a._M_stride), _M_array(__a._M_array) {}
// template<typename _Tp>
// inline slice_array<_Tp>::~slice_array () {}
template<typename _Tp>
inline slice_array<_Tp>&
slice_array<_Tp>::operator=(const slice_array<_Tp>& __a)
{
std::__valarray_copy(__a._M_array, __a._M_sz, __a._M_stride,
_M_array, _M_stride);
return *this;
}
template<typename _Tp>
inline void
slice_array<_Tp>::operator=(const _Tp& __t) const
{ std::__valarray_fill(_M_array, _M_sz, _M_stride, __t); }
template<typename _Tp>
inline void
slice_array<_Tp>::operator=(const valarray<_Tp>& __v) const
{ std::__valarray_copy(_Array<_Tp>(__v), _M_array, _M_sz, _M_stride); }
template<typename _Tp>
template<class _Dom>
inline void
slice_array<_Tp>::operator=(const _Expr<_Dom,_Tp>& __e) const
{ std::__valarray_copy(__e, _M_sz, _M_array, _M_stride); }
#undef _DEFINE_VALARRAY_OPERATOR
#define _DEFINE_VALARRAY_OPERATOR(_Op,_Name) \
template<typename _Tp> \
inline void \
slice_array<_Tp>::operator _Op##=(const valarray<_Tp>& __v) const \
{ \
_Array_augmented_##_Name(_M_array, _M_sz, _M_stride, _Array<_Tp>(__v));\
} \
\
template<typename _Tp> \
template<class _Dom> \
inline void \
slice_array<_Tp>::operator _Op##=(const _Expr<_Dom,_Tp>& __e) const\
{ \
_Array_augmented_##_Name(_M_array, _M_stride, __e, _M_sz); \
}
_DEFINE_VALARRAY_OPERATOR(*, __multiplies)
_DEFINE_VALARRAY_OPERATOR(/, __divides)
_DEFINE_VALARRAY_OPERATOR(%, __modulus)
_DEFINE_VALARRAY_OPERATOR(+, __plus)
_DEFINE_VALARRAY_OPERATOR(-, __minus)
_DEFINE_VALARRAY_OPERATOR(^, __bitwise_xor)
_DEFINE_VALARRAY_OPERATOR(&, __bitwise_and)
_DEFINE_VALARRAY_OPERATOR(|, __bitwise_or)
_DEFINE_VALARRAY_OPERATOR(<<, __shift_left)
_DEFINE_VALARRAY_OPERATOR(>>, __shift_right)
#undef _DEFINE_VALARRAY_OPERATOR
// @} group numeric_arrays
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif /* _SLICE_ARRAY_H */
c++/8/bits/fs_path.h 0000644 00000100176 15201526705 0010031 0 ustar 00 // Class filesystem::path -*- C++ -*-
// Copyright (C) 2014-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/bits/fs_path.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{filesystem}
*/
#ifndef _GLIBCXX_FS_PATH_H
#define _GLIBCXX_FS_PATH_H 1
#if __cplusplus >= 201703L
#include <utility>
#include <type_traits>
#include <vector>
#include <locale>
#include <iosfwd>
#include <codecvt>
#include <string_view>
#include <system_error>
#include <bits/stl_algobase.h>
#include <bits/quoted_string.h>
#include <bits/locale_conv.h>
#if defined(_WIN32) && !defined(__CYGWIN__)
# define _GLIBCXX_FILESYSTEM_IS_WINDOWS 1
# include <algorithm>
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
namespace filesystem
{
_GLIBCXX_BEGIN_NAMESPACE_CXX11
/**
* @ingroup filesystem
* @{
*/
/// A filesystem path.
class path
{
template<typename _CharT>
struct __is_encoded_char : std::false_type { };
template<typename _Iter,
typename _Iter_traits = std::iterator_traits<_Iter>>
using __is_path_iter_src
= __and_<__is_encoded_char<typename _Iter_traits::value_type>,
std::is_base_of<std::input_iterator_tag,
typename _Iter_traits::iterator_category>>;
template<typename _Iter>
static __is_path_iter_src<_Iter>
__is_path_src(_Iter, int);
template<typename _CharT, typename _Traits, typename _Alloc>
static __is_encoded_char<_CharT>
__is_path_src(const basic_string<_CharT, _Traits, _Alloc>&, int);
template<typename _CharT, typename _Traits>
static __is_encoded_char<_CharT>
__is_path_src(const basic_string_view<_CharT, _Traits>&, int);
template<typename _Unknown>
static std::false_type
__is_path_src(const _Unknown&, ...);
template<typename _Tp1, typename _Tp2>
struct __constructible_from;
template<typename _Iter>
struct __constructible_from<_Iter, _Iter>
: __is_path_iter_src<_Iter>
{ };
template<typename _Source>
struct __constructible_from<_Source, void>
: decltype(__is_path_src(std::declval<_Source>(), 0))
{ };
template<typename _Tp1, typename _Tp2 = void>
using _Path = typename
std::enable_if<__and_<__not_<is_same<remove_cv_t<_Tp1>, path>>,
__not_<is_void<remove_pointer_t<_Tp1>>>,
__constructible_from<_Tp1, _Tp2>>::value,
path>::type;
template<typename _Source>
static _Source
_S_range_begin(_Source __begin) { return __begin; }
struct __null_terminated { };
template<typename _Source>
static __null_terminated
_S_range_end(_Source) { return {}; }
template<typename _CharT, typename _Traits, typename _Alloc>
static const _CharT*
_S_range_begin(const basic_string<_CharT, _Traits, _Alloc>& __str)
{ return __str.data(); }
template<typename _CharT, typename _Traits, typename _Alloc>
static const _CharT*
_S_range_end(const basic_string<_CharT, _Traits, _Alloc>& __str)
{ return __str.data() + __str.size(); }
template<typename _CharT, typename _Traits>
static const _CharT*
_S_range_begin(const basic_string_view<_CharT, _Traits>& __str)
{ return __str.data(); }
template<typename _CharT, typename _Traits>
static const _CharT*
_S_range_end(const basic_string_view<_CharT, _Traits>& __str)
{ return __str.data() + __str.size(); }
template<typename _Tp,
typename _Iter = decltype(_S_range_begin(std::declval<_Tp>())),
typename _Val = typename std::iterator_traits<_Iter>::value_type>
using __value_type_is_char
= typename std::enable_if<std::is_same<_Val, char>::value>::type;
public:
#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
typedef wchar_t value_type;
static constexpr value_type preferred_separator = L'\\';
#else
typedef char value_type;
static constexpr value_type preferred_separator = '/';
#endif
typedef std::basic_string<value_type> string_type;
enum format { native_format, generic_format, auto_format };
// constructors and destructor
path() noexcept { }
path(const path& __p) = default;
path(path&& __p) noexcept
: _M_pathname(std::move(__p._M_pathname)), _M_type(__p._M_type)
{
if (_M_type == _Type::_Multi)
_M_split_cmpts();
__p.clear();
}
path(string_type&& __source, format = auto_format)
: _M_pathname(std::move(__source))
{ _M_split_cmpts(); }
template<typename _Source,
typename _Require = _Path<_Source>>
path(_Source const& __source, format = auto_format)
: _M_pathname(_S_convert(_S_range_begin(__source),
_S_range_end(__source)))
{ _M_split_cmpts(); }
template<typename _InputIterator,
typename _Require = _Path<_InputIterator, _InputIterator>>
path(_InputIterator __first, _InputIterator __last, format = auto_format)
: _M_pathname(_S_convert(__first, __last))
{ _M_split_cmpts(); }
template<typename _Source,
typename _Require = _Path<_Source>,
typename _Require2 = __value_type_is_char<_Source>>
path(_Source const& __source, const locale& __loc, format = auto_format)
: _M_pathname(_S_convert_loc(_S_range_begin(__source),
_S_range_end(__source), __loc))
{ _M_split_cmpts(); }
template<typename _InputIterator,
typename _Require = _Path<_InputIterator, _InputIterator>,
typename _Require2 = __value_type_is_char<_InputIterator>>
path(_InputIterator __first, _InputIterator __last, const locale& __loc,
format = auto_format)
: _M_pathname(_S_convert_loc(__first, __last, __loc))
{ _M_split_cmpts(); }
~path() = default;
// assignments
path& operator=(const path& __p) = default;
path& operator=(path&& __p) noexcept;
path& operator=(string_type&& __source);
path& assign(string_type&& __source);
template<typename _Source>
_Path<_Source>&
operator=(_Source const& __source)
{ return *this = path(__source); }
template<typename _Source>
_Path<_Source>&
assign(_Source const& __source)
{ return *this = path(__source); }
template<typename _InputIterator>
_Path<_InputIterator, _InputIterator>&
assign(_InputIterator __first, _InputIterator __last)
{ return *this = path(__first, __last); }
// appends
path& operator/=(const path& __p)
{
#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
if (__p.is_absolute()
|| (__p.has_root_name() && __p.root_name() != root_name()))
operator=(__p);
else
{
string_type __pathname;
if (__p.has_root_directory())
__pathname = root_name().native();
else if (has_filename() || (!has_root_directory() && is_absolute()))
__pathname = _M_pathname + preferred_separator;
__pathname += __p.relative_path().native(); // XXX is this right?
_M_pathname.swap(__pathname);
_M_split_cmpts();
}
#else
// Much simpler, as any path with root-name or root-dir is absolute.
if (__p.is_absolute())
operator=(__p);
else
{
if (has_filename() || (_M_type == _Type::_Root_name))
_M_pathname += preferred_separator;
_M_pathname += __p.native();
_M_split_cmpts();
}
#endif
return *this;
}
template <class _Source>
_Path<_Source>&
operator/=(_Source const& __source)
{ return _M_append(path(__source)); }
template<typename _Source>
_Path<_Source>&
append(_Source const& __source)
{ return _M_append(path(__source)); }
template<typename _InputIterator>
_Path<_InputIterator, _InputIterator>&
append(_InputIterator __first, _InputIterator __last)
{ return _M_append(path(__first, __last)); }
// concatenation
path& operator+=(const path& __x);
path& operator+=(const string_type& __x);
path& operator+=(const value_type* __x);
path& operator+=(value_type __x);
path& operator+=(basic_string_view<value_type> __x);
template<typename _Source>
_Path<_Source>&
operator+=(_Source const& __x) { return concat(__x); }
template<typename _CharT>
_Path<_CharT*, _CharT*>&
operator+=(_CharT __x);
template<typename _Source>
_Path<_Source>&
concat(_Source const& __x)
{ return *this += _S_convert(_S_range_begin(__x), _S_range_end(__x)); }
template<typename _InputIterator>
_Path<_InputIterator, _InputIterator>&
concat(_InputIterator __first, _InputIterator __last)
{ return *this += _S_convert(__first, __last); }
// modifiers
void clear() noexcept { _M_pathname.clear(); _M_split_cmpts(); }
path& make_preferred();
path& remove_filename();
path& replace_filename(const path& __replacement);
path& replace_extension(const path& __replacement = path());
void swap(path& __rhs) noexcept;
// native format observers
const string_type& native() const noexcept { return _M_pathname; }
const value_type* c_str() const noexcept { return _M_pathname.c_str(); }
operator string_type() const { return _M_pathname; }
template<typename _CharT, typename _Traits = std::char_traits<_CharT>,
typename _Allocator = std::allocator<_CharT>>
std::basic_string<_CharT, _Traits, _Allocator>
string(const _Allocator& __a = _Allocator()) const;
std::string string() const;
#if _GLIBCXX_USE_WCHAR_T
std::wstring wstring() const;
#endif
std::string u8string() const;
std::u16string u16string() const;
std::u32string u32string() const;
// generic format observers
template<typename _CharT, typename _Traits = std::char_traits<_CharT>,
typename _Allocator = std::allocator<_CharT>>
std::basic_string<_CharT, _Traits, _Allocator>
generic_string(const _Allocator& __a = _Allocator()) const;
std::string generic_string() const;
#if _GLIBCXX_USE_WCHAR_T
std::wstring generic_wstring() const;
#endif
std::string generic_u8string() const;
std::u16string generic_u16string() const;
std::u32string generic_u32string() const;
// compare
int compare(const path& __p) const noexcept;
int compare(const string_type& __s) const;
int compare(const value_type* __s) const;
int compare(const basic_string_view<value_type> __s) const;
// decomposition
path root_name() const;
path root_directory() const;
path root_path() const;
path relative_path() const;
path parent_path() const;
path filename() const;
path stem() const;
path extension() const;
// query
[[nodiscard]] bool empty() const noexcept { return _M_pathname.empty(); }
bool has_root_name() const;
bool has_root_directory() const;
bool has_root_path() const;
bool has_relative_path() const;
bool has_parent_path() const;
bool has_filename() const;
bool has_stem() const;
bool has_extension() const;
bool is_absolute() const { return has_root_directory(); }
bool is_relative() const { return !is_absolute(); }
// generation
path lexically_normal() const;
path lexically_relative(const path& base) const;
path lexically_proximate(const path& base) const;
// iterators
class iterator;
typedef iterator const_iterator;
iterator begin() const;
iterator end() const;
private:
enum class _Type : unsigned char {
_Multi, _Root_name, _Root_dir, _Filename
};
path(string_type __str, _Type __type) : _M_pathname(__str), _M_type(__type)
{
__glibcxx_assert(_M_type != _Type::_Multi);
}
enum class _Split { _Stem, _Extension };
path&
_M_append(path __p)
{
if (__p.is_absolute())
operator=(std::move(__p));
#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
else if (__p.has_root_name() && __p.root_name() != root_name())
operator=(std::move(__p));
#endif
else
operator/=(const_cast<const path&>(__p));
return *this;
}
pair<const string_type*, size_t> _M_find_extension() const;
template<typename _CharT>
struct _Cvt;
static string_type
_S_convert(value_type* __src, __null_terminated)
{ return string_type(__src); }
static string_type
_S_convert(const value_type* __src, __null_terminated)
{ return string_type(__src); }
template<typename _Iter>
static string_type
_S_convert(_Iter __first, _Iter __last)
{
using __value_type = typename std::iterator_traits<_Iter>::value_type;
return _Cvt<typename remove_cv<__value_type>::type>::
_S_convert(__first, __last);
}
template<typename _InputIterator>
static string_type
_S_convert(_InputIterator __src, __null_terminated)
{
using _Tp = typename std::iterator_traits<_InputIterator>::value_type;
std::basic_string<typename remove_cv<_Tp>::type> __tmp;
for (; *__src != _Tp{}; ++__src)
__tmp.push_back(*__src);
return _S_convert(__tmp.c_str(), __tmp.c_str() + __tmp.size());
}
static string_type
_S_convert_loc(const char* __first, const char* __last,
const std::locale& __loc);
template<typename _Iter>
static string_type
_S_convert_loc(_Iter __first, _Iter __last, const std::locale& __loc)
{
const std::string __str(__first, __last);
return _S_convert_loc(__str.data(), __str.data()+__str.size(), __loc);
}
template<typename _InputIterator>
static string_type
_S_convert_loc(_InputIterator __src, __null_terminated,
const std::locale& __loc)
{
std::string __tmp;
while (*__src != '\0')
__tmp.push_back(*__src++);
return _S_convert_loc(__tmp.data(), __tmp.data()+__tmp.size(), __loc);
}
template<typename _CharT, typename _Traits, typename _Allocator>
static basic_string<_CharT, _Traits, _Allocator>
_S_str_convert(basic_string_view<value_type>, const _Allocator&);
static bool _S_is_dir_sep(value_type __ch)
{
#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
return __ch == L'/' || __ch == preferred_separator;
#else
return __ch == '/';
#endif
}
void _M_split_cmpts();
void _M_trim();
void _M_add_root_name(size_t __n);
void _M_add_root_dir(size_t __pos);
void _M_add_filename(size_t __pos, size_t __n);
string_type _M_pathname;
struct _Cmpt;
using _List = _GLIBCXX_STD_C::vector<_Cmpt>;
_List _M_cmpts; // empty unless _M_type == _Type::_Multi
_Type _M_type = _Type::_Filename;
};
template<>
struct path::__is_encoded_char<char> : std::true_type
{ using value_type = char; };
template<>
struct path::__is_encoded_char<wchar_t> : std::true_type
{ using value_type = wchar_t; };
template<>
struct path::__is_encoded_char<char16_t> : std::true_type
{ using value_type = char16_t; };
template<>
struct path::__is_encoded_char<char32_t> : std::true_type
{ using value_type = char32_t; };
template<typename _Tp>
struct path::__is_encoded_char<const _Tp> : __is_encoded_char<_Tp> { };
inline void swap(path& __lhs, path& __rhs) noexcept { __lhs.swap(__rhs); }
size_t hash_value(const path& __p) noexcept;
/// Compare paths
inline bool operator<(const path& __lhs, const path& __rhs) noexcept
{ return __lhs.compare(__rhs) < 0; }
/// Compare paths
inline bool operator<=(const path& __lhs, const path& __rhs) noexcept
{ return !(__rhs < __lhs); }
/// Compare paths
inline bool operator>(const path& __lhs, const path& __rhs) noexcept
{ return __rhs < __lhs; }
/// Compare paths
inline bool operator>=(const path& __lhs, const path& __rhs) noexcept
{ return !(__lhs < __rhs); }
/// Compare paths
inline bool operator==(const path& __lhs, const path& __rhs) noexcept
{ return __lhs.compare(__rhs) == 0; }
/// Compare paths
inline bool operator!=(const path& __lhs, const path& __rhs) noexcept
{ return !(__lhs == __rhs); }
/// Append one path to another
inline path operator/(const path& __lhs, const path& __rhs)
{
path __result(__lhs);
__result /= __rhs;
return __result;
}
/// Write a path to a stream
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p)
{
auto __tmp = __p.string<_CharT, _Traits>();
using __quoted_string
= std::__detail::_Quoted_string<decltype(__tmp)&, _CharT>;
__os << __quoted_string{__tmp, '"', '\\'};
return __os;
}
/// Read a path from a stream
template<typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, path& __p)
{
basic_string<_CharT, _Traits> __tmp;
using __quoted_string
= std::__detail::_Quoted_string<decltype(__tmp)&, _CharT>;
if (__is >> __quoted_string{ __tmp, '"', '\\' })
__p = std::move(__tmp);
return __is;
}
template<typename _Source>
inline auto
u8path(const _Source& __source)
-> decltype(filesystem::path(__source, std::locale::classic()))
{
#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
const std::string __u8str{__source};
return std::filesystem::u8path(__u8str.begin(), __u8str.end());
#else
return path{ __source };
#endif
}
template<typename _InputIterator>
inline auto
u8path(_InputIterator __first, _InputIterator __last)
-> decltype(filesystem::path(__first, __last, std::locale::classic()))
{
#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
codecvt_utf8<value_type> __cvt;
string_type __tmp;
if (__str_codecvt_in(__first, __last, __tmp, __cvt))
return path{ __tmp };
else
return {};
#else
return path{ __first, __last };
#endif
}
class filesystem_error : public std::system_error
{
public:
filesystem_error(const string& __what_arg, error_code __ec)
: system_error(__ec, __what_arg) { }
filesystem_error(const string& __what_arg, const path& __p1,
error_code __ec)
: system_error(__ec, __what_arg), _M_path1(__p1) { }
filesystem_error(const string& __what_arg, const path& __p1,
const path& __p2, error_code __ec)
: system_error(__ec, __what_arg), _M_path1(__p1), _M_path2(__p2)
{ }
~filesystem_error();
const path& path1() const noexcept { return _M_path1; }
const path& path2() const noexcept { return _M_path2; }
const char* what() const noexcept { return _M_what.c_str(); }
private:
std::string _M_gen_what();
path _M_path1;
path _M_path2;
std::string _M_what = _M_gen_what();
};
struct path::_Cmpt : path
{
_Cmpt(string_type __s, _Type __t, size_t __pos)
: path(std::move(__s), __t), _M_pos(__pos) { }
_Cmpt() : _M_pos(-1) { }
size_t _M_pos;
};
// specialize _Cvt for degenerate 'noconv' case
template<>
struct path::_Cvt<path::value_type>
{
template<typename _Iter>
static string_type
_S_convert(_Iter __first, _Iter __last)
{ return string_type{__first, __last}; }
};
template<typename _CharT>
struct path::_Cvt
{
#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
static string_type
_S_wconvert(const char* __f, const char* __l, true_type)
{
using _Cvt = std::codecvt<wchar_t, char, mbstate_t>;
const auto& __cvt = std::use_facet<_Cvt>(std::locale{});
std::wstring __wstr;
if (__str_codecvt_in(__f, __l, __wstr, __cvt))
return __wstr;
_GLIBCXX_THROW_OR_ABORT(filesystem_error(
"Cannot convert character sequence",
std::make_error_code(errc::illegal_byte_sequence)));
}
static string_type
_S_wconvert(const _CharT* __f, const _CharT* __l, false_type)
{
std::codecvt_utf8<_CharT> __cvt;
std::string __str;
if (__str_codecvt_out(__f, __l, __str, __cvt))
{
const char* __f2 = __str.data();
const char* __l2 = __f2 + __str.size();
std::codecvt_utf8<wchar_t> __wcvt;
std::wstring __wstr;
if (__str_codecvt_in(__f2, __l2, __wstr, __wcvt))
return __wstr;
}
_GLIBCXX_THROW_OR_ABORT(filesystem_error(
"Cannot convert character sequence",
std::make_error_code(errc::illegal_byte_sequence)));
}
static string_type
_S_convert(const _CharT* __f, const _CharT* __l)
{
return _S_wconvert(__f, __l, is_same<_CharT, char>{});
}
#else
static string_type
_S_convert(const _CharT* __f, const _CharT* __l)
{
std::codecvt_utf8<_CharT> __cvt;
std::string __str;
if (__str_codecvt_out(__f, __l, __str, __cvt))
return __str;
_GLIBCXX_THROW_OR_ABORT(filesystem_error(
"Cannot convert character sequence",
std::make_error_code(errc::illegal_byte_sequence)));
}
#endif
static string_type
_S_convert(_CharT* __f, _CharT* __l)
{
return _S_convert(const_cast<const _CharT*>(__f),
const_cast<const _CharT*>(__l));
}
template<typename _Iter>
static string_type
_S_convert(_Iter __first, _Iter __last)
{
const std::basic_string<_CharT> __str(__first, __last);
return _S_convert(__str.data(), __str.data() + __str.size());
}
template<typename _Iter, typename _Cont>
static string_type
_S_convert(__gnu_cxx::__normal_iterator<_Iter, _Cont> __first,
__gnu_cxx::__normal_iterator<_Iter, _Cont> __last)
{ return _S_convert(__first.base(), __last.base()); }
};
/// An iterator for the components of a path
class path::iterator
{
public:
using difference_type = std::ptrdiff_t;
using value_type = path;
using reference = const path&;
using pointer = const path*;
using iterator_category = std::bidirectional_iterator_tag;
iterator() : _M_path(nullptr), _M_cur(), _M_at_end() { }
iterator(const iterator&) = default;
iterator& operator=(const iterator&) = default;
reference operator*() const;
pointer operator->() const { return std::__addressof(**this); }
iterator& operator++();
iterator operator++(int) { auto __tmp = *this; ++*this; return __tmp; }
iterator& operator--();
iterator operator--(int) { auto __tmp = *this; --*this; return __tmp; }
friend bool operator==(const iterator& __lhs, const iterator& __rhs)
{ return __lhs._M_equals(__rhs); }
friend bool operator!=(const iterator& __lhs, const iterator& __rhs)
{ return !__lhs._M_equals(__rhs); }
private:
friend class path;
iterator(const path* __path, path::_List::const_iterator __iter)
: _M_path(__path), _M_cur(__iter), _M_at_end()
{ }
iterator(const path* __path, bool __at_end)
: _M_path(__path), _M_cur(), _M_at_end(__at_end)
{ }
bool _M_equals(iterator) const;
const path* _M_path;
path::_List::const_iterator _M_cur;
bool _M_at_end; // only used when type != _Multi
};
inline path&
path::operator=(path&& __p) noexcept
{
if (&__p == this)
return *this;
_M_pathname = std::move(__p._M_pathname);
_M_cmpts = std::move(__p._M_cmpts);
_M_type = __p._M_type;
__p.clear();
return *this;
}
inline path&
path::operator=(string_type&& __source)
{ return *this = path(std::move(__source)); }
inline path&
path::assign(string_type&& __source)
{ return *this = path(std::move(__source)); }
inline path&
path::operator+=(const path& __p)
{
return operator+=(__p.native());
}
inline path&
path::operator+=(const string_type& __x)
{
_M_pathname += __x;
_M_split_cmpts();
return *this;
}
inline path&
path::operator+=(const value_type* __x)
{
_M_pathname += __x;
_M_split_cmpts();
return *this;
}
inline path&
path::operator+=(value_type __x)
{
_M_pathname += __x;
_M_split_cmpts();
return *this;
}
inline path&
path::operator+=(basic_string_view<value_type> __x)
{
_M_pathname.append(__x.data(), __x.size());
_M_split_cmpts();
return *this;
}
template<typename _CharT>
inline path::_Path<_CharT*, _CharT*>&
path::operator+=(_CharT __x)
{
auto* __addr = std::__addressof(__x);
return concat(__addr, __addr + 1);
}
inline path&
path::make_preferred()
{
#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
std::replace(_M_pathname.begin(), _M_pathname.end(), L'/',
preferred_separator);
#endif
return *this;
}
inline void path::swap(path& __rhs) noexcept
{
_M_pathname.swap(__rhs._M_pathname);
_M_cmpts.swap(__rhs._M_cmpts);
std::swap(_M_type, __rhs._M_type);
}
template<typename _CharT, typename _Traits, typename _Allocator>
std::basic_string<_CharT, _Traits, _Allocator>
path::_S_str_convert(basic_string_view<value_type> __str,
const _Allocator& __a)
{
if (__str.size() == 0)
return std::basic_string<_CharT, _Traits, _Allocator>(__a);
const value_type* __first = __str.data();
const value_type* __last = __first + __str.size();
#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
using _CharAlloc = __alloc_rebind<_Allocator, char>;
using _String = basic_string<char, char_traits<char>, _CharAlloc>;
using _WString = basic_string<_CharT, _Traits, _Allocator>;
// use codecvt_utf8<wchar_t> to convert native string to UTF-8
codecvt_utf8<value_type> __cvt;
_String __u8str{_CharAlloc{__a}};
if (__str_codecvt_out(__first, __last, __u8str, __cvt))
{
if constexpr (is_same_v<_CharT, char>)
return __u8str;
else
{
_WString __wstr;
// use codecvt_utf8<_CharT> to convert UTF-8 to wide string
codecvt_utf8<_CharT> __cvt;
const char* __f = __u8str.data();
const char* __l = __f + __u8str.size();
if (__str_codecvt_in(__f, __l, __wstr, __cvt))
return __wstr;
}
}
#else
codecvt_utf8<_CharT> __cvt;
basic_string<_CharT, _Traits, _Allocator> __wstr{__a};
if (__str_codecvt_in(__first, __last, __wstr, __cvt))
return __wstr;
#endif
_GLIBCXX_THROW_OR_ABORT(filesystem_error(
"Cannot convert character sequence",
std::make_error_code(errc::illegal_byte_sequence)));
}
template<typename _CharT, typename _Traits, typename _Allocator>
inline basic_string<_CharT, _Traits, _Allocator>
path::string(const _Allocator& __a) const
{
if constexpr (is_same_v<_CharT, value_type>)
#if _GLIBCXX_USE_CXX11_ABI
return { _M_pathname, __a };
#else
return { _M_pathname, string_type::size_type(0), __a };
#endif
else
return _S_str_convert<_CharT, _Traits>(_M_pathname, __a);
}
inline std::string
path::string() const { return string<char>(); }
#if _GLIBCXX_USE_WCHAR_T
inline std::wstring
path::wstring() const { return string<wchar_t>(); }
#endif
inline std::string
path::u8string() const
{
#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
std::string __str;
// convert from native encoding to UTF-8
codecvt_utf8<value_type> __cvt;
const value_type* __first = _M_pathname.data();
const value_type* __last = __first + _M_pathname.size();
if (__str_codecvt_out(__first, __last, __str, __cvt))
return __str;
_GLIBCXX_THROW_OR_ABORT(filesystem_error(
"Cannot convert character sequence",
std::make_error_code(errc::illegal_byte_sequence)));
#else
return _M_pathname;
#endif
}
inline std::u16string
path::u16string() const { return string<char16_t>(); }
inline std::u32string
path::u32string() const { return string<char32_t>(); }
template<typename _CharT, typename _Traits, typename _Allocator>
inline std::basic_string<_CharT, _Traits, _Allocator>
path::generic_string(const _Allocator& __a) const
{
#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
const value_type __slash = L'/';
#else
const value_type __slash = '/';
#endif
using _Alloc2 = typename allocator_traits<_Allocator>::template
rebind_alloc<value_type>;
basic_string<value_type, char_traits<value_type>, _Alloc2> __str(__a);
if (_M_type == _Type::_Root_dir)
__str.assign(1, __slash);
else
{
__str.reserve(_M_pathname.size());
bool __add_slash = false;
for (auto& __elem : *this)
{
if (__add_slash)
__str += __slash;
__str += basic_string_view<value_type>(__elem._M_pathname);
__add_slash = __elem._M_type == _Type::_Filename;
}
}
if constexpr (is_same_v<_CharT, value_type>)
return __str;
else
return _S_str_convert<_CharT, _Traits>(__str, __a);
}
inline std::string
path::generic_string() const
{ return generic_string<char>(); }
#if _GLIBCXX_USE_WCHAR_T
inline std::wstring
path::generic_wstring() const
{ return generic_string<wchar_t>(); }
#endif
inline std::string
path::generic_u8string() const
{ return generic_string(); }
inline std::u16string
path::generic_u16string() const
{ return generic_string<char16_t>(); }
inline std::u32string
path::generic_u32string() const
{ return generic_string<char32_t>(); }
inline int
path::compare(const string_type& __s) const { return compare(path(__s)); }
inline int
path::compare(const value_type* __s) const { return compare(path(__s)); }
inline int
path::compare(basic_string_view<value_type> __s) const
{ return compare(path(__s)); }
inline path
path::filename() const
{
if (empty())
return {};
else if (_M_type == _Type::_Filename)
return *this;
else if (_M_type == _Type::_Multi)
{
if (_M_pathname.back() == preferred_separator)
return {};
auto& __last = *--end();
if (__last._M_type == _Type::_Filename)
return __last;
}
return {};
}
inline path
path::stem() const
{
auto ext = _M_find_extension();
if (ext.first && ext.second != 0)
return path{ext.first->substr(0, ext.second)};
return {};
}
inline path
path::extension() const
{
auto ext = _M_find_extension();
if (ext.first && ext.second != string_type::npos)
return path{ext.first->substr(ext.second)};
return {};
}
inline bool
path::has_stem() const
{
auto ext = _M_find_extension();
return ext.first && ext.second != 0;
}
inline bool
path::has_extension() const
{
auto ext = _M_find_extension();
return ext.first && ext.second != string_type::npos;
}
inline path::iterator
path::begin() const
{
if (_M_type == _Type::_Multi)
return iterator(this, _M_cmpts.begin());
return iterator(this, empty());
}
inline path::iterator
path::end() const
{
if (_M_type == _Type::_Multi)
return iterator(this, _M_cmpts.end());
return iterator(this, true);
}
inline path::iterator&
path::iterator::operator++()
{
__glibcxx_assert(_M_path != nullptr);
if (_M_path->_M_type == _Type::_Multi)
{
__glibcxx_assert(_M_cur != _M_path->_M_cmpts.end());
++_M_cur;
}
else
{
__glibcxx_assert(!_M_at_end);
_M_at_end = true;
}
return *this;
}
inline path::iterator&
path::iterator::operator--()
{
__glibcxx_assert(_M_path != nullptr);
if (_M_path->_M_type == _Type::_Multi)
{
__glibcxx_assert(_M_cur != _M_path->_M_cmpts.begin());
--_M_cur;
}
else
{
__glibcxx_assert(_M_at_end);
_M_at_end = false;
}
return *this;
}
inline path::iterator::reference
path::iterator::operator*() const
{
__glibcxx_assert(_M_path != nullptr);
if (_M_path->_M_type == _Type::_Multi)
{
__glibcxx_assert(_M_cur != _M_path->_M_cmpts.end());
return *_M_cur;
}
return *_M_path;
}
inline bool
path::iterator::_M_equals(iterator __rhs) const
{
if (_M_path != __rhs._M_path)
return false;
if (_M_path == nullptr)
return true;
if (_M_path->_M_type == path::_Type::_Multi)
return _M_cur == __rhs._M_cur;
return _M_at_end == __rhs._M_at_end;
}
// @} group filesystem
_GLIBCXX_END_NAMESPACE_CXX11
} // namespace filesystem
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // C++17
#endif // _GLIBCXX_FS_PATH_H
c++/8/bits/stringfwd.h 0000644 00000005057 15201526705 0010416 0 ustar 00 // <string> Forward declarations -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/stringfwd.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{string}
*/
//
// ISO C++ 14882: 21 Strings library
//
#ifndef _STRINGFWD_H
#define _STRINGFWD_H 1
#pragma GCC system_header
#include <bits/c++config.h>
#include <bits/memoryfwd.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @defgroup strings Strings
*
* @{
*/
template<class _CharT>
struct char_traits;
template<> struct char_traits<char>;
#ifdef _GLIBCXX_USE_WCHAR_T
template<> struct char_traits<wchar_t>;
#endif
#if ((__cplusplus >= 201103L) \
&& defined(_GLIBCXX_USE_C99_STDINT_TR1))
template<> struct char_traits<char16_t>;
template<> struct char_traits<char32_t>;
#endif
_GLIBCXX_BEGIN_NAMESPACE_CXX11
template<typename _CharT, typename _Traits = char_traits<_CharT>,
typename _Alloc = allocator<_CharT> >
class basic_string;
/// A string of @c char
typedef basic_string<char> string;
#ifdef _GLIBCXX_USE_WCHAR_T
/// A string of @c wchar_t
typedef basic_string<wchar_t> wstring;
#endif
#if ((__cplusplus >= 201103L) \
&& defined(_GLIBCXX_USE_C99_STDINT_TR1))
/// A string of @c char16_t
typedef basic_string<char16_t> u16string;
/// A string of @c char32_t
typedef basic_string<char32_t> u32string;
#endif
_GLIBCXX_END_NAMESPACE_CXX11
/** @} */
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // _STRINGFWD_H
c++/8/bits/alloc_traits.h 0000644 00000047142 15201526705 0011070 0 ustar 00 // Allocator traits -*- C++ -*-
// Copyright (C) 2011-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/alloc_traits.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{memory}
*/
#ifndef _ALLOC_TRAITS_H
#define _ALLOC_TRAITS_H 1
#if __cplusplus >= 201103L
#include <bits/memoryfwd.h>
#include <bits/ptr_traits.h>
#include <ext/numeric_traits.h>
#define __cpp_lib_allocator_traits_is_always_equal 201411
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
struct __allocator_traits_base
{
template<typename _Tp, typename _Up, typename = void>
struct __rebind : __replace_first_arg<_Tp, _Up> { };
template<typename _Tp, typename _Up>
struct __rebind<_Tp, _Up,
__void_t<typename _Tp::template rebind<_Up>::other>>
{ using type = typename _Tp::template rebind<_Up>::other; };
protected:
template<typename _Tp>
using __pointer = typename _Tp::pointer;
template<typename _Tp>
using __c_pointer = typename _Tp::const_pointer;
template<typename _Tp>
using __v_pointer = typename _Tp::void_pointer;
template<typename _Tp>
using __cv_pointer = typename _Tp::const_void_pointer;
template<typename _Tp>
using __pocca = typename _Tp::propagate_on_container_copy_assignment;
template<typename _Tp>
using __pocma = typename _Tp::propagate_on_container_move_assignment;
template<typename _Tp>
using __pocs = typename _Tp::propagate_on_container_swap;
template<typename _Tp>
using __equal = typename _Tp::is_always_equal;
};
template<typename _Alloc, typename _Up>
using __alloc_rebind
= typename __allocator_traits_base::template __rebind<_Alloc, _Up>::type;
/**
* @brief Uniform interface to all allocator types.
* @ingroup allocators
*/
template<typename _Alloc>
struct allocator_traits : __allocator_traits_base
{
/// The allocator type
typedef _Alloc allocator_type;
/// The allocated type
typedef typename _Alloc::value_type value_type;
/**
* @brief The allocator's pointer type.
*
* @c Alloc::pointer if that type exists, otherwise @c value_type*
*/
using pointer = __detected_or_t<value_type*, __pointer, _Alloc>;
private:
// Select _Func<_Alloc> or pointer_traits<pointer>::rebind<_Tp>
template<template<typename> class _Func, typename _Tp, typename = void>
struct _Ptr
{
using type = typename pointer_traits<pointer>::template rebind<_Tp>;
};
template<template<typename> class _Func, typename _Tp>
struct _Ptr<_Func, _Tp, __void_t<_Func<_Alloc>>>
{
using type = _Func<_Alloc>;
};
// Select _A2::difference_type or pointer_traits<_Ptr>::difference_type
template<typename _A2, typename _PtrT, typename = void>
struct _Diff
{ using type = typename pointer_traits<_PtrT>::difference_type; };
template<typename _A2, typename _PtrT>
struct _Diff<_A2, _PtrT, __void_t<typename _A2::difference_type>>
{ using type = typename _A2::difference_type; };
// Select _A2::size_type or make_unsigned<_DiffT>::type
template<typename _A2, typename _DiffT, typename = void>
struct _Size : make_unsigned<_DiffT> { };
template<typename _A2, typename _DiffT>
struct _Size<_A2, _DiffT, __void_t<typename _A2::size_type>>
{ using type = typename _A2::size_type; };
public:
/**
* @brief The allocator's const pointer type.
*
* @c Alloc::const_pointer if that type exists, otherwise
* <tt> pointer_traits<pointer>::rebind<const value_type> </tt>
*/
using const_pointer = typename _Ptr<__c_pointer, const value_type>::type;
/**
* @brief The allocator's void pointer type.
*
* @c Alloc::void_pointer if that type exists, otherwise
* <tt> pointer_traits<pointer>::rebind<void> </tt>
*/
using void_pointer = typename _Ptr<__v_pointer, void>::type;
/**
* @brief The allocator's const void pointer type.
*
* @c Alloc::const_void_pointer if that type exists, otherwise
* <tt> pointer_traits<pointer>::rebind<const void> </tt>
*/
using const_void_pointer = typename _Ptr<__cv_pointer, const void>::type;
/**
* @brief The allocator's difference type
*
* @c Alloc::difference_type if that type exists, otherwise
* <tt> pointer_traits<pointer>::difference_type </tt>
*/
using difference_type = typename _Diff<_Alloc, pointer>::type;
/**
* @brief The allocator's size type
*
* @c Alloc::size_type if that type exists, otherwise
* <tt> make_unsigned<difference_type>::type </tt>
*/
using size_type = typename _Size<_Alloc, difference_type>::type;
/**
* @brief How the allocator is propagated on copy assignment
*
* @c Alloc::propagate_on_container_copy_assignment if that type exists,
* otherwise @c false_type
*/
using propagate_on_container_copy_assignment
= __detected_or_t<false_type, __pocca, _Alloc>;
/**
* @brief How the allocator is propagated on move assignment
*
* @c Alloc::propagate_on_container_move_assignment if that type exists,
* otherwise @c false_type
*/
using propagate_on_container_move_assignment
= __detected_or_t<false_type, __pocma, _Alloc>;
/**
* @brief How the allocator is propagated on swap
*
* @c Alloc::propagate_on_container_swap if that type exists,
* otherwise @c false_type
*/
using propagate_on_container_swap
= __detected_or_t<false_type, __pocs, _Alloc>;
/**
* @brief Whether all instances of the allocator type compare equal.
*
* @c Alloc::is_always_equal if that type exists,
* otherwise @c is_empty<Alloc>::type
*/
using is_always_equal
= __detected_or_t<typename is_empty<_Alloc>::type, __equal, _Alloc>;
template<typename _Tp>
using rebind_alloc = __alloc_rebind<_Alloc, _Tp>;
template<typename _Tp>
using rebind_traits = allocator_traits<rebind_alloc<_Tp>>;
private:
template<typename _Alloc2>
static auto
_S_allocate(_Alloc2& __a, size_type __n, const_void_pointer __hint, int)
-> decltype(__a.allocate(__n, __hint))
{ return __a.allocate(__n, __hint); }
template<typename _Alloc2>
static pointer
_S_allocate(_Alloc2& __a, size_type __n, const_void_pointer, ...)
{ return __a.allocate(__n); }
template<typename _Tp, typename... _Args>
struct __construct_helper
{
template<typename _Alloc2,
typename = decltype(std::declval<_Alloc2*>()->construct(
std::declval<_Tp*>(), std::declval<_Args>()...))>
static true_type __test(int);
template<typename>
static false_type __test(...);
using type = decltype(__test<_Alloc>(0));
};
template<typename _Tp, typename... _Args>
using __has_construct
= typename __construct_helper<_Tp, _Args...>::type;
template<typename _Tp, typename... _Args>
static _Require<__has_construct<_Tp, _Args...>>
_S_construct(_Alloc& __a, _Tp* __p, _Args&&... __args)
{ __a.construct(__p, std::forward<_Args>(__args)...); }
template<typename _Tp, typename... _Args>
static
_Require<__and_<__not_<__has_construct<_Tp, _Args...>>,
is_constructible<_Tp, _Args...>>>
_S_construct(_Alloc&, _Tp* __p, _Args&&... __args)
{ ::new((void*)__p) _Tp(std::forward<_Args>(__args)...); }
template<typename _Alloc2, typename _Tp>
static auto
_S_destroy(_Alloc2& __a, _Tp* __p, int)
-> decltype(__a.destroy(__p))
{ __a.destroy(__p); }
template<typename _Alloc2, typename _Tp>
static void
_S_destroy(_Alloc2&, _Tp* __p, ...)
{ __p->~_Tp(); }
template<typename _Alloc2>
static auto
_S_max_size(_Alloc2& __a, int)
-> decltype(__a.max_size())
{ return __a.max_size(); }
template<typename _Alloc2>
static size_type
_S_max_size(_Alloc2&, ...)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2466. allocator_traits::max_size() default behavior is incorrect
return __gnu_cxx::__numeric_traits<size_type>::__max
/ sizeof(value_type);
}
template<typename _Alloc2>
static auto
_S_select(_Alloc2& __a, int)
-> decltype(__a.select_on_container_copy_construction())
{ return __a.select_on_container_copy_construction(); }
template<typename _Alloc2>
static _Alloc2
_S_select(_Alloc2& __a, ...)
{ return __a; }
public:
/**
* @brief Allocate memory.
* @param __a An allocator.
* @param __n The number of objects to allocate space for.
*
* Calls @c a.allocate(n)
*/
static pointer
allocate(_Alloc& __a, size_type __n)
{ return __a.allocate(__n); }
/**
* @brief Allocate memory.
* @param __a An allocator.
* @param __n The number of objects to allocate space for.
* @param __hint Aid to locality.
* @return Memory of suitable size and alignment for @a n objects
* of type @c value_type
*
* Returns <tt> a.allocate(n, hint) </tt> if that expression is
* well-formed, otherwise returns @c a.allocate(n)
*/
static pointer
allocate(_Alloc& __a, size_type __n, const_void_pointer __hint)
{ return _S_allocate(__a, __n, __hint, 0); }
/**
* @brief Deallocate memory.
* @param __a An allocator.
* @param __p Pointer to the memory to deallocate.
* @param __n The number of objects space was allocated for.
*
* Calls <tt> a.deallocate(p, n) </tt>
*/
static void
deallocate(_Alloc& __a, pointer __p, size_type __n)
{ __a.deallocate(__p, __n); }
/**
* @brief Construct an object of type @a _Tp
* @param __a An allocator.
* @param __p Pointer to memory of suitable size and alignment for Tp
* @param __args Constructor arguments.
*
* Calls <tt> __a.construct(__p, std::forward<Args>(__args)...) </tt>
* if that expression is well-formed, otherwise uses placement-new
* to construct an object of type @a _Tp at location @a __p from the
* arguments @a __args...
*/
template<typename _Tp, typename... _Args>
static auto construct(_Alloc& __a, _Tp* __p, _Args&&... __args)
-> decltype(_S_construct(__a, __p, std::forward<_Args>(__args)...))
{ _S_construct(__a, __p, std::forward<_Args>(__args)...); }
/**
* @brief Destroy an object of type @a _Tp
* @param __a An allocator.
* @param __p Pointer to the object to destroy
*
* Calls @c __a.destroy(__p) if that expression is well-formed,
* otherwise calls @c __p->~_Tp()
*/
template<typename _Tp>
static void destroy(_Alloc& __a, _Tp* __p)
{ _S_destroy(__a, __p, 0); }
/**
* @brief The maximum supported allocation size
* @param __a An allocator.
* @return @c __a.max_size() or @c numeric_limits<size_type>::max()
*
* Returns @c __a.max_size() if that expression is well-formed,
* otherwise returns @c numeric_limits<size_type>::max()
*/
static size_type max_size(const _Alloc& __a) noexcept
{ return _S_max_size(__a, 0); }
/**
* @brief Obtain an allocator to use when copying a container.
* @param __rhs An allocator.
* @return @c __rhs.select_on_container_copy_construction() or @a __rhs
*
* Returns @c __rhs.select_on_container_copy_construction() if that
* expression is well-formed, otherwise returns @a __rhs
*/
static _Alloc
select_on_container_copy_construction(const _Alloc& __rhs)
{ return _S_select(__rhs, 0); }
};
/// Partial specialization for std::allocator.
template<typename _Tp>
struct allocator_traits<allocator<_Tp>>
{
/// The allocator type
using allocator_type = allocator<_Tp>;
/// The allocated type
using value_type = _Tp;
/// The allocator's pointer type.
using pointer = _Tp*;
/// The allocator's const pointer type.
using const_pointer = const _Tp*;
/// The allocator's void pointer type.
using void_pointer = void*;
/// The allocator's const void pointer type.
using const_void_pointer = const void*;
/// The allocator's difference type
using difference_type = std::ptrdiff_t;
/// The allocator's size type
using size_type = std::size_t;
/// How the allocator is propagated on copy assignment
using propagate_on_container_copy_assignment = false_type;
/// How the allocator is propagated on move assignment
using propagate_on_container_move_assignment = true_type;
/// How the allocator is propagated on swap
using propagate_on_container_swap = false_type;
/// Whether all instances of the allocator type compare equal.
using is_always_equal = true_type;
template<typename _Up>
using rebind_alloc = allocator<_Up>;
template<typename _Up>
using rebind_traits = allocator_traits<allocator<_Up>>;
/**
* @brief Allocate memory.
* @param __a An allocator.
* @param __n The number of objects to allocate space for.
*
* Calls @c a.allocate(n)
*/
static pointer
allocate(allocator_type& __a, size_type __n)
{ return __a.allocate(__n); }
/**
* @brief Allocate memory.
* @param __a An allocator.
* @param __n The number of objects to allocate space for.
* @param __hint Aid to locality.
* @return Memory of suitable size and alignment for @a n objects
* of type @c value_type
*
* Returns <tt> a.allocate(n, hint) </tt>
*/
static pointer
allocate(allocator_type& __a, size_type __n, const_void_pointer __hint)
{ return __a.allocate(__n, __hint); }
/**
* @brief Deallocate memory.
* @param __a An allocator.
* @param __p Pointer to the memory to deallocate.
* @param __n The number of objects space was allocated for.
*
* Calls <tt> a.deallocate(p, n) </tt>
*/
static void
deallocate(allocator_type& __a, pointer __p, size_type __n)
{ __a.deallocate(__p, __n); }
/**
* @brief Construct an object of type @a _Up
* @param __a An allocator.
* @param __p Pointer to memory of suitable size and alignment for Tp
* @param __args Constructor arguments.
*
* Calls <tt> __a.construct(__p, std::forward<Args>(__args)...) </tt>
*/
template<typename _Up, typename... _Args>
static void
construct(allocator_type& __a, _Up* __p, _Args&&... __args)
{ __a.construct(__p, std::forward<_Args>(__args)...); }
/**
* @brief Destroy an object of type @a _Up
* @param __a An allocator.
* @param __p Pointer to the object to destroy
*
* Calls @c __a.destroy(__p).
*/
template<typename _Up>
static void
destroy(allocator_type& __a, _Up* __p)
{ __a.destroy(__p); }
/**
* @brief The maximum supported allocation size
* @param __a An allocator.
* @return @c __a.max_size()
*/
static size_type
max_size(const allocator_type& __a) noexcept
{ return __a.max_size(); }
/**
* @brief Obtain an allocator to use when copying a container.
* @param __rhs An allocator.
* @return @c __rhs
*/
static allocator_type
select_on_container_copy_construction(const allocator_type& __rhs)
{ return __rhs; }
};
template<typename _Alloc>
inline void
__do_alloc_on_copy(_Alloc& __one, const _Alloc& __two, true_type)
{ __one = __two; }
template<typename _Alloc>
inline void
__do_alloc_on_copy(_Alloc&, const _Alloc&, false_type)
{ }
template<typename _Alloc>
inline void __alloc_on_copy(_Alloc& __one, const _Alloc& __two)
{
typedef allocator_traits<_Alloc> __traits;
typedef typename __traits::propagate_on_container_copy_assignment __pocca;
__do_alloc_on_copy(__one, __two, __pocca());
}
template<typename _Alloc>
inline _Alloc __alloc_on_copy(const _Alloc& __a)
{
typedef allocator_traits<_Alloc> __traits;
return __traits::select_on_container_copy_construction(__a);
}
template<typename _Alloc>
inline void __do_alloc_on_move(_Alloc& __one, _Alloc& __two, true_type)
{ __one = std::move(__two); }
template<typename _Alloc>
inline void __do_alloc_on_move(_Alloc&, _Alloc&, false_type)
{ }
template<typename _Alloc>
inline void __alloc_on_move(_Alloc& __one, _Alloc& __two)
{
typedef allocator_traits<_Alloc> __traits;
typedef typename __traits::propagate_on_container_move_assignment __pocma;
__do_alloc_on_move(__one, __two, __pocma());
}
template<typename _Alloc>
inline void __do_alloc_on_swap(_Alloc& __one, _Alloc& __two, true_type)
{
using std::swap;
swap(__one, __two);
}
template<typename _Alloc>
inline void __do_alloc_on_swap(_Alloc&, _Alloc&, false_type)
{ }
template<typename _Alloc>
inline void __alloc_on_swap(_Alloc& __one, _Alloc& __two)
{
typedef allocator_traits<_Alloc> __traits;
typedef typename __traits::propagate_on_container_swap __pocs;
__do_alloc_on_swap(__one, __two, __pocs());
}
template<typename _Alloc>
class __is_copy_insertable_impl
{
typedef allocator_traits<_Alloc> _Traits;
template<typename _Up, typename
= decltype(_Traits::construct(std::declval<_Alloc&>(),
std::declval<_Up*>(),
std::declval<const _Up&>()))>
static true_type
_M_select(int);
template<typename _Up>
static false_type
_M_select(...);
public:
typedef decltype(_M_select<typename _Alloc::value_type>(0)) type;
};
// true if _Alloc::value_type is CopyInsertable into containers using _Alloc
template<typename _Alloc>
struct __is_copy_insertable
: __is_copy_insertable_impl<_Alloc>::type
{ };
// std::allocator<_Tp> just requires CopyConstructible
template<typename _Tp>
struct __is_copy_insertable<allocator<_Tp>>
: is_copy_constructible<_Tp>
{ };
// Trait to detect Allocator-like types.
template<typename _Alloc, typename = void>
struct __is_allocator : false_type { };
template<typename _Alloc>
struct __is_allocator<_Alloc,
__void_t<typename _Alloc::value_type,
decltype(std::declval<_Alloc&>().allocate(size_t{}))>>
: true_type { };
template<typename _Alloc>
using _RequireAllocator
= typename enable_if<__is_allocator<_Alloc>::value, _Alloc>::type;
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // C++11
#endif // _ALLOC_TRAITS_H
c++/8/bits/allocator.h 0000644 00000016621 15201526705 0010366 0 ustar 00 // Allocators -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
* Copyright (c) 1996-1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file bits/allocator.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{memory}
*/
#ifndef _ALLOCATOR_H
#define _ALLOCATOR_H 1
#include <bits/c++allocator.h> // Define the base class to std::allocator.
#include <bits/memoryfwd.h>
#if __cplusplus >= 201103L
#include <type_traits>
#endif
#define __cpp_lib_incomplete_container_elements 201505
#if __cplusplus >= 201103L
# define __cpp_lib_allocator_is_always_equal 201411
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @addtogroup allocators
* @{
*/
/// allocator<void> specialization.
template<>
class allocator<void>
{
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef void* pointer;
typedef const void* const_pointer;
typedef void value_type;
template<typename _Tp1>
struct rebind
{ typedef allocator<_Tp1> other; };
#if __cplusplus >= 201103L
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2103. std::allocator propagate_on_container_move_assignment
typedef true_type propagate_on_container_move_assignment;
typedef true_type is_always_equal;
template<typename _Up, typename... _Args>
void
construct(_Up* __p, _Args&&... __args)
{ ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
template<typename _Up>
void
destroy(_Up* __p) { __p->~_Up(); }
#endif
};
/**
* @brief The @a standard allocator, as per [20.4].
*
* See https://gcc.gnu.org/onlinedocs/libstdc++/manual/memory.html#std.util.memory.allocator
* for further details.
*
* @tparam _Tp Type of allocated object.
*/
template<typename _Tp>
class allocator : public __allocator_base<_Tp>
{
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef _Tp* pointer;
typedef const _Tp* const_pointer;
typedef _Tp& reference;
typedef const _Tp& const_reference;
typedef _Tp value_type;
template<typename _Tp1>
struct rebind
{ typedef allocator<_Tp1> other; };
#if __cplusplus >= 201103L
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2103. std::allocator propagate_on_container_move_assignment
typedef true_type propagate_on_container_move_assignment;
typedef true_type is_always_equal;
#endif
allocator() throw() { }
allocator(const allocator& __a) throw()
: __allocator_base<_Tp>(__a) { }
template<typename _Tp1>
allocator(const allocator<_Tp1>&) throw() { }
~allocator() throw() { }
// Inherit everything else.
};
template<typename _T1, typename _T2>
inline bool
operator==(const allocator<_T1>&, const allocator<_T2>&)
_GLIBCXX_USE_NOEXCEPT
{ return true; }
template<typename _Tp>
inline bool
operator==(const allocator<_Tp>&, const allocator<_Tp>&)
_GLIBCXX_USE_NOEXCEPT
{ return true; }
template<typename _T1, typename _T2>
inline bool
operator!=(const allocator<_T1>&, const allocator<_T2>&)
_GLIBCXX_USE_NOEXCEPT
{ return false; }
template<typename _Tp>
inline bool
operator!=(const allocator<_Tp>&, const allocator<_Tp>&)
_GLIBCXX_USE_NOEXCEPT
{ return false; }
// Invalid allocator<cv T> partial specializations.
// allocator_traits::rebind_alloc can be used to form a valid allocator type.
template<typename _Tp>
class allocator<const _Tp>
{
public:
typedef _Tp value_type;
template<typename _Up> allocator(const allocator<_Up>&) { }
};
template<typename _Tp>
class allocator<volatile _Tp>
{
public:
typedef _Tp value_type;
template<typename _Up> allocator(const allocator<_Up>&) { }
};
template<typename _Tp>
class allocator<const volatile _Tp>
{
public:
typedef _Tp value_type;
template<typename _Up> allocator(const allocator<_Up>&) { }
};
/// @} group allocator
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
#if _GLIBCXX_EXTERN_TEMPLATE
extern template class allocator<char>;
extern template class allocator<wchar_t>;
#endif
// Undefine.
#undef __allocator_base
// To implement Option 3 of DR 431.
template<typename _Alloc, bool = __is_empty(_Alloc)>
struct __alloc_swap
{ static void _S_do_it(_Alloc&, _Alloc&) _GLIBCXX_NOEXCEPT { } };
template<typename _Alloc>
struct __alloc_swap<_Alloc, false>
{
static void
_S_do_it(_Alloc& __one, _Alloc& __two) _GLIBCXX_NOEXCEPT
{
// Precondition: swappable allocators.
if (__one != __two)
swap(__one, __two);
}
};
// Optimize for stateless allocators.
template<typename _Alloc, bool = __is_empty(_Alloc)>
struct __alloc_neq
{
static bool
_S_do_it(const _Alloc&, const _Alloc&)
{ return false; }
};
template<typename _Alloc>
struct __alloc_neq<_Alloc, false>
{
static bool
_S_do_it(const _Alloc& __one, const _Alloc& __two)
{ return __one != __two; }
};
#if __cplusplus >= 201103L
template<typename _Tp, bool
= __or_<is_copy_constructible<typename _Tp::value_type>,
is_nothrow_move_constructible<typename _Tp::value_type>>::value>
struct __shrink_to_fit_aux
{ static bool _S_do_it(_Tp&) noexcept { return false; } };
template<typename _Tp>
struct __shrink_to_fit_aux<_Tp, true>
{
static bool
_S_do_it(_Tp& __c) noexcept
{
#if __cpp_exceptions
try
{
_Tp(__make_move_if_noexcept_iterator(__c.begin()),
__make_move_if_noexcept_iterator(__c.end()),
__c.get_allocator()).swap(__c);
return true;
}
catch(...)
{ return false; }
#else
return false;
#endif
}
};
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif
c++/8/bits/valarray_array.tcc 0000644 00000016126 15201526705 0011747 0 ustar 00 // The template and inlines for the -*- C++ -*- internal _Array helper class.
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/valarray_array.tcc
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{valarray}
*/
// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
#ifndef _VALARRAY_ARRAY_TCC
#define _VALARRAY_ARRAY_TCC 1
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp>
void
__valarray_fill(_Array<_Tp> __a, size_t __n, _Array<bool> __m,
const _Tp& __t)
{
_Tp* __p = __a._M_data;
bool* __ok (__m._M_data);
for (size_t __i=0; __i < __n; ++__i, ++__ok, ++__p)
{
while (!*__ok)
{
++__ok;
++__p;
}
*__p = __t;
}
}
// Copy n elements of a into consecutive elements of b. When m is
// false, the corresponding element of a is skipped. m must contain
// at least n true elements. a must contain at least n elements and
// enough elements to match up with m through the nth true element
// of m. I.e. if n is 10, m has 15 elements with 5 false followed
// by 10 true, a must have 15 elements.
template<typename _Tp>
void
__valarray_copy(_Array<_Tp> __a, _Array<bool> __m, _Array<_Tp> __b,
size_t __n)
{
_Tp* __p (__a._M_data);
bool* __ok (__m._M_data);
for (_Tp* __q = __b._M_data; __q < __b._M_data + __n;
++__q, ++__ok, ++__p)
{
while (! *__ok)
{
++__ok;
++__p;
}
*__q = *__p;
}
}
// Copy n consecutive elements from a into elements of b. Elements
// of b are skipped if the corresponding element of m is false. m
// must contain at least n true elements. b must have at least as
// many elements as the index of the nth true element of m. I.e. if
// m has 15 elements with 5 false followed by 10 true, b must have
// at least 15 elements.
template<typename _Tp>
void
__valarray_copy(_Array<_Tp> __a, size_t __n, _Array<_Tp> __b,
_Array<bool> __m)
{
_Tp* __q (__b._M_data);
bool* __ok (__m._M_data);
for (_Tp* __p = __a._M_data; __p < __a._M_data+__n;
++__p, ++__ok, ++__q)
{
while (! *__ok)
{
++__ok;
++__q;
}
*__q = *__p;
}
}
// Copy n elements from a into elements of b. Elements of a are
// skipped if the corresponding element of m is false. Elements of
// b are skipped if the corresponding element of k is false. m and
// k must contain at least n true elements. a and b must have at
// least as many elements as the index of the nth true element of m.
template<typename _Tp>
void
__valarray_copy(_Array<_Tp> __a, _Array<bool> __m, size_t __n,
_Array<_Tp> __b, _Array<bool> __k)
{
_Tp* __p (__a._M_data);
_Tp* __q (__b._M_data);
bool* __srcok (__m._M_data);
bool* __dstok (__k._M_data);
for (size_t __i = 0; __i < __n;
++__srcok, ++__p, ++__dstok, ++__q, ++__i)
{
while (! *__srcok)
{
++__srcok;
++__p;
}
while (! *__dstok)
{
++__dstok;
++__q;
}
*__q = *__p;
}
}
// Copy n consecutive elements of e into consecutive elements of a.
// I.e. a[i] = e[i].
template<typename _Tp, class _Dom>
void
__valarray_copy(const _Expr<_Dom, _Tp>& __e, size_t __n, _Array<_Tp> __a)
{
_Tp* __p (__a._M_data);
for (size_t __i = 0; __i < __n; ++__i, ++__p)
*__p = __e[__i];
}
// Copy n consecutive elements of e into elements of a using stride
// s. I.e., a[0] = e[0], a[s] = e[1], a[2*s] = e[2].
template<typename _Tp, class _Dom>
void
__valarray_copy(const _Expr<_Dom, _Tp>& __e, size_t __n,
_Array<_Tp> __a, size_t __s)
{
_Tp* __p (__a._M_data);
for (size_t __i = 0; __i < __n; ++__i, __p += __s)
*__p = __e[__i];
}
// Copy n consecutive elements of e into elements of a indexed by
// contents of i. I.e., a[i[0]] = e[0].
template<typename _Tp, class _Dom>
void
__valarray_copy(const _Expr<_Dom, _Tp>& __e, size_t __n,
_Array<_Tp> __a, _Array<size_t> __i)
{
size_t* __j (__i._M_data);
for (size_t __k = 0; __k < __n; ++__k, ++__j)
__a._M_data[*__j] = __e[__k];
}
// Copy n elements of e indexed by contents of f into elements of a
// indexed by contents of i. I.e., a[i[0]] = e[f[0]].
template<typename _Tp>
void
__valarray_copy(_Array<_Tp> __e, _Array<size_t> __f,
size_t __n,
_Array<_Tp> __a, _Array<size_t> __i)
{
size_t* __g (__f._M_data);
size_t* __j (__i._M_data);
for (size_t __k = 0; __k < __n; ++__k, ++__j, ++__g)
__a._M_data[*__j] = __e._M_data[*__g];
}
// Copy n consecutive elements of e into elements of a. Elements of
// a are skipped if the corresponding element of m is false. m must
// have at least n true elements and a must have at least as many
// elements as the index of the nth true element of m. I.e. if m
// has 5 false followed by 10 true elements and n == 10, a must have
// at least 15 elements.
template<typename _Tp, class _Dom>
void
__valarray_copy(const _Expr<_Dom, _Tp>& __e, size_t __n,
_Array<_Tp> __a, _Array<bool> __m)
{
bool* __ok (__m._M_data);
_Tp* __p (__a._M_data);
for (size_t __i = 0; __i < __n; ++__i, ++__ok, ++__p)
{
while (! *__ok)
{
++__ok;
++__p;
}
*__p = __e[__i];
}
}
template<typename _Tp, class _Dom>
void
__valarray_copy_construct(const _Expr<_Dom, _Tp>& __e, size_t __n,
_Array<_Tp> __a)
{
_Tp* __p (__a._M_data);
for (size_t __i = 0; __i < __n; ++__i, ++__p)
new (__p) _Tp(__e[__i]);
}
template<typename _Tp>
void
__valarray_copy_construct(_Array<_Tp> __a, _Array<bool> __m,
_Array<_Tp> __b, size_t __n)
{
_Tp* __p (__a._M_data);
bool* __ok (__m._M_data);
for (_Tp* __q = __b._M_data; __q < __b._M_data+__n; ++__q, ++__ok, ++__p)
{
while (! *__ok)
{
++__ok;
++__p;
}
new (__q) _Tp(*__p);
}
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif /* _VALARRAY_ARRAY_TCC */
c++/8/bits/locale_classes.h 0000644 00000060501 15201526705 0011356 0 ustar 00 // Locale support -*- C++ -*-
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/locale_classes.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{locale}
*/
//
// ISO C++ 14882: 22.1 Locales
//
#ifndef _LOCALE_CLASSES_H
#define _LOCALE_CLASSES_H 1
#pragma GCC system_header
#include <bits/localefwd.h>
#include <string>
#include <ext/atomicity.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// 22.1.1 Class locale
/**
* @brief Container class for localization functionality.
* @ingroup locales
*
* The locale class is first a class wrapper for C library locales. It is
* also an extensible container for user-defined localization. A locale is
* a collection of facets that implement various localization features such
* as money, time, and number printing.
*
* Constructing C++ locales does not change the C library locale.
*
* This library supports efficient construction and copying of locales
* through a reference counting implementation of the locale class.
*/
class locale
{
public:
// Types:
/// Definition of locale::category.
typedef int category;
// Forward decls and friends:
class facet;
class id;
class _Impl;
friend class facet;
friend class _Impl;
template<typename _Facet>
friend bool
has_facet(const locale&) throw();
template<typename _Facet>
friend const _Facet&
use_facet(const locale&);
template<typename _Cache>
friend struct __use_cache;
//@{
/**
* @brief Category values.
*
* The standard category values are none, ctype, numeric, collate, time,
* monetary, and messages. They form a bitmask that supports union and
* intersection. The category all is the union of these values.
*
* NB: Order must match _S_facet_categories definition in locale.cc
*/
static const category none = 0;
static const category ctype = 1L << 0;
static const category numeric = 1L << 1;
static const category collate = 1L << 2;
static const category time = 1L << 3;
static const category monetary = 1L << 4;
static const category messages = 1L << 5;
static const category all = (ctype | numeric | collate |
time | monetary | messages);
//@}
// Construct/copy/destroy:
/**
* @brief Default constructor.
*
* Constructs a copy of the global locale. If no locale has been
* explicitly set, this is the C locale.
*/
locale() throw();
/**
* @brief Copy constructor.
*
* Constructs a copy of @a other.
*
* @param __other The locale to copy.
*/
locale(const locale& __other) throw();
/**
* @brief Named locale constructor.
*
* Constructs a copy of the named C library locale.
*
* @param __s Name of the locale to construct.
* @throw std::runtime_error if __s is null or an undefined locale.
*/
explicit
locale(const char* __s);
/**
* @brief Construct locale with facets from another locale.
*
* Constructs a copy of the locale @a base. The facets specified by @a
* cat are replaced with those from the locale named by @a s. If base is
* named, this locale instance will also be named.
*
* @param __base The locale to copy.
* @param __s Name of the locale to use facets from.
* @param __cat Set of categories defining the facets to use from __s.
* @throw std::runtime_error if __s is null or an undefined locale.
*/
locale(const locale& __base, const char* __s, category __cat);
#if __cplusplus >= 201103L
/**
* @brief Named locale constructor.
*
* Constructs a copy of the named C library locale.
*
* @param __s Name of the locale to construct.
* @throw std::runtime_error if __s is an undefined locale.
*/
explicit
locale(const std::string& __s) : locale(__s.c_str()) { }
/**
* @brief Construct locale with facets from another locale.
*
* Constructs a copy of the locale @a base. The facets specified by @a
* cat are replaced with those from the locale named by @a s. If base is
* named, this locale instance will also be named.
*
* @param __base The locale to copy.
* @param __s Name of the locale to use facets from.
* @param __cat Set of categories defining the facets to use from __s.
* @throw std::runtime_error if __s is an undefined locale.
*/
locale(const locale& __base, const std::string& __s, category __cat)
: locale(__base, __s.c_str(), __cat) { }
#endif
/**
* @brief Construct locale with facets from another locale.
*
* Constructs a copy of the locale @a base. The facets specified by @a
* cat are replaced with those from the locale @a add. If @a base and @a
* add are named, this locale instance will also be named.
*
* @param __base The locale to copy.
* @param __add The locale to use facets from.
* @param __cat Set of categories defining the facets to use from add.
*/
locale(const locale& __base, const locale& __add, category __cat);
/**
* @brief Construct locale with another facet.
*
* Constructs a copy of the locale @a __other. The facet @a __f
* is added to @a __other, replacing an existing facet of type
* Facet if there is one. If @a __f is null, this locale is a
* copy of @a __other.
*
* @param __other The locale to copy.
* @param __f The facet to add in.
*/
template<typename _Facet>
locale(const locale& __other, _Facet* __f);
/// Locale destructor.
~locale() throw();
/**
* @brief Assignment operator.
*
* Set this locale to be a copy of @a other.
*
* @param __other The locale to copy.
* @return A reference to this locale.
*/
const locale&
operator=(const locale& __other) throw();
/**
* @brief Construct locale with another facet.
*
* Constructs and returns a new copy of this locale. Adds or replaces an
* existing facet of type Facet from the locale @a other into the new
* locale.
*
* @tparam _Facet The facet type to copy from other
* @param __other The locale to copy from.
* @return Newly constructed locale.
* @throw std::runtime_error if __other has no facet of type _Facet.
*/
template<typename _Facet>
locale
combine(const locale& __other) const;
// Locale operations:
/**
* @brief Return locale name.
* @return Locale name or "*" if unnamed.
*/
_GLIBCXX_DEFAULT_ABI_TAG
string
name() const;
/**
* @brief Locale equality.
*
* @param __other The locale to compare against.
* @return True if other and this refer to the same locale instance, are
* copies, or have the same name. False otherwise.
*/
bool
operator==(const locale& __other) const throw();
/**
* @brief Locale inequality.
*
* @param __other The locale to compare against.
* @return ! (*this == __other)
*/
bool
operator!=(const locale& __other) const throw()
{ return !(this->operator==(__other)); }
/**
* @brief Compare two strings according to collate.
*
* Template operator to compare two strings using the compare function of
* the collate facet in this locale. One use is to provide the locale to
* the sort function. For example, a vector v of strings could be sorted
* according to locale loc by doing:
* @code
* std::sort(v.begin(), v.end(), loc);
* @endcode
*
* @param __s1 First string to compare.
* @param __s2 Second string to compare.
* @return True if collate<_Char> facet compares __s1 < __s2, else false.
*/
template<typename _Char, typename _Traits, typename _Alloc>
bool
operator()(const basic_string<_Char, _Traits, _Alloc>& __s1,
const basic_string<_Char, _Traits, _Alloc>& __s2) const;
// Global locale objects:
/**
* @brief Set global locale
*
* This function sets the global locale to the argument and returns a
* copy of the previous global locale. If the argument has a name, it
* will also call std::setlocale(LC_ALL, loc.name()).
*
* @param __loc The new locale to make global.
* @return Copy of the old global locale.
*/
static locale
global(const locale& __loc);
/**
* @brief Return reference to the C locale.
*/
static const locale&
classic();
private:
// The (shared) implementation
_Impl* _M_impl;
// The "C" reference locale
static _Impl* _S_classic;
// Current global locale
static _Impl* _S_global;
// Names of underlying locale categories.
// NB: locale::global() has to know how to modify all the
// underlying categories, not just the ones required by the C++
// standard.
static const char* const* const _S_categories;
// Number of standard categories. For C++, these categories are
// collate, ctype, monetary, numeric, time, and messages. These
// directly correspond to ISO C99 macros LC_COLLATE, LC_CTYPE,
// LC_MONETARY, LC_NUMERIC, and LC_TIME. In addition, POSIX (IEEE
// 1003.1-2001) specifies LC_MESSAGES.
// In addition to the standard categories, the underlying
// operating system is allowed to define extra LC_*
// macros. For GNU systems, the following are also valid:
// LC_PAPER, LC_NAME, LC_ADDRESS, LC_TELEPHONE, LC_MEASUREMENT,
// and LC_IDENTIFICATION.
enum { _S_categories_size = 6 + _GLIBCXX_NUM_CATEGORIES };
#ifdef __GTHREADS
static __gthread_once_t _S_once;
#endif
explicit
locale(_Impl*) throw();
static void
_S_initialize();
static void
_S_initialize_once() throw();
static category
_S_normalize_category(category);
void
_M_coalesce(const locale& __base, const locale& __add, category __cat);
#if _GLIBCXX_USE_CXX11_ABI
static const id* const _S_twinned_facets[];
#endif
};
// 22.1.1.1.2 Class locale::facet
/**
* @brief Localization functionality base class.
* @ingroup locales
*
* The facet class is the base class for a localization feature, such as
* money, time, and number printing. It provides common support for facets
* and reference management.
*
* Facets may not be copied or assigned.
*/
class locale::facet
{
private:
friend class locale;
friend class locale::_Impl;
mutable _Atomic_word _M_refcount;
// Contains data from the underlying "C" library for the classic locale.
static __c_locale _S_c_locale;
// String literal for the name of the classic locale.
static const char _S_c_name[2];
#ifdef __GTHREADS
static __gthread_once_t _S_once;
#endif
static void
_S_initialize_once();
protected:
/**
* @brief Facet constructor.
*
* This is the constructor provided by the standard. If refs is 0, the
* facet is destroyed when the last referencing locale is destroyed.
* Otherwise the facet will never be destroyed.
*
* @param __refs The initial value for reference count.
*/
explicit
facet(size_t __refs = 0) throw() : _M_refcount(__refs ? 1 : 0)
{ }
/// Facet destructor.
virtual
~facet();
static void
_S_create_c_locale(__c_locale& __cloc, const char* __s,
__c_locale __old = 0);
static __c_locale
_S_clone_c_locale(__c_locale& __cloc) throw();
static void
_S_destroy_c_locale(__c_locale& __cloc);
static __c_locale
_S_lc_ctype_c_locale(__c_locale __cloc, const char* __s);
// Returns data from the underlying "C" library data for the
// classic locale.
static __c_locale
_S_get_c_locale();
_GLIBCXX_CONST static const char*
_S_get_c_name() throw();
#if __cplusplus < 201103L
private:
facet(const facet&); // Not defined.
facet&
operator=(const facet&); // Not defined.
#else
facet(const facet&) = delete;
facet&
operator=(const facet&) = delete;
#endif
private:
void
_M_add_reference() const throw()
{ __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); }
void
_M_remove_reference() const throw()
{
// Be race-detector-friendly. For more info see bits/c++config.
_GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_refcount);
if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1)
{
_GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_refcount);
__try
{ delete this; }
__catch(...)
{ }
}
}
const facet* _M_sso_shim(const id*) const;
const facet* _M_cow_shim(const id*) const;
protected:
class __shim; // For internal use only.
};
// 22.1.1.1.3 Class locale::id
/**
* @brief Facet ID class.
* @ingroup locales
*
* The ID class provides facets with an index used to identify them.
* Every facet class must define a public static member locale::id, or be
* derived from a facet that provides this member, otherwise the facet
* cannot be used in a locale. The locale::id ensures that each class
* type gets a unique identifier.
*/
class locale::id
{
private:
friend class locale;
friend class locale::_Impl;
template<typename _Facet>
friend const _Facet&
use_facet(const locale&);
template<typename _Facet>
friend bool
has_facet(const locale&) throw();
// NB: There is no accessor for _M_index because it may be used
// before the constructor is run; the effect of calling a member
// function (even an inline) would be undefined.
mutable size_t _M_index;
// Last id number assigned.
static _Atomic_word _S_refcount;
void
operator=(const id&); // Not defined.
id(const id&); // Not defined.
public:
// NB: This class is always a static data member, and thus can be
// counted on to be zero-initialized.
/// Constructor.
id() { }
size_t
_M_id() const throw();
};
// Implementation object for locale.
class locale::_Impl
{
public:
// Friends.
friend class locale;
friend class locale::facet;
template<typename _Facet>
friend bool
has_facet(const locale&) throw();
template<typename _Facet>
friend const _Facet&
use_facet(const locale&);
template<typename _Cache>
friend struct __use_cache;
private:
// Data Members.
_Atomic_word _M_refcount;
const facet** _M_facets;
size_t _M_facets_size;
const facet** _M_caches;
char** _M_names;
static const locale::id* const _S_id_ctype[];
static const locale::id* const _S_id_numeric[];
static const locale::id* const _S_id_collate[];
static const locale::id* const _S_id_time[];
static const locale::id* const _S_id_monetary[];
static const locale::id* const _S_id_messages[];
static const locale::id* const* const _S_facet_categories[];
void
_M_add_reference() throw()
{ __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); }
void
_M_remove_reference() throw()
{
// Be race-detector-friendly. For more info see bits/c++config.
_GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_refcount);
if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1)
{
_GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_refcount);
__try
{ delete this; }
__catch(...)
{ }
}
}
_Impl(const _Impl&, size_t);
_Impl(const char*, size_t);
_Impl(size_t) throw();
~_Impl() throw();
_Impl(const _Impl&); // Not defined.
void
operator=(const _Impl&); // Not defined.
bool
_M_check_same_name()
{
bool __ret = true;
if (_M_names[1])
// We must actually compare all the _M_names: can be all equal!
for (size_t __i = 0; __ret && __i < _S_categories_size - 1; ++__i)
__ret = __builtin_strcmp(_M_names[__i], _M_names[__i + 1]) == 0;
return __ret;
}
void
_M_replace_categories(const _Impl*, category);
void
_M_replace_category(const _Impl*, const locale::id* const*);
void
_M_replace_facet(const _Impl*, const locale::id*);
void
_M_install_facet(const locale::id*, const facet*);
template<typename _Facet>
void
_M_init_facet(_Facet* __facet)
{ _M_install_facet(&_Facet::id, __facet); }
template<typename _Facet>
void
_M_init_facet_unchecked(_Facet* __facet)
{
__facet->_M_add_reference();
_M_facets[_Facet::id._M_id()] = __facet;
}
void
_M_install_cache(const facet*, size_t);
void _M_init_extra(facet**);
void _M_init_extra(void*, void*, const char*, const char*);
};
/**
* @brief Facet for localized string comparison.
*
* This facet encapsulates the code to compare strings in a localized
* manner.
*
* The collate template uses protected virtual functions to provide
* the actual results. The public accessors forward the call to
* the virtual functions. These virtual functions are hooks for
* developers to implement the behavior they require from the
* collate facet.
*/
template<typename _CharT>
class _GLIBCXX_NAMESPACE_CXX11 collate : public locale::facet
{
public:
// Types:
//@{
/// Public typedefs
typedef _CharT char_type;
typedef basic_string<_CharT> string_type;
//@}
protected:
// Underlying "C" library locale information saved from
// initialization, needed by collate_byname as well.
__c_locale _M_c_locale_collate;
public:
/// Numpunct facet id.
static locale::id id;
/**
* @brief Constructor performs initialization.
*
* This is the constructor provided by the standard.
*
* @param __refs Passed to the base facet class.
*/
explicit
collate(size_t __refs = 0)
: facet(__refs), _M_c_locale_collate(_S_get_c_locale())
{ }
/**
* @brief Internal constructor. Not for general use.
*
* This is a constructor for use by the library itself to set up new
* locales.
*
* @param __cloc The C locale.
* @param __refs Passed to the base facet class.
*/
explicit
collate(__c_locale __cloc, size_t __refs = 0)
: facet(__refs), _M_c_locale_collate(_S_clone_c_locale(__cloc))
{ }
/**
* @brief Compare two strings.
*
* This function compares two strings and returns the result by calling
* collate::do_compare().
*
* @param __lo1 Start of string 1.
* @param __hi1 End of string 1.
* @param __lo2 Start of string 2.
* @param __hi2 End of string 2.
* @return 1 if string1 > string2, -1 if string1 < string2, else 0.
*/
int
compare(const _CharT* __lo1, const _CharT* __hi1,
const _CharT* __lo2, const _CharT* __hi2) const
{ return this->do_compare(__lo1, __hi1, __lo2, __hi2); }
/**
* @brief Transform string to comparable form.
*
* This function is a wrapper for strxfrm functionality. It takes the
* input string and returns a modified string that can be directly
* compared to other transformed strings. In the C locale, this
* function just returns a copy of the input string. In some other
* locales, it may replace two chars with one, change a char for
* another, etc. It does so by returning collate::do_transform().
*
* @param __lo Start of string.
* @param __hi End of string.
* @return Transformed string_type.
*/
string_type
transform(const _CharT* __lo, const _CharT* __hi) const
{ return this->do_transform(__lo, __hi); }
/**
* @brief Return hash of a string.
*
* This function computes and returns a hash on the input string. It
* does so by returning collate::do_hash().
*
* @param __lo Start of string.
* @param __hi End of string.
* @return Hash value.
*/
long
hash(const _CharT* __lo, const _CharT* __hi) const
{ return this->do_hash(__lo, __hi); }
// Used to abstract out _CharT bits in virtual member functions, below.
int
_M_compare(const _CharT*, const _CharT*) const throw();
size_t
_M_transform(_CharT*, const _CharT*, size_t) const throw();
protected:
/// Destructor.
virtual
~collate()
{ _S_destroy_c_locale(_M_c_locale_collate); }
/**
* @brief Compare two strings.
*
* This function is a hook for derived classes to change the value
* returned. @see compare().
*
* @param __lo1 Start of string 1.
* @param __hi1 End of string 1.
* @param __lo2 Start of string 2.
* @param __hi2 End of string 2.
* @return 1 if string1 > string2, -1 if string1 < string2, else 0.
*/
virtual int
do_compare(const _CharT* __lo1, const _CharT* __hi1,
const _CharT* __lo2, const _CharT* __hi2) const;
/**
* @brief Transform string to comparable form.
*
* This function is a hook for derived classes to change the value
* returned.
*
* @param __lo Start.
* @param __hi End.
* @return transformed string.
*/
virtual string_type
do_transform(const _CharT* __lo, const _CharT* __hi) const;
/**
* @brief Return hash of a string.
*
* This function computes and returns a hash on the input string. This
* function is a hook for derived classes to change the value returned.
*
* @param __lo Start of string.
* @param __hi End of string.
* @return Hash value.
*/
virtual long
do_hash(const _CharT* __lo, const _CharT* __hi) const;
};
template<typename _CharT>
locale::id collate<_CharT>::id;
// Specializations.
template<>
int
collate<char>::_M_compare(const char*, const char*) const throw();
template<>
size_t
collate<char>::_M_transform(char*, const char*, size_t) const throw();
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
int
collate<wchar_t>::_M_compare(const wchar_t*, const wchar_t*) const throw();
template<>
size_t
collate<wchar_t>::_M_transform(wchar_t*, const wchar_t*, size_t) const throw();
#endif
/// class collate_byname [22.2.4.2].
template<typename _CharT>
class _GLIBCXX_NAMESPACE_CXX11 collate_byname : public collate<_CharT>
{
public:
//@{
/// Public typedefs
typedef _CharT char_type;
typedef basic_string<_CharT> string_type;
//@}
explicit
collate_byname(const char* __s, size_t __refs = 0)
: collate<_CharT>(__refs)
{
if (__builtin_strcmp(__s, "C") != 0
&& __builtin_strcmp(__s, "POSIX") != 0)
{
this->_S_destroy_c_locale(this->_M_c_locale_collate);
this->_S_create_c_locale(this->_M_c_locale_collate, __s);
}
}
#if __cplusplus >= 201103L
explicit
collate_byname(const string& __s, size_t __refs = 0)
: collate_byname(__s.c_str(), __refs) { }
#endif
protected:
virtual
~collate_byname() { }
};
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
# include <bits/locale_classes.tcc>
#endif
c++/8/bits/functional_hash.h 0000644 00000020056 15201526705 0011550 0 ustar 00 // functional_hash.h header -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/functional_hash.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{functional}
*/
#ifndef _FUNCTIONAL_HASH_H
#define _FUNCTIONAL_HASH_H 1
#pragma GCC system_header
#include <bits/hash_bytes.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/** @defgroup hashes Hashes
* @ingroup functors
*
* Hashing functors taking a variable type and returning a @c std::size_t.
*
* @{
*/
template<typename _Result, typename _Arg>
struct __hash_base
{
typedef _Result result_type _GLIBCXX17_DEPRECATED;
typedef _Arg argument_type _GLIBCXX17_DEPRECATED;
};
/// Primary class template hash.
template<typename _Tp>
struct hash;
template<typename _Tp, typename = void>
struct __poison_hash
{
static constexpr bool __enable_hash_call = false;
private:
// Private rather than deleted to be non-trivially-copyable.
__poison_hash(__poison_hash&&);
~__poison_hash();
};
template<typename _Tp>
struct __poison_hash<_Tp, __void_t<decltype(hash<_Tp>()(declval<_Tp>()))>>
{
static constexpr bool __enable_hash_call = true;
};
// Helper struct for SFINAE-poisoning non-enum types.
template<typename _Tp, bool = is_enum<_Tp>::value>
struct __hash_enum
{
private:
// Private rather than deleted to be non-trivially-copyable.
__hash_enum(__hash_enum&&);
~__hash_enum();
};
// Helper struct for hash with enum types.
template<typename _Tp>
struct __hash_enum<_Tp, true> : public __hash_base<size_t, _Tp>
{
size_t
operator()(_Tp __val) const noexcept
{
using __type = typename underlying_type<_Tp>::type;
return hash<__type>{}(static_cast<__type>(__val));
}
};
/// Primary class template hash, usable for enum types only.
// Use with non-enum types still SFINAES.
template<typename _Tp>
struct hash : __hash_enum<_Tp>
{ };
/// Partial specializations for pointer types.
template<typename _Tp>
struct hash<_Tp*> : public __hash_base<size_t, _Tp*>
{
size_t
operator()(_Tp* __p) const noexcept
{ return reinterpret_cast<size_t>(__p); }
};
// Explicit specializations for integer types.
#define _Cxx_hashtable_define_trivial_hash(_Tp) \
template<> \
struct hash<_Tp> : public __hash_base<size_t, _Tp> \
{ \
size_t \
operator()(_Tp __val) const noexcept \
{ return static_cast<size_t>(__val); } \
};
/// Explicit specialization for bool.
_Cxx_hashtable_define_trivial_hash(bool)
/// Explicit specialization for char.
_Cxx_hashtable_define_trivial_hash(char)
/// Explicit specialization for signed char.
_Cxx_hashtable_define_trivial_hash(signed char)
/// Explicit specialization for unsigned char.
_Cxx_hashtable_define_trivial_hash(unsigned char)
/// Explicit specialization for wchar_t.
_Cxx_hashtable_define_trivial_hash(wchar_t)
/// Explicit specialization for char16_t.
_Cxx_hashtable_define_trivial_hash(char16_t)
/// Explicit specialization for char32_t.
_Cxx_hashtable_define_trivial_hash(char32_t)
/// Explicit specialization for short.
_Cxx_hashtable_define_trivial_hash(short)
/// Explicit specialization for int.
_Cxx_hashtable_define_trivial_hash(int)
/// Explicit specialization for long.
_Cxx_hashtable_define_trivial_hash(long)
/// Explicit specialization for long long.
_Cxx_hashtable_define_trivial_hash(long long)
/// Explicit specialization for unsigned short.
_Cxx_hashtable_define_trivial_hash(unsigned short)
/// Explicit specialization for unsigned int.
_Cxx_hashtable_define_trivial_hash(unsigned int)
/// Explicit specialization for unsigned long.
_Cxx_hashtable_define_trivial_hash(unsigned long)
/// Explicit specialization for unsigned long long.
_Cxx_hashtable_define_trivial_hash(unsigned long long)
#ifdef __GLIBCXX_TYPE_INT_N_0
_Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_0)
_Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_0 unsigned)
#endif
#ifdef __GLIBCXX_TYPE_INT_N_1
_Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_1)
_Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_1 unsigned)
#endif
#ifdef __GLIBCXX_TYPE_INT_N_2
_Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_2)
_Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_2 unsigned)
#endif
#ifdef __GLIBCXX_TYPE_INT_N_3
_Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_3)
_Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_3 unsigned)
#endif
#undef _Cxx_hashtable_define_trivial_hash
struct _Hash_impl
{
static size_t
hash(const void* __ptr, size_t __clength,
size_t __seed = static_cast<size_t>(0xc70f6907UL))
{ return _Hash_bytes(__ptr, __clength, __seed); }
template<typename _Tp>
static size_t
hash(const _Tp& __val)
{ return hash(&__val, sizeof(__val)); }
template<typename _Tp>
static size_t
__hash_combine(const _Tp& __val, size_t __hash)
{ return hash(&__val, sizeof(__val), __hash); }
};
// A hash function similar to FNV-1a (see PR59406 for how it differs).
struct _Fnv_hash_impl
{
static size_t
hash(const void* __ptr, size_t __clength,
size_t __seed = static_cast<size_t>(2166136261UL))
{ return _Fnv_hash_bytes(__ptr, __clength, __seed); }
template<typename _Tp>
static size_t
hash(const _Tp& __val)
{ return hash(&__val, sizeof(__val)); }
template<typename _Tp>
static size_t
__hash_combine(const _Tp& __val, size_t __hash)
{ return hash(&__val, sizeof(__val), __hash); }
};
/// Specialization for float.
template<>
struct hash<float> : public __hash_base<size_t, float>
{
size_t
operator()(float __val) const noexcept
{
// 0 and -0 both hash to zero.
return __val != 0.0f ? std::_Hash_impl::hash(__val) : 0;
}
};
/// Specialization for double.
template<>
struct hash<double> : public __hash_base<size_t, double>
{
size_t
operator()(double __val) const noexcept
{
// 0 and -0 both hash to zero.
return __val != 0.0 ? std::_Hash_impl::hash(__val) : 0;
}
};
/// Specialization for long double.
template<>
struct hash<long double>
: public __hash_base<size_t, long double>
{
_GLIBCXX_PURE size_t
operator()(long double __val) const noexcept;
};
// @} group hashes
// Hint about performance of hash functor. If not fast the hash-based
// containers will cache the hash code.
// Default behavior is to consider that hashers are fast unless specified
// otherwise.
template<typename _Hash>
struct __is_fast_hash : public std::true_type
{ };
template<>
struct __is_fast_hash<hash<long double>> : public std::false_type
{ };
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif // _FUNCTIONAL_HASH_H
c++/8/bits/stl_heap.h 0000644 00000047356 15201526705 0010216 0 ustar 00 // Heap implementation -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
* Copyright (c) 1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file bits/stl_heap.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{queue}
*/
#ifndef _STL_HEAP_H
#define _STL_HEAP_H 1
#include <debug/debug.h>
#include <bits/move.h>
#include <bits/predefined_ops.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @defgroup heap_algorithms Heap
* @ingroup sorting_algorithms
*/
template<typename _RandomAccessIterator, typename _Distance,
typename _Compare>
_Distance
__is_heap_until(_RandomAccessIterator __first, _Distance __n,
_Compare& __comp)
{
_Distance __parent = 0;
for (_Distance __child = 1; __child < __n; ++__child)
{
if (__comp(__first + __parent, __first + __child))
return __child;
if ((__child & 1) == 0)
++__parent;
}
return __n;
}
// __is_heap, a predicate testing whether or not a range is a heap.
// This function is an extension, not part of the C++ standard.
template<typename _RandomAccessIterator, typename _Distance>
inline bool
__is_heap(_RandomAccessIterator __first, _Distance __n)
{
__gnu_cxx::__ops::_Iter_less_iter __comp;
return std::__is_heap_until(__first, __n, __comp) == __n;
}
template<typename _RandomAccessIterator, typename _Compare,
typename _Distance>
inline bool
__is_heap(_RandomAccessIterator __first, _Compare __comp, _Distance __n)
{
typedef __decltype(__comp) _Cmp;
__gnu_cxx::__ops::_Iter_comp_iter<_Cmp> __cmp(_GLIBCXX_MOVE(__comp));
return std::__is_heap_until(__first, __n, __cmp) == __n;
}
template<typename _RandomAccessIterator>
inline bool
__is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
{ return std::__is_heap(__first, std::distance(__first, __last)); }
template<typename _RandomAccessIterator, typename _Compare>
inline bool
__is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
_Compare __comp)
{
return std::__is_heap(__first, _GLIBCXX_MOVE(__comp),
std::distance(__first, __last));
}
// Heap-manipulation functions: push_heap, pop_heap, make_heap, sort_heap,
// + is_heap and is_heap_until in C++0x.
template<typename _RandomAccessIterator, typename _Distance, typename _Tp,
typename _Compare>
void
__push_heap(_RandomAccessIterator __first,
_Distance __holeIndex, _Distance __topIndex, _Tp __value,
_Compare& __comp)
{
_Distance __parent = (__holeIndex - 1) / 2;
while (__holeIndex > __topIndex && __comp(__first + __parent, __value))
{
*(__first + __holeIndex) = _GLIBCXX_MOVE(*(__first + __parent));
__holeIndex = __parent;
__parent = (__holeIndex - 1) / 2;
}
*(__first + __holeIndex) = _GLIBCXX_MOVE(__value);
}
/**
* @brief Push an element onto a heap.
* @param __first Start of heap.
* @param __last End of heap + element.
* @ingroup heap_algorithms
*
* This operation pushes the element at last-1 onto the valid heap
* over the range [__first,__last-1). After completion,
* [__first,__last) is a valid heap.
*/
template<typename _RandomAccessIterator>
inline void
push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
{
typedef typename iterator_traits<_RandomAccessIterator>::value_type
_ValueType;
typedef typename iterator_traits<_RandomAccessIterator>::difference_type
_DistanceType;
// concept requirements
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>)
__glibcxx_function_requires(_LessThanComparableConcept<_ValueType>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_irreflexive(__first, __last);
__glibcxx_requires_heap(__first, __last - 1);
__gnu_cxx::__ops::_Iter_less_val __comp;
_ValueType __value = _GLIBCXX_MOVE(*(__last - 1));
std::__push_heap(__first, _DistanceType((__last - __first) - 1),
_DistanceType(0), _GLIBCXX_MOVE(__value), __comp);
}
/**
* @brief Push an element onto a heap using comparison functor.
* @param __first Start of heap.
* @param __last End of heap + element.
* @param __comp Comparison functor.
* @ingroup heap_algorithms
*
* This operation pushes the element at __last-1 onto the valid
* heap over the range [__first,__last-1). After completion,
* [__first,__last) is a valid heap. Compare operations are
* performed using comp.
*/
template<typename _RandomAccessIterator, typename _Compare>
inline void
push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
_Compare __comp)
{
typedef typename iterator_traits<_RandomAccessIterator>::value_type
_ValueType;
typedef typename iterator_traits<_RandomAccessIterator>::difference_type
_DistanceType;
// concept requirements
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_irreflexive_pred(__first, __last, __comp);
__glibcxx_requires_heap_pred(__first, __last - 1, __comp);
__decltype(__gnu_cxx::__ops::__iter_comp_val(_GLIBCXX_MOVE(__comp)))
__cmp(_GLIBCXX_MOVE(__comp));
_ValueType __value = _GLIBCXX_MOVE(*(__last - 1));
std::__push_heap(__first, _DistanceType((__last - __first) - 1),
_DistanceType(0), _GLIBCXX_MOVE(__value), __cmp);
}
template<typename _RandomAccessIterator, typename _Distance,
typename _Tp, typename _Compare>
void
__adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
_Distance __len, _Tp __value, _Compare __comp)
{
const _Distance __topIndex = __holeIndex;
_Distance __secondChild = __holeIndex;
while (__secondChild < (__len - 1) / 2)
{
__secondChild = 2 * (__secondChild + 1);
if (__comp(__first + __secondChild,
__first + (__secondChild - 1)))
__secondChild--;
*(__first + __holeIndex) = _GLIBCXX_MOVE(*(__first + __secondChild));
__holeIndex = __secondChild;
}
if ((__len & 1) == 0 && __secondChild == (__len - 2) / 2)
{
__secondChild = 2 * (__secondChild + 1);
*(__first + __holeIndex) = _GLIBCXX_MOVE(*(__first
+ (__secondChild - 1)));
__holeIndex = __secondChild - 1;
}
__decltype(__gnu_cxx::__ops::__iter_comp_val(_GLIBCXX_MOVE(__comp)))
__cmp(_GLIBCXX_MOVE(__comp));
std::__push_heap(__first, __holeIndex, __topIndex,
_GLIBCXX_MOVE(__value), __cmp);
}
template<typename _RandomAccessIterator, typename _Compare>
inline void
__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
_RandomAccessIterator __result, _Compare& __comp)
{
typedef typename iterator_traits<_RandomAccessIterator>::value_type
_ValueType;
typedef typename iterator_traits<_RandomAccessIterator>::difference_type
_DistanceType;
_ValueType __value = _GLIBCXX_MOVE(*__result);
*__result = _GLIBCXX_MOVE(*__first);
std::__adjust_heap(__first, _DistanceType(0),
_DistanceType(__last - __first),
_GLIBCXX_MOVE(__value), __comp);
}
/**
* @brief Pop an element off a heap.
* @param __first Start of heap.
* @param __last End of heap.
* @pre [__first, __last) is a valid, non-empty range.
* @ingroup heap_algorithms
*
* This operation pops the top of the heap. The elements __first
* and __last-1 are swapped and [__first,__last-1) is made into a
* heap.
*/
template<typename _RandomAccessIterator>
inline void
pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
{
// concept requirements
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>)
__glibcxx_function_requires(_LessThanComparableConcept<
typename iterator_traits<_RandomAccessIterator>::value_type>)
__glibcxx_requires_non_empty_range(__first, __last);
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_irreflexive(__first, __last);
__glibcxx_requires_heap(__first, __last);
if (__last - __first > 1)
{
--__last;
__gnu_cxx::__ops::_Iter_less_iter __comp;
std::__pop_heap(__first, __last, __last, __comp);
}
}
/**
* @brief Pop an element off a heap using comparison functor.
* @param __first Start of heap.
* @param __last End of heap.
* @param __comp Comparison functor to use.
* @ingroup heap_algorithms
*
* This operation pops the top of the heap. The elements __first
* and __last-1 are swapped and [__first,__last-1) is made into a
* heap. Comparisons are made using comp.
*/
template<typename _RandomAccessIterator, typename _Compare>
inline void
pop_heap(_RandomAccessIterator __first,
_RandomAccessIterator __last, _Compare __comp)
{
// concept requirements
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_irreflexive_pred(__first, __last, __comp);
__glibcxx_requires_non_empty_range(__first, __last);
__glibcxx_requires_heap_pred(__first, __last, __comp);
if (__last - __first > 1)
{
typedef __decltype(__comp) _Cmp;
__gnu_cxx::__ops::_Iter_comp_iter<_Cmp> __cmp(_GLIBCXX_MOVE(__comp));
--__last;
std::__pop_heap(__first, __last, __last, __cmp);
}
}
template<typename _RandomAccessIterator, typename _Compare>
void
__make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
_Compare& __comp)
{
typedef typename iterator_traits<_RandomAccessIterator>::value_type
_ValueType;
typedef typename iterator_traits<_RandomAccessIterator>::difference_type
_DistanceType;
if (__last - __first < 2)
return;
const _DistanceType __len = __last - __first;
_DistanceType __parent = (__len - 2) / 2;
while (true)
{
_ValueType __value = _GLIBCXX_MOVE(*(__first + __parent));
std::__adjust_heap(__first, __parent, __len, _GLIBCXX_MOVE(__value),
__comp);
if (__parent == 0)
return;
__parent--;
}
}
/**
* @brief Construct a heap over a range.
* @param __first Start of heap.
* @param __last End of heap.
* @ingroup heap_algorithms
*
* This operation makes the elements in [__first,__last) into a heap.
*/
template<typename _RandomAccessIterator>
inline void
make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
{
// concept requirements
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>)
__glibcxx_function_requires(_LessThanComparableConcept<
typename iterator_traits<_RandomAccessIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_irreflexive(__first, __last);
__gnu_cxx::__ops::_Iter_less_iter __comp;
std::__make_heap(__first, __last, __comp);
}
/**
* @brief Construct a heap over a range using comparison functor.
* @param __first Start of heap.
* @param __last End of heap.
* @param __comp Comparison functor to use.
* @ingroup heap_algorithms
*
* This operation makes the elements in [__first,__last) into a heap.
* Comparisons are made using __comp.
*/
template<typename _RandomAccessIterator, typename _Compare>
inline void
make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
_Compare __comp)
{
// concept requirements
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_irreflexive_pred(__first, __last, __comp);
typedef __decltype(__comp) _Cmp;
__gnu_cxx::__ops::_Iter_comp_iter<_Cmp> __cmp(_GLIBCXX_MOVE(__comp));
std::__make_heap(__first, __last, __cmp);
}
template<typename _RandomAccessIterator, typename _Compare>
void
__sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
_Compare& __comp)
{
while (__last - __first > 1)
{
--__last;
std::__pop_heap(__first, __last, __last, __comp);
}
}
/**
* @brief Sort a heap.
* @param __first Start of heap.
* @param __last End of heap.
* @ingroup heap_algorithms
*
* This operation sorts the valid heap in the range [__first,__last).
*/
template<typename _RandomAccessIterator>
inline void
sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
{
// concept requirements
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>)
__glibcxx_function_requires(_LessThanComparableConcept<
typename iterator_traits<_RandomAccessIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_irreflexive(__first, __last);
__glibcxx_requires_heap(__first, __last);
__gnu_cxx::__ops::_Iter_less_iter __comp;
std::__sort_heap(__first, __last, __comp);
}
/**
* @brief Sort a heap using comparison functor.
* @param __first Start of heap.
* @param __last End of heap.
* @param __comp Comparison functor to use.
* @ingroup heap_algorithms
*
* This operation sorts the valid heap in the range [__first,__last).
* Comparisons are made using __comp.
*/
template<typename _RandomAccessIterator, typename _Compare>
inline void
sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
_Compare __comp)
{
// concept requirements
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_irreflexive_pred(__first, __last, __comp);
__glibcxx_requires_heap_pred(__first, __last, __comp);
typedef __decltype(__comp) _Cmp;
__gnu_cxx::__ops::_Iter_comp_iter<_Cmp> __cmp(_GLIBCXX_MOVE(__comp));
std::__sort_heap(__first, __last, __cmp);
}
#if __cplusplus >= 201103L
/**
* @brief Search the end of a heap.
* @param __first Start of range.
* @param __last End of range.
* @return An iterator pointing to the first element not in the heap.
* @ingroup heap_algorithms
*
* This operation returns the last iterator i in [__first, __last) for which
* the range [__first, i) is a heap.
*/
template<typename _RandomAccessIterator>
inline _RandomAccessIterator
is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last)
{
// concept requirements
__glibcxx_function_requires(_RandomAccessIteratorConcept<
_RandomAccessIterator>)
__glibcxx_function_requires(_LessThanComparableConcept<
typename iterator_traits<_RandomAccessIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_irreflexive(__first, __last);
__gnu_cxx::__ops::_Iter_less_iter __comp;
return __first +
std::__is_heap_until(__first, std::distance(__first, __last), __comp);
}
/**
* @brief Search the end of a heap using comparison functor.
* @param __first Start of range.
* @param __last End of range.
* @param __comp Comparison functor to use.
* @return An iterator pointing to the first element not in the heap.
* @ingroup heap_algorithms
*
* This operation returns the last iterator i in [__first, __last) for which
* the range [__first, i) is a heap. Comparisons are made using __comp.
*/
template<typename _RandomAccessIterator, typename _Compare>
inline _RandomAccessIterator
is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last,
_Compare __comp)
{
// concept requirements
__glibcxx_function_requires(_RandomAccessIteratorConcept<
_RandomAccessIterator>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_irreflexive_pred(__first, __last, __comp);
typedef __decltype(__comp) _Cmp;
__gnu_cxx::__ops::_Iter_comp_iter<_Cmp> __cmp(_GLIBCXX_MOVE(__comp));
return __first
+ std::__is_heap_until(__first, std::distance(__first, __last), __cmp);
}
/**
* @brief Determines whether a range is a heap.
* @param __first Start of range.
* @param __last End of range.
* @return True if range is a heap, false otherwise.
* @ingroup heap_algorithms
*/
template<typename _RandomAccessIterator>
inline bool
is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
{ return std::is_heap_until(__first, __last) == __last; }
/**
* @brief Determines whether a range is a heap using comparison functor.
* @param __first Start of range.
* @param __last End of range.
* @param __comp Comparison functor to use.
* @return True if range is a heap, false otherwise.
* @ingroup heap_algorithms
*/
template<typename _RandomAccessIterator, typename _Compare>
inline bool
is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
_Compare __comp)
{
// concept requirements
__glibcxx_function_requires(_RandomAccessIteratorConcept<
_RandomAccessIterator>)
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_irreflexive_pred(__first, __last, __comp);
const auto __dist = std::distance(__first, __last);
typedef __decltype(__comp) _Cmp;
__gnu_cxx::__ops::_Iter_comp_iter<_Cmp> __cmp(_GLIBCXX_MOVE(__comp));
return std::__is_heap_until(__first, __dist, __cmp) == __dist;
}
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif /* _STL_HEAP_H */
c++/8/bits/exception.h 0000644 00000004350 15201526705 0010400 0 ustar 00 // Exception Handling support header for -*- C++ -*-
// Copyright (C) 2016-2018 Free Software Foundation, Inc.
//
// This file is part of GCC.
//
// GCC is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// GCC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/exception.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly.
*/
#ifndef __EXCEPTION_H
#define __EXCEPTION_H 1
#pragma GCC system_header
#pragma GCC visibility push(default)
#include <bits/c++config.h>
extern "C++" {
namespace std
{
/**
* @defgroup exceptions Exceptions
* @ingroup diagnostics
*
* Classes and functions for reporting errors via exception classes.
* @{
*/
/**
* @brief Base class for all library exceptions.
*
* This is the base class for all exceptions thrown by the standard
* library, and by certain language expressions. You are free to derive
* your own %exception classes, or use a different hierarchy, or to
* throw non-class data (e.g., fundamental types).
*/
class exception
{
public:
exception() _GLIBCXX_USE_NOEXCEPT { }
virtual ~exception() _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_USE_NOEXCEPT;
/** Returns a C-style character string describing the general cause
* of the current error. */
virtual const char*
what() const _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_USE_NOEXCEPT;
};
} // namespace std
}
#pragma GCC visibility pop
#endif
c++/8/bits/stl_numeric.h 0000644 00000033010 15201526705 0010721 0 ustar 00 // Numeric functions implementation -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1996,1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file bits/stl_numeric.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{numeric}
*/
#ifndef _STL_NUMERIC_H
#define _STL_NUMERIC_H 1
#include <bits/concept_check.h>
#include <debug/debug.h>
#include <bits/move.h> // For _GLIBCXX_MOVE
#if __cplusplus >= 201103L
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @brief Create a range of sequentially increasing values.
*
* For each element in the range @p [first,last) assigns @p value and
* increments @p value as if by @p ++value.
*
* @param __first Start of range.
* @param __last End of range.
* @param __value Starting value.
* @return Nothing.
*/
template<typename _ForwardIterator, typename _Tp>
void
iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value)
{
// concept requirements
__glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
_ForwardIterator>)
__glibcxx_function_requires(_ConvertibleConcept<_Tp,
typename iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last);
for (; __first != __last; ++__first)
{
*__first = __value;
++__value;
}
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_ALGO
/**
* @brief Accumulate values in a range.
*
* Accumulates the values in the range [first,last) using operator+(). The
* initial value is @a init. The values are processed in order.
*
* @param __first Start of range.
* @param __last End of range.
* @param __init Starting value to add other values to.
* @return The final sum.
*/
template<typename _InputIterator, typename _Tp>
inline _Tp
accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_requires_valid_range(__first, __last);
for (; __first != __last; ++__first)
__init = __init + *__first;
return __init;
}
/**
* @brief Accumulate values in a range with operation.
*
* Accumulates the values in the range [first,last) using the function
* object @p __binary_op. The initial value is @p __init. The values are
* processed in order.
*
* @param __first Start of range.
* @param __last End of range.
* @param __init Starting value to add other values to.
* @param __binary_op Function object to accumulate with.
* @return The final sum.
*/
template<typename _InputIterator, typename _Tp, typename _BinaryOperation>
inline _Tp
accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,
_BinaryOperation __binary_op)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_requires_valid_range(__first, __last);
for (; __first != __last; ++__first)
__init = __binary_op(__init, *__first);
return __init;
}
/**
* @brief Compute inner product of two ranges.
*
* Starting with an initial value of @p __init, multiplies successive
* elements from the two ranges and adds each product into the accumulated
* value using operator+(). The values in the ranges are processed in
* order.
*
* @param __first1 Start of range 1.
* @param __last1 End of range 1.
* @param __first2 Start of range 2.
* @param __init Starting value to add other values to.
* @return The final inner product.
*/
template<typename _InputIterator1, typename _InputIterator2, typename _Tp>
inline _Tp
inner_product(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _Tp __init)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
__glibcxx_requires_valid_range(__first1, __last1);
for (; __first1 != __last1; ++__first1, (void)++__first2)
__init = __init + (*__first1 * *__first2);
return __init;
}
/**
* @brief Compute inner product of two ranges.
*
* Starting with an initial value of @p __init, applies @p __binary_op2 to
* successive elements from the two ranges and accumulates each result into
* the accumulated value using @p __binary_op1. The values in the ranges are
* processed in order.
*
* @param __first1 Start of range 1.
* @param __last1 End of range 1.
* @param __first2 Start of range 2.
* @param __init Starting value to add other values to.
* @param __binary_op1 Function object to accumulate with.
* @param __binary_op2 Function object to apply to pairs of input values.
* @return The final inner product.
*/
template<typename _InputIterator1, typename _InputIterator2, typename _Tp,
typename _BinaryOperation1, typename _BinaryOperation2>
inline _Tp
inner_product(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _Tp __init,
_BinaryOperation1 __binary_op1,
_BinaryOperation2 __binary_op2)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
__glibcxx_requires_valid_range(__first1, __last1);
for (; __first1 != __last1; ++__first1, (void)++__first2)
__init = __binary_op1(__init, __binary_op2(*__first1, *__first2));
return __init;
}
/**
* @brief Return list of partial sums
*
* Accumulates the values in the range [first,last) using the @c + operator.
* As each successive input value is added into the total, that partial sum
* is written to @p __result. Therefore, the first value in @p __result is
* the first value of the input, the second value in @p __result is the sum
* of the first and second input values, and so on.
*
* @param __first Start of input range.
* @param __last End of input range.
* @param __result Output sum.
* @return Iterator pointing just beyond the values written to __result.
*/
template<typename _InputIterator, typename _OutputIterator>
_OutputIterator
partial_sum(_InputIterator __first, _InputIterator __last,
_OutputIterator __result)
{
typedef typename iterator_traits<_InputIterator>::value_type _ValueType;
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
_ValueType>)
__glibcxx_requires_valid_range(__first, __last);
if (__first == __last)
return __result;
_ValueType __value = *__first;
*__result = __value;
while (++__first != __last)
{
__value = __value + *__first;
*++__result = __value;
}
return ++__result;
}
/**
* @brief Return list of partial sums
*
* Accumulates the values in the range [first,last) using @p __binary_op.
* As each successive input value is added into the total, that partial sum
* is written to @p __result. Therefore, the first value in @p __result is
* the first value of the input, the second value in @p __result is the sum
* of the first and second input values, and so on.
*
* @param __first Start of input range.
* @param __last End of input range.
* @param __result Output sum.
* @param __binary_op Function object.
* @return Iterator pointing just beyond the values written to __result.
*/
template<typename _InputIterator, typename _OutputIterator,
typename _BinaryOperation>
_OutputIterator
partial_sum(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _BinaryOperation __binary_op)
{
typedef typename iterator_traits<_InputIterator>::value_type _ValueType;
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
_ValueType>)
__glibcxx_requires_valid_range(__first, __last);
if (__first == __last)
return __result;
_ValueType __value = *__first;
*__result = __value;
while (++__first != __last)
{
__value = __binary_op(__value, *__first);
*++__result = __value;
}
return ++__result;
}
/**
* @brief Return differences between adjacent values.
*
* Computes the difference between adjacent values in the range
* [first,last) using operator-() and writes the result to @p __result.
*
* @param __first Start of input range.
* @param __last End of input range.
* @param __result Output sums.
* @return Iterator pointing just beyond the values written to result.
*
* _GLIBCXX_RESOLVE_LIB_DEFECTS
* DR 539. partial_sum and adjacent_difference should mention requirements
*/
template<typename _InputIterator, typename _OutputIterator>
_OutputIterator
adjacent_difference(_InputIterator __first,
_InputIterator __last, _OutputIterator __result)
{
typedef typename iterator_traits<_InputIterator>::value_type _ValueType;
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
_ValueType>)
__glibcxx_requires_valid_range(__first, __last);
if (__first == __last)
return __result;
_ValueType __value = *__first;
*__result = __value;
while (++__first != __last)
{
_ValueType __tmp = *__first;
*++__result = __tmp - __value;
__value = _GLIBCXX_MOVE(__tmp);
}
return ++__result;
}
/**
* @brief Return differences between adjacent values.
*
* Computes the difference between adjacent values in the range
* [__first,__last) using the function object @p __binary_op and writes the
* result to @p __result.
*
* @param __first Start of input range.
* @param __last End of input range.
* @param __result Output sum.
* @param __binary_op Function object.
* @return Iterator pointing just beyond the values written to result.
*
* _GLIBCXX_RESOLVE_LIB_DEFECTS
* DR 539. partial_sum and adjacent_difference should mention requirements
*/
template<typename _InputIterator, typename _OutputIterator,
typename _BinaryOperation>
_OutputIterator
adjacent_difference(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _BinaryOperation __binary_op)
{
typedef typename iterator_traits<_InputIterator>::value_type _ValueType;
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
_ValueType>)
__glibcxx_requires_valid_range(__first, __last);
if (__first == __last)
return __result;
_ValueType __value = *__first;
*__result = __value;
while (++__first != __last)
{
_ValueType __tmp = *__first;
*++__result = __binary_op(__tmp, __value);
__value = _GLIBCXX_MOVE(__tmp);
}
return ++__result;
}
_GLIBCXX_END_NAMESPACE_ALGO
} // namespace std
#endif /* _STL_NUMERIC_H */
c++/8/bits/hash_bytes.h 0000644 00000004142 15201526705 0010532 0 ustar 00 // Declarations for hash functions. -*- C++ -*-
// Copyright (C) 2010-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/hash_bytes.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{functional}
*/
#ifndef _HASH_BYTES_H
#define _HASH_BYTES_H 1
#pragma GCC system_header
#include <bits/c++config.h>
namespace std
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Hash function implementation for the nontrivial specialization.
// All of them are based on a primitive that hashes a pointer to a
// byte array. The actual hash algorithm is not guaranteed to stay
// the same from release to release -- it may be updated or tuned to
// improve hash quality or speed.
size_t
_Hash_bytes(const void* __ptr, size_t __len, size_t __seed);
// A similar hash primitive, using the FNV hash algorithm. This
// algorithm is guaranteed to stay the same from release to release.
// (although it might not produce the same values on different
// machines.)
size_t
_Fnv_hash_bytes(const void* __ptr, size_t __len, size_t __seed);
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/bits/stl_pair.h 0000644 00000044322 15201526705 0010222 0 ustar 00 // Pair implementation -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1996,1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file bits/stl_pair.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{utility}
*/
#ifndef _STL_PAIR_H
#define _STL_PAIR_H 1
#include <bits/move.h> // for std::move / std::forward, and std::swap
#if __cplusplus >= 201103L
#include <type_traits> // for std::__decay_and_strip too
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @addtogroup utilities
* @{
*/
#if __cplusplus >= 201103L
/// piecewise_construct_t
struct piecewise_construct_t { explicit piecewise_construct_t() = default; };
/// piecewise_construct
_GLIBCXX17_INLINE constexpr piecewise_construct_t piecewise_construct =
piecewise_construct_t();
// Forward declarations.
template<typename...>
class tuple;
template<std::size_t...>
struct _Index_tuple;
// Concept utility functions, reused in conditionally-explicit
// constructors.
// See PR 70437, don't look at is_constructible or
// is_convertible if the types are the same to
// avoid querying those properties for incomplete types.
template <bool, typename _T1, typename _T2>
struct _PCC
{
template <typename _U1, typename _U2>
static constexpr bool _ConstructiblePair()
{
return __and_<is_constructible<_T1, const _U1&>,
is_constructible<_T2, const _U2&>>::value;
}
template <typename _U1, typename _U2>
static constexpr bool _ImplicitlyConvertiblePair()
{
return __and_<is_convertible<const _U1&, _T1>,
is_convertible<const _U2&, _T2>>::value;
}
template <typename _U1, typename _U2>
static constexpr bool _MoveConstructiblePair()
{
return __and_<is_constructible<_T1, _U1&&>,
is_constructible<_T2, _U2&&>>::value;
}
template <typename _U1, typename _U2>
static constexpr bool _ImplicitlyMoveConvertiblePair()
{
return __and_<is_convertible<_U1&&, _T1>,
is_convertible<_U2&&, _T2>>::value;
}
template <bool __implicit, typename _U1, typename _U2>
static constexpr bool _CopyMovePair()
{
using __do_converts = __and_<is_convertible<const _U1&, _T1>,
is_convertible<_U2&&, _T2>>;
using __converts = typename conditional<__implicit,
__do_converts,
__not_<__do_converts>>::type;
return __and_<is_constructible<_T1, const _U1&>,
is_constructible<_T2, _U2&&>,
__converts
>::value;
}
template <bool __implicit, typename _U1, typename _U2>
static constexpr bool _MoveCopyPair()
{
using __do_converts = __and_<is_convertible<_U1&&, _T1>,
is_convertible<const _U2&, _T2>>;
using __converts = typename conditional<__implicit,
__do_converts,
__not_<__do_converts>>::type;
return __and_<is_constructible<_T1, _U1&&>,
is_constructible<_T2, const _U2&&>,
__converts
>::value;
}
};
template <typename _T1, typename _T2>
struct _PCC<false, _T1, _T2>
{
template <typename _U1, typename _U2>
static constexpr bool _ConstructiblePair()
{
return false;
}
template <typename _U1, typename _U2>
static constexpr bool _ImplicitlyConvertiblePair()
{
return false;
}
template <typename _U1, typename _U2>
static constexpr bool _MoveConstructiblePair()
{
return false;
}
template <typename _U1, typename _U2>
static constexpr bool _ImplicitlyMoveConvertiblePair()
{
return false;
}
};
// PR libstdc++/79141, a utility type for preventing
// initialization of an argument of a disabled assignment
// operator from a pair of empty braces.
struct __nonesuch_no_braces : std::__nonesuch {
explicit __nonesuch_no_braces(const __nonesuch&) = delete;
};
#endif // C++11
template<typename _U1, typename _U2> class __pair_base
{
#if __cplusplus >= 201103L
template<typename _T1, typename _T2> friend struct pair;
__pair_base() = default;
~__pair_base() = default;
__pair_base(const __pair_base&) = default;
__pair_base& operator=(const __pair_base&) = delete;
#endif // C++11
};
/**
* @brief Struct holding two objects of arbitrary type.
*
* @tparam _T1 Type of first object.
* @tparam _T2 Type of second object.
*/
template<typename _T1, typename _T2>
struct pair
: private __pair_base<_T1, _T2>
{
typedef _T1 first_type; /// @c first_type is the first bound type
typedef _T2 second_type; /// @c second_type is the second bound type
_T1 first; /// @c first is a copy of the first object
_T2 second; /// @c second is a copy of the second object
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 265. std::pair::pair() effects overly restrictive
/** The default constructor creates @c first and @c second using their
* respective default constructors. */
#if __cplusplus >= 201103L
template <typename _U1 = _T1,
typename _U2 = _T2,
typename enable_if<__and_<
__is_implicitly_default_constructible<_U1>,
__is_implicitly_default_constructible<_U2>>
::value, bool>::type = true>
#endif
_GLIBCXX_CONSTEXPR pair()
: first(), second() { }
#if __cplusplus >= 201103L
template <typename _U1 = _T1,
typename _U2 = _T2,
typename enable_if<__and_<
is_default_constructible<_U1>,
is_default_constructible<_U2>,
__not_<
__and_<__is_implicitly_default_constructible<_U1>,
__is_implicitly_default_constructible<_U2>>>>
::value, bool>::type = false>
explicit constexpr pair()
: first(), second() { }
#endif
/** Two objects may be passed to a @c pair constructor to be copied. */
#if __cplusplus < 201103L
pair(const _T1& __a, const _T2& __b)
: first(__a), second(__b) { }
#else
// Shortcut for constraining the templates that don't take pairs.
using _PCCP = _PCC<true, _T1, _T2>;
template<typename _U1 = _T1, typename _U2=_T2, typename
enable_if<_PCCP::template
_ConstructiblePair<_U1, _U2>()
&& _PCCP::template
_ImplicitlyConvertiblePair<_U1, _U2>(),
bool>::type=true>
constexpr pair(const _T1& __a, const _T2& __b)
: first(__a), second(__b) { }
template<typename _U1 = _T1, typename _U2=_T2, typename
enable_if<_PCCP::template
_ConstructiblePair<_U1, _U2>()
&& !_PCCP::template
_ImplicitlyConvertiblePair<_U1, _U2>(),
bool>::type=false>
explicit constexpr pair(const _T1& __a, const _T2& __b)
: first(__a), second(__b) { }
#endif
/** There is also a templated copy ctor for the @c pair class itself. */
#if __cplusplus < 201103L
template<typename _U1, typename _U2>
pair(const pair<_U1, _U2>& __p)
: first(__p.first), second(__p.second) { }
#else
// Shortcut for constraining the templates that take pairs.
template <typename _U1, typename _U2>
using _PCCFP = _PCC<!is_same<_T1, _U1>::value
|| !is_same<_T2, _U2>::value,
_T1, _T2>;
template<typename _U1, typename _U2, typename
enable_if<_PCCFP<_U1, _U2>::template
_ConstructiblePair<_U1, _U2>()
&& _PCCFP<_U1, _U2>::template
_ImplicitlyConvertiblePair<_U1, _U2>(),
bool>::type=true>
constexpr pair(const pair<_U1, _U2>& __p)
: first(__p.first), second(__p.second) { }
template<typename _U1, typename _U2, typename
enable_if<_PCCFP<_U1, _U2>::template
_ConstructiblePair<_U1, _U2>()
&& !_PCCFP<_U1, _U2>::template
_ImplicitlyConvertiblePair<_U1, _U2>(),
bool>::type=false>
explicit constexpr pair(const pair<_U1, _U2>& __p)
: first(__p.first), second(__p.second) { }
constexpr pair(const pair&) = default;
constexpr pair(pair&&) = default;
// DR 811.
template<typename _U1, typename
enable_if<_PCCP::template
_MoveCopyPair<true, _U1, _T2>(),
bool>::type=true>
constexpr pair(_U1&& __x, const _T2& __y)
: first(std::forward<_U1>(__x)), second(__y) { }
template<typename _U1, typename
enable_if<_PCCP::template
_MoveCopyPair<false, _U1, _T2>(),
bool>::type=false>
explicit constexpr pair(_U1&& __x, const _T2& __y)
: first(std::forward<_U1>(__x)), second(__y) { }
template<typename _U2, typename
enable_if<_PCCP::template
_CopyMovePair<true, _T1, _U2>(),
bool>::type=true>
constexpr pair(const _T1& __x, _U2&& __y)
: first(__x), second(std::forward<_U2>(__y)) { }
template<typename _U2, typename
enable_if<_PCCP::template
_CopyMovePair<false, _T1, _U2>(),
bool>::type=false>
explicit pair(const _T1& __x, _U2&& __y)
: first(__x), second(std::forward<_U2>(__y)) { }
template<typename _U1, typename _U2, typename
enable_if<_PCCP::template
_MoveConstructiblePair<_U1, _U2>()
&& _PCCP::template
_ImplicitlyMoveConvertiblePair<_U1, _U2>(),
bool>::type=true>
constexpr pair(_U1&& __x, _U2&& __y)
: first(std::forward<_U1>(__x)), second(std::forward<_U2>(__y)) { }
template<typename _U1, typename _U2, typename
enable_if<_PCCP::template
_MoveConstructiblePair<_U1, _U2>()
&& !_PCCP::template
_ImplicitlyMoveConvertiblePair<_U1, _U2>(),
bool>::type=false>
explicit constexpr pair(_U1&& __x, _U2&& __y)
: first(std::forward<_U1>(__x)), second(std::forward<_U2>(__y)) { }
template<typename _U1, typename _U2, typename
enable_if<_PCCFP<_U1, _U2>::template
_MoveConstructiblePair<_U1, _U2>()
&& _PCCFP<_U1, _U2>::template
_ImplicitlyMoveConvertiblePair<_U1, _U2>(),
bool>::type=true>
constexpr pair(pair<_U1, _U2>&& __p)
: first(std::forward<_U1>(__p.first)),
second(std::forward<_U2>(__p.second)) { }
template<typename _U1, typename _U2, typename
enable_if<_PCCFP<_U1, _U2>::template
_MoveConstructiblePair<_U1, _U2>()
&& !_PCCFP<_U1, _U2>::template
_ImplicitlyMoveConvertiblePair<_U1, _U2>(),
bool>::type=false>
explicit constexpr pair(pair<_U1, _U2>&& __p)
: first(std::forward<_U1>(__p.first)),
second(std::forward<_U2>(__p.second)) { }
template<typename... _Args1, typename... _Args2>
pair(piecewise_construct_t, tuple<_Args1...>, tuple<_Args2...>);
pair&
operator=(typename conditional<
__and_<is_copy_assignable<_T1>,
is_copy_assignable<_T2>>::value,
const pair&, const __nonesuch_no_braces&>::type __p)
{
first = __p.first;
second = __p.second;
return *this;
}
pair&
operator=(typename conditional<
__and_<is_move_assignable<_T1>,
is_move_assignable<_T2>>::value,
pair&&, __nonesuch_no_braces&&>::type __p)
noexcept(__and_<is_nothrow_move_assignable<_T1>,
is_nothrow_move_assignable<_T2>>::value)
{
first = std::forward<first_type>(__p.first);
second = std::forward<second_type>(__p.second);
return *this;
}
template<typename _U1, typename _U2>
typename enable_if<__and_<is_assignable<_T1&, const _U1&>,
is_assignable<_T2&, const _U2&>>::value,
pair&>::type
operator=(const pair<_U1, _U2>& __p)
{
first = __p.first;
second = __p.second;
return *this;
}
template<typename _U1, typename _U2>
typename enable_if<__and_<is_assignable<_T1&, _U1&&>,
is_assignable<_T2&, _U2&&>>::value,
pair&>::type
operator=(pair<_U1, _U2>&& __p)
{
first = std::forward<_U1>(__p.first);
second = std::forward<_U2>(__p.second);
return *this;
}
void
swap(pair& __p)
noexcept(__and_<__is_nothrow_swappable<_T1>,
__is_nothrow_swappable<_T2>>::value)
{
using std::swap;
swap(first, __p.first);
swap(second, __p.second);
}
private:
template<typename... _Args1, std::size_t... _Indexes1,
typename... _Args2, std::size_t... _Indexes2>
pair(tuple<_Args1...>&, tuple<_Args2...>&,
_Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>);
#endif
};
#if __cpp_deduction_guides >= 201606
template<typename _T1, typename _T2> pair(_T1, _T2) -> pair<_T1, _T2>;
#endif
/// Two pairs of the same type are equal iff their members are equal.
template<typename _T1, typename _T2>
inline _GLIBCXX_CONSTEXPR bool
operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
{ return __x.first == __y.first && __x.second == __y.second; }
/// <http://gcc.gnu.org/onlinedocs/libstdc++/manual/utilities.html>
template<typename _T1, typename _T2>
inline _GLIBCXX_CONSTEXPR bool
operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
{ return __x.first < __y.first
|| (!(__y.first < __x.first) && __x.second < __y.second); }
/// Uses @c operator== to find the result.
template<typename _T1, typename _T2>
inline _GLIBCXX_CONSTEXPR bool
operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
{ return !(__x == __y); }
/// Uses @c operator< to find the result.
template<typename _T1, typename _T2>
inline _GLIBCXX_CONSTEXPR bool
operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
{ return __y < __x; }
/// Uses @c operator< to find the result.
template<typename _T1, typename _T2>
inline _GLIBCXX_CONSTEXPR bool
operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
{ return !(__y < __x); }
/// Uses @c operator< to find the result.
template<typename _T1, typename _T2>
inline _GLIBCXX_CONSTEXPR bool
operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
{ return !(__x < __y); }
#if __cplusplus >= 201103L
/// See std::pair::swap().
// Note: no std::swap overloads in C++03 mode, this has performance
// implications, see, eg, libstdc++/38466.
template<typename _T1, typename _T2>
inline
#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
// Constrained free swap overload, see p0185r1
typename enable_if<__and_<__is_swappable<_T1>,
__is_swappable<_T2>>::value>::type
#else
void
#endif
swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
noexcept(noexcept(__x.swap(__y)))
{ __x.swap(__y); }
#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
template<typename _T1, typename _T2>
typename enable_if<!__and_<__is_swappable<_T1>,
__is_swappable<_T2>>::value>::type
swap(pair<_T1, _T2>&, pair<_T1, _T2>&) = delete;
#endif
#endif // __cplusplus >= 201103L
/**
* @brief A convenience wrapper for creating a pair from two objects.
* @param __x The first object.
* @param __y The second object.
* @return A newly-constructed pair<> object of the appropriate type.
*
* The standard requires that the objects be passed by reference-to-const,
* but LWG issue #181 says they should be passed by const value. We follow
* the LWG by default.
*/
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 181. make_pair() unintended behavior
#if __cplusplus >= 201103L
// NB: DR 706.
template<typename _T1, typename _T2>
constexpr pair<typename __decay_and_strip<_T1>::__type,
typename __decay_and_strip<_T2>::__type>
make_pair(_T1&& __x, _T2&& __y)
{
typedef typename __decay_and_strip<_T1>::__type __ds_type1;
typedef typename __decay_and_strip<_T2>::__type __ds_type2;
typedef pair<__ds_type1, __ds_type2> __pair_type;
return __pair_type(std::forward<_T1>(__x), std::forward<_T2>(__y));
}
#else
template<typename _T1, typename _T2>
inline pair<_T1, _T2>
make_pair(_T1 __x, _T2 __y)
{ return pair<_T1, _T2>(__x, __y); }
#endif
/// @}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif /* _STL_PAIR_H */
c++/8/bits/atomic_base.h 0000644 00000056442 15201526705 0010661 0 ustar 00 // -*- C++ -*- header.
// Copyright (C) 2008-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/atomic_base.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{atomic}
*/
#ifndef _GLIBCXX_ATOMIC_BASE_H
#define _GLIBCXX_ATOMIC_BASE_H 1
#pragma GCC system_header
#include <bits/c++config.h>
#include <stdint.h>
#include <bits/atomic_lockfree_defines.h>
#ifndef _GLIBCXX_ALWAYS_INLINE
#define _GLIBCXX_ALWAYS_INLINE inline __attribute__((__always_inline__))
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @defgroup atomics Atomics
*
* Components for performing atomic operations.
* @{
*/
/// Enumeration for memory_order
typedef enum memory_order
{
memory_order_relaxed,
memory_order_consume,
memory_order_acquire,
memory_order_release,
memory_order_acq_rel,
memory_order_seq_cst
} memory_order;
enum __memory_order_modifier
{
__memory_order_mask = 0x0ffff,
__memory_order_modifier_mask = 0xffff0000,
__memory_order_hle_acquire = 0x10000,
__memory_order_hle_release = 0x20000
};
constexpr memory_order
operator|(memory_order __m, __memory_order_modifier __mod)
{
return memory_order(__m | int(__mod));
}
constexpr memory_order
operator&(memory_order __m, __memory_order_modifier __mod)
{
return memory_order(__m & int(__mod));
}
// Drop release ordering as per [atomics.types.operations.req]/21
constexpr memory_order
__cmpexch_failure_order2(memory_order __m) noexcept
{
return __m == memory_order_acq_rel ? memory_order_acquire
: __m == memory_order_release ? memory_order_relaxed : __m;
}
constexpr memory_order
__cmpexch_failure_order(memory_order __m) noexcept
{
return memory_order(__cmpexch_failure_order2(__m & __memory_order_mask)
| (__m & __memory_order_modifier_mask));
}
_GLIBCXX_ALWAYS_INLINE void
atomic_thread_fence(memory_order __m) noexcept
{ __atomic_thread_fence(__m); }
_GLIBCXX_ALWAYS_INLINE void
atomic_signal_fence(memory_order __m) noexcept
{ __atomic_signal_fence(__m); }
/// kill_dependency
template<typename _Tp>
inline _Tp
kill_dependency(_Tp __y) noexcept
{
_Tp __ret(__y);
return __ret;
}
// Base types for atomics.
template<typename _IntTp>
struct __atomic_base;
#define ATOMIC_VAR_INIT(_VI) { _VI }
template<typename _Tp>
struct atomic;
template<typename _Tp>
struct atomic<_Tp*>;
/* The target's "set" value for test-and-set may not be exactly 1. */
#if __GCC_ATOMIC_TEST_AND_SET_TRUEVAL == 1
typedef bool __atomic_flag_data_type;
#else
typedef unsigned char __atomic_flag_data_type;
#endif
/**
* @brief Base type for atomic_flag.
*
* Base type is POD with data, allowing atomic_flag to derive from
* it and meet the standard layout type requirement. In addition to
* compatibility with a C interface, this allows different
* implementations of atomic_flag to use the same atomic operation
* functions, via a standard conversion to the __atomic_flag_base
* argument.
*/
_GLIBCXX_BEGIN_EXTERN_C
struct __atomic_flag_base
{
__atomic_flag_data_type _M_i;
};
_GLIBCXX_END_EXTERN_C
#define ATOMIC_FLAG_INIT { 0 }
/// atomic_flag
struct atomic_flag : public __atomic_flag_base
{
atomic_flag() noexcept = default;
~atomic_flag() noexcept = default;
atomic_flag(const atomic_flag&) = delete;
atomic_flag& operator=(const atomic_flag&) = delete;
atomic_flag& operator=(const atomic_flag&) volatile = delete;
// Conversion to ATOMIC_FLAG_INIT.
constexpr atomic_flag(bool __i) noexcept
: __atomic_flag_base{ _S_init(__i) }
{ }
_GLIBCXX_ALWAYS_INLINE bool
test_and_set(memory_order __m = memory_order_seq_cst) noexcept
{
return __atomic_test_and_set (&_M_i, __m);
}
_GLIBCXX_ALWAYS_INLINE bool
test_and_set(memory_order __m = memory_order_seq_cst) volatile noexcept
{
return __atomic_test_and_set (&_M_i, __m);
}
_GLIBCXX_ALWAYS_INLINE void
clear(memory_order __m = memory_order_seq_cst) noexcept
{
memory_order __b = __m & __memory_order_mask;
__glibcxx_assert(__b != memory_order_consume);
__glibcxx_assert(__b != memory_order_acquire);
__glibcxx_assert(__b != memory_order_acq_rel);
__atomic_clear (&_M_i, __m);
}
_GLIBCXX_ALWAYS_INLINE void
clear(memory_order __m = memory_order_seq_cst) volatile noexcept
{
memory_order __b = __m & __memory_order_mask;
__glibcxx_assert(__b != memory_order_consume);
__glibcxx_assert(__b != memory_order_acquire);
__glibcxx_assert(__b != memory_order_acq_rel);
__atomic_clear (&_M_i, __m);
}
private:
static constexpr __atomic_flag_data_type
_S_init(bool __i)
{ return __i ? __GCC_ATOMIC_TEST_AND_SET_TRUEVAL : 0; }
};
/// Base class for atomic integrals.
//
// For each of the integral types, define atomic_[integral type] struct
//
// atomic_bool bool
// atomic_char char
// atomic_schar signed char
// atomic_uchar unsigned char
// atomic_short short
// atomic_ushort unsigned short
// atomic_int int
// atomic_uint unsigned int
// atomic_long long
// atomic_ulong unsigned long
// atomic_llong long long
// atomic_ullong unsigned long long
// atomic_char16_t char16_t
// atomic_char32_t char32_t
// atomic_wchar_t wchar_t
//
// NB: Assuming _ITp is an integral scalar type that is 1, 2, 4, or
// 8 bytes, since that is what GCC built-in functions for atomic
// memory access expect.
template<typename _ITp>
struct __atomic_base
{
private:
typedef _ITp __int_type;
static constexpr int _S_alignment =
sizeof(_ITp) > alignof(_ITp) ? sizeof(_ITp) : alignof(_ITp);
alignas(_S_alignment) __int_type _M_i;
public:
__atomic_base() noexcept = default;
~__atomic_base() noexcept = default;
__atomic_base(const __atomic_base&) = delete;
__atomic_base& operator=(const __atomic_base&) = delete;
__atomic_base& operator=(const __atomic_base&) volatile = delete;
// Requires __int_type convertible to _M_i.
constexpr __atomic_base(__int_type __i) noexcept : _M_i (__i) { }
operator __int_type() const noexcept
{ return load(); }
operator __int_type() const volatile noexcept
{ return load(); }
__int_type
operator=(__int_type __i) noexcept
{
store(__i);
return __i;
}
__int_type
operator=(__int_type __i) volatile noexcept
{
store(__i);
return __i;
}
__int_type
operator++(int) noexcept
{ return fetch_add(1); }
__int_type
operator++(int) volatile noexcept
{ return fetch_add(1); }
__int_type
operator--(int) noexcept
{ return fetch_sub(1); }
__int_type
operator--(int) volatile noexcept
{ return fetch_sub(1); }
__int_type
operator++() noexcept
{ return __atomic_add_fetch(&_M_i, 1, memory_order_seq_cst); }
__int_type
operator++() volatile noexcept
{ return __atomic_add_fetch(&_M_i, 1, memory_order_seq_cst); }
__int_type
operator--() noexcept
{ return __atomic_sub_fetch(&_M_i, 1, memory_order_seq_cst); }
__int_type
operator--() volatile noexcept
{ return __atomic_sub_fetch(&_M_i, 1, memory_order_seq_cst); }
__int_type
operator+=(__int_type __i) noexcept
{ return __atomic_add_fetch(&_M_i, __i, memory_order_seq_cst); }
__int_type
operator+=(__int_type __i) volatile noexcept
{ return __atomic_add_fetch(&_M_i, __i, memory_order_seq_cst); }
__int_type
operator-=(__int_type __i) noexcept
{ return __atomic_sub_fetch(&_M_i, __i, memory_order_seq_cst); }
__int_type
operator-=(__int_type __i) volatile noexcept
{ return __atomic_sub_fetch(&_M_i, __i, memory_order_seq_cst); }
__int_type
operator&=(__int_type __i) noexcept
{ return __atomic_and_fetch(&_M_i, __i, memory_order_seq_cst); }
__int_type
operator&=(__int_type __i) volatile noexcept
{ return __atomic_and_fetch(&_M_i, __i, memory_order_seq_cst); }
__int_type
operator|=(__int_type __i) noexcept
{ return __atomic_or_fetch(&_M_i, __i, memory_order_seq_cst); }
__int_type
operator|=(__int_type __i) volatile noexcept
{ return __atomic_or_fetch(&_M_i, __i, memory_order_seq_cst); }
__int_type
operator^=(__int_type __i) noexcept
{ return __atomic_xor_fetch(&_M_i, __i, memory_order_seq_cst); }
__int_type
operator^=(__int_type __i) volatile noexcept
{ return __atomic_xor_fetch(&_M_i, __i, memory_order_seq_cst); }
bool
is_lock_free() const noexcept
{
// Use a fake, minimally aligned pointer.
return __atomic_is_lock_free(sizeof(_M_i),
reinterpret_cast<void *>(-__alignof(_M_i)));
}
bool
is_lock_free() const volatile noexcept
{
// Use a fake, minimally aligned pointer.
return __atomic_is_lock_free(sizeof(_M_i),
reinterpret_cast<void *>(-__alignof(_M_i)));
}
_GLIBCXX_ALWAYS_INLINE void
store(__int_type __i, memory_order __m = memory_order_seq_cst) noexcept
{
memory_order __b = __m & __memory_order_mask;
__glibcxx_assert(__b != memory_order_acquire);
__glibcxx_assert(__b != memory_order_acq_rel);
__glibcxx_assert(__b != memory_order_consume);
__atomic_store_n(&_M_i, __i, __m);
}
_GLIBCXX_ALWAYS_INLINE void
store(__int_type __i,
memory_order __m = memory_order_seq_cst) volatile noexcept
{
memory_order __b = __m & __memory_order_mask;
__glibcxx_assert(__b != memory_order_acquire);
__glibcxx_assert(__b != memory_order_acq_rel);
__glibcxx_assert(__b != memory_order_consume);
__atomic_store_n(&_M_i, __i, __m);
}
_GLIBCXX_ALWAYS_INLINE __int_type
load(memory_order __m = memory_order_seq_cst) const noexcept
{
memory_order __b = __m & __memory_order_mask;
__glibcxx_assert(__b != memory_order_release);
__glibcxx_assert(__b != memory_order_acq_rel);
return __atomic_load_n(&_M_i, __m);
}
_GLIBCXX_ALWAYS_INLINE __int_type
load(memory_order __m = memory_order_seq_cst) const volatile noexcept
{
memory_order __b = __m & __memory_order_mask;
__glibcxx_assert(__b != memory_order_release);
__glibcxx_assert(__b != memory_order_acq_rel);
return __atomic_load_n(&_M_i, __m);
}
_GLIBCXX_ALWAYS_INLINE __int_type
exchange(__int_type __i,
memory_order __m = memory_order_seq_cst) noexcept
{
return __atomic_exchange_n(&_M_i, __i, __m);
}
_GLIBCXX_ALWAYS_INLINE __int_type
exchange(__int_type __i,
memory_order __m = memory_order_seq_cst) volatile noexcept
{
return __atomic_exchange_n(&_M_i, __i, __m);
}
_GLIBCXX_ALWAYS_INLINE bool
compare_exchange_weak(__int_type& __i1, __int_type __i2,
memory_order __m1, memory_order __m2) noexcept
{
memory_order __b2 = __m2 & __memory_order_mask;
memory_order __b1 = __m1 & __memory_order_mask;
__glibcxx_assert(__b2 != memory_order_release);
__glibcxx_assert(__b2 != memory_order_acq_rel);
__glibcxx_assert(__b2 <= __b1);
return __atomic_compare_exchange_n(&_M_i, &__i1, __i2, 1, __m1, __m2);
}
_GLIBCXX_ALWAYS_INLINE bool
compare_exchange_weak(__int_type& __i1, __int_type __i2,
memory_order __m1,
memory_order __m2) volatile noexcept
{
memory_order __b2 = __m2 & __memory_order_mask;
memory_order __b1 = __m1 & __memory_order_mask;
__glibcxx_assert(__b2 != memory_order_release);
__glibcxx_assert(__b2 != memory_order_acq_rel);
__glibcxx_assert(__b2 <= __b1);
return __atomic_compare_exchange_n(&_M_i, &__i1, __i2, 1, __m1, __m2);
}
_GLIBCXX_ALWAYS_INLINE bool
compare_exchange_weak(__int_type& __i1, __int_type __i2,
memory_order __m = memory_order_seq_cst) noexcept
{
return compare_exchange_weak(__i1, __i2, __m,
__cmpexch_failure_order(__m));
}
_GLIBCXX_ALWAYS_INLINE bool
compare_exchange_weak(__int_type& __i1, __int_type __i2,
memory_order __m = memory_order_seq_cst) volatile noexcept
{
return compare_exchange_weak(__i1, __i2, __m,
__cmpexch_failure_order(__m));
}
_GLIBCXX_ALWAYS_INLINE bool
compare_exchange_strong(__int_type& __i1, __int_type __i2,
memory_order __m1, memory_order __m2) noexcept
{
memory_order __b2 = __m2 & __memory_order_mask;
memory_order __b1 = __m1 & __memory_order_mask;
__glibcxx_assert(__b2 != memory_order_release);
__glibcxx_assert(__b2 != memory_order_acq_rel);
__glibcxx_assert(__b2 <= __b1);
return __atomic_compare_exchange_n(&_M_i, &__i1, __i2, 0, __m1, __m2);
}
_GLIBCXX_ALWAYS_INLINE bool
compare_exchange_strong(__int_type& __i1, __int_type __i2,
memory_order __m1,
memory_order __m2) volatile noexcept
{
memory_order __b2 = __m2 & __memory_order_mask;
memory_order __b1 = __m1 & __memory_order_mask;
__glibcxx_assert(__b2 != memory_order_release);
__glibcxx_assert(__b2 != memory_order_acq_rel);
__glibcxx_assert(__b2 <= __b1);
return __atomic_compare_exchange_n(&_M_i, &__i1, __i2, 0, __m1, __m2);
}
_GLIBCXX_ALWAYS_INLINE bool
compare_exchange_strong(__int_type& __i1, __int_type __i2,
memory_order __m = memory_order_seq_cst) noexcept
{
return compare_exchange_strong(__i1, __i2, __m,
__cmpexch_failure_order(__m));
}
_GLIBCXX_ALWAYS_INLINE bool
compare_exchange_strong(__int_type& __i1, __int_type __i2,
memory_order __m = memory_order_seq_cst) volatile noexcept
{
return compare_exchange_strong(__i1, __i2, __m,
__cmpexch_failure_order(__m));
}
_GLIBCXX_ALWAYS_INLINE __int_type
fetch_add(__int_type __i,
memory_order __m = memory_order_seq_cst) noexcept
{ return __atomic_fetch_add(&_M_i, __i, __m); }
_GLIBCXX_ALWAYS_INLINE __int_type
fetch_add(__int_type __i,
memory_order __m = memory_order_seq_cst) volatile noexcept
{ return __atomic_fetch_add(&_M_i, __i, __m); }
_GLIBCXX_ALWAYS_INLINE __int_type
fetch_sub(__int_type __i,
memory_order __m = memory_order_seq_cst) noexcept
{ return __atomic_fetch_sub(&_M_i, __i, __m); }
_GLIBCXX_ALWAYS_INLINE __int_type
fetch_sub(__int_type __i,
memory_order __m = memory_order_seq_cst) volatile noexcept
{ return __atomic_fetch_sub(&_M_i, __i, __m); }
_GLIBCXX_ALWAYS_INLINE __int_type
fetch_and(__int_type __i,
memory_order __m = memory_order_seq_cst) noexcept
{ return __atomic_fetch_and(&_M_i, __i, __m); }
_GLIBCXX_ALWAYS_INLINE __int_type
fetch_and(__int_type __i,
memory_order __m = memory_order_seq_cst) volatile noexcept
{ return __atomic_fetch_and(&_M_i, __i, __m); }
_GLIBCXX_ALWAYS_INLINE __int_type
fetch_or(__int_type __i,
memory_order __m = memory_order_seq_cst) noexcept
{ return __atomic_fetch_or(&_M_i, __i, __m); }
_GLIBCXX_ALWAYS_INLINE __int_type
fetch_or(__int_type __i,
memory_order __m = memory_order_seq_cst) volatile noexcept
{ return __atomic_fetch_or(&_M_i, __i, __m); }
_GLIBCXX_ALWAYS_INLINE __int_type
fetch_xor(__int_type __i,
memory_order __m = memory_order_seq_cst) noexcept
{ return __atomic_fetch_xor(&_M_i, __i, __m); }
_GLIBCXX_ALWAYS_INLINE __int_type
fetch_xor(__int_type __i,
memory_order __m = memory_order_seq_cst) volatile noexcept
{ return __atomic_fetch_xor(&_M_i, __i, __m); }
};
/// Partial specialization for pointer types.
template<typename _PTp>
struct __atomic_base<_PTp*>
{
private:
typedef _PTp* __pointer_type;
__pointer_type _M_p;
// Factored out to facilitate explicit specialization.
constexpr ptrdiff_t
_M_type_size(ptrdiff_t __d) const { return __d * sizeof(_PTp); }
constexpr ptrdiff_t
_M_type_size(ptrdiff_t __d) const volatile { return __d * sizeof(_PTp); }
public:
__atomic_base() noexcept = default;
~__atomic_base() noexcept = default;
__atomic_base(const __atomic_base&) = delete;
__atomic_base& operator=(const __atomic_base&) = delete;
__atomic_base& operator=(const __atomic_base&) volatile = delete;
// Requires __pointer_type convertible to _M_p.
constexpr __atomic_base(__pointer_type __p) noexcept : _M_p (__p) { }
operator __pointer_type() const noexcept
{ return load(); }
operator __pointer_type() const volatile noexcept
{ return load(); }
__pointer_type
operator=(__pointer_type __p) noexcept
{
store(__p);
return __p;
}
__pointer_type
operator=(__pointer_type __p) volatile noexcept
{
store(__p);
return __p;
}
__pointer_type
operator++(int) noexcept
{ return fetch_add(1); }
__pointer_type
operator++(int) volatile noexcept
{ return fetch_add(1); }
__pointer_type
operator--(int) noexcept
{ return fetch_sub(1); }
__pointer_type
operator--(int) volatile noexcept
{ return fetch_sub(1); }
__pointer_type
operator++() noexcept
{ return __atomic_add_fetch(&_M_p, _M_type_size(1),
memory_order_seq_cst); }
__pointer_type
operator++() volatile noexcept
{ return __atomic_add_fetch(&_M_p, _M_type_size(1),
memory_order_seq_cst); }
__pointer_type
operator--() noexcept
{ return __atomic_sub_fetch(&_M_p, _M_type_size(1),
memory_order_seq_cst); }
__pointer_type
operator--() volatile noexcept
{ return __atomic_sub_fetch(&_M_p, _M_type_size(1),
memory_order_seq_cst); }
__pointer_type
operator+=(ptrdiff_t __d) noexcept
{ return __atomic_add_fetch(&_M_p, _M_type_size(__d),
memory_order_seq_cst); }
__pointer_type
operator+=(ptrdiff_t __d) volatile noexcept
{ return __atomic_add_fetch(&_M_p, _M_type_size(__d),
memory_order_seq_cst); }
__pointer_type
operator-=(ptrdiff_t __d) noexcept
{ return __atomic_sub_fetch(&_M_p, _M_type_size(__d),
memory_order_seq_cst); }
__pointer_type
operator-=(ptrdiff_t __d) volatile noexcept
{ return __atomic_sub_fetch(&_M_p, _M_type_size(__d),
memory_order_seq_cst); }
bool
is_lock_free() const noexcept
{
// Produce a fake, minimally aligned pointer.
return __atomic_is_lock_free(sizeof(_M_p),
reinterpret_cast<void *>(-__alignof(_M_p)));
}
bool
is_lock_free() const volatile noexcept
{
// Produce a fake, minimally aligned pointer.
return __atomic_is_lock_free(sizeof(_M_p),
reinterpret_cast<void *>(-__alignof(_M_p)));
}
_GLIBCXX_ALWAYS_INLINE void
store(__pointer_type __p,
memory_order __m = memory_order_seq_cst) noexcept
{
memory_order __b = __m & __memory_order_mask;
__glibcxx_assert(__b != memory_order_acquire);
__glibcxx_assert(__b != memory_order_acq_rel);
__glibcxx_assert(__b != memory_order_consume);
__atomic_store_n(&_M_p, __p, __m);
}
_GLIBCXX_ALWAYS_INLINE void
store(__pointer_type __p,
memory_order __m = memory_order_seq_cst) volatile noexcept
{
memory_order __b = __m & __memory_order_mask;
__glibcxx_assert(__b != memory_order_acquire);
__glibcxx_assert(__b != memory_order_acq_rel);
__glibcxx_assert(__b != memory_order_consume);
__atomic_store_n(&_M_p, __p, __m);
}
_GLIBCXX_ALWAYS_INLINE __pointer_type
load(memory_order __m = memory_order_seq_cst) const noexcept
{
memory_order __b = __m & __memory_order_mask;
__glibcxx_assert(__b != memory_order_release);
__glibcxx_assert(__b != memory_order_acq_rel);
return __atomic_load_n(&_M_p, __m);
}
_GLIBCXX_ALWAYS_INLINE __pointer_type
load(memory_order __m = memory_order_seq_cst) const volatile noexcept
{
memory_order __b = __m & __memory_order_mask;
__glibcxx_assert(__b != memory_order_release);
__glibcxx_assert(__b != memory_order_acq_rel);
return __atomic_load_n(&_M_p, __m);
}
_GLIBCXX_ALWAYS_INLINE __pointer_type
exchange(__pointer_type __p,
memory_order __m = memory_order_seq_cst) noexcept
{
return __atomic_exchange_n(&_M_p, __p, __m);
}
_GLIBCXX_ALWAYS_INLINE __pointer_type
exchange(__pointer_type __p,
memory_order __m = memory_order_seq_cst) volatile noexcept
{
return __atomic_exchange_n(&_M_p, __p, __m);
}
_GLIBCXX_ALWAYS_INLINE bool
compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2,
memory_order __m1,
memory_order __m2) noexcept
{
memory_order __b2 = __m2 & __memory_order_mask;
memory_order __b1 = __m1 & __memory_order_mask;
__glibcxx_assert(__b2 != memory_order_release);
__glibcxx_assert(__b2 != memory_order_acq_rel);
__glibcxx_assert(__b2 <= __b1);
return __atomic_compare_exchange_n(&_M_p, &__p1, __p2, 0, __m1, __m2);
}
_GLIBCXX_ALWAYS_INLINE bool
compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2,
memory_order __m1,
memory_order __m2) volatile noexcept
{
memory_order __b2 = __m2 & __memory_order_mask;
memory_order __b1 = __m1 & __memory_order_mask;
__glibcxx_assert(__b2 != memory_order_release);
__glibcxx_assert(__b2 != memory_order_acq_rel);
__glibcxx_assert(__b2 <= __b1);
return __atomic_compare_exchange_n(&_M_p, &__p1, __p2, 0, __m1, __m2);
}
_GLIBCXX_ALWAYS_INLINE __pointer_type
fetch_add(ptrdiff_t __d,
memory_order __m = memory_order_seq_cst) noexcept
{ return __atomic_fetch_add(&_M_p, _M_type_size(__d), __m); }
_GLIBCXX_ALWAYS_INLINE __pointer_type
fetch_add(ptrdiff_t __d,
memory_order __m = memory_order_seq_cst) volatile noexcept
{ return __atomic_fetch_add(&_M_p, _M_type_size(__d), __m); }
_GLIBCXX_ALWAYS_INLINE __pointer_type
fetch_sub(ptrdiff_t __d,
memory_order __m = memory_order_seq_cst) noexcept
{ return __atomic_fetch_sub(&_M_p, _M_type_size(__d), __m); }
_GLIBCXX_ALWAYS_INLINE __pointer_type
fetch_sub(ptrdiff_t __d,
memory_order __m = memory_order_seq_cst) volatile noexcept
{ return __atomic_fetch_sub(&_M_p, _M_type_size(__d), __m); }
};
// @} group atomics
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif
c++/8/bits/stl_iterator_base_types.h 0000644 00000020750 15201526705 0013335 0 ustar 00 // Types used in iterator implementation -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1996-1998
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file bits/stl_iterator_base_types.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{iterator}
*
* This file contains all of the general iterator-related utility types,
* such as iterator_traits and struct iterator.
*/
#ifndef _STL_ITERATOR_BASE_TYPES_H
#define _STL_ITERATOR_BASE_TYPES_H 1
#pragma GCC system_header
#include <bits/c++config.h>
#if __cplusplus >= 201103L
# include <type_traits> // For __void_t, is_convertible
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @defgroup iterators Iterators
* Abstractions for uniform iterating through various underlying types.
*/
//@{
/**
* @defgroup iterator_tags Iterator Tags
* These are empty types, used to distinguish different iterators. The
* distinction is not made by what they contain, but simply by what they
* are. Different underlying algorithms can then be used based on the
* different operations supported by different iterator types.
*/
//@{
/// Marking input iterators.
struct input_iterator_tag { };
/// Marking output iterators.
struct output_iterator_tag { };
/// Forward iterators support a superset of input iterator operations.
struct forward_iterator_tag : public input_iterator_tag { };
/// Bidirectional iterators support a superset of forward iterator
/// operations.
struct bidirectional_iterator_tag : public forward_iterator_tag { };
/// Random-access iterators support a superset of bidirectional
/// iterator operations.
struct random_access_iterator_tag : public bidirectional_iterator_tag { };
//@}
/**
* @brief Common %iterator class.
*
* This class does nothing but define nested typedefs. %Iterator classes
* can inherit from this class to save some work. The typedefs are then
* used in specializations and overloading.
*
* In particular, there are no default implementations of requirements
* such as @c operator++ and the like. (How could there be?)
*/
template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t,
typename _Pointer = _Tp*, typename _Reference = _Tp&>
struct iterator
{
/// One of the @link iterator_tags tag types@endlink.
typedef _Category iterator_category;
/// The type "pointed to" by the iterator.
typedef _Tp value_type;
/// Distance between iterators is represented as this type.
typedef _Distance difference_type;
/// This type represents a pointer-to-value_type.
typedef _Pointer pointer;
/// This type represents a reference-to-value_type.
typedef _Reference reference;
};
/**
* @brief Traits class for iterators.
*
* This class does nothing but define nested typedefs. The general
* version simply @a forwards the nested typedefs from the Iterator
* argument. Specialized versions for pointers and pointers-to-const
* provide tighter, more correct semantics.
*/
#if __cplusplus >= 201103L
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2408. SFINAE-friendly common_type/iterator_traits is missing in C++14
template<typename _Iterator, typename = __void_t<>>
struct __iterator_traits { };
template<typename _Iterator>
struct __iterator_traits<_Iterator,
__void_t<typename _Iterator::iterator_category,
typename _Iterator::value_type,
typename _Iterator::difference_type,
typename _Iterator::pointer,
typename _Iterator::reference>>
{
typedef typename _Iterator::iterator_category iterator_category;
typedef typename _Iterator::value_type value_type;
typedef typename _Iterator::difference_type difference_type;
typedef typename _Iterator::pointer pointer;
typedef typename _Iterator::reference reference;
};
template<typename _Iterator>
struct iterator_traits
: public __iterator_traits<_Iterator> { };
#else
template<typename _Iterator>
struct iterator_traits
{
typedef typename _Iterator::iterator_category iterator_category;
typedef typename _Iterator::value_type value_type;
typedef typename _Iterator::difference_type difference_type;
typedef typename _Iterator::pointer pointer;
typedef typename _Iterator::reference reference;
};
#endif
/// Partial specialization for pointer types.
template<typename _Tp>
struct iterator_traits<_Tp*>
{
typedef random_access_iterator_tag iterator_category;
typedef _Tp value_type;
typedef ptrdiff_t difference_type;
typedef _Tp* pointer;
typedef _Tp& reference;
};
/// Partial specialization for const pointer types.
template<typename _Tp>
struct iterator_traits<const _Tp*>
{
typedef random_access_iterator_tag iterator_category;
typedef _Tp value_type;
typedef ptrdiff_t difference_type;
typedef const _Tp* pointer;
typedef const _Tp& reference;
};
/**
* This function is not a part of the C++ standard but is syntactic
* sugar for internal library use only.
*/
template<typename _Iter>
inline _GLIBCXX_CONSTEXPR
typename iterator_traits<_Iter>::iterator_category
__iterator_category(const _Iter&)
{ return typename iterator_traits<_Iter>::iterator_category(); }
//@}
#if __cplusplus < 201103L
// If _Iterator has a base returns it otherwise _Iterator is returned
// untouched
template<typename _Iterator, bool _HasBase>
struct _Iter_base
{
typedef _Iterator iterator_type;
static iterator_type _S_base(_Iterator __it)
{ return __it; }
};
template<typename _Iterator>
struct _Iter_base<_Iterator, true>
{
typedef typename _Iterator::iterator_type iterator_type;
static iterator_type _S_base(_Iterator __it)
{ return __it.base(); }
};
#endif
#if __cplusplus >= 201103L
template<typename _InIter>
using _RequireInputIter = typename
enable_if<is_convertible<typename
iterator_traits<_InIter>::iterator_category,
input_iterator_tag>::value>::type;
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif /* _STL_ITERATOR_BASE_TYPES_H */
c++/8/bits/locale_facets_nonio.h 0000644 00000206564 15201526705 0012403 0 ustar 00 // Locale support -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/locale_facets_nonio.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{locale}
*/
//
// ISO C++ 14882: 22.1 Locales
//
#ifndef _LOCALE_FACETS_NONIO_H
#define _LOCALE_FACETS_NONIO_H 1
#pragma GCC system_header
#include <ctime> // For struct tm
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @brief Time format ordering data.
* @ingroup locales
*
* This class provides an enum representing different orderings of
* time: day, month, and year.
*/
class time_base
{
public:
enum dateorder { no_order, dmy, mdy, ymd, ydm };
};
template<typename _CharT>
struct __timepunct_cache : public locale::facet
{
// List of all known timezones, with GMT first.
static const _CharT* _S_timezones[14];
const _CharT* _M_date_format;
const _CharT* _M_date_era_format;
const _CharT* _M_time_format;
const _CharT* _M_time_era_format;
const _CharT* _M_date_time_format;
const _CharT* _M_date_time_era_format;
const _CharT* _M_am;
const _CharT* _M_pm;
const _CharT* _M_am_pm_format;
// Day names, starting with "C"'s Sunday.
const _CharT* _M_day1;
const _CharT* _M_day2;
const _CharT* _M_day3;
const _CharT* _M_day4;
const _CharT* _M_day5;
const _CharT* _M_day6;
const _CharT* _M_day7;
// Abbreviated day names, starting with "C"'s Sun.
const _CharT* _M_aday1;
const _CharT* _M_aday2;
const _CharT* _M_aday3;
const _CharT* _M_aday4;
const _CharT* _M_aday5;
const _CharT* _M_aday6;
const _CharT* _M_aday7;
// Month names, starting with "C"'s January.
const _CharT* _M_month01;
const _CharT* _M_month02;
const _CharT* _M_month03;
const _CharT* _M_month04;
const _CharT* _M_month05;
const _CharT* _M_month06;
const _CharT* _M_month07;
const _CharT* _M_month08;
const _CharT* _M_month09;
const _CharT* _M_month10;
const _CharT* _M_month11;
const _CharT* _M_month12;
// Abbreviated month names, starting with "C"'s Jan.
const _CharT* _M_amonth01;
const _CharT* _M_amonth02;
const _CharT* _M_amonth03;
const _CharT* _M_amonth04;
const _CharT* _M_amonth05;
const _CharT* _M_amonth06;
const _CharT* _M_amonth07;
const _CharT* _M_amonth08;
const _CharT* _M_amonth09;
const _CharT* _M_amonth10;
const _CharT* _M_amonth11;
const _CharT* _M_amonth12;
bool _M_allocated;
__timepunct_cache(size_t __refs = 0) : facet(__refs),
_M_date_format(0), _M_date_era_format(0), _M_time_format(0),
_M_time_era_format(0), _M_date_time_format(0),
_M_date_time_era_format(0), _M_am(0), _M_pm(0),
_M_am_pm_format(0), _M_day1(0), _M_day2(0), _M_day3(0),
_M_day4(0), _M_day5(0), _M_day6(0), _M_day7(0),
_M_aday1(0), _M_aday2(0), _M_aday3(0), _M_aday4(0),
_M_aday5(0), _M_aday6(0), _M_aday7(0), _M_month01(0),
_M_month02(0), _M_month03(0), _M_month04(0), _M_month05(0),
_M_month06(0), _M_month07(0), _M_month08(0), _M_month09(0),
_M_month10(0), _M_month11(0), _M_month12(0), _M_amonth01(0),
_M_amonth02(0), _M_amonth03(0), _M_amonth04(0),
_M_amonth05(0), _M_amonth06(0), _M_amonth07(0),
_M_amonth08(0), _M_amonth09(0), _M_amonth10(0),
_M_amonth11(0), _M_amonth12(0), _M_allocated(false)
{ }
~__timepunct_cache();
private:
__timepunct_cache&
operator=(const __timepunct_cache&);
explicit
__timepunct_cache(const __timepunct_cache&);
};
template<typename _CharT>
__timepunct_cache<_CharT>::~__timepunct_cache()
{
if (_M_allocated)
{
// Unused.
}
}
// Specializations.
template<>
const char*
__timepunct_cache<char>::_S_timezones[14];
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
const wchar_t*
__timepunct_cache<wchar_t>::_S_timezones[14];
#endif
// Generic.
template<typename _CharT>
const _CharT* __timepunct_cache<_CharT>::_S_timezones[14];
template<typename _CharT>
class __timepunct : public locale::facet
{
public:
// Types:
typedef _CharT __char_type;
typedef __timepunct_cache<_CharT> __cache_type;
protected:
__cache_type* _M_data;
__c_locale _M_c_locale_timepunct;
const char* _M_name_timepunct;
public:
/// Numpunct facet id.
static locale::id id;
explicit
__timepunct(size_t __refs = 0);
explicit
__timepunct(__cache_type* __cache, size_t __refs = 0);
/**
* @brief Internal constructor. Not for general use.
*
* This is a constructor for use by the library itself to set up new
* locales.
*
* @param __cloc The C locale.
* @param __s The name of a locale.
* @param refs Passed to the base facet class.
*/
explicit
__timepunct(__c_locale __cloc, const char* __s, size_t __refs = 0);
// FIXME: for error checking purposes _M_put should return the return
// value of strftime/wcsftime.
void
_M_put(_CharT* __s, size_t __maxlen, const _CharT* __format,
const tm* __tm) const throw ();
void
_M_date_formats(const _CharT** __date) const
{
// Always have default first.
__date[0] = _M_data->_M_date_format;
__date[1] = _M_data->_M_date_era_format;
}
void
_M_time_formats(const _CharT** __time) const
{
// Always have default first.
__time[0] = _M_data->_M_time_format;
__time[1] = _M_data->_M_time_era_format;
}
void
_M_date_time_formats(const _CharT** __dt) const
{
// Always have default first.
__dt[0] = _M_data->_M_date_time_format;
__dt[1] = _M_data->_M_date_time_era_format;
}
#if !_GLIBCXX_INLINE_VERSION
void
_M_am_pm_format(const _CharT*) const
{ /* Kept for ABI compatibility, see PR65927 */ }
#endif
void
_M_am_pm(const _CharT** __ampm) const
{
__ampm[0] = _M_data->_M_am;
__ampm[1] = _M_data->_M_pm;
}
void
_M_days(const _CharT** __days) const
{
__days[0] = _M_data->_M_day1;
__days[1] = _M_data->_M_day2;
__days[2] = _M_data->_M_day3;
__days[3] = _M_data->_M_day4;
__days[4] = _M_data->_M_day5;
__days[5] = _M_data->_M_day6;
__days[6] = _M_data->_M_day7;
}
void
_M_days_abbreviated(const _CharT** __days) const
{
__days[0] = _M_data->_M_aday1;
__days[1] = _M_data->_M_aday2;
__days[2] = _M_data->_M_aday3;
__days[3] = _M_data->_M_aday4;
__days[4] = _M_data->_M_aday5;
__days[5] = _M_data->_M_aday6;
__days[6] = _M_data->_M_aday7;
}
void
_M_months(const _CharT** __months) const
{
__months[0] = _M_data->_M_month01;
__months[1] = _M_data->_M_month02;
__months[2] = _M_data->_M_month03;
__months[3] = _M_data->_M_month04;
__months[4] = _M_data->_M_month05;
__months[5] = _M_data->_M_month06;
__months[6] = _M_data->_M_month07;
__months[7] = _M_data->_M_month08;
__months[8] = _M_data->_M_month09;
__months[9] = _M_data->_M_month10;
__months[10] = _M_data->_M_month11;
__months[11] = _M_data->_M_month12;
}
void
_M_months_abbreviated(const _CharT** __months) const
{
__months[0] = _M_data->_M_amonth01;
__months[1] = _M_data->_M_amonth02;
__months[2] = _M_data->_M_amonth03;
__months[3] = _M_data->_M_amonth04;
__months[4] = _M_data->_M_amonth05;
__months[5] = _M_data->_M_amonth06;
__months[6] = _M_data->_M_amonth07;
__months[7] = _M_data->_M_amonth08;
__months[8] = _M_data->_M_amonth09;
__months[9] = _M_data->_M_amonth10;
__months[10] = _M_data->_M_amonth11;
__months[11] = _M_data->_M_amonth12;
}
protected:
virtual
~__timepunct();
// For use at construction time only.
void
_M_initialize_timepunct(__c_locale __cloc = 0);
};
template<typename _CharT>
locale::id __timepunct<_CharT>::id;
// Specializations.
template<>
void
__timepunct<char>::_M_initialize_timepunct(__c_locale __cloc);
template<>
void
__timepunct<char>::_M_put(char*, size_t, const char*, const tm*) const throw ();
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
void
__timepunct<wchar_t>::_M_initialize_timepunct(__c_locale __cloc);
template<>
void
__timepunct<wchar_t>::_M_put(wchar_t*, size_t, const wchar_t*,
const tm*) const throw ();
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
// Include host and configuration specific timepunct functions.
#include <bits/time_members.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_BEGIN_NAMESPACE_CXX11
/**
* @brief Primary class template time_get.
* @ingroup locales
*
* This facet encapsulates the code to parse and return a date or
* time from a string. It is used by the istream numeric
* extraction operators.
*
* The time_get template uses protected virtual functions to provide the
* actual results. The public accessors forward the call to the virtual
* functions. These virtual functions are hooks for developers to
* implement the behavior they require from the time_get facet.
*/
template<typename _CharT, typename _InIter>
class time_get : public locale::facet, public time_base
{
public:
// Types:
//@{
/// Public typedefs
typedef _CharT char_type;
typedef _InIter iter_type;
//@}
/// Numpunct facet id.
static locale::id id;
/**
* @brief Constructor performs initialization.
*
* This is the constructor provided by the standard.
*
* @param __refs Passed to the base facet class.
*/
explicit
time_get(size_t __refs = 0)
: facet (__refs) { }
/**
* @brief Return preferred order of month, day, and year.
*
* This function returns an enum from time_base::dateorder giving the
* preferred ordering if the format @a x given to time_put::put() only
* uses month, day, and year. If the format @a x for the associated
* locale uses other fields, this function returns
* time_base::dateorder::noorder.
*
* NOTE: The library always returns noorder at the moment.
*
* @return A member of time_base::dateorder.
*/
dateorder
date_order() const
{ return this->do_date_order(); }
/**
* @brief Parse input time string.
*
* This function parses a time according to the format @a X and puts the
* results into a user-supplied struct tm. The result is returned by
* calling time_get::do_get_time().
*
* If there is a valid time string according to format @a X, @a tm will
* be filled in accordingly and the returned iterator will point to the
* first character beyond the time string. If an error occurs before
* the end, err |= ios_base::failbit. If parsing reads all the
* characters, err |= ios_base::eofbit.
*
* @param __beg Start of string to parse.
* @param __end End of string to parse.
* @param __io Source of the locale.
* @param __err Error flags to set.
* @param __tm Pointer to struct tm to fill in.
* @return Iterator to first char beyond time string.
*/
iter_type
get_time(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, tm* __tm) const
{ return this->do_get_time(__beg, __end, __io, __err, __tm); }
/**
* @brief Parse input date string.
*
* This function parses a date according to the format @a x and puts the
* results into a user-supplied struct tm. The result is returned by
* calling time_get::do_get_date().
*
* If there is a valid date string according to format @a x, @a tm will
* be filled in accordingly and the returned iterator will point to the
* first character beyond the date string. If an error occurs before
* the end, err |= ios_base::failbit. If parsing reads all the
* characters, err |= ios_base::eofbit.
*
* @param __beg Start of string to parse.
* @param __end End of string to parse.
* @param __io Source of the locale.
* @param __err Error flags to set.
* @param __tm Pointer to struct tm to fill in.
* @return Iterator to first char beyond date string.
*/
iter_type
get_date(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, tm* __tm) const
{ return this->do_get_date(__beg, __end, __io, __err, __tm); }
/**
* @brief Parse input weekday string.
*
* This function parses a weekday name and puts the results into a
* user-supplied struct tm. The result is returned by calling
* time_get::do_get_weekday().
*
* Parsing starts by parsing an abbreviated weekday name. If a valid
* abbreviation is followed by a character that would lead to the full
* weekday name, parsing continues until the full name is found or an
* error occurs. Otherwise parsing finishes at the end of the
* abbreviated name.
*
* If an error occurs before the end, err |= ios_base::failbit. If
* parsing reads all the characters, err |= ios_base::eofbit.
*
* @param __beg Start of string to parse.
* @param __end End of string to parse.
* @param __io Source of the locale.
* @param __err Error flags to set.
* @param __tm Pointer to struct tm to fill in.
* @return Iterator to first char beyond weekday name.
*/
iter_type
get_weekday(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, tm* __tm) const
{ return this->do_get_weekday(__beg, __end, __io, __err, __tm); }
/**
* @brief Parse input month string.
*
* This function parses a month name and puts the results into a
* user-supplied struct tm. The result is returned by calling
* time_get::do_get_monthname().
*
* Parsing starts by parsing an abbreviated month name. If a valid
* abbreviation is followed by a character that would lead to the full
* month name, parsing continues until the full name is found or an
* error occurs. Otherwise parsing finishes at the end of the
* abbreviated name.
*
* If an error occurs before the end, err |= ios_base::failbit. If
* parsing reads all the characters, err |=
* ios_base::eofbit.
*
* @param __beg Start of string to parse.
* @param __end End of string to parse.
* @param __io Source of the locale.
* @param __err Error flags to set.
* @param __tm Pointer to struct tm to fill in.
* @return Iterator to first char beyond month name.
*/
iter_type
get_monthname(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, tm* __tm) const
{ return this->do_get_monthname(__beg, __end, __io, __err, __tm); }
/**
* @brief Parse input year string.
*
* This function reads up to 4 characters to parse a year string and
* puts the results into a user-supplied struct tm. The result is
* returned by calling time_get::do_get_year().
*
* 4 consecutive digits are interpreted as a full year. If there are
* exactly 2 consecutive digits, the library interprets this as the
* number of years since 1900.
*
* If an error occurs before the end, err |= ios_base::failbit. If
* parsing reads all the characters, err |= ios_base::eofbit.
*
* @param __beg Start of string to parse.
* @param __end End of string to parse.
* @param __io Source of the locale.
* @param __err Error flags to set.
* @param __tm Pointer to struct tm to fill in.
* @return Iterator to first char beyond year.
*/
iter_type
get_year(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, tm* __tm) const
{ return this->do_get_year(__beg, __end, __io, __err, __tm); }
#if __cplusplus >= 201103L
/**
* @brief Parse input string according to format.
*
* This function calls time_get::do_get with the provided
* parameters. @see do_get() and get().
*
* @param __s Start of string to parse.
* @param __end End of string to parse.
* @param __io Source of the locale.
* @param __err Error flags to set.
* @param __tm Pointer to struct tm to fill in.
* @param __format Format specifier.
* @param __modifier Format modifier.
* @return Iterator to first char not parsed.
*/
inline
iter_type get(iter_type __s, iter_type __end, ios_base& __io,
ios_base::iostate& __err, tm* __tm, char __format,
char __modifier = 0) const
{
return this->do_get(__s, __end, __io, __err, __tm, __format,
__modifier);
}
/**
* @brief Parse input string according to format.
*
* This function parses the input string according to a
* provided format string. It does the inverse of
* time_put::put. The format string follows the format
* specified for strftime(3)/strptime(3). The actual parsing
* is done by time_get::do_get.
*
* @param __s Start of string to parse.
* @param __end End of string to parse.
* @param __io Source of the locale.
* @param __err Error flags to set.
* @param __tm Pointer to struct tm to fill in.
* @param __fmt Start of the format string.
* @param __fmtend End of the format string.
* @return Iterator to first char not parsed.
*/
iter_type get(iter_type __s, iter_type __end, ios_base& __io,
ios_base::iostate& __err, tm* __tm, const char_type* __fmt,
const char_type* __fmtend) const;
#endif // __cplusplus >= 201103L
protected:
/// Destructor.
virtual
~time_get() { }
/**
* @brief Return preferred order of month, day, and year.
*
* This function returns an enum from time_base::dateorder giving the
* preferred ordering if the format @a x given to time_put::put() only
* uses month, day, and year. This function is a hook for derived
* classes to change the value returned.
*
* @return A member of time_base::dateorder.
*/
virtual dateorder
do_date_order() const;
/**
* @brief Parse input time string.
*
* This function parses a time according to the format @a x and puts the
* results into a user-supplied struct tm. This function is a hook for
* derived classes to change the value returned. @see get_time() for
* details.
*
* @param __beg Start of string to parse.
* @param __end End of string to parse.
* @param __io Source of the locale.
* @param __err Error flags to set.
* @param __tm Pointer to struct tm to fill in.
* @return Iterator to first char beyond time string.
*/
virtual iter_type
do_get_time(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, tm* __tm) const;
/**
* @brief Parse input date string.
*
* This function parses a date according to the format @a X and puts the
* results into a user-supplied struct tm. This function is a hook for
* derived classes to change the value returned. @see get_date() for
* details.
*
* @param __beg Start of string to parse.
* @param __end End of string to parse.
* @param __io Source of the locale.
* @param __err Error flags to set.
* @param __tm Pointer to struct tm to fill in.
* @return Iterator to first char beyond date string.
*/
virtual iter_type
do_get_date(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, tm* __tm) const;
/**
* @brief Parse input weekday string.
*
* This function parses a weekday name and puts the results into a
* user-supplied struct tm. This function is a hook for derived
* classes to change the value returned. @see get_weekday() for
* details.
*
* @param __beg Start of string to parse.
* @param __end End of string to parse.
* @param __io Source of the locale.
* @param __err Error flags to set.
* @param __tm Pointer to struct tm to fill in.
* @return Iterator to first char beyond weekday name.
*/
virtual iter_type
do_get_weekday(iter_type __beg, iter_type __end, ios_base&,
ios_base::iostate& __err, tm* __tm) const;
/**
* @brief Parse input month string.
*
* This function parses a month name and puts the results into a
* user-supplied struct tm. This function is a hook for derived
* classes to change the value returned. @see get_monthname() for
* details.
*
* @param __beg Start of string to parse.
* @param __end End of string to parse.
* @param __io Source of the locale.
* @param __err Error flags to set.
* @param __tm Pointer to struct tm to fill in.
* @return Iterator to first char beyond month name.
*/
virtual iter_type
do_get_monthname(iter_type __beg, iter_type __end, ios_base&,
ios_base::iostate& __err, tm* __tm) const;
/**
* @brief Parse input year string.
*
* This function reads up to 4 characters to parse a year string and
* puts the results into a user-supplied struct tm. This function is a
* hook for derived classes to change the value returned. @see
* get_year() for details.
*
* @param __beg Start of string to parse.
* @param __end End of string to parse.
* @param __io Source of the locale.
* @param __err Error flags to set.
* @param __tm Pointer to struct tm to fill in.
* @return Iterator to first char beyond year.
*/
virtual iter_type
do_get_year(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, tm* __tm) const;
#if __cplusplus >= 201103L
/**
* @brief Parse input string according to format.
*
* This function parses the string according to the provided
* format and optional modifier. This function is a hook for
* derived classes to change the value returned. @see get()
* for more details.
*
* @param __s Start of string to parse.
* @param __end End of string to parse.
* @param __f Source of the locale.
* @param __err Error flags to set.
* @param __tm Pointer to struct tm to fill in.
* @param __format Format specifier.
* @param __modifier Format modifier.
* @return Iterator to first char not parsed.
*/
#if _GLIBCXX_USE_CXX11_ABI
virtual
#endif
iter_type
do_get(iter_type __s, iter_type __end, ios_base& __f,
ios_base::iostate& __err, tm* __tm,
char __format, char __modifier) const;
#endif // __cplusplus >= 201103L
// Extract numeric component of length __len.
iter_type
_M_extract_num(iter_type __beg, iter_type __end, int& __member,
int __min, int __max, size_t __len,
ios_base& __io, ios_base::iostate& __err) const;
// Extract any unique array of string literals in a const _CharT* array.
iter_type
_M_extract_name(iter_type __beg, iter_type __end, int& __member,
const _CharT** __names, size_t __indexlen,
ios_base& __io, ios_base::iostate& __err) const;
// Extract day or month name in a const _CharT* array.
iter_type
_M_extract_wday_or_month(iter_type __beg, iter_type __end, int& __member,
const _CharT** __names, size_t __indexlen,
ios_base& __io, ios_base::iostate& __err) const;
// Extract on a component-by-component basis, via __format argument.
iter_type
_M_extract_via_format(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, tm* __tm,
const _CharT* __format) const;
};
template<typename _CharT, typename _InIter>
locale::id time_get<_CharT, _InIter>::id;
/// class time_get_byname [22.2.5.2].
template<typename _CharT, typename _InIter>
class time_get_byname : public time_get<_CharT, _InIter>
{
public:
// Types:
typedef _CharT char_type;
typedef _InIter iter_type;
explicit
time_get_byname(const char*, size_t __refs = 0)
: time_get<_CharT, _InIter>(__refs) { }
#if __cplusplus >= 201103L
explicit
time_get_byname(const string& __s, size_t __refs = 0)
: time_get_byname(__s.c_str(), __refs) { }
#endif
protected:
virtual
~time_get_byname() { }
};
_GLIBCXX_END_NAMESPACE_CXX11
/**
* @brief Primary class template time_put.
* @ingroup locales
*
* This facet encapsulates the code to format and output dates and times
* according to formats used by strftime().
*
* The time_put template uses protected virtual functions to provide the
* actual results. The public accessors forward the call to the virtual
* functions. These virtual functions are hooks for developers to
* implement the behavior they require from the time_put facet.
*/
template<typename _CharT, typename _OutIter>
class time_put : public locale::facet
{
public:
// Types:
//@{
/// Public typedefs
typedef _CharT char_type;
typedef _OutIter iter_type;
//@}
/// Numpunct facet id.
static locale::id id;
/**
* @brief Constructor performs initialization.
*
* This is the constructor provided by the standard.
*
* @param __refs Passed to the base facet class.
*/
explicit
time_put(size_t __refs = 0)
: facet(__refs) { }
/**
* @brief Format and output a time or date.
*
* This function formats the data in struct tm according to the
* provided format string. The format string is interpreted as by
* strftime().
*
* @param __s The stream to write to.
* @param __io Source of locale.
* @param __fill char_type to use for padding.
* @param __tm Struct tm with date and time info to format.
* @param __beg Start of format string.
* @param __end End of format string.
* @return Iterator after writing.
*/
iter_type
put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm,
const _CharT* __beg, const _CharT* __end) const;
/**
* @brief Format and output a time or date.
*
* This function formats the data in struct tm according to the
* provided format char and optional modifier. The format and modifier
* are interpreted as by strftime(). It does so by returning
* time_put::do_put().
*
* @param __s The stream to write to.
* @param __io Source of locale.
* @param __fill char_type to use for padding.
* @param __tm Struct tm with date and time info to format.
* @param __format Format char.
* @param __mod Optional modifier char.
* @return Iterator after writing.
*/
iter_type
put(iter_type __s, ios_base& __io, char_type __fill,
const tm* __tm, char __format, char __mod = 0) const
{ return this->do_put(__s, __io, __fill, __tm, __format, __mod); }
protected:
/// Destructor.
virtual
~time_put()
{ }
/**
* @brief Format and output a time or date.
*
* This function formats the data in struct tm according to the
* provided format char and optional modifier. This function is a hook
* for derived classes to change the value returned. @see put() for
* more details.
*
* @param __s The stream to write to.
* @param __io Source of locale.
* @param __fill char_type to use for padding.
* @param __tm Struct tm with date and time info to format.
* @param __format Format char.
* @param __mod Optional modifier char.
* @return Iterator after writing.
*/
virtual iter_type
do_put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm,
char __format, char __mod) const;
};
template<typename _CharT, typename _OutIter>
locale::id time_put<_CharT, _OutIter>::id;
/// class time_put_byname [22.2.5.4].
template<typename _CharT, typename _OutIter>
class time_put_byname : public time_put<_CharT, _OutIter>
{
public:
// Types:
typedef _CharT char_type;
typedef _OutIter iter_type;
explicit
time_put_byname(const char*, size_t __refs = 0)
: time_put<_CharT, _OutIter>(__refs)
{ }
#if __cplusplus >= 201103L
explicit
time_put_byname(const string& __s, size_t __refs = 0)
: time_put_byname(__s.c_str(), __refs) { }
#endif
protected:
virtual
~time_put_byname() { }
};
/**
* @brief Money format ordering data.
* @ingroup locales
*
* This class contains an ordered array of 4 fields to represent the
* pattern for formatting a money amount. Each field may contain one entry
* from the part enum. symbol, sign, and value must be present and the
* remaining field must contain either none or space. @see
* moneypunct::pos_format() and moneypunct::neg_format() for details of how
* these fields are interpreted.
*/
class money_base
{
public:
enum part { none, space, symbol, sign, value };
struct pattern { char field[4]; };
static const pattern _S_default_pattern;
enum
{
_S_minus,
_S_zero,
_S_end = 11
};
// String literal of acceptable (narrow) input/output, for
// money_get/money_put. "-0123456789"
static const char* _S_atoms;
// Construct and return valid pattern consisting of some combination of:
// space none symbol sign value
_GLIBCXX_CONST static pattern
_S_construct_pattern(char __precedes, char __space, char __posn) throw ();
};
template<typename _CharT, bool _Intl>
struct __moneypunct_cache : public locale::facet
{
const char* _M_grouping;
size_t _M_grouping_size;
bool _M_use_grouping;
_CharT _M_decimal_point;
_CharT _M_thousands_sep;
const _CharT* _M_curr_symbol;
size_t _M_curr_symbol_size;
const _CharT* _M_positive_sign;
size_t _M_positive_sign_size;
const _CharT* _M_negative_sign;
size_t _M_negative_sign_size;
int _M_frac_digits;
money_base::pattern _M_pos_format;
money_base::pattern _M_neg_format;
// A list of valid numeric literals for input and output: in the standard
// "C" locale, this is "-0123456789". This array contains the chars after
// having been passed through the current locale's ctype<_CharT>.widen().
_CharT _M_atoms[money_base::_S_end];
bool _M_allocated;
__moneypunct_cache(size_t __refs = 0) : facet(__refs),
_M_grouping(0), _M_grouping_size(0), _M_use_grouping(false),
_M_decimal_point(_CharT()), _M_thousands_sep(_CharT()),
_M_curr_symbol(0), _M_curr_symbol_size(0),
_M_positive_sign(0), _M_positive_sign_size(0),
_M_negative_sign(0), _M_negative_sign_size(0),
_M_frac_digits(0),
_M_pos_format(money_base::pattern()),
_M_neg_format(money_base::pattern()), _M_allocated(false)
{ }
~__moneypunct_cache();
void
_M_cache(const locale& __loc);
private:
__moneypunct_cache&
operator=(const __moneypunct_cache&);
explicit
__moneypunct_cache(const __moneypunct_cache&);
};
template<typename _CharT, bool _Intl>
__moneypunct_cache<_CharT, _Intl>::~__moneypunct_cache()
{
if (_M_allocated)
{
delete [] _M_grouping;
delete [] _M_curr_symbol;
delete [] _M_positive_sign;
delete [] _M_negative_sign;
}
}
_GLIBCXX_BEGIN_NAMESPACE_CXX11
/**
* @brief Primary class template moneypunct.
* @ingroup locales
*
* This facet encapsulates the punctuation, grouping and other formatting
* features of money amount string representations.
*/
template<typename _CharT, bool _Intl>
class moneypunct : public locale::facet, public money_base
{
public:
// Types:
//@{
/// Public typedefs
typedef _CharT char_type;
typedef basic_string<_CharT> string_type;
//@}
typedef __moneypunct_cache<_CharT, _Intl> __cache_type;
private:
__cache_type* _M_data;
public:
/// This value is provided by the standard, but no reason for its
/// existence.
static const bool intl = _Intl;
/// Numpunct facet id.
static locale::id id;
/**
* @brief Constructor performs initialization.
*
* This is the constructor provided by the standard.
*
* @param __refs Passed to the base facet class.
*/
explicit
moneypunct(size_t __refs = 0)
: facet(__refs), _M_data(0)
{ _M_initialize_moneypunct(); }
/**
* @brief Constructor performs initialization.
*
* This is an internal constructor.
*
* @param __cache Cache for optimization.
* @param __refs Passed to the base facet class.
*/
explicit
moneypunct(__cache_type* __cache, size_t __refs = 0)
: facet(__refs), _M_data(__cache)
{ _M_initialize_moneypunct(); }
/**
* @brief Internal constructor. Not for general use.
*
* This is a constructor for use by the library itself to set up new
* locales.
*
* @param __cloc The C locale.
* @param __s The name of a locale.
* @param __refs Passed to the base facet class.
*/
explicit
moneypunct(__c_locale __cloc, const char* __s, size_t __refs = 0)
: facet(__refs), _M_data(0)
{ _M_initialize_moneypunct(__cloc, __s); }
/**
* @brief Return decimal point character.
*
* This function returns a char_type to use as a decimal point. It
* does so by returning returning
* moneypunct<char_type>::do_decimal_point().
*
* @return @a char_type representing a decimal point.
*/
char_type
decimal_point() const
{ return this->do_decimal_point(); }
/**
* @brief Return thousands separator character.
*
* This function returns a char_type to use as a thousands
* separator. It does so by returning returning
* moneypunct<char_type>::do_thousands_sep().
*
* @return char_type representing a thousands separator.
*/
char_type
thousands_sep() const
{ return this->do_thousands_sep(); }
/**
* @brief Return grouping specification.
*
* This function returns a string representing groupings for the
* integer part of an amount. Groupings indicate where thousands
* separators should be inserted.
*
* Each char in the return string is interpret as an integer rather
* than a character. These numbers represent the number of digits in a
* group. The first char in the string represents the number of digits
* in the least significant group. If a char is negative, it indicates
* an unlimited number of digits for the group. If more chars from the
* string are required to group a number, the last char is used
* repeatedly.
*
* For example, if the grouping() returns <code>\003\002</code>
* and is applied to the number 123456789, this corresponds to
* 12,34,56,789. Note that if the string was <code>32</code>, this would
* put more than 50 digits into the least significant group if
* the character set is ASCII.
*
* The string is returned by calling
* moneypunct<char_type>::do_grouping().
*
* @return string representing grouping specification.
*/
string
grouping() const
{ return this->do_grouping(); }
/**
* @brief Return currency symbol string.
*
* This function returns a string_type to use as a currency symbol. It
* does so by returning returning
* moneypunct<char_type>::do_curr_symbol().
*
* @return @a string_type representing a currency symbol.
*/
string_type
curr_symbol() const
{ return this->do_curr_symbol(); }
/**
* @brief Return positive sign string.
*
* This function returns a string_type to use as a sign for positive
* amounts. It does so by returning returning
* moneypunct<char_type>::do_positive_sign().
*
* If the return value contains more than one character, the first
* character appears in the position indicated by pos_format() and the
* remainder appear at the end of the formatted string.
*
* @return @a string_type representing a positive sign.
*/
string_type
positive_sign() const
{ return this->do_positive_sign(); }
/**
* @brief Return negative sign string.
*
* This function returns a string_type to use as a sign for negative
* amounts. It does so by returning returning
* moneypunct<char_type>::do_negative_sign().
*
* If the return value contains more than one character, the first
* character appears in the position indicated by neg_format() and the
* remainder appear at the end of the formatted string.
*
* @return @a string_type representing a negative sign.
*/
string_type
negative_sign() const
{ return this->do_negative_sign(); }
/**
* @brief Return number of digits in fraction.
*
* This function returns the exact number of digits that make up the
* fractional part of a money amount. It does so by returning
* returning moneypunct<char_type>::do_frac_digits().
*
* The fractional part of a money amount is optional. But if it is
* present, there must be frac_digits() digits.
*
* @return Number of digits in amount fraction.
*/
int
frac_digits() const
{ return this->do_frac_digits(); }
//@{
/**
* @brief Return pattern for money values.
*
* This function returns a pattern describing the formatting of a
* positive or negative valued money amount. It does so by returning
* returning moneypunct<char_type>::do_pos_format() or
* moneypunct<char_type>::do_neg_format().
*
* The pattern has 4 fields describing the ordering of symbol, sign,
* value, and none or space. There must be one of each in the pattern.
* The none and space enums may not appear in the first field and space
* may not appear in the final field.
*
* The parts of a money string must appear in the order indicated by
* the fields of the pattern. The symbol field indicates that the
* value of curr_symbol() may be present. The sign field indicates
* that the value of positive_sign() or negative_sign() must be
* present. The value field indicates that the absolute value of the
* money amount is present. none indicates 0 or more whitespace
* characters, except at the end, where it permits no whitespace.
* space indicates that 1 or more whitespace characters must be
* present.
*
* For example, for the US locale and pos_format() pattern
* {symbol,sign,value,none}, curr_symbol() == '$'
* positive_sign() == '+', and value 10.01, and
* options set to force the symbol, the corresponding string is
* <code>$+10.01</code>.
*
* @return Pattern for money values.
*/
pattern
pos_format() const
{ return this->do_pos_format(); }
pattern
neg_format() const
{ return this->do_neg_format(); }
//@}
protected:
/// Destructor.
virtual
~moneypunct();
/**
* @brief Return decimal point character.
*
* Returns a char_type to use as a decimal point. This function is a
* hook for derived classes to change the value returned.
*
* @return @a char_type representing a decimal point.
*/
virtual char_type
do_decimal_point() const
{ return _M_data->_M_decimal_point; }
/**
* @brief Return thousands separator character.
*
* Returns a char_type to use as a thousands separator. This function
* is a hook for derived classes to change the value returned.
*
* @return @a char_type representing a thousands separator.
*/
virtual char_type
do_thousands_sep() const
{ return _M_data->_M_thousands_sep; }
/**
* @brief Return grouping specification.
*
* Returns a string representing groupings for the integer part of a
* number. This function is a hook for derived classes to change the
* value returned. @see grouping() for details.
*
* @return String representing grouping specification.
*/
virtual string
do_grouping() const
{ return _M_data->_M_grouping; }
/**
* @brief Return currency symbol string.
*
* This function returns a string_type to use as a currency symbol.
* This function is a hook for derived classes to change the value
* returned. @see curr_symbol() for details.
*
* @return @a string_type representing a currency symbol.
*/
virtual string_type
do_curr_symbol() const
{ return _M_data->_M_curr_symbol; }
/**
* @brief Return positive sign string.
*
* This function returns a string_type to use as a sign for positive
* amounts. This function is a hook for derived classes to change the
* value returned. @see positive_sign() for details.
*
* @return @a string_type representing a positive sign.
*/
virtual string_type
do_positive_sign() const
{ return _M_data->_M_positive_sign; }
/**
* @brief Return negative sign string.
*
* This function returns a string_type to use as a sign for negative
* amounts. This function is a hook for derived classes to change the
* value returned. @see negative_sign() for details.
*
* @return @a string_type representing a negative sign.
*/
virtual string_type
do_negative_sign() const
{ return _M_data->_M_negative_sign; }
/**
* @brief Return number of digits in fraction.
*
* This function returns the exact number of digits that make up the
* fractional part of a money amount. This function is a hook for
* derived classes to change the value returned. @see frac_digits()
* for details.
*
* @return Number of digits in amount fraction.
*/
virtual int
do_frac_digits() const
{ return _M_data->_M_frac_digits; }
/**
* @brief Return pattern for money values.
*
* This function returns a pattern describing the formatting of a
* positive valued money amount. This function is a hook for derived
* classes to change the value returned. @see pos_format() for
* details.
*
* @return Pattern for money values.
*/
virtual pattern
do_pos_format() const
{ return _M_data->_M_pos_format; }
/**
* @brief Return pattern for money values.
*
* This function returns a pattern describing the formatting of a
* negative valued money amount. This function is a hook for derived
* classes to change the value returned. @see neg_format() for
* details.
*
* @return Pattern for money values.
*/
virtual pattern
do_neg_format() const
{ return _M_data->_M_neg_format; }
// For use at construction time only.
void
_M_initialize_moneypunct(__c_locale __cloc = 0,
const char* __name = 0);
};
template<typename _CharT, bool _Intl>
locale::id moneypunct<_CharT, _Intl>::id;
template<typename _CharT, bool _Intl>
const bool moneypunct<_CharT, _Intl>::intl;
template<>
moneypunct<char, true>::~moneypunct();
template<>
moneypunct<char, false>::~moneypunct();
template<>
void
moneypunct<char, true>::_M_initialize_moneypunct(__c_locale, const char*);
template<>
void
moneypunct<char, false>::_M_initialize_moneypunct(__c_locale, const char*);
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
moneypunct<wchar_t, true>::~moneypunct();
template<>
moneypunct<wchar_t, false>::~moneypunct();
template<>
void
moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale,
const char*);
template<>
void
moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale,
const char*);
#endif
/// class moneypunct_byname [22.2.6.4].
template<typename _CharT, bool _Intl>
class moneypunct_byname : public moneypunct<_CharT, _Intl>
{
public:
typedef _CharT char_type;
typedef basic_string<_CharT> string_type;
static const bool intl = _Intl;
explicit
moneypunct_byname(const char* __s, size_t __refs = 0)
: moneypunct<_CharT, _Intl>(__refs)
{
if (__builtin_strcmp(__s, "C") != 0
&& __builtin_strcmp(__s, "POSIX") != 0)
{
__c_locale __tmp;
this->_S_create_c_locale(__tmp, __s);
this->_M_initialize_moneypunct(__tmp);
this->_S_destroy_c_locale(__tmp);
}
}
#if __cplusplus >= 201103L
explicit
moneypunct_byname(const string& __s, size_t __refs = 0)
: moneypunct_byname(__s.c_str(), __refs) { }
#endif
protected:
virtual
~moneypunct_byname() { }
};
template<typename _CharT, bool _Intl>
const bool moneypunct_byname<_CharT, _Intl>::intl;
_GLIBCXX_END_NAMESPACE_CXX11
_GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11
/**
* @brief Primary class template money_get.
* @ingroup locales
*
* This facet encapsulates the code to parse and return a monetary
* amount from a string.
*
* The money_get template uses protected virtual functions to
* provide the actual results. The public accessors forward the
* call to the virtual functions. These virtual functions are
* hooks for developers to implement the behavior they require from
* the money_get facet.
*/
template<typename _CharT, typename _InIter>
class money_get : public locale::facet
{
public:
// Types:
//@{
/// Public typedefs
typedef _CharT char_type;
typedef _InIter iter_type;
typedef basic_string<_CharT> string_type;
//@}
/// Numpunct facet id.
static locale::id id;
/**
* @brief Constructor performs initialization.
*
* This is the constructor provided by the standard.
*
* @param __refs Passed to the base facet class.
*/
explicit
money_get(size_t __refs = 0) : facet(__refs) { }
/**
* @brief Read and parse a monetary value.
*
* This function reads characters from @a __s, interprets them as a
* monetary value according to moneypunct and ctype facets retrieved
* from io.getloc(), and returns the result in @a units as an integral
* value moneypunct::frac_digits() * the actual amount. For example,
* the string $10.01 in a US locale would store 1001 in @a units.
*
* Any characters not part of a valid money amount are not consumed.
*
* If a money value cannot be parsed from the input stream, sets
* err=(err|io.failbit). If the stream is consumed before finishing
* parsing, sets err=(err|io.failbit|io.eofbit). @a units is
* unchanged if parsing fails.
*
* This function works by returning the result of do_get().
*
* @param __s Start of characters to parse.
* @param __end End of characters to parse.
* @param __intl Parameter to use_facet<moneypunct<CharT,intl> >.
* @param __io Source of facets and io state.
* @param __err Error field to set if parsing fails.
* @param __units Place to store result of parsing.
* @return Iterator referencing first character beyond valid money
* amount.
*/
iter_type
get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
ios_base::iostate& __err, long double& __units) const
{ return this->do_get(__s, __end, __intl, __io, __err, __units); }
/**
* @brief Read and parse a monetary value.
*
* This function reads characters from @a __s, interprets them as
* a monetary value according to moneypunct and ctype facets
* retrieved from io.getloc(), and returns the result in @a
* digits. For example, the string $10.01 in a US locale would
* store <code>1001</code> in @a digits.
*
* Any characters not part of a valid money amount are not consumed.
*
* If a money value cannot be parsed from the input stream, sets
* err=(err|io.failbit). If the stream is consumed before finishing
* parsing, sets err=(err|io.failbit|io.eofbit).
*
* This function works by returning the result of do_get().
*
* @param __s Start of characters to parse.
* @param __end End of characters to parse.
* @param __intl Parameter to use_facet<moneypunct<CharT,intl> >.
* @param __io Source of facets and io state.
* @param __err Error field to set if parsing fails.
* @param __digits Place to store result of parsing.
* @return Iterator referencing first character beyond valid money
* amount.
*/
iter_type
get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
ios_base::iostate& __err, string_type& __digits) const
{ return this->do_get(__s, __end, __intl, __io, __err, __digits); }
protected:
/// Destructor.
virtual
~money_get() { }
/**
* @brief Read and parse a monetary value.
*
* This function reads and parses characters representing a monetary
* value. This function is a hook for derived classes to change the
* value returned. @see get() for details.
*/
// XXX GLIBCXX_ABI Deprecated
#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ \
&& _GLIBCXX_USE_CXX11_ABI == 0
virtual iter_type
__do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
ios_base::iostate& __err, double& __units) const;
#else
virtual iter_type
do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
ios_base::iostate& __err, long double& __units) const;
#endif
/**
* @brief Read and parse a monetary value.
*
* This function reads and parses characters representing a monetary
* value. This function is a hook for derived classes to change the
* value returned. @see get() for details.
*/
virtual iter_type
do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
ios_base::iostate& __err, string_type& __digits) const;
// XXX GLIBCXX_ABI Deprecated
#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ \
&& _GLIBCXX_USE_CXX11_ABI == 0
virtual iter_type
do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
ios_base::iostate& __err, long double& __units) const;
#endif
template<bool _Intl>
iter_type
_M_extract(iter_type __s, iter_type __end, ios_base& __io,
ios_base::iostate& __err, string& __digits) const;
};
template<typename _CharT, typename _InIter>
locale::id money_get<_CharT, _InIter>::id;
/**
* @brief Primary class template money_put.
* @ingroup locales
*
* This facet encapsulates the code to format and output a monetary
* amount.
*
* The money_put template uses protected virtual functions to
* provide the actual results. The public accessors forward the
* call to the virtual functions. These virtual functions are
* hooks for developers to implement the behavior they require from
* the money_put facet.
*/
template<typename _CharT, typename _OutIter>
class money_put : public locale::facet
{
public:
//@{
/// Public typedefs
typedef _CharT char_type;
typedef _OutIter iter_type;
typedef basic_string<_CharT> string_type;
//@}
/// Numpunct facet id.
static locale::id id;
/**
* @brief Constructor performs initialization.
*
* This is the constructor provided by the standard.
*
* @param __refs Passed to the base facet class.
*/
explicit
money_put(size_t __refs = 0) : facet(__refs) { }
/**
* @brief Format and output a monetary value.
*
* This function formats @a units as a monetary value according to
* moneypunct and ctype facets retrieved from io.getloc(), and writes
* the resulting characters to @a __s. For example, the value 1001 in a
* US locale would write <code>$10.01</code> to @a __s.
*
* This function works by returning the result of do_put().
*
* @param __s The stream to write to.
* @param __intl Parameter to use_facet<moneypunct<CharT,intl> >.
* @param __io Source of facets and io state.
* @param __fill char_type to use for padding.
* @param __units Place to store result of parsing.
* @return Iterator after writing.
*/
iter_type
put(iter_type __s, bool __intl, ios_base& __io,
char_type __fill, long double __units) const
{ return this->do_put(__s, __intl, __io, __fill, __units); }
/**
* @brief Format and output a monetary value.
*
* This function formats @a digits as a monetary value
* according to moneypunct and ctype facets retrieved from
* io.getloc(), and writes the resulting characters to @a __s.
* For example, the string <code>1001</code> in a US locale
* would write <code>$10.01</code> to @a __s.
*
* This function works by returning the result of do_put().
*
* @param __s The stream to write to.
* @param __intl Parameter to use_facet<moneypunct<CharT,intl> >.
* @param __io Source of facets and io state.
* @param __fill char_type to use for padding.
* @param __digits Place to store result of parsing.
* @return Iterator after writing.
*/
iter_type
put(iter_type __s, bool __intl, ios_base& __io,
char_type __fill, const string_type& __digits) const
{ return this->do_put(__s, __intl, __io, __fill, __digits); }
protected:
/// Destructor.
virtual
~money_put() { }
/**
* @brief Format and output a monetary value.
*
* This function formats @a units as a monetary value according to
* moneypunct and ctype facets retrieved from io.getloc(), and writes
* the resulting characters to @a __s. For example, the value 1001 in a
* US locale would write <code>$10.01</code> to @a __s.
*
* This function is a hook for derived classes to change the value
* returned. @see put().
*
* @param __s The stream to write to.
* @param __intl Parameter to use_facet<moneypunct<CharT,intl> >.
* @param __io Source of facets and io state.
* @param __fill char_type to use for padding.
* @param __units Place to store result of parsing.
* @return Iterator after writing.
*/
// XXX GLIBCXX_ABI Deprecated
#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ \
&& _GLIBCXX_USE_CXX11_ABI == 0
virtual iter_type
__do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
double __units) const;
#else
virtual iter_type
do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
long double __units) const;
#endif
/**
* @brief Format and output a monetary value.
*
* This function formats @a digits as a monetary value
* according to moneypunct and ctype facets retrieved from
* io.getloc(), and writes the resulting characters to @a __s.
* For example, the string <code>1001</code> in a US locale
* would write <code>$10.01</code> to @a __s.
*
* This function is a hook for derived classes to change the value
* returned. @see put().
*
* @param __s The stream to write to.
* @param __intl Parameter to use_facet<moneypunct<CharT,intl> >.
* @param __io Source of facets and io state.
* @param __fill char_type to use for padding.
* @param __digits Place to store result of parsing.
* @return Iterator after writing.
*/
virtual iter_type
do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
const string_type& __digits) const;
// XXX GLIBCXX_ABI Deprecated
#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ \
&& _GLIBCXX_USE_CXX11_ABI == 0
virtual iter_type
do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
long double __units) const;
#endif
template<bool _Intl>
iter_type
_M_insert(iter_type __s, ios_base& __io, char_type __fill,
const string_type& __digits) const;
};
template<typename _CharT, typename _OutIter>
locale::id money_put<_CharT, _OutIter>::id;
_GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
/**
* @brief Messages facet base class providing catalog typedef.
* @ingroup locales
*/
struct messages_base
{
typedef int catalog;
};
_GLIBCXX_BEGIN_NAMESPACE_CXX11
/**
* @brief Primary class template messages.
* @ingroup locales
*
* This facet encapsulates the code to retrieve messages from
* message catalogs. The only thing defined by the standard for this facet
* is the interface. All underlying functionality is
* implementation-defined.
*
* This library currently implements 3 versions of the message facet. The
* first version (gnu) is a wrapper around gettext, provided by libintl.
* The second version (ieee) is a wrapper around catgets. The final
* version (default) does no actual translation. These implementations are
* only provided for char and wchar_t instantiations.
*
* The messages template uses protected virtual functions to
* provide the actual results. The public accessors forward the
* call to the virtual functions. These virtual functions are
* hooks for developers to implement the behavior they require from
* the messages facet.
*/
template<typename _CharT>
class messages : public locale::facet, public messages_base
{
public:
// Types:
//@{
/// Public typedefs
typedef _CharT char_type;
typedef basic_string<_CharT> string_type;
//@}
protected:
// Underlying "C" library locale information saved from
// initialization, needed by messages_byname as well.
__c_locale _M_c_locale_messages;
const char* _M_name_messages;
public:
/// Numpunct facet id.
static locale::id id;
/**
* @brief Constructor performs initialization.
*
* This is the constructor provided by the standard.
*
* @param __refs Passed to the base facet class.
*/
explicit
messages(size_t __refs = 0);
// Non-standard.
/**
* @brief Internal constructor. Not for general use.
*
* This is a constructor for use by the library itself to set up new
* locales.
*
* @param __cloc The C locale.
* @param __s The name of a locale.
* @param __refs Refcount to pass to the base class.
*/
explicit
messages(__c_locale __cloc, const char* __s, size_t __refs = 0);
/*
* @brief Open a message catalog.
*
* This function opens and returns a handle to a message catalog by
* returning do_open(__s, __loc).
*
* @param __s The catalog to open.
* @param __loc Locale to use for character set conversions.
* @return Handle to the catalog or value < 0 if open fails.
*/
catalog
open(const basic_string<char>& __s, const locale& __loc) const
{ return this->do_open(__s, __loc); }
// Non-standard and unorthodox, yet effective.
/*
* @brief Open a message catalog.
*
* This non-standard function opens and returns a handle to a message
* catalog by returning do_open(s, loc). The third argument provides a
* message catalog root directory for gnu gettext and is ignored
* otherwise.
*
* @param __s The catalog to open.
* @param __loc Locale to use for character set conversions.
* @param __dir Message catalog root directory.
* @return Handle to the catalog or value < 0 if open fails.
*/
catalog
open(const basic_string<char>&, const locale&, const char*) const;
/*
* @brief Look up a string in a message catalog.
*
* This function retrieves and returns a message from a catalog by
* returning do_get(c, set, msgid, s).
*
* For gnu, @a __set and @a msgid are ignored. Returns gettext(s).
* For default, returns s. For ieee, returns catgets(c,set,msgid,s).
*
* @param __c The catalog to access.
* @param __set Implementation-defined.
* @param __msgid Implementation-defined.
* @param __s Default return value if retrieval fails.
* @return Retrieved message or @a __s if get fails.
*/
string_type
get(catalog __c, int __set, int __msgid, const string_type& __s) const
{ return this->do_get(__c, __set, __msgid, __s); }
/*
* @brief Close a message catalog.
*
* Closes catalog @a c by calling do_close(c).
*
* @param __c The catalog to close.
*/
void
close(catalog __c) const
{ return this->do_close(__c); }
protected:
/// Destructor.
virtual
~messages();
/*
* @brief Open a message catalog.
*
* This function opens and returns a handle to a message catalog in an
* implementation-defined manner. This function is a hook for derived
* classes to change the value returned.
*
* @param __s The catalog to open.
* @param __loc Locale to use for character set conversions.
* @return Handle to the opened catalog, value < 0 if open failed.
*/
virtual catalog
do_open(const basic_string<char>&, const locale&) const;
/*
* @brief Look up a string in a message catalog.
*
* This function retrieves and returns a message from a catalog in an
* implementation-defined manner. This function is a hook for derived
* classes to change the value returned.
*
* For gnu, @a __set and @a __msgid are ignored. Returns gettext(s).
* For default, returns s. For ieee, returns catgets(c,set,msgid,s).
*
* @param __c The catalog to access.
* @param __set Implementation-defined.
* @param __msgid Implementation-defined.
* @param __s Default return value if retrieval fails.
* @return Retrieved message or @a __s if get fails.
*/
virtual string_type
do_get(catalog, int, int, const string_type& __dfault) const;
/*
* @brief Close a message catalog.
*
* @param __c The catalog to close.
*/
virtual void
do_close(catalog) const;
// Returns a locale and codeset-converted string, given a char* message.
char*
_M_convert_to_char(const string_type& __msg) const
{
// XXX
return reinterpret_cast<char*>(const_cast<_CharT*>(__msg.c_str()));
}
// Returns a locale and codeset-converted string, given a char* message.
string_type
_M_convert_from_char(char*) const
{
// XXX
return string_type();
}
};
template<typename _CharT>
locale::id messages<_CharT>::id;
/// Specializations for required instantiations.
template<>
string
messages<char>::do_get(catalog, int, int, const string&) const;
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
wstring
messages<wchar_t>::do_get(catalog, int, int, const wstring&) const;
#endif
/// class messages_byname [22.2.7.2].
template<typename _CharT>
class messages_byname : public messages<_CharT>
{
public:
typedef _CharT char_type;
typedef basic_string<_CharT> string_type;
explicit
messages_byname(const char* __s, size_t __refs = 0);
#if __cplusplus >= 201103L
explicit
messages_byname(const string& __s, size_t __refs = 0)
: messages_byname(__s.c_str(), __refs) { }
#endif
protected:
virtual
~messages_byname()
{ }
};
_GLIBCXX_END_NAMESPACE_CXX11
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
// Include host and configuration specific messages functions.
#include <bits/messages_members.h>
// 22.2.1.5 Template class codecvt
#include <bits/codecvt.h>
#include <bits/locale_facets_nonio.tcc>
#endif
c++/8/bits/stl_set.h 0000644 00000106435 15201526705 0010066 0 ustar 00 // Set implementation -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1996,1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file bits/stl_set.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{set}
*/
#ifndef _STL_SET_H
#define _STL_SET_H 1
#include <bits/concept_check.h>
#if __cplusplus >= 201103L
#include <initializer_list>
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Key, typename _Compare, typename _Alloc>
class multiset;
/**
* @brief A standard container made up of unique keys, which can be
* retrieved in logarithmic time.
*
* @ingroup associative_containers
*
* @tparam _Key Type of key objects.
* @tparam _Compare Comparison function object type, defaults to less<_Key>.
* @tparam _Alloc Allocator type, defaults to allocator<_Key>.
*
* Meets the requirements of a <a href="tables.html#65">container</a>, a
* <a href="tables.html#66">reversible container</a>, and an
* <a href="tables.html#69">associative container</a> (using unique keys).
*
* Sets support bidirectional iterators.
*
* The private tree data is declared exactly the same way for set and
* multiset; the distinction is made entirely in how the tree functions are
* called (*_unique versus *_equal, same as the standard).
*/
template<typename _Key, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<_Key> >
class set
{
#ifdef _GLIBCXX_CONCEPT_CHECKS
// concept requirements
typedef typename _Alloc::value_type _Alloc_value_type;
# if __cplusplus < 201103L
__glibcxx_class_requires(_Key, _SGIAssignableConcept)
# endif
__glibcxx_class_requires4(_Compare, bool, _Key, _Key,
_BinaryFunctionConcept)
__glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept)
#endif
#if __cplusplus >= 201103L
static_assert(is_same<typename remove_cv<_Key>::type, _Key>::value,
"std::set must have a non-const, non-volatile value_type");
# ifdef __STRICT_ANSI__
static_assert(is_same<typename _Alloc::value_type, _Key>::value,
"std::set must have the same value_type as its allocator");
# endif
#endif
public:
// typedefs:
//@{
/// Public typedefs.
typedef _Key key_type;
typedef _Key value_type;
typedef _Compare key_compare;
typedef _Compare value_compare;
typedef _Alloc allocator_type;
//@}
private:
typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template
rebind<_Key>::other _Key_alloc_type;
typedef _Rb_tree<key_type, value_type, _Identity<value_type>,
key_compare, _Key_alloc_type> _Rep_type;
_Rep_type _M_t; // Red-black tree representing set.
typedef __gnu_cxx::__alloc_traits<_Key_alloc_type> _Alloc_traits;
public:
//@{
/// Iterator-related typedefs.
typedef typename _Alloc_traits::pointer pointer;
typedef typename _Alloc_traits::const_pointer const_pointer;
typedef typename _Alloc_traits::reference reference;
typedef typename _Alloc_traits::const_reference const_reference;
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 103. set::iterator is required to be modifiable,
// but this allows modification of keys.
typedef typename _Rep_type::const_iterator iterator;
typedef typename _Rep_type::const_iterator const_iterator;
typedef typename _Rep_type::const_reverse_iterator reverse_iterator;
typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
typedef typename _Rep_type::size_type size_type;
typedef typename _Rep_type::difference_type difference_type;
//@}
#if __cplusplus > 201402L
using node_type = typename _Rep_type::node_type;
using insert_return_type = typename _Rep_type::insert_return_type;
#endif
// allocation/deallocation
/**
* @brief Default constructor creates no elements.
*/
#if __cplusplus < 201103L
set() : _M_t() { }
#else
set() = default;
#endif
/**
* @brief Creates a %set with no elements.
* @param __comp Comparator to use.
* @param __a An allocator object.
*/
explicit
set(const _Compare& __comp,
const allocator_type& __a = allocator_type())
: _M_t(__comp, _Key_alloc_type(__a)) { }
/**
* @brief Builds a %set from a range.
* @param __first An input iterator.
* @param __last An input iterator.
*
* Create a %set consisting of copies of the elements from
* [__first,__last). This is linear in N if the range is
* already sorted, and NlogN otherwise (where N is
* distance(__first,__last)).
*/
template<typename _InputIterator>
set(_InputIterator __first, _InputIterator __last)
: _M_t()
{ _M_t._M_insert_unique(__first, __last); }
/**
* @brief Builds a %set from a range.
* @param __first An input iterator.
* @param __last An input iterator.
* @param __comp A comparison functor.
* @param __a An allocator object.
*
* Create a %set consisting of copies of the elements from
* [__first,__last). This is linear in N if the range is
* already sorted, and NlogN otherwise (where N is
* distance(__first,__last)).
*/
template<typename _InputIterator>
set(_InputIterator __first, _InputIterator __last,
const _Compare& __comp,
const allocator_type& __a = allocator_type())
: _M_t(__comp, _Key_alloc_type(__a))
{ _M_t._M_insert_unique(__first, __last); }
/**
* @brief %Set copy constructor.
*
* Whether the allocator is copied depends on the allocator traits.
*/
#if __cplusplus < 201103L
set(const set& __x)
: _M_t(__x._M_t) { }
#else
set(const set&) = default;
/**
* @brief %Set move constructor
*
* The newly-created %set contains the exact contents of the moved
* instance. The moved instance is a valid, but unspecified, %set.
*/
set(set&&) = default;
/**
* @brief Builds a %set from an initializer_list.
* @param __l An initializer_list.
* @param __comp A comparison functor.
* @param __a An allocator object.
*
* Create a %set consisting of copies of the elements in the list.
* This is linear in N if the list is already sorted, and NlogN
* otherwise (where N is @a __l.size()).
*/
set(initializer_list<value_type> __l,
const _Compare& __comp = _Compare(),
const allocator_type& __a = allocator_type())
: _M_t(__comp, _Key_alloc_type(__a))
{ _M_t._M_insert_unique(__l.begin(), __l.end()); }
/// Allocator-extended default constructor.
explicit
set(const allocator_type& __a)
: _M_t(_Compare(), _Key_alloc_type(__a)) { }
/// Allocator-extended copy constructor.
set(const set& __x, const allocator_type& __a)
: _M_t(__x._M_t, _Key_alloc_type(__a)) { }
/// Allocator-extended move constructor.
set(set&& __x, const allocator_type& __a)
noexcept(is_nothrow_copy_constructible<_Compare>::value
&& _Alloc_traits::_S_always_equal())
: _M_t(std::move(__x._M_t), _Key_alloc_type(__a)) { }
/// Allocator-extended initialier-list constructor.
set(initializer_list<value_type> __l, const allocator_type& __a)
: _M_t(_Compare(), _Key_alloc_type(__a))
{ _M_t._M_insert_unique(__l.begin(), __l.end()); }
/// Allocator-extended range constructor.
template<typename _InputIterator>
set(_InputIterator __first, _InputIterator __last,
const allocator_type& __a)
: _M_t(_Compare(), _Key_alloc_type(__a))
{ _M_t._M_insert_unique(__first, __last); }
/**
* The dtor only erases the elements, and note that if the elements
* themselves are pointers, the pointed-to memory is not touched in any
* way. Managing the pointer is the user's responsibility.
*/
~set() = default;
#endif
/**
* @brief %Set assignment operator.
*
* Whether the allocator is copied depends on the allocator traits.
*/
#if __cplusplus < 201103L
set&
operator=(const set& __x)
{
_M_t = __x._M_t;
return *this;
}
#else
set&
operator=(const set&) = default;
/// Move assignment operator.
set&
operator=(set&&) = default;
/**
* @brief %Set list assignment operator.
* @param __l An initializer_list.
*
* This function fills a %set with copies of the elements in the
* initializer list @a __l.
*
* Note that the assignment completely changes the %set and
* that the resulting %set's size is the same as the number
* of elements assigned.
*/
set&
operator=(initializer_list<value_type> __l)
{
_M_t._M_assign_unique(__l.begin(), __l.end());
return *this;
}
#endif
// accessors:
/// Returns the comparison object with which the %set was constructed.
key_compare
key_comp() const
{ return _M_t.key_comp(); }
/// Returns the comparison object with which the %set was constructed.
value_compare
value_comp() const
{ return _M_t.key_comp(); }
/// Returns the allocator object with which the %set was constructed.
allocator_type
get_allocator() const _GLIBCXX_NOEXCEPT
{ return allocator_type(_M_t.get_allocator()); }
/**
* Returns a read-only (constant) iterator that points to the first
* element in the %set. Iteration is done in ascending order according
* to the keys.
*/
iterator
begin() const _GLIBCXX_NOEXCEPT
{ return _M_t.begin(); }
/**
* Returns a read-only (constant) iterator that points one past the last
* element in the %set. Iteration is done in ascending order according
* to the keys.
*/
iterator
end() const _GLIBCXX_NOEXCEPT
{ return _M_t.end(); }
/**
* Returns a read-only (constant) iterator that points to the last
* element in the %set. Iteration is done in descending order according
* to the keys.
*/
reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT
{ return _M_t.rbegin(); }
/**
* Returns a read-only (constant) reverse iterator that points to the
* last pair in the %set. Iteration is done in descending order
* according to the keys.
*/
reverse_iterator
rend() const _GLIBCXX_NOEXCEPT
{ return _M_t.rend(); }
#if __cplusplus >= 201103L
/**
* Returns a read-only (constant) iterator that points to the first
* element in the %set. Iteration is done in ascending order according
* to the keys.
*/
iterator
cbegin() const noexcept
{ return _M_t.begin(); }
/**
* Returns a read-only (constant) iterator that points one past the last
* element in the %set. Iteration is done in ascending order according
* to the keys.
*/
iterator
cend() const noexcept
{ return _M_t.end(); }
/**
* Returns a read-only (constant) iterator that points to the last
* element in the %set. Iteration is done in descending order according
* to the keys.
*/
reverse_iterator
crbegin() const noexcept
{ return _M_t.rbegin(); }
/**
* Returns a read-only (constant) reverse iterator that points to the
* last pair in the %set. Iteration is done in descending order
* according to the keys.
*/
reverse_iterator
crend() const noexcept
{ return _M_t.rend(); }
#endif
/// Returns true if the %set is empty.
bool
empty() const _GLIBCXX_NOEXCEPT
{ return _M_t.empty(); }
/// Returns the size of the %set.
size_type
size() const _GLIBCXX_NOEXCEPT
{ return _M_t.size(); }
/// Returns the maximum size of the %set.
size_type
max_size() const _GLIBCXX_NOEXCEPT
{ return _M_t.max_size(); }
/**
* @brief Swaps data with another %set.
* @param __x A %set of the same element and allocator types.
*
* This exchanges the elements between two sets in constant
* time. (It is only swapping a pointer, an integer, and an
* instance of the @c Compare type (which itself is often
* stateless and empty), so it should be quite fast.) Note
* that the global std::swap() function is specialized such
* that std::swap(s1,s2) will feed to this function.
*
* Whether the allocators are swapped depends on the allocator traits.
*/
void
swap(set& __x)
_GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value)
{ _M_t.swap(__x._M_t); }
// insert/erase
#if __cplusplus >= 201103L
/**
* @brief Attempts to build and insert an element into the %set.
* @param __args Arguments used to generate an element.
* @return A pair, of which the first element is an iterator that points
* to the possibly inserted element, and the second is a bool
* that is true if the element was actually inserted.
*
* This function attempts to build and insert an element into the %set.
* A %set relies on unique keys and thus an element is only inserted if
* it is not already present in the %set.
*
* Insertion requires logarithmic time.
*/
template<typename... _Args>
std::pair<iterator, bool>
emplace(_Args&&... __args)
{ return _M_t._M_emplace_unique(std::forward<_Args>(__args)...); }
/**
* @brief Attempts to insert an element into the %set.
* @param __pos An iterator that serves as a hint as to where the
* element should be inserted.
* @param __args Arguments used to generate the element to be
* inserted.
* @return An iterator that points to the element with key equivalent to
* the one generated from @a __args (may or may not be the
* element itself).
*
* This function is not concerned about whether the insertion took place,
* and thus does not return a boolean like the single-argument emplace()
* does. Note that the first parameter is only a hint and can
* potentially improve the performance of the insertion process. A bad
* hint would cause no gains in efficiency.
*
* For more on @a hinting, see:
* https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints
*
* Insertion requires logarithmic time (if the hint is not taken).
*/
template<typename... _Args>
iterator
emplace_hint(const_iterator __pos, _Args&&... __args)
{
return _M_t._M_emplace_hint_unique(__pos,
std::forward<_Args>(__args)...);
}
#endif
/**
* @brief Attempts to insert an element into the %set.
* @param __x Element to be inserted.
* @return A pair, of which the first element is an iterator that points
* to the possibly inserted element, and the second is a bool
* that is true if the element was actually inserted.
*
* This function attempts to insert an element into the %set. A %set
* relies on unique keys and thus an element is only inserted if it is
* not already present in the %set.
*
* Insertion requires logarithmic time.
*/
std::pair<iterator, bool>
insert(const value_type& __x)
{
std::pair<typename _Rep_type::iterator, bool> __p =
_M_t._M_insert_unique(__x);
return std::pair<iterator, bool>(__p.first, __p.second);
}
#if __cplusplus >= 201103L
std::pair<iterator, bool>
insert(value_type&& __x)
{
std::pair<typename _Rep_type::iterator, bool> __p =
_M_t._M_insert_unique(std::move(__x));
return std::pair<iterator, bool>(__p.first, __p.second);
}
#endif
/**
* @brief Attempts to insert an element into the %set.
* @param __position An iterator that serves as a hint as to where the
* element should be inserted.
* @param __x Element to be inserted.
* @return An iterator that points to the element with key of
* @a __x (may or may not be the element passed in).
*
* This function is not concerned about whether the insertion took place,
* and thus does not return a boolean like the single-argument insert()
* does. Note that the first parameter is only a hint and can
* potentially improve the performance of the insertion process. A bad
* hint would cause no gains in efficiency.
*
* For more on @a hinting, see:
* https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints
*
* Insertion requires logarithmic time (if the hint is not taken).
*/
iterator
insert(const_iterator __position, const value_type& __x)
{ return _M_t._M_insert_unique_(__position, __x); }
#if __cplusplus >= 201103L
iterator
insert(const_iterator __position, value_type&& __x)
{ return _M_t._M_insert_unique_(__position, std::move(__x)); }
#endif
/**
* @brief A template function that attempts to insert a range
* of elements.
* @param __first Iterator pointing to the start of the range to be
* inserted.
* @param __last Iterator pointing to the end of the range.
*
* Complexity similar to that of the range constructor.
*/
template<typename _InputIterator>
void
insert(_InputIterator __first, _InputIterator __last)
{ _M_t._M_insert_unique(__first, __last); }
#if __cplusplus >= 201103L
/**
* @brief Attempts to insert a list of elements into the %set.
* @param __l A std::initializer_list<value_type> of elements
* to be inserted.
*
* Complexity similar to that of the range constructor.
*/
void
insert(initializer_list<value_type> __l)
{ this->insert(__l.begin(), __l.end()); }
#endif
#if __cplusplus > 201402L
/// Extract a node.
node_type
extract(const_iterator __pos)
{
__glibcxx_assert(__pos != end());
return _M_t.extract(__pos);
}
/// Extract a node.
node_type
extract(const key_type& __x)
{ return _M_t.extract(__x); }
/// Re-insert an extracted node.
insert_return_type
insert(node_type&& __nh)
{ return _M_t._M_reinsert_node_unique(std::move(__nh)); }
/// Re-insert an extracted node.
iterator
insert(const_iterator __hint, node_type&& __nh)
{ return _M_t._M_reinsert_node_hint_unique(__hint, std::move(__nh)); }
template<typename, typename>
friend class std::_Rb_tree_merge_helper;
template<typename _Compare1>
void
merge(set<_Key, _Compare1, _Alloc>& __source)
{
using _Merge_helper = _Rb_tree_merge_helper<set, _Compare1>;
_M_t._M_merge_unique(_Merge_helper::_S_get_tree(__source));
}
template<typename _Compare1>
void
merge(set<_Key, _Compare1, _Alloc>&& __source)
{ merge(__source); }
template<typename _Compare1>
void
merge(multiset<_Key, _Compare1, _Alloc>& __source)
{
using _Merge_helper = _Rb_tree_merge_helper<set, _Compare1>;
_M_t._M_merge_unique(_Merge_helper::_S_get_tree(__source));
}
template<typename _Compare1>
void
merge(multiset<_Key, _Compare1, _Alloc>&& __source)
{ merge(__source); }
#endif // C++17
#if __cplusplus >= 201103L
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 130. Associative erase should return an iterator.
/**
* @brief Erases an element from a %set.
* @param __position An iterator pointing to the element to be erased.
* @return An iterator pointing to the element immediately following
* @a __position prior to the element being erased. If no such
* element exists, end() is returned.
*
* This function erases an element, pointed to by the given iterator,
* from a %set. Note that this function only erases the element, and
* that if the element is itself a pointer, the pointed-to memory is not
* touched in any way. Managing the pointer is the user's
* responsibility.
*/
_GLIBCXX_ABI_TAG_CXX11
iterator
erase(const_iterator __position)
{ return _M_t.erase(__position); }
#else
/**
* @brief Erases an element from a %set.
* @param position An iterator pointing to the element to be erased.
*
* This function erases an element, pointed to by the given iterator,
* from a %set. Note that this function only erases the element, and
* that if the element is itself a pointer, the pointed-to memory is not
* touched in any way. Managing the pointer is the user's
* responsibility.
*/
void
erase(iterator __position)
{ _M_t.erase(__position); }
#endif
/**
* @brief Erases elements according to the provided key.
* @param __x Key of element to be erased.
* @return The number of elements erased.
*
* This function erases all the elements located by the given key from
* a %set.
* Note that this function only erases the element, and that if
* the element is itself a pointer, the pointed-to memory is not touched
* in any way. Managing the pointer is the user's responsibility.
*/
size_type
erase(const key_type& __x)
{ return _M_t.erase(__x); }
#if __cplusplus >= 201103L
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 130. Associative erase should return an iterator.
/**
* @brief Erases a [__first,__last) range of elements from a %set.
* @param __first Iterator pointing to the start of the range to be
* erased.
* @param __last Iterator pointing to the end of the range to
* be erased.
* @return The iterator @a __last.
*
* This function erases a sequence of elements from a %set.
* Note that this function only erases the element, and that if
* the element is itself a pointer, the pointed-to memory is not touched
* in any way. Managing the pointer is the user's responsibility.
*/
_GLIBCXX_ABI_TAG_CXX11
iterator
erase(const_iterator __first, const_iterator __last)
{ return _M_t.erase(__first, __last); }
#else
/**
* @brief Erases a [first,last) range of elements from a %set.
* @param __first Iterator pointing to the start of the range to be
* erased.
* @param __last Iterator pointing to the end of the range to
* be erased.
*
* This function erases a sequence of elements from a %set.
* Note that this function only erases the element, and that if
* the element is itself a pointer, the pointed-to memory is not touched
* in any way. Managing the pointer is the user's responsibility.
*/
void
erase(iterator __first, iterator __last)
{ _M_t.erase(__first, __last); }
#endif
/**
* Erases all elements in a %set. Note that this function only erases
* the elements, and that if the elements themselves are pointers, the
* pointed-to memory is not touched in any way. Managing the pointer is
* the user's responsibility.
*/
void
clear() _GLIBCXX_NOEXCEPT
{ _M_t.clear(); }
// set operations:
//@{
/**
* @brief Finds the number of elements.
* @param __x Element to located.
* @return Number of elements with specified key.
*
* This function only makes sense for multisets; for set the result will
* either be 0 (not present) or 1 (present).
*/
size_type
count(const key_type& __x) const
{ return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
#if __cplusplus > 201103L
template<typename _Kt>
auto
count(const _Kt& __x) const
-> decltype(_M_t._M_count_tr(__x))
{ return _M_t._M_count_tr(__x); }
#endif
//@}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 214. set::find() missing const overload
//@{
/**
* @brief Tries to locate an element in a %set.
* @param __x Element to be located.
* @return Iterator pointing to sought-after element, or end() if not
* found.
*
* This function takes a key and tries to locate the element with which
* the key matches. If successful the function returns an iterator
* pointing to the sought after element. If unsuccessful it returns the
* past-the-end ( @c end() ) iterator.
*/
iterator
find(const key_type& __x)
{ return _M_t.find(__x); }
const_iterator
find(const key_type& __x) const
{ return _M_t.find(__x); }
#if __cplusplus > 201103L
template<typename _Kt>
auto
find(const _Kt& __x)
-> decltype(iterator{_M_t._M_find_tr(__x)})
{ return iterator{_M_t._M_find_tr(__x)}; }
template<typename _Kt>
auto
find(const _Kt& __x) const
-> decltype(const_iterator{_M_t._M_find_tr(__x)})
{ return const_iterator{_M_t._M_find_tr(__x)}; }
#endif
//@}
//@{
/**
* @brief Finds the beginning of a subsequence matching given key.
* @param __x Key to be located.
* @return Iterator pointing to first element equal to or greater
* than key, or end().
*
* This function returns the first element of a subsequence of elements
* that matches the given key. If unsuccessful it returns an iterator
* pointing to the first element that has a greater value than given key
* or end() if no such element exists.
*/
iterator
lower_bound(const key_type& __x)
{ return _M_t.lower_bound(__x); }
const_iterator
lower_bound(const key_type& __x) const
{ return _M_t.lower_bound(__x); }
#if __cplusplus > 201103L
template<typename _Kt>
auto
lower_bound(const _Kt& __x)
-> decltype(iterator(_M_t._M_lower_bound_tr(__x)))
{ return iterator(_M_t._M_lower_bound_tr(__x)); }
template<typename _Kt>
auto
lower_bound(const _Kt& __x) const
-> decltype(const_iterator(_M_t._M_lower_bound_tr(__x)))
{ return const_iterator(_M_t._M_lower_bound_tr(__x)); }
#endif
//@}
//@{
/**
* @brief Finds the end of a subsequence matching given key.
* @param __x Key to be located.
* @return Iterator pointing to the first element
* greater than key, or end().
*/
iterator
upper_bound(const key_type& __x)
{ return _M_t.upper_bound(__x); }
const_iterator
upper_bound(const key_type& __x) const
{ return _M_t.upper_bound(__x); }
#if __cplusplus > 201103L
template<typename _Kt>
auto
upper_bound(const _Kt& __x)
-> decltype(iterator(_M_t._M_upper_bound_tr(__x)))
{ return iterator(_M_t._M_upper_bound_tr(__x)); }
template<typename _Kt>
auto
upper_bound(const _Kt& __x) const
-> decltype(iterator(_M_t._M_upper_bound_tr(__x)))
{ return const_iterator(_M_t._M_upper_bound_tr(__x)); }
#endif
//@}
//@{
/**
* @brief Finds a subsequence matching given key.
* @param __x Key to be located.
* @return Pair of iterators that possibly points to the subsequence
* matching given key.
*
* This function is equivalent to
* @code
* std::make_pair(c.lower_bound(val),
* c.upper_bound(val))
* @endcode
* (but is faster than making the calls separately).
*
* This function probably only makes sense for multisets.
*/
std::pair<iterator, iterator>
equal_range(const key_type& __x)
{ return _M_t.equal_range(__x); }
std::pair<const_iterator, const_iterator>
equal_range(const key_type& __x) const
{ return _M_t.equal_range(__x); }
#if __cplusplus > 201103L
template<typename _Kt>
auto
equal_range(const _Kt& __x)
-> decltype(pair<iterator, iterator>(_M_t._M_equal_range_tr(__x)))
{ return pair<iterator, iterator>(_M_t._M_equal_range_tr(__x)); }
template<typename _Kt>
auto
equal_range(const _Kt& __x) const
-> decltype(pair<iterator, iterator>(_M_t._M_equal_range_tr(__x)))
{ return pair<iterator, iterator>(_M_t._M_equal_range_tr(__x)); }
#endif
//@}
template<typename _K1, typename _C1, typename _A1>
friend bool
operator==(const set<_K1, _C1, _A1>&, const set<_K1, _C1, _A1>&);
template<typename _K1, typename _C1, typename _A1>
friend bool
operator<(const set<_K1, _C1, _A1>&, const set<_K1, _C1, _A1>&);
};
#if __cpp_deduction_guides >= 201606
template<typename _InputIterator,
typename _Compare =
less<typename iterator_traits<_InputIterator>::value_type>,
typename _Allocator =
allocator<typename iterator_traits<_InputIterator>::value_type>,
typename = _RequireInputIter<_InputIterator>,
typename = _RequireAllocator<_Allocator>>
set(_InputIterator, _InputIterator,
_Compare = _Compare(), _Allocator = _Allocator())
-> set<typename iterator_traits<_InputIterator>::value_type,
_Compare, _Allocator>;
template<typename _Key, typename _Compare = less<_Key>,
typename _Allocator = allocator<_Key>,
typename = _RequireAllocator<_Allocator>>
set(initializer_list<_Key>,
_Compare = _Compare(), _Allocator = _Allocator())
-> set<_Key, _Compare, _Allocator>;
template<typename _InputIterator, typename _Allocator,
typename = _RequireInputIter<_InputIterator>,
typename = _RequireAllocator<_Allocator>>
set(_InputIterator, _InputIterator, _Allocator)
-> set<typename iterator_traits<_InputIterator>::value_type,
less<typename iterator_traits<_InputIterator>::value_type>,
_Allocator>;
template<typename _Key, typename _Allocator,
typename = _RequireAllocator<_Allocator>>
set(initializer_list<_Key>, _Allocator)
-> set<_Key, less<_Key>, _Allocator>;
#endif
/**
* @brief Set equality comparison.
* @param __x A %set.
* @param __y A %set of the same type as @a x.
* @return True iff the size and elements of the sets are equal.
*
* This is an equivalence relation. It is linear in the size of the sets.
* Sets are considered equivalent if their sizes are equal, and if
* corresponding elements compare equal.
*/
template<typename _Key, typename _Compare, typename _Alloc>
inline bool
operator==(const set<_Key, _Compare, _Alloc>& __x,
const set<_Key, _Compare, _Alloc>& __y)
{ return __x._M_t == __y._M_t; }
/**
* @brief Set ordering relation.
* @param __x A %set.
* @param __y A %set of the same type as @a x.
* @return True iff @a __x is lexicographically less than @a __y.
*
* This is a total ordering relation. It is linear in the size of the
* sets. The elements must be comparable with @c <.
*
* See std::lexicographical_compare() for how the determination is made.
*/
template<typename _Key, typename _Compare, typename _Alloc>
inline bool
operator<(const set<_Key, _Compare, _Alloc>& __x,
const set<_Key, _Compare, _Alloc>& __y)
{ return __x._M_t < __y._M_t; }
/// Returns !(x == y).
template<typename _Key, typename _Compare, typename _Alloc>
inline bool
operator!=(const set<_Key, _Compare, _Alloc>& __x,
const set<_Key, _Compare, _Alloc>& __y)
{ return !(__x == __y); }
/// Returns y < x.
template<typename _Key, typename _Compare, typename _Alloc>
inline bool
operator>(const set<_Key, _Compare, _Alloc>& __x,
const set<_Key, _Compare, _Alloc>& __y)
{ return __y < __x; }
/// Returns !(y < x)
template<typename _Key, typename _Compare, typename _Alloc>
inline bool
operator<=(const set<_Key, _Compare, _Alloc>& __x,
const set<_Key, _Compare, _Alloc>& __y)
{ return !(__y < __x); }
/// Returns !(x < y)
template<typename _Key, typename _Compare, typename _Alloc>
inline bool
operator>=(const set<_Key, _Compare, _Alloc>& __x,
const set<_Key, _Compare, _Alloc>& __y)
{ return !(__x < __y); }
/// See std::set::swap().
template<typename _Key, typename _Compare, typename _Alloc>
inline void
swap(set<_Key, _Compare, _Alloc>& __x, set<_Key, _Compare, _Alloc>& __y)
_GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
{ __x.swap(__y); }
_GLIBCXX_END_NAMESPACE_CONTAINER
#if __cplusplus > 201402L
// Allow std::set access to internals of compatible sets.
template<typename _Val, typename _Cmp1, typename _Alloc, typename _Cmp2>
struct
_Rb_tree_merge_helper<_GLIBCXX_STD_C::set<_Val, _Cmp1, _Alloc>, _Cmp2>
{
private:
friend class _GLIBCXX_STD_C::set<_Val, _Cmp1, _Alloc>;
static auto&
_S_get_tree(_GLIBCXX_STD_C::set<_Val, _Cmp2, _Alloc>& __set)
{ return __set._M_t; }
static auto&
_S_get_tree(_GLIBCXX_STD_C::multiset<_Val, _Cmp2, _Alloc>& __set)
{ return __set._M_t; }
};
#endif // C++17
_GLIBCXX_END_NAMESPACE_VERSION
} //namespace std
#endif /* _STL_SET_H */
c++/8/bits/regex_automaton.h 0000644 00000024742 15201526705 0011612 0 ustar 00 // class template regex -*- C++ -*-
// Copyright (C) 2013-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/**
* @file bits/regex_automaton.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{regex}
*/
// This macro defines the maximal state number a NFA can have.
#ifndef _GLIBCXX_REGEX_STATE_LIMIT
#define _GLIBCXX_REGEX_STATE_LIMIT 100000
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
namespace __detail
{
/**
* @defgroup regex-detail Base and Implementation Classes
* @ingroup regex
* @{
*/
typedef long _StateIdT;
static const _StateIdT _S_invalid_state_id = -1;
template<typename _CharT>
using _Matcher = std::function<bool (_CharT)>;
/// Operation codes that define the type of transitions within the base NFA
/// that represents the regular expression.
enum _Opcode : int
{
_S_opcode_unknown,
_S_opcode_alternative,
_S_opcode_repeat,
_S_opcode_backref,
_S_opcode_line_begin_assertion,
_S_opcode_line_end_assertion,
_S_opcode_word_boundary,
_S_opcode_subexpr_lookahead,
_S_opcode_subexpr_begin,
_S_opcode_subexpr_end,
_S_opcode_dummy,
_S_opcode_match,
_S_opcode_accept,
};
struct _State_base
{
protected:
_Opcode _M_opcode; // type of outgoing transition
public:
_StateIdT _M_next; // outgoing transition
union // Since they are mutually exclusive.
{
size_t _M_subexpr; // for _S_opcode_subexpr_*
size_t _M_backref_index; // for _S_opcode_backref
struct
{
// for _S_opcode_alternative, _S_opcode_repeat and
// _S_opcode_subexpr_lookahead
_StateIdT _M_alt;
// for _S_opcode_word_boundary or _S_opcode_subexpr_lookahead or
// quantifiers (ungreedy if set true)
bool _M_neg;
};
// For _S_opcode_match
__gnu_cxx::__aligned_membuf<_Matcher<char>> _M_matcher_storage;
};
protected:
explicit _State_base(_Opcode __opcode)
: _M_opcode(__opcode), _M_next(_S_invalid_state_id)
{ }
public:
bool
_M_has_alt()
{
return _M_opcode == _S_opcode_alternative
|| _M_opcode == _S_opcode_repeat
|| _M_opcode == _S_opcode_subexpr_lookahead;
}
#ifdef _GLIBCXX_DEBUG
std::ostream&
_M_print(std::ostream& ostr) const;
// Prints graphviz dot commands for state.
std::ostream&
_M_dot(std::ostream& __ostr, _StateIdT __id) const;
#endif
};
template<typename _Char_type>
struct _State : _State_base
{
typedef _Matcher<_Char_type> _MatcherT;
static_assert(sizeof(_MatcherT) == sizeof(_Matcher<char>),
"std::function<bool(T)> has the same size as "
"std::function<bool(char)>");
static_assert(alignof(_MatcherT) == alignof(_Matcher<char>),
"std::function<bool(T)> has the same alignment as "
"std::function<bool(char)>");
explicit
_State(_Opcode __opcode) : _State_base(__opcode)
{
if (_M_opcode() == _S_opcode_match)
new (this->_M_matcher_storage._M_addr()) _MatcherT();
}
_State(const _State& __rhs) : _State_base(__rhs)
{
if (__rhs._M_opcode() == _S_opcode_match)
new (this->_M_matcher_storage._M_addr())
_MatcherT(__rhs._M_get_matcher());
}
_State(_State&& __rhs) : _State_base(__rhs)
{
if (__rhs._M_opcode() == _S_opcode_match)
new (this->_M_matcher_storage._M_addr())
_MatcherT(std::move(__rhs._M_get_matcher()));
}
_State&
operator=(const _State&) = delete;
~_State()
{
if (_M_opcode() == _S_opcode_match)
_M_get_matcher().~_MatcherT();
}
// Since correct ctor and dtor rely on _M_opcode, it's better not to
// change it over time.
_Opcode
_M_opcode() const
{ return _State_base::_M_opcode; }
bool
_M_matches(_Char_type __char) const
{ return _M_get_matcher()(__char); }
_MatcherT&
_M_get_matcher()
{ return *static_cast<_MatcherT*>(this->_M_matcher_storage._M_addr()); }
const _MatcherT&
_M_get_matcher() const
{
return *static_cast<const _MatcherT*>(
this->_M_matcher_storage._M_addr());
}
};
struct _NFA_base
{
typedef size_t _SizeT;
typedef regex_constants::syntax_option_type _FlagT;
explicit
_NFA_base(_FlagT __f)
: _M_flags(__f), _M_start_state(0), _M_subexpr_count(0),
_M_has_backref(false)
{ }
_NFA_base(_NFA_base&&) = default;
protected:
~_NFA_base() = default;
public:
_FlagT
_M_options() const
{ return _M_flags; }
_StateIdT
_M_start() const
{ return _M_start_state; }
_SizeT
_M_sub_count() const
{ return _M_subexpr_count; }
std::vector<size_t> _M_paren_stack;
_FlagT _M_flags;
_StateIdT _M_start_state;
_SizeT _M_subexpr_count;
bool _M_has_backref;
};
template<typename _TraitsT>
struct _NFA
: _NFA_base, std::vector<_State<typename _TraitsT::char_type>>
{
typedef typename _TraitsT::char_type _Char_type;
typedef _State<_Char_type> _StateT;
typedef _Matcher<_Char_type> _MatcherT;
_NFA(const typename _TraitsT::locale_type& __loc, _FlagT __flags)
: _NFA_base(__flags)
{ _M_traits.imbue(__loc); }
// for performance reasons _NFA objects should only be moved not copied
_NFA(const _NFA&) = delete;
_NFA(_NFA&&) = default;
_StateIdT
_M_insert_accept()
{
auto __ret = _M_insert_state(_StateT(_S_opcode_accept));
return __ret;
}
_StateIdT
_M_insert_alt(_StateIdT __next, _StateIdT __alt,
bool __neg __attribute__((__unused__)))
{
_StateT __tmp(_S_opcode_alternative);
// It labels every quantifier to make greedy comparison easier in BFS
// approach.
__tmp._M_next = __next;
__tmp._M_alt = __alt;
return _M_insert_state(std::move(__tmp));
}
_StateIdT
_M_insert_repeat(_StateIdT __next, _StateIdT __alt, bool __neg)
{
_StateT __tmp(_S_opcode_repeat);
// It labels every quantifier to make greedy comparison easier in BFS
// approach.
__tmp._M_next = __next;
__tmp._M_alt = __alt;
__tmp._M_neg = __neg;
return _M_insert_state(std::move(__tmp));
}
_StateIdT
_M_insert_matcher(_MatcherT __m)
{
_StateT __tmp(_S_opcode_match);
__tmp._M_get_matcher() = std::move(__m);
return _M_insert_state(std::move(__tmp));
}
_StateIdT
_M_insert_subexpr_begin()
{
auto __id = this->_M_subexpr_count++;
this->_M_paren_stack.push_back(__id);
_StateT __tmp(_S_opcode_subexpr_begin);
__tmp._M_subexpr = __id;
return _M_insert_state(std::move(__tmp));
}
_StateIdT
_M_insert_subexpr_end()
{
_StateT __tmp(_S_opcode_subexpr_end);
__tmp._M_subexpr = this->_M_paren_stack.back();
this->_M_paren_stack.pop_back();
return _M_insert_state(std::move(__tmp));
}
_StateIdT
_M_insert_backref(size_t __index);
_StateIdT
_M_insert_line_begin()
{ return _M_insert_state(_StateT(_S_opcode_line_begin_assertion)); }
_StateIdT
_M_insert_line_end()
{ return _M_insert_state(_StateT(_S_opcode_line_end_assertion)); }
_StateIdT
_M_insert_word_bound(bool __neg)
{
_StateT __tmp(_S_opcode_word_boundary);
__tmp._M_neg = __neg;
return _M_insert_state(std::move(__tmp));
}
_StateIdT
_M_insert_lookahead(_StateIdT __alt, bool __neg)
{
_StateT __tmp(_S_opcode_subexpr_lookahead);
__tmp._M_alt = __alt;
__tmp._M_neg = __neg;
return _M_insert_state(std::move(__tmp));
}
_StateIdT
_M_insert_dummy()
{ return _M_insert_state(_StateT(_S_opcode_dummy)); }
_StateIdT
_M_insert_state(_StateT __s)
{
this->push_back(std::move(__s));
if (this->size() > _GLIBCXX_REGEX_STATE_LIMIT)
__throw_regex_error(
regex_constants::error_space,
"Number of NFA states exceeds limit. Please use shorter regex "
"string, or use smaller brace expression, or make "
"_GLIBCXX_REGEX_STATE_LIMIT larger.");
return this->size() - 1;
}
// Eliminate dummy node in this NFA to make it compact.
void
_M_eliminate_dummy();
#ifdef _GLIBCXX_DEBUG
std::ostream&
_M_dot(std::ostream& __ostr) const;
#endif
public:
_TraitsT _M_traits;
};
/// Describes a sequence of one or more %_State, its current start
/// and end(s). This structure contains fragments of an NFA during
/// construction.
template<typename _TraitsT>
class _StateSeq
{
public:
typedef _NFA<_TraitsT> _RegexT;
public:
_StateSeq(_RegexT& __nfa, _StateIdT __s)
: _M_nfa(__nfa), _M_start(__s), _M_end(__s)
{ }
_StateSeq(_RegexT& __nfa, _StateIdT __s, _StateIdT __end)
: _M_nfa(__nfa), _M_start(__s), _M_end(__end)
{ }
// Append a state on *this and change *this to the new sequence.
void
_M_append(_StateIdT __id)
{
_M_nfa[_M_end]._M_next = __id;
_M_end = __id;
}
// Append a sequence on *this and change *this to the new sequence.
void
_M_append(const _StateSeq& __s)
{
_M_nfa[_M_end]._M_next = __s._M_start;
_M_end = __s._M_end;
}
// Clones an entire sequence.
_StateSeq
_M_clone();
public:
_RegexT& _M_nfa;
_StateIdT _M_start;
_StateIdT _M_end;
};
//@} regex-detail
} // namespace __detail
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#include <bits/regex_automaton.tcc>
c++/8/bits/atomic_futex.h 0000644 00000022550 15201526705 0011073 0 ustar 00 // -*- C++ -*- header.
// Copyright (C) 2015-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/atomic_futex.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly.
*/
#ifndef _GLIBCXX_ATOMIC_FUTEX_H
#define _GLIBCXX_ATOMIC_FUTEX_H 1
#pragma GCC system_header
#include <bits/c++config.h>
#include <atomic>
#include <chrono>
#if ! (defined(_GLIBCXX_HAVE_LINUX_FUTEX) && ATOMIC_INT_LOCK_FREE > 1)
#include <mutex>
#include <condition_variable>
#endif
#ifndef _GLIBCXX_ALWAYS_INLINE
#define _GLIBCXX_ALWAYS_INLINE inline __attribute__((__always_inline__))
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
#if defined(_GLIBCXX_HAVE_LINUX_FUTEX) && ATOMIC_INT_LOCK_FREE > 1
struct __atomic_futex_unsigned_base
{
// Returns false iff a timeout occurred.
bool
_M_futex_wait_until(unsigned *__addr, unsigned __val, bool __has_timeout,
chrono::seconds __s, chrono::nanoseconds __ns);
// This can be executed after the object has been destroyed.
static void _M_futex_notify_all(unsigned* __addr);
};
template <unsigned _Waiter_bit = 0x80000000>
class __atomic_futex_unsigned : __atomic_futex_unsigned_base
{
typedef chrono::system_clock __clock_t;
// This must be lock-free and at offset 0.
atomic<unsigned> _M_data;
public:
explicit
__atomic_futex_unsigned(unsigned __data) : _M_data(__data)
{ }
_GLIBCXX_ALWAYS_INLINE unsigned
_M_load(memory_order __mo)
{
return _M_data.load(__mo) & ~_Waiter_bit;
}
private:
// If a timeout occurs, returns a current value after the timeout;
// otherwise, returns the operand's value if equal is true or a different
// value if equal is false.
// The assumed value is the caller's assumption about the current value
// when making the call.
unsigned
_M_load_and_test_until(unsigned __assumed, unsigned __operand,
bool __equal, memory_order __mo, bool __has_timeout,
chrono::seconds __s, chrono::nanoseconds __ns)
{
for (;;)
{
// Don't bother checking the value again because we expect the caller
// to have done it recently.
// memory_order_relaxed is sufficient because we can rely on just the
// modification order (store_notify uses an atomic RMW operation too),
// and the futex syscalls synchronize between themselves.
_M_data.fetch_or(_Waiter_bit, memory_order_relaxed);
bool __ret = _M_futex_wait_until((unsigned*)(void*)&_M_data,
__assumed | _Waiter_bit,
__has_timeout, __s, __ns);
// Fetch the current value after waiting (clears _Waiter_bit).
__assumed = _M_load(__mo);
if (!__ret || ((__operand == __assumed) == __equal))
return __assumed;
// TODO adapt wait time
}
}
// Returns the operand's value if equal is true or a different value if
// equal is false.
// The assumed value is the caller's assumption about the current value
// when making the call.
unsigned
_M_load_and_test(unsigned __assumed, unsigned __operand,
bool __equal, memory_order __mo)
{
return _M_load_and_test_until(__assumed, __operand, __equal, __mo,
false, {}, {});
}
// If a timeout occurs, returns a current value after the timeout;
// otherwise, returns the operand's value if equal is true or a different
// value if equal is false.
// The assumed value is the caller's assumption about the current value
// when making the call.
template<typename _Dur>
unsigned
_M_load_and_test_until_impl(unsigned __assumed, unsigned __operand,
bool __equal, memory_order __mo,
const chrono::time_point<__clock_t, _Dur>& __atime)
{
auto __s = chrono::time_point_cast<chrono::seconds>(__atime);
auto __ns = chrono::duration_cast<chrono::nanoseconds>(__atime - __s);
// XXX correct?
return _M_load_and_test_until(__assumed, __operand, __equal, __mo,
true, __s.time_since_epoch(), __ns);
}
public:
_GLIBCXX_ALWAYS_INLINE unsigned
_M_load_when_not_equal(unsigned __val, memory_order __mo)
{
unsigned __i = _M_load(__mo);
if ((__i & ~_Waiter_bit) != __val)
return (__i & ~_Waiter_bit);
// TODO Spin-wait first.
return _M_load_and_test(__i, __val, false, __mo);
}
_GLIBCXX_ALWAYS_INLINE void
_M_load_when_equal(unsigned __val, memory_order __mo)
{
unsigned __i = _M_load(__mo);
if ((__i & ~_Waiter_bit) == __val)
return;
// TODO Spin-wait first.
_M_load_and_test(__i, __val, true, __mo);
}
// Returns false iff a timeout occurred.
template<typename _Rep, typename _Period>
_GLIBCXX_ALWAYS_INLINE bool
_M_load_when_equal_for(unsigned __val, memory_order __mo,
const chrono::duration<_Rep, _Period>& __rtime)
{
return _M_load_when_equal_until(__val, __mo,
__clock_t::now() + __rtime);
}
// Returns false iff a timeout occurred.
template<typename _Clock, typename _Duration>
_GLIBCXX_ALWAYS_INLINE bool
_M_load_when_equal_until(unsigned __val, memory_order __mo,
const chrono::time_point<_Clock, _Duration>& __atime)
{
// DR 887 - Sync unknown clock to known clock.
const typename _Clock::time_point __c_entry = _Clock::now();
const __clock_t::time_point __s_entry = __clock_t::now();
const auto __delta = __atime - __c_entry;
const auto __s_atime = __s_entry + __delta;
return _M_load_when_equal_until(__val, __mo, __s_atime);
}
// Returns false iff a timeout occurred.
template<typename _Duration>
_GLIBCXX_ALWAYS_INLINE bool
_M_load_when_equal_until(unsigned __val, memory_order __mo,
const chrono::time_point<__clock_t, _Duration>& __atime)
{
unsigned __i = _M_load(__mo);
if ((__i & ~_Waiter_bit) == __val)
return true;
// TODO Spin-wait first. Ignore effect on timeout.
__i = _M_load_and_test_until_impl(__i, __val, true, __mo, __atime);
return (__i & ~_Waiter_bit) == __val;
}
_GLIBCXX_ALWAYS_INLINE void
_M_store_notify_all(unsigned __val, memory_order __mo)
{
unsigned* __futex = (unsigned *)(void *)&_M_data;
if (_M_data.exchange(__val, __mo) & _Waiter_bit)
_M_futex_notify_all(__futex);
}
};
#else // ! (_GLIBCXX_HAVE_LINUX_FUTEX && ATOMIC_INT_LOCK_FREE > 1)
// If futexes are not available, use a mutex and a condvar to wait.
// Because we access the data only within critical sections, all accesses
// are sequentially consistent; thus, we satisfy any provided memory_order.
template <unsigned _Waiter_bit = 0x80000000>
class __atomic_futex_unsigned
{
typedef chrono::system_clock __clock_t;
unsigned _M_data;
mutex _M_mutex;
condition_variable _M_condvar;
public:
explicit
__atomic_futex_unsigned(unsigned __data) : _M_data(__data)
{ }
_GLIBCXX_ALWAYS_INLINE unsigned
_M_load(memory_order __mo)
{
unique_lock<mutex> __lock(_M_mutex);
return _M_data;
}
_GLIBCXX_ALWAYS_INLINE unsigned
_M_load_when_not_equal(unsigned __val, memory_order __mo)
{
unique_lock<mutex> __lock(_M_mutex);
while (_M_data == __val)
_M_condvar.wait(__lock);
return _M_data;
}
_GLIBCXX_ALWAYS_INLINE void
_M_load_when_equal(unsigned __val, memory_order __mo)
{
unique_lock<mutex> __lock(_M_mutex);
while (_M_data != __val)
_M_condvar.wait(__lock);
}
template<typename _Rep, typename _Period>
_GLIBCXX_ALWAYS_INLINE bool
_M_load_when_equal_for(unsigned __val, memory_order __mo,
const chrono::duration<_Rep, _Period>& __rtime)
{
unique_lock<mutex> __lock(_M_mutex);
return _M_condvar.wait_for(__lock, __rtime,
[&] { return _M_data == __val;});
}
template<typename _Clock, typename _Duration>
_GLIBCXX_ALWAYS_INLINE bool
_M_load_when_equal_until(unsigned __val, memory_order __mo,
const chrono::time_point<_Clock, _Duration>& __atime)
{
unique_lock<mutex> __lock(_M_mutex);
return _M_condvar.wait_until(__lock, __atime,
[&] { return _M_data == __val;});
}
_GLIBCXX_ALWAYS_INLINE void
_M_store_notify_all(unsigned __val, memory_order __mo)
{
unique_lock<mutex> __lock(_M_mutex);
_M_data = __val;
_M_condvar.notify_all();
}
};
#endif // _GLIBCXX_HAVE_LINUX_FUTEX && ATOMIC_INT_LOCK_FREE > 1
#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif
c++/8/bits/algorithmfwd.h 0000644 00000052350 15201526705 0011074 0 ustar 00 // <algorithm> Forward declarations -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/algorithmfwd.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{algorithm}
*/
#ifndef _GLIBCXX_ALGORITHMFWD_H
#define _GLIBCXX_ALGORITHMFWD_H 1
#pragma GCC system_header
#include <bits/c++config.h>
#include <bits/stl_pair.h>
#include <bits/stl_iterator_base_types.h>
#if __cplusplus >= 201103L
#include <initializer_list>
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/*
adjacent_find
all_of (C++11)
any_of (C++11)
binary_search
clamp (C++17)
copy
copy_backward
copy_if (C++11)
copy_n (C++11)
count
count_if
equal
equal_range
fill
fill_n
find
find_end
find_first_of
find_if
find_if_not (C++11)
for_each
generate
generate_n
includes
inplace_merge
is_heap (C++11)
is_heap_until (C++11)
is_partitioned (C++11)
is_sorted (C++11)
is_sorted_until (C++11)
iter_swap
lexicographical_compare
lower_bound
make_heap
max
max_element
merge
min
min_element
minmax (C++11)
minmax_element (C++11)
mismatch
next_permutation
none_of (C++11)
nth_element
partial_sort
partial_sort_copy
partition
partition_copy (C++11)
partition_point (C++11)
pop_heap
prev_permutation
push_heap
random_shuffle
remove
remove_copy
remove_copy_if
remove_if
replace
replace_copy
replace_copy_if
replace_if
reverse
reverse_copy
rotate
rotate_copy
search
search_n
set_difference
set_intersection
set_symmetric_difference
set_union
shuffle (C++11)
sort
sort_heap
stable_partition
stable_sort
swap
swap_ranges
transform
unique
unique_copy
upper_bound
*/
/**
* @defgroup algorithms Algorithms
*
* Components for performing algorithmic operations. Includes
* non-modifying sequence, modifying (mutating) sequence, sorting,
* searching, merge, partition, heap, set, minima, maxima, and
* permutation operations.
*/
/**
* @defgroup mutating_algorithms Mutating
* @ingroup algorithms
*/
/**
* @defgroup non_mutating_algorithms Non-Mutating
* @ingroup algorithms
*/
/**
* @defgroup sorting_algorithms Sorting
* @ingroup algorithms
*/
/**
* @defgroup set_algorithms Set Operation
* @ingroup sorting_algorithms
*
* These algorithms are common set operations performed on sequences
* that are already sorted. The number of comparisons will be
* linear.
*/
/**
* @defgroup binary_search_algorithms Binary Search
* @ingroup sorting_algorithms
*
* These algorithms are variations of a classic binary search, and
* all assume that the sequence being searched is already sorted.
*
* The number of comparisons will be logarithmic (and as few as
* possible). The number of steps through the sequence will be
* logarithmic for random-access iterators (e.g., pointers), and
* linear otherwise.
*
* The LWG has passed Defect Report 270, which notes: <em>The
* proposed resolution reinterprets binary search. Instead of
* thinking about searching for a value in a sorted range, we view
* that as an important special case of a more general algorithm:
* searching for the partition point in a partitioned range. We
* also add a guarantee that the old wording did not: we ensure that
* the upper bound is no earlier than the lower bound, that the pair
* returned by equal_range is a valid range, and that the first part
* of that pair is the lower bound.</em>
*
* The actual effect of the first sentence is that a comparison
* functor passed by the user doesn't necessarily need to induce a
* strict weak ordering relation. Rather, it partitions the range.
*/
// adjacent_find
#if __cplusplus >= 201103L
template<typename _IIter, typename _Predicate>
bool
all_of(_IIter, _IIter, _Predicate);
template<typename _IIter, typename _Predicate>
bool
any_of(_IIter, _IIter, _Predicate);
#endif
template<typename _FIter, typename _Tp>
bool
binary_search(_FIter, _FIter, const _Tp&);
template<typename _FIter, typename _Tp, typename _Compare>
bool
binary_search(_FIter, _FIter, const _Tp&, _Compare);
#if __cplusplus > 201402L
template<typename _Tp>
_GLIBCXX14_CONSTEXPR
const _Tp&
clamp(const _Tp&, const _Tp&, const _Tp&);
template<typename _Tp, typename _Compare>
_GLIBCXX14_CONSTEXPR
const _Tp&
clamp(const _Tp&, const _Tp&, const _Tp&, _Compare);
#endif
template<typename _IIter, typename _OIter>
_OIter
copy(_IIter, _IIter, _OIter);
template<typename _BIter1, typename _BIter2>
_BIter2
copy_backward(_BIter1, _BIter1, _BIter2);
#if __cplusplus >= 201103L
template<typename _IIter, typename _OIter, typename _Predicate>
_OIter
copy_if(_IIter, _IIter, _OIter, _Predicate);
template<typename _IIter, typename _Size, typename _OIter>
_OIter
copy_n(_IIter, _Size, _OIter);
#endif
// count
// count_if
template<typename _FIter, typename _Tp>
pair<_FIter, _FIter>
equal_range(_FIter, _FIter, const _Tp&);
template<typename _FIter, typename _Tp, typename _Compare>
pair<_FIter, _FIter>
equal_range(_FIter, _FIter, const _Tp&, _Compare);
template<typename _FIter, typename _Tp>
void
fill(_FIter, _FIter, const _Tp&);
template<typename _OIter, typename _Size, typename _Tp>
_OIter
fill_n(_OIter, _Size, const _Tp&);
// find
template<typename _FIter1, typename _FIter2>
_FIter1
find_end(_FIter1, _FIter1, _FIter2, _FIter2);
template<typename _FIter1, typename _FIter2, typename _BinaryPredicate>
_FIter1
find_end(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate);
// find_first_of
// find_if
#if __cplusplus >= 201103L
template<typename _IIter, typename _Predicate>
_IIter
find_if_not(_IIter, _IIter, _Predicate);
#endif
// for_each
// generate
// generate_n
template<typename _IIter1, typename _IIter2>
bool
includes(_IIter1, _IIter1, _IIter2, _IIter2);
template<typename _IIter1, typename _IIter2, typename _Compare>
bool
includes(_IIter1, _IIter1, _IIter2, _IIter2, _Compare);
template<typename _BIter>
void
inplace_merge(_BIter, _BIter, _BIter);
template<typename _BIter, typename _Compare>
void
inplace_merge(_BIter, _BIter, _BIter, _Compare);
#if __cplusplus >= 201103L
template<typename _RAIter>
bool
is_heap(_RAIter, _RAIter);
template<typename _RAIter, typename _Compare>
bool
is_heap(_RAIter, _RAIter, _Compare);
template<typename _RAIter>
_RAIter
is_heap_until(_RAIter, _RAIter);
template<typename _RAIter, typename _Compare>
_RAIter
is_heap_until(_RAIter, _RAIter, _Compare);
template<typename _IIter, typename _Predicate>
bool
is_partitioned(_IIter, _IIter, _Predicate);
template<typename _FIter1, typename _FIter2>
bool
is_permutation(_FIter1, _FIter1, _FIter2);
template<typename _FIter1, typename _FIter2,
typename _BinaryPredicate>
bool
is_permutation(_FIter1, _FIter1, _FIter2, _BinaryPredicate);
template<typename _FIter>
bool
is_sorted(_FIter, _FIter);
template<typename _FIter, typename _Compare>
bool
is_sorted(_FIter, _FIter, _Compare);
template<typename _FIter>
_FIter
is_sorted_until(_FIter, _FIter);
template<typename _FIter, typename _Compare>
_FIter
is_sorted_until(_FIter, _FIter, _Compare);
#endif
template<typename _FIter1, typename _FIter2>
void
iter_swap(_FIter1, _FIter2);
template<typename _FIter, typename _Tp>
_FIter
lower_bound(_FIter, _FIter, const _Tp&);
template<typename _FIter, typename _Tp, typename _Compare>
_FIter
lower_bound(_FIter, _FIter, const _Tp&, _Compare);
template<typename _RAIter>
void
make_heap(_RAIter, _RAIter);
template<typename _RAIter, typename _Compare>
void
make_heap(_RAIter, _RAIter, _Compare);
template<typename _Tp>
_GLIBCXX14_CONSTEXPR
const _Tp&
max(const _Tp&, const _Tp&);
template<typename _Tp, typename _Compare>
_GLIBCXX14_CONSTEXPR
const _Tp&
max(const _Tp&, const _Tp&, _Compare);
// max_element
// merge
template<typename _Tp>
_GLIBCXX14_CONSTEXPR
const _Tp&
min(const _Tp&, const _Tp&);
template<typename _Tp, typename _Compare>
_GLIBCXX14_CONSTEXPR
const _Tp&
min(const _Tp&, const _Tp&, _Compare);
// min_element
#if __cplusplus >= 201103L
template<typename _Tp>
_GLIBCXX14_CONSTEXPR
pair<const _Tp&, const _Tp&>
minmax(const _Tp&, const _Tp&);
template<typename _Tp, typename _Compare>
_GLIBCXX14_CONSTEXPR
pair<const _Tp&, const _Tp&>
minmax(const _Tp&, const _Tp&, _Compare);
template<typename _FIter>
_GLIBCXX14_CONSTEXPR
pair<_FIter, _FIter>
minmax_element(_FIter, _FIter);
template<typename _FIter, typename _Compare>
_GLIBCXX14_CONSTEXPR
pair<_FIter, _FIter>
minmax_element(_FIter, _FIter, _Compare);
template<typename _Tp>
_GLIBCXX14_CONSTEXPR
_Tp
min(initializer_list<_Tp>);
template<typename _Tp, typename _Compare>
_GLIBCXX14_CONSTEXPR
_Tp
min(initializer_list<_Tp>, _Compare);
template<typename _Tp>
_GLIBCXX14_CONSTEXPR
_Tp
max(initializer_list<_Tp>);
template<typename _Tp, typename _Compare>
_GLIBCXX14_CONSTEXPR
_Tp
max(initializer_list<_Tp>, _Compare);
template<typename _Tp>
_GLIBCXX14_CONSTEXPR
pair<_Tp, _Tp>
minmax(initializer_list<_Tp>);
template<typename _Tp, typename _Compare>
_GLIBCXX14_CONSTEXPR
pair<_Tp, _Tp>
minmax(initializer_list<_Tp>, _Compare);
#endif
// mismatch
template<typename _BIter>
bool
next_permutation(_BIter, _BIter);
template<typename _BIter, typename _Compare>
bool
next_permutation(_BIter, _BIter, _Compare);
#if __cplusplus >= 201103L
template<typename _IIter, typename _Predicate>
bool
none_of(_IIter, _IIter, _Predicate);
#endif
// nth_element
// partial_sort
template<typename _IIter, typename _RAIter>
_RAIter
partial_sort_copy(_IIter, _IIter, _RAIter, _RAIter);
template<typename _IIter, typename _RAIter, typename _Compare>
_RAIter
partial_sort_copy(_IIter, _IIter, _RAIter, _RAIter, _Compare);
// partition
#if __cplusplus >= 201103L
template<typename _IIter, typename _OIter1,
typename _OIter2, typename _Predicate>
pair<_OIter1, _OIter2>
partition_copy(_IIter, _IIter, _OIter1, _OIter2, _Predicate);
template<typename _FIter, typename _Predicate>
_FIter
partition_point(_FIter, _FIter, _Predicate);
#endif
template<typename _RAIter>
void
pop_heap(_RAIter, _RAIter);
template<typename _RAIter, typename _Compare>
void
pop_heap(_RAIter, _RAIter, _Compare);
template<typename _BIter>
bool
prev_permutation(_BIter, _BIter);
template<typename _BIter, typename _Compare>
bool
prev_permutation(_BIter, _BIter, _Compare);
template<typename _RAIter>
void
push_heap(_RAIter, _RAIter);
template<typename _RAIter, typename _Compare>
void
push_heap(_RAIter, _RAIter, _Compare);
// random_shuffle
template<typename _FIter, typename _Tp>
_FIter
remove(_FIter, _FIter, const _Tp&);
template<typename _FIter, typename _Predicate>
_FIter
remove_if(_FIter, _FIter, _Predicate);
template<typename _IIter, typename _OIter, typename _Tp>
_OIter
remove_copy(_IIter, _IIter, _OIter, const _Tp&);
template<typename _IIter, typename _OIter, typename _Predicate>
_OIter
remove_copy_if(_IIter, _IIter, _OIter, _Predicate);
// replace
template<typename _IIter, typename _OIter, typename _Tp>
_OIter
replace_copy(_IIter, _IIter, _OIter, const _Tp&, const _Tp&);
template<typename _Iter, typename _OIter, typename _Predicate, typename _Tp>
_OIter
replace_copy_if(_Iter, _Iter, _OIter, _Predicate, const _Tp&);
// replace_if
template<typename _BIter>
void
reverse(_BIter, _BIter);
template<typename _BIter, typename _OIter>
_OIter
reverse_copy(_BIter, _BIter, _OIter);
inline namespace _V2
{
template<typename _FIter>
_FIter
rotate(_FIter, _FIter, _FIter);
}
template<typename _FIter, typename _OIter>
_OIter
rotate_copy(_FIter, _FIter, _FIter, _OIter);
// search
// search_n
// set_difference
// set_intersection
// set_symmetric_difference
// set_union
#if (__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
template<typename _RAIter, typename _UGenerator>
void
shuffle(_RAIter, _RAIter, _UGenerator&&);
#endif
template<typename _RAIter>
void
sort_heap(_RAIter, _RAIter);
template<typename _RAIter, typename _Compare>
void
sort_heap(_RAIter, _RAIter, _Compare);
template<typename _BIter, typename _Predicate>
_BIter
stable_partition(_BIter, _BIter, _Predicate);
#if __cplusplus < 201103L
// For C++11 swap() is declared in <type_traits>.
template<typename _Tp, size_t _Nm>
inline void
swap(_Tp& __a, _Tp& __b);
template<typename _Tp, size_t _Nm>
inline void
swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]);
#endif
template<typename _FIter1, typename _FIter2>
_FIter2
swap_ranges(_FIter1, _FIter1, _FIter2);
// transform
template<typename _FIter>
_FIter
unique(_FIter, _FIter);
template<typename _FIter, typename _BinaryPredicate>
_FIter
unique(_FIter, _FIter, _BinaryPredicate);
// unique_copy
template<typename _FIter, typename _Tp>
_FIter
upper_bound(_FIter, _FIter, const _Tp&);
template<typename _FIter, typename _Tp, typename _Compare>
_FIter
upper_bound(_FIter, _FIter, const _Tp&, _Compare);
_GLIBCXX_BEGIN_NAMESPACE_ALGO
template<typename _FIter>
_FIter
adjacent_find(_FIter, _FIter);
template<typename _FIter, typename _BinaryPredicate>
_FIter
adjacent_find(_FIter, _FIter, _BinaryPredicate);
template<typename _IIter, typename _Tp>
typename iterator_traits<_IIter>::difference_type
count(_IIter, _IIter, const _Tp&);
template<typename _IIter, typename _Predicate>
typename iterator_traits<_IIter>::difference_type
count_if(_IIter, _IIter, _Predicate);
template<typename _IIter1, typename _IIter2>
bool
equal(_IIter1, _IIter1, _IIter2);
template<typename _IIter1, typename _IIter2, typename _BinaryPredicate>
bool
equal(_IIter1, _IIter1, _IIter2, _BinaryPredicate);
template<typename _IIter, typename _Tp>
_IIter
find(_IIter, _IIter, const _Tp&);
template<typename _FIter1, typename _FIter2>
_FIter1
find_first_of(_FIter1, _FIter1, _FIter2, _FIter2);
template<typename _FIter1, typename _FIter2, typename _BinaryPredicate>
_FIter1
find_first_of(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate);
template<typename _IIter, typename _Predicate>
_IIter
find_if(_IIter, _IIter, _Predicate);
template<typename _IIter, typename _Funct>
_Funct
for_each(_IIter, _IIter, _Funct);
template<typename _FIter, typename _Generator>
void
generate(_FIter, _FIter, _Generator);
template<typename _OIter, typename _Size, typename _Generator>
_OIter
generate_n(_OIter, _Size, _Generator);
template<typename _IIter1, typename _IIter2>
bool
lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2);
template<typename _IIter1, typename _IIter2, typename _Compare>
bool
lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2, _Compare);
template<typename _FIter>
_GLIBCXX14_CONSTEXPR
_FIter
max_element(_FIter, _FIter);
template<typename _FIter, typename _Compare>
_GLIBCXX14_CONSTEXPR
_FIter
max_element(_FIter, _FIter, _Compare);
template<typename _IIter1, typename _IIter2, typename _OIter>
_OIter
merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter);
template<typename _IIter1, typename _IIter2, typename _OIter,
typename _Compare>
_OIter
merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare);
template<typename _FIter>
_GLIBCXX14_CONSTEXPR
_FIter
min_element(_FIter, _FIter);
template<typename _FIter, typename _Compare>
_GLIBCXX14_CONSTEXPR
_FIter
min_element(_FIter, _FIter, _Compare);
template<typename _IIter1, typename _IIter2>
pair<_IIter1, _IIter2>
mismatch(_IIter1, _IIter1, _IIter2);
template<typename _IIter1, typename _IIter2, typename _BinaryPredicate>
pair<_IIter1, _IIter2>
mismatch(_IIter1, _IIter1, _IIter2, _BinaryPredicate);
template<typename _RAIter>
void
nth_element(_RAIter, _RAIter, _RAIter);
template<typename _RAIter, typename _Compare>
void
nth_element(_RAIter, _RAIter, _RAIter, _Compare);
template<typename _RAIter>
void
partial_sort(_RAIter, _RAIter, _RAIter);
template<typename _RAIter, typename _Compare>
void
partial_sort(_RAIter, _RAIter, _RAIter, _Compare);
template<typename _BIter, typename _Predicate>
_BIter
partition(_BIter, _BIter, _Predicate);
template<typename _RAIter>
void
random_shuffle(_RAIter, _RAIter);
template<typename _RAIter, typename _Generator>
void
random_shuffle(_RAIter, _RAIter,
#if __cplusplus >= 201103L
_Generator&&);
#else
_Generator&);
#endif
template<typename _FIter, typename _Tp>
void
replace(_FIter, _FIter, const _Tp&, const _Tp&);
template<typename _FIter, typename _Predicate, typename _Tp>
void
replace_if(_FIter, _FIter, _Predicate, const _Tp&);
template<typename _FIter1, typename _FIter2>
_FIter1
search(_FIter1, _FIter1, _FIter2, _FIter2);
template<typename _FIter1, typename _FIter2, typename _BinaryPredicate>
_FIter1
search(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate);
template<typename _FIter, typename _Size, typename _Tp>
_FIter
search_n(_FIter, _FIter, _Size, const _Tp&);
template<typename _FIter, typename _Size, typename _Tp,
typename _BinaryPredicate>
_FIter
search_n(_FIter, _FIter, _Size, const _Tp&, _BinaryPredicate);
template<typename _IIter1, typename _IIter2, typename _OIter>
_OIter
set_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter);
template<typename _IIter1, typename _IIter2, typename _OIter,
typename _Compare>
_OIter
set_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare);
template<typename _IIter1, typename _IIter2, typename _OIter>
_OIter
set_intersection(_IIter1, _IIter1, _IIter2, _IIter2, _OIter);
template<typename _IIter1, typename _IIter2, typename _OIter,
typename _Compare>
_OIter
set_intersection(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare);
template<typename _IIter1, typename _IIter2, typename _OIter>
_OIter
set_symmetric_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter);
template<typename _IIter1, typename _IIter2, typename _OIter,
typename _Compare>
_OIter
set_symmetric_difference(_IIter1, _IIter1, _IIter2, _IIter2,
_OIter, _Compare);
template<typename _IIter1, typename _IIter2, typename _OIter>
_OIter
set_union(_IIter1, _IIter1, _IIter2, _IIter2, _OIter);
template<typename _IIter1, typename _IIter2, typename _OIter,
typename _Compare>
_OIter
set_union(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare);
template<typename _RAIter>
void
sort(_RAIter, _RAIter);
template<typename _RAIter, typename _Compare>
void
sort(_RAIter, _RAIter, _Compare);
template<typename _RAIter>
void
stable_sort(_RAIter, _RAIter);
template<typename _RAIter, typename _Compare>
void
stable_sort(_RAIter, _RAIter, _Compare);
template<typename _IIter, typename _OIter, typename _UnaryOperation>
_OIter
transform(_IIter, _IIter, _OIter, _UnaryOperation);
template<typename _IIter1, typename _IIter2, typename _OIter,
typename _BinaryOperation>
_OIter
transform(_IIter1, _IIter1, _IIter2, _OIter, _BinaryOperation);
template<typename _IIter, typename _OIter>
_OIter
unique_copy(_IIter, _IIter, _OIter);
template<typename _IIter, typename _OIter, typename _BinaryPredicate>
_OIter
unique_copy(_IIter, _IIter, _OIter, _BinaryPredicate);
_GLIBCXX_END_NAMESPACE_ALGO
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#ifdef _GLIBCXX_PARALLEL
# include <parallel/algorithmfwd.h>
#endif
#endif
c++/8/bits/std_mutex.h 0000644 00000022122 15201526705 0010413 0 ustar 00 // std::mutex implementation -*- C++ -*-
// Copyright (C) 2003-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/std_mutex.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{mutex}
*/
#ifndef _GLIBCXX_MUTEX_H
#define _GLIBCXX_MUTEX_H 1
#pragma GCC system_header
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
#include <system_error>
#include <bits/functexcept.h>
#include <bits/gthr.h>
#include <bits/move.h> // for std::swap
#ifdef _GLIBCXX_USE_C99_STDINT_TR1
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @defgroup mutexes Mutexes
* @ingroup concurrency
*
* Classes for mutex support.
* @{
*/
#ifdef _GLIBCXX_HAS_GTHREADS
// Common base class for std::mutex and std::timed_mutex
class __mutex_base
{
protected:
typedef __gthread_mutex_t __native_type;
#ifdef __GTHREAD_MUTEX_INIT
__native_type _M_mutex = __GTHREAD_MUTEX_INIT;
constexpr __mutex_base() noexcept = default;
#else
__native_type _M_mutex;
__mutex_base() noexcept
{
// XXX EAGAIN, ENOMEM, EPERM, EBUSY(may), EINVAL(may)
__GTHREAD_MUTEX_INIT_FUNCTION(&_M_mutex);
}
~__mutex_base() noexcept { __gthread_mutex_destroy(&_M_mutex); }
#endif
__mutex_base(const __mutex_base&) = delete;
__mutex_base& operator=(const __mutex_base&) = delete;
};
/// The standard mutex type.
class mutex : private __mutex_base
{
public:
typedef __native_type* native_handle_type;
#ifdef __GTHREAD_MUTEX_INIT
constexpr
#endif
mutex() noexcept = default;
~mutex() = default;
mutex(const mutex&) = delete;
mutex& operator=(const mutex&) = delete;
void
lock()
{
int __e = __gthread_mutex_lock(&_M_mutex);
// EINVAL, EAGAIN, EBUSY, EINVAL, EDEADLK(may)
if (__e)
__throw_system_error(__e);
}
bool
try_lock() noexcept
{
// XXX EINVAL, EAGAIN, EBUSY
return !__gthread_mutex_trylock(&_M_mutex);
}
void
unlock()
{
// XXX EINVAL, EAGAIN, EPERM
__gthread_mutex_unlock(&_M_mutex);
}
native_handle_type
native_handle() noexcept
{ return &_M_mutex; }
};
#endif // _GLIBCXX_HAS_GTHREADS
/// Do not acquire ownership of the mutex.
struct defer_lock_t { explicit defer_lock_t() = default; };
/// Try to acquire ownership of the mutex without blocking.
struct try_to_lock_t { explicit try_to_lock_t() = default; };
/// Assume the calling thread has already obtained mutex ownership
/// and manage it.
struct adopt_lock_t { explicit adopt_lock_t() = default; };
/// Tag used to prevent a scoped lock from acquiring ownership of a mutex.
_GLIBCXX17_INLINE constexpr defer_lock_t defer_lock { };
/// Tag used to prevent a scoped lock from blocking if a mutex is locked.
_GLIBCXX17_INLINE constexpr try_to_lock_t try_to_lock { };
/// Tag used to make a scoped lock take ownership of a locked mutex.
_GLIBCXX17_INLINE constexpr adopt_lock_t adopt_lock { };
/** @brief A simple scoped lock type.
*
* A lock_guard controls mutex ownership within a scope, releasing
* ownership in the destructor.
*/
template<typename _Mutex>
class lock_guard
{
public:
typedef _Mutex mutex_type;
explicit lock_guard(mutex_type& __m) : _M_device(__m)
{ _M_device.lock(); }
lock_guard(mutex_type& __m, adopt_lock_t) noexcept : _M_device(__m)
{ } // calling thread owns mutex
~lock_guard()
{ _M_device.unlock(); }
lock_guard(const lock_guard&) = delete;
lock_guard& operator=(const lock_guard&) = delete;
private:
mutex_type& _M_device;
};
/** @brief A movable scoped lock type.
*
* A unique_lock controls mutex ownership within a scope. Ownership of the
* mutex can be delayed until after construction and can be transferred
* to another unique_lock by move construction or move assignment. If a
* mutex lock is owned when the destructor runs ownership will be released.
*/
template<typename _Mutex>
class unique_lock
{
public:
typedef _Mutex mutex_type;
unique_lock() noexcept
: _M_device(0), _M_owns(false)
{ }
explicit unique_lock(mutex_type& __m)
: _M_device(std::__addressof(__m)), _M_owns(false)
{
lock();
_M_owns = true;
}
unique_lock(mutex_type& __m, defer_lock_t) noexcept
: _M_device(std::__addressof(__m)), _M_owns(false)
{ }
unique_lock(mutex_type& __m, try_to_lock_t)
: _M_device(std::__addressof(__m)), _M_owns(_M_device->try_lock())
{ }
unique_lock(mutex_type& __m, adopt_lock_t) noexcept
: _M_device(std::__addressof(__m)), _M_owns(true)
{
// XXX calling thread owns mutex
}
template<typename _Clock, typename _Duration>
unique_lock(mutex_type& __m,
const chrono::time_point<_Clock, _Duration>& __atime)
: _M_device(std::__addressof(__m)),
_M_owns(_M_device->try_lock_until(__atime))
{ }
template<typename _Rep, typename _Period>
unique_lock(mutex_type& __m,
const chrono::duration<_Rep, _Period>& __rtime)
: _M_device(std::__addressof(__m)),
_M_owns(_M_device->try_lock_for(__rtime))
{ }
~unique_lock()
{
if (_M_owns)
unlock();
}
unique_lock(const unique_lock&) = delete;
unique_lock& operator=(const unique_lock&) = delete;
unique_lock(unique_lock&& __u) noexcept
: _M_device(__u._M_device), _M_owns(__u._M_owns)
{
__u._M_device = 0;
__u._M_owns = false;
}
unique_lock& operator=(unique_lock&& __u) noexcept
{
if(_M_owns)
unlock();
unique_lock(std::move(__u)).swap(*this);
__u._M_device = 0;
__u._M_owns = false;
return *this;
}
void
lock()
{
if (!_M_device)
__throw_system_error(int(errc::operation_not_permitted));
else if (_M_owns)
__throw_system_error(int(errc::resource_deadlock_would_occur));
else
{
_M_device->lock();
_M_owns = true;
}
}
bool
try_lock()
{
if (!_M_device)
__throw_system_error(int(errc::operation_not_permitted));
else if (_M_owns)
__throw_system_error(int(errc::resource_deadlock_would_occur));
else
{
_M_owns = _M_device->try_lock();
return _M_owns;
}
}
template<typename _Clock, typename _Duration>
bool
try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime)
{
if (!_M_device)
__throw_system_error(int(errc::operation_not_permitted));
else if (_M_owns)
__throw_system_error(int(errc::resource_deadlock_would_occur));
else
{
_M_owns = _M_device->try_lock_until(__atime);
return _M_owns;
}
}
template<typename _Rep, typename _Period>
bool
try_lock_for(const chrono::duration<_Rep, _Period>& __rtime)
{
if (!_M_device)
__throw_system_error(int(errc::operation_not_permitted));
else if (_M_owns)
__throw_system_error(int(errc::resource_deadlock_would_occur));
else
{
_M_owns = _M_device->try_lock_for(__rtime);
return _M_owns;
}
}
void
unlock()
{
if (!_M_owns)
__throw_system_error(int(errc::operation_not_permitted));
else if (_M_device)
{
_M_device->unlock();
_M_owns = false;
}
}
void
swap(unique_lock& __u) noexcept
{
std::swap(_M_device, __u._M_device);
std::swap(_M_owns, __u._M_owns);
}
mutex_type*
release() noexcept
{
mutex_type* __ret = _M_device;
_M_device = 0;
_M_owns = false;
return __ret;
}
bool
owns_lock() const noexcept
{ return _M_owns; }
explicit operator bool() const noexcept
{ return owns_lock(); }
mutex_type*
mutex() const noexcept
{ return _M_device; }
private:
mutex_type* _M_device;
bool _M_owns; // XXX use atomic_bool
};
/// Swap overload for unique_lock objects.
template<typename _Mutex>
inline void
swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>& __y) noexcept
{ __x.swap(__y); }
// @} group mutexes
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif // _GLIBCXX_USE_C99_STDINT_TR1
#endif // C++11
#endif // _GLIBCXX_MUTEX_H
c++/8/bits/functexcept.h 0000644 00000006266 15201526705 0010742 0 ustar 00 // Function-Based Exception Support -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/functexcept.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{exception}
*
* This header provides support for -fno-exceptions.
*/
//
// ISO C++ 14882: 19.1 Exception classes
//
#ifndef _FUNCTEXCEPT_H
#define _FUNCTEXCEPT_H 1
#include <bits/c++config.h>
#include <bits/exception_defines.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Helper for exception objects in <except>
void
__throw_bad_exception(void) __attribute__((__noreturn__));
// Helper for exception objects in <new>
void
__throw_bad_alloc(void) __attribute__((__noreturn__));
// Helper for exception objects in <typeinfo>
void
__throw_bad_cast(void) __attribute__((__noreturn__));
void
__throw_bad_typeid(void) __attribute__((__noreturn__));
// Helpers for exception objects in <stdexcept>
void
__throw_logic_error(const char*) __attribute__((__noreturn__));
void
__throw_domain_error(const char*) __attribute__((__noreturn__));
void
__throw_invalid_argument(const char*) __attribute__((__noreturn__));
void
__throw_length_error(const char*) __attribute__((__noreturn__));
void
__throw_out_of_range(const char*) __attribute__((__noreturn__));
void
__throw_out_of_range_fmt(const char*, ...) __attribute__((__noreturn__))
__attribute__((__format__(__gnu_printf__, 1, 2)));
void
__throw_runtime_error(const char*) __attribute__((__noreturn__));
void
__throw_range_error(const char*) __attribute__((__noreturn__));
void
__throw_overflow_error(const char*) __attribute__((__noreturn__));
void
__throw_underflow_error(const char*) __attribute__((__noreturn__));
// Helpers for exception objects in <ios>
void
__throw_ios_failure(const char*) __attribute__((__noreturn__));
void
__throw_system_error(int) __attribute__((__noreturn__));
void
__throw_future_error(int) __attribute__((__noreturn__));
// Helpers for exception objects in <functional>
void
__throw_bad_function_call() __attribute__((__noreturn__));
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
c++/8/bits/valarray_after.h 0000644 00000054177 15201526705 0011420 0 ustar 00 // The template and inlines for the -*- C++ -*- internal _Meta class.
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/valarray_after.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{valarray}
*/
// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@cmla.ens-cachan.fr>
#ifndef _VALARRAY_AFTER_H
#define _VALARRAY_AFTER_H 1
#pragma GCC system_header
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
//
// gslice_array closure.
//
template<class _Dom>
class _GBase
{
public:
typedef typename _Dom::value_type value_type;
_GBase (const _Dom& __e, const valarray<size_t>& __i)
: _M_expr (__e), _M_index(__i) {}
value_type
operator[] (size_t __i) const
{ return _M_expr[_M_index[__i]]; }
size_t
size () const
{ return _M_index.size(); }
private:
const _Dom& _M_expr;
const valarray<size_t>& _M_index;
};
template<typename _Tp>
class _GBase<_Array<_Tp> >
{
public:
typedef _Tp value_type;
_GBase (_Array<_Tp> __a, const valarray<size_t>& __i)
: _M_array (__a), _M_index(__i) {}
value_type
operator[] (size_t __i) const
{ return _M_array._M_data[_M_index[__i]]; }
size_t
size () const
{ return _M_index.size(); }
private:
const _Array<_Tp> _M_array;
const valarray<size_t>& _M_index;
};
template<class _Dom>
struct _GClos<_Expr, _Dom>
: _GBase<_Dom>
{
typedef _GBase<_Dom> _Base;
typedef typename _Base::value_type value_type;
_GClos (const _Dom& __e, const valarray<size_t>& __i)
: _Base (__e, __i) {}
};
template<typename _Tp>
struct _GClos<_ValArray, _Tp>
: _GBase<_Array<_Tp> >
{
typedef _GBase<_Array<_Tp> > _Base;
typedef typename _Base::value_type value_type;
_GClos (_Array<_Tp> __a, const valarray<size_t>& __i)
: _Base (__a, __i) {}
};
//
// indirect_array closure
//
template<class _Dom>
class _IBase
{
public:
typedef typename _Dom::value_type value_type;
_IBase (const _Dom& __e, const valarray<size_t>& __i)
: _M_expr (__e), _M_index (__i) {}
value_type
operator[] (size_t __i) const
{ return _M_expr[_M_index[__i]]; }
size_t
size() const
{ return _M_index.size(); }
private:
const _Dom& _M_expr;
const valarray<size_t>& _M_index;
};
template<class _Dom>
struct _IClos<_Expr, _Dom>
: _IBase<_Dom>
{
typedef _IBase<_Dom> _Base;
typedef typename _Base::value_type value_type;
_IClos (const _Dom& __e, const valarray<size_t>& __i)
: _Base (__e, __i) {}
};
template<typename _Tp>
struct _IClos<_ValArray, _Tp>
: _IBase<valarray<_Tp> >
{
typedef _IBase<valarray<_Tp> > _Base;
typedef _Tp value_type;
_IClos (const valarray<_Tp>& __a, const valarray<size_t>& __i)
: _Base (__a, __i) {}
};
//
// class _Expr
//
template<class _Clos, typename _Tp>
class _Expr
{
public:
typedef _Tp value_type;
_Expr(const _Clos&);
const _Clos& operator()() const;
value_type operator[](size_t) const;
valarray<value_type> operator[](slice) const;
valarray<value_type> operator[](const gslice&) const;
valarray<value_type> operator[](const valarray<bool>&) const;
valarray<value_type> operator[](const valarray<size_t>&) const;
_Expr<_UnClos<__unary_plus, std::_Expr, _Clos>, value_type>
operator+() const;
_Expr<_UnClos<__negate, std::_Expr, _Clos>, value_type>
operator-() const;
_Expr<_UnClos<__bitwise_not, std::_Expr, _Clos>, value_type>
operator~() const;
_Expr<_UnClos<__logical_not, std::_Expr, _Clos>, bool>
operator!() const;
size_t size() const;
value_type sum() const;
valarray<value_type> shift(int) const;
valarray<value_type> cshift(int) const;
value_type min() const;
value_type max() const;
valarray<value_type> apply(value_type (*)(const value_type&)) const;
valarray<value_type> apply(value_type (*)(value_type)) const;
private:
const _Clos _M_closure;
};
template<class _Clos, typename _Tp>
inline
_Expr<_Clos, _Tp>::_Expr(const _Clos& __c) : _M_closure(__c) {}
template<class _Clos, typename _Tp>
inline const _Clos&
_Expr<_Clos, _Tp>::operator()() const
{ return _M_closure; }
template<class _Clos, typename _Tp>
inline _Tp
_Expr<_Clos, _Tp>::operator[](size_t __i) const
{ return _M_closure[__i]; }
template<class _Clos, typename _Tp>
inline valarray<_Tp>
_Expr<_Clos, _Tp>::operator[](slice __s) const
{
valarray<_Tp> __v = valarray<_Tp>(*this)[__s];
return __v;
}
template<class _Clos, typename _Tp>
inline valarray<_Tp>
_Expr<_Clos, _Tp>::operator[](const gslice& __gs) const
{
valarray<_Tp> __v = valarray<_Tp>(*this)[__gs];
return __v;
}
template<class _Clos, typename _Tp>
inline valarray<_Tp>
_Expr<_Clos, _Tp>::operator[](const valarray<bool>& __m) const
{
valarray<_Tp> __v = valarray<_Tp>(*this)[__m];
return __v;
}
template<class _Clos, typename _Tp>
inline valarray<_Tp>
_Expr<_Clos, _Tp>::operator[](const valarray<size_t>& __i) const
{
valarray<_Tp> __v = valarray<_Tp>(*this)[__i];
return __v;
}
template<class _Clos, typename _Tp>
inline size_t
_Expr<_Clos, _Tp>::size() const
{ return _M_closure.size(); }
template<class _Clos, typename _Tp>
inline valarray<_Tp>
_Expr<_Clos, _Tp>::shift(int __n) const
{
valarray<_Tp> __v = valarray<_Tp>(*this).shift(__n);
return __v;
}
template<class _Clos, typename _Tp>
inline valarray<_Tp>
_Expr<_Clos, _Tp>::cshift(int __n) const
{
valarray<_Tp> __v = valarray<_Tp>(*this).cshift(__n);
return __v;
}
template<class _Clos, typename _Tp>
inline valarray<_Tp>
_Expr<_Clos, _Tp>::apply(_Tp __f(const _Tp&)) const
{
valarray<_Tp> __v = valarray<_Tp>(*this).apply(__f);
return __v;
}
template<class _Clos, typename _Tp>
inline valarray<_Tp>
_Expr<_Clos, _Tp>::apply(_Tp __f(_Tp)) const
{
valarray<_Tp> __v = valarray<_Tp>(*this).apply(__f);
return __v;
}
// XXX: replace this with a more robust summation algorithm.
template<class _Clos, typename _Tp>
inline _Tp
_Expr<_Clos, _Tp>::sum() const
{
size_t __n = _M_closure.size();
if (__n == 0)
return _Tp();
else
{
_Tp __s = _M_closure[--__n];
while (__n != 0)
__s += _M_closure[--__n];
return __s;
}
}
template<class _Clos, typename _Tp>
inline _Tp
_Expr<_Clos, _Tp>::min() const
{ return __valarray_min(_M_closure); }
template<class _Clos, typename _Tp>
inline _Tp
_Expr<_Clos, _Tp>::max() const
{ return __valarray_max(_M_closure); }
template<class _Dom, typename _Tp>
inline _Expr<_UnClos<__logical_not, _Expr, _Dom>, bool>
_Expr<_Dom, _Tp>::operator!() const
{
typedef _UnClos<__logical_not, std::_Expr, _Dom> _Closure;
return _Expr<_Closure, bool>(_Closure(this->_M_closure));
}
#define _DEFINE_EXPR_UNARY_OPERATOR(_Op, _Name) \
template<class _Dom, typename _Tp> \
inline _Expr<_UnClos<_Name, std::_Expr, _Dom>, _Tp> \
_Expr<_Dom, _Tp>::operator _Op() const \
{ \
typedef _UnClos<_Name, std::_Expr, _Dom> _Closure; \
return _Expr<_Closure, _Tp>(_Closure(this->_M_closure)); \
}
_DEFINE_EXPR_UNARY_OPERATOR(+, __unary_plus)
_DEFINE_EXPR_UNARY_OPERATOR(-, __negate)
_DEFINE_EXPR_UNARY_OPERATOR(~, __bitwise_not)
#undef _DEFINE_EXPR_UNARY_OPERATOR
#define _DEFINE_EXPR_BINARY_OPERATOR(_Op, _Name) \
template<class _Dom1, class _Dom2> \
inline _Expr<_BinClos<_Name, _Expr, _Expr, _Dom1, _Dom2>, \
typename __fun<_Name, typename _Dom1::value_type>::result_type> \
operator _Op(const _Expr<_Dom1, typename _Dom1::value_type>& __v, \
const _Expr<_Dom2, typename _Dom2::value_type>& __w) \
{ \
typedef typename _Dom1::value_type _Arg; \
typedef typename __fun<_Name, _Arg>::result_type _Value; \
typedef _BinClos<_Name, _Expr, _Expr, _Dom1, _Dom2> _Closure; \
return _Expr<_Closure, _Value>(_Closure(__v(), __w())); \
} \
\
template<class _Dom> \
inline _Expr<_BinClos<_Name, _Expr, _Constant, _Dom, \
typename _Dom::value_type>, \
typename __fun<_Name, typename _Dom::value_type>::result_type> \
operator _Op(const _Expr<_Dom, typename _Dom::value_type>& __v, \
const typename _Dom::value_type& __t) \
{ \
typedef typename _Dom::value_type _Arg; \
typedef typename __fun<_Name, _Arg>::result_type _Value; \
typedef _BinClos<_Name, _Expr, _Constant, _Dom, _Arg> _Closure; \
return _Expr<_Closure, _Value>(_Closure(__v(), __t)); \
} \
\
template<class _Dom> \
inline _Expr<_BinClos<_Name, _Constant, _Expr, \
typename _Dom::value_type, _Dom>, \
typename __fun<_Name, typename _Dom::value_type>::result_type> \
operator _Op(const typename _Dom::value_type& __t, \
const _Expr<_Dom, typename _Dom::value_type>& __v) \
{ \
typedef typename _Dom::value_type _Arg; \
typedef typename __fun<_Name, _Arg>::result_type _Value; \
typedef _BinClos<_Name, _Constant, _Expr, _Arg, _Dom> _Closure; \
return _Expr<_Closure, _Value>(_Closure(__t, __v())); \
} \
\
template<class _Dom> \
inline _Expr<_BinClos<_Name, _Expr, _ValArray, \
_Dom, typename _Dom::value_type>, \
typename __fun<_Name, typename _Dom::value_type>::result_type> \
operator _Op(const _Expr<_Dom,typename _Dom::value_type>& __e, \
const valarray<typename _Dom::value_type>& __v) \
{ \
typedef typename _Dom::value_type _Arg; \
typedef typename __fun<_Name, _Arg>::result_type _Value; \
typedef _BinClos<_Name, _Expr, _ValArray, _Dom, _Arg> _Closure; \
return _Expr<_Closure, _Value>(_Closure(__e(), __v)); \
} \
\
template<class _Dom> \
inline _Expr<_BinClos<_Name, _ValArray, _Expr, \
typename _Dom::value_type, _Dom>, \
typename __fun<_Name, typename _Dom::value_type>::result_type> \
operator _Op(const valarray<typename _Dom::value_type>& __v, \
const _Expr<_Dom, typename _Dom::value_type>& __e) \
{ \
typedef typename _Dom::value_type _Tp; \
typedef typename __fun<_Name, _Tp>::result_type _Value; \
typedef _BinClos<_Name, _ValArray, _Expr, _Tp, _Dom> _Closure; \
return _Expr<_Closure, _Value>(_Closure(__v, __e ())); \
}
_DEFINE_EXPR_BINARY_OPERATOR(+, __plus)
_DEFINE_EXPR_BINARY_OPERATOR(-, __minus)
_DEFINE_EXPR_BINARY_OPERATOR(*, __multiplies)
_DEFINE_EXPR_BINARY_OPERATOR(/, __divides)
_DEFINE_EXPR_BINARY_OPERATOR(%, __modulus)
_DEFINE_EXPR_BINARY_OPERATOR(^, __bitwise_xor)
_DEFINE_EXPR_BINARY_OPERATOR(&, __bitwise_and)
_DEFINE_EXPR_BINARY_OPERATOR(|, __bitwise_or)
_DEFINE_EXPR_BINARY_OPERATOR(<<, __shift_left)
_DEFINE_EXPR_BINARY_OPERATOR(>>, __shift_right)
_DEFINE_EXPR_BINARY_OPERATOR(&&, __logical_and)
_DEFINE_EXPR_BINARY_OPERATOR(||, __logical_or)
_DEFINE_EXPR_BINARY_OPERATOR(==, __equal_to)
_DEFINE_EXPR_BINARY_OPERATOR(!=, __not_equal_to)
_DEFINE_EXPR_BINARY_OPERATOR(<, __less)
_DEFINE_EXPR_BINARY_OPERATOR(>, __greater)
_DEFINE_EXPR_BINARY_OPERATOR(<=, __less_equal)
_DEFINE_EXPR_BINARY_OPERATOR(>=, __greater_equal)
#undef _DEFINE_EXPR_BINARY_OPERATOR
#define _DEFINE_EXPR_UNARY_FUNCTION(_Name, _UName) \
template<class _Dom> \
inline _Expr<_UnClos<_UName, _Expr, _Dom>, \
typename _Dom::value_type> \
_Name(const _Expr<_Dom, typename _Dom::value_type>& __e) \
{ \
typedef typename _Dom::value_type _Tp; \
typedef _UnClos<_UName, _Expr, _Dom> _Closure; \
return _Expr<_Closure, _Tp>(_Closure(__e())); \
} \
\
template<typename _Tp> \
inline _Expr<_UnClos<_UName, _ValArray, _Tp>, _Tp> \
_Name(const valarray<_Tp>& __v) \
{ \
typedef _UnClos<_UName, _ValArray, _Tp> _Closure; \
return _Expr<_Closure, _Tp>(_Closure(__v)); \
}
_DEFINE_EXPR_UNARY_FUNCTION(abs, _Abs)
_DEFINE_EXPR_UNARY_FUNCTION(cos, _Cos)
_DEFINE_EXPR_UNARY_FUNCTION(acos, _Acos)
_DEFINE_EXPR_UNARY_FUNCTION(cosh, _Cosh)
_DEFINE_EXPR_UNARY_FUNCTION(sin, _Sin)
_DEFINE_EXPR_UNARY_FUNCTION(asin, _Asin)
_DEFINE_EXPR_UNARY_FUNCTION(sinh, _Sinh)
_DEFINE_EXPR_UNARY_FUNCTION(tan, _Tan)
_DEFINE_EXPR_UNARY_FUNCTION(tanh, _Tanh)
_DEFINE_EXPR_UNARY_FUNCTION(atan, _Atan)
_DEFINE_EXPR_UNARY_FUNCTION(exp, _Exp)
_DEFINE_EXPR_UNARY_FUNCTION(log, _Log)
_DEFINE_EXPR_UNARY_FUNCTION(log10, _Log10)
_DEFINE_EXPR_UNARY_FUNCTION(sqrt, _Sqrt)
#undef _DEFINE_EXPR_UNARY_FUNCTION
#define _DEFINE_EXPR_BINARY_FUNCTION(_Fun, _UFun) \
template<class _Dom1, class _Dom2> \
inline _Expr<_BinClos<_UFun, _Expr, _Expr, _Dom1, _Dom2>, \
typename _Dom1::value_type> \
_Fun(const _Expr<_Dom1, typename _Dom1::value_type>& __e1, \
const _Expr<_Dom2, typename _Dom2::value_type>& __e2) \
{ \
typedef typename _Dom1::value_type _Tp; \
typedef _BinClos<_UFun, _Expr, _Expr, _Dom1, _Dom2> _Closure; \
return _Expr<_Closure, _Tp>(_Closure(__e1(), __e2())); \
} \
\
template<class _Dom> \
inline _Expr<_BinClos<_UFun, _Expr, _ValArray, _Dom, \
typename _Dom::value_type>, \
typename _Dom::value_type> \
_Fun(const _Expr<_Dom, typename _Dom::value_type>& __e, \
const valarray<typename _Dom::value_type>& __v) \
{ \
typedef typename _Dom::value_type _Tp; \
typedef _BinClos<_UFun, _Expr, _ValArray, _Dom, _Tp> _Closure; \
return _Expr<_Closure, _Tp>(_Closure(__e(), __v)); \
} \
\
template<class _Dom> \
inline _Expr<_BinClos<_UFun, _ValArray, _Expr, \
typename _Dom::value_type, _Dom>, \
typename _Dom::value_type> \
_Fun(const valarray<typename _Dom::valarray>& __v, \
const _Expr<_Dom, typename _Dom::value_type>& __e) \
{ \
typedef typename _Dom::value_type _Tp; \
typedef _BinClos<_UFun, _ValArray, _Expr, _Tp, _Dom> _Closure; \
return _Expr<_Closure, _Tp>(_Closure(__v, __e())); \
} \
\
template<class _Dom> \
inline _Expr<_BinClos<_UFun, _Expr, _Constant, _Dom, \
typename _Dom::value_type>, \
typename _Dom::value_type> \
_Fun(const _Expr<_Dom, typename _Dom::value_type>& __e, \
const typename _Dom::value_type& __t) \
{ \
typedef typename _Dom::value_type _Tp; \
typedef _BinClos<_UFun, _Expr, _Constant, _Dom, _Tp> _Closure; \
return _Expr<_Closure, _Tp>(_Closure(__e(), __t)); \
} \
\
template<class _Dom> \
inline _Expr<_BinClos<_UFun, _Constant, _Expr, \
typename _Dom::value_type, _Dom>, \
typename _Dom::value_type> \
_Fun(const typename _Dom::value_type& __t, \
const _Expr<_Dom, typename _Dom::value_type>& __e) \
{ \
typedef typename _Dom::value_type _Tp; \
typedef _BinClos<_UFun, _Constant, _Expr, _Tp, _Dom> _Closure; \
return _Expr<_Closure, _Tp>(_Closure(__t, __e())); \
} \
\
template<typename _Tp> \
inline _Expr<_BinClos<_UFun, _ValArray, _ValArray, _Tp, _Tp>, _Tp> \
_Fun(const valarray<_Tp>& __v, const valarray<_Tp>& __w) \
{ \
typedef _BinClos<_UFun, _ValArray, _ValArray, _Tp, _Tp> _Closure;\
return _Expr<_Closure, _Tp>(_Closure(__v, __w)); \
} \
\
template<typename _Tp> \
inline _Expr<_BinClos<_UFun, _ValArray, _Constant, _Tp, _Tp>, _Tp> \
_Fun(const valarray<_Tp>& __v, const _Tp& __t) \
{ \
typedef _BinClos<_UFun, _ValArray, _Constant, _Tp, _Tp> _Closure;\
return _Expr<_Closure, _Tp>(_Closure(__v, __t)); \
} \
\
template<typename _Tp> \
inline _Expr<_BinClos<_UFun, _Constant, _ValArray, _Tp, _Tp>, _Tp> \
_Fun(const _Tp& __t, const valarray<_Tp>& __v) \
{ \
typedef _BinClos<_UFun, _Constant, _ValArray, _Tp, _Tp> _Closure;\
return _Expr<_Closure, _Tp>(_Closure(__t, __v)); \
}
_DEFINE_EXPR_BINARY_FUNCTION(atan2, _Atan2)
_DEFINE_EXPR_BINARY_FUNCTION(pow, _Pow)
#undef _DEFINE_EXPR_BINARY_FUNCTION
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif /* _CPP_VALARRAY_AFTER_H */
c++/8/bits/stl_deque.h 0000644 00000231357 15201526705 0010400 0 ustar 00 // Deque implementation -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file bits/stl_deque.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{deque}
*/
#ifndef _STL_DEQUE_H
#define _STL_DEQUE_H 1
#include <bits/concept_check.h>
#include <bits/stl_iterator_base_types.h>
#include <bits/stl_iterator_base_funcs.h>
#if __cplusplus >= 201103L
#include <initializer_list>
#endif
#include <debug/assertions.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
/**
* @brief This function controls the size of memory nodes.
* @param __size The size of an element.
* @return The number (not byte size) of elements per node.
*
* This function started off as a compiler kludge from SGI, but
* seems to be a useful wrapper around a repeated constant
* expression. The @b 512 is tunable (and no other code needs to
* change), but no investigation has been done since inheriting the
* SGI code. Touch _GLIBCXX_DEQUE_BUF_SIZE only if you know what
* you are doing, however: changing it breaks the binary
* compatibility!!
*/
#ifndef _GLIBCXX_DEQUE_BUF_SIZE
#define _GLIBCXX_DEQUE_BUF_SIZE 512
#endif
_GLIBCXX_CONSTEXPR inline size_t
__deque_buf_size(size_t __size)
{ return (__size < _GLIBCXX_DEQUE_BUF_SIZE
? size_t(_GLIBCXX_DEQUE_BUF_SIZE / __size) : size_t(1)); }
/**
* @brief A deque::iterator.
*
* Quite a bit of intelligence here. Much of the functionality of
* deque is actually passed off to this class. A deque holds two
* of these internally, marking its valid range. Access to
* elements is done as offsets of either of those two, relying on
* operator overloading in this class.
*
* All the functions are op overloads except for _M_set_node.
*/
template<typename _Tp, typename _Ref, typename _Ptr>
struct _Deque_iterator
{
#if __cplusplus < 201103L
typedef _Deque_iterator<_Tp, _Tp&, _Tp*> iterator;
typedef _Deque_iterator<_Tp, const _Tp&, const _Tp*> const_iterator;
typedef _Tp* _Elt_pointer;
typedef _Tp** _Map_pointer;
#else
private:
template<typename _Up>
using __ptr_to = typename pointer_traits<_Ptr>::template rebind<_Up>;
template<typename _CvTp>
using __iter = _Deque_iterator<_Tp, _CvTp&, __ptr_to<_CvTp>>;
public:
typedef __iter<_Tp> iterator;
typedef __iter<const _Tp> const_iterator;
typedef __ptr_to<_Tp> _Elt_pointer;
typedef __ptr_to<_Elt_pointer> _Map_pointer;
#endif
static size_t _S_buffer_size() _GLIBCXX_NOEXCEPT
{ return __deque_buf_size(sizeof(_Tp)); }
typedef std::random_access_iterator_tag iterator_category;
typedef _Tp value_type;
typedef _Ptr pointer;
typedef _Ref reference;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef _Deque_iterator _Self;
_Elt_pointer _M_cur;
_Elt_pointer _M_first;
_Elt_pointer _M_last;
_Map_pointer _M_node;
_Deque_iterator(_Elt_pointer __x, _Map_pointer __y) _GLIBCXX_NOEXCEPT
: _M_cur(__x), _M_first(*__y),
_M_last(*__y + _S_buffer_size()), _M_node(__y) { }
_Deque_iterator() _GLIBCXX_NOEXCEPT
: _M_cur(), _M_first(), _M_last(), _M_node() { }
_Deque_iterator(const iterator& __x) _GLIBCXX_NOEXCEPT
: _M_cur(__x._M_cur), _M_first(__x._M_first),
_M_last(__x._M_last), _M_node(__x._M_node) { }
iterator
_M_const_cast() const _GLIBCXX_NOEXCEPT
{ return iterator(_M_cur, _M_node); }
reference
operator*() const _GLIBCXX_NOEXCEPT
{ return *_M_cur; }
pointer
operator->() const _GLIBCXX_NOEXCEPT
{ return _M_cur; }
_Self&
operator++() _GLIBCXX_NOEXCEPT
{
++_M_cur;
if (_M_cur == _M_last)
{
_M_set_node(_M_node + 1);
_M_cur = _M_first;
}
return *this;
}
_Self
operator++(int) _GLIBCXX_NOEXCEPT
{
_Self __tmp = *this;
++*this;
return __tmp;
}
_Self&
operator--() _GLIBCXX_NOEXCEPT
{
if (_M_cur == _M_first)
{
_M_set_node(_M_node - 1);
_M_cur = _M_last;
}
--_M_cur;
return *this;
}
_Self
operator--(int) _GLIBCXX_NOEXCEPT
{
_Self __tmp = *this;
--*this;
return __tmp;
}
_Self&
operator+=(difference_type __n) _GLIBCXX_NOEXCEPT
{
const difference_type __offset = __n + (_M_cur - _M_first);
if (__offset >= 0 && __offset < difference_type(_S_buffer_size()))
_M_cur += __n;
else
{
const difference_type __node_offset =
__offset > 0 ? __offset / difference_type(_S_buffer_size())
: -difference_type((-__offset - 1)
/ _S_buffer_size()) - 1;
_M_set_node(_M_node + __node_offset);
_M_cur = _M_first + (__offset - __node_offset
* difference_type(_S_buffer_size()));
}
return *this;
}
_Self
operator+(difference_type __n) const _GLIBCXX_NOEXCEPT
{
_Self __tmp = *this;
return __tmp += __n;
}
_Self&
operator-=(difference_type __n) _GLIBCXX_NOEXCEPT
{ return *this += -__n; }
_Self
operator-(difference_type __n) const _GLIBCXX_NOEXCEPT
{
_Self __tmp = *this;
return __tmp -= __n;
}
reference
operator[](difference_type __n) const _GLIBCXX_NOEXCEPT
{ return *(*this + __n); }
/**
* Prepares to traverse new_node. Sets everything except
* _M_cur, which should therefore be set by the caller
* immediately afterwards, based on _M_first and _M_last.
*/
void
_M_set_node(_Map_pointer __new_node) _GLIBCXX_NOEXCEPT
{
_M_node = __new_node;
_M_first = *__new_node;
_M_last = _M_first + difference_type(_S_buffer_size());
}
};
// Note: we also provide overloads whose operands are of the same type in
// order to avoid ambiguous overload resolution when std::rel_ops operators
// are in scope (for additional details, see libstdc++/3628)
template<typename _Tp, typename _Ref, typename _Ptr>
inline bool
operator==(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
const _Deque_iterator<_Tp, _Ref, _Ptr>& __y) _GLIBCXX_NOEXCEPT
{ return __x._M_cur == __y._M_cur; }
template<typename _Tp, typename _RefL, typename _PtrL,
typename _RefR, typename _PtrR>
inline bool
operator==(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) _GLIBCXX_NOEXCEPT
{ return __x._M_cur == __y._M_cur; }
template<typename _Tp, typename _Ref, typename _Ptr>
inline bool
operator!=(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
const _Deque_iterator<_Tp, _Ref, _Ptr>& __y) _GLIBCXX_NOEXCEPT
{ return !(__x == __y); }
template<typename _Tp, typename _RefL, typename _PtrL,
typename _RefR, typename _PtrR>
inline bool
operator!=(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) _GLIBCXX_NOEXCEPT
{ return !(__x == __y); }
template<typename _Tp, typename _Ref, typename _Ptr>
inline bool
operator<(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
const _Deque_iterator<_Tp, _Ref, _Ptr>& __y) _GLIBCXX_NOEXCEPT
{ return (__x._M_node == __y._M_node) ? (__x._M_cur < __y._M_cur)
: (__x._M_node < __y._M_node); }
template<typename _Tp, typename _RefL, typename _PtrL,
typename _RefR, typename _PtrR>
inline bool
operator<(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) _GLIBCXX_NOEXCEPT
{ return (__x._M_node == __y._M_node) ? (__x._M_cur < __y._M_cur)
: (__x._M_node < __y._M_node); }
template<typename _Tp, typename _Ref, typename _Ptr>
inline bool
operator>(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
const _Deque_iterator<_Tp, _Ref, _Ptr>& __y) _GLIBCXX_NOEXCEPT
{ return __y < __x; }
template<typename _Tp, typename _RefL, typename _PtrL,
typename _RefR, typename _PtrR>
inline bool
operator>(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) _GLIBCXX_NOEXCEPT
{ return __y < __x; }
template<typename _Tp, typename _Ref, typename _Ptr>
inline bool
operator<=(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
const _Deque_iterator<_Tp, _Ref, _Ptr>& __y) _GLIBCXX_NOEXCEPT
{ return !(__y < __x); }
template<typename _Tp, typename _RefL, typename _PtrL,
typename _RefR, typename _PtrR>
inline bool
operator<=(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) _GLIBCXX_NOEXCEPT
{ return !(__y < __x); }
template<typename _Tp, typename _Ref, typename _Ptr>
inline bool
operator>=(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
const _Deque_iterator<_Tp, _Ref, _Ptr>& __y) _GLIBCXX_NOEXCEPT
{ return !(__x < __y); }
template<typename _Tp, typename _RefL, typename _PtrL,
typename _RefR, typename _PtrR>
inline bool
operator>=(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) _GLIBCXX_NOEXCEPT
{ return !(__x < __y); }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// According to the resolution of DR179 not only the various comparison
// operators but also operator- must accept mixed iterator/const_iterator
// parameters.
template<typename _Tp, typename _Ref, typename _Ptr>
inline typename _Deque_iterator<_Tp, _Ref, _Ptr>::difference_type
operator-(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
const _Deque_iterator<_Tp, _Ref, _Ptr>& __y) _GLIBCXX_NOEXCEPT
{
return typename _Deque_iterator<_Tp, _Ref, _Ptr>::difference_type
(_Deque_iterator<_Tp, _Ref, _Ptr>::_S_buffer_size())
* (__x._M_node - __y._M_node - 1) + (__x._M_cur - __x._M_first)
+ (__y._M_last - __y._M_cur);
}
template<typename _Tp, typename _RefL, typename _PtrL,
typename _RefR, typename _PtrR>
inline typename _Deque_iterator<_Tp, _RefL, _PtrL>::difference_type
operator-(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) _GLIBCXX_NOEXCEPT
{
return typename _Deque_iterator<_Tp, _RefL, _PtrL>::difference_type
(_Deque_iterator<_Tp, _RefL, _PtrL>::_S_buffer_size())
* (__x._M_node - __y._M_node - 1) + (__x._M_cur - __x._M_first)
+ (__y._M_last - __y._M_cur);
}
template<typename _Tp, typename _Ref, typename _Ptr>
inline _Deque_iterator<_Tp, _Ref, _Ptr>
operator+(ptrdiff_t __n, const _Deque_iterator<_Tp, _Ref, _Ptr>& __x)
_GLIBCXX_NOEXCEPT
{ return __x + __n; }
template<typename _Tp>
void
fill(const _Deque_iterator<_Tp, _Tp&, _Tp*>&,
const _Deque_iterator<_Tp, _Tp&, _Tp*>&, const _Tp&);
template<typename _Tp>
_Deque_iterator<_Tp, _Tp&, _Tp*>
copy(_Deque_iterator<_Tp, const _Tp&, const _Tp*>,
_Deque_iterator<_Tp, const _Tp&, const _Tp*>,
_Deque_iterator<_Tp, _Tp&, _Tp*>);
template<typename _Tp>
inline _Deque_iterator<_Tp, _Tp&, _Tp*>
copy(_Deque_iterator<_Tp, _Tp&, _Tp*> __first,
_Deque_iterator<_Tp, _Tp&, _Tp*> __last,
_Deque_iterator<_Tp, _Tp&, _Tp*> __result)
{ return std::copy(_Deque_iterator<_Tp, const _Tp&, const _Tp*>(__first),
_Deque_iterator<_Tp, const _Tp&, const _Tp*>(__last),
__result); }
template<typename _Tp>
_Deque_iterator<_Tp, _Tp&, _Tp*>
copy_backward(_Deque_iterator<_Tp, const _Tp&, const _Tp*>,
_Deque_iterator<_Tp, const _Tp&, const _Tp*>,
_Deque_iterator<_Tp, _Tp&, _Tp*>);
template<typename _Tp>
inline _Deque_iterator<_Tp, _Tp&, _Tp*>
copy_backward(_Deque_iterator<_Tp, _Tp&, _Tp*> __first,
_Deque_iterator<_Tp, _Tp&, _Tp*> __last,
_Deque_iterator<_Tp, _Tp&, _Tp*> __result)
{ return std::copy_backward(_Deque_iterator<_Tp,
const _Tp&, const _Tp*>(__first),
_Deque_iterator<_Tp,
const _Tp&, const _Tp*>(__last),
__result); }
#if __cplusplus >= 201103L
template<typename _Tp>
_Deque_iterator<_Tp, _Tp&, _Tp*>
move(_Deque_iterator<_Tp, const _Tp&, const _Tp*>,
_Deque_iterator<_Tp, const _Tp&, const _Tp*>,
_Deque_iterator<_Tp, _Tp&, _Tp*>);
template<typename _Tp>
inline _Deque_iterator<_Tp, _Tp&, _Tp*>
move(_Deque_iterator<_Tp, _Tp&, _Tp*> __first,
_Deque_iterator<_Tp, _Tp&, _Tp*> __last,
_Deque_iterator<_Tp, _Tp&, _Tp*> __result)
{ return std::move(_Deque_iterator<_Tp, const _Tp&, const _Tp*>(__first),
_Deque_iterator<_Tp, const _Tp&, const _Tp*>(__last),
__result); }
template<typename _Tp>
_Deque_iterator<_Tp, _Tp&, _Tp*>
move_backward(_Deque_iterator<_Tp, const _Tp&, const _Tp*>,
_Deque_iterator<_Tp, const _Tp&, const _Tp*>,
_Deque_iterator<_Tp, _Tp&, _Tp*>);
template<typename _Tp>
inline _Deque_iterator<_Tp, _Tp&, _Tp*>
move_backward(_Deque_iterator<_Tp, _Tp&, _Tp*> __first,
_Deque_iterator<_Tp, _Tp&, _Tp*> __last,
_Deque_iterator<_Tp, _Tp&, _Tp*> __result)
{ return std::move_backward(_Deque_iterator<_Tp,
const _Tp&, const _Tp*>(__first),
_Deque_iterator<_Tp,
const _Tp&, const _Tp*>(__last),
__result); }
#endif
/**
* Deque base class. This class provides the unified face for %deque's
* allocation. This class's constructor and destructor allocate and
* deallocate (but do not initialize) storage. This makes %exception
* safety easier.
*
* Nothing in this class ever constructs or destroys an actual Tp element.
* (Deque handles that itself.) Only/All memory management is performed
* here.
*/
template<typename _Tp, typename _Alloc>
class _Deque_base
{
protected:
typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template
rebind<_Tp>::other _Tp_alloc_type;
typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Alloc_traits;
#if __cplusplus < 201103L
typedef _Tp* _Ptr;
typedef const _Tp* _Ptr_const;
#else
typedef typename _Alloc_traits::pointer _Ptr;
typedef typename _Alloc_traits::const_pointer _Ptr_const;
#endif
typedef typename _Alloc_traits::template rebind<_Ptr>::other
_Map_alloc_type;
typedef __gnu_cxx::__alloc_traits<_Map_alloc_type> _Map_alloc_traits;
public:
typedef _Alloc allocator_type;
typedef typename _Alloc_traits::size_type size_type;
allocator_type
get_allocator() const _GLIBCXX_NOEXCEPT
{ return allocator_type(_M_get_Tp_allocator()); }
typedef _Deque_iterator<_Tp, _Tp&, _Ptr> iterator;
typedef _Deque_iterator<_Tp, const _Tp&, _Ptr_const> const_iterator;
_Deque_base()
: _M_impl()
{ _M_initialize_map(0); }
_Deque_base(size_t __num_elements)
: _M_impl()
{ _M_initialize_map(__num_elements); }
_Deque_base(const allocator_type& __a, size_t __num_elements)
: _M_impl(__a)
{ _M_initialize_map(__num_elements); }
_Deque_base(const allocator_type& __a)
: _M_impl(__a)
{ /* Caller must initialize map. */ }
#if __cplusplus >= 201103L
_Deque_base(_Deque_base&& __x, false_type)
: _M_impl(__x._M_move_impl())
{ }
_Deque_base(_Deque_base&& __x, true_type)
: _M_impl(std::move(__x._M_get_Tp_allocator()))
{
_M_initialize_map(0);
if (__x._M_impl._M_map)
this->_M_impl._M_swap_data(__x._M_impl);
}
_Deque_base(_Deque_base&& __x)
: _Deque_base(std::move(__x), typename _Alloc_traits::is_always_equal{})
{ }
_Deque_base(_Deque_base&& __x, const allocator_type& __a, size_type __n)
: _M_impl(__a)
{
if (__x.get_allocator() == __a)
{
if (__x._M_impl._M_map)
{
_M_initialize_map(0);
this->_M_impl._M_swap_data(__x._M_impl);
}
}
else
{
_M_initialize_map(__n);
}
}
#endif
~_Deque_base() _GLIBCXX_NOEXCEPT;
protected:
typedef typename iterator::_Map_pointer _Map_pointer;
//This struct encapsulates the implementation of the std::deque
//standard container and at the same time makes use of the EBO
//for empty allocators.
struct _Deque_impl
: public _Tp_alloc_type
{
_Map_pointer _M_map;
size_t _M_map_size;
iterator _M_start;
iterator _M_finish;
_Deque_impl()
: _Tp_alloc_type(), _M_map(), _M_map_size(0),
_M_start(), _M_finish()
{ }
_Deque_impl(const _Tp_alloc_type& __a) _GLIBCXX_NOEXCEPT
: _Tp_alloc_type(__a), _M_map(), _M_map_size(0),
_M_start(), _M_finish()
{ }
#if __cplusplus >= 201103L
_Deque_impl(_Deque_impl&&) = default;
_Deque_impl(_Tp_alloc_type&& __a) noexcept
: _Tp_alloc_type(std::move(__a)), _M_map(), _M_map_size(0),
_M_start(), _M_finish()
{ }
#endif
void _M_swap_data(_Deque_impl& __x) _GLIBCXX_NOEXCEPT
{
using std::swap;
swap(this->_M_start, __x._M_start);
swap(this->_M_finish, __x._M_finish);
swap(this->_M_map, __x._M_map);
swap(this->_M_map_size, __x._M_map_size);
}
};
_Tp_alloc_type&
_M_get_Tp_allocator() _GLIBCXX_NOEXCEPT
{ return *static_cast<_Tp_alloc_type*>(&this->_M_impl); }
const _Tp_alloc_type&
_M_get_Tp_allocator() const _GLIBCXX_NOEXCEPT
{ return *static_cast<const _Tp_alloc_type*>(&this->_M_impl); }
_Map_alloc_type
_M_get_map_allocator() const _GLIBCXX_NOEXCEPT
{ return _Map_alloc_type(_M_get_Tp_allocator()); }
_Ptr
_M_allocate_node()
{
typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Traits;
return _Traits::allocate(_M_impl, __deque_buf_size(sizeof(_Tp)));
}
void
_M_deallocate_node(_Ptr __p) _GLIBCXX_NOEXCEPT
{
typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Traits;
_Traits::deallocate(_M_impl, __p, __deque_buf_size(sizeof(_Tp)));
}
_Map_pointer
_M_allocate_map(size_t __n)
{
_Map_alloc_type __map_alloc = _M_get_map_allocator();
return _Map_alloc_traits::allocate(__map_alloc, __n);
}
void
_M_deallocate_map(_Map_pointer __p, size_t __n) _GLIBCXX_NOEXCEPT
{
_Map_alloc_type __map_alloc = _M_get_map_allocator();
_Map_alloc_traits::deallocate(__map_alloc, __p, __n);
}
protected:
void _M_initialize_map(size_t);
void _M_create_nodes(_Map_pointer __nstart, _Map_pointer __nfinish);
void _M_destroy_nodes(_Map_pointer __nstart,
_Map_pointer __nfinish) _GLIBCXX_NOEXCEPT;
enum { _S_initial_map_size = 8 };
_Deque_impl _M_impl;
#if __cplusplus >= 201103L
private:
_Deque_impl
_M_move_impl()
{
if (!_M_impl._M_map)
return std::move(_M_impl);
// Create a copy of the current allocator.
_Tp_alloc_type __alloc{_M_get_Tp_allocator()};
// Put that copy in a moved-from state.
_Tp_alloc_type __sink __attribute((__unused__)) {std::move(__alloc)};
// Create an empty map that allocates using the moved-from allocator.
_Deque_base __empty{__alloc};
__empty._M_initialize_map(0);
// Now safe to modify current allocator and perform non-throwing swaps.
_Deque_impl __ret{std::move(_M_get_Tp_allocator())};
_M_impl._M_swap_data(__ret);
_M_impl._M_swap_data(__empty._M_impl);
return __ret;
}
#endif
};
template<typename _Tp, typename _Alloc>
_Deque_base<_Tp, _Alloc>::
~_Deque_base() _GLIBCXX_NOEXCEPT
{
if (this->_M_impl._M_map)
{
_M_destroy_nodes(this->_M_impl._M_start._M_node,
this->_M_impl._M_finish._M_node + 1);
_M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size);
}
}
/**
* @brief Layout storage.
* @param __num_elements The count of T's for which to allocate space
* at first.
* @return Nothing.
*
* The initial underlying memory layout is a bit complicated...
*/
template<typename _Tp, typename _Alloc>
void
_Deque_base<_Tp, _Alloc>::
_M_initialize_map(size_t __num_elements)
{
const size_t __num_nodes = (__num_elements/ __deque_buf_size(sizeof(_Tp))
+ 1);
this->_M_impl._M_map_size = std::max((size_t) _S_initial_map_size,
size_t(__num_nodes + 2));
this->_M_impl._M_map = _M_allocate_map(this->_M_impl._M_map_size);
// For "small" maps (needing less than _M_map_size nodes), allocation
// starts in the middle elements and grows outwards. So nstart may be
// the beginning of _M_map, but for small maps it may be as far in as
// _M_map+3.
_Map_pointer __nstart = (this->_M_impl._M_map
+ (this->_M_impl._M_map_size - __num_nodes) / 2);
_Map_pointer __nfinish = __nstart + __num_nodes;
__try
{ _M_create_nodes(__nstart, __nfinish); }
__catch(...)
{
_M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size);
this->_M_impl._M_map = _Map_pointer();
this->_M_impl._M_map_size = 0;
__throw_exception_again;
}
this->_M_impl._M_start._M_set_node(__nstart);
this->_M_impl._M_finish._M_set_node(__nfinish - 1);
this->_M_impl._M_start._M_cur = _M_impl._M_start._M_first;
this->_M_impl._M_finish._M_cur = (this->_M_impl._M_finish._M_first
+ __num_elements
% __deque_buf_size(sizeof(_Tp)));
}
template<typename _Tp, typename _Alloc>
void
_Deque_base<_Tp, _Alloc>::
_M_create_nodes(_Map_pointer __nstart, _Map_pointer __nfinish)
{
_Map_pointer __cur;
__try
{
for (__cur = __nstart; __cur < __nfinish; ++__cur)
*__cur = this->_M_allocate_node();
}
__catch(...)
{
_M_destroy_nodes(__nstart, __cur);
__throw_exception_again;
}
}
template<typename _Tp, typename _Alloc>
void
_Deque_base<_Tp, _Alloc>::
_M_destroy_nodes(_Map_pointer __nstart,
_Map_pointer __nfinish) _GLIBCXX_NOEXCEPT
{
for (_Map_pointer __n = __nstart; __n < __nfinish; ++__n)
_M_deallocate_node(*__n);
}
/**
* @brief A standard container using fixed-size memory allocation and
* constant-time manipulation of elements at either end.
*
* @ingroup sequences
*
* @tparam _Tp Type of element.
* @tparam _Alloc Allocator type, defaults to allocator<_Tp>.
*
* Meets the requirements of a <a href="tables.html#65">container</a>, a
* <a href="tables.html#66">reversible container</a>, and a
* <a href="tables.html#67">sequence</a>, including the
* <a href="tables.html#68">optional sequence requirements</a>.
*
* In previous HP/SGI versions of deque, there was an extra template
* parameter so users could control the node size. This extension turned
* out to violate the C++ standard (it can be detected using template
* template parameters), and it was removed.
*
* Here's how a deque<Tp> manages memory. Each deque has 4 members:
*
* - Tp** _M_map
* - size_t _M_map_size
* - iterator _M_start, _M_finish
*
* map_size is at least 8. %map is an array of map_size
* pointers-to-@a nodes. (The name %map has nothing to do with the
* std::map class, and @b nodes should not be confused with
* std::list's usage of @a node.)
*
* A @a node has no specific type name as such, but it is referred
* to as @a node in this file. It is a simple array-of-Tp. If Tp
* is very large, there will be one Tp element per node (i.e., an
* @a array of one). For non-huge Tp's, node size is inversely
* related to Tp size: the larger the Tp, the fewer Tp's will fit
* in a node. The goal here is to keep the total size of a node
* relatively small and constant over different Tp's, to improve
* allocator efficiency.
*
* Not every pointer in the %map array will point to a node. If
* the initial number of elements in the deque is small, the
* /middle/ %map pointers will be valid, and the ones at the edges
* will be unused. This same situation will arise as the %map
* grows: available %map pointers, if any, will be on the ends. As
* new nodes are created, only a subset of the %map's pointers need
* to be copied @a outward.
*
* Class invariants:
* - For any nonsingular iterator i:
* - i.node points to a member of the %map array. (Yes, you read that
* correctly: i.node does not actually point to a node.) The member of
* the %map array is what actually points to the node.
* - i.first == *(i.node) (This points to the node (first Tp element).)
* - i.last == i.first + node_size
* - i.cur is a pointer in the range [i.first, i.last). NOTE:
* the implication of this is that i.cur is always a dereferenceable
* pointer, even if i is a past-the-end iterator.
* - Start and Finish are always nonsingular iterators. NOTE: this
* means that an empty deque must have one node, a deque with <N
* elements (where N is the node buffer size) must have one node, a
* deque with N through (2N-1) elements must have two nodes, etc.
* - For every node other than start.node and finish.node, every
* element in the node is an initialized object. If start.node ==
* finish.node, then [start.cur, finish.cur) are initialized
* objects, and the elements outside that range are uninitialized
* storage. Otherwise, [start.cur, start.last) and [finish.first,
* finish.cur) are initialized objects, and [start.first, start.cur)
* and [finish.cur, finish.last) are uninitialized storage.
* - [%map, %map + map_size) is a valid, non-empty range.
* - [start.node, finish.node] is a valid range contained within
* [%map, %map + map_size).
* - A pointer in the range [%map, %map + map_size) points to an allocated
* node if and only if the pointer is in the range
* [start.node, finish.node].
*
* Here's the magic: nothing in deque is @b aware of the discontiguous
* storage!
*
* The memory setup and layout occurs in the parent, _Base, and the iterator
* class is entirely responsible for @a leaping from one node to the next.
* All the implementation routines for deque itself work only through the
* start and finish iterators. This keeps the routines simple and sane,
* and we can use other standard algorithms as well.
*/
template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
class deque : protected _Deque_base<_Tp, _Alloc>
{
#ifdef _GLIBCXX_CONCEPT_CHECKS
// concept requirements
typedef typename _Alloc::value_type _Alloc_value_type;
# if __cplusplus < 201103L
__glibcxx_class_requires(_Tp, _SGIAssignableConcept)
# endif
__glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept)
#endif
#if __cplusplus >= 201103L
static_assert(is_same<typename remove_cv<_Tp>::type, _Tp>::value,
"std::deque must have a non-const, non-volatile value_type");
# ifdef __STRICT_ANSI__
static_assert(is_same<typename _Alloc::value_type, _Tp>::value,
"std::deque must have the same value_type as its allocator");
# endif
#endif
typedef _Deque_base<_Tp, _Alloc> _Base;
typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
typedef typename _Base::_Alloc_traits _Alloc_traits;
typedef typename _Base::_Map_pointer _Map_pointer;
public:
typedef _Tp value_type;
typedef typename _Alloc_traits::pointer pointer;
typedef typename _Alloc_traits::const_pointer const_pointer;
typedef typename _Alloc_traits::reference reference;
typedef typename _Alloc_traits::const_reference const_reference;
typedef typename _Base::iterator iterator;
typedef typename _Base::const_iterator const_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef _Alloc allocator_type;
protected:
static size_t _S_buffer_size() _GLIBCXX_NOEXCEPT
{ return __deque_buf_size(sizeof(_Tp)); }
// Functions controlling memory layout, and nothing else.
using _Base::_M_initialize_map;
using _Base::_M_create_nodes;
using _Base::_M_destroy_nodes;
using _Base::_M_allocate_node;
using _Base::_M_deallocate_node;
using _Base::_M_allocate_map;
using _Base::_M_deallocate_map;
using _Base::_M_get_Tp_allocator;
/**
* A total of four data members accumulated down the hierarchy.
* May be accessed via _M_impl.*
*/
using _Base::_M_impl;
public:
// [23.2.1.1] construct/copy/destroy
// (assign() and get_allocator() are also listed in this section)
/**
* @brief Creates a %deque with no elements.
*/
deque() : _Base() { }
/**
* @brief Creates a %deque with no elements.
* @param __a An allocator object.
*/
explicit
deque(const allocator_type& __a)
: _Base(__a, 0) { }
#if __cplusplus >= 201103L
/**
* @brief Creates a %deque with default constructed elements.
* @param __n The number of elements to initially create.
* @param __a An allocator.
*
* This constructor fills the %deque with @a n default
* constructed elements.
*/
explicit
deque(size_type __n, const allocator_type& __a = allocator_type())
: _Base(__a, __n)
{ _M_default_initialize(); }
/**
* @brief Creates a %deque with copies of an exemplar element.
* @param __n The number of elements to initially create.
* @param __value An element to copy.
* @param __a An allocator.
*
* This constructor fills the %deque with @a __n copies of @a __value.
*/
deque(size_type __n, const value_type& __value,
const allocator_type& __a = allocator_type())
: _Base(__a, __n)
{ _M_fill_initialize(__value); }
#else
/**
* @brief Creates a %deque with copies of an exemplar element.
* @param __n The number of elements to initially create.
* @param __value An element to copy.
* @param __a An allocator.
*
* This constructor fills the %deque with @a __n copies of @a __value.
*/
explicit
deque(size_type __n, const value_type& __value = value_type(),
const allocator_type& __a = allocator_type())
: _Base(__a, __n)
{ _M_fill_initialize(__value); }
#endif
/**
* @brief %Deque copy constructor.
* @param __x A %deque of identical element and allocator types.
*
* The newly-created %deque uses a copy of the allocator object used
* by @a __x (unless the allocator traits dictate a different object).
*/
deque(const deque& __x)
: _Base(_Alloc_traits::_S_select_on_copy(__x._M_get_Tp_allocator()),
__x.size())
{ std::__uninitialized_copy_a(__x.begin(), __x.end(),
this->_M_impl._M_start,
_M_get_Tp_allocator()); }
#if __cplusplus >= 201103L
/**
* @brief %Deque move constructor.
* @param __x A %deque of identical element and allocator types.
*
* The newly-created %deque contains the exact contents of @a __x.
* The contents of @a __x are a valid, but unspecified %deque.
*/
deque(deque&& __x)
: _Base(std::move(__x)) { }
/// Copy constructor with alternative allocator
deque(const deque& __x, const allocator_type& __a)
: _Base(__a, __x.size())
{ std::__uninitialized_copy_a(__x.begin(), __x.end(),
this->_M_impl._M_start,
_M_get_Tp_allocator()); }
/// Move constructor with alternative allocator
deque(deque&& __x, const allocator_type& __a)
: _Base(std::move(__x), __a, __x.size())
{
if (__x.get_allocator() != __a)
{
std::__uninitialized_move_a(__x.begin(), __x.end(),
this->_M_impl._M_start,
_M_get_Tp_allocator());
__x.clear();
}
}
/**
* @brief Builds a %deque from an initializer list.
* @param __l An initializer_list.
* @param __a An allocator object.
*
* Create a %deque consisting of copies of the elements in the
* initializer_list @a __l.
*
* This will call the element type's copy constructor N times
* (where N is __l.size()) and do no memory reallocation.
*/
deque(initializer_list<value_type> __l,
const allocator_type& __a = allocator_type())
: _Base(__a)
{
_M_range_initialize(__l.begin(), __l.end(),
random_access_iterator_tag());
}
#endif
/**
* @brief Builds a %deque from a range.
* @param __first An input iterator.
* @param __last An input iterator.
* @param __a An allocator object.
*
* Create a %deque consisting of copies of the elements from [__first,
* __last).
*
* If the iterators are forward, bidirectional, or random-access, then
* this will call the elements' copy constructor N times (where N is
* distance(__first,__last)) and do no memory reallocation. But if only
* input iterators are used, then this will do at most 2N calls to the
* copy constructor, and logN memory reallocations.
*/
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
deque(_InputIterator __first, _InputIterator __last,
const allocator_type& __a = allocator_type())
: _Base(__a)
{ _M_initialize_dispatch(__first, __last, __false_type()); }
#else
template<typename _InputIterator>
deque(_InputIterator __first, _InputIterator __last,
const allocator_type& __a = allocator_type())
: _Base(__a)
{
// Check whether it's an integral type. If so, it's not an iterator.
typedef typename std::__is_integer<_InputIterator>::__type _Integral;
_M_initialize_dispatch(__first, __last, _Integral());
}
#endif
/**
* The dtor only erases the elements, and note that if the elements
* themselves are pointers, the pointed-to memory is not touched in any
* way. Managing the pointer is the user's responsibility.
*/
~deque()
{ _M_destroy_data(begin(), end(), _M_get_Tp_allocator()); }
/**
* @brief %Deque assignment operator.
* @param __x A %deque of identical element and allocator types.
*
* All the elements of @a x are copied.
*
* The newly-created %deque uses a copy of the allocator object used
* by @a __x (unless the allocator traits dictate a different object).
*/
deque&
operator=(const deque& __x);
#if __cplusplus >= 201103L
/**
* @brief %Deque move assignment operator.
* @param __x A %deque of identical element and allocator types.
*
* The contents of @a __x are moved into this deque (without copying,
* if the allocators permit it).
* @a __x is a valid, but unspecified %deque.
*/
deque&
operator=(deque&& __x) noexcept(_Alloc_traits::_S_always_equal())
{
using __always_equal = typename _Alloc_traits::is_always_equal;
_M_move_assign1(std::move(__x), __always_equal{});
return *this;
}
/**
* @brief Assigns an initializer list to a %deque.
* @param __l An initializer_list.
*
* This function fills a %deque with copies of the elements in the
* initializer_list @a __l.
*
* Note that the assignment completely changes the %deque and that the
* resulting %deque's size is the same as the number of elements
* assigned.
*/
deque&
operator=(initializer_list<value_type> __l)
{
_M_assign_aux(__l.begin(), __l.end(),
random_access_iterator_tag());
return *this;
}
#endif
/**
* @brief Assigns a given value to a %deque.
* @param __n Number of elements to be assigned.
* @param __val Value to be assigned.
*
* This function fills a %deque with @a n copies of the given
* value. Note that the assignment completely changes the
* %deque and that the resulting %deque's size is the same as
* the number of elements assigned.
*/
void
assign(size_type __n, const value_type& __val)
{ _M_fill_assign(__n, __val); }
/**
* @brief Assigns a range to a %deque.
* @param __first An input iterator.
* @param __last An input iterator.
*
* This function fills a %deque with copies of the elements in the
* range [__first,__last).
*
* Note that the assignment completely changes the %deque and that the
* resulting %deque's size is the same as the number of elements
* assigned.
*/
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
void
assign(_InputIterator __first, _InputIterator __last)
{ _M_assign_dispatch(__first, __last, __false_type()); }
#else
template<typename _InputIterator>
void
assign(_InputIterator __first, _InputIterator __last)
{
typedef typename std::__is_integer<_InputIterator>::__type _Integral;
_M_assign_dispatch(__first, __last, _Integral());
}
#endif
#if __cplusplus >= 201103L
/**
* @brief Assigns an initializer list to a %deque.
* @param __l An initializer_list.
*
* This function fills a %deque with copies of the elements in the
* initializer_list @a __l.
*
* Note that the assignment completely changes the %deque and that the
* resulting %deque's size is the same as the number of elements
* assigned.
*/
void
assign(initializer_list<value_type> __l)
{ _M_assign_aux(__l.begin(), __l.end(), random_access_iterator_tag()); }
#endif
/// Get a copy of the memory allocation object.
allocator_type
get_allocator() const _GLIBCXX_NOEXCEPT
{ return _Base::get_allocator(); }
// iterators
/**
* Returns a read/write iterator that points to the first element in the
* %deque. Iteration is done in ordinary element order.
*/
iterator
begin() _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_start; }
/**
* Returns a read-only (constant) iterator that points to the first
* element in the %deque. Iteration is done in ordinary element order.
*/
const_iterator
begin() const _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_start; }
/**
* Returns a read/write iterator that points one past the last
* element in the %deque. Iteration is done in ordinary
* element order.
*/
iterator
end() _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_finish; }
/**
* Returns a read-only (constant) iterator that points one past
* the last element in the %deque. Iteration is done in
* ordinary element order.
*/
const_iterator
end() const _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_finish; }
/**
* Returns a read/write reverse iterator that points to the
* last element in the %deque. Iteration is done in reverse
* element order.
*/
reverse_iterator
rbegin() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(this->_M_impl._M_finish); }
/**
* Returns a read-only (constant) reverse iterator that points
* to the last element in the %deque. Iteration is done in
* reverse element order.
*/
const_reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(this->_M_impl._M_finish); }
/**
* Returns a read/write reverse iterator that points to one
* before the first element in the %deque. Iteration is done
* in reverse element order.
*/
reverse_iterator
rend() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(this->_M_impl._M_start); }
/**
* Returns a read-only (constant) reverse iterator that points
* to one before the first element in the %deque. Iteration is
* done in reverse element order.
*/
const_reverse_iterator
rend() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(this->_M_impl._M_start); }
#if __cplusplus >= 201103L
/**
* Returns a read-only (constant) iterator that points to the first
* element in the %deque. Iteration is done in ordinary element order.
*/
const_iterator
cbegin() const noexcept
{ return this->_M_impl._M_start; }
/**
* Returns a read-only (constant) iterator that points one past
* the last element in the %deque. Iteration is done in
* ordinary element order.
*/
const_iterator
cend() const noexcept
{ return this->_M_impl._M_finish; }
/**
* Returns a read-only (constant) reverse iterator that points
* to the last element in the %deque. Iteration is done in
* reverse element order.
*/
const_reverse_iterator
crbegin() const noexcept
{ return const_reverse_iterator(this->_M_impl._M_finish); }
/**
* Returns a read-only (constant) reverse iterator that points
* to one before the first element in the %deque. Iteration is
* done in reverse element order.
*/
const_reverse_iterator
crend() const noexcept
{ return const_reverse_iterator(this->_M_impl._M_start); }
#endif
// [23.2.1.2] capacity
/** Returns the number of elements in the %deque. */
size_type
size() const _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_finish - this->_M_impl._M_start; }
/** Returns the size() of the largest possible %deque. */
size_type
max_size() const _GLIBCXX_NOEXCEPT
{ return _Alloc_traits::max_size(_M_get_Tp_allocator()); }
#if __cplusplus >= 201103L
/**
* @brief Resizes the %deque to the specified number of elements.
* @param __new_size Number of elements the %deque should contain.
*
* This function will %resize the %deque to the specified
* number of elements. If the number is smaller than the
* %deque's current size the %deque is truncated, otherwise
* default constructed elements are appended.
*/
void
resize(size_type __new_size)
{
const size_type __len = size();
if (__new_size > __len)
_M_default_append(__new_size - __len);
else if (__new_size < __len)
_M_erase_at_end(this->_M_impl._M_start
+ difference_type(__new_size));
}
/**
* @brief Resizes the %deque to the specified number of elements.
* @param __new_size Number of elements the %deque should contain.
* @param __x Data with which new elements should be populated.
*
* This function will %resize the %deque to the specified
* number of elements. If the number is smaller than the
* %deque's current size the %deque is truncated, otherwise the
* %deque is extended and new elements are populated with given
* data.
*/
void
resize(size_type __new_size, const value_type& __x)
{
const size_type __len = size();
if (__new_size > __len)
_M_fill_insert(this->_M_impl._M_finish, __new_size - __len, __x);
else if (__new_size < __len)
_M_erase_at_end(this->_M_impl._M_start
+ difference_type(__new_size));
}
#else
/**
* @brief Resizes the %deque to the specified number of elements.
* @param __new_size Number of elements the %deque should contain.
* @param __x Data with which new elements should be populated.
*
* This function will %resize the %deque to the specified
* number of elements. If the number is smaller than the
* %deque's current size the %deque is truncated, otherwise the
* %deque is extended and new elements are populated with given
* data.
*/
void
resize(size_type __new_size, value_type __x = value_type())
{
const size_type __len = size();
if (__new_size > __len)
_M_fill_insert(this->_M_impl._M_finish, __new_size - __len, __x);
else if (__new_size < __len)
_M_erase_at_end(this->_M_impl._M_start
+ difference_type(__new_size));
}
#endif
#if __cplusplus >= 201103L
/** A non-binding request to reduce memory use. */
void
shrink_to_fit() noexcept
{ _M_shrink_to_fit(); }
#endif
/**
* Returns true if the %deque is empty. (Thus begin() would
* equal end().)
*/
bool
empty() const _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_finish == this->_M_impl._M_start; }
// element access
/**
* @brief Subscript access to the data contained in the %deque.
* @param __n The index of the element for which data should be
* accessed.
* @return Read/write reference to data.
*
* This operator allows for easy, array-style, data access.
* Note that data access with this operator is unchecked and
* out_of_range lookups are not defined. (For checked lookups
* see at().)
*/
reference
operator[](size_type __n) _GLIBCXX_NOEXCEPT
{
__glibcxx_requires_subscript(__n);
return this->_M_impl._M_start[difference_type(__n)];
}
/**
* @brief Subscript access to the data contained in the %deque.
* @param __n The index of the element for which data should be
* accessed.
* @return Read-only (constant) reference to data.
*
* This operator allows for easy, array-style, data access.
* Note that data access with this operator is unchecked and
* out_of_range lookups are not defined. (For checked lookups
* see at().)
*/
const_reference
operator[](size_type __n) const _GLIBCXX_NOEXCEPT
{
__glibcxx_requires_subscript(__n);
return this->_M_impl._M_start[difference_type(__n)];
}
protected:
/// Safety check used only from at().
void
_M_range_check(size_type __n) const
{
if (__n >= this->size())
__throw_out_of_range_fmt(__N("deque::_M_range_check: __n "
"(which is %zu)>= this->size() "
"(which is %zu)"),
__n, this->size());
}
public:
/**
* @brief Provides access to the data contained in the %deque.
* @param __n The index of the element for which data should be
* accessed.
* @return Read/write reference to data.
* @throw std::out_of_range If @a __n is an invalid index.
*
* This function provides for safer data access. The parameter
* is first checked that it is in the range of the deque. The
* function throws out_of_range if the check fails.
*/
reference
at(size_type __n)
{
_M_range_check(__n);
return (*this)[__n];
}
/**
* @brief Provides access to the data contained in the %deque.
* @param __n The index of the element for which data should be
* accessed.
* @return Read-only (constant) reference to data.
* @throw std::out_of_range If @a __n is an invalid index.
*
* This function provides for safer data access. The parameter is first
* checked that it is in the range of the deque. The function throws
* out_of_range if the check fails.
*/
const_reference
at(size_type __n) const
{
_M_range_check(__n);
return (*this)[__n];
}
/**
* Returns a read/write reference to the data at the first
* element of the %deque.
*/
reference
front() _GLIBCXX_NOEXCEPT
{
__glibcxx_requires_nonempty();
return *begin();
}
/**
* Returns a read-only (constant) reference to the data at the first
* element of the %deque.
*/
const_reference
front() const _GLIBCXX_NOEXCEPT
{
__glibcxx_requires_nonempty();
return *begin();
}
/**
* Returns a read/write reference to the data at the last element of the
* %deque.
*/
reference
back() _GLIBCXX_NOEXCEPT
{
__glibcxx_requires_nonempty();
iterator __tmp = end();
--__tmp;
return *__tmp;
}
/**
* Returns a read-only (constant) reference to the data at the last
* element of the %deque.
*/
const_reference
back() const _GLIBCXX_NOEXCEPT
{
__glibcxx_requires_nonempty();
const_iterator __tmp = end();
--__tmp;
return *__tmp;
}
// [23.2.1.2] modifiers
/**
* @brief Add data to the front of the %deque.
* @param __x Data to be added.
*
* This is a typical stack operation. The function creates an
* element at the front of the %deque and assigns the given
* data to it. Due to the nature of a %deque this operation
* can be done in constant time.
*/
void
push_front(const value_type& __x)
{
if (this->_M_impl._M_start._M_cur != this->_M_impl._M_start._M_first)
{
_Alloc_traits::construct(this->_M_impl,
this->_M_impl._M_start._M_cur - 1,
__x);
--this->_M_impl._M_start._M_cur;
}
else
_M_push_front_aux(__x);
}
#if __cplusplus >= 201103L
void
push_front(value_type&& __x)
{ emplace_front(std::move(__x)); }
template<typename... _Args>
#if __cplusplus > 201402L
reference
#else
void
#endif
emplace_front(_Args&&... __args);
#endif
/**
* @brief Add data to the end of the %deque.
* @param __x Data to be added.
*
* This is a typical stack operation. The function creates an
* element at the end of the %deque and assigns the given data
* to it. Due to the nature of a %deque this operation can be
* done in constant time.
*/
void
push_back(const value_type& __x)
{
if (this->_M_impl._M_finish._M_cur
!= this->_M_impl._M_finish._M_last - 1)
{
_Alloc_traits::construct(this->_M_impl,
this->_M_impl._M_finish._M_cur, __x);
++this->_M_impl._M_finish._M_cur;
}
else
_M_push_back_aux(__x);
}
#if __cplusplus >= 201103L
void
push_back(value_type&& __x)
{ emplace_back(std::move(__x)); }
template<typename... _Args>
#if __cplusplus > 201402L
reference
#else
void
#endif
emplace_back(_Args&&... __args);
#endif
/**
* @brief Removes first element.
*
* This is a typical stack operation. It shrinks the %deque by one.
*
* Note that no data is returned, and if the first element's data is
* needed, it should be retrieved before pop_front() is called.
*/
void
pop_front() _GLIBCXX_NOEXCEPT
{
__glibcxx_requires_nonempty();
if (this->_M_impl._M_start._M_cur
!= this->_M_impl._M_start._M_last - 1)
{
_Alloc_traits::destroy(this->_M_impl,
this->_M_impl._M_start._M_cur);
++this->_M_impl._M_start._M_cur;
}
else
_M_pop_front_aux();
}
/**
* @brief Removes last element.
*
* This is a typical stack operation. It shrinks the %deque by one.
*
* Note that no data is returned, and if the last element's data is
* needed, it should be retrieved before pop_back() is called.
*/
void
pop_back() _GLIBCXX_NOEXCEPT
{
__glibcxx_requires_nonempty();
if (this->_M_impl._M_finish._M_cur
!= this->_M_impl._M_finish._M_first)
{
--this->_M_impl._M_finish._M_cur;
_Alloc_traits::destroy(this->_M_impl,
this->_M_impl._M_finish._M_cur);
}
else
_M_pop_back_aux();
}
#if __cplusplus >= 201103L
/**
* @brief Inserts an object in %deque before specified iterator.
* @param __position A const_iterator into the %deque.
* @param __args Arguments.
* @return An iterator that points to the inserted data.
*
* This function will insert an object of type T constructed
* with T(std::forward<Args>(args)...) before the specified location.
*/
template<typename... _Args>
iterator
emplace(const_iterator __position, _Args&&... __args);
/**
* @brief Inserts given value into %deque before specified iterator.
* @param __position A const_iterator into the %deque.
* @param __x Data to be inserted.
* @return An iterator that points to the inserted data.
*
* This function will insert a copy of the given value before the
* specified location.
*/
iterator
insert(const_iterator __position, const value_type& __x);
#else
/**
* @brief Inserts given value into %deque before specified iterator.
* @param __position An iterator into the %deque.
* @param __x Data to be inserted.
* @return An iterator that points to the inserted data.
*
* This function will insert a copy of the given value before the
* specified location.
*/
iterator
insert(iterator __position, const value_type& __x);
#endif
#if __cplusplus >= 201103L
/**
* @brief Inserts given rvalue into %deque before specified iterator.
* @param __position A const_iterator into the %deque.
* @param __x Data to be inserted.
* @return An iterator that points to the inserted data.
*
* This function will insert a copy of the given rvalue before the
* specified location.
*/
iterator
insert(const_iterator __position, value_type&& __x)
{ return emplace(__position, std::move(__x)); }
/**
* @brief Inserts an initializer list into the %deque.
* @param __p An iterator into the %deque.
* @param __l An initializer_list.
*
* This function will insert copies of the data in the
* initializer_list @a __l into the %deque before the location
* specified by @a __p. This is known as <em>list insert</em>.
*/
iterator
insert(const_iterator __p, initializer_list<value_type> __l)
{
auto __offset = __p - cbegin();
_M_range_insert_aux(__p._M_const_cast(), __l.begin(), __l.end(),
std::random_access_iterator_tag());
return begin() + __offset;
}
#endif
#if __cplusplus >= 201103L
/**
* @brief Inserts a number of copies of given data into the %deque.
* @param __position A const_iterator into the %deque.
* @param __n Number of elements to be inserted.
* @param __x Data to be inserted.
* @return An iterator that points to the inserted data.
*
* This function will insert a specified number of copies of the given
* data before the location specified by @a __position.
*/
iterator
insert(const_iterator __position, size_type __n, const value_type& __x)
{
difference_type __offset = __position - cbegin();
_M_fill_insert(__position._M_const_cast(), __n, __x);
return begin() + __offset;
}
#else
/**
* @brief Inserts a number of copies of given data into the %deque.
* @param __position An iterator into the %deque.
* @param __n Number of elements to be inserted.
* @param __x Data to be inserted.
*
* This function will insert a specified number of copies of the given
* data before the location specified by @a __position.
*/
void
insert(iterator __position, size_type __n, const value_type& __x)
{ _M_fill_insert(__position, __n, __x); }
#endif
#if __cplusplus >= 201103L
/**
* @brief Inserts a range into the %deque.
* @param __position A const_iterator into the %deque.
* @param __first An input iterator.
* @param __last An input iterator.
* @return An iterator that points to the inserted data.
*
* This function will insert copies of the data in the range
* [__first,__last) into the %deque before the location specified
* by @a __position. This is known as <em>range insert</em>.
*/
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
iterator
insert(const_iterator __position, _InputIterator __first,
_InputIterator __last)
{
difference_type __offset = __position - cbegin();
_M_insert_dispatch(__position._M_const_cast(),
__first, __last, __false_type());
return begin() + __offset;
}
#else
/**
* @brief Inserts a range into the %deque.
* @param __position An iterator into the %deque.
* @param __first An input iterator.
* @param __last An input iterator.
*
* This function will insert copies of the data in the range
* [__first,__last) into the %deque before the location specified
* by @a __position. This is known as <em>range insert</em>.
*/
template<typename _InputIterator>
void
insert(iterator __position, _InputIterator __first,
_InputIterator __last)
{
// Check whether it's an integral type. If so, it's not an iterator.
typedef typename std::__is_integer<_InputIterator>::__type _Integral;
_M_insert_dispatch(__position, __first, __last, _Integral());
}
#endif
/**
* @brief Remove element at given position.
* @param __position Iterator pointing to element to be erased.
* @return An iterator pointing to the next element (or end()).
*
* This function will erase the element at the given position and thus
* shorten the %deque by one.
*
* The user is cautioned that
* this function only erases the element, and that if the element is
* itself a pointer, the pointed-to memory is not touched in any way.
* Managing the pointer is the user's responsibility.
*/
iterator
#if __cplusplus >= 201103L
erase(const_iterator __position)
#else
erase(iterator __position)
#endif
{ return _M_erase(__position._M_const_cast()); }
/**
* @brief Remove a range of elements.
* @param __first Iterator pointing to the first element to be erased.
* @param __last Iterator pointing to one past the last element to be
* erased.
* @return An iterator pointing to the element pointed to by @a last
* prior to erasing (or end()).
*
* This function will erase the elements in the range
* [__first,__last) and shorten the %deque accordingly.
*
* The user is cautioned that
* this function only erases the elements, and that if the elements
* themselves are pointers, the pointed-to memory is not touched in any
* way. Managing the pointer is the user's responsibility.
*/
iterator
#if __cplusplus >= 201103L
erase(const_iterator __first, const_iterator __last)
#else
erase(iterator __first, iterator __last)
#endif
{ return _M_erase(__first._M_const_cast(), __last._M_const_cast()); }
/**
* @brief Swaps data with another %deque.
* @param __x A %deque of the same element and allocator types.
*
* This exchanges the elements between two deques in constant time.
* (Four pointers, so it should be quite fast.)
* Note that the global std::swap() function is specialized such that
* std::swap(d1,d2) will feed to this function.
*
* Whether the allocators are swapped depends on the allocator traits.
*/
void
swap(deque& __x) _GLIBCXX_NOEXCEPT
{
#if __cplusplus >= 201103L
__glibcxx_assert(_Alloc_traits::propagate_on_container_swap::value
|| _M_get_Tp_allocator() == __x._M_get_Tp_allocator());
#endif
_M_impl._M_swap_data(__x._M_impl);
_Alloc_traits::_S_on_swap(_M_get_Tp_allocator(),
__x._M_get_Tp_allocator());
}
/**
* Erases all the elements. Note that this function only erases the
* elements, and that if the elements themselves are pointers, the
* pointed-to memory is not touched in any way. Managing the pointer is
* the user's responsibility.
*/
void
clear() _GLIBCXX_NOEXCEPT
{ _M_erase_at_end(begin()); }
protected:
// Internal constructor functions follow.
// called by the range constructor to implement [23.1.1]/9
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 438. Ambiguity in the "do the right thing" clause
template<typename _Integer>
void
_M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
{
_M_initialize_map(static_cast<size_type>(__n));
_M_fill_initialize(__x);
}
// called by the range constructor to implement [23.1.1]/9
template<typename _InputIterator>
void
_M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
__false_type)
{
_M_range_initialize(__first, __last,
std::__iterator_category(__first));
}
// called by the second initialize_dispatch above
//@{
/**
* @brief Fills the deque with whatever is in [first,last).
* @param __first An input iterator.
* @param __last An input iterator.
* @return Nothing.
*
* If the iterators are actually forward iterators (or better), then the
* memory layout can be done all at once. Else we move forward using
* push_back on each value from the iterator.
*/
template<typename _InputIterator>
void
_M_range_initialize(_InputIterator __first, _InputIterator __last,
std::input_iterator_tag);
// called by the second initialize_dispatch above
template<typename _ForwardIterator>
void
_M_range_initialize(_ForwardIterator __first, _ForwardIterator __last,
std::forward_iterator_tag);
//@}
/**
* @brief Fills the %deque with copies of value.
* @param __value Initial value.
* @return Nothing.
* @pre _M_start and _M_finish have already been initialized,
* but none of the %deque's elements have yet been constructed.
*
* This function is called only when the user provides an explicit size
* (with or without an explicit exemplar value).
*/
void
_M_fill_initialize(const value_type& __value);
#if __cplusplus >= 201103L
// called by deque(n).
void
_M_default_initialize();
#endif
// Internal assign functions follow. The *_aux functions do the actual
// assignment work for the range versions.
// called by the range assign to implement [23.1.1]/9
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 438. Ambiguity in the "do the right thing" clause
template<typename _Integer>
void
_M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
{ _M_fill_assign(__n, __val); }
// called by the range assign to implement [23.1.1]/9
template<typename _InputIterator>
void
_M_assign_dispatch(_InputIterator __first, _InputIterator __last,
__false_type)
{ _M_assign_aux(__first, __last, std::__iterator_category(__first)); }
// called by the second assign_dispatch above
template<typename _InputIterator>
void
_M_assign_aux(_InputIterator __first, _InputIterator __last,
std::input_iterator_tag);
// called by the second assign_dispatch above
template<typename _ForwardIterator>
void
_M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
std::forward_iterator_tag)
{
const size_type __len = std::distance(__first, __last);
if (__len > size())
{
_ForwardIterator __mid = __first;
std::advance(__mid, size());
std::copy(__first, __mid, begin());
_M_range_insert_aux(end(), __mid, __last,
std::__iterator_category(__first));
}
else
_M_erase_at_end(std::copy(__first, __last, begin()));
}
// Called by assign(n,t), and the range assign when it turns out
// to be the same thing.
void
_M_fill_assign(size_type __n, const value_type& __val)
{
if (__n > size())
{
std::fill(begin(), end(), __val);
_M_fill_insert(end(), __n - size(), __val);
}
else
{
_M_erase_at_end(begin() + difference_type(__n));
std::fill(begin(), end(), __val);
}
}
//@{
/// Helper functions for push_* and pop_*.
#if __cplusplus < 201103L
void _M_push_back_aux(const value_type&);
void _M_push_front_aux(const value_type&);
#else
template<typename... _Args>
void _M_push_back_aux(_Args&&... __args);
template<typename... _Args>
void _M_push_front_aux(_Args&&... __args);
#endif
void _M_pop_back_aux();
void _M_pop_front_aux();
//@}
// Internal insert functions follow. The *_aux functions do the actual
// insertion work when all shortcuts fail.
// called by the range insert to implement [23.1.1]/9
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 438. Ambiguity in the "do the right thing" clause
template<typename _Integer>
void
_M_insert_dispatch(iterator __pos,
_Integer __n, _Integer __x, __true_type)
{ _M_fill_insert(__pos, __n, __x); }
// called by the range insert to implement [23.1.1]/9
template<typename _InputIterator>
void
_M_insert_dispatch(iterator __pos,
_InputIterator __first, _InputIterator __last,
__false_type)
{
_M_range_insert_aux(__pos, __first, __last,
std::__iterator_category(__first));
}
// called by the second insert_dispatch above
template<typename _InputIterator>
void
_M_range_insert_aux(iterator __pos, _InputIterator __first,
_InputIterator __last, std::input_iterator_tag);
// called by the second insert_dispatch above
template<typename _ForwardIterator>
void
_M_range_insert_aux(iterator __pos, _ForwardIterator __first,
_ForwardIterator __last, std::forward_iterator_tag);
// Called by insert(p,n,x), and the range insert when it turns out to be
// the same thing. Can use fill functions in optimal situations,
// otherwise passes off to insert_aux(p,n,x).
void
_M_fill_insert(iterator __pos, size_type __n, const value_type& __x);
// called by insert(p,x)
#if __cplusplus < 201103L
iterator
_M_insert_aux(iterator __pos, const value_type& __x);
#else
template<typename... _Args>
iterator
_M_insert_aux(iterator __pos, _Args&&... __args);
#endif
// called by insert(p,n,x) via fill_insert
void
_M_insert_aux(iterator __pos, size_type __n, const value_type& __x);
// called by range_insert_aux for forward iterators
template<typename _ForwardIterator>
void
_M_insert_aux(iterator __pos,
_ForwardIterator __first, _ForwardIterator __last,
size_type __n);
// Internal erase functions follow.
void
_M_destroy_data_aux(iterator __first, iterator __last);
// Called by ~deque().
// NB: Doesn't deallocate the nodes.
template<typename _Alloc1>
void
_M_destroy_data(iterator __first, iterator __last, const _Alloc1&)
{ _M_destroy_data_aux(__first, __last); }
void
_M_destroy_data(iterator __first, iterator __last,
const std::allocator<_Tp>&)
{
if (!__has_trivial_destructor(value_type))
_M_destroy_data_aux(__first, __last);
}
// Called by erase(q1, q2).
void
_M_erase_at_begin(iterator __pos)
{
_M_destroy_data(begin(), __pos, _M_get_Tp_allocator());
_M_destroy_nodes(this->_M_impl._M_start._M_node, __pos._M_node);
this->_M_impl._M_start = __pos;
}
// Called by erase(q1, q2), resize(), clear(), _M_assign_aux,
// _M_fill_assign, operator=.
void
_M_erase_at_end(iterator __pos)
{
_M_destroy_data(__pos, end(), _M_get_Tp_allocator());
_M_destroy_nodes(__pos._M_node + 1,
this->_M_impl._M_finish._M_node + 1);
this->_M_impl._M_finish = __pos;
}
iterator
_M_erase(iterator __pos);
iterator
_M_erase(iterator __first, iterator __last);
#if __cplusplus >= 201103L
// Called by resize(sz).
void
_M_default_append(size_type __n);
bool
_M_shrink_to_fit();
#endif
//@{
/// Memory-handling helpers for the previous internal insert functions.
iterator
_M_reserve_elements_at_front(size_type __n)
{
const size_type __vacancies = this->_M_impl._M_start._M_cur
- this->_M_impl._M_start._M_first;
if (__n > __vacancies)
_M_new_elements_at_front(__n - __vacancies);
return this->_M_impl._M_start - difference_type(__n);
}
iterator
_M_reserve_elements_at_back(size_type __n)
{
const size_type __vacancies = (this->_M_impl._M_finish._M_last
- this->_M_impl._M_finish._M_cur) - 1;
if (__n > __vacancies)
_M_new_elements_at_back(__n - __vacancies);
return this->_M_impl._M_finish + difference_type(__n);
}
void
_M_new_elements_at_front(size_type __new_elements);
void
_M_new_elements_at_back(size_type __new_elements);
//@}
//@{
/**
* @brief Memory-handling helpers for the major %map.
*
* Makes sure the _M_map has space for new nodes. Does not
* actually add the nodes. Can invalidate _M_map pointers.
* (And consequently, %deque iterators.)
*/
void
_M_reserve_map_at_back(size_type __nodes_to_add = 1)
{
if (__nodes_to_add + 1 > this->_M_impl._M_map_size
- (this->_M_impl._M_finish._M_node - this->_M_impl._M_map))
_M_reallocate_map(__nodes_to_add, false);
}
void
_M_reserve_map_at_front(size_type __nodes_to_add = 1)
{
if (__nodes_to_add > size_type(this->_M_impl._M_start._M_node
- this->_M_impl._M_map))
_M_reallocate_map(__nodes_to_add, true);
}
void
_M_reallocate_map(size_type __nodes_to_add, bool __add_at_front);
//@}
#if __cplusplus >= 201103L
// Constant-time, nothrow move assignment when source object's memory
// can be moved because the allocators are equal.
void
_M_move_assign1(deque&& __x, /* always equal: */ true_type) noexcept
{
this->_M_impl._M_swap_data(__x._M_impl);
__x.clear();
std::__alloc_on_move(_M_get_Tp_allocator(), __x._M_get_Tp_allocator());
}
// When the allocators are not equal the operation could throw, because
// we might need to allocate a new map for __x after moving from it
// or we might need to allocate new elements for *this.
void
_M_move_assign1(deque&& __x, /* always equal: */ false_type)
{
constexpr bool __move_storage =
_Alloc_traits::_S_propagate_on_move_assign();
_M_move_assign2(std::move(__x), __bool_constant<__move_storage>());
}
// Destroy all elements and deallocate all memory, then replace
// with elements created from __args.
template<typename... _Args>
void
_M_replace_map(_Args&&... __args)
{
// Create new data first, so if allocation fails there are no effects.
deque __newobj(std::forward<_Args>(__args)...);
// Free existing storage using existing allocator.
clear();
_M_deallocate_node(*begin()._M_node); // one node left after clear()
_M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size);
this->_M_impl._M_map = nullptr;
this->_M_impl._M_map_size = 0;
// Take ownership of replacement memory.
this->_M_impl._M_swap_data(__newobj._M_impl);
}
// Do move assignment when the allocator propagates.
void
_M_move_assign2(deque&& __x, /* propagate: */ true_type)
{
// Make a copy of the original allocator state.
auto __alloc = __x._M_get_Tp_allocator();
// The allocator propagates so storage can be moved from __x,
// leaving __x in a valid empty state with a moved-from allocator.
_M_replace_map(std::move(__x));
// Move the corresponding allocator state too.
_M_get_Tp_allocator() = std::move(__alloc);
}
// Do move assignment when it may not be possible to move source
// object's memory, resulting in a linear-time operation.
void
_M_move_assign2(deque&& __x, /* propagate: */ false_type)
{
if (__x._M_get_Tp_allocator() == this->_M_get_Tp_allocator())
{
// The allocators are equal so storage can be moved from __x,
// leaving __x in a valid empty state with its current allocator.
_M_replace_map(std::move(__x), __x.get_allocator());
}
else
{
// The rvalue's allocator cannot be moved and is not equal,
// so we need to individually move each element.
_M_assign_aux(std::__make_move_if_noexcept_iterator(__x.begin()),
std::__make_move_if_noexcept_iterator(__x.end()),
std::random_access_iterator_tag());
__x.clear();
}
}
#endif
};
#if __cpp_deduction_guides >= 201606
template<typename _InputIterator, typename _ValT
= typename iterator_traits<_InputIterator>::value_type,
typename _Allocator = allocator<_ValT>,
typename = _RequireInputIter<_InputIterator>,
typename = _RequireAllocator<_Allocator>>
deque(_InputIterator, _InputIterator, _Allocator = _Allocator())
-> deque<_ValT, _Allocator>;
#endif
/**
* @brief Deque equality comparison.
* @param __x A %deque.
* @param __y A %deque of the same type as @a __x.
* @return True iff the size and elements of the deques are equal.
*
* This is an equivalence relation. It is linear in the size of the
* deques. Deques are considered equivalent if their sizes are equal,
* and if corresponding elements compare equal.
*/
template<typename _Tp, typename _Alloc>
inline bool
operator==(const deque<_Tp, _Alloc>& __x,
const deque<_Tp, _Alloc>& __y)
{ return __x.size() == __y.size()
&& std::equal(__x.begin(), __x.end(), __y.begin()); }
/**
* @brief Deque ordering relation.
* @param __x A %deque.
* @param __y A %deque of the same type as @a __x.
* @return True iff @a x is lexicographically less than @a __y.
*
* This is a total ordering relation. It is linear in the size of the
* deques. The elements must be comparable with @c <.
*
* See std::lexicographical_compare() for how the determination is made.
*/
template<typename _Tp, typename _Alloc>
inline bool
operator<(const deque<_Tp, _Alloc>& __x,
const deque<_Tp, _Alloc>& __y)
{ return std::lexicographical_compare(__x.begin(), __x.end(),
__y.begin(), __y.end()); }
/// Based on operator==
template<typename _Tp, typename _Alloc>
inline bool
operator!=(const deque<_Tp, _Alloc>& __x,
const deque<_Tp, _Alloc>& __y)
{ return !(__x == __y); }
/// Based on operator<
template<typename _Tp, typename _Alloc>
inline bool
operator>(const deque<_Tp, _Alloc>& __x,
const deque<_Tp, _Alloc>& __y)
{ return __y < __x; }
/// Based on operator<
template<typename _Tp, typename _Alloc>
inline bool
operator<=(const deque<_Tp, _Alloc>& __x,
const deque<_Tp, _Alloc>& __y)
{ return !(__y < __x); }
/// Based on operator<
template<typename _Tp, typename _Alloc>
inline bool
operator>=(const deque<_Tp, _Alloc>& __x,
const deque<_Tp, _Alloc>& __y)
{ return !(__x < __y); }
/// See std::deque::swap().
template<typename _Tp, typename _Alloc>
inline void
swap(deque<_Tp,_Alloc>& __x, deque<_Tp,_Alloc>& __y)
_GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
{ __x.swap(__y); }
#undef _GLIBCXX_DEQUE_BUF_SIZE
_GLIBCXX_END_NAMESPACE_CONTAINER
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif /* _STL_DEQUE_H */
c++/8/bits/stl_vector.h 0000644 00000166166 15201526705 0010604 0 ustar 00 // Vector implementation -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1996
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file bits/stl_vector.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{vector}
*/
#ifndef _STL_VECTOR_H
#define _STL_VECTOR_H 1
#include <bits/stl_iterator_base_funcs.h>
#include <bits/functexcept.h>
#include <bits/concept_check.h>
#if __cplusplus >= 201103L
#include <initializer_list>
#endif
#include <debug/assertions.h>
#if _GLIBCXX_SANITIZE_STD_ALLOCATOR && _GLIBCXX_SANITIZE_VECTOR
extern "C" void
__sanitizer_annotate_contiguous_container(const void*, const void*,
const void*, const void*);
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
/// See bits/stl_deque.h's _Deque_base for an explanation.
template<typename _Tp, typename _Alloc>
struct _Vector_base
{
typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template
rebind<_Tp>::other _Tp_alloc_type;
typedef typename __gnu_cxx::__alloc_traits<_Tp_alloc_type>::pointer
pointer;
struct _Vector_impl
: public _Tp_alloc_type
{
pointer _M_start;
pointer _M_finish;
pointer _M_end_of_storage;
_Vector_impl()
: _Tp_alloc_type(), _M_start(), _M_finish(), _M_end_of_storage()
{ }
_Vector_impl(_Tp_alloc_type const& __a) _GLIBCXX_NOEXCEPT
: _Tp_alloc_type(__a), _M_start(), _M_finish(), _M_end_of_storage()
{ }
#if __cplusplus >= 201103L
_Vector_impl(_Tp_alloc_type&& __a) noexcept
: _Tp_alloc_type(std::move(__a)),
_M_start(), _M_finish(), _M_end_of_storage()
{ }
#endif
void _M_swap_data(_Vector_impl& __x) _GLIBCXX_NOEXCEPT
{
std::swap(_M_start, __x._M_start);
std::swap(_M_finish, __x._M_finish);
std::swap(_M_end_of_storage, __x._M_end_of_storage);
}
#if _GLIBCXX_SANITIZE_STD_ALLOCATOR && _GLIBCXX_SANITIZE_VECTOR
template<typename = _Tp_alloc_type>
struct _Asan
{
typedef typename __gnu_cxx::__alloc_traits<_Tp_alloc_type>
::size_type size_type;
static void _S_shrink(_Vector_impl&, size_type) { }
static void _S_on_dealloc(_Vector_impl&) { }
typedef _Vector_impl& _Reinit;
struct _Grow
{
_Grow(_Vector_impl&, size_type) { }
void _M_grew(size_type) { }
};
};
// Enable ASan annotations for memory obtained from std::allocator.
template<typename _Up>
struct _Asan<allocator<_Up> >
{
typedef typename __gnu_cxx::__alloc_traits<_Tp_alloc_type>
::size_type size_type;
// Adjust ASan annotation for [_M_start, _M_end_of_storage) to
// mark end of valid region as __curr instead of __prev.
static void
_S_adjust(_Vector_impl& __impl, pointer __prev, pointer __curr)
{
__sanitizer_annotate_contiguous_container(__impl._M_start,
__impl._M_end_of_storage, __prev, __curr);
}
static void
_S_grow(_Vector_impl& __impl, size_type __n)
{ _S_adjust(__impl, __impl._M_finish, __impl._M_finish + __n); }
static void
_S_shrink(_Vector_impl& __impl, size_type __n)
{ _S_adjust(__impl, __impl._M_finish + __n, __impl._M_finish); }
static void
_S_on_dealloc(_Vector_impl& __impl)
{
if (__impl._M_start)
_S_adjust(__impl, __impl._M_finish, __impl._M_end_of_storage);
}
// Used on reallocation to tell ASan unused capacity is invalid.
struct _Reinit
{
explicit _Reinit(_Vector_impl& __impl) : _M_impl(__impl)
{
// Mark unused capacity as valid again before deallocating it.
_S_on_dealloc(_M_impl);
}
~_Reinit()
{
// Mark unused capacity as invalid after reallocation.
if (_M_impl._M_start)
_S_adjust(_M_impl, _M_impl._M_end_of_storage,
_M_impl._M_finish);
}
_Vector_impl& _M_impl;
#if __cplusplus >= 201103L
_Reinit(const _Reinit&) = delete;
_Reinit& operator=(const _Reinit&) = delete;
#endif
};
// Tell ASan when unused capacity is initialized to be valid.
struct _Grow
{
_Grow(_Vector_impl& __impl, size_type __n)
: _M_impl(__impl), _M_n(__n)
{ _S_grow(_M_impl, __n); }
~_Grow() { if (_M_n) _S_shrink(_M_impl, _M_n); }
void _M_grew(size_type __n) { _M_n -= __n; }
#if __cplusplus >= 201103L
_Grow(const _Grow&) = delete;
_Grow& operator=(const _Grow&) = delete;
#endif
private:
_Vector_impl& _M_impl;
size_type _M_n;
};
};
#define _GLIBCXX_ASAN_ANNOTATE_REINIT \
typename _Base::_Vector_impl::template _Asan<>::_Reinit const \
__attribute__((__unused__)) __reinit_guard(this->_M_impl)
#define _GLIBCXX_ASAN_ANNOTATE_GROW(n) \
typename _Base::_Vector_impl::template _Asan<>::_Grow \
__attribute__((__unused__)) __grow_guard(this->_M_impl, (n))
#define _GLIBCXX_ASAN_ANNOTATE_GREW(n) __grow_guard._M_grew(n)
#define _GLIBCXX_ASAN_ANNOTATE_SHRINK(n) \
_Base::_Vector_impl::template _Asan<>::_S_shrink(this->_M_impl, n)
#define _GLIBCXX_ASAN_ANNOTATE_BEFORE_DEALLOC \
_Base::_Vector_impl::template _Asan<>::_S_on_dealloc(this->_M_impl)
#else // ! (_GLIBCXX_SANITIZE_STD_ALLOCATOR && _GLIBCXX_SANITIZE_VECTOR)
#define _GLIBCXX_ASAN_ANNOTATE_REINIT
#define _GLIBCXX_ASAN_ANNOTATE_GROW(n)
#define _GLIBCXX_ASAN_ANNOTATE_GREW(n)
#define _GLIBCXX_ASAN_ANNOTATE_SHRINK(n)
#define _GLIBCXX_ASAN_ANNOTATE_BEFORE_DEALLOC
#endif // _GLIBCXX_SANITIZE_STD_ALLOCATOR && _GLIBCXX_SANITIZE_VECTOR
};
public:
typedef _Alloc allocator_type;
_Tp_alloc_type&
_M_get_Tp_allocator() _GLIBCXX_NOEXCEPT
{ return *static_cast<_Tp_alloc_type*>(&this->_M_impl); }
const _Tp_alloc_type&
_M_get_Tp_allocator() const _GLIBCXX_NOEXCEPT
{ return *static_cast<const _Tp_alloc_type*>(&this->_M_impl); }
allocator_type
get_allocator() const _GLIBCXX_NOEXCEPT
{ return allocator_type(_M_get_Tp_allocator()); }
_Vector_base()
: _M_impl() { }
_Vector_base(const allocator_type& __a) _GLIBCXX_NOEXCEPT
: _M_impl(__a) { }
_Vector_base(size_t __n)
: _M_impl()
{ _M_create_storage(__n); }
_Vector_base(size_t __n, const allocator_type& __a)
: _M_impl(__a)
{ _M_create_storage(__n); }
#if __cplusplus >= 201103L
_Vector_base(_Tp_alloc_type&& __a) noexcept
: _M_impl(std::move(__a)) { }
_Vector_base(_Vector_base&& __x) noexcept
: _M_impl(std::move(__x._M_get_Tp_allocator()))
{ this->_M_impl._M_swap_data(__x._M_impl); }
_Vector_base(_Vector_base&& __x, const allocator_type& __a)
: _M_impl(__a)
{
if (__x.get_allocator() == __a)
this->_M_impl._M_swap_data(__x._M_impl);
else
{
size_t __n = __x._M_impl._M_finish - __x._M_impl._M_start;
_M_create_storage(__n);
}
}
#endif
~_Vector_base() _GLIBCXX_NOEXCEPT
{
_M_deallocate(_M_impl._M_start,
_M_impl._M_end_of_storage - _M_impl._M_start);
}
public:
_Vector_impl _M_impl;
pointer
_M_allocate(size_t __n)
{
typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Tr;
return __n != 0 ? _Tr::allocate(_M_impl, __n) : pointer();
}
void
_M_deallocate(pointer __p, size_t __n)
{
typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Tr;
if (__p)
_Tr::deallocate(_M_impl, __p, __n);
}
private:
void
_M_create_storage(size_t __n)
{
this->_M_impl._M_start = this->_M_allocate(__n);
this->_M_impl._M_finish = this->_M_impl._M_start;
this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
}
};
/**
* @brief A standard container which offers fixed time access to
* individual elements in any order.
*
* @ingroup sequences
*
* @tparam _Tp Type of element.
* @tparam _Alloc Allocator type, defaults to allocator<_Tp>.
*
* Meets the requirements of a <a href="tables.html#65">container</a>, a
* <a href="tables.html#66">reversible container</a>, and a
* <a href="tables.html#67">sequence</a>, including the
* <a href="tables.html#68">optional sequence requirements</a> with the
* %exception of @c push_front and @c pop_front.
*
* In some terminology a %vector can be described as a dynamic
* C-style array, it offers fast and efficient access to individual
* elements in any order and saves the user from worrying about
* memory and size allocation. Subscripting ( @c [] ) access is
* also provided as with C-style arrays.
*/
template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
class vector : protected _Vector_base<_Tp, _Alloc>
{
#ifdef _GLIBCXX_CONCEPT_CHECKS
// Concept requirements.
typedef typename _Alloc::value_type _Alloc_value_type;
# if __cplusplus < 201103L
__glibcxx_class_requires(_Tp, _SGIAssignableConcept)
# endif
__glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept)
#endif
#if __cplusplus >= 201103L
static_assert(is_same<typename remove_cv<_Tp>::type, _Tp>::value,
"std::vector must have a non-const, non-volatile value_type");
# ifdef __STRICT_ANSI__
static_assert(is_same<typename _Alloc::value_type, _Tp>::value,
"std::vector must have the same value_type as its allocator");
# endif
#endif
typedef _Vector_base<_Tp, _Alloc> _Base;
typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Alloc_traits;
public:
typedef _Tp value_type;
typedef typename _Base::pointer pointer;
typedef typename _Alloc_traits::const_pointer const_pointer;
typedef typename _Alloc_traits::reference reference;
typedef typename _Alloc_traits::const_reference const_reference;
typedef __gnu_cxx::__normal_iterator<pointer, vector> iterator;
typedef __gnu_cxx::__normal_iterator<const_pointer, vector>
const_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef _Alloc allocator_type;
protected:
using _Base::_M_allocate;
using _Base::_M_deallocate;
using _Base::_M_impl;
using _Base::_M_get_Tp_allocator;
public:
// [23.2.4.1] construct/copy/destroy
// (assign() and get_allocator() are also listed in this section)
/**
* @brief Creates a %vector with no elements.
*/
vector()
#if __cplusplus >= 201103L
noexcept(is_nothrow_default_constructible<_Alloc>::value)
#endif
: _Base() { }
/**
* @brief Creates a %vector with no elements.
* @param __a An allocator object.
*/
explicit
vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT
: _Base(__a) { }
#if __cplusplus >= 201103L
/**
* @brief Creates a %vector with default constructed elements.
* @param __n The number of elements to initially create.
* @param __a An allocator.
*
* This constructor fills the %vector with @a __n default
* constructed elements.
*/
explicit
vector(size_type __n, const allocator_type& __a = allocator_type())
: _Base(__n, __a)
{ _M_default_initialize(__n); }
/**
* @brief Creates a %vector with copies of an exemplar element.
* @param __n The number of elements to initially create.
* @param __value An element to copy.
* @param __a An allocator.
*
* This constructor fills the %vector with @a __n copies of @a __value.
*/
vector(size_type __n, const value_type& __value,
const allocator_type& __a = allocator_type())
: _Base(__n, __a)
{ _M_fill_initialize(__n, __value); }
#else
/**
* @brief Creates a %vector with copies of an exemplar element.
* @param __n The number of elements to initially create.
* @param __value An element to copy.
* @param __a An allocator.
*
* This constructor fills the %vector with @a __n copies of @a __value.
*/
explicit
vector(size_type __n, const value_type& __value = value_type(),
const allocator_type& __a = allocator_type())
: _Base(__n, __a)
{ _M_fill_initialize(__n, __value); }
#endif
/**
* @brief %Vector copy constructor.
* @param __x A %vector of identical element and allocator types.
*
* All the elements of @a __x are copied, but any unused capacity in
* @a __x will not be copied
* (i.e. capacity() == size() in the new %vector).
*
* The newly-created %vector uses a copy of the allocator object used
* by @a __x (unless the allocator traits dictate a different object).
*/
vector(const vector& __x)
: _Base(__x.size(),
_Alloc_traits::_S_select_on_copy(__x._M_get_Tp_allocator()))
{
this->_M_impl._M_finish =
std::__uninitialized_copy_a(__x.begin(), __x.end(),
this->_M_impl._M_start,
_M_get_Tp_allocator());
}
#if __cplusplus >= 201103L
/**
* @brief %Vector move constructor.
* @param __x A %vector of identical element and allocator types.
*
* The newly-created %vector contains the exact contents of @a __x.
* The contents of @a __x are a valid, but unspecified %vector.
*/
vector(vector&& __x) noexcept
: _Base(std::move(__x)) { }
/// Copy constructor with alternative allocator
vector(const vector& __x, const allocator_type& __a)
: _Base(__x.size(), __a)
{
this->_M_impl._M_finish =
std::__uninitialized_copy_a(__x.begin(), __x.end(),
this->_M_impl._M_start,
_M_get_Tp_allocator());
}
/// Move constructor with alternative allocator
vector(vector&& __rv, const allocator_type& __m)
noexcept(_Alloc_traits::_S_always_equal())
: _Base(std::move(__rv), __m)
{
if (__rv.get_allocator() != __m)
{
this->_M_impl._M_finish =
std::__uninitialized_move_a(__rv.begin(), __rv.end(),
this->_M_impl._M_start,
_M_get_Tp_allocator());
__rv.clear();
}
}
/**
* @brief Builds a %vector from an initializer list.
* @param __l An initializer_list.
* @param __a An allocator.
*
* Create a %vector consisting of copies of the elements in the
* initializer_list @a __l.
*
* This will call the element type's copy constructor N times
* (where N is @a __l.size()) and do no memory reallocation.
*/
vector(initializer_list<value_type> __l,
const allocator_type& __a = allocator_type())
: _Base(__a)
{
_M_range_initialize(__l.begin(), __l.end(),
random_access_iterator_tag());
}
#endif
/**
* @brief Builds a %vector from a range.
* @param __first An input iterator.
* @param __last An input iterator.
* @param __a An allocator.
*
* Create a %vector consisting of copies of the elements from
* [first,last).
*
* If the iterators are forward, bidirectional, or
* random-access, then this will call the elements' copy
* constructor N times (where N is distance(first,last)) and do
* no memory reallocation. But if only input iterators are
* used, then this will do at most 2N calls to the copy
* constructor, and logN memory reallocations.
*/
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
vector(_InputIterator __first, _InputIterator __last,
const allocator_type& __a = allocator_type())
: _Base(__a)
{ _M_initialize_dispatch(__first, __last, __false_type()); }
#else
template<typename _InputIterator>
vector(_InputIterator __first, _InputIterator __last,
const allocator_type& __a = allocator_type())
: _Base(__a)
{
// Check whether it's an integral type. If so, it's not an iterator.
typedef typename std::__is_integer<_InputIterator>::__type _Integral;
_M_initialize_dispatch(__first, __last, _Integral());
}
#endif
/**
* The dtor only erases the elements, and note that if the
* elements themselves are pointers, the pointed-to memory is
* not touched in any way. Managing the pointer is the user's
* responsibility.
*/
~vector() _GLIBCXX_NOEXCEPT
{
std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
_M_get_Tp_allocator());
_GLIBCXX_ASAN_ANNOTATE_BEFORE_DEALLOC;
}
/**
* @brief %Vector assignment operator.
* @param __x A %vector of identical element and allocator types.
*
* All the elements of @a __x are copied, but any unused capacity in
* @a __x will not be copied.
*
* Whether the allocator is copied depends on the allocator traits.
*/
vector&
operator=(const vector& __x);
#if __cplusplus >= 201103L
/**
* @brief %Vector move assignment operator.
* @param __x A %vector of identical element and allocator types.
*
* The contents of @a __x are moved into this %vector (without copying,
* if the allocators permit it).
* Afterwards @a __x is a valid, but unspecified %vector.
*
* Whether the allocator is moved depends on the allocator traits.
*/
vector&
operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
{
constexpr bool __move_storage =
_Alloc_traits::_S_propagate_on_move_assign()
|| _Alloc_traits::_S_always_equal();
_M_move_assign(std::move(__x), __bool_constant<__move_storage>());
return *this;
}
/**
* @brief %Vector list assignment operator.
* @param __l An initializer_list.
*
* This function fills a %vector with copies of the elements in the
* initializer list @a __l.
*
* Note that the assignment completely changes the %vector and
* that the resulting %vector's size is the same as the number
* of elements assigned.
*/
vector&
operator=(initializer_list<value_type> __l)
{
this->_M_assign_aux(__l.begin(), __l.end(),
random_access_iterator_tag());
return *this;
}
#endif
/**
* @brief Assigns a given value to a %vector.
* @param __n Number of elements to be assigned.
* @param __val Value to be assigned.
*
* This function fills a %vector with @a __n copies of the given
* value. Note that the assignment completely changes the
* %vector and that the resulting %vector's size is the same as
* the number of elements assigned.
*/
void
assign(size_type __n, const value_type& __val)
{ _M_fill_assign(__n, __val); }
/**
* @brief Assigns a range to a %vector.
* @param __first An input iterator.
* @param __last An input iterator.
*
* This function fills a %vector with copies of the elements in the
* range [__first,__last).
*
* Note that the assignment completely changes the %vector and
* that the resulting %vector's size is the same as the number
* of elements assigned.
*/
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
void
assign(_InputIterator __first, _InputIterator __last)
{ _M_assign_dispatch(__first, __last, __false_type()); }
#else
template<typename _InputIterator>
void
assign(_InputIterator __first, _InputIterator __last)
{
// Check whether it's an integral type. If so, it's not an iterator.
typedef typename std::__is_integer<_InputIterator>::__type _Integral;
_M_assign_dispatch(__first, __last, _Integral());
}
#endif
#if __cplusplus >= 201103L
/**
* @brief Assigns an initializer list to a %vector.
* @param __l An initializer_list.
*
* This function fills a %vector with copies of the elements in the
* initializer list @a __l.
*
* Note that the assignment completely changes the %vector and
* that the resulting %vector's size is the same as the number
* of elements assigned.
*/
void
assign(initializer_list<value_type> __l)
{
this->_M_assign_aux(__l.begin(), __l.end(),
random_access_iterator_tag());
}
#endif
/// Get a copy of the memory allocation object.
using _Base::get_allocator;
// iterators
/**
* Returns a read/write iterator that points to the first
* element in the %vector. Iteration is done in ordinary
* element order.
*/
iterator
begin() _GLIBCXX_NOEXCEPT
{ return iterator(this->_M_impl._M_start); }
/**
* Returns a read-only (constant) iterator that points to the
* first element in the %vector. Iteration is done in ordinary
* element order.
*/
const_iterator
begin() const _GLIBCXX_NOEXCEPT
{ return const_iterator(this->_M_impl._M_start); }
/**
* Returns a read/write iterator that points one past the last
* element in the %vector. Iteration is done in ordinary
* element order.
*/
iterator
end() _GLIBCXX_NOEXCEPT
{ return iterator(this->_M_impl._M_finish); }
/**
* Returns a read-only (constant) iterator that points one past
* the last element in the %vector. Iteration is done in
* ordinary element order.
*/
const_iterator
end() const _GLIBCXX_NOEXCEPT
{ return const_iterator(this->_M_impl._M_finish); }
/**
* Returns a read/write reverse iterator that points to the
* last element in the %vector. Iteration is done in reverse
* element order.
*/
reverse_iterator
rbegin() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(end()); }
/**
* Returns a read-only (constant) reverse iterator that points
* to the last element in the %vector. Iteration is done in
* reverse element order.
*/
const_reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(end()); }
/**
* Returns a read/write reverse iterator that points to one
* before the first element in the %vector. Iteration is done
* in reverse element order.
*/
reverse_iterator
rend() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(begin()); }
/**
* Returns a read-only (constant) reverse iterator that points
* to one before the first element in the %vector. Iteration
* is done in reverse element order.
*/
const_reverse_iterator
rend() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(begin()); }
#if __cplusplus >= 201103L
/**
* Returns a read-only (constant) iterator that points to the
* first element in the %vector. Iteration is done in ordinary
* element order.
*/
const_iterator
cbegin() const noexcept
{ return const_iterator(this->_M_impl._M_start); }
/**
* Returns a read-only (constant) iterator that points one past
* the last element in the %vector. Iteration is done in
* ordinary element order.
*/
const_iterator
cend() const noexcept
{ return const_iterator(this->_M_impl._M_finish); }
/**
* Returns a read-only (constant) reverse iterator that points
* to the last element in the %vector. Iteration is done in
* reverse element order.
*/
const_reverse_iterator
crbegin() const noexcept
{ return const_reverse_iterator(end()); }
/**
* Returns a read-only (constant) reverse iterator that points
* to one before the first element in the %vector. Iteration
* is done in reverse element order.
*/
const_reverse_iterator
crend() const noexcept
{ return const_reverse_iterator(begin()); }
#endif
// [23.2.4.2] capacity
/** Returns the number of elements in the %vector. */
size_type
size() const _GLIBCXX_NOEXCEPT
{ return size_type(this->_M_impl._M_finish - this->_M_impl._M_start); }
/** Returns the size() of the largest possible %vector. */
size_type
max_size() const _GLIBCXX_NOEXCEPT
{ return _Alloc_traits::max_size(_M_get_Tp_allocator()); }
#if __cplusplus >= 201103L
/**
* @brief Resizes the %vector to the specified number of elements.
* @param __new_size Number of elements the %vector should contain.
*
* This function will %resize the %vector to the specified
* number of elements. If the number is smaller than the
* %vector's current size the %vector is truncated, otherwise
* default constructed elements are appended.
*/
void
resize(size_type __new_size)
{
if (__new_size > size())
_M_default_append(__new_size - size());
else if (__new_size < size())
_M_erase_at_end(this->_M_impl._M_start + __new_size);
}
/**
* @brief Resizes the %vector to the specified number of elements.
* @param __new_size Number of elements the %vector should contain.
* @param __x Data with which new elements should be populated.
*
* This function will %resize the %vector to the specified
* number of elements. If the number is smaller than the
* %vector's current size the %vector is truncated, otherwise
* the %vector is extended and new elements are populated with
* given data.
*/
void
resize(size_type __new_size, const value_type& __x)
{
if (__new_size > size())
_M_fill_insert(end(), __new_size - size(), __x);
else if (__new_size < size())
_M_erase_at_end(this->_M_impl._M_start + __new_size);
}
#else
/**
* @brief Resizes the %vector to the specified number of elements.
* @param __new_size Number of elements the %vector should contain.
* @param __x Data with which new elements should be populated.
*
* This function will %resize the %vector to the specified
* number of elements. If the number is smaller than the
* %vector's current size the %vector is truncated, otherwise
* the %vector is extended and new elements are populated with
* given data.
*/
void
resize(size_type __new_size, value_type __x = value_type())
{
if (__new_size > size())
_M_fill_insert(end(), __new_size - size(), __x);
else if (__new_size < size())
_M_erase_at_end(this->_M_impl._M_start + __new_size);
}
#endif
#if __cplusplus >= 201103L
/** A non-binding request to reduce capacity() to size(). */
void
shrink_to_fit()
{ _M_shrink_to_fit(); }
#endif
/**
* Returns the total number of elements that the %vector can
* hold before needing to allocate more memory.
*/
size_type
capacity() const _GLIBCXX_NOEXCEPT
{ return size_type(this->_M_impl._M_end_of_storage
- this->_M_impl._M_start); }
/**
* Returns true if the %vector is empty. (Thus begin() would
* equal end().)
*/
bool
empty() const _GLIBCXX_NOEXCEPT
{ return begin() == end(); }
/**
* @brief Attempt to preallocate enough memory for specified number of
* elements.
* @param __n Number of elements required.
* @throw std::length_error If @a n exceeds @c max_size().
*
* This function attempts to reserve enough memory for the
* %vector to hold the specified number of elements. If the
* number requested is more than max_size(), length_error is
* thrown.
*
* The advantage of this function is that if optimal code is a
* necessity and the user can determine the number of elements
* that will be required, the user can reserve the memory in
* %advance, and thus prevent a possible reallocation of memory
* and copying of %vector data.
*/
void
reserve(size_type __n);
// element access
/**
* @brief Subscript access to the data contained in the %vector.
* @param __n The index of the element for which data should be
* accessed.
* @return Read/write reference to data.
*
* This operator allows for easy, array-style, data access.
* Note that data access with this operator is unchecked and
* out_of_range lookups are not defined. (For checked lookups
* see at().)
*/
reference
operator[](size_type __n) _GLIBCXX_NOEXCEPT
{
__glibcxx_requires_subscript(__n);
return *(this->_M_impl._M_start + __n);
}
/**
* @brief Subscript access to the data contained in the %vector.
* @param __n The index of the element for which data should be
* accessed.
* @return Read-only (constant) reference to data.
*
* This operator allows for easy, array-style, data access.
* Note that data access with this operator is unchecked and
* out_of_range lookups are not defined. (For checked lookups
* see at().)
*/
const_reference
operator[](size_type __n) const _GLIBCXX_NOEXCEPT
{
__glibcxx_requires_subscript(__n);
return *(this->_M_impl._M_start + __n);
}
protected:
/// Safety check used only from at().
void
_M_range_check(size_type __n) const
{
if (__n >= this->size())
__throw_out_of_range_fmt(__N("vector::_M_range_check: __n "
"(which is %zu) >= this->size() "
"(which is %zu)"),
__n, this->size());
}
public:
/**
* @brief Provides access to the data contained in the %vector.
* @param __n The index of the element for which data should be
* accessed.
* @return Read/write reference to data.
* @throw std::out_of_range If @a __n is an invalid index.
*
* This function provides for safer data access. The parameter
* is first checked that it is in the range of the vector. The
* function throws out_of_range if the check fails.
*/
reference
at(size_type __n)
{
_M_range_check(__n);
return (*this)[__n];
}
/**
* @brief Provides access to the data contained in the %vector.
* @param __n The index of the element for which data should be
* accessed.
* @return Read-only (constant) reference to data.
* @throw std::out_of_range If @a __n is an invalid index.
*
* This function provides for safer data access. The parameter
* is first checked that it is in the range of the vector. The
* function throws out_of_range if the check fails.
*/
const_reference
at(size_type __n) const
{
_M_range_check(__n);
return (*this)[__n];
}
/**
* Returns a read/write reference to the data at the first
* element of the %vector.
*/
reference
front() _GLIBCXX_NOEXCEPT
{
__glibcxx_requires_nonempty();
return *begin();
}
/**
* Returns a read-only (constant) reference to the data at the first
* element of the %vector.
*/
const_reference
front() const _GLIBCXX_NOEXCEPT
{
__glibcxx_requires_nonempty();
return *begin();
}
/**
* Returns a read/write reference to the data at the last
* element of the %vector.
*/
reference
back() _GLIBCXX_NOEXCEPT
{
__glibcxx_requires_nonempty();
return *(end() - 1);
}
/**
* Returns a read-only (constant) reference to the data at the
* last element of the %vector.
*/
const_reference
back() const _GLIBCXX_NOEXCEPT
{
__glibcxx_requires_nonempty();
return *(end() - 1);
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 464. Suggestion for new member functions in standard containers.
// data access
/**
* Returns a pointer such that [data(), data() + size()) is a valid
* range. For a non-empty %vector, data() == &front().
*/
_Tp*
data() _GLIBCXX_NOEXCEPT
{ return _M_data_ptr(this->_M_impl._M_start); }
const _Tp*
data() const _GLIBCXX_NOEXCEPT
{ return _M_data_ptr(this->_M_impl._M_start); }
// [23.2.4.3] modifiers
/**
* @brief Add data to the end of the %vector.
* @param __x Data to be added.
*
* This is a typical stack operation. The function creates an
* element at the end of the %vector and assigns the given data
* to it. Due to the nature of a %vector this operation can be
* done in constant time if the %vector has preallocated space
* available.
*/
void
push_back(const value_type& __x)
{
if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
{
_GLIBCXX_ASAN_ANNOTATE_GROW(1);
_Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
__x);
++this->_M_impl._M_finish;
_GLIBCXX_ASAN_ANNOTATE_GREW(1);
}
else
_M_realloc_insert(end(), __x);
}
#if __cplusplus >= 201103L
void
push_back(value_type&& __x)
{ emplace_back(std::move(__x)); }
template<typename... _Args>
#if __cplusplus > 201402L
reference
#else
void
#endif
emplace_back(_Args&&... __args);
#endif
/**
* @brief Removes last element.
*
* This is a typical stack operation. It shrinks the %vector by one.
*
* Note that no data is returned, and if the last element's
* data is needed, it should be retrieved before pop_back() is
* called.
*/
void
pop_back() _GLIBCXX_NOEXCEPT
{
__glibcxx_requires_nonempty();
--this->_M_impl._M_finish;
_Alloc_traits::destroy(this->_M_impl, this->_M_impl._M_finish);
_GLIBCXX_ASAN_ANNOTATE_SHRINK(1);
}
#if __cplusplus >= 201103L
/**
* @brief Inserts an object in %vector before specified iterator.
* @param __position A const_iterator into the %vector.
* @param __args Arguments.
* @return An iterator that points to the inserted data.
*
* This function will insert an object of type T constructed
* with T(std::forward<Args>(args)...) before the specified location.
* Note that this kind of operation could be expensive for a %vector
* and if it is frequently used the user should consider using
* std::list.
*/
template<typename... _Args>
iterator
emplace(const_iterator __position, _Args&&... __args)
{ return _M_emplace_aux(__position, std::forward<_Args>(__args)...); }
/**
* @brief Inserts given value into %vector before specified iterator.
* @param __position A const_iterator into the %vector.
* @param __x Data to be inserted.
* @return An iterator that points to the inserted data.
*
* This function will insert a copy of the given value before
* the specified location. Note that this kind of operation
* could be expensive for a %vector and if it is frequently
* used the user should consider using std::list.
*/
iterator
insert(const_iterator __position, const value_type& __x);
#else
/**
* @brief Inserts given value into %vector before specified iterator.
* @param __position An iterator into the %vector.
* @param __x Data to be inserted.
* @return An iterator that points to the inserted data.
*
* This function will insert a copy of the given value before
* the specified location. Note that this kind of operation
* could be expensive for a %vector and if it is frequently
* used the user should consider using std::list.
*/
iterator
insert(iterator __position, const value_type& __x);
#endif
#if __cplusplus >= 201103L
/**
* @brief Inserts given rvalue into %vector before specified iterator.
* @param __position A const_iterator into the %vector.
* @param __x Data to be inserted.
* @return An iterator that points to the inserted data.
*
* This function will insert a copy of the given rvalue before
* the specified location. Note that this kind of operation
* could be expensive for a %vector and if it is frequently
* used the user should consider using std::list.
*/
iterator
insert(const_iterator __position, value_type&& __x)
{ return _M_insert_rval(__position, std::move(__x)); }
/**
* @brief Inserts an initializer_list into the %vector.
* @param __position An iterator into the %vector.
* @param __l An initializer_list.
*
* This function will insert copies of the data in the
* initializer_list @a l into the %vector before the location
* specified by @a position.
*
* Note that this kind of operation could be expensive for a
* %vector and if it is frequently used the user should
* consider using std::list.
*/
iterator
insert(const_iterator __position, initializer_list<value_type> __l)
{
auto __offset = __position - cbegin();
_M_range_insert(begin() + __offset, __l.begin(), __l.end(),
std::random_access_iterator_tag());
return begin() + __offset;
}
#endif
#if __cplusplus >= 201103L
/**
* @brief Inserts a number of copies of given data into the %vector.
* @param __position A const_iterator into the %vector.
* @param __n Number of elements to be inserted.
* @param __x Data to be inserted.
* @return An iterator that points to the inserted data.
*
* This function will insert a specified number of copies of
* the given data before the location specified by @a position.
*
* Note that this kind of operation could be expensive for a
* %vector and if it is frequently used the user should
* consider using std::list.
*/
iterator
insert(const_iterator __position, size_type __n, const value_type& __x)
{
difference_type __offset = __position - cbegin();
_M_fill_insert(begin() + __offset, __n, __x);
return begin() + __offset;
}
#else
/**
* @brief Inserts a number of copies of given data into the %vector.
* @param __position An iterator into the %vector.
* @param __n Number of elements to be inserted.
* @param __x Data to be inserted.
*
* This function will insert a specified number of copies of
* the given data before the location specified by @a position.
*
* Note that this kind of operation could be expensive for a
* %vector and if it is frequently used the user should
* consider using std::list.
*/
void
insert(iterator __position, size_type __n, const value_type& __x)
{ _M_fill_insert(__position, __n, __x); }
#endif
#if __cplusplus >= 201103L
/**
* @brief Inserts a range into the %vector.
* @param __position A const_iterator into the %vector.
* @param __first An input iterator.
* @param __last An input iterator.
* @return An iterator that points to the inserted data.
*
* This function will insert copies of the data in the range
* [__first,__last) into the %vector before the location specified
* by @a pos.
*
* Note that this kind of operation could be expensive for a
* %vector and if it is frequently used the user should
* consider using std::list.
*/
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
iterator
insert(const_iterator __position, _InputIterator __first,
_InputIterator __last)
{
difference_type __offset = __position - cbegin();
_M_insert_dispatch(begin() + __offset,
__first, __last, __false_type());
return begin() + __offset;
}
#else
/**
* @brief Inserts a range into the %vector.
* @param __position An iterator into the %vector.
* @param __first An input iterator.
* @param __last An input iterator.
*
* This function will insert copies of the data in the range
* [__first,__last) into the %vector before the location specified
* by @a pos.
*
* Note that this kind of operation could be expensive for a
* %vector and if it is frequently used the user should
* consider using std::list.
*/
template<typename _InputIterator>
void
insert(iterator __position, _InputIterator __first,
_InputIterator __last)
{
// Check whether it's an integral type. If so, it's not an iterator.
typedef typename std::__is_integer<_InputIterator>::__type _Integral;
_M_insert_dispatch(__position, __first, __last, _Integral());
}
#endif
/**
* @brief Remove element at given position.
* @param __position Iterator pointing to element to be erased.
* @return An iterator pointing to the next element (or end()).
*
* This function will erase the element at the given position and thus
* shorten the %vector by one.
*
* Note This operation could be expensive and if it is
* frequently used the user should consider using std::list.
* The user is also cautioned that this function only erases
* the element, and that if the element is itself a pointer,
* the pointed-to memory is not touched in any way. Managing
* the pointer is the user's responsibility.
*/
iterator
#if __cplusplus >= 201103L
erase(const_iterator __position)
{ return _M_erase(begin() + (__position - cbegin())); }
#else
erase(iterator __position)
{ return _M_erase(__position); }
#endif
/**
* @brief Remove a range of elements.
* @param __first Iterator pointing to the first element to be erased.
* @param __last Iterator pointing to one past the last element to be
* erased.
* @return An iterator pointing to the element pointed to by @a __last
* prior to erasing (or end()).
*
* This function will erase the elements in the range
* [__first,__last) and shorten the %vector accordingly.
*
* Note This operation could be expensive and if it is
* frequently used the user should consider using std::list.
* The user is also cautioned that this function only erases
* the elements, and that if the elements themselves are
* pointers, the pointed-to memory is not touched in any way.
* Managing the pointer is the user's responsibility.
*/
iterator
#if __cplusplus >= 201103L
erase(const_iterator __first, const_iterator __last)
{
const auto __beg = begin();
const auto __cbeg = cbegin();
return _M_erase(__beg + (__first - __cbeg), __beg + (__last - __cbeg));
}
#else
erase(iterator __first, iterator __last)
{ return _M_erase(__first, __last); }
#endif
/**
* @brief Swaps data with another %vector.
* @param __x A %vector of the same element and allocator types.
*
* This exchanges the elements between two vectors in constant time.
* (Three pointers, so it should be quite fast.)
* Note that the global std::swap() function is specialized such that
* std::swap(v1,v2) will feed to this function.
*
* Whether the allocators are swapped depends on the allocator traits.
*/
void
swap(vector& __x) _GLIBCXX_NOEXCEPT
{
#if __cplusplus >= 201103L
__glibcxx_assert(_Alloc_traits::propagate_on_container_swap::value
|| _M_get_Tp_allocator() == __x._M_get_Tp_allocator());
#endif
this->_M_impl._M_swap_data(__x._M_impl);
_Alloc_traits::_S_on_swap(_M_get_Tp_allocator(),
__x._M_get_Tp_allocator());
}
/**
* Erases all the elements. Note that this function only erases the
* elements, and that if the elements themselves are pointers, the
* pointed-to memory is not touched in any way. Managing the pointer is
* the user's responsibility.
*/
void
clear() _GLIBCXX_NOEXCEPT
{ _M_erase_at_end(this->_M_impl._M_start); }
protected:
/**
* Memory expansion handler. Uses the member allocation function to
* obtain @a n bytes of memory, and then copies [first,last) into it.
*/
template<typename _ForwardIterator>
pointer
_M_allocate_and_copy(size_type __n,
_ForwardIterator __first, _ForwardIterator __last)
{
pointer __result = this->_M_allocate(__n);
__try
{
std::__uninitialized_copy_a(__first, __last, __result,
_M_get_Tp_allocator());
return __result;
}
__catch(...)
{
_M_deallocate(__result, __n);
__throw_exception_again;
}
}
// Internal constructor functions follow.
// Called by the range constructor to implement [23.1.1]/9
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 438. Ambiguity in the "do the right thing" clause
template<typename _Integer>
void
_M_initialize_dispatch(_Integer __n, _Integer __value, __true_type)
{
this->_M_impl._M_start = _M_allocate(static_cast<size_type>(__n));
this->_M_impl._M_end_of_storage =
this->_M_impl._M_start + static_cast<size_type>(__n);
_M_fill_initialize(static_cast<size_type>(__n), __value);
}
// Called by the range constructor to implement [23.1.1]/9
template<typename _InputIterator>
void
_M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
__false_type)
{
typedef typename std::iterator_traits<_InputIterator>::
iterator_category _IterCategory;
_M_range_initialize(__first, __last, _IterCategory());
}
// Called by the second initialize_dispatch above
template<typename _InputIterator>
void
_M_range_initialize(_InputIterator __first, _InputIterator __last,
std::input_iterator_tag)
{
__try {
for (; __first != __last; ++__first)
#if __cplusplus >= 201103L
emplace_back(*__first);
#else
push_back(*__first);
#endif
} __catch(...) {
clear();
__throw_exception_again;
}
}
// Called by the second initialize_dispatch above
template<typename _ForwardIterator>
void
_M_range_initialize(_ForwardIterator __first, _ForwardIterator __last,
std::forward_iterator_tag)
{
const size_type __n = std::distance(__first, __last);
this->_M_impl._M_start = this->_M_allocate(__n);
this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
this->_M_impl._M_finish =
std::__uninitialized_copy_a(__first, __last,
this->_M_impl._M_start,
_M_get_Tp_allocator());
}
// Called by the first initialize_dispatch above and by the
// vector(n,value,a) constructor.
void
_M_fill_initialize(size_type __n, const value_type& __value)
{
this->_M_impl._M_finish =
std::__uninitialized_fill_n_a(this->_M_impl._M_start, __n, __value,
_M_get_Tp_allocator());
}
#if __cplusplus >= 201103L
// Called by the vector(n) constructor.
void
_M_default_initialize(size_type __n)
{
this->_M_impl._M_finish =
std::__uninitialized_default_n_a(this->_M_impl._M_start, __n,
_M_get_Tp_allocator());
}
#endif
// Internal assign functions follow. The *_aux functions do the actual
// assignment work for the range versions.
// Called by the range assign to implement [23.1.1]/9
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 438. Ambiguity in the "do the right thing" clause
template<typename _Integer>
void
_M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
{ _M_fill_assign(__n, __val); }
// Called by the range assign to implement [23.1.1]/9
template<typename _InputIterator>
void
_M_assign_dispatch(_InputIterator __first, _InputIterator __last,
__false_type)
{ _M_assign_aux(__first, __last, std::__iterator_category(__first)); }
// Called by the second assign_dispatch above
template<typename _InputIterator>
void
_M_assign_aux(_InputIterator __first, _InputIterator __last,
std::input_iterator_tag);
// Called by the second assign_dispatch above
template<typename _ForwardIterator>
void
_M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
std::forward_iterator_tag);
// Called by assign(n,t), and the range assign when it turns out
// to be the same thing.
void
_M_fill_assign(size_type __n, const value_type& __val);
// Internal insert functions follow.
// Called by the range insert to implement [23.1.1]/9
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 438. Ambiguity in the "do the right thing" clause
template<typename _Integer>
void
_M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val,
__true_type)
{ _M_fill_insert(__pos, __n, __val); }
// Called by the range insert to implement [23.1.1]/9
template<typename _InputIterator>
void
_M_insert_dispatch(iterator __pos, _InputIterator __first,
_InputIterator __last, __false_type)
{
_M_range_insert(__pos, __first, __last,
std::__iterator_category(__first));
}
// Called by the second insert_dispatch above
template<typename _InputIterator>
void
_M_range_insert(iterator __pos, _InputIterator __first,
_InputIterator __last, std::input_iterator_tag);
// Called by the second insert_dispatch above
template<typename _ForwardIterator>
void
_M_range_insert(iterator __pos, _ForwardIterator __first,
_ForwardIterator __last, std::forward_iterator_tag);
// Called by insert(p,n,x), and the range insert when it turns out to be
// the same thing.
void
_M_fill_insert(iterator __pos, size_type __n, const value_type& __x);
#if __cplusplus >= 201103L
// Called by resize(n).
void
_M_default_append(size_type __n);
bool
_M_shrink_to_fit();
#endif
#if __cplusplus < 201103L
// Called by insert(p,x)
void
_M_insert_aux(iterator __position, const value_type& __x);
void
_M_realloc_insert(iterator __position, const value_type& __x);
#else
// A value_type object constructed with _Alloc_traits::construct()
// and destroyed with _Alloc_traits::destroy().
struct _Temporary_value
{
template<typename... _Args>
explicit
_Temporary_value(vector* __vec, _Args&&... __args) : _M_this(__vec)
{
_Alloc_traits::construct(_M_this->_M_impl, _M_ptr(),
std::forward<_Args>(__args)...);
}
~_Temporary_value()
{ _Alloc_traits::destroy(_M_this->_M_impl, _M_ptr()); }
value_type&
_M_val() { return *_M_ptr(); }
private:
_Tp*
_M_ptr() { return reinterpret_cast<_Tp*>(&__buf); }
vector* _M_this;
typename aligned_storage<sizeof(_Tp), alignof(_Tp)>::type __buf;
};
// Called by insert(p,x) and other functions when insertion needs to
// reallocate or move existing elements. _Arg is either _Tp& or _Tp.
template<typename _Arg>
void
_M_insert_aux(iterator __position, _Arg&& __arg);
template<typename... _Args>
void
_M_realloc_insert(iterator __position, _Args&&... __args);
// Either move-construct at the end, or forward to _M_insert_aux.
iterator
_M_insert_rval(const_iterator __position, value_type&& __v);
// Try to emplace at the end, otherwise forward to _M_insert_aux.
template<typename... _Args>
iterator
_M_emplace_aux(const_iterator __position, _Args&&... __args);
// Emplacing an rvalue of the correct type can use _M_insert_rval.
iterator
_M_emplace_aux(const_iterator __position, value_type&& __v)
{ return _M_insert_rval(__position, std::move(__v)); }
#endif
// Called by _M_fill_insert, _M_insert_aux etc.
size_type
_M_check_len(size_type __n, const char* __s) const
{
if (max_size() - size() < __n)
__throw_length_error(__N(__s));
const size_type __len = size() + std::max(size(), __n);
return (__len < size() || __len > max_size()) ? max_size() : __len;
}
// Internal erase functions follow.
// Called by erase(q1,q2), clear(), resize(), _M_fill_assign,
// _M_assign_aux.
void
_M_erase_at_end(pointer __pos) _GLIBCXX_NOEXCEPT
{
if (size_type __n = this->_M_impl._M_finish - __pos)
{
std::_Destroy(__pos, this->_M_impl._M_finish,
_M_get_Tp_allocator());
this->_M_impl._M_finish = __pos;
_GLIBCXX_ASAN_ANNOTATE_SHRINK(__n);
}
}
iterator
_M_erase(iterator __position);
iterator
_M_erase(iterator __first, iterator __last);
#if __cplusplus >= 201103L
private:
// Constant-time move assignment when source object's memory can be
// moved, either because the source's allocator will move too
// or because the allocators are equal.
void
_M_move_assign(vector&& __x, std::true_type) noexcept
{
vector __tmp(get_allocator());
this->_M_impl._M_swap_data(__tmp._M_impl);
this->_M_impl._M_swap_data(__x._M_impl);
std::__alloc_on_move(_M_get_Tp_allocator(), __x._M_get_Tp_allocator());
}
// Do move assignment when it might not be possible to move source
// object's memory, resulting in a linear-time operation.
void
_M_move_assign(vector&& __x, std::false_type)
{
if (__x._M_get_Tp_allocator() == this->_M_get_Tp_allocator())
_M_move_assign(std::move(__x), std::true_type());
else
{
// The rvalue's allocator cannot be moved and is not equal,
// so we need to individually move each element.
this->assign(std::__make_move_if_noexcept_iterator(__x.begin()),
std::__make_move_if_noexcept_iterator(__x.end()));
__x.clear();
}
}
#endif
template<typename _Up>
_Up*
_M_data_ptr(_Up* __ptr) const _GLIBCXX_NOEXCEPT
{ return __ptr; }
#if __cplusplus >= 201103L
template<typename _Ptr>
typename std::pointer_traits<_Ptr>::element_type*
_M_data_ptr(_Ptr __ptr) const
{ return empty() ? nullptr : std::__to_address(__ptr); }
#else
template<typename _Up>
_Up*
_M_data_ptr(_Up* __ptr) _GLIBCXX_NOEXCEPT
{ return __ptr; }
template<typename _Ptr>
value_type*
_M_data_ptr(_Ptr __ptr)
{ return empty() ? (value_type*)0 : __ptr.operator->(); }
template<typename _Ptr>
const value_type*
_M_data_ptr(_Ptr __ptr) const
{ return empty() ? (const value_type*)0 : __ptr.operator->(); }
#endif
};
#if __cpp_deduction_guides >= 201606
template<typename _InputIterator, typename _ValT
= typename iterator_traits<_InputIterator>::value_type,
typename _Allocator = allocator<_ValT>,
typename = _RequireInputIter<_InputIterator>,
typename = _RequireAllocator<_Allocator>>
vector(_InputIterator, _InputIterator, _Allocator = _Allocator())
-> vector<_ValT, _Allocator>;
#endif
/**
* @brief Vector equality comparison.
* @param __x A %vector.
* @param __y A %vector of the same type as @a __x.
* @return True iff the size and elements of the vectors are equal.
*
* This is an equivalence relation. It is linear in the size of the
* vectors. Vectors are considered equivalent if their sizes are equal,
* and if corresponding elements compare equal.
*/
template<typename _Tp, typename _Alloc>
inline bool
operator==(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
{ return (__x.size() == __y.size()
&& std::equal(__x.begin(), __x.end(), __y.begin())); }
/**
* @brief Vector ordering relation.
* @param __x A %vector.
* @param __y A %vector of the same type as @a __x.
* @return True iff @a __x is lexicographically less than @a __y.
*
* This is a total ordering relation. It is linear in the size of the
* vectors. The elements must be comparable with @c <.
*
* See std::lexicographical_compare() for how the determination is made.
*/
template<typename _Tp, typename _Alloc>
inline bool
operator<(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
{ return std::lexicographical_compare(__x.begin(), __x.end(),
__y.begin(), __y.end()); }
/// Based on operator==
template<typename _Tp, typename _Alloc>
inline bool
operator!=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
{ return !(__x == __y); }
/// Based on operator<
template<typename _Tp, typename _Alloc>
inline bool
operator>(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
{ return __y < __x; }
/// Based on operator<
template<typename _Tp, typename _Alloc>
inline bool
operator<=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
{ return !(__y < __x); }
/// Based on operator<
template<typename _Tp, typename _Alloc>
inline bool
operator>=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
{ return !(__x < __y); }
/// See std::vector::swap().
template<typename _Tp, typename _Alloc>
inline void
swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>& __y)
_GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
{ __x.swap(__y); }
_GLIBCXX_END_NAMESPACE_CONTAINER
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif /* _STL_VECTOR_H */
c++/8/bits/regex.tcc 0000644 00000040265 15201526705 0010043 0 ustar 00 // class template regex -*- C++ -*-
// Copyright (C) 2013-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/**
* @file bits/regex.tcc
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{regex}
*/
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
namespace __detail
{
// Result of merging regex_match and regex_search.
//
// __policy now can be _S_auto (auto dispatch) and _S_alternate (use
// the other one if possible, for test purpose).
//
// That __match_mode is true means regex_match, else regex_search.
template<typename _BiIter, typename _Alloc,
typename _CharT, typename _TraitsT,
_RegexExecutorPolicy __policy,
bool __match_mode>
bool
__regex_algo_impl(_BiIter __s,
_BiIter __e,
match_results<_BiIter, _Alloc>& __m,
const basic_regex<_CharT, _TraitsT>& __re,
regex_constants::match_flag_type __flags)
{
if (__re._M_automaton == nullptr)
return false;
typename match_results<_BiIter, _Alloc>::_Base_type& __res = __m;
__m._M_begin = __s;
__m._M_resize(__re._M_automaton->_M_sub_count());
for (auto& __it : __res)
__it.matched = false;
bool __ret;
if ((__re.flags() & regex_constants::__polynomial)
|| (__policy == _RegexExecutorPolicy::_S_alternate
&& !__re._M_automaton->_M_has_backref))
{
_Executor<_BiIter, _Alloc, _TraitsT, false>
__executor(__s, __e, __m, __re, __flags);
if (__match_mode)
__ret = __executor._M_match();
else
__ret = __executor._M_search();
}
else
{
_Executor<_BiIter, _Alloc, _TraitsT, true>
__executor(__s, __e, __m, __re, __flags);
if (__match_mode)
__ret = __executor._M_match();
else
__ret = __executor._M_search();
}
if (__ret)
{
for (auto& __it : __res)
if (!__it.matched)
__it.first = __it.second = __e;
auto& __pre = __m._M_prefix();
auto& __suf = __m._M_suffix();
if (__match_mode)
{
__pre.matched = false;
__pre.first = __s;
__pre.second = __s;
__suf.matched = false;
__suf.first = __e;
__suf.second = __e;
}
else
{
__pre.first = __s;
__pre.second = __res[0].first;
__pre.matched = (__pre.first != __pre.second);
__suf.first = __res[0].second;
__suf.second = __e;
__suf.matched = (__suf.first != __suf.second);
}
}
else
{
__m._M_resize(0);
for (auto& __it : __res)
{
__it.matched = false;
__it.first = __it.second = __e;
}
}
return __ret;
}
}
template<typename _Ch_type>
template<typename _Fwd_iter>
typename regex_traits<_Ch_type>::string_type
regex_traits<_Ch_type>::
lookup_collatename(_Fwd_iter __first, _Fwd_iter __last) const
{
typedef std::ctype<char_type> __ctype_type;
const __ctype_type& __fctyp(use_facet<__ctype_type>(_M_locale));
static const char* __collatenames[] =
{
"NUL",
"SOH",
"STX",
"ETX",
"EOT",
"ENQ",
"ACK",
"alert",
"backspace",
"tab",
"newline",
"vertical-tab",
"form-feed",
"carriage-return",
"SO",
"SI",
"DLE",
"DC1",
"DC2",
"DC3",
"DC4",
"NAK",
"SYN",
"ETB",
"CAN",
"EM",
"SUB",
"ESC",
"IS4",
"IS3",
"IS2",
"IS1",
"space",
"exclamation-mark",
"quotation-mark",
"number-sign",
"dollar-sign",
"percent-sign",
"ampersand",
"apostrophe",
"left-parenthesis",
"right-parenthesis",
"asterisk",
"plus-sign",
"comma",
"hyphen",
"period",
"slash",
"zero",
"one",
"two",
"three",
"four",
"five",
"six",
"seven",
"eight",
"nine",
"colon",
"semicolon",
"less-than-sign",
"equals-sign",
"greater-than-sign",
"question-mark",
"commercial-at",
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"Q",
"R",
"S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z",
"left-square-bracket",
"backslash",
"right-square-bracket",
"circumflex",
"underscore",
"grave-accent",
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
"left-curly-bracket",
"vertical-line",
"right-curly-bracket",
"tilde",
"DEL",
};
string __s;
for (; __first != __last; ++__first)
__s += __fctyp.narrow(*__first, 0);
for (const auto& __it : __collatenames)
if (__s == __it)
return string_type(1, __fctyp.widen(
static_cast<char>(&__it - __collatenames)));
// TODO Add digraph support:
// http://boost.sourceforge.net/libs/regex/doc/collating_names.html
return string_type();
}
template<typename _Ch_type>
template<typename _Fwd_iter>
typename regex_traits<_Ch_type>::char_class_type
regex_traits<_Ch_type>::
lookup_classname(_Fwd_iter __first, _Fwd_iter __last, bool __icase) const
{
typedef std::ctype<char_type> __ctype_type;
const __ctype_type& __fctyp(use_facet<__ctype_type>(_M_locale));
// Mappings from class name to class mask.
static const pair<const char*, char_class_type> __classnames[] =
{
{"d", ctype_base::digit},
{"w", {ctype_base::alnum, _RegexMask::_S_under}},
{"s", ctype_base::space},
{"alnum", ctype_base::alnum},
{"alpha", ctype_base::alpha},
{"blank", ctype_base::blank},
{"cntrl", ctype_base::cntrl},
{"digit", ctype_base::digit},
{"graph", ctype_base::graph},
{"lower", ctype_base::lower},
{"print", ctype_base::print},
{"punct", ctype_base::punct},
{"space", ctype_base::space},
{"upper", ctype_base::upper},
{"xdigit", ctype_base::xdigit},
};
string __s;
for (; __first != __last; ++__first)
__s += __fctyp.narrow(__fctyp.tolower(*__first), 0);
for (const auto& __it : __classnames)
if (__s == __it.first)
{
if (__icase
&& ((__it.second
& (ctype_base::lower | ctype_base::upper)) != 0))
return ctype_base::alpha;
return __it.second;
}
return 0;
}
template<typename _Ch_type>
bool
regex_traits<_Ch_type>::
isctype(_Ch_type __c, char_class_type __f) const
{
typedef std::ctype<char_type> __ctype_type;
const __ctype_type& __fctyp(use_facet<__ctype_type>(_M_locale));
return __fctyp.is(__f._M_base, __c)
// [[:w:]]
|| ((__f._M_extended & _RegexMask::_S_under)
&& __c == __fctyp.widen('_'));
}
template<typename _Ch_type>
int
regex_traits<_Ch_type>::
value(_Ch_type __ch, int __radix) const
{
std::basic_istringstream<char_type> __is(string_type(1, __ch));
long __v;
if (__radix == 8)
__is >> std::oct;
else if (__radix == 16)
__is >> std::hex;
__is >> __v;
return __is.fail() ? -1 : __v;
}
template<typename _Bi_iter, typename _Alloc>
template<typename _Out_iter>
_Out_iter match_results<_Bi_iter, _Alloc>::
format(_Out_iter __out,
const match_results<_Bi_iter, _Alloc>::char_type* __fmt_first,
const match_results<_Bi_iter, _Alloc>::char_type* __fmt_last,
match_flag_type __flags) const
{
__glibcxx_assert( ready() );
regex_traits<char_type> __traits;
typedef std::ctype<char_type> __ctype_type;
const __ctype_type&
__fctyp(use_facet<__ctype_type>(__traits.getloc()));
auto __output = [&](size_t __idx)
{
auto& __sub = (*this)[__idx];
if (__sub.matched)
__out = std::copy(__sub.first, __sub.second, __out);
};
if (__flags & regex_constants::format_sed)
{
bool __escaping = false;
for (; __fmt_first != __fmt_last; __fmt_first++)
{
if (__escaping)
{
__escaping = false;
if (__fctyp.is(__ctype_type::digit, *__fmt_first))
__output(__traits.value(*__fmt_first, 10));
else
*__out++ = *__fmt_first;
continue;
}
if (*__fmt_first == '\\')
{
__escaping = true;
continue;
}
if (*__fmt_first == '&')
{
__output(0);
continue;
}
*__out++ = *__fmt_first;
}
if (__escaping)
*__out++ = '\\';
}
else
{
while (1)
{
auto __next = std::find(__fmt_first, __fmt_last, '$');
if (__next == __fmt_last)
break;
__out = std::copy(__fmt_first, __next, __out);
auto __eat = [&](char __ch) -> bool
{
if (*__next == __ch)
{
++__next;
return true;
}
return false;
};
if (++__next == __fmt_last)
*__out++ = '$';
else if (__eat('$'))
*__out++ = '$';
else if (__eat('&'))
__output(0);
else if (__eat('`'))
{
auto& __sub = _M_prefix();
if (__sub.matched)
__out = std::copy(__sub.first, __sub.second, __out);
}
else if (__eat('\''))
{
auto& __sub = _M_suffix();
if (__sub.matched)
__out = std::copy(__sub.first, __sub.second, __out);
}
else if (__fctyp.is(__ctype_type::digit, *__next))
{
long __num = __traits.value(*__next, 10);
if (++__next != __fmt_last
&& __fctyp.is(__ctype_type::digit, *__next))
{
__num *= 10;
__num += __traits.value(*__next++, 10);
}
if (0 <= __num && __num < this->size())
__output(__num);
}
else
*__out++ = '$';
__fmt_first = __next;
}
__out = std::copy(__fmt_first, __fmt_last, __out);
}
return __out;
}
template<typename _Out_iter, typename _Bi_iter,
typename _Rx_traits, typename _Ch_type>
_Out_iter
regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
const basic_regex<_Ch_type, _Rx_traits>& __e,
const _Ch_type* __fmt,
regex_constants::match_flag_type __flags)
{
typedef regex_iterator<_Bi_iter, _Ch_type, _Rx_traits> _IterT;
_IterT __i(__first, __last, __e, __flags);
_IterT __end;
if (__i == __end)
{
if (!(__flags & regex_constants::format_no_copy))
__out = std::copy(__first, __last, __out);
}
else
{
sub_match<_Bi_iter> __last;
auto __len = char_traits<_Ch_type>::length(__fmt);
for (; __i != __end; ++__i)
{
if (!(__flags & regex_constants::format_no_copy))
__out = std::copy(__i->prefix().first, __i->prefix().second,
__out);
__out = __i->format(__out, __fmt, __fmt + __len, __flags);
__last = __i->suffix();
if (__flags & regex_constants::format_first_only)
break;
}
if (!(__flags & regex_constants::format_no_copy))
__out = std::copy(__last.first, __last.second, __out);
}
return __out;
}
template<typename _Bi_iter,
typename _Ch_type,
typename _Rx_traits>
bool
regex_iterator<_Bi_iter, _Ch_type, _Rx_traits>::
operator==(const regex_iterator& __rhs) const
{
if (_M_pregex == nullptr && __rhs._M_pregex == nullptr)
return true;
return _M_pregex == __rhs._M_pregex
&& _M_begin == __rhs._M_begin
&& _M_end == __rhs._M_end
&& _M_flags == __rhs._M_flags
&& _M_match[0] == __rhs._M_match[0];
}
template<typename _Bi_iter,
typename _Ch_type,
typename _Rx_traits>
regex_iterator<_Bi_iter, _Ch_type, _Rx_traits>&
regex_iterator<_Bi_iter, _Ch_type, _Rx_traits>::
operator++()
{
// In all cases in which the call to regex_search returns true,
// match.prefix().first shall be equal to the previous value of
// match[0].second, and for each index i in the half-open range
// [0, match.size()) for which match[i].matched is true,
// match[i].position() shall return distance(begin, match[i].first).
// [28.12.1.4.5]
if (_M_match[0].matched)
{
auto __start = _M_match[0].second;
auto __prefix_first = _M_match[0].second;
if (_M_match[0].first == _M_match[0].second)
{
if (__start == _M_end)
{
_M_pregex = nullptr;
return *this;
}
else
{
if (regex_search(__start, _M_end, _M_match, *_M_pregex,
_M_flags
| regex_constants::match_not_null
| regex_constants::match_continuous))
{
__glibcxx_assert(_M_match[0].matched);
auto& __prefix = _M_match._M_prefix();
__prefix.first = __prefix_first;
__prefix.matched = __prefix.first != __prefix.second;
// [28.12.1.4.5]
_M_match._M_begin = _M_begin;
return *this;
}
else
++__start;
}
}
_M_flags |= regex_constants::match_prev_avail;
if (regex_search(__start, _M_end, _M_match, *_M_pregex, _M_flags))
{
__glibcxx_assert(_M_match[0].matched);
auto& __prefix = _M_match._M_prefix();
__prefix.first = __prefix_first;
__prefix.matched = __prefix.first != __prefix.second;
// [28.12.1.4.5]
_M_match._M_begin = _M_begin;
}
else
_M_pregex = nullptr;
}
return *this;
}
template<typename _Bi_iter,
typename _Ch_type,
typename _Rx_traits>
regex_token_iterator<_Bi_iter, _Ch_type, _Rx_traits>&
regex_token_iterator<_Bi_iter, _Ch_type, _Rx_traits>::
operator=(const regex_token_iterator& __rhs)
{
_M_position = __rhs._M_position;
_M_subs = __rhs._M_subs;
_M_n = __rhs._M_n;
_M_suffix = __rhs._M_suffix;
_M_has_m1 = __rhs._M_has_m1;
_M_normalize_result();
return *this;
}
template<typename _Bi_iter,
typename _Ch_type,
typename _Rx_traits>
bool
regex_token_iterator<_Bi_iter, _Ch_type, _Rx_traits>::
operator==(const regex_token_iterator& __rhs) const
{
if (_M_end_of_seq() && __rhs._M_end_of_seq())
return true;
if (_M_suffix.matched && __rhs._M_suffix.matched
&& _M_suffix == __rhs._M_suffix)
return true;
if (_M_end_of_seq() || _M_suffix.matched
|| __rhs._M_end_of_seq() || __rhs._M_suffix.matched)
return false;
return _M_position == __rhs._M_position
&& _M_n == __rhs._M_n
&& _M_subs == __rhs._M_subs;
}
template<typename _Bi_iter,
typename _Ch_type,
typename _Rx_traits>
regex_token_iterator<_Bi_iter, _Ch_type, _Rx_traits>&
regex_token_iterator<_Bi_iter, _Ch_type, _Rx_traits>::
operator++()
{
_Position __prev = _M_position;
if (_M_suffix.matched)
*this = regex_token_iterator();
else if (_M_n + 1 < _M_subs.size())
{
_M_n++;
_M_result = &_M_current_match();
}
else
{
_M_n = 0;
++_M_position;
if (_M_position != _Position())
_M_result = &_M_current_match();
else if (_M_has_m1 && __prev->suffix().length() != 0)
{
_M_suffix.matched = true;
_M_suffix.first = __prev->suffix().first;
_M_suffix.second = __prev->suffix().second;
_M_result = &_M_suffix;
}
else
*this = regex_token_iterator();
}
return *this;
}
template<typename _Bi_iter,
typename _Ch_type,
typename _Rx_traits>
void
regex_token_iterator<_Bi_iter, _Ch_type, _Rx_traits>::
_M_init(_Bi_iter __a, _Bi_iter __b)
{
_M_has_m1 = false;
for (auto __it : _M_subs)
if (__it == -1)
{
_M_has_m1 = true;
break;
}
if (_M_position != _Position())
_M_result = &_M_current_match();
else if (_M_has_m1)
{
_M_suffix.matched = true;
_M_suffix.first = __a;
_M_suffix.second = __b;
_M_result = &_M_suffix;
}
else
_M_result = nullptr;
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
c++/8/bits/codecvt.h 0000644 00000051451 15201526705 0010035 0 ustar 00 // Locale support (codecvt) -*- C++ -*-
// Copyright (C) 2000-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/codecvt.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{locale}
*/
//
// ISO C++ 14882: 22.2.1.5 Template class codecvt
//
// Written by Benjamin Kosnik <bkoz@redhat.com>
#ifndef _CODECVT_H
#define _CODECVT_H 1
#pragma GCC system_header
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/// Empty base class for codecvt facet [22.2.1.5].
class codecvt_base
{
public:
enum result
{
ok,
partial,
error,
noconv
};
};
/**
* @brief Common base for codecvt functions.
*
* This template class provides implementations of the public functions
* that forward to the protected virtual functions.
*
* This template also provides abstract stubs for the protected virtual
* functions.
*/
template<typename _InternT, typename _ExternT, typename _StateT>
class __codecvt_abstract_base
: public locale::facet, public codecvt_base
{
public:
// Types:
typedef codecvt_base::result result;
typedef _InternT intern_type;
typedef _ExternT extern_type;
typedef _StateT state_type;
// 22.2.1.5.1 codecvt members
/**
* @brief Convert from internal to external character set.
*
* Converts input string of intern_type to output string of
* extern_type. This is analogous to wcsrtombs. It does this by
* calling codecvt::do_out.
*
* The source and destination character sets are determined by the
* facet's locale, internal and external types.
*
* The characters in [from,from_end) are converted and written to
* [to,to_end). from_next and to_next are set to point to the
* character following the last successfully converted character,
* respectively. If the result needed no conversion, from_next and
* to_next are not affected.
*
* The @a state argument should be initialized if the input is at the
* beginning and carried from a previous call if continuing
* conversion. There are no guarantees about how @a state is used.
*
* The result returned is a member of codecvt_base::result. If
* all the input is converted, returns codecvt_base::ok. If no
* conversion is necessary, returns codecvt_base::noconv. If
* the input ends early or there is insufficient space in the
* output, returns codecvt_base::partial. Otherwise the
* conversion failed and codecvt_base::error is returned.
*
* @param __state Persistent conversion state data.
* @param __from Start of input.
* @param __from_end End of input.
* @param __from_next Returns start of unconverted data.
* @param __to Start of output buffer.
* @param __to_end End of output buffer.
* @param __to_next Returns start of unused output area.
* @return codecvt_base::result.
*/
result
out(state_type& __state, const intern_type* __from,
const intern_type* __from_end, const intern_type*& __from_next,
extern_type* __to, extern_type* __to_end,
extern_type*& __to_next) const
{
return this->do_out(__state, __from, __from_end, __from_next,
__to, __to_end, __to_next);
}
/**
* @brief Reset conversion state.
*
* Writes characters to output that would restore @a state to initial
* conditions. The idea is that if a partial conversion occurs, then
* the converting the characters written by this function would leave
* the state in initial conditions, rather than partial conversion
* state. It does this by calling codecvt::do_unshift().
*
* For example, if 4 external characters always converted to 1 internal
* character, and input to in() had 6 external characters with state
* saved, this function would write two characters to the output and
* set the state to initialized conditions.
*
* The source and destination character sets are determined by the
* facet's locale, internal and external types.
*
* The result returned is a member of codecvt_base::result. If the
* state could be reset and data written, returns codecvt_base::ok. If
* no conversion is necessary, returns codecvt_base::noconv. If the
* output has insufficient space, returns codecvt_base::partial.
* Otherwise the reset failed and codecvt_base::error is returned.
*
* @param __state Persistent conversion state data.
* @param __to Start of output buffer.
* @param __to_end End of output buffer.
* @param __to_next Returns start of unused output area.
* @return codecvt_base::result.
*/
result
unshift(state_type& __state, extern_type* __to, extern_type* __to_end,
extern_type*& __to_next) const
{ return this->do_unshift(__state, __to,__to_end,__to_next); }
/**
* @brief Convert from external to internal character set.
*
* Converts input string of extern_type to output string of
* intern_type. This is analogous to mbsrtowcs. It does this by
* calling codecvt::do_in.
*
* The source and destination character sets are determined by the
* facet's locale, internal and external types.
*
* The characters in [from,from_end) are converted and written to
* [to,to_end). from_next and to_next are set to point to the
* character following the last successfully converted character,
* respectively. If the result needed no conversion, from_next and
* to_next are not affected.
*
* The @a state argument should be initialized if the input is at the
* beginning and carried from a previous call if continuing
* conversion. There are no guarantees about how @a state is used.
*
* The result returned is a member of codecvt_base::result. If
* all the input is converted, returns codecvt_base::ok. If no
* conversion is necessary, returns codecvt_base::noconv. If
* the input ends early or there is insufficient space in the
* output, returns codecvt_base::partial. Otherwise the
* conversion failed and codecvt_base::error is returned.
*
* @param __state Persistent conversion state data.
* @param __from Start of input.
* @param __from_end End of input.
* @param __from_next Returns start of unconverted data.
* @param __to Start of output buffer.
* @param __to_end End of output buffer.
* @param __to_next Returns start of unused output area.
* @return codecvt_base::result.
*/
result
in(state_type& __state, const extern_type* __from,
const extern_type* __from_end, const extern_type*& __from_next,
intern_type* __to, intern_type* __to_end,
intern_type*& __to_next) const
{
return this->do_in(__state, __from, __from_end, __from_next,
__to, __to_end, __to_next);
}
int
encoding() const throw()
{ return this->do_encoding(); }
bool
always_noconv() const throw()
{ return this->do_always_noconv(); }
int
length(state_type& __state, const extern_type* __from,
const extern_type* __end, size_t __max) const
{ return this->do_length(__state, __from, __end, __max); }
int
max_length() const throw()
{ return this->do_max_length(); }
protected:
explicit
__codecvt_abstract_base(size_t __refs = 0) : locale::facet(__refs) { }
virtual
~__codecvt_abstract_base() { }
/**
* @brief Convert from internal to external character set.
*
* Converts input string of intern_type to output string of
* extern_type. This function is a hook for derived classes to change
* the value returned. @see out for more information.
*/
virtual result
do_out(state_type& __state, const intern_type* __from,
const intern_type* __from_end, const intern_type*& __from_next,
extern_type* __to, extern_type* __to_end,
extern_type*& __to_next) const = 0;
virtual result
do_unshift(state_type& __state, extern_type* __to,
extern_type* __to_end, extern_type*& __to_next) const = 0;
virtual result
do_in(state_type& __state, const extern_type* __from,
const extern_type* __from_end, const extern_type*& __from_next,
intern_type* __to, intern_type* __to_end,
intern_type*& __to_next) const = 0;
virtual int
do_encoding() const throw() = 0;
virtual bool
do_always_noconv() const throw() = 0;
virtual int
do_length(state_type&, const extern_type* __from,
const extern_type* __end, size_t __max) const = 0;
virtual int
do_max_length() const throw() = 0;
};
/**
* @brief Primary class template codecvt.
* @ingroup locales
*
* NB: Generic, mostly useless implementation.
*
*/
template<typename _InternT, typename _ExternT, typename _StateT>
class codecvt
: public __codecvt_abstract_base<_InternT, _ExternT, _StateT>
{
public:
// Types:
typedef codecvt_base::result result;
typedef _InternT intern_type;
typedef _ExternT extern_type;
typedef _StateT state_type;
protected:
__c_locale _M_c_locale_codecvt;
public:
static locale::id id;
explicit
codecvt(size_t __refs = 0)
: __codecvt_abstract_base<_InternT, _ExternT, _StateT> (__refs),
_M_c_locale_codecvt(0)
{ }
explicit
codecvt(__c_locale __cloc, size_t __refs = 0);
protected:
virtual
~codecvt() { }
virtual result
do_out(state_type& __state, const intern_type* __from,
const intern_type* __from_end, const intern_type*& __from_next,
extern_type* __to, extern_type* __to_end,
extern_type*& __to_next) const;
virtual result
do_unshift(state_type& __state, extern_type* __to,
extern_type* __to_end, extern_type*& __to_next) const;
virtual result
do_in(state_type& __state, const extern_type* __from,
const extern_type* __from_end, const extern_type*& __from_next,
intern_type* __to, intern_type* __to_end,
intern_type*& __to_next) const;
virtual int
do_encoding() const throw();
virtual bool
do_always_noconv() const throw();
virtual int
do_length(state_type&, const extern_type* __from,
const extern_type* __end, size_t __max) const;
virtual int
do_max_length() const throw();
};
template<typename _InternT, typename _ExternT, typename _StateT>
locale::id codecvt<_InternT, _ExternT, _StateT>::id;
/// class codecvt<char, char, mbstate_t> specialization.
template<>
class codecvt<char, char, mbstate_t>
: public __codecvt_abstract_base<char, char, mbstate_t>
{
friend class messages<char>;
public:
// Types:
typedef char intern_type;
typedef char extern_type;
typedef mbstate_t state_type;
protected:
__c_locale _M_c_locale_codecvt;
public:
static locale::id id;
explicit
codecvt(size_t __refs = 0);
explicit
codecvt(__c_locale __cloc, size_t __refs = 0);
protected:
virtual
~codecvt();
virtual result
do_out(state_type& __state, const intern_type* __from,
const intern_type* __from_end, const intern_type*& __from_next,
extern_type* __to, extern_type* __to_end,
extern_type*& __to_next) const;
virtual result
do_unshift(state_type& __state, extern_type* __to,
extern_type* __to_end, extern_type*& __to_next) const;
virtual result
do_in(state_type& __state, const extern_type* __from,
const extern_type* __from_end, const extern_type*& __from_next,
intern_type* __to, intern_type* __to_end,
intern_type*& __to_next) const;
virtual int
do_encoding() const throw();
virtual bool
do_always_noconv() const throw();
virtual int
do_length(state_type&, const extern_type* __from,
const extern_type* __end, size_t __max) const;
virtual int
do_max_length() const throw();
};
#ifdef _GLIBCXX_USE_WCHAR_T
/** @brief Class codecvt<wchar_t, char, mbstate_t> specialization.
*
* Converts between narrow and wide characters in the native character set
*/
template<>
class codecvt<wchar_t, char, mbstate_t>
: public __codecvt_abstract_base<wchar_t, char, mbstate_t>
{
friend class messages<wchar_t>;
public:
// Types:
typedef wchar_t intern_type;
typedef char extern_type;
typedef mbstate_t state_type;
protected:
__c_locale _M_c_locale_codecvt;
public:
static locale::id id;
explicit
codecvt(size_t __refs = 0);
explicit
codecvt(__c_locale __cloc, size_t __refs = 0);
protected:
virtual
~codecvt();
virtual result
do_out(state_type& __state, const intern_type* __from,
const intern_type* __from_end, const intern_type*& __from_next,
extern_type* __to, extern_type* __to_end,
extern_type*& __to_next) const;
virtual result
do_unshift(state_type& __state,
extern_type* __to, extern_type* __to_end,
extern_type*& __to_next) const;
virtual result
do_in(state_type& __state,
const extern_type* __from, const extern_type* __from_end,
const extern_type*& __from_next,
intern_type* __to, intern_type* __to_end,
intern_type*& __to_next) const;
virtual
int do_encoding() const throw();
virtual
bool do_always_noconv() const throw();
virtual
int do_length(state_type&, const extern_type* __from,
const extern_type* __end, size_t __max) const;
virtual int
do_max_length() const throw();
};
#endif //_GLIBCXX_USE_WCHAR_T
#if __cplusplus >= 201103L
#ifdef _GLIBCXX_USE_C99_STDINT_TR1
/** @brief Class codecvt<char16_t, char, mbstate_t> specialization.
*
* Converts between UTF-16 and UTF-8.
*/
template<>
class codecvt<char16_t, char, mbstate_t>
: public __codecvt_abstract_base<char16_t, char, mbstate_t>
{
public:
// Types:
typedef char16_t intern_type;
typedef char extern_type;
typedef mbstate_t state_type;
public:
static locale::id id;
explicit
codecvt(size_t __refs = 0)
: __codecvt_abstract_base<char16_t, char, mbstate_t>(__refs) { }
protected:
virtual
~codecvt();
virtual result
do_out(state_type& __state, const intern_type* __from,
const intern_type* __from_end, const intern_type*& __from_next,
extern_type* __to, extern_type* __to_end,
extern_type*& __to_next) const;
virtual result
do_unshift(state_type& __state,
extern_type* __to, extern_type* __to_end,
extern_type*& __to_next) const;
virtual result
do_in(state_type& __state,
const extern_type* __from, const extern_type* __from_end,
const extern_type*& __from_next,
intern_type* __to, intern_type* __to_end,
intern_type*& __to_next) const;
virtual
int do_encoding() const throw();
virtual
bool do_always_noconv() const throw();
virtual
int do_length(state_type&, const extern_type* __from,
const extern_type* __end, size_t __max) const;
virtual int
do_max_length() const throw();
};
/** @brief Class codecvt<char32_t, char, mbstate_t> specialization.
*
* Converts between UTF-32 and UTF-8.
*/
template<>
class codecvt<char32_t, char, mbstate_t>
: public __codecvt_abstract_base<char32_t, char, mbstate_t>
{
public:
// Types:
typedef char32_t intern_type;
typedef char extern_type;
typedef mbstate_t state_type;
public:
static locale::id id;
explicit
codecvt(size_t __refs = 0)
: __codecvt_abstract_base<char32_t, char, mbstate_t>(__refs) { }
protected:
virtual
~codecvt();
virtual result
do_out(state_type& __state, const intern_type* __from,
const intern_type* __from_end, const intern_type*& __from_next,
extern_type* __to, extern_type* __to_end,
extern_type*& __to_next) const;
virtual result
do_unshift(state_type& __state,
extern_type* __to, extern_type* __to_end,
extern_type*& __to_next) const;
virtual result
do_in(state_type& __state,
const extern_type* __from, const extern_type* __from_end,
const extern_type*& __from_next,
intern_type* __to, intern_type* __to_end,
intern_type*& __to_next) const;
virtual
int do_encoding() const throw();
virtual
bool do_always_noconv() const throw();
virtual
int do_length(state_type&, const extern_type* __from,
const extern_type* __end, size_t __max) const;
virtual int
do_max_length() const throw();
};
#endif // _GLIBCXX_USE_C99_STDINT_TR1
#endif // C++11
/// class codecvt_byname [22.2.1.6].
template<typename _InternT, typename _ExternT, typename _StateT>
class codecvt_byname : public codecvt<_InternT, _ExternT, _StateT>
{
public:
explicit
codecvt_byname(const char* __s, size_t __refs = 0)
: codecvt<_InternT, _ExternT, _StateT>(__refs)
{
if (__builtin_strcmp(__s, "C") != 0
&& __builtin_strcmp(__s, "POSIX") != 0)
{
this->_S_destroy_c_locale(this->_M_c_locale_codecvt);
this->_S_create_c_locale(this->_M_c_locale_codecvt, __s);
}
}
#if __cplusplus >= 201103L
explicit
codecvt_byname(const string& __s, size_t __refs = 0)
: codecvt_byname(__s.c_str(), __refs) { }
#endif
protected:
virtual
~codecvt_byname() { }
};
#if __cplusplus >= 201103L && defined(_GLIBCXX_USE_C99_STDINT_TR1)
template<>
class codecvt_byname<char16_t, char, mbstate_t>
: public codecvt<char16_t, char, mbstate_t>
{
public:
explicit
codecvt_byname(const char*, size_t __refs = 0)
: codecvt<char16_t, char, mbstate_t>(__refs) { }
explicit
codecvt_byname(const string& __s, size_t __refs = 0)
: codecvt_byname(__s.c_str(), __refs) { }
protected:
virtual
~codecvt_byname() { }
};
template<>
class codecvt_byname<char32_t, char, mbstate_t>
: public codecvt<char32_t, char, mbstate_t>
{
public:
explicit
codecvt_byname(const char*, size_t __refs = 0)
: codecvt<char32_t, char, mbstate_t>(__refs) { }
explicit
codecvt_byname(const string& __s, size_t __refs = 0)
: codecvt_byname(__s.c_str(), __refs) { }
protected:
virtual
~codecvt_byname() { }
};
#endif
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
#if _GLIBCXX_EXTERN_TEMPLATE
extern template class codecvt_byname<char, char, mbstate_t>;
extern template
const codecvt<char, char, mbstate_t>&
use_facet<codecvt<char, char, mbstate_t> >(const locale&);
extern template
bool
has_facet<codecvt<char, char, mbstate_t> >(const locale&);
#ifdef _GLIBCXX_USE_WCHAR_T
extern template class codecvt_byname<wchar_t, char, mbstate_t>;
extern template
const codecvt<wchar_t, char, mbstate_t>&
use_facet<codecvt<wchar_t, char, mbstate_t> >(const locale&);
extern template
bool
has_facet<codecvt<wchar_t, char, mbstate_t> >(const locale&);
#endif
#if __cplusplus >= 201103L && defined(_GLIBCXX_USE_C99_STDINT_TR1)
extern template class codecvt_byname<char16_t, char, mbstate_t>;
extern template class codecvt_byname<char32_t, char, mbstate_t>;
#endif
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // _CODECVT_H
c++/8/bits/ostream.tcc 0000644 00000030033 15201526705 0010373 0 ustar 00 // ostream classes -*- C++ -*-
// Copyright (C) 1997-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/ostream.tcc
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{ostream}
*/
//
// ISO C++ 14882: 27.6.2 Output streams
//
#ifndef _OSTREAM_TCC
#define _OSTREAM_TCC 1
#pragma GCC system_header
#include <bits/cxxabi_forced.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>::sentry::
sentry(basic_ostream<_CharT, _Traits>& __os)
: _M_ok(false), _M_os(__os)
{
// XXX MT
if (__os.tie() && __os.good())
__os.tie()->flush();
if (__os.good())
_M_ok = true;
else
__os.setstate(ios_base::failbit);
}
template<typename _CharT, typename _Traits>
template<typename _ValueT>
basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::
_M_insert(_ValueT __v)
{
sentry __cerb(*this);
if (__cerb)
{
ios_base::iostate __err = ios_base::goodbit;
__try
{
const __num_put_type& __np = __check_facet(this->_M_num_put);
if (__np.put(*this, *this, this->fill(), __v).failed())
__err |= ios_base::badbit;
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
}
return *this;
}
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::
operator<<(short __n)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 117. basic_ostream uses nonexistent num_put member functions.
const ios_base::fmtflags __fmt = this->flags() & ios_base::basefield;
if (__fmt == ios_base::oct || __fmt == ios_base::hex)
return _M_insert(static_cast<long>(static_cast<unsigned short>(__n)));
else
return _M_insert(static_cast<long>(__n));
}
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::
operator<<(int __n)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 117. basic_ostream uses nonexistent num_put member functions.
const ios_base::fmtflags __fmt = this->flags() & ios_base::basefield;
if (__fmt == ios_base::oct || __fmt == ios_base::hex)
return _M_insert(static_cast<long>(static_cast<unsigned int>(__n)));
else
return _M_insert(static_cast<long>(__n));
}
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::
operator<<(__streambuf_type* __sbin)
{
ios_base::iostate __err = ios_base::goodbit;
sentry __cerb(*this);
if (__cerb && __sbin)
{
__try
{
if (!__copy_streambufs(__sbin, this->rdbuf()))
__err |= ios_base::failbit;
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::failbit); }
}
else if (!__sbin)
__err |= ios_base::badbit;
if (__err)
this->setstate(__err);
return *this;
}
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::
put(char_type __c)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 60. What is a formatted input function?
// basic_ostream::put(char_type) is an unformatted output function.
// DR 63. Exception-handling policy for unformatted output.
// Unformatted output functions should catch exceptions thrown
// from streambuf members.
sentry __cerb(*this);
if (__cerb)
{
ios_base::iostate __err = ios_base::goodbit;
__try
{
const int_type __put = this->rdbuf()->sputc(__c);
if (traits_type::eq_int_type(__put, traits_type::eof()))
__err |= ios_base::badbit;
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
}
return *this;
}
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::
write(const _CharT* __s, streamsize __n)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 60. What is a formatted input function?
// basic_ostream::write(const char_type*, streamsize) is an
// unformatted output function.
// DR 63. Exception-handling policy for unformatted output.
// Unformatted output functions should catch exceptions thrown
// from streambuf members.
sentry __cerb(*this);
if (__cerb)
{
__try
{ _M_write(__s, __n); }
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
}
return *this;
}
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::
flush()
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 60. What is a formatted input function?
// basic_ostream::flush() is *not* an unformatted output function.
ios_base::iostate __err = ios_base::goodbit;
__try
{
if (this->rdbuf() && this->rdbuf()->pubsync() == -1)
__err |= ios_base::badbit;
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
return *this;
}
template<typename _CharT, typename _Traits>
typename basic_ostream<_CharT, _Traits>::pos_type
basic_ostream<_CharT, _Traits>::
tellp()
{
pos_type __ret = pos_type(-1);
__try
{
if (!this->fail())
__ret = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out);
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
return __ret;
}
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::
seekp(pos_type __pos)
{
ios_base::iostate __err = ios_base::goodbit;
__try
{
if (!this->fail())
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 136. seekp, seekg setting wrong streams?
const pos_type __p = this->rdbuf()->pubseekpos(__pos,
ios_base::out);
// 129. Need error indication from seekp() and seekg()
if (__p == pos_type(off_type(-1)))
__err |= ios_base::failbit;
}
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
return *this;
}
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::
seekp(off_type __off, ios_base::seekdir __dir)
{
ios_base::iostate __err = ios_base::goodbit;
__try
{
if (!this->fail())
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 136. seekp, seekg setting wrong streams?
const pos_type __p = this->rdbuf()->pubseekoff(__off, __dir,
ios_base::out);
// 129. Need error indication from seekp() and seekg()
if (__p == pos_type(off_type(-1)))
__err |= ios_base::failbit;
}
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
return *this;
}
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s)
{
if (!__s)
__out.setstate(ios_base::badbit);
else
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 167. Improper use of traits_type::length()
const size_t __clen = char_traits<char>::length(__s);
__try
{
struct __ptr_guard
{
_CharT *__p;
__ptr_guard (_CharT *__ip): __p(__ip) { }
~__ptr_guard() { delete[] __p; }
_CharT* __get() { return __p; }
} __pg (new _CharT[__clen]);
_CharT *__ws = __pg.__get();
for (size_t __i = 0; __i < __clen; ++__i)
__ws[__i] = __out.widen(__s[__i]);
__ostream_insert(__out, __ws, __clen);
}
__catch(__cxxabiv1::__forced_unwind&)
{
__out._M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ __out._M_setstate(ios_base::badbit); }
}
return __out;
}
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
#if _GLIBCXX_EXTERN_TEMPLATE
extern template class basic_ostream<char>;
extern template ostream& endl(ostream&);
extern template ostream& ends(ostream&);
extern template ostream& flush(ostream&);
extern template ostream& operator<<(ostream&, char);
extern template ostream& operator<<(ostream&, unsigned char);
extern template ostream& operator<<(ostream&, signed char);
extern template ostream& operator<<(ostream&, const char*);
extern template ostream& operator<<(ostream&, const unsigned char*);
extern template ostream& operator<<(ostream&, const signed char*);
extern template ostream& ostream::_M_insert(long);
extern template ostream& ostream::_M_insert(unsigned long);
extern template ostream& ostream::_M_insert(bool);
#ifdef _GLIBCXX_USE_LONG_LONG
extern template ostream& ostream::_M_insert(long long);
extern template ostream& ostream::_M_insert(unsigned long long);
#endif
extern template ostream& ostream::_M_insert(double);
extern template ostream& ostream::_M_insert(long double);
extern template ostream& ostream::_M_insert(const void*);
#ifdef _GLIBCXX_USE_WCHAR_T
extern template class basic_ostream<wchar_t>;
extern template wostream& endl(wostream&);
extern template wostream& ends(wostream&);
extern template wostream& flush(wostream&);
extern template wostream& operator<<(wostream&, wchar_t);
extern template wostream& operator<<(wostream&, char);
extern template wostream& operator<<(wostream&, const wchar_t*);
extern template wostream& operator<<(wostream&, const char*);
extern template wostream& wostream::_M_insert(long);
extern template wostream& wostream::_M_insert(unsigned long);
extern template wostream& wostream::_M_insert(bool);
#ifdef _GLIBCXX_USE_LONG_LONG
extern template wostream& wostream::_M_insert(long long);
extern template wostream& wostream::_M_insert(unsigned long long);
#endif
extern template wostream& wostream::_M_insert(double);
extern template wostream& wostream::_M_insert(long double);
extern template wostream& wostream::_M_insert(const void*);
#endif
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif
c++/8/bits/fs_dir.h 0000644 00000034604 15201526705 0007655 0 ustar 00 // Filesystem directory utilities -*- C++ -*-
// Copyright (C) 2014-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/bits/fs_dir.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{filesystem}
*/
#ifndef _GLIBCXX_FS_DIR_H
#define _GLIBCXX_FS_DIR_H 1
#if __cplusplus >= 201703L
# include <typeinfo>
# include <ext/concurrence.h>
# include <bits/unique_ptr.h>
# include <bits/shared_ptr.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
namespace filesystem
{
/**
* @ingroup filesystem
* @{
*/
class file_status
{
public:
// constructors and destructor
file_status() noexcept : file_status(file_type::none) {}
explicit
file_status(file_type __ft, perms __prms = perms::unknown) noexcept
: _M_type(__ft), _M_perms(__prms) { }
file_status(const file_status&) noexcept = default;
file_status(file_status&&) noexcept = default;
~file_status() = default;
file_status& operator=(const file_status&) noexcept = default;
file_status& operator=(file_status&&) noexcept = default;
// observers
file_type type() const noexcept { return _M_type; }
perms permissions() const noexcept { return _M_perms; }
// modifiers
void type(file_type __ft) noexcept { _M_type = __ft; }
void permissions(perms __prms) noexcept { _M_perms = __prms; }
private:
file_type _M_type;
perms _M_perms;
};
_GLIBCXX_BEGIN_NAMESPACE_CXX11
struct _Dir;
class directory_iterator;
class recursive_directory_iterator;
class directory_entry
{
public:
// constructors and destructor
directory_entry() noexcept = default;
directory_entry(const directory_entry&) = default;
directory_entry(directory_entry&&) noexcept = default;
explicit
directory_entry(const filesystem::path& __p)
: _M_path(__p)
{ refresh(); }
directory_entry(const filesystem::path& __p, error_code& __ec)
: _M_path(__p)
{
refresh(__ec);
if (__ec)
_M_path.clear();
}
~directory_entry() = default;
// modifiers
directory_entry& operator=(const directory_entry&) = default;
directory_entry& operator=(directory_entry&&) noexcept = default;
void
assign(const filesystem::path& __p)
{
_M_path = __p;
refresh();
}
void
assign(const filesystem::path& __p, error_code& __ec)
{
_M_path = __p;
refresh(__ec);
}
void
replace_filename(const filesystem::path& __p)
{
_M_path.replace_filename(__p);
refresh();
}
void
replace_filename(const filesystem::path& __p, error_code& __ec)
{
_M_path.replace_filename(__p);
refresh(__ec);
}
void
refresh()
{ _M_type = symlink_status().type(); }
void
refresh(error_code& __ec) noexcept
{ _M_type = symlink_status(__ec).type(); }
// observers
const filesystem::path& path() const noexcept { return _M_path; }
operator const filesystem::path& () const noexcept { return _M_path; }
bool
exists() const
{ return filesystem::exists(file_status{_M_file_type()}); }
bool
exists(error_code& __ec) const noexcept
{ return filesystem::exists(file_status{_M_file_type(__ec)}); }
bool
is_block_file() const
{ return _M_file_type() == file_type::block; }
bool
is_block_file(error_code& __ec) const noexcept
{ return _M_file_type(__ec) == file_type::block; }
bool
is_character_file() const
{ return _M_file_type() == file_type::character; }
bool
is_character_file(error_code& __ec) const noexcept
{ return _M_file_type(__ec) == file_type::character; }
bool
is_directory() const
{ return _M_file_type() == file_type::directory; }
bool
is_directory(error_code& __ec) const noexcept
{ return _M_file_type(__ec) == file_type::directory; }
bool
is_fifo() const
{ return _M_file_type() == file_type::fifo; }
bool
is_fifo(error_code& __ec) const noexcept
{ return _M_file_type(__ec) == file_type::fifo; }
bool
is_other() const
{ return filesystem::is_other(file_status{_M_file_type()}); }
bool
is_other(error_code& __ec) const noexcept
{ return filesystem::is_other(file_status{_M_file_type(__ec)}); }
bool
is_regular_file() const
{ return _M_file_type() == file_type::regular; }
bool
is_regular_file(error_code& __ec) const noexcept
{ return _M_file_type(__ec) == file_type::regular; }
bool
is_socket() const
{ return _M_file_type() == file_type::socket; }
bool
is_socket(error_code& __ec) const noexcept
{ return _M_file_type(__ec) == file_type::socket; }
bool
is_symlink() const
{
if (_M_type != file_type::none)
return _M_type == file_type::symlink;
return symlink_status().type() == file_type::symlink;
}
bool
is_symlink(error_code& __ec) const noexcept
{
if (_M_type != file_type::none)
return _M_type == file_type::symlink;
return symlink_status(__ec).type() == file_type::symlink;
}
uintmax_t
file_size() const
{ return filesystem::file_size(_M_path); }
uintmax_t
file_size(error_code& __ec) const noexcept
{ return filesystem::file_size(_M_path, __ec); }
uintmax_t
hard_link_count() const
{ return filesystem::hard_link_count(_M_path); }
uintmax_t
hard_link_count(error_code& __ec) const noexcept
{ return filesystem::hard_link_count(_M_path, __ec); }
file_time_type
last_write_time() const
{ return filesystem::last_write_time(_M_path); }
file_time_type
last_write_time(error_code& __ec) const noexcept
{ return filesystem::last_write_time(_M_path, __ec); }
file_status
status() const
{ return filesystem::status(_M_path); }
file_status
status(error_code& __ec) const noexcept
{ return filesystem::status(_M_path, __ec); }
file_status
symlink_status() const
{ return filesystem::symlink_status(_M_path); }
file_status
symlink_status(error_code& __ec) const noexcept
{ return filesystem::symlink_status(_M_path, __ec); }
bool
operator< (const directory_entry& __rhs) const noexcept
{ return _M_path < __rhs._M_path; }
bool
operator==(const directory_entry& __rhs) const noexcept
{ return _M_path == __rhs._M_path; }
bool
operator!=(const directory_entry& __rhs) const noexcept
{ return _M_path != __rhs._M_path; }
bool
operator<=(const directory_entry& __rhs) const noexcept
{ return _M_path <= __rhs._M_path; }
bool
operator> (const directory_entry& __rhs) const noexcept
{ return _M_path > __rhs._M_path; }
bool
operator>=(const directory_entry& __rhs) const noexcept
{ return _M_path >= __rhs._M_path; }
private:
friend class _Dir;
friend class directory_iterator;
friend class recursive_directory_iterator;
directory_entry(const filesystem::path& __p, file_type __t)
: _M_path(__p), _M_type(__t)
{ }
// Equivalent to status().type() but uses cached value, if any.
file_type
_M_file_type() const
{
if (_M_type != file_type::none && _M_type != file_type::symlink)
return _M_type;
return status().type();
}
// Equivalent to status(__ec).type() but uses cached value, if any.
file_type
_M_file_type(error_code& __ec) const noexcept
{
if (_M_type != file_type::none && _M_type != file_type::symlink)
{
__ec.clear();
return _M_type;
}
return status(__ec).type();
}
filesystem::path _M_path;
file_type _M_type = file_type::none;
};
struct __directory_iterator_proxy
{
const directory_entry& operator*() const& noexcept { return _M_entry; }
directory_entry operator*() && noexcept { return std::move(_M_entry); }
private:
friend class directory_iterator;
friend class recursive_directory_iterator;
explicit
__directory_iterator_proxy(const directory_entry& __e) : _M_entry(__e) { }
directory_entry _M_entry;
};
class directory_iterator
{
public:
typedef directory_entry value_type;
typedef ptrdiff_t difference_type;
typedef const directory_entry* pointer;
typedef const directory_entry& reference;
typedef input_iterator_tag iterator_category;
directory_iterator() = default;
explicit
directory_iterator(const path& __p)
: directory_iterator(__p, directory_options::none, nullptr) { }
directory_iterator(const path& __p, directory_options __options)
: directory_iterator(__p, __options, nullptr) { }
directory_iterator(const path& __p, error_code& __ec)
: directory_iterator(__p, directory_options::none, __ec) { }
directory_iterator(const path& __p, directory_options __options,
error_code& __ec)
: directory_iterator(__p, __options, &__ec) { }
directory_iterator(const directory_iterator& __rhs) = default;
directory_iterator(directory_iterator&& __rhs) noexcept = default;
~directory_iterator() = default;
directory_iterator&
operator=(const directory_iterator& __rhs) = default;
directory_iterator&
operator=(directory_iterator&& __rhs) noexcept = default;
const directory_entry& operator*() const;
const directory_entry* operator->() const { return &**this; }
directory_iterator& operator++();
directory_iterator& increment(error_code& __ec);
__directory_iterator_proxy operator++(int)
{
__directory_iterator_proxy __pr{**this};
++*this;
return __pr;
}
private:
directory_iterator(const path&, directory_options, error_code*);
friend bool
operator==(const directory_iterator& __lhs,
const directory_iterator& __rhs);
friend class recursive_directory_iterator;
std::shared_ptr<_Dir> _M_dir;
};
inline directory_iterator
begin(directory_iterator __iter) noexcept
{ return __iter; }
inline directory_iterator
end(directory_iterator) noexcept
{ return directory_iterator(); }
inline bool
operator==(const directory_iterator& __lhs, const directory_iterator& __rhs)
{
return !__rhs._M_dir.owner_before(__lhs._M_dir)
&& !__lhs._M_dir.owner_before(__rhs._M_dir);
}
inline bool
operator!=(const directory_iterator& __lhs, const directory_iterator& __rhs)
{ return !(__lhs == __rhs); }
class recursive_directory_iterator
{
public:
typedef directory_entry value_type;
typedef ptrdiff_t difference_type;
typedef const directory_entry* pointer;
typedef const directory_entry& reference;
typedef input_iterator_tag iterator_category;
recursive_directory_iterator() = default;
explicit
recursive_directory_iterator(const path& __p)
: recursive_directory_iterator(__p, directory_options::none, nullptr) { }
recursive_directory_iterator(const path& __p, directory_options __options)
: recursive_directory_iterator(__p, __options, nullptr) { }
recursive_directory_iterator(const path& __p, directory_options __options,
error_code& __ec)
: recursive_directory_iterator(__p, __options, &__ec) { }
recursive_directory_iterator(const path& __p, error_code& __ec)
: recursive_directory_iterator(__p, directory_options::none, &__ec) { }
recursive_directory_iterator(
const recursive_directory_iterator&) = default;
recursive_directory_iterator(recursive_directory_iterator&&) = default;
~recursive_directory_iterator();
// observers
directory_options options() const { return _M_options; }
int depth() const;
bool recursion_pending() const { return _M_pending; }
const directory_entry& operator*() const;
const directory_entry* operator->() const { return &**this; }
// modifiers
recursive_directory_iterator&
operator=(const recursive_directory_iterator& __rhs) noexcept;
recursive_directory_iterator&
operator=(recursive_directory_iterator&& __rhs) noexcept;
recursive_directory_iterator& operator++();
recursive_directory_iterator& increment(error_code& __ec);
__directory_iterator_proxy operator++(int)
{
__directory_iterator_proxy __pr{**this};
++*this;
return __pr;
}
void pop();
void pop(error_code&);
void disable_recursion_pending() { _M_pending = false; }
private:
recursive_directory_iterator(const path&, directory_options, error_code*);
friend bool
operator==(const recursive_directory_iterator& __lhs,
const recursive_directory_iterator& __rhs);
struct _Dir_stack;
std::shared_ptr<_Dir_stack> _M_dirs;
directory_options _M_options = {};
bool _M_pending = false;
};
inline recursive_directory_iterator
begin(recursive_directory_iterator __iter) noexcept
{ return __iter; }
inline recursive_directory_iterator
end(recursive_directory_iterator) noexcept
{ return recursive_directory_iterator(); }
inline bool
operator==(const recursive_directory_iterator& __lhs,
const recursive_directory_iterator& __rhs)
{
return !__rhs._M_dirs.owner_before(__lhs._M_dirs)
&& !__lhs._M_dirs.owner_before(__rhs._M_dirs);
}
inline bool
operator!=(const recursive_directory_iterator& __lhs,
const recursive_directory_iterator& __rhs)
{ return !(__lhs == __rhs); }
_GLIBCXX_END_NAMESPACE_CXX11
// @} group filesystem
} // namespace filesystem
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // C++17
#endif // _GLIBCXX_FS_DIR_H
c++/8/bits/concept_check.h 0000644 00000006537 15201526705 0011203 0 ustar 00 // Concept-checking control -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/concept_check.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{iterator}
*/
#ifndef _CONCEPT_CHECK_H
#define _CONCEPT_CHECK_H 1
#pragma GCC system_header
#include <bits/c++config.h>
// All places in libstdc++-v3 where these are used, or /might/ be used, or
// don't need to be used, or perhaps /should/ be used, are commented with
// "concept requirements" (and maybe some more text). So grep like crazy
// if you're looking for additional places to use these.
// Concept-checking code is off by default unless users turn it on via
// configure options or editing c++config.h.
// It is not supported for freestanding implementations.
#if !defined(_GLIBCXX_CONCEPT_CHECKS) || !_GLIBCXX_HOSTED
#define __glibcxx_function_requires(...)
#define __glibcxx_class_requires(_a,_b)
#define __glibcxx_class_requires2(_a,_b,_c)
#define __glibcxx_class_requires3(_a,_b,_c,_d)
#define __glibcxx_class_requires4(_a,_b,_c,_d,_e)
#else // the checks are on
#include <bits/boost_concept_check.h>
// Note that the obvious and elegant approach of
//
//#define glibcxx_function_requires(C) debug::function_requires< debug::C >()
//
// won't work due to concept templates with more than one parameter, e.g.,
// BinaryPredicateConcept. The preprocessor tries to split things up on
// the commas in the template argument list. We can't use an inner pair of
// parenthesis to hide the commas, because "debug::(Temp<Foo,Bar>)" isn't
// a valid instantiation pattern. Thus, we steal a feature from C99.
#define __glibcxx_function_requires(...) \
__gnu_cxx::__function_requires< __gnu_cxx::__VA_ARGS__ >();
#define __glibcxx_class_requires(_a,_C) \
_GLIBCXX_CLASS_REQUIRES(_a, __gnu_cxx, _C);
#define __glibcxx_class_requires2(_a,_b,_C) \
_GLIBCXX_CLASS_REQUIRES2(_a, _b, __gnu_cxx, _C);
#define __glibcxx_class_requires3(_a,_b,_c,_C) \
_GLIBCXX_CLASS_REQUIRES3(_a, _b, _c, __gnu_cxx, _C);
#define __glibcxx_class_requires4(_a,_b,_c,_d,_C) \
_GLIBCXX_CLASS_REQUIRES4(_a, _b, _c, _d, __gnu_cxx, _C);
#endif // enable/disable
#endif // _GLIBCXX_CONCEPT_CHECK
c++/8/bits/locale_classes.tcc 0000644 00000020267 15201526705 0011705 0 ustar 00 // Locale support -*- C++ -*-
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/locale_classes.tcc
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{locale}
*/
//
// ISO C++ 14882: 22.1 Locales
//
#ifndef _LOCALE_CLASSES_TCC
#define _LOCALE_CLASSES_TCC 1
#pragma GCC system_header
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Facet>
locale::
locale(const locale& __other, _Facet* __f)
{
_M_impl = new _Impl(*__other._M_impl, 1);
__try
{ _M_impl->_M_install_facet(&_Facet::id, __f); }
__catch(...)
{
_M_impl->_M_remove_reference();
__throw_exception_again;
}
delete [] _M_impl->_M_names[0];
_M_impl->_M_names[0] = 0; // Unnamed.
}
template<typename _Facet>
locale
locale::
combine(const locale& __other) const
{
_Impl* __tmp = new _Impl(*_M_impl, 1);
__try
{
__tmp->_M_replace_facet(__other._M_impl, &_Facet::id);
}
__catch(...)
{
__tmp->_M_remove_reference();
__throw_exception_again;
}
return locale(__tmp);
}
template<typename _CharT, typename _Traits, typename _Alloc>
bool
locale::
operator()(const basic_string<_CharT, _Traits, _Alloc>& __s1,
const basic_string<_CharT, _Traits, _Alloc>& __s2) const
{
typedef std::collate<_CharT> __collate_type;
const __collate_type& __collate = use_facet<__collate_type>(*this);
return (__collate.compare(__s1.data(), __s1.data() + __s1.length(),
__s2.data(), __s2.data() + __s2.length()) < 0);
}
/**
* @brief Test for the presence of a facet.
* @ingroup locales
*
* has_facet tests the locale argument for the presence of the facet type
* provided as the template parameter. Facets derived from the facet
* parameter will also return true.
*
* @tparam _Facet The facet type to test the presence of.
* @param __loc The locale to test.
* @return true if @p __loc contains a facet of type _Facet, else false.
*/
template<typename _Facet>
bool
has_facet(const locale& __loc) throw()
{
const size_t __i = _Facet::id._M_id();
const locale::facet** __facets = __loc._M_impl->_M_facets;
return (__i < __loc._M_impl->_M_facets_size
#if __cpp_rtti
&& dynamic_cast<const _Facet*>(__facets[__i]));
#else
&& static_cast<const _Facet*>(__facets[__i]));
#endif
}
/**
* @brief Return a facet.
* @ingroup locales
*
* use_facet looks for and returns a reference to a facet of type Facet
* where Facet is the template parameter. If has_facet(locale) is true,
* there is a suitable facet to return. It throws std::bad_cast if the
* locale doesn't contain a facet of type Facet.
*
* @tparam _Facet The facet type to access.
* @param __loc The locale to use.
* @return Reference to facet of type Facet.
* @throw std::bad_cast if @p __loc doesn't contain a facet of type _Facet.
*/
template<typename _Facet>
const _Facet&
use_facet(const locale& __loc)
{
const size_t __i = _Facet::id._M_id();
const locale::facet** __facets = __loc._M_impl->_M_facets;
if (__i >= __loc._M_impl->_M_facets_size || !__facets[__i])
__throw_bad_cast();
#if __cpp_rtti
return dynamic_cast<const _Facet&>(*__facets[__i]);
#else
return static_cast<const _Facet&>(*__facets[__i]);
#endif
}
// Generic version does nothing.
template<typename _CharT>
int
collate<_CharT>::_M_compare(const _CharT*, const _CharT*) const throw ()
{ return 0; }
// Generic version does nothing.
template<typename _CharT>
size_t
collate<_CharT>::_M_transform(_CharT*, const _CharT*, size_t) const throw ()
{ return 0; }
template<typename _CharT>
int
collate<_CharT>::
do_compare(const _CharT* __lo1, const _CharT* __hi1,
const _CharT* __lo2, const _CharT* __hi2) const
{
// strcoll assumes zero-terminated strings so we make a copy
// and then put a zero at the end.
const string_type __one(__lo1, __hi1);
const string_type __two(__lo2, __hi2);
const _CharT* __p = __one.c_str();
const _CharT* __pend = __one.data() + __one.length();
const _CharT* __q = __two.c_str();
const _CharT* __qend = __two.data() + __two.length();
// strcoll stops when it sees a nul character so we break
// the strings into zero-terminated substrings and pass those
// to strcoll.
for (;;)
{
const int __res = _M_compare(__p, __q);
if (__res)
return __res;
__p += char_traits<_CharT>::length(__p);
__q += char_traits<_CharT>::length(__q);
if (__p == __pend && __q == __qend)
return 0;
else if (__p == __pend)
return -1;
else if (__q == __qend)
return 1;
__p++;
__q++;
}
}
template<typename _CharT>
typename collate<_CharT>::string_type
collate<_CharT>::
do_transform(const _CharT* __lo, const _CharT* __hi) const
{
string_type __ret;
// strxfrm assumes zero-terminated strings so we make a copy
const string_type __str(__lo, __hi);
const _CharT* __p = __str.c_str();
const _CharT* __pend = __str.data() + __str.length();
size_t __len = (__hi - __lo) * 2;
_CharT* __c = new _CharT[__len];
__try
{
// strxfrm stops when it sees a nul character so we break
// the string into zero-terminated substrings and pass those
// to strxfrm.
for (;;)
{
// First try a buffer perhaps big enough.
size_t __res = _M_transform(__c, __p, __len);
// If the buffer was not large enough, try again with the
// correct size.
if (__res >= __len)
{
__len = __res + 1;
delete [] __c, __c = 0;
__c = new _CharT[__len];
__res = _M_transform(__c, __p, __len);
}
__ret.append(__c, __res);
__p += char_traits<_CharT>::length(__p);
if (__p == __pend)
break;
__p++;
__ret.push_back(_CharT());
}
}
__catch(...)
{
delete [] __c;
__throw_exception_again;
}
delete [] __c;
return __ret;
}
template<typename _CharT>
long
collate<_CharT>::
do_hash(const _CharT* __lo, const _CharT* __hi) const
{
unsigned long __val = 0;
for (; __lo < __hi; ++__lo)
__val =
*__lo + ((__val << 7)
| (__val >> (__gnu_cxx::__numeric_traits<unsigned long>::
__digits - 7)));
return static_cast<long>(__val);
}
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
#if _GLIBCXX_EXTERN_TEMPLATE
extern template class collate<char>;
extern template class collate_byname<char>;
extern template
const collate<char>&
use_facet<collate<char> >(const locale&);
extern template
bool
has_facet<collate<char> >(const locale&);
#ifdef _GLIBCXX_USE_WCHAR_T
extern template class collate<wchar_t>;
extern template class collate_byname<wchar_t>;
extern template
const collate<wchar_t>&
use_facet<collate<wchar_t> >(const locale&);
extern template
bool
has_facet<collate<wchar_t> >(const locale&);
#endif
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif
c++/8/bits/stl_relops.h 0000644 00000010762 15201526705 0010574 0 ustar 00 // std::rel_ops implementation -*- C++ -*-
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the, 2009 Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
* Copyright (c) 1996,1997
* Silicon Graphics
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is"