<commit_before>/*
 * Copyright 2018  <NAME> tot Westerflier <<EMAIL>>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) version 3, or any
 * later version accepted by the membership of KDE e.V. (or its
 * successor approved by the membership of KDE e.V.), which shall
 * act as a proxy defined in Section 6 of version 3 of the license.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef ACBFREFERENCES_H
#define ACBFREFERENCES_H

#include <memory>

#include "AcbfDocument.h"
#include "AcbfReference.h"
#include <QObject>
#include <QXmlStreamReader>

namespace AdvancedComicBookFormat
{

    /**
     * @brief Class to handle the ACBF references section.
     * 
     * The References object holds Reference objects, which
     * in turn have an id, language and a list of paragraphs.
     * 
     * A reference is a bit of text that can be referred to
     * with an anchor in any of the other paragraphs. This
     * can be used for footnotes, like translation notes
     * or author's notes.
     * 
     * Reference objects can be retrieved by using their ID.
     */
class ACBF_EXPORT References : public QObject
{
    Q_OBJECT
    Q_PROPERTY(QObjectList references READ references NOTIFY referencesChanged)
public:
    explicit References(Document* parent = nullptr);
    ~References() override;


    /**
     * \brief Write the references into the xml writer.
     */
    void toXml(QXmlStreamWriter* writer);
    /**
     * \brief load a reference element into this object.
     * @return True if the xmlReader encountered no errors.
     */
    bool fromXml(QXmlStreamReader *xmlReader);

    /**
     * @param id - the id that is used to reference to this object.
     * @return the reference object referenced by this id.
     */
    Reference* reference(const QString& id) const;

    /**
     * @brief Add reference at ID.
     * 
     * @param id The id that will refer to this reference.
     * @param paragraphs The paragraphs comprising this reference.
     * @param language The language (optional, and 1.2 only)
     */
    Q_INVOKABLE void addReference(const QString& id, const QStringList& paragraphs, const QString& language = "");

    QObjectList references() const;
    Q_SIGNAL void referencesChanged();
private:
    class Private;
    std::unique_ptr<Private> d;
};
}

#endif // ACBFREFERENCES_H<commit_msg>Also modify the header, silly<commit_after>/*
 * Copyright 2018  <NAME> Westerflier <<EMAIL>>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) version 3, or any
 * later version accepted by the membership of KDE e.V. (or its
 * successor approved by the membership of KDE e.V.), which shall
 * act as a proxy defined in Section 6 of version 3 of the license.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef ACBFREFERENCES_H
#define ACBFREFERENCES_H

#include <memory>

#include "AcbfDocument.h"
#include "AcbfReference.h"
#include <QObject>
#include <QXmlStreamReader>

namespace AdvancedComicBookFormat
{

    /**
     * @brief Class to handle the ACBF references section.
     * 
     * The References object holds Reference objects, which
     * in turn have an id, language and a list of paragraphs.
     * 
     * A reference is a bit of text that can be referred to
     * with an anchor in any of the other paragraphs. This
     * can be used for footnotes, like translation notes
     * or author's notes.
     * 
     * Reference objects can be retrieved by using their ID.
     */
class ACBF_EXPORT References : public QObject
{
    Q_OBJECT
    Q_PROPERTY(QObjectList references READ references NOTIFY referencesChanged)
public:
    explicit References(Document* parent = nullptr);
    ~References() override;


    /**
     * \brief Write the references into the xml writer.
     */
    void toXml(QXmlStreamWriter* writer);
    /**
     * \brief load a reference element into this object.
     * @return True if the xmlReader encountered no errors.
     */
    bool fromXml(QXmlStreamReader *xmlReader);

    /**
     * @param id - the id that is used to reference to this object.
     * @return the reference object referenced by this id.
     */
    Reference* reference(const QString& id) const;

    /**
     * @brief Add reference at ID.
     * 
     * @param id The id that will refer to this reference.
     * @param paragraphs The paragraphs comprising this reference.
     * @param language The language (optional, and 1.2 only)
     */
    Q_INVOKABLE AdvancedComicBookFormat::Reference* addReference(const QString& id, const QStringList& paragraphs, const QString& language = "");

    QObjectList references() const;
    Q_SIGNAL void referencesChanged();
private:
    class Private;
    std::unique_ptr<Private> d;
};
}

#endif // ACBFREFERENCES_H
{'fraction_non_alphanumeric': 0.07525226611937746, 'fraction_numerical': 0.003762613305968873, 'mean_word_length': 3.159317211948791, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2196014', 'n_tokens_mistral': 1627, 'n_tokens_neox': 1547, 'n_words': 716}