Helper class for checking UTF-8 byte sequence during parsing URI or incoming byte stream.
More...
#include <utf8_checker.hpp>
Helper class for checking UTF-8 byte sequence during parsing URI or incoming byte stream.
Definition at line 32 of file utf8_checker.hpp.
◆ state_t
Enumeration of all possible checker states.
Enumerator |
---|
wait_first_byte | |
wait_second_of_two | |
wait_second_of_three | |
wait_second_of_four | |
wait_third_of_three | |
wait_third_of_four | |
wait_fourth_of_four | |
invalid | |
Definition at line 35 of file utf8_checker.hpp.
◆ utf8_checker_t()
restinio::utils::utf8_checker_t::utf8_checker_t |
( |
| ) |
|
|
default |
◆ current_symbol()
std::uint32_t restinio::utils::utf8_checker_t::current_symbol |
( |
| ) |
const |
|
inlinenodiscardnoexcept |
Get the collected value of the current symbol.
- Note
- It returns the actual value only if:
Definition at line 342 of file utf8_checker.hpp.
◆ finalized()
bool restinio::utils::utf8_checker_t::finalized |
( |
| ) |
const |
|
inlinenodiscardnoexcept |
- Returns
- true if the current sequence finalized.
Definition at line 316 of file utf8_checker.hpp.
◆ on_first_byte()
void restinio::utils::utf8_checker_t::on_first_byte |
( |
std::uint8_t | byte | ) |
|
|
inlineprivatenoexcept |
◆ on_fourth_of_four()
void restinio::utils::utf8_checker_t::on_fourth_of_four |
( |
std::uint8_t | byte | ) |
|
|
inlineprivatenoexcept |
◆ on_second_of_four()
void restinio::utils::utf8_checker_t::on_second_of_four |
( |
std::uint8_t | byte | ) |
|
|
inlineprivatenoexcept |
◆ on_second_of_three()
void restinio::utils::utf8_checker_t::on_second_of_three |
( |
std::uint8_t | byte | ) |
|
|
inlineprivatenoexcept |
◆ on_second_of_two()
void restinio::utils::utf8_checker_t::on_second_of_two |
( |
std::uint8_t | byte | ) |
|
|
inlineprivatenoexcept |
◆ on_third_of_four()
void restinio::utils::utf8_checker_t::on_third_of_four |
( |
std::uint8_t | byte | ) |
|
|
inlineprivatenoexcept |
◆ on_third_of_three()
void restinio::utils::utf8_checker_t::on_third_of_three |
( |
std::uint8_t | byte | ) |
|
|
inlineprivatenoexcept |
◆ process_byte()
bool restinio::utils::utf8_checker_t::process_byte |
( |
std::uint8_t | byte | ) |
|
|
inlinenodiscardnoexcept |
Checks another byte.
- Note
- The actual value of the current symbol can be obtained only if process_byte() returns true and the subsequent call to finalized() returns true:
utf8checker_t checker;
for( const auto ch : some_string )
{
if( checker.process_byte() )
{
if( checker.finalized() )
process_unicode_symbol( checker.current_symbol() );
}
else
{
...
break;
}
}
- Return values
-
true | if the sequence is still valid and the next byte can be given to the next call to process_byte(). |
false | if the sequence is invalid an there is no sense to continue call process_byte(). |
Definition at line 271 of file utf8_checker.hpp.
◆ reset()
void restinio::utils::utf8_checker_t::reset |
( |
| ) |
|
|
inlinenoexcept |
◆ m_current_symbol
std::uint32_t restinio::utils::utf8_checker_t::m_current_symbol = 0u |
|
private |
The current UNICODE symbol.
Contains a valid value only if some bytes were successfully processed by process_byte() and the current state is wait_first_byte.
Definition at line 53 of file utf8_checker.hpp.
◆ m_state
The documentation for this class was generated from the following file: