[Compbench-devel] CompBenchmarks++/System System.cpp, 1.6, 1.7 System.h, 1.9, 1.10
Brought to you by:
xfred
From: Frederic T. <xf...@us...> - 2006-11-01 10:29:45
|
Update of /cvsroot/compbench/CompBenchmarks++/System In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv17750 Modified Files: System.cpp System.h Log Message: New string manipulation methods. Split has been taken from the System-Cygwin object. Chomp() added. Index: System.cpp =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/System/System.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** System.cpp 25 Sep 2006 15:54:25 -0000 1.6 --- System.cpp 1 Nov 2006 10:29:40 -0000 1.7 *************** *** 1,4 **** --- 1,5 ---- #include <System/System.h> #include <System/md5.h> + #include <Benchmark/Benchmark-DLLoader.h> #include <UI/UI.h> *************** *** 103,117 **** } void CBMSystem::display(void) { ! std::cout << "host::arch=" << arch() ! << "host::hostid=" << hostid() ! << "host::hostname=" << hostname() ! << "host::os=" << os() ! << "host::os_version=" << os_version() ! << "host::processor_name=" << processor_name() ! << "host::processor_mhz=" << processor_mhz() ! << "host::processor_cache=" << processor_cache() ! << "host::processor_number=" << processor_number(); } --- 104,159 ---- } + + + std::string CBMSystem::Split(const std::string& str, const std::string& delim, int wantedIndex) + { + unsigned int offset = 0; + unsigned int delimIndex = 0; + unsigned int nowIndex = 0; + + delimIndex = str.find(delim, offset); + + while (delimIndex != std::string::npos) + { + if (wantedIndex==nowIndex) + return(str.substr(offset, delimIndex - offset)); + offset += delimIndex - offset + delim.length(); + delimIndex = str.find(delim, offset); + nowIndex++; + } + if (wantedIndex==nowIndex) + return(str.substr(offset)); + else + return(""); + } + + void CBMSystem::Chomp(std::string& str) + { + int l = str.length(); + + if (l) { + if (str[l-1]=='\n') { + str.resize(l-1); + l--; + } + if (l) + if (str[l-1]=='\r') { + str.resize(l-1); + l--; + } + } + } + void CBMSystem::display(void) { ! std::cout << "host::arch=" << arch() << std::endl ! << "host::hostid=" << hostid() << std::endl ! << "host::hostname=" << hostname() << std::endl ! << "host::os=" << os() << std::endl ! << "host::os_version=" << os_version() << std::endl ! << "host::processor_name=" << processor_name() << std::endl ! << "host::processor_mhz=" << processor_mhz() << std::endl ! << "host::processor_cache=" << processor_cache() << std::endl ! << "host::processor_number=" << processor_number() << std::endl; } *************** *** 222,226 **** host=hostname(); - host.erase(host.length()-1); switch(where) { --- 264,267 ---- *************** *** 363,366 **** --- 404,409 ---- std::string fn; + cbmlib_done(); + fn=temporaryDirectory(CBMSystem::Status); fn+="/"; Index: System.h =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/System/System.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** System.h 25 Sep 2006 15:54:25 -0000 1.9 --- System.h 1 Nov 2006 10:29:40 -0000 1.10 *************** *** 106,109 **** --- 106,122 ---- virtual int init(void); + /** Split a std::string. + * Split given string as sub-strings, according to an arbitrary delimiter. + * \param str string to split + * \param delim delimiter + * \param wantedIndex sub-string index */ + virtual std::string Split(const std::string& str, + const std::string& delim, + int wantedIndex); + + /** Remove trailing line-feed (and carriage return) from specified string. + * \param str the string */ + virtual void Chomp(std::string& str); + /** Describe host. * Displays informations about processors, OS, and so on. |