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