ServiceName.h 761 B

123456789101112131415161718192021
  1. #pragma once
  2. #include "../nx/nxstring.h"
  3. /*
  4. this is a helper class to implement GetServiceName
  5. just put WASABI_SERVICE_NAME("Your Service Name"); in the public section of your class declaration.
  6. this implementation does leak memory, but I don't think it's that big of a deal (services can't be unloaded at run-time anyway)
  7. if we ever implement the NXSTR() macro, we can eliminate this leak
  8. e.g.
  9. class MyAPI : public api_whatever
  10. {
  11. public:
  12. WASABI_SERVICE_NAME("My API");
  13. };
  14. */
  15. #define WASABI_SERVICE_NAME(x) static nx_string_t GetServiceName(){ static nx_string_t service_name=0; if (!service_name) NXStringCreateWithUTF8(&service_name, x); return NXStringRetain(service_name); }
  16. #define WASABI_SERVICE_GUID(x) static GUID GetServiceGUID() { return x; }