ReactOS 0.4.16-dev-1007-g2e85425
__crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase > Class Template Reference

#include <corecrt_internal_stdio_output.h>

Inheritance diagram for __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >:
Collaboration diagram for __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >:

Public Types

using oad_base = typename ProcessorBase::output_adapter_data
 
using common_data_base = typename ProcessorBase::common_data_base
 
typedef __acrt_stdio_char_traits< Character > char_traits
 

Public Member Functions

 output_processor (OutputAdapter const &output_adapter, uint64_t const options, Character const *const format, __crt_cached_ptd_host &ptd, va_list const arglist) throw ()
 
int process () throw ()
 

Private Member Functions

__forceinline bool state_case_normal () throw ()
 
__forceinline bool state_case_normal_common () throw ()
 
__forceinline bool state_case_normal_tchar (char) throw ()
 
__forceinline bool state_case_normal_tchar (wchar_t) throw ()
 
__forceinline bool state_case_percent () throw ()
 
__forceinline bool state_case_flag () throw ()
 
bool parse_int_from_format_string (int *const result) throw ()
 
__forceinline bool state_case_width () throw ()
 
__forceinline bool state_case_dot () throw ()
 
__forceinline bool state_case_precision () throw ()
 
bool state_case_size () throw ()
 
bool state_case_type () throw ()
 
bool type_case_c () throw ()
 
bool type_case_c_tchar (char) throw ()
 
bool type_case_c_tchar (wchar_t) throw ()
 
bool type_case_Z () throw ()
 
bool type_case_s () throw ()
 
int type_case_s_compute_narrow_string_length (int const maximum_length, char) throw ()
 
int type_case_s_compute_narrow_string_length (int const maximum_length, wchar_t) throw ()
 
bool type_case_a () throw ()
 
bool type_case_d () throw ()
 
bool type_case_u () throw ()
 
bool type_case_o () throw ()
 
bool type_case_X () throw ()
 
bool type_case_x () throw ()
 
bool type_case_p () throw ()
 
template<unsigned Radix>
bool type_case_integer (bool const capital_hexits=false) throw ()
 
template<typename UnsignedInteger , unsigned Radix>
void type_case_integer_parse_into_buffer (UnsignedInteger number, bool const capital_hexits) throw ()
 
bool type_case_n () throw ()
 
__forceinline bool write_stored_string_tchar (char) throw ()
 
__forceinline bool write_stored_string_tchar (wchar_t) throw ()
 
bool has_flag (unsigned const f) const throw ()
 
void set_flag (unsigned const f) throw ()
 
void unset_flag (unsigned const f) throw ()
 
state find_next_state (Character const c, state const previous_state) const throw ()
 

Static Private Member Functions

static char __cdecl adjust_hexit (int const value, bool const capitalize) throw ()
 
static char *__cdecl narrow_null_string () throw ()
 
static wchar_t *__cdecl wide_null_string () throw ()
 

Detailed Description

template<typename Character, typename OutputAdapter, typename ProcessorBase>
class __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >

Definition at line 1697 of file corecrt_internal_stdio_output.h.

Member Typedef Documentation

◆ char_traits

template<typename Character , typename OutputAdapter , typename ProcessorBase >
typedef __acrt_stdio_char_traits<Character> __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::char_traits

Definition at line 1735 of file corecrt_internal_stdio_output.h.

◆ common_data_base

template<typename Character , typename OutputAdapter , typename ProcessorBase >
using __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::common_data_base = typename ProcessorBase::common_data_base

Definition at line 1716 of file corecrt_internal_stdio_output.h.

◆ oad_base

template<typename Character , typename OutputAdapter , typename ProcessorBase >
using __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::oad_base = typename ProcessorBase::output_adapter_data

Definition at line 1714 of file corecrt_internal_stdio_output.h.

Constructor & Destructor Documentation

◆ output_processor()

template<typename Character , typename OutputAdapter , typename ProcessorBase >
__crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::output_processor ( OutputAdapter const output_adapter,
uint64_t const  options,
Character const *const  format,
__crt_cached_ptd_host &  ptd,
va_list const  arglist 
)
throw (
)
inline

Definition at line 1737 of file corecrt_internal_stdio_output.h.

1744 : ProcessorBase{output_adapter, options, format, ptd, arglist}
1745 {
1746 }
_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
va_lists_t arglist[FMT_ARGMAX+1]
Definition: format.c:284
Definition: format.c:58

Member Function Documentation

◆ adjust_hexit()

template<typename Character , typename OutputAdapter , typename ProcessorBase >
static char __cdecl __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::adjust_hexit ( int const  value,
bool const  capitalize 
)
throw (
)
inlinestaticprivate

Definition at line 2884 of file corecrt_internal_stdio_output.h.

2885 {
2886 int const base {capitalize ? 'A' : 'a'};
2887 int const offset{base - '9' - 1 };
2888
2889 return static_cast<char>(offset + value);
2890 }
GLintptr offset
Definition: glext.h:5920
Definition: pdh_main.c:96

Referenced by __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::state_case_type(), and __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::type_case_integer_parse_into_buffer().

◆ find_next_state()

template<typename Character , typename OutputAdapter , typename ProcessorBase >
state __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::find_next_state ( Character const  c,
state const  previous_state 
) const
throw (
)
inlineprivate

Definition at line 2867 of file corecrt_internal_stdio_output.h.

2868 {
2869 auto const& lookup_table = state_transition_table();
2870
2871 unsigned const current_class = static_cast<unsigned>((c < ' ' || c > 'z')
2873 : static_cast<character_type>(lookup_table[c - ' '].current_class));
2874
2875 auto const index = current_class * state_count() + static_cast<unsigned>(previous_state);
2876 return static_cast<state>(lookup_table[index].next_state);
2877 }
#define index(s, c)
Definition: various.h:29
const GLubyte * c
Definition: glext.h:8905
GLuint index
Definition: glext.h:6031

Referenced by __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::process().

◆ has_flag()

◆ narrow_null_string()

template<typename Character , typename OutputAdapter , typename ProcessorBase >
static char *__cdecl __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::narrow_null_string ( )
throw (
)
inlinestaticprivate

◆ parse_int_from_format_string()

template<typename Character , typename OutputAdapter , typename ProcessorBase >
bool __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::parse_int_from_format_string ( int *const  result)
throw (
)
inlineprivate

Definition at line 1900 of file corecrt_internal_stdio_output.h.

1901 {
1902 auto const reset_errno = _ptd.get_errno().create_guard();
1903
1904 Character* end{};
1905 *result = static_cast<int>(_tcstol_internal(_ptd,
1906 _format_it - 1,
1907 &end,
1908 10));
1909
1910 if (_ptd.get_errno().check(ERANGE))
1911 {
1912 return false;
1913 }
1914
1915 if (end < _format_it)
1916 {
1917 return false;
1918 }
1919
1920 _format_it = end;
1921 return true;
1922 }
#define ERANGE
Definition: acclib.h:92
__forceinline long __cdecl _tcstol_internal(__crt_cached_ptd_host &ptd, Character const *const string, EndPointer const end, int const base)
GLuint GLuint end
Definition: gl.h:1545
GLuint64EXT * result
Definition: glext.h:11304

Referenced by __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::state_case_precision(), and __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::state_case_width().

◆ process()

template<typename Character , typename OutputAdapter , typename ProcessorBase >
int __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::process ( )
throw (
)
inline

Definition at line 1751 of file corecrt_internal_stdio_output.h.

1752 {
1753 if (!_output_adapter.validate(_ptd))
1754 {
1755 return -1;
1756 }
1757
1758 _UCRT_VALIDATE_RETURN(_ptd, _format_it != nullptr, EINVAL, -1);
1759
1760 while (advance_to_next_pass())
1761 {
1762 // At the start of each pass, we have no buffered string and we are
1763 // in the normal state:
1764 _string_length = 0;
1765 _state = state::normal;
1766
1767 // Iterate over the format string until we reach the end, encounter
1768 // an I/O error, or fail due to some other error:
1769 while ((_format_char = *_format_it++) != '\0' && _characters_written >= 0)
1770 {
1771 _state = find_next_state(_format_char, _state);
1772
1773 if (!validate_and_update_state_at_beginning_of_format_character())
1774 {
1775 return -1;
1776 }
1777
1778 if (_state >= state::invalid)
1779 {
1780 _UCRT_VALIDATE_RETURN(_ptd, ("Incorrect format specifier", 0), EINVAL, -1);
1781 }
1782
1783 bool result = false;
1784
1785 switch (_state)
1786 {
1787 case state::normal: result = state_case_normal (); break;
1788 case state::percent: result = state_case_percent (); break;
1789 case state::flag: result = state_case_flag (); break;
1790 case state::width: result = state_case_width (); break;
1791 case state::dot: result = state_case_dot (); break;
1793 case state::size: result = state_case_size (); break;
1794 case state::type: result = state_case_type (); break;
1795 }
1796
1797 // If the state-specific operation failed, return immediately.
1798 // The individual state cases are responsible for invoking the
1799 // invalid parameter handler if the failure is due to an invalid
1800 // parameter.
1801 if (!result)
1802 return -1;
1803 }
1804
1805 if (!validate_and_update_state_at_end_of_format_string())
1806 return -1;
1807 }
1808
1809 return _characters_written;
1810 }
#define EINVAL
Definition: acclib.h:90
state find_next_state(Character const c, state const previous_state) const
#define _UCRT_VALIDATE_RETURN(ptd, expr, errorcode, retexpr)

◆ set_flag()

◆ state_case_dot()

template<typename Character , typename OutputAdapter , typename ProcessorBase >
__forceinline bool __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::state_case_dot ( )
throw (
)
inlineprivate

Definition at line 1955 of file corecrt_internal_stdio_output.h.

1956 {
1957 // Reset the precision to zero. If the dot is not followed by a number,
1958 // it means a precision of zero, not the default precision (per the C
1959 // Standard Library specification). (Note: We represent the default
1960 // precision with -1.)
1961 _precision = 0;
1962
1963 return true;
1964 }

Referenced by __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::process().

◆ state_case_flag()

template<typename Character , typename OutputAdapter , typename ProcessorBase >
__forceinline bool __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::state_case_flag ( )
throw (
)
inlineprivate

Definition at line 1880 of file corecrt_internal_stdio_output.h.

1881 {
1882 // Set the flag based on which flag character:
1883 switch (_format_char)
1884 {
1885 case '-': set_flag(FL_LEFT ); break; // '-' => left justify
1886 case '+': set_flag(FL_SIGN ); break; // '+' => force sign indicator
1887 case ' ': set_flag(FL_SIGNSP ); break; // ' ' => force sign or space
1888 case '#': set_flag(FL_ALTERNATE); break; // '#' => alternate form
1889 case '0': set_flag(FL_LEADZERO ); break; // '0' => pad with leading zeros
1890 }
1891
1892 return true;
1893 }

Referenced by __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::process().

◆ state_case_normal()

template<typename Character , typename OutputAdapter , typename ProcessorBase >
__forceinline bool __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::state_case_normal ( )
throw (
)
inlineprivate

Definition at line 1821 of file corecrt_internal_stdio_output.h.

1822 {
1823 if (should_skip_normal_state_processing())
1824 return true;
1825
1827
1828 return true;
1829 }

Referenced by __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::process().

◆ state_case_normal_common()

template<typename Character , typename OutputAdapter , typename ProcessorBase >
__forceinline bool __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::state_case_normal_common ( )
throw (
)
inlineprivate

Definition at line 1831 of file corecrt_internal_stdio_output.h.

1832 {
1833 if (!state_case_normal_tchar(Character()))
1834 return false;
1835
1836 _output_adapter.write_character(_format_char, &_characters_written, _ptd);
1837 return true;
1838 }

Referenced by __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::state_case_normal().

◆ state_case_normal_tchar() [1/2]

template<typename Character , typename OutputAdapter , typename ProcessorBase >
__forceinline bool __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::state_case_normal_tchar ( char  )
throw (
)
inlineprivate

Definition at line 1840 of file corecrt_internal_stdio_output.h.

1841 {
1842 _string_is_wide = false;
1843
1844 if (__acrt_isleadbyte_l_noupdate(_format_char, _ptd.get_locale()))
1845 {
1846 _output_adapter.write_character(_format_char, &_characters_written, _ptd);
1847 _format_char = *_format_it++;
1848
1849 // Ensure that we do not fall off the end of the format string:
1850 _UCRT_VALIDATE_RETURN(_ptd, _format_char != '\0', EINVAL, false);
1851 }
1852
1853 return true;
1854 }
__inline int __CRTDECL __acrt_isleadbyte_l_noupdate(_In_ int const c, _In_ _locale_t const locale)

Referenced by __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::state_case_normal_common().

◆ state_case_normal_tchar() [2/2]

template<typename Character , typename OutputAdapter , typename ProcessorBase >
__forceinline bool __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::state_case_normal_tchar ( wchar_t  )
throw (
)
inlineprivate

Definition at line 1856 of file corecrt_internal_stdio_output.h.

1857 {
1858 _string_is_wide = true;
1859 return true;
1860 }

◆ state_case_percent()

template<typename Character , typename OutputAdapter , typename ProcessorBase >
__forceinline bool __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::state_case_percent ( )
throw (
)
inlineprivate

Definition at line 1865 of file corecrt_internal_stdio_output.h.

1866 {
1867 _field_width = 0;
1868 _suppress_output = false;
1869 _flags = 0;
1870 _precision = -1;
1871 _length = length_modifier::none;
1872 _string_is_wide = false;
1873
1874 return true;
1875 }

Referenced by __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::process().

◆ state_case_precision()

template<typename Character , typename OutputAdapter , typename ProcessorBase >
__forceinline bool __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::state_case_precision ( )
throw (
)
inlineprivate

Definition at line 1969 of file corecrt_internal_stdio_output.h.

1970 {
1971 if (_format_char != '*')
1972 {
1973 return parse_int_from_format_string(&_precision);
1974 }
1975
1976 // If the format character is an asterisk, we read the width from the
1977 // varargs. If we read a negative value, we treat it as indicating the
1978 // default precision.
1979 if (!update_precision())
1980 return false;
1981
1982 if (!should_format())
1983 return true;
1984
1985 if (_precision < 0)
1986 _precision = -1;
1987
1988 return true;
1989 }

Referenced by __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::process().

◆ state_case_size()

template<typename Character , typename OutputAdapter , typename ProcessorBase >
bool __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::state_case_size ( )
throw (
)
inlineprivate

Definition at line 1993 of file corecrt_internal_stdio_output.h.

1994 {
1995 if (_format_char == 'F')
1996 {
1997 // We hand the 'F' character as a length modifier because the length
1998 // modifier occurs before the type specifier. If we find an 'F' and
1999 // we are in the legacy compatibility mode that supports the 'F' length
2000 // modifier, we just ignore it (it has no meaning). Otherwise we are
2001 // not in compatibility mode so we switch out to the type case to handle
2002 // the 'F' as a %F format specifier:
2004 {
2005 _state = state::type;
2006 return state_case_type();
2007 }
2008
2009 return true;
2010 }
2011
2012 if (_format_char == 'N')
2013 {
2014 // If we find an 'N' and we are in the legacy compatibility mode that
2015 // supports the 'N' length modifier, we just ignore it (it has no
2016 // meaning). Otherwise, we are not in compatibility mode, so we
2017 // invoke the invalid parameter handler and return failure.
2019 {
2020 _state = state::invalid;
2021#pragma warning(suppress: __WARNING_IGNOREDBYCOMMA) // 6319 comma operator
2022 _UCRT_VALIDATE_RETURN(_ptd, ("N length modifier not specifier", false), EINVAL, false);
2023 return false;
2024 }
2025
2026 return true;
2027 }
2028
2029 _UCRT_VALIDATE_RETURN(_ptd, _length == length_modifier::none, EINVAL, false);
2030
2031 // We just read a size specifier; set the flags based on it:
2032 switch (_format_char)
2033 {
2034 case 'h':
2035 {
2036 if (*_format_it == 'h')
2037 {
2038 ++_format_it;
2039 _length = length_modifier::hh;
2040 }
2041 else
2042 {
2043 _length = length_modifier::h;
2044 }
2045
2046 return true;
2047 }
2048
2049 case 'I':
2050 {
2051 // The I32, I64, and I length modifiers are Microsoft extensions.
2052
2053 if (*_format_it == '3' && *(_format_it + 1) == '2')
2054 {
2055 _format_it += 2;
2056 _length = length_modifier::I32;
2057 }
2058 else if (*_format_it == '6' && *(_format_it + 1) == '4')
2059 {
2060 _format_it += 2;
2061 _length = length_modifier::I64;
2062 }
2063 else if (*_format_it == 'd' ||
2064 *_format_it == 'i' ||
2065 *_format_it == 'o' ||
2066 *_format_it == 'u' ||
2067 *_format_it == 'x' ||
2068 *_format_it == 'X')
2069 {
2070 // If we support positional parameters, then %I without a following
2071 // 32 or 64 is platform-dependent:
2072 _length = length_modifier::I;
2073 }
2074
2075 return true;
2076 }
2077
2078 case 'l':
2079 {
2080 if (*_format_it == 'l')
2081 {
2082 ++_format_it;
2083 _length = length_modifier::ll;
2084 }
2085 else
2086 {
2087 _length = length_modifier::l;
2088 }
2089
2090 return true;
2091 }
2092
2093 case 'L':
2094 {
2095 _length = length_modifier::L;
2096 return true;
2097 }
2098
2099 case 'j':
2100 {
2101 _length = length_modifier::j;
2102 return true;
2103 }
2104
2105 case 't':
2106 {
2107 _length = length_modifier::t;
2108 return true;
2109 }
2110
2111 case 'z':
2112 {
2113 _length = length_modifier::z;
2114 return true;
2115 }
2116
2117 case 'w':
2118 {
2119 _length = length_modifier::w;
2120 return true;
2121 }
2122
2123 case 'T':
2124 {
2125 _length = length_modifier::T;
2126 return true;
2127 }
2128 }
2129
2130 return true;
2131 }
#define _CRT_INTERNAL_PRINTF_LEGACY_MSVCRT_COMPATIBILITY

Referenced by __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::process().

◆ state_case_type()

template<typename Character , typename OutputAdapter , typename ProcessorBase >
bool __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::state_case_type ( )
throw (
)
inlineprivate

Definition at line 2137 of file corecrt_internal_stdio_output.h.

2138 {
2139 // Each of the subfunctions is responsible for [1] extracting the next
2140 // argument from the varargs, [2] formatting that argument into the
2141 // internal buffer, and [3] updating the string state variables with
2142 // the correct data for the format operation (either _narrow_string or
2143 // _wide_string must be set correctly, the _string_length must be set
2144 // correctly, and _string_is_wide must be true if the wide string
2145 // should be used.
2146 bool result{false};
2147 switch (_format_char)
2148 {
2149 // Individual character output:
2150 case 'C':
2151 case 'c': result = type_case_c(); break;
2152
2153 // String output:
2154 case 'Z': result = type_case_Z(); break;
2155 case 'S':
2156 case 's': result = type_case_s(); break;
2157
2158 // Floating-point output:
2159 case 'A':
2160 case 'E':
2161 case 'F':
2162 case 'G':
2163 case 'a':
2164 case 'e':
2165 case 'f':
2166 case 'g': result = type_case_a(); break;
2167
2168 // Integer and pointer output:
2169 case 'd':
2170 case 'i': result = type_case_d(); break;
2171 case 'u': result = type_case_u(); break;
2172 case 'o': result = type_case_o(); break;
2173 case 'X': result = type_case_X(); break;
2174 case 'x': result = type_case_x(); break;
2175 case 'p': result = type_case_p(); break;
2176
2177 // State reporting (no output):
2178 case 'n': result = type_case_n(); break;
2179 }
2180
2181 // If the case-specific logic failed, return immediately. The case-
2182 // specific function is responsible for invoking the invalid parameter
2183 // handler if it needs to do so.
2184 if (!result)
2185 return false;
2186
2187 // Check to see whether the output operation should be skipped (we skip
2188 // the output part e.g. during the positional scan pass when positional
2189 // formatting is used).
2190 if (should_skip_type_state_output())
2191 return true;
2192
2193 // At this point, we've completed the bulk of the formatting operation
2194 // and the string is ready to be printed. We now justify the string,
2195 // pre-pend any required prefix and leading zeroes, then print it. Well,
2196 // unless output is suppressed, that is... :-)
2197 if (_suppress_output)
2198 return true;
2199
2200 // Compute the prefix, if one is required...
2201 Character prefix[3]{};
2202 size_t prefix_length{0};
2203
2204 if (has_flag(FL_SIGNED))
2205 {
2206 if (has_flag(FL_NEGATIVE))
2207 {
2208 prefix[prefix_length++] = '-';
2209 }
2210 else if (has_flag(FL_SIGN))
2211 {
2212 prefix[prefix_length++] = '+';
2213 }
2214 else if (has_flag(FL_SIGNSP))
2215 {
2216 prefix[prefix_length++] = ' ';
2217 }
2218 }
2219
2220 bool const print_integer_0x{(_format_char == 'x' || _format_char == 'X') && has_flag(FL_ALTERNATE)};
2221 bool const print_floating_point_0x{_format_char == 'a' || _format_char == 'A'};
2222
2223 if (print_integer_0x || print_floating_point_0x)
2224 {
2225 prefix[prefix_length++] = '0';
2226 prefix[prefix_length++] = adjust_hexit('x' - 'a' + '9' + 1, _format_char == 'X' || _format_char == 'A');
2227 }
2228
2229 // Compute the amount of padding required to get to the desired field
2230 // width, then output the left padding, prefix, leading zeroes, the
2231 // string, and right padding, in that order.
2232 int const padding = static_cast<int>(_field_width - _string_length - prefix_length);
2233
2235 {
2236 // Left-pad with spaces
2237 write_multiple_characters(_output_adapter, ' ', padding, &_characters_written, _ptd);
2238 }
2239
2240 // Write the prefix
2241 _output_adapter.write_string(prefix, static_cast<int>(prefix_length), &_characters_written, _ptd);
2242
2244 {
2245 // Write leading zeroes
2246 write_multiple_characters(_output_adapter, '0', padding, &_characters_written, _ptd);
2247 }
2248
2249 // Write the string
2250 write_stored_string_tchar(Character());
2251
2252 if (_characters_written >= 0 && has_flag(FL_LEFT))
2253 {
2254 // Right-pad with spaces
2255 write_multiple_characters(_output_adapter, ' ', padding, &_characters_written, _ptd);
2256 }
2257
2258 return true;
2259 }
static char __cdecl adjust_hexit(int const value, bool const capitalize)
static const DWORD padding[]
Definition: mciwnd.c:89
__forceinline void write_multiple_characters(OutputAdapter const &adapter, Character const c, int const count, int *const count_written, __crt_cached_ptd_host &ptd)
Character const *const prefix
Definition: tempnam.cpp:195

Referenced by __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::process(), and __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::state_case_size().

◆ state_case_width()

template<typename Character , typename OutputAdapter , typename ProcessorBase >
__forceinline bool __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::state_case_width ( )
throw (
)
inlineprivate

Definition at line 1928 of file corecrt_internal_stdio_output.h.

1929 {
1930 if (_format_char != '*')
1931 {
1932 return parse_int_from_format_string(&_field_width);
1933 }
1934
1935 // If the format character is an asterisk, we read the width from the
1936 // varargs. If we read a negative value, we treat it as the '-' flag
1937 // followed by a positive width (per the C Standard Library spec).
1938 if (!update_field_width())
1939 return false;
1940
1941 if (!should_format())
1942 return true;
1943
1944 if (_field_width < 0)
1945 {
1947 _field_width = -_field_width;
1948 }
1949
1950 return true;
1951 }

Referenced by __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::process().

◆ type_case_a()

template<typename Character , typename OutputAdapter , typename ProcessorBase >
bool __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::type_case_a ( )
throw (
)
inlineprivate

Definition at line 2468 of file corecrt_internal_stdio_output.h.

2469 {
2470 // The double type is signed:
2472
2473 if (!validate_state_for_type_case_a())
2474 return false;
2475
2476 if (!should_format())
2477 return true;
2478
2479 // First, we need to compute the actual precision to use, limited by
2480 // both the maximum precision and the size of the buffer that we can
2481 // allocate.
2482 if (_precision < 0)
2483 {
2484 // The default precision depends on the format specifier used. For
2485 // %e, %f, and %g, C specifies that the default precision is 6. For
2486 // %a, C specifies that "if the precision is missing and FLT_RADIX
2487 // is a power of 2, then the precision is sufficient for an exact
2488 // representation of the value" (C11 7.21.6.1/8).
2489 //
2490 // The 64-bit double has 53 bits of precision. When printing in
2491 // hexadecimal form, we print one bit of precision to the left of the
2492 // radix point and the remaining 52 bits of precision to the right.
2493 // Thus, the default precision is 13 (13 * 4 == 52).
2494 if (_format_char == 'a' || _format_char == 'A')
2495 {
2496 _precision = 13;
2497 }
2498 else
2499 {
2500 _precision = 6;
2501 }
2502 }
2503 else if (_precision == 0 && (_format_char == 'g' || _format_char == 'G'))
2504 {
2505 _precision = 1; // Per C Standard Library specification.
2506 }
2507
2508 if (!_buffer.template ensure_buffer_is_big_enough<char>(_CVTBUFSIZE + _precision, _ptd))
2509 {
2510 // If we fail to enlarge the buffer, cap precision so that the
2511 // statically-sized buffer may be used for the formatting:
2512 _precision = static_cast<int>(_buffer.template count<char>() - _CVTBUFSIZE);
2513 }
2514
2515 _narrow_string = _buffer.template data<char>();
2516
2517 // Note that we separately handle the FORMAT_POSSCAN_PASS above.
2518 _CRT_DOUBLE tmp{};
2519 if (!this->template extract_argument_from_va_list<_CRT_DOUBLE>(tmp))
2520 {
2521 return false;
2522 }
2523
2524 // Format the number into the buffer:
2526 &tmp.x,
2527 _buffer.template data<char>(),
2528 _buffer.template count<char>(),
2529 _buffer.template scratch_data<char>(),
2530 _buffer.template scratch_count<char>(),
2531 static_cast<char>(_format_char),
2532 _precision,
2533 _options,
2534 __acrt_rounding_mode::standard,
2535 _ptd);
2536
2537 // If the precision is zero but the '#' flag is part of the specifier,
2538 // we force a decimal point:
2539 if (has_flag(FL_ALTERNATE) && _precision == 0)
2540 {
2541 force_decimal_point(_narrow_string, _ptd.get_locale());
2542 }
2543
2544 // The 'g' format specifier indicates that zeroes should be cropped
2545 // unless the '#' flag is part of the specifier.
2546 if ((_format_char == 'g' || _format_char == 'G') && !has_flag(FL_ALTERNATE))
2547 {
2548 crop_zeroes(_narrow_string, _ptd.get_locale());
2549 }
2550
2551 // If the result was negative, we save the '-' for later and advance past
2552 // the negative sign (we handle the '-' separately, in code shared with
2553 // the integer formatting, to correctly handle flags).
2554 if (*_narrow_string == '-')
2555 {
2557 ++_narrow_string;
2558 }
2559
2560 // If the result was a special infinity or a nan string, suppress output
2561 // of the "0x" prefix by treating the special string as just a string:
2562 if (*_narrow_string == 'i' || *_narrow_string == 'I' ||
2563 *_narrow_string == 'n' || *_narrow_string == 'N')
2564 {
2565 unset_flag(FL_LEADZERO); // padded with spaces, not zeros.
2566 _format_char = 's';
2567 }
2568
2569 _string_length = static_cast<int>(strlen(_narrow_string));
2570
2571 return true;
2572 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
errno_t __cdecl __acrt_fp_format(double const *const value, char *const result_buffer, size_t const result_buffer_count, char *const scratch_buffer, size_t const scratch_buffer_count, int const format, int const precision, uint64_t const options, __acrt_rounding_mode rounding_mode, __crt_cached_ptd_host &ptd)
Definition: cvt.cpp:786
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define _CVTBUFSIZE
Definition: stdlib.h:1050
void __cdecl crop_zeroes(_Inout_z_ char *buffer, _locale_t const locale)
void __cdecl force_decimal_point(_Inout_z_ char *buffer, _locale_t const locale)

Referenced by __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::state_case_type().

◆ type_case_c()

template<typename Character , typename OutputAdapter , typename ProcessorBase >
bool __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::type_case_c ( )
throw (
)
inlineprivate

◆ type_case_c_tchar() [1/2]

template<typename Character , typename OutputAdapter , typename ProcessorBase >
bool __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::type_case_c_tchar ( char  )
throw (
)
inlineprivate

Definition at line 2270 of file corecrt_internal_stdio_output.h.

2271 {
2272 // If the character is a wide character, we translate it to multibyte
2273 // to be output, storing the multibyte string in the internal buffer:
2274 if (is_wide_character_specifier(_options, _format_char, _length))
2275 {
2276 wchar_t wide_character{};
2277 if (!this->template extract_argument_from_va_list<wchar_t>(wide_character))
2278 {
2279 return false;
2280 }
2281
2282 if (!should_format())
2283 {
2284 return true;
2285 }
2286
2287 // Convert to multibyte. If the conversion fails, we suppress the
2288 // output operation but we do not fail the entire operation:
2289 errno_t const status{_wctomb_internal(&_string_length, _buffer.template data<char>(), _buffer.template count<char>(), wide_character, _ptd)};
2290 if (status != 0)
2291 {
2292 _suppress_output = true;
2293 }
2294 }
2295 // If the character is a narrow character, we can just write it directly
2296 // to the output, as-is.
2297 else
2298 {
2299 if (!this->template extract_argument_from_va_list<unsigned short>(_buffer.template data<char>()[0]))
2300 {
2301 return false;
2302 }
2303
2304 if (!should_format())
2305 {
2306 return true;
2307 }
2308
2309 _string_length = 1;
2310 }
2311
2312 _narrow_string = _buffer.template data<char>();
2313 return true;
2314 }
bool __cdecl is_wide_character_specifier(uint64_t const options, Character const format_type, length_modifier const length)
Definition: ps.c:97
int errno_t
Definition: corecrt.h:615
int __cdecl _wctomb_internal(int *const return_value, char *const destination, size_t const destination_count, wchar_t const wchar, __crt_cached_ptd_host &ptd)
Definition: wctomb.cpp:30

Referenced by __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::type_case_c().

◆ type_case_c_tchar() [2/2]

template<typename Character , typename OutputAdapter , typename ProcessorBase >
bool __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::type_case_c_tchar ( wchar_t  )
throw (
)
inlineprivate

Definition at line 2316 of file corecrt_internal_stdio_output.h.

2317 {
2318 // If the output adapter accepts wide characters, then we must transform
2319 // the character into a wide character to be output.
2320 _string_is_wide = true;
2321
2322 wchar_t wide_character{};
2323 if (!this->template extract_argument_from_va_list<wchar_t>(wide_character))
2324 return false;
2325
2326 if (!should_format())
2327 return true;
2328
2329 if (!is_wide_character_specifier(_options, _format_char, _length))
2330 {
2331 // If the character is actually a multibyte character, then we must
2332 // transform it into the equivalent wide character. If the translation
2333 // is unsuccessful, we ignore this character but do not fail the entire
2334 // output operation.
2335 char const local_buffer[2]{ static_cast<char>(wide_character & 0x00ff), '\0' };
2336 int const mbc_length{_mbtowc_internal(
2337 _buffer.template data<wchar_t>(),
2338 local_buffer,
2339 _ptd.get_locale()->locinfo->_public._locale_mb_cur_max,
2340 _ptd
2341 )};
2342 if (mbc_length < 0)
2343 {
2344 _suppress_output = true;
2345 }
2346 }
2347 else
2348 {
2349 _buffer.template data<wchar_t>()[0] = wide_character;
2350 }
2351
2352 _wide_string = _buffer.template data<wchar_t>();
2353 _string_length = 1;
2354 return true;
2355 }
int __cdecl _mbtowc_internal(wchar_t *pwc, const char *s, size_t n, __crt_cached_ptd_host &ptd)
Definition: mbtowc.cpp:45

◆ type_case_d()

template<typename Character , typename OutputAdapter , typename ProcessorBase >
bool __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::type_case_d ( )
throw (
)
inlineprivate

Definition at line 2578 of file corecrt_internal_stdio_output.h.

2579 {
2581
2582 return type_case_integer<10>();
2583 }

Referenced by __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::state_case_type().

◆ type_case_integer()

template<typename Character , typename OutputAdapter , typename ProcessorBase >
template<unsigned Radix>
bool __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::type_case_integer ( bool const  capital_hexits = false)
throw (
)
inlineprivate

Definition at line 2631 of file corecrt_internal_stdio_output.h.

2632 {
2633 size_t const integer_size = to_integer_size(_length);
2634
2635 // First, extract the argument of the required type from the varargs:
2636 __int64 original_number {};
2637 bool extraction_result{};
2638 switch (integer_size)
2639 {
2640 case sizeof(int8_t):
2641 extraction_result = has_flag(FL_SIGNED)
2642 ? this->template extract_argument_from_va_list<int8_t >(original_number)
2643 : this->template extract_argument_from_va_list<uint8_t>(original_number);
2644 break;
2645 case sizeof(int16_t):
2646 extraction_result = has_flag(FL_SIGNED)
2647 ? this->template extract_argument_from_va_list<int16_t >(original_number)
2648 : this->template extract_argument_from_va_list<uint16_t>(original_number);
2649 break;
2650 case sizeof(int32_t):
2651 extraction_result = has_flag(FL_SIGNED)
2652 ? this->template extract_argument_from_va_list<int32_t >(original_number)
2653 : this->template extract_argument_from_va_list<uint32_t>(original_number);
2654 break;
2655 case sizeof(int64_t):
2656 extraction_result = has_flag(FL_SIGNED)
2657 ? this->template extract_argument_from_va_list<int64_t >(original_number)
2658 : this->template extract_argument_from_va_list<uint64_t>(original_number);
2659 break;
2660 default:
2661 _UCRT_VALIDATE_RETURN(_ptd, ("Invalid integer length modifier", 0), EINVAL, false);
2662 break;
2663 }
2664
2665 if (!extraction_result)
2666 return false;
2667
2668 // If we're not formatting, then we're done; we just needed to read the
2669 // argument from the varargs.
2670 if (!should_format())
2671 return true;
2672
2673 // Check the sign of the number. If it is negative, convert it to
2674 // positive for formatting. We'll handle the minus sign later (after
2675 // we return from this function).
2676 unsigned __int64 number{};
2677
2678 if (has_flag(FL_SIGNED) && original_number < 0)
2679 {
2680 number = static_cast<unsigned __int64>(-original_number);
2682 }
2683 else
2684 {
2685 number = static_cast<unsigned __int64>(original_number);
2686 }
2687
2688 // Check the precision to see if the default precision was specified. If
2689 // a non-default precision was specified, we turn off the zero flag, per
2690 // the C Standard Library specification.
2691 if (_precision < 0)
2692 {
2693 _precision = 1; // Default precision
2694 }
2695 else
2696 {
2698 _buffer.template ensure_buffer_is_big_enough<Character>(_precision, _ptd);
2699 }
2700
2701 // If the number is zero, we do not want to print the hex prefix ("0x"),
2702 // even if it was requested:
2703 if (number == 0)
2704 {
2706 }
2707
2708 _string_is_wide = sizeof(Character) == sizeof(wchar_t);
2709
2710 if (integer_size == sizeof(int64_t))
2711 {
2712 type_case_integer_parse_into_buffer<uint64_t, Radix>(number, capital_hexits);
2713 }
2714 else
2715 {
2716 type_case_integer_parse_into_buffer<uint32_t, Radix>(static_cast<uint32_t>(number), capital_hexits);
2717 }
2718
2719 // If the FORCEOCTAL flag is set, then we output a leading zero, unless
2720 // the formatted string already has a leading zero:
2721 if (has_flag(FL_FORCEOCTAL) && (_string_length == 0 || tchar_string()[0] != '0'))
2722 {
2723 *--tchar_string() = '0';
2724 ++_string_length;
2725 }
2726
2727 return true;
2728 }
unsigned short int uint16_t
Definition: acefiex.h:54
signed char int8_t
Definition: acefiex.h:50
#define __int64
Definition: basetyps.h:16
UINT32 uint32_t
Definition: types.h:75
UINT64 uint64_t
Definition: types.h:77
INT64 int64_t
Definition: types.h:72
const UINT template
Definition: action.c:7511
static unsigned int number
Definition: dsound.c:1479
BYTE uint8_t
Definition: msvideo1.c:66
size_t __cdecl to_integer_size(length_modifier const length)
#define int32_t
Definition: nsiface.idl:56
#define int64_t
Definition: nsiface.idl:57
#define int16_t
Definition: nsiface.idl:55

◆ type_case_integer_parse_into_buffer()

template<typename Character , typename OutputAdapter , typename ProcessorBase >
template<typename UnsignedInteger , unsigned Radix>
void __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::type_case_integer_parse_into_buffer ( UnsignedInteger  number,
bool const  capital_hexits 
)
throw (
)
inlineprivate

Definition at line 2735 of file corecrt_internal_stdio_output.h.

2739 {
2740 // Format the number into the formatting buffer. Note that we format the
2741 // buffer at the end of the formatting buffer, which allows us to perform
2742 // the formatting from least to greatest magnitude, which maps well to
2743 // the math.
2744 Character* const last_digit{_buffer.template data<Character>() + _buffer.template count<Character>() - 1};
2745
2746 Character*& string_pointer = tchar_string();
2747
2748 string_pointer = last_digit;
2749 while (_precision > 0 || number != 0)
2750 {
2751 --_precision;
2752
2753 Character digit{static_cast<Character>(number % Radix + '0')};
2754 number /= Radix;
2755
2756 // If the digit is greater than 9, we need to convert it to the
2757 // corresponding letter hexit in the required case:
2758 if (digit > '9')
2759 {
2760 digit = adjust_hexit(digit, capital_hexits);
2761 }
2762
2763 *string_pointer-- = static_cast<char>(digit);
2764 }
2765
2766 _string_length = static_cast<int>(last_digit - string_pointer);
2767 ++string_pointer;
2768 }

◆ type_case_n()

template<typename Character , typename OutputAdapter , typename ProcessorBase >
bool __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::type_case_n ( )
throw (
)
inlineprivate

Definition at line 2773 of file corecrt_internal_stdio_output.h.

2774 {
2775 void* p{nullptr};
2776 if (!this->template extract_argument_from_va_list<void*>(p))
2777 return false;
2778
2779 if (!should_format())
2780 return true;
2781
2783 {
2784 _UCRT_VALIDATE_RETURN(_ptd, ("'n' format specifier disabled", 0), EINVAL, false);
2785 return false; // Unreachable
2786 }
2787
2788 switch (to_integer_size(_length))
2789 {
2790 case sizeof(int8_t): *static_cast<int8_t *>(p) = static_cast<int8_t >(_characters_written); break;
2791 case sizeof(int16_t): *static_cast<int16_t*>(p) = static_cast<int16_t>(_characters_written); break;
2792 case sizeof(int32_t): *static_cast<int32_t*>(p) = static_cast<int32_t>(_characters_written); break;
2793 case sizeof(int64_t): *static_cast<int64_t*>(p) = static_cast<int64_t>(_characters_written); break;
2794 default: _UCRT_VALIDATE_RETURN(_ptd, ("Invalid integer length modifier", 0), EINVAL, false); break;
2795 }
2796
2797 // This format specifier never corresponds to an output operation:
2798 _suppress_output = true;
2799 return true;
2800 }
INT32 int32_t
Definition: types.h:71
INT16 int16_t
Definition: types.h:70
GLfloat GLfloat p
Definition: glext.h:8902
_CRTIMP int __cdecl _get_printf_count_output(void)
Definition: stubs.c:5

Referenced by __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::state_case_type().

◆ type_case_o()

template<typename Character , typename OutputAdapter , typename ProcessorBase >
bool __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::type_case_o ( )
throw (
)
inlineprivate

Definition at line 2590 of file corecrt_internal_stdio_output.h.

2591 {
2592 // If the alternate flag is set, we force a leading 0:
2595
2596 return type_case_integer<8>();
2597 }

Referenced by __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::state_case_type().

◆ type_case_p()

template<typename Character , typename OutputAdapter , typename ProcessorBase >
bool __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::type_case_p ( )
throw (
)
inlineprivate

Definition at line 2611 of file corecrt_internal_stdio_output.h.

2612 {
2613 // We force the precision to be 2 * sizeof(void*), which is the number
2614 // of hexits required to represent the pointer, so that it is zero-
2615 // padded.
2616 _precision = 2 * sizeof(void*);
2617
2618 // Ensure that we read a 32-bit integer on 32-bit architectures, and
2619 // a 64-bit integer on 64-bit platforms:
2620 _length = sizeof(void*) == 4
2623
2624 return type_case_integer<16>(true);
2625 }

Referenced by __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::state_case_type().

◆ type_case_s()

template<typename Character , typename OutputAdapter , typename ProcessorBase >
bool __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::type_case_s ( )
throw (
)
inlineprivate

Definition at line 2402 of file corecrt_internal_stdio_output.h.

2403 {
2404 // If this format specifier has the default precision, then the entire
2405 // string is output. If a precision is given, then we output the minimum
2406 // of the length of the C string and the given precision. Note that the
2407 // string needs not be null-terminated if a precision is given, so we
2408 // cannot call strlen to compute the length of the string.
2409 if (!this->template extract_argument_from_va_list<char*>(_narrow_string))
2410 return false;
2411
2412 if (!should_format())
2413 return true;
2414
2415 int const maximum_length{(_precision == -1) ? INT_MAX : _precision};
2416
2417 if (is_wide_character_specifier(_options, _format_char, _length))
2418 {
2419 if (!_wide_string)
2420 _wide_string = wide_null_string();
2421
2422 _string_is_wide = true;
2423 _string_length = static_cast<int>(wcsnlen(_wide_string, maximum_length));
2424 }
2425 else
2426 {
2427 if (!_narrow_string)
2428 _narrow_string = narrow_null_string();
2429
2430 _string_length = type_case_s_compute_narrow_string_length(maximum_length, Character());
2431 }
2432
2433 return true;
2434 }
int type_case_s_compute_narrow_string_length(int const maximum_length, char)
#define INT_MAX
Definition: intsafe.h:150
size_t __cdecl wcsnlen(wchar_t const *const string, size_t const maximum_count)
Definition: strnlen.cpp:210

Referenced by __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::state_case_type().

◆ type_case_s_compute_narrow_string_length() [1/2]

template<typename Character , typename OutputAdapter , typename ProcessorBase >
int __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::type_case_s_compute_narrow_string_length ( int const  maximum_length,
char   
)
throw (
)
inlineprivate

Definition at line 2441 of file corecrt_internal_stdio_output.h.

2442 {
2443 return static_cast<int>(strnlen(_narrow_string, maximum_length));
2444 }
size_t __cdecl strnlen(char const *const string, size_t const maximum_count)
Definition: strnlen.cpp:202

Referenced by __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::type_case_s().

◆ type_case_s_compute_narrow_string_length() [2/2]

template<typename Character , typename OutputAdapter , typename ProcessorBase >
int __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::type_case_s_compute_narrow_string_length ( int const  maximum_length,
wchar_t   
)
throw (
)
inlineprivate

Definition at line 2446 of file corecrt_internal_stdio_output.h.

2447 {
2448 _locale_t locale = _ptd.get_locale();
2449 int string_length{0};
2450
2451 for (char const* p{_narrow_string}; string_length < maximum_length && *p; ++string_length)
2452 {
2453 if (__acrt_isleadbyte_l_noupdate(static_cast<unsigned char>(*p), locale))
2454 {
2455 ++p;
2456 }
2457
2458 ++p;
2459 }
2460
2461 return string_length;
2462 }
Definition: _locale.h:75

◆ type_case_u()

template<typename Character , typename OutputAdapter , typename ProcessorBase >
bool __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::type_case_u ( )
throw (
)
inlineprivate

Definition at line 2585 of file corecrt_internal_stdio_output.h.

2586 {
2587 return type_case_integer<10>();
2588 }

Referenced by __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::state_case_type().

◆ type_case_X()

template<typename Character , typename OutputAdapter , typename ProcessorBase >
bool __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::type_case_X ( )
throw (
)
inlineprivate

Definition at line 2599 of file corecrt_internal_stdio_output.h.

2600 {
2601 return type_case_integer<16>(true);
2602 }

Referenced by __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::state_case_type().

◆ type_case_x()

template<typename Character , typename OutputAdapter , typename ProcessorBase >
bool __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::type_case_x ( )
throw (
)
inlineprivate

Definition at line 2604 of file corecrt_internal_stdio_output.h.

2605 {
2606 return type_case_integer<16>();
2607 }

Referenced by __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::state_case_type().

◆ type_case_Z()

template<typename Character , typename OutputAdapter , typename ProcessorBase >
bool __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::type_case_Z ( )
throw (
)
inlineprivate

Definition at line 2362 of file corecrt_internal_stdio_output.h.

2363 {
2364 // This matches the representation of the Windows SDK types ANSI_STRING
2365 // and UNICODE_STRING, which represent a counted string.
2366 struct ansi_string
2367 {
2368 unsigned short _length;
2369 unsigned short _maximum_length;
2370 char* _buffer;
2371 };
2372
2373 ansi_string* string{};
2374 if (!this->template extract_argument_from_va_list<ansi_string*>(string))
2375 return false;
2376
2377 if (!should_format())
2378 return true;
2379
2380 if (!string || string->_buffer == nullptr)
2381 {
2382 _narrow_string = narrow_null_string();
2383 _string_length = static_cast<int>(strlen(_narrow_string));
2384 _string_is_wide = false;
2385 }
2386 else if (is_wide_character_specifier(_options, _format_char, _length))
2387 {
2388 _wide_string = reinterpret_cast<wchar_t*>(string->_buffer);
2389 _string_length = string->_length / static_cast<int>(sizeof(wchar_t));
2390 _string_is_wide = true;
2391 }
2392 else
2393 {
2394 _narrow_string = string->_buffer;
2395 _string_length = string->_length;
2396 _string_is_wide = false;
2397 }
2398
2399 return true;
2400 }
#define wchar_t
Definition: wchar.h:102

Referenced by __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::state_case_type().

◆ unset_flag()

template<typename Character , typename OutputAdapter , typename ProcessorBase >
void __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::unset_flag ( unsigned const  f)
throw (
)
inlineprivate

◆ wide_null_string()

template<typename Character , typename OutputAdapter , typename ProcessorBase >
static wchar_t *__cdecl __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::wide_null_string ( )
throw (
)
inlinestaticprivate

◆ write_stored_string_tchar() [1/2]

template<typename Character , typename OutputAdapter , typename ProcessorBase >
__forceinline bool __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::write_stored_string_tchar ( char  )
throw (
)
inlineprivate

Definition at line 2804 of file corecrt_internal_stdio_output.h.

2805 {
2806 if (!_string_is_wide || _string_length <= 0)
2807 {
2808 _output_adapter.write_string(_narrow_string, _string_length, &_characters_written, _ptd);
2809 }
2810 else
2811 {
2812 wchar_t* p{_wide_string};
2813 for (int i{0}; i != _string_length; ++i)
2814 {
2815 char local_buffer[MB_LEN_MAX + 1];
2816
2817 int mbc_length{0};
2818 errno_t const status{_wctomb_internal(&mbc_length, local_buffer, _countof(local_buffer), *p++, _ptd)};
2819 if (status != 0 || mbc_length == 0)
2820 {
2821 _characters_written = -1;
2822 return true;
2823 }
2824
2825 _output_adapter.write_string(local_buffer, mbc_length, &_characters_written, _ptd);
2826 }
2827 }
2828
2829 return true;
2830 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define MB_LEN_MAX
Definition: stdlib.h:19
#define _countof(array)
Definition: sndvol32.h:70

Referenced by __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::state_case_type().

◆ write_stored_string_tchar() [2/2]

template<typename Character , typename OutputAdapter , typename ProcessorBase >
__forceinline bool __crt_stdio_output::output_processor< Character, OutputAdapter, ProcessorBase >::write_stored_string_tchar ( wchar_t  )
throw (
)
inlineprivate

Definition at line 2832 of file corecrt_internal_stdio_output.h.

2833 {
2834 if (_string_is_wide || _string_length <= 0)
2835 {
2836 _output_adapter.write_string(_wide_string, _string_length, &_characters_written, _ptd);
2837 }
2838 else
2839 {
2840 _locale_t locale_ptr = _ptd.get_locale();
2841 char* p{_narrow_string};
2842 for (int i{0}; i != _string_length; ++i)
2843 {
2844 wchar_t wide_character{};
2845 int mbc_length{_mbtowc_internal(&wide_character, p, locale_ptr->locinfo->_public._locale_mb_cur_max, _ptd)};
2846
2847 if (mbc_length <= 0)
2848 {
2849 _characters_written = -1;
2850 return true;
2851 }
2852
2853 _output_adapter.write_character(wide_character, &_characters_written, _ptd);
2854 p += mbc_length;
2855 }
2856 }
2857
2858 return true;
2859 }
pthreadlocinfo locinfo
Definition: corecrt.h:23

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