From 61377c582e0f2675baa5f5e6e30a35d1a4164b33 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 1 May 2017 16:08:43 +0300 Subject: Add hxx extension for headers and lib prefix for library dir --- butl/string-parser.cxx | 132 ------------------------------------------------- 1 file changed, 132 deletions(-) delete mode 100644 butl/string-parser.cxx (limited to 'butl/string-parser.cxx') diff --git a/butl/string-parser.cxx b/butl/string-parser.cxx deleted file mode 100644 index 9228d66..0000000 --- a/butl/string-parser.cxx +++ /dev/null @@ -1,132 +0,0 @@ -// file : butl/string-parser.cxx -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#include - -#include // move() - -using namespace std; - -namespace butl -{ - // Utility functions - // - inline static bool - space (char c) noexcept - { - return c == ' ' || c == '\t'; - } - - // string_parser - // - vector> string_parser:: - parse_quoted_position (const string& s, bool unquote) - { - vector> r; - for (auto b (s.begin ()), i (b), e (s.end ()); i != e; ) - { - for (; i != e && space (*i); ++i) ; // Skip spaces. - - if (i == e) // No more strings. - break; - - string s; - char quoting ('\0'); // Current quoting mode, can be used as bool. - size_t pos (i - b); // String position. - - for (; i != e; ++i) - { - char c (*i); - - if (!quoting) - { - if (space (c)) // End of string. - break; - - if (c == '"' || c == '\'') // Begin of quoted substring. - { - quoting = c; - - if (!unquote) - s += c; - - continue; - } - } - else if (c == quoting) // End of quoted substring. - { - quoting = '\0'; - - if (!unquote) - s += c; - - continue; - } - - s += c; - } - - if (quoting) - throw invalid_string (i - b, "unterminated quoted string"); - - r.emplace_back (move (s), pos); - } - - return r; - } - - vector string_parser:: - parse_quoted (const string& s, bool unquote) - { - vector> sp (parse_quoted_position (s, unquote)); - - vector r; - r.reserve (sp.size ()); - for (auto& s: sp) - r.emplace_back (move (s.first)); - - return r; - } - - string string_parser:: - unquote (const string& s) - { - string r; - char quoting ('\0'); // Current quoting mode, can be used as bool. - - for (auto i (s.begin ()), e (s.end ()); i != e; ++i) - { - char c (*i); - - if (!quoting) - { - if (c == '"' || c == '\'') // Begin of quoted substring. - { - quoting = c; - continue; - } - } - else if (c == quoting) // End of quoted substring. - { - quoting = '\0'; - continue; - } - - r += c; - } - - return r; - } - - vector string_parser:: - unquote (const vector& v) - { - vector r; - r.reserve (v.size ()); - for (auto& s: v) - r.emplace_back (unquote (s)); - - return r; - } -} -- cgit v1.1