00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "TcaEndpointID.h"
00020 #include "../../servlib/bundling/Bundle.h"
00021
00022
00023 namespace dtn {
00024
00025
00027
00028
00029
00030 TcaEndpointID::TcaEndpointID(const std::string& str)
00031 : EndpointID(str), host_(""), app_("")
00032 {
00033 parse();
00034 }
00035
00036
00037 TcaEndpointID::TcaEndpointID(const std::string& host, const std::string& app)
00038 : EndpointID(), host_(host), app_(app)
00039 {
00040 assign(build(host, app));
00041 }
00042
00043
00044 TcaEndpointID::TcaEndpointID(const EndpointID& eid)
00045 : EndpointID(eid), host_(""), app_("")
00046 {
00047 parse();
00048 }
00049
00050
00051 TcaEndpointID::TcaEndpointID(const TcaEndpointID& eid)
00052 : EndpointID(eid), host_(eid.host_), app_(eid.app_)
00053 {
00054 }
00055
00056
00057 void
00058 TcaEndpointID::parse()
00059 {
00060 if (!valid_) return;
00061 if (scheme_str_ != "tca")
00062 {
00063 valid_ = false;
00064 return;
00065 }
00066 if (ssp_.length() <= 2)
00067 {
00068 valid_ = false;
00069 return;
00070 }
00071 if (ssp_.substr(0,2) != "//")
00072 {
00073 valid_ = false;
00074 }
00075 std::string nub = ssp_.substr(2, ssp_.length());
00076
00077 int slash = nub.find("/");
00078 if (slash < 0)
00079 {
00080 host_ = nub;
00081 app_ = "";
00082 return;
00083 }
00084
00085 host_ = nub.substr(0, slash);
00086 app_ = nub.substr(slash + 1, nub.length());
00087 }
00088
00089
00090 void
00091 TcaEndpointID::set_host(const std::string& host)
00092 {
00093 host_ = host;
00094 assign(build(host_, app_));
00095 }
00096
00097
00098 void
00099 TcaEndpointID::set_app(const std::string& app)
00100 {
00101 app_ = app;
00102 assign(build(host_, app_));
00103 }
00104
00105
00106 }