cmServerConnection.h 1.5 KB
Newer Older
1 2
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
   file Copyright.txt or https://cmake.org/licensing for details.  */
3 4
#pragma once

5 6 7
#include "cmConfigure.h" // IWYU pragma: keep

#include <string>
8

9
#include "cmConnection.h"
10
#include "cmPipeConnection.h"
11
#include "cmUVHandlePtr.h"
12

13
class cmServerBase;
14

15 16 17 18 19 20 21 22 23 24
/***
 * This connection buffer strategy accepts messages in the form of
 * [== "CMake Server" ==[
{
  ... some JSON message ...
}
]== "CMake Server" ==]
 * and only passes on the core json; it discards the envelope.
 */
class cmServerBufferStrategy : public cmConnectionBufferStrategy
25 26
{
public:
27
  std::string BufferMessage(std::string& rawBuffer) override;
28
  std::string BufferOutMessage(const std::string& rawBuffer) const override;
29 30

private:
31
  std::string RequestBuffer;
32 33
};

34 35 36
/***
 * Generic connection over std io interfaces -- tty
 */
37
class cmStdIoConnection : public cmEventBasedConnection
38 39
{
public:
40 41 42 43
  cmStdIoConnection(cmConnectionBufferStrategy* bufferStrategy);

  void SetServer(cmServerBase* s) override;

44
  bool OnConnectionShuttingDown() override;
45

46
  bool OnServeStart(std::string* pString) override;
47 48

private:
49 50
  cm::uv_stream_ptr SetupStream(int file_id);
  cm::uv_stream_ptr ReadStream;
51 52
};

53 54 55 56 57
/***
 * These specific connections use the cmake server
 * buffering strategy.
 */
class cmServerStdIoConnection : public cmStdIoConnection
58 59
{
public:
60 61
  cmServerStdIoConnection();
};
62

63 64 65 66
class cmServerPipeConnection : public cmPipeConnection
{
public:
  cmServerPipeConnection(const std::string& name);
67
};