Ignore:
Timestamp:
Feb 18, 2009, 11:39:30 AM (15 years ago)
Author:
mies
Message:

implemented bootstrap info parser

Location:
source/ariba/communication
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • source/ariba/communication/EndpointDescriptor.cpp

    r2451 r2452  
    3838
    3939#include "EndpointDescriptor.h"
     40#include "ariba/utility/misc/StringFormat.h"
     41#include "ariba/utility/misc/Helper.h"
    4042
    4143namespace ariba {
     
    6870string EndpointDescriptor::toString() const {
    6971        if( locator == NULL ) return "<undefined locator>";
    70         else                  return locator->toString();
     72        std::ostringstream o;
     73        o << "ip{" << locator->getIP() << "}";
     74        o << ",";
     75        o << "tcp(ip,{" << locator->getPort() << "})";
     76        return o.str();
    7177}
    7278
    7379EndpointDescriptor* EndpointDescriptor::fromString( string str ) {
    74         EndpointDescriptor* ep = new EndpointDescriptor();
    75         ep->locator->fromString(str);
    76         ep->isUnspec = false;
     80        using namespace boost::xpressive;
     81        using namespace ariba::utility::string_format;
     82        using namespace ariba::utility::Helper;
     83        using namespace std;
     84
     85        EndpointDescriptor* ep = NULL;
     86        smatch match;
     87        if (regex_search(str, match, robjects)) {
     88                regex_nav nav = match;
     89                for (int i=0; i<nav.size(); i++) {
     90                        string type = nav[i][robject_id].str();
     91                        if (type=="ip") {
     92                                string ip = nav[i][robject_data].str();
     93                                ip = ip.substr(1,ip.size()-2);
     94                                cout << "ep-ip = " <<ip << endl;
     95                                ep = new EndpointDescriptor();
     96                                ep->locator = new IPv4Locator();
     97                                ep->locator->setIP(ip);
     98                                ep->isUnspec = false;
     99                        } else
     100                        if (type=="tcp") {
     101                                string port = nav[i][robject_data][rfields][1].str();
     102                                port = port.substr(1,port.size()-2);
     103                                cout << "ep-tcp-port = " << port << endl;
     104                                ep->locator->setPort(stoi(port));
     105                        }
     106                }
     107        }
    77108        return ep;
    78109}
  • source/ariba/communication/modules/network/ip/IPv4Locator.h

    r2451 r2452  
    7777        virtual string toString() const;
    7878
     79        void setIP( string ip ) {
     80                ipv4Address = boost::asio::ip::address_v4::from_string( ip );
     81        }
     82
    7983        string getIP() const {
    8084                return ipv4Address.to_string();
     
    9195        boost::asio::ip::address_v4 ipv4Address;
    9296        uint16_t port;
    93 
    9497};
    9598
Note: See TracChangeset for help on using the changeset viewer.