cmServerConnection.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #pragma once
  4. #include "cmConfigure.h" // IWYU pragma: keep
  5. #include <string>
  6. #include "cmConnection.h"
  7. #include "cmPipeConnection.h"
  8. #include "cm_uv.h"
  9. class cmServerBase;
  10. /***
  11. * This connection buffer strategy accepts messages in the form of
  12. * [== "CMake Server" ==[
  13. {
  14. ... some JSON message ...
  15. }
  16. ]== "CMake Server" ==]
  17. * and only passes on the core json; it discards the envelope.
  18. */
  19. class cmServerBufferStrategy : public cmConnectionBufferStrategy
  20. {
  21. public:
  22. std::string BufferMessage(std::string& rawBuffer) override;
  23. private:
  24. std::string RequestBuffer;
  25. };
  26. /***
  27. * Generic connection over std io interfaces -- tty
  28. */
  29. class cmStdIoConnection : public cmEventBasedConnection
  30. {
  31. public:
  32. cmStdIoConnection(cmConnectionBufferStrategy* bufferStrategy);
  33. void SetServer(cmServerBase* s) override;
  34. bool OnConnectionShuttingDown() override;
  35. bool OnServeStart(std::string* pString) override;
  36. private:
  37. void SetupStream(uv_stream_t*& stream, int file_id);
  38. void ShutdownStream(uv_stream_t*& stream);
  39. };
  40. /***
  41. * These specific connections use the cmake server
  42. * buffering strategy.
  43. */
  44. class cmServerStdIoConnection : public cmStdIoConnection
  45. {
  46. public:
  47. cmServerStdIoConnection();
  48. };
  49. class cmServerPipeConnection : public cmPipeConnection
  50. {
  51. public:
  52. cmServerPipeConnection(const std::string& name);
  53. };