[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src Debug.cc,1.1,1.2 Debug.hh,1.1,1.2 Pin
From: |
torangan |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src Debug.cc,1.1,1.2 Debug.hh,1.1,1.2 PingusStream.cc,1.1,1.2 PingusStream.hh,1.1,1.2 |
Date: |
6 Jun 2002 13:56:51 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv23147
Modified Files:
Debug.cc Debug.hh PingusStream.cc PingusStream.hh
Log Message:
Changed MultiplexStream to DebugStream, cleanup of the code
Index: Debug.cc
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/Debug.cc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Debug.cc 5 Jun 2002 17:51:08 -0000 1.1
+++ Debug.cc 6 Jun 2002 13:56:48 -0000 1.2
@@ -20,12 +20,12 @@
#include "Debug.hh"
/* Stream for error messages */
-MultiplexStream perr("[Error] ");
+DebugStream perr("[Error] ");
/* Stream for warnings */
-MultiplexStream pwarn("[Warning] ");
+DebugStream pwarn("[Warning] ");
/* For everything else (temporary stuff only) */
-MultiplexStream pout ("[Output] ");
+DebugStream pout ("[Output] ");
/* EOF */
Index: Debug.hh
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/Debug.hh,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Debug.hh 5 Jun 2002 17:51:08 -0000 1.1
+++ Debug.hh 6 Jun 2002 13:56:48 -0000 1.2
@@ -23,13 +23,13 @@
#include "PingusStream.hh"
/* Stream for error messages */
-extern MultiplexStream perr;
+extern DebugStream perr;
/* Stream for warnings */
-extern MultiplexStream pwarn;
+extern DebugStream pwarn;
/* Stream for warnings */
-extern MultiplexStream pout;
+extern DebugStream pout;
#endif
Index: PingusStream.cc
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/PingusStream.cc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- PingusStream.cc 5 Jun 2002 17:51:08 -0000 1.1
+++ PingusStream.cc 6 Jun 2002 13:56:48 -0000 1.2
@@ -19,9 +19,7 @@
#include "PingusStream.hh"
-const int MultiplexStreamBuffer::buffersize = 200;
-
-MultiplexStreamBuffer::MultiplexStreamBuffer (const std::string& p)
+DebugStream::Buffer::Buffer (const std::string& p)
: prefix (p)
{
// Set the output buffer
@@ -31,13 +29,13 @@
setg(0, 0, 0);
}
-MultiplexStreamBuffer::~MultiplexStreamBuffer ()
+DebugStream::Buffer::~Buffer ()
{
sync ();
}
int
-MultiplexStreamBuffer::overflow (int c)
+DebugStream::Buffer::overflow (int c)
{
std::string str;
@@ -59,7 +57,7 @@
}
void
-MultiplexStreamBuffer::put_line (const std::string& line)
+DebugStream::Buffer::put_line (const std::string& line)
{
if (!out_streams.empty ())
{
@@ -71,12 +69,12 @@
}
else
{
- std::cout << "[MultiplexStreamBuffer fallback stream] " << line;
+ std::cout << "[DebugStream::Buffer fallback stream] " << line;
}
}
int
-MultiplexStreamBuffer::sync ()
+DebugStream::Buffer::sync ()
{
std::string str;
@@ -102,25 +100,43 @@
}
void
-MultiplexStreamBuffer::add (std::ostream& s)
+DebugStream::Buffer::add (std::ostream& s)
{
out_streams.push_back (&s);
}
-MultiplexStream::MultiplexStream (const std::string& prefix)
+
+void
+DebugStream::Buffer::set_prefix (const std::string & prefix_)
+{
+ prefix = prefix_;
+}
+
+
+// ----------------------------------------------------------------
+
+
+DebugStream::DebugStream (const std::string& prefix)
: std::ostream (&buffer),
buffer (prefix)
{
}
-MultiplexStream::~MultiplexStream ()
+DebugStream::~DebugStream ()
{
}
void
-MultiplexStream::add (std::ostream& s)
+DebugStream::add (std::ostream& s)
{
buffer.add (s);
}
+
+void
+DebugStream::set_prefix (const std::string & prefix)
+{
+ buffer.set_prefix(prefix);
+}
+
/* EOF */
Index: PingusStream.hh
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/PingusStream.hh,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- PingusStream.hh 5 Jun 2002 17:51:08 -0000 1.1
+++ PingusStream.hh 6 Jun 2002 13:56:48 -0000 1.2
@@ -24,43 +24,52 @@
#include <vector>
#include <iostream>
-class MultiplexStreamBuffer
- : public std::streambuf
+
+class DebugStream
+ : public std::ostream
{
+
private:
- static const int buffersize;
- std::vector<std::ostream*> out_streams;
+ class Buffer
+ : public std::streambuf
+ {
+ private:
- std::string current_line;
- bool continue_last;
- std::vector<std::string> buffer;
- char char_buffer[200];
+ // unnessecary complex in this case
+ // static const int buffersize;
+ enum { buffersize = 200 };
+
+ std::vector<std::ostream*> out_streams;
+
+ char char_buffer[200];
+ std::string prefix;
- std::string prefix;
+ public:
- void put_line (const std::string& line);
-public:
- MultiplexStreamBuffer (const std::string& prefix);
- virtual ~MultiplexStreamBuffer ();
+ Buffer (const std::string& prefix);
+ virtual ~Buffer ();
- int overflow (int c);
- int sync ();
+ int overflow (int c);
+ int sync ();
- void add (std::ostream& s);
-};
+ void add (std::ostream& s);
+ void set_prefix (const std::string & prefix_);
+
+ private:
-class MultiplexStream
- : public std::ostream
-{
-private:
- MultiplexStreamBuffer buffer;
+ void put_line (const std::string& line);
+ } buffer;
+
+
public:
- MultiplexStream (const std::string& prefix);
- virtual ~MultiplexStream ();
+
+ DebugStream (const std::string& prefix);
+ virtual ~DebugStream ();
void add (std::ostream& s);
+ void set_prefix (const std::string & prefix);
};
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src Debug.cc,1.1,1.2 Debug.hh,1.1,1.2 PingusStream.cc,1.1,1.2 PingusStream.hh,1.1,1.2,
torangan <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src/worldmap PingusWorldMap.cc,1.36,1.37 PingusWorldMap.hh,1.20,1.21 PingusWorldMapGraph.cc,1.30,1.31 PingusWorldMapGraph.hh,1.19,1.20 PingusWorldMapNode.cc,1.1,1.2 PingusWorldMapNode.hh,1.1,1.2 PingusWorldMapNodeData.cc,1.1,1.2 PingusWorldMapNodeData.hh,1.1,1.2 PingusWorldMapPingus.cc,1.14,1.15 PingusWorldMapPingus.hh,1.10,1.11 PingusWorldMapStat.cc,1.4,1.5 PingusWorldMapStat.hh,1.3,1.4
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/src Display.hh,1.10,1.11 Story.cc,1.13,1.14 SurfaceButton.hh,1.21,1.22 globals.cc,1.39,1.40
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src/worldmap PingusWorldMap.cc,1.36,1.37 PingusWorldMap.hh,1.20,1.21 PingusWorldMapGraph.cc,1.30,1.31 PingusWorldMapGraph.hh,1.19,1.20 PingusWorldMapNode.cc,1.1,1.2 PingusWorldMapNode.hh,1.1,1.2 PingusWorldMapNodeData.cc,1.1,1.2 PingusWorldMapNodeData.hh,1.1,1.2 PingusWorldMapPingus.cc,1.14,1.15 PingusWorldMapPingus.hh,1.10,1.11 PingusWorldMapStat.cc,1.4,1.5 PingusWorldMapStat.hh,1.3,1.4
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/src Display.hh,1.10,1.11 Story.cc,1.13,1.14 SurfaceButton.hh,1.21,1.22 globals.cc,1.39,1.40
- Index(es):