src/lib/BackspaceUnescapingProcessor.h
branchv_0
changeset 29 06aaad12c207
parent 28 0e7c57d48d1e
equal deleted inserted replaced
28:0e7c57d48d1e 29:06aaad12c207
    28 namespace ini {
    28 namespace ini {
    29 namespace lib {
    29 namespace lib {
    30 
    30 
    31 class BackspaceUnescapingProcessor : public UnescapingProcessor {
    31 class BackspaceUnescapingProcessor : public UnescapingProcessor {
    32 private:
    32 private:
       
    33 	/**
       
    34 	 * By default it is set to true, thus no unrecognized escape sequences may left after this stage.
       
    35 	 * Setting this to false is dangerous and may lead to errors and ambiguous behavior.
       
    36 	 * It should be used only as a last resort.
       
    37 	 * Because both "\\ \xxx" and "\ \xxx" will be converted to "\ \xxx" and the information will be lost.
       
    38 	 * So, it is usually better to keep the "\" escaped as "\\" and process both the escaped backspaces and unrecognized escape sequences later.
       
    39 	 */
       
    40 
    33 	const bool lastEscaphingPhase = true;
    41 	const bool lastEscaphingPhase = true;
    34 public:
    42 public:
    35 
    43 
    36 	std::string unescape(const std::string& s, const TextType type) override {
    44 	std::string unescape(const std::string& s, const TextType type) override {
    37 		std::stringstream result;
    45 		std::stringstream result;
    49 			}
    57 			}
    50 		}
    58 		}
    51 		return result.str();
    59 		return result.str();
    52 	}
    60 	}
    53 
    61 
    54 	/**
       
    55 	 * @param lastEscaphingPhase whether this is final unescaping stage.
       
    56 	 * By default it is set to true, thus no unrecognized escape sequences may left after this stage.
       
    57 	 * Setting this to false is dangerous and may lead to errors and ambiguous behavior.
       
    58 	 * It should be used only as a last resort.
       
    59 	 * Because both "\\ \xxx" and "\ \xxx" will be converted to "\ \xxx" and the information will be lost.
       
    60 	 * So, it is usually better to keep the "\" escaped as "\\" and process both the escaped backspaces and unrecognized escape sequences later.
       
    61 	 */
       
    62 	BackspaceUnescapingProcessor(bool lastEscaphingPhase = true) : lastEscaphingPhase(lastEscaphingPhase) {
       
    63 	}
       
    64 
       
    65 };
    62 };
    66 
    63 
    67 }
    64 }
    68 }
    65 }
    69 }
    66 }