Skip to content

Commit faea4e9

Browse files
committed
Add HTS_PARSE_* parsing flags [DRAFT]
1 parent 306664a commit faea4e9

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

htslib/hts.h

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,28 +477,45 @@ hts_idx_t *hts_idx_load2(const char *fn, const char *fnidx);
477477
int hts_idx_get_stat(const hts_idx_t* idx, int tid, uint64_t* mapped, uint64_t* unmapped);
478478
uint64_t hts_idx_get_n_no_coor(const hts_idx_t* idx);
479479

480+
#define HTS_PARSE_THOUSANDS_SEP 1
481+
// ...other parser flags may follow...
482+
480483
/// Parse a numeric string
481484
/** The number may be expressed in scientific notation, and may contain commas
482485
in the integer part (before any decimal point or E notation).
483-
@param str String to be parsed
484-
@param end If non-NULL, set on return to point to the first character
485-
in @a str after those forming the parsed number
486+
@param str String to be parsed
487+
@param strend If non-NULL, set on return to point to the first character
488+
in @a str after those forming the parsed number
489+
@param flags Or'ed-together combination of HTS_PARSE_* flags
486490
@return Converted value of the parsed number.
487491
488492
When @a end is NULL, a warning will be printed (if hts_verbose is 2
489493
or more) if there are any trailing characters after the number.
490494
*/
491-
long long hts_parse_decimal(const char *str, char **end);
495+
long long hts_parse_decimal(const char *str, char **strend, int flags);
492496

493497
/// Parse a "CHR:START-END"-style region string
494498
/** @param str String to be parsed
495499
@param beg Set on return to the 0-based start of the region
496500
@param end Set on return to the 1-based end of the region
497501
@return Pointer to the colon or '\0' after the reference sequence name,
498502
or NULL if @a str could not be parsed.
503+
@note Equivalent to hts_parse_region(str, beg, end, NULL, HTS_PARSE_THOUSANDS_SEP)
499504
*/
500505
const char *hts_parse_reg(const char *str, int *beg, int *end);
501506

507+
/// Parse a "CHR:START-END"-style region string
508+
/** @param str String to be parsed
509+
@param beg Set on return to the 0-based start of the region
510+
@param end Set on return to the 1-based end of the region
511+
@param strend If non-NULL, set on return to point to the first character
512+
in @a str after those forming the parsed region
513+
@param flags Or'ed-together combination of HTS_PARSE_* flags
514+
@return Pointer to the colon or '\0' after the reference sequence name,
515+
or NULL if @a str could not be parsed.
516+
*/
517+
const char *hts_parse_region(const char *str, int *beg, int *end, char **strend, int flags);
518+
502519
hts_itr_t *hts_itr_query(const hts_idx_t *idx, int tid, int beg, int end, hts_readrec_func *readrec);
503520
void hts_itr_destroy(hts_itr_t *iter);
504521

0 commit comments

Comments
 (0)