[extension] Check if basic_type_map is empty

When a library is loaded the return type of shared_library::open() or shared_library::is_open() can be used to detect whether the library was loaded successfully. When shared_library::call() is called the return type can be used to detect whether the exported map function could be called. But is there another function like is_open() which could be called afterwards to check if the map function was called successfully? The datatype basic_type_map only provides get() and no empty(). It would be required to call get() first and operate on the returned std::map type to see if it contains any factories? Boris

Boris, On Wed, Aug 20, 2008 at 2:42 PM, Boris <boriss@web.de> wrote:
I've just added size() and empty() functions to type_map. You can also pass some sort of status message through the type_map to the shared library if you'd like (using a string or some custom type). I'm curious though, what type of problem were you having that led to this request? Jeremy Pack http://boost-extension.blogspot.com

On Thu, 21 Aug 2008 00:05:08 +0200, Jeremy Pack <rostovpack@gmail.com> wrote:
[...]I've just added size() and empty() functions to type_map.
Thank you!
I was rearranging some code when I started to use Andrey's logging library. With empty() I can implement a function loading a shared library and calling types like this: bool init(const std::string &name) { shared_library lib(name); if (!lib.open()) BOOST_LOG(mylogger) << "error ..."; else if (!lib.call(types)) BOOST_LOG(mylogger) << "error ..."; else BOOST_LOG(mylogger) << "no error ..."; return lib.is_open() && !types.empty(); } As you see it was not a very important request. :) Boris
participants (2)
-
Boris
-
Jeremy Pack