Public Types | Public Member Functions | Public Attributes | Private Member Functions | List of all members
xml_buffered_writer Class Reference

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

anonymous enum
Enumerator
bufcapacitybytes 
bufcapacity 

Definition at line 3174 of file pugixml.cpp.

3175 {
3177 #ifdef PUGIXML_MEMORY_OUTPUT_STACK
3178 PUGIXML_MEMORY_OUTPUT_STACK
3179 #else
3180 10240
3181 #endif
3182 ,
3183 bufcapacity = bufcapacitybytes / (sizeof(char_t) + 4)
3184 };

Constructor & Destructor Documentation

◆ xml_buffered_writer() [1/2]

xml_buffered_writer::xml_buffered_writer ( const xml_buffered_writer )
private

◆ xml_buffered_writer() [2/2]

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

Definition at line 3028 of file pugixml.cpp.

3028 : writer(writer_), bufsize(0), encoding(get_write_encoding(user_encoding))
3029 {
3031 }
xml_writer & writer
Definition pugixml.cpp:3196
xml_encoding encoding
Definition pugixml.cpp:3198
#define PUGI__STATIC_ASSERT(cond)
Definition pugixml.cpp:95
PUGI__FN xml_encoding get_write_encoding(xml_encoding encoding)
Definition pugixml.cpp:2870

References bufcapacity, and PUGI__STATIC_ASSERT.

◆ ~xml_buffered_writer()

xml_buffered_writer::~xml_buffered_writer ( )
inline

Definition at line 3033 of file pugixml.cpp.

3034 {
3035 flush();
3036 }

References flush().

Member Function Documentation

◆ flush() [1/2]

void xml_buffered_writer::flush ( )
inline

Definition at line 3038 of file pugixml.cpp.

3039 {
3041 bufsize = 0;
3042 }
char_t buffer[bufcapacity]
Definition pugixml.cpp:3186

References buffer, bufsize, and flush().

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

◆ flush() [2/2]

void xml_buffered_writer::flush ( const char_t *  data,
size_t  size 
)
inline

Definition at line 3044 of file pugixml.cpp.

3045 {
3046 if (size == 0) return;
3047
3048 // fast path, just write data
3050 writer.write(data, size * sizeof(char_t));
3051 else
3052 {
3053 // convert chunk
3054 size_t result = convert_buffer_output(scratch.data_char, scratch.data_u8, scratch.data_u16, scratch.data_u32, data, size, encoding);
3055 assert(result <= sizeof(scratch));
3056
3057 // write data
3058 writer.write(scratch.data_u8, result);
3059 }
3060 }
union xml_buffered_writer::@6 scratch
PUGI__FN xml_encoding get_write_native_encoding()
Definition pugixml.cpp:2861
PUGI__FN size_t convert_buffer_output(char_t *, uint8_t *r_u8, uint16_t *r_u16, uint32_t *r_u32, const char_t *data, size_t length, xml_encoding encoding)
Definition pugixml.cpp:2977

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

◆ operator=()

xml_buffered_writer & xml_buffered_writer::operator= ( const xml_buffered_writer )
private

◆ write() [1/8]

void xml_buffered_writer::write ( char_t  d0)
inline

Definition at line 3108 of file pugixml.cpp.

3109 {
3110 if (bufsize + 1 > bufcapacity) flush();
3111
3112 buffer[bufsize + 0] = d0;
3113 bufsize += 1;
3114 }

References bufcapacity, buffer, bufsize, and flush().

◆ write() [2/8]

void xml_buffered_writer::write ( char_t  d0,
char_t  d1 
)
inline

Definition at line 3116 of file pugixml.cpp.

3117 {
3118 if (bufsize + 2 > bufcapacity) flush();
3119
3120 buffer[bufsize + 0] = d0;
3121 buffer[bufsize + 1] = d1;
3122 bufsize += 2;
3123 }

References bufcapacity, buffer, bufsize, and flush().

◆ write() [3/8]

void xml_buffered_writer::write ( char_t  d0,
char_t  d1,
char_t  d2 
)
inline

Definition at line 3125 of file pugixml.cpp.

3126 {
3127 if (bufsize + 3 > bufcapacity) flush();
3128
3129 buffer[bufsize + 0] = d0;
3130 buffer[bufsize + 1] = d1;
3131 buffer[bufsize + 2] = d2;
3132 bufsize += 3;
3133 }

References bufcapacity, buffer, bufsize, and flush().

◆ write() [4/8]

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.

3136 {
3137 if (bufsize + 4 > bufcapacity) flush();
3138
3139 buffer[bufsize + 0] = d0;
3140 buffer[bufsize + 1] = d1;
3141 buffer[bufsize + 2] = d2;
3142 buffer[bufsize + 3] = d3;
3143 bufsize += 4;
3144 }

References bufcapacity, buffer, bufsize, and flush().

◆ write() [5/8]

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.

3147 {
3148 if (bufsize + 5 > bufcapacity) flush();
3149
3150 buffer[bufsize + 0] = d0;
3151 buffer[bufsize + 1] = d1;
3152 buffer[bufsize + 2] = d2;
3153 buffer[bufsize + 3] = d3;
3154 buffer[bufsize + 4] = d4;
3155 bufsize += 5;
3156 }

References bufcapacity, buffer, bufsize, and flush().

◆ write() [6/8]

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.

3159 {
3160 if (bufsize + 6 > bufcapacity) flush();
3161
3162 buffer[bufsize + 0] = d0;
3163 buffer[bufsize + 1] = d1;
3164 buffer[bufsize + 2] = d2;
3165 buffer[bufsize + 3] = d3;
3166 buffer[bufsize + 4] = d4;
3167 buffer[bufsize + 5] = d5;
3168 bufsize += 6;
3169 }

References bufcapacity, buffer, bufsize, and flush().

◆ write() [7/8]

void xml_buffered_writer::write ( const char_t *  data)
inline

Definition at line 3103 of file pugixml.cpp.

3104 {
3105 write(data, strlength(data));
3106 }
void write(const char_t *data, size_t length)
Definition pugixml.cpp:3062
PUGI__NS_END PUGI__NS_BEGIN PUGI__FN size_t strlength(const char_t *s)
Definition pugixml.cpp:176

References strlength(), and write().

◆ write() [8/8]

void xml_buffered_writer::write ( const char_t *  data,
size_t  length 
)
inline

Definition at line 3062 of file pugixml.cpp.

3063 {
3064 if (bufsize + length > bufcapacity)
3065 {
3066 // flush the remaining buffer contents
3067 flush();
3068
3069 // handle large chunks
3070 if (length > bufcapacity)
3071 {
3073 {
3074 // fast path, can just write data chunk
3075 writer.write(data, length * sizeof(char_t));
3076 return;
3077 }
3078
3079 // need to convert in suitable chunks
3080 while (length > bufcapacity)
3081 {
3082 // get chunk size by selecting such number of characters that are guaranteed to fit into scratch buffer
3083 // and form a complete codepoint sequence (i.e. discard start of last codepoint if necessary)
3084 size_t chunk_size = get_valid_length(data, bufcapacity);
3085
3086 // convert chunk and write
3087 flush(data, chunk_size);
3088
3089 // iterate
3090 data += chunk_size;
3091 length -= chunk_size;
3092 }
3093
3094 // small tail is copied below
3095 bufsize = 0;
3096 }
3097 }
3098
3099 memcpy(buffer + bufsize, data, length * sizeof(char_t));
3100 bufsize += length;
3101 }
PUGI__FN size_t get_valid_length(const char_t *data, size_t length)
Definition pugixml.cpp:2961

References bufcapacity, buffer, bufsize, encoding, 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().

Member Data Documentation

◆ buffer

char_t xml_buffered_writer::buffer[bufcapacity]

Definition at line 3186 of file pugixml.cpp.

Referenced by flush(), write(), write(), write(), write(), write(), write(), and write().

◆ bufsize

size_t xml_buffered_writer::bufsize

Definition at line 3197 of file pugixml.cpp.

Referenced by flush(), write(), write(), write(), write(), write(), write(), and write().

◆ data_char

char_t xml_buffered_writer::data_char[bufcapacity]

Definition at line 3193 of file pugixml.cpp.

◆ data_u16

uint16_t xml_buffered_writer::data_u16[2 *bufcapacity]

Definition at line 3191 of file pugixml.cpp.

◆ data_u32

uint32_t xml_buffered_writer::data_u32[bufcapacity]

Definition at line 3192 of file pugixml.cpp.

◆ data_u8

uint8_t xml_buffered_writer::data_u8[4 *bufcapacity]

Definition at line 3190 of file pugixml.cpp.

◆ encoding

xml_encoding xml_buffered_writer::encoding

Definition at line 3198 of file pugixml.cpp.

Referenced by flush(), and write().

◆ [union]

union { ... } xml_buffered_writer::scratch

Referenced by flush().

◆ writer

xml_writer& xml_buffered_writer::writer

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 Oct 14 2024 06:04:44 for QuickFIX by doxygen 1.9.8 written by Dimitri van Heesch, © 1997-2001