#ifndef TITAN_PCBCAM_ODBFEATUREPARSERV2_H
#define TITAN_PCBCAM_ODBFEATUREPARSERV2_H
#include "../titanpcbcamglobal.h"
#include <QVariantList>
#include <QVariantMap>
#include <QPainterPath>
#include <QPointF>
#include <QSizeF>
#include "../core/common.h"


struct PcbCamOdbFeatureInfo {
    PcbCam::FeatureType type {PcbCam::PadFeature};
    PcbCam::Polarity polarity {PcbCam::Positive};
    QVariantMap attributes;
    int index {0};
    int decode {0};
    QString symbol;
    QPointF ps;
    QPointF pe;
    QPointF pc;
    bool cw {false};
    PcbCam::Orient orient {PcbCam::Orient_N_0};
    QString font {"standard"};
    QSizeF size;
    qreal widthFactor {1.0};
    QString text;
    int version {1};
    QString barcode;
    bool fullAscii {false};
    bool checkSum {false};
    bool background {false};
    bool additionStr {false};
    PcbCam::BarcodeTextPos additionStrPos {PcbCam::BarcodeTextPos_Top};
    QPainterPath path;
};


class PcbCamOdbFeatureParserPrivate;
class TITAN_PCBCAM_EXPORT PcbCamOdbFeatureParser
{
public:
    PcbCamOdbFeatureParser(const QByteArray &iFeatData);
    ~PcbCamOdbFeatureParser();

    void parse();
    QList<PcbCamOdbFeatureInfo> features();
    QStringList errors();
    QStringList symbols();

private:
    void parseSymbolName(const QString &iLine);
    void parseAttrName(const QString &iLine);
    void parseAttrText(const QString &iLine);
    void parseLine(const QString &iLine);
    void parsePad(const QString &iLine);
    void parseArc(const QString &iLine);
    void parseText(const QString &iLine);
    void parseBarcode(const QString &iLine);
    void parseSurfaceStart(const QString &iLine);
    void parseSurfaceLine(const QString &iLine);
    void parseSurfaceEnd();

    void parseAttributes(const QString &iLine, QStringList *oParams, QVariantMap *oAttrMap) const;


protected:
    const QScopedPointer<PcbCamOdbFeatureParserPrivate> d_ptr;

private:
    Q_DECLARE_PRIVATE(PcbCamOdbFeatureParser)
    Q_DISABLE_COPY(PcbCamOdbFeatureParser)
};


#endif // TITAN_PCBCAM_ODBFEATUREPARSERV2_H
