Blame view

build5/epsilon-master/poincare/src/undefined.cpp 1.04 KB
6663b6c9   adorian   projet complet av...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  #include <poincare/undefined.h>
  #include <poincare/layout_engine.h>
  
  extern "C" {
  #include <math.h>
  #include <string.h>
  }
  
  namespace Poincare {
  
  Expression::Type Undefined::type() const {
    return Type::Undefined;
  }
  
  Expression * Undefined::clone() const {
    return new Undefined();
  }
  
  int Undefined::polynomialDegree(char symbolName) const {
    return -1;
  }
  
  template<typename T> Complex<T> * Undefined::templatedApproximate(Context& context, AngleUnit angleUnit) const {
    return new Complex<T>(Complex<T>::Undefined());
  }
  
  ExpressionLayout * Undefined::createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const {
    char buffer[16];
    int numberOfChars = PrintFloat::convertFloatToText<float>(NAN, buffer, 16, 1, floatDisplayMode);
    return LayoutEngine::createStringLayout(buffer, numberOfChars);
  }
  
  int Undefined::writeTextInBuffer(char * buffer, int bufferSize, PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const {
    if (bufferSize == 0) {
      return -1;
    }
    return strlcpy(buffer, "undef", bufferSize);
  }
  
  }