vformat.hpp 957 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //
  2. // Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // Official repository: https://github.com/boostorg/url
  8. //
  9. #ifndef BOOST_URL_DETAIL_FORMAT_HPP
  10. #define BOOST_URL_DETAIL_FORMAT_HPP
  11. #include <boost/url/detail/format_args.hpp>
  12. #include <boost/url/detail/pattern.hpp>
  13. #include <boost/core/detail/string_view.hpp>
  14. #include <boost/url/url.hpp>
  15. namespace boost {
  16. namespace urls {
  17. namespace detail {
  18. inline
  19. void
  20. vformat_to(
  21. url_base& u,
  22. core::string_view fmt,
  23. detail::format_args args)
  24. {
  25. parse_pattern(fmt)
  26. .value().apply(u, args);
  27. }
  28. inline
  29. url
  30. vformat(
  31. core::string_view fmt,
  32. detail::format_args args)
  33. {
  34. url u;
  35. vformat_to(u, fmt, args);
  36. return u;
  37. }
  38. } // detail
  39. } // url
  40. } // boost
  41. #endif