summaryrefslogtreecommitdiff
path: root/base/str.cc
diff options
context:
space:
mode:
authorRon Dreslinski <rdreslin@umich.edu>2005-02-09 16:23:56 -0500
committerRon Dreslinski <rdreslin@umich.edu>2005-02-09 16:23:56 -0500
commit118b374b84bea9cd3a5120d92be5bfbaec13416f (patch)
treef8d86dd3585c7b87c60db0ffea5ff067c1571a7d /base/str.cc
parent230a5a608dfb2204e2886a795e6bd8a30224b84f (diff)
parent061f40df08f6992bf314eb6f23315ef415e58882 (diff)
downloadgem5-118b374b84bea9cd3a5120d92be5bfbaec13416f.tar.xz
Merge zizzer:/z/m5/Bitkeeper/m5
into zizzer.eecs.umich.edu:/.automount/zazzer/z/rdreslin/m5bk/timing_L1 --HG-- extra : convert_revision : c12f7ad9143bc69d25c39132d30889f22c73edf1
Diffstat (limited to 'base/str.cc')
-rw-r--r--base/str.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/base/str.cc b/base/str.cc
index dd8d80043..5357ba79f 100644
--- a/base/str.cc
+++ b/base/str.cc
@@ -39,6 +39,36 @@
using namespace std;
+bool
+split_first(const string &s, string &lhs, string &rhs, char c)
+{
+ string::size_type offset = s.find(c);
+ if (offset == string::npos) {
+ lhs = s;
+ rhs = "";
+ return false;
+ }
+
+ lhs = s.substr(0, offset);
+ rhs = s.substr(offset + 1);
+ return true;
+}
+
+bool
+split_last(const string &s, string &lhs, string &rhs, char c)
+{
+ string::size_type offset = s.rfind(c);
+ if (offset == string::npos) {
+ lhs = s;
+ rhs = "";
+ return false;
+ }
+
+ lhs = s.substr(0, offset);
+ rhs = s.substr(offset + 1);
+ return true;
+}
+
void
tokenize(vector<string>& v, const string &s, char token, bool ignore)
{