How do I access sequence and MAPQ from bam using HTSlib in C++?

I am using the "htslib/sam.h" header in C++. I need to access the SEQ field of bam reads and store each sequence in a vector of strings. I also need to access the MAPQ field of each read to check if the read passes my threshold quality of 10 (which I have stored as an integer). Does anyone know which htslib/sam.h functions can accomplish these tasks?

The MAPQ is stored in b->core.qual, given a bam1_t *b. You can access the sequence with bam_seqi(bam_get_seq(b), some_offset)(see https://github.com/samtools/htslib/blob/develop/htslib/sam.h#L317). This will get you a base at a time, so you'd need to iterate over it (the length of the sequence being in b->core.l_qseq).