g4tools  5.4.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tools::log_file Class Reference

Public Member Functions

void close ()
 
void write (const std::string &a_string) const
 
void writef (const char *a_format,...) const
 

Static Public Member Functions

static log_fileget ()
 

Protected Member Functions

 log_file (const log_file &)
 
log_fileoperator= (const log_file &)
 

Protected Attributes

FILE * m_FILE
 

Detailed Description

Definition at line 14 of file log_file.

Constructor & Destructor Documentation

◆ log_file()

tools::log_file::log_file ( const log_file )
inlineprotected

Definition at line 38 of file log_file.

38 :m_FILE(0) {}

Member Function Documentation

◆ close()

void tools::log_file::close ( )
inline

Definition at line 41 of file log_file.

41 {if(m_FILE) ::fclose(m_FILE);m_FILE = 0;}

◆ get()

static log_file& tools::log_file::get ( )
inlinestatic

Definition at line 16 of file log_file.

16  {
17  static log_file s_log_file;
18  return s_log_file;
19  }

◆ operator=()

log_file& tools::log_file::operator= ( const log_file )
inlineprotected

Definition at line 39 of file log_file.

39 {return *this;}

◆ write()

void tools::log_file::write ( const std::string &  a_string) const
inline

Definition at line 42 of file log_file.

42  {
43  if(!m_FILE) return;
44  if(::fprintf(m_FILE,"%s",a_string.c_str())<0) {}
45  }

◆ writef()

void tools::log_file::writef ( const char *  a_format,
  ... 
) const
inline

Definition at line 46 of file log_file.

46  {
47  if(!m_FILE) return;
48  std::string s;
49  va_list args;
50  va_start(args,a_format);
51  if(vsprintf(s,1000,a_format,args)) write(s);
52  va_end(args);
53  }

Member Data Documentation

◆ m_FILE

FILE* tools::log_file::m_FILE
protected

Definition at line 55 of file log_file.


The documentation for this class was generated from the following file:
tools::vsprintf
bool vsprintf(std::string &a_string, int a_length, const char *a_format, va_list a_args)
Definition: sprintf:12
tools::log_file::m_FILE
FILE * m_FILE
Definition: log_file:55
tools::log_file::write
void write(const std::string &a_string) const
Definition: log_file:42