METASOURCES = AUTO
+DOXYGEN_SET_WARN_IF_UNDOCUMENTED = YES
+DOXYGEN_SET_INTERNAL_DOCS = YES
ElementCount *
ElementCountMap::search(Element *_element)
{
- QList<ElementCount *>::ConstIterator it = m_map.constBegin();
- const QList<ElementCount *>::ConstIterator itEnd = m_map.constEnd();
-
- for (; it != itEnd; ++it) {
- if ((*it)->element() == _element)
- return *it;
+ //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;
}
return 0;
void
ElementCountMap::add(ElementCountMap &_map)
{
- QList<ElementCount *>::ConstIterator it = _map.m_map.constBegin();
- const QList<ElementCount *>::ConstIterator itEnd = _map.m_map.constEnd();
-
- // Step throught _map and for each element, add it to the current one.
- for (; it != itEnd; ++it) {
- add((*it)->m_element, (*it)->m_count);
+ //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 );
}
}
#include "element.h"
#include "parser.h"
-#include <qmap.h>
-#include <qlist.h>
+#include <QMap>
+#include <QList>
/**
* @class ElementCountMap
+ * @author Inge Wallin
*/
-class ElementCount {
- public:
- ElementCount(Element *_element, int _count)
- {
- m_element = _element;
- m_count = _count;
- }
- ElementCount(Element *_element)
- {
- m_element = _element;
- m_count = 0;
- }
-
- ~ElementCount();
-
- Element *element() const { return m_element; }
- int count() const { return m_count; }
- void add(int _count) { m_count += _count; }
- void multiply(int _factor) { m_count *= _factor; }
-
- Element *m_element;
- int m_count;
+class ElementCount
+{
+ public:
+ /**
+ * Constructor
+ */
+ ElementCount(Element *_element, int _count)
+ {
+ m_element = _element;
+ m_count = _count;
+ }
+
+ /**
+ * Constructor
+ */
+ ElementCount(Element *_element)
+ {
+ m_element = _element;
+ m_count = 0;
+ }
+ /**
+ * Destructor
+ */
+ ~ElementCount();
+
+ /**
+ * @return the Element
+ */
+ Element *element() const { return m_element; }
+
+ /**
+ * @return the number of occurences of the Element
+ */
+ int count() const { return m_count; }
+
+ /**
+ * Add @p _count occurences of the Element
+ * @param _count The number of times the Element occurs
+ */
+ void add(int _count) { m_count += _count; }
+ void multiply(int _factor) { m_count *= _factor; }
+
+ /**
+ * The Element of the object
+ */
+ Element *m_element;
+
+ /**
+ * The number of occurences
+ */
+ int m_count;
};
/**
+ * This class is used to count the elements in the molecule
+ * which is being calculated
+ *
* @class ElementCount
+ * @author Inge Wallin
*/
-class ElementCountMap {
- public:
- ElementCountMap();
- ~ElementCountMap();
-
- /**
- *
- */
- void clear() { m_map.clear(); }
-
- /**
- * @param _element
- */
- ElementCount *search(Element *_element);
-
- /**
- * @param _map
- */
- void add(ElementCountMap &_map);
-
- /**
- * @param _element
- * @param _count
- */
- void add(Element *_element, int _count);
-
- /**
- * @param _factor
- */
- void multiply(int _factor);
-
- /**
- * typedef
- */
- typedef QList<ElementCount*>::Iterator Iterator;
-
- /**
- *
- */
- Iterator begin() { return m_map.begin(); }
-
- /**
- *
- */
- Iterator end() { return m_map.end(); }
-
- private:
- QList<ElementCount*> m_map;
+class ElementCountMap
+{
+ public:
+ /**
+ * Constructor
+ */
+ ElementCountMap();
+
+ /**
+ * Destructor
+ */
+ ~ElementCountMap();
+
+ /**
+ * Clear the map of ElementCount pointers
+ */
+ void clear() { m_map.clear(); }
+
+ /**
+ * @param _element the searched Element
+ * @return the Element which is searched
+ */
+ ElementCount *search(Element *_element);
+
+ /**
+ * @param _map
+ */
+ void add(ElementCountMap &_map);
+
+ /**
+ * @param _element
+ * @param _count
+ */
+ void add(Element *_element, int _count);
+
+ /**
+ * @param _factor
+ */
+ void multiply(int _factor);
+
+ /**
+ * typedef
+ */
+ typedef QList<ElementCount*>::Iterator Iterator;
+
+ /**
+ *
+ */
+ Iterator begin() { return m_map.begin(); }
+
+ /**
+ *
+ */
+ Iterator end() { return m_map.end(); }
+
+ private:
+ QList<ElementCount*> m_map;
};
#ifndef PARSER_H
#define PARSER_H
-#include <qstring.h>
+#include <QString>
/**
* @class Parser
*/
class Parser {
public:
- // All characters are their own token value per default.
- static const int INT_TOKEN = 257;
- static const int FLOAT_TOKEN = 258;
- // Extend this list in your subclass to make a more advanced parser.
-
/**
* Constructor
*/
bool parseSimpleFloat(double *_result);
protected:
+ /**
+ * All characters are their own token value per default.
+ * Extend this list in your subclass to make a more advanced parser.
+ */
+ static const int INT_TOKEN = 257;
+
+ /**
+ * All characters are their own token value per default.
+ * Extend this list in your subclass to make a more advanced parser.
+ */
+ static const int FLOAT_TOKEN = 258;
/**
* Make the next character the current one.
// union, but I don't think it is necessary to bother, since they
// are so few and we don't instantiate a lot of copies of the
// parser.
+
+ /**
+ * Valid if m_nextToken == INT_TOKEN
+ */
int m_intVal; // Valid if m_nextToken == INT_TOKEN
+
+ /**
+ * Valid if m_nextToken == FLOAT_TOKEN
+ */
double m_floatVal; // Valid if m_nextToken == FLOAT_TOKEN
};