class SingleByteInputStream
{
typedef typename InputStreamType::byte_type byte_type;
- static const int BUFFERSIZE = SIZE;
InputStreamType& m_inputStream;
- byte_type m_buffer[BUFFERSIZE];
+ byte_type m_buffer[SIZE];
byte_type* m_cur;
byte_type* m_end;
public:
- SingleByteInputStream(InputStreamType& inputStream) : m_inputStream(inputStream), m_cur(m_buffer + BUFFERSIZE), m_end(m_cur)
+ SingleByteInputStream(InputStreamType& inputStream) : m_inputStream(inputStream), m_cur(m_buffer + SIZE), m_end(m_cur)
{
}
bool readByte(byte_type& b)
{
if(m_cur == m_end)
{
- if(m_end != m_buffer + BUFFERSIZE)
+ if(m_end != m_buffer + SIZE)
{
return false;
}
- m_end = m_buffer + m_inputStream.read(m_buffer, BUFFERSIZE);
+ m_end = m_buffer + m_inputStream.read(m_buffer, SIZE);
m_cur = m_buffer;
if(m_end == m_buffer)
#else
#define ASSERT_MESSAGE(condition, message)
+#define ERROR_MESSAGE(message)
#define ASSERT_NOTNULL(ptr)
#endif
class StaticNodeType
{
public:
- static const int SIZE = NODETYPEID_MAX;
+ enum unnamed0 { SIZE = NODETYPEID_MAX };
static TypeId getTypeId()
{
return Static< NodeType<Type> >::instance().getTypeId();
class Node
{
public:
- static const int eVisible = 0;
- static const int eHidden = 1 << 0;
- static const int eFiltered = 1 << 1;
- static const int eExcluded = 1 << 2;
+ enum unnamed0 { eVisible = 0 };
+ enum unnamed1 { eHidden = 1 << 0 };
+ enum unnamed2 { eFiltered = 1 << 1 };
+ enum unnamed3 { eExcluded = 1 << 2 };
class Symbiot
{
class StaticInstanceType
{
public:
- static const int SIZE = INSTANCETYPEID_MAX;
+ enum unnamed0 { SIZE = INSTANCETYPEID_MAX };
static TypeId getTypeId()
{
return Static< InstanceType<Type> >::instance().getTypeId();
}
};
+/// \brief A wrapper for a TextOutputStream, optimised for writing a single character at a time.
+class SingleCharacterOutputStream : public TextOutputStream
+{
+ enum unnamed0 { m_bufsize = 1024 };
+ TextOutputStream& m_ostream;
+ char m_buffer[m_bufsize];
+ char* m_pos;
+ const char* m_end;
+
+ const char* end() const
+ {
+ return m_end;
+ }
+ void reset()
+ {
+ m_pos = m_buffer;
+ }
+ void flush()
+ {
+ m_ostream.write(m_buffer, m_pos - m_buffer);
+ reset();
+ }
+public:
+ SingleCharacterOutputStream(TextOutputStream& ostream) : m_ostream(ostream), m_pos(m_buffer), m_end(m_buffer+m_bufsize)
+ {
+ }
+ ~SingleCharacterOutputStream()
+ {
+ flush();
+ }
+ void write(const char c)
+ {
+ if(m_pos == end())
+ {
+ flush();
+ }
+ *m_pos++ = c;
+ }
+ std::size_t write(const char* buffer, std::size_t length)
+ {
+ const char*const end = buffer + length;
+ for(const char* p = buffer; p != end; ++p)
+ {
+ write(*p);
+ }
+ return length;
+ }
+};
+
+/// \brief A wrapper for a TextOutputStream, optimised for writing a few characters at a time.
+template<typename TextOutputStreamType, int SIZE = 1024>
+class BufferedTextOutputStream : public TextOutputStream
+{
+ TextOutputStreamType outputStream;
+ char m_buffer[SIZE];
+ char* m_cur;
+
+public:
+ BufferedTextOutputStream(TextOutputStreamType& outputStream) : outputStream(outputStream), m_cur(m_buffer)
+ {
+ }
+ ~BufferedTextOutputStream()
+ {
+ outputStream.write(m_buffer, m_cur - m_buffer);
+ }
+ std::size_t write(const char* buffer, std::size_t length)
+ {
+ std::size_t remaining = length;
+ for(;;)
+ {
+ std::size_t n = std::min(remaining, std::size_t((m_buffer + SIZE) - m_cur));
+ m_cur = std::copy(buffer, buffer + n, m_cur);
+ remaining -= n;
+ if(remaining == 0)
+ {
+ return 0;
+ }
+ outputStream.write(m_buffer, SIZE);
+ m_cur = m_buffer;
+ }
+ }
+};
+
#endif
class XMLStreamParser : public XMLExporter
{
- static const int BUFSIZE = 1024;
+ enum unnamed0 { BUFSIZE = 1024 };
public:
XMLStreamParser(TextInputStream& istream)
: m_istream(istream)
#include <vector>
#include "xml/ixml.h"
-class BufferedTextOutputStream : public TextOutputStream
-{
- static const int m_bufsize = 1024;
- TextOutputStream& m_ostream;
- char m_buffer[m_bufsize];
- char* m_pos;
- const char* m_end;
-
- const char* end() const
- {
- return m_end;
- }
- void reset()
- {
- m_pos = m_buffer;
- }
- void flush()
- {
- m_ostream.write(m_buffer, m_pos - m_buffer);
- reset();
- }
-public:
- BufferedTextOutputStream(TextOutputStream& ostream) : m_ostream(ostream), m_pos(m_buffer), m_end(m_buffer+m_bufsize)
- {
- }
- ~BufferedTextOutputStream()
- {
- flush();
- }
- void write(const char c)
- {
- if(m_pos == end())
- {
- flush();
- }
- *m_pos++ = c;
- }
- std::size_t write(const char* buffer, std::size_t length)
- {
- const char*const end = buffer + length;
- for(const char* p = buffer; p != end; ++p)
- {
- write(*p);
- }
- return length;
- }
-};
-
class XMLEntityOutputStream
{
- BufferedTextOutputStream m_ostream;
+ SingleCharacterOutputStream m_ostream;
public:
XMLEntityOutputStream(TextOutputStream& ostream)
: m_ostream(ostream)
{
InputStream& m_istream;
z_stream m_zipstream;
- static const int m_bufsize = 1024;
+ enum unnamed0 { m_bufsize = 1024 };
unsigned char m_buffer[m_bufsize];
public:
}
- GtkTextBufferOutputStream textBuffer(buffer, &iter, tag);
- if(!globalCharacterSet().isUTF8())
{
- textBuffer << ConvertLocaleToUTF8(StringRange(buf, buf + length));
- }
- else
- {
- textBuffer << StringRange(buf, buf + length);
+ GtkTextBufferOutputStream textBuffer(buffer, &iter, tag);
+ if(!globalCharacterSet().isUTF8())
+ {
+ BufferedTextOutputStream<GtkTextBufferOutputStream> buffered(textBuffer);
+ buffered << ConvertLocaleToUTF8(StringRange(buf, buf + length));
+ }
+ else
+ {
+ textBuffer << StringRange(buf, buf + length);
+ }
}
// update console widget immediatly if we're doing something time-consuming
class RadiantUndoSystem : public UndoSystem
{
- static const int MAX_UNDO_LEVELS = 1024;
+ INTEGER_CONSTANT(MAX_UNDO_LEVELS, 1024);
class Snapshot
{
}
void setLevels(std::size_t levels)
{
- if(levels > MAX_UNDO_LEVELS)
+ if(levels > MAX_UNDO_LEVELS())
{
- levels = MAX_UNDO_LEVELS;
+ levels = MAX_UNDO_LEVELS();
}
while(m_undo_stack.size() > levels)
int geometry_depth; // are we parsing some geometry information (i.e. do we forward the SAX calls?)
ISAXHandler* pGeometry; // the handler
- static const int bufsize = 1024;
+ enum unnamed0 { bufsize = 1024 };
char m_buffer[bufsize];
std::size_t m_length;
};