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 #include "CeylanUniformResourceIdentifier.h"
00028
00029 #include "CeylanStringUtils.h"
00030
00031
00032 using namespace Ceylan ;
00033 using namespace Ceylan::URI ;
00034
00035 using std::string ;
00036
00037
00038
00039 const std::string Ceylan::URI::ProtocolSeparator( "://" ) ;
00040
00041
00042
00043
00044 const string Ceylan::URI::getProtocolName( const string & fullURI )
00045 {
00046
00047 return getProtocolName( fullURI, ProtocolSeparator ) ;
00048
00049 }
00050
00051
00052
00053 const string Ceylan::URI::getProtocolName( const string & fullURI,
00054 const string & protocolSeparator )
00055 {
00056
00057 Ceylan::StringSize endOfPrefix = fullURI.find( protocolSeparator ) ;
00058
00059 if ( endOfPrefix == string::npos )
00060 {
00061
00062 return "" ;
00063 }
00064
00065 return fullURI.substr( 0, endOfPrefix ) ;
00066
00067 }
00068
00069
00070
00071 const string Ceylan::URI::getEmbeddedURI( const string & fullURI )
00072 {
00073
00074 return getEmbeddedURI( fullURI, ProtocolSeparator ) ;
00075
00076 }
00077
00078
00079
00080 const string Ceylan::URI::getEmbeddedURI( const string & fullURI,
00081 const string & protocolSeparator )
00082 {
00083
00084 Ceylan::StringSize endOfPrefix = fullURI.find( protocolSeparator ) ;
00085
00086 if ( endOfPrefix == string::npos )
00087 {
00088
00089
00090
00091
00092
00093 return fullURI ;
00094 }
00095
00096 return fullURI.substr( endOfPrefix + protocolSeparator.size() ) ;
00097
00098 }
00099