/*******************************************************************************
** Copyright (c) 1992-2026 MAK Technologies, Inc
** All rights reserved.
*******************************************************************************/
//! \file datatypeRep.h
//! \ingroup omtReader
#pragma once


#include <omtReader/omtReader.h>
#include <vlutil/vlString.h>
#include <sstream>
#ifdef DtUSE_UTILITIES_NAMESPACE
namespace DtUSE_UTILITIES_NAMESPACE
{
#endif
#define MAKE_STRING( msg )  ( ((std::ostringstream&) \
    (std::ostringstream() << msg)).str() )

//! A Datatype Representation is a class that can take a group of bytes
//! and display them in a certain type of way that would be more useful
//! to the user.
//! \ingroup omtReader
class DT_DLL_OMTREADER DtDatatypeRep
{
public:

   // Constructor
   DtDatatypeRep(bool useImplicitPadding);

   //! Copy Constructor
   DtDatatypeRep(const DtDatatypeRep& orig);

   //! Assignment Operator
   DtDatatypeRep& operator=(const DtDatatypeRep& rhs); 

   //! @return the string name of this datatype
   virtual const char* datatype() const = 0;
   
   //! Given a byte string, returns a character string in a format
   //!  that is easily read by a person.
   //! @param ptr A Pointer to the unformated data 
   //! @param size If this is other than 0, this pointer will be set to
   //! the total count of bytes used in ptr.
   virtual DtString stringRep(const void* ptr, int* size = 0) const = 0;   

   //! The reverse of string rep, given a character string, this returns
   //! an unformatted byte stream.
   //! @param stringRep A The character string
   //! @param size If this is other than 0, this pointer will be set to
   //! the total count of bytes used in ptr.
   virtual std::vector<char> valueFromStringRep(const DtString& stringRep) const = 0;

   //! The alignment size in bytes for this representation.
   virtual int byteAlignment() const = 0;

protected:
   bool myUseImplicitPadding;
};

inline DtDatatypeRep::DtDatatypeRep(bool useImplicitPadding)
   : myUseImplicitPadding(useImplicitPadding)
{
};

inline DtDatatypeRep::DtDatatypeRep(const DtDatatypeRep& orig)
   : myUseImplicitPadding(orig.myUseImplicitPadding)
{
};

inline DtDatatypeRep& DtDatatypeRep::operator=(const DtDatatypeRep& rhs)
{
   if (&rhs != this)
   {
      myUseImplicitPadding = rhs.myUseImplicitPadding;
   }
   return *this;   
}


#ifdef DtUSE_UTILITIES_NAMESPACE
} // end of namespace DtUSE_UTILITIES_NAMESPACE
#endif
