#ifndef _STRINGMESSAGE_H
#define _STRINGMESSAGE_H

#include "ExternalData.h"
#include "StringData.h"

/*
CLASS 
StringMessage

DESCRIPTION
Character string containing ascii representation of primitive data types,
with specified token delimiter.

AUTHOR
Tom O'Reilly
*/
class StringMessage : public ExternalData {

public:
  
  StringMessage(int maxStringBytes, char tokenDelimiter);
  virtual ~StringMessage();

  ///////////////////////////////////////////////////////////////////
  // Set char value to external representation
  // [input] charData: Value to be converted
  virtual void set(CharData *charData);

  ///////////////////////////////////////////////////////////////////
  // Set short value to external representation
  // [input] shortData: Value to be converted
  virtual void set(ShortData *shortData);

  ///////////////////////////////////////////////////////////////////
  // Set int value to external representation
  // [input] integerData: Value to be converted
  virtual void set(IntegerData *integerData);

  ///////////////////////////////////////////////////////////////////
  // Set float value to external representation
  // [input] floatData: Value to be converted
  virtual void set(FloatData *floatData);

  ///////////////////////////////////////////////////////////////////
  // Set double value to external representation
  // [input] doubleData: Value to be converted
  virtual void set(DoubleData *doubleData);

  ///////////////////////////////////////////////////////////////////
  // Set string to external representation
  // [input] stringData: Value to be converted
  virtual void set(StringData *stringData);

  ///////////////////////////////////////////////////////////////////
  // Append string
  // [input] string: String to append
  virtual void set(char *string);

  ///////////////////////////////////////////////////////////////////
  // Get char value from external representation
  // [output] charData: contains internal representation of data
  virtual void get(CharData *charData);

;  ///////////////////////////////////////////////////////////////////
  // Get short value from external representation
  // [output] shortData: contains internal representation of data
  virtual void get(ShortData *shortData);

  ///////////////////////////////////////////////////////////////////
  // Get int value from external representation
  // [output] integerData: contains internal representation of data
  virtual void get(IntegerData *integerData);

  ///////////////////////////////////////////////////////////////////
  // Get float value from external representation
  // [output] floatData: contains internal representation of data
  virtual void get(FloatData *floatData);

  ///////////////////////////////////////////////////////////////////
  // Get double value from external representation
  // [output] doubleData: contains internal representation of data
  virtual void get(DoubleData *doubleData);

  ///////////////////////////////////////////////////////////////////
  // Get string from external representation
  // [output] stringData: contains internal representation of data
  virtual void get(StringData *stringData);

  ///////////////////////////////////////////////////////////////////
  // Get string
  // [output] string: String from buffer
  // [input] stringSize: Bytes allocated to string
  virtual void get(char *string, int stringSize);

  ///////////////////////////////////////////////////////////////////
  // Set string to external representation
  // [input] stringData: Value to be converted
  virtual void set(StringData *stringData);

  ///////////////////////////////////////////////////////////////////
  // Maximum bytes allocated for string buffer
  int maxStringBytes();

  ///////////////////////////////////////////////////////////////////
  // Move pointer to beginning of buffer
  virtual void reset();

  ///////////////////////////////////////////////////////////////////
  // Point to buffer
  char *buffer();

  ///////////////////////////////////////////////////////////////////
  // Copy into buffer
  void setBuffer(char *buffer);

  ///////////////////////////////////////////////////////////////////
  // Pad with specified character
  void pad(char padChar = ' ');

protected:

  ///////////////////////////////////////////////////////////////////
  // Return pointer to next token in buffer
  virtual char *nextToken();

  ///////////////////////////////////////////////////////////////////
  // Append new token
  virtual void addToken(const char *newToken);

  char *_buffer;
  char *_bufferEnd;
  char *_token;
  char *_bufferPtr;
  int _maxStringBytes;
  char _tokenDelimiter;
};


#endif

