User Guide
nmodl::codegen::utils Namespace Reference

Functions

std::string format_double_string (const std::string &s_value)
 Handles the double constants format being printed in the generated code. More...
 
std::string format_float_string (const std::string &s_value)
 Handles the float constants format being printed in the generated code. More...
 

Function Documentation

◆ format_double_string()

std::string nmodl::codegen::utils::format_double_string ( const std::string &  s_value)

Handles the double constants format being printed in the generated code.

We can directly print value but if user specify value as integer then then it gets printed as an integer. To avoid this, we use below wrappers. If user has provided integer then it gets printed as 1.0 (similar to mod2c and neuron where ".0" is appended). Otherwise we print double variables as they are represented in the mod file by user. If the value is in scientific representation (1e+20, 1E-15) then keep it as it is.

It takes care of printing the values with the correct floating point precision for each backend, similar to mod2c and Neuron. This function can be called using as template CodegenCppVisitor

Parameters
s_valueThe double constant as string
Returns
The proper string to be printed in the generated file.

Definition at line 23 of file codegen_utils.cpp.

◆ format_float_string()

std::string nmodl::codegen::utils::format_float_string ( const std::string &  s_value)

Handles the float constants format being printed in the generated code.

It takes care of printing the values with the correct floating point precision for each backend, similar to mod2c and Neuron. This function can be called using as template CodegenCppVisitor

Parameters
s_valueThe double constant as string
Returns
The proper string to be printed in the generated file.

Definition at line 32 of file codegen_utils.cpp.