6 #ifndef SPIRIT_PO_CATALOG_METADATA_HPP_INCLUDED
7 #define SPIRIT_PO_CATALOG_METADATA_HPP_INCLUDED
9 #ifndef BOOST_SPIRIT_USE_PHOENIX_V3
10 #define BOOST_SPIRIT_USE_PHOENIX_V3
15 #include <boost/spirit/include/qi.hpp>
16 #include <boost/fusion/include/std_pair.hpp>
21 namespace qi = boost::spirit::qi;
23 typedef unsigned int uint;
48 size_t idx = header.find(
label);
49 if (idx == std::string::npos) {
52 auto it = header.begin() + idx +
label.size();
53 while (it != header.end() && *it ==
' ') { ++it; }
56 while (
e != header.end() && *
e !=
'\n') { ++
e; }
57 return std::string(it,
e);
60 template <
typename Iterator>
65 main = qi::skip(
' ') [ lit(
"nplurals=") >> qi::uint_ >> lit(
';') >> lit(
"plural=") ] >> (*qi::char_);
69 #define SPIRIT_PO_DEFAULT_CHARSET "UTF-8"
71 template <
typename Iterator>
73 qi::rule<Iterator, std::string()>
main;
86 #undef SPIRIT_PO_DEFAULT_CHARSET
94 if (content_type_line.size()) {
95 auto it = content_type_line.begin();
96 auto end = content_type_line.end();
99 if (qi::parse(it, end, gram, ct)) {
102 return "PO file declared charset of '" +
charset +
"', but spirit_po only supports UTF-8 and ASCII for this.";
110 std::string content_transfer_encoding =
find_header_line(header,
"Content-Transfer-Encoding:");
111 if (content_transfer_encoding.size()) {
112 auto it = content_transfer_encoding.begin();
113 auto end = content_transfer_encoding.end();
114 if (!qi::phrase_parse(it, end, qi::lit(
"8bit"), qi::ascii::space)) {
115 return "PO header 'Content-Transfer-Encoding' must be '8bit' if specified, but PO file declared '" + content_transfer_encoding +
"'";
121 if (num_plurals_line.size()) {
122 auto it = num_plurals_line.begin();
123 auto end = num_plurals_line.end();
127 if (qi::parse(it, end, gram,
info)) {
std::string label
What to show in the filter's drop-down list.
std::string string_iterator_context(const std::string &str, std::string::const_iterator it)
std::pair< uint, std::string > num_plurals_info
qi::rule< Iterator, std::string()> main