GLYLIB
0.3.0b
|
00001 /** \file gly_codeutils.h 00002 \brief Header file that loads utilities to facilitate programming 00003 */ 00004 #if !defined(GLYLIB_CODING_UTILITIES) 00005 #define GLYLIB_CODING_UTILITIES 00006 00007 /** \addtogroup CODE_UTILS 00008 * @{ 00009 */ 00010 /******************** STRUCTURES ******************/ 00011 00012 /** An array of characters for times when a 2D char array might be confusing */ 00013 typedef struct { 00014 char *T; 00015 } llcharset; 00016 00017 00018 /******************** FUNCTIONS ******************/ 00019 00020 /** Prints usage.*/ 00021 void myusage(const char *USAGE); ///< Prints usage message and exits(1). 00022 00023 /** Prints error message and exits(1). 00024 Prints the following: 00025 00026 "This program encountered the following error and will exit: 00027 00028 whinetext " 00029 */ 00030 void mywhine(const char *whinetext); ///< Prints error message and exits(1). 00031 00032 /** Prints usage and an error message and exits(1). See mywhine for more information. 00033 Prints a usage statement after the whinetext*/ 00034 void mywhineusage(const char *whinetext,const char *USAGE);///< Prints error message and usage and exits(1). 00035 00036 /** Returns a the time in one of four popular formats. 00037 * 00038 * Usage: 00039 * 00040 * const char * mylocaltimestring,mytime(format) 00041 * 00042 * -for example: 00043 * 00044 * strcpy(mylocaltimestring,mytime("format")); 00045 * 00046 * where: 00047 * 00048 * format is one of: 00049 * 00050 * [keyword] [example] 00051 * 00052 * YYYYMMDD 20070321 00053 * 00054 * YYYYMMDDhhmmss 20070321152110 00055 * 00056 * pretty Wed, 21 March, 2007 00057 * 00058 * longpretty 15:12:10, Wed, 21 March, 2007 00059 */ 00060 const char * mytime(const char*); ///< Gets the time in a nice format 00061 00062 /** Prunes leading and trailing whitespace from string I*/ 00063 const char *prune_string_whitespace(const char *I); 00064 00065 /** Returns a character string of width w characters and justified as 00066 per the character in j (l or L or r or R for left or right) based on the 00067 string provided in x. */ 00068 const char * get_char_string(const char *x, char j, int w); 00069 00070 /** Returns a character string corresponding to a floating point 00071 representation of the number supplied by x. The return string will have a 00072 width of w characters, d of which will be integers appearing to the right of 00073 the decimal point. The number will be justified as per the character in j 00074 (l or L or r or R for left or right). */ 00075 const char * get_float_string(double x, char j, int w, int d); 00076 00077 /** Returns a character string corresponding to a exponential notation 00078 representation of the number supplied by x. The return string will have a 00079 width of w characters, d of which will be integers appearing to the right of 00080 the decimal point. The number will be justified as per the character in j 00081 (l or L or r or R for left or right). */ 00082 const char * get_exp_string(double x, char j, int w, int d); 00083 00084 /** @}*/ 00085 00086 #endif