cisst-saw
Toggle main menu visibility
Loading...
Searching...
No Matches
tmp
cisst-saw
cisst
cisstOSAbstraction
osaPipeExec.h
Go to the documentation of this file.
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3
4
/*
5
6
Author(s): Martin Kelly
7
Created on: 2010-09-23
8
9
(C) Copyright 2010-2019 Johns Hopkins University (JHU), All Rights Reserved.
10
11
--- begin cisst license - do not edit ---
12
13
This software is provided "as is" under an open source license, with
14
no warranty. The complete license can be found in license.txt and
15
http://www.cisst.org/cisst/license.txt.
16
17
--- end cisst license ---
18
19
*/
20
21
#ifndef _osaPipeExec_h
22
#define _osaPipeExec_h
23
24
#include <vector>
25
#include <string>
26
27
#include <
cisstCommon/cmnPortability.h
>
28
29
// Always include last
30
#include <
cisstOSAbstraction/osaExport.h
>
31
32
class
CISST_EXPORT
osaPipeExec
{
34
enum
{INTERNALS_SIZE = 64};
35
char
Internals[INTERNALS_SIZE];
36
39
static
unsigned
int
SizeOfInternals(
void
);
40
friend
class
osaPipeExecTest
;
41
42
int
ToProgram[2];
43
int
FromProgram[2];
44
bool
Connected;
45
bool
ReadFlag;
46
bool
WriteFlag;
47
std::string Name;
48
50
int
DoClose(
int
&n);
51
54
void
CloseAllPipes(
void
);
55
57
void
CloseUnusedHandles(
void
);
58
61
char
** ParseCommand(
const
std::string & executable,
62
const
std::vector<std::string> & arguments);
63
65
void
FreeCommand(
char
**command);
66
67
#if (CISST_OS == CISST_WINDOWS)
71
void
RestoreIO(
int
newStdin,
int
newStdout);
72
#endif
73
74
public
:
76
osaPipeExec
(
const
std::string & name =
"unnamed"
);
77
79
~osaPipeExec
(
void
);
80
86
bool
Open
(
const
std::string & executable,
const
std::string & mode,
87
bool
noWindow =
false
);
88
95
96
bool
Open
(
const
std::string & executable,
97
const
std::vector<std::string> & parameters,
98
const
std::string & mode,
bool
noWindow =
false
);
99
106
bool
Close
(
bool
killProcess =
true
);
107
110
int
Read
(
char
* buffer,
int
maxLength)
const
;
111
115
std::string
Read
(
int
maxLength)
const
;
116
120
int
ReadUntil
(
char
* buffer,
int
maxLength,
char
stopChar,
double
timeoutSec = 0.0)
const
;
121
124
std::string
ReadUntil
(
int
maxLength,
char
stopChar,
double
timeoutSec = 0.0)
const
;
125
127
std::string
ReadString
(
int
maxLength,
double
timeoutSec = 0.0)
const
;
128
131
int
Write
(
const
char
* buffer);
132
135
int
Write
(
const
char
* buffer,
int
n);
136
139
int
Write
(
const
std::string & s);
140
143
int
Write
(
const
std::string & s,
int
n);
144
147
bool
IsConnected
(
void
)
const
;
148
150
bool
IsProcessRunning
(
void
)
const
;
151
153
const
std::string &
GetName
(
void
)
const
;
154
};
155
156
#endif
// _osaPipeExec_h
osaPipeExec::Write
int Write(const char *buffer, int n)
osaPipeExec::Write
int Write(const std::string &s, int n)
osaPipeExec::Read
std::string Read(int maxLength) const
osaPipeExec::Read
int Read(char *buffer, int maxLength) const
osaPipeExec::IsConnected
bool IsConnected(void) const
osaPipeExec::osaPipeExec
osaPipeExec(const std::string &name="unnamed")
osaPipeExec::Write
int Write(const std::string &s)
osaPipeExec::IsProcessRunning
bool IsProcessRunning(void) const
osaPipeExec::Open
bool Open(const std::string &executable, const std::string &mode, bool noWindow=false)
osaPipeExec::ReadUntil
int ReadUntil(char *buffer, int maxLength, char stopChar, double timeoutSec=0.0) const
osaPipeExec::ReadString
std::string ReadString(int maxLength, double timeoutSec=0.0) const
osaPipeExec::Write
int Write(const char *buffer)
osaPipeExec::~osaPipeExec
~osaPipeExec(void)
osaPipeExec::GetName
const std::string & GetName(void) const
osaPipeExec::osaPipeExecTest
friend class osaPipeExecTest
Definition
osaPipeExec.h:40
osaPipeExec::Open
bool Open(const std::string &executable, const std::vector< std::string > ¶meters, const std::string &mode, bool noWindow=false)
osaPipeExec::ReadUntil
std::string ReadUntil(int maxLength, char stopChar, double timeoutSec=0.0) const
osaPipeExec::Close
bool Close(bool killProcess=true)
CISST_EXPORT
#define CISST_EXPORT
Definition
cmnExportMacros.h:50
cmnPortability.h
Portability across compilers and operating systems tools.
osaExport.h
Macros to export the symbols of cisstOSAbstraction (in a Dll).
Generated by
1.18.0