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-08-03 02:19:58 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         346 : XmppServerAddressParser::XmppServerAddressParser(uint16_t default_port, uint32_t max_servers_count) :
      12         346 :     default_port(default_port),
      13         346 :     max_servers_count(max_servers_count) {
      14             : 
      15         346 : }
      16             : 
      17         342 : void XmppServerAddressParser::ParseAddress(const std::string &address,
      18             :                                            std::string *out_ip, uint16_t *out_port) const {
      19         342 :     std::vector<std::string> parts;
      20         342 :     boost::split(parts, address, boost::is_any_of(":"));
      21             : 
      22         342 :     *out_ip = parts[0];
      23         342 :     *out_port = default_port;
      24             : 
      25         342 :     if (parts.size() >= 2) {
      26             :         uint16_t port;
      27         340 :         std::istringstream converter(parts[1]);
      28         340 :         if (converter >> port) {
      29         336 :             *out_port = port;
      30             :         }
      31         340 :     }
      32         342 : }
      33             : 
      34         342 : void XmppServerAddressParser::ParseAddresses(const std::vector<std::string> &addresses,
      35             :                                              std::string out_ips[], uint16_t out_ports[]) const {
      36         342 :     const uint32_t count = std::min(static_cast<uint32_t>(addresses.size()), max_servers_count);
      37         680 :     for (uint32_t i = 0; i < count; ++i) {
      38         338 :         ParseAddress(addresses[i], &out_ips[i], &out_ports[i]);
      39             :     }
      40         342 : }

Generated by: LCOV version 1.14