Menu

[b84aab]: / src / common / fmt.h  Maximize  Restore  History

Download this file

140 lines (126 with data), 2.7 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
// This file is part of SmallBASIC
//
// formating numbers and strings
//
// This program is distributed under the terms of the GPL v2.0 or later
// Download the GNU Public License (GPL) from www.gnu.org
//
// Copyright(C) 2000 Nicholas Christopoulos
#if !defined(_sb_fmt_h)
#define _sb_fmt_h
#include "common/sys.h"
#if defined(__cplusplus)
extern "C" {
#endif
/**
* @ingroup str
*
* Part of floating point to string (by using integers) algorithm
* where x any number 2^31 > x >= 0
*
* @param x is the number
* @param dest is the string buffer
*/
void fptoa(var_num_t x, char *dest) SEC(BLIB);
/**
* @ingroup str
*
* best float to string
*
* @param x is the number
* @param dest is the string buffer
*/
void bestfta(var_num_t x, char *dest) SEC(BLIB);
/**
* @ingroup str
*
* float to string (user, E mode)
*
* @param x is the number
* @param dest is the string buffer
*/
void expfta(var_num_t x, char *dest) SEC(BLIB);
/**
* @ingroup str
*
* format: format a number
*
* symbols:
@code
# = digit or space
0 = digit or zero
^ = exponential digit/format
. = decimal point
, = thousands
- = minus for negative
+ = sign of number
@endcode
*
* @param dest is the string buffer
* @param fmt_cnst is the format string
* @param x is the number
*/
void format_num(char *dest, const char *fmt_cnst, var_num_t x) SEC(BLIB);
/**
* @ingroup str
*
* format: format a string
*
* symbols:
@code
& the whole string
! the first char
\\ segment
@endcode
*
* @param dest is the string buffer
* @param fmt_cnst is the format string
* @param str is the source string
*/
void format_str(char *dest, const char *fmt_cnst, const char *str) SEC(BLIB);
/**
* @ingroup str
*
* creates the internal-format queue
*
* @note part of USING
*
* @param fmt_cnst is the format
*/
void build_format(const char *fmt_cnst) SEC(BLIB);
/**
* @ingroup str
*
* clears the internal-format queue
*
* @note part of USING
*/
void free_format(void) SEC(BLIB);
/**
* @ingroup str
*
* prints a number using the queued format
*
* @note part of USING
*
* @param x is the number
* @param output is the output-set-of-routines code (see PV_xxx macros)
* @param handle is the output handle (depented on output-code)
*/
void fmt_printN(var_num_t x, int output, int handle) SEC(BLIB);
/**
* @ingroup str
*
* prints a string using the queued format
*
* @note part of USING
*
* @param str is the string
* @param output is the output-set-of-routines code (see PV_xxx macros)
* @param handle is the output handle (depented on output-code)
*/
void fmt_printS(const char *str, int output, int handle) SEC(BLIB);
#if defined(__cplusplus)
}
#endif
#endif
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.