ReactOS 0.4.16-dev-822-gbcedb53
__crt_stdio_output::string_output_adapter< Character > Class Template Reference

#include <corecrt_internal_stdio_output.h>

Collaboration diagram for __crt_stdio_output::string_output_adapter< Character >:

Public Types

typedef __acrt_stdio_char_traits< Character > char_traits
 
typedef string_output_adapter_context< Character > context_type
 

Public Member Functions

 string_output_adapter (context_type *const context) throw ()
 
bool validate (__crt_cached_ptd_host &ptd) const throw ()
 
__forceinline bool write_character (Character const c, int *const count_written, __crt_cached_ptd_host &) const throw ()
 
void write_string (Character const *const string, int const length, int *const count_written, __crt_cached_ptd_host &ptd) const throw ()
 

Private Attributes

context_type_context
 

Detailed Description

template<typename Character>
class __crt_stdio_output::string_output_adapter< Character >

Definition at line 227 of file corecrt_internal_stdio_output.h.

Member Typedef Documentation

◆ char_traits

Definition at line 231 of file corecrt_internal_stdio_output.h.

◆ context_type

template<typename Character >
typedef string_output_adapter_context<Character> __crt_stdio_output::string_output_adapter< Character >::context_type

Definition at line 232 of file corecrt_internal_stdio_output.h.

Constructor & Destructor Documentation

◆ string_output_adapter()

template<typename Character >
__crt_stdio_output::string_output_adapter< Character >::string_output_adapter ( context_type *const  context)
throw (
)
inline

Member Function Documentation

◆ validate()

template<typename Character >
bool __crt_stdio_output::string_output_adapter< Character >::validate ( __crt_cached_ptd_host &  ptd) const
throw (
)
inline

Definition at line 239 of file corecrt_internal_stdio_output.h.

240 {
241 _UCRT_VALIDATE_RETURN(ptd, _context != nullptr, EINVAL, false);
242 return true;
243 }
#define EINVAL
Definition: acclib.h:90
#define _UCRT_VALIDATE_RETURN(ptd, expr, errorcode, retexpr)
_In_ size_t const _In_ int _In_ bool const _In_ unsigned const _In_ __acrt_rounding_mode const _Inout_ __crt_cached_ptd_host & ptd
Definition: cvt.cpp:355

◆ write_character()

template<typename Character >
__forceinline bool __crt_stdio_output::string_output_adapter< Character >::write_character ( Character const  c,
int *const  count_written,
__crt_cached_ptd_host &   
) const
throw (
)
inline

Definition at line 245 of file corecrt_internal_stdio_output.h.

246 {
248 {
250 {
251 ++*count_written;
252 }
253 else
254 {
255 *count_written = -1;
256 }
257
259 }
260
261 ++*count_written;
263 *_context->_buffer++ = c;
264 return true;
265 }
#define c
Definition: ke_i.h:80

◆ write_string()

template<typename Character >
void __crt_stdio_output::string_output_adapter< Character >::write_string ( Character const *const  string,
int const  length,
int *const  count_written,
__crt_cached_ptd_host &  ptd 
) const
throw (
)
inline

Definition at line 267 of file corecrt_internal_stdio_output.h.

273 {
274 // This function does not perform any operations that might reset errno,
275 // so we don't need to use __crt_errno_guard as we do in other output
276 // adapters.
278
279 if (length == 0)
280 {
281 return;
282 }
283
285 {
287 {
288 *count_written += length;
289 }
290 else
291 {
292 *count_written = -1;
293 }
294
295 return;
296 }
297
298 size_t const space_available = _context->_buffer_count - _context->_buffer_used;
299 size_t const elements_to_copy = __min(space_available, static_cast<size_t>(length));
300
301 // Performance note: This is hot code. Profiling has shown the extra
302 // validation done by memcpy_s to be quite expensive. The validation is
303 // unnecessary, so we call memcpy directly here:
304 memcpy(
306 string,
307 elements_to_copy * sizeof(Character));
308
309 _context->_buffer += elements_to_copy;
310 _context->_buffer_used += elements_to_copy;
311
313 {
314 *count_written += length;
315 }
316 else if (elements_to_copy != static_cast<size_t>(length))
317 {
318 *count_written = -1;
319 }
320 else
321 {
322 *count_written += static_cast<int>(elements_to_copy);
323 }
324 }
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
#define __min(a, b)
Definition: stdlib.h:102
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325

Member Data Documentation

◆ _context


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