Back to index

texmacs  1.0.7.15
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes
tm_ostream Class Reference

#include <tm_ostream.hpp>

Collaboration diagram for tm_ostream:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 tm_ostream ()
 tm_ostream (char *)
 tm_ostream (FILE *)
 ~tm_ostream ()
bool open ()
bool open (char *)
bool open (FILE *)
bool is_writable () const
bool is_buffered () const
void flush ()
void close ()
void buffer ()
string unbuffer ()
tm_ostreamoperator<< (bool)
tm_ostreamoperator<< (char)
tm_ostreamoperator<< (short)
tm_ostreamoperator<< (unsigned short)
tm_ostreamoperator<< (int)
tm_ostreamoperator<< (unsigned int)
tm_ostreamoperator<< (long)
tm_ostreamoperator<< (unsigned long)
tm_ostreamoperator<< (long long int)
tm_ostreamoperator<< (unsigned long long int)
tm_ostreamoperator<< (float)
tm_ostreamoperator<< (double)
tm_ostreamoperator<< (long double)
tm_ostreamoperator<< (const char *)
bool operator== (tm_ostream &)

Static Public Attributes

static tm_ostreamcout = private_cout
static tm_ostreamcerr = private_cerr

Private Member Functions

 tm_ostream (const tm_ostream &)
tm_ostreamoperator= (const tm_ostream &)

Private Attributes

FILE * file
stringbuf
bool is_w
bool is_mine
bool is_buf

Static Private Attributes

static tm_ostream private_cout
static tm_ostream private_cerr

Detailed Description

Definition at line 19 of file tm_ostream.hpp.


Constructor & Destructor Documentation

tm_ostream::tm_ostream ( const tm_ostream out) [private]

Definition at line 21 of file tm_ostream.cpp.

                                             { // private
  file= out.file;
  is_w= out.is_w;
  is_buf= out.is_buf;
  *buf= *(out.buf);
  is_mine= false;
}

Definition at line 47 of file tm_ostream.cpp.

                        :
  file (0), is_w (false), is_mine (false), is_buf (false) {
  buf= tm_new<string> ();
}
tm_ostream::tm_ostream ( char *  fn)

Definition at line 52 of file tm_ostream.cpp.

                                :
  file (0), is_w (false), is_mine (false), is_buf (false) {
  buf= tm_new<string> ();
  open (fn);
}

Here is the call graph for this function:

tm_ostream::tm_ostream ( FILE *  f)

Definition at line 58 of file tm_ostream.cpp.

                               :
  file (0), is_w (false), is_mine (false), is_buf (false) {
  buf= tm_new<string> ();
  open (f);
}

Here is the call graph for this function:

Definition at line 64 of file tm_ostream.cpp.

                         {
  if (file && is_mine) fclose (file);
  tm_delete (buf);
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 147 of file tm_ostream.cpp.

                    {
  is_buf= true;
  *buf= "";
}

Here is the caller graph for this function:

Definition at line 137 of file tm_ostream.cpp.

                   {
  if (file && is_mine) fclose (file);
  file= 0;
  *buf= "";
  is_w= false;
  is_mine= false;
  is_buf= false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 132 of file tm_ostream.cpp.

                   {
  if (file && is_w) fflush (file);
}

Here is the caller graph for this function:

bool tm_ostream::is_buffered ( ) const

Definition at line 127 of file tm_ostream.cpp.

                               {
  return is_buf;
}
bool tm_ostream::is_writable ( ) const

Definition at line 122 of file tm_ostream.cpp.

                               {
  return is_w;
}
bool tm_ostream::open ( )

Definition at line 70 of file tm_ostream.cpp.

                  {
  if (file && is_mine) fclose (file);
  file= 0;
  *buf= "";
  is_w= true;
  is_mine= true;
  is_buf= false;
  return is_w;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool tm_ostream::open ( char *  fn)

Definition at line 94 of file tm_ostream.cpp.

                          {
  if (file && is_mine) fclose (file);
  file= fopen (fn, "w");
  *buf= "";
  is_buf= false;
  if (file) {
    is_w= true;
    is_mine= true;
  } else {
    is_w= false;
    is_mine= false;
  }
  return is_w;
}

Here is the call graph for this function:

bool tm_ostream::open ( FILE *  f)

Definition at line 110 of file tm_ostream.cpp.

                         {
  if (file && is_mine) fclose (file);
  file= f;
  *buf= "";
  is_buf= false;
  if (file) is_w= true;
  else is_w= false;
  is_mine= false;
  return is_w;
}

Here is the call graph for this function:

tm_ostream & tm_ostream::operator<< ( bool  b)

Definition at line 161 of file tm_ostream.cpp.

                               {
  if (is_buf) {
    if (b) *buf << "true";
    else *buf << "false";
  }
  else if (file && is_w) {
    if (b) {
      if (0 > fprintf (file, "%s", "true")) is_w= false;
    } else {
      if (0 > fprintf (file, "%s", "false")) is_w= false;
    }
  }
  return *this;
}
tm_ostream & tm_ostream::operator<< ( char  c)

Definition at line 177 of file tm_ostream.cpp.

                               {
  if (is_buf) {
    char _buf[8];
    sprintf (_buf, "%c", c);
    *buf << _buf;
  }
  else if (file && is_w)
    if (0 > fprintf (file, "%c", c)) is_w= false;
  return *this;
}
tm_ostream & tm_ostream::operator<< ( short  sh)

Definition at line 189 of file tm_ostream.cpp.

                                 {
  if (is_buf) {
    char _buf[32];
    sprintf (_buf, "%hd", sh);
    *buf << _buf;
  }
  else if (file && is_w)
    if (0 > fprintf (file, "%hd", sh)) is_w= false;
  return *this;
}
tm_ostream & tm_ostream::operator<< ( unsigned short  ush)

Definition at line 201 of file tm_ostream.cpp.

                                           {
  if (is_buf) {
    char _buf[32];
    sprintf (_buf, "%hu", ush);
    *buf << _buf;
  }
  else if (file && is_w)
    if (0 > fprintf (file, "%hu", ush)) is_w= false;
  return *this;
}
tm_ostream & tm_ostream::operator<< ( int  i)

Definition at line 213 of file tm_ostream.cpp.

                              {
  if (is_buf) {
    char _buf[64];
    sprintf (_buf, "%d", i);
    *buf << _buf;
  }
  else if (file && is_w)
    if (0 > fprintf (file, "%d", i)) is_w= false;
  return *this;
}
tm_ostream & tm_ostream::operator<< ( unsigned int  ui)

Definition at line 225 of file tm_ostream.cpp.

                                        {
  if (is_buf) {
    char _buf[64];
    sprintf (_buf, "%u", ui);
    *buf << _buf;
  }
  else if (file && is_w)
    if (0 > fprintf (file, "%u", ui)) is_w= false;
  return *this;
}
tm_ostream & tm_ostream::operator<< ( long  l)

Definition at line 237 of file tm_ostream.cpp.

                               {
  if (is_buf) {
    char _buf[64];
    sprintf (_buf, "%ld", l);
    *buf << _buf;
  }
  else if (file && is_w)
    if (0 > fprintf (file, "%ld", l)) is_w= false;
  return *this;
}
tm_ostream & tm_ostream::operator<< ( unsigned long  ul)

Definition at line 249 of file tm_ostream.cpp.

                                         {
  if (is_buf) {
    char _buf[64];
    sprintf (_buf, "%lu", ul);
    *buf << _buf;
  }
  else if (file && is_w)
    if (0 > fprintf (file, "%lu", ul)) is_w= false;
  return *this;
}
tm_ostream & tm_ostream::operator<< ( long long int  l)

Definition at line 261 of file tm_ostream.cpp.

                                        {
  if (is_buf) {
    char _buf[64];
    sprintf (_buf, "%lld", l);
    *buf << _buf;
  }
  else if (file && is_w)
    if (0 > fprintf (file, "%lld", l)) is_w= false;
  return *this;
}
tm_ostream & tm_ostream::operator<< ( unsigned long long int  ul)

Definition at line 273 of file tm_ostream.cpp.

                                                  {
  if (is_buf) {
    char _buf[64];
    sprintf (_buf, "%llu", ul);
    *buf << _buf;
  }
  else if (file && is_w)
    if (0 > fprintf (file, "%llu", ul)) is_w= false;
  return *this;
}
tm_ostream & tm_ostream::operator<< ( float  f)

Definition at line 285 of file tm_ostream.cpp.

                                {
  if (is_buf) {
    char _buf[32];
    sprintf (_buf, "%g", f);
    *buf << _buf;
  }
  else if (file && is_w)
    if (0 > fprintf (file, "%g", f)) is_w= false;
  return *this;
}
tm_ostream & tm_ostream::operator<< ( double  d)

Definition at line 297 of file tm_ostream.cpp.

                                 {
  if (is_buf) {
    char _buf[64];
    sprintf (_buf, "%g", d);
    *buf << _buf;
  }
  else 
  if (file && is_w)
    if (0 > fprintf (file, "%g", d)) is_w= false;
  return *this;
}
tm_ostream & tm_ostream::operator<< ( long double  ld)

Definition at line 310 of file tm_ostream.cpp.

                                       {
  if (is_buf) {
    char _buf[128];
    sprintf (_buf, "%Lg", ld);
    *buf << _buf;
  }
  else if (file && is_w)
    if (0 > fprintf (file, "%Lg", ld)) is_w= false;
  return *this;
}
tm_ostream & tm_ostream::operator<< ( const char *  s)

Definition at line 322 of file tm_ostream.cpp.

                                      {
  if (is_buf) *buf << s;
  else if (file && is_w) {
    if (0 <= fprintf (file, "%s", s)) {
      const char* c= s;
      while (*c != 0 && *c != '\n') ++c;
      if (*c == '\n') flush ();
    } else {
      is_w= false;
    }
  }    
  return *this;
}

Here is the call graph for this function:

tm_ostream & tm_ostream::operator= ( const tm_ostream out) [private]

Definition at line 30 of file tm_ostream.cpp.

                                            { // private
  if (this != &out) {
    file= out.file;
    is_w= out.is_w;
    is_buf= out.is_buf;
    *buf= *(out.buf);
    is_mine= false;
  }
  return *this;
}
bool tm_ostream::operator== ( tm_ostream out)

Definition at line 337 of file tm_ostream.cpp.

                                        {
  return (&out == this);
}

Definition at line 153 of file tm_ostream.cpp.

                      {
  string res= *buf;
  *buf= "";
  is_buf= false;
  return res;
}

Here is the caller graph for this function:


Member Data Documentation

string* tm_ostream::buf [private]

Definition at line 21 of file tm_ostream.hpp.

Definition at line 34 of file tm_ostream.hpp.

Definition at line 33 of file tm_ostream.hpp.

FILE* tm_ostream::file [private]

Definition at line 20 of file tm_ostream.hpp.

bool tm_ostream::is_buf [private]

Definition at line 24 of file tm_ostream.hpp.

bool tm_ostream::is_mine [private]

Definition at line 23 of file tm_ostream.hpp.

bool tm_ostream::is_w [private]

Definition at line 22 of file tm_ostream.hpp.

Definition at line 27 of file tm_ostream.hpp.

Definition at line 26 of file tm_ostream.hpp.


The documentation for this class was generated from the following files: