// ============================================================= //
//                                                               //
//   File      : seqio.hxx                                       //
//   Purpose   :                                                 //
//                                                               //
//   Institute of Microbiology (Technical University Munich)     //
//   http://www.arb-home.de/                                     //
//                                                               //
// ============================================================= //

#ifndef SEQIO_HXX
#define SEQIO_HXX

#ifndef ARBDB_BASE_H
#include <arbdb_base.h>
#endif
#ifndef ARB_MSG_H
#include <arb_msg.h>
#endif
#ifndef SMARTPTR_H
#include <smartptr.h>
#endif

class AP_filter;

namespace SEQIO {

    enum ExportWhich {
        EBF_ALL,
        EBF_MARKED,
        EBF_ONE, // export explicitely specified species
    };

    inline void appendTo(char*& content, char sep, char*& toAppend) {
        if (content) {
            freeset(content, GBS_global_string_copy("%s%c%s", content, sep, toAppend));
            freenull(toAppend);
        }
        else {
            reassign(content, toAppend);
        }
    }

    bool  read_string_pair(FILE *in, char *&s1, char *&s2, size_t& lineNr);
    char *fgets_smartLF(char *s, int size, FILE *stream);

    GB_ERROR export_by_format(GBDATA *gb_main, ExportWhich which, const char *one_species,
                              AP_filter *filter, int cut_stop_codon, int compress,
                              const char *dbname, const char *formname, const char *field_transfer_set,
                              const char *outname, int multiple, char **real_outname);

    struct ExportFormatInfo {
        SmartCharPtr suffix;      // default output file suffix (optional)
        SmartCharPtr description; // description                (optional)
    };

    GB_ERROR get_exportFormat_information(const char *eft_formname, ExportFormatInfo& info);
    char *get_exportFormat_evalForm(const char *eft_formname, GB_ERROR& error);
};

#else
#error seqio.hxx included twice
#endif // SEQIO_HXX
