1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmProcess.h,v $
6 Date: $Date: 2009-09-11 16:26:41 $
7 Version: $Revision: 1.8 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
21 #include "cmStandardIncludes.h"
22 #include <cmsys/Process.h>
26 * \brief run a process with c++
28 * cmProcess wraps the kwsys process stuff in a c++ class.
35 const char* GetCommand() { return this->Command
.c_str();}
36 void SetCommand(const char* command
);
37 void SetCommandArguments(std::vector
<std::string
> const& arg
);
38 void SetWorkingDirectory(const char* dir
) { this->WorkingDirectory
= dir
;}
39 void SetTimeout(double t
) { this->Timeout
= t
;}
40 // Return true if the process starts
43 // return the process status
44 int GetProcessStatus();
45 // Report the status of the program
47 int GetId() { return this->Id
; }
48 void SetId(int id
) { this->Id
= id
;}
49 int GetExitValue() { return this->ExitValue
;}
50 double GetTotalTime() { return this->TotalTime
;}
53 * Read one line of output but block for no more than timeout.
55 * cmsysProcess_Pipe_None = Process terminated and all output read
56 * cmsysProcess_Pipe_STDOUT = Line came from stdout
57 * cmsysProcess_Pipe_STDOUT = Line came from stderr
58 * cmsysProcess_Pipe_Timeout = Timeout expired while waiting
60 int GetNextOutputLine(std::string
& line
, double timeout
);
65 cmsysProcess
* Process
;
66 class Buffer
: public std::vector
<char>
68 // Half-open index range of partial line already scanned.
72 Buffer(): First(0), Last(0) {}
73 bool GetLine(std::string
& line
);
74 bool GetLast(std::string
& line
);
79 std::string WorkingDirectory
;
80 std::vector
<std::string
> Arguments
;
81 std::vector
<const char*> ProcessArgs
;