Public Types | Public Member Functions | Public Attributes | Private Member Functions
xml_buffered_writer Class Reference

List of all members.

Public Types

enum  { bufcapacitybytes, bufcapacity = bufcapacitybytes / (sizeof(char_t) + 4) }

Public Member Functions

 xml_buffered_writer (xml_writer &writer_, xml_encoding user_encoding)
 ~xml_buffered_writer ()
void flush ()
void flush (const char_t *data, size_t size)
void write (const char_t *data, size_t length)
void write (const char_t *data)
void write (char_t d0)
void write (char_t d0, char_t d1)
void write (char_t d0, char_t d1, char_t d2)
void write (char_t d0, char_t d1, char_t d2, char_t d3)
void write (char_t d0, char_t d1, char_t d2, char_t d3, char_t d4)
void write (char_t d0, char_t d1, char_t d2, char_t d3, char_t d4, char_t d5)

Public Attributes

char_t buffer [bufcapacity]
union {
   uint8_t   data_u8 [4 *bufcapacity]
   uint16_t   data_u16 [2 *bufcapacity]
   uint32_t   data_u32 [bufcapacity]
   char_t   data_char [bufcapacity]
scratch
xml_writer & writer
size_t bufsize
xml_encoding encoding

Private Member Functions

 xml_buffered_writer (const xml_buffered_writer &)
xml_buffered_writeroperator= (const xml_buffered_writer &)

Detailed Description

Definition at line 3022 of file pugixml.cpp.


Member Enumeration Documentation

anonymous enum
Enumerator:
bufcapacitybytes 
bufcapacity 

Definition at line 3174 of file pugixml.cpp.

                {
                        bufcapacitybytes =
                        #ifdef PUGIXML_MEMORY_OUTPUT_STACK
                                PUGIXML_MEMORY_OUTPUT_STACK
                        #else
                                10240
                        #endif
                        ,
                        bufcapacity = bufcapacitybytes / (sizeof(char_t) + 4)
                };

Constructor & Destructor Documentation

xml_buffered_writer::xml_buffered_writer ( xml_writer &  writer_,
xml_encoding  user_encoding 
) [inline]

Definition at line 3028 of file pugixml.cpp.

References bufcapacity, and PUGI__STATIC_ASSERT.

                                                                                    : writer(writer_), bufsize(0), encoding(get_write_encoding(user_encoding))
                {
                        PUGI__STATIC_ASSERT(bufcapacity >= 8);
                }

Definition at line 3033 of file pugixml.cpp.

References flush().

                {
                        flush();
                }

Member Function Documentation

void xml_buffered_writer::flush ( ) [inline]

Definition at line 3038 of file pugixml.cpp.

References bufsize.

Referenced by write(), and ~xml_buffered_writer().

                {
                        flush(buffer, bufsize);
                        bufsize = 0;
                }
void xml_buffered_writer::flush ( const char_t *  data,
size_t  size 
) [inline]

Definition at line 3044 of file pugixml.cpp.

References convert_buffer_output(), get_write_native_encoding(), scratch, and writer.

                {
                        if (size == 0) return;

                        // fast path, just write data
                        if (encoding == get_write_native_encoding())
                                writer.write(data, size * sizeof(char_t));
                        else
                        {
                                // convert chunk
                                size_t result = convert_buffer_output(scratch.data_char, scratch.data_u8, scratch.data_u16, scratch.data_u32, data, size, encoding);
                                assert(result <= sizeof(scratch));

                                // write data
                                writer.write(scratch.data_u8, result);
                        }
                }
xml_buffered_writer& xml_buffered_writer::operator= ( const xml_buffered_writer ) [private]
void xml_buffered_writer::write ( const char_t *  data,
size_t  length 
) [inline]

Definition at line 3062 of file pugixml.cpp.

References bufcapacity, bufsize, flush(), get_valid_length(), get_write_native_encoding(), and writer.

Referenced by node_output(), node_output_attributes(), text_output(), text_output_cdata(), text_output_escaped(), and write().

                {
                        if (bufsize + length > bufcapacity)
                        {
                                // flush the remaining buffer contents
                                flush();

                                // handle large chunks
                                if (length > bufcapacity)
                                {
                                        if (encoding == get_write_native_encoding())
                                        {
                                                // fast path, can just write data chunk
                                                writer.write(data, length * sizeof(char_t));
                                                return;
                                        }

                                        // need to convert in suitable chunks
                                        while (length > bufcapacity)
                                        {
                                                // get chunk size by selecting such number of characters that are guaranteed to fit into scratch buffer
                                                // and form a complete codepoint sequence (i.e. discard start of last codepoint if necessary)
                                                size_t chunk_size = get_valid_length(data, bufcapacity);

                                                // convert chunk and write
                                                flush(data, chunk_size);

                                                // iterate
                                                data += chunk_size;
                                                length -= chunk_size;
                                        }

                                        // small tail is copied below
                                        bufsize = 0;
                                }
                        }

                        memcpy(buffer + bufsize, data, length * sizeof(char_t));
                        bufsize += length;
                }
void xml_buffered_writer::write ( const char_t *  data) [inline]

Definition at line 3103 of file pugixml.cpp.

References strlength(), and write().

                {
                        write(data, strlength(data));
                }
void xml_buffered_writer::write ( char_t  d0) [inline]

Definition at line 3108 of file pugixml.cpp.

References bufcapacity, bufsize, and flush().

                {
                        if (bufsize + 1 > bufcapacity) flush();

                        buffer[bufsize + 0] = d0;
                        bufsize += 1;
                }
void xml_buffered_writer::write ( char_t  d0,
char_t  d1 
) [inline]

Definition at line 3116 of file pugixml.cpp.

References bufcapacity, bufsize, and flush().

                {
                        if (bufsize + 2 > bufcapacity) flush();

                        buffer[bufsize + 0] = d0;
                        buffer[bufsize + 1] = d1;
                        bufsize += 2;
                }
void xml_buffered_writer::write ( char_t  d0,
char_t  d1,
char_t  d2 
) [inline]

Definition at line 3125 of file pugixml.cpp.

References bufcapacity, bufsize, and flush().

                {
                        if (bufsize + 3 > bufcapacity) flush();

                        buffer[bufsize + 0] = d0;
                        buffer[bufsize + 1] = d1;
                        buffer[bufsize + 2] = d2;
                        bufsize += 3;
                }
void xml_buffered_writer::write ( char_t  d0,
char_t  d1,
char_t  d2,
char_t  d3 
) [inline]

Definition at line 3135 of file pugixml.cpp.

References bufcapacity, bufsize, and flush().

                {
                        if (bufsize + 4 > bufcapacity) flush();

                        buffer[bufsize + 0] = d0;
                        buffer[bufsize + 1] = d1;
                        buffer[bufsize + 2] = d2;
                        buffer[bufsize + 3] = d3;
                        bufsize += 4;
                }
void xml_buffered_writer::write ( char_t  d0,
char_t  d1,
char_t  d2,
char_t  d3,
char_t  d4 
) [inline]

Definition at line 3146 of file pugixml.cpp.

References bufcapacity, bufsize, and flush().

                {
                        if (bufsize + 5 > bufcapacity) flush();

                        buffer[bufsize + 0] = d0;
                        buffer[bufsize + 1] = d1;
                        buffer[bufsize + 2] = d2;
                        buffer[bufsize + 3] = d3;
                        buffer[bufsize + 4] = d4;
                        bufsize += 5;
                }
void xml_buffered_writer::write ( char_t  d0,
char_t  d1,
char_t  d2,
char_t  d3,
char_t  d4,
char_t  d5 
) [inline]

Definition at line 3158 of file pugixml.cpp.

References bufcapacity, bufsize, and flush().

                {
                        if (bufsize + 6 > bufcapacity) flush();

                        buffer[bufsize + 0] = d0;
                        buffer[bufsize + 1] = d1;
                        buffer[bufsize + 2] = d2;
                        buffer[bufsize + 3] = d3;
                        buffer[bufsize + 4] = d4;
                        buffer[bufsize + 5] = d5;
                        bufsize += 6;
                }

Member Data Documentation

Definition at line 3186 of file pugixml.cpp.

Definition at line 3197 of file pugixml.cpp.

Referenced by flush(), and write().

Definition at line 3193 of file pugixml.cpp.

Definition at line 3191 of file pugixml.cpp.

Definition at line 3192 of file pugixml.cpp.

Definition at line 3190 of file pugixml.cpp.

Definition at line 3198 of file pugixml.cpp.

Referenced by flush().

Definition at line 3196 of file pugixml.cpp.

Referenced by flush(), and write().


The documentation for this class was generated from the following file:

Generated on Mon Sep 15 2014 01:23:55 for QuickFIX by doxygen 1.7.6.1 written by Dimitri van Heesch, © 1997-2001