LCOV - code coverage report
Current view: top level - vnsw/agent/cmn - xmpp_server_address_parser.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 20 20 100.0 %
Date: 2026-10-05 02:12:29 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2018 Juniper Networks, Inc. All rights reserved.
       3             :  */
       4             : 
       5             : #include "xmpp_server_address_parser.h"
       6             : 
       7             : #include <algorithm>
       8             : #include <sstream>
       9             : #include <boost/algorithm/string.hpp>
      10             : 
      11         342 : XmppServerAddressParser::XmppServerAddressParser(uint16_t default_port, uint32_t max_servers_count) :
      12         342 :     default_port(default_port),
      13         342 :     max_servers_count(max_servers_count) {
      14             : 
      15         342 : }
      16             : 
      17         338 : void XmppServerAddressParser::ParseAddress(const std::string &address,
      18             :                                            std::string *out_ip, uint16_t *out_port) const {
      19         338 :     std::vector<std::string> parts;
      20         338 :     boost::split(parts, address, boost::is_any_of(":"));
      21             : 
      22         338 :     *out_ip = parts[0];
      23         338 :     *out_port = default_port;
      24             : 
      25         338 :     if (parts.size() >= 2) {
      26             :         uint16_t port;
      27         336 :         std::istringstream converter(parts[1]);
      28         336 :         if (converter >> port) {
      29         332 :             *out_port = port;
      30             :         }
      31         336 :     }
      32         338 : }
      33             : 
      34         338 : void XmppServerAddressParser::ParseAddresses(const std::vector<std::string> &addresses,
      35             :                                              std::string out_ips[], uint16_t out_ports[]) const {
      36         338 :     const uint32_t count = std::min(static_cast<uint32_t>(addresses.size()), max_servers_count);
      37         672 :     for (uint32_t i = 0; i < count; ++i) {
      38         334 :         ParseAddress(addresses[i], &out_ips[i], &out_ports[i]);
      39             :     }
      40         338 : }

Generated by: LCOV version 1.14