Return the (key, value) map as a Python dict.
| 104 | { |
| 105 | /// Return the (key, value) map as a Python dict. |
| 106 | static nb::dict items() |
| 107 | { |
| 108 | static std::mutex sMutex; |
| 109 | static nb::dict itemDict; |
| 110 | if (!itemDict) { |
| 111 | // The first time this function is called, populate |
| 112 | // the static dict with (key, value) pairs. |
| 113 | std::lock_guard<std::mutex> lock(sMutex); |
| 114 | if (!itemDict) { |
| 115 | for (int i = 0; ; ++i) { |
| 116 | const CStringPair item = Descr::item(i); |
| 117 | OPENVDB_START_THREADSAFE_STATIC_WRITE |
| 118 | if (item.first) { |
| 119 | itemDict[nb::str(*item.first)] = |
| 120 | nb::str(*item.second); |
| 121 | } |
| 122 | OPENVDB_FINISH_THREADSAFE_STATIC_WRITE |
| 123 | else break; |
| 124 | } |
| 125 | } |
| 126 | } |
| 127 | return itemDict; |
| 128 | } |
| 129 | |
| 130 | /// Return the keys as a Python list of strings. |
| 131 | static nb::object keys() { return items().attr("keys")(); } |
no test coverage detected