2013-10-20 12:39:31 +00:00
|
|
|
/*
|
|
|
|
* $Id$
|
|
|
|
*
|
2014-11-19 14:42:24 +00:00
|
|
|
Copyright (c) 2006-2014 Chung, Hyung-Hwan. All rights reserved.
|
2013-10-20 12:39:31 +00:00
|
|
|
|
2014-11-19 14:42:24 +00:00
|
|
|
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.
|
2013-10-20 12:39:31 +00:00
|
|
|
|
2014-11-19 14:42:24 +00:00
|
|
|
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.
|
2013-10-20 12:39:31 +00:00
|
|
|
*/
|
|
|
|
|
2016-04-29 03:55:42 +00:00
|
|
|
#ifndef _QSE_LIB_CMN_FMT_PRV_H_
|
|
|
|
#define _QSE_LIB_CMN_FMT_PRV_H_
|
2013-10-20 12:39:31 +00:00
|
|
|
|
|
|
|
#include <qse/cmn/fmt.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
2013-10-28 09:40:25 +00:00
|
|
|
typedef int (*qse_mfmtout_put_t) (
|
|
|
|
qse_mchar_t c,
|
|
|
|
void* ctx
|
|
|
|
);
|
|
|
|
|
|
|
|
/* convert a wide string to a multi-byte string */
|
|
|
|
typedef int (*qse_mfmtout_conv_t) (
|
|
|
|
const qse_wchar_t* wcs,
|
|
|
|
qse_size_t* wcslen,
|
|
|
|
qse_mchar_t* mbs,
|
|
|
|
qse_size_t* mbslen,
|
|
|
|
void* ctx
|
|
|
|
);
|
|
|
|
|
|
|
|
struct qse_mfmtout_t
|
|
|
|
{
|
|
|
|
qse_size_t count; /* out */
|
|
|
|
qse_size_t limit; /* in */
|
|
|
|
void* ctx; /* in */
|
|
|
|
qse_mfmtout_put_t put; /* in */
|
|
|
|
qse_mfmtout_conv_t conv; /* in */
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct qse_mfmtout_t qse_mfmtout_t;
|
|
|
|
|
|
|
|
typedef int (*qse_wfmtout_put_t) (
|
|
|
|
qse_wchar_t c,
|
|
|
|
void* ctx
|
|
|
|
);
|
|
|
|
|
|
|
|
/* convert a multi-byte string to a wide string */
|
|
|
|
typedef int (*qse_wfmtout_conv_t) (
|
|
|
|
const qse_mchar_t* mbs,
|
|
|
|
qse_size_t* mbslen,
|
|
|
|
qse_wchar_t* wcs,
|
|
|
|
qse_size_t* wcslen,
|
|
|
|
void* ctx
|
|
|
|
);
|
|
|
|
|
|
|
|
struct qse_wfmtout_t
|
|
|
|
{
|
|
|
|
qse_size_t count; /* out */
|
|
|
|
qse_size_t limit; /* in */
|
|
|
|
void* ctx; /* in */
|
|
|
|
qse_wfmtout_put_t put; /* in */
|
|
|
|
qse_wfmtout_conv_t conv; /* in */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct qse_wfmtout_t qse_wfmtout_t;
|
|
|
|
|
2014-11-14 02:44:20 +00:00
|
|
|
#if defined(__cplusplus)
|
2013-10-24 14:55:15 +00:00
|
|
|
extern "C" {
|
2013-10-20 12:39:31 +00:00
|
|
|
#endif
|
|
|
|
|
2016-04-28 14:33:10 +00:00
|
|
|
/* QSE_EXPORTed, but keep in it the private header for used by other libraries in QSE */
|
|
|
|
QSE_EXPORT int qse_mfmtout (
|
2013-10-20 12:39:31 +00:00
|
|
|
const qse_mchar_t* fmt,
|
2013-10-28 09:40:25 +00:00
|
|
|
qse_mfmtout_t* data,
|
2013-10-20 12:39:31 +00:00
|
|
|
va_list ap
|
|
|
|
);
|
|
|
|
|
2016-04-28 14:33:10 +00:00
|
|
|
QSE_EXPORT int qse_wfmtout (
|
2013-10-20 12:39:31 +00:00
|
|
|
const qse_wchar_t* fmt,
|
2013-10-28 09:40:25 +00:00
|
|
|
qse_wfmtout_t* data,
|
2013-10-20 12:39:31 +00:00
|
|
|
va_list ap
|
|
|
|
);
|
|
|
|
|
2013-10-24 14:55:15 +00:00
|
|
|
#if defined(QSE_CHAR_IS_MCHAR)
|
|
|
|
# define qse_fmtout(fmt,fo,ap) qse_mfmtout(fmt,fo,ap)
|
|
|
|
#else
|
|
|
|
# define qse_fmtout(fmt,fo,ap) qse_wfmtout(fmt,fo,ap)
|
|
|
|
#endif
|
|
|
|
|
2014-11-14 02:44:20 +00:00
|
|
|
#if defined(__cplusplus)
|
2013-10-20 12:39:31 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|