private void ReadKeyValue() {
int ch = -1;
bool foundQuote = false;
int characters = 0;
SkipWhitespace();
while(true) {
ch = PeekChar();
if(!IsWhitespace(ch)) {
characters++;
}
if(!ConsumeAllKeyText && ch == '"') {
ReadChar();
if(!foundQuote && characters == 1) {
foundQuote = true;
continue;
}
else {
break;
}
}
if(foundQuote && EndOfLine(ch)) {
throw new IniException(this, "Expected closing quote (\")");
}
// Handle line continuation
if(lineContinuation && ch == '\\') {
StringBuilder buffer = new StringBuilder();
buffer.Append((char)ReadChar()); // append '\'
while(PeekChar() != '\n' && IsWhitespace(PeekChar())) {
if(PeekChar() != '\r') {
buffer.Append((char)ReadChar());
}
else {
ReadChar(); // consume '\r'
}
}
if(PeekChar() == '\n') {
// continue reading key value on next line
ReadChar();
continue;
}
else {
// Replace consumed characters
value.Append(buffer.ToString());
}
}
if(!ConsumeAllKeyText) {
// If accepting comments then don't consume as key value
if(acceptCommentAfterKey && IsComment(ch) && !foundQuote) {
break;
}
}
// Always break at end of line
if(EndOfLine(ch)) {
break;
}
value.Append((char)ReadChar());
}
if(!foundQuote) {
RemoveTrailingWhitespace(value);
}
}