added QSE_FIO_TEMPORARY.

added qse_rand31()
fixed a minor bug in handling QSE_FMTINTMAX_ZEROLEAD
This commit is contained in:
2011-11-16 15:18:46 +00:00
parent e15fcd0c14
commit df28fde9ef
18 changed files with 645 additions and 302 deletions

View File

@ -113,4 +113,13 @@ void qse_qsort (
void* ctx
);
/**
* The qse_rand31() function implements Park-Miller's minimal standard
* 32 bit pseudo-random number generator.
*/
qse_uint32_t qse_rand31 (
qse_uint32_t seed
);
#endif

View File

@ -39,8 +39,12 @@ enum qse_fio_open_flag_t
/** treat the file name pointer as a handle pointer */
QSE_FIO_HANDLE = (1 << 3),
/** treate the file name pointer as a pointer to file name
* template to use when making a temporary file name */
QSE_FIO_TEMPORARY = (1 << 4),
/** don't close an I/O handle in qse_fio_fini() and qse_fio_close() */
QSE_FIO_NOCLOSE = (1 << 4),
QSE_FIO_NOCLOSE = (1 << 5),
/* normal open flags */
QSE_FIO_READ = (1 << 8),
@ -58,10 +62,11 @@ enum qse_fio_open_flag_t
/* for WIN32 only. harmless(no effect) when used on other platforms */
QSE_FIO_NOSHRD = (1 << 24),
QSE_FIO_NOSHWR = (1 << 25),
QSE_FIO_NOSHDL = (1 << 26),
/* hints to OS. harmless(no effect) when used on unsupported platforms */
QSE_FIO_RANDOM = (1 << 26), /* hint that access be random */
QSE_FIO_SEQUENTIAL = (1 << 27) /* hint that access is sequential */
QSE_FIO_RANDOM = (1 << 27), /* hint that access be random */
QSE_FIO_SEQUENTIAL = (1 << 28) /* hint that access is sequential */
};
enum qse_fio_std_t
@ -150,6 +155,16 @@ QSE_DEFINE_COMMON_FUNCTIONS (fio)
* The qse_fio_open() function opens a file.
* To open a file, you should set the flags with at least one of
* QSE_FIO_READ, QSE_FIO_WRITE, QSE_FIO_APPEND.
*
* If the #QSE_FIO_HANDLE flag is set, the @a path parameter is interpreted
* as a pointer to qse_fio_hnd_t.
*
* If the #QSE_FIO_TEMPORARY flag is set, the @a path parameter is
* interpreted as a path name template and an actual file name to open
* is internally generated using the template. The @a path parameter
* is filled with the last actual path name attempted when the function
* returns. So, you must not pass a constant string to the @a path
* parameter when #QSE_FIO_TEMPORARY is set.
*/
qse_fio_t* qse_fio_open (
qse_mmgr_t* mmgr,

View File

@ -67,6 +67,16 @@ enum qse_fmtintmax_flag_t
#define QSE_FMTINTMAX_FILLRIGHT QSE_FMTINTMAX_FILLRIGHT
#define QSE_FMTINTMAX_FILLCENTER QSE_FMTINTMAX_FILLCENTER
#define QSE_FMTUINTMAX_NOTRUNC QSE_FMTINTMAX_NOTRUNC
#define QSE_FMTUINTMAX_NONULL QSE_FMTINTMAX_NONULL
#define QSE_FMTUINTMAX_NOZERO QSE_FMTINTMAX_NOZERO
#define QSE_FMTUINTMAX_ZEROLEAD QSE_FMTINTMAX_ZEROLEAD
#define QSE_FMTUINTMAX_UPPERCASE QSE_FMTINTMAX_UPPERCASE
#define QSE_FMTUINTMAX_PLUSSIGN QSE_FMTINTMAX_PLUSSIGN
#define QSE_FMTUINTMAX_EMPTYSIGN QSE_FMTINTMAX_EMPTYSIGN
#define QSE_FMTUINTMAX_FILLRIGHT QSE_FMTINTMAX_FILLRIGHT
#define QSE_FMTUINTMAX_FILLCENTER QSE_FMTINTMAX_FILLCENTER
#define QSE_FMTINTMAXTOMBS_NOTRUNC QSE_FMTINTMAX_NOTRUNC
#define QSE_FMTINTMAXTOMBS_NONULL QSE_FMTINTMAX_NONULL
#define QSE_FMTINTMAXTOMBS_NOZERO QSE_FMTINTMAX_NOZERO
@ -77,6 +87,16 @@ enum qse_fmtintmax_flag_t
#define QSE_FMTINTMAXTOMBS_FILLRIGHT QSE_FMTINTMAX_FILLRIGHT
#define QSE_FMTINTMAXTOMBS_FILLCENTER QSE_FMTINTMAX_FILLCENTER
#define QSE_FMTUINTMAXTOMBS_NOTRUNC QSE_FMTINTMAX_NOTRUNC
#define QSE_FMTUINTMAXTOMBS_NONULL QSE_FMTINTMAX_NONULL
#define QSE_FMTUINTMAXTOMBS_NOZERO QSE_FMTINTMAX_NOZERO
#define QSE_FMTUINTMAXTOMBS_ZEROLEAD QSE_FMTINTMAX_ZEROLEAD
#define QSE_FMTUINTMAXTOMBS_UPPERCASE QSE_FMTINTMAX_UPPERCASE
#define QSE_FMTUINTMAXTOMBS_PLUSSIGN QSE_FMTINTMAX_PLUSSIGN
#define QSE_FMTUINTMAXTOMBS_EMPTYSIGN QSE_FMTINTMAX_EMPTYSIGN
#define QSE_FMTUINTMAXTOMBS_FILLRIGHT QSE_FMTINTMAX_FILLRIGHT
#define QSE_FMTUINTMAXTOMBS_FILLCENTER QSE_FMTINTMAX_FILLCENTER
#define QSE_FMTINTMAXTOWCS_NOTRUNC QSE_FMTINTMAX_NOTRUNC
#define QSE_FMTINTMAXTOWCS_NONULL QSE_FMTINTMAX_NONULL
#define QSE_FMTINTMAXTOWCS_NOZERO QSE_FMTINTMAX_NOZERO
@ -87,6 +107,16 @@ enum qse_fmtintmax_flag_t
#define QSE_FMTINTMAXTOWCS_FILLRIGHT QSE_FMTINTMAX_FILLRIGHT
#define QSE_FMTINTMAXTOWCS_FILLCENTER QSE_FMTINTMAX_FILLCENTER
#define QSE_FMTUINTMAXTOWCS_NOTRUNC QSE_FMTINTMAX_NOTRUNC
#define QSE_FMTUINTMAXTOWCS_NONULL QSE_FMTINTMAX_NONULL
#define QSE_FMTUINTMAXTOWCS_NOZERO QSE_FMTINTMAX_NOZERO
#define QSE_FMTUINTMAXTOWCS_ZEROLEAD QSE_FMTINTMAX_ZEROLEAD
#define QSE_FMTUINTMAXTOWCS_UPPERCASE QSE_FMTINTMAX_UPPERCASE
#define QSE_FMTUINTMAXTOWCS_PLUSSIGN QSE_FMTINTMAX_PLUSSIGN
#define QSE_FMTUINTMAXTOWCS_EMPTYSIGN QSE_FMTINTMAX_EMPTYSIGN
#define QSE_FMTUINTMAXTOWCS_FILLRIGHT QSE_FMTINTMAX_FILLRIGHT
#define QSE_FMTUINTMAXTOWCS_FILLCENTER QSE_FMTINTMAX_FILLCENTER
#ifdef __cplusplus
extern "C" {
#endif
@ -111,6 +141,12 @@ extern "C" {
* - If neither #QSE_FMTINTMAXTOMBS_FILLRIGHT nor #QSE_FMTINTMAXTOMBS_FILLCENTER
* , slots before the formatting string are filled.
*
* The @a precision parameter specified the minimum number of digits to
* produce from the @ value. If @a value produces fewer digits than
* @a precision, the actual digits are padded with '0' to meet the precision
* requirement. You can pass a negative number if you don't wish to specify
* precision.
*
* The terminating null is not added if #QSE_FMTINTMAXTOMBS_NONULL is set;
* The #QSE_FMTINTMAXTOMBS_UPPERCASE flag indicates that the function should
* use the uppercase letter for a alphabetic digit;
@ -118,6 +154,11 @@ extern "C" {
* The #QSE_FMTINTMAXTOMBS_PLUSSIGN flag and #QSE_FMTINTMAXTOMBS_EMPTYSIGN
* ensures that the plus sign and a space is added for a positive integer
* including 0 respectively.
* The #QSE_FMTINTMAXTOMBS_ZEROLEAD flag ensures that the numeric string
* begins with '0' before applying the prefix.
* You can set the #QSE_FMTINTMAXTOMBS_NOZERO flag if you want the value of
* 0 to produce nothing. If both #QSE_FMTINTMAXTOMBS_NOZERO and
* #QSE_FMTINTMAXTOMBS_ZEROLEAD are specified, '0' is still produced.
*
* If @a prefix is not #QSE_NULL, it is inserted before the digits.
*
@ -159,6 +200,12 @@ int qse_fmtintmaxtombs (
* are filled.
* - If neither #QSE_FMTINTMAXTOWCS_FILLRIGHT nor #QSE_FMTINTMAXTOWCS_FILLCENTER
* , slots before the formatting string are filled.
*
* The @a precision parameter specified the minimum number of digits to
* produce from the @ value. If @a value produces fewer digits than
* @a precision, the actual digits are padded with '0' to meet the precision
* requirement. You can pass a negative number if don't wish to specify
* precision.
*
* The terminating null is not added if #QSE_FMTINTMAXTOWCS_NONULL is set;
* The #QSE_FMTINTMAXTOWCS_UPPERCASE flag indicates that the function should
@ -167,6 +214,11 @@ int qse_fmtintmaxtombs (
* The #QSE_FMTINTMAXTOWCS_PLUSSIGN flag and #QSE_FMTINTMAXTOWCS_EMPTYSIGN
* ensures that the plus sign and a space is added for a positive integer
* including 0 respectively.
* The #QSE_FMTINTMAXTOWCS_ZEROLEAD flag ensures that the numeric string
* begins with 0 before applying the prefix.
* You can set the #QSE_FMTINTMAXTOWCS_NOZERO flag if you want the value of
* 0 to produce nothing. If both #QSE_FMTINTMAXTOWCS_NOZERO and
* #QSE_FMTINTMAXTOWCS_ZEROLEAD are specified, '0' is still produced.
*
* If @a prefix is not #QSE_NULL, it is inserted before the digits.
*

View File

@ -33,8 +33,10 @@
enum qse_sio_open_flag_t
{
QSE_SIO_HANDLE = QSE_FIO_HANDLE,
QSE_SIO_NOCLOSE = QSE_FIO_NOCLOSE,
QSE_SIO_TEMPORARY = QSE_FIO_TEMPORARY,
QSE_SIO_IGNOREMBWCERR = QSE_FIO_IGNOREMBWCERR,
QSE_SIO_NOCLOSE = QSE_FIO_NOCLOSE,
QSE_SIO_READ = QSE_FIO_READ,
QSE_SIO_WRITE = QSE_FIO_WRITE,
@ -48,6 +50,7 @@ enum qse_sio_open_flag_t
QSE_SIO_NOSHRD = QSE_FIO_NOSHRD,
QSE_SIO_NOSHWR = QSE_FIO_NOSHWR,
QSE_SIO_NOSHDL = QSE_FIO_NOSHDL,
QSE_SIO_RANDOM = QSE_FIO_RANDOM,
QSE_SIO_SEQUENTIAL = QSE_FIO_SEQUENTIAL