g4tools  5.4.0
Namespaces | Classes | Typedefs | Enumerations | Functions
tools Namespace Reference

inlined C code : /////////////////////////////////// More...

Namespaces

 aida
 
 columns
 
 device
 
 dir
 
 file
 
 gl
 
 hdf5
 
 hep
 
 histo
 
 hplot
 
 image
 
 io
 
 jpeg
 
 metal
 
 mpi
 
 osc
 
 png
 
 Qt
 
 random
 
 rcsv
 
 read
 
 rroot
 
 sg
 
 spline
 
 waxml
 
 wcsv
 
 Windows
 
 WinTk
 
 wroot
 
 X11
 
 xml
 
 xpm
 
 Xt
 
 zb
 

Classes

class  args
 
class  array
 
class  base_handle
 
class  box3
 
class  box3f
 
class  ccontour
 
class  charp_out
 
class  clip
 
class  clist_contour
 
struct  cmp_colorf
 
class  colorf
 
class  column_binding
 
class  column_booking
 
class  csv_time
 
class  cubic
 
class  curve
 
class  data_axis
 
class  FILE_reader
 
class  fits_bit
 
class  get_funcs
 
class  get_named
 
class  get_path
 
class  handle
 
class  hatcher
 
class  hershey
 
class  img
 
class  impi
 
class  impi_world
 
class  iobj_const_visitor
 
class  iobj_visitor
 
class  irandd
 
class  istorable
 
class  ival_func
 
class  kronecker
 common array ///////////////////////////////////////////////////////////// More...
 
class  line
 
class  log_file
 
class  long_out
 
class  mat
 
class  mat3
 
class  mat3d
 
class  mat3f
 
class  mat4
 
class  mat4d
 
class  mat4f
 
class  nmat
 
class  nostream
 
class  ntuple_binding
 
class  ntuple_booking
 
class  num_out
 
class  plane
 
class  qrot
 
class  raxml
 
class  raxml_out
 
class  raxml_outs
 
class  rbinomial
 
class  rbinomiald
 
class  rbw
 
class  rbwd
 
class  rbwf
 
class  rdir2
 
class  rdir2d
 
class  rdir3
 
class  rdir3d
 
class  rexp
 
class  rexpd
 
class  rexpf
 
class  rgauss
 
class  rgaussd
 
class  rgaussf
 
class  rotd
 
class  rotf
 
class  rpoiss
 
class  rpoissd
 
class  rtausmed
 
class  rtausmef
 
class  rtausmeui
 
class  sout
 
class  tess_contour
 
struct  tess_triangle
 
class  test
 
class  utest
 
class  valop
 
class  valop2sg
 
class  valop_visitor
 
class  value
 
class  vec2
 
class  vec2f
 
class  vec3
 
class  vec3d
 
class  vec3f
 
class  vec4
 
class  vec4d
 
class  vec4f
 
class  viewplot
 
class  wps
 

Typedefs

typedef unsigned short cid
 
typedef std::list< unsigned int > cline_strip
 
typedef std::list< cline_strip * > cline_strip_list
 
typedef std::vector< cline_strip_listcline_strip_list_vector
 
typedef img< unsigned char > img_byte
 
typedef bool(* compress_func) (std::ostream &, unsigned int, unsigned int, const char *, unsigned int, char *, unsigned int &)
 
typedef bool(* decompress_func) (std::ostream &, unsigned int, const char *, unsigned int, char *, unsigned int &)
 
typedef int int32
 
typedef long long int64
 
typedef unsigned int uint32
 
typedef unsigned long long uint64
 
typedef unsigned long diff_pointer_t
 
typedef unsigned long upointer
 
typedef unsigned char byte
 
typedef unsigned char uchar
 
typedef short int16
 
typedef unsigned short ushort
 
typedef unsigned short uint16
 
typedef uint32 ref
 
typedef char * cstr_t
 
typedef const char * const_cstr_t
 
typedef unsigned int key_code
 

Enumerations

enum  what { leading, trailing, both }
 

Functions

bool is_mac_app (const std::string &)
 
bool program_path (const std::string &a_arg0, std::string &a_path)
 
bool if_mouse_startup (const std::string &a_arg0, const std::string &a_env_HOME_DIR, const std::vector< std::string > &a_home_dirs, std::ostream &a_out)
 
void app_res_dir (const std::string &a_exe_path, std::string &a_res_dir)
 
void new_argcv (const std::vector< std::string > &a_args, int &a_argc, char **&a_argv)
 
void delete_argcv (int &a_argc, char **&a_argv)
 
bool check_args (const std::vector< std::string > &a_args, unsigned int a_number, std::ostream &a_out)
 
bool check_min (const std::vector< std::string > &a_args, unsigned int a_number, std::string &a_last, std::ostream &a_out)
 
bool check_min_args (const std::vector< std::string > &aArgs, unsigned int a_number, std::ostream &a_out)
 
bool check_or_args (const std::vector< std::string > &aArgs, unsigned int a_1, unsigned int a_2, std::ostream &a_out)
 
std::vector< std::string > to (int a_argc, char **a_argv)
 
template<class T >
bool contract (const array< T > &aA, unsigned int aIA, const array< T > &aB, unsigned int aIB, array< T > &aR)
 
template<class T >
bool swap (const array< T > &aV, unsigned int aI1, unsigned int aI2, array< T > &aR)
 
template<class T >
void dump (std::ostream &a_out, const tools::array< T > &a_array, const std::string &a_title)
 
template<class T >
void diff (std::ostream &a_out, const array< T > &aA, const array< T > &aB, T a_epsilon)
 
template<class T >
array< T > operator+ (const array< T > &a1, const array< T > &a2)
 
template<class T >
array< T > operator- (const array< T > &a1, const array< T > &a2)
 
template<class T >
array< T > operator* (const T &a_fac, const array< T > &a_m)
 
void b2s (bool a_value, std::string &a_s)
 
void bas (bool a_value, std::string &a_s)
 
void b2s (const std::vector< bool > &a_vals, std::string &a_s, const std::string &a_sep="\n", bool a_sep_at_end=false)
 
void buf2lines (char *a_buffer, std::vector< std::string > &a_lines)
 
void buf2lines (size_t a_size, const char *a_buffer, std::vector< std::string > &a_lines)
 
bool strings2buf (const std::vector< std::string > &a_strings, size_t &a_size, char *&a_buffer)
 
bool buf2strings (size_t a_size, char *a_buffer, std::vector< std::string > &a_strings)
 
template<class T >
void destroy (T *&a_v)
 
template<class T , class I >
bool carray_copy (T *&a_v, I a_n, const T *a_from)
 
template<class T , class I >
bool copy (T *&a_v, I a_n, const T *a_from)
 
template<class I , class T , class TO >
bool min_max (I a_n, const void *a_v, TO &a_mn, TO &a_mx)
 
template<class I , class T , class TO >
bool min_max_S_S2 (I a_n, const void *a_v, TO &a_mn, TO &a_mx, TO &a_S, TO &a_S2)
 
template<class I , class T , class TO >
bool min_max_mean_rms (I a_n, const void *a_v, TO &a_mn, TO &a_mx, TO &a_mean, TO &a_rms, TO(*a_sqrt)(TO), TO(*a_fabs)(TO))
 
template<class I , class T , class HISTO >
bool h1_fill (I a_n, const void *a_v, HISTO &a_histo)
 
template<class T , class I >
T * _4s_to_3s (const T *a_4s, const I &a_w, const I &a_h)
 
bool is_upper (char a_char)
 
bool is_lower (char a_char)
 
bool is_digit (char a_char)
 
bool is_letter (char a_char)
 
bool is_printable (char a_char)
 
char LF ()
 
char CR ()
 
cid _cid (byte)
 
cid _cid (char)
 
cid _cid (unsigned short)
 
cid _cid (short)
 
cid _cid (unsigned int)
 
cid _cid (int)
 
cid _cid (float)
 
cid _cid (double)
 
cid _cid (bool)
 
cid _cid (uint64)
 
cid _cid (int64)
 
cid _cid (const std::string &)
 
cid _cid (fits_bit)
 
cid _cid (csv_time)
 
template<class T >
cid _cid (const std::vector< T > &)
 
template<class T >
cid _cid_std_vector ()
 
bool cid2s (cid a_id, std::string &a_s)
 
template<class T >
void cmem_free (T *&a_p)
 
template<class T >
T * cmem_alloc (size_t a_num)
 
template<class T >
T * cmem_alloc_copy (const T *a_from, size_t a_num)
 
template<class T >
bool cmp (std::ostream &a_out, const T &a_what, const T &a_ref, const T &a_error=T())
 
const colorfcolorf_default ()
 
char * str_dup (const char *a_cstr)
 
char * str_from_buffer (const char *a_buffer, size_t a_len)
 
void str_del (char *&a_cstr)
 
char * str_new (size_t a_l=0, char a_char=' ')
 
bool str_cat (char *&a_1, const char a_c)
 
bool str_cat (char *&a_1, const char *a_2)
 
void str_rev (char *a_s)
 
char * str_sub (const char *a_s, unsigned int a_pos, unsigned int a_sz=0)
 
char * str_rep (const char *a_s, unsigned int a_pos, unsigned int a_sz, const char *a_new)
 
void str_skip (char *&a_cstr, char a_c)
 
char * beg_LC_NUMERIC ()
 
void end_LC_NUMERIC (char *&a_s)
 
bool str_2d (const char *a_s, double &a_v)
 
size_t str_lcpy (char *dst, const char *src, size_t siz)
 
size_t str_lcat (char *dst, const char *src, size_t siz)
 
template<class VECTOR >
bool str_2ds (char *a_s, const char *a_sep, VECTOR &a_v)
 
template<class NUMBER , class PREC >
bool numbers_are_equal (const NUMBER &a_left, const NUMBER &a_right, const PREC &a_prec, PREC(*a_fabs)(const NUMBER &))
 
template<class NUMBER , class PREC >
bool is_zero (const NUMBER &a_left, const PREC &a_prec, PREC(*a_fabs)(const NUMBER &))
 
template<class VEC , class PREC >
bool vectors_are_equal (const VEC &a_1, const VEC &a_2, const PREC &a_prec, PREC(*a_fabs)(const PREC &))
 
template<class VECVEC , class PREC >
bool vecvecs_are_equal (const VECVEC &a_1, const VECVEC &a_2, const PREC &a_prec, PREC(*a_fabs)(const PREC &))
 
template<class NUMBER , class PREC >
bool numbers_are_equal (const NUMBER &a_left, const NUMBER &a_right, const PREC &a_prec, PREC(*a_fabs)(NUMBER))
 PREC(*a_fabs)(PREC) : /////////////////////////////////////////////////////////////////////////////////////. More...
 
template<class VEC , class PREC >
bool vectors_are_equal (const VEC &a_1, const VEC &a_2, const PREC &a_prec, PREC(*a_fabs)(PREC))
 
template<class VECVEC , class PREC >
bool vecvecs_are_equal (const VECVEC &a_1, const VECVEC &a_2, const PREC &a_prec, PREC(*a_fabs)(PREC))
 
bool rep_env (std::string &a_string)
 
bool file_name (const std::string &a_path, std::string &a_name)
 
bool find_with_dirs (std::ostream &a_out, const std::vector< std::string > &a_dirs, const std::string &a_file, std::string &a_path, bool a_verbose=false)
 
bool find_with_env (std::ostream &a_out, const std::string &a_env, const std::string &a_file, std::string &a_path, bool a_verbose=false)
 
bool is_env (const std::string &a_string)
 
bool get_env (const std::string &a_string, std::string &a_value)
 
template<class T >
bool get_env (const std::string &a_string, T &a_v, const T &a_def=T())
 
bool get_env_bool (const std::string &a_string, bool &a_v)
 
void get_lines (const std::string &a_string, std::vector< std::string > &a_lines)
 
void * mem_alloc (size_t a_size)
 
void * mem_realloc (void *a_ptr, size_t a_size)
 
void mem_free (void *a_ptr)
 
int mem_init (size_t)
 
template<class T >
hls_to_rgb2 (T rn1, T rn2, T huei)
 
template<class T >
void hls_to_rgb (T hue, T light, T satur, T &a_r, T &a_g, T &a_b)
 
template<class T >
void rgb_to_hls (T rr, T gg, T bb, T &hue, T &light, T &satur)
 
void tex_expand_size (unsigned int a_w, unsigned int &a_h, unsigned int &a_ew, unsigned int &a_eh)
 
void box_3f_make_empty (float &a_mn_x, float &a_mn_y, float &a_mn_z, float &a_mx_x, float &a_mx_y, float &a_mx_z)
 
void box_3f_extend_by (float &a_mn_x, float &a_mn_y, float &a_mn_z, float &a_mx_x, float &a_mx_y, float &a_mx_z, float a_x, float a_y, float a_z)
 
bool box_3f_is_empty (float a_mn_x, float a_mx_x)
 
template<class VEC2 >
double is_left (const VEC2 &P0, const VEC2 &P1, const VEC2 &P2)
 
template<class VEC2 >
bool is_inside (const VEC2 &a_P, const std::vector< VEC2 > &a_V)
 
template<class T >
double is_left (const std::pair< T, T > &P0, const std::pair< T, T > &P1, const std::pair< T, T > &P2)
 
template<class T >
bool inside (const std::pair< T, T > &a_P, const std::vector< std::pair< T, T > > &a_V)
 
template<class VEC2 >
bool intersect (const VEC2 &P1, const VEC2 &Q1, const VEC2 &P2, const VEC2 &Q2, VEC2 &a_out)
 
template<class T , unsigned int D>
nmat< T > copy (const mat< T, D > &a_from)
 
template<class VECTOR >
void multiply (VECTOR &a_vec, const typename VECTOR::value_type &a_mat)
 
template<class VECTOR >
void multiply (VECTOR &a_vec, const typename VECTOR::value_type::elem_t &a_value)
 
template<class MAT >
void conjugate (MAT &a_m, typename MAT::elem_t(*a_conj)(const typename MAT::elem_t &))
 related to complex numbers : ////////////////////////////////////////////////////// More...
 
template<class MAT >
bool is_real (MAT &a_m, typename MAT::elem_t::value_type(*a_imag)(const typename MAT::elem_t &))
 
template<class MAT , class PREC >
bool is_real_prec (MAT &a_m, typename MAT::elem_t::value_type(*a_imag)(const typename MAT::elem_t &), const PREC &a_prec, PREC(*a_fabs)(const typename MAT::elem_t::value_type &))
 
template<class MAT >
bool is_imag (MAT &a_m, typename MAT::elem_t::value_type(*a_real)(const typename MAT::elem_t &))
 
template<class CMAT , class RMAT >
bool to_real (const CMAT &a_c, RMAT &a_r, typename CMAT::elem_t::value_type(*a_real)(const typename CMAT::elem_t &))
 
template<class RMAT , class CMAT >
bool to_complex (const RMAT &a_r, CMAT &a_c)
 
template<class MAT >
void dagger (MAT &a_m, typename MAT::elem_t(*a_conj)(const typename MAT::elem_t &))
 
template<class CMAT , class RMAT >
bool decomplex (const CMAT &a_c, RMAT &a_r, typename CMAT::elem_t::value_type(*a_real)(const typename CMAT::elem_t &), typename CMAT::elem_t::value_type(*a_imag)(const typename CMAT::elem_t &))
 
template<class VEC_CMAT , class VEC_RMAT >
bool decomplex (const VEC_CMAT &a_vc, VEC_RMAT &a_vr, typename VEC_CMAT::value_type::elem_t::value_type(*a_real)(const typename VEC_CMAT::value_type::elem_t &), typename VEC_CMAT::value_type::elem_t::value_type(*a_imag)(const typename VEC_CMAT::value_type::elem_t &))
 
template<class MAT >
MAT commutator (const MAT &a1, const MAT &a2)
 
template<class MAT >
MAT anticommutator (const MAT &a1, const MAT &a2)
 
template<class MAT >
void commutator (const MAT &a1, const MAT &a2, MAT &a_tmp, MAT &a_res)
 
template<class MAT , class T >
void commutator (const MAT &a1, const MAT &a2, MAT &a_tmp, T a_vtmp[], MAT &a_res)
 
template<class MAT >
void anticommutator (const MAT &a1, const MAT &a2, MAT &a_tmp, MAT &a_res)
 
template<class MAT , class T >
void anticommutator (const MAT &a1, const MAT &a2, MAT &a_tmp, T a_vtmp[], MAT &a_res)
 
template<class T , unsigned int D>
bool commutator_equal (const mat< T, D > &a_1, const mat< T, D > &a_2, const mat< T, D > &a_c, const T &a_prec)
 
template<class T , unsigned int D>
bool anticommutator_equal (const mat< T, D > &a_1, const mat< T, D > &a_2, const mat< T, D > &a_c, const T &a_prec)
 
template<class T , unsigned int D>
mat< T, D > operator- (const mat< T, D > &a1, const mat< T, D > &a2)
 
template<class T , unsigned int D>
mat< T, D > operator+ (const mat< T, D > &a1, const mat< T, D > &a2)
 
template<class T , unsigned int D>
mat< T, D > operator* (const mat< T, D > &a1, const mat< T, D > &a2)
 
template<class T , unsigned int D>
mat< T, D > operator* (const T &a_fac, const mat< T, D > &a_m)
 
template<class T >
nmat< T > operator- (const nmat< T > &a1, const nmat< T > &a2)
 
template<class T >
nmat< T > operator+ (const nmat< T > &a1, const nmat< T > &a2)
 
template<class T >
nmat< T > operator* (const nmat< T > &a1, const nmat< T > &a2)
 
template<class T >
nmat< T > operator* (const T &a_fac, const nmat< T > &a_m)
 
template<class MAT , class REAL >
bool mat_fabs (const MAT &a_in, MAT &a_ou, REAL(*a_fabs)(const typename MAT::elem_t &))
 
template<class MAT >
void matrix_set (MAT &a_m, TOOLS_MELEM a_00, TOOLS_MELEM a_01, TOOLS_MELEM a_10, TOOLS_MELEM a_11)
 specific D=2 /////////////////////////////// More...
 
template<class MAT >
void matrix_set (MAT &a_m, TOOLS_MELEM a_00, TOOLS_MELEM a_01, TOOLS_MELEM a_02, TOOLS_MELEM a_10, TOOLS_MELEM a_11, TOOLS_MELEM a_12, TOOLS_MELEM a_20, TOOLS_MELEM a_21, TOOLS_MELEM a_22)
 specific D=3 /////////////////////////////// More...
 
template<class MAT >
void matrix_set (MAT &a_m, TOOLS_MELEM a_00, TOOLS_MELEM a_01, TOOLS_MELEM a_02, TOOLS_MELEM a_03, TOOLS_MELEM a_10, TOOLS_MELEM a_11, TOOLS_MELEM a_12, TOOLS_MELEM a_13, TOOLS_MELEM a_20, TOOLS_MELEM a_21, TOOLS_MELEM a_22, TOOLS_MELEM a_23, TOOLS_MELEM a_30, TOOLS_MELEM a_31, TOOLS_MELEM a_32, TOOLS_MELEM a_33)
 specific D=4 /////////////////////////////// More...
 
template<class MAT >
void matrix_set (MAT &a_m, TOOLS_MELEM a_00, TOOLS_MELEM a_01, TOOLS_MELEM a_02, TOOLS_MELEM a_03, TOOLS_MELEM a_04, TOOLS_MELEM a_10, TOOLS_MELEM a_11, TOOLS_MELEM a_12, TOOLS_MELEM a_13, TOOLS_MELEM a_14, TOOLS_MELEM a_20, TOOLS_MELEM a_21, TOOLS_MELEM a_22, TOOLS_MELEM a_23, TOOLS_MELEM a_24, TOOLS_MELEM a_30, TOOLS_MELEM a_31, TOOLS_MELEM a_32, TOOLS_MELEM a_33, TOOLS_MELEM a_34, TOOLS_MELEM a_40, TOOLS_MELEM a_41, TOOLS_MELEM a_42, TOOLS_MELEM a_43, TOOLS_MELEM a_44)
 specific D=5 /////////////////////////////// More...
 
template<class MAT >
void matrix_set (MAT &a_m, TOOLS_MELEM a_00, TOOLS_MELEM a_01, TOOLS_MELEM a_02, TOOLS_MELEM a_03, TOOLS_MELEM a_04, TOOLS_MELEM a_05, TOOLS_MELEM a_10, TOOLS_MELEM a_11, TOOLS_MELEM a_12, TOOLS_MELEM a_13, TOOLS_MELEM a_14, TOOLS_MELEM a_15, TOOLS_MELEM a_20, TOOLS_MELEM a_21, TOOLS_MELEM a_22, TOOLS_MELEM a_23, TOOLS_MELEM a_24, TOOLS_MELEM a_25, TOOLS_MELEM a_30, TOOLS_MELEM a_31, TOOLS_MELEM a_32, TOOLS_MELEM a_33, TOOLS_MELEM a_34, TOOLS_MELEM a_35, TOOLS_MELEM a_40, TOOLS_MELEM a_41, TOOLS_MELEM a_42, TOOLS_MELEM a_43, TOOLS_MELEM a_44, TOOLS_MELEM a_45, TOOLS_MELEM a_50, TOOLS_MELEM a_51, TOOLS_MELEM a_52, TOOLS_MELEM a_53, TOOLS_MELEM a_54, TOOLS_MELEM a_55)
 specific D=6 /////////////////////////////// More...
 
template<class MAT >
void matrix_set (MAT &a_m, TOOLS_MELEM a_00, TOOLS_MELEM a_01, TOOLS_MELEM a_02, TOOLS_MELEM a_03, TOOLS_MELEM a_04, TOOLS_MELEM a_05, TOOLS_MELEM a_06, TOOLS_MELEM a_07, TOOLS_MELEM a_08, TOOLS_MELEM a_09, TOOLS_MELEM a_10, TOOLS_MELEM a_11, TOOLS_MELEM a_12, TOOLS_MELEM a_13, TOOLS_MELEM a_14, TOOLS_MELEM a_15, TOOLS_MELEM a_16, TOOLS_MELEM a_17, TOOLS_MELEM a_18, TOOLS_MELEM a_19, TOOLS_MELEM a_20, TOOLS_MELEM a_21, TOOLS_MELEM a_22, TOOLS_MELEM a_23, TOOLS_MELEM a_24, TOOLS_MELEM a_25, TOOLS_MELEM a_26, TOOLS_MELEM a_27, TOOLS_MELEM a_28, TOOLS_MELEM a_29, TOOLS_MELEM a_30, TOOLS_MELEM a_31, TOOLS_MELEM a_32, TOOLS_MELEM a_33, TOOLS_MELEM a_34, TOOLS_MELEM a_35, TOOLS_MELEM a_36, TOOLS_MELEM a_37, TOOLS_MELEM a_38, TOOLS_MELEM a_39, TOOLS_MELEM a_40, TOOLS_MELEM a_41, TOOLS_MELEM a_42, TOOLS_MELEM a_43, TOOLS_MELEM a_44, TOOLS_MELEM a_45, TOOLS_MELEM a_46, TOOLS_MELEM a_47, TOOLS_MELEM a_48, TOOLS_MELEM a_49, TOOLS_MELEM a_50, TOOLS_MELEM a_51, TOOLS_MELEM a_52, TOOLS_MELEM a_53, TOOLS_MELEM a_54, TOOLS_MELEM a_55, TOOLS_MELEM a_56, TOOLS_MELEM a_57, TOOLS_MELEM a_58, TOOLS_MELEM a_59, TOOLS_MELEM a_60, TOOLS_MELEM a_61, TOOLS_MELEM a_62, TOOLS_MELEM a_63, TOOLS_MELEM a_64, TOOLS_MELEM a_65, TOOLS_MELEM a_66, TOOLS_MELEM a_67, TOOLS_MELEM a_68, TOOLS_MELEM a_69, TOOLS_MELEM a_70, TOOLS_MELEM a_71, TOOLS_MELEM a_72, TOOLS_MELEM a_73, TOOLS_MELEM a_74, TOOLS_MELEM a_75, TOOLS_MELEM a_76, TOOLS_MELEM a_77, TOOLS_MELEM a_78, TOOLS_MELEM a_79, TOOLS_MELEM a_80, TOOLS_MELEM a_81, TOOLS_MELEM a_82, TOOLS_MELEM a_83, TOOLS_MELEM a_84, TOOLS_MELEM a_85, TOOLS_MELEM a_86, TOOLS_MELEM a_87, TOOLS_MELEM a_88, TOOLS_MELEM a_89, TOOLS_MELEM a_90, TOOLS_MELEM a_91, TOOLS_MELEM a_92, TOOLS_MELEM a_93, TOOLS_MELEM a_94, TOOLS_MELEM a_95, TOOLS_MELEM a_96, TOOLS_MELEM a_97, TOOLS_MELEM a_98, TOOLS_MELEM a_99)
 specific D=10 ////////////////////////////// More...
 
template<class MAT >
void dump (std::ostream &a_out, const std::string &aCMT, const MAT &a_matrix)
 
template<class MAT >
bool check_invert (const MAT &a_matrix, std::ostream &a_out)
 
template<class T >
const mat3< T > & mat3_zero ()
 common matrices : ////////////////////////// More...
 
template<class T >
std::ostream & operator<< (std::ostream &a_out, const mat3< T > &a_mtx)
 
template<class T >
const mat4< T > & mat4_zero ()
 common matrices : ////////////////////////// More...
 
template<class T >
const T * get_data (const mat4< T > &a_v)
 
template<class T >
std::ostream & operator<< (std::ostream &a_out, const mat4< T > &a_mtx)
 
const std::string & stype (const mat4f &)
 
bool tos (const rotf &a_v, std::string &a_s)
 
template<class T >
const T * get_data (const vec2< T > &a_v)
 
template<class T >
std::ostream & operator<< (std::ostream &a_out, const vec2< T > &a_this)
 
vec2f operator* (float a_f, const vec2f &a_v)
 
bool set_from_vec (vec2f &a_v, const std::vector< float > &a_sv)
 
template<class T >
const T * get_data (const vec3< T > &a_v)
 
template<class T >
void get_normal (const vec3< T > &a_p0, const vec3< T > &a_p1, const vec3< T > &a_p2, vec3< T > &a_nm, vec3< T > &a_tmp_1, vec3< T > &a_tmp_2, T(*a_sqrt)(T))
 
template<class VEC3 >
void direction (const VEC3 &a_p0, const VEC3 &a_p1, const VEC3 &a_p2, VEC3 &a_value)
 
template<class VEC3 >
void area (const VEC3 &a_p0, const VEC3 &a_p1, const VEC3 &a_p2, typename VEC3::elem_t &a_value, VEC3 &a_tmp_1, VEC3 &a_tmp_2, VEC3 &a_tmp_3)
 
template<class VEC3 >
void area (const VEC3 &a_p0, const VEC3 &a_p1, const VEC3 &a_p2, typename VEC3::elem_t &a_value)
 
template<class T >
void direction (const T &a_0_x, const T &a_0_y, const T &a_0_z, const T &a_1_x, const T &a_1_y, const T &a_1_z, const T &a_2_x, const T &a_2_y, const T &a_2_z, vec3< T > &a_value)
 
template<class T >
std::ostream & operator<< (std::ostream &a_out, const vec3< T > &a_this)
 
vec3d operator* (double a_f, const vec3d &a_v)
 
bool set_from_vec (vec3d &a_v, const std::vector< double > &a_sv)
 
vec3f operator* (float a_f, const vec3f &a_v)
 
void get_normal (const vec3f &a_p0, const vec3f &a_p1, const vec3f &a_p2, vec3f &a_nm, vec3f &a_tmp_1, vec3f &a_tmp_2)
 
bool set_from_vec (vec3f &a_v, const std::vector< float > &a_sv)
 
template<class T >
const T * get_data (const vec4< T > &a_v)
 
template<class T >
std::ostream & operator<< (std::ostream &a_out, const vec4< T > &a_this)
 
bool set_from_vec (vec4f &a_v, const std::vector< float > &a_sv)
 
template<class K , class V >
void safe_clear (std::map< K, V * > &a_m)
 
template<class K , class V >
void find_and_remove_value (std::map< K, V * > &a_m, V *a_value)
 
template<class K , class V >
bool delete_key (std::map< K, V * > &a_m, const K &a_key)
 
template<class K , class V >
void raw_clear (std::map< K, V * > &a_m)
 
template<class K , class V >
void copy (std::map< K, V * > &a_to, const std::map< K, V * > &a_from)
 
template<class K , class V >
bool add_unique (std::map< K, V * > &a_map, const K &a_key, V *a_value, bool a_delete)
 
template<class K , class V >
bool find (const std::map< K, V > &a_map, const K &a_key, V &a_value)
 
template<class K , class V >
bool is_key (const std::map< K, V > &a_map, const K &a_key)
 
double pi ()
 
double two_pi ()
 
double half_pi ()
 
double deg2rad ()
 
double rad2deg ()
 
bool in_domain_all (double)
 
bool in_domain_log (double a_x)
 
bool in_domain_tan (double a_x)
 
bool in_domain_acos (double a_x)
 
double dcos (const double &a_x)
 
double dsin (const double &a_x)
 
double dpow (const double &a_x, const double &a_y)
 
double dcosh (const double &a_x)
 
double dsinh (const double &a_x)
 
double dconj (const double &a_x)
 
double dfabs (const double &a_x)
 
double dsqrt (const double &a_x)
 
long double ldfabs (const long double &a_x)
 
bool dpow (const double &a_x, const double &a_y, double &a_v)
 
double dgaussian (const double &a_x, const double &a_mean, const double &a_sigma)
 
float fpi ()
 
float ftwo_pi ()
 
float fhalf_pi ()
 
float fdeg2rad ()
 
float frad2deg ()
 
int fround (const float &a_x)
 
float fstep (const float &a_x)
 
float fcos (const float &x)
 
float fsin (const float &x)
 
float facos (const float &x)
 
float fasin (const float &x)
 
float ftan (const float &x)
 
float fatan (const float &x)
 
float fatan2 (const float &x, const float &y)
 
float fsqrt (const float &x)
 
float fpow (const float &x, const float &y)
 
float fexp (const float &x)
 
float flog (const float &x)
 
float flog10 (const float &x)
 
float ffloor (const float &x)
 
float fceil (const float &x)
 
float fcosh (const float &x)
 
float fsinh (const float &x)
 
float ffabs (const float &x)
 
template<class T >
mn (const T &a, const T &b)
 
template<class T >
mx (const T &a, const T &b)
 
template<class T >
min_of (const T &a, const T &b)
 
template<class T >
max_of (const T &a, const T &b)
 
bool num2s (unsigned short a_value, std::string &a_s)
 
bool num2s (short a_value, std::string &a_s)
 
bool num2s (unsigned int a_value, std::string &a_s)
 
bool num2s (int a_value, std::string &a_s)
 
bool num2s (uint64 a_value, std::string &a_s)
 
bool num2s (int64 a_value, std::string &a_s)
 
bool num2s (float a_value, std::string &a_s)
 
bool num2s (double a_value, std::string &a_s)
 
bool size_t2s (size_t a_value, std::string &a_s)
 
bool ptrdiff_t2s (ptrdiff_t a_value, std::string &a_s)
 
template<class T >
bool numas (const T &a_value, std::string &a_s)
 
template<class T >
bool size_tas (const T &a_value, std::string &a_s)
 
bool num2s (const std::string &a_value, std::string &a_s)
 
template<class VEC >
bool nums2s (const VEC &a_vals, std::string &a_s, const std::string &a_sep="\n", bool a_sep_at_end=false)
 
template<class T >
bool nums2s (const std::vector< T > &a_vals, std::string &a_s, const std::string &a_sep="\n", bool a_sep_at_end=false)
 
void out_error (std::ostream &a_out, const char *location, const char *fmt,...)
 
void suffix (const std::string &a_string, std::string &a_value, bool a_back=true)
 
void nosuffix (const std::string &a_string, std::string &a_value, bool a_back=true)
 
void path_no_suffix (const std::string &a_string, std::string &a_value)
 
bool has_dir (const std::string &a_string)
 
void base_name (const std::string &a_path, std::string &a_value)
 
std::string suffix (const std::string &a_string, bool a_back=true)
 
std::string nosuffix (const std::string &a_string, bool a_back=true)
 
std::string base_name (const std::string &a_path)
 
bool is_absolute_path (const std::string &a_path)
 
bool path_name_suffix (const std::string &a_string, std::string &a_path, std::string &a_name, std::string &a_suffix)
 
std::string dir_name (const std::string &a_path, unsigned int a_num=1)
 
void quote (std::string &a_path)
 
bool is_f77 (const std::string &a_path)
 
bool is_cpp (const std::string &a_path)
 
bool is_python (const std::string &a_path)
 
bool url_parse (const std::string &a_url, std::string &a_host, unsigned int &a_port, std::string &a_path)
 
bool env_append (const std::string &a_env, const std::string &a_sep, const std::vector< std::string > &a_vals)
 
bool env_path_append (const std::string &a_env, const std::vector< std::string > &a_paths)
 
bool env_append_path (const std::string &a_env, const std::string &a_path)
 
bool is_little_endian ()
 
const char * os ()
 
bool _WIN32_defined ()
 
const char * processor ()
 
const char * compiler_name ()
 
void compiler (char a_s[128])
 
bool to_pointer (const std::string &a_string, void *&a_value)
 
bool to_pointer (const char *a_string, void *&a_value)
 
bool p2s (const void *a_value, std::string &a_s)
 
bool p2sx (const void *a_value, std::string &a_s)
 
bool put_env (const std::string &a_env, const std::string &a_value)
 
bool rm_env (const std::string &a_env)
 
bool rcmp (const char *a_1, const char *a_2)
 
bool rcmp (const std::string &a_1, const char *a_2)
 
bool rcmp (const char *a_1, const std::string &a_2)
 
bool rcmp (const std::string &a_1, const std::string &a_2)
 
template<class T >
bool realloc (T *&a_pointer, size_t a_new_size, size_t a_old_size, bool a_init=false)
 
bool s2time (const std::string &a_string, time_t &a_time)
 
bool time2s (std::string &a_s)
 
template<class FROM , class TO >
TO * safe_cast (FROM &a_o)
 
template<class FROM , class TO >
const TO * safe_cast (const FROM &a_o)
 
template<class FROM , class TO >
TO * id_cast (FROM &a_o)
 
template<class FROM , class TO >
const TO * id_cast (const FROM &a_o)
 
std::string gui_toolkit (args &a_args, bool a_rm_in_args)
 
bool window_size_from_args (const args &a_args, unsigned int &a_ww, unsigned int &a_wh)
 
void remove_window_size_args (args &a_args)
 
bool is_beg (const std::string &a_s, const std::string &a_b, bool a_forward=true)
 
bool is_beg (const std::string &a_s, const std::string &a_b, std::string &a_cmd, bool a_forward=true)
 
template<class TO >
void * cmp_cast (const TO *a_this, const std::string &a_class)
 
template<class TO >
void * cmp_cast (const TO *a_this, cid a_id)
 
bool belong (const std::string &a_string, char a_c)
 
size_t numchar (const std::string &a_string, char a_c)
 
bool is_spaces (const std::string &a_string)
 
const std::string & sep ()
 
const std::string & psep ()
 
const std::string & res_sep ()
 
void serrno (std::string &a_s)
 
bool mnmx (std::ostream &a_out, sg::node &a_node, vec3f &a_mn, vec3f &a_mx)
 
bool center_adjust (std::ostream &a_out, sg::node &a_node, sg::matrix &a_tsf, unsigned int a_ww, unsigned int a_wh, float a_height, float &a_dx, float &a_dy, float &a_dz, bool a_verbose=true)
 
bool center_adjust (std::ostream &a_out, sg::node &a_node, sg::matrix &a_tsf, unsigned int a_ww, unsigned int a_wh, float a_height, bool a_verbose=true)
 
bool match (const std::string &a_string, const std::string &a_pattern, bool a_check_for_wilds=true)
 
bool match2 (const std::string &a_string, const std::string &a_pattern)
 
void filter (std::vector< std::string > &a_v, const std::string &a_pattern, bool a_check_for_wilds=true)
 
const std::string & s_partial_derivative ()
 
int vsnpf (char *a_s, size_t a_n, const char *a_fmt, va_list args)
 
int snpf (char *a_s, size_t a_n, const char *a_fmt,...)
 
template<class T >
bool snums (const std::string &a_string, std::istringstream &a_iss, std::vector< std::string > &a_tmp, const std::string &a_sep, std::vector< T > &a_values, bool a_clear=true)
 
template<class T >
bool snums (const std::string &a_string, const std::string &a_sep, std::vector< T > &a_values, bool a_clear=true)
 
bool vsprintf (std::string &a_string, int a_length, const char *a_format, va_list a_args)
 
bool sprintf (std::string &a_string, int a_length, const char *a_format,...)
 
bool print2sv (std::string &a_string, int a_length, const char *a_format, va_list a_args)
 
bool print2s (std::string &a_string, int a_length, const char *a_format,...)
 
template<class MATRIX >
void set_matrix (MATRIX &a_matrix, const std::string &a_fmt)
 
void replace (std::string &a_string, char a_old, char a_new)
 
bool replace (std::string &a_string, const std::string &a_old, const std::string &a_new)
 
bool replace_ (std::string &a_string, const std::string &a_old, const std::string &a_new)
 
bool replace (std::vector< std::string > &a_strings, const std::string &a_old, const std::string &a_new)
 
void toxml (std::string &a_string)
 
std::string to_xml (const std::string &a_string)
 
void to_win (std::string &a_string)
 
void to_win_python (std::string &a_string)
 
int std_system (std::ostream &a_out, const std::string &a_string)
 
bool to (const std::string &a_string, bool &a_value, bool a_def=false)
 
bool tob (const std::string &a_string, bool &a_value, bool a_def=false)
 
template<class T >
bool to (const std::string &a_s, T &a_v, const T &a_def=T())
 
template<class T >
bool to (T &a_field, const std::string &a_s, bool &a_changed)
 
template<class T >
bool to (std::ostream &a_out, const std::string &a_string, T &a_value)
 
bool to (std::ostream &a_out, const std::string &a_string, bool &a_value)
 
bool to_size_t (const std::string &a_string, size_t &a_value, const size_t &a_def=0)
 
bool strip (std::string &a_string, what a_type=both, char a_char=' ')
 
bool strip (std::vector< std::string > &a_strings, what a_type=both, char a_char=' ')
 
const std::string & stype (unsigned char)
 
const std::string & stype (char)
 
const std::string & stype (unsigned short)
 
const std::string & stype (short)
 
const std::string & stype (int)
 
const std::string & stype (unsigned int)
 
const std::string & stype (float)
 
const std::string & stype (double)
 
const std::string & stype (bool)
 
const std::string & stype (int64)
 
const std::string & stype (uint64)
 
const std::string & stype (const std::string &)
 
template<class T >
const std::string & stype (const T &)
 
bool stemplate (const std::string &a_s, std::string &a_inc)
 
const std::string & stype (const std::vector< std::string > &)
 
template<class T >
bool values (const std::string &a_string, const std::string &a_sep, bool a_take_empty, std::vector< T > &a_values)
 
int process_id ()
 
bool equal (std::ostream &a_out, const char *a_file, int a_line, const std::string &a_v, const std::string &a_expected)
 
bool equal (std::ostream &a_out, const char *a_file, int a_line, bool a_v, bool a_expected)
 
template<class CLASS >
bool valid_pointer (std::ostream &a_out, const char *a_file, int a_line, CLASS *a_p)
 
template<class INTEGER >
bool equal (std::ostream &a_out, const char *a_file, int a_line, const INTEGER &a_v, const INTEGER &a_expected)
 
template<class INTEGER >
bool not_equal (std::ostream &a_out, const char *a_file, int a_line, const INTEGER &a_v, const INTEGER &a_expected)
 
template<class INTEGER >
bool ge (std::ostream &a_out, const char *a_file, int a_line, const INTEGER &a_v, const INTEGER &a_expected)
 
template<class REAL >
bool equal (std::ostream &a_out, const char *a_file, int a_line, const REAL &a_v, const REAL &a_expected, const REAL &a_tolerance, REAL(*a_fabs)(const REAL &))
 
template<class REAL >
bool not_equal (std::ostream &a_out, const char *a_file, int a_line, const REAL &a_v, const REAL &a_expected, const REAL &a_tolerance, REAL(*a_fabs)(const REAL &))
 
template<class NUMBER , class PREC >
bool _equal (std::ostream &a_out, const char *a_file, int a_line, const NUMBER &a_v, const NUMBER &a_expected, const PREC &a_tolerance, PREC(*a_fabs)(const NUMBER &))
 
template<class REAL >
bool equal (std::ostream &a_out, const char *a_file, int a_line, size_t a_size, const REAL *a_v, const REAL *a_expected, const REAL &a_tolerance, REAL(*a_fabs)(const REAL &))
 
template<class VEC , class REAL >
bool equal (std::ostream &a_out, const char *a_file, int a_line, const VEC &a_1, const VEC &a_2, const REAL &a_tolerance, REAL(*a_fabs)(const REAL &))
 
template<class MAT , class REAL >
bool mat_equal (std::ostream &a_out, const char *a_file, int a_line, const MAT &a_1, const MAT &a_2, const REAL &a_tolerance, REAL(*a_fabs)(const REAL &))
 
bool equal (std::ostream &a_out, const char *a_file, int a_line, const std::vector< std::string > &a_v, const std::vector< std::string > &a_expected)
 
std::string tos (unsigned char a_value)
 
std::string tos (char a_value)
 
std::string tos (unsigned short a_value)
 
std::string tos (short a_value)
 
std::string tos (unsigned int a_value)
 
std::string tosx (unsigned int a_value)
 
std::string tos (int a_value)
 
std::string tos (uint64 a_value)
 
std::string tos (int64 a_value)
 
std::string tos (float a_value)
 
std::string tos (double a_value)
 
std::string tos (bool a_value)
 
std::string tos (const std::string &a_value)
 
template<class T >
std::string tos (const std::vector< T > &a_vals, const std::string &a_sep="\n", bool a_sep_at_end=false)
 
std::string tos (unsigned int a_linen, const char *a_lines[])
 
void toss (const char *a_from, char a_s[], unsigned int &a_l)
 
template<class T >
void tosu (T a_i, char a_s[], unsigned int &a_l)
 
void tolowercase (std::string &a_string)
 
void touppercase (std::string &a_string)
 
const char * int32_format ()
 
const char * int64_format ()
 
const char * uint32_format ()
 
const char * uint64_format ()
 
const char * upointer_format ()
 
const char * upointer_format_x ()
 
uint32 uint32_mx ()
 
uint64 uint64_mx ()
 
unsigned int size_char ()
 
unsigned int size_short ()
 
unsigned int size_int ()
 
unsigned int size_int64 ()
 
unsigned int size_float ()
 
unsigned int size_double ()
 
const char * type_format (float)
 
const char * type_format (double)
 
const char * type_format (char)
 
const char * type_format (short)
 
const char * type_format (int)
 
const char * type_format (int64)
 
const char * type_format (unsigned char)
 
const char * type_format (unsigned short)
 
const char * type_format (unsigned int)
 
const char * type_format (uint64)
 
template<class T >
const T * vec_data (const std::vector< T > &a_vec)
 
template<class T >
T * vec_data (std::vector< T > &a_vec)
 
void tools_vdata_check_compile ()
 
unsigned int version ()
 
template<class T >
T * find_named (const std::vector< T * > &a_vec, const std::string &a_name)
 
template<class T >
const T * find_obj_named (const std::vector< T > &a_vec, const std::string &a_name)
 
template<class T >
T * find_obj_named (std::vector< T > &a_vec, const std::string &a_name)
 
template<class T >
T * find_named_case_insensitive (const std::vector< T * > &a_vec, const std::string &a_name)
 
template<class T >
void safe_clear (std::vector< T * > &a_vec)
 T* : /////////////////////////////////////////////////. More...
 
template<class T >
void safe_reverse_clear (std::vector< T * > &a_vec)
 
template<class T >
void raw_clear (std::vector< T * > &a_vec)
 
template<class T >
void copy (std::vector< T * > &a_to, const std::vector< T * > &a_from)
 
template<class T >
void vcopy (std::vector< T * > &a_to, const std::vector< T * > &a_from)
 
template<class T >
void append (std::vector< T > &a_vec, const std::vector< T > &a_from)
 
template<class T >
void append (std::vector< T > &a_vec, typename std::vector< T >::size_type a_num, const T *a_from)
 
template<class T >
void removep (std::vector< T * > &a_vec, const T *a_elem)
 
template<class T >
bool is_inp (const std::vector< T * > &a_vec, const T *a_item)
 
template<class T >
void push_back_unique (std::vector< T > &a_vec, const T &a_v)
 T : ////////////////////////////////////////////////////////////////////. More...
 
template<class T >
bool remove (std::vector< T > &a_vals, const T &a_elem)
 
template<class T >
void vfilter (std::vector< T > &a_vals, bool(*a_filter_func)(const T &a_elem))
 
template<class T >
void unique (std::vector< T > &a_vec)
 
template<class T >
bool is_in (const std::vector< T > &a_vec, const T &a_item)
 
template<class T >
bool item_index (const std::vector< T > &a_vec, const T &a_item, unsigned int &a_index)
 
template<class T >
bool belong (const std::vector< T > &a_vec, const T &a_item)
 
template<class T >
bool minimum (const std::vector< T > &a_vec, T &a_value)
 
template<class T >
bool maximum (const std::vector< T > &a_vec, T &a_value)
 
template<class T >
sum (const std::vector< T > &a_vec)
 
template<class T >
void filter (std::vector< T > &a_vec, unsigned int a_min, unsigned int a_max)
 
template<class T >
void steps (std::vector< T > &a_vec, unsigned int a_number)
 
template<class T >
bool add (std::vector< T > &a_vec, const std::vector< T > &a_v)
 
template<class T >
bool vequ (const std::vector< T > &a_vec, const std::vector< T > &a_v)
 
template<class T >
bool vadd (std::vector< T > &a_vec, const std::vector< T > &a_v)
 
template<class T >
bool sub (std::vector< T > &a_vec, const std::vector< T > &a_v)
 
template<class T >
bool div (std::vector< T > &a_vec, const std::vector< T > &a_v)
 
template<class T >
void add (std::vector< T > &a_vec, const T &a_v)
 
template<class T >
void sub (std::vector< T > &a_vec, const T &a_v)
 
template<class T >
void mul (std::vector< T > &a_vec, const T &a_v)
 
template<class T >
bool vmul (std::vector< T > &a_vec, const std::vector< T > &a_v)
 
template<class T >
void div (std::vector< T > &a_vec, const T &a_v)
 
template<class FROM , class TO >
void convert (const std::vector< FROM > &a_from, std::vector< TO > &a_to)
 
template<class T >
bool min_max (const std::vector< T > &a_vec, T &a_min, T &a_max)
 
template<class T >
bool mean_rms (const std::vector< T > &a_vec, T &a_mean, T &a_rms, T(*a_sqrt)(T), T(*a_fabs)(T))
 T(*a_fabs)(T) : ///////////////////////////////////////////////////////////////////////////////////////////. More...
 
template<class T >
bool min_max_mean_rms (const std::vector< T > &a_vec, T &a_min, T &a_max, T &a_mean, T &a_rms, T(*a_sqrt)(T), T(*a_fabs)(T))
 
template<class T >
bool mean_rms (const std::vector< T > &a_vec, T &a_mean, T &a_rms, T(*a_sqrt)(const T &), T(*a_fabs)(const T &))
 T(*a_fabs)(const T&) : ///////////////////////////////////////////////////////////////////////////////////////////. More...
 
template<class T >
bool min_max_mean_rms (const std::vector< T > &a_vec, T &a_min, T &a_max, T &a_mean, T &a_rms, T(*a_sqrt)(const T &), T(*a_fabs)(const T &))
 
template<class T >
void dump (const std::vector< T > &a_vec, std::ostream &a_out)
 
template<class K , class V >
void add (std::vector< std::pair< K, V > > &a_vec, const K &a_key, const V &a_value)
 
template<class K , class V >
bool find (const std::vector< std::pair< K, V > > &a_vec, const K &a_key, V &a_value)
 
template<class K , class V >
bool rfind (const std::vector< std::pair< K, V > > &a_vec, const K &a_key, V &a_value)
 
template<class K , class V >
bool is_key (const std::vector< std::pair< K, V > > &a_vec, const K &a_key)
 
template<class K , class V >
bool find_key (const std::vector< std::pair< K, V > > &a_vec, const V &a_value, K &a_key)
 
template<class K , class V >
void sort_by_second (std::vector< std::pair< K, V > > &a_vec)
 
template<class K , class V >
bool remove (std::vector< std::pair< K, V > > &a_vec, const K &a_key)
 
template<class K , class V >
bool remove (std::vector< std::pair< K, V > > &a_vec, const K &a_key, bool a_delete)
 
void words (const std::string &a_string, const std::string &a_sep, bool a_take_empty, std::vector< std::string > &a_words, bool a_clear=true)
 
void words (const std::string &a_string, const std::string &a_sep, bool a_take_empty, unsigned int &a_wn, std::string::size_type a_wps[], std::string::size_type a_wls[])
 
bool compress_buffer (std::ostream &a_out, unsigned int a_level, unsigned int a_srcsize, const char *a_src, unsigned int a_tgtsize, char *a_tgt, unsigned int &a_irep)
 
bool decompress_buffer (std::ostream &a_out, unsigned int a_srcsize, const char *a_src, unsigned int a_tgtsize, char *a_tgt, unsigned int &a_irep)
 
int gunzip_get_byte (char *&a_buffer)
 
int gunzip_check_header (char *&a_buffer)
 
bool gunzip_buffer (std::ostream &a_out, unsigned int a_srcsize, const char *a_src, unsigned int a_tgtsize, char *a_tgt, unsigned int &a_irep)
 

Detailed Description

inlined C code : ///////////////////////////////////

manipulations that induces other includes : ///////////

primitives : ///////////////////////////////////////////////////////////////

backcomp : for OnX/source/Core/atat.cxx : /////////////////////

h3 -> h2 ////////////////////////////////////////////////////////////////////

h2 -> p1 ////////////////////////////////////////////////////////////////////

h2 -> h1 ////////////////////////////////////////////////////////////////////

hatcher is a class to draw Hatch in a 3D polyline plane A hatch is caracterise by a direction (dirAngle), a spacing to get second hatch, an offset, and a stripWidth :

The compute_polyline() method
By default:

A way to get all points and vertices and to draw them can be :

 iindex =0;
 icoord =0;
 for (unsigned int a=0;a<sbHatch.number_of_vertices();a++) {
   for (unsigned int b=0;b<sbHatch.number_of_vertices()[a];b++) {
     coordinate3->point.set1Value(icoord,sbHatch.get_points()[icoord]);
     indexedFaceSet->coordIndex.set1Value(iindex,icoord);
     iindex++;
     icoord ++;
   }
   indexedFaceSet->coordIndex.set1Value(iindex,SO_END_LINE_INDEX);
   iindex++;
 }
Author
Laurent Garnier Creation : on Fri Jan 05 2004 Last update : 9 April 2004

Typedef Documentation

◆ byte

typedef unsigned char tools::byte

Definition at line 96 of file typedefs.

◆ cid

typedef unsigned short tools::cid

Definition at line 9 of file cid.

◆ cline_strip

typedef std::list<unsigned int> tools::cline_strip

Definition at line 21 of file clist_contour.

◆ cline_strip_list

typedef std::list<cline_strip*> tools::cline_strip_list

Definition at line 22 of file clist_contour.

◆ cline_strip_list_vector

Definition at line 23 of file clist_contour.

◆ compress_func

typedef bool(* tools::compress_func) (std::ostream &, unsigned int, unsigned int, const char *, unsigned int, char *, unsigned int &)

Definition at line 11 of file press_func.

◆ const_cstr_t

typedef const char* tools::const_cstr_t

Definition at line 105 of file typedefs.

◆ cstr_t

typedef char* tools::cstr_t

Definition at line 104 of file typedefs.

◆ decompress_func

typedef bool(* tools::decompress_func) (std::ostream &, unsigned int, const char *, unsigned int, char *, unsigned int &)

Definition at line 13 of file press_func.

◆ diff_pointer_t

typedef unsigned long tools::diff_pointer_t

Definition at line 76 of file typedefs.

◆ img_byte

typedef img<unsigned char> tools::img_byte

Definition at line 894 of file img.

◆ int16

typedef short tools::int16

Definition at line 100 of file typedefs.

◆ int32

typedef int tools::int32

Definition at line 66 of file typedefs.

◆ int64

typedef long long tools::int64

Definition at line 67 of file typedefs.

◆ key_code

typedef unsigned int tools::key_code

Definition at line 131 of file typedefs.

◆ ref

typedef uint32 tools::ref

Definition at line 103 of file typedefs.

◆ uchar

typedef unsigned char tools::uchar

Definition at line 99 of file typedefs.

◆ uint16

typedef unsigned short tools::uint16

Definition at line 102 of file typedefs.

◆ uint32

typedef unsigned int tools::uint32

Definition at line 71 of file typedefs.

◆ uint64

typedef unsigned long long tools::uint64

Definition at line 72 of file typedefs.

◆ upointer

typedef unsigned long tools::upointer

Definition at line 78 of file typedefs.

◆ ushort

typedef unsigned short tools::ushort

Definition at line 101 of file typedefs.

Enumeration Type Documentation

◆ what

Enumerator
leading 
trailing 
both 

Definition at line 12 of file strip.

12 { leading, trailing, both };

Function Documentation

◆ _4s_to_3s()

template<class T , class I >
T* tools::_4s_to_3s ( const T *  a_4s,
const I &  a_w,
const I &  a_h 
)
inline

Definition at line 126 of file carray.

126  {
127  T* _3s = new T[a_w*a_h*3];
128  if(!_3s) return 0;
129  T* pfrom = (T*)a_4s;
130  T* pto = _3s;
131  {I _sz = a_w*a_h*4;
132  for(I i=0;i<_sz;i+=4) {
133  *(pto+0) = *(pfrom+0);
134  *(pto+1) = *(pfrom+1);
135  *(pto+2) = *(pfrom+2);
136  pfrom += 4;
137  pto += 3;
138  }}
139  return _3s;
140 }

◆ _cid() [1/15]

cid tools::_cid ( bool  )
inline

Definition at line 22 of file cids.

22 {return 9;}

◆ _cid() [2/15]

cid tools::_cid ( byte  )
inline

Definition at line 14 of file cids.

14 {return 1;}

◆ _cid() [3/15]

cid tools::_cid ( char  )
inline

Definition at line 15 of file cids.

15 {return 2;}

◆ _cid() [4/15]

cid tools::_cid ( const std::string &  )
inline

Definition at line 27 of file cids.

27 {return 12;}

◆ _cid() [5/15]

template<class T >
cid tools::_cid ( const std::vector< T > &  )
inline

Definition at line 48 of file cids.

48 {return 20+_cid(T());}

◆ _cid() [6/15]

cid tools::_cid ( csv_time  )
inline

Definition at line 29 of file cids.

29 {return 14;}

◆ _cid() [7/15]

cid tools::_cid ( double  )
inline

Definition at line 21 of file cids.

21 {return 8;}

◆ _cid() [8/15]

cid tools::_cid ( fits_bit  )
inline

Definition at line 28 of file cids.

28 {return 13;}

◆ _cid() [9/15]

cid tools::_cid ( float  )
inline

Definition at line 20 of file cids.

20 {return 7;}

◆ _cid() [10/15]

cid tools::_cid ( int  )
inline

Definition at line 19 of file cids.

19 {return 6;}

◆ _cid() [11/15]

cid tools::_cid ( int64  )
inline

Definition at line 26 of file cids.

26 {return 11;}

◆ _cid() [12/15]

cid tools::_cid ( short  )
inline

Definition at line 17 of file cids.

17 {return 4;}

◆ _cid() [13/15]

cid tools::_cid ( uint64  )
inline

Definition at line 25 of file cids.

25 {return 10;}

◆ _cid() [14/15]

cid tools::_cid ( unsigned int  )
inline

Definition at line 18 of file cids.

18 {return 5;}

◆ _cid() [15/15]

cid tools::_cid ( unsigned short  )
inline

Definition at line 16 of file cids.

16 {return 3;}

◆ _cid_std_vector()

template<class T >
cid tools::_cid_std_vector ( )
inline

Definition at line 51 of file cids.

51  {
52  static const T s_v = T(); //do that for T = std::string.
53  return 20+_cid(s_v);
54 }

◆ _equal()

template<class NUMBER , class PREC >
bool tools::_equal ( std::ostream &  a_out,
const char *  a_file,
int  a_line,
const NUMBER &  a_v,
const NUMBER &  a_expected,
const PREC &  a_tolerance,
PREC(*)(const NUMBER &)  a_fabs 
)
inline

Definition at line 122 of file test.

122  {
123  PREC diff = a_fabs(a_v-a_expected);
124  if(diff>=a_tolerance) {
125  a_out << "failed in file :" << std::endl
126  << a_file << std::endl
127  << "at line :" << std::endl
128  << a_line << std::endl
129  << "value " << a_v << ", expected " << a_expected << ",diff " << diff << std::endl;
130  return false;
131  }
132  return true;
133 }

◆ _WIN32_defined()

bool tools::_WIN32_defined ( )
inline

Definition at line 131 of file platform.

131  {
132 #ifdef _WIN32
133  return true;
134 #else
135  return false;
136 #endif
137 }

◆ add() [1/3]

template<class K , class V >
void tools::add ( std::vector< std::pair< K, V > > &  a_vec,
const K &  a_key,
const V &  a_value 
)
inline

Definition at line 12 of file vpair.

12  {
13  typedef typename std::vector< std::pair<K,V> >::iterator it_t;
14  it_t it;
15  for(it=a_vec.begin();it!=a_vec.end();++it) {
16  if((*it).first==a_key) {
17  (*it).second = a_value; //override.
18  return;
19  }
20  }
21  //not found, add a new pair :
22  a_vec.push_back(std::pair<K,V>(a_key,a_value));
23 }

◆ add() [2/3]

template<class T >
bool tools::add ( std::vector< T > &  a_vec,
const std::vector< T > &  a_v 
)
inline

Definition at line 250 of file vmanip.

250  {
251  if(a_vec.size()!=a_v.size()) return false;
252  typedef typename std::vector<T>::iterator it_t;
253  typedef typename std::vector<T>::const_iterator cit_t;
254  it_t it = a_vec.begin();
255  cit_t vit = a_v.begin();
256  for(;it!=a_vec.end();++it,++vit) *it += *vit;
257  return true;
258 }

◆ add() [3/3]

template<class T >
void tools::add ( std::vector< T > &  a_vec,
const T &  a_v 
)
inline

Definition at line 312 of file vmanip.

312  {
313  typedef typename std::vector<T>::iterator it_t;
314  for(it_t it=a_vec.begin();it!=a_vec.end();++it) *it += a_v;
315 }

◆ add_unique()

template<class K , class V >
bool tools::add_unique ( std::map< K, V * > &  a_map,
const K &  a_key,
V *  a_value,
bool  a_delete 
)
inline

Definition at line 72 of file mapmanip.

72  {
73  typedef typename std::map<K,V*>::iterator it_t;
74  it_t it = a_map.find(a_key);
75  if(it==a_map.end()) {a_map[a_key] = a_value;return false;} //false=was not found.
76  if(a_delete) {
77  V* entry = (*it).second;
78  a_map.erase(it);
79  delete entry;
80  }
81  a_map[a_key] = a_value;
82  return true;
83 }

◆ anticommutator() [1/3]

template<class MAT >
MAT tools::anticommutator ( const MAT &  a1,
const MAT &  a2 
)
inline

Definition at line 315 of file mat.

315  {
316  return a1*a2+a2*a1;
317 }

◆ anticommutator() [2/3]

template<class MAT >
void tools::anticommutator ( const MAT &  a1,
const MAT &  a2,
MAT &  a_tmp,
MAT &  a_res 
)
inline

Definition at line 338 of file mat.

338  {
339  a_res = a1;
340  a_res *= a2;
341  a_tmp = a2;
342  a_tmp *= a1;
343  a_res += a_tmp;
344 }

◆ anticommutator() [3/3]

template<class MAT , class T >
void tools::anticommutator ( const MAT &  a1,
const MAT &  a2,
MAT &  a_tmp,
a_vtmp[],
MAT &  a_res 
)
inline

Definition at line 347 of file mat.

347  {
348  a_res = a1;
349  a_res.mul_mtx(a2,a_vtmp);
350  a_tmp = a2;
351  a_tmp.mul_mtx(a1,a_vtmp);
352  a_res += a_tmp;
353 }

◆ anticommutator_equal()

template<class T , unsigned int D>
bool tools::anticommutator_equal ( const mat< T, D > &  a_1,
const mat< T, D > &  a_2,
const mat< T, D > &  a_c,
const T &  a_prec 
)
inline

Definition at line 380 of file mat.

380  {
381  unsigned int order = D;
382  const T* p1 = a_1.data();
383  const T* p2 = a_2.data();
384  const T* pc = a_c.data();
385  for(unsigned int r=0;r<order;r++) {
386  for(unsigned int c=0;c<order;c++) {
387  T _12 = T();
388  {for(unsigned int i=0;i<order;i++) {
389  _12 += (*(p1+r+i*order)) * (*(p2+i+c*order));
390  }}
391  T _21 = T();
392  {for(unsigned int i=0;i<order;i++) {
393  _21 += (*(p2+r+i*order)) * (*(p1+i+c*order));
394  }}
395  T diff = (_12+_21) - *(pc+r+c*order);
396  if(diff<T()) diff *= T(-1);
397  if(diff>=a_prec) return false;
398  }
399  }
400  return true;
401 }

◆ app_res_dir()

void tools::app_res_dir ( const std::string &  a_exe_path,
std::string &  a_res_dir 
)
inline

Definition at line 185 of file app.

185  {
186  a_res_dir = a_exe_path+sep()+".."+sep()+"res";
187 }

◆ append() [1/2]

template<class T >
void tools::append ( std::vector< T > &  a_vec,
const std::vector< T > &  a_from 
)
inline

Definition at line 66 of file vmanip.

66  {
67  typedef typename std::vector<T>::size_type sz_t;
68  sz_t number = a_from.size();
69  sz_t offset = a_vec.size();
70  a_vec.resize(offset+number);
71  for(sz_t index=0;index<number;index++,offset++) {
72  a_vec[offset] = a_from[index];
73  }
74 }

◆ append() [2/2]

template<class T >
void tools::append ( std::vector< T > &  a_vec,
typename std::vector< T >::size_type  a_num,
const T *  a_from 
)
inline

Definition at line 77 of file vmanip.

77  {
78  typedef typename std::vector<T>::size_type sz_t;
79  sz_t vsize = a_vec.size();
80  a_vec.resize(vsize+a_num);
81  sz_t offset = vsize;
82  for(sz_t index=0;index<a_num;index++,offset++) {
83  a_vec[offset] = a_from[index];
84  }
85 }

◆ area() [1/2]

template<class VEC3 >
void tools::area ( const VEC3 &  a_p0,
const VEC3 &  a_p1,
const VEC3 &  a_p2,
typename VEC3::elem_t &  a_value 
)
inline

Definition at line 371 of file vec3.

371  {
372  VEC3 tmp1,tmp2,tmp3;
373  area(a_p0,a_p1,a_p2,a_value,tmp1,tmp2,tmp3);
374 }

◆ area() [2/2]

template<class VEC3 >
void tools::area ( const VEC3 &  a_p0,
const VEC3 &  a_p1,
const VEC3 &  a_p2,
typename VEC3::elem_t &  a_value,
VEC3 &  a_tmp_1,
VEC3 &  a_tmp_2,
VEC3 &  a_tmp_3 
)
inline

Definition at line 354 of file vec3.

355  {
356  // area of the triangle (a_p0,a_p1,a_p2)
357  typedef typename VEC3::elem_t T;
358 
359  a_tmp_1 = a_p1;
360  a_tmp_1.subtract(a_p0);
361 
362  a_tmp_2 = a_p2;
363  a_tmp_2.subtract(a_p1);
364 
365  a_tmp_1.cross(a_tmp_2,a_tmp_3);
366 
367  a_value = a_tmp_3.length()/T(2);
368 }

◆ b2s() [1/2]

void tools::b2s ( bool  a_value,
std::string &  a_s 
)
inline

Definition at line 11 of file b2s.

11  {
12  a_s = a_value?"true":"false";
13 }

◆ b2s() [2/2]

void tools::b2s ( const std::vector< bool > &  a_vals,
std::string &  a_s,
const std::string &  a_sep = "\n",
bool  a_sep_at_end = false 
)
inline

Definition at line 25 of file b2s.

25  {
26  a_s.clear();
27  size_t number = a_vals.size();
28  if(number<=0) return;
29  number--;
30  std::string stmp;
31  for(size_t index=0;index<number;index++) {
32  b2s(a_vals[index],stmp);
33  a_s += stmp;
34  a_s += a_sep;
35  }
36  b2s(a_vals[number],stmp);
37  a_s += stmp;
38  if(a_sep_at_end) a_s += a_sep;
39 }

◆ bas()

void tools::bas ( bool  a_value,
std::string &  a_s 
)
inline

Definition at line 15 of file b2s.

15  {
16  a_s += (a_value?"true":"false");
17 }

◆ base_name() [1/2]

std::string tools::base_name ( const std::string &  a_path)
inline

Definition at line 100 of file path.

100  { //deprecated.
101  std::string value;
102  base_name(a_path,value);
103  return value;
104 }

◆ base_name() [2/2]

void tools::base_name ( const std::string &  a_path,
std::string &  a_value 
)
inline

Definition at line 54 of file path.

54  {
55  std::string::size_type pos_slash = a_path.rfind('/');
56  std::string::size_type pos_bslash = a_path.rfind('\\');
57  std::string::size_type pos = 0;
58  if(pos_slash==std::string::npos) {
59  if(pos_bslash==std::string::npos) {
60  pos = std::string::npos;
61  } else {
62  pos = pos_bslash;
63  }
64  } else {
65  if(pos_bslash==std::string::npos) {
66  pos = pos_slash;
67  } else {
68  if(pos_slash<=pos_bslash) {
69  pos = pos_bslash;
70  } else {
71  pos = pos_slash;
72  }
73  }
74  }
75  if(pos==std::string::npos) {a_value = a_path;return;}
76  pos++;
77  a_value = a_path.substr(pos,a_path.size()-pos);
78 }

◆ beg_LC_NUMERIC()

char* tools::beg_LC_NUMERIC ( )
inline

Definition at line 221 of file cstr.

221  {
222  char* _sl = ::setlocale(LC_NUMERIC,0);
223  char* old = _sl?str_dup(_sl):0;
224  ::setlocale(LC_NUMERIC,"C");
225  return old;
226 }

◆ belong() [1/2]

bool tools::belong ( const std::string &  a_string,
char  a_c 
)
inline

Definition at line 11 of file schar.

11  {
12  std::string::const_iterator it;
13  for(it=a_string.begin();it!=a_string.end();++it) {
14  if((*it)==a_c) return true;
15  }
16  return false;
17 }

◆ belong() [2/2]

template<class T >
bool tools::belong ( const std::vector< T > &  a_vec,
const T &  a_item 
)
inline

Definition at line 193 of file vmanip.

193  {
194  typedef typename std::vector<T>::const_iterator it_t;
195  it_t it;
196  for(it=a_vec.begin();it!=a_vec.end();++it) {
197  if(*it==a_item) return true;
198  }
199  return false;
200 }

◆ box_3f_extend_by()

void tools::box_3f_extend_by ( float &  a_mn_x,
float &  a_mn_y,
float &  a_mn_z,
float &  a_mx_x,
float &  a_mx_y,
float &  a_mx_z,
float  a_x,
float  a_y,
float  a_z 
)
inline

Definition at line 24 of file box_3f.

26  {
27  if(a_mx_x<a_mn_x){ //is empty.
28  a_mn_x = a_x;
29  a_mn_y = a_y;
30  a_mn_z = a_z;
31 
32  a_mx_x = a_x;
33  a_mx_y = a_y;
34  a_mx_z = a_z;
35  } else {
36  a_mn_x = mn<float>(a_x,a_mn_x);
37  a_mn_y = mn<float>(a_y,a_mn_y);
38  a_mn_z = mn<float>(a_z,a_mn_z);
39 
40  a_mx_x = mx<float>(a_x,a_mx_x);
41  a_mx_y = mx<float>(a_y,a_mx_y);
42  a_mx_z = mx<float>(a_z,a_mx_z);
43  }
44 }

◆ box_3f_is_empty()

bool tools::box_3f_is_empty ( float  a_mn_x,
float  a_mx_x 
)
inline

Definition at line 45 of file box_3f.

45  {
46  return a_mx_x < a_mn_x;
47 }

◆ box_3f_make_empty()

void tools::box_3f_make_empty ( float &  a_mn_x,
float &  a_mn_y,
float &  a_mn_z,
float &  a_mx_x,
float &  a_mx_y,
float &  a_mx_z 
)
inline

Definition at line 15 of file box_3f.

16  {
17  a_mn_x = FLT_MAX;
18  a_mn_y = FLT_MAX;
19  a_mn_z = FLT_MAX;
20  a_mx_x = -FLT_MAX;
21  a_mx_y = -FLT_MAX;
22  a_mx_z = -FLT_MAX;
23 }

◆ buf2lines() [1/2]

void tools::buf2lines ( char *  a_buffer,
std::vector< std::string > &  a_lines 
)
inline

Definition at line 12 of file buf2lines.

12  {
13  // WARNING : it is assumed that last char of a_buffer is 0.
14  // This function seeks '\n' and replaces them with '0'.
15  a_lines.clear();
16  char* pos = a_buffer;
17  char* beg = pos;
18  while(true) {
19  if((*pos=='\r')&&(*(pos+1)=='\n')) {
20  *pos = 0;
21  a_lines.push_back(beg);
22  pos += 2;
23  beg = pos;
24  } else if(*pos=='\n') {
25  *pos = 0;
26  a_lines.push_back(beg);
27  pos++;
28  beg = pos;
29  } else if(*pos==0) {
30  a_lines.push_back(beg);
31  return;
32  } else {
33  pos++;
34  }
35  }
36 }

◆ buf2lines() [2/2]

void tools::buf2lines ( size_t  a_size,
const char *  a_buffer,
std::vector< std::string > &  a_lines 
)
inline

Definition at line 38 of file buf2lines.

38  {
39  a_lines.clear();
40  if(!a_size) return;
41  std::string line;
42  char* pos = (char*)a_buffer;
43  const char* end = a_buffer+a_size-1;
44  while(true) {
45  if(pos>end) {
46  if(line.size()) a_lines.push_back(line);
47  return;
48  }
49  if((*pos=='\r')&&((pos+1)<=end)&&(*(pos+1)=='\n')) {
50  a_lines.push_back(line);
51  line.clear();
52  pos += 2;
53  } else if(*pos=='\n') {
54  a_lines.push_back(line);
55  line.clear();
56  pos++;
57  } else {
58  line += *pos;
59  pos++;
60  }
61  }
62 }

◆ buf2strings()

bool tools::buf2strings ( size_t  a_size,
char *  a_buffer,
std::vector< std::string > &  a_strings 
)
inline

Definition at line 116 of file buf2lines.

116  {
117  if(a_size<=1) return false;
118  // We assume here a_size>=1
119  // Exa : if ab0cde00, then a_strings should contain two strings ab and cde.
120  a_strings.clear();
121  char* begin = a_buffer;
122  char* pos = a_buffer;
123  size_t number = a_size-1;
124  for(size_t index=0;index<number;index++) {
125  if((*pos)=='\0') {
126  size_t l = pos - begin;
127  std::string s(l,0);
128  char* data = (char*)s.c_str();
129  ::memcpy(data,begin,l);
130  a_strings.push_back(s);
131  begin = pos+1;
132  }
133  pos++;
134  }
135  //pos++;
136  return true;
137 }

◆ carray_copy()

template<class T , class I >
bool tools::carray_copy ( T *&  a_v,
a_n,
const T *  a_from 
)
inline

Definition at line 18 of file carray.

18  {
19  delete [] a_v;
20  a_v = 0;
21  if(a_n) {
22  a_v = new T[a_n];
23  if(!a_v) return false;
24  }
25  for(I i=0;i<a_n;i++) a_v[i] = a_from[i];
26  return true;
27 }

◆ center_adjust() [1/2]

bool tools::center_adjust ( std::ostream &  a_out,
sg::node a_node,
sg::matrix a_tsf,
unsigned int  a_ww,
unsigned int  a_wh,
float  a_height,
bool  a_verbose = true 
)
inline

Definition at line 95 of file mnmx.

98  {
99  float dx,dy,dz;
100  return center_adjust(a_out,a_node,a_tsf,a_ww,a_wh,a_height,
101  dx,dy,dz,a_verbose);
102 }

◆ center_adjust() [2/2]

bool tools::center_adjust ( std::ostream &  a_out,
sg::node a_node,
sg::matrix a_tsf,
unsigned int  a_ww,
unsigned int  a_wh,
float  a_height,
float &  a_dx,
float &  a_dy,
float &  a_dz,
bool  a_verbose = true 
)
inline

Definition at line 34 of file mnmx.

39  {
40  //NOTE : we assume an ortho camera.
41  if(!a_ww||!a_wh) {
42  if(a_verbose) {
43  a_out << "tools::center_adjust :"
44  << " null viewer width or height."
45  << std::endl;
46  }
47  a_dx = 0;a_dy = 0;a_dz = 0;
48  return false;
49  }
50  sg::bbox_action _action(a_out);
51  a_node.bbox(_action);
52  if(!_action.box().get_size(a_dx,a_dy,a_dz)) {
53  if(a_verbose) {
54  a_out << "tools::center_adjust :"
55  << " empty box."
56  << std::endl;
57  }
58  a_dx = 0;a_dy = 0;a_dz = 0;
59  return false;
60  }
61  if(!a_dx||!a_dy) {
62  if(a_verbose) {
63  a_out << "tools::center_adjust :"
64  << " dx or dy null."
65  << std::endl;
66  }
67  a_dx = 0;a_dy = 0;a_dz = 0;
68  return false;
69  }
70  vec3f c;
71  if(!_action.box().center(c)) {
72  if(a_verbose) {
73  a_out << "tools::center_adjust :"
74  << " can't get box center."
75  << std::endl;
76  }
77  a_dx = 0;a_dy = 0;a_dz = 0;
78  return false;
79  }
80  float vp_aspect = float(a_ww)/float(a_wh);
81  float scene_aspect = float(a_dx)/float(a_dy);
82  //::printf("debug : set_tsf : %d %d : %g %g %g : %g %g\n",
83  // a_ww,a_wh,a_dx,a_dy,a_dz,vp_aspect,scene_aspect);
84  float scale;
85  if(vp_aspect>=scene_aspect) {
86  scale = a_height/a_dy;
87  } else {
88  scale = (vp_aspect*a_height)/a_dx;
89  }
90  a_tsf.set_scale(scale,scale,scale);
91  a_tsf.mul_translate(-c.x(),-c.y(),0);
92  return true;
93 }

◆ check_args()

bool tools::check_args ( const std::vector< std::string > &  a_args,
unsigned int  a_number,
std::ostream &  a_out 
)
inline

Definition at line 458 of file args.

458  {
459  if(a_args.size()==a_number) return true;
460  a_out << "bad argument number."
461  << " Given " << (unsigned int)a_args.size()
462  << " whilst " << a_number << " expected."
463  << std::endl;
464  return false;
465 }

◆ check_invert()

template<class MAT >
bool tools::check_invert ( const MAT &  a_matrix,
std::ostream &  a_out 
)
inline

Definition at line 660 of file mat.

660  {
661  MAT I;I.set_identity();
662  MAT tmp;
663  if(!a_matrix.invert(tmp)) return false;
664  tmp.mul_mtx(a_matrix);
665  if(!tmp.equal(I)) {
666  dump(a_out,"problem with inv of :",a_matrix);
667  return false;
668  }
669  return true;
670 }

◆ check_min()

bool tools::check_min ( const std::vector< std::string > &  a_args,
unsigned int  a_number,
std::string &  a_last,
std::ostream &  a_out 
)
inline

Definition at line 467 of file args.

467  {
468  if(a_args.size()>=a_number) {
469  if(a_number==0) {
470  if(a_args.empty()) {
471  a_last.clear();
472  } else {
473  a_last = a_args[0];
474  for(size_t index=1;index<a_args.size();index++) a_last += " " + a_args[index];
475  }
476  } else {
477  a_last = a_args[a_number-1];
478  for(size_t index=a_number;index<a_args.size();index++) a_last += " " + a_args[index];
479  }
480  return true;
481  }
482  a_out << "bad argument number."
483  << " Given " << (unsigned int)a_args.size()
484  << " whilst at least " << a_number << " expected."
485  << std::endl;
486  return false;
487 }

◆ check_min_args()

bool tools::check_min_args ( const std::vector< std::string > &  aArgs,
unsigned int  a_number,
std::ostream &  a_out 
)
inline

Definition at line 489 of file args.

489  {
490  if(aArgs.size()>=a_number) return true;
491  a_out << "bad argument number."
492  << " Given " << (unsigned int)aArgs.size()
493  << " whilst at least " << a_number << " expected."
494  << std::endl;
495  return false;
496 }

◆ check_or_args()

bool tools::check_or_args ( const std::vector< std::string > &  aArgs,
unsigned int  a_1,
unsigned int  a_2,
std::ostream &  a_out 
)
inline

Definition at line 498 of file args.

498  {
499  if((aArgs.size()==a_1)||(aArgs.size()==a_2)) return true;
500  a_out << "bad argument number."
501  << " Given " << (unsigned int)aArgs.size()
502  << " whilst " << a_1 << " or " << a_2 << " expected."
503  << std::endl;
504  return false;
505 }

◆ cid2s()

bool tools::cid2s ( cid  a_id,
std::string &  a_s 
)
inline

Definition at line 66 of file cids.

66  {
67  // NOTE : the returned string must not contain space.
68 
69  if(a_id==_cid(char(0))) {a_s = "char";return true;}
70  else if(a_id==_cid(short(0))) {a_s = "short";return true;}
71  else if(a_id==_cid(int(0))) {a_s = "int";return true;}
72  else if(a_id==_cid(float(0))) {a_s = "float";return true;}
73  else if(a_id==_cid(double(0))) {a_s = "double";return true;}
74  else if(a_id==_cid(std::string())) {a_s = "string";return true;}
75 
76  // NOTE : the below do not follow the AIDA convention.
77  else if(a_id==_cid((unsigned char)0)) {a_s = "uchar";return true;} //AIDA=byte
78  else if(a_id==_cid((unsigned short)0)) {a_s = "ushort";return true;} //AIDA not defined
79  else if(a_id==_cid((unsigned int)0)) {a_s = "uint";return true;} //AIDA not defined
80  else if(a_id==_cid(bool(true))) {a_s = "bool";return true;} //AIDA=boolean
81  else if(a_id==_cid(int64(0))) {a_s = "int64";return true;} //AIDA=long
82  else if(a_id==_cid(uint64(0))) {a_s = "uint64";return true;} //AIDA=not defined
83 
84  else if(a_id==_cid_std_vector<char>()) {a_s = "char[]";return true;}
85  else if(a_id==_cid_std_vector<short>()) {a_s = "short[]";return true;}
86  else if(a_id==_cid_std_vector<int>()) {a_s = "int[]";return true;}
87  else if(a_id==_cid_std_vector<float>()) {a_s = "float[]";return true;}
88  else if(a_id==_cid_std_vector<double>()) {a_s = "double[]";return true;}
89  else if(a_id==_cid_std_vector<std::string>()) {a_s = "string[]";return true;}
90 
91  else if(a_id==_cid_std_vector<unsigned char>()) {a_s = "uchar[]";return true;}
92  else if(a_id==_cid_std_vector<unsigned short>()) {a_s = "ushort[]";return true;}
93  else if(a_id==_cid_std_vector<unsigned int>()) {a_s = "uint[]";return true;}
94  else if(a_id==_cid_std_vector<bool>()) {a_s = "bool[]";return true;}
95  else if(a_id==_cid_std_vector<int64>()) {a_s = "int64[]";return true;}
96  else if(a_id==_cid_std_vector<uint64>()) {a_s = "uint64[]";return true;}
97 
98  a_s.clear();
99  return false;
100 }

◆ cmem_alloc()

template<class T >
T* tools::cmem_alloc ( size_t  a_num)
inline

Definition at line 26 of file cmemT.

26  {
27  if(a_num<=0) return 0;
28  T* p = (T*)::malloc(a_num*sizeof(T));
29  if(!p) return 0;
30 #ifdef TOOLS_MEM
31  mem::increment("cmem");
32 #endif
33  return p;
34 }

◆ cmem_alloc_copy()

template<class T >
T* tools::cmem_alloc_copy ( const T *  a_from,
size_t  a_num 
)
inline

Definition at line 37 of file cmemT.

37  {
38  if(a_num<=0) return 0;
39  T* p = (T*)::malloc(a_num*sizeof(T));
40  if(!p) return 0;
41 #ifdef TOOLS_MEM
42  mem::increment("cmem");
43 #endif
44  //::memcpy(p,a_from,a_num*sizeof(T));
45  for(size_t i=0;i<a_num;i++) p[i] = a_from[i];
46  return p;
47 }

◆ cmem_free()

template<class T >
void tools::cmem_free ( T *&  a_p)
inline

Definition at line 16 of file cmemT.

16  {
17  if(!a_p) return;
18  ::free(a_p);
19  a_p = NULL;
20 #ifdef TOOLS_MEM
21  mem::decrement("cmem");
22 #endif
23 }

◆ cmp()

template<class T >
bool tools::cmp ( std::ostream &  a_out,
const T &  a_what,
const T &  a_ref,
const T &  a_error = T() 
)
inline

Definition at line 12 of file cmp.

14  {
15  if(a_what>a_ref) {
16  if((a_what-a_ref)>a_error) {
17  a_out << a_ref << " expected. Got " << a_what << std::endl;
18  return false;
19  }
20  } else {
21  if((a_ref-a_what)>a_error) {
22  a_out << a_ref << " expected. Got " << a_what << std::endl;
23  return false;
24  }
25  }
26  return true;
27 }

◆ cmp_cast() [1/2]

template<class TO >
void* tools::cmp_cast ( const TO *  a_this,
cid  a_id 
)
inline

Definition at line 21 of file scast.

21  {
22  if(TO::id_class()!=a_id) return 0;
23  return (void*)static_cast<const TO*>(a_this);
24 }

◆ cmp_cast() [2/2]

template<class TO >
void* tools::cmp_cast ( const TO *  a_this,
const std::string &  a_class 
)
inline

Definition at line 15 of file scast.

15  {
16  if(!rcmp(a_class,TO::s_class())) return 0;
17  return (void*)static_cast<const TO*>(a_this);
18 }

◆ colorf_default()

const colorf& tools::colorf_default ( )
inline

Definition at line 161 of file colorf.

161 {static const colorf s_v(0.8f,0.8f,0.8f,1);return s_v;}

◆ commutator() [1/3]

template<class MAT >
MAT tools::commutator ( const MAT &  a1,
const MAT &  a2 
)
inline

Definition at line 310 of file mat.

310  {
311  return a1*a2-a2*a1;
312 }

◆ commutator() [2/3]

template<class MAT >
void tools::commutator ( const MAT &  a1,
const MAT &  a2,
MAT &  a_tmp,
MAT &  a_res 
)
inline

Definition at line 320 of file mat.

320  {
321  a_res = a1;
322  a_res *= a2;
323  a_tmp = a2;
324  a_tmp *= a1;
325  a_res -= a_tmp;
326 }

◆ commutator() [3/3]

template<class MAT , class T >
void tools::commutator ( const MAT &  a1,
const MAT &  a2,
MAT &  a_tmp,
a_vtmp[],
MAT &  a_res 
)
inline

Definition at line 329 of file mat.

329  {
330  a_res = a1;
331  a_res.mul_mtx(a2,a_vtmp);
332  a_tmp = a2;
333  a_tmp.mul_mtx(a1,a_vtmp);
334  a_res -= a_tmp;
335 }

◆ commutator_equal()

template<class T , unsigned int D>
bool tools::commutator_equal ( const mat< T, D > &  a_1,
const mat< T, D > &  a_2,
const mat< T, D > &  a_c,
const T &  a_prec 
)
inline

Definition at line 356 of file mat.

356  {
357  unsigned int order = D;
358  const T* p1 = a_1.data();
359  const T* p2 = a_2.data();
360  const T* pc = a_c.data();
361  for(unsigned int r=0;r<order;r++) {
362  for(unsigned int c=0;c<order;c++) {
363  T _12 = T();
364  {for(unsigned int i=0;i<order;i++) {
365  _12 += (*(p1+r+i*order)) * (*(p2+i+c*order));
366  }}
367  T _21 = T();
368  {for(unsigned int i=0;i<order;i++) {
369  _21 += (*(p2+r+i*order)) * (*(p1+i+c*order));
370  }}
371  T diff = (_12-_21) - *(pc+r+c*order);
372  if(diff<T()) diff *= T(-1);
373  if(diff>=a_prec) return false;
374  }
375  }
376  return true;
377 }

◆ compiler()

void tools::compiler ( char  a_s[128])
inline

Definition at line 198 of file platform.

198  {
199  char* pos = a_s;
200  unsigned int l;
201  toss(compiler_name(),pos,l);pos += l;
202 
203 #if defined(__clang__)
204  *pos = '_';pos++;
205  tosu<unsigned int>(__clang_major__,pos,l);pos += l;
206  tosu<unsigned int>(__clang_minor__,pos,l);pos += l;
207  tosu<unsigned int>(__clang_patchlevel__,pos,l);pos += l;
208 #elif defined(__GNUC__)
209  *pos = '_';pos++;
210  tosu<unsigned int>(__GNUC__,pos,l);pos += l;
211  tosu<unsigned int>(__GNUC_MINOR__,pos,l);pos += l;
212  tosu<unsigned int>(__GNUC_PATCHLEVEL__,pos,l);pos += l;
213 #elif defined(_MSC_VER)
214  *pos = '_';pos++;
215  tosu<unsigned int>(_MSC_VER,pos,l);pos += l;
216  //_mfc_
217  //tosu<unsigned int>(_MFC_VER,pos,l);pos += l;
218 #elif defined(__alpha)
219 #else
220 #endif
221  *pos = 0;
222 }

◆ compiler_name()

const char* tools::compiler_name ( )
inline

Definition at line 176 of file platform.

176  {
177 
178 #if defined(__clang__)
179  static const char s_s[] = "clang";
180 #elif defined(__GNUC__)
181  static const char s_s[] = "gcc";
182 #elif defined(_MSC_VER)
183  static const char s_s[] = "cl";
184 #elif defined(__alpha)
185  static const char s_s[] = "cxx";
186 #else
187  static const char s_s[] = "unknown";
188 #endif
189  return s_s;
190 }

◆ compress_buffer()

bool tools::compress_buffer ( std::ostream &  a_out,
unsigned int  a_level,
unsigned int  a_srcsize,
const char *  a_src,
unsigned int  a_tgtsize,
char *  a_tgt,
unsigned int &  a_irep 
)
inline

Definition at line 22 of file zlib.

26  {
27 
28  z_stream stream; // decompression stream
29 
30  stream.next_in = (Bytef*)(a_src);
31  stream.avail_in = (uInt)(a_srcsize);
32  stream.next_out = (Bytef*)a_tgt;
33  stream.avail_out = (uInt)(a_tgtsize);
34  stream.zalloc = (alloc_func)0;
35  stream.zfree = (free_func)0;
36  stream.opaque = (voidpf)0;
37  stream.total_in = 0; /*to quiet Coverity.*/
38  stream.total_out = 0; /*to quiet Coverity.*/
39 
40  int err = deflateInit(&stream,a_level);
41  if(err!=Z_OK) {
42  a_out << "tools::compress_buffer :"
43  << " error in zlib/deflateInit." << std::endl;
44  a_irep = 0;
45  return false;
46  }
47 
48  err = deflate(&stream, Z_FINISH);
49  if(err!=Z_STREAM_END) {
50  deflateEnd(&stream);
51  a_out << "tools::compress_buffer :"
52  << " error in zlib/deflate." << std::endl;
53  a_irep = 0;
54  return false;
55  }
56 
57  deflateEnd(&stream);
58 
59  //a_out << "tools::compress_buffer : ok "
60  // << stream.total_out << std::endl;
61 
62  a_irep = stream.total_out;
63 
64  return true;
65 }

◆ conjugate()

template<class MAT >
void tools::conjugate ( MAT &  a_m,
typename MAT::elem_t(*)(const typename MAT::elem_t &)  a_conj 
)
inline

related to complex numbers : //////////////////////////////////////////////////////

Definition at line 186 of file mat.

186  {
187  typedef typename MAT::elem_t T;
188  T* pos = const_cast<T*>(a_m.data());
189  unsigned int D2 = a_m.dimension()*a_m.dimension();
190  for(unsigned int i=0;i<D2;i++,pos++) {
191  *pos = a_conj(*pos); //T = std::complex<>
192  }
193 }

◆ contract()

template<class T >
bool tools::contract ( const array< T > &  aA,
unsigned int  aIA,
const array< T > &  aB,
unsigned int  aIB,
array< T > &  aR 
)
inline

Definition at line 389 of file array.

395  {
396  // Contract a tensor (aA) with a vector (aB)
397  // on indice aIA of aA and aIB of aB.
398  // aA.dimension must be > 1.
399  // aB.dimension must be > 1.
400  if(&aR==&aA) return false;
401  if(&aR==&aB) return false;
402 
403  if(aA.dimension()==0) return false;
404  if(aB.dimension()==0) return false;
405  if(aIA>=aA.dimension()) return false;
406  if(aIB>=aB.dimension()) return false;
407  if(aA.orders()[aIA]!=aB.orders()[aIB]) return false;
408 
409  unsigned int rdima = aA.dimension()-1;
410  unsigned int rdimb = aB.dimension()-1;
411 
412  if((rdima+rdimb)==0) {
413  std::vector<unsigned int> rorders(1);
414  rorders[0] = 1;
415  if(!aR.configure(rorders)) return false;
416  const std::vector<T>& vA = aA.vector();
417  const std::vector<T>& vB = aB.vector();
418  T value = array<T>::zero();
419  for(unsigned int index=0;index<vA.size();index++) {
420  value += vA[index]*vB[index];
421  }
422  aR.vector()[0] = value;
423  return true;
424  }
425 
426  std::vector<unsigned int> rorders(rdima+rdimb);
427  unsigned int index;
428  for(index=0;index<aIA;index++)
429  rorders[index] = aA.orders()[index];
430  for(index=aIA;index<rdima;index++)
431  rorders[index] = aA.orders()[index+1];
432 
433  for(index=0;index<aIB;index++)
434  rorders[rdima+index] = aB.orders()[index];
435  for(index=aIB;index<rdimb;index++)
436  rorders[rdima+index] = aB.orders()[index+1];
437 
438  if(!aR.configure(rorders)) return false;
439 
440  std::vector<unsigned int> ais(aA.dimension());
441  std::vector<unsigned int> bis(aB.dimension());
442  std::vector<unsigned int> ris(aR.dimension());
443 
444  //FIXME : optimize the below.
445  unsigned int order = aA.orders()[aIA];
446  unsigned int rsize = aR.size();
447 
448  std::vector<T>& rvec = aR.vector();
449 
450  for(unsigned int roffset=0;roffset<rsize;roffset++) {
451  if(!aR.indices(roffset,ris)) return false;
452 
453  for(index=0;index<aIA;index++) ais[index] = ris[index];
454  for(index=aIA;index<rdima;index++) ais[index+1] = ris[index];
455 
456  for(index=0;index<aIB;index++) bis[index] = ris[rdima+index];
457  for(index=aIB;index<rdimb;index++) bis[index+1] = ris[rdima+index];
458 
459  T value = 0;
460  for(index=0;index<order;index++) {
461  ais[aIA] = index;
462  T av;
463  if(!aA.value(ais,av)) return false;
464 
465  bis[aIB] = index;
466  T bv;
467  if(!aB.value(bis,bv)) return false;
468 
469  value += av * bv;
470  }
471 
472  rvec[roffset] = value;
473  }
474 
475  return true;
476 }

◆ convert()

template<class FROM , class TO >
void tools::convert ( const std::vector< FROM > &  a_from,
std::vector< TO > &  a_to 
)
inline

Definition at line 350 of file vmanip.

350  {
351  typedef typename std::vector<FROM>::const_iterator const_it_t;
352  typedef typename std::vector<TO>::iterator it_t;
353  a_to.resize(a_from.size());
354  const_it_t ait = a_from.begin();
355  it_t toit = a_to.begin();
356  for(;ait!=a_from.end();++ait,++toit) {*toit = (TO)*ait;}
357 }

◆ copy() [1/4]

template<class T , unsigned int D>
nmat<T> tools::copy ( const mat< T, D > &  a_from)
inline

Definition at line 159 of file mat.

159  {
160  unsigned int D2 = D*D;
161  nmat<T> v(D);
162  for(unsigned int i=0;i<D2;i++) v[i] = a_from[i];
163  return v;
164 }

◆ copy() [2/4]

template<class K , class V >
void tools::copy ( std::map< K, V * > &  a_to,
const std::map< K, V * > &  a_from 
)
inline

Definition at line 63 of file mapmanip.

63  {
64  raw_clear<K,V>(a_to);
65  typedef typename std::map<K,V*>::const_iterator it_t;
66  for(it_t it=a_from.begin();it!=a_from.end();++it) {
67  a_to[(*it).first] = (*it).second->copy();
68  }
69 }

◆ copy() [3/4]

template<class T >
void tools::copy ( std::vector< T * > &  a_to,
const std::vector< T * > &  a_from 
)
inline

Definition at line 54 of file vmanip.

54  {
55  raw_clear<T>(a_to);
56  typedef typename std::vector<T*>::const_iterator it_t;
57  for(it_t it = a_from.begin();it!=a_from.end();++it) {
58  a_to.push_back((*it)->copy());
59  }
60 }

◆ copy() [4/4]

template<class T , class I >
bool tools::copy ( T *&  a_v,
a_n,
const T *  a_from 
)
inline

Definition at line 30 of file carray.

30 {return carray_copy<T,I>(a_v,a_n,a_from);}

◆ CR()

char tools::CR ( )
inline

Definition at line 17 of file chars.

17 {return 13;}

◆ dagger()

template<class MAT >
void tools::dagger ( MAT &  a_m,
typename MAT::elem_t(*)(const typename MAT::elem_t &)  a_conj 
)
inline

Definition at line 248 of file mat.

248  {
249  conjugate<MAT>(a_m,a_conj);
250  a_m.transpose();
251 }

◆ dconj()

double tools::dconj ( const double &  a_x)
inline

Definition at line 66 of file mathd.

66 {return a_x;}

◆ dcos()

double tools::dcos ( const double &  a_x)
inline

Definition at line 60 of file mathd.

60 {return ::cos(a_x);}

◆ dcosh()

double tools::dcosh ( const double &  a_x)
inline

Definition at line 63 of file mathd.

63 {return ::cosh(a_x);}

◆ decomplex() [1/2]

template<class CMAT , class RMAT >
bool tools::decomplex ( const CMAT &  a_c,
RMAT &  a_r,
typename CMAT::elem_t::value_type(*)(const typename CMAT::elem_t &)  a_real,
typename CMAT::elem_t::value_type(*)(const typename CMAT::elem_t &)  a_imag 
)
inline

Definition at line 254 of file mat.

256  {
257  // CMAT = X+iY
258  // RMAT = | X Y |
259  // | -Y X |
260  typedef typename CMAT::elem_t CT; //std::complex<double>
261  typedef typename RMAT::elem_t RT; //double
262 
263  unsigned int cdim = a_c.dimension();
264  if(a_r.dimension()!=2*cdim) {a_r.set_zero();return false;}
265  RT value;unsigned int r,c;
266  for(r=0;r<cdim;r++) {
267  for(c=0;c<cdim;c++) {
268  const CT& cvalue = a_c.value(r,c);
269  value = a_real(cvalue);
270  a_r.set_value(r,c,value);
271  a_r.set_value(r+cdim,c+cdim,value);
272  value = a_imag(cvalue);
273  a_r.set_value(r,c+cdim,value);
274  a_r.set_value(r+cdim,c,-value);
275  }
276  }
277  return true;
278 }

◆ decomplex() [2/2]

template<class VEC_CMAT , class VEC_RMAT >
bool tools::decomplex ( const VEC_CMAT &  a_vc,
VEC_RMAT &  a_vr,
typename VEC_CMAT::value_type::elem_t::value_type(*)(const typename VEC_CMAT::value_type::elem_t &)  a_real,
typename VEC_CMAT::value_type::elem_t::value_type(*)(const typename VEC_CMAT::value_type::elem_t &)  a_imag 
)
inline

Definition at line 281 of file mat.

285  {
286  // CMAT = X+iY
287  // RMAT = | X Y |
288  // | -Y X |
289  typedef typename VEC_CMAT::size_type sz_t;
290  sz_t number = a_vc.size();
291  a_vr.resize(number);
292  for(sz_t index=0;index<number;index++) {
293  if(!decomplex(a_vc[index],a_vr[index],a_real,a_imag)) {
294  a_vr.clear();
295  return false;
296  }
297  }
298  return true;
299 }

◆ decompress_buffer()

bool tools::decompress_buffer ( std::ostream &  a_out,
unsigned int  a_srcsize,
const char *  a_src,
unsigned int  a_tgtsize,
char *  a_tgt,
unsigned int &  a_irep 
)
inline

Definition at line 67 of file zlib.

70  {
71 
72  z_stream stream; // decompression stream
73 
74  stream.next_in = (Bytef*)(a_src);
75  stream.avail_in = (uInt)(a_srcsize);
76  stream.next_out = (Bytef*)a_tgt;
77  stream.avail_out = (uInt)(a_tgtsize);
78  stream.zalloc = (alloc_func)0;
79  stream.zfree = (free_func)0;
80  stream.opaque = (voidpf)0;
81  stream.total_in = 0; /*to quiet Coverity.*/
82  stream.total_out = 0; /*to quiet Coverity.*/
83 
84  int err = inflateInit(&stream);
85  if (err != Z_OK) {
86  a_out << "tools::decompress_buffer :"
87  << " error " << err << " in zlib/inflateInit." << std::endl;
88  return false;
89  }
90 
91  err = inflate(&stream, Z_FINISH);
92  if (err != Z_STREAM_END) {
93  inflateEnd(&stream);
94  a_out << "tools::decompress_buffer :"
95  << " error " << err << " in zlib/inflate." << std::endl;
96  return false;
97  }
98 
99  inflateEnd(&stream);
100 
101  //a_out << "tools::decompress_buffer : zlib : ok "
102  // << stream.total_out << std::endl;
103 
104  a_irep = stream.total_out;
105 
106  return true;
107 }

◆ deg2rad()

double tools::deg2rad ( )
inline

Definition at line 21 of file mathd.

21  {
22  static const double s_v = pi()/180.0;
23  return s_v;
24 }

◆ delete_argcv()

void tools::delete_argcv ( int &  a_argc,
char **&  a_argv 
)
inline

Definition at line 30 of file argcv.

30  {
31  for(int index=0;index<a_argc;index++) delete [] a_argv[index];
32  delete [] a_argv;
33  a_argc = 0;
34  a_argv = 0;
35 }

◆ delete_key()

template<class K , class V >
bool tools::delete_key ( std::map< K, V * > &  a_m,
const K &  a_key 
)
inline

Definition at line 45 of file mapmanip.

45  {
46  typedef typename std::map<K,V*>::iterator it_t;
47  it_t it = a_m.find(a_key);
48  if(it==a_m.end()) return false;
49  V* obj = (*it).second;
50  a_m.erase(it);
51  delete obj;
52  return true;
53 }

◆ destroy()

template<class T >
void tools::destroy ( T *&  a_v)
inline

Definition at line 12 of file carray.

12  {
13  delete [] a_v;
14  a_v = 0;
15 }

◆ dfabs()

double tools::dfabs ( const double &  a_x)
inline

Definition at line 67 of file mathd.

67 {return ::fabs(a_x);} //if passing a_fabs(const T&).

◆ dgaussian()

double tools::dgaussian ( const double &  a_x,
const double &  a_mean,
const double &  a_sigma 
)
inline

Definition at line 84 of file mathd.

84  {
85  double _tmp = (a_x-a_mean)/a_sigma;
86  return ::exp(-_tmp*_tmp/2.0)/(a_sigma*::sqrt(2*pi()));
87 }

◆ diff()

template<class T >
void tools::diff ( std::ostream &  a_out,
const array< T > &  aA,
const array< T > &  aB,
a_epsilon 
)
inline

Definition at line 529 of file array.

529  {
530  if(aA.orders()!=aB.orders()) {
531  a_out << "tools::arrays::diff : not same orders" << std::endl;
532  return;
533  }
534  bool header_done = false;
535  unsigned int dim = aA.dimension();
536  std::vector<unsigned int> is(dim);
537  unsigned int vsize = aA.vector().size();
538  for(unsigned int index=0;index<vsize;index++) {
539  T diff = aA.vector()[index]-aB.vector()[index];
540  if(diff<0) diff *= -1;
541  if(diff>=a_epsilon) {
542  aA.indices(index,is);
543  if(!header_done) {
544  a_out << "tools::arrays::diff :" << std::endl;
545  header_done = true;
546  }
547  for(unsigned int i=0;i<dim;i++) a_out << is[i] << " ";
548  a_out << aA.vector()[index] << " " << aB.vector()[index] << std::endl;
549  }
550  }
551 }

◆ dir_name()

std::string tools::dir_name ( const std::string &  a_path,
unsigned int  a_num = 1 
)
inline

Definition at line 208 of file path.

208  {
209  std::string path = a_path;
210  for(unsigned int index=0;index<a_num;index++) {
211  std::string p,n,s;
212  path_name_suffix(path,p,n,s);
213  path = p;
214  }
215  return path;
216 }

◆ direction() [1/2]

template<class T >
void tools::direction ( const T &  a_0_x,
const T &  a_0_y,
const T &  a_0_z,
const T &  a_1_x,
const T &  a_1_y,
const T &  a_1_z,
const T &  a_2_x,
const T &  a_2_y,
const T &  a_2_z,
vec3< T > &  a_value 
)
inline

Definition at line 377 of file vec3.

379  {
380  direction(vec3<T>(a_0_x,a_0_y,a_0_z),
381  vec3<T>(a_1_x,a_1_y,a_1_z),
382  vec3<T>(a_2_x,a_2_y,a_2_z),a_value);
383 }

◆ direction() [2/2]

template<class VEC3 >
void tools::direction ( const VEC3 &  a_p0,
const VEC3 &  a_p1,
const VEC3 &  a_p2,
VEC3 &  a_value 
)
inline

Definition at line 344 of file vec3.

344  {
345  // Orientation is computed by taking (p1 - p0) x (p2 - p0)
346  VEC3 P = a_p1;
347  P.subtract(a_p0);
348  VEC3 P2 = a_p2;
349  P2.subtract(a_p0);
350  P.cross(P2,a_value);
351 }

◆ div() [1/2]

template<class T >
bool tools::div ( std::vector< T > &  a_vec,
const std::vector< T > &  a_v 
)
inline

Definition at line 294 of file vmanip.

294  {
295  if(a_vec.size()!=a_v.size()) return false;
296  typedef typename std::vector<T>::iterator it_t;
297  typedef typename std::vector<T>::const_iterator cit_t;
298  it_t it = a_vec.begin();
299  cit_t vit = a_v.begin();
300  bool errors = false;
301  for(;it!=a_vec.end();++it,++vit) {
302  if(*vit==T()) {
303  errors = true;
304  } else {
305  *it /= *vit;
306  }
307  }
308  return errors;
309 }

◆ div() [2/2]

template<class T >
void tools::div ( std::vector< T > &  a_vec,
const T &  a_v 
)
inline

Definition at line 332 of file vmanip.

332  {
333  typedef typename std::vector<T>::iterator it_t;
334  for(it_t it=a_vec.begin();it!=a_vec.end();++it) *it /= a_v;
335 }

◆ dpow() [1/2]

double tools::dpow ( const double &  a_x,
const double &  a_y 
)
inline

Definition at line 62 of file mathd.

62 {return ::pow(a_x,a_y);}

◆ dpow() [2/2]

bool tools::dpow ( const double &  a_x,
const double &  a_y,
double &  a_v 
)
inline

Definition at line 75 of file mathd.

75  {
76  if((a_x==0)&&(a_y<0)) {
77  a_v = 0;
78  return false;
79  }
80  a_v = dpow(a_x,a_y);
81  return true;
82 }

◆ dsin()

double tools::dsin ( const double &  a_x)
inline

Definition at line 61 of file mathd.

61 {return ::sin(a_x);}

◆ dsinh()

double tools::dsinh ( const double &  a_x)
inline

Definition at line 64 of file mathd.

64 {return ::sinh(a_x);}

◆ dsqrt()

double tools::dsqrt ( const double &  a_x)
inline

Definition at line 68 of file mathd.

68 {return ::sqrt(a_x);}

◆ dump() [1/3]

template<class T >
void tools::dump ( const std::vector< T > &  a_vec,
std::ostream &  a_out 
)
inline

Definition at line 459 of file vmanip.

459  {
460  typedef typename std::vector<T>::const_iterator it_t;
461  it_t it;
462  for(it=a_vec.begin();it!=a_vec.end();++it) {
463  a_out << *it << std::endl;
464  }
465 }

◆ dump() [2/3]

template<class MAT >
void tools::dump ( std::ostream &  a_out,
const std::string &  aCMT,
const MAT &  a_matrix 
)
inline

Definition at line 648 of file mat.

648  {
649  if(aCMT.size()) a_out << aCMT << std::endl;
650  unsigned int D = a_matrix.dimension();
651  for(unsigned int r=0;r<D;r++) {
652  for(unsigned int c=0;c<D;c++) {
653  a_out << " " << a_matrix.value(r,c);
654  }
655  a_out << std::endl;
656  }
657 }

◆ dump() [3/3]

template<class T >
void tools::dump ( std::ostream &  a_out,
const tools::array< T > &  a_array,
const std::string &  a_title 
)
inline

Definition at line 519 of file array.

519  {
520  if(a_title.size()) a_out << a_title << std::endl;
521  const std::vector<T>& vec = a_array.vector();
522  typedef typename std::vector<T>::const_iterator cons_vec_it_t;
523  for(cons_vec_it_t it = vec.begin();it!=vec.end();++it) {
524  a_out << (*it) << std::endl;
525  }
526 }

◆ end_LC_NUMERIC()

void tools::end_LC_NUMERIC ( char *&  a_s)
inline

Definition at line 227 of file cstr.

227  {
228  if(a_s) {
229  ::setlocale(LC_NUMERIC,a_s);
230  str_del(a_s);
231  }
232 }

◆ env_append()

bool tools::env_append ( const std::string &  a_env,
const std::string &  a_sep,
const std::vector< std::string > &  a_vals 
)
inline

Definition at line 16 of file path_env.

16  {
17  std::string env_value;
18  if(is_env(a_env)) {
19  if(!get_env(a_env,env_value)) return false;
20  }
21 
22  {std::vector<std::string>::const_iterator it;
23  for(it=a_vals.begin();it!=a_vals.end();++it) {
24  const std::string& value = *it;
25  if(value.empty()) continue;
26 
27  if(env_value.size()) {
28  std::vector<std::string> ws;
29  words(env_value,a_sep,false,ws);
30  // Remove existing one, so that value be put at end.
31  remove(ws,value);
32  if(!nums2s<std::string>(ws,env_value,a_sep)) {}
33  }
34 
35  if(env_value.size()) env_value += a_sep;
36  env_value += value;
37  }}
38 
39  if(!put_env(a_env,env_value)) return false;
40 
41  return true;
42 }

◆ env_append_path()

bool tools::env_append_path ( const std::string &  a_env,
const std::string &  a_path 
)
inline

Definition at line 48 of file path_env.

48  {
49  std::vector<std::string> v;
50  v.push_back(a_path);
51  return env_append(a_env,psep(),v);
52 }

◆ env_path_append()

bool tools::env_path_append ( const std::string &  a_env,
const std::vector< std::string > &  a_paths 
)
inline

Definition at line 44 of file path_env.

44  {
45  return env_append(a_env,psep(),a_paths);
46 }

◆ equal() [1/7]

bool tools::equal ( std::ostream &  a_out,
const char *  a_file,
int  a_line,
bool  a_v,
bool  a_expected 
)
inline

Definition at line 25 of file test.

25  {
26  if(a_v!=a_expected) {
27  a_out << "failed in file :" << std::endl
28  << a_file << std::endl
29  << "at line :" << std::endl
30  << a_line << std::endl
31  << "value " << (a_v?"true":"false") << ", expected " << (a_expected?"true":"false") << std::endl;
32  return false;
33  }
34  return true;
35 }

◆ equal() [2/7]

template<class INTEGER >
bool tools::equal ( std::ostream &  a_out,
const char *  a_file,
int  a_line,
const INTEGER &  a_v,
const INTEGER &  a_expected 
)
inline

Definition at line 54 of file test.

54  {
55  if(a_v!=a_expected) {
56  a_out << "failed in file :" << std::endl
57  << a_file << std::endl
58  << "at line :" << std::endl
59  << a_line << std::endl
60  << "value " << a_v << ", expected " << a_expected << std::endl;
61  return false;
62  }
63  return true;
64 }

◆ equal() [3/7]

template<class REAL >
bool tools::equal ( std::ostream &  a_out,
const char *  a_file,
int  a_line,
const REAL &  a_v,
const REAL &  a_expected,
const REAL &  a_tolerance,
REAL(*)(const REAL &)  a_fabs 
)
inline

Definition at line 93 of file test.

93  {
94  REAL diff = a_fabs(a_v-a_expected);
95  if(diff>=a_tolerance) {
96  a_out << "failed in file :" << std::endl
97  << a_file << std::endl
98  << "at line :" << std::endl
99  << a_line << std::endl
100  << "value " << a_v << ", expected " << a_expected << ",diff " << diff << std::endl;
101  return false;
102  }
103  return true;
104 }

◆ equal() [4/7]

bool tools::equal ( std::ostream &  a_out,
const char *  a_file,
int  a_line,
const std::string &  a_v,
const std::string &  a_expected 
)
inline

Definition at line 12 of file test.

12  {
13  if(a_v!=a_expected) {
14  a_out << "failed in file :" << std::endl
15  << a_file << std::endl
16  << "at line :" << std::endl
17  << a_line << std::endl
18  << "strg value \"" << a_v << "\"" << std::endl
19  << ", expected \"" << a_expected << "\"." << std::endl;
20  return false;
21  }
22  return true;
23 }

◆ equal() [5/7]

bool tools::equal ( std::ostream &  a_out,
const char *  a_file,
int  a_line,
const std::vector< std::string > &  a_v,
const std::vector< std::string > &  a_expected 
)
inline

Definition at line 189 of file test.

189  {
190  if(a_v.size()!=a_expected.size()) {
191  a_out << "failed in file :" << std::endl
192  << a_file << std::endl
193  << "at line :" << std::endl
194  << a_line << std::endl
195  << "vector value.size() " << a_v.size() << ", expected " << a_expected.size() << std::endl;
196  return false;
197  }
198  std::vector<std::string>::const_iterator it1 = a_v.begin();
199  std::vector<std::string>::const_iterator it2 = a_expected.begin();
200  for(;it1!=a_v.end();++it1,++it2) {
201  if((*it1)!=(*it2)) {
202  a_out << "failed in file :" << std::endl
203  << a_file << std::endl
204  << "at line :" << std::endl
205  << a_line << std::endl
206  << "line value \"" << (*it1) << "\"" << std::endl
207  << ", expected \"" << (*it2) << "\"" << std::endl;
208  return false;
209  }
210  }
211  return true;
212 }

◆ equal() [6/7]

template<class VEC , class REAL >
bool tools::equal ( std::ostream &  a_out,
const char *  a_file,
int  a_line,
const VEC &  a_1,
const VEC &  a_2,
const REAL &  a_tolerance,
REAL(*)(const REAL &)  a_fabs 
)
inline

Definition at line 144 of file test.

144  {
145  if(a_1.dimension()!=a_2.dimension()) {
146  a_out << "failed in file :" << std::endl
147  << a_file << std::endl
148  << "at line :" << std::endl
149  << a_line << std::endl
150  << "vector dimension " << a_1.dimension() << " != " << a_2.dimension() << std::endl;
151  return false;
152  }
153  for(size_t index=0;index<a_1.dimension();index++) {
154  if(!equal<REAL>(a_out,a_file,a_line,a_1[index],a_2[index],a_tolerance,a_fabs)) return false;
155  }
156  return true;
157 }

◆ equal() [7/7]

template<class REAL >
bool tools::equal ( std::ostream &  a_out,
const char *  a_file,
int  a_line,
size_t  a_size,
const REAL *  a_v,
const REAL *  a_expected,
const REAL &  a_tolerance,
REAL(*)(const REAL &)  a_fabs 
)
inline

Definition at line 136 of file test.

136  {
137  for(size_t index=0;index<a_size;index++) {
138  if(!equal<REAL>(a_out,a_file,a_line,a_v[index],a_expected[index],a_tolerance,a_fabs)) return false;
139  }
140  return true;
141 }

◆ facos()

float tools::facos ( const float &  x)
inline

Definition at line 44 of file mathf.

44 {return (float)::acos(double(x));}

◆ fasin()

float tools::fasin ( const float &  x)
inline

Definition at line 45 of file mathf.

45 {return (float)::asin(double(x));}

◆ fatan()

float tools::fatan ( const float &  x)
inline

Definition at line 47 of file mathf.

47 {return (float)::atan(double(x));}

◆ fatan2()

float tools::fatan2 ( const float &  x,
const float &  y 
)
inline

Definition at line 48 of file mathf.

48 {return (float)::atan2(double(x),double(y));}

◆ fceil()

float tools::fceil ( const float &  x)
inline

Definition at line 55 of file mathf.

55 {return (float)::ceil(double(x));}

◆ fcos()

float tools::fcos ( const float &  x)
inline

Definition at line 42 of file mathf.

42 {return (float)::cos(double(x));}

◆ fcosh()

float tools::fcosh ( const float &  x)
inline

Definition at line 56 of file mathf.

56 {return (float)::cosh(double(x));}

◆ fdeg2rad()

float tools::fdeg2rad ( )
inline

Definition at line 18 of file mathf.

18  {
19  static const float s_v = fpi()/180.0f; //0.0174f
20  return s_v;
21 }

◆ fexp()

float tools::fexp ( const float &  x)
inline

Definition at line 51 of file mathf.

51 {return (float)::exp(double(x));}

◆ ffabs()

float tools::ffabs ( const float &  x)
inline

Definition at line 58 of file mathf.

58 {return (float)::fabs(double(x));}

◆ ffloor()

float tools::ffloor ( const float &  x)
inline

Definition at line 54 of file mathf.

54 {return (float)::floor(double(x));}

◆ fhalf_pi()

float tools::fhalf_pi ( )
inline

Definition at line 13 of file mathf.

13 {return (float)1.5707963267948965580E0;}

◆ file_name()

bool tools::file_name ( const std::string &  a_path,
std::string &  a_name 
)
inline

Definition at line 61 of file file_name.

61  {
62  //used in osc packages and a tools::xml::parser::load_file() compatible for OnX.
63  a_name = a_path;
64  if(!rep_env(a_name)) {a_name.clear();return false;}
65 #ifdef _WIN32
66  replace(a_name,"/","\\");
67  replace(a_name,"\"","");
68 #endif
69  return true;
70 }

◆ filter() [1/2]

void tools::filter ( std::vector< std::string > &  a_v,
const std::string &  a_pattern,
bool  a_check_for_wilds = true 
)
inline

Definition at line 91 of file smatch.

93  {
94  std::vector<std::string>::iterator it;
95  for(it=a_v.begin();it!=a_v.end();) {
96  if(match(*it,a_pattern,a_check_for_wilds)) {
97  it++;
98  } else {
99  it = a_v.erase(it);
100  }
101  }
102 }

◆ filter() [2/2]

template<class T >
void tools::filter ( std::vector< T > &  a_vec,
unsigned int  a_min,
unsigned int  a_max 
)
inline

Definition at line 233 of file vmanip.

233  {
234  unsigned int imx = a_vec.size()-1;
235  unsigned int mx = a_max<imx?a_max:imx;
236  unsigned int i = 0;
237  for(unsigned int index=a_min;index<=mx;index++) {
238  a_vec[i] = a_vec[index];i++;
239  }
240  a_vec.resize(i);
241 }

◆ find() [1/2]

template<class K , class V >
bool tools::find ( const std::map< K, V > &  a_map,
const K &  a_key,
V &  a_value 
)
inline

Definition at line 86 of file mapmanip.

86  {
87  typedef typename std::map<K,V>::const_iterator it_t;
88  it_t it = a_map.find(a_key);
89  if(it==a_map.end()) {a_value = V();return false;}
90  a_value = (*it).second;
91  return true;
92 }

◆ find() [2/2]

template<class K , class V >
bool tools::find ( const std::vector< std::pair< K, V > > &  a_vec,
const K &  a_key,
V &  a_value 
)
inline

Definition at line 26 of file vpair.

26  {
27  typedef typename std::vector< std::pair<K,V> >::const_iterator it_t;
28  it_t it;
29  for(it=a_vec.begin();it!=a_vec.end();++it) {
30  if((*it).first==a_key) {
31  a_value = (*it).second;
32  return true;
33  }
34  }
35  a_value = V();
36  return false;
37 }

◆ find_and_remove_value()

template<class K , class V >
void tools::find_and_remove_value ( std::map< K, V * > &  a_m,
V *  a_value 
)
inline

Definition at line 25 of file mapmanip.

25  {
26  typedef typename std::map<K,V*>::iterator it_t;
27  while(true) {
28  bool found = false;
29  for(it_t it=a_m.begin();it!=a_m.end();++it) {
30  if((*it).second==a_value) {
31  a_m.erase(it);
32  found = true;
33  break;
34  }
35  }
36  if(!found) break;
37  }
38 }

◆ find_key()

template<class K , class V >
bool tools::find_key ( const std::vector< std::pair< K, V > > &  a_vec,
const V &  a_value,
K &  a_key 
)
inline

Definition at line 64 of file vpair.

64  {
65  typedef typename std::vector< std::pair<K,V> >::const_iterator it_t;
66  it_t it;
67  for(it=a_vec.begin();it!=a_vec.end();++it) {
68  if((*it).second==a_value) {
69  a_key = (*it).first;
70  return true;
71  }
72  }
73  a_key = K();
74  return false;
75 }

◆ find_named()

template<class T >
T* tools::find_named ( const std::vector< T * > &  a_vec,
const std::string &  a_name 
)
inline

Definition at line 13 of file vfind.

13  {
14  typedef typename std::vector<T*>::const_iterator it_t;
15  it_t it;
16  for(it=a_vec.begin();it!=a_vec.end();++it) {
17  if((*it)->name()==a_name) return *it;
18  }
19  return 0;
20 }

◆ find_named_case_insensitive()

template<class T >
T* tools::find_named_case_insensitive ( const std::vector< T * > &  a_vec,
const std::string &  a_name 
)
inline

Definition at line 48 of file vfind.

48  {
49  std::string low_a_name = a_name;
50  tolowercase(low_a_name);
51  std::string low_name;
52  typedef typename std::vector<T*>::const_iterator it_t;
53  it_t it;
54  for(it=a_vec.begin();it!=a_vec.end();++it) {
55  low_name = (*it)->name();
56  tolowercase(low_name);
57  if(low_name==low_a_name) return *it;
58  }
59  return 0;
60 }

◆ find_obj_named() [1/2]

template<class T >
const T* tools::find_obj_named ( const std::vector< T > &  a_vec,
const std::string &  a_name 
)
inline

Definition at line 23 of file vfind.

23  { //used in hep/pdgs.
24  typedef typename std::vector<T>::const_iterator it_t;
25  it_t it;
26  for(it=a_vec.begin();it!=a_vec.end();++it) {
27  if((*it).name()==a_name) return &(*it);
28  }
29  return 0;
30 }

◆ find_obj_named() [2/2]

template<class T >
T* tools::find_obj_named ( std::vector< T > &  a_vec,
const std::string &  a_name 
)
inline

Definition at line 32 of file vfind.

32  { //used in hep/pdgs.
33  typedef typename std::vector<T>::iterator it_t;
34  it_t it;
35  for(it=a_vec.begin();it!=a_vec.end();++it) {
36  if((*it).name()==a_name) return &(*it);
37  }
38  return 0;
39 }

◆ find_with_dirs()

bool tools::find_with_dirs ( std::ostream &  a_out,
const std::vector< std::string > &  a_dirs,
const std::string &  a_file,
std::string &  a_path,
bool  a_verbose = false 
)
inline

Definition at line 14 of file fmanip.

18  {
19  std::vector<std::string>::const_iterator it;
20  for(it=a_dirs.begin();it!=a_dirs.end();++it) {
21  if((*it).empty()) {
22  // with a "" in dirs, this case could solve :
23  // - a_file in the current directory.
24  // - a_file with an absolute path name.
25  a_path = a_file; //may be an absolute file name.
26  } else {
27  a_path = *it;
28  a_path += sep();
29  a_path += a_file;
30  }
31 
32  if(a_verbose) {
33  a_out << "find_with_dirs :"
34  << " look for " << sout(a_path) << " ..."
35  << std::endl;
36  }
37 
38  if(file::exists(a_path)) {
39  if(a_verbose) {
40  a_out << "find_with_dirs :"
41  << " found " << sout(a_path) << "."
42  << std::endl;
43  }
44  return true;
45  }
46  }
47  a_path.clear();
48 
49  if(a_verbose) {
50  a_out << "find_with_dirs :"
51  << " " << sout(a_file) << " not found."
52  << std::endl;
53  }
54 
55  return false;
56 }

◆ find_with_env()

bool tools::find_with_env ( std::ostream &  a_out,
const std::string &  a_env,
const std::string &  a_file,
std::string &  a_path,
bool  a_verbose = false 
)
inline

Definition at line 64 of file fmanip.

68  {
69  std::string PATH;
70  if(!get_env(a_env,PATH)) {
71  //look for a a_file in current directory.
72  if(file::exists(a_file)) {
73  //a_out << "tools::find_with_env :"
74  // << " env variable " << sout(a_env) << " not defined, but file " << sout(a_file) << " exists."
75  // << std::endl;
76  a_path = a_file;
77  return true;
78  }
79  a_out << "tools::find_with_env : env variable " << sout(a_env) << " not defined." << std::endl;
80  a_path.clear();
81  return false;
82  }
83  if(a_verbose) {
84  a_out << "find_with_env : env " << sout(a_env) << " is " << sout(PATH) << std::endl;
85  }
86 
87  std::vector<std::string> dirs;
88  words(PATH,psep(),false,dirs); //or true ?
89 
90  return find_with_dirs(a_out,dirs,a_file,a_path,a_verbose);
91 }

◆ flog()

float tools::flog ( const float &  x)
inline

Definition at line 52 of file mathf.

52 {return (float)::log(double(x));}

◆ flog10()

float tools::flog10 ( const float &  x)
inline

Definition at line 53 of file mathf.

53 {return (float)::log10(double(x));}

◆ fpi()

float tools::fpi ( )
inline

Definition at line 11 of file mathf.

11 {return (float)3.1415926535897931160E0;}

◆ fpow()

float tools::fpow ( const float &  x,
const float &  y 
)
inline

Definition at line 50 of file mathf.

50 {return (float)::pow(double(x),(double)(y));}

◆ frad2deg()

float tools::frad2deg ( )
inline

Definition at line 22 of file mathf.

22  {
23  static const float s_v = 180.0f/fpi();
24  return s_v;
25 }

◆ fround()

int tools::fround ( const float &  a_x)
inline

Definition at line 27 of file mathf.

27  {
28  // From CoinGL/src/base/SbViewportRegion.cpp.
29  if (a_x == (float) (int(a_x))) return int(a_x);
30  else return (a_x>0.0f) ? int(a_x+0.5f) : -int(0.5f-a_x);
31 }

◆ fsin()

float tools::fsin ( const float &  x)
inline

Definition at line 43 of file mathf.

43 {return (float)::sin(double(x));}

◆ fsinh()

float tools::fsinh ( const float &  x)
inline

Definition at line 57 of file mathf.

57 {return (float)::sinh(double(x));}

◆ fsqrt()

float tools::fsqrt ( const float &  x)
inline

Definition at line 49 of file mathf.

49 {return (float)::sqrt(double(x));}

◆ fstep()

float tools::fstep ( const float &  a_x)
inline

Definition at line 33 of file mathf.

33 {return a_x<0.0f?0.0f:1.0f;}

◆ ftan()

float tools::ftan ( const float &  x)
inline

Definition at line 46 of file mathf.

46 {return (float)::tan(double(x));}

◆ ftwo_pi()

float tools::ftwo_pi ( )
inline

Definition at line 12 of file mathf.

12 {return (float)6.2831853071795862320E0;}

◆ ge()

template<class INTEGER >
bool tools::ge ( std::ostream &  a_out,
const char *  a_file,
int  a_line,
const INTEGER &  a_v,
const INTEGER &  a_expected 
)
inline

Definition at line 80 of file test.

80  {
81  if(a_v<a_expected) {
82  a_out << "failed in file :" << std::endl
83  << a_file << std::endl
84  << "at line :" << std::endl
85  << a_line << std::endl
86  << "value " << a_v << " < " << a_expected << std::endl;
87  return false;
88  }
89  return true;
90 }

◆ get_data() [1/4]

template<class T >
const T* tools::get_data ( const mat4< T > &  a_v)
inline

Definition at line 494 of file mat4.

494 {return a_v.data();}

◆ get_data() [2/4]

template<class T >
const T* tools::get_data ( const vec2< T > &  a_v)
inline

Definition at line 204 of file vec2.

204 {return a_v.data();}

◆ get_data() [3/4]

template<class T >
const T* tools::get_data ( const vec3< T > &  a_v)
inline

Definition at line 317 of file vec3.

317 {return a_v.data();}

◆ get_data() [4/4]

template<class T >
const T* tools::get_data ( const vec4< T > &  a_v)
inline

Definition at line 268 of file vec4.

268 {return a_v.data();}

◆ get_env() [1/2]

bool tools::get_env ( const std::string &  a_string,
std::string &  a_value 
)
inline

Definition at line 18 of file get_env.

18  {
19  const char* env = ::getenv(a_string.c_str());
20  if(env) {
21  a_value = std::string(env?env:"");
22  return true;
23  } else {
24  a_value.clear();
25  return false;
26  }
27 }

◆ get_env() [2/2]

template<class T >
bool tools::get_env ( const std::string &  a_string,
T &  a_v,
const T &  a_def = T() 
)
inline

Definition at line 30 of file get_env.

30  {
31  std::string s;
32  if(!get_env(a_string,s)) {a_v = a_def;return false;}
33  return to<T>(s,a_v,a_def);
34 }

◆ get_env_bool()

bool tools::get_env_bool ( const std::string &  a_string,
bool &  a_v 
)
inline

Definition at line 36 of file get_env.

36  {
37  std::string s;
38  if(!get_env(a_string,s)) return false;
39  return to(s,a_v);
40 }

◆ get_lines()

void tools::get_lines ( const std::string &  a_string,
std::vector< std::string > &  a_lines 
)
inline

Definition at line 14 of file get_lines.

14  {
15  // a_string is a list separated by "\n" or "\\n".
16  // For "xxx\n\nxxx", {"xxx","","xxx"} will be created.
17  // WARNING : if a_string is a Windows file name, it may
18  // contains a \n which is not a delimiter ; like ..\data\ntuples.hbook.
19  a_lines.clear();
20  size_t length = a_string.length();
21  if(!length) return;
22  char* cstring = str_dup(a_string.c_str());
23  if(!cstring) return;
24  size_t pos = 0;
25  length++;
26  for(size_t count=0;count<length;count++) {
27  if( (cstring[count]=='\n') ||
28  (cstring[count]=='\0') ||
29  ( (cstring[count]=='\\') && (cstring[count+1]=='n') ) ) {
30  char shift_one = (cstring[count]=='\n' ? 1 : 0);
31  cstring[count] = '\0';
32  a_lines.push_back(cstring+pos);
33  if(shift_one==1) {
34  pos = count+1;
35  } else {
36  pos = count+2;
37  count++;
38  }
39  }
40  }
41  str_del(cstring);
42 }

◆ get_normal() [1/2]

template<class T >
void tools::get_normal ( const vec3< T > &  a_p0,
const vec3< T > &  a_p1,
const vec3< T > &  a_p2,
vec3< T > &  a_nm,
vec3< T > &  a_tmp_1,
vec3< T > &  a_tmp_2,
T(*)(T)  a_sqrt 
)
inline

Definition at line 320 of file vec3.

321  {
322  // Used to optimize sg::bin().
323  //(a_p1-a_p0).cross(a_p2-a_p1,a_nm);
324 
325  a_tmp_1 = a_p1;
326  a_tmp_1.subtract(a_p0);
327 
328  a_tmp_2 = a_p2;
329  a_tmp_2.subtract(a_p1);
330 
331  a_tmp_1.cross(a_tmp_2,a_nm);
332 
333  a_nm.normalize(a_sqrt);
334 }

◆ get_normal() [2/2]

void tools::get_normal ( const vec3f a_p0,
const vec3f a_p1,
const vec3f a_p2,
vec3f a_nm,
vec3f a_tmp_1,
vec3f a_tmp_2 
)
inline

Definition at line 123 of file vec3f.

124  {
125  // Used to optimize sg::bin().
126  //(a_p1-a_p0).cross(a_p2-a_p1,a_nm);
127 
128  a_tmp_1 = a_p1;
129  a_tmp_1.subtract(a_p0);
130 
131  a_tmp_2 = a_p2;
132  a_tmp_2.subtract(a_p1);
133 
134  a_tmp_1.cross(a_tmp_2,a_nm);
135 
136  a_nm.normalize();
137 }

◆ gui_toolkit()

std::string tools::gui_toolkit ( args a_args,
bool  a_rm_in_args 
)
inline

Definition at line 11 of file saui.

11  {
12  std::string driver;
13  a_args.find("-toolkit",driver);
14  if(a_rm_in_args) a_args.remove("-toolkit");
15  if(driver.empty()) {
16  if(a_args.is_arg("-Xt")||
17  a_args.is_arg("-xt")||
18  a_args.is_arg("-Xm")||
19  a_args.is_arg("-xm")||
20  a_args.is_arg("-Motif")||
21  a_args.is_arg("-motif")) {
22  driver = "Xt";
23  if(a_rm_in_args) {
24  a_args.remove("-Xt");
25  a_args.remove("-xt");
26  a_args.remove("-Xm");
27  a_args.remove("-xm");
28  a_args.remove("-Motif");
29  a_args.remove("-motif");
30  }
31  } else if(a_args.is_arg("-Win")||
32  a_args.is_arg("-win")||
33  a_args.is_arg("-Win32")||
34  a_args.is_arg("-win32")) {
35  driver = "Win";
36  if(a_rm_in_args) {
37  a_args.remove("-Win");
38  a_args.remove("-win");
39  a_args.remove("-Win32");
40  a_args.remove("-win32");
41  }
42  } else if(a_args.is_arg("-NextStep")||
43  a_args.is_arg("-nextstep")) {
44  driver = "NextStep";
45  if(a_rm_in_args) {
46  a_args.remove("-NextStep");
47  a_args.remove("-nextstep");
48  }
49  } else if(a_args.is_arg("-Gtk")||
50  a_args.is_arg("-gtk")) {
51  driver = "Gtk";
52  if(a_rm_in_args) {
53  a_args.remove("-Gtk");
54  a_args.remove("-gtk");
55  }
56  } else if(a_args.is_arg("-Qt")||
57  a_args.is_arg("-qt")) {
58  driver = "Qt";
59  if(a_rm_in_args) {
60  a_args.remove("-Qt");
61  a_args.remove("-qt");
62  }
63  } else if(a_args.is_arg("-SDL")||
64  a_args.is_arg("-sdl")) {
65  driver = "SDL";
66  if(a_rm_in_args) {
67  a_args.remove("-SDL");
68  a_args.remove("-sdl");
69  }
70  } else if(a_args.is_arg("-Net")||
71  a_args.is_arg("-net")) {
72  driver = "Net";
73  if(a_rm_in_args) {
74  a_args.remove("-Net");
75  a_args.remove("-net");
76  }
77  } else if(a_args.is_arg("-inex")) {
78  driver = "inex";
79  if(a_rm_in_args) {
80  a_args.remove("-inex");
81  }
82  }
83  }
84 
85  return driver;
86 }

◆ gunzip_buffer()

bool tools::gunzip_buffer ( std::ostream &  a_out,
unsigned int  a_srcsize,
const char *  a_src,
unsigned int  a_tgtsize,
char *  a_tgt,
unsigned int &  a_irep 
)
inline

Definition at line 183 of file zlib.

186  {
187 
188  z_stream stream; // decompression stream
189 
190 #if ZLIB_VERNUM <= 0x1140
191  char* pos = (char*)a_src;
192  if(gunzip_check_header(pos)!=Z_OK) return false;
193  stream.next_in = (Bytef*)pos;
194  stream.avail_in = (uInt)(a_srcsize-(pos-a_src));
195 #else
196  stream.next_in = (Bytef*)a_src;
197  stream.avail_in = (uInt)a_srcsize;
198 #endif //ZLIB_VERNUM
199 
200  stream.next_out = (Bytef*)a_tgt;
201  stream.avail_out = (uInt)a_tgtsize;
202  stream.zalloc = (alloc_func)0;
203  stream.zfree = (free_func)0;
204  stream.opaque = (voidpf)0;
205 
206 #if ZLIB_VERNUM <= 0x1140
207  int err = inflateInit2(&stream,-MAX_WBITS);
208 #else
209  int err = inflateInit2(&stream,MAX_WBITS+16);
210 #endif
211  if (err != Z_OK) {
212  a_out << "tools::gunzip_buffer :"
213  << " error " << err << " in zlib/inflateInit2." << std::endl;
214  return false;
215  }
216 
217  err = inflate(&stream, Z_FINISH);
218  if (err != Z_STREAM_END) {
219  inflateEnd(&stream);
220  a_out << "tools::gunzip_buffer :"
221  << " error " << err << " in zlib/inflate." << std::endl;
222  return false;
223  }
224 
225  inflateEnd(&stream);
226 
227  a_irep = stream.total_out;
228 
229  return true;
230 }

◆ gunzip_check_header()

int tools::gunzip_check_header ( char *&  a_buffer)
inline

Definition at line 123 of file zlib.

123  {
124 #define TOOLS_ZLIB_HEAD_CRC 0x02 /* bit 1 set: header CRC present */
125 #define TOOLS_ZLIB_EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
126 #define TOOLS_ZLIB_ORIG_NAME 0x08 /* bit 3 set: original file name present */
127 #define TOOLS_ZLIB_COMMENT 0x10 /* bit 4 set: file comment present */
128 #define TOOLS_ZLIB_RESERVED 0xE0 /* bits 5..7: reserved */
129 
130  uInt len;
131  int c;
132 
133  /* Check the gzip magic header */
134  for (len = 0; len < 2; len++) {
135  c = gunzip_get_byte(a_buffer);
136 /*
137  if (c != gz_magic[len]) {
138  if (len != 0) s->stream.avail_in++, s->stream.next_in--;
139  if (c != EOF) {
140  s->stream.avail_in++, s->stream.next_in--;
141  s->transparent = 1;
142  }
143  s->z_err = s->stream.avail_in != 0 ? Z_OK : Z_STREAM_END;
144  return;
145  }
146 */
147  }
148  int method = gunzip_get_byte(a_buffer);
149  int flags = gunzip_get_byte(a_buffer);
150  if (method != Z_DEFLATED || (flags & TOOLS_ZLIB_RESERVED) != 0) {
151  return Z_DATA_ERROR;
152  }
153 
154  /* Discard time, xflags and OS code: */
155  for (len = 0; len < 6; len++) (void)gunzip_get_byte(a_buffer);
156 
157  if ((flags & TOOLS_ZLIB_EXTRA_FIELD) != 0) { /* skip the extra field */
158  len = (uInt)gunzip_get_byte(a_buffer);
159  len += ((uInt)gunzip_get_byte(a_buffer))<<8;
160  /* len is garbage if EOF but the loop below will quit anyway */
161  while (len-- != 0 && gunzip_get_byte(a_buffer) != EOF) ;
162  }
163  if ((flags & TOOLS_ZLIB_ORIG_NAME) != 0) { /* skip the original file name */
164  while ((c = gunzip_get_byte(a_buffer)) != 0 && c != EOF) ;
165  }
166  if ((flags & TOOLS_ZLIB_COMMENT) != 0) { /* skip the .gz file comment */
167  while ((c = gunzip_get_byte(a_buffer)) != 0 && c != EOF) ;
168  }
169  if ((flags & TOOLS_ZLIB_HEAD_CRC) != 0) { /* skip the header crc */
170  for (len = 0; len < 2; len++) (void)gunzip_get_byte(a_buffer);
171  }
172  //s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK;
173  return Z_OK;
174 
175 #undef TOOLS_ZLIB_HEAD_CRC
176 #undef TOOLS_ZLIB_EXTRA_FIELD
177 #undef TOOLS_ZLIB_ORIG_NAME
178 #undef TOOLS_ZLIB_COMMENT
179 #undef TOOLS_ZLIB_RESERVED
180 }

◆ gunzip_get_byte()

int tools::gunzip_get_byte ( char *&  a_buffer)
inline

Definition at line 118 of file zlib.

118  {
119  int c = *a_buffer;a_buffer++;
120  return c;
121 }

◆ h1_fill()

template<class I , class T , class HISTO >
bool tools::h1_fill ( a_n,
const void *  a_v,
HISTO &  a_histo 
)
inline

Definition at line 116 of file carray.

116  {
117  a_histo.reset();
118  if(a_n<=0) return false;
119  typedef typename HISTO::coordinate_t TC;
120  T* pos = (T*)a_v;
121  for(I i=0;i<a_n;i++,pos++) a_histo.fill(TC(*pos));
122  return true;
123 }

◆ half_pi()

double tools::half_pi ( )
inline

Definition at line 19 of file mathd.

19 {return 1.5707963267948965580E0;}

◆ has_dir()

bool tools::has_dir ( const std::string &  a_string)
inline

Definition at line 48 of file path.

48  {
49  if(a_string.rfind('/')!=std::string::npos) return true;
50  if(a_string.rfind('\\')!=std::string::npos) return true;
51  return false;
52 }

◆ hls_to_rgb()

template<class T >
void tools::hls_to_rgb ( hue,
light,
satur,
T &  a_r,
T &  a_g,
T &  a_b 
)
inline

Definition at line 24 of file hls.

24  {
25  // taken from CERN-ROOT/TColor.
26  // Static method to compute RGB from HLS. The l and s are between [0,1]
27  // and h is between [0,360]. The returned r,g,b triplet is between [0,1].
28 
29  T rh, rl, rs, rm1, rm2;
30  rh = rl = rs = 0;
31 
32  if (hue > 0) rh = hue;
33  if (rh > 360) rh = 360;
34 
35  if (light > 0) rl = light;
36  if (rl > 1) rl = 1;
37 
38  if (satur > 0) rs = satur;
39  if (rs > 1) rs = 1;
40 
41  if (rl <= T(0.5)) {
42  rm2 = rl*(1 + rs);
43  } else {
44  rm2 = rl + rs - rl*rs;
45  }
46  rm1 = 2*rl - rm2;
47 
48  if (!rs) { a_r = rl; a_g = rl; a_b = rl; return; }
49  a_r = hls_to_rgb2(rm1, rm2, rh+120);
50  a_g = hls_to_rgb2(rm1, rm2, rh);
51  a_b = hls_to_rgb2(rm1, rm2, rh-120);
52 }

◆ hls_to_rgb2()

template<class T >
T tools::hls_to_rgb2 ( rn1,
rn2,
huei 
)
inline

Definition at line 12 of file hls.

12  {
13  // taken from CERN-ROOT/TColor.
14  T hue = huei;
15  if (hue > 360) hue = hue - 360;
16  if (hue < 0) hue = hue + 360;
17  if (hue < 60 ) return rn1 + (rn2-rn1)*hue/60;
18  if (hue < 180) return rn2;
19  if (hue < 240) return rn1 + (rn2-rn1)*(240-hue)/60;
20  return rn1;
21 }

◆ id_cast() [1/2]

template<class FROM , class TO >
const TO* tools::id_cast ( const FROM &  a_o)
inline

Definition at line 27 of file safe_cast.

27  {
28  return (const TO*)a_o.cast(TO::id_class());
29 }

◆ id_cast() [2/2]

template<class FROM , class TO >
TO* tools::id_cast ( FROM &  a_o)
inline

Definition at line 22 of file safe_cast.

22  {
23  return (TO*)a_o.cast(TO::id_class());
24 }

◆ if_mouse_startup()

bool tools::if_mouse_startup ( const std::string &  a_arg0,
const std::string &  a_env_HOME_DIR,
const std::vector< std::string > &  a_home_dirs,
std::ostream &  a_out 
)
inline

Definition at line 68 of file app.

68  {
69  std::string exe_dir = dir_name(a_arg0);
70  std::string bname = base_name(exe_dir);
71  if(bname=="MacOS") {
72  // cd in a_doc_dir :
73  if(!dir::cd_home()) {
74  a_out << "if_mouse_startup : can't go home." << std::endl;
75  return false;
76  }
77  tools_vforcit(std::string,a_home_dirs,it) {
78  if(!dir::mkcd(*it)) {
79  a_out << "if_mouse_startup :"
80  << " can't mkcd " << sout(*it)
81  << std::endl;
82  return false;
83  }
84  }
85 
86  // set a_env_HOME_DIR from exe_dir :
87  std::string Contents_dir = dir_name(exe_dir);
88  if(!put_env(a_env_HOME_DIR,Contents_dir)) {
89  a_out << "if_mouse_startup :"
90  << " can't putenv " << a_env_HOME_DIR
91  << " to " << sout(Contents_dir)
92  << "."
93  << std::endl;
94  return false;
95  }
96  {std::vector<std::string> vals;
97  vals.push_back(Contents_dir+"/bin");
98  vals.push_back("."); // for on-the-fly compilation and loading :
99  if(!env_path_append("DYLD_LIBRARY_PATH",vals)) {
100  a_out << "if_mouse_startup :"
101  << " can't putenv DYLD_LIBRARY_PATH."
102  //<< " to " << sout(DYLD_LIBRARY_PATH)
103  << std::endl;
104  return false;
105  }}
106 
107 // {std::string DYLD_LIBRARY_PATH;
108 // if(!get_env("DYLD_LIBRARY_PATH",DYLD_LIBRARY_PATH)) {}
109 // a_out << "debug : DYLD_LIBRARY_PATH = " << sout(DYLD_LIBRARY_PATH) << std::endl;}
110 
111  if(!is_env("DISPLAY")) {
112  if(!put_env("DISPLAY",":0.0")) return false;
113  }
114 
115  } else if(bname=="bin") {
116  //Linux, Windows : mouse startup ?
117 
118 /* FIXME : do we want to treat the case of a terminal startup
119  whence the user did not <source setup> ???
120  If so if_mouse_startup should be renamed no_env_startup.
121 
122  } else if(exe_dir=="") { //for exa when typing "osc-plot".
123  if(!program_path(a_arg0,exe_dir)) {
124  a_out << "if_mouse_startup :"
125  << " program_path failed for " << sout(bname) << "."
126  << std::endl;
127  return false;
128  }
129  a_out << "if_mouse_startup :"
130  << " program_path is " << sout(exe_dir) << "."
131  << std::endl;
132 
133 #if defined(__APPLE__) || defined(Linux)
134  bool is_abs,is_win;
135  std::string drive;
136  std::vector<std::string> words;
137  path_words(exe_dir,words,is_abs,is_win,drive);
138  std::vector<std::string>::size_type n = words.size();
139 
140  if( (n>=3) &&
141  (words[n-1]=="bin") &&
142  is_version(words[n-2]) &&
143  (words[n-3].substr(0,4)=="osc_")
144  ){
145 
146  std::string osc_vers_dir = dir_name(exe_dir);
147 
148  printf("debug : auto env 000 \"%s\"\n",osc_vers_dir.c_str());
149 
150  //if(a_env_HOME_DIR.size()) {
151  if(!put_env(a_env_HOME_DIR,osc_vers_dir)) {
152  a_out << "arg0_setenv :"
153  << " can't putenv " << a_env_HOME_DIR
154  << " to " << sout(osc_vers_dir)
155  << "."
156  << std::endl;
157  return false;
158  }
159  //}
160 
161 #ifdef __APPLE__
162 
163  {std::vector<std::string> vals;
164  vals.push_back(osc_vers_dir+"/bin");
165  vals.push_back(osc_vers_dir+"/lib");
166  vals.push_back("."); // for on-the-fly compilation and loading :
167  if(!env_path_append("DYLD_LIBRARY_PATH",vals)) return false;}
168 
169 #else
170 #endif
171 
172  if(!is_env("DISPLAY")) {
173  if(!put_env("DISPLAY",":0.0")) return false;
174  }
175 
176  }
177 #endif
178 */
179 
180  }
181 
182  return true;
183 }

◆ in_domain_acos()

bool tools::in_domain_acos ( double  a_x)
inline

Definition at line 38 of file mathd.

38  {
39  if((a_x<-1)||(1<a_x)) return false;
40  return true;
41 }

◆ in_domain_all()

bool tools::in_domain_all ( double  )
inline

Definition at line 31 of file mathd.

31 {return true;}

◆ in_domain_log()

bool tools::in_domain_log ( double  a_x)
inline

Definition at line 32 of file mathd.

32 {return (a_x>0?true:false);}

◆ in_domain_tan()

bool tools::in_domain_tan ( double  a_x)
inline

Definition at line 33 of file mathd.

33  {
34  int n = int(a_x/half_pi());
35  if(a_x!=n*half_pi()) return true;
36  return (2*int(n/2)==n?true:false);
37 }

◆ inside()

template<class T >
bool tools::inside ( const std::pair< T, T > &  a_P,
const std::vector< std::pair< T, T > > &  a_V 
)
inline

Definition at line 60 of file geom2.

60  {
61  // V[] = vertex points of a polygon V[n+1] with V[n]=V[0]
62 
63  // From :
64  // http://softsurfer.com/Archive/algorithm_0103/algorithm_0103.htm
65  // Copyright 2001, softSurfer (www.softsurfer.com)
66  // This code may be freely used and modified for any purpose
67  // providing that this copyright notice is included with it.
68  // SoftSurfer makes no warranty for this code, and cannot be held
69  // liable for any real or imagined damage resulting from its use.
70  // Users of this code must verify correctness for their application.
71 
72  size_t n = a_V.size()-1;
73 
74  int wn = 0; // the winding number counter
75 
76  // loop through all edges of the polygon
77  for (size_t i=0; i<n; i++) { // edge from V[i] to V[i+1]
78  if (a_V[i].second <= a_P.second) { // start y <= P[1]
79  if (a_V[i+1].second > a_P.second) // an upward crossing
80  if (is_left( a_V[i], a_V[i+1], a_P) > 0) // P left of edge
81  ++wn; // have a valid up intersect
82  } else { // start y > P[1] (no test needed)
83  if (a_V[i+1].second <= a_P.second) // a downward crossing
84  if (is_left( a_V[i], a_V[i+1], a_P) < 0) // P right of edge
85  --wn; // have a valid down intersect
86  }
87  }
88 
89  return ((wn!=0)?true:false);
90 }

◆ int32_format()

const char* tools::int32_format ( )
inline

Definition at line 68 of file typedefs.

68 {static const char s[] = "%d";return s;}

◆ int64_format()

const char* tools::int64_format ( )
inline

Definition at line 69 of file typedefs.

69 {static const char s[] = "%lld";return s;}

◆ intersect()

template<class VEC2 >
bool tools::intersect ( const VEC2 &  P1,
const VEC2 &  Q1,
const VEC2 &  P2,
const VEC2 &  Q2,
VEC2 &  a_out 
)
inline

Definition at line 93 of file geom2.

93  {
94  // (P1,Q1) first line, (P2,Q2) second line and a_out intersection.
95  // return false if no intersection. (For exa, parallel lines).
96 
97  // P1+(Q1-P1)*r = P2+(Q2-P2)*s
98  // (Q1-P1)*r - (Q2-P2)*s = P2-P1
99  // r*(Q1-P1).v0 - s*(Q2-P2).v0 = (P2-P1).v0 //x
100  // r*(Q1-P1).v1 - s*(Q2-P2).v1 = (P2-P1).v1 //y
101 
102  // a*r + b*s = c
103  // d*r + e*s = f
104 
105  // r = (c*e-f*b)/(a*e-d*b)
106  // s = (a*f-d*c)/(a*e-d*b)
107 
108  typedef typename VEC2::elem_t T;
109  VEC2 A = Q1-P1;
110  VEC2 B = P2-Q2;
111  VEC2 C = P2-P1;
112 
113  T a = A.v0();
114  T b = B.v0();
115  T c = C.v0();
116  T d = A.v1();
117  T e = B.v1();
118  T f = C.v1();
119 
120  T det = a*e-d*b;
121  if(det==T()) return false;
122 
123  T r = (c*e-f*b)/det;
124 
125  a_out = P1+A*r;
126  return true;
127 }

◆ is_absolute_path()

bool tools::is_absolute_path ( const std::string &  a_path)
inline

Definition at line 106 of file path.

106  {
107  if(a_path.find('\\')!=std::string::npos) { //Windows path.
108  if(a_path.find(':')!=std::string::npos) return true;
109  return (a_path.size()&&(a_path[0]=='\\')?true:false);
110  } else { //UNIX path
111  return (a_path.size()&&(a_path[0]=='/')?true:false);
112  }
113 }

◆ is_beg() [1/2]

bool tools::is_beg ( const std::string &  a_s,
const std::string &  a_b,
bool  a_forward = true 
)
inline

Definition at line 11 of file sbeg.

11  {
12  //look if a_s begin with a_b.
13  std::string::size_type ls = a_s.size();
14  std::string::size_type lb = a_b.size();
15  if(lb>ls) return false;
16  if(!lb) return false;
17  if(a_forward) {
18  const char* ps = a_s.c_str();
19  const char* pb = a_b.c_str();
20  for(std::string::size_type index=0;index<lb;index++,ps++,pb++) {
21  if(*ps!=*pb) return false;
22  }
23  } else {
24  const char* ps = a_s.c_str()+lb-1;
25  const char* pb = a_b.c_str()+lb-1;
26  for(std::string::size_type index=0;index<lb;index++,ps--,pb--) {
27  if(*ps!=*pb) return false;
28  }
29  }
30  return true;
31 }

◆ is_beg() [2/2]

bool tools::is_beg ( const std::string &  a_s,
const std::string &  a_b,
std::string &  a_cmd,
bool  a_forward = true 
)
inline

Definition at line 33 of file sbeg.

33  {
34  if(!tools::is_beg(a_s,a_b,a_forward)) {a_cmd.clear();return false;}
35  if(a_s.size()<(a_b.size()+1)) {a_cmd.clear();return true;}
36  // a_s.size() >= a_b.size()+1 :
37  a_cmd = a_s.substr(a_b.size()+1,a_s.size()-(a_b.size()+1));
38  return true;
39 }

◆ is_cpp()

bool tools::is_cpp ( const std::string &  a_path)
inline

Definition at line 244 of file path.

244  {
245  std::string sfx = suffix(a_path);
246 
247  //tolowercase(sfx);
248  for(std::string::iterator it=sfx.begin();it!=sfx.end();++it) {
249  char c = *it;
250  *it = ((c) >= 'A' && (c) <= 'Z' ? c - 'A' + 'a' : c);
251  }
252 
253  if(sfx=="c") return true;
254  if(sfx=="cxx") return true;
255  if(sfx=="cpp") return true;
256  if(sfx=="C") return true;
257  return false;
258 }

◆ is_digit()

bool tools::is_digit ( char  a_char)
inline

Definition at line 84 of file charmanip.

84  {
85  switch(a_char){
86  case '0':return true;
87  case '1':return true;
88  case '2':return true;
89  case '3':return true;
90  case '4':return true;
91  case '5':return true;
92  case '6':return true;
93  case '7':return true;
94  case '8':return true;
95  case '9':return true;
96  default:return false;
97  }
98  return false;
99 }

◆ is_env()

bool tools::is_env ( const std::string &  a_string)
inline

Definition at line 13 of file get_env.

13  {
14  const char* env = ::getenv(a_string.c_str());
15  return (env?true:false);
16 }

◆ is_f77()

bool tools::is_f77 ( const std::string &  a_path)
inline

Definition at line 226 of file path.

226  {
227  std::string sfx = suffix(a_path);
228 
229  //tolowercase(sfx);
230  for(std::string::iterator it=sfx.begin();it!=sfx.end();++it) {
231  char c = *it;
232  *it = ((c) >= 'A' && (c) <= 'Z' ? c - 'A' + 'a' : c);
233  }
234 
235  if(sfx=="f") return true; //the standard.
236  if(sfx=="for") return true; //for opaw. Known by g77.
237  if(sfx=="ftn") return true; //for opaw.
238  if(sfx=="fortran") return true; //for opaw.
239  if(sfx=="f77") return true;
240  return false;
241 }

◆ is_imag()

template<class MAT >
bool tools::is_imag ( MAT &  a_m,
typename MAT::elem_t::value_type(*)(const typename MAT::elem_t &)  a_real 
)
inline

Definition at line 215 of file mat.

215  {
216  typedef typename MAT::elem_t T;
217  T* pos = const_cast<T*>(a_m.data());
218  unsigned int D2 = a_m.dimension()*a_m.dimension();
219  for(unsigned int i=0;i<D2;i++,pos++) {if(a_real(*pos)) return false;}
220  return true;
221 }

◆ is_in()

template<class T >
bool tools::is_in ( const std::vector< T > &  a_vec,
const T &  a_item 
)
inline

Definition at line 171 of file vmanip.

171  {
172  typedef typename std::vector<T>::const_iterator it_t;
173  it_t it;
174  for(it=a_vec.begin();it!=a_vec.end();++it) {
175  if(*it==a_item) return true;
176  }
177  return false;
178 }

◆ is_inp()

template<class T >
bool tools::is_inp ( const std::vector< T * > &  a_vec,
const T *  a_item 
)
inline

Definition at line 100 of file vmanip.

100  {
101  typedef typename std::vector<T*>::const_iterator it_t;
102  for(it_t it=a_vec.begin();it!=a_vec.end();++it) {
103  if(*it==a_item) return true;
104  }
105  return false;
106 }

◆ is_inside()

template<class VEC2 >
bool tools::is_inside ( const VEC2 &  a_P,
const std::vector< VEC2 > &  a_V 
)
inline

Definition at line 19 of file geom2.

19  {
20  // V[] = vertex points of a polygon V[n+1] with V[n]=V[0]
21 
22  // From :
23  // http://softsurfer.com/Archive/algorithm_0103/algorithm_0103.htm
24  // Copyright 2001, softSurfer (www.softsurfer.com)
25  // This code may be freely used and modified for any purpose
26  // providing that this copyright notice is included with it.
27  // SoftSurfer makes no warranty for this code, and cannot be held
28  // liable for any real or imagined damage resulting from its use.
29  // Users of this code must verify correctness for their application.
30 
31  size_t n = a_V.size()-1;
32 
33  int wn = 0; // the winding number counter
34 
35  // loop through all edges of the polygon
36  for (size_t i=0; i<n; i++) { // edge from V[i] to V[i+1]
37  if (a_V[i].v1() <= a_P.v1()) { // start y <= P[1]
38  if (a_V[i+1].v1() > a_P.v1()) // an upward crossing
39  if (is_left( a_V[i], a_V[i+1], a_P) > 0) // P left of edge
40  ++wn; // have a valid up intersect
41  } else { // start y > P[1] (no test needed)
42  if (a_V[i+1].v1() <= a_P.v1()) // a downward crossing
43  if (is_left( a_V[i], a_V[i+1], a_P) < 0) // P right of edge
44  --wn; // have a valid down intersect
45  }
46  }
47 
48  return ((wn!=0)?true:false);
49 }

◆ is_key() [1/2]

template<class K , class V >
bool tools::is_key ( const std::map< K, V > &  a_map,
const K &  a_key 
)
inline

Definition at line 95 of file mapmanip.

95  {
96  typedef typename std::map<K,V>::const_iterator it_t;
97  it_t it = a_map.find(a_key);
98  if(it==a_map.end()) return false;
99  return true;
100 }

◆ is_key() [2/2]

template<class K , class V >
bool tools::is_key ( const std::vector< std::pair< K, V > > &  a_vec,
const K &  a_key 
)
inline

Definition at line 54 of file vpair.

54  {
55  typedef typename std::vector< std::pair<K,V> >::const_iterator it_t;
56  it_t it;
57  for(it=a_vec.begin();it!=a_vec.end();++it) {
58  if((*it).first==a_key) return true;
59  }
60  return false;
61 }

◆ is_left() [1/2]

template<class T >
double tools::is_left ( const std::pair< T, T > &  P0,
const std::pair< T, T > &  P1,
const std::pair< T, T > &  P2 
)
inline

Definition at line 54 of file geom2.

54  {
55  return ( (P1.first - P0.first) * (P2.second - P0.second)
56  - (P2.first - P0.first) * (P1.second - P0.second) );
57 }

◆ is_left() [2/2]

template<class VEC2 >
double tools::is_left ( const VEC2 &  P0,
const VEC2 &  P1,
const VEC2 &  P2 
)
inline

Definition at line 13 of file geom2.

13  {
14  return ( (P1.v0() - P0.v0()) * (P2.v1() - P0.v1())
15  - (P2.v0() - P0.v0()) * (P1.v1() - P0.v1()) );
16 }

◆ is_letter()

bool tools::is_letter ( char  a_char)
inline

Definition at line 101 of file charmanip.

101  {
102  return (is_lower(a_char)||is_upper(a_char)) ? true : false;
103 }

◆ is_little_endian()

bool tools::is_little_endian ( )
inline

Definition at line 13 of file platform.

13  {
14  unsigned int i = 1;
15  unsigned char* b = (unsigned char*)&i;
16  // BE = Big Endian, LE = Little Endian.
17  // The Intels x86 are LE.
18  // Mac PPC b[3] is 1 (BE)
19  // Mac Intel b[0] is 1 (LE)
20  // Linux i386 b[0] is 1 (LE)
21  // Linux x86_64 b[0] is 1 (LE)
22  return (b[0]==1?true:false);
23 }

◆ is_lower()

bool tools::is_lower ( char  a_char)
inline

Definition at line 51 of file charmanip.

51  {
52  switch(a_char) {
53  case 'a':return true;
54  case 'b':return true;
55  case 'c':return true;
56  case 'd':return true;
57  case 'e':return true;
58  case 'f':return true;
59  case 'g':return true;
60  case 'h':return true;
61  case 'i':return true;
62  case 'j':return true;
63  case 'k':return true;
64  case 'l':return true;
65  case 'm':return true;
66  case 'n':return true;
67  case 'o':return true;
68  case 'p':return true;
69  case 'q':return true;
70  case 'r':return true;
71  case 's':return true;
72  case 't':return true;
73  case 'u':return true;
74  case 'v':return true;
75  case 'w':return true;
76  case 'x':return true;
77  case 'y':return true;
78  case 'z':return true;
79  default:return false;
80  }
81  return false;
82 }

◆ is_mac_app()

bool tools::is_mac_app ( const std::string &  )
inline

Definition at line 23 of file app.

23 {return false;}

◆ is_printable()

bool tools::is_printable ( char  a_char)
inline

Definition at line 109 of file charmanip.

109  {
110  if(is_lower(a_char)||is_upper(a_char)||is_digit(a_char)) return true;
111  switch(a_char) {
112  case ' ':return true;
113  case '!':return true;
114  case '"':return true;
115  case '#':return true;
116  case '$':return true;
117  case '%':return true;
118  case '&':return true;
119  case '\'':return true;
120  case '(':return true;
121  case ')':return true;
122  case '*':return true;
123  case '+':return true;
124  case ',':return true;
125  case '-':return true;
126  case '.':return true;
127  case '/':return true;
128  case ':':return true;
129  case ';':return true;
130  case '<':return true;
131  case '=':return true;
132  case '>':return true;
133  case '?':return true;
134  case '@':return true;
135  case '[':return true;
136  case '\\':return true;
137  case ']':return true;
138  case '^':return true;
139  case '_':return true;
140  case '`':return true;
141  case '{':return true;
142  case '|':return true;
143  case '}':return true;
144  case '~':return true;
145  default:return false;
146  }
147  return false;
148 }

◆ is_python()

bool tools::is_python ( const std::string &  a_path)
inline

Definition at line 261 of file path.

261  {
262  std::string sfx = suffix(a_path);
263 
264  //tolowercase(sfx);
265  for(std::string::iterator it=sfx.begin();it!=sfx.end();++it) {
266  char c = *it;
267  *it = ((c) >= 'A' && (c) <= 'Z' ? c - 'A' + 'a' : c);
268  }
269 
270  if(sfx=="py") return true;
271  return false;
272 }

◆ is_real()

template<class MAT >
bool tools::is_real ( MAT &  a_m,
typename MAT::elem_t::value_type(*)(const typename MAT::elem_t &)  a_imag 
)
inline

Definition at line 196 of file mat.

196  {
197  typedef typename MAT::elem_t T;
198  T* pos = const_cast<T*>(a_m.data());
199  unsigned int D2 = a_m.dimension()*a_m.dimension();
200  for(unsigned int i=0;i<D2;i++,pos++) {if(a_imag(*pos)) return false;}
201  return true;
202 }

◆ is_real_prec()

template<class MAT , class PREC >
bool tools::is_real_prec ( MAT &  a_m,
typename MAT::elem_t::value_type(*)(const typename MAT::elem_t &)  a_imag,
const PREC &  a_prec,
PREC(*)(const typename MAT::elem_t::value_type &)  a_fabs 
)
inline

Definition at line 205 of file mat.

206  {\
207  typedef typename MAT::elem_t T;
208  T* pos = const_cast<T*>(a_m.data());
209  unsigned int D2 = a_m.dimension()*a_m.dimension();
210  for(unsigned int i=0;i<D2;i++,pos++) {if(a_fabs(a_imag(*pos))>=a_prec) return false;}
211  return true;
212 }

◆ is_spaces()

bool tools::is_spaces ( const std::string &  a_string)
inline

Definition at line 28 of file schar.

28  {
29  std::string::const_iterator it;
30  for(it=a_string.begin();it!=a_string.end();++it) {
31  if((*it)!=' ') return false;
32  }
33  return true;
34 }

◆ is_upper()

bool tools::is_upper ( char  a_char)
inline

Definition at line 16 of file charmanip.

16  {
17  // do it myself: due to problem with ctype.h and
18  // isxxx macros on different platforms.
19  switch(a_char) {
20  case 'A':return true;
21  case 'B':return true;
22  case 'C':return true;
23  case 'D':return true;
24  case 'E':return true;
25  case 'F':return true;
26  case 'G':return true;
27  case 'H':return true;
28  case 'I':return true;
29  case 'J':return true;
30  case 'K':return true;
31  case 'L':return true;
32  case 'M':return true;
33  case 'N':return true;
34  case 'O':return true;
35  case 'P':return true;
36  case 'Q':return true;
37  case 'R':return true;
38  case 'S':return true;
39  case 'T':return true;
40  case 'U':return true;
41  case 'V':return true;
42  case 'W':return true;
43  case 'X':return true;
44  case 'Y':return true;
45  case 'Z':return true;
46  default:return false;
47  }
48  return false;
49 }

◆ is_zero()

template<class NUMBER , class PREC >
bool tools::is_zero ( const NUMBER &  a_left,
const PREC &  a_prec,
PREC(*)(const NUMBER &)  a_fabs 
)
inline

Definition at line 17 of file eqT.

17  {
18  if(a_fabs(a_left)>=a_prec) return false;
19  return true;
20 }

◆ item_index()

template<class T >
bool tools::item_index ( const std::vector< T > &  a_vec,
const T &  a_item,
unsigned int &  a_index 
)
inline

Definition at line 181 of file vmanip.

181  {
182  a_index = 0;
183  typedef typename std::vector<T>::const_iterator it_t;
184  it_t it;
185  for(it=a_vec.begin();it!=a_vec.end();++it,a_index++) {
186  if(*it==a_item) return true;
187  }
188  a_index = 0;
189  return false;
190 }

◆ ldfabs()

long double tools::ldfabs ( const long double &  a_x)
inline

Definition at line 72 of file mathd.

72 {return ::fabsl(a_x);}

◆ LF()

char tools::LF ( )
inline

Definition at line 16 of file chars.

16 {return 10;}

◆ mat3_zero()

template<class T >
const mat3<T>& tools::mat3_zero ( )
inline

common matrices : //////////////////////////

Definition at line 210 of file mat3.

210  {
211  static const mat3<T> s_v(false); //inc mem count = false
212  return s_v;
213 }

◆ mat4_zero()

template<class T >
const mat4<T>& tools::mat4_zero ( )
inline

common matrices : //////////////////////////

Definition at line 479 of file mat4.

479 {static const mat4<T> s_v;return s_v;}

◆ mat_equal()

template<class MAT , class REAL >
bool tools::mat_equal ( std::ostream &  a_out,
const char *  a_file,
int  a_line,
const MAT &  a_1,
const MAT &  a_2,
const REAL &  a_tolerance,
REAL(*)(const REAL &)  a_fabs 
)
inline

Definition at line 160 of file test.

160  {
161  if(a_1.dimension()!=a_2.dimension()) {
162  a_out << "failed in file :" << std::endl
163  << a_file << std::endl
164  << "at line :" << std::endl
165  << a_line << std::endl
166  << "matrix dimension " << a_1.dimension() << " != " << a_2.dimension() << std::endl;
167  return false;
168  }
169  if(a_1.data_size()!=a_2.data_size()) {
170  a_out << "failed in file :" << std::endl
171  << a_file << std::endl
172  << "at line :" << std::endl
173  << a_line << std::endl
174  << "matrix data_size " << a_1.data_size() << " != " << a_2.data_size() << std::endl;
175  return false;
176  }
177  for(size_t index=0;index<a_1.data_size();index++) {
178  if(!equal<REAL>(a_out,a_file,a_line,a_1.data()[index],a_2.data()[index],a_tolerance,a_fabs)) return false;
179  }
180  return true;
181 }

◆ mat_fabs()

template<class MAT , class REAL >
bool tools::mat_fabs ( const MAT &  a_in,
MAT &  a_ou,
REAL(*)(const typename MAT::elem_t &)  a_fabs 
)
inline

Definition at line 470 of file mat.

470  {
471  if(a_in.dimension()!=a_ou.dimension()) {a_ou.set_zero();return false;}
472  typedef typename MAT::elem_t T;
473  T* in_pos = const_cast<T*>(a_in.data());
474  T* ou_pos = const_cast<T*>(a_ou.data());
475  unsigned int D2 = a_in.dimension()*a_in.dimension();
476  for(unsigned int i=0;i<D2;i++,in_pos++,ou_pos++) {*ou_pos = a_fabs(*in_pos);}
477  return true;
478 }

◆ match()

bool tools::match ( const std::string &  a_string,
const std::string &  a_pattern,
bool  a_check_for_wilds = true 
)
inline

Definition at line 12 of file smatch.

12  {
13  std::string::size_type lpattern = a_pattern.length();
14  std::string::size_type lstring = a_string.length();
15  if ((lpattern==0)&&(lstring==0)) return true;
16  if ((lpattern==0)&&(lstring!=0)) return true;
17  if ((lpattern!=0)&&(lstring==0)) return false;
18 
19  if((lpattern==1)&&(a_pattern[0]=='*')) return true;
20 
21  if(a_check_for_wilds) {
22  bool some_star = false;
23  for(std::string::size_type count=0;count<lpattern;count++) {
24  if(a_pattern[count]=='*') {some_star = true;break;}
25  }
26  if(!some_star) { // no wildcard :
27  return (a_pattern==a_string ? true : false );
28  }
29  }
30 
31  // complex pattern :
32  //std::string::size_type* wps = new std::string::size_type[2*lpattern];
33  if((2*lpattern)>1024) return false; //throw
34  std::string::size_type wps[1024]; //OPTIMIZATION : we gain a lot with that.
35 
36  unsigned int wn;
37  std::string::size_type* wls = wps+lpattern;
38  words(a_pattern,"*",false,wn,wps,wls);
39  if(!wn) {
40  //delete [] wps;
41  return true; // only wildcards :
42  }
43 
44  // tricky case :
45  char* token = (char*)a_string.c_str();
46  {for(unsigned int count=0;count<wn;count++) {
47  size_t lword = wls[count];
48  if(!lword) continue;//should never happen !
49  //WARNING : ws_pos does not have a null char at ws_pos+lword !
50  char* ws_pos = (char*)(a_pattern.c_str()+wps[count]);
51  if(count==0) {
52  if(a_pattern[0]!='*') {
53  // Begin of pattern (ws[0]) and a_string must match :
54  if(::strncmp(token,ws_pos,lword)) {
55  //delete [] wps;
56  return false;
57  }
58  token = token + lword;
59  continue;
60  }
61  }
62  char old_char = *(ws_pos+lword);
63  *(ws_pos+lword) = 0;
64  char* pos = ::strstr(token,ws_pos);
65  *(ws_pos+lword) = old_char;
66  if(!pos) {
67  //delete [] wps;
68  return false;
69  }
70  if((count==(wn-1)) && (a_pattern[lpattern-1]!='*') ) { // Last word.
71  // Compare last word and end of a_string.
72  if(::strncmp(a_string.c_str()+lstring-lword,ws_pos,lword)) {
73  //delete [] wps;
74  return false;
75  }
76  break;
77  } else {
78  token = pos + lword;
79  }
80  }}
81 
82  //delete [] wps;
83  return true;
84 }

◆ match2()

bool tools::match2 ( const std::string &  a_string,
const std::string &  a_pattern 
)
inline

Definition at line 87 of file smatch.

87  {
88  return match(a_string,a_pattern,true);
89 }

◆ matrix_set() [1/6]

template<class MAT >
void tools::matrix_set ( MAT &  a_m,
TOOLS_MELEM  a_00,
TOOLS_MELEM  a_01,
TOOLS_MELEM  a_02,
TOOLS_MELEM  a_03,
TOOLS_MELEM  a_04,
TOOLS_MELEM  a_05,
TOOLS_MELEM  a_06,
TOOLS_MELEM  a_07,
TOOLS_MELEM  a_08,
TOOLS_MELEM  a_09,
TOOLS_MELEM  a_10,
TOOLS_MELEM  a_11,
TOOLS_MELEM  a_12,
TOOLS_MELEM  a_13,
TOOLS_MELEM  a_14,
TOOLS_MELEM  a_15,
TOOLS_MELEM  a_16,
TOOLS_MELEM  a_17,
TOOLS_MELEM  a_18,
TOOLS_MELEM  a_19,
TOOLS_MELEM  a_20,
TOOLS_MELEM  a_21,
TOOLS_MELEM  a_22,
TOOLS_MELEM  a_23,
TOOLS_MELEM  a_24,
TOOLS_MELEM  a_25,
TOOLS_MELEM  a_26,
TOOLS_MELEM  a_27,
TOOLS_MELEM  a_28,
TOOLS_MELEM  a_29,
TOOLS_MELEM  a_30,
TOOLS_MELEM  a_31,
TOOLS_MELEM  a_32,
TOOLS_MELEM  a_33,
TOOLS_MELEM  a_34,
TOOLS_MELEM  a_35,
TOOLS_MELEM  a_36,
TOOLS_MELEM  a_37,
TOOLS_MELEM  a_38,
TOOLS_MELEM  a_39,
TOOLS_MELEM  a_40,
TOOLS_MELEM  a_41,
TOOLS_MELEM  a_42,
TOOLS_MELEM  a_43,
TOOLS_MELEM  a_44,
TOOLS_MELEM  a_45,
TOOLS_MELEM  a_46,
TOOLS_MELEM  a_47,
TOOLS_MELEM  a_48,
TOOLS_MELEM  a_49,
TOOLS_MELEM  a_50,
TOOLS_MELEM  a_51,
TOOLS_MELEM  a_52,
TOOLS_MELEM  a_53,
TOOLS_MELEM  a_54,
TOOLS_MELEM  a_55,
TOOLS_MELEM  a_56,
TOOLS_MELEM  a_57,
TOOLS_MELEM  a_58,
TOOLS_MELEM  a_59,
TOOLS_MELEM  a_60,
TOOLS_MELEM  a_61,
TOOLS_MELEM  a_62,
TOOLS_MELEM  a_63,
TOOLS_MELEM  a_64,
TOOLS_MELEM  a_65,
TOOLS_MELEM  a_66,
TOOLS_MELEM  a_67,
TOOLS_MELEM  a_68,
TOOLS_MELEM  a_69,
TOOLS_MELEM  a_70,
TOOLS_MELEM  a_71,
TOOLS_MELEM  a_72,
TOOLS_MELEM  a_73,
TOOLS_MELEM  a_74,
TOOLS_MELEM  a_75,
TOOLS_MELEM  a_76,
TOOLS_MELEM  a_77,
TOOLS_MELEM  a_78,
TOOLS_MELEM  a_79,
TOOLS_MELEM  a_80,
TOOLS_MELEM  a_81,
TOOLS_MELEM  a_82,
TOOLS_MELEM  a_83,
TOOLS_MELEM  a_84,
TOOLS_MELEM  a_85,
TOOLS_MELEM  a_86,
TOOLS_MELEM  a_87,
TOOLS_MELEM  a_88,
TOOLS_MELEM  a_89,
TOOLS_MELEM  a_90,
TOOLS_MELEM  a_91,
TOOLS_MELEM  a_92,
TOOLS_MELEM  a_93,
TOOLS_MELEM  a_94,
TOOLS_MELEM  a_95,
TOOLS_MELEM  a_96,
TOOLS_MELEM  a_97,
TOOLS_MELEM  a_98,
TOOLS_MELEM  a_99 
)
inline

specific D=10 //////////////////////////////

Definition at line 607 of file mat.

619  {
620  //a_<R><C>
621  //vec[R + C * 10];
622  typename MAT::elem_t* vec = const_cast<typename MAT::elem_t*>(a_m.data());
623  vec[0] = a_00;vec[10] = a_01;vec[20] = a_02;vec[30] = a_03;vec[40] = a_04;vec[50] = a_05;vec[60] = a_06;vec[70] = a_07;vec[80] = a_08;vec[90] = a_09;
624  vec[1] = a_10;vec[11] = a_11;vec[21] = a_12;vec[31] = a_13;vec[41] = a_14;vec[51] = a_15;vec[61] = a_16;vec[71] = a_17;vec[81] = a_18;vec[91] = a_19;
625  vec[2] = a_20;vec[12] = a_21;vec[22] = a_22;vec[32] = a_23;vec[42] = a_24;vec[52] = a_25;vec[62] = a_26;vec[72] = a_27;vec[82] = a_28;vec[92] = a_29;
626  vec[3] = a_30;vec[13] = a_31;vec[23] = a_32;vec[33] = a_33;vec[43] = a_34;vec[53] = a_35;vec[63] = a_36;vec[73] = a_37;vec[83] = a_38;vec[93] = a_39;
627  vec[4] = a_40;vec[14] = a_41;vec[24] = a_42;vec[34] = a_43;vec[44] = a_44;vec[54] = a_45;vec[64] = a_46;vec[74] = a_47;vec[84] = a_48;vec[94] = a_49;
628  vec[5] = a_50;vec[15] = a_51;vec[25] = a_52;vec[35] = a_53;vec[45] = a_54;vec[55] = a_55;vec[65] = a_56;vec[75] = a_57;vec[85] = a_58;vec[95] = a_59;
629  vec[6] = a_60;vec[16] = a_61;vec[26] = a_62;vec[36] = a_63;vec[46] = a_64;vec[56] = a_65;vec[66] = a_66;vec[76] = a_67;vec[86] = a_68;vec[96] = a_69;
630  vec[7] = a_70;vec[17] = a_71;vec[27] = a_72;vec[37] = a_73;vec[47] = a_74;vec[57] = a_75;vec[67] = a_76;vec[77] = a_77;vec[87] = a_78;vec[97] = a_79;
631  vec[8] = a_80;vec[18] = a_81;vec[28] = a_82;vec[38] = a_83;vec[48] = a_84;vec[58] = a_85;vec[68] = a_86;vec[78] = a_87;vec[88] = a_88;vec[98] = a_89;
632  vec[9] = a_90;vec[19] = a_91;vec[29] = a_92;vec[39] = a_93;vec[49] = a_94;vec[59] = a_95;vec[69] = a_96;vec[79] = a_97;vec[89] = a_98;vec[99] = a_99;
633 }

◆ matrix_set() [2/6]

template<class MAT >
void tools::matrix_set ( MAT &  a_m,
TOOLS_MELEM  a_00,
TOOLS_MELEM  a_01,
TOOLS_MELEM  a_02,
TOOLS_MELEM  a_03,
TOOLS_MELEM  a_04,
TOOLS_MELEM  a_05,
TOOLS_MELEM  a_10,
TOOLS_MELEM  a_11,
TOOLS_MELEM  a_12,
TOOLS_MELEM  a_13,
TOOLS_MELEM  a_14,
TOOLS_MELEM  a_15,
TOOLS_MELEM  a_20,
TOOLS_MELEM  a_21,
TOOLS_MELEM  a_22,
TOOLS_MELEM  a_23,
TOOLS_MELEM  a_24,
TOOLS_MELEM  a_25,
TOOLS_MELEM  a_30,
TOOLS_MELEM  a_31,
TOOLS_MELEM  a_32,
TOOLS_MELEM  a_33,
TOOLS_MELEM  a_34,
TOOLS_MELEM  a_35,
TOOLS_MELEM  a_40,
TOOLS_MELEM  a_41,
TOOLS_MELEM  a_42,
TOOLS_MELEM  a_43,
TOOLS_MELEM  a_44,
TOOLS_MELEM  a_45,
TOOLS_MELEM  a_50,
TOOLS_MELEM  a_51,
TOOLS_MELEM  a_52,
TOOLS_MELEM  a_53,
TOOLS_MELEM  a_54,
TOOLS_MELEM  a_55 
)
inline

specific D=6 ///////////////////////////////

Definition at line 584 of file mat.

591  {
592  //a_<R><C>
593  //vec[R + C * 6];
594  typename MAT::elem_t* vec = const_cast<typename MAT::elem_t*>(a_m.data());
595  vec[0] = a_00;vec[ 6] = a_01;vec[12] = a_02;vec[18] = a_03;vec[24] = a_04;vec[30] = a_05;
596  vec[1] = a_10;vec[ 7] = a_11;vec[13] = a_12;vec[19] = a_13;vec[25] = a_14;vec[31] = a_15;
597  vec[2] = a_20;vec[ 8] = a_21;vec[14] = a_22;vec[20] = a_23;vec[26] = a_24;vec[32] = a_25;
598  vec[3] = a_30;vec[ 9] = a_31;vec[15] = a_32;vec[21] = a_33;vec[27] = a_34;vec[33] = a_35;
599  vec[4] = a_40;vec[10] = a_41;vec[16] = a_42;vec[22] = a_43;vec[28] = a_44;vec[34] = a_45;
600  vec[5] = a_50;vec[11] = a_51;vec[17] = a_52;vec[23] = a_53;vec[29] = a_54;vec[35] = a_55;
601 }

◆ matrix_set() [3/6]

template<class MAT >
void tools::matrix_set ( MAT &  a_m,
TOOLS_MELEM  a_00,
TOOLS_MELEM  a_01,
TOOLS_MELEM  a_02,
TOOLS_MELEM  a_03,
TOOLS_MELEM  a_04,
TOOLS_MELEM  a_10,
TOOLS_MELEM  a_11,
TOOLS_MELEM  a_12,
TOOLS_MELEM  a_13,
TOOLS_MELEM  a_14,
TOOLS_MELEM  a_20,
TOOLS_MELEM  a_21,
TOOLS_MELEM  a_22,
TOOLS_MELEM  a_23,
TOOLS_MELEM  a_24,
TOOLS_MELEM  a_30,
TOOLS_MELEM  a_31,
TOOLS_MELEM  a_32,
TOOLS_MELEM  a_33,
TOOLS_MELEM  a_34,
TOOLS_MELEM  a_40,
TOOLS_MELEM  a_41,
TOOLS_MELEM  a_42,
TOOLS_MELEM  a_43,
TOOLS_MELEM  a_44 
)
inline

specific D=5 ///////////////////////////////

Definition at line 563 of file mat.

569  {
570  //a_<R><C>
571  //vec[R + C * 5];
572  typename MAT::elem_t* vec = const_cast<typename MAT::elem_t*>(a_m.data());
573  vec[0] = a_00;vec[5] = a_01;vec[10] = a_02;vec[15] = a_03;vec[20] = a_04;
574  vec[1] = a_10;vec[6] = a_11;vec[11] = a_12;vec[16] = a_13;vec[21] = a_14;
575  vec[2] = a_20;vec[7] = a_21;vec[12] = a_22;vec[17] = a_23;vec[22] = a_24;
576  vec[3] = a_30;vec[8] = a_31;vec[13] = a_32;vec[18] = a_33;vec[23] = a_34;
577  vec[4] = a_40;vec[9] = a_41;vec[14] = a_42;vec[19] = a_43;vec[24] = a_44;
578 }

◆ matrix_set() [4/6]

template<class MAT >
void tools::matrix_set ( MAT &  a_m,
TOOLS_MELEM  a_00,
TOOLS_MELEM  a_01,
TOOLS_MELEM  a_02,
TOOLS_MELEM  a_03,
TOOLS_MELEM  a_10,
TOOLS_MELEM  a_11,
TOOLS_MELEM  a_12,
TOOLS_MELEM  a_13,
TOOLS_MELEM  a_20,
TOOLS_MELEM  a_21,
TOOLS_MELEM  a_22,
TOOLS_MELEM  a_23,
TOOLS_MELEM  a_30,
TOOLS_MELEM  a_31,
TOOLS_MELEM  a_32,
TOOLS_MELEM  a_33 
)
inline

specific D=4 ///////////////////////////////

Definition at line 544 of file mat.

549  {
550  //a_<R><C>
551  //vec[R + C * 4];
552  typename MAT::elem_t* vec = const_cast<typename MAT::elem_t*>(a_m.data());
553  vec[0] = a_00;vec[4] = a_01;vec[ 8] = a_02;vec[12] = a_03;
554  vec[1] = a_10;vec[5] = a_11;vec[ 9] = a_12;vec[13] = a_13;
555  vec[2] = a_20;vec[6] = a_21;vec[10] = a_22;vec[14] = a_23;
556  vec[3] = a_30;vec[7] = a_31;vec[11] = a_32;vec[15] = a_33;
557 }

◆ matrix_set() [5/6]

template<class MAT >
void tools::matrix_set ( MAT &  a_m,
TOOLS_MELEM  a_00,
TOOLS_MELEM  a_01,
TOOLS_MELEM  a_02,
TOOLS_MELEM  a_10,
TOOLS_MELEM  a_11,
TOOLS_MELEM  a_12,
TOOLS_MELEM  a_20,
TOOLS_MELEM  a_21,
TOOLS_MELEM  a_22 
)
inline

specific D=3 ///////////////////////////////

Definition at line 527 of file mat.

531  {
532  //a_<R><C>
533  //vec[R + C * 3];
534  typename MAT::elem_t* vec = const_cast<typename MAT::elem_t*>(a_m.data());
535  vec[0] = a_00;vec[3] = a_01;vec[6] = a_02;
536  vec[1] = a_10;vec[4] = a_11;vec[7] = a_12;
537  vec[2] = a_20;vec[5] = a_21;vec[8] = a_22;
538 }

◆ matrix_set() [6/6]

template<class MAT >
void tools::matrix_set ( MAT &  a_m,
TOOLS_MELEM  a_00,
TOOLS_MELEM  a_01,
TOOLS_MELEM  a_10,
TOOLS_MELEM  a_11 
)
inline

specific D=2 ///////////////////////////////

Definition at line 512 of file mat.

515  {
516  //a_<R><C>
517  //vec[R + C * 2];
518  typename MAT::elem_t* vec = const_cast<typename MAT::elem_t*>(a_m.data());
519  vec[0] = a_00;vec[2] = a_01;
520  vec[1] = a_10;vec[3] = a_11;
521 }

◆ max_of()

template<class T >
T tools::max_of ( const T &  a,
const T &  b 
)
inline

Definition at line 20 of file mnmx.

20 {return (a>b?a:b);}

◆ maximum()

template<class T >
bool tools::maximum ( const std::vector< T > &  a_vec,
T &  a_value 
)
inline

Definition at line 214 of file vmanip.

214  {
215  if(a_vec.empty()) {a_value = T();return false;}
216  a_value = a_vec[0];
217  typedef typename std::vector<T>::const_iterator it_t;
218  for(it_t it = a_vec.begin();it!=a_vec.end();++it) {
219  a_value = (a_value>(*it)?a_value:(*it));
220  }
221  return true;
222 }

◆ mean_rms() [1/2]

template<class T >
bool tools::mean_rms ( const std::vector< T > &  a_vec,
T &  a_mean,
T &  a_rms,
T(*)(const T &)  a_sqrt,
T(*)(const T &)  a_fabs 
)
inline

T(*a_fabs)(const T&) : ///////////////////////////////////////////////////////////////////////////////////////////.

Definition at line 414 of file vmanip.

414  {
415  if(a_vec.empty()) {a_mean=T();a_rms=T();return false;}
416  T S = T();
417  T S2 = T();
418  typedef typename std::vector<T>::const_iterator it_t;
419  for(it_t it = a_vec.begin();it!=a_vec.end();++it) {
420  S += *it;
421  S2 += (*it) * (*it);
422  }
423  a_mean = S/T(a_vec.size());
424  a_rms = a_sqrt(a_fabs(S2/T(a_vec.size()) - a_mean * a_mean));
425  return true;
426 }

◆ mean_rms() [2/2]

template<class T >
bool tools::mean_rms ( const std::vector< T > &  a_vec,
T &  a_mean,
T &  a_rms,
T(*)(T)  a_sqrt,
T(*)(T)  a_fabs 
)
inline

T(*a_fabs)(T) : ///////////////////////////////////////////////////////////////////////////////////////////.

Definition at line 376 of file vmanip.

376  {
377  if(a_vec.empty()) {a_mean=T();a_rms=T();return false;}
378  T S = T();
379  T S2 = T();
380  typedef typename std::vector<T>::const_iterator it_t;
381  for(it_t it = a_vec.begin();it!=a_vec.end();++it) {
382  S += *it;
383  S2 += (*it) * (*it);
384  }
385  a_mean = S/T(a_vec.size());
386  a_rms = a_sqrt(a_fabs(S2/T(a_vec.size()) - a_mean * a_mean));
387  return true;
388 }

◆ mem_alloc()

void* tools::mem_alloc ( size_t  a_size)
inline

Definition at line 33 of file memalloc.

33 {return ::memset( ::malloc( a_size ), 0xa5, a_size);}

◆ mem_free()

void tools::mem_free ( void *  a_ptr)
inline

Definition at line 35 of file memalloc.

35 {::free(a_ptr);}

◆ mem_init()

int tools::mem_init ( size_t  )
inline

Definition at line 36 of file memalloc.

36 {return 1;}

◆ mem_realloc()

void* tools::mem_realloc ( void *  a_ptr,
size_t  a_size 
)
inline

Definition at line 34 of file memalloc.

34 {return ::realloc(a_ptr,a_size);}

◆ min_max() [1/2]

template<class T >
bool tools::min_max ( const std::vector< T > &  a_vec,
T &  a_min,
T &  a_max 
)
inline

Definition at line 360 of file vmanip.

360  {
361  if(a_vec.empty()) {a_min=T();a_max=T();return false;}
362  a_min = *(a_vec.begin());
363  a_max = a_min;
364  typedef typename std::vector<T>::const_iterator it_t;
365  for(it_t it = a_vec.begin();it!=a_vec.end();++it) {
366  a_min = *it<a_min?*it:a_min;
367  a_max = *it>a_max?*it:a_max;
368  }
369  return true;
370 }

◆ min_max() [2/2]

template<class I , class T , class TO >
bool tools::min_max ( a_n,
const void *  a_v,
TO &  a_mn,
TO &  a_mx 
)
inline

Definition at line 72 of file carray.

72  {
73  if(a_n<=I(0)) {a_mn = TO(0);a_mx = TO(0);return false;}
74  T* pos = (T*)a_v;
75  a_mn = *pos;
76  a_mx = *pos;
77  for(I i=0;i<a_n;i++,pos++) {
78  a_mn = mn<TO>(a_mn,*pos);
79  a_mx = mx<TO>(a_mx,*pos);
80  }
81  return true;
82 }

◆ min_max_mean_rms() [1/3]

template<class T >
bool tools::min_max_mean_rms ( const std::vector< T > &  a_vec,
T &  a_min,
T &  a_max,
T &  a_mean,
T &  a_rms,
T(*)(const T &)  a_sqrt,
T(*)(const T &)  a_fabs 
)
inline

Definition at line 429 of file vmanip.

430  {
431  if(a_vec.empty()) {a_min=T();a_max=T();a_mean=T();a_rms=T();return false;}
432  a_min = *(a_vec.begin());
433  a_max = a_min;
434  T S = T();
435  T S2 = T();
436  typedef typename std::vector<T>::const_iterator it_t;
437  for(it_t it = a_vec.begin();it!=a_vec.end();++it) {
438  a_min = *it<a_min?*it:a_min;
439  a_max = *it>a_max?*it:a_max;
440  S += *it;
441  S2 += (*it) * (*it);
442  }
443  a_mean = S/T(a_vec.size());
444  a_rms = a_sqrt(a_fabs(S2/T(a_vec.size()) - a_mean * a_mean));
445  return true;
446 }

◆ min_max_mean_rms() [2/3]

template<class T >
bool tools::min_max_mean_rms ( const std::vector< T > &  a_vec,
T &  a_min,
T &  a_max,
T &  a_mean,
T &  a_rms,
T(*)(T)  a_sqrt,
T(*)(T)  a_fabs 
)
inline

Definition at line 391 of file vmanip.

392  {
393  if(a_vec.empty()) {a_min=T();a_max=T();a_mean=T();a_rms=T();return false;}
394  a_min = *(a_vec.begin());
395  a_max = a_min;
396  T S = T();
397  T S2 = T();
398  typedef typename std::vector<T>::const_iterator it_t;
399  for(it_t it = a_vec.begin();it!=a_vec.end();++it) {
400  a_min = *it<a_min?*it:a_min;
401  a_max = *it>a_max?*it:a_max;
402  S += *it;
403  S2 += (*it) * (*it);
404  }
405  a_mean = S/T(a_vec.size());
406  a_rms = a_sqrt(a_fabs(S2/T(a_vec.size()) - a_mean * a_mean));
407  return true;
408 }

◆ min_max_mean_rms() [3/3]

template<class I , class T , class TO >
bool tools::min_max_mean_rms ( a_n,
const void *  a_v,
TO &  a_mn,
TO &  a_mx,
TO &  a_mean,
TO &  a_rms,
TO(*)(TO)  a_sqrt,
TO(*)(TO)  a_fabs 
)
inline

Definition at line 102 of file carray.

103  {
104  TO S = TO(0);
105  TO S2 = TO(0);
106  if(!min_max_S_S2<I,T,TO>(a_n,a_v,a_mn,a_mx,S,S2)) {
107  a_mn = TO(0);a_mx = TO(0);a_mean=TO(0);a_rms=TO(0);
108  return false;
109  }
110  a_mean = S/TO(a_n);
111  a_rms = a_sqrt(a_fabs(S2/TO(a_n) - a_mean * a_mean));
112  return true;
113 }

◆ min_max_S_S2()

template<class I , class T , class TO >
bool tools::min_max_S_S2 ( a_n,
const void *  a_v,
TO &  a_mn,
TO &  a_mx,
TO &  a_S,
TO &  a_S2 
)
inline

Definition at line 85 of file carray.

85  {
86  if(a_n<=0) {a_mn = TO(0);a_mx = TO(0);a_S=TO(0);a_S2=TO(0);return false;}
87  T* pos = (T*)a_v;
88  a_mn = *pos;
89  a_mx = *pos;
90  a_S = TO(0);
91  a_S2 = TO(0);
92  for(I i=0;i<a_n;i++,pos++) {
93  a_mn = mn<TO>(a_mn,*pos);
94  a_mx = mx<TO>(a_mx,*pos);
95  a_S += TO(*pos);
96  a_S2 += TO(*pos) * TO(*pos);
97  }
98  return true;
99 }

◆ min_of()

template<class T >
T tools::min_of ( const T &  a,
const T &  b 
)
inline

Definition at line 17 of file mnmx.

17 {return (a<b?a:b);}

◆ minimum()

template<class T >
bool tools::minimum ( const std::vector< T > &  a_vec,
T &  a_value 
)
inline

Definition at line 203 of file vmanip.

203  {
204  if(a_vec.empty()) {a_value = T();return false;}
205  a_value = a_vec[0];
206  typedef typename std::vector<T>::const_iterator it_t;
207  for(it_t it = a_vec.begin();it!=a_vec.end();++it) {
208  a_value = (a_value<(*it)?a_value:(*it));
209  }
210  return true;
211 }

◆ mn()

template<class T >
T tools::mn ( const T &  a,
const T &  b 
)
inline

Definition at line 10 of file mnmx.

10 {return (a<b?a:b);}

◆ mnmx()

bool tools::mnmx ( std::ostream &  a_out,
sg::node a_node,
vec3f a_mn,
vec3f a_mx 
)
inline

Definition at line 12 of file mnmx.

12  {
13  sg::bbox_action action(a_out);
14  a_node.bbox(action);
15  if(!action.end() || action.box().is_empty()) {
16  a_out << "tools::mnmx :"
17  << " bbox problem."
18  << std::endl;
19  a_mn.set_value(0,0,0);
20  a_mx.set_value(0,0,0);
21  return false;
22  }
23  a_mn = action.box().mn();
24  a_mx = action.box().mx();
25  return true;
26 }

◆ mul()

template<class T >
void tools::mul ( std::vector< T > &  a_vec,
const T &  a_v 
)
inline

Definition at line 324 of file vmanip.

324  {
325  typedef typename std::vector<T>::iterator it_t;
326  for(it_t it=a_vec.begin();it!=a_vec.end();++it) *it *= a_v;
327 }

◆ multiply() [1/2]

template<class VECTOR >
void tools::multiply ( VECTOR &  a_vec,
const typename VECTOR::value_type &  a_mat 
)
inline

Definition at line 167 of file mat.

167  {
168  //typedef typename VECTOR::size_type sz_t;
169  //sz_t number = a_vec.size();
170  //for(sz_t index=0;index<number;index++) a_vec[index] *= a_mat;
171  typedef typename VECTOR::iterator it_t;
172  for(it_t it=a_vec.begin();it!=a_vec.end();++it) *it *= a_mat;
173 }

◆ multiply() [2/2]

template<class VECTOR >
void tools::multiply ( VECTOR &  a_vec,
const typename VECTOR::value_type::elem_t &  a_value 
)
inline

Definition at line 176 of file mat.

176  {
177  typedef typename VECTOR::iterator it_t;
178  for(it_t it=a_vec.begin();it!=a_vec.end();++it) (*it).multiply(a_value);
179 }

◆ mx()

template<class T >
T tools::mx ( const T &  a,
const T &  b 
)
inline

Definition at line 13 of file mnmx.

13 {return (a>b?a:b);}

◆ new_argcv()

void tools::new_argcv ( const std::vector< std::string > &  a_args,
int &  a_argc,
char **&  a_argv 
)
inline

Definition at line 13 of file argcv.

13  {
14  // delete with delete_argcv
15  a_argc = (int)a_args.size();
16  if(a_argc<=0) {
17  a_argc = 0;
18  a_argv = 0;
19  return;
20  }
21  typedef char* cstring;
22  a_argv = new cstring[a_argc];
23  for(int index=0;index<a_argc;index++) {
24  const std::string& arg = a_args[index];
25  a_argv[index] = new char[arg.size()+1];
26  ::strcpy(a_argv[index],arg.c_str());
27  }
28 }

◆ nosuffix() [1/2]

std::string tools::nosuffix ( const std::string &  a_string,
bool  a_back = true 
)
inline

Definition at line 94 of file path.

94  {
95  std::string value;
96  nosuffix(a_string,value,a_back);
97  return value;
98 }

◆ nosuffix() [2/2]

void tools::nosuffix ( const std::string &  a_string,
std::string &  a_value,
bool  a_back = true 
)
inline

Definition at line 20 of file path.

20  {
21  // If a_string = dir0/dir1/dir2/dir3/name.xxx
22  // a_value = name
23  // Start searching after the last / (or last \ for Windows).
24  std::string::size_type pos = a_string.rfind('/');
25  if(pos==std::string::npos) pos = a_string.rfind('\\');
26  if(pos==std::string::npos) pos = 0;
27  else pos++;
28  std::string s = a_string.substr(pos,a_string.size()-pos);
29  std::string::size_type dot_pos = a_back?s.rfind('.'):s.find('.');
30  if(dot_pos==std::string::npos) {
31  a_value = s;
32  } else {
33  a_value = s.substr(0,dot_pos);
34  }
35 }

◆ not_equal() [1/2]

template<class INTEGER >
bool tools::not_equal ( std::ostream &  a_out,
const char *  a_file,
int  a_line,
const INTEGER &  a_v,
const INTEGER &  a_expected 
)
inline

Definition at line 67 of file test.

67  {
68  if(a_v==a_expected) {
69  a_out << "failed in file :" << std::endl
70  << a_file << std::endl
71  << "at line :" << std::endl
72  << a_line << std::endl
73  << "value " << a_v << ", expected " << a_expected << std::endl;
74  return false;
75  }
76  return true;
77 }

◆ not_equal() [2/2]

template<class REAL >
bool tools::not_equal ( std::ostream &  a_out,
const char *  a_file,
int  a_line,
const REAL &  a_v,
const REAL &  a_expected,
const REAL &  a_tolerance,
REAL(*)(const REAL &)  a_fabs 
)
inline

Definition at line 107 of file test.

107  {
108  REAL diff = a_fabs(a_v-a_expected);
109  if(diff<a_tolerance) {
110  a_out << "failed in file :" << std::endl
111  << a_file << std::endl
112  << "at line :" << std::endl
113  << a_line << std::endl
114  << "value " << a_v << ", not expected to be " << a_expected << ",diff " << diff << std::endl;
115  return false;
116  }
117  return true;
118 }

◆ num2s() [1/9]

bool tools::num2s ( const std::string &  a_value,
std::string &  a_s 
)
inline

Definition at line 116 of file num2s.

116 {a_s = a_value;return true;}

◆ num2s() [2/9]

bool tools::num2s ( double  a_value,
std::string &  a_s 
)
inline

Definition at line 60 of file num2s.

60  {
61  return print2s(a_s,32,"%g",a_value);
62 }

◆ num2s() [3/9]

bool tools::num2s ( float  a_value,
std::string &  a_s 
)
inline

Definition at line 56 of file num2s.

56  {
57  return print2s(a_s,32,"%g",a_value);
58 }

◆ num2s() [4/9]

bool tools::num2s ( int  a_value,
std::string &  a_s 
)
inline

Definition at line 44 of file num2s.

44  {
45  return print2s(a_s,32,"%d",a_value);
46 }

◆ num2s() [5/9]

bool tools::num2s ( int64  a_value,
std::string &  a_s 
)
inline

Definition at line 52 of file num2s.

52  {
53  return print2s(a_s,32,int64_format(),a_value);
54 }

◆ num2s() [6/9]

bool tools::num2s ( short  a_value,
std::string &  a_s 
)
inline

Definition at line 30 of file num2s.

30  { //used in value
31  return print2s(a_s,32,"%d",a_value);
32 }

◆ num2s() [7/9]

bool tools::num2s ( uint64  a_value,
std::string &  a_s 
)
inline

Definition at line 48 of file num2s.

48  {
49  return print2s(a_s,32,uint64_format(),a_value);
50 }

◆ num2s() [8/9]

bool tools::num2s ( unsigned int  a_value,
std::string &  a_s 
)
inline

Definition at line 34 of file num2s.

34  {
35  return print2s(a_s,32,"%u",a_value);
36 }

◆ num2s() [9/9]

bool tools::num2s ( unsigned short  a_value,
std::string &  a_s 
)
inline

Definition at line 26 of file num2s.

26  { //used in value
27  return print2s(a_s,32,"%u",a_value);
28 }

◆ numas()

template<class T >
bool tools::numas ( const T &  a_value,
std::string &  a_s 
)
inline

Definition at line 89 of file num2s.

89  {
90  std::string stmp;
91  if(!num2s(a_value,stmp)) return false;
92  a_s += stmp;
93  return true;
94 }

◆ numbers_are_equal() [1/2]

template<class NUMBER , class PREC >
bool tools::numbers_are_equal ( const NUMBER &  a_left,
const NUMBER &  a_right,
const PREC &  a_prec,
PREC(*)(const NUMBER &)  a_fabs 
)
inline

Definition at line 10 of file eqT.

10  {
11  NUMBER diff = a_left - a_right;
12  if(a_fabs(diff)>=a_prec) return false;
13  return true;
14 }

◆ numbers_are_equal() [2/2]

template<class NUMBER , class PREC >
bool tools::numbers_are_equal ( const NUMBER &  a_left,
const NUMBER &  a_right,
const PREC &  a_prec,
PREC(*)(NUMBER)  a_fabs 
)
inline

PREC(*a_fabs)(PREC) : /////////////////////////////////////////////////////////////////////////////////////.

Definition at line 57 of file eqT.

57  {
58  NUMBER diff = a_left - a_right;
59  if(a_fabs(diff)>=a_prec) return false;
60  return true;
61 }

◆ numchar()

size_t tools::numchar ( const std::string &  a_string,
char  a_c 
)
inline

Definition at line 19 of file schar.

19  {
20  size_t num = 0;
21  std::string::const_iterator it;
22  for(it=a_string.begin();it!=a_string.end();++it) {
23  if((*it)==a_c) num++;
24  }
25  return num;
26 }

◆ nums2s() [1/2]

template<class T >
bool tools::nums2s ( const std::vector< T > &  a_vals,
std::string &  a_s,
const std::string &  a_sep = "\n",
bool  a_sep_at_end = false 
)
inline

Definition at line 162 of file num2s.

162  {
163  return nums2s< std::vector<T> >(a_vals,a_s,a_sep,a_sep_at_end);
164 }

◆ nums2s() [2/2]

template<class VEC >
bool tools::nums2s ( const VEC &  a_vals,
std::string &  a_s,
const std::string &  a_sep = "\n",
bool  a_sep_at_end = false 
)
inline

Definition at line 143 of file num2s.

143  {
144  a_s.clear();
145  typename VEC::size_type number = a_vals.size();
146  if(number<=0) return true; //it is ok.
147  number--;
148  std::string stmp;
149  bool status = true;
150  for(typename VEC::size_type index=0;index<number;index++) {
151  if(!num2s(a_vals[index],stmp)) status = false; //continue.
152  a_s += stmp;
153  a_s += a_sep;
154  }
155  if(!num2s(a_vals[number],stmp)) status = false;
156  a_s += stmp;
157  if(a_sep_at_end) a_s += a_sep;
158  return status;
159 }

◆ operator*() [1/8]

template<class T , unsigned int D>
mat<T,D> tools::operator* ( const mat< T, D > &  a1,
const mat< T, D > &  a2 
)
inline

Definition at line 416 of file mat.

416  {
417  mat<T,D> res(a1);
418  res *= a2;
419  return res;
420 }

◆ operator*() [2/8]

template<class T >
nmat<T> tools::operator* ( const nmat< T > &  a1,
const nmat< T > &  a2 
)
inline

Definition at line 449 of file mat.

449  {
450  nmat<T> res(a1);
451  res *= a2;
452  return res;
453 }

◆ operator*() [3/8]

template<class T >
array<T> tools::operator* ( const T &  a_fac,
const array< T > &  a_m 
)
inline

Definition at line 617 of file array.

617  {
618  array<T> res(a_m);
619  res *= a_fac;
620  return res;
621 }

◆ operator*() [4/8]

template<class T , unsigned int D>
mat<T,D> tools::operator* ( const T &  a_fac,
const mat< T, D > &  a_m 
)
inline

Definition at line 422 of file mat.

422  {
423  mat<T,D> res(a_m);
424  res *= a_fac;
425  return res;
426 }

◆ operator*() [5/8]

template<class T >
nmat<T> tools::operator* ( const T &  a_fac,
const nmat< T > &  a_m 
)
inline

Definition at line 455 of file mat.

455  {
456  nmat<T> res(a_m);
457  res *= a_fac;
458  return res;
459 }

◆ operator*() [6/8]

vec3d tools::operator* ( double  a_f,
const vec3d a_v 
)
inline

Definition at line 104 of file vec3d.

104  {
105  vec3d res(a_v);
106  res *= a_f;
107  return res;
108 }

◆ operator*() [7/8]

vec2f tools::operator* ( float  a_f,
const vec2f a_v 
)
inline

Definition at line 88 of file vec2f.

88  {
89  vec2f res(a_v);
90  res *= a_f;
91  return res;
92 }

◆ operator*() [8/8]

vec3f tools::operator* ( float  a_f,
const vec3f a_v 
)
inline

Definition at line 115 of file vec3f.

115  {
116  vec3f res(a_v);
117  res *= a_f;
118  return res;
119 }

◆ operator+() [1/3]

template<class T >
array<T> tools::operator+ ( const array< T > &  a1,
const array< T > &  a2 
)
inline

Definition at line 605 of file array.

605  {
606  array<T> res(a1);
607  if(!res.add(a2)) {}
608  return res;
609 }

◆ operator+() [2/3]

template<class T , unsigned int D>
mat<T,D> tools::operator+ ( const mat< T, D > &  a1,
const mat< T, D > &  a2 
)
inline

Definition at line 410 of file mat.

410  {
411  mat<T,D> res(a1);
412  res += a2;
413  return res;
414 }

◆ operator+() [3/3]

template<class T >
nmat<T> tools::operator+ ( const nmat< T > &  a1,
const nmat< T > &  a2 
)
inline

Definition at line 443 of file mat.

443  {
444  nmat<T> res(a1);
445  res += a2;
446  return res;
447 }

◆ operator-() [1/3]

template<class T >
array<T> tools::operator- ( const array< T > &  a1,
const array< T > &  a2 
)
inline

Definition at line 611 of file array.

611  {
612  array<T> res(a1);
613  if(!res.subtract(a2)) {}
614  return res;
615 }

◆ operator-() [2/3]

template<class T , unsigned int D>
mat<T,D> tools::operator- ( const mat< T, D > &  a1,
const mat< T, D > &  a2 
)
inline

Definition at line 404 of file mat.

404  {
405  mat<T,D> res(a1);
406  res -= a2;
407  return res;
408 }

◆ operator-() [3/3]

template<class T >
nmat<T> tools::operator- ( const nmat< T > &  a1,
const nmat< T > &  a2 
)
inline

Definition at line 437 of file mat.

437  {
438  nmat<T> res(a1);
439  res -= a2;
440  return res;
441 }

◆ operator<<() [1/5]

template<class T >
std::ostream& tools::operator<< ( std::ostream &  a_out,
const mat3< T > &  a_mtx 
)
inline

Definition at line 226 of file mat3.

226  {
227  const T* v = a_mtx.data();
228  a_out << v[0] << "," << v[3] << "," << v[6] << std::endl
229  << v[1] << "," << v[4] << "," << v[7] << std::endl
230  << v[2] << "," << v[5] << "," << v[8] << std::endl;
231  return a_out;
232 }

◆ operator<<() [2/5]

template<class T >
std::ostream& tools::operator<< ( std::ostream &  a_out,
const mat4< T > &  a_mtx 
)
inline

Definition at line 503 of file mat4.

503  {
504  const T* v = a_mtx.data();
505  a_out << v[0] << "," << v[4] << "," << v[ 8] << "," << v[12] << std::endl
506  << v[1] << "," << v[5] << "," << v[ 9] << "," << v[13] << std::endl
507  << v[2] << "," << v[6] << "," << v[10] << "," << v[14] << std::endl
508  << v[3] << "," << v[7] << "," << v[11] << "," << v[15] << std::endl;
509  return a_out;
510 }

◆ operator<<() [3/5]

template<class T >
std::ostream& tools::operator<< ( std::ostream &  a_out,
const vec2< T > &  a_this 
)
inline

Definition at line 214 of file vec2.

214  {
215  a_out << "x = " << a_this.v0()
216  << ",y = " << a_this.v1();
217  return a_out;
218 }

◆ operator<<() [4/5]

template<class T >
std::ostream& tools::operator<< ( std::ostream &  a_out,
const vec3< T > &  a_this 
)
inline

Definition at line 393 of file vec3.

393  {
394  a_out << "x = " << a_this.v0()
395  << ",y = " << a_this.v1()
396  << ",z = " << a_this.v2();
397  return a_out;
398 }

◆ operator<<() [5/5]

template<class T >
std::ostream& tools::operator<< ( std::ostream &  a_out,
const vec4< T > &  a_this 
)
inline

Definition at line 278 of file vec4.

278  {
279  a_out << "x = " << a_this.v0()
280  << ",y = " << a_this.v1()
281  << ",z = " << a_this.v2()
282  << ",t = " << a_this.v3();
283  return a_out;
284 }

◆ os()

const char* tools::os ( )
inline

Definition at line 107 of file platform.

107  {
108 
109 #if TARGET_OS_IPHONE
110  static const char s_s[] = "iOS";
111 #elif defined(ANDROID)
112  static const char s_s[] = "Android";
113 #elif defined(EMSCRIPTEN)
114  static const char s_s[] = "emscripten";
115 #elif defined(_WIN32)
116  static const char s_s[] = "Windows_NT";
117 #elif __APPLE__
118  static const char s_s[] = "Darwin";
119 #elif defined(__linux)
120  static const char s_s[] = "Linux";
121 #elif defined(__alpha)
122  static const char s_s[] = "OSF1";
123 #elif defined(__CYGWIN__)
124  static const char s_s[] = "CYGWIN";
125 #else
126  static const char s_s[] = "unknown";
127 #endif
128  return s_s;
129 }

◆ out_error()

void tools::out_error ( std::ostream &  a_out,
const char *  location,
const char *  fmt,
  ... 
)
inline

Definition at line 13 of file out_error.

14  {
15  char s[1024];
16  va_list args;
17  va_start(args,fmt);
18  vsnpf(s,sizeof(s),fmt,args);
19  va_end(args);
20  if(location) {
21  a_out << location << " : " << s << std::endl;
22  } else {
23  a_out << s << std::endl;
24  }
25 }

◆ p2s()

bool tools::p2s ( const void *  a_value,
std::string &  a_s 
)
inline

Definition at line 42 of file pointer.

42  {
43  char s[512];
44  snpf(s,sizeof(s),upointer_format(),(upointer)a_value);
45  a_s = s;
46  return true;
47 }

◆ p2sx()

bool tools::p2sx ( const void *  a_value,
std::string &  a_s 
)
inline

Definition at line 49 of file pointer.

49  {
50  char s[512];
51  snpf(s,sizeof(s),upointer_format_x(),(upointer)a_value);
52  a_s = s;
53  return true;
54 }

◆ path_name_suffix()

bool tools::path_name_suffix ( const std::string &  a_string,
std::string &  a_path,
std::string &  a_name,
std::string &  a_suffix 
)
inline

Definition at line 115 of file path.

115  {
116  // If a_string = dir0/dir1/dir2/dir3/name.xxx
117  // a_path = dir0/dir1/dir2/dir3
118  // a_name = name.xxx
119  // a_suffix = xxx
120  // If a_string = dir0/name.xxx
121  // a_path = dir0
122  // a_name = name.xxx
123  // a_suffix = xxx
124  // If a_string = name.xxx
125  // a_path.clear()
126  // a_name = name.xxx
127  // a_suffix = xxx
128  // If a_string = /name.xxx
129  // a_path = "/"
130  // a_name = name.xxx
131  // a_suffix = xxx
132  // If a_string = .
133  // a_path = "."
134  // a_name.clear()
135  // a_suffix.clear()
136  // If a_string = ..
137  // a_path = ".."
138  // a_name.clear()
139  // a_suffix.clear()
140  // If a_string = dir0/dir1/dir2/dir3/
141  // a_path = dir0/dir1/dir2/dir3
142  // a_name.clear()
143  // a_suffix.clear()
144  // If a_string = dir0/dir1/dir2/dir3/.
145  // a_path = dir0/dir1/dir2/dir3
146  // a_name = "."
147  // a_suffix.clear()
148  // If a_string = dir0/dir1/dir2/dir3/..
149  // a_path = dir0/dir1/dir2/dir3
150  // a_name = ".."
151  // a_suffix.clear()
152  if(a_string==".") {
153  a_path = ".";
154  a_name.clear();
155  a_suffix.clear();
156  return true;
157  } else if(a_string=="..") {
158  a_path = "..";
159  a_name.clear();
160  a_suffix.clear();
161  return true;
162  }
163 
164  std::string::size_type pos_slash = a_string.rfind('/');
165  std::string::size_type pos_bslash = a_string.rfind('\\');
166  std::string::size_type pos = 0;
167  if(pos_slash==std::string::npos) {
168  if(pos_bslash==std::string::npos) {
169  pos = std::string::npos;
170  } else {
171  pos = pos_bslash;
172  }
173  } else {
174  if(pos_bslash==std::string::npos) {
175  pos = pos_slash;
176  } else {
177  if(pos_slash<=pos_bslash) {
178  pos = pos_bslash;
179  } else {
180  pos = pos_slash;
181  }
182  }
183  }
184 
185  if(pos==std::string::npos) {
186  a_path.clear();
187  pos = 0;
188  } else if(pos==0) {
189  a_path = "/";
190  pos++;
191  } else {
192  a_path = a_string.substr(0,pos);
193  pos++;
194  }
195  std::string s = a_string.substr(pos,a_string.size()-pos);
196  pos = s.rfind('.');
197  if(pos==std::string::npos) {
198  a_name = s;
199  a_suffix.clear();
200  } else {
201  a_name = s;
202  pos++;
203  a_suffix = s.substr(pos,s.size()-pos);
204  }
205  return true;
206 }

◆ path_no_suffix()

void tools::path_no_suffix ( const std::string &  a_string,
std::string &  a_value 
)
inline

Definition at line 37 of file path.

37  {
38  // If a_string = dir0/dir1/dir2/dir3/name.xxx
39  // a_value = dir0/dir1/dir2/dir3/name
40  std::string::size_type dot_pos = a_string.rfind('.');
41  if(dot_pos==std::string::npos) {
42  a_value = a_string;
43  } else {
44  a_value = a_string.substr(0,dot_pos);
45  }
46 }

◆ pi()

double tools::pi ( )
inline

Definition at line 17 of file mathd.

17 {return 3.1415926535897931160E0;}

◆ print2s()

bool tools::print2s ( std::string &  a_string,
int  a_length,
const char *  a_format,
  ... 
)
inline

Definition at line 77 of file sprintf.

77  {
78  if(a_length<0) {a_string.clear();return false;}
79  if(!a_format) {a_string.clear();return false;}
80  a_string.assign(a_length,' '); //data = a_length+1
81  char* s = const_cast<char*>(a_string.c_str());
82  //s[a_length] shoulg be '\0'.
83  va_list args;
84  va_start(args,a_format);
85  int n = vsnpf(s,a_length+1,a_format,args);
86  va_end(args);
87  if(n>a_length) { //a_string is compromised.
88  a_string.clear(); //we cross fingers.
89  return false;
90  }
91  if(s[a_length]!='\0') { //a_string is compromised.
92  a_string.clear(); //we cross fingers.
93  return false;
94  }
95  a_string.resize(n);
96  return true;
97 }

◆ print2sv()

bool tools::print2sv ( std::string &  a_string,
int  a_length,
const char *  a_format,
va_list  a_args 
)
inline

Definition at line 58 of file sprintf.

58  {
59  if(a_length<0) {a_string.clear();return false;}
60  if(!a_format) {a_string.clear();return false;}
61  a_string.assign(a_length,' '); //data = a_length+1
62  char* s = const_cast<char*>(a_string.c_str());
63  //s[a_length] shoulg be '\0'.
64  int n = vsnpf(s,a_length+1,a_format,a_args);
65  if(n>a_length) { //a_string is compromised.
66  a_string.clear(); //we cross fingers.
67  return false;
68  }
69  if(s[a_length]!='\0') { //a_string is compromised.
70  a_string.clear(); //we cross fingers.
71  return false;
72  }
73  a_string.resize(n);
74  return true;
75 }

◆ process_id()

int tools::process_id ( )
inline

Definition at line 15 of file process.

15  {
16  return static_cast<int>(::getpid());
17 }

◆ processor()

const char* tools::processor ( )
inline

Definition at line 139 of file platform.

139  {
140 
141 #if defined(__GNUC__)
142 
143 #if defined(__ppc__)
144  static const char s_s[] = "ppc";
145 #elif defined(__ppc64__)
146  static const char s_s[] = "ppc64";
147 #elif defined(__i386__)
148  static const char s_s[] = "i386";
149 #elif defined(__x86_64__)
150  static const char s_s[] = "x86_64";
151 #elif defined(__ia64__)
152  static const char s_s[] = "ia64";
153 #else
154  static const char s_s[] = "unknown";
155 #endif
156 
157 #elif defined(_MSC_VER)
158 
159 #if defined(_M_IX86)
160  static const char s_s[] = "ix86";
161 #elif defined(_M_X64)
162  static const char s_s[] = "x64";
163 #else
164  static const char s_s[] = "unknown";
165 #endif
166 
167 #elif defined(__alpha)
168  static const char s_s[] = "alpha";
169 
170 #else
171  static const char s_s[] = "unknown";
172 #endif
173  return s_s;
174 }

◆ program_path()

bool tools::program_path ( const std::string &  a_arg0,
std::string &  a_path 
)
inline

Definition at line 26 of file app.

26  {
27  if(a_arg0.empty()) {
28  a_path = "";
29  return false;
30  }
31  std::string path,name,suffix;
32  path_name_suffix(a_arg0,path,name,suffix);
33  if(path.empty()) {
34  std::string PATH;
35  if(get_env("PATH",PATH)) {
36  std::string program = a_arg0;
37 #ifdef _WIN32
38  if(program.find(".exe")==std::string::npos) program += ".exe";
39 #endif
40  std::vector<std::string> paths;
41  words(PATH,psep(),false,paths);
42  tools_vforit(std::string,paths,it) {
43  std::string dir = *it;
44  if(file::exists(dir+sep()+program)) {
45  path = dir;
46  break;
47  }
48  }
49  }
50  }
51  if(path.empty()) {
52  a_path = "";
53  return false;
54  }
55  if(!is_absolute_path(path)) {
56  std::string pwd;
57  if(!dir::pwd(pwd)) {
58  a_path = "";
59  return false;
60  }
61  path = pwd+sep()+path;
62  }
63  //printf("debug : path : %s\n",path.c_str());
64  a_path = path;
65  return true;
66 }

◆ psep()

const std::string& tools::psep ( )
inline

Definition at line 20 of file sep.

20  {
21 #ifdef _WIN32
22  static const std::string s_v(";");
23 #else
24  static const std::string s_v(":");
25 #endif
26  return s_v;
27 }

◆ ptrdiff_t2s()

bool tools::ptrdiff_t2s ( ptrdiff_t  a_value,
std::string &  a_s 
)
inline

Definition at line 72 of file num2s.

72  { //used in write_bsg.
73  if(sizeof(ptrdiff_t)==8) {
74  return num2s((int64)a_value,a_s);
75  } else { //assume 4 :
76  return num2s((int32)a_value,a_s);
77  }
78 }

◆ push_back_unique()

template<class T >
void tools::push_back_unique ( std::vector< T > &  a_vec,
const T &  a_v 
)
inline

T : ////////////////////////////////////////////////////////////////////.

Definition at line 112 of file vmanip.

112  {
113  typedef typename std::vector<T>::const_iterator it_t;
114  for(it_t it=a_vec.begin();it!=a_vec.end();++it) {if(*it==a_v) return;}
115  a_vec.push_back(a_v);
116 }

◆ put_env()

bool tools::put_env ( const std::string &  a_env,
const std::string &  a_value 
)
inline

Definition at line 15 of file put_env.

15  {
16  std::string value = a_env+"="+a_value;
17 #ifdef TOOLS_MEM
18  if(::putenv(str_dup(value.c_str(),false))) return false;
19 #else
20  if(::putenv(str_dup(value.c_str()))) return false;
21 #endif
22  //check:
23  std::string s;
24  if(!get_env(a_env,s)) return false;
25  if(s!=a_value) return false;
26  return true;
27 }

◆ quote()

void tools::quote ( std::string &  a_path)
inline

Definition at line 218 of file path.

218  {
219  if(a_path.find(' ')==std::string::npos) return;
220  // path with spaces :
221  if(a_path[0]=='"') return; //Already in double quote.
222  a_path = std::string("\"")+a_path+"\"";
223 }

◆ rad2deg()

double tools::rad2deg ( )
inline

Definition at line 25 of file mathd.

25  {
26  static const double s_v = 180.0/pi();
27  return s_v;
28 }

◆ raw_clear() [1/2]

template<class K , class V >
void tools::raw_clear ( std::map< K, V * > &  a_m)
inline

Definition at line 56 of file mapmanip.

56  {
57  typedef typename std::map<K,V*>::iterator it_t;
58  for(it_t it=a_m.begin();it!=a_m.end();++it) delete (*it).second;
59  a_m.clear();
60 }

◆ raw_clear() [2/2]

template<class T >
void tools::raw_clear ( std::vector< T * > &  a_vec)
inline

Definition at line 47 of file vmanip.

47  {
48  typedef typename std::vector<T*>::iterator it_t;
49  for(it_t it = a_vec.begin();it!=a_vec.end();++it) delete *it;
50  a_vec.clear();
51 }

◆ rcmp() [1/4]

bool tools::rcmp ( const char *  a_1,
const char *  a_2 
)
inline

Definition at line 14 of file rcmp.

14  {
15  size_t l1 = ::strlen(a_1);
16  size_t l2 = ::strlen(a_2);
17  if(l1!=l2) return false;
18  if(!l1) return true;
19  const char* p1 = a_1+l1-1;
20  const char* p2 = a_2+l2-1;
21  //ab
22  //012
23  for(size_t index=0;index<l1;index++,p1--,p2--) {
24  if(*p1!=*p2) return false;
25  }
26  return true;
27 }

◆ rcmp() [2/4]

bool tools::rcmp ( const char *  a_1,
const std::string &  a_2 
)
inline

Definition at line 44 of file rcmp.

44  {
45  size_t l1 = ::strlen(a_1);
46  std::string::size_type l2 = a_2.size();
47  if(l1!=size_t(l2)) return false;
48  if(!l1) return true;
49  const char* p1 = a_1+l1-1;
50  const char* p2 = a_2.c_str()+l2-1;
51  //ab
52  //012
53  for(size_t index=0;index<l1;index++,p1--,p2--) {
54  if(*p1!=*p2) return false;
55  }
56  return true;
57 }

◆ rcmp() [3/4]

bool tools::rcmp ( const std::string &  a_1,
const char *  a_2 
)
inline

Definition at line 29 of file rcmp.

29  {
30  std::string::size_type l1 = a_1.size();
31  size_t l2 = ::strlen(a_2);
32  if(size_t(l1)!=l2) return false;
33  if(!l1) return true;
34  const char* p1 = a_1.c_str()+l1-1;
35  const char* p2 = a_2+l2-1;
36  //ab
37  //012
38  for(std::string::size_type index=0;index<l1;index++,p1--,p2--) {
39  if(*p1!=*p2) return false;
40  }
41  return true;
42 }

◆ rcmp() [4/4]

bool tools::rcmp ( const std::string &  a_1,
const std::string &  a_2 
)
inline

Definition at line 59 of file rcmp.

59  {
60  std::string::size_type l1 = a_1.size();
61  std::string::size_type l2 = a_2.size();
62  if(l1!=l2) return false;
63  if(!l1) return true;
64  const char* p1 = a_1.c_str()+l1-1;
65  const char* p2 = a_2.c_str()+l2-1;
66  //ab
67  //012
68  for(std::string::size_type index=0;index<l1;index++,p1--,p2--) {
69  if(*p1!=*p2) return false;
70  }
71  return true;
72 }

◆ realloc()

template<class T >
bool tools::realloc ( T *&  a_pointer,
size_t  a_new_size,
size_t  a_old_size,
bool  a_init = false 
)
inline

Definition at line 9 of file realloc.

9  {
10  if(!a_new_size) {
11  delete [] a_pointer;
12  a_pointer = 0;
13  return true;
14  }
15  if(!a_pointer) {
16  a_pointer = new T[a_new_size];
17  if(!a_pointer) return false;
18  return true;
19  }
20  if(a_old_size==a_new_size) return true;
21  T* pointer = new T[a_new_size];
22  if(!pointer) {
23  delete [] a_pointer;
24  a_pointer = 0;
25  return false;
26  }
27  if(a_new_size>a_old_size) {
28  ::memcpy(pointer,a_pointer,a_old_size*sizeof(T));
29  if(a_init){
30  size_t num = a_new_size-a_old_size;
31  T* pos = pointer+a_old_size;
32  for(size_t i=0;i<num;i++,pos++) *pos = T();
33  }
34  } else {
35  ::memcpy(pointer,a_pointer,a_new_size*sizeof(T));
36  }
37  delete [] a_pointer;
38  a_pointer = pointer;
39  return true;
40 }

◆ remove() [1/3]

template<class K , class V >
bool tools::remove ( std::vector< std::pair< K, V > > &  a_vec,
const K &  a_key 
)
inline

Definition at line 107 of file vpair.

107  {
108  typedef typename std::vector< std::pair<K,V> >::iterator it_t;
109  it_t it;
110  for(it=a_vec.begin();it!=a_vec.end();++it) {
111  if((*it).first==a_key) {
112  a_vec.erase(it);
113  return true;
114  }
115  }
116  return false;
117 }

◆ remove() [2/3]

template<class K , class V >
bool tools::remove ( std::vector< std::pair< K, V > > &  a_vec,
const K &  a_key,
bool  a_delete 
)
inline

Definition at line 120 of file vpair.

120  {
121  typedef typename std::vector< std::pair<K,V> >::iterator it_t;
122  it_t it;
123  for(it=a_vec.begin();it!=a_vec.end();++it) {
124  if((*it).first==a_key) {
125  V val = (*it).second;
126  a_vec.erase(it);
127  if(a_delete) delete val;
128  return true;
129  }
130  }
131  return false;
132 }

◆ remove() [3/3]

template<class T >
bool tools::remove ( std::vector< T > &  a_vals,
const T &  a_elem 
)
inline

Definition at line 119 of file vmanip.

119  {
120  bool found_some = false;
121  //std::vector<T>::iterator it;
122  //for(it=a_vals.begin();it!=a_vals.end();) {
123  // if(*it==a_elem) {
124  // it = a_vals.erase(it);
125  // found_some = true;
126  // } else {
127  // ++it;
128  // }
129  //}
130  //TOOLS_STL : brut force avoiding erase() :
131  std::vector<T> vs;
132  typedef typename std::vector<T>::iterator it_t;
133  for(it_t it=a_vals.begin();it!=a_vals.end();++it) {
134  if(*it==a_elem) {
135  found_some = true;
136  } else {
137  vs.push_back(*it);
138  }
139  }
140  a_vals = vs;
141  return found_some;
142 }

◆ remove_window_size_args()

void tools::remove_window_size_args ( args a_args)
inline

Definition at line 141 of file saui.

141  {
142  //use with Wt apps.
143  a_args.remove("-iPod");
144  a_args.remove("-iPhone");
145  a_args.remove("-iPad");
146  a_args.remove("-iPhone4");
147  a_args.remove("-SGS");
148  a_args.remove("-ww");
149  a_args.remove("-wh");
150  a_args.remove("-land");
151 }

◆ removep()

template<class T >
void tools::removep ( std::vector< T * > &  a_vec,
const T *  a_elem 
)
inline

Definition at line 88 of file vmanip.

88  {
89  typedef typename std::vector<T*>::iterator it_t;
90  for(it_t it=a_vec.begin();it!=a_vec.end();) {
91  if(*it==a_elem) {
92  it = a_vec.erase(it);
93  } else {
94  ++it;
95  }
96  }
97 }

◆ rep_env()

bool tools::rep_env ( std::string &  a_string)
inline

Definition at line 14 of file file_name.

14  {
15  char spec_char = '\n';
16  std::string::size_type dollar;
17  while((dollar=a_string.find('$'))!=std::string::npos){
18  std::string::size_type slash = a_string.find('/',dollar+1);
19  std::string::size_type back_slash = a_string.find('\\',dollar+1);
20  std::string::size_type pos = std::string::npos;
21  if(slash!=std::string::npos) {
22  if(back_slash!=std::string::npos) {
23  pos = slash<back_slash?slash:back_slash;
24  } else {
25  pos = slash;
26  }
27  } else {
28  if(back_slash!=std::string::npos) {
29  pos = back_slash;
30  } else {
31  pos = std::string::npos;
32  }
33  }
34  std::string env;
35  if(pos==std::string::npos) {
36  env = a_string.substr(dollar+1,a_string.length()-(dollar+1));
37  } else {
38  // abc$xxx/ef
39  // 0 3 7 9
40  env = a_string.substr(dollar+1,pos-(dollar+1));
41  }
42  char* val = ::getenv(env.c_str());
43  if(!val) {
44  // We may have $ in a_string not attached to an env variable.
45  // For example at LAL, some Windows account name have a leading $
46  // that is found back in the home directory path. To bypass this
47  // problem we change temporarily the $ by spec_char and continue
48  // the loop. We change back all the spec_chars to $ at end.
49  a_string[dollar] = spec_char;
50  } else {
51  std::string value = a_string.substr(0,dollar);
52  value += val;
53  if(pos!=std::string::npos) value += a_string.substr(pos,a_string.length()-pos);
54  a_string = value;
55  }
56  }
57  replace(a_string,spec_char,'$');
58  return true;
59 }

◆ replace() [1/3]

void tools::replace ( std::string &  a_string,
char  a_old,
char  a_new 
)
inline

Definition at line 14 of file srep.

14  {
15  tools_sforit(a_string,it) {
16  if((*it)==a_old) *it = a_new;
17  }
18 }

◆ replace() [2/3]

bool tools::replace ( std::string &  a_string,
const std::string &  a_old,
const std::string &  a_new 
)
inline

Definition at line 20 of file srep.

20  {
21  // return true : some replacement done.
22  // return false : nothing replaced.
23  if(a_old.empty()) return false;
24  std::string snew;
25  std::string::size_type lold = a_old.length();
26  bool status = false;
27  std::string stmp = a_string;
28  while(true) {
29  std::string::size_type pos = stmp.find(a_old);
30  if(pos==std::string::npos){
31  snew += stmp;
32  break;
33  } else {
34  snew += stmp.substr(0,pos);
35  snew += a_new;
36  stmp = stmp.substr(pos+lold,stmp.length()-(pos+lold));
37  status = true;
38  }
39  }
40  a_string = snew;
41  return status;
42 }

◆ replace() [3/3]

bool tools::replace ( std::vector< std::string > &  a_strings,
const std::string &  a_old,
const std::string &  a_new 
)
inline

Definition at line 48 of file srep.

48  {
49  tools_vforit(std::string,a_strings,it) {
50  if(!replace(*it,a_old,a_new)) return false;
51  }
52  return true;
53 }

◆ replace_()

bool tools::replace_ ( std::string &  a_string,
const std::string &  a_old,
const std::string &  a_new 
)
inline

Definition at line 44 of file srep.

44  {
45  return replace(a_string,a_old,a_new);
46 }

◆ res_sep()

const std::string& tools::res_sep ( )
inline

Definition at line 29 of file sep.

29  {
30  static const std::string s_v(".");
31  return s_v;
32 }

◆ rfind()

template<class K , class V >
bool tools::rfind ( const std::vector< std::pair< K, V > > &  a_vec,
const K &  a_key,
V &  a_value 
)
inline

Definition at line 40 of file vpair.

40  {
41  typedef typename std::vector< std::pair<K,V> >::const_reverse_iterator it_t;
42  it_t it;
43  for(it=a_vec.rbegin();it!=a_vec.rend();++it) {
44  if((*it).first==a_key) {
45  a_value = (*it).second;
46  return true;
47  }
48  }
49  a_value = V();
50  return false;
51 }

◆ rgb_to_hls()

template<class T >
void tools::rgb_to_hls ( rr,
gg,
bb,
T &  hue,
T &  light,
T &  satur 
)
inline

Definition at line 55 of file hls.

55  {
56  // The r,g,b triplet is between
57  // [0,1], hue is between [0,360], light and satur are [0,1].
58 
59  T rnorm, gnorm, bnorm, minval, maxval, msum, mdiff, cr, cg, cb;
60  minval = maxval = 0;
61  cr = cg = cb = 0;
62 
63  if (rr > 0) cr = rr;
64  if (cr > 1) cr = 1;
65 
66  if (gg > 0) cg = gg;
67  if (cg > 1) cg = 1;
68 
69  if (bb > 0) cb = bb;
70  if (cb > 1) cb = 1;
71 
72  minval = cr;
73  if (cg < minval) minval = cg;
74  if (cb < minval) minval = cb;
75  maxval = cr;
76  if (cg > maxval) maxval = cg;
77  if (cb > maxval) maxval = cb;
78 
79  rnorm = gnorm = bnorm = 0;
80  mdiff = maxval - minval;
81  msum = maxval + minval;
82  light = T(0.5) * msum;
83  if (maxval != minval) {
84  rnorm = (maxval - cr)/mdiff;
85  gnorm = (maxval - cg)/mdiff;
86  bnorm = (maxval - cb)/mdiff;
87  } else {
88  satur = hue = 0;
89  return;
90  }
91 
92  if (light < T(0.5))
93  satur = mdiff/msum;
94  else
95  satur = mdiff/(2 - msum);
96 
97  if (cr == maxval)
98  hue = 60 * (6 + bnorm - gnorm);
99  else if (cg == maxval)
100  hue = 60 * (2 + rnorm - bnorm);
101  else
102  hue = 60 * (4 + gnorm - rnorm);
103 
104  if (hue > 360)
105  hue = hue - 360;
106 }

◆ rm_env()

bool tools::rm_env ( const std::string &  a_env)
inline

Definition at line 29 of file put_env.

29  {
30 #ifdef _MSC_VER
31  std::string value = a_env+"=";
32 #ifdef TOOLS_MEM
33  if(::putenv(str_dup(value.c_str(),false))) return false;
34 #else
35  if(::putenv(str_dup(value.c_str()))) return false;
36 #endif
37 #else
38  ::unsetenv(a_env.c_str());
39 #endif
40  return true;
41 }

◆ s2time()

bool tools::s2time ( const std::string &  a_string,
time_t &  a_time 
)
inline

Definition at line 13 of file s2time.

13  {
14  int yy, mm, dd, hh, mi, ss;
15  if(::sscanf(a_string.c_str(),
16  "%d-%d-%d %d:%d:%d",
17  &yy,&mm,&dd,&hh,&mi,&ss)!=6) {a_time = 0;return false;}
18  struct tm tp;
19  tp.tm_year = yy-1900;
20  tp.tm_mon = mm-1;
21  tp.tm_mday = dd;
22  tp.tm_hour = hh;
23  tp.tm_min = mi;
24  tp.tm_sec = ss;
25  tp.tm_isdst = 0;
26  a_time = ::mktime(&tp);
27  return true;
28 }

◆ s_partial_derivative()

const std::string& tools::s_partial_derivative ( )
inline

Definition at line 23 of file smath.

23  {
24  static const std::string s_v("partiald");
25  return s_v;
26 }

◆ safe_cast() [1/2]

template<class FROM , class TO >
const TO* tools::safe_cast ( const FROM &  a_o)
inline

Definition at line 17 of file safe_cast.

17  {
18  return (const TO*)a_o.cast(TO::s_class());
19 }

◆ safe_cast() [2/2]

template<class FROM , class TO >
TO* tools::safe_cast ( FROM &  a_o)
inline

Definition at line 12 of file safe_cast.

12  {
13  return (TO*)a_o.cast(TO::s_class());
14 }

◆ safe_clear() [1/2]

template<class K , class V >
void tools::safe_clear ( std::map< K, V * > &  a_m)
inline

Definition at line 12 of file mapmanip.

12  {
13  // the below takes into account the case in
14  // which "delete entry" could modify a_m.
15  typedef typename std::map<K,V*>::iterator it_t;
16  while(!a_m.empty()) {
17  it_t it = a_m.begin();
18  V* entry = (*it).second;
19  a_m.erase(it);
20  delete entry;
21  }
22 }

◆ safe_clear() [2/2]

template<class T >
void tools::safe_clear ( std::vector< T * > &  a_vec)
inline

T* : /////////////////////////////////////////////////.

Definition at line 16 of file vmanip.

16  {
17  // the below takes into account the case in
18  // which "delete entry" could modify a_vec.
19  typedef typename std::vector<T*>::iterator it_t;
20  while(!a_vec.empty()) {
21  it_t it = a_vec.begin();
22  T* entry = *it;
23  a_vec.erase(it);
24  delete entry;
25  }
26 }

◆ safe_reverse_clear()

template<class T >
void tools::safe_reverse_clear ( std::vector< T * > &  a_vec)
inline

Definition at line 29 of file vmanip.

29  { //used in sg/group.
30  // the below takes into account the case in
31  // which "delete entry" could modify a_vec.
32  typedef typename std::vector<T*>::iterator it_t;
33  while(!a_vec.empty()) {
34  it_t it = a_vec.end();
35  it--;
36  T* entry = *it;
37  a_vec.erase(it);
38  delete entry;
39  }
40 }

◆ sep()

const std::string& tools::sep ( )
inline

Definition at line 11 of file sep.

11  {
12 #ifdef _WIN32
13  static const std::string s_v("\\");
14 #else
15  static const std::string s_v("/");
16 #endif
17  return s_v;
18 }

◆ serrno()

void tools::serrno ( std::string &  a_s)
inline

Definition at line 13 of file serrno.

13  {
14  std::ostringstream strm;
15  strm << (int)errno;
16  a_s = " error : ";
17  a_s += strm.str();
18  a_s += " : ";
19  a_s += strerror(errno);
20  a_s += ".";
21 }

◆ set_from_vec() [1/4]

bool tools::set_from_vec ( vec2f a_v,
const std::vector< float > &  a_sv 
)
inline

Definition at line 102 of file vec2f.

102  {
103  if(a_sv.size()!=2) return false;
104  a_v[0] = a_sv[0];
105  a_v[1] = a_sv[1];
106  return true;
107 }

◆ set_from_vec() [2/4]

bool tools::set_from_vec ( vec3d a_v,
const std::vector< double > &  a_sv 
)
inline

Definition at line 119 of file vec3d.

119  {
120  if(a_sv.size()!=3) return false;
121  a_v[0] = a_sv[0];
122  a_v[1] = a_sv[1];
123  a_v[2] = a_sv[2];
124  return true;
125 }

◆ set_from_vec() [3/4]

bool tools::set_from_vec ( vec3f a_v,
const std::vector< float > &  a_sv 
)
inline

Definition at line 153 of file vec3f.

153  {
154  if(a_sv.size()!=3) return false;
155  a_v[0] = a_sv[0];
156  a_v[1] = a_sv[1];
157  a_v[2] = a_sv[2];
158  return true;
159 }

◆ set_from_vec() [4/4]

bool tools::set_from_vec ( vec4f a_v,
const std::vector< float > &  a_sv 
)
inline

Definition at line 94 of file vec4f.

94  {
95  if(a_sv.size()!=4) return false;
96  a_v[0] = a_sv[0];
97  a_v[1] = a_sv[1];
98  a_v[2] = a_sv[2];
99  a_v[3] = a_sv[3];
100  return true;
101 }

◆ set_matrix()

template<class MATRIX >
void tools::set_matrix ( MATRIX &  a_matrix,
const std::string &  a_fmt 
)
inline

Definition at line 100 of file sprintf.

100  {
101  unsigned int DR = a_matrix.rows();
102  unsigned int DC = a_matrix.cols();
103  std::string ss;
104  for(unsigned int i=0;i<DR;i++) {
105  for(unsigned int j=0;j<DC;j++) {
106  tools::sprintf(ss,128,a_fmt.c_str(),i,j);
107  a_matrix.set_value(i,j,ss);
108  }
109  }
110 }

◆ size_char()

unsigned int tools::size_char ( )
inline

Definition at line 110 of file typedefs.

110 {return 1;}

◆ size_double()

unsigned int tools::size_double ( )
inline

Definition at line 115 of file typedefs.

115 {return 8;}

◆ size_float()

unsigned int tools::size_float ( )
inline

Definition at line 114 of file typedefs.

114 {return 4;}

◆ size_int()

unsigned int tools::size_int ( )
inline

Definition at line 112 of file typedefs.

112 {return 4;}

◆ size_int64()

unsigned int tools::size_int64 ( )
inline

Definition at line 113 of file typedefs.

113 {return 8;}

◆ size_short()

unsigned int tools::size_short ( )
inline

Definition at line 111 of file typedefs.

111 {return 2;}

◆ size_t2s()

bool tools::size_t2s ( size_t  a_value,
std::string &  a_s 
)
inline

Definition at line 64 of file num2s.

64  {
65  if(sizeof(size_t)==8) {
66  return num2s((uint64)a_value,a_s);
67  } else { //assume 4 :
68  return num2s((uint32)a_value,a_s);
69  }
70 }

◆ size_tas()

template<class T >
bool tools::size_tas ( const T &  a_value,
std::string &  a_s 
)
inline

Definition at line 97 of file num2s.

97  {
98  std::string stmp;
99  if(!size_t2s(a_value,stmp)) return false;
100  a_s += stmp;
101  return true;
102 }

◆ snpf()

int tools::snpf ( char *  a_s,
size_t  a_n,
const char *  a_fmt,
  ... 
)
inline

Definition at line 27 of file snpf.

27  {
28  va_list args;
29  va_start(args,a_fmt);
30  int n = vsnpf(a_s,a_n,a_fmt,args);
31  va_end(args);
32  return n;
33 }

◆ snums() [1/2]

template<class T >
bool tools::snums ( const std::string &  a_string,
const std::string &  a_sep,
std::vector< T > &  a_values,
bool  a_clear = true 
)
inline

Definition at line 32 of file snums.

32  {
33  std::istringstream iss;
34  std::vector<std::string> words;
35  return snums(a_string,iss,words,a_sep,a_values,a_clear);
36 }

◆ snums() [2/2]

template<class T >
bool tools::snums ( const std::string &  a_string,
std::istringstream &  a_iss,
std::vector< std::string > &  a_tmp,
const std::string &  a_sep,
std::vector< T > &  a_values,
bool  a_clear = true 
)
inline

Definition at line 14 of file snums.

17  {
18  if(a_clear) a_values.clear();
19  words(a_string,a_sep,false,a_tmp);
20  T value;
21  tools_vforcit(std::string,a_tmp,it) {
22  a_iss.str(*it);
23  a_iss.clear(); //IMPORTANT.
24  a_iss >> value;
25  if(a_iss.fail()) {a_values.clear();return false;}
26  a_values.push_back(value);
27  }
28  return true;
29 }

◆ sort_by_second()

template<class K , class V >
void tools::sort_by_second ( std::vector< std::pair< K, V > > &  a_vec)
inline

Definition at line 78 of file vpair.

78  {
79  //sort according V
80 
81  //brute force.
82  std::vector< std::pair<K,V> > v;
83  typedef typename std::vector< std::pair<K,V> >::iterator it_t;
84 
85  it_t it;
86  for(it=a_vec.begin();it!=a_vec.end();++it) {
87  const V& val = (*it).second;
88 
89  bool done = false;
90  it_t it2;
91  for(it2=v.begin();it2!=v.end();++it2) {
92  if(val<(*it2).second) {
93  v.insert(it2,*it);
94  done = true;
95  break;
96  }
97  }
98  if(!done) {
99  v.push_back(*it);
100  }
101  }
102 
103  a_vec = v;
104 }

◆ sprintf()

bool tools::sprintf ( std::string &  a_string,
int  a_length,
const char *  a_format,
  ... 
)
inline

Definition at line 34 of file sprintf.

34  {
35  a_string.clear();
36  if(a_length<0) return false;
37  if(!a_format) return false;
38  char* s = new char[a_length+1];
39  if(!s) return false;
40  s[a_length] = '\0';
41  va_list args;
42  va_start(args,a_format);
43  int n = vsnpf(s,a_length+1,a_format,args);
44  va_end(args);
45  if(n>a_length) {
46  delete [] s;
47  return false;
48  }
49  if(s[a_length]!='\0') {
50  delete [] s;
51  return false;
52  }
53  a_string = s;
54  delete [] s;
55  return true;
56 }

◆ std_system()

int tools::std_system ( std::ostream &  a_out,
const std::string &  a_string 
)
inline

Definition at line 16 of file std_system.

16  {
17 #if TARGET_OS_IPHONE
18  a_out << "tools::std_system : system() not available on iOS. Can't execute " << sout(a_string) << "." << std::endl;
19  return EXIT_FAILURE;
20 #else
21  return ::system(a_string.c_str());
22  (void)a_out;
23 #endif
24 }

◆ stemplate()

bool tools::stemplate ( const std::string &  a_s,
std::string &  a_inc 
)
inline

Definition at line 78 of file stype.

78  {
79  // If a_s is of the form "xxx<yyy>zzz<ttt>uuuu", at end a_inc contains "yyy".
80  // It returns true if something had been found, else false.
81  a_inc = a_s;
82  std::string::size_type pos = a_inc.find('<');
83  if(pos==std::string::npos) {a_inc.clear();return false;}
84  a_inc = a_inc.substr((pos+1),a_inc.size()-(pos+1));
85  std::string::size_type _pos = a_inc.find('>');
86  if(_pos==std::string::npos) {a_inc.clear();return false;}
87  a_inc = a_inc.substr(0,_pos);
88  return true;
89 }

◆ steps()

template<class T >
void tools::steps ( std::vector< T > &  a_vec,
unsigned int  a_number 
)
inline

Definition at line 244 of file vmanip.

244  {
245  a_vec.resize(a_number);
246  for(unsigned int index=0;index<a_number;index++) a_vec[index] = T(index);
247 }

◆ str_2d()

bool tools::str_2d ( const char *  a_s,
double &  a_v 
)
inline

Definition at line 234 of file cstr.

234  {
235  char* olcn = beg_LC_NUMERIC();
236 
237  char* end;
238  a_v = ::strtod(a_s,&end);
239  if(end==a_s) {
240  a_v = 0;
241  end_LC_NUMERIC(olcn);
242  return false;
243  }
244 
245  end_LC_NUMERIC(olcn);
246  return true;
247 }

◆ str_2ds()

template<class VECTOR >
bool tools::str_2ds ( char *  a_s,
const char *  a_sep,
VECTOR &  a_v 
)
inline

Definition at line 339 of file cstr.

339  {
340  a_v.clear();
341  const char* tok;
342  double d;
343  for (tok = ::strtok(a_s,a_sep);tok && *tok;tok = ::strtok(NULL,a_sep)) {
344  if(!str_2d(tok,d)) {a_v.clear();return false;}
345  a_v.push_back(d);
346  }
347  return true;
348 }

◆ str_cat() [1/2]

bool tools::str_cat ( char *&  a_1,
const char *  a_2 
)
inline

Definition at line 117 of file cstr.

117  {
118  size_t l1 = ::strlen(a_1);
119  size_t l2 = ::strlen(a_2);
120  char* s = (char*)::malloc(l1+l2+1);
121  if(!s) return false;
122 #ifdef TOOLS_MEM
123 #ifdef TOOLS_CSTR_DEBUG_MEM
124  ::printf("debug : str_cat \"%s\" \"%s\"\n",a_1,a_2);
125 #endif
126  mem::increment(s_cstr().c_str());
127 #endif
128  ::memcpy(s,a_1,l1);
129  ::memcpy(s+l1,a_2,l2);
130  *(s+l1+l2) = 0;
131  ::free(a_1);
132 #ifdef TOOLS_MEM
133 #ifdef TOOLS_CSTR_DEBUG_MEM
134  ::printf("debug : str_cat : dec\n");
135 #endif
136  mem::decrement(s_cstr().c_str());
137 #endif
138  a_1 = s;
139  return true;
140 }

◆ str_cat() [2/2]

bool tools::str_cat ( char *&  a_1,
const char  a_c 
)
inline

Definition at line 93 of file cstr.

93  {
94  size_t l1 = ::strlen(a_1);
95  char* s = (char*)::malloc(l1+1+1);
96  if(!s) return false;
97 #ifdef TOOLS_MEM
98 #ifdef TOOLS_CSTR_DEBUG_MEM
99  ::printf("debug : str_cat \"%s\", char %d\n",a_1,a_c);
100 #endif
101  mem::increment(s_cstr().c_str());
102 #endif
103  ::memcpy(s,a_1,l1);
104  ::memcpy(s+l1,&a_c,1);
105  *(s+l1+1) = 0;
106  ::free(a_1);
107 #ifdef TOOLS_MEM
108 #ifdef TOOLS_CSTR_DEBUG_MEM
109  ::printf("debug : str_cat : dec\n");
110 #endif
111  mem::decrement(s_cstr().c_str());
112 #endif
113  a_1 = s;
114  return true;
115 }

◆ str_del()

void tools::str_del ( char *&  a_cstr)
inline

Definition at line 66 of file cstr.

66  {
67  if(a_cstr==NULL) return;
68 #ifdef TOOLS_MEM
69 #ifdef TOOLS_CSTR_DEBUG_MEM
70  ::printf("debug : str_del \"%s\"\n",a_cstr);
71 #endif
72  mem::decrement(s_cstr().c_str());
73 #endif
74  ::free(a_cstr);
75  a_cstr = NULL;
76 }

◆ str_dup()

char* tools::str_dup ( const char *  a_cstr)
inline

Definition at line 30 of file cstr.

34  {
35 #ifdef TOOLS_MEM
36  if(a_inc) {
37 #ifdef TOOLS_CSTR_DEBUG_MEM
38  ::printf("debug : str_dup \"%s\"\n",a_cstr);
39 #endif
40  mem::increment(s_cstr().c_str());
41  }
42 #endif
43  return ::strcpy((char*)::malloc(::strlen(a_cstr)+1),a_cstr);
44 }

◆ str_from_buffer()

char* tools::str_from_buffer ( const char *  a_buffer,
size_t  a_len 
)
inline

Definition at line 46 of file cstr.

50  {
51 #ifdef TOOLS_MEM
52  if(a_inc) {
53 #ifdef TOOLS_CSTR_DEBUG_MEM
54  ::printf("debug : str_from_buffer.\n");
55 #endif
56  mem::increment(s_cstr().c_str());
57  }
58 #endif
59  char* s = (char*)::malloc(a_len+1);
60  if(s==NULL) return NULL;
61  s = ::strncpy(s,a_buffer,a_len);
62  s[a_len] = 0;
63  return s;
64 }

◆ str_lcat()

size_t tools::str_lcat ( char *  dst,
const char *  src,
size_t  siz 
)
inline

Definition at line 302 of file cstr.

302  {
303  // Appends src to string dst of size siz (unlike strncat, siz is the
304  // full size of dst, not space left). At most siz-1 characters
305  // will be copied. Always NUL terminates (unless siz <= strlen(dst)).
306  // Returns strlen(src) + MIN(siz, strlen(initial dst)).
307  // If retval >= siz, truncation occurred.
308 
309  // code taken from CERN-ROOT/core/clib to compile exlib/tests/h2root.cpp.
310  // strlcpy, strlcat are in string.h on BSD based systems.
311 
312  // Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>.
313 
314  /*register*/ char* d = dst;
315  /*register*/ const char* s = src;
316  /*register*/ size_t n = siz;
317  size_t dlen;
318 
319  // Find the end of dst and adjust bytes left but don't go past end :
320  while (n-- != 0 && *d != '\0') d++;
321  dlen = d - dst;
322  n = siz - dlen;
323 
324  if (n == 0) return(dlen + strlen(s));
325 
326  while (*s != '\0') {
327  if (n != 1) {
328  *d++ = *s;
329  n--;
330  }
331  s++;
332  }
333  *d = '\0';
334 
335  return(dlen + (s - src)); // count does not include NUL.
336 }

◆ str_lcpy()

size_t tools::str_lcpy ( char *  dst,
const char *  src,
size_t  siz 
)
inline

Definition at line 272 of file cstr.

272  {
273  // Copy src to string dst of size siz. At most siz-1 characters
274  // will be copied. Always NUL terminates (unless siz == 0).
275  // Returns strlen(src); if retval >= siz, truncation occurred.
276 
277  // code taken from CERN-ROOT/core/clib to compile exlib/tests/h2root.cpp.
278  // strlcpy, strlcat are in string.h on BSD based systems.
279 
280  // Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>.
281 
282  /*register*/ char* d = dst;
283  /*register*/ const char* s = src;
284  /*register*/ size_t n = siz;
285 
286  // Copy as many bytes as will fit :
287  if (n != 0 && --n != 0) {
288  do {
289  if ((*d++ = *s++) == 0) break;
290  } while (--n != 0);
291  }
292 
293  // Not enough room in dst, add NUL and traverse rest of src :
294  if (n == 0) {
295  if (siz != 0) *d = '\0'; // NUL-terminate dst.
296  while (*s++);
297  }
298 
299  return(s - src - 1); // count does not include NUL.
300 }

◆ str_new()

char* tools::str_new ( size_t  a_l = 0,
char  a_char = ' ' 
)
inline

Definition at line 78 of file cstr.

78  {
79  char* s = (char*)::malloc((a_l+1)*sizeof(char));
80  if(s==NULL) return NULL;
81 #ifdef TOOLS_MEM
82 #ifdef TOOLS_CSTR_DEBUG_MEM
83  ::printf("debug : str_new : len %lu\n",a_l);
84 #endif
85  mem::increment(s_cstr().c_str());
86 #endif
87  char* pos = s;
88  for(size_t c=0;c<a_l;c++,pos++) *pos = a_char;
89  *(s+a_l) = 0;
90  return s;
91 }

◆ str_rep()

char* tools::str_rep ( const char *  a_s,
unsigned int  a_pos,
unsigned int  a_sz,
const char *  a_new 
)
inline

Definition at line 181 of file cstr.

181  {
182  //not tested yet.
183  size_t las = ::strlen(a_s);
184  if(a_pos>=las) return 0; //throw std::out_of_range
185  if(a_pos+a_sz>las) return 0;
186  size_t lan = ::strlen(a_new);
187  unsigned int num = a_sz<lan?a_sz:(unsigned int)lan;
188  //abcdefghij : l = 10
189  //0123456789
190  // p
191  size_t le = las-(a_pos+a_sz);
192  size_t ls = a_pos+num+le;
193  char* s = (char*)::malloc(ls+1);
194  if(!s) return 0;
195 #ifdef TOOLS_MEM
196 #ifdef TOOLS_CSTR_DEBUG_MEM
197  ::printf("debug : str_rep \"%s\"\n",a_s);
198 #endif
199  mem::increment(s_cstr().c_str());
200 #endif
201  ::memcpy(s,a_s,a_pos);
202  ::memcpy(s+a_pos,a_new,num);
203  if(le) ::memcpy(s+a_pos+num,a_s+a_pos+a_sz,le);
204  *(s+ls) = 0;
205  return s;
206 }

◆ str_rev()

void tools::str_rev ( char *  a_s)
inline

Definition at line 142 of file cstr.

142  {
143  size_t l = ::strlen(a_s);
144  size_t hl = l/2;
145  char* beg = a_s;
146  char* end = a_s+l-1;
147  for(size_t i=0;i<hl;i++) {
148  char c = *end;
149  *end = *beg;
150  *beg = c;
151  beg++;end--;
152  }
153 }

◆ str_skip()

void tools::str_skip ( char *&  a_cstr,
char  a_c 
)
inline

Definition at line 208 of file cstr.

208  {
209  while(true) {
210  if(*a_cstr!=a_c) break;
211  a_cstr++;
212  }
213 }

◆ str_sub()

char* tools::str_sub ( const char *  a_s,
unsigned int  a_pos,
unsigned int  a_sz = 0 
)
inline

Definition at line 155 of file cstr.

157  { //0 = take up end.
158  size_t l = ::strlen(a_s);
159  if(a_pos>=l) return 0; //throw std::out_of_range
160  size_t ls;
161  if(a_sz) {
162  ls = (a_sz<(l-a_pos)?a_sz:(l-a_pos)); //min(a_sz,l-a_pos)
163  } else {
164  ls = l-a_pos;
165  }
166  char* s = (char*)::malloc(ls+1);
167  if(!s) return 0;
168 #ifdef TOOLS_MEM
169 #ifdef TOOLS_CSTR_DEBUG_MEM
170  ::printf("debug : str_sub \"%s\"\n",a_s);
171 #endif
172  mem::increment(s_cstr().c_str());
173 #endif
174  //abcdefgh l=8
175  //0123456789
176  ::memcpy(s,a_s+a_pos,ls);
177  *(s+ls) = 0;
178  return s;
179 }

◆ strings2buf()

bool tools::strings2buf ( const std::vector< std::string > &  a_strings,
size_t &  a_size,
char *&  a_buffer 
)
inline

Definition at line 94 of file buf2lines.

94  {
95  // For {"aa","bbb"}, it produces "aa0bbb00".
96  // For {""}, it produces "00".
97  // For {}, it produces "0".
98  size_t number = a_strings.size();
99  a_size = 0;
100  for(size_t index=0;index<number;index++) a_size += a_strings[index].size()+1;
101  a_size++;
102  a_buffer = new char[a_size];
103  if(!a_buffer) {a_size = 0;return false;}
104  char* pos = a_buffer;
105  size_t array_size;
106  for(size_t index=0;index<number;index++) {
107  const std::string& s = a_strings[index];
108  array_size = s.size()+1;
109  ::memcpy(pos,s.c_str(),array_size);
110  pos += array_size;
111  }
112  *pos = '\0';
113  return true;
114 }

◆ strip() [1/2]

bool tools::strip ( std::string &  a_string,
what  a_type = both,
char  a_char = ' ' 
)
inline

Definition at line 14 of file strip.

14  {
15  //return true = some stripping had been done.
16 
17  std::string::size_type l = a_string.length();
18  if(l==0) return false;
19 
20  switch ( a_type ) {
21  case leading:{
22  char* pos = (char*)a_string.c_str();
23  for(std::string::size_type i=0;i<l;i++,pos++) {
24  if(*pos!=a_char) {
25  a_string = a_string.substr(i,l-i);
26  return (i?true:false); //i=0 : same string.
27  }
28  }
29  // all chars are a_char :
30  a_string.clear();
31  return true;
32  }break;
33  case trailing:{
34  char* pos = (char*)a_string.c_str();
35  pos += (l-1);
36  std::string::size_type i = l-1;
37  std::string::const_reverse_iterator it;
38  for(it=a_string.rbegin();it!=a_string.rend();++it,i--,pos--) {
39  if(*pos!=a_char) {
40  a_string = a_string.substr(0,i+1);
41  return (i==(l-1)?false:true); //i==l-1 : same string.
42  }
43  }
44  // all chars are a_char :
45  a_string.clear();
46  return true;
47  }break;
48  case both:{
49  bool stat_lead = strip(a_string,leading,a_char);
50  bool stat_trail = strip(a_string,trailing,a_char);
51  if(stat_lead) return true;
52  if(stat_trail) return true;
53  }break;
54  //default:break;
55  }
56  return false; //nothing done.
57 }

◆ strip() [2/2]

bool tools::strip ( std::vector< std::string > &  a_strings,
what  a_type = both,
char  a_char = ' ' 
)
inline

Definition at line 67 of file strip.

67  {
68  bool some_done = false;
69  std::vector<std::string>::iterator it;
70  for(it=a_strings.begin();it!=a_strings.end();++it) {
71  if(strip(*it,a_type,a_char)) some_done = true;
72  }
73  return some_done;
74 }

◆ stype() [1/15]

const std::string& tools::stype ( bool  )
inline

Definition at line 55 of file stype.

55  {
56  static const std::string s_v("bool");
57  return s_v;
58 }

◆ stype() [2/15]

const std::string& tools::stype ( char  )
inline

Definition at line 20 of file stype.

20  {
21  static const std::string s_v("char");
22  return s_v;
23 }

◆ stype() [3/15]

const std::string& tools::stype ( const mat4f )
inline

Definition at line 73 of file mat4f.

73  {
74  static const std::string s_v("tools::mat4f");
75  return s_v;
76 }

◆ stype() [4/15]

const std::string& tools::stype ( const std::string &  )
inline

Definition at line 69 of file stype.

69  {
70  static const std::string s_v("std::string");
71  return s_v;
72 }

◆ stype() [5/15]

const std::string& tools::stype ( const std::vector< std::string > &  )
inline

Definition at line 98 of file stype.

98  {
99  static const std::string s_v("std::vector<std::string>");
100  return s_v;
101 }

◆ stype() [6/15]

template<class T >
const std::string& tools::stype ( const T &  )
inline

Definition at line 76 of file stype.

76 {return T::s_class();}

◆ stype() [7/15]

const std::string& tools::stype ( double  )
inline

Definition at line 50 of file stype.

50  {
51  static const std::string s_v("double");
52  return s_v;
53 }

◆ stype() [8/15]

const std::string& tools::stype ( float  )
inline

Definition at line 45 of file stype.

45  {
46  static const std::string s_v("float");
47  return s_v;
48 }

◆ stype() [9/15]

const std::string& tools::stype ( int  )
inline

Definition at line 35 of file stype.

35  {
36  static const std::string s_v("int");
37  return s_v;
38 }

◆ stype() [10/15]

const std::string& tools::stype ( int64  )
inline

Definition at line 61 of file stype.

61  {
62  static const std::string s_v("tools::int64");
63  return s_v;
64 }

◆ stype() [11/15]

const std::string& tools::stype ( short  )
inline

Definition at line 30 of file stype.

30  {
31  static const std::string s_v("short");
32  return s_v;
33 }

◆ stype() [12/15]

const std::string& tools::stype ( uint64  )
inline

Definition at line 65 of file stype.

65  {
66  static const std::string s_v("tools::uint64");
67  return s_v;
68 }

◆ stype() [13/15]

const std::string& tools::stype ( unsigned char  )
inline

Definition at line 15 of file stype.

15  {
16  static const std::string s_v("unsigned char");
17  return s_v;
18 }

◆ stype() [14/15]

const std::string& tools::stype ( unsigned int  )
inline

Definition at line 40 of file stype.

40  {
41  static const std::string s_v("unsigned int");
42  return s_v;
43 }

◆ stype() [15/15]

const std::string& tools::stype ( unsigned short  )
inline

Definition at line 25 of file stype.

25  {
26  static const std::string s_v("unsigned short");
27  return s_v;
28 }

◆ sub() [1/2]

template<class T >
bool tools::sub ( std::vector< T > &  a_vec,
const std::vector< T > &  a_v 
)
inline

Definition at line 283 of file vmanip.

283  {
284  if(a_vec.size()!=a_v.size()) return false;
285  typedef typename std::vector<T>::iterator it_t;
286  typedef typename std::vector<T>::const_iterator cit_t;
287  it_t it = a_vec.begin();
288  cit_t vit = a_v.begin();
289  for(;it!=a_vec.end();++it,++vit) *it -= *vit;
290  return true;
291 }

◆ sub() [2/2]

template<class T >
void tools::sub ( std::vector< T > &  a_vec,
const T &  a_v 
)
inline

Definition at line 318 of file vmanip.

318  {
319  typedef typename std::vector<T>::iterator it_t;
320  for(it_t it=a_vec.begin();it!=a_vec.end();++it) *it -= a_v;
321 }

◆ suffix() [1/2]

std::string tools::suffix ( const std::string &  a_string,
bool  a_back = true 
)
inline

Definition at line 88 of file path.

88  {
89  std::string value;
90  suffix(a_string,value,a_back);
91  return value;
92 }

◆ suffix() [2/2]

void tools::suffix ( const std::string &  a_string,
std::string &  a_value,
bool  a_back = true 
)
inline

Definition at line 11 of file path.

11  {
12  // If a_string = dir0/dir1/dir2/dir3/name.xxx
13  // a_value = xxx
14  std::string::size_type pos = a_back?a_string.rfind('.'):a_string.find('.');
15  if(pos==std::string::npos) {a_value.clear();return;}
16  pos++;
17  a_value = a_string.substr(pos,a_string.size()-pos);
18 }

◆ sum()

template<class T >
T tools::sum ( const std::vector< T > &  a_vec)
inline

Definition at line 225 of file vmanip.

225  {
226  T sum = T();
227  typedef typename std::vector<T>::const_iterator it_t;
228  for(it_t it = a_vec.begin();it!=a_vec.end();++it) sum += *it;
229  return sum;
230 }

◆ swap()

template<class T >
bool tools::swap ( const array< T > &  aV,
unsigned int  aI1,
unsigned int  aI2,
array< T > &  aR 
)
inline

Definition at line 479 of file array.

484  {
485  if(&aR==&aV) return false;
486 
487  unsigned int dim = aV.dimension();
488  if(aI1>=dim) return false;
489  if(aI2>=dim) return false;
490 
491  if(aI1==aI2) {
492  aR.copy(aV);
493  return true;
494  }
495 
496  if(!aR.configure(aV.orders())) return false;
497 
498  std::vector<unsigned int> vis(aV.dimension());
499  std::vector<unsigned int> ris(aV.dimension());
500 
501  const std::vector<T>& vvec = aV.vector();
502 
503  unsigned int size = aV.size();
504  for(unsigned int offset=0;offset<size;offset++) {
505  T value = vvec[offset];
506 
507  if(!aV.indices(offset,vis)) return false;
508  unsigned int i = vis[aI1];
509  vis[aI1] = vis[aI2];
510  vis[aI2] = i;
511  if(!aR.set_value(vis,value)) return false;
512  }
513 
514  return true;
515 }

◆ tex_expand_size()

void tools::tex_expand_size ( unsigned int  a_w,
unsigned int &  a_h,
unsigned int &  a_ew,
unsigned int &  a_eh 
)
inline

Definition at line 899 of file img.

900  {
901  // find closest power of two upper than a_w, a_h :
902  a_ew = 2;
903  while(true) {if(a_ew>=a_w) break;a_ew *=2;}
904  a_eh = 2;
905  while(true) {if(a_eh>=a_h) break;a_eh *=2;}
906 }

◆ time2s()

bool tools::time2s ( std::string &  a_s)
inline

Definition at line 30 of file s2time.

30  {
31  time_t d;
32  if(::time(&d)==(time_t)-1) {a_s.clear();return false;}
33  char* _cstr = ::ctime(&d);
34  _cstr[24] = '\0';
35  a_s = _cstr;
36  return true;
37 }

◆ to() [1/6]

template<class T >
bool tools::to ( const std::string &  a_s,
T &  a_v,
const T &  a_def = T() 
)
inline

Definition at line 41 of file sto.

41  {
42  if(a_s.empty()) {a_v = a_def;return false;} //for TOOLS_STL istringstream.
43  std::istringstream strm(a_s.c_str());
44  strm >> a_v;
45  if(strm.fail()) {a_v = a_def;return false;}
46  return strm.eof();
47 }

◆ to() [2/6]

bool tools::to ( const std::string &  a_string,
bool &  a_value,
bool  a_def = false 
)
inline

Definition at line 11 of file sto.

11  {
12  if( (a_string=="1")
13  ||(a_string=="true")||(a_string=="TRUE")||(a_string=="True")
14  ||(a_string=="yes")||(a_string=="YES")||(a_string=="Yes")
15  ||(a_string=="on")||(a_string=="ON")||(a_string=="On")
16  ){
17  a_value = true;
18  return true;
19  } else if((a_string=="0")
20  ||(a_string=="false")||(a_string=="FALSE")||(a_string=="False")
21  ||(a_string=="no")||(a_string=="NO")||(a_string=="No")
22  ||(a_string=="off")||(a_string=="OFF")||(a_string=="Off")
23  ){
24  a_value = false;
25  return true;
26  } else {
27  a_value = a_def;
28  return false;
29  }
30 }

◆ to() [3/6]

std::vector<std::string> tools::to ( int  a_argc,
char **  a_argv 
)
inline

Definition at line 507 of file args.

507  {
508  std::vector<std::string> v;
509  for(int index=0;index<a_argc;index++) v.push_back(a_argv[index]);
510  return v;
511 }

◆ to() [4/6]

bool tools::to ( std::ostream &  a_out,
const std::string &  a_string,
bool &  a_value 
)
inline

Definition at line 75 of file sto.

75  {
76  if(!to(a_string,a_value)) {
77  a_out << "Passed value \"" << a_string << "\""
78  << " is not a boolean."
79  << std::endl;
80  return false;
81  }
82  return true;
83 }

◆ to() [5/6]

template<class T >
bool tools::to ( std::ostream &  a_out,
const std::string &  a_string,
T &  a_value 
)
inline

Definition at line 65 of file sto.

65  {
66  if(!to<T>(a_string,a_value)) {
67  a_out << "Passed value \"" << a_string << "\""
68  << " is of bad type."
69  << std::endl;
70  return false;
71  }
72  return true;
73 }

◆ to() [6/6]

template<class T >
bool tools::to ( T &  a_field,
const std::string &  a_s,
bool &  a_changed 
)
inline

Definition at line 50 of file sto.

50  {
51  T old = a_field;
52  //if(!tools::to(a_s,a_field)) {a_field = old;a_changed=false;return false;}
53  if(!to(a_s,a_field)) {a_field = old;a_changed=false;return false;}
54  a_changed = a_field==old?false:true;
55  return true;
56 }

◆ to_complex()

template<class RMAT , class CMAT >
bool tools::to_complex ( const RMAT &  a_r,
CMAT &  a_c 
)
inline

Definition at line 236 of file mat.

236  {
237  if(a_c.dimension()!=a_r.dimension()) return false;
238  typedef typename RMAT::elem_t RT;
239  const RT* rpos = a_r.data();
240  typedef typename CMAT::elem_t CT;
241  CT* cpos = const_cast<CT*>(a_c.data());
242  unsigned int D2 = a_r.dimension()*a_r.dimension();
243  for(unsigned int i=0;i<D2;i++,rpos++,cpos++) *cpos = CT(*rpos);
244  return true;
245 }

◆ to_pointer() [1/2]

bool tools::to_pointer ( const char *  a_string,
void *&  a_value 
)
inline

Definition at line 30 of file pointer.

30  {
31  upointer v = 0;
32  if(::sscanf(a_string,upointer_format_x(),&v)!=1) {
33  if(::sscanf(a_string,upointer_format(),&v)!=1) {
34  a_value = 0;
35  return false;
36  }
37  }
38  a_value = (void*)v;
39  return true;
40 }

◆ to_pointer() [2/2]

bool tools::to_pointer ( const std::string &  a_string,
void *&  a_value 
)
inline

Definition at line 18 of file pointer.

18  {
19  upointer v = 0;
20  if(::sscanf(a_string.c_str(),upointer_format_x(),&v)!=1) {
21  if(::sscanf(a_string.c_str(),upointer_format(),&v)!=1) {
22  a_value = 0;
23  return false;
24  }
25  }
26  a_value = (void*)v;
27  return true;
28 }

◆ to_real()

template<class CMAT , class RMAT >
bool tools::to_real ( const CMAT &  a_c,
RMAT &  a_r,
typename CMAT::elem_t::value_type(*)(const typename CMAT::elem_t &)  a_real 
)
inline

Definition at line 224 of file mat.

224  {
225  if(a_r.dimension()!=a_c.dimension()) return false;
226  typedef typename CMAT::elem_t CT;
227  const CT* cpos = a_c.data();
228  typedef typename RMAT::elem_t RT;
229  RT* rpos = const_cast<RT*>(a_r.data());
230  unsigned int D2 = a_c.dimension()*a_c.dimension();
231  for(unsigned int i=0;i<D2;i++,cpos++,rpos++) *rpos = a_real(*cpos);
232  return true;
233 }

◆ to_size_t()

bool tools::to_size_t ( const std::string &  a_string,
size_t &  a_value,
const size_t &  a_def = 0 
)
inline

Definition at line 92 of file sto.

92  {
93  if(sizeof(size_t)==8) {
94  uint64 v;
95  bool status = to<uint64>(a_string,v,a_def);
96  a_value = v;
97  return status;
98  } else { //assume 4 :
99  uint32 v;
100  bool status = to<uint32>(a_string,v,(uint32)a_def);
101  a_value = v;
102  return status;
103  }
104 }

◆ to_win()

void tools::to_win ( std::string &  a_string)
inline

Definition at line 74 of file srep.

74  {
75  replace(a_string,"/cygdrive/c","C:"); // CYGWIN.
76  replace(a_string,"/mnt/c","C:"); // WSL.
77  replace(a_string,'/','\\');
78 }

◆ to_win_python()

void tools::to_win_python ( std::string &  a_string)
inline

Definition at line 80 of file srep.

80  {
81  replace(a_string,"/cygdrive/c","c:"); // CYGWIN.
82  replace(a_string,"/mnt/c","c:"); // WSL. (Python wants c: in lowercase).
83  replace(a_string,"C:","c:");
84  replace(a_string,'\\','/');
85 }

◆ to_xml()

std::string tools::to_xml ( const std::string &  a_string)
inline

Definition at line 68 of file srep.

68  {
69  std::string s = a_string;
70  toxml(s);
71  return s;
72 }

◆ tob()

bool tools::tob ( const std::string &  a_string,
bool &  a_value,
bool  a_def = false 
)
inline

Definition at line 32 of file sto.

32 {return to(a_string,a_value,a_def);}

◆ tolowercase()

void tools::tolowercase ( std::string &  a_string)
inline

Definition at line 11 of file touplow.

11  {
12  for(std::string::iterator it=a_string.begin();it!=a_string.end();++it) {
13  char c = *it;
14  *it = ((c) >= 'A' && (c) <= 'Z' ? c - 'A' + 'a' : c);
15  }
16 }

◆ tools_vdata_check_compile()

void tools::tools_vdata_check_compile ( )
inline

Definition at line 57 of file vdata.

57 {std::vector<double> v;vec_data(v);}

◆ tos() [1/15]

std::string tools::tos ( bool  a_value)
inline

Definition at line 91 of file tos.

91  {
92  return std::string(a_value?"true":"false");
93 }

◆ tos() [2/15]

std::string tools::tos ( char  a_value)
inline

Definition at line 28 of file tos.

28  {
29  std::string s;
30  if(is_printable(a_value))
31  sprintf(s,32,"%c",a_value);
32  else
33  sprintf(s,32,"%d",a_value);
34  return s;
35 }

◆ tos() [3/15]

bool tools::tos ( const rotf a_v,
std::string &  a_s 
)
inline

Definition at line 68 of file rotf.

68  {
69  vec3f axis;
70  float angle = 0;
71  if(!a_v.value(axis,angle)) {a_s.clear();return false;}
72  std::ostringstream strm;
73  strm << axis[0] << " "
74  << axis[1] << " "
75  << axis[2] << " "
76  << angle;
77  a_s = strm.str();
78  return true;
79 }

◆ tos() [4/15]

std::string tools::tos ( const std::string &  a_value)
inline

Definition at line 95 of file tos.

95 {return a_value;}

◆ tos() [5/15]

template<class T >
std::string tools::tos ( const std::vector< T > &  a_vals,
const std::string &  a_sep = "\n",
bool  a_sep_at_end = false 
)
inline

Definition at line 98 of file tos.

100  {
101  size_t number = a_vals.size();
102  if(number<=0) return "";
103  std::string result;
104  number--;
105  for(size_t index=0;index<number;index++) {
106  result += tos(a_vals[index]);
107  result += a_sep;
108  }
109  result += tos(a_vals[number]);
110  if(a_sep_at_end) result += a_sep;
111  return result;
112 }

◆ tos() [6/15]

std::string tools::tos ( double  a_value)
inline

Definition at line 85 of file tos.

85  {
86  std::string s;
87  sprintf(s,32,"%g",a_value);
88  return s;
89 }

◆ tos() [7/15]

std::string tools::tos ( float  a_value)
inline

Definition at line 79 of file tos.

79  {
80  std::string s;
81  sprintf(s,32,"%g",a_value);
82  return s;
83 }

◆ tos() [8/15]

std::string tools::tos ( int  a_value)
inline

Definition at line 61 of file tos.

61  {
62  std::string s;
63  sprintf(s,32,"%d",a_value);
64  return s;
65 }

◆ tos() [9/15]

std::string tools::tos ( int64  a_value)
inline

Definition at line 73 of file tos.

73  {
74  std::string s;
75  sprintf(s,32,int64_format(),a_value);
76  return s;
77 }

◆ tos() [10/15]

std::string tools::tos ( short  a_value)
inline

Definition at line 43 of file tos.

43  {
44  std::string s;
45  sprintf(s,32,"%d",a_value);
46  return s;
47 }

◆ tos() [11/15]

std::string tools::tos ( uint64  a_value)
inline

Definition at line 67 of file tos.

67  {
68  std::string s;
69  sprintf(s,32,uint64_format(),a_value);
70  return s;
71 }

◆ tos() [12/15]

std::string tools::tos ( unsigned char  a_value)
inline

Definition at line 19 of file tos.

19  {
20  std::string s;
21  if(is_printable(a_value))
22  sprintf(s,32,"%c",a_value);
23  else
24  sprintf(s,32,"%d",a_value);
25  return s;
26 }

◆ tos() [13/15]

std::string tools::tos ( unsigned int  a_linen,
const char *  a_lines[] 
)
inline

Definition at line 114 of file tos.

114  {
115  std::string s;
116  for(unsigned int index=0;index<a_linen;index++) {
117  s += std::string(a_lines[index]);
118  s += "\n";
119  }
120  return s;
121 }

◆ tos() [14/15]

std::string tools::tos ( unsigned int  a_value)
inline

Definition at line 49 of file tos.

49  {
50  std::string s;
51  sprintf(s,32,"%u",a_value);
52  return s;
53 }

◆ tos() [15/15]

std::string tools::tos ( unsigned short  a_value)
inline

Definition at line 37 of file tos.

37  {
38  std::string s;
39  sprintf(s,32,"%d",a_value);
40  return s;
41 }

◆ toss()

void tools::toss ( const char *  a_from,
char  a_s[],
unsigned int &  a_l 
)
inline

Definition at line 12 of file tosu.

12  {
13  char* s = (char*)a_from;
14  a_l = 0;
15  char* pos = a_s;
16  while(*s) {
17  *pos = *s;pos++;
18  a_l++;
19  s++;
20  }
21  *pos = 0;
22 }

◆ tosu()

template<class T >
void tools::tosu ( a_i,
char  a_s[],
unsigned int &  a_l 
)
inline

Definition at line 25 of file tosu.

25  {
26  //assume a_s is sufficently allocated (32 is ok).
27  a_l = 0;
28  {char* pos = a_s;
29  T i = a_i;
30  while(true) {
31  if(i<=9) {*pos = '0'+char(i);pos++;a_l++;*pos=0;pos++;break;}
32  T r = i % 10;
33  *pos = '0'+char(r);pos++;
34  a_l++;
35  i = i/10;
36  }}
37  //strrev(s);
38  {unsigned int hl = a_l/2;
39  char* beg = a_s;
40  char* end = a_s+a_l-1;
41  for(unsigned int i=0;i<hl;i++) {
42  char c = *end;
43  *end = *beg;
44  *beg = c;
45  beg++;end--;
46  }}
47 }

◆ tosx()

std::string tools::tosx ( unsigned int  a_value)
inline

Definition at line 55 of file tos.

55  {
56  std::string s;
57  sprintf(s,32,"%x",a_value);
58  return s;
59 }

◆ touppercase()

void tools::touppercase ( std::string &  a_string)
inline

Definition at line 18 of file touplow.

18  {
19  for(std::string::iterator it=a_string.begin();it!=a_string.end();++it) {
20  char c = *it;
21  *it = ((c) >= 'a' && (c) <= 'z' ? c - 'a' + 'A' : c);
22  }
23 }

◆ toxml()

void tools::toxml ( std::string &  a_string)
inline

Definition at line 55 of file srep.

55  {
56  // > : &lt;
57  // < : &gt;
58  // & : &amp;
59  // " : &quot;
60  // ' : &apos;
61  replace(a_string,"&","&amp;"); //must be first.
62  replace(a_string,"<","&lt;");
63  replace(a_string,">","&gt;");
64  replace(a_string,"\"","&quot;");
65  replace(a_string,"'","&apos;");
66 }

◆ two_pi()

double tools::two_pi ( )
inline

Definition at line 18 of file mathd.

18 {return 6.2831853071795862320E0;}

◆ type_format() [1/10]

const char* tools::type_format ( char  )
inline

Definition at line 121 of file typedefs.

121 {static const char s[] = "%d";return s;}

◆ type_format() [2/10]

const char* tools::type_format ( double  )
inline

Definition at line 119 of file typedefs.

119 {static const char s[] = "%g";return s;}

◆ type_format() [3/10]

const char* tools::type_format ( float  )
inline

Definition at line 118 of file typedefs.

118 {static const char s[] = "%g";return s;}

◆ type_format() [4/10]

const char* tools::type_format ( int  )
inline

Definition at line 123 of file typedefs.

123 {static const char s[] = "%d";return s;}

◆ type_format() [5/10]

const char* tools::type_format ( int64  )
inline

Definition at line 124 of file typedefs.

124 {return int64_format();}

◆ type_format() [6/10]

const char* tools::type_format ( short  )
inline

Definition at line 122 of file typedefs.

122 {static const char s[] = "%d";return s;}

◆ type_format() [7/10]

const char* tools::type_format ( uint64  )
inline

Definition at line 129 of file typedefs.

129 {return uint64_format();}

◆ type_format() [8/10]

const char* tools::type_format ( unsigned char  )
inline

Definition at line 126 of file typedefs.

126 {static const char s[] = "%u";return s;}

◆ type_format() [9/10]

const char* tools::type_format ( unsigned int  )
inline

Definition at line 128 of file typedefs.

128 {static const char s[] = "%u";return s;}

◆ type_format() [10/10]

const char* tools::type_format ( unsigned short  )
inline

Definition at line 127 of file typedefs.

127 {static const char s[] = "%u";return s;}

◆ uint32_format()

const char* tools::uint32_format ( )
inline

Definition at line 73 of file typedefs.

73 {static const char s[] = "%u";return s;}

◆ uint32_mx()

uint32 tools::uint32_mx ( )
inline

Definition at line 84 of file typedefs.

84  { //4 294 967 295
85  uint32 n = 0;
86  for(unsigned int i=0;i<32;i++) n += 1<<i;
87  return n;
88 }

◆ uint64_format()

const char* tools::uint64_format ( )
inline

Definition at line 74 of file typedefs.

74 {static const char s[] = "%llu";return s;}

◆ uint64_mx()

uint64 tools::uint64_mx ( )
inline

Definition at line 89 of file typedefs.

89  { //18 446 744 073 709 551 615
90  uint64 one = 1;
91  uint64 n = 0;
92  for(unsigned int i=0;i<64;i++) n += one<<i;
93  return n;
94 }

◆ unique()

template<class T >
void tools::unique ( std::vector< T > &  a_vec)
inline

Definition at line 155 of file vmanip.

155  {
156  typedef typename std::vector<T>::iterator it_t;
157  it_t it,it2;
158  for(it=a_vec.begin();it!=a_vec.end();++it) {
159  it2 = it;it2++; //TOOLS_STL : it2=it+1 does not compile.
160  for(;it2!=a_vec.end();) {
161  if((*it2)==(*it)) {
162  it2 = a_vec.erase(it2);
163  } else {
164  ++it2;
165  }
166  }
167  }
168 }

◆ upointer_format()

const char* tools::upointer_format ( )
inline

Definition at line 79 of file typedefs.

79 {static const char s[] = "%lu";return s;}

◆ upointer_format_x()

const char* tools::upointer_format_x ( )
inline

Definition at line 80 of file typedefs.

80 {static const char s[] = "0x%lx";return s;}

◆ url_parse()

bool tools::url_parse ( const std::string &  a_url,
std::string &  a_host,
unsigned int &  a_port,
std::string &  a_path 
)
inline

Definition at line 280 of file path.

280  {
281  std::string s;
282  if((a_url.size()>=7)&&(a_url.substr(0,7)=="http://")) {
283  s = a_url.substr(7,a_url.size()-7);
284  } else if((a_url.size()>=8)&&(a_url.substr(0,8)=="https://")) {
285  s = a_url.substr(8,a_url.size()-8);
286  } else {
287  a_host.clear();
288  a_port = 0;
289  a_path.clear();
290  return false;
291  }
292 
293  {std::string::size_type pos = s.find('/');
294  if(pos==std::string::npos) {
295  a_host = s;
296  a_path = "/";
297  } else {
298  a_host = s.substr(0,pos);
299  a_path = s.substr(pos,s.size()-pos);
300  }}
301 
302  {std::string::size_type pos = a_host.find(':');
303  if(pos==std::string::npos) {
304  a_port = 0;
305  } else {
306  std::string sport = a_host.substr(pos+1,a_host.size()-(pos+1));
307  std::istringstream strm(sport.c_str());
308  strm >> a_port;
309  if(strm.fail()) {
310  a_host.clear();
311  a_port = 0;
312  a_path.clear();
313  return false;
314  }
315  a_host = a_host.substr(0,pos);
316  }}
317 
318  return true;
319 }

◆ vadd()

template<class T >
bool tools::vadd ( std::vector< T > &  a_vec,
const std::vector< T > &  a_v 
)
inline

Definition at line 280 of file vmanip.

280 {return add<T>(a_vec,a_v);}

◆ valid_pointer()

template<class CLASS >
bool tools::valid_pointer ( std::ostream &  a_out,
const char *  a_file,
int  a_line,
CLASS *  a_p 
)
inline

Definition at line 41 of file test.

41  {
42  if(!a_p) {
43  a_out << "failed in file :" << std::endl
44  << a_file << std::endl
45  << "at line :" << std::endl
46  << a_line << std::endl
47  << "null pointer." << std::endl;
48  return false;
49  }
50  return true;
51 }

◆ values()

template<class T >
bool tools::values ( const std::string &  a_string,
const std::string &  a_sep,
bool  a_take_empty,
std::vector< T > &  a_values 
)
inline

Definition at line 15 of file svalues.

15  {
16  // same logic as words() function.
17 
18  a_values.clear();
19  if(a_string.empty()) return true;
20  std::string::size_type lim = (a_take_empty?0:1);
21  if(a_sep.empty()) {
22  T value;
23  if(!to<T>(a_string,value)) {
24  a_values.clear();
25  return false;
26  }
27  a_values.push_back(value);
28  } else {
29  std::string::size_type l = a_string.length();
30  std::string::size_type llimiter = a_sep.length();
31  std::string::size_type pos = 0;
32  while(true) {
33  std::string::size_type index = a_string.find(a_sep,pos);
34  if(index==std::string::npos){ // Last word.
35  if((l-pos)>=lim) {
36  T value;
37  if(!to<T>(a_string.substr(pos,l-pos),value)) {
38  a_values.clear();
39  return false;
40  }
41  a_values.push_back(value);
42  }
43  break;
44  } else {
45  // abcxxxef
46  // 0 3 67
47  if((index-pos)>=lim) {
48  T value;
49  if(!to<T>(a_string.substr(pos,index-pos),value)) {
50  a_values.clear();
51  return false;
52  }
53  a_values.push_back(value);
54  }
55  pos = index + llimiter;
56  }
57  }
58  }
59  return true;
60 }

◆ vcopy()

template<class T >
void tools::vcopy ( std::vector< T * > &  a_to,
const std::vector< T * > &  a_from 
)
inline

Definition at line 63 of file vmanip.

63 {return copy<T>(a_to,a_from);}

◆ vec_data() [1/2]

template<class T >
const T* tools::vec_data ( const std::vector< T > &  a_vec)
inline

Definition at line 18 of file vdata.

18  {
19 #if TARGET_OS_IPHONE || __INTEL_COMPILER || _MSC_VER || (__GNUC__ == 4 && __GNUC_MINOR__ <= 0)
20  if(a_vec.empty()) return 0;
21  const T& vf = a_vec.front();
22  return &vf;
23 #else
24  return a_vec.data();
25 #endif
26 }

◆ vec_data() [2/2]

template<class T >
T* tools::vec_data ( std::vector< T > &  a_vec)
inline

Definition at line 29 of file vdata.

29  {
30 #if TARGET_OS_IPHONE || __INTEL_COMPILER || _MSC_VER || (__GNUC__ == 4 && __GNUC_MINOR__ <= 0)
31  if(a_vec.empty()) return 0;
32  T& vf = a_vec.front();
33  return &vf;
34 #else
35  return a_vec.data();
36 #endif
37 }

◆ vectors_are_equal() [1/2]

template<class VEC , class PREC >
bool tools::vectors_are_equal ( const VEC &  a_1,
const VEC &  a_2,
const PREC &  a_prec,
PREC(*)(const PREC &)  a_fabs 
)
inline

Definition at line 23 of file eqT.

23  {
24  if(a_1.size()!=a_2.size()) return false;
25  typedef typename VEC::size_type sz_t;
26  sz_t sz = a_1.size();
27  //bool status = true;
28  for(sz_t index=0;index<sz;index++) {
29  if(!numbers_are_equal(a_1[index],a_2[index],a_prec,a_fabs))
30  //{ ::printf("debug : vectors_are_equals : %lu : %g %g\n",index,a_1[index],a_2[index]);
31  return false;
32  //status = false;
33  //}
34  }
35  return true;
36  //return status;
37 }

◆ vectors_are_equal() [2/2]

template<class VEC , class PREC >
bool tools::vectors_are_equal ( const VEC &  a_1,
const VEC &  a_2,
const PREC &  a_prec,
PREC(*)(PREC)  a_fabs 
)
inline

Definition at line 64 of file eqT.

64  {
65  if(a_1.size()!=a_2.size()) return false;
66  typedef typename VEC::size_type sz_t;
67  sz_t sz = a_1.size();
68  //bool status = true;
69  for(sz_t index=0;index<sz;index++) {
70  if(!numbers_are_equal(a_1[index],a_2[index],a_prec,a_fabs))
71  //{ ::printf("debug : vectors_are_equals : %lu : %g %g\n",index,a_1[index],a_2[index]);
72  return false;
73  //status = false;
74  //}
75  }
76  return true;
77  //return status;
78 }

◆ vecvecs_are_equal() [1/2]

template<class VECVEC , class PREC >
bool tools::vecvecs_are_equal ( const VECVEC &  a_1,
const VECVEC &  a_2,
const PREC &  a_prec,
PREC(*)(const PREC &)  a_fabs 
)
inline

Definition at line 40 of file eqT.

40  {
41  if(a_1.size()!=a_2.size()) return false;
42  typedef typename VECVEC::size_type sz_t;
43  sz_t sz = a_1.size();
44  for(sz_t index=0;index<sz;index++) {
45  if(!vectors_are_equal(a_1[index],a_2[index],a_prec,a_fabs)) return false;
46  }
47  return true;
48 }

◆ vecvecs_are_equal() [2/2]

template<class VECVEC , class PREC >
bool tools::vecvecs_are_equal ( const VECVEC &  a_1,
const VECVEC &  a_2,
const PREC &  a_prec,
PREC(*)(PREC)  a_fabs 
)
inline

Definition at line 81 of file eqT.

81  {
82  if(a_1.size()!=a_2.size()) return false;
83  typedef typename VECVEC::size_type sz_t;
84  sz_t sz = a_1.size();
85  for(sz_t index=0;index<sz;index++) {
86  if(!vectors_are_equal(a_1[index],a_2[index],a_prec,a_fabs)) return false;
87  }
88  return true;
89 }

◆ vequ()

template<class T >
bool tools::vequ ( const std::vector< T > &  a_vec,
const std::vector< T > &  a_v 
)
inline

Definition at line 261 of file vmanip.

261  {
262  if(a_vec.size()!=a_v.size()) return false;
263  typedef typename std::vector<T>::const_iterator it_t;
264  typedef typename std::vector<T>::const_iterator cit_t;
265  it_t it = a_vec.begin();
266  cit_t vit = a_v.begin();
267  //size_t count = 0;
268  for(;it!=a_vec.end();++it,++vit
269  // ,count++
270  ) {
271  if((*it)!=(*vit))
272  //{::printf("debug : %lu : %d %d\n",count,(*it),(*vit));
273  return false;
274  //}
275  }
276  return true;
277 }

◆ version()

unsigned int tools::version ( )
inline

Definition at line 14 of file version.

14 {return 50400;}

◆ vfilter()

template<class T >
void tools::vfilter ( std::vector< T > &  a_vals,
bool(*)(const T &a_elem)  a_filter_func 
)
inline

Definition at line 145 of file vmanip.

145  {
146  std::vector<T> vs;
147  typedef typename std::vector<T>::iterator it_t;
148  for(it_t it=a_vals.begin();it!=a_vals.end();++it) {
149  if(a_filter_func(*it)) vs.push_back(*it);
150  }
151  a_vals = vs;
152 }

◆ vmul()

template<class T >
bool tools::vmul ( std::vector< T > &  a_vec,
const std::vector< T > &  a_v 
)
inline

Definition at line 329 of file vmanip.

329 {return vmul<T>(a_vec,a_v);}

◆ vsnpf()

int tools::vsnpf ( char *  a_s,
size_t  a_n,
const char *  a_fmt,
va_list  args 
)
inline

Definition at line 12 of file snpf.

12  {
13 #ifdef _MSC_VER
14 #if _MSC_VER < 1900
15  unsigned int old = _set_output_format(_TWO_DIGIT_EXPONENT);
16  int status = _vsnprintf(a_s,a_n,a_fmt,args);
17  _set_output_format(old);
18  return status;
19 #else
20  return _vsnprintf(a_s,a_n,a_fmt,args);
21 #endif
22 #else
23  return ::vsnprintf(a_s,a_n,a_fmt,args);
24 #endif
25 }

◆ vsprintf()

bool tools::vsprintf ( std::string &  a_string,
int  a_length,
const char *  a_format,
va_list  a_args 
)
inline

Definition at line 12 of file sprintf.

12  {
13  a_string.clear();
14  if(a_length<0) return false;
15  if(!a_format) return false;
16  char* s = new char[a_length+1];
17  if(!s) return false;
18  s[a_length] = '\0';
19  int n = vsnpf(s,a_length+1,a_format,a_args);
20  if(n>a_length) {
21  delete [] s;
22  return false;
23  }
24  if(s[a_length]!='\0') {
25  delete [] s;
26  return false;
27  }
28  a_string = s;
29  delete [] s;
30  return true;
31 }

◆ window_size_from_args()

bool tools::window_size_from_args ( const args a_args,
unsigned int &  a_ww,
unsigned int &  a_wh 
)
inline

Definition at line 88 of file saui.

88  {
89  // set a_ww,a_wh to some common window size (in pixels).
90  // return true if a_ww,a_wh set from a_args, false if not.
91  bool status = true;
92  if(a_args.is_arg("-iPod")||a_args.is_arg("-iPhone")) {
93  a_ww = 320;
94  a_wh = 480;
95  } else if(a_args.is_arg("-iPad")) {
96  a_ww = 768;
97  a_wh = 1024;
98  } else if(a_args.is_arg("-iPhone4")) {
99  a_ww = 640;
100  a_wh = 960;
101  } else if(a_args.is_arg("-wallino")) { //emulate LAL/wallino aspect ratio.
102  a_ww = 1024;
103  a_wh = 512;
104  } else if(a_args.is_arg("-SGS")) { //Samsung Galaxy S
105  //a_ww = 320;
106  //a_wh = 533;
107  a_ww = 480;
108  a_wh = 800;
109  } else {
110  if(a_args.find<unsigned int>("-ww",a_ww)) {
111  if(a_args.find<unsigned int>("-wh",a_wh)) return true;
112  //A4 : we have ww but not wh. Have wh in order to have A4 landscape :
113  a_wh = (unsigned int)(a_ww*(21.0f/29.7f)); //29.7/21 = 0.707
114  } else { //we don't have ww.
115  if(a_args.find<unsigned int>("-wh",a_wh)) {
116  //A4 : we have wh but not ww. Have ww in order to have A4 landscape :
117  a_ww = (unsigned int)(a_wh*(29.7f/21.0f));
118  } else {
119  //we have nothing. Take a ww of 1000 and wh (707) so that to have A4 landscape :
120  a_ww = 1000;
121  a_wh = (unsigned int)(a_ww*(21.0f/29.7f)); // have A4 landscape.
122  status = false;
123  }
124  }
125  }
126  if(a_args.is_arg("-land")){
127  unsigned int _ww = a_ww;
128  unsigned int _wh = a_wh;
129  a_ww = mx(_ww,_wh);
130  a_wh = mn(_ww,_wh);
131  }
132  if(a_args.is_arg("-portrait")){
133  unsigned int _ww = a_ww;
134  unsigned int _wh = a_wh;
135  a_ww = mn(_ww,_wh);
136  a_wh = mx(_ww,_wh);
137  }
138  return status;
139 }

◆ words() [1/2]

void tools::words ( const std::string &  a_string,
const std::string &  a_sep,
bool  a_take_empty,
std::vector< std::string > &  a_words,
bool  a_clear = true 
)
inline

Definition at line 12 of file words.

13  {
14  // If a_sep is for exa "|" and for "xxx||xxx" :
15  // - a_take_empty false : {"xxx","xxx"} will be created
16  // (and NOT {"xxx","","xxx"}).
17  // - a_take_empty true : {"xxx","","xxx"} will be created.
18  if(a_clear) a_words.clear();
19  if(a_string.empty()) return;
20  std::string::size_type lim = (a_take_empty?0:1);
21  if(a_sep.empty()) {
22  a_words.push_back(a_string);
23  } else {
24  std::string::size_type l = a_string.length();
25  std::string::size_type llimiter = a_sep.length();
26  std::string::size_type pos = 0;
27  while(true) {
28  std::string::size_type index = a_string.find(a_sep,pos);
29  if(index==std::string::npos){ // Last word.
30  if((l-pos)>=lim) a_words.push_back(a_string.substr(pos,l-pos));
31  break;
32  } else {
33  // abcxxxef
34  // 0 3 67
35  if((index-pos)>=lim) a_words.push_back(a_string.substr(pos,index-pos));
36  pos = index + llimiter;
37  }
38  }
39  }
40 }

◆ words() [2/2]

void tools::words ( const std::string &  a_string,
const std::string &  a_sep,
bool  a_take_empty,
unsigned int &  a_wn,
std::string::size_type  a_wps[],
std::string::size_type  a_wls[] 
)
inline

Definition at line 50 of file words.

55  {
56  //used to optimize tools::match().
57  a_wn = 0;
58  if(a_string.empty()) return;
59  std::string::size_type lim = (a_take_empty?0:1);
60  if(a_sep.empty()) {
61  //a_words.push_back(a_string);
62  a_wps[a_wn] = 0;
63  a_wls[a_wn] = a_string.length();
64  a_wn++;
65  } else {
66  std::string::size_type l = a_string.length();
67  std::string::size_type llimiter = a_sep.length();
68  std::string::size_type pos = 0;
69  while(true) {
70  std::string::size_type index = a_string.find(a_sep,pos);
71  if(index==std::string::npos){ // Last word.
72  if((l-pos)>=lim) {
73  //a_words.push_back(a_string.substr(pos,l-pos));
74  a_wps[a_wn] = pos;
75  a_wls[a_wn] = l-pos;
76  a_wn++;
77  }
78  break;
79  } else {
80  // abcxxxef
81  // 0 3 67
82  if((index-pos)>=lim) {
83  //a_words.push_back(a_string.substr(pos,index-pos));
84  a_wps[a_wn] = pos;
85  a_wls[a_wn] = index-pos;
86  a_wn++;
87  }
88  pos = index + llimiter;
89  }
90  }
91  }
92 }
tools::upointer_format_x
const char * upointer_format_x()
Definition: typedefs:80
tools::is_lower
bool is_lower(char a_char)
Definition: charmanip:51
tools::jpeg::is
bool is(const std::string &a_file)
Definition: jpeg:216
tools::remove
bool remove(std::vector< T > &a_vals, const T &a_elem)
Definition: vmanip:119
tools::uint64
unsigned long long uint64
Definition: typedefs:72
tools::int64
long long int64
Definition: typedefs:67
tools::leading
@ leading
Definition: strip:12
tools::suffix
std::string suffix(const std::string &a_string, bool a_back=true)
Definition: path:88
tools::get_env
bool get_env(const std::string &a_string, std::string &a_value)
Definition: get_env:18
tools::file::exists
bool exists(const std::string &a_string)
Definition: file:23
tools::pi
double pi()
Definition: mathd:17
tools::replace
void replace(std::string &a_string, char a_old, char a_new)
Definition: srep:14
tools::dir::mkcd
bool mkcd(const std::string &a_name)
Definition: dir:131
tools::psep
const std::string & psep()
Definition: sep:20
tools::match
bool match(const std::string &a_string, const std::string &a_pattern, bool a_check_for_wilds=true)
Definition: smatch:12
tools::center_adjust
bool center_adjust(std::ostream &a_out, sg::node &a_node, sg::matrix &a_tsf, unsigned int a_ww, unsigned int a_wh, float a_height, bool a_verbose=true)
Definition: mnmx:95
tools::dump
void dump(std::ostream &a_out, const std::string &aCMT, const MAT &a_matrix)
Definition: mat:648
tools::half_pi
double half_pi()
Definition: mathd:19
tools::env_path_append
bool env_path_append(const std::string &a_env, const std::vector< std::string > &a_paths)
Definition: path_env:44
tools::gunzip_get_byte
int gunzip_get_byte(char *&a_buffer)
Definition: zlib:118
tools::is_beg
bool is_beg(const std::string &a_s, const std::string &a_b, bool a_forward=true)
Definition: sbeg:11
tools::tos
std::string tos(unsigned int a_linen, const char *a_lines[])
Definition: tos:114
tools::to
bool to(std::ostream &a_out, const std::string &a_string, bool &a_value)
Definition: sto:75
tools::dir_name
std::string dir_name(const std::string &a_path, unsigned int a_num=1)
Definition: path:208
tools::area
void area(const VEC3 &a_p0, const VEC3 &a_p1, const VEC3 &a_p2, typename VEC3::elem_t &a_value)
Definition: vec3:371
tools::toss
void toss(const char *a_from, char a_s[], unsigned int &a_l)
Definition: tosu:12
tools::str_2d
bool str_2d(const char *a_s, double &a_v)
Definition: cstr:234
tools::gunzip_check_header
int gunzip_check_header(char *&a_buffer)
Definition: zlib:123
tools::tolowercase
void tolowercase(std::string &a_string)
Definition: touplow:11
tools::rep_env
bool rep_env(std::string &a_string)
Definition: file_name:14
tools::mn
T mn(const T &a, const T &b)
Definition: mnmx:10
tools::beg_LC_NUMERIC
char * beg_LC_NUMERIC()
Definition: cstr:221
tools::suffix
void suffix(const std::string &a_string, std::string &a_value, bool a_back=true)
Definition: path:11
tools::upointer_format
const char * upointer_format()
Definition: typedefs:79
tools::num2s
bool num2s(const std::string &a_value, std::string &a_s)
Definition: num2s:116
tools::mx
T mx(const T &a, const T &b)
Definition: mnmx:13
tools::env_append
bool env_append(const std::string &a_env, const std::string &a_sep, const std::vector< std::string > &a_vals)
Definition: path_env:16
tools::wcsv::pto
bool pto(std::ostream &a_writer, const std::string &a_class, const PROF &a_prof, char a_sep=',', char a_hc='#', bool a_header=true)
Definition: wcsv_histo:115
tools::end_LC_NUMERIC
void end_LC_NUMERIC(char *&a_s)
Definition: cstr:227
tools::trailing
@ trailing
Definition: strip:12
tools::put_env
bool put_env(const std::string &a_env, const std::string &a_value)
Definition: put_env:15
tools::waxml::begin
void begin(std::ostream &a_writer)
Definition: begend:15
tools::fpi
float fpi()
Definition: mathf:11
tools::size_t2s
bool size_t2s(size_t a_value, std::string &a_s)
Definition: num2s:64
tools::path_name_suffix
bool path_name_suffix(const std::string &a_string, std::string &a_path, std::string &a_name, std::string &a_suffix)
Definition: path:115
tools::strip
bool strip(std::vector< std::string > &a_strings, what a_type=both, char a_char=' ')
Definition: strip:67
tools::print2s
bool print2s(std::string &a_string, int a_length, const char *a_format,...)
Definition: sprintf:77
tools::direction
void direction(const T &a_0_x, const T &a_0_y, const T &a_0_z, const T &a_1_x, const T &a_1_y, const T &a_1_z, const T &a_2_x, const T &a_2_y, const T &a_2_z, vec3< T > &a_value)
Definition: vec3:377
tools::is_left
double is_left(const std::pair< T, T > &P0, const std::pair< T, T > &P1, const std::pair< T, T > &P2)
Definition: geom2:54
tools::is_upper
bool is_upper(char a_char)
Definition: charmanip:16
tools::uint64_format
const char * uint64_format()
Definition: typedefs:74
tools::get_env
bool get_env(const std::string &a_string, T &a_v, const T &a_def=T())
Definition: get_env:30
tools::nosuffix
std::string nosuffix(const std::string &a_string, bool a_back=true)
Definition: path:94
tools::snpf
int snpf(char *a_s, size_t a_n, const char *a_fmt,...)
Definition: snpf:27
tools::int32
int int32
Definition: typedefs:66
tools::realloc
bool realloc(T *&a_pointer, size_t a_new_size, size_t a_old_size, bool a_init=false)
Definition: realloc:9
tools::vectors_are_equal
bool vectors_are_equal(const VEC &a_1, const VEC &a_2, const PREC &a_prec, PREC(*a_fabs)(PREC))
Definition: eqT:64
tools::_cid
cid _cid(const std::vector< T > &)
Definition: cids:48
tools::file::size
bool size(const std::string &a_file, long &a_size)
Definition: fsize:13
tools::is_env
bool is_env(const std::string &a_string)
Definition: get_env:13
tools::vsnpf
int vsnpf(char *a_s, size_t a_n, const char *a_fmt, va_list args)
Definition: snpf:12
tools::is_digit
bool is_digit(char a_char)
Definition: charmanip:84
tools::both
@ both
Definition: strip:12
TOOLS_ZLIB_RESERVED
#define TOOLS_ZLIB_RESERVED
tools::to
std::vector< std::string > to(int a_argc, char **a_argv)
Definition: args:507
tools::upointer
unsigned long upointer
Definition: typedefs:78
tools_vforit
#define tools_vforit(a__T, a__v, a__it)
Definition: forit:13
tools::rcmp
bool rcmp(const char *a_1, const char *a_2)
Definition: rcmp:14
tools::int64_format
const char * int64_format()
Definition: typedefs:69
tools::numbers_are_equal
bool numbers_are_equal(const NUMBER &a_left, const NUMBER &a_right, const PREC &a_prec, PREC(*a_fabs)(NUMBER))
PREC(*a_fabs)(PREC) : ///////////////////////////////////////////////////////////////////////////////...
Definition: eqT:57
tools::dir::pwd
bool pwd(std::string &a_pwd)
Definition: dir:25
tools::compiler_name
const char * compiler_name()
Definition: platform:176
tools::words
void words(const std::string &a_string, const std::string &a_sep, bool a_take_empty, std::vector< std::string > &a_words, bool a_clear=true)
Definition: words:12
tools::b2s
void b2s(const std::vector< bool > &a_vals, std::string &a_s, const std::string &a_sep="\n", bool a_sep_at_end=false)
Definition: b2s:25
TOOLS_ZLIB_COMMENT
#define TOOLS_ZLIB_COMMENT
tools::is_printable
bool is_printable(char a_char)
Definition: charmanip:109
tools::waxml::end
void end(std::ostream &a_writer)
Definition: begend:31
tools::str_del
void str_del(char *&a_cstr)
Definition: cstr:66
tools::diff
void diff(std::ostream &a_out, const array< T > &aA, const array< T > &aB, T a_epsilon)
Definition: array:529
tools::sprintf
bool sprintf(std::string &a_string, int a_length, const char *a_format,...)
Definition: sprintf:34
tools_sforit
#define tools_sforit(a__s, a__it)
Definition: forit:37
tools::str_dup
char * str_dup(const char *a_cstr)
Definition: cstr:30
TOOLS_ZLIB_EXTRA_FIELD
#define TOOLS_ZLIB_EXTRA_FIELD
tools::replace
bool replace(std::vector< std::string > &a_strings, const std::string &a_old, const std::string &a_new)
Definition: srep:48
tools::file::found
bool found(const std::string &a_file, const std::string &a_what, std::vector< std::string > &a_found)
Definition: file:507
tools::sum
T sum(const std::vector< T > &a_vec)
Definition: vmanip:225
tools::dpow
bool dpow(const double &a_x, const double &a_y, double &a_v)
Definition: mathd:75
tools::base_name
void base_name(const std::string &a_path, std::string &a_value)
Definition: path:54
tools::snums
bool snums(const std::string &a_string, const std::string &a_sep, std::vector< T > &a_values, bool a_clear=true)
Definition: snums:32
tools::find_with_dirs
bool find_with_dirs(std::ostream &a_out, const std::vector< std::string > &a_dirs, const std::string &a_file, std::string &a_path, bool a_verbose=false)
Definition: fmanip:14
tools::decomplex
bool decomplex(const VEC_CMAT &a_vc, VEC_RMAT &a_vr, typename VEC_CMAT::value_type::elem_t::value_type(*a_real)(const typename VEC_CMAT::value_type::elem_t &), typename VEC_CMAT::value_type::elem_t::value_type(*a_imag)(const typename VEC_CMAT::value_type::elem_t &))
Definition: mat:281
tools::dir::cd_home
bool cd_home()
Definition: dir:74
tools::sep
const std::string & sep()
Definition: sep:11
tools::hls_to_rgb2
T hls_to_rgb2(T rn1, T rn2, T huei)
Definition: hls:12
tools_vforcit
#define tools_vforcit(a__T, a__v, a__it)
Definition: forit:7
tools::is_absolute_path
bool is_absolute_path(const std::string &a_path)
Definition: path:106
TOOLS_ZLIB_HEAD_CRC
#define TOOLS_ZLIB_HEAD_CRC
tools::uint32
unsigned int uint32
Definition: typedefs:71
TOOLS_ZLIB_ORIG_NAME
#define TOOLS_ZLIB_ORIG_NAME
tools::vec_data
T * vec_data(std::vector< T > &a_vec)
Definition: vdata:29
tools::toxml
void toxml(std::string &a_string)
Definition: srep:55
tools::array::vector
const std::vector< T > & vector() const
Definition: array:161
tools::base_name
std::string base_name(const std::string &a_path)
Definition: path:100