some more code cleanup
This commit is contained in:
@ -27,14 +27,14 @@
|
||||
#ifndef _HCL_FMT_H_
|
||||
#define _HCL_FMT_H_
|
||||
|
||||
#include "hcl-cmn.h"
|
||||
#include <hcl-cmn.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
/** \file
|
||||
* This file defines various formatting functions.
|
||||
*/
|
||||
|
||||
/**
|
||||
/**
|
||||
* The hcl_fmt_intmax_flag_t type defines enumerators to change the
|
||||
* behavior of hcl_fmt_intmax() and hcl_fmt_uintmax().
|
||||
*/
|
||||
@ -163,7 +163,7 @@ typedef int (*hcl_fmtout_putobj_t) (
|
||||
hcl_oop_t obj
|
||||
);
|
||||
|
||||
enum hcl_fmtout_fmt_type_t
|
||||
enum hcl_fmtout_fmt_type_t
|
||||
{
|
||||
HCL_FMTOUT_FMT_TYPE_BCH = 0,
|
||||
HCL_FMTOUT_FMT_TYPE_UCH
|
||||
@ -193,22 +193,22 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The hcl_fmt_intmax_to_bcstr() function formats an integer \a value to a
|
||||
* multibyte string according to the given base and writes it to a buffer
|
||||
* pointed to by \a buf. It writes to the buffer at most \a size characters
|
||||
* including the terminating null. The base must be between 2 and 36 inclusive
|
||||
* and can be ORed with zero or more #hcl_fmt_intmax_to_bcstr_flag_t enumerators.
|
||||
* This ORed value is passed to the function via the \a base_and_flags
|
||||
* The hcl_fmt_intmax_to_bcstr() function formats an integer \a value to a
|
||||
* multibyte string according to the given base and writes it to a buffer
|
||||
* pointed to by \a buf. It writes to the buffer at most \a size characters
|
||||
* including the terminating null. The base must be between 2 and 36 inclusive
|
||||
* and can be ORed with zero or more #hcl_fmt_intmax_to_bcstr_flag_t enumerators.
|
||||
* This ORed value is passed to the function via the \a base_and_flags
|
||||
* parameter. If the formatted string is shorter than \a bufsize, the redundant
|
||||
* slots are filled with the fill character \a fillchar if it is not a null
|
||||
* slots are filled with the fill character \a fillchar if it is not a null
|
||||
* character. The filling behavior is determined by the flags shown below:
|
||||
*
|
||||
* - If #HCL_FMT_INTMAX_TO_BCSTR_FILLRIGHT is set in \a base_and_flags, slots
|
||||
* - If #HCL_FMT_INTMAX_TO_BCSTR_FILLRIGHT is set in \a base_and_flags, slots
|
||||
* after the formatting string are filled.
|
||||
* - If #HCL_FMT_INTMAX_TO_BCSTR_FILLCENTER is set in \a base_and_flags, slots
|
||||
* - If #HCL_FMT_INTMAX_TO_BCSTR_FILLCENTER is set in \a base_and_flags, slots
|
||||
* before the formatting string are filled. However, if it contains the
|
||||
* sign character, the slots between the sign character and the digit part
|
||||
* are filled.
|
||||
* are filled.
|
||||
* - If neither #HCL_FMT_INTMAX_TO_BCSTR_FILLRIGHT nor #HCL_FMT_INTMAX_TO_BCSTR_FILLCENTER
|
||||
* , slots before the formatting string are filled.
|
||||
*
|
||||
@ -220,26 +220,26 @@ extern "C" {
|
||||
*
|
||||
* The terminating null is not added if #HCL_FMT_INTMAX_TO_BCSTR_NONULL is set;
|
||||
* The #HCL_FMT_INTMAX_TO_BCSTR_UPPERCASE flag indicates that the function should
|
||||
* use the uppercase letter for a alphabetic digit;
|
||||
* use the uppercase letter for a alphabetic digit;
|
||||
* You can set #HCL_FMT_INTMAX_TO_BCSTR_NOTRUNC if you require lossless formatting.
|
||||
* The #HCL_FMT_INTMAX_TO_BCSTR_PLUSSIGN flag and #HCL_FMT_INTMAX_TO_BCSTR_EMPTYSIGN
|
||||
* ensures that the plus sign and a space is added for a positive integer
|
||||
* The #HCL_FMT_INTMAX_TO_BCSTR_PLUSSIGN flag and #HCL_FMT_INTMAX_TO_BCSTR_EMPTYSIGN
|
||||
* ensures that the plus sign and a space is added for a positive integer
|
||||
* including 0 respectively.
|
||||
* The #HCL_FMT_INTMAX_TO_BCSTR_ZEROLEAD flag ensures that the numeric string
|
||||
* begins with '0' before applying the prefix.
|
||||
* You can set the #HCL_FMT_INTMAX_TO_BCSTR_NOZERO flag if you want the value of
|
||||
* 0 to produce nothing. If both #HCL_FMT_INTMAX_TO_BCSTR_NOZERO and
|
||||
* 0 to produce nothing. If both #HCL_FMT_INTMAX_TO_BCSTR_NOZERO and
|
||||
* #HCL_FMT_INTMAX_TO_BCSTR_ZEROLEAD are specified, '0' is still produced.
|
||||
*
|
||||
*
|
||||
* If \a prefix is not #HCL_NULL, it is inserted before the digits.
|
||||
*
|
||||
*
|
||||
* \return
|
||||
* - -1 if the base is not between 2 and 36 inclusive.
|
||||
* - negated number of characters required for lossless formatting
|
||||
* - -1 if the base is not between 2 and 36 inclusive.
|
||||
* - negated number of characters required for lossless formatting
|
||||
* - if \a bufsize is 0.
|
||||
* - if #HCL_FMT_INTMAX_TO_BCSTR_NOTRUNC is set and \a bufsize is less than
|
||||
* the minimum required for lossless formatting.
|
||||
* - number of characters written to the buffer excluding a terminating
|
||||
* - number of characters written to the buffer excluding a terminating
|
||||
* null in all other cases.
|
||||
*/
|
||||
HCL_EXPORT int hcl_fmt_intmax_to_bcstr (
|
||||
@ -253,25 +253,25 @@ HCL_EXPORT int hcl_fmt_intmax_to_bcstr (
|
||||
);
|
||||
|
||||
/**
|
||||
* The hcl_fmt_intmax_to_ucstr() function formats an integer \a value to a
|
||||
* wide-character string according to the given base and writes it to a buffer
|
||||
* pointed to by \a buf. It writes to the buffer at most \a size characters
|
||||
* including the terminating null. The base must be between 2 and 36 inclusive
|
||||
* and can be ORed with zero or more #hcl_fmt_intmax_to_ucstr_flag_t enumerators.
|
||||
* This ORed value is passed to the function via the \a base_and_flags
|
||||
* The hcl_fmt_intmax_to_ucstr() function formats an integer \a value to a
|
||||
* wide-character string according to the given base and writes it to a buffer
|
||||
* pointed to by \a buf. It writes to the buffer at most \a size characters
|
||||
* including the terminating null. The base must be between 2 and 36 inclusive
|
||||
* and can be ORed with zero or more #hcl_fmt_intmax_to_ucstr_flag_t enumerators.
|
||||
* This ORed value is passed to the function via the \a base_and_flags
|
||||
* parameter. If the formatted string is shorter than \a bufsize, the redundant
|
||||
* slots are filled with the fill character \a fillchar if it is not a null
|
||||
* slots are filled with the fill character \a fillchar if it is not a null
|
||||
* character. The filling behavior is determined by the flags shown below:
|
||||
*
|
||||
* - If #HCL_FMT_INTMAX_TO_UCSTR_FILLRIGHT is set in \a base_and_flags, slots
|
||||
* - If #HCL_FMT_INTMAX_TO_UCSTR_FILLRIGHT is set in \a base_and_flags, slots
|
||||
* after the formatting string are filled.
|
||||
* - If #HCL_FMT_INTMAX_TO_UCSTR_FILLCENTER is set in \a base_and_flags, slots
|
||||
* - If #HCL_FMT_INTMAX_TO_UCSTR_FILLCENTER is set in \a base_and_flags, slots
|
||||
* before the formatting string are filled. However, if it contains the
|
||||
* sign character, the slots between the sign character and the digit part
|
||||
* are filled.
|
||||
* are filled.
|
||||
* - If neither #HCL_FMT_INTMAX_TO_UCSTR_FILLRIGHT nor #HCL_FMT_INTMAX_TO_UCSTR_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
|
||||
@ -280,26 +280,26 @@ HCL_EXPORT int hcl_fmt_intmax_to_bcstr (
|
||||
*
|
||||
* The terminating null is not added if #HCL_FMT_INTMAX_TO_UCSTR_NONULL is set;
|
||||
* The #HCL_FMT_INTMAX_TO_UCSTR_UPPERCASE flag indicates that the function should
|
||||
* use the uppercase letter for a alphabetic digit;
|
||||
* use the uppercase letter for a alphabetic digit;
|
||||
* You can set #HCL_FMT_INTMAX_TO_UCSTR_NOTRUNC if you require lossless formatting.
|
||||
* The #HCL_FMT_INTMAX_TO_UCSTR_PLUSSIGN flag and #HCL_FMT_INTMAX_TO_UCSTR_EMPTYSIGN
|
||||
* ensures that the plus sign and a space is added for a positive integer
|
||||
* The #HCL_FMT_INTMAX_TO_UCSTR_PLUSSIGN flag and #HCL_FMT_INTMAX_TO_UCSTR_EMPTYSIGN
|
||||
* ensures that the plus sign and a space is added for a positive integer
|
||||
* including 0 respectively.
|
||||
* The #HCL_FMT_INTMAX_TO_UCSTR_ZEROLEAD flag ensures that the numeric string
|
||||
* begins with 0 before applying the prefix.
|
||||
* You can set the #HCL_FMT_INTMAX_TO_UCSTR_NOZERO flag if you want the value of
|
||||
* 0 to produce nothing. If both #HCL_FMT_INTMAX_TO_UCSTR_NOZERO and
|
||||
* 0 to produce nothing. If both #HCL_FMT_INTMAX_TO_UCSTR_NOZERO and
|
||||
* #HCL_FMT_INTMAX_TO_UCSTR_ZEROLEAD are specified, '0' is still produced.
|
||||
*
|
||||
* If \a prefix is not #HCL_NULL, it is inserted before the digits.
|
||||
*
|
||||
*
|
||||
* \return
|
||||
* - -1 if the base is not between 2 and 36 inclusive.
|
||||
* - negated number of characters required for lossless formatting
|
||||
* - -1 if the base is not between 2 and 36 inclusive.
|
||||
* - negated number of characters required for lossless formatting
|
||||
* - if \a bufsize is 0.
|
||||
* - if #HCL_FMT_INTMAX_TO_UCSTR_NOTRUNC is set and \a bufsize is less than
|
||||
* the minimum required for lossless formatting.
|
||||
* - number of characters written to the buffer excluding a terminating
|
||||
* - number of characters written to the buffer excluding a terminating
|
||||
* null in all other cases.
|
||||
*/
|
||||
HCL_EXPORT int hcl_fmt_intmax_to_ucstr (
|
||||
@ -313,8 +313,8 @@ HCL_EXPORT int hcl_fmt_intmax_to_ucstr (
|
||||
);
|
||||
|
||||
/**
|
||||
* The hcl_fmt_uintmax_to_bcstr() function formats an unsigned integer \a value
|
||||
* to a multibyte string buffer. It behaves the same as hcl_fmt_intmax_to_bcstr()
|
||||
* The hcl_fmt_uintmax_to_bcstr() function formats an unsigned integer \a value
|
||||
* to a multibyte string buffer. It behaves the same as hcl_fmt_intmax_to_bcstr()
|
||||
* except that it handles an unsigned integer.
|
||||
*/
|
||||
HCL_EXPORT int hcl_fmt_uintmax_to_bcstr (
|
||||
@ -328,8 +328,8 @@ HCL_EXPORT int hcl_fmt_uintmax_to_bcstr (
|
||||
);
|
||||
|
||||
/**
|
||||
* The hcl_fmt_uintmax_to_ucstr() function formats an unsigned integer \a value
|
||||
* to a multibyte string buffer. It behaves the same as hcl_fmt_intmax_to_ucstr()
|
||||
* The hcl_fmt_uintmax_to_ucstr() function formats an unsigned integer \a value
|
||||
* to a multibyte string buffer. It behaves the same as hcl_fmt_intmax_to_ucstr()
|
||||
* except that it handles an unsigned integer.
|
||||
*/
|
||||
HCL_EXPORT int hcl_fmt_uintmax_to_ucstr (
|
||||
|
Reference in New Issue
Block a user