summaryrefslogtreecommitdiffstats
path: root/src/value.h
diff options
context:
space:
mode:
authorSlávek Banko <[email protected]>2013-06-24 02:08:15 +0200
committerSlávek Banko <[email protected]>2013-07-04 02:44:37 +0200
commit998f21e02a725cd553d7c278819f67cd81295af4 (patch)
tree4bd158018e9302c31367b00c01cd2b41eb228414 /src/value.h
downloadkbibtex-998f21e02a725cd553d7c278819f67cd81295af4.tar.gz
kbibtex-998f21e02a725cd553d7c278819f67cd81295af4.zip
Initial import
Diffstat (limited to 'src/value.h')
-rw-r--r--src/value.h162
1 files changed, 162 insertions, 0 deletions
diff --git a/src/value.h b/src/value.h
new file mode 100644
index 0000000..3c7d876
--- /dev/null
+++ b/src/value.h
@@ -0,0 +1,162 @@
+/***************************************************************************
+* Copyright (C) 2004-2006 by Thomas Fischer *
+* *
+* 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 BIBTEXVALUE_H
+#define BIBTEXVALUE_H
+
+#include <qvaluelist.h>
+
+class QStringList;
+
+namespace BibTeX
+{
+ class ValueTextInterface
+ {
+ public:
+ ValueTextInterface( const ValueTextInterface* other );
+ ValueTextInterface( const QString& text );
+ virtual ~ValueTextInterface() {};
+
+ virtual void setText( const QString& text );
+ virtual QString text() const;
+ QString simplifiedText() const;
+ virtual void replace( const QString &before, const QString &after );
+ virtual bool containsPattern( const QString &pattern, bool caseSensitive );
+
+ private:
+ QString m_text;
+ };
+
+ class ValueItem: public ValueTextInterface
+ {
+ public:
+ ValueItem( const QString& text );
+
+ virtual ValueItem *clone()
+ {
+ return NULL;
+ };
+ };
+
+ class Keyword: public ValueTextInterface
+ {
+ public:
+ Keyword( Keyword *other );
+ Keyword( const QString& text );
+
+ Keyword *clone();
+ };
+
+ class KeywordContainer: public ValueItem
+ {
+ public:
+ KeywordContainer();
+ KeywordContainer( const QString& text );
+ KeywordContainer( KeywordContainer *other );
+ KeywordContainer( const QStringList& list );
+
+ ValueItem *clone();
+ void setList( const QStringList& list );
+ void append( const QString& text );
+ void remove( const QString& text );
+ void setText( const QString& text );
+ QString text() const;
+ void replace( const QString &before, const QString &after );
+
+ QValueList<Keyword*> keywords;
+ };
+
+ class Person: public ValueTextInterface
+ {
+ public:
+ Person( const QString& text, bool firstNameFirst = FALSE );
+ Person( const QString& firstName, const QString& lastName, bool firstNameFirst = FALSE );
+
+ Person *clone();
+ void setText( const QString& text );
+ QString text() const;
+ QString text( bool firstNameFirst ) const;
+
+ QString firstName();
+ QString lastName();
+
+ protected:
+ QString m_firstName;
+ QString m_lastName;
+ bool m_firstNameFirst;
+
+ bool splitName( const QString& text, QStringList& segments );
+ };
+
+ class PersonContainer: public ValueItem
+ {
+ public:
+ PersonContainer( bool firstNameFirst = FALSE );
+ PersonContainer( const QString& text, bool firstNameFirst = FALSE );
+
+ ValueItem *clone();
+ void setText( const QString& text );
+ QString text() const;
+ void replace( const QString &before, const QString &after );
+
+ QValueList<Person*> persons;
+
+ private:
+ bool m_firstNameFirst;
+ };
+
+ class MacroKey: public ValueItem
+ {
+ private:
+ bool m_isValid;
+ bool isValidInternal();
+
+ public:
+ MacroKey( const QString& text );
+
+ ValueItem *clone();
+
+ void setText( const QString& text );
+ bool isValid();
+ };
+
+ class PlainText: public ValueItem
+ {
+ public:
+ PlainText( const QString& text );
+
+ ValueItem *clone();
+ };
+
+ class Value: public ValueTextInterface
+ {
+ public:
+ Value();
+ Value( const Value *other );
+ Value( const QString& text, bool isMacroKey = false );
+
+ void setText( const QString& text );
+ QString text() const;
+ void replace( const QString &before, const QString &after );
+
+ QValueList<ValueItem*> items;
+ };
+}
+
+#endif