- friend std::ostream & operator<< (std::ostream & o, const USER_IPS & i);
- //friend stringstream & operator<< (stringstream & s, const USER_IPS & i);
- friend const USER_IPS StrToIPS(const std::string & ipsStr);
-
-public:
- typedef std::vector<IP_MASK> ContainerType;
- typedef ContainerType::size_type IndexType;
-
- USER_IPS();
- USER_IPS(const USER_IPS &);
- USER_IPS & operator=(const USER_IPS &);
- const IP_MASK & operator[](IndexType idx) const;
- std::string GetIpStr() const;
- bool IsIPInIPS(uint32_t ip) const;
- bool OnlyOneIP() const;
- int Count() const;
- void Add(const IP_MASK &im);
- void Erase();
-
-private:
- uint32_t CalcMask(unsigned int msk) const;
- ContainerType ips;
+ friend std::ostream & operator<< (std::ostream & o, const UserIPs & i);
+
+ public:
+ using ContainerType = std::vector<IPMask>;
+ using IndexType = ContainerType::size_type;
+
+ UserIPs() = default;
+
+ UserIPs(const UserIPs&) = default;
+ UserIPs& operator=(const UserIPs&) = default;
+ UserIPs(UserIPs&&) = default;
+ UserIPs& operator=(UserIPs&&) = default;
+
+ static UserIPs parse(const std::string& source);
+
+ const IPMask& operator[](IndexType idx) const noexcept { return ips[idx]; }
+ std::string toString() const noexcept;
+ bool find(uint32_t ip) const noexcept;
+ bool onlyOneIP() const noexcept;
+ bool isAnyIP() const noexcept;
+ size_t count() const noexcept { return ips.size(); }
+ void add(const IPMask& im) noexcept{ ips.push_back(im); }
+
+ private:
+ uint32_t calcMask(unsigned int msk) const noexcept;
+ ContainerType ips;