inlib  1.2.0
Namespaces | Classes | Typedefs | Enumerations | Functions
inlib Namespace Reference

manipulations that induces other includes : /////////// More...

Namespaces

namespace  a2
namespace  a2d
namespace  a2z
namespace  a3
namespace  a3d
namespace  a4
namespace  a4d
namespace  a4z
namespace  a6
namespace  a6d
namespace  a6z
namespace  aida
namespace  cloner
namespace  columns
namespace  config
namespace  dct
namespace  dir
namespace  f2cmn
namespace  file
namespace  func
namespace  healpix
namespace  hep
namespace  histo
namespace  hplot
namespace  image
namespace  io
namespace  ivrgb
namespace  net
namespace  ntu
namespace  osc
namespace  randf
namespace  random
namespace  rcsv
namespace  read
namespace  rroot
namespace  sg
namespace  sort
namespace  wall
namespace  waxml
namespace  wcsv
namespace  web
namespace  wroot
namespace  xpm

Classes

class  P1
class  P2
class  P3
class  args
class  array
class  kronecker
 common array ///////////////////////////////////////////////////////////// More...
class  box3f
class  CContour
class  CListContour
class  colord
class  colorf
class  FILE_reader
class  fit_func
class  fstring
class  base_handle
class  handle
class  hershey
class  img
class  lut
class  mat4f
class  nostream
class  ntu_proj
class  param
class  params
class  qrot
class  reader
class  rotd
class  rotf
class  spheref
class  sqm
class  E
 Some common d sqm ////////////////////////////////////////////////////////. More...
class  poincare_cartan_metric
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// More...
class  atime
class  base_timer
class  plugin
class  plugin_cache
class  upgrader
class  value
class  vec2f
class  vec3d
class  vec3f
class  vec4f
class  vecs

Typedefs

typedef std::list< unsigned int > CLineStrip
typedef std::list< CLineStrip * > CLineStripList
typedef std::vector
< CLineStripList
CLineStripListVector
typedef img< unsigned char > img_byte
typedef int64(* s2int64_func )(const char *, char **, int)
typedef unsigned short cid
typedef int int32
typedef long long int64
typedef unsigned int uint32
typedef unsigned long long uint64
typedef unsigned char byte
typedef unsigned char uchar
typedef short int16
typedef unsigned short uint16
typedef uint32 ref
typedef unsigned long diff_pointer_t
typedef char * cstr_t
typedef const char * const_cstr_t

Enumerations

enum  side { left, right, middle }
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)
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)
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)
std::string gui_toolkit (args &a_args, bool a_rm_in_args)
void window_size_from_args (const args &a_args, unsigned int &a_ww, unsigned int &a_wh)
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 inlib::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)
void box3f_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 box3f_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 box3f_is_empty (float a_mn_x, float a_mx_x)
template<class T >
unsigned int write_buffer (T a_value, char *a_buffer)
template<class T >
unsigned int read_buffer (const char *a_buffer, T &a_value)
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 (short)
cid _cid (int)
cid _cid (float)
cid _cid (double)
cid _cid (time_t)
cid _cid (const std::string &)
template<class T >
bool cmp (std::ostream &a_out, const T &a_what, const T &a_ref, const T &a_error=T())
std::ostream & operator<< (std::ostream &a_out, const colorf &a_this)
void rgb2hsv (int r, int g, int b, int &h, int &s, int &v)
bool hsv2rgb (int h, int s, int v, int &r, int &g, int &b)
template<class T >
void count_out (std::ostream &a_out, T a_count, T a_step)
char * str_dup (const char *a_cstr)
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)
bool find_with_dirs (std::ostream &a_out, const std::string &a_dirs, const std::string &a_file, std::string &a_path, bool a_verbose=false)
bool find_with_path (std::ostream &a_out, const std::string &a_env, const std::string &a_file, std::string &a_path, bool a_verbose=false)
bool get_files (std::ostream &a_out, const std::string &a_dirs, const std::string &a_exts, std::vector< std::string > &a_paths)
bool mkdirs (std::ostream &a_out, const std::string &a_path, bool a_cd=false)
float fpi ()
float ftwo_pi ()
float fhalf_pi ()
float fcos (float x)
float fsin (float x)
float facos (float x)
float fasin (float x)
float ftan (float x)
float fatan (float x)
float fatan2 (float x, float y)
float fsqrt (float x)
float fpow (float x, float y)
float flog (float x)
float flog10 (float x)
float ffloor (float x)
float ffabs (float x)
float fceil (float x)
float fdeg2rad ()
bool lut_from_string (std::ostream &a_out, const std::string &a_s, inlib::lut< float, unsigned char > &a_lut)
std::ostream & operator<< (std::ostream &a_out, const mat4f &)
double pi ()
double two_pi ()
double half_pi ()
template<class T >
power (const T &a_A, unsigned int a_B)
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)
template<class T >
mn (const T &a, const T &b)
template<class T >
mx (const T &a, const T &b)
bool mparam_bool (bool a_from_env, const inlib::args &a_args, const std::string &a_prefix, const std::string &a_name, const bool &a_def, bool &a_value)
bool mparam (bool a_from_env, const inlib::args &a_args, const std::string &a_prefix, const std::string &a_name, const std::string &a_def, std::string &a_value)
template<class T >
bool mparam (bool a_from_env, const inlib::args &a_args, const std::string &a_prefix, const std::string &a_name, const T &a_def, T &a_value)
const std::string & s_aida_type (char)
 for waxml : /////////////////////////
const std::string & s_aida_type (short)
const std::string & s_aida_type (int)
const std::string & s_aida_type (float)
const std::string & s_aida_type (double)
const std::string & s_aida_type (unsigned short)
 not AIDA ! //////////////////////////
const std::string & s_aida_type (bool)
const std::string & s_aida_type (const std::string &)
const std::string & s_aida_type (int64)
const std::string & s_aida_type (const std::vector< double > &)
const std::string & s_aida_type_ituple ()
const std::string & s_aida_type (uint64)
const char * os ()
const char * processor ()
const char * compiler_name ()
char * compiler ()
void out (std::ostream &a_out, const std::vector< std::string > &a_vec)
template<class T >
bool to_vals_one (const std::string &a_string, std::vector< T > &a_vals)
template<class T >
bool to_vals (const std::string &a_string, const char a_sep, std::vector< T > &a_vals)
bool name_args (const std::string &a_string, std::string &aName, std::vector< std::string > &aArgs)
bool parse_array (const std::string &a_string, std::string &aName, int &aIndex)
bool to_doubles (const std::string &a_string, std::vector< double > &a_values, const std::string &a_sep)
bool is_variable (const std::string &a_string)
unsigned int cstring_strtods (const char *a_cstr, std::vector< double > &a_vals, bool a_fixed=false)
bool read_doubles (const std::string &a_file, std::vector< double > &a_vals)
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)
bool is_little_endian ()
bool to_pointer (const std::string &a_string, void *&a_value)
std::string p2s (void *a_value)
std::string p2sx (void *a_value)
std::string char_p2s (const char *a_value)
std::string long2s (const long a_value)
bool rcmp (const std::string &a_1, const std::string &a_2)
template<class T >
bool realloc (T *&a_pointer, uint32 a_new_size, uint32 a_old_size, bool a_init=false)
int64 s2int64 (const char *a_s, char **a_end, int a_base)
bool s2time (const std::string &a_string, time_t &a_time)
template<class FROM , class TO >
TO * cast (FROM &a_o)
template<class FROM , class TO >
const TO * 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)
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 to_rgb (const std::string &a_string, double &a_r, double &a_g, double &a_b)
bool to_rgba (const std::string &a_string, double &a_r, double &a_g, double &a_b, double &a_a)
bool to_rgbs (const std::string &a_string, std::string &a_value)
std::string sep ()
std::string psep ()
std::string cmd_sep ()
bool justify (std::string &a_string, unsigned int a_size, side a_side=left)
std::string sjust (const std::string &a_string, unsigned int a_size, side a_side=left)
template<class T >
std::string sjust (T a_value, unsigned int a_size, side a_side=left)
bool belong (const std::vector< std::string > &a_vec, const std::string &a_s)
bool match (const std::string &a_string, const std::string &a_pattern)
unsigned int numchar (const std::string &a_string, char a_c)
void replace (std::string &a_string, char a_old, char a_new)
std::vector< std::string > path_words (const std::string &a_path, bool &a_absolute, bool &a_win_path, std::string &a_drive)
bool remove (std::vector< std::string > &a_strings, const std::string &a_string)
void tolowercase (std::string &a_string)
void touppercase (std::string &a_string)
bool is_ip (const std::string &a_string)
bool is_f77 (const std::string &a_path)
bool is_cpp (const std::string &a_path)
std::string to_xml (const std::string &a_string)
std::string to_string (const std::vector< std::string > &a_strings, const std::string &a_sep, bool a_sep_at_end=false)
std::string to_string (unsigned int a_linen, const char *a_lines[])
std::vector< std::string > to (int a_argc, char **a_argv)
template<class T >
bool values (const std::string &a_string, const std::string &a_sep, bool a_take_empty, std::vector< T > &a_values)
bool version (const std::string &a_string, std::vector< unsigned int > &a_version)
bool is_version (const std::string &a_string)
std::string remove_version (const std::string &a_string)
bool polynomial_degree (const std::string &a_string, int &a_degree)
std::string sout (const std::string &a_string)
bool sprintf (std::string &a_string, int a_length, const char *a_format,...)
template<class T >
sqm< T > operator- (const sqm< T > &a1, const sqm< T > &a2)
template<class T >
sqm< T > operator+ (const sqm< T > &a1, const sqm< T > &a2)
template<class T >
sqm< T > operator* (const sqm< T > &a1, const sqm< T > &a2)
template<class T >
sqm< T > commutator (const sqm< T > &a1, const sqm< T > &a2)
template<class T >
sqm< T > anticommutator (const sqm< T > &a1, const sqm< T > &a2)
template<class T >
sqm< T > exp (const sqm< T > &a_matrix, unsigned int aNumber=100)
template<class T >
sqm< T > log (const sqm< T > &a_matrix, unsigned int aNumber=100)
template<class T >
sqm< double > abs (const sqm< T > &a_matrix, double(*a_func)(T))
template<class T >
bool is_log_convergent (const sqm< T > &a_matrix, double(*a_func)(T))
template<class T >
bool determinant (const sqm< T > &a_matrix, T &a_deter)
template<class T >
void dump (const sqm< T > &a_matrix, std::ostream &a_out, const std::string &aCMT)
template<class T >
bool check_invert (const sqm< T > &a_matrix, std::ostream &a_out)
template<class T >
void conj (array< T > &a_array)
template<class T >
void dagger (sqm< T > &a_array)
template<class T >
sqm< std::complex< double > > to_complex (const sqm< T > &a_from)
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)
std::string to (bool a_value)
bool to (const std::string &a_string, bool &a_value)
template<class T >
bool to (const std::string &a_s, T &a_v)
template<class T >
std::string to (const T &a_v)
std::string d2s (double a_value)
std::string soutd (double a_value)
template<class T >
std::string sout (const T &a_value)
void strip (std::string &a_string, what a_type=both, char a_char= ' ')
std::string strp (const std::string &a_string, what a_type=both, char a_char= ' ')
void 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 (short)
const std::string & stype (int)
const std::string & stype (float)
const std::string & stype (double)
const std::string & stype (int64)
const std::string & stype (uint64)
const std::string & stype (const std::string &)
bool tmpname (const std::string &a_dir, const std::string &a_prefix, const std::string &a_suffix, std::string &a_name)
void sleep_secs (unsigned int a_secs)
void sleep_milli_secs (unsigned int a_milli_sec)
bool isenv (const std::string &a_string)
bool getenv (const std::string &a_string, std::string &a_value)
template<class T >
bool get_env (const std::string &a_string, T &a_v)
bool get_env_bool (const std::string &a_string, bool &a_v)
bool putenv (const std::string &a_env, const std::string &a_value)
bool rmenv (const std::string &a_env)
bool check_getenv (std::ostream &a_out, const std::string &a_new, const std::string &a_old, std::string &a_env)
int execute (const std::string &a_string)
bool env_append (const std::string &a_list, const std::string &a_value, const std::string &a_sep)
bool env_path_append (const std::string &a_paths, const std::string &a_path)
bool expand_vars (std::string &a_string)
bool file_name (const std::string &a_path, std::string &a_name)
std::string plugin_prefix ()
std::string plugin_suffix ()
std::string plugin_name (const std::string &a_name)
std::string so_name (const std::string &a_name)
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_value, const std::string &a_sep="\n")
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)
const char * int32_format ()
const char * int64_format ()
const char * uint32_format ()
const char * uint64_format ()
uint32 uint32_mx ()
uint64 uint64_mx ()
template<class T >
const T * vec_data (const std::vector< T > &a_vec)
template<class T >
T * vec_data (std::vector< T > &a_vec)
vec2f operator* (float a_f, const vec2f &a_v)
std::ostream & operator<< (std::ostream &a_out, const vec2f &a_this)
vec3d operator* (double a_f, const vec3d &a_v)
vec3f operator* (float a_f, const vec3f &a_v)
std::ostream & operator<< (std::ostream &a_out, const vec3f &a_this)
std::ostream & operator<< (std::ostream &a_out, const vecs &)
template<class T >
T * find_named (const std::vector< T * > &a_vec, const std::string &a_name)
template<class T >
void clear (std::vector< T * > &a_vec)
 manipulations that induces no intermediate vector : //
template<class T >
void append (std::vector< T > &a_vec, const std::vector< T > &a_from)
template<class T >
void unique (std::vector< T > &a_vec)
template<class T >
bool item_index (const std::vector< T > &a_vec, const T &a_item, unsigned int &a_index)
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_mn, unsigned int a_mx)
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 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 >
void div (std::vector< T > &a_vec, const T &a_v)
template<class FROM , class TO >
std::vector< TO > convert (const std::vector< FROM > &a_from)
template<class T >
void dump (const std::vector< T > &a_vec, std::ostream &a_out)
template<class T >
bool mean_rms (const std::vector< T > &a_vec, T &a_mean, T &a_rms)
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)
void words (const std::string &a_string, const std::string &a_sep, bool a_take_empty, std::vector< std::string > &a_words)
std::vector< std::string > words (const std::string &a_string, const std::string &a_limiter, bool a_take_empty=false)

Detailed Description

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


Typedef Documentation

typedef unsigned char inlib::byte

Definition at line 68 of file typedefs.

typedef unsigned short inlib::cid

Definition at line 19 of file safe_cast.

typedef std::list<unsigned int> inlib::CLineStrip

Definition at line 21 of file CListContour.

typedef std::list<CLineStrip*> inlib::CLineStripList

Definition at line 22 of file CListContour.

Definition at line 23 of file CListContour.

typedef const char* inlib::const_cstr_t

Definition at line 78 of file typedefs.

typedef char* inlib::cstr_t

Definition at line 77 of file typedefs.

typedef unsigned long inlib::diff_pointer_t

Definition at line 76 of file typedefs.

typedef img< unsigned char > inlib::img_byte

Definition at line 870 of file img.

typedef short inlib::int16

Definition at line 72 of file typedefs.

typedef int inlib::int32

Definition at line 45 of file typedefs.

typedef long long inlib::int64

Definition at line 46 of file typedefs.

typedef uint32 inlib::ref

Definition at line 74 of file typedefs.

typedef int64(* inlib::s2int64_func)(const char *, char **, int)

Definition at line 38 of file s2int64.

typedef unsigned char inlib::uchar

Definition at line 71 of file typedefs.

typedef unsigned short inlib::uint16

Definition at line 73 of file typedefs.

typedef unsigned int inlib::uint32

Definition at line 50 of file typedefs.

typedef unsigned long long inlib::uint64

Definition at line 51 of file typedefs.


Enumeration Type Documentation

Enumerator:
left 
right 
middle 

Definition at line 12 of file sjust.

{ left, right, middle };
Enumerator:
leading 
trailing 
both 

Definition at line 12 of file strip.


Function Documentation

cid inlib::_cid ( byte  ) [inline]

Definition at line 15 of file cids.

{return 1;}
cid inlib::_cid ( short  ) [inline]

Definition at line 16 of file cids.

{return 2;}
cid inlib::_cid ( int  ) [inline]

Definition at line 17 of file cids.

{return 3;}
cid inlib::_cid ( float  ) [inline]

Definition at line 18 of file cids.

{return 4;}
cid inlib::_cid ( double  ) [inline]

Definition at line 19 of file cids.

{return 5;}
cid inlib::_cid ( time_t  ) [inline]

Definition at line 21 of file cids.

{return 10;}
cid inlib::_cid ( const std::string &  ) [inline]

Definition at line 22 of file cids.

{return 11;}
template<class T >
sqm<double> inlib::abs ( const sqm< T > &  a_matrix,
double(*)(T)  a_func 
) [inline]

Definition at line 424 of file sqm.

                                                                  {
  const std::vector<T>& avec = a_matrix.vector();
  sqm<double> result(a_matrix.order());
  std::vector<double>& rvec = result.vector();
  unsigned int number = avec.size();
  for(unsigned int index=0;index<number;index++) 
    rvec[index] = a_func(avec[index]);
  return result;
}
template<class K , class V >
void inlib::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.

                                                 {
  typedef typename std::vector< std::pair<K,V> >::iterator it_t;
  it_t it;
  for(it=a_vec.begin();it!=a_vec.end();++it) {
    if((*it).first==a_key) {
      (*it).second = a_value; //override.
      return;
    }
  }
  //not found, add a new pair :
  a_vec.push_back(std::pair<K,V>(a_key,a_value));
}
template<class T >
bool inlib::add ( std::vector< T > &  a_vec,
const std::vector< T > &  a_v 
) [inline]

Definition at line 117 of file vmanip.

                                                            {
  if(a_vec.size()!=a_v.size()) return false;
  typedef typename std::vector<T>::iterator it_t;
  typedef typename std::vector<T>::const_iterator cit_t;
  it_t it = a_vec.begin();
  cit_t vit = a_v.begin();
  for(;it!=a_vec.end();++it,++vit) *it += *vit;
  return true;
}
template<class T >
void inlib::add ( std::vector< T > &  a_vec,
const T &  a_v 
) [inline]

Definition at line 157 of file vmanip.

                                                 {
  typedef typename std::vector<T>::iterator it_t;
  for(it_t it=a_vec.begin();it!=a_vec.end();++it) *it += a_v;
}
template<class T >
sqm<T> inlib::anticommutator ( const sqm< T > &  a1,
const sqm< T > &  a2 
) [inline]

Definition at line 378 of file sqm.

                                                                {
  return a1*a2+a2*a1;
}
template<class T >
void inlib::append ( std::vector< T > &  a_vec,
const std::vector< T > &  a_from 
) [inline]

Definition at line 29 of file vmanip.

                                                                   {
  typedef typename std::vector<T>::size_type sz_t;
  sz_t vsize = a_vec.size();
  sz_t number = a_from.size();
  a_vec.resize(vsize+number);
  sz_t offset = vsize; 
  for(sz_t index=0;index<number;index++,offset++) {
    a_vec[offset] = a_from[index];
  }
}
std::string inlib::base_name ( const std::string &  a_path) [inline]

Definition at line 34 of file path.

                                                    {
  std::string::size_type pos_slash = a_path.rfind('/');
  std::string::size_type pos_bslash = a_path.rfind('\\');
  std::string::size_type pos = 0;
  if(pos_slash==std::string::npos) {
    if(pos_bslash==std::string::npos) {
      pos = std::string::npos;
    } else {
      pos = pos_bslash;
    }
  } else {
    if(pos_bslash==std::string::npos) {
      pos = pos_slash;
    } else {
      if(pos_slash<=pos_bslash) {
        pos = pos_bslash;
      } else {
        pos = pos_slash;
      }
    }
  }
  if(pos==std::string::npos) return a_path;
  pos++;
  return a_path.substr(pos,a_path.size()-pos);
}
bool inlib::belong ( const std::vector< std::string > &  a_vec,
const std::string &  a_s 
) [inline]

Definition at line 22 of file smanip.

                                         {
  std::vector<std::string>::const_iterator it;
  for(it=a_vec.begin();it!=a_vec.end();++it) {
    if(*it==a_s) return true;
  }
  return false;
}
void inlib::box3f_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.

                                                          {
  if(a_mx_x<a_mn_x){ //is empty.
    a_mn_x = a_x;
    a_mn_y = a_y;
    a_mn_z = a_z;

    a_mx_x = a_x;
    a_mx_y = a_y;
    a_mx_z = a_z;
  } else {
    a_mn_x = inlib::mn<float>(a_x,a_mn_x);
    a_mn_y = inlib::mn<float>(a_y,a_mn_y);
    a_mn_z = inlib::mn<float>(a_z,a_mn_z);

    a_mx_x = inlib::mx<float>(a_x,a_mx_x);
    a_mx_y = inlib::mx<float>(a_y,a_mx_y);
    a_mx_z = inlib::mx<float>(a_z,a_mx_z);
  }
}
bool inlib::box3f_is_empty ( float  a_mn_x,
float  a_mx_x 
) [inline]

Definition at line 45 of file box_3f.

                                                      {
  return a_mx_x < a_mn_x;
}
void inlib::box3f_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.

                                                                       {
  a_mn_x = FLT_MAX;
  a_mn_y = FLT_MAX;
  a_mn_z = FLT_MAX;
  a_mx_x = -FLT_MAX;
  a_mx_y = -FLT_MAX;
  a_mx_z = -FLT_MAX;
}
template<class FROM , class TO >
TO* inlib::cast ( FROM &  a_o) [inline]

Definition at line 10 of file safe_cast.

                           {
  return (TO*)a_o.cast(TO::s_class());
}
template<class FROM , class TO >
const TO* inlib::cast ( const FROM &  a_o) [inline]

Definition at line 15 of file safe_cast.

                                       {
  return (const TO*)a_o.cast(TO::s_class());
}
std::string inlib::char_p2s ( const char *  a_value) [inline]

Definition at line 50 of file pointer.

                                               {
  char s[512];
#ifdef WIN32
  _snprintf(s,sizeof(s),"%lu",(unsigned long)a_value);
#else
  ::snprintf(s,sizeof(s),"%lu",(unsigned long)a_value);
#endif
  return std::string(s);
}
bool inlib::check_args ( const std::vector< std::string > &  a_args,
unsigned int  a_number,
std::ostream &  a_out 
) [inline]

Definition at line 304 of file args.

                                                                                                  {
  if(a_args.size()==a_number) return true;
  a_out << "bad argument number." 
        << " Given " << (unsigned int)a_args.size() 
        << " whilst " << a_number << " expected."
        << std::endl;
  return false;
}
bool inlib::check_getenv ( std::ostream &  a_out,
const std::string &  a_new,
const std::string &  a_old,
std::string &  a_env 
) [inline]

Definition at line 63 of file system.

                                                                                                          {
  if(inlib::getenv(a_new,a_env)) return true;
  if(inlib::getenv(a_old,a_env)) {
    a_out << "Environment variable " << sout(a_old) << " is deprecated."
          << " Use " << sout(a_new) << " instead."
          << std::endl;
    return true;
  }
  return false;
}
template<class T >
bool inlib::check_invert ( const sqm< T > &  a_matrix,
std::ostream &  a_out 
) [inline]

Definition at line 829 of file sqm.

                                                                   {
  unsigned int ord = a_matrix.order();
  sqm<T> I(ord);
  I.set_identity();
  sqm<T> inv(ord);
  if(!a_matrix.invert(inv)) return false;
  //sqm<T> tmp(ord);
  //a_matrix.mx_mul(inv,tmp);
  sqm<T> tmp = a_matrix * inv;
  if(!tmp.equal(I)) {
    dump(a_matrix,a_out,"problem with inv of :");
    dump(inv,a_out,"found :");
    return false;
  }
  return true;
}
bool inlib::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 313 of file args.

                                                                                                                   {
  if(a_args.size()>=a_number) {
    if(a_number==0) {
      if(a_args.empty()) {
        a_last.clear();
      } else {
        a_last = a_args[0];
        for(unsigned int index=1;index<a_args.size();index++) {
          a_last += " " + a_args[index];
        }
      }
    } else {
      a_last = a_args[a_number-1];
      for(unsigned int index=a_number;index<a_args.size();index++) {
        a_last += " " + a_args[index];
      }
    }
    return true;
  }
  a_out << "bad argument number." 
        << " Given " << (unsigned int)a_args.size() 
        << " whilst at least " << a_number << " expected."
        << std::endl;
  return false;
}
bool inlib::check_min_args ( const std::vector< std::string > &  aArgs,
unsigned int  a_number,
std::ostream &  a_out 
) [inline]

Definition at line 339 of file args.

                                                                                                     {
  if(aArgs.size()>=a_number) return true;
  a_out << "bad argument number." 
        << " Given " << (unsigned int)aArgs.size() 
        << " whilst at least " << a_number << " expected."
        << std::endl;
  return false;
}
bool inlib::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 348 of file args.

                                                                                                                {
  if((aArgs.size()==a_1)||(aArgs.size()==a_2)) return true;
  a_out << "bad argument number." 
        << " Given " << (unsigned int)aArgs.size() 
        << " whilst " << a_1 << " or " << a_2 << " expected."
        << std::endl;
  return false;
}
template<class T >
void inlib::clear ( std::vector< T * > &  a_vec) [inline]

manipulations that induces no intermediate vector : //

Definition at line 16 of file vmanip.

                                       {
  // the below takes into account the case in
  // which "delete entry" could modify a_vec.
  typedef typename std::vector<T*>::iterator it_t;
  while(!a_vec.empty()) {
    it_t it = a_vec.begin();
    T* entry  = *it;
    a_vec.erase(it);
    delete entry;    
  }
}
std::string inlib::cmd_sep ( ) [inline]

Definition at line 27 of file sep.

                           {
#ifdef WIN32
  return "&&";
#else
  return ";";
#endif
}
template<class T >
bool inlib::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.

                                                       {
  if(a_what>a_ref) {
    if((a_what-a_ref)>a_error) {
      a_out << a_ref << " expected. Got " << a_what << std::endl;
      return false;
    }
  } else {
    if((a_ref-a_what)>a_error) {
      a_out << a_ref << " expected. Got " << a_what << std::endl;
      return false;
    }
  }
  return true;
}
template<class TO >
void* inlib::cmp_cast ( const TO *  a_this,
const std::string &  a_class 
) [inline]

Definition at line 15 of file scast.

                                                                 {
  if(!inlib::rcmp(a_class,TO::s_class())) return 0;
  return (void*)static_cast<const TO*>(a_this);
}
template<class TO >
void* inlib::cmp_cast ( const TO *  a_this,
cid  a_id 
) [inline]

Definition at line 21 of file scast.

                                                 {
  if(TO::id_class()!=a_id) return 0;
  return (void*)static_cast<const TO*>(a_this);
}
template<class T >
sqm<T> inlib::commutator ( const sqm< T > &  a1,
const sqm< T > &  a2 
) [inline]

Definition at line 373 of file sqm.

                                                            {
  return a1*a2-a2*a1;
}
char* inlib::compiler ( ) [inline]

Definition at line 94 of file os.

                        {
  static char s[64];
  char* pos = s;
  unsigned int l;
  toss(compiler_name(),pos,l);pos += l;

#if defined(__GNUC__)
  *pos++ = '_';
  tosu<unsigned int>(__GNUC__,pos,l);pos += l;  
  tosu<unsigned int>(__GNUC_MINOR__,pos,l);pos += l;
  tosu<unsigned int>(__GNUC_PATCHLEVEL__,pos,l);pos += l;
#elif defined(_MSC_VER)
  *pos++ = '_';
  tosu<unsigned int>(_MSC_VER,pos,l);pos += l;  
  //_mfc_
  //tosu<unsigned int>(_MFC_VER,pos,l);pos += l;
#elif defined(__alpha)
#else
#endif
  return s;
}
const char* inlib::compiler_name ( ) [inline]

Definition at line 74 of file os.

                                   {

#if defined(__GNUC__)
  static const char s[] = "gcc";
#elif defined(_MSC_VER)
  static const char s[] = "cl";
#elif defined(__alpha)
  static const char s[] = "cxx";
#else
  static const char s[] = "unknown";
#endif
  return s;
}
template<class T >
void inlib::conj ( array< T > &  a_array) [inline]

Definition at line 14 of file sqmz.

                                    {
  std::vector<T>& vec = a_array.vector();
  typedef typename std::vector<T>::iterator vec_it_t;
  for(vec_it_t it = vec.begin();it!=vec.end();++it) {
    (*it) = conj(*it);     
  }
}
template<class T >
bool inlib::contract ( const array< T > &  aA,
unsigned int  aIA,
const array< T > &  aB,
unsigned int  aIB,
array< T > &  aR 
) [inline]

Definition at line 363 of file array.

 {
  // Contract a tensor (aA) with a vector (aB) 
  // on indice aIA of aA and aIB of aB.
  // aA.dimension must be > 1.
  // aB.dimension must be > 1.
  if(&aR==&aA) return false;
  if(&aR==&aB) return false;

  if(aA.dimension()==0) return false;
  if(aB.dimension()==0) return false;
  if(aIA>=aA.dimension()) return false;
  if(aIB>=aB.dimension()) return false;
  if(aA.orders()[aIA]!=aB.orders()[aIB]) return false;

  unsigned int rdima = aA.dimension()-1;
  unsigned int rdimb = aB.dimension()-1;

  if((rdima+rdimb)==0) return false;

  std::vector<unsigned int> rorders(rdima+rdimb);
  unsigned int index;
  for(index=0;index<aIA;index++) 
    rorders[index] = aA.orders()[index];
  for(index=aIA;index<rdima;index++) 
    rorders[index] = aA.orders()[index+1];

  for(index=0;index<aIB;index++) 
    rorders[rdima+index] = aB.orders()[index];
  for(index=aIB;index<rdimb;index++) 
    rorders[rdima+index] = aB.orders()[index+1];

  if(!aR.configure(rorders)) return false;

  std::vector<unsigned int> ais(aA.dimension());
  std::vector<unsigned int> bis(aB.dimension());
  std::vector<unsigned int> ris(aR.dimension());

  //FIXME : optimize the below.
  unsigned int order = aA.orders()[aIA];
  unsigned int rsize = aR.size();

  std::vector<T>& rvec = aR.vector();

  for(unsigned int roffset=0;roffset<rsize;roffset++) {
    if(!aR.indices(roffset,ris)) return false;

    for(index=0;index<aIA;index++) ais[index] = ris[index];
    for(index=aIA;index<rdima;index++) ais[index+1] = ris[index];

    for(index=0;index<aIB;index++) bis[index] = ris[rdima+index];
    for(index=aIB;index<rdimb;index++) bis[index+1] = ris[rdima+index];

    T value = 0;
    for(index=0;index<order;index++) {
      ais[aIA] = index;
      T av;
      if(!aA.value(ais,av)) return false;

      bis[aIB] = index;
      T bv;
      if(!aB.value(bis,bv)) return false;

      value += av * bv;
    }

    rvec[roffset] = value;
  }

  return true;
}
template<class FROM , class TO >
std::vector<TO> inlib::convert ( const std::vector< FROM > &  a_from) [inline]

Definition at line 181 of file vmanip.

                                                           {
  typedef typename std::vector<FROM>::const_iterator const_it_t;
  typedef typename std::vector<TO>::iterator it_t;
  std::vector<TO> to(a_from.size());
  const_it_t ait = a_from.begin();
  it_t toit = to.begin();
  for(;ait!=a_from.end();++ait,++toit) {*toit = (TO)*ait;}
  return to;
}
template<class T >
void inlib::count_out ( std::ostream &  a_out,
a_count,
a_step 
) [inline]

Definition at line 13 of file count_out.

                                                            {
  if(a_step*T(a_count/a_step)==a_count) a_out << a_count << std::endl;
}
char inlib::CR ( ) [inline]

Definition at line 17 of file chars.

{return 13;}
unsigned int inlib::cstring_strtods ( const char *  a_cstr,
std::vector< double > &  a_vals,
bool  a_fixed = false 
) [inline]

Definition at line 205 of file parse.

                                                                                                      {
  // a_fixed = false : a_vals size is adapted according to what is read.
  // a_fixed = true : a_vals size is fixed. If less is read, then the
  //                 rest is pad with 0.
  // return : the number of double read.

  char* old = str_dup(::setlocale(LC_NUMERIC,0));
  ::setlocale(LC_NUMERIC,"C");

  unsigned int n = a_vals.size();
  char* begin = (char*)a_cstr;
  char* end;
  double d;
  unsigned int index = 0;
  std::vector<double>::iterator it = a_vals.begin();
  while(true) {  
    d = ::strtod(begin,&end);
    if(end==begin) {
      if(a_fixed) {
        for(;it!=a_vals.end();++it) *it = 0;
      } else {
        if(index<n) a_vals.resize(index);
      }
      ::setlocale(LC_NUMERIC,old);
      str_del(old);
      return index;
    }
    if(index<n) {
      *it = d;
      it++;
    } else {
      if(a_fixed) {
        ::setlocale(LC_NUMERIC,old);
        str_del(old);
        return index;
      }
      a_vals.push_back(d);
    }
    index++;
    begin = end;
  }
}
std::string inlib::d2s ( double  a_value) [inline]

Definition at line 58 of file sto.

                                    {
  std::ostringstream strm;
  strm.precision(25);
  strm << a_value;
  return strm.str();
}
template<class T >
void inlib::dagger ( sqm< T > &  a_array) [inline]

Definition at line 23 of file sqmz.

                                    {
  conj(a_array);
  a_array.transpose();
}
template<class T >
bool inlib::determinant ( const sqm< T > &  a_matrix,
T &  a_deter 
) [inline]

Definition at line 459 of file sqm.

                                                           {
  // Brut force determinant by using the kroneckers.
  a_deter = a_matrix.zero();

  unsigned int order = a_matrix.order(); 

  typedef typename std::vector<unsigned int> uints_t;
  typedef typename std::vector<T>::const_iterator const_vec_it_t;

  kronecker<T> k_c(order);
  const std::vector<T>& vec_c = k_c.vector();
  const_vec_it_t it_c;
  uints_t is_c(order);

  //kronecker<T> k_r(order);
  //const std::vector<T>& vec_r = k_r.vector();
  //const_vec_it_t it_r;
  //uints_t is_r(order);

  unsigned int index_c = 0;
  for(it_c = vec_c.begin();it_c!=vec_c.end();++it_c,index_c++) {
    if(*it_c==0.) continue;
    if(!k_c.indices(index_c,is_c)) return false;
    //unsigned int index_r = 0;
    //for(it_r = vec_r.begin();it_r!=vec_r.end();++it_r,index_r++) {
    //  if(*it_r==0.) continue;
    //  if(!k_r.indices(index_r,is_r)) return false;
      T v = array<T>::one();
      for(unsigned iorder=0;iorder<order;iorder++) {
        //v *= a_matrix.value(is_c[iorder],is_r[iorder]); 
        v *= a_matrix.value(is_c[iorder],iorder); 
      }
      a_deter += v;
    //}
  }

  //{T fact = array<T>::one();
  //for(unsigned index=1;index<=order;index++) fact *= index;
  //a_deter /= fact;}

  return true;
}
template<class T >
void inlib::diff ( std::ostream &  a_out,
const array< T > &  aA,
const array< T > &  aB,
a_epsilon 
) [inline]

Definition at line 491 of file array.

                                                                                     {
  if(aA.orders()!=aB.orders()) {
    a_out << "inlib::arrays::diff : not same orders" << std::endl;
    return;
  }
  bool header_done = false;
  unsigned int dim = aA.dimension();
  std::vector<unsigned int> is(dim);
  unsigned int vsize = aA.vector().size();
  for(unsigned int index=0;index<vsize;index++) {
    T diff = aA.vector()[index]-aB.vector()[index];      
    if(diff<0) diff *= -1;
    if(diff>=a_epsilon) {
      aA.indices(index,is);
      if(!header_done) {
        a_out << "inlib::arrays::diff :" << std::endl;
        header_done = true;
      }
      for(unsigned int i=0;i<dim;i++) a_out << is[i] << " ";
      a_out << aA.vector()[index] << " " << aB.vector()[index] << std::endl;
    }
  }
}
std::string inlib::dir_name ( const std::string &  a_path,
unsigned int  a_num = 1 
) [inline]

Definition at line 155 of file path.

                                                                         {
  std::string path = a_path;
  for(unsigned int index=0;index<a_num;index++) {
    std::string p,n,s;
    path_name_suffix(path,p,n,s);
    path = p;
  }
  return path;
}
template<class T >
bool inlib::div ( std::vector< T > &  a_vec,
const std::vector< T > &  a_v 
) [inline]

Definition at line 139 of file vmanip.

                                                            {
  if(a_vec.size()!=a_v.size()) return false;
  typedef typename std::vector<T>::iterator it_t;
  typedef typename std::vector<T>::const_iterator cit_t;
  it_t it = a_vec.begin();
  cit_t vit = a_v.begin();
  bool errors = false;
  for(;it!=a_vec.end();++it,++vit) {
    if(*vit==T()) {
      errors = true;
    } else {
      *it /= *vit;
    }
  }
  return errors;
}
template<class T >
void inlib::div ( std::vector< T > &  a_vec,
const T &  a_v 
) [inline]

Definition at line 175 of file vmanip.

                                                 {
  typedef typename std::vector<T>::iterator it_t;
  for(it_t it=a_vec.begin();it!=a_vec.end();++it) *it /= a_v;
}
template<class T >
void inlib::dump ( const std::vector< T > &  a_vec,
std::ostream &  a_out 
) [inline]

Definition at line 202 of file vmanip.

                                                             {
  typedef typename std::vector<T>::const_iterator it_t;
  it_t it;
  for(it=a_vec.begin();it!=a_vec.end();++it) {
    a_out << *it << std::endl;
  }
}
template<class T >
void inlib::dump ( std::ostream &  a_out,
const inlib::array< T > &  a_array,
const std::string &  a_title 
) [inline]

Definition at line 481 of file array.

                                                                                         {
  if(a_title.size()) a_out << a_title << std::endl;
  const std::vector<T>& vec = a_array.vector();
  typedef typename std::vector<T>::const_iterator cons_vec_it_t;
  for(cons_vec_it_t it = vec.begin();it!=vec.end();++it) {
    a_out << (*it) << std::endl;
  }
}
template<class T >
void inlib::dump ( const sqm< T > &  a_matrix,
std::ostream &  a_out,
const std::string &  aCMT 
) [inline]

Definition at line 817 of file sqm.

                                                                                 {
  if(aCMT.size()) a_out << aCMT << std::endl;
  unsigned int ord = a_matrix.order();
  for(unsigned int r=0;r<ord;r++) {
    for(unsigned int c=0;c<ord;c++) {
      a_out << " " << a_matrix.value(r,c);
    }
    a_out << std::endl;
  }
}
bool inlib::env_append ( const std::string &  a_list,
const std::string &  a_value,
const std::string &  a_sep 
) [inline]

Definition at line 78 of file system.

                                                                                               {
  std::string old_value;
  if(inlib::isenv(a_list)) {
    if(!inlib::getenv(a_list,old_value)) return false;
  }

  if(old_value.size()) {
    std::vector<std::string> ws;
    inlib::words(old_value,a_sep,false,ws);
    // Remove existing one, so that a_value be put at end.
    inlib::remove(ws,a_value);
    old_value = inlib::to_string(ws,a_sep);
  }

  std::string new_value = old_value;
  if(new_value.size()) new_value += a_sep;
  new_value += a_value;
  if(!putenv(a_list,new_value)) return false;

  return true;
}
bool inlib::env_path_append ( const std::string &  a_paths,
const std::string &  a_path 
) [inline]

Definition at line 100 of file system.

                                                                             {
  return env_append(a_paths,a_path,psep());
}
int inlib::execute ( const std::string &  a_string) [inline]

Definition at line 74 of file system.

                                              {
  return ::system(a_string.c_str());
}
template<class T >
sqm<T> inlib::exp ( const sqm< T > &  a_matrix,
unsigned int  aNumber = 100 
) [inline]

Definition at line 383 of file sqm.

                                                                     {
  // result = I + M + M**2/2! + M**3/3! + ....
  sqm<T> result(a_matrix.order());
  result.set_identity();
  sqm<T> m(a_matrix.order());     
  m.set_identity();
  for(unsigned int i=1;i<aNumber;i++) {
    m = m * a_matrix; 
    m.multiply(1./double(i)); 
    result.add(m);
  }
  return result;
}
bool inlib::expand_vars ( std::string &  a_string) [inline]

Definition at line 104 of file system.

                                            {
  std::string::size_type dollar;
  while((dollar=a_string.find('$'))!=std::string::npos){
    std::string::size_type slash = a_string.find('/',dollar+1);
    std::string::size_type back_slash = a_string.find('\\',dollar+1);
    std::string::size_type pos = std::string::npos; 
    if(slash!=std::string::npos) {
      if(back_slash!=std::string::npos) {
        pos = slash<back_slash?slash:back_slash;
      } else {
        pos = slash;
      }
    } else {
      if(back_slash!=std::string::npos) {
        pos = back_slash;
      } else {
        pos = std::string::npos; 
      }
    }
    std::string env;
    if(pos==std::string::npos) {
      env = a_string.substr(dollar+1,a_string.length()-(dollar+1));
    } else {
      //     abc$xxx/ef
      //     0  3   7 9
      env = a_string.substr(dollar+1,pos-(dollar+1));
    }
    char* val = ::getenv(env.c_str());
    if(!val) return false; // Stop looping if env variable not found.
    std::string value = a_string.substr(0,dollar);
    value += val;
    if(pos!=std::string::npos)
      value += a_string.substr(pos,a_string.length()-pos);
    a_string = value;
  }
  return true;
}
float inlib::facos ( float  x) [inline]

Definition at line 19 of file fmath.

{return (float)::acos(double(x));}
float inlib::fasin ( float  x) [inline]

Definition at line 20 of file fmath.

{return (float)::asin(double(x));}
float inlib::fatan ( float  x) [inline]

Definition at line 22 of file fmath.

{return (float)::atan(double(x));}
float inlib::fatan2 ( float  x,
float  y 
) [inline]

Definition at line 23 of file fmath.

{return (float)::atan2(double(x),double(y));}
float inlib::fceil ( float  x) [inline]

Definition at line 30 of file fmath.

{return (float)::ceil(double(x));}
float inlib::fcos ( float  x) [inline]

Definition at line 17 of file fmath.

{return (float)::cos(double(x));}
float inlib::fdeg2rad ( ) [inline]

Definition at line 32 of file fmath.

{return fpi()/180.0f;}
float inlib::ffabs ( float  x) [inline]

Definition at line 29 of file fmath.

{return (float)::fabs(double(x));}
float inlib::ffloor ( float  x) [inline]

Definition at line 28 of file fmath.

{return (float)::floor(double(x));}
float inlib::fhalf_pi ( ) [inline]

Definition at line 15 of file fmath.

{return (float)1.5707963267948965580E0;}
bool inlib::file_name ( const std::string &  a_path,
std::string &  a_name 
) [inline]

Definition at line 142 of file system.

                                                                 {
  a_name = a_path;
  if(!expand_vars(a_name)) {a_name.clear();return false;}
#ifdef WIN32
  replace(a_name,"/","\\");
  replace(a_name,"\"","");
#endif
  return true;
}
template<class T >
void inlib::filter ( std::vector< T > &  a_vec,
unsigned int  a_mn,
unsigned int  a_mx 
) [inline]

Definition at line 99 of file vmanip.

                                                       {
  unsigned int imx = a_vec.size()-1;
  unsigned int mx = a_mx<imx?a_mx:imx;
  unsigned int i = 0;
  for(unsigned int index=a_mn;index<=mx;index++) {
    a_vec[i] = a_vec[index];i++;
  }
  a_vec.resize(i);
}
template<class K , class V >
bool inlib::find ( const std::vector< std::pair< K, V > > &  a_vec,
const K &  a_key,
V &  a_value 
) [inline]

Definition at line 27 of file vpair.

                                            {
  typedef typename std::vector< std::pair<K,V> >::const_iterator it_t;
  it_t it;
  for(it=a_vec.begin();it!=a_vec.end();++it) {
    if((*it).first==a_key) {
      a_value = (*it).second;
      return true;
    }
  }
  a_value = V();
  return false;
}
template<class T >
T* inlib::find_named ( const std::vector< T * > &  a_vec,
const std::string &  a_name 
) [inline]

Definition at line 13 of file vfind.

                                                                         {
  typedef typename std::vector<T*>::const_iterator it_t;
  it_t it;
  for(it=a_vec.begin();it!=a_vec.end();++it) {
    if((*it)->name()==a_name) return *it;
  }
  return 0;
}
bool inlib::find_with_dirs ( std::ostream &  a_out,
const std::string &  a_dirs,
const std::string &  a_file,
std::string &  a_path,
bool  a_verbose = false 
) [inline]

Definition at line 15 of file fmanip.

                                                    {
  std::vector<std::string> words;
  inlib::words(a_dirs,psep(),false,words);
  std::vector<std::string>::const_iterator it;
  for(it=words.begin();it!=words.end();++it) {
    a_path = *it;
    a_path += sep();
    a_path += a_file;

    if(a_verbose) {
      a_out << "find_with_dirs :"
            << " look for " << inlib::sout(a_path) << " ..."
            << std::endl;
    }

    if(inlib::file::exists(a_path)) {
      if(a_verbose) {
        a_out << "find_with_dirs :"
              << " found " << inlib::sout(a_path) << "."
              << std::endl;
      }
      return true;
    }
  }
  a_path.clear();

  if(a_verbose) {
    a_out << "find_with_dirs :"
          << " " << inlib::sout(a_file) << " not found."
          << std::endl;
  }

  return false;   
}
bool inlib::find_with_path ( 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 54 of file fmanip.

                                                    {
  std::string PATH;
  if(!inlib::getenv(a_env,PATH)) {
    //look for a a_file in current directory.
    a_path = a_file;
    if(inlib::file::exists(a_path)) return true;
    a_out << "inlib::find_with_path :"
          << " env variable " << sout(a_env) << " not defined."
          << std::endl;
    a_path.clear();
    return false;
  }
  if(a_verbose) {
    a_out << "find_with_path :"
          << " PATH is " << inlib::sout(PATH)
          << std::endl;
  }
  return find_with_dirs(a_out,PATH,a_file,a_path,a_verbose);
}
float inlib::flog ( float  x) [inline]

Definition at line 26 of file fmath.

{return (float)::log(double(x));}
float inlib::flog10 ( float  x) [inline]

Definition at line 27 of file fmath.

{return (float)::log10(double(x));}
float inlib::fpi ( ) [inline]

Definition at line 13 of file fmath.

{return (float)3.1415926535897931160E0;}
float inlib::fpow ( float  x,
float  y 
) [inline]

Definition at line 25 of file fmath.

{return (float)::pow(double(x),(double)(y));}
float inlib::fsin ( float  x) [inline]

Definition at line 18 of file fmath.

{return (float)::sin(double(x));}
float inlib::fsqrt ( float  x) [inline]

Definition at line 24 of file fmath.

{return (float)::sqrt(double(x));}
float inlib::ftan ( float  x) [inline]

Definition at line 21 of file fmath.

{return (float)::tan(double(x));}
float inlib::ftwo_pi ( ) [inline]

Definition at line 14 of file fmath.

{return (float)6.2831853071795862320E0;}
template<class T >
bool inlib::get_env ( const std::string &  a_string,
T &  a_v 
) [inline]

Definition at line 31 of file system.

                                                     {
  std::string s;
  if(!getenv(a_string,s)) return false;
  return to<T>(s,a_v);
}
bool inlib::get_env_bool ( const std::string &  a_string,
bool &  a_v 
) [inline]

Definition at line 37 of file system.

                                                             {
  std::string s;
  if(!getenv(a_string,s)) return false;
  return to(s,a_v);
}
bool inlib::get_files ( std::ostream &  a_out,
const std::string &  a_dirs,
const std::string &  a_exts,
std::vector< std::string > &  a_paths 
) [inline]

Definition at line 84 of file fmanip.

                                                                                                                       {

  a_paths.clear();

  std::vector<std::string> exts;
  inlib::words(a_exts,"\n",false,exts);

  bool status = true;

  std::vector<std::string> words;
  inlib::words(a_dirs,inlib::psep(),false,words);

  std::vector<std::string>::const_iterator pit;
  for(pit=words.begin();pit!=words.end();++pit) {
    const std::string& dir = *pit;
    bool is_dir;
    if(!inlib::dir::is_a(dir,is_dir)) continue;
    if(!is_dir) continue;
        
    std::vector<std::string> ls;
    if(!inlib::dir::entries(dir,ls,false)){
      a_out << "inlib::get_files :"
            << " can't get entries"
            << " of directory " << inlib::sout(dir) << "."
            << std::endl;
      status = false;
      continue; //continue anyway.
  //} else {
      //a_out << "inlib::get_files :"
      //a_out << "number of files : " << ls.size() << std::endl;
      //std::vector<std::string>::const_iterator it;
      //for(it=ls.begin();it!=ls.end();++it) {
      //  a_out << *it << std::endl;
      //}
    }
    
    std::vector<std::string> files;
   {std::vector<std::string>::const_iterator it;
    for(it=ls.begin();it!=ls.end();++it) {
      if((*it)==".") continue;
      if((*it)=="..") continue;

      std::vector<std::string>::const_iterator eit;
      for(eit=exts.begin();eit!=exts.end();++eit) {
        const std::string& ext = *eit;
        if((*it).rfind(ext)!=std::string::npos) {
          files.push_back(*it);
        }
      }
    }}
      
    std::vector<std::string>::const_iterator it;
    for(it=files.begin();it!=files.end();++it) {
      std::string path = dir+"/"+(*it);
      a_paths.push_back(path);
    }
  }

  inlib::unique(a_paths);
  
  return status;
}
bool inlib::getenv ( const std::string &  a_string,
std::string &  a_value 
) [inline]

Definition at line 19 of file system.

                                                                {
  const char* env = ::getenv(a_string.c_str());
  if(env) {
    a_value = std::string(env?env:"");
    return true;
  } else {
    a_value.clear();
    return false;
  }
}
std::string inlib::gui_toolkit ( args &  a_args,
bool  a_rm_in_args 
) [inline]

Definition at line 378 of file args.

                                                            {
  std::string driver;
  a_args.find("-toolkit",driver);
  if(a_rm_in_args) a_args.remove("-toolkit");
  if(driver.empty()) {
    if(a_args.is_arg("-Xt")||
       a_args.is_arg("-xt")||
       a_args.is_arg("-Xm")||
       a_args.is_arg("-xm")||
       a_args.is_arg("-Motif")||
       a_args.is_arg("-motif")) {
      driver = "Xt";
      if(a_rm_in_args) {
        a_args.remove("-Xt");
        a_args.remove("-xt");
        a_args.remove("-Xm");
        a_args.remove("-xm");
        a_args.remove("-Motif");
        a_args.remove("-motif");
      }
    } else if(a_args.is_arg("-Win")||
              a_args.is_arg("-win")||
              a_args.is_arg("-Win32")||
              a_args.is_arg("-win32")) {
      driver = "Win";
      if(a_rm_in_args) {
        a_args.remove("-Win");
        a_args.remove("-win");
        a_args.remove("-Win32");
        a_args.remove("-win32");
      }
    } else if(a_args.is_arg("-NextStep")||
              a_args.is_arg("-nextstep")) {
      driver = "NextStep";
      if(a_rm_in_args) {
        a_args.remove("-NextStep");
        a_args.remove("-nextstep");
      }
    } else if(a_args.is_arg("-Gtk")||
              a_args.is_arg("-gtk")) {
      driver = "Gtk";
      if(a_rm_in_args) {
        a_args.remove("-Gtk");
        a_args.remove("-gtk");
      }
    } else if(a_args.is_arg("-Qt")||
              a_args.is_arg("-qt")) {
      driver = "Qt";
      if(a_rm_in_args) {
        a_args.remove("-Qt");
        a_args.remove("-qt");
      }
    } else if(a_args.is_arg("-SDL")||
              a_args.is_arg("-sdl")) {
      driver = "SDL";
      if(a_rm_in_args) {
        a_args.remove("-SDL");
        a_args.remove("-sdl");
      }
    } else if(a_args.is_arg("-Net")||
              a_args.is_arg("-net")) {
      driver = "Net";
      if(a_rm_in_args) {
        a_args.remove("-Net");
        a_args.remove("-net");
      }
    }
  }

  return driver;
}
double inlib::half_pi ( ) [inline]

Definition at line 19 of file math.

{return 1.5707963267948965580E0;}
bool inlib::hsv2rgb ( int  h,
int  s,
int  v,
int &  r,
int &  g,
int &  b 
) [inline]

Definition at line 66 of file colormanip.

                                                                 {
  if ( h < -1 || (unsigned int)s > 255 || (unsigned int)v > 255 ) {
    r = g = b = 0;
    return false;
  }
  r=v;
  g=v;
  b=v;
  if ( s == 0 || h == -1 ) {                    // achromatic case
    // Ignore
  } else {                                      // chromatic case
    if ( (unsigned int)h >= 360 ) h %= 360;
    unsigned int f = h%60;
    h /= 60;
    unsigned int p = (unsigned int)(2*v*(255-s)+255)/510;
    unsigned int q, t;
    if ( h&1 ) {
      q = (unsigned int)(2*v*(15300-s*f)+15300)/30600;
      switch( h ) {
        case 1: r=(int)q; g=(int)v, b=(int)p; break;
        case 3: r=(int)p; g=(int)q, b=(int)v; break;
        case 5: r=(int)v; g=(int)p, b=(int)q; break;
      }
    } else {
      t = (unsigned int)(2*v*(15300-(s*(60-f)))+15300)/30600;
      switch( h ) {
        case 0: r=(int)v; g=(int)t, b=(int)p; break;
        case 2: r=(int)p; g=(int)v, b=(int)t; break;
        case 4: r=(int)t; g=(int)p, b=(int)v; break;
      }
    }
  }
  return true;
}
template<class FROM , class TO >
TO* inlib::id_cast ( FROM &  a_o) [inline]

Definition at line 22 of file safe_cast.

                              {
  return (TO*)a_o.cast(TO::id_class());
}
template<class FROM , class TO >
const TO* inlib::id_cast ( const FROM &  a_o) [inline]

Definition at line 27 of file safe_cast.

                                          {
  return (const TO*)a_o.cast(TO::id_class());
}
bool inlib::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 67 of file app.

                                                                                                                                               {
  std::string exe_dir = inlib::dir_name(a_arg0);
  std::string bname = inlib::base_name(exe_dir);
  if(bname=="MacOS") {
    // cd in a_doc_dir :
    if(!inlib::dir::cd_home()) {
      a_out << "if_mouse_startup : can't go home." << std::endl;
      return false;
    }
    std::vector<std::string>::const_iterator it;
    for(it=a_home_dirs.begin();it!=a_home_dirs.end();it++) {
      if(!inlib::dir::mkcd(*it)) {
        a_out << "if_mouse_startup :"
              << " can't mkcd " << sout(*it)
              << std::endl;
        return false;
      }
    }

    // set a_env_HOME_DIR from exe_dir :
    std::string Contents_dir = inlib::dir_name(exe_dir);
    if(!inlib::putenv(a_env_HOME_DIR,Contents_dir)) {
      a_out << "if_mouse_startup :"
            << " can't putenv " << a_env_HOME_DIR 
            << " to " << inlib::sout(Contents_dir)
            << "."
            << std::endl;
      return false;
    }

    if(!inlib::env_path_append("DYLD_LIBRARY_PATH",Contents_dir+"/bin"))
      return false;
    // for on-the-fly compilation and loading :
    if(!inlib::env_path_append("DYLD_LIBRARY_PATH",".")) return false;

    if(!inlib::isenv("DISPLAY")) {
      if(!inlib::putenv("DISPLAY",":0.0")) return false;
    }

  } else if(bname=="bin") {
    //Linux, Windows : mouse startup ?

/* FIXME : do we want to treat the case of a terminal startup
           whence the user did not <source setup> ???
           If so if_mouse_startup should be renamed no_env_startup.

  } else if(exe_dir=="") { //for exa when typing "osc-plot".
    if(!program_path(a_arg0,exe_dir)) {
      a_out << "if_mouse_startup :"
            << " program_path failed for " << inlib::sout(bname) << "."
            << std::endl;
      return false;
    }
    a_out << "if_mouse_startup :"
          << " program_path is " << inlib::sout(exe_dir) << "."
          << std::endl;

#if defined(__APPLE__) || defined(Linux)
    bool is_abs,is_win;
    std::string drive;
    std::vector<std::string> words = path_words(exe_dir,is_abs,is_win,drive);
    std::vector<std::string>::size_type n = words.size();
    
    if( (n>=3) && 
        (words[n-1]=="bin") && 
        is_version(words[n-2]) &&
        (words[n-3].substr(0,4)=="osc_") 
      ){

      std::string osc_vers_dir = inlib::dir_name(exe_dir);

      printf("debug : auto env 000 \"%s\"\n",osc_vers_dir.c_str());

      //if(a_env_HOME_DIR.size()) {
        if(!inlib::putenv(a_env_HOME_DIR,osc_vers_dir)) {
          a_out << "arg0_setenv :"
                << " can't putenv " << a_env_HOME_DIR 
                << " to " << inlib::sout(osc_vers_dir)
                << "."
                << std::endl;
          return false;
        }
      //}

#ifdef __APPLE__

     {std::string x;
      inlib::getenv("DYLD_LIBRARY_PATH",x);
      printf("debug : auto env 001 \"%s\"\n",x.c_str());}

      if(!inlib::env_path_append("DYLD_LIBRARY_PATH",osc_vers_dir+"/bin"))
        return false;

     {std::string x;
      inlib::getenv("DYLD_LIBRARY_PATH",x);
      printf("debug : auto env 002 \"%s\"\n",x.c_str());}

      if(!inlib::env_path_append("DYLD_LIBRARY_PATH",osc_vers_dir+"/lib"))
        return false;

     {std::string x;
      inlib::getenv("DYLD_LIBRARY_PATH",x);
      printf("debug : auto env 003 \"%s\"\n",x.c_str());}

      // for on-the-fly compilation and loading :
      if(!inlib::env_path_append("DYLD_LIBRARY_PATH",".")) return false;

     {std::string x;
      inlib::getenv("DYLD_LIBRARY_PATH",x);
      printf("debug : auto env 004 \"%s\"\n",x.c_str());}


#else
#endif

      if(!inlib::isenv("DISPLAY")) {
        if(!inlib::putenv("DISPLAY",":0.0")) return false;
      }

    }
#endif
*/

  }

  return true;
}
bool inlib::in_domain_acos ( double  a_x) [inline]

Definition at line 36 of file math.

                                      {
  if((a_x<-1)||(1<a_x)) return false;
  return true;
}
bool inlib::in_domain_all ( double  ) [inline]

Definition at line 29 of file math.

{return true;}
bool inlib::in_domain_log ( double  a_x) [inline]

Definition at line 30 of file math.

{return (a_x>0?true:false);}
bool inlib::in_domain_tan ( double  a_x) [inline]

Definition at line 31 of file math.

                                     {
  int n = int(a_x/half_pi());
  if(a_x!=n*half_pi()) return true;
  return (2*int(n/2)==n?true:false);    
}
const char* inlib::int32_format ( ) [inline]

Definition at line 47 of file typedefs.

{static const char s[] = "%d";return s;}
const char* inlib::int64_format ( ) [inline]

Definition at line 48 of file typedefs.

{static const char s[] = "%lld";return s;}
bool inlib::is_absolute_path ( const std::string &  a_path) [inline]

Definition at line 60 of file path.

                                                      {
  if(a_path.find('\\')!=std::string::npos) { //Windows path.
    if(a_path.find(':')!=std::string::npos) return true;
    return (a_path.size()&&(a_path[0]=='\\')?true:false);
  } else { //UNIX path
    return (a_path.size()&&(a_path[0]=='/')?true:false);
  }
}
bool inlib::is_cpp ( const std::string &  a_path) [inline]

Definition at line 196 of file smanip.

                                           {
  std::string sfx = suffix(a_path);
  tolowercase(sfx);
  if(sfx=="c") return true;
  if(sfx=="cxx") return true;
  if(sfx=="cpp") return true;
  if(sfx=="C") return true;
  return false;
}
bool inlib::is_digit ( char  a_char) [inline]

Definition at line 84 of file charmanip.

                                  {
  switch(a_char){
    case '0':return true;
    case '1':return true;
    case '2':return true;
    case '3':return true;
    case '4':return true;
    case '5':return true;
    case '6':return true;
    case '7':return true;
    case '8':return true;
    case '9':return true;
    default:return false;
  }
  return false;
}
bool inlib::is_f77 ( const std::string &  a_path) [inline]

Definition at line 184 of file smanip.

                                           {
  std::string sfx = suffix(a_path);
  tolowercase(sfx);
  if(sfx=="f") return true;       //the standard.
  if(sfx=="for") return true;     //for opaw. Known by g77.
  if(sfx=="ftn") return true;     //for opaw.
  if(sfx=="fortran") return true; //for opaw.
  if(sfx=="f77") return true;
  return false;
}
bool inlib::is_ip ( const std::string &  a_string) [inline]

Definition at line 161 of file smanip.

                                            {
  if(a_string.empty()) return false;
  if(a_string[0]=='.') return false;
  if(a_string[a_string.size()-1]=='.') return false;
  unsigned int ndot = 0;  
  std::string::const_iterator it;
  for(it=a_string.begin();it!=a_string.end();++it) {
    if((*it)=='.') {
      ndot++;
    } else if( ((*it)=='0') || ((*it)=='1') ||
               ((*it)=='2') || ((*it)=='3') ||
               ((*it)=='4') || ((*it)=='5') ||
               ((*it)=='6') || ((*it)=='7') ||
               ((*it)=='8') || ((*it)=='9') ){
    } else {
      return false;
    }
  }
  if(ndot!=3) return false;
  return true;
}
bool inlib::is_letter ( char  a_char) [inline]

Definition at line 101 of file charmanip.

                                   { 
  return (is_lower(a_char)||is_upper(a_char)) ? true : false;
}
bool inlib::is_little_endian ( ) [inline]

Definition at line 13 of file platform.

                               {
  unsigned int i = 1;
  unsigned char* b = (unsigned char*)&i;
  // BE = Big Endian, LE = Little Endian.
  // The Intels x86 are LE.
  // Mac PPC b[3] is 1 (BE)
  // Mac Intel b[0] is 1 (LE)
  // Linux i386 b[0] is 1 (LE)
  // Linux x86_64 b[0] is 1 (LE)
  return (b[0]==1?true:false);
}
template<class T >
bool inlib::is_log_convergent ( const sqm< T > &  a_matrix,
double(*)(T)  a_func 
) [inline]

Definition at line 435 of file sqm.

                                                                         {
  unsigned int order = a_matrix.order();
  sqm<T> I(order);     
  I.set_identity();
  sqm<T> s(a_matrix);
  s.subtract(I);
  sqm<double> a = abs(s,a_func);
  double radius = 1./order;

  std::vector<double>& vec = a.vector();
  typedef typename std::vector<T>::iterator vec_it_t;
  for(vec_it_t it = vec.begin();it!=vec.end();++it) {
    if((*it)>=radius) {
      //::printf("debug : not convergent at : %d : %g rad %g\n",
        //index,a.value(index),radius);
      return false;
    }
  }

  return true;
}
bool inlib::is_lower ( char  a_char) [inline]

Definition at line 51 of file charmanip.

                                  {
  switch(a_char) {
    case 'a':return true;
    case 'b':return true;
    case 'c':return true;
    case 'd':return true;
    case 'e':return true;
    case 'f':return true;
    case 'g':return true;
    case 'h':return true;
    case 'i':return true;
    case 'j':return true;
    case 'k':return true;
    case 'l':return true;
    case 'm':return true;
    case 'n':return true;
    case 'o':return true;
    case 'p':return true;
    case 'q':return true;
    case 'r':return true;
    case 's':return true;
    case 't':return true;
    case 'u':return true;
    case 'v':return true;
    case 'w':return true;
    case 'x':return true;
    case 'y':return true;
    case 'z':return true;
    default:return false;
  }
  return false;
}
bool inlib::is_mac_app ( const std::string &  ) [inline]

Definition at line 22 of file app.

{return false;}
bool inlib::is_printable ( char  a_char) [inline]

Definition at line 109 of file charmanip.

                                      { 
  if(is_lower(a_char)||is_upper(a_char)||is_digit(a_char)) return true;
  switch(a_char) {
    case ' ':return true;
    case '!':return true;
    case '"':return true;
    case '#':return true;
    case '$':return true;
    case '%':return true;
    case '&':return true;
    case '\'':return true;
    case '(':return true;
    case ')':return true;
    case '*':return true;
    case '+':return true;
    case ',':return true;
    case '-':return true;
    case '.':return true;
    case '/':return true;
    case ':':return true;
    case ';':return true;
    case '<':return true;
    case '=':return true;
    case '>':return true;
    case '?':return true;
    case '@':return true;
    case '[':return true;
    case '\\':return true;
    case ']':return true;
    case '^':return true;
    case '_':return true;
    case '`':return true;
    case '{':return true;
    case '|':return true;
    case '}':return true;
    case '~':return true;
    default:return false;
  }
  return false;
}
bool inlib::is_upper ( char  a_char) [inline]

Definition at line 16 of file charmanip.

                                  {
  // do it myself: due to problem with ctype.h and 
  // isxxx macros on different platforms.
  switch(a_char) {
    case 'A':return true;
    case 'B':return true;
    case 'C':return true;
    case 'D':return true;
    case 'E':return true;
    case 'F':return true;
    case 'G':return true;
    case 'H':return true;
    case 'I':return true;
    case 'J':return true;
    case 'K':return true;
    case 'L':return true;
    case 'M':return true;
    case 'N':return true;
    case 'O':return true;
    case 'P':return true;
    case 'Q':return true;
    case 'R':return true;
    case 'S':return true;
    case 'T':return true;
    case 'U':return true;
    case 'V':return true;
    case 'W':return true;
    case 'X':return true;
    case 'Y':return true;
    case 'Z':return true;
    default:return false;
  }
  return false;
}
bool inlib::is_variable ( const std::string &  a_string) [inline]

Definition at line 187 of file parse.

                                                  {
  // Check if a_string is of the form of a programmation variable.
  // - not empty.
  // - not starting by a number.
  // - being composed of alphanumeric, number and '_' characters.
  if(!a_string.size()) return false;
  char* pos = (char*)a_string.c_str();
  if(inlib::is_digit(*pos)) return false;
  pos++;
  while(*pos) {
    if( !inlib::is_letter(*pos) && 
        !inlib::is_digit(*pos) && 
        ((*pos)!='_') ) return false;
    pos++;
  }
  return true;
}
bool inlib::is_version ( const std::string &  a_string) [inline]

Definition at line 340 of file smanip.

                                                  {
  std::vector<unsigned int> vers;
  return version(a_string,vers);
}
bool inlib::isenv ( const std::string &  a_string) [inline]

Definition at line 14 of file system.

                                            {
  const char* env = ::getenv(a_string.c_str());
  return (env?true:false);
}
template<class T >
bool inlib::item_index ( const std::vector< T > &  a_vec,
const T &  a_item,
unsigned int &  a_index 
) [inline]

Definition at line 57 of file vmanip.

                                                                                       {
  a_index = 0;
  typedef typename std::vector<T>::const_iterator it_t;
  it_t it;
  for(it=a_vec.begin();it!=a_vec.end();++it,a_index++) {
    if(*it==a_item) return true;
  }
  a_index = 0;
  return false;
}
bool inlib::justify ( std::string &  a_string,
unsigned int  a_size,
side  a_side = left 
) [inline]

Definition at line 14 of file sjust.

                                       {
  // a_size is the final string length.
  strip(a_string);
  if(a_size<=a_string.size()) {
    a_string.resize(a_size);
    return false;
  } else {
    if(a_side==left) {
      a_string = a_string + std::string(a_size-a_string.size(),' ');
    } else if(a_side==right) {
      a_string = std::string(a_size-a_string.size(),' ') + a_string;
    } else if(a_side==middle) {
      int l = a_size - a_string.size();
      int h = l/2;
      if(h*2==l) { //even number of spaces :
        a_string = std::string(h,' ') + a_string + std::string(h,' ');
      } else { // odd number of spaces :
        a_string = std::string(h,' ') + a_string + std::string(h+1,' ');
      }
    }
    return false;
  }
}
char inlib::LF ( ) [inline]

Definition at line 16 of file chars.

{return 10;}
template<class T >
sqm<T> inlib::log ( const sqm< T > &  a_matrix,
unsigned int  aNumber = 100 
) [inline]

Definition at line 398 of file sqm.

                                                                     {
  // result = (M-I) - (M-I)**2/2 + (M-I)**3/3 +...
  // Warning : cannot converge...
  unsigned int order = a_matrix.order();
  sqm<T> result(order);
  sqm<T> I(order);     
  I.set_identity();
  sqm<T> x(a_matrix);     
  x.subtract(I);
  sqm<T> m(I);
  sqm<T> tmp(order);
  double fact = -1;
  for(unsigned int i=0;i<aNumber;i++) {
    m = m * x; 
    fact *= -1;
    tmp = m;
    tmp.multiply(fact/double(i+1)); 
    result.add(tmp);
  }
  return result;
}
std::string inlib::long2s ( const long  a_value) [inline]

Definition at line 60 of file pointer.

                                            {
  char s[512];
#ifdef WIN32
  _snprintf(s,sizeof(s),"%ld",a_value);
#else
  ::snprintf(s,sizeof(s),"%ld",a_value);
#endif
  return std::string(s);
}
bool inlib::lut_from_string ( std::ostream &  a_out,
const std::string &  a_s,
inlib::lut< float, unsigned char > &  a_lut 
) [inline]

Definition at line 12 of file lutmanip.

                                                                  {
  std::vector<std::string> words;
  inlib::words(a_s,",",false,words);
  if(words.size()!=3) {
    a_out << "lut_from_string :" 
          << " bad syntax in a_ " << inlib::sout(a_s)
          << ". <float:min>,<float:max>,<unsigned int:num> expected."
          << std::endl;    
    return false;
  }
  float mn,mx;
  if(!inlib::to<float>(words[0],mn)) {
    a_out << "lut_from_string :" 
          << " bad syntax in a_ " << inlib::sout(a_s)
          << ". " << words[0] << " not a float."
          << std::endl;    
    return false;
  }
  if(!inlib::to<float>(words[1],mx)) {
    a_out << "lut_from_string :" 
          << " bad syntax in a_ " << inlib::sout(a_s)
          << ". " << words[1] << " not a float."
          << std::endl;    
    return false;
  }
  unsigned int num;
  if(!inlib::to<unsigned int>(words[2],num)) {
    a_out << "lut_from_string :" 
          << " bad syntax in a_ " << inlib::sout(a_s)
          << ". " << words[2] << " not an unsigned int."
          << std::endl;    
    return false;
  }  
  a_lut = inlib::lut<float,unsigned char>(mn,mx,num);
  return true;
}
bool inlib::match ( const std::string &  a_string,
const std::string &  a_pattern 
) [inline]

Definition at line 31 of file smanip.

                                                                       {
  std::string::size_type lpattern = a_pattern.length();
  std::string::size_type lstring  = a_string.length();
  if ((lpattern==0)&&(lstring==0)) return true;
  if ((lpattern==0)&&(lstring!=0)) return true;
  if ((lpattern!=0)&&(lstring==0)) return false;

  if(a_pattern=="*") return true; // pattern is * :

 {bool some_star = false;
  for(unsigned int count=0;count<lpattern;count++) {
    if(a_pattern[count]=='*') {some_star = true;break;}
  }
  if(!some_star) {  // no wildcard :
    return (a_pattern==a_string ? true : false );
  }}

  // complex pattern :
  std::vector<std::string> ws;
  words(a_pattern,"*",false,ws);  
  if(ws.empty()) return true; // only wildcards :

  // tricky case :
  unsigned int wnumber = ws.size();
  char* token = (char*)a_string.c_str();
 {for(unsigned int count=0;count<wnumber;count++) { 
    unsigned int lword = ws[count].size(); 
    if(!lword) continue;//should never happen !
    if(count==0) {
      if(a_pattern[0]!='*') {
        // Begin of pattern (ws[0]) and a_string must match :
        if(::strncmp(token,ws[count].c_str(),lword)) return false;
        token = token + lword;
        continue;
      }
    }
    char* pos = ::strstr(token,ws[count].c_str());
    if(!pos) return false;
    if((count==(wnumber-1)) && (a_pattern[lpattern-1]!='*') ) { // Last word.
      // Compare last word and end of a_string.
      if(::strcmp(a_string.c_str()+lstring-lword,ws[count].c_str())) 
        return false;
      break;
    } else {
      token = pos + lword;
    }
  }}
  return true;
}
template<class T >
bool inlib::maximum ( const std::vector< T > &  a_vec,
T &  a_value 
) [inline]

Definition at line 80 of file vmanip.

                                                          {
  if(a_vec.empty()) {a_value = T();return false;}
  a_value = a_vec[0];
  typedef typename std::vector<T>::const_iterator it_t;
  for(it_t it = a_vec.begin();it!=a_vec.end();++it) {
    a_value = (a_value>(*it)?a_value:(*it));
  }
  return true;
}
template<class T >
bool inlib::mean_rms ( const std::vector< T > &  a_vec,
T &  a_mean,
T &  a_rms 
) [inline]

Definition at line 217 of file vmanip.

                                                                   {
  if(a_vec.empty()) {a_mean=T();a_rms=T();return false;}
  T S = T();
  T S2 = T();
  typedef typename std::vector<T>::const_iterator it_t;
  for(it_t it = a_vec.begin();it!=a_vec.end();++it) {
    S += *it;
    S2 += (*it) * (*it);
  }
  a_mean = S/T(a_vec.size());
  //NOTE : should use a templated sqrt and fabs.
  a_rms = ::sqrt(::fabs(S2/T(a_vec.size()) - a_mean * a_mean));
  return true;
}
template<class T >
bool inlib::minimum ( const std::vector< T > &  a_vec,
T &  a_value 
) [inline]

Definition at line 69 of file vmanip.

                                                          {
  if(a_vec.empty()) {a_value = T();return false;}
  a_value = a_vec[0];
  typedef typename std::vector<T>::const_iterator it_t;
  for(it_t it = a_vec.begin();it!=a_vec.end();++it) {
    a_value = (a_value<(*it)?a_value:(*it));
  }
  return true;
}
bool inlib::mkdirs ( std::ostream &  a_out,
const std::string &  a_path,
bool  a_cd = false 
) [inline]

Definition at line 147 of file fmanip.

                                                                                {
  //By default it does not "cd" to the leaf directory.
  //In the below, we should treat "absolute" and the case of win_path.
  bool absolute;
  bool win_path;
  std::string drive;
  std::vector<std::string> dirs = path_words(a_path,absolute,win_path,drive);
  if(drive.size()) {
    a_out << "inlib::mkdirs :"
          << " path with a Windows drive not treated yet."
          << std::endl;
    return false;
  }
  if(absolute) {
    a_out << "inlib::mkdirs :"
          << " absolute path not treated yet."
          << std::endl;
    return false;
  }
  std::string spwd;
  if(!a_cd) {
    if(!dir::pwd(spwd)) {
      a_out << "inlib::mkdirs :"
            << " can't get current directory."
            << std::endl;
      return false;
    }
  }  
  bool status = true;
  std::vector<std::string>::const_iterator it;
  for(it=dirs.begin();it!=dirs.end();++it) {
    if(!dir::mkcd(*it)) {
      a_out << "inlib::mkdirs :"
            << " can't mkcd " << sout(*it)
            << std::endl;
      status = false;
      break;
    }
  }
  if(!a_cd) {
    //return to spwd :
    if(!dir::cd(spwd)) {
      a_out << "inlib::mkdirs :"
            << " can't cd to " << spwd << "."
            << std::endl;
      return false;
    }
  }
  return status;
}
template<class T >
T inlib::mn ( const T &  a,
const T &  b 
) [inline]

Definition at line 10 of file mnmx.

                                   {
  return (a<b?a:b);
}    
bool inlib::mparam ( bool  a_from_env,
const inlib::args a_args,
const std::string &  a_prefix,
const std::string &  a_name,
const std::string &  a_def,
std::string &  a_value 
) [inline]

Definition at line 40 of file mparam.

                                          {
  a_value = a_def;
  bool found = true;
  if(a_from_env) { 
    std::string NAME(a_name);
    inlib::touppercase(NAME);
    if(!inlib::getenv(a_prefix+NAME,a_value)) {
      found = false;
      a_value = a_def;
    }
  } else {
    if(!a_args.find("-"+a_name,a_value)) {
      found = false;
      a_value = a_def;
    }
  }
  return found;
}
template<class T >
bool inlib::mparam ( bool  a_from_env,
const inlib::args a_args,
const std::string &  a_prefix,
const std::string &  a_name,
const T &  a_def,
T &  a_value 
) [inline]

Definition at line 64 of file mparam.

                                              {
  a_value = a_def;
  bool found = true;
  if(a_from_env) { 
    std::string NAME(a_name);
    inlib::touppercase(NAME);
    if(!inlib::get_env<T>(a_prefix+NAME,a_value)) {
      found = false;
      a_value = a_def;
    }
  } else {
    if(!a_args.find<T>("-"+a_name,a_value)) {
      found = false;
      a_value = a_def;
    }
  }
  return found;
}
bool inlib::mparam_bool ( bool  a_from_env,
const inlib::args a_args,
const std::string &  a_prefix,
const std::string &  a_name,
const bool &  a_def,
bool &  a_value 
) [inline]

Definition at line 16 of file mparam.

                                          {
  a_value = a_def;
  bool found = true;
  if(a_from_env) { 
    std::string NAME(a_name);
    inlib::touppercase(NAME);
    if(!inlib::get_env_bool(a_prefix+NAME,a_value)) {
      found = false;
      a_value = a_def;
    }
  } else {
    if(!a_args.find("-"+a_name,a_value)) {
      found = false;
      a_value = a_def;
    }
  }
  return found;
}
template<class T >
void inlib::mul ( std::vector< T > &  a_vec,
const T &  a_v 
) [inline]

Definition at line 169 of file vmanip.

                                                 {
  typedef typename std::vector<T>::iterator it_t;
  for(it_t it=a_vec.begin();it!=a_vec.end();++it) *it *= a_v;
}
template<class T >
T inlib::mx ( const T &  a,
const T &  b 
) [inline]

Definition at line 15 of file mnmx.

                                   {
  return (a>b?a:b);
}    
bool inlib::name_args ( const std::string &  a_string,
std::string &  aName,
std::vector< std::string > &  aArgs 
) [inline]

Definition at line 71 of file parse.

                                                                                              {
  // Look if aName is of the form <string>(<string>,...,<string>)
  // return true if so.
  // return true if <string> without args
  // return false if any bad syntax.
  std::string::size_type lb = a_string.find('(');
  std::string::size_type rb = a_string.rfind(')');
  if( (lb==std::string::npos) && (rb==std::string::npos) ) {
    aName = a_string;
    aArgs.clear();
    return true;
  } else if( (lb==std::string::npos) && (rb!=std::string::npos) ) {
    aName = "";
    aArgs.clear();
    return false;
  } else if( (lb!=std::string::npos) && (rb==std::string::npos) ) {
    aName = "";
    aArgs.clear();
    return false;
  } else if(lb>=rb) {
    aName = "";
    aArgs.clear();
    return false;
  }
  std::string s = a_string.substr(lb+1,rb-lb-1);
  inlib::words(s,",",true,aArgs);
  aName = a_string.substr(0,lb);
  return true; 
}
std::string inlib::nosuffix ( const std::string &  a_string,
bool  a_back = true 
) [inline]

Definition at line 20 of file path.

                                                                       {
  // If a_string = dir0/dir1/dir2/dir3/name.xxx
  //   return name
  // Start searching after the last / (or last \ for Windows).
  std::string::size_type pos = a_string.rfind('/');
  if(pos==std::string::npos) pos = a_string.rfind('\\');
  if(pos==std::string::npos) pos = 0;
  else pos++;
  std::string s = a_string.substr(pos,a_string.size()-pos);
  std::string::size_type dot_pos = a_back?s.rfind('.'):s.find('.');
  if(dot_pos==std::string::npos) return s;
  return s.substr(0,dot_pos);
}
unsigned int inlib::numchar ( const std::string &  a_string,
char  a_c 
) [inline]

Definition at line 81 of file smanip.

                                                               {
  unsigned int num = 0;  
  std::string::const_iterator it;
  for(it=a_string.begin();it!=a_string.end();++it) {
    if((*it)==a_c) num++;
  }
  return num;
}
vec2f inlib::operator* ( float  a_f,
const vec2f &  a_v 
) [inline]

Definition at line 99 of file vec2f.

                                                   {
  vec2f res(a_v);
  res *= a_f;
  return res;
}
vec3d inlib::operator* ( double  a_f,
const vec3d &  a_v 
) [inline]

Definition at line 117 of file vec3d.

                                                    {
  vec3d res(a_v);
  res *= a_f;
  return res;
}
vec3f inlib::operator* ( float  a_f,
const vec3f &  a_v 
) [inline]

Definition at line 117 of file vec3f.

                                                   {
  vec3f res(a_v);
  res *= a_f;
  return res;
}
template<class T >
sqm<T> inlib::operator* ( const sqm< T > &  a1,
const sqm< T > &  a2 
) [inline]

Definition at line 366 of file sqm.

                                                           {
  sqm<T> res(a1.order());
  a1.mx_mul(a2,res);
  return res;
}
template<class T >
sqm<T> inlib::operator+ ( const sqm< T > &  a1,
const sqm< T > &  a2 
) [inline]

Definition at line 360 of file sqm.

                                                           {
  sqm<T> res(a1);
  res.add(a2);
  return res;
}
template<class T >
sqm<T> inlib::operator- ( const sqm< T > &  a1,
const sqm< T > &  a2 
) [inline]

Definition at line 354 of file sqm.

                                                           {
  sqm<T> res(a1);
  res.subtract(a2);
  return res;
}
std::ostream& inlib::operator<< ( std::ostream &  a_out,
const vecs &   
) [inline]

Definition at line 31 of file vecs.

                                                             {
  //for mf_vec::dump.
  return a_out;
}
std::ostream& inlib::operator<< ( std::ostream &  a_out,
const vec2f &  a_this 
) [inline]

Definition at line 105 of file vec2f.

                                                                    {
  a_out << "x = " << a_this[0]
        << ",y = " << a_this[1]
        << std::endl;
  return a_out;
}
std::ostream& inlib::operator<< ( std::ostream &  a_out,
const vec3f &  a_this 
) [inline]

Definition at line 123 of file vec3f.

                                                                    {
  a_out << "x = " << a_this[0]
        << ",y = " << a_this[1]
        << ",z = " << a_this[2]
        << std::endl;
  return a_out;
}
std::ostream& inlib::operator<< ( std::ostream &  a_out,
const colorf &  a_this 
) [inline]

Definition at line 303 of file colorf.

                                                                     {
  a_out << "r = " << a_this[0]
        << ",g = " << a_this[1]
        << ",b = " << a_this[2]
        << std::endl;
  return a_out;
}
std::ostream& inlib::operator<< ( std::ostream &  a_out,
const mat4f &   
) [inline]

Definition at line 305 of file mat4f.

                                                             {
  //a_out << "x = " << a_this[0]
  //      << ",y = " << a_this[1]
  //      << ",z = " << a_this[2]
  //      << std::endl;
  return a_out;
}
const char* inlib::os ( ) [inline]

Definition at line 12 of file os.

                        {

#if defined(__APPLE__)

#include <TargetConditionals.h>
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR || TARGET_OS_EMBEDDED
  static const char s[] = "iPhone";
#else
  static const char s[] = "Darwin";
#endif

#elif defined(_WIN32)
  static const char s[] = "Windows_NT";
#elif defined(__linux)
  static const char s[] = "Linux";
#elif defined(__alpha)
  static const char s[] = "OSF1";
#elif defined(__CYGWIN__)
  static const char s[] = "CYGWIN";
#else
  static const char s[] = "unknown";
#endif
  return s;
}
void inlib::out ( std::ostream &  a_out,
const std::vector< std::string > &  a_vec 
) [inline]

Definition at line 13 of file out.

                                                                     {
  std::vector<std::string>::const_iterator it;
  for(it=a_vec.begin();it!=a_vec.end();++it) {
    a_out << *it << std::endl;
  }
}
std::string inlib::p2s ( void *  a_value) [inline]

Definition at line 30 of file pointer.

                                   {
  char s[512];
#ifdef WIN32
  _snprintf(s,sizeof(s),"%lu",(unsigned long)a_value);
#else
  ::snprintf(s,sizeof(s),"%lu",(unsigned long)a_value);
#endif
  return s;
}
std::string inlib::p2sx ( void *  a_value) [inline]

Definition at line 40 of file pointer.

                                    {
  char s[512];
#ifdef WIN32
  _snprintf(s,sizeof(s),"0x%lx",(unsigned long)a_value);
#else
  ::snprintf(s,sizeof(s),"0x%lx",(unsigned long)a_value);
#endif
  return s;
}
bool inlib::parse_array ( const std::string &  a_string,
std::string &  aName,
int &  aIndex 
) [inline]

Definition at line 101 of file parse.

                                                                               {
  // Look if aName is of the form <string>(<integer>)
  // return true if <string>(<integer>)
  // return true if <string>. aName = <string> and aIndex = NotFound (-1).
  // return false if bad syntax or <integer> not an integer.
  std::string::size_type lb = a_string.find('(');
  std::string::size_type rb = a_string.rfind(')');
  if( (lb==std::string::npos) && (rb==std::string::npos) ) {
    aName = a_string;
    aIndex = (-1);
    return true;
  } else if( (lb==std::string::npos) && (rb!=std::string::npos) ) {
    aName = "";
    aIndex = 0;
    return false;
  } else if( (lb!=std::string::npos) && (rb==std::string::npos) ) {
    aName = "";
    aIndex = 0;
    return false;
  } else if(lb>=rb) {
    aName = "";
    aIndex = 0;
    return false;
  }
  //012345678
  //Slash::Core::ILibraryManager(123)
  std::string s = a_string.substr(lb+1,rb-lb-1);
  if(!inlib::to<int>(s,aIndex)) {
    aName = "";
    aIndex = 0;
    return false;
  }
  aName = a_string.substr(0,lb);
  return true; 
}
bool inlib::path_name_suffix ( const std::string &  a_string,
std::string &  a_path,
std::string &  a_name,
std::string &  a_suffix 
) [inline]

Definition at line 69 of file path.

 {
  // If a_string = dir0/dir1/dir2/dir3/name.xxx
  //   a_path = dir0/dir1/dir2/dir3
  //   a_name = name.xxx
  //   a_suffix = xxx
  // If a_string = dir0/name.xxx
  //   a_path = dir0
  //   a_name = name.xxx
  //   a_suffix = xxx
  // If a_string = name.xxx
  //   a_path.clear()
  //   a_name = name.xxx
  //   a_suffix = xxx
  // If a_string = /name.xxx
  //   a_path = "/"
  //   a_name = name.xxx
  //   a_suffix = xxx
  // If a_string = .
  //   a_path = "."
  //   a_name.clear()
  //   a_suffix.clear()
  // If a_string = ..
  //   a_path = ".."
  //   a_name.clear()
  //   a_suffix.clear()
  if(a_string==".") {
    a_path = ".";
    a_name.clear();
    a_suffix.clear();
    return true;
  } else if(a_string=="..") {
    a_path = "..";
    a_name.clear();
    a_suffix.clear();
    return true;
  }

  std::string::size_type pos_slash = a_string.rfind('/');
  std::string::size_type pos_bslash = a_string.rfind('\\');
  std::string::size_type pos = 0;
  if(pos_slash==std::string::npos) {
    if(pos_bslash==std::string::npos) {
      pos = std::string::npos;
    } else {
      pos = pos_bslash;
    }
  } else {
    if(pos_bslash==std::string::npos) {
      pos = pos_slash;
    } else {
      if(pos_slash<=pos_bslash) {
        pos = pos_bslash;
      } else {
        pos = pos_slash;
      }
    }
  }

  if(pos==std::string::npos) {
    a_path.clear();
    pos = 0;
  } else if(pos==0) {
    a_path = "/";
    pos++;
  } else {
    a_path = a_string.substr(0,pos);
    pos++;
  }
  std::string s = a_string.substr(pos,a_string.size()-pos);
  pos = s.rfind('.');
  if(pos==std::string::npos) {
    a_name = s;
    a_suffix.clear();
  } else {
    a_name = s;
    pos++;
    a_suffix = s.substr(pos,s.size()-pos);
  }
  return true;
}
std::vector<std::string> inlib::path_words ( const std::string &  a_path,
bool &  a_absolute,
bool &  a_win_path,
std::string &  a_drive 
) [inline]

Definition at line 96 of file smanip.

                                                                                                                    {

  //  a_path could be at the Windows syntax : <drive>:\dir1\dir2...
  // If so, only dir1, dirn are put in a_words.

  std::string path = a_path;
  std::string::size_type pos = path.find('\\');
  a_win_path = (pos==std::string::npos?false:true);
  if(a_win_path) {
    replace(path,"\\","/");
    pos = path.find(':');
    if(pos!=std::string::npos) { //drive 
      a_drive = path.substr(0,pos);
      path = path.substr(pos+1,path.size()-(pos+1));
    } else {
      a_drive = "";
    }
  } else {
    a_drive = "";
  }

  a_absolute = (path.size()&&(path[0]=='/')?true:false);

  return words(path,"/");
}
double inlib::pi ( ) [inline]

Definition at line 17 of file math.

{return 3.1415926535897931160E0;}
std::string inlib::plugin_name ( const std::string &  a_name) [inline]

Definition at line 176 of file system.

                                                     {
#if defined(WIN32)
  return a_name + ".dll";
#elif defined(__CYGWIN__) && defined(__GNUC__)
  return a_name + ".dll";
#elif defined(__APPLE__)
  return a_name + ".bundle";
#else
  return std::string("lib") + a_name + ".so";
#endif
}
std::string inlib::plugin_prefix ( ) [inline]

Definition at line 152 of file system.

                                {
#if defined(WIN32)
  return "";
#elif defined(__APPLE__)
  return "";
#elif defined(__CYGWIN__) && defined(__GNUC__)
  return "";
#else //UNIX
  return "lib";
#endif
}
std::string inlib::plugin_suffix ( ) [inline]

Definition at line 164 of file system.

                                {
#if defined(WIN32)
  return "dll";
#elif defined(__APPLE__)
  return "bundle";
#elif defined(__CYGWIN__) && defined(__GNUC__)
  return "dll";
#else //UNIX
  return "so";
#endif
}
bool inlib::polynomial_degree ( const std::string &  a_string,
int &  a_degree 
) [inline]

Definition at line 364 of file smanip.

                                                                      {
  // a_string = [p,P,Polynomial]<integer degree>
  // We extract <degree> from the upper.
  // The degree is the maximum "x" power.
  // For example P1 is ax+b which of degree 1.
  // For example P2 is ax*x+bx+c which of degree 2.
  std::string s = a_string;
  tolowercase(s);
  replace(s,"polynomial","p");
  a_degree = 0;
  if(s.size()<=0) return false;
  if(s[0]!='p') return false;
  int number = 0;
  if(!to<int>(s.substr(1,s.size()-1),number)) return false;
  a_degree = number;
  return true;
}
template<class T >
T inlib::power ( const T &  a_A,
unsigned int  a_B 
) [inline]

Definition at line 22 of file math.

                                             {
  T v = 1;
  for(unsigned int i=0;i<a_B;i++) v *= a_A; 
  return v;
}
const char* inlib::processor ( ) [inline]

Definition at line 37 of file os.

                               {

#if defined(__GNUC__)

#if defined(__ppc__)
  static const char s[] = "ppc";
#elif defined(__ppc64__)
  static const char s[] = "ppc64";
#elif defined(__i386__)
  static const char s[] = "i386";
#elif defined(__x86_64__)
  static const char s[] = "x86_64";
#elif defined(__ia64__)
  static const char s[] = "ia64";
#else
  static const char s[] = "unknown";
#endif

#elif defined(_MSC_VER)

#if defined(_M_IX86)
  static const char s[] = "ix86";
#elif defined(_M_X64)
  static const char s[] = "x64";
#else
  static const char s[] = "unknown";
#endif

#elif defined(__alpha)
  static const char s[] = "alpha";

#else
  static const char s[] = "unknown";
#endif
  return s;
}
bool inlib::program_path ( const std::string &  a_arg0,
std::string &  a_path 
) [inline]

Definition at line 25 of file app.

                                                                    {
  if(a_arg0.empty()) {
    a_path = "";
    return false;
  }
  std::string path,name,suffix;
  path_name_suffix(a_arg0,path,name,suffix);
  if(path.empty()) {
    std::string PATH;
    if(inlib::getenv("PATH",PATH)) {
      std::string program = a_arg0;
#if defined(WIN32) || (defined(__CYGWIN__) && defined(__GNUC__))
      if(program.find(".exe")==std::string::npos) program += ".exe";
#endif
      std::vector<std::string> paths = words(PATH,psep());
      std::vector<std::string>::iterator it;
      for(it=paths.begin();it!=paths.end();++it) {
        std::string dir = *it;
        if(file::exists(dir+sep()+program)) {
          path = dir;
          break;
        }
      }
    }
  }
  if(path.empty()) {
    a_path = "";
    return false;
  }
  if(!is_absolute_path(path)) {
    std::string pwd;
    if(!dir::pwd(pwd)) {
      a_path = "";
      return false;
    }
    path = pwd+sep()+path;
  }
  //printf("debug : path : %s\n",path.c_str());
  a_path = path;
  return true;
}
std::string inlib::psep ( ) [inline]

Definition at line 19 of file sep.

                       {
#ifdef WIN32
  return ";";
#else
  return ":";
#endif
}
bool inlib::putenv ( const std::string &  a_env,
const std::string &  a_value 
) [inline]

Definition at line 43 of file system.

                                                                   {
  std::string value = a_env+"="+a_value;
  if(::putenv(inlib::str_dup(value.c_str()))) return false;
  //check:
  std::string s;
  if(!getenv(a_env,s)) return false;
  if(s!=a_value) return false;
  return true;
}
bool inlib::rcmp ( const std::string &  a_1,
const std::string &  a_2 
) [inline]

Definition at line 13 of file rcmp.

                                                            {
  std::string::size_type l1 = a_1.size();
  std::string::size_type l2 = a_2.size();
  if(l1!=l2) return false;
  if(!l1) return true;
  const char* p1 = a_1.c_str()+l1-1;
  const char* p2 = a_2.c_str()+l2-1;
  //ab
  //012
  for(std::string::size_type index=0;index<l1;index++,p1--,p2--) {
    if(*p1!=*p2) return false;
  }
  return true;
}
template<class T >
unsigned int inlib::read_buffer ( const char *  a_buffer,
T &  a_value 
) [inline]

Definition at line 28 of file buffer.

                                                                 {
  size_t n = sizeof(T);
  //NOTE : a_buffer must be allocated to n.
  if(is_little_endian()) {
    ::memcpy(&a_value,a_buffer,n);
  } else {
    char* pos = (char*)&a_value;
    for(unsigned int i=0;i<n;i++,pos++) *pos = a_buffer[n-1-i];
  }
  return n;
}
bool inlib::read_doubles ( const std::string &  a_file,
std::vector< double > &  a_vals 
) [inline]

Definition at line 255 of file parse.

                                                                           {
  a_vals.clear();
  FILE* file = ::fopen(a_file.c_str(),"rb");
  if(!file) return false;
  unsigned int BUFSIZE = 65536;
  char* buffer = new char[BUFSIZE+1];
  if(!buffer) {::fclose(file);return false;}
  std::string sep = " ";
  while(true) {
    size_t l;
    if(!file::read_cstring(file,buffer,BUFSIZE,l)) break; // EOF.
    std::string sbuffer = buffer; //can we avoid this copy ?
    std::vector<double> ds;
    if(!inlib::to_doubles(sbuffer,ds,sep)) {
      a_vals.clear();
      delete [] buffer;
      ::fclose(file);
      return false;
    }
    inlib::append<double>(a_vals,ds);
  }
  delete [] buffer;
  ::fclose(file);
  return true;
}
template<class T >
bool inlib::realloc ( T *&  a_pointer,
uint32  a_new_size,
uint32  a_old_size,
bool  a_init = false 
) [inline]

Definition at line 11 of file realloc.

                                                                                           {
  if(!a_new_size) { 
    delete [] a_pointer; 
    a_pointer = 0;
    return true;
  }
  if(!a_pointer) {
    a_pointer = new T[a_new_size];
    return true;
  }
  if(a_old_size==a_new_size) return true;
  T* pointer = new T[a_new_size];
  if(!pointer) {
    delete [] a_pointer; 
    a_pointer = 0;
    return false;
  }
  if(a_new_size>a_old_size) {
    ::memcpy(pointer,a_pointer,a_old_size*sizeof(T));
    if(a_init){
      uint32 num = a_new_size-a_old_size;   
      T* pos = pointer+a_old_size;
      for(uint32 i=0;i<num;i++,pos++) *pos = T();
    }
  } else {
    ::memcpy(pointer,a_pointer,a_new_size*sizeof(T));
  }
  delete [] a_pointer;
  a_pointer = pointer;
  return true;
}
bool inlib::remove ( std::vector< std::string > &  a_strings,
const std::string &  a_string 
) [inline]

Definition at line 122 of file smanip.

                                                                             {
  bool found_some = false;
  //std::vector<std::string>::iterator it;
  //for(it=a_strings.begin();it!=a_strings.end();) {
  //  if(*it==a_string) {
  //    it = a_strings.erase(it);
  //    found_some = true;
  //  } else {
  //    ++it;
  //  }
  //}
  //brut force avoiding erase(). For Android + inlib/stl.
  std::vector<std::string> ss;
  std::vector<std::string>::iterator it;
  for(it=a_strings.begin();it!=a_strings.end();++it) {
    if(*it==a_string) {
      found_some = true;
    } else {
      ss.push_back(*it);
    }
  }
  a_strings = ss;
  return found_some;
}
std::string inlib::remove_version ( const std::string &  a_string) [inline]

Definition at line 345 of file smanip.

                                                           {
  // replace "@@top@@/pack/vers" -> "@@top@@/pack".
  std::string sold = a_string;
  replace(sold,"\"",sep()+"@quote@"); //To treat AIDA/v3r2p1"/src
  std::vector<std::string> words = inlib::words(sold,sep());
  unsigned int wordn = words.size();
  std::string snew;
  for(unsigned int index=0;index<wordn;index++) {
    std::vector<unsigned int> vers;
    std::string word = words[index];
    if(!version(word,vers)) {
      if(snew.size()) snew += sep();
      snew += words[index];
    }
  }
  replace(snew,sep()+"@quote@","\"");
  return snew;
}
bool inlib::replace ( std::string &  a_string,
const std::string &  a_old,
const std::string &  a_new 
) [inline]

Definition at line 12 of file srep.

                                                                                      {
  // return true : some replacement done.
  // return false : nothing replaced.
  if(a_old.empty()) return false;
  std::string snew;
  std::string::size_type lold = a_old.length();
  bool status = false;
  std::string stmp = a_string;
  while(true) {
    std::string::size_type pos = stmp.find(a_old);
    if(pos==std::string::npos){
      snew += stmp;
      break;
    } else {
      snew += stmp.substr(0,pos);
      snew += a_new;
      stmp = stmp.substr(pos+lold,stmp.length()-(pos+lold));
      status = true;
    }
  }
  a_string = snew;
  return status;
}
bool inlib::replace ( std::vector< std::string > &  a_strings,
const std::string &  a_old,
const std::string &  a_new 
) [inline]

Definition at line 36 of file srep.

                                                                                                  {
  std::vector<std::string>::iterator it;
  for(it=a_strings.begin();it!=a_strings.end();++it) {
    if(!replace(*it,a_old,a_new)) return false;
  }
  return true;
}
void inlib::replace ( std::string &  a_string,
char  a_old,
char  a_new 
) [inline]

Definition at line 90 of file smanip.

                                                              {
  for(std::string::iterator it=a_string.begin();it!=a_string.end();++it) {
    if((*it)==a_old) *it = a_new;
  }
}
void inlib::rgb2hsv ( int  r,
int  g,
int  b,
int &  h,
int &  s,
int &  v 
) [inline]

Definition at line 22 of file colormanip.

                                                                {

  unsigned int mx = r;                          // mximum RGB component
  int whatmx = 0;                               // r=>0, g=>1, b=>2
  if ( (unsigned int)g > mx ) {
    mx = g;
    whatmx = 1;
  }
  if ( (unsigned int)b > mx ) {
    mx = b;
    whatmx = 2;
  }
  unsigned int mn = r;                          // find mnimum value
  if ( (unsigned int)g < mn ) mn = g;
  if ( (unsigned int)b < mn ) mn = b;
  int delta = mx-mn;
  v = mx;                                       // calc value
  s = mx ? (510*delta+mx)/(2*mx) : 0;
  if ( s == 0 ) {
    h = -1;                             // undefined hue
  } else {
    switch ( whatmx ) {
    case 0:                             // red is mx component
      if ( g >= b )
        h = (120*(g-b)+delta)/(2*delta);
      else
        h = (120*(g-b+delta)+delta)/(2*delta) + 300;
      break;
    case 1:                             // green is mx component
      if ( b > r )
        h = 120 + (120*(b-r)+delta)/(2*delta);
      else
        h = 60 + (120*(b-r+delta)+delta)/(2*delta);
      break;
    case 2:                             // blue is mx component
      if ( r > g )
        h = 240 + (120*(r-g)+delta)/(2*delta);
      else
        h = 180 + (120*(r-g+delta)+delta)/(2*delta);
      break;
    }
  }
}
bool inlib::rmenv ( const std::string &  a_env) [inline]

Definition at line 53 of file system.

                                         {
#ifdef WIN32
  std::string value = a_env+"=";
  if(::putenv(inlib::str_dup(value.c_str()))) return false;
#else
  ::unsetenv(a_env.c_str());
#endif
  return true;
}
int64 inlib::s2int64 ( const char *  a_s,
char **  a_end,
int  a_base 
) [inline]

Definition at line 39 of file s2int64.

                                                             {
  return ::strtoll(a_s,a_end,a_base);
}
bool inlib::s2time ( const std::string &  a_string,
time_t &  a_time 
) [inline]

Definition at line 13 of file s2time.

                                                             {
  int yy, mm, dd, hh, mi, ss;
  if(::sscanf(a_string.c_str(),
              "%d-%d-%d %d:%d:%d",
              &yy,&mm,&dd,&hh,&mi,&ss)!=6) {a_time = 0;return false;}
  struct tm tp;
  tp.tm_year  = yy-1900;
  tp.tm_mon   = mm-1;
  tp.tm_mday  = dd;
  tp.tm_hour  = hh;
  tp.tm_min   = mi;
  tp.tm_sec   = ss;
  tp.tm_isdst = 0;
  a_time  = ::mktime(&tp);
  return true;
}
const std::string& inlib::s_aida_type ( char  ) [inline]

for waxml : /////////////////////////

Definition at line 22 of file saida.

                                          {
  static const std::string s_v("char");
  return s_v;
}
const std::string& inlib::s_aida_type ( short  ) [inline]

Definition at line 26 of file saida.

                                           {
  static const std::string s_v("short");
  return s_v;
}
const std::string& inlib::s_aida_type ( int  ) [inline]

Definition at line 30 of file saida.

                                         {
  static const std::string s_v("int");
  return s_v;
}
const std::string& inlib::s_aida_type ( float  ) [inline]

Definition at line 34 of file saida.

                                           {
  static const std::string s_v("float");
  return s_v;
}
const std::string& inlib::s_aida_type ( double  ) [inline]

Definition at line 38 of file saida.

                                            {
  static const std::string s_v("double");
  return s_v;
}
const std::string & inlib::s_aida_type ( unsigned  char) [inline]

not AIDA ! //////////////////////////

Definition at line 45 of file saida.

                                                   {
  static const std::string s_v("byte");
  return s_v;
}
const std::string& inlib::s_aida_type ( bool  ) [inline]

Definition at line 50 of file saida.

                                          {
  static const std::string s_v("boolean");
  return s_v;
}
const std::string& inlib::s_aida_type ( const std::string &  ) [inline]

Definition at line 54 of file saida.

                                                      {
  static const std::string s_v("string");
  return s_v;
}
const std::string& inlib::s_aida_type ( int64  ) [inline]

Definition at line 58 of file saida.

                                           {
  static const std::string s_v("long");
  return s_v;
}
const std::string& inlib::s_aida_type ( const std::vector< double > &  ) [inline]

Definition at line 62 of file saida.

                                                              {
  static const std::string s_v("double[]");
  return s_v;
}
const std::string& inlib::s_aida_type ( uint64  ) [inline]

Definition at line 83 of file saida.

                                            {
  static const std::string s_v("ulong");
  return s_v;
}
const std::string& inlib::s_aida_type_ituple ( ) [inline]

Definition at line 67 of file saida.

                                             {
  static const std::string s_v("ITuple");
  return s_v;
}
std::string inlib::sep ( ) [inline]

Definition at line 11 of file sep.

                       {
#ifdef WIN32
  return "\\";
#else
  return "/";
#endif
}
std::string inlib::sjust ( const std::string &  a_string,
unsigned int  a_size,
side  a_side = left 
) [inline]

Definition at line 40 of file sjust.

                                            {
  std::string s(a_string); 
  justify(s,a_size,a_side);
  return s;
}
template<class T >
std::string inlib::sjust ( a_value,
unsigned int  a_size,
side  a_side = left 
) [inline]

Definition at line 49 of file sjust.

                                                                         {
  std::string s = to<T>(a_value);
  justify(s,a_size,a_side);
  return s;
}
void inlib::sleep_milli_secs ( unsigned int  a_milli_sec) [inline]

Definition at line 23 of file sleep.

                                                      {
#ifdef WIN32
  ::Sleep(a_milli_sec);
#else
  ::usleep(a_milli_sec*1000); //it is in micro seconds.
#endif
}
void inlib::sleep_secs ( unsigned int  a_secs) [inline]

Definition at line 15 of file sleep.

                                           {
#ifdef WIN32
  ::Sleep(a_secs*1000);
#else
  ::sleep(a_secs);
#endif
}
std::string inlib::so_name ( const std::string &  a_name) [inline]

Definition at line 188 of file system.

                                                 {
#if defined(WIN32)
  return a_name + ".dll";
#elif defined(__CYGWIN__) && defined(__GNUC__)
  return a_name + ".dll";
#elif defined(__APPLE__)
  return "lib" + a_name + ".dylib";
#else
  return std::string("lib") + a_name + ".so";
#endif
}
std::string inlib::sout ( const std::string &  a_string) [inline]

Definition at line 11 of file sout.

                                                 {
  return std::string("\"")+a_string+"\"";
}
template<class T >
std::string inlib::sout ( const T &  a_value) [inline]

Definition at line 71 of file sto.

                                        {
  return std::string("\"")+to<T>(a_value)+"\"";
}
std::string inlib::soutd ( double  a_value) [inline]

Definition at line 65 of file sto.

                                       {
  return std::string("\"")+d2s(a_value)+"\"";
}
bool inlib::sprintf ( std::string &  a_string,
int  a_length,
const char *  a_format,
  ... 
) [inline]

Definition at line 13 of file sprintf.

                                                                              {
  a_string.clear();
  if(a_length<0) return false;
  if(!a_format) return false;
  char* s = new char[a_length+1];
  if(!s) return false;
  s[a_length] = '\0';
  va_list args;
  va_start(args,a_format);
#ifdef WIN32
  int n = _vsnprintf(s,a_length+1,a_format,args);
#else
  int n = ::vsnprintf(s,a_length+1,a_format,args);
#endif
  va_end(args);
  if(n>a_length) {
    delete [] s;
    return false;
  }
  if(s[a_length]!='\0') {
    delete [] s;
    return false;
  }
  a_string = s;
  delete [] s;
  return true;
}
template<class T >
void inlib::steps ( std::vector< T > &  a_vec,
unsigned int  a_number 
) [inline]

Definition at line 111 of file vmanip.

                                                            {
  a_vec.resize(a_number);
  for(unsigned int index=0;index<a_number;index++) a_vec[index] = T(index);
}
bool inlib::str_cat ( char *&  a_1,
const char  a_c 
) [inline]

Definition at line 34 of file cstr.

                                               {
  size_t l1 = ::strlen(a_1);
  char* s = (char*)::malloc(l1+1+1);
  if(!s) return false;
  ::memcpy(s,a_1,l1);
  ::memcpy(s+l1,&a_c,1);
  *(s+l1+1) = 0;
  ::free(a_1);
  a_1 = s;
  return true;
}
bool inlib::str_cat ( char *&  a_1,
const char *  a_2 
) [inline]

Definition at line 46 of file cstr.

                                                {
  size_t l1 = ::strlen(a_1);
  size_t l2 = ::strlen(a_2);
  char* s = (char*)::malloc(l1+l2+1);
  if(!s) return false;
  ::memcpy(s,a_1,l1);
  ::memcpy(s+l1,a_2,l2);
  *(s+l1+l2) = 0;
  ::free(a_1);
  a_1 = s;
  return true;
}
void inlib::str_del ( char *&  a_cstr) [inline]

Definition at line 19 of file cstr.

                                   {
  if(a_cstr==NULL) return;
  ::free(a_cstr);
  a_cstr = NULL;
}
char* inlib::str_dup ( const char *  a_cstr) [inline]

Definition at line 15 of file cstr.

                                         {
  return ::strcpy((char*)::malloc(::strlen(a_cstr)+1),a_cstr);
}
char* inlib::str_new ( size_t  a_l = 0,
char  a_char = ' ' 
) [inline]

Definition at line 25 of file cstr.

                                                       {
  char* s = (char*)::malloc((a_l+1)*sizeof(char));
  if(s==NULL) return NULL;
  char* pos = s; 
  for(size_t c=0;c<a_l;c++,pos++) *pos = a_char;
  *(s+a_l) = 0;
  return s;
}
char* inlib::str_rep ( const char *  a_s,
unsigned int  a_pos,
unsigned int  a_sz,
const char *  a_new 
) [inline]

Definition at line 92 of file cstr.

                                                                                             {
  //not tested yet.
  size_t las = ::strlen(a_s);
  if(a_pos>=las) return 0; //throw std::out_of_range
  if(a_pos+a_sz>las) return 0;
  size_t lan = ::strlen(a_new);
  unsigned int num = a_sz<lan?a_sz:lan;
  //abcdefghij : l = 10
  //0123456789
  //   p  
  size_t le = las-(a_pos+a_sz);
  size_t ls = a_pos+num+le;
  char* s = (char*)::malloc(ls+1);
  if(!s) return 0;
  ::memcpy(s,a_s,a_pos);
  ::memcpy(s+a_pos,a_new,num);
  if(le) ::memcpy(s+a_pos+num,a_s+a_pos+a_sz,le);
  *(s+ls) = 0;
  return s;
}
void inlib::str_rev ( char *  a_s) [inline]

Definition at line 59 of file cstr.

                               {
  size_t l = ::strlen(a_s);
  size_t hl = l/2;
  char* beg = a_s;
  char* end = a_s+l-1;
  for(size_t i=0;i<hl;i++) {
    char c = *end;
    *end = *beg;      
    *beg = c;
    beg++;end--;  
  }
}
char* inlib::str_sub ( const char *  a_s,
unsigned int  a_pos,
unsigned int  a_sz = 0 
) [inline]

Definition at line 72 of file cstr.

                                            { //0 = take up end.
  size_t l = ::strlen(a_s);
  if(a_pos>=l) return 0; //throw std::out_of_range
  size_t ls;
  if(a_sz) {
    ls = (a_sz<(l-a_pos)?a_sz:(l-a_pos)); //min(a_sz,l-a_pos)
  } else {
    ls = l-a_pos;
  }
  char* s = (char*)::malloc(ls+1);
  if(!s) return 0;
  //abcdefgh  l=8
  //0123456789
  ::memcpy(s,a_s+a_pos,ls);
  *(s+ls) = 0;
  return s;
}
void inlib::strip ( std::string &  a_string,
what  a_type = both,
char  a_char = ' ' 
) [inline]

Definition at line 14 of file strip.

                                                                           {
  std::string::size_type l = a_string.length();
  if(l==0) return;

  switch ( a_type ) {
  case leading:{
    std::string::size_type i;
    char* pos = (char*)a_string.c_str();
    for(i=0;i<l;i++,pos++) {
      if(*pos!=a_char) {
        a_string = a_string.substr(i,l-i);
        return;
      }
    }
    }break;
  case trailing:{
    std::string::size_type i;
    char* pos = (char*)a_string.c_str();
    pos += (l-1);
    for(i=l-1;;i--,pos--) {
      if(*pos!=a_char) {
        a_string = a_string.substr(0,i+1);
        return;
      }
    }
    }break;
  case both:
    strip(a_string,leading,a_char);
    strip(a_string,trailing,a_char);
    break;
  //default:break;
  }
}
void inlib::strip ( std::vector< std::string > &  a_strings,
what  a_type = both,
char  a_char = ' ' 
) [inline]

Definition at line 54 of file strip.

                                                                                        {
  std::vector<std::string>::iterator it;
  for(it=a_strings.begin();it!=a_strings.end();++it) {
    strip(*it,a_type,a_char);
  }
}
std::string inlib::strp ( const std::string &  a_string,
what  a_type = both,
char  a_char = ' ' 
) [inline]

Definition at line 48 of file strip.

                                                                                     {
  std::string s(a_string);
  strip(s,a_type,a_char);
  return s;
}
const std::string & inlib::stype ( unsigned  char) [inline]

Definition at line 15 of file stype.

                                             {
  static const std::string s_v("unsigned char");
  return s_v;
}
const std::string& inlib::stype ( char  ) [inline]

Definition at line 20 of file stype.

                                    {
  static const std::string s_v("char");
  return s_v;
}
const std::string& inlib::stype ( short  ) [inline]

Definition at line 30 of file stype.

                                     {
  static const std::string s_v("short");
  return s_v;
}
const std::string& inlib::stype ( int  ) [inline]

Definition at line 35 of file stype.

                                   {
  static const std::string s_v("int");
  return s_v;
}
const std::string& inlib::stype ( float  ) [inline]

Definition at line 45 of file stype.

                                     {
  static const std::string s_v("float");
  return s_v;
}
const std::string& inlib::stype ( double  ) [inline]

Definition at line 50 of file stype.

                                      {
  static const std::string s_v("double");
  return s_v;
}
const std::string& inlib::stype ( int64  ) [inline]

Definition at line 56 of file stype.

                                     {
  static const std::string s_v("inlib::int64");
  return s_v;
}
const std::string& inlib::stype ( uint64  ) [inline]

Definition at line 60 of file stype.

                                      {
  static const std::string s_v("inlib::uint64");
  return s_v;
}
const std::string& inlib::stype ( const std::string &  ) [inline]

Definition at line 64 of file stype.

                                                {
  static const std::string s_v("std::string");
  return s_v;
}
template<class T >
bool inlib::sub ( std::vector< T > &  a_vec,
const std::vector< T > &  a_v 
) [inline]

Definition at line 128 of file vmanip.

                                                            {
  if(a_vec.size()!=a_v.size()) return false;
  typedef typename std::vector<T>::iterator it_t;
  typedef typename std::vector<T>::const_iterator cit_t;
  it_t it = a_vec.begin();
  cit_t vit = a_v.begin();
  for(;it!=a_vec.end();++it,++vit) *it -= *vit;
  return true;
}
template<class T >
void inlib::sub ( std::vector< T > &  a_vec,
const T &  a_v 
) [inline]

Definition at line 163 of file vmanip.

                                                 {
  typedef typename std::vector<T>::iterator it_t;
  for(it_t it=a_vec.begin();it!=a_vec.end();++it) *it -= a_v;
}
std::string inlib::suffix ( const std::string &  a_string,
bool  a_back = true 
) [inline]

Definition at line 11 of file path.

                                                                      {
  // If a_string = dir0/dir1/dir2/dir3/name.xxx
  //   return xxx
  std::string::size_type pos = a_back?a_string.rfind('.'):a_string.find('.');
  if(pos==std::string::npos) return "";
  pos++;
  return a_string.substr(pos,a_string.size()-pos);
}
template<class T >
T inlib::sum ( const std::vector< T > &  a_vec) [inline]

Definition at line 91 of file vmanip.

                                        {
  T sum = T();
  typedef typename std::vector<T>::const_iterator it_t;
  for(it_t it = a_vec.begin();it!=a_vec.end();++it) sum += *it;
  return sum;
}
template<class T >
bool inlib::swap ( const array< T > &  aV,
unsigned int  aI1,
unsigned int  aI2,
array< T > &  aR 
) [inline]

Definition at line 441 of file array.

 {
  if(&aR==&aV) return false;

  unsigned int dim = aV.dimension();
  if(aI1>=dim) return false;
  if(aI2>=dim) return false;

  if(aI1==aI2) {
    aR.copy(aV);
    return true;
  }

  if(!aR.configure(aV.orders())) return false;

  std::vector<unsigned int> vis(aV.dimension());
  std::vector<unsigned int> ris(aV.dimension());

  const std::vector<T>& vvec = aV.vector();

  unsigned int size = aV.size();
  for(unsigned int offset=0;offset<size;offset++) {
    T value = vvec[offset];

    if(!aV.indices(offset,vis)) return false;
    unsigned int i = vis[aI1]; 
    vis[aI1] = vis[aI2]; 
    vis[aI2] = i; 
    if(!aR.set_value(vis,value)) return false;
  }

  return true;
}
bool inlib::tmpname ( const std::string &  a_dir,
const std::string &  a_prefix,
const std::string &  a_suffix,
std::string &  a_name 
) [inline]

Definition at line 22 of file file.

                                                                                                                 {
  //  a_dir must finish with the system path separator.
  std::string head;
  if(a_dir==".") {
  } else if(a_dir.size()) {
    head += a_dir;
  } else {
#ifdef WIN32
    char* env = ::getenv("HOMEDRIVE");
    std::string drive = (env? env : std::string("C:"));
    head += drive;
    head += "\\";
#else
    head += "/tmp/";
#endif
  }
  head += a_prefix;
  char spid[128];
#ifdef WIN32
  _snprintf(spid,sizeof(spid),"%d",::getpid());
#else
  ::snprintf(spid,sizeof(spid),"%d",::getpid());
#endif
  head += spid;
  head += "_";

  for(int count=0;count<1000;count++) {
    //std::ostringstream strm; //because of Android which has no STL.
    //strm.fill('0');
    //strm.width(3);
    //strm << count;
    char s[32];
#ifdef WIN32
    _snprintf(s,sizeof(s),"%03d",count);
#else
    ::snprintf(s,sizeof(s),"%03d",count);
#endif
    std::string tmpnm = head;
    tmpnm += s;
    //tmpnm += strm.str();
    tmpnm += a_suffix;
    struct stat finfo;
    if(::stat(tmpnm.c_str(),&finfo) < 0) {
      // No directory or file found :
      a_name = tmpnm; // Good file name.
      return true; 
    }
  }
  // No good name found :
  a_name.clear();
  return false;
}
std::string inlib::to ( bool  a_value) [inline]

Definition at line 11 of file sto.

{return a_value?"true":"false";}
bool inlib::to ( const std::string &  a_string,
bool &  a_value 
) [inline]

Definition at line 13 of file sto.

                                                       {
  if(  (a_string=="1")
     ||(a_string=="true")||(a_string=="TRUE")||(a_string=="True")
     ||(a_string=="yes")||(a_string=="YES")||(a_string=="Yes")
     ||(a_string=="on")||(a_string=="ON")||(a_string=="On")
     ){
    a_value = true;
    return true;
  } else if((a_string=="0")
          ||(a_string=="false")||(a_string=="FALSE")||(a_string=="False")
          ||(a_string=="no")||(a_string=="NO")||(a_string=="No")
          ||(a_string=="off")||(a_string=="OFF")||(a_string=="Off")
          ){
    a_value = false;
    return true;
  } else {
    a_value = false;
    return false;
  }
}
template<class T >
bool inlib::to ( const std::string &  a_s,
T &  a_v 
) [inline]

Definition at line 41 of file sto.

                                            {
  std::istringstream strm(a_s.c_str());
  std::streampos pb = strm.tellg();
  strm >> a_v;
  std::streampos pe = strm.tellg();
  std::string::size_type sz = pe-pb;
  if(sz!=a_s.size()) {a_v = T();return false;}
  return true;
}
template<class T >
std::string inlib::to ( const T &  a_v) [inline]

Definition at line 52 of file sto.

                                  {
  std::ostringstream strm;
  strm << a_v;
  return strm.str();
}
std::vector<std::string> inlib::to ( int  a_argc,
char **  a_argv 
) [inline]

Definition at line 244 of file smanip.

                                                         {
  std::vector<std::string> v;
  for(int index=0;index<a_argc;index++) v.push_back(a_argv[index]);
  return v;
}
template<class T >
bool inlib::to ( std::ostream &  a_out,
const std::string &  a_string,
T &  a_value 
) [inline]

Definition at line 358 of file args.

                                                                      {
  if(!to<T>(a_string,a_value)) {
    a_out << "Passed value " << sout(a_string)
          << " is of bad type."
          << std::endl;
    return false;
  }
  return true;
}
bool inlib::to ( std::ostream &  a_out,
const std::string &  a_string,
bool &  a_value 
) [inline]

Definition at line 368 of file args.

                                                                         {
  if(!to(a_string,a_value)) {
    a_out << "Passed value " << sout(a_string)
          << " is not a boolean."
          << std::endl;
    return false;
  }
  return true;
}
template<class T >
sqm< std::complex<double> > inlib::to_complex ( const sqm< T > &  a_from) [inline]

Definition at line 29 of file sqmz.

                                                                  {
  unsigned int order = a_from.order();
  typedef std::complex<double> z;
  sqm<z> to(order);
  const std::vector<T>& fvec = a_from.vector();
  std::vector<z>& tvec = to.vector();
  typedef typename std::vector<T>::const_iterator const_vec_it_t;
  const_vec_it_t fit = fvec.begin();
  typedef typename std::vector<z>::iterator vec_it_t;
  vec_it_t tit = tvec.begin();
  for(;fit!=fvec.end();++fit,++tit) *tit = *fit;
  return to;
}
bool inlib::to_doubles ( const std::string &  a_string,
std::vector< double > &  a_values,
const std::string &  a_sep 
) [inline]

Definition at line 137 of file parse.

                                                                                                    {
  // Support PAW syntax : 3*2.4 is understood as three times 2.4.
  a_values.clear();
  std::vector<std::string> words;
  inlib::words(a_string,a_sep,false,words);
  bool seekMultiplier = (a_sep!="*"?true:false);
  if(!seekMultiplier) a_values.resize(words.size());
  int valuei = 0;
  std::vector<std::string> subwords;
  std::vector<std::string>::iterator it;
  for(it = words.begin();it!=words.end();++it) {
    if(seekMultiplier) {
      std::string::size_type pos = (*it).find('*');
      if(pos==std::string::npos){
        double value;
        if(!inlib::to<double>(*it,value)) {
          a_values.clear();
          return false;
        }
        a_values.push_back(value);
      } else {
        //3*2.4
        //01234
        std::string sn = (*it).substr(0,pos);
        std::string sv = (*it).substr(pos+1,a_string.size()-(pos+1));
        int multiplier;
        if(!inlib::to<int>(sn,multiplier)) {
          a_values.clear();
          return false;
        }
        double value;
        if(!inlib::to<double>(sv,value)) {
          a_values.clear();
          return false;
        }
        for(int index=0;index<multiplier;index++) a_values.push_back(value);
      }
    } else {
      double value;
      if(!inlib::to<double>(*it,value)) {
        a_values.clear();
        return false;
      }
      a_values[valuei] = value;
      valuei++;
    }    
  }
  return true;
}
bool inlib::to_pointer ( const std::string &  a_string,
void *&  a_value 
) [inline]

Definition at line 18 of file pointer.

                                                                {
  unsigned long v = 0L;
  if(::sscanf(a_string.c_str(),"0x%lx",&v)!=1) {
    if(::sscanf(a_string.c_str(),"%lu",&v)!=1) {
      a_value = 0;
      return false;
    }
  }
  a_value = (void*)v;
  return true;
}
bool inlib::to_rgb ( const std::string &  a_string,
double &  a_r,
double &  a_g,
double &  a_b 
) [inline]

Definition at line 14 of file scolor.

                                                                                 {
  a_r = 0.5;
  a_g = 0.5;
  a_b = 0.5;
  if(a_string.empty()) return false;
  std::vector<double> ds;
  if(values<double>(a_string," ",false,ds) && (ds.size()>=3)) {
    if( ds[0]<0 || ds[0]>1 ||
        ds[1]<0 || ds[1]>1 ||
        ds[2]<0 || ds[2]>1 ) return false;
    a_r = ds[0];
    a_g = ds[1];
    a_b = ds[2];
    return true;
  } else if( (a_string.size()==7) && (a_string[0]=='#') ) {
    // #RRGGBB format :
    //  1 3 5
    unsigned int rr;
    if(::sscanf(a_string.substr(1,2).c_str(),"%x",&rr)!=1) return false;
    unsigned int gg;
    if(::sscanf(a_string.substr(3,2).c_str(),"%x",&gg)!=1) return false;
    unsigned int bb;
    if(::sscanf(a_string.substr(5,2).c_str(),"%x",&bb)!=1) return false;
    a_r = double(rr)/255.;
    a_g = double(gg)/255.;
    a_b = double(bb)/255.;
    return true;
  } else {
    return colord::to(a_string,a_r,a_g,a_b);
  }
}
bool inlib::to_rgba ( const std::string &  a_string,
double &  a_r,
double &  a_g,
double &  a_b,
double &  a_a 
) [inline]

Definition at line 46 of file scolor.

                                                                                              {
  a_r = 0.5;
  a_g = 0.5;
  a_b = 0.5;
  a_a = 0;
  if(a_string.empty()) return false;
  std::vector<double> ds;
  if(values<double>(a_string," ",false,ds) && (ds.size()>=4)) {
    if( ds[0]<0 || ds[0]>1 ||
        ds[1]<0 || ds[1]>1 ||
        ds[2]<0 || ds[2]>1 ||
        ds[3]<0 || ds[3]>1 ) return false;
    a_r = ds[0];
    a_g = ds[1];
    a_b = ds[2];
    a_a = ds[3];
    return true;
  } else {  
    return to_rgb(a_string,a_r,a_g,a_b);
  }
}
bool inlib::to_rgbs ( const std::string &  a_string,
std::string &  a_value 
) [inline]

Definition at line 68 of file scolor.

                                                                  {
  double r,g,b;
  if(!to_rgb(a_string,r,g,b)) return false;
  a_value = to<double>(r);
  a_value += " ";
  a_value = to<double>(g);
  a_value += " ";
  a_value = to<double>(b);
  return true;
}
std::string inlib::to_string ( const std::vector< std::string > &  a_strings,
const std::string &  a_sep,
bool  a_sep_at_end = false 
) [inline]

Definition at line 221 of file smanip.

                                                                                                                  {
  unsigned int number = a_strings.size();
  if(number<=0) return "";
  std::string result;
  number--;
  for(unsigned int index=0;index<number;index++) {
    result += a_strings[index];
    result += a_sep;
  }
  result += a_strings[number];
  if(a_sep_at_end) result += a_sep;
  return result;
}
std::string inlib::to_string ( unsigned int  a_linen,
const char *  a_lines[] 
) [inline]

Definition at line 235 of file smanip.

                                                                       {
  std::string s;
  for(unsigned int index=0;index<a_linen;index++) {
    s += std::string(a_lines[index]);
    s += "\n";
  }
  return s;
}
template<class T >
bool inlib::to_vals ( const std::string &  a_string,
const char  a_sep,
std::vector< T > &  a_vals 
) [inline]

Definition at line 39 of file parse.

                                                                                    {
  // Support PAW syntax : 3*2.4 is understood as three times 2.4.
  a_vals.clear();
  if(a_string.empty()) return true;
  std::string::size_type lim = 1;
  std::string::size_type l = a_string.length();
  std::string::size_type pos = 0;
  while(true) {
    std::string::size_type index = a_string.find(a_sep,pos);
    if(index==std::string::npos){ // Last word.
      if((l-pos)>=lim) {
        if(!to_vals_one<T>(a_string.substr(pos,l-pos),a_vals)) {
          a_vals.clear();
          return false;
        }
      }
      break;
    } else {
      //     abcxxxef
      //     0  3  67
      if((index-pos)>=lim) {
        if(!to_vals_one<T>(a_string.substr(pos,index-pos),a_vals)) {
          a_vals.clear();
          return false;
        }
      }
      pos = index + 1;
    }
  }
  return true;
}
template<class T >
bool inlib::to_vals_one ( const std::string &  a_string,
std::vector< T > &  a_vals 
) [inline]

Definition at line 18 of file parse.

                                                                       {
  std::string::size_type pos = a_string.find('*');
  if(pos==std::string::npos){
    T value;
    if(!inlib::to<T>(a_string,value)) return false;
    a_vals.push_back(value);
  } else {
    //3*2.4
    //01234
    std::string sn = a_string.substr(0,pos);
    std::string sv = a_string.substr(pos+1,a_string.size()-(pos+1));
    int multiplier;
    if(!inlib::to<int>(sn,multiplier)) return false;
    T value;
    if(!inlib::to<T>(sv,value)) return false;
    for(int index=0;index<multiplier;index++) a_vals.push_back(value);
  }
  return true;
}
std::string inlib::to_xml ( const std::string &  a_string) [inline]

Definition at line 206 of file smanip.

                                                  {
  // > : &lt;
  // < : &gt;
  // & : &amp;
  // " : &quot;
  // ' : &apos;
  std::string s = a_string;
  replace(s,"<","&lt;");
  replace(s,">","&gt;");
  replace(s,"&","&amp;");
  replace(s,"\"","&quot;");
  replace(s,"'","&apos;");
  return s;
}
void inlib::tolowercase ( std::string &  a_string) [inline]

Definition at line 147 of file smanip.

                                            {
  for(std::string::iterator it=a_string.begin();it!=a_string.end();++it) {
    char c = *it;
    *it = ((c) >= 'A' && (c) <= 'Z' ?  c - 'A' + 'a' : c);
  }
}
std::string inlib::tos ( unsigned char  a_value) [inline]

Definition at line 19 of file tos.

                                           {
  std::string s;
  if(is_printable(a_value)) 
    sprintf(s,32,"%c",a_value);
  else
    sprintf(s,32,"%d",a_value);
  return s;
}
std::string inlib::tos ( char  a_value) [inline]

Definition at line 28 of file tos.

                                  {
  std::string s;
  if(is_printable(a_value)) 
    sprintf(s,32,"%c",a_value);
  else
    sprintf(s,32,"%d",a_value);
  return s;
}
std::string inlib::tos ( unsigned short  a_value) [inline]

Definition at line 37 of file tos.

                                             {
  std::string s;
  sprintf(s,32,"%d",a_value);
  return s;
}
std::string inlib::tos ( short  a_value) [inline]

Definition at line 43 of file tos.

                                   {
  std::string s;
  sprintf(s,32,"%d",a_value);
  return s;
}
std::string inlib::tos ( unsigned int  a_value) [inline]

Definition at line 49 of file tos.

                                           {
  std::string s;
  sprintf(s,32,"%u",a_value);
  return s;
}
std::string inlib::tos ( int  a_value) [inline]

Definition at line 61 of file tos.

                                 {
  std::string s;
  sprintf(s,32,"%d",a_value);
  return s;
}
std::string inlib::tos ( uint64  a_value) [inline]

Definition at line 67 of file tos.

                                     {
  std::string s;
  sprintf(s,32,uint64_format(),a_value);
  return s;
}
std::string inlib::tos ( int64  a_value) [inline]

Definition at line 73 of file tos.

                                   {
  std::string s;
  sprintf(s,32,int64_format(),a_value);
  return s;
}
std::string inlib::tos ( float  a_value) [inline]

Definition at line 79 of file tos.

                                   {
  std::string s;
  sprintf(s,32,"%g",a_value);
  return s;
}
std::string inlib::tos ( double  a_value) [inline]

Definition at line 85 of file tos.

                                    {
  std::string s;
  sprintf(s,32,"%g",a_value);
  return s;
}
std::string inlib::tos ( bool  a_value) [inline]

Definition at line 91 of file tos.

                                  {
  return std::string(a_value?"true":"false");
}
std::string inlib::tos ( const std::string &  a_value) [inline]

Definition at line 95 of file tos.

{return a_value;}
template<class T >
std::string inlib::tos ( const std::vector< T > &  a_value,
const std::string &  a_sep = "\n" 
) [inline]

Definition at line 98 of file tos.

                                                       {
  unsigned int number = a_value.size();
  if(number<=0) return "";
  std::string result;
  number--;
  for(unsigned int index=0;index<number;index++) {
    result += tos(a_value[index]);
    result += a_sep;
  }
  result += tos(a_value[number]);
  return result;
}
void inlib::toss ( const char *  a_from,
char  a_s[],
unsigned int &  a_l 
) [inline]

Definition at line 12 of file tosu.

                                                                  {
  char* s = (char*)a_from;
  a_l = 0;
  char* pos = a_s;
  while(*s) {
    *pos++ = *s;
    a_l++;
    s++;
  }
  *pos++ = 0;
}
template<class T >
void inlib::tosu ( a_i,
char  a_s[],
unsigned int &  a_l 
) [inline]

Definition at line 25 of file tosu.

                                                     {
  //assume a_s is sufficently allocated (32 is ok).
  a_l = 0;
 {char* pos = a_s;
  T i = a_i;
  while(true) {
    if(i<=9) {*pos++ = '0'+i;a_l++;*pos++=0;break;}
    T r = i % 10;
    *pos++ = '0'+r;
    a_l++;
    i = i/10;
  }}
  //strrev(s);
 {unsigned int hl = a_l/2;
  char* beg = a_s;
  char* end = a_s+a_l-1;
  for(unsigned int i=0;i<hl;i++) {
    char c = *end;
    *end = *beg;      
    *beg = c;
    beg++;end--;  
  }}
}
std::string inlib::tosx ( unsigned int  a_value) [inline]

Definition at line 55 of file tos.

                                            {
  std::string s;
  sprintf(s,32,"%x",a_value);
  return s;
}
void inlib::touppercase ( std::string &  a_string) [inline]

Definition at line 154 of file smanip.

                                            {
  for(std::string::iterator it=a_string.begin();it!=a_string.end();++it) {
    char c = *it;
    *it = ((c) >= 'a' && (c) <= 'z' ?  c - 'a' + 'A' : c);
  }
}
double inlib::two_pi ( ) [inline]

Definition at line 18 of file math.

{return 6.2831853071795862320E0;}
const char* inlib::uint32_format ( ) [inline]

Definition at line 52 of file typedefs.

{static const char s[] = "%u";return s;}
uint32 inlib::uint32_mx ( ) [inline]

Definition at line 57 of file typedefs.

                          { //4 294 967 295
  uint32 n = 0;
  for(unsigned int i=0;i<32;i++)  n += 1<<i;  
  return n;
}
const char* inlib::uint64_format ( ) [inline]

Definition at line 53 of file typedefs.

{static const char s[] = "%llu";return s;}
uint64 inlib::uint64_mx ( ) [inline]

Definition at line 62 of file typedefs.

                          { //18 446 744 073 709 551 614
  uint64 n = 0;
  for(unsigned int i=0;i<64;i++)  n += 1<<i;  
  return n;
}
template<class T >
void inlib::unique ( std::vector< T > &  a_vec) [inline]

Definition at line 41 of file vmanip.

                                        {
  typedef typename std::vector<T>::iterator it_t;
  it_t it,it2; //Android : it2=it+1 does not compile with inlib/stl.
  for(it=a_vec.begin();it!=a_vec.end();++it) {
    it2 = it;it2++; //Android : it2=it+1 does not compile.
    for(;it2!=a_vec.end();) {
      if(*it2==*it) {
        it2 = a_vec.erase(it2);
      } else { 
        ++it2;
      }
    }
  }
}
template<class T >
bool inlib::values ( const std::string &  a_string,
const std::string &  a_sep,
bool  a_take_empty,
std::vector< T > &  a_values 
) [inline]

Definition at line 252 of file smanip.

                                                                                                             {
  a_values.clear();
  if(a_string.empty()) return true;
  std::string::size_type lim = (a_take_empty?0:1);
  if(a_sep.empty()) {
    T value;
    if(!to<T>(a_string,value)) {
      a_values.clear();
      return false;
    }
    a_values.push_back(value);
  } else {
    std::string::size_type l = a_string.length();
    std::string::size_type llimiter = a_sep.length();
    std::string::size_type pos = 0;
    while(true) {
      std::string::size_type index = a_string.find(a_sep,pos);
      if(index==std::string::npos){ // Last word.
        if((l-pos)>=lim) {
          T value;
          if(!to<T>(a_string.substr(pos,l-pos),value)) {
            a_values.clear();
            return false;
          }
          a_values.push_back(value);
        }
        break;
      } else {
        //     abcxxxef
        //     0  3  67
        if((index-pos)>=lim) {
          T value;
          if(!to<T>(a_string.substr(pos,index-pos),value)) {
            a_values.clear();
            return false;
          }
          a_values.push_back(value);
        }
        pos = index + llimiter;
      }
    }
  }
  return true;
}
template<class T >
const T* inlib::vec_data ( const std::vector< T > &  a_vec) [inline]

Definition at line 12 of file vdata.

                                                    {
#if TARGET_OS_IPHONE || WIN32 || __INTEL_COMPILER
  const T& vf = a_vec.front();
  return &vf;
#else
  return a_vec.data();
#endif
}
template<class T >
T* inlib::vec_data ( std::vector< T > &  a_vec) [inline]

Definition at line 22 of file vdata.

                                        {
#if TARGET_OS_IPHONE || WIN32 || __INTEL_COMPILER
  T& vf = a_vec.front();
  return &vf;
#else
  return a_vec.data();
#endif
}
bool inlib::version ( const std::string &  a_string,
std::vector< unsigned int > &  a_version 
) [inline]

Definition at line 303 of file smanip.

                                                                                  {
  // a_string is of the form [v,V][<number><char>]<number>
  // Examples : 0 1.2 v0 v1r2 V1r2p3 v0.1.3
  unsigned int number = a_string.size();
  if(!number) {
    a_version.clear();
    return false;
  }
  char* pos = (char*)a_string.c_str();
  if( ((*pos)=='v') || ((*pos)=='V') ) {
    if(number==1) {
      a_version.clear();
      return false; //a_string is only 'v' or 'V' !
    }
    pos++;
  }
  while(*pos!='\0') {
    char* s;
    long v = ::strtol(pos,&s,10);
    if(s==pos) {
      a_version.clear();
      return false;
    }
    if(v<0) {
      a_version.clear();
      return false;
    }
    a_version.push_back((unsigned int)v);
    pos = s; //Could be at end.
    if(*pos=='\0') break;
    // Next char is then not a digit. Skip it.
    pos++;
  }
  return true;
}
void inlib::window_size_from_args ( const args &  a_args,
unsigned int &  a_ww,
unsigned int &  a_wh 
) [inline]

Definition at line 450 of file args.

                                                                         {
  // return some common window size (in pixels).
  if(a_args.is_arg("-iPod")||a_args.is_arg("-iPhone")) {
    a_ww = 320;
    a_wh = 480;
  } else if(a_args.is_arg("-iPad")) {
    a_ww = 768;
    a_wh = 1024;
  } else if(a_args.is_arg("-iPhone4")) {
    a_ww = 640;
    a_wh = 960;
  } else if(a_args.is_arg("-SGS")) { //Samsung Galaxy S
    //a_ww = 320;
    //a_wh = 533;
    a_ww = 480;
    a_wh = 800;
  } else {
    if(a_args.find<unsigned int>("-ww",a_ww)) {
      if(a_args.find<unsigned int>("-wh",a_wh)) return;
      //A4 : we have ww but not wh :
      a_wh = (unsigned int)(a_ww*(29.7f/21.0f)); //29.7/21 = 1.414
    } else { //we don't have ww.
      if(a_args.find<unsigned int>("-wh",a_wh)) {
        //A4 : we have wh but not ww :
        a_ww = (unsigned int)(a_wh*(21.0f/29.7f));
      } else {
        //we have nothing. Take a ww of 700. With A4 wh is then 990.
        a_ww = 700;
        a_wh = (unsigned int)(a_ww*(29.7f/21.0f)); //29.7/21 = 1.414
      }
    }
  }
  if(a_args.is_arg("-land")){
    unsigned int tmp = a_ww;
    a_ww = a_wh;
    a_wh = tmp;
  }
}
void inlib::words ( const std::string &  a_string,
const std::string &  a_sep,
bool  a_take_empty,
std::vector< std::string > &  a_words 
) [inline]

Definition at line 12 of file words.

                                                                                                                   {
  //  If a_sep is for exa "|" and for "xxx||xxx" :
  //  - a_take_empty false : {"xxx","xxx"} will be created 
  //    (and NOT {"xxx","","xxx"}).
  //  - a_take_empty true : {"xxx","","xxx"} will be created.
  a_words.clear();
  if(a_string.empty()) return;
  std::string::size_type lim = (a_take_empty?0:1);
  if(a_sep.empty()) {
    a_words.push_back(a_string);
  } else {
    std::string::size_type l = a_string.length();
    std::string::size_type llimiter = a_sep.length();
    std::string::size_type pos = 0;
    while(true) {
      std::string::size_type index = a_string.find(a_sep,pos);
      if(index==std::string::npos){ // Last word.
        if((l-pos)>=lim) a_words.push_back(a_string.substr(pos,l-pos));
        break;
      } else {
        //     abcxxxef
        //     0  3  67
        if((index-pos)>=lim) a_words.push_back(a_string.substr(pos,index-pos));
        pos = index + llimiter;
      }
    }
  }
}
std::vector<std::string> inlib::words ( const std::string &  a_string,
const std::string &  a_limiter,
bool  a_take_empty = false 
) [inline]

Definition at line 41 of file words.

                                                                                                                 {
  std::vector<std::string> v;
  words(a_string,a_limiter,a_take_empty,v);
  return v;
}
template<class T >
unsigned int inlib::write_buffer ( a_value,
char *  a_buffer 
) [inline]

Definition at line 15 of file buffer.

                                                           {
  size_t n = sizeof(T);
  //NOTE : a_buffer must be allocated to n.
  if(is_little_endian()) {
    ::memcpy(a_buffer,&a_value,n);
  } else {
    char* pos = (char*)&a_value;
    for(unsigned int i=0;i<n;i++,pos++) a_buffer[n-1-i] = *pos;
  }
  return n;
}
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines