CMake/testConsoleBufChild.cxx
KWSys Upstream 7be70ca6cc KWSys 2017-05-16 (fe1f22ce)
Code extracted from:

    https://gitlab.kitware.com/utils/kwsys.git

at commit fe1f22ceefdae18df33e5bab8483fec7a82d4cee (master).

Upstream Shortlog
-----------------

Adam Weisi (3):
      8a799e36 Process: Improve definition ordering in header file
      7d56ef24 Process: Save results from all children internally
      b7eba998 Process: Add APIs to get results of individual processes

Ben Boeckel (2):
      cea71543 style: remove separator comments
      874dc559 style: help clang-format near macros
2017-05-16 11:39:00 -04:00

56 lines
1.4 KiB
C++

/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
#include "kwsysPrivate.h"
#include KWSYS_HEADER(ConsoleBuf.hxx)
#include KWSYS_HEADER(Encoding.hxx)
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
#include "ConsoleBuf.hxx.in"
#include "Encoding.hxx.in"
#endif
#include <iostream>
#include "testConsoleBuf.hxx"
int main(int argc, const char* argv[])
{
#if defined(_WIN32)
kwsys::ConsoleBuf::Manager out(std::cout);
kwsys::ConsoleBuf::Manager err(std::cerr, true);
kwsys::ConsoleBuf::Manager in(std::cin);
if (argc > 1) {
std::cout << argv[1] << std::endl;
std::cerr << argv[1] << std::endl;
} else {
std::string str = kwsys::Encoding::ToNarrow(std::wstring(
UnicodeTestString, sizeof(UnicodeTestString) / sizeof(wchar_t) - 1));
std::cout << str << std::endl;
std::cerr << str << std::endl;
}
std::string input;
HANDLE event = OpenEventW(EVENT_MODIFY_STATE, FALSE, BeforeInputEventName);
if (event) {
SetEvent(event);
CloseHandle(event);
}
std::cin >> input;
std::cout << input << std::endl;
event = OpenEventW(EVENT_MODIFY_STATE, FALSE, AfterOutputEventName);
if (event) {
SetEvent(event);
CloseHandle(event);
}
#else
static_cast<void>(argc);
static_cast<void>(argv);
#endif
return 0;
}