/* ===========================================================================
*
*                            PUBLIC DOMAIN NOTICE
*               National Center for Biotechnology Information
*
*  This software/database is a "United States Government Work" under the
*  terms of the United States Copyright Act.  It was written as part of
*  the author's official duties as a United States Government employee and
*  thus cannot be copyrighted.  This software/database is freely available
*  to the public for use. The National Library of Medicine and the U.S.
*  Government have not placed any restriction on its use or reproduction.
*
*  Although all reasonable efforts have been taken to ensure the accuracy
*  and reliability of the software and data, the NLM and the U.S.
*  Government do not and cannot warrant the performance or results that
*  may be obtained by using this software or data. The NLM and the U.S.
*  Government disclaim all warranties, express or implied, including
*  warranties of performance, merchantability or fitness for any particular
*  purpose.
*
*  Please cite the author in any work or product based on this material.
*
* ===========================================================================*/
#include <objloc.h>
#ifndef __BLAST_STR__
#define __BLAST_STR__
#ifdef __cplusplus
extern "C" {
#endif

typedef enum {
	BLAST_MEMTYPE_NONE = 0,
	BLAST_MEMTYPE_MALLOC = 1,
	BLAST_MEMTYPE_STACK = 2,
	BLAST_MEMTYPE_POOL = 3,
	BLAST_MEMTYPE_OTHER = 4
	} BLAST_MemType, PNTR BLAST_MemTypePtr;

typedef PoolBlkPtr	BLAST_StrPoolPtr;

typedef ValNode	BLAST_SeqId, PNTR BLAST_SeqIdPtr;

typedef struct _blast_strdesc {
	struct _blast_strdesc	PNTR next;
	BLAST_SeqIdPtr	id;
	CharPtr	defline;
	size_t	deflinelen;
	} BLAST_SeqDesc, PNTR BLAST_SeqDescPtr;

typedef struct _blast_str {
		struct _blast_str	PNTR previous, PNTR next;
		struct _blast_str	PNTR src; /* source string, e.g. if translated */
		BLAST_LetterPtr		_str, str;
		BLAST_AlphabetPtr	ap;
		size_t	enclen;	/* currently encoded length of str */
		size_t	alloclen;	/* allocated length of str (0 if not allocated) */
		unsigned long	len;	/* length of unencoded str */
		unsigned long	maxlen; /* max. unencoded str length */
		unsigned	lpb;	/* letters per byte */
		double	efflen; /* effective length (for statistics) */
		int		frame; /* reading frame */
		BLAST_Coord	fulllen; /* length of complete sequence, in residues */
		BLAST_Coord	offset; /* offset of 1st letter in the complete sequence */
		int	gcode_id;
		ValNode	id;
		CharPtr	name;
		size_t	namelen; /* current name length */
		size_t	namemax; /* max. permitted length of name */
		size_t	namealloc; /* allocated length of name[] */
		BLAST_SeqDescPtr	descp;
		BLAST_MemType	mt;
		Boolean	locked;
		BLAST_StrPoolPtr	spp;
		ValNode	user;
	} BLAST_Str, PNTR BLAST_StrPtr;

BLAST_StrPtr	BlastStrNew PROTO((unsigned long maxlen, BLAST_AlphabetPtr ap, unsigned lpb));
BLAST_StrPtr	BlastBuf2Str PROTO((CharPtr buf, size_t buflen, BLAST_AlphabetPtr from, BLAST_AlphabetPtr to));
int LIBCALL BlastStrLock PROTO((BLAST_StrPtr));
void LIBCALL BlastStrUnlock PROTO((BLAST_StrPtr));
void LIBCALL BlastStrDestruct PROTO((BLAST_StrPtr bsp));
void LIBCALL BlastSeqDescDestruct PROTO((BLAST_SeqDescPtr));
void	BlastStrAssign PROTO((BLAST_StrPtr, BLAST_AlphabetPtr, CharPtr, size_t));
BLAST_Error	BlastStrPack PROTO((BLAST_StrPtr bsp, unsigned lpb));
BLAST_StrPoolPtr LIBCALL	BlastStrPoolNew PROTO((size_t cnt));
BLAST_StrPtr LIBCALL	BlastStrPoolGet PROTO((BLAST_StrPoolPtr));
void LIBCALL	BlastStrPoolDestruct PROTO((BLAST_StrPoolPtr));

#ifdef __cplusplus
}
#endif
#endif /* !__BLAST_STR__ */
