Scopira
20080306
|
Typedefs | |
typedef uni01_dist< lincon_core > | lincon_01 |
typedef unireal_dist< lincon_core > | lincon_real |
typedef unismallint_dist< lincon_core > | lincon_smallint |
typedef uniint_dist< lincon_core > | lincon_int |
typedef uni01_dist< scopira::tool::rand48 > | rand48_01 |
typedef unireal_dist< scopira::tool::rand48 > | rand48_real |
typedef unismallint_dist< scopira::tool::rand48 > | rand48_smallint |
typedef uniint_dist< scopira::tool::rand48 > | rand48_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 > | |
object * | objloadfunc_g (void) |
void | flow_reg_imp (const std::type_info &id, const char *name, scopira::tool::objflowloader::loadfunc_t loader) |
scopira::tool::oflow_i & | tool_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 > | |
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_i * | gm_tool_output_stream |
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.
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)
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
typedef scopira::tool::oflow_i&(* scopira::tool::output_func) (void) |
A function type that returns an output stream
typedef void *(* scopira::tool::runfunc_t)(void *) |
a function thet can be called by a thread run routine you should return 0, i guess
|
inline |
Converts a bool to a string
val | the bool value |
|
inline |
Generic byte swapper. Does nothing.
Referenced by byte_swap_all().
|
inline |
Swaps the byte (endianess) of an double.
References byte_swap_all().
|
inline |
Swaps the byte (endianess) of an float.
|
inline |
Swaps the byte (endianess) of an int. Currently only used in binflow.
|
inline |
Swaps the byte (endianess) of an int64_t.
|
inline |
Swaps the byte (endianess) of a short. Currently only used in binflow.
|
inline |
Swaps the byte (endianess) of an uint64_t.
void scopira::tool::byte_swap_all | ( | ITER | head, |
ITER | tail | ||
) |
Applies byte_swap to every element in the iteration
References byte_swap().
Referenced by byte_swap< double >(), scopira::basekit::narray< scopira::tool::uuid >::load(), scopira::basekit::nslice< T, DIM >::load(), scopira::basekit::narray< scopira::tool::uuid >::save(), scopira::basekit::nslice< T, DIM >::save(), and scopira::basekit::const_nslice< T, DIM >::save().
|
inline |
Copies null terminated C string to a fixed_array<char, N>. The destination will always be null terminated and well formed.
References filename_number(), split_char(), trim_left(), and trim_right().
std::string scopira::tool::close_and_hexhash | ( | hashoflow & | o | ) |
Closes the given hashoflow and returns the hash, as a hex string
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 <)
References lowercase(), pad_left(), and uppercase().
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)
std::string scopira::tool::double_to_exp_string | ( | double | i, |
int | pres = 25 |
||
) |
Converts a double to string - exponential edition
i | the double |
pres | the number digits, 25 by default |
Referenced by double_to_string().
std::string scopira::tool::double_to_string | ( | double | i | ) |
Converts a double to string
i | the double |
Referenced by double_to_string(), and int64_t_to_string().
|
inline |
Converts a double to string
i | the double |
out | the string to write out to |
References double_to_exp_string(), double_to_string(), and string_to_double().
std::string scopira::tool::double_to_string | ( | double | i, |
int | pres | ||
) |
Converts a double to string, with precision
i | the double |
pres | the number of post-decimal point digits |
int scopira::tool::double_to_string | ( | double | i, |
char * | out, | ||
int | buflen | ||
) |
Converts a double to string.
i | the double in question |
out | the output buffer, must be non-null |
buflen | the length of the buffer, including null |
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".
fname | the input string, possibly containing the ## mast |
num | the number to mesh in |
Referenced by c_string_to_fixed_array().
std::string scopira::tool::hexhash | ( | const scopira::tool::basic_array< byte_t > & | hash | ) |
Returns the string representation of the given hash.
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
Referenced by scopira::tool::hashoflow::failed().
std::string scopira::tool::int64_t_to_string | ( | int64_t | i | ) |
Converts an int64_t to a string
i | the int64_t |
Referenced by int64_t_to_string(), and size_t_to_string().
|
inline |
Converts an int64_t to a string. Write out to an existing string
i | the int64_t |
out | the string to save the convertion to |
References double_to_string(), int64_t_to_string(), and string_to_int64_t().
|
inline |
Converts a int to a pointer. See glib's GINT_TO_POINTER.
|
inline |
Converts a bool to a string. Write out to an existing string
val | the bool value |
out | the string to save the convertion to |
Referenced by int_to_string().
std::string scopira::tool::int_to_string | ( | int | i | ) |
Converts an int to a string
i | the integer |
|
inline |
Converts an int to a string. Write out to an existing string
i | the integer |
out | the string to save the convertion to |
References int_to_string(), long_to_string(), and string_to_int().
int scopira::tool::int_to_string | ( | int | i, |
char * | out, | ||
int | buflen | ||
) |
Converts a int to string.
i | the int in question |
out | the output buffer, must be non-null |
buflen | the length of the buffer, including null |
|
inline |
See glib's GINT_TO_POINTER - fixed to void*.
std::string scopira::tool::long_to_string | ( | long | i | ) |
Converts an long to a string
i | the long |
Referenced by int_to_string(), and long_to_string().
|
inline |
Converts an long to a string. Write out to an existing string
i | the long |
out | the string to save the convertion to |
References long_to_string(), size_t_to_string(), and string_to_long().
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
s | the input string |
lower | the lowercase'd string |
Referenced by compare().
std::string scopira::tool::lowercase | ( | const std::string & | s | ) |
Converts a string to lowercase
s | the input string |
double scopira::tool::next_double | ( | GEN & | g, |
double | mx | ||
) |
Returns an double from [0..max).
double scopira::tool::next_double | ( | GEN & | g | ) |
Returns an double from [0..1).
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.
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.
s | the string to inspect |
width | with minimum width of the final string |
padchar | the character to use for left padding |
Referenced by compare().
|
inline |
Converts a pointer to an int. Useful for unpacking ints where only a pointer could live. See glib's GPOINTER_TO_INT.
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)
s | the sortable object |
lo0 | left boundary of array partition, initially use 0 |
hi0 | right boundary of array partition, initially use size-1 |
std::string scopira::tool::size_t_to_string | ( | size_t | i | ) |
Converts an size_t to a string
i | the size_t |
Referenced by long_to_string(), and size_t_to_string().
|
inline |
Converts an size_t to a string. Write out to an existing string
i | the size_t |
out | the string to save the convertion to |
References int64_t_to_string(), size_t_to_string(), and string_to_size_t().
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.
src | the string to inspect |
split | the character to use as the split marker |
left_out | on success, this will be the left side of the split |
right_out | on success, this will be the right side of the split |
Referenced by c_string_to_fixed_array().
double scopira::tool::string_to_double | ( | const std::string & | s | ) |
Convert a string to a double (doesn't report failure)
s | the string |
Referenced by double_to_string().
bool scopira::tool::string_to_double | ( | const std::string & | s, |
double & | outdouble | ||
) |
Convert a string to a double (reports failure)
s | the string |
outdouble | the decoded double |
|
inline |
Copies std::string to a fixed_array<char, N>. The destination will always be null terminated and well formed.
int scopira::tool::string_to_int | ( | const std::string & | s | ) |
Converts a string to an int (without reporting failure)
s | the string to convert |
Referenced by int_to_string().
bool scopira::tool::string_to_int | ( | const std::string & | s, |
int & | outint | ||
) |
Converts a string to an int, and reports failure, if any
s | the string to convert |
outint | the int read from the string |
int64_t scopira::tool::string_to_int64_t | ( | const std::string & | s | ) |
Converts a string to an int64_t (without reporting failure)
s | the string to convert |
Referenced by int64_t_to_string().
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
s | the string to convert |
outint64_t | the int64_t read from the string |
long scopira::tool::string_to_long | ( | const std::string & | s | ) |
Converts a string to an long (without reporting failure)
s | the string to convert |
Referenced by long_to_string().
bool scopira::tool::string_to_long | ( | const std::string & | s, |
long & | outlong | ||
) |
Converts a string to an long, and reports failure, if any
s | the string to convert |
outlong | the long read from the string |
size_t scopira::tool::string_to_size_t | ( | const std::string & | s | ) |
Converts a string to an size_t (without reporting failure)
s | the string to convert |
Referenced by size_t_to_string().
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
s | the string to convert |
outsize_t | the size_t read from the string |
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.
containing | the container type (often implicit) |
src | the string to tokenize |
result | the container of strings that will be filled with the output tokens. It will initially be cleared. |
delimiters | one or more delimiters to use. Default is space, tab and newline. |
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
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
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.
Referenced by scopira::tool::output_stack::output_stack().
void scopira::tool::trim_left | ( | std::string & | str | ) |
trims whitespace from the left side of the string
str | string to trim whitespace from |
Referenced by c_string_to_fixed_array().
void scopira::tool::trim_right | ( | std::string & | str | ) |
trims whitespace from the right side of the string
str | string to trim whitespace from |
Referenced by c_string_to_fixed_array().
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
s | the input string |
upper | the uppercase'd string |
Referenced by compare().
std::string scopira::tool::uppercase | ( | const std::string & | s | ) |
Converts a string to uppercase
s | the input string |
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.
Referenced by scopira::tool::output_stack::output_stack().
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.
Referenced by scopira::tool::output_stack::output_stack().