DeltaQt
Version 0.2.0 End user documentation
A C++/Qt library for parsing DELTA (DEscription Language for TAxonomy) files
|
00001 /* Copyright 2012 Craig Robbins 00002 00003 This file is part of DeltaQt 00004 00005 DeltaQt is free software: you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation, either version 3 of the License, or 00008 (at your option) any later version. 00009 00010 DeltaQt is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with DeltaQt. If not, see <http://www.gnu.org/licenses/>. 00017 */ 00018 00019 #ifndef DELTAATTRIBUTE_H 00020 #define DELTAATTRIBUTE_H 00021 00022 #include <QString> 00023 #include <QList> 00024 #include <QVariant> 00025 #include "deltavaluerange.h" 00026 00027 00028 class DeltaAttributeValue 00029 { 00030 public: 00031 00032 DeltaAttributeValue(); 00033 DeltaAttributeValue(const DeltaValueRange& range); 00034 DeltaAttributeValue(const AnnotatedValue& value); 00035 00036 00037 DeltaValueRange range(void) const; 00038 AnnotatedValue value(void) const; 00039 00040 bool setRange(const DeltaValueRange& range); 00041 bool setValue(const AnnotatedValue& value); 00042 00043 bool isRange(void) const; 00044 bool isValid(void) const; 00045 00046 QString toDeltaString(void) const; 00047 00048 private: 00049 bool m_isRange; 00050 DeltaValueRange m_range; // use if m_range == true 00051 AnnotatedValue m_value; // use if m_range == false 00052 }; 00053 00054 typedef QList<DeltaAttributeValue> DeltaAttributeValueList; 00055 00056 00057 /* Keeping the values in "sets" (although they are strictly 00058 * speaking not sets because duplicate values are permitted) so that the 00059 * "logical" operators available in DELTA can be retained. Values within each 00060 * value set have an implied 'AND', and value sets (for the same attribute) are 00061 * combined by 'OR'. 00062 */ 00063 class DeltaAttributeValueSet 00064 { 00065 public: 00066 00067 DeltaAttributeValueSet(); 00068 00069 void addValue(const DeltaAttributeValue& val); 00070 00071 bool isEmpty(void) const; 00072 00073 inline const DeltaAttributeValueList* valueList(void) const 00074 { return &m_values; } 00075 00076 QString toDeltaString(void) const; 00077 00078 inline void clear(void) { m_values.clear(); } 00079 00080 protected: 00081 DeltaAttributeValueList m_values; 00082 00083 }; 00084 00085 00086 typedef QList<DeltaAttributeValueSet> DeltaAttributeValueSetList; 00087 00088 00089 class DeltaAttribute 00090 { 00091 public: 00092 DeltaAttribute(); 00093 DeltaAttribute(int charNum); 00094 00095 typedef enum { 00096 NOT_A_PSEUDOTYPE, // Values in value sets (DEFAULT) 00097 VARIABLE, // The attribute is Variable 00098 UNKNOWN, // The attribute value is Unknown 00099 NOTAPPLICABLE // The attribute is N/A for the charNum 00100 } PseudoValue; 00101 00102 inline const DeltaAttributeValueSetList* attrValueSet(void) const 00103 { return &m_values; } 00104 00105 int charNum(void) const; 00106 QString comment(void) const; 00107 const QString& origAttrValsStr(void) const; 00108 00109 void addValueSet(const DeltaAttributeValueSet& attrVal); 00110 void setCharNum(int charNum); 00111 void setComment(const QString& comment); 00112 void setOrigAttrValsStr(const QString& str); 00113 void setPseudoValue(PseudoValue type); 00114 void setValuesAreParsed(bool valuesAreParsed); 00115 00116 void isPseudoValue(void) const; 00117 00118 QString toDeltaString(void) const; 00119 00120 private: 00121 PseudoValue m_pseudoType; 00122 int m_charNum; 00123 QString m_comment; 00124 DeltaAttributeValueSetList m_values; 00125 QString m_origAttrValsStr; 00126 bool m_valuesAreParsed; 00127 }; 00128 00129 typedef QList<DeltaAttribute> DeltaAttributeList; 00130 00131 #endif // DELTAATTRIBUTE_H