20 #include "variableType.rcd" 30 string VariableType::typeName(
int t)
31 {
return enumKey<Type>(t);}
40 string Units::latexStr()
const 44 if (!i.first.empty() && i.second!=0)
56 Units::Units(
const string& x)
58 if (x.empty())
return;
60 auto divPos=x.find(
'/');
61 vector<string> components;
62 components.push_back(x.substr(0,divPos));
63 if (divPos!=string::npos)
64 components.push_back(x.substr(divPos+1));
66 if (components.back().find(
'/')!=string::npos)
67 throw runtime_error(
"too many division signs: "+x);
70 for (
auto& i: components)
73 throw runtime_error(
"empty numerator or denominator: "+x);
74 const char* b=i.c_str();
75 for (
const char*j=b;;)
77 if (*j==
'^'||*j==
'\0'||isspace(*j))
79 const string name(b,j);
81 throw runtime_error(
"empty unit name: "+x);
82 while (isspace(*j)) ++j;
86 const int v=strtol(k,const_cast<char**>(&j),10);
88 throw runtime_error(
"invalid exponent: "+x);
90 (*this)[name]+=coef*v;
96 while (isspace(*j)) ++j;
Creation and access to the minskyTCL_obj object, which has code to record whenever Minsky's state cha...
std::string str(T x)
utility function to create a string representation of a numeric type
CLASSDESC_ACCESS_EXPLICIT_INSTANTIATION(minsky::VariableType)
string to_string(CONST84 char *x)