File indexing completed on 2025-01-18 10:06:15
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #pragma once
0011
0012 #include "detail/common.h"
0013
0014 PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
0015
0016 class options {
0017 public:
0018
0019 options() : previous_state(global_state()) {}
0020
0021
0022 options(const options &) = delete;
0023 options &operator=(const options &) = delete;
0024
0025
0026 ~options() { global_state() = previous_state; }
0027
0028
0029
0030 options &disable_user_defined_docstrings() & {
0031 global_state().show_user_defined_docstrings = false;
0032 return *this;
0033 }
0034
0035 options &enable_user_defined_docstrings() & {
0036 global_state().show_user_defined_docstrings = true;
0037 return *this;
0038 }
0039
0040 options &disable_function_signatures() & {
0041 global_state().show_function_signatures = false;
0042 return *this;
0043 }
0044
0045 options &enable_function_signatures() & {
0046 global_state().show_function_signatures = true;
0047 return *this;
0048 }
0049
0050 options &disable_enum_members_docstring() & {
0051 global_state().show_enum_members_docstring = false;
0052 return *this;
0053 }
0054
0055 options &enable_enum_members_docstring() & {
0056 global_state().show_enum_members_docstring = true;
0057 return *this;
0058 }
0059
0060
0061
0062 static bool show_user_defined_docstrings() {
0063 return global_state().show_user_defined_docstrings;
0064 }
0065
0066 static bool show_function_signatures() { return global_state().show_function_signatures; }
0067
0068 static bool show_enum_members_docstring() {
0069 return global_state().show_enum_members_docstring;
0070 }
0071
0072
0073 void *operator new(size_t) = delete;
0074
0075 private:
0076 struct state {
0077 bool show_user_defined_docstrings = true;
0078 bool show_function_signatures = true;
0079
0080 bool show_enum_members_docstring = true;
0081
0082 };
0083
0084 static state &global_state() {
0085 static state instance;
0086 return instance;
0087 }
0088
0089 state previous_state;
0090 };
0091
0092 PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)