Numworks Epsilon  1.4.1
Graphing Calculator Operating System
helpers.cpp
Go to the documentation of this file.
1 #include "helpers.h"
2 #include <string.h>
3 
4 namespace Code {
5 namespace Helpers {
6 
7 class EventTextPair {
8 public:
9  constexpr EventTextPair(Ion::Events::Event event, const char * text) : m_event(event), m_text(text) {}
10  Ion::Events::Event event() const { return m_event; }
11  const char * text() const { return m_text; }
12 private:
13  const Ion::Events::Event m_event;
14  const char * m_text;
15 };
16 
17 static constexpr EventTextPair sEventTextMap[] = {
18  EventTextPair(Ion::Events::XNT, "x"),
19  EventTextPair(Ion::Events::Exp, "exp()"),
20  EventTextPair(Ion::Events::Ln, "log()"),
21  EventTextPair(Ion::Events::Log, "log10()"),
22  EventTextPair(Ion::Events::Sine, "sin()"),
23  EventTextPair(Ion::Events::Cosine, "cos()"),
24  EventTextPair(Ion::Events::Tangent, "tan()"),
25  EventTextPair(Ion::Events::Imaginary, "1j"),
26  EventTextPair(Ion::Events::Power, "**"),
27  EventTextPair(Ion::Events::Pi, "pi"),
28  EventTextPair(Ion::Events::Sqrt, "sqrt()"),
29  EventTextPair(Ion::Events::Square, "**2"),
30  EventTextPair(Ion::Events::Multiplication, "*"),
31  EventTextPair(Ion::Events::EE, "e"),
32  EventTextPair(Ion::Events::Arcsine, "asin()"),
33  EventTextPair(Ion::Events::Arccosine, "acos()"),
34  EventTextPair(Ion::Events::Arctangent, "atan()")
35 };
36 
38  for (size_t i=0; i<sizeof(sEventTextMap)/sizeof(sEventTextMap[0]); i++) {
39  if (event == sEventTextMap[i].event()) {
40  return sEventTextMap[i].text();
41  }
42  }
43  return nullptr;
44 }
45 
46 }
47 }
constexpr Event EE
Definition: events.h:112
constexpr Event Power
Definition: events.h:83
constexpr Event Arctangent
Definition: events.h:136
constexpr Event Tangent
Definition: events.h:87
constexpr Event Square
Definition: events.h:90
constexpr Event Exp
Definition: events.h:78
constexpr Event Ln
Definition: events.h:79
constexpr Event Sqrt
Definition: events.h:89
constexpr EventTextPair(Ion::Events::Event event, const char *text)
Definition: helpers.cpp:9
constexpr Event Cosine
Definition: events.h:86
constexpr Event Arcsine
Definition: events.h:134
constexpr Event Pi
Definition: events.h:88
Ion::Events::Event event() const
Definition: helpers.cpp:10
Definition: app.cpp:7
constexpr Event XNT
Definition: events.h:73
constexpr Event Arccosine
Definition: events.h:135
constexpr Event Sine
Definition: events.h:85
constexpr Event Imaginary
Definition: events.h:81
constexpr Event Multiplication
Definition: events.h:101
const char * text() const
Definition: helpers.cpp:11
const char * PythonTextForEvent(Ion::Events::Event event)
Definition: helpers.cpp:37
constexpr Event Log
Definition: events.h:80