GLYLIB
0.3.0b
|
Classes | |
struct | llcharset |
Defines | |
#define | _GNU_SOURCE |
Functions | |
void | myusage (const char *USAGE) |
Prints usage message and exits(1). | |
void | mywhine (const char *whinetext) |
Prints error message and exits(1). | |
void | mywhineusage (const char *whinetext, const char *USAGE) |
Prints error message and usage and exits(1). | |
const char * | mytime (const char *) |
Gets the time in a nice format. | |
const char * | prune_string_whitespace (const char *I) |
const char * | get_char_string (const char *x, char j, int w) |
const char * | get_float_string (double x, char j, int w, int d) |
const char * | get_exp_string (double x, char j, int w, int d) |
#define _GNU_SOURCE |
const char* get_char_string | ( | const char * | x, |
char | j, | ||
int | w | ||
) |
Returns a character string of width w characters and justified as per the character in j (l or L or r or R for left or right) based on the string provided in x.
Functions that produce variable-format output for numbers and strings.
There must be some already-written way to do this, but I suspect I can write the functions before I can figure that out. So, these functions will generate strings when one does not know ahead of time the output format.
For example:
Assume you know you need to write out a double variable in exponential notation, but that the program will determine the proper number of decimal places and character width. These functions will help.
So, where normally, you might write:
You can do, instead:
Normally, this is a lot of bother. But, at times, it can be useful.
I'm lazy, so the maximum number of digits that can be printed is about 145. For float values, that number is divided into pre- and post-decimal, which makes for some limits. Hopefully, these limits are generous enough for most applications. This is hard-coded in the number->string functions below. There are much cooler ways to do this, and anyone who wants to code them is very welcome to do so.
If the incoming string (x) is longer than outgoing size (w), write something to stderr and print what fits
< Allocate memory for new string
Definition at line 104 of file string_utilities.c.
References mywhine().
Referenced by get_PDB_line_for_ATOM().
const char* get_exp_string | ( | double | x, |
char | j, | ||
int | w, | ||
int | d | ||
) |
Returns a character string corresponding to a exponential notation representation of the number supplied by x. The return string will have a width of w characters, d of which will be integers appearing to the right of the decimal point. The number will be justified as per the character in j (l or L or r or R for left or right).
Definition at line 340 of file string_utilities.c.
const char* get_float_string | ( | double | x, |
char | j, | ||
int | w, | ||
int | d | ||
) |
Returns a character string corresponding to a floating point representation of the number supplied by x. The return string will have a width of w characters, d of which will be integers appearing to the right of the decimal point. The number will be justified as per the character in j (l or L or r or R for left or right).
If the incoming string (x) is longer than outgoing size (w), write something to stderr and print what fits
< Allocate memory for new string
Otherwise, print a really wide version of the incoming number to a really wide string Here, the string is 150 chars wide, and 74 of those chars are decimal digits. Another 74 are allocated for the integer part of the float representation. That leaves two spaces, one for a decimal point and another for '-' if needed. At present, this function will not return a '+' sign for positive values.
< 150 wide, minus +/- designation and decimal point and half of that for the fraction
< tst=integer part ; d=fraction part ; 2 = space for . & sign (\0 comes later)
< the starting point in the big number
< Allocate memory for new string
< the ending point in the big number
< check the integer where the null character will finally go
< but only if that won't put us over 150 chars (shouldn't ever happen, really)
< Allocate memory for new string
See if we have a "9X' situation where we have to round up
< Print the first character (space or '-')
< Print a 1 in the next space
For the rest of the string-1, for every 9 add a zero (one space over). Copy any decimals as-is
< Ensure null termination
Increment the "first_not_nine" digit
Change other nines to zeros
< Ensure null termination
< if that situation isn't present
Increment the "end-1" digit
< Ensure null termination
< Ensure termination.
< Allocate memory for new string
< Calculated the padding needed (if any)
Definition at line 150 of file string_utilities.c.
References mywhine().
Referenced by get_PDB_line_for_ATOM().
const char* mytime | ( | const char * | ) |
Gets the time in a nice format.
Returns a the time in one of four popular formats.
Usage:
const char * mylocaltimestring,mytime(format)
-for example:
strcpy(mylocaltimestring,mytime("format"));
where:
format is one of:
[keyword] [example]
YYYYMMDD 20070321
YYYYMMDDhhmmss 20070321152110
pretty Wed, 21 March, 2007
longpretty 15:12:10, Wed, 21 March, 2007
Definition at line 17 of file mytime.c.
References DATE, and mywhine().
void myusage | ( | const char * | USAGE | ) |
void mywhine | ( | const char * | whinetext | ) |
Prints error message and exits(1).
Prints error message and exits(1). Prints the following:
"This program encountered the following error and will exit:
whinetext "
Definition at line 7 of file mywhine.c.
Referenced by add_assembly_to_ensemble(), add_to_moiety_selection(), add_trajcrds_to_prmtop_assembly(), crdsnaps(), find_assembly_top_level_atoms_by_N(), find_molecule_atoms_by_N(), find_molecule_atoms_by_n(), find_molecule_residues_by_N(), find_molecule_residues_by_n(), find_molecules_molbond_array(), find_residue_atoms_by_n(), follow_find_molecule_amber_prmtop_bond_target(), follow_molecule_atom_molbonds_for_contree(), follow_molecule_atom_nodes_from_bonds(), follow_molecule_residue_nodes_from_bonds(), follow_residue_atom_nodes_from_bonds(), get_alt_rms_mol(), get_alt_rms_res(), get_assembly_molecule_COM(), get_assembly_PDB_ATOM_lines(), get_char_string(), get_ensemble_COM(), get_ensemble_PDB_ATOM_lines(), get_float_string(), get_geometric_center(), get_geometric_center_dp(), get_meanvar_array(), get_moiety_selection_assembly(), get_molecule_COM(), get_molecule_PDB_ATOM_lines(), get_molecule_point_charge_dipole(), get_PDB_line_for_ATOM(), get_residue_COM(), getAssembly(), gly_get_current_working_directory(), load_atypes(), load_dlg_mol(), make_ATOM_HETATM(), mytime(), normalize_molecule_vectors(), outputAsmblPDB(), outputMolPDB(), parse_amber_prmtop(), read_amber8_mden(), read_amber_prmtop_asis(), read_prep(), read_prepatom(), rotate_vector_to_Z_list(), rotate_vector_to_Z_M(), set_assembly_atom_molbonds_from_PDB_CONECT(), set_assembly_residue_molbonds_from_PDB_LINK(), set_atom_element_best_guess(), set_connection_tree_molecule_atoms(), set_molecule_atom_nodes_from_bonds(), set_molecule_residue_molbonds(), set_molecule_residue_nodes_from_bonds(), set_residue_atom_nodes_from_bonds(), shift_molecule_atoms_by_vector_scale(), translate_ensemble_by_XYZ(), translate_molecule_by_XYZ(), translate_residue_by_XYZ(), translate_zero_to_coord_M(), and write_amber_prmtop().
void mywhineusage | ( | const char * | whinetext, |
const char * | USAGE | ||
) |
Prints error message and usage and exits(1).
Prints usage and an error message and exits(1). See mywhine for more information. Prints a usage statement after the whinetext
Definition at line 6 of file mywhineusage.c.
const char* prune_string_whitespace | ( | const char * | I | ) |
Prunes leading and trailing whitespace from string I
Function to prune leading and trailing whitespace from a string
< A counter
< Length (meaning varies)
< Length of incoming string
< Start point for pruned string
< End point for pruned string
< Outgoing string
< Begin at the last character
Definition at line 16 of file string_utilities.c.
Referenced by add_to_moiety_selection(), get_keysvals_from_slurp(), and parse_amber_prmtop().