/[dtapublic]/projs/trunk/shared_source/c_datd/bstrfunc.h
ViewVC logotype

Contents of /projs/trunk/shared_source/c_datd/bstrfunc.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 71 - (show annotations) (download)
Sat Nov 5 11:07:06 2016 UTC (8 years, 1 month ago) by dashley
File MIME type: text/plain
File size: 6713 byte(s)
Set EOL properties appropriately to facilitate simultaneous Linux and Windows development.
1 //$Header$
2 //-------------------------------------------------------------------------------------------------
3 //This file is part of "David T. Ashley's Shared Source Code", a set of shared components
4 //integrated into many of David T. Ashley's projects.
5 //-------------------------------------------------------------------------------------------------
6 //This source code and any program in which it is compiled/used is provided under the MIT License,
7 //reproduced below.
8 //-------------------------------------------------------------------------------------------------
9 //Permission is hereby granted, free of charge, to any person obtaining a copy of
10 //this software and associated documentation files(the "Software"), to deal in the
11 //Software without restriction, including without limitation the rights to use,
12 //copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the
13 //Software, and to permit persons to whom the Software is furnished to do so,
14 //subject to the following conditions :
15 //
16 //The above copyright notice and this permission notice shall be included in all
17 //copies or substantial portions of the Software.
18 //
19 //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 //FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
22 //AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 //LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 //SOFTWARE.
26 //-------------------------------------------------------------------------------------------------
27 #ifndef BSTRFUNC_H_INCLUDED
28 #define BSTRFUNC_H_INCLUDED
29
30 #ifdef MODULE_BSTRFUNC
31 #define DECMOD_BSTRFUNC
32 #else
33 #define DECMOD_BSTRFUNC extern
34 #endif
35
36 DECMOD_BSTRFUNC void *BSTRFUNC_malloc( size_t size );
37 DECMOD_BSTRFUNC void *BSTRFUNC_calloc( size_t num, size_t size );
38 DECMOD_BSTRFUNC void *BSTRFUNC_realloc( void *memblock, size_t size );
39 DECMOD_BSTRFUNC void BSTRFUNC_free( void *memblock );
40
41 //Returns 1 if the passed string is a valid unsigned integer
42 //without commas, i.e. "0", or "23943284...". Returns 0
43 //if is not of that data type. The the only allowed representation
44 //for zero is a single "0" character. The string must be
45 //"pure", i.e. no whitespace or non-digit characters or else
46 //a value of 0 will be returned.
47 DECMOD_BSTRFUNC int BSTRFUNC_is_uint_wo_commas(const char *arg);
48
49 //Just like the function above, but requires commas, which must
50 //be appropriately placed. Generally, any unsigned integer will
51 //return TRUE on the function above or on this one, and both
52 //will return TRUE for a number of 3 or fewer digits.
53 DECMOD_BSTRFUNC int BSTRFUNC_is_uint_w_commas(const char *arg);
54
55 //Returns 1 if the passed string is a valid signed integer
56 //without commas, i.e. "0", or "-23943284...". Returns 0
57 //if is not of that data type. The the only allowed representation
58 //for zero is a single "0" character. The string must be
59 //"pure", i.e. no whitespace or non-digit characters or else
60 //a value of 0 will be returned.
61 DECMOD_BSTRFUNC int BSTRFUNC_is_sint_wo_commas(const char *arg);
62
63 //Just like the function above, but allows negative numbers with
64 //commas, which must be appropriately placed. Generally, any
65 //signed integer will return TRUE on the function above or on
66 //this one, and both will return TRUE for a number of 3 or
67 //fewer digits.
68 DECMOD_BSTRFUNC int BSTRFUNC_is_sint_w_commas(const char *arg);
69
70 //Parses a general number in scientific notation, looking
71 //for errors, and splits it into components.
72 //
73 // s
74 // The string to parse. May not be NULL.
75 // *failure
76 // Set to 0 if parsing success. At the present time,
77 // any non-zero value is failure, but this may be refined
78 // later with specific error codes. Code written at this
79 // time should just test against zero. The pointer to
80 // this variable ("failure") must not be NULL. All other
81 // pointers may be NULL if the caller does not want the
82 // information back. If there was a failure, no other
83 // information should be interpreted.
84 // *mant_sign
85 // Will be set to +, -, or N (N means that the sign was
86 // not specified--this should be interpreted as +,
87 // usually.
88 // *mant_bdp, *mant_bdp_len
89 // Digits of mantissa before decimal point. If there is
90 // a zero here, only one is allowed. Possibilities here
91 // are "", "0", or "NNN..NNN" where the leading digit is
92 // not zero.
93 // *mant_adp, *mant_adp_len
94 // Digits of mantissa after decimal point. There may
95 // be any number of leading zeros here.
96 // *exp_sign,
97 // +, -, or N as described for mantissa sign, above.
98 // *exp, *exp_len
99 // The exponent, if any. There may be any number of
100 // leading zeros.
101 DECMOD_BSTRFUNC
102 void BSTRFUNC_parse_gen_sci_not_num(const char *s,
103 int *failure,
104 char *mant_sign,
105 size_t *mant_bdp,
106 size_t *mant_bdp_len,
107 size_t *mant_adp,
108 size_t *mant_adp_len,
109 char *exp_sign,
110 size_t *exp,
111 size_t *exp_len);
112
113 //Reverses the order of characters in a string.
114 DECMOD_BSTRFUNC void BSTRFUNC_str_reverse(char *s);
115
116 //Adds commas into a string. Space must exist.
117 DECMOD_BSTRFUNC void BSTRFUNC_commanate(char *s);
118
119 //Removes commas from a string. Since the new string will be
120 //no longer than the old string, there are no worries about
121 //space allocation. The function is direct comma removal--
122 //it pays no attention to syntax.
123 DECMOD_BSTRFUNC void BSTRFUNC_decommanate(char *s);
124
125 //Tries to parse a string as a 32-bit unsigned integer.
126 //Supplies a return value, plus an error flag which is set
127 //TRUE if something went wrong.
128 DECMOD_BSTRFUNC
129 void BSTRFUNC_parse_str_to_uint32(const char *s,
130 unsigned int *rv,
131 int *error);
132
133 DECMOD_BSTRFUNC const char *BSTRFUNC_cvcinfo(void);
134 DECMOD_BSTRFUNC const char *BSTRFUNC_hvcinfo(void);
135 #define BSTRFUNC_H_VERSION ("$Header$")
136 #endif
137
138 //End of bstrfunc.h.

Properties

Name Value
svn:eol-style native
svn:keywords Header

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25