00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "URI.h"
00021
00022 #define DEFAULT_PORT "2809"
00023 #define DEFAULT_HOST "localhost"
00024
00030 utils::URI::URI( const string &s ) {
00031 _isValid = false;
00032
00033 string t;
00034 string::size_type l;
00035
00036 if( s.find("fbfs:/") != 0 )
00037 return;
00038 t = s.substr(6, s.length()-6);
00039 l = t.find("/");
00040 if( l == string::npos )
00041 return;
00042 string address = t.substr(0,l);
00043 string service = t.substr(l+1,t.length()-l-1);
00044 l = address.find(":");
00045 if( l == string::npos ) {
00046 _host = address;
00047 _port = DEFAULT_PORT;
00048 } else {
00049 _host = address.substr(0,l);
00050 _port = address.substr(l+1,address.length()-l-1);
00051 };
00052 if( _host.length() == 0 )
00053 _host = DEFAULT_HOST;
00054 l = service.find("@");
00055 if( l == string::npos )
00056 return;
00057 _service = service.substr(0,l);
00058 t = service.substr(l+1,service.length()-l-1);
00059 l = t.find("/");
00060 if( l == string::npos )
00061 return;
00062 _context = t.substr(0,l);
00063 _name = t.substr(l+1,t.length()-l-1);
00064 _isValid = true;
00065 };
00066
00067 string utils::URI::nameServerURL() const {
00068 return "corbaloc::" + _host + ":" + _port + "/NameService";
00069 };
00070
00071 string utils::URI::serviceName() const {
00072 return _context + ".fbfs/" + _name + "." + _service;
00073 };
00074
00075 string utils::URI::toString() const {
00076 if(_isValid)
00077 return "fbfs://" + _host + ":" + _port + "/" + _service + "@" + _context + "/" + _name;
00078 else
00079 return "";
00080 };