[shared] StorageFunction: add a method to write the name of the function

with an argument (f(x))
This commit is contained in:
Émilie Feral
2018-10-11 17:15:59 +02:00
parent 8c1f0f4cb2
commit e290c928e0
3 changed files with 19 additions and 14 deletions

View File

@@ -29,6 +29,21 @@ void StorageFunction::setColor(KDColor color) {
recordData()->setColor(color);
}
int StorageFunction::nameWithArgument(char * buffer, size_t bufferSize, char arg) {
const char * functionName = fullName();
int index = 0;
const char ofXSring[4] = {'(',arg,')', 0};
size_t ofXSringLength = strlen(ofXSring);
while (*functionName != Ion::Storage::k_dotChar
&& index < bufferSize - ofXSringLength - 1)
{
// We keep room to write the final "(x)" //TODO should we?
assert(functionName < fullName() + strlen(fullName()));
buffer[index++] = *functionName++;
}
return index - 1 + strlcpy(&buffer[index], ofXSring, bufferSize);
}
template<typename T>
T StorageFunction::templatedApproximateAtAbscissa(T x, Poincare::Context * context) const {
const char unknownX[2] = {Poincare::Symbol::UnknownX, 0};