#include <kdebug.h>
-/* PORTING
- * #include "kalziumdataobject.h"
- */
-
#include "moleculeparser.h"
ElementCount *
ElementCountMap::search(Element *_element)
{
- //not yet tested but the commented code should be the same as
- //the foreach... so lets use Qt4 power
-//X QList<ElementCount *>::ConstIterator it = m_map.constBegin();
-//X const QList<ElementCount *>::ConstIterator itEnd = m_map.constEnd();
-//X
-//X for (; it != itEnd; ++it) {
-//X if ((*it)->element() == _element)
-//X return *it;
-//X }
-
foreach( ElementCount* c, m_map ){
if ( c->element() == _element )
return c;
void
ElementCountMap::add(ElementCountMap &_map)
{
- //not yet tested but the commented code should be the same as
- //the foreach... so lets use Qt4 power
-//X QList<ElementCount *>::ConstIterator it = _map.m_map.constBegin();
-//X const QList<ElementCount *>::ConstIterator itEnd = _map.m_map.constEnd();
-//X
-//X // Step throught _map and for each element, add it to the current one.
-//X for (; it != itEnd; ++it) {
-//X add((*it)->m_element, (*it)->m_count);
-//X }
-
foreach( ElementCount* c, _map.m_map ){
add( c->m_element, c->m_count );
}
double *_resultMass,
ElementCountMap *_resultMap)
{
+ if ( _moleculeString == QString() )
+ return false;
+
// Clear the result variables and set m_error to false
_resultMap->clear();
m_error = false;
Element *
MoleculeParser::lookupElement( const QString& _name )
{
-//X QList<Element*> elementList = KalziumDataObject::instance()->ElementList;
-
kdDebug() << "looking up " << _name << endl;
-//X QList<Element*>::ConstIterator it = elementList.constBegin();
-//X const QList<Element*>::ConstIterator end = elementList.constEnd();
-
foreach( Element* e, m_elementList ){
if ( e->dataAsVariant(ChemicalDataObject::symbol) == _name ) {
kdDebug() << "Found element " << _name << endl;
}
}
-//X for (; it != end; ++it) {
-//X if ( (*it)->dataAsVariant(ChemicalDataObject::symbol) == _name ) {
-//X kdDebug() << "Found element " << _name << endl;
-//X return *it;
-//X }
-//X }
-
//if there is an error make m_error true.
m_error = true;
int
Parser::getNextChar()
{
- if (m_index == -1)
- return -1;
-
- // If end of string, then reset the parser.
- if (m_index == (int) m_str.length()) {
- m_index = -1;
- m_nextChar = -1;
- }
- else
- m_nextChar = m_str.at(++m_index).toLatin1();
+// kdDebug() << "Parser::getNextChar(): char = " << m_nextChar << endl;
+// kdDebug() << "m_str.size() " << m_str.size() << " with m_str: " << m_str << " and m_index: " << m_index << endl;
+
+ m_index++;
+
+ if (m_index == -1)
+ return -1;
- // Take care of null-terminated strings.
- if (m_nextChar == 0) {
- m_index = -1;
- m_nextChar = -1;
- }
+ // If end of string, then reset the parser.
+ if (m_index == m_str.size()) {
+ m_index = -1;
+ m_nextChar = -1;
+ }
+ else
+ m_nextChar = m_str.at(m_index).toLatin1();
- //kdDebug() << "Parser::getNextChar(): char = " << m_nextChar << endl;
+ // Take care of null-terminated strings.
+ if (m_nextChar == 0) {
+ m_index = -1;
+ m_nextChar = -1;
+ }
- return m_nextChar;
+ return m_nextChar;
}