OrcaSlicer latest
OrcaSlicer
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
2070 {
2071 // The skipper shall always be empty, any white space will be accepted.
2072 // skip_over(first, last, skipper);
2073 if (first == last)
2074 return false;
2075 // Iterator over the UTF-8 sequence.
2076 auto it = first;
2077 // Read the first byte of the UTF-8 sequence.
2078 unsigned char c = static_cast<boost::uint8_t>(*it ++);
2079 unsigned int cnt = 0;
2080 // UTF-8 sequence must not start with a continuation character:
2081 if ((c & 0xC0) == 0x80)
2082 goto err;
2083 // Skip high surrogate first if there is one.
2084 // If the most significant bit with a zero in it is in position
2085 // 8-N then there are N bytes in this UTF-8 sequence:
2086 {
2087 unsigned char mask = 0x80u;
2088 unsigned int result = 0;
2089 while (c & mask) {
2090 ++ result;
2091 mask >>= 1;
2092 }
2093 cnt = (result == 0) ? 1 : ((result > 4) ? 4 : result);
2094 }
2095 // Since we haven't read in a value, we need to validate the code points:
2096 for (-- cnt; cnt > 0; -- cnt) {
2097 if (it == last)
2098 goto err;
2099 c = static_cast<boost::uint8_t>(*it ++);
2100 // We must have a continuation byte:
2101 if (cnt > 1 && (c & 0xC0) != 0x80)
2102 goto err;
2103 }
2104 first = it;
2105 return true;
2106 err:
2107 MyContext::throw_exception(L("Invalid utf8 sequence"), IteratorRange(first, last));
2108 return false;
2109 }
#define L(s)
Definition ExtrusionEntity.cpp:25
boost::iterator_range< Iterator > IteratorRange
Definition PlaceholderParser.cpp:222
static void throw_exception(const std::string &msg, const IteratorRange &it_range)
Definition PlaceholderParser.cpp:1882

References L, and 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
2114 {
2115 return spirit::info("unicode_char");
2116 }

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