summaryrefslogtreecommitdiffstats
path: root/src/entry.h
blob: 6a8633cff6f819a4fcc76d68d7b952446a0e710a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/***************************************************************************
*   Copyright (C) 2004-2006 by Thomas Fischer                             *
*   [email protected]                                             *
*                                                                         *
*   This program is free software; you can redistribute it and/or modify  *
*   it under the terms of the GNU General Public License as published by  *
*   the Free Software Foundation; either version 2 of the License, or     *
*   (at your option) any later version.                                   *
*                                                                         *
*   This program 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 General Public License for more details.                          *
*                                                                         *
*   You should have received a copy of the GNU General Public License     *
*   along with this program; if not, write to the                         *
*   Free Software Foundation, Inc.,                                       *
*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
***************************************************************************/
#ifndef BIBTEXBIBTEXENTRY_H
#define BIBTEXBIBTEXENTRY_H

#include <qvaluelist.h>
#include <qstringlist.h>

#include <element.h>
#include <entryfield.h>

class QString;
class QStringList;

namespace BibTeX
{

    class Entry : public Element
    {
    public:
        typedef QValueList<BibTeX::EntryField*> EntryFields;

        enum EntryType {etArticle, etBook, etBooklet, etCollection, etElectronic, etInBook, etInCollection, etInProceedings, etManual, etMastersThesis, etMisc, etPhDThesis, etProceedings, etTechReport, etUnpublished, etUnknown};

        enum FieldRequireStatus {frsRequired, frsOptional, frsIgnored};

        enum MergeSemantics {msAddNew, msForceAdding};

        Entry( );
        Entry( const EntryType entryType, const QString &id );
        Entry( const QString& entryTypeString, const QString& id );
        Entry( const Entry *other );
        virtual ~Entry();
        Element* clone();
        bool equals( const Entry &other );
        QString text() const;

        void setEntryType( const EntryType elementType );
        void setEntryTypeString( const QString& elementTypeString );
        EntryType entryType() const;
        QString entryTypeString() const;
        void setId( const QString& id );
        QString id() const;

        bool containsPattern( const QString& pattern, EntryField::FieldType fieldType = EntryField::ftUnknown, BibTeX::Element::FilterType filterType = BibTeX::Element::ftExact, bool caseSensitive = FALSE ) const;
        QStringList urls() const;

        bool addField( EntryField *field );
        BibTeX::EntryField* getField( const EntryField::FieldType fieldType ) const;
        BibTeX::EntryField* getField( const QString& fieldName ) const;
        bool deleteField( const BibTeX::EntryField::FieldType fieldType );
        bool deleteField( const QString &fieldName );

        EntryFields::const_iterator begin() const;
        EntryFields::const_iterator end() const;
        int getFieldCount() const;
        void clearFields();

        void copyFrom( const BibTeX::Entry *other );
        void merge( BibTeX::Entry *other, MergeSemantics mergeSemantics );

        static QString entryTypeToString( const EntryType entryType );
        static EntryType entryTypeFromString( const QString &entryTypeString );
        static Entry::FieldRequireStatus getRequireStatus( Entry::EntryType entryType, EntryField::FieldType fieldType );

    private:
        EntryType m_entryType;
        QString m_entryTypeString;
        QString m_id;
        EntryFields m_fields;
    };

}

#endif