Log4CPP.TLSLog.Tracing.hpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #pragma once
  2. #include <string>
  3. #include <map>
  4. #include <stack>
  5. //#include "Hash.String.hpp"
  6. #ifdef Log4CPP_TLSLog_EXPORTS
  7. #define __Log4CPP_TLSLog_API _declspec(dllexport)
  8. #else
  9. #define __Log4CPP_TLSLog_API _declspec(dllimport)
  10. #endif
  11. //-----------------------------------------------------------------------------
  12. // Log4CPP::Context
  13. //
  14. // 改成用 Hash, 不要用字符串比较了, 性能超高
  15. // 可以用上面的 Helper 函数来生成字符串的 Hash
  16. // 但是记得用 constexpr, 以便在编译期就能生成 Hash
  17. // 2022-05-30
  18. //-----------------------------------------------------------------------------
  19. namespace Log4CPP
  20. {
  21. namespace ThreadContext
  22. {
  23. class __Log4CPP_TLSLog_API Map
  24. {
  25. public:
  26. static void Set (size_t hash, const std::string & value);
  27. static std::string Get (size_t hash);
  28. static void Clear ();
  29. };
  30. class __Log4CPP_TLSLog_API Stack
  31. {
  32. public:
  33. static void Push (const std::string & value);
  34. static std::string Pop ();
  35. static std::string Peek ();
  36. static void Clear ();
  37. };
  38. }
  39. namespace GlobalContext
  40. {
  41. class __Log4CPP_TLSLog_API Map
  42. {
  43. public:
  44. static void Set (size_t hash, const std::string & value);
  45. static std::string Get (size_t hash);
  46. };
  47. class __Log4CPP_TLSLog_API Stack
  48. {
  49. public:
  50. static void Push (const std::string & value);
  51. static std::string Pop ();
  52. static std::string Peek ();
  53. };
  54. };
  55. };