15 assert(numberOfOperands > 1);
18 for (
int i=1; i<numberOfOperands; i++) {
19 children_layouts[2*i-1] =
new StringLayout(operatorName, 1);
25 delete[] children_layouts;
34 if (numberOfOperands > 0) {
37 grandChildrenLayouts[layoutIndex++] = expression->
operand(0)->
createLayout(floatDisplayMode, complexFormat);
38 for (
int i = 1; i < numberOfOperands; i++) {
39 grandChildrenLayouts[layoutIndex++] =
new StringLayout(
",", 1);
40 grandChildrenLayouts[layoutIndex++] = expression->
operand(i)->
createLayout(floatDisplayMode, complexFormat);
44 argumentLayouts =
new HorizontalLayout(grandChildrenLayouts, 2*numberOfOperands-1);
45 delete [] grandChildrenLayouts;
55 if (bufferSize == 0) {
58 buffer[bufferSize-1] = 0;
61 assert(numberOfOperands > 1);
62 if (numberOfChar >= bufferSize-1) {
return bufferSize-1; }
63 if (expression->
operand(0)->needParenthesisWithParent(expression)) {
64 buffer[numberOfChar++] =
'(';
65 if (numberOfChar >= bufferSize-1) {
return bufferSize-1; }
67 numberOfChar += expression->
operand(0)->
writeTextInBuffer(buffer+numberOfChar, bufferSize-numberOfChar, numberOfDigits);
68 if (expression->
operand(0)->needParenthesisWithParent(expression)) {
69 buffer[numberOfChar++] =
')';
70 if (numberOfChar >= bufferSize-1) {
return bufferSize-1; }
72 for (
int i=1; i<numberOfOperands; i++) {
73 if (numberOfChar >= bufferSize-1) {
return bufferSize-1; }
74 numberOfChar +=
strlcpy(buffer+numberOfChar, operatorName, bufferSize-numberOfChar);
75 if (numberOfChar >= bufferSize-1) {
return bufferSize-1; }
76 if (expression->
operand(i)->needParenthesisWithParent(expression)) {
77 buffer[numberOfChar++] =
'(';
78 if (numberOfChar >= bufferSize-1) {
return bufferSize-1; }
80 numberOfChar += expression->
operand(i)->
writeTextInBuffer(buffer+numberOfChar, bufferSize-numberOfChar, numberOfDigits);
81 if (expression->
operand(i)->needParenthesisWithParent(expression)) {
82 buffer[numberOfChar++] =
')';
83 if (numberOfChar >= bufferSize-1) {
return bufferSize-1; }
86 buffer[numberOfChar] = 0;
91 if (bufferSize == 0) {
94 buffer[bufferSize-1] = 0;
96 numberOfChar +=
strlcpy(buffer, operatorName, bufferSize);
97 if (numberOfChar >= bufferSize-1) {
return bufferSize-1; }
98 buffer[numberOfChar++] =
'(';
99 if (numberOfChar >= bufferSize-1) {
return bufferSize-1; }
101 if (numberOfOperands > 0) {
102 numberOfChar += expression->
operand(0)->
writeTextInBuffer(buffer+numberOfChar, bufferSize-numberOfChar, numberOfDigits);
103 for (
int i = 1; i < numberOfOperands; i++) {
104 if (numberOfChar >= bufferSize-1) {
return bufferSize-1; }
105 buffer[numberOfChar++] =
',';
106 if (numberOfChar >= bufferSize-1) {
return bufferSize-1; }
107 numberOfChar += expression->
operand(i)->
writeTextInBuffer(buffer+numberOfChar, bufferSize-numberOfChar, numberOfDigits);
109 if (numberOfChar >= bufferSize-1) {
return bufferSize-1; }
111 buffer[numberOfChar++] =
')';
112 buffer[numberOfChar] = 0;
static int writeInfixExpressionTextInBuffer(const Expression *expression, char *buffer, int bufferSize, int numberOfDigits, const char *operatorName)
size_t strlcpy(char *dst, const char *src, size_t len)
size_t strlen(const char *s)
virtual int numberOfOperands() const =0
static ExpressionLayout * createPrefixLayout(const Expression *expression, PrintFloat::Mode floatDisplayMode, Expression::ComplexFormat complexFormat, const char *operatorName)
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode=PrintFloat::Mode::Default, ComplexFormat complexFormat=ComplexFormat::Default) const
static ExpressionLayout * createInfixLayout(const Expression *expression, PrintFloat::Mode floatDisplayMode, Expression::ComplexFormat complexFormat, const char *operatorName)
static int writePrefixExpressionTextInBuffer(const Expression *expression, char *buffer, int bufferSize, int numberOfDigits, const char *operatorName)
const Expression * operand(int i) const
virtual Type type() const =0
virtual int writeTextInBuffer(char *buffer, int bufferSize, int numberOfSignificantDigits=PrintFloat::k_numberOfStoredSignificantDigits) const =0