[GME-commit] GMESRC/Paradigms/MetaGME/BonExtension LogStream.cpp,NONE,1.1 LogStream.h,NONE,1.1 BonExt.dsp,1.8,1.9

gme-commit at list.isis.vanderbilt.edu gme-commit at list.isis.vanderbilt.edu
Fri Jul 30 16:22:04 CDT 2004


Update of /var/lib/gme/GMESRC/Paradigms/MetaGME/BonExtension
In directory braindrain:/tmp/cvs-serv24633

Modified Files:
	BonExt.dsp 
Added Files:
	LogStream.cpp LogStream.h 
Log Message:


CVS User: zolmol

--- NEW FILE: LogStream.cpp ---
#include "stdafx.h"
#include "LogStream.h"
#include "BON.h"
#include "BONImpl.h"

LogStream::LogStream()
	: m_proj( BON::Project())
	, m_msgtype( MSG_NORMAL)
	, m_buff()
{ }

LogStream::~LogStream() 
{
	m_proj = BON::Project();
	m_buff = "";
}

void LogStream::flushit()
{
	*this << "\n"; // flush
}

//
// friend put-to operators

LogStream& operator<<( LogStream& stream, msgtype_enum msgtype)
{
	if( !stream.m_buff.empty()) stream << "\n"; // like a flush

	stream.m_msgtype = msgtype;
	/*switch( stream.m_msgtype) {
		case MSG_ERROR:		stream.write( "Error: ", 7); break;
		case MSG_WARNING:	stream.write( "Warning: ", 9); break;
		case MSG_INFO:		stream.write( "Info: ", 5); break;
		case MSG_NORMAL:	;
	}*/

	return stream;

}

LogStream& operator<<( LogStream& stream, const BON::FCO& fco)
{
	std::string tok = "<b>Null_object</b>";
	if( fco)
	{
		try {
			std::string id, nm;
			id = fco->getID();
			nm = fco->getName();
			tok = "<A HREF=\"mga:" + id +"\">" + nm + "</A>";
		} catch( ...) {
		}
	}

	return stream << tok;
}

LogStream& operator<<( LogStream& stream, const char * r)
{
	return stream << std::string( r);
}

LogStream& operator<<( LogStream& stream, const std::string& r)
{
	stream.write( r.c_str(), r.length());
	
	stream.m_buff += r;
	if( r.find('\n') != std::string::npos)
	{
		stream.m_proj->consoleMsg( stream.m_buff, stream.m_msgtype);
		stream.m_buff = "";
	}
	
	return stream;
}


--- NEW FILE: LogStream.h ---
#ifndef LOGSTREAM_H
#define LOGSTREAM_H

#include "fstream"
#include "string"
#include "BON.h"
#include "BONImpl.h"

class LogStream : public std::ofstream
{
public:
	LogStream();
	~LogStream();
	void flushit();

	// friend put-to operators
	friend LogStream& operator<<( LogStream& s, msgtype_enum msgtype);
	friend LogStream& operator<<( LogStream& s, const BON::FCO& fco);
	friend LogStream& operator<<( LogStream& s, const char * r);
	friend LogStream& operator<<( LogStream& s, const std::string& r);

	BON::Project m_proj;
	msgtype_enum m_msgtype;
	std::string  m_buff;
};

#endif //LOGSTREAM_H

Index: BonExt.dsp
===================================================================
RCS file: /var/lib/gme/GMESRC/Paradigms/MetaGME/BonExtension/BonExt.dsp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** BonExt.dsp	16 Jun 2004 18:35:00 -0000	1.8
--- BonExt.dsp	30 Jul 2004 20:22:02 -0000	1.9
***************
*** 210,213 ****
--- 210,217 ----
  # Begin Source File
  
+ SOURCE=.\LogStream.cpp
+ # End Source File
+ # Begin Source File
+ 
  SOURCE=.\Regexp.cpp
  # End Source File
***************
*** 253,256 ****
--- 257,265 ----
  # Begin Source File
  
+ SOURCE=.\BON2Engine.cpp
+ # SUBTRACT CPP /YX /Yc /Yu
+ # End Source File
+ # Begin Source File
+ 
  SOURCE="../../../SDK/BON/BONImpl.cpp"
  # SUBTRACT CPP /YX /Yc /Yu
***************
*** 459,462 ****
--- 468,475 ----
  
  SOURCE=.\logger.h
+ # End Source File
+ # Begin Source File
+ 
+ SOURCE=.\LogStream.h
  # End Source File
  # Begin Source File



More information about the GME-commit mailing list