00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #include <stdlib.h>
00036 #include <stdio.h>
00037 #include <string.h>
00038 #include <assert.h>
00039
00040 #include <mps/mps.h>
00041
00042 namespace MPS {
00043
00044 char const *MPS_version_string = "MPSIDL version " MPSIDL_VERSION;
00045
00046 vector<string> Address::splitResolvedName(string const &resolvedName) {
00047 vector<string> result;
00048 string::size_type startAt = 0;
00049
00050 for (string::size_type colonPos = resolvedName.find(':', startAt);
00051 colonPos != resolvedName.npos;
00052 startAt = colonPos + 1, colonPos = resolvedName.find(':', startAt)) {
00053 string part = resolvedName.substr(startAt, colonPos - startAt);
00054 result.push_back(part);
00055 }
00056
00057 string finalPart = resolvedName.substr(startAt);
00058 result.push_back(finalPart);
00059 return result;
00060 }
00061
00062 void Address::become(string const &resolvedName) {
00063 vector<string> parts = splitResolvedName(resolvedName);
00064
00065 if (parts.size() < 2 ||
00066 parts[0] != "mps") {
00067 throw MPSException("Invalid object name " + resolvedName);
00068 }
00069
00070 transport = parts[1];
00071 for (vector<string>::iterator i = &parts[2];
00072 i != parts.end();
00073 i++) {
00074 params.push_back(*i);
00075 }
00076 }
00077
00078 string Address::getResolvedName() const {
00079 string result = "mps:" + transport;
00080 for (vector<string>::const_iterator i = params.begin();
00081 i != params.end();
00082 i++) {
00083 result += ':';
00084 result += *i;
00085 }
00086 return result;
00087 }
00088
00089 }