<commit_before>/*
*  Author(s):
*  - <NAME> <<EMAIL>>
*
*  Copyright (C) 2012 Aldebaran Robotics
*/


#pragma once
#ifndef _QIMESSAGING_URL_HPP_
#define _QIMESSAGING_URL_HPP_

#include <string>
#include <sstream>

namespace qi {
  class Url
  {
  private:
    std::string    _url;
    unsigned short _port;
    std::string    _host;
    unsigned int   _protocol;
  public:
    enum UrlProtocol {
      Invalid = 0,
      Unknown = 1,
      Tcp     = 2,
    };

    Url(const std::string &url)
      : _url(url)
    {
      size_t begin = 0;
      size_t end = 0;
      end = url.find(":");
      std::string type = url.substr(begin, end);

      if (type == "tcp")
      {
        _protocol = Tcp;
      }
      else
      {
        _protocol = Unknown;
      }

      begin = end + 3;
      end = url.find(":", begin);
      _host = url.substr(begin, end - begin);
      begin = end + 1;
      std::stringstream ss(url.substr(begin));
      ss >> _port;
    }

    unsigned short port() const { return _port; }
    const std::string& host() const { return _host; }
    unsigned int protocol() const { return _protocol; }
    const std::string& str() const { return _url; }
  };
}

#endif  // _QIMESSAGING_URL_HPP_<commit_msg>Rename Protocol enum in Url::.<commit_after>/*
*  Author(s):
*  - <NAME> <<EMAIL>>
*
*  Copyright (C) 2012 Aldebaran Robotics
*/


#pragma once
#ifndef _QIMESSAGING_URL_HPP_
#define _QIMESSAGING_URL_HPP_

#include <string>
#include <sstream>

namespace qi {
  class Url
  {
  private:
    std::string    _url;
    unsigned short _port;
    std::string    _host;
    unsigned int   _protocol;
  public:
    enum Protocol {
      Protocol_Invalid = 0,
      Protocol_Unknown = 1,
      Protocol_Tcp     = 2,
    };

    Url(const std::string &url)
      : _url(url)
    {
      size_t begin = 0;
      size_t end = 0;
      end = url.find(":");
      std::string type = url.substr(begin, end);

      if (type == "tcp")
      {
        _protocol = Protocol_Tcp;
      }
      else
      {
        _protocol = Protocol_Unknown;
      }

      begin = end + 3;
      end = url.find(":", begin);
      _host = url.substr(begin, end - begin);
      begin = end + 1;
      std::stringstream ss(url.substr(begin));
      ss >> _port;
    }

    unsigned short port() const { return _port; }
    const std::string& host() const { return _host; }
    unsigned int protocol() const { return _protocol; }
    const std::string& str() const { return _url; }
  };
}

#endif  // _QIMESSAGING_URL_HPP_
{'fraction_non_alphanumeric': 0.13022700119474312, 'fraction_numerical': 0.008761449621664676, 'mean_word_length': 2.204081632653061, 'pattern_counts': {'":': 4, '<': 13, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1192443', 'n_tokens_mistral': 912, 'n_tokens_neox': 871, 'n_words': 223}