#pragma once

#include <htslib/sam.h>
#include <stdio.h>

// Struct which contains the sorting key for TemplateCoordinate sort.
struct TemplateCoordinateKey {
    int tid1;
    int tid2;
    hts_pos_t pos1;
    hts_pos_t pos2;
    bool neg1;
    bool neg2;
    const char *library;
    char *mid;
    char *name;
    bool is_upper_of_pair;
};

// Struct which contains the a record, and the pointer to the sort tag (if any) or
// a combined ref / position / strand.
// Used to speed up sorts (coordinate, by-tag, and template-coordinate).
struct BamSortTag {
    bam1_t *bam_record;
    union {
        const uint8_t *tag;
        uint8_t pos_tid[12];
        TemplateCoordinateKey *key;
    } u;
};