Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::client::utf8_char_parser Struct Reference
+ Inheritance diagram for Slic3r::client::utf8_char_parser:
+ Collaboration diagram for Slic3r::client::utf8_char_parser:

Classes

struct  attribute
 

Public Member Functions

template<typename Iterator , typename Context , typename Skipper , typename Attribute >
bool parse (Iterator &first, Iterator const &last, Context &context, Skipper const &skipper, Attribute &attr) const
 
template<typename Context >
spirit::info what (Context &) const
 

Detailed Description


Class Documentation

◆ Slic3r::client::utf8_char_parser::attribute

struct Slic3r::client::utf8_char_parser::attribute
template<typename Context, typename Iterator>
struct Slic3r::client::utf8_char_parser::attribute< Context, Iterator >
Class Members
typedef wchar_t type

Member Function Documentation

◆ parse()

template<typename Iterator , typename Context , typename Skipper , typename Attribute >
bool Slic3r::client::utf8_char_parser::parse ( Iterator first,
Iterator const last,
Context &  context,
Skipper const skipper,
Attribute &  attr 
) const
inline
1744 {
1745 // The skipper shall always be empty, any white space will be accepted.
1746 // skip_over(first, last, skipper);
1747 if (first == last)
1748 return false;
1749 // Iterator over the UTF-8 sequence.
1750 auto it = first;
1751 // Read the first byte of the UTF-8 sequence.
1752 unsigned char c = static_cast<boost::uint8_t>(*it ++);
1753 unsigned int cnt = 0;
1754 // UTF-8 sequence must not start with a continuation character:
1755 if ((c & 0xC0) == 0x80)
1756 goto err;
1757 // Skip high surrogate first if there is one.
1758 // If the most significant bit with a zero in it is in position
1759 // 8-N then there are N bytes in this UTF-8 sequence:
1760 {
1761 unsigned char mask = 0x80u;
1762 unsigned int result = 0;
1763 while (c & mask) {
1764 ++ result;
1765 mask >>= 1;
1766 }
1767 cnt = (result == 0) ? 1 : ((result > 4) ? 4 : result);
1768 }
1769 // Since we haven't read in a value, we need to validate the code points:
1770 for (-- cnt; cnt > 0; -- cnt) {
1771 if (it == last)
1772 goto err;
1773 c = static_cast<boost::uint8_t>(*it ++);
1774 // We must have a continuation byte:
1775 if (cnt > 1 && (c & 0xC0) != 0x80)
1776 goto err;
1777 }
1778 first = it;
1779 return true;
1780 err:
1781 MyContext::throw_exception("Invalid utf8 sequence", IteratorRange(first, last));
1782 return false;
1783 }
boost::iterator_range< Iterator > IteratorRange
Definition PlaceholderParser.cpp:172
static void throw_exception(const std::string &msg, const IteratorRange &it_range)
Definition PlaceholderParser.cpp:1558

References Slic3r::client::MyContext::throw_exception().

Referenced by Slic3r::client::ascii_char_skipper_parser::parse().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ what()

template<typename Context >
spirit::info Slic3r::client::utf8_char_parser::what ( Context &  ) const
inline
1788 {
1789 return spirit::info("unicode_char");
1790 }

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