libSBML C API  libSBML 5.20.4 C API
Loading...
Searching...
No Matches
util.cpp File Reference

Utility functions. More...

Include dependency graph for util.cpp:

Macros

#define __DBL_EPSILON__   DBL_EPSILON
 

Functions

int c_locale_snprintf (char *str, size_t size, const char *format,...)
 _tIdentical_t _tto_t _tsnprintf_t _texcept_t _tprinting_t _talways_t _toccurs_t _taccording_t _tto_t _tthe_t "_tC_t" _tlocale_t.
 
double c_locale_strtod (const char *nptr, char **endptr)
 _tIdentical_t _tto_t _tstrtod_t _texcept_t _tconversion_t _talways_t _toccurs_t _taccording_t _tto_t _tthe_t "_tC_t" _tlocale_t.
 
int c_locale_vsnprintf (char *str, size_t size, const char *format, va_list ap)
 _tIdentical_t _tto_t _tvsnprintf_t _texcept_t _tprinting_t _talways_t _toccurs_t _taccording_t _tto_t _tthe_t "_tC_t" _tlocale_t.
 
FILE * safe_fopen (const char *filename, const char *mode)
 _tAttempts_t _tto_t _topen_t _tfilename_t _tfor_t _tthe_t _tgiven_t _taccess_t _tmode_t _tand_t _treturn_t _ta_t _tpointer_t _tto_t _tit_t.
 
char * safe_strcat (const char *str1, const char *str2)
 _tReturns_t _ta_t _tpointer_t _tto_t _ta_t _tnew_t _tstring_t _twhich_t _tis_t _tthe_t _tconcatenation_t _tof_t _tthe_t _tstrings_t _tstr1_t _tand_t _tstr2_t.
 
char * safe_strdup (const char *s)
 @_treturn_t _ta_t _tpointer_t _tto_t _ta_t _tnew_t _tstring_t _twhich_t _tis_t _ta_t _tduplicate_t _tof_t _tthe_t _tstring_t _ts_t.
 
int strcmp_insensitive (const char *s1, const char *s2)
 _tCompares_t _ttwo_t _tstrings_t _ts1_t _tand_t _ts2_t, _tignoring_t _tthe_t _tcase_t _tof_t _tthe_t _tcharacters_t.
 
unsigned int streq (const char *s, const char *t)
 @_tcond_t _tdoxygenLibsbmlInternal_t
 
int util_bsearchStringsI (const char **strings, const char *s, int lo, int hi)
 _tPeforms_t _ta_t _tbinary_t _tsearch_t _ton_t _tthe_t _tstring_t _ttable_t _tstrings_t _tto_t _tfind_t _tstring_t _ts_t.
 
double util_epsilon ()
 @_treturn_t _tthe_t _tmachine_t _tepsilon_t
 
int util_file_exists (const char *filename)
 @_treturns_t @_tc_t _t1_t (_ttrue_t) _tif_t _tfilename_t _texists_t, @_tc_t _t0_t (_tfalse_t) _totherwise_t.
 
void util_free (void *element)
 _tFunction_t _tfor_t _tfreeing_t _tmemory_t _tallocated_t _tby_t _tlibSBML_t _tfunctions_t
 
void util_freeArray (void **objects, int length)
 _tFunction_t _tfor_t _tfreeing_t _tmemory_t _tallocated_t _tby_t _tlibSBML_t _tfunctions_t
 
int util_isEqual (double a, double b)
 @_treturn_t _t1_t _tif_t _tthe_t _tnumber_t _tare_t _tequal_t _tup_t _tto_t _tthe_t _tmachine_t _tepsilon_t _tand_t _t0_t _totherwise_t.
 
int util_isFinite (double d)
 @_treturn_t _t1_t _tif_t _tthe_t _tnumber_t _tis_t _tfinite_t _tand_t _t0_t _totherwise_t.
 
int util_isInf (double d)
 _tFunction_t _tfor_t _ttesting_t _twhether_t _ta_t _tgiven_t _tvalue_t _trepresents_t _tnegative_t _tinfinity_t.
 
int util_isNaN (double d)
 @_tcond_t _tdoxygenLibsbmlInternal_t
 
int util_isNegZero (double d)
 _tFunction_t _tfor_t _ttesting_t _twhether_t _ta_t _tgiven_t _tvalue_t _trepresents_t _tnegative_t _tzero_t.
 
double util_NaN (void)
 @_tendcond_t
 
double util_NegInf (void)
 _tReturns_t _ta_t _trepresentation_t _tof_t _tthe_t _tIEEE_t-_t754_t "_tNegative_t _tInfinity_t" _tvalue_t.
 
double util_NegZero (void)
 _tReturns_t _ta_t _trepresentation_t _tof_t _tthe_t _tIEEE_t-_t754_t "_tNegative_t _tZero_t" _tvalue_t.
 
double util_PosInf (void)
 _tReturns_t _ta_t _trepresentation_t _tof_t _tthe_t _tIEEE_t-_t754_t "_tPositive_t _tInfinity_t" _tvalue_t.
 
char * util_trim (const char *s)
 _tRemoves_t _tleading_t _tand_t _ttrailing_t _twhitespace_t _tfrom_t _tthe_t _tstring_t _ts_t.
 
char * util_trim_in_place (char *s)
 _tRemoves_t _tleading_t _tand_t _ttrailing_t _twhitespace_t _tfrom_t _tthe_t _tstring_t _ts_t.
 

Detailed Description

Utility functions.

Author
Ben Bornstein

Ths file implements a small number of utility functions that may be useful inside and outside of libSBML.

Macro Definition Documentation

◆ __DBL_EPSILON__

#define __DBL_EPSILON__   DBL_EPSILON

Function Documentation

◆ c_locale_snprintf()

int c_locale_snprintf ( char *  str,
size_t  size,
const char *  format,
  ... 
)

_tIdentical_t _tto_t _tsnprintf_t _texcept_t _tprinting_t _talways_t _toccurs_t _taccording_t _tto_t _tthe_t "_tC_t" _tlocale_t.

_tThis_t _tfunction_t _tdoes_t _tnot_t _taffect_t _tthe_t _tlocale_t _tof_t _tthe_t _tcalling_t _tprogram_t.

◆ c_locale_strtod()

double c_locale_strtod ( const char *  nptr,
char **  endptr 
)

_tIdentical_t _tto_t _tstrtod_t _texcept_t _tconversion_t _talways_t _toccurs_t _taccording_t _tto_t _tthe_t "_tC_t" _tlocale_t.

_tThis_t _tfunction_t _tdoes_t _tnot_t _taffect_t _tthe_t _tlocale_t _tof_t _tthe_t _tcalling_t _tprogram_t.

◆ c_locale_vsnprintf()

int c_locale_vsnprintf ( char *  str,
size_t  size,
const char *  format,
va_list  ap 
)

_tIdentical_t _tto_t _tvsnprintf_t _texcept_t _tprinting_t _talways_t _toccurs_t _taccording_t _tto_t _tthe_t "_tC_t" _tlocale_t.

_tThis_t _tfunction_t _tdoes_t _tnot_t _taffect_t _tthe_t _tlocale_t _tof_t _tthe_t _tcalling_t _tprogram_t.

◆ safe_fopen()

FILE * safe_fopen ( const char *  filename,
const char *  mode 
)

_tAttempts_t _tto_t _topen_t _tfilename_t _tfor_t _tthe_t _tgiven_t _taccess_t _tmode_t _tand_t _treturn_t _ta_t _tpointer_t _tto_t _tit_t.

_tIf_t _tthe_t _tfilename_t _tcould_t _tnot_t _tbe_t _topened_t, _tprints_t _tan_t _terror_t _tmessage_t _tand_t _texits_t.

◆ safe_strcat()

char * safe_strcat ( const char *  str1,
const char *  str2 
)

_tReturns_t _ta_t _tpointer_t _tto_t _ta_t _tnew_t _tstring_t _twhich_t _tis_t _tthe_t _tconcatenation_t _tof_t _tthe_t _tstrings_t _tstr1_t _tand_t _tstr2_t.

_tMemory_t _tfor_t _tthe_t _tnew_t _tstring_t _tis_t _tobtained_t _twith_t _tsafe_malloc_t() _tand_t _tcan_t _tbe_t _tfreed_t _twith_t _tsafe_free_t().

_tNOTE_t: _tThis_t _tstrcat_t _tbehaves_t _tdifferently_t _tthan_t _tstandard_t _tlibrary_t _tstrcat_t().

◆ safe_strdup()

char * safe_strdup ( const char *  s)

@_treturn_t _ta_t _tpointer_t _tto_t _ta_t _tnew_t _tstring_t _twhich_t _tis_t _ta_t _tduplicate_t _tof_t _tthe_t _tstring_t _ts_t.

_tMemory_t _tfor_t _tthe_t _tstring_t _tis_t _tobtained_t _twith_t _tsafe_malloc_t() _tand_t _tcan_t _tbe_t _tfreed_t _twith_t _tsafe_free_t().

◆ strcmp_insensitive()

int strcmp_insensitive ( const char *  s1,
const char *  s2 
)

_tCompares_t _ttwo_t _tstrings_t _ts1_t _tand_t _ts2_t, _tignoring_t _tthe_t _tcase_t _tof_t _tthe_t _tcharacters_t.

@_treturn_t _tan_t _tinteger_t _tless_t _tthan_t, _tequal_t _tto_t, _tor_t _tgreater_t _tthan_t _tzero_t _tif_t _ts1_t _tis_t _tfound_t, _trespectively_t, _tto_t _tbe_t _tless_t _tthan_t, _tto_t _tmatch_t, _tor_t _tbe_t _tgreater_t _tthan_t _ts2_t.

◆ streq()

unsigned int streq ( const char *  s,
const char *  t 
)

@_tcond_t _tdoxygenLibsbmlInternal_t

_tEasier_t-_tto_t-_tread_t _tand_t _tNULL_t-_tfriendly_t _tstring_t _tcomparison_t.

◆ util_bsearchStringsI()

int util_bsearchStringsI ( const char **  strings,
const char *  s,
int  lo,
int  hi 
)

_tPeforms_t _ta_t _tbinary_t _tsearch_t _ton_t _tthe_t _tstring_t _ttable_t _tstrings_t _tto_t _tfind_t _tstring_t _ts_t.

_tAll_t _tstrings_t _tfrom_t _tstrings_t[_tlo_t] _tto_t _tstrings_t[_thi_t] _tare_t _tsearched_t. _tThe_t _tstring_t _tcomparison_t _tfunction_t _tused_t _tis_t _tstrcmp_insensitive_t(). _tSince_t _tthe_t _tsearch_t _tis_t _tbinary_t, _tthe_t _tstrings_t _ttable_t _tmust_t _tbe_t _tsorted_t, _tirrespecitve_t _tof_t _tcase_t.

@_treturn_t _tthe_t _tindex_t _tof_t _ts_t _tin_t _tstrings_t, _tif_t _ts_t _twas_t _tfound_t, _tor_t _tstop_t + _t1_t _totherwise_t.

◆ util_epsilon()

double util_epsilon ( )

@_treturn_t _tthe_t _tmachine_t _tepsilon_t

◆ util_file_exists()

int util_file_exists ( const char *  filename)

@_treturns_t @_tc_t _t1_t (_ttrue_t) _tif_t _tfilename_t _texists_t, @_tc_t _t0_t (_tfalse_t) _totherwise_t.

◆ util_free()

void util_free ( void *  element)

_tFunction_t _tfor_t _tfreeing_t _tmemory_t _tallocated_t _tby_t _tlibSBML_t _tfunctions_t

@_tparam_t _telement_t _tpointer_t _tto_t _tthe_t _tobject_t _tto_t _tbe_t _tfreed_t. _tIt_t _tmust_t _tbe_t _tdata_t _tthat_t _twas_t _toriginally_t _tallocated_t _tby_t _ta_t _tlibSBML_t _tfunction_t.

_tThis_t _tfunction_t _twas_t _tintroduced_t _tto_t _tdeal_t _twith_t _ta_t _tspecific_t _tmemory_t _tissue_t _tarising_t _ton_t _tWindows_t _tOS_t _twhen_t _tusing_t _tlibSBML_t _tcompiled_t _tagainst_t _ta_t _tstatic_t _tMSVC_t _truntime_t _tlibrary_t. _tIn_t _tthis_t _tsituation_t, _tit_t _twas_t _tnot_t _tpossible_t _tto_t _tuse_t _tthe_t _tstandard_t <_tcode_t>_tfree_t()</_tcode_t> _tfunction_t _twhen_t _tfreeing_t _tmemory_t _tthat_t _twas_t _tactually_t _tallocated_t _twithin_t _tthe_t _tlibSBML_t _tfunction_t _tcall_t. _tThe_t _tfollowing_t _tis_t _tan_t _texample_t _tof_t _twhere_t _tthe_t _tfree_t _tfunction_t _tfails_t _tand_t _tneeds_t _tto_t _tbe_t _treplaced_t _twith_t _tutil_free_t(). @_tcode_t _tchar_t * _tformula_t = _tSBML_formulaToString_t(_tastNode_t); _tfree_t(_tformula_t); @_tendcode_t

@_tnote_t _tThis_t _tfunction_t _tis_t _tonly_t _tnecessary_t _twhen_t _tusing_t _ta_t _tversion_t _tof_t _tlibSBML_t _tcompiled_t _tand_t _tlinked_t _tagainst_t _ta_t _tstatic_t _tMSVC_t _truntime_t _tlibrary_t.

◆ util_freeArray()

void util_freeArray ( void **  objects,
int  length 
)

_tFunction_t _tfor_t _tfreeing_t _tmemory_t _tallocated_t _tby_t _tlibSBML_t _tfunctions_t

@_tparam_t _tobjects_t _tpointer_t _tto_t _tthe_t _tarray_t _tto_t _tbe_t _tfreed_t. _tIt_t _tmust_t _tbe_t _tdata_t _tthat_t _twas_t _toriginally_t _tallocated_t _tby_t _ta_t _tlibSBML_t _tfunction_t. @_tparam_t _tlength_t _tnumber_t _tof_t _telements_t _tin_t _tthe_t _tarray_t _tto_t _tbe_t _tfreed_t.

_tThis_t _tfunction_t _twas_t _tintroduced_t _tto_t _tdeal_t _twith_t _ta_t _tspecific_t _tmemory_t _tissue_t _tarising_t _ton_t _tWindows_t _tOS_t _twhen_t _tusing_t _tlibSBML_t _tcompiled_t _tagainst_t _ta_t _tstatic_t _tMSVC_t _truntime_t _tlibrary_t. _tIn_t _tthis_t _tsituation_t, _tit_t _twas_t _tnot_t _tpossible_t _tto_t _tuse_t _tthe_t _tstandard_t <_tcode_t>_tfree_t()</_tcode_t> _tfunction_t _twhen_t _tfreeing_t _tmemory_t _tthat_t _twas_t _tactually_t _tallocated_t _twithin_t _tthe_t _tlibSBML_t _tfunction_t _tcall_t. _tThe_t _tfollowing_t _tis_t _tan_t _texample_t _tof_t _twhere_t _tthe_t _tfree_t _tfunction_t _tfails_t _tand_t _tneeds_t _tto_t _tbe_t _treplaced_t _twith_t _tutil_freeArray_t(). @_tcode_t _tint_t _tlength_t; _tSBMLNamespaces_t_t** _tsupported_t = _tSBMLNamespaces_getSupportedNamespaces_t(&_tlength_t); _tfree_t(_tsupported_t); @_tendcode_t

@_tnote_t _tThis_t _tfunction_t _tis_t _tonly_t _tnecessary_t _twhen_t _tusing_t _ta_t _tversion_t _tof_t _tlibSBML_t _tcompiled_t _tand_t _tlinked_t _tagainst_t _ta_t _tstatic_t _tMSVC_t _truntime_t _tlibrary_t.

◆ util_isEqual()

int util_isEqual ( double  a,
double  b 
)

@_treturn_t _t1_t _tif_t _tthe_t _tnumber_t _tare_t _tequal_t _tup_t _tto_t _tthe_t _tmachine_t _tepsilon_t _tand_t _t0_t _totherwise_t.

◆ util_isFinite()

int util_isFinite ( double  d)

@_treturn_t _t1_t _tif_t _tthe_t _tnumber_t _tis_t _tfinite_t _tand_t _t0_t _totherwise_t.

◆ util_isInf()

int util_isInf ( double  d)

_tFunction_t _tfor_t _ttesting_t _twhether_t _ta_t _tgiven_t _tvalue_t _trepresents_t _tnegative_t _tinfinity_t.

@_tparam_t _td_t _tthe_t _tfloating_t-_tpoint_t _tvalue_t _tto_t _ttest_t.

@_treturn_t @_tc_t -_t1_t (_tfor_t _tfalse_t) _tif_t @_tp_t _td_t _trepresents_t _tnegative_t _tinfinity_t, @_tc_t _t1_t (_ttrue_t) _tif_t @_tp_t _td_t _trepresents_t _tpositive_t _tinfinity_t, _tand_t @_tc_t _t0_t (_tfalse_t) _totherwise_t.

◆ util_isNaN()

int util_isNaN ( double  d)

@_tcond_t _tdoxygenLibsbmlInternal_t

@_treturn_t _t1_t _tif_t _tthe_t _tnumber_t _tis_t _tNaN_t _tand_t _t0_t _totherwise_t.

◆ util_isNegZero()

int util_isNegZero ( double  d)

_tFunction_t _tfor_t _ttesting_t _twhether_t _ta_t _tgiven_t _tvalue_t _trepresents_t _tnegative_t _tzero_t.

@_tparam_t _td_t _tthe_t _tfloating_t-_tpoint_t _tvalue_t _tto_t _ttest_t.

@_treturn_t @_tc_t _t1_t (_ttrue_t) _tif_t @_tp_t _td_t _tis_t _tan_t _tIEEE_t-_t754_t _tnegative_t _tzero_t, @_tc_t _t0_t (_tfalse_t) _totherwise_t.

◆ util_NaN()

double util_NaN ( void  )

@_tendcond_t

_tReturns_t _ta_t _trepresentation_t _tof_t @_tc_t _tNaN_t.

@_treturn_t _ta_t (_tquiet_t) _tNaN_t.

◆ util_NegInf()

double util_NegInf ( void  )

_tReturns_t _ta_t _trepresentation_t _tof_t _tthe_t _tIEEE_t-_t754_t "_tNegative_t _tInfinity_t" _tvalue_t.

@_treturn_t _tIEEE_t-_t754_t _tNegative_t _tInfinity_t.

◆ util_NegZero()

double util_NegZero ( void  )

_tReturns_t _ta_t _trepresentation_t _tof_t _tthe_t _tIEEE_t-_t754_t "_tNegative_t _tZero_t" _tvalue_t.

@_treturn_t _tIEEE_t-_t754_t _tNegative_t _tZero_t.

◆ util_PosInf()

double util_PosInf ( void  )

_tReturns_t _ta_t _trepresentation_t _tof_t _tthe_t _tIEEE_t-_t754_t "_tPositive_t _tInfinity_t" _tvalue_t.

@_treturn_t _tIEEE_t-_t754_t _tPositive_t _tInfinity_t

◆ util_trim()

char * util_trim ( const char *  s)

_tRemoves_t _tleading_t _tand_t _ttrailing_t _twhitespace_t _tfrom_t _tthe_t _tstring_t _ts_t.

@_treturn_t _ta_t _tpointer_t _tto_t _ta_t _tnew_t _tstring_t _twhich_t _tis_t _ta_t _tduplicate_t _tof_t _tthe_t _tstring_t _ts_t, _twith_t _tleading_t _tand_t _ttrailing_t _twhitespace_t _tremoved_t _tor_t @_tc_t _tNULL_t _tif_t _ts_t _tis_t @_tc_t _tNULL_t.

_tWhitespace_t _tis_t _tdetermined_t _tby_t _tisspace_t().

◆ util_trim_in_place()

char * util_trim_in_place ( char *  s)

_tRemoves_t _tleading_t _tand_t _ttrailing_t _twhitespace_t _tfrom_t _tthe_t _tstring_t _ts_t.

@_treturn_t _ta_t _tpointer_t _tto_t _tthe_t _tfirst_t _tnon_t-_twhitespace_t _tcharacter_t _tof_t _tthe_t _tstring_t _ts_t (_twhich_t _tmay_t _tbe_t _tthe_t _tterminating_t _tNULL_t), _tor_t @_tc_t _tNULL_t _tif_t _ts_t _tis_t @_tc_t _tNULL_t. _tThe_t _tfirst_t _ttrailing_t _twhitespace_t _tcharacter_t _twill_t _tbe_t _treplaced_t _twith_t _tNULL_t.

_tWhitespace_t _tis_t _tdetermined_t _tby_t _tisspace_t().