diff --git a/htslib/hts.h b/htslib/hts.h index c9ce386ad3..03b8bbb37a 100644 --- a/htslib/hts.h +++ b/htslib/hts.h @@ -477,18 +477,22 @@ hts_idx_t *hts_idx_load2(const char *fn, const char *fnidx); int hts_idx_get_stat(const hts_idx_t* idx, int tid, uint64_t* mapped, uint64_t* unmapped); uint64_t hts_idx_get_n_no_coor(const hts_idx_t* idx); +#define HTS_PARSE_THOUSANDS_SEP 1 +// ...other parser flags may follow... + /// Parse a numeric string /** The number may be expressed in scientific notation, and may contain commas in the integer part (before any decimal point or E notation). - @param str String to be parsed - @param end If non-NULL, set on return to point to the first character - in @a str after those forming the parsed number + @param str String to be parsed + @param strend If non-NULL, set on return to point to the first character + in @a str after those forming the parsed number + @param flags Or'ed-together combination of HTS_PARSE_* flags @return Converted value of the parsed number. When @a end is NULL, a warning will be printed (if hts_verbose is 2 or more) if there are any trailing characters after the number. */ -long long hts_parse_decimal(const char *str, char **end); +long long hts_parse_decimal(const char *str, char **strend, int flags); /// Parse a "CHR:START-END"-style region string /** @param str String to be parsed @@ -496,9 +500,22 @@ long long hts_parse_decimal(const char *str, char **end); @param end Set on return to the 1-based end of the region @return Pointer to the colon or '\0' after the reference sequence name, or NULL if @a str could not be parsed. + @note Equivalent to hts_parse_region(str, beg, end, NULL, HTS_PARSE_THOUSANDS_SEP) */ const char *hts_parse_reg(const char *str, int *beg, int *end); +/// Parse a "CHR:START-END"-style region string +/** @param str String to be parsed + @param beg Set on return to the 0-based start of the region + @param end Set on return to the 1-based end of the region + @param strend If non-NULL, set on return to point to the first character + in @a str after those forming the parsed region + @param flags Or'ed-together combination of HTS_PARSE_* flags + @return Pointer to the colon or '\0' after the reference sequence name, + or NULL if @a str could not be parsed. +*/ +const char *hts_parse_region(const char *str, int *beg, int *end, char **strend, int flags); + hts_itr_t *hts_itr_query(const hts_idx_t *idx, int tid, int beg, int end, hts_readrec_func *readrec); void hts_itr_destroy(hts_itr_t *iter);