RubyRequest.cc revision 8165:5955406f7ed0
1#include <iostream> 2 3#include "mem/ruby/slicc_interface/RubyRequest.hh" 4 5using namespace std; 6 7ostream& 8operator<<(ostream& out, const RubyRequest& obj) 9{ 10 out << hex << "0x" << obj.paddr << " data: 0x" << flush; 11 for (int i = 0; i < obj.len; i++) { 12 out << (int)obj.data[i]; 13 } 14 out << dec << " type: " << RubyRequestType_to_string(obj.type) << endl; 15 return out; 16} 17 18vector<string> 19tokenizeString(string str, string delims) 20{ 21 vector<string> tokens; 22 char* pch; 23 char* tmp; 24 const char* c_delims = delims.c_str(); 25 tmp = new char[str.length()+1]; 26 strcpy(tmp, str.c_str()); 27 pch = strtok(tmp, c_delims); 28 while (pch != NULL) { 29 string tmp_str(pch); 30 if (tmp_str == "null") tmp_str = ""; 31 tokens.push_back(tmp_str); 32 33 pch = strtok(NULL, c_delims); 34 } 35 delete [] tmp; 36 return tokens; 37} 38