MAOS
Multithreaded Adaptive Optics Simulator
|
Functions | |
int | readstr_strarr (char ***res, int len, int relax, const char *key, const char *sdata) |
double | readstr_num (const char *key, const char *data, char **endptr0) |
int | readstr_numarr (void **ret, int *nrow0, int *ncol0, int len, int relax, int type, const char *key, const char *data) |
void | trim_string (const char **pheader, const char **pend) |
const char * | search_keyword (const char *keywords, const char *key) |
double | search_keyword_num (const char *keywords, const char *key) |
double | search_keyword_num_valid (const char *keywords, const char *key) |
double | search_keyword_num_default (const char *keywords, const char *key, double value0) |
Group all routines that are used to parse values from string that contain key=value pairs.
int readstr_strarr | ( | char *** | res, |
int | len, | ||
int | relax, | ||
const char * | key, | ||
const char * | sdata | ||
) |
Group all routines that are used to parse values from string that contain key=value pairs. Obtain a string array value from the key. String entries must be separated by coma [,]. Enclosing with quote is optional, but necessary to protect spaces. Examples: []: one empty string [,]: two empty strings [a,b]: two strings: "a" and "b"; [a,b,]: three strings, "a", "b", and "" ['a b']: one string "a b".
[out] | res | Result |
[in] | len | max number f values to read |
[in] | relax | Whether fewer entries are permitted. If true, will copy from last. |
[in] | key | the key that needs the value. |
[in] | sdata | Input string |
double readstr_num | ( | const char * | key, |
const char * | data, | ||
char ** | endptr0 | ||
) |
Read in a number from the value string. Will interpret +,0,*,/ operators if there is nospace in between. *endptr0 will be updated to point to the next valid entry, or at separator like coma (spaced are skipped).
[in] | key | the key that needs the value. |
[in] | data | Input string |
[out] | endptr0 | Location in Input string after readed number. |
int readstr_numarr | ( | void ** | ret, |
int * | nrow0, | ||
int * | ncol0, | ||
int | len, | ||
int | relax, | ||
int | type, | ||
const char * | key, | ||
const char * | data | ||
) |
Read numerical array from a string. if len is nonzero, ret should be already allocated. NOTICe that continuous numbers are readin as column vector, not row vector(as in matlab) Can read in the following formats: [1 2 3] as 3 rows, 1 col [1 2 3] in memory [1 2 3]+2 as [3 4 5] in memory 2[1 2 3] or [1 2 3]*2 as [2 4 6] in memory [1 2 3]/2 as [0.5 1 1.5] in memory 2/[1 2 3] as [2/1 2/2 2/3] in memory 2/[1 2 3]*2+1 as [5 3 7/3] in memory
2-d arrays are groups as column vecotrs (in contrast to matlab that uses rows); semi-colon is used to separate columns. [1 2 3; 4 5 6] is 2 d array, 3 rows, 2 columns. In memory is stored as [1 2 3 4 5 6] transpose is supported: [1 2 3; 4 5 6]' is 2 d array, 2 rows, 3 columns. In memory is stored as [1 4 2 5 3 6]
when there is no [], only read until there is ';', '
', or end of str.
[out] | ret | Result |
[out] | nrow0 | Number of rows (nx) |
[out] | ncol0 | Number of columns (ny) |
[in] | len | Max number of values to read. |
[in] | relax | Whether fewer entries are permitted. If true, will copy from last. |
[in] | type | Data type |
[in] | key | the key that needs the value. |
[in] | data | Input string |
void trim_string | ( | const char ** | pstart, |
const char ** | pend | ||
) |
update header and end to point to valid region. Does not modify the string
const char* search_keyword | ( | const char * | keywords, |
const char * | key | ||
) |
Search and return the value correspond to key. Case is ignored; NULL if not found. Do not free the returned pointer. The key must be preceeded by space, semicolon, coma or new line (isspace), and succeeded by = sign.
double search_keyword_num | ( | const char * | keywords, |
const char * | key | ||
) |
Read a number from the header with key
double search_keyword_num_valid | ( | const char * | keywords, |
const char * | key | ||
) |
Read a number from the header and verify.
double search_keyword_num_default | ( | const char * | keywords, |
const char * | key, | ||
double | value0 | ||
) |
Read a number from the header and use value0 if not found.