added missing include files

This commit is contained in:
hyung-hwan 2015-09-01 12:15:18 +00:00
parent 08c026c862
commit 693d1ac69f
2 changed files with 174 additions and 2 deletions

103
include/h2/cmn/utf16.h Normal file
View File

@ -0,0 +1,103 @@
/*
* $Id$
*
Copyright 2006-2014 Chung, Hyung-Hwan.
This file is part of H2.
H2 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 3 of
the License, or (at your option) any later version.
H2 is distributed in the hope that 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 H2. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _H2_CMN_UTF16_H_
#define _H2_CMN_UTF16_H_
#include <h2/types.h>
#include <h2/macros.h>
/** \file
* This file provides functions, types, macros for utf16 conversion.
*/
/**
* The H2_UTF16LEN_MAX macro defines the maximum number of qse_wchar_t
* needed to form a single unicode character.
*/
#define H2_UTF16LEN_MAX (H2_SIZEOF_WXCHAR_T / H2_SIZEOF_WCHAR_T)
#ifdef __cplusplus
extern "C" {
#endif
/**
* The h2_uctoutf16() function converts a unicode character to a utf16 sequence.
* \return
* - 0 is returned if \a uc is invalid.
* - An integer greater than \a size is returned if the \a utf16 sequence buffer
* is not #H2_NULL and not large enough. This integer is actually the number
* of bytes needed.
* - If \a utf16 is #H2_NULL, the number of bytes that would have been stored
* into \a utf16 if it had not been #H2_NULL is returned.
* - An integer between 1 and size inclusive is returned in all other cases.
* \note
* This function doesn't check invalid unicode code points and performs
* conversion compuationally.
*/
h2_size_t h2_uctoutf16 (
h2_wxchar_t uc,
h2_wchar_t* utf16,
h2_size_t size
);
/**
* The h2_utf16touc() function converts a utf16 sequence to a unicode character.
* \return
* - 0 is returned if the \a utf16 sequence is invalid.
* - An integer greater than \a size is returned if the \a utf16 sequence is
* not complete.
* - An integer between 1 and size inclusive is returned in all other cases.
*/
h2_size_t h2_utf16touc (
const h2_wchar_t* utf16,
h2_size_t size,
h2_wxchar_t* uc
);
/**
* The h2_utf16len() function scans at most \a size bytes from the \a utf16
* sequence and returns the number of bytes needed to form a single unicode
* character.
* \return
* - 0 is returned if the \a utf16 sequence is invalid.
* - An integer greater than \a size is returned if the \a utf16 sequence is
* not complete.
* - An integer between 1 and size inclusive is returned in all other cases.
*/
h2_size_t h2_utf16len (
const h2_wchar_t* utf16,
h2_size_t size
);
/**
* The h2_utf16lenmax() function returns the maximum number of qse_wchar_t
* needed to form a single unicode character. Use #H2_UTF16LEN_MAX if you
* need a compile-time constant.
*/
h2_size_t h2_utf16lenmax (
void
);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -600,20 +600,44 @@ enum h2_char_type_t
#endif
};
typedef enum h2_char_type_t h2_char_type_t;
typedef struct h2_cmgr_t h2_cmgr_t;
typedef h2_size_t (*h2_cmgr_mbtowc_t) (
h2_cmgr_t* cmgr,
const h2_mchar_t* mb,
h2_size_t size,
h2_wxchar_t* wc
);
typedef h2_size_t (*h2_cmgr_wctomb_t) (
h2_cmgr_t* cmgr,
h2_wxchar_t wc,
h2_mchar_t* mb,
h2_size_t size
);
/*
typedef h2_size_t (*h2_cmgr_mtowx_t) (
h2_cmgr_t* cmgr,
const h2_mchar_t* mb,
h2_size_t size,
h2_wxchar_t* wc
);
typedef h2_size_t (*h2_cmgr_wxtom_t) (
h2_cmgr_t* cmgr,
h2_wxchar_t wc,
h2_mchar_t* mb,
h2_size_t size
);
*/
/**
* The h2_cmgr_t type defines the character-level interface to
* multibyte/wide-character conversion. This interface doesn't
@ -625,11 +649,56 @@ struct h2_cmgr_t
{
h2_cmgr_mbtowc_t mbtowc;
h2_cmgr_wctomb_t wctomb;
/*
h2_cmgr_mtowx_t mtowx;
h2_cmgr_wxtom_t wxtom;
*/
void* ctx;
};
typedef struct h2_cmgr_t h2_cmgr_t;
/* Special definiton to use Unicode APIs on Windows */
typedef struct h2_mmgr_t h2_mmgr_t;
/**
* allocate a memory chunk of the size @a n.
* @return pointer to a memory chunk on success, QSE_NULL on failure.
*/
typedef void* (*h2_mmgr_alloc_t) (h2_mmgr_t* mmgr, h2_size_t n);
/**
* resize a memory chunk pointed to by @a ptr to the size @a n.
* @return pointer to a memory chunk on success, QSE_NULL on failure.
*/
typedef void* (*h2_mmgr_realloc_t) (h2_mmgr_t* mmgr, void* ptr, h2_size_t n);
/**
* free a memory chunk pointed to by @a ptr.
*/
typedef void (*h2_mmgr_free_t) (h2_mmgr_t* mmgr, void* ptr);
/**
* The h2_mmgr_t type defines the memory management interface.
* As the type is merely a structure, it is just used as a single container
* for memory management functions with a pointer to user-defined data.
* The user-defined data pointer @a ctx is passed to each memory management
* function whenever it is called. You can allocate, reallocate, and free
* a memory chunk.
*
* For example, a h2_xxx_open() function accepts a pointer of the h2_mmgr_t
* type and the xxx object uses it to manage dynamic data within the object.
*/
struct h2_mmgr_t
{
h2_mmgr_alloc_t alloc; /**< allocation function */
h2_mmgr_realloc_t realloc; /**< resizing function */
h2_mmgr_free_t free; /**< disposal function */
void* ctx; /**< user-defined data pointer */
};
/* Special definition to use Unicode APIs on Windows */
#if defined(_WIN32)
# if !defined(UNICODE)
# define UNICODE