Merge internal branch.
This commit is contained in:
@ -17,6 +17,7 @@ SET(CORE_SRCS
|
||||
TextReader.h
|
||||
TextReader.cpp
|
||||
TextWriter.h
|
||||
TextWriter.cpp
|
||||
Tokenizer.h
|
||||
Tokenizer.cpp
|
||||
Radix.h
|
||||
|
@ -23,12 +23,6 @@ Do not use memmove in insert & remove, use copy ctors instead.
|
||||
#include <string.h> // memmove
|
||||
#include <new> // for placement new
|
||||
|
||||
#ifndef USE_TU_CONTAINERS
|
||||
#define USE_TU_CONTAINERS 1
|
||||
#endif
|
||||
|
||||
|
||||
#if USE_TU_CONTAINERS
|
||||
|
||||
#if NV_CC_GNUC // If typeof is available:
|
||||
|
||||
@ -57,7 +51,7 @@ struct PseudoIndexWrapper {
|
||||
return *reinterpret_cast<const typename T::PseudoIndex *>(memory);
|
||||
}
|
||||
|
||||
uint8 memory[8]; // Increase the size if we have bigger enumerators.
|
||||
uint8 memory[4]; // Increase the size if we have bigger enumerators.
|
||||
};
|
||||
|
||||
#define NV_FOREACH(i, container) \
|
||||
@ -70,7 +64,6 @@ struct PseudoIndexWrapper {
|
||||
# define foreach NV_FOREACH
|
||||
#endif
|
||||
|
||||
#endif // USE_TU_CONTAINERS
|
||||
|
||||
|
||||
namespace nv
|
||||
@ -193,7 +186,6 @@ namespace nv
|
||||
virtual T current();
|
||||
};
|
||||
|
||||
#if USE_TU_CONTAINERS
|
||||
|
||||
/**
|
||||
* Replacement for std::vector that is easier to debug and provides
|
||||
@ -1060,8 +1052,8 @@ namespace nv
|
||||
|
||||
};
|
||||
|
||||
#endif // USE_TU_CONTAINERS
|
||||
|
||||
|
||||
|
||||
} // nv namespace
|
||||
|
||||
#endif // NV_CORE_CONTAINER_H
|
||||
|
@ -314,7 +314,12 @@ public:
|
||||
{
|
||||
return m_s->isError();
|
||||
}
|
||||
|
||||
|
||||
virtual void clearError()
|
||||
{
|
||||
m_s->clearError();
|
||||
}
|
||||
|
||||
virtual bool isAtEnd() const
|
||||
{
|
||||
return m_s->isAtEnd();
|
||||
|
45
src/nvcore/TextWriter.cpp
Normal file
45
src/nvcore/TextWriter.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
// This code is in the public domain -- castanyo@yahoo.es
|
||||
|
||||
#include <nvcore/TextWriter.h>
|
||||
|
||||
using namespace nv;
|
||||
|
||||
|
||||
/// Constructor
|
||||
TextWriter::TextWriter(Stream * s) :
|
||||
s(s),
|
||||
str(1024)
|
||||
{
|
||||
nvCheck(s != NULL);
|
||||
nvCheck(s->isSaving());
|
||||
}
|
||||
|
||||
void TextWriter::writeString(const char * str)
|
||||
{
|
||||
nvDebugCheck(s != NULL);
|
||||
s->serialize(const_cast<char *>(str), strlen(str));
|
||||
}
|
||||
|
||||
void TextWriter::writeString(const char * str, uint len)
|
||||
{
|
||||
nvDebugCheck(s != NULL);
|
||||
s->serialize(const_cast<char *>(str), len);
|
||||
}
|
||||
|
||||
void TextWriter::write(const char * format, ...)
|
||||
{
|
||||
va_list arg;
|
||||
va_start(arg,format);
|
||||
str.format(format, arg);
|
||||
writeString(str.str(), str.length());
|
||||
va_end(arg);
|
||||
}
|
||||
|
||||
void TextWriter::write(const char * format, va_list arg)
|
||||
{
|
||||
va_list tmp;
|
||||
va_copy(tmp, arg);
|
||||
str.format(format, arg);
|
||||
writeString(str.str(), str.length());
|
||||
va_end(tmp);
|
||||
}
|
@ -7,9 +7,6 @@
|
||||
#include <nvcore/Stream.h>
|
||||
#include <nvcore/StrLib.h>
|
||||
|
||||
// @@ NOT IMPLEMENTED !!!
|
||||
|
||||
|
||||
namespace nv
|
||||
{
|
||||
|
||||
@ -18,16 +15,12 @@ namespace nv
|
||||
{
|
||||
public:
|
||||
|
||||
/// Ctor.
|
||||
TextWriter(Stream * s) : s(s), str(1024) {
|
||||
nvDebugCheck(s != NULL);
|
||||
nvCheck(s->IsSaving());
|
||||
}
|
||||
|
||||
void write( const char * str, uint len );
|
||||
void write( const char * format, ... ) __attribute__((format (printf, 2, 3)));
|
||||
void write( const char * format, va_list arg );
|
||||
TextWriter(Stream * s);
|
||||
|
||||
void writeString(const char * str);
|
||||
void writeString(const char * str, uint len);
|
||||
void write(const char * format, ...) __attribute__((format (printf, 2, 3)));
|
||||
void write(const char * format, va_list arg);
|
||||
|
||||
private:
|
||||
|
||||
@ -38,7 +31,35 @@ namespace nv
|
||||
|
||||
};
|
||||
|
||||
|
||||
inline TextWriter & operator<<( TextWriter & tw, int i)
|
||||
{
|
||||
tw.write("%d", i);
|
||||
return tw;
|
||||
}
|
||||
|
||||
inline TextWriter & operator<<( TextWriter & tw, uint i)
|
||||
{
|
||||
tw.write("%u", i);
|
||||
return tw;
|
||||
}
|
||||
|
||||
inline TextWriter & operator<<( TextWriter & tw, float f)
|
||||
{
|
||||
tw.write("%f", f);
|
||||
return tw;
|
||||
}
|
||||
|
||||
inline TextWriter & operator<<( TextWriter & tw, const char * str)
|
||||
{
|
||||
tw.writeString(str);
|
||||
return tw;
|
||||
}
|
||||
|
||||
} // nv namespace
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // NVCORE_TEXTWRITER_H
|
||||
|
Reference in New Issue
Block a user