~ubuntu-branches/ubuntu/precise/kalzium/precise

« back to all changes in this revision

Viewing changes to libscience/tests/xmlreadingtest.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Philip Muškovac
  • Date: 2011-07-03 12:28:58 UTC
  • Revision ID: james.westby@ubuntu.com-20110703122858-q1yyxncs89e4w0hs
Tags: upstream-4.6.90+repack
Import upstream version 4.6.90+repack

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2005, 2006 by Carsten Niehaus <cniehaus@kde.org>        *
 
3
 *                                                                         *
 
4
 *   This program is free software; you can redistribute it and/or modify  *
 
5
 *   it under the terms of the GNU General Public License as published by  *
 
6
 *   the Free Software Foundation; either version 2 of the License, or     *
 
7
 *   (at your option) any later version.                                   *
 
8
 *                                                                         *
 
9
 *   This program is distributed in the hope that it will be useful,       *
 
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
12
 *   GNU General Public License for more details.                          *
 
13
 *                                                                         *
 
14
 *   You should have received a copy of the GNU General Public License     *
 
15
 *   along with this program; if not, write to the                         *
 
16
 *   Free Software Foundation, Inc.,                                       *
 
17
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.          *
 
18
 ***************************************************************************/
 
19
 
 
20
#include "elementparser.h"
 
21
#include "element.h"
 
22
#include "chemicaldataobject.h"
 
23
#include <QtCore/QDebug>
 
24
#include <iostream>
 
25
 
 
26
int main(int argc, char *argv[])
 
27
{
 
28
    if (argc < 2 || argc > 2) {
 
29
        std::cout << "Usage: elements <XML_FILE>\n";
 
30
        return 1;
 
31
    }
 
32
 
 
33
    ElementSaxParser * parser = new ElementSaxParser();
 
34
    QFile xmlFile(argv[1]);
 
35
 
 
36
    QXmlInputSource source(&xmlFile);
 
37
    QXmlSimpleReader reader;
 
38
 
 
39
    reader.setContentHandler(parser);
 
40
    reader.parse(source);
 
41
 
 
42
    QList<Element*> v = parser->getElements();
 
43
 
 
44
    std::cout << "Found " << v.count() << " elements." << std::endl;
 
45
 
 
46
    foreach( Element* e, v ){
 
47
        if ( e )
 
48
        {
 
49
            QList<ChemicalDataObject> list = e->data();
 
50
 
 
51
            //Test: give me all data available
 
52
            foreach( const ChemicalDataObject &o, list ){
 
53
                    QString unit = o.unitAsString();
 
54
                    if ( unit == "bo:noUnit" )
 
55
                        unit = "";
 
56
                    qDebug() << "Name: " << o.type() << " " << o.valueAsString()  <<" "  << unit;
 
57
            }
 
58
        }
 
59
    }
 
60
 
 
61
    delete parser;
 
62
    qDeleteAll(v);
 
63
 
 
64
    return 0;
 
65
}
 
66
 
 
67
// QString dictRef( int type ) const
 
68
// {
 
69
//      QString botype;
 
70
//      switch ( type ){
 
71
//              case atomicNumber:
 
72
//                      botype = "atomicNumber";
 
73
//                      break;
 
74
//              case symbol:
 
75
//                      botype = "symbol";
 
76
//                      break;
 
77
//              case name:
 
78
//                      botype = "name";
 
79
//                      break;
 
80
//              case mass:
 
81
//                      botype = "mass";
 
82
//                      break;
 
83
//              case exactMass:
 
84
//                      botype = "exactMass";
 
85
//                      break;
 
86
//              case spin:
 
87
//                      botype = "spin";
 
88
//                      break;
 
89
//              case magneticMoment:
 
90
//                      botype = "magneticMoment";
 
91
//                      break;
 
92
//              case halfLife:
 
93
//                      botype = "halfLife";
 
94
//                      break;
 
95
//              case alphaDecay:
 
96
//                      botype = "alphaDecay";
 
97
//                      break;
 
98
//              case alphaDecayLikeliness:
 
99
//                      botype = "alphaDecayLikeliness";
 
100
//                      break;
 
101
//              case betaminusDecayLikeliness:
 
102
//                      botype = "betaminusDecayLikeliness";
 
103
//                      break;
 
104
//              case betaminusDecay:
 
105
//                      botype = "betaminusDecay";
 
106
//                      break;
 
107
//              case betaplusDecayLikeliness:
 
108
//                      botype = "betaplusDecayLikeliness";
 
109
//                      break;
 
110
//              case betaplusDecay:
 
111
//                      botype = "betaplusDecay";
 
112
//                      break;
 
113
//              case ecDecayLikeliness:
 
114
//                      botype = "ecDecayLikeliness";
 
115
//                      break;
 
116
//              case ecDecay:
 
117
//                      botype = "ecDecay";
 
118
//                      break;
 
119
//              case ionization:
 
120
//                      botype = "ionization";
 
121
//                      break;
 
122
//              case electronAffinity:
 
123
//                      botype = "electronAffinity";
 
124
//                      break;
 
125
//              case electronegativityPauling:
 
126
//                      botype = "electronegativityPauling";
 
127
//                      break;
 
128
//              case radiusCovalent:
 
129
//                      botype = "radiusCovalent";
 
130
//                      break;
 
131
//              case radiusVDW:
 
132
//                      botype = "radiusVDW";
 
133
//                      break;
 
134
//              case meltingpoint:
 
135
//                      botype = "meltingpoint";
 
136
//                      break;
 
137
//              case boilingpoint:
 
138
//                      botype = "boilingpoint";
 
139
//                      break;
 
140
//              case periodTableBlock:
 
141
//                      botype = "periodTableBlock";
 
142
//                      break;
 
143
//              case nameOrigin:
 
144
//                      botype = "nameOrigin";
 
145
//                      break;
 
146
//              case orbit:
 
147
//                      botype = "orbit";
 
148
//                      break;
 
149
//              case date:
 
150
//                      botype = "date";
 
151
//                      break;
 
152
//              case discoverers:
 
153
//                      botype = "discoverers";
 
154
//                      break;
 
155
//              case period:
 
156
//                      botype = "period";
 
157
//                      break;
 
158
//              case relativeAbundance:
 
159
//                      botype = "relativeAbundance";
 
160
//                      break;
 
161
//              case family:
 
162
//                      botype ="family";
 
163
//                      break;
 
164
//              case group:
 
165
//                      botype ="group";
 
166
//                      break;
 
167
//              case acidicbehaviour:
 
168
//                      botype ="acidicbehaviour";
 
169
//                      break;
 
170
//              case electronicConfiguration:
 
171
//                      botype ="electronicConfiguration";
 
172
//                      break;
 
173
//              case crystalstructure:
 
174
//                      botype ="crystalstructure";
 
175
//                      break;
 
176
//              case dangerSymbol:
 
177
//                      botype ="dangerSymbol";
 
178
//                      break;
 
179
//              case RPhrase:
 
180
//                      botype ="RPhrase";
 
181
//                      break;
 
182
//              case SPhrase:
 
183
//                      botype ="SPhrase";
 
184
//                      break;
 
185
//              case discoveryCountry:
 
186
//                      botype ="discoveryCountry";
 
187
//                      break;
 
188
//      }
 
189
// 
 
190
//      botype = botype.prepend( QLatin1String("bo:") );
 
191
//      
 
192
//      return botype;
 
193
// }
 
 
b'\\ No newline at end of file'