Pagina Principale   Moduli   Lista dei namespaces   Gerarchia delle classi   Lista in ordine alfabetico   Lista dei composti   Lista dei files   Membri dei namespaces   Membri dei composti   Membri dei files   Esempi  

/home/fbassi/devel/projects/reti/utils/URI.cc

Vai alla documentazione di questo file.
00001 /*
00002  *    FBFS Distributed Object Repository
00003  *    Copyright (C) 2001 Francesco V. Bassi
00004  *
00005  *    This program is free software; you can redistribute it and/or modify
00006  *    it under the terms of the GNU General Public License as published by
00007  *    the Free Software Foundation; either version 2 of the License, or
00008  *    (at your option) any later version.
00009  *
00010  *    This program is distributed in the hope that it will be useful,
00011  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *    GNU General Public License for more details.
00014  *
00015  *    You should have received a copy of the GNU General Public License
00016  *    along with this program; if not, write to the Free Software
00017  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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 };

Generato il Thu Feb 15 13:24:57 2001 per A Simple Distributed Object Repository with CORBA & C++. da doxygen1.2.3 scritto da Dimitri van Heesch, © 1997-2000