From bc18b60e1c99da706f0d766d26a067513172c7bf Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Fri, 21 Oct 2011 03:41:20 -0700 Subject: [PATCH] sqlite: use boost::trim for dequoting of std::string --- plugins/input/sqlite/sqlite_types.hpp | 31 ++------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/plugins/input/sqlite/sqlite_types.hpp b/plugins/input/sqlite/sqlite_types.hpp index df9bb16e0..ba06b0c18 100644 --- a/plugins/input/sqlite/sqlite_types.hpp +++ b/plugins/input/sqlite/sqlite_types.hpp @@ -32,6 +32,7 @@ // boost #include +#include // sqlite extern "C" { @@ -47,35 +48,7 @@ public: static void dequote(std::string & z) { - char quote = z[0]; - - if (quote=='[' || quote=='\'' || quote=='"' || quote=='`') - { - int iIn = 1; // Index of next byte to read from input - int iOut = 0; // Index of next byte to write to output - - // If the first byte was a '[', then the close-quote character is a ']' - if (quote == '[') - { - quote = ']'; - } - - while (z[iIn]) - { - if (z[iIn] == quote) - { - if (z[iIn+1] != quote) break; - z[iOut++] = quote; - iIn += 2; - } - else - { - z[iOut++] = z[iIn++]; - } - } - - z[iOut] = '\0'; - } + boost::algorithm::trim_if(z,boost::algorithm::is_any_of("[]'\"`")); } };