| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- #ifndef NAME_H
- #define NAME_H
- #include <memory>
- #include <sstream>
- #include <string>
- #include <vector>
- namespace Network {
- namespace Dns {
- class NameImpl;
- class Name
- {
- public:
- Name();
- template<typename ...Args>
- Name(const Args& ...args) :
- Name(toStringVector(args...))
- {
- }
- Name(const std::vector<std::string>& labels);
- std::string GetFirstLabel() const;
- std::string GetName() const;
- bool empty() const;
- bool endsWith(const Name& suffix) const;
- void append(const std::string& label);
- void prepend(const std::string& label);
- void swap(Name& x) noexcept;
- bool operator==(const Name& name) const;
- bool operator!=(const Name& name) const;
- bool operator<(const Name& name) const;
- private:
- Name(std::shared_ptr<NameImpl> pNameImpl);
- NameImpl* PImpl() const;
- private:
- template <class T>
- std::string toString(T&& t)
- {
- std::stringstream s;
- s << std::forward<T>(t);
- return s.str();
- }
- template <class... T>
- std::vector<std::string> toStringVector(T&&... args)
- {
- std::vector<std::string> res { toString(std::forward<T>(args))... };
- return res;
- }
- private:
- friend class Query;
- friend class ResourceRecord;
- private:
- std::shared_ptr<NameImpl> m_pNameImpl;
- };
- } // namespace Dns
- } // namespace Network
- #endif // NAME_H
|