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