ptree_fwd.hpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. // ----------------------------------------------------------------------------
  2. // Copyright (C) 2002-2006 Marcin Kalicinski
  3. // Copyright (C) 2009 Sebastian Redl
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // For more information, see www.boost.org
  10. // ----------------------------------------------------------------------------
  11. #ifndef BOOST_PROPERTY_TREE_PTREE_FWD_HPP_INCLUDED
  12. #define BOOST_PROPERTY_TREE_PTREE_FWD_HPP_INCLUDED
  13. #include <boost/config.hpp>
  14. #include <boost/optional/optional_fwd.hpp>
  15. #include <boost/throw_exception.hpp>
  16. #include <functional> // for std::less
  17. #include <memory> // for std::allocator
  18. #include <string>
  19. namespace boost { namespace property_tree
  20. {
  21. namespace detail {
  22. template <typename T> struct less_nocase;
  23. }
  24. // Classes
  25. template < class Key, class Data, class KeyCompare = std::less<Key> >
  26. class basic_ptree;
  27. template <typename T>
  28. struct id_translator;
  29. template <typename String, typename Translator>
  30. class string_path;
  31. // Texas-style concepts for documentation only.
  32. #if 0
  33. concept PropertyTreePath<class Path> {
  34. // The key type for which this path works.
  35. typename key_type;
  36. // Return the key that the first segment of the path names.
  37. // Split the head off the state.
  38. key_type Path::reduce();
  39. // Return true if the path is empty.
  40. bool Path::empty() const;
  41. // Return true if the path contains a single element.
  42. bool Path::single() const;
  43. // Dump as a std::string, for exception messages.
  44. std::string Path::dump() const;
  45. }
  46. concept PropertyTreeKey<class Key> {
  47. PropertyTreePath path;
  48. requires SameType<Key, PropertyTreePath<path>::key_type>;
  49. }
  50. concept PropertyTreeTranslator<class Tr> {
  51. typename internal_type;
  52. typename external_type;
  53. boost::optional<external_type> Tr::get_value(internal_type);
  54. boost::optional<internal_type> Tr::put_value(external_type);
  55. }
  56. #endif
  57. /// If you want to use a custom key type, specialize this struct for it
  58. /// and give it a 'type' typedef that specifies your path type. The path
  59. /// type must conform to the Path concept described in the documentation.
  60. /// This is already specialized for std::basic_string.
  61. template <typename Key>
  62. struct path_of;
  63. /// Specialize this struct to specify a default translator between the data
  64. /// in a tree whose data_type is Internal, and the external data_type
  65. /// specified in a get_value, get, put_value or put operation.
  66. /// This is already specialized for Internal being std::basic_string.
  67. template <typename Internal, typename External>
  68. struct translator_between;
  69. class ptree_error;
  70. class ptree_bad_data;
  71. class ptree_bad_path;
  72. // Typedefs
  73. /** Implements a path using a std::string as the key. */
  74. typedef string_path<std::string, id_translator<std::string> > path;
  75. /**
  76. * A property tree with std::string for key and data, and default
  77. * comparison.
  78. */
  79. typedef basic_ptree<std::string, std::string> ptree;
  80. /**
  81. * A property tree with std::string for key and data, and case-insensitive
  82. * comparison.
  83. */
  84. typedef basic_ptree<std::string, std::string,
  85. detail::less_nocase<std::string> >
  86. iptree;
  87. #ifndef BOOST_NO_STD_WSTRING
  88. /** Implements a path using a std::wstring as the key. */
  89. typedef string_path<std::wstring, id_translator<std::wstring> > wpath;
  90. /**
  91. * A property tree with std::wstring for key and data, and default
  92. * comparison.
  93. * @note The type only exists if the platform supports @c wchar_t.
  94. */
  95. typedef basic_ptree<std::wstring, std::wstring> wptree;
  96. /**
  97. * A property tree with std::wstring for key and data, and case-insensitive
  98. * comparison.
  99. * @note The type only exists if the platform supports @c wchar_t.
  100. */
  101. typedef basic_ptree<std::wstring, std::wstring,
  102. detail::less_nocase<std::wstring> >
  103. wiptree;
  104. #endif
  105. // Free functions
  106. /**
  107. * Swap two property tree instances.
  108. */
  109. template<class K, class D, class C>
  110. void swap(basic_ptree<K, D, C> &pt1,
  111. basic_ptree<K, D, C> &pt2);
  112. } }
  113. #if !defined(BOOST_PROPERTY_TREE_DOXYGEN_INVOKED)
  114. // Throwing macro to avoid no return warnings portably
  115. # define BOOST_PROPERTY_TREE_THROW(e) BOOST_THROW_EXCEPTION(e)
  116. #endif
  117. #endif