next up previous contents index
Next: Simple Examples Up: Miscellaneous Previous: Time Span and Time   Contents   Index


String Handling

String handling functions inside of the DEVSpp name space are available in StrUtil.h and StrUtil.cpp.
 string STR(int v);// return int v as a string
 string STR(conststring& s,int v);//s+::STR(v);
 string STR(unsigned v); // return int v as a string
 string STR(const string& s, unsigned v);//s+::STR(v);
 string STR(double v);// return int v as a string
 string STR(const string& s, double v);//s+::STR(v);

 //-- split string s using delimiter c by n times if possible
 vector<string> Split(const string& s, char c);

 //-- return the merged string with s from f to t with delimiter c
 string Merge(const vector<string>& s, unsigned f, char c);

 //-- return string(pt->Parent->Name+"."+pt->Name);
 string NameWithParent(DEVSpp::Port* pt);

 //-- hierarchical name of child from the view of under.
 //-- if under=NULL, the hierarchical name starts from the root model
 string HierName(const Devs* child, const Coupled* under=NULL);

If the user wants to check the computational time of a function f(), we can check it as follows.

unsigned long start_time = milliseconds();
f();
unsigned long end_time = milliseconds();
cout << "comp. time: " << end_time - start_time << endl;


MHHwang 2007-05-07