Scopira  20080306
scopira::tool Namespace Reference

Classes

class  archiveiflow
 
class  archiveoflow
 
class  area_ptr
 
class  array_view
 
class  basic_array
 
class  basic_matrix
 
class  bin64iflow
 
class  bin64oflow
 
class  biniflow
 
class  binoflow
 
class  bufferflow
 
class  bufferiflow
 
class  bufferoflow
 
class  cacheiflow
 
class  cacheoflow
 
class  chrono
 
class  circular_vector
 
class  commentiflow
 
class  condition
 
class  const_area_ptr
 
class  const_array_view
 
class  const_mod
 
class  const_mod< uint64_t, uint64_t(1)<< 48 >
 
class  const_mod< unsigned int, 0 >
 
class  const_mod< unsigned long, 0 >
 
class  count2_ptr
 
class  count_ptr
 
class  countoflow
 
struct  deref
 
struct  deref_first
 
struct  deref_objauto
 
struct  deref_ptr
 
struct  deref_second
 
class  destroy_reactor_i
 
class  dir_iterator
 
class  distoflow
 
class  dll
 
class  event_area
 
class  event_ptr
 
class  file
 
class  fileflow
 
class  filememory
 
class  fixed_array
 
class  flow_i
 
class  flowtraits_base_g
 
class  flowtraits_g
 
class  flowtraits_g< bool >
 specialization: bool More...
 
class  flowtraits_g< char >
 specialization: char More...
 
class  flowtraits_g< double >
 specialization: double More...
 
class  flowtraits_g< float >
 specialization: float More...
 
class  flowtraits_g< int >
 specialization: int More...
 
class  flowtraits_g< int64_t >
 specialization: long More...
 
class  flowtraits_g< short >
 specialization: short More...
 
class  flowtraits_g< std::string >
 
class  flowtraits_g< std::vector< EE > >
 
class  flowtraits_g< unsigned char >
 specialization: unsigned char More...
 
class  hashoflow
 
class  hexiflow
 
class  hexoflow
 
class  hybrid_array
 
class  iflow_i
 
class  iobjflow_i
 
class  isoiflow
 
class  isooflow
 
class  iterator_g
 
class  iterator_imp_g
 
class  itflow_i
 
class  job_i
 
class  lincon_gen
 
class  locker
 
class  locker_ptr
 
class  mutex
 
class  net_loop
 
class  netaddr
 
class  netflow
 
class  nethostrec
 
class  null_iterator_imp_g
 
class  nullflow
 
class  object
 
class  objflowloader
 
class  objrefcounter
 
class  oflow_i
 
class  oobjflow_i
 
class  otflow_i
 
class  output_stack
 
class  polyiflow
 
class  polyoflow
 
class  printiflow
 
class  printoflow
 
class  property
 
class  property_node
 
class  propiflow
 
class  propoflow
 
class  rand48
 
class  read_flocker
 
class  read_locker
 
class  read_locker_ptr
 
class  regex
 
class  register_flow
 
class  regmatch
 
class  rename_reactor_i
 
class  runnable_i
 
class  rw_area
 
class  rwlock
 
class  shared_area
 
class  singleton
 
class  stl_iterator_imp_g
 
class  stringflow
 
class  stringiflow
 
class  stringoflow
 
class  sysdev_gen
 
class  sysrand_gen
 
class  sysrandom_gen
 
class  teeoflow
 
class  textiflow
 
class  textoflow
 
class  thread
 
class  timespan
 
class  timestamp
 
class  treenode
 
class  udpflow
 
class  uni01_dist
 
class  uniint_dist
 
class  unireal_dist
 
class  unismallint_dist
 
class  unixflow
 
class  update_reactor_i
 
class  url
 
class  uuid
 
class  uuid_generator
 
class  write_flocker
 
class  write_locker
 
class  write_locker_ptr
 
class  xml_attrib
 
class  xml_doc
 
class  xml_node
 

Typedefs

typedef uni01_dist< lincon_corelincon_01
 
typedef unireal_dist< lincon_corelincon_real
 
typedef unismallint_dist< lincon_corelincon_smallint
 
typedef uniint_dist< lincon_corelincon_int
 
typedef uni01_dist< scopira::tool::rand48rand48_01
 
typedef unireal_dist< scopira::tool::rand48rand48_real
 
typedef unismallint_dist< scopira::tool::rand48rand48_smallint
 
typedef uniint_dist< scopira::tool::rand48rand48_int
 
typedef unsigned char byte_t
 
typedef lincon_gen< int, 16807, 0, 2147483647, 1043618065 > minstd_rand0
 
typedef lincon_gen< int, 48271, 0, 2147483647, 399268537 > minstd_rand
 
typedef minstd_rand0 lincon_core
 a typical random core
 
typedef int socket_handle_t
 
typedef scopira::tool::oflow_i &(* output_func) (void)
 
typedef void *(* runfunc_t) (void *)
 

Enumerations

enum  { copy_c = 0, copysoftlink_c = 1, copyhardlink_c = 2 }
 

Functions

const char * get_username (void)
 gets the username of the logged in system, may return "" (but never null)
 
const char * get_homedir (void)
 gets the user's home directory, may return "." (but never null)
 
bool copy_file (const std::string &srcfile, const std::string &destfile, short copytype=copy_c)
 
std::string hexhash (const scopira::tool::basic_array< byte_t > &hash)
 
std::string close_and_hexhash (hashoflow &o)
 
std::string hexhash_string (const std::string &s, int type=scopira::tool::hashoflow::sha1_c)
 
bool is_hex (char c)
 returns true if this is a hex char
 
byte_t char_to_hex (char c)
 converts a '0'..'F' (or '0'..'f') to 0-15
 
std::string get_hostname (void)
 gets the hostname of this machine
 
bool hostname_to_hostrec (const std::string &hname, nethostrec &rec)
 looks up the hname, and saves into rec, returns true on success
 
template<class T >
objectobjloadfunc_g (void)
 
void flow_reg_imp (const std::type_info &id, const char *name, scopira::tool::objflowloader::loadfunc_t loader)
 
scopira::tool::oflow_itool_output (void)
 
void flow_printf (oflow_i &o, const char *fmt,...)
 printf style
 
int time_seed (void)
 
template<class GEN >
double next_double (GEN &g, double mx)
 
template<class GEN >
double next_double (GEN &g)
 
template<class T >
void qsort (T &s, int lo0, int hi0)
 
int num_system_cpus (void)
 
intptr_t ptr_to_int (const void *ptr)
 
template<class C >
C * int_to_ptr (intptr_t x)
 
void * int_to_void (intptr_t x)
 
std::string bool_to_string (bool val)
 
void int_to_string (bool val, std::string &out)
 
std::string int_to_string (int i)
 
void int_to_string (int i, std::string &out)
 
int int_to_string (int i, char *out, int buflen)
 
int string_to_int (const std::string &s)
 
bool string_to_int (const std::string &s, int &outint)
 
std::string long_to_string (long i)
 
void long_to_string (long i, std::string &out)
 
long string_to_long (const std::string &s)
 
bool string_to_long (const std::string &s, long &outlong)
 
std::string size_t_to_string (size_t i)
 
void size_t_to_string (size_t i, std::string &out)
 
size_t string_to_size_t (const std::string &s)
 
bool string_to_size_t (const std::string &s, size_t &outsize_t)
 
std::string int64_t_to_string (int64_t i)
 
void int64_t_to_string (int64_t i, std::string &out)
 
int64_t string_to_int64_t (const std::string &s)
 
bool string_to_int64_t (const std::string &s, int64_t &outint64_t)
 
std::string double_to_string (double i)
 
void double_to_string (double i, std::string &out)
 
std::string double_to_string (double i, int pres)
 
int double_to_string (double i, char *out, int buflen)
 
std::string double_to_exp_string (double i, int pres=25)
 
double string_to_double (const std::string &s)
 
bool string_to_double (const std::string &s, double &outdouble)
 
template<class T >
char compare (const T &lhs, const T &rhs)
 
void uppercase (const std::string &s, std::string &upper)
 
std::string uppercase (const std::string &s)
 
void lowercase (const std::string &s, std::string &lower)
 
std::string lowercase (const std::string &s)
 
std::string pad_left (const std::string &s, int width, char padchar=' ')
 
void impl_cstring_to_fixed_array_impl (const char *in, size_t srclen, char *out, size_t N) throw ()
 
template<size_t N>
void string_to_fixed_array (const std::string &src, fixed_array< char, N > &out) throw ()
 
template<size_t N>
void c_string_to_fixed_array (const char *in, fixed_array< char, N > &out) throw ()
 
bool split_char (const std::string &src, char split, std::string &left_out, std::string &right_out)
 
std::string filename_number (const std::string &fname, int num)
 
void trim_left (std::string &str)
 
void trim_right (std::string &str)
 
template<class container >
void string_tokenize_word (const std::string &src, container &result, const std::string &substr)
 
template<class container >
void string_tokenize (const std::string &src, container &result, const std::string &delimiters=" \")
 
template<class T >
byte_swap (T x)
 
template<>
short byte_swap< short > (short x)
 
template<>
int byte_swap< int > (int x)
 
template<>
int64_t byte_swap< int64_t > (int64_t x)
 
template<>
uint64_t byte_swap< uint64_t > (uint64_t x)
 
template<>
float byte_swap< float > (float x)
 
template<>
double byte_swap< double > (double x)
 
template<class ITER >
void byte_swap_all (ITER head, ITER tail)
 

Variables

const char * dll_ext_c
 either .DLL or .SO
 
const char dir_seperator_c = '/'
 
const char * hexchars
 array of the 16 digits of hex
 
const char * lowerhexchars
 array of the 16 digits of hex (lowercase, which you should probably prefer)
 
scopira::tool::output_func gm_tool_output
 
scopira::tool::oflow_igm_tool_output_stream
 

Detailed Description

The scopira::tool namespace contains scopira-independant utitlies, like autopointers, virtual stream system (with file and network support), threads, property files and a simple vector template.

Author
Aleksander Demko

Typedef Documentation

◆ minstd_rand

typedef lincon_gen<int, 48271, 0, 2147483647, 399268537> scopira::tool::minstd_rand

cycle length: 2^31-2 a typical generator type (lincon_gen + some template paramters)

◆ minstd_rand0

typedef lincon_gen<int, 16807, 0, 2147483647, 1043618065> scopira::tool::minstd_rand0

a typical generator type (lincon_gen + some template paramters) cycle length: 2^31-2

◆ output_func

typedef scopira::tool::oflow_i&(* scopira::tool::output_func) (void)

A function type that returns an output stream

Author
Aleksander Demko

◆ runfunc_t

typedef void *(* scopira::tool::runfunc_t)(void *)

a function thet can be called by a thread run routine you should return 0, i guess

Function Documentation

◆ bool_to_string()

std::string scopira::tool::bool_to_string ( bool  val)
inline

Converts a bool to a string

Parameters
valthe bool value
Returns
the string representation of the bool
Author
Rodrigo Vivanco

◆ byte_swap()

template<class T >
T scopira::tool::byte_swap ( x)
inline

Generic byte swapper. Does nothing.

Author
Aleksander Demko

Referenced by byte_swap_all().

◆ byte_swap< double >()

template<>
double scopira::tool::byte_swap< double > ( double  x)
inline

Swaps the byte (endianess) of an double.

Author
Aleksander Demko

References byte_swap_all().

◆ byte_swap< float >()

template<>
float scopira::tool::byte_swap< float > ( float  x)
inline

Swaps the byte (endianess) of an float.

Author
Aleksander Demko

◆ byte_swap< int >()

template<>
int scopira::tool::byte_swap< int > ( int  x)
inline

Swaps the byte (endianess) of an int. Currently only used in binflow.

Author
Aleksander Demko

◆ byte_swap< int64_t >()

template<>
int64_t scopira::tool::byte_swap< int64_t > ( int64_t  x)
inline

Swaps the byte (endianess) of an int64_t.

Author
Aleksander Demko

◆ byte_swap< short >()

template<>
short scopira::tool::byte_swap< short > ( short  x)
inline

Swaps the byte (endianess) of a short. Currently only used in binflow.

Author
Aleksander Demko

◆ byte_swap< uint64_t >()

template<>
uint64_t scopira::tool::byte_swap< uint64_t > ( uint64_t  x)
inline

Swaps the byte (endianess) of an uint64_t.

Author
Aleksander Demko

◆ byte_swap_all()

template<class ITER >
void scopira::tool::byte_swap_all ( ITER  head,
ITER  tail 
)

◆ c_string_to_fixed_array()

template<size_t N>
void scopira::tool::c_string_to_fixed_array ( const char *  in,
fixed_array< char, N > &  out 
)
throw (
)
inline

Copies null terminated C string to a fixed_array<char, N>. The destination will always be null terminated and well formed.

Author
Aleksander Demko

References filename_number(), split_char(), trim_left(), and trim_right().

◆ close_and_hexhash()

std::string scopira::tool::close_and_hexhash ( hashoflow o)

Closes the given hashoflow and returns the hash, as a hex string

Author
Aleksander Demko

◆ compare()

template<class T >
char scopira::tool::compare ( const T &  lhs,
const T &  rhs 
)

A generic "compare" method. returns -1 if lhs is < than rhs, -1 of rhs<lhs else 0. (so you only need to implement <)

Author
Aleksander Demko

References lowercase(), pad_left(), and uppercase().

◆ copy_file()

bool scopira::tool::copy_file ( const std::string &  srcfile,
const std::string &  destfile,
short  copytype = copy_c 
)

Copies the given srcfile to the given destination (file or dir). Copytype can be linking instead (only used under UNIX)

Author
Aleksander Demko

◆ double_to_exp_string()

std::string scopira::tool::double_to_exp_string ( double  i,
int  pres = 25 
)

Converts a double to string - exponential edition

Parameters
ithe double
presthe number digits, 25 by default
Returns
a string version of the double
Author
Aleksander Demko

Referenced by double_to_string().

◆ double_to_string() [1/4]

std::string scopira::tool::double_to_string ( double  i)

Converts a double to string

Parameters
ithe double
Returns
a string version of the double
Author
Aleksander Demko

Referenced by double_to_string(), and int64_t_to_string().

◆ double_to_string() [2/4]

void scopira::tool::double_to_string ( double  i,
std::string &  out 
)
inline

Converts a double to string

Parameters
ithe double
outthe string to write out to
Author
Aleksander Demko

References double_to_exp_string(), double_to_string(), and string_to_double().

◆ double_to_string() [3/4]

std::string scopira::tool::double_to_string ( double  i,
int  pres 
)

Converts a double to string, with precision

Parameters
ithe double
presthe number of post-decimal point digits
Returns
a string version of the double
Author
Aleksander Demko

◆ double_to_string() [4/4]

int scopira::tool::double_to_string ( double  i,
char *  out,
int  buflen 
)

Converts a double to string.

Parameters
ithe double in question
outthe output buffer, must be non-null
buflenthe length of the buffer, including null
Returns
the actualy length written, including null
Author
Aleksander Demko

◆ filename_number()

std::string scopira::tool::filename_number ( const std::string &  fname,
int  num 
)

Meshes a number into a filename mast. For example, "blah###" and 20 produces "blah020".

Parameters
fnamethe input string, possibly containing the ## mast
numthe number to mesh in
Returns
the result of the mesh
Author
Aleksander Demko

Referenced by c_string_to_fixed_array().

◆ hexhash()

std::string scopira::tool::hexhash ( const scopira::tool::basic_array< byte_t > &  hash)

Returns the string representation of the given hash.

Author
Aleksander Demko

◆ hexhash_string()

std::string scopira::tool::hexhash_string ( const std::string &  s,
int  type = scopira::tool::hashoflow::sha1_c 
)

Returns a hex hash of the given string

Author
Aleksander Demko

Referenced by scopira::tool::hashoflow::failed().

◆ int64_t_to_string() [1/2]

std::string scopira::tool::int64_t_to_string ( int64_t  i)

Converts an int64_t to a string

Parameters
ithe int64_t
Returns
the string representation of the int64_t
Author
Aleksander Demko

Referenced by int64_t_to_string(), and size_t_to_string().

◆ int64_t_to_string() [2/2]

void scopira::tool::int64_t_to_string ( int64_t  i,
std::string &  out 
)
inline

Converts an int64_t to a string. Write out to an existing string

Parameters
ithe int64_t
outthe string to save the convertion to
Author
Aleksander Demko

References double_to_string(), int64_t_to_string(), and string_to_int64_t().

◆ int_to_ptr()

template<class C >
C* scopira::tool::int_to_ptr ( intptr_t  x)
inline

Converts a int to a pointer. See glib's GINT_TO_POINTER.

Author
Aleksander Demko

◆ int_to_string() [1/4]

void scopira::tool::int_to_string ( bool  val,
std::string &  out 
)
inline

Converts a bool to a string. Write out to an existing string

Parameters
valthe bool value
outthe string to save the convertion to
Author
Rodrigo Vivanco

Referenced by int_to_string().

◆ int_to_string() [2/4]

std::string scopira::tool::int_to_string ( int  i)

Converts an int to a string

Parameters
ithe integer
Returns
the string representation of the integer
Author
Aleksander Demko

◆ int_to_string() [3/4]

void scopira::tool::int_to_string ( int  i,
std::string &  out 
)
inline

Converts an int to a string. Write out to an existing string

Parameters
ithe integer
outthe string to save the convertion to
Author
Aleksander Demko

References int_to_string(), long_to_string(), and string_to_int().

◆ int_to_string() [4/4]

int scopira::tool::int_to_string ( int  i,
char *  out,
int  buflen 
)

Converts a int to string.

Parameters
ithe int in question
outthe output buffer, must be non-null
buflenthe length of the buffer, including null
Returns
the actualy length written, including null
Author
Aleksander Demko

◆ int_to_void()

void* scopira::tool::int_to_void ( intptr_t  x)
inline

See glib's GINT_TO_POINTER - fixed to void*.

Author
Aleksander Demko

◆ long_to_string() [1/2]

std::string scopira::tool::long_to_string ( long  i)

Converts an long to a string

Parameters
ithe long
Returns
the string representation of the long
Author
Aleksander Demko

Referenced by int_to_string(), and long_to_string().

◆ long_to_string() [2/2]

void scopira::tool::long_to_string ( long  i,
std::string &  out 
)
inline

Converts an long to a string. Write out to an existing string

Parameters
ithe long
outthe string to save the convertion to
Author
Aleksander Demko

References long_to_string(), size_t_to_string(), and string_to_long().

◆ lowercase() [1/2]

void scopira::tool::lowercase ( const std::string &  s,
std::string &  lower 
)

Converts a string to lower case. You may use the same string for both parameters

Parameters
sthe input string
lowerthe lowercase'd string
Author
Aleksander Demko

Referenced by compare().

◆ lowercase() [2/2]

std::string scopira::tool::lowercase ( const std::string &  s)

Converts a string to lowercase

Parameters
sthe input string
Returns
the lowercase'd string
Author
Aleksander Demko

◆ next_double() [1/2]

template<class GEN >
double scopira::tool::next_double ( GEN &  g,
double  mx 
)

Returns an double from [0..max).

Author
Aleksander Demko

◆ next_double() [2/2]

template<class GEN >
double scopira::tool::next_double ( GEN &  g)

Returns an double from [0..1).

Author
Aleksander Demko

◆ num_system_cpus()

int scopira::tool::num_system_cpus ( void  )

Gets the number of processors in this system. 1 is returned on platforms where this could not be easily detected.

Author
Aleksander Demko

◆ pad_left()

std::string scopira::tool::pad_left ( const std::string &  s,
int  width,
char  padchar = ' ' 
)

Justifies a string. If the given string is not width characters long, it will (left) pad the string with padchar and return that.

Parameters
sthe string to inspect
widthwith minimum width of the final string
padcharthe character to use for left padding
Returns
the possibly padded string
Author
Aleksander Demko

Referenced by compare().

◆ ptr_to_int()

intptr_t scopira::tool::ptr_to_int ( const void *  ptr)
inline

Converts a pointer to an int. Useful for unpacking ints where only a pointer could live. See glib's GPOINTER_TO_INT.

Author
Aleksander Demko

◆ qsort()

template<class T >
void scopira::tool::qsort ( T &  s,
int  lo0,
int  hi0 
)

This is a generic version of C.A.R Hoare's Quick Sort algorithm. This will handle arrays that are already sorted, and arrays with duplicate keys.

If you think of a one dimensional array as going from the lowest index on the left to the highest index on the right then the parameters to this function are lowest index or left and highest index or right. The first time you call this function it will be with the parameters 0, a.length - 1.

The sortable object must have the following form: int compare_element(int lidx, int ridx) [const] void swap_element(int lidx, int ridx)

Parameters
sthe sortable object
lo0left boundary of array partition, initially use 0
hi0right boundary of array partition, initially use size-1
Author
Aleksander Demko

◆ size_t_to_string() [1/2]

std::string scopira::tool::size_t_to_string ( size_t  i)

Converts an size_t to a string

Parameters
ithe size_t
Returns
the string representation of the size_t
Author
Aleksander Demko

Referenced by long_to_string(), and size_t_to_string().

◆ size_t_to_string() [2/2]

void scopira::tool::size_t_to_string ( size_t  i,
std::string &  out 
)
inline

Converts an size_t to a string. Write out to an existing string

Parameters
ithe size_t
outthe string to save the convertion to
Author
Aleksander Demko

References int64_t_to_string(), size_t_to_string(), and string_to_size_t().

◆ split_char()

bool scopira::tool::split_char ( const std::string &  src,
char  split,
std::string &  left_out,
std::string &  right_out 
)

Splits a string into two along a split character.

Parameters
srcthe string to inspect
splitthe character to use as the split marker
left_outon success, this will be the left side of the split
right_outon success, this will be the right side of the split
Returns
true if the split character and the string was split
Author
Aleksander Demko

Referenced by c_string_to_fixed_array().

◆ string_to_double() [1/2]

double scopira::tool::string_to_double ( const std::string &  s)

Convert a string to a double (doesn't report failure)

Parameters
sthe string
Returns
the decoded double
Author
Aleksander Demko

Referenced by double_to_string().

◆ string_to_double() [2/2]

bool scopira::tool::string_to_double ( const std::string &  s,
double &  outdouble 
)

Convert a string to a double (reports failure)

Parameters
sthe string
outdoublethe decoded double
Returns
true on success, false on failure
Author
Aleksander Demko

◆ string_to_fixed_array()

template<size_t N>
void scopira::tool::string_to_fixed_array ( const std::string &  src,
fixed_array< char, N > &  out 
)
throw (
)
inline

Copies std::string to a fixed_array<char, N>. The destination will always be null terminated and well formed.

Author
Aleksander Demko

◆ string_to_int() [1/2]

int scopira::tool::string_to_int ( const std::string &  s)

Converts a string to an int (without reporting failure)

Parameters
sthe string to convert
Returns
the integer representation of the string
Author
Aleksander Demko

Referenced by int_to_string().

◆ string_to_int() [2/2]

bool scopira::tool::string_to_int ( const std::string &  s,
int &  outint 
)

Converts a string to an int, and reports failure, if any

Parameters
sthe string to convert
outintthe int read from the string
Returns
true on success
Author
Aleksander Demko

◆ string_to_int64_t() [1/2]

int64_t scopira::tool::string_to_int64_t ( const std::string &  s)

Converts a string to an int64_t (without reporting failure)

Parameters
sthe string to convert
Returns
the int64_t representation of the string
Author
Aleksander Demko

Referenced by int64_t_to_string().

◆ string_to_int64_t() [2/2]

bool scopira::tool::string_to_int64_t ( const std::string &  s,
int64_t &  outint64_t 
)

Converts a string to an int64_t, and reports failure, if any

Parameters
sthe string to convert
outint64_tthe int64_t read from the string
Returns
true on success
Author
Aleksander Demko

◆ string_to_long() [1/2]

long scopira::tool::string_to_long ( const std::string &  s)

Converts a string to an long (without reporting failure)

Parameters
sthe string to convert
Returns
the long representation of the string
Author
Aleksander Demko

Referenced by long_to_string().

◆ string_to_long() [2/2]

bool scopira::tool::string_to_long ( const std::string &  s,
long &  outlong 
)

Converts a string to an long, and reports failure, if any

Parameters
sthe string to convert
outlongthe long read from the string
Returns
true on success
Author
Aleksander Demko

◆ string_to_size_t() [1/2]

size_t scopira::tool::string_to_size_t ( const std::string &  s)

Converts a string to an size_t (without reporting failure)

Parameters
sthe string to convert
Returns
the size_t representation of the string
Author
Aleksander Demko

Referenced by size_t_to_string().

◆ string_to_size_t() [2/2]

bool scopira::tool::string_to_size_t ( const std::string &  s,
size_t &  outsize_t 
)

Converts a string to an size_t, and reports failure, if any

Parameters
sthe string to convert
outsize_tthe size_t read from the string
Returns
true on success
Author
Aleksander Demko

◆ string_tokenize()

template<class container >
void scopira::tool::string_tokenize ( const std::string &  src,
container &  result,
const std::string &  delimiters = " \t\n" 
)

Splits and tokenizes a string into zero or more parts.

Parameters
containingthe container type (often implicit)
srcthe string to tokenize
resultthe container of strings that will be filled with the output tokens. It will initially be cleared.
delimitersone or more delimiters to use. Default is space, tab and newline.
Author
Aleksander Demko

◆ string_tokenize_word()

template<class container >
void scopira::tool::string_tokenize_word ( const std::string &  src,
container &  result,
const std::string &  substr 
)

splits a string using the provided sub-string the string is only split using the sub-string provided

Author
Aleksander Demko

◆ time_seed()

int scopira::tool::time_seed ( void  )

returns a "random" number, usefull for initing (this is usually time(), so its not random at all. it might have some pid stuff thrown in

Author
Aleksander Demko

◆ tool_output()

scopira::tool::oflow_i& scopira::tool::tool_output ( void  )

Default tool_output stream handler.

This one simply returns gm_tool_output_stream. Since that's initially null, it will also set it if need be (while emitting a warning) just to simplify things.

Author
Aleksander Demko

Referenced by scopira::tool::output_stack::output_stack().

◆ trim_left()

void scopira::tool::trim_left ( std::string &  str)

trims whitespace from the left side of the string

Parameters
strstring to trim whitespace from
Author
Aleksander Demko

Referenced by c_string_to_fixed_array().

◆ trim_right()

void scopira::tool::trim_right ( std::string &  str)

trims whitespace from the right side of the string

Parameters
strstring to trim whitespace from
Author
Aleksander Demko

Referenced by c_string_to_fixed_array().

◆ uppercase() [1/2]

void scopira::tool::uppercase ( const std::string &  s,
std::string &  upper 
)

Converts a string to upper case. You may use the same string for both parameters

Parameters
sthe input string
upperthe uppercase'd string
Author
Aleksander Demko

Referenced by compare().

◆ uppercase() [2/2]

std::string scopira::tool::uppercase ( const std::string &  s)

Converts a string to uppercase

Parameters
sthe input string
Returns
the uppercase'd string
Author
Aleksander Demko

Variable Documentation

◆ gm_tool_output

scopira::tool::output_func scopira::tool::gm_tool_output

General output string, useful for debug messages.

By default, this will be set to _tool_output(). You (well, engines) will often set this to something else.

This returns a general, global thread where you can send output to. Under a true engine, this will be engine::get_outflow(), but may be something else under different environments.

Author
Aleksander Demko

Referenced by scopira::tool::output_stack::output_stack().

◆ gm_tool_output_stream

scopira::tool::oflow_i* scopira::tool::gm_tool_output_stream

The stream pointer used by the default handler, tool_output.

You may set this (while leaving the default handler) if you'd like. Take care to clean up whatever instance you place here.

Author
Aleksander Demko

Referenced by scopira::tool::output_stack::output_stack().