4 #include <unordered_map> 31 const size_t numStrings = m_SupportCode.size();
32 m_SupportCode.emplace(code, m_NamespacePrefix + std::to_string(numStrings));
39 const auto s = m_SupportCode.find(code);
40 assert(s != m_SupportCode.cend());
47 void gen(
CodeStream &os,
const std::string &ftype,
const bool supportsNamespace =
true)
const 50 for(
const auto &s : m_SupportCode) {
51 if (supportsNamespace) {
53 os <<
"namespace " << s.second;
61 std::regex r(
"\\w+(?=\\(.*\\)\\s*\\{)");
62 os <<
ensureFtype(std::regex_replace(s.first, r, s.second +
"_$&"), ftype) << std::endl;
76 std::unordered_map<std::string, std::string> m_SupportCode;
79 const std::string m_NamespacePrefix;
SupportCodeMerged(const std::string &namespacePrefix)
Definition: supportCodeMerged.h:18
size_t getNumSupportCodeString() const
Gets the number of support code strings hence namespaces which will be generated. ...
Definition: supportCodeMerged.h:69
Helper class for generating code - automatically inserts brackets, indents etc.
Definition: backendBase.h:30
Definition: codeStream.h:21
void addSupportCode(const std::string &code)
Add support code string.
Definition: supportCodeMerged.h:25
const std::string & getSupportCodeNamespace(const std::string &code) const
Gets the name of the support code namespace which should be 'used' to provide this support code...
Definition: supportCodeMerged.h:37
void gen(CodeStream &os, const std::string &ftype, const bool supportsNamespace=true) const
Generate support code.
Definition: supportCodeMerged.h:47
GENN_EXPORT std::string ensureFtype(const std::string &oldcode, const std::string &type)
This function implements a parser that converts any floating point constant in a code snippet to a fl...
Definition: codeGenUtils.cc:373
Definition: supportCodeMerged.h:15
Definition: codeStream.h:94