27 #include <boost/locale.hpp> 39 if (name.substr(name.length()-2)==
":_")
return false;
41 static const string constantPrefix=
"constant:", tempPrefix=
"temp:";
42 auto nameCStr=name.c_str();
43 const char* endp=
nullptr;
44 strtoull(nameCStr,&const_cast<char*&>(endp),10);
45 if (*endp==
':' || name.starts_with(constantPrefix)||name.starts_with(tempPrefix))
49 if (name[constantPrefix.length()-1]==
':')
50 endp=nameCStr+constantPrefix.length()-1;
52 endp=nameCStr+tempPrefix.length()-1;
55 for (
auto c=endp+1; *c!=
'\0'; ++c)
56 if (strchr(
":\\ \f\n\r\t\v",*c))
71 if (
scope==0)
return tmp;
83 size_t scope(
const string& name)
85 if (name.starts_with(
"temp:"))
return 0;
86 auto nm=utf_to_utf<char>(name);
87 auto nameCStr=nm.c_str();
89 const size_t r=strtoull(nameCStr,&endp,10);
90 if (endp && *endp==
':')
92 throw error(
"scope requested for local variable");
108 if (a_name[0]==
':' &&
scope)
111 for (
auto g=
scope->group.lock(); g; g=g->group.lock())
112 for (
auto& i: g->items)
113 if (
auto v=i->variableCast())
115 if (v->canonicalName()==name)
118 goto break_outerloop;
130 if (name.empty() || !
scope || !
scope->group.lock())
135 std::string
uqName(
const std::string& name)
137 const string::size_type p=name.rfind(
':');
139 return utf_to_utf<char>(name);
140 return utf_to_utf<char>(name).substr(p+1);
string valueIdCanonical(size_t scope, const string &name)
construct a valueId @ name should be canonicalised
std::string uqName(const std::string &name)
extract unqualified portion of name
string valueId(const GroupPtr &ref, const string &name)
construct a valueId. @ name should not be canonicalised if name has leading :, then heirarchy is sear...
Creation and access to the minskyTCL_obj object, which has code to record whenever Minsky's state cha...
std::string trimWS(const std::string &s)
std::string stripActive(const std::string &s)
repaces characters that cause interpretation by TCL, backslashes are replaced by the set minus operat...
string latexToPangoNonItalicised(const char *input)
string canonicalName(const string &name)
convert a raw name into a canonical name - this is not idempotent.
bool isValueId(const string &name)
check that name is a valid valueId (useful for assertions)
string valueIdFromScope(const GroupPtr &scope, const std::string &name)
value Id from scope and canonical name name
std::shared_ptr< Group > GroupPtr
string to_string(CONST84 char *x)
GroupPtr scope(GroupPtr scope, const string &a_name)
starting from reference group ref, applying scoping rules to determine the actual scope of name If na...