The Gaudi Framework  master (37c0b60a)
PipeReader Class Reference
Collaboration diagram for PipeReader:

Public Member Functions

 PipeReader (const char *cmd)
 
 ~PipeReader (void)
 
std::istringstreamoutput (void)
 

Private Attributes

FILE * pipe
 
std::unique_ptr< std::istringstreamiss
 

Detailed Description

Definition at line 101 of file pfm_gen_analysis.cpp.

Constructor & Destructor Documentation

◆ PipeReader()

PipeReader::PipeReader ( const char *  cmd)
inline

Definition at line 103 of file pfm_gen_analysis.cpp.

103  {
104  pipe = popen( cmd, "r" );
105  if ( !pipe ) {
106  printf( "Cannot open pipe. Exiting...\n" );
107  exit( 1 );
108  }
109  char buffer[PIPE_BUFFER_LENGTH];
110  bzero( buffer, PIPE_BUFFER_LENGTH );
111  std::string result = "";
112  while ( !feof( pipe ) ) {
113  if ( fgets( buffer, PIPE_BUFFER_LENGTH, pipe ) != NULL ) { result += buffer; }
114  bzero( buffer, PIPE_BUFFER_LENGTH );
115  }
116  iss = std::make_unique<std::istringstream>( result, std::istringstream::in );
117  }

◆ ~PipeReader()

PipeReader::~PipeReader ( void  )
inline

Definition at line 119 of file pfm_gen_analysis.cpp.

119 { pclose( pipe ); }

Member Function Documentation

◆ output()

std::istringstream& PipeReader::output ( void  )
inline

Definition at line 121 of file pfm_gen_analysis.cpp.

121 { return *iss; }

Member Data Documentation

◆ iss

std::unique_ptr<std::istringstream> PipeReader::iss
private

Definition at line 125 of file pfm_gen_analysis.cpp.

◆ pipe

FILE* PipeReader::pipe
private

Definition at line 124 of file pfm_gen_analysis.cpp.


The documentation for this class was generated from the following file:
std::string
STL class.
std::feof
T feof(T... args)
std::fgets
T fgets(T... args)
PipeReader::pipe
FILE * pipe
Definition: pfm_gen_analysis.cpp:124
std::printf
T printf(T... args)
PIPE_BUFFER_LENGTH
#define PIPE_BUFFER_LENGTH
Definition: pfm_gen_analysis.cpp:99
PipeReader::iss
std::unique_ptr< std::istringstream > iss
Definition: pfm_gen_analysis.cpp:125
std::exit
T exit(T... args)