simdutf  5.2.8
Unicode at GB/s.
error.h
1 #ifndef SIMDUTF_ERROR_H
2 #define SIMDUTF_ERROR_H
3 namespace simdutf {
4 
5 enum error_code {
6  SUCCESS = 0,
7  HEADER_BITS, // Any byte must have fewer than 5 header bits.
8  TOO_SHORT, // The leading byte must be followed by N-1 continuation bytes, where N is the UTF-8 character length
9  // This is also the error when the input is truncated.
10  TOO_LONG, // We either have too many consecutive continuation bytes or the string starts with a continuation byte.
11  OVERLONG, // The decoded character must be above U+7F for two-byte characters, U+7FF for three-byte characters,
12  // and U+FFFF for four-byte characters.
13  TOO_LARGE, // The decoded character must be less than or equal to U+10FFFF,less than or equal than U+7F for ASCII OR less than equal than U+FF for Latin1
14  SURROGATE, // The decoded character must be not be in U+D800...DFFF (UTF-8 or UTF-32) OR
15  // a high surrogate must be followed by a low surrogate and a low surrogate must be preceded by a high surrogate (UTF-16) OR
16  // there must be no surrogate at all (Latin1)
17  INVALID_BASE64_CHARACTER, // Found a character that cannot be part of a valid base64 string.
18  BASE64_INPUT_REMAINDER, // The base64 input terminates with a single character, excluding padding (=).
19  OUTPUT_BUFFER_TOO_SMALL, // The provided buffer is too small.
20  OTHER // Not related to validation/transcoding.
21 };
22 
23 struct result {
24  error_code error;
25  size_t count; // In case of error, indicates the position of the error. In case of success, indicates the number of code units validated/written.
26 
27  simdutf_really_inline result() : error{error_code::SUCCESS}, count{0} {}
28 
29  simdutf_really_inline result(error_code _err, size_t _pos) : error{_err}, count{_pos} {}
30 };
31 
32 }
33 #endif