From 0392694560d530c14aced7ac21f85b18b676a685 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 21 Feb 2012 22:30:21 +0000 Subject: Initial support to preserve ini file comments --- src/inistream.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/inistream.cc') diff --git a/src/inistream.cc b/src/inistream.cc index c89056f..7a73ea9 100644 --- a/src/inistream.cc +++ b/src/inistream.cc @@ -51,6 +51,9 @@ bool IniStream::getline(QTextStream &textstream) if (line[0] == '#' || line[0] == ';') { // line with comment + comment_next += line; + comment_next += '\n'; + } else { // section header if (line.size() > 2 && line.startsWith('[') && line.endsWith(']')) { @@ -61,6 +64,9 @@ bool IniStream::getline(QTextStream &textstream) section_current = section_current.trimmed(); section_current.toLower(); + comment_current = comment_next; + comment_next.clear(); + last_read_was_section = true; return true; } else { @@ -78,6 +84,9 @@ bool IniStream::getline(QTextStream &textstream) value_current.remove(0, key_current.size() + 1); value_current = value_current.trimmed(); + comment_current = comment_next; + comment_next.clear(); + last_read_was_key = true; return true; } -- cgit v1.2.3