/** @file  psLine.h
 *
 *
 *  @brief Contains the declarations of line utility functions
 *
 *  @ingroup SysUtils
 *
 *  The psLine functions allow manipulation of fixed-length lines.
 *
 *  @author Paul Price, IFA
 *  @author David Robbins, MHPCC
 *
 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
 *  @date $Date: 2006-07-21 02:39:33 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
 */

#ifndef PS_LINE_H
#define PS_LINE_H

#include "psString.h"

/** @addtogroup SysUtils
 *  @{
 */

/** Structure to carry a dynamic string */
typedef struct
{
    long NLINE;                        ///< allocated length
    long Nline;                        ///< current length
    psString line;                     ///< character string data
}
psLine;

/** Allocates a line object of length Nline.
 *
 *  @return psLine*:        the newly allocated line object.
*/
psLine *psLineAlloc(
    long Nline                         ///< length of line object to allocate
);

/** Checks the type of a particular pointer.
 *
 *  Uses the appropriate deallocation function in psMemBlock to check the ptr datatype.
 *
 *  @return bool:       True if the pointer matches a psLine structure, false otherwise.
 */
bool psMemCheckLine(
    psPtr ptr                          ///< the pointer whose type to check
);

/** Initializes or re-initializes a line.
 *
 *  Initializes or re-initializes a line, setting the current length to zero and setting
 *  the string data values to 0.  If the function is passed NULL, false is returned.
 *
 *  @return bool:       True if successful, otherwise false.
*/
bool psLineInit(
    psLine *line                       ///< line to (re-)initialize
);

/** Adds the line segment to the string.
 *
 *  Appends a line segment to the string, returning false if the new segment would
 *  overflow the allocated string length.
 *
 *  @return bool:        True if successful, otherwise false.
*/
bool psLineAdd(
    psLine *line,                      ///< the line segment to append
    const char *format,                ///< printf-style format of line
    ...                                ///< any parameters required in format
);

#endif /* PS_LINE_H */
