translations.h File Reference
General functions for smoothing over the difference between the C and C++ data, cross platform integration, and debug macro definitions. More...
#include "integers.h"
#include "cross_platform.h"
Go to the source code of this file.
Mathematical operations | |
Each function performs the indicated operation using each operand and placing the result in the first argument (overwriting the first operand).
The exceptions are the euclide and boolean operations. It should be noted that infinint operations are in general much slower than fixed size integer operations. This is to be expected of course. However, if the data you are using will not overflow a fixed size variable, use that. It's just faster. Sample code: dar_infinint* a = dar_infi(1000); dar_infinint* b = dar_infds("10345"); dar_infinint* c = dar_infhs("4A3F10"); // a += b dar_infinint_add( &a, b ); // d = a + b dar_infinint_add( &a, b ); dar_infinint* d = dar_infinint_copy( a ); // d = a + b saving a dar_infinint* t = dar_infinint_copy( a ); dar_infinint_add( &a, b ); dar_infinint* d = dar_infinint_copy( a ); a = dar_infinint_copy( t ); dar_infinint_destroy( t ); // a++ dar_infinint_increment( a ); @endverbatim | |
DLLIMPORT void | dar_infinint_add (dar_infinint **a, dar_infinint *b) |
DLLIMPORT void | dar_infinint_sub (dar_infinint **a, dar_infinint *b) |
DLLIMPORT void | dar_infinint_mult (dar_infinint **a, dar_infinint *b) |
DLLIMPORT void | dar_infinint_div (dar_infinint **a, dar_infinint *b) |
DLLIMPORT void | dar_infinint_pow (dar_infinint **a, dar_infinint *b) |
DLLIMPORT void | dar_infinint_powi (dar_infinint **a, int exp) |
DLLIMPORT void | dar_infinint_shiftl (dar_infinint **a, dar_infinint *b) |
DLLIMPORT void | dar_infinint_shiftli (dar_infinint **a, int bit) |
DLLIMPORT void | dar_infinint_shiftr (dar_infinint **a, dar_infinint *b) |
DLLIMPORT void | dar_infinint_shiftri (dar_infinint **a, int bit) |
DLLIMPORT void | dar_infinint_mod (dar_infinint **a, dar_infinint *b) |
DLLIMPORT void | dar_infinint_increment (dar_infinint **a) |
DLLIMPORT void | dar_infinint_decrement (dar_infinint **a) |
DLLIMPORT void | dar_infinint_euclide (dar_infinint *a, dar_infinint *b, dar_infinint **q, dar_infinint **r) |
DLLIMPORT bool | dar_infinint_comp_eq (dar_infinint *a, dar_infinint *b) |
DLLIMPORT bool | dar_infinint_comp_leq (dar_infinint *a, dar_infinint *b) |
DLLIMPORT bool | dar_infinint_comp_l (dar_infinint *a, dar_infinint *b) |
DLLIMPORT bool | dar_infinint_comp_geq (dar_infinint *a, dar_infinint *b) |
DLLIMPORT bool | dar_infinint_comp_g (dar_infinint *a, dar_infinint *b) |
DLLIMPORT bool | dar_infinint_comp_neq (dar_infinint *a, dar_infinint *b) |
Infinint boxing | |
Convenience functions for boxing integer data types into an infinint object.
Boxing comes in two forms: Fixed length and variable length. Fixed length boxing converts integer data types to a boxed struct. Variable length converts either c strings or binary infinint data into an infinint. | |
DLLIMPORT dar_infinint * | dar_infpi (int num) |
Create infinint from platform specified integer. | |
DLLIMPORT dar_infinint * | dar_infi (U_32 num) |
Create infinint from library (libdar) specified integer. | |
DLLIMPORT dar_infinint * | dar_infu32 (U_32 num) |
Create infinint from unsigned 32 bit. | |
DLLIMPORT dar_infinint * | dar_infu64 (U_64 num) |
Create infinint from unsigned 64 bit. | |
DLLIMPORT dar_infinint * | dar_infds (char *num) |
Create infinint from decimal string. | |
DLLIMPORT dar_infinint * | dar_infhs (char *num) |
Create infinint from hex string. | |
DLLIMPORT dar_infinint * | dar_infbin (U_8 *num) |
Create infinint from binary infinint data. | |
Infinint unboxing | |
Convenience functions for unboxing infinint overflow protectors into the desired format.
The unboxing functions come in two varieties: fixed length targets and variable length targets. Fixed length targets (integer data types of various size) come with an overflow checker in the form of a boolean output parameter. This can be set to null if overflow checking is not desired. Variable length targets do not overflow by definition (except for memory exhausts), so the output parameter is set to the length of the returned data. This is not neccessarily as useful for returned strings (they are all null terminated anyway) but can be vital for using binary infinint data). Note that when passing infinint binary data to the library, this length is not needed. The infinint binary format has its own length determining features (a dump length header). | |
DLLIMPORT int | dar_piinf (bool *overflow, dar_infinint *box) |
Extract platform specified integer from infinint. | |
DLLIMPORT U_32 | dar_iinf (bool *overflow, dar_infinint *box) |
Extract library (libdar) defined integer from infinint. | |
DLLIMPORT U_32 | dar_u32inf (bool *overflow, dar_infinint *box) |
Extract unsigned 32 bit from infinint. | |
DLLIMPORT U_64 | dar_u64inf (bool *overflow, dar_infinint *box) |
Extract unsigned 64 bit from infinint. | |
DLLIMPORT char * | dar_dsinf (U_I *length, dar_infinint *box) |
Extract decimal string from infinint. | |
DLLIMPORT char * | dar_hsinf (U_I *length, dar_infinint *box) |
Extract hex string from infinint. | |
DLLIMPORT U_8 * | dar_bininf (U_I *length, dar_infinint *box) |
Extract binary infinint data. | |
Defines | |
#define | LIBDARC_EXCEPTION(container, etype, emessage) |
Creates exception message and sends output to DEBUG if applicable. | |
Functions | |
DLLIMPORT void | dar_infinint_destroy (dar_infinint *ref) |
Have the libdar library destroy the infinint object. | |
DLLIMPORT dar_infinint * | dar_infinint_copy (dar_infinint *ref) |
Creates a copy of a given infinint. |
Detailed Description
General functions for smoothing over the difference between the C and C++ data, cross platform integration, and debug macro definitions.
Definition in file translations.h.
Define Documentation
|
Value: container->type = etype; \ container->message = (char*)malloc(strlen(emessage) + 1); \ if ( container->message != NULL ) { strcpy(exception->message, emessage); } \ DEBUG("Throwing exception: "); DEBUG(emessage); DEBUG("\n");
Definition at line 81 of file translations.h. Referenced by dar_drc_parse_xml_file(), dar_drc_parse_xml_memory(), dar_drc_write_xml_file(), dar_op_archive_close(), dar_op_archive_create(), dar_op_archive_diff(), dar_op_archive_extract(), dar_op_archive_get_children_of(), dar_op_archive_isolate(), dar_op_archive_list(), dar_op_archive_open(), and dar_op_archive_test(). |
Function Documentation
|
Extract binary infinint data.
Storage size is exactly equal to Definition at line 596 of file translations.cpp. |
|
Extract decimal string from infinint.
Storage size is Definition at line 573 of file translations.cpp. |
|
Extract hex string from infinint.
Storage size is Definition at line 586 of file translations.cpp. |
|
Create infinint from binary infinint data. Input byte array must be correctly formated infinint data. Consult a libdar infinint binary dump specification before attempting to use this function. Definition at line 466 of file translations.cpp. |