cmServerConnection.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 "cmUVHandlePtr.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. std::string BufferOutMessage(const std::string& rawBuffer) const override;
  24. private:
  25. std::string RequestBuffer;
  26. };
  27. /***
  28. * Generic connection over std io interfaces -- tty
  29. */
  30. class cmStdIoConnection : public cmEventBasedConnection
  31. {
  32. public:
  33. cmStdIoConnection(cmConnectionBufferStrategy* bufferStrategy);
  34. void SetServer(cmServerBase* s) override;
  35. bool OnConnectionShuttingDown() override;
  36. bool OnServeStart(std::string* pString) override;
  37. private:
  38. cm::uv_stream_ptr SetupStream(int file_id);
  39. cm::uv_stream_ptr ReadStream;
  40. };
  41. /***
  42. * These specific connections use the cmake server
  43. * buffering strategy.
  44. */
  45. class cmServerStdIoConnection : public cmStdIoConnection
  46. {
  47. public:
  48. cmServerStdIoConnection();
  49. };
  50. class cmServerPipeConnection : public cmPipeConnection
  51. {
  52. public:
  53. cmServerPipeConnection(const std::string& name);
  54. };