docstring_options.hpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. // Copyright Ralf W. Grosse-Kunstleve 2006.
  2. // Distributed under the Boost Software License, Version 1.0. (See
  3. // accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef DOCSTRING_OPTIONS_RWGK20060111_HPP
  6. # define DOCSTRING_OPTIONS_RWGK20060111_HPP
  7. #include <boost/python/object/function.hpp>
  8. namespace boost { namespace python {
  9. // Note: the static data members are defined in object/function.cpp
  10. class BOOST_PYTHON_DECL docstring_options : boost::noncopyable
  11. {
  12. public:
  13. docstring_options(bool show_all=true)
  14. {
  15. previous_show_user_defined_ = show_user_defined_;
  16. previous_show_py_signatures_ = show_py_signatures_;
  17. previous_show_cpp_signatures_ = show_cpp_signatures_;
  18. show_user_defined_ = show_all;
  19. show_cpp_signatures_ = show_all;
  20. show_py_signatures_ = show_all;
  21. }
  22. docstring_options(bool show_user_defined, bool show_signatures)
  23. {
  24. previous_show_user_defined_ = show_user_defined_;
  25. previous_show_cpp_signatures_ = show_cpp_signatures_;
  26. previous_show_py_signatures_ = show_py_signatures_;
  27. show_user_defined_ = show_user_defined;
  28. show_cpp_signatures_ = show_signatures;
  29. show_py_signatures_ = show_signatures;
  30. }
  31. docstring_options(bool show_user_defined, bool show_py_signatures, bool show_cpp_signatures)
  32. {
  33. previous_show_user_defined_ = show_user_defined_;
  34. previous_show_cpp_signatures_ = show_cpp_signatures_;
  35. previous_show_py_signatures_ = show_py_signatures_;
  36. show_user_defined_ = show_user_defined;
  37. show_cpp_signatures_ = show_cpp_signatures;
  38. show_py_signatures_ = show_py_signatures;
  39. }
  40. ~docstring_options()
  41. {
  42. show_user_defined_ = previous_show_user_defined_;
  43. show_cpp_signatures_ = previous_show_cpp_signatures_;
  44. show_py_signatures_ = previous_show_py_signatures_;
  45. }
  46. void
  47. disable_user_defined() { show_user_defined_ = false; }
  48. void
  49. enable_user_defined() { show_user_defined_ = true; }
  50. void
  51. disable_py_signatures()
  52. {
  53. show_py_signatures_ = false;
  54. }
  55. void
  56. enable_py_signatures()
  57. {
  58. show_py_signatures_ = true;
  59. }
  60. void
  61. disable_cpp_signatures()
  62. {
  63. show_cpp_signatures_ = false;
  64. }
  65. void
  66. enable_cpp_signatures()
  67. {
  68. show_cpp_signatures_ = true;
  69. }
  70. void
  71. disable_signatures()
  72. {
  73. show_cpp_signatures_ = false;
  74. show_py_signatures_ = false;
  75. }
  76. void
  77. enable_signatures()
  78. {
  79. show_cpp_signatures_ = true;
  80. show_py_signatures_ = true;
  81. }
  82. void
  83. disable_all()
  84. {
  85. show_user_defined_ = false;
  86. show_cpp_signatures_ = false;
  87. show_py_signatures_ = false;
  88. }
  89. void
  90. enable_all()
  91. {
  92. show_user_defined_ = true;
  93. show_cpp_signatures_ = true;
  94. show_py_signatures_ = true;
  95. }
  96. friend struct objects::function;
  97. private:
  98. static volatile bool show_user_defined_;
  99. static volatile bool show_cpp_signatures_;
  100. static volatile bool show_py_signatures_;
  101. bool previous_show_user_defined_;
  102. bool previous_show_cpp_signatures_;
  103. bool previous_show_py_signatures_;
  104. };
  105. }} // namespace boost::python
  106. #endif // DOCSTRING_OPTIONS_RWGK20060111_HPP