src/lib/INIReader.cpp
branchv_0
changeset 26 b1f6fa3a6555
parent 25 b9067d2812e5
child 27 e9aad9dd823a
equal deleted inserted replaced
25:b9067d2812e5 26:b1f6fa3a6555
    35 	/** 
    35 	/** 
    36 	 * By default, we ignore all leading whitespace on continuing lines.
    36 	 * By default, we ignore all leading whitespace on continuing lines.
    37 	 * If there should be some spaces or tabs, they should be placed on the previous line before the „\“.
    37 	 * If there should be some spaces or tabs, they should be placed on the previous line before the „\“.
    38 	 * If a line break is desired, it should be written as \n (escaped) or the value should be quoted in " or '.
    38 	 * If a line break is desired, it should be written as \n (escaped) or the value should be quoted in " or '.
    39 	 * 
    39 	 * 
       
    40 	 * TODO: several options:
       
    41 	 *  - enabled, disabled
       
    42 	 *  - if disabled, then: keep backslash, trim backslash, escape backslash
       
    43 	 *    (keep requires support in some further unescaping phase, or it will cause an error)
       
    44 	 *  - keep or trim the line end
       
    45 	 *  - keep or trim the leading spaces
       
    46 	 *  - allow comments interleaved with continuing lines (the freaky systemd syntax)
       
    47 	 * 
    40 	 * Related specifications:
    48 	 * Related specifications:
    41 	 *  - https://docs.oracle.com/javase/8/docs/api/index.html?java/util/Properties.html
    49 	 *  - https://docs.oracle.com/javase/8/docs/api/index.html?java/util/Properties.html
       
    50 	 *  - https://www.freedesktop.org/software/systemd/man/systemd.syntax.html
    42 	 */
    51 	 */
    43 	bool trimLeadingSpacesOnContinuingLines = true;
    52 	bool trimLeadingSpacesOnContinuingLines = true;
    44 
    53 
    45 
    54 
    46 	/**
    55 	/**
   382 						readSpacesAndTabs();
   391 						readSpacesAndTabs();
   383 						event.comment = readUntil('\n', &found);
   392 						event.comment = readUntil('\n', &found);
   384 					} else if (ch == '\n') {
   393 					} else if (ch == '\n') {
   385 						get();
   394 						get();
   386 					} else {
   395 					} else {
       
   396 						// TODO: optional support for multiple tokens in a single entry?
       
   397 						// modes: array, concatenate
       
   398 						// some-array-1 = "item 1" "item 2" 'item 3' item 4
       
   399 						// some-array-2 = "item 1" "item 2" 'item 3' item_4 item_5
       
   400 						// some-bash-style-string-value = "this "will' be' concatenated → this will be concatenated
   387 						throw std::logic_error(std::string("unexpected content after the quoted value: key='") + fullKey + "' value='" + event.value + "'");
   401 						throw std::logic_error(std::string("unexpected content after the quoted value: key='") + fullKey + "' value='" + event.value + "'");
   388 					}
   402 					}
   389 				}
   403 				}
   390 
   404 
   391 				for (INIContentHandler* handler : handlers) handler->entry(event);
   405 				for (INIContentHandler* handler : handlers) handler->entry(event);