5 #ifndef YAML_PREFETCH_SIZE
6 #define YAML_PREFETCH_SIZE 2048
9 #define S_ARRAY_SIZE( A ) (sizeof(A)/sizeof(*(A)))
10 #define S_ARRAY_END( A ) ((A) + S_ARRAY_SIZE(A))
12 #define CP_REPLACEMENT_CHARACTER (0xFFFD)
96 {0, 1, 1, 0, 0, 0, 0, 1},
97 {0, 2, 2, 2, 2, 2, 2, 2},
98 {3, 3, 3, 3, 0, 3, 3, 3},
99 {4, 4, 4, 4, 4, 0, 4, 4},
100 {1, 1, 1, 1, 1, 1, 1, 1},
101 {1, 1, 1, 1, 1, 1, 1, 1},
102 {2, 2, 2, 2, 2, 0, 2, 2},
103 {2, 2, 2, 2, 0, 2, 2, 2},
104 {0, 1, 1, 1, 1, 1, 1, 1},
105 {0, 2, 2, 2, 2, 2, 2, 2},
106 {1, 1, 1, 1, 1, 1, 1, 1},
107 {1, 1, 1, 1, 1, 1, 1, 1},
108 {0, 2, 2, 2, 2, 2, 2, 2},
109 {0, 3, 3, 3, 3, 3, 3, 3},
110 {4, 4, 4, 4, 4, 4, 4, 4},
111 {2, 0, 2, 2, 2, 2, 2, 2},
112 {3, 3, 0, 3, 3, 3, 3, 3},
113 {1, 1, 1, 1, 1, 1, 1, 1},
118 if (std::istream::traits_type::eof() == ch) {
131 if ((ch > 0) && (ch < 0xFF)) {
138 inline char Utf8Adjust(
unsigned long ch,
unsigned char lead_bits,
unsigned char rshift)
140 const unsigned char header = ((1 << lead_bits) - 1) << (8 - lead_bits);
141 const unsigned char mask = (0xFF >> (lead_bits + 1));
142 return static_cast<char>(
static_cast<unsigned char>(
143 header | ((ch >> rshift) & mask)
151 if (
static_cast<unsigned long>(
Stream::eof()) == ch)
165 else if (ch < 0x10000)
183 m_nPrefetchedAvailable(0), m_nPrefetchedUsed(0)
185 typedef std::istream::traits_type char_traits;
192 char_traits::int_type intro[4];
196 std::istream::int_type ch = input.get();
197 intro[nIntroUsed++] = ch;
203 for(; nUngets > 0; --nUngets) {
204 if(char_traits::eof() != intro[--nIntroUsed])
205 input.putback(char_traits::to_char_type(intro[nIntroUsed]));
238 Stream::operator bool()
const
240 return m_input.good() || (!m_readahead.empty() && m_readahead[0] !=
Stream::eof());
321 unsigned long ch = 0;
322 unsigned char bytes[2];
331 ch = (
static_cast<unsigned long>(bytes[nBigEnd]) << 8) |
332 static_cast<unsigned long>(bytes[1 ^ nBigEnd]);
334 if (ch >= 0xDC00 && ch < 0xE000)
340 else if (ch >= 0xD800 && ch < 0xDC00)
356 unsigned long chLow = (
static_cast<unsigned long>(bytes[nBigEnd]) << 8) |
357 static_cast<unsigned long>(bytes[1 ^ nBigEnd]);
358 if (chLow < 0xDC00 || ch >= 0xE000)
364 if (chLow < 0xD800 || ch >= 0xE000)
383 ch |= (chLow & 0x3FF);
395 return reinterpret_cast<char*
>(pBuffer);
402 std::streambuf *pBuf =
m_input.rdbuf();
408 m_input.setstate(std::ios_base::eofbit);
422 static int indexes[2][4] = {
427 unsigned long ch = 0;
428 unsigned char bytes[4];
440 for (
int i = 0; i < 4; ++i)
443 ch |= bytes[pIndexes[i]];