#ifndef _LSUP_TRIPLE_H #define _LSUP_TRIPLE_H #include "term.h" typedef struct LSUP_Triple { LSUP_Term *s; LSUP_Term *p; LSUP_Term *o; } LSUP_Triple; typedef struct LSUP_SerTriple { LSUP_SerTerm *s; LSUP_SerTerm *p; LSUP_SerTerm *o; } LSUP_SerTriple; typedef enum { TRP_POS_S = 0, TRP_POS_P = 1, TRP_POS_O = 2, } LSUP_TriplePos; #define _FN_BODY \ if (n == 0) return trp->s; \ if (n == 1) return trp->p; \ if (n == 2) return trp->o; \ return NULL; /** @brief Get triple by term position. * * Useful for looping over all terms. * * @param trp[in] Triple pointer. * * @param n[in] A number between 0÷2. * * @return Corresponding triple term or NULL if n is out of range. */ inline LSUP_Term * LSUP_triple_term_by_pos(const LSUP_Triple *trp, LSUP_TriplePos n) { _FN_BODY } /** @brief Get serialized triple by term position. * * Useful for looping over all terms. * * @param trp[in] Serialized triple pointer. * * @param n[in] A number between 0÷2. * * @return Corresponding serialized term or NULL if n is out of range. */ inline LSUP_SerTerm * LSUP_ser_triple_term_by_pos(const LSUP_SerTriple *trp, LSUP_TriplePos n) { _FN_BODY } // TODO Add constructors and destructors with term type checks. #endif