inlib
1.2.0
|
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 > | |
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 > | |
T | mn (const T &a, const T &b) |
template<class T > | |
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 > | |
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) |
manipulations that induces other includes : ///////////
typedef unsigned char inlib::byte |
typedef unsigned short inlib::cid |
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.
typedef std::vector<CLineStripList> inlib::CLineStripListVector |
Definition at line 23 of file CListContour.
typedef const char* inlib::const_cstr_t |
typedef char* inlib::cstr_t |
typedef unsigned long inlib::diff_pointer_t |
typedef img< unsigned char > inlib::img_byte |
typedef short inlib::int16 |
typedef int inlib::int32 |
typedef long long inlib::int64 |
typedef uint32 inlib::ref |
typedef int64(* inlib::s2int64_func)(const char *, char **, int) |
typedef unsigned char inlib::uchar |
typedef unsigned short inlib::uint16 |
typedef unsigned int inlib::uint32 |
typedef unsigned long long inlib::uint64 |
enum inlib::side |
enum inlib::what |
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; }
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)); }
bool inlib::add | ( | std::vector< T > & | a_vec, |
const std::vector< T > & | a_v | ||
) | [inline] |
void inlib::add | ( | std::vector< T > & | a_vec, |
const T & | a_v | ||
) | [inline] |
sqm<T> inlib::anticommutator | ( | const sqm< T > & | a1, |
const sqm< T > & | a2 | ||
) | [inline] |
void inlib::append | ( | std::vector< T > & | a_vec, |
const std::vector< T > & | a_from | ||
) | [inline] |
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] |
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] |
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] |
TO* inlib::cast | ( | FROM & | a_o | ) | [inline] |
const TO* inlib::cast | ( | const FROM & | a_o | ) | [inline] |
std::string inlib::char_p2s | ( | const char * | a_value | ) | [inline] |
bool inlib::check_args | ( | const std::vector< std::string > & | a_args, |
unsigned int | a_number, | ||
std::ostream & | a_out | ||
) | [inline] |
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; }
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] |
bool inlib::check_or_args | ( | const std::vector< std::string > & | aArgs, |
unsigned int | a_1, | ||
unsigned int | a_2, | ||
std::ostream & | a_out | ||
) | [inline] |
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] |
bool inlib::cmp | ( | std::ostream & | a_out, |
const T & | a_what, | ||
const T & | a_ref, | ||
const T & | a_error = T() |
||
) | [inline] |
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); }
void* inlib::cmp_cast | ( | const TO * | a_this, |
cid | a_id | ||
) | [inline] |
sqm<T> inlib::commutator | ( | const sqm< T > & | a1, |
const sqm< T > & | a2 | ||
) | [inline] |
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] |
void inlib::conj | ( | array< T > & | a_array | ) | [inline] |
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; }
std::vector<TO> inlib::convert | ( | const std::vector< FROM > & | a_from | ) | [inline] |
void inlib::count_out | ( | std::ostream & | a_out, |
T | a_count, | ||
T | a_step | ||
) | [inline] |
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] |
void inlib::dagger | ( | sqm< T > & | a_array | ) | [inline] |
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; }
void inlib::diff | ( | std::ostream & | a_out, |
const array< T > & | aA, | ||
const array< T > & | aB, | ||
T | 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; }
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; }
void inlib::div | ( | std::vector< T > & | a_vec, |
const T & | a_v | ||
) | [inline] |
void inlib::dump | ( | const std::vector< T > & | a_vec, |
std::ostream & | a_out | ||
) | [inline] |
void inlib::dump | ( | std::ostream & | a_out, |
const inlib::array< T > & | a_array, | ||
const std::string & | a_title | ||
) | [inline] |
void inlib::dump | ( | const sqm< T > & | a_matrix, |
std::ostream & | a_out, | ||
const std::string & | aCMT | ||
) | [inline] |
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] |
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] |
float inlib::fasin | ( | float | x | ) | [inline] |
float inlib::fatan | ( | float | x | ) | [inline] |
float inlib::fatan2 | ( | float | x, |
float | y | ||
) | [inline] |
float inlib::fceil | ( | float | x | ) | [inline] |
float inlib::fcos | ( | float | x | ) | [inline] |
float inlib::ffabs | ( | float | x | ) | [inline] |
float inlib::ffloor | ( | float | x | ) | [inline] |
float inlib::fhalf_pi | ( | ) | [inline] |
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; }
void inlib::filter | ( | std::vector< T > & | a_vec, |
unsigned int | a_mn, | ||
unsigned int | a_mx | ||
) | [inline] |
bool inlib::find | ( | const std::vector< std::pair< K, V > > & | a_vec, |
const K & | a_key, | ||
V & | a_value | ||
) | [inline] |
T* inlib::find_named | ( | const std::vector< T * > & | a_vec, |
const std::string & | a_name | ||
) | [inline] |
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] |
float inlib::flog10 | ( | float | x | ) | [inline] |
float inlib::fpi | ( | ) | [inline] |
float inlib::fpow | ( | float | x, |
float | y | ||
) | [inline] |
float inlib::fsin | ( | float | x | ) | [inline] |
float inlib::fsqrt | ( | float | x | ) | [inline] |
float inlib::ftan | ( | float | x | ) | [inline] |
float inlib::ftwo_pi | ( | ) | [inline] |
bool inlib::get_env | ( | const std::string & | a_string, |
T & | a_v | ||
) | [inline] |
bool inlib::get_env_bool | ( | const std::string & | a_string, |
bool & | a_v | ||
) | [inline] |
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] |
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] |
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; }
TO* inlib::id_cast | ( | FROM & | a_o | ) | [inline] |
const TO* inlib::id_cast | ( | const FROM & | a_o | ) | [inline] |
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] |
bool inlib::in_domain_log | ( | double | a_x | ) | [inline] |
bool inlib::in_domain_tan | ( | double | a_x | ) | [inline] |
const char* inlib::int32_format | ( | ) | [inline] |
const char* inlib::int64_format | ( | ) | [inline] |
bool inlib::is_absolute_path | ( | const std::string & | a_path | ) | [inline] |
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] |
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); }
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] |
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] |
bool inlib::isenv | ( | const std::string & | a_string | ) | [inline] |
bool inlib::item_index | ( | const std::vector< T > & | a_vec, |
const T & | a_item, | ||
unsigned int & | a_index | ||
) | [inline] |
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; } }
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] |
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; }
bool inlib::maximum | ( | const std::vector< T > & | a_vec, |
T & | a_value | ||
) | [inline] |
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; }
bool inlib::minimum | ( | const std::vector< T > & | a_vec, |
T & | a_value | ||
) | [inline] |
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; }
T inlib::mn | ( | const T & | a, |
const T & | b | ||
) | [inline] |
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; }
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; }
void inlib::mul | ( | std::vector< T > & | a_vec, |
const T & | a_v | ||
) | [inline] |
T inlib::mx | ( | const T & | a, |
const T & | b | ||
) | [inline] |
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] |
vec2f inlib::operator* | ( | float | a_f, |
const vec2f & | a_v | ||
) | [inline] |
vec3d inlib::operator* | ( | double | a_f, |
const vec3d & | a_v | ||
) | [inline] |
vec3f inlib::operator* | ( | float | a_f, |
const vec3f & | a_v | ||
) | [inline] |
sqm<T> inlib::operator* | ( | const sqm< T > & | a1, |
const sqm< T > & | a2 | ||
) | [inline] |
sqm<T> inlib::operator+ | ( | const sqm< T > & | a1, |
const sqm< T > & | a2 | ||
) | [inline] |
sqm<T> inlib::operator- | ( | const sqm< T > & | a1, |
const sqm< T > & | a2 | ||
) | [inline] |
std::ostream& inlib::operator<< | ( | std::ostream & | a_out, |
const vecs & | |||
) | [inline] |
std::ostream& inlib::operator<< | ( | std::ostream & | a_out, |
const vec2f & | a_this | ||
) | [inline] |
std::ostream& inlib::operator<< | ( | std::ostream & | a_out, |
const vec3f & | a_this | ||
) | [inline] |
std::ostream& inlib::operator<< | ( | std::ostream & | a_out, |
const colorf & | a_this | ||
) | [inline] |
std::ostream& inlib::operator<< | ( | std::ostream & | a_out, |
const mat4f & | |||
) | [inline] |
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] |
std::string inlib::p2s | ( | void * | a_value | ) | [inline] |
std::string inlib::p2sx | ( | void * | a_value | ) | [inline] |
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,"/"); }
std::string inlib::plugin_name | ( | const std::string & | a_name | ) | [inline] |
std::string inlib::plugin_prefix | ( | ) | [inline] |
std::string inlib::plugin_suffix | ( | ) | [inline] |
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; }
T inlib::power | ( | const T & | a_A, |
unsigned int | a_B | ||
) | [inline] |
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] |
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; }
unsigned int inlib::read_buffer | ( | const char * | a_buffer, |
T & | a_value | ||
) | [inline] |
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; }
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] |
void inlib::replace | ( | std::string & | a_string, |
char | a_old, | ||
char | a_new | ||
) | [inline] |
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] |
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] |
const std::string& inlib::s_aida_type | ( | short | ) | [inline] |
const std::string& inlib::s_aida_type | ( | int | ) | [inline] |
const std::string& inlib::s_aida_type | ( | float | ) | [inline] |
const std::string& inlib::s_aida_type | ( | double | ) | [inline] |
const std::string & inlib::s_aida_type | ( | unsigned | char | ) | [inline] |
const std::string& inlib::s_aida_type | ( | bool | ) | [inline] |
const std::string& inlib::s_aida_type | ( | const std::string & | ) | [inline] |
const std::string& inlib::s_aida_type | ( | int64 | ) | [inline] |
const std::string& inlib::s_aida_type | ( | const std::vector< double > & | ) | [inline] |
const std::string& inlib::s_aida_type | ( | uint64 | ) | [inline] |
const std::string& inlib::s_aida_type_ituple | ( | ) | [inline] |
std::string inlib::sep | ( | ) | [inline] |
std::string inlib::sjust | ( | const std::string & | a_string, |
unsigned int | a_size, | ||
side | a_side = left |
||
) | [inline] |
std::string inlib::sjust | ( | T | a_value, |
unsigned int | a_size, | ||
side | a_side = left |
||
) | [inline] |
void inlib::sleep_milli_secs | ( | unsigned int | a_milli_sec | ) | [inline] |
void inlib::sleep_secs | ( | unsigned int | a_secs | ) | [inline] |
std::string inlib::so_name | ( | const std::string & | a_name | ) | [inline] |
std::string inlib::sout | ( | const std::string & | a_string | ) | [inline] |
std::string inlib::sout | ( | const T & | a_value | ) | [inline] |
std::string inlib::soutd | ( | double | a_value | ) | [inline] |
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; }
void inlib::steps | ( | std::vector< T > & | a_vec, |
unsigned int | a_number | ||
) | [inline] |
bool inlib::str_cat | ( | char *& | a_1, |
const char | a_c | ||
) | [inline] |
bool inlib::str_cat | ( | char *& | a_1, |
const char * | a_2 | ||
) | [inline] |
void inlib::str_del | ( | char *& | a_cstr | ) | [inline] |
char* inlib::str_dup | ( | const char * | a_cstr | ) | [inline] |
char* inlib::str_new | ( | size_t | a_l = 0 , |
char | a_char = ' ' |
||
) | [inline] |
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] |
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] |
std::string inlib::strp | ( | const std::string & | a_string, |
what | a_type = both , |
||
char | a_char = ' ' |
||
) | [inline] |
const std::string & inlib::stype | ( | unsigned | char | ) | [inline] |
const std::string& inlib::stype | ( | char | ) | [inline] |
const std::string& inlib::stype | ( | short | ) | [inline] |
const std::string& inlib::stype | ( | int | ) | [inline] |
const std::string& inlib::stype | ( | float | ) | [inline] |
const std::string& inlib::stype | ( | double | ) | [inline] |
const std::string& inlib::stype | ( | int64 | ) | [inline] |
const std::string& inlib::stype | ( | uint64 | ) | [inline] |
const std::string& inlib::stype | ( | const std::string & | ) | [inline] |
bool inlib::sub | ( | std::vector< T > & | a_vec, |
const std::vector< T > & | a_v | ||
) | [inline] |
void inlib::sub | ( | std::vector< T > & | a_vec, |
const T & | a_v | ||
) | [inline] |
std::string inlib::suffix | ( | const std::string & | a_string, |
bool | a_back = true |
||
) | [inline] |
T inlib::sum | ( | const std::vector< T > & | a_vec | ) | [inline] |
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] |
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; } }
bool inlib::to | ( | const std::string & | a_s, |
T & | a_v | ||
) | [inline] |
std::string inlib::to | ( | const T & | a_v | ) | [inline] |
std::vector<std::string> inlib::to | ( | int | a_argc, |
char ** | a_argv | ||
) | [inline] |
bool inlib::to | ( | std::ostream & | a_out, |
const std::string & | a_string, | ||
T & | a_value | ||
) | [inline] |
bool inlib::to | ( | std::ostream & | a_out, |
const std::string & | a_string, | ||
bool & | a_value | ||
) | [inline] |
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] |
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] |
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] |
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; }
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] |
void inlib::tolowercase | ( | std::string & | a_string | ) | [inline] |
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] |
std::string inlib::tos | ( | short | a_value | ) | [inline] |
std::string inlib::tos | ( | unsigned int | a_value | ) | [inline] |
std::string inlib::tos | ( | int | a_value | ) | [inline] |
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] |
std::string inlib::tos | ( | double | a_value | ) | [inline] |
std::string inlib::tos | ( | bool | a_value | ) | [inline] |
std::string inlib::tos | ( | const std::string & | a_value | ) | [inline] |
std::string inlib::tos | ( | const std::vector< T > & | a_value, |
const std::string & | a_sep = "\n" |
||
) | [inline] |
void inlib::toss | ( | const char * | a_from, |
char | a_s[], | ||
unsigned int & | a_l | ||
) | [inline] |
void inlib::tosu | ( | T | 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] |
void inlib::touppercase | ( | std::string & | a_string | ) | [inline] |
double inlib::two_pi | ( | ) | [inline] |
const char* inlib::uint32_format | ( | ) | [inline] |
uint32 inlib::uint32_mx | ( | ) | [inline] |
const char* inlib::uint64_format | ( | ) | [inline] |
uint64 inlib::uint64_mx | ( | ) | [inline] |
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; } } } }
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; }
const T* inlib::vec_data | ( | const std::vector< T > & | a_vec | ) | [inline] |
T* inlib::vec_data | ( | std::vector< T > & | a_vec | ) | [inline] |
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] |
unsigned int inlib::write_buffer | ( | T | 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; }