/******************************************************************************
** Copyright (c) 1992-2025 MAK Technologies, Inc
** All rights reserved.
******************************************************************************/


//! \file envXmlWriter.h
//! \ingroup mtl
//! \brief Contains the DtEnvXMLWriter class.

#ifndef envXmlWriter_H__
#define envXmlWriter_H__

#include "envWriter.h"
#include <vlutil/vlString.h>
#include <libxml/xmlwriter.h>

typedef struct _xmlTextWriter xmlTextWriter;

#ifdef DtUSE_UTILITIES_NAMESPACE
namespace DtUSE_UTILITIES_NAMESPACE
{
#endif


//! \ingroup mtl
class DT_DLL_MTL DtEnvXMLWriter : public DtEnvWriter
{
public:

   //! Do not use DTD
   DtEnvXMLWriter(const DtString& docType);

   //! Use DTD
   DtEnvXMLWriter(const DtString& docType,const DtString& dtdFileName);

   //! DTOR
   virtual ~DtEnvXMLWriter();

   virtual void setIndentation(const DtString& str);
   
   //! \brief Write environment to string buffer.
   virtual bool writeString(DtEnvironment& environment, DtString& target);

   //! \brief Write environment to file.
   virtual bool writeFile(DtEnvironment& environment,const DtString& filename);

protected:
   DtEnvironment* myCurrentEnvironment;
   DtEnvValueWP   myCurrentRoot;
   DtString       myDocType;
   DtString       myDtdFileName;
   bool           myUseDtdFlag;
   bool           myUseIndentation;
   DtString       myIndentString;

   //! Buffer used to store XML written to memory
   xmlBufferPtr   myXmlBuffer;

   virtual void writeRoot(xmlTextWriter* writer,DtEnvValueSP value);
   virtual void writeValue(xmlTextWriter* writer,DtEnvValueSP value);
};

#ifdef DtUSE_UTILITIES_NAMESPACE
}
#endif

#endif
