/******************************************************************************
*
* Copyright (C) 1997-2019 by Dimitri van Heesch.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation under the terms of the GNU General Public License is hereby
* granted. No representations are made about the suitability of this software
* for any purpose. It is provided "as is" without express or implied warranty.
* See the GNU General Public License for more details.
*
* Documents produced by analyze are derivative works derived from the
* input used in their production; they are not affected by this license.
*
*/

#ifndef DOTFILEPATCHER_H
#define DOTFILEPATCHER_H

#include <vector>

#include "qcstring.h"

class TextStream;

/** Helper class to insert a set of map file into an output file */
class DotFilePatcher
{
  public:
    DotFilePatcher(const OGString &patchFile);
    int addMap(const OGString &mapFile,const OGString &relPath,
               bool urlOnly,const OGString &context,const OGString &label);

    int addFigure(const OGString &baseName,
                  const OGString &figureName,bool heightCheck);

    int addSVGConversion(const OGString &relPath,bool urlOnly,
                         const OGString &context,bool zoomable,int graphId);

    int addSVGObject(const OGString &baseName, const OGString &figureName,
                     const OGString &relPath);
    bool run() const;
    bool isSVGFile() const;

    static bool convertMapFile(TextStream &t,const OGString &mapName,
                               const OGString &relPath, bool urlOnly=FALSE,
                               const OGString &context=OGString());

    static bool writeSVGFigureLink(TextStream &out,const OGString &relPath,
                                   const OGString &baseName,const OGString &absImgName);

    static bool writeVecGfxFigure(TextStream& out, const OGString& baseName,
                                  const OGString& figureName);

  private:
    struct Map
    {
      Map(const OGString &mf,const OGString &rp,bool uo,const OGString &ctx,
          const OGString &lab,bool zoom=false,int gId=-1) :
        mapFile(mf), relPath(rp), urlOnly(uo), context(ctx),
        label(lab), zoomable(zoom), graphId(gId) {}
      OGString mapFile;
      OGString relPath;
      bool     urlOnly;
      OGString context;
      OGString label;
      bool     zoomable;
      int      graphId;
    };
    std::vector<Map> m_maps;
    OGString m_patchFile;
};


#endif
