• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

Analitza

  • sources
  • kde-4.14
  • kdeedu
  • analitza
  • analitza
value.h
Go to the documentation of this file.
1 /*************************************************************************************
2  * Copyright (C) 2007 by Aleix Pol <aleixpol@kde.org> *
3  * *
4  * This program is free software; you can redistribute it and/or *
5  * modify it under the terms of the GNU General Public License *
6  * as published by the Free Software Foundation; either version 2 *
7  * of the License, or (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 Free Software *
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
17  *************************************************************************************/
18 
19 #ifndef VALUE_H
20 #define VALUE_H
21 
22 #include "object.h"
23 #include "analitzaexport.h"
24 
25 #include <cmath>
26 
27 class QDomElement;
28 
29 namespace Analitza
30 {
31 
42 class ANALITZA_EXPORT Cn : public Object
43 {
44  public:
45  enum ValueFormat { Char=8, Real=7, Integer=3, Boolean=1 };
47  Cn(const Cn& v) : Object(v), m_value(v.value()), m_format(v.m_format) { Q_ASSERT(m_type==Object::value); }
48 
50  explicit Cn(const double &b=0.) : Object(Object::value), m_value(b), m_format(Real) {}
51 
53  explicit Cn(int i) : Object(Object::value), m_value(i), m_format(Integer) {}
54 
56  explicit Cn(uint i) : Object(Object::value), m_value(i), m_format(Integer) {}
57 
59  explicit Cn(bool b) : Object(Object::value), m_value(b?1.:0.), m_format(Boolean) {}
60 
62  explicit Cn(const QChar& c) : Object(Object::value), m_char(c.unicode()), m_format(Char) {}
63 
67  bool setValue(const QDomElement& e);
68 
73  void setValue(const double& v);
74  void setValue(int v);
75  void setValue(uint v);
76  void setValue(bool v);
77 
81  inline double value() const { return m_value; }
82  inline double& rvalue() { return m_value; }
83 
87  int intValue() const { return static_cast<int>(std::floor(m_value)); }
88 
92  bool isBoolean() const { return m_format==Boolean; }
93 
97  bool isCharacter() const { return m_format==Char; }
98 
99  ValueFormat format() const { return m_format; }
100 
104  void setBoolean(bool b) { m_format= b ? Boolean : Real; }
105 
109  bool isTrue() const { Q_ASSERT(m_format==Boolean); return m_value!=0.; }
110 
111 // static double toNum(const QString& num, const QString& type, int base);
112 // static enum ValueFormat whatValueFormat(const QDomElement&);
113 
117  bool isInteger() const { return std::floor(m_value)==m_value; }
118 
122  bool operator==(const Cn& d) const { return m_value==d.m_value; }
123 
127  bool operator<(const Cn& d) const { return m_value<d.m_value; }
128 
132  bool operator<(double d) const { return m_value<d; }
133 
137  bool operator<=(const Cn& d) const { return m_value<=d.m_value; }
138 
142  bool operator<=(double d) const { return m_value<=d; }
143 
147  Cn operator=(double d) { m_value=d; return *this; }
148 
149  QChar character() const { Q_ASSERT(m_format==Char); return QChar(m_char); }
150 
151  virtual QVariant accept(AbstractExpressionVisitor*) const;
152  virtual bool isZero() const { return m_value==0.; }
153 
154  virtual bool matches(const Object* exp, QMap< QString, const Object* >* found) const;
155  /*
158  virtual Object* copy() const;
159 
160  static Cn pi();
161  static Cn e();
162  static Cn euler();
163  private:
164  union { double m_value; ushort m_char; };
165  enum ValueFormat m_format;
166 };
167 
168 }
169 
170 #endif
Analitza::Cn::Cn
Cn(const QChar &c)
Constructor.
Definition: value.h:62
Analitza::AbstractExpressionVisitor
Definition: abstractexpressionvisitor.h:49
Analitza::Cn::operator<=
bool operator<=(const Cn &d) const
Definition: value.h:137
Analitza::Object::value
Describes an object as a value.
Definition: object.h:44
QChar
Analitza::Cn::intValue
int intValue() const
Definition: value.h:87
Analitza::Cn::operator<=
bool operator<=(double d) const
Definition: value.h:142
QMap
Analitza::Cn::rvalue
double & rvalue()
Definition: value.h:82
Analitza::Cn::m_value
double m_value
Definition: value.h:164
Analitza::Cn::ValueFormat
ValueFormat
Definition: value.h:45
Analitza::Cn
Cn is a value in MathML.
Definition: value.h:42
Analitza::Cn::isBoolean
bool isBoolean() const
Definition: value.h:92
Analitza::Cn::format
ValueFormat format() const
Definition: value.h:99
Analitza::Cn::operator<
bool operator<(const Cn &d) const
Definition: value.h:127
Analitza::Cn::Cn
Cn(uint i)
Definition: value.h:56
Analitza::Cn::isZero
virtual bool isZero() const
Definition: value.h:152
Analitza::Cn::Cn
Cn(int i)
Constructor.
Definition: value.h:53
Analitza::Cn::operator<
bool operator<(double d) const
Definition: value.h:132
Analitza::Cn::value
double value() const
Returns the value.
Definition: value.h:81
Analitza::Cn::isTrue
bool isTrue() const
Definition: value.h:109
Analitza::Cn::character
QChar character() const
Definition: value.h:149
analitzaexport.h
Analitza::Cn::operator=
Cn operator=(double d)
Sets the new value to d.
Definition: value.h:147
Analitza::Cn::Cn
Cn(const Cn &v)
Copy constructor.
Definition: value.h:47
Analitza::Cn::isInteger
bool isInteger() const
Definition: value.h:117
Analitza::Cn::setBoolean
void setBoolean(bool b)
Sets whether this value is boolean or not.
Definition: value.h:104
Analitza::Object
Definition: object.h:38
object.h
ANALITZA_EXPORT
#define ANALITZA_EXPORT
Definition: analitzaexport.h:31
Analitza::Cn::Cn
Cn(bool b)
Constructor.
Definition: value.h:59
Analitza::Cn::operator==
bool operator==(const Cn &d) const
Definition: value.h:122
Analitza::Cn::Cn
Cn(const double &b=0.)
Constructor.
Definition: value.h:50
Analitza::Cn::isCharacter
bool isCharacter() const
Definition: value.h:97
QDomElement
QVariant
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:11:37 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Analitza

Skip menu "Analitza"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal