FACT++  1.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bool Readline::RedirectionWrapper ( std::ostream &  out,
bool(*)()  function 
)
static

This wraps the given readline function such that the output can be redirected from thr rl_outstream to the given C++ ostream.

Parameters
outThe stream to which the output should be redirected.
functionTakes a function of type bool(*)() as argument
Returns
The return value of the function

Definition at line 192 of file Readline.cc.

References save(), and SetStreamOut().

Referenced by ReadlineColor::Process().

193 {
194  FILE *save = SetStreamOut(tmpfile());
195  const bool rc = function();
196  FILE *file = SetStreamOut(save);
197 
198  const bool empty = ftell(file)==0;
199 
200  rewind(file);
201 
202  if (empty)
203  {
204  out << " <empty>" << endl;
205  fclose(file);
206  return rc;
207  }
208 
209  while (1)
210  {
211  const int c = getc(file);
212  if (feof(file))
213  break;
214  out << (char)c;
215  }
216  out << endl;
217 
218  fclose(file);
219 
220  return rc;
221 }
function save()
Definition: index.js:502
static FILE * SetStreamOut(FILE *f)
Definition: Readline.cc:721

+ Here is the call graph for this function:

+ Here is the caller graph for this function: