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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.70  
changed lines
  Added in v.71

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25