diff --git a/test/basic_structures.cpp b/test/basic_structures.cpp index 4a47e2fa..f9e60116 100644 --- a/test/basic_structures.cpp +++ b/test/basic_structures.cpp @@ -10,10 +10,5 @@ #include #include -#include - -typedef std::string::const_iterator base_iterator_type; -typedef boost::spirit::classic::position_iterator - iterator_type; - -template struct yaml::parser::basic_structures; +typedef std::string::const_iterator char_iterator_t; +template struct yaml::parser::basic_structures_t; diff --git a/test/block_style.cpp b/test/block_style.cpp index 887d37ae..65d9e16a 100644 --- a/test/block_style.cpp +++ b/test/block_style.cpp @@ -10,10 +10,5 @@ #include #include -#include - -typedef std::string::const_iterator base_iterator_type; -typedef boost::spirit::classic::position_iterator - iterator_type; - -template struct yaml::parser::block_styles; +typedef std::string::const_iterator char_iterator_t; +template struct yaml::parser::block_styles_t; diff --git a/test/characters.cpp b/test/characters.cpp index e371d289..5c7d46cf 100644 --- a/test/characters.cpp +++ b/test/characters.cpp @@ -10,10 +10,5 @@ #include #include -#include - -typedef std::string::const_iterator base_iterator_type; -typedef boost::spirit::classic::position_iterator - iterator_type; - -template struct yaml::parser::characters; +typedef std::string::const_iterator char_iterator_t; +template struct yaml::parser::characters_t; diff --git a/test/flow_style.cpp b/test/flow_style.cpp index 79812088..9c3de910 100644 --- a/test/flow_style.cpp +++ b/test/flow_style.cpp @@ -10,10 +10,5 @@ #include #include -#include - -typedef std::string::const_iterator base_iterator_type; -typedef boost::spirit::classic::position_iterator - iterator_type; - -template struct yaml::parser::flow_styles; +typedef std::string::const_iterator char_iterator_t; +template struct yaml::parser::flow_styles_t; diff --git a/test/stream.cpp b/test/stream.cpp index fdc3ede4..7def0acc 100644 --- a/test/stream.cpp +++ b/test/stream.cpp @@ -10,10 +10,5 @@ #include #include -#include - -typedef std::string::const_iterator base_iterator_type; -typedef boost::spirit::classic::position_iterator - iterator_type; - -template struct yaml::parser::stream; +typedef std::string::const_iterator char_iterator_t; +template struct yaml::parser::stream_t; diff --git a/yaml/parser/basic_structures.hpp b/yaml/parser/basic_structures.hpp index 6de0ccaa..b9133715 100644 --- a/yaml/parser/basic_structures.hpp +++ b/yaml/parser/basic_structures.hpp @@ -40,46 +40,48 @@ namespace yaml { namespace parser { { return os << (s == eoi_state_t::not_at_end ? "not_at_end" : "at_end"); } #endif - template - struct basic_structures + template + struct basic_structures_t { - explicit basic_structures (boost::phoenix::function const & error_handler); + using iterator_t = pos_iterator; - characters characters_; + explicit basic_structures_t (boost::phoenix::function const & error_handler); - qi::rule indent; // indent exactly n spaces - qi::rule indent_lt; // indent <= n spaces - qi::rule indent_le; // indent < n spaces - qi::rule separate_in_line; - qi::rule line_prefix; - qi::rule l_empty; - qi::rule b_l_folded; - qi::rule flow_folded; - qi::rule comment_text; - qi::rule s_b_comment; - qi::rule l_comment; - qi::rule s_l_comments; - qi::rule separate; - qi::rule> separate_lines; + characters_t characters_; - qi::rule> directive; - qi::rule reserved_directive; - qi::rule> yaml_directive; - qi::rule tag_directive; - qi::rule tag_handle; - qi::rule tag_prefix; + qi::rule indent; // indent exactly n spaces + qi::rule indent_lt; // indent <= n spaces + qi::rule indent_le; // indent < n spaces + qi::rule separate_in_line; + qi::rule line_prefix; + qi::rule l_empty; + qi::rule b_l_folded; + qi::rule flow_folded; + qi::rule comment_text; + qi::rule s_b_comment; + qi::rule l_comment; + qi::rule s_l_comments; + qi::rule separate; + qi::rule> separate_lines; + + qi::rule> directive; + qi::rule reserved_directive; + qi::rule> yaml_directive; + qi::rule tag_directive; + qi::rule tag_handle; + qi::rule tag_prefix; qi::rule< - Iterator, + iterator_t, ast::properties_t(int, context_t), qi::locals > properties; - qi::rule tag_property; - qi::rule anchor_property; - qi::rule anchor_name; + qi::rule tag_property; + qi::rule anchor_property; + qi::rule anchor_name; - qi::rule one_time_eoi; + qi::rule one_time_eoi; std::reference_wrapper const> error_handler_; }; diff --git a/yaml/parser/basic_structures_def.hpp b/yaml/parser/basic_structures_def.hpp index 0d4f19d6..acf06760 100644 --- a/yaml/parser/basic_structures_def.hpp +++ b/yaml/parser/basic_structures_def.hpp @@ -86,8 +86,8 @@ namespace yaml { namespace parser { } - template - basic_structures::basic_structures (boost::phoenix::function const & error_handler) + template + basic_structures_t::basic_structures_t (boost::phoenix::function const & error_handler) : error_handler_ (error_handler) { qi::attr_type attr; diff --git a/yaml/parser/block_styles.hpp b/yaml/parser/block_styles.hpp index a9fb53db..7ea34686 100644 --- a/yaml/parser/block_styles.hpp +++ b/yaml/parser/block_styles.hpp @@ -47,79 +47,81 @@ namespace yaml { namespace parser { #endif }; - template - struct block_styles + template + struct block_styles_t { - explicit block_styles (boost::phoenix::function const & error_handler); + using iterator_t = pos_iterator; - flow_styles flow_styles_; + explicit block_styles_t (boost::phoenix::function const & error_handler); + + flow_styles_t flow_styles_; qi::rule< - Iterator, + iterator_t, block_header_t(), qi::locals > block_header; - qi::rule indentation_indicator; - qi::rule chomping_indicator; - qi::rule chomped_empty; - qi::rule strip_empty; - qi::rule keep_empty; - qi::rule> trail_comments; + qi::rule indentation_indicator; + qi::rule chomping_indicator; + qi::rule chomped_empty; + qi::rule strip_empty; + qi::rule keep_empty; + qi::rule> trail_comments; qi::rule< - Iterator, + iterator_t, std::string(int), qi::locals > literal; - qi::rule literal_text; - qi::rule literal_next; - qi::rule literal_content; + qi::rule literal_text; + qi::rule literal_next; + qi::rule literal_content; qi::rule< - Iterator, + iterator_t, std::string(int), qi::locals > folded; - qi::rule folded_text; - qi::rule folded_lines; - qi::rule spaced_text; - qi::rule spaced; - qi::rule spaced_lines; - qi::rule same_lines; - qi::rule diff_lines; - qi::rule folded_content; + qi::rule folded_text; + qi::rule folded_lines; + qi::rule spaced_text; + qi::rule spaced; + qi::rule spaced_lines; + qi::rule same_lines; + qi::rule diff_lines; + qi::rule folded_content; - qi::rule auto_detect_indent; - qi::rule> block_sequence; - qi::rule block_seq_entry; - qi::rule> block_indented; - qi::rule compact_sequence; + qi::rule auto_detect_indent; + qi::rule> block_sequence; + qi::rule block_seq_entry; + qi::rule> block_indented; + qi::rule compact_sequence; - qi::rule> block_mapping; - qi::rule block_map_entry; - qi::rule block_map_explicit_entry; - qi::rule block_map_explicit_key; - qi::rule block_map_explicit_value; - qi::rule block_map_implicit_entry; - qi::rule block_map_implicit_key; - qi::rule> block_map_implicit_value; - qi::rule compact_mapping; + qi::rule> block_mapping; + qi::rule block_map_entry; + qi::rule block_map_explicit_entry; + qi::rule block_map_explicit_key; + qi::rule block_map_explicit_value; + qi::rule block_map_implicit_entry; + qi::rule block_map_implicit_key; + qi::rule> block_map_implicit_value; + qi::rule compact_mapping; - qi::rule block_node; - qi::rule> flow_in_block; - qi::rule block_in_block; + qi::rule block_node; + qi::rule> flow_in_block; + qi::rule block_in_block; qi::rule< - Iterator, + iterator_t, ast::value_t(int, context_t), qi::locals > block_scalar; qi::rule< - Iterator, + iterator_t, ast::value_t(int, context_t), qi::locals > block_collection; diff --git a/yaml/parser/block_styles_def.hpp b/yaml/parser/block_styles_def.hpp index 929097d1..6673fa89 100644 --- a/yaml/parser/block_styles_def.hpp +++ b/yaml/parser/block_styles_def.hpp @@ -50,8 +50,8 @@ namespace yaml { namespace parser { } - template - block_styles::block_styles (boost::phoenix::function const & error_handler) + template + block_styles_t::block_styles_t (boost::phoenix::function const & error_handler) : flow_styles_ (error_handler) { qi::attr_type attr; diff --git a/yaml/parser/characters.hpp b/yaml/parser/characters.hpp index e1325f6d..09ffb787 100644 --- a/yaml/parser/characters.hpp +++ b/yaml/parser/characters.hpp @@ -16,6 +16,7 @@ #include #include +#include #include @@ -90,21 +91,26 @@ namespace yaml { namespace parser { using uchar_t = boost::uint32_t; // Unicode code point - template - struct characters + template + using pos_iterator = boost::spirit::classic::position_iterator; + + template + struct characters_t { - characters (); + using iterator_t = pos_iterator; - qi::rule full_bom; + characters_t (); - qi::rule printable; - qi::rule nb_json; - qi::rule bom; - qi::rule nb_char; - qi::rule ns_char; - qi::rule uri_char; - qi::rule tag_char; - qi::rule esc_char; + qi::rule full_bom; + + qi::rule printable; + qi::rule nb_json; + qi::rule bom; + qi::rule nb_char; + qi::rule ns_char; + qi::rule uri_char; + qi::rule tag_char; + qi::rule esc_char; }; } } diff --git a/yaml/parser/characters_def.hpp b/yaml/parser/characters_def.hpp index 5d54d1dc..2d260033 100644 --- a/yaml/parser/characters_def.hpp +++ b/yaml/parser/characters_def.hpp @@ -69,8 +69,8 @@ namespace yaml { namespace parser { } - template - characters::characters () + template + characters_t::characters_t () { qi::byte_type byte_; qi::char_type char_; diff --git a/yaml/parser/error_handler.hpp b/yaml/parser/error_handler.hpp index 328f996b..cfd4d34c 100644 --- a/yaml/parser/error_handler.hpp +++ b/yaml/parser/error_handler.hpp @@ -67,27 +67,27 @@ namespace yaml { namespace parser { warning_fn_(msg); } - template + template void operator() ( - Iterator first, - Iterator last, - Iterator err_pos, + Iter first, + Iter last, + Iter err_pos, boost::spirit::info const & what ) const { - Iterator line_start = boost::spirit::get_line_start(first, err_pos); + Iter line_start = boost::spirit::get_line_start(first, err_pos); std::string error_line; if (line_start != last && *line_start == '\r') ++line_start; if (line_start != last && *line_start == '\n') ++line_start; - for (Iterator it = line_start; it != last; ++it) { - typename Iterator::value_type c = *it; + for (Iter it = line_start; it != last; ++it) { + typename Iter::value_type c = *it; if (c == '\r' || c == '\n') break; error_line += c; } - typename Iterator::position_t const pos = err_pos.get_position(); + typename Iter::position_t const pos = err_pos.get_position(); int const line = pos.line; int const column = pos.column; diff --git a/yaml/parser/flow_styles.hpp b/yaml/parser/flow_styles.hpp index 8b8742aa..903ceb4f 100644 --- a/yaml/parser/flow_styles.hpp +++ b/yaml/parser/flow_styles.hpp @@ -43,84 +43,86 @@ namespace yaml { namespace parser { } - template - struct flow_styles + template + struct flow_styles_t { - explicit flow_styles (boost::phoenix::function const & error_handler); + using iterator_t = pos_iterator; - basic_structures basic_structures_; + explicit flow_styles_t (boost::phoenix::function const & error_handler); + + basic_structures_t basic_structures_; qi::symbols anchors; - qi::rule alias_node; + qi::rule alias_node; - qi::rule nb_double_char; - qi::rule ns_double_char; - qi::rule double_quoted; - qi::rule double_text; - qi::rule double_escaped; - qi::rule double_break; - qi::rule double_in_line; - qi::rule double_next_line; - qi::rule double_multi_line; + qi::rule nb_double_char; + qi::rule ns_double_char; + qi::rule double_quoted; + qi::rule double_text; + qi::rule double_escaped; + qi::rule double_break; + qi::rule double_in_line; + qi::rule double_next_line; + qi::rule double_multi_line; - qi::rule nb_single_char; - qi::rule ns_single_char; - qi::rule single_quoted; - qi::rule single_text; - qi::rule single_in_line; - qi::rule single_next_line; - qi::rule single_multi_line; + qi::rule nb_single_char; + qi::rule ns_single_char; + qi::rule single_quoted; + qi::rule single_text; + qi::rule single_in_line; + qi::rule single_next_line; + qi::rule single_multi_line; - qi::rule plain_first; - qi::rule plain_safe; - qi::rule plain_char; - qi::rule plain; - qi::rule plain_in_line; - qi::rule plain_one_line; - qi::rule plain_next_line; - qi::rule plain_multi_line; + qi::rule plain_first; + qi::rule plain_safe; + qi::rule plain_char; + qi::rule plain; + qi::rule plain_in_line; + qi::rule plain_one_line; + qi::rule plain_next_line; + qi::rule plain_multi_line; - qi::rule flow_sequence; - qi::rule flow_seq_entries; - qi::rule flow_seq_entry; + qi::rule flow_sequence; + qi::rule flow_seq_entries; + qi::rule flow_seq_entry; - qi::rule flow_mapping; - qi::rule flow_map_entries; - qi::rule flow_map_entry; - qi::rule flow_map_explicit_entry; - qi::rule flow_map_implicit_entry; + qi::rule flow_mapping; + qi::rule flow_map_entries; + qi::rule flow_map_entry; + qi::rule flow_map_explicit_entry; + qi::rule flow_map_implicit_entry; - qi::rule flow_map_yaml_key_entry; - qi::rule flow_map_empty_key_entry; - qi::rule flow_map_separate_value; - qi::rule flow_map_json_key_entry; - qi::rule flow_map_adjacent_value; - qi::rule flow_pair; - qi::rule flow_pair_entry; - qi::rule flow_pair_yaml_key_entry; - qi::rule flow_pair_json_key_entry; - qi::rule implicit_yaml_key; - qi::rule implicit_json_key; + qi::rule flow_map_yaml_key_entry; + qi::rule flow_map_empty_key_entry; + qi::rule flow_map_separate_value; + qi::rule flow_map_json_key_entry; + qi::rule flow_map_adjacent_value; + qi::rule flow_pair; + qi::rule flow_pair_entry; + qi::rule flow_pair_yaml_key_entry; + qi::rule flow_pair_json_key_entry; + qi::rule implicit_yaml_key; + qi::rule implicit_json_key; - qi::rule flow_yaml_content; - qi::rule flow_json_content; - qi::rule flow_content; + qi::rule flow_yaml_content; + qi::rule flow_json_content; + qi::rule flow_content; qi::rule< - Iterator, + iterator_t, ast::value_t(int, context_t), qi::locals > flow_yaml_node; qi::rule< - Iterator, + iterator_t, ast::value_t(int, context_t), qi::locals > flow_json_node; qi::rule< - Iterator, + iterator_t, ast::value_t(int, context_t), qi::locals > flow_node; diff --git a/yaml/parser/flow_styles_def.hpp b/yaml/parser/flow_styles_def.hpp index b51c2845..fc2e1f3a 100644 --- a/yaml/parser/flow_styles_def.hpp +++ b/yaml/parser/flow_styles_def.hpp @@ -44,8 +44,8 @@ namespace yaml { namespace parser { } - template - flow_styles::flow_styles (boost::phoenix::function const & error_handler) + template + flow_styles_t::flow_styles_t (boost::phoenix::function const & error_handler) : basic_structures_ (error_handler) { qi::attr_type attr; diff --git a/yaml/parser/stream.hpp b/yaml/parser/stream.hpp index 4fca0cab..8b7114d6 100644 --- a/yaml/parser/stream.hpp +++ b/yaml/parser/stream.hpp @@ -20,27 +20,29 @@ namespace yaml { namespace parser { - template - struct stream + template + struct stream_t { - stream ( + using iterator_t = pos_iterator; + + stream_t ( std::string const & source_file, reporting_fn_t const & errors_callback, reporting_fn_t const & warnings_callback ); - block_styles block_styles_; + block_styles_t block_styles_; - qi::rule> document_prefix; - qi::rule> document_suffix; - qi::rule forbidden; - qi::rule bare_document; - qi::rule> explicit_document; - qi::rule directive_document; - qi::rule any_document; - qi::rule()> yaml_stream; + qi::rule> document_prefix; + qi::rule> document_suffix; + qi::rule forbidden; + qi::rule bare_document; + qi::rule> explicit_document; + qi::rule directive_document; + qi::rule any_document; + qi::rule()> yaml_stream; - qi::rule end_of_input; + qi::rule end_of_input; boost::phoenix::function const error_handler_; }; @@ -50,8 +52,8 @@ namespace yaml { namespace parser { #endif encoding_t read_bom (std::istream & is); - template - encoding_t read_bom (Iter & first, Iter last); + template + encoding_t read_bom (pos_iterator & first, pos_iterator last); #if YAML_HEADER_ONLY inline diff --git a/yaml/parser/stream_def.hpp b/yaml/parser/stream_def.hpp index 3e782869..94f53d4c 100644 --- a/yaml/parser/stream_def.hpp +++ b/yaml/parser/stream_def.hpp @@ -14,7 +14,6 @@ #include #include #include -#include namespace yaml { namespace parser { @@ -38,8 +37,8 @@ namespace yaml { namespace parser { } - template - stream::stream ( + template + stream_t::stream_t ( std::string const & source_file, reporting_fn_t const & errors_callback, reporting_fn_t const & warnings_callback @@ -223,10 +222,10 @@ namespace yaml { namespace parser { return retval; } - template - encoding_t read_bom (Iter & first, Iter last) + template + encoding_t read_bom (pos_iterator & first, pos_iterator last) { - Iter it = first; + pos_iterator it = first; int size = 0; char buf[4]; for (char & c : buf) { @@ -254,12 +253,10 @@ namespace yaml { namespace parser { ) { boost::optional> retval; - using base_iterator_type = std::string::const_iterator; - using iterator_type = boost::spirit::classic::position_iterator< - base_iterator_type - >; + using char_iterator_t = std::string::const_iterator; + using iterator_t = stream_t::iterator_t; - stream p( + stream_t p( source_file, errors_callback, warnings_callback @@ -272,11 +269,11 @@ namespace yaml { namespace parser { std::string contents; std::getline(is, contents, '\0'); - base_iterator_type sfirst(contents.begin()); - base_iterator_type slast(contents.end()); + char_iterator_t sfirst(contents.begin()); + char_iterator_t slast(contents.end()); - iterator_type first(sfirst, slast); - iterator_type last; + iterator_t first(sfirst, slast); + iterator_t last; first.set_tabchars(1); std::vector documents;