Ticket #8064: ini_parser.patch

File ini_parser.patch, 1.1 KB (added by stefan.jenisch@…, 10 years ago)

patch to allow inline comments in ini_parser.hpp

  • ini_parser.hpp

    old new  
    9191
    9292            // If line is non-empty
    9393            line = property_tree::detail::trim(line, stream.getloc());
     94
     95                        // Ignore comments by removing them
     96                        typename std::basic_string<Ch>::const_iterator first = line.begin();
     97                        typename std::basic_string<Ch>::const_iterator last = line.begin();
     98                        while (last != line.end() && *last != semicolon && *last != hash)
     99                                ++last;
     100                line = std::basic_string<Ch>(first, last);
     101                        std::cout << line << std::endl;
     102
    94103            if (!line.empty())
    95104            {
    96                 // Comment, section or key?
    97                 if (line[0] == semicolon || line[0] == hash)
    98                 {
    99                     // Ignore comments
    100                 }
    101                 else if (line[0] == lbracket)
     105                // Does the line contains a key ?
     106                if (line[0] == lbracket)
    102107                {
    103108                    // If the previous section was empty, drop it again.
    104109                    if (section && section->empty())