~ubuntu-branches/ubuntu/precise/kbibtex/precise

« back to all changes in this revision

Viewing changes to src/libkbibtexio/entry.h

  • Committer: Package Import Robot
  • Author(s): Michael Hanke
  • Date: 2011-07-18 09:29:48 UTC
  • mfrom: (1.1.6) (2.1.5 sid)
  • Revision ID: package-import@ubuntu.com-20110718092948-ksxjmg7kdfamolmg
Tags: 0.3-1
* First upstream release for KDE4 (Closes: #634255). A number of search
  engines are still missing, in comparison to the 0.2 series.
* Bumped Standards-Version to 3.9.2, no changes necessary.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
*   Copyright (C) 2004-2010 by Thomas Fischer                             *
 
3
*   fischer@unix-ag.uni-kl.de                                             *
 
4
*                                                                         *
 
5
*   This program is free software; you can redistribute it and/or modify  *
 
6
*   it under the terms of the GNU General Public License as published by  *
 
7
*   the Free Software Foundation; either version 2 of the License, or     *
 
8
*   (at your option) any later version.                                   *
 
9
*                                                                         *
 
10
*   This program is distributed in the hope that it will be useful,       *
 
11
*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
12
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
13
*   GNU General Public License for more details.                          *
 
14
*                                                                         *
 
15
*   You should have received a copy of the GNU General Public License     *
 
16
*   along with this program; if not, write to the                         *
 
17
*   Free Software Foundation, Inc.,                                       *
 
18
*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 
19
***************************************************************************/
 
20
#ifndef BIBTEXBIBTEXENTRY_H
 
21
#define BIBTEXBIBTEXENTRY_H
 
22
 
 
23
#include <QMap>
 
24
 
 
25
#include "element.h"
 
26
#include "value.h"
 
27
 
 
28
class File;
 
29
 
 
30
/**
 
31
 * This class represents an entry in a BibTeX file such as an article
 
32
 * or a book. This class is essentially a map from keys such as title,
 
33
 * year or other bibliography data to corresponding values.
 
34
 * @see Value
 
35
 * @author Thomas Fischer <fischer@unix-ag.uni-kl.de>
 
36
 */
 
37
class KBIBTEXIO_EXPORT Entry : public Element, public QMap<QString, Value>
 
38
{
 
39
    Q_PROPERTY(QString id READ id WRITE setId)
 
40
    Q_PROPERTY(QString type READ type WRITE setType)
 
41
 
 
42
public:
 
43
    /** Representation of the BibTeX field key "abstract" */
 
44
    static const QLatin1String ftAbstract;
 
45
    /** Representation of the BibTeX field key "address" */
 
46
    static const QLatin1String ftAddress;
 
47
    /** Representation of the BibTeX field key "author" */
 
48
    static const QLatin1String ftAuthor;
 
49
    /** Representation of the BibTeX field key "booktitle" */
 
50
    static const QLatin1String ftBookTitle;
 
51
    /** Representation of the BibTeX field key "chapter" */
 
52
    static const QLatin1String ftChapter;
 
53
    /** Representation of the BibTeX field key "x-color" */
 
54
    static const QLatin1String ftColor;
 
55
    /** Representation of the BibTeX field key "comment" */
 
56
    static const QLatin1String ftComment;
 
57
    /** Representation of the BibTeX field key "crossref" */
 
58
    static const QLatin1String ftCrossRef;
 
59
    /** Representation of the BibTeX field key "doi" */
 
60
    static const QLatin1String ftDOI;
 
61
    /** Representation of the BibTeX field key "editor" */
 
62
    static const QLatin1String ftEditor;
 
63
    /** Representation of the BibTeX field key "issn" */
 
64
    static const QLatin1String ftISSN;
 
65
    /** Representation of the BibTeX field key "isbn" */
 
66
    static const QLatin1String ftISBN;
 
67
    /** Representation of the BibTeX field key "journal" */
 
68
    static const QLatin1String ftJournal;
 
69
    /** Representation of the BibTeX field key "keywords" */
 
70
    static const QLatin1String ftKeywords;
 
71
    /** Representation of the BibTeX field key "localfile" */
 
72
    static const QLatin1String ftLocalFile;
 
73
    /** Representation of the BibTeX field key "location" */
 
74
    static const QLatin1String ftLocation;
 
75
    /** Representation of the BibTeX field key "month" */
 
76
    static const QLatin1String ftMonth;
 
77
    /** Representation of the BibTeX field key "note" */
 
78
    static const QLatin1String ftNote;
 
79
    /** Representation of the BibTeX field key "number" */
 
80
    static const QLatin1String ftNumber;
 
81
    /** Representation of the BibTeX field key "pages" */
 
82
    static const QLatin1String ftPages;
 
83
    /** Representation of the BibTeX field key "publisher" */
 
84
    static const QLatin1String ftPublisher;
 
85
    /** Representation of the BibTeX field key "school" */
 
86
    static const QLatin1String ftSchool;
 
87
    /** Representation of the BibTeX field key "series" */
 
88
    static const QLatin1String ftSeries;
 
89
    /** Representation of the BibTeX field key "title" */
 
90
    static const QLatin1String ftTitle;
 
91
    /** Representation of the BibTeX field key "url" */
 
92
    static const QLatin1String ftUrl;
 
93
    /** Representation of the BibTeX field key "volume" */
 
94
    static const QLatin1String ftVolume;
 
95
    /** Representation of the BibTeX field key "year" */
 
96
    static const QLatin1String ftYear;
 
97
 
 
98
    /** Representation of the BibTeX entry type "Article" */
 
99
    static const QLatin1String etArticle;
 
100
    /** Representation of the BibTeX entry type "Book" */
 
101
    static const QLatin1String etBook;
 
102
    /** Representation of the BibTeX entry type "InBook" */
 
103
    static const QLatin1String etInBook;
 
104
    /** Representation of the BibTeX entry type "InProceedings" */
 
105
    static const QLatin1String etInProceedings;
 
106
    /** Representation of the BibTeX entry type "Misc" */
 
107
    static const QLatin1String etMisc;
 
108
    /** Representation of the BibTeX entry type "TechReport" */
 
109
    static const QLatin1String etTechReport;
 
110
    /** Representation of the BibTeX entry type "PhDThesis" */
 
111
    static const QLatin1String etPhDThesis;
 
112
    /** Representation of the BibTeX entry type "Unpublished" */
 
113
    static const QLatin1String etUnpublished;
 
114
 
 
115
    /**
 
116
     * Create a new entry type. Both type and id are optionally,
 
117
     * allowing to call the constructor as Entry() only.
 
118
     * Both type and id can be set and retrieved later.
 
119
     * @param type type of this entry
 
120
     */
 
121
    Entry(const QString& type = QString::null, const QString &id = QString::null);
 
122
 
 
123
    /**
 
124
     * Copy constructor cloning another entry object.
 
125
     * @param other entry object to clone
 
126
     */
 
127
    Entry(const Entry &other);
 
128
 
 
129
    virtual ~Entry();
 
130
 
 
131
    /**
 
132
     * Assignment operator, working similar to a copy constructor,
 
133
     * but overwrites the current object's values.
 
134
     */
 
135
    Entry& operator= (const Entry& other);
 
136
 
 
137
    Value& operator[](const QString& key);
 
138
    const Value operator[](const QString& key) const;
 
139
 
 
140
    /**
 
141
     * Set the type of this entry. Common values are "article" or "book".
 
142
     * @param type type of this entry
 
143
     */
 
144
    void setType(const QString& type);
 
145
 
 
146
    /**
 
147
     * Retrieve the type of this entry. Common values are "article" or "book".
 
148
     * @return type of this entry
 
149
     */
 
150
    QString type() const;
 
151
 
 
152
    /**
 
153
     * Set the id of this entry. In LaTeX, this id is used to refer to a BibTeX
 
154
     * entry using the "ref" command.
 
155
     * @param id id of this entry
 
156
     */
 
157
    void setId(const QString& id);
 
158
 
 
159
    /**
 
160
     * Retrieve the id of this entry. In LaTeX, this id is used to refer to a BibTeX
 
161
     * entry using the "ref" command.
 
162
     * @return id of this entry
 
163
     */
 
164
    QString id() const;
 
165
 
 
166
    /**
 
167
     * Re-implementation of QMap's value function, but performing a case-insensitive
 
168
     * match on the key. E.g. querying for key "title" will find a key-value pair with
 
169
     * key "TITLE".
 
170
     * @see #contains(const QString&)
 
171
     * @param key field name to search for
 
172
     * @return found value or Value() if nothing found
 
173
     */
 
174
    const Value value(const QString& key) const;
 
175
 
 
176
    int remove(const QString& key);
 
177
 
 
178
    /**
 
179
     * Re-implementation of QMap's contains function, but performing a case-insensitive
 
180
     * match on the key. E.g. querying for key "title" will find a key-value pair with
 
181
     * key "TITLE".
 
182
     * @see #value(const QString&)
 
183
     * @param key field name to search for
 
184
     * @return true if value with key found, else false
 
185
     */
 
186
    bool contains(const QString& key) const;
 
187
 
 
188
    static Entry* resolveCrossref(const Entry &original, const File *bibTeXfile);
 
189
 
 
190
private:
 
191
    class EntryPrivate;
 
192
    EntryPrivate * const d;
 
193
};
 
194
 
 
195
#endif // BIBTEXBIBTEXENTRY_H