41 FW_ASSERT(numRead >= 0 && numRead <= size);
42 memset((
U8*)ptr + numRead, 0, size - numRead);
43 setError(
"Unexpected end of stream!");
53 m_buffer (
NULL, bufferSize)
98 bool pendingBackslash =
false;
102 U8 chr = ptr[inPos++];
103 if (chr >= 32 && chr !=
'\\' && !pendingBackslash)
105 else if (chr ==
'\n')
107 if (!pendingBackslash)
110 pendingBackslash =
false;
112 else if (chr !=
'\r')
114 if (pendingBackslash)
116 ptr[outPos++] =
'\\';
117 pendingBackslash =
false;
119 if (chr ==
'\t' && normalizeWhitespace)
121 else if (chr ==
'\\' && combineWithBackslash)
122 pendingBackslash =
true;
134 if (pendingBackslash)
135 ptr[outPos++] =
'\\';
142 char* line = (
char*)ptr;
155 if (m_numRead - size >= m_numConsumed)
160 if (m_numRead == m_buffer.
getSize())
166 memcpy(m_buffer.
getPtr(), m_buffer.
getPtr(m_numConsumed), m_numRead - m_numConsumed);
167 m_numRead -= m_numConsumed;
174 m_numRead += m_stream.
read(m_buffer.
getPtr(m_numRead), m_buffer.
getSize() - m_numRead);
175 return (m_numRead - size >= m_numConsumed);
187 int tmp =
min(numLeft, m_numRead - m_numConsumed);
189 m_numConsumed += tmp;
197 m_writeOnLF (writeOnLF),
198 m_emulateCR (emulateCR),
200 m_buffer (
NULL, bufferSize),
225 int num =
min(size - ofs, m_buffer.
getSize() - m_numValid);
226 memcpy(m_buffer.
getPtr(m_numValid), (
const U8*)ptr + ofs, num);
251 int space = m_buffer.
getSize() - m_numValid;
252 int size = vsnprintf_s((
char*)m_buffer.
getPtr(m_numValid), space, space - 1, fmt, args);
260 size = _vscprintf(fmt, args);
262 addValid(vsprintf_s((
char*)m_buffer.
getPtr(), m_buffer.
getSize(), fmt, args));
265 char* tmp =
new char[size + 1];
266 vsprintf_s(tmp, size + 1, fmt, args);
267 m_stream.
write(tmp, size);
268 m_numFlushed +=
size;
284 void BufferedOutputStream::addValid(
int size)
292 int old = m_numValid;
294 if (!m_writeOnLF && !m_emulateCR)
301 for (
int i = m_numValid - 1; i >= old; i--)
303 if (m_buffer[i] ==
'\n')
316 for (
int i = old; i < m_numValid; i++)
320 m_currOfs = m_lineStart;
324 m_buffer[m_currOfs++] =
v;
325 m_lineStart = m_currOfs;
330 m_buffer[m_currOfs++] =
v;
331 lineEnd =
max(lineEnd, m_currOfs);
335 m_numValid = lineEnd;
336 if (m_writeOnLF && m_lineStart)
342 void BufferedOutputStream::flushInternal(
void)
344 int size = (m_lineStart) ? m_lineStart : m_numValid;
349 m_numFlushed +=
size;
352 memmove(m_buffer.
getPtr(), m_buffer.
getPtr(size), m_numValid);
353 m_lineStart =
max(m_lineStart - size, 0);
354 m_currOfs =
max(m_currOfs - size, 0);
367 int numRead =
min(size, m_size - m_ofs);
368 memcpy(ptr, m_ptr + m_ofs, numRead);
383 m_data.
add((
const U8*)ptr, size);
BufferedOutputStream(OutputStream &stream, int bufferSize=64<< 10, bool writeOnLF=false, bool emulateCR=false)
void setError(const char *fmt,...)
virtual void write(const void *ptr, int size)
virtual void write(const void *ptr, int size)=0
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr const GLvoid GLenum usage GLuint shader GLenum type GLsizei const GLuint framebuffers GLsizei const GLuint renderbuffers GLuint v
FW_CUDA_FUNC T min(const VectorBase< T, L, S > &v)
FW_CUDA_FUNC T max(const VectorBase< T, L, S > &v)
virtual void flush(void)=0
virtual ~MemoryOutputStream(void)
virtual void write(const void *ptr, int size)
virtual ~BufferedOutputStream(void)
void writefv(const char *fmt, va_list args)
void writef(const char *fmt,...)
const T * getPtr(S idx=0) const
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr size