cmServerConnection.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 "cmConnection.h"
  5. #include "cmPipeConnection.h"
  6. #include "cm_uv.h"
  7. #include <string>
  8. class cmServerBase;
  9. /***
  10. * This connection buffer strategy accepts messages in the form of
  11. * [== "CMake Server" ==[
  12. {
  13. ... some JSON message ...
  14. }
  15. ]== "CMake Server" ==]
  16. * and only passes on the core json; it discards the envelope.
  17. */
  18. class cmServerBufferStrategy : public cmConnectionBufferStrategy
  19. {
  20. public:
  21. std::string BufferMessage(std::string& rawBuffer) override;
  22. private:
  23. std::string RequestBuffer;
  24. };
  25. /***
  26. * Generic connection over std io interfaces -- tty
  27. */
  28. class cmStdIoConnection : public cmConnection
  29. {
  30. public:
  31. cmStdIoConnection(cmConnectionBufferStrategy* bufferStrategy);
  32. void SetServer(cmServerBase* s) override;
  33. bool OnServerShuttingDown() override;
  34. bool OnServeStart(std::string* pString) override;
  35. private:
  36. typedef union
  37. {
  38. uv_tty_t* tty;
  39. uv_pipe_t* pipe;
  40. } InOutUnion;
  41. bool usesTty = false;
  42. InOutUnion Input;
  43. InOutUnion Output;
  44. };
  45. /***
  46. * These specific connections use the cmake server
  47. * buffering strategy.
  48. */
  49. class cmServerStdIoConnection : public cmStdIoConnection
  50. {
  51. public:
  52. cmServerStdIoConnection();
  53. };
  54. class cmServerPipeConnection : public cmPipeConnection
  55. {
  56. public:
  57. cmServerPipeConnection(const std::string& name);
  58. };